From c47cb2878130309317593698753f74c6f99c8464 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" Date: Fri, 5 Jun 2026 03:21:15 +0000 Subject: [PATCH] chore: generate --- .../core/src/plugin/provider/snowflake-cortex.ts | 13 +++++++++---- .../plugin/provider-snowflake-cortex.test.ts | 16 ++++++++++++---- packages/opencode/src/provider/provider.ts | 9 ++++----- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/packages/core/src/plugin/provider/snowflake-cortex.ts b/packages/core/src/plugin/provider/snowflake-cortex.ts index 3493b976bd..8dcabf26b1 100644 --- a/packages/core/src/plugin/provider/snowflake-cortex.ts +++ b/packages/core/src/plugin/provider/snowflake-cortex.ts @@ -24,7 +24,11 @@ export function cortexFetch(upstream: FetchLike = fetch) { if (!response.ok && response.status === 400) { try { const errorData = (await response.clone().json()) as Record - if (String(errorData.message || errorData.error || "").toLowerCase().includes("conversation complete")) { + if ( + String(errorData.message || errorData.error || "") + .toLowerCase() + .includes("conversation complete") + ) { return new Response( JSON.stringify({ choices: [{ finish_reason: "stop", message: { content: "", role: "assistant" } }] }), { status: 200, headers: new Headers({ "content-type": "application/json" }) }, @@ -45,7 +49,9 @@ export function cortexFetch(upstream: FetchLike = fetch) { ctrl.close() return } - ctrl.enqueue(encoder.encode(decoder.decode(value, { stream: true }).replace(/"role"\s*:\s*""/g, '"role":"assistant"'))) + ctrl.enqueue( + encoder.encode(decoder.decode(value, { stream: true }).replace(/"role"\s*:\s*""/g, '"role":"assistant"')), + ) }, cancel() { reader.cancel() @@ -65,8 +71,7 @@ export const SnowflakeCortexPlugin = PluginV2.define({ "aisdk.sdk": Effect.fn(function* (evt) { if (evt.model.providerID !== ProviderV2.ID.make("snowflake-cortex")) return const pat = - process.env.SNOWFLAKE_CORTEX_PAT ?? - (typeof evt.options.apiKey === "string" ? evt.options.apiKey : undefined) + process.env.SNOWFLAKE_CORTEX_PAT ?? (typeof evt.options.apiKey === "string" ? evt.options.apiKey : undefined) const upstream = typeof evt.options.fetch === "function" ? (evt.options.fetch as FetchLike) : undefined if (evt.options.includeUsage !== false) evt.options.includeUsage = true const mod = yield* Effect.promise(() => import("@ai-sdk/openai-compatible")) diff --git a/packages/core/test/plugin/provider-snowflake-cortex.test.ts b/packages/core/test/plugin/provider-snowflake-cortex.test.ts index cec25dbf05..f702945978 100644 --- a/packages/core/test/plugin/provider-snowflake-cortex.test.ts +++ b/packages/core/test/plugin/provider-snowflake-cortex.test.ts @@ -173,10 +173,18 @@ describe("cortexFetch", () => { bun_it("rewrites role:'' to role:'assistant' in streaming SSE chunks", async () => { const chunk = `data: {"choices":[{"delta":{"role":"","content":"Hi"},"index":0}]}\n\n` const upstream: FetchLike = async () => - new Response(new ReadableStream({ start: (ctrl) => { ctrl.enqueue(new TextEncoder().encode(chunk)); ctrl.close() } }), { - status: 200, - headers: { "content-type": "text/event-stream" }, - }) + new Response( + new ReadableStream({ + start: (ctrl) => { + ctrl.enqueue(new TextEncoder().encode(chunk)) + ctrl.close() + }, + }), + { + status: 200, + headers: { "content-type": "text/event-stream" }, + }, + ) const response = await cortexFetch(upstream)("https://test", {}) const text = await response.text() expect(text).toContain('"role":"assistant"') diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts index e329b10192..2142f84340 100644 --- a/packages/opencode/src/provider/provider.ts +++ b/packages/opencode/src/provider/provider.ts @@ -860,10 +860,7 @@ function custom(dep: CustomDep): Record { (auth?.type === "api" ? auth.metadata?.account : undefined) ?? input.options?.account - const pat = - env["SNOWFLAKE_CORTEX_PAT"] ?? - (auth?.type === "api" ? auth.key : undefined) ?? - input.options?.apiKey + const pat = env["SNOWFLAKE_CORTEX_PAT"] ?? (auth?.type === "api" ? auth.key : undefined) ?? input.options?.apiKey if (!account || !pat) { const missing = [!account && "SNOWFLAKE_ACCOUNT", !pat && "SNOWFLAKE_CORTEX_PAT"].filter(Boolean).join(", ") @@ -905,7 +902,9 @@ function custom(dep: CustomDep): Record { const errorMessage = String(errorData.message || errorData.error || "") if (errorMessage.toLowerCase().includes("conversation complete")) { return new Response( - JSON.stringify({ choices: [{ finish_reason: "stop", message: { content: "", role: "assistant" } }] }), + JSON.stringify({ + choices: [{ finish_reason: "stop", message: { content: "", role: "assistant" } }], + }), { status: 200, headers: new Headers({ "content-type": "application/json" }) }, ) }