@opencode-ai/ai 0.0.0-dev-18100 → 0.0.0-dev-18103
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/open-responses.js +0 -1
- package/dist/protocols/openai-chat.d.ts +25 -11
- package/dist/protocols/openai-chat.js +124 -8
- package/dist/protocols/openai-compatible-chat.d.ts +3 -1
- package/dist/protocols/openai-responses.js +1 -1
- package/dist/providers/amazon-bedrock-mantle.d.ts +3 -1
- package/dist/providers/azure.d.ts +3 -1
- package/dist/providers/cloudflare.d.ts +9 -3
- package/dist/providers/google-vertex-chat.d.ts +3 -1
- package/dist/providers/openai-compatible.d.ts +3 -1
- package/dist/providers/openai.d.ts +3 -1
- package/dist/providers/openrouter.d.ts +11 -3
- package/dist/providers/xai.d.ts +3 -1
- package/dist/schema/options.d.ts +4 -0
- package/dist/schema/options.js +4 -0
- package/package.json +3 -3
|
@@ -917,7 +917,6 @@ export const step = (state, event) => {
|
|
|
917
917
|
}
|
|
918
918
|
if (event.type === "response.reasoning.done" ||
|
|
919
919
|
event.type === "response.reasoning_summary_text.done" ||
|
|
920
|
-
event.type === "response.reasoning_summary.done" ||
|
|
921
920
|
event.type === "response.reasoning_text.done") {
|
|
922
921
|
if (!event.item_id)
|
|
923
922
|
return ProviderShared.eventError(state.id, `${event.type} is missing item_id`);
|
|
@@ -77,6 +77,7 @@ export declare const bodyFields: {
|
|
|
77
77
|
readonly name: Schema.String;
|
|
78
78
|
readonly description: Schema.String;
|
|
79
79
|
readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
80
|
+
readonly strict: Schema.optional<Schema.Boolean>;
|
|
80
81
|
}>;
|
|
81
82
|
readonly cache_control: Schema.optional<Schema.Struct<{
|
|
82
83
|
readonly type: Schema.Literal<"ephemeral">;
|
|
@@ -96,6 +97,7 @@ export declare const bodyFields: {
|
|
|
96
97
|
store: Schema.optional<Schema.Boolean>;
|
|
97
98
|
prompt_cache_key: Schema.optional<Schema.String>;
|
|
98
99
|
reasoning_effort: Schema.optional<Schema.declare<import("./utils/open-responses-options.js").ReasoningEffort, import("./utils/open-responses-options.js").ReasoningEffort>>;
|
|
100
|
+
tool_stream: Schema.optional<Schema.Boolean>;
|
|
99
101
|
max_completion_tokens: Schema.optional<Schema.Number>;
|
|
100
102
|
max_tokens: Schema.optional<Schema.Number>;
|
|
101
103
|
temperature: Schema.optional<Schema.Number>;
|
|
@@ -171,6 +173,7 @@ declare const OpenAIChatBody: Schema.Struct<{
|
|
|
171
173
|
readonly name: Schema.String;
|
|
172
174
|
readonly description: Schema.String;
|
|
173
175
|
readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
176
|
+
readonly strict: Schema.optional<Schema.Boolean>;
|
|
174
177
|
}>;
|
|
175
178
|
readonly cache_control: Schema.optional<Schema.Struct<{
|
|
176
179
|
readonly type: Schema.Literal<"ephemeral">;
|
|
@@ -190,6 +193,7 @@ declare const OpenAIChatBody: Schema.Struct<{
|
|
|
190
193
|
store: Schema.optional<Schema.Boolean>;
|
|
191
194
|
prompt_cache_key: Schema.optional<Schema.String>;
|
|
192
195
|
reasoning_effort: Schema.optional<Schema.declare<import("./utils/open-responses-options.js").ReasoningEffort, import("./utils/open-responses-options.js").ReasoningEffort>>;
|
|
196
|
+
tool_stream: Schema.optional<Schema.Boolean>;
|
|
193
197
|
max_completion_tokens: Schema.optional<Schema.Number>;
|
|
194
198
|
max_tokens: Schema.optional<Schema.Number>;
|
|
195
199
|
temperature: Schema.optional<Schema.Number>;
|
|
@@ -292,6 +296,10 @@ export declare const fromRequest: (request: LLMRequest, options?: LoweringOption
|
|
|
292
296
|
seed: number | undefined;
|
|
293
297
|
stop: readonly string[] | undefined;
|
|
294
298
|
max_completion_tokens: number | undefined;
|
|
299
|
+
tool_stream?: boolean | undefined;
|
|
300
|
+
stream_options?: {
|
|
301
|
+
include_usage: boolean;
|
|
302
|
+
} | undefined;
|
|
295
303
|
model: string & import("effect/Brand").Brand<"AI.ModelID">;
|
|
296
304
|
messages: ({
|
|
297
305
|
readonly role: "system";
|
|
@@ -354,11 +362,12 @@ export declare const fromRequest: (request: LLMRequest, options?: LoweringOption
|
|
|
354
362
|
})[];
|
|
355
363
|
tools: {
|
|
356
364
|
readonly function: {
|
|
357
|
-
readonly name: string;
|
|
358
365
|
readonly description: string;
|
|
366
|
+
readonly name: string;
|
|
359
367
|
readonly parameters: {
|
|
360
368
|
readonly [x: string]: unknown;
|
|
361
369
|
};
|
|
370
|
+
readonly strict?: boolean | undefined;
|
|
362
371
|
};
|
|
363
372
|
readonly type: "function";
|
|
364
373
|
readonly cache_control?: {
|
|
@@ -373,9 +382,6 @@ export declare const fromRequest: (request: LLMRequest, options?: LoweringOption
|
|
|
373
382
|
};
|
|
374
383
|
} | undefined;
|
|
375
384
|
stream: true;
|
|
376
|
-
stream_options: {
|
|
377
|
-
include_usage: boolean;
|
|
378
|
-
};
|
|
379
385
|
} | {
|
|
380
386
|
reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
381
387
|
prompt_cache_key?: string | undefined;
|
|
@@ -387,6 +393,10 @@ export declare const fromRequest: (request: LLMRequest, options?: LoweringOption
|
|
|
387
393
|
seed: number | undefined;
|
|
388
394
|
stop: readonly string[] | undefined;
|
|
389
395
|
max_tokens: number | undefined;
|
|
396
|
+
tool_stream?: boolean | undefined;
|
|
397
|
+
stream_options?: {
|
|
398
|
+
include_usage: boolean;
|
|
399
|
+
} | undefined;
|
|
390
400
|
model: string & import("effect/Brand").Brand<"AI.ModelID">;
|
|
391
401
|
messages: ({
|
|
392
402
|
readonly role: "system";
|
|
@@ -449,11 +459,12 @@ export declare const fromRequest: (request: LLMRequest, options?: LoweringOption
|
|
|
449
459
|
})[];
|
|
450
460
|
tools: {
|
|
451
461
|
readonly function: {
|
|
452
|
-
readonly name: string;
|
|
453
462
|
readonly description: string;
|
|
463
|
+
readonly name: string;
|
|
454
464
|
readonly parameters: {
|
|
455
465
|
readonly [x: string]: unknown;
|
|
456
466
|
};
|
|
467
|
+
readonly strict?: boolean | undefined;
|
|
457
468
|
};
|
|
458
469
|
readonly type: "function";
|
|
459
470
|
readonly cache_control?: {
|
|
@@ -468,9 +479,6 @@ export declare const fromRequest: (request: LLMRequest, options?: LoweringOption
|
|
|
468
479
|
};
|
|
469
480
|
} | undefined;
|
|
470
481
|
stream: true;
|
|
471
|
-
stream_options: {
|
|
472
|
-
include_usage: boolean;
|
|
473
|
-
};
|
|
474
482
|
}, AIError, never>;
|
|
475
483
|
/**
|
|
476
484
|
* The OpenAI Chat protocol — request body construction, body schema, and the
|
|
@@ -544,11 +552,12 @@ export declare const protocol: Protocol<{
|
|
|
544
552
|
readonly max_tokens?: number | undefined;
|
|
545
553
|
readonly tools?: readonly {
|
|
546
554
|
readonly function: {
|
|
547
|
-
readonly name: string;
|
|
548
555
|
readonly description: string;
|
|
556
|
+
readonly name: string;
|
|
549
557
|
readonly parameters: {
|
|
550
558
|
readonly [x: string]: unknown;
|
|
551
559
|
};
|
|
560
|
+
readonly strict?: boolean | undefined;
|
|
552
561
|
};
|
|
553
562
|
readonly type: "function";
|
|
554
563
|
readonly cache_control?: {
|
|
@@ -572,6 +581,7 @@ export declare const protocol: Protocol<{
|
|
|
572
581
|
} | undefined;
|
|
573
582
|
readonly prompt_cache_key?: string | undefined;
|
|
574
583
|
readonly reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
584
|
+
readonly tool_stream?: boolean | undefined;
|
|
575
585
|
readonly frequency_penalty?: number | undefined;
|
|
576
586
|
readonly presence_penalty?: number | undefined;
|
|
577
587
|
}, string, {
|
|
@@ -706,11 +716,12 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
706
716
|
readonly max_tokens?: number | undefined;
|
|
707
717
|
readonly tools?: readonly {
|
|
708
718
|
readonly function: {
|
|
709
|
-
readonly name: string;
|
|
710
719
|
readonly description: string;
|
|
720
|
+
readonly name: string;
|
|
711
721
|
readonly parameters: {
|
|
712
722
|
readonly [x: string]: unknown;
|
|
713
723
|
};
|
|
724
|
+
readonly strict?: boolean | undefined;
|
|
714
725
|
};
|
|
715
726
|
readonly type: "function";
|
|
716
727
|
readonly cache_control?: {
|
|
@@ -734,6 +745,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
734
745
|
} | undefined;
|
|
735
746
|
readonly prompt_cache_key?: string | undefined;
|
|
736
747
|
readonly reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
748
|
+
readonly tool_stream?: boolean | undefined;
|
|
737
749
|
readonly frequency_penalty?: number | undefined;
|
|
738
750
|
readonly presence_penalty?: number | undefined;
|
|
739
751
|
}, string>;
|
|
@@ -803,11 +815,12 @@ export declare const route: Route<{
|
|
|
803
815
|
readonly max_tokens?: number | undefined;
|
|
804
816
|
readonly tools?: readonly {
|
|
805
817
|
readonly function: {
|
|
806
|
-
readonly name: string;
|
|
807
818
|
readonly description: string;
|
|
819
|
+
readonly name: string;
|
|
808
820
|
readonly parameters: {
|
|
809
821
|
readonly [x: string]: unknown;
|
|
810
822
|
};
|
|
823
|
+
readonly strict?: boolean | undefined;
|
|
811
824
|
};
|
|
812
825
|
readonly type: "function";
|
|
813
826
|
readonly cache_control?: {
|
|
@@ -831,6 +844,7 @@ export declare const route: Route<{
|
|
|
831
844
|
} | undefined;
|
|
832
845
|
readonly prompt_cache_key?: string | undefined;
|
|
833
846
|
readonly reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
847
|
+
readonly tool_stream?: boolean | undefined;
|
|
834
848
|
readonly frequency_penalty?: number | undefined;
|
|
835
849
|
readonly presence_penalty?: number | undefined;
|
|
836
850
|
}, HttpTransport.HttpPrepared<string>>;
|
|
@@ -33,7 +33,12 @@ const OpenAIChatFunction = Schema.Struct({
|
|
|
33
33
|
});
|
|
34
34
|
const OpenAIChatTool = Schema.Struct({
|
|
35
35
|
type: Schema.tag("function"),
|
|
36
|
-
function:
|
|
36
|
+
function: Schema.Struct({
|
|
37
|
+
name: Schema.String,
|
|
38
|
+
description: Schema.String,
|
|
39
|
+
parameters: JsonObject,
|
|
40
|
+
strict: Schema.optional(Schema.Boolean),
|
|
41
|
+
}),
|
|
37
42
|
cache_control: Schema.optional(OpenAIChatCacheControl),
|
|
38
43
|
});
|
|
39
44
|
const OpenAIChatAssistantToolCall = Schema.Struct({
|
|
@@ -103,6 +108,7 @@ export const bodyFields = {
|
|
|
103
108
|
store: Schema.optional(Schema.Boolean),
|
|
104
109
|
prompt_cache_key: Schema.optional(Schema.String),
|
|
105
110
|
reasoning_effort: Schema.optional(OpenAIOptions.OpenAIReasoningEffort),
|
|
111
|
+
tool_stream: Schema.optional(Schema.Boolean),
|
|
106
112
|
max_completion_tokens: Schema.optional(Schema.Number),
|
|
107
113
|
max_tokens: Schema.optional(Schema.Number),
|
|
108
114
|
temperature: Schema.optional(Schema.Number),
|
|
@@ -170,12 +176,13 @@ export const OpenAIChatEvent = Schema.Struct({
|
|
|
170
176
|
usage: optionalNull(OpenAIChatUsage),
|
|
171
177
|
error: optionalNull(OpenAIChatError),
|
|
172
178
|
});
|
|
173
|
-
const lowerTool = (tool, inputSchema, options) => ({
|
|
179
|
+
const lowerTool = (tool, inputSchema, options, supportsStrictMode) => ({
|
|
174
180
|
type: "function",
|
|
175
181
|
function: {
|
|
176
182
|
name: tool.name,
|
|
177
183
|
description: tool.description,
|
|
178
184
|
parameters: inputSchema,
|
|
185
|
+
...(supportsStrictMode ? { strict: false } : {}),
|
|
179
186
|
},
|
|
180
187
|
cache_control: options.cacheControl?.(tool.cache),
|
|
181
188
|
});
|
|
@@ -413,11 +420,110 @@ const hasToolHistory = (messages) => {
|
|
|
413
420
|
}
|
|
414
421
|
return false;
|
|
415
422
|
};
|
|
416
|
-
|
|
423
|
+
// Derive `max_tokens` vs `max_completion_tokens` from provider/baseURL when
|
|
424
|
+
// explicit `compatibility.maxTokensField` is not set. Aligned with
|
|
425
|
+
// models.dev provider naming: DeepSeek, Moonshot AI, Together AI, ZAI
|
|
426
|
+
// (Zhipu + Coding Plan variants), Nvidia, Cerebras, Chutes, etc. still
|
|
427
|
+
// require `max_tokens`.
|
|
428
|
+
const detectMaxTokensField = (provider, baseURL) => {
|
|
429
|
+
const p = provider.toLowerCase();
|
|
430
|
+
const url = (baseURL ?? "").toLowerCase();
|
|
431
|
+
if (p === "deepseek" ||
|
|
432
|
+
url.includes("deepseek.com") ||
|
|
433
|
+
p === "moonshotai" ||
|
|
434
|
+
url.includes("api.moonshot.ai") ||
|
|
435
|
+
p === "togetherai" ||
|
|
436
|
+
url.includes("api.together.") ||
|
|
437
|
+
p === "zai" ||
|
|
438
|
+
p === "zai-coding-plan" ||
|
|
439
|
+
p === "zhipuai" ||
|
|
440
|
+
p === "zhipuai-coding-plan" ||
|
|
441
|
+
url.includes("api.z.ai") ||
|
|
442
|
+
url.includes("open.bigmodel.cn") ||
|
|
443
|
+
p === "nvidia" ||
|
|
444
|
+
url.includes("integrate.api.nvidia.com") ||
|
|
445
|
+
p === "cerebras" ||
|
|
446
|
+
url.includes("cerebras.ai") ||
|
|
447
|
+
url.includes("llm.chutes.ai") ||
|
|
448
|
+
p === "chutes" ||
|
|
449
|
+
p === "cloudflare-ai-gateway" ||
|
|
450
|
+
url.includes("gateway.ai.cloudflare.com") ||
|
|
451
|
+
p === "cloudflare-workers-ai" ||
|
|
452
|
+
url.includes("api.cloudflare.com"))
|
|
453
|
+
return "max_tokens";
|
|
454
|
+
return "max_completion_tokens";
|
|
455
|
+
};
|
|
456
|
+
const detectSupportsStore = (provider, baseURL) => {
|
|
457
|
+
const p = provider.toLowerCase();
|
|
458
|
+
const url = (baseURL ?? "").toLowerCase();
|
|
459
|
+
const isNvidia = p === "nvidia" || url.includes("integrate.api.nvidia.com");
|
|
460
|
+
const isMoonshot = p === "moonshotai" || p === "moonshotai-cn" || url.includes("api.moonshot.");
|
|
461
|
+
const isTogether = p === "togetherai" || p === "together" || url.includes("api.together.");
|
|
462
|
+
const isZai = p === "zai" ||
|
|
463
|
+
p === "zai-coding-plan" ||
|
|
464
|
+
p === "zhipuai" ||
|
|
465
|
+
p === "zhipuai-coding-plan" ||
|
|
466
|
+
url.includes("api.z.ai") ||
|
|
467
|
+
url.includes("open.bigmodel.cn");
|
|
468
|
+
const isDeepSeek = p === "deepseek" || url.includes("deepseek.com");
|
|
469
|
+
const isCerebras = p === "cerebras" || url.includes("cerebras.ai");
|
|
470
|
+
const isXai = p === "xai" || url.includes("api.x.ai");
|
|
471
|
+
const isChutes = p === "chutes" || url.includes("chutes.ai");
|
|
472
|
+
const isCloudflareWorkersAI = p === "cloudflare-workers-ai" || url.includes("api.cloudflare.com");
|
|
473
|
+
const isCloudflareAiGateway = p === "cloudflare-ai-gateway" || url.includes("gateway.ai.cloudflare.com");
|
|
474
|
+
const isVercelAiGateway = p === "vercel-ai-gateway" || url.includes("ai-gateway.vercel.sh") || url.includes("vercel.sh");
|
|
475
|
+
const isAntLing = p === "ant-ling" || url.includes("api.ant-ling.com");
|
|
476
|
+
const isOpencode = p === "opencode" || url.includes("opencode.ai");
|
|
477
|
+
const isNonStandard = isNvidia ||
|
|
478
|
+
isCerebras ||
|
|
479
|
+
isXai ||
|
|
480
|
+
isTogether ||
|
|
481
|
+
isChutes ||
|
|
482
|
+
isDeepSeek ||
|
|
483
|
+
isZai ||
|
|
484
|
+
isMoonshot ||
|
|
485
|
+
isOpencode ||
|
|
486
|
+
isCloudflareWorkersAI ||
|
|
487
|
+
isCloudflareAiGateway ||
|
|
488
|
+
isVercelAiGateway ||
|
|
489
|
+
isAntLing;
|
|
490
|
+
return !isNonStandard;
|
|
491
|
+
};
|
|
492
|
+
const detectSupportsUsageInStreaming = () => true;
|
|
493
|
+
const detectSupportsStrictMode = (provider, baseURL) => {
|
|
494
|
+
const p = provider.toLowerCase();
|
|
495
|
+
const url = (baseURL ?? "").toLowerCase();
|
|
496
|
+
const isMoonshot = p === "moonshotai" || p === "moonshotai-cn" || url.includes("api.moonshot.");
|
|
497
|
+
const isTogether = p === "togetherai" || p === "together" || url.includes("api.together.");
|
|
498
|
+
const isCloudflareAiGateway = p === "cloudflare-ai-gateway" || url.includes("gateway.ai.cloudflare.com");
|
|
499
|
+
const isNvidia = p === "nvidia" || url.includes("integrate.api.nvidia.com");
|
|
500
|
+
return !isMoonshot && !isTogether && !isCloudflareAiGateway && !isNvidia;
|
|
501
|
+
};
|
|
502
|
+
const detectZaiToolStream = (provider, baseURL, modelID) => {
|
|
503
|
+
const p = provider.toLowerCase();
|
|
504
|
+
const url = (baseURL ?? "").toLowerCase();
|
|
505
|
+
const isZai = p === "zai" ||
|
|
506
|
+
p === "zai-coding-plan" ||
|
|
507
|
+
p === "zhipuai" ||
|
|
508
|
+
p === "zhipuai-coding-plan" ||
|
|
509
|
+
url.includes("api.z.ai") ||
|
|
510
|
+
url.includes("open.bigmodel.cn");
|
|
511
|
+
if (!isZai)
|
|
512
|
+
return false;
|
|
513
|
+
const id = modelID.toLowerCase();
|
|
514
|
+
if (id === "glm-4.5" || id === "glm-4.5-air" || id === "glm-4.5-flash" || id === "glm-4.5v")
|
|
515
|
+
return false;
|
|
516
|
+
return true;
|
|
517
|
+
};
|
|
518
|
+
const lowerOptions = (request, supportsStore) => {
|
|
417
519
|
const options = OpenAIOptions.resolve(request);
|
|
418
520
|
const cacheKey = ProviderShared.clampPromptCacheKey(request.promptCacheKey);
|
|
419
521
|
return {
|
|
420
|
-
...(options.store !== undefined ? { store: options.store } : {}),
|
|
522
|
+
...(supportsStore && options.store !== undefined ? { store: options.store } : {}),
|
|
523
|
+
// For providers that support `store`, ensure stateless `store:false` is sent
|
|
524
|
+
// even when no explicit `providerOptions.store` was supplied, mirroring the
|
|
525
|
+
// native OpenAI Chat default. Non-standard providers omit `store` entirely.
|
|
526
|
+
...(supportsStore && options.store === undefined ? { store: false } : {}),
|
|
421
527
|
...(cacheKey ? { prompt_cache_key: cacheKey } : {}),
|
|
422
528
|
...(options.reasoningEffort ? { reasoning_effort: options.reasoningEffort } : {}),
|
|
423
529
|
};
|
|
@@ -430,8 +536,17 @@ export const fromRequest = Effect.fn("OpenAIChat.fromRequest")(function* (reques
|
|
|
430
536
|
return yield* ProviderShared.invalidRequest(`OpenAI Chat reasoning field conflicts with reserved field ${reasoningField}`);
|
|
431
537
|
const generation = request.generation;
|
|
432
538
|
const toolSchemaCompatibility = request.model.compatibility?.toolSchema;
|
|
433
|
-
const
|
|
539
|
+
const provider = String(request.model.provider);
|
|
540
|
+
const baseURL = request.model.route.endpoint.baseURL;
|
|
541
|
+
const detectedMaxTokensField = detectMaxTokensField(provider, baseURL);
|
|
542
|
+
const maxTokensField = request.model.compatibility?.maxTokensField ?? detectedMaxTokensField;
|
|
543
|
+
const supportsStore = request.model.compatibility?.supportsStore ?? detectSupportsStore(provider, baseURL);
|
|
544
|
+
const supportsUsageInStreaming = request.model.compatibility?.supportsUsageInStreaming ?? detectSupportsUsageInStreaming();
|
|
545
|
+
const supportsStrictMode = request.model.compatibility?.supportsStrictMode ?? detectSupportsStrictMode(provider, baseURL);
|
|
546
|
+
const zaiToolStream = request.model.compatibility?.zaiToolStream ??
|
|
547
|
+
detectZaiToolStream(provider, baseURL, request.model.id);
|
|
434
548
|
const hasHistory = hasToolHistory(request.messages);
|
|
549
|
+
const hasActiveTools = request.tools.length > 0;
|
|
435
550
|
return {
|
|
436
551
|
model: request.model.id,
|
|
437
552
|
messages: yield* lowerMessages(request, options),
|
|
@@ -439,10 +554,11 @@ export const fromRequest = Effect.fn("OpenAIChat.fromRequest")(function* (reques
|
|
|
439
554
|
? hasHistory
|
|
440
555
|
? []
|
|
441
556
|
: undefined
|
|
442
|
-
: request.tools.map((tool) => lowerTool(tool, ToolSchemaProjection.modelCompatibility(tool.inputSchema, toolSchemaCompatibility), options)),
|
|
557
|
+
: request.tools.map((tool) => lowerTool(tool, ToolSchemaProjection.modelCompatibility(tool.inputSchema, toolSchemaCompatibility), options, supportsStrictMode)),
|
|
443
558
|
tool_choice: request.toolChoice ? yield* lowerToolChoice(request.toolChoice) : undefined,
|
|
444
559
|
stream: true,
|
|
445
|
-
stream_options: { include_usage: true },
|
|
560
|
+
...(supportsUsageInStreaming ? { stream_options: { include_usage: true } } : {}),
|
|
561
|
+
...(zaiToolStream && hasActiveTools ? { tool_stream: true } : {}),
|
|
446
562
|
...(maxTokensField === "max_completion_tokens"
|
|
447
563
|
? { max_completion_tokens: generation?.maxTokens }
|
|
448
564
|
: { max_tokens: generation?.maxTokens }),
|
|
@@ -452,7 +568,7 @@ export const fromRequest = Effect.fn("OpenAIChat.fromRequest")(function* (reques
|
|
|
452
568
|
presence_penalty: generation?.presencePenalty,
|
|
453
569
|
seed: generation?.seed,
|
|
454
570
|
stop: generation?.stop,
|
|
455
|
-
...lowerOptions(request),
|
|
571
|
+
...lowerOptions(request, supportsStore),
|
|
456
572
|
};
|
|
457
573
|
});
|
|
458
574
|
// =============================================================================
|
|
@@ -73,11 +73,12 @@ export declare const route: Route<{
|
|
|
73
73
|
readonly max_tokens?: number | undefined;
|
|
74
74
|
readonly tools?: readonly {
|
|
75
75
|
readonly function: {
|
|
76
|
-
readonly name: string;
|
|
77
76
|
readonly description: string;
|
|
77
|
+
readonly name: string;
|
|
78
78
|
readonly parameters: {
|
|
79
79
|
readonly [x: string]: unknown;
|
|
80
80
|
};
|
|
81
|
+
readonly strict?: boolean | undefined;
|
|
81
82
|
};
|
|
82
83
|
readonly type: "function";
|
|
83
84
|
readonly cache_control?: {
|
|
@@ -101,6 +102,7 @@ export declare const route: Route<{
|
|
|
101
102
|
} | undefined;
|
|
102
103
|
readonly prompt_cache_key?: string | undefined;
|
|
103
104
|
readonly reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
105
|
+
readonly tool_stream?: boolean | undefined;
|
|
104
106
|
readonly frequency_penalty?: number | undefined;
|
|
105
107
|
readonly presence_penalty?: number | undefined;
|
|
106
108
|
}, import("../route/transport/http.js").HttpPrepared<string>>;
|
|
@@ -135,7 +135,7 @@ const HOSTED_TOOLS = {
|
|
|
135
135
|
},
|
|
136
136
|
};
|
|
137
137
|
const step = (state, event) => {
|
|
138
|
-
if (event.type === "response.reasoning_text.delta"
|
|
138
|
+
if (event.type === "response.reasoning_text.delta")
|
|
139
139
|
return event.item_id
|
|
140
140
|
? Effect.succeed(OpenResponses.onReasoningDelta(state, event, event.item_id))
|
|
141
141
|
: ProviderShared.eventError(ADAPTER, `${event.type} is missing item_id`);
|
|
@@ -85,11 +85,12 @@ export declare const routes: (RouteDef<{
|
|
|
85
85
|
readonly max_tokens?: number | undefined;
|
|
86
86
|
readonly tools?: readonly {
|
|
87
87
|
readonly function: {
|
|
88
|
-
readonly name: string;
|
|
89
88
|
readonly description: string;
|
|
89
|
+
readonly name: string;
|
|
90
90
|
readonly parameters: {
|
|
91
91
|
readonly [x: string]: unknown;
|
|
92
92
|
};
|
|
93
|
+
readonly strict?: boolean | undefined;
|
|
93
94
|
};
|
|
94
95
|
readonly type: "function";
|
|
95
96
|
readonly cache_control?: {
|
|
@@ -113,6 +114,7 @@ export declare const routes: (RouteDef<{
|
|
|
113
114
|
} | undefined;
|
|
114
115
|
readonly prompt_cache_key?: string | undefined;
|
|
115
116
|
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
117
|
+
readonly tool_stream?: boolean | undefined;
|
|
116
118
|
readonly frequency_penalty?: number | undefined;
|
|
117
119
|
readonly presence_penalty?: number | undefined;
|
|
118
120
|
}, import("../route/transport/http.js").HttpPrepared<string>> | RouteDef<{
|
|
@@ -88,11 +88,12 @@ export declare const routes: (RouteDef<{
|
|
|
88
88
|
readonly max_tokens?: number | undefined;
|
|
89
89
|
readonly tools?: readonly {
|
|
90
90
|
readonly function: {
|
|
91
|
-
readonly name: string;
|
|
92
91
|
readonly description: string;
|
|
92
|
+
readonly name: string;
|
|
93
93
|
readonly parameters: {
|
|
94
94
|
readonly [x: string]: unknown;
|
|
95
95
|
};
|
|
96
|
+
readonly strict?: boolean | undefined;
|
|
96
97
|
};
|
|
97
98
|
readonly type: "function";
|
|
98
99
|
readonly cache_control?: {
|
|
@@ -116,6 +117,7 @@ export declare const routes: (RouteDef<{
|
|
|
116
117
|
} | undefined;
|
|
117
118
|
readonly prompt_cache_key?: string | undefined;
|
|
118
119
|
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
120
|
+
readonly tool_stream?: boolean | undefined;
|
|
119
121
|
readonly frequency_penalty?: number | undefined;
|
|
120
122
|
readonly presence_penalty?: number | undefined;
|
|
121
123
|
}, import("../route/transport/http.js").HttpPrepared<string>> | RouteDef<{
|
|
@@ -94,11 +94,12 @@ export declare const aiGatewayRoute: import("../route/client.js").Route<{
|
|
|
94
94
|
readonly max_tokens?: number | undefined;
|
|
95
95
|
readonly tools?: readonly {
|
|
96
96
|
readonly function: {
|
|
97
|
-
readonly name: string;
|
|
98
97
|
readonly description: string;
|
|
98
|
+
readonly name: string;
|
|
99
99
|
readonly parameters: {
|
|
100
100
|
readonly [x: string]: unknown;
|
|
101
101
|
};
|
|
102
|
+
readonly strict?: boolean | undefined;
|
|
102
103
|
};
|
|
103
104
|
readonly type: "function";
|
|
104
105
|
readonly cache_control?: {
|
|
@@ -122,6 +123,7 @@ export declare const aiGatewayRoute: import("../route/client.js").Route<{
|
|
|
122
123
|
} | undefined;
|
|
123
124
|
readonly prompt_cache_key?: string | undefined;
|
|
124
125
|
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
126
|
+
readonly tool_stream?: boolean | undefined;
|
|
125
127
|
readonly frequency_penalty?: number | undefined;
|
|
126
128
|
readonly presence_penalty?: number | undefined;
|
|
127
129
|
}, import("../route/transport/http.js").HttpPrepared<string>>;
|
|
@@ -191,11 +193,12 @@ export declare const workersAIRoute: import("../route/client.js").Route<{
|
|
|
191
193
|
readonly max_tokens?: number | undefined;
|
|
192
194
|
readonly tools?: readonly {
|
|
193
195
|
readonly function: {
|
|
194
|
-
readonly name: string;
|
|
195
196
|
readonly description: string;
|
|
197
|
+
readonly name: string;
|
|
196
198
|
readonly parameters: {
|
|
197
199
|
readonly [x: string]: unknown;
|
|
198
200
|
};
|
|
201
|
+
readonly strict?: boolean | undefined;
|
|
199
202
|
};
|
|
200
203
|
readonly type: "function";
|
|
201
204
|
readonly cache_control?: {
|
|
@@ -219,6 +222,7 @@ export declare const workersAIRoute: import("../route/client.js").Route<{
|
|
|
219
222
|
} | undefined;
|
|
220
223
|
readonly prompt_cache_key?: string | undefined;
|
|
221
224
|
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
225
|
+
readonly tool_stream?: boolean | undefined;
|
|
222
226
|
readonly frequency_penalty?: number | undefined;
|
|
223
227
|
readonly presence_penalty?: number | undefined;
|
|
224
228
|
}, import("../route/transport/http.js").HttpPrepared<string>>;
|
|
@@ -288,11 +292,12 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
288
292
|
readonly max_tokens?: number | undefined;
|
|
289
293
|
readonly tools?: readonly {
|
|
290
294
|
readonly function: {
|
|
291
|
-
readonly name: string;
|
|
292
295
|
readonly description: string;
|
|
296
|
+
readonly name: string;
|
|
293
297
|
readonly parameters: {
|
|
294
298
|
readonly [x: string]: unknown;
|
|
295
299
|
};
|
|
300
|
+
readonly strict?: boolean | undefined;
|
|
296
301
|
};
|
|
297
302
|
readonly type: "function";
|
|
298
303
|
readonly cache_control?: {
|
|
@@ -316,6 +321,7 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
316
321
|
} | undefined;
|
|
317
322
|
readonly prompt_cache_key?: string | undefined;
|
|
318
323
|
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
324
|
+
readonly tool_stream?: boolean | undefined;
|
|
319
325
|
readonly frequency_penalty?: number | undefined;
|
|
320
326
|
readonly presence_penalty?: number | undefined;
|
|
321
327
|
}, import("../route/transport/http.js").HttpPrepared<string>>[];
|
|
@@ -84,11 +84,12 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
84
84
|
readonly max_tokens?: number | undefined;
|
|
85
85
|
readonly tools?: readonly {
|
|
86
86
|
readonly function: {
|
|
87
|
-
readonly name: string;
|
|
88
87
|
readonly description: string;
|
|
88
|
+
readonly name: string;
|
|
89
89
|
readonly parameters: {
|
|
90
90
|
readonly [x: string]: unknown;
|
|
91
91
|
};
|
|
92
|
+
readonly strict?: boolean | undefined;
|
|
92
93
|
};
|
|
93
94
|
readonly type: "function";
|
|
94
95
|
readonly cache_control?: {
|
|
@@ -112,6 +113,7 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
112
113
|
} | undefined;
|
|
113
114
|
readonly prompt_cache_key?: string | undefined;
|
|
114
115
|
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
116
|
+
readonly tool_stream?: boolean | undefined;
|
|
115
117
|
readonly frequency_penalty?: number | undefined;
|
|
116
118
|
readonly presence_penalty?: number | undefined;
|
|
117
119
|
}, import("../route/transport/http.js").HttpPrepared<string>>[];
|
|
@@ -85,11 +85,12 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
85
85
|
readonly max_tokens?: number | undefined;
|
|
86
86
|
readonly tools?: readonly {
|
|
87
87
|
readonly function: {
|
|
88
|
-
readonly name: string;
|
|
89
88
|
readonly description: string;
|
|
89
|
+
readonly name: string;
|
|
90
90
|
readonly parameters: {
|
|
91
91
|
readonly [x: string]: unknown;
|
|
92
92
|
};
|
|
93
|
+
readonly strict?: boolean | undefined;
|
|
93
94
|
};
|
|
94
95
|
readonly type: "function";
|
|
95
96
|
readonly cache_control?: {
|
|
@@ -113,6 +114,7 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
113
114
|
} | undefined;
|
|
114
115
|
readonly prompt_cache_key?: string | undefined;
|
|
115
116
|
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
117
|
+
readonly tool_stream?: boolean | undefined;
|
|
116
118
|
readonly frequency_penalty?: number | undefined;
|
|
117
119
|
readonly presence_penalty?: number | undefined;
|
|
118
120
|
}, import("../route/transport/http.js").HttpPrepared<string>>[];
|
|
@@ -73,11 +73,12 @@ export declare const routes: (Route<{
|
|
|
73
73
|
readonly max_tokens?: number | undefined;
|
|
74
74
|
readonly tools?: readonly {
|
|
75
75
|
readonly function: {
|
|
76
|
-
readonly name: string;
|
|
77
76
|
readonly description: string;
|
|
77
|
+
readonly name: string;
|
|
78
78
|
readonly parameters: {
|
|
79
79
|
readonly [x: string]: unknown;
|
|
80
80
|
};
|
|
81
|
+
readonly strict?: boolean | undefined;
|
|
81
82
|
};
|
|
82
83
|
readonly type: "function";
|
|
83
84
|
readonly cache_control?: {
|
|
@@ -101,6 +102,7 @@ export declare const routes: (Route<{
|
|
|
101
102
|
} | undefined;
|
|
102
103
|
readonly prompt_cache_key?: string | undefined;
|
|
103
104
|
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
105
|
+
readonly tool_stream?: boolean | undefined;
|
|
104
106
|
readonly frequency_penalty?: number | undefined;
|
|
105
107
|
readonly presence_penalty?: number | undefined;
|
|
106
108
|
}, import("../route/transport/http.js").HttpPrepared<string>> | Route<{
|
|
@@ -152,6 +152,7 @@ declare const OpenRouterBody: Schema.StructWithRest<Schema.Struct<{
|
|
|
152
152
|
readonly name: Schema.String;
|
|
153
153
|
readonly description: Schema.String;
|
|
154
154
|
readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
155
|
+
readonly strict: Schema.optional<Schema.Boolean>;
|
|
155
156
|
}>;
|
|
156
157
|
readonly cache_control: Schema.optional<Schema.Struct<{
|
|
157
158
|
readonly type: Schema.Literal<"ephemeral">;
|
|
@@ -171,6 +172,7 @@ declare const OpenRouterBody: Schema.StructWithRest<Schema.Struct<{
|
|
|
171
172
|
store: Schema.optional<Schema.Boolean>;
|
|
172
173
|
prompt_cache_key: Schema.optional<Schema.String>;
|
|
173
174
|
reasoning_effort: Schema.optional<Schema.declare<import("../protocols/utils/open-responses-options.js").ReasoningEffort, import("../protocols/utils/open-responses-options.js").ReasoningEffort>>;
|
|
175
|
+
tool_stream: Schema.optional<Schema.Boolean>;
|
|
174
176
|
max_completion_tokens: Schema.optional<Schema.Number>;
|
|
175
177
|
max_tokens: Schema.optional<Schema.Number>;
|
|
176
178
|
temperature: Schema.optional<Schema.Number>;
|
|
@@ -248,11 +250,12 @@ export declare const protocol: Protocol<{
|
|
|
248
250
|
readonly max_tokens?: number | undefined;
|
|
249
251
|
readonly tools?: readonly {
|
|
250
252
|
readonly function: {
|
|
251
|
-
readonly name: string;
|
|
252
253
|
readonly description: string;
|
|
254
|
+
readonly name: string;
|
|
253
255
|
readonly parameters: {
|
|
254
256
|
readonly [x: string]: unknown;
|
|
255
257
|
};
|
|
258
|
+
readonly strict?: boolean | undefined;
|
|
256
259
|
};
|
|
257
260
|
readonly type: "function";
|
|
258
261
|
readonly cache_control?: {
|
|
@@ -276,6 +279,7 @@ export declare const protocol: Protocol<{
|
|
|
276
279
|
} | undefined;
|
|
277
280
|
readonly prompt_cache_key?: string | undefined;
|
|
278
281
|
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
282
|
+
readonly tool_stream?: boolean | undefined;
|
|
279
283
|
readonly frequency_penalty?: number | undefined;
|
|
280
284
|
readonly presence_penalty?: number | undefined;
|
|
281
285
|
}, string, {
|
|
@@ -411,11 +415,12 @@ export declare const route: Route<{
|
|
|
411
415
|
readonly max_tokens?: number | undefined;
|
|
412
416
|
readonly tools?: readonly {
|
|
413
417
|
readonly function: {
|
|
414
|
-
readonly name: string;
|
|
415
418
|
readonly description: string;
|
|
419
|
+
readonly name: string;
|
|
416
420
|
readonly parameters: {
|
|
417
421
|
readonly [x: string]: unknown;
|
|
418
422
|
};
|
|
423
|
+
readonly strict?: boolean | undefined;
|
|
419
424
|
};
|
|
420
425
|
readonly type: "function";
|
|
421
426
|
readonly cache_control?: {
|
|
@@ -439,6 +444,7 @@ export declare const route: Route<{
|
|
|
439
444
|
} | undefined;
|
|
440
445
|
readonly prompt_cache_key?: string | undefined;
|
|
441
446
|
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
447
|
+
readonly tool_stream?: boolean | undefined;
|
|
442
448
|
readonly frequency_penalty?: number | undefined;
|
|
443
449
|
readonly presence_penalty?: number | undefined;
|
|
444
450
|
}, import("../route/transport/http.js").HttpPrepared<string>>;
|
|
@@ -509,11 +515,12 @@ export declare const routes: Route<{
|
|
|
509
515
|
readonly max_tokens?: number | undefined;
|
|
510
516
|
readonly tools?: readonly {
|
|
511
517
|
readonly function: {
|
|
512
|
-
readonly name: string;
|
|
513
518
|
readonly description: string;
|
|
519
|
+
readonly name: string;
|
|
514
520
|
readonly parameters: {
|
|
515
521
|
readonly [x: string]: unknown;
|
|
516
522
|
};
|
|
523
|
+
readonly strict?: boolean | undefined;
|
|
517
524
|
};
|
|
518
525
|
readonly type: "function";
|
|
519
526
|
readonly cache_control?: {
|
|
@@ -537,6 +544,7 @@ export declare const routes: Route<{
|
|
|
537
544
|
} | undefined;
|
|
538
545
|
readonly prompt_cache_key?: string | undefined;
|
|
539
546
|
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
547
|
+
readonly tool_stream?: boolean | undefined;
|
|
540
548
|
readonly frequency_penalty?: number | undefined;
|
|
541
549
|
readonly presence_penalty?: number | undefined;
|
|
542
550
|
}, import("../route/transport/http.js").HttpPrepared<string>>[];
|
package/dist/providers/xai.d.ts
CHANGED
|
@@ -81,11 +81,12 @@ export declare const routes: (Route<{
|
|
|
81
81
|
readonly max_tokens?: number | undefined;
|
|
82
82
|
readonly tools?: readonly {
|
|
83
83
|
readonly function: {
|
|
84
|
-
readonly name: string;
|
|
85
84
|
readonly description: string;
|
|
85
|
+
readonly name: string;
|
|
86
86
|
readonly parameters: {
|
|
87
87
|
readonly [x: string]: unknown;
|
|
88
88
|
};
|
|
89
|
+
readonly strict?: boolean | undefined;
|
|
89
90
|
};
|
|
90
91
|
readonly type: "function";
|
|
91
92
|
readonly cache_control?: {
|
|
@@ -109,6 +110,7 @@ export declare const routes: (Route<{
|
|
|
109
110
|
} | undefined;
|
|
110
111
|
readonly prompt_cache_key?: string | undefined;
|
|
111
112
|
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
113
|
+
readonly tool_stream?: boolean | undefined;
|
|
112
114
|
readonly frequency_penalty?: number | undefined;
|
|
113
115
|
readonly presence_penalty?: number | undefined;
|
|
114
116
|
}, import("../route/transport/http.js").HttpPrepared<string>> | Route<unknown, import("../protocols/open-responses-channel.js").Prepared>)[];
|
package/dist/schema/options.d.ts
CHANGED
|
@@ -74,6 +74,10 @@ declare const LanguageModelCompatibility_base: Schema.Class<LanguageModelCompati
|
|
|
74
74
|
readonly reasoningField: Schema.optional<Schema.String>;
|
|
75
75
|
readonly maxTokensField: Schema.optional<Schema.Literals<readonly ["max_completion_tokens", "max_tokens"]>>;
|
|
76
76
|
readonly requireFinishReason: Schema.optional<Schema.Boolean>;
|
|
77
|
+
readonly supportsStore: Schema.optional<Schema.Boolean>;
|
|
78
|
+
readonly supportsUsageInStreaming: Schema.optional<Schema.Boolean>;
|
|
79
|
+
readonly supportsStrictMode: Schema.optional<Schema.Boolean>;
|
|
80
|
+
readonly zaiToolStream: Schema.optional<Schema.Boolean>;
|
|
77
81
|
}>, {}>;
|
|
78
82
|
export declare class LanguageModelCompatibility extends LanguageModelCompatibility_base {
|
|
79
83
|
}
|
package/dist/schema/options.js
CHANGED
|
@@ -101,6 +101,10 @@ export class LanguageModelCompatibility extends Schema.Class("LLM.LanguageModelC
|
|
|
101
101
|
reasoningField: Schema.optional(Schema.String),
|
|
102
102
|
maxTokensField: Schema.optional(LanguageModelMaxTokensFieldCompatibility),
|
|
103
103
|
requireFinishReason: Schema.optional(Schema.Boolean),
|
|
104
|
+
supportsStore: Schema.optional(Schema.Boolean),
|
|
105
|
+
supportsUsageInStreaming: Schema.optional(Schema.Boolean),
|
|
106
|
+
supportsStrictMode: Schema.optional(Schema.Boolean),
|
|
107
|
+
zaiToolStream: Schema.optional(Schema.Boolean),
|
|
104
108
|
}) {
|
|
105
109
|
}
|
|
106
110
|
(function (LanguageModelCompatibility) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-18103",
|
|
4
4
|
"name": "@opencode-ai/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
32
32
|
"@effect/platform-node": "4.0.0-rc.111",
|
|
33
|
-
"@opencode-ai/http-recorder": "0.0.0-dev-
|
|
33
|
+
"@opencode-ai/http-recorder": "0.0.0-dev-18103",
|
|
34
34
|
"@tsconfig/bun": "1.0.9",
|
|
35
35
|
"@types/bun": "1.3.13",
|
|
36
36
|
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@smithy/eventstream-codec": "4.2.14",
|
|
41
41
|
"@smithy/util-utf8": "4.2.2",
|
|
42
|
-
"@opencode-ai/schema": "0.0.0-dev-
|
|
42
|
+
"@opencode-ai/schema": "0.0.0-dev-18103",
|
|
43
43
|
"aws4fetch": "1.0.20",
|
|
44
44
|
"effect": "4.0.0-rc.111",
|
|
45
45
|
"google-auth-library": "10.5.0"
|