@openclaw/ai 2026.9.4 → 2026.9.5
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 +1 -1
- package/dist/{anthropic-C4Qu4H0Z.mjs → anthropic-COtDvgtt.mjs} +10 -11
- package/dist/{anthropic-payload-policy-BZ8umAbk.d.mts → anthropic-payload-policy-5Erq1Nzy.d.mts} +3 -3
- package/dist/{anthropic-stream-reducer-CILWF7JD.mjs → anthropic-stream-reducer-BvdYYWL8.mjs} +47 -43
- package/dist/{api-registry-ByUwIR0e.d.mts → api-registry-Ba2Cv-ut.d.mts} +2 -2
- package/dist/{assistant-output-tLt4H-iQ.mjs → assistant-output-BsEkB-vU.mjs} +1 -1
- package/dist/{azure-openai-responses-BAlqlKKc.mjs → azure-openai-responses-YrgnD583.mjs} +6 -9
- package/dist/{base64-D-su8YVo.mjs → base64-BQOzsvUH.mjs} +4 -4
- package/dist/credential-redaction-BKv49aiv.d.mts +24 -0
- package/dist/{diagnostics-QuErwCIl.mjs → diagnostics-Dm4bisWG.mjs} +89 -2
- package/dist/diagnostics.d.mts +4 -23
- package/dist/diagnostics.mjs +3 -3
- package/dist/{event-stream-Bt5Y4Pav.d.mts → event-stream-CCoa-qSI.d.mts} +1 -1
- package/dist/event-stream-DmSCpi1T.d.mts +1 -0
- package/dist/event-stream.d.mts +2 -2
- package/dist/expect-lbe3Hgrh.mjs +8 -0
- package/dist/{google-DPBAOaOW.mjs → google-BuhpRO9r.mjs} +6 -9
- package/dist/{google-messages-6JkpHrhJ.mjs → google-messages-CyWnYlh0.mjs} +3 -3
- package/dist/{google-shared-BvBeW9aq.mjs → google-shared-BT5ZeNer.mjs} +13 -13
- package/dist/{google-vertex-k-TMCAYD.mjs → google-vertex-C7EplRvt.mjs} +5 -8
- package/dist/{host-B8YfDGd4.mjs → host-B4MeUNBc.mjs} +25 -27
- package/dist/{host-4atIX-2V.d.mts → host-FZ1RA_qD.d.mts} +5 -3
- package/dist/{host-policy-Zcg_cNz8.mjs → host-policy-DUnXSx0I.mjs} +1 -1
- package/dist/{index-DdD3qerf.d.mts → index-DaF2QbwS.d.mts} +4 -9
- package/dist/index.d.mts +6 -7
- package/dist/index.mjs +3 -4
- package/dist/internal/anthropic.d.mts +6 -7
- package/dist/internal/anthropic.mjs +4 -4
- package/dist/internal/openai-completions-compat.d.mts +2 -0
- package/dist/internal/openai-completions-compat.mjs +2 -0
- 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 +10 -53
- package/dist/internal/openai.mjs +11 -9
- package/dist/internal/runtime.d.mts +6 -8
- package/dist/internal/runtime.mjs +5 -9
- package/dist/internal/shared.d.mts +6 -5
- package/dist/internal/shared.mjs +4 -3
- package/dist/internal/tool-schema.d.mts +3 -3
- package/dist/internal/tool-schema.mjs +2 -2
- package/dist/{mistral-CxUZ1jUb.mjs → mistral-moA-mbwl.mjs} +9 -13
- package/dist/{openai-chatgpt-responses-CgO6kZfo.mjs → openai-chatgpt-responses-DWID3EFO.mjs} +73 -29
- package/dist/{openai-completions-yJuk7eis.mjs → openai-completions-DJ1Vm-CD.mjs} +11 -12
- package/dist/{openai-prompt-cache-Bds-n_9Q.mjs → openai-completions-compat-CkwdxTZx.mjs} +5 -50
- package/dist/{openai-completions-compat-eHgh5UPE.d.mts → openai-completions-compat-JE7gqxb9.d.mts} +4 -4
- package/dist/{openai-completions-stream-Da2vvl-S.mjs → openai-completions-stream-Bu98b0Hv.mjs} +94 -96
- package/dist/openai-prompt-cache-1wfaIszn.mjs +46 -0
- package/dist/{openai-prompt-cache-B4eYo2-I.d.mts → openai-prompt-cache-CJ_xEevu.d.mts} +2 -2
- package/dist/{openai-provider-client-S2gCrM2Z.mjs → openai-provider-client-DPo0Hmak.mjs} +2 -2
- package/dist/openai-reasoning-effort-NlFZmfEu.mjs +235 -0
- package/dist/{openai-responses-DaYwH05E.mjs → openai-responses-BejZzQCP.mjs} +8 -12
- package/dist/{openai-responses-compaction-window-CIhBAkkq.mjs → openai-responses-compaction-window-D6P5oZP5.mjs} +20 -62
- package/dist/openai-responses-contracts-DWrfMODE.mjs +81 -0
- package/dist/{openai-responses-contracts-BjBAqAg_.d.mts → openai-responses-contracts-Dflvrfa8.d.mts} +9 -5
- package/dist/{openai-responses-payload-policy-rLRPsSmB.d.mts → openai-responses-payload-policy-C7GsA1y0.d.mts} +5 -3
- package/dist/openai-responses-prompt-observer-internal-C15_-OwV.mjs +195 -0
- package/dist/{openai-responses-shared-B8RdBPCv.mjs → openai-responses-shared-CwsziD_m.mjs} +385 -178
- package/dist/openai-responses-terminal-usage-Dl3J6zrf.d.mts +47 -0
- package/dist/{openai-tool-schema-CzjyYXun.mjs → openai-tool-schema-BO8rwyAD.mjs} +92 -68
- package/dist/{openai-transport-params-9aPuV5YY.mjs → openai-transport-params-DQeuAvBl.mjs} +157 -47
- package/dist/{positive-integer-41zhOdcV.mjs → positive-integer-DtjCkbue.mjs} +1 -1
- package/dist/{provider-error-BA-v_tKd.mjs → provider-error-DDqw9Qda.mjs} +100 -38
- package/dist/{provider-options-Ceqv1OKk.d.mts → provider-options-DprLsWh9.d.mts} +9 -6
- package/dist/{provider-replay-context-CJ_YvcEW.mjs → provider-replay-context-CnUSOwhr.mjs} +1 -1
- package/dist/{provider-transcript-transform-V5YzU9zh.mjs → provider-transcript-transform-BsRAhuWJ.mjs} +1 -1
- package/dist/{provider-transport-turn-state-D5EXOFL2.mjs → provider-transport-turn-state-CkGToCD2.mjs} +1 -1
- package/dist/{provider-types-CVjKjsuq.d.mts → provider-types-CAKRC7N5.d.mts} +3 -3
- package/dist/provider-types.d.mts +5 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +10 -10
- package/dist/{reasoning-tag-text-partitioner-BcR5pztD.mjs → reasoning-tag-text-partitioner-Dy9IO8Dc.mjs} +15 -7
- package/dist/{simple-options-BQbb4yQL.mjs → simple-options-C6cFWj_f.mjs} +5 -3
- package/dist/{usage-cost-BNWbbXav.mjs → src-DeKjbE8I.mjs} +3 -5
- package/dist/{stream-first-event-timeout-2hfrquuz.mjs → stream-first-event-timeout-C9ZadkJW.mjs} +1 -1
- package/dist/{string-normalization-CmLIasuf.mjs → string-normalization-J9ZiLfGO.mjs} +13 -1
- package/dist/tool-schema-json-projection-CD9c_fK8.mjs +134 -0
- package/dist/{transport-stream-shared-DNvmoWnv.d.mts → transport-stream-shared-BbUkFaHi.d.mts} +4 -4
- package/dist/{transport-stream-shared-zHll9BxO.mjs → transport-stream-shared-D-6FQSHm.mjs} +14 -14
- package/dist/{transport-utils-zrYjICLZ.mjs → transport-utils-1cyq5Y7x.mjs} +3 -3
- package/dist/transports.d.mts +26 -12
- package/dist/transports.mjs +130 -449
- package/dist/{types-Ntv5z2g2.d.mts → types-4_uVs5WH.d.mts} +47 -3
- package/dist/types-DkJfb4W3.d.mts +1 -0
- package/dist/types.d.mts +5 -6
- package/dist/types.mjs +2 -3
- package/dist/{validation-B0t_G2H6.d.mts → validation-Ctzu2DhF.d.mts} +1 -1
- package/dist/{validation-BDzVDnTs.mjs → validation-Dw7cb6BV.mjs} +1 -0
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +10 -5
- package/dist/diagnostics-DnPnOui6.d.mts +0 -29
- package/dist/event-stream-C3WGFsum.d.mts +0 -1
- package/dist/openai-responses-contracts-DDOHA62Y.mjs +0 -245
- package/dist/openai-responses-prompt-observer-internal-f8J7wpsk.mjs +0 -32
- package/dist/src-DDmEryvj.mjs +0 -2
- package/dist/tool-schema-json-projection-ClptDdAO.mjs +0 -82
- package/dist/types-DlfwzH3T.d.mts +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { i as normalizeOptionalLowercaseString, n as normalizeLowercaseStringOrEmpty, s as readStringValue } from "./string-coerce-fsri9iCu.mjs";
|
|
2
2
|
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
3
|
+
import { l as supportsOpenAIReasoningEffort } from "./openai-reasoning-effort-NlFZmfEu.mjs";
|
|
4
|
+
import { t as canonicalizeBase64 } from "./base64-BQOzsvUH.mjs";
|
|
5
|
+
import { t as parsePositiveInteger } from "./positive-integer-DtjCkbue.mjs";
|
|
6
|
+
import { i as OPENAI_RESPONSES_APIS } from "./openai-responses-contracts-DWrfMODE.mjs";
|
|
6
7
|
import { t as createSseByteGuard } from "./streaming-byte-guard-CC-HMn_u.mjs";
|
|
7
8
|
//#region packages/model-catalog-core/src/provider-id.ts
|
|
8
9
|
function normalizeProviderId(provider) {
|
|
@@ -20,33 +21,6 @@ const OPENAI_RESPONSES_PROVIDERS = /* @__PURE__ */ new Set([
|
|
|
20
21
|
"azure-openai",
|
|
21
22
|
"azure-openai-responses"
|
|
22
23
|
]);
|
|
23
|
-
const LOCAL_ENDPOINT_HOSTS = /* @__PURE__ */ new Set([
|
|
24
|
-
"localhost",
|
|
25
|
-
"127.0.0.1",
|
|
26
|
-
"::1",
|
|
27
|
-
"[::1]"
|
|
28
|
-
]);
|
|
29
|
-
const MODELSTUDIO_NATIVE_BASE_URLS = /* @__PURE__ */ new Set([
|
|
30
|
-
"https://coding-intl.dashscope.aliyuncs.com/v1",
|
|
31
|
-
"https://coding.dashscope.aliyuncs.com/v1",
|
|
32
|
-
"https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
33
|
-
"https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
|
|
34
|
-
]);
|
|
35
|
-
const MOONSHOT_NATIVE_BASE_URLS = /* @__PURE__ */ new Set(["https://api.moonshot.ai/v1", "https://api.moonshot.cn/v1"]);
|
|
36
|
-
function normalizeComparableBaseUrl(value) {
|
|
37
|
-
const trimmed = readStringValue(value)?.trim();
|
|
38
|
-
if (!trimmed) return;
|
|
39
|
-
const parsedValue = /^[a-z0-9.[\]-]+(?::\d+)?(?:[/?#].*)?$/i.test(trimmed) ? `https://${trimmed}` : trimmed;
|
|
40
|
-
try {
|
|
41
|
-
const url = new URL(parsedValue);
|
|
42
|
-
if (url.protocol !== "http:" && url.protocol !== "https:") return;
|
|
43
|
-
url.hash = "";
|
|
44
|
-
url.search = "";
|
|
45
|
-
return url.toString().replace(/\/+$/, "").toLowerCase();
|
|
46
|
-
} catch {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
24
|
function resolveUrlHostname(value) {
|
|
51
25
|
const trimmed = readStringValue(value)?.trim();
|
|
52
26
|
if (!trimmed) return;
|
|
@@ -60,45 +34,22 @@ function resolveUrlHostname(value) {
|
|
|
60
34
|
}
|
|
61
35
|
}
|
|
62
36
|
}
|
|
63
|
-
function
|
|
64
|
-
return suffix.startsWith(".") || suffix.startsWith("-") ? host.endsWith(suffix) : host === suffix || host.endsWith(`.${suffix}`);
|
|
65
|
-
}
|
|
66
|
-
function isLocalEndpointHost(host) {
|
|
67
|
-
return LOCAL_ENDPOINT_HOSTS.has(host) || host.endsWith(".localhost") || host.endsWith(".local") || host.endsWith(".internal");
|
|
68
|
-
}
|
|
69
|
-
function resolveBundledOpenAIResponsesEndpointClass(baseUrl) {
|
|
37
|
+
function resolveOpenAIResponsesEndpointClass(baseUrl) {
|
|
70
38
|
const trimmed = readStringValue(baseUrl)?.trim();
|
|
71
39
|
if (!trimmed) return "default";
|
|
72
40
|
const host = resolveUrlHostname(trimmed);
|
|
73
|
-
if (!host) return "
|
|
74
|
-
const comparableBaseUrl = normalizeComparableBaseUrl(trimmed);
|
|
41
|
+
if (!host) return "custom";
|
|
75
42
|
switch (host) {
|
|
76
|
-
case "api.anthropic.com": return "anthropic-public";
|
|
77
|
-
case "api.cerebras.ai": return "cerebras-native";
|
|
78
|
-
case "llm.chutes.ai": return "chutes-native";
|
|
79
|
-
case "api.deepseek.com": return "deepseek-native";
|
|
80
|
-
case "api.groq.com": return "groq-native";
|
|
81
|
-
case "api.mistral.ai": return "mistral-public";
|
|
82
43
|
case "api.openai.com": return "openai-public";
|
|
83
44
|
case "chatgpt.com": return "openai";
|
|
84
|
-
case "generativelanguage.googleapis.com": return "google-generative-ai";
|
|
85
|
-
case "aiplatform.googleapis.com": return "google-vertex";
|
|
86
45
|
case "api.x.ai": return "xai-native";
|
|
87
|
-
case "api.z.ai": return "zai-native";
|
|
88
46
|
}
|
|
89
|
-
if (hostMatchesSuffix(host, ".githubcopilot.com")) return "github-copilot-native";
|
|
90
47
|
if ([
|
|
91
48
|
".openai.azure.com",
|
|
92
49
|
".cognitiveservices.azure.com",
|
|
93
50
|
".services.ai.azure.com",
|
|
94
51
|
".api.cognitive.microsoft.com"
|
|
95
|
-
].some((suffix) =>
|
|
96
|
-
if (hostMatchesSuffix(host, "openrouter.ai")) return "openrouter";
|
|
97
|
-
if (hostMatchesSuffix(host, "opencode.ai")) return "opencode-native";
|
|
98
|
-
if (hostMatchesSuffix(host, "-aiplatform.googleapis.com")) return "google-vertex";
|
|
99
|
-
if (comparableBaseUrl && MOONSHOT_NATIVE_BASE_URLS.has(comparableBaseUrl)) return "moonshot-native";
|
|
100
|
-
if (comparableBaseUrl && MODELSTUDIO_NATIVE_BASE_URLS.has(comparableBaseUrl)) return "modelstudio-native";
|
|
101
|
-
if (isLocalEndpointHost(host)) return "local";
|
|
52
|
+
].some((suffix) => host.endsWith(suffix))) return "azure-openai";
|
|
102
53
|
return "custom";
|
|
103
54
|
}
|
|
104
55
|
function isOpenAIResponsesApi(api) {
|
|
@@ -113,7 +64,7 @@ function resolveOpenAIResponsesPayloadCapabilities(model) {
|
|
|
113
64
|
const provider = normalizeOptionalLowercaseString(model.provider);
|
|
114
65
|
const api = normalizeOptionalLowercaseString(model.api);
|
|
115
66
|
const isOpenAIProvider = provider === "openai";
|
|
116
|
-
const endpointClass =
|
|
67
|
+
const endpointClass = resolveOpenAIResponsesEndpointClass(model.baseUrl);
|
|
117
68
|
const isResponsesApi = isOpenAIResponsesApi(api);
|
|
118
69
|
const usesConfiguredBaseUrl = endpointClass !== "default";
|
|
119
70
|
const usesKnownNativeOpenAIEndpoint = endpointClass === "openai-public" || endpointClass === "openai" || endpointClass === "azure-openai";
|
|
@@ -123,9 +74,11 @@ function resolveOpenAIResponsesPayloadCapabilities(model) {
|
|
|
123
74
|
const promptCacheKeySupport = readCompatPayloadBoolean(model.compat, "supportsPromptCacheKey");
|
|
124
75
|
const shouldStripResponsesPromptCache = promptCacheKeySupport === true ? false : promptCacheKeySupport === false ? isResponsesApi : isResponsesApi && usesExplicitProxyLikeEndpoint;
|
|
125
76
|
const supportsResponsesStoreField = readCompatPayloadBoolean(model.compat, "supportsStore") !== false && isResponsesApi;
|
|
77
|
+
const explicitContinuationOptIn = (api === "openai-responses" || api === "openclaw-openai-responses-transport") && supportsResponsesStoreField && provider !== "azure-openai" && provider !== "azure-openai-responses" && readCompatPayloadBoolean(model.compat, "supportsResponsesContinuation") === true;
|
|
126
78
|
return {
|
|
127
79
|
allowsOpenAIServiceTier: provider === "openai" && (api === "openai-responses" || api === "openclaw-openai-responses-transport") && endpointClass === "openai-public" || isOpenAIProvider && (api === "openai-chatgpt-responses" || api === "openclaw-openai-chatgpt-responses-transport" || api === "openai-responses" || api === "openclaw-openai-responses-transport") && endpointClass === "openai",
|
|
128
80
|
allowsResponsesStore: supportsResponsesStoreField && api !== "openai-chatgpt-responses" && api !== "openclaw-openai-chatgpt-responses-transport" && provider !== void 0 && OPENAI_RESPONSES_PROVIDERS.has(provider) && usesKnownNativeOpenAIEndpoint,
|
|
81
|
+
explicitContinuationOptIn,
|
|
129
82
|
shouldStripResponsesPromptCache,
|
|
130
83
|
supportsResponsesStoreField,
|
|
131
84
|
usesKnownNativeOpenAIRoute,
|
|
@@ -150,11 +103,14 @@ function resolveOpenAIResponsesServerCompactionPlan(model, extraParams) {
|
|
|
150
103
|
threshold: enabled ? parsePositiveInteger(extraParams?.responsesCompactThreshold) ?? resolveOpenAIResponsesCompactThreshold(model) : void 0
|
|
151
104
|
};
|
|
152
105
|
}
|
|
153
|
-
/** Resolve the
|
|
154
|
-
function resolveOpenAIResponsesCompactEndpointPlan(model, extraParams) {
|
|
106
|
+
/** Resolve the Responses compact-endpoint gate for one route and compaction purpose. */
|
|
107
|
+
function resolveOpenAIResponsesCompactEndpointPlan(model, extraParams, purpose = "manual") {
|
|
155
108
|
const configured = extraParams?.responsesCompactEndpoint;
|
|
156
109
|
const provider = typeof model.provider === "string" ? normalizeProviderId(model.provider) : "";
|
|
157
|
-
|
|
110
|
+
const api = normalizeOptionalLowercaseString(model.api);
|
|
111
|
+
const endpointClass = resolveOpenAIResponsesEndpointClass(model.baseUrl);
|
|
112
|
+
const enabledByDefault = (provider === "xai" || provider === "x-ai") && endpointClass === "xai-native" || purpose === "budget" && provider === "openai" && api === "openai-responses" && endpointClass === "openai-public";
|
|
113
|
+
return { enabled: isOpenAIResponsesApi(api) && configured !== false && (configured === true || enabledByDefault) };
|
|
158
114
|
}
|
|
159
115
|
function stripDisabledOpenAIReasoningPayload(payloadObj) {
|
|
160
116
|
const reasoning = payloadObj.reasoning;
|
|
@@ -174,15 +130,17 @@ function stripInputItemStatuses(input) {
|
|
|
174
130
|
function resolveOpenAIResponsesPayloadPolicy(model, options = {}) {
|
|
175
131
|
const capabilities = resolveOpenAIResponsesPayloadCapabilities(model);
|
|
176
132
|
const storeMode = options.storeMode ?? "provider-policy";
|
|
177
|
-
const explicitStore = storeMode === "preserve" ? void 0 : storeMode === "disable" ? capabilities.supportsResponsesStoreField ? false : void 0 : capabilities.allowsResponsesStore ? true : void 0;
|
|
133
|
+
const explicitStore = storeMode === "preserve" ? void 0 : storeMode === "disable" || storeMode === "transport-default" && !capabilities.explicitContinuationOptIn ? capabilities.supportsResponsesStoreField ? false : void 0 : capabilities.allowsResponsesStore || capabilities.explicitContinuationOptIn ? true : void 0;
|
|
178
134
|
const isResponsesApi = isOpenAIResponsesApi(normalizeOptionalLowercaseString(model.api));
|
|
179
|
-
const shouldStripDisabledReasoningPayload = isResponsesApi && (
|
|
135
|
+
const shouldStripDisabledReasoningPayload = isResponsesApi && !supportsOpenAIReasoningEffort(capabilities.usesKnownNativeOpenAIRoute ? model : { compat: model.compat }, "none");
|
|
180
136
|
const shouldStripInputStatus = isResponsesApi && !capabilities.usesKnownNativeOpenAIRoute;
|
|
181
137
|
const serverCompactionPlan = resolveOpenAIResponsesServerCompactionPlan(model, options.extraParams);
|
|
182
138
|
const usesInstructionsField = readCompatPayloadBoolean(model.compat, "supportsInstructions") ?? capabilities.usesVerifiedInstructionsEndpoint;
|
|
183
139
|
return {
|
|
184
140
|
allowsServiceTier: capabilities.allowsOpenAIServiceTier,
|
|
185
141
|
compactThreshold: serverCompactionPlan.threshold,
|
|
142
|
+
defaultManagedReasoningEffort: capabilities.usesKnownNativeOpenAIRoute && !shouldStripDisabledReasoningPayload && model.provider !== "github-copilot" ? "none" : void 0,
|
|
143
|
+
explicitContinuationOptIn: capabilities.explicitContinuationOptIn,
|
|
186
144
|
explicitStore,
|
|
187
145
|
shouldStripDisabledReasoningPayload,
|
|
188
146
|
shouldStripInputStatus,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { r as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE } from "./types-LFWwv0cF.mjs";
|
|
2
|
+
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
3
|
+
//#region packages/ai/src/transports/openai-responses-contracts.ts
|
|
4
|
+
const DEFAULT_AZURE_OPENAI_API_VERSION = "preview";
|
|
5
|
+
const OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS = "Follow the user request.";
|
|
6
|
+
const AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS = 3e4;
|
|
7
|
+
const RESPONSE_FAILED_NO_DETAILS_MESSAGE = "Unknown error (no error details in response)";
|
|
8
|
+
const OPENAI_RESPONSES_REASONING_REPLAY_META_KEY = "__openclaw_replay";
|
|
9
|
+
const OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY = "openclawReasoningReplay";
|
|
10
|
+
const OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE = "openai-responses-compaction";
|
|
11
|
+
const OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE = "openai-responses-retained-compaction";
|
|
12
|
+
const OPENAI_RESPONSES_APIS = /* @__PURE__ */ new Set([
|
|
13
|
+
"openai-responses",
|
|
14
|
+
"azure-openai-responses",
|
|
15
|
+
"openai-chatgpt-responses",
|
|
16
|
+
"openclaw-openai-responses-transport",
|
|
17
|
+
"openclaw-openai-chatgpt-responses-transport",
|
|
18
|
+
"openclaw-azure-openai-responses-transport"
|
|
19
|
+
]);
|
|
20
|
+
var OpenAIResponsesWebSocketPreDispatchError = class extends Error {
|
|
21
|
+
constructor(cause) {
|
|
22
|
+
super("OpenAI Responses WebSocket failed before request dispatch", { cause });
|
|
23
|
+
this.name = "OpenAIResponsesWebSocketPreDispatchError";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var OpenAIResponsesWebSocketPostDispatchError = class extends Error {
|
|
27
|
+
constructor(cause) {
|
|
28
|
+
super("OpenAI Responses WebSocket failed after request dispatch; outcome is unknown", { cause });
|
|
29
|
+
this.code = PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE;
|
|
30
|
+
this.name = "OpenAIResponsesWebSocketPostDispatchError";
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var OpenAIResponsesWebSocketServerError = class extends Error {
|
|
34
|
+
constructor(code, status, param, message, cause) {
|
|
35
|
+
super(message, { cause });
|
|
36
|
+
this.code = code;
|
|
37
|
+
this.status = status;
|
|
38
|
+
this.param = param;
|
|
39
|
+
this.name = "OpenAIResponsesWebSocketServerError";
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var OpenAIResponsesWebSocketSafeRetryError = class extends OpenAIResponsesWebSocketServerError {};
|
|
43
|
+
function readWebSocketServerError(value) {
|
|
44
|
+
if (!isRecord(value) || value.type !== "error") return;
|
|
45
|
+
const details = isRecord(value.error) ? value.error : value;
|
|
46
|
+
if (typeof details.code !== "string" || typeof details.message !== "string") return;
|
|
47
|
+
const rawStatus = value.status ?? value.status_code;
|
|
48
|
+
return {
|
|
49
|
+
code: details.code,
|
|
50
|
+
message: details.message,
|
|
51
|
+
param: typeof details.param === "string" ? details.param : null,
|
|
52
|
+
status: typeof rawStatus === "number" ? rawStatus : void 0
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function isPreviousResponseRejection(error) {
|
|
56
|
+
return error.code === "previous_response_not_found" || error.code === "unsupported_parameter" && error.param === "previous_response_id";
|
|
57
|
+
}
|
|
58
|
+
function parseOpenAIResponsesWebSocketServerError(cause) {
|
|
59
|
+
if (!isRecord(cause)) return;
|
|
60
|
+
let details = readWebSocketServerError(cause.error) ?? readWebSocketServerError(cause);
|
|
61
|
+
if (!details && typeof cause.message === "string") try {
|
|
62
|
+
details = readWebSocketServerError(JSON.parse(cause.message));
|
|
63
|
+
} catch {}
|
|
64
|
+
if (!details) return;
|
|
65
|
+
return new (isPreviousResponseRejection(details) || 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);
|
|
66
|
+
}
|
|
67
|
+
const PROMPT_OBSERVER = Symbol("openaiResponsesPromptObserver");
|
|
68
|
+
const responsesPromptObserver = {
|
|
69
|
+
set(options, observer) {
|
|
70
|
+
Reflect.set(options, PROMPT_OBSERVER, observer);
|
|
71
|
+
},
|
|
72
|
+
get(options) {
|
|
73
|
+
return Reflect.get(options, PROMPT_OBSERVER);
|
|
74
|
+
},
|
|
75
|
+
copy(source, target) {
|
|
76
|
+
const observer = source && responsesPromptObserver.get(source);
|
|
77
|
+
if (observer) responsesPromptObserver.set(target, observer);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
export { OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE as a, OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE as c, OpenAIResponsesWebSocketSafeRetryError as d, RESPONSE_FAILED_NO_DETAILS_MESSAGE as f, responsesPromptObserver as h, OPENAI_RESPONSES_APIS as i, OpenAIResponsesWebSocketPostDispatchError as l, parseOpenAIResponsesWebSocketServerError as m, DEFAULT_AZURE_OPENAI_API_VERSION as n, OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY as o, isPreviousResponseRejection 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 };
|
package/dist/{openai-responses-contracts-BjBAqAg_.d.mts → openai-responses-contracts-Dflvrfa8.d.mts}
RENAMED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { O as Model, n as Api } from "./types-
|
|
3
|
-
import { a as BaseOpenAIStreamOptions, f as OpenAIReasoningEffort } from "./provider-options-
|
|
1
|
+
import "./index-DaF2QbwS.mjs";
|
|
2
|
+
import { O as Model, j as ModelThinkingLevel, n as Api } from "./types-4_uVs5WH.mjs";
|
|
3
|
+
import { a as BaseOpenAIStreamOptions, f as OpenAIReasoningEffort } from "./provider-options-DprLsWh9.mjs";
|
|
4
|
+
import "./types-DkJfb4W3.mjs";
|
|
4
5
|
import { ResponseCompactionItem, ResponseCreateParamsStreaming, ResponseInputItem } from "openai/resources/responses/responses.js";
|
|
6
|
+
//#region packages/ai/src/providers/openai-request-reasoning.d.ts
|
|
7
|
+
type OpenAIRequestReasoningEffort = ModelThinkingLevel | "none";
|
|
8
|
+
//#endregion
|
|
5
9
|
//#region packages/ai/src/transports/openai-responses-compaction-window.d.ts
|
|
6
10
|
type OpenAIResponsesCompactionOutput = Array<ResponseInputItem.Message | ReplayableResponseCompactionItem>;
|
|
7
11
|
/** Read the saved canonical window only when it still matches its opaque checkpoint. */
|
|
@@ -27,7 +31,7 @@ type OpenAIResponsesReasoningReplayMetadata = {
|
|
|
27
31
|
authProfileHash?: string;
|
|
28
32
|
};
|
|
29
33
|
type OpenAIResponsesOptions = BaseOpenAIStreamOptions & {
|
|
30
|
-
reasoning?:
|
|
34
|
+
reasoning?: OpenAIRequestReasoningEffort;
|
|
31
35
|
reasoningEffort?: OpenAIReasoningEffort;
|
|
32
36
|
reasoningSummary?: "auto" | "detailed" | "concise" | null;
|
|
33
37
|
replayResponsesItemIds?: boolean;
|
|
@@ -49,4 +53,4 @@ declare const responsesPromptObserver: {
|
|
|
49
53
|
copy(source: object | undefined, target: object): void;
|
|
50
54
|
};
|
|
51
55
|
//#endregion
|
|
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 };
|
|
56
|
+
export { ResponsesPromptObservation as a, readOpenAIResponsesCompactionWindow as c, ReplayableResponseCompactionItem as i, OpenAIRequestReasoningEffort as l, OpenAIResponsesOptions as n, responsesPromptObserver as o, OpenAIResponsesReasoningReplayMetadata as r, OpenAIResponsesCompactionOutput as s, OPENAI_RESPONSES_APIS as t };
|
|
@@ -10,13 +10,15 @@ type OpenAIResponsesPayloadModel = {
|
|
|
10
10
|
};
|
|
11
11
|
type OpenAIResponsesPayloadPolicyOptions = {
|
|
12
12
|
extraParams?: Record<string, unknown>;
|
|
13
|
-
storeMode?: "provider-policy" | "disable" | "preserve";
|
|
13
|
+
storeMode?: "provider-policy" | "transport-default" | "disable" | "preserve";
|
|
14
14
|
enablePromptCacheStripping?: boolean;
|
|
15
15
|
enableServerCompaction?: boolean;
|
|
16
16
|
};
|
|
17
17
|
type OpenAIResponsesPayloadPolicy = {
|
|
18
18
|
allowsServiceTier: boolean;
|
|
19
19
|
compactThreshold: number | undefined;
|
|
20
|
+
defaultManagedReasoningEffort: "none" | undefined;
|
|
21
|
+
explicitContinuationOptIn: boolean;
|
|
20
22
|
explicitStore: boolean | undefined;
|
|
21
23
|
shouldStripDisabledReasoningPayload: boolean;
|
|
22
24
|
shouldStripInputStatus: boolean;
|
|
@@ -30,8 +32,8 @@ declare function resolveOpenAIResponsesServerCompactionPlan(model: OpenAIRespons
|
|
|
30
32
|
enabled: boolean;
|
|
31
33
|
threshold: number | undefined;
|
|
32
34
|
};
|
|
33
|
-
/** Resolve the
|
|
34
|
-
declare function resolveOpenAIResponsesCompactEndpointPlan(model: OpenAIResponsesPayloadModel, extraParams?: Record<string, unknown
|
|
35
|
+
/** Resolve the Responses compact-endpoint gate for one route and compaction purpose. */
|
|
36
|
+
declare function resolveOpenAIResponsesCompactEndpointPlan(model: OpenAIResponsesPayloadModel, extraParams?: Record<string, unknown>, purpose?: "manual" | "budget"): {
|
|
35
37
|
enabled: boolean;
|
|
36
38
|
};
|
|
37
39
|
/** Resolve payload mutation policy for one OpenAI Responses-style model endpoint. */
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
2
|
+
import { u as supportsOpenAITemperature } from "./openai-reasoning-effort-NlFZmfEu.mjs";
|
|
3
|
+
import { r as resolveOpenAIPromptCacheParams } from "./openai-prompt-cache-1wfaIszn.mjs";
|
|
4
|
+
import { o as usesNativeOpenAICodexResponsesBackend } from "./openai-completions-compat-CkwdxTZx.mjs";
|
|
5
|
+
import { r as resolveOpenAIStrictToolSetting } from "./host-policy-DUnXSx0I.mjs";
|
|
6
|
+
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
7
|
+
import { m as stripSystemPromptCacheBoundary } from "./simple-options-C6cFWj_f.mjs";
|
|
8
|
+
import { A as resolvePromptCacheKey, g as resolveOpenAISimpleReasoningEffort, h as resolveOpenAIRequestReasoning, m as reconcileOpenAIResponsesToolChoice, s as getCompat } from "./openai-transport-params-DQeuAvBl.mjs";
|
|
9
|
+
import { _ as sanitizeTransportPayloadText } from "./transport-stream-shared-D-6FQSHm.mjs";
|
|
10
|
+
import { h as responsesPromptObserver, r as OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS } from "./openai-responses-contracts-DWrfMODE.mjs";
|
|
11
|
+
import { a as applyOpenAIResponsesPayloadPolicy, s as resolveOpenAIResponsesPayloadPolicy } from "./openai-responses-compaction-window-D6P5oZP5.mjs";
|
|
12
|
+
import { N as buildResponsesInputMessage, P as convertResponsesMessages, s as prepareResponsesTools } from "./openai-responses-shared-CwsziD_m.mjs";
|
|
13
|
+
//#region packages/ai/src/transports/openai-responses-params-internal.ts
|
|
14
|
+
const OPENAI_RESPONSES_TOOL_CALL_PROVIDERS = /* @__PURE__ */ new Set([
|
|
15
|
+
"openai",
|
|
16
|
+
"opencode",
|
|
17
|
+
"azure-openai-responses",
|
|
18
|
+
"github-copilot"
|
|
19
|
+
]);
|
|
20
|
+
function hasResponsesWebSearchTool(tools) {
|
|
21
|
+
if (!Array.isArray(tools)) return false;
|
|
22
|
+
return tools.some((tool) => {
|
|
23
|
+
if (!isRecord(tool)) return false;
|
|
24
|
+
if (tool.type === "web_search") return true;
|
|
25
|
+
if (tool.type === "function" && tool.name === "web_search") return true;
|
|
26
|
+
const fn = tool.function;
|
|
27
|
+
return isRecord(fn) && fn.name === "web_search";
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function raiseMinimalReasoningForResponsesWebSearch(params) {
|
|
31
|
+
if (params.effort !== "minimal" || !hasResponsesWebSearchTool(params.tools)) return params.effort;
|
|
32
|
+
for (const effort of [
|
|
33
|
+
"low",
|
|
34
|
+
"medium",
|
|
35
|
+
"high"
|
|
36
|
+
]) {
|
|
37
|
+
const resolved = resolveOpenAIRequestReasoning(params.model, effort).effort;
|
|
38
|
+
if (resolved && resolved !== "none" && resolved !== "minimal") return resolved;
|
|
39
|
+
}
|
|
40
|
+
return params.effort;
|
|
41
|
+
}
|
|
42
|
+
const OPENAI_CODEX_RESPONSES_UNSUPPORTED_PARAMS = [
|
|
43
|
+
"max_output_tokens",
|
|
44
|
+
"metadata",
|
|
45
|
+
"prompt_cache_retention",
|
|
46
|
+
"prompt_cache_options",
|
|
47
|
+
"service_tier",
|
|
48
|
+
"temperature",
|
|
49
|
+
"top_p"
|
|
50
|
+
];
|
|
51
|
+
function stripOpenAICodexResponsesUnsupportedTextFields(params) {
|
|
52
|
+
const text = params.text;
|
|
53
|
+
if (!text || typeof text !== "object" || Array.isArray(text)) return;
|
|
54
|
+
const sanitizedText = { ...text };
|
|
55
|
+
delete sanitizedText.format;
|
|
56
|
+
if (Object.keys(sanitizedText).length > 0) params.text = sanitizedText;
|
|
57
|
+
else delete params.text;
|
|
58
|
+
}
|
|
59
|
+
function sanitizeOpenAICodexResponsesParams(model, params) {
|
|
60
|
+
if (!usesNativeOpenAICodexResponsesBackend(model)) return params;
|
|
61
|
+
for (const key of OPENAI_CODEX_RESPONSES_UNSUPPORTED_PARAMS) delete params[key];
|
|
62
|
+
Object.assign(params, { store: false });
|
|
63
|
+
stripOpenAICodexResponsesUnsupportedTextFields(params);
|
|
64
|
+
return params;
|
|
65
|
+
}
|
|
66
|
+
function buildOpenAIResponsesInstructionsText(context) {
|
|
67
|
+
if (!context.systemPrompt) return;
|
|
68
|
+
return sanitizeTransportPayloadText(stripSystemPromptCacheBoundary(context.systemPrompt));
|
|
69
|
+
}
|
|
70
|
+
function resolveOpenAIResponsesInstructions(model, context, usesInstructionsField) {
|
|
71
|
+
if (!usesInstructionsField) return;
|
|
72
|
+
const instructions = buildOpenAIResponsesInstructionsText(context);
|
|
73
|
+
if (instructions && instructions.trim().length > 0) return instructions;
|
|
74
|
+
return usesNativeOpenAICodexResponsesBackend(model) ? OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS : void 0;
|
|
75
|
+
}
|
|
76
|
+
function buildOpenAIResponsesCompactSystemMessage(model, instructions) {
|
|
77
|
+
const compat = getCompat(model);
|
|
78
|
+
const supportsDeveloperRole = typeof compat.supportsDeveloperRole === "boolean" ? compat.supportsDeveloperRole : void 0;
|
|
79
|
+
const role = model.reasoning && supportsDeveloperRole !== false ? "developer" : "system";
|
|
80
|
+
return buildResponsesInputMessage(role, [{
|
|
81
|
+
type: "input_text",
|
|
82
|
+
text: instructions
|
|
83
|
+
}]);
|
|
84
|
+
}
|
|
85
|
+
function ensureOpenAIResponsesNonEmptyInput(messages, context) {
|
|
86
|
+
if (messages.length > 0 || !context.systemPrompt) return;
|
|
87
|
+
if (!buildOpenAIResponsesInstructionsText(context)) throw new Error("OpenAI Responses requires non-empty input when only systemPrompt is provided.");
|
|
88
|
+
messages.push(buildResponsesInputMessage("user", [{
|
|
89
|
+
type: "input_text",
|
|
90
|
+
text: " "
|
|
91
|
+
}]));
|
|
92
|
+
}
|
|
93
|
+
function resolveOpenAIResponsesTextFormat(responseFormat) {
|
|
94
|
+
if (responseFormat.type === "json_schema" && responseFormat.json_schema && typeof responseFormat.json_schema === "object" && !Array.isArray(responseFormat.json_schema)) return {
|
|
95
|
+
...responseFormat.json_schema,
|
|
96
|
+
type: "json_schema"
|
|
97
|
+
};
|
|
98
|
+
return responseFormat;
|
|
99
|
+
}
|
|
100
|
+
function buildOpenAIResponsesParams(model, context, options, metadata, replayMode = "checkpoint") {
|
|
101
|
+
const payloadPolicy = resolveOpenAIResponsesPayloadPolicy(model, { storeMode: "transport-default" });
|
|
102
|
+
const policyAllowsReplayIds = payloadPolicy.explicitStore !== false && !payloadPolicy.shouldStripStore;
|
|
103
|
+
const replayResponsesItemIds = !usesNativeOpenAICodexResponsesBackend(model) && (options?.replayResponsesItemIds ?? policyAllowsReplayIds);
|
|
104
|
+
const messages = convertResponsesMessages(model, context, OPENAI_RESPONSES_TOOL_CALL_PROVIDERS, {
|
|
105
|
+
includeSystemPrompt: !payloadPolicy.usesInstructionsField,
|
|
106
|
+
replayReasoningItems: true,
|
|
107
|
+
replayResponsesItemIds,
|
|
108
|
+
authProfileId: options?.authProfileId,
|
|
109
|
+
sessionId: options?.sessionId,
|
|
110
|
+
replayMode
|
|
111
|
+
});
|
|
112
|
+
ensureOpenAIResponsesNonEmptyInput(messages, context);
|
|
113
|
+
const cacheRetention = resolveCacheRetention(options?.cacheRetention);
|
|
114
|
+
const compat = getCompat(model);
|
|
115
|
+
const promptCacheKey = compat.supportsPromptCacheKey ? resolvePromptCacheKey(options, cacheRetention) : void 0;
|
|
116
|
+
const instructions = resolveOpenAIResponsesInstructions(model, context, payloadPolicy.usesInstructionsField);
|
|
117
|
+
const params = {
|
|
118
|
+
model: model.id,
|
|
119
|
+
input: messages,
|
|
120
|
+
stream: true,
|
|
121
|
+
prompt_cache_key: promptCacheKey,
|
|
122
|
+
...resolveOpenAIPromptCacheParams(model, cacheRetention, compat),
|
|
123
|
+
...instructions ? { instructions } : {},
|
|
124
|
+
...metadata ? { metadata } : {}
|
|
125
|
+
};
|
|
126
|
+
const effectiveMaxTokens = options?.maxTokens || model.maxTokens;
|
|
127
|
+
if (effectiveMaxTokens) params.max_output_tokens = Math.max(effectiveMaxTokens, 16);
|
|
128
|
+
if (options?.temperature !== void 0 && supportsOpenAITemperature(model)) params.temperature = options.temperature;
|
|
129
|
+
if (options?.topP !== void 0 && model.id !== "gpt-6-astra") params.top_p = options.topP;
|
|
130
|
+
if (options?.responseFormat !== void 0) params.text = {
|
|
131
|
+
...params.text,
|
|
132
|
+
format: resolveOpenAIResponsesTextFormat(options.responseFormat)
|
|
133
|
+
};
|
|
134
|
+
if (options?.serviceTier !== void 0 && payloadPolicy.allowsServiceTier) params.service_tier = options.serviceTier;
|
|
135
|
+
if (context.tools) {
|
|
136
|
+
const tools = context.tools;
|
|
137
|
+
const strict = resolveOpenAIStrictToolSetting(model, { transport: "stream" });
|
|
138
|
+
const { projection, tools: converted } = prepareResponsesTools(tools, strict, model);
|
|
139
|
+
if (converted.length > 0 || projection.inputToolCount === 0 && projection.diagnostics.length === 0) params.tools = converted;
|
|
140
|
+
if (options?.toolChoice) {
|
|
141
|
+
const toolChoice = reconcileOpenAIResponsesToolChoice(options.toolChoice, projection);
|
|
142
|
+
if (toolChoice !== void 0) params.tool_choice = toolChoice;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (model.reasoning) {
|
|
146
|
+
const reasoning = options?.reasoning;
|
|
147
|
+
const requestedEffort = options?.reasoningEffort ?? (reasoning === "none" ? "none" : resolveOpenAISimpleReasoningEffort(model, reasoning)) ?? (options?.reasoningSummary ? "high" : payloadPolicy.defaultManagedReasoningEffort);
|
|
148
|
+
const resolvedEffort = requestedEffort === void 0 ? void 0 : resolveOpenAIRequestReasoning(model, requestedEffort).effort;
|
|
149
|
+
if (resolvedEffort !== void 0) {
|
|
150
|
+
const effort = raiseMinimalReasoningForResponsesWebSearch({
|
|
151
|
+
model,
|
|
152
|
+
effort: resolvedEffort,
|
|
153
|
+
tools: params.tools
|
|
154
|
+
});
|
|
155
|
+
const summary = effort !== "none" && (options?.reasoningEffort || options?.reasoning || options?.reasoningSummary) ? options.reasoningSummary || "auto" : void 0;
|
|
156
|
+
params.reasoning = {
|
|
157
|
+
effort,
|
|
158
|
+
...summary ? { summary } : {}
|
|
159
|
+
};
|
|
160
|
+
if (summary) params.include = ["reasoning.encrypted_content"];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
applyOpenAIResponsesPayloadPolicy(params, payloadPolicy);
|
|
164
|
+
return sanitizeOpenAICodexResponsesParams(model, params);
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region packages/ai/src/transports/openai-responses-prompt-observer-internal.ts
|
|
168
|
+
function readFinalResponsesPrompt(request) {
|
|
169
|
+
if (typeof request.instructions === "string") return ["instructions", request.instructions];
|
|
170
|
+
const message = (Array.isArray(request.input) ? request.input : []).find((item) => {
|
|
171
|
+
const role = item.role;
|
|
172
|
+
return role === "developer" || role === "system";
|
|
173
|
+
});
|
|
174
|
+
if (!message) return ["missing", ""];
|
|
175
|
+
const content = message.content;
|
|
176
|
+
const observedPrompt = typeof content === "string" ? content : Array.isArray(content) ? content.flatMap((part) => part.type === "input_text" ? [part.text] : []).join("") : "";
|
|
177
|
+
return [message.role === "developer" ? "input.developer" : "input.system", observedPrompt];
|
|
178
|
+
}
|
|
179
|
+
function createResponsesPromptEgressObserver(options, assembledPrompt) {
|
|
180
|
+
const observer = options ? responsesPromptObserver.get(options) : void 0;
|
|
181
|
+
if (!observer) return;
|
|
182
|
+
const expectedPrompt = sanitizeTransportPayloadText(stripSystemPromptCacheBoundary(assembledPrompt ?? ""));
|
|
183
|
+
return (request, metadata) => {
|
|
184
|
+
const [promptSource, observedPrompt] = readFinalResponsesPrompt(request);
|
|
185
|
+
observer({
|
|
186
|
+
...metadata,
|
|
187
|
+
promptSource,
|
|
188
|
+
expectedChars: expectedPrompt.length,
|
|
189
|
+
observedChars: observedPrompt.length,
|
|
190
|
+
matchesAssembledPrompt: promptSource !== "missing" && observedPrompt === expectedPrompt
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
export { sanitizeOpenAICodexResponsesParams as a, resolveOpenAIResponsesTextFormat as i, buildOpenAIResponsesCompactSystemMessage as n, buildOpenAIResponsesParams as r, createResponsesPromptEgressObserver as t };
|