@opencode/ai 2.1.2 → 2.1.4
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 +3 -11
- package/dist/experimental/realtime.d.ts +59 -0
- package/dist/experimental/realtime.js +21 -13
- package/dist/experimental.d.ts +1 -1
- package/dist/generation.js +1 -1
- package/dist/image-client.d.ts +11 -9
- package/dist/image.d.ts +158 -150
- 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/promise.d.ts +121 -121
- package/dist/promise.js +3 -5
- package/dist/protocols/alibaba-chat.d.ts +18 -18
- package/dist/protocols/alibaba-chat.js +3 -3
- package/dist/protocols/alibaba-messages.d.ts +12 -12
- package/dist/protocols/alibaba-messages.js +1 -1
- package/dist/protocols/alibaba-responses.d.ts +38 -38
- package/dist/protocols/anthropic-messages.d.ts +40 -44
- package/dist/protocols/anthropic-messages.js +13 -15
- package/dist/protocols/bedrock-converse.d.ts +36 -85
- package/dist/protocols/bedrock-converse.js +6 -6
- package/dist/protocols/bedrock-event-stream.d.ts +6 -1
- package/dist/protocols/bedrock-event-stream.js +9 -8
- package/dist/protocols/cartesia-speech.d.ts +32 -32
- package/dist/protocols/cohere-chat.d.ts +13 -10
- package/dist/protocols/cohere-chat.js +2 -2
- package/dist/protocols/deepgram-speech.d.ts +32 -32
- package/dist/protocols/elevenlabs-speech.d.ts +32 -32
- package/dist/protocols/gemini.d.ts +46 -36
- package/dist/protocols/gemini.js +12 -15
- package/dist/protocols/google-interactions.d.ts +14 -13
- package/dist/protocols/google-interactions.js +16 -11
- package/dist/protocols/google-speech.d.ts +32 -32
- package/dist/protocols/google-transcription.d.ts +32 -32
- package/dist/protocols/meta-messages.d.ts +23 -23
- package/dist/protocols/meta-responses.d.ts +84 -84
- package/dist/protocols/mistral-chat.d.ts +81 -78
- package/dist/protocols/mistral-chat.js +3 -5
- package/dist/protocols/open-responses-channel.js +47 -46
- package/dist/protocols/open-responses-continuation.d.ts +8 -2
- package/dist/protocols/open-responses-continuation.js +3 -1
- package/dist/protocols/open-responses.d.ts +419 -419
- package/dist/protocols/open-responses.js +11 -10
- package/dist/protocols/openai-chat.d.ts +68 -67
- package/dist/protocols/openai-chat.js +7 -8
- package/dist/protocols/openai-compatible-chat.d.ts +13 -14
- package/dist/protocols/openai-compatible-responses.d.ts +39 -40
- package/dist/protocols/openai-images.d.ts +32 -32
- package/dist/protocols/openai-responses.d.ts +253 -253
- package/dist/protocols/openai-responses.js +1 -1
- package/dist/protocols/openai-speech.d.ts +32 -32
- package/dist/protocols/openai-transcription.d.ts +32 -32
- package/dist/protocols/openai-transcription.js +12 -7
- 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-options.d.ts +0 -1
- package/dist/protocols/utils/partial-json-options.js +0 -1
- 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/utils/tool-stream.d.ts +1 -1
- package/dist/protocols/venice-chat.d.ts +52 -53
- package/dist/protocols/venice-chat.js +6 -5
- package/dist/protocols/xai-images.js +3 -4
- package/dist/protocols/xai-responses.d.ts +81 -81
- package/dist/protocols/zai-chat.d.ts +33 -30
- package/dist/protocols/zai-chat.js +8 -3
- package/dist/protocols/zai-messages.d.ts +21 -19
- package/dist/protocols/zai-messages.js +3 -2
- package/dist/provider-error.js +8 -7
- package/dist/providers/alibaba.d.ts +74 -74
- package/dist/providers/amazon-bedrock-mantle.d.ts +202 -202
- package/dist/providers/amazon-bedrock.d.ts +16 -13
- package/dist/providers/anthropic-compatible.d.ts +13 -13
- package/dist/providers/anthropic.d.ts +13 -13
- package/dist/providers/azure.d.ts +112 -112
- package/dist/providers/baseten.d.ts +24 -24
- package/dist/providers/cerebras.d.ts +24 -24
- package/dist/providers/cloudflare-ai-gateway.d.ts +237 -234
- package/dist/providers/cloudflare-ai-gateway.js +3 -6
- package/dist/providers/cloudflare-workers-ai.d.ts +24 -24
- package/dist/providers/cohere.d.ts +78 -74
- package/dist/providers/deepinfra.d.ts +24 -24
- package/dist/providers/deepseek.d.ts +24 -24
- package/dist/providers/digitalocean.d.ts +36 -36
- package/dist/providers/fireworks.d.ts +24 -24
- package/dist/providers/google-vertex-chat.d.ts +12 -12
- package/dist/providers/google-vertex-interactions.d.ts +3 -3
- package/dist/providers/google-vertex-messages.d.ts +20 -20
- package/dist/providers/google-vertex-mistral.d.ts +14 -14
- package/dist/providers/google-vertex-responses.d.ts +38 -38
- package/dist/providers/google-vertex.d.ts +17 -17
- package/dist/providers/google-vertex.js +2 -2
- package/dist/providers/google.d.ts +79 -79
- package/dist/providers/groq.d.ts +24 -24
- package/dist/providers/meta.d.ts +189 -189
- package/dist/providers/minimax.d.ts +202 -202
- package/dist/providers/mistral.d.ts +28 -28
- package/dist/providers/moonshot.d.ts +202 -202
- package/dist/providers/open-responses-options.d.ts +0 -1
- package/dist/providers/open-responses-options.js +1 -1
- package/dist/providers/openai-compatible-responses.d.ts +38 -38
- package/dist/providers/openai-compatible.d.ts +12 -12
- package/dist/providers/openai-compatible.js +1 -1
- package/dist/providers/openai-options.d.ts +3 -4
- package/dist/providers/openai-options.js +0 -1
- package/dist/providers/openai.d.ts +103 -103
- package/dist/providers/openrouter.d.ts +171 -112
- package/dist/providers/openrouter.js +40 -33
- package/dist/providers/togetherai.d.ts +24 -24
- package/dist/providers/venice.d.ts +195 -20
- package/dist/providers/xai.d.ts +12 -12
- package/dist/providers/zai-coding-plan.d.ts +152 -72
- package/dist/providers/zai.d.ts +84 -19
- package/dist/route/auth-options.d.ts +0 -3
- package/dist/route/auth.d.ts +0 -2
- package/dist/route/auth.js +0 -2
- package/dist/route/client.d.ts +0 -218
- package/dist/route/client.js +3 -7
- package/dist/route/executor-service.js +1 -1
- package/dist/route/transport/http.js +5 -8
- package/dist/schema/errors.d.ts +1 -1
- package/dist/schema/errors.js +1 -1
- package/dist/schema/messages.js +4 -7
- package/dist/speech-client.d.ts +11 -9
- package/dist/speech.d.ts +158 -150
- package/dist/speech.js +2 -2
- package/dist/transcription-client.d.ts +11 -9
- package/dist/transcription.d.ts +158 -150
- package/dist/transcription.js +2 -2
- package/dist/video-client.d.ts +11 -9
- package/dist/video.d.ts +124 -116
- package/dist/video.js +2 -2
- package/package.json +7 -6
- package/dist/protocols/utils/openai-options.d.ts +0 -16
- package/dist/protocols/utils/openai-options.js +0 -15
|
@@ -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
|
|
@@ -566,7 +566,7 @@ export const lowerConversation = Effect.fnUntraced(function* (request, adapter)
|
|
|
566
566
|
export const lowerGeneration = (request, options = OpenResponsesOptions.resolve(request)) => {
|
|
567
567
|
const generation = request.generation;
|
|
568
568
|
const cacheKey = ProviderShared.promptCacheKey(request);
|
|
569
|
-
const parallelToolCalls = resolveParallelToolCalls(request);
|
|
569
|
+
const parallelToolCalls = resolveParallelToolCalls(request, options);
|
|
570
570
|
return {
|
|
571
571
|
stream: true,
|
|
572
572
|
max_output_tokens: generation?.maxTokens,
|
|
@@ -593,15 +593,15 @@ export const lowerGeneration = (request, options = OpenResponsesOptions.resolve(
|
|
|
593
593
|
...(options.truncation ? { truncation: options.truncation } : {}),
|
|
594
594
|
};
|
|
595
595
|
};
|
|
596
|
-
export const resolveParallelToolCalls = (request) => {
|
|
597
|
-
const configured =
|
|
596
|
+
export const resolveParallelToolCalls = (request, options = OpenResponsesOptions.resolve(request)) => {
|
|
597
|
+
const configured = options.parallelToolCalls;
|
|
598
598
|
if (configured !== undefined)
|
|
599
599
|
return configured;
|
|
600
600
|
const disabled = request.toolChoice?.disableParallelToolUse;
|
|
601
601
|
return disabled === undefined ? undefined : !disabled;
|
|
602
602
|
};
|
|
603
|
-
export const allowedToolChoice = (request) => {
|
|
604
|
-
const allowed =
|
|
603
|
+
export const allowedToolChoice = (request, options = OpenResponsesOptions.resolve(request)) => {
|
|
604
|
+
const allowed = options.allowedTools;
|
|
605
605
|
if (!allowed)
|
|
606
606
|
return undefined;
|
|
607
607
|
return {
|
|
@@ -612,11 +612,12 @@ export const allowedToolChoice = (request) => {
|
|
|
612
612
|
};
|
|
613
613
|
export const fromRequestWithAdapter = Effect.fn("OpenResponses.fromRequestWithAdapter")(function* (request, adapter) {
|
|
614
614
|
const projected = ProviderShared.flattenToolRequest(request);
|
|
615
|
+
const options = OpenResponsesOptions.resolve(request);
|
|
615
616
|
return {
|
|
616
617
|
...(yield* lowerConversation(projected.request, adapter)),
|
|
617
|
-
...lowerGeneration(request),
|
|
618
|
+
...lowerGeneration(request, options),
|
|
618
619
|
tools: projected.tools.length === 0 ? undefined : yield* lowerTools(projected.tools, adapter),
|
|
619
|
-
tool_choice: allowedToolChoice(request) ??
|
|
620
|
+
tool_choice: allowedToolChoice(request, options) ??
|
|
620
621
|
(request.toolChoice ? yield* lowerToolChoice(adapter.name, request.toolChoice) : undefined),
|
|
621
622
|
};
|
|
622
623
|
});
|
|
@@ -774,7 +775,7 @@ export const onReasoningDelta = (state, event, itemID) => {
|
|
|
774
775
|
// as a single delta unless that summary index already streamed one.
|
|
775
776
|
export const onReasoningDone = (state, event, itemID) => {
|
|
776
777
|
const item = state.reasoningItems[itemID];
|
|
777
|
-
if (!item ||
|
|
778
|
+
if (!item || event.text === undefined)
|
|
778
779
|
return [state, NO_EVENTS];
|
|
779
780
|
const index = event.summary_index ?? 0;
|
|
780
781
|
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,18 +566,11 @@ 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";
|
|
572
573
|
readonly content: string | readonly ({
|
|
573
|
-
readonly type: "text";
|
|
574
|
-
readonly text: string;
|
|
575
|
-
readonly cache_control?: {
|
|
576
|
-
readonly type: "ephemeral";
|
|
577
|
-
readonly ttl?: string | undefined;
|
|
578
|
-
} | undefined;
|
|
579
|
-
} | {
|
|
580
574
|
readonly type: "image_url";
|
|
581
575
|
readonly image_url: {
|
|
582
576
|
readonly url: string;
|
|
@@ -587,17 +581,17 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
|
|
|
587
581
|
readonly filename: string;
|
|
588
582
|
readonly file_data: string;
|
|
589
583
|
};
|
|
590
|
-
}
|
|
591
|
-
} | {
|
|
592
|
-
readonly role: "user";
|
|
593
|
-
readonly content: string | readonly ({
|
|
584
|
+
} | {
|
|
594
585
|
readonly type: "text";
|
|
595
586
|
readonly text: string;
|
|
596
587
|
readonly cache_control?: {
|
|
597
588
|
readonly type: "ephemeral";
|
|
598
589
|
readonly ttl?: string | undefined;
|
|
599
590
|
} | undefined;
|
|
600
|
-
}
|
|
591
|
+
})[];
|
|
592
|
+
} | {
|
|
593
|
+
readonly role: "user";
|
|
594
|
+
readonly content: string | readonly ({
|
|
601
595
|
readonly type: "image_url";
|
|
602
596
|
readonly image_url: {
|
|
603
597
|
readonly url: string;
|
|
@@ -608,6 +602,13 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
|
|
|
608
602
|
readonly filename: string;
|
|
609
603
|
readonly file_data: string;
|
|
610
604
|
};
|
|
605
|
+
} | {
|
|
606
|
+
readonly type: "text";
|
|
607
|
+
readonly text: string;
|
|
608
|
+
readonly cache_control?: {
|
|
609
|
+
readonly type: "ephemeral";
|
|
610
|
+
readonly ttl?: string | undefined;
|
|
611
|
+
} | undefined;
|
|
611
612
|
})[];
|
|
612
613
|
} | {
|
|
613
614
|
readonly role: "tool";
|
|
@@ -685,18 +686,11 @@ 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";
|
|
692
693
|
readonly content: string | readonly ({
|
|
693
|
-
readonly type: "text";
|
|
694
|
-
readonly text: string;
|
|
695
|
-
readonly cache_control?: {
|
|
696
|
-
readonly type: "ephemeral";
|
|
697
|
-
readonly ttl?: string | undefined;
|
|
698
|
-
} | undefined;
|
|
699
|
-
} | {
|
|
700
694
|
readonly type: "image_url";
|
|
701
695
|
readonly image_url: {
|
|
702
696
|
readonly url: string;
|
|
@@ -707,17 +701,17 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
|
|
|
707
701
|
readonly filename: string;
|
|
708
702
|
readonly file_data: string;
|
|
709
703
|
};
|
|
710
|
-
}
|
|
711
|
-
} | {
|
|
712
|
-
readonly role: "user";
|
|
713
|
-
readonly content: string | readonly ({
|
|
704
|
+
} | {
|
|
714
705
|
readonly type: "text";
|
|
715
706
|
readonly text: string;
|
|
716
707
|
readonly cache_control?: {
|
|
717
708
|
readonly type: "ephemeral";
|
|
718
709
|
readonly ttl?: string | undefined;
|
|
719
710
|
} | undefined;
|
|
720
|
-
}
|
|
711
|
+
})[];
|
|
712
|
+
} | {
|
|
713
|
+
readonly role: "user";
|
|
714
|
+
readonly content: string | readonly ({
|
|
721
715
|
readonly type: "image_url";
|
|
722
716
|
readonly image_url: {
|
|
723
717
|
readonly url: string;
|
|
@@ -728,6 +722,13 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
|
|
|
728
722
|
readonly filename: string;
|
|
729
723
|
readonly file_data: string;
|
|
730
724
|
};
|
|
725
|
+
} | {
|
|
726
|
+
readonly type: "text";
|
|
727
|
+
readonly text: string;
|
|
728
|
+
readonly cache_control?: {
|
|
729
|
+
readonly type: "ephemeral";
|
|
730
|
+
readonly ttl?: string | undefined;
|
|
731
|
+
} | undefined;
|
|
731
732
|
})[];
|
|
732
733
|
} | {
|
|
733
734
|
readonly role: "tool";
|
|
@@ -1030,13 +1031,6 @@ export declare const protocol: Protocol<{
|
|
|
1030
1031
|
readonly messages: readonly ({
|
|
1031
1032
|
readonly role: "system";
|
|
1032
1033
|
readonly content: string | readonly ({
|
|
1033
|
-
readonly type: "text";
|
|
1034
|
-
readonly text: string;
|
|
1035
|
-
readonly cache_control?: {
|
|
1036
|
-
readonly type: "ephemeral";
|
|
1037
|
-
readonly ttl?: string | undefined;
|
|
1038
|
-
} | undefined;
|
|
1039
|
-
} | {
|
|
1040
1034
|
readonly type: "image_url";
|
|
1041
1035
|
readonly image_url: {
|
|
1042
1036
|
readonly url: string;
|
|
@@ -1047,17 +1041,17 @@ export declare const protocol: Protocol<{
|
|
|
1047
1041
|
readonly filename: string;
|
|
1048
1042
|
readonly file_data: string;
|
|
1049
1043
|
};
|
|
1050
|
-
}
|
|
1051
|
-
} | {
|
|
1052
|
-
readonly role: "user";
|
|
1053
|
-
readonly content: string | readonly ({
|
|
1044
|
+
} | {
|
|
1054
1045
|
readonly type: "text";
|
|
1055
1046
|
readonly text: string;
|
|
1056
1047
|
readonly cache_control?: {
|
|
1057
1048
|
readonly type: "ephemeral";
|
|
1058
1049
|
readonly ttl?: string | undefined;
|
|
1059
1050
|
} | undefined;
|
|
1060
|
-
}
|
|
1051
|
+
})[];
|
|
1052
|
+
} | {
|
|
1053
|
+
readonly role: "user";
|
|
1054
|
+
readonly content: string | readonly ({
|
|
1061
1055
|
readonly type: "image_url";
|
|
1062
1056
|
readonly image_url: {
|
|
1063
1057
|
readonly url: string;
|
|
@@ -1068,6 +1062,13 @@ export declare const protocol: Protocol<{
|
|
|
1068
1062
|
readonly filename: string;
|
|
1069
1063
|
readonly file_data: string;
|
|
1070
1064
|
};
|
|
1065
|
+
} | {
|
|
1066
|
+
readonly type: "text";
|
|
1067
|
+
readonly text: string;
|
|
1068
|
+
readonly cache_control?: {
|
|
1069
|
+
readonly type: "ephemeral";
|
|
1070
|
+
readonly ttl?: string | undefined;
|
|
1071
|
+
} | undefined;
|
|
1071
1072
|
})[];
|
|
1072
1073
|
} | {
|
|
1073
1074
|
readonly role: "tool";
|
|
@@ -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;
|
|
@@ -1225,13 +1226,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
1225
1226
|
readonly messages: readonly ({
|
|
1226
1227
|
readonly role: "system";
|
|
1227
1228
|
readonly content: string | readonly ({
|
|
1228
|
-
readonly type: "text";
|
|
1229
|
-
readonly text: string;
|
|
1230
|
-
readonly cache_control?: {
|
|
1231
|
-
readonly type: "ephemeral";
|
|
1232
|
-
readonly ttl?: string | undefined;
|
|
1233
|
-
} | undefined;
|
|
1234
|
-
} | {
|
|
1235
1229
|
readonly type: "image_url";
|
|
1236
1230
|
readonly image_url: {
|
|
1237
1231
|
readonly url: string;
|
|
@@ -1242,17 +1236,17 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
1242
1236
|
readonly filename: string;
|
|
1243
1237
|
readonly file_data: string;
|
|
1244
1238
|
};
|
|
1245
|
-
}
|
|
1246
|
-
} | {
|
|
1247
|
-
readonly role: "user";
|
|
1248
|
-
readonly content: string | readonly ({
|
|
1239
|
+
} | {
|
|
1249
1240
|
readonly type: "text";
|
|
1250
1241
|
readonly text: string;
|
|
1251
1242
|
readonly cache_control?: {
|
|
1252
1243
|
readonly type: "ephemeral";
|
|
1253
1244
|
readonly ttl?: string | undefined;
|
|
1254
1245
|
} | undefined;
|
|
1255
|
-
}
|
|
1246
|
+
})[];
|
|
1247
|
+
} | {
|
|
1248
|
+
readonly role: "user";
|
|
1249
|
+
readonly content: string | readonly ({
|
|
1256
1250
|
readonly type: "image_url";
|
|
1257
1251
|
readonly image_url: {
|
|
1258
1252
|
readonly url: string;
|
|
@@ -1263,6 +1257,13 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
1263
1257
|
readonly filename: string;
|
|
1264
1258
|
readonly file_data: string;
|
|
1265
1259
|
};
|
|
1260
|
+
} | {
|
|
1261
|
+
readonly type: "text";
|
|
1262
|
+
readonly text: string;
|
|
1263
|
+
readonly cache_control?: {
|
|
1264
|
+
readonly type: "ephemeral";
|
|
1265
|
+
readonly ttl?: string | undefined;
|
|
1266
|
+
} | undefined;
|
|
1266
1267
|
})[];
|
|
1267
1268
|
} | {
|
|
1268
1269
|
readonly role: "tool";
|
|
@@ -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;
|
|
@@ -1347,13 +1348,6 @@ export declare const route: Route<{
|
|
|
1347
1348
|
readonly messages: readonly ({
|
|
1348
1349
|
readonly role: "system";
|
|
1349
1350
|
readonly content: string | readonly ({
|
|
1350
|
-
readonly type: "text";
|
|
1351
|
-
readonly text: string;
|
|
1352
|
-
readonly cache_control?: {
|
|
1353
|
-
readonly type: "ephemeral";
|
|
1354
|
-
readonly ttl?: string | undefined;
|
|
1355
|
-
} | undefined;
|
|
1356
|
-
} | {
|
|
1357
1351
|
readonly type: "image_url";
|
|
1358
1352
|
readonly image_url: {
|
|
1359
1353
|
readonly url: string;
|
|
@@ -1364,17 +1358,17 @@ export declare const route: Route<{
|
|
|
1364
1358
|
readonly filename: string;
|
|
1365
1359
|
readonly file_data: string;
|
|
1366
1360
|
};
|
|
1367
|
-
}
|
|
1368
|
-
} | {
|
|
1369
|
-
readonly role: "user";
|
|
1370
|
-
readonly content: string | readonly ({
|
|
1361
|
+
} | {
|
|
1371
1362
|
readonly type: "text";
|
|
1372
1363
|
readonly text: string;
|
|
1373
1364
|
readonly cache_control?: {
|
|
1374
1365
|
readonly type: "ephemeral";
|
|
1375
1366
|
readonly ttl?: string | undefined;
|
|
1376
1367
|
} | undefined;
|
|
1377
|
-
}
|
|
1368
|
+
})[];
|
|
1369
|
+
} | {
|
|
1370
|
+
readonly role: "user";
|
|
1371
|
+
readonly content: string | readonly ({
|
|
1378
1372
|
readonly type: "image_url";
|
|
1379
1373
|
readonly image_url: {
|
|
1380
1374
|
readonly url: string;
|
|
@@ -1385,6 +1379,13 @@ export declare const route: Route<{
|
|
|
1385
1379
|
readonly filename: string;
|
|
1386
1380
|
readonly file_data: string;
|
|
1387
1381
|
};
|
|
1382
|
+
} | {
|
|
1383
|
+
readonly type: "text";
|
|
1384
|
+
readonly text: string;
|
|
1385
|
+
readonly cache_control?: {
|
|
1386
|
+
readonly type: "ephemeral";
|
|
1387
|
+
readonly ttl?: string | undefined;
|
|
1388
|
+
} | undefined;
|
|
1388
1389
|
})[];
|
|
1389
1390
|
} | {
|
|
1390
1391
|
readonly role: "tool";
|
|
@@ -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),
|
|
@@ -419,7 +419,7 @@ const lowerMessages = Effect.fnUntraced(function* (request, options) {
|
|
|
419
419
|
const mistral = ["mistral", "devstral", "codestral", "pixtral", "mixtral"].some((family) => modelID.includes(family));
|
|
420
420
|
const lowering = {
|
|
421
421
|
...options,
|
|
422
|
-
providerMetadataKey: request.model.route.providerMetadataKey ??
|
|
422
|
+
providerMetadataKey: request.model.route.providerMetadataKey ?? request.model.provider,
|
|
423
423
|
toolCallID: (id) => {
|
|
424
424
|
if (mistral)
|
|
425
425
|
return id
|
|
@@ -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.
|
|
@@ -607,7 +607,7 @@ export const fromRequest = Effect.fn("OpenAIChat.fromRequest")(function* (reques
|
|
|
607
607
|
return yield* ProviderShared.invalidRequest(`OpenAI Chat reasoning field conflicts with reserved field ${reasoningField}`);
|
|
608
608
|
const generation = request.generation;
|
|
609
609
|
const flattened = ProviderShared.flattenToolRequest(request);
|
|
610
|
-
const provider =
|
|
610
|
+
const provider = request.model.provider;
|
|
611
611
|
const baseURL = request.model.route.endpoint.baseURL;
|
|
612
612
|
const detectedMaxTokensField = detectMaxTokensField(provider, baseURL);
|
|
613
613
|
const maxTokensField = request.model.compatibility?.maxTokensField ?? detectedMaxTokensField;
|
|
@@ -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
|
|
@@ -1006,7 +1005,7 @@ export const protocol = Protocol.make({
|
|
|
1006
1005
|
stream: {
|
|
1007
1006
|
event: OpenAIChatStreamEvent,
|
|
1008
1007
|
initial: (request) => ({
|
|
1009
|
-
providerMetadataKey: request.model.route.providerMetadataKey ??
|
|
1008
|
+
providerMetadataKey: request.model.route.providerMetadataKey ?? request.model.provider,
|
|
1010
1009
|
tools: ToolStream.empty(),
|
|
1011
1010
|
pendingTools: {},
|
|
1012
1011
|
toolCallEvents: [],
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Route
|
|
2
|
-
export type OpenAICompatibleChatLanguageModelInput = RouteRoutedLanguageModelInput;
|
|
1
|
+
import { Route } from "../route/client.js";
|
|
3
2
|
/**
|
|
4
3
|
* Route for non-OpenAI providers that expose an OpenAI Chat-compatible
|
|
5
4
|
* `/chat/completions` endpoint. Reuses `OpenAIChat.protocol` end-to-end and
|
|
@@ -12,13 +11,6 @@ export declare const route: Route<{
|
|
|
12
11
|
readonly messages: readonly ({
|
|
13
12
|
readonly role: "system";
|
|
14
13
|
readonly content: string | readonly ({
|
|
15
|
-
readonly type: "text";
|
|
16
|
-
readonly text: string;
|
|
17
|
-
readonly cache_control?: {
|
|
18
|
-
readonly type: "ephemeral";
|
|
19
|
-
readonly ttl?: string | undefined;
|
|
20
|
-
} | undefined;
|
|
21
|
-
} | {
|
|
22
14
|
readonly type: "image_url";
|
|
23
15
|
readonly image_url: {
|
|
24
16
|
readonly url: string;
|
|
@@ -29,17 +21,17 @@ export declare const route: Route<{
|
|
|
29
21
|
readonly filename: string;
|
|
30
22
|
readonly file_data: string;
|
|
31
23
|
};
|
|
32
|
-
}
|
|
33
|
-
} | {
|
|
34
|
-
readonly role: "user";
|
|
35
|
-
readonly content: string | readonly ({
|
|
24
|
+
} | {
|
|
36
25
|
readonly type: "text";
|
|
37
26
|
readonly text: string;
|
|
38
27
|
readonly cache_control?: {
|
|
39
28
|
readonly type: "ephemeral";
|
|
40
29
|
readonly ttl?: string | undefined;
|
|
41
30
|
} | undefined;
|
|
42
|
-
}
|
|
31
|
+
})[];
|
|
32
|
+
} | {
|
|
33
|
+
readonly role: "user";
|
|
34
|
+
readonly content: string | readonly ({
|
|
43
35
|
readonly type: "image_url";
|
|
44
36
|
readonly image_url: {
|
|
45
37
|
readonly url: string;
|
|
@@ -50,6 +42,13 @@ export declare const route: Route<{
|
|
|
50
42
|
readonly filename: string;
|
|
51
43
|
readonly file_data: string;
|
|
52
44
|
};
|
|
45
|
+
} | {
|
|
46
|
+
readonly type: "text";
|
|
47
|
+
readonly text: string;
|
|
48
|
+
readonly cache_control?: {
|
|
49
|
+
readonly type: "ephemeral";
|
|
50
|
+
readonly ttl?: string | undefined;
|
|
51
|
+
} | undefined;
|
|
53
52
|
})[];
|
|
54
53
|
} | {
|
|
55
54
|
readonly role: "tool";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Route
|
|
2
|
-
export type OpenAICompatibleResponsesLanguageModelInput = RouteRoutedLanguageModelInput;
|
|
1
|
+
import { Route } from "../route/client.js";
|
|
3
2
|
/**
|
|
4
3
|
* Deployment adapter for providers that expose an Open Responses-compatible
|
|
5
4
|
* `/responses` endpoint. Provider helpers configure identity, endpoint, and
|
|
@@ -8,10 +7,6 @@ export type OpenAICompatibleResponsesLanguageModelInput = RouteRoutedLanguageMod
|
|
|
8
7
|
export declare const route: Route<{
|
|
9
8
|
readonly model: string;
|
|
10
9
|
readonly input: readonly ({
|
|
11
|
-
readonly type: "compaction";
|
|
12
|
-
readonly id?: string | null | undefined;
|
|
13
|
-
readonly encrypted_content: string;
|
|
14
|
-
} | {
|
|
15
10
|
readonly type: "configuration_update";
|
|
16
11
|
readonly reasoning: {
|
|
17
12
|
readonly effort: import("../index.js").ReasoningEffort;
|
|
@@ -24,10 +19,45 @@ export declare const route: Route<{
|
|
|
24
19
|
readonly type: "message";
|
|
25
20
|
readonly role: "developer";
|
|
26
21
|
readonly content: string;
|
|
22
|
+
} | {
|
|
23
|
+
readonly type: "function_call_output";
|
|
24
|
+
readonly call_id: string;
|
|
25
|
+
readonly output: string | readonly ({
|
|
26
|
+
readonly type: "input_text";
|
|
27
|
+
readonly text: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly type: "input_video";
|
|
30
|
+
readonly video_url: string;
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: "input_image";
|
|
33
|
+
readonly image_url: string;
|
|
34
|
+
readonly detail?: string | undefined;
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: "input_file";
|
|
37
|
+
readonly filename: string;
|
|
38
|
+
readonly detail?: string | undefined;
|
|
39
|
+
readonly file_data?: string | undefined;
|
|
40
|
+
readonly file_url?: string | undefined;
|
|
41
|
+
})[];
|
|
42
|
+
} | {
|
|
43
|
+
readonly type: "reasoning";
|
|
44
|
+
readonly id?: string | undefined;
|
|
45
|
+
readonly summary: readonly {
|
|
46
|
+
readonly type: "summary_text";
|
|
47
|
+
readonly text: string;
|
|
48
|
+
}[];
|
|
49
|
+
readonly encrypted_content?: string | null | undefined;
|
|
50
|
+
} | {
|
|
51
|
+
readonly type: "compaction";
|
|
52
|
+
readonly id?: string | null | undefined;
|
|
53
|
+
readonly encrypted_content: string;
|
|
27
54
|
} | {
|
|
28
55
|
readonly type: "message";
|
|
29
56
|
readonly role: "user";
|
|
30
57
|
readonly content: readonly ({
|
|
58
|
+
readonly type: "input_text";
|
|
59
|
+
readonly text: string;
|
|
60
|
+
} | {
|
|
31
61
|
readonly type: "input_image";
|
|
32
62
|
readonly image_url: string;
|
|
33
63
|
readonly detail?: string | undefined;
|
|
@@ -37,9 +67,6 @@ export declare const route: Route<{
|
|
|
37
67
|
readonly detail?: string | undefined;
|
|
38
68
|
readonly file_data?: string | undefined;
|
|
39
69
|
readonly file_url?: string | undefined;
|
|
40
|
-
} | {
|
|
41
|
-
readonly type: "input_text";
|
|
42
|
-
readonly text: string;
|
|
43
70
|
})[];
|
|
44
71
|
readonly id?: string | undefined;
|
|
45
72
|
readonly status?: string | undefined;
|
|
@@ -53,14 +80,6 @@ export declare const route: Route<{
|
|
|
53
80
|
}[];
|
|
54
81
|
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
55
82
|
readonly status?: string | undefined;
|
|
56
|
-
} | {
|
|
57
|
-
readonly type: "reasoning";
|
|
58
|
-
readonly id?: string | undefined;
|
|
59
|
-
readonly summary: readonly {
|
|
60
|
-
readonly type: "summary_text";
|
|
61
|
-
readonly text: string;
|
|
62
|
-
}[];
|
|
63
|
-
readonly encrypted_content?: string | null | undefined;
|
|
64
83
|
} | {
|
|
65
84
|
readonly type: "function_call";
|
|
66
85
|
readonly id?: string | undefined;
|
|
@@ -68,26 +87,6 @@ export declare const route: Route<{
|
|
|
68
87
|
readonly name: string;
|
|
69
88
|
readonly namespace?: string | undefined;
|
|
70
89
|
readonly arguments: string;
|
|
71
|
-
} | {
|
|
72
|
-
readonly type: "function_call_output";
|
|
73
|
-
readonly call_id: string;
|
|
74
|
-
readonly output: string | readonly ({
|
|
75
|
-
readonly type: "input_image";
|
|
76
|
-
readonly image_url: string;
|
|
77
|
-
readonly detail?: string | undefined;
|
|
78
|
-
} | {
|
|
79
|
-
readonly type: "input_file";
|
|
80
|
-
readonly filename: string;
|
|
81
|
-
readonly detail?: string | undefined;
|
|
82
|
-
readonly file_data?: string | undefined;
|
|
83
|
-
readonly file_url?: string | undefined;
|
|
84
|
-
} | {
|
|
85
|
-
readonly type: "input_text";
|
|
86
|
-
readonly text: string;
|
|
87
|
-
} | {
|
|
88
|
-
readonly type: "input_video";
|
|
89
|
-
readonly video_url: string;
|
|
90
|
-
})[];
|
|
91
90
|
} | {
|
|
92
91
|
readonly [x: string]: unknown;
|
|
93
92
|
readonly type: "web_search_call";
|
|
@@ -164,15 +163,15 @@ export declare const route: Route<{
|
|
|
164
163
|
} | undefined;
|
|
165
164
|
readonly top_logprobs?: number | undefined;
|
|
166
165
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
167
|
-
readonly service_tier?: import("
|
|
166
|
+
readonly service_tier?: import("../index.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
168
167
|
readonly prompt_cache_key?: string | undefined;
|
|
169
|
-
readonly include?: readonly import("
|
|
168
|
+
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
169
|
readonly reasoning?: {
|
|
171
170
|
readonly effort?: import("../index.js").ReasoningEffort | undefined;
|
|
172
171
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
173
172
|
} | undefined;
|
|
174
173
|
readonly text?: {
|
|
175
|
-
readonly verbosity?: import("
|
|
174
|
+
readonly verbosity?: import("../index.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
176
175
|
} | undefined;
|
|
177
176
|
readonly max_output_tokens?: number | undefined;
|
|
178
177
|
readonly max_tool_calls?: number | undefined;
|