@opencode/ai 2.2.2 → 2.2.3

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 (51) hide show
  1. package/README.md +92 -76
  2. package/dist/decision.d.ts +0 -1
  3. package/dist/effect.d.ts +2 -14
  4. package/dist/effect.js +1 -10
  5. package/dist/experimental/testing.d.ts +3 -0
  6. package/dist/experimental/testing.js +3 -0
  7. package/dist/experimental.d.ts +12 -0
  8. package/dist/experimental.js +9 -0
  9. package/dist/index.d.ts +340 -336
  10. package/dist/index.js +43 -41
  11. package/dist/llm.d.ts +2 -2
  12. package/dist/llm.js +19 -29
  13. package/dist/protocols/alibaba-responses.d.ts +2 -2
  14. package/dist/protocols/assemblyai-transcription.js +3 -3
  15. package/dist/protocols/meta-responses.d.ts +4 -4
  16. package/dist/protocols/open-responses.d.ts +18 -18
  17. package/dist/protocols/open-responses.js +4 -2
  18. package/dist/protocols/openai-compatible-responses.d.ts +2 -2
  19. package/dist/protocols/openai-responses.d.ts +12 -12
  20. package/dist/protocols/runway-video.js +2 -2
  21. package/dist/protocols/xai-responses.d.ts +2 -2
  22. package/dist/protocols/xai-video.js +2 -2
  23. package/dist/providers/alibaba.d.ts +2 -2
  24. package/dist/providers/amazon-bedrock-mantle.d.ts +2 -2
  25. package/dist/providers/azure.d.ts +4 -4
  26. package/dist/providers/cloudflare-ai-gateway.d.ts +4 -4
  27. package/dist/providers/digitalocean.d.ts +2 -2
  28. package/dist/providers/google-vertex-responses.d.ts +2 -2
  29. package/dist/providers/meta.d.ts +2 -2
  30. package/dist/providers/minimax.d.ts +2 -2
  31. package/dist/providers/moonshot.d.ts +2 -2
  32. package/dist/providers/openai-compatible-responses.d.ts +2 -2
  33. package/dist/providers/openai.d.ts +2 -2
  34. package/dist/providers/openrouter/responses.d.ts +1 -2
  35. package/dist/providers/openrouter.d.ts +36 -23
  36. package/dist/providers/openrouter.js +29 -10
  37. package/dist/providers/venice.d.ts +2 -2
  38. package/dist/providers/zai-coding-plan.d.ts +2 -2
  39. package/dist/route/client.d.ts +3 -0
  40. package/dist/route/client.js +5 -4
  41. package/dist/route/media-protocol.d.ts +2 -3
  42. package/dist/route/media-protocol.js +2 -6
  43. package/dist/schema/errors.d.ts +6 -0
  44. package/dist/schema/errors.js +8 -0
  45. package/dist/schema/events.d.ts +2 -0
  46. package/dist/schema/events.js +4 -0
  47. package/dist/testing.d.ts +1 -4
  48. package/dist/testing.js +4 -12
  49. package/dist/tool.d.ts +40 -73
  50. package/dist/tool.js +27 -18
  51. package/package.json +7 -3
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # @opencode/ai
2
2
 
3
- Schema-first APIs for text, images, video, speech, transcription, and decisions, built with Effect.
3
+ Schema-first APIs for text, images, and decisions, built with Effect. Video, speech, transcription, extraction, and
4
+ realtime voice are [experimental](#experimental).
4
5
 
5
6
  `@opencode/ai` is the Promise API: one managed runtime behind the LLM and media methods, plus asset helpers. `ai.file`
6
7
  and `ai.write` load `node:fs/promises` on first use, so no Effect `FileSystem` is needed:
@@ -55,16 +56,16 @@ Anthropic Messages, Gemini, Bedrock Converse, and any OpenAI-compatible deployme
55
56
  `stream` runs one model call; `loop` runs the model's tool calls and calls the model again until it stops calling
56
57
  tools. Events from every step arrive on one stream, with a `tool-result` after each tool runs. `until` is checked
57
58
  after each step that has tool calls, with every step's `LLMResponse`; returning `true` ends the loop without running
58
- them. `AI.tool` takes a plain `async` execute; a throw or rejection goes back to the model as an error result, and
59
+ them. `tool` takes a plain `async` execute; a throw or rejection goes back to the model as an error result, and
59
60
  `signal` aborts when the loop is interrupted.
60
- `Tool.make` from `@opencode/ai/effect` is the Effect form, with a validated `success` schema:
61
+ `tool` from `@opencode/ai/effect` takes the same options (including an optional `success` schema) with an Effect execute:
61
62
 
62
63
  ```ts
63
64
  import { readFile } from "node:fs/promises"
64
65
  import { Schema } from "effect"
65
- import { AI } from "@opencode/ai"
66
+ import { tool } from "@opencode/ai"
66
67
 
67
- const read_file = AI.tool({
68
+ const read_file = tool({
68
69
  description: "Read a UTF-8 file.",
69
70
  parameters: Schema.Struct({ path: Schema.String }),
70
71
  execute: ({ path }, { signal }) => readFile(path, { encoding: "utf8", signal }),
@@ -87,7 +88,7 @@ A tool with exactly one required string parameter can set `freeform`, so the mod
87
88
  instead of JSON arguments: unconstrained `text`, or text matching a `regex` or `lark` grammar.
88
89
 
89
90
  ```ts
90
- const run_code = AI.tool({
91
+ const run_code = tool({
91
92
  description: "Run JavaScript",
92
93
  parameters: Schema.Struct({ code: Schema.String }),
93
94
  freeform: { type: "lark", grammar: JS_GRAMMAR },
@@ -165,8 +166,8 @@ Raw usage is preserved in `usage.providerMetadata.google`. `inputTokens` follows
165
166
  `contextTokens` uses its full `raw_prompt_token` count when supplied. These can differ substantially with server-side
166
167
  continuation. Explicit caches, hosted tools, and generated media are not supported by this initial protocol.
167
168
 
168
- The same configured facade names image, video, speech, and transcription models. `Image.generate` resolves the
169
- provider's image route from the model and returns `Media.Asset`s with lazily decoded bytes:
169
+ The same configured facade names image models (and the experimental video, speech, and transcription models).
170
+ `Image.generate` resolves the provider's image route from the model and returns `Media.Asset`s with lazily decoded bytes:
170
171
 
171
172
  ```ts
172
173
  import { NodeFileSystem } from "@effect/platform-node"
@@ -309,38 +310,6 @@ CloudflareAIGateway.configure({ accountId }).decision("typesafe/jev")
309
310
  OpenAI and Vercel AI Gateway use OpenAI's `/v1/decisions` API. TypeSafe, OpenCode, OpenRouter, Baseten and
310
311
  DigitalOcean use System One (`/systemone`), and Cloudflare sends the System One body through `/ai/run`.
311
312
 
312
- ### Extraction (experimental)
313
-
314
- Extraction models read typed values out of text instead of answering questions with probabilities. A field of type
315
- `text`, `number`, `date`, `time`, `datetime`, `duration`, `list`, `estimate` or `forecast` gets an answer typed to
316
- match; other types are sent and answered as-is. Only Cloudflare's Clairic serves it today, so it lives under
317
- `@opencode/ai/experimental`.
318
-
319
- ```ts
320
- import { ai } from "@opencode/ai"
321
- import { Extraction } from "@opencode/ai/experimental"
322
- import { CloudflareWorkersAI } from "@opencode/ai/providers"
323
-
324
- const response = await ai.run(
325
- Extraction.generate({
326
- model: CloudflareWorkersAI.configure({ accountId }).experimental.extraction("@cf/cloudflare/clairic"),
327
- input: "Invoice INV-2291, issued 2026-09-02, net 30. Total $1,080.00. Contact: Dana Ruiz, Priya Shah.",
328
- fields: {
329
- invoiceNumber: { type: "text" },
330
- dueDate: { type: "date", instructions: "Issue date plus the net payment days" },
331
- total: { type: "number", decimals: 2, unit: "USD" },
332
- contacts: { type: "list", items: "text" },
333
- },
334
- }),
335
- )
336
- response.answers.total.value // 1080, or null when the input does not say
337
- ```
338
-
339
- Value answers carry `guess`, `nullProbability` and `confidence`; text answers carry a `span` into `input`. Estimates and
340
- forecasts return `median`, `p10` and `p90`. Field options other than `type`, `instructions` and `nullThreshold` go to
341
- Clairic as written. Effect users provide `RequestExecutor.fetchLayer` (or `AIClient.layer`). Images are not supported
342
- yet.
343
-
344
313
  ## Alibaba Cloud Model Studio
345
314
 
346
315
  `Alibaba` provides standard Model Studio inference. Configure a region explicitly, then select
@@ -910,7 +879,42 @@ const program = Effect.gen(function* () {
910
879
 
911
880
  The hosted result is represented as a provider-executed tool call and a tool result whose content carries the generated image as a file. Gemini image-capable models instead emit a first-class `media` `LLMEvent` for inline image output (`response.message` then carries a `media` part). Retaining `response.message` preserves the generated image for continuation on both routes.
912
881
 
913
- ## Video generation
882
+ ## Public API
883
+
884
+ Everything below is exported from `@opencode/ai/effect` unless noted.
885
+
886
+ - **`LLM.request({...})`** — build a provider-neutral `LLMRequest`. Accepts ergonomic inputs (`system: string`, `prompt: string`) that normalize into the canonical Schema classes.
887
+ - **`LLM.generate` / `LLM.stream`** — run direct input or an `LLMRequest` through `LLMClient` for one-import use.
888
+ - **`LLM.loop`** — stream model calls, running `tool(...)` tools between them until the model stops calling tools.
889
+ - **`Message.user(...)` / `Message.assistant(...)` / `Message.tool(...)`** — message constructors from the canonical schema model.
890
+ - **`LanguageModel.make(...)` / `ToolCallPart.make(...)` / `ToolResultPart.make(...)` / `ToolDefinition.make(...)`** — model and tool-related constructors from the canonical schema model.
891
+ - **`LLMEvent.is.*`** — typed guards (`is.textDelta`, `is.toolCall`, `is.finish`, …) for filtering streams.
892
+ - **`Image.request` / `generate` / `stream` / `start` / `resume`** — images over inline, streaming (partial previews), and queued routes through a provider-neutral request and response model.
893
+ - **`ImageClient`** — Effect service and layer for image execution, parallel to `LLMClient`.
894
+ - **`Media`** — the shared asset type (`Media.Asset`, `Media.Source`) and constructors used by messages, tool results, and media requests.
895
+ - **`Generation`** — provider-neutral handle for an in-flight media generation (`await`, `refresh`, `cancel`, `events`) used by queued media routes.
896
+ - **`Decision.request` / `Decision.generate`** — typed predicate, choice, and score questions over text, JSON, and media input; `DecisionClient` is its Effect service and layer.
897
+ - **`AIClient.layer` / `AIClient.layerWith(executor)`** — every modality client plus the request executor in one layer.
898
+ - **`@opencode/ai`** (Promise root) — `AI.make({ layer?, clients? })` and a default `ai` client exposing `llm`, `image`, and `decision` (plus `experimental.video`, `experimental.speech`, and `experimental.transcription`) as Promise / `AsyncIterable` APIs, `run(effect)` for any package Effect, plus `file`, `write`, `bytes`, `base64`, and `materialize` for assets.
899
+ - **`@opencode/ai/experimental`** — APIs that may change without compatibility guarantees: `Video`, `Speech`, `Transcription`, `Extraction`, and `Realtime`. See [Experimental](#experimental).
900
+
901
+ ## Experimental
902
+
903
+ These APIs may change without compatibility guarantees. The Effect API is exported from `@opencode/ai/experimental`,
904
+ the Promise client exposes it under `ai.experimental`, and test layers come from `@opencode/ai/experimental/testing`.
905
+
906
+ - **`Video`**, **`Speech`**, and **`Transcription`** — media generation and speech-to-text, with `VideoClient`,
907
+ `SpeechClient`, and `TranscriptionClient` as their Effect services. Promise: `ai.experimental.video`, `.speech`, and
908
+ `.transcription`. Testing: `TestVideo`, `TestSpeech`, and `TestTranscription`.
909
+ - **`Extraction`** — typed values read out of text.
910
+ - **`Realtime`** — `Realtime.connect` starts an OpenAI, xAI, or Gemini voice session and returns a WebRTC answer SDP or
911
+ a short-lived WebSocket URL and token.
912
+
913
+ The provider selectors for these modalities (`.video(...)`, `.speech(...)`, `.transcription(...)`,
914
+ `.experimental.extraction(...)`) and their protocol entrypoints (such as `@opencode/ai/protocols/openai-speech`) are
915
+ part of the same experimental surface.
916
+
917
+ ### Video generation
914
918
 
915
919
  Video mirrors `Image` with one difference: every provider is asynchronous, so the route is a submit-then-poll
916
920
  `Generation`. Models come from `.video(...)` selectors on the `Google` (Veo), `XAI`, and `Runway` facades.
@@ -919,7 +923,7 @@ Common fields (`frames`, `references`, `video`, `durationSeconds`, `aspect`, `re
919
923
  under `providerOptions`, inferred from the selected model.
920
924
 
921
925
  ```ts
922
- import { Video } from "@opencode/ai/effect"
926
+ import { Video } from "@opencode/ai/experimental"
923
927
  import { Google, Runway } from "@opencode/ai/providers"
924
928
 
925
929
  const google = Google.configure({ apiKey: process.env.GOOGLE_GENERATIVE_AI_API_KEY })
@@ -981,9 +985,9 @@ Provider notes:
981
985
  - **Runway** expects pixel ratios in `aspect` for most models (`"1280:720"`), pins `X-Runway-Version`, reports
982
986
  `usage: { type: "credits" }`, and its output URLs expire after 24–48 hours.
983
987
 
984
- The promise client exposes the same surface: `ai.video.start(...)` resolves to a handle with `await`, `events`,
985
- `result`, `refresh`, `cancel`, and `token`; `ai.video.generate`, `ai.video.resume(model, token)`, and
986
- `ai.video.stream` mirror the Effect API. The handle's `status` and `progress` are a snapshot from when it was
988
+ The promise client exposes the same surface: `ai.experimental.video.start(...)` resolves to a handle with `await`, `events`,
989
+ `result`, `refresh`, `cancel`, and `token`; `ai.experimental.video.generate`, `ai.experimental.video.resume(model, token)`, and
990
+ `ai.experimental.video.stream` mirror the Effect API. The handle's `status` and `progress` are a snapshot from when it was
987
991
  created; `refresh()` resolves to a new handle. Every promise method and stream accepts `{ signal }`: like `fetch`,
988
992
  aborting rejects the Promise or throws from the `for await` loop with `signal.reason` (an `AbortError` `DOMException`
989
993
  unless `abort(reason)` passed one), while `break` stops a stream without throwing.
@@ -991,13 +995,13 @@ unless `abort(reason)` passed one), while `break` stops a stream without throwin
991
995
  ```ts
992
996
  import { ai } from "@opencode/ai"
993
997
 
994
- const generation = await ai.video.start({ model, prompt })
998
+ const generation = await ai.experimental.video.start({ model, prompt })
995
999
  for await (const event of generation.events({ poll: { interval: 10_000 } })) console.log(event.type)
996
1000
  const video = await generation.result({ signal })
997
1001
  await ai.write(video.video, "./kite.mp4")
998
1002
  ```
999
1003
 
1000
- ## Speech generation
1004
+ ### Speech generation
1001
1005
 
1002
1006
  Speech (text-to-speech) is one request whose response is parsed incrementally, so every route supports both
1003
1007
  `Speech.generate` (the whole file) and `Speech.stream` (audio chunks as they arrive). Models come from `.speech(...)`
@@ -1006,7 +1010,8 @@ selectors on the `OpenAI`, `Google` (Gemini TTS), `ElevenLabs`, `Cartesia`, and
1006
1010
  before any network call; provider-native controls live under `providerOptions`, inferred from the selected model.
1007
1011
 
1008
1012
  ```ts
1009
- import { Media, Speech, SpeechClient, SpeechEvent } from "@opencode/ai/effect"
1013
+ import { Media } from "@opencode/ai/effect"
1014
+ import { Speech, SpeechEvent } from "@opencode/ai/experimental"
1010
1015
  import { ElevenLabs, OpenAI } from "@opencode/ai/providers"
1011
1016
 
1012
1017
  const openai = OpenAI.configure({ apiKey: process.env.OPENAI_API_KEY })
@@ -1068,20 +1073,20 @@ Provider notes:
1068
1073
  and `providerOptions` lower to query parameters (`encoding`, `container`, `sample_rate`, `bit_rate`); `pcm` is
1069
1074
  `linear16` without a container. Auth is `Authorization: Token <DEEPGRAM_API_KEY>`.
1070
1075
 
1071
- The promise client mirrors the Effect API; `ai.speech.stream` is an `AsyncIterable`.
1076
+ The promise client mirrors the Effect API; `ai.experimental.speech.stream` is an `AsyncIterable`.
1072
1077
 
1073
1078
  ```ts
1074
1079
  import { ai } from "@opencode/ai"
1075
1080
 
1076
- const response = await ai.speech.generate({ model, text: "Hello from OpenCode.", voice: "coral" })
1081
+ const response = await ai.experimental.speech.generate({ model, text: "Hello from OpenCode.", voice: "coral" })
1077
1082
  await ai.write(response.audio, "hello.mp3")
1078
1083
 
1079
- for await (const event of ai.speech.stream({ model, text: "Hello from OpenCode.", voice: "coral" })) {
1084
+ for await (const event of ai.experimental.speech.stream({ model, text: "Hello from OpenCode.", voice: "coral" })) {
1080
1085
  if (event.type === "audio-delta") player.write(event.chunk)
1081
1086
  }
1082
1087
  ```
1083
1088
 
1084
- ## Transcription
1089
+ ### Transcription
1085
1090
 
1086
1091
  Transcription (speech-to-text) is the one modality whose providers use every route kind: OpenAI and Gemini stream,
1087
1092
  Deepgram and ElevenLabs answer inline, and AssemblyAI is queued. `Transcription.generate` and `Transcription.stream`
@@ -1093,7 +1098,8 @@ any network call; a route may return more than asked.
1093
1098
 
1094
1099
  ```ts
1095
1100
  import { Console, Effect, Stream } from "effect"
1096
- import { Media, Transcription, TranscriptionEvent } from "@opencode/ai/effect"
1101
+ import { Media } from "@opencode/ai/effect"
1102
+ import { Transcription, TranscriptionEvent } from "@opencode/ai/experimental"
1097
1103
  import { AssemblyAI, Deepgram, OpenAI } from "@opencode/ai/providers"
1098
1104
 
1099
1105
  const openai = OpenAI.configure({ apiKey: process.env.OPENAI_API_KEY })
@@ -1146,33 +1152,43 @@ The promise client mirrors the Effect API:
1146
1152
 
1147
1153
  ```ts
1148
1154
  const audio = await ai.file("./call.mp3")
1149
- const text = (await ai.transcription.generate({ model, audio })).text
1150
- for await (const event of ai.transcription.stream({ model, audio })) if (event.type === "text-delta") write(event.delta)
1151
- const generation = await ai.transcription.start({ model: assemblyai, audio })
1155
+ const text = (await ai.experimental.transcription.generate({ model, audio })).text
1156
+ for await (const event of ai.experimental.transcription.stream({ model, audio }))
1157
+ if (event.type === "text-delta") write(event.delta)
1158
+ const generation = await ai.experimental.transcription.start({ model: assemblyai, audio })
1152
1159
  const transcript = await generation.await({ poll: { interval: 3_000 } })
1153
1160
  ```
1154
1161
 
1155
- ## Public API
1162
+ ### Extraction
1156
1163
 
1157
- Everything below is exported from `@opencode/ai/effect` unless noted.
1164
+ Extraction models read typed values out of text instead of answering questions with probabilities. A field of type
1165
+ `text`, `number`, `date`, `time`, `datetime`, `duration`, `list`, `estimate` or `forecast` gets an answer typed to
1166
+ match; other types are sent and answered as-is. Only Cloudflare's Clairic serves it today.
1158
1167
 
1159
- - **`LLM.request({...})`** — build a provider-neutral `LLMRequest`. Accepts ergonomic inputs (`system: string`, `prompt: string`) that normalize into the canonical Schema classes.
1160
- - **`LLM.generate` / `LLM.stream`** — run direct input or an `LLMRequest` through `LLMClient` for one-import use.
1161
- - **`LLM.loop`** — stream model calls, running `Tool.make(...)` tools between them until the model stops calling tools.
1162
- - **`Message.user(...)` / `Message.assistant(...)` / `Message.tool(...)`** — message constructors from the canonical schema model.
1163
- - **`LanguageModel.make(...)` / `ToolCallPart.make(...)` / `ToolResultPart.make(...)` / `ToolDefinition.make(...)`** — model and tool-related constructors from the canonical schema model.
1164
- - **`LLMEvent.is.*`** — typed guards (`is.textDelta`, `is.toolCall`, `is.finish`, …) for filtering streams.
1165
- - **`Image.request` / `generate` / `stream` / `start` / `resume`** — images over inline, streaming (partial previews), and queued routes through a provider-neutral request and response model.
1166
- - **`ImageClient`** — Effect service and layer for image execution, parallel to `LLMClient`.
1167
- - **`Media`** — the shared asset type (`Media.Asset`, `Media.Source`) and constructors used by messages, tool results, and media requests.
1168
- - **`Generation`** — provider-neutral handle for an in-flight media generation (`await`, `refresh`, `cancel`, `events`) used by queued media routes.
1169
- - **`Video.request` / `generate` / `stream` / `start` / `resume`** — queued video generation through a provider-neutral request; `VideoClient` is its Effect service and layer.
1170
- - **`Speech.request` / `Speech.generate` / `Speech.stream`** — text-to-speech through a provider-neutral request; `SpeechClient` is its Effect service and layer.
1171
- - **`Transcription.request` / `generate` / `stream` / `start` / `resume`** — speech-to-text over inline, streaming, and queued routes; `TranscriptionClient` is its Effect service and layer.
1172
- - **`Decision.request` / `Decision.generate`** — typed predicate, choice, and score questions over text, JSON, and media input; `DecisionClient` is its Effect service and layer.
1173
- - **`AIClient.layer` / `AIClient.layerWith(executor)`** — every modality client plus the request executor in one layer.
1174
- - **`@opencode/ai`** (Promise root) — `AI.make({ layer?, clients? })` and a default `ai` client exposing `llm`, `image`, `video`, `speech`, `transcription`, and `decision` as Promise / `AsyncIterable` APIs, `run(effect)` for any package Effect, plus `file`, `write`, `bytes`, `base64`, and `materialize` for assets.
1175
- - **`@opencode/ai/experimental`** — APIs that may still change: `Extraction` (typed values read out of text) and `Realtime` (`Realtime.connect` starts an OpenAI, xAI, or Gemini voice session and returns a WebRTC answer SDP or a short-lived WebSocket URL and token).
1168
+ ```ts
1169
+ import { ai } from "@opencode/ai"
1170
+ import { Extraction } from "@opencode/ai/experimental"
1171
+ import { CloudflareWorkersAI } from "@opencode/ai/providers"
1172
+
1173
+ const response = await ai.run(
1174
+ Extraction.generate({
1175
+ model: CloudflareWorkersAI.configure({ accountId }).experimental.extraction("@cf/cloudflare/clairic"),
1176
+ input: "Invoice INV-2291, issued 2026-09-02, net 30. Total $1,080.00. Contact: Dana Ruiz, Priya Shah.",
1177
+ fields: {
1178
+ invoiceNumber: { type: "text" },
1179
+ dueDate: { type: "date", instructions: "Issue date plus the net payment days" },
1180
+ total: { type: "number", decimals: 2, unit: "USD" },
1181
+ contacts: { type: "list", items: "text" },
1182
+ },
1183
+ }),
1184
+ )
1185
+ response.answers.total.value // 1080, or null when the input does not say
1186
+ ```
1187
+
1188
+ Value answers carry `guess`, `nullProbability` and `confidence`; text answers carry a `span` into `input`. Estimates and
1189
+ forecasts return `median`, `p10` and `p90`. Field options other than `type`, `instructions` and `nullThreshold` go to
1190
+ Clairic as written. Effect users provide `RequestExecutor.fetchLayer` (or `AIClient.layer`). Images are not supported
1191
+ yet.
1176
1192
 
1177
1193
  ## Testing
1178
1194
 
@@ -1218,7 +1234,7 @@ For explicit compaction, script a `CompactionResponse` through `push`, `always`,
1218
1234
 
1219
1235
  For `compact(request, { mechanism: "trigger" })`, script a `CompactionCheckpointResponse` instead. It carries `checkpoint`, `responseID`, and optional `usage`. Endpoint and trigger calls reject each other's fixtures; both share the same queue, gates, lazy recording, and fallback controls.
1220
1236
 
1221
- `TestImage`, `TestVideo`, `TestSpeech`, `TestTranscription`, and `TestDecision` follow the same pattern: `testLayer()` provides the modality's client and `Test`, with the same `push`, `always`, `serve`, `requests`, `wait`, and `gate` controls. Script an `ImageResponse` (or the modality's response) or an `AIError`. `stream` expands the response into its events, and `start` returns an already finished generation that `resume` accepts by token. Decision responses are returned as scripted, without checking the answers against the questions.
1237
+ `TestImage` and `TestDecision` (and `TestVideo`, `TestSpeech`, and `TestTranscription` from `@opencode/ai/experimental/testing`) follow the same pattern: `testLayer()` provides the modality's client and `Test`, with the same `push`, `always`, `serve`, `requests`, `wait`, and `gate` controls. Script an `ImageResponse` (or the modality's response) or an `AIError`. `stream` expands the response into its events, and `start` returns an already finished generation that `resume` accepts by token. Decision responses are returned as scripted, without checking the answers against the questions.
1222
1238
 
1223
1239
  The Promise client accepts the same layers as `AI.make({ clients: TestImage.testLayer() })`; `ai.run(TestImage.Test.use(...))` reaches the controls.
1224
1240
 
@@ -464,7 +464,6 @@ export declare function request<const Model extends DecisionModel, const Questio
464
464
  export declare function request(input: DecisionRequest): DecisionRequest;
465
465
  export declare function request(input: DecisionRequest | DecisionRequestInput): DecisionRequest;
466
466
  export declare function generate<const Model extends DecisionModel, const Questions extends DecisionQuestions>(input: DecisionRequestInput<Model, Questions>): Effect.Effect<DecisionResponseFor<Questions>, AIError, Service>;
467
- export declare function generate(input: DecisionRequest): Effect.Effect<DecisionResponse, AIError, Service>;
468
467
  export declare const Decision: {
469
468
  readonly request: typeof request;
470
469
  readonly generate: typeof generate;
package/dist/effect.d.ts CHANGED
@@ -10,18 +10,6 @@ export type { GenerationOptionsFields, GenerationOptionsInput, LanguageModelInpu
10
10
  export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageRequest, ImageResponse } from "./image.js";
11
11
  export type { ImageModelOptions, ImageOptions, ImageRequestFor, ImageRequestInput, ImageResolution, ImageRoute, } from "./image.js";
12
12
  export { Image } from "./image.js";
13
- export { VideoClient } from "./video-client.js";
14
- export { VideoAspectRatio, VideoEvent, VideoFrames, VideoModel, VideoModelSchema, VideoRequest, VideoResponse, } from "./video.js";
15
- export type { VideoModelOptions, VideoOptions, VideoRequestFor, VideoRequestInput, VideoResolution, VideoRoute, } from "./video.js";
16
- export { Video } from "./video.js";
17
- export { SpeechClient } from "./speech-client.js";
18
- export { SpeechEvent, SpeechModel, SpeechModelSchema, SpeechRequest, SpeechResponse, SpeechTimestamp, SpeechVoice, } from "./speech.js";
19
- export type { SpeechFormat, SpeechModelOptions, SpeechOptions, SpeechRequestFor, SpeechRequestInput, SpeechRoute, } from "./speech.js";
20
- export { Speech } from "./speech.js";
21
- export { TranscriptionClient } from "./transcription-client.js";
22
- export { TranscriptionEvent, TranscriptionModel, TranscriptionModelSchema, TranscriptionRequest, TranscriptionResponse, TranscriptionSegment, TranscriptionTimestamps, TranscriptionWord, } from "./transcription.js";
23
- export type { TranscriptionModelOptions, TranscriptionOptions, TranscriptionRequestFor, TranscriptionRequestInput, TranscriptionRoute, } from "./transcription.js";
24
- export { Transcription } from "./transcription.js";
25
13
  export { DecisionClient } from "./decision-client.js";
26
14
  export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionRequest, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
27
15
  export type { AnswerFor, AnswersFor, DecisionInput, DecisionModelOptions, DecisionOptions, DecisionQuestions, DecisionRequestFor, DecisionRequestInput, DecisionResponseFor, DecisionModelRoute, } from "./decision.js";
@@ -30,9 +18,9 @@ export { DecisionRoute } from "./route/decision.js";
30
18
  export { Media } from "./media.js";
31
19
  export { Generation } from "./generation.js";
32
20
  export type { AwaitOptions as GenerationAwaitOptions, Event as GenerationEvent, Poll, Route as GenerationRoute, Snapshot as GenerationSnapshot, Status as GenerationStatus, } from "./generation.js";
33
- export { Tool, ToolFailure, emptyInputJsonSchema, toDefinitions } from "./tool.js";
21
+ export { ToolFailure, emptyInputJsonSchema, toDefinitions, tool } from "./tool.js";
34
22
  export { ToolRuntime } from "./tool-runtime.js";
35
23
  export type { DispatchResult as ToolDispatchResult, ToolSettlement } from "./tool-runtime.js";
36
- export type { AnyExecutableTool, AnyTool, ExecutableTool, ExecutableTools, Definition as ToolShape, ToolExecute, ToolExecuteContext, ToolModelOutputInput, Tools, ToolSchema, ToolToModelOutput, } from "./tool.js";
24
+ export type { ExecutableTool, Tool, ToolExecute, ToolExecuteContext, ToolModelOutputInput, ToolOptions, Tools, ToolSchema, ToolToModelOutput, } from "./tool.js";
37
25
  export * as LLM from "./llm.js";
38
26
  export type { Definition as ProviderPackageDefinition, Settings as ProviderPackageSettings, } from "./provider-package.js";
package/dist/effect.js CHANGED
@@ -7,21 +7,12 @@ export { isContextOverflow, isContextOverflowFailure, isRetryable } from "./prov
7
7
  export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, HttpOptions, GenerationOptions, LanguageModelDefaults, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, LLMRequest, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, ToolError, FinishReasonDetails, StepFinish, Finish, MediaEvent, ProviderErrorEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, NoRouteError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
8
8
  export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageRequest, ImageResponse } from "./image.js";
9
9
  export { Image } from "./image.js";
10
- export { VideoClient } from "./video-client.js";
11
- export { VideoAspectRatio, VideoEvent, VideoFrames, VideoModel, VideoModelSchema, VideoRequest, VideoResponse, } from "./video.js";
12
- export { Video } from "./video.js";
13
- export { SpeechClient } from "./speech-client.js";
14
- export { SpeechEvent, SpeechModel, SpeechModelSchema, SpeechRequest, SpeechResponse, SpeechTimestamp, SpeechVoice, } from "./speech.js";
15
- export { Speech } from "./speech.js";
16
- export { TranscriptionClient } from "./transcription-client.js";
17
- export { TranscriptionEvent, TranscriptionModel, TranscriptionModelSchema, TranscriptionRequest, TranscriptionResponse, TranscriptionSegment, TranscriptionTimestamps, TranscriptionWord, } from "./transcription.js";
18
- export { Transcription } from "./transcription.js";
19
10
  export { DecisionClient } from "./decision-client.js";
20
11
  export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionRequest, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
21
12
  export { Decision } from "./decision.js";
22
13
  export { DecisionRoute } from "./route/decision.js";
23
14
  export { Media } from "./media.js";
24
15
  export { Generation } from "./generation.js";
25
- export { Tool, ToolFailure, emptyInputJsonSchema, toDefinitions } from "./tool.js";
16
+ export { ToolFailure, emptyInputJsonSchema, toDefinitions, tool } from "./tool.js";
26
17
  export { ToolRuntime } from "./tool-runtime.js";
27
18
  export * as LLM from "./llm.js";
@@ -0,0 +1,3 @@
1
+ export { TestSpeech } from "../testing/speech.js";
2
+ export { TestTranscription } from "../testing/transcription.js";
3
+ export { TestVideo } from "../testing/video.js";
@@ -0,0 +1,3 @@
1
+ export { TestSpeech } from "../testing/speech.js";
2
+ export { TestTranscription } from "../testing/transcription.js";
3
+ export { TestVideo } from "../testing/video.js";
@@ -1,3 +1,15 @@
1
+ export { VideoClient } from "./video-client.js";
2
+ export { VideoAspectRatio, VideoEvent, VideoFrames, VideoModel, VideoModelSchema, VideoRequest, VideoResponse, } from "./video.js";
3
+ export type { VideoModelOptions, VideoOptions, VideoRequestFor, VideoRequestInput, VideoResolution, VideoRoute, } from "./video.js";
4
+ export { Video } from "./video.js";
5
+ export { SpeechClient } from "./speech-client.js";
6
+ export { SpeechEvent, SpeechModel, SpeechModelSchema, SpeechRequest, SpeechResponse, SpeechTimestamp, SpeechVoice, } from "./speech.js";
7
+ export type { SpeechFormat, SpeechModelOptions, SpeechOptions, SpeechRequestFor, SpeechRequestInput, SpeechRoute, } from "./speech.js";
8
+ export { Speech } from "./speech.js";
9
+ export { TranscriptionClient } from "./transcription-client.js";
10
+ export { TranscriptionEvent, TranscriptionModel, TranscriptionModelSchema, TranscriptionRequest, TranscriptionResponse, TranscriptionSegment, TranscriptionTimestamps, TranscriptionWord, } from "./transcription.js";
11
+ export type { TranscriptionModelOptions, TranscriptionOptions, TranscriptionRequestFor, TranscriptionRequestInput, TranscriptionRoute, } from "./transcription.js";
12
+ export { Transcription } from "./transcription.js";
1
13
  export { Extraction, ExtractionModel, ExtractionRequest, ExtractionResponse } from "./experimental/extraction.js";
2
14
  export type { ExtractionAnswerFor, ExtractionAnswersFor, ExtractionField, ExtractionFields, ExtractionModelOptions, ExtractionOptions, ExtractionRequestFor, ExtractionRequestInput, ExtractionResponseFor, ExtractionRoute, } from "./experimental/extraction.js";
3
15
  export { Realtime } from "./experimental/realtime.js";
@@ -1,2 +1,11 @@
1
+ export { VideoClient } from "./video-client.js";
2
+ export { VideoAspectRatio, VideoEvent, VideoFrames, VideoModel, VideoModelSchema, VideoRequest, VideoResponse, } from "./video.js";
3
+ export { Video } from "./video.js";
4
+ export { SpeechClient } from "./speech-client.js";
5
+ export { SpeechEvent, SpeechModel, SpeechModelSchema, SpeechRequest, SpeechResponse, SpeechTimestamp, SpeechVoice, } from "./speech.js";
6
+ export { Speech } from "./speech.js";
7
+ export { TranscriptionClient } from "./transcription-client.js";
8
+ export { TranscriptionEvent, TranscriptionModel, TranscriptionModelSchema, TranscriptionRequest, TranscriptionResponse, TranscriptionSegment, TranscriptionTimestamps, TranscriptionWord, } from "./transcription.js";
9
+ export { Transcription } from "./transcription.js";
1
10
  export { Extraction, ExtractionModel, ExtractionRequest, ExtractionResponse } from "./experimental/extraction.js";
2
11
  export { Realtime } from "./experimental/realtime.js";