@opencode-ai/ai
Advanced tools
@@ -205,3 +205,3 @@ import { Schema } from "effect"; | ||
| readonly thinking: Schema.String; | ||
| readonly signature: Schema.optional<Schema.String>; | ||
| readonly signature: Schema.String; | ||
| readonly cache_control: Schema.optional<Schema.Struct<{ | ||
@@ -475,2 +475,3 @@ readonly type: Schema.tag<"ephemeral">; | ||
| readonly thinking: string; | ||
| readonly signature: string; | ||
| readonly cache_control?: { | ||
@@ -480,3 +481,2 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly signature?: string | undefined; | ||
| } | { | ||
@@ -791,2 +791,3 @@ readonly data: string; | ||
| readonly thinking: string; | ||
| readonly signature: string; | ||
| readonly cache_control?: { | ||
@@ -796,3 +797,2 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly signature?: string | undefined; | ||
| } | { | ||
@@ -799,0 +799,0 @@ readonly data: string; |
@@ -99,3 +99,3 @@ import { Buffer } from "node:buffer"; | ||
| thinking: Schema.String, | ||
| signature: Schema.optional(Schema.String), | ||
| signature: Schema.String, | ||
| cache_control: Schema.optional(AnthropicCacheControl), | ||
@@ -578,2 +578,20 @@ }); | ||
| }); | ||
| const requireThinkingSignature = (request) => { | ||
| if (request.model.compatibility?.requireSignature !== undefined) | ||
| return request.model.compatibility.requireSignature; | ||
| const provider = request.model.provider.toLowerCase(); | ||
| const model = request.model.id.toLowerCase(); | ||
| const baseURL = (request.model.route.endpoint.baseURL ?? "").toLowerCase(); | ||
| if (provider === "kimi-for-coding" || | ||
| provider === "moonshotai" || | ||
| provider === "moonshotai-cn" || | ||
| model.startsWith("kimi-") || | ||
| baseURL.includes("api.kimi.com/coding") || | ||
| baseURL.includes("api.moonshot.ai/anthropic") || | ||
| baseURL.includes("api.moonshot.cn/anthropic")) | ||
| return false; | ||
| if (provider.includes("xiaomi") || model.includes("mimo") || baseURL.includes("xiaomimimo.com")) | ||
| return false; | ||
| return true; | ||
| }; | ||
| // Mid-conversation system messages became available with Opus 4.8 and version | ||
@@ -672,5 +690,4 @@ // 5 of the other supported Claude families. Treat later family versions as | ||
| if (part.type === "reasoning") { | ||
| // Mirrors Vercel's @ai-sdk/anthropic: a signature marks visible | ||
| // thinking; only signature-less parts carrying redactedData | ||
| // round-trip as opaque redacted_thinking blocks. | ||
| // A signature marks visible thinking; only signature-less parts carrying | ||
| // redactedData round-trip as opaque redacted_thinking blocks. | ||
| const signature = part.encrypted ?? signatureFromMetadata(part.providerMetadata); | ||
@@ -682,2 +699,19 @@ const redactedData = redactedDataFromMetadata(part.providerMetadata); | ||
| } | ||
| if (typeof signature !== "string" || signature.trim().length === 0) { | ||
| if (part.text.trim().length === 0) | ||
| continue; | ||
| if (!requireThinkingSignature(request)) { | ||
| content.push({ type: "thinking", thinking: part.text, signature: "" }); | ||
| continue; | ||
| } | ||
| // Without a signature this cannot be a valid thinking block per | ||
| // the SDK ThinkingBlockParam:3217 — demote to text so the | ||
| // conversation remains sendable. | ||
| content.push({ | ||
| type: "text", | ||
| text: part.text, | ||
| cache_control: cacheControl(breakpoints, part.cache), | ||
| }); | ||
| continue; | ||
| } | ||
| content.push({ type: "thinking", thinking: part.text, signature }); | ||
@@ -684,0 +718,0 @@ continue; |
@@ -185,2 +185,3 @@ import type { ProviderPackage } from "../provider-package.js"; | ||
| readonly thinking: string; | ||
| readonly signature: string; | ||
| readonly cache_control?: { | ||
@@ -190,3 +191,2 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly signature?: string | undefined; | ||
| } | { | ||
@@ -193,0 +193,0 @@ readonly data: string; |
@@ -169,2 +169,3 @@ import type { RouteDefaultsInput } from "../route/client.js"; | ||
| readonly thinking: string; | ||
| readonly signature: string; | ||
| readonly cache_control?: { | ||
@@ -174,3 +175,2 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly signature?: string | undefined; | ||
| } | { | ||
@@ -177,0 +177,0 @@ readonly data: string; |
@@ -205,2 +205,3 @@ import type { ProviderPackage } from "../provider-package.js"; | ||
| readonly thinking: string; | ||
| readonly signature: string; | ||
| readonly cache_control?: { | ||
@@ -210,3 +211,2 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly signature?: string | undefined; | ||
| } | { | ||
@@ -213,0 +213,0 @@ readonly data: string; |
@@ -81,2 +81,3 @@ import { Schema } from "effect"; | ||
| readonly zaiToolStream: Schema.optional<Schema.Boolean>; | ||
| readonly requireSignature: Schema.optional<Schema.Boolean>; | ||
| }>, {}>; | ||
@@ -83,0 +84,0 @@ export declare class LanguageModelCompatibility extends LanguageModelCompatibility_base { |
@@ -108,2 +108,3 @@ import { Schema } from "effect"; | ||
| zaiToolStream: Schema.optional(Schema.Boolean), | ||
| requireSignature: Schema.optional(Schema.Boolean), | ||
| }) { | ||
@@ -110,0 +111,0 @@ } |
+3
-3
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "version": "0.0.0-dev-18104", | ||
| "version": "0.0.0-dev-18105", | ||
| "name": "@opencode-ai/ai", | ||
@@ -33,3 +33,3 @@ "type": "module", | ||
| "@effect/platform-node": "4.0.0-rc.111", | ||
| "@opencode-ai/http-recorder": "0.0.0-dev-18104", | ||
| "@opencode-ai/http-recorder": "0.0.0-dev-18105", | ||
| "@tsconfig/bun": "1.0.9", | ||
@@ -43,3 +43,3 @@ "@types/bun": "1.3.13", | ||
| "@smithy/util-utf8": "4.2.2", | ||
| "@opencode-ai/schema": "0.0.0-dev-18104", | ||
| "@opencode-ai/schema": "0.0.0-dev-18105", | ||
| "aws4fetch": "1.0.20", | ||
@@ -46,0 +46,0 @@ "effect": "4.0.0-rc.111", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1245985
0.14%28566
0.13%+ Added
- Removed