@opencode-ai/ai
Advanced tools
@@ -288,2 +288,3 @@ import { Effect, Schema } from "effect"; | ||
| readonly cacheControl?: (cache: CacheHint | undefined) => Schema.Schema.Type<typeof OpenAIChatCacheControl> | undefined; | ||
| readonly toolCallID?: (id: string) => string; | ||
| } | ||
@@ -290,0 +291,0 @@ export declare const fromRequest: (request: LLMRequest, options?: LoweringOptions | undefined) => Effect.Effect<{ |
@@ -195,4 +195,4 @@ import { Effect, Schema } from "effect"; | ||
| }); | ||
| const lowerToolCall = (part) => ({ | ||
| id: part.id, | ||
| const lowerToolCall = (part, options) => ({ | ||
| id: options.toolCallID?.(part.id) ?? part.id, | ||
| type: "function", | ||
@@ -261,3 +261,3 @@ function: { | ||
| if (part.type === "tool-call") { | ||
| toolCalls.push(lowerToolCall(part)); | ||
| toolCalls.push(lowerToolCall(part, options)); | ||
| continue; | ||
@@ -312,3 +312,3 @@ } | ||
| role: "tool", | ||
| tool_call_id: part.id, | ||
| tool_call_id: options.toolCallID?.(part.id) ?? part.id, | ||
| content: ProviderShared.toolResultText(part), | ||
@@ -323,3 +323,3 @@ cache_control: options.cacheControl?.(part.cache), | ||
| role: "tool", | ||
| tool_call_id: part.id, | ||
| tool_call_id: options.toolCallID?.(part.id) ?? part.id, | ||
| content: text.join("\n"), | ||
@@ -356,4 +356,17 @@ cache_control: options.cacheControl?.(part.cache), | ||
| const messages = [...system]; | ||
| const requireAssistantAfterTool = request.model.compatibility?.requireAssistantAfterTool ?? | ||
| ["mistral", "devstral", "codestral", "pixtral", "mixtral"].some((family) => request.model.id.toLowerCase().includes(family)); | ||
| const modelID = request.model.id.toLowerCase(); | ||
| const mistral = ["mistral", "devstral", "codestral", "pixtral", "mixtral"].some((family) => modelID.includes(family)); | ||
| const lowering = { | ||
| ...options, | ||
| toolCallID: (id) => { | ||
| if (mistral) | ||
| return id.replace(/[^a-zA-Z0-9]/g, "").slice(0, 9).padEnd(9, "0"); | ||
| if (modelID.includes("claude")) | ||
| return id.replace(/[^a-zA-Z0-9_-]/g, "_"); | ||
| if (request.model.provider === "openai" || request.model.provider === "azure" || modelID.startsWith("openai/")) | ||
| return id.slice(0, 40); | ||
| return id; | ||
| }, | ||
| }; | ||
| const requireAssistantAfterTool = request.model.compatibility?.requireAssistantAfterTool ?? mistral; | ||
| const bridgeTools = () => { | ||
@@ -416,3 +429,3 @@ if (requireAssistantAfterTool && messages.at(-1)?.role === "tool") | ||
| if (message.role === "tool") { | ||
| const lowered = yield* lowerToolMessages(message, options); | ||
| const lowered = yield* lowerToolMessages(message, lowering); | ||
| messages.push(...lowered.messages); | ||
@@ -423,3 +436,3 @@ pendingImages.push(...lowered.images); | ||
| flushImages(); | ||
| messages.push(...(yield* lowerMessage(message, request.model.compatibility?.reasoningField, options))); | ||
| messages.push(...(yield* lowerMessage(message, request.model.compatibility?.reasoningField, lowering))); | ||
| } | ||
@@ -426,0 +439,0 @@ flushImages(); |
+3
-3
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "version": "0.0.0-beta-18219", | ||
| "version": "0.0.0-beta-18230", | ||
| "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-beta-18219", | ||
| "@opencode-ai/http-recorder": "0.0.0-beta-18230", | ||
| "@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-beta-18219", | ||
| "@opencode-ai/schema": "0.0.0-beta-18230", | ||
| "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.
1271027
0.06%29172
0.05%+ Added
- Removed