@openclaw/ai 2026.9.5 → 2026.9.7
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/{anthropic-COtDvgtt.mjs → anthropic-Cw2pgccz.mjs} +59 -88
- package/dist/{anthropic-payload-policy-5Erq1Nzy.d.mts → anthropic-payload-policy-NIPVYXPq.d.mts} +8 -6
- package/dist/{anthropic-stream-reducer-BvdYYWL8.mjs → anthropic-stream-reducer-D9MCkl8Z.mjs} +194 -247
- package/dist/{api-registry-Ba2Cv-ut.d.mts → api-registry-D-nbmSqr.d.mts} +2 -2
- package/dist/{azure-openai-responses-YrgnD583.mjs → azure-openai-responses-BwT3-X8P.mjs} +22 -33
- package/dist/{base64-BQOzsvUH.mjs → base64-C1PsYcRQ.mjs} +22 -16
- package/dist/{diagnostics-Dm4bisWG.mjs → diagnostics-CJaB6g8J.mjs} +55 -10
- package/dist/{diagnostics-CPeq9F7y.mjs → diagnostics-DzrF1h4J.mjs} +18 -1
- package/dist/diagnostics.d.mts +11 -5
- package/dist/diagnostics.mjs +4 -4
- package/dist/{env-api-keys-bktO00EJ.mjs → env-api-keys-CyX4VKGO.mjs} +7 -5
- package/dist/event-stream-CMQfX_yr.d.mts +1 -0
- package/dist/{event-stream-CCoa-qSI.d.mts → event-stream-DOPFYVqs.d.mts} +2 -2
- package/dist/{event-stream-D8PARQfL.mjs → event-stream-vd9UnCAU.mjs} +10 -0
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -1
- package/dist/{google-BuhpRO9r.mjs → google-BfapkS_K.mjs} +8 -11
- package/dist/google-interactions-DW3iXzjc.mjs +574 -0
- package/dist/{google-messages-CyWnYlh0.mjs → google-messages-CtjVtVot.mjs} +35 -71
- package/dist/{google-shared-BT5ZeNer.mjs → google-shared-Y2YfotEu.mjs} +43 -47
- package/dist/{google-vertex-C7EplRvt.mjs → google-vertex-Dov4kBWu.mjs} +16 -30
- package/dist/{host-B4MeUNBc.mjs → host-CHi3X87F.mjs} +64 -189
- package/dist/{host-policy-DUnXSx0I.mjs → host-policy-BOAwRg_M.mjs} +2 -14
- package/dist/{host-FZ1RA_qD.d.mts → host-rxlNaBwm.d.mts} +9 -3
- package/dist/{index-DaF2QbwS.d.mts → index-D6KsSE74.d.mts} +57 -9
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +7 -7
- package/dist/internal/anthropic.d.mts +13 -8
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/openai-completions-compat.d.mts +1 -1
- package/dist/internal/openai-completions-compat.mjs +1 -1
- package/dist/internal/openai-responses-payload-policy.d.mts +1 -1
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +46 -9
- package/dist/internal/openai.mjs +13 -12
- package/dist/internal/runtime.d.mts +31 -70
- package/dist/internal/runtime.mjs +11 -66
- package/dist/internal/shared.d.mts +16 -13
- package/dist/internal/shared.mjs +6 -5
- package/dist/internal/tool-schema.d.mts +2 -2
- package/dist/internal/tool-schema.mjs +2 -2
- package/dist/{mistral-moA-mbwl.mjs → mistral-RS6mboC-.mjs} +46 -93
- package/dist/{model-transport-url-DKocrEsb.d.mts → model-transport-url-C5f59L3Y.d.mts} +1 -1
- package/dist/{openai-chatgpt-responses-DWID3EFO.mjs → openai-chatgpt-responses-CYbidtrn.mjs} +118 -99
- package/dist/{openai-completions-DJ1Vm-CD.mjs → openai-completions-D14ihPYk.mjs} +14 -12
- package/dist/{openai-completions-compat-CkwdxTZx.mjs → openai-completions-compat-BOVWBZDn.mjs} +3 -5
- package/dist/{openai-completions-compat-JE7gqxb9.d.mts → openai-completions-compat-qJjmqQ71.d.mts} +3 -3
- package/dist/{openai-completions-stream-Bu98b0Hv.mjs → openai-completions-stream-CDCuw3DP.mjs} +124 -183
- package/dist/{openai-prompt-cache-CJ_xEevu.d.mts → openai-prompt-cache-CouErLh7.d.mts} +2 -2
- package/dist/{openai-prompt-cache-1wfaIszn.mjs → openai-prompt-cache-D2V7MqR7.mjs} +1 -1
- package/dist/{openai-provider-client-DPo0Hmak.mjs → openai-provider-client-CwfsGBbA.mjs} +2 -2
- package/dist/{openai-reasoning-effort-NlFZmfEu.mjs → openai-reasoning-effort-ConhwkeX.mjs} +14 -5
- package/dist/{openai-responses-BejZzQCP.mjs → openai-responses-CKCBEc2W.mjs} +12 -11
- package/dist/openai-responses-compaction-replay-DiYn-gFM.d.mts +12 -0
- package/dist/{openai-responses-compaction-window-D6P5oZP5.mjs → openai-responses-compaction-window-UNK1GDpy.mjs} +5 -5
- package/dist/{openai-responses-contracts-DWrfMODE.mjs → openai-responses-contracts-CLxnqS9p.mjs} +1 -1
- package/dist/{openai-responses-contracts-Dflvrfa8.d.mts → openai-responses-contracts-D1iZ0njF.d.mts} +4 -4
- package/dist/{openai-responses-prompt-observer-internal-C15_-OwV.mjs → openai-responses-prompt-observer-internal-iAqLb4tk.mjs} +16 -13
- package/dist/openai-responses-request-lifecycle-Fsag-IGZ.mjs +36 -0
- package/dist/{openai-responses-shared-CwsziD_m.mjs → openai-responses-shared-DL4ulQn7.mjs} +838 -577
- package/dist/{openai-responses-terminal-usage-Dl3J6zrf.d.mts → openai-responses-terminal-usage-BE7lf7nW.d.mts} +2 -2
- package/dist/{openai-stop-reason-Drnn_6Qj.mjs → openai-stop-reason-8s70vDXj.mjs} +2 -12
- package/dist/{openai-tool-schema-ynZBgqW-.d.mts → openai-tool-schema-a5ysBBga.d.mts} +0 -6
- package/dist/{openai-tool-schema-BO8rwyAD.mjs → openai-tool-schema-vsl-cE-n.mjs} +365 -429
- package/dist/{openai-transport-params-DQeuAvBl.mjs → openai-transport-params-BwlpzX-2.mjs} +61 -106
- package/dist/{positive-integer-DtjCkbue.mjs → positive-integer-CjN5OJbH.mjs} +1 -1
- package/dist/{provider-error-DDqw9Qda.mjs → provider-error-CwT_j2v0.mjs} +82 -10
- package/dist/{provider-error-CzNw4BWX.d.mts → provider-error-xumb1V3F.d.mts} +3 -1
- package/dist/{provider-options-DprLsWh9.d.mts → provider-options-Df7ov0K1.d.mts} +6 -4
- package/dist/{provider-replay-context-CnUSOwhr.mjs → provider-replay-context-DsyI5jOP.mjs} +1 -1
- package/dist/{provider-transcript-transform-BsRAhuWJ.mjs → provider-transcript-transform-JbFbHV8h.mjs} +17 -2
- package/dist/{provider-transport-turn-state-CkGToCD2.mjs → provider-transport-turn-state-BheUi_hl.mjs} +1 -1
- package/dist/{provider-types-CAKRC7N5.d.mts → provider-types-d4XnoZMd.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +15 -11
- package/dist/{reasoning-tag-text-partitioner-Dy9IO8Dc.mjs → reasoning-tag-text-partitioner-B6FIIBt6.mjs} +193 -98
- package/dist/{record-coerce-DwRYMj3t.mjs → record-coerce-CNDovvft.mjs} +1 -1
- package/dist/simple-options-CGAkCwtM.mjs +349 -0
- package/dist/{src-DeKjbE8I.mjs → src-H4aXcFuX.mjs} +53 -26
- package/dist/{stream-CREqxHgU.mjs → stream-DDsCBgd-.mjs} +1 -7
- package/dist/{stream-first-event-timeout-C9ZadkJW.mjs → stream-first-event-timeout-B9o0S4SZ.mjs} +1 -1
- package/dist/{tool-schema-json-projection-CD9c_fK8.mjs → tool-schema-json-projection-Ct8SeBeJ.mjs} +63 -23
- package/dist/{transport-stream-shared-D-6FQSHm.mjs → transport-stream-shared-Dh5qKJ8e.mjs} +63 -37
- package/dist/{transport-stream-shared-BbUkFaHi.d.mts → transport-stream-shared-yYhXa4kX.d.mts} +13 -7
- package/dist/{transport-utils-1cyq5Y7x.mjs → transport-utils-C-4bf2Ok.mjs} +3 -4
- package/dist/transports.d.mts +37 -33
- package/dist/transports.mjs +208 -239
- package/dist/types-CB-_vNyI.d.mts +1 -0
- package/dist/{types-4_uVs5WH.d.mts → types-CLLR3eB4.d.mts} +5 -1
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +5 -5
- package/dist/{validation-Dw7cb6BV.mjs → validation-BFZc40Ig.mjs} +80 -54
- package/dist/{validation-Ctzu2DhF.d.mts → validation-Cat2wQsc.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +6 -6
- package/dist/assistant-output-BsEkB-vU.mjs +0 -16
- package/dist/event-stream-DmSCpi1T.d.mts +0 -1
- package/dist/simple-options-C6cFWj_f.mjs +0 -175
- package/dist/types-DkJfb4W3.d.mts +0 -1
- package/dist/utf16-slice-CvGodqok.mjs +0 -29
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { o as isRecord, r as asOptionalObjectRecord } from "./record-coerce-CNDovvft.mjs";
|
|
2
|
+
import { C as applyProviderReportedUsageCost, S as headersToRecord, T as clampThinkingLevel, n as getAiTransportHost, w as calculateCost } from "./host-CHi3X87F.mjs";
|
|
1
3
|
import { a as normalizeOptionalString, n as normalizeLowercaseStringOrEmpty } from "./string-coerce-fsri9iCu.mjs";
|
|
2
|
-
import { o as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { n as
|
|
9
|
-
import { n as projectRuntimeToolInputSchema, t as prepareRuntimeToolInputSchema } from "./tool-schema-json-projection-CD9c_fK8.mjs";
|
|
10
|
-
import { O as headersToRecord, p as notifyProviderHttpResponse, v as transportAbortError } from "./transport-stream-shared-D-6FQSHm.mjs";
|
|
4
|
+
import { a as normalizeOpenAIReasoningEffort, c as resolveOpenAIReasoningEffortMapping, f as MODEL_CATALOG_THINKING_LEVELS, m as resolveOpenAIThinkingApi, o as resolveOpenAIModelReasoningEfforts, s as resolveOpenAIReasoningEffortForModel, u as supportsOpenAIReasoningEffort } from "./openai-reasoning-effort-ConhwkeX.mjs";
|
|
5
|
+
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-D2V7MqR7.mjs";
|
|
6
|
+
import { i as isCodeModeModelVisibleToolName } from "./transport-utils-C-4bf2Ok.mjs";
|
|
7
|
+
import { i as resolveOpenAICompletionsCompat, o as usesNativeOpenAICodexResponsesBackend } from "./openai-completions-compat-BOVWBZDn.mjs";
|
|
8
|
+
import { n as resolveModelRequestTimeoutMs } from "./host-policy-BOAwRg_M.mjs";
|
|
9
|
+
import { m as notifyProviderHttpResponse } from "./transport-stream-shared-Dh5qKJ8e.mjs";
|
|
10
|
+
import { n as projectRuntimeToolInputSchema, t as prepareRuntimeToolInputSchema } from "./tool-schema-json-projection-Ct8SeBeJ.mjs";
|
|
11
11
|
import { n as resolveOpencodeSessionHeaders } from "./session-affinity-Bcunsn4I.mjs";
|
|
12
|
-
import { a as resolveOpenAIProjectedToolsStrictToolFlag, t as findOpenAIStrictToolProjectionDiagnostics } from "./openai-tool-schema-
|
|
13
|
-
import { i as OPENAI_RESPONSES_APIS } from "./openai-responses-contracts-
|
|
12
|
+
import { a as resolveOpenAIProjectedToolsStrictToolFlag, t as findOpenAIStrictToolProjectionDiagnostics } from "./openai-tool-schema-vsl-cE-n.mjs";
|
|
13
|
+
import { i as OPENAI_RESPONSES_APIS } from "./openai-responses-contracts-CLxnqS9p.mjs";
|
|
14
14
|
import { hash } from "node:crypto";
|
|
15
15
|
//#region packages/normalization-core/src/node-crypto.ts
|
|
16
16
|
function sha256Hex(input) {
|
|
@@ -28,9 +28,7 @@ function redactIdentifier(value, opts) {
|
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region packages/ai/src/transports/openai-transport-shared.ts
|
|
31
|
-
/** Shared options, usage shape, cache identity,
|
|
32
|
-
const MODEL_STREAM_COOPERATIVE_YIELD_INTERVAL_MS = 12;
|
|
33
|
-
const MODEL_STREAM_COOPERATIVE_YIELD_MAX_EVENTS = 64;
|
|
31
|
+
/** Shared options, usage shape, cache identity, and ordering for OpenAI APIs. */
|
|
34
32
|
const OPENAI_RESPONSE_MODEL_HEADER_NAMES = /* @__PURE__ */ new Set(["openai-model", "x-openai-model"]);
|
|
35
33
|
const OPENAI_RESPONSE_MODEL_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
36
34
|
"response.created",
|
|
@@ -243,9 +241,6 @@ function createOpenAIProviderAcceptanceHook(options, response, model) {
|
|
|
243
241
|
model
|
|
244
242
|
});
|
|
245
243
|
}
|
|
246
|
-
function throwIfModelStreamAborted(signal) {
|
|
247
|
-
if (signal?.aborted) throw transportAbortError(signal);
|
|
248
|
-
}
|
|
249
244
|
/** Measure one UTF-8 append without double-counting a surrogate pair split across chunks. */
|
|
250
245
|
function measureUtf8AppendBytes(bufferEndsWithHighSurrogate, chunk) {
|
|
251
246
|
let bytes = Buffer.byteLength(chunk, "utf8");
|
|
@@ -261,21 +256,6 @@ function measureUtf8AppendBytes(bufferEndsWithHighSurrogate, chunk) {
|
|
|
261
256
|
endsWithHighSurrogate: finalCodeUnit >= 55296 && finalCodeUnit <= 56319
|
|
262
257
|
};
|
|
263
258
|
}
|
|
264
|
-
function createModelStreamCooperativeScheduler(signal) {
|
|
265
|
-
let lastYieldedAt = Date.now();
|
|
266
|
-
let eventsSinceYield = 0;
|
|
267
|
-
return { async afterEvent() {
|
|
268
|
-
throwIfModelStreamAborted(signal);
|
|
269
|
-
eventsSinceYield += 1;
|
|
270
|
-
if (eventsSinceYield < MODEL_STREAM_COOPERATIVE_YIELD_MAX_EVENTS && Date.now() - lastYieldedAt < MODEL_STREAM_COOPERATIVE_YIELD_INTERVAL_MS) return;
|
|
271
|
-
eventsSinceYield = 0;
|
|
272
|
-
await new Promise((resolve) => {
|
|
273
|
-
setTimeout(resolve, 0);
|
|
274
|
-
});
|
|
275
|
-
throwIfModelStreamAborted(signal);
|
|
276
|
-
lastYieldedAt = Date.now();
|
|
277
|
-
} };
|
|
278
|
-
}
|
|
279
259
|
function resolvePromptCacheKey(options, cacheRetention) {
|
|
280
260
|
if (cacheRetention === "none") return;
|
|
281
261
|
return clampOpenAIPromptCacheKey(options?.promptCacheKey ?? options?.sessionId);
|
|
@@ -370,7 +350,7 @@ function resolveOpenAIRequestReasoning(model, reasoning) {
|
|
|
370
350
|
fallbackMap: { [requested]: intent }
|
|
371
351
|
});
|
|
372
352
|
return {
|
|
373
|
-
effort: effort === "none" && resolveOpenAIThinkingApi(model.api) === "openai-chatgpt-responses" && !supportsOpenAIReasoningEffort({ compat: model.compat }, "none") ? void 0 : effort,
|
|
353
|
+
effort: effort === "none" && resolveOpenAIThinkingApi(model.api) === "openai-chatgpt-responses" && !supportsOpenAIReasoningEffort(model.id === "gpt-6-sol" || model.id === "gpt-6-luna" ? model : { compat: model.compat }, "none") ? void 0 : effort,
|
|
374
354
|
thinkingEnabled: intent === void 0 ? void 0 : model.reasoning && normalizedIntent !== "off" && normalizedIntent !== "none"
|
|
375
355
|
};
|
|
376
356
|
}
|
|
@@ -477,102 +457,78 @@ function projectOpenAIToolDescriptors(tools, schemas) {
|
|
|
477
457
|
diagnostics
|
|
478
458
|
};
|
|
479
459
|
}
|
|
480
|
-
function
|
|
481
|
-
|
|
482
|
-
}
|
|
483
|
-
/** Keeps Responses tool choices aligned with surviving function schemas. */
|
|
484
|
-
function reconcileOpenAIResponsesToolChoice(choice, projection) {
|
|
460
|
+
function reconcileToolChoice(choice, projection, responses) {
|
|
461
|
+
const label = responses ? "OpenAI Responses" : "OpenAI Chat Completions";
|
|
485
462
|
if (choice === "auto") return projection.tools.length > 0 ? choice : void 0;
|
|
486
463
|
if (choice === "required") {
|
|
487
|
-
if (projection.tools.length === 0) throw new Error(
|
|
464
|
+
if (projection.tools.length === 0) throw new Error(`${label} tool_choice requires a tool, but no tools survived schema conversion`);
|
|
488
465
|
return choice;
|
|
489
466
|
}
|
|
490
467
|
if (choice === "none" || !isRecord(choice)) return choice;
|
|
491
468
|
const choiceType = choice.type;
|
|
469
|
+
if (!responses && choiceType === "custom") throw new Error("OpenAI Chat Completions custom tool_choice is unsupported because this adapter emits function tools only");
|
|
492
470
|
if (choiceType === "function") {
|
|
493
|
-
const
|
|
471
|
+
const functionChoice = responses ? choice : choice.function;
|
|
472
|
+
const functionName = isRecord(functionChoice) ? functionChoice.name : void 0;
|
|
494
473
|
if (typeof functionName !== "string") return choice;
|
|
495
|
-
|
|
496
|
-
return {
|
|
474
|
+
if (!projection.tools.some((tool) => tool.name === functionName)) throw new Error(`${label} tool_choice requested unavailable tool "${functionName}" after schema conversion`);
|
|
475
|
+
return responses ? {
|
|
497
476
|
type: "function",
|
|
498
477
|
name: functionName
|
|
478
|
+
} : {
|
|
479
|
+
type: "function",
|
|
480
|
+
function: { name: functionName }
|
|
499
481
|
};
|
|
500
482
|
}
|
|
501
483
|
if (choiceType !== "allowed_tools") return choice;
|
|
502
|
-
const
|
|
503
|
-
|
|
484
|
+
const allowedConfig = responses ? choice : choice.allowed_tools;
|
|
485
|
+
if (!isRecord(allowedConfig)) return choice;
|
|
486
|
+
const { mode, tools } = allowedConfig;
|
|
504
487
|
if (mode !== "auto" && mode !== "required" || !Array.isArray(tools)) return choice;
|
|
505
|
-
const
|
|
488
|
+
const responseTools = [];
|
|
489
|
+
const completionTools = [];
|
|
506
490
|
for (const tool of tools) {
|
|
507
491
|
if (!isRecord(tool) || tool.type !== "function") {
|
|
508
|
-
|
|
492
|
+
if (responses) responseTools.push(tool);
|
|
509
493
|
continue;
|
|
510
494
|
}
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
495
|
+
const functionChoice = responses ? tool : tool.function;
|
|
496
|
+
const functionName = isRecord(functionChoice) ? functionChoice.name : void 0;
|
|
497
|
+
if (typeof functionName === "string" && projection.tools.some((projectedTool) => projectedTool.name === functionName)) {
|
|
498
|
+
if (responses) responseTools.push({
|
|
499
|
+
type: "function",
|
|
500
|
+
name: functionName
|
|
501
|
+
});
|
|
502
|
+
else completionTools.push({
|
|
503
|
+
type: "function",
|
|
504
|
+
function: { name: functionName }
|
|
505
|
+
});
|
|
506
|
+
}
|
|
516
507
|
}
|
|
517
|
-
if (
|
|
508
|
+
if (responseTools.length === 0 && completionTools.length === 0) {
|
|
518
509
|
if (mode === "auto") return "none";
|
|
519
|
-
throw new Error(
|
|
510
|
+
throw new Error(`${label} tool_choice requires a tool, but no allowed tools survived schema conversion`);
|
|
520
511
|
}
|
|
521
|
-
return {
|
|
512
|
+
return responses ? {
|
|
522
513
|
type: "allowed_tools",
|
|
523
514
|
mode,
|
|
524
|
-
tools:
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
/** Keeps Chat Completions tool choices aligned with surviving function schemas. */
|
|
528
|
-
function reconcileOpenAICompletionsToolChoice(choice, projection) {
|
|
529
|
-
if (choice === "auto") return projection.tools.length > 0 ? choice : void 0;
|
|
530
|
-
if (choice === "required") {
|
|
531
|
-
if (projection.tools.length === 0) throw new Error("OpenAI Chat Completions tool_choice requires a tool, but no tools survived schema conversion");
|
|
532
|
-
return choice;
|
|
533
|
-
}
|
|
534
|
-
if (choice === "none" || !isRecord(choice)) return choice;
|
|
535
|
-
const choiceType = choice.type;
|
|
536
|
-
if (choiceType === "custom") throw new Error("OpenAI Chat Completions custom tool_choice is unsupported because this adapter emits function tools only");
|
|
537
|
-
if (choiceType === "function") {
|
|
538
|
-
const functionChoice = choice.function;
|
|
539
|
-
if (!isRecord(functionChoice)) return choice;
|
|
540
|
-
const functionName = functionChoice.name;
|
|
541
|
-
if (typeof functionName !== "string") return choice;
|
|
542
|
-
requireProjectedFunction(functionName, projection, "OpenAI Chat Completions tool_choice");
|
|
543
|
-
return {
|
|
544
|
-
type: "function",
|
|
545
|
-
function: { name: functionName }
|
|
546
|
-
};
|
|
547
|
-
}
|
|
548
|
-
if (choiceType !== "allowed_tools") return choice;
|
|
549
|
-
const allowedConfig = choice.allowed_tools;
|
|
550
|
-
if (!isRecord(allowedConfig)) return choice;
|
|
551
|
-
const mode = allowedConfig.mode;
|
|
552
|
-
const tools = allowedConfig.tools;
|
|
553
|
-
if (mode !== "auto" && mode !== "required" || !Array.isArray(tools)) return choice;
|
|
554
|
-
const normalizedAllowedTools = [];
|
|
555
|
-
for (const tool of tools) {
|
|
556
|
-
if (!isRecord(tool) || tool.type !== "function") continue;
|
|
557
|
-
const functionChoice = tool.function;
|
|
558
|
-
const functionName = isRecord(functionChoice) ? functionChoice.name : void 0;
|
|
559
|
-
if (typeof functionName === "string" && projection.tools.some((projectedTool) => projectedTool.name === functionName)) normalizedAllowedTools.push({
|
|
560
|
-
type: "function",
|
|
561
|
-
function: { name: functionName }
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
if (normalizedAllowedTools.length === 0) {
|
|
565
|
-
if (mode === "auto") return "none";
|
|
566
|
-
throw new Error("OpenAI Chat Completions tool_choice requires a tool, but no allowed tools survived schema conversion");
|
|
567
|
-
}
|
|
568
|
-
return {
|
|
515
|
+
tools: responseTools
|
|
516
|
+
} : {
|
|
569
517
|
type: "allowed_tools",
|
|
570
518
|
allowed_tools: {
|
|
571
519
|
mode,
|
|
572
|
-
tools:
|
|
520
|
+
tools: completionTools
|
|
573
521
|
}
|
|
574
522
|
};
|
|
575
523
|
}
|
|
524
|
+
/** Keeps Responses tool choices aligned with surviving function schemas. */
|
|
525
|
+
function reconcileOpenAIResponsesToolChoice(choice, projection) {
|
|
526
|
+
return reconcileToolChoice(choice, projection, true);
|
|
527
|
+
}
|
|
528
|
+
/** Keeps Chat Completions tool choices aligned with surviving function schemas. */
|
|
529
|
+
function reconcileOpenAICompletionsToolChoice(choice, projection) {
|
|
530
|
+
return reconcileToolChoice(choice, projection, false);
|
|
531
|
+
}
|
|
576
532
|
//#endregion
|
|
577
533
|
//#region packages/ai/src/transports/openai-transport-params.ts
|
|
578
534
|
const MAX_OPENAI_STRICT_TOOL_DOWNGRADE_DIAGNOSTIC_KEYS = 256;
|
|
@@ -733,16 +689,15 @@ function buildOpenAIClientHeaders(model, context, optionHeaders, turnHeaders, se
|
|
|
733
689
|
...optionHeaders,
|
|
734
690
|
...turnHeaders
|
|
735
691
|
};
|
|
736
|
-
const resolvedHeaders =
|
|
692
|
+
const resolvedHeaders = getAiTransportHost().resolveProviderRequestHeaders({
|
|
737
693
|
provider: model.provider,
|
|
738
694
|
api: model.api,
|
|
739
695
|
baseUrl: model.baseUrl,
|
|
740
|
-
capability: "llm",
|
|
741
|
-
transport: "stream",
|
|
742
696
|
providerHeaders,
|
|
743
697
|
callerHeaders: Object.keys(callerHeaders).length > 0 ? callerHeaders : void 0,
|
|
744
|
-
precedence: "caller-wins"
|
|
745
|
-
|
|
698
|
+
precedence: "caller-wins",
|
|
699
|
+
model
|
|
700
|
+
}) ?? {};
|
|
746
701
|
const sendSessionIdHeader = (OPENAI_RESPONSES_APIS.has(model.api) && model.compat && "sendSessionIdHeader" in model.compat ? model.compat?.sendSessionIdHeader : void 0) ?? usesNativeOpenAICodexResponsesBackend(model);
|
|
747
702
|
if (sessionId && cacheRetention !== "none" && sendSessionIdHeader && !Object.keys(resolvedHeaders).some((key) => normalizeLowercaseStringOrEmpty(key) === "session_id")) resolvedHeaders.session_id = clampOpenAIPromptCacheKey(sessionId) ?? sessionId;
|
|
748
703
|
return resolveOpencodeSessionHeaders(model, {
|
|
@@ -782,4 +737,4 @@ function getCompat(model) {
|
|
|
782
737
|
};
|
|
783
738
|
}
|
|
784
739
|
//#endregion
|
|
785
|
-
export {
|
|
740
|
+
export { redactIdentifier as A, log as C, readOpenAICompletionsReasoningBatch as D, readOpenAICompletionsContentDeltas as E, resolveOpenAIClientBaseUrl as O, isOpenAICompletionsThinkingEnabled as S, parseOpenAICompletionsUsage as T, resolveOpenAIReasoningEffortMap as _, enforceCodeModeResponsesToolSurface as a, createOpenAIResponseHook as b, readCodeModePayloadToolName as c, prepareOpenAITools as d, projectOpenAITools as f, resolveOpenAISimpleReasoningEffort as g, resolveOpenAIRequestReasoning as h, buildOpenAISdkRequestOptions as i, sha256Hex as j, resolvePromptCacheKey as k, resolveCodeModeResponsesVisibleToolNames as l, reconcileOpenAIResponsesToolChoice as m, buildOpenAIClientHeaders as n, filterCodeModePayloadTools as o, reconcileOpenAICompletionsToolChoice as p, buildOpenAISdkClientOptions as r, getCompat as s, assertCodeModeResponsesToolSurface as t, resolveOpenAIStrictToolFlagWithDiagnostics as u, GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP as v, measureUtf8AppendBytes as w, createResponseModelTracker as x, createOpenAIProviderAcceptanceHook as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as parseStrictPositiveInteger } from "./base64-
|
|
1
|
+
import { o as parseStrictPositiveInteger } from "./base64-C1PsYcRQ.mjs";
|
|
2
2
|
//#region packages/ai/src/transports/positive-integer.ts
|
|
3
3
|
function parsePositiveInteger(value) {
|
|
4
4
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return Math.floor(value);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { i as asOptionalRecord } from "./record-coerce-CNDovvft.mjs";
|
|
1
2
|
import { o as normalizeStringifiedOptionalString } from "./string-coerce-fsri9iCu.mjs";
|
|
2
|
-
import { i as asOptionalRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
3
|
-
import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
|
|
4
3
|
import { t as expectDefined } from "./expect-lbe3Hgrh.mjs";
|
|
5
|
-
import { n as estimateBase64DecodedBytes } from "./base64-
|
|
4
|
+
import { n as estimateBase64DecodedBytes } from "./base64-C1PsYcRQ.mjs";
|
|
6
5
|
import { parseRetryAfterErrorSeconds, parseRetryAfterHeadersSeconds } from "./internal/retry-after.mjs";
|
|
7
6
|
//#region packages/normalization-core/src/balanced-json.ts
|
|
8
7
|
function isJsonOpeningDelimiter(char, openers) {
|
|
@@ -103,7 +102,7 @@ const preserveString = (value) => value;
|
|
|
103
102
|
function stableStringify(value, normalizeString = preserveString) {
|
|
104
103
|
return stringifyStableValue(value, /* @__PURE__ */ new WeakSet(), normalizeString);
|
|
105
104
|
}
|
|
106
|
-
function stringifyStableValue(value, stack, normalizeString) {
|
|
105
|
+
function stringifyStableValue(value, stack, normalizeString, write) {
|
|
107
106
|
if (value === null || value === void 0) return String(value);
|
|
108
107
|
if (typeof value === "number" && !Number.isFinite(value)) return JSON.stringify(String(value));
|
|
109
108
|
if (typeof value === "bigint") return JSON.stringify(value.toString());
|
|
@@ -112,22 +111,33 @@ function stringifyStableValue(value, stack, normalizeString) {
|
|
|
112
111
|
if (stack.has(value)) return JSON.stringify("[Circular]");
|
|
113
112
|
stack.add(value);
|
|
114
113
|
try {
|
|
115
|
-
return stringifyObjectValue(value, stack, normalizeString);
|
|
114
|
+
return stringifyObjectValue(value, stack, normalizeString, write);
|
|
116
115
|
} finally {
|
|
117
116
|
stack.delete(value);
|
|
118
117
|
}
|
|
119
118
|
}
|
|
120
|
-
function stringifyObjectValue(value, stack, normalizeString) {
|
|
119
|
+
function stringifyObjectValue(value, stack, normalizeString, write) {
|
|
121
120
|
if (value instanceof Error) return stringifyStableValue({
|
|
122
121
|
name: value.name,
|
|
123
122
|
message: value.message,
|
|
124
123
|
stack: value.stack
|
|
125
|
-
}, stack, normalizeString);
|
|
124
|
+
}, stack, normalizeString, write);
|
|
126
125
|
if (value instanceof Uint8Array) return stringifyStableValue({
|
|
127
126
|
type: "Uint8Array",
|
|
128
127
|
data: encodeBase64(value)
|
|
129
|
-
}, stack, normalizeString);
|
|
128
|
+
}, stack, normalizeString, write);
|
|
130
129
|
if (Array.isArray(value)) {
|
|
130
|
+
if (write) {
|
|
131
|
+
write("[");
|
|
132
|
+
let separator = "";
|
|
133
|
+
for (const entry of value) {
|
|
134
|
+
write(separator);
|
|
135
|
+
write(stringifyStableValue(entry, stack, normalizeString, write));
|
|
136
|
+
separator = ",";
|
|
137
|
+
}
|
|
138
|
+
write("]");
|
|
139
|
+
return "";
|
|
140
|
+
}
|
|
131
141
|
const serializedEntries = [];
|
|
132
142
|
for (const entry of value) serializedEntries.push(stringifyStableValue(entry, stack, normalizeString));
|
|
133
143
|
return `[${serializedEntries.join(",")}]`;
|
|
@@ -135,6 +145,17 @@ function stringifyObjectValue(value, stack, normalizeString) {
|
|
|
135
145
|
const record = value;
|
|
136
146
|
if (normalizeString === preserveString) {
|
|
137
147
|
const fields = Object.keys(record).sort();
|
|
148
|
+
if (write) {
|
|
149
|
+
write("{");
|
|
150
|
+
let separator = "";
|
|
151
|
+
for (const key of fields) {
|
|
152
|
+
write(`${separator}${JSON.stringify(key)}:`);
|
|
153
|
+
write(stringifyStableValue(record[key], stack, normalizeString, write));
|
|
154
|
+
separator = ",";
|
|
155
|
+
}
|
|
156
|
+
write("}");
|
|
157
|
+
return "";
|
|
158
|
+
}
|
|
138
159
|
let fieldIndex = 0;
|
|
139
160
|
for (const key of fields) fields[fieldIndex++] = `${JSON.stringify(key)}:${stringifyStableValue(record[key], stack, normalizeString)}`;
|
|
140
161
|
return `{${fields.join(",")}}`;
|
|
@@ -146,6 +167,17 @@ function stringifyObjectValue(value, stack, normalizeString) {
|
|
|
146
167
|
return compareStableStrings(left.normalizedKey, right.normalizedKey) || compareStableStrings(left.key, right.key);
|
|
147
168
|
});
|
|
148
169
|
const serializedFields = [];
|
|
170
|
+
if (write) {
|
|
171
|
+
write("{");
|
|
172
|
+
let separator = "";
|
|
173
|
+
for (const { key, normalizedKey } of entries) {
|
|
174
|
+
write(`${separator}${JSON.stringify(normalizedKey)}:`);
|
|
175
|
+
write(stringifyStableValue(record[key], stack, normalizeString, write));
|
|
176
|
+
separator = ",";
|
|
177
|
+
}
|
|
178
|
+
write("}");
|
|
179
|
+
return "";
|
|
180
|
+
}
|
|
149
181
|
for (const { key, normalizedKey } of entries) serializedFields.push(`${JSON.stringify(normalizedKey)}:${stringifyStableValue(record[key], stack, normalizeString)}`);
|
|
150
182
|
return `{${serializedFields.join(",")}}`;
|
|
151
183
|
}
|
|
@@ -158,6 +190,34 @@ function compareStableStrings(left, right) {
|
|
|
158
190
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
159
191
|
}
|
|
160
192
|
//#endregion
|
|
193
|
+
//#region packages/normalization-core/src/utf16-slice.ts
|
|
194
|
+
function isHighSurrogate(codeUnit) {
|
|
195
|
+
return codeUnit >= 55296 && codeUnit <= 56319;
|
|
196
|
+
}
|
|
197
|
+
function isLowSurrogate(codeUnit) {
|
|
198
|
+
return codeUnit >= 56320 && codeUnit <= 57343;
|
|
199
|
+
}
|
|
200
|
+
/** Slices a UTF-16 string without returning dangling surrogate halves at either edge. */
|
|
201
|
+
function sliceUtf16Safe(input, start, end) {
|
|
202
|
+
const len = input.length;
|
|
203
|
+
let from = start < 0 ? Math.max(len + start, 0) : Math.min(start, len);
|
|
204
|
+
let to = end === void 0 ? len : end < 0 ? Math.max(len + end, 0) : Math.min(end, len);
|
|
205
|
+
if (to <= from) return "";
|
|
206
|
+
if (from > 0 && from < len) {
|
|
207
|
+
if (isLowSurrogate(input.charCodeAt(from)) && isHighSurrogate(input.charCodeAt(from - 1))) from += 1;
|
|
208
|
+
}
|
|
209
|
+
if (to > 0 && to < len) {
|
|
210
|
+
if (isHighSurrogate(input.charCodeAt(to - 1)) && isLowSurrogate(input.charCodeAt(to))) to -= 1;
|
|
211
|
+
}
|
|
212
|
+
return input.slice(from, to);
|
|
213
|
+
}
|
|
214
|
+
/** Truncates a UTF-16 string without cutting a surrogate pair in half. */
|
|
215
|
+
function truncateUtf16Safe(input, maxLen) {
|
|
216
|
+
const limit = Math.max(0, Math.floor(maxLen));
|
|
217
|
+
if (input.length <= limit) return input;
|
|
218
|
+
return sliceUtf16Safe(input, 0, limit);
|
|
219
|
+
}
|
|
220
|
+
//#endregion
|
|
161
221
|
//#region packages/ai/src/utils/credential-redaction.ts
|
|
162
222
|
const NON_CREDENTIAL_FIELD_NAMES = /* @__PURE__ */ new Set([
|
|
163
223
|
"passwordfile",
|
|
@@ -194,6 +254,9 @@ const LOOSE_QUOTED_CREDENTIAL_PAIR_RE = /\b((?!(?:api|endpoint|method|model|prov
|
|
|
194
254
|
const LOOSE_CREDENTIAL_PAIR_RE = /\b((?!(?:api|endpoint|method|model|provider|status|type)=)[A-Za-z][A-Za-z0-9_.-]{0,64})=([A-Za-z0-9+/._~%=-]{16,})(?=[;&#'"\s]|$)/giu;
|
|
195
255
|
const MEDIA_DATA_URL_RE = /data:(?:audio|image|video)\/[a-z0-9.+-]+(?:;[^,;\s]+)*;base64,[ \t]*(?:\r?\n[ \t]*)?[a-z0-9+/_=-]+(?:[ \t]*\r?\n[ \t]*[a-z0-9+/_=-]+)*/giu;
|
|
196
256
|
const MAX_DIAGNOSTIC_JSON_LENGTH = 16384;
|
|
257
|
+
const UNCHANGED_DIAGNOSTIC_TEXT_MAX_ENTRIES = 2048;
|
|
258
|
+
const UNCHANGED_DIAGNOSTIC_TEXT_MAX_LENGTH = 2048;
|
|
259
|
+
const unchangedDiagnosticText = /* @__PURE__ */ new Set();
|
|
197
260
|
const BRACKET_PROSE_PATTERN = String.raw`(\[+)([A-Za-z][A-Za-z0-9 _.-]*|\s*\d+\s+(?!(?:true|false|null)(?![\w-]))[A-Za-z][A-Za-z0-9 _.=-]*)(\]+)`;
|
|
198
261
|
const BRACKET_PROSE_RE = new RegExp(`^${BRACKET_PROSE_PATTERN}$`, "u");
|
|
199
262
|
const BRACKET_PROSE_PART_RE = new RegExp(String.raw`(?<!\[)${BRACKET_PROSE_PATTERN}`, "gu");
|
|
@@ -353,6 +416,15 @@ function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new W
|
|
|
353
416
|
}
|
|
354
417
|
/** Redacts bounded structured JSON while preserving harmless diagnostic text byte-for-byte. */
|
|
355
418
|
function redactDiagnosticText(value) {
|
|
419
|
+
if (unchangedDiagnosticText.has(value)) return value;
|
|
420
|
+
const projected = projectDiagnosticText(value);
|
|
421
|
+
if (projected === value && value.length <= UNCHANGED_DIAGNOSTIC_TEXT_MAX_LENGTH) {
|
|
422
|
+
if (unchangedDiagnosticText.size >= UNCHANGED_DIAGNOSTIC_TEXT_MAX_ENTRIES) unchangedDiagnosticText.clear();
|
|
423
|
+
unchangedDiagnosticText.add(value);
|
|
424
|
+
}
|
|
425
|
+
return projected;
|
|
426
|
+
}
|
|
427
|
+
function projectDiagnosticText(value) {
|
|
356
428
|
const text = redactCredentialText(value).replace(MEDIA_DATA_URL_RE, "<redacted>");
|
|
357
429
|
if (!looksLikeDiagnosticJson(text)) return text;
|
|
358
430
|
const allowProse = !hasSensitiveProseContent(text);
|
|
@@ -432,7 +504,7 @@ function buildProjection(snapshot, signal) {
|
|
|
432
504
|
const originalMessage = (typeof snapshot === "string" ? snapshot : void 0) ?? readProviderErrorField(error, "message") ?? readProviderErrorField(nestedError, "message");
|
|
433
505
|
const genericMessage = originalMessage === `${status} status code (no body)`;
|
|
434
506
|
let errorMessage = status !== void 0 && body && (!originalMessage || genericMessage) ? `${status}: ${body}` : originalMessage ?? body ?? stringifyField(snapshot, MAX_ERROR_BODY_LENGTH) ?? "Unknown provider error";
|
|
435
|
-
if (status !== void 0 &&
|
|
507
|
+
if (status !== void 0 && originalMessage && !originalMessage.startsWith(String(status))) errorMessage = `${status}: ${errorMessage}`;
|
|
436
508
|
const rawMetadata = stringifyField(asOptionalRecord(nestedError?.metadata)?.raw, MAX_ERROR_BODY_LENGTH);
|
|
437
509
|
if (rawMetadata && !errorMessage.includes(rawMetadata)) errorMessage += `\n${rawMetadata}`;
|
|
438
510
|
const errorCode = readProviderErrorField(error, "errorCode") ?? readProviderErrorField(error, "code") ?? readProviderErrorField(nestedError, "code") ?? (error ? readCauseCode(error) : void 0) ?? (status === void 0 ? void 0 : String(status));
|
|
@@ -468,4 +540,4 @@ function projectProviderError(error, signal) {
|
|
|
468
540
|
}
|
|
469
541
|
}
|
|
470
542
|
//#endregion
|
|
471
|
-
export { redactDiagnosticText as a, projectDiagnosticValue as i, projectProviderError as n,
|
|
543
|
+
export { redactDiagnosticText as a, projectDiagnosticValue as i, projectProviderError as n, truncateUtf16Safe as o, createDiagnosticRecord as r, stableStringify as s, configureProviderErrorRedactor as t };
|
|
@@ -8,5 +8,7 @@ type ProviderErrorProjection = {
|
|
|
8
8
|
};
|
|
9
9
|
type ProviderErrorRedactor = (value: unknown) => unknown;
|
|
10
10
|
declare function configureProviderErrorRedactor(redactor: ProviderErrorRedactor | undefined): ProviderErrorRedactor | undefined;
|
|
11
|
+
/** Projects one hostile provider throw into final, bounded assistant terminal fields. */
|
|
12
|
+
declare function projectProviderError(error: unknown, signal?: AbortSignal): ProviderErrorProjection;
|
|
11
13
|
//#endregion
|
|
12
|
-
export { ProviderErrorRedactor as n, configureProviderErrorRedactor as r, ProviderErrorProjection as t };
|
|
14
|
+
export { projectProviderError as i, ProviderErrorRedactor as n, configureProviderErrorRedactor as r, ProviderErrorProjection as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Y as StreamOptions } from "./types-
|
|
1
|
+
import { Y as StreamOptions } from "./types-CLLR3eB4.mjs";
|
|
2
2
|
import { t as OpenAICompletionsToolChoice } from "./openai-tool-projection-793cE3QX.mjs";
|
|
3
|
-
import "./types-
|
|
3
|
+
import "./types-CB-_vNyI.mjs";
|
|
4
4
|
import Anthropic from "@anthropic-ai/sdk";
|
|
5
5
|
//#region packages/ai/src/providers/openai-reasoning-effort.d.ts
|
|
6
6
|
declare const ENABLED_REASONING_EFFORTS: readonly ["minimal", "low", "medium", "high", "xhigh", "max"];
|
|
@@ -20,6 +20,8 @@ declare function isOpenAIGpt54MiniModel(model: OpenAIReasoningModel): boolean;
|
|
|
20
20
|
declare function isOpenAIGpt55Model(model: OpenAIReasoningModel): boolean;
|
|
21
21
|
/** Return whether a model is the GPT-5.6 family. */
|
|
22
22
|
declare function isOpenAIGpt56Model(model: OpenAIReasoningModel): boolean;
|
|
23
|
+
/** Return whether a model has a known GPT-6 reasoning and sampling contract. */
|
|
24
|
+
declare function isOpenAIGpt6Model(model: OpenAIReasoningModel): boolean;
|
|
23
25
|
/** Normalize user-facing reasoning effort names to API effort names. */
|
|
24
26
|
declare function normalizeOpenAIReasoningEffort(effort: string): string;
|
|
25
27
|
/** Resolve the reasoning efforts accepted by a specific OpenAI-compatible model. */
|
|
@@ -27,7 +29,7 @@ declare function resolveOpenAISupportedReasoningEfforts(model: OpenAIReasoningMo
|
|
|
27
29
|
/** Read a declared or known model contract, leaving unknown compatible models unspecified. */
|
|
28
30
|
declare function resolveOpenAIModelReasoningEfforts(model: OpenAIReasoningModel): readonly OpenAIApiReasoningEffort[] | undefined;
|
|
29
31
|
/**
|
|
30
|
-
* Return whether a model accepts temperature. GPT-5.6 and GPT-6
|
|
32
|
+
* Return whether a model accepts temperature. GPT-5.6 and known GPT-6 models
|
|
31
33
|
* reject it with a 400; catalog compat can override per model.
|
|
32
34
|
*/
|
|
33
35
|
declare function supportsOpenAITemperature(model: OpenAIReasoningModel): boolean;
|
|
@@ -146,4 +148,4 @@ type OpenAICompletionsOptions = BaseOpenAIStreamOptions & {
|
|
|
146
148
|
reasoningEffort?: OpenAIReasoningEffort | "off";
|
|
147
149
|
};
|
|
148
150
|
//#endregion
|
|
149
|
-
export { supportsOpenAITemperature as S,
|
|
151
|
+
export { supportsOpenAITemperature as C, supportsOpenAIReasoningEffort as S, normalizeOpenAIReasoningEffort as _, BaseOpenAIStreamOptions as a, resolveOpenAIReasoningEffortMapping as b, OpenAIResponsesCompactionRejection as c, OpenAIApiReasoningEffort as d, OpenAIReasoningEffort as f, isOpenAIGpt6Model as g, isOpenAIGpt56Model as h, AnthropicThinkingDisplay as i, codeModeToolSurfaceObserver as l, isOpenAIGpt55Model as m, AnthropicEffort as n, CodeModeToolSurfaceObservation as o, isOpenAIGpt54MiniModel as p, AnthropicOptions as r, OpenAICompletionsOptions as s, AnthropicContextManagementOptions as t, reasoningTagTextPolicy as u, resolveOpenAIModelReasoningEfforts as v, resolveOpenAISupportedReasoningEfforts as x, resolveOpenAIReasoningEffortForModel as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as shortHash } from "./transport-stream-shared-Dh5qKJ8e.mjs";
|
|
2
2
|
//#region packages/ai/src/transports/provider-replay-context.ts
|
|
3
3
|
function hashReplayContextValue(value) {
|
|
4
4
|
const normalized = value?.trim();
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
import { i as transformMessages } from "./host-
|
|
1
|
+
import { i as transformMessages } from "./host-CHi3X87F.mjs";
|
|
2
|
+
import { a as createEmptyTransportUsage } from "./transport-stream-shared-Dh5qKJ8e.mjs";
|
|
3
|
+
//#region packages/ai/src/transports/assistant-output.ts
|
|
4
|
+
function createAssistantOutput(model, api = model.api) {
|
|
5
|
+
return {
|
|
6
|
+
role: "assistant",
|
|
7
|
+
content: [],
|
|
8
|
+
api,
|
|
9
|
+
provider: model.provider,
|
|
10
|
+
model: model.id,
|
|
11
|
+
usage: createEmptyTransportUsage(),
|
|
12
|
+
stopReason: "stop",
|
|
13
|
+
timestamp: Date.now()
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
2
17
|
//#region packages/ai/src/provider-transcript-transform.ts
|
|
3
18
|
const IMAGE_OMISSION = "(image omitted: model does not support images)";
|
|
4
19
|
const VIDEO_OMISSION = "(video omitted: provider does not support video input)";
|
|
@@ -29,4 +44,4 @@ function transformProviderMessages(messages, model, normalizeToolCallId) {
|
|
|
29
44
|
}), target, normalizeToolCallId);
|
|
30
45
|
}
|
|
31
46
|
//#endregion
|
|
32
|
-
export { transformProviderMessages as t };
|
|
47
|
+
export { createAssistantOutput as n, transformProviderMessages as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as getAiTransportHost } from "./host-
|
|
1
|
+
import { n as getAiTransportHost } from "./host-CHi3X87F.mjs";
|
|
2
2
|
import { n as resolveOpencodeSessionHeaders, t as hasOpencodeSessionHeader } from "./session-affinity-Bcunsn4I.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
//#region packages/ai/src/transports/provider-transport-turn-state.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as index_d_exports } from "./index-
|
|
2
|
-
import { O as Model, X as TextContent, Y as StreamOptions, a as AssistantMessage, d as Context, f as ImageContent, it as ToolResultMessage, n as Api, s as AssistantMessageEventStreamContract, st as UserMessage } from "./types-
|
|
3
|
-
import "./types-
|
|
1
|
+
import { t as index_d_exports } from "./index-D6KsSE74.mjs";
|
|
2
|
+
import { O as Model, X as TextContent, Y as StreamOptions, a as AssistantMessage, d as Context, f as ImageContent, it as ToolResultMessage, n as Api, s as AssistantMessageEventStreamContract, st as UserMessage } from "./types-CLLR3eB4.mjs";
|
|
3
|
+
import "./types-CB-_vNyI.mjs";
|
|
4
4
|
//#region packages/ai/src/provider-types.d.ts
|
|
5
5
|
declare const PROVIDER_CONTEXT_HANDOFF: unique symbol;
|
|
6
6
|
type VideoContent = Omit<ImageContent, "type"> & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { $ as ThinkingContent, A as ModelCostRates, B as ProviderReplayState, C as KnownImagesApi, E as MaybePromise, F as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, G as SimpleStreamOptions, I as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, K as StopReason, L as PricingTier, M as OpenAICompletionsCompat, N as OpenAIResponsesCompat, P as OpenRouterRouting, Q as ThinkingBudgets, R as Provider, S as KnownApi, T as MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, U as RawModelCostConfig, V as ProviderResponse, W as RawPricingTier, X as TextContent, Y as StreamOptions, Z as TextSignatureV1, _ as ImagesModel, a as AssistantMessage, at as Transport, b as ImagesProvider, c as AssistantMessageEventStreamLike, ct as ValidateToolArgumentsFn, dt as DiagnosticErrorInfo, et as ThinkingLevel, f as ImageContent, ft as appendAssistantMessageDiagnostic, g as ImagesInputContent, gt as isProviderRefusalAssistantError, h as ImagesFunction, ht as formatThrownValue, i as AssistantImages, it as ToolResultMessage, j as ModelThinkingLevel, k as ModelCostConfig, l as CacheRetention, lt as VercelGatewayRouting, m as ImagesContext, mt as extractDiagnosticError, n as Api, nt as Tool, o as AssistantMessageEvent, ot as Usage, p as ImagesApi, pt as createAssistantMessageDiagnostic, q as StreamFn, r as AssistantDeliveryTtsFacts, rt as ToolCall, s as AssistantMessageEventStreamContract, st as UserMessage, t as AnthropicMessagesCompat, tt as ThinkingLevelMap, u as CompleteSimpleFn, ut as AssistantMessageDiagnostic, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as ProviderImagesOptions } from "./types-
|
|
3
|
-
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
4
|
-
import { n as validateToolCall, t as validateToolArguments } from "./validation-
|
|
5
|
-
import { a as ProviderContextHandoff, c as ProviderStreamFunction, d as VideoContent, f as resolveProviderContext, i as ProviderContext, l as ProviderStreamOptions, n as ModelInputContent, o as ProviderMessage, r as PROVIDER_CONTEXT_HANDOFF, s as ProviderModel, t as MediaContent, u as ProviderUserMessage } from "./provider-types-
|
|
6
|
-
export { type AnthropicMessagesCompat, type Api, type AssistantDeliveryTtsFacts, type AssistantImages, type AssistantMessage, type AssistantMessageDiagnostic, type AssistantMessageEvent, type AssistantMessageEventStream, type AssistantMessageEventStreamContract, type AssistantMessageEventStreamLike, type CLAUDE_FABLE_5_THINKING_PROFILE, type CLAUDE_OPUS_5_THINKING_PROFILE, type CLAUDE_SONNET_5_THINKING_PROFILE, type CacheRetention, type CompleteSimpleFn, type ProviderContext as Context, ProviderContext, type DiagnosticErrorInfo, type EventStream, type ImageContent, type ImagesApi, type ImagesContext, type ImagesFunction, type ImagesInputContent, type ImagesModel, type ImagesOptions, type ImagesOutputContent, type ImagesProvider, type ImagesStopReason, type KnownApi, type KnownImagesApi, type KnownImagesProvider, type MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, type MaybePromise, MediaContent, type ProviderMessage as Message, ProviderMessage, type ProviderModel as Model, ProviderModel, type ModelCostConfig, type ModelCostRates, ModelInputContent, type ModelThinkingLevel, type OpenAICompletionsCompat, type OpenAIResponsesCompat, type OpenRouterRouting, PROVIDER_CONTEXT_HANDOFF, type PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, type PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, type PricingTier, type Provider, ProviderContextHandoff, type ProviderImagesOptions, type ProviderReplayState, type ProviderResponse, ProviderStreamFunction, type ProviderStreamFunction as StreamFunction, ProviderStreamOptions, ProviderUserMessage, type RawModelCostConfig, type RawPricingTier, type SimpleStreamOptions, type StopReason, type StreamFn, type StreamOptions, type TextContent, type TextSignatureV1, type ThinkingBudgets, type ThinkingContent, type ThinkingLevel, type ThinkingLevelMap, type Tool, type ToolCall, type ToolResultMessage, type Transport, type Usage, type UserMessage, type ValidateToolArgumentsFn, type VercelGatewayRouting, VideoContent, type appendAssistantMessageDiagnostic, type bindsClaudeThinkingPrefix, type calculateUsageCost, type createAssistantMessageDiagnostic, type createAssistantMessageEventStream, type extractDiagnosticError, type formatThrownValue, type isProviderRefusalAssistantError, type normalizeModelCostConfig, type normalizeResolvedPricing, type requiresClaudeDefaultSampling, type requiresClaudeMandatoryAdaptiveThinking, type resolveClaudeFable5ModelIdentity, type resolveClaudeModelIdentity, type resolveClaudeMythos5ModelIdentity, type resolveClaudeNativeThinkingLevelMap, type resolveClaudeOpus5ModelIdentity, type resolveClaudeSonnet5ModelIdentity, resolveProviderContext, type supportsClaude1MContext, type supportsClaudeAdaptiveThinking, type supportsClaudeFastMode, type supportsClaudeNativeMaxEffort, type supportsClaudeNativeXhighEffort, type validateToolArguments, type validateToolCall };
|
|
1
|
+
import { C as resolveClaudeSonnet5ModelIdentity, D as supportsClaudeNativeMaxEffort, E as supportsClaudeFastMode, O as supportsClaudeNativeXhighEffort, S as resolveClaudeSonnet55ModelIdentity, T as supportsClaudeAdaptiveThinking, _ as resolveClaudeModelIdentity, a as ProviderRefusalReview, b as resolveClaudeOpus55ModelIdentity, c as CLAUDE_OPUS_55_THINKING_PROFILE, d as CLAUDE_SONNET_5_THINKING_PROFILE, f as bindsClaudeThinkingPrefix, g as resolveClaudeFable5ModelIdentity, h as requiresClaudeMandatoryAdaptiveThinking, i as normalizeResolvedPricing, l as CLAUDE_OPUS_5_THINKING_PROFILE, m as requiresClaudeDefaultSampling, n as calculateUsageCost, o as readProviderRefusalReview, p as requiresClaudeBetweenToolsThinking, r as normalizeModelCostConfig, s as CLAUDE_FABLE_5_THINKING_PROFILE, u as CLAUDE_SONNET_55_THINKING_PROFILE, v as resolveClaudeMythos5ModelIdentity, w as supportsClaude1MContext, x as resolveClaudeOpus5ModelIdentity, y as resolveClaudeNativeThinkingLevelMap } from "./index-D6KsSE74.mjs";
|
|
2
|
+
import { $ as ThinkingContent, A as ModelCostRates, B as ProviderReplayState, C as KnownImagesApi, E as MaybePromise, F as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, G as SimpleStreamOptions, I as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, K as StopReason, L as PricingTier, M as OpenAICompletionsCompat, N as OpenAIResponsesCompat, P as OpenRouterRouting, Q as ThinkingBudgets, R as Provider, S as KnownApi, T as MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, U as RawModelCostConfig, V as ProviderResponse, W as RawPricingTier, X as TextContent, Y as StreamOptions, Z as TextSignatureV1, _ as ImagesModel, a as AssistantMessage, at as Transport, b as ImagesProvider, c as AssistantMessageEventStreamLike, ct as ValidateToolArgumentsFn, dt as DiagnosticErrorInfo, et as ThinkingLevel, f as ImageContent, ft as appendAssistantMessageDiagnostic, g as ImagesInputContent, gt as isProviderRefusalAssistantError, h as ImagesFunction, ht as formatThrownValue, i as AssistantImages, it as ToolResultMessage, j as ModelThinkingLevel, k as ModelCostConfig, l as CacheRetention, lt as VercelGatewayRouting, m as ImagesContext, mt as extractDiagnosticError, n as Api, nt as Tool, o as AssistantMessageEvent, ot as Usage, p as ImagesApi, pt as createAssistantMessageDiagnostic, q as StreamFn, r as AssistantDeliveryTtsFacts, rt as ToolCall, s as AssistantMessageEventStreamContract, st as UserMessage, t as AnthropicMessagesCompat, tt as ThinkingLevelMap, u as CompleteSimpleFn, ut as AssistantMessageDiagnostic, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as ProviderImagesOptions } from "./types-CLLR3eB4.mjs";
|
|
3
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-DOPFYVqs.mjs";
|
|
4
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-Cat2wQsc.mjs";
|
|
5
|
+
import { a as ProviderContextHandoff, c as ProviderStreamFunction, d as VideoContent, f as resolveProviderContext, i as ProviderContext, l as ProviderStreamOptions, n as ModelInputContent, o as ProviderMessage, r as PROVIDER_CONTEXT_HANDOFF, s as ProviderModel, t as MediaContent, u as ProviderUserMessage } from "./provider-types-d4XnoZMd.mjs";
|
|
6
|
+
export { type AnthropicMessagesCompat, type Api, type AssistantDeliveryTtsFacts, type AssistantImages, type AssistantMessage, type AssistantMessageDiagnostic, type AssistantMessageEvent, type AssistantMessageEventStream, type AssistantMessageEventStreamContract, type AssistantMessageEventStreamLike, type CLAUDE_FABLE_5_THINKING_PROFILE, type CLAUDE_OPUS_55_THINKING_PROFILE, type CLAUDE_OPUS_5_THINKING_PROFILE, type CLAUDE_SONNET_55_THINKING_PROFILE, type CLAUDE_SONNET_5_THINKING_PROFILE, type CacheRetention, type CompleteSimpleFn, type ProviderContext as Context, ProviderContext, type DiagnosticErrorInfo, type EventStream, type ImageContent, type ImagesApi, type ImagesContext, type ImagesFunction, type ImagesInputContent, type ImagesModel, type ImagesOptions, type ImagesOutputContent, type ImagesProvider, type ImagesStopReason, type KnownApi, type KnownImagesApi, type KnownImagesProvider, type MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, type MaybePromise, MediaContent, type ProviderMessage as Message, ProviderMessage, type ProviderModel as Model, ProviderModel, type ModelCostConfig, type ModelCostRates, ModelInputContent, type ModelThinkingLevel, type OpenAICompletionsCompat, type OpenAIResponsesCompat, type OpenRouterRouting, PROVIDER_CONTEXT_HANDOFF, type PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, type PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, type PricingTier, type Provider, ProviderContextHandoff, type ProviderImagesOptions, type ProviderRefusalReview, type ProviderReplayState, type ProviderResponse, ProviderStreamFunction, type ProviderStreamFunction as StreamFunction, ProviderStreamOptions, ProviderUserMessage, type RawModelCostConfig, type RawPricingTier, type SimpleStreamOptions, type StopReason, type StreamFn, type StreamOptions, type TextContent, type TextSignatureV1, type ThinkingBudgets, type ThinkingContent, type ThinkingLevel, type ThinkingLevelMap, type Tool, type ToolCall, type ToolResultMessage, type Transport, type Usage, type UserMessage, type ValidateToolArgumentsFn, type VercelGatewayRouting, VideoContent, type appendAssistantMessageDiagnostic, type bindsClaudeThinkingPrefix, type calculateUsageCost, type createAssistantMessageDiagnostic, type createAssistantMessageEventStream, type extractDiagnosticError, type formatThrownValue, type isProviderRefusalAssistantError, type normalizeModelCostConfig, type normalizeResolvedPricing, type readProviderRefusalReview, type requiresClaudeBetweenToolsThinking, type requiresClaudeDefaultSampling, type requiresClaudeMandatoryAdaptiveThinking, type resolveClaudeFable5ModelIdentity, type resolveClaudeModelIdentity, type resolveClaudeMythos5ModelIdentity, type resolveClaudeNativeThinkingLevelMap, type resolveClaudeOpus55ModelIdentity, type resolveClaudeOpus5ModelIdentity, type resolveClaudeSonnet55ModelIdentity, type resolveClaudeSonnet5ModelIdentity, resolveProviderContext, type supportsClaude1MContext, type supportsClaudeAdaptiveThinking, type supportsClaudeFastMode, type supportsClaudeNativeMaxEffort, type supportsClaudeNativeXhighEffort, type validateToolArguments, type validateToolCall };
|
package/dist/providers.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as ApiRegistry } from "./api-registry-
|
|
2
|
-
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-
|
|
1
|
+
import { n as ApiRegistry } from "./api-registry-D-nbmSqr.mjs";
|
|
2
|
+
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-CouErLh7.mjs";
|
|
3
3
|
//#region packages/ai/src/providers/register-builtins.d.ts
|
|
4
4
|
/** Source id used for built-in API provider registrations. */
|
|
5
5
|
export declare const BUILT_IN_API_PROVIDER_SOURCE_ID = "core:built-in";
|