@openclaw/ai 2026.9.2 → 2026.9.3
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 +3 -2
- package/dist/anthropic-CZy5U0NY.mjs +376 -0
- package/dist/{anthropic-payload-policy-d46X2pR0.d.mts → anthropic-payload-policy-wuRCb6MH.d.mts} +16 -6
- package/dist/{anthropic-compaction-replay-DB2FGLQc.mjs → anthropic-stream-reducer-B_yo_7pf.mjs} +923 -181
- package/dist/{api-registry-DWtPjzyn.d.mts → api-registry-CB1-1oQ2.d.mts} +2 -2
- package/dist/assistant-output-iqnlJCV2.mjs +16 -0
- package/dist/assistant-text-phase-C20rxWwP.mjs +55 -0
- package/dist/{azure-openai-responses-C5bZRfAP.mjs → azure-openai-responses-Crpa40QR.mjs} +5 -5
- package/dist/{base64-CEFBpSkN.mjs → base64-D-su8YVo.mjs} +1 -27
- package/dist/{diagnostics-DfFyKeX_.mjs → diagnostics-dV98PqIy.mjs} +96 -21
- package/dist/diagnostics.d.mts +3 -1
- package/dist/diagnostics.mjs +3 -3
- package/dist/{event-stream-BhT5T1Ay.d.mts → event-stream-C1Z2piyk.d.mts} +11 -3
- package/dist/{event-stream-BgDvQeum.mjs → event-stream-D8PARQfL.mjs} +45 -1
- package/dist/event-stream-I_GlBsuZ.d.mts +1 -0
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -1
- package/dist/{github-copilot-headers-NCJtz9i0.mjs → github-copilot-headers-B37TB3rB.mjs} +3 -10
- package/dist/github-copilot-request-facts-BTEBMeOv.mjs +16 -0
- package/dist/{google-4qeuE8iX.mjs → google-BDPriaVe.mjs} +10 -10
- package/dist/google-messages-CVn9eFpF.mjs +449 -0
- package/dist/google-shared-BedY23XS.mjs +185 -0
- package/dist/{google-vertex-O9BcnB6X.mjs → google-vertex-DMz8XQCn.mjs} +7 -6
- package/dist/{host-CEvLw30U.mjs → host-CWuF-sS3.mjs} +44 -39
- package/dist/{host-DjzGmdZ2.d.mts → host-DK3wmS3e.d.mts} +3 -3
- package/dist/host-policy-CAopLRKA.mjs +37 -0
- package/dist/{index-FnHM2FcI.d.mts → index-CQ6LTHw8.d.mts} +3 -3
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/dist/internal/anthropic.d.mts +7 -7
- package/dist/internal/anthropic.mjs +4 -4
- package/dist/internal/google-model-family.d.mts +5 -0
- package/dist/internal/google-model-family.mjs +15 -0
- package/dist/internal/openai-responses-payload-policy.d.mts +1 -1
- package/dist/internal/openai-responses-payload-policy.mjs +1 -1
- package/dist/internal/openai.d.mts +8 -103
- package/dist/internal/openai.mjs +10 -10
- package/dist/internal/retry-after.d.mts +2 -4
- package/dist/internal/retry-after.mjs +57 -8
- package/dist/internal/runtime.d.mts +7 -6
- package/dist/internal/runtime.mjs +8 -7
- package/dist/internal/shared.d.mts +14 -3
- package/dist/internal/shared.mjs +6 -4
- package/dist/internal/tool-schema.d.mts +63 -0
- package/dist/internal/tool-schema.mjs +3 -0
- package/dist/{json-parse-BuAJEbdW.mjs → json-parse-Dw_hnxsA.mjs} +1 -1
- package/dist/{mistral-Tb6oalqH.mjs → mistral--m-Jm6VZ.mjs} +13 -37
- package/dist/model-transport-url-DKocrEsb.d.mts +28 -0
- package/dist/{openai-chatgpt-responses-yUXjPNfu.mjs → openai-chatgpt-responses-nDZccFW-.mjs} +48 -38
- package/dist/openai-completions-KuoZyx0d.mjs +187 -0
- package/dist/{openai-completions-compat-CpjYUArk.d.mts → openai-completions-compat-CXn3T1we.d.mts} +26 -4
- package/dist/{openai-completions-stream-BsrBe3Gg.mjs → openai-completions-stream-BQk3SkLD.mjs} +622 -452
- package/dist/openai-prompt-cache-BI0rkM-5.mjs +220 -0
- package/dist/openai-prompt-cache-rrutvqxq.d.mts +16 -0
- package/dist/openai-provider-client-ha_WxTyj.mjs +24 -0
- package/dist/openai-reasoning-effort-BK7FbcLT.mjs +167 -0
- package/dist/{openai-responses-CCL41ALM.mjs → openai-responses-D99dOzKI.mjs} +14 -29
- package/dist/{openai-responses-compaction-window-BMVHFOtq.mjs → openai-responses-compaction-window-D5jbzCi3.mjs} +7 -170
- package/dist/{openai-responses-contracts-rF5DDRNS.d.mts → openai-responses-contracts-B55afwRo.d.mts} +3 -3
- package/dist/{openai-responses-prompt-observer-internal-D0bhBfgL.mjs → openai-responses-prompt-observer-internal-tApyTLVu.mjs} +3 -3
- package/dist/{openai-responses-shared-Bmma_3Qc.mjs → openai-responses-shared-ZyQEzS5i.mjs} +44 -115
- package/dist/openai-tool-projection-793cE3QX.d.mts +37 -0
- package/dist/{openai-tool-schema-_pTAJqKF.mjs → openai-tool-schema-CzjyYXun.mjs} +38 -556
- package/dist/openai-tool-schema-ynZBgqW-.d.mts +38 -0
- package/dist/openai-transport-params-DNasp2fU.mjs +674 -0
- package/dist/{provider-error-9TraxGvt.mjs → provider-error-C6TbKiey.mjs} +23 -6
- package/dist/{provider-options-Bcc_p-TU.d.mts → provider-options-BXr9Ec83.d.mts} +4 -39
- package/dist/{provider-transcript-transform-BaMbI1hr.mjs → provider-transcript-transform-pPmUIwKt.mjs} +1 -1
- package/dist/provider-types-CAV0Og3m.d.mts +29 -0
- package/dist/provider-types.d.mts +6 -31
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +11 -11
- package/dist/{reasoning-tag-text-partitioner-DLCNXki6.mjs → reasoning-tag-text-partitioner-BQBi4B9d.mjs} +19 -12
- package/dist/record-coerce-DwRYMj3t.mjs +32 -0
- package/dist/retry-after-CdCURCVg.d.mts +15 -0
- package/dist/{sanitize-unicode-D6xUvZaS.mjs → sanitize-unicode-Bb-v9meu.mjs} +1 -1
- package/dist/session-affinity-CCH7eYdB.mjs +20 -0
- package/dist/{simple-options-BjHCCh4v.mjs → simple-options-tcKOqnpF.mjs} +3 -3
- package/dist/{src-2qBGKg8O.mjs → src-B2Q_6G8V.mjs} +1 -1
- package/dist/{stream-first-event-timeout-DcNjoFQE.mjs → stream-first-event-timeout-2hfrquuz.mjs} +1 -1
- package/dist/string-coerce-fsri9iCu.mjs +34 -0
- package/dist/{string-normalization--fwJ4S2q.mjs → string-normalization-CmLIasuf.mjs} +1 -1
- package/dist/{tool-schema-json-projection-mJhXDcyz.mjs → tool-schema-json-projection-ClptDdAO.mjs} +2 -38
- package/dist/{transport-stream-shared-CZqMhfIw.mjs → transport-stream-shared-Cu3ZPhNW.mjs} +5 -5
- package/dist/{transport-stream-shared-xnaqxmbP.d.mts → transport-stream-shared-DOxpGJ-H.d.mts} +4 -4
- package/dist/transport-utils-CCooe-cr.mjs +121 -0
- package/dist/transports.d.mts +113 -41
- package/dist/transports.mjs +162 -1276
- package/dist/types-BADKjDBI.d.mts +1 -0
- package/dist/{types-CJ1-Ht7A.d.mts → types-Dy1q0CSu.d.mts} +72 -57
- package/dist/types.d.mts +5 -5
- package/dist/types.mjs +3 -3
- package/dist/utf16-slice-CvGodqok.mjs +29 -0
- package/dist/{validation-CJZtym2g.mjs → validation-BDzVDnTs.mjs} +9 -1
- package/dist/{validation-AKZBDGQd.d.mts → validation-CaFUZN9B.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +13 -3
- package/dist/anthropic-BDdqdVLK.mjs +0 -886
- package/dist/event-stream-zctLx0yr.d.mts +0 -1
- package/dist/google-shared-CWeG8RIl.mjs +0 -636
- package/dist/google-thinking-level-C-V3tecN.mjs +0 -9
- package/dist/openai-completions-BIUV3RDT.mjs +0 -403
- package/dist/openai-prompt-cache-CGnVB74a.mjs +0 -21
- package/dist/openai-prompt-cache-CNoIfHYC.d.mts +0 -16
- package/dist/transport-utils-7il795_9.mjs +0 -138
- package/dist/types-3Lnm-QSJ.d.mts +0 -1
- package/dist/utf16-slice-qz3nsy87.mjs +0 -84
|
@@ -1,174 +1,11 @@
|
|
|
1
|
-
import "./src-
|
|
1
|
+
import "./src-B2Q_6G8V.mjs";
|
|
2
2
|
import { n as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE } from "./types-BDdaOVi2.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { i as normalizeOptionalLowercaseString, n as normalizeLowercaseStringOrEmpty, s as readStringValue } from "./string-coerce-fsri9iCu.mjs";
|
|
4
|
+
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
5
|
+
import { t as canonicalizeBase64 } from "./base64-D-su8YVo.mjs";
|
|
6
|
+
import { a as parsePositiveInteger } from "./transport-utils-CCooe-cr.mjs";
|
|
7
|
+
import { c as supportsOpenAIReasoningEffort } from "./openai-reasoning-effort-BK7FbcLT.mjs";
|
|
7
8
|
import { t as createSseByteGuard } from "./streaming-byte-guard-CC-HMn_u.mjs";
|
|
8
|
-
//#region packages/ai/src/providers/openai-reasoning-effort.ts
|
|
9
|
-
/**
|
|
10
|
-
* OpenAI-compatible reasoning-effort normalization. Different GPT families
|
|
11
|
-
* expose different accepted effort enums, so callers map requested values here
|
|
12
|
-
* before constructing provider payloads.
|
|
13
|
-
*/
|
|
14
|
-
const GPT_5_REASONING_EFFORTS = [
|
|
15
|
-
"minimal",
|
|
16
|
-
"low",
|
|
17
|
-
"medium",
|
|
18
|
-
"high"
|
|
19
|
-
];
|
|
20
|
-
const GPT_51_REASONING_EFFORTS = [
|
|
21
|
-
"none",
|
|
22
|
-
"low",
|
|
23
|
-
"medium",
|
|
24
|
-
"high"
|
|
25
|
-
];
|
|
26
|
-
const GPT_52_REASONING_EFFORTS = [
|
|
27
|
-
"none",
|
|
28
|
-
"low",
|
|
29
|
-
"medium",
|
|
30
|
-
"high",
|
|
31
|
-
"xhigh"
|
|
32
|
-
];
|
|
33
|
-
const GPT_56_REASONING_EFFORTS = [
|
|
34
|
-
"none",
|
|
35
|
-
"low",
|
|
36
|
-
"medium",
|
|
37
|
-
"high",
|
|
38
|
-
"xhigh",
|
|
39
|
-
"max"
|
|
40
|
-
];
|
|
41
|
-
const GPT_6_ASTRA_REASONING_EFFORTS = [
|
|
42
|
-
"low",
|
|
43
|
-
"medium",
|
|
44
|
-
"high",
|
|
45
|
-
"xhigh",
|
|
46
|
-
"max"
|
|
47
|
-
];
|
|
48
|
-
const GPT_CODEX_REASONING_EFFORTS = [
|
|
49
|
-
"low",
|
|
50
|
-
"medium",
|
|
51
|
-
"high",
|
|
52
|
-
"xhigh"
|
|
53
|
-
];
|
|
54
|
-
const GPT_PRO_REASONING_EFFORTS = [
|
|
55
|
-
"medium",
|
|
56
|
-
"high",
|
|
57
|
-
"xhigh"
|
|
58
|
-
];
|
|
59
|
-
const GPT_5_PRO_REASONING_EFFORTS = ["high"];
|
|
60
|
-
const GPT_51_CODEX_MAX_REASONING_EFFORTS = [
|
|
61
|
-
"none",
|
|
62
|
-
"medium",
|
|
63
|
-
"high",
|
|
64
|
-
"xhigh"
|
|
65
|
-
];
|
|
66
|
-
const GPT_51_CODEX_MINI_REASONING_EFFORTS = ["medium"];
|
|
67
|
-
const GENERIC_REASONING_EFFORTS = [
|
|
68
|
-
"low",
|
|
69
|
-
"medium",
|
|
70
|
-
"high"
|
|
71
|
-
];
|
|
72
|
-
const CANONICAL_REASONING_EFFORTS = /* @__PURE__ */ new Set([
|
|
73
|
-
"none",
|
|
74
|
-
"minimal",
|
|
75
|
-
"low",
|
|
76
|
-
"medium",
|
|
77
|
-
"high",
|
|
78
|
-
"xhigh",
|
|
79
|
-
"max",
|
|
80
|
-
"off"
|
|
81
|
-
]);
|
|
82
|
-
function normalizeModelId(id) {
|
|
83
|
-
return normalizeLowercaseStringOrEmpty(id ?? "").replace(/-\d{4}-\d{2}-\d{2}$/u, "");
|
|
84
|
-
}
|
|
85
|
-
/** Return whether a model is the GPT-5.4 mini family. */
|
|
86
|
-
function isOpenAIGpt54MiniModel(model) {
|
|
87
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
88
|
-
return /^gpt-5\.4-mini(?:-|$)/u.test(id);
|
|
89
|
-
}
|
|
90
|
-
/** Return whether a model is the GPT-5.5 family. */
|
|
91
|
-
function isOpenAIGpt55Model(model) {
|
|
92
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
93
|
-
const name = normalizeModelId(typeof model.name === "string" ? model.name : void 0);
|
|
94
|
-
return /^gpt-5\.5(?:-|$)/u.test(id) || /^gpt-5\.5(?:\s|\(|-|$)/u.test(name);
|
|
95
|
-
}
|
|
96
|
-
/** Return whether a model is the GPT-5.6 family. */
|
|
97
|
-
function isOpenAIGpt56Model(model) {
|
|
98
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
99
|
-
const name = normalizeModelId(typeof model.name === "string" ? model.name : void 0);
|
|
100
|
-
return /^gpt-5\.6(?:-|$)/u.test(id) || /^gpt-5\.6(?:\s|\(|-|$)/u.test(name);
|
|
101
|
-
}
|
|
102
|
-
/** Normalize user-facing reasoning effort names to API effort names. */
|
|
103
|
-
function normalizeOpenAIReasoningEffort(effort) {
|
|
104
|
-
const trimmed = effort.trim();
|
|
105
|
-
const folded = trimmed.toLowerCase();
|
|
106
|
-
return CANONICAL_REASONING_EFFORTS.has(folded) ? folded : trimmed;
|
|
107
|
-
}
|
|
108
|
-
function readCompatReasoningEfforts(compat) {
|
|
109
|
-
if (!compat || typeof compat !== "object") return;
|
|
110
|
-
if (compat.supportsReasoningEffort === false) return [];
|
|
111
|
-
const raw = compat.supportedReasoningEfforts;
|
|
112
|
-
if (!Array.isArray(raw)) return;
|
|
113
|
-
const supported = uniqueStrings(normalizeStringEntries(raw.filter((value) => typeof value === "string")));
|
|
114
|
-
return supported.length > 0 ? supported : void 0;
|
|
115
|
-
}
|
|
116
|
-
function isDisabledReasoningEffort(effort) {
|
|
117
|
-
return effort === "none" || effort === "off";
|
|
118
|
-
}
|
|
119
|
-
/** Resolve the reasoning efforts accepted by a specific OpenAI-compatible model. */
|
|
120
|
-
function resolveOpenAISupportedReasoningEfforts(model) {
|
|
121
|
-
return resolveOpenAIModelReasoningEfforts(model) ?? GENERIC_REASONING_EFFORTS;
|
|
122
|
-
}
|
|
123
|
-
/** Read a declared or known model contract, leaving unknown compatible models unspecified. */
|
|
124
|
-
function resolveOpenAIModelReasoningEfforts(model) {
|
|
125
|
-
const compatEfforts = readCompatReasoningEfforts(model.compat);
|
|
126
|
-
if (compatEfforts) return compatEfforts;
|
|
127
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
128
|
-
if (id === "gpt-6-astra" && model.api !== "azure-openai-responses") return GPT_6_ASTRA_REASONING_EFFORTS;
|
|
129
|
-
if (/^gpt-5\.6(?:-|$)/u.test(id)) return GPT_56_REASONING_EFFORTS;
|
|
130
|
-
if (id === "gpt-5.1-codex-mini") return GPT_51_CODEX_MINI_REASONING_EFFORTS;
|
|
131
|
-
if (id === "gpt-5.1-codex-max") return GPT_51_CODEX_MAX_REASONING_EFFORTS;
|
|
132
|
-
if (/^gpt-5(?:\.\d+)?-codex(?:-|$)/u.test(id)) return GPT_CODEX_REASONING_EFFORTS;
|
|
133
|
-
if (id === "gpt-5-pro") return GPT_5_PRO_REASONING_EFFORTS;
|
|
134
|
-
if (/^gpt-5\.[2-9](?:\.\d+)?-pro(?:-|$)/u.test(id)) return GPT_PRO_REASONING_EFFORTS;
|
|
135
|
-
if (/^gpt-5\.[2-9](?:\.\d+)?(?:-|$)/u.test(id)) return GPT_52_REASONING_EFFORTS;
|
|
136
|
-
if (/^gpt-5\.1(?:-|$)/u.test(id)) return GPT_51_REASONING_EFFORTS;
|
|
137
|
-
if (/^gpt-5(?:-|$)/u.test(id)) return GPT_5_REASONING_EFFORTS;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Return whether a model accepts temperature. GPT-5.6 and GPT-6 Astra
|
|
141
|
-
* reject it with a 400; catalog compat can override per model.
|
|
142
|
-
*/
|
|
143
|
-
function supportsOpenAITemperature(model) {
|
|
144
|
-
const compat = model.compat;
|
|
145
|
-
if (compat && typeof compat === "object") {
|
|
146
|
-
const declared = compat.supportsTemperature;
|
|
147
|
-
if (typeof declared === "boolean") return declared;
|
|
148
|
-
}
|
|
149
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
150
|
-
return (id !== "gpt-6-astra" || model.api === "azure-openai-responses") && !/^gpt-5\.6(?:-|$)/u.test(id);
|
|
151
|
-
}
|
|
152
|
-
/** Return whether a model accepts a requested reasoning effort. */
|
|
153
|
-
function supportsOpenAIReasoningEffort(model, effort) {
|
|
154
|
-
return resolveOpenAISupportedReasoningEfforts(model).includes(normalizeOpenAIReasoningEffort(effort));
|
|
155
|
-
}
|
|
156
|
-
/** Resolve a requested reasoning effort to the closest value supported by the model. */
|
|
157
|
-
function resolveOpenAIReasoningEffortForModel(params) {
|
|
158
|
-
const requested = normalizeOpenAIReasoningEffort(params.effort);
|
|
159
|
-
const mapped = params.fallbackMap?.[requested] ?? (params.fallbackMap && CANONICAL_REASONING_EFFORTS.has(requested) ? Object.entries(params.fallbackMap).find(([effort]) => normalizeOpenAIReasoningEffort(effort) === requested)?.[1] : void 0);
|
|
160
|
-
const normalized = mapped === void 0 ? requested : mapped.trim();
|
|
161
|
-
const supported = resolveOpenAISupportedReasoningEfforts(params.model);
|
|
162
|
-
if (supported.includes(normalized)) return normalized;
|
|
163
|
-
if (requested === "off" && supported.includes("none")) return "none";
|
|
164
|
-
if (isDisabledReasoningEffort(requested) || isDisabledReasoningEffort(normalized)) return;
|
|
165
|
-
if (requested === "minimal" && supported.includes("low")) return "low";
|
|
166
|
-
if ((requested === "minimal" || requested === "low") && supported.includes("medium")) return "medium";
|
|
167
|
-
if (requested === "xhigh" && supported.includes("high")) return "high";
|
|
168
|
-
if (requested === "max" && supported.includes("xhigh")) return "xhigh";
|
|
169
|
-
return supported.find((effort) => !isDisabledReasoningEffort(normalizeOpenAIReasoningEffort(effort)));
|
|
170
|
-
}
|
|
171
|
-
//#endregion
|
|
172
9
|
//#region packages/model-catalog-core/src/provider-id.ts
|
|
173
10
|
function normalizeProviderId(provider) {
|
|
174
11
|
return normalizeLowercaseStringOrEmpty(provider);
|
|
@@ -694,4 +531,4 @@ function createBoundedOpenAIResponsesCompactionFetch(upstreamFetch) {
|
|
|
694
531
|
};
|
|
695
532
|
}
|
|
696
533
|
//#endregion
|
|
697
|
-
export {
|
|
534
|
+
export { responsesPromptObserver as S, OpenAIResponsesWebSocketPostDispatchError as _, applyOpenAIResponsesPayloadPolicy as a, RESPONSE_FAILED_NO_DETAILS_MESSAGE as b, resolveOpenAIResponsesServerCompactionPlan as c, OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS as d, OPENAI_RESPONSES_APIS as f, OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE as g, OPENAI_RESPONSES_REASONING_REPLAY_META_KEY as h, sanitizeResponsesImagePayload as i, AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS as l, OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY as m, isOpenAIResponsesCompactionOutput as n, resolveOpenAIResponsesCompactEndpointPlan as o, OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE as p, readOpenAIResponsesCompactionWindow as r, resolveOpenAIResponsesPayloadPolicy as s, createBoundedOpenAIResponsesCompactionFetch as t, DEFAULT_AZURE_OPENAI_API_VERSION as u, OpenAIResponsesWebSocketPreDispatchError as v, parseOpenAIResponsesWebSocketServerError as x, OpenAIResponsesWebSocketSafeRetryError as y };
|
package/dist/{openai-responses-contracts-rF5DDRNS.d.mts → openai-responses-contracts-B55afwRo.d.mts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { D as Model, n as Api } from "./types-
|
|
3
|
-
import {
|
|
1
|
+
import "./index-CQ6LTHw8.mjs";
|
|
2
|
+
import { D as Model, n as Api } from "./types-Dy1q0CSu.mjs";
|
|
3
|
+
import { a as BaseOpenAIStreamOptions, d as OpenAIApiReasoningEffort, f as OpenAIReasoningEffort } from "./provider-options-BXr9Ec83.mjs";
|
|
4
4
|
import { FunctionTool, ResponseCompactionItem, ResponseCreateParamsStreaming, ResponseInput, ResponseInputItem } from "openai/resources/responses/responses.js";
|
|
5
5
|
//#region packages/ai/src/transports/openai-responses-compaction-window.d.ts
|
|
6
6
|
type OpenAIResponsesCompactionOutput = Array<ResponseInputItem.Message | ReplayableResponseCompactionItem>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as stripSystemPromptCacheBoundary } from "./simple-options-
|
|
2
|
-
import { g as sanitizeTransportPayloadText } from "./transport-stream-shared-
|
|
3
|
-
import { S as responsesPromptObserver } from "./openai-responses-compaction-window-
|
|
1
|
+
import { d as stripSystemPromptCacheBoundary } from "./simple-options-tcKOqnpF.mjs";
|
|
2
|
+
import { g as sanitizeTransportPayloadText } from "./transport-stream-shared-Cu3ZPhNW.mjs";
|
|
3
|
+
import { S as responsesPromptObserver } from "./openai-responses-compaction-window-D5jbzCi3.mjs";
|
|
4
4
|
//#region packages/ai/src/transports/openai-responses-prompt-observer-internal.ts
|
|
5
5
|
function readFinalResponsesPrompt(request) {
|
|
6
6
|
if (typeof request.instructions === "string") return ["instructions", request.instructions];
|
|
@@ -1,62 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import { r as appendAssistantThinking } from "./event-stream-D8PARQfL.mjs";
|
|
2
|
+
import { a as normalizeOptionalString } from "./string-coerce-fsri9iCu.mjs";
|
|
3
|
+
import { i as clampThinkingLevel, r as calculateCost } from "./sanitize-unicode-Bb-v9meu.mjs";
|
|
4
|
+
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload, n as getAiTransportHost } from "./host-CWuF-sS3.mjs";
|
|
5
|
+
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
6
|
+
import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
|
|
7
|
+
import { i as stableStringify } from "./provider-error-C6TbKiey.mjs";
|
|
8
|
+
import { a as resolveModelSseDebugMode, i as resolveModelPayloadDebugMode, r as emitModelTransportDebug } from "./diagnostics-dV98PqIy.mjs";
|
|
9
|
+
import { r as asFiniteNumber } from "./base64-D-su8YVo.mjs";
|
|
10
|
+
import { s as redactSensitiveText } from "./transport-utils-CCooe-cr.mjs";
|
|
11
|
+
import { s as transformTransportMessages } from "./host-policy-CAopLRKA.mjs";
|
|
12
|
+
import { d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName } from "./simple-options-tcKOqnpF.mjs";
|
|
13
|
+
import { O as redactIdentifier, _ as createOpenAIProviderAcceptanceHook, b as log, f as projectOpenAITools, g as createModelStreamCooperativeScheduler, k as sha256Hex, u as resolveOpenAIStrictToolFlagWithDiagnostics } from "./openai-transport-params-DNasp2fU.mjs";
|
|
14
|
+
import { _ as transportAbortError, c as finalizeTransportStream, g as sanitizeTransportPayloadText, h as sanitizeNonEmptyTransportPayloadText, m as parseTerminalToolCallArguments, o as failTransportStream, y as withProviderResponseHook } from "./transport-stream-shared-Cu3ZPhNW.mjs";
|
|
12
15
|
import { t as shortHash } from "./hash-CHgqbJmD.mjs";
|
|
13
16
|
import { n as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-BuSUaAk5.mjs";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { t as
|
|
17
|
-
import {
|
|
17
|
+
import { r as parseStreamingJson, t as createToolArgumentPreviewSchedule } from "./json-parse-Dw_hnxsA.mjs";
|
|
18
|
+
import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
|
|
19
|
+
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-2hfrquuz.mjs";
|
|
20
|
+
import { t as transformProviderMessages } from "./provider-transcript-transform-pPmUIwKt.mjs";
|
|
21
|
+
import { a as resolveOpenAIModelReasoningEfforts, l as supportsOpenAITemperature, o as resolveOpenAIReasoningEffortForModel } from "./openai-reasoning-effort-BK7FbcLT.mjs";
|
|
22
|
+
import { a as resolveOpenAIProjectedToolsStrictToolFlag, r as normalizeOpenAIStrictToolParameters } from "./openai-tool-schema-CzjyYXun.mjs";
|
|
23
|
+
import { b as RESPONSE_FAILED_NO_DETAILS_MESSAGE, g as OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE, h as OPENAI_RESPONSES_REASONING_REPLAY_META_KEY, m as OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY, n as isOpenAIResponsesCompactionOutput, p as OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE, r as readOpenAIResponsesCompactionWindow } from "./openai-responses-compaction-window-D5jbzCi3.mjs";
|
|
18
24
|
import { createHash, randomUUID } from "node:crypto";
|
|
19
|
-
//#region packages/ai/src/transports/model-transport-debug.ts
|
|
20
|
-
/**
|
|
21
|
-
* Environment-driven debug controls for model transport logging.
|
|
22
|
-
*
|
|
23
|
-
* Model adapters share these helpers so payload, SSE, and transport diagnostics
|
|
24
|
-
* interpret OpenClaw debug environment variables consistently.
|
|
25
|
-
*/
|
|
26
|
-
function isTruthyEnv(value) {
|
|
27
|
-
const normalized = normalizeLowercaseStringOrEmpty(value);
|
|
28
|
-
return normalized.length > 0 && normalized !== "0" && normalized !== "false" && normalized !== "off" && normalized !== "no";
|
|
29
|
-
}
|
|
30
|
-
/** Resolves model payload debug verbosity from `OPENCLAW_DEBUG_MODEL_PAYLOAD`. */
|
|
31
|
-
function resolveModelPayloadDebugMode(env = process.env) {
|
|
32
|
-
const normalized = normalizeLowercaseStringOrEmpty(env.OPENCLAW_DEBUG_MODEL_PAYLOAD);
|
|
33
|
-
if (normalized === "tools" || normalized === "full-redacted") return normalized;
|
|
34
|
-
if (normalized === "summary") return "summary";
|
|
35
|
-
return "off";
|
|
36
|
-
}
|
|
37
|
-
/** Resolves SSE stream debug verbosity from `OPENCLAW_DEBUG_SSE`. */
|
|
38
|
-
function resolveModelSseDebugMode(env = process.env) {
|
|
39
|
-
const normalized = normalizeLowercaseStringOrEmpty(env.OPENCLAW_DEBUG_SSE);
|
|
40
|
-
if (normalized === "peek") return "peek";
|
|
41
|
-
if (normalized === "events" || isTruthyEnv(normalized)) return "events";
|
|
42
|
-
return "off";
|
|
43
|
-
}
|
|
44
|
-
/** Returns whether any model transport debug channel is enabled. */
|
|
45
|
-
function isModelTransportDebugEnabled(env = process.env) {
|
|
46
|
-
return isTruthyEnv(env.OPENCLAW_DEBUG_MODEL_TRANSPORT) || resolveModelPayloadDebugMode(env) !== "off" || resolveModelSseDebugMode(env) !== "off" || isTruthyEnv(env.OPENCLAW_DEBUG_CODE_MODE);
|
|
47
|
-
}
|
|
48
|
-
function isModelFetchMetadataMessage(message) {
|
|
49
|
-
return message.startsWith("[model-fetch]");
|
|
50
|
-
}
|
|
51
|
-
/** Emits model-fetch metadata at info level by default; other diagnostics require debug env. */
|
|
52
|
-
function emitModelTransportDebug(log, message) {
|
|
53
|
-
if (isModelFetchMetadataMessage(message) || isModelTransportDebugEnabled()) {
|
|
54
|
-
log.info(message);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
log.debug(message);
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
25
|
//#region packages/ai/src/transports/openai-responses-replay.ts
|
|
61
26
|
/** Resolves the assistant message id that can be replayed to OpenAI Responses. */
|
|
62
27
|
function resolveReplayableResponsesMessageId(params) {
|
|
@@ -1736,7 +1701,7 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
|
|
|
1736
1701
|
for (const slot of outputSlots.values()) if (slot !== except && slot.type === "text") materializeDeferredTextSlot(slot);
|
|
1737
1702
|
};
|
|
1738
1703
|
const appendThinkingDelta = (slot, delta) => {
|
|
1739
|
-
slot.block
|
|
1704
|
+
appendAssistantThinking(slot.block, delta);
|
|
1740
1705
|
stream.push({
|
|
1741
1706
|
type: "thinking_delta",
|
|
1742
1707
|
contentIndex: slot.contentIndex,
|
|
@@ -2088,26 +2053,26 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
|
|
|
2088
2053
|
}
|
|
2089
2054
|
//#endregion
|
|
2090
2055
|
//#region packages/ai/src/providers/openai-responses-tools.ts
|
|
2091
|
-
|
|
2092
|
-
const MAX_STRICT_TOOL_DOWNGRADE_DIAGNOSTIC_KEYS = 64;
|
|
2093
|
-
const loggedStrictToolDowngradeDiagnosticKeys = /* @__PURE__ */ new Set();
|
|
2094
|
-
/** Converts and returns the projection used to reconcile tool choices. */
|
|
2056
|
+
/** Projects direct provider descriptors before resolving their strict policy. */
|
|
2095
2057
|
function convertResponsesToolPayload(tools, options) {
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2058
|
+
return convertProjectedResponsesTools(projectOpenAITools(tools), resolveResponsesStrictToolSetting(options), options?.model);
|
|
2059
|
+
}
|
|
2060
|
+
/** Uses caller-prepared facts without rereading descriptors or resolving host policy again. */
|
|
2061
|
+
function convertProjectedResponsesTools(projection, strictSetting, model) {
|
|
2062
|
+
const strict = model ? resolveOpenAIStrictToolFlagWithDiagnostics(projection, strictSetting, {
|
|
2063
|
+
transport: "responses",
|
|
2064
|
+
model
|
|
2065
|
+
}) : resolveOpenAIProjectedToolsStrictToolFlag(projection, strictSetting);
|
|
2066
|
+
return sortPromptCacheToolsByName(projection.tools).map((tool) => {
|
|
2067
|
+
const result = {
|
|
2068
|
+
type: "function",
|
|
2069
|
+
name: tool.name,
|
|
2070
|
+
description: tool.description,
|
|
2071
|
+
parameters: normalizeOpenAIStrictToolParameters(tool.parameters, strict === true, model?.compat)
|
|
2072
|
+
};
|
|
2073
|
+
if (strict !== void 0) result.strict = strict;
|
|
2074
|
+
return result;
|
|
2075
|
+
});
|
|
2111
2076
|
}
|
|
2112
2077
|
function resolveResponsesStrictToolSetting(options) {
|
|
2113
2078
|
if (options?.strict !== void 0) return options.strict;
|
|
@@ -2117,42 +2082,6 @@ function resolveResponsesStrictToolSetting(options) {
|
|
|
2117
2082
|
});
|
|
2118
2083
|
return false;
|
|
2119
2084
|
}
|
|
2120
|
-
function resolveResponsesStrictToolFlag(projection, strictSetting, model) {
|
|
2121
|
-
const strict = resolveOpenAIProjectedToolsStrictToolFlag(projection, strictSetting);
|
|
2122
|
-
if (strictSetting === true && strict === false && model) getAiTransportHost().logDebug(LOG_SUBSYSTEM, () => {
|
|
2123
|
-
const diagnostics = findOpenAIStrictToolProjectionDiagnostics(projection);
|
|
2124
|
-
if (!shouldLogStrictToolDowngradeDiagnostic(diagnostics, model)) return null;
|
|
2125
|
-
const sample = diagnostics.slice(0, 5).map((entry) => ({
|
|
2126
|
-
tool: entry.toolName ?? `tool[${entry.toolIndex}]`,
|
|
2127
|
-
violations: entry.violations.slice(0, 8)
|
|
2128
|
-
}));
|
|
2129
|
-
return {
|
|
2130
|
-
message: `OpenAI responses tool schema strict mode downgraded to strict=false for ${model.provider ?? "unknown"}/${model.id ?? "unknown"} because ${diagnostics.length} tool schema(s) are not strict-compatible`,
|
|
2131
|
-
data: {
|
|
2132
|
-
provider: model.provider,
|
|
2133
|
-
model: model.id,
|
|
2134
|
-
incompatibleToolCount: diagnostics.length,
|
|
2135
|
-
sample
|
|
2136
|
-
}
|
|
2137
|
-
};
|
|
2138
|
-
});
|
|
2139
|
-
return strict;
|
|
2140
|
-
}
|
|
2141
|
-
function shouldLogStrictToolDowngradeDiagnostic(diagnostics, model) {
|
|
2142
|
-
const key = createHash("sha256").update(JSON.stringify({
|
|
2143
|
-
provider: model.provider,
|
|
2144
|
-
model: model.id,
|
|
2145
|
-
diagnostics: diagnostics.map((entry) => ({
|
|
2146
|
-
toolIndex: entry.toolIndex,
|
|
2147
|
-
toolName: entry.toolName ?? null,
|
|
2148
|
-
violations: entry.violations
|
|
2149
|
-
}))
|
|
2150
|
-
})).digest("hex");
|
|
2151
|
-
if (loggedStrictToolDowngradeDiagnosticKeys.has(key)) return false;
|
|
2152
|
-
if (loggedStrictToolDowngradeDiagnosticKeys.size >= MAX_STRICT_TOOL_DOWNGRADE_DIAGNOSTIC_KEYS) loggedStrictToolDowngradeDiagnosticKeys.clear();
|
|
2153
|
-
loggedStrictToolDowngradeDiagnosticKeys.add(key);
|
|
2154
|
-
return true;
|
|
2155
|
-
}
|
|
2156
2085
|
//#endregion
|
|
2157
2086
|
//#region packages/ai/src/providers/openai-responses-shared.ts
|
|
2158
2087
|
function convertResponsesMessages(model, context, allowedToolCallProviders, options) {
|
|
@@ -2187,8 +2116,8 @@ function applyCommonResponsesParams(params, model, context, options, config) {
|
|
|
2187
2116
|
if (options?.maxTokens) params.max_output_tokens = Math.max(options.maxTokens, 16);
|
|
2188
2117
|
if (options?.temperature !== void 0 && supportsOpenAITemperature(model)) params.temperature = options.temperature;
|
|
2189
2118
|
if (context.tools) {
|
|
2190
|
-
const
|
|
2191
|
-
if (
|
|
2119
|
+
const tools = convertResponsesToolPayload(context.tools, { model });
|
|
2120
|
+
if (tools.length > 0) params.tools = tools;
|
|
2192
2121
|
}
|
|
2193
2122
|
if (!model.reasoning) return;
|
|
2194
2123
|
const requestedEffort = options?.reasoningEffort ?? (options?.reasoningSummary ? "medium" : config?.setDefaultReasoningOff ?? true ? "off" : void 0);
|
|
@@ -2289,4 +2218,4 @@ async function runResponsesStreamLifecycle(params) {
|
|
|
2289
2218
|
}
|
|
2290
2219
|
}
|
|
2291
2220
|
//#endregion
|
|
2292
|
-
export {
|
|
2221
|
+
export { resolveReplayableResponsesMessageId as $, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE as A, resolveAzureOpenAIApiVersion as B, summarizeResponsesFailedNoDetailsObservation as C, readResponsesToolCallItemIdentity as D, createResponsesToolCallTracker as E, isResponsesTextDeltaEventType as F, recordResponsesInputReplay as G, buildResponsesInputMessage as H, resolveResponsesMessageSnapshotCollapse as I, buildOpenAIResponsesReasoningReplayMetadata as J, responsesInputFingerprint as K, commitResponsesEncryptedContentAttempt as L, isAzureResponsesTextDeltaEvent as M, isAzureResponsesTextDeltaEventType as N, AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE as O, isResponsesTextContentPartType as P, suppressOpenAIResponsesCompaction as Q, createResponsesStreamWithEncryptedContentRetry as R, summarizeOpenAITransportError as S, summarizeResponsesTools as T, convertResponsesMessages$1 as U, resolveNextResponsesEncryptedContentAttempt as V, createOpenAIResponsesAssistantOutput as W, isOpenAIResponsesReplayContext as X, captureOpenAIResponsesCompaction as Y, resolveNewestOpenAIResponsesCompactionReplay as Z, logResponsesFailedNoDetails as _, resolveResponsesReasoningEffort as a, stringifyRedactedEvent as b, convertProjectedResponsesTools as c, mapResponsesTerminalUsage as d, readResponsesReasoningTokens as f, buildResponsesFailedNoDetailsObservation as g, ResponsesStreamFailure as h, createResponsesAssistantOutput as i, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE as j, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE as k, convertResponsesToolPayload as l, observeResponsesStream as m, applyResponsesServiceTierPricing as n, resolveResponsesRequestReasoningEffort as o, resolveResponsesTerminalStopReason as p, CompactionReplayRefreshRequiredError as q, convertResponsesMessages as r, runResponsesStreamLifecycle as s, applyCommonResponsesParams as t, processResponsesStream as u, normalizeResponsesFailedEvent as v, summarizeResponsesPayload as w, stringifyRedactedPayload as x, safeDebugValue as y, isInvalidEncryptedContentError as z };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
import { ResponseCreateParamsStreaming } from "openai/resources/responses/responses.js";
|
|
3
|
+
//#region packages/ai/src/providers/openai-tool-projection.d.ts
|
|
4
|
+
type OpenAIToolDescriptor = {
|
|
5
|
+
readonly name?: unknown;
|
|
6
|
+
readonly description?: unknown;
|
|
7
|
+
readonly parameters: unknown;
|
|
8
|
+
};
|
|
9
|
+
type OpenAIProjectedTool = {
|
|
10
|
+
readonly toolIndex: number;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly description?: string;
|
|
13
|
+
readonly parameters: Record<string, unknown>;
|
|
14
|
+
};
|
|
15
|
+
type OpenAIToolProjectionDiagnostic = {
|
|
16
|
+
readonly toolIndex: number;
|
|
17
|
+
readonly toolName?: string;
|
|
18
|
+
readonly violations: readonly string[];
|
|
19
|
+
};
|
|
20
|
+
type OpenAIToolProjection = {
|
|
21
|
+
readonly inputToolCount: number;
|
|
22
|
+
readonly tools: readonly OpenAIProjectedTool[];
|
|
23
|
+
readonly diagnostics: readonly OpenAIToolProjectionDiagnostic[];
|
|
24
|
+
};
|
|
25
|
+
type OpenAIResponsesToolChoice = ResponseCreateParamsStreaming["tool_choice"];
|
|
26
|
+
type OpenAICompletionsSdkToolChoice = OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming["tool_choice"];
|
|
27
|
+
type OpenAICompletionsToolChoice = Exclude<OpenAICompletionsSdkToolChoice, {
|
|
28
|
+
type: "custom";
|
|
29
|
+
}>;
|
|
30
|
+
/** Snapshots direct/custom tool descriptors before OpenAI payload construction. */
|
|
31
|
+
declare function projectOpenAITools(tools: readonly OpenAIToolDescriptor[]): OpenAIToolProjection;
|
|
32
|
+
/** Keeps Responses tool choices aligned with surviving function schemas. */
|
|
33
|
+
declare function reconcileOpenAIResponsesToolChoice(choice: OpenAIResponsesToolChoice, projection: OpenAIToolProjection): OpenAIResponsesToolChoice | undefined;
|
|
34
|
+
/** Keeps Chat Completions tool choices aligned with surviving function schemas. */
|
|
35
|
+
declare function reconcileOpenAICompletionsToolChoice(choice: OpenAICompletionsSdkToolChoice, projection: OpenAIToolProjection): OpenAICompletionsSdkToolChoice | undefined;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { reconcileOpenAIResponsesToolChoice as a, reconcileOpenAICompletionsToolChoice as i, OpenAIToolProjection as n, projectOpenAITools as r, OpenAICompletionsToolChoice as t };
|