@opencode/ai 0.0.0-dev-21803 → 0.0.0-dev-21812
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/protocols/alibaba-chat.d.ts +6 -0
- package/dist/protocols/alibaba-messages.d.ts +1 -0
- package/dist/protocols/anthropic-messages.d.ts +5 -1
- package/dist/protocols/anthropic-messages.js +7 -0
- package/dist/protocols/meta-messages.d.ts +1 -0
- package/dist/protocols/openai-chat.d.ts +45 -0
- package/dist/protocols/openai-chat.js +19 -13
- package/dist/protocols/openai-compatible-chat.d.ts +7 -0
- package/dist/protocols/openai-responses.d.ts +40 -24
- package/dist/protocols/openai-responses.js +27 -2
- package/dist/protocols/venice-chat.d.ts +6 -0
- package/dist/protocols/xai-responses.d.ts +1 -0
- package/dist/protocols/xai-responses.js +13 -2
- package/dist/protocols/zai-chat.d.ts +7 -0
- package/dist/protocols/zai-messages.d.ts +1 -0
- package/dist/provider-error.js +1 -1
- package/dist/providers/alibaba.d.ts +7 -0
- package/dist/providers/amazon-bedrock-mantle.d.ts +139 -131
- package/dist/providers/anthropic-compatible.d.ts +1 -0
- package/dist/providers/anthropic.d.ts +1 -0
- package/dist/providers/azure.d.ts +19 -8
- package/dist/providers/baseten.d.ts +14 -0
- package/dist/providers/cerebras.d.ts +14 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +28 -8
- package/dist/providers/cloudflare-workers-ai.d.ts +14 -0
- package/dist/providers/cohere.d.ts +14 -0
- package/dist/providers/deepinfra.d.ts +14 -0
- package/dist/providers/deepseek.d.ts +14 -0
- package/dist/providers/digitalocean.d.ts +21 -0
- package/dist/providers/fireworks.d.ts +14 -0
- package/dist/providers/google-vertex-chat.d.ts +7 -0
- package/dist/providers/google-vertex-messages.d.ts +1 -0
- package/dist/providers/groq.d.ts +14 -4
- package/dist/providers/groq.js +0 -6
- package/dist/providers/meta.d.ts +139 -131
- package/dist/providers/minimax.d.ts +8 -0
- package/dist/providers/moonshot.d.ts +8 -0
- package/dist/providers/openai-compatible.d.ts +7 -0
- package/dist/providers/openai-options.d.ts +3 -1
- package/dist/providers/openai.d.ts +13 -4
- package/dist/providers/openrouter.d.ts +26 -0
- package/dist/providers/togetherai.d.ts +14 -0
- package/dist/providers/venice.d.ts +6 -0
- package/dist/providers/xai.d.ts +7 -0
- package/dist/providers/zai-coding-plan.d.ts +8 -0
- package/dist/providers/zai.d.ts +7 -0
- package/package.json +3 -3
|
@@ -155,6 +155,12 @@ export declare const protocol: Protocol<{
|
|
|
155
155
|
readonly store?: boolean | undefined;
|
|
156
156
|
readonly prompt_cache_key?: string | undefined;
|
|
157
157
|
readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
158
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
159
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
160
|
+
readonly metadata?: {
|
|
161
|
+
readonly [x: string]: string;
|
|
162
|
+
} | undefined;
|
|
163
|
+
readonly safety_identifier?: string | undefined;
|
|
158
164
|
readonly tool_stream?: boolean | undefined;
|
|
159
165
|
readonly max_completion_tokens?: number | undefined;
|
|
160
166
|
readonly max_tokens?: number | undefined;
|
|
@@ -301,6 +301,7 @@ export declare const protocol: Protocol<{
|
|
|
301
301
|
readonly user_id?: string | null | undefined;
|
|
302
302
|
} | undefined;
|
|
303
303
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
304
|
+
readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
|
|
304
305
|
readonly thinking?: {
|
|
305
306
|
readonly type: string;
|
|
306
307
|
readonly budget_tokens?: number | undefined;
|
|
@@ -102,6 +102,7 @@ declare const Options: Schema.Struct<{
|
|
|
102
102
|
readonly effort: Schema.optional<Schema.String>;
|
|
103
103
|
readonly service_tier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "standard_only">, import("../schema/options.js").OpenString<"auto" | "standard_only">>>;
|
|
104
104
|
readonly serviceTier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "standard_only">, import("../schema/options.js").OpenString<"auto" | "standard_only">>>;
|
|
105
|
+
readonly speed: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"fast" | "standard">, import("../schema/options.js").OpenString<"fast" | "standard">>>;
|
|
105
106
|
readonly metadata: Schema.optional<Schema.Struct<{
|
|
106
107
|
readonly user_id: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
107
108
|
}>>;
|
|
@@ -434,6 +435,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
|
|
|
434
435
|
readonly user_id: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
435
436
|
}>>;
|
|
436
437
|
service_tier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "standard_only">, import("../schema/options.js").OpenString<"auto" | "standard_only">>>;
|
|
438
|
+
speed: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"fast" | "standard">, import("../schema/options.js").OpenString<"fast" | "standard">>>;
|
|
437
439
|
}>;
|
|
438
440
|
export type AnthropicMessagesBody = Schema.Schema.Type<typeof AnthropicMessagesBody>;
|
|
439
441
|
/**
|
|
@@ -747,6 +749,7 @@ export declare const protocol: Protocol<{
|
|
|
747
749
|
readonly user_id?: string | null | undefined;
|
|
748
750
|
} | undefined;
|
|
749
751
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
752
|
+
readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
|
|
750
753
|
}, string, {
|
|
751
754
|
readonly [x: string]: unknown;
|
|
752
755
|
readonly type: string;
|
|
@@ -829,7 +832,7 @@ export declare const protocol: Protocol<{
|
|
|
829
832
|
reasoningSignatures: {};
|
|
830
833
|
lifecycle: Lifecycle.State;
|
|
831
834
|
}>;
|
|
832
|
-
export declare const transport: <Body extends Pick<AnthropicMessagesBody, "messages" | "context_management" | "thinking">>() => {
|
|
835
|
+
export declare const transport: <Body extends Pick<AnthropicMessagesBody, "messages" | "context_management" | "thinking" | "speed">>() => {
|
|
833
836
|
with: (patch: Partial<HttpTransport.HttpJsonInput<Body, string>>) => HttpTransport.HttpJsonTransport<Body, string>;
|
|
834
837
|
id: string;
|
|
835
838
|
execute: (prepared: HttpTransport.HttpPrepared<string>, request: LLMRequest, runtime: import("../route/transport/index.js").TransportRuntime, options?: import("../route/transport/index.js").TransportExecuteOptions) => Effect.Effect<import("../route/transport/index.js").TransportExecution<string>, AIError, import("effect/Scope").Scope>;
|
|
@@ -1141,5 +1144,6 @@ export declare const route: Route<{
|
|
|
1141
1144
|
readonly user_id?: string | null | undefined;
|
|
1142
1145
|
} | undefined;
|
|
1143
1146
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
1147
|
+
readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
|
|
1144
1148
|
}, HttpTransport.HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>;
|
|
1145
1149
|
export * as AnthropicMessages from "./anthropic-messages.js";
|
|
@@ -53,6 +53,7 @@ const AnthropicCacheControl = Schema.Struct({
|
|
|
53
53
|
ttl: Schema.optional(Schema.Literals(["5m", "1h"])),
|
|
54
54
|
});
|
|
55
55
|
const AnthropicServiceTier = knownString();
|
|
56
|
+
const AnthropicSpeed = knownString();
|
|
56
57
|
const AnthropicTextBlock = Schema.Struct({
|
|
57
58
|
type: Schema.tag("text"),
|
|
58
59
|
text: Schema.String,
|
|
@@ -287,6 +288,7 @@ const Options = Schema.Struct({
|
|
|
287
288
|
effort: Schema.optional(Schema.String),
|
|
288
289
|
service_tier: Schema.optional(AnthropicServiceTier),
|
|
289
290
|
serviceTier: Schema.optional(AnthropicServiceTier),
|
|
291
|
+
speed: Schema.optional(AnthropicSpeed),
|
|
290
292
|
metadata: Schema.optional(AnthropicMetadata),
|
|
291
293
|
container: Schema.optional(AnthropicContainer),
|
|
292
294
|
inference_geo: optionalNull(Schema.String),
|
|
@@ -325,6 +327,7 @@ const AnthropicBodyFields = {
|
|
|
325
327
|
inference_geo: Schema.optional(Schema.NullOr(Schema.String)),
|
|
326
328
|
metadata: Schema.optional(AnthropicMetadata),
|
|
327
329
|
service_tier: Schema.optional(AnthropicServiceTier),
|
|
330
|
+
speed: Schema.optional(AnthropicSpeed),
|
|
328
331
|
};
|
|
329
332
|
export const AnthropicMessagesBody = Schema.Struct(AnthropicBodyFields);
|
|
330
333
|
const AnthropicIterationUsage = Schema.StructWithRest(Schema.Struct({
|
|
@@ -964,6 +967,7 @@ const fromRequest = Effect.fn("AnthropicMessages.fromRequest")(function* (reques
|
|
|
964
967
|
inference_geo: options.inference_geo ?? options.inferenceGeo ?? undefined,
|
|
965
968
|
metadata: options.metadata,
|
|
966
969
|
service_tier: options.service_tier ?? options.serviceTier,
|
|
970
|
+
speed: options.speed,
|
|
967
971
|
};
|
|
968
972
|
if (!management)
|
|
969
973
|
return body;
|
|
@@ -1457,6 +1461,9 @@ function requiredBetaHeaders(body) {
|
|
|
1457
1461
|
betas.push("compact-2026-01-12");
|
|
1458
1462
|
if (body.messages.some((message) => message.role === "system" && message.output_config !== undefined))
|
|
1459
1463
|
betas.push("mid-conversation-output-config-2026-07-01");
|
|
1464
|
+
// Opus 5.5 accepts `speed` without this header; earlier fast-mode models reject `speed` without it.
|
|
1465
|
+
if (body.speed !== undefined)
|
|
1466
|
+
betas.push("fast-mode-2026-02-01");
|
|
1460
1467
|
const thinking = body.thinking;
|
|
1461
1468
|
if (thinking && !isThinkingOff(thinking) && thinking.block_binding)
|
|
1462
1469
|
betas.push(THINKING_BINDING_BETA);
|
|
@@ -294,6 +294,7 @@ export declare const protocol: Protocol<{
|
|
|
294
294
|
readonly user_id?: string | null | undefined;
|
|
295
295
|
} | undefined;
|
|
296
296
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
297
|
+
readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
|
|
297
298
|
readonly tools?: readonly ({
|
|
298
299
|
readonly type: "web_search";
|
|
299
300
|
readonly name: "web_search";
|
|
@@ -274,6 +274,11 @@ export declare const bodyFields: {
|
|
|
274
274
|
store: Schema.optional<Schema.Boolean>;
|
|
275
275
|
prompt_cache_key: Schema.optional<Schema.String>;
|
|
276
276
|
reasoning_effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
277
|
+
verbosity: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"high" | "low" | "medium">, import("../schema/options.js").OpenString<"high" | "low" | "medium">>>;
|
|
278
|
+
service_tier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">, import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">>>;
|
|
279
|
+
parallel_tool_calls: Schema.optional<Schema.Boolean>;
|
|
280
|
+
metadata: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
281
|
+
safety_identifier: Schema.optional<Schema.String>;
|
|
277
282
|
tool_stream: Schema.optional<Schema.Boolean>;
|
|
278
283
|
max_completion_tokens: Schema.optional<Schema.Number>;
|
|
279
284
|
max_tokens: Schema.optional<Schema.Number>;
|
|
@@ -403,6 +408,11 @@ declare const OpenAIChatBody: Schema.Struct<{
|
|
|
403
408
|
store: Schema.optional<Schema.Boolean>;
|
|
404
409
|
prompt_cache_key: Schema.optional<Schema.String>;
|
|
405
410
|
reasoning_effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
411
|
+
verbosity: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"high" | "low" | "medium">, import("../schema/options.js").OpenString<"high" | "low" | "medium">>>;
|
|
412
|
+
service_tier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">, import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">>>;
|
|
413
|
+
parallel_tool_calls: Schema.optional<Schema.Boolean>;
|
|
414
|
+
metadata: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
415
|
+
safety_identifier: Schema.optional<Schema.String>;
|
|
406
416
|
tool_stream: Schema.optional<Schema.Boolean>;
|
|
407
417
|
max_completion_tokens: Schema.optional<Schema.Number>;
|
|
408
418
|
max_tokens: Schema.optional<Schema.Number>;
|
|
@@ -597,6 +607,13 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
|
|
|
597
607
|
store?: boolean | undefined;
|
|
598
608
|
prompt_cache_key?: string | undefined;
|
|
599
609
|
reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
610
|
+
verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
611
|
+
service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
612
|
+
parallel_tool_calls?: boolean | undefined;
|
|
613
|
+
metadata?: {
|
|
614
|
+
readonly [x: string]: string;
|
|
615
|
+
} | undefined;
|
|
616
|
+
safety_identifier?: string | undefined;
|
|
600
617
|
model: string & import("effect/Brand").Brand<"AI.ModelID">;
|
|
601
618
|
messages: ({
|
|
602
619
|
readonly role: "system";
|
|
@@ -727,6 +744,13 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
|
|
|
727
744
|
store?: boolean | undefined;
|
|
728
745
|
prompt_cache_key?: string | undefined;
|
|
729
746
|
reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
747
|
+
verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
748
|
+
service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
749
|
+
parallel_tool_calls?: boolean | undefined;
|
|
750
|
+
metadata?: {
|
|
751
|
+
readonly [x: string]: string;
|
|
752
|
+
} | undefined;
|
|
753
|
+
safety_identifier?: string | undefined;
|
|
730
754
|
model: string & import("effect/Brand").Brand<"AI.ModelID">;
|
|
731
755
|
messages: ({
|
|
732
756
|
readonly role: "system";
|
|
@@ -1198,6 +1222,13 @@ export declare const protocol: Protocol<{
|
|
|
1198
1222
|
readonly store?: boolean | undefined;
|
|
1199
1223
|
readonly prompt_cache_key?: string | undefined;
|
|
1200
1224
|
readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1225
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
1226
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
1227
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
1228
|
+
readonly metadata?: {
|
|
1229
|
+
readonly [x: string]: string;
|
|
1230
|
+
} | undefined;
|
|
1231
|
+
readonly safety_identifier?: string | undefined;
|
|
1201
1232
|
readonly tool_stream?: boolean | undefined;
|
|
1202
1233
|
readonly max_completion_tokens?: number | undefined;
|
|
1203
1234
|
readonly max_tokens?: number | undefined;
|
|
@@ -1403,6 +1434,13 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
1403
1434
|
readonly store?: boolean | undefined;
|
|
1404
1435
|
readonly prompt_cache_key?: string | undefined;
|
|
1405
1436
|
readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1437
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
1438
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
1439
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
1440
|
+
readonly metadata?: {
|
|
1441
|
+
readonly [x: string]: string;
|
|
1442
|
+
} | undefined;
|
|
1443
|
+
readonly safety_identifier?: string | undefined;
|
|
1406
1444
|
readonly tool_stream?: boolean | undefined;
|
|
1407
1445
|
readonly max_completion_tokens?: number | undefined;
|
|
1408
1446
|
readonly max_tokens?: number | undefined;
|
|
@@ -1535,6 +1573,13 @@ export declare const route: Route<{
|
|
|
1535
1573
|
readonly store?: boolean | undefined;
|
|
1536
1574
|
readonly prompt_cache_key?: string | undefined;
|
|
1537
1575
|
readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1576
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
1577
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
1578
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
1579
|
+
readonly metadata?: {
|
|
1580
|
+
readonly [x: string]: string;
|
|
1581
|
+
} | undefined;
|
|
1582
|
+
readonly safety_identifier?: string | undefined;
|
|
1538
1583
|
readonly tool_stream?: boolean | undefined;
|
|
1539
1584
|
readonly max_completion_tokens?: number | undefined;
|
|
1540
1585
|
readonly max_tokens?: number | undefined;
|
|
@@ -10,6 +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 { resolveParallelToolCalls } from "./open-responses.js";
|
|
13
14
|
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
14
15
|
import { Lifecycle } from "./utils/lifecycle.js";
|
|
15
16
|
import { ToolStream } from "./utils/tool-stream.js";
|
|
@@ -140,6 +141,11 @@ export const bodyFields = {
|
|
|
140
141
|
store: Schema.optional(Schema.Boolean),
|
|
141
142
|
prompt_cache_key: Schema.optional(Schema.String),
|
|
142
143
|
reasoning_effort: Schema.optional(OpenResponsesOptions.ReasoningEffort),
|
|
144
|
+
verbosity: Schema.optional(OpenResponsesOptions.TextVerbositySchema),
|
|
145
|
+
service_tier: Schema.optional(OpenResponsesOptions.ServiceTierSchema),
|
|
146
|
+
parallel_tool_calls: Schema.optional(Schema.Boolean),
|
|
147
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
148
|
+
safety_identifier: Schema.optional(Schema.String),
|
|
143
149
|
tool_stream: Schema.optional(Schema.Boolean),
|
|
144
150
|
max_completion_tokens: Schema.optional(Schema.Number),
|
|
145
151
|
max_tokens: Schema.optional(Schema.Number),
|
|
@@ -593,8 +599,10 @@ const detectZaiToolStream = (provider, baseURL, modelID) => {
|
|
|
593
599
|
return false;
|
|
594
600
|
return true;
|
|
595
601
|
};
|
|
596
|
-
const lowerOptions = (request, supportsStore) => {
|
|
602
|
+
const lowerOptions = (request, supportsStore, hasActiveTools) => {
|
|
597
603
|
const options = OpenResponsesOptions.resolve(request);
|
|
604
|
+
// OpenAI rejects `parallel_tool_calls` unless tools are present.
|
|
605
|
+
const parallelToolCalls = hasActiveTools ? resolveParallelToolCalls(request, options) : undefined;
|
|
598
606
|
// Default off: strict providers 400 on unknown body fields, so only send
|
|
599
607
|
// the key where compatibility explicitly allows it. Header-based affinity
|
|
600
608
|
// (x-session-affinity, x-grok-conv-id, ...) is unaffected.
|
|
@@ -603,6 +611,11 @@ const lowerOptions = (request, supportsStore) => {
|
|
|
603
611
|
...(supportsStore ? { store: options.store ?? false } : {}),
|
|
604
612
|
...(cacheKey ? { prompt_cache_key: cacheKey } : {}),
|
|
605
613
|
...(options.reasoningEffort ? { reasoning_effort: options.reasoningEffort } : {}),
|
|
614
|
+
...(options.textVerbosity ? { verbosity: options.textVerbosity } : {}),
|
|
615
|
+
...(options.serviceTier ? { service_tier: options.serviceTier } : {}),
|
|
616
|
+
...(parallelToolCalls !== undefined ? { parallel_tool_calls: parallelToolCalls } : {}),
|
|
617
|
+
...(options.metadata ? { metadata: options.metadata } : {}),
|
|
618
|
+
...(options.safetyIdentifier ? { safety_identifier: options.safetyIdentifier } : {}),
|
|
606
619
|
};
|
|
607
620
|
};
|
|
608
621
|
export const fromRequest = Effect.fn("OpenAIChat.fromRequest")(function* (request, options = {}) {
|
|
@@ -644,7 +657,7 @@ export const fromRequest = Effect.fn("OpenAIChat.fromRequest")(function* (reques
|
|
|
644
657
|
presence_penalty: generation?.presencePenalty,
|
|
645
658
|
seed: generation?.seed,
|
|
646
659
|
stop: generation?.stop,
|
|
647
|
-
...lowerOptions(request, supportsStore),
|
|
660
|
+
...lowerOptions(request, supportsStore, hasActiveTools),
|
|
648
661
|
};
|
|
649
662
|
});
|
|
650
663
|
// Provider wrappers that pass their own marker writer keep it; otherwise a declared cache format adds one.
|
|
@@ -841,16 +854,9 @@ const step = (state, event) => Effect.gen(function* () {
|
|
|
841
854
|
let nextToolIndex = state.nextToolIndex;
|
|
842
855
|
let lifecycle = state.lifecycle;
|
|
843
856
|
const reasoning = reasoningDelta(delta, state.reasoningField);
|
|
844
|
-
|
|
845
|
-
Boolean(
|
|
846
|
-
|
|
847
|
-
(Array.isArray(delta?.reasoning_details) && delta.reasoning_details.length > 0) ||
|
|
848
|
-
toolDeltas.some((tool) => Boolean(tool.id) || Boolean(tool.function?.name) || Boolean(tool.function?.arguments));
|
|
849
|
-
if (state.finishReason !== undefined) {
|
|
850
|
-
if (hasLateContent)
|
|
851
|
-
return yield* ProviderShared.eventError(ADAPTER, "OpenAI Chat received content after the finish reason", ProviderShared.encodeJson(event));
|
|
852
|
-
return [{ ...state, usage }, events];
|
|
853
|
-
}
|
|
857
|
+
if (state.finishReason !== undefined &&
|
|
858
|
+
toolDeltas.some((tool) => Boolean(tool.id) || Boolean(tool.function?.name) || Boolean(tool.function?.arguments)))
|
|
859
|
+
return yield* ProviderShared.eventError(ADAPTER, "OpenAI Chat received content after the finish reason", ProviderShared.encodeJson(event));
|
|
854
860
|
const reasoningField = state.reasoningField ?? reasoning?.field;
|
|
855
861
|
const reasoningTextObserved = state.reasoningTextObserved || reasoning !== undefined;
|
|
856
862
|
const detailDelta = Array.isArray(delta?.reasoning_details)
|
|
@@ -943,7 +949,7 @@ const step = (state, event) => Effect.gen(function* () {
|
|
|
943
949
|
pendingTools,
|
|
944
950
|
toolCallEvents: finished?.events ?? state.toolCallEvents,
|
|
945
951
|
usage,
|
|
946
|
-
finishReason,
|
|
952
|
+
finishReason: state.finishReason ?? finishReason,
|
|
947
953
|
lifecycle,
|
|
948
954
|
reasoningField,
|
|
949
955
|
reasoningTextObserved,
|
|
@@ -128,6 +128,13 @@ export declare const route: Route<{
|
|
|
128
128
|
readonly store?: boolean | undefined;
|
|
129
129
|
readonly prompt_cache_key?: string | undefined;
|
|
130
130
|
readonly reasoning_effort?: import("../effect.js").ReasoningEffort | undefined;
|
|
131
|
+
readonly verbosity?: import("../effect.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
132
|
+
readonly service_tier?: import("../effect.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
133
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
134
|
+
readonly metadata?: {
|
|
135
|
+
readonly [x: string]: string;
|
|
136
|
+
} | undefined;
|
|
137
|
+
readonly safety_identifier?: string | undefined;
|
|
131
138
|
readonly tool_stream?: boolean | undefined;
|
|
132
139
|
readonly max_completion_tokens?: number | undefined;
|
|
133
140
|
readonly max_tokens?: number | undefined;
|
|
@@ -11,6 +11,10 @@ export declare const ContextManagement: Schema.$Array<Schema.Struct<{
|
|
|
11
11
|
readonly compactThreshold: Schema.optional<Schema.Int>;
|
|
12
12
|
}>>;
|
|
13
13
|
export type ContextManagement = typeof ContextManagement.Type;
|
|
14
|
+
export declare const ReasoningMode: Schema.declare<import("../schema/options.js").OpenString<"pro" | "standard">, import("../schema/options.js").OpenString<"pro" | "standard">>;
|
|
15
|
+
export type ReasoningMode = typeof ReasoningMode.Type;
|
|
16
|
+
export declare const ReasoningContext: Schema.declare<import("../schema/options.js").OpenString<"all_turns" | "auto" | "current_turn">, import("../schema/options.js").OpenString<"all_turns" | "auto" | "current_turn">>;
|
|
17
|
+
export type ReasoningContext = typeof ReasoningContext.Type;
|
|
14
18
|
declare const OpenAIResponsesBody: Schema.Struct<{
|
|
15
19
|
readonly model: Schema.String;
|
|
16
20
|
readonly input: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
@@ -140,10 +144,6 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
140
144
|
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">>>;
|
|
141
145
|
readonly prompt_cache_key: Schema.optional<Schema.String>;
|
|
142
146
|
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">>>>;
|
|
143
|
-
readonly reasoning: Schema.optional<Schema.Struct<{
|
|
144
|
-
readonly effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
145
|
-
readonly summary: Schema.optional<Schema.Literals<readonly ["auto", "concise", "detailed"]>>;
|
|
146
|
-
}>>;
|
|
147
147
|
readonly text: Schema.optional<Schema.Struct<{
|
|
148
148
|
readonly verbosity: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"high" | "low" | "medium">, import("../schema/options.js").OpenString<"high" | "low" | "medium">>>;
|
|
149
149
|
}>>;
|
|
@@ -195,6 +195,12 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
195
195
|
}>]>, Schema.Struct<{
|
|
196
196
|
readonly type: Schema.tag<"image_generation">;
|
|
197
197
|
}>]>>;
|
|
198
|
+
readonly reasoning: Schema.optional<Schema.Struct<{
|
|
199
|
+
readonly effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
200
|
+
readonly summary: Schema.optional<Schema.Literals<readonly ["auto", "concise", "detailed"]>>;
|
|
201
|
+
readonly mode: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"pro" | "standard">, import("../schema/options.js").OpenString<"pro" | "standard">>>;
|
|
202
|
+
readonly context: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"all_turns" | "auto" | "current_turn">, import("../schema/options.js").OpenString<"all_turns" | "auto" | "current_turn">>>;
|
|
203
|
+
}>>;
|
|
198
204
|
readonly context_management: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
199
205
|
readonly type: Schema.Literal<"compaction">;
|
|
200
206
|
readonly compact_threshold: Schema.optional<Schema.Int>;
|
|
@@ -348,10 +354,6 @@ export declare const protocol: Protocol<{
|
|
|
348
354
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
349
355
|
readonly prompt_cache_key?: string | undefined;
|
|
350
356
|
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;
|
|
351
|
-
readonly reasoning?: {
|
|
352
|
-
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
353
|
-
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
354
|
-
} | undefined;
|
|
355
357
|
readonly text?: {
|
|
356
358
|
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
357
359
|
} | undefined;
|
|
@@ -407,6 +409,12 @@ export declare const protocol: Protocol<{
|
|
|
407
409
|
} | {
|
|
408
410
|
readonly type: "image_generation";
|
|
409
411
|
} | undefined;
|
|
412
|
+
readonly reasoning?: {
|
|
413
|
+
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
414
|
+
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
415
|
+
readonly mode?: import("../schema/options.js").OpenString<"pro" | "standard"> | undefined;
|
|
416
|
+
readonly context?: import("../schema/options.js").OpenString<"all_turns" | "auto" | "current_turn"> | undefined;
|
|
417
|
+
} | undefined;
|
|
410
418
|
readonly context_management?: readonly {
|
|
411
419
|
readonly type: "compaction";
|
|
412
420
|
readonly compact_threshold?: number | undefined;
|
|
@@ -613,10 +621,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
613
621
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
614
622
|
readonly prompt_cache_key?: string | undefined;
|
|
615
623
|
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;
|
|
616
|
-
readonly reasoning?: {
|
|
617
|
-
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
618
|
-
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
619
|
-
} | undefined;
|
|
620
624
|
readonly text?: {
|
|
621
625
|
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
622
626
|
} | undefined;
|
|
@@ -672,6 +676,12 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
672
676
|
} | {
|
|
673
677
|
readonly type: "image_generation";
|
|
674
678
|
} | undefined;
|
|
679
|
+
readonly reasoning?: {
|
|
680
|
+
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
681
|
+
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
682
|
+
readonly mode?: import("../schema/options.js").OpenString<"pro" | "standard"> | undefined;
|
|
683
|
+
readonly context?: import("../schema/options.js").OpenString<"all_turns" | "auto" | "current_turn"> | undefined;
|
|
684
|
+
} | undefined;
|
|
675
685
|
readonly context_management?: readonly {
|
|
676
686
|
readonly type: "compaction";
|
|
677
687
|
readonly compact_threshold?: number | undefined;
|
|
@@ -820,10 +830,6 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
820
830
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
821
831
|
readonly prompt_cache_key?: string | undefined;
|
|
822
832
|
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;
|
|
823
|
-
readonly reasoning?: {
|
|
824
|
-
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
825
|
-
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
826
|
-
} | undefined;
|
|
827
833
|
readonly text?: {
|
|
828
834
|
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
829
835
|
} | undefined;
|
|
@@ -879,6 +885,12 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
879
885
|
} | {
|
|
880
886
|
readonly type: "image_generation";
|
|
881
887
|
} | undefined;
|
|
888
|
+
readonly reasoning?: {
|
|
889
|
+
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
890
|
+
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
891
|
+
readonly mode?: import("../schema/options.js").OpenString<"pro" | "standard"> | undefined;
|
|
892
|
+
readonly context?: import("../schema/options.js").OpenString<"all_turns" | "auto" | "current_turn"> | undefined;
|
|
893
|
+
} | undefined;
|
|
882
894
|
readonly context_management?: readonly {
|
|
883
895
|
readonly type: "compaction";
|
|
884
896
|
readonly compact_threshold?: number | undefined;
|
|
@@ -1027,10 +1039,6 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1027
1039
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
1028
1040
|
readonly prompt_cache_key?: string | undefined;
|
|
1029
1041
|
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;
|
|
1030
|
-
readonly reasoning?: {
|
|
1031
|
-
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1032
|
-
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
1033
|
-
} | undefined;
|
|
1034
1042
|
readonly text?: {
|
|
1035
1043
|
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
1036
1044
|
} | undefined;
|
|
@@ -1086,6 +1094,12 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1086
1094
|
} | {
|
|
1087
1095
|
readonly type: "image_generation";
|
|
1088
1096
|
} | undefined;
|
|
1097
|
+
readonly reasoning?: {
|
|
1098
|
+
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1099
|
+
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
1100
|
+
readonly mode?: import("../schema/options.js").OpenString<"pro" | "standard"> | undefined;
|
|
1101
|
+
readonly context?: import("../schema/options.js").OpenString<"all_turns" | "auto" | "current_turn"> | undefined;
|
|
1102
|
+
} | undefined;
|
|
1089
1103
|
readonly context_management?: readonly {
|
|
1090
1104
|
readonly type: "compaction";
|
|
1091
1105
|
readonly compact_threshold?: number | undefined;
|
|
@@ -1234,10 +1248,6 @@ export declare const route: Route<{
|
|
|
1234
1248
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
1235
1249
|
readonly prompt_cache_key?: string | undefined;
|
|
1236
1250
|
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;
|
|
1237
|
-
readonly reasoning?: {
|
|
1238
|
-
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1239
|
-
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
1240
|
-
} | undefined;
|
|
1241
1251
|
readonly text?: {
|
|
1242
1252
|
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
1243
1253
|
} | undefined;
|
|
@@ -1293,6 +1303,12 @@ export declare const route: Route<{
|
|
|
1293
1303
|
} | {
|
|
1294
1304
|
readonly type: "image_generation";
|
|
1295
1305
|
} | undefined;
|
|
1306
|
+
readonly reasoning?: {
|
|
1307
|
+
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1308
|
+
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
1309
|
+
readonly mode?: import("../schema/options.js").OpenString<"pro" | "standard"> | undefined;
|
|
1310
|
+
readonly context?: import("../schema/options.js").OpenString<"all_turns" | "auto" | "current_turn"> | undefined;
|
|
1311
|
+
} | undefined;
|
|
1296
1312
|
readonly context_management?: readonly {
|
|
1297
1313
|
readonly type: "compaction";
|
|
1298
1314
|
readonly compact_threshold?: number | undefined;
|
|
@@ -10,7 +10,7 @@ import { LLMRequest } from "../schema/index.js";
|
|
|
10
10
|
import { resolveEffortUpdates } from "../effort-updates.js";
|
|
11
11
|
import { OpenResponses } from "./open-responses.js";
|
|
12
12
|
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
13
|
-
import { JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared.js";
|
|
13
|
+
import { JsonObject, lenient, optionalArray, optionalNull, ProviderShared } from "./shared.js";
|
|
14
14
|
import { ResponsesHostedTools } from "./utils/responses-hosted-tools.js";
|
|
15
15
|
import { OpenResponsesChannel } from "./open-responses-channel.js";
|
|
16
16
|
import { ResponsesCompaction } from "./utils/responses-compaction.js";
|
|
@@ -25,6 +25,12 @@ export const ContextManagement = Schema.Array(Schema.Struct({
|
|
|
25
25
|
type: Schema.Literal("compaction"),
|
|
26
26
|
compactThreshold: Schema.optional(Schema.Int.check(Schema.isGreaterThan(0))),
|
|
27
27
|
}));
|
|
28
|
+
export const ReasoningMode = ProviderShared.knownString();
|
|
29
|
+
export const ReasoningContext = ProviderShared.knownString();
|
|
30
|
+
const ReasoningOptions = Schema.Struct({
|
|
31
|
+
reasoningMode: lenient(ReasoningMode),
|
|
32
|
+
reasoningContext: lenient(ReasoningContext),
|
|
33
|
+
});
|
|
28
34
|
const OpenAIResponsesImageGenerationTool = Schema.Struct({
|
|
29
35
|
type: Schema.tag("image_generation"),
|
|
30
36
|
action: Schema.optional(Schema.Literals(["auto", "generate", "edit"])),
|
|
@@ -86,6 +92,12 @@ const OpenAIResponsesCoreFields = {
|
|
|
86
92
|
...OpenResponses.coreFields,
|
|
87
93
|
tools: optionalArray(OpenAIResponsesTools),
|
|
88
94
|
tool_choice: Schema.optional(OpenAIResponsesToolChoice),
|
|
95
|
+
reasoning: Schema.optional(Schema.Struct({
|
|
96
|
+
effort: Schema.optional(OpenResponsesOptions.ReasoningEffort),
|
|
97
|
+
summary: Schema.optional(Schema.Literals(["auto", "concise", "detailed"])),
|
|
98
|
+
mode: Schema.optional(ReasoningMode),
|
|
99
|
+
context: Schema.optional(ReasoningContext),
|
|
100
|
+
})),
|
|
89
101
|
context_management: Schema.optional(Schema.Array(Schema.Struct({
|
|
90
102
|
type: Schema.Literal("compaction"),
|
|
91
103
|
compact_threshold: Schema.optional(Schema.Int.check(Schema.isGreaterThan(0))),
|
|
@@ -111,6 +123,8 @@ const adapter = {
|
|
|
111
123
|
const supportsEffortUpdates = (request) => {
|
|
112
124
|
if (request.providerOptions?.contextManagement !== undefined)
|
|
113
125
|
return false;
|
|
126
|
+
if (request.providerOptions?.reasoningMode === "pro")
|
|
127
|
+
return false;
|
|
114
128
|
if (Schema.is(Schema.Struct({ mode: Schema.Literal("pro") }))(request.http?.body?.reasoning))
|
|
115
129
|
return false;
|
|
116
130
|
const override = request.model.compatibility?.supportsEffortUpdates;
|
|
@@ -162,10 +176,21 @@ const lowerToolChoice = (toolChoice, tools) => ProviderShared.matchToolChoice(NA
|
|
|
162
176
|
const fromRequest = Effect.fn("OpenAIResponses.fromRequest")(function* (request) {
|
|
163
177
|
const management = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Schema.UndefinedOr(ContextManagement)))(request.providerOptions?.contextManagement);
|
|
164
178
|
const options = OpenResponsesOptions.resolve(request);
|
|
179
|
+
const reasoning = Schema.decodeUnknownSync(ReasoningOptions)(request.providerOptions ?? {});
|
|
165
180
|
const updates = resolveEffortUpdates(request, options.reasoningEffort);
|
|
181
|
+
const generation = OpenResponses.lowerGeneration(request, { ...options, reasoningEffort: updates.effort });
|
|
166
182
|
return {
|
|
167
183
|
...(yield* OpenResponses.lowerConversation(updates.request, adapter)),
|
|
168
|
-
...
|
|
184
|
+
...generation,
|
|
185
|
+
...(generation.reasoning || reasoning.reasoningMode || reasoning.reasoningContext
|
|
186
|
+
? {
|
|
187
|
+
reasoning: {
|
|
188
|
+
...generation.reasoning,
|
|
189
|
+
mode: reasoning.reasoningMode,
|
|
190
|
+
context: reasoning.reasoningContext,
|
|
191
|
+
},
|
|
192
|
+
}
|
|
193
|
+
: {}),
|
|
169
194
|
context_management: management?.map((edit) => ({ type: edit.type, compact_threshold: edit.compactThreshold })),
|
|
170
195
|
tools: request.tools.length === 0 ? undefined : yield* lowerTools(request),
|
|
171
196
|
tool_choice: request.tools.length === 0
|
|
@@ -80,6 +80,12 @@ export declare const protocol: Protocol<{
|
|
|
80
80
|
readonly store?: boolean | undefined;
|
|
81
81
|
readonly prompt_cache_key?: string | undefined;
|
|
82
82
|
readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
83
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
84
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
85
|
+
readonly metadata?: {
|
|
86
|
+
readonly [x: string]: string;
|
|
87
|
+
} | undefined;
|
|
88
|
+
readonly safety_identifier?: string | undefined;
|
|
83
89
|
readonly tool_stream?: boolean | undefined;
|
|
84
90
|
readonly max_completion_tokens?: number | undefined;
|
|
85
91
|
readonly max_tokens?: number | undefined;
|
|
@@ -180,6 +180,7 @@ export declare const protocol: Protocol<{
|
|
|
180
180
|
readonly presence_penalty?: number | undefined;
|
|
181
181
|
readonly frequency_penalty?: number | undefined;
|
|
182
182
|
readonly stream: true;
|
|
183
|
+
readonly top_k?: number | undefined;
|
|
183
184
|
}, string, {
|
|
184
185
|
readonly [x: string]: unknown;
|
|
185
186
|
readonly type: string;
|
|
@@ -21,6 +21,10 @@ const XAIResponsesHostedToolItem = Schema.Union([
|
|
|
21
21
|
error: Schema.optional(Schema.Unknown),
|
|
22
22
|
}), [JsonObject]),
|
|
23
23
|
]);
|
|
24
|
+
const Body = Schema.Struct({
|
|
25
|
+
...OpenResponses.OpenResponsesBody.fields,
|
|
26
|
+
top_k: Schema.optional(Schema.Number),
|
|
27
|
+
});
|
|
24
28
|
const adapter = {
|
|
25
29
|
id: ADAPTER,
|
|
26
30
|
name: NAME,
|
|
@@ -43,7 +47,14 @@ const fromRequest = Effect.fn("XAIResponses.fromRequest")(function* (request) {
|
|
|
43
47
|
route: request.model.route.id,
|
|
44
48
|
message: "xAI requires explicit compaction through LLMClient.compact; automatic context management is not supported",
|
|
45
49
|
});
|
|
46
|
-
|
|
50
|
+
const body = yield* OpenResponses.fromRequestWithAdapter(request, adapter);
|
|
51
|
+
// xAI Responses does not support penalties (they are ignored), but does support top_k.
|
|
52
|
+
return {
|
|
53
|
+
...body,
|
|
54
|
+
presence_penalty: undefined,
|
|
55
|
+
frequency_penalty: undefined,
|
|
56
|
+
top_k: request.generation?.topK,
|
|
57
|
+
};
|
|
47
58
|
});
|
|
48
59
|
const HOSTED_TOOLS = {
|
|
49
60
|
web_search_call: { name: "web_search", input: (item) => item.action ?? {} },
|
|
@@ -70,7 +81,7 @@ const step = (state, input) => {
|
|
|
70
81
|
export const protocol = Protocol.make({
|
|
71
82
|
id: ADAPTER,
|
|
72
83
|
body: {
|
|
73
|
-
schema:
|
|
84
|
+
schema: Body,
|
|
74
85
|
from: fromRequest,
|
|
75
86
|
},
|
|
76
87
|
stream: {
|
|
@@ -147,6 +147,13 @@ export declare const protocol: Protocol<{
|
|
|
147
147
|
readonly store?: boolean | undefined;
|
|
148
148
|
readonly prompt_cache_key?: string | undefined;
|
|
149
149
|
readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
150
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
151
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
152
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
153
|
+
readonly metadata?: {
|
|
154
|
+
readonly [x: string]: string;
|
|
155
|
+
} | undefined;
|
|
156
|
+
readonly safety_identifier?: string | undefined;
|
|
150
157
|
readonly tool_stream?: boolean | undefined;
|
|
151
158
|
readonly max_completion_tokens?: number | undefined;
|
|
152
159
|
readonly max_tokens?: number | undefined;
|
|
@@ -298,6 +298,7 @@ export declare const protocol: Protocol<{
|
|
|
298
298
|
readonly user_id?: string | null | undefined;
|
|
299
299
|
} | undefined;
|
|
300
300
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
301
|
+
readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
|
|
301
302
|
readonly thinking?: {
|
|
302
303
|
readonly type: import("../schema/options.js").OpenString<"adaptive" | "disabled" | "enabled">;
|
|
303
304
|
} | undefined;
|
package/dist/provider-error.js
CHANGED
|
@@ -203,7 +203,7 @@ export function classifyProviderFailure(input) {
|
|
|
203
203
|
(codes.includes("context_length_exceeded") ||
|
|
204
204
|
codes.includes("model_context_window_exceeded") ||
|
|
205
205
|
codes.includes("request_too_large") ||
|
|
206
|
-
isContextOverflow(text)))
|
|
206
|
+
(!codes.includes("throttlingexception") && isContextOverflow(text))))
|
|
207
207
|
return new InvalidRequestError({ ...details, classification: "context-overflow" });
|
|
208
208
|
if (input.status === 413 || isPayloadTooLarge(text))
|
|
209
209
|
return new InvalidRequestError({ ...details, classification: "payload-too-large" });
|