@openclaw/ai 2026.9.3 → 2026.9.4
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-CZy5U0NY.mjs → anthropic-C4Qu4H0Z.mjs} +14 -13
- package/dist/{anthropic-payload-policy-wuRCb6MH.d.mts → anthropic-payload-policy-BZ8umAbk.d.mts} +3 -3
- package/dist/{anthropic-stream-reducer-B_yo_7pf.mjs → anthropic-stream-reducer-CILWF7JD.mjs} +17 -12
- package/dist/{api-registry-CB1-1oQ2.d.mts → api-registry-ByUwIR0e.d.mts} +2 -2
- package/dist/{assistant-output-iqnlJCV2.mjs → assistant-output-tLt4H-iQ.mjs} +1 -1
- package/dist/{azure-openai-responses-Crpa40QR.mjs → azure-openai-responses-BAlqlKKc.mjs} +4 -4
- package/dist/{diagnostics-dV98PqIy.mjs → diagnostics-QuErwCIl.mjs} +1 -1
- package/dist/diagnostics.mjs +2 -2
- package/dist/{event-stream-C1Z2piyk.d.mts → event-stream-Bt5Y4Pav.d.mts} +1 -1
- package/dist/event-stream-C3WGFsum.d.mts +1 -0
- package/dist/event-stream.d.mts +2 -2
- package/dist/{google-BDPriaVe.mjs → google-DPBAOaOW.mjs} +6 -6
- package/dist/{google-messages-CVn9eFpF.mjs → google-messages-6JkpHrhJ.mjs} +3 -4
- package/dist/{google-shared-BedY23XS.mjs → google-shared-BvBeW9aq.mjs} +5 -5
- package/dist/{google-vertex-DMz8XQCn.mjs → google-vertex-k-TMCAYD.mjs} +4 -4
- package/dist/{host-DK3wmS3e.d.mts → host-4atIX-2V.d.mts} +5 -3
- package/dist/{host-CWuF-sS3.mjs → host-B8YfDGd4.mjs} +140 -5
- package/dist/{host-policy-CAopLRKA.mjs → host-policy-Zcg_cNz8.mjs} +1 -1
- package/dist/{index-CQ6LTHw8.d.mts → index-DdD3qerf.d.mts} +4 -4
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +5 -4
- package/dist/internal/anthropic.d.mts +5 -5
- package/dist/internal/anthropic.mjs +4 -4
- package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
- package/dist/internal/openai-responses-payload-policy.mjs +3 -2
- package/dist/internal/openai.d.mts +6 -6
- package/dist/internal/openai.mjs +8 -9
- package/dist/internal/runtime.d.mts +43 -8
- package/dist/internal/runtime.mjs +3 -5
- package/dist/internal/shared.d.mts +32 -3
- package/dist/internal/shared.mjs +3 -4
- package/dist/{mistral--m-Jm6VZ.mjs → mistral-CxUZ1jUb.mjs} +5 -8
- package/dist/{openai-chatgpt-responses-nDZccFW-.mjs → openai-chatgpt-responses-CgO6kZfo.mjs} +13 -14
- package/dist/{openai-completions-compat-CXn3T1we.d.mts → openai-completions-compat-eHgh5UPE.d.mts} +3 -3
- package/dist/{openai-completions-stream-BQk3SkLD.mjs → openai-completions-stream-Da2vvl-S.mjs} +45 -14
- package/dist/{openai-completions-KuoZyx0d.mjs → openai-completions-yJuk7eis.mjs} +10 -10
- package/dist/{openai-prompt-cache-rrutvqxq.d.mts → openai-prompt-cache-B4eYo2-I.d.mts} +2 -2
- package/dist/{openai-prompt-cache-BI0rkM-5.mjs → openai-prompt-cache-Bds-n_9Q.mjs} +1 -1
- package/dist/{openai-provider-client-ha_WxTyj.mjs → openai-provider-client-S2gCrM2Z.mjs} +2 -2
- package/dist/{openai-responses-D99dOzKI.mjs → openai-responses-DaYwH05E.mjs} +7 -7
- package/dist/{openai-responses-compaction-window-D5jbzCi3.mjs → openai-responses-compaction-window-CIhBAkkq.mjs} +3 -80
- package/dist/{openai-responses-contracts-B55afwRo.d.mts → openai-responses-contracts-BjBAqAg_.d.mts} +5 -38
- package/dist/{openai-reasoning-effort-BK7FbcLT.mjs → openai-responses-contracts-DDOHA62Y.mjs} +79 -1
- package/dist/{openai-responses-prompt-observer-internal-tApyTLVu.mjs → openai-responses-prompt-observer-internal-f8J7wpsk.mjs} +3 -3
- package/dist/{openai-responses-shared-ZyQEzS5i.mjs → openai-responses-shared-B8RdBPCv.mjs} +18 -18
- package/dist/{openai-transport-params-DNasp2fU.mjs → openai-transport-params-9aPuV5YY.mjs} +11 -10
- package/dist/positive-integer-41zhOdcV.mjs +8 -0
- package/dist/{provider-error-C6TbKiey.mjs → provider-error-BA-v_tKd.mjs} +47 -5
- package/dist/{provider-options-BXr9Ec83.d.mts → provider-options-Ceqv1OKk.d.mts} +2 -2
- package/dist/{provider-replay-context-BuSUaAk5.mjs → provider-replay-context-CJ_YvcEW.mjs} +1 -1
- package/dist/{provider-transcript-transform-pPmUIwKt.mjs → provider-transcript-transform-V5YzU9zh.mjs} +1 -1
- package/dist/provider-transport-turn-state-D5EXOFL2.mjs +42 -0
- package/dist/{provider-types-CAV0Og3m.d.mts → provider-types-CVjKjsuq.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +10 -10
- package/dist/{reasoning-tag-text-partitioner-BQBi4B9d.mjs → reasoning-tag-text-partitioner-BcR5pztD.mjs} +1 -8
- package/dist/{session-affinity-CCH7eYdB.mjs → session-affinity-Bcunsn4I.mjs} +5 -2
- package/dist/{simple-options-tcKOqnpF.mjs → simple-options-BQbb4yQL.mjs} +23 -4
- package/dist/src-DDmEryvj.mjs +2 -0
- package/dist/{transport-stream-shared-DOxpGJ-H.d.mts → transport-stream-shared-DNvmoWnv.d.mts} +20 -36
- package/dist/{transport-stream-shared-Cu3ZPhNW.mjs → transport-stream-shared-zHll9BxO.mjs} +223 -11
- package/dist/{transport-utils-CCooe-cr.mjs → transport-utils-zrYjICLZ.mjs} +4 -7
- package/dist/transports.d.mts +35 -163
- package/dist/transports.mjs +66 -82
- package/dist/types-DlfwzH3T.d.mts +1 -0
- package/dist/types-LFWwv0cF.mjs +8 -0
- package/dist/{types-Dy1q0CSu.d.mts → types-Ntv5z2g2.d.mts} +3 -1
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +4 -3
- package/dist/{src-B2Q_6G8V.mjs → usage-cost-BNWbbXav.mjs} +0 -1
- package/dist/{validation-CaFUZN9B.d.mts → validation-B0t_G2H6.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/package.json +1 -1
- package/dist/event-stream-I_GlBsuZ.d.mts +0 -1
- package/dist/hash-CHgqbJmD.mjs +0 -16
- package/dist/json-parse-Dw_hnxsA.mjs +0 -146
- package/dist/sanitize-unicode-Bb-v9meu.mjs +0 -83
- package/dist/types-BADKjDBI.d.mts +0 -1
- package/dist/types-BDdaOVi2.mjs +0 -6
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
2
|
import { t as AssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
|
|
3
|
-
import { n as clampOpenAIPromptCacheKey, r as resolveOpenAIPromptCacheParams, s as resolveOpenAICompletionsCompat } from "./openai-prompt-cache-
|
|
3
|
+
import { n as clampOpenAIPromptCacheKey, r as resolveOpenAIPromptCacheParams, s as resolveOpenAICompletionsCompat } from "./openai-prompt-cache-Bds-n_9Q.mjs";
|
|
4
4
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
5
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
5
|
+
import { n as buildBaseOptions } from "./simple-options-BQbb4yQL.mjs";
|
|
6
6
|
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { a as resolveResponsesReasoningEffort, i as createResponsesAssistantOutput, n as applyResponsesServiceTierPricing, r as convertResponsesMessages, s as runResponsesStreamLifecycle, t as applyCommonResponsesParams } from "./openai-responses-shared-
|
|
7
|
+
import { C as supportsOpenAITemperature } from "./openai-responses-contracts-DDOHA62Y.mjs";
|
|
8
|
+
import { n as resolveProviderSimpleCompletionHeaders } from "./provider-transport-turn-state-D5EXOFL2.mjs";
|
|
9
|
+
import { a as resolveResponsesReasoningEffort, i as createResponsesAssistantOutput, n as applyResponsesServiceTierPricing, r as convertResponsesMessages, s as runResponsesStreamLifecycle, t as applyCommonResponsesParams } from "./openai-responses-shared-B8RdBPCv.mjs";
|
|
10
10
|
import { n as hasCopilotVisionInput, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-B37TB3rB.mjs";
|
|
11
|
-
import { t as createOpenAIProviderClient } from "./openai-provider-client-
|
|
11
|
+
import { t as createOpenAIProviderClient } from "./openai-provider-client-S2gCrM2Z.mjs";
|
|
12
12
|
//#region packages/ai/src/providers/openai-responses.ts
|
|
13
13
|
var openai_responses_exports = /* @__PURE__ */ __exportAll({
|
|
14
14
|
streamOpenAIResponses: () => streamOpenAIResponses,
|
|
@@ -35,7 +35,7 @@ const streamOpenAIResponses = (model, context, options) => {
|
|
|
35
35
|
createClient: () => {
|
|
36
36
|
const apiKey = options?.apiKey || getEnvApiKey(model.provider) || "";
|
|
37
37
|
const cacheSessionId = resolveCacheRetention(options?.cacheRetention) === "none" ? void 0 : options?.sessionId;
|
|
38
|
-
return createClient(model, context, apiKey,
|
|
38
|
+
return createClient(model, context, apiKey, resolveProviderSimpleCompletionHeaders(model, options), cacheSessionId);
|
|
39
39
|
},
|
|
40
40
|
buildParams: (_requestModel, replayMode) => buildParams(model, context, options, replayMode),
|
|
41
41
|
processStreamOptions: {
|
|
@@ -1,91 +1,14 @@
|
|
|
1
|
-
import "./src-B2Q_6G8V.mjs";
|
|
2
|
-
import { n as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE } from "./types-BDdaOVi2.mjs";
|
|
3
1
|
import { i as normalizeOptionalLowercaseString, n as normalizeLowercaseStringOrEmpty, s as readStringValue } from "./string-coerce-fsri9iCu.mjs";
|
|
4
2
|
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
5
3
|
import { t as canonicalizeBase64 } from "./base64-D-su8YVo.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { t as parsePositiveInteger } from "./positive-integer-41zhOdcV.mjs";
|
|
5
|
+
import { S as supportsOpenAIReasoningEffort, i as OPENAI_RESPONSES_APIS } from "./openai-responses-contracts-DDOHA62Y.mjs";
|
|
8
6
|
import { t as createSseByteGuard } from "./streaming-byte-guard-CC-HMn_u.mjs";
|
|
9
7
|
//#region packages/model-catalog-core/src/provider-id.ts
|
|
10
8
|
function normalizeProviderId(provider) {
|
|
11
9
|
return normalizeLowercaseStringOrEmpty(provider);
|
|
12
10
|
}
|
|
13
11
|
//#endregion
|
|
14
|
-
//#region packages/ai/src/transports/openai-responses-contracts.ts
|
|
15
|
-
const DEFAULT_AZURE_OPENAI_API_VERSION = "preview";
|
|
16
|
-
const OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS = "Follow the user request.";
|
|
17
|
-
const AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS = 3e4;
|
|
18
|
-
const RESPONSE_FAILED_NO_DETAILS_MESSAGE = "Unknown error (no error details in response)";
|
|
19
|
-
const OPENAI_RESPONSES_REASONING_REPLAY_META_KEY = "__openclaw_replay";
|
|
20
|
-
const OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY = "openclawReasoningReplay";
|
|
21
|
-
const OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE = "openai-responses-compaction";
|
|
22
|
-
const OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE = "openai-responses-retained-compaction";
|
|
23
|
-
const OPENAI_RESPONSES_APIS = /* @__PURE__ */ new Set([
|
|
24
|
-
"openai-responses",
|
|
25
|
-
"azure-openai-responses",
|
|
26
|
-
"openai-chatgpt-responses",
|
|
27
|
-
"openclaw-openai-responses-transport",
|
|
28
|
-
"openclaw-openai-chatgpt-responses-transport",
|
|
29
|
-
"openclaw-azure-openai-responses-transport"
|
|
30
|
-
]);
|
|
31
|
-
var OpenAIResponsesWebSocketPreDispatchError = class extends Error {
|
|
32
|
-
constructor(cause) {
|
|
33
|
-
super("OpenAI Responses WebSocket failed before request dispatch", { cause });
|
|
34
|
-
this.name = "OpenAIResponsesWebSocketPreDispatchError";
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var OpenAIResponsesWebSocketPostDispatchError = class extends Error {
|
|
38
|
-
constructor(cause) {
|
|
39
|
-
super("OpenAI Responses WebSocket failed after request dispatch; outcome is unknown", { cause });
|
|
40
|
-
this.code = PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE;
|
|
41
|
-
this.name = "OpenAIResponsesWebSocketPostDispatchError";
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var OpenAIResponsesWebSocketServerError = class extends Error {
|
|
45
|
-
constructor(code, status, param, message, cause) {
|
|
46
|
-
super(message, { cause });
|
|
47
|
-
this.code = code;
|
|
48
|
-
this.status = status;
|
|
49
|
-
this.param = param;
|
|
50
|
-
this.name = "OpenAIResponsesWebSocketServerError";
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var OpenAIResponsesWebSocketSafeRetryError = class extends OpenAIResponsesWebSocketServerError {};
|
|
54
|
-
function readWebSocketServerError(value) {
|
|
55
|
-
if (!isRecord(value) || value.type !== "error") return;
|
|
56
|
-
const details = isRecord(value.error) ? value.error : value;
|
|
57
|
-
if (typeof details.code !== "string" || typeof details.message !== "string") return;
|
|
58
|
-
const rawStatus = value.status ?? value.status_code;
|
|
59
|
-
return {
|
|
60
|
-
code: details.code,
|
|
61
|
-
message: details.message,
|
|
62
|
-
param: typeof details.param === "string" ? details.param : null,
|
|
63
|
-
status: typeof rawStatus === "number" ? rawStatus : void 0
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
function parseOpenAIResponsesWebSocketServerError(cause) {
|
|
67
|
-
if (!isRecord(cause)) return;
|
|
68
|
-
let details = readWebSocketServerError(cause.error) ?? readWebSocketServerError(cause);
|
|
69
|
-
if (!details && typeof cause.message === "string") try {
|
|
70
|
-
details = readWebSocketServerError(JSON.parse(cause.message));
|
|
71
|
-
} catch {}
|
|
72
|
-
if (!details) return;
|
|
73
|
-
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);
|
|
74
|
-
}
|
|
75
|
-
const PROMPT_OBSERVER = Symbol("openaiResponsesPromptObserver");
|
|
76
|
-
const responsesPromptObserver = {
|
|
77
|
-
set(options, observer) {
|
|
78
|
-
Reflect.set(options, PROMPT_OBSERVER, observer);
|
|
79
|
-
},
|
|
80
|
-
get(options) {
|
|
81
|
-
return Reflect.get(options, PROMPT_OBSERVER);
|
|
82
|
-
},
|
|
83
|
-
copy(source, target) {
|
|
84
|
-
const observer = source && responsesPromptObserver.get(source);
|
|
85
|
-
if (observer) responsesPromptObserver.set(target, observer);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
//#endregion
|
|
89
12
|
//#region packages/ai/src/transports/openai-responses-payload-policy.ts
|
|
90
13
|
/**
|
|
91
14
|
* OpenAI Responses payload policy.
|
|
@@ -531,4 +454,4 @@ function createBoundedOpenAIResponsesCompactionFetch(upstreamFetch) {
|
|
|
531
454
|
};
|
|
532
455
|
}
|
|
533
456
|
//#endregion
|
|
534
|
-
export {
|
|
457
|
+
export { applyOpenAIResponsesPayloadPolicy as a, resolveOpenAIResponsesServerCompactionPlan as c, sanitizeResponsesImagePayload as i, isOpenAIResponsesCompactionOutput as n, resolveOpenAIResponsesCompactEndpointPlan as o, readOpenAIResponsesCompactionWindow as r, resolveOpenAIResponsesPayloadPolicy as s, createBoundedOpenAIResponsesCompactionFetch as t };
|
package/dist/{openai-responses-contracts-B55afwRo.d.mts → openai-responses-contracts-BjBAqAg_.d.mts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import {
|
|
3
|
-
import { a as BaseOpenAIStreamOptions,
|
|
4
|
-
import {
|
|
1
|
+
import "./index-DdD3qerf.mjs";
|
|
2
|
+
import { O as Model, n as Api } from "./types-Ntv5z2g2.mjs";
|
|
3
|
+
import { a as BaseOpenAIStreamOptions, f as OpenAIReasoningEffort } from "./provider-options-Ceqv1OKk.mjs";
|
|
4
|
+
import { ResponseCompactionItem, ResponseCreateParamsStreaming, ResponseInputItem } from "openai/resources/responses/responses.js";
|
|
5
5
|
//#region packages/ai/src/transports/openai-responses-compaction-window.d.ts
|
|
6
6
|
type OpenAIResponsesCompactionOutput = Array<ResponseInputItem.Message | ReplayableResponseCompactionItem>;
|
|
7
7
|
/** Read the saved canonical window only when it still matches its opaque checkpoint. */
|
|
@@ -48,38 +48,5 @@ declare const responsesPromptObserver: {
|
|
|
48
48
|
get(options: object): ResponsesPromptObserver | undefined;
|
|
49
49
|
copy(source: object | undefined, target: object): void;
|
|
50
50
|
};
|
|
51
|
-
type OpenAIResponsesRequestParams = {
|
|
52
|
-
model: string;
|
|
53
|
-
input: ResponseInput;
|
|
54
|
-
stream: true;
|
|
55
|
-
instructions?: string;
|
|
56
|
-
prompt_cache_key?: string;
|
|
57
|
-
prompt_cache_retention?: "24h";
|
|
58
|
-
prompt_cache_options?: {
|
|
59
|
-
ttl: "30m";
|
|
60
|
-
};
|
|
61
|
-
metadata?: Record<string, string>;
|
|
62
|
-
previous_response_id?: string;
|
|
63
|
-
store?: boolean;
|
|
64
|
-
max_output_tokens?: number;
|
|
65
|
-
temperature?: number;
|
|
66
|
-
top_p?: number;
|
|
67
|
-
text?: ResponseCreateParamsStreaming["text"];
|
|
68
|
-
service_tier?: ResponseCreateParamsStreaming["service_tier"];
|
|
69
|
-
tools?: Array<FunctionTool & {
|
|
70
|
-
async?: boolean;
|
|
71
|
-
}>;
|
|
72
|
-
multi_agent?: {
|
|
73
|
-
enabled?: boolean;
|
|
74
|
-
};
|
|
75
|
-
tool_choice?: ResponseCreateParamsStreaming["tool_choice"];
|
|
76
|
-
reasoning?: {
|
|
77
|
-
effort: OpenAIApiReasoningEffort;
|
|
78
|
-
} | {
|
|
79
|
-
effort: OpenAIApiReasoningEffort;
|
|
80
|
-
summary: NonNullable<OpenAIResponsesOptions["reasoningSummary"]>;
|
|
81
|
-
};
|
|
82
|
-
include?: string[];
|
|
83
|
-
};
|
|
84
51
|
//#endregion
|
|
85
|
-
export {
|
|
52
|
+
export { ResponsesPromptObservation as a, readOpenAIResponsesCompactionWindow as c, ReplayableResponseCompactionItem as i, OpenAIResponsesOptions as n, responsesPromptObserver as o, OpenAIResponsesReasoningReplayMetadata as r, OpenAIResponsesCompactionOutput as s, OPENAI_RESPONSES_APIS as t };
|
package/dist/{openai-reasoning-effort-BK7FbcLT.mjs → openai-responses-contracts-DDOHA62Y.mjs}
RENAMED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { r as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE } from "./types-LFWwv0cF.mjs";
|
|
2
|
+
import "./src-DDmEryvj.mjs";
|
|
1
3
|
import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-fsri9iCu.mjs";
|
|
4
|
+
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
2
5
|
import { n as uniqueStrings, t as normalizeStringEntries } from "./string-normalization-CmLIasuf.mjs";
|
|
3
6
|
//#region packages/ai/src/providers/openai-reasoning-effort.ts
|
|
4
7
|
/**
|
|
@@ -164,4 +167,79 @@ function resolveOpenAIReasoningEffortForModel(params) {
|
|
|
164
167
|
return supported.find((effort) => !isDisabledReasoningEffort(normalizeOpenAIReasoningEffort(effort)));
|
|
165
168
|
}
|
|
166
169
|
//#endregion
|
|
167
|
-
|
|
170
|
+
//#region packages/ai/src/transports/openai-responses-contracts.ts
|
|
171
|
+
const DEFAULT_AZURE_OPENAI_API_VERSION = "preview";
|
|
172
|
+
const OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS = "Follow the user request.";
|
|
173
|
+
const AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS = 3e4;
|
|
174
|
+
const RESPONSE_FAILED_NO_DETAILS_MESSAGE = "Unknown error (no error details in response)";
|
|
175
|
+
const OPENAI_RESPONSES_REASONING_REPLAY_META_KEY = "__openclaw_replay";
|
|
176
|
+
const OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY = "openclawReasoningReplay";
|
|
177
|
+
const OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE = "openai-responses-compaction";
|
|
178
|
+
const OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE = "openai-responses-retained-compaction";
|
|
179
|
+
const OPENAI_RESPONSES_APIS = /* @__PURE__ */ new Set([
|
|
180
|
+
"openai-responses",
|
|
181
|
+
"azure-openai-responses",
|
|
182
|
+
"openai-chatgpt-responses",
|
|
183
|
+
"openclaw-openai-responses-transport",
|
|
184
|
+
"openclaw-openai-chatgpt-responses-transport",
|
|
185
|
+
"openclaw-azure-openai-responses-transport"
|
|
186
|
+
]);
|
|
187
|
+
var OpenAIResponsesWebSocketPreDispatchError = class extends Error {
|
|
188
|
+
constructor(cause) {
|
|
189
|
+
super("OpenAI Responses WebSocket failed before request dispatch", { cause });
|
|
190
|
+
this.name = "OpenAIResponsesWebSocketPreDispatchError";
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
var OpenAIResponsesWebSocketPostDispatchError = class extends Error {
|
|
194
|
+
constructor(cause) {
|
|
195
|
+
super("OpenAI Responses WebSocket failed after request dispatch; outcome is unknown", { cause });
|
|
196
|
+
this.code = PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE;
|
|
197
|
+
this.name = "OpenAIResponsesWebSocketPostDispatchError";
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
var OpenAIResponsesWebSocketServerError = class extends Error {
|
|
201
|
+
constructor(code, status, param, message, cause) {
|
|
202
|
+
super(message, { cause });
|
|
203
|
+
this.code = code;
|
|
204
|
+
this.status = status;
|
|
205
|
+
this.param = param;
|
|
206
|
+
this.name = "OpenAIResponsesWebSocketServerError";
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
var OpenAIResponsesWebSocketSafeRetryError = class extends OpenAIResponsesWebSocketServerError {};
|
|
210
|
+
function readWebSocketServerError(value) {
|
|
211
|
+
if (!isRecord(value) || value.type !== "error") return;
|
|
212
|
+
const details = isRecord(value.error) ? value.error : value;
|
|
213
|
+
if (typeof details.code !== "string" || typeof details.message !== "string") return;
|
|
214
|
+
const rawStatus = value.status ?? value.status_code;
|
|
215
|
+
return {
|
|
216
|
+
code: details.code,
|
|
217
|
+
message: details.message,
|
|
218
|
+
param: typeof details.param === "string" ? details.param : null,
|
|
219
|
+
status: typeof rawStatus === "number" ? rawStatus : void 0
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function parseOpenAIResponsesWebSocketServerError(cause) {
|
|
223
|
+
if (!isRecord(cause)) return;
|
|
224
|
+
let details = readWebSocketServerError(cause.error) ?? readWebSocketServerError(cause);
|
|
225
|
+
if (!details && typeof cause.message === "string") try {
|
|
226
|
+
details = readWebSocketServerError(JSON.parse(cause.message));
|
|
227
|
+
} catch {}
|
|
228
|
+
if (!details) return;
|
|
229
|
+
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);
|
|
230
|
+
}
|
|
231
|
+
const PROMPT_OBSERVER = Symbol("openaiResponsesPromptObserver");
|
|
232
|
+
const responsesPromptObserver = {
|
|
233
|
+
set(options, observer) {
|
|
234
|
+
Reflect.set(options, PROMPT_OBSERVER, observer);
|
|
235
|
+
},
|
|
236
|
+
get(options) {
|
|
237
|
+
return Reflect.get(options, PROMPT_OBSERVER);
|
|
238
|
+
},
|
|
239
|
+
copy(source, target) {
|
|
240
|
+
const observer = source && responsesPromptObserver.get(source);
|
|
241
|
+
if (observer) responsesPromptObserver.set(target, observer);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
//#endregion
|
|
245
|
+
export { supportsOpenAITemperature as C, supportsOpenAIReasoningEffort as S, isOpenAIGpt56Model as _, OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE as a, resolveOpenAIReasoningEffortForModel 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, resolveOpenAISupportedReasoningEfforts as x, resolveOpenAIModelReasoningEfforts as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { m as stripSystemPromptCacheBoundary } from "./simple-options-BQbb4yQL.mjs";
|
|
2
|
+
import { _ as sanitizeTransportPayloadText } from "./transport-stream-shared-zHll9BxO.mjs";
|
|
3
|
+
import { m as responsesPromptObserver } from "./openai-responses-contracts-DDOHA62Y.mjs";
|
|
4
4
|
//#region packages/ai/src/transports/openai-responses-prompt-observer-internal.ts
|
|
5
5
|
function readFinalResponsesPrompt(request) {
|
|
6
6
|
if (typeof request.instructions === "string") return ["instructions", request.instructions];
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import { r as appendAssistantThinking } from "./event-stream-D8PARQfL.mjs";
|
|
2
2
|
import { a as normalizeOptionalString } from "./string-coerce-fsri9iCu.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload, n as getAiTransportHost } from "./host-CWuF-sS3.mjs";
|
|
3
|
+
import { M as clampThinkingLevel, _ as isImageWithMediaPayload, d as describeToolResultMediaPlaceholder, j as calculateCost, m as extractToolResultText, n as getAiTransportHost } from "./host-B8YfDGd4.mjs";
|
|
5
4
|
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
6
5
|
import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
|
|
7
|
-
import { i as stableStringify } from "./provider-error-
|
|
8
|
-
import { a as resolveModelSseDebugMode, i as resolveModelPayloadDebugMode, r as emitModelTransportDebug } from "./diagnostics-
|
|
6
|
+
import { i as stableStringify } from "./provider-error-BA-v_tKd.mjs";
|
|
7
|
+
import { a as resolveModelSseDebugMode, i as resolveModelPayloadDebugMode, r as emitModelTransportDebug } from "./diagnostics-QuErwCIl.mjs";
|
|
9
8
|
import { r as asFiniteNumber } from "./base64-D-su8YVo.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import { s as transformTransportMessages } from "./host-policy-
|
|
12
|
-
import {
|
|
13
|
-
import { O as redactIdentifier, _ as createOpenAIProviderAcceptanceHook, b as log, f as projectOpenAITools, g as createModelStreamCooperativeScheduler, k as sha256Hex, u as resolveOpenAIStrictToolFlagWithDiagnostics } from "./openai-transport-params-
|
|
14
|
-
import { _ as
|
|
15
|
-
import { t as
|
|
16
|
-
import { n as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-BuSUaAk5.mjs";
|
|
17
|
-
import { r as parseStreamingJson, t as createToolArgumentPreviewSchedule } from "./json-parse-Dw_hnxsA.mjs";
|
|
9
|
+
import { o as redactSensitiveText } from "./transport-utils-zrYjICLZ.mjs";
|
|
10
|
+
import { s as transformTransportMessages } from "./host-policy-Zcg_cNz8.mjs";
|
|
11
|
+
import { m as stripSystemPromptCacheBoundary, v as sortPromptCacheToolsByName } from "./simple-options-BQbb4yQL.mjs";
|
|
12
|
+
import { O as redactIdentifier, _ as createOpenAIProviderAcceptanceHook, b as log, f as projectOpenAITools, g as createModelStreamCooperativeScheduler, k as sha256Hex, u as resolveOpenAIStrictToolFlagWithDiagnostics } from "./openai-transport-params-9aPuV5YY.mjs";
|
|
13
|
+
import { E as parseStreamingJson, _ as sanitizeTransportPayloadText, b as withProviderResponseHook, g as sanitizeNonEmptyTransportPayloadText, h as parseTerminalToolCallArguments, k as shortHash, l as finalizeTransportStream, s as failTransportStream, t as IncompleteToolCallError, v as transportAbortError, w as createToolArgumentPreviewSchedule } from "./transport-stream-shared-zHll9BxO.mjs";
|
|
14
|
+
import { n as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-CJ_YvcEW.mjs";
|
|
18
15
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
|
|
19
16
|
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-2hfrquuz.mjs";
|
|
20
|
-
import { t as transformProviderMessages } from "./provider-transcript-transform-
|
|
21
|
-
import { a as
|
|
17
|
+
import { t as transformProviderMessages } from "./provider-transcript-transform-V5YzU9zh.mjs";
|
|
18
|
+
import { C as supportsOpenAITemperature, a as OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE, b as resolveOpenAIReasoningEffortForModel, c as OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE, f as RESPONSE_FAILED_NO_DETAILS_MESSAGE, o as OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY, s as OPENAI_RESPONSES_REASONING_REPLAY_META_KEY, y as resolveOpenAIModelReasoningEfforts } from "./openai-responses-contracts-DDOHA62Y.mjs";
|
|
22
19
|
import { a as resolveOpenAIProjectedToolsStrictToolFlag, r as normalizeOpenAIStrictToolParameters } from "./openai-tool-schema-CzjyYXun.mjs";
|
|
23
|
-
import {
|
|
20
|
+
import { n as isOpenAIResponsesCompactionOutput, r as readOpenAIResponsesCompactionWindow } from "./openai-responses-compaction-window-CIhBAkkq.mjs";
|
|
24
21
|
import { createHash, randomUUID } from "node:crypto";
|
|
25
22
|
//#region packages/ai/src/transports/openai-responses-replay.ts
|
|
26
23
|
/** Resolves the assistant message id that can be replayed to OpenAI Responses. */
|
|
@@ -1387,7 +1384,7 @@ function resolveResponsesToolCallId(item, fallbackId) {
|
|
|
1387
1384
|
return resolvedItemId ? `${generated}|${resolvedItemId}` : generated;
|
|
1388
1385
|
}
|
|
1389
1386
|
function resolveCompletedResponsesToolCall(item, streamed) {
|
|
1390
|
-
if (item.status && item.status !== "completed") throw new
|
|
1387
|
+
if (item.status && item.status !== "completed") throw new IncompleteToolCallError("Responses stream completed with an incomplete terminal tool call");
|
|
1391
1388
|
const streamedName = streamed?.name?.trim() || void 0;
|
|
1392
1389
|
const completedName = typeof item.name === "string" ? item.name.trim() || void 0 : void 0;
|
|
1393
1390
|
if (streamedName && completedName && streamedName !== completedName) throw new Error(`Responses stream changed tool-call function name from ${streamedName} to ${completedName}`);
|
|
@@ -2027,7 +2024,10 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
|
|
|
2027
2024
|
if (output.errorMessage) throw new Error(output.errorMessage);
|
|
2028
2025
|
resolveCompletedResponsesToolCall(incompleteToolCall);
|
|
2029
2026
|
}
|
|
2030
|
-
if (event.type === "response.incomplete" && streamingToolCalls.hasActive())
|
|
2027
|
+
if (event.type === "response.incomplete" && streamingToolCalls.hasActive()) {
|
|
2028
|
+
if (output.errorMessage) throw new Error(output.errorMessage);
|
|
2029
|
+
throw new IncompleteToolCallError("Responses stream completed with unresolved tool calls");
|
|
2030
|
+
}
|
|
2031
2031
|
if (event.type === "response.completed" || output.stopReason === "length") {
|
|
2032
2032
|
const items = event.response.output ?? [];
|
|
2033
2033
|
const completeToolCall = event.type === "response.completed" ? prepareTerminalToolCalls(items) : void 0;
|
|
@@ -2218,4 +2218,4 @@ async function runResponsesStreamLifecycle(params) {
|
|
|
2218
2218
|
}
|
|
2219
2219
|
}
|
|
2220
2220
|
//#endregion
|
|
2221
|
-
export {
|
|
2221
|
+
export { resolveResponsesMessageSnapshotCollapse as A, responsesInputFingerprint as B, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE as C, isAzureResponsesTextDeltaEventType as D, isAzureResponsesTextDeltaEvent as E, resolveNextResponsesEncryptedContentAttempt as F, resolveNewestOpenAIResponsesCompactionReplay as G, buildOpenAIResponsesReasoningReplayMetadata as H, buildResponsesInputMessage as I, suppressOpenAIResponsesCompaction as K, convertResponsesMessages$1 as L, createResponsesStreamWithEncryptedContentRetry as M, isInvalidEncryptedContentError as N, isResponsesTextContentPartType as O, resolveAzureOpenAIApiVersion as P, createOpenAIResponsesAssistantOutput as R, AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE as S, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE as T, captureOpenAIResponsesCompaction as U, CompactionReplayRefreshRequiredError as V, isOpenAIResponsesReplayContext as W, safeDebugValue as _, resolveResponsesReasoningEffort as a, createResponsesToolCallTracker as b, convertProjectedResponsesTools as c, mapResponsesTerminalUsage as d, readResponsesReasoningTokens as f, logResponsesFailedNoDetails as g, ResponsesStreamFailure as h, createResponsesAssistantOutput as i, commitResponsesEncryptedContentAttempt as j, isResponsesTextDeltaEventType as k, convertResponsesToolPayload as l, observeResponsesStream as m, applyResponsesServiceTierPricing as n, resolveResponsesRequestReasoningEffort as o, resolveResponsesTerminalStopReason as p, resolveReplayableResponsesMessageId as q, convertResponsesMessages as r, runResponsesStreamLifecycle as s, applyCommonResponsesParams as t, processResponsesStream as u, summarizeOpenAITransportError as v, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE as w, readResponsesToolCallItemIdentity as x, summarizeResponsesPayload as y, recordResponsesInputReplay as z };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { a as normalizeOptionalString, n as normalizeLowercaseStringOrEmpty } from "./string-coerce-fsri9iCu.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { n as getAiTransportHost } from "./host-CWuF-sS3.mjs";
|
|
2
|
+
import { A as applyProviderReportedUsageCost, j as calculateCost, n as getAiTransportHost } from "./host-B8YfDGd4.mjs";
|
|
4
3
|
import { o as isRecord, r as asOptionalObjectRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
5
|
-
import { l as usesNativeOpenAICodexResponsesBackend, n as clampOpenAIPromptCacheKey, s as resolveOpenAICompletionsCompat } from "./openai-prompt-cache-
|
|
6
|
-
import { i as isCodeModeModelVisibleToolName } from "./transport-utils-
|
|
7
|
-
import { n as resolveModelRequestTimeoutMs, o as resolveProviderRequestPolicyConfig } from "./host-policy-
|
|
4
|
+
import { l as usesNativeOpenAICodexResponsesBackend, n as clampOpenAIPromptCacheKey, s as resolveOpenAICompletionsCompat } from "./openai-prompt-cache-Bds-n_9Q.mjs";
|
|
5
|
+
import { i as isCodeModeModelVisibleToolName } from "./transport-utils-zrYjICLZ.mjs";
|
|
6
|
+
import { n as resolveModelRequestTimeoutMs, o as resolveProviderRequestPolicyConfig } from "./host-policy-Zcg_cNz8.mjs";
|
|
8
7
|
import { t as projectRuntimeToolInputSchema } from "./tool-schema-json-projection-ClptDdAO.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { O as headersToRecord, p as notifyProviderHttpResponse, v as transportAbortError } from "./transport-stream-shared-zHll9BxO.mjs";
|
|
9
|
+
import { n as resolveOpencodeSessionHeaders } from "./session-affinity-Bcunsn4I.mjs";
|
|
10
|
+
import { i as OPENAI_RESPONSES_APIS } from "./openai-responses-contracts-DDOHA62Y.mjs";
|
|
11
11
|
import { a as resolveOpenAIProjectedToolsStrictToolFlag, t as findOpenAIStrictToolProjectionDiagnostics } from "./openai-tool-schema-CzjyYXun.mjs";
|
|
12
12
|
import { createHash } from "node:crypto";
|
|
13
13
|
//#region packages/normalization-core/src/node-crypto.ts
|
|
@@ -132,7 +132,7 @@ function readOpenAICompletionsReasoningBatch(delta, visibleReasoningDetailTypes)
|
|
|
132
132
|
}
|
|
133
133
|
function parseOpenAICompletionsUsage(rawUsage, model, options) {
|
|
134
134
|
const cacheRead = rawUsage.prompt_tokens_details?.cached_tokens ?? rawUsage.prompt_cache_hit_tokens ?? 0;
|
|
135
|
-
const cacheWrite = rawUsage.prompt_tokens_details?.cache_write_tokens ?? rawUsage.prompt_tokens_details?.cache_creation_input_tokens ?? 0;
|
|
135
|
+
const cacheWrite = rawUsage.prompt_tokens_details?.cache_write_tokens ?? rawUsage.prompt_tokens_details?.cache_creation_input_tokens ?? rawUsage.cache_creation_input_tokens ?? 0;
|
|
136
136
|
const input = Math.max(0, (rawUsage.prompt_tokens || 0) - cacheRead - cacheWrite);
|
|
137
137
|
const output = rawUsage.completion_tokens || 0;
|
|
138
138
|
const reasoningTokens = rawUsage.completion_tokens_details?.reasoning_tokens;
|
|
@@ -613,7 +613,7 @@ function resolveOpenAIStrictToolFlagWithDiagnostics(projection, strictSetting, c
|
|
|
613
613
|
});
|
|
614
614
|
return strict;
|
|
615
615
|
}
|
|
616
|
-
function buildOpenAIClientHeaders(model, context, optionHeaders, turnHeaders, sessionId) {
|
|
616
|
+
function buildOpenAIClientHeaders(model, context, optionHeaders, turnHeaders, sessionId, cacheRetention) {
|
|
617
617
|
const providerHeaders = { ...model.headers };
|
|
618
618
|
if (model.provider === "github-copilot") Object.assign(providerHeaders, getAiTransportHost().buildCopilotDynamicHeaders(context.messages));
|
|
619
619
|
const callerHeaders = {
|
|
@@ -630,7 +630,8 @@ function buildOpenAIClientHeaders(model, context, optionHeaders, turnHeaders, se
|
|
|
630
630
|
callerHeaders: Object.keys(callerHeaders).length > 0 ? callerHeaders : void 0,
|
|
631
631
|
precedence: "caller-wins"
|
|
632
632
|
}).headers ?? {};
|
|
633
|
-
|
|
633
|
+
const sendSessionIdHeader = (OPENAI_RESPONSES_APIS.has(model.api) && model.compat && "sendSessionIdHeader" in model.compat ? model.compat?.sendSessionIdHeader : void 0) ?? usesNativeOpenAICodexResponsesBackend(model);
|
|
634
|
+
if (sessionId && cacheRetention !== "none" && sendSessionIdHeader && !Object.keys(resolvedHeaders).some((key) => normalizeLowercaseStringOrEmpty(key) === "session_id")) resolvedHeaders.session_id = clampOpenAIPromptCacheKey(sessionId) ?? sessionId;
|
|
634
635
|
return resolveOpencodeSessionHeaders(model, {
|
|
635
636
|
sessionId,
|
|
636
637
|
headers: resolvedHeaders
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { o as parseStrictPositiveInteger } from "./base64-D-su8YVo.mjs";
|
|
2
|
+
//#region packages/ai/src/transports/positive-integer.ts
|
|
3
|
+
function parsePositiveInteger(value) {
|
|
4
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) return Math.floor(value);
|
|
5
|
+
return typeof value === "string" ? parseStrictPositiveInteger(value) : void 0;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { parsePositiveInteger as t };
|
|
@@ -47,6 +47,13 @@ function extractBalancedJsonFragments(raw, opts = {}) {
|
|
|
47
47
|
return fragments;
|
|
48
48
|
}
|
|
49
49
|
//#endregion
|
|
50
|
+
//#region packages/normalization-core/src/expect.ts
|
|
51
|
+
/** Returns the value or throws with the named context; use for genuine invariants only. */
|
|
52
|
+
function expectDefined(value, context) {
|
|
53
|
+
if (value === null || value === void 0) throw new Error("expected " + context + " to be defined");
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
50
57
|
//#region packages/normalization-core/src/stable-stringify.ts
|
|
51
58
|
const preserveString = (value) => value;
|
|
52
59
|
/** Deterministically stringifies values, optionally normalizing strings before key ordering. */
|
|
@@ -130,12 +137,38 @@ const LOOSE_QUOTED_CREDENTIAL_PAIR_RE = /\b((?!(?:api|endpoint|method|model|prov
|
|
|
130
137
|
const LOOSE_CREDENTIAL_PAIR_RE = /\b((?!(?:api|endpoint|method|model|provider|status|type)=)[A-Za-z][A-Za-z0-9_.-]{0,64})=([A-Za-z0-9+/._~%=-]{16,})(?=[;&#'"\s]|$)/giu;
|
|
131
138
|
const MEDIA_DATA_URL_RE = /data:(?:audio|image|video)\/[a-z0-9.+-]+(?:;[^,;\s]+)*;base64,[ \t]*(?:\r?\n[ \t]*)?[a-z0-9+/_=-]+(?:[ \t]*\r?\n[ \t]*[a-z0-9+/_=-]+)*/giu;
|
|
132
139
|
const MAX_DIAGNOSTIC_JSON_LENGTH = 16384;
|
|
133
|
-
const
|
|
140
|
+
const BRACKET_PROSE_PATTERN = String.raw`(\[+)([A-Za-z][A-Za-z0-9 _.-]*|\s*\d+\s+(?!(?:true|false|null)(?![\w-]))[A-Za-z][A-Za-z0-9 _.=-]*)(\]+)`;
|
|
141
|
+
const BRACKET_PROSE_RE = new RegExp(`^${BRACKET_PROSE_PATTERN}$`, "u");
|
|
142
|
+
const BRACKET_PROSE_PART_RE = new RegExp(String.raw`(?<!\[)${BRACKET_PROSE_PATTERN}`, "gu");
|
|
143
|
+
const JSON_LITERAL_PROSE_START_RE = /^(?:true|false|null)\b(?!-)/u;
|
|
144
|
+
const PROSE_ASSIGNMENT_RE = /(?<![A-Za-z0-9_.-])([A-Za-z0-9_.-]+)\s*(?:=\s*)+(?=([^=;&\s\]'"},]+))/gu;
|
|
145
|
+
const PRIVATE_KEY_HEADER_RE = /-----BEGIN [A-Z ]*PRIVATE KEY/iu;
|
|
134
146
|
const JSON_ARRAY_START_RE = /\[\s*(?:[{"\d\]-]|true\b|false\b|null\b)/u;
|
|
135
147
|
const MALFORMED_JSON_RE = /\{|(?:"[^"]+"|\b(?:b64_json|data|(?:input|output)?(?:audio|image|video)[\w-]*))\s*:/iu;
|
|
136
148
|
function looksLikeDiagnosticJson(value) {
|
|
137
149
|
return JSON_ARRAY_START_RE.test(value) || MALFORMED_JSON_RE.test(value);
|
|
138
150
|
}
|
|
151
|
+
function isPlainBracketProse(value) {
|
|
152
|
+
const match = BRACKET_PROSE_RE.exec(value);
|
|
153
|
+
return match !== null && expectDefined(match[1], "opening brackets").length === expectDefined(match[3], "closing brackets").length && !JSON_LITERAL_PROSE_START_RE.test(expectDefined(match[2], "bracket prose"));
|
|
154
|
+
}
|
|
155
|
+
function hasSensitiveProseContent(value) {
|
|
156
|
+
if (PRIVATE_KEY_HEADER_RE.test(value)) return true;
|
|
157
|
+
let mediaContext = false;
|
|
158
|
+
let contextualPayload = false;
|
|
159
|
+
for (const match of value.matchAll(PROSE_ASSIGNMENT_RE)) {
|
|
160
|
+
const assigned = expectDefined(match[2], "diagnostic assignment value");
|
|
161
|
+
const valueEnd = match.index + match[0].length + assigned.length;
|
|
162
|
+
if (assigned === "<redacted>" && value[valueEnd] !== "=") continue;
|
|
163
|
+
const key = expectDefined(match[1], "diagnostic assignment field");
|
|
164
|
+
const normalized = normalizeDiagnosticFieldName(key);
|
|
165
|
+
if (isCredentialFieldName(normalized) || extractDiagnosticMediaField(key, normalized, void 0, false)) return true;
|
|
166
|
+
mediaContext ||= isDiagnosticMediaPayload({ [key]: { value: assigned } });
|
|
167
|
+
contextualPayload ||= Boolean(extractDiagnosticMediaField(key, normalized, void 0, true));
|
|
168
|
+
if (mediaContext && contextualPayload) return true;
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
139
172
|
function normalizeDiagnosticFieldName(value) {
|
|
140
173
|
return value.toLowerCase().replaceAll(/[^a-z0-9]/g, "");
|
|
141
174
|
}
|
|
@@ -262,7 +295,12 @@ function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new W
|
|
|
262
295
|
function redactDiagnosticText(value) {
|
|
263
296
|
const text = redactCredentialText(value).replace(MEDIA_DATA_URL_RE, "<redacted>");
|
|
264
297
|
if (!looksLikeDiagnosticJson(text)) return text;
|
|
265
|
-
|
|
298
|
+
const allowProse = !hasSensitiveProseContent(text);
|
|
299
|
+
if (text.length > MAX_DIAGNOSTIC_JSON_LENGTH) {
|
|
300
|
+
const remaining = allowProse && !MALFORMED_JSON_RE.test(text) ? text.replace(BRACKET_PROSE_PART_RE, (part) => isPlainBracketProse(part) ? "" : part) : text;
|
|
301
|
+
if (allowProse && !/[[\]{}]/u.test(remaining) && !MALFORMED_JSON_RE.test(text)) return text;
|
|
302
|
+
return "[Oversized diagnostic JSON redacted]";
|
|
303
|
+
}
|
|
266
304
|
let cursor = 0;
|
|
267
305
|
let redacted = "";
|
|
268
306
|
let unstructured = "";
|
|
@@ -270,6 +308,11 @@ function redactDiagnosticText(value) {
|
|
|
270
308
|
const plainText = text.slice(cursor, fragment.startIndex);
|
|
271
309
|
unstructured += plainText;
|
|
272
310
|
redacted += plainText;
|
|
311
|
+
if (allowProse && isPlainBracketProse(fragment.json)) {
|
|
312
|
+
redacted += fragment.json;
|
|
313
|
+
cursor = fragment.endIndex + 1;
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
273
316
|
try {
|
|
274
317
|
const state = {
|
|
275
318
|
changed: false,
|
|
@@ -278,8 +321,7 @@ function redactDiagnosticText(value) {
|
|
|
278
321
|
const projected = projectDiagnosticValue(JSON.parse(fragment.json), {}, /* @__PURE__ */ new WeakSet(), false, state);
|
|
279
322
|
redacted += state.changed ? stableStringify(projected) : fragment.json;
|
|
280
323
|
} catch {
|
|
281
|
-
|
|
282
|
-
redacted += fragment.json;
|
|
324
|
+
return "[Malformed diagnostic JSON redacted]";
|
|
283
325
|
}
|
|
284
326
|
cursor = fragment.endIndex + 1;
|
|
285
327
|
}
|
|
@@ -364,4 +406,4 @@ function projectProviderError(error, signal) {
|
|
|
364
406
|
}
|
|
365
407
|
}
|
|
366
408
|
//#endregion
|
|
367
|
-
export { stableStringify as i, projectProviderError as n, projectDiagnosticValue as r, configureProviderErrorRedactor as t };
|
|
409
|
+
export { expectDefined as a, stableStringify as i, projectProviderError as n, projectDiagnosticValue as r, configureProviderErrorRedactor as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Y as StreamOptions } from "./types-Ntv5z2g2.mjs";
|
|
2
2
|
import { t as OpenAICompletionsToolChoice } from "./openai-tool-projection-793cE3QX.mjs";
|
|
3
|
-
import "./types-
|
|
3
|
+
import "./types-DlfwzH3T.mjs";
|
|
4
4
|
import Anthropic from "@anthropic-ai/sdk";
|
|
5
5
|
//#region packages/ai/src/providers/openai-reasoning-effort.d.ts
|
|
6
6
|
type OpenAIReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as shortHash } from "./transport-stream-shared-zHll9BxO.mjs";
|
|
2
2
|
//#region packages/ai/src/transports/provider-replay-context.ts
|
|
3
3
|
function hashReplayContextValue(value) {
|
|
4
4
|
const normalized = value?.trim();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as transformMessages } from "./host-
|
|
1
|
+
import { i as transformMessages } from "./host-B8YfDGd4.mjs";
|
|
2
2
|
//#region packages/ai/src/provider-transcript-transform.ts
|
|
3
3
|
const IMAGE_OMISSION = "(image omitted: model does not support images)";
|
|
4
4
|
const VIDEO_OMISSION = "(video omitted: provider does not support video input)";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { n as getAiTransportHost } from "./host-B8YfDGd4.mjs";
|
|
2
|
+
import { n as resolveOpencodeSessionHeaders, t as hasOpencodeSessionHeader } from "./session-affinity-Bcunsn4I.mjs";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
//#region packages/ai/src/transports/provider-transport-turn-state.ts
|
|
5
|
+
function resolveProviderTransportTurnState(model, params) {
|
|
6
|
+
const normalizedProvider = model.provider.trim().toLowerCase();
|
|
7
|
+
const allowRuntimePluginLoad = normalizedProvider === "openai" || normalizedProvider === "azure-openai" || normalizedProvider === "azure-openai-responses";
|
|
8
|
+
return getAiTransportHost().plugin.resolveTransportTurnState({
|
|
9
|
+
provider: model.provider,
|
|
10
|
+
modelId: model.id,
|
|
11
|
+
allowRuntimePluginLoad,
|
|
12
|
+
context: {
|
|
13
|
+
provider: model.provider,
|
|
14
|
+
modelId: model.id,
|
|
15
|
+
model,
|
|
16
|
+
sessionId: params.sessionId,
|
|
17
|
+
turnId: params.turnId,
|
|
18
|
+
attempt: params.attempt,
|
|
19
|
+
transport: params.transport
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function filterProviderTurnHeadersForExplicitOpencodeSession(model, options, turnHeaders) {
|
|
24
|
+
if (!turnHeaders || !hasOpencodeSessionHeader(model, options)) return turnHeaders;
|
|
25
|
+
const filtered = Object.fromEntries(Object.entries(turnHeaders).filter(([name]) => name.toLowerCase() !== "x-opencode-session"));
|
|
26
|
+
return Object.keys(filtered).length > 0 ? filtered : void 0;
|
|
27
|
+
}
|
|
28
|
+
function resolveProviderSimpleCompletionHeaders(model, options) {
|
|
29
|
+
const optionHeaders = resolveOpencodeSessionHeaders(model, options);
|
|
30
|
+
const turnState = resolveProviderTransportTurnState(model, {
|
|
31
|
+
sessionId: options?.sessionId,
|
|
32
|
+
turnId: randomUUID(),
|
|
33
|
+
attempt: 1,
|
|
34
|
+
transport: "stream"
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
...filterProviderTurnHeadersForExplicitOpencodeSession(model, { headers: optionHeaders }, turnState?.headers),
|
|
38
|
+
...optionHeaders
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { resolveProviderSimpleCompletionHeaders as n, resolveProviderTransportTurnState as r, filterProviderTurnHeadersForExplicitOpencodeSession as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as index_d_exports } from "./index-
|
|
2
|
-
import {
|
|
3
|
-
import "./types-
|
|
1
|
+
import { t as index_d_exports } from "./index-DdD3qerf.mjs";
|
|
2
|
+
import { O as Model, X as TextContent, Y as StreamOptions, a as AssistantMessage, d as Context, f as ImageContent, it as ToolResultMessage, n as Api, s as AssistantMessageEventStreamContract, st as UserMessage } from "./types-Ntv5z2g2.mjs";
|
|
3
|
+
import "./types-DlfwzH3T.mjs";
|
|
4
4
|
//#region packages/ai/src/provider-types.d.ts
|
|
5
5
|
declare const PROVIDER_CONTEXT_HANDOFF: unique symbol;
|
|
6
6
|
type VideoContent = Omit<ImageContent, "type"> & {
|