@opencode-ai/ai
Advanced tools
@@ -153,3 +153,3 @@ import { Schema } from "effect"; | ||
| tool_choice: Schema.optional<Schema.Union<readonly [Schema.Struct<{ | ||
| readonly type: Schema.Literals<readonly ["auto", "any"]>; | ||
| readonly type: Schema.Literals<readonly ["auto", "any", "none"]>; | ||
| }>, Schema.Struct<{ | ||
@@ -344,3 +344,3 @@ readonly type: Schema.tag<"tool">; | ||
| readonly tool_choice?: Schema.Struct.ReadonlySide<{ | ||
| readonly type: Schema.Literals<readonly ["auto", "any"]>; | ||
| readonly type: Schema.Literals<readonly ["auto", "any", "none"]>; | ||
| }, "Type"> | Schema.Struct.ReadonlySide<{ | ||
@@ -560,3 +560,3 @@ readonly type: Schema.tag<"tool">; | ||
| readonly tool_choice?: Schema.Struct.ReadonlySide<{ | ||
| readonly type: Schema.Literals<readonly ["auto", "any"]>; | ||
| readonly type: Schema.Literals<readonly ["auto", "any", "none"]>; | ||
| }, "Type"> | Schema.Struct.ReadonlySide<{ | ||
@@ -563,0 +563,0 @@ readonly type: Schema.tag<"tool">; |
@@ -120,3 +120,3 @@ import { Effect, Schema } from "effect"; | ||
| const AnthropicToolChoice = Schema.Union([ | ||
| Schema.Struct({ type: Schema.Literals(["auto", "any"]) }), | ||
| Schema.Struct({ type: Schema.Literals(["auto", "any", "none"]) }), | ||
| Schema.Struct({ type: Schema.tag("tool"), name: Schema.String }), | ||
@@ -234,3 +234,3 @@ ]); | ||
| auto: () => ({ type: "auto" }), | ||
| none: () => undefined, | ||
| none: () => ({ type: "none" }), | ||
| required: () => ({ type: "any" }), | ||
@@ -455,3 +455,2 @@ tool: (name) => ({ type: "tool", name }), | ||
| const fromRequest = Effect.fn("AnthropicMessages.fromRequest")(function* (request) { | ||
| const toolChoice = request.toolChoice ? yield* lowerToolChoice(request.toolChoice) : undefined; | ||
| const generation = request.generation; | ||
@@ -464,5 +463,7 @@ const toolSchemaCompatibility = request.model.compatibility?.toolSchema; | ||
| const breakpoints = Cache.newBreakpoints(ANTHROPIC_BREAKPOINT_CAP); | ||
| const tools = request.tools.length === 0 || request.toolChoice?.type === "none" | ||
| const tools = request.tools.length === 0 | ||
| ? undefined | ||
| : request.tools.map((tool) => lowerTool(breakpoints, tool, ToolSchemaProjection.modelCompatibility(tool.inputSchema, toolSchemaCompatibility))); | ||
| // Anthropic rejects tool_choice when tools are absent; "none" is only meaningful with tools present. | ||
| const toolChoice = tools === undefined || !request.toolChoice ? undefined : yield* lowerToolChoice(request.toolChoice); | ||
| const system = request.system.length === 0 | ||
@@ -469,0 +470,0 @@ ? undefined |
@@ -259,3 +259,3 @@ import { Effect, Schema } from "effect"; | ||
| const fromRequest = Effect.fn("Gemini.fromRequest")(function* (request) { | ||
| const toolsEnabled = request.tools.length > 0 && request.toolChoice?.type !== "none"; | ||
| const hasTools = request.tools.length > 0; | ||
| const generation = request.generation; | ||
@@ -274,3 +274,3 @@ const toolSchemaCompatibility = request.model.compatibility?.toolSchema; | ||
| systemInstruction: request.system.length === 0 ? undefined : { parts: [{ text: ProviderShared.joinText(request.system) }] }, | ||
| tools: toolsEnabled | ||
| tools: hasTools | ||
| ? [ | ||
@@ -282,3 +282,3 @@ { | ||
| : undefined, | ||
| toolConfig: toolsEnabled && request.toolChoice ? yield* lowerToolConfig(request.toolChoice) : undefined, | ||
| toolConfig: hasTools && request.toolChoice ? yield* lowerToolConfig(request.toolChoice) : undefined, | ||
| generationConfig: Object.values(generationConfig).some((value) => value !== undefined) | ||
@@ -285,0 +285,0 @@ ? generationConfig |
@@ -180,3 +180,3 @@ import type { ProviderPackage } from "../provider-package"; | ||
| readonly tool_choice?: import("effect/Schema").Struct.ReadonlySide<{ | ||
| readonly type: import("effect/Schema").Literals<readonly ["auto", "any"]>; | ||
| readonly type: import("effect/Schema").Literals<readonly ["auto", "any", "none"]>; | ||
| }, "Type"> | import("effect/Schema").Struct.ReadonlySide<{ | ||
@@ -183,0 +183,0 @@ readonly type: import("effect/Schema").tag<"tool">; |
@@ -166,3 +166,3 @@ import type { RouteDefaultsInput } from "../route/client"; | ||
| readonly tool_choice?: import("effect/Schema").Struct.ReadonlySide<{ | ||
| readonly type: import("effect/Schema").Literals<readonly ["auto", "any"]>; | ||
| readonly type: import("effect/Schema").Literals<readonly ["auto", "any", "none"]>; | ||
| }, "Type"> | import("effect/Schema").Struct.ReadonlySide<{ | ||
@@ -169,0 +169,0 @@ readonly type: import("effect/Schema").tag<"tool">; |
@@ -180,3 +180,3 @@ import { Schema } from "effect"; | ||
| tool_choice?: Schema.Struct.ReadonlySide<{ | ||
| readonly type: Schema.Literals<readonly ["auto", "any"]>; | ||
| readonly type: Schema.Literals<readonly ["auto", "any", "none"]>; | ||
| }, "Type"> | Schema.Struct.ReadonlySide<{ | ||
@@ -183,0 +183,0 @@ readonly type: Schema.tag<"tool">; |
+3
-3
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "version": "0.0.0-next-16077", | ||
| "version": "0.0.0-next-16087", | ||
| "name": "@opencode-ai/ai", | ||
@@ -29,3 +29,3 @@ "type": "module", | ||
| "@effect/platform-node": "4.0.0-beta.98", | ||
| "@opencode-ai/http-recorder": "0.0.0-next-16077", | ||
| "@opencode-ai/http-recorder": "0.0.0-next-16087", | ||
| "@tsconfig/bun": "1.0.9", | ||
@@ -39,3 +39,3 @@ "@types/bun": "1.3.13", | ||
| "@smithy/util-utf8": "4.2.2", | ||
| "@opencode-ai/schema": "0.0.0-next-16077", | ||
| "@opencode-ai/schema": "0.0.0-next-16087", | ||
| "aws4fetch": "1.0.20", | ||
@@ -42,0 +42,0 @@ "effect": "4.0.0-beta.98", |
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.
1036341
0.01%21771
0+ Added
- Removed