@openclaw/codex 2026.9.8 → 2026.10.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/.setup/{account-usage-runtime-G348lY1q.mjs → account-usage-runtime-C4GFoef_.mjs} +5 -5
- package/dist/.setup/app-server-policy-Bg4FZw1f.mjs +23 -0
- package/dist/.setup/{apply-Cqb-YoCS.mjs → apply-D02fLpgN.mjs} +48 -39
- package/dist/.setup/attempt-client-cleanup-yLjGwbwT.mjs +155 -0
- package/dist/.setup/{attempt-workspace-context-BJ5Z_olH.mjs → attempt-workspace-context-CbSzT6V2.mjs} +11 -15
- package/dist/.setup/{auth-binding-BLWz7stm.mjs → auth-binding-BoMwpuPN.mjs} +17 -25
- package/dist/.setup/{auth-cache-key-Dnps4W4_.mjs → auth-cache-key-CEd9QlIs.mjs} +244 -82
- package/dist/.setup/{auth-profile-B0okYl2D.mjs → auth-profile-CgHQ8Vot.mjs} +2 -1
- package/dist/.setup/{auth-profile-selection-DFu9e167.mjs → auth-profile-selection-hr8ocLtz.mjs} +5 -7
- package/dist/.setup/{binding-connection-DTtN1KrX.mjs → binding-connection-C-08ez1w.mjs} +2 -2
- package/dist/.setup/{binding-connection.runtime-6TpgD1M6.mjs → binding-connection.runtime-Dn2p-fdy.mjs} +3 -3
- package/dist/.setup/{bounded-turn-BNunZPtz.mjs → bounded-turn-DlHlNTyS.mjs} +14 -13
- package/dist/.setup/{bounded-turn-isolation-B8K_ylqk.mjs → bounded-turn-isolation-DklXNk3k.mjs} +4 -4
- package/dist/.setup/{build-state-DIQ5O_-S.mjs → build-state-CIi3Ckqu.mjs} +1 -1
- package/dist/.setup/{capabilities-B3WEZl4e.mjs → capabilities-kQntafj_.mjs} +1 -1
- package/dist/.setup/{client-qyUBJlGZ.mjs → client-CBzEVDyb.mjs} +438 -160
- package/dist/.setup/{client-catalog-response-DRvx_wCC.mjs → client-catalog-response-CmvIiDdj.mjs} +57 -25
- package/dist/.setup/command-authorization-AikPDtcc.mjs +15 -0
- package/dist/.setup/{command-dispatch-Btrs1D6f.mjs → command-dispatch-BE_RdMou.mjs} +3 -3
- package/dist/.setup/{command-formatters-R3ckE3Co.mjs → command-formatters-DV3DHhdr.mjs} +7 -5
- package/dist/.setup/{command-handlers-DvlCHJch.mjs → command-handlers-DNoRq5Ps.mjs} +82 -144
- package/dist/.setup/{command-rpc-skzRq4wD.mjs → command-rpc-B6xsq2dB.mjs} +23 -31
- package/dist/.setup/{compact-8ttks5U5.mjs → compact-BLSAd-ru.mjs} +117 -65
- package/dist/.setup/{plugin-metadata-cache-BRwtRct9.mjs → computer-use-DpolvQHw.mjs} +65 -202
- package/dist/.setup/{config-DKhXquav.mjs → config-0Gxk3_eq.mjs} +5 -6
- package/dist/.setup/{config-options-CzyWLTJt.mjs → config-options-HG_Rr3W_.mjs} +13 -23
- package/dist/.setup/{config-parsing-b088LyhT.mjs → config-parsing-BQq-CHTF.mjs} +41 -4
- package/dist/.setup/{config-runtime-C0NbLms1.mjs → config-runtime-cUYrqu_a.mjs} +2 -2
- package/dist/.setup/{config-security-CE-FcGw9.mjs → config-security-KAPScztc.mjs} +20 -36
- package/dist/.setup/{context-engine-projection-PezSESth.mjs → context-engine-projection-CsgYSQhW.mjs} +11 -14
- package/dist/.setup/{conversation-binding-74LaGGH-.mjs → conversation-binding-CgSSD1Qz.mjs} +36 -48
- package/dist/.setup/{conversation-binding-data-C746z5Pn.mjs → conversation-binding-data-DJ4ix-W5.mjs} +1 -1
- package/dist/.setup/{conversation-control-OrN6zuaY.mjs → conversation-control-tCg763cI.mjs} +19 -21
- package/dist/.setup/{cyber-failover-XV0nNRZu.mjs → cyber-failover-Bb1J6hS1.mjs} +1 -1
- package/dist/.setup/{cyber-failover-notice-RNpGpTyP.mjs → cyber-failover-notice-XR03ef31.mjs} +1 -1
- package/dist/.setup/doctor-start-options-DPW9JxIE.mjs +63 -0
- package/dist/.setup/dynamic-tool-build-CVrx02cH.mjs +463 -0
- package/dist/.setup/{dynamic-tools-Db2sY5cZ.mjs → dynamic-tools-DdsymYGQ.mjs} +238 -878
- package/dist/.setup/{effective-mcp-catalog-Bi6-SQ7i.mjs → effective-mcp-catalog-BysTBZCW.mjs} +83 -11
- package/dist/.setup/{elicitation-input-DPoK8F7w.mjs → elicitation-input-r9axtppm.mjs} +4 -2
- package/dist/.setup/{ephemeral-turn-DiCS1ijR.mjs → ephemeral-turn-oPKxs3ia.mjs} +2 -2
- package/dist/.setup/{event-projector-assistant-message-MV_1dj-3.mjs → event-projector-assistant-message-YCL2wspu.mjs} +2 -2
- package/dist/.setup/{event-projector-values-DJSz8BTk.mjs → event-projector-values-DTqZHizf.mjs} +2 -12
- package/dist/.setup/{inference-dispatch-CMZtjQyz.mjs → inference-dispatch-B5UKEUyC.mjs} +12 -21
- package/dist/.setup/{inference-proxy-DhcXOgUE.mjs → inference-proxy-DUO5E2QQ.mjs} +6 -5
- package/dist/.setup/{isolated-completion-D80IXfQF.mjs → isolated-completion-D5gbKm6k.mjs} +8 -8
- package/dist/.setup/{managed-binary-kiWRhNRE.mjs → managed-binary-C1VFoVPf.mjs} +31 -38
- package/dist/.setup/mcp-app-session-preparation-CdqsXwZX.mjs +223 -0
- package/dist/.setup/mcp-tool-metadata-j10HhfTC.mjs +43 -0
- package/dist/.setup/{model-catalog-DiC0Tkha.mjs → model-catalog-Dj_uvusa.mjs} +7 -7
- package/dist/.setup/{models-DfLmPV0k.mjs → models-Du_i5G_t.mjs} +10 -7
- package/dist/.setup/{native-auth-CuG53tu4.mjs → native-auth-Cjb9y7IZ.mjs} +5 -6
- package/dist/.setup/{native-execution-policy-BxZJy5mP.mjs → native-execution-policy-ClzpdG3D.mjs} +1 -12
- package/dist/.setup/native-mcp-app-DV7VbfzF.mjs +310 -0
- package/dist/.setup/{native-subagent-monitor-BwkQXf9e.mjs → native-subagent-monitor-CCEFO6qK.mjs} +235 -318
- package/dist/.setup/{native-subagent-pending-assignments-DwkCzLvD.mjs → native-subagent-pending-assignments-BDqhOdJp.mjs} +0 -4
- package/dist/.setup/{native-task-assignments-DMQ0g3hu.mjs → native-task-assignments-C6KVqiN1.mjs} +9 -8
- package/dist/.setup/{node-cli-sessions-HC4W6FLI.mjs → node-cli-sessions-B5oNDkUS.mjs} +11 -17
- package/dist/.setup/{node-exec-server.runtime-BgBfWQqo.mjs → node-exec-server.runtime-0xSEjKYt.mjs} +2 -2
- package/dist/.setup/{plan-DPdMk1Oy.mjs → plan-CUHSIOep.mjs} +67 -89
- package/dist/.setup/{plugin-activation-cNHRfaxU.mjs → plugin-activation-BcyBv8PG.mjs} +4 -4
- package/dist/.setup/{plugin-app-cache-key-BL9B5H0L.mjs → plugin-app-cache-key-BW8rd98k.mjs} +11 -15
- package/dist/.setup/plugin-approval-roundtrip-uAR-oQfr.mjs +109 -0
- package/dist/.setup/{plugin-inventory-Cky2XJUw.mjs → plugin-inventory-Bf0_piTw.mjs} +29 -51
- package/dist/.setup/{plugin-marketplace-discovery-D_dV9FXa.mjs → plugin-marketplace-discovery-SQPhSuic.mjs} +2 -16
- package/dist/.setup/plugin-metadata-cache-DWnB7VMj.mjs +84 -0
- package/dist/.setup/plugin-thread-config-deadline-CdRzGJt4.mjs +124 -0
- package/dist/.setup/{provider-D6F_7p1I.mjs → provider-BP8ZaZqn.mjs} +4 -4
- package/dist/.setup/provider-capabilities-Z5ZbBxqP.mjs +50 -0
- package/dist/.setup/{rate-limits-B7-X2TgG.mjs → rate-limits-CMPy24F5.mjs} +1 -5
- package/dist/.setup/{request-BZOfsSXW.mjs → request-BH3FvYUE.mjs} +189 -49
- package/dist/.setup/rpc-error-hmWM21RB.mjs +57 -0
- package/dist/.setup/{run-attempt-dYJhjZrp.mjs → run-attempt-CgvFoW7R.mjs} +553 -727
- package/dist/.setup/{run-attempt-lifecycle-C-6O3Exn.mjs → run-attempt-lifecycle-BuZgVbDA.mjs} +19 -3
- package/dist/.setup/{runtime-artifact-DDQ-HGXf.mjs → runtime-artifact-CUTOOnKw.mjs} +5 -6
- package/dist/.setup/{runtime-artifact-connection-D68qQn1m.mjs → runtime-artifact-connection-CADz3_BY.mjs} +5 -4
- package/dist/.setup/{sandbox-guard-DjCz2eOw.mjs → sandbox-guard-WqE8yPge.mjs} +3 -3
- package/dist/.setup/service-tier-normalization-Cei89SW6.mjs +15 -0
- package/dist/.setup/{session-binding-DGCYAfvD.mjs → session-binding-Ce7BqiPN.mjs} +92 -102
- package/dist/.setup/session-binding-meta-Lkm5Lpf4.mjs +15 -0
- package/dist/.setup/session-binding-record-BZB8RgcF.mjs +179 -0
- package/dist/.setup/session-binding-record-codec-z4ZpDn6E.mjs +216 -0
- package/dist/.setup/{session-binding-sidecars-jo6H8dFr.mjs → session-binding-sidecars-BrdV95Fg.mjs} +8 -2
- package/dist/.setup/{session-catalog-adoption-BU_pHWG7.mjs → session-catalog-adoption-CPIP4S_y.mjs} +34 -18
- package/dist/.setup/{session-catalog-archive-spHfihri.mjs → session-catalog-archive-DcgwvSbF.mjs} +24 -29
- package/dist/.setup/{session-catalog-events-BMCFMZw-.mjs → session-catalog-events-KIXOoSnQ.mjs} +5 -5
- package/dist/.setup/{session-catalog-index-DwJjnF5k.mjs → session-catalog-index-DPICGlxr.mjs} +361 -72
- package/dist/.setup/{session-catalog-index-order-BcQpHks3.mjs → session-catalog-index-order-nhyO0wdW.mjs} +1 -1
- package/dist/.setup/{session-catalog-limits-DDxOsQeC.mjs → session-catalog-limits-DEU36Qlo.mjs} +1 -1
- package/dist/.setup/{session-catalog-index-state-TeO7EyO-.mjs → session-catalog-list-request-tXephOB4.mjs} +180 -6
- package/dist/.setup/{session-catalog-native-projection-CuaFZuQE.mjs → session-catalog-native-projection-CTBd4EUm.mjs} +7 -6
- package/dist/.setup/{session-catalog-node-adoption-DgXvSGu0.mjs → session-catalog-node-adoption-7-WEQTB1.mjs} +12 -2
- package/dist/.setup/{session-catalog-node-continue-DjKXHBbi.mjs → session-catalog-node-continue-DLWBwAAO.mjs} +11 -15
- package/dist/.setup/{session-catalog-node-lookup-CtAXI5W5.mjs → session-catalog-node-lookup-Uufckwcm.mjs} +2 -2
- package/dist/.setup/{session-catalog-parsing-CPGaPYr-.mjs → session-catalog-parsing-B-qWJh2x.mjs} +70 -28
- package/dist/.setup/{session-catalog-projection-CGfzfP93.mjs → session-catalog-projection-CE0_Hffi.mjs} +6 -122
- package/dist/.setup/{session-catalog-provenance-DoAvktcj.mjs → session-catalog-provenance-CmsOE5mh.mjs} +6 -1
- package/dist/.setup/{session-cli-DlmBHYIe.mjs → session-cli-kH4vuGod.mjs} +1 -2
- package/dist/.setup/{session-history-D83lJWHG.mjs → session-history-BogBHKLk.mjs} +1 -1
- package/dist/.setup/{session-history-import-WhX-X33a.mjs → session-history-import-NWKPa4ZO.mjs} +4 -4
- package/dist/.setup/{session-history-read-Ov3StuL4.mjs → session-history-read-CNN8zwbD.mjs} +8 -19
- package/dist/.setup/{session-history.worker-MnPKncqP.mjs → session-history.worker-Cq_4DYgN.mjs} +3 -3
- package/dist/.setup/{session-initialization-6aveB9qb.mjs → session-initialization-D6dtFQkE.mjs} +2 -2
- package/dist/.setup/{session-permission-policy-Ci_fVX6y.mjs → session-permission-policy-BxIUJ0Zd.mjs} +8 -37
- package/dist/.setup/{session-retirement-LlYWBKTJ.mjs → session-retirement-aC60o6P3.mjs} +14 -15
- package/dist/.setup/{settled-turn-context-D4yj4rxf.mjs → settled-turn-context-BZsMjkIO.mjs} +13 -6
- package/dist/.setup/{settled-turn-finalizer-DW9W3gza.mjs → settled-turn-finalizer-CDxCejjC.mjs} +8 -8
- package/dist/.setup/{shared-client-CJCTeFpQ.mjs → shared-client-DJJ3ljH2.mjs} +291 -272
- package/dist/.setup/{provider-capabilities-DG5qbsUZ.mjs → shell-dynamic-tools-Do9lIAT1.mjs} +16 -55
- package/dist/.setup/{side-question-BLeGj7TQ.mjs → side-question-B7T0_GEC.mjs} +99 -91
- package/dist/.setup/{source-CJis_1EF.mjs → source-DH70LqN0.mjs} +24 -40
- package/dist/.setup/{thread-lifecycle-_bAbjedG.mjs → thread-lifecycle-DkcoX9q-.mjs} +262 -305
- package/dist/.setup/{thread-ownership-B6pPt21M.mjs → thread-ownership-0aRHD9iK.mjs} +10 -8
- package/dist/.setup/{thread-policy-gNPzzpVp.mjs → thread-policy-CXZV97TS.mjs} +22 -21
- package/dist/.setup/{thread-requests-OWGOiDaV.mjs → thread-requests-COrRJcZb.mjs} +107 -98
- package/dist/.setup/{thread-resume-GOry0AYh.mjs → thread-resume-rx7J68Rx.mjs} +10 -18
- package/dist/.setup/{transcript-history-projection-DRSifI-1.mjs → transcript-history-projection-B9a7HwUV.mjs} +11 -16
- package/dist/.setup/{transcript-mirror-kxmCYsuF.mjs → transcript-mirror-BfLRARNL.mjs} +64 -67
- package/dist/.setup/{transport-stdio-Bdegpn2V.mjs → transport-stdio-a0HDa2Mj.mjs} +27 -8
- package/dist/.setup/{transport-websocket-BTBE-LD9.mjs → transport-websocket-zqJ0Cmtn.mjs} +3 -8
- package/dist/.setup/{attempt-client-cleanup-B-S7ngS_.mjs → turn-router-CX1-EoCp.mjs} +75 -170
- package/dist/.setup/{upstream-session-fork-gkdRj2yH.mjs → upstream-session-fork-LYlaQnbt.mjs} +35 -46
- package/dist/.setup/{usage-CApUvLOV.mjs → usage-Dmx7B0W2.mjs} +4 -4
- package/dist/.setup/{usage-limit-error-wSMQkbpV.mjs → usage-limit-error-M8jVnITZ.mjs} +4 -4
- package/dist/.setup/{web-search-provider.runtime-UKgeiBUG.mjs → web-search-provider.runtime-CsVmqbFm.mjs} +4 -20
- package/dist/.setup/websocket-data-XlRvt8Ys.mjs +6 -0
- package/dist/.setup/workspace-write-sandbox-probe-DmUHLrrl.mjs +118 -0
- package/dist/api.js +34 -54
- package/dist/catalog-page.worker.js +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/doctor-contract-api.js +15 -27
- package/dist/harness.js +37 -22
- package/dist/index.js +2880 -276
- package/dist/media-understanding-provider.js +2 -2
- package/dist/migration-provider-api.js +1 -1
- package/dist/native-session-binding-api.js +2 -0
- package/dist/provider-discovery.js +1 -1
- package/dist/session-history-worker-runtime.js +33 -4
- package/dist/session-history.worker.js +1 -1
- package/openclaw.plugin.json +3 -3
- package/package.json +6 -6
- package/dist/.setup/config-utils-D0CXecki.mjs +0 -57
- package/dist/.setup/incognito-session-DWYapfwf.mjs +0 -2
- package/dist/.setup/managed-thread-store-BMqgThVL.mjs +0 -100
- package/dist/.setup/rpc-error-BlD2vuzn.mjs +0 -31
- package/dist/.setup/session-binding-meta-B7aEMU7g.mjs +0 -6
- package/dist/.setup/session-binding-record-Oe9L-CNY.mjs +0 -375
- package/dist/.setup/session-catalog-BFafIiF6.mjs +0 -2599
- package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +0 -170
- package/dist/.setup/shared-client-lifecycle-7xgtlo15.mjs +0 -153
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { U as protectCodexAppServerLiveThread, _ as retainSharedCodexAppServerClientIfCurrent, n as captureCodexAppServerClientLifetime } from "./shared-client-DJJ3ljH2.mjs";
|
|
2
|
+
import { B as getCodexAppServerClientInstanceId } from "./client-CBzEVDyb.mjs";
|
|
3
|
+
import { n as getCodexAppServerTurnRouter } from "./turn-router-CX1-EoCp.mjs";
|
|
4
|
+
import { a as requestPluginApprovalOutcome } from "./plugin-approval-roundtrip-uAR-oQfr.mjs";
|
|
5
|
+
import { i as readCodexMcpToolUiVisibility, n as projectCodexMcpToolMetadata, r as readCodexMcpToolConnectorId, t as projectCodexMcpServerMetadata } from "./mcp-tool-metadata-j10HhfTC.mjs";
|
|
6
|
+
import { t as __exportAll } from "./session-binding-sidecars-BrdV95Fg.mjs";
|
|
7
|
+
import { asOptionalRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { loadAgentHarnessMcpConfig, prepareHarnessNativeMcpAppPreview } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
10
|
+
import { captureMcpClientElicitation, createHarnessMcpFormResourceContext, normalizeMcpCodexToolAnnotations, requiresMcpCodexToolApproval, resolveProjectedMcpCodexToolApprovalMode } from "openclaw/plugin-sdk/codex-mcp-projection";
|
|
11
|
+
//#region extensions/codex/src/app-server/native-mcp-app.ts
|
|
12
|
+
var native_mcp_app_exports = /* @__PURE__ */ __exportAll({
|
|
13
|
+
createCodexNativeMcpAppResultDetailsPreparer: () => createCodexNativeMcpAppResultDetailsPreparer,
|
|
14
|
+
createNativeMcpRuntime: () => createNativeMcpRuntime,
|
|
15
|
+
prepareCodexNativeMcpFormResourceContext: () => prepareCodexNativeMcpFormResourceContext
|
|
16
|
+
});
|
|
17
|
+
const CODEX_APPS_MCP_SERVER = "codex_apps";
|
|
18
|
+
const toolCallMetadataSchema = z.record(z.string(), z.json());
|
|
19
|
+
function readMcpToolResult(item) {
|
|
20
|
+
const result = asOptionalRecord(item.result);
|
|
21
|
+
if (!result || !Array.isArray(result.content)) return;
|
|
22
|
+
const resultMeta = asOptionalRecord(result["_meta"]);
|
|
23
|
+
return {
|
|
24
|
+
content: result.content,
|
|
25
|
+
...result.structuredContent !== void 0 ? { structuredContent: result.structuredContent } : {},
|
|
26
|
+
...result.isError === true ? { isError: true } : {},
|
|
27
|
+
...resultMeta ? { _meta: resultMeta } : {}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function statusTools(status) {
|
|
31
|
+
return Object.entries(status.tools).map(([name, value]) => Object.assign({}, asOptionalRecord(value) ?? {}, { name }));
|
|
32
|
+
}
|
|
33
|
+
function createNativeMcpRuntime(params) {
|
|
34
|
+
let catalog = null;
|
|
35
|
+
let statuses;
|
|
36
|
+
const createdAt = Date.now();
|
|
37
|
+
let localFileOwner;
|
|
38
|
+
try {
|
|
39
|
+
localFileOwner = captureCodexAppServerClientLifetime(params.client, "native-process");
|
|
40
|
+
} catch {}
|
|
41
|
+
let localServerNames;
|
|
42
|
+
const loadStatuses = async () => {
|
|
43
|
+
params.assertCurrent?.();
|
|
44
|
+
if (statuses) return statuses;
|
|
45
|
+
const loaded = [];
|
|
46
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
47
|
+
let cursor;
|
|
48
|
+
for (let page = 0; page < 100; page += 1) {
|
|
49
|
+
params.assertCurrent?.();
|
|
50
|
+
const response = await params.client.request("mcpServerStatus/list", {
|
|
51
|
+
threadId: params.threadId,
|
|
52
|
+
detail: "full",
|
|
53
|
+
...cursor ? { cursor } : {}
|
|
54
|
+
}, { assertCurrent: params.assertCurrent });
|
|
55
|
+
params.assertCurrent?.();
|
|
56
|
+
loaded.push(...response.data);
|
|
57
|
+
if (!response.nextCursor) {
|
|
58
|
+
statuses = loaded;
|
|
59
|
+
return statuses;
|
|
60
|
+
}
|
|
61
|
+
if (cursors.has(response.nextCursor)) throw new Error("Native MCP status cursor repeated");
|
|
62
|
+
cursor = response.nextCursor;
|
|
63
|
+
cursors.add(cursor);
|
|
64
|
+
}
|
|
65
|
+
throw new Error("Native MCP status exceeded the page limit");
|
|
66
|
+
};
|
|
67
|
+
const getCatalog = async () => {
|
|
68
|
+
if (catalog) return catalog;
|
|
69
|
+
const loaded = await loadStatuses();
|
|
70
|
+
if (localFileOwner && !localServerNames) {
|
|
71
|
+
const configured = await loadAgentHarnessMcpConfig({
|
|
72
|
+
workspaceDir: params.attempt.workspaceDir,
|
|
73
|
+
cfg: params.attempt.config,
|
|
74
|
+
toolOverrides: params.attempt.toolOverrides
|
|
75
|
+
});
|
|
76
|
+
params.assertCurrent?.();
|
|
77
|
+
localFileOwner();
|
|
78
|
+
localServerNames = new Set(Object.entries(configured.config.mcpServers).filter(([, server]) => (normalizeLowercaseStringOrEmpty(server.transport) || "stdio") === "stdio" && typeof server.command === "string").map(([name]) => name));
|
|
79
|
+
}
|
|
80
|
+
catalog = {
|
|
81
|
+
version: 1,
|
|
82
|
+
generatedAt: Date.now(),
|
|
83
|
+
servers: Object.fromEntries(loaded.map((status) => [status.name, projectCodexMcpServerMetadata(status)])),
|
|
84
|
+
tools: loaded.flatMap((status) => statusTools(status).map((tool) => {
|
|
85
|
+
const uiVisibility = readCodexMcpToolUiVisibility(tool);
|
|
86
|
+
return Object.assign({
|
|
87
|
+
serverName: status.name,
|
|
88
|
+
safeServerName: status.name,
|
|
89
|
+
toolName: String(tool.name),
|
|
90
|
+
inputSchema: asOptionalRecord(tool.inputSchema) ?? { type: "object" }
|
|
91
|
+
}, projectCodexMcpToolMetadata(String(tool.name), tool), uiVisibility ? { uiVisibility } : {});
|
|
92
|
+
}))
|
|
93
|
+
};
|
|
94
|
+
return catalog;
|
|
95
|
+
};
|
|
96
|
+
const runtime = {
|
|
97
|
+
sessionId: params.attempt.sessionId,
|
|
98
|
+
sessionKey: params.attempt.sessionKey,
|
|
99
|
+
workspaceDir: params.attempt.workspaceDir,
|
|
100
|
+
configFingerprint: `${getCodexAppServerClientInstanceId(params.client)}:${params.threadId}`,
|
|
101
|
+
mcpAppsEnabled: true,
|
|
102
|
+
...params.appRequester ? { appRequester: params.appRequester } : {},
|
|
103
|
+
assertOwnerCurrent: params.assertCurrent,
|
|
104
|
+
canReadLocalFiles: (serverName) => {
|
|
105
|
+
params.assertCurrent?.();
|
|
106
|
+
if (!localFileOwner || !localServerNames?.has(serverName)) return false;
|
|
107
|
+
localFileOwner();
|
|
108
|
+
return true;
|
|
109
|
+
},
|
|
110
|
+
createdAt,
|
|
111
|
+
lastUsedAt: createdAt,
|
|
112
|
+
acquireLease: () => {
|
|
113
|
+
params.assertCurrent?.();
|
|
114
|
+
const releaseClient = retainSharedCodexAppServerClientIfCurrent(params.client);
|
|
115
|
+
if (!releaseClient) throw new Error("Native MCP App client is no longer current");
|
|
116
|
+
const unprotect = protectCodexAppServerLiveThread(params.client, params.threadId);
|
|
117
|
+
return () => {
|
|
118
|
+
unprotect();
|
|
119
|
+
releaseClient();
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
getCatalog,
|
|
123
|
+
peekCatalog: () => catalog,
|
|
124
|
+
markUsed: () => {
|
|
125
|
+
runtime.lastUsedAt = Date.now();
|
|
126
|
+
},
|
|
127
|
+
callTool: async (serverName, toolName, input, options) => {
|
|
128
|
+
const assertCurrent = () => {
|
|
129
|
+
params.assertCurrent?.();
|
|
130
|
+
options?.assertCurrent?.();
|
|
131
|
+
};
|
|
132
|
+
assertCurrent();
|
|
133
|
+
const elicitation = captureMcpClientElicitation();
|
|
134
|
+
const call = async () => await params.client.request("mcpServer/tool/call", {
|
|
135
|
+
threadId: params.threadId,
|
|
136
|
+
server: serverName,
|
|
137
|
+
tool: toolName,
|
|
138
|
+
arguments: asOptionalRecord(input) ?? {},
|
|
139
|
+
...options?._meta ? { _meta: toolCallMetadataSchema.parse(options._meta) } : {}
|
|
140
|
+
}, {
|
|
141
|
+
signal: elicitation?.signal,
|
|
142
|
+
assertCurrent
|
|
143
|
+
});
|
|
144
|
+
if (!elicitation) return await call();
|
|
145
|
+
return await getCodexAppServerTurnRouter(params.client).withMcpToolCall({
|
|
146
|
+
threadId: params.threadId,
|
|
147
|
+
serverName,
|
|
148
|
+
signal: elicitation.signal,
|
|
149
|
+
onRequest: async (request, _scope, signal) => {
|
|
150
|
+
assertCurrent();
|
|
151
|
+
const elicitationInput = asOptionalRecord(request.params);
|
|
152
|
+
if (!elicitationInput) throw new Error("Invalid native MCP elicitation");
|
|
153
|
+
const rich = elicitationInput.mode === "openai/form" || elicitationInput.mode === "openaiForm";
|
|
154
|
+
const result = await elicitation.handle({
|
|
155
|
+
method: rich ? "openai/elicitation/create" : "elicitation/create",
|
|
156
|
+
requestId: request.id,
|
|
157
|
+
params: elicitationInput,
|
|
158
|
+
signal
|
|
159
|
+
});
|
|
160
|
+
assertCurrent();
|
|
161
|
+
return z.json().parse(result);
|
|
162
|
+
}
|
|
163
|
+
}, call);
|
|
164
|
+
},
|
|
165
|
+
listTools: async (serverName) => {
|
|
166
|
+
const status = (await loadStatuses()).find((entry) => entry.name === serverName);
|
|
167
|
+
return { tools: status ? statusTools(status) : [] };
|
|
168
|
+
},
|
|
169
|
+
readResource: async (serverName, uri, options) => {
|
|
170
|
+
params.assertCurrent?.();
|
|
171
|
+
if (options?._meta && Object.keys(options._meta).length > 0) throw new Error("This Codex connection does not support metadata-selected remote resource representations");
|
|
172
|
+
const isCodexAppsServer = serverName === CODEX_APPS_MCP_SERVER;
|
|
173
|
+
const response = await params.client.request("mcpServer/resource/read", {
|
|
174
|
+
threadId: params.threadId,
|
|
175
|
+
...isCodexAppsServer ? { originCallId: params.originCallId } : {},
|
|
176
|
+
server: serverName,
|
|
177
|
+
uri,
|
|
178
|
+
...params.connectorId ? { connectorId: params.connectorId } : {}
|
|
179
|
+
}, { assertCurrent: params.assertCurrent });
|
|
180
|
+
if (isCodexAppsServer && response.originCallId !== params.originCallId) throw new Error(`Codex MCP resource response originCallId mismatch: expected ${params.originCallId}, received ${response.originCallId}`);
|
|
181
|
+
return response;
|
|
182
|
+
},
|
|
183
|
+
listResources: async (serverName) => {
|
|
184
|
+
return { resources: (await loadStatuses()).find((entry) => entry.name === serverName)?.resources ?? [] };
|
|
185
|
+
},
|
|
186
|
+
listResourceTemplates: async (serverName) => {
|
|
187
|
+
return { resourceTemplates: (await loadStatuses()).find((entry) => entry.name === serverName)?.resourceTemplates ?? [] };
|
|
188
|
+
},
|
|
189
|
+
joinCleanup: async () => {},
|
|
190
|
+
dispose: async () => {}
|
|
191
|
+
};
|
|
192
|
+
return runtime;
|
|
193
|
+
}
|
|
194
|
+
function createCodexNativeMcpAppResultDetailsPreparer(params) {
|
|
195
|
+
if (params.attempt.config?.mcp?.apps?.enabled !== true) return;
|
|
196
|
+
return async (item) => {
|
|
197
|
+
const serverName = normalizeOptionalString(item.server);
|
|
198
|
+
const toolName = normalizeOptionalString(item.tool);
|
|
199
|
+
const appContext = asOptionalRecord(item.appContext);
|
|
200
|
+
const uiResourceUri = normalizeOptionalString(appContext?.resourceUri) ?? normalizeOptionalString(item.mcpAppResourceUri);
|
|
201
|
+
const connectorId = normalizeOptionalString(appContext?.connectorId);
|
|
202
|
+
const toolResult = readMcpToolResult(item);
|
|
203
|
+
if (!serverName || !toolName || !uiResourceUri?.startsWith("ui://") || !toolResult) return;
|
|
204
|
+
if (serverName === CODEX_APPS_MCP_SERVER && !connectorId) return;
|
|
205
|
+
const runtime = createNativeMcpRuntime({
|
|
206
|
+
...params,
|
|
207
|
+
originCallId: item.id,
|
|
208
|
+
...connectorId ? { connectorId } : {}
|
|
209
|
+
});
|
|
210
|
+
const tools = (await runtime.listTools?.(serverName))?.tools ?? [];
|
|
211
|
+
const allowedAppToolNames = new Set(tools.filter((tool) => {
|
|
212
|
+
const uiVisibility = readCodexMcpToolUiVisibility(tool);
|
|
213
|
+
return (uiVisibility === void 0 || uiVisibility.includes("app")) && (serverName !== CODEX_APPS_MCP_SERVER || readCodexMcpToolConnectorId(tool) === connectorId);
|
|
214
|
+
}).map((tool) => tool.name));
|
|
215
|
+
if (!allowedAppToolNames.has(toolName)) return;
|
|
216
|
+
await runtime.getCatalog();
|
|
217
|
+
return await prepareHarnessNativeMcpAppPreview({
|
|
218
|
+
runtime,
|
|
219
|
+
agentId: params.attempt.agentId,
|
|
220
|
+
serverName,
|
|
221
|
+
toolName,
|
|
222
|
+
uiResourceUri,
|
|
223
|
+
toolCallId: item.id,
|
|
224
|
+
toolInput: item.arguments ?? {},
|
|
225
|
+
toolResult,
|
|
226
|
+
allowedAppToolNames,
|
|
227
|
+
...toolResult["_meta"] !== void 0 ? { resultMetaState: "unavailable" } : {}
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
/** The per-turn projector, not a client-supplied resource id, selects the native origin. */
|
|
232
|
+
async function prepareCodexNativeMcpFormResourceContext(params) {
|
|
233
|
+
const serverName = typeof params.request.snapshot.serverName === "string" ? params.request.snapshot.serverName : "";
|
|
234
|
+
const origin = params.readOrigin(serverName);
|
|
235
|
+
const { agentId, sessionKey } = params.attempt;
|
|
236
|
+
if (!origin || !sessionKey || !agentId) throw new Error("Native MCP form has no unambiguous live origin");
|
|
237
|
+
const assertCurrent = () => {
|
|
238
|
+
params.attempt.hostCapabilities.assertActive();
|
|
239
|
+
if (params.readOrigin(serverName)?.id !== origin.id) throw new Error("Native MCP form origin expired");
|
|
240
|
+
params.request.signal.throwIfAborted();
|
|
241
|
+
};
|
|
242
|
+
assertCurrent();
|
|
243
|
+
const tools = (await createNativeMcpRuntime({
|
|
244
|
+
client: params.client,
|
|
245
|
+
threadId: params.threadId,
|
|
246
|
+
attempt: params.attempt,
|
|
247
|
+
originCallId: origin.id,
|
|
248
|
+
assertCurrent
|
|
249
|
+
}).listTools?.(origin.server))?.tools ?? [];
|
|
250
|
+
assertCurrent();
|
|
251
|
+
const source = tools.find((tool) => tool.name === origin.tool);
|
|
252
|
+
if (!source) throw new Error("Native MCP form origin is no longer listed");
|
|
253
|
+
const connectorId = readCodexMcpToolConnectorId(source);
|
|
254
|
+
if (origin.server === CODEX_APPS_MCP_SERVER && !connectorId) throw new Error("Native MCP form connector is unavailable");
|
|
255
|
+
const runtime = createNativeMcpRuntime({
|
|
256
|
+
client: params.client,
|
|
257
|
+
threadId: params.threadId,
|
|
258
|
+
attempt: params.attempt,
|
|
259
|
+
originCallId: origin.id,
|
|
260
|
+
connectorId,
|
|
261
|
+
assertCurrent
|
|
262
|
+
});
|
|
263
|
+
await runtime.getCatalog();
|
|
264
|
+
assertCurrent();
|
|
265
|
+
return await createHarnessMcpFormResourceContext({
|
|
266
|
+
version: 1,
|
|
267
|
+
requestId: params.request.requestId,
|
|
268
|
+
snapshot: params.request.snapshot,
|
|
269
|
+
signal: params.request.signal,
|
|
270
|
+
origin: {
|
|
271
|
+
runtime,
|
|
272
|
+
serverName: origin.server,
|
|
273
|
+
agentId,
|
|
274
|
+
sessionKey,
|
|
275
|
+
requesterId: runtime.appRequester?.profileId,
|
|
276
|
+
assertCurrent,
|
|
277
|
+
prepareToolCall: async (request) => {
|
|
278
|
+
assertCurrent();
|
|
279
|
+
request.assertCurrent();
|
|
280
|
+
const target = tools.find((tool) => tool.name === request.toolName);
|
|
281
|
+
if (!target || params.attempt.toolOverrides?.mcpServers?.[origin.server] === false || params.attempt.toolOverrides?.mcpToolsDeny?.[origin.server]?.includes(request.toolName) || readCodexMcpToolUiVisibility(target)?.includes("app") === false || origin.server === CODEX_APPS_MCP_SERVER && readCodexMcpToolConnectorId(target) !== connectorId) throw new Error("Native form preview tool is not authorized");
|
|
282
|
+
const server = params.attempt.config?.mcp?.servers?.[origin.server];
|
|
283
|
+
if (requiresMcpCodexToolApproval({
|
|
284
|
+
mode: server ? resolveProjectedMcpCodexToolApprovalMode(origin.server, server) : "prompt",
|
|
285
|
+
fullPermission: params.attempt.permissionMode === "full",
|
|
286
|
+
annotations: normalizeMcpCodexToolAnnotations(target.annotations)
|
|
287
|
+
})) {
|
|
288
|
+
const description = JSON.stringify({
|
|
289
|
+
server: origin.server,
|
|
290
|
+
tool: request.toolName,
|
|
291
|
+
arguments: request.input
|
|
292
|
+
});
|
|
293
|
+
if (description.length > 512) throw new Error("Native form preview arguments exceed the approval display limit");
|
|
294
|
+
if (await requestPluginApprovalOutcome({
|
|
295
|
+
hostCapabilities: params.attempt.hostCapabilities,
|
|
296
|
+
signal: request.signal ?? params.request.signal,
|
|
297
|
+
title: "Run MCP form preview?",
|
|
298
|
+
description,
|
|
299
|
+
toolName: request.toolName,
|
|
300
|
+
allowedDecisions: ["allow-once", "deny"]
|
|
301
|
+
}) !== "approved-once") throw new Error("Native MCP form preview was not approved");
|
|
302
|
+
}
|
|
303
|
+
assertCurrent();
|
|
304
|
+
request.assertCurrent();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
//#endregion
|
|
310
|
+
export { native_mcp_app_exports as n, prepareCodexNativeMcpFormResourceContext as r, createCodexNativeMcpAppResultDetailsPreparer as t };
|