@opencode-ai/ai 0.0.0-dev-17675 → 0.0.0-dev-17684

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 (58) hide show
  1. package/README.md +16 -4
  2. package/dist/cache-policy.js +3 -5
  3. package/dist/protocols/anthropic-messages.d.ts +25 -28
  4. package/dist/protocols/anthropic-messages.js +3 -3
  5. package/dist/protocols/gemini.d.ts +5 -9
  6. package/dist/protocols/gemini.js +2 -3
  7. package/dist/protocols/open-responses.d.ts +33 -33
  8. package/dist/protocols/open-responses.js +1 -1
  9. package/dist/protocols/openai-chat.d.ts +15 -15
  10. package/dist/protocols/openai-compatible-chat.d.ts +3 -3
  11. package/dist/protocols/openai-compatible-responses.d.ts +4 -4
  12. package/dist/protocols/openai-responses.d.ts +28 -28
  13. package/dist/protocols/openai-responses.js +1 -1
  14. package/dist/protocols/shared.d.ts +8 -14
  15. package/dist/protocols/shared.js +8 -14
  16. package/dist/protocols/utils/bedrock-cache.js +3 -4
  17. package/dist/protocols/utils/cache.js +3 -6
  18. package/dist/protocols/utils/open-responses-options.d.ts +10 -5
  19. package/dist/protocols/utils/open-responses-options.js +5 -3
  20. package/dist/protocols/utils/openai-options.d.ts +6 -4
  21. package/dist/protocols/utils/openai-options.js +3 -3
  22. package/dist/providers/amazon-bedrock-mantle.d.ts +18 -18
  23. package/dist/providers/amazon-bedrock.d.ts +3 -9
  24. package/dist/providers/anthropic-compatible.d.ts +11 -11
  25. package/dist/providers/anthropic.d.ts +12 -12
  26. package/dist/providers/azure.d.ts +15 -15
  27. package/dist/providers/cloudflare.d.ts +11 -11
  28. package/dist/providers/google-vertex-chat.d.ts +5 -5
  29. package/dist/providers/google-vertex-messages.d.ts +11 -11
  30. package/dist/providers/google-vertex-responses.d.ts +6 -6
  31. package/dist/providers/google-vertex-responses.js +1 -1
  32. package/dist/providers/google-vertex.d.ts +5 -7
  33. package/dist/providers/google-vertex.js +1 -1
  34. package/dist/providers/google.d.ts +4 -4
  35. package/dist/providers/open-responses-options.d.ts +1 -4
  36. package/dist/providers/openai-compatible-responses.d.ts +6 -6
  37. package/dist/providers/openai-compatible.d.ts +12 -12
  38. package/dist/providers/openai-options.d.ts +2 -4
  39. package/dist/providers/openai-options.js +3 -3
  40. package/dist/providers/openai.d.ts +19 -19
  41. package/dist/providers/openrouter.d.ts +15 -17
  42. package/dist/providers/openrouter.js +1 -1
  43. package/dist/providers/xai.d.ts +21 -23
  44. package/dist/providers/xai.js +1 -1
  45. package/dist/route/client.d.ts +1 -3
  46. package/dist/route/framing.d.ts +2 -2
  47. package/dist/route/protocol.d.ts +1 -2
  48. package/dist/route/protocol.js +1 -2
  49. package/dist/schema/errors.js +2 -1
  50. package/dist/schema/events.d.ts +5 -3
  51. package/dist/schema/events.js +5 -2
  52. package/dist/schema/ids.d.ts +0 -13
  53. package/dist/schema/ids.js +0 -9
  54. package/dist/schema/messages.d.ts +7 -7
  55. package/dist/schema/messages.js +5 -2
  56. package/dist/schema/options.d.ts +6 -8
  57. package/dist/schema/options.js +6 -18
  58. package/package.json +3 -3
@@ -69,7 +69,6 @@ export declare const route: Route<{
69
69
  } | undefined;
70
70
  })[];
71
71
  readonly stream: true;
72
- readonly stop?: readonly string[] | undefined;
73
72
  readonly max_completion_tokens?: number | undefined;
74
73
  readonly max_tokens?: number | undefined;
75
74
  readonly tools?: readonly {
@@ -86,9 +85,10 @@ export declare const route: Route<{
86
85
  readonly ttl?: string | undefined;
87
86
  } | undefined;
88
87
  }[] | undefined;
88
+ readonly stop?: readonly string[] | undefined;
89
89
  readonly temperature?: number | undefined;
90
90
  readonly seed?: number | undefined;
91
- readonly tool_choice?: "required" | "none" | "auto" | {
91
+ readonly tool_choice?: "required" | "auto" | "none" | {
92
92
  readonly type: "function";
93
93
  readonly function: {
94
94
  readonly name: string;
@@ -100,7 +100,7 @@ export declare const route: Route<{
100
100
  readonly include_usage: boolean;
101
101
  } | undefined;
102
102
  readonly prompt_cache_key?: string | undefined;
103
- readonly reasoning_effort?: string | undefined;
103
+ readonly reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
104
104
  readonly frequency_penalty?: number | undefined;
105
105
  readonly presence_penalty?: number | undefined;
106
106
  }, import("../route/transport/http.js").HttpPrepared<string>>;
@@ -70,7 +70,7 @@ export declare const route: Route<{
70
70
  readonly instructions?: string | undefined;
71
71
  readonly reasoning?: {
72
72
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
73
- readonly effort?: string | undefined;
73
+ readonly effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
74
74
  } | undefined;
75
75
  readonly tools?: readonly {
76
76
  readonly type: "function";
@@ -82,15 +82,15 @@ export declare const route: Route<{
82
82
  readonly strict?: boolean | undefined;
83
83
  }[] | undefined;
84
84
  readonly text?: {
85
- readonly verbosity?: "low" | "medium" | "high" | undefined;
85
+ readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
86
86
  } | undefined;
87
87
  readonly temperature?: number | undefined;
88
- readonly tool_choice?: "required" | "none" | "auto" | {
88
+ readonly tool_choice?: "required" | "auto" | "none" | {
89
89
  readonly type: "function";
90
90
  readonly name: string;
91
91
  } | {
92
92
  readonly type: "allowed_tools";
93
- readonly mode: "required" | "none" | "auto";
93
+ readonly mode: "required" | "auto" | "none";
94
94
  readonly tools: readonly {
95
95
  readonly type: "function";
96
96
  readonly name: string;
@@ -111,11 +111,11 @@ declare const OpenAIResponsesBody: Schema.Struct<{
111
111
  readonly prompt_cache_key: Schema.optional<Schema.String>;
112
112
  readonly include: Schema.optional<Schema.$Array<Schema.declare<import("./utils/open-responses-options.js").ResponseIncludable, import("./utils/open-responses-options.js").ResponseIncludable>>>;
113
113
  readonly reasoning: Schema.optional<Schema.Struct<{
114
- readonly effort: Schema.optional<Schema.String>;
114
+ readonly effort: Schema.optional<Schema.declare<import("./utils/open-responses-options.js").ReasoningEffort, import("./utils/open-responses-options.js").ReasoningEffort>>;
115
115
  readonly summary: Schema.optional<Schema.Literals<readonly ["auto", "concise", "detailed"]>>;
116
116
  }>>;
117
117
  readonly text: Schema.optional<Schema.Struct<{
118
- readonly verbosity: Schema.optional<Schema.Literals<readonly ["low", "medium", "high"]>>;
118
+ readonly verbosity: Schema.optional<Schema.declare<import("./utils/open-responses-options.js").TextVerbosity, import("./utils/open-responses-options.js").TextVerbosity>>;
119
119
  }>>;
120
120
  readonly max_output_tokens: Schema.optional<Schema.Number>;
121
121
  readonly max_tool_calls: Schema.optional<Schema.Int>;
@@ -196,7 +196,7 @@ export declare const protocol: Protocol<{
196
196
  readonly instructions?: string | undefined;
197
197
  readonly reasoning?: {
198
198
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
199
- readonly effort?: string | undefined;
199
+ readonly effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
200
200
  } | undefined;
201
201
  readonly tools?: readonly ({
202
202
  readonly type: "function";
@@ -211,22 +211,22 @@ export declare const protocol: Protocol<{
211
211
  readonly size?: string | undefined;
212
212
  readonly action?: "generate" | "auto" | "edit" | undefined;
213
213
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
214
- readonly quality?: "low" | "medium" | "high" | "auto" | undefined;
214
+ readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
215
215
  readonly background?: "auto" | "opaque" | "transparent" | undefined;
216
216
  readonly output_compression?: number | undefined;
217
217
  readonly input_fidelity?: "low" | "high" | undefined;
218
218
  readonly partial_images?: number | undefined;
219
219
  })[] | undefined;
220
220
  readonly text?: {
221
- readonly verbosity?: "low" | "medium" | "high" | undefined;
221
+ readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
222
222
  } | undefined;
223
223
  readonly temperature?: number | undefined;
224
- readonly tool_choice?: "required" | "none" | "auto" | {
224
+ readonly tool_choice?: "required" | "auto" | "none" | {
225
225
  readonly type: "function";
226
226
  readonly name: string;
227
227
  } | {
228
228
  readonly type: "allowed_tools";
229
- readonly mode: "required" | "none" | "auto";
229
+ readonly mode: "required" | "auto" | "none";
230
230
  readonly tools: readonly {
231
231
  readonly type: "function";
232
232
  readonly name: string;
@@ -246,17 +246,17 @@ export declare const protocol: Protocol<{
246
246
  }, string, {
247
247
  readonly [x: string]: unknown;
248
248
  readonly type: string;
249
+ readonly status?: unknown;
250
+ readonly code?: string | null | undefined;
251
+ readonly message?: string | undefined;
252
+ readonly headers?: unknown;
253
+ readonly text?: string | undefined;
249
254
  readonly error?: {
250
255
  readonly type?: string | null | undefined;
251
256
  readonly code?: string | null | undefined;
252
257
  readonly message?: string | null | undefined;
253
258
  readonly param?: string | null | undefined;
254
259
  } | null | undefined;
255
- readonly status?: unknown;
256
- readonly code?: string | null | undefined;
257
- readonly message?: string | undefined;
258
- readonly headers?: unknown;
259
- readonly text?: string | undefined;
260
260
  readonly item?: {
261
261
  readonly [x: string]: unknown;
262
262
  readonly type: string;
@@ -269,13 +269,13 @@ export declare const protocol: Protocol<{
269
269
  readonly delta?: string | undefined;
270
270
  readonly response?: {
271
271
  readonly [x: string]: unknown;
272
+ readonly id?: string | undefined;
272
273
  readonly error?: {
273
274
  readonly type?: string | null | undefined;
274
275
  readonly code?: string | null | undefined;
275
276
  readonly message?: string | null | undefined;
276
277
  readonly param?: string | null | undefined;
277
278
  } | null | undefined;
278
- readonly id?: string | undefined;
279
279
  readonly usage?: {
280
280
  readonly input_tokens?: number | undefined;
281
281
  readonly output_tokens?: number | undefined;
@@ -370,7 +370,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
370
370
  readonly instructions?: string | undefined;
371
371
  readonly reasoning?: {
372
372
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
373
- readonly effort?: string | undefined;
373
+ readonly effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
374
374
  } | undefined;
375
375
  readonly tools?: readonly ({
376
376
  readonly type: "function";
@@ -385,22 +385,22 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
385
385
  readonly size?: string | undefined;
386
386
  readonly action?: "generate" | "auto" | "edit" | undefined;
387
387
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
388
- readonly quality?: "low" | "medium" | "high" | "auto" | undefined;
388
+ readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
389
389
  readonly background?: "auto" | "opaque" | "transparent" | undefined;
390
390
  readonly output_compression?: number | undefined;
391
391
  readonly input_fidelity?: "low" | "high" | undefined;
392
392
  readonly partial_images?: number | undefined;
393
393
  })[] | undefined;
394
394
  readonly text?: {
395
- readonly verbosity?: "low" | "medium" | "high" | undefined;
395
+ readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
396
396
  } | undefined;
397
397
  readonly temperature?: number | undefined;
398
- readonly tool_choice?: "required" | "none" | "auto" | {
398
+ readonly tool_choice?: "required" | "auto" | "none" | {
399
399
  readonly type: "function";
400
400
  readonly name: string;
401
401
  } | {
402
402
  readonly type: "allowed_tools";
403
- readonly mode: "required" | "none" | "auto";
403
+ readonly mode: "required" | "auto" | "none";
404
404
  readonly tools: readonly {
405
405
  readonly type: "function";
406
406
  readonly name: string;
@@ -490,7 +490,7 @@ export declare const transport: import("../route/transport/index.js").Transport<
490
490
  readonly instructions?: string | undefined;
491
491
  readonly reasoning?: {
492
492
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
493
- readonly effort?: string | undefined;
493
+ readonly effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
494
494
  } | undefined;
495
495
  readonly tools?: readonly ({
496
496
  readonly type: "function";
@@ -505,22 +505,22 @@ export declare const transport: import("../route/transport/index.js").Transport<
505
505
  readonly size?: string | undefined;
506
506
  readonly action?: "generate" | "auto" | "edit" | undefined;
507
507
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
508
- readonly quality?: "low" | "medium" | "high" | "auto" | undefined;
508
+ readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
509
509
  readonly background?: "auto" | "opaque" | "transparent" | undefined;
510
510
  readonly output_compression?: number | undefined;
511
511
  readonly input_fidelity?: "low" | "high" | undefined;
512
512
  readonly partial_images?: number | undefined;
513
513
  })[] | undefined;
514
514
  readonly text?: {
515
- readonly verbosity?: "low" | "medium" | "high" | undefined;
515
+ readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
516
516
  } | undefined;
517
517
  readonly temperature?: number | undefined;
518
- readonly tool_choice?: "required" | "none" | "auto" | {
518
+ readonly tool_choice?: "required" | "auto" | "none" | {
519
519
  readonly type: "function";
520
520
  readonly name: string;
521
521
  } | {
522
522
  readonly type: "allowed_tools";
523
- readonly mode: "required" | "none" | "auto";
523
+ readonly mode: "required" | "auto" | "none";
524
524
  readonly tools: readonly {
525
525
  readonly type: "function";
526
526
  readonly name: string;
@@ -610,7 +610,7 @@ export declare const route: Route<{
610
610
  readonly instructions?: string | undefined;
611
611
  readonly reasoning?: {
612
612
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
613
- readonly effort?: string | undefined;
613
+ readonly effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
614
614
  } | undefined;
615
615
  readonly tools?: readonly ({
616
616
  readonly type: "function";
@@ -625,22 +625,22 @@ export declare const route: Route<{
625
625
  readonly size?: string | undefined;
626
626
  readonly action?: "generate" | "auto" | "edit" | undefined;
627
627
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
628
- readonly quality?: "low" | "medium" | "high" | "auto" | undefined;
628
+ readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
629
629
  readonly background?: "auto" | "opaque" | "transparent" | undefined;
630
630
  readonly output_compression?: number | undefined;
631
631
  readonly input_fidelity?: "low" | "high" | undefined;
632
632
  readonly partial_images?: number | undefined;
633
633
  })[] | undefined;
634
634
  readonly text?: {
635
- readonly verbosity?: "low" | "medium" | "high" | undefined;
635
+ readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
636
636
  } | undefined;
637
637
  readonly temperature?: number | undefined;
638
- readonly tool_choice?: "required" | "none" | "auto" | {
638
+ readonly tool_choice?: "required" | "auto" | "none" | {
639
639
  readonly type: "function";
640
640
  readonly name: string;
641
641
  } | {
642
642
  readonly type: "allowed_tools";
643
- readonly mode: "required" | "none" | "auto";
643
+ readonly mode: "required" | "auto" | "none";
644
644
  readonly tools: readonly {
645
645
  readonly type: "function";
646
646
  readonly name: string;
@@ -203,6 +203,6 @@ export const route = Route.make({
203
203
  endpoint,
204
204
  auth,
205
205
  transport,
206
- defaults: { providerOptions: { openai: { store: false } } },
206
+ defaults: { providerOptions: { store: false } },
207
207
  });
208
208
  export * as OpenAIResponses from "./openai-responses.js";
@@ -26,12 +26,10 @@ export interface ToolAccumulator {
26
26
  * when at least one is defined. Returns `undefined` when neither input nor
27
27
  * output is known so routes don't publish a misleading `0`.
28
28
  *
29
- * Under the additive `AI.Usage` contract, `inputTokens` and `outputTokens`
30
- * are the non-cached input and visible output only. The provider-supplied
31
- * `total` is the source of truth when present; the computed fallback
32
- * under-counts cache and reasoning by design and exists mainly so
33
- * Anthropic-style providers (which don't surface a total) still get a
34
- * sensible aggregate on the input + output axes.
29
+ * Under the inclusive `AI.Usage` contract, `inputTokens` includes cached input
30
+ * and `outputTokens` includes reasoning. Protocol mappers normalize those
31
+ * inclusive values before calling this helper. The provider-supplied total is
32
+ * the source of truth when present; otherwise their sum is the canonical total.
35
33
  */
36
34
  export declare const totalTokens: (inputTokens: number | undefined, outputTokens: number | undefined, total: number | undefined) => number | undefined;
37
35
  /**
@@ -43,7 +41,7 @@ export declare const totalTokens: (inputTokens: number | undefined, outputTokens
43
41
  *
44
42
  * If `total` is `undefined`, returns `undefined` (we don't fabricate
45
43
  * counts). If `subtrahend` is `undefined`, returns `total` unchanged. The
46
- * provider-native breakdown stays available on `Usage.native` for debugging.
44
+ * provider-native breakdown stays available on `Usage.providerMetadata` for debugging.
47
45
  */
48
46
  export declare const subtractTokens: (total: number | undefined, subtrahend: number | undefined) => number | undefined;
49
47
  /**
@@ -117,19 +115,15 @@ export declare const toolResultText: (part: ToolResultPart) => string;
117
115
  export declare const errorText: (error: unknown) => string;
118
116
  /**
119
117
  * `framing` step for Server-Sent Events. Decodes UTF-8, runs the SSE channel
120
- * decoder, and drops empty / `[DONE]` keep-alive events so the downstream
121
- * `decodeChunk` sees one JSON string per element. The SSE channel emits a
118
+ * decoder, and drops empty / `[DONE]` keep-alive events so the protocol event
119
+ * schema sees one JSON string per element. The SSE channel emits a
122
120
  * `Retry` control event on its error channel; we drop it here (we don't
123
121
  * implement client-driven retries). Decoder failures become provider output
124
122
  * errors so the public error channel stays `AIError`.
125
123
  */
126
124
  export declare const sseFraming: (bytes: Stream.Stream<Uint8Array, AIError>) => Stream.Stream<string, AIError>;
127
125
  /**
128
- * Canonical invalid-request constructor. Lift one-line `const invalid =
129
- * (message) => invalidRequest(message)` aliases out of every
130
- * route so the error constructor lives in one place. If we ever extend
131
- * `InvalidRequestReason` with route context or trace metadata, the change
132
- * lands here.
126
+ * Canonical invalid-request constructor shared by protocol lowering.
133
127
  */
134
128
  export declare const invalidRequest: (message: string) => AIError;
135
129
  export declare const matchToolChoice: <Auto, None, Required, Tool>(route: string, toolChoice: NonNullable<LLMRequest["toolChoice"]>, cases: {
@@ -19,12 +19,10 @@ export const optionalNull = (schema) => Schema.optional(Schema.NullOr(schema));
19
19
  * when at least one is defined. Returns `undefined` when neither input nor
20
20
  * output is known so routes don't publish a misleading `0`.
21
21
  *
22
- * Under the additive `AI.Usage` contract, `inputTokens` and `outputTokens`
23
- * are the non-cached input and visible output only. The provider-supplied
24
- * `total` is the source of truth when present; the computed fallback
25
- * under-counts cache and reasoning by design and exists mainly so
26
- * Anthropic-style providers (which don't surface a total) still get a
27
- * sensible aggregate on the input + output axes.
22
+ * Under the inclusive `AI.Usage` contract, `inputTokens` includes cached input
23
+ * and `outputTokens` includes reasoning. Protocol mappers normalize those
24
+ * inclusive values before calling this helper. The provider-supplied total is
25
+ * the source of truth when present; otherwise their sum is the canonical total.
28
26
  */
29
27
  export const totalTokens = (inputTokens, outputTokens, total) => {
30
28
  if (total !== undefined)
@@ -42,7 +40,7 @@ export const totalTokens = (inputTokens, outputTokens, total) => {
42
40
  *
43
41
  * If `total` is `undefined`, returns `undefined` (we don't fabricate
44
42
  * counts). If `subtrahend` is `undefined`, returns `total` unchanged. The
45
- * provider-native breakdown stays available on `Usage.native` for debugging.
43
+ * provider-native breakdown stays available on `Usage.providerMetadata` for debugging.
46
44
  */
47
45
  export const subtractTokens = (total, subtrahend) => {
48
46
  if (total === undefined)
@@ -151,19 +149,15 @@ export const errorText = (error) => {
151
149
  };
152
150
  /**
153
151
  * `framing` step for Server-Sent Events. Decodes UTF-8, runs the SSE channel
154
- * decoder, and drops empty / `[DONE]` keep-alive events so the downstream
155
- * `decodeChunk` sees one JSON string per element. The SSE channel emits a
152
+ * decoder, and drops empty / `[DONE]` keep-alive events so the protocol event
153
+ * schema sees one JSON string per element. The SSE channel emits a
156
154
  * `Retry` control event on its error channel; we drop it here (we don't
157
155
  * implement client-driven retries). Decoder failures become provider output
158
156
  * errors so the public error channel stays `AIError`.
159
157
  */
160
158
  export const sseFraming = (bytes) => bytes.pipe(Stream.decodeText(), Stream.pipeThroughChannel(Sse.decode()), Stream.catchTag("Retry", () => Stream.empty), Stream.catchTag("SseError", (error) => Stream.fail(eventError("sse", error.message))), Stream.filter((event) => event.data.length > 0 && event.data !== "[DONE]"), Stream.map((event) => event.data));
161
159
  /**
162
- * Canonical invalid-request constructor. Lift one-line `const invalid =
163
- * (message) => invalidRequest(message)` aliases out of every
164
- * route so the error constructor lives in one place. If we ever extend
165
- * `InvalidRequestReason` with route context or trace metadata, the change
166
- * lands here.
160
+ * Canonical invalid-request constructor shared by protocol lowering.
167
161
  */
168
162
  export const invalidRequest = (message) => new AIError({
169
163
  module: "ProviderShared",
@@ -2,16 +2,15 @@ import { Schema } from "effect";
2
2
  import { newBreakpoints, ttlBucket } from "./cache.js";
3
3
  // Bedrock cache markers are positional: emit a `cachePoint` block immediately
4
4
  // after the content the caller wants treated as a cacheable prefix. Bedrock
5
- // accepts optional `ttl: "5m" | "1h"` on cachePoint, mirroring Anthropic.
5
+ // accepts optional `ttl: "5m" | "1h"` on cachePoint.
6
6
  export const CachePointBlock = Schema.Struct({
7
7
  cachePoint: Schema.Struct({
8
8
  type: Schema.tag("default"),
9
9
  ttl: Schema.optional(Schema.Literals(["5m", "1h"])),
10
10
  }),
11
11
  });
12
- // Bedrock-Claude enforces the same 4-breakpoint cap as the Anthropic Messages
13
- // API. Callers pass a shared counter through every `block()` call site so the
14
- // budget is respected across `system`, `messages`, and `tools`.
12
+ // Callers pass a shared counter through every `block()` call site so the
13
+ // four-breakpoint budget is respected across `system`, `messages`, and `tools`.
15
14
  export const BEDROCK_BREAKPOINT_CAP = 4;
16
15
  export const breakpoints = () => newBreakpoints(BEDROCK_BREAKPOINT_CAP);
17
16
  const DEFAULT_5M = { cachePoint: { type: "default" } };
@@ -1,8 +1,5 @@
1
- // Shared helpers for provider cache-marker lowering. Anthropic and Bedrock
2
- // both enforce a 4-breakpoint cap per request and accept the same `5m`/`1h`
3
- // TTL buckets, so the counter and TTL mapping live here.
1
+ // Shared counter and TTL mapping for provider cache-marker lowering.
4
2
  export const newBreakpoints = (cap) => ({ remaining: cap, dropped: 0 });
5
- // Returns `"1h"` for any `ttlSeconds >= 3600`, otherwise `undefined` (the
6
- // provider default 5m). Anthropic & Bedrock both treat anything shorter than
7
- // an hour as 5m.
3
+ // Requests of at least one hour use the explicit `"1h"` bucket; shorter
4
+ // requests omit the wire TTL and use the provider default.
8
5
  export const ttlBucket = (ttlSeconds) => ttlSeconds !== undefined && ttlSeconds >= 3600 ? "1h" : undefined;
@@ -1,13 +1,18 @@
1
1
  import { Schema } from "effect";
2
- import { type LLMRequest } from "../../schema/index.js";
2
+ import type { LLMRequest } from "../../schema/index.js";
3
+ export declare const ReasoningEfforts: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
4
+ export type ReasoningEffort = (typeof ReasoningEfforts)[number] | (string & {});
5
+ export declare const ReasoningEffort: Schema.declare<ReasoningEffort, ReasoningEffort>;
6
+ export declare const TextVerbosities: readonly ["low", "medium", "high"];
7
+ export type TextVerbosity = (typeof TextVerbosities)[number] | (string & {});
8
+ export declare const TextVerbosity: Schema.declare<TextVerbosity, TextVerbosity>;
3
9
  export declare const ResponseIncludables: 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"];
4
10
  export type ResponseIncludable = (typeof ResponseIncludables)[number] | (string & {});
5
11
  export declare const ServiceTiers: readonly ["auto", "default", "flex", "priority"];
6
12
  export type ServiceTier = (typeof ServiceTiers)[number];
7
13
  export declare const Truncations: readonly ["auto", "disabled"];
8
14
  export type Truncation = (typeof Truncations)[number];
9
- export declare const ReasoningEffort: Schema.String;
10
- export declare const TextVerbositySchema: Schema.Literals<readonly ["low", "medium", "high"]>;
15
+ export declare const TextVerbositySchema: Schema.declare<TextVerbosity, TextVerbosity>;
11
16
  export declare const ResponseIncludableSchema: Schema.declare<ResponseIncludable, ResponseIncludable>;
12
17
  export declare const ServiceTierSchema: Schema.Literals<readonly ["auto", "default", "flex", "priority"]>;
13
18
  export declare const TruncationSchema: Schema.Literals<readonly ["auto", "disabled"]>;
@@ -19,10 +24,10 @@ export type AllowedTools = typeof AllowedTools.Type;
19
24
  export declare const Options: Schema.Struct<{
20
25
  readonly instructions: Schema.optional<Schema.String>;
21
26
  readonly store: Schema.optional<Schema.Boolean>;
22
- readonly reasoningEffort: Schema.optional<Schema.String>;
27
+ readonly reasoningEffort: Schema.optional<Schema.declare<ReasoningEffort, ReasoningEffort>>;
23
28
  readonly reasoningSummary: Schema.optional<Schema.Literals<readonly ["auto", "concise", "detailed"]>>;
24
29
  readonly include: Schema.optional<Schema.$Array<Schema.declare<ResponseIncludable, ResponseIncludable>>>;
25
- readonly textVerbosity: Schema.optional<Schema.Literals<readonly ["low", "medium", "high"]>>;
30
+ readonly textVerbosity: Schema.optional<Schema.declare<TextVerbosity, TextVerbosity>>;
26
31
  readonly serviceTier: Schema.optional<Schema.Literals<readonly ["auto", "default", "flex", "priority"]>>;
27
32
  readonly truncation: Schema.optional<Schema.Literals<readonly ["auto", "disabled"]>>;
28
33
  readonly allowedTools: Schema.optional<Schema.Struct<{
@@ -1,5 +1,8 @@
1
1
  import { Option, Schema } from "effect";
2
- import { TextVerbosity } from "../../schema/index.js";
2
+ export const ReasoningEfforts = ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
3
+ export const ReasoningEffort = Schema.declare((value) => typeof value === "string", { title: "ReasoningEffort" });
4
+ export const TextVerbosities = ["low", "medium", "high"];
5
+ export const TextVerbosity = Schema.declare((value) => typeof value === "string", { title: "TextVerbosity" });
3
6
  export const ResponseIncludables = [
4
7
  "file_search_call.results",
5
8
  "web_search_call.results",
@@ -12,7 +15,6 @@ export const ResponseIncludables = [
12
15
  ];
13
16
  export const ServiceTiers = ["auto", "default", "flex", "priority"];
14
17
  export const Truncations = ["auto", "disabled"];
15
- export const ReasoningEffort = Schema.String;
16
18
  export const TextVerbositySchema = TextVerbosity;
17
19
  export const ResponseIncludableSchema = Schema.declare((value) => typeof value === "string", { title: "ResponseIncludable" });
18
20
  export const ServiceTierSchema = Schema.Literals(ServiceTiers);
@@ -36,7 +38,7 @@ export const Options = Schema.Struct({
36
38
  });
37
39
  const decodeOptions = Schema.decodeUnknownOption(Options);
38
40
  export const resolve = (request) => {
39
- const input = Option.getOrUndefined(decodeOptions(request.providerOptions?.[request.model.route.providerMetadataKey ?? "openresponses"]));
41
+ const input = Option.getOrUndefined(decodeOptions(request.providerOptions));
40
42
  if (!input)
41
43
  return {};
42
44
  return {
@@ -1,14 +1,16 @@
1
1
  import { OpenResponsesOptions } from "./open-responses-options.js";
2
2
  export declare const OpenAIReasoningEfforts: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
3
- export type OpenAIReasoningEffort = string;
3
+ export type OpenAIReasoningEffort = OpenResponsesOptions.ReasoningEffort;
4
+ export declare const OpenAITextVerbosities: readonly ["low", "medium", "high"];
5
+ export type OpenAITextVerbosity = OpenResponsesOptions.TextVerbosity;
4
6
  export declare const OpenAIResponseIncludables: 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"];
5
7
  export type OpenAIResponseIncludable = OpenResponsesOptions.ResponseIncludable;
6
8
  export declare const OpenAIServiceTiers: readonly ["auto", "default", "flex", "priority"];
7
9
  export type OpenAIServiceTier = OpenResponsesOptions.ServiceTier;
8
- export declare const OpenAIReasoningEffort: import("effect/Schema").String;
9
- export declare const OpenAITextVerbosity: import("effect/Schema").Literals<readonly ["low", "medium", "high"]>;
10
+ export declare const OpenAIReasoningEffort: import("effect/Schema").declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>;
11
+ export declare const OpenAITextVerbosity: import("effect/Schema").declare<OpenResponsesOptions.TextVerbosity, OpenResponsesOptions.TextVerbosity>;
10
12
  export declare const OpenAIResponseIncludable: import("effect/Schema").declare<OpenResponsesOptions.ResponseIncludable, OpenResponsesOptions.ResponseIncludable>;
11
13
  export declare const OpenAIServiceTier: import("effect/Schema").Literals<readonly ["auto", "default", "flex", "priority"]>;
12
14
  export declare const isReasoningEffort: (effort: unknown) => effort is OpenAIReasoningEffort;
13
- export declare const resolve: (request: import("../../schema/messages.js").LLMRequest) => OpenResponsesOptions.Resolved;
15
+ export declare const resolve: (request: import("../../index.js").LLMRequest) => OpenResponsesOptions.Resolved;
14
16
  export * as OpenAIOptions from "./openai-options.js";
@@ -1,12 +1,12 @@
1
- import { ReasoningEfforts } from "../../schema/index.js";
2
1
  import { OpenResponsesOptions } from "./open-responses-options.js";
3
- export const OpenAIReasoningEfforts = ReasoningEfforts;
2
+ export const OpenAIReasoningEfforts = OpenResponsesOptions.ReasoningEfforts;
3
+ export const OpenAITextVerbosities = OpenResponsesOptions.TextVerbosities;
4
4
  // Mirrors OpenAI's `ResponseIncludable` union from the official SDK. Keep this
5
5
  // in lockstep with `openai-node/src/resources/responses/responses.ts`.
6
6
  export const OpenAIResponseIncludables = OpenResponsesOptions.ResponseIncludables;
7
7
  export const OpenAIServiceTiers = OpenResponsesOptions.ServiceTiers;
8
8
  export const OpenAIReasoningEffort = OpenResponsesOptions.ReasoningEffort;
9
- export const OpenAITextVerbosity = OpenResponsesOptions.TextVerbositySchema;
9
+ export const OpenAITextVerbosity = OpenResponsesOptions.TextVerbosity;
10
10
  export const OpenAIResponseIncludable = OpenResponsesOptions.ResponseIncludableSchema;
11
11
  export const OpenAIServiceTier = OpenResponsesOptions.ServiceTierSchema;
12
12
  export const isReasoningEffort = (effort) => typeof effort === "string";
@@ -81,7 +81,6 @@ export declare const routes: (RouteDef<{
81
81
  } | undefined;
82
82
  })[];
83
83
  readonly stream: true;
84
- readonly stop?: readonly string[] | undefined;
85
84
  readonly max_completion_tokens?: number | undefined;
86
85
  readonly max_tokens?: number | undefined;
87
86
  readonly tools?: readonly {
@@ -98,9 +97,10 @@ export declare const routes: (RouteDef<{
98
97
  readonly ttl?: string | undefined;
99
98
  } | undefined;
100
99
  }[] | undefined;
100
+ readonly stop?: readonly string[] | undefined;
101
101
  readonly temperature?: number | undefined;
102
102
  readonly seed?: number | undefined;
103
- readonly tool_choice?: "required" | "none" | "auto" | {
103
+ readonly tool_choice?: "required" | "auto" | "none" | {
104
104
  readonly type: "function";
105
105
  readonly function: {
106
106
  readonly name: string;
@@ -112,7 +112,7 @@ export declare const routes: (RouteDef<{
112
112
  readonly include_usage: boolean;
113
113
  } | undefined;
114
114
  readonly prompt_cache_key?: string | undefined;
115
- readonly reasoning_effort?: string | undefined;
115
+ readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
116
116
  readonly frequency_penalty?: number | undefined;
117
117
  readonly presence_penalty?: number | undefined;
118
118
  }, import("../route/transport/http.js").HttpPrepared<string>> | RouteDef<{
@@ -187,7 +187,7 @@ export declare const routes: (RouteDef<{
187
187
  readonly instructions?: string | undefined;
188
188
  readonly reasoning?: {
189
189
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
190
- readonly effort?: string | undefined;
190
+ readonly effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
191
191
  } | undefined;
192
192
  readonly tools?: readonly ({
193
193
  readonly type: "function";
@@ -202,22 +202,22 @@ export declare const routes: (RouteDef<{
202
202
  readonly size?: string | undefined;
203
203
  readonly action?: "generate" | "auto" | "edit" | undefined;
204
204
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
205
- readonly quality?: "low" | "medium" | "high" | "auto" | undefined;
205
+ readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
206
206
  readonly background?: "auto" | "opaque" | "transparent" | undefined;
207
207
  readonly output_compression?: number | undefined;
208
208
  readonly input_fidelity?: "low" | "high" | undefined;
209
209
  readonly partial_images?: number | undefined;
210
210
  })[] | undefined;
211
211
  readonly text?: {
212
- readonly verbosity?: "low" | "medium" | "high" | undefined;
212
+ readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
213
213
  } | undefined;
214
214
  readonly temperature?: number | undefined;
215
- readonly tool_choice?: "required" | "none" | "auto" | {
215
+ readonly tool_choice?: "required" | "auto" | "none" | {
216
216
  readonly type: "function";
217
217
  readonly name: string;
218
218
  } | {
219
219
  readonly type: "allowed_tools";
220
- readonly mode: "required" | "none" | "auto";
220
+ readonly mode: "required" | "auto" | "none";
221
221
  readonly tools: readonly {
222
222
  readonly type: "function";
223
223
  readonly name: string;
@@ -237,24 +237,24 @@ export declare const routes: (RouteDef<{
237
237
  }, import("../protocols/open-responses-channel.js").Prepared>)[];
238
238
  export declare const configure: (input?: Config) => {
239
239
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
240
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
241
- chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
242
- responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
240
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
241
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
242
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
243
243
  configure: (input?: Config) => /*elided*/ any;
244
244
  };
245
245
  export declare const provider: {
246
246
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
247
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
248
- chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
249
- responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
247
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
248
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
249
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
250
250
  configure: (input?: Config) => {
251
251
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
252
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
253
- chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
254
- responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
252
+ model: (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>;
254
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
255
255
  configure: /*elided*/ any;
256
256
  };
257
257
  };
258
258
  export declare const chatModel: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
259
259
  export declare const responsesModel: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
260
- export declare const model: (modelID: string, settings: Settings) => import("../schema/options.js").LanguageModel<OpenAIProviderOptionsInput>;
260
+ export declare const model: (modelID: string, settings: Settings) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;