@opencode/ai 2.0.16 → 2.0.18

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 (185) hide show
  1. package/README.md +187 -129
  2. package/dist/ai-client.d.ts +8 -0
  3. package/dist/ai-client.js +12 -0
  4. package/dist/experimental/evaluation-client.d.ts +3 -3
  5. package/dist/experimental/evaluation-client.js +1 -1
  6. package/dist/experimental/evaluation.js +1 -1
  7. package/dist/generation.d.ts +6 -10
  8. package/dist/generation.js +17 -20
  9. package/dist/image-client.d.ts +59 -24
  10. package/dist/image-client.js +16 -40
  11. package/dist/image.d.ts +15 -27
  12. package/dist/image.js +4 -15
  13. package/dist/index.d.ts +2 -1
  14. package/dist/index.js +1 -0
  15. package/dist/llm.d.ts +7 -5
  16. package/dist/llm.js +10 -4
  17. package/dist/media-client.d.ts +30 -0
  18. package/dist/media-client.js +51 -0
  19. package/dist/media-model.d.ts +9 -10
  20. package/dist/media-model.js +10 -12
  21. package/dist/media.js +2 -2
  22. package/dist/promise.d.ts +68 -30
  23. package/dist/promise.js +52 -31
  24. package/dist/protocols/alibaba-chat.js +4 -1
  25. package/dist/protocols/alibaba-messages.d.ts +1 -1
  26. package/dist/protocols/alibaba-messages.js +6 -4
  27. package/dist/protocols/anthropic-messages.d.ts +34 -34
  28. package/dist/protocols/anthropic-messages.js +14 -8
  29. package/dist/protocols/assemblyai-transcription.d.ts +2 -1
  30. package/dist/protocols/assemblyai-transcription.js +14 -16
  31. package/dist/protocols/bedrock-converse.d.ts +7 -0
  32. package/dist/protocols/bedrock-converse.js +37 -11
  33. package/dist/protocols/bfl-images.d.ts +7 -1
  34. package/dist/protocols/bfl-images.js +36 -36
  35. package/dist/protocols/cartesia-speech.d.ts +18 -2
  36. package/dist/protocols/cartesia-speech.js +10 -16
  37. package/dist/protocols/deepgram-speech.d.ts +19 -3
  38. package/dist/protocols/deepgram-speech.js +11 -12
  39. package/dist/protocols/deepgram-transcription.d.ts +2 -1
  40. package/dist/protocols/deepgram-transcription.js +9 -13
  41. package/dist/protocols/elevenlabs-speech.d.ts +19 -3
  42. package/dist/protocols/elevenlabs-speech.js +9 -13
  43. package/dist/protocols/fal-images.d.ts +2 -1
  44. package/dist/protocols/fal-images.js +30 -40
  45. package/dist/protocols/fal-video.d.ts +2 -2
  46. package/dist/protocols/fal-video.js +9 -24
  47. package/dist/protocols/gemini.d.ts +13 -13
  48. package/dist/protocols/gemini.js +16 -7
  49. package/dist/protocols/google-images.d.ts +3 -3
  50. package/dist/protocols/google-images.js +11 -21
  51. package/dist/protocols/google-speech.d.ts +16 -0
  52. package/dist/protocols/google-speech.js +20 -16
  53. package/dist/protocols/google-transcription.d.ts +2 -1
  54. package/dist/protocols/google-transcription.js +8 -20
  55. package/dist/protocols/google-video.d.ts +2 -2
  56. package/dist/protocols/google-video.js +14 -30
  57. package/dist/protocols/meta-images.d.ts +3 -4
  58. package/dist/protocols/meta-images.js +12 -21
  59. package/dist/protocols/meta-messages.d.ts +5 -5
  60. package/dist/protocols/meta-responses.js +6 -4
  61. package/dist/protocols/open-responses.d.ts +4 -3
  62. package/dist/protocols/open-responses.js +4 -8
  63. package/dist/protocols/openai-chat.js +3 -4
  64. package/dist/protocols/openai-images.d.ts +7 -5
  65. package/dist/protocols/openai-images.js +65 -66
  66. package/dist/protocols/openai-responses.d.ts +10 -10
  67. package/dist/protocols/openai-responses.js +31 -30
  68. package/dist/protocols/openai-speech.d.ts +21 -1
  69. package/dist/protocols/openai-speech.js +11 -12
  70. package/dist/protocols/openai-transcription.d.ts +4 -0
  71. package/dist/protocols/openai-transcription.js +44 -32
  72. package/dist/protocols/replicate-images.js +11 -17
  73. package/dist/protocols/runway-video.d.ts +3 -3
  74. package/dist/protocols/runway-video.js +11 -17
  75. package/dist/protocols/shared.d.ts +11 -17
  76. package/dist/protocols/shared.js +11 -40
  77. package/dist/protocols/stability-images.d.ts +2 -1
  78. package/dist/protocols/stability-images.js +24 -36
  79. package/dist/protocols/utils/fal-queue.d.ts +1 -3
  80. package/dist/protocols/utils/fal-queue.js +4 -6
  81. package/dist/protocols/utils/media-input.d.ts +15 -1
  82. package/dist/protocols/utils/media-input.js +22 -0
  83. package/dist/protocols/utils/responses-checkpoint.js +3 -7
  84. package/dist/protocols/utils/responses-compaction.d.ts +3 -1
  85. package/dist/protocols/utils/responses-compaction.js +16 -3
  86. package/dist/protocols/utils/speech-stream.d.ts +3 -3
  87. package/dist/protocols/utils/speech-stream.js +1 -4
  88. package/dist/protocols/utils/tool-schema.d.ts +2 -2
  89. package/dist/protocols/utils/tool-schema.js +29 -9
  90. package/dist/protocols/xai-images.d.ts +4 -4
  91. package/dist/protocols/xai-images.js +14 -29
  92. package/dist/protocols/xai-responses.js +1 -1
  93. package/dist/protocols/xai-video.js +12 -18
  94. package/dist/protocols/zai-images.d.ts +2 -2
  95. package/dist/protocols/zai-images.js +11 -14
  96. package/dist/protocols/zai-messages.d.ts +1 -1
  97. package/dist/provider-error.js +7 -1
  98. package/dist/providers/alibaba.d.ts +1 -1
  99. package/dist/providers/amazon-bedrock.d.ts +2 -0
  100. package/dist/providers/amazon-bedrock.js +1 -0
  101. package/dist/providers/anthropic-compatible.d.ts +5 -5
  102. package/dist/providers/anthropic.d.ts +5 -5
  103. package/dist/providers/assemblyai.d.ts +1 -1
  104. package/dist/providers/assemblyai.js +5 -10
  105. package/dist/providers/azure.d.ts +4 -4
  106. package/dist/providers/azure.js +2 -2
  107. package/dist/providers/black-forest-labs.d.ts +1 -1
  108. package/dist/providers/black-forest-labs.js +5 -10
  109. package/dist/providers/cartesia.d.ts +1 -1
  110. package/dist/providers/cartesia.js +5 -10
  111. package/dist/providers/cloudflare-ai-gateway.d.ts +14 -14
  112. package/dist/providers/deepgram.d.ts +1 -1
  113. package/dist/providers/deepgram.js +6 -12
  114. package/dist/providers/elevenlabs.d.ts +1 -1
  115. package/dist/providers/elevenlabs.js +5 -10
  116. package/dist/providers/fal.d.ts +1 -1
  117. package/dist/providers/fal.js +5 -12
  118. package/dist/providers/google-vertex-messages.d.ts +5 -5
  119. package/dist/providers/google-vertex.d.ts +3 -3
  120. package/dist/providers/google.d.ts +3 -3
  121. package/dist/providers/google.js +7 -12
  122. package/dist/providers/meta.d.ts +8 -8
  123. package/dist/providers/meta.js +4 -8
  124. package/dist/providers/minimax.d.ts +5 -5
  125. package/dist/providers/moonshot.d.ts +5 -5
  126. package/dist/providers/openai-options.d.ts +3 -9
  127. package/dist/providers/openai-options.js +4 -7
  128. package/dist/providers/openai.d.ts +9 -10
  129. package/dist/providers/openai.js +11 -12
  130. package/dist/providers/opencode-zen.js +1 -1
  131. package/dist/providers/openrouter.d.ts +6 -7
  132. package/dist/providers/openrouter.js +10 -5
  133. package/dist/providers/replicate.d.ts +1 -1
  134. package/dist/providers/replicate.js +5 -10
  135. package/dist/providers/runway.d.ts +1 -1
  136. package/dist/providers/runway.js +5 -10
  137. package/dist/providers/stability.d.ts +1 -1
  138. package/dist/providers/stability.js +6 -11
  139. package/dist/providers/typesafe-ai.js +1 -1
  140. package/dist/providers/vercel-ai-gateway.js +1 -1
  141. package/dist/providers/xai.js +5 -10
  142. package/dist/providers/zai-coding-plan.d.ts +1 -1
  143. package/dist/providers/zai.js +4 -8
  144. package/dist/route/auth.d.ts +1 -1
  145. package/dist/route/auth.js +14 -13
  146. package/dist/route/client.d.ts +9 -7
  147. package/dist/route/client.js +6 -8
  148. package/dist/route/endpoint.d.ts +1 -0
  149. package/dist/route/endpoint.js +2 -2
  150. package/dist/route/executor-service.d.ts +4 -2
  151. package/dist/route/executor-service.js +2 -1
  152. package/dist/route/executor.d.ts +3 -1
  153. package/dist/route/executor.js +7 -0
  154. package/dist/route/framing.d.ts +10 -1
  155. package/dist/route/framing.js +45 -5
  156. package/dist/route/index.d.ts +1 -1
  157. package/dist/route/media-protocol.d.ts +49 -35
  158. package/dist/route/media-protocol.js +77 -65
  159. package/dist/route/media.d.ts +10 -16
  160. package/dist/route/media.js +46 -62
  161. package/dist/route/protocol.d.ts +3 -1
  162. package/dist/schema/options.d.ts +6 -3
  163. package/dist/schema/options.js +7 -3
  164. package/dist/speech-client.d.ts +62 -17
  165. package/dist/speech-client.js +17 -21
  166. package/dist/speech.d.ts +178 -21
  167. package/dist/speech.js +13 -8
  168. package/dist/testing.d.ts +2 -2
  169. package/dist/transcription-client.d.ts +78 -24
  170. package/dist/transcription-client.js +9 -40
  171. package/dist/transcription.d.ts +15 -27
  172. package/dist/transcription.js +4 -10
  173. package/dist/utils/json.d.ts +4 -0
  174. package/dist/utils/json.js +4 -0
  175. package/dist/utils/media-type.d.ts +2 -1
  176. package/dist/utils/media-type.js +3 -1
  177. package/dist/video-client.d.ts +55 -24
  178. package/dist/video-client.js +16 -36
  179. package/dist/video.d.ts +18 -26
  180. package/dist/video.js +15 -16
  181. package/package.json +3 -3
  182. package/dist/protocols/utils/meta-image.d.ts +0 -2
  183. package/dist/protocols/utils/meta-image.js +0 -13
  184. package/dist/protocols/utils/openai-image.d.ts +0 -5
  185. package/dist/protocols/utils/openai-image.js +0 -18
@@ -28,33 +28,33 @@ export declare const ContextManagement: Schema.Struct<{
28
28
  }>;
29
29
  export type ContextManagement = typeof ContextManagement.Type;
30
30
  declare const AnthropicThinkingBlockBinding: Schema.Struct<{
31
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
31
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
32
32
  }>;
33
33
  declare const Thinking: Schema.Union<readonly [Schema.decodeTo<Schema.Struct<{
34
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
34
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
35
35
  readonly block_binding: Schema.optional<Schema.Struct<{
36
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
36
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
37
37
  }>>;
38
38
  readonly type: Schema.tag<"enabled">;
39
39
  readonly budget_tokens: Schema.Number;
40
40
  }>, Schema.Union<readonly [Schema.Struct<{
41
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
41
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
42
42
  readonly block_binding: Schema.optional<Schema.Struct<{
43
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
43
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
44
44
  }>>;
45
45
  readonly type: Schema.tag<"enabled">;
46
46
  readonly budgetTokens: Schema.Number;
47
47
  }>, Schema.Struct<{
48
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
48
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
49
49
  readonly block_binding: Schema.optional<Schema.Struct<{
50
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
50
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
51
51
  }>>;
52
52
  readonly type: Schema.tag<"enabled">;
53
53
  readonly budget_tokens: Schema.Number;
54
54
  }>]>, never, never>, Schema.Struct<{
55
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
55
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
56
56
  readonly block_binding: Schema.optional<Schema.Struct<{
57
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
57
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
58
58
  }>>;
59
59
  readonly type: Schema.tag<"adaptive">;
60
60
  }>, Schema.Struct<{
@@ -74,38 +74,38 @@ declare const Options: Schema.Struct<{
74
74
  }>>;
75
75
  }>>;
76
76
  readonly thinking: Schema.optional<Schema.Union<readonly [Schema.decodeTo<Schema.Struct<{
77
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
77
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
78
78
  readonly block_binding: Schema.optional<Schema.Struct<{
79
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
79
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
80
80
  }>>;
81
81
  readonly type: Schema.tag<"enabled">;
82
82
  readonly budget_tokens: Schema.Number;
83
83
  }>, Schema.Union<readonly [Schema.Struct<{
84
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
84
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
85
85
  readonly block_binding: Schema.optional<Schema.Struct<{
86
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
86
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
87
87
  }>>;
88
88
  readonly type: Schema.tag<"enabled">;
89
89
  readonly budgetTokens: Schema.Number;
90
90
  }>, Schema.Struct<{
91
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
91
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
92
92
  readonly block_binding: Schema.optional<Schema.Struct<{
93
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
93
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
94
94
  }>>;
95
95
  readonly type: Schema.tag<"enabled">;
96
96
  readonly budget_tokens: Schema.Number;
97
97
  }>]>, never, never>, Schema.Struct<{
98
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
98
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
99
99
  readonly block_binding: Schema.optional<Schema.Struct<{
100
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
100
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
101
101
  }>>;
102
102
  readonly type: Schema.tag<"adaptive">;
103
103
  }>, Schema.Struct<{
104
104
  readonly type: Schema.tag<"disabled">;
105
105
  }>]>>;
106
106
  readonly effort: Schema.optional<Schema.String>;
107
- readonly service_tier: Schema.optional<Schema.declare<"auto" | (string & {}) | "standard_only", "auto" | (string & {}) | "standard_only">>;
108
- readonly serviceTier: Schema.optional<Schema.declare<"auto" | (string & {}) | "standard_only", "auto" | (string & {}) | "standard_only">>;
107
+ readonly service_tier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "standard_only">, import("../schema/options.js").OpenString<"auto" | "standard_only">>>;
108
+ readonly serviceTier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "standard_only">, import("../schema/options.js").OpenString<"auto" | "standard_only">>>;
109
109
  readonly metadata: Schema.optional<Schema.Struct<{
110
110
  readonly user_id: Schema.optional<Schema.NullOr<Schema.String>>;
111
111
  }>>;
@@ -369,16 +369,16 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
369
369
  top_k: Schema.optional<Schema.Number>;
370
370
  stop_sequences: Schema.optional<Schema.$Array<Schema.String>>;
371
371
  thinking: Schema.optional<Schema.Union<readonly [Schema.Struct<{
372
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
372
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
373
373
  readonly block_binding: Schema.optional<Schema.Struct<{
374
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
374
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
375
375
  }>>;
376
376
  readonly type: Schema.tag<"enabled">;
377
377
  readonly budget_tokens: Schema.Number;
378
378
  }>, Schema.Struct<{
379
- readonly display: Schema.optional<Schema.declare<(string & {}) | "summarized" | "omitted", (string & {}) | "summarized" | "omitted">>;
379
+ readonly display: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"summarized" | "omitted">, import("../schema/options.js").OpenString<"summarized" | "omitted">>>;
380
380
  readonly block_binding: Schema.optional<Schema.Struct<{
381
- readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<(string & {}) | "error" | "drop_block", (string & {}) | "error" | "drop_block">>;
381
+ readonly prefix_mismatch_behavior: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"error" | "drop_block">, import("../schema/options.js").OpenString<"error" | "drop_block">>>;
382
382
  }>>;
383
383
  readonly type: Schema.tag<"adaptive">;
384
384
  }>, Schema.Struct<{
@@ -403,7 +403,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
403
403
  metadata: Schema.optional<Schema.Struct<{
404
404
  readonly user_id: Schema.optional<Schema.NullOr<Schema.String>>;
405
405
  }>>;
406
- service_tier: Schema.optional<Schema.declare<"auto" | (string & {}) | "standard_only", "auto" | (string & {}) | "standard_only">>;
406
+ service_tier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "standard_only">, import("../schema/options.js").OpenString<"auto" | "standard_only">>>;
407
407
  }>;
408
408
  export type AnthropicMessagesBody = Schema.Schema.Type<typeof AnthropicMessagesBody>;
409
409
  /**
@@ -627,20 +627,20 @@ export declare const protocol: Protocol<{
627
627
  readonly thinking?: {
628
628
  readonly type: "enabled";
629
629
  readonly budget_tokens: number;
630
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
630
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
631
631
  readonly block_binding?: {
632
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
632
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
633
633
  } | undefined;
634
634
  } | {
635
635
  readonly type: "adaptive";
636
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
636
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
637
637
  readonly block_binding?: {
638
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
638
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
639
639
  } | undefined;
640
640
  } | {
641
641
  readonly type: "disabled";
642
642
  } | undefined;
643
- readonly service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
643
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
644
644
  readonly container?: string | {
645
645
  readonly id?: string | null | undefined;
646
646
  readonly skills?: readonly {
@@ -984,20 +984,20 @@ export declare const route: Route<{
984
984
  readonly thinking?: {
985
985
  readonly type: "enabled";
986
986
  readonly budget_tokens: number;
987
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
987
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
988
988
  readonly block_binding?: {
989
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
989
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
990
990
  } | undefined;
991
991
  } | {
992
992
  readonly type: "adaptive";
993
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
993
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
994
994
  readonly block_binding?: {
995
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
995
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
996
996
  } | undefined;
997
997
  } | {
998
998
  readonly type: "disabled";
999
999
  } | undefined;
1000
- readonly service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
1000
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
1001
1001
  readonly container?: string | {
1002
1002
  readonly id?: string | null | undefined;
1003
1003
  readonly skills?: readonly {
@@ -14,12 +14,12 @@ import { classifyProviderFailure } from "../provider-error.js";
14
14
  import { effortUpdate, resolveEffortUpdates } from "../effort-updates.js";
15
15
  import * as Cache from "./utils/cache.js";
16
16
  import { Lifecycle } from "./utils/lifecycle.js";
17
- import { ToolSchemaProjection } from "./utils/tool-schema.js";
18
17
  import { ToolStream } from "./utils/tool-stream.js";
19
18
  const ADAPTER = "anthropic-messages";
20
19
  export const DEFAULT_BASE_URL = "https://api.anthropic.com/v1";
21
20
  export const PATH = "/messages";
22
21
  export const DEFAULT_MAX_TOKENS = 32_000;
22
+ const MIN_THINKING_BUDGET = 1_024;
23
23
  const DEFAULT_EFFORT = "high";
24
24
  const SSE_EVENTS = new Set([
25
25
  "message",
@@ -407,10 +407,10 @@ const redactedDataFromMetadata = (metadata, key) => {
407
407
  return undefined;
408
408
  return typeof provider.redactedData === "string" ? provider.redactedData : undefined;
409
409
  };
410
- const lowerTool = (breakpoints, tool, inputSchema) => ({
410
+ const lowerTool = (breakpoints, tool) => ({
411
411
  name: tool.name,
412
412
  description: tool.description,
413
- input_schema: inputSchema,
413
+ input_schema: tool.inputSchema,
414
414
  cache_control: cacheControl(breakpoints, tool.cache),
415
415
  });
416
416
  const lowerToolChoice = (toolChoice) => ProviderShared.matchToolChoice("Anthropic Messages", toolChoice, {
@@ -890,6 +890,13 @@ const applyThinkingBindingDefault = (model, thinking) => {
890
890
  },
891
891
  };
892
892
  };
893
+ // Anthropic also requires an explicit thinking budget below `max_tokens` and at or above its minimum.
894
+ const fitThinking = (thinking, maxTokens) => thinking?.type === "enabled"
895
+ ? {
896
+ ...thinking,
897
+ budget_tokens: ProviderShared.fitThinkingBudget(thinking.budget_tokens, maxTokens, MIN_THINKING_BUDGET),
898
+ }
899
+ : thinking;
893
900
  const fromRequest = Effect.fn("AnthropicMessages.fromRequest")(function* (request) {
894
901
  const options = yield* decodeOptions(request.providerOptions ?? {});
895
902
  const management = options.contextManagement;
@@ -902,9 +909,7 @@ const fromRequest = Effect.fn("AnthropicMessages.fromRequest")(function* (reques
902
909
  // over-mark we keep their tool hints and shed the message-tail ones first.
903
910
  const breakpoints = Cache.newBreakpoints(ANTHROPIC_BREAKPOINT_CAP);
904
911
  const flattened = ProviderShared.flattenToolRequest(updates.request);
905
- const tools = flattened.tools.length === 0
906
- ? undefined
907
- : flattened.tools.map((tool) => lowerTool(breakpoints, tool, ToolSchemaProjection.modelCompatibility(tool.inputSchema, request.model)));
912
+ const tools = flattened.tools.length === 0 ? undefined : flattened.tools.map((tool) => lowerTool(breakpoints, tool));
908
913
  // Anthropic rejects tool_choice when tools are absent; "none" is only meaningful with tools present.
909
914
  const toolChoice = tools === undefined || !request.toolChoice ? undefined : yield* lowerToolChoice(request.toolChoice);
910
915
  const systemParts = request.system.filter((part) => part.text.length > 0);
@@ -920,6 +925,7 @@ const fromRequest = Effect.fn("AnthropicMessages.fromRequest")(function* (reques
920
925
  yield* Effect.logWarning(`Anthropic Messages: dropped ${breakpoints.dropped} cache breakpoint(s); the API allows at most ${ANTHROPIC_BREAKPOINT_CAP} per request.`);
921
926
  }
922
927
  const output_config = updates.effort === undefined && format === undefined ? undefined : { effort: updates.effort, format };
928
+ const maxTokens = generation?.maxTokens ?? DEFAULT_MAX_TOKENS;
923
929
  const body = {
924
930
  model: request.model.id,
925
931
  system,
@@ -927,12 +933,12 @@ const fromRequest = Effect.fn("AnthropicMessages.fromRequest")(function* (reques
927
933
  tools,
928
934
  tool_choice: toolChoice,
929
935
  stream: true,
930
- max_tokens: generation?.maxTokens ?? DEFAULT_MAX_TOKENS,
936
+ max_tokens: maxTokens,
931
937
  temperature: generation?.temperature,
932
938
  top_p: generation?.topP,
933
939
  top_k: generation?.topK,
934
940
  stop_sequences: generation?.stop,
935
- thinking: applyThinkingBindingDefault(request.model, options.thinking),
941
+ thinking: applyThinkingBindingDefault(request.model, fitThinking(options.thinking, maxTokens)),
936
942
  output_config,
937
943
  // top-level passthrough per SDK MessageCreateParamsBase:4638,4643,4649,4654,4670
938
944
  cache_control: options.cache_control ?? options.cacheControl,
@@ -1,6 +1,7 @@
1
1
  import { Schema } from "effect";
2
2
  import { MediaProtocol } from "../route/media-protocol.js";
3
3
  import { MediaRoute } from "../route/media.js";
4
+ import { type OpenString } from "../schema/index.js";
4
5
  import { TranscriptionModel, TranscriptionResponse, type TranscriptionRequestFor } from "../transcription.js";
5
6
  export declare const DEFAULT_BASE_URL = "https://api.assemblyai.com";
6
7
  export declare const PATH = "/v2/transcript";
@@ -21,7 +22,7 @@ export type AssemblyAITranscriptionOptions = {
21
22
  readonly fallback_language?: string;
22
23
  readonly code_switching?: boolean;
23
24
  };
24
- readonly speech_models?: ReadonlyArray<"universal-3-5-pro" | "universal-2" | (string & {})>;
25
+ readonly speech_models?: ReadonlyArray<OpenString<"universal-3-5-pro" | "universal-2">>;
25
26
  } & Record<string, unknown>;
26
27
  export type Request = TranscriptionRequestFor<AssemblyAITranscriptionOptions>;
27
28
  export declare const Token: Schema.Struct<{
@@ -2,13 +2,11 @@ import { Effect, Schema } from "effect";
2
2
  import { Media } from "../media.js";
3
3
  import { MediaProtocol } from "../route/media-protocol.js";
4
4
  import { MediaRoute } from "../route/media.js";
5
- import { ProviderID, mergeJsonRecords } from "../schema/index.js";
5
+ import { mergeJsonRecords } from "../schema/index.js";
6
6
  import { TranscriptionModel, TranscriptionResponse } from "../transcription.js";
7
7
  import { ProviderShared, optionalNull } from "./shared.js";
8
8
  import { MediaInput } from "./utils/media-input.js";
9
- const ADAPTER = "assemblyai-transcription";
10
- const NAME = "AssemblyAI";
11
- const PROVIDER = ProviderID.make("assemblyai");
9
+ const route = MediaProtocol.identity({ id: "assemblyai-transcription", name: "AssemblyAI", provider: "assemblyai" });
12
10
  export const DEFAULT_BASE_URL = "https://api.assemblyai.com";
13
11
  export const PATH = "/v2/transcript";
14
12
  export const UPLOAD_PATH = "/v2/upload";
@@ -49,32 +47,34 @@ const STATUS = {
49
47
  // ---------------------------------------------------------------------------
50
48
  // 5. Request body construction
51
49
  // ---------------------------------------------------------------------------
52
- const decodeUpload = MediaProtocol.decodeJson(ADAPTER, NAME, Upload);
50
+ const decodeUpload = route.decodeJson(Upload);
53
51
  /** `/v2/transcript` only takes a URL, so inline audio is uploaded to `/v2/upload` first. */
54
52
  const prepare = Effect.fn("AssemblyAITranscription.prepare")(function* (request, send) {
55
53
  if (request.audio.source.type !== "bytes" && request.audio.source.type !== "base64")
56
54
  return request;
57
- const audio = yield* MediaInput.inlineBytes(ADAPTER, request.audio);
55
+ const audio = yield* MediaInput.inlineBytes(route.id, request.audio);
58
56
  const uploaded = yield* send(UPLOAD_PATH, MediaProtocol.binary(audio, "application/octet-stream")).pipe(Effect.flatMap(decodeUpload));
59
57
  return { ...request, audio: Media.url(uploaded.value.upload_url, { mediaType: request.audio.mediaType }) };
60
58
  });
61
59
  const fromRequest = Effect.fn("AssemblyAITranscription.fromRequest")(function* (request) {
62
- const audio = yield* ProviderShared.mediaReference(request.audio, PROVIDER, NAME);
60
+ const audio = yield* ProviderShared.mediaReference(request.audio, route.provider, route.name);
63
61
  return MediaProtocol.json(mergeJsonRecords({
64
62
  audio_url: audio.value,
65
63
  speech_models: [request.model.id],
66
64
  language_code: request.language,
67
65
  language_detection: request.language === undefined ? true : undefined,
68
66
  prompt: request.prompt,
69
- // Turn-level `utterances`, the only segments AssemblyAI returns, require speaker labels.
70
- speaker_labels: request.diarize === true || request.timestamps === "segment" ? true : undefined,
67
+ // Turn-level `utterances`, the only segments AssemblyAI returns, and `speakers_expected` require speaker labels.
68
+ speaker_labels: request.diarize === true || request.timestamps === "segment" || request.speakers !== undefined
69
+ ? true
70
+ : undefined,
71
71
  speakers_expected: request.speakers,
72
72
  }, request.providerOptions, request.http?.body) ?? {});
73
73
  });
74
74
  // ---------------------------------------------------------------------------
75
75
  // 6. Response decoding
76
76
  // ---------------------------------------------------------------------------
77
- const decodeTranscript = MediaProtocol.decodeJson(ADAPTER, NAME, Transcript);
77
+ const decodeTranscript = route.decodeJson(Transcript);
78
78
  const decodeStart = Effect.fn("AssemblyAITranscription.decodeStart")(function* (response) {
79
79
  const output = yield* decodeTranscript(response);
80
80
  const status = yield* MediaProtocol.status(STATUS, output.value.status, output);
@@ -92,9 +92,9 @@ const decodeResult = Effect.fn("AssemblyAITranscription.decodeResult")(function*
92
92
  const status = yield* MediaProtocol.status(STATUS, transcript.status, output);
93
93
  const error = transcript.error ?? undefined;
94
94
  if (status === "failed")
95
- return yield* output.ended("failed", `${NAME} transcription failed${error === undefined ? "" : `: ${error}`}`);
95
+ return yield* output.ended("failed", `${route.name} transcription failed${error === undefined ? "" : `: ${error}`}`);
96
96
  if (status !== "completed")
97
- return yield* output.invalid(`${NAME} transcript ${context.token.transcriptID} has not finished`);
97
+ return yield* output.pending(context.token.transcriptID);
98
98
  const duration = transcript.audio_duration ?? undefined;
99
99
  return new TranscriptionResponse({
100
100
  text: transcript.text ?? "",
@@ -123,15 +123,13 @@ const decodeResult = Effect.fn("AssemblyAITranscription.decodeResult")(function*
123
123
  // 7. Protocol and route
124
124
  // ---------------------------------------------------------------------------
125
125
  const transcriptPath = (token) => `${PATH}/${token.transcriptID}`;
126
- export const protocol = MediaProtocol.queued({
127
- id: ADAPTER,
128
- name: NAME,
126
+ export const protocol = MediaProtocol.queued(route, {
129
127
  token: Token,
130
128
  start: { prepare, body: { from: fromRequest }, decode: decodeStart },
131
129
  status: { path: transcriptPath, decode: decodeStatus },
132
130
  result: { path: transcriptPath, decode: decodeResult },
133
131
  });
134
- export const model = (input) => TranscriptionModel.fromRoute({ id: ADAPTER, provider: PROVIDER, protocol, baseURL: DEFAULT_BASE_URL, path: PATH }, input);
132
+ export const model = (input) => TranscriptionModel.fromRoute({ protocol, baseURL: DEFAULT_BASE_URL, path: PATH }, input);
135
133
  export const AssemblyAITranscription = {
136
134
  protocol,
137
135
  model,
@@ -126,6 +126,13 @@ declare const BedrockConverseBody: Schema.Struct<{
126
126
  additionalModelRequestFields: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
127
127
  }>;
128
128
  export type BedrockConverseBody = Schema.Schema.Type<typeof BedrockConverseBody>;
129
+ declare const Options: Schema.Struct<{
130
+ readonly thinking: Schema.optional<Schema.Struct<{
131
+ readonly type: Schema.Literal<"enabled">;
132
+ readonly budgetTokens: Schema.Number;
133
+ }>>;
134
+ }>;
135
+ export type OptionsInput = typeof Options.Type;
129
136
  interface ParserState {
130
137
  readonly providerMetadataKey: string;
131
138
  readonly tools: ToolStream.State<number>;
@@ -11,7 +11,6 @@ import { BedrockCache } from "./utils/bedrock-cache.js";
11
11
  import { BedrockMedia } from "./utils/bedrock-media.js";
12
12
  import { Lifecycle } from "./utils/lifecycle.js";
13
13
  import { MistralToolID } from "./utils/mistral-tool-id.js";
14
- import { ToolSchemaProjection } from "./utils/tool-schema.js";
15
14
  import { ToolStream } from "./utils/tool-stream.js";
16
15
  import { concatBytes } from "../utils/bytes.js";
17
16
  const ADAPTER = "bedrock-converse";
@@ -156,17 +155,17 @@ const BedrockEvent = Schema.Struct({
156
155
  // =============================================================================
157
156
  // Request Lowering
158
157
  // =============================================================================
159
- const lowerToolSpec = (tool, inputSchema) => ({
158
+ const lowerToolSpec = (tool) => ({
160
159
  toolSpec: {
161
160
  name: tool.name,
162
161
  ...(tool.description.trim().length > 0 ? { description: tool.description } : {}),
163
- inputSchema: { json: inputSchema },
162
+ inputSchema: { json: tool.inputSchema },
164
163
  },
165
164
  });
166
- const lowerTools = (model, breakpoints, tools) => {
165
+ const lowerTools = (breakpoints, tools) => {
167
166
  const result = [];
168
167
  for (const tool of tools) {
169
- result.push(lowerToolSpec(tool, ToolSchemaProjection.modelCompatibility(tool.inputSchema, model)));
168
+ result.push(lowerToolSpec(tool));
170
169
  const cachePoint = BedrockCache.block(breakpoints, tool.cache);
171
170
  if (cachePoint)
172
171
  result.push(cachePoint);
@@ -338,10 +337,32 @@ const lowerSystem = (breakpoints, system) => {
338
337
  .flatMap((part) => textWithCache(breakpoints, part.text, part.cache));
339
338
  return content.length === 0 ? undefined : content;
340
339
  };
340
+ // Nova 2 rejects `maxTokens` at high reasoning effort, where its output can exceed the field's maximum. Other models
341
+ // that take `reasoningConfig`, such as Grok on Bedrock, accept it.
342
+ const isNova2 = (model) => /\bamazon\.nova-2-/.test(model.id);
343
+ const isHighReasoningEffort = Schema.is(Schema.Struct({
344
+ additionalModelRequestFields: Schema.Struct({
345
+ reasoningConfig: Schema.Struct({ maxReasoningEffort: Schema.Literal("high") }),
346
+ }),
347
+ }));
348
+ const Options = Schema.Struct({
349
+ thinking: Schema.optional(Schema.Struct({ type: Schema.Literal("enabled"), budgetTokens: Schema.Number })),
350
+ });
351
+ const decodeOptions = ProviderShared.validateWith(Schema.decodeUnknownEffect(Options));
352
+ // Claude on Bedrock requires the thinking budget below `maxTokens`, with a minimum of 1,024.
353
+ const MIN_THINKING_BUDGET = 1_024;
341
354
  const fromRequest = Effect.fn("BedrockConverse.fromRequest")(function* (request) {
342
355
  const toolChoice = request.toolChoice ? yield* lowerToolChoice(request.toolChoice) : undefined;
343
356
  const flattened = ProviderShared.flattenToolRequest(request);
344
357
  const generation = request.generation;
358
+ const options = yield* decodeOptions(request.providerOptions ?? {});
359
+ const maxTokens = isNova2(request.model) && isHighReasoningEffort(request.http?.body) ? undefined : generation?.maxTokens;
360
+ const thinking = options.thinking === undefined
361
+ ? undefined
362
+ : {
363
+ type: "enabled",
364
+ budget_tokens: ProviderShared.fitThinkingBudget(options.thinking.budgetTokens, maxTokens, MIN_THINKING_BUDGET),
365
+ };
345
366
  // Bedrock-Claude shares Anthropic's 4-breakpoint cap. Spend the budget in
346
367
  // tools → system → messages order to favour the highest-impact prefixes.
347
368
  const breakpoints = BedrockCache.breakpoints(request.model.id);
@@ -349,7 +370,7 @@ const fromRequest = Effect.fn("BedrockConverse.fromRequest")(function* (request)
349
370
  if (flattened.tools.length === 0)
350
371
  return undefined;
351
372
  return {
352
- tools: lowerTools(request.model, breakpoints, flattened.tools),
373
+ tools: lowerTools(breakpoints, flattened.tools),
353
374
  // Converse has no native "none". Keep definitions stable for prompt
354
375
  // caching and omit only the unsupported choice.
355
376
  toolChoice,
@@ -361,13 +382,13 @@ const fromRequest = Effect.fn("BedrockConverse.fromRequest")(function* (request)
361
382
  yield* Effect.logWarning(`Bedrock Converse: dropped ${breakpoints.dropped} cache breakpoint(s); the API allows at most ${BedrockCache.BEDROCK_BREAKPOINT_CAP} per request.`);
362
383
  }
363
384
  const inferenceConfig = (() => {
364
- if (generation?.maxTokens === undefined &&
385
+ if (maxTokens === undefined &&
365
386
  generation?.temperature === undefined &&
366
387
  generation?.topP === undefined &&
367
388
  (generation?.stop === undefined || generation.stop.length === 0))
368
389
  return undefined;
369
390
  return {
370
- maxTokens: generation?.maxTokens,
391
+ maxTokens,
371
392
  temperature: generation?.temperature,
372
393
  topP: generation?.topP,
373
394
  stopSequences: generation?.stop,
@@ -379,9 +400,14 @@ const fromRequest = Effect.fn("BedrockConverse.fromRequest")(function* (request)
379
400
  system,
380
401
  inferenceConfig,
381
402
  toolConfig,
382
- // Converse's base inferenceConfig has no topK; Anthropic/Nova accept it
383
- // as a model-specific field, so it goes through additionalModelRequestFields.
384
- additionalModelRequestFields: generation?.topK === undefined ? undefined : { top_k: generation.topK },
403
+ // Converse's base inferenceConfig has no topK or thinking; Anthropic/Nova accept them
404
+ // as model-specific fields, so they go through additionalModelRequestFields.
405
+ additionalModelRequestFields: generation?.topK === undefined && thinking === undefined
406
+ ? undefined
407
+ : {
408
+ ...(generation?.topK === undefined ? {} : { top_k: generation.topK }),
409
+ ...(thinking === undefined ? {} : { thinking }),
410
+ },
385
411
  };
386
412
  });
387
413
  // =============================================================================
@@ -12,21 +12,27 @@ export type BlackForestLabsImageOptions = {
12
12
  readonly steps?: number;
13
13
  } & Record<string, unknown>;
14
14
  export type Request = ImageRequestFor<BlackForestLabsImageOptions>;
15
- /** Regional clusters answer on different hosts, so the returned `polling_url` is followed verbatim. */
15
+ /**
16
+ * Regional clusters answer on different hosts, so the returned `polling_url` is followed verbatim. BFL reports the
17
+ * credit cost on submit, so it rides on the token; it is optional so tokens persisted before it existed still decode.
18
+ */
16
19
  export declare const Token: Schema.Struct<{
17
20
  readonly id: Schema.String;
18
21
  readonly pollingURL: Schema.String;
22
+ readonly cost: Schema.optionalKey<Schema.Number>;
19
23
  }>;
20
24
  export type Token = Schema.Schema.Type<typeof Token>;
21
25
  export declare const protocol: MediaProtocol.Queued<Request, ImageResponse, {
22
26
  readonly id: string;
23
27
  readonly pollingURL: string;
28
+ readonly cost?: number | undefined;
24
29
  }>;
25
30
  export declare const model: (input: MediaRoute.ModelInput) => ImageModel<BlackForestLabsImageOptions>;
26
31
  export declare const BlackForestLabsImages: {
27
32
  readonly protocol: MediaProtocol.Queued<Request, ImageResponse, {
28
33
  readonly id: string;
29
34
  readonly pollingURL: string;
35
+ readonly cost?: number | undefined;
30
36
  }>;
31
37
  readonly model: (input: MediaRoute.ModelInput) => ImageModel<BlackForestLabsImageOptions>;
32
38
  };