@opencode/ai 0.0.0-dev-21920 → 0.0.0-dev-44

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 (166) hide show
  1. package/README.md +61 -19
  2. package/dist/ai-client.d.ts +2 -2
  3. package/dist/cache-policy.d.ts +4 -0
  4. package/dist/cache-policy.js +20 -6
  5. package/dist/decision-client.d.ts +3 -3
  6. package/dist/decision.d.ts +4 -1
  7. package/dist/decision.js +3 -0
  8. package/dist/effect.d.ts +4 -5
  9. package/dist/effect.js +2 -3
  10. package/dist/experimental/realtime.d.ts +3 -2
  11. package/dist/image-client.d.ts +1 -1
  12. package/dist/image.js +1 -0
  13. package/dist/index.d.ts +6 -0
  14. package/dist/llm.d.ts +3 -0
  15. package/dist/media-client.d.ts +2 -1
  16. package/dist/media-model.d.ts +3 -0
  17. package/dist/media-model.js +4 -1
  18. package/dist/protocols/alibaba-chat.d.ts +4 -0
  19. package/dist/protocols/alibaba-messages.d.ts +19 -19
  20. package/dist/protocols/alibaba-responses.d.ts +3 -3
  21. package/dist/protocols/anthropic-messages.d.ts +59 -59
  22. package/dist/protocols/anthropic-messages.js +3 -5
  23. package/dist/protocols/bedrock-converse.d.ts +110 -15
  24. package/dist/protocols/bedrock-converse.js +112 -15
  25. package/dist/protocols/bedrock-event-stream.js +1 -0
  26. package/dist/protocols/meta-messages.d.ts +19 -19
  27. package/dist/protocols/meta-messages.js +2 -1
  28. package/dist/protocols/open-responses.d.ts +3 -0
  29. package/dist/protocols/openai-chat.d.ts +588 -1
  30. package/dist/protocols/openai-chat.js +7 -2
  31. package/dist/protocols/openai-compatible-chat.d.ts +6 -2
  32. package/dist/protocols/openai-compatible-responses.d.ts +3 -3
  33. package/dist/protocols/openai-responses.d.ts +24 -0
  34. package/dist/protocols/openai-responses.js +5 -0
  35. package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
  36. package/dist/protocols/utils/bedrock-cache.js +7 -6
  37. package/dist/protocols/utils/cache.d.ts +14 -3
  38. package/dist/protocols/utils/cache.js +11 -4
  39. package/dist/protocols/utils/gemini-json-schema.d.ts +5 -0
  40. package/dist/protocols/utils/gemini-json-schema.js +3 -3
  41. package/dist/protocols/utils/tool-schema.js +15 -5
  42. package/dist/protocols/utils/tool-stream.d.ts +9 -0
  43. package/dist/protocols/venice-chat.d.ts +3 -0
  44. package/dist/protocols/venice-chat.js +1 -1
  45. package/dist/protocols/zai-chat.d.ts +4 -0
  46. package/dist/protocols/zai-messages.d.ts +19 -19
  47. package/dist/providers/alibaba/images.d.ts +2 -0
  48. package/dist/providers/alibaba/images.js +1 -0
  49. package/dist/providers/alibaba.d.ts +26 -21
  50. package/dist/providers/alibaba.js +12 -8
  51. package/dist/providers/amazon-bedrock-mantle.d.ts +23 -19
  52. package/dist/providers/amazon-bedrock.d.ts +34 -14
  53. package/dist/providers/amazon-bedrock.js +11 -11
  54. package/dist/providers/anthropic-compatible.d.ts +19 -19
  55. package/dist/providers/anthropic.d.ts +19 -19
  56. package/dist/providers/azure/images.d.ts +2 -0
  57. package/dist/providers/azure/images.js +1 -0
  58. package/dist/providers/azure.d.ts +15 -1
  59. package/dist/providers/azure.js +19 -1
  60. package/dist/providers/baseten/decisions.d.ts +2 -0
  61. package/dist/providers/baseten/decisions.js +1 -0
  62. package/dist/providers/baseten.d.ts +13 -4
  63. package/dist/providers/baseten.js +15 -8
  64. package/dist/providers/cerebras.d.ts +8 -0
  65. package/dist/providers/cloudflare-ai-gateway/decisions.d.ts +2 -0
  66. package/dist/providers/cloudflare-ai-gateway/decisions.js +1 -0
  67. package/dist/providers/cloudflare-ai-gateway.d.ts +57 -40
  68. package/dist/providers/cloudflare-ai-gateway.js +11 -6
  69. package/dist/providers/cloudflare-workers-ai/decisions.d.ts +2 -0
  70. package/dist/providers/cloudflare-workers-ai/decisions.js +1 -0
  71. package/dist/providers/cloudflare-workers-ai/images.d.ts +2 -0
  72. package/dist/providers/cloudflare-workers-ai/images.js +1 -0
  73. package/dist/providers/cloudflare-workers-ai.d.ts +13 -3
  74. package/dist/providers/cloudflare-workers-ai.js +16 -7
  75. package/dist/providers/cohere.d.ts +8 -0
  76. package/dist/providers/deepinfra.d.ts +8 -0
  77. package/dist/providers/deepseek.d.ts +8 -0
  78. package/dist/providers/digitalocean/decisions.d.ts +2 -0
  79. package/dist/providers/digitalocean/decisions.js +1 -0
  80. package/dist/providers/digitalocean/images.d.ts +2 -0
  81. package/dist/providers/digitalocean/images.js +1 -0
  82. package/dist/providers/digitalocean.d.ts +21 -4
  83. package/dist/providers/digitalocean.js +25 -8
  84. package/dist/providers/fireworks.d.ts +8 -0
  85. package/dist/providers/google/images.d.ts +2 -0
  86. package/dist/providers/google/images.js +1 -0
  87. package/dist/providers/google-vertex/images.d.ts +2 -0
  88. package/dist/providers/google-vertex/images.js +1 -0
  89. package/dist/providers/google-vertex-chat.d.ts +4 -0
  90. package/dist/providers/google-vertex-messages.d.ts +19 -19
  91. package/dist/providers/google-vertex.d.ts +3 -1
  92. package/dist/providers/google-vertex.js +30 -13
  93. package/dist/providers/google.d.ts +5 -4
  94. package/dist/providers/google.js +15 -8
  95. package/dist/providers/groq.d.ts +8 -0
  96. package/dist/providers/meta.d.ts +23 -19
  97. package/dist/providers/minimax.d.ts +23 -19
  98. package/dist/providers/moonshot.d.ts +23 -19
  99. package/dist/providers/openai/images.d.ts +2 -0
  100. package/dist/providers/openai/images.js +1 -0
  101. package/dist/providers/openai-compatible/images.d.ts +2 -0
  102. package/dist/providers/openai-compatible/images.js +1 -0
  103. package/dist/providers/openai-compatible.d.ts +7 -1
  104. package/dist/providers/openai-compatible.js +21 -9
  105. package/dist/providers/openai.d.ts +18 -8
  106. package/dist/providers/openai.js +10 -2
  107. package/dist/providers/opencode/decisions.d.ts +2 -0
  108. package/dist/providers/opencode/decisions.js +1 -0
  109. package/dist/providers/opencode.d.ts +9 -4
  110. package/dist/providers/opencode.js +2 -1
  111. package/dist/providers/openrouter/decisions.d.ts +2 -0
  112. package/dist/providers/openrouter/decisions.js +1 -0
  113. package/dist/providers/openrouter/images.d.ts +2 -0
  114. package/dist/providers/openrouter/images.js +1 -0
  115. package/dist/providers/openrouter.d.ts +25 -4
  116. package/dist/providers/openrouter.js +31 -9
  117. package/dist/providers/togetherai.d.ts +8 -0
  118. package/dist/providers/typesafe-ai/decisions.d.ts +2 -0
  119. package/dist/providers/typesafe-ai/decisions.js +1 -0
  120. package/dist/providers/typesafe-ai.d.ts +9 -4
  121. package/dist/providers/typesafe-ai.js +2 -1
  122. package/dist/providers/venice.d.ts +3 -0
  123. package/dist/providers/vercel-ai-gateway/decisions.d.ts +2 -0
  124. package/dist/providers/vercel-ai-gateway/decisions.js +1 -0
  125. package/dist/providers/vercel-ai-gateway/images.d.ts +2 -0
  126. package/dist/providers/vercel-ai-gateway/images.js +1 -0
  127. package/dist/providers/vercel-ai-gateway.d.ts +9 -7
  128. package/dist/providers/vercel-ai-gateway.js +18 -10
  129. package/dist/providers/xai/images.d.ts +2 -0
  130. package/dist/providers/xai/images.js +1 -0
  131. package/dist/providers/xai.d.ts +9 -4
  132. package/dist/providers/xai.js +15 -8
  133. package/dist/providers/zai/images.d.ts +2 -0
  134. package/dist/providers/zai/images.js +1 -0
  135. package/dist/providers/zai-coding-plan.d.ts +23 -19
  136. package/dist/providers/zai.d.ts +9 -4
  137. package/dist/providers/zai.js +15 -8
  138. package/dist/route/client.d.ts +2 -2
  139. package/dist/route/client.js +15 -4
  140. package/dist/route/decision.d.ts +2 -1
  141. package/dist/route/decision.js +1 -0
  142. package/dist/route/executor.d.ts +1 -1
  143. package/dist/route/framing.d.ts +2 -0
  144. package/dist/route/index.d.ts +3 -0
  145. package/dist/route/index.js +3 -0
  146. package/dist/route/media.d.ts +5 -1
  147. package/dist/route/media.js +6 -2
  148. package/dist/route/transport/http.js +1 -0
  149. package/dist/route/transport/index.d.ts +1 -0
  150. package/dist/schema/events.d.ts +135 -6
  151. package/dist/schema/events.js +10 -0
  152. package/dist/schema/messages.d.ts +6 -2
  153. package/dist/schema/messages.js +3 -0
  154. package/dist/schema/options.d.ts +5 -3
  155. package/dist/schema/options.js +8 -3
  156. package/dist/speech-client.d.ts +1 -1
  157. package/dist/speech.js +2 -1
  158. package/dist/testing.d.ts +25 -24
  159. package/dist/testing.js +3 -21
  160. package/dist/transcription-client.d.ts +1 -1
  161. package/dist/transcription.js +1 -0
  162. package/dist/video-client.d.ts +1 -1
  163. package/dist/video.js +1 -0
  164. package/package.json +510 -8
  165. package/dist/provider.d.ts +0 -23
  166. package/dist/provider.js +0 -2
@@ -1,7 +1,7 @@
1
1
  import { Schema } from "effect";
2
2
  import { Route } from "../route/client.js";
3
3
  import { Protocol } from "../route/protocol.js";
4
- import { Usage, type FinishReasonDetails } from "../schema/index.js";
4
+ import { Usage, type FinishReasonDetails, type ProviderOptions } from "../schema/index.js";
5
5
  import { Lifecycle } from "./utils/lifecycle.js";
6
6
  import { ToolStream } from "./utils/tool-stream.js";
7
7
  export type { Credentials as BedrockCredentials } from "./utils/bedrock-auth.js";
@@ -54,7 +54,7 @@ declare const BedrockConverseBody: Schema.Struct<{
54
54
  }>, Schema.Struct<{
55
55
  readonly cachePoint: Schema.Struct<{
56
56
  readonly type: Schema.tag<"default">;
57
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
57
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
58
58
  }>;
59
59
  }>]>>;
60
60
  }>, Schema.Struct<{
@@ -79,7 +79,7 @@ declare const BedrockConverseBody: Schema.Struct<{
79
79
  }>, Schema.Struct<{
80
80
  readonly cachePoint: Schema.Struct<{
81
81
  readonly type: Schema.tag<"default">;
82
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
82
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
83
83
  }>;
84
84
  }>]>>;
85
85
  }>]>>;
@@ -88,7 +88,7 @@ declare const BedrockConverseBody: Schema.Struct<{
88
88
  }>, Schema.Struct<{
89
89
  readonly cachePoint: Schema.Struct<{
90
90
  readonly type: Schema.tag<"default">;
91
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
91
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
92
92
  }>;
93
93
  }>]>>>;
94
94
  inferenceConfig: Schema.optional<Schema.Struct<{
@@ -109,7 +109,7 @@ declare const BedrockConverseBody: Schema.Struct<{
109
109
  }>, Schema.Struct<{
110
110
  readonly cachePoint: Schema.Struct<{
111
111
  readonly type: Schema.tag<"default">;
112
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
112
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
113
113
  }>;
114
114
  }>]>>;
115
115
  readonly toolChoice: Schema.optional<Schema.Union<readonly [Schema.Struct<{
@@ -123,15 +123,62 @@ declare const BedrockConverseBody: Schema.Struct<{
123
123
  }>]>>;
124
124
  }>>;
125
125
  additionalModelRequestFields: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
126
+ serviceTier: Schema.optional<Schema.Struct<{
127
+ readonly type: Schema.declare<import("../schema/options.js").OpenString<"default" | "flex" | "priority" | "reserved">, import("../schema/options.js").OpenString<"default" | "flex" | "priority" | "reserved">>;
128
+ }>>;
129
+ guardrailConfig: Schema.optional<Schema.Struct<{
130
+ readonly guardrailIdentifier: Schema.String;
131
+ readonly guardrailVersion: Schema.String;
132
+ readonly trace: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"disabled" | "enabled" | "enabled_full">, import("../schema/options.js").OpenString<"disabled" | "enabled" | "enabled_full">>>;
133
+ readonly streamProcessingMode: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"async" | "sync">, import("../schema/options.js").OpenString<"async" | "sync">>>;
134
+ }>>;
135
+ outputConfig: Schema.optional<Schema.Struct<{
136
+ readonly textFormat: Schema.Struct<{
137
+ readonly type: Schema.declare<import("../schema/options.js").OpenString<"json_schema">, import("../schema/options.js").OpenString<"json_schema">>;
138
+ readonly structure: Schema.Struct<{
139
+ readonly jsonSchema: Schema.Struct<{
140
+ readonly schema: Schema.String;
141
+ readonly name: Schema.optional<Schema.String>;
142
+ readonly description: Schema.optional<Schema.String>;
143
+ }>;
144
+ }>;
145
+ }>;
146
+ }>>;
147
+ requestMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
126
148
  }>;
127
149
  export type BedrockConverseBody = Schema.Schema.Type<typeof BedrockConverseBody>;
128
150
  declare const Options: Schema.Struct<{
129
- readonly thinking: Schema.optional<Schema.Struct<{
151
+ /** Claude thinking. `adaptive` and `disabled` apply to Claude models only. */
152
+ readonly thinking: Schema.optional<Schema.Union<readonly [Schema.Struct<{
130
153
  readonly type: Schema.Literal<"enabled">;
131
154
  readonly budgetTokens: Schema.Number;
155
+ }>, Schema.Struct<{
156
+ readonly type: Schema.Literal<"adaptive">;
157
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"omitted" | "summarized">, import("../schema/options.js").OpenString<"omitted" | "summarized">>>;
158
+ }>, Schema.Struct<{
159
+ readonly type: Schema.Literal<"disabled">;
160
+ }>]>>;
161
+ /** Reasoning effort, sent in the field each model family reads. */
162
+ readonly effort: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"high" | "low" | "max" | "medium" | "xhigh">, import("../schema/options.js").OpenString<"high" | "low" | "max" | "medium" | "xhigh">>>;
163
+ readonly serviceTier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"default" | "flex" | "priority" | "reserved">, import("../schema/options.js").OpenString<"default" | "flex" | "priority" | "reserved">>>;
164
+ /** Constrains the response text to a JSON schema. */
165
+ readonly outputFormat: Schema.optional<Schema.Struct<{
166
+ readonly type: Schema.declare<import("../schema/options.js").OpenString<"json_schema">, import("../schema/options.js").OpenString<"json_schema">>;
167
+ readonly schema: Schema.$Record<Schema.String, Schema.Unknown>;
168
+ readonly name: Schema.optional<Schema.String>;
169
+ readonly description: Schema.optional<Schema.String>;
132
170
  }>>;
171
+ readonly guardrail: Schema.optional<Schema.Struct<{
172
+ readonly identifier: Schema.String;
173
+ readonly version: Schema.String;
174
+ readonly trace: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"disabled" | "enabled" | "enabled_full">, import("../schema/options.js").OpenString<"disabled" | "enabled" | "enabled_full">>>;
175
+ readonly streamProcessingMode: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"async" | "sync">, import("../schema/options.js").OpenString<"async" | "sync">>>;
176
+ }>>;
177
+ /** Key-value pairs for filtering invocation logs. */
178
+ readonly requestMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
133
179
  }>;
134
- export type OptionsInput = typeof Options.Type;
180
+ /** Caller-facing provider options; unknown keys are accepted and ignored. */
181
+ export type OptionsInput = ProviderOptions & typeof Options.Encoded;
135
182
  /**
136
183
  * The Bedrock Converse protocol — request body construction, body schema, and
137
184
  * the streaming-event state machine.
@@ -143,7 +190,7 @@ export declare const protocol: Protocol<{
143
190
  readonly content: readonly ({
144
191
  readonly cachePoint: {
145
192
  readonly type: "default";
146
- readonly ttl?: "1h" | "5m" | undefined;
193
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
147
194
  };
148
195
  } | {
149
196
  readonly image: {
@@ -193,7 +240,7 @@ export declare const protocol: Protocol<{
193
240
  readonly content: readonly ({
194
241
  readonly cachePoint: {
195
242
  readonly type: "default";
196
- readonly ttl?: "1h" | "5m" | undefined;
243
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
197
244
  };
198
245
  } | {
199
246
  readonly text: string;
@@ -217,7 +264,7 @@ export declare const protocol: Protocol<{
217
264
  readonly system?: readonly ({
218
265
  readonly cachePoint: {
219
266
  readonly type: "default";
220
- readonly ttl?: "1h" | "5m" | undefined;
267
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
221
268
  };
222
269
  } | {
223
270
  readonly text: string;
@@ -232,7 +279,7 @@ export declare const protocol: Protocol<{
232
279
  readonly tools: readonly ({
233
280
  readonly cachePoint: {
234
281
  readonly type: "default";
235
- readonly ttl?: "1h" | "5m" | undefined;
282
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
236
283
  };
237
284
  } | {
238
285
  readonly toolSpec: {
@@ -258,6 +305,30 @@ export declare const protocol: Protocol<{
258
305
  readonly additionalModelRequestFields?: {
259
306
  readonly [x: string]: unknown;
260
307
  } | undefined;
308
+ readonly serviceTier?: {
309
+ readonly type: import("../schema/options.js").OpenString<"default" | "flex" | "priority" | "reserved">;
310
+ } | undefined;
311
+ readonly guardrailConfig?: {
312
+ readonly guardrailIdentifier: string;
313
+ readonly guardrailVersion: string;
314
+ readonly trace?: import("../schema/options.js").OpenString<"disabled" | "enabled" | "enabled_full"> | undefined;
315
+ readonly streamProcessingMode?: import("../schema/options.js").OpenString<"async" | "sync"> | undefined;
316
+ } | undefined;
317
+ readonly outputConfig?: {
318
+ readonly textFormat: {
319
+ readonly type: import("../schema/options.js").OpenString<"json_schema">;
320
+ readonly structure: {
321
+ readonly jsonSchema: {
322
+ readonly schema: string;
323
+ readonly name?: string | undefined;
324
+ readonly description?: string | undefined;
325
+ };
326
+ };
327
+ };
328
+ } | undefined;
329
+ readonly requestMetadata?: {
330
+ readonly [x: string]: string;
331
+ } | undefined;
261
332
  }, {
262
333
  readonly [x: string]: unknown;
263
334
  readonly rawBody: string;
@@ -331,7 +402,7 @@ export declare const route: Route<{
331
402
  readonly content: readonly ({
332
403
  readonly cachePoint: {
333
404
  readonly type: "default";
334
- readonly ttl?: "1h" | "5m" | undefined;
405
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
335
406
  };
336
407
  } | {
337
408
  readonly image: {
@@ -381,7 +452,7 @@ export declare const route: Route<{
381
452
  readonly content: readonly ({
382
453
  readonly cachePoint: {
383
454
  readonly type: "default";
384
- readonly ttl?: "1h" | "5m" | undefined;
455
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
385
456
  };
386
457
  } | {
387
458
  readonly text: string;
@@ -405,7 +476,7 @@ export declare const route: Route<{
405
476
  readonly system?: readonly ({
406
477
  readonly cachePoint: {
407
478
  readonly type: "default";
408
- readonly ttl?: "1h" | "5m" | undefined;
479
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
409
480
  };
410
481
  } | {
411
482
  readonly text: string;
@@ -420,7 +491,7 @@ export declare const route: Route<{
420
491
  readonly tools: readonly ({
421
492
  readonly cachePoint: {
422
493
  readonly type: "default";
423
- readonly ttl?: "1h" | "5m" | undefined;
494
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
424
495
  };
425
496
  } | {
426
497
  readonly toolSpec: {
@@ -446,6 +517,30 @@ export declare const route: Route<{
446
517
  readonly additionalModelRequestFields?: {
447
518
  readonly [x: string]: unknown;
448
519
  } | undefined;
520
+ readonly serviceTier?: {
521
+ readonly type: import("../schema/options.js").OpenString<"default" | "flex" | "priority" | "reserved">;
522
+ } | undefined;
523
+ readonly guardrailConfig?: {
524
+ readonly guardrailIdentifier: string;
525
+ readonly guardrailVersion: string;
526
+ readonly trace?: import("../schema/options.js").OpenString<"disabled" | "enabled" | "enabled_full"> | undefined;
527
+ readonly streamProcessingMode?: import("../schema/options.js").OpenString<"async" | "sync"> | undefined;
528
+ } | undefined;
529
+ readonly outputConfig?: {
530
+ readonly textFormat: {
531
+ readonly type: import("../schema/options.js").OpenString<"json_schema">;
532
+ readonly structure: {
533
+ readonly jsonSchema: {
534
+ readonly schema: string;
535
+ readonly name?: string | undefined;
536
+ readonly description?: string | undefined;
537
+ };
538
+ };
539
+ };
540
+ } | undefined;
541
+ readonly requestMetadata?: {
542
+ readonly [x: string]: string;
543
+ } | undefined;
449
544
  }, import("../route/transport/http.js").HttpPrepared<{
450
545
  readonly [x: string]: unknown;
451
546
  readonly rawBody: string;
@@ -10,7 +10,7 @@ import { JsonObject, optionalArray, ProviderShared } from "./shared.js";
10
10
  import { BedrockAuth } from "./utils/bedrock-auth.js";
11
11
  import { BedrockCache } from "./utils/bedrock-cache.js";
12
12
  import { BedrockMedia } from "./utils/bedrock-media.js";
13
- import { supportsThinkingBlockBinding, THINKING_BINDING_BETA } from "./utils/claude-model.js";
13
+ import { claudeVersion, supportsThinkingBlockBinding, THINKING_BINDING_BETA } from "./utils/claude-model.js";
14
14
  import { Lifecycle } from "./utils/lifecycle.js";
15
15
  import { MistralToolID } from "./utils/mistral-tool-id.js";
16
16
  import { ToolStream } from "./utils/tool-stream.js";
@@ -86,6 +86,11 @@ const BedrockToolChoice = Schema.Union([
86
86
  Schema.Struct({ any: Schema.Struct({}) }),
87
87
  Schema.Struct({ tool: Schema.Struct({ name: Schema.String }) }),
88
88
  ]);
89
+ // Value sets from the Converse API reference. Unknown values pass through for forward compatibility.
90
+ const ServiceTierType = ProviderShared.knownString();
91
+ const GuardrailTrace = ProviderShared.knownString();
92
+ const GuardrailStreamProcessingMode = ProviderShared.knownString();
93
+ const TextFormatType = ProviderShared.knownString();
89
94
  const BedrockBodyFields = {
90
95
  modelId: Schema.String,
91
96
  messages: Schema.Array(BedrockMessage),
@@ -101,6 +106,26 @@ const BedrockBodyFields = {
101
106
  toolChoice: Schema.optional(BedrockToolChoice),
102
107
  })),
103
108
  additionalModelRequestFields: Schema.optional(JsonObject),
109
+ serviceTier: Schema.optional(Schema.Struct({ type: ServiceTierType })),
110
+ guardrailConfig: Schema.optional(Schema.Struct({
111
+ guardrailIdentifier: Schema.String,
112
+ guardrailVersion: Schema.String,
113
+ trace: Schema.optional(GuardrailTrace),
114
+ streamProcessingMode: Schema.optional(GuardrailStreamProcessingMode),
115
+ })),
116
+ outputConfig: Schema.optional(Schema.Struct({
117
+ textFormat: Schema.Struct({
118
+ type: TextFormatType,
119
+ structure: Schema.Struct({
120
+ jsonSchema: Schema.Struct({
121
+ schema: Schema.String,
122
+ name: Schema.optional(Schema.String),
123
+ description: Schema.optional(Schema.String),
124
+ }),
125
+ }),
126
+ }),
127
+ })),
128
+ requestMetadata: Schema.optional(Schema.Record(Schema.String, Schema.String)),
104
129
  };
105
130
  const BedrockConverseBody = Schema.Struct(BedrockBodyFields);
106
131
  const BedrockUsageSchema = Schema.Struct({
@@ -376,8 +401,49 @@ const isHighReasoningEffort = Schema.is(Schema.Struct({
376
401
  reasoningConfig: Schema.Struct({ maxReasoningEffort: Schema.Literal("high") }),
377
402
  }),
378
403
  }));
404
+ // Claude 4.6+ pairs effort with adaptive thinking; earlier Claude models take effort beside a manual budget.
405
+ const supportsAdaptiveThinking = (model) => {
406
+ const version = claudeVersion(model.id);
407
+ return version !== undefined && (version.major > 4 || (version.major === 4 && version.minor >= 6));
408
+ };
409
+ const effortFields = (model, effort) => {
410
+ if (model.id.includes("anthropic"))
411
+ return { output_config: { effort } };
412
+ // gpt-oss takes the flat chat-completions spelling; newer OpenAI and xAI models take the Responses one.
413
+ if (model.id.includes("openai.gpt-oss"))
414
+ return { reasoning_effort: effort };
415
+ if (model.id.includes("openai.") || model.id.includes("xai."))
416
+ return { reasoning: { effort } };
417
+ return { reasoningConfig: { type: "enabled", maxReasoningEffort: effort } };
418
+ };
379
419
  const Options = Schema.Struct({
380
- thinking: Schema.optional(Schema.Struct({ type: Schema.Literal("enabled"), budgetTokens: Schema.Number })),
420
+ /** Claude thinking. `adaptive` and `disabled` apply to Claude models only. */
421
+ thinking: Schema.optional(Schema.Union([
422
+ Schema.Struct({ type: Schema.Literal("enabled"), budgetTokens: Schema.Number }),
423
+ Schema.Struct({
424
+ type: Schema.Literal("adaptive"),
425
+ display: Schema.optional(ProviderShared.knownString()),
426
+ }),
427
+ Schema.Struct({ type: Schema.Literal("disabled") }),
428
+ ])),
429
+ /** Reasoning effort, sent in the field each model family reads. */
430
+ effort: Schema.optional(ProviderShared.knownString()),
431
+ serviceTier: Schema.optional(ServiceTierType),
432
+ /** Constrains the response text to a JSON schema. */
433
+ outputFormat: Schema.optional(Schema.Struct({
434
+ type: TextFormatType,
435
+ schema: JsonObject,
436
+ name: Schema.optional(Schema.String),
437
+ description: Schema.optional(Schema.String),
438
+ })),
439
+ guardrail: Schema.optional(Schema.Struct({
440
+ identifier: Schema.String,
441
+ version: Schema.String,
442
+ trace: Schema.optional(GuardrailTrace),
443
+ streamProcessingMode: Schema.optional(GuardrailStreamProcessingMode),
444
+ })),
445
+ /** Key-value pairs for filtering invocation logs. */
446
+ requestMetadata: Schema.optional(Schema.Record(Schema.String, Schema.String)),
381
447
  });
382
448
  const decodeOptions = ProviderShared.validateWith(Schema.decodeUnknownEffect(Options));
383
449
  // Claude on Bedrock requires the thinking budget below `maxTokens`, with a minimum of 1,024.
@@ -390,7 +456,7 @@ const isThinkingDisabled = Schema.is(Schema.Struct({
390
456
  // Claude 5.1+ binds each thinking signature to the prefix above it. Ask Bedrock to drop the affected blocks instead of
391
457
  // failing when that prefix changes. `http.body` overlays this field by field, so callers can still override it.
392
458
  const applyThinkingBindingDefault = (request, thinking) => {
393
- if (isThinkingDisabled(request.http?.body))
459
+ if (thinking?.type === "disabled" || isThinkingDisabled(request.http?.body))
394
460
  return thinking;
395
461
  if (!supportsThinkingBlockBinding(request.model))
396
462
  return thinking;
@@ -404,13 +470,27 @@ const fromRequest = Effect.fn("BedrockConverse.fromRequest")(function* (request)
404
470
  const flattened = ProviderShared.flattenToolRequest(request);
405
471
  const generation = request.generation;
406
472
  const options = yield* decodeOptions(request.providerOptions ?? {});
407
- const maxTokens = isNova2(request.model) && isHighReasoningEffort(request.http?.body) ? undefined : generation?.maxTokens;
408
- const thinking = applyThinkingBindingDefault(request, options.thinking === undefined
473
+ const maxTokens = isNova2(request.model) && (options.effort === "high" || isHighReasoningEffort(request.http?.body))
409
474
  ? undefined
410
- : {
411
- type: "enabled",
412
- budget_tokens: ProviderShared.fitThinkingBudget(options.thinking.budgetTokens, maxTokens, MIN_THINKING_BUDGET),
413
- });
475
+ : generation?.maxTokens;
476
+ const thinking = applyThinkingBindingDefault(request, (() => {
477
+ if (options.thinking?.type === "enabled")
478
+ return {
479
+ type: "enabled",
480
+ budget_tokens: ProviderShared.fitThinkingBudget(options.thinking.budgetTokens, maxTokens, MIN_THINKING_BUDGET),
481
+ };
482
+ if (options.thinking !== undefined)
483
+ return options.thinking;
484
+ if (options.effort !== undefined && supportsAdaptiveThinking(request.model))
485
+ return { type: "adaptive" };
486
+ })());
487
+ const additionalModelRequestFields = {
488
+ ...(generation?.topK === undefined ? {} : { top_k: generation.topK }),
489
+ ...(thinking === undefined ? {} : { thinking }),
490
+ ...(options.effort === undefined ? {} : effortFields(request.model, options.effort)),
491
+ // Converse takes Anthropic betas in the body, and Bedrock rejects `block_binding` without this one.
492
+ ...(thinking?.block_binding === undefined ? {} : { anthropic_beta: [THINKING_BINDING_BETA] }),
493
+ };
414
494
  // Bedrock-Claude shares Anthropic's 4-breakpoint cap. Spend the budget in
415
495
  // tools → system → messages order to favour the highest-impact prefixes.
416
496
  const breakpoints = BedrockCache.breakpoints(request.model);
@@ -448,16 +528,33 @@ const fromRequest = Effect.fn("BedrockConverse.fromRequest")(function* (request)
448
528
  system,
449
529
  inferenceConfig,
450
530
  toolConfig,
451
- // Converse's base inferenceConfig has no topK or thinking; Anthropic/Nova accept them
531
+ // Converse's base inferenceConfig has no topK, thinking or effort; models accept them
452
532
  // as model-specific fields, so they go through additionalModelRequestFields.
453
- additionalModelRequestFields: generation?.topK === undefined && thinking === undefined
533
+ additionalModelRequestFields: Object.keys(additionalModelRequestFields).length === 0 ? undefined : additionalModelRequestFields,
534
+ serviceTier: options.serviceTier === undefined ? undefined : { type: options.serviceTier },
535
+ guardrailConfig: options.guardrail === undefined
454
536
  ? undefined
455
537
  : {
456
- ...(generation?.topK === undefined ? {} : { top_k: generation.topK }),
457
- ...(thinking === undefined ? {} : { thinking }),
458
- // Converse takes Anthropic betas in the body, and Bedrock rejects `block_binding` without this one.
459
- ...(thinking?.block_binding === undefined ? {} : { anthropic_beta: [THINKING_BINDING_BETA] }),
538
+ guardrailIdentifier: options.guardrail.identifier,
539
+ guardrailVersion: options.guardrail.version,
540
+ trace: options.guardrail.trace,
541
+ streamProcessingMode: options.guardrail.streamProcessingMode,
542
+ },
543
+ outputConfig: options.outputFormat === undefined
544
+ ? undefined
545
+ : {
546
+ textFormat: {
547
+ type: options.outputFormat.type,
548
+ structure: {
549
+ jsonSchema: {
550
+ schema: ProviderShared.encodeJson(options.outputFormat.schema),
551
+ name: options.outputFormat.name,
552
+ description: options.outputFormat.description,
553
+ },
554
+ },
555
+ },
460
556
  },
557
+ requestMetadata: options.requestMetadata,
461
558
  };
462
559
  });
463
560
  // =============================================================================
@@ -94,6 +94,7 @@ const consumeFrames = (route) => (state, input) => Effect.gen(function* () {
94
94
  export const framing = (route) => ({
95
95
  id: "aws-event-stream",
96
96
  body: (frame) => frame.rawBody,
97
+ raw: ({ rawBody: _, ...event }) => event,
97
98
  frame: (bytes) => bytes.pipe(Stream.map((bytes) => ({ _tag: "Chunk", bytes })), Stream.concat(Stream.succeed(endOfStream)), Stream.mapAccumEffect(() => initialFrameBuffer, consumeFrames(route))),
98
99
  });
99
100
  export * as BedrockEventStream from "./bedrock-event-stream.js";
@@ -17,7 +17,7 @@ export declare const protocol: Protocol<{
17
17
  readonly text: string;
18
18
  readonly cache_control?: {
19
19
  readonly type: "ephemeral";
20
- readonly ttl?: "1h" | "5m" | undefined;
20
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
21
21
  } | undefined;
22
22
  }[] | undefined;
23
23
  readonly messages: readonly ({
@@ -27,7 +27,7 @@ export declare const protocol: Protocol<{
27
27
  readonly text: string;
28
28
  readonly cache_control?: {
29
29
  readonly type: "ephemeral";
30
- readonly ttl?: "1h" | "5m" | undefined;
30
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
31
31
  } | undefined;
32
32
  } | {
33
33
  readonly type: "image";
@@ -44,7 +44,7 @@ export declare const protocol: Protocol<{
44
44
  };
45
45
  readonly cache_control?: {
46
46
  readonly type: "ephemeral";
47
- readonly ttl?: "1h" | "5m" | undefined;
47
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
48
48
  } | undefined;
49
49
  readonly transformations?: {
50
50
  readonly oversized_image?: "downsize" | "error" | undefined;
@@ -64,7 +64,7 @@ export declare const protocol: Protocol<{
64
64
  };
65
65
  readonly cache_control?: {
66
66
  readonly type: "ephemeral";
67
- readonly ttl?: "1h" | "5m" | undefined;
67
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
68
68
  } | undefined;
69
69
  } | {
70
70
  readonly type: "document";
@@ -85,7 +85,7 @@ export declare const protocol: Protocol<{
85
85
  };
86
86
  readonly cache_control?: {
87
87
  readonly type: "ephemeral";
88
- readonly ttl?: "1h" | "5m" | undefined;
88
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
89
89
  } | undefined;
90
90
  readonly title?: string | undefined;
91
91
  readonly context?: string | undefined;
@@ -100,7 +100,7 @@ export declare const protocol: Protocol<{
100
100
  readonly text: string;
101
101
  readonly cache_control?: {
102
102
  readonly type: "ephemeral";
103
- readonly ttl?: "1h" | "5m" | undefined;
103
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
104
104
  } | undefined;
105
105
  } | {
106
106
  readonly type: "image";
@@ -117,7 +117,7 @@ export declare const protocol: Protocol<{
117
117
  };
118
118
  readonly cache_control?: {
119
119
  readonly type: "ephemeral";
120
- readonly ttl?: "1h" | "5m" | undefined;
120
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
121
121
  } | undefined;
122
122
  readonly transformations?: {
123
123
  readonly oversized_image?: "downsize" | "error" | undefined;
@@ -137,7 +137,7 @@ export declare const protocol: Protocol<{
137
137
  };
138
138
  readonly cache_control?: {
139
139
  readonly type: "ephemeral";
140
- readonly ttl?: "1h" | "5m" | undefined;
140
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
141
141
  } | undefined;
142
142
  } | {
143
143
  readonly type: "document";
@@ -158,7 +158,7 @@ export declare const protocol: Protocol<{
158
158
  };
159
159
  readonly cache_control?: {
160
160
  readonly type: "ephemeral";
161
- readonly ttl?: "1h" | "5m" | undefined;
161
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
162
162
  } | undefined;
163
163
  readonly title?: string | undefined;
164
164
  readonly context?: string | undefined;
@@ -169,7 +169,7 @@ export declare const protocol: Protocol<{
169
169
  readonly is_error?: boolean | undefined;
170
170
  readonly cache_control?: {
171
171
  readonly type: "ephemeral";
172
- readonly ttl?: "1h" | "5m" | undefined;
172
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
173
173
  } | undefined;
174
174
  })[];
175
175
  } | {
@@ -182,7 +182,7 @@ export declare const protocol: Protocol<{
182
182
  readonly text: string;
183
183
  readonly cache_control?: {
184
184
  readonly type: "ephemeral";
185
- readonly ttl?: "1h" | "5m" | undefined;
185
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
186
186
  } | undefined;
187
187
  } | {
188
188
  readonly type: "thinking";
@@ -190,14 +190,14 @@ export declare const protocol: Protocol<{
190
190
  readonly signature: string;
191
191
  readonly cache_control?: {
192
192
  readonly type: "ephemeral";
193
- readonly ttl?: "1h" | "5m" | undefined;
193
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
194
194
  } | undefined;
195
195
  } | {
196
196
  readonly type: "redacted_thinking";
197
197
  readonly data: string;
198
198
  readonly cache_control?: {
199
199
  readonly type: "ephemeral";
200
- readonly ttl?: "1h" | "5m" | undefined;
200
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
201
201
  } | undefined;
202
202
  } | {
203
203
  readonly type: "tool_use";
@@ -206,7 +206,7 @@ export declare const protocol: Protocol<{
206
206
  readonly input: unknown;
207
207
  readonly cache_control?: {
208
208
  readonly type: "ephemeral";
209
- readonly ttl?: "1h" | "5m" | undefined;
209
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
210
210
  } | undefined;
211
211
  } | {
212
212
  readonly type: "server_tool_use";
@@ -215,7 +215,7 @@ export declare const protocol: Protocol<{
215
215
  readonly input: unknown;
216
216
  readonly cache_control?: {
217
217
  readonly type: "ephemeral";
218
- readonly ttl?: "1h" | "5m" | undefined;
218
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
219
219
  } | undefined;
220
220
  } | {
221
221
  readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
@@ -223,7 +223,7 @@ export declare const protocol: Protocol<{
223
223
  readonly content: unknown;
224
224
  readonly cache_control?: {
225
225
  readonly type: "ephemeral";
226
- readonly ttl?: "1h" | "5m" | undefined;
226
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
227
227
  } | undefined;
228
228
  })[];
229
229
  } | {
@@ -233,7 +233,7 @@ export declare const protocol: Protocol<{
233
233
  readonly text: string;
234
234
  readonly cache_control?: {
235
235
  readonly type: "ephemeral";
236
- readonly ttl?: "1h" | "5m" | undefined;
236
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
237
237
  } | undefined;
238
238
  }[];
239
239
  readonly output_config?: {
@@ -281,7 +281,7 @@ export declare const protocol: Protocol<{
281
281
  } | undefined;
282
282
  readonly cache_control?: {
283
283
  readonly type: "ephemeral";
284
- readonly ttl?: "1h" | "5m" | undefined;
284
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
285
285
  } | undefined;
286
286
  readonly container?: string | {
287
287
  readonly id?: string | null | undefined;
@@ -313,7 +313,7 @@ export declare const protocol: Protocol<{
313
313
  };
314
314
  readonly cache_control?: {
315
315
  readonly type: "ephemeral";
316
- readonly ttl?: "1h" | "5m" | undefined;
316
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
317
317
  } | undefined;
318
318
  })[] | undefined;
319
319
  }, string, {
@@ -1,5 +1,6 @@
1
1
  import { Effect, Schema } from "effect";
2
2
  import { Protocol } from "../route/protocol.js";
3
+ import { CacheTTL } from "../schema/index.js";
3
4
  import { AnthropicMessages } from "./anthropic-messages.js";
4
5
  import { MetaResponses } from "./meta-responses.js";
5
6
  import { JsonObject, optionalArray, ProviderShared } from "./shared.js";
@@ -10,7 +11,7 @@ const WebSearch = Schema.Struct({
10
11
  });
11
12
  const MetaCacheControl = Schema.Struct({
12
13
  type: Schema.tag("ephemeral"),
13
- ttl: Schema.optional(Schema.Literals(["5m", "1h"])),
14
+ ttl: Schema.optional(CacheTTL),
14
15
  });
15
16
  const FunctionTool = Schema.Struct({
16
17
  name: Schema.String,
@@ -1462,6 +1462,9 @@ export declare const providerFailure: (event: Event, fallback: string, body?: st
1462
1462
  export declare const step: (state: ParserState, event: NormalizedEvent) => AIError | Effect.Effect<StepResult, never, never> | Effect.Effect<[ParserState, readonly ({
1463
1463
  readonly type: "step-start";
1464
1464
  readonly index: number;
1465
+ } | {
1466
+ readonly type: "raw";
1467
+ readonly data: unknown;
1465
1468
  } | {
1466
1469
  readonly type: "text-start";
1467
1470
  readonly id: string;