@opencode/ai 2.1.4 → 2.2.1
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 +339 -166
- package/dist/ai-client.d.ts +2 -2
- package/dist/ai-client.js +2 -1
- package/dist/cache-policy.d.ts +4 -0
- package/dist/cache-policy.js +20 -6
- package/dist/decision-client.d.ts +21 -0
- package/dist/decision-client.js +55 -0
- package/dist/decision.d.ts +472 -0
- package/dist/decision.js +158 -0
- package/dist/effect.d.ts +38 -0
- package/dist/effect.js +27 -0
- package/dist/effort-updates.d.ts +2 -2
- package/dist/experimental/cloudflare-run-extraction.d.ts +13 -0
- package/dist/experimental/cloudflare-run-extraction.js +83 -0
- package/dist/experimental/extraction.d.ts +183 -0
- package/dist/experimental/extraction.js +102 -0
- package/dist/experimental/realtime.d.ts +7 -2
- package/dist/experimental/realtime.js +5 -5
- package/dist/experimental.d.ts +2 -3
- package/dist/experimental.js +1 -2
- package/dist/image-client.d.ts +50 -14
- package/dist/image-client.js +0 -1
- package/dist/image.d.ts +6 -176
- package/dist/image.js +4 -11
- package/dist/index.d.ts +1444 -34
- package/dist/index.js +139 -24
- package/dist/llm.d.ts +16 -1
- package/dist/llm.js +34 -0
- package/dist/media-client.d.ts +3 -1
- package/dist/media-client.js +1 -0
- package/dist/media-model.d.ts +3 -0
- package/dist/media-model.js +4 -1
- package/dist/media.d.ts +0 -7
- package/dist/media.js +0 -6
- package/dist/protocols/alibaba-chat.d.ts +59 -4
- package/dist/protocols/alibaba-images.d.ts +22 -0
- package/dist/protocols/alibaba-images.js +77 -0
- package/dist/protocols/alibaba-messages.d.ts +52 -17
- package/dist/protocols/alibaba-responses.d.ts +26 -6
- package/dist/protocols/anthropic-messages.d.ts +160 -54
- package/dist/protocols/anthropic-messages.js +44 -13
- package/dist/protocols/bedrock-converse.d.ts +110 -15
- package/dist/protocols/bedrock-converse.js +112 -15
- package/dist/protocols/bedrock-event-stream.js +1 -0
- package/dist/protocols/cartesia-speech.d.ts +0 -18
- package/dist/protocols/cloudflare-run-decisions.d.ts +9 -0
- package/dist/protocols/cloudflare-run-decisions.js +36 -0
- package/dist/protocols/cloudflare-workers-ai-images.d.ts +23 -0
- package/dist/protocols/cloudflare-workers-ai-images.js +80 -0
- package/dist/protocols/deepgram-speech.d.ts +0 -18
- package/dist/protocols/elevenlabs-speech.d.ts +0 -18
- package/dist/protocols/gemini.d.ts +3 -0
- package/dist/protocols/gemini.js +11 -6
- package/dist/protocols/google-images.d.ts +2 -2
- package/dist/protocols/google-images.js +10 -37
- package/dist/protocols/google-interactions.d.ts +4 -0
- package/dist/protocols/google-interactions.js +12 -5
- package/dist/protocols/google-speech.d.ts +0 -18
- package/dist/protocols/google-speech.js +0 -1
- package/dist/protocols/google-transcription.d.ts +0 -18
- package/dist/protocols/google-transcription.js +0 -1
- package/dist/protocols/google-video.d.ts +1 -1
- package/dist/protocols/google-video.js +2 -7
- package/dist/protocols/index.d.ts +3 -0
- package/dist/protocols/index.js +3 -0
- package/dist/protocols/meta-images.d.ts +7 -1
- package/dist/protocols/meta-images.js +10 -8
- package/dist/protocols/meta-messages.d.ts +52 -17
- package/dist/protocols/meta-messages.js +14 -1
- package/dist/protocols/meta-responses.d.ts +46 -6
- package/dist/protocols/meta-responses.js +29 -1
- package/dist/protocols/minimax-images.d.ts +25 -0
- package/dist/protocols/minimax-images.js +150 -0
- package/dist/protocols/open-responses.d.ts +212 -27
- package/dist/protocols/open-responses.js +116 -54
- package/dist/protocols/openai-chat.d.ts +1135 -31
- package/dist/protocols/openai-chat.js +155 -60
- package/dist/protocols/openai-compatible-chat.d.ts +57 -5
- package/dist/protocols/openai-compatible-responses.d.ts +28 -8
- package/dist/protocols/openai-decisions.d.ts +22 -0
- package/dist/protocols/openai-decisions.js +128 -0
- package/dist/protocols/openai-freeform.d.ts +47 -0
- package/dist/protocols/openai-freeform.js +54 -0
- package/dist/protocols/openai-images.d.ts +36 -24
- package/dist/protocols/openai-images.js +137 -39
- package/dist/protocols/openai-responses.d.ts +202 -42
- package/dist/protocols/openai-responses.js +49 -10
- package/dist/protocols/openai-speech.d.ts +0 -18
- package/dist/protocols/openai-speech.js +15 -5
- package/dist/protocols/openai-transcription.d.ts +0 -18
- package/dist/protocols/openai-transcription.js +3 -4
- package/dist/protocols/runway-video.d.ts +1 -1
- package/dist/protocols/runway-video.js +1 -1
- package/dist/protocols/shared.d.ts +9 -1
- package/dist/protocols/shared.js +13 -2
- package/dist/protocols/system-one.d.ts +101 -0
- package/dist/protocols/system-one.js +230 -0
- package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
- package/dist/protocols/utils/bedrock-cache.js +7 -6
- package/dist/protocols/utils/cache.d.ts +14 -3
- package/dist/protocols/utils/cache.js +11 -4
- package/dist/protocols/utils/gemini-generate-content.d.ts +3 -3
- package/dist/protocols/utils/gemini-generate-content.js +10 -16
- package/dist/protocols/utils/gemini-json-schema.d.ts +5 -0
- package/dist/protocols/utils/gemini-json-schema.js +3 -3
- package/dist/protocols/utils/image-sizing.d.ts +31 -0
- package/dist/protocols/utils/image-sizing.js +73 -0
- package/dist/protocols/utils/media-input.d.ts +4 -5
- package/dist/protocols/utils/media-input.js +8 -5
- package/dist/protocols/utils/speech-stream.d.ts +0 -1
- package/dist/protocols/utils/speech-stream.js +0 -1
- package/dist/protocols/utils/tool-schema.js +15 -5
- package/dist/protocols/utils/tool-stream.d.ts +9 -0
- package/dist/protocols/venice-chat.d.ts +58 -4
- package/dist/protocols/venice-chat.js +2 -2
- package/dist/protocols/xai-images.d.ts +7 -2
- package/dist/protocols/xai-images.js +11 -5
- package/dist/protocols/xai-responses.d.ts +30 -3
- package/dist/protocols/xai-responses.js +30 -3
- package/dist/protocols/xai-video.d.ts +1 -1
- package/dist/protocols/xai-video.js +11 -8
- package/dist/protocols/zai-chat.d.ts +60 -4
- package/dist/protocols/zai-images.d.ts +3 -1
- package/dist/protocols/zai-images.js +12 -11
- package/dist/protocols/zai-messages.d.ts +52 -17
- package/dist/provider-error.js +23 -7
- package/dist/provider-package.d.ts +2 -0
- package/dist/providers/alibaba/images.d.ts +2 -0
- package/dist/providers/alibaba/images.js +1 -0
- package/dist/providers/alibaba.d.ts +137 -28
- package/dist/providers/alibaba.js +16 -8
- package/dist/providers/amazon-bedrock-mantle.d.ts +259 -145
- package/dist/providers/amazon-bedrock-mantle.js +1 -1
- package/dist/providers/amazon-bedrock.d.ts +34 -14
- package/dist/providers/amazon-bedrock.js +11 -11
- package/dist/providers/anthropic-compatible.d.ts +53 -18
- package/dist/providers/anthropic.d.ts +53 -18
- package/dist/providers/anthropic.js +1 -1
- package/dist/providers/azure/images.d.ts +2 -0
- package/dist/providers/azure/images.js +1 -0
- package/dist/providers/azure.d.ts +129 -24
- package/dist/providers/azure.js +19 -1
- package/dist/providers/baseten/decisions.d.ts +2 -0
- package/dist/providers/baseten/decisions.js +1 -0
- package/dist/providers/baseten.d.ts +124 -12
- package/dist/providers/baseten.js +41 -8
- package/dist/providers/cerebras.d.ts +115 -11
- package/dist/providers/cerebras.js +1 -1
- package/dist/providers/cloudflare-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-ai-gateway/decisions.js +1 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +290 -60
- package/dist/providers/cloudflare-ai-gateway.js +32 -4
- package/dist/providers/cloudflare-workers-ai/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/decisions.js +1 -0
- package/dist/providers/cloudflare-workers-ai/images.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/images.js +1 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +128 -12
- package/dist/providers/cloudflare-workers-ai.js +45 -9
- package/dist/providers/cohere/chat.d.ts +1 -1
- package/dist/providers/cohere/chat.js +1 -1
- package/dist/providers/cohere.d.ts +115 -11
- package/dist/providers/cohere.js +1 -1
- package/dist/providers/deepinfra.d.ts +115 -11
- package/dist/providers/deepinfra.js +1 -1
- package/dist/providers/deepseek.d.ts +115 -11
- package/dist/providers/deepseek.js +1 -1
- package/dist/providers/digitalocean/decisions.d.ts +2 -0
- package/dist/providers/digitalocean/decisions.js +1 -0
- package/dist/providers/digitalocean/images.d.ts +2 -0
- package/dist/providers/digitalocean/images.js +1 -0
- package/dist/providers/digitalocean/responses.d.ts +4 -0
- package/dist/providers/digitalocean/responses.js +1 -0
- package/dist/providers/digitalocean.d.ts +390 -20
- package/dist/providers/digitalocean.js +53 -11
- package/dist/providers/fireworks.d.ts +115 -11
- package/dist/providers/fireworks.js +1 -1
- package/dist/providers/google/images.d.ts +2 -0
- package/dist/providers/google/images.js +1 -0
- package/dist/providers/google/interactions.d.ts +1 -1
- package/dist/providers/google/interactions.js +1 -1
- package/dist/providers/google-vertex/images.d.ts +2 -0
- package/dist/providers/google-vertex/images.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +57 -5
- package/dist/providers/google-vertex-chat.js +1 -1
- package/dist/providers/google-vertex-interactions.d.ts +1 -1
- package/dist/providers/google-vertex-interactions.js +1 -1
- package/dist/providers/google-vertex-messages.d.ts +53 -18
- package/dist/providers/google-vertex-messages.js +1 -1
- package/dist/providers/google-vertex-mistral.d.ts +1 -1
- package/dist/providers/google-vertex-mistral.js +1 -1
- package/dist/providers/google-vertex-responses.d.ts +24 -4
- package/dist/providers/google-vertex-responses.js +1 -1
- package/dist/providers/google-vertex.d.ts +4 -2
- package/dist/providers/google-vertex.js +30 -13
- package/dist/providers/google.d.ts +6 -5
- package/dist/providers/google.js +15 -8
- package/dist/providers/groq.d.ts +119 -15
- package/dist/providers/groq.js +1 -7
- package/dist/providers/index.d.ts +0 -4
- package/dist/providers/index.js +0 -4
- package/dist/providers/meta/images.d.ts +2 -0
- package/dist/providers/meta/images.js +1 -0
- package/dist/providers/meta.d.ts +254 -146
- package/dist/providers/meta.js +2 -1
- package/dist/providers/minimax/chat.d.ts +1 -1
- package/dist/providers/minimax/chat.js +1 -1
- package/dist/providers/minimax/images.d.ts +3 -0
- package/dist/providers/minimax/images.js +1 -0
- package/dist/providers/minimax/responses.d.ts +1 -1
- package/dist/providers/minimax/responses.js +1 -1
- package/dist/providers/minimax.d.ts +139 -26
- package/dist/providers/minimax.js +22 -9
- package/dist/providers/mistral.d.ts +3 -3
- package/dist/providers/mistral.js +1 -1
- package/dist/providers/moonshot/messages.d.ts +1 -1
- package/dist/providers/moonshot/messages.js +1 -1
- package/dist/providers/moonshot/responses.d.ts +1 -1
- package/dist/providers/moonshot/responses.js +1 -1
- package/dist/providers/moonshot.d.ts +132 -25
- package/dist/providers/moonshot.js +1 -1
- package/dist/providers/openai/images.d.ts +2 -0
- package/dist/providers/openai/images.js +1 -0
- package/dist/providers/openai-compatible/images.d.ts +2 -0
- package/dist/providers/openai-compatible/images.js +1 -0
- package/dist/providers/openai-compatible-responses.d.ts +24 -4
- package/dist/providers/openai-compatible.d.ts +62 -8
- package/dist/providers/openai-compatible.js +29 -10
- package/dist/providers/openai-options.d.ts +3 -1
- package/dist/providers/openai.d.ts +103 -18
- package/dist/providers/openai.js +23 -5
- package/dist/providers/opencode/decisions.d.ts +2 -0
- package/dist/providers/opencode/decisions.js +1 -0
- package/dist/providers/opencode.d.ts +11 -12
- package/dist/providers/opencode.js +10 -8
- package/dist/providers/openrouter/decisions.d.ts +2 -0
- package/dist/providers/openrouter/decisions.js +1 -0
- package/dist/providers/openrouter/images.d.ts +2 -0
- package/dist/providers/openrouter/images.js +1 -0
- package/dist/providers/openrouter/responses.d.ts +4 -0
- package/dist/providers/openrouter/responses.js +1 -0
- package/dist/providers/openrouter.d.ts +446 -35
- package/dist/providers/openrouter.js +78 -27
- package/dist/providers/togetherai.d.ts +115 -11
- package/dist/providers/togetherai.js +1 -1
- package/dist/providers/typesafe-ai/decisions.d.ts +2 -0
- package/dist/providers/typesafe-ai/decisions.js +1 -0
- package/dist/providers/typesafe-ai.d.ts +11 -12
- package/dist/providers/typesafe-ai.js +10 -8
- package/dist/providers/venice/responses.d.ts +4 -0
- package/dist/providers/venice/responses.js +1 -0
- package/dist/providers/venice.d.ts +261 -9
- package/dist/providers/venice.js +33 -17
- package/dist/providers/vercel-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/decisions.js +1 -0
- package/dist/providers/vercel-ai-gateway/images.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/images.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +16 -22
- package/dist/providers/vercel-ai-gateway.js +41 -85
- package/dist/providers/xai/images.d.ts +2 -0
- package/dist/providers/xai/images.js +1 -0
- package/dist/providers/xai.d.ts +66 -12
- package/dist/providers/xai.js +15 -8
- package/dist/providers/zai/images.d.ts +2 -0
- package/dist/providers/zai/images.js +1 -0
- package/dist/providers/zai-coding-plan/messages.d.ts +1 -1
- package/dist/providers/zai-coding-plan/messages.js +1 -1
- package/dist/providers/zai-coding-plan/responses.d.ts +1 -1
- package/dist/providers/zai-coding-plan/responses.js +1 -1
- package/dist/providers/zai-coding-plan.d.ts +132 -25
- package/dist/providers/zai-coding-plan.js +1 -1
- package/dist/providers/zai.d.ts +62 -9
- package/dist/providers/zai.js +15 -8
- package/dist/route/auth.d.ts +1 -1
- package/dist/route/client.d.ts +2 -2
- package/dist/route/client.js +26 -4
- package/dist/route/decision.d.ts +58 -0
- package/dist/route/decision.js +75 -0
- package/dist/route/executor.d.ts +1 -1
- package/dist/route/framing.d.ts +2 -0
- package/dist/route/index.d.ts +3 -0
- package/dist/route/index.js +3 -0
- package/dist/route/media-protocol.d.ts +3 -4
- package/dist/route/media-protocol.js +12 -8
- package/dist/route/media.d.ts +6 -2
- package/dist/route/media.js +8 -6
- package/dist/route/transport/http.js +1 -0
- package/dist/route/transport/index.d.ts +1 -0
- package/dist/schema/events.d.ts +148 -6
- package/dist/schema/events.js +20 -0
- package/dist/schema/messages.d.ts +41 -3
- package/dist/schema/messages.js +23 -0
- package/dist/schema/options.d.ts +5 -3
- package/dist/schema/options.js +8 -3
- package/dist/speech-client.d.ts +53 -14
- package/dist/speech-client.js +0 -1
- package/dist/speech.d.ts +0 -135
- package/dist/speech.js +2 -4
- package/dist/testing/decision.d.ts +16 -0
- package/dist/testing/decision.js +20 -0
- package/dist/testing/image.d.ts +14 -0
- package/dist/testing/image.js +12 -0
- package/dist/testing/media.d.ts +18 -0
- package/dist/testing/media.js +36 -0
- package/dist/testing/script.d.ts +28 -0
- package/dist/testing/script.js +60 -0
- package/dist/testing/speech.d.ts +14 -0
- package/dist/testing/speech.js +12 -0
- package/dist/testing/transcription.d.ts +14 -0
- package/dist/testing/transcription.js +12 -0
- package/dist/testing/video.d.ts +14 -0
- package/dist/testing/video.js +12 -0
- package/dist/testing.d.ts +35 -45
- package/dist/testing.js +14 -75
- package/dist/tool.d.ts +12 -1
- package/dist/tool.js +10 -2
- package/dist/transcription-client.d.ts +69 -14
- package/dist/transcription.d.ts +0 -135
- package/dist/transcription.js +1 -1
- package/dist/utils/media-type.js +22 -1
- package/dist/video-client.d.ts +46 -14
- package/dist/video-client.js +0 -1
- package/dist/video.d.ts +1 -136
- package/dist/video.js +3 -5
- package/package.json +497 -11
- package/dist/experimental/evaluation-client.d.ts +0 -21
- package/dist/experimental/evaluation-client.js +0 -64
- package/dist/experimental/evaluation.d.ts +0 -242
- package/dist/experimental/evaluation.js +0 -108
- package/dist/experimental/system-one.d.ts +0 -16
- package/dist/experimental/system-one.js +0 -135
- package/dist/promise.d.ts +0 -1021
- package/dist/promise.js +0 -101
- package/dist/protocols/bfl-images.d.ts +0 -38
- package/dist/protocols/bfl-images.js +0 -153
- package/dist/protocols/fal-images.d.ts +0 -25
- package/dist/protocols/fal-images.js +0 -104
- package/dist/protocols/fal-video.d.ts +0 -29
- package/dist/protocols/fal-video.js +0 -73
- package/dist/protocols/replicate-images.d.ts +0 -28
- package/dist/protocols/replicate-images.js +0 -127
- package/dist/protocols/stability-images.d.ts +0 -39
- package/dist/protocols/stability-images.js +0 -136
- package/dist/protocols/utils/fal-queue.d.ts +0 -26
- package/dist/protocols/utils/fal-queue.js +0 -67
- package/dist/provider.d.ts +0 -23
- package/dist/provider.js +0 -2
- package/dist/providers/black-forest-labs.d.ts +0 -21
- package/dist/providers/black-forest-labs.js +0 -23
- package/dist/providers/fal.d.ts +0 -24
- package/dist/providers/fal.js +0 -26
- package/dist/providers/replicate.d.ts +0 -21
- package/dist/providers/replicate.js +0 -17
- package/dist/providers/stability.d.ts +0 -23
- package/dist/providers/stability.js +0 -18
package/dist/schema/events.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ declare const Usage_base: Schema.Class<Usage, Schema.Struct<{
|
|
|
15
15
|
readonly cacheWriteInputTokens: Schema.optional<Schema.Number>;
|
|
16
16
|
readonly reasoningTokens: Schema.optional<Schema.Number>;
|
|
17
17
|
readonly totalTokens: Schema.optional<Schema.Number>;
|
|
18
|
+
/**
|
|
19
|
+
* USD the endpoint says it charged for this request, as OpenRouter, LiteLLM and OpenCode Zen report it in
|
|
20
|
+
* `usage.cost`. `0` is authoritative: the request was free or a subscription covered it. Absent, callers price the
|
|
21
|
+
* tokens themselves.
|
|
22
|
+
*/
|
|
23
|
+
readonly cost: Schema.optional<Schema.Number>;
|
|
18
24
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
19
25
|
}>, {}>;
|
|
20
26
|
/**
|
|
@@ -97,6 +103,13 @@ export declare const MediaUsage: Schema.Union<readonly [Schema.Struct<{
|
|
|
97
103
|
readonly seconds: Schema.Number;
|
|
98
104
|
}>]>;
|
|
99
105
|
export type MediaUsage = Schema.Schema.Type<typeof MediaUsage>;
|
|
106
|
+
/** Token usage from a provider's counts. A usage object without any count is no usage, so it returns undefined. */
|
|
107
|
+
export declare const tokenUsage: (counts: {
|
|
108
|
+
readonly input?: number;
|
|
109
|
+
readonly output?: number;
|
|
110
|
+
readonly total?: number;
|
|
111
|
+
readonly details?: Record<string, unknown>;
|
|
112
|
+
}) => MediaUsage | undefined;
|
|
100
113
|
declare const CompactionResponse_base: Schema.Class<CompactionResponse, Schema.Struct<{
|
|
101
114
|
readonly replacement: Schema.$Array<typeof Message>;
|
|
102
115
|
readonly usage: Schema.optional<typeof Usage>;
|
|
@@ -404,6 +417,12 @@ export declare const ProviderErrorEvent: Schema.Struct<{
|
|
|
404
417
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
405
418
|
}>;
|
|
406
419
|
export type ProviderErrorEvent = Schema.Schema.Type<typeof ProviderErrorEvent>;
|
|
420
|
+
/** One provider frame as received, emitted before the events parsed from it when the request sets `includeRaw`. */
|
|
421
|
+
export declare const RawEvent: Schema.Struct<{
|
|
422
|
+
readonly type: Schema.tag<"raw">;
|
|
423
|
+
readonly data: Schema.Unknown;
|
|
424
|
+
}>;
|
|
425
|
+
export type RawEvent = Schema.Schema.Type<typeof RawEvent>;
|
|
407
426
|
declare const llmEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.refine<{
|
|
408
427
|
readonly type: "compaction";
|
|
409
428
|
readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -637,6 +656,9 @@ declare const llmEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.refi
|
|
|
637
656
|
readonly message: Schema.String;
|
|
638
657
|
readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
|
|
639
658
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
659
|
+
}>, Schema.Struct<{
|
|
660
|
+
readonly type: Schema.tag<"raw">;
|
|
661
|
+
readonly data: Schema.Unknown;
|
|
640
662
|
}>]>;
|
|
641
663
|
type WithID<Event extends {
|
|
642
664
|
readonly id: unknown;
|
|
@@ -886,8 +908,11 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
886
908
|
readonly message: Schema.String;
|
|
887
909
|
readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
|
|
888
910
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
911
|
+
}>, Schema.Struct<{
|
|
912
|
+
readonly type: Schema.tag<"raw">;
|
|
913
|
+
readonly data: Schema.Unknown;
|
|
889
914
|
}>]> & {
|
|
890
|
-
readonly discriminants: readonly ["compaction", "step-start", "text-start", "text-delta", "text-end", "reasoning-start", "reasoning-delta", "reasoning-end", "tool-input-start", "tool-input-delta", "tool-input-end", "tool-input-error", "tool-call", "tool-result", "tool-error", "media", "step-finish", "finish", "provider-error"];
|
|
915
|
+
readonly discriminants: readonly ["compaction", "step-start", "text-start", "text-delta", "text-end", "reasoning-start", "reasoning-delta", "reasoning-end", "tool-input-start", "tool-input-delta", "tool-input-end", "tool-input-error", "tool-call", "tool-result", "tool-error", "media", "step-finish", "finish", "provider-error", "raw"];
|
|
891
916
|
readonly cases: {
|
|
892
917
|
compaction: Schema.refine<{
|
|
893
918
|
readonly type: "compaction";
|
|
@@ -970,6 +995,10 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
970
995
|
readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
|
|
971
996
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
972
997
|
}>;
|
|
998
|
+
raw: Schema.Struct<{
|
|
999
|
+
readonly type: Schema.tag<"raw">;
|
|
1000
|
+
readonly data: Schema.Unknown;
|
|
1001
|
+
}>;
|
|
973
1002
|
"reasoning-delta": Schema.Struct<{
|
|
974
1003
|
readonly type: Schema.tag<"reasoning-delta">;
|
|
975
1004
|
readonly id: Schema.String;
|
|
@@ -1145,6 +1174,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
1145
1174
|
readonly isAnyOf: <const Keys>(keys: readonly Keys[]) => (value: {
|
|
1146
1175
|
readonly type: "step-start";
|
|
1147
1176
|
readonly index: number;
|
|
1177
|
+
} | {
|
|
1178
|
+
readonly type: "raw";
|
|
1179
|
+
readonly data: unknown;
|
|
1148
1180
|
} | {
|
|
1149
1181
|
readonly type: "text-start";
|
|
1150
1182
|
readonly id: string;
|
|
@@ -1362,6 +1394,11 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
1362
1394
|
readonly index: number;
|
|
1363
1395
|
}, {
|
|
1364
1396
|
readonly type: Keys;
|
|
1397
|
+
}> | Extract<{
|
|
1398
|
+
readonly type: "raw";
|
|
1399
|
+
readonly data: unknown;
|
|
1400
|
+
}, {
|
|
1401
|
+
readonly type: Keys;
|
|
1365
1402
|
}> | Extract<{
|
|
1366
1403
|
readonly type: "text-start";
|
|
1367
1404
|
readonly id: string;
|
|
@@ -1667,6 +1704,10 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
1667
1704
|
};
|
|
1668
1705
|
} | undefined;
|
|
1669
1706
|
};
|
|
1707
|
+
raw: (u: unknown) => u is {
|
|
1708
|
+
readonly type: "raw";
|
|
1709
|
+
readonly data: unknown;
|
|
1710
|
+
};
|
|
1670
1711
|
"reasoning-delta": (u: unknown) => u is {
|
|
1671
1712
|
readonly type: "reasoning-delta";
|
|
1672
1713
|
readonly id: string;
|
|
@@ -2063,6 +2104,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
2063
2104
|
readonly message: Schema.String;
|
|
2064
2105
|
readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
|
|
2065
2106
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
2107
|
+
}> | Schema.Struct<{
|
|
2108
|
+
readonly type: Schema.tag<"raw">;
|
|
2109
|
+
readonly data: Schema.Unknown;
|
|
2066
2110
|
}> | (Schema.refine<{
|
|
2067
2111
|
readonly type: "compaction";
|
|
2068
2112
|
readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -2092,6 +2136,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
2092
2136
|
}) as M["Type"]["type"]]: (value: M["Type"]) => any; }>(value: {
|
|
2093
2137
|
readonly type: "step-start";
|
|
2094
2138
|
readonly index: number;
|
|
2139
|
+
} | {
|
|
2140
|
+
readonly type: "raw";
|
|
2141
|
+
readonly data: unknown;
|
|
2095
2142
|
} | {
|
|
2096
2143
|
readonly type: "text-start";
|
|
2097
2144
|
readonly id: string;
|
|
@@ -2512,6 +2559,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
2512
2559
|
readonly message: Schema.String;
|
|
2513
2560
|
readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
|
|
2514
2561
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
2562
|
+
}> | Schema.Struct<{
|
|
2563
|
+
readonly type: Schema.tag<"raw">;
|
|
2564
|
+
readonly data: Schema.Unknown;
|
|
2515
2565
|
}> | (Schema.refine<{
|
|
2516
2566
|
readonly type: "compaction";
|
|
2517
2567
|
readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -2541,6 +2591,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
2541
2591
|
}) as M["Type"]["type"]]: (value: M["Type"]) => any; }>(cases: Cases): (value: {
|
|
2542
2592
|
readonly type: "step-start";
|
|
2543
2593
|
readonly index: number;
|
|
2594
|
+
} | {
|
|
2595
|
+
readonly type: "raw";
|
|
2596
|
+
readonly data: unknown;
|
|
2544
2597
|
} | {
|
|
2545
2598
|
readonly type: "text-start";
|
|
2546
2599
|
readonly id: string;
|
|
@@ -2963,6 +3016,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
2963
3016
|
readonly message: Schema.String;
|
|
2964
3017
|
readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
|
|
2965
3018
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
3019
|
+
}> | Schema.Struct<{
|
|
3020
|
+
readonly type: Schema.tag<"raw">;
|
|
3021
|
+
readonly data: Schema.Unknown;
|
|
2966
3022
|
}> | (Schema.refine<{
|
|
2967
3023
|
readonly type: "compaction";
|
|
2968
3024
|
readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -2989,9 +3045,12 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
2989
3045
|
readonly text: string | null;
|
|
2990
3046
|
readonly encrypted?: never;
|
|
2991
3047
|
})) => CompactionPart;
|
|
2992
|
-
}) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
|
|
3048
|
+
}) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "raw" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
|
|
2993
3049
|
readonly type: "step-start";
|
|
2994
3050
|
readonly index: number;
|
|
3051
|
+
} | {
|
|
3052
|
+
readonly type: "raw";
|
|
3053
|
+
readonly data: unknown;
|
|
2995
3054
|
} | {
|
|
2996
3055
|
readonly type: "text-start";
|
|
2997
3056
|
readonly id: string;
|
|
@@ -3207,6 +3266,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
3207
3266
|
})), { readonly [K in "type"]: keyof Cases; }>) => any>(value: {
|
|
3208
3267
|
readonly type: "step-start";
|
|
3209
3268
|
readonly index: number;
|
|
3269
|
+
} | {
|
|
3270
|
+
readonly type: "raw";
|
|
3271
|
+
readonly data: unknown;
|
|
3210
3272
|
} | {
|
|
3211
3273
|
readonly type: "text-start";
|
|
3212
3274
|
readonly id: string;
|
|
@@ -3627,6 +3689,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
3627
3689
|
readonly message: Schema.String;
|
|
3628
3690
|
readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
|
|
3629
3691
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
3692
|
+
}> | Schema.Struct<{
|
|
3693
|
+
readonly type: Schema.tag<"raw">;
|
|
3694
|
+
readonly data: Schema.Unknown;
|
|
3630
3695
|
}> | (Schema.refine<{
|
|
3631
3696
|
readonly type: "compaction";
|
|
3632
3697
|
readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -3653,9 +3718,12 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
3653
3718
|
readonly text: string | null;
|
|
3654
3719
|
readonly encrypted?: never;
|
|
3655
3720
|
})) => CompactionPart;
|
|
3656
|
-
}) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
|
|
3721
|
+
}) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "raw" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
|
|
3657
3722
|
readonly type: "step-start";
|
|
3658
3723
|
readonly index: number;
|
|
3724
|
+
} | {
|
|
3725
|
+
readonly type: "raw";
|
|
3726
|
+
readonly data: unknown;
|
|
3659
3727
|
} | {
|
|
3660
3728
|
readonly type: "text-start";
|
|
3661
3729
|
readonly id: string;
|
|
@@ -3871,6 +3939,9 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
3871
3939
|
})), { readonly [K in "type"]: keyof Cases; }>) => any>(cases: Cases, orElse: OrElse): (value: {
|
|
3872
3940
|
readonly type: "step-start";
|
|
3873
3941
|
readonly index: number;
|
|
3942
|
+
} | {
|
|
3943
|
+
readonly type: "raw";
|
|
3944
|
+
readonly data: unknown;
|
|
3874
3945
|
} | {
|
|
3875
3946
|
readonly type: "text-start";
|
|
3876
3947
|
readonly id: string;
|
|
@@ -4352,6 +4423,13 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
4352
4423
|
};
|
|
4353
4424
|
} | undefined;
|
|
4354
4425
|
};
|
|
4426
|
+
raw: (input: {
|
|
4427
|
+
readonly type?: "raw" | undefined;
|
|
4428
|
+
readonly data: unknown;
|
|
4429
|
+
}, options?: Schema.MakeOptions) => {
|
|
4430
|
+
readonly type: "raw";
|
|
4431
|
+
readonly data: unknown;
|
|
4432
|
+
};
|
|
4355
4433
|
is: {
|
|
4356
4434
|
compaction: (u: unknown) => u is {
|
|
4357
4435
|
readonly type: "compaction";
|
|
@@ -4587,6 +4665,10 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
|
|
|
4587
4665
|
};
|
|
4588
4666
|
} | undefined;
|
|
4589
4667
|
};
|
|
4668
|
+
raw: (u: unknown) => u is {
|
|
4669
|
+
readonly type: "raw";
|
|
4670
|
+
readonly data: unknown;
|
|
4671
|
+
};
|
|
4590
4672
|
};
|
|
4591
4673
|
};
|
|
4592
4674
|
export type LLMEvent = Schema.Schema.Type<typeof llmEventTagged>;
|
|
@@ -4847,8 +4929,11 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
4847
4929
|
readonly message: Schema.String;
|
|
4848
4930
|
readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
|
|
4849
4931
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
4932
|
+
}>, Schema.Struct<{
|
|
4933
|
+
readonly type: Schema.tag<"raw">;
|
|
4934
|
+
readonly data: Schema.Unknown;
|
|
4850
4935
|
}>]> & {
|
|
4851
|
-
readonly discriminants: readonly ["compaction", "step-start", "text-start", "text-delta", "text-end", "reasoning-start", "reasoning-delta", "reasoning-end", "tool-input-start", "tool-input-delta", "tool-input-end", "tool-input-error", "tool-call", "tool-result", "tool-error", "media", "step-finish", "finish", "provider-error"];
|
|
4936
|
+
readonly discriminants: readonly ["compaction", "step-start", "text-start", "text-delta", "text-end", "reasoning-start", "reasoning-delta", "reasoning-end", "tool-input-start", "tool-input-delta", "tool-input-end", "tool-input-error", "tool-call", "tool-result", "tool-error", "media", "step-finish", "finish", "provider-error", "raw"];
|
|
4852
4937
|
readonly cases: {
|
|
4853
4938
|
compaction: Schema.refine<{
|
|
4854
4939
|
readonly type: "compaction";
|
|
@@ -4931,6 +5016,10 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
4931
5016
|
readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
|
|
4932
5017
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
4933
5018
|
}>;
|
|
5019
|
+
raw: Schema.Struct<{
|
|
5020
|
+
readonly type: Schema.tag<"raw">;
|
|
5021
|
+
readonly data: Schema.Unknown;
|
|
5022
|
+
}>;
|
|
4934
5023
|
"reasoning-delta": Schema.Struct<{
|
|
4935
5024
|
readonly type: Schema.tag<"reasoning-delta">;
|
|
4936
5025
|
readonly id: Schema.String;
|
|
@@ -5106,6 +5195,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
5106
5195
|
readonly isAnyOf: <const Keys>(keys: readonly Keys[]) => (value: {
|
|
5107
5196
|
readonly type: "step-start";
|
|
5108
5197
|
readonly index: number;
|
|
5198
|
+
} | {
|
|
5199
|
+
readonly type: "raw";
|
|
5200
|
+
readonly data: unknown;
|
|
5109
5201
|
} | {
|
|
5110
5202
|
readonly type: "text-start";
|
|
5111
5203
|
readonly id: string;
|
|
@@ -5323,6 +5415,11 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
5323
5415
|
readonly index: number;
|
|
5324
5416
|
}, {
|
|
5325
5417
|
readonly type: Keys;
|
|
5418
|
+
}> | Extract<{
|
|
5419
|
+
readonly type: "raw";
|
|
5420
|
+
readonly data: unknown;
|
|
5421
|
+
}, {
|
|
5422
|
+
readonly type: Keys;
|
|
5326
5423
|
}> | Extract<{
|
|
5327
5424
|
readonly type: "text-start";
|
|
5328
5425
|
readonly id: string;
|
|
@@ -5628,6 +5725,10 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
5628
5725
|
};
|
|
5629
5726
|
} | undefined;
|
|
5630
5727
|
};
|
|
5728
|
+
raw: (u: unknown) => u is {
|
|
5729
|
+
readonly type: "raw";
|
|
5730
|
+
readonly data: unknown;
|
|
5731
|
+
};
|
|
5631
5732
|
"reasoning-delta": (u: unknown) => u is {
|
|
5632
5733
|
readonly type: "reasoning-delta";
|
|
5633
5734
|
readonly id: string;
|
|
@@ -6024,6 +6125,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
6024
6125
|
readonly message: Schema.String;
|
|
6025
6126
|
readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
|
|
6026
6127
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
6128
|
+
}> | Schema.Struct<{
|
|
6129
|
+
readonly type: Schema.tag<"raw">;
|
|
6130
|
+
readonly data: Schema.Unknown;
|
|
6027
6131
|
}> | (Schema.refine<{
|
|
6028
6132
|
readonly type: "compaction";
|
|
6029
6133
|
readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -6053,6 +6157,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
6053
6157
|
}) as M["Type"]["type"]]: (value: M["Type"]) => any; }>(value: {
|
|
6054
6158
|
readonly type: "step-start";
|
|
6055
6159
|
readonly index: number;
|
|
6160
|
+
} | {
|
|
6161
|
+
readonly type: "raw";
|
|
6162
|
+
readonly data: unknown;
|
|
6056
6163
|
} | {
|
|
6057
6164
|
readonly type: "text-start";
|
|
6058
6165
|
readonly id: string;
|
|
@@ -6473,6 +6580,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
6473
6580
|
readonly message: Schema.String;
|
|
6474
6581
|
readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
|
|
6475
6582
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
6583
|
+
}> | Schema.Struct<{
|
|
6584
|
+
readonly type: Schema.tag<"raw">;
|
|
6585
|
+
readonly data: Schema.Unknown;
|
|
6476
6586
|
}> | (Schema.refine<{
|
|
6477
6587
|
readonly type: "compaction";
|
|
6478
6588
|
readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -6502,6 +6612,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
6502
6612
|
}) as M["Type"]["type"]]: (value: M["Type"]) => any; }>(cases: Cases): (value: {
|
|
6503
6613
|
readonly type: "step-start";
|
|
6504
6614
|
readonly index: number;
|
|
6615
|
+
} | {
|
|
6616
|
+
readonly type: "raw";
|
|
6617
|
+
readonly data: unknown;
|
|
6505
6618
|
} | {
|
|
6506
6619
|
readonly type: "text-start";
|
|
6507
6620
|
readonly id: string;
|
|
@@ -6924,6 +7037,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
6924
7037
|
readonly message: Schema.String;
|
|
6925
7038
|
readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
|
|
6926
7039
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
7040
|
+
}> | Schema.Struct<{
|
|
7041
|
+
readonly type: Schema.tag<"raw">;
|
|
7042
|
+
readonly data: Schema.Unknown;
|
|
6927
7043
|
}> | (Schema.refine<{
|
|
6928
7044
|
readonly type: "compaction";
|
|
6929
7045
|
readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -6950,9 +7066,12 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
6950
7066
|
readonly text: string | null;
|
|
6951
7067
|
readonly encrypted?: never;
|
|
6952
7068
|
})) => CompactionPart;
|
|
6953
|
-
}) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
|
|
7069
|
+
}) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "raw" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
|
|
6954
7070
|
readonly type: "step-start";
|
|
6955
7071
|
readonly index: number;
|
|
7072
|
+
} | {
|
|
7073
|
+
readonly type: "raw";
|
|
7074
|
+
readonly data: unknown;
|
|
6956
7075
|
} | {
|
|
6957
7076
|
readonly type: "text-start";
|
|
6958
7077
|
readonly id: string;
|
|
@@ -7168,6 +7287,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
7168
7287
|
})), { readonly [K in "type"]: keyof Cases; }>) => any>(value: {
|
|
7169
7288
|
readonly type: "step-start";
|
|
7170
7289
|
readonly index: number;
|
|
7290
|
+
} | {
|
|
7291
|
+
readonly type: "raw";
|
|
7292
|
+
readonly data: unknown;
|
|
7171
7293
|
} | {
|
|
7172
7294
|
readonly type: "text-start";
|
|
7173
7295
|
readonly id: string;
|
|
@@ -7588,6 +7710,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
7588
7710
|
readonly message: Schema.String;
|
|
7589
7711
|
readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
|
|
7590
7712
|
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
7713
|
+
}> | Schema.Struct<{
|
|
7714
|
+
readonly type: Schema.tag<"raw">;
|
|
7715
|
+
readonly data: Schema.Unknown;
|
|
7591
7716
|
}> | (Schema.refine<{
|
|
7592
7717
|
readonly type: "compaction";
|
|
7593
7718
|
readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -7614,9 +7739,12 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
7614
7739
|
readonly text: string | null;
|
|
7615
7740
|
readonly encrypted?: never;
|
|
7616
7741
|
})) => CompactionPart;
|
|
7617
|
-
}) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
|
|
7742
|
+
}) as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "compaction" | "finish" | "media" | "provider-error" | "raw" | "reasoning-delta" | "reasoning-end" | "reasoning-start" | "step-finish" | "step-start" | "text-delta" | "text-end" | "text-start" | "tool-call" | "tool-error" | "tool-input-delta" | "tool-input-end" | "tool-input-error" | "tool-input-start" | "tool-result">]: never; }, OrElse extends (value: Exclude<{
|
|
7618
7743
|
readonly type: "step-start";
|
|
7619
7744
|
readonly index: number;
|
|
7745
|
+
} | {
|
|
7746
|
+
readonly type: "raw";
|
|
7747
|
+
readonly data: unknown;
|
|
7620
7748
|
} | {
|
|
7621
7749
|
readonly type: "text-start";
|
|
7622
7750
|
readonly id: string;
|
|
@@ -7832,6 +7960,9 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
7832
7960
|
})), { readonly [K in "type"]: keyof Cases; }>) => any>(cases: Cases, orElse: OrElse): (value: {
|
|
7833
7961
|
readonly type: "step-start";
|
|
7834
7962
|
readonly index: number;
|
|
7963
|
+
} | {
|
|
7964
|
+
readonly type: "raw";
|
|
7965
|
+
readonly data: unknown;
|
|
7835
7966
|
} | {
|
|
7836
7967
|
readonly type: "text-start";
|
|
7837
7968
|
readonly id: string;
|
|
@@ -8313,6 +8444,13 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
8313
8444
|
};
|
|
8314
8445
|
} | undefined;
|
|
8315
8446
|
};
|
|
8447
|
+
raw: (input: {
|
|
8448
|
+
readonly type?: "raw" | undefined;
|
|
8449
|
+
readonly data: unknown;
|
|
8450
|
+
}, options?: Schema.MakeOptions) => {
|
|
8451
|
+
readonly type: "raw";
|
|
8452
|
+
readonly data: unknown;
|
|
8453
|
+
};
|
|
8316
8454
|
is: {
|
|
8317
8455
|
compaction: (u: unknown) => u is {
|
|
8318
8456
|
readonly type: "compaction";
|
|
@@ -8548,6 +8686,10 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
|
|
|
8548
8686
|
};
|
|
8549
8687
|
} | undefined;
|
|
8550
8688
|
};
|
|
8689
|
+
raw: (u: unknown) => u is {
|
|
8690
|
+
readonly type: "raw";
|
|
8691
|
+
readonly data: unknown;
|
|
8692
|
+
};
|
|
8551
8693
|
};
|
|
8552
8694
|
}>;
|
|
8553
8695
|
readonly usage: Schema.optional<typeof Usage>;
|
package/dist/schema/events.js
CHANGED
|
@@ -61,6 +61,12 @@ export class Usage extends Schema.Class("AI.Usage")({
|
|
|
61
61
|
cacheWriteInputTokens: Schema.optional(Schema.Number),
|
|
62
62
|
reasoningTokens: Schema.optional(Schema.Number),
|
|
63
63
|
totalTokens: Schema.optional(Schema.Number),
|
|
64
|
+
/**
|
|
65
|
+
* USD the endpoint says it charged for this request, as OpenRouter, LiteLLM and OpenCode Zen report it in
|
|
66
|
+
* `usage.cost`. `0` is authoritative: the request was free or a subscription covered it. Absent, callers price the
|
|
67
|
+
* tokens themselves.
|
|
68
|
+
*/
|
|
69
|
+
cost: Schema.optional(Schema.Number),
|
|
64
70
|
providerMetadata: Schema.optional(ProviderMetadata),
|
|
65
71
|
}) {
|
|
66
72
|
/**
|
|
@@ -95,6 +101,10 @@ export const MediaUsage = Schema.Union([
|
|
|
95
101
|
])
|
|
96
102
|
.pipe(Schema.toTaggedUnion("type"))
|
|
97
103
|
.annotate({ identifier: "AI.MediaUsage" });
|
|
104
|
+
/** Token usage from a provider's counts. A usage object without any count is no usage, so it returns undefined. */
|
|
105
|
+
export const tokenUsage = (counts) => counts.input === undefined && counts.output === undefined && counts.total === undefined
|
|
106
|
+
? undefined
|
|
107
|
+
: { type: "tokens", ...counts };
|
|
98
108
|
/** A replacement context window, not an assistant message to append to prior history. */
|
|
99
109
|
export class CompactionResponse extends Schema.Class("LLM.CompactionResponse")({
|
|
100
110
|
replacement: Schema.Array(Message),
|
|
@@ -241,6 +251,11 @@ export const ProviderErrorEvent = Schema.Struct({
|
|
|
241
251
|
classification: Schema.optional(ProviderFailureClassification),
|
|
242
252
|
providerMetadata: Schema.optional(ProviderMetadata),
|
|
243
253
|
}).annotate({ identifier: "LLM.Event.ProviderError" });
|
|
254
|
+
/** One provider frame as received, emitted before the events parsed from it when the request sets `includeRaw`. */
|
|
255
|
+
export const RawEvent = Schema.Struct({
|
|
256
|
+
type: Schema.tag("raw"),
|
|
257
|
+
data: Schema.Unknown,
|
|
258
|
+
}).annotate({ identifier: "LLM.Event.Raw" });
|
|
244
259
|
const llmEventTagged = Schema.Union([
|
|
245
260
|
CompactionPart,
|
|
246
261
|
StepStart,
|
|
@@ -261,6 +276,7 @@ const llmEventTagged = Schema.Union([
|
|
|
261
276
|
StepFinish,
|
|
262
277
|
Finish,
|
|
263
278
|
ProviderErrorEvent,
|
|
279
|
+
RawEvent,
|
|
264
280
|
]).pipe(Schema.toTaggedUnion("type"));
|
|
265
281
|
const contentBlockID = (value) => ContentBlockID.make(value);
|
|
266
282
|
const toolCallID = (value) => ToolCallID.make(value);
|
|
@@ -299,6 +315,7 @@ export const LLMEvent = Object.assign(llmEventTagged, {
|
|
|
299
315
|
usage: input.usage === undefined ? undefined : Usage.from(input.usage),
|
|
300
316
|
}),
|
|
301
317
|
providerError: ProviderErrorEvent.make,
|
|
318
|
+
raw: RawEvent.make,
|
|
302
319
|
is: {
|
|
303
320
|
compaction: llmEventTagged.guards.compaction,
|
|
304
321
|
stepStart: llmEventTagged.guards["step-start"],
|
|
@@ -319,6 +336,7 @@ export const LLMEvent = Object.assign(llmEventTagged, {
|
|
|
319
336
|
stepFinish: llmEventTagged.guards["step-finish"],
|
|
320
337
|
finish: llmEventTagged.guards.finish,
|
|
321
338
|
providerError: llmEventTagged.guards["provider-error"],
|
|
339
|
+
raw: llmEventTagged.guards.raw,
|
|
322
340
|
},
|
|
323
341
|
});
|
|
324
342
|
/** Joins deltas per fragment, letting an authoritative end value replace that fragment's accumulated deltas. */
|
|
@@ -503,6 +521,8 @@ const reduceToolCall = (state, event) => {
|
|
|
503
521
|
return { ...appendContent(state, toolCallContent(event)), toolInputs };
|
|
504
522
|
};
|
|
505
523
|
const reduceResponseState = (state, event) => {
|
|
524
|
+
if (event.type === "raw")
|
|
525
|
+
return state;
|
|
506
526
|
const next = appendEvent(state, event);
|
|
507
527
|
switch (event.type) {
|
|
508
528
|
case "compaction":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { Tool } from "@opencode/schema/tool";
|
|
3
|
-
import { CacheHint, GenerationOptions, HttpOptions, type LanguageModel, ReasoningEffort } from "./options.js";
|
|
3
|
+
import { CacheHint, GenerationOptions, HttpOptions, JsonSchema, type LanguageModel, ReasoningEffort } from "./options.js";
|
|
4
4
|
import { Media } from "../media.js";
|
|
5
5
|
export declare const MessageRole: Schema.Literals<readonly ["system", "user", "assistant", "tool"]>;
|
|
6
6
|
export type MessageRole = Schema.Schema.Type<typeof MessageRole>;
|
|
@@ -598,11 +598,34 @@ export declare namespace Message {
|
|
|
598
598
|
}) => Message;
|
|
599
599
|
const tool: (result: ToolResultPart | Parameters<typeof ToolResultPart.make>[0]) => Message;
|
|
600
600
|
}
|
|
601
|
+
/**
|
|
602
|
+
* Raw-text wire encoding for a tool with exactly one required string parameter. Models that accept the format
|
|
603
|
+
* write that parameter's value directly instead of JSON arguments; calls still decode to the normal object input.
|
|
604
|
+
*/
|
|
605
|
+
export declare const Freeform: Schema.Union<readonly [Schema.Struct<{
|
|
606
|
+
readonly type: Schema.Literal<"text">;
|
|
607
|
+
}>, Schema.Struct<{
|
|
608
|
+
readonly type: Schema.Literal<"regex">;
|
|
609
|
+
readonly pattern: Schema.String;
|
|
610
|
+
}>, Schema.Struct<{
|
|
611
|
+
readonly type: Schema.Literal<"lark">;
|
|
612
|
+
readonly grammar: Schema.String;
|
|
613
|
+
}>]>;
|
|
614
|
+
export type Freeform = Schema.Schema.Type<typeof Freeform>;
|
|
601
615
|
declare const toolDefinitionFields: {
|
|
602
616
|
name: Schema.String;
|
|
603
617
|
description: Schema.String;
|
|
604
618
|
inputSchema: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
605
619
|
outputSchema: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
620
|
+
freeform: Schema.optional<Schema.Union<readonly [Schema.Struct<{
|
|
621
|
+
readonly type: Schema.Literal<"text">;
|
|
622
|
+
}>, Schema.Struct<{
|
|
623
|
+
readonly type: Schema.Literal<"regex">;
|
|
624
|
+
readonly pattern: Schema.String;
|
|
625
|
+
}>, Schema.Struct<{
|
|
626
|
+
readonly type: Schema.Literal<"lark">;
|
|
627
|
+
readonly grammar: Schema.String;
|
|
628
|
+
}>]>>;
|
|
606
629
|
cache: Schema.optional<typeof CacheHint>;
|
|
607
630
|
metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
608
631
|
native: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
@@ -613,6 +636,15 @@ declare const ToolDefinition_base: Schema.Class<ToolDefinition, Schema.Struct<{
|
|
|
613
636
|
readonly description: Schema.String;
|
|
614
637
|
readonly inputSchema: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
615
638
|
readonly outputSchema: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
639
|
+
readonly freeform: Schema.optional<Schema.Union<readonly [Schema.Struct<{
|
|
640
|
+
readonly type: Schema.Literal<"text">;
|
|
641
|
+
}>, Schema.Struct<{
|
|
642
|
+
readonly type: Schema.Literal<"regex">;
|
|
643
|
+
readonly pattern: Schema.String;
|
|
644
|
+
}>, Schema.Struct<{
|
|
645
|
+
readonly type: Schema.Literal<"lark">;
|
|
646
|
+
readonly grammar: Schema.String;
|
|
647
|
+
}>]>>;
|
|
616
648
|
readonly cache: Schema.optional<typeof CacheHint>;
|
|
617
649
|
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
618
650
|
readonly native: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
@@ -625,6 +657,8 @@ export declare namespace ToolDefinition {
|
|
|
625
657
|
type Input = ToolDefinition | ToolDefinitionInput;
|
|
626
658
|
/** Normalize tool definition input into the canonical `ToolDefinition` class. */
|
|
627
659
|
const make: (input: Input) => ToolDefinition;
|
|
660
|
+
/** The parameter a freeform call fills: the input schema's only property, when it is a required string. */
|
|
661
|
+
const freeformField: (schema: JsonSchema) => string | undefined;
|
|
628
662
|
}
|
|
629
663
|
export type ToolNamespace = {
|
|
630
664
|
readonly type: "namespace";
|
|
@@ -691,10 +725,12 @@ declare const requestSchema: Schema.Struct<{
|
|
|
691
725
|
readonly messages: Schema.optional<Schema.Union<readonly [Schema.Literal<"latest-user-message">, Schema.Literal<"latest-assistant">, Schema.Struct<{
|
|
692
726
|
readonly tail: Schema.Natural;
|
|
693
727
|
}>]>>;
|
|
694
|
-
readonly
|
|
728
|
+
readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
|
|
695
729
|
}>]>>;
|
|
696
730
|
readonly promptCacheKey: Schema.optional<Schema.String>;
|
|
697
731
|
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
732
|
+
/** Emit a `raw` event with each provider frame before the events parsed from it. */
|
|
733
|
+
readonly includeRaw: Schema.optional<Schema.Boolean>;
|
|
698
734
|
}>;
|
|
699
735
|
declare const LLMRequest_base: Schema.Class<LLMRequest<LanguageModel<{
|
|
700
736
|
readonly [x: string]: unknown;
|
|
@@ -728,10 +764,12 @@ declare const LLMRequest_base: Schema.Class<LLMRequest<LanguageModel<{
|
|
|
728
764
|
readonly messages: Schema.optional<Schema.Union<readonly [Schema.Literal<"latest-user-message">, Schema.Literal<"latest-assistant">, Schema.Struct<{
|
|
729
765
|
readonly tail: Schema.Natural;
|
|
730
766
|
}>]>>;
|
|
731
|
-
readonly
|
|
767
|
+
readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
|
|
732
768
|
}>]>>;
|
|
733
769
|
readonly promptCacheKey: Schema.optional<Schema.String>;
|
|
734
770
|
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
771
|
+
/** Emit a `raw` event with each provider frame before the events parsed from it. */
|
|
772
|
+
readonly includeRaw: Schema.optional<Schema.Boolean>;
|
|
735
773
|
}>, {}>;
|
|
736
774
|
export declare class LLMRequest<Model extends LanguageModel = LanguageModel> extends LLMRequest_base {
|
|
737
775
|
readonly model: Model;
|
package/dist/schema/messages.js
CHANGED
|
@@ -202,11 +202,21 @@ export class Message extends Schema.Class("LLM.Message")({
|
|
|
202
202
|
Message.effort = (input) => Message.make({ role: "system", content: [{ type: "effort", effort: input.effort, previous: input.previous }] });
|
|
203
203
|
Message.tool = (result) => Message.make({ role: "tool", content: ["type" in result ? result : ToolResultPart.make(result)] });
|
|
204
204
|
})(Message || (Message = {}));
|
|
205
|
+
/**
|
|
206
|
+
* Raw-text wire encoding for a tool with exactly one required string parameter. Models that accept the format
|
|
207
|
+
* write that parameter's value directly instead of JSON arguments; calls still decode to the normal object input.
|
|
208
|
+
*/
|
|
209
|
+
export const Freeform = Schema.Union([
|
|
210
|
+
Schema.Struct({ type: Schema.Literal("text") }),
|
|
211
|
+
Schema.Struct({ type: Schema.Literal("regex"), pattern: Schema.String }),
|
|
212
|
+
Schema.Struct({ type: Schema.Literal("lark"), grammar: Schema.String }),
|
|
213
|
+
]).annotate({ identifier: "LLM.Freeform" });
|
|
205
214
|
const toolDefinitionFields = {
|
|
206
215
|
name: Schema.String,
|
|
207
216
|
description: Schema.String,
|
|
208
217
|
inputSchema: JsonSchema,
|
|
209
218
|
outputSchema: Schema.optional(JsonSchema),
|
|
219
|
+
freeform: Schema.optional(Freeform),
|
|
210
220
|
cache: Schema.optional(CacheHint),
|
|
211
221
|
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
212
222
|
native: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
@@ -222,6 +232,16 @@ export class ToolDefinition extends Schema.Class("LLM.ToolDefinition")({
|
|
|
222
232
|
(function (ToolDefinition) {
|
|
223
233
|
/** Normalize tool definition input into the canonical `ToolDefinition` class. */
|
|
224
234
|
ToolDefinition.make = (input) => (input instanceof ToolDefinition ? input : new ToolDefinition(input));
|
|
235
|
+
/** The parameter a freeform call fills: the input schema's only property, when it is a required string. */
|
|
236
|
+
ToolDefinition.freeformField = (schema) => {
|
|
237
|
+
const properties = Object.entries(Schema.is(JsonSchema)(schema.properties) ? schema.properties : {});
|
|
238
|
+
if (properties.length !== 1)
|
|
239
|
+
return undefined;
|
|
240
|
+
const [name, property] = properties[0];
|
|
241
|
+
if (!Schema.is(JsonSchema)(property) || property.type !== "string")
|
|
242
|
+
return undefined;
|
|
243
|
+
return Array.isArray(schema.required) && schema.required.includes(name) ? name : undefined;
|
|
244
|
+
};
|
|
225
245
|
})(ToolDefinition || (ToolDefinition = {}));
|
|
226
246
|
export const ToolNamespace = withStatics(Schema.Struct({
|
|
227
247
|
type: Schema.Literal("namespace"),
|
|
@@ -273,6 +293,8 @@ const requestSchema = Schema.Struct({
|
|
|
273
293
|
// Stable cache affinity for protocols that support provider-managed prompt caching.
|
|
274
294
|
promptCacheKey: Schema.optional(Schema.String),
|
|
275
295
|
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
296
|
+
/** Emit a `raw` event with each provider frame before the events parsed from it. */
|
|
297
|
+
includeRaw: Schema.optional(Schema.Boolean),
|
|
276
298
|
});
|
|
277
299
|
export class LLMRequest extends Schema.Class("LLM.Request")(requestSchema.fields) {
|
|
278
300
|
// Preserve model inference instead of inheriting the schema's erased constructor signature.
|
|
@@ -295,6 +317,7 @@ export class LLMRequest extends Schema.Class("LLM.Request")(requestSchema.fields
|
|
|
295
317
|
cache: request.cache,
|
|
296
318
|
promptCacheKey: request.promptCacheKey,
|
|
297
319
|
metadata: request.metadata,
|
|
320
|
+
includeRaw: request.includeRaw,
|
|
298
321
|
});
|
|
299
322
|
function update(request, patch) {
|
|
300
323
|
if (Object.keys(patch).length === 0)
|