@openclaw/ai 2026.10.10 → 2026.10.33
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 +9 -1
- package/dist/{anthropic-B54Ts1tV.mjs → anthropic-B58ec88k.mjs} +46 -26
- package/dist/{anthropic-payload-policy-rqCq9sT_.d.mts → anthropic-payload-policy-BCp4dUJR.d.mts} +2 -2
- package/dist/{anthropic-stream-reducer-C__ByTq1.mjs → anthropic-stream-reducer-BTcDHWGM.mjs} +11 -11
- package/dist/{anthropic-tool-projection-DA_KeluM.mjs → anthropic-tool-projection-CrsCkF4k.mjs} +1 -1
- package/dist/{anthropic-tool-projection-JTvMo4KG.d.mts → anthropic-tool-projection-CzSSQzZL.d.mts} +1 -1
- package/dist/{api-registry-gDt0faai.d.mts → api-registry-CkmxPPac.d.mts} +1 -1
- package/dist/{assistant-output-DbgdWAhJ.mjs → assistant-output-Hl3b-ViJ.mjs} +3 -3
- package/dist/{azure-openai-responses-DHzTwi-y.mjs → azure-openai-responses-B0Hi9cAV.mjs} +5 -6
- package/dist/{diagnostics-Cv7cW3pS.mjs → diagnostics-v7oVEW59.mjs} +17 -1
- package/dist/diagnostics.d.mts +3 -3
- package/dist/diagnostics.mjs +1 -1
- package/dist/{google-CZ6uGVkV.mjs → google-DuI8TLy0.mjs} +2 -2
- package/dist/{google-interactions-qd4flmND.mjs → google-interactions-9Jd_049M.mjs} +91 -30
- package/dist/{google-messages-B-svbJuN.mjs → google-messages-BWhsZ167.mjs} +9 -3
- package/dist/{google-provider-stream-DlhaCvCf.mjs → google-provider-stream-DL0bXgX5.mjs} +16 -11
- package/dist/{google-shared-Cif7nve-.mjs → google-shared-DXizMtnG.mjs} +6 -5
- package/dist/{google-vertex-BZTcYnWU.mjs → google-vertex-DnjRWo-M.mjs} +2 -2
- package/dist/google-video-slots-D8tPH8wX.mjs +29 -0
- package/dist/{host-jJOffdlW.d.mts → host-B03VqZdH.d.mts} +2 -2
- package/dist/{host-rCxf5Tjd.mjs → host-CyGba3M8.mjs} +111 -88
- package/dist/{host-policy-Ci1cKluf.mjs → host-policy-CNQztzZm.mjs} +1 -1
- package/dist/{index-DSprYWaz.d.mts → index-B8ODIVmA.d.mts} +15 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/internal/anthropic.d.mts +16 -6
- package/dist/internal/anthropic.mjs +6 -6
- package/dist/internal/openai-completions-compat.d.mts +5 -1
- package/dist/internal/openai-completions-compat.mjs +3 -2
- package/dist/internal/openai-responses-payload-policy.d.mts +2 -2
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +8 -8
- package/dist/internal/openai.mjs +9 -9
- package/dist/internal/retry-after.d.mts +2 -2
- package/dist/internal/retry-after.mjs +75 -1
- package/dist/internal/runtime.d.mts +6 -6
- package/dist/internal/runtime.mjs +4 -4
- package/dist/internal/shared.d.mts +3 -3
- package/dist/internal/shared.mjs +2 -2
- package/dist/internal/tool-schema.d.mts +2 -2
- package/dist/internal/tool-schema.mjs +3 -3
- package/dist/{mistral-C_ImzxlK.mjs → mistral-BgamhpFG.mjs} +4 -4
- package/dist/openai-BfFy1nvf.mjs +20077 -0
- package/dist/{openai-chatgpt-responses-iGYDPbmc.mjs → openai-chatgpt-responses-Biu_I7p4.mjs} +14 -19
- package/dist/{openai-completions-CDy5u1mv.mjs → openai-completions-Cbwde_Dr.mjs} +4 -4
- package/dist/{openai-completions-compat-CJ0OXZgi.mjs → openai-completions-compat-D9KEUevM.mjs} +2 -2
- package/dist/{openai-completions-compat-CBvb2eld.d.mts → openai-completions-compat-DTe2EXPi.d.mts} +2 -2
- package/dist/openai-completions-reasoning-replay-BwT1xwRI.mjs +45 -0
- package/dist/openai-completions-transport-RCOvvBq_.mjs +10874 -0
- package/dist/{openai-prompt-cache-h8vXRiaH.mjs → openai-prompt-cache-CAo-Mah6.mjs} +1 -1
- package/dist/{openai-prompt-cache-DgjD-UL5.d.mts → openai-prompt-cache-k7EPMLa0.d.mts} +1 -1
- package/dist/{openai-responses-Cp2QPq7K.mjs → openai-responses-DOgBvvca.mjs} +7 -8
- package/dist/{openai-responses-compaction-replay-DUBbsfku.d.mts → openai-responses-compaction-replay-DOJaDCUl.d.mts} +3 -3
- package/dist/{openai-responses-contracts-DCG51Us0.mjs → openai-responses-contracts-B5mGAbR6.mjs} +1 -1
- package/dist/{openai-responses-contracts-gnl6ZRs1.d.mts → openai-responses-contracts-DHtim7d_.d.mts} +3 -3
- package/dist/{openai-responses-endpoint-JbBT8IDv.mjs → openai-responses-endpoint-DJwbSy3n.mjs} +4 -2
- package/dist/{openai-responses-payload-policy-BzM52TTH.d.mts → openai-responses-payload-policy-cIaYG5ZQ.d.mts} +1 -0
- package/dist/{openai-responses-request-lifecycle-DuMpdA6y.mjs → openai-responses-request-lifecycle-bJ24Q_OK.mjs} +7 -7
- package/dist/{openai-responses-shared-CNfHudFg.mjs → openai-responses-shared-BDGaQxiw.mjs} +1130 -30
- package/dist/{openai-responses-terminal-usage-CpVjkqn-.d.mts → openai-responses-terminal-usage-BDGDBGuA.d.mts} +1 -1
- package/dist/{openai-tool-schema-CGhEl7ao.mjs → openai-tool-schema-D913am3I.mjs} +4 -3
- package/dist/openai.LICENSE +201 -0
- package/dist/{provider-options-Bo8GzTGX.d.mts → provider-options-DFjnfImJ.d.mts} +8 -2
- package/dist/{provider-replay-context-BC23HyZo.mjs → provider-replay-context-C5uMjBz4.mjs} +3 -4
- package/dist/{provider-transport-turn-state-B11rmZpv.mjs → provider-transport-turn-state-CfUfU9v1.mjs} +3 -3
- package/dist/{provider-types-ODq57rG_.d.mts → provider-types-C-67EZr8.d.mts} +5 -3
- package/dist/provider-types.d.mts +3 -3
- package/dist/provider-types.mjs +2 -1
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +10 -10
- package/dist/{reasoning-tag-text-partitioner-DzlRubwU.mjs → reasoning-tag-text-partitioner-CU9A4Lg8.mjs} +2 -13
- package/dist/retry-after-BrmTv0jL.d.mts +25 -0
- package/dist/rolldown-runtime-B4iAMlE-.mjs +35 -0
- package/dist/{sanitize-unicode-ZqVLLEKC.d.mts → sanitize-unicode-CkejzD2f.d.mts} +1 -1
- package/dist/{simple-options-BdJJbzZk.mjs → simple-options-Bd0STwu7.mjs} +3 -3
- package/dist/{src-CyA0zJnt.mjs → src--qsViR3j.mjs} +60 -12
- package/dist/{stream-DQqGjhbq.mjs → stream-BRecd0FZ.mjs} +1 -1
- package/dist/{tool-schema-json-projection-Cvq69Ajp.mjs → tool-schema-json-projection-DU-FFSa7.mjs} +1 -1
- package/dist/{transport-stream-shared-DdnJGEj0.mjs → transport-stream-shared-C1AtJhZA.mjs} +2 -2
- package/dist/{transport-stream-shared-8ru8eX4s.d.mts → transport-stream-shared-Dhx_37f1.d.mts} +1 -1
- package/dist/{transport-utils-CcCAuFVS.mjs → transport-utils-4xPfuKp2.mjs} +2 -2
- package/dist/transports.d.mts +23 -15
- package/dist/transports.mjs +65 -44
- package/dist/types-BFfXm_Jr.d.mts +1 -0
- package/dist/types.d.mts +3 -3
- package/dist/types.mjs +2 -2
- package/dist/ws.LICENSE +20 -0
- package/package.json +1 -1
- package/dist/openai-completions-transport-DLrm5EWi.mjs +0 -3468
- package/dist/retry-after-sw-XX8aC.d.mts +0 -15
- package/dist/types-CBJthzJX.d.mts +0 -1
|
@@ -1,32 +1,1109 @@
|
|
|
1
|
-
import "./src
|
|
1
|
+
import "./src--qsViR3j.mjs";
|
|
2
2
|
import { _ as runtimeContextContentToText, f as hasRuntimeContextMarker, p as isRuntimeContextMessage } from "./types-BXd0kI8-.mjs";
|
|
3
3
|
import { o as readProviderRefusalReview, t as appendAssistantMessageDiagnostic } from "./diagnostics-DzrF1h4J.mjs";
|
|
4
4
|
import { r as appendAssistantThinking } from "./event-stream-X2gmsUWv.mjs";
|
|
5
5
|
import { o as isRecord, r as asOptionalObjectRecord } from "./record-coerce-CNDovvft.mjs";
|
|
6
6
|
import { l as readStringValue, o as normalizeOptionalString, r as normalizeLowercaseStringOrEmpty, s as normalizeStringifiedOptionalString } from "./string-coerce-Cj8sqWHx.mjs";
|
|
7
7
|
import { t as asFiniteNumber } from "./number-coercion-37gmNkuA.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { A as supportsOpenAIReasoningEffort, D as resolveOpenAIReasoningEffortForModel, E as resolveOpenAIModelReasoningEfforts,
|
|
8
|
+
import { A as applyProviderReportedUsageCost, I as isImageWithMediaPayload, M as clampThinkingLevel, a as resolveAiTransportHeaderSentinels, j as calculateCost, k as headersToRecord, r as getAiTransportHost } from "./host-CyGba3M8.mjs";
|
|
9
|
+
import { A as supportsOpenAIReasoningEffort, D as resolveOpenAIReasoningEffortForModel, E as resolveOpenAIModelReasoningEfforts, L as resolveOpenAIThinkingApi, O as resolveOpenAIReasoningEffortMapping, P as MODEL_CATALOG_THINKING_LEVELS, T as normalizeOpenAIReasoningEffort, _ as responsesServiceTierObserver, a as OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE, c as OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE, f as RESPONSES_RETAINED_USER, i as OPENAI_RESPONSES_APIS, j as supportsOpenAITemperature, m as isPreviousResponseRejection, o as OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY, p as RESPONSE_FAILED_NO_DETAILS_MESSAGE, s as OPENAI_RESPONSES_REASONING_REPLAY_META_KEY, v as isResponsesServiceTierRejection, y as nextResponsesServiceTier } from "./openai-responses-contracts-B5mGAbR6.mjs";
|
|
10
10
|
import { n as getSessionResourceOwnerId, r as registerSessionResourceCleanup } from "./session-resources-vKvGIE3J.mjs";
|
|
11
11
|
import { c as stableStringify, s as truncateUtf16Safe } from "./provider-error-qtZD2inE.mjs";
|
|
12
|
-
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-
|
|
13
|
-
import { _ as
|
|
14
|
-
import { a as redactSensitiveText, r as isCodeModeModelVisibleToolName } from "./transport-utils-
|
|
15
|
-
import { c as resolveOpenAIResponsesTextFormat, i as resolveOpenAICompletionsCompat, o as usesNativeOpenAICodexResponsesBackend } from "./openai-completions-compat-
|
|
16
|
-
import { r as resolveModelRequestTimeoutMs } from "./host-policy-
|
|
12
|
+
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-CAo-Mah6.mjs";
|
|
13
|
+
import { _ as mapResponsesTerminalUsage, a as resolveModelPayloadDebugMode, d as ResponsesOutputIdentityError, f as countToolCallTrailingWhitespace, m as isResponsesProviderTool, p as hasOnlyResponsesFunctionTools, r as emitModelTransportDebug, v as readResponsesReasoningTokens, y as resolveResponsesTerminalStopReason } from "./diagnostics-v7oVEW59.mjs";
|
|
14
|
+
import { a as redactSensitiveText, r as isCodeModeModelVisibleToolName } from "./transport-utils-4xPfuKp2.mjs";
|
|
15
|
+
import { c as resolveOpenAIResponsesTextFormat, i as resolveOpenAICompletionsCompat, o as usesNativeOpenAICodexResponsesBackend } from "./openai-completions-compat-D9KEUevM.mjs";
|
|
16
|
+
import { r as resolveModelRequestTimeoutMs } from "./host-policy-CNQztzZm.mjs";
|
|
17
17
|
import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-D_MeCQFI.mjs";
|
|
18
|
-
import { d as extractToolResultBlockText, f as extractToolResultText, h as preparedRequestSuffix, l as describeToolResultMediaPlaceholder, r as clampMaxTokensToModel, s as prepareModelRequestBody, w as stripSystemPromptCacheBoundary } from "./simple-options-
|
|
19
|
-
import { A as shortHash, C as parseJsonObjectPreservingUnsafeIntegers, E as createToolArgumentPreviewSchedule, O as parseStreamingJson, S as withProviderResponseHook, b as transportAbortError, c as failTransportStream, d as iterateModelStream, g as parseTerminalToolCallArguments, m as notifyProviderHttpResponse, t as IncompleteToolCallError, u as finalizeTransportStream, v as sanitizeTransportPayloadText } from "./transport-stream-shared-
|
|
20
|
-
import { C as redactIdentifier, n as prepareRuntimeToolInputSchema, r as projectRuntimeToolInputSchema, w as sha256Hex } from "./tool-schema-json-projection-
|
|
21
|
-
import { n as isProviderReplayContext, r as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-
|
|
22
|
-
import { n as transformProviderMessages } from "./assistant-output-
|
|
18
|
+
import { d as extractToolResultBlockText, f as extractToolResultText, h as preparedRequestSuffix, l as describeToolResultMediaPlaceholder, r as clampMaxTokensToModel, s as prepareModelRequestBody, w as stripSystemPromptCacheBoundary } from "./simple-options-Bd0STwu7.mjs";
|
|
19
|
+
import { A as shortHash, C as parseJsonObjectPreservingUnsafeIntegers, E as createToolArgumentPreviewSchedule, O as parseStreamingJson, S as withProviderResponseHook, b as transportAbortError, c as failTransportStream, d as iterateModelStream, g as parseTerminalToolCallArguments, m as notifyProviderHttpResponse, t as IncompleteToolCallError, u as finalizeTransportStream, v as sanitizeTransportPayloadText } from "./transport-stream-shared-C1AtJhZA.mjs";
|
|
20
|
+
import { C as redactIdentifier, n as prepareRuntimeToolInputSchema, r as projectRuntimeToolInputSchema, w as sha256Hex } from "./tool-schema-json-projection-DU-FFSa7.mjs";
|
|
21
|
+
import { n as isProviderReplayContext, r as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-C5uMjBz4.mjs";
|
|
22
|
+
import { n as transformProviderMessages } from "./assistant-output-Hl3b-ViJ.mjs";
|
|
23
23
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-CfMuh5cC.mjs";
|
|
24
24
|
import { n as resolveOpencodeSessionHeaders } from "./session-affinity-DA4WHv1h.mjs";
|
|
25
25
|
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-D_TfJHRJ.mjs";
|
|
26
|
-
import { a as resolveOpenAIProjectedToolsStrictToolFlag, b as prepareOpenAIFunctionTool, p as withPreparedToolSchemaNormalization, r as normalizeOpenAIStrictToolParameters, t as findOpenAIStrictToolProjectionDiagnostics } from "./openai-tool-schema-
|
|
27
|
-
import { a as isOpenAIResponsesCompactionOutput, n as supportsNativeOpenAIResponsesEndpoint, o as readOpenAIResponsesCompactionWindow } from "./openai-responses-endpoint-
|
|
26
|
+
import { a as resolveOpenAIProjectedToolsStrictToolFlag, b as prepareOpenAIFunctionTool, p as withPreparedToolSchemaNormalization, r as normalizeOpenAIStrictToolParameters, t as findOpenAIStrictToolProjectionDiagnostics } from "./openai-tool-schema-D913am3I.mjs";
|
|
27
|
+
import { a as isOpenAIResponsesCompactionOutput, n as supportsNativeOpenAIResponsesEndpoint, o as readOpenAIResponsesCompactionWindow } from "./openai-responses-endpoint-DJwbSy3n.mjs";
|
|
28
28
|
import { randomUUID } from "node:crypto";
|
|
29
|
-
|
|
29
|
+
//#region node_modules/.pnpm/openai@7.28.0_@aws-sdk+credential-provider-node@3.972.84_@smithy+hash-node@4.5.2_@smith_228c78b5ff380a7908ad856e85d64d8d/node_modules/openai/internal/tslib.mjs
|
|
30
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
31
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
32
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
33
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
34
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
35
|
+
}
|
|
36
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
37
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
38
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
39
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region node_modules/.pnpm/openai@7.28.0_@aws-sdk+credential-provider-node@3.972.84_@smithy+hash-node@4.5.2_@smith_228c78b5ff380a7908ad856e85d64d8d/node_modules/openai/internal/errors.mjs
|
|
43
|
+
function isAbortError(err) {
|
|
44
|
+
return typeof err === "object" && err !== null && ("name" in err && err.name === "AbortError" || "message" in err && String(err.message).includes("FetchRequestCanceledException"));
|
|
45
|
+
}
|
|
46
|
+
const castToError = (err) => {
|
|
47
|
+
if (err instanceof Error) return err;
|
|
48
|
+
if (typeof err === "object" && err !== null) {
|
|
49
|
+
try {
|
|
50
|
+
if (Object.prototype.toString.call(err) === "[object Error]") {
|
|
51
|
+
const hasCause = "cause" in err;
|
|
52
|
+
const error = new Error(err.message, hasCause ? { cause: err.cause } : {});
|
|
53
|
+
if (err.stack) error.stack = err.stack;
|
|
54
|
+
if (hasCause && !Object.prototype.hasOwnProperty.call(error, "cause")) error.cause = err.cause;
|
|
55
|
+
if (err.name) error.name = err.name;
|
|
56
|
+
return error;
|
|
57
|
+
}
|
|
58
|
+
} catch {}
|
|
59
|
+
try {
|
|
60
|
+
return new Error(JSON.stringify(err));
|
|
61
|
+
} catch {}
|
|
62
|
+
}
|
|
63
|
+
return new Error(err);
|
|
64
|
+
};
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region node_modules/.pnpm/openai@7.28.0_@aws-sdk+credential-provider-node@3.972.84_@smithy+hash-node@4.5.2_@smith_228c78b5ff380a7908ad856e85d64d8d/node_modules/openai/core/error.mjs
|
|
67
|
+
var OpenAIError = class extends Error {};
|
|
68
|
+
var APIError = class APIError extends OpenAIError {
|
|
69
|
+
constructor(status, error, message, headers) {
|
|
70
|
+
super(`${APIError.makeMessage(status, error, message)}`);
|
|
71
|
+
this.status = status;
|
|
72
|
+
this.headers = headers;
|
|
73
|
+
this.requestID = headers?.get("x-request-id");
|
|
74
|
+
this.error = error;
|
|
75
|
+
const data = error;
|
|
76
|
+
this.code = data?.["code"];
|
|
77
|
+
this.param = data?.["param"];
|
|
78
|
+
this.type = data?.["type"];
|
|
79
|
+
}
|
|
80
|
+
static makeMessage(status, error, message) {
|
|
81
|
+
const msg = error?.message ? typeof error.message === "string" ? error.message : JSON.stringify(error.message) : error ? JSON.stringify(error) : message;
|
|
82
|
+
if (status && msg) return `${status} ${msg}`;
|
|
83
|
+
if (status) return `${status} status code (no body)`;
|
|
84
|
+
if (msg) return msg;
|
|
85
|
+
return "(no status code or body)";
|
|
86
|
+
}
|
|
87
|
+
static generate(status, errorResponse, message, headers) {
|
|
88
|
+
if (!status || !headers) return new APIConnectionError({
|
|
89
|
+
message,
|
|
90
|
+
cause: castToError(errorResponse)
|
|
91
|
+
});
|
|
92
|
+
const error = errorResponse?.["error"];
|
|
93
|
+
if (status === 400) return new BadRequestError(status, error, message, headers);
|
|
94
|
+
if (status === 401) return new AuthenticationError(status, error, message, headers);
|
|
95
|
+
if (status === 403) return new PermissionDeniedError(status, error, message, headers);
|
|
96
|
+
if (status === 404) return new NotFoundError(status, error, message, headers);
|
|
97
|
+
if (status === 409) return new ConflictError(status, error, message, headers);
|
|
98
|
+
if (status === 422) return new UnprocessableEntityError(status, error, message, headers);
|
|
99
|
+
if (status === 429) return new RateLimitError(status, error, message, headers);
|
|
100
|
+
if (status >= 500) return new InternalServerError(status, error, message, headers);
|
|
101
|
+
return new APIError(status, error, message, headers);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var APIUserAbortError = class extends APIError {
|
|
105
|
+
constructor({ message } = {}) {
|
|
106
|
+
super(void 0, void 0, message || "Request was aborted.", void 0);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var APIConnectionError = class extends APIError {
|
|
110
|
+
constructor({ message, cause }) {
|
|
111
|
+
super(void 0, void 0, message || "Connection error.", void 0);
|
|
112
|
+
if (cause) this.cause = cause;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
var APIConnectionTimeoutError = class extends APIConnectionError {
|
|
116
|
+
constructor({ message } = {}) {
|
|
117
|
+
super({ message: message ?? "Request timed out." });
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
var BadRequestError = class extends APIError {};
|
|
121
|
+
var AuthenticationError = class extends APIError {};
|
|
122
|
+
var PermissionDeniedError = class extends APIError {};
|
|
123
|
+
var NotFoundError = class extends APIError {};
|
|
124
|
+
var ConflictError = class extends APIError {};
|
|
125
|
+
var UnprocessableEntityError = class extends APIError {};
|
|
126
|
+
var RateLimitError = class extends APIError {};
|
|
127
|
+
var InternalServerError = class extends APIError {};
|
|
128
|
+
var LengthFinishReasonError = class extends OpenAIError {
|
|
129
|
+
constructor() {
|
|
130
|
+
super(`Could not parse response content as the length limit was reached`);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
var ContentFilterFinishReasonError = class extends OpenAIError {
|
|
134
|
+
constructor() {
|
|
135
|
+
super(`Could not parse response content as the request was rejected by the content filter`);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
var InvalidWebhookSignatureError = class extends Error {
|
|
139
|
+
constructor(message) {
|
|
140
|
+
super(message);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Error thrown by the API server during OAuth token exchange.
|
|
145
|
+
* Can have status codes 400, 401, or 403.
|
|
146
|
+
* Other status codes from OAuth endpoints are raised as normal APIError types.
|
|
147
|
+
*/
|
|
148
|
+
var OAuthError = class extends APIError {
|
|
149
|
+
constructor(status, error, headers) {
|
|
150
|
+
let finalMessage = "OAuth2 authentication error";
|
|
151
|
+
let error_code = void 0;
|
|
152
|
+
if (error && typeof error === "object") {
|
|
153
|
+
const errorData = error;
|
|
154
|
+
error_code = errorData["error"];
|
|
155
|
+
const description = errorData["error_description"];
|
|
156
|
+
if (description && typeof description === "string") finalMessage = description;
|
|
157
|
+
else if (error_code) finalMessage = error_code;
|
|
158
|
+
}
|
|
159
|
+
super(status, error, finalMessage, headers);
|
|
160
|
+
this.error_code = error_code;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
var SubjectTokenProviderError = class extends OpenAIError {
|
|
164
|
+
constructor(message, provider, cause) {
|
|
165
|
+
super(message);
|
|
166
|
+
this.provider = provider;
|
|
167
|
+
this.cause = cause;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region node_modules/.pnpm/openai@7.28.0_@aws-sdk+credential-provider-node@3.972.84_@smithy+hash-node@4.5.2_@smith_228c78b5ff380a7908ad856e85d64d8d/node_modules/openai/internal/utils/values.mjs
|
|
172
|
+
const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
|
|
173
|
+
const isAbsoluteURL = (url) => {
|
|
174
|
+
return startsWithSchemeRegexp.test(url);
|
|
175
|
+
};
|
|
176
|
+
let isArray = (val) => (isArray = Array.isArray, isArray(val));
|
|
177
|
+
let isReadonlyArray = isArray;
|
|
178
|
+
/** Returns an object if the given value isn't an object, otherwise returns as-is */
|
|
179
|
+
function maybeObj(x) {
|
|
180
|
+
if (typeof x !== "object") return {};
|
|
181
|
+
return x ?? {};
|
|
182
|
+
}
|
|
183
|
+
function isEmptyObj(obj) {
|
|
184
|
+
if (!obj) return true;
|
|
185
|
+
for (const _k in obj) return false;
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
function hasOwn(obj, key) {
|
|
189
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
190
|
+
}
|
|
191
|
+
function isObj(obj) {
|
|
192
|
+
return obj != null && typeof obj === "object" && !Array.isArray(obj);
|
|
193
|
+
}
|
|
194
|
+
const validatePositiveInteger = (name, n) => {
|
|
195
|
+
if (typeof n !== "number" || !Number.isInteger(n)) throw new OpenAIError(`${name} must be an integer`);
|
|
196
|
+
if (n < 0) throw new OpenAIError(`${name} must be a positive integer`);
|
|
197
|
+
return n;
|
|
198
|
+
};
|
|
199
|
+
const safeJSON = (text) => {
|
|
200
|
+
try {
|
|
201
|
+
return JSON.parse(text);
|
|
202
|
+
} catch (err) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region node_modules/.pnpm/openai@7.28.0_@aws-sdk+credential-provider-node@3.972.84_@smithy+hash-node@4.5.2_@smith_228c78b5ff380a7908ad856e85d64d8d/node_modules/openai/internal/shims.mjs
|
|
208
|
+
/**
|
|
209
|
+
* This module provides internal shims and utility functions for environments where certain Node.js or global types may not be available.
|
|
210
|
+
*
|
|
211
|
+
* These are used to ensure we can provide a consistent behaviour between different JavaScript environments and good error
|
|
212
|
+
* messages in cases where an environment isn't fully supported.
|
|
213
|
+
*/
|
|
214
|
+
function getDefaultFetch() {
|
|
215
|
+
if (typeof fetch !== "undefined") return fetch;
|
|
216
|
+
throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`");
|
|
217
|
+
}
|
|
218
|
+
function makeReadableStream(...args) {
|
|
219
|
+
const ReadableStream = globalThis.ReadableStream;
|
|
220
|
+
if (typeof ReadableStream === "undefined") throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");
|
|
221
|
+
return new ReadableStream(...args);
|
|
222
|
+
}
|
|
223
|
+
function ReadableStreamFrom(iterable) {
|
|
224
|
+
let iter = Symbol.asyncIterator in iterable ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
|
|
225
|
+
return makeReadableStream({
|
|
226
|
+
start() {},
|
|
227
|
+
async pull(controller) {
|
|
228
|
+
const { done, value } = await iter.next();
|
|
229
|
+
if (done) controller.close();
|
|
230
|
+
else controller.enqueue(value);
|
|
231
|
+
},
|
|
232
|
+
async cancel() {
|
|
233
|
+
await iter.return?.();
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Most browsers don't yet have async iterable support for ReadableStream,
|
|
239
|
+
* and Node has a very different way of reading bytes from its "ReadableStream".
|
|
240
|
+
*
|
|
241
|
+
* This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
|
|
242
|
+
*/
|
|
243
|
+
function ReadableStreamToAsyncIterable(stream) {
|
|
244
|
+
if (stream[Symbol.asyncIterator]) return stream;
|
|
245
|
+
const reader = stream.getReader();
|
|
246
|
+
return {
|
|
247
|
+
async next() {
|
|
248
|
+
try {
|
|
249
|
+
const result = await reader.read();
|
|
250
|
+
if (result?.done) reader.releaseLock();
|
|
251
|
+
return result;
|
|
252
|
+
} catch (e) {
|
|
253
|
+
reader.releaseLock();
|
|
254
|
+
throw e;
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
async return() {
|
|
258
|
+
const cancelPromise = reader.cancel();
|
|
259
|
+
reader.releaseLock();
|
|
260
|
+
await cancelPromise;
|
|
261
|
+
return {
|
|
262
|
+
done: true,
|
|
263
|
+
value: void 0
|
|
264
|
+
};
|
|
265
|
+
},
|
|
266
|
+
[Symbol.asyncIterator]() {
|
|
267
|
+
return this;
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Cancels a ReadableStream we don't need to consume.
|
|
273
|
+
* See https://undici.nodejs.org/#/?id=garbage-collection
|
|
274
|
+
*/
|
|
275
|
+
async function CancelReadableStream(stream) {
|
|
276
|
+
if (stream === null || typeof stream !== "object") return;
|
|
277
|
+
if (stream[Symbol.asyncIterator]) {
|
|
278
|
+
await stream[Symbol.asyncIterator]().return?.();
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const reader = stream.getReader();
|
|
282
|
+
const cancelPromise = reader.cancel();
|
|
283
|
+
reader.releaseLock();
|
|
284
|
+
await cancelPromise;
|
|
285
|
+
}
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region node_modules/.pnpm/openai@7.28.0_@aws-sdk+credential-provider-node@3.972.84_@smithy+hash-node@4.5.2_@smith_228c78b5ff380a7908ad856e85d64d8d/node_modules/openai/internal/utils/bytes.mjs
|
|
288
|
+
let encodeUTF8_;
|
|
289
|
+
/** Encodes text as UTF-8 bytes, reusing the platform encoder after its first call. */
|
|
290
|
+
function encodeUTF8(str) {
|
|
291
|
+
let encoder;
|
|
292
|
+
return (encodeUTF8_ ?? (encoder = new globalThis.TextEncoder(), encodeUTF8_ = encoder.encode.bind(encoder)))(str);
|
|
293
|
+
}
|
|
294
|
+
let decodeUTF8_;
|
|
295
|
+
/** Decodes UTF-8 bytes as text, reusing the platform decoder after its first call. */
|
|
296
|
+
function decodeUTF8(bytes) {
|
|
297
|
+
let decoder;
|
|
298
|
+
return (decodeUTF8_ ?? (decoder = new globalThis.TextDecoder(), decodeUTF8_ = decoder.decode.bind(decoder)))(bytes);
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region node_modules/.pnpm/openai@7.28.0_@aws-sdk+credential-provider-node@3.972.84_@smithy+hash-node@4.5.2_@smith_228c78b5ff380a7908ad856e85d64d8d/node_modules/openai/internal/decoders/line.mjs
|
|
302
|
+
var _LineDecoder_instances;
|
|
303
|
+
var _LineDecoder_buffer;
|
|
304
|
+
var _LineDecoder_start;
|
|
305
|
+
var _LineDecoder_end;
|
|
306
|
+
var _LineDecoder_searchIndex;
|
|
307
|
+
var _LineDecoder_skipLeadingLF;
|
|
308
|
+
var _LineDecoder_append;
|
|
309
|
+
/** Maximum backing-buffer capacity retained when completed lines leave little active data. */
|
|
310
|
+
const MAX_RETAINED_BUFFER_BYTES = 65536;
|
|
311
|
+
/**
|
|
312
|
+
* Incrementally decodes UTF-8 text into lines without losing partial characters
|
|
313
|
+
* or newline sequences that span multiple chunks.
|
|
314
|
+
*
|
|
315
|
+
* Supports `\n`, `\r`, and `\r\n` line endings. Call {@link flush} after the
|
|
316
|
+
* final chunk to emit a trailing line that does not end with a newline.
|
|
317
|
+
*
|
|
318
|
+
* Based on the line decoder used by the Python `httpx` project:
|
|
319
|
+
* https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
|
|
320
|
+
*/
|
|
321
|
+
var LineDecoder = class {
|
|
322
|
+
/** Creates a decoder with no buffered bytes or pending newline continuation. */
|
|
323
|
+
constructor() {
|
|
324
|
+
_LineDecoder_instances.add(this);
|
|
325
|
+
_LineDecoder_buffer.set(this, void 0);
|
|
326
|
+
_LineDecoder_start.set(this, void 0);
|
|
327
|
+
_LineDecoder_end.set(this, void 0);
|
|
328
|
+
_LineDecoder_searchIndex.set(this, void 0);
|
|
329
|
+
_LineDecoder_skipLeadingLF.set(this, void 0);
|
|
330
|
+
__classPrivateFieldSet(this, _LineDecoder_buffer, /* @__PURE__ */ new Uint8Array(), "f");
|
|
331
|
+
__classPrivateFieldSet(this, _LineDecoder_start, 0, "f");
|
|
332
|
+
__classPrivateFieldSet(this, _LineDecoder_end, 0, "f");
|
|
333
|
+
__classPrivateFieldSet(this, _LineDecoder_searchIndex, 0, "f");
|
|
334
|
+
__classPrivateFieldSet(this, _LineDecoder_skipLeadingLF, false, "f");
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Appends a text or UTF-8 byte chunk and returns every newly completed line.
|
|
338
|
+
*
|
|
339
|
+
* Incomplete lines remain buffered for the next call. A trailing `\r`
|
|
340
|
+
* completes its line immediately, and a following `\n` is consumed as its
|
|
341
|
+
* continuation. `null` and `undefined` are ignored and do not flush buffered
|
|
342
|
+
* content.
|
|
343
|
+
*/
|
|
344
|
+
decode(chunk) {
|
|
345
|
+
if (chunk == null) return [];
|
|
346
|
+
let binaryChunk;
|
|
347
|
+
if (chunk instanceof ArrayBuffer) binaryChunk = new Uint8Array(chunk);
|
|
348
|
+
else if (typeof chunk === "string") binaryChunk = encodeUTF8(chunk);
|
|
349
|
+
else binaryChunk = chunk;
|
|
350
|
+
if (binaryChunk.length === 0) return [];
|
|
351
|
+
if (__classPrivateFieldGet(this, _LineDecoder_skipLeadingLF, "f")) {
|
|
352
|
+
__classPrivateFieldSet(this, _LineDecoder_skipLeadingLF, false, "f");
|
|
353
|
+
if (binaryChunk[0] === 10) binaryChunk = binaryChunk.subarray(1);
|
|
354
|
+
if (binaryChunk.length === 0) return [];
|
|
355
|
+
}
|
|
356
|
+
__classPrivateFieldGet(this, _LineDecoder_instances, "m", _LineDecoder_append).call(this, binaryChunk);
|
|
357
|
+
const lines = [];
|
|
358
|
+
let patternIndex;
|
|
359
|
+
while ((patternIndex = findNewlineIndex(__classPrivateFieldGet(this, _LineDecoder_buffer, "f"), __classPrivateFieldGet(this, _LineDecoder_searchIndex, "f"), __classPrivateFieldGet(this, _LineDecoder_end, "f"))) != null) {
|
|
360
|
+
const line = decodeUTF8(__classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(__classPrivateFieldGet(this, _LineDecoder_start, "f"), patternIndex.preceding));
|
|
361
|
+
lines.push(line);
|
|
362
|
+
__classPrivateFieldSet(this, _LineDecoder_start, patternIndex.index, "f");
|
|
363
|
+
if (patternIndex.carriage) {
|
|
364
|
+
if (__classPrivateFieldGet(this, _LineDecoder_start, "f") < __classPrivateFieldGet(this, _LineDecoder_end, "f") && __classPrivateFieldGet(this, _LineDecoder_buffer, "f")[__classPrivateFieldGet(this, _LineDecoder_start, "f")] === 10) __classPrivateFieldSet(this, _LineDecoder_start, __classPrivateFieldGet(this, _LineDecoder_start, "f") + 1, "f");
|
|
365
|
+
else if (__classPrivateFieldGet(this, _LineDecoder_start, "f") === __classPrivateFieldGet(this, _LineDecoder_end, "f")) __classPrivateFieldSet(this, _LineDecoder_skipLeadingLF, true, "f");
|
|
366
|
+
}
|
|
367
|
+
__classPrivateFieldSet(this, _LineDecoder_searchIndex, __classPrivateFieldGet(this, _LineDecoder_start, "f"), "f");
|
|
368
|
+
}
|
|
369
|
+
__classPrivateFieldSet(this, _LineDecoder_searchIndex, __classPrivateFieldGet(this, _LineDecoder_end, "f"), "f");
|
|
370
|
+
if (__classPrivateFieldGet(this, _LineDecoder_start, "f") === __classPrivateFieldGet(this, _LineDecoder_end, "f")) {
|
|
371
|
+
__classPrivateFieldSet(this, _LineDecoder_start, 0, "f");
|
|
372
|
+
__classPrivateFieldSet(this, _LineDecoder_end, 0, "f");
|
|
373
|
+
__classPrivateFieldSet(this, _LineDecoder_searchIndex, 0, "f");
|
|
374
|
+
if (__classPrivateFieldGet(this, _LineDecoder_buffer, "f").length > MAX_RETAINED_BUFFER_BYTES) __classPrivateFieldSet(this, _LineDecoder_buffer, /* @__PURE__ */ new Uint8Array(), "f");
|
|
375
|
+
} else if (lines.length > 0 && __classPrivateFieldGet(this, _LineDecoder_buffer, "f").length > MAX_RETAINED_BUFFER_BYTES) {
|
|
376
|
+
const length = __classPrivateFieldGet(this, _LineDecoder_end, "f") - __classPrivateFieldGet(this, _LineDecoder_start, "f");
|
|
377
|
+
if (length <= MAX_RETAINED_BUFFER_BYTES || __classPrivateFieldGet(this, _LineDecoder_buffer, "f").length > length * 4) {
|
|
378
|
+
const capacity = length <= MAX_RETAINED_BUFFER_BYTES ? Math.min(Math.max(length * 2, 256), MAX_RETAINED_BUFFER_BYTES) : length * 2;
|
|
379
|
+
const buffer = new Uint8Array(capacity);
|
|
380
|
+
buffer.set(__classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(__classPrivateFieldGet(this, _LineDecoder_start, "f"), __classPrivateFieldGet(this, _LineDecoder_end, "f")));
|
|
381
|
+
__classPrivateFieldSet(this, _LineDecoder_buffer, buffer, "f");
|
|
382
|
+
__classPrivateFieldSet(this, _LineDecoder_start, 0, "f");
|
|
383
|
+
__classPrivateFieldSet(this, _LineDecoder_end, length, "f");
|
|
384
|
+
__classPrivateFieldSet(this, _LineDecoder_searchIndex, length, "f");
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return lines;
|
|
388
|
+
}
|
|
389
|
+
/** Emits the remaining unterminated line, or returns an empty array when idle. */
|
|
390
|
+
flush() {
|
|
391
|
+
__classPrivateFieldSet(this, _LineDecoder_skipLeadingLF, false, "f");
|
|
392
|
+
if (__classPrivateFieldGet(this, _LineDecoder_start, "f") === __classPrivateFieldGet(this, _LineDecoder_end, "f")) return [];
|
|
393
|
+
return this.decode("\n");
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
_LineDecoder_buffer = /* @__PURE__ */ new WeakMap(), _LineDecoder_start = /* @__PURE__ */ new WeakMap(), _LineDecoder_end = /* @__PURE__ */ new WeakMap(), _LineDecoder_searchIndex = /* @__PURE__ */ new WeakMap(), _LineDecoder_skipLeadingLF = /* @__PURE__ */ new WeakMap(), _LineDecoder_instances = /* @__PURE__ */ new WeakSet(), _LineDecoder_append = function _LineDecoder_append(chunk) {
|
|
397
|
+
if (__classPrivateFieldGet(this, _LineDecoder_end, "f") + chunk.length > __classPrivateFieldGet(this, _LineDecoder_buffer, "f").length) {
|
|
398
|
+
const length = __classPrivateFieldGet(this, _LineDecoder_end, "f") - __classPrivateFieldGet(this, _LineDecoder_start, "f");
|
|
399
|
+
if (__classPrivateFieldGet(this, _LineDecoder_start, "f") >= __classPrivateFieldGet(this, _LineDecoder_buffer, "f").length / 2 && length + chunk.length <= __classPrivateFieldGet(this, _LineDecoder_buffer, "f").length) __classPrivateFieldGet(this, _LineDecoder_buffer, "f").copyWithin(0, __classPrivateFieldGet(this, _LineDecoder_start, "f"), __classPrivateFieldGet(this, _LineDecoder_end, "f"));
|
|
400
|
+
else {
|
|
401
|
+
const capacity = Math.max(__classPrivateFieldGet(this, _LineDecoder_buffer, "f").length * 2, length + chunk.length, 256);
|
|
402
|
+
const buffer = new Uint8Array(capacity);
|
|
403
|
+
buffer.set(__classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(__classPrivateFieldGet(this, _LineDecoder_start, "f"), __classPrivateFieldGet(this, _LineDecoder_end, "f")));
|
|
404
|
+
__classPrivateFieldSet(this, _LineDecoder_buffer, buffer, "f");
|
|
405
|
+
}
|
|
406
|
+
__classPrivateFieldSet(this, _LineDecoder_searchIndex, __classPrivateFieldGet(this, _LineDecoder_searchIndex, "f") - __classPrivateFieldGet(this, _LineDecoder_start, "f"), "f");
|
|
407
|
+
__classPrivateFieldSet(this, _LineDecoder_end, length, "f");
|
|
408
|
+
__classPrivateFieldSet(this, _LineDecoder_start, 0, "f");
|
|
409
|
+
}
|
|
410
|
+
__classPrivateFieldGet(this, _LineDecoder_buffer, "f").set(chunk, __classPrivateFieldGet(this, _LineDecoder_end, "f"));
|
|
411
|
+
__classPrivateFieldSet(this, _LineDecoder_end, __classPrivateFieldGet(this, _LineDecoder_end, "f") + chunk.length, "f");
|
|
412
|
+
};
|
|
413
|
+
/** Individual characters recognized as possible line terminators. */
|
|
414
|
+
LineDecoder.NEWLINE_CHARS = /* @__PURE__ */ new Set(["\n", "\r"]);
|
|
415
|
+
/** Matches complete CRLF terminators as well as standalone CR and LF characters. */
|
|
416
|
+
LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
417
|
+
/**
|
|
418
|
+
* Searches the active buffer range for the next CR or LF byte and returns its
|
|
419
|
+
* zero-based position, the position immediately after it, and whether the byte
|
|
420
|
+
* was a carriage return. Returns `null` when the range contains no newline byte.
|
|
421
|
+
*
|
|
422
|
+
* ```ts
|
|
423
|
+
* findNewlineIndex(new TextEncoder().encode('abc\ndef'), 0, 7)
|
|
424
|
+
* // => { preceding: 3, index: 4, carriage: false }
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
function findNewlineIndex(buffer, start, end) {
|
|
428
|
+
const newline = 10;
|
|
429
|
+
const carriage = 13;
|
|
430
|
+
for (let i = start; i < end; i++) {
|
|
431
|
+
if (buffer[i] === newline) return {
|
|
432
|
+
preceding: i,
|
|
433
|
+
index: i + 1,
|
|
434
|
+
carriage: false
|
|
435
|
+
};
|
|
436
|
+
if (buffer[i] === carriage) return {
|
|
437
|
+
preceding: i,
|
|
438
|
+
index: i + 1,
|
|
439
|
+
carriage: true
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Finds the first blank-line separator used to delimit streamed event records.
|
|
446
|
+
*
|
|
447
|
+
* @returns The byte offset immediately after the first pair of consecutive
|
|
448
|
+
* line endings, or `-1` when the buffer contains no complete separator.
|
|
449
|
+
*/
|
|
450
|
+
function findDoubleNewlineIndex(buffer) {
|
|
451
|
+
for (let i = 0; i < buffer.length - 1; i++) {
|
|
452
|
+
const firstEndingLength = lineEndingLength(buffer, i);
|
|
453
|
+
if (firstEndingLength > 0) {
|
|
454
|
+
const secondEndingIndex = i + firstEndingLength;
|
|
455
|
+
const secondEndingLength = lineEndingLength(buffer, secondEndingIndex);
|
|
456
|
+
if (secondEndingLength > 0) return secondEndingIndex + secondEndingLength;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return -1;
|
|
460
|
+
}
|
|
461
|
+
function lineEndingLength(buffer, index) {
|
|
462
|
+
const newline = 10;
|
|
463
|
+
const carriage = 13;
|
|
464
|
+
if (buffer[index] === newline) return 1;
|
|
465
|
+
if (buffer[index] === carriage) return buffer[index + 1] === newline ? 2 : 1;
|
|
466
|
+
return 0;
|
|
467
|
+
}
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region node_modules/.pnpm/openai@7.28.0_@aws-sdk+credential-provider-node@3.972.84_@smithy+hash-node@4.5.2_@smith_228c78b5ff380a7908ad856e85d64d8d/node_modules/openai/internal/utils/log.mjs
|
|
470
|
+
const levelNumbers = {
|
|
471
|
+
off: 0,
|
|
472
|
+
error: 200,
|
|
473
|
+
warn: 300,
|
|
474
|
+
info: 400,
|
|
475
|
+
debug: 500
|
|
476
|
+
};
|
|
477
|
+
const parseLogLevel = (maybeLevel, sourceName, client) => {
|
|
478
|
+
if (!maybeLevel) return;
|
|
479
|
+
if (hasOwn(levelNumbers, maybeLevel)) return maybeLevel;
|
|
480
|
+
loggerFor(client).warn(`${sourceName} was set to ${JSON.stringify(maybeLevel)}, expected one of ${JSON.stringify(Object.keys(levelNumbers))}`);
|
|
481
|
+
};
|
|
482
|
+
function noop() {}
|
|
483
|
+
function makeLogFn(fnLevel, logger, logLevel) {
|
|
484
|
+
if (!logger || levelNumbers[fnLevel] > levelNumbers[logLevel]) return noop;
|
|
485
|
+
else return logger[fnLevel].bind(logger);
|
|
486
|
+
}
|
|
487
|
+
const noopLogger = {
|
|
488
|
+
error: noop,
|
|
489
|
+
warn: noop,
|
|
490
|
+
info: noop,
|
|
491
|
+
debug: noop
|
|
492
|
+
};
|
|
493
|
+
let cachedLoggers = /* @__PURE__ */ new WeakMap();
|
|
494
|
+
function loggerFor(client) {
|
|
495
|
+
const logger = client.logger;
|
|
496
|
+
const logLevel = client.logLevel ?? "off";
|
|
497
|
+
if (!logger) return noopLogger;
|
|
498
|
+
const cachedLogger = cachedLoggers.get(logger);
|
|
499
|
+
if (cachedLogger && cachedLogger[0] === logLevel) return cachedLogger[1];
|
|
500
|
+
const levelLogger = {
|
|
501
|
+
error: makeLogFn("error", logger, logLevel),
|
|
502
|
+
warn: makeLogFn("warn", logger, logLevel),
|
|
503
|
+
info: makeLogFn("info", logger, logLevel),
|
|
504
|
+
debug: makeLogFn("debug", logger, logLevel)
|
|
505
|
+
};
|
|
506
|
+
cachedLoggers.set(logger, [logLevel, levelLogger]);
|
|
507
|
+
return levelLogger;
|
|
508
|
+
}
|
|
509
|
+
const sensitiveQueryNames = /* @__PURE__ */ new Set([
|
|
510
|
+
"apikey",
|
|
511
|
+
"accesstoken",
|
|
512
|
+
"refreshtoken",
|
|
513
|
+
"sessiontoken",
|
|
514
|
+
"sessionid",
|
|
515
|
+
"idtoken",
|
|
516
|
+
"authtoken",
|
|
517
|
+
"authorization",
|
|
518
|
+
"token",
|
|
519
|
+
"password",
|
|
520
|
+
"clientsecret",
|
|
521
|
+
"signingsecret",
|
|
522
|
+
"xamzsecuritytoken",
|
|
523
|
+
"xamzsignature",
|
|
524
|
+
"xamzcredential"
|
|
525
|
+
]);
|
|
526
|
+
/** Recognizes credential-bearing query names across ordinary and provider authentication. */
|
|
527
|
+
function isSensitiveQueryParameter(name) {
|
|
528
|
+
const normalized = name.toLowerCase().replace(/[-_]/gu, "");
|
|
529
|
+
return sensitiveQueryNames.has(normalized) || sensitiveQueryNames.has(normalized.replace(/^x/u, ""));
|
|
530
|
+
}
|
|
531
|
+
const sensitiveHeaderNames = /* @__PURE__ */ new Set([
|
|
532
|
+
"authorization",
|
|
533
|
+
"proxy-authorization",
|
|
534
|
+
"api-key",
|
|
535
|
+
"x-api-key",
|
|
536
|
+
"x-amz-security-token",
|
|
537
|
+
"cookie",
|
|
538
|
+
"set-cookie",
|
|
539
|
+
"x-session-token",
|
|
540
|
+
"x-session-id",
|
|
541
|
+
"x-auth-token",
|
|
542
|
+
"x-id-token"
|
|
543
|
+
]);
|
|
544
|
+
/** Recognizes credential-bearing request headers across provider and workload authentication. */
|
|
545
|
+
function isSensitiveHeader(name) {
|
|
546
|
+
return sensitiveHeaderNames.has(name.toLowerCase().replace(/_/gu, "-")) || isSensitiveQueryParameter(name);
|
|
547
|
+
}
|
|
548
|
+
/** Removes credential-valued query parameters before a request URL reaches any logger. */
|
|
549
|
+
function redactURL(value) {
|
|
550
|
+
const url = new URL(value);
|
|
551
|
+
url.username = "";
|
|
552
|
+
url.password = "";
|
|
553
|
+
url.hash = "";
|
|
554
|
+
for (const name of url.searchParams.keys()) if (isSensitiveQueryParameter(name)) url.searchParams.set(name, "***");
|
|
555
|
+
return url.href;
|
|
556
|
+
}
|
|
557
|
+
const formatRequestDetails = (details) => {
|
|
558
|
+
if (details.options) {
|
|
559
|
+
details.options = { ...details.options };
|
|
560
|
+
delete details.options["headers"];
|
|
561
|
+
if (details.options.path) {
|
|
562
|
+
const path = details.options.path;
|
|
563
|
+
const redacted = new URL(redactURL(new URL(path, "https://redacted.invalid").href));
|
|
564
|
+
details.options.path = redacted.origin === "https://redacted.invalid" ? `${path.startsWith("/") ? "/" : ""}${redacted.pathname.slice(1)}${redacted.search}` : redacted.href;
|
|
565
|
+
}
|
|
566
|
+
if (details.options.query) details.options.query = Object.fromEntries(Object.entries(details.options.query).map(([name, value]) => [name, isSensitiveQueryParameter(name) ? "***" : value]));
|
|
567
|
+
}
|
|
568
|
+
if (details.url) details.url = redactURL(details.url);
|
|
569
|
+
if (details.headers) details.headers = Object.fromEntries((details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map(([name, value]) => [name, isSensitiveHeader(name) ? "***" : value]));
|
|
570
|
+
if ("retryOfRequestLogID" in details) {
|
|
571
|
+
if (details.retryOfRequestLogID) details.retryOf = details.retryOfRequestLogID;
|
|
572
|
+
delete details.retryOfRequestLogID;
|
|
573
|
+
}
|
|
574
|
+
return details;
|
|
575
|
+
};
|
|
576
|
+
//#endregion
|
|
577
|
+
//#region node_modules/.pnpm/openai@7.28.0_@aws-sdk+credential-provider-node@3.972.84_@smithy+hash-node@4.5.2_@smith_228c78b5ff380a7908ad856e85d64d8d/node_modules/openai/core/streaming.mjs
|
|
578
|
+
var _Stream_instances;
|
|
579
|
+
var _Stream_client;
|
|
580
|
+
var _Stream_isTeeBranch;
|
|
581
|
+
var _Stream_cancelIterator;
|
|
582
|
+
function isTransportAbortError(error) {
|
|
583
|
+
return !(error instanceof APIError) && isAbortError(error);
|
|
584
|
+
}
|
|
585
|
+
function createStreamTeeQueue() {
|
|
586
|
+
let entries = [];
|
|
587
|
+
let head = 0;
|
|
588
|
+
let canceled = false;
|
|
589
|
+
return {
|
|
590
|
+
get length() {
|
|
591
|
+
return entries.length - head;
|
|
592
|
+
},
|
|
593
|
+
get canceled() {
|
|
594
|
+
return canceled;
|
|
595
|
+
},
|
|
596
|
+
enqueue(value) {
|
|
597
|
+
if (!canceled) entries.push(value);
|
|
598
|
+
},
|
|
599
|
+
dequeue() {
|
|
600
|
+
if (head === entries.length) return;
|
|
601
|
+
const value = entries[head];
|
|
602
|
+
entries[head] = void 0;
|
|
603
|
+
head += 1;
|
|
604
|
+
if (head === entries.length) {
|
|
605
|
+
entries = [];
|
|
606
|
+
head = 0;
|
|
607
|
+
} else if (head >= 1024 && head * 2 >= entries.length) {
|
|
608
|
+
entries = entries.slice(head);
|
|
609
|
+
head = 0;
|
|
610
|
+
}
|
|
611
|
+
return value;
|
|
612
|
+
},
|
|
613
|
+
cancel() {
|
|
614
|
+
canceled = true;
|
|
615
|
+
entries.length = 0;
|
|
616
|
+
head = 0;
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* A single-consumption asynchronous API response stream.
|
|
622
|
+
*
|
|
623
|
+
* Use {@link Stream.tee} when two consumers need the same events. Breaking out of
|
|
624
|
+
* a response-backed stream early aborts its request; branches created by `tee()`
|
|
625
|
+
* instead share {@link Stream.controller} for explicit cancellation.
|
|
626
|
+
*/
|
|
627
|
+
var Stream = class Stream {
|
|
628
|
+
/** Wraps an asynchronous event iterator and the controller that owns its request. */
|
|
629
|
+
constructor(iterator, controller, client) {
|
|
630
|
+
_Stream_instances.add(this);
|
|
631
|
+
_Stream_client.set(this, void 0);
|
|
632
|
+
_Stream_isTeeBranch.set(this, false);
|
|
633
|
+
this.iterator = iterator;
|
|
634
|
+
this.controller = controller;
|
|
635
|
+
__classPrivateFieldSet(this, _Stream_client, client, "f");
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Decodes an SSE response into parsed JSON events.
|
|
639
|
+
*
|
|
640
|
+
* The resulting stream can be consumed only once, ignores events after `[DONE]`, and
|
|
641
|
+
* surfaces API error payloads as `APIError` instances. When
|
|
642
|
+
* `synthesizeEventData` is enabled, each item also includes its SSE event name.
|
|
643
|
+
*/
|
|
644
|
+
static fromSSEResponse(response, controller, client, synthesizeEventData) {
|
|
645
|
+
let consumed = false;
|
|
646
|
+
const logger = client ? loggerFor(client) : console;
|
|
647
|
+
async function* iterator() {
|
|
648
|
+
if (consumed) throw new OpenAIError("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
|
|
649
|
+
consumed = true;
|
|
650
|
+
let done = false;
|
|
651
|
+
let receivedCompletionSentinel = false;
|
|
652
|
+
const messages = _iterSSEMessages(response, controller);
|
|
653
|
+
const closeMessages = messages.return.bind(messages);
|
|
654
|
+
messages.return = (value) => {
|
|
655
|
+
if (!receivedCompletionSentinel) controller.abort();
|
|
656
|
+
return closeMessages(value);
|
|
657
|
+
};
|
|
658
|
+
try {
|
|
659
|
+
for await (const sse of messages) {
|
|
660
|
+
if (sse.data === "[DONE]") {
|
|
661
|
+
receivedCompletionSentinel = true;
|
|
662
|
+
break;
|
|
663
|
+
}
|
|
664
|
+
if (sse.event === null || !sse.event.startsWith("thread.")) {
|
|
665
|
+
let data;
|
|
666
|
+
try {
|
|
667
|
+
data = JSON.parse(sse.data);
|
|
668
|
+
} catch {
|
|
669
|
+
logger.error(`Could not parse message into JSON:`);
|
|
670
|
+
logger.error(`From chunk:`);
|
|
671
|
+
throw new SyntaxError("Error reading response: malformed server-sent event JSON.");
|
|
672
|
+
}
|
|
673
|
+
if (sse.event === "error") throw new APIError(void 0, data?.error ?? data, void 0, response.headers);
|
|
674
|
+
if (data && data.error) throw new APIError(void 0, data.error, void 0, response.headers);
|
|
675
|
+
yield synthesizeEventData ? {
|
|
676
|
+
event: sse.event,
|
|
677
|
+
data
|
|
678
|
+
} : data;
|
|
679
|
+
} else {
|
|
680
|
+
let data;
|
|
681
|
+
try {
|
|
682
|
+
data = JSON.parse(sse.data);
|
|
683
|
+
} catch {
|
|
684
|
+
logger.error(`Could not parse message into JSON:`);
|
|
685
|
+
logger.error(`From chunk:`);
|
|
686
|
+
throw new SyntaxError("Error reading response: malformed server-sent event JSON.");
|
|
687
|
+
}
|
|
688
|
+
yield {
|
|
689
|
+
event: sse.event,
|
|
690
|
+
data
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
done = true;
|
|
695
|
+
} catch (e) {
|
|
696
|
+
if (receivedCompletionSentinel || isTransportAbortError(e) || controller.signal.aborted && e === controller.signal.reason) return;
|
|
697
|
+
throw e;
|
|
698
|
+
} finally {
|
|
699
|
+
if (!done) controller.abort();
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
return new Stream(iterator, controller, client);
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Generates a Stream from a newline-separated ReadableStream
|
|
706
|
+
* where each item is a JSON value.
|
|
707
|
+
*/
|
|
708
|
+
static fromReadableStream(readableStream, controller, client) {
|
|
709
|
+
let consumed = false;
|
|
710
|
+
async function* iterLines() {
|
|
711
|
+
const lineDecoder = new LineDecoder();
|
|
712
|
+
const reader = readableStream.getReader();
|
|
713
|
+
let closed = false;
|
|
714
|
+
let cancelPromise;
|
|
715
|
+
const cancel = () => {
|
|
716
|
+
cancelPromise ?? (cancelPromise = reader.cancel());
|
|
717
|
+
cancelPromise.catch(() => void 0);
|
|
718
|
+
};
|
|
719
|
+
controller.signal.addEventListener("abort", cancel, { once: true });
|
|
720
|
+
try {
|
|
721
|
+
if (controller.signal.aborted) {
|
|
722
|
+
cancel();
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
while (true) {
|
|
726
|
+
const { value: chunk, done } = await reader.read();
|
|
727
|
+
if (done) {
|
|
728
|
+
closed = true;
|
|
729
|
+
break;
|
|
730
|
+
}
|
|
731
|
+
if (controller.signal.aborted) return;
|
|
732
|
+
for (const line of lineDecoder.decode(chunk)) {
|
|
733
|
+
if (controller.signal.aborted) return;
|
|
734
|
+
yield line;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
if (controller.signal.aborted) return;
|
|
738
|
+
for (const line of lineDecoder.flush()) {
|
|
739
|
+
if (controller.signal.aborted) return;
|
|
740
|
+
yield line;
|
|
741
|
+
}
|
|
742
|
+
} finally {
|
|
743
|
+
controller.signal.removeEventListener("abort", cancel);
|
|
744
|
+
if (!closed) cancel();
|
|
745
|
+
reader.releaseLock();
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
async function* iterator() {
|
|
749
|
+
if (consumed) throw new OpenAIError("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
|
|
750
|
+
consumed = true;
|
|
751
|
+
let done = false;
|
|
752
|
+
try {
|
|
753
|
+
for await (const line of iterLines()) if (line) {
|
|
754
|
+
let data;
|
|
755
|
+
try {
|
|
756
|
+
data = JSON.parse(line);
|
|
757
|
+
} catch (error) {
|
|
758
|
+
if (error instanceof SyntaxError) throw new SyntaxError("Error reading response: malformed newline-delimited JSON.");
|
|
759
|
+
throw error;
|
|
760
|
+
}
|
|
761
|
+
yield data;
|
|
762
|
+
}
|
|
763
|
+
done = true;
|
|
764
|
+
} catch (e) {
|
|
765
|
+
if (controller.signal.aborted || isAbortError(e)) return;
|
|
766
|
+
throw e;
|
|
767
|
+
} finally {
|
|
768
|
+
if (!done) controller.abort();
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
return new Stream(iterator, controller, client);
|
|
772
|
+
}
|
|
773
|
+
/** Starts consuming this stream; attempting to consume it again throws. */
|
|
774
|
+
[(_Stream_client = /* @__PURE__ */ new WeakMap(), _Stream_isTeeBranch = /* @__PURE__ */ new WeakMap(), _Stream_instances = /* @__PURE__ */ new WeakSet(), Symbol.asyncIterator)]() {
|
|
775
|
+
return this.iterator();
|
|
776
|
+
}
|
|
777
|
+
/** Beta-only iterator decoration for Agents helpers, preserving custom stream identity.
|
|
778
|
+
* @internal
|
|
779
|
+
*/
|
|
780
|
+
__betaTransformIterator(transform) {
|
|
781
|
+
this.iterator = transform(this.iterator.bind(this));
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Splits the stream into two streams which can be
|
|
785
|
+
* independently read from at different speeds.
|
|
786
|
+
* Closing a branch discards its buffered events without stopping its sibling.
|
|
787
|
+
* Future reads on that branch finish immediately; previously issued `next()`
|
|
788
|
+
* promises remain shared with its sibling and may still resolve with events.
|
|
789
|
+
* Closing both branches invokes the source iterator's `return()` when available.
|
|
790
|
+
* For {@link Stream.fromReadableStream}, closing both branches before iteration
|
|
791
|
+
* starts does not cancel the supplied readable; cancel that readable directly.
|
|
792
|
+
*/
|
|
793
|
+
tee() {
|
|
794
|
+
const { controller } = this;
|
|
795
|
+
const left = createStreamTeeQueue();
|
|
796
|
+
const right = createStreamTeeQueue();
|
|
797
|
+
const iterator = this.iterator();
|
|
798
|
+
const teeIterator = (queue) => ({
|
|
799
|
+
next: () => {
|
|
800
|
+
if (queue.canceled) return Promise.resolve({
|
|
801
|
+
value: void 0,
|
|
802
|
+
done: true
|
|
803
|
+
});
|
|
804
|
+
if (queue.length === 0) {
|
|
805
|
+
const result = iterator.next();
|
|
806
|
+
left.enqueue(result);
|
|
807
|
+
right.enqueue(result);
|
|
808
|
+
}
|
|
809
|
+
return queue.dequeue();
|
|
810
|
+
},
|
|
811
|
+
return: async () => {
|
|
812
|
+
if (!queue.canceled) {
|
|
813
|
+
queue.cancel();
|
|
814
|
+
if (left.canceled && right.canceled) await __classPrivateFieldGet(this, _Stream_instances, "m", _Stream_cancelIterator).call(this, iterator, controller);
|
|
815
|
+
}
|
|
816
|
+
return {
|
|
817
|
+
value: void 0,
|
|
818
|
+
done: true
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
const branch = (queue) => {
|
|
823
|
+
const stream = new Stream(() => teeIterator(queue), controller, __classPrivateFieldGet(this, _Stream_client, "f"));
|
|
824
|
+
__classPrivateFieldSet(stream, _Stream_isTeeBranch, true, "f");
|
|
825
|
+
return stream;
|
|
826
|
+
};
|
|
827
|
+
return [branch(left), branch(right)];
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Converts this stream to a newline-separated ReadableStream of
|
|
831
|
+
* JSON stringified values in the stream
|
|
832
|
+
* which can be turned back into a Stream with `Stream.fromReadableStream()`.
|
|
833
|
+
* Canceling a response-backed readable aborts its request. Canceling a tee
|
|
834
|
+
* branch discards its buffered events and leaves sibling consumers running.
|
|
835
|
+
* Read or serialization failures also release the iterator without replacing the original error.
|
|
836
|
+
*/
|
|
837
|
+
toReadableStream() {
|
|
838
|
+
const { controller } = this;
|
|
839
|
+
let iter;
|
|
840
|
+
let cancellation;
|
|
841
|
+
const cancel = () => cancellation ?? (cancellation = __classPrivateFieldGet(this, _Stream_instances, "m", _Stream_cancelIterator).call(this, iter, controller));
|
|
842
|
+
return makeReadableStream({
|
|
843
|
+
start: async () => {
|
|
844
|
+
iter = this[Symbol.asyncIterator]();
|
|
845
|
+
},
|
|
846
|
+
async pull(ctrl) {
|
|
847
|
+
try {
|
|
848
|
+
const { value, done } = await iter.next();
|
|
849
|
+
if (done) return ctrl.close();
|
|
850
|
+
const bytes = encodeUTF8(JSON.stringify(value) + "\n");
|
|
851
|
+
ctrl.enqueue(bytes);
|
|
852
|
+
} catch (err) {
|
|
853
|
+
ctrl.error(err);
|
|
854
|
+
cancel().catch(() => void 0);
|
|
855
|
+
}
|
|
856
|
+
},
|
|
857
|
+
cancel
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
_Stream_cancelIterator = async function _Stream_cancelIterator(iterator, controller) {
|
|
862
|
+
const returnMethod = iterator.return;
|
|
863
|
+
if (returnMethod) {
|
|
864
|
+
if (!__classPrivateFieldGet(this, _Stream_isTeeBranch, "f")) controller.abort();
|
|
865
|
+
await Reflect.apply(returnMethod, iterator, []);
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
function createAbortableSSESource(body, signal) {
|
|
869
|
+
const reader = typeof body.getReader === "function" ? body.getReader() : void 0;
|
|
870
|
+
const source = reader ? {
|
|
871
|
+
next: () => reader.read(),
|
|
872
|
+
return: () => reader.cancel()
|
|
873
|
+
} : ReadableStreamToAsyncIterable(body)[Symbol.asyncIterator]();
|
|
874
|
+
const ended = {
|
|
875
|
+
value: void 0,
|
|
876
|
+
done: true
|
|
877
|
+
};
|
|
878
|
+
let closed = false;
|
|
879
|
+
let canceled = false;
|
|
880
|
+
let cancellation;
|
|
881
|
+
let interrupt;
|
|
882
|
+
const waitForAbort = () => new Promise((resolve) => {
|
|
883
|
+
interrupt = resolve;
|
|
884
|
+
});
|
|
885
|
+
const cancel = () => {
|
|
886
|
+
if (canceled || closed) return cancellation;
|
|
887
|
+
canceled = true;
|
|
888
|
+
try {
|
|
889
|
+
cancellation = Promise.resolve(source.return?.());
|
|
890
|
+
} catch (error) {
|
|
891
|
+
cancellation = Promise.reject(error);
|
|
892
|
+
}
|
|
893
|
+
cancellation.catch(() => void 0);
|
|
894
|
+
return cancellation;
|
|
895
|
+
};
|
|
896
|
+
const abort = () => {
|
|
897
|
+
queueMicrotask(() => {
|
|
898
|
+
interrupt?.();
|
|
899
|
+
cancel();
|
|
900
|
+
});
|
|
901
|
+
};
|
|
902
|
+
return {
|
|
903
|
+
iterator: {
|
|
904
|
+
async next() {
|
|
905
|
+
if (signal.aborted) return ended;
|
|
906
|
+
const aborted = waitForAbort().then(() => ended);
|
|
907
|
+
try {
|
|
908
|
+
const result = await Promise.race([source.next(), aborted]);
|
|
909
|
+
if (signal.aborted) return ended;
|
|
910
|
+
if (result.done) {
|
|
911
|
+
closed = true;
|
|
912
|
+
return ended;
|
|
913
|
+
}
|
|
914
|
+
return {
|
|
915
|
+
value: result.value,
|
|
916
|
+
done: false
|
|
917
|
+
};
|
|
918
|
+
} catch (error) {
|
|
919
|
+
if (signal.aborted && (isAbortError(error) || error === signal.reason)) return ended;
|
|
920
|
+
throw error;
|
|
921
|
+
} finally {
|
|
922
|
+
interrupt = void 0;
|
|
923
|
+
}
|
|
924
|
+
},
|
|
925
|
+
async return() {
|
|
926
|
+
const pending = cancel();
|
|
927
|
+
if (pending && !signal.aborted) {
|
|
928
|
+
const aborted = waitForAbort();
|
|
929
|
+
try {
|
|
930
|
+
if (!signal.aborted) await Promise.race([pending, aborted]);
|
|
931
|
+
} finally {
|
|
932
|
+
interrupt = void 0;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
return ended;
|
|
936
|
+
},
|
|
937
|
+
[Symbol.asyncIterator]() {
|
|
938
|
+
return this;
|
|
939
|
+
}
|
|
940
|
+
},
|
|
941
|
+
start() {
|
|
942
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
943
|
+
if (signal.aborted) abort();
|
|
944
|
+
},
|
|
945
|
+
async cleanup(failed) {
|
|
946
|
+
let cleanupError;
|
|
947
|
+
try {
|
|
948
|
+
signal.removeEventListener("abort", abort);
|
|
949
|
+
} catch (error) {
|
|
950
|
+
cleanupError = error;
|
|
951
|
+
}
|
|
952
|
+
if (!closed) {
|
|
953
|
+
const pending = cancel();
|
|
954
|
+
if (pending && !failed && !signal.aborted) try {
|
|
955
|
+
await pending;
|
|
956
|
+
} catch (error) {
|
|
957
|
+
cleanupError ?? (cleanupError = error);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
if (reader) try {
|
|
961
|
+
reader.releaseLock();
|
|
962
|
+
} catch (error) {
|
|
963
|
+
cleanupError ?? (cleanupError = error);
|
|
964
|
+
}
|
|
965
|
+
if (cleanupError !== void 0 && !failed && !signal.aborted) throw cleanupError;
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Decodes complete SSE records from a response and aborts when its body is absent.
|
|
971
|
+
* Complete events are decoded on demand without imposing a line or event size limit.
|
|
972
|
+
*
|
|
973
|
+
* @yields {ServerSentEvent} Each decoded server-sent event in wire order.
|
|
974
|
+
*/
|
|
975
|
+
async function* _iterSSEMessages(response, controller) {
|
|
976
|
+
if (!response.body) {
|
|
977
|
+
controller.abort();
|
|
978
|
+
if (globalThis.navigator !== void 0 && globalThis.navigator.product === "ReactNative") throw new OpenAIError(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`);
|
|
979
|
+
throw new OpenAIError(`Attempted to iterate over a response with no body`);
|
|
980
|
+
}
|
|
981
|
+
const sseDecoder = new SSEDecoder();
|
|
982
|
+
const lineDecoder = new LineDecoder();
|
|
983
|
+
const { signal } = controller;
|
|
984
|
+
const source = createAbortableSSESource(response.body, signal);
|
|
985
|
+
let failed = false;
|
|
986
|
+
try {
|
|
987
|
+
source.start();
|
|
988
|
+
for await (const sseChunk of iterSSEChunks(source.iterator)) {
|
|
989
|
+
if (signal.aborted) return;
|
|
990
|
+
for (const line of lineDecoder.decode(sseChunk)) {
|
|
991
|
+
if (signal.aborted) return;
|
|
992
|
+
const sse = sseDecoder.decode(line);
|
|
993
|
+
if (sse) yield sse;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
if (signal.aborted) return;
|
|
997
|
+
for (const line of lineDecoder.flush()) {
|
|
998
|
+
if (signal.aborted) return;
|
|
999
|
+
const sse = sseDecoder.decode(line);
|
|
1000
|
+
if (sse) yield sse;
|
|
1001
|
+
}
|
|
1002
|
+
if (signal.aborted) return;
|
|
1003
|
+
const pending = sseDecoder.flush();
|
|
1004
|
+
if (pending) yield pending;
|
|
1005
|
+
} catch (error) {
|
|
1006
|
+
failed = true;
|
|
1007
|
+
if (!signal.aborted || !isAbortError(error) && error !== signal.reason) throw error;
|
|
1008
|
+
} finally {
|
|
1009
|
+
await source.cleanup(failed);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
const DOUBLE_NEWLINE_DELIMITER_MAX_OVERLAP_BYTES = 3;
|
|
1013
|
+
/**
|
|
1014
|
+
* Given an async iterable iterator, iterates over it and yields full
|
|
1015
|
+
* SSE chunks, i.e. yields when a double new-line is encountered.
|
|
1016
|
+
*
|
|
1017
|
+
* @yields {Uint8Array} A complete SSE chunk.
|
|
1018
|
+
*/
|
|
1019
|
+
async function* iterSSEChunks(iterator) {
|
|
1020
|
+
let data = /* @__PURE__ */ new Uint8Array();
|
|
1021
|
+
let dataStart = 0;
|
|
1022
|
+
let dataEnd = 0;
|
|
1023
|
+
let searchStartIndex = 0;
|
|
1024
|
+
for await (const chunk of iterator) {
|
|
1025
|
+
if (chunk == null) continue;
|
|
1026
|
+
let binaryChunk;
|
|
1027
|
+
if (chunk instanceof ArrayBuffer) binaryChunk = new Uint8Array(chunk);
|
|
1028
|
+
else if (typeof chunk === "string") binaryChunk = encodeUTF8(chunk);
|
|
1029
|
+
else binaryChunk = chunk;
|
|
1030
|
+
if (dataEnd + binaryChunk.length > data.length) {
|
|
1031
|
+
const bufferedLength = dataEnd - dataStart;
|
|
1032
|
+
if (dataStart >= data.length / 2 && bufferedLength + binaryChunk.length <= data.length) data.copyWithin(0, dataStart, dataEnd);
|
|
1033
|
+
else {
|
|
1034
|
+
const newData = new Uint8Array(Math.max(data.length * 2, bufferedLength + binaryChunk.length));
|
|
1035
|
+
newData.set(data.subarray(dataStart, dataEnd));
|
|
1036
|
+
data = newData;
|
|
1037
|
+
}
|
|
1038
|
+
searchStartIndex -= dataStart;
|
|
1039
|
+
dataStart = 0;
|
|
1040
|
+
dataEnd = bufferedLength;
|
|
1041
|
+
}
|
|
1042
|
+
data.set(binaryChunk, dataEnd);
|
|
1043
|
+
dataEnd += binaryChunk.length;
|
|
1044
|
+
let patternIndex;
|
|
1045
|
+
while ((patternIndex = findDoubleNewlineIndex(data.subarray(searchStartIndex, dataEnd))) !== -1) {
|
|
1046
|
+
patternIndex += searchStartIndex;
|
|
1047
|
+
yield data.slice(dataStart, patternIndex);
|
|
1048
|
+
dataStart = patternIndex;
|
|
1049
|
+
searchStartIndex = dataStart;
|
|
1050
|
+
}
|
|
1051
|
+
searchStartIndex = Math.max(dataStart, dataEnd - DOUBLE_NEWLINE_DELIMITER_MAX_OVERLAP_BYTES);
|
|
1052
|
+
}
|
|
1053
|
+
if (dataEnd > dataStart) yield data.slice(dataStart, dataEnd);
|
|
1054
|
+
}
|
|
1055
|
+
var SSEDecoder = class {
|
|
1056
|
+
constructor() {
|
|
1057
|
+
this.event = null;
|
|
1058
|
+
this.data = [];
|
|
1059
|
+
this.chunks = [];
|
|
1060
|
+
}
|
|
1061
|
+
decode(line) {
|
|
1062
|
+
if (line.endsWith("\r")) line = line.slice(0, -1);
|
|
1063
|
+
if (!line) {
|
|
1064
|
+
if (!this.event && !this.data.length) return null;
|
|
1065
|
+
const sse = {
|
|
1066
|
+
event: this.event,
|
|
1067
|
+
data: this.data.join("\n"),
|
|
1068
|
+
raw: this.chunks
|
|
1069
|
+
};
|
|
1070
|
+
this.event = null;
|
|
1071
|
+
this.data = [];
|
|
1072
|
+
this.chunks = [];
|
|
1073
|
+
return sse;
|
|
1074
|
+
}
|
|
1075
|
+
this.chunks.push(line);
|
|
1076
|
+
if (line.startsWith(":")) return null;
|
|
1077
|
+
const [fieldname, , initialValue] = partition(line, ":");
|
|
1078
|
+
let value = initialValue;
|
|
1079
|
+
if (value.startsWith(" ")) value = value.slice(1);
|
|
1080
|
+
if (fieldname === "event") this.event = value;
|
|
1081
|
+
else if (fieldname === "data") this.data.push(value);
|
|
1082
|
+
return null;
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Emits a pending event at EOF when the stream omitted the trailing blank
|
|
1086
|
+
* line. Returns `null` when no event is in progress so a record that already
|
|
1087
|
+
* ended with a blank line is not delivered twice.
|
|
1088
|
+
*/
|
|
1089
|
+
flush() {
|
|
1090
|
+
return this.decode("");
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
function partition(str, delimiter) {
|
|
1094
|
+
const index = str.indexOf(delimiter);
|
|
1095
|
+
if (index !== -1) return [
|
|
1096
|
+
str.slice(0, index),
|
|
1097
|
+
delimiter,
|
|
1098
|
+
str.slice(index + delimiter.length)
|
|
1099
|
+
];
|
|
1100
|
+
return [
|
|
1101
|
+
str,
|
|
1102
|
+
"",
|
|
1103
|
+
""
|
|
1104
|
+
];
|
|
1105
|
+
}
|
|
1106
|
+
//#endregion
|
|
30
1107
|
//#region packages/ai/src/transports/openai-transport-shared.ts
|
|
31
1108
|
const OPENAI_RESPONSE_MODEL_HEADER_NAMES = /* @__PURE__ */ new Set(["openai-model", "x-openai-model"]);
|
|
32
1109
|
const OPENAI_RESPONSE_MODEL_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -798,7 +1875,6 @@ function captureOpenAIResponsesCompaction(output, item, boundary, model, capture
|
|
|
798
1875
|
model: metadata.model,
|
|
799
1876
|
baseUrlHash: metadata.baseUrlHash,
|
|
800
1877
|
...metadata.sessionHash ? { sessionHash: metadata.sessionHash } : {},
|
|
801
|
-
...metadata.authProfileHash ? { authProfileHash: metadata.authProfileHash } : {},
|
|
802
1878
|
...compactedOutput ? { compactedWindow: {
|
|
803
1879
|
state: "ready",
|
|
804
1880
|
output: JSON.stringify(compactedOutput),
|
|
@@ -1553,10 +2629,7 @@ function convertResponsesMessagesWithStyle(model, context, allowedToolCallProvid
|
|
|
1553
2629
|
const providerStyle = conversionStyle === "provider";
|
|
1554
2630
|
const shouldReplayReasoningItems = options?.replayReasoningItems ?? true;
|
|
1555
2631
|
const shouldReplayResponsesItemIds = options?.replayResponsesItemIds ?? true;
|
|
1556
|
-
const replayContext = buildProviderReplayContext(model, {
|
|
1557
|
-
sessionId: options?.sessionId,
|
|
1558
|
-
authProfileId: options?.authProfileId
|
|
1559
|
-
});
|
|
2632
|
+
const replayContext = buildProviderReplayContext(model, { sessionId: options?.sessionId });
|
|
1560
2633
|
const shouldNormalizeSameModelToolCallIds = model.provider === "github-copilot";
|
|
1561
2634
|
const sanitizeIdPart = (part) => {
|
|
1562
2635
|
const sanitized = part.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
@@ -1584,7 +2657,6 @@ function convertResponsesMessagesWithStyle(model, context, allowedToolCallProvid
|
|
|
1584
2657
|
};
|
|
1585
2658
|
const replayPlan = buildOpenAIResponsesCompactionReplayPlan(context.messages, model, {
|
|
1586
2659
|
sessionId: options?.sessionId,
|
|
1587
|
-
authProfileId: options?.authProfileId,
|
|
1588
2660
|
mode: options?.replayMode
|
|
1589
2661
|
});
|
|
1590
2662
|
const transformMessages = (source) => providerStyle ? transformProviderMessages(source, model, normalizeToolCallId) : getAiTransportHost().transformTransportMessages(source, model, normalizeToolCallId, {
|
|
@@ -2085,11 +3157,11 @@ function summarizeResponsesPayload(params) {
|
|
|
2085
3157
|
if (resolveModelPayloadDebugMode() === "full-redacted") parts.push(`payload=${stringifyRedactedPayload(record)}`);
|
|
2086
3158
|
return parts.join(" ");
|
|
2087
3159
|
}
|
|
2088
|
-
function summarizeOpenAITransportError(error) {
|
|
3160
|
+
function summarizeOpenAITransportError(error, signal) {
|
|
2089
3161
|
if (!error || typeof error !== "object") return `type=${typeof error} message=${safeDebugValue(error)}`;
|
|
2090
3162
|
const record = error;
|
|
2091
3163
|
const cause = record.cause && typeof record.cause === "object" ? record.cause : void 0;
|
|
2092
|
-
|
|
3164
|
+
const parts = [
|
|
2093
3165
|
`name=${safeDebugValue(record.name)}`,
|
|
2094
3166
|
`status=${safeDebugValue(record.status)}`,
|
|
2095
3167
|
`code=${safeDebugValue(record.code)}`,
|
|
@@ -2097,7 +3169,35 @@ function summarizeOpenAITransportError(error) {
|
|
|
2097
3169
|
`causeName=${safeDebugValue(cause?.name)}`,
|
|
2098
3170
|
`causeCode=${safeDebugValue(cause?.code)}`,
|
|
2099
3171
|
`message=${error instanceof Error ? error.message : safeDebugValue(error)}`
|
|
2100
|
-
]
|
|
3172
|
+
];
|
|
3173
|
+
if (signal?.aborted) {
|
|
3174
|
+
const reason = isRecord(signal.reason) ? signal.reason : void 0;
|
|
3175
|
+
let abortReason = reason?.name === "TimeoutError" ? "request_deadline" : "caller_abort";
|
|
3176
|
+
switch (reason?.code ?? reason?.name) {
|
|
3177
|
+
case "LlmIdleTimeoutError":
|
|
3178
|
+
abortReason = "idle_timeout";
|
|
3179
|
+
break;
|
|
3180
|
+
case "LlmNoProgressError":
|
|
3181
|
+
abortReason = "no_progress";
|
|
3182
|
+
break;
|
|
3183
|
+
case "FirstStreamEventTimeoutError":
|
|
3184
|
+
abortReason = "first_event_timeout";
|
|
3185
|
+
break;
|
|
3186
|
+
case "OPENCLAW_SESSION_WATCHDOG":
|
|
3187
|
+
abortReason = "session_watchdog";
|
|
3188
|
+
break;
|
|
3189
|
+
case "degenerate_output":
|
|
3190
|
+
abortReason = "degenerate_output";
|
|
3191
|
+
break;
|
|
3192
|
+
case "OPENCLAW_RESTART_ABORT":
|
|
3193
|
+
case "ERR_STALE_GATEWAY_LIFECYCLE":
|
|
3194
|
+
abortReason = "restart";
|
|
3195
|
+
break;
|
|
3196
|
+
case "AGENT_RUN_SUPERSEDED_ABORT": abortReason = "superseded";
|
|
3197
|
+
}
|
|
3198
|
+
parts.push(`abortReason=${abortReason}`);
|
|
3199
|
+
}
|
|
3200
|
+
return parts.join(" ");
|
|
2101
3201
|
}
|
|
2102
3202
|
//#endregion
|
|
2103
3203
|
//#region packages/ai/src/transports/openai-responses-replay-internal.ts
|
|
@@ -3104,6 +4204,7 @@ async function processResponsesStream(openaiStream, output, sink, model, options
|
|
|
3104
4204
|
argumentStreamReliable: true,
|
|
3105
4205
|
argumentsStreamed: false,
|
|
3106
4206
|
previewSchedule: createToolArgumentPreviewSchedule(),
|
|
4207
|
+
trailingWhitespaceChars: countToolCallTrailingWhitespace(toolCallBlock.partialJson),
|
|
3107
4208
|
...readResponsesToolCallItemIdentity(item)
|
|
3108
4209
|
};
|
|
3109
4210
|
streamingToolCalls.register(event, toolCallState);
|
|
@@ -3178,6 +4279,7 @@ async function processResponsesStream(openaiStream, output, sink, model, options
|
|
|
3178
4279
|
}
|
|
3179
4280
|
let delta;
|
|
3180
4281
|
if (event.type === "response.function_call_arguments.delta") {
|
|
4282
|
+
toolCall.trailingWhitespaceChars = countToolCallTrailingWhitespace(event.delta, toolCall.trailingWhitespaceChars);
|
|
3181
4283
|
toolCall.block.partialJson += event.delta;
|
|
3182
4284
|
toolCall.argumentsStreamed = true;
|
|
3183
4285
|
if (toolCall.previewSchedule(toolCall.block.partialJson.length)) toolCall.block.arguments = parseStreamingJson(toolCall.block.partialJson);
|
|
@@ -3186,6 +4288,7 @@ async function processResponsesStream(openaiStream, output, sink, model, options
|
|
|
3186
4288
|
const previousPartialJson = toolCall.block.partialJson;
|
|
3187
4289
|
const doneArguments = typeof event.arguments === "string" ? event.arguments : void 0;
|
|
3188
4290
|
if (doneArguments !== void 0 && (doneArguments.length > 0 || previousPartialJson === "")) {
|
|
4291
|
+
toolCall.trailingWhitespaceChars = countToolCallTrailingWhitespace(doneArguments);
|
|
3189
4292
|
toolCall.block.partialJson = doneArguments;
|
|
3190
4293
|
toolCall.block.arguments = parseStreamingJson(toolCall.block.partialJson);
|
|
3191
4294
|
toolCall.argumentStreamReliable = true;
|
|
@@ -3482,10 +4585,7 @@ async function runResponsesStreamLifecycle(params) {
|
|
|
3482
4585
|
},
|
|
3483
4586
|
onServiceTier: (responseTier, response) => responsesServiceTierObserver.observe(options, requestedTier, responseTier, response),
|
|
3484
4587
|
canRetryIdentityConflict: () => hasOnlyResponsesFunctionTools(admittedRequest),
|
|
3485
|
-
reasoningReplayMetadata: buildOpenAIResponsesReasoningReplayMetadata(model, {
|
|
3486
|
-
sessionId: options?.sessionId,
|
|
3487
|
-
authProfileId: options?.authProfileId
|
|
3488
|
-
})
|
|
4588
|
+
reasoningReplayMetadata: buildOpenAIResponsesReasoningReplayMetadata(model, { sessionId: options?.sessionId })
|
|
3489
4589
|
});
|
|
3490
4590
|
if (terminal && admittedRequest && !options?.signal?.aborted) recordResponsesContextUsage(output, model, options, admittedRequest, terminal.output, "provider");
|
|
3491
4591
|
finalizeTransportStream({
|
|
@@ -3520,4 +4620,4 @@ async function runResponsesStreamLifecycle(params) {
|
|
|
3520
4620
|
}
|
|
3521
4621
|
}
|
|
3522
4622
|
//#endregion
|
|
3523
|
-
export { isConfigurationUpdate as $, summarizeResponsesPayload as A, isOpenAICompletionsThinkingEnabled as At, recordResponsesInputReplay as B, readResponsesRecoveryEvent as C, reconcileOpenAIResponsesToolChoice as Ct, logResponsesFailedNoDetails as D, createOpenAIResponseHook as Dt, ResponsesStreamFailure as E, createOpenAIProviderAcceptanceHook as Et, convertProviderResponsesMessages as F, readOpenAICompletionsReasoningBatch as Ft, responsesContinuationPrefixFingerprint as G, claimOpenAIResponsesHttpContinuation as H, convertResponsesMessages as I, resolveOpenAIClientBaseUrl as It, OPENAI_RESPONSES_FUNCTION_CALL_ITEM_ID_RE as J, responsesContinuationRequestFingerprint as K, normalizeOpenAIResponsesReasoningReplayItem as L, resolvePromptCacheKey as Lt, resolveResponsesContextUsageBoundary as M, measureUtf8AppendBytes as Mt, bindResponsesInputMessage as N, parseOpenAICompletionsUsage as Nt, safeDebugValue as O, createResponseModelTracker as Ot, buildResponsesInputMessage as P, readOpenAICompletionsContentDeltas as Pt, splitOpenAIFunctionCallPairing as Q, resolveReplayableResponsesMessageId as R, withOpenAIErrorResponseHook as Rt, isInvalidEncryptedContentError as S, reconcileOpenAICompletionsToolChoice as St, resolveNextResponsesEncryptedContentAttempt as T, GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP as Tt, recordResponsesContinuationState as U, responsesInputFingerprint as V, resolveResponsesContinuationRequest as W, normalizeOpenAIResponsesFunctionCallId as X, OPENAI_RESPONSES_ID_MAX_LENGTH as Y, shouldNormalizeOpenAIResponsesToolCallId as Z, isResponsesTextContentPartType as _, resolveOpenAIRequestReasoning as _t, prepareResponsesTools as a, resolveNewestOpenAIResponsesCompactionReplay as at, commitResponsesEncryptedContentAttempt as b, prepareOpenAITools as bt, observeResponsesStream as c, buildOpenAIClientHeaders as ct, AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE as d, enforceCodeModeResponsesToolSurface as dt, replayResponsesReasoningUpdates as et, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE as f, filterCodeModePayloadTools as ft, isAzureResponsesTextDeltaEventType as g, resolveOpenAIStrictToolFlagWithDiagnostics as gt, isAzureResponsesTextDeltaEvent as h, resolveCodeModeResponsesVisibleToolNames as ht, convertResponsesToolPayload as i, captureOpenAIResponsesCompaction as it, recordResponsesContextUsage as j, log as jt, summarizeOpenAITransportError as k, detachPartialSnapshot as kt, createResponsesToolCallTracker as l, buildOpenAISdkClientOptions as lt, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE as m, readCodeModePayloadToolName as mt, applyResponsesServiceTierPricing as n, CompactionReplayRefreshRequiredError as nt, readOpenAIMisalignmentReview as o, suppressOpenAIResponsesCompaction as ot, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE as p, getCompat as pt, OPENAI_RESPONSES_CALL_ID_RE as q, runResponsesStreamLifecycle as r, buildOpenAIResponsesReasoningReplayMetadata as rt, processResponsesStream as s, assertCodeModeResponsesToolSurface as st, applyCommonResponsesParams as t, supportsResponsesReasoningUpdate as tt, readResponsesToolCallItemIdentity as u, buildOpenAISdkRequestOptions as ut, isResponsesTextDeltaEventType as v, resolveOpenAISimpleReasoningEffort as vt, resolveAzureOpenAIApiVersion as w, toOpenAIResponsesToolChoice as wt, createResponsesStreamWithRecovery as x, projectOpenAITools as xt, resolveResponsesMessageSnapshotCollapse as y, resolveOpenAIReasoningEffortMap as yt, readResponsesInputReplayState as z };
|
|
4623
|
+
export { isConfigurationUpdate as $, isArray as $t, summarizeResponsesPayload as A, isOpenAICompletionsThinkingEnabled as At, recordResponsesInputReplay as B, formatRequestDetails as Bt, readResponsesRecoveryEvent as C, UnprocessableEntityError as Cn, reconcileOpenAIResponsesToolChoice as Ct, logResponsesFailedNoDetails as D, __classPrivateFieldSet as Dn, createOpenAIResponseHook as Dt, ResponsesStreamFailure as E, __classPrivateFieldGet as En, createOpenAIProviderAcceptanceHook as Et, convertProviderResponsesMessages as F, readOpenAICompletionsReasoningBatch as Ft, responsesContinuationPrefixFingerprint as G, redactURL as Gt, claimOpenAIResponsesHttpContinuation as H, isSensitiveQueryParameter as Ht, convertResponsesMessages as I, resolveOpenAIClientBaseUrl as It, OPENAI_RESPONSES_FUNCTION_CALL_ITEM_ID_RE as J, ReadableStreamFrom as Jt, responsesContinuationRequestFingerprint as K, encodeUTF8 as Kt, normalizeOpenAIResponsesReasoningReplayItem as L, resolvePromptCacheKey as Lt, resolveResponsesContextUsageBoundary as M, measureUtf8AppendBytes as Mt, bindResponsesInputMessage as N, parseOpenAICompletionsUsage as Nt, safeDebugValue as O, createResponseModelTracker as Ot, buildResponsesInputMessage as P, readOpenAICompletionsContentDeltas as Pt, splitOpenAIFunctionCallPairing as Q, isAbsoluteURL as Qt, resolveReplayableResponsesMessageId as R, withOpenAIErrorResponseHook as Rt, isInvalidEncryptedContentError as S, SubjectTokenProviderError as Sn, reconcileOpenAICompletionsToolChoice as St, resolveNextResponsesEncryptedContentAttempt as T, isAbortError as Tn, GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP as Tt, recordResponsesContinuationState as U, loggerFor as Ut, responsesInputFingerprint as V, isSensitiveHeader as Vt, resolveResponsesContinuationRequest as W, parseLogLevel as Wt, normalizeOpenAIResponsesFunctionCallId as X, getDefaultFetch as Xt, OPENAI_RESPONSES_ID_MAX_LENGTH as Y, ReadableStreamToAsyncIterable as Yt, shouldNormalizeOpenAIResponsesToolCallId as Z, hasOwn as Zt, isResponsesTextContentPartType as _, NotFoundError as _n, resolveOpenAIRequestReasoning as _t, prepareResponsesTools as a, validatePositiveInteger as an, resolveNewestOpenAIResponsesCompactionReplay as at, commitResponsesEncryptedContentAttempt as b, PermissionDeniedError as bn, prepareOpenAITools as bt, observeResponsesStream as c, APIError as cn, buildOpenAIClientHeaders as ct, AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE as d, BadRequestError as dn, enforceCodeModeResponsesToolSurface as dt, isEmptyObj as en, replayResponsesReasoningUpdates as et, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE as f, ConflictError as fn, filterCodeModePayloadTools as ft, isAzureResponsesTextDeltaEventType as g, LengthFinishReasonError as gn, resolveOpenAIStrictToolFlagWithDiagnostics as gt, isAzureResponsesTextDeltaEvent as h, InvalidWebhookSignatureError as hn, resolveCodeModeResponsesVisibleToolNames as ht, convertResponsesToolPayload as i, safeJSON as in, captureOpenAIResponsesCompaction as it, recordResponsesContextUsage as j, log as jt, summarizeOpenAITransportError as k, detachPartialSnapshot as kt, createResponsesToolCallTracker as l, APIUserAbortError as ln, buildOpenAISdkClientOptions as lt, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE as m, InternalServerError as mn, readCodeModePayloadToolName as mt, applyResponsesServiceTierPricing as n, isReadonlyArray as nn, CompactionReplayRefreshRequiredError as nt, readOpenAIMisalignmentReview as o, APIConnectionError as on, suppressOpenAIResponsesCompaction as ot, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE as p, ContentFilterFinishReasonError as pn, getCompat as pt, OPENAI_RESPONSES_CALL_ID_RE as q, CancelReadableStream as qt, runResponsesStreamLifecycle as r, maybeObj as rn, buildOpenAIResponsesReasoningReplayMetadata as rt, processResponsesStream as s, APIConnectionTimeoutError as sn, assertCodeModeResponsesToolSurface as st, applyCommonResponsesParams as t, isObj as tn, supportsResponsesReasoningUpdate as tt, readResponsesToolCallItemIdentity as u, AuthenticationError as un, buildOpenAISdkRequestOptions as ut, isResponsesTextDeltaEventType as v, OAuthError as vn, resolveOpenAISimpleReasoningEffort as vt, resolveAzureOpenAIApiVersion as w, castToError as wn, toOpenAIResponsesToolChoice as wt, createResponsesStreamWithRecovery as x, RateLimitError as xn, projectOpenAITools as xt, resolveResponsesMessageSnapshotCollapse as y, OpenAIError as yn, resolveOpenAIReasoningEffortMap as yt, readResponsesInputReplayState as z, Stream as zt };
|