@openclaw/ai 2026.9.4 → 2026.9.6
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-DZQ_7gD1.mjs} +37 -38
- package/dist/{anthropic-payload-policy-BZ8umAbk.d.mts → anthropic-payload-policy-DyfwikYJ.d.mts} +4 -4
- package/dist/{anthropic-stream-reducer-CILWF7JD.mjs → anthropic-stream-reducer-D6ZI1wwj.mjs} +70 -50
- package/dist/{api-registry-ByUwIR0e.d.mts → api-registry-C2T3lTV7.d.mts} +2 -2
- package/dist/{assistant-output-tLt4H-iQ.mjs → assistant-output-DM1JBNs1.mjs} +1 -1
- package/dist/{azure-openai-responses-BAlqlKKc.mjs → azure-openai-responses-DS86GYzq.mjs} +6 -9
- package/dist/{base64-D-su8YVo.mjs → base64-CPmadnUf.mjs} +12 -12
- package/dist/credential-redaction-BKv49aiv.d.mts +24 -0
- package/dist/{diagnostics-QuErwCIl.mjs → diagnostics-CH8j2wIG.mjs} +139 -7
- package/dist/{diagnostics-CPeq9F7y.mjs → diagnostics-DzrF1h4J.mjs} +18 -1
- package/dist/diagnostics.d.mts +11 -24
- package/dist/diagnostics.mjs +4 -4
- package/dist/event-stream-C0nsgbj2.d.mts +1 -0
- package/dist/{event-stream-Bt5Y4Pav.d.mts → event-stream-CjnIZZst.d.mts} +1 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/expect-lbe3Hgrh.mjs +8 -0
- package/dist/{google-DPBAOaOW.mjs → google-BZJFjhuC.mjs} +6 -9
- package/dist/{google-messages-6JkpHrhJ.mjs → google-messages-DB7GKkDk.mjs} +3 -3
- package/dist/{google-shared-BvBeW9aq.mjs → google-shared-Bok4I6zB.mjs} +13 -13
- package/dist/{google-vertex-k-TMCAYD.mjs → google-vertex-3eVNR2qW.mjs} +5 -8
- package/dist/{host-4atIX-2V.d.mts → host-DH-Z-LDb.d.mts} +5 -3
- package/dist/{host-policy-Zcg_cNz8.mjs → host-policy-DZO3oPPk.mjs} +1 -1
- package/dist/{host-B8YfDGd4.mjs → host-yTvBrYM2.mjs} +63 -31
- package/dist/{index-DdD3qerf.d.mts → index-C25RT6bP.d.mts} +37 -14
- package/dist/index.d.mts +7 -8
- package/dist/index.mjs +5 -6
- package/dist/internal/anthropic.d.mts +13 -10
- package/dist/internal/anthropic.mjs +5 -5
- 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 +24 -53
- package/dist/internal/openai.mjs +12 -9
- package/dist/internal/runtime.d.mts +6 -8
- package/dist/internal/runtime.mjs +6 -10
- package/dist/internal/shared.d.mts +7 -5
- package/dist/internal/shared.mjs +4 -3
- package/dist/internal/tool-schema.d.mts +4 -4
- package/dist/internal/tool-schema.mjs +2 -2
- package/dist/{mistral-CxUZ1jUb.mjs → mistral-C_13dVBn.mjs} +9 -13
- package/dist/{model-transport-url-DKocrEsb.d.mts → model-transport-url-C5f59L3Y.d.mts} +1 -1
- package/dist/{openai-chatgpt-responses-CgO6kZfo.mjs → openai-chatgpt-responses-sTxPl4zM.mjs} +150 -83
- package/dist/{openai-completions-yJuk7eis.mjs → openai-completions-BO6D_hrB.mjs} +11 -12
- package/dist/{openai-prompt-cache-Bds-n_9Q.mjs → openai-completions-compat-CUollwl6.mjs} +5 -50
- package/dist/{openai-completions-compat-eHgh5UPE.d.mts → openai-completions-compat-DfJG1wSO.d.mts} +4 -4
- package/dist/{openai-completions-stream-Da2vvl-S.mjs → openai-completions-stream-BpuJ0ZOA.mjs} +117 -106
- package/dist/{openai-prompt-cache-B4eYo2-I.d.mts → openai-prompt-cache-C4RHdN4n.d.mts} +2 -2
- package/dist/openai-prompt-cache-CjV_2IRI.mjs +46 -0
- package/dist/{openai-provider-client-S2gCrM2Z.mjs → openai-provider-client-BP8J1aeg.mjs} +2 -2
- package/dist/openai-reasoning-effort-ash8dPrd.mjs +243 -0
- package/dist/{openai-responses-DaYwH05E.mjs → openai-responses-BJ_IEoMU.mjs} +8 -12
- package/dist/{openai-responses-compaction-window-CIhBAkkq.mjs → openai-responses-compaction-window-BiNCT0bS.mjs} +20 -62
- package/dist/{openai-responses-contracts-BjBAqAg_.d.mts → openai-responses-contracts-B1ENJFpI.d.mts} +9 -5
- package/dist/openai-responses-contracts-DWrfMODE.mjs +81 -0
- 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-DPHWgbBH.mjs +198 -0
- package/dist/openai-responses-request-lifecycle-DFuyO1pQ.mjs +36 -0
- package/dist/{openai-responses-shared-B8RdBPCv.mjs → openai-responses-shared-DvSqtJ6_.mjs} +859 -581
- package/dist/openai-responses-terminal-usage-BNFbvY9f.d.mts +47 -0
- package/dist/{openai-tool-schema-CzjyYXun.mjs → openai-tool-schema-D4BMcj2D.mjs} +262 -162
- package/dist/{openai-transport-params-9aPuV5YY.mjs → openai-transport-params-DZKOTSfH.mjs} +157 -47
- package/dist/{positive-integer-41zhOdcV.mjs → positive-integer-BiUxrd71.mjs} +1 -1
- package/dist/{provider-error-BA-v_tKd.mjs → provider-error-CRhW7lkJ.mjs} +139 -44
- package/dist/{provider-error-CzNw4BWX.d.mts → provider-error-xumb1V3F.d.mts} +3 -1
- package/dist/{provider-options-Ceqv1OKk.d.mts → provider-options-DZYq53lj.d.mts} +12 -7
- package/dist/{provider-replay-context-CJ_YvcEW.mjs → provider-replay-context-DPr3w20a.mjs} +1 -1
- package/dist/{provider-transcript-transform-V5YzU9zh.mjs → provider-transcript-transform-BTocjCRs.mjs} +1 -1
- package/dist/{provider-transport-turn-state-D5EXOFL2.mjs → provider-transport-turn-state-lrXEFkYr.mjs} +1 -1
- package/dist/{provider-types-CVjKjsuq.d.mts → provider-types-w1rEqrGP.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -7
- 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-Di38crhI.mjs} +167 -40
- package/dist/{simple-options-BQbb4yQL.mjs → simple-options-np1XPuhm.mjs} +5 -3
- package/dist/{usage-cost-BNWbbXav.mjs → src-DwGYYyZp.mjs} +18 -11
- package/dist/{stream-first-event-timeout-2hfrquuz.mjs → stream-first-event-timeout-BeptfRL6.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-zHll9BxO.mjs → transport-stream-shared-B5RioB_Q.mjs} +16 -24
- package/dist/{transport-stream-shared-DNvmoWnv.d.mts → transport-stream-shared-B7Z9oCYg.d.mts} +5 -5
- package/dist/{transport-utils-zrYjICLZ.mjs → transport-utils-03Qi0CN2.mjs} +3 -3
- package/dist/transports.d.mts +27 -13
- package/dist/transports.mjs +168 -462
- package/dist/types-DTvddOfm.d.mts +1 -0
- package/dist/{types-Ntv5z2g2.d.mts → types-qZFbaDbK.d.mts} +49 -3
- package/dist/types.d.mts +6 -7
- package/dist/types.mjs +4 -5
- package/dist/{validation-B0t_G2H6.d.mts → validation-DhQhmt6t.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 +11 -6
- 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
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
2
|
+
import { d as supportsOpenAITemperature, i as isOpenAIGpt6Model, m as resolveOpenAIThinkingApi } from "./openai-reasoning-effort-ash8dPrd.mjs";
|
|
3
|
+
import { r as resolveOpenAIPromptCacheParams } from "./openai-prompt-cache-CjV_2IRI.mjs";
|
|
4
|
+
import { o as usesNativeOpenAICodexResponsesBackend } from "./openai-completions-compat-CUollwl6.mjs";
|
|
5
|
+
import { r as resolveOpenAIStrictToolSetting } from "./host-policy-DZO3oPPk.mjs";
|
|
6
|
+
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
7
|
+
import { m as stripSystemPromptCacheBoundary } from "./simple-options-np1XPuhm.mjs";
|
|
8
|
+
import { A as resolvePromptCacheKey, g as resolveOpenAISimpleReasoningEffort, h as resolveOpenAIRequestReasoning, m as reconcileOpenAIResponsesToolChoice, s as getCompat } from "./openai-transport-params-DZKOTSfH.mjs";
|
|
9
|
+
import { _ as sanitizeTransportPayloadText } from "./transport-stream-shared-B5RioB_Q.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-BiNCT0bS.mjs";
|
|
12
|
+
import { F as convertResponsesMessages, P as buildResponsesInputMessage, s as prepareResponsesTools } from "./openai-responses-shared-DvSqtJ6_.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 && (!isOpenAIGpt6Model(model) || resolveOpenAIThinkingApi(model.api) === "azure-openai-responses")) 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, {
|
|
138
|
+
transport: "stream",
|
|
139
|
+
supportsStrictMode: compat.supportsStrictMode
|
|
140
|
+
});
|
|
141
|
+
const { projection, tools: converted } = prepareResponsesTools(tools, strict, model);
|
|
142
|
+
if (converted.length > 0 || projection.inputToolCount === 0 && projection.diagnostics.length === 0) params.tools = converted;
|
|
143
|
+
if (options?.toolChoice) {
|
|
144
|
+
const toolChoice = reconcileOpenAIResponsesToolChoice(options.toolChoice, projection);
|
|
145
|
+
if (toolChoice !== void 0) params.tool_choice = toolChoice;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (model.reasoning) {
|
|
149
|
+
const reasoning = options?.reasoning;
|
|
150
|
+
const requestedEffort = options?.reasoningEffort ?? (reasoning === "none" ? "none" : resolveOpenAISimpleReasoningEffort(model, reasoning)) ?? (options?.reasoningSummary ? "high" : payloadPolicy.defaultManagedReasoningEffort);
|
|
151
|
+
const resolvedEffort = requestedEffort === void 0 ? void 0 : resolveOpenAIRequestReasoning(model, requestedEffort).effort;
|
|
152
|
+
if (resolvedEffort !== void 0) {
|
|
153
|
+
const effort = raiseMinimalReasoningForResponsesWebSearch({
|
|
154
|
+
model,
|
|
155
|
+
effort: resolvedEffort,
|
|
156
|
+
tools: params.tools
|
|
157
|
+
});
|
|
158
|
+
const summary = effort !== "none" && (options?.reasoningEffort || options?.reasoning || options?.reasoningSummary) ? options.reasoningSummary || "auto" : void 0;
|
|
159
|
+
params.reasoning = {
|
|
160
|
+
effort,
|
|
161
|
+
...summary ? { summary } : {}
|
|
162
|
+
};
|
|
163
|
+
if (summary) params.include = ["reasoning.encrypted_content"];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
applyOpenAIResponsesPayloadPolicy(params, payloadPolicy);
|
|
167
|
+
return sanitizeOpenAICodexResponsesParams(model, params);
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region packages/ai/src/transports/openai-responses-prompt-observer-internal.ts
|
|
171
|
+
function readFinalResponsesPrompt(request) {
|
|
172
|
+
if (typeof request.instructions === "string") return ["instructions", request.instructions];
|
|
173
|
+
const message = (Array.isArray(request.input) ? request.input : []).find((item) => {
|
|
174
|
+
const role = item.role;
|
|
175
|
+
return role === "developer" || role === "system";
|
|
176
|
+
});
|
|
177
|
+
if (!message) return ["missing", ""];
|
|
178
|
+
const content = message.content;
|
|
179
|
+
const observedPrompt = typeof content === "string" ? content : Array.isArray(content) ? content.flatMap((part) => part.type === "input_text" ? [part.text] : []).join("") : "";
|
|
180
|
+
return [message.role === "developer" ? "input.developer" : "input.system", observedPrompt];
|
|
181
|
+
}
|
|
182
|
+
function createResponsesPromptEgressObserver(options, assembledPrompt) {
|
|
183
|
+
const observer = options ? responsesPromptObserver.get(options) : void 0;
|
|
184
|
+
if (!observer) return;
|
|
185
|
+
const expectedPrompt = sanitizeTransportPayloadText(stripSystemPromptCacheBoundary(assembledPrompt ?? ""));
|
|
186
|
+
return (request, metadata) => {
|
|
187
|
+
const [promptSource, observedPrompt] = readFinalResponsesPrompt(request);
|
|
188
|
+
observer({
|
|
189
|
+
...metadata,
|
|
190
|
+
promptSource,
|
|
191
|
+
expectedChars: expectedPrompt.length,
|
|
192
|
+
observedChars: observedPrompt.length,
|
|
193
|
+
matchesAssembledPrompt: promptSource !== "missing" && observedPrompt === expectedPrompt
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
198
|
+
export { sanitizeOpenAICodexResponsesParams as a, resolveOpenAIResponsesTextFormat as i, buildOpenAIResponsesCompactSystemMessage as n, buildOpenAIResponsesParams as r, createResponsesPromptEgressObserver as t };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
2
|
+
//#region packages/ai/src/transports/openai-responses-request-lifecycle.ts
|
|
3
|
+
const lifecycleKey = Symbol("openclaw.responsesRequestLifecycle");
|
|
4
|
+
/** Private transport carrier: serialized options cannot mint host authority. */
|
|
5
|
+
const responsesRequestLifecycle = {
|
|
6
|
+
set(options, lifecycle) {
|
|
7
|
+
Object.defineProperty(options, lifecycleKey, {
|
|
8
|
+
value: lifecycle,
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
get(options) {
|
|
13
|
+
if (!options) return;
|
|
14
|
+
return Reflect.get(options, lifecycleKey);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/** A transport receipt must settle before model output can authorize later work. */
|
|
18
|
+
function withResponsesRequestAcceptance(events, lifecycle, signal) {
|
|
19
|
+
if (!lifecycle) return events;
|
|
20
|
+
return { async *[Symbol.asyncIterator]() {
|
|
21
|
+
for await (const event of events) {
|
|
22
|
+
if (isRecord(event) && event.type === "response.created") {
|
|
23
|
+
const response = isRecord(event.response) ? event.response : void 0;
|
|
24
|
+
if (typeof response?.id !== "string" || !response.id.trim()) throw new Error("Provider continuation response has no identity");
|
|
25
|
+
signal?.throwIfAborted();
|
|
26
|
+
lifecycle.assertCurrent();
|
|
27
|
+
await lifecycle.accepted(response.id, signal);
|
|
28
|
+
signal?.throwIfAborted();
|
|
29
|
+
lifecycle.assertCurrent();
|
|
30
|
+
}
|
|
31
|
+
yield event;
|
|
32
|
+
}
|
|
33
|
+
} };
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { withResponsesRequestAcceptance as n, responsesRequestLifecycle as t };
|