@opencode/ai 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache-policy.js +6 -5
- package/dist/experimental/evaluation.d.ts +7 -6
- package/dist/experimental/evaluation.js +2 -3
- package/dist/experimental/realtime.d.ts +59 -0
- package/dist/experimental/realtime.js +32 -19
- package/dist/experimental/system-one.js +8 -8
- package/dist/experimental.d.ts +1 -1
- package/dist/generation.js +1 -1
- package/dist/image-client.d.ts +3 -1
- package/dist/image.d.ts +10 -2
- package/dist/image.js +2 -2
- package/dist/llm.d.ts +2 -4
- package/dist/llm.js +2 -2
- package/dist/media-model.d.ts +2 -2
- package/dist/media-model.js +1 -1
- package/dist/media.js +3 -3
- package/dist/promise.d.ts +1 -1
- package/dist/promise.js +3 -5
- package/dist/protocols/alibaba-chat.d.ts +6 -6
- package/dist/protocols/alibaba-chat.js +3 -3
- package/dist/protocols/alibaba-messages.d.ts +1 -1
- package/dist/protocols/alibaba-messages.js +1 -1
- package/dist/protocols/alibaba-responses.d.ts +3 -3
- package/dist/protocols/anthropic-messages.js +10 -12
- package/dist/protocols/bedrock-converse.d.ts +6 -53
- package/dist/protocols/bedrock-converse.js +4 -3
- package/dist/protocols/bedrock-event-stream.d.ts +6 -1
- package/dist/protocols/bedrock-event-stream.js +9 -8
- package/dist/protocols/cohere-chat.d.ts +6 -2
- package/dist/protocols/cohere-chat.js +2 -2
- package/dist/protocols/gemini.d.ts +12 -2
- package/dist/protocols/gemini.js +10 -13
- package/dist/protocols/google-interactions.d.ts +2 -1
- package/dist/protocols/google-interactions.js +14 -9
- package/dist/protocols/meta-responses.d.ts +6 -6
- package/dist/protocols/mistral-chat.js +1 -4
- package/dist/protocols/open-responses.d.ts +21 -21
- package/dist/protocols/open-responses.js +3 -3
- package/dist/protocols/openai-chat.d.ts +8 -7
- package/dist/protocols/openai-chat.js +4 -5
- package/dist/protocols/openai-compatible-responses.d.ts +3 -3
- package/dist/protocols/openai-responses.d.ts +18 -18
- package/dist/protocols/utils/open-responses-options.d.ts +8 -8
- package/dist/protocols/utils/open-responses-options.js +4 -6
- package/dist/protocols/utils/partial-json.js +5 -4
- package/dist/protocols/utils/tool-schema.d.ts +0 -3
- package/dist/protocols/utils/tool-schema.js +0 -4
- package/dist/protocols/venice-chat.js +6 -6
- package/dist/protocols/xai-images.js +3 -4
- package/dist/protocols/xai-responses.d.ts +3 -3
- package/dist/provider-error.js +4 -5
- package/dist/providers/alibaba.d.ts +30 -30
- package/dist/providers/amazon-bedrock-mantle.d.ts +3 -3
- package/dist/providers/amazon-bedrock.d.ts +11 -8
- package/dist/providers/azure.d.ts +6 -6
- package/dist/providers/cloudflare-ai-gateway.d.ts +7 -7
- package/dist/providers/cloudflare-ai-gateway.js +2 -4
- package/dist/providers/cohere.d.ts +6 -2
- package/dist/providers/google-vertex-interactions.d.ts +3 -3
- package/dist/providers/google-vertex-messages.d.ts +18 -18
- package/dist/providers/google-vertex-mistral.d.ts +3 -3
- package/dist/providers/google-vertex-responses.d.ts +3 -3
- package/dist/providers/google.d.ts +66 -66
- package/dist/providers/meta.d.ts +21 -21
- package/dist/providers/minimax.d.ts +195 -195
- package/dist/providers/moonshot.d.ts +3 -3
- package/dist/providers/openai-compatible-responses.d.ts +3 -3
- package/dist/providers/openai-options.d.ts +3 -3
- package/dist/providers/openai.d.ts +3 -3
- package/dist/providers/openrouter.d.ts +135 -76
- package/dist/providers/openrouter.js +40 -33
- package/dist/providers/vercel-ai-gateway.js +7 -6
- package/dist/providers/zai-coding-plan.d.ts +3 -3
- package/dist/route/client.d.ts +0 -216
- package/dist/route/client.js +1 -5
- package/dist/route/executor-service.d.ts +6 -2
- package/dist/route/executor-service.js +7 -0
- package/dist/route/executor.d.ts +2 -3
- package/dist/route/executor.js +6 -11
- package/dist/route/media-protocol.d.ts +1 -1
- package/dist/route/media-protocol.js +3 -3
- package/dist/route/transport/http.js +5 -8
- package/dist/route/transport/websocket.d.ts +0 -24
- package/dist/route/transport/websocket.js +0 -50
- package/dist/schema/errors.d.ts +9 -8
- package/dist/schema/errors.js +9 -5
- package/dist/schema/messages.js +4 -7
- package/dist/speech-client.d.ts +3 -1
- package/dist/speech.d.ts +10 -2
- package/dist/speech.js +2 -2
- package/dist/transcription-client.d.ts +3 -1
- package/dist/transcription.d.ts +10 -2
- package/dist/transcription.js +2 -2
- package/dist/video-client.d.ts +3 -1
- package/dist/video.d.ts +10 -2
- package/dist/video.js +2 -2
- package/package.json +4 -4
- package/dist/protocols/utils/openai-options.d.ts +0 -16
- package/dist/protocols/utils/openai-options.js +0 -15
|
@@ -378,15 +378,15 @@ export declare const coreFields: {
|
|
|
378
378
|
}>>;
|
|
379
379
|
top_logprobs: Schema.optional<Schema.Int>;
|
|
380
380
|
truncation: Schema.optional<Schema.Literals<readonly ["auto", "disabled"]>>;
|
|
381
|
-
service_tier: Schema.optional<Schema.declare<
|
|
381
|
+
service_tier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">, import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">>>;
|
|
382
382
|
prompt_cache_key: Schema.optional<Schema.String>;
|
|
383
|
-
include: Schema.optional<Schema.$Array<Schema.declare<
|
|
383
|
+
include: Schema.optional<Schema.$Array<Schema.declare<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">, 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">>>>;
|
|
384
384
|
reasoning: Schema.optional<Schema.Struct<{
|
|
385
385
|
readonly effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
386
386
|
readonly summary: Schema.optional<Schema.Literals<readonly ["auto", "concise", "detailed"]>>;
|
|
387
387
|
}>>;
|
|
388
388
|
text: Schema.optional<Schema.Struct<{
|
|
389
|
-
readonly verbosity: Schema.optional<Schema.declare<
|
|
389
|
+
readonly verbosity: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"high" | "low" | "medium">, import("../schema/options.js").OpenString<"high" | "low" | "medium">>>;
|
|
390
390
|
}>>;
|
|
391
391
|
max_output_tokens: Schema.optional<Schema.Number>;
|
|
392
392
|
max_tool_calls: Schema.optional<Schema.Int>;
|
|
@@ -539,15 +539,15 @@ export declare const OpenResponsesBody: Schema.Struct<{
|
|
|
539
539
|
}>>;
|
|
540
540
|
readonly top_logprobs: Schema.optional<Schema.Int>;
|
|
541
541
|
readonly truncation: Schema.optional<Schema.Literals<readonly ["auto", "disabled"]>>;
|
|
542
|
-
readonly service_tier: Schema.optional<Schema.declare<
|
|
542
|
+
readonly service_tier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">, import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">>>;
|
|
543
543
|
readonly prompt_cache_key: Schema.optional<Schema.String>;
|
|
544
|
-
readonly include: Schema.optional<Schema.$Array<Schema.declare<
|
|
544
|
+
readonly include: Schema.optional<Schema.$Array<Schema.declare<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">, 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">>>>;
|
|
545
545
|
readonly reasoning: Schema.optional<Schema.Struct<{
|
|
546
546
|
readonly effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
547
547
|
readonly summary: Schema.optional<Schema.Literals<readonly ["auto", "concise", "detailed"]>>;
|
|
548
548
|
}>>;
|
|
549
549
|
readonly text: Schema.optional<Schema.Struct<{
|
|
550
|
-
readonly verbosity: Schema.optional<Schema.declare<
|
|
550
|
+
readonly verbosity: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"high" | "low" | "medium">, import("../schema/options.js").OpenString<"high" | "low" | "medium">>>;
|
|
551
551
|
}>>;
|
|
552
552
|
readonly max_output_tokens: Schema.optional<Schema.Number>;
|
|
553
553
|
readonly max_tool_calls: Schema.optional<Schema.Int>;
|
|
@@ -1044,15 +1044,15 @@ export declare const lowerGeneration: (request: LLMRequest, options?: OpenRespon
|
|
|
1044
1044
|
} | undefined;
|
|
1045
1045
|
top_logprobs?: number | undefined;
|
|
1046
1046
|
prompt_cache_key?: string | undefined;
|
|
1047
|
-
include?: readonly
|
|
1047
|
+
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;
|
|
1048
1048
|
reasoning?: {
|
|
1049
1049
|
effort: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1050
1050
|
summary: "auto" | "concise" | "detailed" | undefined;
|
|
1051
1051
|
} | undefined;
|
|
1052
1052
|
text?: {
|
|
1053
|
-
verbosity:
|
|
1053
|
+
verbosity: import("../schema/options.js").OpenString<"high" | "low" | "medium">;
|
|
1054
1054
|
} | undefined;
|
|
1055
|
-
service_tier?:
|
|
1055
|
+
service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
1056
1056
|
max_tool_calls?: number | undefined;
|
|
1057
1057
|
parallel_tool_calls?: boolean | undefined;
|
|
1058
1058
|
truncation?: "auto" | "disabled" | undefined;
|
|
@@ -1210,15 +1210,15 @@ export declare const fromRequestWithAdapter: (request: LLMRequest<import("../sch
|
|
|
1210
1210
|
} | undefined;
|
|
1211
1211
|
top_logprobs?: number | undefined;
|
|
1212
1212
|
prompt_cache_key?: string | undefined;
|
|
1213
|
-
include?: readonly
|
|
1213
|
+
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;
|
|
1214
1214
|
reasoning?: {
|
|
1215
1215
|
effort: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1216
1216
|
summary: "auto" | "concise" | "detailed" | undefined;
|
|
1217
1217
|
} | undefined;
|
|
1218
1218
|
text?: {
|
|
1219
|
-
verbosity:
|
|
1219
|
+
verbosity: import("../schema/options.js").OpenString<"high" | "low" | "medium">;
|
|
1220
1220
|
} | undefined;
|
|
1221
|
-
service_tier?:
|
|
1221
|
+
service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
1222
1222
|
max_tool_calls?: number | undefined;
|
|
1223
1223
|
parallel_tool_calls?: boolean | undefined;
|
|
1224
1224
|
truncation?: "auto" | "disabled" | undefined;
|
|
@@ -1388,15 +1388,15 @@ export declare const fromRequest: (request: LLMRequest) => Effect.Effect<{
|
|
|
1388
1388
|
} | undefined;
|
|
1389
1389
|
top_logprobs?: number | undefined;
|
|
1390
1390
|
prompt_cache_key?: string | undefined;
|
|
1391
|
-
include?: readonly
|
|
1391
|
+
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;
|
|
1392
1392
|
reasoning?: {
|
|
1393
1393
|
effort: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1394
1394
|
summary: "auto" | "concise" | "detailed" | undefined;
|
|
1395
1395
|
} | undefined;
|
|
1396
1396
|
text?: {
|
|
1397
|
-
verbosity:
|
|
1397
|
+
verbosity: import("../schema/options.js").OpenString<"high" | "low" | "medium">;
|
|
1398
1398
|
} | undefined;
|
|
1399
|
-
service_tier?:
|
|
1399
|
+
service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
1400
1400
|
max_tool_calls?: number | undefined;
|
|
1401
1401
|
parallel_tool_calls?: boolean | undefined;
|
|
1402
1402
|
truncation?: "auto" | "disabled" | undefined;
|
|
@@ -1818,15 +1818,15 @@ export declare const protocol: Protocol<{
|
|
|
1818
1818
|
} | undefined;
|
|
1819
1819
|
readonly top_logprobs?: number | undefined;
|
|
1820
1820
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
1821
|
-
readonly service_tier?:
|
|
1821
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
1822
1822
|
readonly prompt_cache_key?: string | undefined;
|
|
1823
|
-
readonly include?: readonly
|
|
1823
|
+
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;
|
|
1824
1824
|
readonly reasoning?: {
|
|
1825
1825
|
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1826
1826
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
1827
1827
|
} | undefined;
|
|
1828
1828
|
readonly text?: {
|
|
1829
|
-
readonly verbosity?:
|
|
1829
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
1830
1830
|
} | undefined;
|
|
1831
1831
|
readonly max_output_tokens?: number | undefined;
|
|
1832
1832
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -2054,15 +2054,15 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
2054
2054
|
} | undefined;
|
|
2055
2055
|
readonly top_logprobs?: number | undefined;
|
|
2056
2056
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
2057
|
-
readonly service_tier?:
|
|
2057
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
2058
2058
|
readonly prompt_cache_key?: string | undefined;
|
|
2059
|
-
readonly include?: readonly
|
|
2059
|
+
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;
|
|
2060
2060
|
readonly reasoning?: {
|
|
2061
2061
|
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
2062
2062
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
2063
2063
|
} | undefined;
|
|
2064
2064
|
readonly text?: {
|
|
2065
|
-
readonly verbosity?:
|
|
2065
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
2066
2066
|
} | undefined;
|
|
2067
2067
|
readonly max_output_tokens?: number | undefined;
|
|
2068
2068
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -306,7 +306,7 @@ export const lowerToolChoice = (protocolName, toolChoice) => ProviderShared.matc
|
|
|
306
306
|
// provider-defined and does not necessarily identify the item's semantic type.
|
|
307
307
|
const itemID = (providerMetadata, providerMetadataKey) => {
|
|
308
308
|
const metadata = providerMetadata?.[providerMetadataKey];
|
|
309
|
-
if (!
|
|
309
|
+
if (!metadata || typeof metadata.itemId !== "string")
|
|
310
310
|
return undefined;
|
|
311
311
|
const separator = metadata.itemId.indexOf("_");
|
|
312
312
|
return separator > 0 && separator < metadata.itemId.length - 1 ? metadata.itemId : undefined;
|
|
@@ -324,7 +324,7 @@ const lowerToolCall = (part, providerMetadataKey) => {
|
|
|
324
324
|
};
|
|
325
325
|
const lowerReasoning = (part, providerMetadataKey) => {
|
|
326
326
|
const metadata = part.providerMetadata?.[providerMetadataKey];
|
|
327
|
-
if (!
|
|
327
|
+
if (!metadata)
|
|
328
328
|
return undefined;
|
|
329
329
|
const id = itemID(part.providerMetadata, providerMetadataKey);
|
|
330
330
|
const encryptedContent = typeof metadata.reasoningEncryptedContent === "string" || metadata.reasoningEncryptedContent === null
|
|
@@ -774,7 +774,7 @@ export const onReasoningDelta = (state, event, itemID) => {
|
|
|
774
774
|
// as a single delta unless that summary index already streamed one.
|
|
775
775
|
export const onReasoningDone = (state, event, itemID) => {
|
|
776
776
|
const item = state.reasoningItems[itemID];
|
|
777
|
-
if (!item ||
|
|
777
|
+
if (!item || event.text === undefined)
|
|
778
778
|
return [state, NO_EVENTS];
|
|
779
779
|
const index = event.summary_index ?? 0;
|
|
780
780
|
if (item.deltaIndexes.has(index))
|
|
@@ -4,6 +4,7 @@ import { Framing } from "../route/framing.js";
|
|
|
4
4
|
import { HttpTransport } from "../route/transport/index.js";
|
|
5
5
|
import { Protocol } from "../route/protocol.js";
|
|
6
6
|
import { AIError, LLMEvent, Usage, type FinishReasonDetails, type CacheHint, type LLMRequest } from "../schema/index.js";
|
|
7
|
+
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
7
8
|
import { Lifecycle } from "./utils/lifecycle.js";
|
|
8
9
|
import { ToolStream } from "./utils/tool-stream.js";
|
|
9
10
|
export declare const DEFAULT_BASE_URL = "https://api.openai.com/v1";
|
|
@@ -252,7 +253,7 @@ export declare const bodyFields: {
|
|
|
252
253
|
}>>;
|
|
253
254
|
store: Schema.optional<Schema.Boolean>;
|
|
254
255
|
prompt_cache_key: Schema.optional<Schema.String>;
|
|
255
|
-
reasoning_effort: Schema.optional<Schema.declare<
|
|
256
|
+
reasoning_effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
256
257
|
tool_stream: Schema.optional<Schema.Boolean>;
|
|
257
258
|
max_completion_tokens: Schema.optional<Schema.Number>;
|
|
258
259
|
max_tokens: Schema.optional<Schema.Number>;
|
|
@@ -371,7 +372,7 @@ declare const OpenAIChatBody: Schema.Struct<{
|
|
|
371
372
|
}>>;
|
|
372
373
|
store: Schema.optional<Schema.Boolean>;
|
|
373
374
|
prompt_cache_key: Schema.optional<Schema.String>;
|
|
374
|
-
reasoning_effort: Schema.optional<Schema.declare<
|
|
375
|
+
reasoning_effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
375
376
|
tool_stream: Schema.optional<Schema.Boolean>;
|
|
376
377
|
max_completion_tokens: Schema.optional<Schema.Number>;
|
|
377
378
|
max_tokens: Schema.optional<Schema.Number>;
|
|
@@ -565,7 +566,7 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
|
|
|
565
566
|
}, import("../route/client.js").CompactionOperations | undefined>>, options?: LoweringOptions | undefined) => Effect.Effect<{
|
|
566
567
|
store?: boolean | undefined;
|
|
567
568
|
prompt_cache_key?: string | undefined;
|
|
568
|
-
reasoning_effort?:
|
|
569
|
+
reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
569
570
|
model: string & import("effect/Brand").Brand<"AI.ModelID">;
|
|
570
571
|
messages: ({
|
|
571
572
|
readonly role: "system";
|
|
@@ -685,7 +686,7 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
|
|
|
685
686
|
} | {
|
|
686
687
|
store?: boolean | undefined;
|
|
687
688
|
prompt_cache_key?: string | undefined;
|
|
688
|
-
reasoning_effort?:
|
|
689
|
+
reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
689
690
|
model: string & import("effect/Brand").Brand<"AI.ModelID">;
|
|
690
691
|
messages: ({
|
|
691
692
|
readonly role: "system";
|
|
@@ -1136,7 +1137,7 @@ export declare const protocol: Protocol<{
|
|
|
1136
1137
|
} | undefined;
|
|
1137
1138
|
readonly store?: boolean | undefined;
|
|
1138
1139
|
readonly prompt_cache_key?: string | undefined;
|
|
1139
|
-
readonly reasoning_effort?:
|
|
1140
|
+
readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1140
1141
|
readonly tool_stream?: boolean | undefined;
|
|
1141
1142
|
readonly max_completion_tokens?: number | undefined;
|
|
1142
1143
|
readonly max_tokens?: number | undefined;
|
|
@@ -1331,7 +1332,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
1331
1332
|
} | undefined;
|
|
1332
1333
|
readonly store?: boolean | undefined;
|
|
1333
1334
|
readonly prompt_cache_key?: string | undefined;
|
|
1334
|
-
readonly reasoning_effort?:
|
|
1335
|
+
readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1335
1336
|
readonly tool_stream?: boolean | undefined;
|
|
1336
1337
|
readonly max_completion_tokens?: number | undefined;
|
|
1337
1338
|
readonly max_tokens?: number | undefined;
|
|
@@ -1453,7 +1454,7 @@ export declare const route: Route<{
|
|
|
1453
1454
|
} | undefined;
|
|
1454
1455
|
readonly store?: boolean | undefined;
|
|
1455
1456
|
readonly prompt_cache_key?: string | undefined;
|
|
1456
|
-
readonly reasoning_effort?:
|
|
1457
|
+
readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1457
1458
|
readonly tool_stream?: boolean | undefined;
|
|
1458
1459
|
readonly max_completion_tokens?: number | undefined;
|
|
1459
1460
|
readonly max_tokens?: number | undefined;
|
|
@@ -10,7 +10,7 @@ import { AIError, AIErrorReason, InvalidProviderOutputError, LLMEvent, ProviderI
|
|
|
10
10
|
import { classifyProviderFailure } from "../provider-error.js";
|
|
11
11
|
import { isRecord, JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared.js";
|
|
12
12
|
import { cacheControl } from "./utils/cache.js";
|
|
13
|
-
import {
|
|
13
|
+
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
14
14
|
import { Lifecycle } from "./utils/lifecycle.js";
|
|
15
15
|
import { ToolStream } from "./utils/tool-stream.js";
|
|
16
16
|
const ADAPTER = "openai-chat";
|
|
@@ -135,7 +135,7 @@ export const bodyFields = {
|
|
|
135
135
|
stream_options: Schema.optional(Schema.Struct({ include_usage: Schema.Boolean })),
|
|
136
136
|
store: Schema.optional(Schema.Boolean),
|
|
137
137
|
prompt_cache_key: Schema.optional(Schema.String),
|
|
138
|
-
reasoning_effort: Schema.optional(
|
|
138
|
+
reasoning_effort: Schema.optional(OpenResponsesOptions.ReasoningEffort),
|
|
139
139
|
tool_stream: Schema.optional(Schema.Boolean),
|
|
140
140
|
max_completion_tokens: Schema.optional(Schema.Number),
|
|
141
141
|
max_tokens: Schema.optional(Schema.Number),
|
|
@@ -588,7 +588,7 @@ const detectZaiToolStream = (provider, baseURL, modelID) => {
|
|
|
588
588
|
return true;
|
|
589
589
|
};
|
|
590
590
|
const lowerOptions = (request, supportsStore) => {
|
|
591
|
-
const options =
|
|
591
|
+
const options = OpenResponsesOptions.resolve(request);
|
|
592
592
|
// Default off: strict providers 400 on unknown body fields, so only send
|
|
593
593
|
// the key where compatibility explicitly allows it. Header-based affinity
|
|
594
594
|
// (x-session-affinity, x-grok-conv-id, ...) is unaffected.
|
|
@@ -821,9 +821,8 @@ const step = (state, event) => Effect.gen(function* () {
|
|
|
821
821
|
const choice = event.choices?.[0];
|
|
822
822
|
// Moonshot (and a few other OpenAI-compatible providers) attach usage to
|
|
823
823
|
// `choice.usage` instead of the top-level `usage` field.
|
|
824
|
-
const choiceUsage = choice?.usage;
|
|
825
824
|
const usage = mapUsage(event.usage, state.providerMetadataKey) ??
|
|
826
|
-
|
|
825
|
+
mapUsage(choice?.usage, state.providerMetadataKey) ??
|
|
827
826
|
state.usage;
|
|
828
827
|
const rawFinishReason = choice?.finish_reason;
|
|
829
828
|
const finishReason = rawFinishReason
|
|
@@ -164,15 +164,15 @@ export declare const route: Route<{
|
|
|
164
164
|
} | undefined;
|
|
165
165
|
readonly top_logprobs?: number | undefined;
|
|
166
166
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
167
|
-
readonly service_tier?: import("
|
|
167
|
+
readonly service_tier?: import("../index.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
168
168
|
readonly prompt_cache_key?: string | undefined;
|
|
169
|
-
readonly include?: readonly import("
|
|
169
|
+
readonly include?: readonly import("../index.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;
|
|
170
170
|
readonly reasoning?: {
|
|
171
171
|
readonly effort?: import("../index.js").ReasoningEffort | undefined;
|
|
172
172
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
173
173
|
} | undefined;
|
|
174
174
|
readonly text?: {
|
|
175
|
-
readonly verbosity?: import("
|
|
175
|
+
readonly verbosity?: import("../index.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
176
176
|
} | undefined;
|
|
177
177
|
readonly max_output_tokens?: number | undefined;
|
|
178
178
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -134,15 +134,15 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
134
134
|
}>>;
|
|
135
135
|
readonly top_logprobs: Schema.optional<Schema.Int>;
|
|
136
136
|
readonly truncation: Schema.optional<Schema.Literals<readonly ["auto", "disabled"]>>;
|
|
137
|
-
readonly service_tier: Schema.optional<Schema.declare<
|
|
137
|
+
readonly service_tier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">, import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">>>;
|
|
138
138
|
readonly prompt_cache_key: Schema.optional<Schema.String>;
|
|
139
|
-
readonly include: Schema.optional<Schema.$Array<Schema.declare<
|
|
139
|
+
readonly include: Schema.optional<Schema.$Array<Schema.declare<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">, 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">>>>;
|
|
140
140
|
readonly reasoning: Schema.optional<Schema.Struct<{
|
|
141
141
|
readonly effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
142
142
|
readonly summary: Schema.optional<Schema.Literals<readonly ["auto", "concise", "detailed"]>>;
|
|
143
143
|
}>>;
|
|
144
144
|
readonly text: Schema.optional<Schema.Struct<{
|
|
145
|
-
readonly verbosity: Schema.optional<Schema.declare<
|
|
145
|
+
readonly verbosity: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"high" | "low" | "medium">, import("../schema/options.js").OpenString<"high" | "low" | "medium">>>;
|
|
146
146
|
}>>;
|
|
147
147
|
readonly max_output_tokens: Schema.optional<Schema.Number>;
|
|
148
148
|
readonly max_tool_calls: Schema.optional<Schema.Int>;
|
|
@@ -339,15 +339,15 @@ export declare const protocol: Protocol<{
|
|
|
339
339
|
} | undefined;
|
|
340
340
|
readonly top_logprobs?: number | undefined;
|
|
341
341
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
342
|
-
readonly service_tier?:
|
|
342
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
343
343
|
readonly prompt_cache_key?: string | undefined;
|
|
344
|
-
readonly include?: readonly
|
|
344
|
+
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;
|
|
345
345
|
readonly reasoning?: {
|
|
346
346
|
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
347
347
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
348
348
|
} | undefined;
|
|
349
349
|
readonly text?: {
|
|
350
|
-
readonly verbosity?:
|
|
350
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
351
351
|
} | undefined;
|
|
352
352
|
readonly max_output_tokens?: number | undefined;
|
|
353
353
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -601,15 +601,15 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
601
601
|
} | undefined;
|
|
602
602
|
readonly top_logprobs?: number | undefined;
|
|
603
603
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
604
|
-
readonly service_tier?:
|
|
604
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
605
605
|
readonly prompt_cache_key?: string | undefined;
|
|
606
|
-
readonly include?: readonly
|
|
606
|
+
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;
|
|
607
607
|
readonly reasoning?: {
|
|
608
608
|
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
609
609
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
610
610
|
} | undefined;
|
|
611
611
|
readonly text?: {
|
|
612
|
-
readonly verbosity?:
|
|
612
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
613
613
|
} | undefined;
|
|
614
614
|
readonly max_output_tokens?: number | undefined;
|
|
615
615
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -805,15 +805,15 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
805
805
|
} | undefined;
|
|
806
806
|
readonly top_logprobs?: number | undefined;
|
|
807
807
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
808
|
-
readonly service_tier?:
|
|
808
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
809
809
|
readonly prompt_cache_key?: string | undefined;
|
|
810
|
-
readonly include?: readonly
|
|
810
|
+
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;
|
|
811
811
|
readonly reasoning?: {
|
|
812
812
|
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
813
813
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
814
814
|
} | undefined;
|
|
815
815
|
readonly text?: {
|
|
816
|
-
readonly verbosity?:
|
|
816
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
817
817
|
} | undefined;
|
|
818
818
|
readonly max_output_tokens?: number | undefined;
|
|
819
819
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -1009,15 +1009,15 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1009
1009
|
} | undefined;
|
|
1010
1010
|
readonly top_logprobs?: number | undefined;
|
|
1011
1011
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
1012
|
-
readonly service_tier?:
|
|
1012
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
1013
1013
|
readonly prompt_cache_key?: string | undefined;
|
|
1014
|
-
readonly include?: readonly
|
|
1014
|
+
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;
|
|
1015
1015
|
readonly reasoning?: {
|
|
1016
1016
|
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1017
1017
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
1018
1018
|
} | undefined;
|
|
1019
1019
|
readonly text?: {
|
|
1020
|
-
readonly verbosity?:
|
|
1020
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
1021
1021
|
} | undefined;
|
|
1022
1022
|
readonly max_output_tokens?: number | undefined;
|
|
1023
1023
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -1213,15 +1213,15 @@ export declare const route: Route<{
|
|
|
1213
1213
|
} | undefined;
|
|
1214
1214
|
readonly top_logprobs?: number | undefined;
|
|
1215
1215
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
1216
|
-
readonly service_tier?:
|
|
1216
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
1217
1217
|
readonly prompt_cache_key?: string | undefined;
|
|
1218
|
-
readonly include?: readonly
|
|
1218
|
+
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;
|
|
1219
1219
|
readonly reasoning?: {
|
|
1220
1220
|
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1221
1221
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
1222
1222
|
} | undefined;
|
|
1223
1223
|
readonly text?: {
|
|
1224
|
-
readonly verbosity?:
|
|
1224
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
1225
1225
|
} | undefined;
|
|
1226
1226
|
readonly max_output_tokens?: number | undefined;
|
|
1227
1227
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -3,17 +3,17 @@ import { ReasoningEffort, ReasoningEfforts, type LLMRequest } from "../../schema
|
|
|
3
3
|
export { ReasoningEffort, ReasoningEfforts };
|
|
4
4
|
export declare const TextVerbosities: readonly ["low", "medium", "high"];
|
|
5
5
|
export type TextVerbosity = (typeof TextVerbosities)[number] | (string & {});
|
|
6
|
-
export declare const TextVerbosity: Schema.declare<
|
|
6
|
+
export declare const TextVerbosity: Schema.declare<import("../../schema/options.js").OpenString<"high" | "low" | "medium">, import("../../schema/options.js").OpenString<"high" | "low" | "medium">>;
|
|
7
7
|
export declare const ResponseIncludables: readonly ["file_search_call.results", "web_search_call.results", "web_search_call.action.sources", "message.input_image.image_url", "computer_call_output.output.image_url", "code_interpreter_call.outputs", "reasoning.encrypted_content", "message.output_text.logprobs"];
|
|
8
8
|
export type ResponseIncludable = (typeof ResponseIncludables)[number] | (string & {});
|
|
9
9
|
export declare const ServiceTiers: readonly ["auto", "default", "flex", "priority"];
|
|
10
10
|
export type ServiceTier = (typeof ServiceTiers)[number] | (string & {});
|
|
11
|
-
export declare const ServiceTier: Schema.declare<
|
|
11
|
+
export declare const ServiceTier: Schema.declare<import("../../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">, import("../../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">>;
|
|
12
12
|
export declare const Truncations: readonly ["auto", "disabled"];
|
|
13
13
|
export type Truncation = (typeof Truncations)[number];
|
|
14
|
-
export declare const TextVerbositySchema: Schema.declare<
|
|
15
|
-
export declare const ResponseIncludableSchema: Schema.declare<
|
|
16
|
-
export declare const ServiceTierSchema: Schema.declare<
|
|
14
|
+
export declare const TextVerbositySchema: Schema.declare<import("../../schema/options.js").OpenString<"high" | "low" | "medium">, import("../../schema/options.js").OpenString<"high" | "low" | "medium">>;
|
|
15
|
+
export declare const ResponseIncludableSchema: Schema.declare<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">, 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">>;
|
|
16
|
+
export declare const ServiceTierSchema: Schema.declare<import("../../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">, import("../../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">>;
|
|
17
17
|
export declare const TruncationSchema: Schema.Literals<readonly ["auto", "disabled"]>;
|
|
18
18
|
export declare const AllowedTools: Schema.Struct<{
|
|
19
19
|
readonly toolNames: Schema.$Array<Schema.String>;
|
|
@@ -33,9 +33,9 @@ export declare const Options: Schema.Struct<{
|
|
|
33
33
|
readonly topLogprobs: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Int>, never>>;
|
|
34
34
|
readonly reasoningEffort: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<ReasoningEffort, ReasoningEffort>>, never>>;
|
|
35
35
|
readonly reasoningSummary: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Literals<readonly ["auto", "concise", "detailed"]>>, never>>;
|
|
36
|
-
readonly include: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.$Array<Schema.declare<
|
|
37
|
-
readonly textVerbosity: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<
|
|
38
|
-
readonly serviceTier: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<
|
|
36
|
+
readonly include: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.$Array<Schema.declare<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">, 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">>>>, never>>;
|
|
37
|
+
readonly textVerbosity: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<import("../../schema/options.js").OpenString<"high" | "low" | "medium">, import("../../schema/options.js").OpenString<"high" | "low" | "medium">>>, never>>;
|
|
38
|
+
readonly serviceTier: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<import("../../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">, import("../../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">>>, never>>;
|
|
39
39
|
readonly truncation: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Literals<readonly ["auto", "disabled"]>>, never>>;
|
|
40
40
|
readonly allowedTools: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Struct<{
|
|
41
41
|
readonly toolNames: Schema.$Array<Schema.String>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { ReasoningEffort, ReasoningEfforts } from "../../schema/index.js";
|
|
3
|
-
import { lenient } from "../shared.js";
|
|
3
|
+
import { lenient, ProviderShared } from "../shared.js";
|
|
4
4
|
export { ReasoningEffort, ReasoningEfforts };
|
|
5
5
|
export const TextVerbosities = ["low", "medium", "high"];
|
|
6
|
-
export const TextVerbosity =
|
|
6
|
+
export const TextVerbosity = ProviderShared.knownString();
|
|
7
7
|
export const ResponseIncludables = [
|
|
8
8
|
"file_search_call.results",
|
|
9
9
|
"web_search_call.results",
|
|
@@ -15,12 +15,10 @@ export const ResponseIncludables = [
|
|
|
15
15
|
"message.output_text.logprobs",
|
|
16
16
|
];
|
|
17
17
|
export const ServiceTiers = ["auto", "default", "flex", "priority"];
|
|
18
|
-
export const ServiceTier =
|
|
19
|
-
title: "ServiceTier",
|
|
20
|
-
});
|
|
18
|
+
export const ServiceTier = ProviderShared.knownString();
|
|
21
19
|
export const Truncations = ["auto", "disabled"];
|
|
22
20
|
export const TextVerbositySchema = TextVerbosity;
|
|
23
|
-
export const ResponseIncludableSchema =
|
|
21
|
+
export const ResponseIncludableSchema = ProviderShared.knownString();
|
|
24
22
|
export const ServiceTierSchema = ServiceTier;
|
|
25
23
|
export const TruncationSchema = Schema.Literals(Truncations);
|
|
26
24
|
export const AllowedTools = Schema.Struct({
|
|
@@ -25,13 +25,14 @@
|
|
|
25
25
|
* SOFTWARE.
|
|
26
26
|
*/
|
|
27
27
|
import { Schema } from "effect";
|
|
28
|
+
import { decodeJson } from "../../utils/json.js";
|
|
28
29
|
import { Allow } from "./partial-json-options.js";
|
|
29
30
|
export * from "./partial-json-options.js";
|
|
30
31
|
export class PartialJSON extends Error {
|
|
31
32
|
}
|
|
32
33
|
export class MalformedJSON extends Error {
|
|
33
34
|
}
|
|
34
|
-
const
|
|
35
|
+
const decodeJsonString = Schema.decodeUnknownSync(Schema.fromJsonString(Schema.String));
|
|
35
36
|
/** Parse complete or incomplete JSON, restricted by the supplied partial-value flags. */
|
|
36
37
|
export function parseJSON(jsonString, allowPartial = Allow.ALL) {
|
|
37
38
|
if (typeof jsonString !== "string")
|
|
@@ -159,7 +160,7 @@ const _parseJSON = (jsonString, allow) => {
|
|
|
159
160
|
}
|
|
160
161
|
if (jsonString.charAt(index) === '"') {
|
|
161
162
|
try {
|
|
162
|
-
return
|
|
163
|
+
return decodeJsonString(jsonString.substring(start, ++index - Number(escape)));
|
|
163
164
|
}
|
|
164
165
|
catch (error) {
|
|
165
166
|
throwMalformedError(String(error));
|
|
@@ -167,10 +168,10 @@ const _parseJSON = (jsonString, allow) => {
|
|
|
167
168
|
}
|
|
168
169
|
if (Allow.STR & allow) {
|
|
169
170
|
try {
|
|
170
|
-
return
|
|
171
|
+
return decodeJsonString(`${jsonString.substring(start, index - Number(escape))}"`);
|
|
171
172
|
}
|
|
172
173
|
catch {
|
|
173
|
-
return
|
|
174
|
+
return decodeJsonString(`${jsonString.substring(start, jsonString.lastIndexOf("\\"))}"`);
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
177
|
return markPartialJSON("Unterminated string literal");
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { type JsonSchema, type LanguageModel, type LLMRequest } from "../../schema/index.js";
|
|
2
2
|
import { GeminiJsonSchema } from "./gemini-json-schema.js";
|
|
3
3
|
declare const moonshot: (schema: JsonSchema) => JsonSchema;
|
|
4
|
-
declare const openAI: (schema: JsonSchema) => JsonSchema;
|
|
5
4
|
declare const tools: (entries: LLMRequest["tools"], model: LanguageModel) => LLMRequest["tools"];
|
|
6
5
|
export declare const ToolSchemaProjection: {
|
|
7
6
|
readonly gemini: typeof GeminiJsonSchema.normalize;
|
|
8
7
|
readonly moonshot: typeof moonshot;
|
|
9
|
-
readonly openAI: typeof openAI;
|
|
10
|
-
readonly responses: typeof openAI;
|
|
11
8
|
readonly tools: typeof tools;
|
|
12
9
|
};
|
|
13
10
|
export {};
|
|
@@ -48,8 +48,6 @@ const moonshot = (schema) => {
|
|
|
48
48
|
const projected = moonshotNode(schema);
|
|
49
49
|
return isRecord(projected) ? projected : {};
|
|
50
50
|
};
|
|
51
|
-
const openAI = (schema) => schema;
|
|
52
|
-
const responses = openAI;
|
|
53
51
|
const gemini = GeminiJsonSchema.normalize;
|
|
54
52
|
const MODEL_NAMES = [
|
|
55
53
|
[/gemini/i, "gemini"],
|
|
@@ -97,7 +95,5 @@ const tools = (entries, model) => entries.map((tool) => tool.type === "tool"
|
|
|
97
95
|
export const ToolSchemaProjection = {
|
|
98
96
|
gemini,
|
|
99
97
|
moonshot,
|
|
100
|
-
openAI,
|
|
101
|
-
responses,
|
|
102
98
|
tools,
|
|
103
99
|
};
|
|
@@ -49,7 +49,7 @@ const Assistant = Schema.StructWithRest(Schema.Struct({
|
|
|
49
49
|
...OpenAIChat.OpenAIChatMessage.cases.assistant.schema.fields,
|
|
50
50
|
tool_calls: optionalArray(ToolCall),
|
|
51
51
|
thought_signature: Schema.optional(Schema.String),
|
|
52
|
-
}), [
|
|
52
|
+
}), [JsonObject]);
|
|
53
53
|
const Messages = Schema.Array(Schema.Union([
|
|
54
54
|
OpenAIChat.OpenAIChatMessage.cases.system,
|
|
55
55
|
OpenAIChat.OpenAIChatMessage.cases.user,
|
|
@@ -85,16 +85,16 @@ const Delta = Schema.StructWithRest(Schema.Struct({
|
|
|
85
85
|
...OpenAIChat.OpenAIChatDelta.schema.fields,
|
|
86
86
|
tool_calls: optionalNull(Schema.Array(ToolDelta)),
|
|
87
87
|
thought_signature: optionalNull(Schema.String),
|
|
88
|
-
}), [
|
|
89
|
-
const Choice = Schema.StructWithRest(Schema.Struct({ ...OpenAIChat.OpenAIChatChoice.schema.fields, delta: optionalNull(Delta) }), [
|
|
88
|
+
}), [JsonObject]);
|
|
89
|
+
const Choice = Schema.StructWithRest(Schema.Struct({ ...OpenAIChat.OpenAIChatChoice.schema.fields, delta: optionalNull(Delta) }), [JsonObject]);
|
|
90
90
|
const Usage = Schema.StructWithRest(Schema.Struct({
|
|
91
91
|
...OpenAIChat.OpenAIChatUsage.schema.fields,
|
|
92
92
|
prompt_tokens_details: optionalNull(Schema.StructWithRest(Schema.Struct({
|
|
93
93
|
cached_tokens: optionalNull(Schema.Number),
|
|
94
94
|
cache_write_tokens: optionalNull(Schema.Number),
|
|
95
95
|
cache_creation_input_tokens: optionalNull(Schema.Number),
|
|
96
|
-
}), [
|
|
97
|
-
}), [
|
|
96
|
+
}), [JsonObject])),
|
|
97
|
+
}), [JsonObject]);
|
|
98
98
|
const Event = Schema.StructWithRest(Schema.Struct({
|
|
99
99
|
...OpenAIChat.OpenAIChatEvent.schema.fields,
|
|
100
100
|
choices: optionalNull(Schema.Array(Choice)),
|
|
@@ -104,7 +104,7 @@ const Event = Schema.StructWithRest(Schema.Struct({
|
|
|
104
104
|
message: Schema.String,
|
|
105
105
|
path: Schema.optional(Schema.Array(Schema.Union([Schema.String, Schema.Number]))),
|
|
106
106
|
})),
|
|
107
|
-
}), [
|
|
107
|
+
}), [JsonObject]);
|
|
108
108
|
const MARKER = "__ENCRYPTED_REASONING__";
|
|
109
109
|
// ---------------------------------------------------------------------------
|
|
110
110
|
// Request lowering
|