@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
|
@@ -7,14 +7,17 @@ import { Endpoint } from "../route/endpoint.js";
|
|
|
7
7
|
import { Protocol } from "../route/protocol.js";
|
|
8
8
|
import { HttpTransport } from "../route/transport/index.js";
|
|
9
9
|
import { LLMRequest } from "../schema/index.js";
|
|
10
|
+
import { requestTTL } from "../cache-policy.js";
|
|
10
11
|
import { resolveEffortUpdates } from "../effort-updates.js";
|
|
11
12
|
import { OpenResponses } from "./open-responses.js";
|
|
12
13
|
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
13
|
-
import { JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared.js";
|
|
14
|
+
import { JsonObject, lenient, optionalArray, optionalNull, ProviderShared } from "./shared.js";
|
|
14
15
|
import { ResponsesHostedTools } from "./utils/responses-hosted-tools.js";
|
|
15
16
|
import { OpenResponsesChannel } from "./open-responses-channel.js";
|
|
16
17
|
import { ResponsesCompaction } from "./utils/responses-compaction.js";
|
|
17
18
|
import { ResponsesCheckpoint } from "./utils/responses-checkpoint.js";
|
|
19
|
+
import * as Cache from "./utils/cache.js";
|
|
20
|
+
import { OpenAIFreeform } from "./openai-freeform.js";
|
|
18
21
|
const ADAPTER = "openai-responses";
|
|
19
22
|
const NAME = "OpenAI Responses";
|
|
20
23
|
const WEBSOCKET_PROTOCOL_HEADER = "responses_websockets=2026-02-06";
|
|
@@ -25,6 +28,12 @@ export const ContextManagement = Schema.Array(Schema.Struct({
|
|
|
25
28
|
type: Schema.Literal("compaction"),
|
|
26
29
|
compactThreshold: Schema.optional(Schema.Int.check(Schema.isGreaterThan(0))),
|
|
27
30
|
}));
|
|
31
|
+
export const ReasoningMode = ProviderShared.knownString();
|
|
32
|
+
export const ReasoningContext = ProviderShared.knownString();
|
|
33
|
+
const ReasoningOptions = Schema.Struct({
|
|
34
|
+
reasoningMode: lenient(ReasoningMode),
|
|
35
|
+
reasoningContext: lenient(ReasoningContext),
|
|
36
|
+
});
|
|
28
37
|
const OpenAIResponsesImageGenerationTool = Schema.Struct({
|
|
29
38
|
type: Schema.tag("image_generation"),
|
|
30
39
|
action: Schema.optional(Schema.Literals(["auto", "generate", "edit"])),
|
|
@@ -75,6 +84,7 @@ const OpenAIResponsesNamespace = Schema.Struct({
|
|
|
75
84
|
});
|
|
76
85
|
const OpenAIResponsesTools = Schema.Union([
|
|
77
86
|
OpenResponses.Tool,
|
|
87
|
+
OpenResponses.CustomTool,
|
|
78
88
|
OpenAIResponsesNamespace,
|
|
79
89
|
OpenAIResponsesImageGenerationTool,
|
|
80
90
|
]);
|
|
@@ -84,8 +94,16 @@ const OpenAIResponsesToolChoice = Schema.Union([
|
|
|
84
94
|
]);
|
|
85
95
|
const OpenAIResponsesCoreFields = {
|
|
86
96
|
...OpenResponses.coreFields,
|
|
97
|
+
prompt_cache_retention: Schema.optional(Schema.String),
|
|
98
|
+
prompt_cache_options: Schema.optional(Schema.Struct({ ttl: Schema.optional(Schema.String) })),
|
|
87
99
|
tools: optionalArray(OpenAIResponsesTools),
|
|
88
100
|
tool_choice: Schema.optional(OpenAIResponsesToolChoice),
|
|
101
|
+
reasoning: Schema.optional(Schema.Struct({
|
|
102
|
+
effort: Schema.optional(OpenResponsesOptions.ReasoningEffort),
|
|
103
|
+
summary: Schema.optional(Schema.Literals(["auto", "concise", "detailed"])),
|
|
104
|
+
mode: Schema.optional(ReasoningMode),
|
|
105
|
+
context: Schema.optional(ReasoningContext),
|
|
106
|
+
})),
|
|
89
107
|
context_management: Schema.optional(Schema.Array(Schema.Struct({
|
|
90
108
|
type: Schema.Literal("compaction"),
|
|
91
109
|
compact_threshold: Schema.optional(Schema.Int.check(Schema.isGreaterThan(0))),
|
|
@@ -111,6 +129,8 @@ const adapter = {
|
|
|
111
129
|
const supportsEffortUpdates = (request) => {
|
|
112
130
|
if (request.providerOptions?.contextManagement !== undefined)
|
|
113
131
|
return false;
|
|
132
|
+
if (request.providerOptions?.reasoningMode === "pro")
|
|
133
|
+
return false;
|
|
114
134
|
if (Schema.is(Schema.Struct({ mode: Schema.Literal("pro") }))(request.http?.body?.reasoning))
|
|
115
135
|
return false;
|
|
116
136
|
const override = request.model.compatibility?.supportsEffortUpdates;
|
|
@@ -127,20 +147,23 @@ const nativeImageTool = (tool) => {
|
|
|
127
147
|
const native = nativeImageToolInput(tool);
|
|
128
148
|
return Schema.is(OpenAIResponsesImageGenerationTool)(native) ? native : undefined;
|
|
129
149
|
};
|
|
130
|
-
const lowerTool = Effect.fnUntraced(function* (tool) {
|
|
150
|
+
const lowerTool = Effect.fnUntraced(function* (tool, custom) {
|
|
131
151
|
const native = nativeImageToolInput(tool);
|
|
132
152
|
if (native !== undefined) {
|
|
133
153
|
if (Schema.is(OpenAIResponsesImageGenerationTool)(native))
|
|
134
154
|
return native;
|
|
135
155
|
return yield* ProviderShared.invalidRequest("OpenAI Responses image generation tool options are invalid");
|
|
136
156
|
}
|
|
157
|
+
const definition = custom.get(tool.name);
|
|
158
|
+
if (definition)
|
|
159
|
+
return OpenResponses.lowerCustomTool(tool, definition);
|
|
137
160
|
return yield* OpenResponses.lowerTool(NAME, tool);
|
|
138
161
|
});
|
|
139
162
|
// Native namespaces hold only function tools, so deeper levels flatten into
|
|
140
163
|
// the leaf names the same way non-native protocols flatten the whole tree.
|
|
141
|
-
const lowerToolEntry = Effect.fnUntraced(function* (tool) {
|
|
164
|
+
const lowerToolEntry = Effect.fnUntraced(function* (tool, custom) {
|
|
142
165
|
if (tool.type === "tool")
|
|
143
|
-
return yield* lowerTool(tool);
|
|
166
|
+
return yield* lowerTool(tool, custom);
|
|
144
167
|
// OpenAI requires a namespace description; fall back to a generic one so a
|
|
145
168
|
// missing description never blocks the request.
|
|
146
169
|
return {
|
|
@@ -150,28 +173,44 @@ const lowerToolEntry = Effect.fnUntraced(function* (tool) {
|
|
|
150
173
|
tools: yield* Effect.forEach(ProviderShared.flattenTools(tool.tools), (leaf) => OpenResponses.lowerTool(NAME, leaf)),
|
|
151
174
|
};
|
|
152
175
|
});
|
|
153
|
-
const lowerTools = (request) =>
|
|
154
|
-
const
|
|
176
|
+
const lowerTools = (request) => {
|
|
177
|
+
const custom = OpenAIFreeform.tools(request);
|
|
178
|
+
return Effect.forEach(request.tools, (tool) => lowerToolEntry(tool, custom));
|
|
179
|
+
};
|
|
180
|
+
const lowerToolChoice = (toolChoice, tools, custom) => ProviderShared.matchToolChoice(NAME, toolChoice, {
|
|
155
181
|
auto: () => "auto",
|
|
156
182
|
none: () => "none",
|
|
157
183
|
required: () => "required",
|
|
158
184
|
tool: (name) => tools.some((tool) => tool.type === "tool" && tool.name === name && nativeImageTool(tool) !== undefined)
|
|
159
185
|
? { type: "image_generation" }
|
|
160
|
-
:
|
|
186
|
+
: OpenResponses.namedTool(name, custom),
|
|
161
187
|
});
|
|
162
188
|
const fromRequest = Effect.fn("OpenAIResponses.fromRequest")(function* (request) {
|
|
163
189
|
const management = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Schema.UndefinedOr(ContextManagement)))(request.providerOptions?.contextManagement);
|
|
164
190
|
const options = OpenResponsesOptions.resolve(request);
|
|
191
|
+
const reasoning = Schema.decodeUnknownSync(ReasoningOptions)(request.providerOptions ?? {});
|
|
165
192
|
const updates = resolveEffortUpdates(request, options.reasoningEffort);
|
|
193
|
+
const generation = OpenResponses.lowerGeneration(request, { ...options, reasoningEffort: updates.effort });
|
|
194
|
+
const custom = OpenAIFreeform.tools(request);
|
|
166
195
|
return {
|
|
167
196
|
...(yield* OpenResponses.lowerConversation(updates.request, adapter)),
|
|
168
|
-
...
|
|
197
|
+
...generation,
|
|
198
|
+
...Cache.openAIRequestTTL(requestTTL(request)),
|
|
199
|
+
...(generation.reasoning || reasoning.reasoningMode || reasoning.reasoningContext
|
|
200
|
+
? {
|
|
201
|
+
reasoning: {
|
|
202
|
+
...generation.reasoning,
|
|
203
|
+
mode: reasoning.reasoningMode,
|
|
204
|
+
context: reasoning.reasoningContext,
|
|
205
|
+
},
|
|
206
|
+
}
|
|
207
|
+
: {}),
|
|
169
208
|
context_management: management?.map((edit) => ({ type: edit.type, compact_threshold: edit.compactThreshold })),
|
|
170
209
|
tools: request.tools.length === 0 ? undefined : yield* lowerTools(request),
|
|
171
210
|
tool_choice: request.tools.length === 0
|
|
172
211
|
? undefined
|
|
173
|
-
: (OpenResponses.allowedToolChoice(
|
|
174
|
-
(request.toolChoice ? yield* lowerToolChoice(request.toolChoice, request.tools) : undefined)),
|
|
212
|
+
: (OpenResponses.allowedToolChoice(options, custom) ??
|
|
213
|
+
(request.toolChoice ? yield* lowerToolChoice(request.toolChoice, request.tools, custom) : undefined)),
|
|
175
214
|
};
|
|
176
215
|
});
|
|
177
216
|
const checkpointBody = {
|
|
@@ -57,15 +57,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
|
57
57
|
readonly [x: string]: unknown;
|
|
58
58
|
} | undefined;
|
|
59
59
|
} | undefined;
|
|
60
|
-
readonly notices?: readonly {
|
|
61
|
-
readonly type: "filtered" | "moderated" | "other";
|
|
62
|
-
readonly message: string;
|
|
63
|
-
readonly providerMetadata?: {
|
|
64
|
-
readonly [x: string]: {
|
|
65
|
-
readonly [x: string]: unknown;
|
|
66
|
-
};
|
|
67
|
-
} | undefined;
|
|
68
|
-
}[] | undefined;
|
|
69
60
|
readonly providerMetadata?: {
|
|
70
61
|
readonly [x: string]: {
|
|
71
62
|
readonly [x: string]: unknown;
|
|
@@ -116,15 +107,6 @@ export declare const OpenAISpeech: {
|
|
|
116
107
|
readonly [x: string]: unknown;
|
|
117
108
|
} | undefined;
|
|
118
109
|
} | undefined;
|
|
119
|
-
readonly notices?: readonly {
|
|
120
|
-
readonly type: "filtered" | "moderated" | "other";
|
|
121
|
-
readonly message: string;
|
|
122
|
-
readonly providerMetadata?: {
|
|
123
|
-
readonly [x: string]: {
|
|
124
|
-
readonly [x: string]: unknown;
|
|
125
|
-
};
|
|
126
|
-
} | undefined;
|
|
127
|
-
}[] | undefined;
|
|
128
110
|
readonly providerMetadata?: {
|
|
129
111
|
readonly [x: string]: {
|
|
130
112
|
readonly [x: string]: unknown;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect";
|
|
1
|
+
import { Effect, Schema, SchemaGetter } from "effect";
|
|
2
2
|
import { Framing } from "../route/framing.js";
|
|
3
3
|
import { MediaProtocol } from "../route/media-protocol.js";
|
|
4
4
|
import { MediaRoute } from "../route/media.js";
|
|
5
|
-
import { mergeJsonRecords } from "../schema/index.js";
|
|
5
|
+
import { mergeJsonRecords, tokenUsage } from "../schema/index.js";
|
|
6
6
|
import { SpeechModel } from "../speech.js";
|
|
7
7
|
import { SpeechStream } from "./utils/speech-stream.js";
|
|
8
8
|
const route = MediaProtocol.identity({ id: "openai-speech", name: "OpenAI Speech", provider: "openai" });
|
|
@@ -13,6 +13,14 @@ const PCM_SAMPLE_RATE = 24000;
|
|
|
13
13
|
// ---------------------------------------------------------------------------
|
|
14
14
|
// 3. Streaming event schema
|
|
15
15
|
// ---------------------------------------------------------------------------
|
|
16
|
+
const EVENT_TYPES = new Set(["speech.audio.delta", "speech.audio.done"]);
|
|
17
|
+
/** OpenAI may add stream event types; frames outside `EVENT_TYPES` are ignored, while a malformed known type still fails decoding. */
|
|
18
|
+
const UnknownEvent = Schema.Struct({
|
|
19
|
+
type: Schema.String.check(Schema.makeFilter((type) => !EVENT_TYPES.has(type))),
|
|
20
|
+
}).pipe(Schema.decodeTo(Schema.Struct({ type: Schema.Literal("unknown"), rawType: Schema.String }), {
|
|
21
|
+
decode: SchemaGetter.transform((event) => ({ type: "unknown", rawType: event.type })),
|
|
22
|
+
encode: SchemaGetter.forbidden(() => "Unknown OpenAI Speech stream events are decode-only"),
|
|
23
|
+
}));
|
|
16
24
|
const SpeechStreamEvent = Schema.Union([
|
|
17
25
|
Schema.Struct({ type: Schema.Literal("speech.audio.delta"), audio: Schema.Uint8ArrayFromBase64 }),
|
|
18
26
|
Schema.Struct({
|
|
@@ -23,6 +31,7 @@ const SpeechStreamEvent = Schema.Union([
|
|
|
23
31
|
total_tokens: Schema.optional(Schema.Number),
|
|
24
32
|
})),
|
|
25
33
|
}),
|
|
34
|
+
UnknownEvent,
|
|
26
35
|
]);
|
|
27
36
|
const decodeEvent = route.decodeFrame(SpeechStreamEvent);
|
|
28
37
|
// ---------------------------------------------------------------------------
|
|
@@ -53,6 +62,8 @@ const fromRequest = Effect.fn("OpenAISpeech.fromRequest")(function* (request) {
|
|
|
53
62
|
const isSse = (body) => body.type === "json" && body.value.stream_format === "sse";
|
|
54
63
|
const onEvent = Effect.fnUntraced(function* (state, frame) {
|
|
55
64
|
const event = yield* decodeEvent(frame);
|
|
65
|
+
if (event.type === "unknown")
|
|
66
|
+
return [state, []];
|
|
56
67
|
if (event.type === "speech.audio.delta")
|
|
57
68
|
return SpeechStream.delta(state, event.audio);
|
|
58
69
|
const usage = event.usage;
|
|
@@ -62,13 +73,12 @@ const onEvent = Effect.fnUntraced(function* (state, frame) {
|
|
|
62
73
|
done: true,
|
|
63
74
|
usage: usage === undefined
|
|
64
75
|
? undefined
|
|
65
|
-
: {
|
|
66
|
-
type: "tokens",
|
|
76
|
+
: tokenUsage({
|
|
67
77
|
input: usage.input_tokens,
|
|
68
78
|
output: usage.output_tokens,
|
|
69
79
|
total: usage.total_tokens,
|
|
70
80
|
details: { openai: usage },
|
|
71
|
-
},
|
|
81
|
+
}),
|
|
72
82
|
},
|
|
73
83
|
[],
|
|
74
84
|
];
|
|
@@ -115,15 +115,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
|
|
|
115
115
|
readonly [x: string]: unknown;
|
|
116
116
|
} | undefined;
|
|
117
117
|
} | undefined;
|
|
118
|
-
readonly notices?: readonly {
|
|
119
|
-
readonly type: "filtered" | "moderated" | "other";
|
|
120
|
-
readonly message: string;
|
|
121
|
-
readonly providerMetadata?: {
|
|
122
|
-
readonly [x: string]: {
|
|
123
|
-
readonly [x: string]: unknown;
|
|
124
|
-
};
|
|
125
|
-
} | undefined;
|
|
126
|
-
}[] | undefined;
|
|
127
118
|
readonly providerMetadata?: {
|
|
128
119
|
readonly [x: string]: {
|
|
129
120
|
readonly [x: string]: unknown;
|
|
@@ -190,15 +181,6 @@ export declare const OpenAITranscription: {
|
|
|
190
181
|
readonly [x: string]: unknown;
|
|
191
182
|
} | undefined;
|
|
192
183
|
} | undefined;
|
|
193
|
-
readonly notices?: readonly {
|
|
194
|
-
readonly type: "filtered" | "moderated" | "other";
|
|
195
|
-
readonly message: string;
|
|
196
|
-
readonly providerMetadata?: {
|
|
197
|
-
readonly [x: string]: {
|
|
198
|
-
readonly [x: string]: unknown;
|
|
199
|
-
};
|
|
200
|
-
} | undefined;
|
|
201
|
-
}[] | undefined;
|
|
202
184
|
readonly providerMetadata?: {
|
|
203
185
|
readonly [x: string]: {
|
|
204
186
|
readonly [x: string]: unknown;
|
|
@@ -3,7 +3,7 @@ import { classifyProviderFailure } from "../provider-error.js";
|
|
|
3
3
|
import { Framing } from "../route/framing.js";
|
|
4
4
|
import { MediaProtocol } from "../route/media-protocol.js";
|
|
5
5
|
import { MediaRoute } from "../route/media.js";
|
|
6
|
-
import { AIError, mergeJsonRecords } from "../schema/index.js";
|
|
6
|
+
import { AIError, mergeJsonRecords, tokenUsage } from "../schema/index.js";
|
|
7
7
|
import { TranscriptionFinishEvent, TranscriptionModel, TranscriptionSegmentEvent, TranscriptionTextDeltaEvent, } from "../transcription.js";
|
|
8
8
|
import { mediaTypeExtension } from "../utils/media-type.js";
|
|
9
9
|
import { ProviderShared } from "./shared.js";
|
|
@@ -163,13 +163,12 @@ const usage = (value) => {
|
|
|
163
163
|
return undefined;
|
|
164
164
|
if (value.type === "duration")
|
|
165
165
|
return { type: "seconds", seconds: value.seconds };
|
|
166
|
-
return {
|
|
167
|
-
type: "tokens",
|
|
166
|
+
return tokenUsage({
|
|
168
167
|
input: value.input_tokens,
|
|
169
168
|
output: value.output_tokens,
|
|
170
169
|
total: value.total_tokens,
|
|
171
170
|
details: { openai: value },
|
|
172
|
-
};
|
|
171
|
+
});
|
|
173
172
|
};
|
|
174
173
|
const finish = (state) => {
|
|
175
174
|
const transcript = state.transcript;
|
|
@@ -11,7 +11,7 @@ export declare const IMAGE_TO_VIDEO_PATH = "/image_to_video";
|
|
|
11
11
|
export declare const VIDEO_TO_VIDEO_PATH = "/video_to_video";
|
|
12
12
|
export declare const TASKS_PATH = "/tasks";
|
|
13
13
|
/**
|
|
14
|
-
* Provider-native options. Common fields lower to Runway's names: `
|
|
14
|
+
* Provider-native options. Common fields lower to Runway's names: `aspect` → `ratio` (Runway expects pixel
|
|
15
15
|
* ratios such as `1280:720` for most models), `durationSeconds` → `duration`, `audio`, `negativePrompt`,
|
|
16
16
|
* `resolution`, `references`, and `frames` → `promptImage`.
|
|
17
17
|
*/
|
|
@@ -58,7 +58,7 @@ const fromRequest = Effect.fn("RunwayVideo.fromRequest")(function* (request) {
|
|
|
58
58
|
promptImage: promptImage.length === 0 ? undefined : promptImage,
|
|
59
59
|
videoUri,
|
|
60
60
|
references: references.length === 0 ? undefined : references,
|
|
61
|
-
ratio: request.
|
|
61
|
+
ratio: request.aspect,
|
|
62
62
|
duration: request.durationSeconds,
|
|
63
63
|
resolution: request.resolution,
|
|
64
64
|
audio: request.audio,
|
|
@@ -13,6 +13,14 @@ export declare const optionalNull: <const S extends Schema.Top>(schema: S) => Sc
|
|
|
13
13
|
export declare const optionalNullish: <const S extends Schema.Top>(schema: S) => Schema.decodeTo<Schema.optional<Schema.toType<S>>, Schema.optional<Schema.NullOr<S>>, never, never>;
|
|
14
14
|
/** Optional field whose malformed value decodes to `undefined` instead of failing the enclosing struct. */
|
|
15
15
|
export declare const lenient: <const S extends Schema.Top>(schema: S) => Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<S>, S["DecodingServices"]>>;
|
|
16
|
+
/** Billing an endpoint reports beside its token usage: `cost` is the USD it charged (OpenRouter, LiteLLM, OpenCode Zen). */
|
|
17
|
+
export declare const ReportedBilling: Schema.Struct<{
|
|
18
|
+
readonly cost: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Finite>, never>>;
|
|
19
|
+
}>;
|
|
20
|
+
/** Reads `ReportedBilling` from a raw usage object, which provider metadata keeps as the endpoint sent it. */
|
|
21
|
+
export declare const reportedBilling: (usage: unknown) => {} | {
|
|
22
|
+
cost: number | undefined;
|
|
23
|
+
};
|
|
16
24
|
/**
|
|
17
25
|
* Accepts stream frames that carry no `type`, alongside the typed event schema. Gateways inject such frames as
|
|
18
26
|
* keep-alives, so they decode as an ignored event; one with an `error` still decodes as an error event.
|
|
@@ -143,7 +151,7 @@ export type MediaReference = {
|
|
|
143
151
|
*/
|
|
144
152
|
export declare const mediaReference: (asset: Media.Asset, provider: ProviderID | undefined, label: string) => Effect.Effect<MediaReference, AIError>;
|
|
145
153
|
/**
|
|
146
|
-
* Lift a tool-result file into a `MediaPart`. Tool files carry either a data URL,
|
|
154
|
+
* Lift a tool-result file into a `MediaPart`. Tool files carry either a data URL, a URI, or raw base64 in
|
|
147
155
|
* `uri`; the declared `mime` wins over any data-URL prefix so tool authors control the type the model sees.
|
|
148
156
|
*/
|
|
149
157
|
export declare const toolFileMedia: (item: Tool.FileContent) => MediaPart;
|
package/dist/protocols/shared.js
CHANGED
|
@@ -17,6 +17,17 @@ export const optionalNullish = (schema) => Schema.optional(Schema.NullOr(schema)
|
|
|
17
17
|
})));
|
|
18
18
|
/** Optional field whose malformed value decodes to `undefined` instead of failing the enclosing struct. */
|
|
19
19
|
export const lenient = (schema) => Schema.optionalKey(Schema.UndefinedOr(schema).pipe(Schema.catchDecoding(() => Effect.succeed(Option.some(undefined)))));
|
|
20
|
+
/** A billed amount in USD; a malformed or negative one decodes as absent. */
|
|
21
|
+
const billedAmount = lenient(Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0)));
|
|
22
|
+
/** Billing an endpoint reports beside its token usage: `cost` is the USD it charged (OpenRouter, LiteLLM, OpenCode Zen). */
|
|
23
|
+
export const ReportedBilling = Schema.Struct({
|
|
24
|
+
cost: billedAmount,
|
|
25
|
+
});
|
|
26
|
+
/** Reads `ReportedBilling` from a raw usage object, which provider metadata keeps as the endpoint sent it. */
|
|
27
|
+
export const reportedBilling = (usage) => Option.match(Schema.decodeUnknownOption(ReportedBilling)(usage), {
|
|
28
|
+
onNone: () => ({}),
|
|
29
|
+
onSome: (billing) => ({ cost: billing.cost }),
|
|
30
|
+
});
|
|
20
31
|
/**
|
|
21
32
|
* Accepts stream frames that carry no `type`, alongside the typed event schema. Gateways inject such frames as
|
|
22
33
|
* keep-alives, so they decode as an ignored event; one with an `error` still decodes as an error event.
|
|
@@ -175,14 +186,14 @@ export const mediaReference = (asset, provider, label) => {
|
|
|
175
186
|
return Effect.fail(invalidRequest(`${label} accepts inline bytes, data URLs, http(s) URLs${accepted}${got}`));
|
|
176
187
|
};
|
|
177
188
|
/**
|
|
178
|
-
* Lift a tool-result file into a `MediaPart`. Tool files carry either a data URL,
|
|
189
|
+
* Lift a tool-result file into a `MediaPart`. Tool files carry either a data URL, a URI, or raw base64 in
|
|
179
190
|
* `uri`; the declared `mime` wins over any data-URL prefix so tool authors control the type the model sees.
|
|
180
191
|
*/
|
|
181
192
|
export const toolFileMedia = (item) => {
|
|
182
193
|
const parsed = Media.parseDataUrl(item.uri);
|
|
183
194
|
const asset = parsed
|
|
184
195
|
? Media.from({ ...parsed.source, mediaType: item.mime })
|
|
185
|
-
:
|
|
196
|
+
: item.uri.includes("://")
|
|
186
197
|
? Media.url(item.uri, { mediaType: item.mime })
|
|
187
198
|
: Media.base64(item.uri, item.mime);
|
|
188
199
|
return Message.media(asset, { filename: item.name });
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { DecisionResponse, type DecisionModelCompatibility, type DecisionRequestFor } from "../decision.js";
|
|
3
|
+
import { DecisionRoute } from "../route/decision.js";
|
|
4
|
+
import { AIError } from "../schema/index.js";
|
|
5
|
+
export declare const DEFAULT_PATH = "/systemone";
|
|
6
|
+
export declare const DEFAULT_BASE_URL = "https://api.typesafe.ai/v1";
|
|
7
|
+
/** `state.messages` is Baseten's own placement (parts in a user message inside `state.messages`), set by its provider. */
|
|
8
|
+
type MediaInput = NonNullable<DecisionModelCompatibility["mediaInput"]> | "state.messages";
|
|
9
|
+
export declare const Response: Schema.Struct<{
|
|
10
|
+
readonly model: Schema.String;
|
|
11
|
+
readonly answers: Schema.$Record<Schema.String, Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
|
|
12
|
+
readonly type: Schema.Literal<"noul">;
|
|
13
|
+
readonly noul: Schema.Number;
|
|
14
|
+
}>, Schema.Struct<{
|
|
15
|
+
readonly type: Schema.Literal<"choice">;
|
|
16
|
+
readonly choice: Schema.String;
|
|
17
|
+
readonly probabilities: Schema.$Record<Schema.String, Schema.Number>;
|
|
18
|
+
readonly confidence: Schema.Number;
|
|
19
|
+
}>, Schema.Struct<{
|
|
20
|
+
readonly type: Schema.Literal<"score">;
|
|
21
|
+
readonly score: Schema.Number;
|
|
22
|
+
readonly probabilities: Schema.$Record<Schema.String, Schema.Number>;
|
|
23
|
+
readonly confidence: Schema.Number;
|
|
24
|
+
}>]>>;
|
|
25
|
+
readonly usage: Schema.optional<Schema.StructWithRest<Schema.Struct<{
|
|
26
|
+
readonly input_tokens: Schema.optional<Schema.Number>;
|
|
27
|
+
readonly output_tokens: Schema.optional<Schema.Number>;
|
|
28
|
+
readonly cost: Schema.optional<Schema.Number>;
|
|
29
|
+
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>;
|
|
30
|
+
readonly id: Schema.optional<Schema.String>;
|
|
31
|
+
readonly provider: Schema.optional<Schema.String>;
|
|
32
|
+
readonly provider_metadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
33
|
+
}>;
|
|
34
|
+
export type Response = Schema.Schema.Type<typeof Response>;
|
|
35
|
+
/** The System One body without `model`; media goes where the model's `mediaInput` says, else `fallback`. */
|
|
36
|
+
export declare const encodeBody: (request: DecisionRequestFor, fallback: MediaInput) => Effect.Effect<{
|
|
37
|
+
questions: any;
|
|
38
|
+
state: unknown;
|
|
39
|
+
assets?: undefined;
|
|
40
|
+
} | {
|
|
41
|
+
questions: any;
|
|
42
|
+
state: readonly unknown[];
|
|
43
|
+
assets: {
|
|
44
|
+
[k: string]: {
|
|
45
|
+
type: string;
|
|
46
|
+
format: string;
|
|
47
|
+
data_base64: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}, AIError, never>;
|
|
51
|
+
/** Map System One's answers, keyed by question name, back to the request's question order. */
|
|
52
|
+
export declare const toResponse: (data: Response, request: DecisionRequestFor, providerMetadataKey: string, invalid: (message: string) => AIError) => Effect.Effect<never, AIError, never> | Effect.Effect<DecisionResponse, never, never>;
|
|
53
|
+
export declare const protocol: DecisionRoute.Protocol;
|
|
54
|
+
/** TypeSafe's API, the reference System One host; other hosts change the endpoint and auth with `route.with(...)`. */
|
|
55
|
+
export declare const route: DecisionRoute.Route;
|
|
56
|
+
export declare const SystemOne: {
|
|
57
|
+
readonly Response: Schema.Struct<{
|
|
58
|
+
readonly model: Schema.String;
|
|
59
|
+
readonly answers: Schema.$Record<Schema.String, Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
|
|
60
|
+
readonly type: Schema.Literal<"noul">;
|
|
61
|
+
readonly noul: Schema.Number;
|
|
62
|
+
}>, Schema.Struct<{
|
|
63
|
+
readonly type: Schema.Literal<"choice">;
|
|
64
|
+
readonly choice: Schema.String;
|
|
65
|
+
readonly probabilities: Schema.$Record<Schema.String, Schema.Number>;
|
|
66
|
+
readonly confidence: Schema.Number;
|
|
67
|
+
}>, Schema.Struct<{
|
|
68
|
+
readonly type: Schema.Literal<"score">;
|
|
69
|
+
readonly score: Schema.Number;
|
|
70
|
+
readonly probabilities: Schema.$Record<Schema.String, Schema.Number>;
|
|
71
|
+
readonly confidence: Schema.Number;
|
|
72
|
+
}>]>>;
|
|
73
|
+
readonly usage: Schema.optional<Schema.StructWithRest<Schema.Struct<{
|
|
74
|
+
readonly input_tokens: Schema.optional<Schema.Number>;
|
|
75
|
+
readonly output_tokens: Schema.optional<Schema.Number>;
|
|
76
|
+
readonly cost: Schema.optional<Schema.Number>;
|
|
77
|
+
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>;
|
|
78
|
+
readonly id: Schema.optional<Schema.String>;
|
|
79
|
+
readonly provider: Schema.optional<Schema.String>;
|
|
80
|
+
readonly provider_metadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
81
|
+
}>;
|
|
82
|
+
readonly encodeBody: (request: DecisionRequestFor, fallback: MediaInput) => Effect.Effect<{
|
|
83
|
+
questions: any;
|
|
84
|
+
state: unknown;
|
|
85
|
+
assets?: undefined;
|
|
86
|
+
} | {
|
|
87
|
+
questions: any;
|
|
88
|
+
state: readonly unknown[];
|
|
89
|
+
assets: {
|
|
90
|
+
[k: string]: {
|
|
91
|
+
type: string;
|
|
92
|
+
format: string;
|
|
93
|
+
data_base64: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
}, AIError, never>;
|
|
97
|
+
readonly toResponse: typeof toResponse;
|
|
98
|
+
readonly protocol: DecisionRoute.Protocol;
|
|
99
|
+
readonly route: DecisionRoute.Route;
|
|
100
|
+
};
|
|
101
|
+
export {};
|