@openclaw/ai 2026.10.5-beta.3 → 2026.10.10-beta.1
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 +11 -0
- package/dist/{anthropic-BalhAzs-.mjs → anthropic-D6spfBri.mjs} +16 -18
- package/dist/{anthropic-payload-policy-DGblkHL5.d.mts → anthropic-payload-policy-Cr8xjazC.d.mts} +6 -3
- package/dist/{anthropic-stream-reducer-DkKeXXx4.mjs → anthropic-stream-reducer-CzPXOaLM.mjs} +59 -226
- package/dist/anthropic-tool-projection-BdAS3rtJ.mjs +165 -0
- package/dist/anthropic-tool-projection-DKH-aEWU.d.mts +51 -0
- package/dist/{api-registry-BhXXYdRA.d.mts → api-registry-gDt0faai.d.mts} +2 -2
- package/dist/{assistant-output-BuhRpLeD.mjs → assistant-output-6iFA1nbC.mjs} +2 -2
- package/dist/{azure-openai-responses-DfT9Ndd8.mjs → azure-openai-responses-0TqHwnlD.mjs} +8 -8
- package/dist/{cloudflare-5qSGvIUH.mjs → cloudflare-Dttf8jKq.mjs} +1 -1
- package/dist/{credential-redaction-BHxruEH6.d.mts → credential-redaction-XvsPf7Yi.d.mts} +1 -0
- package/dist/{diagnostics-tQasYct1.mjs → diagnostics-Cv7cW3pS.mjs} +3 -3
- package/dist/diagnostics.d.mts +6 -6
- package/dist/diagnostics.mjs +2 -2
- package/dist/{env-api-keys-CrxwdylR.mjs → env-api-keys-Xd8dm_aV.mjs} +10 -34
- package/dist/event-stream-CDpFza-M.d.mts +1 -0
- package/dist/{event-stream-BcqWLo_u.d.mts → event-stream-CzpE1g_o.d.mts} +1 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/{github-copilot-request-facts-DEE6gcB9.mjs → github-copilot-request-facts-F-EmvkpW.mjs} +1 -1
- package/dist/{google-interactions-9SSqsJg9.mjs → google-interactions-CTEBy9od.mjs} +19 -37
- package/dist/{google-messages-DsB7fmoQ.mjs → google-messages-DfpHVTaD.mjs} +18 -6
- package/dist/{google-provider-stream-CcEI2-MC.mjs → google-provider-stream-DJ8ANfsS.mjs} +6 -6
- package/dist/{google-shared-zGR0QUyS.mjs → google-shared-VTcCJLW3.mjs} +28 -41
- package/dist/{google-vertex-Dw_abY1w.mjs → google-vertex-Bkfizj7M.mjs} +3 -3
- package/dist/{google-sYI2wnY6.mjs → google-zWpkDSeN.mjs} +4 -4
- package/dist/{host-Bf3NjYNj.mjs → host-B2gk-d1H.mjs} +5 -11
- package/dist/{host-CTDz7LXD.d.mts → host-jJOffdlW.d.mts} +4 -6
- package/dist/{host-policy-BzZluO6_.mjs → host-policy-mpqGhbeM.mjs} +1 -1
- package/dist/{index-BYDvopUB.d.mts → index-DSprYWaz.d.mts} +7 -5
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +6 -6
- package/dist/internal/anthropic.d.mts +7 -53
- package/dist/internal/anthropic.mjs +6 -5
- package/dist/internal/google-model-family.d.mts +2 -0
- package/dist/internal/google-model-family.mjs +7 -3
- package/dist/internal/openai-completions-compat.d.mts +1 -1
- package/dist/internal/openai-completions-compat.mjs +1 -1
- package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
- package/dist/internal/openai-responses-payload-policy.mjs +3 -3
- package/dist/internal/openai.d.mts +17 -26
- package/dist/internal/openai.mjs +10 -10
- package/dist/internal/retry-after.d.mts +1 -1
- package/dist/internal/retry-after.mjs +80 -55
- package/dist/internal/runtime.d.mts +9 -31
- package/dist/internal/runtime.mjs +10 -116
- package/dist/internal/shared.d.mts +9 -7
- package/dist/internal/shared.mjs +8 -6
- package/dist/internal/tool-schema.d.mts +83 -5
- package/dist/internal/tool-schema.mjs +4 -3
- package/dist/{mistral-dCDCR5ur.mjs → mistral-CATJrwne.mjs} +32 -35
- package/dist/model-request-body-BD5vy4rP.d.mts +17 -0
- package/dist/{number-coercion-C3hztWoY.mjs → number-coercion-37gmNkuA.mjs} +1 -1
- package/dist/{openai-chatgpt-responses-BHI3uCcA.mjs → openai-chatgpt-responses-CtdnpWwe.mjs} +95 -63
- package/dist/{openai-completions-CrVgnFrV.mjs → openai-completions-B6sET3oI.mjs} +10 -8
- package/dist/{openai-completions-compat-i-nLZxFy.d.mts → openai-completions-compat-1gsjP-KO.d.mts} +6 -3
- package/dist/{openai-completions-compat-CYX18uDk.mjs → openai-completions-compat-CFhQ3UVU.mjs} +7 -2
- package/dist/{openai-completions-transport-Dy4CZo9Q.mjs → openai-completions-transport-DviPEqw3.mjs} +370 -237
- package/dist/{openai-prompt-cache-r93BJhjm.mjs → openai-prompt-cache-DJ_P143P.mjs} +1 -1
- package/dist/{openai-prompt-cache-DIPMrMFy.d.mts → openai-prompt-cache-DgjD-UL5.d.mts} +2 -2
- package/dist/{openai-responses-D5oiAUOG.mjs → openai-responses-BXsJK-mD.mjs} +13 -15
- package/dist/{openai-responses-compaction-replay-B2FE4Nw8.d.mts → openai-responses-compaction-replay-Cvnl_nCq.d.mts} +5 -5
- package/dist/{openai-responses-contracts-DlKMMTxK.mjs → openai-responses-contracts-Bx-16mnf.mjs} +45 -6
- package/dist/{openai-responses-contracts-DKqMJ1Ct.d.mts → openai-responses-contracts-CQ4_AWjL.d.mts} +20 -8
- package/dist/{openai-responses-endpoint-CinGh4VZ.mjs → openai-responses-endpoint-D4v-eeYy.mjs} +55 -22
- package/dist/{openai-responses-payload-policy-C7GsA1y0.d.mts → openai-responses-payload-policy-BzM52TTH.d.mts} +9 -3
- package/dist/openai-responses-request-lifecycle-CTdAb2v1.mjs +246 -0
- package/dist/{openai-responses-shared-D-aDYAkJ.mjs → openai-responses-shared-Bv_1NtH9.mjs} +284 -160
- package/dist/{openai-responses-terminal-usage-BygjiAdi.d.mts → openai-responses-terminal-usage-CpVjkqn-.d.mts} +2 -2
- package/dist/{openai-tool-schema-DDPXsvJP.mjs → openai-tool-schema-Buv0GXFb.mjs} +170 -237
- package/dist/overflow-DJHXTNBQ.mjs +117 -0
- package/dist/{positive-integer-CqWjqSi9.mjs → positive-integer-Bb4Evc7L.mjs} +1 -1
- package/dist/prompt-cache-stability-D_MeCQFI.mjs +32 -0
- package/dist/{provider-error-xumb1V3F.d.mts → provider-error-CnaWYTRY.d.mts} +1 -0
- package/dist/{provider-error-CF9GWCs2.mjs → provider-error-qtZD2inE.mjs} +75 -13
- package/dist/{provider-options-CVrXZBtA.d.mts → provider-options-DeYeaflL.d.mts} +52 -6
- package/dist/{text-signature-Drb4Erb8.mjs → provider-replay-context-J6CfU3m1.mjs} +5 -14
- package/dist/{provider-transport-turn-state-BOpxgm-J.mjs → provider-transport-turn-state-Jxppzuc2.mjs} +5 -5
- package/dist/{provider-types-CHtRx0dI.d.mts → provider-types-ODq57rG_.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +11 -11
- package/dist/{reasoning-tag-text-partitioner-CpOy9-IQ.mjs → reasoning-tag-text-partitioner-DzlRubwU.mjs} +134 -47
- package/dist/{required-api-key-CFJvcFy_.mjs → required-api-key-D088S4Cd.mjs} +1 -1
- package/dist/{retry-after-CdCURCVg.d.mts → retry-after-sw-XX8aC.d.mts} +1 -1
- package/dist/sanitize-unicode-CRGuMONI.mjs +8 -0
- package/dist/sanitize-unicode-ZqVLLEKC.d.mts +27 -0
- package/dist/{session-resources-D1wgDQ8C.mjs → session-resources-vKvGIE3J.mjs} +1 -10
- package/dist/{simple-options-BAu4B54D.mjs → simple-options-BYgC6kse.mjs} +68 -79
- package/dist/{src-C44MKrW5.mjs → src-CyA0zJnt.mjs} +6 -2
- package/dist/{stream-Dd8DwRFL.mjs → stream-DLBirT0e.mjs} +8 -47
- package/dist/{stream-first-event-timeout-Dc42hKv6.mjs → stream-first-event-timeout-D_TfJHRJ.mjs} +1 -1
- package/dist/{string-coerce-CtgOVOSv.mjs → string-coerce-Cj8sqWHx.mjs} +26 -1
- package/dist/tool-schema-json-projection-B0hHDV7N.mjs +492 -0
- package/dist/{transport-stream-shared-BmpzDtdQ.d.mts → transport-stream-shared-8ru8eX4s.d.mts} +5 -5
- package/dist/{transport-stream-shared-CWGOuLcA.mjs → transport-stream-shared-CzQlAzJH.mjs} +27 -75
- package/dist/transports.d.mts +34 -28
- package/dist/transports.mjs +42 -48
- package/dist/{types-CQc6JNG4.mjs → types-BXd0kI8-.mjs} +1 -1
- package/dist/types-CBJthzJX.d.mts +1 -0
- package/dist/{types-Bd2T86VJ.d.mts → types-CVYzKrMl.d.mts} +20 -3
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +4 -4
- package/dist/{validation-ZX_sPVV0.mjs → validation-9FSkE8T-.mjs} +22 -3
- package/dist/{validation-DdGB1yy3.d.mts → validation-BQ5u20Ru.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +3 -3
- package/dist/assistant-text-phase-Bn1hbvK9.mjs +0 -50
- package/dist/event-stream-6UNs-AhN.d.mts +0 -1
- package/dist/expect-lbe3Hgrh.mjs +0 -8
- package/dist/json-schema-Bp07Qui3.mjs +0 -22
- package/dist/openai-responses-request-lifecycle-NSIJo9jY.mjs +0 -67
- package/dist/openai-tool-projection-793cE3QX.d.mts +0 -37
- package/dist/openai-tool-schema-a5ysBBga.d.mts +0 -32
- package/dist/rolldown-runtime-BhDjJH2R.mjs +0 -15
- package/dist/sanitize-unicode-CjDG6jJx.d.mts +0 -5
- package/dist/string-normalization-I3ux50s9.mjs +0 -28
- package/dist/tool-schema-json-projection-B8sG1I9v.mjs +0 -180
- package/dist/types-Kdfw_04V.d.mts +0 -1
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
|
|
2
|
+
import { f as RESPONSES_RETAINED_USER, g as responsesPromptObserver } from "./openai-responses-contracts-Bx-16mnf.mjs";
|
|
3
|
+
import { c as stableStringify, d as estimateTokensFromChars, u as estimateStringChars } from "./provider-error-qtZD2inE.mjs";
|
|
4
|
+
import "./provider-replay-context-J6CfU3m1.mjs";
|
|
5
|
+
import { w as stripSystemPromptCacheBoundary } from "./simple-options-BYgC6kse.mjs";
|
|
6
|
+
import { v as sanitizeTransportPayloadText } from "./transport-stream-shared-CzQlAzJH.mjs";
|
|
7
|
+
import { w as sha256Hex } from "./tool-schema-json-projection-B0hHDV7N.mjs";
|
|
8
|
+
import { rt as buildOpenAIResponsesReasoningReplayMetadata } from "./openai-responses-shared-Bv_1NtH9.mjs";
|
|
9
|
+
import { a as isOpenAIResponsesCompactionOutput, s as sanitizeResponsesImagePayload } from "./openai-responses-endpoint-D4v-eeYy.mjs";
|
|
10
|
+
//#region packages/ai/src/transports/openai-responses-compact-request.ts
|
|
11
|
+
const COMPACT_REQUEST = Symbol("openaiResponsesCompactRequest");
|
|
12
|
+
function claimResponsesCompactRequest(options) {
|
|
13
|
+
const controller = options ? Reflect.get(options, COMPACT_REQUEST) : void 0;
|
|
14
|
+
if (controller?.claimed === false) {
|
|
15
|
+
controller.claimed = true;
|
|
16
|
+
controller.onClaimed();
|
|
17
|
+
return controller;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Preserve the operation when a provider translates simple stream options. */
|
|
21
|
+
function copyResponsesCompactRequest(source, target) {
|
|
22
|
+
const request = source ? Reflect.get(source, COMPACT_REQUEST) : void 0;
|
|
23
|
+
if (request) Reflect.set(target, COMPACT_REQUEST, request);
|
|
24
|
+
}
|
|
25
|
+
/** Run provider compaction through the session's prepared stream stack. */
|
|
26
|
+
async function requestPreparedOpenAIResponsesCompaction(streamFn, model, context, options, mode = "endpoint", replayBudget) {
|
|
27
|
+
const preparedOptions = { ...options };
|
|
28
|
+
let resolveResult;
|
|
29
|
+
let rejectResult;
|
|
30
|
+
const result = new Promise((resolve, reject) => {
|
|
31
|
+
resolveResult = resolve;
|
|
32
|
+
rejectResult = reject;
|
|
33
|
+
});
|
|
34
|
+
let markClaimed;
|
|
35
|
+
const claimed = new Promise((resolve) => {
|
|
36
|
+
markClaimed = resolve;
|
|
37
|
+
});
|
|
38
|
+
Reflect.set(preparedOptions, COMPACT_REQUEST, {
|
|
39
|
+
claimed: false,
|
|
40
|
+
mode,
|
|
41
|
+
replayBudget,
|
|
42
|
+
onClaimed: markClaimed,
|
|
43
|
+
resolve: resolveResult,
|
|
44
|
+
reject: rejectResult
|
|
45
|
+
});
|
|
46
|
+
const stream = await Promise.resolve(streamFn(model, context, preparedOptions));
|
|
47
|
+
try {
|
|
48
|
+
const settled = stream.result().then(() => "settled", () => "settled");
|
|
49
|
+
if (await Promise.race([claimed.then(() => "claimed"), settled]) !== "claimed") throw new Error("Prepared stream did not reach an OpenAI Responses transport");
|
|
50
|
+
return await result;
|
|
51
|
+
} finally {
|
|
52
|
+
await stream.result().catch(() => void 0);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region packages/ai/src/transports/openai-responses-compaction-v2.ts
|
|
57
|
+
/** Request-local collection; no partial checkpoint may survive a provider retry. */
|
|
58
|
+
function createResponsesV2CompactionCollector(replayBudget) {
|
|
59
|
+
let count = 0;
|
|
60
|
+
let item;
|
|
61
|
+
return {
|
|
62
|
+
assertReplayFits(input, model) {
|
|
63
|
+
if (!replayBudget) return;
|
|
64
|
+
const minimumCheckpoint = {
|
|
65
|
+
type: "compaction",
|
|
66
|
+
encrypted_content: "opaque"
|
|
67
|
+
};
|
|
68
|
+
const output = [...retainV2Users(input), minimumCheckpoint];
|
|
69
|
+
if (!isOpenAIResponsesCompactionOutput(output, model)) throw new Error("Responses V2 compaction produced an incompatible replay window");
|
|
70
|
+
if (replayBudget.estimateTokens(output, 1) > replayBudget.maxTokens) throw new Error("ChatGPT V2 retained window exceeds the next request budget");
|
|
71
|
+
},
|
|
72
|
+
sanitizeImages(request) {
|
|
73
|
+
const sanitized = sanitizeResponsesImagePayload(request);
|
|
74
|
+
sanitized.input?.forEach((inputItem, index) => {
|
|
75
|
+
const source = request.input?.[index];
|
|
76
|
+
if (source && Reflect.get(source, RESPONSES_RETAINED_USER)) Object.assign(inputItem, { [RESPONSES_RETAINED_USER]: true });
|
|
77
|
+
});
|
|
78
|
+
return sanitized;
|
|
79
|
+
},
|
|
80
|
+
preserveUsers(input) {
|
|
81
|
+
const users = /* @__PURE__ */ new Map();
|
|
82
|
+
for (const message of input) if (Reflect.get(message, RESPONSES_RETAINED_USER)) {
|
|
83
|
+
const key = sha256Hex(stableStringify(message));
|
|
84
|
+
users.set(key, (users.get(key) ?? 0) + 1);
|
|
85
|
+
}
|
|
86
|
+
return (nextInput) => nextInput.map((message) => {
|
|
87
|
+
if (message.type !== "message" || message.role !== "user") return message;
|
|
88
|
+
const key = sha256Hex(stableStringify(message));
|
|
89
|
+
const remaining = users.get(key) ?? 0;
|
|
90
|
+
if (remaining > 0) {
|
|
91
|
+
users.set(key, remaining - 1);
|
|
92
|
+
return Object.assign({}, message, { [RESPONSES_RETAINED_USER]: true });
|
|
93
|
+
}
|
|
94
|
+
return message;
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
async *observe(events) {
|
|
98
|
+
count = 0;
|
|
99
|
+
item = void 0;
|
|
100
|
+
for await (const event of events) {
|
|
101
|
+
if (isRecord(event) && event.type === "response.output_item.done" && isRecord(event.item) && event.item.type === "compaction") {
|
|
102
|
+
count += 1;
|
|
103
|
+
if (typeof event.item.encrypted_content === "string" && event.item.encrypted_content.length > 0) item = {
|
|
104
|
+
type: "compaction",
|
|
105
|
+
encrypted_content: event.item.encrypted_content
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
yield event;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
finish(params) {
|
|
112
|
+
params.options?.signal?.throwIfAborted();
|
|
113
|
+
if (!params.terminal || params.terminal.status !== "completed" || count !== 1 || !item) throw new Error("Responses V2 compaction requires successful completion and exactly one nonempty compaction item");
|
|
114
|
+
const usage = params.terminal.usage;
|
|
115
|
+
if (!usage) throw new Error("Responses V2 compaction completed without usage");
|
|
116
|
+
const output = [...retainV2Users(params.input), item];
|
|
117
|
+
if (!isOpenAIResponsesCompactionOutput(output, params.model)) throw new Error("Responses V2 compaction produced an incompatible replay window");
|
|
118
|
+
return {
|
|
119
|
+
output,
|
|
120
|
+
item,
|
|
121
|
+
historyMode: "retained-users",
|
|
122
|
+
usage: { ...usage },
|
|
123
|
+
model: params.model,
|
|
124
|
+
replayMetadata: buildOpenAIResponsesReasoningReplayMetadata(params.model, params.options)
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function retainV2Users(input) {
|
|
130
|
+
let remaining = 64e3;
|
|
131
|
+
const retained = [];
|
|
132
|
+
for (let index = input.length - 1; index >= 0 && remaining > 0; index -= 1) {
|
|
133
|
+
const message = input[index];
|
|
134
|
+
if (!message || message.type !== "message" || message.role !== "user" || !Reflect.get(message, RESPONSES_RETAINED_USER) || !Array.isArray(message.content)) continue;
|
|
135
|
+
const content = [];
|
|
136
|
+
for (const part of message.content) {
|
|
137
|
+
const tokens = part.type === "input_text" ? Math.max(1, estimateTokensFromChars(estimateStringChars(part.text))) : part.type === "input_image" ? 2e3 : remaining + 1;
|
|
138
|
+
if (tokens <= remaining) {
|
|
139
|
+
content.push(part);
|
|
140
|
+
remaining -= tokens;
|
|
141
|
+
} else {
|
|
142
|
+
if (part.type === "input_text") {
|
|
143
|
+
let low = 0;
|
|
144
|
+
let high = Math.min(part.text.length, remaining * 4);
|
|
145
|
+
while (low < high) {
|
|
146
|
+
const end = Math.ceil((low + high) / 2);
|
|
147
|
+
if (estimateTokensFromChars(estimateStringChars(part.text.slice(0, end))) <= remaining) low = end;
|
|
148
|
+
else high = end - 1;
|
|
149
|
+
}
|
|
150
|
+
if (low > 0) content.push({
|
|
151
|
+
...part,
|
|
152
|
+
text: part.text.slice(0, low)
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
remaining = 0;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (content.length) {
|
|
160
|
+
const retainedMessage = {
|
|
161
|
+
...message,
|
|
162
|
+
content
|
|
163
|
+
};
|
|
164
|
+
Reflect.deleteProperty(retainedMessage, RESPONSES_RETAINED_USER);
|
|
165
|
+
retained.push(retainedMessage);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return retained.toReversed();
|
|
169
|
+
}
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region packages/ai/src/transports/openai-responses-prompt-observer-internal.ts
|
|
172
|
+
function readFinalResponsesPrompt(request) {
|
|
173
|
+
if (typeof request.instructions === "string") return ["instructions", request.instructions];
|
|
174
|
+
const message = (Array.isArray(request.input) ? request.input : []).find((item) => {
|
|
175
|
+
const role = item.role;
|
|
176
|
+
return role === "developer" || role === "system";
|
|
177
|
+
});
|
|
178
|
+
if (!message) return ["missing", ""];
|
|
179
|
+
const content = message.content;
|
|
180
|
+
const observedPrompt = typeof content === "string" ? content : Array.isArray(content) ? content.flatMap((part) => part.type === "input_text" ? [part.text] : []).join("") : "";
|
|
181
|
+
return [message.role === "developer" ? "input.developer" : "input.system", observedPrompt];
|
|
182
|
+
}
|
|
183
|
+
function createResponsesPromptEgressObserver(options, assembledPrompt) {
|
|
184
|
+
const observer = options ? responsesPromptObserver.get(options) : void 0;
|
|
185
|
+
if (!observer) return;
|
|
186
|
+
const expectedPrompt = sanitizeTransportPayloadText(stripSystemPromptCacheBoundary(assembledPrompt ?? ""));
|
|
187
|
+
return (request, metadata) => {
|
|
188
|
+
const [promptSource, observedPrompt] = readFinalResponsesPrompt(request);
|
|
189
|
+
observer({
|
|
190
|
+
...metadata,
|
|
191
|
+
promptSource,
|
|
192
|
+
expectedChars: expectedPrompt.length,
|
|
193
|
+
observedChars: observedPrompt.length,
|
|
194
|
+
matchesAssembledPrompt: promptSource !== "missing" && observedPrompt === expectedPrompt
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region packages/ai/src/transports/openai-responses-request-lifecycle.ts
|
|
200
|
+
const lifecycleKey = Symbol("openclaw.responsesRequestLifecycle");
|
|
201
|
+
const independentRequestKey = Symbol("openclaw.independentResponsesRequest");
|
|
202
|
+
/** A full-input side request must neither consume nor replace a session's continuation. */
|
|
203
|
+
const independentResponsesRequest = {
|
|
204
|
+
set(options) {
|
|
205
|
+
Object.defineProperty(options, independentRequestKey, {
|
|
206
|
+
value: true,
|
|
207
|
+
enumerable: true
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
has(options) {
|
|
211
|
+
return options !== void 0 && Reflect.get(options, independentRequestKey) === true;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
/** Private transport carrier: serialized options cannot mint host authority. */
|
|
215
|
+
const responsesRequestLifecycle = {
|
|
216
|
+
set(options, lifecycle) {
|
|
217
|
+
Object.defineProperty(options, lifecycleKey, {
|
|
218
|
+
value: lifecycle,
|
|
219
|
+
enumerable: true
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
get(options) {
|
|
223
|
+
if (!options) return;
|
|
224
|
+
return Reflect.get(options, lifecycleKey);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
/** A transport receipt must settle before model output can authorize later work. */
|
|
228
|
+
function withResponsesRequestAcceptance(events, lifecycle, signal) {
|
|
229
|
+
if (!lifecycle) return events;
|
|
230
|
+
return { async *[Symbol.asyncIterator]() {
|
|
231
|
+
for await (const event of events) {
|
|
232
|
+
if (isRecord(event) && event.type === "response.created") {
|
|
233
|
+
const response = isRecord(event.response) ? event.response : void 0;
|
|
234
|
+
if (typeof response?.id !== "string" || !response.id.trim()) throw new Error("Provider continuation response has no identity");
|
|
235
|
+
signal?.throwIfAborted();
|
|
236
|
+
lifecycle.assertCurrent();
|
|
237
|
+
await lifecycle.accepted(response.id, signal);
|
|
238
|
+
signal?.throwIfAborted();
|
|
239
|
+
lifecycle.assertCurrent();
|
|
240
|
+
}
|
|
241
|
+
yield event;
|
|
242
|
+
}
|
|
243
|
+
} };
|
|
244
|
+
}
|
|
245
|
+
//#endregion
|
|
246
|
+
export { createResponsesV2CompactionCollector as a, requestPreparedOpenAIResponsesCompaction as c, createResponsesPromptEgressObserver as i, responsesRequestLifecycle as n, claimResponsesCompactRequest as o, withResponsesRequestAcceptance as r, copyResponsesCompactRequest as s, independentResponsesRequest as t };
|