@openclaw/codex 2026.8.1 → 2026.8.2
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/dist/api.js +2 -2
- package/dist/{attempt-client-cleanup-CVPvp9dL.js → attempt-client-cleanup-CpVfwctT.js} +1 -1
- package/dist/{binding-connection-CCQFs8lf.js → binding-connection-CF7BmrDk.js} +2 -2
- package/dist/{bounded-turn-rq5tiSXk.js → bounded-turn-DRC3hcjm.js} +10 -9
- package/dist/{capabilities-CGm_94eL.js → capabilities-D6m_TdVy.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{command-formatters-C54Yg3eA.js → command-formatters--UToCokS.js} +4 -3
- package/dist/{command-handlers-BvOAHTrA.js → command-handlers-CLFx2Ypa.js} +41 -33
- package/dist/{compact-Hd7SAc0N.js → compact-5xqW1oCh.js} +13 -11
- package/dist/{config-Cxw3Cl3k.js → config-CcYL77O6.js} +6 -4
- package/dist/{conversation-binding-data-CW2GuupV.js → conversation-binding-data-BiodpIzq.js} +2 -1
- package/dist/doctor-contract-api.js +8 -4
- package/dist/{dynamic-tools-BFoUcRdx.js → dynamic-tools-BmeXjwNZ.js} +103 -106
- package/dist/{effective-mcp-catalog-BTJHnDSx.js → effective-mcp-catalog-XXQKgK1U.js} +2 -2
- package/dist/{event-projector-usage-D3PHFFXh.js → event-projector-usage-B2r5vhWH.js} +7 -12
- package/dist/{harness-DVfUQBlQ.js → harness-BgeB7LnD.js} +13 -13
- package/dist/harness.js +1 -1
- package/dist/index.js +56 -37
- package/dist/{isolated-completion-Cbbx_5Ed.js → isolated-completion-CxTus3vZ.js} +3 -3
- package/dist/media-understanding-provider.js +1 -1
- package/dist/{model-catalog-o6Cgjoss.js → model-catalog-DULBcniB.js} +5 -5
- package/dist/{models-DgFWSuxA.js → models-DaWfETQk.js} +4 -3
- package/dist/{native-subagent-monitor-CwFyoylz.js → native-subagent-monitor-vXYUZH37.js} +24 -104
- package/dist/{node-exec-server.runtime-DXrqpw1c.js → node-exec-server.runtime-DirKVZ5h.js} +2 -2
- package/dist/{plugin-approval-roundtrip-D80UZiJ_.js → plugin-approval-roundtrip-CCWQGlAI.js} +2 -1
- package/dist/{plugin-marketplace-discovery-mdmScYOj.js → plugin-marketplace-discovery-BXjIFEiw.js} +14 -13
- package/dist/{plugin-metadata-cache-CulOABwu.js → plugin-metadata-cache-DQQm4gWT.js} +5 -5
- package/dist/{rate-limits-hFtzt2Up.js → rate-limits-BqHEHXQJ.js} +3 -2
- package/dist/{request-CCm4LaED.js → request-BWxweEdK.js} +2 -2
- package/dist/{run-attempt-BwNQDH2u.js → run-attempt-BVLE4Gbi.js} +133 -182
- package/dist/{runtime-artifact-DeBvleJw.js → runtime-artifact-D9pYp4zL.js} +3 -3
- package/dist/{session-binding-q2WSTVmC.js → session-binding-D0zinCP1.js} +1 -1
- package/dist/{session-catalog-C2Tae4rI.js → session-catalog-eMhVm0Ql.js} +232 -204
- package/dist/{session-catalog-home-id-DAKUrm3C.js → session-catalog-home-id-Dt2GiG5o.js} +3 -3
- package/dist/{session-cli-BuDjm5Ou.js → session-cli-B2lyjJA0.js} +1 -1
- package/dist/session-history-C5J1AKzG.js +87 -0
- package/dist/{session-permission-policy-gLm40Vtq.js → session-permission-policy-ScnAyG90.js} +1 -1
- package/dist/{session-retirement-CdkI0bvb.js → session-retirement-CtUtUTr9.js} +4 -4
- package/dist/{session-upstream-marker-Bcy33kam.js → session-upstream-marker-gqrYIRHk.js} +1 -1
- package/dist/settled-turn-context-Bk3IUwod.js +290 -0
- package/dist/settled-turn-finalizer-BXLN9PfJ.js +104 -0
- package/dist/{shared-client-kNkljY-R.js → shared-client-B1tT5U6r.js} +33 -35
- package/dist/{side-question-GwD73tX6.js → side-question-CZ-mCw-t.js} +18 -15
- package/dist/{thread-lifecycle-Ss-uwnC4.js → thread-lifecycle-CGGKP720.js} +206 -163
- package/dist/{thread-ownership-CeYBqg_4.js → thread-ownership-RkaoZCmQ.js} +2 -2
- package/dist/{thread-resume-DF54hagX.js → thread-resume-BFt1-ZDa.js} +7 -6
- package/dist/{transcript-mirror-CkEQIna-.js → transcript-mirror-1ep4XjzF.js} +14 -7
- package/dist/{transport-stdio-C7-s9TLG.js → transport-stdio-NT_Dpd9V.js} +40 -24
- package/dist/{upstream-prompt-provenance-CFmsKwr9.js → upstream-prompt-provenance-LphB8slG.js} +8 -4
- package/dist/{upstream-session-fork-BACGlOFa.js → upstream-session-fork-Dc8BFExw.js} +13 -19
- package/dist/{usage-C2l8Mils.js → usage-DUhd58gI.js} +3 -3
- package/dist/{web-search-provider.runtime-B2XgRdFv.js → web-search-provider.runtime-BEmlE7ov.js} +3 -3
- package/package.json +5 -5
- package/dist/settled-turn-finalizer-B8JJcxCi.js +0 -329
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { C as isCodexRemoteExecPlacementSandbox, T as readCodexPluginConfig } from "./config-
|
|
2
|
-
import { Bt as CODEX_OPENCLAW_DIRECT_DYNAMIC_TOOL_NAMESPACE, Ht as isJsonObject, dt as resolveCodexToolAbortTerminalReason, et as createCodexElicitationResponse, ft as createFailedDynamicToolResponse, h as releaseLeasedSharedCodexAppServerClient, mt as withDynamicToolTranscriptDetails, pt as withDynamicToolExecutionState } from "./shared-client-
|
|
1
|
+
import { C as isCodexRemoteExecPlacementSandbox, T as readCodexPluginConfig } from "./config-CcYL77O6.js";
|
|
2
|
+
import { Bt as CODEX_OPENCLAW_DIRECT_DYNAMIC_TOOL_NAMESPACE, Ht as isJsonObject, dt as resolveCodexToolAbortTerminalReason, et as createCodexElicitationResponse, ft as createFailedDynamicToolResponse, h as releaseLeasedSharedCodexAppServerClient, mt as withDynamicToolTranscriptDetails, pt as withDynamicToolExecutionState } from "./shared-client-B1tT5U6r.js";
|
|
3
3
|
import { d as readCodexTurn } from "./protocol-validators-Bg5rpNxk.js";
|
|
4
|
-
import { D as itemStatus, I as readItem, b as auditNativeToolTerminalStatus, g as isCodexNotificationForTurn, x as auditNativeToolUnfinishedStatus, y as auditNativeToolName } from "./attempt-client-cleanup-
|
|
5
|
-
import { H as normalizeCodexDynamicToolName, L as filterCodexDynamicTools, R as filterCodexDynamicToolsForDisabledNativeSurface, V as isSystemAgentOnlyCodexDynamicToolAllowlist, d as emitCodexNativePreToolUseFailureDiagnostic, x as resolveCodexWebSearchPlan, z as isForcedPrivateQaCodexRuntime } from "./thread-lifecycle-
|
|
6
|
-
import { l as resolveCodexNativeExecutionPolicy, u as resolveCodexNodeExecToolOverrides } from "./request-
|
|
4
|
+
import { D as itemStatus, I as readItem, b as auditNativeToolTerminalStatus, g as isCodexNotificationForTurn, x as auditNativeToolUnfinishedStatus, y as auditNativeToolName } from "./attempt-client-cleanup-CpVfwctT.js";
|
|
5
|
+
import { H as normalizeCodexDynamicToolName, L as filterCodexDynamicTools, R as filterCodexDynamicToolsForDisabledNativeSurface, V as isSystemAgentOnlyCodexDynamicToolAllowlist, d as emitCodexNativePreToolUseFailureDiagnostic, x as resolveCodexWebSearchPlan, z as isForcedPrivateQaCodexRuntime } from "./thread-lifecycle-CGGKP720.js";
|
|
6
|
+
import { l as resolveCodexNativeExecutionPolicy, u as resolveCodexNodeExecToolOverrides } from "./request-BWxweEdK.js";
|
|
7
7
|
import { r as sanitizeInlineImageDataUrl, t as invalidInlineImageText } from "./image-payload-sanitizer-CnfoUPCE.js";
|
|
8
|
-
import { r as formatCodexDisplayText } from "./command-formatters
|
|
9
|
-
import { a as sanitizeCodexApprovalVisibleText, c as waitForPluginApprovalDecision, i as requestPluginApproval, n as codexApprovalTimeoutText, o as stripDanglingCodexApprovalTerminalSequence, r as mapExecDecisionToOutcome, s as truncateCodexApprovalDisplayText, t as approvalRequestExplicitlyUnavailable } from "./plugin-approval-roundtrip-
|
|
8
|
+
import { r as formatCodexDisplayText } from "./command-formatters--UToCokS.js";
|
|
9
|
+
import { a as sanitizeCodexApprovalVisibleText, c as waitForPluginApprovalDecision, i as requestPluginApproval, n as codexApprovalTimeoutText, o as stripDanglingCodexApprovalTerminalSequence, r as mapExecDecisionToOutcome, s as truncateCodexApprovalDisplayText, t as approvalRequestExplicitlyUnavailable } from "./plugin-approval-roundtrip-CCWQGlAI.js";
|
|
10
10
|
import { asNonArrayRecord, asOptionalRecord, isRecord, normalizeOptionalString, normalizeTrimmedStringList, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
11
11
|
import { validateJsonSchemaValue } from "openclaw/plugin-sdk/json-schema-runtime";
|
|
12
12
|
import path, { posix } from "node:path";
|
|
@@ -33,6 +33,7 @@ import { buildRemoteCommand, isToolAllowed, sanitizeEnvVars } from "openclaw/plu
|
|
|
33
33
|
import { pinExecToolTarget, resolveCodexScheduledToolProjectionFactory, runWithCronCreatorAuthorityCapabilityResolver } from "openclaw/plugin-sdk/codex-mcp-projection";
|
|
34
34
|
import { saveMediaBuffer } from "openclaw/plugin-sdk/media-store";
|
|
35
35
|
import { getMediaDir } from "openclaw/plugin-sdk/media-runtime";
|
|
36
|
+
import { getCoreTtsToolResultMediaUrls } from "openclaw/plugin-sdk/agent-harness-tool-runtime";
|
|
36
37
|
import { normalizeOpenAIToolSchemas } from "openclaw/plugin-sdk/provider-tools";
|
|
37
38
|
//#region extensions/codex/src/app-server/event-projector-native-tool-lifecycle.ts
|
|
38
39
|
/** Projects metadata-only lifecycle diagnostics for native tool items. */
|
|
@@ -278,10 +279,10 @@ function joinRemoteWorkspacePath(remoteRoot, suffix) {
|
|
|
278
279
|
//#endregion
|
|
279
280
|
//#region extensions/codex/src/app-server/remote-workspace-media.ts
|
|
280
281
|
const REMOTE_WORKSPACE_MEDIA_TIMEOUT_MS = 6e4;
|
|
281
|
-
const REMOTE_WORKSPACE_MEDIA_MAX_BYTES =
|
|
282
|
+
const REMOTE_WORKSPACE_MEDIA_MAX_BYTES = 67108864;
|
|
282
283
|
const REMOTE_WORKSPACE_MEDIA_MAX_ATTACHMENTS = 16;
|
|
283
|
-
const CODEX_REMOTE_MEDIA_CHUNK_BYTES =
|
|
284
|
-
const CODEX_REMOTE_COMMAND_DEFAULT_OUTPUT_BYTES =
|
|
284
|
+
const CODEX_REMOTE_MEDIA_CHUNK_BYTES = 524288;
|
|
285
|
+
const CODEX_REMOTE_COMMAND_DEFAULT_OUTPUT_BYTES = 1048576;
|
|
285
286
|
const CODEX_BOUNDED_REMOTE_FILE_READER = [
|
|
286
287
|
"try{",
|
|
287
288
|
"const fs=require(\"node:fs\");",
|
|
@@ -632,13 +633,6 @@ function preserveRingZeroSystemAgentTool(allTools, filteredTools) {
|
|
|
632
633
|
if (!openclaw) return filteredTools;
|
|
633
634
|
return [openclaw, ...filteredTools.filter((tool) => tool.name !== "openclaw")];
|
|
634
635
|
}
|
|
635
|
-
/** Splits sandbox and run session keys so tool calls can bind to both scopes when needed. */
|
|
636
|
-
function resolveOpenClawCodingToolsSessionKeys(params, sandboxSessionKey) {
|
|
637
|
-
return {
|
|
638
|
-
sessionKey: sandboxSessionKey,
|
|
639
|
-
runSessionKey: params.sessionKey && params.sessionKey !== sandboxSessionKey ? params.sessionKey : void 0
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
636
|
/** Returns the canonical channel used for Codex message routing and receipts. */
|
|
643
637
|
function resolveCodexMessageToolProvider(params) {
|
|
644
638
|
return params.messageChannel ?? params.messageProvider;
|
|
@@ -720,11 +714,11 @@ async function buildDynamicTools(input) {
|
|
|
720
714
|
const modelHasVision = params.model.input?.includes("image") ?? false;
|
|
721
715
|
const agentDir = params.agentDir ?? resolveAgentDir$1(params.config ?? {}, input.sessionAgentId);
|
|
722
716
|
const injectedOpenClawCodingToolsFactory = dynamicToolBuildState.openClawCodingToolsFactory;
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
717
|
+
const nativeExecutionPolicy = resolveCodexNativeExecutionPolicyForRun(params, {
|
|
718
|
+
agentId: input.policyAgentId,
|
|
719
|
+
runtimeSessionKey: input.sandboxSessionKey,
|
|
720
|
+
sandbox: input.sandbox
|
|
721
|
+
});
|
|
728
722
|
const webSearchPlan = resolveCodexWebSearchPlan({
|
|
729
723
|
config: params.config,
|
|
730
724
|
disableTools: params.disableTools,
|
|
@@ -736,6 +730,7 @@ async function buildDynamicTools(input) {
|
|
|
736
730
|
const toolConstructionPlan = resolveCodexNodePlacementToolConstructionPlan(input.sandbox, input.nativeToolSurfaceEnabled);
|
|
737
731
|
const options = {
|
|
738
732
|
agentId: input.sessionAgentId,
|
|
733
|
+
policyAgentId: input.policyAgentId,
|
|
739
734
|
...toolRunContext,
|
|
740
735
|
exec: {
|
|
741
736
|
...params.execOverrides,
|
|
@@ -772,7 +767,8 @@ async function buildDynamicTools(input) {
|
|
|
772
767
|
trustedInternalHandoff: params.trustedInternalHandoff,
|
|
773
768
|
scheduledToolPolicy: params.scheduledToolPolicy,
|
|
774
769
|
allowGatewaySubagentBinding: params.allowGatewaySubagentBinding || isForcedPrivateQaCodexRuntime(),
|
|
775
|
-
|
|
770
|
+
sessionKey: input.sandboxSessionKey,
|
|
771
|
+
runSessionKey: params.sessionKey && params.sessionKey !== input.sandboxSessionKey ? params.sessionKey : void 0,
|
|
776
772
|
sessionId: params.sessionId,
|
|
777
773
|
runId: params.runId,
|
|
778
774
|
approvalReviewerDeviceId: params.approvalReviewerDeviceId,
|
|
@@ -855,7 +851,7 @@ async function buildDynamicTools(input) {
|
|
|
855
851
|
const readableAllTools = [...readableAllToolProjection.tools];
|
|
856
852
|
const normallyProfiledTools = input.nativeToolSurfaceEnabled === false ? filterCodexDynamicToolsForDisabledNativeSurface(readableAllTools, input.pluginConfig, { preserveShell: shouldKeepOpenClawShellDynamicTools(input, nativeExecutionPolicy) }) : filterCodexDynamicTools(readableAllTools, input.pluginConfig);
|
|
857
853
|
const profileFilteredTools = (input.isHostScopedToolActive?.("openclaw") ?? isHostScopedAgentToolActive("openclaw")) && isSystemAgentOnlyCodexDynamicToolAllowlist(params.toolsAllow) ? preserveRingZeroSystemAgentTool(readableAllTools, normallyProfiledTools) : normallyProfiledTools;
|
|
858
|
-
const codexFilteredTools = addNodeShellDynamicToolsIfNeeded(addGatewayShellDynamicToolsIfAvailable(addSandboxShellDynamicToolsIfAvailable(isCodexMemoryFlushRun(params) ? filterCodexMemoryFlushDynamicTools(readableAllTools) : profileFilteredTools, readableAllTools, input), readableAllTools, input, nativeExecutionPolicy), readableAllTools, input, nativeExecutionPolicy);
|
|
854
|
+
const codexFilteredTools = addNodeShellDynamicToolsIfNeeded(addGatewayShellDynamicToolsIfAvailable(addSandboxShellDynamicToolsIfAvailable(isCodexMemoryFlushRun(params) ? filterCodexMemoryFlushDynamicTools(readableAllTools) : profileFilteredTools, readableAllTools, input, nativeExecutionPolicy), readableAllTools, input, nativeExecutionPolicy), readableAllTools, input, nativeExecutionPolicy);
|
|
859
855
|
toolBuildStages.mark("codex-filtering");
|
|
860
856
|
const visionFilteredTools = filterCodexVisionTools(codexFilteredTools, {
|
|
861
857
|
modelHasVision,
|
|
@@ -864,32 +860,32 @@ async function buildDynamicTools(input) {
|
|
|
864
860
|
toolBuildStages.mark("vision-filtering");
|
|
865
861
|
const webSearchPresent = visionFilteredTools.some((tool) => tool.name === "web_search");
|
|
866
862
|
const persistentCodexWebSearchSurface = params.config?.tools?.web?.search?.enabled !== false && !(input.pluginConfig.codexDynamicToolsExclude ?? []).some((name) => normalizeCodexDynamicToolName(name) === "web_search");
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
input.onPersistentWebSearchPolicyResolved?.(
|
|
863
|
+
let persistentWebSearchAllowed = webSearchPresent;
|
|
864
|
+
if (input.onPersistentWebSearchPolicyResolved && !webSearchPresent && persistentCodexWebSearchSurface) {
|
|
865
|
+
const webSearchPolicy = (await import("openclaw/plugin-sdk/agent-harness")).resolveWebSearchToolPolicy({
|
|
866
|
+
config: params.config,
|
|
867
|
+
modelProvider: params.model.provider,
|
|
868
|
+
modelId: params.modelId,
|
|
869
|
+
agentId: input.policyAgentId,
|
|
870
|
+
sessionKey: input.sandboxSessionKey,
|
|
871
|
+
sandboxToolPolicy: input.sandbox?.tools,
|
|
872
|
+
messageProvider: resolveCodexMessageToolProvider(params),
|
|
873
|
+
agentAccountId: params.agentAccountId,
|
|
874
|
+
groupId: params.groupId,
|
|
875
|
+
groupChannel: params.groupChannel,
|
|
876
|
+
groupSpace: params.groupSpace,
|
|
877
|
+
spawnedBy: params.spawnedBy,
|
|
878
|
+
senderId: params.senderId,
|
|
879
|
+
senderName: params.senderName,
|
|
880
|
+
senderUsername: params.senderUsername,
|
|
881
|
+
senderE164: params.senderE164,
|
|
882
|
+
inputProvenance: params.inputProvenance,
|
|
883
|
+
trustedInternalHandoff: params.trustedInternalHandoff,
|
|
884
|
+
scheduledToolPolicy: params.scheduledToolPolicy
|
|
885
|
+
});
|
|
886
|
+
persistentWebSearchAllowed = webSearchPolicy.persistentAllowed && (!webSearchPolicy.allowed || isCodexMemoryFlushRun(params));
|
|
887
|
+
}
|
|
888
|
+
input.onPersistentWebSearchPolicyResolved?.(persistentWebSearchAllowed);
|
|
893
889
|
const filteredTools = filterCodexDynamicToolsForAllowlist(visionFilteredTools, toolRunContext.runtimeToolAllowlist);
|
|
894
890
|
toolBuildStages.mark("allowlist-filter");
|
|
895
891
|
const normalizedTools = normalizeAgentRuntimeTools({
|
|
@@ -965,26 +961,25 @@ function shouldEnableCodexAppServerNativeToolSurface(params, sandbox, options =
|
|
|
965
961
|
if (params.pluginHarnessToolPolicyRestricted === true) return false;
|
|
966
962
|
if (isCodexMemoryFlushRun(params)) return false;
|
|
967
963
|
if (params.disableTools) return false;
|
|
968
|
-
if (
|
|
964
|
+
if (!resolveCodexNativeExecutionPolicyForRun(params, {
|
|
969
965
|
agentId: options.agentId,
|
|
970
966
|
runtimeSessionKey: options.runtimeSessionKey,
|
|
971
967
|
sandbox
|
|
972
|
-
})) return false;
|
|
968
|
+
}).nativeToolSurfaceAllowed) return false;
|
|
973
969
|
const toolsAllow = params.toolsAllow;
|
|
974
970
|
if (toolsAllow === void 0) return canCodexAppServerNativeToolSurfaceHonorSandbox(sandbox, options);
|
|
975
971
|
return hasWildcardCodexToolsAllow(toolsAllow) && canCodexAppServerNativeToolSurfaceHonorSandbox(sandbox, options);
|
|
976
972
|
}
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
return !resolveCodexNativeExecutionPolicy({
|
|
973
|
+
function resolveCodexNativeExecutionPolicyForRun(params, options = {}) {
|
|
974
|
+
return resolveCodexNativeExecutionPolicy({
|
|
980
975
|
config: params.config,
|
|
981
976
|
sessionKey: resolveCodexRuntimePolicySessionKey(params, options.runtimeSessionKey),
|
|
982
977
|
sessionId: params.sessionId,
|
|
983
978
|
agentId: options.agentId,
|
|
984
979
|
execOverrides: params.execOverrides,
|
|
985
|
-
sandboxAvailable: options.sandbox?.enabled,
|
|
980
|
+
sandboxAvailable: options.sandbox === null ? false : options.sandbox?.enabled,
|
|
986
981
|
readRuntimeSessionEntry: true
|
|
987
|
-
})
|
|
982
|
+
});
|
|
988
983
|
}
|
|
989
984
|
function resolveCodexRuntimePolicySessionKey(params, runtimeSessionKey) {
|
|
990
985
|
return runtimeSessionKey?.trim() || params.sandboxSessionKey?.trim() || params.sessionKey?.trim() || params.sessionId;
|
|
@@ -1047,8 +1042,8 @@ function disableCodexPluginThreadConfig(pluginConfig) {
|
|
|
1047
1042
|
};
|
|
1048
1043
|
}
|
|
1049
1044
|
/** Adds sandbox_exec/process aliases when native Code Mode cannot directly honor the sandbox. */
|
|
1050
|
-
function addSandboxShellDynamicToolsIfAvailable(filteredTools, allTools, input) {
|
|
1051
|
-
if (
|
|
1045
|
+
function addSandboxShellDynamicToolsIfAvailable(filteredTools, allTools, input, executionPolicy) {
|
|
1046
|
+
if (isCodexMemoryFlushRun(input.params) || !executionPolicy.nativeToolSurfaceAllowed || !input.sandbox?.enabled || !input.sandbox.backendId.trim() || input.nativeToolSurfaceEnabled !== false || isSandboxShellDynamicToolExcluded(input.pluginConfig)) return filteredTools;
|
|
1052
1047
|
const execTool = allTools.find((tool) => normalizeCodexDynamicToolName(tool.name) === "exec");
|
|
1053
1048
|
const processTool = allTools.find((tool) => normalizeCodexDynamicToolName(tool.name) === "process");
|
|
1054
1049
|
if (!execTool || !processTool) return filteredTools;
|
|
@@ -1075,16 +1070,6 @@ function addSandboxShellDynamicToolsIfAvailable(filteredTools, allTools, input)
|
|
|
1075
1070
|
sandboxProcessTool
|
|
1076
1071
|
];
|
|
1077
1072
|
}
|
|
1078
|
-
function shouldExposeSandboxExecDynamicTool(input) {
|
|
1079
|
-
if (isCodexMemoryFlushRun(input.params)) return false;
|
|
1080
|
-
if (isCodexNativeExecutionBlockedByNodeExecHost(input.params, {
|
|
1081
|
-
agentId: input.sessionAgentId,
|
|
1082
|
-
runtimeSessionKey: input.sandboxSessionKey,
|
|
1083
|
-
sandbox: input.sandbox
|
|
1084
|
-
})) return false;
|
|
1085
|
-
const backendId = input.sandbox?.enabled ? input.sandbox.backendId.trim().toLowerCase() : "";
|
|
1086
|
-
return Boolean(backendId && input.nativeToolSurfaceEnabled === false);
|
|
1087
|
-
}
|
|
1088
1073
|
function isSandboxShellDynamicToolExcluded(config) {
|
|
1089
1074
|
return isCodexDynamicToolExcluded(config, [
|
|
1090
1075
|
"exec",
|
|
@@ -1106,17 +1091,6 @@ function addNodeShellDynamicToolsIfNeeded(filteredTools, allTools, input, nodePo
|
|
|
1106
1091
|
function shouldKeepOpenClawShellDynamicTools(input, nodePolicy) {
|
|
1107
1092
|
return !isCodexMemoryFlushRun(input.params) && input.nativeToolSurfaceEnabled === false && input.sandbox?.enabled !== true && nodePolicy.effectiveExecHost !== "node";
|
|
1108
1093
|
}
|
|
1109
|
-
function resolveCodexNativeExecutionPolicyForDynamicTools(input) {
|
|
1110
|
-
return resolveCodexNativeExecutionPolicy({
|
|
1111
|
-
config: input.params.config,
|
|
1112
|
-
sessionKey: resolveCodexRuntimePolicySessionKey(input.params, input.sandboxSessionKey),
|
|
1113
|
-
sessionId: input.params.sessionId,
|
|
1114
|
-
agentId: input.sessionAgentId,
|
|
1115
|
-
execOverrides: input.params.execOverrides,
|
|
1116
|
-
sandboxAvailable: input.sandbox?.enabled,
|
|
1117
|
-
readRuntimeSessionEntry: true
|
|
1118
|
-
});
|
|
1119
|
-
}
|
|
1120
1094
|
/** Applies a normalized tool allowlist while preserving shell aliases for exec/process. */
|
|
1121
1095
|
function filterCodexDynamicToolsForAllowlist(tools, toolsAllow) {
|
|
1122
1096
|
if (!toolsAllow) return tools;
|
|
@@ -1138,9 +1112,9 @@ function shouldForceMessageTool(params) {
|
|
|
1138
1112
|
}
|
|
1139
1113
|
//#endregion
|
|
1140
1114
|
//#region extensions/codex/src/app-server/sandbox-exec-server-node-relay.ts
|
|
1141
|
-
const CODEX_NODE_EXEC_SERVER_MAX_MESSAGE_BYTES$1 =
|
|
1115
|
+
const CODEX_NODE_EXEC_SERVER_MAX_MESSAGE_BYTES$1 = 67108864;
|
|
1142
1116
|
const CODEX_NODE_EXEC_SERVER_MAX_FAILURE_DETAIL_CHARS = 240;
|
|
1143
|
-
const CODEX_NODE_HTTP_CREDENTIAL_BODY_MAX_BYTES =
|
|
1117
|
+
const CODEX_NODE_HTTP_CREDENTIAL_BODY_MAX_BYTES = 1048576;
|
|
1144
1118
|
const CODEX_NODE_HTTP_CREDENTIAL_SCAN_MAX_FIELDS = 256;
|
|
1145
1119
|
const CODEX_NODE_HTTP_CREDENTIAL_SCAN_MAX_DEPTH = 8;
|
|
1146
1120
|
const CODEX_NODE_HTTP_CREDENTIAL_HEADER_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -1780,10 +1754,10 @@ function joinSandboxChildPath(parent, child) {
|
|
|
1780
1754
|
* Implements filesystem JSON-RPC handlers for the Codex sandbox exec-server
|
|
1781
1755
|
* with OpenClaw sandbox policy checks before every bridge operation.
|
|
1782
1756
|
*/
|
|
1783
|
-
const CODEX_SANDBOX_EXEC_SERVER_MAX_READ_FILE_BYTES =
|
|
1757
|
+
const CODEX_SANDBOX_EXEC_SERVER_MAX_READ_FILE_BYTES = 536870912;
|
|
1784
1758
|
const CODEX_SANDBOX_EXEC_SERVER_MAX_OPEN_FILE_READS = 128;
|
|
1785
|
-
const CODEX_SANDBOX_EXEC_SERVER_MAX_BUFFERED_FILE_READ_BYTES =
|
|
1786
|
-
const CODEX_SANDBOX_EXEC_SERVER_MAX_READ_BLOCK_BYTES =
|
|
1759
|
+
const CODEX_SANDBOX_EXEC_SERVER_MAX_BUFFERED_FILE_READ_BYTES = 67108864;
|
|
1760
|
+
const CODEX_SANDBOX_EXEC_SERVER_MAX_READ_BLOCK_BYTES = 1048576;
|
|
1787
1761
|
const CODEX_SANDBOX_EXEC_SERVER_MAX_FILE_READ_HANDLE_ID_BYTES = 32;
|
|
1788
1762
|
/** Opens a policy-checked sandbox file under a bounded, connection-owned handle. */
|
|
1789
1763
|
async function openFile(execServer, handles, params) {
|
|
@@ -2187,7 +2161,7 @@ function delay(ms) {
|
|
|
2187
2161
|
* access through the active OpenClaw sandbox backend.
|
|
2188
2162
|
*/
|
|
2189
2163
|
/** Maximum JSON-line size accepted from the streaming HTTP helper process. */
|
|
2190
|
-
const SANDBOX_HTTP_STREAM_LINE_MAX_CHARS =
|
|
2164
|
+
const SANDBOX_HTTP_STREAM_LINE_MAX_CHARS = 262144;
|
|
2191
2165
|
/** Handles one sandbox HTTP JSON-RPC request, optionally streaming response body deltas. */
|
|
2192
2166
|
async function httpRequest(execServer, notifications, params) {
|
|
2193
2167
|
const record = requireObject(params, "http/request params");
|
|
@@ -2499,6 +2473,9 @@ def assert_url_allowed(url):
|
|
|
2499
2473
|
PINNED_ADDRESSES[hostname] = sorted(addresses)
|
|
2500
2474
|
|
|
2501
2475
|
class GuardedRedirectHandler(urllib.request.HTTPRedirectHandler):
|
|
2476
|
+
# Python 3.9 lacks the 308 dispatch alias; use the same guarded redirect path.
|
|
2477
|
+
http_error_308 = urllib.request.HTTPRedirectHandler.http_error_302
|
|
2478
|
+
|
|
2502
2479
|
def __init__(self, redirect_policy):
|
|
2503
2480
|
self.redirect_policy = redirect_policy
|
|
2504
2481
|
|
|
@@ -2612,7 +2589,7 @@ python3 "$tmp"
|
|
|
2612
2589
|
* termination for Codex sandbox exec-server process RPCs.
|
|
2613
2590
|
*/
|
|
2614
2591
|
const ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
2615
|
-
const RETAINED_PROCESS_OUTPUT_BYTES =
|
|
2592
|
+
const RETAINED_PROCESS_OUTPUT_BYTES = 1048576;
|
|
2616
2593
|
const CLOSED_PROCESS_EVICTION_MS = 6e4;
|
|
2617
2594
|
/** Starts a sandbox-backed process and registers it in the connection-local process table. */
|
|
2618
2595
|
async function startProcess(execServer, processes, notify, params) {
|
|
@@ -2869,10 +2846,11 @@ function readEnv(value) {
|
|
|
2869
2846
|
return env;
|
|
2870
2847
|
}
|
|
2871
2848
|
function readProcessEnv(record) {
|
|
2872
|
-
|
|
2849
|
+
const requestedEnv = {
|
|
2873
2850
|
...buildEnvFromPolicy(record.envPolicy),
|
|
2874
2851
|
...readEnv(record.env)
|
|
2875
|
-
}
|
|
2852
|
+
};
|
|
2853
|
+
return sanitizeEnvVars(requestedEnv).allowed;
|
|
2876
2854
|
}
|
|
2877
2855
|
function buildEnvFromPolicy(value) {
|
|
2878
2856
|
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
@@ -2987,8 +2965,8 @@ var CodexSandboxExecSession = class {
|
|
|
2987
2965
|
* Hosts the local OpenClaw sandbox exec-server that Codex app-server native
|
|
2988
2966
|
* execution can register as an external environment.
|
|
2989
2967
|
*/
|
|
2990
|
-
const CODEX_SANDBOX_EXEC_SERVER_MAX_INBOUND_MESSAGE_BYTES =
|
|
2991
|
-
const CODEX_NODE_EXEC_SERVER_MAX_MESSAGE_BYTES =
|
|
2968
|
+
const CODEX_SANDBOX_EXEC_SERVER_MAX_INBOUND_MESSAGE_BYTES = 104857600;
|
|
2969
|
+
const CODEX_NODE_EXEC_SERVER_MAX_MESSAGE_BYTES = 67108864;
|
|
2992
2970
|
const codexNodeExecServerLeases = /* @__PURE__ */ new WeakMap();
|
|
2993
2971
|
/** Starts or reuses a sandbox exec-server and registers it with Codex app-server. */
|
|
2994
2972
|
async function ensureCodexSandboxExecServerEnvironment(params) {
|
|
@@ -3369,6 +3347,8 @@ async function handleCodexAppServerApprovalRequest(params) {
|
|
|
3369
3347
|
resolvedOutcome = "approved-once";
|
|
3370
3348
|
resolvedMessage = "Codex app-server approval granted for this byte-bound command only.";
|
|
3371
3349
|
}
|
|
3350
|
+
params.signal?.throwIfAborted();
|
|
3351
|
+
if (resolvedOutcome !== "denied") params.paramsForRun.hostCapabilities.assertActive();
|
|
3372
3352
|
emitApprovalEvent(params.paramsForRun, {
|
|
3373
3353
|
phase: "resolved",
|
|
3374
3354
|
kind: context.kind,
|
|
@@ -3407,6 +3387,7 @@ async function handleCodexAppServerApprovalRequest(params) {
|
|
|
3407
3387
|
autoApprove: params.autoApprove,
|
|
3408
3388
|
signal: params.signal
|
|
3409
3389
|
});
|
|
3390
|
+
params.signal?.throwIfAborted();
|
|
3410
3391
|
if (policyOutcome?.outcome === "denied") {
|
|
3411
3392
|
recordNativeToolFailureDisposition(params, context, policyOutcome.failureDisposition);
|
|
3412
3393
|
return await resolvePolicyApproval("denied", policyOutcome.reason);
|
|
@@ -3415,6 +3396,7 @@ async function handleCodexAppServerApprovalRequest(params) {
|
|
|
3415
3396
|
if (CONCRETE_TOOL_AUTO_APPROVAL_METHODS.has(params.method) && !readNetworkApprovalContext(requestParams) && params.autoApprove === true) return await resolvePolicyApproval("approved-session", "Codex app-server approval auto-approved by runtime policy.");
|
|
3416
3397
|
const requestResult = await requestPluginApproval({
|
|
3417
3398
|
hostCapabilities: params.paramsForRun.hostCapabilities,
|
|
3399
|
+
signal: params.signal,
|
|
3418
3400
|
title: context.title,
|
|
3419
3401
|
description: context.description,
|
|
3420
3402
|
severity: context.severity,
|
|
@@ -3928,7 +3910,8 @@ function summarizeNetworkPolicyAmendments(value) {
|
|
|
3928
3910
|
function sanitizePermissionHostValue(value) {
|
|
3929
3911
|
const withoutScheme = sanitizePermissionScalar(value).toLowerCase().replace(/^[a-z][a-z0-9+.-]*:\/\//, "");
|
|
3930
3912
|
const authority = withoutScheme.split(/[/?#]/, 1)[0] ?? withoutScheme;
|
|
3931
|
-
|
|
3913
|
+
const withoutUserInfo = authority.includes("@") ? authority.slice(authority.lastIndexOf("@") + 1) : authority;
|
|
3914
|
+
return truncateCodexApprovalDisplayText(withoutUserInfo, PERMISSION_VALUE_MAX_LENGTH);
|
|
3932
3915
|
}
|
|
3933
3916
|
function sanitizePermissionPathValue(value) {
|
|
3934
3917
|
return truncateCodexApprovalDisplayText(formatApprovalDisplayPath(sanitizePermissionScalar(value)), PERMISSION_VALUE_MAX_LENGTH);
|
|
@@ -4057,7 +4040,8 @@ function appendPreviewPart(source, part, separator) {
|
|
|
4057
4040
|
}
|
|
4058
4041
|
function sanitizeApprovalPreview(source, maxLength) {
|
|
4059
4042
|
if (!source || !source.value) return { omitted: false };
|
|
4060
|
-
const
|
|
4043
|
+
const rawPreview = stripDanglingCodexApprovalTerminalSequence(source.value);
|
|
4044
|
+
const sanitized = sanitizeCodexApprovalVisibleText(rawPreview);
|
|
4061
4045
|
if (!sanitized) return { omitted: true };
|
|
4062
4046
|
return {
|
|
4063
4047
|
text: formatCodexDisplayText(truncateCodexApprovalDisplayText(sanitized, maxLength)),
|
|
@@ -4202,6 +4186,7 @@ async function routeCodexAppServerElicitationRequest(params) {
|
|
|
4202
4186
|
const requestTurnId = requestParams.turnId;
|
|
4203
4187
|
if (requestTurnId !== null && requestTurnId !== void 0 && requestTurnId !== params.turnId) return { kind: "not-mine" };
|
|
4204
4188
|
if (!((isJsonObject(requestParams["_meta"]) ? requestParams["_meta"] : void 0)?.[MCP_TOOL_APPROVAL_KIND_KEY] === MCP_TOOL_APPROVAL_KIND || params.computerUseMcpServerName !== void 0 && readNonBlankStringField(requestParams, "serverName") === params.computerUseMcpServerName)) return { kind: "not-mine" };
|
|
4189
|
+
if (params.signal?.aborted) return handled(createCodexElicitationResponse("cancel"));
|
|
4205
4190
|
const pluginResolution = resolvePluginElicitation({
|
|
4206
4191
|
requestParams,
|
|
4207
4192
|
pluginAppPolicyContext: params.pluginAppPolicyContext
|
|
@@ -4500,7 +4485,8 @@ function readDisplayParamLines(meta) {
|
|
|
4500
4485
|
return remaining > 0 ? [...lines, `- Additional parameters: ${remaining} more`] : lines;
|
|
4501
4486
|
}
|
|
4502
4487
|
function formatDisplayParamValue(value) {
|
|
4503
|
-
|
|
4488
|
+
const formatted = typeof value === "string" ? value : formatDisplayJsonValue(value ?? null);
|
|
4489
|
+
return truncateCodexApprovalDisplayText(sanitizeDisplayText(formatted), MAX_DISPLAY_PARAM_VALUE_LENGTH);
|
|
4504
4490
|
}
|
|
4505
4491
|
function formatDisplayJsonValue(value, depth = MAX_DISPLAY_VALUE_DEPTH) {
|
|
4506
4492
|
if (value === null) return "null";
|
|
@@ -4548,6 +4534,7 @@ async function requestPluginApprovalOutcome(params) {
|
|
|
4548
4534
|
try {
|
|
4549
4535
|
const requestResult = await requestPluginApproval({
|
|
4550
4536
|
hostCapabilities: params.paramsForRun.hostCapabilities,
|
|
4537
|
+
signal: params.signal,
|
|
4551
4538
|
title: params.title,
|
|
4552
4539
|
description: params.description,
|
|
4553
4540
|
severity: "warning",
|
|
@@ -4734,7 +4721,7 @@ function assertCodexDynamicToolInputMatchesSchema(params) {
|
|
|
4734
4721
|
const visibleErrors = validation.errors.slice(0, MAX_CODEX_DYNAMIC_TOOL_VALIDATION_ERRORS);
|
|
4735
4722
|
const details = visibleErrors.map((error) => {
|
|
4736
4723
|
if (error.text.length <= MAX_CODEX_DYNAMIC_TOOL_VALIDATION_ERROR_CHARS) return error.text;
|
|
4737
|
-
return `${error.text.slice(0,
|
|
4724
|
+
return `${error.text.slice(0, 141)}${CODEX_DYNAMIC_TOOL_VALIDATION_TRUNCATED_SUFFIX}`;
|
|
4738
4725
|
}).join("; ");
|
|
4739
4726
|
const omitted = validation.errors.length - visibleErrors.length;
|
|
4740
4727
|
const omittedSuffix = omitted > 0 ? `; ${omitted} more violation(s) omitted` : "";
|
|
@@ -4943,6 +4930,8 @@ function createCodexDynamicToolBridge(params) {
|
|
|
4943
4930
|
messagingToolSentTargets: [],
|
|
4944
4931
|
messagingToolSourceReplyPayloads: [],
|
|
4945
4932
|
toolMediaUrls: [],
|
|
4933
|
+
toolAutoDeliveryMediaUrls: [],
|
|
4934
|
+
coreTtsToolResults: [],
|
|
4946
4935
|
toolAudioAsVoice: false,
|
|
4947
4936
|
acceptedSessionSpawns: [],
|
|
4948
4937
|
quarantinedTools
|
|
@@ -5156,13 +5145,17 @@ function createCodexDynamicToolBridge(params) {
|
|
|
5156
5145
|
const toolConfirmedSourceReply = params.hookContext?.sourceReplyDeliveryMode === "message_tool_only" && toolName === "message" && !resultIsError && (rawResult.terminate === true || result.terminate === true);
|
|
5157
5146
|
const confirmedSourceReply = params.hookContext?.sourceReplyDeliveryMode === "message_tool_only" && toolName === "message" && (toolConfirmedSourceReply || deliveredSourceReply || receiptConfirmedSourceReply);
|
|
5158
5147
|
const sourceReplyFinal = confirmedSourceReply ? executedArgs.final !== false : void 0;
|
|
5148
|
+
const autoDeliveryTtsMediaUrls = getCoreTtsToolResultMediaUrls(rawResult);
|
|
5159
5149
|
collectToolTelemetry({
|
|
5160
5150
|
toolName,
|
|
5161
5151
|
args: executedArgs,
|
|
5162
5152
|
result,
|
|
5163
5153
|
mediaTrustResult: telemetryRawResult,
|
|
5164
5154
|
telemetry,
|
|
5155
|
+
signal,
|
|
5165
5156
|
isError: resultIsError,
|
|
5157
|
+
autoDeliveryTtsMediaUrls,
|
|
5158
|
+
coreTtsToolResult: autoDeliveryTtsMediaUrls?.length ? rawResult : void 0,
|
|
5166
5159
|
messagingTarget: confirmedMessagingTarget,
|
|
5167
5160
|
sourceReplyFinal
|
|
5168
5161
|
});
|
|
@@ -5194,13 +5187,6 @@ function createCodexDynamicToolBridge(params) {
|
|
|
5194
5187
|
toolCallOrdinal: options?.toolCallOrdinal
|
|
5195
5188
|
});
|
|
5196
5189
|
notifyAgentToolResult(options?.onAgentToolResult, toolName, failedResult, true);
|
|
5197
|
-
collectToolTelemetry({
|
|
5198
|
-
toolName,
|
|
5199
|
-
args: executedArgs,
|
|
5200
|
-
result: void 0,
|
|
5201
|
-
telemetry,
|
|
5202
|
-
isError: true
|
|
5203
|
-
});
|
|
5204
5190
|
runAgentHarnessAfterToolCallHook({
|
|
5205
5191
|
toolName,
|
|
5206
5192
|
toolCallId: call.callId,
|
|
@@ -5525,15 +5511,26 @@ function collectToolTelemetry(params) {
|
|
|
5525
5511
|
const response = normalizeHeartbeatToolResponse(params.result?.details);
|
|
5526
5512
|
if (response) params.telemetry.heartbeatToolResponse = response;
|
|
5527
5513
|
}
|
|
5528
|
-
if (
|
|
5514
|
+
if (params.result && !params.signal.aborted) {
|
|
5529
5515
|
const media = extractToolResultMediaArtifact(params.result);
|
|
5530
5516
|
if (media) {
|
|
5531
5517
|
const mediaUrls = filterToolResultMediaUrls(params.toolName, media.mediaUrls, params.mediaTrustResult ?? params.result);
|
|
5532
5518
|
const seen = new Set(params.telemetry.toolMediaUrls);
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5519
|
+
const autoDeliveryMediaUrls = new Set(params.telemetry.toolAutoDeliveryMediaUrls);
|
|
5520
|
+
const rawAutoDeliveryMediaUrls = new Set(params.autoDeliveryTtsMediaUrls);
|
|
5521
|
+
let retainsCoreTtsMedia = false;
|
|
5522
|
+
for (const mediaUrl of mediaUrls) {
|
|
5523
|
+
if (!seen.has(mediaUrl)) {
|
|
5524
|
+
seen.add(mediaUrl);
|
|
5525
|
+
params.telemetry.toolMediaUrls.push(mediaUrl);
|
|
5526
|
+
}
|
|
5527
|
+
if (rawAutoDeliveryMediaUrls.has(mediaUrl)) {
|
|
5528
|
+
autoDeliveryMediaUrls.add(mediaUrl);
|
|
5529
|
+
retainsCoreTtsMedia = true;
|
|
5530
|
+
} else autoDeliveryMediaUrls.delete(mediaUrl);
|
|
5536
5531
|
}
|
|
5532
|
+
params.telemetry.toolAutoDeliveryMediaUrls = [...autoDeliveryMediaUrls];
|
|
5533
|
+
if (retainsCoreTtsMedia && params.coreTtsToolResult && !params.telemetry.coreTtsToolResults.includes(params.coreTtsToolResult)) params.telemetry.coreTtsToolResults.push(params.coreTtsToolResult);
|
|
5537
5534
|
if (media.audioAsVoice) params.telemetry.toolAudioAsVoice = true;
|
|
5538
5535
|
}
|
|
5539
5536
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as retainSharedCodexAppServerClientByInstanceId } from "./shared-client-
|
|
2
|
-
import { d as sessionBindingIdentity } from "./session-binding-
|
|
1
|
+
import { _ as retainSharedCodexAppServerClientByInstanceId } from "./shared-client-B1tT5U6r.js";
|
|
2
|
+
import { d as sessionBindingIdentity } from "./session-binding-D0zinCP1.js";
|
|
3
3
|
import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { assignMcpCatalogSafeServerNames } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
5
5
|
//#region extensions/codex/src/app-server/effective-mcp-catalog.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ht as isJsonObject } from "./shared-client-
|
|
1
|
+
import { Ht as isJsonObject } from "./shared-client-B1tT5U6r.js";
|
|
2
2
|
import { asSafeIntegerInRange, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { normalizeUsage } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
4
4
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
@@ -246,7 +246,7 @@ function readTokenCount(record, key) {
|
|
|
246
246
|
function readCodexThreadTokenUsage(params) {
|
|
247
247
|
const tokenUsage = isJsonObject(params.tokenUsage) ? params.tokenUsage : void 0;
|
|
248
248
|
const last = tokenUsage && isJsonObject(tokenUsage.last) ? tokenUsage.last : void 0;
|
|
249
|
-
return last ?
|
|
249
|
+
return last ? normalizeCodexResponseTokenUsage(last) : void 0;
|
|
250
250
|
}
|
|
251
251
|
function readCodexThreadContextSnapshot(params) {
|
|
252
252
|
const tokenUsage = isJsonObject(params.tokenUsage) ? params.tokenUsage : void 0;
|
|
@@ -256,7 +256,6 @@ function readCodexThreadContextSnapshot(params) {
|
|
|
256
256
|
const inputTokens = last ? readTokenCount(last, "inputTokens") : void 0;
|
|
257
257
|
const cachedInputTokens = last ? readTokenCount(last, "cachedInputTokens") : void 0;
|
|
258
258
|
const cacheWriteInputTokens = last ? readTokenCount(last, "cacheWriteInputTokens") : void 0;
|
|
259
|
-
const outputTokens = last ? readTokenCount(last, "outputTokens") : void 0;
|
|
260
259
|
const reasoningOutputTokens = last ? readTokenCount(last, "reasoningOutputTokens") : void 0;
|
|
261
260
|
return {
|
|
262
261
|
...activeContextTokens !== void 0 ? { activeContextTokens } : {},
|
|
@@ -264,7 +263,6 @@ function readCodexThreadContextSnapshot(params) {
|
|
|
264
263
|
...cacheWriteInputTokens !== void 0 ? { cacheWriteInputTokens } : {},
|
|
265
264
|
...inputTokens !== void 0 ? { inputTokens } : {},
|
|
266
265
|
...modelContextWindow && modelContextWindow > 0 ? { modelContextWindow } : {},
|
|
267
|
-
...outputTokens !== void 0 ? { outputTokens } : {},
|
|
268
266
|
...inputTokens !== void 0 ? { promptTokens: inputTokens } : {},
|
|
269
267
|
...reasoningOutputTokens !== void 0 ? { reasoningOutputTokens } : {}
|
|
270
268
|
};
|
|
@@ -274,13 +272,7 @@ function projectCodexThreadUsageUpdate(params, currentUsage, applyUsage, emitCon
|
|
|
274
272
|
const context = readCodexThreadContextSnapshot(params);
|
|
275
273
|
if (Object.keys(context).length > 0) emitContext(context);
|
|
276
274
|
}
|
|
277
|
-
function normalizeCodexThreadTokenUsage(record) {
|
|
278
|
-
return normalizeCodexTokenUsageBreakdown(record);
|
|
279
|
-
}
|
|
280
275
|
function normalizeCodexResponseTokenUsage(record) {
|
|
281
|
-
return normalizeCodexTokenUsageBreakdown(record);
|
|
282
|
-
}
|
|
283
|
-
function normalizeCodexTokenUsageBreakdown(record) {
|
|
284
276
|
const totalTokens = readTokenCount(record, "totalTokens");
|
|
285
277
|
const inputTokens = readTokenCount(record, "inputTokens");
|
|
286
278
|
const cacheRead = readTokenCount(record, "cachedInputTokens");
|
|
@@ -317,11 +309,14 @@ var CodexResponseCompletionProjection = class {
|
|
|
317
309
|
clear() {
|
|
318
310
|
this.usage = void 0;
|
|
319
311
|
}
|
|
320
|
-
record(params) {
|
|
312
|
+
record(params, reportOutputTokens) {
|
|
321
313
|
const responseId = readStringField(params, "responseId");
|
|
322
|
-
if (responseId
|
|
314
|
+
if (!responseId || this.responseIds.has(responseId)) return;
|
|
315
|
+
this.responseIds.add(responseId);
|
|
323
316
|
const usage = isJsonObject(params.usage) ? params.usage : void 0;
|
|
324
317
|
this.usage = usage ? normalizeCodexResponseTokenUsage(usage) : void 0;
|
|
318
|
+
const outputTokens = this.usage?.output;
|
|
319
|
+
if (outputTokens !== void 0) reportOutputTokens?.(outputTokens);
|
|
325
320
|
}
|
|
326
321
|
};
|
|
327
322
|
//#endregion
|
|
@@ -77,7 +77,7 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
77
77
|
...sessionCatalogControlFactory && sessionRuntime ? { sessionFork: {
|
|
78
78
|
upstreamKinds: ["codex-app-server"],
|
|
79
79
|
fork: async (params) => {
|
|
80
|
-
const { forkCodexUpstreamSession } = await import("./upstream-session-fork-
|
|
80
|
+
const { forkCodexUpstreamSession } = await import("./upstream-session-fork-Dc8BFExw.js");
|
|
81
81
|
return await forkCodexUpstreamSession(params, {
|
|
82
82
|
bindingStore: options.bindingStore,
|
|
83
83
|
controlFactory: sessionCatalogControlFactory,
|
|
@@ -92,22 +92,22 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
92
92
|
return fingerprintCodexAppServerAuthBinding(params);
|
|
93
93
|
} },
|
|
94
94
|
runtimeArtifact: { validate: async (binding) => {
|
|
95
|
-
const { validateCodexAppServerRuntimeArtifact } = await import("./runtime-artifact-
|
|
95
|
+
const { validateCodexAppServerRuntimeArtifact } = await import("./runtime-artifact-D9pYp4zL.js");
|
|
96
96
|
return validateCodexAppServerRuntimeArtifact(binding);
|
|
97
97
|
} },
|
|
98
98
|
fetchUsageSnapshot: async (ctx) => {
|
|
99
|
-
const { fetchCodexAppServerUsageSnapshot } = await import("./usage-
|
|
99
|
+
const { fetchCodexAppServerUsageSnapshot } = await import("./usage-DUhd58gI.js");
|
|
100
100
|
return await fetchCodexAppServerUsageSnapshot(ctx, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
|
|
101
101
|
},
|
|
102
102
|
loadModelCatalog: async (params) => {
|
|
103
|
-
const { createCodexAppServerModelCatalog } = await import("./model-catalog-
|
|
103
|
+
const { createCodexAppServerModelCatalog } = await import("./model-catalog-DULBcniB.js");
|
|
104
104
|
if (disposed) return [];
|
|
105
105
|
modelCatalog ??= createCodexAppServerModelCatalog(harnessRuntimeId);
|
|
106
106
|
return await modelCatalog.load(params, resolveAttemptPluginConfig(params.config));
|
|
107
107
|
},
|
|
108
108
|
readModelCatalogReadiness: (params) => modelCatalog?.read(params, resolveAttemptPluginConfig(params.config)),
|
|
109
109
|
loadMcpToolCatalog: async (params) => {
|
|
110
|
-
const { loadCodexEffectiveMcpCatalog } = await import("./effective-mcp-catalog-
|
|
110
|
+
const { loadCodexEffectiveMcpCatalog } = await import("./effective-mcp-catalog-XXQKgK1U.js");
|
|
111
111
|
return await loadCodexEffectiveMcpCatalog(params, { bindingStore: options.bindingStore });
|
|
112
112
|
},
|
|
113
113
|
supports: (ctx) => {
|
|
@@ -150,7 +150,7 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
150
150
|
};
|
|
151
151
|
},
|
|
152
152
|
runAttempt: async (params) => {
|
|
153
|
-
const { runCodexAppServerAttempt } = await import("./run-attempt-
|
|
153
|
+
const { runCodexAppServerAttempt } = await import("./run-attempt-BVLE4Gbi.js");
|
|
154
154
|
return runCodexAppServerAttempt(params, {
|
|
155
155
|
bindingStore: options.bindingStore,
|
|
156
156
|
pluginConfig: resolveAttemptPluginConfig(params.config),
|
|
@@ -161,7 +161,7 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
161
161
|
},
|
|
162
162
|
runIsolatedCompletionV2: async (params) => {
|
|
163
163
|
if (params.authorization.owner === "host") return runHostPreparedIsolatedCompletion(params);
|
|
164
|
-
const { runCodexIsolatedCompletion } = await import("./isolated-completion-
|
|
164
|
+
const { runCodexIsolatedCompletion } = await import("./isolated-completion-CxTus3vZ.js");
|
|
165
165
|
return runCodexIsolatedCompletion(params, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
|
|
166
166
|
},
|
|
167
167
|
runIsolatedCompletion: async (params) => {
|
|
@@ -176,11 +176,11 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
176
176
|
});
|
|
177
177
|
},
|
|
178
178
|
finalizeSettledTurn: async (params) => {
|
|
179
|
-
const { runCodexSettledTurnFinalization } = await import("./settled-turn-finalizer-
|
|
179
|
+
const { runCodexSettledTurnFinalization } = await import("./settled-turn-finalizer-BXLN9PfJ.js");
|
|
180
180
|
return runCodexSettledTurnFinalization(params, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
|
|
181
181
|
},
|
|
182
182
|
runSideQuestion: async (params) => {
|
|
183
|
-
const { runCodexAppServerSideQuestion } = await import("./side-question-
|
|
183
|
+
const { runCodexAppServerSideQuestion } = await import("./side-question-CZ-mCw-t.js");
|
|
184
184
|
return runCodexAppServerSideQuestion(params, {
|
|
185
185
|
bindingStore: options.bindingStore,
|
|
186
186
|
pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
|
|
@@ -190,20 +190,20 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
190
190
|
});
|
|
191
191
|
},
|
|
192
192
|
compact: async (params) => {
|
|
193
|
-
const { maybeCompactCodexAppServerSession } = await import("./compact-
|
|
193
|
+
const { maybeCompactCodexAppServerSession } = await import("./compact-5xqW1oCh.js");
|
|
194
194
|
return maybeCompactCodexAppServerSession(params, {
|
|
195
195
|
bindingStore: options.bindingStore,
|
|
196
196
|
pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig
|
|
197
197
|
});
|
|
198
198
|
},
|
|
199
199
|
withSessionDeletion: async (params, run) => {
|
|
200
|
-
const { withCodexAppServerSessionDeletion } = await import("./session-retirement-
|
|
200
|
+
const { withCodexAppServerSessionDeletion } = await import("./session-retirement-CtUtUTr9.js");
|
|
201
201
|
params.assertCurrent();
|
|
202
202
|
return withCodexAppServerSessionDeletion(options.bindingStore, params, run);
|
|
203
203
|
},
|
|
204
204
|
reset: async (params) => {
|
|
205
205
|
if (params.sessionId && params.reason !== "deleted") {
|
|
206
|
-
const [{ reclaimCurrentCodexSessionGeneration, sessionBindingIdentity }, { retireCodexAppServerSessionGeneration }] = await Promise.all([import("./session-binding-
|
|
206
|
+
const [{ reclaimCurrentCodexSessionGeneration, sessionBindingIdentity }, { retireCodexAppServerSessionGeneration }] = await Promise.all([import("./session-binding-D0zinCP1.js").then((n) => n.f), import("./session-retirement-CtUtUTr9.js")]);
|
|
207
207
|
const identity = sessionBindingIdentity({
|
|
208
208
|
agentId: params.agentId,
|
|
209
209
|
sessionId: params.sessionId,
|
|
@@ -235,7 +235,7 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
235
235
|
/** Creates the private native-compaction bridge registered in host-owned capability state. */
|
|
236
236
|
function createCodexAppServerNativeCompaction(options) {
|
|
237
237
|
return async (params) => {
|
|
238
|
-
const { maybeCompactCodexAppServerSession } = await import("./compact-
|
|
238
|
+
const { maybeCompactCodexAppServerSession } = await import("./compact-5xqW1oCh.js");
|
|
239
239
|
return maybeCompactCodexAppServerSession(params, {
|
|
240
240
|
bindingStore: options.bindingStore,
|
|
241
241
|
pluginConfig: options.resolvePluginConfig?.() ?? options.pluginConfig,
|
package/dist/harness.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createCodexAppServerNativeCompaction, t as createCodexAppServerAgentHarness } from "./harness-
|
|
1
|
+
import { n as createCodexAppServerNativeCompaction, t as createCodexAppServerAgentHarness } from "./harness-BgeB7LnD.js";
|
|
2
2
|
export { createCodexAppServerAgentHarness, createCodexAppServerNativeCompaction };
|