Skip to content

Commit 0b716f2

Browse files
authored
Merge branch 'RooVetGit:main' into feature/textToSpeech
2 parents da8a98c + 9dfdc42 commit 0b716f2

File tree

12 files changed

+551
-93
lines changed

12 files changed

+551
-93
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Update GitHub Actions workflow to automatically create and push git tags during release

.github/workflows/marketplace-publish.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ env:
1010
jobs:
1111
publish-extension:
1212
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write # Required for pushing tags
1315
if: >
1416
( github.event_name == 'pull_request' &&
1517
github.event.pull_request.base.ref == 'main' &&
@@ -23,24 +25,24 @@ jobs:
2325
- uses: actions/setup-node@v4
2426
with:
2527
node-version: 18
28+
2629
- run: |
2730
git config user.name github-actions
2831
git config user.email [email protected]
32+
2933
- name: Install Dependencies
3034
run: |
3135
npm install -g vsce ovsx
3236
npm run install:ci
37+
3338
- name: Create .env file
3439
run: |
3540
echo "# PostHog API Keys for telemetry" > .env
3641
echo "POSTHOG_API_KEY=${{ secrets.POSTHOG_API_KEY }}" >> .env
37-
- name: Package and Publish Extension
38-
env:
39-
VSCE_PAT: ${{ secrets.VSCE_PAT }}
40-
OVSX_PAT: ${{ secrets.OVSX_PAT }}
42+
43+
- name: Package Extension
4144
run: |
4245
current_package_version=$(node -p "require('./package.json').version")
43-
4446
npm run vsix
4547
package=$(unzip -l bin/roo-cline-${current_package_version}.vsix)
4648
echo "$package"
@@ -49,5 +51,18 @@ jobs:
4951
echo "$package" | grep -q "extension/node_modules/@vscode/codicons/dist/codicon.ttf" || exit 1
5052
echo "$package" | grep -q ".env" || exit 1
5153
54+
- name: Create and Push Git Tag
55+
run: |
56+
current_package_version=$(node -p "require('./package.json').version")
57+
git tag -a "v${current_package_version}" -m "Release v${current_package_version}"
58+
git push origin "v${current_package_version}"
59+
echo "Successfully created and pushed git tag v${current_package_version}"
60+
61+
- name: Publish Extension
62+
env:
63+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
64+
OVSX_PAT: ${{ secrets.OVSX_PAT }}
65+
run: |
66+
current_package_version=$(node -p "require('./package.json').version")
5267
npm run publish:marketplace
5368
echo "Successfully published version $current_package_version to VS Code Marketplace"

src/api/providers/__tests__/requesty.test.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ describe("RequestyHandler", () => {
2222
contextWindow: 4000,
2323
supportsPromptCache: false,
2424
supportsImages: true,
25-
inputPrice: 0,
26-
outputPrice: 0,
25+
inputPrice: 1,
26+
outputPrice: 10,
27+
cacheReadsPrice: 0.1,
28+
cacheWritesPrice: 1.5,
2729
},
2830
openAiStreamingEnabled: true,
2931
includeMaxTokens: true, // Add this to match the implementation
@@ -83,8 +85,12 @@ describe("RequestyHandler", () => {
8385
yield {
8486
choices: [{ delta: { content: " world" } }],
8587
usage: {
86-
prompt_tokens: 10,
87-
completion_tokens: 5,
88+
prompt_tokens: 30,
89+
completion_tokens: 10,
90+
prompt_tokens_details: {
91+
cached_tokens: 15,
92+
caching_tokens: 5,
93+
},
8894
},
8995
}
9096
},
@@ -105,10 +111,11 @@ describe("RequestyHandler", () => {
105111
{ type: "text", text: " world" },
106112
{
107113
type: "usage",
108-
inputTokens: 10,
109-
outputTokens: 5,
110-
cacheWriteTokens: undefined,
111-
cacheReadTokens: undefined,
114+
inputTokens: 30,
115+
outputTokens: 10,
116+
cacheWriteTokens: 5,
117+
cacheReadTokens: 15,
118+
totalCost: 0.000119, // (10 * 1 / 1,000,000) + (5 * 1.5 / 1,000,000) + (15 * 0.1 / 1,000,000) + (10 * 10 / 1,000,000)
112119
},
113120
])
114121

@@ -182,6 +189,9 @@ describe("RequestyHandler", () => {
182189
type: "usage",
183190
inputTokens: 10,
184191
outputTokens: 5,
192+
cacheWriteTokens: 0,
193+
cacheReadTokens: 0,
194+
totalCost: 0.00006, // (10 * 1 / 1,000,000) + (5 * 10 / 1,000,000)
185195
},
186196
])
187197

src/api/providers/openai.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
116116
}
117117
}
118118
if (chunk.usage) {
119-
yield this.processUsageMetrics(chunk.usage)
119+
yield this.processUsageMetrics(chunk.usage, modelInfo)
120120
}
121121
}
122122
} else {
@@ -139,11 +139,11 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
139139
type: "text",
140140
text: response.choices[0]?.message.content || "",
141141
}
142-
yield this.processUsageMetrics(response.usage)
142+
yield this.processUsageMetrics(response.usage, modelInfo)
143143
}
144144
}
145145

146-
protected processUsageMetrics(usage: any): ApiStreamUsageChunk {
146+
protected processUsageMetrics(usage: any, modelInfo?: ModelInfo): ApiStreamUsageChunk {
147147
return {
148148
type: "usage",
149149
inputTokens: usage?.prompt_tokens || 0,

src/api/providers/requesty.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
import axios from "axios"
22

33
import { ModelInfo, requestyModelInfoSaneDefaults, requestyDefaultModelId } from "../../shared/api"
4-
import { parseApiPrice } from "../../utils/cost"
4+
import { calculateApiCostOpenAI, parseApiPrice } from "../../utils/cost"
55
import { ApiStreamUsageChunk } from "../transform/stream"
66
import { OpenAiHandler, OpenAiHandlerOptions } from "./openai"
7+
import OpenAI from "openai"
8+
9+
// Requesty usage includes an extra field for Anthropic use cases.
10+
// Safely cast the prompt token details section to the appropriate structure.
11+
interface RequestyUsage extends OpenAI.CompletionUsage {
12+
prompt_tokens_details?: {
13+
caching_tokens?: number
14+
cached_tokens?: number
15+
}
16+
total_cost?: number
17+
}
718

819
export class RequestyHandler extends OpenAiHandler {
920
constructor(options: OpenAiHandlerOptions) {
@@ -27,13 +38,22 @@ export class RequestyHandler extends OpenAiHandler {
2738
}
2839
}
2940

30-
protected override processUsageMetrics(usage: any): ApiStreamUsageChunk {
41+
protected override processUsageMetrics(usage: any, modelInfo?: ModelInfo): ApiStreamUsageChunk {
42+
const requestyUsage = usage as RequestyUsage
43+
const inputTokens = requestyUsage?.prompt_tokens || 0
44+
const outputTokens = requestyUsage?.completion_tokens || 0
45+
const cacheWriteTokens = requestyUsage?.prompt_tokens_details?.caching_tokens || 0
46+
const cacheReadTokens = requestyUsage?.prompt_tokens_details?.cached_tokens || 0
47+
const totalCost = modelInfo
48+
? calculateApiCostOpenAI(modelInfo, inputTokens, outputTokens, cacheWriteTokens, cacheReadTokens)
49+
: 0
3150
return {
3251
type: "usage",
33-
inputTokens: usage?.prompt_tokens || 0,
34-
outputTokens: usage?.completion_tokens || 0,
35-
cacheWriteTokens: usage?.cache_creation_input_tokens,
36-
cacheReadTokens: usage?.cache_read_input_tokens,
52+
inputTokens: inputTokens,
53+
outputTokens: outputTokens,
54+
cacheWriteTokens: cacheWriteTokens,
55+
cacheReadTokens: cacheReadTokens,
56+
totalCost: totalCost,
3757
}
3858
}
3959
}

src/api/providers/vscode-lm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Anthropic } from "@anthropic-ai/sdk"
22
import * as vscode from "vscode"
33

44
import { SingleCompletionHandler } from "../"
5-
import { calculateApiCost } from "../../utils/cost"
5+
import { calculateApiCostAnthropic } from "../../utils/cost"
66
import { ApiStream } from "../transform/stream"
77
import { convertToVsCodeLmMessages } from "../transform/vscode-lm-format"
88
import { SELECTOR_SEPARATOR, stringifyVsCodeLmModelSelector } from "../../shared/vsCodeSelectorUtils"
@@ -462,7 +462,7 @@ export class VsCodeLmHandler extends BaseProvider implements SingleCompletionHan
462462
type: "usage",
463463
inputTokens: totalInputTokens,
464464
outputTokens: totalOutputTokens,
465-
totalCost: calculateApiCost(this.getModel().info, totalInputTokens, totalOutputTokens),
465+
totalCost: calculateApiCostAnthropic(this.getModel().info, totalInputTokens, totalOutputTokens),
466466
}
467467
} catch (error: unknown) {
468468
this.ensureCleanState()

src/core/Cline.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import { ClineAskResponse } from "../shared/WebviewMessage"
5555
import { GlobalFileNames } from "../shared/globalFileNames"
5656
import { defaultModeSlug, getModeBySlug, getFullModeDetails } from "../shared/modes"
5757
import { EXPERIMENT_IDS, experiments as Experiments, ExperimentId } from "../shared/experiments"
58-
import { calculateApiCost } from "../utils/cost"
58+
import { calculateApiCostAnthropic } from "../utils/cost"
5959
import { fileExistsAtPath } from "../utils/fs"
6060
import { arePathsEqual, getReadablePath } from "../utils/path"
6161
import { parseMentions } from "./mentions"
@@ -875,7 +875,7 @@ export class Cline {
875875
// The way this agentic loop works is that cline will be given a task that he then calls tools to complete. unless there's an attempt_completion call, we keep responding back to him with his tool's responses until he either attempt_completion or does not use anymore tools. If he does not use anymore tools, we ask him to consider if he's completed the task and then call attempt_completion, otherwise proceed with completing the task.
876876
// There is a MAX_REQUESTS_PER_TASK limit to prevent infinite requests, but Cline is prompted to finish the task as efficiently as he can.
877877

878-
//const totalCost = this.calculateApiCost(totalInputTokens, totalOutputTokens)
878+
//const totalCost = this.calculateApiCostAnthropic(totalInputTokens, totalOutputTokens)
879879
if (didEndLoop) {
880880
// For now a task never 'completes'. This will only happen if the user hits max requests and denies resetting the count.
881881
//this.say("task_completed", `Task completed. Total API usage cost: ${totalCost}`)
@@ -3173,7 +3173,7 @@ export class Cline {
31733173
cacheReads: cacheReadTokens,
31743174
cost:
31753175
totalCost ??
3176-
calculateApiCost(
3176+
calculateApiCostAnthropic(
31773177
this.api.getModel().info,
31783178
inputTokens,
31793179
outputTokens,
@@ -3798,6 +3798,8 @@ export class Cline {
37983798
return
37993799
}
38003800

3801+
telemetryService.captureCheckpointDiffed(this.taskId)
3802+
38013803
if (!previousCommitHash && mode === "checkpoint") {
38023804
const previousCheckpoint = this.clineMessages
38033805
.filter(({ say }) => say === "checkpoint_saved")
@@ -3849,6 +3851,8 @@ export class Cline {
38493851
return
38503852
}
38513853

3854+
telemetryService.captureCheckpointCreated(this.taskId)
3855+
38523856
// Start the checkpoint process in the background.
38533857
service.saveCheckpoint(`Task: ${this.taskId}, Time: ${Date.now()}`).catch((err) => {
38543858
console.error("[Cline#checkpointSave] caught unexpected error, disabling checkpoints", err)
@@ -3880,6 +3884,8 @@ export class Cline {
38803884
try {
38813885
await service.restoreCheckpoint(commitHash)
38823886

3887+
telemetryService.captureCheckpointRestored(this.taskId)
3888+
38833889
await this.providerRef.deref()?.postMessageToWebview({ type: "currentCheckpointUpdated", text: commitHash })
38843890

38853891
if (mode === "restore") {

src/core/webview/ClineProvider.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
18491849
fuzzyMatchThreshold,
18501850
experiments,
18511851
enableMcpServerCreation,
1852+
browserToolEnabled,
18521853
} = await this.getState()
18531854

18541855
// Create diffStrategy based on current model and settings
@@ -1864,10 +1865,14 @@ export class ClineProvider implements vscode.WebviewViewProvider {
18641865

18651866
const rooIgnoreInstructions = this.getCurrentCline()?.rooIgnoreController?.getInstructions()
18661867

1868+
// Determine if browser tools can be used based on model support and user settings
1869+
const modelSupportsComputerUse = this.getCurrentCline()?.api.getModel().info.supportsComputerUse ?? false
1870+
const canUseBrowserTool = modelSupportsComputerUse && (browserToolEnabled ?? true)
1871+
18671872
const systemPrompt = await SYSTEM_PROMPT(
18681873
this.context,
18691874
cwd,
1870-
apiConfiguration.openRouterModelInfo?.supportsComputerUse ?? false,
1875+
canUseBrowserTool,
18711876
mcpEnabled ? this.mcpHub : undefined,
18721877
diffStrategy,
18731878
browserViewportSize ?? "900x600",
@@ -2596,6 +2601,15 @@ export class ClineProvider implements vscode.WebviewViewProvider {
25962601
properties.apiProvider = apiConfiguration.apiProvider
25972602
}
25982603

2604+
// Add model ID if available
2605+
const currentCline = this.getCurrentCline()
2606+
if (currentCline?.api) {
2607+
const { id: modelId } = currentCline.api.getModel()
2608+
if (modelId) {
2609+
properties.modelId = modelId
2610+
}
2611+
}
2612+
25992613
return properties
26002614
}
26012615
}

0 commit comments

Comments
 (0)