@opencode/ai 2.0.31 → 2.1.0
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/dist/ai-client.d.ts +2 -2
- package/dist/experimental/evaluation-client.d.ts +1 -1
- package/dist/experimental/evaluation.d.ts +20 -20
- package/dist/experimental/realtime.d.ts +47 -0
- package/dist/experimental/realtime.js +99 -0
- package/dist/experimental/system-one.d.ts +1 -1
- package/dist/experimental.d.ts +2 -0
- package/dist/experimental.js +1 -0
- package/dist/image-client.d.ts +8 -8
- package/dist/image.d.ts +593 -437
- package/dist/llm.d.ts +51 -51
- package/dist/media-client.d.ts +1 -1
- package/dist/media.d.ts +4 -4
- package/dist/promise.d.ts +199 -198
- package/dist/protocols/alibaba-chat.d.ts +81 -82
- package/dist/protocols/alibaba-chat.js +0 -1
- package/dist/protocols/alibaba-messages.d.ts +99 -99
- package/dist/protocols/alibaba-responses.d.ts +120 -120
- package/dist/protocols/anthropic-messages.d.ts +187 -187
- package/dist/protocols/anthropic-messages.js +3 -2
- package/dist/protocols/assemblyai-transcription.d.ts +1 -1
- package/dist/protocols/bedrock-converse.d.ts +75 -79
- package/dist/protocols/bfl-images.d.ts +1 -1
- package/dist/protocols/cartesia-speech.d.ts +17 -17
- package/dist/protocols/cohere-chat.d.ts +26 -23
- package/dist/protocols/cohere-chat.js +22 -1
- package/dist/protocols/deepgram-speech.d.ts +17 -17
- package/dist/protocols/deepgram-transcription.d.ts +1 -1
- package/dist/protocols/elevenlabs-speech.d.ts +17 -17
- package/dist/protocols/elevenlabs-transcription.d.ts +1 -1
- package/dist/protocols/fal-images.d.ts +1 -1
- package/dist/protocols/fal-video.d.ts +1 -1
- package/dist/protocols/gemini.d.ts +55 -55
- package/dist/protocols/gemini.js +11 -1
- package/dist/protocols/google-images.d.ts +1 -1
- package/dist/protocols/google-interactions.d.ts +64 -62
- package/dist/protocols/google-interactions.js +19 -1
- package/dist/protocols/google-speech.d.ts +17 -17
- package/dist/protocols/google-transcription.d.ts +47 -47
- package/dist/protocols/google-video.d.ts +1 -1
- package/dist/protocols/meta-messages.d.ts +121 -121
- package/dist/protocols/meta-responses.d.ts +201 -201
- package/dist/protocols/mistral-chat.d.ts +45 -45
- package/dist/protocols/open-responses-channel.d.ts +1 -1
- package/dist/protocols/open-responses.d.ts +584 -450
- package/dist/protocols/open-responses.js +27 -35
- package/dist/protocols/openai-chat.d.ts +248 -248
- package/dist/protocols/openai-chat.js +11 -42
- package/dist/protocols/openai-compatible-chat.d.ts +32 -32
- package/dist/protocols/openai-compatible-responses.d.ts +88 -88
- package/dist/protocols/openai-images.d.ts +17 -17
- package/dist/protocols/openai-responses.d.ts +567 -567
- package/dist/protocols/openai-responses.js +1 -1
- package/dist/protocols/openai-speech.d.ts +17 -17
- package/dist/protocols/openai-transcription.d.ts +47 -47
- package/dist/protocols/replicate-images.d.ts +1 -1
- package/dist/protocols/runway-video.d.ts +1 -1
- package/dist/protocols/shared.d.ts +12 -1
- package/dist/protocols/shared.js +17 -1
- package/dist/protocols/stability-images.d.ts +2 -2
- package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
- package/dist/protocols/utils/bedrock-media.d.ts +4 -4
- package/dist/protocols/utils/openai-options.d.ts +1 -1
- package/dist/protocols/utils/speech-stream.d.ts +1 -1
- package/dist/protocols/utils/tool-schema.d.ts +10 -5
- package/dist/protocols/utils/tool-stream.d.ts +152 -152
- package/dist/protocols/venice-chat.d.ts +109 -110
- package/dist/protocols/venice-chat.js +0 -1
- package/dist/protocols/xai-images.d.ts +1 -1
- package/dist/protocols/xai-responses.d.ts +79 -79
- package/dist/protocols/xai-video.d.ts +1 -1
- package/dist/protocols/zai-chat.d.ts +77 -78
- package/dist/protocols/zai-chat.js +0 -1
- package/dist/protocols/zai-images.d.ts +1 -1
- package/dist/protocols/zai-messages.d.ts +97 -97
- package/dist/providers/alibaba.d.ts +222 -283
- package/dist/providers/amazon-bedrock-mantle.d.ts +291 -298
- package/dist/providers/amazon-bedrock.d.ts +22 -28
- package/dist/providers/anthropic-compatible.d.ts +86 -90
- package/dist/providers/anthropic.d.ts +86 -90
- package/dist/providers/assemblyai.d.ts +2 -6
- package/dist/providers/azure.d.ts +228 -238
- package/dist/providers/baseten.d.ts +66 -70
- package/dist/providers/black-forest-labs.d.ts +2 -6
- package/dist/providers/cartesia.d.ts +2 -6
- package/dist/providers/cerebras.d.ts +66 -70
- package/dist/providers/cerebras.js +0 -1
- package/dist/providers/cloudflare-ai-gateway.d.ts +352 -356
- package/dist/providers/cloudflare-workers-ai.d.ts +66 -70
- package/dist/providers/cohere.d.ts +122 -132
- package/dist/providers/cohere.js +0 -2
- package/dist/providers/deepgram.d.ts +2 -7
- package/dist/providers/deepinfra.d.ts +66 -70
- package/dist/providers/deepinfra.js +0 -1
- package/dist/providers/deepseek.d.ts +66 -70
- package/dist/providers/deepseek.js +1 -1
- package/dist/providers/digitalocean.d.ts +137 -141
- package/dist/providers/elevenlabs.d.ts +2 -7
- package/dist/providers/fal.d.ts +2 -7
- package/dist/providers/fireworks.d.ts +66 -70
- package/dist/providers/google-vertex-chat.d.ts +34 -38
- package/dist/providers/google-vertex-interactions.d.ts +31 -41
- package/dist/providers/google-vertex-messages.d.ts +81 -85
- package/dist/providers/google-vertex-mistral.d.ts +23 -27
- package/dist/providers/google-vertex-responses.d.ts +90 -94
- package/dist/providers/google-vertex.d.ts +26 -30
- package/dist/providers/google.d.ts +94 -109
- package/dist/providers/groq.d.ts +111 -115
- package/dist/providers/groq.js +0 -1
- package/dist/providers/meta.d.ts +309 -317
- package/dist/providers/meta.js +1 -1
- package/dist/providers/minimax.d.ts +296 -303
- package/dist/providers/minimax.js +1 -1
- package/dist/providers/mistral.d.ts +22 -26
- package/dist/providers/moonshot.d.ts +296 -303
- package/dist/providers/moonshot.js +0 -1
- package/dist/providers/openai-compatible-responses.d.ts +90 -94
- package/dist/providers/openai-compatible.d.ts +34 -38
- package/dist/providers/openai.d.ts +93 -108
- package/dist/providers/opencode.d.ts +2 -8
- package/dist/providers/openrouter.d.ts +137 -144
- package/dist/providers/replicate.d.ts +2 -6
- package/dist/providers/runway.d.ts +2 -6
- package/dist/providers/stability.d.ts +2 -7
- package/dist/providers/togetherai.d.ts +66 -70
- package/dist/providers/togetherai.js +1 -1
- package/dist/providers/typesafe-ai.d.ts +2 -8
- package/dist/providers/venice.d.ts +58 -63
- package/dist/providers/vercel-ai-gateway.d.ts +2 -12
- package/dist/providers/xai.d.ts +38 -50
- package/dist/providers/zai-coding-plan.d.ts +206 -213
- package/dist/providers/zai.d.ts +40 -46
- package/dist/route/client.d.ts +51 -51
- package/dist/route/media-protocol.d.ts +1 -1
- package/dist/route/transport/http.d.ts +1 -1
- package/dist/route/transport/websocket.d.ts +8 -8
- package/dist/schema/errors.d.ts +19 -19
- package/dist/schema/events.d.ts +3090 -3288
- package/dist/schema/messages.d.ts +8 -7
- package/dist/schema/options.d.ts +2 -1
- package/dist/schema/options.js +2 -1
- package/dist/speech-client.d.ts +8 -8
- package/dist/speech.d.ts +434 -398
- package/dist/testing.d.ts +338 -338
- package/dist/tool-runtime.d.ts +1 -1
- package/dist/transcription-client.d.ts +23 -23
- package/dist/transcription.d.ts +562 -646
- package/dist/utils/sanitize.d.ts +4 -0
- package/dist/utils/sanitize.js +23 -6
- package/dist/video-client.d.ts +8 -8
- package/dist/video.d.ts +416 -372
- package/package.json +6 -6
|
@@ -2,7 +2,7 @@ import { Effect, Option, Schema } from "effect";
|
|
|
2
2
|
import { HttpTransport } from "../route/transport/index.js";
|
|
3
3
|
import { Protocol } from "../route/protocol.js";
|
|
4
4
|
import { AIError, LLMEvent, ProviderInternalError, Usage, } from "../schema/index.js";
|
|
5
|
-
import { JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared.js";
|
|
5
|
+
import { JsonObject, lenient, optionalArray, optionalNull, optionalNullish, ProviderShared, withUntypedFrames, } from "./shared.js";
|
|
6
6
|
import { classifyProviderFailure } from "../provider-error.js";
|
|
7
7
|
import { effortUpdate } from "../effort-updates.js";
|
|
8
8
|
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
@@ -222,14 +222,14 @@ export const OpenResponsesBody = Schema.Struct({
|
|
|
222
222
|
stream: Schema.Literal(true),
|
|
223
223
|
});
|
|
224
224
|
export const OpenResponsesUsage = Schema.StructWithRest(Schema.Struct({
|
|
225
|
-
input_tokens:
|
|
225
|
+
input_tokens: lenient(Schema.Number),
|
|
226
226
|
input_tokens_details: optionalNull(Schema.StructWithRest(Schema.Struct({
|
|
227
|
-
cached_tokens:
|
|
228
|
-
cache_write_tokens:
|
|
227
|
+
cached_tokens: lenient(Schema.Number),
|
|
228
|
+
cache_write_tokens: lenient(Schema.Number),
|
|
229
229
|
}), [JsonObject])),
|
|
230
|
-
output_tokens:
|
|
231
|
-
output_tokens_details: optionalNull(Schema.StructWithRest(Schema.Struct({ reasoning_tokens:
|
|
232
|
-
total_tokens:
|
|
230
|
+
output_tokens: lenient(Schema.Number),
|
|
231
|
+
output_tokens_details: optionalNull(Schema.StructWithRest(Schema.Struct({ reasoning_tokens: lenient(Schema.Number) }), [JsonObject])),
|
|
232
|
+
total_tokens: lenient(Schema.Number),
|
|
233
233
|
}), [JsonObject]);
|
|
234
234
|
// The spec requires `id` on every output item, but some gateways drop it from
|
|
235
235
|
// later item events (Bedrock Mantle renames it to `item_id` on
|
|
@@ -238,11 +238,11 @@ export const OpenResponsesUsage = Schema.StructWithRest(Schema.Struct({
|
|
|
238
238
|
// https://www.openresponses.org/specification#extending-items
|
|
239
239
|
export const StreamItem = Schema.StructWithRest(Schema.Struct({
|
|
240
240
|
type: Schema.String,
|
|
241
|
-
id:
|
|
242
|
-
call_id:
|
|
243
|
-
name:
|
|
244
|
-
namespace:
|
|
245
|
-
arguments:
|
|
241
|
+
id: optionalNullish(Schema.String),
|
|
242
|
+
call_id: optionalNullish(Schema.String),
|
|
243
|
+
name: optionalNullish(Schema.String),
|
|
244
|
+
namespace: optionalNullish(Schema.String),
|
|
245
|
+
arguments: optionalNullish(Schema.String),
|
|
246
246
|
encrypted_content: optionalNull(Schema.String),
|
|
247
247
|
}), [Schema.Record(Schema.String, Schema.Unknown)]);
|
|
248
248
|
// Responses-compatible providers put error details at the top level, under `error`, or under
|
|
@@ -251,21 +251,22 @@ export const StreamItem = Schema.StructWithRest(Schema.Struct({
|
|
|
251
251
|
// only fail on invalid JSON and otherwise always classifies with the raw body as the fallback.
|
|
252
252
|
// https://www.openresponses.org/specification
|
|
253
253
|
const asText = (value) => typeof value === "string" && value.length > 0 ? value : typeof value === "number" ? String(value) : undefined;
|
|
254
|
-
|
|
254
|
+
const TypedEvent = Schema.StructWithRest(Schema.Struct({
|
|
255
255
|
type: Schema.String,
|
|
256
|
-
delta:
|
|
257
|
-
arguments:
|
|
258
|
-
text:
|
|
256
|
+
delta: optionalNullish(Schema.String),
|
|
257
|
+
arguments: optionalNullish(Schema.String),
|
|
258
|
+
text: optionalNullish(Schema.String),
|
|
259
|
+
// Kept strict: item-scoped events always carry an id, so null means a broken stream.
|
|
259
260
|
item_id: Schema.optional(Schema.String),
|
|
260
|
-
output_index:
|
|
261
|
-
summary_index:
|
|
261
|
+
output_index: optionalNullish(Schema.Number),
|
|
262
|
+
summary_index: optionalNullish(Schema.Number),
|
|
262
263
|
// OutputItemAdded/Done permit a null item in the Open Responses OpenAPI schema.
|
|
263
264
|
item: optionalNull(StreamItem),
|
|
264
|
-
response:
|
|
265
|
-
id:
|
|
265
|
+
response: optionalNullish(Schema.StructWithRest(Schema.Struct({
|
|
266
|
+
id: optionalNullish(Schema.String),
|
|
266
267
|
service_tier: optionalNull(Schema.String),
|
|
267
|
-
incomplete_details: optionalNull(Schema.Struct({ reason:
|
|
268
|
-
output:
|
|
268
|
+
incomplete_details: optionalNull(Schema.Struct({ reason: optionalNullish(Schema.String) })),
|
|
269
|
+
output: optionalNullish(Schema.Array(StreamItem)),
|
|
269
270
|
usage: optionalNull(OpenResponsesUsage),
|
|
270
271
|
error: Schema.optional(Schema.Unknown),
|
|
271
272
|
}), [Schema.Record(Schema.String, Schema.Unknown)])),
|
|
@@ -275,16 +276,9 @@ export const Event = Schema.StructWithRest(Schema.Struct({
|
|
|
275
276
|
status: Schema.optional(Schema.Unknown),
|
|
276
277
|
status_code: Schema.optional(Schema.Unknown),
|
|
277
278
|
}), [Schema.Record(Schema.String, Schema.Unknown)]);
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
* Decodes one WebSocket frame. Some providers and gateways answer a rejected `response.create` with a bare
|
|
282
|
-
* `{ "error": ... }` envelope and no event type; that reads as an error event so it classifies instead of
|
|
283
|
-
* failing decoding.
|
|
284
|
-
*/
|
|
285
|
-
export const decodeChannelEvent = (frame) => decodeFrame(frame).pipe(Effect.flatMap((value) => decodeEventValue(ProviderShared.isRecord(value) && value.type === undefined && value.error != null
|
|
286
|
-
? { ...value, type: "error" }
|
|
287
|
-
: value)));
|
|
279
|
+
export const Event = withUntypedFrames(TypedEvent);
|
|
280
|
+
/** Decodes one WebSocket frame. */
|
|
281
|
+
export const decodeChannelEvent = Schema.decodeUnknownEffect(Protocol.jsonEvent(Event));
|
|
288
282
|
const BASE_ADAPTER = { id: ADAPTER, name: NAME };
|
|
289
283
|
// =============================================================================
|
|
290
284
|
// Request Lowering
|
|
@@ -654,7 +648,7 @@ export const mapUsage = (usage, providerMetadataKey) => {
|
|
|
654
648
|
};
|
|
655
649
|
const mapFinishReason = (event, hasFunctionCall) => {
|
|
656
650
|
const reason = event.response?.incomplete_details?.reason;
|
|
657
|
-
if (reason === undefined
|
|
651
|
+
if (reason === undefined) {
|
|
658
652
|
if (hasFunctionCall)
|
|
659
653
|
return "tool-calls";
|
|
660
654
|
if (event.type === "response.incomplete")
|
|
@@ -714,8 +708,6 @@ const ITEM_ID_PREFIX = {
|
|
|
714
708
|
// otherwise it gets a locally minted one.
|
|
715
709
|
const resolveItem = (state, item, index) => ({
|
|
716
710
|
...item,
|
|
717
|
-
// Some gateways serialize an absent namespace as null.
|
|
718
|
-
namespace: item.namespace ?? undefined,
|
|
719
711
|
id: item.id ??
|
|
720
712
|
(index === undefined ? undefined : state.outputItems[index]) ??
|
|
721
713
|
`${ITEM_ID_PREFIX[item.type] ?? "item"}_${crypto.randomUUID().replaceAll("-", "")}`,
|