@opencode-ai/ai 0.0.0-dev-18017 → 0.0.0-dev-18035

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.
@@ -15,6 +15,7 @@ export type ThinkingInput = {
15
15
  readonly type: "disabled";
16
16
  } | ({
17
17
  readonly type: "enabled";
18
+ readonly display?: "summarized" | "omitted";
18
19
  } & ({
19
20
  readonly budgetTokens: number;
20
21
  readonly budget_tokens?: number;
@@ -194,6 +195,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
194
195
  thinking: Schema.optional<Schema.Union<readonly [Schema.Struct<{
195
196
  readonly type: Schema.tag<"enabled">;
196
197
  readonly budget_tokens: Schema.Number;
198
+ readonly display: Schema.optional<Schema.Literals<readonly ["summarized", "omitted"]>>;
197
199
  }>, Schema.Struct<{
198
200
  readonly type: Schema.tag<"adaptive">;
199
201
  readonly display: Schema.optional<Schema.Literals<readonly ["summarized", "omitted"]>>;
@@ -369,6 +371,7 @@ export declare const protocol: Protocol<{
369
371
  readonly thinking?: {
370
372
  readonly type: "enabled";
371
373
  readonly budget_tokens: number;
374
+ readonly display?: "summarized" | "omitted" | undefined;
372
375
  } | {
373
376
  readonly type: "adaptive";
374
377
  readonly display?: "summarized" | "omitted" | undefined;
@@ -611,6 +614,7 @@ export declare const route: Route<{
611
614
  readonly thinking?: {
612
615
  readonly type: "enabled";
613
616
  readonly budget_tokens: number;
617
+ readonly display?: "summarized" | "omitted" | undefined;
614
618
  } | {
615
619
  readonly type: "adaptive";
616
620
  readonly display?: "summarized" | "omitted" | undefined;
@@ -146,6 +146,7 @@ const AnthropicThinking = Schema.Union([
146
146
  Schema.Struct({
147
147
  type: Schema.tag("enabled"),
148
148
  budget_tokens: Schema.Number,
149
+ display: Schema.optional(Schema.Literals(["summarized", "omitted"])),
149
150
  }),
150
151
  Schema.Struct({
151
152
  type: Schema.tag("adaptive"),
@@ -491,14 +492,11 @@ const resolveOptions = Effect.fn("AnthropicMessages.resolveOptions")(function* (
491
492
  const resolveThinking = Effect.fn("AnthropicMessages.resolveThinking")(function* (input) {
492
493
  if (!ProviderShared.isRecord(input))
493
494
  return undefined;
494
- if (input.type === "adaptive") {
495
- const display = input.display === "summarized"
496
- ? "summarized"
497
- : input.display === "omitted"
498
- ? "omitted"
499
- : undefined;
495
+ const display = input.display === "summarized" || input.display === "omitted"
496
+ ? input.display
497
+ : undefined;
498
+ if (input.type === "adaptive")
500
499
  return { type: "adaptive", ...(display === undefined ? {} : { display }) };
501
- }
502
500
  if (input.type === "disabled")
503
501
  return { type: "disabled" };
504
502
  if (input.type !== "enabled")
@@ -510,7 +508,7 @@ const resolveThinking = Effect.fn("AnthropicMessages.resolveThinking")(function*
510
508
  : undefined;
511
509
  if (budget === undefined)
512
510
  return yield* ProviderShared.invalidRequest("Anthropic thinking provider option requires budgetTokens");
513
- return { type: "enabled", budget_tokens: budget };
511
+ return { type: "enabled", budget_tokens: budget, ...(display === undefined ? {} : { display }) };
514
512
  });
515
513
  const fromRequest = Effect.fn("AnthropicMessages.fromRequest")(function* (request) {
516
514
  const generation = request.generation;
@@ -1,7 +1,7 @@
1
1
  import { Effect, Schema } from "effect";
2
2
  import { HttpTransport } from "../route/transport/index.js";
3
3
  import { Protocol } from "../route/protocol.js";
4
- import { AIError, LLMEvent, Usage, } from "../schema/index.js";
4
+ import { AIError, LLMEvent, ProviderInternalReason, Usage, } from "../schema/index.js";
5
5
  import { JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared.js";
6
6
  import { classifyProviderFailure } from "../provider-error.js";
7
7
  import { OpenResponsesOptions } from "./utils/open-responses-options.js";
@@ -234,7 +234,7 @@ export const lowerTool = Effect.fn("OpenResponses.lowerTool")(function* (protoco
234
234
  type: "function",
235
235
  name: tool.name,
236
236
  description: tool.description,
237
- parameters: ToolSchemaProjection.responses(inputSchema),
237
+ parameters: inputSchema,
238
238
  // The common tool definition does not currently express Responses strict-schema policy.
239
239
  strict: false,
240
240
  };
@@ -856,11 +856,18 @@ export const providerFailure = (id, event, fallback) => {
856
856
  : typeof event.status_code === "number"
857
857
  ? event.status_code
858
858
  : undefined;
859
+ const reason = event.type === "error" &&
860
+ event.error === undefined &&
861
+ event.response === undefined &&
862
+ summary === undefined &&
863
+ status === undefined
864
+ ? new ProviderInternalReason({ message })
865
+ : classifyProviderFailure({ message, code, status, rawBody: body });
859
866
  return new AIError({
860
867
  module: id,
861
868
  method: "stream",
862
869
  body,
863
- reason: classifyProviderFailure({ message, code, status, rawBody: body }),
870
+ reason,
864
871
  });
865
872
  };
866
873
  const providerError = (state, event, fallback) => providerFailure(state.id, event, fallback);
@@ -175,7 +175,7 @@ const lowerTool = (tool, inputSchema, options) => ({
175
175
  function: {
176
176
  name: tool.name,
177
177
  description: tool.description,
178
- parameters: ToolSchemaProjection.openAI(inputSchema),
178
+ parameters: inputSchema,
179
179
  },
180
180
  cache_control: options.cacheControl?.(tool.cache),
181
181
  });
@@ -1,20 +1,5 @@
1
1
  import { isRecord } from "../../utils/record.js";
2
2
  import { GeminiToolSchema } from "./gemini-tool-schema.js";
3
- const removeNullSchemas = (value) => {
4
- if (Array.isArray(value))
5
- return value.map(removeNullSchemas);
6
- if (!isRecord(value))
7
- return value;
8
- const fields = Object.fromEntries(Object.entries(value)
9
- .filter(([key]) => key !== "anyOf")
10
- .map(([key, field]) => [key, removeNullSchemas(field)]));
11
- if (!Array.isArray(value.anyOf))
12
- return fields;
13
- const variants = value.anyOf.filter((variant) => !isRecord(variant) || variant.type !== "null").map(removeNullSchemas);
14
- if (variants.length === 1 && isRecord(variants[0]))
15
- return { ...fields, ...variants[0] };
16
- return { ...fields, anyOf: variants };
17
- };
18
3
  const tupleItemsSchema = (items) => {
19
4
  const projected = items.map(moonshotNode);
20
5
  if (projected.length === 0)
@@ -47,19 +32,7 @@ const moonshot = (schema) => {
47
32
  const projected = moonshotNode(schema);
48
33
  return isRecord(projected) ? projected : {};
49
34
  };
50
- const openAI = (schema) => {
51
- const variants = Array.isArray(schema.anyOf) ? schema.anyOf.filter(isRecord) : [];
52
- const flattened = variants.length === 0
53
- ? { ...schema, type: "object" }
54
- : {
55
- ...Object.fromEntries(Object.entries(schema).filter(([key]) => key !== "anyOf")),
56
- type: "object",
57
- properties: variants.reduce((properties, variant) => ({ ...(isRecord(variant.properties) ? variant.properties : {}), ...properties }), {}),
58
- additionalProperties: false,
59
- };
60
- const normalized = removeNullSchemas(flattened);
61
- return isRecord(normalized) ? normalized : { type: "object" };
62
- };
35
+ const openAI = (schema) => schema;
63
36
  const responses = openAI;
64
37
  const gemini = (schema) => GeminiToolSchema.convert(schema) ?? {};
65
38
  const modelCompatibility = (schema, compatibility) => {
@@ -182,6 +182,7 @@ export declare const routes: import("../route/client.js").Route<{
182
182
  readonly thinking?: {
183
183
  readonly type: "enabled";
184
184
  readonly budget_tokens: number;
185
+ readonly display?: "summarized" | "omitted" | undefined;
185
186
  } | {
186
187
  readonly type: "adaptive";
187
188
  readonly display?: "summarized" | "omitted" | undefined;
@@ -166,6 +166,7 @@ export declare const routes: import("../route/client.js").Route<{
166
166
  readonly thinking?: {
167
167
  readonly type: "enabled";
168
168
  readonly budget_tokens: number;
169
+ readonly display?: "summarized" | "omitted" | undefined;
169
170
  } | {
170
171
  readonly type: "adaptive";
171
172
  readonly display?: "summarized" | "omitted" | undefined;
@@ -180,6 +180,7 @@ export declare const routes: Route<{
180
180
  thinking?: {
181
181
  readonly type: "enabled";
182
182
  readonly budget_tokens: number;
183
+ readonly display?: "summarized" | "omitted" | undefined;
183
184
  } | {
184
185
  readonly type: "adaptive";
185
186
  readonly display?: "summarized" | "omitted" | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-dev-18017",
3
+ "version": "0.0.0-dev-18035",
4
4
  "name": "@opencode-ai/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "devDependencies": {
31
31
  "@clack/prompts": "1.0.0-alpha.1",
32
32
  "@effect/platform-node": "4.0.0-rc.111",
33
- "@opencode-ai/http-recorder": "0.0.0-dev-18017",
33
+ "@opencode-ai/http-recorder": "0.0.0-dev-18035",
34
34
  "@tsconfig/bun": "1.0.9",
35
35
  "@types/bun": "1.3.13",
36
36
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@smithy/eventstream-codec": "4.2.14",
41
41
  "@smithy/util-utf8": "4.2.2",
42
- "@opencode-ai/schema": "0.0.0-dev-18017",
42
+ "@opencode-ai/schema": "0.0.0-dev-18035",
43
43
  "aws4fetch": "1.0.20",
44
44
  "effect": "4.0.0-rc.111",
45
45
  "google-auth-library": "10.5.0"