@openclaw/codex 2026.8.1-beta.2 → 2026.8.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.
Files changed (64) hide show
  1. package/dist/api.js +146 -0
  2. package/dist/{attempt-client-cleanup-DMLXUfa8.js → attempt-client-cleanup-CVPvp9dL.js} +47 -5
  3. package/dist/{auth-binding-B4FfbcCg.js → auth-binding-Ds_QVm-X.js} +18 -3
  4. package/dist/{binding-connection-I5Bo-AsX.js → binding-connection-CCQFs8lf.js} +15 -3
  5. package/dist/{bounded-turn-qgZmzy_4.js → bounded-turn-rq5tiSXk.js} +27 -26
  6. package/dist/{capabilities-CybGI1oz.js → capabilities-CGm_94eL.js} +1 -1
  7. package/dist/cli-metadata.js +1 -1
  8. package/dist/{command-formatters-B1AEz8ZA.js → command-formatters-C54Yg3eA.js} +2 -2
  9. package/dist/{command-handlers-Db8pu_ds.js → command-handlers-BvOAHTrA.js} +111 -67
  10. package/dist/{compact-LspQaGfl.js → compact-Hd7SAc0N.js} +35 -30
  11. package/dist/{session-binding-DPxIvMgE.js → config-Cxw3Cl3k.js} +361 -1161
  12. package/dist/context-compaction-activity-BOeJf7yo.js +58 -0
  13. package/dist/doctor-contract-api.js +128 -26
  14. package/dist/{dynamic-tools-BVdyWkUD.js → dynamic-tools-BFoUcRdx.js} +1341 -1464
  15. package/dist/{effective-mcp-catalog-DIIhAtOZ.js → effective-mcp-catalog-BTJHnDSx.js} +2 -2
  16. package/dist/elicitation-input-DMkeki8d.js +71 -0
  17. package/dist/{event-projector-assistant-message-BwxV4d6N.js → event-projector-assistant-message-C5-Ds8mA.js} +18 -1
  18. package/dist/{event-projector-usage-e5huIQWu.js → event-projector-usage-D3PHFFXh.js} +18 -18
  19. package/dist/harness-DVfUQBlQ.js +248 -0
  20. package/dist/harness.js +2 -226
  21. package/dist/index.js +405 -299
  22. package/dist/{isolated-completion-C58NbL40.js → isolated-completion-Cbbx_5Ed.js} +4 -4
  23. package/dist/launch-args-sXOAg0SX.js +84 -0
  24. package/dist/managed-binary-ZkGodW19.js +248 -0
  25. package/dist/media-understanding-provider.js +2 -2
  26. package/dist/model-catalog-o6Cgjoss.js +101 -0
  27. package/dist/{models-BFlpn1Ex.js → models-DgFWSuxA.js} +25 -28
  28. package/dist/{native-subagent-monitor-DyTGmTUx.js → native-subagent-monitor-CwFyoylz.js} +385 -94
  29. package/dist/node-exec-server.runtime-DXrqpw1c.js +195 -0
  30. package/dist/plugin-approval-roundtrip-D80UZiJ_.js +95 -0
  31. package/dist/{plugin-marketplace-discovery-CzrGJdCR.js → plugin-marketplace-discovery-mdmScYOj.js} +60 -55
  32. package/dist/{plugin-metadata-cache-CNJPj4_b.js → plugin-metadata-cache-CulOABwu.js} +164 -134
  33. package/dist/{protocol-validators-B4F7L8Rf.js → protocol-validators-Bg5rpNxk.js} +203 -7
  34. package/dist/{rate-limits-DZXmOL8-.js → rate-limits-hFtzt2Up.js} +1 -1
  35. package/dist/{sandbox-guard-Cmwc9eIk.js → request-CCm4LaED.js} +207 -20
  36. package/dist/{run-attempt-P8BdxC1I.js → run-attempt-BwNQDH2u.js} +1506 -836
  37. package/dist/{runtime-artifact-BVSPdd6g.js → runtime-artifact-DeBvleJw.js} +4 -7
  38. package/dist/session-binding-q2WSTVmC.js +947 -0
  39. package/dist/{session-catalog-xwNi_SDM.js → session-catalog-C2Tae4rI.js} +1698 -1346
  40. package/dist/session-catalog-home-id-DAKUrm3C.js +112 -0
  41. package/dist/{session-cli-7hgXZDV7.js → session-cli-BuDjm5Ou.js} +20 -7
  42. package/dist/session-permission-policy-gLm40Vtq.js +160 -0
  43. package/dist/session-retirement-CdkI0bvb.js +90 -0
  44. package/dist/{session-upstream-marker-CrIFX06J.js → session-upstream-marker-Bcy33kam.js} +2 -3
  45. package/dist/{settled-turn-finalizer-BRWBO4MO.js → settled-turn-finalizer-B8JJcxCi.js} +27 -22
  46. package/dist/{shared-client-kIBbGjk4.js → shared-client-kNkljY-R.js} +2023 -607
  47. package/dist/{side-question-9HAL26l9.js → side-question-GwD73tX6.js} +109 -57
  48. package/dist/{thread-lifecycle-Bu1BTDXr.js → thread-lifecycle-Ss-uwnC4.js} +1208 -497
  49. package/dist/{thread-ownership-6kOQHlyC.js → thread-ownership-CeYBqg_4.js} +18 -8
  50. package/dist/{plugin-app-cache-key-C3H2CVp6.js → thread-resume-DF54hagX.js} +64 -6
  51. package/dist/{transcript-mirror-B9gGgnJS.js → transcript-mirror-CkEQIna-.js} +158 -41
  52. package/dist/transport-stdio-C7-s9TLG.js +708 -0
  53. package/dist/{upstream-prompt-provenance-ClRBije0.js → upstream-prompt-provenance-CFmsKwr9.js} +12 -14
  54. package/dist/{upstream-session-fork-CE-_LdnP.js → upstream-session-fork-BACGlOFa.js} +86 -88
  55. package/dist/{usage-CHlV0e-o.js → usage-C2l8Mils.js} +3 -3
  56. package/dist/{web-search-provider.runtime-DRw2Vl42.js → web-search-provider.runtime-B2XgRdFv.js} +3 -3
  57. package/openclaw.plugin.json +50 -2
  58. package/package.json +9 -8
  59. package/dist/app-server-policy-zcBDc1JU.js +0 -49
  60. package/dist/incognito-session-ET_ufDH-.js +0 -2
  61. package/dist/request-BRl5_UfX.js +0 -157
  62. package/dist/session-retirement-DoMMJFKm.js +0 -36
  63. package/dist/thread-resume-CPrJNQVM.js +0 -30
  64. package/dist/transport-stdio-DIImwDVS.js +0 -99
@@ -0,0 +1,58 @@
1
+ import { embeddedAgentLog, formatErrorMessage } from "openclaw/plugin-sdk/agent-harness-runtime";
2
+ import { appendSessionTranscriptMessageByIdentity, publishSessionTranscriptUpdateByIdentity } from "openclaw/plugin-sdk/session-transcript-runtime";
3
+ //#region extensions/codex/src/app-server/context-compaction-activity.ts
4
+ const CONTEXT_COMPACTION_CUSTOM_TYPE = "openclaw.context-compaction";
5
+ async function persistCodexContextCompactionActivity(params) {
6
+ const target = params.sessionTarget;
7
+ if (!target?.sessionId || !target.sessionKey || !target.storePath) return;
8
+ const activityId = `codex-context-compaction:${params.threadId}:${params.turnId}:${params.itemId}`;
9
+ const message = {
10
+ role: "custom",
11
+ customType: CONTEXT_COMPACTION_CUSTOM_TYPE,
12
+ content: "Context compacted",
13
+ display: true,
14
+ excludeFromContext: true,
15
+ details: {
16
+ kind: "context_compaction",
17
+ backend: "codex-app-server",
18
+ threadId: params.threadId,
19
+ turnId: params.turnId,
20
+ itemId: params.itemId,
21
+ ...params.runId ? { runId: params.runId } : {}
22
+ },
23
+ ...params.runId ? { __openclaw: { runId: params.runId } } : {},
24
+ timestamp: params.timestamp,
25
+ idempotencyKey: activityId
26
+ };
27
+ try {
28
+ const appended = await appendSessionTranscriptMessageByIdentity({
29
+ agentId: target.agentId,
30
+ sessionId: target.sessionId,
31
+ sessionKey: target.sessionKey,
32
+ storePath: target.storePath,
33
+ config: params.config,
34
+ cwd: params.cwd,
35
+ eventId: activityId,
36
+ message
37
+ });
38
+ if (!appended?.appended) return;
39
+ await publishSessionTranscriptUpdateByIdentity({
40
+ agentId: target.agentId,
41
+ sessionId: target.sessionId,
42
+ sessionKey: target.sessionKey,
43
+ storePath: target.storePath,
44
+ update: {
45
+ message: appended.message,
46
+ messageId: appended.messageId,
47
+ ...params.runId ? { runId: params.runId } : {}
48
+ }
49
+ });
50
+ } catch (error) {
51
+ embeddedAgentLog.warn("failed to persist codex context compaction activity", {
52
+ error: formatErrorMessage(error),
53
+ itemId: params.itemId
54
+ });
55
+ }
56
+ }
57
+ //#endregion
58
+ export { persistCodexContextCompactionActivity as t };
@@ -1,12 +1,113 @@
1
1
  import { n as CODEX_APP_SERVER_BINDING_NAMESPACE, t as CODEX_APP_SERVER_BINDING_MAX_ENTRIES } from "./session-binding-meta-B7aEMU7g.js";
2
- import { asNullableRecord, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
2
+ import { asNullableRecord, asOptionalRecord, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  import fs from "node:fs/promises";
4
4
  import path from "node:path";
5
+ import { createHash } from "node:crypto";
5
6
  import { isDeepStrictEqual } from "node:util";
6
- import { canonicalPathFromExistingAncestor, isPathInside, pathExists } from "openclaw/plugin-sdk/security-runtime";
7
- import { listAgentIds, resolveAgentDir, resolveSessionAgentIds } from "openclaw/plugin-sdk/agent-scope-runtime";
7
+ import { pathExists } from "openclaw/plugin-sdk/security-runtime";
8
+ import { listAgentIds, resolveAgentDir, resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
9
+ import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
10
+ import { canonicalPathFromExistingAncestor, isPathInside } from "openclaw/plugin-sdk/file-access-runtime";
11
+ import { setImmediate } from "node:timers/promises";
8
12
  import { withFileLock } from "openclaw/plugin-sdk/file-lock";
9
13
  import { archiveLegacyStateSource, legacyStateFileExists } from "openclaw/plugin-sdk/runtime-doctor-migrations";
14
+ //#region extensions/codex/src/migration/session-binding-orphans.ts
15
+ const PAGE_SIZE = 512;
16
+ const KEY_PREFIXES = ["session-key:", "session:"];
17
+ function readBindingCandidate(row, prefix) {
18
+ const identity = /^([a-z0-9][a-z0-9_-]{0,63}):(.+)$/u.exec(row.key.slice(prefix.length));
19
+ if (!identity) return;
20
+ const agentId = identity[1];
21
+ const keyIdentity = identity[2];
22
+ const stored = asOptionalRecord(row.value);
23
+ const sessionId = typeof stored?.sessionId === "string" ? stored.sessionId.trim() : "";
24
+ const stable = prefix === "session-key:";
25
+ if (!stored || stored.version !== 1 || !sessionId || (stable ? !/^[A-Za-z0-9_-]{43}$/u.test(keyIdentity) : sessionId !== keyIdentity)) return;
26
+ if (stored.state === "cleared") {
27
+ if (stored.binding !== void 0 || stored.retired !== void 0 && stored.retired !== true) return;
28
+ } else if (stored.state === "active") {
29
+ const binding = asOptionalRecord(stored.binding);
30
+ if (!binding || typeof binding.threadId !== "string" || !binding.threadId.trim() || typeof binding.cwd !== "string" || binding.connectionScope !== void 0 || binding.supervisionSourceThreadId !== void 0 || binding.pendingSupervisionBranch !== void 0 || stored.retired !== void 0) return;
31
+ } else return;
32
+ if (stored.lease !== void 0) {
33
+ const lease = asOptionalRecord(stored.lease);
34
+ if (!lease || typeof lease.token !== "string" || !lease.token.trim() || typeof lease.expiresAt !== "number" || !Number.isFinite(lease.expiresAt) || lease.expiresAt > Date.now()) return;
35
+ }
36
+ return {
37
+ row,
38
+ agentId,
39
+ sessionId,
40
+ stable
41
+ };
42
+ }
43
+ async function* iterateOrphanBindingPages({ context }) {
44
+ const readPage = context.readPluginStateEntriesInKeyRange;
45
+ const readEvidence = context.readSessionIdentityEvidenceBatch;
46
+ if (!readPage || !readEvidence) return;
47
+ for (const prefix of KEY_PREFIXES) {
48
+ let after;
49
+ while (true) {
50
+ const rows = readPage(CODEX_APP_SERVER_BINDING_NAMESPACE, {
51
+ prefix,
52
+ ...after ? { after } : {},
53
+ limit: PAGE_SIZE
54
+ });
55
+ if (rows.length === 0) break;
56
+ after = rows.at(-1)?.key;
57
+ const candidates = rows.flatMap((row) => {
58
+ const candidate = readBindingCandidate(row, prefix);
59
+ return candidate ? [candidate] : [];
60
+ });
61
+ if (candidates.length > 0) {
62
+ const identities = new Map(candidates.map(({ agentId, sessionId }) => [`${agentId}\0${sessionId}`, {
63
+ agentId,
64
+ sessionId
65
+ }]));
66
+ const evidence = new Map((await readEvidence([...identities.values()])).map((owner) => [`${owner.agentId}\0${owner.sessionId}`, owner]));
67
+ const stale = candidates.filter(({ row, agentId, sessionId, stable }) => {
68
+ const owner = evidence.get(`${agentId}\0${sessionId}`);
69
+ if (!owner || owner.state === "unknown") return false;
70
+ if (owner.state !== "current") return true;
71
+ if (!stable) return false;
72
+ const digest = createHash("sha256").update(owner.sessionKey).digest("base64url");
73
+ return row.key !== `session-key:${agentId}:${digest}`;
74
+ }).map(({ row }) => row);
75
+ if (stale.length > 0) yield stale;
76
+ }
77
+ if (rows.length < PAGE_SIZE) break;
78
+ await setImmediate();
79
+ }
80
+ }
81
+ }
82
+ const codexOrphanedSessionBindingMigration = {
83
+ id: "codex-app-server-orphaned-session-bindings",
84
+ label: "Codex app-server orphaned session bindings",
85
+ doctorOnly: true,
86
+ phase: "after-session-repair",
87
+ async detectLegacyState(params) {
88
+ for await (const _ of iterateOrphanBindingPages(params)) return { preview: ["- Codex app-server bindings: remove orphaned session ownership"] };
89
+ return null;
90
+ },
91
+ async migrateLegacyState(params) {
92
+ const remove = params.context.deletePluginStateEntriesIfUnchanged;
93
+ if (!remove) return {
94
+ changes: [],
95
+ warnings: ["Codex session binding repair requires locked SQLite maintenance ownership"]
96
+ };
97
+ let deleted = 0;
98
+ let changed = 0;
99
+ for await (const rows of iterateOrphanBindingPages(params)) {
100
+ const result = remove(CODEX_APP_SERVER_BINDING_NAMESPACE, rows);
101
+ deleted += result.deleted;
102
+ changed += result.changed;
103
+ }
104
+ return {
105
+ changes: deleted > 0 ? [`Removed ${deleted} orphaned Codex app-server session binding(s)`] : [],
106
+ warnings: changed > 0 ? [`Preserved ${changed} Codex app-server session binding(s) changed during repair`] : []
107
+ };
108
+ }
109
+ };
110
+ //#endregion
10
111
  //#region extensions/codex/src/migration/session-binding-sidecars.ts
11
112
  const LEGACY_BINDING_SUFFIX = ".codex-app-server.json";
12
113
  const CODEX_AGENT_HARNESS_ID = "codex";
@@ -41,7 +142,7 @@ async function collectSessionSurfaces(params) {
41
142
  const agentsDir = path.join(params.stateDir, "agents");
42
143
  for (const entry of await readDirectoryEntries(agentsDir)) {
43
144
  if (!entry.isDirectory() || entry.isSymbolicLink()) continue;
44
- const agentId = resolveSessionAgentIds({
145
+ const agentId = resolveSessionAgentIdsStrict({
45
146
  agentId: entry.name,
46
147
  config: params.config
47
148
  }).sessionAgentId;
@@ -242,24 +343,23 @@ async function resolveLegacySessionFileLocator(sessionsDir, entry, sessionId) {
242
343
  if (!isPathInside(canonicalBase, canonicalCandidate)) throw new Error("legacy session file locator escapes its session directory");
243
344
  return candidate;
244
345
  }
245
- function resolveLegacyBindingOwnerAgentId(params) {
246
- if (params.sessionKey.trim().toLowerCase().startsWith("agent:")) return resolveSessionAgentIds({
346
+ function tryResolveLegacyBindingOwnerAgentId(params) {
347
+ if (params.sessionKey.trim().toLowerCase().startsWith("agent:")) return resolveSessionAgentIdsStrict({
247
348
  sessionKey: params.sessionKey,
248
349
  config: params.config
249
350
  }).sessionAgentId;
250
351
  const storeAgentId = params.storeAgentIds?.size === 1 ? [...params.storeAgentIds][0] : void 0;
251
- return resolveSessionAgentIds({
252
- sessionKey: params.sessionKey,
253
- config: params.config,
254
- ...storeAgentId ? { agentId: storeAgentId } : {}
255
- }).sessionAgentId;
256
- }
257
- function tryResolveLegacyBindingOwnerAgentId(params) {
258
- try {
259
- return resolveLegacyBindingOwnerAgentId(params);
352
+ const configuredAgentId = params.config.agents?.defaults?.systemAgent?.agentId?.trim();
353
+ const systemAgentId = !storeAgentId && configuredAgentId ? normalizeAgentId(configuredAgentId) : void 0;
354
+ const fallbackAgentIds = systemAgentId && listAgentIds(params.config).includes(systemAgentId) ? [void 0, systemAgentId] : [void 0];
355
+ for (const fallbackAgentId of fallbackAgentIds) try {
356
+ return resolveSessionAgentIdsStrict({
357
+ sessionKey: params.sessionKey,
358
+ config: params.config,
359
+ ...storeAgentId ? { agentId: storeAgentId } : fallbackAgentId ? { fallbackAgentId } : {}
360
+ }).sessionAgentId;
260
361
  } catch (error) {
261
- if (error.code === "AGENT_SELECTION_REQUIRED") return;
262
- throw error;
362
+ if (error.code !== "AGENT_SELECTION_REQUIRED") throw error;
263
363
  }
264
364
  }
265
365
  function copyBindingForSession(stored, sessionId) {
@@ -292,7 +392,7 @@ async function migrateSource(source, candidates, params, store) {
292
392
  return await withFileLock(source.sidecarPath, LEGACY_BINDING_LOCK_OPTIONS, async () => {
293
393
  const [contents, stat] = await Promise.all([fs.readFile(source.sidecarPath, "utf8"), fs.stat(source.sidecarPath)]);
294
394
  const raw = JSON.parse(contents);
295
- const [{ bindingStoreKey, createStoredCodexAppServerBinding, normalizeStoredCodexAppServerBindingFingerprints, readStoredCodexAppServerBinding }, { legacyCodexConversationBindingId }] = await Promise.all([import("./session-binding-DPxIvMgE.js").then((n) => n.f), import("./conversation-binding-data-CW2GuupV.js").then((n) => n.t)]);
395
+ const [{ bindingStoreKey, createStoredCodexAppServerBinding, normalizeStoredCodexAppServerBindingFingerprints, readStoredCodexAppServerBinding }, { legacyCodexConversationBindingId }] = await Promise.all([import("./session-binding-q2WSTVmC.js").then((n) => n.f), import("./conversation-binding-data-CW2GuupV.js").then((n) => n.t)]);
296
396
  const agentId = owner?.agentId ?? (source.agentIds.size === 1 ? [...source.agentIds][0] : void 0);
297
397
  const baseStored = createStoredCodexAppServerBinding(raw, {
298
398
  now: stat.mtime.toISOString(),
@@ -477,7 +577,7 @@ function isSafeLegacySessionId(value) {
477
577
  const trimmed = value.trim();
478
578
  return trimmed.length > 0 && trimmed.length <= 255 && /^[A-Za-z0-9][A-Za-z0-9._:@-]*$/.test(trimmed);
479
579
  }
480
- const stateMigrations = [{
580
+ const stateMigrations$1 = [{
481
581
  id: "codex-app-server-sidecars-to-plugin-state",
482
582
  label: "Codex app-server thread bindings",
483
583
  async detectLegacyState(params) {
@@ -536,8 +636,9 @@ function hasLegacyPluginDestructivePolicy(value) {
536
636
  const plugins = asNullableRecord(codexPlugins.plugins);
537
637
  return Object.values(plugins ?? {}).some((plugin) => asNullableRecord(plugin)?.allow_destructive_actions === "on-request");
538
638
  }
539
- function hasRetiredOnFailureApprovalPolicy(value) {
540
- return asNullableRecord(value)?.approvalPolicy === "on-failure";
639
+ function hasRetiredApprovalPolicy(value) {
640
+ const approvalPolicy = asNullableRecord(value)?.approvalPolicy;
641
+ return approvalPolicy === "on-failure" || approvalPolicy === "untrusted";
541
642
  }
542
643
  /** Legacy Codex config keys that doctor should report or repair. */
543
644
  const legacyConfigRules = [
@@ -570,8 +671,8 @@ const legacyConfigRules = [
570
671
  "config",
571
672
  "appServer"
572
673
  ],
573
- message: "plugins.entries.codex.config.appServer.approvalPolicy=\"on-failure\" was retired by Codex 0.143; use \"on-request\". Run \"openclaw doctor --fix\".",
574
- match: hasRetiredOnFailureApprovalPolicy
674
+ message: "plugins.entries.codex.config.appServer.approvalPolicy values \"on-failure\" and \"untrusted\" are retired; use \"on-request\". Run \"openclaw doctor --fix\".",
675
+ match: hasRetiredApprovalPolicy
575
676
  }
576
677
  ];
577
678
  /**
@@ -583,7 +684,7 @@ function normalizeCompatibilityConfig({ cfg }) {
583
684
  const rawAppServer = asNullableRecord(rawPluginConfig?.appServer);
584
685
  const shouldRemoveDynamicToolsProfile = rawPluginConfig !== null && hasRetiredDynamicToolsProfile(rawPluginConfig);
585
686
  const shouldRewriteDestructivePolicy = hasLegacyPluginDestructivePolicy(rawCodexPlugins);
586
- const shouldRewriteApprovalPolicy = hasRetiredOnFailureApprovalPolicy(rawAppServer);
687
+ const shouldRewriteApprovalPolicy = hasRetiredApprovalPolicy(rawAppServer);
587
688
  if (!rawPluginConfig || !shouldRemoveDynamicToolsProfile && !shouldRewriteDestructivePolicy && !shouldRewriteApprovalPolicy) return {
588
689
  config: cfg,
589
690
  changes: []
@@ -611,13 +712,14 @@ function normalizeCompatibilityConfig({ cfg }) {
611
712
  }
612
713
  if (shouldRewriteApprovalPolicy) {
613
714
  const nextAppServer = asNullableRecord(nextPluginConfig.appServer);
614
- if (nextAppServer?.approvalPolicy === "on-failure") nextAppServer.approvalPolicy = "on-request";
615
- changes.push("Renamed plugins.entries.codex.config.appServer.approvalPolicy=\"on-failure\" to \"on-request\".");
715
+ if (nextAppServer?.approvalPolicy === "on-failure" || nextAppServer?.approvalPolicy === "untrusted") nextAppServer.approvalPolicy = "on-request";
716
+ changes.push("Renamed retired plugins.entries.codex.config.appServer.approvalPolicy to \"on-request\".");
616
717
  }
617
718
  return {
618
719
  config: nextConfig,
619
720
  changes
620
721
  };
621
722
  }
723
+ const stateMigrations = [...stateMigrations$1, codexOrphanedSessionBindingMigration];
622
724
  //#endregion
623
725
  export { legacyConfigRules, normalizeCompatibilityConfig, stateMigrations };