@openclaw/codex 2026.5.14-beta.2 → 2026.5.16-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{client-CoctX13d.js → client-CA7amCZ8.js} +1 -1
- package/dist/{client-factory-Be6RD28K.js → client-factory-DwzPofwS.js} +1 -1
- package/dist/{command-formatters-DRJaVHhN.js → command-formatters-BRW7_Nu7.js} +10 -2
- package/dist/{command-handlers-CXxykxjq.js → command-handlers-D6UDzndR.js} +7 -7
- package/dist/compact-96QPqIAu.js +329 -0
- package/dist/{computer-use-DsJxRRtm.js → computer-use-BX02ojP4.js} +2 -2
- package/dist/{config-0rd3LnKg.js → config-3ATInASk.js} +7 -1
- package/dist/harness.js +9 -6
- package/dist/index.js +7 -7
- package/dist/media-understanding-provider.js +3 -3
- package/dist/{models-GCYf5s8J.js → models-BHS-8DS_.js} +1 -1
- package/dist/{node-cli-sessions-CiexDHeV.js → node-cli-sessions-BLDFnUEF.js} +5 -5
- package/dist/{plugin-activation-aQOmRQwA.js → plugin-activation-BDU4e-NA.js} +1 -1
- package/dist/provider.js +2 -2
- package/dist/{request-CKYiRqsN.js → request-Czoa60Nt.js} +3 -3
- package/dist/{run-attempt-DG9NQab2.js → run-attempt-B6gN6CrO.js} +364 -77
- package/dist/{session-binding-CMTXuyoz.js → session-binding-DbdVqMzW.js} +14 -2
- package/dist/{shared-client-BwUqd3lh.js → shared-client-CnbrvEfV.js} +2 -2
- package/dist/{side-question-CVWPOkY-.js → side-question-CFcVH8fj.js} +7 -7
- package/dist/test-api.js +2 -2
- package/dist/{thread-lifecycle-DrbViNpf.js → thread-lifecycle-BMK4m_PL.js} +159 -34
- package/dist/{vision-tools-CzTdigBu.js → vision-tools-Cm_YicZb.js} +107 -7
- package/openclaw.plugin.json +1 -1
- package/package.json +4 -4
- package/dist/compact-DWa8cylR.js +0 -256
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as resolveCodexAppServerRuntimeOptions } from "./config-3ATInASk.js";
|
|
2
2
|
import { n as isRpcResponse } from "./protocol-C9UWI98H.js";
|
|
3
3
|
import { createInterface } from "node:readline";
|
|
4
4
|
import { OPENCLAW_VERSION, embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region extensions/codex/src/app-server/client-factory.ts
|
|
2
|
-
const defaultCodexAppServerClientFactory = (startOptions, authProfileId, agentDir, config) => import("./shared-client-
|
|
2
|
+
const defaultCodexAppServerClientFactory = (startOptions, authProfileId, agentDir, config) => import("./shared-client-CnbrvEfV.js").then((n) => n.a).then(({ getSharedCodexAppServerClient }) => getSharedCodexAppServerClient({
|
|
3
3
|
startOptions,
|
|
4
4
|
authProfileId,
|
|
5
5
|
agentDir,
|
|
@@ -474,7 +474,10 @@ function formatCodexRateLimitDetails(value) {
|
|
|
474
474
|
}
|
|
475
475
|
function summarizeRateLimits(value) {
|
|
476
476
|
const entries = extractArray(value);
|
|
477
|
-
if (entries.length > 0)
|
|
477
|
+
if (entries.length > 0) {
|
|
478
|
+
const count = entries.filter(isMeaningfulRateLimitSnapshot).length;
|
|
479
|
+
return count > 0 ? `${count}` : "none returned";
|
|
480
|
+
}
|
|
478
481
|
if (!isJsonObject(value)) return "none returned";
|
|
479
482
|
const keyed = value.rateLimitsByLimitId;
|
|
480
483
|
if (isJsonObject(keyed)) {
|
|
@@ -484,7 +487,12 @@ function summarizeRateLimits(value) {
|
|
|
484
487
|
return isMeaningfulRateLimitSnapshot(value.rateLimits) ? "1" : "none returned";
|
|
485
488
|
}
|
|
486
489
|
function isMeaningfulRateLimitSnapshot(value) {
|
|
487
|
-
|
|
490
|
+
if (!isJsonObject(value)) return false;
|
|
491
|
+
if (readString(value, "rateLimitReachedType") ?? readString(value, "rate_limit_reached_type")) return true;
|
|
492
|
+
return ["primary", "secondary"].some((key) => {
|
|
493
|
+
const window = value[key];
|
|
494
|
+
return isJsonObject(window) && Object.values(window).some((entry) => entry != null);
|
|
495
|
+
});
|
|
488
496
|
}
|
|
489
497
|
function extractArray(value) {
|
|
490
498
|
if (Array.isArray(value)) return value;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as listCodexAppServerModels, t as listAllCodexAppServerModels } from "./models-
|
|
1
|
+
import { a as isCodexFastServiceTier, c as resolveCodexAppServerRuntimeOptions } from "./config-3ATInASk.js";
|
|
2
|
+
import { n as listCodexAppServerModels, t as listAllCodexAppServerModels } from "./models-BHS-8DS_.js";
|
|
3
3
|
import { t as isJsonObject } from "./protocol-C9UWI98H.js";
|
|
4
|
-
import { i as describeControlFailure, r as CODEX_CONTROL_METHODS, t as requestCodexAppServerJson } from "./request-
|
|
5
|
-
import { a as formatComputerUseStatus, c as formatThreads, i as formatCodexStatus, l as readString$1, n as formatAccount, o as formatList, p as summarizeCodexAccountUsage, r as formatCodexDisplayText, s as formatModels, t as buildHelp } from "./command-formatters-
|
|
6
|
-
import { i as readCodexAppServerBinding, o as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-
|
|
7
|
-
import { _ as steerCodexConversationTurn, b as readCodexConversationBindingData, d as parseCodexFastModeArg, f as parseCodexPermissionsModeArg, g as setCodexConversationPermissions, h as setCodexConversationModel, l as startCodexConversationThread, m as setCodexConversationFastMode, p as readCodexConversationActiveTurn, r as formatCodexCliSessions, u as formatPermissionsMode, v as stopCodexConversationTurn, x as resolveCodexDefaultWorkspaceDir, y as createCodexCliNodeConversationBindingData } from "./node-cli-sessions-
|
|
8
|
-
import { n as installCodexComputerUse, r as readCodexComputerUseStatus } from "./computer-use-
|
|
4
|
+
import { i as describeControlFailure, r as CODEX_CONTROL_METHODS, t as requestCodexAppServerJson } from "./request-Czoa60Nt.js";
|
|
5
|
+
import { a as formatComputerUseStatus, c as formatThreads, i as formatCodexStatus, l as readString$1, n as formatAccount, o as formatList, p as summarizeCodexAccountUsage, r as formatCodexDisplayText, s as formatModels, t as buildHelp } from "./command-formatters-BRW7_Nu7.js";
|
|
6
|
+
import { i as readCodexAppServerBinding, o as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-DbdVqMzW.js";
|
|
7
|
+
import { _ as steerCodexConversationTurn, b as readCodexConversationBindingData, d as parseCodexFastModeArg, f as parseCodexPermissionsModeArg, g as setCodexConversationPermissions, h as setCodexConversationModel, l as startCodexConversationThread, m as setCodexConversationFastMode, p as readCodexConversationActiveTurn, r as formatCodexCliSessions, u as formatPermissionsMode, v as stopCodexConversationTurn, x as resolveCodexDefaultWorkspaceDir, y as createCodexCliNodeConversationBindingData } from "./node-cli-sessions-BLDFnUEF.js";
|
|
8
|
+
import { n as installCodexComputerUse, r as readCodexComputerUseStatus } from "./computer-use-BX02ojP4.js";
|
|
9
9
|
import { n as rememberCodexRateLimits } from "./rate-limit-cache-dvhq-4pi.js";
|
|
10
10
|
import crypto from "node:crypto";
|
|
11
11
|
import { ensureAuthProfileStore, findNormalizedProviderValue, resolveAuthProfileEligibility, resolveAuthProfileOrder, resolveDefaultAgentDir, resolveProfileUnusableUntilForDisplay } from "openclaw/plugin-sdk/agent-runtime";
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { c as resolveCodexAppServerRuntimeOptions } from "./config-3ATInASk.js";
|
|
2
|
+
import { t as isJsonObject } from "./protocol-C9UWI98H.js";
|
|
3
|
+
import { i as readCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-DbdVqMzW.js";
|
|
4
|
+
import { t as defaultCodexAppServerClientFactory } from "./client-factory-DwzPofwS.js";
|
|
5
|
+
import { embeddedAgentLog, formatErrorMessage, isActiveHarnessContextEngine, resolveContextEngineOwnerPluginId, runHarnessContextEngineMaintenance } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
6
|
+
//#region extensions/codex/src/app-server/compact.ts
|
|
7
|
+
const DEFAULT_CODEX_COMPACTION_WAIT_TIMEOUT_MS = 300 * 1e3;
|
|
8
|
+
const warnedIgnoredCompactionOverrides = /* @__PURE__ */ new Set();
|
|
9
|
+
async function maybeCompactCodexAppServerSession(params, options = {}) {
|
|
10
|
+
const activeContextEngine = isActiveHarnessContextEngine(params.contextEngine) ? params.contextEngine : void 0;
|
|
11
|
+
if (activeContextEngine?.info.ownsCompaction) return await compactOwningContextEngine(params, activeContextEngine);
|
|
12
|
+
warnIfIgnoringOpenClawCompactionOverrides(params);
|
|
13
|
+
const nativeResult = await compactCodexNativeThread(params, options);
|
|
14
|
+
if (activeContextEngine && nativeResult?.ok && nativeResult.compacted) try {
|
|
15
|
+
await runHarnessContextEngineMaintenance({
|
|
16
|
+
contextEngine: activeContextEngine,
|
|
17
|
+
sessionId: params.sessionId,
|
|
18
|
+
sessionKey: params.sessionKey,
|
|
19
|
+
sessionFile: params.sessionFile,
|
|
20
|
+
reason: "compaction",
|
|
21
|
+
runtimeContext: params.contextEngineRuntimeContext,
|
|
22
|
+
config: params.config
|
|
23
|
+
});
|
|
24
|
+
} catch (error) {
|
|
25
|
+
embeddedAgentLog.warn("context engine compaction maintenance failed after Codex compaction", {
|
|
26
|
+
sessionId: params.sessionId,
|
|
27
|
+
engineId: activeContextEngine.info.id,
|
|
28
|
+
error: formatErrorMessage(error)
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return nativeResult;
|
|
32
|
+
}
|
|
33
|
+
async function compactOwningContextEngine(params, contextEngine) {
|
|
34
|
+
embeddedAgentLog.info("starting context-engine-owned Codex app-server compaction", {
|
|
35
|
+
sessionId: params.sessionId,
|
|
36
|
+
sessionKey: params.sessionKey,
|
|
37
|
+
engineId: contextEngine.info.id,
|
|
38
|
+
tokenBudget: params.contextTokenBudget,
|
|
39
|
+
currentTokenCount: params.currentTokenCount,
|
|
40
|
+
trigger: params.trigger,
|
|
41
|
+
compactionTarget: params.trigger === "manual" ? "threshold" : "budget",
|
|
42
|
+
force: params.trigger === "manual"
|
|
43
|
+
});
|
|
44
|
+
let result;
|
|
45
|
+
try {
|
|
46
|
+
result = await contextEngine.compact({
|
|
47
|
+
sessionId: params.sessionId,
|
|
48
|
+
sessionKey: params.sessionKey,
|
|
49
|
+
sessionFile: params.sessionFile,
|
|
50
|
+
tokenBudget: params.contextTokenBudget,
|
|
51
|
+
currentTokenCount: params.currentTokenCount,
|
|
52
|
+
compactionTarget: params.trigger === "manual" ? "threshold" : "budget",
|
|
53
|
+
customInstructions: params.customInstructions,
|
|
54
|
+
force: params.trigger === "manual",
|
|
55
|
+
runtimeContext: params.contextEngineRuntimeContext
|
|
56
|
+
});
|
|
57
|
+
} catch (error) {
|
|
58
|
+
embeddedAgentLog.warn("context-engine-owned Codex app-server compaction failed", {
|
|
59
|
+
sessionId: params.sessionId,
|
|
60
|
+
sessionKey: params.sessionKey,
|
|
61
|
+
engineId: contextEngine.info.id,
|
|
62
|
+
error: formatErrorMessage(error)
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
ok: false,
|
|
66
|
+
compacted: false,
|
|
67
|
+
reason: `context engine compaction failed: ${formatErrorMessage(error)}`
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (result.ok && result.compacted) {
|
|
71
|
+
const compactedSessionId = result.result?.sessionId ?? params.sessionId;
|
|
72
|
+
const compactedSessionFile = result.result?.sessionFile ?? params.sessionFile;
|
|
73
|
+
try {
|
|
74
|
+
await runHarnessContextEngineMaintenance({
|
|
75
|
+
contextEngine,
|
|
76
|
+
sessionId: compactedSessionId,
|
|
77
|
+
sessionKey: params.sessionKey,
|
|
78
|
+
sessionFile: compactedSessionFile,
|
|
79
|
+
reason: "compaction",
|
|
80
|
+
runtimeContext: params.contextEngineRuntimeContext,
|
|
81
|
+
config: params.config
|
|
82
|
+
});
|
|
83
|
+
} catch (error) {
|
|
84
|
+
embeddedAgentLog.warn("context engine compaction maintenance failed", {
|
|
85
|
+
sessionId: compactedSessionId,
|
|
86
|
+
engineId: contextEngine.info.id,
|
|
87
|
+
error: formatErrorMessage(error)
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
await clearCodexAppServerBinding(params.sessionFile);
|
|
91
|
+
if (compactedSessionFile !== params.sessionFile) await clearCodexAppServerBinding(compactedSessionFile);
|
|
92
|
+
}
|
|
93
|
+
embeddedAgentLog.info("completed context-engine-owned Codex app-server compaction", {
|
|
94
|
+
sessionId: params.sessionId,
|
|
95
|
+
sessionKey: params.sessionKey,
|
|
96
|
+
engineId: contextEngine.info.id,
|
|
97
|
+
ok: result.ok,
|
|
98
|
+
compacted: result.compacted,
|
|
99
|
+
reason: result.reason,
|
|
100
|
+
codexThreadBindingInvalidated: result.ok && result.compacted
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
ok: result.ok,
|
|
104
|
+
compacted: result.compacted,
|
|
105
|
+
reason: result.reason,
|
|
106
|
+
result: result.result ? {
|
|
107
|
+
...result.result,
|
|
108
|
+
summary: result.result.summary ?? "",
|
|
109
|
+
firstKeptEntryId: result.result.firstKeptEntryId ?? "",
|
|
110
|
+
details: mergeContextEngineCompactionDetails(result.result.details, { codexThreadBindingInvalidated: result.ok && result.compacted })
|
|
111
|
+
} : result.ok && result.compacted ? {
|
|
112
|
+
summary: "",
|
|
113
|
+
firstKeptEntryId: "",
|
|
114
|
+
tokensBefore: params.currentTokenCount ?? 0,
|
|
115
|
+
details: { codexThreadBindingInvalidated: true }
|
|
116
|
+
} : void 0
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function mergeContextEngineCompactionDetails(details, extra) {
|
|
120
|
+
if (details && typeof details === "object" && !Array.isArray(details)) return {
|
|
121
|
+
...details,
|
|
122
|
+
...extra
|
|
123
|
+
};
|
|
124
|
+
return extra;
|
|
125
|
+
}
|
|
126
|
+
function warnIfIgnoringOpenClawCompactionOverrides(params) {
|
|
127
|
+
const ignoredConfig = readIgnoredCompactionOverridePaths(params, isActiveHarnessContextEngine(params.contextEngine) ? params.contextEngine : void 0);
|
|
128
|
+
if (ignoredConfig.length === 0) return;
|
|
129
|
+
const warningKey = ignoredConfig.join("\0");
|
|
130
|
+
if (warnedIgnoredCompactionOverrides.has(warningKey)) return;
|
|
131
|
+
warnedIgnoredCompactionOverrides.add(warningKey);
|
|
132
|
+
embeddedAgentLog.warn("ignoring OpenClaw compaction overrides for Codex app-server compaction; Codex uses native server-side compaction", {
|
|
133
|
+
sessionId: params.sessionId,
|
|
134
|
+
sessionKey: params.sessionKey,
|
|
135
|
+
ignoredConfig
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function readIgnoredCompactionOverridePaths(params, activeContextEngine) {
|
|
139
|
+
const ignored = /* @__PURE__ */ new Set();
|
|
140
|
+
const configuredContextEngine = readStringPath(params.config, [
|
|
141
|
+
"plugins",
|
|
142
|
+
"slots",
|
|
143
|
+
"contextEngine"
|
|
144
|
+
]);
|
|
145
|
+
const runtimeContextEnginePlugin = typeof params.contextEngineRuntimeContext?.contextEnginePluginId === "string" ? params.contextEngineRuntimeContext.contextEnginePluginId.trim() : "";
|
|
146
|
+
const activeContextEnginePlugin = resolveContextEngineOwnerPluginId(activeContextEngine);
|
|
147
|
+
for (const entry of readCompactionOverrideEntries(params)) {
|
|
148
|
+
const localProvider = typeof entry.record.provider === "string" ? entry.record.provider.trim() : "";
|
|
149
|
+
const inheritedProvider = !localProvider && typeof entry.inheritedRecord?.provider === "string" ? entry.inheritedRecord.provider.trim() : "";
|
|
150
|
+
const provider = localProvider || inheritedProvider;
|
|
151
|
+
const providerPath = localProvider ? `${entry.path}.compaction.provider` : inheritedProvider && entry.inheritedPath ? `${entry.inheritedPath}.compaction.provider` : void 0;
|
|
152
|
+
if (provider.toLowerCase() === "lossless-claw" && (activeContextEnginePlugin === "lossless-claw" || runtimeContextEnginePlugin.toLowerCase() === "lossless-claw" || configuredContextEngine?.toLowerCase() === "lossless-claw")) continue;
|
|
153
|
+
if (typeof entry.record.model === "string" && entry.record.model.trim()) ignored.add(`${entry.path}.compaction.model`);
|
|
154
|
+
if (providerPath) ignored.add(providerPath);
|
|
155
|
+
}
|
|
156
|
+
return [...ignored];
|
|
157
|
+
}
|
|
158
|
+
function readCompactionOverrideEntries(params) {
|
|
159
|
+
const entries = [];
|
|
160
|
+
const defaultCompaction = readRecord(readRecord(params.config?.agents)?.defaults)?.compaction;
|
|
161
|
+
const defaultRecord = readRecord(defaultCompaction);
|
|
162
|
+
if (defaultRecord) entries.push({
|
|
163
|
+
path: "agents.defaults",
|
|
164
|
+
record: defaultRecord
|
|
165
|
+
});
|
|
166
|
+
const agentId = readAgentIdFromSessionKey(params.sessionKey ?? params.sandboxSessionKey);
|
|
167
|
+
if (!agentId) return entries;
|
|
168
|
+
const agentCompaction = readRecord((Array.isArray(params.config?.agents?.list) ? params.config.agents.list : []).find((agent) => {
|
|
169
|
+
return (typeof agent?.id === "string" ? agent.id.trim().toLowerCase() : "") === agentId;
|
|
170
|
+
}))?.compaction;
|
|
171
|
+
const agentRecord = readRecord(agentCompaction);
|
|
172
|
+
if (agentRecord) entries.push({
|
|
173
|
+
path: `agents.list.${agentId}`,
|
|
174
|
+
record: agentRecord,
|
|
175
|
+
inheritedRecord: defaultRecord,
|
|
176
|
+
inheritedPath: "agents.defaults"
|
|
177
|
+
});
|
|
178
|
+
return entries;
|
|
179
|
+
}
|
|
180
|
+
function readAgentIdFromSessionKey(sessionKey) {
|
|
181
|
+
const parts = sessionKey?.trim().toLowerCase().split(":").filter(Boolean) ?? [];
|
|
182
|
+
if (parts.length < 3 || parts[0] !== "agent") return;
|
|
183
|
+
return parts[1]?.trim() || void 0;
|
|
184
|
+
}
|
|
185
|
+
function readRecord(value) {
|
|
186
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
187
|
+
}
|
|
188
|
+
function readStringPath(value, path) {
|
|
189
|
+
let current = value;
|
|
190
|
+
for (const segment of path) current = readRecord(current)?.[segment];
|
|
191
|
+
return typeof current === "string" && current.trim() ? current.trim() : void 0;
|
|
192
|
+
}
|
|
193
|
+
async function compactCodexNativeThread(params, options = {}) {
|
|
194
|
+
const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig: options.pluginConfig });
|
|
195
|
+
const binding = await readCodexAppServerBinding(params.sessionFile, { config: params.config });
|
|
196
|
+
if (!binding?.threadId) return {
|
|
197
|
+
ok: false,
|
|
198
|
+
compacted: false,
|
|
199
|
+
reason: "no codex app-server thread binding"
|
|
200
|
+
};
|
|
201
|
+
const requestedAuthProfileId = params.authProfileId?.trim() || void 0;
|
|
202
|
+
if (requestedAuthProfileId && binding.authProfileId && binding.authProfileId !== requestedAuthProfileId) return {
|
|
203
|
+
ok: false,
|
|
204
|
+
compacted: false,
|
|
205
|
+
reason: "auth profile mismatch for session binding"
|
|
206
|
+
};
|
|
207
|
+
const client = await (options.clientFactory ?? defaultCodexAppServerClientFactory)(appServer.start, requestedAuthProfileId ?? binding.authProfileId, params.agentDir, params.config);
|
|
208
|
+
const waiter = createCodexNativeCompactionWaiter(client, binding.threadId);
|
|
209
|
+
let completion;
|
|
210
|
+
try {
|
|
211
|
+
await client.request("thread/compact/start", { threadId: binding.threadId });
|
|
212
|
+
embeddedAgentLog.info("started codex app-server compaction", {
|
|
213
|
+
sessionId: params.sessionId,
|
|
214
|
+
threadId: binding.threadId
|
|
215
|
+
});
|
|
216
|
+
waiter.startTimeout();
|
|
217
|
+
completion = await waiter.promise;
|
|
218
|
+
} catch (error) {
|
|
219
|
+
waiter.cancel();
|
|
220
|
+
return {
|
|
221
|
+
ok: false,
|
|
222
|
+
compacted: false,
|
|
223
|
+
reason: formatCompactionError(error)
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
embeddedAgentLog.info("completed codex app-server compaction", {
|
|
227
|
+
sessionId: params.sessionId,
|
|
228
|
+
threadId: binding.threadId,
|
|
229
|
+
signal: completion.signal,
|
|
230
|
+
turnId: completion.turnId,
|
|
231
|
+
itemId: completion.itemId
|
|
232
|
+
});
|
|
233
|
+
return {
|
|
234
|
+
ok: true,
|
|
235
|
+
compacted: true,
|
|
236
|
+
result: {
|
|
237
|
+
summary: "",
|
|
238
|
+
firstKeptEntryId: "",
|
|
239
|
+
tokensBefore: params.currentTokenCount ?? 0,
|
|
240
|
+
details: {
|
|
241
|
+
backend: "codex-app-server",
|
|
242
|
+
threadId: binding.threadId,
|
|
243
|
+
signal: completion.signal,
|
|
244
|
+
turnId: completion.turnId,
|
|
245
|
+
itemId: completion.itemId
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function createCodexNativeCompactionWaiter(client, threadId) {
|
|
251
|
+
let settled = false;
|
|
252
|
+
let removeHandler = () => {};
|
|
253
|
+
let timeout;
|
|
254
|
+
let failWaiter = () => {};
|
|
255
|
+
return {
|
|
256
|
+
promise: new Promise((resolve, reject) => {
|
|
257
|
+
const cleanup = () => {
|
|
258
|
+
removeHandler();
|
|
259
|
+
if (timeout) clearTimeout(timeout);
|
|
260
|
+
};
|
|
261
|
+
const complete = (completion) => {
|
|
262
|
+
if (settled) return;
|
|
263
|
+
settled = true;
|
|
264
|
+
cleanup();
|
|
265
|
+
resolve(completion);
|
|
266
|
+
};
|
|
267
|
+
const fail = (error) => {
|
|
268
|
+
if (settled) return;
|
|
269
|
+
settled = true;
|
|
270
|
+
cleanup();
|
|
271
|
+
reject(error);
|
|
272
|
+
};
|
|
273
|
+
failWaiter = fail;
|
|
274
|
+
const handler = (notification) => {
|
|
275
|
+
const completion = readNativeCompactionCompletion(notification, threadId);
|
|
276
|
+
if (completion) complete(completion);
|
|
277
|
+
};
|
|
278
|
+
removeHandler = client.addNotificationHandler(handler);
|
|
279
|
+
}),
|
|
280
|
+
startTimeout() {
|
|
281
|
+
if (settled || timeout) return;
|
|
282
|
+
timeout = setTimeout(() => {
|
|
283
|
+
failWaiter(/* @__PURE__ */ new Error(`timed out waiting for codex app-server compaction for ${threadId}`));
|
|
284
|
+
}, resolveCompactionWaitTimeoutMs());
|
|
285
|
+
timeout.unref?.();
|
|
286
|
+
},
|
|
287
|
+
cancel() {
|
|
288
|
+
if (settled) return;
|
|
289
|
+
settled = true;
|
|
290
|
+
removeHandler();
|
|
291
|
+
if (timeout) clearTimeout(timeout);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function readNativeCompactionCompletion(notification, threadId) {
|
|
296
|
+
const params = notification.params;
|
|
297
|
+
if (!isJsonObject(params) || readString(params, "threadId", "thread_id") !== threadId) return;
|
|
298
|
+
if (notification.method === "thread/compacted") return {
|
|
299
|
+
signal: "thread/compacted",
|
|
300
|
+
turnId: readString(params, "turnId", "turn_id")
|
|
301
|
+
};
|
|
302
|
+
if (notification.method !== "item/completed") return;
|
|
303
|
+
const item = isJsonObject(params.item) ? params.item : void 0;
|
|
304
|
+
if (readString(item, "type") !== "contextCompaction") return;
|
|
305
|
+
return {
|
|
306
|
+
signal: "item/completed",
|
|
307
|
+
turnId: readString(params, "turnId", "turn_id"),
|
|
308
|
+
itemId: readString(item, "id") ?? readString(params, "itemId", "item_id", "id")
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function resolveCompactionWaitTimeoutMs() {
|
|
312
|
+
const raw = process.env.OPENCLAW_CODEX_COMPACTION_WAIT_TIMEOUT_MS?.trim();
|
|
313
|
+
const parsed = raw ? Number.parseInt(raw, 10) : NaN;
|
|
314
|
+
if (Number.isFinite(parsed) && parsed > 0) return parsed;
|
|
315
|
+
return DEFAULT_CODEX_COMPACTION_WAIT_TIMEOUT_MS;
|
|
316
|
+
}
|
|
317
|
+
function readString(params, ...keys) {
|
|
318
|
+
if (!params) return;
|
|
319
|
+
for (const key of keys) {
|
|
320
|
+
const value = params[key];
|
|
321
|
+
if (typeof value === "string") return value;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function formatCompactionError(error) {
|
|
325
|
+
if (error instanceof Error) return error.message;
|
|
326
|
+
return String(error);
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
329
|
+
export { maybeCompactCodexAppServerSession };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { i as describeControlFailure, t as requestCodexAppServerJson } from "./request-
|
|
1
|
+
import { c as resolveCodexAppServerRuntimeOptions, l as resolveCodexComputerUseConfig } from "./config-3ATInASk.js";
|
|
2
|
+
import { i as describeControlFailure, t as requestCodexAppServerJson } from "./request-Czoa60Nt.js";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
//#region extensions/codex/src/app-server/computer-use.ts
|
|
5
5
|
var CodexComputerUseSetupError = class extends Error {
|
|
@@ -158,6 +158,12 @@ function resolveCodexAppServerRuntimeOptions(params = {}) {
|
|
|
158
158
|
...serviceTier ? { serviceTier } : {}
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
|
+
function isCodexAppServerApprovalPolicyAllowedByRequirements(policy, params = {}) {
|
|
162
|
+
const content = readCodexRequirementsToml(params);
|
|
163
|
+
if (content === void 0) return true;
|
|
164
|
+
const allowedApprovalPolicies = parseAllowedApprovalPoliciesFromCodexRequirements(content);
|
|
165
|
+
return allowedApprovalPolicies === void 0 || allowedApprovalPolicies.has(policy);
|
|
166
|
+
}
|
|
161
167
|
function resolveCodexComputerUseConfig(params = {}) {
|
|
162
168
|
const env = params.env ?? process.env;
|
|
163
169
|
const config = readCodexPluginConfig(params.pluginConfig).computerUse ?? {};
|
|
@@ -493,4 +499,4 @@ function splitShellWords(value) {
|
|
|
493
499
|
return words;
|
|
494
500
|
}
|
|
495
501
|
//#endregion
|
|
496
|
-
export {
|
|
502
|
+
export { isCodexFastServiceTier as a, resolveCodexAppServerRuntimeOptions as c, withMcpElicitationsApprovalPolicy as d, isCodexAppServerApprovalPolicyAllowedByRequirements as i, resolveCodexComputerUseConfig as l, codexAppServerStartOptionsKey as n, normalizeCodexServiceTier as o, codexSandboxPolicyForTurn as r, readCodexPluginConfig as s, CODEX_PLUGINS_MARKETPLACE_NAME as t, resolveCodexPluginsPolicy as u };
|
package/dist/harness.js
CHANGED
|
@@ -18,25 +18,28 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
18
18
|
};
|
|
19
19
|
},
|
|
20
20
|
runAttempt: async (params) => {
|
|
21
|
-
const { runCodexAppServerAttempt } = await import("./run-attempt-
|
|
22
|
-
return runCodexAppServerAttempt(params, {
|
|
21
|
+
const { runCodexAppServerAttempt } = await import("./run-attempt-B6gN6CrO.js");
|
|
22
|
+
return runCodexAppServerAttempt(params, {
|
|
23
|
+
pluginConfig: options?.pluginConfig,
|
|
24
|
+
nativeHookRelay: { enabled: true }
|
|
25
|
+
});
|
|
23
26
|
},
|
|
24
27
|
runSideQuestion: async (params) => {
|
|
25
|
-
const { runCodexAppServerSideQuestion } = await import("./side-question-
|
|
28
|
+
const { runCodexAppServerSideQuestion } = await import("./side-question-CFcVH8fj.js");
|
|
26
29
|
return runCodexAppServerSideQuestion(params, { pluginConfig: options?.pluginConfig });
|
|
27
30
|
},
|
|
28
31
|
compact: async (params) => {
|
|
29
|
-
const { maybeCompactCodexAppServerSession } = await import("./compact-
|
|
32
|
+
const { maybeCompactCodexAppServerSession } = await import("./compact-96QPqIAu.js");
|
|
30
33
|
return maybeCompactCodexAppServerSession(params, { pluginConfig: options?.pluginConfig });
|
|
31
34
|
},
|
|
32
35
|
reset: async (params) => {
|
|
33
36
|
if (params.sessionFile) {
|
|
34
|
-
const { clearCodexAppServerBinding } = await import("./session-binding-
|
|
37
|
+
const { clearCodexAppServerBinding } = await import("./session-binding-DbdVqMzW.js").then((n) => n.a);
|
|
35
38
|
await clearCodexAppServerBinding(params.sessionFile);
|
|
36
39
|
}
|
|
37
40
|
},
|
|
38
41
|
dispose: async () => {
|
|
39
|
-
const { clearSharedCodexAppServerClientAndWait } = await import("./shared-client-
|
|
42
|
+
const { clearSharedCodexAppServerClientAndWait } = await import("./shared-client-CnbrvEfV.js").then((n) => n.a);
|
|
40
43
|
await clearSharedCodexAppServerClientAndWait();
|
|
41
44
|
}
|
|
42
45
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createCodexAppServerAgentHarness } from "./harness.js";
|
|
2
|
-
import {
|
|
2
|
+
import { c as resolveCodexAppServerRuntimeOptions, s as readCodexPluginConfig, t as CODEX_PLUGINS_MARKETPLACE_NAME } from "./config-3ATInASk.js";
|
|
3
3
|
import { buildCodexMediaUnderstandingProvider } from "./media-understanding-provider.js";
|
|
4
4
|
import { buildCodexProvider } from "./provider.js";
|
|
5
|
-
import { i as describeControlFailure, n as buildCodexPluginAppCacheKey, t as requestCodexAppServerJson } from "./request-
|
|
6
|
-
import { r as formatCodexDisplayText } from "./command-formatters-
|
|
7
|
-
import { c as resolveCodexAppServerAuthAccountCacheKey, d as resolveCodexAppServerEnvApiKeyCacheKey, i as getSharedCodexAppServerClient, t as clearSharedCodexAppServerClientAndWait, u as resolveCodexAppServerAuthProfileIdForAgent } from "./shared-client-
|
|
8
|
-
import { a as resolveCodexCliSessionForBindingOnNode, c as handleCodexConversationInboundClaim, i as listCodexCliSessionsOnNode, n as createCodexCliSessionNodeInvokePolicies, o as resumeCodexCliSessionOnNode, s as handleCodexConversationBindingResolved, t as createCodexCliSessionNodeHostCommands } from "./node-cli-sessions-
|
|
9
|
-
import { a as defaultCodexAppInventoryCache, n as pluginReadParams, t as ensureCodexPluginActivation } from "./plugin-activation-
|
|
5
|
+
import { i as describeControlFailure, n as buildCodexPluginAppCacheKey, t as requestCodexAppServerJson } from "./request-Czoa60Nt.js";
|
|
6
|
+
import { r as formatCodexDisplayText } from "./command-formatters-BRW7_Nu7.js";
|
|
7
|
+
import { c as resolveCodexAppServerAuthAccountCacheKey, d as resolveCodexAppServerEnvApiKeyCacheKey, i as getSharedCodexAppServerClient, t as clearSharedCodexAppServerClientAndWait, u as resolveCodexAppServerAuthProfileIdForAgent } from "./shared-client-CnbrvEfV.js";
|
|
8
|
+
import { a as resolveCodexCliSessionForBindingOnNode, c as handleCodexConversationInboundClaim, i as listCodexCliSessionsOnNode, n as createCodexCliSessionNodeInvokePolicies, o as resumeCodexCliSessionOnNode, s as handleCodexConversationBindingResolved, t as createCodexCliSessionNodeHostCommands } from "./node-cli-sessions-BLDFnUEF.js";
|
|
9
|
+
import { a as defaultCodexAppInventoryCache, n as pluginReadParams, t as ensureCodexPluginActivation } from "./plugin-activation-BDU4e-NA.js";
|
|
10
10
|
import { resolveLivePluginConfigObject } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
11
11
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
12
12
|
import os from "node:os";
|
|
@@ -38,7 +38,7 @@ async function handleCodexCommand(ctx, options = {}) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async function loadDefaultCodexSubcommandHandler() {
|
|
41
|
-
const { handleCodexSubcommand } = await import("./command-handlers-
|
|
41
|
+
const { handleCodexSubcommand } = await import("./command-handlers-D6UDzndR.js");
|
|
42
42
|
return handleCodexSubcommand;
|
|
43
43
|
}
|
|
44
44
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CODEX_PROVIDER_ID, FALLBACK_CODEX_MODELS } from "./provider-catalog.js";
|
|
2
|
-
import {
|
|
2
|
+
import { c as resolveCodexAppServerRuntimeOptions } from "./config-3ATInASk.js";
|
|
3
3
|
import { i as assertCodexTurnStartResponse, l as readCodexTurnCompletedNotification, o as readCodexErrorNotification, r as assertCodexThreadStartResponse } from "./protocol-validators-CSY0BFBo.js";
|
|
4
|
-
import { i as readModelListResult } from "./models-
|
|
4
|
+
import { i as readModelListResult } from "./models-BHS-8DS_.js";
|
|
5
5
|
import { t as isJsonObject } from "./protocol-C9UWI98H.js";
|
|
6
6
|
import { validateJsonSchemaValue } from "openclaw/plugin-sdk/json-schema-runtime";
|
|
7
7
|
//#region extensions/codex/media-understanding-provider.ts
|
|
@@ -62,7 +62,7 @@ async function runBoundedCodexVisionTurn(params) {
|
|
|
62
62
|
const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig: params.options.pluginConfig });
|
|
63
63
|
const timeoutMs = Math.max(100, params.timeoutMs);
|
|
64
64
|
const ownsClient = !params.options.clientFactory;
|
|
65
|
-
const client = params.options.clientFactory ? await params.options.clientFactory(appServer.start, params.profile) : await import("./shared-client-
|
|
65
|
+
const client = params.options.clientFactory ? await params.options.clientFactory(appServer.start, params.profile) : await import("./shared-client-CnbrvEfV.js").then((n) => n.a).then(({ createIsolatedCodexAppServerClient }) => createIsolatedCodexAppServerClient({
|
|
66
66
|
startOptions: appServer.start,
|
|
67
67
|
timeoutMs,
|
|
68
68
|
authProfileId: params.profile
|
|
@@ -39,7 +39,7 @@ async function listAllCodexAppServerModels(options = {}) {
|
|
|
39
39
|
async function withCodexAppServerModelClient(options, run) {
|
|
40
40
|
const timeoutMs = options.timeoutMs ?? 2500;
|
|
41
41
|
const useSharedClient = options.sharedClient !== false;
|
|
42
|
-
const { createIsolatedCodexAppServerClient, getSharedCodexAppServerClient } = await import("./shared-client-
|
|
42
|
+
const { createIsolatedCodexAppServerClient, getSharedCodexAppServerClient } = await import("./shared-client-CnbrvEfV.js").then((n) => n.a);
|
|
43
43
|
const client = useSharedClient ? await getSharedCodexAppServerClient({
|
|
44
44
|
startOptions: options.startOptions,
|
|
45
45
|
timeoutMs,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as isCodexFastServiceTier, c as resolveCodexAppServerRuntimeOptions, r as codexSandboxPolicyForTurn } from "./config-3ATInASk.js";
|
|
2
2
|
import { t as isJsonObject } from "./protocol-C9UWI98H.js";
|
|
3
|
-
import { r as CODEX_CONTROL_METHODS } from "./request-
|
|
4
|
-
import { r as formatCodexDisplayText } from "./command-formatters-
|
|
5
|
-
import { i as getSharedCodexAppServerClient, u as resolveCodexAppServerAuthProfileIdForAgent } from "./shared-client-
|
|
6
|
-
import { i as readCodexAppServerBinding, n as isCodexAppServerNativeAuthProfile, o as writeCodexAppServerBinding, r as normalizeCodexAppServerBindingModelProvider, t as clearCodexAppServerBinding } from "./session-binding-
|
|
3
|
+
import { r as CODEX_CONTROL_METHODS } from "./request-Czoa60Nt.js";
|
|
4
|
+
import { r as formatCodexDisplayText } from "./command-formatters-BRW7_Nu7.js";
|
|
5
|
+
import { i as getSharedCodexAppServerClient, u as resolveCodexAppServerAuthProfileIdForAgent } from "./shared-client-CnbrvEfV.js";
|
|
6
|
+
import { i as readCodexAppServerBinding, n as isCodexAppServerNativeAuthProfile, o as writeCodexAppServerBinding, r as normalizeCodexAppServerBindingModelProvider, t as clearCodexAppServerBinding } from "./session-binding-DbdVqMzW.js";
|
|
7
7
|
import os from "node:os";
|
|
8
8
|
import { formatErrorMessage } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
9
9
|
import { spawn } from "node:child_process";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as CODEX_PLUGINS_MARKETPLACE_NAME, u as resolveCodexPluginsPolicy } from "./config-3ATInASk.js";
|
|
2
2
|
import "node:fs/promises";
|
|
3
3
|
import "node:path";
|
|
4
4
|
var CodexAppInventoryCache = class {
|
package/dist/provider.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CODEX_APP_SERVER_AUTH_MARKER, CODEX_BASE_URL, CODEX_PROVIDER_ID, FALLBACK_CODEX_MODELS, buildCodexModelDefinition, buildCodexProviderConfig } from "./provider-catalog.js";
|
|
2
|
-
import {
|
|
2
|
+
import { c as resolveCodexAppServerRuntimeOptions, s as readCodexPluginConfig } from "./config-3ATInASk.js";
|
|
3
3
|
import { resolveCodexSystemPromptContribution } from "./prompt-overlay.js";
|
|
4
4
|
import { resolvePluginConfigObject } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
5
5
|
import { createSubsystemLogger } from "openclaw/plugin-sdk/core";
|
|
@@ -123,7 +123,7 @@ async function listModelsBestEffort(params) {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
async function listCodexAppServerModelsLazy(options) {
|
|
126
|
-
const { listCodexAppServerModels } = await import("./models-
|
|
126
|
+
const { listCodexAppServerModels } = await import("./models-BHS-8DS_.js").then((n) => n.r);
|
|
127
127
|
return listCodexAppServerModels(options);
|
|
128
128
|
}
|
|
129
129
|
function normalizeTimeoutMs(value) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as CodexAppServerRpcError } from "./client-
|
|
2
|
-
import { f as resolveCodexAppServerHomeDir, i as getSharedCodexAppServerClient, o as withTimeout, r as createIsolatedCodexAppServerClient } from "./shared-client-
|
|
3
|
-
import { i as buildCodexAppInventoryCacheKey } from "./plugin-activation-
|
|
1
|
+
import { n as CodexAppServerRpcError } from "./client-CA7amCZ8.js";
|
|
2
|
+
import { f as resolveCodexAppServerHomeDir, i as getSharedCodexAppServerClient, o as withTimeout, r as createIsolatedCodexAppServerClient } from "./shared-client-CnbrvEfV.js";
|
|
3
|
+
import { i as buildCodexAppInventoryCacheKey } from "./plugin-activation-BDU4e-NA.js";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
//#region extensions/codex/src/app-server/capabilities.ts
|
|
6
6
|
const CODEX_CONTROL_METHODS = {
|