@opencode-ai/ai 0.0.0-beta-17595 → 0.0.0-beta-17727

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 (74) 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 +21 -9
  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 +200 -38
  8. package/dist/protocols/open-responses.js +115 -42
  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 +31 -5
  13. package/dist/protocols/openai-responses.d.ts +171 -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 +49 -14
  20. package/dist/protocols/utils/open-responses-options.js +40 -22
  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 +47 -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 +44 -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 +33 -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 -13
  46. package/dist/providers/openai-compatible-responses.d.ts +33 -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 +48 -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 +50 -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/dist/testing.d.ts +2 -1
  73. package/dist/testing.js +7 -2
  74. 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<{
@@ -128,6 +126,9 @@ export declare const routes: (Route<{
128
126
  } | {
129
127
  readonly role: "system";
130
128
  readonly content: string;
129
+ } | {
130
+ readonly role: "developer";
131
+ readonly content: string;
131
132
  } | {
132
133
  readonly role: "user";
133
134
  readonly content: readonly ({
@@ -143,17 +144,20 @@ export declare const routes: (Route<{
143
144
  readonly text: string;
144
145
  })[];
145
146
  } | {
147
+ readonly type: "message";
146
148
  readonly content: readonly {
147
149
  readonly type: "output_text";
148
150
  readonly text: string;
149
151
  }[];
150
152
  readonly role: "assistant";
153
+ readonly id?: string | undefined;
151
154
  readonly phase?: "commentary" | "final_answer" | undefined;
152
155
  } | {
153
156
  readonly type: "function_call";
154
- readonly call_id: string;
155
157
  readonly name: string;
156
158
  readonly arguments: string;
159
+ readonly call_id: string;
160
+ readonly id?: string | undefined;
157
161
  } | {
158
162
  readonly type: "function_call_output";
159
163
  readonly call_id: string;
@@ -170,19 +174,24 @@ export declare const routes: (Route<{
170
174
  readonly text: string;
171
175
  })[];
172
176
  } | {
177
+ readonly type: "message";
173
178
  readonly content: readonly {
174
179
  readonly type: "output_text";
175
180
  readonly text: string;
176
181
  }[];
177
182
  readonly role: "assistant";
183
+ readonly id?: string | undefined;
178
184
  readonly phase?: "commentary" | "final_answer" | null | undefined;
179
185
  })[];
180
186
  readonly model: string;
181
187
  readonly stream: true;
188
+ readonly metadata?: {
189
+ readonly [x: string]: string;
190
+ } | undefined;
182
191
  readonly instructions?: string | undefined;
183
192
  readonly reasoning?: {
184
193
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
185
- readonly effort?: string | undefined;
194
+ readonly effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
186
195
  } | undefined;
187
196
  readonly tools?: readonly ({
188
197
  readonly type: "function";
@@ -197,53 +206,70 @@ export declare const routes: (Route<{
197
206
  readonly size?: string | undefined;
198
207
  readonly action?: "generate" | "auto" | "edit" | undefined;
199
208
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
200
- readonly quality?: "low" | "medium" | "high" | "auto" | undefined;
209
+ readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
201
210
  readonly background?: "auto" | "opaque" | "transparent" | undefined;
202
211
  readonly output_compression?: number | undefined;
203
212
  readonly input_fidelity?: "low" | "high" | undefined;
204
213
  readonly partial_images?: number | undefined;
205
214
  })[] | undefined;
206
215
  readonly text?: {
207
- readonly verbosity?: "low" | "medium" | "high" | undefined;
216
+ readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
208
217
  } | undefined;
209
218
  readonly temperature?: number | undefined;
210
- readonly tool_choice?: "required" | "none" | "auto" | {
219
+ readonly tool_choice?: "required" | "auto" | "none" | {
211
220
  readonly type: "function";
212
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
+ }[];
213
229
  } | {
214
230
  readonly type: "image_generation";
215
231
  } | undefined;
216
232
  readonly top_p?: number | undefined;
217
- 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;
218
233
  readonly store?: boolean | undefined;
234
+ readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
235
+ readonly truncation?: "auto" | "disabled" | undefined;
236
+ readonly stream_options?: {
237
+ readonly include_obfuscation?: boolean | undefined;
238
+ } | undefined;
219
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;
220
244
  readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
221
245
  readonly max_output_tokens?: number | undefined;
246
+ readonly max_tool_calls?: number | undefined;
247
+ readonly parallel_tool_calls?: boolean | undefined;
222
248
  }, import("../route/transport/http.js").HttpPrepared<string>>)[];
223
249
  export declare const configure: (input?: LanguageModelOptions) => {
224
250
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
225
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
226
- responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
227
- 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>;
228
254
  image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
229
255
  configure: (input?: LanguageModelOptions) => /*elided*/ any;
230
256
  };
231
257
  export declare const provider: {
232
258
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
233
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
234
- responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
235
- 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>;
236
262
  image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
237
263
  configure: (input?: LanguageModelOptions) => {
238
264
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
239
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
240
- responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
241
- 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>;
242
268
  image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
243
269
  configure: /*elided*/ any;
244
270
  };
245
271
  };
246
272
  export declare const model: ProviderPackage.Definition<Settings, XAIProviderOptionsInput>["model"];
247
- export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput>;
248
- 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>;
249
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/dist/testing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * as TestLLM from "./testing.js";
2
2
  import { type Interface as LLMClientShape } from "./route/client.js";
3
- import { LLMEvent, type FinishReasonDetails, type AIError, type LLMRequest, type UsageInput } from "./schema/index.js";
3
+ import { LLMEvent, type FinishReasonDetails, type AIError, type LLMRequest, type ProviderMetadata, type UsageInput } from "./schema/index.js";
4
4
  import { Context, Effect, Layer, Scope, Stream } from "effect";
5
5
  export type Response = readonly LLMEvent[] | Stream.Stream<LLMEvent, AIError>;
6
6
  export type Gate = Readonly<{
@@ -26,6 +26,7 @@ export declare class Service extends Service_base {
26
26
  export declare const complete: (options: {
27
27
  readonly reason: FinishReasonDetails;
28
28
  readonly usage?: UsageInput;
29
+ readonly providerMetadata?: ProviderMetadata;
29
30
  }, ...events: readonly LLMEvent[]) => ({
30
31
  readonly type: "step-start";
31
32
  readonly index: number;
package/dist/testing.js CHANGED
@@ -7,8 +7,13 @@ export class Service extends Context.Service()("@opencode/ai/TestLLM") {
7
7
  export const complete = (options, ...events) => [
8
8
  LLMEvent.stepStart({ index: 0 }),
9
9
  ...events,
10
- LLMEvent.stepFinish({ index: 0, reason: options.reason, usage: options.usage }),
11
- LLMEvent.finish({ reason: options.reason }),
10
+ LLMEvent.stepFinish({
11
+ index: 0,
12
+ reason: options.reason,
13
+ usage: options.usage,
14
+ providerMetadata: options.providerMetadata,
15
+ }),
16
+ LLMEvent.finish({ reason: options.reason, providerMetadata: options.providerMetadata }),
12
17
  ];
13
18
  export const stop = (...events) => complete({ reason: { normalized: "stop" } }, ...events);
14
19
  export const toolCalls = (...events) => complete({ reason: { normalized: "tool-calls" } }, ...events);
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-17595",
3
+ "version": "0.0.0-beta-17727",
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-17595",
32
+ "@effect/platform-node": "4.0.0-rc.110",
33
+ "@opencode-ai/http-recorder": "0.0.0-beta-17727",
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-17595",
42
+ "@opencode-ai/schema": "0.0.0-beta-17727",
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
  }