@openclaw/ai 2026.9.8 → 2026.10.1-beta.1
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/README.md +4 -1
- package/dist/{anthropic-CTXJlfnS.mjs → anthropic-CZv6XFER.mjs} +52 -147
- package/dist/{anthropic-payload-policy-NIPVYXPq.d.mts → anthropic-payload-policy-BhCcgNdm.d.mts} +7 -4
- package/dist/{anthropic-stream-reducer-DrsBCsFY.mjs → anthropic-stream-reducer-BQ1tjd7x.mjs} +369 -233
- package/dist/{api-registry-D-nbmSqr.d.mts → api-registry-DpU0Rj-I.d.mts} +4 -4
- package/dist/{provider-transcript-transform-DjA5Fk2P.mjs → assistant-output-OLm-Oln0.mjs} +17 -17
- package/dist/{assistant-text-phase-C20rxWwP.mjs → assistant-text-phase-Bl1aDCB7.mjs} +2 -8
- package/dist/{azure-openai-responses-BBxv4QVI.mjs → azure-openai-responses-DH7bd3QT.mjs} +12 -17
- package/dist/{azure-openai-responses-client-compat-C7K7QfUE.mjs → azure-openai-responses-client-compat-D0dvJMbZ.mjs} +3 -10
- package/dist/{base64-C1PsYcRQ.mjs → base64-C8CdcsjU.mjs} +3 -45
- package/dist/cloudflare-5qSGvIUH.mjs +39 -0
- package/dist/{diagnostics-CJaB6g8J.mjs → diagnostics-Caj-4RBA.mjs} +19 -37
- package/dist/diagnostics.d.mts +4 -4
- package/dist/diagnostics.mjs +2 -2
- package/dist/{event-stream-vd9UnCAU.mjs → event-stream-C5AbCAaZ.mjs} +29 -1
- package/dist/event-stream-DqDQWqiy.d.mts +1 -0
- package/dist/{event-stream-DOPFYVqs.d.mts → event-stream-DrRM_90c.d.mts} +1 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -1
- package/dist/{github-copilot-request-facts-BTEBMeOv.mjs → github-copilot-request-facts-DEE6gcB9.mjs} +3 -1
- package/dist/{google-B3HEK0Ag.mjs → google-1WLOtb8w.mjs} +12 -9
- package/dist/{google-interactions-vMlEfPAA.mjs → google-interactions-wrnE6MLw.mjs} +39 -49
- package/dist/{google-messages-Dz2dAnGo.mjs → google-messages-BwPPycw6.mjs} +11 -17
- package/dist/{google-shared-B58i3c8H.mjs → google-shared-Eql1OMPU.mjs} +5 -6
- package/dist/{google-vertex-DYFXzEbh.mjs → google-vertex-0LrlRoO3.mjs} +11 -11
- package/dist/{host-rxlNaBwm.d.mts → host-BinBeGcQ.d.mts} +12 -4
- package/dist/{host-DwBmNMCC.mjs → host-DCW52iHe.mjs} +57 -9
- package/dist/{host-policy-wK-ay_RK.mjs → host-policy-B3jc4Rpn.mjs} +9 -2
- package/dist/{index-D6KsSE74.d.mts → index-a8e_oKnu.d.mts} +7 -5
- package/dist/index.d.mts +23 -7
- package/dist/index.mjs +7 -7
- package/dist/internal/anthropic.d.mts +6 -6
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/google-model-family.mjs +1 -1
- 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 +14 -10
- package/dist/internal/openai.mjs +12 -12
- package/dist/internal/runtime.d.mts +18 -9
- package/dist/internal/runtime.mjs +9 -9
- package/dist/internal/shared.d.mts +6 -4
- package/dist/internal/shared.mjs +6 -6
- package/dist/internal/tool-schema.mjs +1 -1
- package/dist/json-schema-Bp07Qui3.mjs +22 -0
- package/dist/{llm-request-activity-BjtkplhG.mjs → llm-request-activity-D8f_oxHj.mjs} +1 -2
- package/dist/{mistral-7wDWcjfF.mjs → mistral-DSt4vQAO.mjs} +18 -29
- package/dist/number-coercion-V8-BhME4.mjs +47 -0
- package/dist/{openai-chatgpt-responses-Bc7NZrQR.mjs → openai-chatgpt-responses-BC2x0Oqx.mjs} +215 -164
- package/dist/openai-completions-DNyHnXKg.mjs +25 -0
- package/dist/{openai-completions-compat-qJjmqQ71.d.mts → openai-completions-compat-BYdYpXhU.d.mts} +3 -3
- package/dist/{openai-completions-compat-BJf57ZxN.mjs → openai-completions-compat-BdmlhD4u.mjs} +30 -23
- package/dist/{openai-completions-stream-dju_5F3P.mjs → openai-completions-transport-DWM2mQDB.mjs} +389 -76
- package/dist/{openai-prompt-cache-CouErLh7.d.mts → openai-prompt-cache-45-AH_xv.d.mts} +2 -2
- package/dist/{openai-prompt-cache-BTMs80_O.mjs → openai-prompt-cache-I8YQTzf8.mjs} +1 -1
- package/dist/{openai-responses-compaction-replay-DiYn-gFM.d.mts → openai-responses-compaction-replay-BClApUIf.d.mts} +4 -4
- package/dist/{openai-responses-compaction-window-CYGCjAQz.mjs → openai-responses-compaction-window-m878aVpU.mjs} +25 -83
- package/dist/{openai-reasoning-effort-C_0p3psG.mjs → openai-responses-contracts-BKu8O7l4.mjs} +103 -4
- package/dist/{openai-responses-contracts-D1iZ0njF.d.mts → openai-responses-contracts-Br5IIw_h.d.mts} +16 -5
- package/dist/openai-responses-prompt-observer-internal-CCg7B6l4.mjs +32 -0
- package/dist/{openai-responses-shared-CIEHiKx7.mjs → openai-responses-shared-C7oVyjED.mjs} +297 -312
- package/dist/{openai-responses-terminal-usage-BE7lf7nW.d.mts → openai-responses-terminal-usage-DgImcyJu.d.mts} +2 -2
- package/dist/{openai-responses-DbPe3-Py.mjs → openai-responses-uZ5oWSp7.mjs} +12 -21
- package/dist/{openai-tool-schema-vsl-cE-n.mjs → openai-tool-schema-DYNePiF8.mjs} +66 -36
- package/dist/{openai-transport-params-DyFJ4cgR.mjs → openai-transport-params-JFsnIyto.mjs} +25 -30
- package/dist/openai-web-search-tools-Cfu0uLyN.mjs +14 -0
- package/dist/{positive-integer-CjN5OJbH.mjs → positive-integer-CwLi8LUL.mjs} +1 -1
- package/dist/{provider-error-CwT_j2v0.mjs → provider-error-DQBE1bUQ.mjs} +17 -28
- package/dist/{provider-options-Df7ov0K1.d.mts → provider-options-D5ABCV_l.d.mts} +2 -2
- package/dist/{provider-replay-context-Bs5aWE1d.mjs → provider-replay-context-C7Bmi84a.mjs} +6 -2
- package/dist/{provider-transport-turn-state-Dw7OtYUs.mjs → provider-transport-turn-state-_M2kLdUE.mjs} +25 -3
- package/dist/{provider-types-d4XnoZMd.d.mts → provider-types-F8Mqc9Ma.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +14 -26
- package/dist/{reasoning-tag-text-partitioner-B6FIIBt6.mjs → reasoning-tag-text-partitioner-Ju9VpUGl.mjs} +23 -37
- package/dist/required-api-key-D4kn3252.mjs +9 -0
- package/dist/sanitize-unicode-CjDG6jJx.d.mts +5 -0
- package/dist/{session-affinity-Bcunsn4I.mjs → session-affinity-DA4WHv1h.mjs} +2 -6
- package/dist/session-resources-D1wgDQ8C.mjs +40 -0
- package/dist/{simple-options-BkDPMuxw.mjs → simple-options-BkKTXxhp.mjs} +7 -11
- package/dist/{src-H4aXcFuX.mjs → src-B0NIt2UK.mjs} +7 -4
- package/dist/stream-DSdzKsDK.mjs +275 -0
- package/dist/{stream-first-event-timeout-B9o0S4SZ.mjs → stream-first-event-timeout-D9ZmL_s9.mjs} +3 -3
- package/dist/{string-coerce-fsri9iCu.mjs → string-coerce-CtgOVOSv.mjs} +5 -1
- package/dist/{string-normalization-J9ZiLfGO.mjs → string-normalization-PN10hf6d.mjs} +1 -1
- package/dist/{transport-utils-CqXzku3R.mjs → text-signature-MLwfi6fq.mjs} +18 -18
- package/dist/{transport-stream-shared-yYhXa4kX.d.mts → transport-stream-shared-BcAKh2XH.d.mts} +6 -19
- package/dist/{transport-stream-shared-BU5pwY6W.mjs → transport-stream-shared-CxXXz_Dd.mjs} +171 -56
- package/dist/transports.d.mts +22 -23
- package/dist/transports.mjs +251 -495
- package/dist/types-BuiEBM3u.d.mts +1 -0
- package/dist/types-CQc6JNG4.mjs +69 -0
- package/dist/{types-CLLR3eB4.d.mts → types-DvzmWW8J.d.mts} +58 -6
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +5 -5
- package/dist/usage-CJH5D6Ea.mjs +19 -0
- package/dist/{validation-Cat2wQsc.d.mts → validation-B3lQt_VE.d.mts} +1 -1
- package/dist/{validation-BFZc40Ig.mjs → validation-DbqlIfDn.mjs} +15 -30
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +4 -4
- package/dist/cache-retention-0x979a5V.mjs +0 -12
- package/dist/event-stream-CMQfX_yr.d.mts +0 -1
- package/dist/github-copilot-headers-B37TB3rB.mjs +0 -30
- package/dist/openai-completions-CHnwIV-W.mjs +0 -188
- package/dist/openai-provider-client-G8Otsq2Q.mjs +0 -24
- package/dist/openai-responses-contracts-CLxnqS9p.mjs +0 -81
- package/dist/openai-responses-prompt-observer-internal-BX3QTNSv.mjs +0 -198
- package/dist/sanitize-unicode-BZiVbGwK.d.mts +0 -24
- package/dist/session-resources-CkR4WWy1.mjs +0 -21
- package/dist/stream-DDsCBgd-.mjs +0 -68
- package/dist/types-CB-_vNyI.d.mts +0 -1
- package/dist/types-LFWwv0cF.mjs +0 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./types-
|
|
1
|
+
import { $ as StopReason, a as AssistantMessage, pt as Usage } from "./types-DvzmWW8J.mjs";
|
|
2
|
+
import "./types-BuiEBM3u.mjs";
|
|
3
3
|
import OpenAI from "openai";
|
|
4
4
|
//#region packages/ai/src/providers/openai-responses-terminal-usage.d.ts
|
|
5
5
|
/** A known output ceiling can resume sampling after admitted tools have settled. */
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
3
|
-
import { n as clampOpenAIPromptCacheKey, r as resolveOpenAIPromptCacheParams } from "./openai-prompt-cache-
|
|
4
|
-
import { i as resolveOpenAICompletionsCompat } from "./openai-completions-compat-
|
|
5
|
-
import {
|
|
6
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
7
|
-
import { g as resolveOpenAISimpleReasoningEffort } from "./openai-transport-params-
|
|
2
|
+
import { t as AssistantMessageEventStream } from "./event-stream-C5AbCAaZ.mjs";
|
|
3
|
+
import { n as clampOpenAIPromptCacheKey, r as resolveOpenAIPromptCacheParams } from "./openai-prompt-cache-I8YQTzf8.mjs";
|
|
4
|
+
import { i as resolveOpenAICompletionsCompat } from "./openai-completions-compat-BdmlhD4u.mjs";
|
|
5
|
+
import { i as resolveCacheRetention, r as buildCopilotDynamicHeaders } from "./cloudflare-5qSGvIUH.mjs";
|
|
6
|
+
import { n as buildBaseOptions } from "./simple-options-BkKTXxhp.mjs";
|
|
7
|
+
import { g as resolveOpenAISimpleReasoningEffort } from "./openai-transport-params-JFsnIyto.mjs";
|
|
8
8
|
import { n as getEnvApiKey } from "./env-api-keys-CyX4VKGO.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import { n as resolveProviderSimpleCompletionHeaders } from "./provider-transport-turn-state-
|
|
11
|
-
import { P as convertProviderResponsesMessages, n as applyResponsesServiceTierPricing, r as runResponsesStreamLifecycle, t as applyCommonResponsesParams } from "./openai-responses-shared-
|
|
12
|
-
import {
|
|
13
|
-
import { t as createOpenAIProviderClient } from "./openai-provider-client-G8Otsq2Q.mjs";
|
|
9
|
+
import { t as createAssistantOutput } from "./assistant-output-OLm-Oln0.mjs";
|
|
10
|
+
import { i as createOpenAIProviderClient, n as resolveProviderSimpleCompletionHeaders } from "./provider-transport-turn-state-_M2kLdUE.mjs";
|
|
11
|
+
import { P as convertProviderResponsesMessages, n as applyResponsesServiceTierPricing, r as runResponsesStreamLifecycle, t as applyCommonResponsesParams } from "./openai-responses-shared-C7oVyjED.mjs";
|
|
12
|
+
import { t as requireApiKey } from "./required-api-key-D4kn3252.mjs";
|
|
14
13
|
//#region packages/ai/src/providers/openai-responses.ts
|
|
15
14
|
var openai_responses_exports = /* @__PURE__ */ __exportAll({
|
|
16
15
|
streamOpenAIResponses: () => streamOpenAIResponses,
|
|
@@ -45,8 +44,7 @@ const streamOpenAIResponses = (model, context, options) => {
|
|
|
45
44
|
return stream;
|
|
46
45
|
};
|
|
47
46
|
const streamSimpleOpenAIResponses = (model, context, options) => {
|
|
48
|
-
const apiKey =
|
|
49
|
-
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
47
|
+
const apiKey = requireApiKey(model.provider, options?.apiKey);
|
|
50
48
|
const base = buildBaseOptions(model, options, apiKey);
|
|
51
49
|
const replayOptions = options;
|
|
52
50
|
return streamOpenAIResponses(model, context, {
|
|
@@ -60,14 +58,7 @@ function createClient(model, context, apiKey, optionsHeaders, sessionId) {
|
|
|
60
58
|
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
61
59
|
const compat = getCompat(model);
|
|
62
60
|
const headers = { ...model.headers };
|
|
63
|
-
if (model.provider === "github-copilot")
|
|
64
|
-
const hasImages = hasCopilotVisionInput(context.messages);
|
|
65
|
-
const copilotHeaders = buildCopilotDynamicHeaders({
|
|
66
|
-
messages: context.messages,
|
|
67
|
-
hasImages
|
|
68
|
-
});
|
|
69
|
-
Object.assign(headers, copilotHeaders);
|
|
70
|
-
}
|
|
61
|
+
if (model.provider === "github-copilot") Object.assign(headers, buildCopilotDynamicHeaders(context.messages));
|
|
71
62
|
if (sessionId) {
|
|
72
63
|
if (compat.sendSessionIdHeader) headers.session_id = sessionId;
|
|
73
64
|
headers["x-client-request-id"] = sessionId;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { t as parseLocalSchemaRefPointer } from "./json-schema-Bp07Qui3.mjs";
|
|
3
|
+
import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-CtgOVOSv.mjs";
|
|
4
|
+
import { i as uniqueValues, t as normalizeStringEntries } from "./string-normalization-PN10hf6d.mjs";
|
|
4
5
|
import { a as SCHEMA_OBJECT_KEYS$1, i as SCHEMA_MAP_KEYS$1, o as evaluateSchemaWalk, r as SCHEMA_ARRAY_KEYS$1 } from "./tool-schema-json-projection-Ct8SeBeJ.mjs";
|
|
5
6
|
//#region packages/ai/src/providers/clean-for-gemini.ts
|
|
6
7
|
const GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS = /* @__PURE__ */ new Set([
|
|
@@ -91,15 +92,11 @@ function extendSchemaDefs$1(defs, schema) {
|
|
|
91
92
|
if (legacyDefsEntry) for (const [key, value] of Object.entries(legacyDefsEntry)) next.set(key, value);
|
|
92
93
|
return next;
|
|
93
94
|
}
|
|
94
|
-
function decodeJsonPointerSegment$1(segment) {
|
|
95
|
-
return segment.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
96
|
-
}
|
|
97
95
|
function tryResolveLocalRef$1(ref, defs) {
|
|
98
96
|
if (!defs) return;
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (!name) return;
|
|
97
|
+
const tokens = parseLocalSchemaRefPointer(ref);
|
|
98
|
+
const [table, name] = tokens ?? [];
|
|
99
|
+
if (tokens?.length !== 2 || table !== "$defs" && table !== "definitions" || !name) return;
|
|
103
100
|
return defs.get(name);
|
|
104
101
|
}
|
|
105
102
|
function simplifyUnionVariants(params) {
|
|
@@ -309,14 +306,10 @@ function extendSchemaDefs(defs, schema) {
|
|
|
309
306
|
if (legacyDefsEntry) for (const [key, value] of Object.entries(legacyDefsEntry)) next.definitions.set(key, value);
|
|
310
307
|
return next;
|
|
311
308
|
}
|
|
312
|
-
function
|
|
313
|
-
return segment.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
314
|
-
}
|
|
315
|
-
function resolveJsonPointerPath(value, segments) {
|
|
309
|
+
function resolveJsonPointerPath(value, tokens) {
|
|
316
310
|
let current = value;
|
|
317
|
-
for (const
|
|
311
|
+
for (const key of tokens) {
|
|
318
312
|
if (!current || typeof current !== "object") return;
|
|
319
|
-
const key = decodeJsonPointerSegment(segment);
|
|
320
313
|
if (Array.isArray(current)) {
|
|
321
314
|
const index = /^(?:0|[1-9]\d*)$/.test(key) ? Number(key) : -1;
|
|
322
315
|
if (index < 0 || index >= current.length) return;
|
|
@@ -329,8 +322,8 @@ function resolveJsonPointerPath(value, segments) {
|
|
|
329
322
|
return current;
|
|
330
323
|
}
|
|
331
324
|
function resolveLocalJsonPointer(rootDocument, ref) {
|
|
332
|
-
|
|
333
|
-
return resolveJsonPointerPath(rootDocument,
|
|
325
|
+
const tokens = parseLocalSchemaRefPointer(ref);
|
|
326
|
+
return tokens ? resolveJsonPointerPath(rootDocument, tokens) : void 0;
|
|
334
327
|
}
|
|
335
328
|
const SCHEMA_MAP_KEYS = /* @__PURE__ */ new Set([
|
|
336
329
|
"$defs",
|
|
@@ -363,14 +356,14 @@ const SCHEMA_LITERAL_KEYS = /* @__PURE__ */ new Set([
|
|
|
363
356
|
"examples"
|
|
364
357
|
]);
|
|
365
358
|
function tryResolveLocalRef(ref, defs, rootDocument) {
|
|
366
|
-
const
|
|
367
|
-
if (
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
const resolved =
|
|
371
|
-
if (resolved !== void 0) return resolveJsonPointerPath(resolved,
|
|
359
|
+
const tokens = parseLocalSchemaRefPointer(ref);
|
|
360
|
+
if (!tokens) return;
|
|
361
|
+
const [table, name, ...remainingPath] = tokens;
|
|
362
|
+
if (defs && name && (table === "$defs" || table === "definitions")) {
|
|
363
|
+
const resolved = (table === "$defs" ? defs.$defs : defs.definitions).get(name);
|
|
364
|
+
if (resolved !== void 0) return resolveJsonPointerPath(resolved, remainingPath);
|
|
372
365
|
}
|
|
373
|
-
return
|
|
366
|
+
return resolveJsonPointerPath(rootDocument, tokens);
|
|
374
367
|
}
|
|
375
368
|
function inlineLocalSchemaRefsWithDefs(schema, defs, refStack, state, rootDocument) {
|
|
376
369
|
if (Array.isArray(schema)) return schema.map((entry) => inlineLocalSchemaRefsWithDefs(entry, defs, refStack, state, rootDocument));
|
|
@@ -382,7 +375,7 @@ function inlineLocalSchemaRefsWithDefs(schema, defs, refStack, state, rootDocume
|
|
|
382
375
|
if (refStack?.has(refValue)) return {};
|
|
383
376
|
const resolved = tryResolveLocalRef(refValue, nextDefs, rootDocument);
|
|
384
377
|
if (resolved === void 0) {
|
|
385
|
-
if (refValue.startsWith("#/")) state.unresolvedLocalRefs = true;
|
|
378
|
+
if (refValue.startsWith("#/") || parseLocalSchemaRefPointer(refValue)) state.unresolvedLocalRefs = true;
|
|
386
379
|
return { ...obj };
|
|
387
380
|
}
|
|
388
381
|
const nextRefStack = refStack ? new Set(refStack) : /* @__PURE__ */ new Set();
|
|
@@ -656,20 +649,32 @@ function resolveToolParameterSchemaCacheKey(options) {
|
|
|
656
649
|
function isGeminiModelId(modelId) {
|
|
657
650
|
return /(?:^|[/:])gemini(?:$|[-/:.])/.test(modelId);
|
|
658
651
|
}
|
|
659
|
-
function extractEnumValues(schema) {
|
|
652
|
+
function extractEnumValues(schema, requireAllVariants = false) {
|
|
660
653
|
if (!schema || typeof schema !== "object") return;
|
|
661
654
|
const record = schema;
|
|
662
655
|
if (Array.isArray(record.enum)) return record.enum;
|
|
663
656
|
if ("const" in record) return [record.const];
|
|
664
657
|
const variants = Array.isArray(record.anyOf) ? record.anyOf : Array.isArray(record.oneOf) ? record.oneOf : null;
|
|
665
658
|
if (variants) {
|
|
659
|
+
let complete = true;
|
|
666
660
|
const values = variants.flatMap((variant) => {
|
|
667
|
-
|
|
661
|
+
const extracted = extractEnumValues(variant, requireAllVariants);
|
|
662
|
+
complete &&= extracted !== void 0;
|
|
663
|
+
return extracted ?? [];
|
|
668
664
|
});
|
|
669
|
-
return values.length > 0 ? values : void 0;
|
|
665
|
+
return (!requireAllVariants || complete) && values.length > 0 ? values : void 0;
|
|
670
666
|
}
|
|
671
667
|
}
|
|
672
|
-
function
|
|
668
|
+
function isUnconstrainedStringSchema(schema) {
|
|
669
|
+
return isRecord(schema) && schema.type === "string" && Object.keys(schema).every((key) => [
|
|
670
|
+
"type",
|
|
671
|
+
"title",
|
|
672
|
+
"description",
|
|
673
|
+
"default",
|
|
674
|
+
"examples"
|
|
675
|
+
].includes(key));
|
|
676
|
+
}
|
|
677
|
+
function mergePropertySchemas(existing, incoming, allowUnconstrainedString) {
|
|
673
678
|
if (!existing) return incoming;
|
|
674
679
|
if (!incoming) return existing;
|
|
675
680
|
const existingEnum = extractEnumValues(existing);
|
|
@@ -686,6 +691,16 @@ function mergePropertySchemas(existing, incoming) {
|
|
|
686
691
|
"default"
|
|
687
692
|
]) if (!(key in merged) && key in record) merged[key] = record[key];
|
|
688
693
|
}
|
|
694
|
+
if (allowUnconstrainedString) {
|
|
695
|
+
if (existingEnum?.every((value) => typeof value === "string") && isUnconstrainedStringSchema(incoming)) return {
|
|
696
|
+
...incoming,
|
|
697
|
+
...merged
|
|
698
|
+
};
|
|
699
|
+
if (incomingEnum?.every((value) => typeof value === "string") && isUnconstrainedStringSchema(existing)) return {
|
|
700
|
+
...existing,
|
|
701
|
+
...merged
|
|
702
|
+
};
|
|
703
|
+
}
|
|
689
704
|
const types = new Set(values.map((value) => typeof value));
|
|
690
705
|
if (types.size === 1) merged.type = Array.from(types)[0];
|
|
691
706
|
merged.enum = values;
|
|
@@ -869,7 +884,9 @@ function normalizeToolParameterSchemaUncached(schema, options) {
|
|
|
869
884
|
properties: {}
|
|
870
885
|
} : inlinedSchema);
|
|
871
886
|
const variants = schemaRecord[flattenableVariantKey];
|
|
872
|
-
const
|
|
887
|
+
const rootProperties = isRecord(schemaRecord.properties) ? schemaRecord.properties : {};
|
|
888
|
+
const mergedProperties = { ...rootProperties };
|
|
889
|
+
const propertyAlternatives = /* @__PURE__ */ new Map();
|
|
873
890
|
const requiredCounts = /* @__PURE__ */ new Map();
|
|
874
891
|
let objectVariants = 0;
|
|
875
892
|
for (const entry of variants) {
|
|
@@ -877,13 +894,23 @@ function normalizeToolParameterSchemaUncached(schema, options) {
|
|
|
877
894
|
const props = entry.properties;
|
|
878
895
|
if (!props || typeof props !== "object") continue;
|
|
879
896
|
objectVariants += 1;
|
|
880
|
-
for (const [key, value] of Object.entries(props))
|
|
897
|
+
for (const [key, value] of Object.entries(props)) {
|
|
898
|
+
const alternatives = propertyAlternatives.get(key);
|
|
899
|
+
if (alternatives) alternatives.push(value);
|
|
900
|
+
else propertyAlternatives.set(key, [value]);
|
|
901
|
+
}
|
|
881
902
|
const required = Array.isArray(entry.required) ? entry.required : [];
|
|
882
903
|
for (const key of required) {
|
|
883
904
|
if (typeof key !== "string") continue;
|
|
884
905
|
requiredCounts.set(key, (requiredCounts.get(key) ?? 0) + 1);
|
|
885
906
|
}
|
|
886
907
|
}
|
|
908
|
+
for (const [key, alternatives] of propertyAlternatives) {
|
|
909
|
+
const allowUnconstrainedString = !Object.hasOwn(rootProperties, key) && alternatives.every((alternative) => isUnconstrainedStringSchema(alternative) || extractEnumValues(alternative, true)?.every((value) => typeof value === "string") === true);
|
|
910
|
+
let merged = Object.hasOwn(mergedProperties, key) ? mergedProperties[key] : void 0;
|
|
911
|
+
for (const alternative of alternatives) merged = mergePropertySchemas(merged, alternative, allowUnconstrainedString);
|
|
912
|
+
setOwnSchemaProperty(mergedProperties, key, merged);
|
|
913
|
+
}
|
|
887
914
|
const baseRequired = Array.isArray(schemaRecord.required) ? schemaRecord.required.filter((key) => typeof key === "string") : void 0;
|
|
888
915
|
const mergedRequired = baseRequired && baseRequired.length > 0 ? baseRequired : objectVariants > 0 ? Array.from(requiredCounts.entries()).filter(([, count]) => count === objectVariants).map(([key]) => key) : void 0;
|
|
889
916
|
return applyProviderCleaning({
|
|
@@ -1037,11 +1064,14 @@ function resolveStrictOpenAISchemaCacheKey(modelCompat) {
|
|
|
1037
1064
|
/** Normalizes a tool parameter schema into the OpenAI strict JSON-schema subset. */
|
|
1038
1065
|
function normalizeStrictOpenAIJsonSchema(schema, modelCompat) {
|
|
1039
1066
|
const schemaInput = schema ?? {};
|
|
1040
|
-
|
|
1041
|
-
const cacheKey = resolveStrictOpenAISchemaCacheKey(modelCompat);
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1067
|
+
const cacheable = typeof schemaInput === "object";
|
|
1068
|
+
const cacheKey = cacheable ? resolveStrictOpenAISchemaCacheKey(modelCompat) : "";
|
|
1069
|
+
if (cacheable) {
|
|
1070
|
+
const cached = strictOpenAISchemaCache.get(schemaInput, cacheKey);
|
|
1071
|
+
if (cached !== void 0) return cached;
|
|
1072
|
+
}
|
|
1073
|
+
const normalized = normalizeStrictOpenAIJsonSchemaRecursive(normalizeToolParameterSchema(schemaInput, { modelCompat: resolveToolSchemaModelCompat(modelCompat) }), 0);
|
|
1074
|
+
return cacheable ? strictOpenAISchemaCache.remember(schemaInput, cacheKey, normalized) : normalized;
|
|
1045
1075
|
}
|
|
1046
1076
|
function normalizeStrictOpenAIJsonSchemaRecursive(schema, depth) {
|
|
1047
1077
|
if (Array.isArray(schema)) {
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { o as isRecord, r as asOptionalObjectRecord } from "./record-coerce-CNDovvft.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-
|
|
6
|
-
import { i as isCodeModeModelVisibleToolName } from "./
|
|
7
|
-
import { i as resolveOpenAICompletionsCompat, o as usesNativeOpenAICodexResponsesBackend } from "./openai-completions-compat-
|
|
8
|
-
import {
|
|
9
|
-
import { m as notifyProviderHttpResponse } from "./transport-stream-shared-
|
|
2
|
+
import { a as normalizeOptionalString, n as normalizeLowercaseStringOrEmpty } from "./string-coerce-CtgOVOSv.mjs";
|
|
3
|
+
import { D as applyProviderReportedUsageCost, E as headersToRecord, O as calculateCost, k as clampThinkingLevel, r as getAiTransportHost } from "./host-DCW52iHe.mjs";
|
|
4
|
+
import { A as resolveOpenAIThinkingApi, C as resolveOpenAIReasoningEffortForModel, E as supportsOpenAIReasoningEffort, O as MODEL_CATALOG_THINKING_LEVELS, S as resolveOpenAIModelReasoningEfforts, i as OPENAI_RESPONSES_APIS, w as resolveOpenAIReasoningEffortMapping, x as normalizeOpenAIReasoningEffort } from "./openai-responses-contracts-BKu8O7l4.mjs";
|
|
5
|
+
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-I8YQTzf8.mjs";
|
|
6
|
+
import { i as isCodeModeModelVisibleToolName } from "./text-signature-MLwfi6fq.mjs";
|
|
7
|
+
import { i as resolveOpenAICompletionsCompat, o as usesNativeOpenAICodexResponsesBackend } from "./openai-completions-compat-BdmlhD4u.mjs";
|
|
8
|
+
import { r as resolveModelRequestTimeoutMs } from "./host-policy-B3jc4Rpn.mjs";
|
|
9
|
+
import { m as notifyProviderHttpResponse } from "./transport-stream-shared-CxXXz_Dd.mjs";
|
|
10
10
|
import { n as projectRuntimeToolInputSchema, t as prepareRuntimeToolInputSchema } from "./tool-schema-json-projection-Ct8SeBeJ.mjs";
|
|
11
|
-
import { n as resolveOpencodeSessionHeaders } from "./session-affinity-
|
|
12
|
-
import { a as resolveOpenAIProjectedToolsStrictToolFlag, t as findOpenAIStrictToolProjectionDiagnostics } from "./openai-tool-schema-
|
|
13
|
-
import { i as OPENAI_RESPONSES_APIS } from "./openai-responses-contracts-CLxnqS9p.mjs";
|
|
11
|
+
import { n as resolveOpencodeSessionHeaders } from "./session-affinity-DA4WHv1h.mjs";
|
|
12
|
+
import { a as resolveOpenAIProjectedToolsStrictToolFlag, t as findOpenAIStrictToolProjectionDiagnostics } from "./openai-tool-schema-DYNePiF8.mjs";
|
|
14
13
|
import { hash } from "node:crypto";
|
|
15
14
|
//#region packages/normalization-core/src/node-crypto.ts
|
|
16
15
|
function sha256Hex(input) {
|
|
@@ -28,7 +27,6 @@ function redactIdentifier(value, opts) {
|
|
|
28
27
|
}
|
|
29
28
|
//#endregion
|
|
30
29
|
//#region packages/ai/src/transports/openai-transport-shared.ts
|
|
31
|
-
/** Shared options, usage shape, cache identity, and ordering for OpenAI APIs. */
|
|
32
30
|
const OPENAI_RESPONSE_MODEL_HEADER_NAMES = /* @__PURE__ */ new Set(["openai-model", "x-openai-model"]);
|
|
33
31
|
const OPENAI_RESPONSE_MODEL_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
34
32
|
"response.created",
|
|
@@ -122,12 +120,7 @@ function resolveOpenAIClientBaseUrl(model, baseUrl = model.baseUrl) {
|
|
|
122
120
|
if (model.provider.trim().toLowerCase() === "openai") return;
|
|
123
121
|
throw new Error(`Provider "${model.provider}" requires an explicit base URL before using an OpenAI-compatible API. Reload provider metadata or configure an endpoint.`);
|
|
124
122
|
}
|
|
125
|
-
const EMPTY_OPENAI_COMPLETIONS_REASONING_BATCH =
|
|
126
|
-
deltas: [],
|
|
127
|
-
mirroredThinking: [],
|
|
128
|
-
hasThinking: false,
|
|
129
|
-
hasVisibleText: false
|
|
130
|
-
};
|
|
123
|
+
const EMPTY_OPENAI_COMPLETIONS_REASONING_BATCH = createOpenAICompletionsReasoningBatch();
|
|
131
124
|
const OPENAI_COMPLETIONS_REASONING_FIELDS = [
|
|
132
125
|
"reasoning_content",
|
|
133
126
|
"reasoning",
|
|
@@ -137,22 +130,13 @@ function appendOpenAICompletionsReasoningDelta(batch, next) {
|
|
|
137
130
|
if (next.kind === "thinking") batch.hasThinking = true;
|
|
138
131
|
else batch.hasVisibleText = true;
|
|
139
132
|
const previous = batch.deltas[batch.deltas.length - 1];
|
|
140
|
-
if (!previous || previous.kind !== next.kind) {
|
|
133
|
+
if (!previous || previous.kind !== next.kind || next.kind === "thinking" && previous.kind === "thinking" && previous.signature !== next.signature) {
|
|
141
134
|
batch.deltas.push(next);
|
|
142
135
|
if (next.kind === "thinking") batch.mirroredThinking.push(next.text);
|
|
143
136
|
return;
|
|
144
137
|
}
|
|
145
|
-
if (next.kind === "thinking" && previous.kind === "thinking") {
|
|
146
|
-
if (previous.signature !== next.signature) {
|
|
147
|
-
batch.deltas.push(next);
|
|
148
|
-
batch.mirroredThinking.push(next.text);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
previous.text += next.text;
|
|
152
|
-
batch.mirroredThinking[batch.mirroredThinking.length - 1] += next.text;
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
138
|
previous.text += next.text;
|
|
139
|
+
if (next.kind === "thinking") batch.mirroredThinking[batch.mirroredThinking.length - 1] += next.text;
|
|
156
140
|
}
|
|
157
141
|
function createOpenAICompletionsReasoningBatch() {
|
|
158
142
|
return {
|
|
@@ -209,12 +193,24 @@ function parseOpenAICompletionsUsage(rawUsage, model, options) {
|
|
|
209
193
|
const input = Math.max(0, (rawUsage.prompt_tokens || 0) - cacheRead - cacheWrite);
|
|
210
194
|
const output = rawUsage.completion_tokens || 0;
|
|
211
195
|
const reasoningTokens = rawUsage.completion_tokens_details?.reasoning_tokens;
|
|
196
|
+
const hasCoherentContext = [
|
|
197
|
+
rawUsage.prompt_tokens,
|
|
198
|
+
rawUsage.completion_tokens,
|
|
199
|
+
rawUsage.total_tokens,
|
|
200
|
+
cacheRead,
|
|
201
|
+
cacheWrite
|
|
202
|
+
].every((value) => typeof value === "number" && Number.isFinite(value) && value >= 0) && rawUsage.prompt_tokens >= cacheRead + cacheWrite && rawUsage.total_tokens >= rawUsage.prompt_tokens + rawUsage.completion_tokens;
|
|
212
203
|
const usage = {
|
|
213
204
|
input,
|
|
214
205
|
output,
|
|
215
206
|
cacheRead,
|
|
216
207
|
cacheWrite,
|
|
217
208
|
...options?.includeReasoningTokens !== false && typeof reasoningTokens === "number" && Number.isFinite(reasoningTokens) ? { reasoningTokens } : {},
|
|
209
|
+
contextUsage: hasCoherentContext ? {
|
|
210
|
+
state: "available",
|
|
211
|
+
promptTokens: rawUsage.prompt_tokens,
|
|
212
|
+
totalTokens: Math.max(input + output + cacheRead + cacheWrite, rawUsage.total_tokens)
|
|
213
|
+
} : { state: "unavailable" },
|
|
218
214
|
totalTokens: input + output + cacheRead + cacheWrite,
|
|
219
215
|
cost: {
|
|
220
216
|
input: 0,
|
|
@@ -728,7 +724,6 @@ function getCompat(model) {
|
|
|
728
724
|
const compat = model.compat ?? {};
|
|
729
725
|
return {
|
|
730
726
|
...resolved,
|
|
731
|
-
cacheControlFormat: resolved.cacheControlFormat,
|
|
732
727
|
reasoningEffortMap: resolveOpenAIReasoningEffortMap(model, {}),
|
|
733
728
|
openRouterRouting: resolved.openRouterRouting ?? {},
|
|
734
729
|
vercelGatewayRouting: resolved.vercelGatewayRouting,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
|
|
2
|
+
//#region packages/ai/src/providers/openai-web-search-tools.ts
|
|
3
|
+
function hasResponsesWebSearchTool(tools) {
|
|
4
|
+
if (!Array.isArray(tools)) return false;
|
|
5
|
+
return tools.some((tool) => {
|
|
6
|
+
if (!isRecord(tool)) return false;
|
|
7
|
+
if (tool.type === "web_search") return true;
|
|
8
|
+
if (tool.type === "function" && tool.name === "web_search") return true;
|
|
9
|
+
const fn = tool.function;
|
|
10
|
+
return isRecord(fn) && fn.name === "web_search";
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { hasResponsesWebSearchTool as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as parseStrictPositiveInteger } from "./
|
|
1
|
+
import { o as parseStrictPositiveInteger } from "./number-coercion-V8-BhME4.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,9 @@
|
|
|
1
1
|
import { i as asOptionalRecord } from "./record-coerce-CNDovvft.mjs";
|
|
2
|
-
import { o as normalizeStringifiedOptionalString } from "./string-coerce-
|
|
2
|
+
import { o as normalizeStringifiedOptionalString } from "./string-coerce-CtgOVOSv.mjs";
|
|
3
|
+
import "./number-coercion-V8-BhME4.mjs";
|
|
3
4
|
import { t as expectDefined } from "./expect-lbe3Hgrh.mjs";
|
|
4
|
-
import { n as estimateBase64DecodedBytes } from "./base64-C1PsYcRQ.mjs";
|
|
5
5
|
import { parseRetryAfterErrorSeconds, parseRetryAfterHeadersSeconds } from "./internal/retry-after.mjs";
|
|
6
|
+
import { n as estimateBase64DecodedBytes } from "./base64-C8CdcsjU.mjs";
|
|
6
7
|
//#region packages/normalization-core/src/balanced-json.ts
|
|
7
8
|
function isJsonOpeningDelimiter(char, openers) {
|
|
8
9
|
return (char === "{" || char === "[") && openers.includes(char);
|
|
@@ -143,42 +144,30 @@ function stringifyObjectValue(value, stack, normalizeString, write) {
|
|
|
143
144
|
return `[${serializedEntries.join(",")}]`;
|
|
144
145
|
}
|
|
145
146
|
const record = value;
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
}
|
|
159
|
-
let fieldIndex = 0;
|
|
160
|
-
for (const key of fields) fields[fieldIndex++] = `${JSON.stringify(key)}:${stringifyStableValue(record[key], stack, normalizeString)}`;
|
|
161
|
-
return `{${fields.join(",")}}`;
|
|
162
|
-
}
|
|
163
|
-
const entries = Object.keys(record).map((key) => ({
|
|
147
|
+
const keys = Object.keys(record);
|
|
148
|
+
const fields = normalizeString === preserveString ? keys.sort() : keys.map((key) => ({
|
|
164
149
|
key,
|
|
165
150
|
normalizedKey: normalizeString(key)
|
|
166
151
|
})).sort((left, right) => {
|
|
167
152
|
return compareStableStrings(left.normalizedKey, right.normalizedKey) || compareStableStrings(left.key, right.key);
|
|
168
153
|
});
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
154
|
+
write?.("{");
|
|
155
|
+
const serializedFields = normalizeString === preserveString ? keys : [];
|
|
156
|
+
let separator = "";
|
|
157
|
+
let fieldIndex = 0;
|
|
158
|
+
for (const field of fields) {
|
|
159
|
+
const key = typeof field === "string" ? field : field.key;
|
|
160
|
+
const prefix = `${JSON.stringify(typeof field === "string" ? field : field.normalizedKey)}:`;
|
|
161
|
+
if (write) {
|
|
162
|
+
write(`${separator}${prefix}`);
|
|
175
163
|
write(stringifyStableValue(record[key], stack, normalizeString, write));
|
|
176
164
|
separator = ",";
|
|
177
|
-
}
|
|
165
|
+
} else serializedFields[fieldIndex++] = `${prefix}${stringifyStableValue(record[key], stack, normalizeString)}`;
|
|
166
|
+
}
|
|
167
|
+
if (write) {
|
|
178
168
|
write("}");
|
|
179
169
|
return "";
|
|
180
170
|
}
|
|
181
|
-
for (const { key, normalizedKey } of entries) serializedFields.push(`${JSON.stringify(normalizedKey)}:${stringifyStableValue(record[key], stack, normalizeString)}`);
|
|
182
171
|
return `{${serializedFields.join(",")}}`;
|
|
183
172
|
}
|
|
184
173
|
function encodeBase64(value) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nt as StreamOptions } from "./types-DvzmWW8J.mjs";
|
|
2
2
|
import { t as OpenAICompletionsToolChoice } from "./openai-tool-projection-793cE3QX.mjs";
|
|
3
|
-
import "./types-
|
|
3
|
+
import "./types-BuiEBM3u.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"];
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
|
|
2
|
+
import { A as shortHash } from "./transport-stream-shared-CxXXz_Dd.mjs";
|
|
2
3
|
//#region packages/ai/src/transports/provider-replay-context.ts
|
|
4
|
+
function isProviderReplayContext(value) {
|
|
5
|
+
return isRecord(value) && typeof value.provider === "string" && typeof value.api === "string" && typeof value.model === "string" && (value.baseUrlHash === void 0 || typeof value.baseUrlHash === "string") && (value.sessionHash === void 0 || typeof value.sessionHash === "string") && (value.authProfileHash === void 0 || typeof value.authProfileHash === "string");
|
|
6
|
+
}
|
|
3
7
|
function hashReplayContextValue(value) {
|
|
4
8
|
const normalized = value?.trim();
|
|
5
9
|
return normalized ? shortHash(normalized) : void 0;
|
|
@@ -18,4 +22,4 @@ function providerReplayContextMatches(state, context) {
|
|
|
18
22
|
return state.provider === context.provider && state.api === context.api && state.model === context.model && state.baseUrlHash === context.baseUrlHash && state.sessionHash === context.sessionHash && state.authProfileHash === context.authProfileHash;
|
|
19
23
|
}
|
|
20
24
|
//#endregion
|
|
21
|
-
export {
|
|
25
|
+
export { isProviderReplayContext as n, providerReplayContextMatches as r, buildProviderReplayContext as t };
|
|
@@ -1,6 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
1
|
+
import { r as getAiTransportHost } from "./host-DCW52iHe.mjs";
|
|
2
|
+
import { n as resolveCloudflareBaseUrl, t as isCloudflareProvider } from "./cloudflare-5qSGvIUH.mjs";
|
|
3
|
+
import { O as resolveOpenAIClientBaseUrl } from "./openai-transport-params-JFsnIyto.mjs";
|
|
4
|
+
import { n as resolveOpencodeSessionHeaders, t as hasOpencodeSessionHeader } from "./session-affinity-DA4WHv1h.mjs";
|
|
3
5
|
import { randomUUID } from "node:crypto";
|
|
6
|
+
import OpenAI from "openai";
|
|
7
|
+
//#region packages/ai/src/providers/openai-provider-client.ts
|
|
8
|
+
function createOpenAIProviderClient(model, apiKey, headers, optionsHeaders) {
|
|
9
|
+
if (optionsHeaders) Object.assign(headers, optionsHeaders);
|
|
10
|
+
const defaultHeaders = model.provider === "cloudflare-ai-gateway" ? {
|
|
11
|
+
...headers,
|
|
12
|
+
Authorization: headers.Authorization ?? null,
|
|
13
|
+
"cf-aig-authorization": `Bearer ${apiKey}`
|
|
14
|
+
} : headers;
|
|
15
|
+
const baseUrl = isCloudflareProvider(model.provider) ? resolveCloudflareBaseUrl(model) : model.baseUrl;
|
|
16
|
+
return new OpenAI({
|
|
17
|
+
apiKey,
|
|
18
|
+
baseURL: resolveOpenAIClientBaseUrl(model, baseUrl),
|
|
19
|
+
dangerouslyAllowBrowser: true,
|
|
20
|
+
defaultHeaders,
|
|
21
|
+
maxRetries: 0,
|
|
22
|
+
fetch: getAiTransportHost().buildModelFetch(model)
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
4
26
|
//#region packages/ai/src/transports/provider-transport-turn-state.ts
|
|
5
27
|
function resolveProviderTransportTurnState(model, params) {
|
|
6
28
|
const normalizedProvider = model.provider.trim().toLowerCase();
|
|
@@ -39,4 +61,4 @@ function resolveProviderSimpleCompletionHeaders(model, options) {
|
|
|
39
61
|
};
|
|
40
62
|
}
|
|
41
63
|
//#endregion
|
|
42
|
-
export { resolveProviderSimpleCompletionHeaders as n, resolveProviderTransportTurnState as r, filterProviderTurnHeadersForExplicitOpencodeSession as t };
|
|
64
|
+
export { createOpenAIProviderClient as i, resolveProviderSimpleCompletionHeaders as n, resolveProviderTransportTurnState as r, filterProviderTurnHeadersForExplicitOpencodeSession as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as index_d_exports } from "./index-
|
|
2
|
-
import {
|
|
3
|
-
import "./types-
|
|
1
|
+
import { t as index_d_exports } from "./index-a8e_oKnu.mjs";
|
|
2
|
+
import { a as AssistantMessage, d as Context, dt as ToolResultMessage, k as Model, mt as UserMessage, n as Api, nt as StreamOptions, p as ImageContent, rt as TextContent, s as AssistantMessageEventStreamContract } from "./types-DvzmWW8J.mjs";
|
|
3
|
+
import "./types-BuiEBM3u.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 { C as resolveClaudeSonnet5ModelIdentity, D as
|
|
2
|
-
import { $ as
|
|
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_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 };
|
|
1
|
+
import { C as resolveClaudeSonnet5ModelIdentity, D as supportsClaudeInHistorySystemMessages, E as supportsClaudeFastMode, O as supportsClaudeNativeMaxEffort, 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, k as supportsClaudeNativeXhighEffort, 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-a8e_oKnu.mjs";
|
|
2
|
+
import { $ as StopReason, A as ModelCostConfig, At as extractDiagnosticError, B as ProviderImagesOptions, C as KnownApi, Ct as readRuntimeContextMetadata, D as MaybePromise, Dt as DiagnosticErrorInfo, E as MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, Et as AssistantMessageDiagnostic, F as OpenRouterRouting, G as RUNTIME_CONTEXT_CUSTOM_TYPE, H as ProviderResponse, I as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, J as RUNTIME_CONTEXT_HEADER, K as RUNTIME_CONTEXT_END_MARKER, L as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, M as ModelThinkingLevel, Mt as isProviderRefusalAssistantError, N as OpenAICompletionsCompat, Ot as appendAssistantMessageDiagnostic, P as OpenAIResponsesCompat, Q as SimpleStreamOptions, R as PricingTier, S as ImagesStopReason, St as labelRuntimeContextText, T as KnownImagesProvider, Tt as setRuntimeContextRetention, V as ProviderReplayState, W as RUNTIME_CONTEXT_BEGIN_MARKER, X as RawPricingTier, Y as RawModelCostConfig, Z as RuntimeContextMessage, _ as ImagesInputContent, _t as escapeRuntimeContextFooter, a as AssistantMessage, at as ThinkingBudgets, b as ImagesOutputContent, bt as isRuntimeContextMessage, c as AssistantMessageEventStreamLike, ct as ThinkingLevelMap, dt as ToolResultMessage, et as StreamFn, f as DEFAULT_MISSING_TOOL_RESULT_TEXT, ft as Transport, g as ImagesFunction, gt as VercelGatewayRouting, h as ImagesContext, ht as ValidateToolArgumentsFn, i as AssistantImages, it as TextSignatureV1, j as ModelCostRates, jt as formatThrownValue, kt as createAssistantMessageDiagnostic, l as CacheRetention, lt as Tool, m as ImagesApi, mt as UserMessage, n as Api, nt as StreamOptions, o as AssistantMessageEvent, ot as ThinkingContent, p as ImageContent, pt as Usage, q as RUNTIME_CONTEXT_FOOTER, r as AssistantDeliveryTtsFacts, rt as TextContent, s as AssistantMessageEventStreamContract, st as ThinkingLevel, t as AnthropicMessagesCompat, u as CompleteSimpleFn, ut as ToolCall, v as ImagesModel, vt as hasLegacyRuntimeContextEnvelope, w as KnownImagesApi, wt as runtimeContextContentToText, x as ImagesProvider, xt as labelRuntimeContextContent, y as ImagesOptions, yt as hasRuntimeContextMarker, z as Provider } from "./types-DvzmWW8J.mjs";
|
|
3
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-DrRM_90c.mjs";
|
|
4
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-B3lQt_VE.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-F8Mqc9Ma.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 DEFAULT_MISSING_TOOL_RESULT_TEXT, 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 RUNTIME_CONTEXT_BEGIN_MARKER, type RUNTIME_CONTEXT_CUSTOM_TYPE, type RUNTIME_CONTEXT_END_MARKER, type RUNTIME_CONTEXT_FOOTER, type RUNTIME_CONTEXT_HEADER, type RawModelCostConfig, type RawPricingTier, type RuntimeContextMessage, 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 escapeRuntimeContextFooter, type extractDiagnosticError, type formatThrownValue, type hasLegacyRuntimeContextEnvelope, type hasRuntimeContextMarker, type isProviderRefusalAssistantError, type isRuntimeContextMessage, type labelRuntimeContextContent, type labelRuntimeContextText, type normalizeModelCostConfig, type normalizeResolvedPricing, type readProviderRefusalReview, type readRuntimeContextMetadata, type requiresClaudeBetweenToolsThinking, type requiresClaudeDefaultSampling, type requiresClaudeMandatoryAdaptiveThinking, type resolveClaudeFable5ModelIdentity, type resolveClaudeModelIdentity, type resolveClaudeMythos5ModelIdentity, type resolveClaudeNativeThinkingLevelMap, type resolveClaudeOpus55ModelIdentity, type resolveClaudeOpus5ModelIdentity, type resolveClaudeSonnet55ModelIdentity, type resolveClaudeSonnet5ModelIdentity, resolveProviderContext, type runtimeContextContentToText, type setRuntimeContextRetention, type supportsClaude1MContext, type supportsClaudeAdaptiveThinking, type supportsClaudeFastMode, type supportsClaudeInHistorySystemMessages, 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-DpU0Rj-I.mjs";
|
|
2
|
+
import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-45-AH_xv.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";
|