@openclaw/codex 2026.9.2 → 2026.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/api.js +29 -26
- package/dist/apply-CvT8tW5i.js +356 -0
- package/dist/{attempt-client-cleanup-Bp1ZOnk2.js → attempt-client-cleanup-DKHzbwt5.js} +38 -214
- package/dist/{attempt-context-CSazkWns.js → attempt-context-D44yeDII.js} +9 -7
- package/dist/{event-projector-usage-ZqEVbAEY.js → attempt-notifications-C9XufG6l.js} +3 -106
- package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-CWlKVccJ.js} +2 -2
- package/dist/auth-cache-key-7orQae_j.js +498 -0
- package/dist/auth-profile-CwzO4_RG.js +43 -0
- package/dist/auth-profile-selection-DFu9e167.js +45 -0
- package/dist/binding-connection-D3udKbIE.js +60 -0
- package/dist/{bounded-turn-DxGJRYbY.js → bounded-turn-C_Hneydj.js} +28 -125
- package/dist/build-state-BCmg9-5p.js +19 -0
- package/dist/{capabilities-B1mgvpP8.js → capabilities-8vx68WLH.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/client-B57KWPQx.js +4005 -0
- package/dist/command-dispatch-BpduNGVf.js +21 -0
- package/dist/{command-formatters-DSbGMXA0.js → command-formatters-lxlkNZgU.js} +4 -3
- package/dist/{command-handlers-DOJvGv6-.js → command-handlers-tiL9iWj7.js} +788 -135
- package/dist/command-rpc-CR5EOEZX.js +233 -0
- package/dist/{compact-Y_xBqrHN.js → compact-B_H3AOd7.js} +19 -14
- package/dist/config-oIORaQ5T.js +106 -0
- package/dist/{config-CyapYSji.js → config-options-CXMq1T-C.js} +205 -593
- package/dist/config-runtime-D0zGNIHu.js +11 -0
- package/dist/{config-utils-C57JiJrU.js → config-utils-DujwEnhg.js} +2 -4
- package/dist/conversation-binding-DsB4-O7U.js +900 -0
- package/dist/{plugin-marketplace-discovery-B7gHXJ3d.js → conversation-control-CtUu1b3m.js} +11 -143
- package/dist/doctor-contract-api.js +5 -5
- package/dist/{dynamic-tools-BwpvTxaX.js → dynamic-tools-CmN5RAip.js} +133 -76
- package/dist/{effective-mcp-catalog-CY9Jn4bA.js → effective-mcp-catalog-Bd73bqA8.js} +3 -3
- package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
- package/dist/ephemeral-turn-D78_VmzO.js +101 -0
- package/dist/{event-projector-assistant-message-B9kp6iGC.js → event-projector-assistant-message-BmBM4qBV.js} +12 -25
- package/dist/event-projector-items-5VhsECCO.js +200 -0
- package/dist/event-projector-usage-BfXmpOec.js +102 -0
- package/dist/{harness-Czh2Sdoc.js → harness-C7rRa7bm.js} +48 -24
- package/dist/harness.js +1 -1
- package/dist/history-rejection-B4nOXNXF.js +13 -0
- package/dist/incognito-session-uhrBF6wJ.js +15 -0
- package/dist/index.js +406 -2915
- package/dist/inference-context-Dr_mzvk4.js +94 -0
- package/dist/inference-proxy-HGXKUIre.js +311 -0
- package/dist/{isolated-completion-CRh-51AK.js → isolated-completion-DWVb5U2J.js} +7 -4
- package/dist/launch-args-RXQwn8zV.js +90 -0
- package/dist/{managed-binary-DcpnJF9x.js → managed-binary-D22rNEcR.js} +13 -103
- package/dist/managed-thread-store-D1t5jh3G.js +66 -0
- package/dist/media-understanding-provider.js +4 -1
- package/dist/migration-provider-api.js +2 -0
- package/dist/{model-catalog-DT5vo6qo.js → model-catalog-Dq2n8f_p.js} +6 -5
- package/dist/{models-CcrgSMQR.js → models-PCKOim-h.js} +3 -3
- package/dist/native-execution-policy-umd0tgh4.js +128 -0
- package/dist/native-subagent-history-DjtPloaU.js +140 -0
- package/dist/native-subagent-history-owner-Pcp7JuVF.js +34 -0
- package/dist/{native-subagent-monitor-B3bvQGcg.js → native-subagent-monitor-fQ7eIXEf.js} +115 -460
- package/dist/native-subagent-task-ids-BzTdT0Uw.js +387 -0
- package/dist/node-cli-sessions-DKaOmVUh.js +527 -0
- package/dist/{node-exec-server.runtime-nfbUOtUB.js → node-exec-server.runtime-Cl2vapEi.js} +55 -24
- package/dist/plan-7uG-Fp36.js +947 -0
- package/dist/plugin-activation-BYQculil.js +138 -0
- package/dist/{thread-resume-BLgqkUc1.js → plugin-app-cache-key-d0eKxy7b.js} +4 -52
- package/dist/{plugin-approval-roundtrip-aQVdyL5g.js → plugin-approval-roundtrip-Bz3FT8W5.js} +1 -1
- package/dist/plugin-inventory-oL4Na1ZG.js +328 -0
- package/dist/plugin-marketplace-discovery-P-Vndfqq.js +137 -0
- package/dist/{plugin-metadata-cache-BwCLTY_U.js → plugin-metadata-cache-ClPJpRio.js} +17 -9
- package/dist/protocol-5bh1G-H7.js +275 -0
- package/dist/provider-MQ8PVkuE.js +50 -0
- package/dist/{provider-capabilities-BpG9Ltc5.js → provider-capabilities-BvCUL69A.js} +2 -2
- package/dist/{rate-limits-Fx_l4eNa.js → rate-limits-CBMmWBr9.js} +1 -1
- package/dist/request-B7hEkBGq.js +212 -0
- package/dist/rpc-error-ttN_QjEm.js +30 -0
- package/dist/{run-attempt-BzthFQSM.js → run-attempt-CvsAAGa0.js} +664 -377
- package/dist/{runtime-artifact-Bh_gf6-t.js → runtime-artifact-BJ0rXBZ_.js} +27 -27
- package/dist/sandbox-guard-BxgyoM8M.js +166 -0
- package/dist/{session-binding-4Ki04sW-.js → session-binding-CI8UuilT.js} +30 -48
- package/dist/{session-binding-record-CyaXZvTe.js → session-binding-record-Bcvslnhf.js} +12 -26
- package/dist/session-catalog-adoption-tcZi1IfX.js +251 -0
- package/dist/session-catalog-archive-CwKg8Xz2.js +56 -0
- package/dist/session-catalog-ct-AH01I.js +1477 -0
- package/dist/session-catalog-home-id-CwhLdC03.js +18 -0
- package/dist/session-catalog-node-adoption-B1tgDW-m.js +182 -0
- package/dist/session-catalog-node-continue-Ci-DXyJP.js +238 -0
- package/dist/session-catalog-provenance-D-dIfRAH.js +96 -0
- package/dist/{session-cli-BjLhpmS1.js → session-cli-DNN_jhGc.js} +3 -2
- package/dist/{session-history-DWmMqiqW.js → session-history-Cz-tOOYj.js} +6 -3
- package/dist/{session-upstream-marker-DReTpGz6.js → session-history-import-DwyijFI6.js} +5 -50
- package/dist/{session-history-read-LHldwvyh.js → session-history-read-cxPUxyVV.js} +21 -7
- package/dist/session-history-worker-runtime.js +18 -6
- package/dist/session-history.worker-BeK1YOyT.js +378 -0
- package/dist/session-history.worker.js +1 -1
- package/dist/{session-initialization-BCFVnLL4.js → session-initialization-Ct0_Hzmg.js} +2 -2
- package/dist/{session-permission-policy-BaueHmSj.js → session-permission-policy-BBmXA8Eg.js} +4 -7
- package/dist/{session-retirement-DNdmYdFc.js → session-retirement-B2YfbAAT.js} +6 -5
- package/dist/session-upstream-marker-D15C9NHp.js +46 -0
- package/dist/{settled-turn-context-BOM3Y1pl.js → settled-turn-context-Du6gdUDd.js} +9 -9
- package/dist/{settled-turn-finalizer-BI-b1sry.js → settled-turn-finalizer-Dn91stmc.js} +8 -7
- package/dist/shared-client-CscigXXL.js +3109 -0
- package/dist/{side-question-B6DWAw1A.js → side-question-BGMJQf4U.js} +65 -170
- package/dist/source-CElXU0Oy.js +518 -0
- package/dist/thread-archive-guard-DfpBr-Sz.js +53 -0
- package/dist/thread-history-page-D0JIp48V.js +361 -0
- package/dist/{thread-lifecycle-DPK30jad.js → thread-lifecycle-DXl1-I6b.js} +187 -639
- package/dist/{thread-ownership-CbucAmmp.js → thread-ownership-BsDRTsyp.js} +13 -15
- package/dist/thread-policy-BuEQfE0g.js +54 -0
- package/dist/thread-resume-DsDOZpFg.js +52 -0
- package/dist/timeout-BVw8aaM1.js +33 -0
- package/dist/transcript-history-projection-v17wXgdK.js +238 -0
- package/dist/{transcript-mirror-_njEB84z.js → transcript-mirror-C5CKgNy6.js} +50 -260
- package/dist/{transcript-mirror-attestation-Byl34PC-.js → transcript-mirror-attestation-DibE0krH.js} +17 -4
- package/dist/{transport-stdio-CzTngV0j.js → transport-stdio-BGjHoYLr.js} +73 -43
- package/dist/{upstream-session-fork-1fwbNKzQ.js → upstream-session-fork-BZerMte_.js} +27 -19
- package/dist/{usage-i9fv5-4m.js → usage-tCk-mg_x.js} +4 -3
- package/dist/version-omm6IPI3.js +12 -0
- package/dist/{web-search-provider.runtime-DKQn67A7.js → web-search-provider.runtime-B7bGbGWq.js} +3 -3
- package/openclaw.plugin.json +23 -1
- package/package.json +4 -4
- package/dist/request-C8H22rPi.js +0 -475
- package/dist/session-catalog-B47uwekb.js +0 -3272
- package/dist/session-history.worker-zZVcx0ME.js +0 -267
- package/dist/shared-client-CKhX2kFt.js +0 -7505
- package/dist/thread-policy-CTalhWFy.js +0 -105
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
import { n as isCodexFastServiceTier } from "./config-utils-
|
|
2
|
-
import {
|
|
3
|
-
import "./
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import { getSessionEntry, patchSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
1
|
+
import { n as isCodexFastServiceTier } from "./config-utils-DujwEnhg.js";
|
|
2
|
+
import { r as bindingStoreKey } from "./session-binding-record-Bcvslnhf.js";
|
|
3
|
+
import { o as formatCodexDisplayText } from "./command-formatters-lxlkNZgU.js";
|
|
4
|
+
import "./config-oIORaQ5T.js";
|
|
5
|
+
import { i as resolveCodexBindingAppServerConnection } from "./binding-connection-D3udKbIE.js";
|
|
6
|
+
import { n as normalizeCodexAppServerBindingModelProvider, t as isCodexAppServerNativeAuthProfile } from "./auth-profile-CwzO4_RG.js";
|
|
7
|
+
import { c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient } from "./shared-client-CscigXXL.js";
|
|
8
|
+
import { D as resolveCodexAppServerRequestModelSelection, k as resolveCodexBindingModelProviderFallback } from "./thread-lifecycle-DXl1-I6b.js";
|
|
9
|
+
import "./session-binding-CI8UuilT.js";
|
|
11
10
|
import { resolveAgentDir } from "openclaw/plugin-sdk/agent-runtime";
|
|
11
|
+
import { getSessionEntry, patchSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
12
12
|
import { ModelSelectionLockedError, applyModelOverrideWithAuthProfileCompatibility } from "openclaw/plugin-sdk/model-session-runtime";
|
|
13
|
-
//#region extensions/codex/src/command-authorization.ts
|
|
14
|
-
const CODEX_NATIVE_EXECUTION_AUTH_ERROR = "Only an owner or operator.admin can control Codex native execution.";
|
|
15
|
-
const CODEX_HOST_INSPECTION_AUTH_ERROR = "Only an owner or operator.admin can inspect Codex host state.";
|
|
16
|
-
const CODEX_FULL_PERMISSIONS_AUTH_ERROR = "Full Codex permissions require operator.admin. Choose Admin in the Control UI permission picker, or use an admin-authenticated CLI.";
|
|
17
|
-
function hasCodexAdminScope(ctx) {
|
|
18
|
-
return ctx.gatewayClientScopes?.includes("operator.admin") === true;
|
|
19
|
-
}
|
|
20
|
-
function canMutateCodexHost(ctx) {
|
|
21
|
-
return ctx.senderIsOwner === true || hasCodexAdminScope(ctx);
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
13
|
//#region extensions/codex/src/conversation-control.ts
|
|
25
14
|
const CODEX_CONVERSATION_CONTROL_STATE = Symbol.for("openclaw.codex.conversationControl");
|
|
26
15
|
function getActiveTurns() {
|
|
@@ -280,125 +269,4 @@ function resolveConversationControlModelProvider(params) {
|
|
|
280
269
|
return modelProvider.toLowerCase() === "openai" ? "openai" : modelProvider;
|
|
281
270
|
}
|
|
282
271
|
//#endregion
|
|
283
|
-
|
|
284
|
-
/** Read-only discovery of Codex-owned local, curated, and remote plugin marketplaces. */
|
|
285
|
-
const PLUGIN_SEGMENT_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
286
|
-
const MAX_PLUGIN_DESCRIPTION_LENGTH = 160;
|
|
287
|
-
const SUPPLEMENTAL_MARKETPLACE_KINDS = [
|
|
288
|
-
"workspace-directory",
|
|
289
|
-
"shared-with-me",
|
|
290
|
-
"created-by-me-remote",
|
|
291
|
-
"vertical"
|
|
292
|
-
];
|
|
293
|
-
/** Validates the same identifier segments required by Codex's stable PluginId parser. */
|
|
294
|
-
function parseCodexPluginMarketplaceId(value) {
|
|
295
|
-
const separator = value.lastIndexOf("@");
|
|
296
|
-
if (separator <= 0 || separator === value.length - 1) return;
|
|
297
|
-
const pluginName = value.slice(0, separator);
|
|
298
|
-
const marketplaceName = value.slice(separator + 1);
|
|
299
|
-
return PLUGIN_SEGMENT_PATTERN.test(pluginName) && PLUGIN_SEGMENT_PATTERN.test(marketplaceName) ? {
|
|
300
|
-
pluginName,
|
|
301
|
-
marketplaceName
|
|
302
|
-
} : void 0;
|
|
303
|
-
}
|
|
304
|
-
/** Lists local/global first and separately requests workspace, shared, and personal catalogs. */
|
|
305
|
-
async function discoverCodexMarketplacePlugins(params) {
|
|
306
|
-
const requestParams = { cwds: [params.workspaceDir] };
|
|
307
|
-
const primary = await params.request(requestParams);
|
|
308
|
-
const warnings = (primary.marketplaceLoadErrors ?? []).map((error) => boundedCatalogText(error.message));
|
|
309
|
-
const marketplaces = [...primary.marketplaces];
|
|
310
|
-
try {
|
|
311
|
-
const supplemental = await params.request({
|
|
312
|
-
...requestParams,
|
|
313
|
-
marketplaceKinds: [...SUPPLEMENTAL_MARKETPLACE_KINDS]
|
|
314
|
-
});
|
|
315
|
-
marketplaces.push(...supplemental.marketplaces);
|
|
316
|
-
warnings.push(...(supplemental.marketplaceLoadErrors ?? []).map((error) => boundedCatalogText(error.message)));
|
|
317
|
-
} catch (error) {
|
|
318
|
-
let recoveredSupplementalMarketplace = false;
|
|
319
|
-
for (const kind of SUPPLEMENTAL_MARKETPLACE_KINDS) try {
|
|
320
|
-
const supplemental = await params.request({
|
|
321
|
-
...requestParams,
|
|
322
|
-
marketplaceKinds: [kind]
|
|
323
|
-
});
|
|
324
|
-
marketplaces.push(...supplemental.marketplaces);
|
|
325
|
-
recoveredSupplementalMarketplace ||= supplemental.marketplaces.length > 0;
|
|
326
|
-
warnings.push(...(supplemental.marketplaceLoadErrors ?? []).map((loadError) => boundedCatalogText(loadError.message)));
|
|
327
|
-
} catch (kindError) {
|
|
328
|
-
warnings.push(boundedCatalogText(`${kind} marketplace unavailable: ${kindError instanceof Error ? kindError.message : String(kindError)}`));
|
|
329
|
-
}
|
|
330
|
-
if (!recoveredSupplementalMarketplace && warnings.length === 0) warnings.push(boundedCatalogText(`Additional marketplaces could not be listed: ${error instanceof Error ? error.message : String(error)}`));
|
|
331
|
-
}
|
|
332
|
-
const discovered = /* @__PURE__ */ new Map();
|
|
333
|
-
const ambiguous = /* @__PURE__ */ new Set();
|
|
334
|
-
for (const marketplace of marketplaces) {
|
|
335
|
-
if (!PLUGIN_SEGMENT_PATTERN.test(marketplace.name)) continue;
|
|
336
|
-
for (const summary of marketplace.plugins) {
|
|
337
|
-
const pluginName = pluginSlug(summary, marketplace.name);
|
|
338
|
-
if (!pluginName) continue;
|
|
339
|
-
const id = `${pluginName}@${marketplace.name}`;
|
|
340
|
-
if (ambiguous.has(id)) continue;
|
|
341
|
-
const previous = discovered.get(id);
|
|
342
|
-
const next = {
|
|
343
|
-
id,
|
|
344
|
-
pluginName,
|
|
345
|
-
marketplaceName: marketplace.name,
|
|
346
|
-
installed: summary.installed,
|
|
347
|
-
enabled: summary.enabled,
|
|
348
|
-
available: summary.availability !== "DISABLED_BY_ADMIN" && summary.installPolicy !== "NOT_AVAILABLE",
|
|
349
|
-
...summary.installPolicy ? { installPolicy: summary.installPolicy } : {},
|
|
350
|
-
...summary.authPolicy ? { authPolicy: summary.authPolicy } : {},
|
|
351
|
-
...marketplace.path ? { marketplacePath: marketplace.path } : {},
|
|
352
|
-
...summary.remotePluginId?.trim() ? {
|
|
353
|
-
remotePluginId: summary.remotePluginId.trim(),
|
|
354
|
-
mustShowInstallationInterstitial: summary.mustShowInstallationInterstitial ?? null
|
|
355
|
-
} : {},
|
|
356
|
-
summaryId: summary.id
|
|
357
|
-
};
|
|
358
|
-
const description = pluginDescription(summary);
|
|
359
|
-
if (description) next.description = description;
|
|
360
|
-
if (previous && (previous.marketplacePath !== next.marketplacePath || previous.remotePluginId !== next.remotePluginId)) {
|
|
361
|
-
discovered.delete(id);
|
|
362
|
-
ambiguous.add(id);
|
|
363
|
-
warnings.push(`Multiple discovered plugins share ${id}; installation requires a unique identity.`);
|
|
364
|
-
continue;
|
|
365
|
-
}
|
|
366
|
-
if (!previous) discovered.set(id, next);
|
|
367
|
-
else {
|
|
368
|
-
const preferred = !previous.installed && next.installed || !previous.enabled && next.installed && next.enabled ? next : previous;
|
|
369
|
-
discovered.set(id, {
|
|
370
|
-
...preferred,
|
|
371
|
-
available: previous.available && next.available,
|
|
372
|
-
...preferred.remotePluginId ? { mustShowInstallationInterstitial: previous.mustShowInstallationInterstitial === true || next.mustShowInstallationInterstitial === true ? true : previous.mustShowInstallationInterstitial === false && next.mustShowInstallationInterstitial === false ? false : null } : {},
|
|
373
|
-
...previous.installPolicy === "NOT_AVAILABLE" || next.installPolicy === "NOT_AVAILABLE" ? { installPolicy: "NOT_AVAILABLE" } : {}
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
return {
|
|
379
|
-
plugins: [...discovered.values()].toSorted((left, right) => left.id.localeCompare(right.id)),
|
|
380
|
-
warnings
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
function pluginSlug(summary, marketplaceName) {
|
|
384
|
-
const qualified = parseCodexPluginMarketplaceId(summary.id);
|
|
385
|
-
if (qualified?.marketplaceName === marketplaceName) return qualified.pluginName;
|
|
386
|
-
const identitySegment = summary.id.split("/").at(-1);
|
|
387
|
-
if (identitySegment && PLUGIN_SEGMENT_PATTERN.test(identitySegment)) return identitySegment;
|
|
388
|
-
return PLUGIN_SEGMENT_PATTERN.test(summary.name) ? summary.name : void 0;
|
|
389
|
-
}
|
|
390
|
-
function pluginDescription(summary) {
|
|
391
|
-
const description = asOptionalRecord(summary.interface)?.shortDescription;
|
|
392
|
-
if (typeof description !== "string") return;
|
|
393
|
-
return boundedCatalogText(description) || void 0;
|
|
394
|
-
}
|
|
395
|
-
function boundedCatalogText(value) {
|
|
396
|
-
let sanitized = "";
|
|
397
|
-
for (const character of value) {
|
|
398
|
-
const codePoint = character.codePointAt(0);
|
|
399
|
-
sanitized += codePoint !== void 0 && (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) ? " " : character;
|
|
400
|
-
}
|
|
401
|
-
return sanitized.replace(/\s+/g, " ").trim().slice(0, MAX_PLUGIN_DESCRIPTION_LENGTH);
|
|
402
|
-
}
|
|
403
|
-
//#endregion
|
|
404
|
-
export { hasCodexAdminScope as _, parseCodexPermissionsModeArg as a, setCodexConversationModel as c, stopCodexConversationTurn as d, trackCodexConversationActiveTurn as f, canMutateCodexHost as g, CODEX_NATIVE_EXECUTION_AUTH_ERROR as h, parseCodexFastModeArg as i, setCodexConversationPermissions as l, CODEX_HOST_INSPECTION_AUTH_ERROR as m, parseCodexPluginMarketplaceId as n, readCodexConversationActiveTurn as o, CODEX_FULL_PERMISSIONS_AUTH_ERROR as p, formatPermissionsMode as r, setCodexConversationFastMode as s, discoverCodexMarketplacePlugins as t, steerCodexConversationTurn as u };
|
|
272
|
+
export { setCodexConversationFastMode as a, steerCodexConversationTurn as c, readCodexConversationActiveTurn as i, stopCodexConversationTurn as l, parseCodexFastModeArg as n, setCodexConversationModel as o, parseCodexPermissionsModeArg as r, setCodexConversationPermissions as s, formatPermissionsMode as t, trackCodexConversationActiveTurn as u };
|
|
@@ -2,15 +2,15 @@ import { n as CODEX_APP_SERVER_BINDING_NAMESPACE, t as CODEX_APP_SERVER_BINDING_
|
|
|
2
2
|
import { asNullableRecord, asOptionalRecord, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { listAgentIds, resolveAgentDir, resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
5
|
-
import fs from "node:fs/promises";
|
|
6
5
|
import path from "node:path";
|
|
6
|
+
import fs from "node:fs/promises";
|
|
7
|
+
import { setImmediate } from "node:timers/promises";
|
|
7
8
|
import { canonicalPathFromExistingAncestor, isPathInside } from "openclaw/plugin-sdk/file-access-runtime";
|
|
8
9
|
import { isDeepStrictEqual } from "node:util";
|
|
9
|
-
import { pathExists } from "openclaw/plugin-sdk/security-runtime";
|
|
10
|
-
import { setImmediate } from "node:timers/promises";
|
|
11
|
-
import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
|
|
12
10
|
import { withFileLock } from "openclaw/plugin-sdk/file-lock";
|
|
11
|
+
import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
|
|
13
12
|
import { archiveLegacyStateSource, legacyStateFileExists } from "openclaw/plugin-sdk/runtime-doctor-migrations";
|
|
13
|
+
import { pathExists } from "openclaw/plugin-sdk/security-runtime";
|
|
14
14
|
import { resolveStorePath } from "openclaw/plugin-sdk/session-store-paths";
|
|
15
15
|
//#region extensions/codex/src/migration/session-binding-orphans.ts
|
|
16
16
|
const PAGE_SIZE = 512;
|
|
@@ -391,7 +391,7 @@ async function migrateSource(source, candidates, params, store) {
|
|
|
391
391
|
return await withFileLock(source.sidecarPath, LEGACY_BINDING_LOCK_OPTIONS, async () => {
|
|
392
392
|
const [contents, stat] = await Promise.all([fs.readFile(source.sidecarPath, "utf8"), fs.stat(source.sidecarPath)]);
|
|
393
393
|
const raw = JSON.parse(contents);
|
|
394
|
-
const [{ bindingStoreKey, createStoredCodexAppServerBinding, normalizeStoredCodexAppServerBindingFingerprints, readStoredCodexAppServerBinding }, { legacyCodexConversationBindingId }] = await Promise.all([import("./session-binding-
|
|
394
|
+
const [{ bindingStoreKey, createStoredCodexAppServerBinding, normalizeStoredCodexAppServerBindingFingerprints, readStoredCodexAppServerBinding }, { legacyCodexConversationBindingId }] = await Promise.all([import("./session-binding-CI8UuilT.js").then((n) => n.c), import("./conversation-binding-data-BiodpIzq.js").then((n) => n.t)]);
|
|
395
395
|
const agentId = owner?.agentId ?? (source.agentIds.size === 1 ? [...source.agentIds][0] : void 0);
|
|
396
396
|
const baseStored = createStoredCodexAppServerBinding(raw, {
|
|
397
397
|
now: stat.mtime.toISOString(),
|
|
@@ -1,36 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
import { a as flattenCodexDynamicToolFunctions, o as isJsonObject, r as CODEX_OPENCLAW_DIRECT_DYNAMIC_TOOL_NAMESPACE, x as readCodexPluginConfig, y as isCodexRemoteExecPlacementSandbox } from "./protocol-5bh1G-H7.js";
|
|
2
|
+
import { B as withDynamicToolTranscriptDetails, E as createCodexElicitationResponse, L as resolveCodexToolAbortTerminalReason, R as createFailedDynamicToolResponse, w as readCodexTurn, z as withDynamicToolExecutionState } from "./client-B57KWPQx.js";
|
|
3
|
+
import { o as formatCodexDisplayText } from "./command-formatters-lxlkNZgU.js";
|
|
4
|
+
import { c as itemName, f as shouldClearTerminalPresentationForNativeItem, l as itemStatus, n as auditNativeToolTerminalStatus, r as auditNativeToolUnfinishedStatus, t as auditNativeToolName, x as readItem } from "./event-projector-items-5VhsECCO.js";
|
|
5
|
+
import "./config-oIORaQ5T.js";
|
|
6
6
|
import { r as sanitizeInlineImageDataUrl, t as invalidInlineImageText } from "./image-payload-sanitizer-tupAr-2o.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { h as isCodexNotificationForTurn } from "./attempt-client-cleanup-DKHzbwt5.js";
|
|
8
|
+
import { C as resolveCodexWebSearchPlan, V as emitCodexNativePreToolUseFailureDiagnostic, at as isForcedPrivateQaCodexRuntime, ct as normalizeCodexDynamicToolName, it as filterCodexDynamicToolsForDisabledNativeSurface, rt as filterCodexDynamicTools, st as isSystemAgentOnlyCodexDynamicToolAllowlist } from "./thread-lifecycle-DXl1-I6b.js";
|
|
9
|
+
import { n as resolveCodexNativeExecutionPolicy, r as resolveCodexNodeExecToolOverrides } from "./native-execution-policy-umd0tgh4.js";
|
|
10
|
+
import { a as CODEX_NODE_EXEC_DYNAMIC_TOOL_NAME, c as createNodeExecAliasDynamicTool, i as CODEX_GATEWAY_PROCESS_DYNAMIC_TOOL_NAME, l as isCodexDynamicToolExcluded, o as createGatewayExecProjection, r as CODEX_GATEWAY_EXEC_DYNAMIC_TOOL_NAME, s as createGatewayProcessProjection } from "./provider-capabilities-BvCUL69A.js";
|
|
11
|
+
import { a as requestPluginApprovalOutcome, c as truncateCodexApprovalDisplayText, i as requestPluginApproval, l as waitForPluginApprovalDecision, n as codexApprovalTimeoutText, o as sanitizeCodexApprovalVisibleText, r as mapExecDecisionToOutcome, s as stripDanglingCodexApprovalTerminalSequence, t as approvalRequestExplicitlyUnavailable } from "./plugin-approval-roundtrip-Bz3FT8W5.js";
|
|
12
|
+
import { createRequire } from "node:module";
|
|
10
13
|
import { asNonArrayRecord, asOptionalRecord, isRecord, normalizeOptionalString, normalizeTrimmedStringList, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
11
14
|
import { createHash, randomUUID } from "node:crypto";
|
|
12
15
|
import { asDateTimestampMs } from "openclaw/plugin-sdk/number-runtime";
|
|
13
16
|
import { killProcessTree } from "openclaw/plugin-sdk/process-runtime";
|
|
14
17
|
import { validateJsonSchemaValue } from "openclaw/plugin-sdk/json-schema-runtime";
|
|
15
18
|
import path, { posix } from "node:path";
|
|
16
|
-
import {
|
|
17
|
-
import { HEARTBEAT_RESPONSE_TOOL_NAME, buildAgentHookContextChannelFields, buildEmbeddedAttemptToolRunContext, consumeAdjustedParamsForToolCall, consumePreExecutionBlockedToolCall, createAgentToolResultMiddlewareRunner, createCodexAppServerToolResultExtensionRunner, embeddedAgentLog, extractMessagingToolSend, extractMessagingToolSendResult, extractToolResultMediaArtifact, filterProviderNormalizableTools, filterToolResultMediaUrls, finalizeAgentToolAvailability, finalizeToolTerminalPresentation, formatApprovalDisplayPath, formatToolExecutionErrorMessage, getBeforeToolCallFailureDisposition, getChannelAgentToolMeta, getPluginToolMeta, getPluginToolSideEffectOwnerKey, hasNativeHookRelayInvocation, invokeNativeHookRelay, isDeliveredMessageToolOnlySourceReplyResult, isDeliveredMessagingToolResult, isHostScopedAgentToolActive, isMessagingTool, isMessagingToolSendAction, isReplaySafeToolCall, isSubagentSessionKey, isToolResultError, isToolWrappedWithBeforeToolCallHook, normalizeAgentRuntimeTools, normalizeHeartbeatToolResponse, projectRuntimeToolInputSchema, resolveAttemptSpawnWorkspaceDir, resolveModelAuthMode, resolveNativeHookRelayDeferredToolApproval, resolveToolExecutionErrorKind, resolveToolResultFailureKind, runAgentHarnessAfterToolCallHook, sanitizeToolResult, setBeforeToolCallDiagnosticsEnabled, supportsModelTools, wrapToolWithBeforeToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
18
|
-
import { isPathStrictlyInside, root } from "openclaw/plugin-sdk/file-access-runtime";
|
|
19
|
-
import { resolveAgentDir as resolveAgentDir$1 } from "openclaw/plugin-sdk/agent-runtime";
|
|
20
|
-
import { formatErrorMessage as formatErrorMessage$1, redactSensitiveText } from "openclaw/plugin-sdk/security-runtime";
|
|
21
|
-
import { SsrFBlockedError, isBlockedHostnameOrIp } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
22
|
-
import { spawn } from "node:child_process";
|
|
19
|
+
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
23
20
|
import { once } from "node:events";
|
|
21
|
+
import { spawn } from "node:child_process";
|
|
24
22
|
import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
25
23
|
import { DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS, estimateToolResultTextChars, resolveLiveToolResultMaxChars, sliceToolResultTextToBudget, sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
24
|
+
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
25
|
+
import { createStageTimingTracker, formatStageTimings } from "openclaw/plugin-sdk/time-runtime";
|
|
26
|
+
import { isPathStrictlyInside, root } from "openclaw/plugin-sdk/file-access-runtime";
|
|
27
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
28
|
+
import { resolveAgentDir } from "openclaw/plugin-sdk/agent-runtime";
|
|
29
|
+
import { HEARTBEAT_RESPONSE_TOOL_NAME, buildAgentHookContextChannelFields, buildEmbeddedAttemptToolRunContext, consumeAdjustedParamsForToolCall, consumePreExecutionBlockedToolCall, createAgentToolResultMiddlewareRunner, createCodexAppServerToolResultExtensionRunner, embeddedAgentLog, extractMessagingToolSend, extractMessagingToolSendResult, extractToolResultMediaArtifact, filterProviderNormalizableTools, filterToolResultMediaUrls, finalizeAgentToolAvailability, finalizeToolTerminalPresentation, formatApprovalDisplayPath, formatToolExecutionErrorMessage, getBeforeToolCallFailureDisposition, getChannelAgentToolMeta, getPluginToolMeta, getPluginToolSideEffectOwnerKey, hasNativeHookRelayInvocation, invokeNativeHookRelay, isDeliveredMessageToolOnlySourceReplyResult, isDeliveredMessagingToolResult, isHostScopedAgentToolActive, isMessagingTool, isMessagingToolSendAction, isReplaySafeToolCall, isSubagentSessionKey, isToolResultError, isToolWrappedWithBeforeToolCallHook, normalizeAgentRuntimeTools, normalizeHeartbeatToolResponse, projectRuntimeToolInputSchema, resolveAttemptSpawnWorkspaceDir, resolveModelAuthMode, resolveNativeHookRelayDeferredToolApproval, resolveToolExecutionErrorKind, resolveToolResultFailureKind, runAgentHarnessAfterToolCallHook, sanitizeToolResult, setBeforeToolCallDiagnosticsEnabled, supportsModelTools, wrapToolWithBeforeToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
30
|
+
import { formatErrorMessage as formatErrorMessage$2, redactSensitiveText } from "openclaw/plugin-sdk/security-runtime";
|
|
26
31
|
import { emitTrustedDiagnosticEvent } from "openclaw/plugin-sdk/diagnostic-runtime";
|
|
27
32
|
import { isIP } from "node:net";
|
|
28
|
-
import { WebSocketServer } from "ws";
|
|
29
|
-
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
30
33
|
import { redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
31
34
|
import { formatMcpCodexApprovalRemedy, requiresMcpCodexToolApproval, resolveCodexScheduledToolProjectionFactory, resolveProjectedMcpCodexToolApprovalMode, runWithCronCreatorAuthorityCapabilityResolver } from "openclaw/plugin-sdk/codex-mcp-projection";
|
|
32
35
|
import { buildRemoteCommand, isToolAllowed, sanitizeEnvVars } from "openclaw/plugin-sdk/sandbox";
|
|
33
|
-
import {
|
|
36
|
+
import { SsrFBlockedError, isBlockedHostnameOrIp } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
34
37
|
import { saveMediaBuffer } from "openclaw/plugin-sdk/media-store";
|
|
35
38
|
import { getMediaDir } from "openclaw/plugin-sdk/media-runtime";
|
|
36
39
|
import { consumeTrustedToolNoStartError, copyInternalToolResultState, getCoreTtsToolResultMediaUrls } from "openclaw/plugin-sdk/agent-harness-tool-runtime";
|
|
@@ -156,26 +159,10 @@ const CODEX_DYNAMIC_TOOL_BUILD_WARN_TOTAL_MS = 1e3;
|
|
|
156
159
|
const CODEX_DYNAMIC_TOOL_BUILD_WARN_STAGE_MS = 500;
|
|
157
160
|
/** Captures bounded preparation stages before a slow turn needs diagnosis. */
|
|
158
161
|
function createCodexDynamicToolBuildStageTracker() {
|
|
159
|
-
const
|
|
160
|
-
let previousAt = startedAt;
|
|
161
|
-
const stages = [];
|
|
162
|
-
const toMs = (value) => Math.max(0, Math.round(value));
|
|
162
|
+
const { mark, snapshot } = createStageTimingTracker();
|
|
163
163
|
return {
|
|
164
|
-
mark
|
|
165
|
-
|
|
166
|
-
stages.push({
|
|
167
|
-
name,
|
|
168
|
-
durationMs: toMs(currentAt - previousAt),
|
|
169
|
-
elapsedMs: toMs(currentAt - startedAt)
|
|
170
|
-
});
|
|
171
|
-
previousAt = currentAt;
|
|
172
|
-
},
|
|
173
|
-
snapshot() {
|
|
174
|
-
return {
|
|
175
|
-
totalMs: toMs(Date.now() - startedAt),
|
|
176
|
-
stages: stages.slice()
|
|
177
|
-
};
|
|
178
|
-
}
|
|
164
|
+
mark,
|
|
165
|
+
snapshot
|
|
179
166
|
};
|
|
180
167
|
}
|
|
181
168
|
/** Returns true when dynamic-tool construction is slow enough to warrant a warning log. */
|
|
@@ -186,7 +173,7 @@ function shouldWarnCodexDynamicToolBuildStageSummary(summary, profilerEnabled =
|
|
|
186
173
|
}
|
|
187
174
|
/** Formats per-stage timings into the compact form used by Codex app-server logs. */
|
|
188
175
|
function formatCodexDynamicToolBuildStageSummary(summary) {
|
|
189
|
-
return summary.stages
|
|
176
|
+
return formatStageTimings(summary.stages);
|
|
190
177
|
}
|
|
191
178
|
/** Builds, filters, and normalizes Codex-compatible runtime tools for a single turn. */
|
|
192
179
|
async function buildDynamicTools(input) {
|
|
@@ -210,7 +197,7 @@ async function buildDynamicTools(input) {
|
|
|
210
197
|
}
|
|
211
198
|
const toolBuildStages = createCodexDynamicToolBuildStageTracker();
|
|
212
199
|
const modelHasVision = params.model.input?.includes("image") ?? false;
|
|
213
|
-
const agentDir = params.agentDir ?? resolveAgentDir
|
|
200
|
+
const agentDir = params.agentDir ?? resolveAgentDir(params.config ?? {}, input.sessionAgentId);
|
|
214
201
|
const injectedOpenClawCodingToolsFactory = dynamicToolBuildState.openClawCodingToolsFactory;
|
|
215
202
|
const nativeExecutionPolicy = resolveCodexNativeExecutionPolicyForRun(params, {
|
|
216
203
|
agentId: input.policyAgentId,
|
|
@@ -248,31 +235,13 @@ async function buildDynamicTools(input) {
|
|
|
248
235
|
send: params.onToolResult,
|
|
249
236
|
...params.messageChannel ? { messageChannel: params.messageChannel } : {}
|
|
250
237
|
} } : {},
|
|
251
|
-
clientCaps: params.clientCaps,
|
|
252
|
-
chatType: params.chatType,
|
|
253
|
-
agentAccountId: params.agentAccountId,
|
|
254
|
-
messageTo: params.messageTo,
|
|
255
|
-
messageThreadId: params.messageThreadId,
|
|
256
|
-
nativeChannelId: params.chatId,
|
|
257
|
-
messageActionTurnCapability: params.messageActionTurnCapability,
|
|
258
|
-
groupId: params.groupId,
|
|
259
|
-
groupChannel: params.groupChannel,
|
|
260
|
-
groupSpace: params.groupSpace,
|
|
261
|
-
spawnedBy: params.spawnedBy,
|
|
262
|
-
senderId: params.senderId,
|
|
263
|
-
senderName: params.senderName,
|
|
264
|
-
senderUsername: params.senderUsername,
|
|
265
|
-
senderE164: params.senderE164,
|
|
266
|
-
senderIsOwner: params.senderIsOwner,
|
|
267
238
|
inputProvenance: params.inputProvenance,
|
|
268
239
|
trustedInternalHandoff: params.trustedInternalHandoff,
|
|
269
|
-
scheduledToolPolicy: params.scheduledToolPolicy,
|
|
270
240
|
allowGatewaySubagentBinding: params.allowGatewaySubagentBinding || isForcedPrivateQaCodexRuntime(),
|
|
271
241
|
sessionKey: input.sandboxSessionKey,
|
|
272
242
|
runSessionKey: params.sessionKey && params.sessionKey !== input.sandboxSessionKey ? params.sessionKey : void 0,
|
|
273
243
|
sessionId: params.sessionId,
|
|
274
244
|
runId: params.runId,
|
|
275
|
-
approvalReviewerDeviceId: params.approvalReviewerDeviceId,
|
|
276
245
|
agentDir,
|
|
277
246
|
preparedModelRuntime: params.preparedModelRuntime,
|
|
278
247
|
cwd: input.effectiveCwd ?? input.effectiveWorkspace,
|
|
@@ -297,25 +266,18 @@ async function buildDynamicTools(input) {
|
|
|
297
266
|
modelAuthMode: resolveModelAuthMode(params.model.provider, params.config, params.toolAuthProfileStore ?? params.authProfileStore, { workspaceDir: input.effectiveWorkspace }),
|
|
298
267
|
suppressManagedWebSearch: false,
|
|
299
268
|
webFetchHostnameAllowlistRef,
|
|
300
|
-
currentChannelId: params.currentChannelId,
|
|
301
|
-
currentMessagingTarget: params.currentMessagingTarget,
|
|
302
269
|
hookChannelId: resolveCodexAppServerHookChannelId(params, input.sandboxSessionKey),
|
|
303
|
-
currentThreadTs: params.currentThreadTs,
|
|
304
|
-
currentMessageId: params.currentMessageId,
|
|
305
|
-
replyToMode: params.replyToMode,
|
|
306
|
-
hasRepliedRef: params.hasRepliedRef,
|
|
307
270
|
modelHasVision,
|
|
308
271
|
computerContextEpoch: input.computerContextEpoch,
|
|
272
|
+
oneShotCliRun: params.oneShotCliRun,
|
|
309
273
|
registerRunCleanup: input.registerRunCleanup,
|
|
310
274
|
requireExplicitMessageTarget: params.requireExplicitMessageTarget ?? isSubagentSessionKey(params.sessionKey),
|
|
311
|
-
sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
|
|
312
|
-
taskSuggestionDeliveryMode: params.taskSuggestionDeliveryMode,
|
|
313
275
|
disableMessageTool: input.ignoreDisableMessageTool ? false : params.disableMessageTool,
|
|
314
276
|
forceMessageTool: shouldForceMessageTool(messagePolicyParams),
|
|
315
277
|
enableHeartbeatTool: params.trigger === "heartbeat" || input.forceHeartbeatTool === true,
|
|
316
278
|
forceHeartbeatTool: params.trigger === "heartbeat" || input.forceHeartbeatTool === true,
|
|
317
279
|
onYield: (message, acknowledgment) => {
|
|
318
|
-
input.onYieldDetected(acknowledgment);
|
|
280
|
+
input.onYieldDetected(message, acknowledgment);
|
|
319
281
|
input.onCodexAppServerEvent?.({
|
|
320
282
|
stream: "codex_app_server.tool",
|
|
321
283
|
data: {
|
|
@@ -335,6 +297,7 @@ async function buildDynamicTools(input) {
|
|
|
335
297
|
cronCreatorToolAllowlistCaptureRef: input.cronCreatorToolAllowlistCaptureRef,
|
|
336
298
|
cronCreatorAuthorityUnavailableReason: input.cronCreatorAuthorityUnavailableReason
|
|
337
299
|
};
|
|
300
|
+
input.onMessageToolTargetResolved?.(options.requireExplicitMessageTarget === true);
|
|
338
301
|
const buildOpenClawCodingTools = () => {
|
|
339
302
|
const bindingOptions = { cwd: input.effectiveCwd ?? input.effectiveWorkspace };
|
|
340
303
|
if (injectedOpenClawCodingToolsFactory) return params.hostCapabilities.bindToolSurface(injectedOpenClawCodingToolsFactory(options), bindingOptions);
|
|
@@ -1157,7 +1120,7 @@ const CODEX_NODE_HTTP_CREDENTIAL_FIELD_NAME_PATTERN = /^(?:(?:[a-z\d]+_)*(?:toke
|
|
|
1157
1120
|
const nodeExecServerTextDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
1158
1121
|
/** Produces the bounded, redacted terminal failure shared by pending and claimed node leases. */
|
|
1159
1122
|
function createCodexNodeExecServerDisconnectError(reason, cause) {
|
|
1160
|
-
const detail = cause === void 0 ? "" : `: ${truncateUtf16Safe(redactSensitiveText(formatErrorMessage$
|
|
1123
|
+
const detail = cause === void 0 ? "" : `: ${truncateUtf16Safe(redactSensitiveText(formatErrorMessage$2(cause), { mode: "tools" }), CODEX_NODE_EXEC_SERVER_MAX_FAILURE_DETAIL_CHARS)}`;
|
|
1161
1124
|
return /* @__PURE__ */ new Error(`Codex execution node disconnected; start a fresh attempt. (${reason}${detail})`);
|
|
1162
1125
|
}
|
|
1163
1126
|
/** Relays one authorized, single-use Codex exec-server channel without interpreting its protocol. */
|
|
@@ -1451,6 +1414,10 @@ const sandboxExecServerRegistry = {
|
|
|
1451
1414
|
}
|
|
1452
1415
|
};
|
|
1453
1416
|
//#endregion
|
|
1417
|
+
//#region extensions/codex/src/app-server/sandbox-exec-server.websocket.ts
|
|
1418
|
+
const require = createRequire(import.meta.url);
|
|
1419
|
+
const websocket = require(path.join(path.dirname(require.resolve("ws/package.json")), "index.js"));
|
|
1420
|
+
//#endregion
|
|
1454
1421
|
//#region extensions/codex/src/app-server/sandbox-exec-server/json-rpc.ts
|
|
1455
1422
|
/** JSON-RPC error code used when a sandbox filesystem resource does not exist. */
|
|
1456
1423
|
const JSON_RPC_NOT_FOUND = -32004;
|
|
@@ -3129,7 +3096,7 @@ async function startOpenClawExecServer(sandbox) {
|
|
|
3129
3096
|
fsBridge
|
|
3130
3097
|
};
|
|
3131
3098
|
}
|
|
3132
|
-
const server = new WebSocketServer({
|
|
3099
|
+
const server = new websocket.WebSocketServer({
|
|
3133
3100
|
host: "127.0.0.1",
|
|
3134
3101
|
port: 0,
|
|
3135
3102
|
maxPayload: connection.kind === "node" ? CODEX_NODE_EXEC_SERVER_MAX_MESSAGE_BYTES : CODEX_SANDBOX_EXEC_SERVER_MAX_INBOUND_MESSAGE_BYTES
|
|
@@ -4696,6 +4663,64 @@ function readFirstString$1(record, keys) {
|
|
|
4696
4663
|
}
|
|
4697
4664
|
}
|
|
4698
4665
|
//#endregion
|
|
4666
|
+
//#region extensions/codex/src/app-server/dynamic-tool-automations-allowlist.ts
|
|
4667
|
+
function createCodexAutomationsToolsAllowResolver(specs) {
|
|
4668
|
+
const names = /* @__PURE__ */ new Set();
|
|
4669
|
+
const qualifiedNames = /* @__PURE__ */ new Map();
|
|
4670
|
+
for (const spec of specs) {
|
|
4671
|
+
if (spec.type === "function") {
|
|
4672
|
+
names.add(spec.name);
|
|
4673
|
+
continue;
|
|
4674
|
+
}
|
|
4675
|
+
for (const tool of spec.tools) {
|
|
4676
|
+
names.add(tool.name);
|
|
4677
|
+
const separator = spec.name.endsWith("_") || tool.name.startsWith("_") ? "" : "__";
|
|
4678
|
+
qualifiedNames.set(`${spec.name}${separator}${tool.name}`, tool.name);
|
|
4679
|
+
}
|
|
4680
|
+
}
|
|
4681
|
+
function resolveList(value) {
|
|
4682
|
+
const resolved = value.map((name) => typeof name !== "string" || names.has(name) ? name : qualifiedNames.get(name) ?? name);
|
|
4683
|
+
return resolved.every((name, index) => name === value[index]) ? value : resolved;
|
|
4684
|
+
}
|
|
4685
|
+
function resolvePayload(value) {
|
|
4686
|
+
if (!isJsonObject(value) || !Array.isArray(value.toolsAllow)) return value;
|
|
4687
|
+
const toolsAllow = resolveList(value.toolsAllow);
|
|
4688
|
+
return toolsAllow === value.toolsAllow ? value : {
|
|
4689
|
+
...value,
|
|
4690
|
+
toolsAllow
|
|
4691
|
+
};
|
|
4692
|
+
}
|
|
4693
|
+
function resolveJobFields(value, paddedKeys) {
|
|
4694
|
+
let resolved = value;
|
|
4695
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
4696
|
+
const field = paddedKeys ? key.trim() : key;
|
|
4697
|
+
if (key !== field && Object.hasOwn(value, field)) continue;
|
|
4698
|
+
const next = field === "toolsAllow" && Array.isArray(entry) ? resolveList(entry) : field === "payload" || field === "namePayload" ? resolvePayload(entry) : entry;
|
|
4699
|
+
if (next !== entry) {
|
|
4700
|
+
if (resolved === value) resolved = { ...value };
|
|
4701
|
+
resolved[key] = next;
|
|
4702
|
+
}
|
|
4703
|
+
}
|
|
4704
|
+
return resolved;
|
|
4705
|
+
}
|
|
4706
|
+
return (args) => {
|
|
4707
|
+
if (!isJsonObject(args)) return args;
|
|
4708
|
+
const job = args.job;
|
|
4709
|
+
if (!job || isJsonObject(job) && Object.keys(job).length === 0) return resolveJobFields(args, false);
|
|
4710
|
+
if (!isJsonObject(job)) return args;
|
|
4711
|
+
const wrapper = isJsonObject(job.data) ? "data" : isJsonObject(job.job) ? "job" : void 0;
|
|
4712
|
+
const wrapped = wrapper ? job[wrapper] : void 0;
|
|
4713
|
+
const resolved = wrapper && isJsonObject(wrapped) ? {
|
|
4714
|
+
...job,
|
|
4715
|
+
[wrapper]: resolveJobFields(wrapped, true)
|
|
4716
|
+
} : resolveJobFields(job, true);
|
|
4717
|
+
return resolved === job ? args : {
|
|
4718
|
+
...args,
|
|
4719
|
+
job: resolved
|
|
4720
|
+
};
|
|
4721
|
+
};
|
|
4722
|
+
}
|
|
4723
|
+
//#endregion
|
|
4699
4724
|
//#region extensions/codex/src/app-server/dynamic-tool-catalog.ts
|
|
4700
4725
|
/** Namespace attached to OpenClaw-owned dynamic tools exposed to Codex. */
|
|
4701
4726
|
const CODEX_OPENCLAW_DYNAMIC_TOOL_NAMESPACE = "openclaw";
|
|
@@ -5155,6 +5180,12 @@ function createCodexDynamicToolBridge(params) {
|
|
|
5155
5180
|
const legacyExtensionRunner = createCodexAppServerToolResultExtensionRunner(toolResultHookContext);
|
|
5156
5181
|
const executionSnapshotStates = /* @__PURE__ */ new Map();
|
|
5157
5182
|
const directToolNames = params.directToolNames;
|
|
5183
|
+
const specs = inheritedSpecs ?? createCodexDynamicToolSpecs({
|
|
5184
|
+
entries: registeredSpecTools,
|
|
5185
|
+
loading: params.loading ?? "searchable",
|
|
5186
|
+
directToolNames
|
|
5187
|
+
});
|
|
5188
|
+
const resolveAutomationsToolsAllow = createCodexAutomationsToolsAllowResolver(specs);
|
|
5158
5189
|
let readRemoteWorkspaceFile;
|
|
5159
5190
|
return {
|
|
5160
5191
|
availableTools: availableTools.map((entry) => entry.tool),
|
|
@@ -5170,11 +5201,7 @@ function createCodexDynamicToolBridge(params) {
|
|
|
5170
5201
|
loading: params.loading ?? "searchable",
|
|
5171
5202
|
directToolNames
|
|
5172
5203
|
}),
|
|
5173
|
-
specs
|
|
5174
|
-
entries: registeredSpecTools,
|
|
5175
|
-
loading: params.loading ?? "searchable",
|
|
5176
|
-
directToolNames
|
|
5177
|
-
}),
|
|
5204
|
+
specs,
|
|
5178
5205
|
resultContentSourceForTool: (toolName) => toolMap.get(toolName)?.tool.resultContentSource,
|
|
5179
5206
|
sideEffectOwnerKeyForTool: (toolName) => {
|
|
5180
5207
|
const tool = toolMap.get(toolName)?.tool;
|
|
@@ -5211,7 +5238,7 @@ function createCodexDynamicToolBridge(params) {
|
|
|
5211
5238
|
});
|
|
5212
5239
|
}
|
|
5213
5240
|
const { tool, name: toolName } = toolEntry;
|
|
5214
|
-
const rawArguments = call.arguments;
|
|
5241
|
+
const rawArguments = toolName === "automations" ? resolveAutomationsToolsAllow(call.arguments) : call.arguments;
|
|
5215
5242
|
const args = asNonArrayRecord(rawArguments);
|
|
5216
5243
|
const startedAt = Date.now();
|
|
5217
5244
|
const signal = composeAbortSignals(params.signal, options?.signal);
|
|
@@ -5477,7 +5504,8 @@ function notifyAgentToolResult(observer, toolName, result, isError) {
|
|
|
5477
5504
|
isError
|
|
5478
5505
|
});
|
|
5479
5506
|
} catch (error) {
|
|
5480
|
-
|
|
5507
|
+
const message = formatToolExecutionErrorMessage(error, "Unknown error");
|
|
5508
|
+
embeddedAgentLog.warn(`onAgentToolResult handler failed: tool=${toolName} error=${message}`);
|
|
5481
5509
|
}
|
|
5482
5510
|
}
|
|
5483
5511
|
function failedToolResult(message, status = "failed") {
|
|
@@ -5684,7 +5712,36 @@ function withDynamicToolAsyncStarted(response, asyncStarted) {
|
|
|
5684
5712
|
function normalizeToolResultMaxChars(maxChars) {
|
|
5685
5713
|
return typeof maxChars === "number" && Number.isFinite(maxChars) && maxChars > 0 ? Math.floor(maxChars) : DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS;
|
|
5686
5714
|
}
|
|
5687
|
-
function
|
|
5715
|
+
function sanitizeToolTextRuns(rawContent) {
|
|
5716
|
+
const content = [];
|
|
5717
|
+
for (let index = 0; index < rawContent.length;) {
|
|
5718
|
+
const item = rawContent[index];
|
|
5719
|
+
if (item.type !== "text") {
|
|
5720
|
+
content.push(item);
|
|
5721
|
+
index += 1;
|
|
5722
|
+
continue;
|
|
5723
|
+
}
|
|
5724
|
+
const textRun = [];
|
|
5725
|
+
while (index < rawContent.length) {
|
|
5726
|
+
const next = rawContent[index];
|
|
5727
|
+
if (next.type !== "text") break;
|
|
5728
|
+
textRun.push(next);
|
|
5729
|
+
index += 1;
|
|
5730
|
+
}
|
|
5731
|
+
const sanitizedText = sanitizeToolResult(textRun.map((entry) => entry.text).join(""));
|
|
5732
|
+
let offset = 0;
|
|
5733
|
+
content.push(...textRun.map((entry, runIndex) => {
|
|
5734
|
+
const targetEnd = runIndex === textRun.length - 1 ? sanitizedText.length : Math.min(sanitizedText.length, offset + entry.text.length);
|
|
5735
|
+
const text = sliceUtf16Safe(sanitizedText, offset, targetEnd);
|
|
5736
|
+
const sanitized = Object.assign({}, entry, { text });
|
|
5737
|
+
offset += text.length;
|
|
5738
|
+
return sanitized;
|
|
5739
|
+
}));
|
|
5740
|
+
}
|
|
5741
|
+
return content;
|
|
5742
|
+
}
|
|
5743
|
+
function convertToolContents(rawContent, toolResultMaxChars = DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS) {
|
|
5744
|
+
const content = sanitizeToolTextRuns(rawContent);
|
|
5688
5745
|
const maxChars = normalizeToolResultMaxChars(toolResultMaxChars);
|
|
5689
5746
|
const totalTextChars = content.reduce((total, item) => total + (item.type === "text" ? item.text.length : 0), 0);
|
|
5690
5747
|
if (content.reduce((total, item) => total + (item.type === "text" ? estimateToolResultTextChars(item.text) : 0), 0) <= maxChars) return content.flatMap(convertToolContent);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as sessionBindingIdentity } from "./session-binding-record-
|
|
2
|
-
import { _ as retainSharedCodexAppServerClientByInstanceId } from "./shared-client-
|
|
3
|
-
import "./session-binding-
|
|
1
|
+
import { l as sessionBindingIdentity } from "./session-binding-record-Bcvslnhf.js";
|
|
2
|
+
import { _ as retainSharedCodexAppServerClientByInstanceId } from "./shared-client-CscigXXL.js";
|
|
3
|
+
import "./session-binding-CI8UuilT.js";
|
|
4
4
|
import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
5
|
import { assignMcpCatalogSafeServerNames } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
6
6
|
//#region extensions/codex/src/app-server/effective-mcp-catalog.ts
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { agentHarnessStructuredInput } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
2
2
|
//#region extensions/codex/src/app-server/elicitation-input.ts
|
|
3
|
-
/**
|
|
3
|
+
/** Compiles a validated Codex input snapshot before it enters the per-turn queue. */
|
|
4
4
|
function compileCodexOrdinaryElicitation(params) {
|
|
5
|
-
|
|
6
|
-
const snapshot = agentHarnessStructuredInput.snapshot(params.value);
|
|
7
|
-
if (!agentHarnessStructuredInput.isRecord(snapshot)) return {
|
|
8
|
-
kind: "compiled",
|
|
9
|
-
input: {
|
|
10
|
-
kind: "unsupported",
|
|
11
|
-
message: "OpenClaw declined a malformed or over-limit MCP elicitation request."
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
const requestTurnId = readValue(snapshot, "turnId");
|
|
5
|
+
const requestTurnId = readValue(params.snapshot, "turnId");
|
|
15
6
|
if (typeof requestTurnId === "string" && requestTurnId !== params.turnId) return { kind: "ignored" };
|
|
16
7
|
if (requestTurnId !== null && typeof requestTurnId !== "string") return {
|
|
17
8
|
kind: "compiled",
|
|
@@ -20,13 +11,13 @@ function compileCodexOrdinaryElicitation(params) {
|
|
|
20
11
|
message: "OpenClaw declined an MCP elicitation with invalid turn correlation."
|
|
21
12
|
}
|
|
22
13
|
};
|
|
23
|
-
const mode = readCodexElicitationString(snapshot, "mode");
|
|
14
|
+
const mode = readCodexElicitationString(params.snapshot, "mode");
|
|
24
15
|
if (mode === "url") return {
|
|
25
16
|
kind: "compiled",
|
|
26
17
|
input: agentHarnessStructuredInput.compileUrl({
|
|
27
|
-
url: readValue(snapshot, "url"),
|
|
28
|
-
elicitationId: readValue(snapshot, "elicitationId"),
|
|
29
|
-
message: readValue(snapshot, "message"),
|
|
18
|
+
url: readValue(params.snapshot, "url"),
|
|
19
|
+
elicitationId: readValue(params.snapshot, "elicitationId"),
|
|
20
|
+
message: readValue(params.snapshot, "message"),
|
|
30
21
|
fallbackMessage: "Codex provided a URL",
|
|
31
22
|
protocolName: "MCP"
|
|
32
23
|
})
|
|
@@ -41,8 +32,8 @@ function compileCodexOrdinaryElicitation(params) {
|
|
|
41
32
|
return {
|
|
42
33
|
kind: "compiled",
|
|
43
34
|
input: agentHarnessStructuredInput.compileForm({
|
|
44
|
-
schema: readValue(snapshot, "requestedSchema"),
|
|
45
|
-
message: readCodexElicitationString(snapshot, "message"),
|
|
35
|
+
schema: readValue(params.snapshot, "requestedSchema"),
|
|
36
|
+
message: readCodexElicitationString(params.snapshot, "message"),
|
|
46
37
|
fallbackMessage: "Codex needs input",
|
|
47
38
|
options: {
|
|
48
39
|
protocolName: mode === "openai/form" ? "OpenAI" : "MCP",
|
|
@@ -62,10 +53,5 @@ function readCodexElicitationString(record, key) {
|
|
|
62
53
|
const value = readValue(record, key);
|
|
63
54
|
return typeof value === "string" ? value : void 0;
|
|
64
55
|
}
|
|
65
|
-
function readRawOwnString(value, key) {
|
|
66
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
67
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
68
|
-
return descriptor && "value" in descriptor && typeof descriptor.value === "string" ? descriptor.value : void 0;
|
|
69
|
-
}
|
|
70
56
|
//#endregion
|
|
71
57
|
export { compileCodexOrdinaryElicitation };
|