@openclaw/codex 2026.7.2-beta.3 → 2026.7.2-beta.5

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 (43) hide show
  1. package/dist/{app-server-policy-DUMF2Xyr.js → app-server-policy-BmDgseo_.js} +1 -1
  2. package/dist/attempt-client-cleanup-Ia52yRWc.js +127 -0
  3. package/dist/{attempt-notifications-Ecjyzufe.js → attempt-notifications-CMR2_fmR.js} +1 -1
  4. package/dist/{media-understanding-provider-IPNNQre6.js → bounded-turn-FEbUXoYT.js} +71 -188
  5. package/dist/capabilities-BHRSI6Cn.js +36 -0
  6. package/dist/cli-metadata.js +1 -1
  7. package/dist/{command-formatters-NCTL7A2q.js → command-formatters-ico4ZFnk.js} +3 -37
  8. package/dist/{command-handlers-DtFbZiba.js → command-handlers-CRmnwI2N.js} +1233 -1221
  9. package/dist/{compact-Kgy26gIM.js → compact-dEN49UH6.js} +8 -7
  10. package/dist/{computer-use-C7x4ZaqR.js → computer-use-BjGylO-E.js} +16 -6
  11. package/dist/{conversation-control-B0s3aIjT.js → conversation-control-DE7d9DOj.js} +6 -5
  12. package/dist/doctor-contract-api.js +24 -86
  13. package/dist/{dynamic-tools-D_vSVmv9.js → dynamic-tools-LIt9ojep.js} +135 -2696
  14. package/dist/event-projector-assistant-message-DTgnPPVF.js +101 -0
  15. package/dist/event-projector-usage-tvgb1NCX.js +69 -0
  16. package/dist/harness.js +31 -11
  17. package/dist/incognito-session-ET_ufDH-.js +2 -0
  18. package/dist/index.js +250 -275
  19. package/dist/media-understanding-provider.js +173 -1
  20. package/dist/{models-DD5zBdX5.js → models-BA01NEez.js} +2 -2
  21. package/dist/{notification-correlation-C8DVQ_Bq.js → notification-correlation-Bj_Ak_jI.js} +3 -3
  22. package/dist/{plugin-app-cache-key-DJbhLYSK.js → plugin-app-cache-key-DSXX-rXO.js} +5 -5
  23. package/dist/{transcript-mirror-D9rTxx2P.js → protocol-validators-Dm4eXZmt.js} +335 -595
  24. package/dist/{rate-limits-CqhWQ2R9.js → rate-limits-S_PXs0ul.js} +1 -1
  25. package/dist/realtime-voice-api-BPcA1uN9.js +494 -0
  26. package/dist/realtime-voice-api.js +2 -0
  27. package/dist/{request-9yf9pZjf.js → request-CXpPennK.js} +1 -1
  28. package/dist/{run-attempt-BIoO8ISr.js → run-attempt-C5GTPJOE.js} +3111 -387
  29. package/dist/{session-binding-Bmt20HfB.js → session-binding-DlVQ-Pxs.js} +957 -890
  30. package/dist/{session-catalog-CA7R-hX2.js → session-catalog-CP2oCcEb.js} +98 -87
  31. package/dist/{session-cli-Bxk3-Wqz.js → session-cli-CqZ0Fp2a.js} +2 -2
  32. package/dist/session-upstream-marker-QE-m5QFG.js +82 -0
  33. package/dist/settled-turn-finalizer-CA_2QXIE.js +303 -0
  34. package/dist/{shared-client-CSXLtCLE.js → shared-client-BVKE40c-.js} +1870 -1694
  35. package/dist/{side-question-DtzquMOb.js → side-question-CO12sHxo.js} +24 -16
  36. package/dist/{thread-lifecycle-CQ_9mAa1.js → thread-lifecycle-DRg_FdzC.js} +127 -153
  37. package/dist/transcript-mirror-uKA-A4tB.js +550 -0
  38. package/dist/upstream-session-fork-_Vrz4WJr.js +320 -0
  39. package/dist/{usage-CuPpFgTc.js → usage-UpVbdX5G.js} +3 -3
  40. package/dist/{web-search-provider.runtime-_x5XTeqh.js → web-search-provider.runtime-CaQMYDbp.js} +3 -3
  41. package/package.json +7 -8
  42. package/npm-shrinkwrap.json +0 -202
  43. package/dist/{auth-binding-C1czuHPA.js → auth-binding-B4FfbcCg.js} +1 -1
@@ -1,26 +1,31 @@
1
- import { J as CODEX_INTERACTIVE_THREAD_SOURCE_KINDS, R as CodexAppServerRpcError, Z as isJsonObject, a as getLeasedSharedCodexAppServerClient, c as releaseLeasedSharedCodexAppServerClient, m as withTimeout, q as CODEX_INTERACTIVE_CUSTOM_THREAD_SOURCES } from "./shared-client-CSXLtCLE.js";
2
- import { E as resolveCodexSupervisionAppServerRuntimeOptions, b as resolveCodexAppServerRuntimeOptions, c as sessionBindingIdentity, s as reclaimCurrentCodexSessionGeneration } from "./session-binding-Bmt20HfB.js";
3
- import { r as importCodexThreadHistoryToTranscript } from "./transcript-mirror-D9rTxx2P.js";
4
- import { n as listCodexAppServerModels } from "./models-DD5zBdX5.js";
5
- import { t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-DJbhLYSK.js";
6
- import { d as CODEX_CONTROL_METHODS, f as describeControlFailure, r as formatCodexDisplayText } from "./command-formatters-NCTL7A2q.js";
1
+ import { E as resolveCodexAppServerClientInstanceId, L as CODEX_INTERACTIVE_CUSTOM_THREAD_SOURCES, R as CODEX_INTERACTIVE_THREAD_SOURCE_KINDS, V as isJsonObject, _ as CodexAppServerRpcError, a as getLeasedSharedCodexAppServerClient, h as withTimeout, l as releaseLeasedSharedCodexAppServerClient } from "./shared-client-BVKE40c-.js";
2
+ import { c as reclaimCurrentCodexSessionGeneration, g as resolveCodexSupervisionAppServerRuntimeOptions, l as sessionBindingIdentity, p as resolveCodexAppServerRuntimeOptions } from "./session-binding-DlVQ-Pxs.js";
3
+ import { t as assertCodexThreadForkParams } from "./protocol-validators-Dm4eXZmt.js";
4
+ import { n as listCodexAppServerModels } from "./models-BA01NEez.js";
5
+ import { t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-DSXX-rXO.js";
6
+ import { r as importCodexThreadHistoryToTranscript } from "./transcript-mirror-uKA-A4tB.js";
7
+ import { n as describeControlFailure, t as CODEX_CONTROL_METHODS } from "./capabilities-BHRSI6Cn.js";
8
+ import { r as formatCodexDisplayText } from "./command-formatters-ico4ZFnk.js";
7
9
  import { n as createCodexCliNodeConversationBindingData } from "./conversation-binding-data-BHRpYbX3.js";
8
- import { n as requestCodexAppServerClientJson, r as requestCodexAppServerJson } from "./request-9yf9pZjf.js";
10
+ import { n as requestCodexAppServerClientJson, r as requestCodexAppServerJson } from "./request-CXpPennK.js";
11
+ import { i as createImportedCodexSession, n as codexUpstreamBaseline, r as codexUpstreamContinueResult, t as codexLastTerminalTurnId } from "./session-upstream-marker-QE-m5QFG.js";
9
12
  import fs from "node:fs/promises";
10
13
  import path from "node:path";
11
14
  import { timestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
12
15
  import { resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path";
13
- import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
14
16
  import { createHash } from "node:crypto";
17
+ import { listAgentIds, resolveAllowedModelRef, resolveDefaultAgentDir, resolveDefaultAgentId, resolveDefaultModelForAgent } from "openclaw/plugin-sdk/agent-runtime";
15
18
  import os from "node:os";
16
- import { listAgentIds, resolveDefaultAgentDir, resolveDefaultAgentId } from "openclaw/plugin-sdk/agent-runtime";
17
19
  import { parseAgentSessionKey } from "openclaw/plugin-sdk/routing";
18
20
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
19
21
  import { materializeWindowsSpawnProgram, resolveWindowsSpawnProgram } from "openclaw/plugin-sdk/windows-spawn";
20
- import { spawn } from "node:child_process";
21
22
  import { resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
23
+ import { spawn } from "node:child_process";
24
+ import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
22
25
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
23
26
  import process$1 from "node:process";
27
+ import { listSessionCatalogEntries } from "openclaw/plugin-sdk/session-catalog";
28
+ import { sanitizeTerminalText } from "openclaw/plugin-sdk/text-chunking";
24
29
  import { decodeNodePtyResumeParams, resolveNodeHostExecutable, runNodePtyCommand } from "openclaw/plugin-sdk/node-host";
25
30
  //#region extensions/codex/src/node-cli-sessions.ts
26
31
  const CODEX_CLI_SESSIONS_LIST_COMMAND = "codex.cli.sessions.list";
@@ -611,6 +616,29 @@ async function safeValue(read) {
611
616
  }
612
617
  }
613
618
  //#endregion
619
+ //#region extensions/codex/src/session-catalog-create.ts
620
+ const CODEX_AGENT_RUNTIME_ID = "codex";
621
+ const CODEX_CATALOG_DEFAULT_MODEL_REF = "openai/gpt-5.6-sol";
622
+ function resolveCodexCatalogCreateSession(config, requestedAgentId) {
623
+ if (!config) return;
624
+ const agentId = requestedAgentId ?? resolveDefaultAgentId(config);
625
+ const defaultModel = resolveDefaultModelForAgent({
626
+ cfg: config,
627
+ agentId
628
+ });
629
+ return "error" in resolveAllowedModelRef({
630
+ cfg: config,
631
+ catalog: [],
632
+ raw: CODEX_CATALOG_DEFAULT_MODEL_REF,
633
+ defaultProvider: defaultModel.provider,
634
+ defaultModel: defaultModel.model,
635
+ agentId
636
+ }) ? void 0 : {
637
+ model: CODEX_CATALOG_DEFAULT_MODEL_REF,
638
+ agentRuntime: CODEX_AGENT_RUNTIME_ID
639
+ };
640
+ }
641
+ //#endregion
614
642
  //#region extensions/codex/src/session-catalog-parsing.ts
615
643
  const DEFAULT_PAGE_LIMIT = 50;
616
644
  const CODEX_APP_SERVER_THREADS_CAPABILITY = "codex-app-server-threads";
@@ -624,6 +652,7 @@ const MAX_CURSOR_COUNT = 100;
624
652
  const MAX_HOST_ID_LENGTH = 256;
625
653
  const MAX_CWD_LENGTH = 4096;
626
654
  const MAX_SESSION_NAME_LENGTH = 500;
655
+ const MAX_SESSION_PREVIEW_LENGTH = 500;
627
656
  const MAX_SESSION_KEY_LENGTH = 1024;
628
657
  const MAX_METADATA_LENGTH = 500;
629
658
  const MAX_ACTIVE_FLAGS = 16;
@@ -641,6 +670,10 @@ function boundedCatalogString(value, maxLength, overflow = "omit") {
641
670
  if (normalized.length <= maxLength) return normalized;
642
671
  return overflow === "truncate" ? truncateUtf16Safe(normalized, maxLength) : void 0;
643
672
  }
673
+ function catalogPreview(value) {
674
+ if (typeof value !== "string") return;
675
+ return boundedCatalogString(sanitizeTerminalText(value.replace(/\s+/g, " ")), MAX_SESSION_PREVIEW_LENGTH, "truncate");
676
+ }
644
677
  function normalizeInteractiveThreadSource(source) {
645
678
  if (CODEX_INTERACTIVE_THREAD_SOURCE_KINDS.some((kind) => kind === source) || CODEX_INTERACTIVE_CUSTOM_THREAD_SOURCES.some((kind) => kind === source)) return source;
646
679
  if (isRecord(source) && CODEX_INTERACTIVE_CUSTOM_THREAD_SOURCES.some((kind) => kind === source.custom)) return source.custom;
@@ -661,6 +694,7 @@ function toCatalogSession(thread, archived) {
661
694
  const gitInfo = isRecord(record.gitInfo) ? record.gitInfo : void 0;
662
695
  const sessionId = boundedCatalogString(thread.sessionId, 256);
663
696
  const name = boundedCatalogString(thread.name, MAX_SESSION_NAME_LENGTH, "truncate");
697
+ const fallbackName = name ? void 0 : catalogPreview(thread.preview);
664
698
  const cwd = boundedCatalogString(thread.cwd, MAX_CWD_LENGTH);
665
699
  const modelProvider = boundedCatalogString(record.modelProvider, MAX_METADATA_LENGTH, "truncate");
666
700
  const cliVersion = boundedCatalogString(record.cliVersion, MAX_METADATA_LENGTH, "truncate");
@@ -671,6 +705,7 @@ function toCatalogSession(thread, archived) {
671
705
  archived,
672
706
  ...sessionId ? { sessionId } : {},
673
707
  ...thread.name === null ? { name: null } : name ? { name } : {},
708
+ ...fallbackName ? { fallbackName } : {},
674
709
  ...cwd ? { cwd } : {},
675
710
  ...activeFlags?.length ? { activeFlags } : {},
676
711
  ...typeof thread.createdAt === "number" && Number.isFinite(thread.createdAt) ? { createdAt: thread.createdAt } : {},
@@ -789,12 +824,13 @@ function parseCatalogSession(value, options = {}) {
789
824
  }) : void 0;
790
825
  const sessionId = parseOptionalCatalogString(value.sessionId, "session id", 256);
791
826
  const name = value.name === null ? null : parseOptionalCatalogString(value.name, "session name", MAX_SESSION_NAME_LENGTH);
827
+ const fallbackName = parseOptionalCatalogString(value.fallbackName, "session fallback name", MAX_SESSION_PREVIEW_LENGTH);
792
828
  const cwd = parseOptionalCatalogString(value.cwd, "cwd", MAX_CWD_LENGTH);
793
829
  const source = parseOptionalCatalogString(value.source, "source", MAX_METADATA_LENGTH);
794
830
  const modelProvider = parseOptionalCatalogString(value.modelProvider, "model provider", MAX_METADATA_LENGTH);
795
831
  const cliVersion = parseOptionalCatalogString(value.cliVersion, "CLI version", MAX_METADATA_LENGTH);
796
832
  const gitBranch = parseOptionalCatalogString(value.gitBranch, "Git branch", MAX_METADATA_LENGTH);
797
- const openClawSessionKey = options.allowOpenClawSessionKey ? parseOptionalCatalogString(value.openClawSessionKey, "OpenClaw session key", MAX_SESSION_KEY_LENGTH) : void 0;
833
+ const sessionKey = options.allowSessionKey ? parseOptionalCatalogString(value.sessionKey, "OpenClaw session key", MAX_SESSION_KEY_LENGTH) : void 0;
798
834
  const createdAt = readFiniteNumber(value.createdAt);
799
835
  const updatedAt = readFiniteNumber(value.updatedAt);
800
836
  const recencyAt = value.recencyAt === null ? null : readFiniteNumber(value.recencyAt);
@@ -804,6 +840,7 @@ function parseCatalogSession(value, options = {}) {
804
840
  archived: value.archived,
805
841
  ...sessionId !== void 0 ? { sessionId } : {},
806
842
  ...name !== void 0 ? { name } : {},
843
+ ...fallbackName !== void 0 ? { fallbackName } : {},
807
844
  ...cwd !== void 0 ? { cwd } : {},
808
845
  ...activeFlags && activeFlags.length > 0 ? { activeFlags } : {},
809
846
  ...createdAt !== void 0 ? { createdAt } : {},
@@ -813,7 +850,7 @@ function parseCatalogSession(value, options = {}) {
813
850
  ...modelProvider !== void 0 ? { modelProvider } : {},
814
851
  ...cliVersion !== void 0 ? { cliVersion } : {},
815
852
  ...gitBranch !== void 0 ? { gitBranch } : {},
816
- ...openClawSessionKey !== void 0 ? { openClawSessionKey } : {}
853
+ ...sessionKey !== void 0 ? { sessionKey } : {}
817
854
  };
818
855
  }
819
856
  function parseCatalogPage(value, options = {}) {
@@ -930,7 +967,11 @@ function readNodeSessionMarker(entry) {
930
967
  }
931
968
  function listNodeAdoptedSessionEntries(params) {
932
969
  const adopted = /* @__PURE__ */ new Map();
933
- for (const agentId of listSupervisionAgentIds(params.config ?? {})) for (const { entry, sessionKey } of params.runtime.agent.session.listSessionEntries({ agentId })) {
970
+ for (const { agentId, entry, sessionKey } of listSessionCatalogEntries({
971
+ config: params.config ?? {},
972
+ runtime: params.runtime,
973
+ sessionEntries: params.sessionEntries
974
+ })) {
934
975
  const marker = readNodeSessionMarker(entry);
935
976
  const sessionId = entry.sessionId?.trim();
936
977
  if (!marker || marker.initializing === true && params.includeInitializing !== true || entry.initializationPending === true || entry.agentHarnessId !== "codex" || entry.modelSelectionLocked !== true || !sessionId || adoptionSessionKeyRest(sessionKey) !== nodeAdoptionSessionKey(marker.sourceHostId, marker.sourceThreadId) || marker.sourceHostId !== `node:${marker.nodeId}`) continue;
@@ -1117,7 +1158,7 @@ async function listPairedNode(params) {
1117
1158
  ...page,
1118
1159
  sessions: page.sessions.map((session) => {
1119
1160
  const adopted = params.adoptedSessions.get(adoptedSourceKey(hostId, session.threadId));
1120
- return adopted ? Object.assign({}, session, { openClawSessionKey: adopted.key }) : session;
1161
+ return adopted ? Object.assign({}, session, { sessionKey: adopted.key }) : session;
1121
1162
  })
1122
1163
  };
1123
1164
  }).catch((error) => ({
@@ -1574,56 +1615,12 @@ function createChecker(params) {
1574
1615
  });
1575
1616
  }
1576
1617
  //#endregion
1577
- //#region extensions/codex/src/session-upstream-marker.ts
1578
- function lastIdentifiableTurn(thread, normalizeTurnId) {
1579
- for (let index = (thread.turns?.length ?? 0) - 1; index >= 0; index -= 1) {
1580
- const turn = thread.turns?.[index];
1581
- const turnId = normalizeTurnId(turn?.id);
1582
- if (turn && turnId) return {
1583
- ...turn,
1584
- id: turnId
1585
- };
1586
- }
1587
- }
1588
- function codexUpstreamBaseline(thread, normalizeTurnId) {
1589
- const turn = lastIdentifiableTurn(thread, normalizeTurnId);
1590
- return {
1591
- turnId: turn?.id ?? null,
1592
- userMessageCount: turn?.items.filter((item) => item.type === "userMessage").length ?? 0
1593
- };
1594
- }
1595
- function codexLastTerminalTurnId(thread, normalizeTurnId) {
1596
- for (let index = (thread.turns?.length ?? 0) - 1; index >= 0; index -= 1) {
1597
- const turn = thread.turns?.[index];
1598
- const turnId = normalizeTurnId(turn?.id);
1599
- if (!turn || !turnId) continue;
1600
- if (turn.status === "completed" || turn.status === "interrupted" || turn.status === "failed") return turnId;
1601
- }
1602
- }
1603
- /** Build the upstream link seed for a continued Codex session, if a baseline exists. */
1604
- function codexUpstreamContinueResult(sessionKey, threadId, baseline) {
1605
- if (!baseline) return { sessionKey };
1606
- return {
1607
- sessionKey,
1608
- upstream: {
1609
- kind: "codex-app-server",
1610
- ref: {
1611
- connectionFingerprint: baseline.connectionFingerprint,
1612
- threadId
1613
- },
1614
- marker: {
1615
- turnId: baseline.turnId,
1616
- userMessageCount: baseline.userMessageCount
1617
- }
1618
- }
1619
- };
1620
- }
1621
- //#endregion
1622
1618
  //#region extensions/codex/src/session-catalog.ts
1623
1619
  const boundCatalogSessionId = (value) => boundedCatalogString(value, 256);
1624
1620
  const CODEX_SUPERVISION_SESSION_KEY_PREFIX = "harness:codex:supervision:";
1625
1621
  function createCodexSessionCatalogControlFromRequests(params) {
1626
1622
  return {
1623
+ ...params.clientId ? { clientId: params.clientId } : {},
1627
1624
  ...params.connectionFingerprint ? { connectionFingerprint: params.connectionFingerprint } : {},
1628
1625
  withPinnedConnection: params.withPinnedConnection,
1629
1626
  async listPage(pageParams) {
@@ -1678,6 +1675,9 @@ function createCodexSessionCatalogControlFromRequests(params) {
1678
1675
  async listTurnPage(listParams) {
1679
1676
  return await params.createRequestSnapshot().listThreadTurns(listParams);
1680
1677
  },
1678
+ async forkThread(forkParams) {
1679
+ return await params.createRequestSnapshot().forkThread(forkParams);
1680
+ },
1681
1681
  async archiveThread(threadId) {
1682
1682
  await params.createRequestSnapshot().archiveThread(threadId);
1683
1683
  }
@@ -1705,6 +1705,7 @@ function createCodexSessionCatalogControl(params) {
1705
1705
  includeTurns
1706
1706
  }, requestOptions)).thread,
1707
1707
  listThreadTurns: async (listParams) => await codexControlRequest(pluginConfig, CODEX_CONTROL_METHODS.listThreadTurns, listParams, requestOptions),
1708
+ forkThread: async (forkParams) => await codexControlRequest(pluginConfig, CODEX_CONTROL_METHODS.forkThread, assertCodexThreadForkParams(forkParams), requestOptions),
1708
1709
  archiveThread: async (threadId) => {
1709
1710
  await codexControlRequest(pluginConfig, CODEX_CONTROL_METHODS.archiveThread, { threadId }, requestOptions);
1710
1711
  }
@@ -1745,6 +1746,13 @@ function createCodexSessionCatalogControl(params) {
1745
1746
  config: runtimeConfig,
1746
1747
  timeoutMs: runtime.requestTimeoutMs
1747
1748
  }),
1749
+ forkThread: async (forkParams) => await requestCodexAppServerClientJson({
1750
+ client,
1751
+ method: CODEX_CONTROL_METHODS.forkThread,
1752
+ requestParams: assertCodexThreadForkParams(forkParams),
1753
+ config: runtimeConfig,
1754
+ timeoutMs: runtime.requestTimeoutMs
1755
+ }),
1748
1756
  archiveThread: async (threadId) => {
1749
1757
  await requestCodexAppServerClientJson({
1750
1758
  client,
@@ -1756,6 +1764,7 @@ function createCodexSessionCatalogControl(params) {
1756
1764
  }
1757
1765
  };
1758
1766
  const pinnedControl = createCodexSessionCatalogControlFromRequests({
1767
+ clientId: resolveCodexAppServerClientInstanceId(client),
1759
1768
  connectionFingerprint: buildCodexAppServerConnectionFingerprint(runtime, resolveDefaultAgentDir(runtimeConfig ?? {})),
1760
1769
  createRequestSnapshot: () => requests,
1761
1770
  now,
@@ -1782,7 +1791,8 @@ async function listGatewayHost(params) {
1782
1791
  const adoptedSessions = await listAdoptedSessionEntries({
1783
1792
  bindingStore: params.bindingStore,
1784
1793
  config: params.config,
1785
- runtime: params.runtime
1794
+ runtime: params.runtime,
1795
+ sessionEntries: params.sessionEntries
1786
1796
  });
1787
1797
  return {
1788
1798
  hostId: CODEX_LOCAL_SESSION_HOST_ID,
@@ -1792,7 +1802,7 @@ async function listGatewayHost(params) {
1792
1802
  ...page,
1793
1803
  sessions: page.sessions.map((session) => {
1794
1804
  const adopted = adoptedSessions.get(session.threadId);
1795
- return adopted ? Object.assign({}, session, { openClawSessionKey: adopted.key }) : session;
1805
+ return adopted ? Object.assign({}, session, { sessionKey: adopted.key }) : session;
1796
1806
  })
1797
1807
  };
1798
1808
  } catch (error) {
@@ -1815,13 +1825,14 @@ async function listCodexSessionCatalog(params) {
1815
1825
  config: params.config,
1816
1826
  control: params.control,
1817
1827
  query,
1818
- runtime: params.runtime
1828
+ runtime: params.runtime,
1829
+ sessionEntries: params.sessionEntries
1819
1830
  })] : [];
1820
1831
  for (const host of localHosts) if (params.onHost) host.then(params.onHost).catch(() => void 0);
1821
1832
  if (!(!requestedHostIds || query.hostIds?.some((hostId) => hostId.startsWith("node:")))) return { hosts: await Promise.all(localHosts) };
1822
1833
  let nodes;
1823
1834
  try {
1824
- nodes = (await params.runtime.nodes.list()).nodes.filter((node) => node.commands?.includes("codex.appServer.threads.list.v1") && (!requestedHostIds || requestedHostIds.has(`node:${node.nodeId}`))).slice(0, 100 - localHosts.length);
1835
+ nodes = (await (params.listNodes?.() ?? params.runtime.nodes.list())).nodes.filter((node) => node.commands?.includes("codex.appServer.threads.list.v1") && (!requestedHostIds || requestedHostIds.has(`node:${node.nodeId}`))).slice(0, 100 - localHosts.length);
1825
1836
  } catch (error) {
1826
1837
  const registryHost = {
1827
1838
  hostId: "node:registry",
@@ -1836,7 +1847,8 @@ async function listCodexSessionCatalog(params) {
1836
1847
  }
1837
1848
  const adoptedNodeSessions = listNodeAdoptedSessionEntries({
1838
1849
  config: params.config,
1839
- runtime: params.runtime
1850
+ runtime: params.runtime,
1851
+ sessionEntries: params.sessionEntries
1840
1852
  });
1841
1853
  const nodeHosts = nodes.toSorted(compareNodeLabels).map(async (node) => {
1842
1854
  const host = await listPairedNode({
@@ -1973,7 +1985,11 @@ function isAdoptionSessionKeyForThread(sessionKey, threadId) {
1973
1985
  }
1974
1986
  async function listAdoptedSessionEntries(params) {
1975
1987
  const adopted = /* @__PURE__ */ new Map();
1976
- for (const agentId of listSupervisionAgentIds(params.config ?? {})) for (const { entry, sessionKey } of params.runtime.agent.session.listSessionEntries({ agentId })) {
1988
+ for (const { agentId, entry, sessionKey } of listSessionCatalogEntries({
1989
+ config: params.config ?? {},
1990
+ runtime: params.runtime,
1991
+ sessionEntries: params.sessionEntries
1992
+ })) {
1977
1993
  const sessionKeyRest = adoptionSessionKeyRest(sessionKey);
1978
1994
  if (!sessionKeyRest.startsWith(CODEX_SUPERVISION_SESSION_KEY_PREFIX) || entry.initializationPending === true || entry.agentHarnessId !== "codex" || entry.modelSelectionLocked !== true) continue;
1979
1995
  const sessionId = entry.sessionId?.trim();
@@ -2087,17 +2103,17 @@ async function createOrReuseAdoptedSession(params) {
2087
2103
  let createdBindingIdentity;
2088
2104
  let createdPendingBinding;
2089
2105
  try {
2090
- const label = params.sourceThread.name?.trim() || void 0;
2091
2106
  const spawnedCwd = params.sourceThread.cwd?.trim() || void 0;
2092
2107
  const pendingLastTurnId = codexLastTerminalTurnId(params.sourceThread, boundCatalogSessionId);
2093
2108
  const marker = { sourceThreadId: params.sourceThread.id };
2094
- const created = await params.api.runtime.agent.session.createSessionEntry({
2095
- cfg: params.config,
2109
+ const created = await createImportedCodexSession({
2110
+ runtime: params.api.runtime,
2111
+ config: params.config,
2096
2112
  key: adoptionSessionKey(params.sourceThread.id),
2097
2113
  agentId: resolveDefaultAgentId(params.config),
2114
+ thread: params.sourceThread,
2115
+ throughTurnId: pendingLastTurnId ?? null,
2098
2116
  recoverMatchingInitialEntry: true,
2099
- ...label ? { label } : {},
2100
- ...spawnedCwd ? { spawnedCwd } : {},
2101
2117
  initialEntry: {
2102
2118
  agentHarnessId: "codex",
2103
2119
  modelSelectionLocked: true,
@@ -2107,24 +2123,12 @@ async function createOrReuseAdoptedSession(params) {
2107
2123
  modelLocked: true
2108
2124
  } } }
2109
2125
  },
2110
- afterCreate: async (entry) => {
2126
+ afterImport: async (entry) => {
2111
2127
  createdBindingIdentity = sessionBindingIdentity({
2112
2128
  sessionId: entry.sessionId,
2113
2129
  sessionKey: entry.key,
2114
2130
  config: params.config
2115
2131
  });
2116
- const storePath = resolveStorePath(params.config.session?.store, { agentId: entry.agentId });
2117
- await importCodexThreadHistoryToTranscript({
2118
- thread: params.sourceThread,
2119
- throughTurnId: pendingLastTurnId ?? null,
2120
- storePath,
2121
- sessionId: entry.sessionId,
2122
- sessionKey: entry.key,
2123
- agentId: entry.agentId,
2124
- ...spawnedCwd ? { cwd: spawnedCwd } : {},
2125
- modelProvider: params.sourceThread.modelProvider,
2126
- config: params.config
2127
- });
2128
2132
  createdPendingBinding = {
2129
2133
  sourceThreadId: params.sourceThread.id,
2130
2134
  connectionFingerprint: params.connectionFingerprint,
@@ -2251,7 +2255,10 @@ async function continueLocalCodexSession(params) {
2251
2255
  }
2252
2256
  }
2253
2257
  async function assertNoPendingSupervisionBranch(params) {
2254
- const adoptedEntries = listSupervisionAgentIds(params.config).flatMap((agentId) => params.runtime.agent.session.listSessionEntries({ agentId })).filter((candidate) => isAdoptionSessionKeyForThread(candidate.sessionKey, params.threadId));
2258
+ const adoptedEntries = listSupervisionAgentIds(params.config).flatMap((agentId) => params.runtime.agent.session.listSessionEntries({
2259
+ agentId,
2260
+ readOnly: true
2261
+ })).filter((candidate) => isAdoptionSessionKeyForThread(candidate.sessionKey, params.threadId));
2255
2262
  for (const adopted of adoptedEntries) {
2256
2263
  if (adopted.entry.initializationPending === true) throw new CatalogParamsError("Codex session cannot be archived while its OpenClaw branch is initializing");
2257
2264
  const sessionId = adopted.entry.sessionId?.trim();
@@ -2320,9 +2327,10 @@ function toGenericCatalogHost(host, localTerminalAvailable) {
2320
2327
  const canContinue = (local || host.canContinueCodex === true) && continuableStatus && isInteractiveThreadSource(session.source);
2321
2328
  const canArchive = local && continuableStatus && isInteractiveThreadSource(session.source);
2322
2329
  const canOpenTerminal = isInteractiveThreadSource(session.source) && (local ? localTerminalAvailable : host.canOpenTerminalCodex === true);
2330
+ const name = session.name ?? session.fallbackName;
2323
2331
  return {
2324
2332
  threadId: session.threadId,
2325
- ...session.name != null ? { name: session.name } : {},
2333
+ ...name ? { name } : {},
2326
2334
  ...session.cwd ? { cwd: session.cwd } : {},
2327
2335
  status: session.status,
2328
2336
  ...session.createdAt != null ? { createdAt: session.createdAt } : {},
@@ -2333,7 +2341,7 @@ function toGenericCatalogHost(host, localTerminalAvailable) {
2333
2341
  ...session.cliVersion ? { cliVersion: session.cliVersion } : {},
2334
2342
  ...session.gitBranch ? { gitBranch: session.gitBranch } : {},
2335
2343
  archived: session.archived,
2336
- ...session.openClawSessionKey ? { openClawSessionKey: session.openClawSessionKey } : {},
2344
+ ...session.sessionKey ? { sessionKey: session.sessionKey } : {},
2337
2345
  canContinue,
2338
2346
  canArchive,
2339
2347
  canOpenTerminal
@@ -2347,9 +2355,10 @@ function registerCodexSessionCatalog(params) {
2347
2355
  const provider = {
2348
2356
  id: "codex",
2349
2357
  label: "Codex",
2358
+ resolveCreateSession: ({ agentId }) => resolveCodexCatalogCreateSession(params.getRuntimeConfig() ?? params.api.config, agentId),
2350
2359
  list: async (query) => {
2351
2360
  const localTerminalAvailable = resolveLocalCodexTerminalExecutable() !== void 0;
2352
- const { onHost, ...gatewayQuery } = query;
2361
+ const { listNodes, onHost, sessionEntries, ...gatewayQuery } = query;
2353
2362
  const mapHost = (host) => toGenericCatalogHost(host, localTerminalAvailable);
2354
2363
  return (await listCodexSessionCatalog({
2355
2364
  bindingStore: params.bindingStore,
@@ -2357,6 +2366,8 @@ function registerCodexSessionCatalog(params) {
2357
2366
  runtime: params.api.runtime,
2358
2367
  control: params.control,
2359
2368
  query: gatewayQuery,
2369
+ listNodes,
2370
+ sessionEntries,
2360
2371
  ...onHost ? { onHost: (host) => onHost(mapHost(host)) } : {}
2361
2372
  })).hosts.map(mapHost);
2362
2373
  },
@@ -1,6 +1,6 @@
1
- import { a as CODEX_LOCAL_SESSION_HOST_ID } from "./session-catalog-CA7R-hX2.js";
2
- import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
1
+ import { a as CODEX_LOCAL_SESSION_HOST_ID } from "./session-catalog-CP2oCcEb.js";
3
2
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
3
+ import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
4
4
  import { sanitizeTerminalText } from "openclaw/plugin-sdk/text-chunking";
5
5
  import { addGatewayClientOptions, callGatewayFromCli } from "openclaw/plugin-sdk/gateway-runtime";
6
6
  //#region extensions/codex/src/session-cli.ts
@@ -0,0 +1,82 @@
1
+ import { r as importCodexThreadHistoryToTranscript } from "./transcript-mirror-uKA-A4tB.js";
2
+ import { resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
3
+ //#region extensions/codex/src/app-server/session-history-import.ts
4
+ /** Creates a session whose transcript is derived from one verified Codex thread snapshot. */
5
+ async function createImportedCodexSession(params) {
6
+ const label = params.thread.name?.trim() || void 0;
7
+ const spawnedCwd = params.thread.cwd?.trim() || void 0;
8
+ const createParams = {
9
+ cfg: params.config,
10
+ key: params.key,
11
+ agentId: params.agentId,
12
+ ...label ? { label } : {},
13
+ ...spawnedCwd ? { spawnedCwd } : {},
14
+ initialEntry: params.initialEntry,
15
+ afterCreate: async (entry) => {
16
+ const storePath = resolveStorePath(params.config.session?.store, { agentId: entry.agentId });
17
+ await importCodexThreadHistoryToTranscript({
18
+ thread: params.thread,
19
+ throughTurnId: params.throughTurnId,
20
+ storePath,
21
+ sessionId: entry.sessionId,
22
+ sessionKey: entry.key,
23
+ agentId: entry.agentId,
24
+ ...spawnedCwd ? { cwd: spawnedCwd } : {},
25
+ modelProvider: params.thread.modelProvider,
26
+ config: params.config
27
+ });
28
+ return await params.afterImport(entry);
29
+ }
30
+ };
31
+ return params.recoverMatchingInitialEntry ? await params.runtime.agent.session.createSessionEntry({
32
+ ...createParams,
33
+ recoverMatchingInitialEntry: true
34
+ }) : await params.runtime.agent.session.createSessionEntry(createParams);
35
+ }
36
+ //#endregion
37
+ //#region extensions/codex/src/session-upstream-marker.ts
38
+ function lastIdentifiableTurn(thread, normalizeTurnId) {
39
+ for (let index = (thread.turns?.length ?? 0) - 1; index >= 0; index -= 1) {
40
+ const turn = thread.turns?.[index];
41
+ const turnId = normalizeTurnId(turn?.id);
42
+ if (turn && turnId) return {
43
+ ...turn,
44
+ id: turnId
45
+ };
46
+ }
47
+ }
48
+ function codexUpstreamBaseline(thread, normalizeTurnId) {
49
+ const turn = lastIdentifiableTurn(thread, normalizeTurnId);
50
+ return {
51
+ turnId: turn?.id ?? null,
52
+ userMessageCount: turn?.items.filter((item) => item.type === "userMessage").length ?? 0
53
+ };
54
+ }
55
+ function codexLastTerminalTurnId(thread, normalizeTurnId) {
56
+ for (let index = (thread.turns?.length ?? 0) - 1; index >= 0; index -= 1) {
57
+ const turn = thread.turns?.[index];
58
+ const turnId = normalizeTurnId(turn?.id);
59
+ if (!turn || !turnId) continue;
60
+ if (turn.status === "completed" || turn.status === "interrupted" || turn.status === "failed") return turnId;
61
+ }
62
+ }
63
+ /** Build the upstream link seed for a continued Codex session, if a baseline exists. */
64
+ function codexUpstreamContinueResult(sessionKey, threadId, baseline) {
65
+ if (!baseline) return { sessionKey };
66
+ return {
67
+ sessionKey,
68
+ upstream: {
69
+ kind: "codex-app-server",
70
+ ref: {
71
+ connectionFingerprint: baseline.connectionFingerprint,
72
+ threadId
73
+ },
74
+ marker: {
75
+ turnId: baseline.turnId,
76
+ userMessageCount: baseline.userMessageCount
77
+ }
78
+ }
79
+ };
80
+ }
81
+ //#endregion
82
+ export { createImportedCodexSession as i, codexUpstreamBaseline as n, codexUpstreamContinueResult as r, codexLastTerminalTurnId as t };