@openclaw/ai 2026.9.1-beta.1 → 2026.9.2
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-DI4PZKKB.mjs → anthropic-BDdqdVLK.mjs} +222 -216
- package/dist/{anthropic-compaction-replay-nhKaCXu6.mjs → anthropic-compaction-replay-DB2FGLQc.mjs} +160 -68
- package/dist/{anthropic-payload-policy-B_0n0enE.d.mts → anthropic-payload-policy-d46X2pR0.d.mts} +28 -4
- package/dist/{api-registry-CTd8NzcD.d.mts → api-registry-DWtPjzyn.d.mts} +2 -2
- package/dist/{azure-openai-responses-D8dI0ekg.mjs → azure-openai-responses-C5bZRfAP.mjs} +12 -9
- package/dist/{number-coercion-H9qHik3g.mjs → base64-CEFBpSkN.mjs} +73 -1
- package/dist/{diagnostics-COpOtRwq.mjs → diagnostics-CPeq9F7y.mjs} +5 -1
- package/dist/diagnostics-DfFyKeX_.mjs +136 -0
- package/dist/{diagnostics-BaTA9eVl.d.mts → diagnostics-DnPnOui6.d.mts} +5 -1
- package/dist/diagnostics.d.mts +8 -3
- package/dist/diagnostics.mjs +4 -3
- package/dist/{env-api-keys-DrgeBuva.mjs → env-api-keys-bktO00EJ.mjs} +2 -15
- package/dist/{event-stream-uSMZJ3FA.mjs → event-stream-BgDvQeum.mjs} +3 -9
- package/dist/{event-stream-LiXePESD.d.mts → event-stream-BhT5T1Ay.d.mts} +1 -1
- package/dist/event-stream-zctLx0yr.d.mts +1 -0
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -1
- package/dist/{google-Od-LLdVK.mjs → google-4qeuE8iX.mjs} +9 -7
- package/dist/{google-shared-Bgr9lFPw.mjs → google-shared-CWeG8RIl.mjs} +27 -23
- package/dist/{google-vertex-aerRSXc4.mjs → google-vertex-O9BcnB6X.mjs} +8 -6
- package/dist/{host-D51fmkH6.mjs → host-CEvLw30U.mjs} +54 -9
- package/dist/{host-DsbPMFU6.d.mts → host-DjzGmdZ2.d.mts} +3 -3
- package/dist/index-FnHM2FcI.d.mts +117 -0
- package/dist/index.d.mts +10 -11
- package/dist/index.mjs +6 -6
- package/dist/internal/anthropic.d.mts +59 -55
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
- package/dist/internal/openai-responses-payload-policy.mjs +2 -3
- package/dist/internal/openai.d.mts +66 -64
- package/dist/internal/openai.mjs +10 -10
- package/dist/internal/retry-after.d.mts +2 -3
- package/dist/internal/runtime.d.mts +43 -43
- package/dist/internal/runtime.mjs +10 -8
- package/dist/internal/shared.d.mts +25 -25
- package/dist/internal/shared.mjs +95 -4
- package/dist/{mistral-EiHdymeb.mjs → mistral-Tb6oalqH.mjs} +30 -23
- package/dist/{openai-chatgpt-responses-DHpF9o1e.mjs → openai-chatgpt-responses-yUXjPNfu.mjs} +76 -137
- package/dist/{openai-completions-EFPiUGfS.mjs → openai-completions-BIUV3RDT.mjs} +26 -22
- package/dist/{openai-completions-compat-BefmHT26.d.mts → openai-completions-compat-CpjYUArk.d.mts} +5 -5
- package/dist/{openai-completions-stream-DUlGwRMz.mjs → openai-completions-stream-BsrBe3Gg.mjs} +103 -96
- package/dist/openai-prompt-cache-CGnVB74a.mjs +21 -0
- package/dist/openai-prompt-cache-CNoIfHYC.d.mts +16 -0
- package/dist/{openai-responses-BogP8OjX.mjs → openai-responses-CCL41ALM.mjs} +15 -14
- package/dist/openai-responses-compaction-window-BMVHFOtq.mjs +697 -0
- package/dist/{openai-responses-contracts-Dvj_UtPy.d.mts → openai-responses-contracts-rF5DDRNS.d.mts} +23 -6
- package/dist/{openai-responses-payload-policy-CNGFT9zr.d.mts → openai-responses-payload-policy-rLRPsSmB.d.mts} +1 -0
- package/dist/{openai-responses-prompt-observer-internal-Cd4hJG-S.mjs → openai-responses-prompt-observer-internal-D0bhBfgL.mjs} +4 -18
- package/dist/{openai-responses-shared-DJThc6jW.mjs → openai-responses-shared-Bmma_3Qc.mjs} +438 -309
- package/dist/{openai-tool-schema-ho-hIkQf.mjs → openai-tool-schema-_pTAJqKF.mjs} +30 -40
- package/dist/{provider-error-DDOs_Bz0.mjs → provider-error-9TraxGvt.mjs} +20 -92
- package/dist/{provider-options-MdMBLzlU.d.mts → provider-options-Bcc_p-TU.d.mts} +26 -6
- package/dist/provider-replay-context-BuSUaAk5.mjs +21 -0
- package/dist/{provider-transcript-transform-C01bQ5a3.mjs → provider-transcript-transform-BaMbI1hr.mjs} +1 -1
- package/dist/provider-types.d.mts +19 -20
- package/dist/providers.d.mts +6 -6
- package/dist/providers.mjs +11 -11
- package/dist/{reasoning-tag-text-partitioner-5ygO2rZc.mjs → reasoning-tag-text-partitioner-DLCNXki6.mjs} +158 -94
- package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
- package/dist/{sanitize-unicode-DCkltN94.mjs → sanitize-unicode-D6xUvZaS.mjs} +2 -8
- package/dist/{simple-options-CFj7x3J4.mjs → simple-options-BjHCCh4v.mjs} +42 -6
- package/dist/{src-Bu3FiFAG.mjs → src-2qBGKg8O.mjs} +83 -2
- package/dist/{stream-first-event-timeout-MK28puvq.mjs → stream-first-event-timeout-DcNjoFQE.mjs} +1 -1
- package/dist/{tool-schema-json-projection-qvTEs5Am.mjs → tool-schema-json-projection-mJhXDcyz.mjs} +21 -31
- package/dist/{transport-stream-shared-ljShVIZB.mjs → transport-stream-shared-CZqMhfIw.mjs} +19 -6
- package/dist/{transport-stream-shared-rvaCyFYt.d.mts → transport-stream-shared-xnaqxmbP.d.mts} +5 -5
- package/dist/{transport-utils-LJ1_rbi-.mjs → transport-utils-7il795_9.mjs} +5 -8
- package/dist/transports.d.mts +121 -85
- package/dist/transports.mjs +747 -464
- package/dist/types-3Lnm-QSJ.d.mts +1 -0
- package/dist/{types-DhLoJbFm.d.mts → types-CJ1-Ht7A.d.mts} +55 -19
- package/dist/types.d.mts +7 -7
- package/dist/types.mjs +5 -5
- package/dist/{validation-Dk7q7NMN.d.mts → validation-AKZBDGQd.d.mts} +1 -1
- package/dist/{validation-B61OhAio.mjs → validation-CJZtym2g.mjs} +7 -5
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +5 -5
- package/dist/anthropic-BECQCNdF.d.mts +0 -98
- package/dist/event-stream-BKp4fOt_.d.mts +0 -1
- package/dist/index-Qbej8io0.d.mts +0 -3
- package/dist/openai-prompt-cache-2uo_1OR1.d.mts +0 -7
- package/dist/openai-prompt-cache-mZTCdRPo.mjs +0 -12
- package/dist/openai-responses-contracts-QUY12X0B.mjs +0 -233
- package/dist/openai-responses-payload-policy-D8EdimYe.mjs +0 -204
- package/dist/provider-options-AvldWZt8.mjs +0 -21
- package/dist/tls-certificate-errors-DXSpluKI.mjs +0 -93
- package/dist/types-GiAjXatj.d.mts +0 -1
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import "./src-Bu3FiFAG.mjs";
|
|
2
|
-
import { n as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE } from "./types-BDdaOVi2.mjs";
|
|
3
|
-
import { c as normalizeLowercaseStringOrEmpty, o as isRecord } from "./utf16-slice-qz3nsy87.mjs";
|
|
4
|
-
import { n as uniqueStrings, t as normalizeStringEntries } from "./string-normalization--fwJ4S2q.mjs";
|
|
5
|
-
//#region packages/ai/src/providers/openai-reasoning-effort.ts
|
|
6
|
-
/**
|
|
7
|
-
* OpenAI-compatible reasoning-effort normalization. Different GPT families
|
|
8
|
-
* expose different accepted effort enums, so callers map requested values here
|
|
9
|
-
* before constructing provider payloads.
|
|
10
|
-
*/
|
|
11
|
-
const GPT_5_REASONING_EFFORTS = [
|
|
12
|
-
"minimal",
|
|
13
|
-
"low",
|
|
14
|
-
"medium",
|
|
15
|
-
"high"
|
|
16
|
-
];
|
|
17
|
-
const GPT_51_REASONING_EFFORTS = [
|
|
18
|
-
"none",
|
|
19
|
-
"low",
|
|
20
|
-
"medium",
|
|
21
|
-
"high"
|
|
22
|
-
];
|
|
23
|
-
const GPT_52_REASONING_EFFORTS = [
|
|
24
|
-
"none",
|
|
25
|
-
"low",
|
|
26
|
-
"medium",
|
|
27
|
-
"high",
|
|
28
|
-
"xhigh"
|
|
29
|
-
];
|
|
30
|
-
const GPT_56_REASONING_EFFORTS = [
|
|
31
|
-
"none",
|
|
32
|
-
"low",
|
|
33
|
-
"medium",
|
|
34
|
-
"high",
|
|
35
|
-
"xhigh",
|
|
36
|
-
"max"
|
|
37
|
-
];
|
|
38
|
-
const GPT_CODEX_REASONING_EFFORTS = [
|
|
39
|
-
"low",
|
|
40
|
-
"medium",
|
|
41
|
-
"high",
|
|
42
|
-
"xhigh"
|
|
43
|
-
];
|
|
44
|
-
const GPT_PRO_REASONING_EFFORTS = [
|
|
45
|
-
"medium",
|
|
46
|
-
"high",
|
|
47
|
-
"xhigh"
|
|
48
|
-
];
|
|
49
|
-
const GPT_5_PRO_REASONING_EFFORTS = ["high"];
|
|
50
|
-
const GPT_51_CODEX_MAX_REASONING_EFFORTS = [
|
|
51
|
-
"none",
|
|
52
|
-
"medium",
|
|
53
|
-
"high",
|
|
54
|
-
"xhigh"
|
|
55
|
-
];
|
|
56
|
-
const GPT_51_CODEX_MINI_REASONING_EFFORTS = ["medium"];
|
|
57
|
-
const GENERIC_REASONING_EFFORTS = [
|
|
58
|
-
"low",
|
|
59
|
-
"medium",
|
|
60
|
-
"high"
|
|
61
|
-
];
|
|
62
|
-
const CANONICAL_REASONING_EFFORTS = /* @__PURE__ */ new Set([
|
|
63
|
-
"none",
|
|
64
|
-
"minimal",
|
|
65
|
-
"low",
|
|
66
|
-
"medium",
|
|
67
|
-
"high",
|
|
68
|
-
"xhigh",
|
|
69
|
-
"max",
|
|
70
|
-
"off"
|
|
71
|
-
]);
|
|
72
|
-
function normalizeModelId(id) {
|
|
73
|
-
return normalizeLowercaseStringOrEmpty(id ?? "").replace(/-\d{4}-\d{2}-\d{2}$/u, "");
|
|
74
|
-
}
|
|
75
|
-
/** Return whether a model is the GPT-5.4 mini family. */
|
|
76
|
-
function isOpenAIGpt54MiniModel(model) {
|
|
77
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
78
|
-
return /^gpt-5\.4-mini(?:-|$)/u.test(id);
|
|
79
|
-
}
|
|
80
|
-
/** Return whether a model is the GPT-5.5 family. */
|
|
81
|
-
function isOpenAIGpt55Model(model) {
|
|
82
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
83
|
-
const name = normalizeModelId(typeof model.name === "string" ? model.name : void 0);
|
|
84
|
-
return /^gpt-5\.5(?:-|$)/u.test(id) || /^gpt-5\.5(?:\s|\(|-|$)/u.test(name);
|
|
85
|
-
}
|
|
86
|
-
/** Return whether a model is the GPT-5.6 family. */
|
|
87
|
-
function isOpenAIGpt56Model(model) {
|
|
88
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
89
|
-
const name = normalizeModelId(typeof model.name === "string" ? model.name : void 0);
|
|
90
|
-
return /^gpt-5\.6(?:-|$)/u.test(id) || /^gpt-5\.6(?:\s|\(|-|$)/u.test(name);
|
|
91
|
-
}
|
|
92
|
-
/** Normalize user-facing reasoning effort names to API effort names. */
|
|
93
|
-
function normalizeOpenAIReasoningEffort(effort) {
|
|
94
|
-
const trimmed = effort.trim();
|
|
95
|
-
const folded = trimmed.toLowerCase();
|
|
96
|
-
return CANONICAL_REASONING_EFFORTS.has(folded) ? folded : trimmed;
|
|
97
|
-
}
|
|
98
|
-
function readCompatReasoningEfforts(compat) {
|
|
99
|
-
if (!compat || typeof compat !== "object") return;
|
|
100
|
-
if (compat.supportsReasoningEffort === false) return [];
|
|
101
|
-
const raw = compat.supportedReasoningEfforts;
|
|
102
|
-
if (!Array.isArray(raw)) return;
|
|
103
|
-
const supported = uniqueStrings(normalizeStringEntries(raw.filter((value) => typeof value === "string")));
|
|
104
|
-
return supported.length > 0 ? supported : void 0;
|
|
105
|
-
}
|
|
106
|
-
function isDisabledReasoningEffort(effort) {
|
|
107
|
-
return effort === "none" || effort === "off";
|
|
108
|
-
}
|
|
109
|
-
/** Resolve the reasoning efforts accepted by a specific OpenAI-compatible model. */
|
|
110
|
-
function resolveOpenAISupportedReasoningEfforts(model) {
|
|
111
|
-
const compatEfforts = readCompatReasoningEfforts(model.compat);
|
|
112
|
-
if (compatEfforts) return compatEfforts;
|
|
113
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
114
|
-
if (/^gpt-5\.6(?:-|$)/u.test(id)) return GPT_56_REASONING_EFFORTS;
|
|
115
|
-
if (id === "gpt-5.1-codex-mini") return GPT_51_CODEX_MINI_REASONING_EFFORTS;
|
|
116
|
-
if (id === "gpt-5.1-codex-max") return GPT_51_CODEX_MAX_REASONING_EFFORTS;
|
|
117
|
-
if (/^gpt-5(?:\.\d+)?-codex(?:-|$)/u.test(id)) return GPT_CODEX_REASONING_EFFORTS;
|
|
118
|
-
if (id === "gpt-5-pro") return GPT_5_PRO_REASONING_EFFORTS;
|
|
119
|
-
if (/^gpt-5\.[2-9](?:\.\d+)?-pro(?:-|$)/u.test(id)) return GPT_PRO_REASONING_EFFORTS;
|
|
120
|
-
if (/^gpt-5\.[2-9](?:\.\d+)?(?:-|$)/u.test(id)) return GPT_52_REASONING_EFFORTS;
|
|
121
|
-
if (/^gpt-5\.1(?:-|$)/u.test(id)) return GPT_51_REASONING_EFFORTS;
|
|
122
|
-
if (/^gpt-5(?:-|$)/u.test(id)) return GPT_5_REASONING_EFFORTS;
|
|
123
|
-
return GENERIC_REASONING_EFFORTS;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Return whether a model accepts the temperature parameter. The GPT-5.6
|
|
127
|
-
* family rejects it with a 400; catalog compat can override per model.
|
|
128
|
-
*/
|
|
129
|
-
function supportsOpenAITemperature(model) {
|
|
130
|
-
const compat = model.compat;
|
|
131
|
-
if (compat && typeof compat === "object") {
|
|
132
|
-
const declared = compat.supportsTemperature;
|
|
133
|
-
if (typeof declared === "boolean") return declared;
|
|
134
|
-
}
|
|
135
|
-
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
136
|
-
return !/^gpt-5\.6(?:-|$)/u.test(id);
|
|
137
|
-
}
|
|
138
|
-
/** Return whether a model accepts a requested reasoning effort. */
|
|
139
|
-
function supportsOpenAIReasoningEffort(model, effort) {
|
|
140
|
-
return resolveOpenAISupportedReasoningEfforts(model).includes(normalizeOpenAIReasoningEffort(effort));
|
|
141
|
-
}
|
|
142
|
-
/** Resolve a requested reasoning effort to the closest value supported by the model. */
|
|
143
|
-
function resolveOpenAIReasoningEffortForModel(params) {
|
|
144
|
-
const requested = normalizeOpenAIReasoningEffort(params.effort);
|
|
145
|
-
const mapped = params.fallbackMap?.[requested] ?? (params.fallbackMap && CANONICAL_REASONING_EFFORTS.has(requested) ? Object.entries(params.fallbackMap).find(([effort]) => normalizeOpenAIReasoningEffort(effort) === requested)?.[1] : void 0);
|
|
146
|
-
const normalized = mapped === void 0 ? requested : mapped.trim();
|
|
147
|
-
const supported = resolveOpenAISupportedReasoningEfforts(params.model);
|
|
148
|
-
if (supported.includes(normalized)) return normalized;
|
|
149
|
-
if (requested === "off" && supported.includes("none")) return "none";
|
|
150
|
-
if (isDisabledReasoningEffort(requested) || isDisabledReasoningEffort(normalized)) return;
|
|
151
|
-
if (requested === "minimal" && supported.includes("low")) return "low";
|
|
152
|
-
if ((requested === "minimal" || requested === "low") && supported.includes("medium")) return "medium";
|
|
153
|
-
if (requested === "xhigh" && supported.includes("high")) return "high";
|
|
154
|
-
if (requested === "max" && supported.includes("xhigh")) return "xhigh";
|
|
155
|
-
return supported.find((effort) => !isDisabledReasoningEffort(normalizeOpenAIReasoningEffort(effort)));
|
|
156
|
-
}
|
|
157
|
-
//#endregion
|
|
158
|
-
//#region packages/ai/src/transports/openai-responses-contracts.ts
|
|
159
|
-
const DEFAULT_AZURE_OPENAI_API_VERSION = "preview";
|
|
160
|
-
const OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS = "Follow the user request.";
|
|
161
|
-
const AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS = 3e4;
|
|
162
|
-
const RESPONSE_FAILED_NO_DETAILS_MESSAGE = "Unknown error (no error details in response)";
|
|
163
|
-
const OPENAI_RESPONSES_REASONING_REPLAY_META_KEY = "__openclaw_replay";
|
|
164
|
-
const OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY = "openclawReasoningReplay";
|
|
165
|
-
const OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE = "openai-responses-compaction";
|
|
166
|
-
const OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE = "openai-responses-retained-compaction";
|
|
167
|
-
const OPENAI_RESPONSES_APIS = /* @__PURE__ */ new Set([
|
|
168
|
-
"openai-responses",
|
|
169
|
-
"azure-openai-responses",
|
|
170
|
-
"openai-chatgpt-responses",
|
|
171
|
-
"openclaw-openai-responses-transport",
|
|
172
|
-
"openclaw-openai-chatgpt-responses-transport",
|
|
173
|
-
"openclaw-azure-openai-responses-transport"
|
|
174
|
-
]);
|
|
175
|
-
var OpenAIResponsesWebSocketPreDispatchError = class extends Error {
|
|
176
|
-
constructor(cause) {
|
|
177
|
-
super("OpenAI Responses WebSocket failed before request dispatch", { cause });
|
|
178
|
-
this.name = "OpenAIResponsesWebSocketPreDispatchError";
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
var OpenAIResponsesWebSocketPostDispatchError = class extends Error {
|
|
182
|
-
constructor(cause) {
|
|
183
|
-
super("OpenAI Responses WebSocket failed after request dispatch; outcome is unknown", { cause });
|
|
184
|
-
this.code = PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE;
|
|
185
|
-
this.name = "OpenAIResponsesWebSocketPostDispatchError";
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
var OpenAIResponsesWebSocketServerError = class extends Error {
|
|
189
|
-
constructor(code, status, param, message, cause) {
|
|
190
|
-
super(message, { cause });
|
|
191
|
-
this.code = code;
|
|
192
|
-
this.status = status;
|
|
193
|
-
this.param = param;
|
|
194
|
-
this.name = "OpenAIResponsesWebSocketServerError";
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
var OpenAIResponsesWebSocketSafeRetryError = class extends OpenAIResponsesWebSocketServerError {};
|
|
198
|
-
function readWebSocketServerError(value) {
|
|
199
|
-
if (!isRecord(value) || value.type !== "error") return;
|
|
200
|
-
const details = isRecord(value.error) ? value.error : value;
|
|
201
|
-
if (typeof details.code !== "string" || typeof details.message !== "string") return;
|
|
202
|
-
const rawStatus = value.status ?? value.status_code;
|
|
203
|
-
return {
|
|
204
|
-
code: details.code,
|
|
205
|
-
message: details.message,
|
|
206
|
-
param: typeof details.param === "string" ? details.param : null,
|
|
207
|
-
status: typeof rawStatus === "number" ? rawStatus : void 0
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
function parseOpenAIResponsesWebSocketServerError(cause) {
|
|
211
|
-
if (!isRecord(cause)) return;
|
|
212
|
-
let details = readWebSocketServerError(cause.error) ?? readWebSocketServerError(cause);
|
|
213
|
-
if (!details && typeof cause.message === "string") try {
|
|
214
|
-
details = readWebSocketServerError(JSON.parse(cause.message));
|
|
215
|
-
} catch {}
|
|
216
|
-
if (!details) return;
|
|
217
|
-
return new (details.code === "previous_response_not_found" || details.code === "websocket_connection_limit_reached" || details.code === "invalid_encrypted_content" || details.code === "thinking_signature_invalid" ? OpenAIResponsesWebSocketSafeRetryError : OpenAIResponsesWebSocketServerError)(details.code, details.status, details.param, details.message, cause);
|
|
218
|
-
}
|
|
219
|
-
const PROMPT_OBSERVER = Symbol("openaiResponsesPromptObserver");
|
|
220
|
-
const responsesPromptObserver = {
|
|
221
|
-
set(options, observer) {
|
|
222
|
-
Reflect.set(options, PROMPT_OBSERVER, observer);
|
|
223
|
-
},
|
|
224
|
-
get(options) {
|
|
225
|
-
return Reflect.get(options, PROMPT_OBSERVER);
|
|
226
|
-
},
|
|
227
|
-
copy(source, target) {
|
|
228
|
-
const observer = source && responsesPromptObserver.get(source);
|
|
229
|
-
if (observer) responsesPromptObserver.set(target, observer);
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
//#endregion
|
|
233
|
-
export { supportsOpenAITemperature as S, isOpenAIGpt56Model as _, OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE as a, resolveOpenAISupportedReasoningEfforts as b, OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE as c, OpenAIResponsesWebSocketSafeRetryError as d, RESPONSE_FAILED_NO_DETAILS_MESSAGE as f, isOpenAIGpt55Model as g, isOpenAIGpt54MiniModel as h, OPENAI_RESPONSES_APIS as i, OpenAIResponsesWebSocketPostDispatchError as l, responsesPromptObserver as m, DEFAULT_AZURE_OPENAI_API_VERSION as n, OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY as o, parseOpenAIResponsesWebSocketServerError as p, OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS as r, OPENAI_RESPONSES_REASONING_REPLAY_META_KEY as s, AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS as t, OpenAIResponsesWebSocketPreDispatchError as u, normalizeOpenAIReasoningEffort as v, supportsOpenAIReasoningEffort as x, resolveOpenAIReasoningEffortForModel as y };
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { c as normalizeLowercaseStringOrEmpty, p as readStringValue, u as normalizeOptionalLowercaseString } from "./utf16-slice-qz3nsy87.mjs";
|
|
2
|
-
import { s as parsePositiveInteger } from "./transport-utils-LJ1_rbi-.mjs";
|
|
3
|
-
import { i as OPENAI_RESPONSES_APIS, x as supportsOpenAIReasoningEffort } from "./openai-responses-contracts-QUY12X0B.mjs";
|
|
4
|
-
//#region packages/model-catalog-core/src/provider-id.ts
|
|
5
|
-
function normalizeProviderId(provider) {
|
|
6
|
-
return normalizeLowercaseStringOrEmpty(provider);
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region packages/ai/src/transports/openai-responses-payload-policy.ts
|
|
10
|
-
/**
|
|
11
|
-
* OpenAI Responses payload policy.
|
|
12
|
-
* Classifies endpoint capabilities and applies store, prompt-cache,
|
|
13
|
-
* server-compaction, service-tier, and reasoning payload rules.
|
|
14
|
-
*/
|
|
15
|
-
const OPENAI_RESPONSES_PROVIDERS = /* @__PURE__ */ new Set([
|
|
16
|
-
"openai",
|
|
17
|
-
"azure-openai",
|
|
18
|
-
"azure-openai-responses"
|
|
19
|
-
]);
|
|
20
|
-
const LOCAL_ENDPOINT_HOSTS = /* @__PURE__ */ new Set([
|
|
21
|
-
"localhost",
|
|
22
|
-
"127.0.0.1",
|
|
23
|
-
"::1",
|
|
24
|
-
"[::1]"
|
|
25
|
-
]);
|
|
26
|
-
const MODELSTUDIO_NATIVE_BASE_URLS = /* @__PURE__ */ new Set([
|
|
27
|
-
"https://coding-intl.dashscope.aliyuncs.com/v1",
|
|
28
|
-
"https://coding.dashscope.aliyuncs.com/v1",
|
|
29
|
-
"https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
30
|
-
"https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
|
|
31
|
-
]);
|
|
32
|
-
const MOONSHOT_NATIVE_BASE_URLS = /* @__PURE__ */ new Set(["https://api.moonshot.ai/v1", "https://api.moonshot.cn/v1"]);
|
|
33
|
-
function normalizeComparableBaseUrl(value) {
|
|
34
|
-
const trimmed = readStringValue(value)?.trim();
|
|
35
|
-
if (!trimmed) return;
|
|
36
|
-
const parsedValue = /^[a-z0-9.[\]-]+(?::\d+)?(?:[/?#].*)?$/i.test(trimmed) ? `https://${trimmed}` : trimmed;
|
|
37
|
-
try {
|
|
38
|
-
const url = new URL(parsedValue);
|
|
39
|
-
if (url.protocol !== "http:" && url.protocol !== "https:") return;
|
|
40
|
-
url.hash = "";
|
|
41
|
-
url.search = "";
|
|
42
|
-
return url.toString().replace(/\/+$/, "").toLowerCase();
|
|
43
|
-
} catch {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function resolveUrlHostname(value) {
|
|
48
|
-
const trimmed = readStringValue(value)?.trim();
|
|
49
|
-
if (!trimmed) return;
|
|
50
|
-
try {
|
|
51
|
-
return new URL(trimmed).hostname.toLowerCase();
|
|
52
|
-
} catch {
|
|
53
|
-
try {
|
|
54
|
-
return new URL(`https://${trimmed}`).hostname.toLowerCase();
|
|
55
|
-
} catch {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function hostMatchesSuffix(host, suffix) {
|
|
61
|
-
return suffix.startsWith(".") || suffix.startsWith("-") ? host.endsWith(suffix) : host === suffix || host.endsWith(`.${suffix}`);
|
|
62
|
-
}
|
|
63
|
-
function isLocalEndpointHost(host) {
|
|
64
|
-
return LOCAL_ENDPOINT_HOSTS.has(host) || host.endsWith(".localhost") || host.endsWith(".local") || host.endsWith(".internal");
|
|
65
|
-
}
|
|
66
|
-
function resolveBundledOpenAIResponsesEndpointClass(baseUrl) {
|
|
67
|
-
const trimmed = readStringValue(baseUrl)?.trim();
|
|
68
|
-
if (!trimmed) return "default";
|
|
69
|
-
const host = resolveUrlHostname(trimmed);
|
|
70
|
-
if (!host) return "invalid";
|
|
71
|
-
const comparableBaseUrl = normalizeComparableBaseUrl(trimmed);
|
|
72
|
-
switch (host) {
|
|
73
|
-
case "api.anthropic.com": return "anthropic-public";
|
|
74
|
-
case "api.cerebras.ai": return "cerebras-native";
|
|
75
|
-
case "llm.chutes.ai": return "chutes-native";
|
|
76
|
-
case "api.deepseek.com": return "deepseek-native";
|
|
77
|
-
case "api.groq.com": return "groq-native";
|
|
78
|
-
case "api.mistral.ai": return "mistral-public";
|
|
79
|
-
case "api.openai.com": return "openai-public";
|
|
80
|
-
case "chatgpt.com": return "openai";
|
|
81
|
-
case "generativelanguage.googleapis.com": return "google-generative-ai";
|
|
82
|
-
case "aiplatform.googleapis.com": return "google-vertex";
|
|
83
|
-
case "api.x.ai": return "xai-native";
|
|
84
|
-
case "api.z.ai": return "zai-native";
|
|
85
|
-
}
|
|
86
|
-
if (hostMatchesSuffix(host, ".githubcopilot.com")) return "github-copilot-native";
|
|
87
|
-
if ([
|
|
88
|
-
".openai.azure.com",
|
|
89
|
-
".cognitiveservices.azure.com",
|
|
90
|
-
".services.ai.azure.com",
|
|
91
|
-
".api.cognitive.microsoft.com"
|
|
92
|
-
].some((suffix) => hostMatchesSuffix(host, suffix))) return "azure-openai";
|
|
93
|
-
if (hostMatchesSuffix(host, "openrouter.ai")) return "openrouter";
|
|
94
|
-
if (hostMatchesSuffix(host, "opencode.ai")) return "opencode-native";
|
|
95
|
-
if (hostMatchesSuffix(host, "-aiplatform.googleapis.com")) return "google-vertex";
|
|
96
|
-
if (comparableBaseUrl && MOONSHOT_NATIVE_BASE_URLS.has(comparableBaseUrl)) return "moonshot-native";
|
|
97
|
-
if (comparableBaseUrl && MODELSTUDIO_NATIVE_BASE_URLS.has(comparableBaseUrl)) return "modelstudio-native";
|
|
98
|
-
if (isLocalEndpointHost(host)) return "local";
|
|
99
|
-
return "custom";
|
|
100
|
-
}
|
|
101
|
-
function isOpenAIResponsesApi(api) {
|
|
102
|
-
return api !== void 0 && OPENAI_RESPONSES_APIS.has(api);
|
|
103
|
-
}
|
|
104
|
-
function readCompatPayloadBoolean(compat, key) {
|
|
105
|
-
if (!compat || typeof compat !== "object") return;
|
|
106
|
-
const value = compat[key];
|
|
107
|
-
return typeof value === "boolean" ? value : void 0;
|
|
108
|
-
}
|
|
109
|
-
function resolveOpenAIResponsesPayloadCapabilities(model) {
|
|
110
|
-
const provider = normalizeOptionalLowercaseString(model.provider);
|
|
111
|
-
const api = normalizeOptionalLowercaseString(model.api);
|
|
112
|
-
const isOpenAIProvider = provider === "openai";
|
|
113
|
-
const endpointClass = resolveBundledOpenAIResponsesEndpointClass(model.baseUrl);
|
|
114
|
-
const isResponsesApi = isOpenAIResponsesApi(api);
|
|
115
|
-
const usesConfiguredBaseUrl = endpointClass !== "default";
|
|
116
|
-
const usesKnownNativeOpenAIEndpoint = endpointClass === "openai-public" || endpointClass === "openai" || endpointClass === "azure-openai";
|
|
117
|
-
const usesKnownNativeOpenAIRoute = endpointClass === "default" ? provider === "openai" : usesKnownNativeOpenAIEndpoint;
|
|
118
|
-
const usesExplicitProxyLikeEndpoint = usesConfiguredBaseUrl && !usesKnownNativeOpenAIEndpoint;
|
|
119
|
-
const promptCacheKeySupport = readCompatPayloadBoolean(model.compat, "supportsPromptCacheKey");
|
|
120
|
-
const shouldStripResponsesPromptCache = promptCacheKeySupport === true ? false : promptCacheKeySupport === false ? isResponsesApi : isResponsesApi && usesExplicitProxyLikeEndpoint;
|
|
121
|
-
const supportsResponsesStoreField = readCompatPayloadBoolean(model.compat, "supportsStore") !== false && isResponsesApi;
|
|
122
|
-
return {
|
|
123
|
-
allowsOpenAIServiceTier: provider === "openai" && (api === "openai-responses" || api === "openclaw-openai-responses-transport") && endpointClass === "openai-public" || isOpenAIProvider && (api === "openai-chatgpt-responses" || api === "openclaw-openai-chatgpt-responses-transport" || api === "openai-responses" || api === "openclaw-openai-responses-transport") && endpointClass === "openai",
|
|
124
|
-
allowsResponsesStore: supportsResponsesStoreField && api !== "openai-chatgpt-responses" && api !== "openclaw-openai-chatgpt-responses-transport" && provider !== void 0 && OPENAI_RESPONSES_PROVIDERS.has(provider) && usesKnownNativeOpenAIEndpoint,
|
|
125
|
-
shouldStripResponsesPromptCache,
|
|
126
|
-
supportsResponsesStoreField,
|
|
127
|
-
usesKnownNativeOpenAIRoute
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
function resolveOpenAIResponsesCompactThreshold(model) {
|
|
131
|
-
const contextTokens = parsePositiveInteger(model.contextTokens);
|
|
132
|
-
const contextWindow = parsePositiveInteger(model.contextWindow);
|
|
133
|
-
const effectiveBudget = contextTokens && contextWindow ? Math.min(contextTokens, contextWindow) : contextTokens || contextWindow;
|
|
134
|
-
if (effectiveBudget) return Math.max(1e3, Math.floor(effectiveBudget * .7));
|
|
135
|
-
return 8e4;
|
|
136
|
-
}
|
|
137
|
-
/** Resolve the server-compaction gate and effective threshold for a Responses route. */
|
|
138
|
-
function resolveOpenAIResponsesServerCompactionPlan(model, extraParams) {
|
|
139
|
-
const provider = normalizeOptionalLowercaseString(model.provider);
|
|
140
|
-
const allowsResponsesStore = resolveOpenAIResponsesPayloadCapabilities(model).allowsResponsesStore;
|
|
141
|
-
const configured = extraParams?.responsesServerCompaction;
|
|
142
|
-
const enabled = configured !== false && allowsResponsesStore && (configured === true || provider === "openai");
|
|
143
|
-
return {
|
|
144
|
-
enabled,
|
|
145
|
-
threshold: enabled ? parsePositiveInteger(extraParams?.responsesCompactThreshold) ?? resolveOpenAIResponsesCompactThreshold(model) : void 0
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
/** Resolve the manual Responses compact-endpoint gate for one route. */
|
|
149
|
-
function resolveOpenAIResponsesCompactEndpointPlan(model, extraParams) {
|
|
150
|
-
const configured = extraParams?.responsesCompactEndpoint;
|
|
151
|
-
const provider = typeof model.provider === "string" ? normalizeProviderId(model.provider) : "";
|
|
152
|
-
return { enabled: isOpenAIResponsesApi(normalizeOptionalLowercaseString(model.api)) && (configured === true || configured !== false && (provider === "xai" || provider === "x-ai") && resolveBundledOpenAIResponsesEndpointClass(model.baseUrl) === "xai-native") };
|
|
153
|
-
}
|
|
154
|
-
function stripDisabledOpenAIReasoningPayload(payloadObj) {
|
|
155
|
-
const reasoning = payloadObj.reasoning;
|
|
156
|
-
if (reasoning === "none") {
|
|
157
|
-
delete payloadObj.reasoning;
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (!reasoning || typeof reasoning !== "object" || Array.isArray(reasoning)) return;
|
|
161
|
-
if (reasoning.effort === "none") delete payloadObj.reasoning;
|
|
162
|
-
}
|
|
163
|
-
/** Strip returned-item metadata rejected by strict Responses-compatible endpoints. */
|
|
164
|
-
function stripInputItemStatuses(input) {
|
|
165
|
-
if (!Array.isArray(input)) return;
|
|
166
|
-
for (const item of input) if (item && typeof item === "object" && !Array.isArray(item)) delete item.status;
|
|
167
|
-
}
|
|
168
|
-
/** Resolve payload mutation policy for one OpenAI Responses-style model endpoint. */
|
|
169
|
-
function resolveOpenAIResponsesPayloadPolicy(model, options = {}) {
|
|
170
|
-
const capabilities = resolveOpenAIResponsesPayloadCapabilities(model);
|
|
171
|
-
const storeMode = options.storeMode ?? "provider-policy";
|
|
172
|
-
const explicitStore = storeMode === "preserve" ? void 0 : storeMode === "disable" ? capabilities.supportsResponsesStoreField ? false : void 0 : capabilities.allowsResponsesStore ? true : void 0;
|
|
173
|
-
const isResponsesApi = isOpenAIResponsesApi(normalizeOptionalLowercaseString(model.api));
|
|
174
|
-
const shouldStripDisabledReasoningPayload = isResponsesApi && (!capabilities.usesKnownNativeOpenAIRoute || !supportsOpenAIReasoningEffort(model, "none"));
|
|
175
|
-
const shouldStripInputStatus = isResponsesApi && !capabilities.usesKnownNativeOpenAIRoute;
|
|
176
|
-
const serverCompactionPlan = resolveOpenAIResponsesServerCompactionPlan(model, options.extraParams);
|
|
177
|
-
return {
|
|
178
|
-
allowsServiceTier: capabilities.allowsOpenAIServiceTier,
|
|
179
|
-
compactThreshold: serverCompactionPlan.threshold,
|
|
180
|
-
explicitStore,
|
|
181
|
-
shouldStripDisabledReasoningPayload,
|
|
182
|
-
shouldStripInputStatus,
|
|
183
|
-
shouldStripPromptCache: options.enablePromptCacheStripping === true && capabilities.shouldStripResponsesPromptCache,
|
|
184
|
-
shouldStripStore: explicitStore !== true && readCompatPayloadBoolean(model.compat, "supportsStore") === false && isResponsesApi,
|
|
185
|
-
useServerCompaction: options.enableServerCompaction === true && serverCompactionPlan.enabled
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
/** Mutate a Responses request payload according to the resolved endpoint policy. */
|
|
189
|
-
function applyOpenAIResponsesPayloadPolicy(payloadObj, policy) {
|
|
190
|
-
if (policy.explicitStore !== void 0) payloadObj.store = policy.explicitStore;
|
|
191
|
-
if (policy.shouldStripStore) delete payloadObj.store;
|
|
192
|
-
if (policy.shouldStripPromptCache) {
|
|
193
|
-
delete payloadObj.prompt_cache_key;
|
|
194
|
-
delete payloadObj.prompt_cache_retention;
|
|
195
|
-
}
|
|
196
|
-
if (policy.useServerCompaction && policy.compactThreshold !== void 0 && payloadObj.context_management === void 0) payloadObj.context_management = [{
|
|
197
|
-
type: "compaction",
|
|
198
|
-
compact_threshold: policy.compactThreshold
|
|
199
|
-
}];
|
|
200
|
-
if (policy.shouldStripDisabledReasoningPayload) stripDisabledOpenAIReasoningPayload(payloadObj);
|
|
201
|
-
if (policy.shouldStripInputStatus) stripInputItemStatuses(payloadObj.input);
|
|
202
|
-
}
|
|
203
|
-
//#endregion
|
|
204
|
-
export { resolveOpenAIResponsesServerCompactionPlan as i, resolveOpenAIResponsesCompactEndpointPlan as n, resolveOpenAIResponsesPayloadPolicy as r, applyOpenAIResponsesPayloadPolicy as t };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//#region packages/ai/src/provider-options.ts
|
|
2
|
-
const CODE_MODE_TOOL_SURFACE_OBSERVER = Symbol("openaiCodeModeToolSurfaceObserver");
|
|
3
|
-
const CODE_MODE_TOOL_SURFACE_COLLECTOR = Symbol("openaiCodeModeToolSurfaceCollector");
|
|
4
|
-
const codeModeToolSurfaceObserver = {
|
|
5
|
-
set(options, observer, collector) {
|
|
6
|
-
Reflect.set(options, CODE_MODE_TOOL_SURFACE_OBSERVER, observer);
|
|
7
|
-
if (collector) Reflect.set(options, CODE_MODE_TOOL_SURFACE_COLLECTOR, collector);
|
|
8
|
-
},
|
|
9
|
-
get(options) {
|
|
10
|
-
if (!options) return;
|
|
11
|
-
const observer = Reflect.get(options, CODE_MODE_TOOL_SURFACE_OBSERVER);
|
|
12
|
-
return typeof observer === "function" ? (observation) => observer(observation) : void 0;
|
|
13
|
-
},
|
|
14
|
-
getCollector(options) {
|
|
15
|
-
if (!options) return;
|
|
16
|
-
const collector = Reflect.get(options, CODE_MODE_TOOL_SURFACE_COLLECTOR);
|
|
17
|
-
return typeof collector === "function" ? (observation) => collector(observation) : void 0;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
export { codeModeToolSurfaceObserver as t };
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
//#region packages/ai/src/utils/tls-certificate-errors.ts
|
|
2
|
-
const HOSTNAME_MISMATCH_CODES = /* @__PURE__ */ new Set(["ERR_TLS_CERT_ALTNAME_INVALID", "HOSTNAME_MISMATCH"]);
|
|
3
|
-
const CERTIFICATE_INVALID_CODES = /* @__PURE__ */ new Set([
|
|
4
|
-
"CERT_CHAIN_TOO_LONG",
|
|
5
|
-
"CERT_HAS_EXPIRED",
|
|
6
|
-
"CERT_NOT_YET_VALID",
|
|
7
|
-
"CERT_REJECTED",
|
|
8
|
-
"CERT_REVOKED",
|
|
9
|
-
"CERT_SIGNATURE_FAILURE",
|
|
10
|
-
"CERT_UNTRUSTED",
|
|
11
|
-
"CRL_HAS_EXPIRED",
|
|
12
|
-
"CRL_NOT_YET_VALID",
|
|
13
|
-
"CRL_SIGNATURE_FAILURE",
|
|
14
|
-
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
15
|
-
"ERROR_IN_CERT_NOT_AFTER_FIELD",
|
|
16
|
-
"ERROR_IN_CERT_NOT_BEFORE_FIELD",
|
|
17
|
-
"ERROR_IN_CRL_LAST_UPDATE_FIELD",
|
|
18
|
-
"ERROR_IN_CRL_NEXT_UPDATE_FIELD",
|
|
19
|
-
"INVALID_CA",
|
|
20
|
-
"INVALID_PURPOSE",
|
|
21
|
-
"PATH_LENGTH_EXCEEDED",
|
|
22
|
-
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
23
|
-
"UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY",
|
|
24
|
-
"UNABLE_TO_DECRYPT_CERT_SIGNATURE",
|
|
25
|
-
"UNABLE_TO_DECRYPT_CRL_SIGNATURE",
|
|
26
|
-
"UNABLE_TO_GET_CRL",
|
|
27
|
-
"UNABLE_TO_GET_ISSUER_CERT",
|
|
28
|
-
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
29
|
-
"UNABLE_TO_VERIFY_LEAF_SIGNATURE"
|
|
30
|
-
]);
|
|
31
|
-
const HOSTNAME_MISMATCH_PATTERNS = [
|
|
32
|
-
/hostname\/ip does not match certificate(?:'s)? altnames/i,
|
|
33
|
-
/hostname mismatch/i,
|
|
34
|
-
/host: .+ is not in the cert(?:ificate)?(?:'s)? altnames/i
|
|
35
|
-
];
|
|
36
|
-
const CERTIFICATE_INVALID_PATTERNS = [
|
|
37
|
-
/certificate has expired/i,
|
|
38
|
-
/certificate is not yet valid/i,
|
|
39
|
-
/self[- ]signed certificate/i,
|
|
40
|
-
/unable to get local issuer certificate/i,
|
|
41
|
-
/unable to verify the first certificate/i
|
|
42
|
-
];
|
|
43
|
-
const MAX_TLS_ERROR_DEPTH = 8;
|
|
44
|
-
function classifyCode(code) {
|
|
45
|
-
if (HOSTNAME_MISMATCH_CODES.has(code)) return "hostname_mismatch";
|
|
46
|
-
return CERTIFICATE_INVALID_CODES.has(code) ? "certificate_invalid" : null;
|
|
47
|
-
}
|
|
48
|
-
function classifyMessage(message) {
|
|
49
|
-
if (HOSTNAME_MISMATCH_PATTERNS.some((pattern) => pattern.test(message))) return "hostname_mismatch";
|
|
50
|
-
return CERTIFICATE_INVALID_PATTERNS.some((pattern) => pattern.test(message)) ? "certificate_invalid" : null;
|
|
51
|
-
}
|
|
52
|
-
function inspectTlsCertificateErrorInternal(error, seen, depth) {
|
|
53
|
-
if (depth > MAX_TLS_ERROR_DEPTH) return null;
|
|
54
|
-
if (typeof error === "string") {
|
|
55
|
-
const kind = classifyMessage(error);
|
|
56
|
-
return kind ? {
|
|
57
|
-
kind,
|
|
58
|
-
message: error
|
|
59
|
-
} : null;
|
|
60
|
-
}
|
|
61
|
-
if (!error || typeof error !== "object" || seen.has(error)) return null;
|
|
62
|
-
seen.add(error);
|
|
63
|
-
const candidate = error;
|
|
64
|
-
const code = typeof candidate.code === "string" ? candidate.code.trim().toUpperCase() : void 0;
|
|
65
|
-
const message = typeof candidate.message === "string" && candidate.message.trim() ? candidate.message : void 0;
|
|
66
|
-
const codeKind = code ? classifyCode(code) : null;
|
|
67
|
-
if (code && codeKind) return {
|
|
68
|
-
kind: codeKind,
|
|
69
|
-
code,
|
|
70
|
-
message: message ?? code
|
|
71
|
-
};
|
|
72
|
-
const nestedErrors = Array.isArray(candidate.errors) ? candidate.errors : [];
|
|
73
|
-
for (const nested of [
|
|
74
|
-
candidate.cause,
|
|
75
|
-
candidate.error,
|
|
76
|
-
...nestedErrors
|
|
77
|
-
]) {
|
|
78
|
-
if (nested === void 0 || nested === error) continue;
|
|
79
|
-
const details = inspectTlsCertificateErrorInternal(nested, seen, depth + 1);
|
|
80
|
-
if (details) return details;
|
|
81
|
-
}
|
|
82
|
-
const messageKind = message ? classifyMessage(message) : null;
|
|
83
|
-
return messageKind && message ? {
|
|
84
|
-
kind: messageKind,
|
|
85
|
-
message
|
|
86
|
-
} : null;
|
|
87
|
-
}
|
|
88
|
-
/** Classify deterministic Node/OpenSSL certificate validation failures. */
|
|
89
|
-
function inspectTlsCertificateError(error) {
|
|
90
|
-
return inspectTlsCertificateErrorInternal(error, /* @__PURE__ */ new Set(), 0);
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
export { inspectTlsCertificateError as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./index-Qbej8io0.mjs";
|