diff options
| author | Aiden Cline <[email protected]> | 2026-03-27 15:24:30 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-03-27 15:24:30 -0500 |
| commit | c33d9996f0e630d15b6e40b9a1feb578e991561a (patch) | |
| tree | 9cadd3b59c7467843680fdbca35184233060ddda /patches | |
| parent | 7a7643c86a69edbd79f99b0c4f613463627f2428 (diff) | |
| download | opencode-c33d9996f0e630d15b6e40b9a1feb578e991561a.tar.gz opencode-c33d9996f0e630d15b6e40b9a1feb578e991561a.zip | |
feat: AI SDK v6 support (#18433)
Diffstat (limited to 'patches')
| -rw-r--r-- | patches/@ai-sdk%[email protected] | 119 | ||||
| -rw-r--r-- | patches/@ai-sdk%[email protected] | 61 | ||||
| -rw-r--r-- | patches/@ai-sdk%[email protected] | 108 | ||||
| -rw-r--r-- | patches/@openrouter%[email protected] | 128 |
4 files changed, 180 insertions, 236 deletions
diff --git a/patches/@ai-sdk%[email protected] b/patches/@ai-sdk%[email protected] new file mode 100644 index 000000000..b8c2f387d --- /dev/null +++ b/patches/@ai-sdk%[email protected] @@ -0,0 +1,119 @@ +--- a/dist/index.js ++++ b/dist/index.js +@@ -3155,15 +3155,6 @@ + }); + } + baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0); +- } else { +- if (topP != null && temperature != null) { +- warnings.push({ +- type: "unsupported", +- feature: "topP", +- details: `topP is not supported when temperature is set. topP is ignored.` +- }); +- baseArgs.top_p = void 0; +- } + } + if (isKnownModel && baseArgs.max_tokens > maxOutputTokensForModel) { + if (maxOutputTokens != null) { +@@ -5180,4 +5171,4 @@ + createAnthropic, + forwardAnthropicContainerIdFromLastStep + }); +-//# sourceMappingURL=index.js.map +\ No newline at end of file ++//# sourceMappingURL=index.js.map +--- a/dist/index.mjs ++++ b/dist/index.mjs +@@ -3192,15 +3192,6 @@ + }); + } + baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0); +- } else { +- if (topP != null && temperature != null) { +- warnings.push({ +- type: "unsupported", +- feature: "topP", +- details: `topP is not supported when temperature is set. topP is ignored.` +- }); +- baseArgs.top_p = void 0; +- } + } + if (isKnownModel && baseArgs.max_tokens > maxOutputTokensForModel) { + if (maxOutputTokens != null) { +@@ -5256,4 +5247,4 @@ + createAnthropic, + forwardAnthropicContainerIdFromLastStep + }; +-//# sourceMappingURL=index.mjs.map +\ No newline at end of file ++//# sourceMappingURL=index.mjs.map +--- a/dist/internal/index.js ++++ b/dist/internal/index.js +@@ -3147,15 +3147,6 @@ + }); + } + baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0); +- } else { +- if (topP != null && temperature != null) { +- warnings.push({ +- type: "unsupported", +- feature: "topP", +- details: `topP is not supported when temperature is set. topP is ignored.` +- }); +- baseArgs.top_p = void 0; +- } + } + if (isKnownModel && baseArgs.max_tokens > maxOutputTokensForModel) { + if (maxOutputTokens != null) { +@@ -5080,4 +5071,4 @@ + anthropicTools, + prepareTools + }); +-//# sourceMappingURL=index.js.map +\ No newline at end of file ++//# sourceMappingURL=index.js.map +--- a/dist/internal/index.mjs ++++ b/dist/internal/index.mjs +@@ -3176,15 +3176,6 @@ + }); + } + baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0); +- } else { +- if (topP != null && temperature != null) { +- warnings.push({ +- type: "unsupported", +- feature: "topP", +- details: `topP is not supported when temperature is set. topP is ignored.` +- }); +- baseArgs.top_p = void 0; +- } + } + if (isKnownModel && baseArgs.max_tokens > maxOutputTokensForModel) { + if (maxOutputTokens != null) { +@@ -5148,4 +5139,4 @@ + anthropicTools, + prepareTools + }; +-//# sourceMappingURL=index.mjs.map +\ No newline at end of file ++//# sourceMappingURL=index.mjs.map +--- a/src/anthropic-messages-language-model.ts ++++ b/src/anthropic-messages-language-model.ts +@@ -534,16 +534,6 @@ + + // adjust max tokens to account for thinking: + baseArgs.max_tokens = maxTokens + (thinkingBudget ?? 0); +- } else { +- // Only check temperature/topP mutual exclusivity when thinking is not enabled +- if (topP != null && temperature != null) { +- warnings.push({ +- type: 'unsupported', +- feature: 'topP', +- details: `topP is not supported when temperature is set. topP is ignored.`, +- }); +- baseArgs.top_p = undefined; +- } + } + + // limit to max output tokens for known models to enable model switching without breaking it: diff --git a/patches/@ai-sdk%[email protected] b/patches/@ai-sdk%[email protected] new file mode 100644 index 000000000..b93092c46 --- /dev/null +++ b/patches/@ai-sdk%[email protected] @@ -0,0 +1,61 @@ +diff --git a/dist/index.js b/dist/index.js +index 9aa8e83684777e860d905ff7a6895995a7347a4f..820797581ac2a33e731e139da3ebc98b4d93fdcf 100644 +--- a/dist/index.js ++++ b/dist/index.js +@@ -395,10 +395,13 @@ function validateDownloadUrl(url) { + message: `Invalid URL: ${url}` + }); + } ++ if (parsed.protocol === "data:") { ++ return; ++ } + if (parsed.protocol !== "http:" && parsed.protocol !== "https:") { + throw new DownloadError({ + url, +- message: `URL scheme must be http or https, got ${parsed.protocol}` ++ message: `URL scheme must be http, https, or data, got ${parsed.protocol}` + }); + } + const hostname = parsed.hostname; +diff --git a/dist/index.mjs b/dist/index.mjs +index 095fdc188b1d7f227b42591c78ecb71fe2e2cf8b..ca5227d3b6e358aea8ecd85782a0a2b48130a2c9 100644 +--- a/dist/index.mjs ++++ b/dist/index.mjs +@@ -299,10 +299,13 @@ function validateDownloadUrl(url) { + message: `Invalid URL: ${url}` + }); + } ++ if (parsed.protocol === "data:") { ++ return; ++ } + if (parsed.protocol !== "http:" && parsed.protocol !== "https:") { + throw new DownloadError({ + url, +- message: `URL scheme must be http or https, got ${parsed.protocol}` ++ message: `URL scheme must be http, https, or data, got ${parsed.protocol}` + }); + } + const hostname = parsed.hostname; +diff --git a/src/validate-download-url.ts b/src/validate-download-url.ts +index 7c026ad6b400aef551ce3a424c343e1cedc60997..6a2f11398e58f80a8e11995ac1ce5f4d7c110561 100644 +--- a/src/validate-download-url.ts ++++ b/src/validate-download-url.ts +@@ -18,11 +18,16 @@ export function validateDownloadUrl(url: string): void { + }); + } + +- // Only allow http and https protocols ++ // data: URLs are inline content and do not make network requests. ++ if (parsed.protocol === 'data:') { ++ return; ++ } ++ ++ // Only allow http and https network protocols + if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') { + throw new DownloadError({ + url, +- message: `URL scheme must be http or https, got ${parsed.protocol}`, ++ message: `URL scheme must be http, https, or data, got ${parsed.protocol}`, + }); + } + diff --git a/patches/@ai-sdk%[email protected] b/patches/@ai-sdk%[email protected] deleted file mode 100644 index 8776cab48..000000000 --- a/patches/@ai-sdk%[email protected] +++ /dev/null @@ -1,108 +0,0 @@ -diff --git a/dist/index.mjs b/dist/index.mjs ---- a/dist/index.mjs -+++ b/dist/index.mjs -@@ -959,7 +959,7 @@ - model: z4.string().nullish(), - object: z4.literal("response"), - output: z4.array(outputItemSchema), -- usage: xaiResponsesUsageSchema, -+ usage: xaiResponsesUsageSchema.nullish(), - status: z4.string() - }); - var xaiResponsesChunkSchema = z4.union([ -\ No newline at end of file -@@ -1143,6 +1143,18 @@ - z4.object({ - type: z4.literal("response.completed"), - response: xaiResponsesResponseSchema -+ }), -+ z4.object({ -+ type: z4.literal("response.function_call_arguments.delta"), -+ item_id: z4.string(), -+ output_index: z4.number(), -+ delta: z4.string() -+ }), -+ z4.object({ -+ type: z4.literal("response.function_call_arguments.done"), -+ item_id: z4.string(), -+ output_index: z4.number(), -+ arguments: z4.string() - }) - ]); - -\ No newline at end of file -@@ -1940,6 +1952,9 @@ - if (response2.status) { - finishReason = mapXaiResponsesFinishReason(response2.status); - } -+ if (seenToolCalls.size > 0 && finishReason !== "tool-calls") { -+ finishReason = "tool-calls"; -+ } - return; - } - if (event.type === "response.output_item.added" || event.type === "response.output_item.done") { -\ No newline at end of file -@@ -2024,7 +2039,7 @@ - } - } - } else if (part.type === "function_call") { -- if (!seenToolCalls.has(part.call_id)) { -+ if (event.type === "response.output_item.done" && !seenToolCalls.has(part.call_id)) { - seenToolCalls.add(part.call_id); - controller.enqueue({ - type: "tool-input-start", -\ No newline at end of file -diff --git a/dist/index.js b/dist/index.js ---- a/dist/index.js -+++ b/dist/index.js -@@ -964,7 +964,7 @@ - model: import_v44.z.string().nullish(), - object: import_v44.z.literal("response"), - output: import_v44.z.array(outputItemSchema), -- usage: xaiResponsesUsageSchema, -+ usage: xaiResponsesUsageSchema.nullish(), - status: import_v44.z.string() - }); - var xaiResponsesChunkSchema = import_v44.z.union([ -\ No newline at end of file -@@ -1148,6 +1148,18 @@ - import_v44.z.object({ - type: import_v44.z.literal("response.completed"), - response: xaiResponsesResponseSchema -+ }), -+ import_v44.z.object({ -+ type: import_v44.z.literal("response.function_call_arguments.delta"), -+ item_id: import_v44.z.string(), -+ output_index: import_v44.z.number(), -+ delta: import_v44.z.string() -+ }), -+ import_v44.z.object({ -+ type: import_v44.z.literal("response.function_call_arguments.done"), -+ item_id: import_v44.z.string(), -+ output_index: import_v44.z.number(), -+ arguments: import_v44.z.string() - }) - ]); - -\ No newline at end of file -@@ -1935,6 +1947,9 @@ - if (response2.status) { - finishReason = mapXaiResponsesFinishReason(response2.status); - } -+ if (seenToolCalls.size > 0 && finishReason !== "tool-calls") { -+ finishReason = "tool-calls"; -+ } - return; - } - if (event.type === "response.output_item.added" || event.type === "response.output_item.done") { -\ No newline at end of file -@@ -2019,7 +2034,7 @@ - } - } - } else if (part.type === "function_call") { -- if (!seenToolCalls.has(part.call_id)) { -+ if (event.type === "response.output_item.done" && !seenToolCalls.has(part.call_id)) { - seenToolCalls.add(part.call_id); - controller.enqueue({ - type: "tool-input-start", -\ No newline at end of file diff --git a/patches/@openrouter%[email protected] b/patches/@openrouter%[email protected] deleted file mode 100644 index 6226bf790..000000000 --- a/patches/@openrouter%[email protected] +++ /dev/null @@ -1,128 +0,0 @@ -diff --git a/dist/index.js b/dist/index.js -index f33510a50d11a2cb92a90ea70cc0ac84c89f29b9..e887a60352c0c08ab794b1e6821854dfeefd20cc 100644 ---- a/dist/index.js -+++ b/dist/index.js -@@ -2110,7 +2110,12 @@ var OpenRouterChatLanguageModel = class { - if (reasoningStarted && !textStarted) { - controller.enqueue({ - type: "reasoning-end", -- id: reasoningId || generateId() -+ id: reasoningId || generateId(), -+ providerMetadata: accumulatedReasoningDetails.length > 0 ? { -+ openrouter: { -+ reasoning_details: accumulatedReasoningDetails -+ } -+ } : undefined - }); - reasoningStarted = false; - } -@@ -2307,7 +2312,12 @@ var OpenRouterChatLanguageModel = class { - if (reasoningStarted) { - controller.enqueue({ - type: "reasoning-end", -- id: reasoningId || generateId() -+ id: reasoningId || generateId(), -+ providerMetadata: accumulatedReasoningDetails.length > 0 ? { -+ openrouter: { -+ reasoning_details: accumulatedReasoningDetails -+ } -+ } : undefined - }); - } - if (textStarted) { -diff --git a/dist/index.mjs b/dist/index.mjs -index 8a688331b88b4af738ee4ca8062b5f24124d3d81..6310cb8b7c8d0a728d86e1eed09906c6b4c91ae2 100644 ---- a/dist/index.mjs -+++ b/dist/index.mjs -@@ -2075,7 +2075,12 @@ var OpenRouterChatLanguageModel = class { - if (reasoningStarted && !textStarted) { - controller.enqueue({ - type: "reasoning-end", -- id: reasoningId || generateId() -+ id: reasoningId || generateId(), -+ providerMetadata: accumulatedReasoningDetails.length > 0 ? { -+ openrouter: { -+ reasoning_details: accumulatedReasoningDetails -+ } -+ } : undefined - }); - reasoningStarted = false; - } -@@ -2272,7 +2277,12 @@ var OpenRouterChatLanguageModel = class { - if (reasoningStarted) { - controller.enqueue({ - type: "reasoning-end", -- id: reasoningId || generateId() -+ id: reasoningId || generateId(), -+ providerMetadata: accumulatedReasoningDetails.length > 0 ? { -+ openrouter: { -+ reasoning_details: accumulatedReasoningDetails -+ } -+ } : undefined - }); - } - if (textStarted) { -diff --git a/dist/internal/index.js b/dist/internal/index.js -index d40fa66125941155ac13a4619503caba24d89f8a..8dd86d1b473f2fa31c1acd9881d72945b294a197 100644 ---- a/dist/internal/index.js -+++ b/dist/internal/index.js -@@ -2064,7 +2064,12 @@ var OpenRouterChatLanguageModel = class { - if (reasoningStarted && !textStarted) { - controller.enqueue({ - type: "reasoning-end", -- id: reasoningId || generateId() -+ id: reasoningId || generateId(), -+ providerMetadata: accumulatedReasoningDetails.length > 0 ? { -+ openrouter: { -+ reasoning_details: accumulatedReasoningDetails -+ } -+ } : undefined - }); - reasoningStarted = false; - } -@@ -2261,7 +2266,12 @@ var OpenRouterChatLanguageModel = class { - if (reasoningStarted) { - controller.enqueue({ - type: "reasoning-end", -- id: reasoningId || generateId() -+ id: reasoningId || generateId(), -+ providerMetadata: accumulatedReasoningDetails.length > 0 ? { -+ openrouter: { -+ reasoning_details: accumulatedReasoningDetails -+ } -+ } : undefined - }); - } - if (textStarted) { -diff --git a/dist/internal/index.mjs b/dist/internal/index.mjs -index b0ed9d113549c5c55ea3b1e08abb3db6f92ae5a7..5695930a8e038facc071d58a4179a369a29be9c7 100644 ---- a/dist/internal/index.mjs -+++ b/dist/internal/index.mjs -@@ -2030,7 +2030,12 @@ var OpenRouterChatLanguageModel = class { - if (reasoningStarted && !textStarted) { - controller.enqueue({ - type: "reasoning-end", -- id: reasoningId || generateId() -+ id: reasoningId || generateId(), -+ providerMetadata: accumulatedReasoningDetails.length > 0 ? { -+ openrouter: { -+ reasoning_details: accumulatedReasoningDetails -+ } -+ } : undefined - }); - reasoningStarted = false; - } -@@ -2227,7 +2232,12 @@ var OpenRouterChatLanguageModel = class { - if (reasoningStarted) { - controller.enqueue({ - type: "reasoning-end", -- id: reasoningId || generateId() -+ id: reasoningId || generateId(), -+ providerMetadata: accumulatedReasoningDetails.length > 0 ? { -+ openrouter: { -+ reasoning_details: accumulatedReasoningDetails -+ } -+ } : undefined - }); - } - if (textStarted) { |
