@opencode/ai 2.2.5 → 2.2.6

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 (264) hide show
  1. package/README.md +133 -69
  2. package/dist/cache-policy.d.ts +1 -1
  3. package/dist/cache-policy.js +16 -4
  4. package/dist/decision-client.d.ts +3 -3
  5. package/dist/decision.d.ts +20 -125
  6. package/dist/decision.js +25 -15
  7. package/dist/effect.d.ts +4 -15
  8. package/dist/effect.js +2 -6
  9. package/dist/effort-updates.d.ts +3 -3
  10. package/dist/effort-updates.js +2 -2
  11. package/dist/experimental/cloudflare-run-extraction.d.ts +7 -3
  12. package/dist/experimental/cloudflare-run-extraction.js +4 -1
  13. package/dist/experimental/extraction.d.ts +10 -40
  14. package/dist/experimental/extraction.js +14 -13
  15. package/dist/experimental.d.ts +8 -8
  16. package/dist/experimental.js +4 -4
  17. package/dist/generation.d.ts +0 -2
  18. package/dist/generation.js +2 -2
  19. package/dist/image-client.d.ts +13 -7
  20. package/dist/image-client.js +1 -1
  21. package/dist/image.d.ts +357 -464
  22. package/dist/image.js +17 -15
  23. package/dist/index.d.ts +28 -465
  24. package/dist/index.js +18 -17
  25. package/dist/llm.d.ts +65 -266
  26. package/dist/llm.js +101 -92
  27. package/dist/loop.d.ts +38 -0
  28. package/dist/loop.js +136 -0
  29. package/dist/media-model.d.ts +1 -1
  30. package/dist/media-model.js +8 -6
  31. package/dist/media.d.ts +9 -0
  32. package/dist/media.js +37 -2
  33. package/dist/protocols/alibaba-chat.d.ts +5 -1
  34. package/dist/protocols/alibaba-chat.js +3 -3
  35. package/dist/protocols/alibaba-images.d.ts +2 -2
  36. package/dist/protocols/alibaba-messages.js +3 -3
  37. package/dist/protocols/alibaba-responses.js +8 -20
  38. package/dist/protocols/anthropic-messages.d.ts +1 -1
  39. package/dist/protocols/anthropic-messages.js +54 -173
  40. package/dist/protocols/assemblyai-transcription.d.ts +2 -2
  41. package/dist/protocols/bedrock-converse.js +10 -16
  42. package/dist/protocols/cartesia-speech.d.ts +2 -2
  43. package/dist/protocols/cloudflare-workers-ai-images.d.ts +2 -2
  44. package/dist/protocols/cohere-chat.js +9 -12
  45. package/dist/protocols/deepgram-speech.d.ts +2 -2
  46. package/dist/protocols/deepgram-transcription.d.ts +2 -2
  47. package/dist/protocols/elevenlabs-speech.d.ts +2 -2
  48. package/dist/protocols/elevenlabs-transcription.d.ts +2 -2
  49. package/dist/protocols/gemini.d.ts +3 -0
  50. package/dist/protocols/gemini.js +54 -72
  51. package/dist/protocols/google-images.d.ts +2 -2
  52. package/dist/protocols/google-interactions.d.ts +3 -4
  53. package/dist/protocols/google-interactions.js +44 -30
  54. package/dist/protocols/google-speech.d.ts +2 -2
  55. package/dist/protocols/google-transcription.d.ts +2 -2
  56. package/dist/protocols/google-video.d.ts +2 -2
  57. package/dist/protocols/meta-images.d.ts +2 -2
  58. package/dist/protocols/meta-responses.js +26 -23
  59. package/dist/protocols/minimax-images.d.ts +2 -2
  60. package/dist/protocols/mistral-chat.js +7 -10
  61. package/dist/protocols/open-responses-channel.js +6 -19
  62. package/dist/protocols/open-responses-continuation.d.ts +1 -5
  63. package/dist/protocols/open-responses-continuation.js +1 -3
  64. package/dist/protocols/open-responses.d.ts +1 -21
  65. package/dist/protocols/open-responses.js +10 -15
  66. package/dist/protocols/openai-chat.d.ts +3 -23
  67. package/dist/protocols/openai-chat.js +26 -47
  68. package/dist/protocols/openai-compatible-chat.d.ts +1 -1
  69. package/dist/protocols/openai-compatible-responses.d.ts +2 -2
  70. package/dist/protocols/openai-compatible-responses.js +1 -1
  71. package/dist/protocols/openai-decisions.js +1 -1
  72. package/dist/protocols/openai-images.d.ts +2 -2
  73. package/dist/protocols/openai-responses.js +10 -29
  74. package/dist/protocols/openai-speech.d.ts +2 -2
  75. package/dist/protocols/openai-transcription.d.ts +2 -2
  76. package/dist/protocols/runway-video.d.ts +2 -2
  77. package/dist/protocols/shared.d.ts +1 -4
  78. package/dist/protocols/shared.js +13 -11
  79. package/dist/protocols/system-one.d.ts +4 -4
  80. package/dist/protocols/utils/bedrock-cache.js +2 -5
  81. package/dist/protocols/utils/bedrock-media.d.ts +0 -3
  82. package/dist/protocols/utils/cache.d.ts +3 -0
  83. package/dist/protocols/utils/cache.js +15 -2
  84. package/dist/protocols/utils/image-sizing.d.ts +1 -1
  85. package/dist/protocols/utils/responses-checkpoint.js +1 -1
  86. package/dist/protocols/utils/responses-compaction.d.ts +1 -1
  87. package/dist/protocols/utils/responses-compaction.js +6 -5
  88. package/dist/protocols/utils/responses-hosted-tools.d.ts +97 -1
  89. package/dist/protocols/utils/responses-hosted-tools.js +31 -0
  90. package/dist/protocols/utils/tool-stream.d.ts +5 -271
  91. package/dist/protocols/utils/tool-stream.js +3 -13
  92. package/dist/protocols/venice-chat.d.ts +3 -1
  93. package/dist/protocols/venice-chat.js +4 -4
  94. package/dist/protocols/xai-images.d.ts +2 -2
  95. package/dist/protocols/xai-responses.js +5 -25
  96. package/dist/protocols/xai-video.d.ts +2 -2
  97. package/dist/protocols/zai-chat.d.ts +5 -1
  98. package/dist/protocols/zai-chat.js +1 -1
  99. package/dist/protocols/zai-images.d.ts +2 -2
  100. package/dist/protocols/zai-messages.js +3 -3
  101. package/dist/provider-error.d.ts +0 -1
  102. package/dist/provider-error.js +7 -80
  103. package/dist/providers/alibaba.d.ts +67 -4
  104. package/dist/providers/alibaba.js +6 -1
  105. package/dist/providers/amazon-bedrock-mantle.d.ts +6 -3
  106. package/dist/providers/amazon-bedrock-mantle.js +6 -3
  107. package/dist/providers/amazon-bedrock.d.ts +6 -7
  108. package/dist/providers/amazon-bedrock.js +1 -1
  109. package/dist/providers/anthropic-compatible.d.ts +7 -8
  110. package/dist/providers/anthropic-compatible.js +2 -5
  111. package/dist/providers/anthropic.d.ts +8 -9
  112. package/dist/providers/anthropic.js +2 -7
  113. package/dist/providers/assemblyai.d.ts +2 -2
  114. package/dist/providers/assemblyai.js +2 -7
  115. package/dist/providers/azure/messages.d.ts +2 -0
  116. package/dist/providers/azure/messages.js +1 -0
  117. package/dist/providers/azure.d.ts +322 -7
  118. package/dist/providers/azure.js +25 -9
  119. package/dist/providers/baseten.d.ts +5 -5
  120. package/dist/providers/baseten.js +7 -21
  121. package/dist/providers/cartesia.d.ts +1 -1
  122. package/dist/providers/cerebras.d.ts +5 -5
  123. package/dist/providers/cerebras.js +4 -15
  124. package/dist/providers/cloudflare-ai-gateway.d.ts +21 -13
  125. package/dist/providers/cloudflare-ai-gateway.js +28 -40
  126. package/dist/providers/cloudflare-shared.d.ts +9 -0
  127. package/dist/providers/cloudflare-shared.js +25 -0
  128. package/dist/providers/cloudflare-workers-ai.d.ts +4 -4
  129. package/dist/providers/cloudflare-workers-ai.js +4 -20
  130. package/dist/providers/cohere/chat.js +2 -7
  131. package/dist/providers/cohere.d.ts +6 -5
  132. package/dist/providers/cohere.js +7 -13
  133. package/dist/providers/deepgram.d.ts +2 -2
  134. package/dist/providers/deepgram.js +2 -7
  135. package/dist/providers/deepinfra.d.ts +5 -5
  136. package/dist/providers/deepinfra.js +5 -13
  137. package/dist/providers/deepseek.d.ts +5 -5
  138. package/dist/providers/deepseek.js +3 -14
  139. package/dist/providers/digitalocean.d.ts +8 -5
  140. package/dist/providers/digitalocean.js +13 -14
  141. package/dist/providers/elevenlabs.d.ts +2 -2
  142. package/dist/providers/elevenlabs.js +2 -7
  143. package/dist/providers/fireworks.d.ts +5 -5
  144. package/dist/providers/fireworks.js +4 -15
  145. package/dist/providers/google/interactions.d.ts +1 -1
  146. package/dist/providers/google/interactions.js +2 -7
  147. package/dist/providers/google-vertex-chat.d.ts +3 -3
  148. package/dist/providers/google-vertex-chat.js +3 -29
  149. package/dist/providers/google-vertex-interactions.d.ts +3 -3
  150. package/dist/providers/google-vertex-messages.d.ts +3 -3
  151. package/dist/providers/google-vertex-messages.js +3 -29
  152. package/dist/providers/google-vertex-mistral.d.ts +3 -3
  153. package/dist/providers/google-vertex-mistral.js +3 -29
  154. package/dist/providers/google-vertex-responses.d.ts +3 -3
  155. package/dist/providers/google-vertex-responses.js +4 -30
  156. package/dist/providers/google-vertex-shared.d.ts +31 -0
  157. package/dist/providers/google-vertex-shared.js +25 -0
  158. package/dist/providers/google-vertex.d.ts +3 -3
  159. package/dist/providers/google.d.ts +15 -13
  160. package/dist/providers/google.js +9 -19
  161. package/dist/providers/groq.d.ts +5 -5
  162. package/dist/providers/groq.js +4 -15
  163. package/dist/providers/meta.d.ts +5 -5
  164. package/dist/providers/meta.js +10 -23
  165. package/dist/providers/minimax/chat.js +2 -7
  166. package/dist/providers/minimax/responses.js +2 -7
  167. package/dist/providers/minimax.d.ts +5 -5
  168. package/dist/providers/minimax.js +7 -22
  169. package/dist/providers/mistral.d.ts +10 -11
  170. package/dist/providers/mistral.js +3 -14
  171. package/dist/providers/moonshot/messages.js +2 -7
  172. package/dist/providers/moonshot/responses.js +2 -7
  173. package/dist/providers/moonshot.d.ts +5 -5
  174. package/dist/providers/moonshot.js +4 -16
  175. package/dist/providers/openai-compatible-responses.d.ts +6 -7
  176. package/dist/providers/openai-compatible-responses.js +2 -8
  177. package/dist/providers/openai-compatible.d.ts +6 -7
  178. package/dist/providers/openai-compatible.js +4 -10
  179. package/dist/providers/openai.d.ts +4 -4
  180. package/dist/providers/openai.js +3 -3
  181. package/dist/providers/opencode.d.ts +4 -4
  182. package/dist/providers/opencode.js +6 -2
  183. package/dist/providers/openrouter.d.ts +8 -5
  184. package/dist/providers/openrouter.js +16 -24
  185. package/dist/providers/runway.d.ts +1 -1
  186. package/dist/providers/settings.d.ts +40 -0
  187. package/dist/providers/settings.js +19 -0
  188. package/dist/providers/togetherai.d.ts +5 -5
  189. package/dist/providers/togetherai.js +5 -15
  190. package/dist/providers/typesafe-ai.d.ts +4 -4
  191. package/dist/providers/typesafe-ai.js +6 -2
  192. package/dist/providers/venice.d.ts +4 -4
  193. package/dist/providers/venice.js +6 -2
  194. package/dist/providers/vercel-ai-gateway.d.ts +5 -5
  195. package/dist/providers/vercel-ai-gateway.js +15 -28
  196. package/dist/providers/xai.d.ts +4 -4
  197. package/dist/providers/xai.js +4 -12
  198. package/dist/providers/zai-coding-plan/messages.js +2 -7
  199. package/dist/providers/zai-coding-plan/responses.js +2 -7
  200. package/dist/providers/zai-coding-plan.d.ts +5 -5
  201. package/dist/providers/zai-coding-plan.js +8 -15
  202. package/dist/providers/zai.d.ts +5 -5
  203. package/dist/providers/zai.js +10 -22
  204. package/dist/public.d.ts +12 -0
  205. package/dist/public.js +5 -0
  206. package/dist/route/auth-options.d.ts +9 -5
  207. package/dist/route/auth-options.js +10 -7
  208. package/dist/route/client.d.ts +50 -37
  209. package/dist/route/client.js +42 -53
  210. package/dist/route/decision.d.ts +8 -8
  211. package/dist/route/decision.js +3 -3
  212. package/dist/route/executor.d.ts +5 -0
  213. package/dist/route/executor.js +10 -0
  214. package/dist/route/index.d.ts +5 -7
  215. package/dist/route/index.js +1 -1
  216. package/dist/route/media.d.ts +7 -11
  217. package/dist/route/media.js +22 -26
  218. package/dist/route/transport/http.js +6 -5
  219. package/dist/route/transport/websocket.js +7 -1
  220. package/dist/schema/errors.d.ts +16 -17
  221. package/dist/schema/errors.js +63 -12
  222. package/dist/schema/events.d.ts +2563 -2954
  223. package/dist/schema/events.js +54 -109
  224. package/dist/schema/messages.d.ts +194 -137
  225. package/dist/schema/messages.js +66 -83
  226. package/dist/schema/options.d.ts +112 -65
  227. package/dist/schema/options.js +52 -101
  228. package/dist/speech-client.d.ts +7 -7
  229. package/dist/speech.d.ts +306 -316
  230. package/dist/speech.js +16 -14
  231. package/dist/testing.d.ts +31 -175
  232. package/dist/testing.js +60 -5
  233. package/dist/tool-history.d.ts +1 -1
  234. package/dist/tool-history.js +3 -10
  235. package/dist/tool-runtime.d.ts +9 -2
  236. package/dist/tool-runtime.js +17 -31
  237. package/dist/tool.d.ts +39 -43
  238. package/dist/tool.js +16 -26
  239. package/dist/transcription-client.d.ts +7 -7
  240. package/dist/transcription.d.ts +314 -265
  241. package/dist/transcription.js +16 -14
  242. package/dist/utils/provider-codes.d.ts +3 -0
  243. package/dist/utils/provider-codes.js +41 -0
  244. package/dist/video-client.d.ts +7 -7
  245. package/dist/video-client.js +1 -1
  246. package/dist/video.d.ts +269 -287
  247. package/dist/video.js +16 -14
  248. package/package.json +9 -9
  249. package/dist/experimental/testing.d.ts +0 -3
  250. package/dist/experimental/testing.js +0 -3
  251. package/dist/testing/decision.d.ts +0 -16
  252. package/dist/testing/decision.js +0 -20
  253. package/dist/testing/image.d.ts +0 -14
  254. package/dist/testing/image.js +0 -12
  255. package/dist/testing/media.d.ts +0 -18
  256. package/dist/testing/media.js +0 -36
  257. package/dist/testing/script.d.ts +0 -28
  258. package/dist/testing/script.js +0 -60
  259. package/dist/testing/speech.d.ts +0 -14
  260. package/dist/testing/speech.js +0 -12
  261. package/dist/testing/transcription.d.ts +0 -14
  262. package/dist/testing/transcription.js +0 -12
  263. package/dist/testing/video.d.ts +0 -14
  264. package/dist/testing/video.js +0 -12
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
  import { Tool } from "@opencode/schema/tool";
3
- import { CacheHint, GenerationOptions, HttpOptions, JsonSchema, type LanguageModel, ReasoningEffort } from "./options.js";
3
+ import { type BaseRequest, CacheHint, type CachePolicy, JsonSchema, type LanguageModel, type LanguageModelProviderOptions, ReasoningEffort, type GenerationOptionsFields } from "./options.js";
4
4
  import { Media } from "../media.js";
5
5
  export declare const MessageRole: Schema.Literals<readonly ["system", "user", "assistant", "tool"]>;
6
6
  export type MessageRole = Schema.Schema.Type<typeof MessageRole>;
@@ -25,7 +25,6 @@ export declare const TextPart: Schema.Struct<{
25
25
  readonly type: Schema.Literal<"text">;
26
26
  readonly text: Schema.String;
27
27
  readonly cache: Schema.optional<typeof CacheHint>;
28
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
29
28
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
30
29
  }>;
31
30
  export type TextPart = Schema.Schema.Type<typeof TextPart>;
@@ -64,10 +63,14 @@ export declare const MediaPart: Schema.Struct<{
64
63
  }>, never, never>;
65
64
  readonly filename: Schema.optional<Schema.String>;
66
65
  readonly cache: Schema.optional<typeof CacheHint>;
67
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
68
66
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
69
67
  }>;
70
68
  export type MediaPart = Schema.Schema.Type<typeof MediaPart>;
69
+ /** A media part as input: `media` may be plain data, with `mediaType` naming its type when the content can't. */
70
+ export type MediaPartInput = Omit<MediaPart, "media"> & {
71
+ readonly media: Media.Input;
72
+ readonly mediaType?: string;
73
+ };
71
74
  declare const toolResultValueSchema: Schema.Union<readonly [Schema.Struct<{
72
75
  readonly type: Schema.Literal<"json">;
73
76
  readonly value: Schema.Unknown;
@@ -162,7 +165,6 @@ export declare const ToolCallPart: Schema.Struct<{
162
165
  readonly input: Schema.Unknown;
163
166
  readonly providerExecuted: Schema.optional<Schema.Boolean>;
164
167
  readonly cache: Schema.optional<typeof CacheHint>;
165
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
166
168
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
167
169
  }> & {
168
170
  make: (input: Omit<ToolCallPart, "type">) => ToolCallPart;
@@ -219,7 +221,6 @@ export declare const ToolResultPart: Schema.Struct<{
219
221
  };
220
222
  readonly providerExecuted: Schema.optional<Schema.Boolean>;
221
223
  readonly cache: Schema.optional<typeof CacheHint>;
222
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
223
224
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
224
225
  }> & {
225
226
  make: (input: Omit<ToolResultPart, "type" | "result"> & {
@@ -233,7 +234,6 @@ export declare const ReasoningPart: Schema.Struct<{
233
234
  readonly text: Schema.String;
234
235
  readonly encrypted: Schema.optional<Schema.String>;
235
236
  readonly cache: Schema.optional<typeof CacheHint>;
236
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
237
237
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
238
238
  }>;
239
239
  export type ReasoningPart = Schema.Schema.Type<typeof ReasoningPart>;
@@ -287,7 +287,6 @@ export declare const ContentPart: Schema.toTaggedUnion<"type", readonly [Schema.
287
287
  readonly type: Schema.Literal<"text">;
288
288
  readonly text: Schema.String;
289
289
  readonly cache: Schema.optional<typeof CacheHint>;
290
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
291
290
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
292
291
  }>, Schema.Struct<{
293
292
  readonly type: Schema.Literal<"media">;
@@ -324,7 +323,6 @@ export declare const ContentPart: Schema.toTaggedUnion<"type", readonly [Schema.
324
323
  }>, never, never>;
325
324
  readonly filename: Schema.optional<Schema.String>;
326
325
  readonly cache: Schema.optional<typeof CacheHint>;
327
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
328
326
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
329
327
  }>, Schema.Struct<{
330
328
  readonly type: Schema.Literal<"tool-call">;
@@ -334,7 +332,6 @@ export declare const ContentPart: Schema.toTaggedUnion<"type", readonly [Schema.
334
332
  readonly input: Schema.Unknown;
335
333
  readonly providerExecuted: Schema.optional<Schema.Boolean>;
336
334
  readonly cache: Schema.optional<typeof CacheHint>;
337
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
338
335
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
339
336
  }> & {
340
337
  make: (input: Omit<ToolCallPart, "type">) => ToolCallPart;
@@ -389,7 +386,6 @@ export declare const ContentPart: Schema.toTaggedUnion<"type", readonly [Schema.
389
386
  };
390
387
  readonly providerExecuted: Schema.optional<Schema.Boolean>;
391
388
  readonly cache: Schema.optional<typeof CacheHint>;
392
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
393
389
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
394
390
  }> & {
395
391
  make: (input: Omit<ToolResultPart, "type" | "result"> & {
@@ -401,7 +397,6 @@ export declare const ContentPart: Schema.toTaggedUnion<"type", readonly [Schema.
401
397
  readonly text: Schema.String;
402
398
  readonly encrypted: Schema.optional<Schema.String>;
403
399
  readonly cache: Schema.optional<typeof CacheHint>;
404
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
405
400
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
406
401
  }>, Schema.refine<{
407
402
  readonly type: "compaction";
@@ -424,14 +419,29 @@ export declare const ContentPart: Schema.toTaggedUnion<"type", readonly [Schema.
424
419
  readonly previous: Schema.optional<Schema.declare<ReasoningEffort, ReasoningEffort>>;
425
420
  }>]>;
426
421
  export type ContentPart = Schema.Schema.Type<typeof ContentPart>;
427
- declare const Message_base: Schema.Class<Message, Schema.Struct<{
422
+ declare const SystemMessage_base: Schema.Class<SystemMessage, Schema.Struct<{
423
+ readonly id: Schema.optional<Schema.String>;
424
+ readonly role: Schema.Literal<"system">;
425
+ readonly content: Schema.$Array<Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
426
+ readonly type: Schema.Literal<"text">;
427
+ readonly text: Schema.String;
428
+ readonly cache: Schema.optional<typeof CacheHint>;
429
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
430
+ }>, Schema.Struct<{
431
+ readonly type: Schema.Literal<"effort">;
432
+ readonly effort: Schema.optional<Schema.declare<ReasoningEffort, ReasoningEffort>>;
433
+ readonly previous: Schema.optional<Schema.declare<ReasoningEffort, ReasoningEffort>>;
434
+ }>]>>;
435
+ }>, {}>;
436
+ export declare class SystemMessage extends SystemMessage_base {
437
+ }
438
+ declare const UserMessage_base: Schema.Class<UserMessage, Schema.Struct<{
428
439
  readonly id: Schema.optional<Schema.String>;
429
- readonly role: Schema.Literals<readonly ["system", "user", "assistant", "tool"]>;
440
+ readonly role: Schema.Literal<"user">;
430
441
  readonly content: Schema.$Array<Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
431
442
  readonly type: Schema.Literal<"text">;
432
443
  readonly text: Schema.String;
433
444
  readonly cache: Schema.optional<typeof CacheHint>;
434
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
435
445
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
436
446
  }>, Schema.Struct<{
437
447
  readonly type: Schema.Literal<"media">;
@@ -468,7 +478,25 @@ declare const Message_base: Schema.Class<Message, Schema.Struct<{
468
478
  }>, never, never>;
469
479
  readonly filename: Schema.optional<Schema.String>;
470
480
  readonly cache: Schema.optional<typeof CacheHint>;
471
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
481
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
482
+ }>]>>;
483
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
484
+ }>, {}>;
485
+ export declare class UserMessage extends UserMessage_base {
486
+ }
487
+ declare const AssistantMessage_base: Schema.Class<AssistantMessage, Schema.Struct<{
488
+ readonly id: Schema.optional<Schema.String>;
489
+ readonly role: Schema.Literal<"assistant">;
490
+ readonly content: Schema.$Array<Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
491
+ readonly type: Schema.Literal<"text">;
492
+ readonly text: Schema.String;
493
+ readonly cache: Schema.optional<typeof CacheHint>;
494
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
495
+ }>, Schema.Struct<{
496
+ readonly type: Schema.Literal<"reasoning">;
497
+ readonly text: Schema.String;
498
+ readonly encrypted: Schema.optional<Schema.String>;
499
+ readonly cache: Schema.optional<typeof CacheHint>;
472
500
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
473
501
  }>, Schema.Struct<{
474
502
  readonly type: Schema.Literal<"tool-call">;
@@ -478,7 +506,6 @@ declare const Message_base: Schema.Class<Message, Schema.Struct<{
478
506
  readonly input: Schema.Unknown;
479
507
  readonly providerExecuted: Schema.optional<Schema.Boolean>;
480
508
  readonly cache: Schema.optional<typeof CacheHint>;
481
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
482
509
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
483
510
  }> & {
484
511
  make: (input: Omit<ToolCallPart, "type">) => ToolCallPart;
@@ -533,7 +560,6 @@ declare const Message_base: Schema.Class<Message, Schema.Struct<{
533
560
  };
534
561
  readonly providerExecuted: Schema.optional<Schema.Boolean>;
535
562
  readonly cache: Schema.optional<typeof CacheHint>;
536
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
537
563
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
538
564
  }> & {
539
565
  make: (input: Omit<ToolResultPart, "type" | "result"> & {
@@ -541,11 +567,40 @@ declare const Message_base: Schema.Class<Message, Schema.Struct<{
541
567
  readonly resultType?: ToolResultValue["type"];
542
568
  }) => ToolResultPart;
543
569
  }, Schema.Struct<{
544
- readonly type: Schema.Literal<"reasoning">;
545
- readonly text: Schema.String;
546
- readonly encrypted: Schema.optional<Schema.String>;
570
+ readonly type: Schema.Literal<"media">;
571
+ readonly media: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
572
+ readonly source: Schema.Union<readonly [Schema.Struct<{
573
+ readonly type: Schema.Literal<"bytes">;
574
+ readonly data: Schema.Uint8Array;
575
+ readonly mediaType: Schema.String;
576
+ }>, Schema.Struct<{
577
+ readonly type: Schema.Literal<"base64">;
578
+ readonly data: Schema.String;
579
+ readonly mediaType: Schema.String;
580
+ }>, Schema.Struct<{
581
+ readonly type: Schema.Literal<"url">;
582
+ readonly url: Schema.String;
583
+ readonly mediaType: Schema.optional<Schema.String>;
584
+ readonly expiresAt: Schema.optional<Schema.Number>;
585
+ }>, Schema.Struct<{
586
+ readonly type: Schema.Literal<"ref">;
587
+ readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
588
+ readonly id: Schema.String;
589
+ readonly mediaType: Schema.optional<Schema.String>;
590
+ }>]>;
591
+ readonly info: Schema.optional<Schema.Struct<{
592
+ readonly width: Schema.optional<Schema.Number>;
593
+ readonly height: Schema.optional<Schema.Number>;
594
+ readonly durationSeconds: Schema.optional<Schema.Number>;
595
+ readonly sampleRate: Schema.optional<Schema.Number>;
596
+ readonly channels: Schema.optional<Schema.Number>;
597
+ readonly encoding: Schema.optional<Schema.String>;
598
+ readonly format: Schema.optional<Schema.String>;
599
+ }>>;
600
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
601
+ }>, never, never>;
602
+ readonly filename: Schema.optional<Schema.String>;
547
603
  readonly cache: Schema.optional<typeof CacheHint>;
548
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
549
604
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
550
605
  }>, Schema.refine<{
551
606
  readonly type: "compaction";
@@ -562,42 +617,123 @@ declare const Message_base: Schema.Class<Message, Schema.Struct<{
562
617
  readonly text: Schema.optional<Schema.NullOr<Schema.String>>;
563
618
  }>> & {
564
619
  make: (input: Omit<CompactionPart, "type" | "encrypted" | "text"> & CompactionContent) => CompactionPart;
565
- }, Schema.Struct<{
566
- readonly type: Schema.Literal<"effort">;
567
- readonly effort: Schema.optional<Schema.declare<ReasoningEffort, ReasoningEffort>>;
568
- readonly previous: Schema.optional<Schema.declare<ReasoningEffort, ReasoningEffort>>;
569
- }>]>>;
570
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
620
+ }]>>;
571
621
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
572
- readonly native: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
573
622
  }>, {}>;
574
- export declare class Message extends Message_base {
623
+ export declare class AssistantMessage extends AssistantMessage_base {
575
624
  }
625
+ declare const ToolMessage_base: Schema.Class<ToolMessage, Schema.Struct<{
626
+ readonly id: Schema.optional<Schema.String>;
627
+ readonly role: Schema.Literal<"tool">;
628
+ readonly content: Schema.$Array<Schema.Struct<{
629
+ readonly type: Schema.Literal<"tool-result">;
630
+ readonly id: Schema.String;
631
+ readonly name: Schema.String;
632
+ readonly namespace: Schema.optional<Schema.String>;
633
+ readonly result: Schema.Union<readonly [Schema.Struct<{
634
+ readonly type: Schema.Literal<"json">;
635
+ readonly value: Schema.Unknown;
636
+ }>, Schema.Struct<{
637
+ readonly type: Schema.Literal<"text">;
638
+ readonly value: Schema.Unknown;
639
+ }>, Schema.Struct<{
640
+ readonly type: Schema.Literal<"error">;
641
+ readonly value: Schema.Unknown;
642
+ }>, Schema.Struct<{
643
+ readonly type: Schema.Literal<"content">;
644
+ readonly value: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
645
+ readonly type: Schema.Literal<"text">;
646
+ readonly text: Schema.String;
647
+ }>, Schema.Struct<{
648
+ readonly type: Schema.Literal<"file">;
649
+ readonly uri: Schema.String;
650
+ readonly mime: Schema.String;
651
+ readonly name: Schema.optional<Schema.String>;
652
+ }>]>>;
653
+ }>]> & {
654
+ is: <I>(input: I) => input is I & ({
655
+ readonly type: "json";
656
+ readonly value: unknown;
657
+ } | {
658
+ readonly type: "text";
659
+ readonly value: unknown;
660
+ } | {
661
+ readonly type: "error";
662
+ readonly value: unknown;
663
+ } | {
664
+ readonly type: "content";
665
+ readonly value: readonly ({
666
+ readonly type: "text";
667
+ readonly text: string;
668
+ } | {
669
+ readonly type: "file";
670
+ readonly uri: string;
671
+ readonly mime: string;
672
+ readonly name?: string | undefined;
673
+ })[];
674
+ });
675
+ make: (value: unknown, type?: ToolResultValue["type"]) => ToolResultValue;
676
+ };
677
+ readonly providerExecuted: Schema.optional<Schema.Boolean>;
678
+ readonly cache: Schema.optional<typeof CacheHint>;
679
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
680
+ }> & {
681
+ make: (input: Omit<ToolResultPart, "type" | "result"> & {
682
+ readonly result: unknown;
683
+ readonly resultType?: ToolResultValue["type"];
684
+ }) => ToolResultPart;
685
+ }>;
686
+ }>, {}>;
687
+ export declare class ToolMessage extends ToolMessage_base {
688
+ }
689
+ export type Message = SystemMessage | UserMessage | AssistantMessage | ToolMessage;
690
+ export type ContentPartInput = Exclude<ContentPart, MediaPart> | MediaPartInput;
576
691
  export declare namespace Message {
577
- type ContentInput = string | ContentPart | ReadonlyArray<ContentPart>;
578
- type SystemContentInput = string | TextPart | ReadonlyArray<TextPart>;
579
- type Input = Omit<ConstructorParameters<typeof Message>[0], "content"> & {
580
- readonly content: ContentInput;
692
+ export type ContentInput<Part extends {
693
+ readonly type: string;
694
+ } = ContentPartInput> = string | Part | ReadonlyArray<Part>;
695
+ export type SystemContentInput = ContentInput<TextPart>;
696
+ export type UserContentInput = ContentInput<TextPart | MediaPartInput>;
697
+ export type AssistantContentInput = ContentInput<Exclude<AssistantMessage["content"][number], MediaPart> | MediaPartInput>;
698
+ type RoleInput<Props, Content> = Omit<Props, "content"> & {
699
+ readonly content: Content;
581
700
  };
582
- const text: (value: string) => ContentPart;
583
- const media: (asset: Media.Asset, options?: Omit<MediaPart, "type" | "media">) => MediaPart;
584
- const content: (input: ContentInput) => any[];
585
- const make: (input: Message | Input) => Message;
586
- const user: (content: ContentInput) => Message;
587
- const assistant: (content: ContentInput) => Message;
701
+ export type SystemInput = RoleInput<ConstructorParameters<typeof SystemMessage>[0], ContentInput<SystemMessage["content"][number]>>;
702
+ export type UserInput = RoleInput<ConstructorParameters<typeof UserMessage>[0], UserContentInput>;
703
+ export type AssistantInput = RoleInput<ConstructorParameters<typeof AssistantMessage>[0], AssistantContentInput>;
704
+ export type ToolInput = RoleInput<ConstructorParameters<typeof ToolMessage>[0], ToolResultPart | ReadonlyArray<ToolResultPart>>;
705
+ export type Input = SystemInput | UserInput | AssistantInput | ToolInput;
706
+ export {};
707
+ }
708
+ declare const text: (value: string) => TextPart;
709
+ declare function contentWithMedia(input: Message.UserContentInput): UserMessage["content"];
710
+ declare function contentWithMedia(input: Message.AssistantContentInput): AssistantMessage["content"];
711
+ declare function contentWithMedia(input: Message.ContentInput): ReadonlyArray<ContentPart>;
712
+ declare function make(input: SystemMessage | Message.SystemInput): SystemMessage;
713
+ declare function make(input: UserMessage | Message.UserInput): UserMessage;
714
+ declare function make(input: AssistantMessage | Message.AssistantInput): AssistantMessage;
715
+ declare function make(input: ToolMessage | Message.ToolInput): ToolMessage;
716
+ declare function make(input: Message | Message.Input): Message;
717
+ export declare const Message: Schema.Union<readonly [typeof SystemMessage, typeof UserMessage, typeof AssistantMessage, typeof ToolMessage]> & {
718
+ text: typeof text;
719
+ media: (media: MediaPartInput["media"], options?: Omit<MediaPartInput, "type" | "media">) => MediaPart;
720
+ content: typeof contentWithMedia;
721
+ make: typeof make;
722
+ user: (input: Message.UserContentInput) => UserMessage;
723
+ assistant: (input: Message.AssistantContentInput) => AssistantMessage;
588
724
  /**
589
725
  * Add an operator-authored instruction at this chronological point in the
590
726
  * conversation. This is distinct from the initial `LLMRequest.system`
591
727
  * prompt. Keep raw retrieved, tool, and web content out of privileged system
592
728
  * updates; pass that untrusted content through ordinary user/tool channels.
593
729
  */
594
- const system: (content: SystemContentInput) => Message;
595
- const effort: (input: {
730
+ system: (input: Message.SystemContentInput) => SystemMessage;
731
+ effort: (input: {
596
732
  readonly effort?: ReasoningEffort;
597
733
  readonly previous?: ReasoningEffort;
598
- }) => Message;
599
- const tool: (result: ToolResultPart | Parameters<typeof ToolResultPart.make>[0]) => Message;
600
- }
734
+ }) => SystemMessage;
735
+ tool: (result: ToolResultPart | Parameters<typeof ToolResultPart.make>[0]) => ToolMessage;
736
+ };
601
737
  /**
602
738
  * Raw-text wire encoding for a tool with exactly one required string parameter. Models that accept the format
603
739
  * write that parameter's value directly instead of JSON arguments; calls still decode to the normal object input.
@@ -627,7 +763,6 @@ declare const toolDefinitionFields: {
627
763
  readonly grammar: Schema.String;
628
764
  }>]>>;
629
765
  cache: Schema.optional<typeof CacheHint>;
630
- metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
631
766
  native: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
632
767
  };
633
768
  export type ToolDefinitionInput = Schema.Struct.Type<typeof toolDefinitionFields>;
@@ -646,7 +781,6 @@ declare const ToolDefinition_base: Schema.Class<ToolDefinition, Schema.Struct<{
646
781
  readonly grammar: Schema.String;
647
782
  }>]>>;
648
783
  readonly cache: Schema.optional<typeof CacheHint>;
649
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
650
784
  readonly native: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
651
785
  readonly type: Schema.Literal<"tool">;
652
786
  }>, {}>;
@@ -695,97 +829,20 @@ export declare namespace ToolChoice {
695
829
  /** Normalize ergonomic tool-choice inputs into the canonical `ToolChoice` class. */
696
830
  const make: (input: Input) => ToolChoice;
697
831
  }
698
- declare const requestSchema: Schema.Struct<{
699
- readonly id: Schema.optional<Schema.String>;
700
- readonly model: Schema.declare<LanguageModel<{
701
- readonly [x: string]: unknown;
702
- }, import("../route.js").CompactionOperations | undefined>, LanguageModel<{
703
- readonly [x: string]: unknown;
704
- }, import("../route.js").CompactionOperations | undefined>>;
705
- readonly system: Schema.$Array<Schema.Struct<{
706
- readonly type: Schema.Literal<"text">;
707
- readonly text: Schema.String;
708
- readonly cache: Schema.optional<typeof CacheHint>;
709
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
710
- }> & {
711
- make: typeof makeSystemPart;
712
- content: (input?: string | SystemPart | ReadonlyArray<SystemPart>) => any[];
713
- }>;
714
- readonly messages: Schema.$Array<typeof Message>;
715
- readonly tools: Schema.$Array<Schema.Codec<ToolEntry, ToolEntry, never, never> & {
716
- readonly make: (input: ToolEntryInput) => ToolEntry;
717
- }>;
718
- readonly toolChoice: Schema.optional<typeof ToolChoice>;
719
- readonly generation: Schema.optional<typeof GenerationOptions>;
720
- readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
721
- readonly http: Schema.optional<typeof HttpOptions>;
722
- readonly cache: Schema.optional<Schema.Union<readonly [Schema.Literal<"auto">, Schema.Literal<"none">, Schema.Struct<{
723
- readonly tools: Schema.optional<Schema.Boolean>;
724
- readonly system: Schema.optional<Schema.Boolean>;
725
- readonly messages: Schema.optional<Schema.Union<readonly [Schema.Literal<"latest-user-message">, Schema.Literal<"latest-assistant">, Schema.Struct<{
726
- readonly tail: Schema.Natural;
727
- }>]>>;
728
- readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
729
- }>]>>;
730
- readonly promptCacheKey: Schema.optional<Schema.String>;
731
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
732
- /** Emit a `raw` event with each provider frame before the events parsed from it. */
733
- readonly includeRaw: Schema.optional<Schema.Boolean>;
734
- }>;
735
- declare const LLMRequest_base: Schema.Class<LLMRequest<LanguageModel<{
736
- readonly [x: string]: unknown;
737
- }, import("../route.js").CompactionOperations | undefined>>, Schema.Struct<{
738
- readonly id: Schema.optional<Schema.String>;
739
- readonly model: Schema.declare<LanguageModel<{
740
- readonly [x: string]: unknown;
741
- }, import("../route.js").CompactionOperations | undefined>, LanguageModel<{
742
- readonly [x: string]: unknown;
743
- }, import("../route.js").CompactionOperations | undefined>>;
744
- readonly system: Schema.$Array<Schema.Struct<{
745
- readonly type: Schema.Literal<"text">;
746
- readonly text: Schema.String;
747
- readonly cache: Schema.optional<typeof CacheHint>;
748
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
749
- }> & {
750
- make: typeof makeSystemPart;
751
- content: (input?: string | SystemPart | ReadonlyArray<SystemPart>) => any[];
752
- }>;
753
- readonly messages: Schema.$Array<typeof Message>;
754
- readonly tools: Schema.$Array<Schema.Codec<ToolEntry, ToolEntry, never, never> & {
755
- readonly make: (input: ToolEntryInput) => ToolEntry;
756
- }>;
757
- readonly toolChoice: Schema.optional<typeof ToolChoice>;
758
- readonly generation: Schema.optional<typeof GenerationOptions>;
759
- readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
760
- readonly http: Schema.optional<typeof HttpOptions>;
761
- readonly cache: Schema.optional<Schema.Union<readonly [Schema.Literal<"auto">, Schema.Literal<"none">, Schema.Struct<{
762
- readonly tools: Schema.optional<Schema.Boolean>;
763
- readonly system: Schema.optional<Schema.Boolean>;
764
- readonly messages: Schema.optional<Schema.Union<readonly [Schema.Literal<"latest-user-message">, Schema.Literal<"latest-assistant">, Schema.Struct<{
765
- readonly tail: Schema.Natural;
766
- }>]>>;
767
- readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
768
- }>]>>;
769
- readonly promptCacheKey: Schema.optional<Schema.String>;
770
- readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
832
+ /**
833
+ * A normalized text request, the plain object `ai.request(...)` returns. Edit it with a spread, such as
834
+ * `{ ...request, messages: [...request.messages, next] }`, or pass the edited object back to `ai.request`.
835
+ */
836
+ export interface LLMRequest<Model extends LanguageModel = LanguageModel> extends BaseRequest<Model, LanguageModelProviderOptions<Model>>, GenerationOptionsFields {
837
+ readonly id?: string;
838
+ readonly system: ReadonlyArray<SystemPart>;
839
+ readonly messages: ReadonlyArray<Message>;
840
+ readonly tools: ReadonlyArray<ToolEntry>;
841
+ readonly toolChoice?: ToolChoice;
842
+ readonly cache?: CachePolicy;
843
+ /** Stable cache affinity for protocols that support provider-managed prompt caching. */
844
+ readonly promptCacheKey?: string;
771
845
  /** Emit a `raw` event with each provider frame before the events parsed from it. */
772
- readonly includeRaw: Schema.optional<Schema.Boolean>;
773
- }>, {}>;
774
- export declare class LLMRequest<Model extends LanguageModel = LanguageModel> extends LLMRequest_base {
775
- readonly model: Model;
776
- constructor(input: LLMRequest.Input<Model>);
777
- }
778
- export declare namespace LLMRequest {
779
- type Input<Model extends LanguageModel = LanguageModel> = Omit<typeof requestSchema.Type, "model"> & {
780
- readonly model: Model;
781
- };
782
- const input: <Model extends LanguageModel>(request: LLMRequest<Model>) => Input<Model>;
783
- function update<Model extends LanguageModel>(request: LLMRequest, patch: Partial<Input<Model>> & {
784
- readonly model: Model;
785
- }): LLMRequest<Model>;
786
- function update<Model extends LanguageModel>(request: LLMRequest<Model>, patch: Partial<Omit<Input, "model">> & {
787
- readonly model?: undefined;
788
- }): LLMRequest<Model>;
789
- function update(request: LLMRequest, patch: Partial<Input>): LLMRequest;
846
+ readonly includeRaw?: boolean;
790
847
  }
791
848
  export {};