Skip to content

Commit 33d63bb

Browse files
Merge branch 'dev' into dev
2 parents 6e945e5 + 9b805e1 commit 33d63bb

115 files changed

Lines changed: 4622 additions & 3102 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/VOUCHED.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@
1010
adamdotdevin
1111
-agusbasari29 AI PR slop
1212
ariane-emory
13+
-danieljoshuanazareth
1314
edemaine
1415
-florianleibert
1516
fwang
1617
iamdavidhill
1718
jayair
1819
kitlangton
1920
kommander
21+
-opencode2026
2022
r44vc0rp
2123
rekram1-node
2224
-spider-yamet clawdbot/llm psychosis, spam pinging the team
2325
thdxr
24-
-OpenCode2026
26+
-danieljoshuanazareth

bun.lock

Lines changed: 15 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/hashes.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"nodeModules": {
3-
"x86_64-linux": "sha256-Gv0pHYCinlj0SQXRQ/a9ozYPxECwdrC99ssTzpeOr1I=",
4-
"aarch64-linux": "sha256-WzVt5goOrxoGe26juzRf73PWPqwnB1URu2TYjxye/Aw=",
5-
"aarch64-darwin": "sha256-18Nn0TR1wK2gRUF/FFP4vFMY/td49XkfjOwFbD5iJNc=",
6-
"x86_64-darwin": "sha256-zk2yaulPzUUiCerCPJaCOCLhklXKMp9mSv7v0N8AMfA="
3+
"x86_64-linux": "sha256-P0RJfQF8APTYVGP6hLJRrOkRSl5nVDNxdcGcZECPPJE=",
4+
"aarch64-linux": "sha256-ZtMjTcd35X3JhJIdn3DilFsp7i/IZIcNaKZFnSzW/nk=",
5+
"aarch64-darwin": "sha256-Uw/okFDRxxKQMfEsj8MXuHyhpugxZGgIKtu89Getlz8=",
6+
"x86_64-darwin": "sha256-ZySIgT1HbWZWnaQ0W0eURKC43BTupRmmply92JDFPWA="
77
}
88
}

packages/console/app/src/routes/zen/util/handler.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ import {
2424
FreeUsageLimitError,
2525
SubscriptionUsageLimitError,
2626
} from "./error"
27-
import { createBodyConverter, createStreamPartConverter, createResponseConverter, UsageInfo } from "./provider/provider"
27+
import {
28+
buildCostChunk,
29+
createBodyConverter,
30+
createStreamPartConverter,
31+
createResponseConverter,
32+
UsageInfo,
33+
} from "./provider/provider"
2834
import { anthropicHelper } from "./provider/anthropic"
2935
import { googleHelper } from "./provider/google"
3036
import { openaiHelper } from "./provider/openai"
@@ -90,7 +96,7 @@ export async function handler(
9096
const projectId = input.request.headers.get("x-opencode-project") ?? ""
9197
const ocClient = input.request.headers.get("x-opencode-client") ?? ""
9298
logger.metric({
93-
is_tream: isStream,
99+
is_stream: isStream,
94100
session: sessionId,
95101
request: requestId,
96102
client: ocClient,
@@ -230,7 +236,7 @@ export async function handler(
230236
const body = JSON.stringify(
231237
responseConverter({
232238
...json,
233-
cost: calculateOccuredCost(billingSource, costInfo),
239+
cost: calculateOccurredCost(billingSource, costInfo),
234240
}),
235241
)
236242
logger.metric({ response_length: body.length })
@@ -274,8 +280,8 @@ export async function handler(
274280
await trialLimiter?.track(usageInfo)
275281
await trackUsage(sessionId, billingSource, authInfo, modelInfo, providerInfo, usageInfo, costInfo)
276282
await reload(billingSource, authInfo, costInfo)
277-
const cost = calculateOccuredCost(billingSource, costInfo)
278-
c.enqueue(encoder.encode(usageParser.buidlCostChunk(cost)))
283+
const cost = calculateOccurredCost(billingSource, costInfo)
284+
c.enqueue(encoder.encode(buildCostChunk(opts.format, cost)))
279285
}
280286
c.close()
281287
return
@@ -818,7 +824,7 @@ export async function handler(
818824
}
819825
}
820826

821-
function calculateOccuredCost(billingSource: BillingSource, costInfo: CostInfo) {
827+
function calculateOccurredCost(billingSource: BillingSource, costInfo: CostInfo) {
822828
return billingSource === "balance" ? (costInfo.totalCostInCent / 100).toFixed(8) : "0"
823829
}
824830

packages/console/app/src/routes/zen/util/provider/anthropic.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const anthropicHelper: ProviderHelper = ({ reqModel, providerModel }) =>
2020
const isBedrockModelArn = providerModel.startsWith("arn:aws:bedrock:")
2121
const isBedrockModelID = providerModel.startsWith("global.anthropic.")
2222
const isBedrock = isBedrockModelArn || isBedrockModelID
23+
const isDatabricks = providerModel.startsWith("databricks-claude-")
2324
const supports1m = reqModel.includes("sonnet") || reqModel.includes("opus-4-6")
2425
return {
2526
format: "anthropic",
@@ -28,7 +29,7 @@ export const anthropicHelper: ProviderHelper = ({ reqModel, providerModel }) =>
2829
? `${providerApi}/model/${isBedrockModelArn ? encodeURIComponent(providerModel) : providerModel}/${isStream ? "invoke-with-response-stream" : "invoke"}`
2930
: providerApi + "/messages",
3031
modifyHeaders: (headers: Headers, body: Record<string, any>, apiKey: string) => {
31-
if (isBedrock) {
32+
if (isBedrock || isDatabricks) {
3233
headers.set("Authorization", `Bearer ${apiKey}`)
3334
} else {
3435
headers.set("x-api-key", apiKey)
@@ -47,9 +48,14 @@ export const anthropicHelper: ProviderHelper = ({ reqModel, providerModel }) =>
4748
model: undefined,
4849
stream: undefined,
4950
}
50-
: {
51-
service_tier: "standard_only",
52-
}),
51+
: isDatabricks
52+
? {
53+
anthropic_version: "bedrock-2023-05-31",
54+
anthropic_beta: supports1m ? ["context-1m-2025-08-07"] : undefined,
55+
}
56+
: {
57+
service_tier: "standard_only",
58+
}),
5359
}),
5460
createBinaryStreamDecoder: () => {
5561
if (!isBedrock) return undefined
@@ -167,7 +173,6 @@ export const anthropicHelper: ProviderHelper = ({ reqModel, providerModel }) =>
167173
}
168174
},
169175
retrieve: () => usage,
170-
buidlCostChunk: (cost: string) => `event: ping\ndata: ${JSON.stringify({ type: "ping", cost })}\n\n`,
171176
}
172177
},
173178
normalizeUsage: (usage: Usage) => ({

packages/console/app/src/routes/zen/util/provider/google.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ export const googleHelper: ProviderHelper = ({ providerModel }) => ({
5656
usage = json.usageMetadata
5757
},
5858
retrieve: () => usage,
59-
buidlCostChunk: (cost: string) => `data: ${JSON.stringify({ type: "ping", cost })}\n\n`,
6059
}
6160
},
6261
normalizeUsage: (usage: Usage) => {

packages/console/app/src/routes/zen/util/provider/openai-compatible.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export const oaCompatHelper: ProviderHelper = () => ({
5454
usage = json.usage
5555
},
5656
retrieve: () => usage,
57-
buidlCostChunk: (cost: string) => `data: ${JSON.stringify({ choices: [], cost })}\n\n`,
5857
}
5958
},
6059
normalizeUsage: (usage: Usage) => {

packages/console/app/src/routes/zen/util/provider/openai.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export const openaiHelper: ProviderHelper = () => ({
4444
usage = json.response.usage
4545
},
4646
retrieve: () => usage,
47-
buidlCostChunk: (cost: string) => `event: ping\ndata: ${JSON.stringify({ type: "ping", cost })}\n\n`,
4847
}
4948
},
5049
normalizeUsage: (usage: Usage) => {

packages/console/app/src/routes/zen/util/provider/provider.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export type ProviderHelper = (input: { reqModel: string; providerModel: string }
4343
createUsageParser: () => {
4444
parse: (chunk: string) => void
4545
retrieve: () => any
46-
buidlCostChunk: (cost: string) => string
4746
}
4847
normalizeUsage: (usage: any) => UsageInfo
4948
}
@@ -162,6 +161,19 @@ export interface CommonChunk {
162161
}
163162
}
164163

164+
export function buildCostChunk(format: ZenData.Format, cost: string): string {
165+
switch (format) {
166+
case "anthropic":
167+
return `event: ping\ndata: ${JSON.stringify({ type: "ping", cost })}\n\n`
168+
case "openai":
169+
return `event: ping\ndata: ${JSON.stringify({ type: "ping", cost })}\n\n`
170+
case "oa-compat":
171+
return `data: ${JSON.stringify({ choices: [], cost })}\n\n`
172+
default:
173+
return `data: ${JSON.stringify({ type: "ping", cost })}\n\n`
174+
}
175+
}
176+
165177
export function createBodyConverter(from: ZenData.Format, to: ZenData.Format) {
166178
return (body: any): any => {
167179
if (from === to) return body

packages/opencode/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@
9090
"@aws-sdk/credential-providers": "3.993.0",
9191
"@clack/prompts": "1.0.0-alpha.1",
9292
"@effect/platform-node": "catalog:",
93-
"@gitlab/gitlab-ai-provider": "3.6.0",
94-
"@gitlab/opencode-gitlab-auth": "1.3.3",
9593
"@hono/standard-validator": "0.1.5",
9694
"@hono/zod-validator": "catalog:",
9795
"@modelcontextprotocol/sdk": "1.25.2",
@@ -123,6 +121,7 @@
123121
"drizzle-orm": "catalog:",
124122
"effect": "catalog:",
125123
"fuzzysort": "3.1.0",
124+
"gitlab-ai-provider": "5.2.2",
126125
"glob": "13.0.5",
127126
"google-auth-library": "10.5.0",
128127
"gray-matter": "4.0.3",
@@ -133,6 +132,7 @@
133132
"mime-types": "3.0.2",
134133
"minimatch": "10.0.3",
135134
"open": "10.1.2",
135+
"opencode-gitlab-auth": "2.0.0",
136136
"opentui-spinner": "0.0.6",
137137
"partial-json": "0.1.7",
138138
"remeda": "catalog:",

0 commit comments

Comments
 (0)