@opencode-ai/ai 0.0.0-beta-17639 → 0.0.0-beta-17728

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.
Files changed (72) hide show
  1. package/README.md +17 -6
  2. package/dist/cache-policy.js +3 -5
  3. package/dist/protocols/anthropic-messages.d.ts +26 -28
  4. package/dist/protocols/anthropic-messages.js +5 -5
  5. package/dist/protocols/gemini.d.ts +5 -9
  6. package/dist/protocols/gemini.js +5 -4
  7. package/dist/protocols/open-responses.d.ts +176 -38
  8. package/dist/protocols/open-responses.js +108 -33
  9. package/dist/protocols/openai-chat.d.ts +17 -15
  10. package/dist/protocols/openai-chat.js +8 -2
  11. package/dist/protocols/openai-compatible-chat.d.ts +3 -3
  12. package/dist/protocols/openai-compatible-responses.d.ts +27 -5
  13. package/dist/protocols/openai-responses.d.ts +151 -33
  14. package/dist/protocols/openai-responses.js +4 -2
  15. package/dist/protocols/shared.d.ts +8 -14
  16. package/dist/protocols/shared.js +8 -14
  17. package/dist/protocols/utils/bedrock-cache.js +3 -4
  18. package/dist/protocols/utils/cache.js +3 -6
  19. package/dist/protocols/utils/open-responses-options.d.ts +46 -15
  20. package/dist/protocols/utils/open-responses-options.js +38 -25
  21. package/dist/protocols/utils/openai-options.d.ts +7 -5
  22. package/dist/protocols/utils/openai-options.js +3 -3
  23. package/dist/provider-package.d.ts +0 -5
  24. package/dist/providers/amazon-bedrock-mantle.d.ts +43 -19
  25. package/dist/providers/amazon-bedrock-mantle.js +0 -1
  26. package/dist/providers/amazon-bedrock.d.ts +3 -9
  27. package/dist/providers/amazon-bedrock.js +0 -1
  28. package/dist/providers/anthropic-compatible.d.ts +11 -11
  29. package/dist/providers/anthropic-compatible.js +0 -1
  30. package/dist/providers/anthropic.d.ts +12 -12
  31. package/dist/providers/anthropic.js +0 -1
  32. package/dist/providers/azure.d.ts +40 -16
  33. package/dist/providers/azure.js +0 -1
  34. package/dist/providers/cloudflare.d.ts +11 -11
  35. package/dist/providers/google-vertex-chat.d.ts +5 -5
  36. package/dist/providers/google-vertex-chat.js +0 -1
  37. package/dist/providers/google-vertex-messages.d.ts +11 -11
  38. package/dist/providers/google-vertex-messages.js +0 -1
  39. package/dist/providers/google-vertex-responses.d.ts +29 -7
  40. package/dist/providers/google-vertex-responses.js +1 -2
  41. package/dist/providers/google-vertex.d.ts +5 -7
  42. package/dist/providers/google-vertex.js +1 -2
  43. package/dist/providers/google.d.ts +4 -4
  44. package/dist/providers/google.js +0 -1
  45. package/dist/providers/open-responses-options.d.ts +3 -14
  46. package/dist/providers/openai-compatible-responses.d.ts +29 -7
  47. package/dist/providers/openai-compatible-responses.js +0 -1
  48. package/dist/providers/openai-compatible.d.ts +13 -12
  49. package/dist/providers/openai-compatible.js +1 -1
  50. package/dist/providers/openai-options.d.ts +2 -4
  51. package/dist/providers/openai-options.js +3 -3
  52. package/dist/providers/openai.d.ts +44 -20
  53. package/dist/providers/openai.js +0 -1
  54. package/dist/providers/openrouter.d.ts +16 -17
  55. package/dist/providers/openrouter.js +1 -2
  56. package/dist/providers/xai.d.ts +46 -24
  57. package/dist/providers/xai.js +1 -2
  58. package/dist/route/client.d.ts +2 -6
  59. package/dist/route/client.js +1 -2
  60. package/dist/route/framing.d.ts +2 -2
  61. package/dist/route/protocol.d.ts +1 -2
  62. package/dist/route/protocol.js +1 -2
  63. package/dist/schema/errors.js +2 -1
  64. package/dist/schema/events.d.ts +5 -3
  65. package/dist/schema/events.js +5 -2
  66. package/dist/schema/ids.d.ts +0 -13
  67. package/dist/schema/ids.js +0 -9
  68. package/dist/schema/messages.d.ts +7 -7
  69. package/dist/schema/messages.js +5 -2
  70. package/dist/schema/options.d.ts +6 -22
  71. package/dist/schema/options.js +6 -30
  72. package/package.json +5 -5
@@ -1,12 +1,10 @@
1
1
  import { type ProviderAuthOption } from "../route/auth-options.js";
2
2
  import { Route, type RouteDefaultsInput } from "../route/client.js";
3
- import { type ModelID, type ProviderOptions } from "../schema/index.js";
3
+ import { type ModelID } from "../schema/index.js";
4
4
  import type { OpenAIOptionsInput } from "./openai-options.js";
5
5
  import type { ProviderPackage } from "../provider-package.js";
6
6
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
- export type XAIProviderOptionsInput = ProviderOptions & {
8
- readonly xai?: OpenAIOptionsInput;
9
- };
7
+ export type XAIProviderOptionsInput = OpenAIOptionsInput;
10
8
  export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
11
9
  readonly baseURL?: string;
12
10
  readonly providerOptions?: XAIProviderOptionsInput;
@@ -79,7 +77,6 @@ export declare const routes: (Route<{
79
77
  } | undefined;
80
78
  })[];
81
79
  readonly stream: true;
82
- readonly stop?: readonly string[] | undefined;
83
80
  readonly max_completion_tokens?: number | undefined;
84
81
  readonly max_tokens?: number | undefined;
85
82
  readonly tools?: readonly {
@@ -96,9 +93,10 @@ export declare const routes: (Route<{
96
93
  readonly ttl?: string | undefined;
97
94
  } | undefined;
98
95
  }[] | undefined;
96
+ readonly stop?: readonly string[] | undefined;
99
97
  readonly temperature?: number | undefined;
100
98
  readonly seed?: number | undefined;
101
- readonly tool_choice?: "required" | "none" | "auto" | {
99
+ readonly tool_choice?: "required" | "auto" | "none" | {
102
100
  readonly type: "function";
103
101
  readonly function: {
104
102
  readonly name: string;
@@ -110,7 +108,7 @@ export declare const routes: (Route<{
110
108
  readonly include_usage: boolean;
111
109
  } | undefined;
112
110
  readonly prompt_cache_key?: string | undefined;
113
- readonly reasoning_effort?: string | undefined;
111
+ readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
114
112
  readonly frequency_penalty?: number | undefined;
115
113
  readonly presence_penalty?: number | undefined;
116
114
  }, import("../route/transport/http.js").HttpPrepared<string>> | Route<{
@@ -146,17 +144,20 @@ export declare const routes: (Route<{
146
144
  readonly text: string;
147
145
  })[];
148
146
  } | {
147
+ readonly type: "message";
149
148
  readonly content: readonly {
150
149
  readonly type: "output_text";
151
150
  readonly text: string;
152
151
  }[];
153
152
  readonly role: "assistant";
153
+ readonly id?: string | undefined;
154
154
  readonly phase?: "commentary" | "final_answer" | undefined;
155
155
  } | {
156
156
  readonly type: "function_call";
157
- readonly call_id: string;
158
157
  readonly name: string;
159
158
  readonly arguments: string;
159
+ readonly call_id: string;
160
+ readonly id?: string | undefined;
160
161
  } | {
161
162
  readonly type: "function_call_output";
162
163
  readonly call_id: string;
@@ -173,19 +174,24 @@ export declare const routes: (Route<{
173
174
  readonly text: string;
174
175
  })[];
175
176
  } | {
177
+ readonly type: "message";
176
178
  readonly content: readonly {
177
179
  readonly type: "output_text";
178
180
  readonly text: string;
179
181
  }[];
180
182
  readonly role: "assistant";
183
+ readonly id?: string | undefined;
181
184
  readonly phase?: "commentary" | "final_answer" | null | undefined;
182
185
  })[];
183
186
  readonly model: string;
184
187
  readonly stream: true;
188
+ readonly metadata?: {
189
+ readonly [x: string]: string;
190
+ } | undefined;
185
191
  readonly instructions?: string | undefined;
186
192
  readonly reasoning?: {
187
193
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
188
- readonly effort?: string | undefined;
194
+ readonly effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
189
195
  } | undefined;
190
196
  readonly tools?: readonly ({
191
197
  readonly type: "function";
@@ -200,54 +206,70 @@ export declare const routes: (Route<{
200
206
  readonly size?: string | undefined;
201
207
  readonly action?: "generate" | "auto" | "edit" | undefined;
202
208
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
203
- readonly quality?: "low" | "medium" | "high" | "auto" | undefined;
209
+ readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
204
210
  readonly background?: "auto" | "opaque" | "transparent" | undefined;
205
211
  readonly output_compression?: number | undefined;
206
212
  readonly input_fidelity?: "low" | "high" | undefined;
207
213
  readonly partial_images?: number | undefined;
208
214
  })[] | undefined;
209
215
  readonly text?: {
210
- readonly verbosity?: "low" | "medium" | "high" | undefined;
216
+ readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
211
217
  } | undefined;
212
218
  readonly temperature?: number | undefined;
213
- readonly tool_choice?: "required" | "none" | "auto" | {
219
+ readonly tool_choice?: "required" | "auto" | "none" | {
214
220
  readonly type: "function";
215
221
  readonly name: string;
222
+ } | {
223
+ readonly type: "allowed_tools";
224
+ readonly mode: "required" | "auto" | "none";
225
+ readonly tools: readonly {
226
+ readonly type: "function";
227
+ readonly name: string;
228
+ }[];
216
229
  } | {
217
230
  readonly type: "image_generation";
218
231
  } | undefined;
219
232
  readonly top_p?: number | undefined;
220
- readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
221
233
  readonly store?: boolean | undefined;
234
+ readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
222
235
  readonly truncation?: "auto" | "disabled" | undefined;
236
+ readonly stream_options?: {
237
+ readonly include_obfuscation?: boolean | undefined;
238
+ } | undefined;
223
239
  readonly prompt_cache_key?: string | undefined;
240
+ readonly frequency_penalty?: number | undefined;
241
+ readonly presence_penalty?: number | undefined;
242
+ readonly safety_identifier?: string | undefined;
243
+ readonly top_logprobs?: number | undefined;
224
244
  readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
225
245
  readonly max_output_tokens?: number | undefined;
246
+ readonly max_tool_calls?: number | undefined;
247
+ readonly parallel_tool_calls?: boolean | undefined;
226
248
  }, import("../route/transport/http.js").HttpPrepared<string>>)[];
227
249
  export declare const configure: (input?: LanguageModelOptions) => {
228
250
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
229
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
230
- responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
231
- chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
251
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
252
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
253
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
232
254
  image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
233
255
  configure: (input?: LanguageModelOptions) => /*elided*/ any;
234
256
  };
235
257
  export declare const provider: {
236
258
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
237
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
238
- responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
239
- chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
259
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
260
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
261
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
240
262
  image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
241
263
  configure: (input?: LanguageModelOptions) => {
242
264
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
243
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
244
- responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
245
- chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
265
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
266
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
267
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
246
268
  image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
247
269
  configure: /*elided*/ any;
248
270
  };
249
271
  };
250
272
  export declare const model: ProviderPackage.Definition<Settings, XAIProviderOptionsInput>["model"];
251
- export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
252
- export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
273
+ export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
274
+ export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
253
275
  export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
@@ -15,7 +15,7 @@ const responsesRoute = Route.make({
15
15
  protocol: OpenAIResponses.protocol,
16
16
  endpoint: Endpoint.path("/responses", { baseURL: OpenAICompatibleProfiles.profiles.xai.baseURL }),
17
17
  transport: OpenAIResponses.httpTransport,
18
- defaults: { providerOptions: { xai: { store: false } } },
18
+ defaults: { providerOptions: { store: false } },
19
19
  });
20
20
  const chatRoute = Route.make({
21
21
  id: "openai-compatible-chat",
@@ -71,7 +71,6 @@ export const model = (modelID, settings) => configure({
71
71
  baseURL: settings.baseURL,
72
72
  headers: settings.headers,
73
73
  http: settings.body === undefined ? undefined : { body: { ...settings.body } },
74
- limits: settings.limits,
75
74
  providerOptions: settings.providerOptions,
76
75
  }).model(modelID);
77
76
  export const responses = provider.responses;
@@ -7,7 +7,7 @@ import { HttpTransport } from "./transport/index.js";
7
7
  import type { HttpMiddleware, Transport, TransportRuntime, WebSocketChannelExecutor } from "./transport/index.js";
8
8
  import type { Protocol } from "./protocol.js";
9
9
  import type { ProtocolID, ProviderOptions } from "../schema/index.js";
10
- import { AIError, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel, LanguageModelLimits, LLMEvent, ProviderID } from "../schema/index.js";
10
+ import { AIError, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel, LLMEvent, ProviderID } from "../schema/index.js";
11
11
  export interface RouteBody<Body> {
12
12
  /** Schema for the validated provider-native body sent as the JSON request. */
13
13
  readonly schema: Schema.Codec<Body, unknown>;
@@ -36,14 +36,12 @@ export type RouteLanguageModelInput = Omit<LanguageModel.Input, "provider" | "ro
36
36
  export type RouteRoutedLanguageModelInput = Omit<LanguageModel.Input, "route">;
37
37
  export interface RouteDefaults {
38
38
  readonly headers?: Record<string, string>;
39
- readonly limits?: LanguageModelLimits;
40
39
  readonly generation?: GenerationOptions;
41
40
  readonly providerOptions?: ProviderOptions;
42
41
  readonly http?: HttpOptions;
43
42
  }
44
43
  export interface RouteDefaultsInput {
45
44
  readonly headers?: Record<string, string>;
46
- readonly limits?: LanguageModelLimits.Input;
47
45
  readonly generation?: GenerationOptions.Input;
48
46
  readonly providerOptions?: ProviderOptions;
49
47
  readonly http?: HttpOptions.Input;
@@ -142,9 +140,7 @@ export declare const compileRequest: (request: LLMRequest) => Effect.Effect<{
142
140
  route: string;
143
141
  protocol: string;
144
142
  model: LanguageModel<{
145
- readonly [x: string]: {
146
- readonly [x: string]: unknown;
147
- };
143
+ readonly [x: string]: unknown;
148
144
  }>;
149
145
  body: any;
150
146
  metadata: {
@@ -6,7 +6,7 @@ import { Framing } from "./framing.js";
6
6
  import { HttpTransport } from "./transport/index.js";
7
7
  import { applyCachePolicy } from "../cache-policy.js";
8
8
  import * as ProviderShared from "../protocols/shared.js";
9
- import { AIError, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel, LanguageModelLimits, LLMEvent, InvalidProviderOutputReason, ProviderID, mergeGenerationOptions, mergeHttpOptions, mergeProviderOptions, } from "../schema/index.js";
9
+ import { AIError, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel, LLMEvent, InvalidProviderOutputReason, ProviderID, mergeGenerationOptions, mergeHttpOptions, mergeProviderOptions, } from "../schema/index.js";
10
10
  const makeRouteLanguageModel = (route, mapped) => {
11
11
  const provider = route.provider ?? ("provider" in mapped ? mapped.provider : undefined);
12
12
  if (!provider)
@@ -25,7 +25,6 @@ const mergeRouteDefaults = (base, patch) => {
25
25
  ...base,
26
26
  ...patch,
27
27
  headers,
28
- limits: patch.limits === undefined ? base?.limits : LanguageModelLimits.make(patch.limits),
29
28
  generation: mergeGenerationOptions(generationOptions(base?.generation), generationOptions(patch.generation)),
30
29
  providerOptions: mergeProviderOptions(base?.providerOptions, patch.providerOptions),
31
30
  http: mergeHttpOptions(base?.http, httpOptions(patch.http), headers === undefined ? undefined : new HttpOptions({ headers })),
@@ -11,8 +11,8 @@ import type { AIError } from "../schema/index.js";
11
11
  * - AWS event stream — length-prefixed binary frames with CRC checksums.
12
12
  * Each emitted frame is one parsed binary event record.
13
13
  *
14
- * The frame type is opaque to this layer; the protocol's `decode` step turns
15
- * a frame into a typed chunk.
14
+ * The frame type is opaque to this layer; the protocol's event schema decodes
15
+ * each frame before its state machine handles it.
16
16
  */
17
17
  export interface Definition<Frame> {
18
18
  readonly id: string;
@@ -69,8 +69,7 @@ export interface ProtocolStream<Frame, Event, State> {
69
69
  *
70
70
  * Provider implementations should usually call `Protocol.make({ ... })`
71
71
  * without explicit type arguments; the schemas and parser functions are the
72
- * source of truth. The constructor remains as the public seam for future
73
- * cross-cutting concerns such as tracing or instrumentation.
72
+ * source of truth.
74
73
  */
75
74
  export declare const make: <Body, Frame, Event, State>(input: Protocol<Body, Frame, Event, State>) => Protocol<Body, Frame, Event, State>;
76
75
  export declare const jsonEvent: <const S extends Schema.Top>(schema: S) => Schema.fromJsonString<S>;
@@ -9,8 +9,7 @@ import { Schema } from "effect";
9
9
  *
10
10
  * Provider implementations should usually call `Protocol.make({ ... })`
11
11
  * without explicit type arguments; the schemas and parser functions are the
12
- * source of truth. The constructor remains as the public seam for future
13
- * cross-cutting concerns such as tracing or instrumentation.
12
+ * source of truth.
14
13
  */
15
14
  export const make = (input) => input;
16
15
  export const jsonEvent = (schema) => Schema.fromJsonString(schema);
@@ -1,6 +1,7 @@
1
1
  import { Schema } from "effect";
2
2
  import { Tool } from "@opencode-ai/schema/tool";
3
- import { ModelID, ProviderID, ProviderMetadata, RouteID } from "./ids.js";
3
+ import { ModelID, ProviderID, RouteID } from "./ids.js";
4
+ import { ProviderMetadata } from "./messages.js";
4
5
  export const ProviderFailureClassification = Schema.Literals(["context-overflow", "payload-too-large"]);
5
6
  export class HttpRequestDetails extends Schema.Class("AI.HttpRequestDetails")({
6
7
  method: Schema.String,
@@ -1,6 +1,9 @@
1
1
  import { Schema } from "effect";
2
- import { ContentBlockID, ProviderMetadata, ToolCallID } from "./ids.js";
3
- import { Message, ToolOutput, ToolResultValue } from "./messages.js";
2
+ import { ContentBlockID, ToolCallID } from "./ids.js";
3
+ import { Message, ProviderMetadata, ToolOutput, ToolResultValue } from "./messages.js";
4
+ export declare const FinishReason: Schema.Literals<readonly ["stop", "length", "tool-calls", "content-filter", "error", "unknown"]>;
5
+ export type FinishReason = Schema.Schema.Type<typeof FinishReason>;
6
+ export { ProviderMetadata } from "./messages.js";
4
7
  declare const Usage_base: Schema.Class<Usage, Schema.Struct<{
5
8
  readonly inputTokens: Schema.optional<Schema.Number>;
6
9
  readonly outputTokens: Schema.optional<Schema.Number>;
@@ -4584,4 +4587,3 @@ export declare namespace LLMResponse {
4584
4587
  /** Concatenate reasoning text from a response or collected event list. */
4585
4588
  const reasoning: (response: Output) => string;
4586
4589
  }
4587
- export {};
@@ -1,7 +1,10 @@
1
1
  import { Schema } from "effect";
2
- import { ContentBlockID, FinishReason, ProviderMetadata, ToolCallID } from "./ids.js";
3
- import { Message, ToolCallPart, ToolOutput, ToolResultPart, ToolResultValue } from "./messages.js";
2
+ import { LLM } from "@opencode-ai/schema/llm";
3
+ import { ContentBlockID, ToolCallID } from "./ids.js";
4
+ import { Message, ProviderMetadata, ToolCallPart, ToolOutput, ToolResultPart, ToolResultValue, } from "./messages.js";
4
5
  import { ProviderFailureClassification } from "./errors.js";
6
+ export const FinishReason = LLM.FinishReason;
7
+ export { ProviderMetadata } from "./messages.js";
5
8
  /**
6
9
  * Token usage reported by an LLM provider.
7
10
  *
@@ -1,6 +1,4 @@
1
1
  import { Schema } from "effect";
2
- import { ProviderMetadata } from "@opencode-ai/schema/ai";
3
- export { ProviderMetadata };
4
2
  /** Stable string identifier for a protocol implementation. */
5
3
  export declare const ProtocolID: Schema.String;
6
4
  export type ProtocolID = Schema.Schema.Type<typeof ProtocolID>;
@@ -17,14 +15,3 @@ export declare const ContentBlockID: Schema.String;
17
15
  export type ContentBlockID = Schema.Schema.Type<typeof ContentBlockID>;
18
16
  export declare const ToolCallID: Schema.String;
19
17
  export type ToolCallID = Schema.Schema.Type<typeof ToolCallID>;
20
- export declare const ReasoningEfforts: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
21
- export declare const ReasoningEffort: Schema.String;
22
- export type ReasoningEffort = Schema.Schema.Type<typeof ReasoningEffort>;
23
- export declare const TextVerbosity: Schema.Literals<readonly ["low", "medium", "high"]>;
24
- export type TextVerbosity = Schema.Schema.Type<typeof TextVerbosity>;
25
- export declare const MessageRole: Schema.Literals<readonly ["system", "user", "assistant", "tool"]>;
26
- export type MessageRole = Schema.Schema.Type<typeof MessageRole>;
27
- export declare const FinishReason: Schema.Literals<readonly ["stop", "length", "tool-calls", "content-filter", "error", "unknown"]>;
28
- export type FinishReason = Schema.Schema.Type<typeof FinishReason>;
29
- export declare const JsonSchema: Schema.$Record<Schema.String, Schema.Unknown>;
30
- export type JsonSchema = Schema.Schema.Type<typeof JsonSchema>;
@@ -1,7 +1,4 @@
1
1
  import { Schema } from "effect";
2
- import { ProviderMetadata } from "@opencode-ai/schema/ai";
3
- import { LLM } from "@opencode-ai/schema/llm";
4
- export { ProviderMetadata };
5
2
  /** Stable string identifier for a protocol implementation. */
6
3
  export const ProtocolID = Schema.String;
7
4
  /** Stable string identifier for the runnable route. */
@@ -11,9 +8,3 @@ export const ProviderID = Schema.String.pipe(Schema.brand("AI.ProviderID"));
11
8
  export const ResponseID = Schema.String;
12
9
  export const ContentBlockID = Schema.String;
13
10
  export const ToolCallID = Schema.String;
14
- export const ReasoningEfforts = ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
15
- export const ReasoningEffort = Schema.String;
16
- export const TextVerbosity = Schema.Literals(["low", "medium", "high"]);
17
- export const MessageRole = Schema.Literals(["system", "user", "assistant", "tool"]);
18
- export const FinishReason = LLM.FinishReason;
19
- export const JsonSchema = Schema.Record(Schema.String, Schema.Unknown);
@@ -1,6 +1,10 @@
1
1
  import { Schema } from "effect";
2
2
  import { Tool } from "@opencode-ai/schema/tool";
3
3
  import { CacheHint, GenerationOptions, HttpOptions } from "./options.js";
4
+ export declare const MessageRole: Schema.Literals<readonly ["system", "user", "assistant", "tool"]>;
5
+ export type MessageRole = Schema.Schema.Type<typeof MessageRole>;
6
+ export declare const ProviderMetadata: Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>;
7
+ export type ProviderMetadata = Schema.Schema.Type<typeof ProviderMetadata>;
4
8
  declare const systemPartSchema: Schema.Struct<{
5
9
  readonly type: Schema.Literal<"text">;
6
10
  readonly text: Schema.String;
@@ -358,13 +362,9 @@ export declare namespace ToolChoice {
358
362
  declare const LLMRequest_base: Schema.Class<LLMRequest, Schema.Struct<{
359
363
  readonly id: Schema.optional<Schema.String>;
360
364
  readonly model: Schema.declare<import("./options.js").LanguageModel<{
361
- readonly [x: string]: {
362
- readonly [x: string]: unknown;
363
- };
365
+ readonly [x: string]: unknown;
364
366
  }>, import("./options.js").LanguageModel<{
365
- readonly [x: string]: {
366
- readonly [x: string]: unknown;
367
- };
367
+ readonly [x: string]: unknown;
368
368
  }>>;
369
369
  readonly system: Schema.$Array<Schema.Struct<{
370
370
  readonly type: Schema.Literal<"text">;
@@ -379,7 +379,7 @@ declare const LLMRequest_base: Schema.Class<LLMRequest, Schema.Struct<{
379
379
  readonly tools: Schema.$Array<typeof ToolDefinition>;
380
380
  readonly toolChoice: Schema.optional<typeof ToolChoice>;
381
381
  readonly generation: Schema.optional<typeof GenerationOptions>;
382
- readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
382
+ readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
383
383
  readonly http: Schema.optional<typeof HttpOptions>;
384
384
  readonly cache: Schema.optional<Schema.Union<readonly [Schema.Literal<"auto">, Schema.Literal<"none">, Schema.Struct<{
385
385
  readonly tools: Schema.optional<Schema.Boolean>;
@@ -1,8 +1,11 @@
1
1
  import { Schema } from "effect";
2
2
  import { Tool } from "@opencode-ai/schema/tool";
3
- import { JsonSchema, MessageRole, ProviderMetadata } from "./ids.js";
4
- import { CacheHint, CachePolicy, GenerationOptions, HttpOptions, LanguageModelSchema, ProviderOptions, } from "./options.js";
3
+ import { CacheHint, CachePolicy, GenerationOptions, HttpOptions, JsonSchema, LanguageModelSchema, ProviderOptions, } from "./options.js";
5
4
  import { isRecord } from "../utils/record.js";
5
+ export const MessageRole = Schema.Literals(["system", "user", "assistant", "tool"]);
6
+ export const ProviderMetadata = Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.Unknown)).annotate({
7
+ identifier: "LLM.ProviderMetadata",
8
+ });
6
9
  const systemPartSchema = Schema.Struct({
7
10
  type: Schema.Literal("text"),
8
11
  text: Schema.String,
@@ -1,8 +1,10 @@
1
1
  import { Schema } from "effect";
2
2
  import { ModelID, ProviderID } from "./ids.js";
3
3
  import type { AnyRoute } from "../route/client.js";
4
+ export declare const JsonSchema: Schema.$Record<Schema.String, Schema.Unknown>;
5
+ export type JsonSchema = Schema.Schema.Type<typeof JsonSchema>;
4
6
  export declare const mergeJsonRecords: (...items: ReadonlyArray<Record<string, unknown> | undefined>) => Record<string, unknown> | undefined;
5
- export declare const ProviderOptions: Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>;
7
+ export declare const ProviderOptions: Schema.$Record<Schema.String, Schema.Unknown>;
6
8
  export type ProviderOptions = Schema.Schema.Type<typeof ProviderOptions>;
7
9
  export declare const mergeProviderOptions: (...items: ReadonlyArray<ProviderOptions | undefined>) => ProviderOptions | undefined;
8
10
  declare const HttpOptions_base: Schema.Class<HttpOptions, Schema.Struct<{
@@ -47,29 +49,15 @@ export type GenerationOptionsFields = {
47
49
  };
48
50
  export type GenerationOptionsInput = GenerationOptions | GenerationOptionsFields;
49
51
  export declare const mergeGenerationOptions: (...items: ReadonlyArray<GenerationOptionsInput | undefined>) => GenerationOptions | undefined;
50
- declare const LanguageModelLimits_base: Schema.Class<LanguageModelLimits, Schema.Struct<{
51
- readonly context: Schema.optional<Schema.Number>;
52
- readonly input: Schema.optional<Schema.Number>;
53
- readonly output: Schema.optional<Schema.Number>;
54
- }>, {}>;
55
- export declare class LanguageModelLimits extends LanguageModelLimits_base {
56
- }
57
- export declare namespace LanguageModelLimits {
58
- type Input = LanguageModelLimits | ConstructorParameters<typeof LanguageModelLimits>[0];
59
- /** Normalize model limit input into the canonical `LanguageModelLimits` class. */
60
- const make: (input: Input | undefined) => LanguageModelLimits;
61
- }
62
52
  declare const LanguageModelDefaults_base: Schema.Class<LanguageModelDefaults, Schema.Struct<{
63
- readonly limits: Schema.optional<typeof LanguageModelLimits>;
64
53
  readonly generation: Schema.optional<typeof GenerationOptions>;
65
- readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
54
+ readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
66
55
  readonly http: Schema.optional<typeof HttpOptions>;
67
56
  }>, {}>;
68
57
  export declare class LanguageModelDefaults extends LanguageModelDefaults_base {
69
58
  }
70
59
  export declare namespace LanguageModelDefaults {
71
60
  type Input = LanguageModelDefaults | {
72
- readonly limits?: LanguageModelLimits.Input;
73
61
  readonly generation?: GenerationOptions.Input;
74
62
  readonly providerOptions?: ProviderOptions;
75
63
  readonly http?: HttpOptions.Input;
@@ -124,13 +112,9 @@ export declare namespace LanguageModel {
124
112
  export type LanguageModelInput = LanguageModel.Input;
125
113
  export type LanguageModelProviderOptions<SelectedModel> = SelectedModel extends LanguageModel<infer Options> ? Options : never;
126
114
  export declare const LanguageModelSchema: Schema.declare<LanguageModel<{
127
- readonly [x: string]: {
128
- readonly [x: string]: unknown;
129
- };
115
+ readonly [x: string]: unknown;
130
116
  }>, LanguageModel<{
131
- readonly [x: string]: {
132
- readonly [x: string]: unknown;
133
- };
117
+ readonly [x: string]: unknown;
134
118
  }>>;
135
119
  declare const CacheHint_base: Schema.Class<CacheHint, Schema.Struct<{
136
120
  readonly type: Schema.Literals<readonly ["ephemeral", "persistent"]>;
@@ -1,6 +1,7 @@
1
1
  import { Schema } from "effect";
2
- import { JsonSchema, ModelID, ProviderID } from "./ids.js";
2
+ import { ModelID, ProviderID } from "./ids.js";
3
3
  import { isRecord } from "../utils/record.js";
4
+ export const JsonSchema = Schema.Record(Schema.String, Schema.Unknown);
4
5
  export const mergeJsonRecords = (...items) => {
5
6
  const defined = items.filter((item) => item !== undefined);
6
7
  if (defined.length === 0)
@@ -26,20 +27,8 @@ const mergeStringRecords = (...items) => {
26
27
  const result = Object.fromEntries(defined.flatMap((item) => Object.entries(item).filter((entry) => entry[1] !== undefined)));
27
28
  return Object.keys(result).length === 0 ? undefined : result;
28
29
  };
29
- export const ProviderOptions = Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.Unknown));
30
- export const mergeProviderOptions = (...items) => {
31
- const result = {};
32
- for (const item of items) {
33
- if (!item)
34
- continue;
35
- for (const [provider, options] of Object.entries(item)) {
36
- const merged = mergeJsonRecords(result[provider], options);
37
- if (merged)
38
- result[provider] = merged;
39
- }
40
- }
41
- return Object.keys(result).length === 0 ? undefined : result;
42
- };
30
+ export const ProviderOptions = Schema.Record(Schema.String, Schema.Unknown);
31
+ export const mergeProviderOptions = (...items) => mergeJsonRecords(...items);
43
32
  export class HttpOptions extends Schema.Class("AI.HttpOptions")({
44
33
  body: Schema.optional(JsonSchema),
45
34
  headers: Schema.optional(Schema.Record(Schema.String, Schema.String)),
@@ -87,18 +76,7 @@ export const mergeGenerationOptions = (...items) => {
87
76
  });
88
77
  return Object.values(result).some((value) => value !== undefined) ? result : undefined;
89
78
  };
90
- export class LanguageModelLimits extends Schema.Class("LLM.LanguageModelLimits")({
91
- context: Schema.optional(Schema.Number),
92
- input: Schema.optional(Schema.Number),
93
- output: Schema.optional(Schema.Number),
94
- }) {
95
- }
96
- (function (LanguageModelLimits) {
97
- /** Normalize model limit input into the canonical `LanguageModelLimits` class. */
98
- LanguageModelLimits.make = (input) => input instanceof LanguageModelLimits ? input : new LanguageModelLimits(input ?? {});
99
- })(LanguageModelLimits || (LanguageModelLimits = {}));
100
79
  export class LanguageModelDefaults extends Schema.Class("LLM.LanguageModelDefaults")({
101
- limits: Schema.optional(LanguageModelLimits),
102
80
  generation: Schema.optional(GenerationOptions),
103
81
  providerOptions: Schema.optional(ProviderOptions),
104
82
  http: Schema.optional(HttpOptions),
@@ -110,7 +88,6 @@ export class LanguageModelDefaults extends Schema.Class("LLM.LanguageModelDefaul
110
88
  if (input instanceof LanguageModelDefaults)
111
89
  return input;
112
90
  return new LanguageModelDefaults({
113
- limits: input.limits === undefined ? undefined : LanguageModelLimits.make(input.limits),
114
91
  generation: input.generation === undefined ? undefined : GenerationOptions.make(input.generation),
115
92
  providerOptions: input.providerOptions,
116
93
  http: input.http === undefined ? undefined : HttpOptions.make(input.http),
@@ -181,10 +158,9 @@ export class CacheHint extends Schema.Class("LLM.CacheHint")({
181
158
  // Auto-placement policy for prompt caching. The protocol-neutral lowering step
182
159
  // reads this and injects `CacheHint`s at the configured boundaries; the
183
160
  // per-protocol body builders then translate those hints into wire markers as
184
- // usual. `"auto"` is the recommended default for agent loops — it places
161
+ // usual. `"auto"` is the default for agent loops — it places
185
162
  // breakpoints at the last tool definition, the first and last distinct system
186
- // parts, and the conversation tail. The rolling message breakpoint keeps a
187
- // prior cache entry within Anthropic/Bedrock's 20-block lookback during long
163
+ // parts, and the conversation tail so recent prefixes remain reusable during
188
164
  // tool loops.
189
165
  //
190
166
  // Pass `"none"` to opt out entirely (the legacy behavior). Pass the granular
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-beta-17639",
3
+ "version": "0.0.0-beta-17728",
4
4
  "name": "@opencode-ai/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@clack/prompts": "1.0.0-alpha.1",
32
- "@effect/platform-node": "4.0.0-beta.107",
33
- "@opencode-ai/http-recorder": "0.0.0-beta-17639",
32
+ "@effect/platform-node": "4.0.0-rc.110",
33
+ "@opencode-ai/http-recorder": "0.0.0-beta-17728",
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,9 +39,9 @@
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-beta-17639",
42
+ "@opencode-ai/schema": "0.0.0-beta-17728",
43
43
  "aws4fetch": "1.0.20",
44
- "effect": "4.0.0-beta.107",
44
+ "effect": "4.0.0-rc.110",
45
45
  "google-auth-library": "10.5.0"
46
46
  }
47
47
  }