@opencode/ai 2.2.4 → 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.
- package/README.md +133 -69
- package/dist/cache-policy.d.ts +1 -1
- package/dist/cache-policy.js +16 -4
- package/dist/decision-client.d.ts +3 -3
- package/dist/decision.d.ts +20 -125
- package/dist/decision.js +25 -15
- package/dist/effect.d.ts +4 -15
- package/dist/effect.js +2 -6
- package/dist/effort-updates.d.ts +3 -3
- package/dist/effort-updates.js +2 -2
- package/dist/experimental/cloudflare-run-extraction.d.ts +7 -3
- package/dist/experimental/cloudflare-run-extraction.js +4 -1
- package/dist/experimental/extraction.d.ts +10 -40
- package/dist/experimental/extraction.js +14 -13
- package/dist/experimental.d.ts +8 -8
- package/dist/experimental.js +4 -4
- package/dist/generation.d.ts +0 -2
- package/dist/generation.js +2 -2
- package/dist/image-client.d.ts +13 -7
- package/dist/image-client.js +1 -1
- package/dist/image.d.ts +357 -464
- package/dist/image.js +17 -15
- package/dist/index.d.ts +28 -465
- package/dist/index.js +18 -17
- package/dist/llm.d.ts +65 -266
- package/dist/llm.js +101 -92
- package/dist/loop.d.ts +38 -0
- package/dist/loop.js +136 -0
- package/dist/media-model.d.ts +1 -1
- package/dist/media-model.js +8 -6
- package/dist/media.d.ts +9 -0
- package/dist/media.js +37 -2
- package/dist/protocols/alibaba-chat.d.ts +5 -1
- package/dist/protocols/alibaba-chat.js +3 -3
- package/dist/protocols/alibaba-images.d.ts +2 -2
- package/dist/protocols/alibaba-messages.js +3 -3
- package/dist/protocols/alibaba-responses.js +8 -20
- package/dist/protocols/anthropic-messages.d.ts +1 -1
- package/dist/protocols/anthropic-messages.js +57 -185
- package/dist/protocols/assemblyai-transcription.d.ts +2 -2
- package/dist/protocols/bedrock-converse.js +11 -22
- package/dist/protocols/cartesia-speech.d.ts +2 -2
- package/dist/protocols/cloudflare-workers-ai-images.d.ts +2 -2
- package/dist/protocols/cohere-chat.js +9 -12
- package/dist/protocols/deepgram-speech.d.ts +2 -2
- package/dist/protocols/deepgram-transcription.d.ts +2 -2
- package/dist/protocols/elevenlabs-speech.d.ts +2 -2
- package/dist/protocols/elevenlabs-transcription.d.ts +2 -2
- package/dist/protocols/gemini.d.ts +3 -0
- package/dist/protocols/gemini.js +56 -89
- package/dist/protocols/google-images.d.ts +2 -2
- package/dist/protocols/google-interactions.d.ts +3 -4
- package/dist/protocols/google-interactions.js +54 -32
- package/dist/protocols/google-speech.d.ts +2 -2
- package/dist/protocols/google-transcription.d.ts +2 -2
- package/dist/protocols/google-video.d.ts +2 -2
- package/dist/protocols/meta-images.d.ts +2 -2
- package/dist/protocols/meta-responses.js +26 -23
- package/dist/protocols/minimax-images.d.ts +2 -2
- package/dist/protocols/mistral-chat.js +14 -20
- package/dist/protocols/open-responses-channel.js +6 -19
- package/dist/protocols/open-responses-continuation.d.ts +1 -5
- package/dist/protocols/open-responses-continuation.js +1 -3
- package/dist/protocols/open-responses.d.ts +1 -21
- package/dist/protocols/open-responses.js +10 -15
- package/dist/protocols/openai-chat.d.ts +3 -23
- package/dist/protocols/openai-chat.js +26 -47
- package/dist/protocols/openai-compatible-chat.d.ts +1 -1
- package/dist/protocols/openai-compatible-responses.d.ts +2 -2
- package/dist/protocols/openai-compatible-responses.js +1 -1
- package/dist/protocols/openai-decisions.js +1 -1
- package/dist/protocols/openai-images.d.ts +2 -2
- package/dist/protocols/openai-responses.js +10 -29
- package/dist/protocols/openai-speech.d.ts +2 -2
- package/dist/protocols/openai-transcription.d.ts +2 -2
- package/dist/protocols/runway-video.d.ts +2 -2
- package/dist/protocols/shared.d.ts +1 -4
- package/dist/protocols/shared.js +13 -11
- package/dist/protocols/system-one.d.ts +4 -4
- package/dist/protocols/utils/bedrock-cache.js +2 -5
- package/dist/protocols/utils/bedrock-media.d.ts +0 -3
- package/dist/protocols/utils/cache.d.ts +3 -0
- package/dist/protocols/utils/cache.js +15 -2
- package/dist/protocols/utils/image-sizing.d.ts +1 -1
- package/dist/protocols/utils/responses-checkpoint.js +1 -1
- package/dist/protocols/utils/responses-compaction.d.ts +1 -1
- package/dist/protocols/utils/responses-compaction.js +6 -5
- package/dist/protocols/utils/responses-hosted-tools.d.ts +97 -1
- package/dist/protocols/utils/responses-hosted-tools.js +31 -0
- package/dist/protocols/utils/tool-stream.d.ts +5 -271
- package/dist/protocols/utils/tool-stream.js +3 -13
- package/dist/protocols/venice-chat.d.ts +3 -1
- package/dist/protocols/venice-chat.js +4 -4
- package/dist/protocols/xai-images.d.ts +2 -2
- package/dist/protocols/xai-responses.js +5 -25
- package/dist/protocols/xai-video.d.ts +2 -2
- package/dist/protocols/zai-chat.d.ts +5 -1
- package/dist/protocols/zai-chat.js +1 -1
- package/dist/protocols/zai-images.d.ts +2 -2
- package/dist/protocols/zai-messages.js +3 -3
- package/dist/provider-error.d.ts +0 -1
- package/dist/provider-error.js +9 -80
- package/dist/providers/alibaba.d.ts +67 -4
- package/dist/providers/alibaba.js +6 -1
- package/dist/providers/amazon-bedrock-mantle.d.ts +6 -3
- package/dist/providers/amazon-bedrock-mantle.js +6 -3
- package/dist/providers/amazon-bedrock.d.ts +6 -7
- package/dist/providers/amazon-bedrock.js +1 -1
- package/dist/providers/anthropic-compatible.d.ts +7 -8
- package/dist/providers/anthropic-compatible.js +2 -5
- package/dist/providers/anthropic.d.ts +8 -9
- package/dist/providers/anthropic.js +2 -7
- package/dist/providers/assemblyai.d.ts +2 -2
- package/dist/providers/assemblyai.js +2 -7
- package/dist/providers/azure/messages.d.ts +2 -0
- package/dist/providers/azure/messages.js +1 -0
- package/dist/providers/azure.d.ts +322 -7
- package/dist/providers/azure.js +25 -9
- package/dist/providers/baseten.d.ts +5 -5
- package/dist/providers/baseten.js +7 -21
- package/dist/providers/cartesia.d.ts +1 -1
- package/dist/providers/cerebras.d.ts +5 -5
- package/dist/providers/cerebras.js +4 -15
- package/dist/providers/cloudflare-ai-gateway.d.ts +21 -13
- package/dist/providers/cloudflare-ai-gateway.js +28 -40
- package/dist/providers/cloudflare-shared.d.ts +9 -0
- package/dist/providers/cloudflare-shared.js +25 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +4 -4
- package/dist/providers/cloudflare-workers-ai.js +4 -20
- package/dist/providers/cohere/chat.js +2 -7
- package/dist/providers/cohere.d.ts +6 -5
- package/dist/providers/cohere.js +7 -13
- package/dist/providers/deepgram.d.ts +2 -2
- package/dist/providers/deepgram.js +2 -7
- package/dist/providers/deepinfra.d.ts +5 -5
- package/dist/providers/deepinfra.js +5 -13
- package/dist/providers/deepseek.d.ts +5 -5
- package/dist/providers/deepseek.js +3 -14
- package/dist/providers/digitalocean.d.ts +8 -5
- package/dist/providers/digitalocean.js +13 -14
- package/dist/providers/elevenlabs.d.ts +2 -2
- package/dist/providers/elevenlabs.js +2 -7
- package/dist/providers/fireworks.d.ts +5 -5
- package/dist/providers/fireworks.js +4 -15
- package/dist/providers/google/interactions.d.ts +1 -1
- package/dist/providers/google/interactions.js +2 -7
- package/dist/providers/google-vertex-chat.d.ts +3 -3
- package/dist/providers/google-vertex-chat.js +3 -29
- package/dist/providers/google-vertex-interactions.d.ts +3 -3
- package/dist/providers/google-vertex-messages.d.ts +3 -3
- package/dist/providers/google-vertex-messages.js +3 -29
- package/dist/providers/google-vertex-mistral.d.ts +3 -3
- package/dist/providers/google-vertex-mistral.js +3 -29
- package/dist/providers/google-vertex-responses.d.ts +3 -3
- package/dist/providers/google-vertex-responses.js +4 -30
- package/dist/providers/google-vertex-shared.d.ts +31 -0
- package/dist/providers/google-vertex-shared.js +25 -0
- package/dist/providers/google-vertex.d.ts +3 -3
- package/dist/providers/google.d.ts +15 -13
- package/dist/providers/google.js +9 -19
- package/dist/providers/groq.d.ts +5 -5
- package/dist/providers/groq.js +4 -15
- package/dist/providers/meta.d.ts +5 -5
- package/dist/providers/meta.js +10 -24
- package/dist/providers/minimax/chat.js +2 -7
- package/dist/providers/minimax/responses.js +2 -7
- package/dist/providers/minimax.d.ts +5 -5
- package/dist/providers/minimax.js +11 -23
- package/dist/providers/mistral.d.ts +10 -11
- package/dist/providers/mistral.js +3 -14
- package/dist/providers/moonshot/messages.js +2 -7
- package/dist/providers/moonshot/responses.js +2 -7
- package/dist/providers/moonshot.d.ts +5 -5
- package/dist/providers/moonshot.js +4 -16
- package/dist/providers/openai-compatible-responses.d.ts +6 -7
- package/dist/providers/openai-compatible-responses.js +2 -8
- package/dist/providers/openai-compatible.d.ts +6 -7
- package/dist/providers/openai-compatible.js +4 -10
- package/dist/providers/openai.d.ts +4 -4
- package/dist/providers/openai.js +3 -3
- package/dist/providers/opencode.d.ts +4 -4
- package/dist/providers/opencode.js +6 -2
- package/dist/providers/openrouter.d.ts +8 -5
- package/dist/providers/openrouter.js +16 -24
- package/dist/providers/runway.d.ts +1 -1
- package/dist/providers/settings.d.ts +40 -0
- package/dist/providers/settings.js +19 -0
- package/dist/providers/togetherai.d.ts +5 -5
- package/dist/providers/togetherai.js +5 -15
- package/dist/providers/typesafe-ai.d.ts +4 -4
- package/dist/providers/typesafe-ai.js +6 -2
- package/dist/providers/venice.d.ts +4 -4
- package/dist/providers/venice.js +6 -2
- package/dist/providers/vercel-ai-gateway.d.ts +5 -5
- package/dist/providers/vercel-ai-gateway.js +15 -28
- package/dist/providers/xai.d.ts +4 -4
- package/dist/providers/xai.js +4 -12
- package/dist/providers/zai-coding-plan/messages.js +2 -7
- package/dist/providers/zai-coding-plan/responses.js +2 -7
- package/dist/providers/zai-coding-plan.d.ts +5 -5
- package/dist/providers/zai-coding-plan.js +8 -15
- package/dist/providers/zai.d.ts +5 -5
- package/dist/providers/zai.js +10 -22
- package/dist/public.d.ts +12 -0
- package/dist/public.js +5 -0
- package/dist/route/auth-options.d.ts +9 -5
- package/dist/route/auth-options.js +10 -7
- package/dist/route/client.d.ts +50 -37
- package/dist/route/client.js +42 -53
- package/dist/route/decision.d.ts +8 -8
- package/dist/route/decision.js +3 -3
- package/dist/route/executor.d.ts +5 -0
- package/dist/route/executor.js +10 -0
- package/dist/route/index.d.ts +5 -7
- package/dist/route/index.js +1 -1
- package/dist/route/media.d.ts +7 -11
- package/dist/route/media.js +22 -26
- package/dist/route/transport/http.js +6 -5
- package/dist/route/transport/websocket.js +7 -1
- package/dist/schema/errors.d.ts +16 -17
- package/dist/schema/errors.js +63 -12
- package/dist/schema/events.d.ts +2563 -2954
- package/dist/schema/events.js +54 -109
- package/dist/schema/messages.d.ts +194 -137
- package/dist/schema/messages.js +66 -83
- package/dist/schema/options.d.ts +112 -65
- package/dist/schema/options.js +52 -101
- package/dist/speech-client.d.ts +7 -7
- package/dist/speech.d.ts +306 -316
- package/dist/speech.js +16 -14
- package/dist/testing.d.ts +31 -175
- package/dist/testing.js +60 -5
- package/dist/tool-history.d.ts +1 -1
- package/dist/tool-history.js +3 -10
- package/dist/tool-runtime.d.ts +9 -2
- package/dist/tool-runtime.js +17 -31
- package/dist/tool.d.ts +39 -43
- package/dist/tool.js +16 -26
- package/dist/transcription-client.d.ts +7 -7
- package/dist/transcription.d.ts +314 -265
- package/dist/transcription.js +16 -14
- package/dist/utils/provider-codes.d.ts +3 -0
- package/dist/utils/provider-codes.js +41 -0
- package/dist/video-client.d.ts +7 -7
- package/dist/video-client.js +1 -1
- package/dist/video.d.ts +269 -287
- package/dist/video.js +16 -14
- package/package.json +9 -9
- package/dist/experimental/testing.d.ts +0 -3
- package/dist/experimental/testing.js +0 -3
- package/dist/testing/decision.d.ts +0 -16
- package/dist/testing/decision.js +0 -20
- package/dist/testing/image.d.ts +0 -14
- package/dist/testing/image.js +0 -12
- package/dist/testing/media.d.ts +0 -18
- package/dist/testing/media.js +0 -36
- package/dist/testing/script.d.ts +0 -28
- package/dist/testing/script.js +0 -60
- package/dist/testing/speech.d.ts +0 -14
- package/dist/testing/speech.js +0 -12
- package/dist/testing/transcription.d.ts +0 -14
- package/dist/testing/transcription.js +0 -12
- package/dist/testing/video.d.ts +0 -14
- package/dist/testing/video.js +0 -12
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ const program = Effect.gen(function* () {
|
|
|
37
37
|
model: openai.responses("gpt-4o-mini"), // `.chat(...)` selects the Chat Completions API instead
|
|
38
38
|
system: "You are concise.",
|
|
39
39
|
prompt: "Say hello in one short sentence.",
|
|
40
|
-
|
|
40
|
+
maxTokens: 40,
|
|
41
41
|
})
|
|
42
42
|
console.log(response.text)
|
|
43
43
|
})
|
|
@@ -47,17 +47,26 @@ await Effect.runPromise(program.pipe(Effect.provide(AIClient.layer)))
|
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
Run `ai.stream(...)` instead of `generate` when you want incremental `LLMEvent`s. Both accept input or a prebuilt
|
|
50
|
-
`ai.request(...)`.
|
|
50
|
+
`ai.request(...)`. Input takes either `prompt`, a single user message, or `messages`, the whole conversation, never
|
|
51
|
+
both; `system` goes with either. The event stream is provider-neutral — same shape across OpenAI Chat, OpenAI Responses,
|
|
51
52
|
Anthropic Messages, Gemini, Bedrock Converse, and any OpenAI-compatible deployment.
|
|
52
53
|
|
|
53
54
|
### Tool loop
|
|
54
55
|
|
|
55
56
|
`stream` runs one model call; `loop` runs the model's tool calls and calls the model again until it stops calling
|
|
56
|
-
tools. Events from every step arrive on one stream, with a `tool-result` after each tool runs
|
|
57
|
+
tools. Events from every step arrive on one stream, with a `tool-result` after each tool runs (an error result when
|
|
58
|
+
it fails). Each step ends with its own `step-finish`; one `finish` ends the loop, carrying the final step's reason
|
|
59
|
+
and the usage summed across steps. `until` is checked
|
|
57
60
|
after each step that has tool calls, with every step's `LLMResponse`; returning `true` ends the loop without running
|
|
58
|
-
them.
|
|
59
|
-
`
|
|
60
|
-
|
|
61
|
+
them. Tools are an array, sent in the order given so the provider can reuse its cached prompt prefix. Each tool has a
|
|
62
|
+
`name`, and two tools with the same name fail the request. Tool arguments that are not valid JSON go back to the model
|
|
63
|
+
as an error result so it can retry. A step that hits the output token limit ends the loop without running its tool
|
|
64
|
+
calls, which may be cut off. A forced `toolChoice` applies to the first step only; later steps use `auto`. `tool` takes
|
|
65
|
+
a plain `async` execute; a throw or rejection goes back to the model as an error result, and `signal` aborts when the
|
|
66
|
+
loop is interrupted.
|
|
67
|
+
`input` is an Effect Schema that decodes and types the arguments, or a raw JSON Schema object, such as an MCP tool's,
|
|
68
|
+
whose arguments arrive as `unknown` (pair it with an optional JSON Schema `outputSchema`). `tool` from
|
|
69
|
+
`@opencode/ai/effect` takes the same options (including an optional `success` schema) with an Effect execute:
|
|
61
70
|
|
|
62
71
|
```ts
|
|
63
72
|
import { readFile } from "node:fs/promises"
|
|
@@ -65,15 +74,16 @@ import { Schema } from "effect"
|
|
|
65
74
|
import { ai, tool } from "@opencode/ai"
|
|
66
75
|
|
|
67
76
|
const read_file = tool({
|
|
77
|
+
name: "read_file",
|
|
68
78
|
description: "Read a UTF-8 file.",
|
|
69
|
-
|
|
79
|
+
input: Schema.Struct({ path: Schema.String }),
|
|
70
80
|
execute: ({ path }, { signal }) => readFile(path, { encoding: "utf8", signal }),
|
|
71
81
|
})
|
|
72
82
|
|
|
73
83
|
const events = ai.loop({
|
|
74
84
|
model,
|
|
75
85
|
prompt: "Summarize package.json.",
|
|
76
|
-
tools:
|
|
86
|
+
tools: [read_file],
|
|
77
87
|
until: ({ steps }) => steps.length >= 8,
|
|
78
88
|
})
|
|
79
89
|
for await (const event of events) {
|
|
@@ -81,6 +91,17 @@ for await (const event of events) {
|
|
|
81
91
|
}
|
|
82
92
|
```
|
|
83
93
|
|
|
94
|
+
The terminal `finish` carries the final assistant `message` and `usage`. To skip the events, `ai.collect` folds a
|
|
95
|
+
stream from `stream` or `loop` into one result: `text` of the final step, `steps` (one `LLMResponse` per call),
|
|
96
|
+
`messages` (each step's assistant message and its tool results, ready to append to the next request), the total
|
|
97
|
+
`usage`, `finishReason`, and `object` with `schema`.
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
const result = await ai.collect(ai.loop({ model, prompt: "Summarize package.json.", tools: { read_file } }))
|
|
101
|
+
// Effect: const result = yield* ai.collect(ai.loop({ ... }))
|
|
102
|
+
console.log(result.text, result.usage?.totalTokens)
|
|
103
|
+
```
|
|
104
|
+
|
|
84
105
|
### Freeform tools
|
|
85
106
|
|
|
86
107
|
A tool with exactly one required string parameter can set `freeform`, so the model writes that parameter as raw text
|
|
@@ -88,8 +109,9 @@ instead of JSON arguments: unconstrained `text`, or text matching a `regex` or `
|
|
|
88
109
|
|
|
89
110
|
```ts
|
|
90
111
|
const run_code = tool({
|
|
112
|
+
name: "run_code",
|
|
91
113
|
description: "Run JavaScript",
|
|
92
|
-
|
|
114
|
+
input: Schema.Struct({ code: Schema.String }),
|
|
93
115
|
freeform: { type: "lark", grammar: JS_GRAMMAR },
|
|
94
116
|
execute: ({ code }) => runCode(code),
|
|
95
117
|
})
|
|
@@ -104,35 +126,57 @@ history works with or without `freeform`.
|
|
|
104
126
|
|
|
105
127
|
### Structured output
|
|
106
128
|
|
|
107
|
-
`
|
|
108
|
-
unvalidated `unknown` object:
|
|
129
|
+
Pass `schema` to `generate`, `stream` or `loop`. The model must answer through a hidden tool call, decoded into
|
|
130
|
+
`object` (typed from an Effect Schema, or an unvalidated `unknown` for a raw JSON Schema object):
|
|
109
131
|
|
|
110
132
|
```ts
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
133
|
+
const res = await ai.generate({ model, prompt: "Pick a city.", schema: Schema.Struct({ city: Schema.String }) })
|
|
134
|
+
res.object.city
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`stream` puts `object` on its `finish` event; `loop` runs tools first and puts it on the loop's `finish`. A
|
|
138
|
+
decode failure is an `AIError` whose `partial` holds the response.
|
|
139
|
+
|
|
140
|
+
### Errors
|
|
141
|
+
|
|
142
|
+
Every failure is an `AIError`. `reason._tag` names the kind (`RateLimit`, `InvalidRequest`, `Transport`, ...), and
|
|
143
|
+
getters read the common fields without digging into `reason` or the raw body:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
try {
|
|
147
|
+
await ai.generate({ model, prompt: "Hi" })
|
|
148
|
+
} catch (error) {
|
|
149
|
+
if (!(error instanceof AIError)) throw error
|
|
150
|
+
error.status // HTTP status, when the failure came from a response
|
|
151
|
+
error.code // provider error code such as "model_not_found", when known
|
|
152
|
+
error.isRetryable // whether sending the same request again may succeed
|
|
153
|
+
error.retryAfterMs // delay the provider asked for, when known
|
|
154
|
+
}
|
|
116
155
|
```
|
|
117
156
|
|
|
118
157
|
### Raw provider events
|
|
119
158
|
|
|
120
159
|
Set `includeRaw: true` on a request to also receive every provider frame as `{ type: "raw", data }`, in order and
|
|
121
160
|
before the events parsed from that frame. `data` is the parsed JSON frame, so frames this package doesn't handle yet
|
|
122
|
-
are visible too. Raw events are off by default, and `generate` ignores them.
|
|
161
|
+
are visible too. Raw events are off by default, and `generate` ignores them. `RawEvent` is the event's type. Act on a
|
|
162
|
+
frame with a stream map:
|
|
123
163
|
|
|
124
164
|
```ts
|
|
125
|
-
import { Stream } from "effect"
|
|
126
|
-
import { ai,
|
|
165
|
+
import { Effect, Stream } from "effect"
|
|
166
|
+
import { ai, AIError, ContentPolicyError } from "@opencode/ai/effect"
|
|
127
167
|
|
|
128
168
|
const flagged = (data: unknown) =>
|
|
129
169
|
typeof data === "object" && data !== null && "type" in data && data.type === "moderation.flagged"
|
|
130
170
|
|
|
131
|
-
const events = ai
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
)
|
|
171
|
+
const events = ai
|
|
172
|
+
.stream({ model, prompt: "Say hello.", includeRaw: true })
|
|
173
|
+
.pipe(
|
|
174
|
+
Stream.mapEffect((event) =>
|
|
175
|
+
event.type === "raw" && flagged(event.data)
|
|
176
|
+
? Effect.fail(new AIError({ reason: new ContentPolicyError({ message: "Flagged by moderation" }) }))
|
|
177
|
+
: Effect.succeed(event),
|
|
178
|
+
),
|
|
179
|
+
)
|
|
136
180
|
```
|
|
137
181
|
|
|
138
182
|
### Google Interactions
|
|
@@ -147,11 +191,13 @@ live under `providerMetadata.vertex`. The default is still full-history replay w
|
|
|
147
191
|
|
|
148
192
|
```ts
|
|
149
193
|
const model = Google.configure({ apiKey }).interactions("gemini-3.8-flash")
|
|
150
|
-
const response =
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
194
|
+
const response =
|
|
195
|
+
yield *
|
|
196
|
+
ai.generate({
|
|
197
|
+
model,
|
|
198
|
+
prompt: "Say hello.",
|
|
199
|
+
providerOptions: { thinkingLevel: "low", thinkingSummaries: "auto", store: true },
|
|
200
|
+
})
|
|
155
201
|
```
|
|
156
202
|
|
|
157
203
|
Interactions supports text output, streamed function calls, native tool results, thought signatures, and multimodal
|
|
@@ -363,7 +409,7 @@ shared host; the entry above follows the base URL table. Dedicated hosts can be
|
|
|
363
409
|
Replay complete `response.message` values to retain `reasoning_content` separately from answer text.
|
|
364
410
|
Qwen 3.8 defaults to preserving thinking; older models have different defaults.
|
|
365
411
|
Additional options include `toolStream`, `parallelToolCalls`, `repetitionPenalty`, `responseFormat`,
|
|
366
|
-
`enableSearch`, and native `searchOptions`. `
|
|
412
|
+
`enableSearch`, and native `searchOptions`. `topK` lowers to `top_k`.
|
|
367
413
|
`clearThinking` is a hosted GLM control, and `thinking.type` is available for hosted MiniMax models.
|
|
368
414
|
- **Messages:** `effort` → `output_config.effort`. `thinking.type` accepts enabled/disabled with an
|
|
369
415
|
optional `budgetTokens` (or native `budget_tokens`). `outputConfig.format` accepts a JSON schema.
|
|
@@ -532,7 +578,7 @@ const request = ai.request({
|
|
|
532
578
|
model: minimax.model("MiniMax-M3"), // also minimax.messages("MiniMax-M3")
|
|
533
579
|
prompt: "What is 173 multiplied by 219?",
|
|
534
580
|
providerOptions: { thinking: { type: "adaptive" } },
|
|
535
|
-
|
|
581
|
+
maxTokens: 1536,
|
|
536
582
|
})
|
|
537
583
|
|
|
538
584
|
const response = await Effect.runPromise(ai.generate(request).pipe(Effect.provide(AIClient.layer)))
|
|
@@ -570,7 +616,7 @@ const request = ai.request({
|
|
|
570
616
|
model: meta.responses("muse-spark-1.3"), // meta.model(...) also selects Responses
|
|
571
617
|
prompt: "What is 173 multiplied by 219? Reply with the integer.",
|
|
572
618
|
providerOptions: { reasoningEffort: "low" },
|
|
573
|
-
|
|
619
|
+
maxTokens: 1024,
|
|
574
620
|
})
|
|
575
621
|
```
|
|
576
622
|
|
|
@@ -592,7 +638,7 @@ Responses and Chat support only `toolChoice: "auto"` (the default). Messages als
|
|
|
592
638
|
its documented forced `"any"` choice currently returns HTTP 400. Messages defaults to adaptive thinking
|
|
593
639
|
with `display: "omitted"`, preserving encrypted `redacted_thinking` in `response.message`. Use
|
|
594
640
|
`providerOptions: { effort: "low" }` for depth or `thinking: { type: "enabled", budgetTokens: 1024 }`
|
|
595
|
-
for budget compatibility (with `
|
|
641
|
+
for budget compatibility (with `maxTokens > 1024`).
|
|
596
642
|
|
|
597
643
|
Add `tools: [Meta.webSearch()]` to a Spark Responses or Messages request for hosted web search.
|
|
598
644
|
Responses exposes hosted results and URL citations in text-part `providerMetadata.meta.annotations`.
|
|
@@ -666,18 +712,18 @@ Common fields are portable in shape, not in support. Some routes approximate `as
|
|
|
666
712
|
size they offer; others fail with a typed `AIError` before any network call rather than dropping them, so check this
|
|
667
713
|
table before swapping only the `model`:
|
|
668
714
|
|
|
669
|
-
| Provider | `n` | `aspect`
|
|
670
|
-
| --------------------- | --- |
|
|
671
|
-
| OpenAI | ✓¹ | nearest size
|
|
672
|
-
| Google (Gemini) | 1 | ✓
|
|
673
|
-
| xAI | ✓ | ✓
|
|
674
|
-
| Meta | ✓ | ✓ (hint)
|
|
675
|
-
| Z.ai | ✗ | width × height
|
|
676
|
-
| Alibaba | ✓ | width × height
|
|
677
|
-
| MiniMax | ✓ | preset or w × h⁴
|
|
678
|
-
| Vercel AI Gateway | ✓ | as OpenAI³
|
|
679
|
-
| OpenRouter | ✓ | ✓ (`aspect_ratio`)
|
|
680
|
-
| Cloudflare Workers AI | 1 | width × height²
|
|
715
|
+
| Provider | `n` | `aspect` | `resolution` | `images` | Moved to `providerOptions` |
|
|
716
|
+
| --------------------- | --- | ------------------ | ------------------- | -------------------- | ----------------------------------------- |
|
|
717
|
+
| OpenAI | ✓¹ | nearest size | nearest size | ✓ | `size`, `outputFormat`, `mask` |
|
|
718
|
+
| Google (Gemini) | 1 | ✓ | ✓ (`0.5K` as `512`) | ✓ (no public URLs) | `seed` |
|
|
719
|
+
| xAI | ✓ | ✓ | `1k`/`2k` | ✓ | none |
|
|
720
|
+
| Meta | ✓ | ✓ (hint) | ignored | ✓ | `size`, `outputFormat` |
|
|
721
|
+
| Z.ai | ✗ | width × height | width × height | ✗ | `size` |
|
|
722
|
+
| Alibaba | ✓ | width × height | width × height | ✓ | `size`, `seed` |
|
|
723
|
+
| MiniMax | ✓ | preset or w × h⁴ | preset or w × h⁴ | 1 (portrait subject) | `aspect_ratio`, `width`, `height`, `seed` |
|
|
724
|
+
| Vercel AI Gateway | ✓ | as OpenAI³ | as OpenAI³ | per model | as OpenAI |
|
|
725
|
+
| OpenRouter | ✓ | ✓ (`aspect_ratio`) | tier⁵ | per model⁵ | `size`, `outputFormat` (no `mask`) |
|
|
726
|
+
| Cloudflare Workers AI | 1 | width × height² | width × height² | ✗ | `width`, `height`, `seed` |
|
|
681
727
|
|
|
682
728
|
✓ lowers natively; ✗ fails whenever the field is set (including `n: 1`); `1` means `n > 1` fails. "width × height"
|
|
683
729
|
computes a size the provider accepts and fails when the request falls outside its limits. ¹ `ai.image.stream` on OpenAI
|
|
@@ -698,6 +744,20 @@ edits endpoint, so input images go to `/images/generations` as `input_references
|
|
|
698
744
|
asset into owned bytes before the provider URL expires. Construct assets with `Media.bytes`, `Media.base64`,
|
|
699
745
|
`Media.url`, `Media.ref(provider, id)`, `Media.fromDataUrl`, or `Media.file(path)`.
|
|
700
746
|
|
|
747
|
+
File inputs (message `media` parts, image `images`, decision `media` parts) also take plain data: a `Uint8Array`,
|
|
748
|
+
`ArrayBuffer`, `URL`, or a string holding a data URL, an http(s) URL or base64. Bytes and base64 are sniffed from
|
|
749
|
+
magic bytes; pass `mediaType` when that fails:
|
|
750
|
+
|
|
751
|
+
```ts
|
|
752
|
+
ai.request({
|
|
753
|
+
model,
|
|
754
|
+
prompt: [
|
|
755
|
+
{ type: "text", text: "Summarize this report" },
|
|
756
|
+
{ type: "media", media: pdfBase64, mediaType: "application/pdf" },
|
|
757
|
+
],
|
|
758
|
+
})
|
|
759
|
+
```
|
|
760
|
+
|
|
701
761
|
Pass ordered image inputs to the same method for editing, composition, or image-conditioned generation:
|
|
702
762
|
|
|
703
763
|
```ts
|
|
@@ -719,8 +779,8 @@ const composed = Effect.gen(function* () {
|
|
|
719
779
|
|
|
720
780
|
`Media.ref(provider, id)` represents provider file handles such as OpenAI file IDs or Gemini Files URIs; routes
|
|
721
781
|
only forward refs that belong to their own provider (OpenAI, xAI, and Gemini images accept them). No shipped route
|
|
722
|
-
returns a ref yet, and `asset.bytes()` / `materialize()` on a ref fail by design.
|
|
723
|
-
|
|
782
|
+
returns a ref yet, and `asset.bytes()` / `materialize()` on a ref fail by design. Empty or omitted `images` uses
|
|
783
|
+
text-to-image generation; a
|
|
724
784
|
non-empty array selects the provider's edit behavior (see the table above for routes that limit the count). OpenAI
|
|
725
785
|
uses multipart for byte/data-URL edits and its JSON reference body for URL or file-ID edits. Inpainting is a
|
|
726
786
|
provider option on the routes that support it (OpenAI):
|
|
@@ -848,11 +908,13 @@ and emits `image-partial` events before each final `image`; `ai.image.generate`
|
|
|
848
908
|
import { Stream } from "effect"
|
|
849
909
|
import { ImageEvent } from "@opencode/ai/effect"
|
|
850
910
|
|
|
851
|
-
const previews = ai.image
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
911
|
+
const previews = ai.image
|
|
912
|
+
.stream({
|
|
913
|
+
model: openai.image("gpt-image-2"),
|
|
914
|
+
prompt: "A lighthouse at dusk",
|
|
915
|
+
providerOptions: { partialImages: 2 },
|
|
916
|
+
})
|
|
917
|
+
.pipe(Stream.runForEach((event) => (ImageEvent.is.imagePartial(event) ? showPreview(event.image) : Effect.void)))
|
|
856
918
|
```
|
|
857
919
|
|
|
858
920
|
The provider may send fewer previews than requested when the final image is ready first.
|
|
@@ -882,9 +944,10 @@ The hosted result is represented as a provider-executed tool call and a tool res
|
|
|
882
944
|
|
|
883
945
|
Everything below is exported from `@opencode/ai/effect` unless noted.
|
|
884
946
|
|
|
885
|
-
- **`ai.request({...})`** — build a provider-neutral `LLMRequest
|
|
947
|
+
- **`ai.request({...})`** — build a provider-neutral `LLMRequest`, a plain object. Accepts ergonomic inputs (`system: string`, `prompt: string`) and normalizes them into `system`, `messages` and `tools` arrays. Edit it with a spread, or pass the edited object back to `ai.request`.
|
|
886
948
|
- **`ai.generate` / `ai.stream`** — run direct input or an `LLMRequest` through `LLMClient` for one-import use.
|
|
887
949
|
- **`ai.loop`** — stream model calls, running `tool(...)` tools between them until the model stops calling tools.
|
|
950
|
+
- **`ai.collect`** — fold a stream from `ai.stream` or `ai.loop` into its final result (`text`, `steps`, `messages`, `usage`).
|
|
888
951
|
- **`Message.user(...)` / `Message.assistant(...)` / `Message.tool(...)`** — message constructors from the canonical schema model.
|
|
889
952
|
- **`LanguageModel.make(...)` / `ToolCallPart.make(...)` / `ToolResultPart.make(...)` / `ToolDefinition.make(...)`** — model and tool-related constructors from the canonical schema model.
|
|
890
953
|
- **`LLMEvent.is.*`** — typed guards (`is.textDelta`, `is.toolCall`, `is.finish`, …) for filtering streams.
|
|
@@ -894,17 +957,17 @@ Everything below is exported from `@opencode/ai/effect` unless noted.
|
|
|
894
957
|
- **`Generation`** — provider-neutral handle for an in-flight media generation (`await`, `refresh`, `cancel`, `events`) used by queued media routes.
|
|
895
958
|
- **`ai.decision.request` / `ai.decision.generate`** — typed predicate, choice, and score questions over text, JSON, and media input; `DecisionClient` is its Effect service and layer.
|
|
896
959
|
- **`AIClient.layer` / `AIClient.layerWith(executor)`** — every modality client plus the request executor in one layer.
|
|
897
|
-
- **`@opencode/ai`** (Promise root) — a default `ai` with the text calls (`request`, `generate`, `stream`, `loop`, `
|
|
960
|
+
- **`@opencode/ai`** (Promise root) — a default `ai` with the text calls (`request`, `generate`, `stream`, `loop`, `compact`, `canCompact`) at the top level plus `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. `AI.make({ layer? })` builds a client over a custom executor. The same `ai` from `@opencode/ai/effect` returns `Effect` and `Stream`.
|
|
898
961
|
- **`@opencode/ai/experimental`** — APIs that may change without compatibility guarantees: `Video`, `Speech`, `Transcription`, `Extraction`, and `Realtime`. See [Experimental](#experimental).
|
|
899
962
|
|
|
900
963
|
## Experimental
|
|
901
964
|
|
|
902
965
|
These APIs may change without compatibility guarantees. The Effect API is exported from `@opencode/ai/experimental`,
|
|
903
|
-
the Promise client exposes it under `ai.experimental
|
|
966
|
+
and the Promise client exposes it under `ai.experimental`.
|
|
904
967
|
|
|
905
968
|
- **`Video`**, **`Speech`**, and **`Transcription`** — media generation and speech-to-text, with `VideoClient`,
|
|
906
969
|
`SpeechClient`, and `TranscriptionClient` as their Effect services. Promise: `ai.experimental.video`, `.speech`, and
|
|
907
|
-
`.transcription`.
|
|
970
|
+
`.transcription`.
|
|
908
971
|
- **`Extraction`** — typed values read out of text.
|
|
909
972
|
- **`Realtime`** — `Realtime.connect` starts an OpenAI, xAI, or Gemini voice session and returns a WebRTC answer SDP or
|
|
910
973
|
a short-lived WebSocket URL and token.
|
|
@@ -1233,13 +1296,16 @@ For explicit compaction, script a `CompactionResponse` through `push`, `always`,
|
|
|
1233
1296
|
|
|
1234
1297
|
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.
|
|
1235
1298
|
|
|
1236
|
-
|
|
1299
|
+
Response helpers build common event arrays: `TestLLM.text(value, id)`, `textWithUsage(value, id, inputTokens)`,
|
|
1300
|
+
`toolCall(id, name, input)`, `stop(...events)`, `toolCalls(...events)`, and
|
|
1301
|
+
`complete({ reason, usage?, providerMetadata? }, ...events)`. `failAfter(error, ...events)` and `hangAfter(...events)`
|
|
1302
|
+
return streams that fail or never finish after the given events.
|
|
1237
1303
|
|
|
1238
|
-
|
|
1304
|
+
`compileRequest`, also from `@opencode/ai/testing`, compiles an `LLMRequest` through its route without sending it, so
|
|
1305
|
+
tests can assert the provider payload.
|
|
1239
1306
|
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
`testLayer`.
|
|
1307
|
+
Other modalities and the Promise client have no test double. Test them over a custom executor layer, such as
|
|
1308
|
+
`AI.make({ layer })`, that answers the HTTP requests.
|
|
1243
1309
|
|
|
1244
1310
|
## Provider compaction
|
|
1245
1311
|
|
|
@@ -1256,9 +1322,7 @@ Prefer this operation, where supported, when the application owns compaction pol
|
|
|
1256
1322
|
```ts
|
|
1257
1323
|
const compacted = Effect.gen(function* () {
|
|
1258
1324
|
const result = yield* ai.compact(request)
|
|
1259
|
-
const next =
|
|
1260
|
-
messages: result.replacement,
|
|
1261
|
-
})
|
|
1325
|
+
const next = { ...request, messages: result.replacement }
|
|
1262
1326
|
return yield* ai.generate(next)
|
|
1263
1327
|
})
|
|
1264
1328
|
```
|
|
@@ -1318,7 +1382,7 @@ Enable OpenAI compaction with typed provider options:
|
|
|
1318
1382
|
|
|
1319
1383
|
```ts
|
|
1320
1384
|
import { Effect } from "effect"
|
|
1321
|
-
import { ai, LLMClient,
|
|
1385
|
+
import { ai, LLMClient, Message } from "@opencode/ai/effect"
|
|
1322
1386
|
import { OpenAI } from "@opencode/ai/providers"
|
|
1323
1387
|
|
|
1324
1388
|
const request = ai.request({
|
|
@@ -1330,9 +1394,7 @@ const request = ai.request({
|
|
|
1330
1394
|
})
|
|
1331
1395
|
const continued = Effect.gen(function* () {
|
|
1332
1396
|
const response = yield* LLMClient.generate(request)
|
|
1333
|
-
return
|
|
1334
|
-
messages: [...request.messages, response.message, Message.user("Continue")],
|
|
1335
|
-
})
|
|
1397
|
+
return { ...request, messages: [...request.messages, response.message, Message.user("Continue")] }
|
|
1336
1398
|
})
|
|
1337
1399
|
```
|
|
1338
1400
|
|
|
@@ -1476,6 +1538,8 @@ const gateway = CloudflareAIGateway.configure({
|
|
|
1476
1538
|
}).model("workers-ai/@cf/meta/llama-3.1-8b-instruct")
|
|
1477
1539
|
```
|
|
1478
1540
|
|
|
1541
|
+
For a provider that needs no key, such as a local server, pass `apiKey: false`: the package skips the environment lookup and sends no auth header (Amazon Bedrock and Google Vertex keep their own auth).
|
|
1542
|
+
|
|
1479
1543
|
Included LLM providers: OpenAI, Anthropic, Google (Gemini), Google Vertex, Amazon Bedrock (Converse and Mantle), Azure OpenAI, Alibaba, Baseten, Cerebras, Cohere, Cloudflare AI Gateway, Cloudflare Workers AI, DeepInfra, DeepSeek, DigitalOcean, Fireworks, Groq, Meta, MiniMax, Mistral, Moonshot, OpenRouter, TogetherAI, Venice, Vercel AI Gateway, xAI, Z.ai, and Z.ai Coding Plan. TypeSafe AI and OpenCode expose decision models only. Generic Chat Completions, Responses, and Anthropic Messages-compatible entrypoints support custom endpoints.
|
|
1480
1544
|
|
|
1481
1545
|
Each named provider owns its module, endpoint, authentication, and route setup. Providers with the same wire format compose the shared protocol directly:
|
|
@@ -1556,7 +1620,7 @@ Additional provider entrypoints include:
|
|
|
1556
1620
|
|
|
1557
1621
|
Request options in order of stability:
|
|
1558
1622
|
|
|
1559
|
-
1.
|
|
1623
|
+
1. **Portable knobs** — `maxTokens`, `temperature`, `topP`, `topK`, `frequencyPenalty`, `presencePenalty`, `seed` and `stop`, at the top level of a text request. `GENERATION_KEYS` lists them.
|
|
1560
1624
|
2. **`promptCacheKey`** — stable cache affinity lowered by every protocol that supports it.
|
|
1561
1625
|
3. **`providerOptions: { ... }`** — flat options inferred from the selected model (OpenAI `store`, Anthropic `thinking`, Gemini `thinkingConfig`, OpenRouter routing).
|
|
1562
1626
|
4. **`http: { body, headers, query }`** — last-resort serializable overlays merged into the final HTTP request. Reach for this only when a stable typed path doesn't yet exist.
|
package/dist/cache-policy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LLMRequest } from "./schema/messages.js";
|
|
1
|
+
import { type LLMRequest } from "./schema/messages.js";
|
|
2
2
|
/** The requested cache lifetime, for routes that send it as a request-level option instead of on markers. */
|
|
3
3
|
export declare const requestTTL: (request: LLMRequest) => `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
4
4
|
export declare const applyCachePolicy: (request: LLMRequest) => LLMRequest;
|
package/dist/cache-policy.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// Manual `cache: CacheHint` placements on individual parts are preserved and
|
|
12
12
|
// count against the four-breakpoint budget; auto only fills remaining slots.
|
|
13
13
|
import { CacheHint } from "./schema/options.js";
|
|
14
|
-
import {
|
|
14
|
+
import { AssistantMessage, SystemMessage, ToolDefinition, ToolMessage, UserMessage, } from "./schema/messages.js";
|
|
15
15
|
import { effortUpdate } from "./effort-updates.js";
|
|
16
16
|
const AUTO = {
|
|
17
17
|
tools: true,
|
|
@@ -119,8 +119,7 @@ const markMessageAt = (messages, index, hint, budget) => {
|
|
|
119
119
|
if (!existing || !isCacheablePart(existing) || existing.cache || budget.remaining === 0)
|
|
120
120
|
return messages;
|
|
121
121
|
budget.remaining -= 1;
|
|
122
|
-
const
|
|
123
|
-
const next = new Message({ ...target, content: nextContent });
|
|
122
|
+
const next = cachePartAt(target, markAt, hint);
|
|
124
123
|
// Single pass over `messages`, substituting the one updated entry. Long
|
|
125
124
|
// conversations call this on every request, so avoid `.map()` here — its
|
|
126
125
|
// closure dispatch and identity copies show up in profiling.
|
|
@@ -128,6 +127,19 @@ const markMessageAt = (messages, index, hint, budget) => {
|
|
|
128
127
|
result[index] = next;
|
|
129
128
|
return result;
|
|
130
129
|
};
|
|
130
|
+
const cachePartAt = (message, index, hint) => {
|
|
131
|
+
switch (message.role) {
|
|
132
|
+
case "system":
|
|
133
|
+
return new SystemMessage({ ...message, content: cacheContentAt(message.content, index, hint) });
|
|
134
|
+
case "user":
|
|
135
|
+
return new UserMessage({ ...message, content: cacheContentAt(message.content, index, hint) });
|
|
136
|
+
case "assistant":
|
|
137
|
+
return new AssistantMessage({ ...message, content: cacheContentAt(message.content, index, hint) });
|
|
138
|
+
case "tool":
|
|
139
|
+
return new ToolMessage({ ...message, content: cacheContentAt(message.content, index, hint) });
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const cacheContentAt = (content, index, hint) => content.map((part, i) => (i === index ? { ...part, cache: hint } : part));
|
|
131
143
|
const markMessages = (messages, strategy, hint, budget) => {
|
|
132
144
|
if (messages.length === 0)
|
|
133
145
|
return messages;
|
|
@@ -163,7 +175,7 @@ export const applyCachePolicy = (request) => {
|
|
|
163
175
|
const messages = policy.messages ? markMessages(request.messages, policy.messages, hint, budget) : request.messages;
|
|
164
176
|
if (tools === request.tools && system === request.system && messages === request.messages)
|
|
165
177
|
return request;
|
|
166
|
-
return
|
|
178
|
+
return { ...request, tools, system, messages };
|
|
167
179
|
};
|
|
168
180
|
/** Whether the cache policy places inline markers, which then carry the requested lifetime. */
|
|
169
181
|
export const placesMarkers = (request) => {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Context, Effect, Layer } from "effect";
|
|
2
|
-
import type { DecisionOptions, DecisionQuestions,
|
|
2
|
+
import type { DecisionModel, DecisionOptions, DecisionQuestions, DecisionRequest, DecisionResponseFor } from "./decision.js";
|
|
3
3
|
import { RequestExecutor } from "./route/executor.js";
|
|
4
4
|
import { AIError } from "./schema/index.js";
|
|
5
5
|
export type Execute = RequestExecutor.Interface["execute"];
|
|
6
6
|
export interface Interface {
|
|
7
|
-
readonly generate: <Options extends DecisionOptions, const Questions extends DecisionQuestions>(request:
|
|
7
|
+
readonly generate: <Options extends DecisionOptions, const Questions extends DecisionQuestions>(request: DecisionRequest<DecisionModel<Options>, Questions>) => Effect.Effect<DecisionResponseFor<Questions>, AIError>;
|
|
8
8
|
}
|
|
9
9
|
declare const Service_base: Context.ServiceClass<Service, "@opencode/AI/DecisionClient", Interface>;
|
|
10
10
|
export declare class Service extends Service_base {
|
|
11
11
|
}
|
|
12
|
-
export declare const generate: <Options extends DecisionOptions, const Questions extends DecisionQuestions>(request:
|
|
12
|
+
export declare const generate: <Options extends DecisionOptions, const Questions extends DecisionQuestions>(request: DecisionRequest<DecisionModel<Options>, Questions>) => Effect.Effect<DecisionResponseFor<Questions>, AIError, Service>;
|
|
13
13
|
export declare const layer: Layer.Layer<Service, never, RequestExecutor.Service>;
|
|
14
14
|
export declare const fetchLayer: Layer.Layer<RequestExecutor.RequestExecutorService | Service, never, never>;
|
|
15
15
|
export declare const DecisionClient: {
|