@opencode/ai 2.0.3 → 2.0.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 +10 -2
- package/dist/effort-updates.d.ts +12 -0
- package/dist/effort-updates.js +23 -0
- package/dist/protocols/alibaba-messages.d.ts +4 -1
- package/dist/protocols/alibaba-responses.d.ts +3 -1
- package/dist/protocols/anthropic-messages.d.ts +11 -2
- package/dist/protocols/anthropic-messages.js +48 -17
- package/dist/protocols/bedrock-converse.js +17 -12
- package/dist/protocols/meta-messages.d.ts +4 -1
- package/dist/protocols/meta-responses.d.ts +8 -4
- package/dist/protocols/mistral-chat.js +5 -33
- package/dist/protocols/open-responses-channel.js +4 -0
- package/dist/protocols/open-responses.d.ts +27 -9
- package/dist/protocols/open-responses.js +24 -8
- package/dist/protocols/openai-chat.d.ts +7 -7
- package/dist/protocols/openai-chat.js +10 -4
- package/dist/protocols/openai-compatible-chat.d.ts +1 -1
- package/dist/protocols/openai-compatible-responses.d.ts +4 -2
- package/dist/protocols/openai-responses.d.ts +74 -31
- package/dist/protocols/openai-responses.js +27 -6
- package/dist/protocols/utils/bedrock-media.d.ts +10 -8
- package/dist/protocols/utils/bedrock-media.js +29 -5
- package/dist/protocols/utils/mistral-tool-id.d.ts +5 -0
- package/dist/protocols/utils/mistral-tool-id.js +31 -0
- package/dist/protocols/utils/open-responses-options.d.ts +2 -4
- package/dist/protocols/utils/open-responses-options.js +2 -2
- package/dist/protocols/utils/responses-compaction.js +3 -1
- package/dist/protocols/xai-responses.d.ts +4 -2
- package/dist/protocols/zai-chat.d.ts +1 -1
- package/dist/protocols/zai-messages.d.ts +4 -1
- package/dist/provider-error.js +40 -4
- package/dist/providers/alibaba.d.ts +15 -10
- package/dist/providers/amazon-bedrock-mantle.d.ts +5 -3
- package/dist/providers/anthropic-compatible.d.ts +4 -1
- package/dist/providers/anthropic.d.ts +4 -1
- package/dist/providers/azure.d.ts +19 -5
- package/dist/providers/azure.js +1 -8
- package/dist/providers/baseten.d.ts +2 -2
- package/dist/providers/cerebras.d.ts +2 -2
- package/dist/providers/cerebras.js +1 -1
- package/dist/providers/cloudflare-ai-gateway.d.ts +1024 -13
- package/dist/providers/cloudflare-ai-gateway.js +64 -27
- package/dist/providers/cloudflare-workers-ai.d.ts +3 -3
- package/dist/providers/cloudflare-workers-ai.js +1 -1
- package/dist/providers/deepinfra.d.ts +2 -2
- package/dist/providers/deepinfra.js +1 -1
- package/dist/providers/deepseek.d.ts +2 -2
- package/dist/providers/fireworks.d.ts +2 -2
- package/dist/providers/fireworks.js +1 -1
- package/dist/providers/google-vertex-chat.d.ts +1 -1
- package/dist/providers/google-vertex-messages.d.ts +4 -1
- package/dist/providers/google-vertex-responses.d.ts +4 -2
- package/dist/providers/google-vertex.js +5 -1
- package/dist/providers/groq.d.ts +2 -2
- package/dist/providers/meta.d.ts +9 -4
- package/dist/providers/meta.js +1 -1
- package/dist/providers/minimax.d.ts +9 -4
- package/dist/providers/moonshot.d.ts +9 -4
- package/dist/providers/moonshot.js +1 -0
- package/dist/providers/openai-compatible-responses.d.ts +4 -2
- package/dist/providers/openai-compatible.d.ts +1 -1
- package/dist/providers/openai.d.ts +10 -3
- package/dist/providers/openai.js +4 -1
- package/dist/providers/openrouter.d.ts +4 -4
- package/dist/providers/openrouter.js +1 -1
- package/dist/providers/togetherai.d.ts +2 -2
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/zai-coding-plan.d.ts +9 -4
- package/dist/providers/zai.d.ts +1 -1
- package/dist/route/client.d.ts +1 -0
- package/dist/route/client.js +3 -1
- package/dist/route/protocol.d.ts +2 -0
- package/dist/schema/messages.d.ts +22 -3
- package/dist/schema/messages.js +9 -1
- package/dist/schema/options.d.ts +6 -0
- package/dist/schema/options.js +7 -0
- package/package.json +3 -3
|
@@ -43,7 +43,6 @@ export declare const MessagePhase: Schema.NullOr<Schema.Literals<readonly ["comm
|
|
|
43
43
|
type MessagePhase = Schema.Schema.Type<typeof MessagePhase>;
|
|
44
44
|
export declare const MessageMetadata: Schema.Struct<{
|
|
45
45
|
readonly itemId: Schema.optional<Schema.String>;
|
|
46
|
-
readonly type: Schema.optional<Schema.Literal<"message">>;
|
|
47
46
|
readonly status: Schema.optional<Schema.String>;
|
|
48
47
|
readonly phase: Schema.optional<Schema.NullOr<Schema.Literals<readonly ["commentary", "final_answer"]>>>;
|
|
49
48
|
}>;
|
|
@@ -90,17 +89,27 @@ export declare const CompactionItem: Schema.Struct<{
|
|
|
90
89
|
readonly id: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
91
90
|
readonly encrypted_content: Schema.String;
|
|
92
91
|
}>;
|
|
92
|
+
export declare const ConfigurationUpdate: Schema.Struct<{
|
|
93
|
+
readonly type: Schema.Literal<"configuration_update">;
|
|
94
|
+
readonly reasoning: Schema.Struct<{
|
|
95
|
+
readonly effort: Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>;
|
|
96
|
+
}>;
|
|
97
|
+
}>;
|
|
98
|
+
type ConfigurationUpdate = Schema.Schema.Type<typeof ConfigurationUpdate>;
|
|
93
99
|
export declare const InputItem: Schema.Union<readonly [Schema.Struct<{
|
|
94
100
|
readonly type: Schema.Literal<"compaction">;
|
|
95
101
|
readonly id: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
96
102
|
readonly encrypted_content: Schema.String;
|
|
97
103
|
}>, Schema.Struct<{
|
|
104
|
+
readonly type: Schema.tag<"message">;
|
|
98
105
|
readonly role: Schema.tag<"system">;
|
|
99
106
|
readonly content: Schema.String;
|
|
100
107
|
}>, Schema.Struct<{
|
|
108
|
+
readonly type: Schema.tag<"message">;
|
|
101
109
|
readonly role: Schema.tag<"developer">;
|
|
102
110
|
readonly content: Schema.String;
|
|
103
111
|
}>, Schema.Struct<{
|
|
112
|
+
readonly type: Schema.tag<"message">;
|
|
104
113
|
readonly role: Schema.tag<"user">;
|
|
105
114
|
readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
106
115
|
readonly type: Schema.tag<"input_text">;
|
|
@@ -116,7 +125,6 @@ export declare const InputItem: Schema.Union<readonly [Schema.Struct<{
|
|
|
116
125
|
readonly file_data: Schema.optional<Schema.String>;
|
|
117
126
|
readonly file_url: Schema.optional<Schema.String>;
|
|
118
127
|
}>]>]>>;
|
|
119
|
-
readonly type: Schema.optional<Schema.Literal<"message">>;
|
|
120
128
|
readonly id: Schema.optional<Schema.String>;
|
|
121
129
|
readonly status: Schema.optional<Schema.String>;
|
|
122
130
|
}>, Schema.Struct<{
|
|
@@ -198,7 +206,7 @@ export type HostedToolReplayItem = {
|
|
|
198
206
|
readonly id: string;
|
|
199
207
|
readonly [key: string]: unknown;
|
|
200
208
|
};
|
|
201
|
-
type LoweredInputItem = OpenResponsesInputItem | HostedToolReplayItem | {
|
|
209
|
+
type LoweredInputItem = OpenResponsesInputItem | HostedToolReplayItem | ConfigurationUpdate | {
|
|
202
210
|
readonly type: "message";
|
|
203
211
|
readonly id?: string;
|
|
204
212
|
readonly role: "assistant";
|
|
@@ -233,12 +241,15 @@ export declare const coreFields: {
|
|
|
233
241
|
readonly id: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
234
242
|
readonly encrypted_content: Schema.String;
|
|
235
243
|
}>, Schema.Struct<{
|
|
244
|
+
readonly type: Schema.tag<"message">;
|
|
236
245
|
readonly role: Schema.tag<"system">;
|
|
237
246
|
readonly content: Schema.String;
|
|
238
247
|
}>, Schema.Struct<{
|
|
248
|
+
readonly type: Schema.tag<"message">;
|
|
239
249
|
readonly role: Schema.tag<"developer">;
|
|
240
250
|
readonly content: Schema.String;
|
|
241
251
|
}>, Schema.Struct<{
|
|
252
|
+
readonly type: Schema.tag<"message">;
|
|
242
253
|
readonly role: Schema.tag<"user">;
|
|
243
254
|
readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
244
255
|
readonly type: Schema.tag<"input_text">;
|
|
@@ -254,7 +265,6 @@ export declare const coreFields: {
|
|
|
254
265
|
readonly file_data: Schema.optional<Schema.String>;
|
|
255
266
|
readonly file_url: Schema.optional<Schema.String>;
|
|
256
267
|
}>]>]>>;
|
|
257
|
-
readonly type: Schema.optional<Schema.Literal<"message">>;
|
|
258
268
|
readonly id: Schema.optional<Schema.String>;
|
|
259
269
|
readonly status: Schema.optional<Schema.String>;
|
|
260
270
|
}>, Schema.Struct<{
|
|
@@ -383,12 +393,15 @@ declare const OpenResponsesBody: Schema.Struct<{
|
|
|
383
393
|
readonly id: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
384
394
|
readonly encrypted_content: Schema.String;
|
|
385
395
|
}>, Schema.Struct<{
|
|
396
|
+
readonly type: Schema.tag<"message">;
|
|
386
397
|
readonly role: Schema.tag<"system">;
|
|
387
398
|
readonly content: Schema.String;
|
|
388
399
|
}>, Schema.Struct<{
|
|
400
|
+
readonly type: Schema.tag<"message">;
|
|
389
401
|
readonly role: Schema.tag<"developer">;
|
|
390
402
|
readonly content: Schema.String;
|
|
391
403
|
}>, Schema.Struct<{
|
|
404
|
+
readonly type: Schema.tag<"message">;
|
|
392
405
|
readonly role: Schema.tag<"user">;
|
|
393
406
|
readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
394
407
|
readonly type: Schema.tag<"input_text">;
|
|
@@ -404,7 +417,6 @@ declare const OpenResponsesBody: Schema.Struct<{
|
|
|
404
417
|
readonly file_data: Schema.optional<Schema.String>;
|
|
405
418
|
readonly file_url: Schema.optional<Schema.String>;
|
|
406
419
|
}>]>]>>;
|
|
407
|
-
readonly type: Schema.optional<Schema.Literal<"message">>;
|
|
408
420
|
readonly id: Schema.optional<Schema.String>;
|
|
409
421
|
readonly status: Schema.optional<Schema.String>;
|
|
410
422
|
}>, Schema.Struct<{
|
|
@@ -845,7 +857,7 @@ export declare const lowerConversation: (request: LLMRequest<import("../schema/o
|
|
|
845
857
|
model: string & import("effect/Brand").Brand<"AI.ModelID">;
|
|
846
858
|
input: LoweredInputItem[];
|
|
847
859
|
}, AIError, never>;
|
|
848
|
-
export declare const lowerGeneration: (request: LLMRequest) => {
|
|
860
|
+
export declare const lowerGeneration: (request: LLMRequest, options?: OpenResponsesOptions.Resolved) => {
|
|
849
861
|
truncation?: "auto" | "disabled" | undefined;
|
|
850
862
|
parallel_tool_calls?: boolean | undefined;
|
|
851
863
|
max_tool_calls?: number | undefined;
|
|
@@ -986,12 +998,15 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
|
|
|
986
998
|
readonly encrypted_content: string;
|
|
987
999
|
readonly id?: string | null | undefined;
|
|
988
1000
|
} | {
|
|
1001
|
+
readonly type: "message";
|
|
989
1002
|
readonly role: "system";
|
|
990
1003
|
readonly content: string;
|
|
991
1004
|
} | {
|
|
1005
|
+
readonly type: "message";
|
|
992
1006
|
readonly role: "developer";
|
|
993
1007
|
readonly content: string;
|
|
994
1008
|
} | {
|
|
1009
|
+
readonly type: "message";
|
|
995
1010
|
readonly content: readonly ({
|
|
996
1011
|
readonly type: "input_image";
|
|
997
1012
|
readonly image_url: string;
|
|
@@ -1008,7 +1023,6 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
|
|
|
1008
1023
|
})[];
|
|
1009
1024
|
readonly role: "user";
|
|
1010
1025
|
readonly id?: string | undefined;
|
|
1011
|
-
readonly type?: "message" | undefined;
|
|
1012
1026
|
readonly status?: string | undefined;
|
|
1013
1027
|
} | {
|
|
1014
1028
|
readonly type: "message";
|
|
@@ -1368,12 +1382,15 @@ export declare const protocol: Protocol<{
|
|
|
1368
1382
|
readonly encrypted_content: string;
|
|
1369
1383
|
readonly id?: string | null | undefined;
|
|
1370
1384
|
} | {
|
|
1385
|
+
readonly type: "message";
|
|
1371
1386
|
readonly role: "system";
|
|
1372
1387
|
readonly content: string;
|
|
1373
1388
|
} | {
|
|
1389
|
+
readonly type: "message";
|
|
1374
1390
|
readonly role: "developer";
|
|
1375
1391
|
readonly content: string;
|
|
1376
1392
|
} | {
|
|
1393
|
+
readonly type: "message";
|
|
1377
1394
|
readonly content: readonly ({
|
|
1378
1395
|
readonly type: "input_image";
|
|
1379
1396
|
readonly image_url: string;
|
|
@@ -1390,7 +1407,6 @@ export declare const protocol: Protocol<{
|
|
|
1390
1407
|
})[];
|
|
1391
1408
|
readonly role: "user";
|
|
1392
1409
|
readonly id?: string | undefined;
|
|
1393
|
-
readonly type?: "message" | undefined;
|
|
1394
1410
|
readonly status?: string | undefined;
|
|
1395
1411
|
} | {
|
|
1396
1412
|
readonly type: "message";
|
|
@@ -1599,12 +1615,15 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
1599
1615
|
readonly encrypted_content: string;
|
|
1600
1616
|
readonly id?: string | null | undefined;
|
|
1601
1617
|
} | {
|
|
1618
|
+
readonly type: "message";
|
|
1602
1619
|
readonly role: "system";
|
|
1603
1620
|
readonly content: string;
|
|
1604
1621
|
} | {
|
|
1622
|
+
readonly type: "message";
|
|
1605
1623
|
readonly role: "developer";
|
|
1606
1624
|
readonly content: string;
|
|
1607
1625
|
} | {
|
|
1626
|
+
readonly type: "message";
|
|
1608
1627
|
readonly content: readonly ({
|
|
1609
1628
|
readonly type: "input_image";
|
|
1610
1629
|
readonly image_url: string;
|
|
@@ -1621,7 +1640,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
1621
1640
|
})[];
|
|
1622
1641
|
readonly role: "user";
|
|
1623
1642
|
readonly id?: string | undefined;
|
|
1624
|
-
readonly type?: "message" | undefined;
|
|
1625
1643
|
readonly status?: string | undefined;
|
|
1626
1644
|
} | {
|
|
1627
1645
|
readonly type: "message";
|
|
@@ -4,6 +4,7 @@ import { Protocol } from "../route/protocol.js";
|
|
|
4
4
|
import { AIError, LLMEvent, ProviderInternalError, Usage, } from "../schema/index.js";
|
|
5
5
|
import { JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared.js";
|
|
6
6
|
import { classifyProviderFailure } from "../provider-error.js";
|
|
7
|
+
import { effortUpdate } from "../effort-updates.js";
|
|
7
8
|
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
8
9
|
import { Lifecycle } from "./utils/lifecycle.js";
|
|
9
10
|
import { ToolSchemaProjection } from "./utils/tool-schema.js";
|
|
@@ -43,7 +44,6 @@ export const OpenResponsesOutputText = Schema.Struct({
|
|
|
43
44
|
export const MessagePhase = Schema.NullOr(Schema.Literals(["commentary", "final_answer"]));
|
|
44
45
|
export const MessageMetadata = Schema.Struct({
|
|
45
46
|
itemId: Schema.optional(Schema.String),
|
|
46
|
-
type: Schema.optional(Schema.Literal("message")),
|
|
47
47
|
status: Schema.optional(Schema.String),
|
|
48
48
|
phase: Schema.optional(MessagePhase),
|
|
49
49
|
});
|
|
@@ -117,14 +117,19 @@ export const CompactionItem = Schema.Struct({
|
|
|
117
117
|
id: optionalNull(Schema.String),
|
|
118
118
|
encrypted_content: Schema.String,
|
|
119
119
|
});
|
|
120
|
+
// Kept out of the baseline `InputItem` union: only the OpenAI extension accepts it.
|
|
121
|
+
export const ConfigurationUpdate = Schema.Struct({
|
|
122
|
+
type: Schema.Literal("configuration_update"),
|
|
123
|
+
reasoning: Schema.Struct({ effort: OpenResponsesOptions.ReasoningEffort }),
|
|
124
|
+
});
|
|
120
125
|
export const InputItem = Schema.Union([
|
|
121
126
|
CompactionItem,
|
|
122
|
-
Schema.Struct({ role: Schema.tag("system"), content: Schema.String }),
|
|
123
|
-
Schema.Struct({ role: Schema.tag("developer"), content: Schema.String }),
|
|
127
|
+
Schema.Struct({ type: Schema.tag("message"), role: Schema.tag("system"), content: Schema.String }),
|
|
128
|
+
Schema.Struct({ type: Schema.tag("message"), role: Schema.tag("developer"), content: Schema.String }),
|
|
124
129
|
Schema.Struct({
|
|
130
|
+
type: Schema.tag("message"),
|
|
125
131
|
role: Schema.tag("user"),
|
|
126
132
|
content: Schema.Array(OpenResponsesInputContent),
|
|
127
|
-
type: Schema.optional(Schema.Literal("message")),
|
|
128
133
|
id: Schema.optional(Schema.String),
|
|
129
134
|
status: Schema.optional(Schema.String),
|
|
130
135
|
}),
|
|
@@ -346,7 +351,7 @@ const lowerToolCall = (part, providerMetadataKey) => {
|
|
|
346
351
|
call_id: part.id,
|
|
347
352
|
name: part.name,
|
|
348
353
|
namespace: part.namespace,
|
|
349
|
-
arguments: ProviderShared.encodeJson(part.input),
|
|
354
|
+
arguments: ProviderShared.encodeJson(part.input === undefined ? {} : part.input),
|
|
350
355
|
};
|
|
351
356
|
};
|
|
352
357
|
const lowerReasoning = (part, providerMetadataKey) => {
|
|
@@ -423,13 +428,24 @@ const lowerToolResultOutput = Effect.fnUntraced(function* (part, request, adapte
|
|
|
423
428
|
const content = part.result.value;
|
|
424
429
|
return yield* Effect.forEach(content, (item) => lowerToolResultContentItem(item, request, adapter));
|
|
425
430
|
});
|
|
431
|
+
const DEFAULT_EFFORT = "medium";
|
|
426
432
|
const lowerMessages = Effect.fn("OpenResponses.lowerMessages")(function* (request, adapter) {
|
|
427
433
|
const input = [];
|
|
428
434
|
const providerMetadataKey = metadataKey(request.model);
|
|
429
435
|
for (const message of request.messages) {
|
|
430
436
|
const metadata = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Schema.UndefinedOr(MessageMetadata)))(message.providerMetadata?.[providerMetadataKey]);
|
|
431
437
|
if (message.role === "system") {
|
|
438
|
+
const update = effortUpdate(message);
|
|
439
|
+
if (update) {
|
|
440
|
+
// Consecutive updates are rejected, so a newer one replaces its predecessor.
|
|
441
|
+
const last = input.at(-1);
|
|
442
|
+
if (last !== undefined && "type" in last && last.type === "configuration_update")
|
|
443
|
+
input.pop();
|
|
444
|
+
input.push({ type: "configuration_update", reasoning: { effort: update.effort ?? DEFAULT_EFFORT } });
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
432
447
|
input.push({
|
|
448
|
+
type: "message",
|
|
433
449
|
role: "developer",
|
|
434
450
|
content: ProviderShared.joinText(yield* ProviderShared.systemUpdateText(adapter.name, message)),
|
|
435
451
|
});
|
|
@@ -438,7 +454,7 @@ const lowerMessages = Effect.fn("OpenResponses.lowerMessages")(function* (reques
|
|
|
438
454
|
if (message.role === "user") {
|
|
439
455
|
const content = yield* Effect.forEach(message.content, (part) => lowerUserContent(part, request, adapter));
|
|
440
456
|
if (content.length > 0)
|
|
441
|
-
input.push({ role: "user", content,
|
|
457
|
+
input.push({ type: "message", role: "user", content, id: metadata?.itemId, status: metadata?.status });
|
|
442
458
|
continue;
|
|
443
459
|
}
|
|
444
460
|
if (message.role === "assistant") {
|
|
@@ -526,6 +542,7 @@ const lowerMessages = Effect.fn("OpenResponses.lowerMessages")(function* (reques
|
|
|
526
542
|
? part.result.value
|
|
527
543
|
: [{ type: "text", text: ProviderShared.toolResultText(part) }];
|
|
528
544
|
input.push({
|
|
545
|
+
type: "message",
|
|
529
546
|
role: "user",
|
|
530
547
|
content: yield* Effect.forEach(content, (item) => lowerHostedToolResultContentItem(item, request, adapter)),
|
|
531
548
|
});
|
|
@@ -561,8 +578,7 @@ export const lowerConversation = Effect.fn("OpenResponses.lowerConversation")(fu
|
|
|
561
578
|
...(instructions ? { instructions } : {}),
|
|
562
579
|
};
|
|
563
580
|
});
|
|
564
|
-
export const lowerGeneration = (request) => {
|
|
565
|
-
const options = OpenResponsesOptions.resolve(request);
|
|
581
|
+
export const lowerGeneration = (request, options = OpenResponsesOptions.resolve(request)) => {
|
|
566
582
|
const generation = request.generation;
|
|
567
583
|
const cacheKey = ProviderShared.promptCacheKey(request);
|
|
568
584
|
const parallelToolCalls = resolveParallelToolCalls(request);
|
|
@@ -97,7 +97,7 @@ export declare const bodyFields: {
|
|
|
97
97
|
}>>;
|
|
98
98
|
store: Schema.optional<Schema.Boolean>;
|
|
99
99
|
prompt_cache_key: Schema.optional<Schema.String>;
|
|
100
|
-
reasoning_effort: Schema.optional<Schema.declare<import("
|
|
100
|
+
reasoning_effort: Schema.optional<Schema.declare<import("../schema/options.js").ReasoningEffort, import("../schema/options.js").ReasoningEffort>>;
|
|
101
101
|
tool_stream: Schema.optional<Schema.Boolean>;
|
|
102
102
|
max_completion_tokens: Schema.optional<Schema.Number>;
|
|
103
103
|
max_tokens: Schema.optional<Schema.Number>;
|
|
@@ -193,7 +193,7 @@ declare const OpenAIChatBody: Schema.Struct<{
|
|
|
193
193
|
}>>;
|
|
194
194
|
store: Schema.optional<Schema.Boolean>;
|
|
195
195
|
prompt_cache_key: Schema.optional<Schema.String>;
|
|
196
|
-
reasoning_effort: Schema.optional<Schema.declare<import("
|
|
196
|
+
reasoning_effort: Schema.optional<Schema.declare<import("../schema/options.js").ReasoningEffort, import("../schema/options.js").ReasoningEffort>>;
|
|
197
197
|
tool_stream: Schema.optional<Schema.Boolean>;
|
|
198
198
|
max_completion_tokens: Schema.optional<Schema.Number>;
|
|
199
199
|
max_tokens: Schema.optional<Schema.Number>;
|
|
@@ -292,7 +292,7 @@ interface LoweringOptions {
|
|
|
292
292
|
export declare const fromRequest: (request: LLMRequest<import("../schema/options.js").LanguageModel<{
|
|
293
293
|
readonly [x: string]: unknown;
|
|
294
294
|
}, import("../route/client.js").CompactionOperations | undefined>>, options?: LoweringOptions | undefined) => Effect.Effect<{
|
|
295
|
-
reasoning_effort?: import("
|
|
295
|
+
reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
296
296
|
prompt_cache_key?: string | undefined;
|
|
297
297
|
store?: boolean | undefined;
|
|
298
298
|
temperature: number | undefined;
|
|
@@ -389,7 +389,7 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
|
|
|
389
389
|
} | undefined;
|
|
390
390
|
stream: true;
|
|
391
391
|
} | {
|
|
392
|
-
reasoning_effort?: import("
|
|
392
|
+
reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
393
393
|
prompt_cache_key?: string | undefined;
|
|
394
394
|
store?: boolean | undefined;
|
|
395
395
|
temperature: number | undefined;
|
|
@@ -584,7 +584,7 @@ export declare const protocol: Protocol<{
|
|
|
584
584
|
readonly frequency_penalty?: number | undefined;
|
|
585
585
|
readonly presence_penalty?: number | undefined;
|
|
586
586
|
readonly prompt_cache_key?: string | undefined;
|
|
587
|
-
readonly reasoning_effort?: import("
|
|
587
|
+
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
588
588
|
readonly store?: boolean | undefined;
|
|
589
589
|
readonly stream_options?: {
|
|
590
590
|
readonly include_usage: boolean;
|
|
@@ -751,7 +751,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
751
751
|
readonly frequency_penalty?: number | undefined;
|
|
752
752
|
readonly presence_penalty?: number | undefined;
|
|
753
753
|
readonly prompt_cache_key?: string | undefined;
|
|
754
|
-
readonly reasoning_effort?: import("
|
|
754
|
+
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
755
755
|
readonly store?: boolean | undefined;
|
|
756
756
|
readonly stream_options?: {
|
|
757
757
|
readonly include_usage: boolean;
|
|
@@ -850,7 +850,7 @@ export declare const route: Route<{
|
|
|
850
850
|
readonly frequency_penalty?: number | undefined;
|
|
851
851
|
readonly presence_penalty?: number | undefined;
|
|
852
852
|
readonly prompt_cache_key?: string | undefined;
|
|
853
|
-
readonly reasoning_effort?: import("
|
|
853
|
+
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
854
854
|
readonly store?: boolean | undefined;
|
|
855
855
|
readonly stream_options?: {
|
|
856
856
|
readonly include_usage: boolean;
|
|
@@ -200,14 +200,17 @@ const lowerToolCall = (part, options) => ({
|
|
|
200
200
|
type: "function",
|
|
201
201
|
function: {
|
|
202
202
|
name: part.name,
|
|
203
|
-
arguments: ProviderShared.encodeJson(part.input),
|
|
203
|
+
arguments: ProviderShared.encodeJson(part.input === undefined ? {} : part.input),
|
|
204
204
|
},
|
|
205
205
|
});
|
|
206
206
|
const lowerMedia = Effect.fn("OpenAIChat.lowerMedia")(function* (part) {
|
|
207
207
|
const media = ProviderShared.normalizeMedia(part);
|
|
208
208
|
if (!media.mime.startsWith("image/"))
|
|
209
209
|
return yield* ProviderShared.invalidRequest(`OpenAI Chat does not support media type ${part.mediaType}`);
|
|
210
|
-
|
|
210
|
+
const url = typeof part.data === "string" && (part.data.startsWith("https://") || part.data.startsWith("http://"))
|
|
211
|
+
? part.data
|
|
212
|
+
: media.dataUrl;
|
|
213
|
+
return { type: "image_url", image_url: { url } };
|
|
211
214
|
});
|
|
212
215
|
const openAICompatibleReasoningContent = (native) => isRecord(native) && typeof native.reasoning_content === "string" ? native.reasoning_content : undefined;
|
|
213
216
|
const reasoningField = (part, providerMetadataKey) => {
|
|
@@ -557,7 +560,10 @@ const detectZaiToolStream = (provider, baseURL, modelID) => {
|
|
|
557
560
|
};
|
|
558
561
|
const lowerOptions = (request, supportsStore) => {
|
|
559
562
|
const options = OpenAIOptions.resolve(request);
|
|
560
|
-
|
|
563
|
+
// Default off: strict providers 400 on unknown body fields, so only send
|
|
564
|
+
// the key where compatibility explicitly allows it. Header-based affinity
|
|
565
|
+
// (x-session-affinity, x-grok-conv-id, ...) is unaffected.
|
|
566
|
+
const cacheKey = (request.model.compatibility?.supportsPromptCacheKey ?? false) ? ProviderShared.promptCacheKey(request) : undefined;
|
|
561
567
|
return {
|
|
562
568
|
...(supportsStore && options.store !== undefined ? { store: options.store } : {}),
|
|
563
569
|
// For providers that support `store`, ensure stateless `store:false` is sent
|
|
@@ -595,7 +601,7 @@ export const fromRequest = Effect.fn("OpenAIChat.fromRequest")(function* (reques
|
|
|
595
601
|
? []
|
|
596
602
|
: undefined
|
|
597
603
|
: flattened.tools.map((tool) => lowerTool(tool, ToolSchemaProjection.modelCompatibility(tool.inputSchema, toolSchemaCompatibility), options, supportsStrictMode)),
|
|
598
|
-
tool_choice: request.toolChoice ? yield* lowerToolChoice(request.toolChoice) : undefined,
|
|
604
|
+
tool_choice: hasActiveTools && request.toolChoice ? yield* lowerToolChoice(request.toolChoice) : undefined,
|
|
599
605
|
stream: true,
|
|
600
606
|
...(supportsUsageInStreaming ? { stream_options: { include_usage: true } } : {}),
|
|
601
607
|
...(zaiToolStream && hasActiveTools ? { tool_stream: true } : {}),
|
|
@@ -99,7 +99,7 @@ export declare const route: Route<{
|
|
|
99
99
|
readonly frequency_penalty?: number | undefined;
|
|
100
100
|
readonly presence_penalty?: number | undefined;
|
|
101
101
|
readonly prompt_cache_key?: string | undefined;
|
|
102
|
-
readonly reasoning_effort?: import("
|
|
102
|
+
readonly reasoning_effort?: import("../index.js").ReasoningEffort | undefined;
|
|
103
103
|
readonly store?: boolean | undefined;
|
|
104
104
|
readonly stream_options?: {
|
|
105
105
|
readonly include_usage: boolean;
|
|
@@ -56,12 +56,15 @@ export declare const route: Route<{
|
|
|
56
56
|
readonly encrypted_content: string;
|
|
57
57
|
readonly id?: string | null | undefined;
|
|
58
58
|
} | {
|
|
59
|
+
readonly type: "message";
|
|
59
60
|
readonly role: "system";
|
|
60
61
|
readonly content: string;
|
|
61
62
|
} | {
|
|
63
|
+
readonly type: "message";
|
|
62
64
|
readonly role: "developer";
|
|
63
65
|
readonly content: string;
|
|
64
66
|
} | {
|
|
67
|
+
readonly type: "message";
|
|
65
68
|
readonly content: readonly ({
|
|
66
69
|
readonly type: "input_image";
|
|
67
70
|
readonly image_url: string;
|
|
@@ -78,7 +81,6 @@ export declare const route: Route<{
|
|
|
78
81
|
})[];
|
|
79
82
|
readonly role: "user";
|
|
80
83
|
readonly id?: string | undefined;
|
|
81
|
-
readonly type?: "message" | undefined;
|
|
82
84
|
readonly status?: string | undefined;
|
|
83
85
|
} | {
|
|
84
86
|
readonly type: "message";
|
|
@@ -126,7 +128,7 @@ export declare const route: Route<{
|
|
|
126
128
|
readonly instructions?: string | undefined;
|
|
127
129
|
readonly reasoning?: {
|
|
128
130
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
129
|
-
readonly effort?: import("
|
|
131
|
+
readonly effort?: import("../index.js").ReasoningEffort | undefined;
|
|
130
132
|
} | undefined;
|
|
131
133
|
readonly tools?: readonly {
|
|
132
134
|
readonly type: "function";
|