Skip to content

Commit b2b4f64

Browse files
authored
Pass app version to provider (#9730)
1 parent ba7340f commit b2b4f64

File tree

2 files changed

+55
-15
lines changed

2 files changed

+55
-15
lines changed

src/api/providers/__tests__/roo.spec.ts

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,11 @@ describe("RooHandler", () => {
304304
expect.objectContaining({ role: "user", content: "Second message" }),
305305
]),
306306
}),
307-
undefined,
307+
expect.objectContaining({
308+
headers: expect.objectContaining({
309+
"X-Roo-App-Version": expect.any(String),
310+
}),
311+
}),
308312
)
309313
})
310314
})
@@ -469,7 +473,11 @@ describe("RooHandler", () => {
469473
expect.objectContaining({
470474
temperature: 0.7,
471475
}),
472-
undefined,
476+
expect.objectContaining({
477+
headers: expect.objectContaining({
478+
"X-Roo-App-Version": expect.any(String),
479+
}),
480+
}),
473481
)
474482
})
475483

@@ -487,7 +495,11 @@ describe("RooHandler", () => {
487495
expect.objectContaining({
488496
temperature: 0.9,
489497
}),
490-
undefined,
498+
expect.objectContaining({
499+
headers: expect.objectContaining({
500+
"X-Roo-App-Version": expect.any(String),
501+
}),
502+
}),
491503
)
492504
})
493505

@@ -572,7 +584,11 @@ describe("RooHandler", () => {
572584
stream_options: { include_usage: true },
573585
reasoning: { enabled: false },
574586
}),
575-
undefined,
587+
expect.objectContaining({
588+
headers: expect.objectContaining({
589+
"X-Roo-App-Version": expect.any(String),
590+
}),
591+
}),
576592
)
577593
})
578594

@@ -590,7 +606,11 @@ describe("RooHandler", () => {
590606
expect.objectContaining({
591607
reasoning: { enabled: false },
592608
}),
593-
undefined,
609+
expect.objectContaining({
610+
headers: expect.objectContaining({
611+
"X-Roo-App-Version": expect.any(String),
612+
}),
613+
}),
594614
)
595615
})
596616

@@ -608,7 +628,11 @@ describe("RooHandler", () => {
608628
expect.objectContaining({
609629
reasoning: { enabled: true, effort: "low" },
610630
}),
611-
undefined,
631+
expect.objectContaining({
632+
headers: expect.objectContaining({
633+
"X-Roo-App-Version": expect.any(String),
634+
}),
635+
}),
612636
)
613637
})
614638

@@ -626,7 +650,11 @@ describe("RooHandler", () => {
626650
expect.objectContaining({
627651
reasoning: { enabled: true, effort: "medium" },
628652
}),
629-
undefined,
653+
expect.objectContaining({
654+
headers: expect.objectContaining({
655+
"X-Roo-App-Version": expect.any(String),
656+
}),
657+
}),
630658
)
631659
})
632660

@@ -644,7 +672,11 @@ describe("RooHandler", () => {
644672
expect.objectContaining({
645673
reasoning: { enabled: true, effort: "high" },
646674
}),
647-
undefined,
675+
expect.objectContaining({
676+
headers: expect.objectContaining({
677+
"X-Roo-App-Version": expect.any(String),
678+
}),
679+
}),
648680
)
649681
})
650682

@@ -679,7 +711,11 @@ describe("RooHandler", () => {
679711
expect.objectContaining({
680712
reasoning: { enabled: false },
681713
}),
682-
undefined,
714+
expect.objectContaining({
715+
headers: expect.objectContaining({
716+
"X-Roo-App-Version": expect.any(String),
717+
}),
718+
}),
683719
)
684720
})
685721
})

src/api/providers/roo.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import OpenAI from "openai"
44
import { rooDefaultModelId, getApiProtocol, type ImageGenerationApiMethod } from "@roo-code/types"
55
import { CloudService } from "@roo-code/cloud"
66

7+
import { Package } from "../../shared/package"
78
import type { ApiHandlerOptions, ModelRecord } from "../../shared/api"
89
import { ApiStream } from "../transform/stream"
910
import { getModelParams } from "../transform/model-params"
@@ -121,12 +122,15 @@ export class RooHandler extends BaseOpenAiCompatibleProvider<string> {
121122
metadata?: ApiHandlerCreateMessageMetadata,
122123
): ApiStream {
123124
try {
124-
const stream = await this.createStream(
125-
systemPrompt,
126-
messages,
127-
metadata,
128-
metadata?.taskId ? { headers: { "X-Roo-Task-ID": metadata.taskId } } : undefined,
129-
)
125+
const headers: Record<string, string> = {
126+
"X-Roo-App-Version": Package.version,
127+
}
128+
129+
if (metadata?.taskId) {
130+
headers["X-Roo-Task-ID"] = metadata.taskId
131+
}
132+
133+
const stream = await this.createStream(systemPrompt, messages, metadata, { headers })
130134

131135
let lastUsage: RooUsage | undefined = undefined
132136

0 commit comments

Comments
 (0)