@opencode-ai/ai 0.0.0-next-16079 → 0.0.0-next-16087

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -150,7 +150,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
150
150
  }>>;
151
151
  }>>>;
152
152
  tool_choice: Schema.optional<Schema.Union<readonly [Schema.Struct<{
153
- readonly type: Schema.Literals<readonly ["auto", "any"]>;
153
+ readonly type: Schema.Literals<readonly ["auto", "any", "none"]>;
154
154
  }>, Schema.Struct<{
155
155
  readonly type: Schema.tag<"tool">;
156
156
  readonly name: Schema.String;
@@ -340,7 +340,7 @@ export declare const protocol: Protocol<{
340
340
  readonly type: Schema.tag<"disabled">;
341
341
  }, "Type"> | undefined;
342
342
  readonly tool_choice?: Schema.Struct.ReadonlySide<{
343
- readonly type: Schema.Literals<readonly ["auto", "any"]>;
343
+ readonly type: Schema.Literals<readonly ["auto", "any", "none"]>;
344
344
  }, "Type"> | Schema.Struct.ReadonlySide<{
345
345
  readonly type: Schema.tag<"tool">;
346
346
  readonly name: Schema.String;
@@ -555,7 +555,7 @@ export declare const route: Route<{
555
555
  readonly type: Schema.tag<"disabled">;
556
556
  }, "Type"> | undefined;
557
557
  readonly tool_choice?: Schema.Struct.ReadonlySide<{
558
- readonly type: Schema.Literals<readonly ["auto", "any"]>;
558
+ readonly type: Schema.Literals<readonly ["auto", "any", "none"]>;
559
559
  }, "Type"> | Schema.Struct.ReadonlySide<{
560
560
  readonly type: Schema.tag<"tool">;
561
561
  readonly name: Schema.String;
@@ -117,7 +117,7 @@ const AnthropicTool = Schema.Struct({
117
117
  cache_control: Schema.optional(AnthropicCacheControl),
118
118
  });
119
119
  const AnthropicToolChoice = Schema.Union([
120
- Schema.Struct({ type: Schema.Literals(["auto", "any"]) }),
120
+ Schema.Struct({ type: Schema.Literals(["auto", "any", "none"]) }),
121
121
  Schema.Struct({ type: Schema.tag("tool"), name: Schema.String }),
122
122
  ]);
123
123
  const AnthropicThinking = Schema.Union([
@@ -230,7 +230,7 @@ const lowerTool = (breakpoints, tool, inputSchema) => ({
230
230
  });
231
231
  const lowerToolChoice = (toolChoice) => ProviderShared.matchToolChoice("Anthropic Messages", toolChoice, {
232
232
  auto: () => ({ type: "auto" }),
233
- none: () => undefined,
233
+ none: () => ({ type: "none" }),
234
234
  required: () => ({ type: "any" }),
235
235
  tool: (name) => ({ type: "tool", name }),
236
236
  });
@@ -450,7 +450,6 @@ const outputConfig = (request) => {
450
450
  return typeof effort === "string" ? { effort } : undefined;
451
451
  };
452
452
  const fromRequest = Effect.fn("AnthropicMessages.fromRequest")(function* (request) {
453
- const toolChoice = request.toolChoice ? yield* lowerToolChoice(request.toolChoice) : undefined;
454
453
  const generation = request.generation;
455
454
  const toolSchemaCompatibility = request.model.compatibility?.toolSchema;
456
455
  const outputLimit = request.model.defaults?.limits?.output ?? request.model.route.defaults.limits?.output ?? 4096;
@@ -458,9 +457,11 @@ const fromRequest = Effect.fn("AnthropicMessages.fromRequest")(function* (reques
458
457
  // messages. Tools live highest in the cache hierarchy, so when callers
459
458
  // over-mark we keep their tool hints and shed the message-tail ones first.
460
459
  const breakpoints = Cache.newBreakpoints(ANTHROPIC_BREAKPOINT_CAP);
461
- const tools = request.tools.length === 0 || request.toolChoice?.type === "none"
460
+ const tools = request.tools.length === 0
462
461
  ? undefined
463
462
  : request.tools.map((tool) => lowerTool(breakpoints, tool, ToolSchemaProjection.modelCompatibility(tool.inputSchema, toolSchemaCompatibility)));
463
+ // Anthropic rejects tool_choice when tools are absent; "none" is only meaningful with tools present.
464
+ const toolChoice = tools === undefined || !request.toolChoice ? undefined : yield* lowerToolChoice(request.toolChoice);
464
465
  const system = request.system.length === 0
465
466
  ? undefined
466
467
  : request.system.map((part) => ({
@@ -256,7 +256,7 @@ const thinkingConfig = (request) => {
256
256
  return Object.values(result).some((item) => item !== undefined) ? result : undefined;
257
257
  };
258
258
  const fromRequest = Effect.fn("Gemini.fromRequest")(function* (request) {
259
- const toolsEnabled = request.tools.length > 0 && request.toolChoice?.type !== "none";
259
+ const hasTools = request.tools.length > 0;
260
260
  const generation = request.generation;
261
261
  const toolSchemaCompatibility = request.model.compatibility?.toolSchema;
262
262
  const generationConfig = {
@@ -270,14 +270,14 @@ const fromRequest = Effect.fn("Gemini.fromRequest")(function* (request) {
270
270
  return {
271
271
  contents: yield* lowerMessages(request),
272
272
  systemInstruction: request.system.length === 0 ? undefined : { parts: [{ text: ProviderShared.joinText(request.system) }] },
273
- tools: toolsEnabled
273
+ tools: hasTools
274
274
  ? [
275
275
  {
276
276
  functionDeclarations: request.tools.map((tool) => lowerTool(tool, ToolSchemaProjection.modelCompatibility(tool.inputSchema, toolSchemaCompatibility))),
277
277
  },
278
278
  ]
279
279
  : undefined,
280
- toolConfig: toolsEnabled && request.toolChoice ? yield* lowerToolConfig(request.toolChoice) : undefined,
280
+ toolConfig: hasTools && request.toolChoice ? yield* lowerToolConfig(request.toolChoice) : undefined,
281
281
  generationConfig: Object.values(generationConfig).some((value) => value !== undefined)
282
282
  ? generationConfig
283
283
  : undefined,
@@ -177,7 +177,7 @@ export declare const routes: import("../route").Route<{
177
177
  readonly type: import("effect/Schema").tag<"disabled">;
178
178
  }, "Type"> | undefined;
179
179
  readonly tool_choice?: import("effect/Schema").Struct.ReadonlySide<{
180
- readonly type: import("effect/Schema").Literals<readonly ["auto", "any"]>;
180
+ readonly type: import("effect/Schema").Literals<readonly ["auto", "any", "none"]>;
181
181
  }, "Type"> | import("effect/Schema").Struct.ReadonlySide<{
182
182
  readonly type: import("effect/Schema").tag<"tool">;
183
183
  readonly name: import("effect/Schema").String;
@@ -163,7 +163,7 @@ export declare const routes: import("../route").Route<{
163
163
  readonly type: import("effect/Schema").tag<"disabled">;
164
164
  }, "Type"> | undefined;
165
165
  readonly tool_choice?: import("effect/Schema").Struct.ReadonlySide<{
166
- readonly type: import("effect/Schema").Literals<readonly ["auto", "any"]>;
166
+ readonly type: import("effect/Schema").Literals<readonly ["auto", "any", "none"]>;
167
167
  }, "Type"> | import("effect/Schema").Struct.ReadonlySide<{
168
168
  readonly type: import("effect/Schema").tag<"tool">;
169
169
  readonly name: import("effect/Schema").String;
@@ -177,7 +177,7 @@ export declare const routes: Route<{
177
177
  readonly type: Schema.tag<"disabled">;
178
178
  }, "Type"> | undefined;
179
179
  tool_choice?: Schema.Struct.ReadonlySide<{
180
- readonly type: Schema.Literals<readonly ["auto", "any"]>;
180
+ readonly type: Schema.Literals<readonly ["auto", "any", "none"]>;
181
181
  }, "Type"> | Schema.Struct.ReadonlySide<{
182
182
  readonly type: Schema.tag<"tool">;
183
183
  readonly name: Schema.String;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-next-16079",
3
+ "version": "0.0.0-next-16087",
4
4
  "name": "@opencode-ai/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "devDependencies": {
27
27
  "@clack/prompts": "1.0.0-alpha.1",
28
28
  "@effect/platform-node": "4.0.0-beta.98",
29
- "@opencode-ai/http-recorder": "0.0.0-next-16079",
29
+ "@opencode-ai/http-recorder": "0.0.0-next-16087",
30
30
  "@tsconfig/bun": "1.0.9",
31
31
  "@types/bun": "1.3.13",
32
32
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -35,7 +35,7 @@
35
35
  "dependencies": {
36
36
  "@smithy/eventstream-codec": "4.2.14",
37
37
  "@smithy/util-utf8": "4.2.2",
38
- "@opencode-ai/schema": "0.0.0-next-16079",
38
+ "@opencode-ai/schema": "0.0.0-next-16087",
39
39
  "aws4fetch": "1.0.20",
40
40
  "effect": "4.0.0-beta.98",
41
41
  "google-auth-library": "10.5.0"