@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
|
@@ -9,10 +9,13 @@ import { Protocol } from "../route/protocol.js";
|
|
|
9
9
|
import { AIError, AIErrorReason, InvalidProviderOutputError, LLMEvent, ProviderInternalError, UnknownProviderError, Usage, } from "../schema/index.js";
|
|
10
10
|
import { classifyProviderFailure } from "../provider-error.js";
|
|
11
11
|
import { isRecord, JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared.js";
|
|
12
|
-
import {
|
|
12
|
+
import { placesMarkers, requestTTL } from "../cache-policy.js";
|
|
13
|
+
import * as Cache from "./utils/cache.js";
|
|
14
|
+
import { resolveParallelToolCalls } from "./open-responses.js";
|
|
13
15
|
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
14
16
|
import { Lifecycle } from "./utils/lifecycle.js";
|
|
15
17
|
import { ToolStream } from "./utils/tool-stream.js";
|
|
18
|
+
import { OpenAIFreeform } from "./openai-freeform.js";
|
|
16
19
|
const ADAPTER = "openai-chat";
|
|
17
20
|
const RESERVED_REASONING_FIELDS = new Set(["role", "content", "refusal", "tool_calls"]);
|
|
18
21
|
export const DEFAULT_BASE_URL = "https://api.openai.com/v1";
|
|
@@ -27,16 +30,33 @@ const OpenAIChatCacheControl = Schema.Struct({
|
|
|
27
30
|
type: Schema.Literal("ephemeral"),
|
|
28
31
|
ttl: Schema.optional(Schema.String),
|
|
29
32
|
});
|
|
30
|
-
const OpenAIChatTool = Schema.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
const OpenAIChatTool = Schema.Union([
|
|
34
|
+
Schema.Struct({
|
|
35
|
+
type: Schema.tag("function"),
|
|
36
|
+
function: Schema.Struct({
|
|
37
|
+
name: Schema.String,
|
|
38
|
+
description: Schema.String,
|
|
39
|
+
parameters: JsonObject,
|
|
40
|
+
strict: Schema.optional(Schema.Boolean),
|
|
41
|
+
}),
|
|
42
|
+
cache_control: Schema.optional(OpenAIChatCacheControl),
|
|
37
43
|
}),
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
Schema.Struct({
|
|
45
|
+
type: Schema.tag("custom"),
|
|
46
|
+
custom: Schema.Struct({
|
|
47
|
+
name: Schema.String,
|
|
48
|
+
description: Schema.String,
|
|
49
|
+
format: Schema.Union([
|
|
50
|
+
Schema.Struct({ type: Schema.tag("text") }),
|
|
51
|
+
Schema.Struct({
|
|
52
|
+
type: Schema.tag("grammar"),
|
|
53
|
+
grammar: Schema.Struct({ syntax: Schema.Literals(["lark", "regex"]), definition: Schema.String }),
|
|
54
|
+
}),
|
|
55
|
+
]),
|
|
56
|
+
}),
|
|
57
|
+
cache_control: Schema.optional(OpenAIChatCacheControl),
|
|
58
|
+
}),
|
|
59
|
+
]);
|
|
40
60
|
// Gemini's OpenAI-compatible surface carries thought signatures in tool call
|
|
41
61
|
// `extra_content` and rejects replayed parallel calls without them:
|
|
42
62
|
// https://ai.google.dev/gemini-api/docs/thinking#signatures
|
|
@@ -53,6 +73,14 @@ export const OpenAIChatAssistantToolCall = Schema.Struct({
|
|
|
53
73
|
}),
|
|
54
74
|
extra_content: Schema.optional(ExtraContent),
|
|
55
75
|
});
|
|
76
|
+
export const OpenAIChatAssistantCustomToolCall = Schema.Struct({
|
|
77
|
+
id: Schema.String,
|
|
78
|
+
type: Schema.tag("custom"),
|
|
79
|
+
custom: Schema.Struct({
|
|
80
|
+
name: Schema.String,
|
|
81
|
+
input: Schema.String,
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
56
84
|
// `reasoning_details` carries two dialects. OpenRouter's `reasoning.*` entries
|
|
57
85
|
// must be replayed unmodified (`index` included), so they keep every field they
|
|
58
86
|
// arrived with. Kimi's OpenAI-compatible surface streams preserved thinking as
|
|
@@ -90,6 +118,10 @@ const OpenAIChatUserContent = Schema.Union([
|
|
|
90
118
|
type: Schema.Literal("image_url"),
|
|
91
119
|
image_url: Schema.Struct({ url: Schema.String }),
|
|
92
120
|
}),
|
|
121
|
+
Schema.Struct({
|
|
122
|
+
type: Schema.Literal("video_url"),
|
|
123
|
+
video_url: Schema.Struct({ url: Schema.String }),
|
|
124
|
+
}),
|
|
93
125
|
Schema.Struct({
|
|
94
126
|
type: Schema.Literal("file"),
|
|
95
127
|
file: Schema.Struct({ filename: Schema.String, file_data: Schema.String }),
|
|
@@ -107,7 +139,7 @@ export const OpenAIChatMessage = Schema.Union([
|
|
|
107
139
|
Schema.StructWithRest(Schema.Struct({
|
|
108
140
|
role: Schema.Literal("assistant"),
|
|
109
141
|
content: Schema.NullOr(Schema.Union([Schema.String, Schema.Array(OpenAIChatTextContent)])),
|
|
110
|
-
tool_calls: optionalArray(OpenAIChatAssistantToolCall),
|
|
142
|
+
tool_calls: optionalArray(Schema.Union([OpenAIChatAssistantToolCall, OpenAIChatAssistantCustomToolCall])),
|
|
111
143
|
reasoning_content: Schema.optional(Schema.String),
|
|
112
144
|
reasoning: Schema.optional(Schema.String),
|
|
113
145
|
reasoning_text: Schema.optional(Schema.String),
|
|
@@ -125,6 +157,10 @@ const OpenAIChatToolChoice = Schema.Union([
|
|
|
125
157
|
type: Schema.tag("function"),
|
|
126
158
|
function: Schema.Struct({ name: Schema.String }),
|
|
127
159
|
}),
|
|
160
|
+
Schema.Struct({
|
|
161
|
+
type: Schema.tag("custom"),
|
|
162
|
+
custom: Schema.Struct({ name: Schema.String }),
|
|
163
|
+
}),
|
|
128
164
|
]);
|
|
129
165
|
export const bodyFields = {
|
|
130
166
|
model: Schema.String,
|
|
@@ -135,7 +171,14 @@ export const bodyFields = {
|
|
|
135
171
|
stream_options: Schema.optional(Schema.Struct({ include_usage: Schema.Boolean })),
|
|
136
172
|
store: Schema.optional(Schema.Boolean),
|
|
137
173
|
prompt_cache_key: Schema.optional(Schema.String),
|
|
174
|
+
prompt_cache_retention: Schema.optional(Schema.String),
|
|
175
|
+
prompt_cache_options: Schema.optional(Schema.Struct({ ttl: Schema.optional(Schema.String) })),
|
|
138
176
|
reasoning_effort: Schema.optional(OpenResponsesOptions.ReasoningEffort),
|
|
177
|
+
verbosity: Schema.optional(OpenResponsesOptions.TextVerbositySchema),
|
|
178
|
+
service_tier: Schema.optional(OpenResponsesOptions.ServiceTierSchema),
|
|
179
|
+
parallel_tool_calls: Schema.optional(Schema.Boolean),
|
|
180
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
181
|
+
safety_identifier: Schema.optional(Schema.String),
|
|
139
182
|
tool_stream: Schema.optional(Schema.Boolean),
|
|
140
183
|
max_completion_tokens: Schema.optional(Schema.Number),
|
|
141
184
|
max_tokens: Schema.optional(Schema.Number),
|
|
@@ -180,6 +223,7 @@ export const OpenAIChatToolCallDelta = Schema.Struct({
|
|
|
180
223
|
index: optionalNull(Schema.Number),
|
|
181
224
|
id: optionalNull(Schema.String),
|
|
182
225
|
function: optionalNull(OpenAIChatToolCallDeltaFunction),
|
|
226
|
+
custom: optionalNull(Schema.Struct({ name: optionalNull(Schema.String), input: optionalNull(Schema.String) })),
|
|
183
227
|
extra_content: optionalNull(Schema.Unknown),
|
|
184
228
|
});
|
|
185
229
|
export const OpenAIChatDelta = Schema.StructWithRest(Schema.Struct({
|
|
@@ -209,31 +253,57 @@ export const OpenAIChatEvent = Schema.StructWithRest(Schema.Struct({
|
|
|
209
253
|
}), [Schema.Record(Schema.String, Schema.Unknown)]);
|
|
210
254
|
const DONE = "[DONE]";
|
|
211
255
|
const OpenAIChatStreamEvent = Schema.Union([Schema.Literal(DONE), Protocol.jsonEvent(OpenAIChatEvent)]);
|
|
212
|
-
const lowerTool = (tool, options, supportsStrictMode) =>
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
256
|
+
const lowerTool = (tool, options, supportsStrictMode, custom) => {
|
|
257
|
+
if (custom) {
|
|
258
|
+
const grammar = OpenAIFreeform.grammar(custom.format);
|
|
259
|
+
return {
|
|
260
|
+
type: "custom",
|
|
261
|
+
custom: {
|
|
262
|
+
name: tool.name,
|
|
263
|
+
description: tool.description,
|
|
264
|
+
format: grammar ? { type: "grammar", grammar } : { type: "text" },
|
|
265
|
+
},
|
|
266
|
+
cache_control: options.cacheControl?.(tool.cache),
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
return {
|
|
270
|
+
type: "function",
|
|
271
|
+
function: {
|
|
272
|
+
name: tool.name,
|
|
273
|
+
description: tool.description,
|
|
274
|
+
parameters: tool.inputSchema,
|
|
275
|
+
...(supportsStrictMode ? { strict: false } : {}),
|
|
276
|
+
},
|
|
277
|
+
cache_control: options.cacheControl?.(tool.cache),
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
const lowerToolChoice = (toolChoice, custom) => ProviderShared.matchToolChoice("OpenAI Chat", toolChoice, {
|
|
223
281
|
auto: () => "auto",
|
|
224
282
|
none: () => "none",
|
|
225
283
|
required: () => "required",
|
|
226
|
-
tool: (name) => (
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
id: options.toolCallID?.(part.id) ?? part.id,
|
|
230
|
-
type: "function",
|
|
231
|
-
function: {
|
|
232
|
-
name: part.name,
|
|
233
|
-
arguments: ProviderShared.encodeJson(part.input === undefined ? {} : part.input),
|
|
234
|
-
},
|
|
235
|
-
extra_content: decodeExtraContent(part.providerMetadata?.[options.providerMetadataKey]?.extraContent),
|
|
284
|
+
tool: (name) => custom.has(name)
|
|
285
|
+
? { type: "custom", custom: { name } }
|
|
286
|
+
: { type: "function", function: { name } },
|
|
236
287
|
});
|
|
288
|
+
// A call replays as the type its tool is declared with in this request.
|
|
289
|
+
const lowerToolCall = (part, options) => {
|
|
290
|
+
const custom = options.custom.get(part.name);
|
|
291
|
+
if (custom)
|
|
292
|
+
return {
|
|
293
|
+
id: options.toolCallID?.(part.id) ?? part.id,
|
|
294
|
+
type: "custom",
|
|
295
|
+
custom: { name: part.name, input: OpenAIFreeform.toRaw(custom, part.input) },
|
|
296
|
+
};
|
|
297
|
+
return {
|
|
298
|
+
id: options.toolCallID?.(part.id) ?? part.id,
|
|
299
|
+
type: "function",
|
|
300
|
+
function: {
|
|
301
|
+
name: part.name,
|
|
302
|
+
arguments: ProviderShared.encodeJson(part.input === undefined ? {} : part.input),
|
|
303
|
+
},
|
|
304
|
+
extra_content: decodeExtraContent(part.providerMetadata?.[options.providerMetadataKey]?.extraContent),
|
|
305
|
+
};
|
|
306
|
+
};
|
|
237
307
|
const lowerMedia = Effect.fnUntraced(function* (part) {
|
|
238
308
|
// Chat Completions accepts PDFs, and no other documents, as inline `file` parts; file URLs are not supported.
|
|
239
309
|
if (part.media.mediaType.toLowerCase() === "application/pdf")
|
|
@@ -244,9 +314,11 @@ const lowerMedia = Effect.fnUntraced(function* (part) {
|
|
|
244
314
|
file_data: (yield* ProviderShared.requireInlineMedia("OpenAI Chat", part.media)).dataUrl,
|
|
245
315
|
},
|
|
246
316
|
};
|
|
247
|
-
if (part.media.kind !== "image")
|
|
317
|
+
if (part.media.kind !== "image" && part.media.kind !== "video")
|
|
248
318
|
return yield* ProviderShared.invalidRequest(`OpenAI Chat does not support media type ${part.media.mediaType}`);
|
|
249
319
|
const url = ProviderShared.mediaUrl(part.media) ?? (yield* ProviderShared.requireInlineMedia("OpenAI Chat", part.media)).dataUrl;
|
|
320
|
+
if (part.media.kind === "video")
|
|
321
|
+
return { type: "video_url", video_url: { url } };
|
|
250
322
|
return { type: "image_url", image_url: { url } };
|
|
251
323
|
});
|
|
252
324
|
const openAICompatibleReasoningContent = (native) => isRecord(native) && typeof native.reasoning_content === "string" ? native.reasoning_content : undefined;
|
|
@@ -587,8 +659,10 @@ const detectZaiToolStream = (provider, baseURL, modelID) => {
|
|
|
587
659
|
return false;
|
|
588
660
|
return true;
|
|
589
661
|
};
|
|
590
|
-
const lowerOptions = (request, supportsStore) => {
|
|
662
|
+
const lowerOptions = (request, supportsStore, hasActiveTools) => {
|
|
591
663
|
const options = OpenResponsesOptions.resolve(request);
|
|
664
|
+
// OpenAI rejects `parallel_tool_calls` unless tools are present.
|
|
665
|
+
const parallelToolCalls = hasActiveTools ? resolveParallelToolCalls(request, options) : undefined;
|
|
592
666
|
// Default off: strict providers 400 on unknown body fields, so only send
|
|
593
667
|
// the key where compatibility explicitly allows it. Header-based affinity
|
|
594
668
|
// (x-session-affinity, x-grok-conv-id, ...) is unaffected.
|
|
@@ -596,7 +670,14 @@ const lowerOptions = (request, supportsStore) => {
|
|
|
596
670
|
return {
|
|
597
671
|
...(supportsStore ? { store: options.store ?? false } : {}),
|
|
598
672
|
...(cacheKey ? { prompt_cache_key: cacheKey } : {}),
|
|
673
|
+
// Inline markers carry the lifetime when the policy places them.
|
|
674
|
+
...(placesMarkers(request) ? {} : Cache.openAIRequestTTL(requestTTL(request))),
|
|
599
675
|
...(options.reasoningEffort ? { reasoning_effort: options.reasoningEffort } : {}),
|
|
676
|
+
...(options.textVerbosity ? { verbosity: options.textVerbosity } : {}),
|
|
677
|
+
...(options.serviceTier ? { service_tier: options.serviceTier } : {}),
|
|
678
|
+
...(parallelToolCalls !== undefined ? { parallel_tool_calls: parallelToolCalls } : {}),
|
|
679
|
+
...(options.metadata ? { metadata: options.metadata } : {}),
|
|
680
|
+
...(options.safetyIdentifier ? { safety_identifier: options.safetyIdentifier } : {}),
|
|
600
681
|
};
|
|
601
682
|
};
|
|
602
683
|
export const fromRequest = Effect.fn("OpenAIChat.fromRequest")(function* (request, options = {}) {
|
|
@@ -616,7 +697,8 @@ export const fromRequest = Effect.fn("OpenAIChat.fromRequest")(function* (reques
|
|
|
616
697
|
const zaiToolStream = request.model.compatibility?.zaiToolStream ?? detectZaiToolStream(provider, baseURL, request.model.id);
|
|
617
698
|
const hasHistory = hasToolHistory(request.messages);
|
|
618
699
|
const hasActiveTools = flattened.tools.length > 0;
|
|
619
|
-
const
|
|
700
|
+
const custom = OpenAIFreeform.tools(request);
|
|
701
|
+
const lowering = { ...options, cacheControl: options.cacheControl ?? declaredCacheControl(request), custom };
|
|
620
702
|
return {
|
|
621
703
|
model: request.model.id,
|
|
622
704
|
messages: yield* lowerMessages(flattened.request, lowering),
|
|
@@ -624,8 +706,8 @@ export const fromRequest = Effect.fn("OpenAIChat.fromRequest")(function* (reques
|
|
|
624
706
|
? hasHistory
|
|
625
707
|
? []
|
|
626
708
|
: undefined
|
|
627
|
-
: flattened.tools.map((tool) => lowerTool(tool, lowering, supportsStrictMode)),
|
|
628
|
-
tool_choice: hasActiveTools && request.toolChoice ? yield* lowerToolChoice(request.toolChoice) : undefined,
|
|
709
|
+
: flattened.tools.map((tool) => lowerTool(tool, lowering, supportsStrictMode, custom.get(tool.name))),
|
|
710
|
+
tool_choice: hasActiveTools && request.toolChoice ? yield* lowerToolChoice(request.toolChoice, custom) : undefined,
|
|
629
711
|
stream: true,
|
|
630
712
|
...((request.model.compatibility?.streamUsage ?? true) ? { stream_options: { include_usage: true } } : {}),
|
|
631
713
|
...(zaiToolStream && hasActiveTools ? { tool_stream: true } : {}),
|
|
@@ -638,11 +720,11 @@ export const fromRequest = Effect.fn("OpenAIChat.fromRequest")(function* (reques
|
|
|
638
720
|
presence_penalty: generation?.presencePenalty,
|
|
639
721
|
seed: generation?.seed,
|
|
640
722
|
stop: generation?.stop,
|
|
641
|
-
...lowerOptions(request, supportsStore),
|
|
723
|
+
...lowerOptions(request, supportsStore, hasActiveTools),
|
|
642
724
|
};
|
|
643
725
|
});
|
|
644
726
|
// Provider wrappers that pass their own marker writer keep it; otherwise a declared cache format adds one.
|
|
645
|
-
const declaredCacheControl = (request) => request.model.compatibility?.cacheFormat === undefined ? undefined : cacheControl();
|
|
727
|
+
const declaredCacheControl = (request) => request.model.compatibility?.cacheFormat === undefined ? undefined : Cache.cacheControl();
|
|
646
728
|
// =============================================================================
|
|
647
729
|
// Stream Parsing
|
|
648
730
|
// =============================================================================
|
|
@@ -676,12 +758,7 @@ const mapFinishReason = Effect.fnUntraced(function* (event, reason) {
|
|
|
676
758
|
case "tool_calls":
|
|
677
759
|
return "tool-calls";
|
|
678
760
|
default:
|
|
679
|
-
return
|
|
680
|
-
reason: new UnknownProviderError({
|
|
681
|
-
message: `Provider finish_reason: ${reason}`,
|
|
682
|
-
body: ProviderShared.encodeJson(event),
|
|
683
|
-
}),
|
|
684
|
-
});
|
|
761
|
+
return "unknown";
|
|
685
762
|
}
|
|
686
763
|
});
|
|
687
764
|
// OpenAI Chat reports `prompt_tokens` (inclusive total) with a
|
|
@@ -714,6 +791,7 @@ const mapUsage = (usage, providerMetadataKey) => {
|
|
|
714
791
|
cacheWriteInputTokens: cacheWrite,
|
|
715
792
|
reasoningTokens: reasoning,
|
|
716
793
|
totalTokens: ProviderShared.totalTokens(input, output, usage.total_tokens ?? undefined),
|
|
794
|
+
...ProviderShared.reportedBilling(usage),
|
|
717
795
|
providerMetadata: { [providerMetadataKey]: usage },
|
|
718
796
|
});
|
|
719
797
|
};
|
|
@@ -835,20 +913,17 @@ const step = (state, event) => Effect.gen(function* () {
|
|
|
835
913
|
const toolDeltas = delta?.tool_calls ?? [];
|
|
836
914
|
let tools = state.tools;
|
|
837
915
|
let pendingTools = state.pendingTools;
|
|
916
|
+
let customCalls = state.customCalls;
|
|
838
917
|
let latestToolIndex = state.latestToolIndex;
|
|
839
918
|
let nextToolIndex = state.nextToolIndex;
|
|
840
919
|
let lifecycle = state.lifecycle;
|
|
841
920
|
const reasoning = reasoningDelta(delta, state.reasoningField);
|
|
842
|
-
|
|
843
|
-
Boolean(
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
if (hasLateContent)
|
|
849
|
-
return yield* ProviderShared.eventError(ADAPTER, "OpenAI Chat received content after the finish reason", ProviderShared.encodeJson(event));
|
|
850
|
-
return [{ ...state, usage }, events];
|
|
851
|
-
}
|
|
921
|
+
if (state.finishReason !== undefined &&
|
|
922
|
+
toolDeltas.some((tool) => Boolean(tool.id) ||
|
|
923
|
+
Boolean(tool.function?.name) ||
|
|
924
|
+
Boolean(tool.function?.arguments) ||
|
|
925
|
+
Boolean(tool.custom?.input)))
|
|
926
|
+
return yield* ProviderShared.eventError(ADAPTER, "OpenAI Chat received content after the finish reason", ProviderShared.encodeJson(event));
|
|
852
927
|
const reasoningField = state.reasoningField ?? reasoning?.field;
|
|
853
928
|
const reasoningTextObserved = state.reasoningTextObserved || reasoning !== undefined;
|
|
854
929
|
const detailDelta = Array.isArray(delta?.reasoning_details)
|
|
@@ -885,8 +960,18 @@ const step = (state, event) => Effect.gen(function* () {
|
|
|
885
960
|
const current = tools[index];
|
|
886
961
|
const pending = pendingTools[index];
|
|
887
962
|
const id = current?.id ?? pending?.id ?? (tool.id || undefined);
|
|
888
|
-
const name = current?.name ?? pending?.name ?? (tool.function?.name || undefined);
|
|
889
|
-
|
|
963
|
+
const name = current?.name ?? pending?.name ?? (tool.function?.name || tool.custom?.name || undefined);
|
|
964
|
+
// Custom calls stream raw text; re-encode it as JSON arguments for the call's field.
|
|
965
|
+
const opening = Boolean(tool.custom) && !customCalls.has(index);
|
|
966
|
+
if (opening)
|
|
967
|
+
customCalls = new Set([...customCalls, index]);
|
|
968
|
+
const raw = tool.custom?.input ?? "";
|
|
969
|
+
const fragment = tool.custom
|
|
970
|
+
? opening
|
|
971
|
+
? OpenAIFreeform.streamStart(state.custom.get(name ?? ""), raw)
|
|
972
|
+
: OpenAIFreeform.streamDelta(raw)
|
|
973
|
+
: (tool.function?.arguments ?? "");
|
|
974
|
+
const text = `${pending?.input ?? ""}${fragment}`;
|
|
890
975
|
const extraContent = pending?.extraContent ?? decodeExtraContent(tool.extra_content);
|
|
891
976
|
latestToolIndex = index;
|
|
892
977
|
nextToolIndex = Math.max(nextToolIndex, index + 1);
|
|
@@ -932,16 +1017,18 @@ const step = (state, event) => Effect.gen(function* () {
|
|
|
932
1017
|
!incompleteTools &&
|
|
933
1018
|
state.finishReason === undefined &&
|
|
934
1019
|
Object.keys(tools).length > 0
|
|
935
|
-
? yield*
|
|
1020
|
+
? yield* finishTools(tools, customCalls)
|
|
936
1021
|
: undefined;
|
|
937
1022
|
return [
|
|
938
1023
|
{
|
|
939
1024
|
providerMetadataKey: state.providerMetadataKey,
|
|
940
1025
|
tools: finished?.tools ?? tools,
|
|
1026
|
+
custom: state.custom,
|
|
1027
|
+
customCalls,
|
|
941
1028
|
pendingTools,
|
|
942
1029
|
toolCallEvents: finished?.events ?? state.toolCallEvents,
|
|
943
1030
|
usage,
|
|
944
|
-
finishReason,
|
|
1031
|
+
finishReason: state.finishReason ?? finishReason,
|
|
945
1032
|
lifecycle,
|
|
946
1033
|
reasoningField,
|
|
947
1034
|
reasoningTextObserved,
|
|
@@ -955,6 +1042,12 @@ const step = (state, event) => Effect.gen(function* () {
|
|
|
955
1042
|
events,
|
|
956
1043
|
];
|
|
957
1044
|
});
|
|
1045
|
+
// Custom calls close their JSON fragment before every pending call finishes.
|
|
1046
|
+
const finishTools = Effect.fnUntraced(function* (tools, customCalls) {
|
|
1047
|
+
const closed = OpenAIFreeform.close(tools, customCalls);
|
|
1048
|
+
const finished = yield* ToolStream.finishAll(ADAPTER, closed.tools);
|
|
1049
|
+
return { tools: finished.tools, events: [...closed.events, ...finished.events] };
|
|
1050
|
+
});
|
|
958
1051
|
export const finishEvents = Effect.fnUntraced(function* (state) {
|
|
959
1052
|
if (state.finishReason === undefined && state.requireFinishReason)
|
|
960
1053
|
return yield* new AIError({
|
|
@@ -966,7 +1059,7 @@ export const finishEvents = Effect.fnUntraced(function* (state) {
|
|
|
966
1059
|
});
|
|
967
1060
|
const events = [];
|
|
968
1061
|
const toolCallEvents = state.finishReason === undefined && Object.keys(state.tools).length > 0
|
|
969
|
-
? (yield*
|
|
1062
|
+
? (yield* finishTools(state.tools, state.customCalls)).events
|
|
970
1063
|
: state.toolCallEvents;
|
|
971
1064
|
const hasToolCalls = toolCallEvents.length > 0;
|
|
972
1065
|
const reason = state.finishReason
|
|
@@ -1007,6 +1100,8 @@ export const protocol = Protocol.make({
|
|
|
1007
1100
|
initial: (request) => ({
|
|
1008
1101
|
providerMetadataKey: request.model.route.providerMetadataKey ?? request.model.provider,
|
|
1009
1102
|
tools: ToolStream.empty(),
|
|
1103
|
+
custom: OpenAIFreeform.tools(request),
|
|
1104
|
+
customCalls: new Set(),
|
|
1010
1105
|
pendingTools: {},
|
|
1011
1106
|
toolCallEvents: [],
|
|
1012
1107
|
lifecycle: Lifecycle.initial(),
|
|
@@ -15,6 +15,11 @@ export declare const route: Route<{
|
|
|
15
15
|
readonly image_url: {
|
|
16
16
|
readonly url: string;
|
|
17
17
|
};
|
|
18
|
+
} | {
|
|
19
|
+
readonly type: "video_url";
|
|
20
|
+
readonly video_url: {
|
|
21
|
+
readonly url: string;
|
|
22
|
+
};
|
|
18
23
|
} | {
|
|
19
24
|
readonly type: "file";
|
|
20
25
|
readonly file: {
|
|
@@ -36,6 +41,11 @@ export declare const route: Route<{
|
|
|
36
41
|
readonly image_url: {
|
|
37
42
|
readonly url: string;
|
|
38
43
|
};
|
|
44
|
+
} | {
|
|
45
|
+
readonly type: "video_url";
|
|
46
|
+
readonly video_url: {
|
|
47
|
+
readonly url: string;
|
|
48
|
+
};
|
|
39
49
|
} | {
|
|
40
50
|
readonly type: "file";
|
|
41
51
|
readonly file: {
|
|
@@ -72,7 +82,14 @@ export declare const route: Route<{
|
|
|
72
82
|
readonly ttl?: string | undefined;
|
|
73
83
|
} | undefined;
|
|
74
84
|
}[] | null;
|
|
75
|
-
readonly tool_calls?: readonly {
|
|
85
|
+
readonly tool_calls?: readonly ({
|
|
86
|
+
readonly id: string;
|
|
87
|
+
readonly type: "custom";
|
|
88
|
+
readonly custom: {
|
|
89
|
+
readonly name: string;
|
|
90
|
+
readonly input: string;
|
|
91
|
+
};
|
|
92
|
+
} | {
|
|
76
93
|
readonly id: string;
|
|
77
94
|
readonly type: "function";
|
|
78
95
|
readonly function: {
|
|
@@ -84,13 +101,13 @@ export declare const route: Route<{
|
|
|
84
101
|
readonly thought_signature: string;
|
|
85
102
|
};
|
|
86
103
|
} | undefined;
|
|
87
|
-
}[] | undefined;
|
|
104
|
+
})[] | undefined;
|
|
88
105
|
readonly reasoning_content?: string | undefined;
|
|
89
106
|
readonly reasoning?: string | undefined;
|
|
90
107
|
readonly reasoning_text?: string | undefined;
|
|
91
108
|
readonly reasoning_details?: unknown;
|
|
92
109
|
})[];
|
|
93
|
-
readonly tools?: readonly {
|
|
110
|
+
readonly tools?: readonly ({
|
|
94
111
|
readonly type: "function";
|
|
95
112
|
readonly function: {
|
|
96
113
|
readonly name: string;
|
|
@@ -104,12 +121,36 @@ export declare const route: Route<{
|
|
|
104
121
|
readonly type: "ephemeral";
|
|
105
122
|
readonly ttl?: string | undefined;
|
|
106
123
|
} | undefined;
|
|
107
|
-
}
|
|
124
|
+
} | {
|
|
125
|
+
readonly type: "custom";
|
|
126
|
+
readonly custom: {
|
|
127
|
+
readonly name: string;
|
|
128
|
+
readonly description: string;
|
|
129
|
+
readonly format: {
|
|
130
|
+
readonly type: "text";
|
|
131
|
+
} | {
|
|
132
|
+
readonly type: "grammar";
|
|
133
|
+
readonly grammar: {
|
|
134
|
+
readonly syntax: "lark" | "regex";
|
|
135
|
+
readonly definition: string;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
readonly cache_control?: {
|
|
140
|
+
readonly type: "ephemeral";
|
|
141
|
+
readonly ttl?: string | undefined;
|
|
142
|
+
} | undefined;
|
|
143
|
+
})[] | undefined;
|
|
108
144
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
109
145
|
readonly type: "function";
|
|
110
146
|
readonly function: {
|
|
111
147
|
readonly name: string;
|
|
112
148
|
};
|
|
149
|
+
} | {
|
|
150
|
+
readonly type: "custom";
|
|
151
|
+
readonly custom: {
|
|
152
|
+
readonly name: string;
|
|
153
|
+
};
|
|
113
154
|
} | undefined;
|
|
114
155
|
readonly stream: true;
|
|
115
156
|
readonly stream_options?: {
|
|
@@ -117,7 +158,18 @@ export declare const route: Route<{
|
|
|
117
158
|
} | undefined;
|
|
118
159
|
readonly store?: boolean | undefined;
|
|
119
160
|
readonly prompt_cache_key?: string | undefined;
|
|
120
|
-
readonly
|
|
161
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
162
|
+
readonly prompt_cache_options?: {
|
|
163
|
+
readonly ttl?: string | undefined;
|
|
164
|
+
} | undefined;
|
|
165
|
+
readonly reasoning_effort?: import("../effect.js").ReasoningEffort | undefined;
|
|
166
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
167
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
168
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
169
|
+
readonly metadata?: {
|
|
170
|
+
readonly [x: string]: string;
|
|
171
|
+
} | undefined;
|
|
172
|
+
readonly safety_identifier?: string | undefined;
|
|
121
173
|
readonly tool_stream?: boolean | undefined;
|
|
122
174
|
readonly max_completion_tokens?: number | undefined;
|
|
123
175
|
readonly max_tokens?: number | undefined;
|
|
@@ -9,7 +9,7 @@ export declare const route: Route<{
|
|
|
9
9
|
readonly input: readonly ({
|
|
10
10
|
readonly type: "configuration_update";
|
|
11
11
|
readonly reasoning: {
|
|
12
|
-
readonly effort: import("../
|
|
12
|
+
readonly effort: import("../effect.js").ReasoningEffort;
|
|
13
13
|
};
|
|
14
14
|
} | {
|
|
15
15
|
readonly type: "message";
|
|
@@ -20,7 +20,7 @@ export declare const route: Route<{
|
|
|
20
20
|
readonly role: "developer";
|
|
21
21
|
readonly content: string;
|
|
22
22
|
} | {
|
|
23
|
-
readonly type: "function_call_output";
|
|
23
|
+
readonly type: "custom_tool_call_output" | "function_call_output";
|
|
24
24
|
readonly call_id: string;
|
|
25
25
|
readonly output: string | readonly ({
|
|
26
26
|
readonly type: "input_text";
|
|
@@ -57,6 +57,9 @@ export declare const route: Route<{
|
|
|
57
57
|
readonly content: readonly ({
|
|
58
58
|
readonly type: "input_text";
|
|
59
59
|
readonly text: string;
|
|
60
|
+
} | {
|
|
61
|
+
readonly type: "input_video";
|
|
62
|
+
readonly video_url: string;
|
|
60
63
|
} | {
|
|
61
64
|
readonly type: "input_image";
|
|
62
65
|
readonly image_url: string;
|
|
@@ -87,6 +90,12 @@ export declare const route: Route<{
|
|
|
87
90
|
readonly name: string;
|
|
88
91
|
readonly namespace?: string | undefined;
|
|
89
92
|
readonly arguments: string;
|
|
93
|
+
} | {
|
|
94
|
+
readonly type: "custom_tool_call";
|
|
95
|
+
readonly id?: string | undefined;
|
|
96
|
+
readonly call_id: string;
|
|
97
|
+
readonly name: string;
|
|
98
|
+
readonly input: string;
|
|
90
99
|
} | {
|
|
91
100
|
readonly [x: string]: unknown;
|
|
92
101
|
readonly type: "web_search_call";
|
|
@@ -131,6 +140,17 @@ export declare const route: Route<{
|
|
|
131
140
|
})[];
|
|
132
141
|
readonly instructions?: string | undefined;
|
|
133
142
|
readonly tools?: readonly ({
|
|
143
|
+
readonly type: "custom";
|
|
144
|
+
readonly name: string;
|
|
145
|
+
readonly description: string;
|
|
146
|
+
readonly format: {
|
|
147
|
+
readonly type: "text";
|
|
148
|
+
} | {
|
|
149
|
+
readonly type: "grammar";
|
|
150
|
+
readonly syntax: "lark" | "regex";
|
|
151
|
+
readonly definition: string;
|
|
152
|
+
};
|
|
153
|
+
} | {
|
|
134
154
|
readonly type: "function";
|
|
135
155
|
readonly name: string;
|
|
136
156
|
readonly description: string;
|
|
@@ -143,13 +163,13 @@ export declare const route: Route<{
|
|
|
143
163
|
readonly type: string;
|
|
144
164
|
})[] | undefined;
|
|
145
165
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
146
|
-
readonly type: "function";
|
|
166
|
+
readonly type: "custom" | "function";
|
|
147
167
|
readonly name: string;
|
|
148
168
|
} | {
|
|
149
169
|
readonly type: "allowed_tools";
|
|
150
170
|
readonly mode: "auto" | "none" | "required";
|
|
151
171
|
readonly tools: readonly {
|
|
152
|
-
readonly type: "function";
|
|
172
|
+
readonly type: "custom" | "function";
|
|
153
173
|
readonly name: string;
|
|
154
174
|
}[];
|
|
155
175
|
} | undefined;
|
|
@@ -163,15 +183,15 @@ export declare const route: Route<{
|
|
|
163
183
|
} | undefined;
|
|
164
184
|
readonly top_logprobs?: number | undefined;
|
|
165
185
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
166
|
-
readonly service_tier?: import("../
|
|
186
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
167
187
|
readonly prompt_cache_key?: string | undefined;
|
|
168
|
-
readonly include?: readonly import("../
|
|
188
|
+
readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
|
|
169
189
|
readonly reasoning?: {
|
|
170
|
-
readonly effort?: import("../
|
|
190
|
+
readonly effort?: import("../effect.js").ReasoningEffort | undefined;
|
|
171
191
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
172
192
|
} | undefined;
|
|
173
193
|
readonly text?: {
|
|
174
|
-
readonly verbosity?: import("../
|
|
194
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
175
195
|
} | undefined;
|
|
176
196
|
readonly max_output_tokens?: number | undefined;
|
|
177
197
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { DecisionRoute } from "../route/decision.js";
|
|
3
|
+
import { type ProviderOptions } from "../schema/index.js";
|
|
4
|
+
export declare const DEFAULT_BASE_URL = "https://api.openai.com/v1";
|
|
5
|
+
export declare const PATH = "/decisions";
|
|
6
|
+
declare const Options: Schema.Struct<{
|
|
7
|
+
readonly promptCacheKey: Schema.optional<Schema.String>;
|
|
8
|
+
readonly promptCacheOptions: Schema.optional<Schema.Struct<{
|
|
9
|
+
readonly mode: Schema.optional<Schema.String>;
|
|
10
|
+
readonly ttl: Schema.optional<Schema.String>;
|
|
11
|
+
}>>;
|
|
12
|
+
readonly safetyIdentifier: Schema.optional<Schema.String>;
|
|
13
|
+
}>;
|
|
14
|
+
/** Known fields map to their wire names; anything else is sent as given. */
|
|
15
|
+
export type OptionsInput = ProviderOptions & typeof Options.Encoded;
|
|
16
|
+
export declare const protocol: DecisionRoute.Protocol;
|
|
17
|
+
export declare const route: DecisionRoute.Route;
|
|
18
|
+
export declare const OpenAIDecisions: {
|
|
19
|
+
readonly protocol: DecisionRoute.Protocol;
|
|
20
|
+
readonly route: DecisionRoute.Route;
|
|
21
|
+
};
|
|
22
|
+
export {};
|