@openclaw/codex 2026.9.1 → 2026.9.3
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 +2 -0
- package/dist/api.js +18 -23
- package/dist/apply-B6el6hdO.js +357 -0
- package/dist/{attempt-client-cleanup-DYHcRQAa.js → attempt-client-cleanup-D6cR54TV.js} +113 -49
- package/dist/{attempt-context-DmQUNWwT.js → attempt-context-AO4DSjE0.js} +11 -9
- package/dist/{event-projector-usage-C5mcrGjp.js → attempt-notifications--H8zXR5-.js} +3 -89
- package/dist/auth-cache-key-Kq6oerr6.js +498 -0
- package/dist/auth-profile-CwzO4_RG.js +43 -0
- package/dist/auth-profile-selection-DFu9e167.js +45 -0
- package/dist/{binding-connection-E6uDsPlx.js → binding-connection-QqgcPCgk.js} +18 -3
- package/dist/{bounded-turn-wzJrwKKe.js → bounded-turn-lRpmZHFv.js} +54 -150
- package/dist/build-state-6RL6qohz.js +19 -0
- package/dist/{capabilities-dIjNVCYH.js → capabilities-BeqLPbtM.js} +2 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/client-BEKu4yDx.js +3983 -0
- package/dist/command-dispatch-CisT9Jqq.js +21 -0
- package/dist/{command-formatters-CLHhEB1Q.js → command-formatters-DeTfrapr.js} +2 -2
- package/dist/{command-handlers-CTGb2csu.js → command-handlers-BfIsJEuA.js} +158 -76
- package/dist/command-rpc-BMqRQOFX.js +226 -0
- package/dist/{compact-_t0HQrUS.js → compact-CGJZ2rlb.js} +89 -49
- package/dist/config-JDfTI4VI.js +106 -0
- package/dist/{config-BhmfC1s6.js → config-options-jnIFvwxD.js} +208 -654
- package/dist/config-runtime-BWf6JLWG.js +11 -0
- package/dist/config-utils-C57JiJrU.js +69 -0
- package/dist/conversation-binding-CxOlHiix.js +889 -0
- package/dist/{plugin-marketplace-discovery-CfFlKqDl.js → conversation-control-CUCrSIQI.js} +36 -155
- package/dist/doctor-contract-api.js +8 -9
- package/dist/{dynamic-tools-BU9tmlYm.js → dynamic-tools-D-JBoaLt.js} +734 -698
- package/dist/{effective-mcp-catalog-DzYBW4h1.js → effective-mcp-catalog-J_5Ep5Um.js} +4 -3
- package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
- package/dist/ephemeral-turn-DSwzP8YY.js +101 -0
- package/dist/{event-projector-assistant-message-DHRFXKbS.js → event-projector-assistant-message-BmBM4qBV.js} +23 -27
- package/dist/event-projector-usage-CIyrYYid.js +102 -0
- package/dist/{harness-DXVZ5II5.js → harness-FR6eQgyO.js} +47 -17
- package/dist/harness.js +1 -1
- package/dist/history-rejection-B4nOXNXF.js +13 -0
- package/dist/{image-payload-sanitizer-CnfoUPCE.js → image-payload-sanitizer-tupAr-2o.js} +29 -15
- package/dist/incognito-session-uhrBF6wJ.js +15 -0
- package/dist/index.js +413 -2893
- package/dist/{isolated-completion-kg9kv4iH.js → isolated-completion-DHBefrzg.js} +12 -21
- package/dist/{managed-binary-4-Vjz5GH.js → managed-binary-DrjjRRUD.js} +17 -84
- package/dist/managed-thread-store-D1t5jh3G.js +66 -0
- package/dist/media-understanding-provider.js +4 -1
- package/dist/{model-catalog-CUM68Hkl.js → model-catalog-B_6M04Wo.js} +6 -5
- package/dist/{models-sYnEc0gd.js → models-P9k2qAof.js} +4 -4
- package/dist/native-execution-policy-umd0tgh4.js +128 -0
- package/dist/{native-subagent-monitor-CnH147jH.js → native-subagent-monitor-BbCUKRwC.js} +76 -48
- package/dist/node-cli-sessions-rj0ysJwM.js +527 -0
- package/dist/{node-exec-server.runtime-CstNHCmC.js → node-exec-server.runtime-BY_ctYnT.js} +54 -23
- package/dist/plan-BMJdMOEF.js +711 -0
- package/dist/plugin-activation-BQK-f5sV.js +133 -0
- package/dist/{thread-resume-C7pyVKeW.js → plugin-app-cache-key-CdSQzWyX.js} +5 -53
- package/dist/{plugin-approval-roundtrip-CNe-Xrjx.js → plugin-approval-roundtrip-DeW95wB5.js} +1 -1
- package/dist/plugin-inventory-CoRCzWW4.js +325 -0
- package/dist/plugin-marketplace-discovery-3akBizzF.js +134 -0
- package/dist/{plugin-metadata-cache-BFrPhb2c.js → plugin-metadata-cache-DgNfRAGA.js} +13 -9
- package/dist/protocol-CAAcVIKF.js +275 -0
- package/dist/{provider-capabilities-DW5p4k9w.js → provider-capabilities-W4tfK5Y5.js} +2 -2
- package/dist/{rate-limits-CawQJfUS.js → rate-limits-Bqnx1N4z.js} +1 -1
- package/dist/request-CGvGOpeR.js +198 -0
- package/dist/{run-attempt-D1hJO4fX.js → run-attempt-DwKds3DN.js} +1498 -1028
- package/dist/{runtime-artifact-C3jVimFn.js → runtime-artifact-T-NwqeSH.js} +28 -28
- package/dist/sandbox-guard-BcT66fWy.js +165 -0
- package/dist/{session-binding-BHuTCRZQ.js → session-binding-CKSepwIC.js} +118 -324
- package/dist/session-binding-record-CaZjYwNS.js +256 -0
- package/dist/session-catalog-HaDcp7Sv.js +1533 -0
- package/dist/session-catalog-adoption-BKLtSrwi.js +251 -0
- package/dist/session-catalog-archive-D0i2pGj2.js +56 -0
- package/dist/session-catalog-home-id-D7-aLiNt.js +190 -0
- package/dist/session-catalog-node-adoption-BUuDYY8R.js +182 -0
- package/dist/session-catalog-node-continue-CBtc4wkI.js +238 -0
- package/dist/session-catalog-parsing-CdD3JhdM.js +280 -0
- package/dist/session-catalog-provenance-DkJHo735.js +124 -0
- package/dist/{session-cli-CmFEXMAM.js → session-cli-CbgaHh0f.js} +3 -2
- package/dist/session-history-Cz-tOOYj.js +96 -0
- package/dist/{session-upstream-marker-C351-5Qw.js → session-history-import-DFN7sWRU.js} +5 -49
- package/dist/session-history-read-cxPUxyVV.js +50 -0
- package/dist/session-history-worker-runtime.js +60 -0
- package/dist/{settled-turn-context-D3SNWtUn.js → session-history.worker-CNEvGaU5.js} +75 -69
- package/dist/session-history.worker.js +2 -0
- package/dist/{session-initialization-BeWzjGiR.js → session-initialization-Jo86C60I.js} +2 -1
- package/dist/{session-permission-policy-DeWVTCMj.js → session-permission-policy-B22InTp_.js} +4 -7
- package/dist/{session-retirement-BujDjXVF.js → session-retirement-BSNG_mhf.js} +8 -7
- package/dist/session-upstream-marker-D15C9NHp.js +46 -0
- package/dist/settled-turn-context-Du6gdUDd.js +45 -0
- package/dist/{settled-turn-finalizer-BVJx4yoc.js → settled-turn-finalizer-BuLUrZl2.js} +54 -42
- package/dist/shared-client-CVhez2Uo.js +2911 -0
- package/dist/{side-question-BTZAII4l.js → side-question-DLbr2vUU.js} +135 -191
- package/dist/source-Da-h6f7e.js +518 -0
- package/dist/thread-archive-guard-D1bP04Tf.js +53 -0
- package/dist/{thread-lifecycle-DAcEJ_Om.js → thread-lifecycle-D1pzRwHB.js} +467 -977
- package/dist/{thread-ownership-zGokd8i1.js → thread-ownership-D6oASVRu.js} +15 -17
- package/dist/{thread-policy-g4KbJPzp.js → thread-policy-D8kI7yAO.js} +2 -2
- package/dist/thread-resume-T5cveyxA.js +52 -0
- package/dist/timeout-BVw8aaM1.js +33 -0
- package/dist/transcript-mirror-attestation-DibE0krH.js +89 -0
- package/dist/{transcript-mirror-DTUxFWa_.js → transcript-mirror-t5TOccct.js} +111 -379
- package/dist/{transport-stdio-CyPldczm.js → transport-stdio-BGjHoYLr.js} +80 -48
- package/dist/{upstream-session-fork-CYlBIGVt.js → upstream-session-fork-De-sLJ2r.js} +94 -166
- package/dist/{usage-Bj-rrzkR.js → usage-CPPTmBvZ.js} +4 -3
- package/dist/version-omm6IPI3.js +12 -0
- package/dist/{web-search-provider.runtime-D2FWSK4w.js → web-search-provider.runtime-CSVgQL0w.js} +3 -3
- package/openclaw.plugin.json +22 -1
- package/package.json +6 -6
- package/dist/request-DYAI5FQE.js +0 -475
- package/dist/session-catalog-yyvTWFOw.js +0 -3120
- package/dist/session-history-C5J1AKzG.js +0 -87
- package/dist/shared-client-DxcfF9KX.js +0 -7494
- package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-Co2Vfcf_.js} +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { $t as isJsonObject, at as readCodexTurnCompletedNotification, et as assertCodexThreadStartResponse, ot as createCodexElicitationResponse, rt as readCodexErrorNotification, tt as assertCodexTurnStartResponse, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-DxcfF9KX.js";
|
|
2
1
|
import { r as readCodexAppServerConfigOptions } from "./launch-args-RXQwn8zV.js";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
2
|
+
import { C as readCodexErrorNotification, E as createCodexElicitationResponse, b as assertCodexThreadStartResponse, x as assertCodexTurnStartResponse } from "./client-BEKu4yDx.js";
|
|
3
|
+
import "./config-JDfTI4VI.js";
|
|
4
|
+
import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-BWf6JLWG.js";
|
|
5
|
+
import { u as isCodexAppServerStartSelectionChangedError } from "./shared-client-CVhez2Uo.js";
|
|
6
|
+
import { a as closeCodexStartupClientBestEffort, o as interruptCodexTurnAndWaitBestEffort, t as CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS } from "./attempt-client-cleanup-D6cR54TV.js";
|
|
7
|
+
import { t as CodexEphemeralTurn } from "./ephemeral-turn-DSwzP8YY.js";
|
|
8
|
+
import { r as readModelListResult } from "./models-P9k2qAof.js";
|
|
9
|
+
import { G as attestCodexRestrictedToolSurfaceMcpServersDisabled, Tt as mergeCodexThreadConfigs, _ as buildCodexRingZeroThreadConfigPatch, b as readCodexInheritedMcpServerNames, g as assertCodexManagedRequirementsDoNotOverrideToolPolicy, v as buildCodexRuntimeThreadConfig } from "./thread-lifecycle-D1pzRwHB.js";
|
|
12
10
|
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
import fs from "node:fs/promises";
|
|
13
13
|
import { resolvePreferredOpenClawTmpDir, withTempWorkspace } from "openclaw/plugin-sdk/temp-path";
|
|
14
14
|
//#region extensions/codex/src/app-server/bounded-turn.ts
|
|
15
15
|
const CODEX_APP_SERVER_ARGS_ENV_KEY = "OPENCLAW_CODEX_APP_SERVER_ARGS";
|
|
@@ -39,6 +39,7 @@ var CodexBoundedTurnTimeoutError = class extends Error {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
async function runBoundedCodexAppServerTurn(params) {
|
|
42
|
+
params.assertCurrent?.();
|
|
42
43
|
const appServer = resolveCodexAppServerRuntimeOptions({
|
|
43
44
|
pluginConfig: params.options.pluginConfig,
|
|
44
45
|
managedCommandOrder: params.isolation === "private-stdio" ? "package-first" : void 0
|
|
@@ -64,27 +65,23 @@ async function runBoundedCodexAppServerTurnInWorkspace(params, appServer, worksp
|
|
|
64
65
|
const deadline = timing?.deadline ?? Date.now() + totalTimeoutMs;
|
|
65
66
|
const timeoutMs = deadline - Date.now();
|
|
66
67
|
if (timeoutMs <= 0) throw timeoutError;
|
|
68
|
+
params.assertCurrent?.();
|
|
67
69
|
const agentDir = params.agentDir?.trim() || void 0;
|
|
68
70
|
const startOptions = workspace.codexHome ? buildPrivateCodexAppServerStartOptions(appServer.start, workspace.codexHome) : appServer.start;
|
|
69
71
|
const ownsClient = !params.options.clientFactory;
|
|
70
|
-
const
|
|
71
|
-
const client = params.options.clientFactory ? await params.options.clientFactory({
|
|
72
|
+
const clientOptions = {
|
|
72
73
|
startOptions,
|
|
73
|
-
...
|
|
74
|
+
...params.preparedAuth ? { preparedAuth: params.preparedAuth } : { authProfileId: params.profile },
|
|
74
75
|
authRequirement: params.authRequirement,
|
|
75
76
|
agentDir,
|
|
76
77
|
config: params.config,
|
|
77
78
|
timeoutMs,
|
|
79
|
+
assertCurrent: params.assertCurrent,
|
|
78
80
|
...params.signal ? { abandonSignal: params.signal } : {}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
authRequirement: params.authRequirement,
|
|
84
|
-
agentDir,
|
|
85
|
-
authProfileStore: params.authProfileStore,
|
|
86
|
-
config: params.config,
|
|
87
|
-
...params.signal ? { abandonSignal: params.signal } : {}
|
|
81
|
+
};
|
|
82
|
+
const client = params.options.clientFactory ? await params.options.clientFactory(clientOptions) : await import("./shared-client-CVhez2Uo.js").then((n) => n.y).then(({ createIsolatedCodexAppServerClient }) => createIsolatedCodexAppServerClient({
|
|
83
|
+
...clientOptions,
|
|
84
|
+
authProfileStore: params.authProfileStore
|
|
88
85
|
}));
|
|
89
86
|
const abortController = new AbortController();
|
|
90
87
|
let activeThreadId;
|
|
@@ -110,17 +107,23 @@ async function runBoundedCodexAppServerTurnInWorkspace(params, appServer, worksp
|
|
|
110
107
|
const timeout = setTimeout(() => abortRun(timeoutError), Math.max(1, remainingRunMs));
|
|
111
108
|
timeout.unref?.();
|
|
112
109
|
let retrySelection = false;
|
|
110
|
+
const requestOptions = {
|
|
111
|
+
timeoutMs,
|
|
112
|
+
signal: abortController.signal,
|
|
113
|
+
assertCurrent: params.assertCurrent
|
|
114
|
+
};
|
|
113
115
|
try {
|
|
116
|
+
params.assertCurrent?.();
|
|
114
117
|
const modelSelection = await resolveCodexBoundedTurnModel({
|
|
115
118
|
client,
|
|
116
119
|
selection: params.model,
|
|
117
120
|
requiredModalities: params.requiredModalities,
|
|
118
|
-
|
|
119
|
-
signal: abortController.signal
|
|
121
|
+
...requestOptions
|
|
120
122
|
});
|
|
121
123
|
const inheritedMcpServerNames = params.requireNoExternalCapabilities ? await readCodexInheritedMcpServerNames(client, workspace.cwd, abortController.signal) : [];
|
|
122
124
|
if (params.requireNoExternalCapabilities) await assertCodexManagedRequirementsDoNotOverrideToolPolicy(client, { restrictedToolSurface: true }, abortController.signal);
|
|
123
125
|
const threadConfig = buildCodexRuntimeThreadConfig(resolveBoundedThreadConfig(params, workspace, inheritedMcpServerNames), { nativeCodeModeEnabled: false });
|
|
126
|
+
params.assertCurrent?.();
|
|
124
127
|
const thread = assertCodexThreadStartResponse(await client.request("thread/start", {
|
|
125
128
|
model: modelSelection.runtimeModelId,
|
|
126
129
|
...params.modelProvider ? { modelProvider: params.modelProvider } : {},
|
|
@@ -135,47 +138,49 @@ async function runBoundedCodexAppServerTurnInWorkspace(params, appServer, worksp
|
|
|
135
138
|
dynamicTools: [],
|
|
136
139
|
experimentalRawEvents: true,
|
|
137
140
|
ephemeral: true
|
|
138
|
-
},
|
|
139
|
-
timeoutMs,
|
|
140
|
-
signal: abortController.signal
|
|
141
|
-
}));
|
|
141
|
+
}, requestOptions));
|
|
142
142
|
activeThreadId = thread.thread.id;
|
|
143
143
|
if (abortController.signal.aborted) requestInterrupt();
|
|
144
144
|
if (params.requireNoExternalCapabilities) await attestCodexRestrictedToolSurfaceMcpServersDisabled(client, thread.thread.id, threadConfig, abortController.signal);
|
|
145
145
|
if (params.historyItems?.length) await client.request("thread/inject_items", {
|
|
146
146
|
threadId: thread.thread.id,
|
|
147
147
|
items: params.historyItems
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
}, requestOptions);
|
|
149
|
+
params.assertCurrent?.();
|
|
150
|
+
const collector = new CodexEphemeralTurn(client, thread.thread.id, {
|
|
151
|
+
textMode: "all",
|
|
152
|
+
onRequest: createCodexBoundedApprovalHandler(params.taskLabel)
|
|
151
153
|
});
|
|
152
|
-
const collector = createCodexBoundedTurnCollector(thread.thread.id, params.taskLabel, params.allowEmptyText === true);
|
|
153
|
-
const cleanup = client.addNotificationHandler(collector.handleNotification);
|
|
154
|
-
const requestCleanup = client.addRequestHandler(createCodexBoundedApprovalHandler(params.taskLabel));
|
|
155
154
|
try {
|
|
156
155
|
const turn = assertCodexTurnStartResponse(await client.request("turn/start", {
|
|
157
156
|
threadId: thread.thread.id,
|
|
158
157
|
input: params.input,
|
|
159
158
|
approvalPolicy: "on-request",
|
|
160
|
-
model: modelSelection.runtimeModelId,
|
|
161
159
|
effort: "low"
|
|
162
|
-
},
|
|
163
|
-
timeoutMs,
|
|
164
|
-
signal: abortController.signal
|
|
165
|
-
}));
|
|
160
|
+
}, requestOptions));
|
|
166
161
|
activeTurnId = turn.turn.id;
|
|
167
162
|
if (abortController.signal.aborted) requestInterrupt();
|
|
163
|
+
const result = await collector.wait(turn.turn, {
|
|
164
|
+
signal: abortController.signal,
|
|
165
|
+
abortError: () => resolveCodexBoundedTurnAbortError(abortController.signal, params.taskLabel, timeoutError)
|
|
166
|
+
});
|
|
167
|
+
if (result.error || result.turn?.status === "failed") throw new Error((result.error ? readCodexErrorNotification(result.error)?.error.message : result.turn?.error?.message) ?? `codex app-server ${params.taskLabel} turn failed`);
|
|
168
|
+
if (result.turn?.status !== "completed") throw new Error(`codex app-server ${params.taskLabel} turn ended with status ${result.turn?.status ?? "unknown"}`);
|
|
169
|
+
if (!result.text && !params.allowEmptyText) throw new Error(`Codex app-server ${params.taskLabel} turn returned no text.`);
|
|
170
|
+
params.assertCurrent?.();
|
|
168
171
|
return {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
text: result.text,
|
|
173
|
+
items: result.items,
|
|
174
|
+
usage: result.usage,
|
|
175
|
+
model: modelSelection.catalogId,
|
|
176
|
+
nativeSelection: {
|
|
177
|
+
model: thread.model,
|
|
178
|
+
modelProvider: thread.modelProvider
|
|
179
|
+
}
|
|
174
180
|
};
|
|
175
181
|
} finally {
|
|
176
182
|
await interruptPromise;
|
|
177
|
-
|
|
178
|
-
cleanup();
|
|
183
|
+
collector.route.release();
|
|
179
184
|
}
|
|
180
185
|
} catch (error) {
|
|
181
186
|
if (abortController.signal.aborted) throw resolveCodexBoundedTurnAbortError(abortController.signal, params.taskLabel, timeoutError);
|
|
@@ -246,7 +251,8 @@ async function resolveCodexBoundedTurnModel(params) {
|
|
|
246
251
|
includeHidden: params.selection.mode === "required"
|
|
247
252
|
}, {
|
|
248
253
|
timeoutMs: Math.min(params.timeoutMs, 5e3),
|
|
249
|
-
signal: params.signal
|
|
254
|
+
signal: params.signal,
|
|
255
|
+
assertCurrent: params.assertCurrent
|
|
250
256
|
});
|
|
251
257
|
const listed = readModelListResult(result).models;
|
|
252
258
|
if (params.selection.mode === "live-default") {
|
|
@@ -268,110 +274,8 @@ async function resolveCodexBoundedTurnModel(params) {
|
|
|
268
274
|
runtimeModelId: match.model
|
|
269
275
|
};
|
|
270
276
|
}
|
|
271
|
-
function createCodexBoundedTurnCollector(threadId, taskLabel, allowEmptyText) {
|
|
272
|
-
let turnId;
|
|
273
|
-
let completedTurn;
|
|
274
|
-
let promptError;
|
|
275
|
-
let responseUsage;
|
|
276
|
-
const pending = [];
|
|
277
|
-
const completedItems = /* @__PURE__ */ new Map();
|
|
278
|
-
const assistantTextByItem = /* @__PURE__ */ new Map();
|
|
279
|
-
const assistantItemOrder = [];
|
|
280
|
-
const { promise: completion, resolve: resolveCompletion } = createDeferred();
|
|
281
|
-
const rememberAssistantText = (itemId, text) => {
|
|
282
|
-
if (!text) return;
|
|
283
|
-
if (!assistantTextByItem.has(itemId)) assistantItemOrder.push(itemId);
|
|
284
|
-
assistantTextByItem.set(itemId, text);
|
|
285
|
-
};
|
|
286
|
-
const handleNotification = (notification) => {
|
|
287
|
-
const params = isJsonObject(notification.params) ? notification.params : void 0;
|
|
288
|
-
if (!params || readStringField(params, "threadId") !== threadId) return;
|
|
289
|
-
if (!turnId) {
|
|
290
|
-
pending.push(notification);
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
if (readCodexNotificationTurnId(params) !== turnId) return;
|
|
294
|
-
if (notification.method === "item/completed") {
|
|
295
|
-
const item = readCodexNotificationItem(notification.params);
|
|
296
|
-
if (item) {
|
|
297
|
-
completedItems.set(item.id, item);
|
|
298
|
-
if (item.type === "agentMessage" && typeof item.text === "string") rememberAssistantText(item.id, item.text);
|
|
299
|
-
}
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
if (notification.method === "item/agentMessage/delta") {
|
|
303
|
-
const itemId = readStringField(params, "itemId") ?? readStringField(params, "id") ?? "assistant";
|
|
304
|
-
const delta = readStringField(params, "delta") ?? "";
|
|
305
|
-
rememberAssistantText(itemId, `${assistantTextByItem.get(itemId) ?? ""}${delta}`);
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
if (notification.method === "rawResponse/completed") {
|
|
309
|
-
const usage = isJsonObject(params.usage) ? params.usage : void 0;
|
|
310
|
-
responseUsage = usage ? normalizeCodexResponseTokenUsage(usage) : void 0;
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
if (notification.method === "turn/completed") {
|
|
314
|
-
completedTurn = readCodexTurnCompletedNotification(notification.params)?.turn ?? completedTurn;
|
|
315
|
-
resolveCompletion();
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
if (notification.method === "error") {
|
|
319
|
-
if (isRetryableErrorNotification(notification.params)) return;
|
|
320
|
-
promptError = readCodexErrorNotification(notification.params)?.error.message ?? `codex app-server ${taskLabel} turn failed`;
|
|
321
|
-
resolveCompletion();
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
return {
|
|
325
|
-
handleNotification,
|
|
326
|
-
async collect(startedTurn, options) {
|
|
327
|
-
turnId = startedTurn.id;
|
|
328
|
-
if (isTerminalTurnStatus(startedTurn.status)) completedTurn = startedTurn;
|
|
329
|
-
for (const notification of pending.splice(0)) handleNotification(notification);
|
|
330
|
-
if (!completedTurn && !promptError) await waitForTurnCompletion({
|
|
331
|
-
completion,
|
|
332
|
-
signal: options.signal,
|
|
333
|
-
taskLabel,
|
|
334
|
-
timeoutError: options.timeoutError
|
|
335
|
-
});
|
|
336
|
-
if (promptError) throw new Error(promptError);
|
|
337
|
-
if (completedTurn?.status === "failed") throw new Error(completedTurn.error?.message ?? `codex app-server ${taskLabel} turn failed`);
|
|
338
|
-
if (completedTurn?.status !== "completed") throw new Error(`codex app-server ${taskLabel} turn ended with status ${completedTurn?.status ?? "unknown"}`);
|
|
339
|
-
const items = collectCompletedItems(completedTurn?.items, completedItems);
|
|
340
|
-
const itemText = collectAssistantTextFromItems(items);
|
|
341
|
-
const deltaText = assistantItemOrder.map((itemId) => assistantTextByItem.get(itemId)?.trim()).filter((text) => Boolean(text)).join("\n\n").trim();
|
|
342
|
-
const text = (itemText || deltaText).trim();
|
|
343
|
-
if (!text && !allowEmptyText) throw new Error(`Codex app-server ${taskLabel} turn returned no text.`);
|
|
344
|
-
return {
|
|
345
|
-
text,
|
|
346
|
-
items,
|
|
347
|
-
...responseUsage ? { usage: responseUsage } : {}
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
function collectCompletedItems(turnItems, notificationItems) {
|
|
353
|
-
const items = new Map(notificationItems);
|
|
354
|
-
for (const item of turnItems ?? []) items.set(item.id, item);
|
|
355
|
-
return [...items.values()];
|
|
356
|
-
}
|
|
357
|
-
async function waitForTurnCompletion(params) {
|
|
358
|
-
if (params.signal.aborted) throw resolveCodexBoundedTurnAbortError(params.signal, params.taskLabel, params.timeoutError);
|
|
359
|
-
let cleanupAbort;
|
|
360
|
-
try {
|
|
361
|
-
await Promise.race([params.completion, new Promise((_, reject) => {
|
|
362
|
-
const abortListener = () => reject(resolveCodexBoundedTurnAbortError(params.signal, params.taskLabel, params.timeoutError));
|
|
363
|
-
params.signal.addEventListener("abort", abortListener, { once: true });
|
|
364
|
-
cleanupAbort = () => params.signal.removeEventListener("abort", abortListener);
|
|
365
|
-
})]);
|
|
366
|
-
} finally {
|
|
367
|
-
cleanupAbort?.();
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
277
|
function resolveCodexBoundedTurnAbortError(signal, taskLabel, timeoutError) {
|
|
371
278
|
return signal.reason === timeoutError ? timeoutError : /* @__PURE__ */ new Error(`codex app-server ${taskLabel} turn aborted`);
|
|
372
279
|
}
|
|
373
|
-
function collectAssistantTextFromItems(items) {
|
|
374
|
-
return (items ?? []).filter((item) => item.type === "agentMessage").map((item) => item.text.trim()).filter(Boolean).join("\n\n").trim();
|
|
375
|
-
}
|
|
376
280
|
//#endregion
|
|
377
|
-
export { runBoundedCodexAppServerTurn
|
|
281
|
+
export { runBoundedCodexAppServerTurn };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region extensions/codex/package.json
|
|
2
|
+
var version = "2026.9.3";
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region extensions/codex/src/build-state.ts
|
|
5
|
+
/**
|
|
6
|
+
* Duplicate module copies share one immutable published version's state.
|
|
7
|
+
* In-process restarts retain old records and callbacks for their old owners.
|
|
8
|
+
* Local rebuilds without a version bump deliberately share the same state.
|
|
9
|
+
*/
|
|
10
|
+
function codexBuildSymbol(name) {
|
|
11
|
+
return Symbol.for(`${name}@${version}`);
|
|
12
|
+
}
|
|
13
|
+
function defineCodexBuildState(name, create) {
|
|
14
|
+
const key = codexBuildSymbol(name);
|
|
15
|
+
const globalState = globalThis;
|
|
16
|
+
return () => globalState[key] ??= create();
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { defineCodexBuildState as n, codexBuildSymbol as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as CodexAppServerRpcError } from "./session-catalog-provenance-DkJHo735.js";
|
|
2
2
|
//#region extensions/codex/src/app-server/capabilities.ts
|
|
3
3
|
/**
|
|
4
4
|
* Capability helpers for optional Codex app-server control-plane methods.
|
|
@@ -17,6 +17,7 @@ const CODEX_CONTROL_METHODS = {
|
|
|
17
17
|
listSkills: "skills/list",
|
|
18
18
|
listThreads: "thread/list",
|
|
19
19
|
listThreadTurns: "thread/turns/list",
|
|
20
|
+
listThreadItems: "thread/items/list",
|
|
20
21
|
readThread: "thread/read",
|
|
21
22
|
rateLimits: "account/rateLimits/read",
|
|
22
23
|
archiveThread: "thread/archive",
|
package/dist/cli-metadata.js
CHANGED
|
@@ -2,7 +2,7 @@ import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
|
2
2
|
//#region extensions/codex/cli-metadata.ts
|
|
3
3
|
function registerCodexCliMetadata(api) {
|
|
4
4
|
api.registerCli(async ({ program }) => {
|
|
5
|
-
const { registerCodexSessionCli } = await import("./session-cli-
|
|
5
|
+
const { registerCodexSessionCli } = await import("./session-cli-CbgaHh0f.js");
|
|
6
6
|
registerCodexSessionCli(program);
|
|
7
7
|
}, { descriptors: [{
|
|
8
8
|
name: "codex",
|