@openclaw/codex 2026.9.2 → 2026.9.3
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 +14 -19
- package/dist/apply-B6el6hdO.js +357 -0
- package/dist/{attempt-client-cleanup-Bp1ZOnk2.js → attempt-client-cleanup-D6cR54TV.js} +39 -19
- package/dist/{attempt-context-CSazkWns.js → attempt-context-AO4DSjE0.js} +8 -6
- package/dist/{event-projector-usage-ZqEVbAEY.js → attempt-notifications--H8zXR5-.js} +3 -106
- package/dist/auth-cache-key-Kq6oerr6.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-QqgcPCgk.js +60 -0
- package/dist/{bounded-turn-DxGJRYbY.js → bounded-turn-lRpmZHFv.js} +25 -122
- package/dist/build-state-6RL6qohz.js +19 -0
- package/dist/{capabilities-B1mgvpP8.js → capabilities-BeqLPbtM.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/client-BEKu4yDx.js +3983 -0
- package/dist/command-dispatch-CisT9Jqq.js +21 -0
- package/dist/{command-formatters-DSbGMXA0.js → command-formatters-DeTfrapr.js} +2 -2
- package/dist/{command-handlers-DOJvGv6-.js → command-handlers-BfIsJEuA.js} +31 -21
- package/dist/command-rpc-BMqRQOFX.js +226 -0
- package/dist/{compact-Y_xBqrHN.js → compact-CGJZ2rlb.js} +19 -14
- package/dist/config-JDfTI4VI.js +106 -0
- package/dist/{config-CyapYSji.js → config-options-jnIFvwxD.js} +204 -592
- package/dist/config-runtime-BWf6JLWG.js +11 -0
- package/dist/conversation-binding-CxOlHiix.js +889 -0
- package/dist/{plugin-marketplace-discovery-B7gHXJ3d.js → conversation-control-CUCrSIQI.js} +10 -142
- package/dist/doctor-contract-api.js +5 -5
- package/dist/{dynamic-tools-BwpvTxaX.js → dynamic-tools-D-JBoaLt.js} +66 -70
- package/dist/{effective-mcp-catalog-CY9Jn4bA.js → effective-mcp-catalog-J_5Ep5Um.js} +3 -3
- package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
- package/dist/ephemeral-turn-DSwzP8YY.js +101 -0
- package/dist/{event-projector-assistant-message-B9kp6iGC.js → event-projector-assistant-message-BmBM4qBV.js} +12 -25
- package/dist/event-projector-usage-CIyrYYid.js +102 -0
- package/dist/{harness-Czh2Sdoc.js → harness-FR6eQgyO.js} +31 -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 +411 -2875
- package/dist/{isolated-completion-CRh-51AK.js → isolated-completion-DHBefrzg.js} +7 -4
- package/dist/launch-args-RXQwn8zV.js +90 -0
- package/dist/{managed-binary-DcpnJF9x.js → managed-binary-DrjjRRUD.js} +4 -103
- package/dist/managed-thread-store-D1t5jh3G.js +66 -0
- package/dist/media-understanding-provider.js +4 -1
- package/dist/{model-catalog-DT5vo6qo.js → model-catalog-B_6M04Wo.js} +6 -5
- package/dist/{models-CcrgSMQR.js → models-P9k2qAof.js} +3 -3
- package/dist/native-execution-policy-umd0tgh4.js +128 -0
- package/dist/{native-subagent-monitor-B3bvQGcg.js → native-subagent-monitor-BbCUKRwC.js} +69 -42
- package/dist/node-cli-sessions-rj0ysJwM.js +527 -0
- package/dist/{node-exec-server.runtime-nfbUOtUB.js → node-exec-server.runtime-BY_ctYnT.js} +53 -22
- package/dist/plan-BMJdMOEF.js +711 -0
- package/dist/plugin-activation-BQK-f5sV.js +133 -0
- package/dist/{thread-resume-BLgqkUc1.js → plugin-app-cache-key-CdSQzWyX.js} +4 -52
- package/dist/{plugin-approval-roundtrip-aQVdyL5g.js → plugin-approval-roundtrip-DeW95wB5.js} +1 -1
- package/dist/plugin-inventory-CoRCzWW4.js +325 -0
- package/dist/plugin-marketplace-discovery-3akBizzF.js +134 -0
- package/dist/{plugin-metadata-cache-BwCLTY_U.js → plugin-metadata-cache-DgNfRAGA.js} +13 -9
- package/dist/protocol-CAAcVIKF.js +275 -0
- package/dist/{provider-capabilities-BpG9Ltc5.js → provider-capabilities-W4tfK5Y5.js} +2 -2
- package/dist/{rate-limits-Fx_l4eNa.js → rate-limits-Bqnx1N4z.js} +1 -1
- package/dist/request-CGvGOpeR.js +198 -0
- package/dist/{run-attempt-BzthFQSM.js → run-attempt-DwKds3DN.js} +589 -373
- package/dist/{runtime-artifact-Bh_gf6-t.js → runtime-artifact-T-NwqeSH.js} +27 -27
- package/dist/sandbox-guard-BcT66fWy.js +165 -0
- package/dist/{session-binding-4Ki04sW-.js → session-binding-CKSepwIC.js} +29 -47
- package/dist/{session-binding-record-CyaXZvTe.js → session-binding-record-CaZjYwNS.js} +11 -25
- package/dist/session-catalog-HaDcp7Sv.js +1533 -0
- package/dist/session-catalog-adoption-BKLtSrwi.js +251 -0
- package/dist/session-catalog-archive-D0i2pGj2.js +56 -0
- package/dist/session-catalog-home-id-D7-aLiNt.js +190 -0
- package/dist/session-catalog-node-adoption-BUuDYY8R.js +182 -0
- package/dist/session-catalog-node-continue-CBtc4wkI.js +238 -0
- package/dist/session-catalog-parsing-CdD3JhdM.js +280 -0
- package/dist/session-catalog-provenance-DkJHo735.js +124 -0
- package/dist/{session-cli-BjLhpmS1.js → session-cli-CbgaHh0f.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-DFN7sWRU.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-zZVcx0ME.js → session-history.worker-CNEvGaU5.js} +58 -51
- package/dist/session-history.worker.js +1 -1
- package/dist/{session-initialization-BCFVnLL4.js → session-initialization-Jo86C60I.js} +2 -2
- package/dist/{session-permission-policy-BaueHmSj.js → session-permission-policy-B22InTp_.js} +4 -7
- package/dist/{session-retirement-DNdmYdFc.js → session-retirement-BSNG_mhf.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-BuLUrZl2.js} +7 -6
- package/dist/shared-client-CVhez2Uo.js +2911 -0
- package/dist/{side-question-B6DWAw1A.js → side-question-DLbr2vUU.js} +64 -169
- package/dist/source-Da-h6f7e.js +518 -0
- package/dist/thread-archive-guard-D1bP04Tf.js +53 -0
- package/dist/{thread-lifecycle-DPK30jad.js → thread-lifecycle-D1pzRwHB.js} +112 -616
- package/dist/{thread-ownership-CbucAmmp.js → thread-ownership-D6oASVRu.js} +13 -15
- package/dist/thread-policy-D8kI7yAO.js +54 -0
- package/dist/thread-resume-T5cveyxA.js +52 -0
- package/dist/timeout-BVw8aaM1.js +33 -0
- package/dist/{transcript-mirror-attestation-Byl34PC-.js → transcript-mirror-attestation-DibE0krH.js} +17 -4
- package/dist/{transcript-mirror-_njEB84z.js → transcript-mirror-t5TOccct.js} +50 -260
- package/dist/{transport-stdio-CzTngV0j.js → transport-stdio-BGjHoYLr.js} +73 -43
- package/dist/{upstream-session-fork-1fwbNKzQ.js → upstream-session-fork-De-sLJ2r.js} +26 -18
- package/dist/{usage-i9fv5-4m.js → usage-CPPTmBvZ.js} +4 -3
- package/dist/version-omm6IPI3.js +12 -0
- package/dist/{web-search-provider.runtime-DKQn67A7.js → web-search-provider.runtime-CSVgQL0w.js} +3 -3
- package/openclaw.plugin.json +22 -1
- package/package.json +4 -4
- package/dist/request-C8H22rPi.js +0 -475
- package/dist/session-catalog-B47uwekb.js +0 -3272
- package/dist/shared-client-CKhX2kFt.js +0 -7505
- package/dist/thread-policy-CTalhWFy.js +0 -105
- package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-Co2Vfcf_.js} +1 -1
|
@@ -1,26 +1,15 @@
|
|
|
1
1
|
import { n as isCodexFastServiceTier } from "./config-utils-C57JiJrU.js";
|
|
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";
|
|
2
|
+
import { r as bindingStoreKey } from "./session-binding-record-CaZjYwNS.js";
|
|
3
|
+
import { a as formatCodexDisplayText } from "./command-formatters-DeTfrapr.js";
|
|
4
|
+
import "./config-JDfTI4VI.js";
|
|
5
|
+
import { i as resolveCodexBindingAppServerConnection } from "./binding-connection-QqgcPCgk.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-CVhez2Uo.js";
|
|
8
|
+
import { E as resolveCodexAppServerRequestModelSelection, O as resolveCodexBindingModelProviderFallback } from "./thread-lifecycle-D1pzRwHB.js";
|
|
9
|
+
import "./session-binding-CKSepwIC.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-CKSepwIC.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,39 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { l as resolveCodexNativeExecutionPolicy, u as resolveCodexNodeExecToolOverrides } from "./request-C8H22rPi.js";
|
|
1
|
+
import { a as flattenCodexDynamicToolFunctions, o as isJsonObject, r as CODEX_OPENCLAW_DIRECT_DYNAMIC_TOOL_NAMESPACE, x as readCodexPluginConfig, y as isCodexRemoteExecPlacementSandbox } from "./protocol-CAAcVIKF.js";
|
|
2
|
+
import { B as withDynamicToolTranscriptDetails, E as createCodexElicitationResponse, L as resolveCodexToolAbortTerminalReason, R as createFailedDynamicToolResponse, w as readCodexTurn, z as withDynamicToolExecutionState } from "./client-BEKu4yDx.js";
|
|
3
|
+
import { a as formatCodexDisplayText } from "./command-formatters-DeTfrapr.js";
|
|
4
|
+
import "./config-JDfTI4VI.js";
|
|
6
5
|
import { r as sanitizeInlineImageDataUrl, t as invalidInlineImageText } from "./image-payload-sanitizer-tupAr-2o.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { E as itemStatus, L as readItem, T as itemName, b as auditNativeToolUnfinishedStatus, h as isCodexNotificationForTurn, k as shouldClearTerminalPresentationForNativeItem, v as auditNativeToolName, y as auditNativeToolTerminalStatus } from "./attempt-client-cleanup-D6cR54TV.js";
|
|
7
|
+
import { B as emitCodexNativePreToolUseFailureDiagnostic, S as resolveCodexWebSearchPlan, it as isForcedPrivateQaCodexRuntime, nt as filterCodexDynamicTools, ot as isSystemAgentOnlyCodexDynamicToolAllowlist, rt as filterCodexDynamicToolsForDisabledNativeSurface, st as normalizeCodexDynamicToolName } from "./thread-lifecycle-D1pzRwHB.js";
|
|
8
|
+
import { n as resolveCodexNativeExecutionPolicy, r as resolveCodexNodeExecToolOverrides } from "./native-execution-policy-umd0tgh4.js";
|
|
9
|
+
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-W4tfK5Y5.js";
|
|
10
|
+
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-DeW95wB5.js";
|
|
11
|
+
import { createRequire } from "node:module";
|
|
10
12
|
import { asNonArrayRecord, asOptionalRecord, isRecord, normalizeOptionalString, normalizeTrimmedStringList, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
11
13
|
import { createHash, randomUUID } from "node:crypto";
|
|
12
14
|
import { asDateTimestampMs } from "openclaw/plugin-sdk/number-runtime";
|
|
13
15
|
import { killProcessTree } from "openclaw/plugin-sdk/process-runtime";
|
|
14
16
|
import { validateJsonSchemaValue } from "openclaw/plugin-sdk/json-schema-runtime";
|
|
15
17
|
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";
|
|
18
|
+
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
23
19
|
import { once } from "node:events";
|
|
20
|
+
import { spawn } from "node:child_process";
|
|
24
21
|
import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
25
22
|
import { DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS, estimateToolResultTextChars, resolveLiveToolResultMaxChars, sliceToolResultTextToBudget, sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
23
|
+
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
24
|
+
import { createStageTimingTracker, formatStageTimings } from "openclaw/plugin-sdk/time-runtime";
|
|
25
|
+
import { isPathStrictlyInside, root } from "openclaw/plugin-sdk/file-access-runtime";
|
|
26
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
27
|
+
import { resolveAgentDir } from "openclaw/plugin-sdk/agent-runtime";
|
|
28
|
+
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";
|
|
29
|
+
import { formatErrorMessage as formatErrorMessage$2, redactSensitiveText } from "openclaw/plugin-sdk/security-runtime";
|
|
26
30
|
import { emitTrustedDiagnosticEvent } from "openclaw/plugin-sdk/diagnostic-runtime";
|
|
27
31
|
import { isIP } from "node:net";
|
|
28
|
-
import { WebSocketServer } from "ws";
|
|
29
|
-
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
30
32
|
import { redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
31
33
|
import { formatMcpCodexApprovalRemedy, requiresMcpCodexToolApproval, resolveCodexScheduledToolProjectionFactory, resolveProjectedMcpCodexToolApprovalMode, runWithCronCreatorAuthorityCapabilityResolver } from "openclaw/plugin-sdk/codex-mcp-projection";
|
|
32
34
|
import { buildRemoteCommand, isToolAllowed, sanitizeEnvVars } from "openclaw/plugin-sdk/sandbox";
|
|
33
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
34
35
|
import { saveMediaBuffer } from "openclaw/plugin-sdk/media-store";
|
|
35
36
|
import { getMediaDir } from "openclaw/plugin-sdk/media-runtime";
|
|
36
37
|
import { consumeTrustedToolNoStartError, copyInternalToolResultState, getCoreTtsToolResultMediaUrls } from "openclaw/plugin-sdk/agent-harness-tool-runtime";
|
|
38
|
+
import { SsrFBlockedError, isBlockedHostnameOrIp } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
37
39
|
import { normalizeOpenAIStrictCompatSchema } from "openclaw/plugin-sdk/provider-tools";
|
|
38
40
|
//#region extensions/codex/src/app-server/dynamic-tool-build-state.ts
|
|
39
41
|
/** Mutable dependency seam shared by dynamic-tool construction and its behavioral tests. */
|
|
@@ -156,26 +158,10 @@ const CODEX_DYNAMIC_TOOL_BUILD_WARN_TOTAL_MS = 1e3;
|
|
|
156
158
|
const CODEX_DYNAMIC_TOOL_BUILD_WARN_STAGE_MS = 500;
|
|
157
159
|
/** Captures bounded preparation stages before a slow turn needs diagnosis. */
|
|
158
160
|
function createCodexDynamicToolBuildStageTracker() {
|
|
159
|
-
const
|
|
160
|
-
let previousAt = startedAt;
|
|
161
|
-
const stages = [];
|
|
162
|
-
const toMs = (value) => Math.max(0, Math.round(value));
|
|
161
|
+
const { mark, snapshot } = createStageTimingTracker();
|
|
163
162
|
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
|
-
}
|
|
163
|
+
mark,
|
|
164
|
+
snapshot
|
|
179
165
|
};
|
|
180
166
|
}
|
|
181
167
|
/** Returns true when dynamic-tool construction is slow enough to warrant a warning log. */
|
|
@@ -186,7 +172,7 @@ function shouldWarnCodexDynamicToolBuildStageSummary(summary, profilerEnabled =
|
|
|
186
172
|
}
|
|
187
173
|
/** Formats per-stage timings into the compact form used by Codex app-server logs. */
|
|
188
174
|
function formatCodexDynamicToolBuildStageSummary(summary) {
|
|
189
|
-
return summary.stages
|
|
175
|
+
return formatStageTimings(summary.stages);
|
|
190
176
|
}
|
|
191
177
|
/** Builds, filters, and normalizes Codex-compatible runtime tools for a single turn. */
|
|
192
178
|
async function buildDynamicTools(input) {
|
|
@@ -210,7 +196,7 @@ async function buildDynamicTools(input) {
|
|
|
210
196
|
}
|
|
211
197
|
const toolBuildStages = createCodexDynamicToolBuildStageTracker();
|
|
212
198
|
const modelHasVision = params.model.input?.includes("image") ?? false;
|
|
213
|
-
const agentDir = params.agentDir ?? resolveAgentDir
|
|
199
|
+
const agentDir = params.agentDir ?? resolveAgentDir(params.config ?? {}, input.sessionAgentId);
|
|
214
200
|
const injectedOpenClawCodingToolsFactory = dynamicToolBuildState.openClawCodingToolsFactory;
|
|
215
201
|
const nativeExecutionPolicy = resolveCodexNativeExecutionPolicyForRun(params, {
|
|
216
202
|
agentId: input.policyAgentId,
|
|
@@ -248,31 +234,13 @@ async function buildDynamicTools(input) {
|
|
|
248
234
|
send: params.onToolResult,
|
|
249
235
|
...params.messageChannel ? { messageChannel: params.messageChannel } : {}
|
|
250
236
|
} } : {},
|
|
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
237
|
inputProvenance: params.inputProvenance,
|
|
268
238
|
trustedInternalHandoff: params.trustedInternalHandoff,
|
|
269
|
-
scheduledToolPolicy: params.scheduledToolPolicy,
|
|
270
239
|
allowGatewaySubagentBinding: params.allowGatewaySubagentBinding || isForcedPrivateQaCodexRuntime(),
|
|
271
240
|
sessionKey: input.sandboxSessionKey,
|
|
272
241
|
runSessionKey: params.sessionKey && params.sessionKey !== input.sandboxSessionKey ? params.sessionKey : void 0,
|
|
273
242
|
sessionId: params.sessionId,
|
|
274
243
|
runId: params.runId,
|
|
275
|
-
approvalReviewerDeviceId: params.approvalReviewerDeviceId,
|
|
276
244
|
agentDir,
|
|
277
245
|
preparedModelRuntime: params.preparedModelRuntime,
|
|
278
246
|
cwd: input.effectiveCwd ?? input.effectiveWorkspace,
|
|
@@ -297,25 +265,18 @@ async function buildDynamicTools(input) {
|
|
|
297
265
|
modelAuthMode: resolveModelAuthMode(params.model.provider, params.config, params.toolAuthProfileStore ?? params.authProfileStore, { workspaceDir: input.effectiveWorkspace }),
|
|
298
266
|
suppressManagedWebSearch: false,
|
|
299
267
|
webFetchHostnameAllowlistRef,
|
|
300
|
-
currentChannelId: params.currentChannelId,
|
|
301
|
-
currentMessagingTarget: params.currentMessagingTarget,
|
|
302
268
|
hookChannelId: resolveCodexAppServerHookChannelId(params, input.sandboxSessionKey),
|
|
303
|
-
currentThreadTs: params.currentThreadTs,
|
|
304
|
-
currentMessageId: params.currentMessageId,
|
|
305
|
-
replyToMode: params.replyToMode,
|
|
306
|
-
hasRepliedRef: params.hasRepliedRef,
|
|
307
269
|
modelHasVision,
|
|
308
270
|
computerContextEpoch: input.computerContextEpoch,
|
|
271
|
+
oneShotCliRun: params.oneShotCliRun,
|
|
309
272
|
registerRunCleanup: input.registerRunCleanup,
|
|
310
273
|
requireExplicitMessageTarget: params.requireExplicitMessageTarget ?? isSubagentSessionKey(params.sessionKey),
|
|
311
|
-
sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
|
|
312
|
-
taskSuggestionDeliveryMode: params.taskSuggestionDeliveryMode,
|
|
313
274
|
disableMessageTool: input.ignoreDisableMessageTool ? false : params.disableMessageTool,
|
|
314
275
|
forceMessageTool: shouldForceMessageTool(messagePolicyParams),
|
|
315
276
|
enableHeartbeatTool: params.trigger === "heartbeat" || input.forceHeartbeatTool === true,
|
|
316
277
|
forceHeartbeatTool: params.trigger === "heartbeat" || input.forceHeartbeatTool === true,
|
|
317
278
|
onYield: (message, acknowledgment) => {
|
|
318
|
-
input.onYieldDetected(acknowledgment);
|
|
279
|
+
input.onYieldDetected(message, acknowledgment);
|
|
319
280
|
input.onCodexAppServerEvent?.({
|
|
320
281
|
stream: "codex_app_server.tool",
|
|
321
282
|
data: {
|
|
@@ -335,6 +296,7 @@ async function buildDynamicTools(input) {
|
|
|
335
296
|
cronCreatorToolAllowlistCaptureRef: input.cronCreatorToolAllowlistCaptureRef,
|
|
336
297
|
cronCreatorAuthorityUnavailableReason: input.cronCreatorAuthorityUnavailableReason
|
|
337
298
|
};
|
|
299
|
+
input.onMessageToolTargetResolved?.(options.requireExplicitMessageTarget === true);
|
|
338
300
|
const buildOpenClawCodingTools = () => {
|
|
339
301
|
const bindingOptions = { cwd: input.effectiveCwd ?? input.effectiveWorkspace };
|
|
340
302
|
if (injectedOpenClawCodingToolsFactory) return params.hostCapabilities.bindToolSurface(injectedOpenClawCodingToolsFactory(options), bindingOptions);
|
|
@@ -1157,7 +1119,7 @@ const CODEX_NODE_HTTP_CREDENTIAL_FIELD_NAME_PATTERN = /^(?:(?:[a-z\d]+_)*(?:toke
|
|
|
1157
1119
|
const nodeExecServerTextDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
1158
1120
|
/** Produces the bounded, redacted terminal failure shared by pending and claimed node leases. */
|
|
1159
1121
|
function createCodexNodeExecServerDisconnectError(reason, cause) {
|
|
1160
|
-
const detail = cause === void 0 ? "" : `: ${truncateUtf16Safe(redactSensitiveText(formatErrorMessage$
|
|
1122
|
+
const detail = cause === void 0 ? "" : `: ${truncateUtf16Safe(redactSensitiveText(formatErrorMessage$2(cause), { mode: "tools" }), CODEX_NODE_EXEC_SERVER_MAX_FAILURE_DETAIL_CHARS)}`;
|
|
1161
1123
|
return /* @__PURE__ */ new Error(`Codex execution node disconnected; start a fresh attempt. (${reason}${detail})`);
|
|
1162
1124
|
}
|
|
1163
1125
|
/** Relays one authorized, single-use Codex exec-server channel without interpreting its protocol. */
|
|
@@ -1451,6 +1413,10 @@ const sandboxExecServerRegistry = {
|
|
|
1451
1413
|
}
|
|
1452
1414
|
};
|
|
1453
1415
|
//#endregion
|
|
1416
|
+
//#region extensions/codex/src/app-server/sandbox-exec-server.websocket.ts
|
|
1417
|
+
const require = createRequire(import.meta.url);
|
|
1418
|
+
const websocket = require(path.join(path.dirname(require.resolve("ws/package.json")), "index.js"));
|
|
1419
|
+
//#endregion
|
|
1454
1420
|
//#region extensions/codex/src/app-server/sandbox-exec-server/json-rpc.ts
|
|
1455
1421
|
/** JSON-RPC error code used when a sandbox filesystem resource does not exist. */
|
|
1456
1422
|
const JSON_RPC_NOT_FOUND = -32004;
|
|
@@ -3129,7 +3095,7 @@ async function startOpenClawExecServer(sandbox) {
|
|
|
3129
3095
|
fsBridge
|
|
3130
3096
|
};
|
|
3131
3097
|
}
|
|
3132
|
-
const server = new WebSocketServer({
|
|
3098
|
+
const server = new websocket.WebSocketServer({
|
|
3133
3099
|
host: "127.0.0.1",
|
|
3134
3100
|
port: 0,
|
|
3135
3101
|
maxPayload: connection.kind === "node" ? CODEX_NODE_EXEC_SERVER_MAX_MESSAGE_BYTES : CODEX_SANDBOX_EXEC_SERVER_MAX_INBOUND_MESSAGE_BYTES
|
|
@@ -5477,7 +5443,8 @@ function notifyAgentToolResult(observer, toolName, result, isError) {
|
|
|
5477
5443
|
isError
|
|
5478
5444
|
});
|
|
5479
5445
|
} catch (error) {
|
|
5480
|
-
|
|
5446
|
+
const message = formatToolExecutionErrorMessage(error, "Unknown error");
|
|
5447
|
+
embeddedAgentLog.warn(`onAgentToolResult handler failed: tool=${toolName} error=${message}`);
|
|
5481
5448
|
}
|
|
5482
5449
|
}
|
|
5483
5450
|
function failedToolResult(message, status = "failed") {
|
|
@@ -5684,7 +5651,36 @@ function withDynamicToolAsyncStarted(response, asyncStarted) {
|
|
|
5684
5651
|
function normalizeToolResultMaxChars(maxChars) {
|
|
5685
5652
|
return typeof maxChars === "number" && Number.isFinite(maxChars) && maxChars > 0 ? Math.floor(maxChars) : DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS;
|
|
5686
5653
|
}
|
|
5687
|
-
function
|
|
5654
|
+
function sanitizeToolTextRuns(rawContent) {
|
|
5655
|
+
const content = [];
|
|
5656
|
+
for (let index = 0; index < rawContent.length;) {
|
|
5657
|
+
const item = rawContent[index];
|
|
5658
|
+
if (item.type !== "text") {
|
|
5659
|
+
content.push(item);
|
|
5660
|
+
index += 1;
|
|
5661
|
+
continue;
|
|
5662
|
+
}
|
|
5663
|
+
const textRun = [];
|
|
5664
|
+
while (index < rawContent.length) {
|
|
5665
|
+
const next = rawContent[index];
|
|
5666
|
+
if (next.type !== "text") break;
|
|
5667
|
+
textRun.push(next);
|
|
5668
|
+
index += 1;
|
|
5669
|
+
}
|
|
5670
|
+
const sanitizedText = sanitizeToolResult(textRun.map((entry) => entry.text).join(""));
|
|
5671
|
+
let offset = 0;
|
|
5672
|
+
content.push(...textRun.map((entry, runIndex) => {
|
|
5673
|
+
const targetEnd = runIndex === textRun.length - 1 ? sanitizedText.length : Math.min(sanitizedText.length, offset + entry.text.length);
|
|
5674
|
+
const text = sliceUtf16Safe(sanitizedText, offset, targetEnd);
|
|
5675
|
+
const sanitized = Object.assign({}, entry, { text });
|
|
5676
|
+
offset += text.length;
|
|
5677
|
+
return sanitized;
|
|
5678
|
+
}));
|
|
5679
|
+
}
|
|
5680
|
+
return content;
|
|
5681
|
+
}
|
|
5682
|
+
function convertToolContents(rawContent, toolResultMaxChars = DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS) {
|
|
5683
|
+
const content = sanitizeToolTextRuns(rawContent);
|
|
5688
5684
|
const maxChars = normalizeToolResultMaxChars(toolResultMaxChars);
|
|
5689
5685
|
const totalTextChars = content.reduce((total, item) => total + (item.type === "text" ? item.text.length : 0), 0);
|
|
5690
5686
|
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-CaZjYwNS.js";
|
|
2
|
+
import { _ as retainSharedCodexAppServerClientByInstanceId } from "./shared-client-CVhez2Uo.js";
|
|
3
|
+
import "./session-binding-CKSepwIC.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 };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { o as isJsonObject } from "./protocol-CAAcVIKF.js";
|
|
2
|
+
import { T as readCodexTurnCompletedNotification } from "./client-BEKu4yDx.js";
|
|
3
|
+
import { p as getCodexAppServerTurnRouter } from "./attempt-client-cleanup-D6cR54TV.js";
|
|
4
|
+
import { o as isTerminalTurnStatus, s as readCodexNotificationItem } from "./attempt-notifications--H8zXR5-.js";
|
|
5
|
+
import { t as CodexUsageProjection } from "./event-projector-usage-CIyrYYid.js";
|
|
6
|
+
import { readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
|
+
import { toStringifiedError } from "openclaw/plugin-sdk/error-runtime";
|
|
8
|
+
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
9
|
+
//#region extensions/codex/src/app-server/ephemeral-turn.ts
|
|
10
|
+
/** One ephemeral turn; the client router owns correlation, buffering and request lifetime. */
|
|
11
|
+
var CodexEphemeralTurn = class {
|
|
12
|
+
constructor(client, threadId, options) {
|
|
13
|
+
this.options = options;
|
|
14
|
+
this.completion = createDeferred();
|
|
15
|
+
this.usage = new CodexUsageProjection();
|
|
16
|
+
this.items = /* @__PURE__ */ new Map();
|
|
17
|
+
this.assistantItems = /* @__PURE__ */ new Map();
|
|
18
|
+
this.assistantText = "";
|
|
19
|
+
this.route = getCodexAppServerTurnRouter(client).reserveThread({
|
|
20
|
+
threadId,
|
|
21
|
+
...options,
|
|
22
|
+
onNotification: async (notification, scope) => {
|
|
23
|
+
const params = isJsonObject(notification.params) ? notification.params : void 0;
|
|
24
|
+
if (params && scope.turnId) {
|
|
25
|
+
if (notification.method === "item/completed" && options.textMode === "all") {
|
|
26
|
+
const item = readCodexNotificationItem(params);
|
|
27
|
+
if (item) {
|
|
28
|
+
this.items.set(item.id, item);
|
|
29
|
+
if (item.type === "agentMessage" && item.text) this.assistantItems.set(item.id, item.text);
|
|
30
|
+
}
|
|
31
|
+
} else if (notification.method === "item/agentMessage/delta") {
|
|
32
|
+
const delta = readStringField(params, "delta") ?? "";
|
|
33
|
+
const itemId = readStringField(params, "itemId") ?? readStringField(params, "id") ?? "assistant";
|
|
34
|
+
const firstDelta = !this.assistantText && Boolean(delta);
|
|
35
|
+
this.assistantText += delta;
|
|
36
|
+
if (delta && options.textMode === "all") this.assistantItems.set(itemId, `${this.assistantItems.get(itemId) ?? ""}${delta}`);
|
|
37
|
+
if (firstDelta) await options.onAssistantMessageStart?.();
|
|
38
|
+
} else if (notification.method === "rawResponse/completed") this.usage.record(params);
|
|
39
|
+
else if (notification.method === "turn/completed") {
|
|
40
|
+
this.turn = readCodexTurnCompletedNotification(params)?.turn ?? this.turn;
|
|
41
|
+
this.completion.resolve();
|
|
42
|
+
} else if (notification.method === "error") {
|
|
43
|
+
this.usage.invalidateContext();
|
|
44
|
+
if (params.willRetry !== true) {
|
|
45
|
+
this.error = params;
|
|
46
|
+
this.completion.resolve();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
await options.onNotification?.(notification, scope);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
this.route.armTurn();
|
|
54
|
+
}
|
|
55
|
+
get completed() {
|
|
56
|
+
return this.turn !== void 0;
|
|
57
|
+
}
|
|
58
|
+
async wait(turn, options) {
|
|
59
|
+
if (isTerminalTurnStatus(turn.status)) {
|
|
60
|
+
this.turn = turn;
|
|
61
|
+
this.completion.resolve();
|
|
62
|
+
}
|
|
63
|
+
const completion = this.route.bindTurn(turn.id, { completed: isTerminalTurnStatus(turn.status) }).then(() => this.completion.promise);
|
|
64
|
+
const signals = [this.route.signal, options.signal];
|
|
65
|
+
const abortError = () => options.signal.aborted ? options.abortError() : toStringifiedError(this.route.signal.reason);
|
|
66
|
+
let timer;
|
|
67
|
+
let abort = () => {};
|
|
68
|
+
try {
|
|
69
|
+
await Promise.race([completion, new Promise((_resolve, reject) => {
|
|
70
|
+
abort = () => {
|
|
71
|
+
if (options.signal.aborted || !this.route.completed) reject(abortError());
|
|
72
|
+
};
|
|
73
|
+
for (const signal of signals) {
|
|
74
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
75
|
+
if (signal.aborted) abort();
|
|
76
|
+
}
|
|
77
|
+
const timeout = options.timeout;
|
|
78
|
+
if (timeout) {
|
|
79
|
+
timer = setTimeout(() => reject(timeout.error), timeout.ms);
|
|
80
|
+
timer.unref?.();
|
|
81
|
+
}
|
|
82
|
+
})]);
|
|
83
|
+
} finally {
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
for (const signal of signals) signal.removeEventListener("abort", abort);
|
|
86
|
+
}
|
|
87
|
+
const items = new Map(this.items);
|
|
88
|
+
for (const item of this.turn?.items ?? []) items.set(item.id, item);
|
|
89
|
+
const messages = (this.options.textMode === "last" ? this.turn?.items ?? [] : [...items.values()]).filter((item) => item.type === "agentMessage").map((item) => item.text.trim()).filter(Boolean);
|
|
90
|
+
const text = this.options.textMode === "last" ? messages.at(-1) || this.assistantText : messages.join("\n\n") || [...this.assistantItems.values()].map((message) => message.trim()).filter(Boolean).join("\n\n");
|
|
91
|
+
return {
|
|
92
|
+
turn: this.turn,
|
|
93
|
+
error: this.error,
|
|
94
|
+
items: [...items.values()],
|
|
95
|
+
text: text.trim(),
|
|
96
|
+
usage: this.usage.usage
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
export { CodexEphemeralTurn as t };
|