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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/{app-server-policy-BO3jYBkv.js → app-server-policy-BmDgseo_.js} +1 -1
  2. package/dist/attempt-client-cleanup-Ia52yRWc.js +127 -0
  3. package/dist/{attempt-notifications-DdmnBMUp.js → attempt-notifications-CMR2_fmR.js} +1 -1
  4. package/dist/{bounded-turn-CaQL96kg.js → bounded-turn-FEbUXoYT.js} +36 -13
  5. package/dist/{capabilities-CLICvTxf.js → capabilities-BHRSI6Cn.js} +1 -1
  6. package/dist/cli-metadata.js +1 -1
  7. package/dist/{command-formatters-DgADqnHa.js → command-formatters-ico4ZFnk.js} +2 -2
  8. package/dist/{command-handlers-l_lVPNlB.js → command-handlers-CRmnwI2N.js} +1232 -1221
  9. package/dist/{compact-CC5KhBzX.js → compact-dEN49UH6.js} +7 -7
  10. package/dist/{computer-use-Ip1-QGa-.js → computer-use-BjGylO-E.js} +16 -6
  11. package/dist/{conversation-control-sNPsbTCP.js → conversation-control-DE7d9DOj.js} +6 -6
  12. package/dist/doctor-contract-api.js +24 -86
  13. package/dist/{dynamic-tools-CQI3UwqY.js → dynamic-tools-LIt9ojep.js} +50 -46
  14. package/dist/{event-projector-usage-D6tE7_qD.js → event-projector-usage-tvgb1NCX.js} +2 -2
  15. package/dist/harness.js +14 -13
  16. package/dist/index.js +208 -267
  17. package/dist/media-understanding-provider.js +6 -1
  18. package/dist/{models-BNeMlHgg.js → models-BA01NEez.js} +2 -2
  19. package/dist/{notification-correlation-BGLixv5_.js → notification-correlation-Bj_Ak_jI.js} +3 -3
  20. package/dist/{plugin-app-cache-key-CvzvmBRz.js → plugin-app-cache-key-DSXX-rXO.js} +5 -5
  21. package/dist/{transcript-mirror-2p7kl6e4.js → protocol-validators-Dm4eXZmt.js} +2 -550
  22. package/dist/{rate-limits-D0IJT-a6.js → rate-limits-S_PXs0ul.js} +1 -1
  23. package/dist/realtime-voice-api-BPcA1uN9.js +494 -0
  24. package/dist/realtime-voice-api.js +2 -0
  25. package/dist/{request-BTccUTD3.js → request-CXpPennK.js} +1 -1
  26. package/dist/{run-attempt--858NXDl.js → run-attempt-C5GTPJOE.js} +417 -237
  27. package/dist/{session-binding-ZSMX1omP.js → session-binding-DlVQ-Pxs.js} +952 -890
  28. package/dist/{session-catalog-DsKaezgR.js → session-catalog-CP2oCcEb.js} +32 -23
  29. package/dist/{session-cli-CYJTfRLG.js → session-cli-CqZ0Fp2a.js} +2 -2
  30. package/dist/{session-upstream-marker-D7XlI9us.js → session-upstream-marker-QE-m5QFG.js} +1 -1
  31. package/dist/{settled-turn-finalizer-DHltNgtF.js → settled-turn-finalizer-CA_2QXIE.js} +2 -2
  32. package/dist/{shared-client-wmgNFNYp.js → shared-client-BVKE40c-.js} +1863 -1707
  33. package/dist/{side-question-BfFZCsJ-.js → side-question-CO12sHxo.js} +11 -9
  34. package/dist/{thread-lifecycle-cqrOlJkq.js → thread-lifecycle-DRg_FdzC.js} +12 -132
  35. package/dist/transcript-mirror-uKA-A4tB.js +550 -0
  36. package/dist/{upstream-session-fork-vPjwkT1i.js → upstream-session-fork-_Vrz4WJr.js} +3 -3
  37. package/dist/{usage-DM_I3mPT.js → usage-UpVbdX5G.js} +3 -3
  38. package/dist/{web-search-provider.runtime-Bx6HAc_k.js → web-search-provider.runtime-CaQMYDbp.js} +3 -3
  39. package/package.json +4 -5
  40. package/npm-shrinkwrap.json +0 -202
  41. package/dist/{auth-binding-C1czuHPA.js → auth-binding-B4FfbcCg.js} +1 -1
@@ -1,34 +1,36 @@
1
- import { A as isCodexAppServerStartupError, B as isCodexAppServerApprovalRequest, C as resolveCodexAppServerFallbackApiKeyCacheKey, D as resolveCodexAppServerHomeDir, F as resolveCodexTurnCompletionIdleTimeoutMs, H as isCodexAppServerConnectionClosedError, I as resolveCodexTurnTerminalIdleTimeoutMs, K as isCodexAppServerRequestTimeoutError, L as withCodexStartupTimeout, M as resolveCodexPostToolRawAssistantCompletionIdleTimeoutMs, N as resolveCodexStartupTimeoutMs, O as CODEX_POST_REASONING_REPLY_IDLE_TIMEOUT_MS, P as resolveCodexTurnAssistantCompletionIdleTimeoutMs, Q as isJsonObject, R as CodexAppServerRpcError, S as resolveCodexAppServerAuthProfileIdForAgent, T as resolveCodexAppServerPreparedAuthHandoff, V as isCodexAppServerBrokenPipeError, Z as flattenCodexDynamicToolFunctions, _ as readCodexRateLimitsRevision, a as getLeasedSharedCodexAppServerClient, b as resolveCodexAppServerAuthAccountCacheKey, c as releaseLeasedSharedCodexAppServerClient, d as retireSharedCodexAppServerClientIfCurrent, g as ensureCodexAppServerClientRuntime, k as CodexAppServerStartupError, n as clearSharedCodexAppServerClientIfCurrentAndUnclaimed, o as isCodexAppServerStartSelectionChangedError, t as clearSharedCodexAppServerClientIfCurrent, u as retainSharedCodexAppServerClientIfCurrent, v as readRecentCodexRateLimits, w as resolveCodexAppServerPreparedApiKeyCacheKey, x as resolveCodexAppServerAuthProfileId, y as rememberCodexRateLimitsRead } from "./shared-client-wmgNFNYp.js";
2
- import { S as updateActiveTurnItemIds, _ as readCodexNotificationItem, a as isCodexTurnAbortMarkerNotification, b as shouldDisarmAssistantCompletionIdleWatch, c as isPendingOpenClawDynamicToolCompletionNotification, d as isRawReasoningCompletionNotification, f as isRawToolOutputCompletionNotification, g as isTerminalTurnStatus, h as isRetryableErrorNotification, i as isAssistantCompletionReleaseNotification, l as isRawAssistantProgressNotification, m as isReasoningProgressNotification, n as describeNotificationActivity, o as isFileChangePatchUpdatedNotification, p as isReasoningItemCompletionNotification, r as isAssistantCommentaryCompletionNotification, s as isNativeToolProgressNotification, t as codexExecutionToolName, u as isRawFunctionToolOutputCompletionNotification, v as readNotificationItemId, x as updateActiveCompletionBlockerItemIds, y as readRawResponseToolCallId } from "./attempt-notifications-DdmnBMUp.js";
3
- import { A as withMcpElicitationsApprovalPolicy, E as resolveCodexPluginsPolicy, O as resolveOpenClawExecPolicyForCodexAppServer, T as resolveCodexModelBackedReviewerPolicyContext, _ as isCodexAppServerApprovalPolicyAllowedByRequirements, b as readCodexPluginConfig, c as reclaimCurrentCodexSessionGeneration, i as createCodexSessionGenerationSupersededError, k as shouldAutoApproveCodexAppServerApprovals, l as sessionBindingIdentity, w as resolveCodexComputerUseConfig, y as isCodexSandboxExecServerEnabled } from "./session-binding-ZSMX1omP.js";
4
- import { $ as shouldBuildCodexPluginThreadConfig, B as codexDynamicToolsFingerprint, F as closeCodexStartupClientBestEffort, G as projectContextEngineAssemblyForCodex, H as buildContextEngineBinding, I as interruptCodexTurnBestEffort, K as resolveCodexContextEngineProjectionMaxChars, L as retireCodexAppServerClientAfterTimedOutTurn, M as CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS, N as CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS, O as isSystemAgentOnlyCodexDynamicToolAllowlist, P as CodexAppServerUnsafeSubscriptionError, Q as mergeCodexThreadConfigs, R as unsubscribeCodexThreadBestEffort, T as filterCodexDynamicTools, U as isContextEngineBindingCompatible, V as codexLegacyDynamicToolsFingerprint, W as fitCodexProjectedContextForTurnStart, X as buildCodexPluginThreadConfigInputFingerprint, Y as buildCodexPluginThreadConfig, Z as buildCodexPluginThreadConfigTimeoutFallback, a as sanitizeCodexHistoryImagePayloads, at as readCodexErrorNotificationMessage, b as resolveCodexAppServerThreadModelSelection, ct as readItemString, dt as readNonNegativeInteger, ft as readNullableString$1, g as buildDeveloperInstructions, h as resolveCodexWebSearchPlan, ht as splitPlanText, it as normalizeNonEmptyString, j as resolveCodexDynamicToolsLoadingForRuntime, lt as readNonEmptyString$1, mt as readString$5, n as buildTurnStartParams, nt as resolveRecoverableCodexPluginConfigKeys, ot as readHookOutputEntries, pt as readNumber, q as resolveCodexContextEngineProjectionReserveTokens, r as buildCodexUserInput, rt as extractRawAssistantText, s as startOrResumeThread, st as readItem, t as buildTurnCollaborationMode, ut as readNonEmptyStringArray, w as isCodexAppServerProfilerEnabled, z as areCodexDynamicToolFingerprintsCompatible } from "./thread-lifecycle-cqrOlJkq.js";
5
- import { n as projectCodexThreadUsageUpdate, t as normalizeCodexResponseTokenUsage } from "./event-projector-usage-D6tE7_qD.js";
6
- import { C as readCodexTurnCompletedNotification, S as readCodexTurn, d as attachCodexMirrorIdentity, f as readMirrorIdentity, i as mirrorPromptAtTurnStartBestEffort, n as createCodexAppServerUserMessagePersistenceNotifier, o as buildCodexUserPromptMessage, s as promptSnapshot, t as codexTranscriptMirrorRuntime, u as serializeCodexMirrorSourceEvidence, v as assertCodexTurnStartResponse, y as readCodexDynamicToolCallParams } from "./transcript-mirror-2p7kl6e4.js";
7
- import { i as defaultCodexAppInventoryCache, n as buildCodexAppServerRuntimeFingerprint, r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-CvzvmBRz.js";
1
+ import { $ as withCodexStartupTimeout, A as rememberCodexRateLimitsRead, B as flattenCodexDynamicToolFunctions, D as ensureCodexAppServerClientRuntime, F as resolveCodexAppServerPreparedApiKeyCacheKey, G as CodexAppServerStartupError, I as resolveCodexAppServerPreparedAuthHandoff, J as resolveCodexPostToolRawAssistantCompletionIdleTimeoutMs, K as isCodexAppServerStartupError, M as resolveCodexAppServerAuthProfileId, N as resolveCodexAppServerAuthProfileIdForAgent, O as readCodexRateLimitsRevision, P as resolveCodexAppServerFallbackApiKeyCacheKey, Q as resolveCodexTurnTerminalIdleTimeoutMs, T as isCodexAppServerRequestTimeoutError, U as resolveCodexAppServerHomeDir, V as isJsonObject, W as CODEX_POST_REASONING_REPLY_IDLE_TIMEOUT_MS, X as resolveCodexTurnAssistantCompletionIdleTimeoutMs, Y as resolveCodexStartupTimeoutMs, Z as resolveCodexTurnCompletionIdleTimeoutMs, _ as CodexAppServerRpcError, a as getLeasedSharedCodexAppServerClient, b as isCodexAppServerBrokenPipeError, d as retainSharedCodexAppServerClientIfCurrent, f as retireSharedCodexAppServerClientIfCurrent, j as resolveCodexAppServerAuthAccountCacheKey, k as readRecentCodexRateLimits, l as releaseLeasedSharedCodexAppServerClient, n as clearSharedCodexAppServerClientIfCurrentAndUnclaimed, o as getSharedCodexAppServerClient, s as isCodexAppServerStartSelectionChangedError, t as clearSharedCodexAppServerClientIfCurrent, v as getCodexAppServerClientInstanceId, x as isCodexAppServerConnectionClosedError, y as isCodexAppServerApprovalRequest } from "./shared-client-BVKE40c-.js";
2
+ import { C as isCodexAppServerApprovalPolicyAllowedByRequirements, D as resolveOpenClawExecPolicyForCodexAppServer, E as resolveCodexPluginsPolicy, S as resolveCodexModelBackedReviewerPolicyContext, T as readCodexPluginConfig, c as reclaimCurrentCodexSessionGeneration, h as resolveCodexComputerUseConfig, i as createCodexSessionGenerationSupersededError, l as sessionBindingIdentity, v as shouldAutoApproveCodexAppServerApprovals, w as isCodexSandboxExecServerEnabled, y as withMcpElicitationsApprovalPolicy } from "./session-binding-DlVQ-Pxs.js";
3
+ import { a as closeCodexStartupClientBestEffort, l as retireCodexAppServerClientAfterTimedOutTurn, n as CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS, r as CodexAppServerUnsafeSubscriptionError, s as interruptCodexTurnBestEffort, t as CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS, u as unsubscribeCodexThreadBestEffort } from "./attempt-client-cleanup-Ia52yRWc.js";
4
+ import { S as updateActiveTurnItemIds, _ as readCodexNotificationItem, a as isCodexTurnAbortMarkerNotification, b as shouldDisarmAssistantCompletionIdleWatch, c as isPendingOpenClawDynamicToolCompletionNotification, d as isRawReasoningCompletionNotification, f as isRawToolOutputCompletionNotification, g as isTerminalTurnStatus, h as isRetryableErrorNotification, i as isAssistantCompletionReleaseNotification, l as isRawAssistantProgressNotification, m as isReasoningProgressNotification, n as describeNotificationActivity, o as isFileChangePatchUpdatedNotification, p as isReasoningItemCompletionNotification, r as isAssistantCommentaryCompletionNotification, s as isNativeToolProgressNotification, t as codexExecutionToolName, u as isRawFunctionToolOutputCompletionNotification, v as readNotificationItemId, x as updateActiveCompletionBlockerItemIds, y as readRawResponseToolCallId } from "./attempt-notifications-CMR2_fmR.js";
5
+ import { $ as readHookOutputEntries, B as resolveCodexContextEngineProjectionReserveTokens, F as buildContextEngineBinding, G as mergeCodexThreadConfigs, H as buildCodexPluginThreadConfig, I as isContextEngineBindingCompatible, K as shouldBuildCodexPluginThreadConfig, L as fitCodexProjectedContextForTurnStart, M as areCodexDynamicToolFingerprintsCompatible, N as codexDynamicToolsFingerprint, O as isSystemAgentOnlyCodexDynamicToolAllowlist, P as codexLegacyDynamicToolsFingerprint, Q as readCodexErrorNotificationMessage, R as projectContextEngineAssemblyForCodex, T as filterCodexDynamicTools, U as buildCodexPluginThreadConfigInputFingerprint, W as buildCodexPluginThreadConfigTimeoutFallback, X as extractRawAssistantText, Y as resolveRecoverableCodexPluginConfigKeys, Z as normalizeNonEmptyString, a as sanitizeCodexHistoryImagePayloads, at as readNullableString$1, b as resolveCodexAppServerThreadModelSelection, ct as splitPlanText, et as readItem, g as buildDeveloperInstructions, h as resolveCodexWebSearchPlan, it as readNonNegativeInteger, j as resolveCodexDynamicToolsLoadingForRuntime, n as buildTurnStartParams, nt as readNonEmptyString$1, ot as readNumber, r as buildCodexUserInput, rt as readNonEmptyStringArray, s as startOrResumeThread, st as readString$6, t as buildTurnCollaborationMode, tt as readItemString, w as isCodexAppServerProfilerEnabled, z as resolveCodexContextEngineProjectionMaxChars } from "./thread-lifecycle-DRg_FdzC.js";
6
+ import { n as projectCodexThreadUsageUpdate, t as normalizeCodexResponseTokenUsage } from "./event-projector-usage-tvgb1NCX.js";
7
+ import { a as assertCodexTurnStartResponse, l as readCodexTurn, o as readCodexDynamicToolCallParams, u as readCodexTurnCompletedNotification } from "./protocol-validators-Dm4eXZmt.js";
8
+ import { i as defaultCodexAppInventoryCache, n as buildCodexAppServerRuntimeFingerprint, r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-DSXX-rXO.js";
8
9
  import { t as isIncognitoSessionKey } from "./incognito-session-ET_ufDH-.js";
9
- import { t as CODEX_CONTROL_METHODS } from "./capabilities-CLICvTxf.js";
10
- import { a as shouldRefreshCodexRateLimitsForUsageLimitMessage, i as resolveCodexUsageLimitResetAtMs, n as formatCodexUsageLimitErrorMessage } from "./rate-limits-D0IJT-a6.js";
11
- import { r as formatCodexDisplayText } from "./command-formatters-DgADqnHa.js";
12
- import { n as resolveCodexAppServerForOpenClawToolPolicy, t as resolveCodexAppServerForModelProvider } from "./app-server-policy-BO3jYBkv.js";
13
- import { a as resolveCodexBindingAppServerConnection, n as readCodexNotificationThreadId, r as readCodexNotificationTurnId, t as isCodexNotificationForTurn } from "./notification-correlation-BGLixv5_.js";
14
- import { n as prepareCodexAppServerAuthBinding } from "./auth-binding-C1czuHPA.js";
10
+ import { d as attachCodexMirrorIdentity, f as readMirrorIdentity, i as mirrorPromptAtTurnStartBestEffort, n as createCodexAppServerUserMessagePersistenceNotifier, o as buildCodexUserPromptMessage, s as promptSnapshot, t as codexTranscriptMirrorRuntime, u as serializeCodexMirrorSourceEvidence } from "./transcript-mirror-uKA-A4tB.js";
11
+ import { t as CODEX_CONTROL_METHODS } from "./capabilities-BHRSI6Cn.js";
12
+ import { a as shouldRefreshCodexRateLimitsForUsageLimitMessage, i as resolveCodexUsageLimitResetAtMs, n as formatCodexUsageLimitErrorMessage } from "./rate-limits-S_PXs0ul.js";
13
+ import { r as formatCodexDisplayText } from "./command-formatters-ico4ZFnk.js";
14
+ import { n as resolveCodexAppServerForOpenClawToolPolicy, t as resolveCodexAppServerForModelProvider } from "./app-server-policy-BmDgseo_.js";
15
+ import { a as resolveCodexBindingAppServerConnection, n as readCodexNotificationThreadId, r as readCodexNotificationTurnId, t as isCodexNotificationForTurn } from "./notification-correlation-Bj_Ak_jI.js";
16
+ import { n as prepareCodexAppServerAuthBinding } from "./auth-binding-B4FfbcCg.js";
15
17
  import { i as resolveCodexLocalRuntimeAttribution, n as createAssistantMessage, r as createAssistantMirrorMessage, t as createAssistantCommentaryMessage } from "./event-projector-assistant-message-DTgnPPVF.js";
16
- import { $ as shouldSynthesizeToolProgressForItem, A as resolveCodexNativeHookRelayEvents, B as shouldReleaseTurnAfterTerminalDynamicTool, C as CodexNativeToolLifecycleProjector, D as buildCodexNativeHookRelayDisabledConfig, E as buildCodexNativeHookRelayConfig, F as isDynamicToolTerminalDiagnosticEvent, G as isNonSuccessItemStatus, H as toCodexDynamicToolProtocolResponse, I as isMatchingDynamicToolTerminalDiagnostic, J as itemName, K as isSideEffectingNativeToolItem, L as resolveDynamicToolCallTimeoutMs, M as scheduleCodexNativeHookRelayUnregister, N as handleDynamicToolCallWithTimeout, O as createCodexNativeHookRelay, P as hasPendingDynamicToolTerminalDiagnostic, Q as shouldRecordNativeToolTranscript, R as resolveTerminalDynamicToolBatchAction, T as CODEX_NATIVE_HOOK_RELAY_TTL_GRACE_MS, U as resolveCodexToolAbortTerminalReason, V as toCodexDynamicToolProgressResponse, W as isMutatingNativeToolItem, X as itemTitle, Y as itemStatus, Z as shouldClearTerminalPresentationForNativeItem, _ as resolveCodexMessageToolProvider, a as emitDynamicToolStartedDiagnostic, b as shouldRequireCodexSandboxExecServerEnvironment, d as createCodexDynamicToolBuildStageTracker, et as unknownItemStatus, f as disableCodexPluginThreadConfig, g as resolveCodexExternalSandboxPolicyForOpenClawSandbox, h as resolveCodexAppServerHookChannelId, i as emitDynamicToolErrorDiagnostic, j as resolveCodexNativeHookRelayTtlMs, k as emitCodexNativePreToolUseFailureDiagnostic, l as settleCodexSourceReplyFinality, m as resolveCodexAppServerExecutionCwd, n as handleCodexAppServerApprovalRequest, o as emitDynamicToolTerminalDiagnostic, p as formatCodexDynamicToolBuildStageSummary, q as itemKind, r as handleCodexAppServerElicitationRequest, s as resolveCodexProviderWebSearchSupport, t as createCodexDynamicToolBridge, u as buildDynamicTools, v as resolveCodexSandboxEnvironmentSelection, x as shouldWarnCodexDynamicToolBuildStageSummary, y as shouldEnableCodexAppServerNativeToolSurface, z as shouldBlockTerminalReleaseForNonTerminalDynamicToolResult } from "./dynamic-tools-CQI3UwqY.js";
17
- import { a as runCodexComputerUseLiveTest, r as killStaleComputerUseMcpChildren, t as ensureCodexComputerUse } from "./computer-use-Ip1-QGa-.js";
18
+ import { $ as shouldSynthesizeToolProgressForItem, A as resolveCodexNativeHookRelayEvents, B as shouldReleaseTurnAfterTerminalDynamicTool, C as CodexNativeToolLifecycleProjector, D as buildCodexNativeHookRelayDisabledConfig, E as buildCodexNativeHookRelayConfig, F as isDynamicToolTerminalDiagnosticEvent, G as isNonSuccessItemStatus, H as toCodexDynamicToolProtocolResponse, I as isMatchingDynamicToolTerminalDiagnostic, J as itemName, K as isSideEffectingNativeToolItem, L as resolveDynamicToolCallTimeoutMs, M as scheduleCodexNativeHookRelayUnregister, N as handleDynamicToolCallWithTimeout, O as createCodexNativeHookRelay, P as hasPendingDynamicToolTerminalDiagnostic, Q as shouldRecordNativeToolTranscript, R as resolveTerminalDynamicToolBatchAction, T as CODEX_NATIVE_HOOK_RELAY_TTL_GRACE_MS, U as resolveCodexToolAbortTerminalReason, V as toCodexDynamicToolProgressResponse, W as isMutatingNativeToolItem, X as itemTitle, Y as itemStatus, Z as shouldClearTerminalPresentationForNativeItem, _ as resolveCodexMessageToolProvider, a as emitDynamicToolStartedDiagnostic, b as shouldRequireCodexSandboxExecServerEnvironment, d as createCodexDynamicToolBuildStageTracker, et as unknownItemStatus, f as disableCodexPluginThreadConfig, g as resolveCodexExternalSandboxPolicyForOpenClawSandbox, h as resolveCodexAppServerHookChannelId, i as emitDynamicToolErrorDiagnostic, j as resolveCodexNativeHookRelayTtlMs, k as emitCodexNativePreToolUseFailureDiagnostic, l as settleCodexSourceReplyFinality, m as resolveCodexAppServerExecutionCwd, n as handleCodexAppServerApprovalRequest, o as emitDynamicToolTerminalDiagnostic, p as formatCodexDynamicToolBuildStageSummary, q as itemKind, r as handleCodexAppServerElicitationRequest, s as resolveCodexProviderWebSearchSupport, t as createCodexDynamicToolBridge, u as buildDynamicTools, v as resolveCodexSandboxEnvironmentSelection, x as shouldWarnCodexDynamicToolBuildStageSummary, y as shouldEnableCodexAppServerNativeToolSurface, z as shouldBlockTerminalReleaseForNonTerminalDynamicToolResult } from "./dynamic-tools-LIt9ojep.js";
19
+ import { a as runCodexComputerUseLiveTest, r as killStaleComputerUseMcpChildren, t as ensureCodexComputerUse } from "./computer-use-BjGylO-E.js";
18
20
  import fs from "node:fs/promises";
19
21
  import path, { posix } from "node:path";
20
22
  import { asDateTimestampMs, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
21
- import { sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
23
+ import { AgentHarnessPreflightError, CODEX_APP_SERVER_CONTEXT_ENGINE_HOST, FAST_MODE_AUTO_PROGRESS_KIND, TOOL_PROGRESS_OUTPUT_MAX_CHARS, agentHarnessAttemptTerminal, assembleHarnessContextEngine, assertContextEngineHostSupport, awaitAgentEndSideEffects, bootstrapHarnessContextEngine, buildAgentHarnessUserInputAnswers, buildBootstrapContextForFiles, buildHarnessContextEngineRuntimeContext, buildHarnessContextEngineRuntimeContextFromUsage, callGatewayTool, cancelPendingAgentQuestionForSession, claimPendingAgentQuestionAnswer, classifyAgentHarnessTerminalOutcome, clearActiveEmbeddedRun, deliverAgentHarnessUserInputPrompt, embeddedAgentLog, emitAgentEvent, emptyAgentHarnessUserInputAnswers, finalizeHarnessContextEngineTurn, formatErrorMessage, formatFastModeAutoProgressText, formatToolAggregate, formatToolProgressOutput, getAgentHarnessHookRunner, getBeforeToolCallPolicyDiagnosticState, inferToolMetaFromArgs, isActiveHarnessContextEngine, isHostScopedAgentToolActive, loadCodexBundleMcpThreadConfig, materializeRequesterScopedMcpToolsForHarnessRun, prepareHarnessNativeMcpAppPreview, projectAgentHarnessTranscriptMessageForDisplay, resolveAgentDir, resolveAgentHarnessBeforePromptBuildResult, resolveAgentRunAbortLifecycleFields, resolveBootstrapFilesForRun, resolveContextEngineOwnerPluginId, resolveFastModeForElapsed, resolveSandboxContext, resolveSessionAgentIds, resolveUserPath, runAgentCleanupStep, runAgentEndSideEffects, runAgentHarnessAfterCompactionHook, runAgentHarnessAfterToolCallHook, runAgentHarnessBeforeCompactionHook, runAgentHarnessGatewayQuestion, runAgentHarnessLlmInputHook, runAgentHarnessLlmOutputHook, runHarnessContextEngineMaintenance, setActiveEmbeddedRun, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
22
24
  import { createHash, randomUUID } from "node:crypto";
23
- import { markAuthProfileBlockedUntil, resolveAgentDir, resolveAgentWorkspaceDir } from "openclaw/plugin-sdk/agent-runtime";
25
+ import { markAuthProfileBlockedUntil, resolveAgentDir as resolveAgentDir$1, resolveAgentWorkspaceDir } from "openclaw/plugin-sdk/agent-runtime";
24
26
  import { loadExecApprovals } from "openclaw/plugin-sdk/exec-approvals-runtime";
25
27
  import { asFiniteNumber, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
26
- import { CODEX_APP_SERVER_CONTEXT_ENGINE_HOST, FAST_MODE_AUTO_PROGRESS_KIND, TOOL_PROGRESS_OUTPUT_MAX_CHARS, assembleHarnessContextEngine, assertContextEngineHostSupport, awaitAgentEndSideEffects, bootstrapHarnessContextEngine, buildAgentHarnessUserInputAnswers, buildBootstrapContextForFiles, buildHarnessContextEngineRuntimeContext, buildHarnessContextEngineRuntimeContextFromUsage, callGatewayTool, cancelPendingAgentQuestionForSession, claimPendingAgentQuestionAnswer, classifyAgentHarnessTerminalOutcome, clearActiveEmbeddedRun, deliverAgentHarnessUserInputPrompt, embeddedAgentLog, emitAgentEvent, emptyAgentHarnessUserInputAnswers, finalizeHarnessContextEngineTurn, formatErrorMessage, formatFastModeAutoProgressText, formatToolAggregate, formatToolProgressOutput, getAgentHarnessHookRunner, getBeforeToolCallPolicyDiagnosticState, inferToolMetaFromArgs, isActiveHarnessContextEngine, isHostScopedAgentToolActive, loadCodexBundleMcpThreadConfig, materializeRequesterScopedMcpToolsForHarnessRun, projectAgentHarnessTranscriptMessageForDisplay, resolveAgentDir as resolveAgentDir$1, resolveAgentHarnessBeforePromptBuildResult, resolveAgentRunAbortLifecycleFields, resolveBootstrapFilesForRun, resolveContextEngineOwnerPluginId, resolveFastModeForElapsed, resolveSandboxContext, resolveSessionAgentIds as resolveSessionAgentIds$1, resolveUserPath, runAgentCleanupStep, runAgentEndSideEffects, runAgentHarnessAfterCompactionHook, runAgentHarnessAfterToolCallHook, runAgentHarnessBeforeCompactionHook, runAgentHarnessGatewayQuestion, runAgentHarnessLlmInputHook, runAgentHarnessLlmOutputHook, runHarnessContextEngineMaintenance, setActiveEmbeddedRun, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
28
+ import { listSessionEntries, parseSqliteSessionFileMarker } from "openclaw/plugin-sdk/session-store-runtime";
27
29
  import { spawn } from "node:child_process";
30
+ import { sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
28
31
  import { once } from "node:events";
29
32
  import { isIP } from "node:net";
30
33
  import { WebSocketServer } from "ws";
31
- import { listSessionEntries, parseSqliteSessionFileMarker } from "openclaw/plugin-sdk/session-store-runtime";
32
34
  import { fileURLToPath } from "node:url";
33
35
  import { redactSensitiveFieldValue, redactSensitiveText, redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
34
36
  import { createDiagnosticTraceContextFromActiveScope, emitTrustedDiagnosticEvent, emitTrustedDiagnosticEventWithPrivateData, freezeDiagnosticTraceContext, onInternalDiagnosticEvent, resolveDiagnosticModelContentCapturePolicy } from "openclaw/plugin-sdk/diagnostic-runtime";
@@ -37,6 +39,7 @@ import { prepareMemorySystemPromptAddition } from "openclaw/plugin-sdk/core";
37
39
  import { sanitizeTerminalText } from "openclaw/plugin-sdk/text-chunking";
38
40
  import { buildSessionContext, migrateSessionEntries, parseSessionEntries } from "openclaw/plugin-sdk/agent-sessions";
39
41
  import { generatedImageAssetFromBase64 } from "openclaw/plugin-sdk/image-generation";
42
+ import { resolveGeneratedMediaMaxBytes } from "openclaw/plugin-sdk/media-generation-runtime";
40
43
  import { saveMediaBuffer } from "openclaw/plugin-sdk/media-store";
41
44
  import { MESSAGE_TOOL_DELIVERY_HINTS } from "openclaw/plugin-sdk/message-tool-delivery-hints";
42
45
  import { createAgentHarnessTaskRuntime, deliverAgentHarnessTaskCompletion, isDurableAgentHarnessCompletionDelivery } from "openclaw/plugin-sdk/agent-harness-task-runtime";
@@ -201,6 +204,9 @@ function normalizeCodexSteerDebounceMs(value) {
201
204
  return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.floor(value) : CODEX_STEER_ALL_DEBOUNCE_MS;
202
205
  }
203
206
  //#endregion
207
+ //#region extensions/codex/src/app-server/attempt-terminal.ts
208
+ const attemptTerminal = agentHarnessAttemptTerminal;
209
+ //#endregion
204
210
  //#region extensions/codex/src/app-server/event-projector-assistant.ts
205
211
  var CodexAssistantProjection = class {
206
212
  constructor(params, emitAgentEvent, matchesToolProgressEcho, nextTranscriptTimestamp) {
@@ -244,8 +250,8 @@ var CodexAssistantProjection = class {
244
250
  return this.latestTerminalAssistantCandidateCanReleaseAfterToolHandoff && this.hasLatestTerminalAssistantCandidateText();
245
251
  }
246
252
  async handleAssistantDelta(params) {
247
- const itemId = readString$5(params, "itemId") ?? "assistant";
248
- const delta = readString$5(params, "delta") ?? "";
253
+ const itemId = readString$6(params, "itemId") ?? "assistant";
254
+ const delta = readString$6(params, "delta") ?? "";
249
255
  if (!delta) return;
250
256
  if (itemId !== this.pendingRawTerminalAssistantEchoItemId) this.pendingRawTerminalAssistantEchoItemId = void 0;
251
257
  const isCommentary = this.isCommentaryAssistantItem(itemId);
@@ -327,9 +333,9 @@ var CodexAssistantProjection = class {
327
333
  }
328
334
  }
329
335
  handleRawResponseItemCompleted(item, activeItemIds) {
330
- const role = readString$5(item, "role");
331
- const phase = readString$5(item, "phase");
332
- const rawItemId = readString$5(item, "id");
336
+ const role = readString$6(item, "role");
337
+ const phase = readString$6(item, "phase");
338
+ const rawItemId = readString$6(item, "id");
333
339
  const candidateWasSupersededBeforeRaw = this.latestTerminalAssistantCandidateSuperseded;
334
340
  const pendingTerminalAssistantEchoItemId = this.pendingRawTerminalAssistantEchoItemId;
335
341
  const isPendingTerminalAssistantEcho = role === "assistant" && phase !== "commentary" && pendingTerminalAssistantEchoItemId !== void 0 && (rawItemId === void 0 || rawItemId === pendingTerminalAssistantEchoItemId);
@@ -652,7 +658,7 @@ function collectDynamicToolContentText(contentItems) {
652
658
  if (!Array.isArray(contentItems)) return "";
653
659
  return contentItems.flatMap((entry) => {
654
660
  if (!isJsonObject(entry)) return [];
655
- const text = readString$5(entry, "text");
661
+ const text = readString$6(entry, "text");
656
662
  return text ? [text] : [];
657
663
  }).join("\n");
658
664
  }
@@ -1043,8 +1049,8 @@ var CodexToolProgressProjection = class {
1043
1049
  if (params.sideEffectEvidence === true) this.sideEffectingDynamicIds.add(params.callId);
1044
1050
  }
1045
1051
  handleOutputDelta(params, toolName) {
1046
- const itemId = readString$5(params, "itemId");
1047
- const delta = readString$5(params, "delta");
1052
+ const itemId = readString$6(params, "itemId");
1053
+ const delta = readString$6(params, "delta");
1048
1054
  if (!itemId || !delta) return;
1049
1055
  const storedOutput = this.output.append(itemId, delta);
1050
1056
  this.rememberEcho(itemId, {
@@ -1276,6 +1282,13 @@ var CodexToolProgressProjection = class {
1276
1282
  function isMissingFileError(error) {
1277
1283
  return Boolean(error && typeof error === "object" && "code" in error && error.code === "ENOENT");
1278
1284
  }
1285
+ function selectPreferredSessionKey(matches, sessionId) {
1286
+ const structural = matches.filter(({ sessionKey }) => sessionKey === sessionId || sessionKey.endsWith(`:${sessionId}`));
1287
+ const candidates = structural.length > 0 ? structural : matches;
1288
+ if (candidates.length === 1) return candidates[0]?.sessionKey;
1289
+ const sorted = candidates.toSorted((left, right) => (right.entry.updatedAt ?? 0) - (left.entry.updatedAt ?? 0));
1290
+ return (sorted[0]?.entry.updatedAt ?? 0) > (sorted[1]?.entry.updatedAt ?? 0) ? sorted[0]?.sessionKey : void 0;
1291
+ }
1279
1292
  /** Returns sanitized session-context messages for a Codex mirrored session file. */
1280
1293
  async function readCodexMirroredSessionHistoryMessages(target) {
1281
1294
  try {
@@ -1310,17 +1323,16 @@ async function readCodexMirroredSessionEntries(target) {
1310
1323
  }
1311
1324
  function resolveSqliteMarkerSessionKey(target, marker) {
1312
1325
  const explicitSessionKey = target.sessionKey?.trim();
1313
- if (explicitSessionKey) return explicitSessionKey;
1314
1326
  const entries = listSessionEntries({
1315
1327
  agentId: marker.agentId,
1316
1328
  readOnly: true,
1317
1329
  storePath: marker.storePath
1318
1330
  });
1319
- return (entries.find(({ entry }) => {
1320
- return entry.sessionId === marker.sessionId && entry.sessionFile === target.sessionFile;
1321
- }) ?? entries.find(({ entry }) => {
1322
- return entry.sessionId === marker.sessionId;
1323
- }))?.sessionKey;
1331
+ if (explicitSessionKey) {
1332
+ const explicitEntry = entries.find(({ sessionKey }) => sessionKey === explicitSessionKey);
1333
+ if (explicitEntry) return explicitEntry.entry.sessionId === marker.sessionId ? explicitSessionKey : void 0;
1334
+ }
1335
+ return selectPreferredSessionKey(entries.filter(({ entry }) => entry.sessionId === marker.sessionId), marker.sessionId);
1324
1336
  }
1325
1337
  //#endregion
1326
1338
  //#region extensions/codex/src/app-server/event-projector-tool-transcript.ts
@@ -1356,6 +1368,8 @@ var CodexToolTranscriptProjection = class {
1356
1368
  this.trajectoryNamesById = /* @__PURE__ */ new Map();
1357
1369
  this.trajectoryItemsById = /* @__PURE__ */ new Map();
1358
1370
  this.afterToolCallObservedItemIds = /* @__PURE__ */ new Set();
1371
+ this.nativeMcpAppResultDetails = /* @__PURE__ */ new Map();
1372
+ this.nativeMcpAppResultDetailsAttempted = /* @__PURE__ */ new Set();
1359
1373
  }
1360
1374
  get transcriptMessages() {
1361
1375
  return this.messages;
@@ -1372,7 +1386,8 @@ var CodexToolTranscriptProjection = class {
1372
1386
  id: params.callId,
1373
1387
  name: params.tool,
1374
1388
  text: collectDynamicToolContentText(params.contentItems),
1375
- isError: !params.success
1389
+ isError: !params.success,
1390
+ details: params.details
1376
1391
  });
1377
1392
  }
1378
1393
  recordNativeToolCall(item) {
@@ -1384,16 +1399,37 @@ var CodexToolTranscriptProjection = class {
1384
1399
  arguments: itemToolArgs(item)
1385
1400
  });
1386
1401
  }
1387
- recordNativeToolResult(item) {
1402
+ recordNativeToolResult(item, details) {
1388
1403
  if (!item || !shouldRecordNativeToolTranscript(item)) return;
1389
1404
  const name = itemName(item);
1390
1405
  if (name) this.recordToolResult({
1391
1406
  id: item.id,
1392
1407
  name,
1393
1408
  text: itemTranscriptResultText(item, this.progress.outputTextByItem),
1394
- isError: isNonSuccessItemStatus(itemStatus(item))
1409
+ isError: isNonSuccessItemStatus(itemStatus(item)),
1410
+ details
1395
1411
  });
1396
1412
  }
1413
+ async recordNativeToolResultWithDetails(item) {
1414
+ this.recordNativeToolResult(item, await this.prepareNativeMcpAppResultDetails(item));
1415
+ }
1416
+ async prepareNativeMcpAppResultDetails(item) {
1417
+ if (!item || item.type !== "mcpToolCall" || itemStatus(item) === "running") return;
1418
+ if (this.nativeMcpAppResultDetails.has(item.id)) return this.nativeMcpAppResultDetails.get(item.id);
1419
+ if (this.nativeMcpAppResultDetailsAttempted.has(item.id) || !this.options.prepareNativeMcpAppResultDetails) return;
1420
+ this.nativeMcpAppResultDetailsAttempted.add(item.id);
1421
+ try {
1422
+ const details = await this.options.prepareNativeMcpAppResultDetails(item);
1423
+ if (details !== void 0) this.nativeMcpAppResultDetails.set(item.id, details);
1424
+ return details;
1425
+ } catch (error) {
1426
+ embeddedAgentLog.debug("codex native MCP App preview preparation failed", {
1427
+ itemId: item.id,
1428
+ error
1429
+ });
1430
+ return;
1431
+ }
1432
+ }
1397
1433
  recordTrajectoryEvent(params) {
1398
1434
  if (params.phase === "start") {
1399
1435
  this.trajectoryCallIds.add(params.item.id);
@@ -1578,6 +1614,7 @@ var CodexToolTranscriptProjection = class {
1578
1614
  content: text,
1579
1615
  text
1580
1616
  }],
1617
+ ...params.details !== void 0 ? { details: params.details } : {},
1581
1618
  timestamp: this.nextTranscriptTimestamp()
1582
1619
  };
1583
1620
  }
@@ -1616,14 +1653,14 @@ var CodexEventProjection = class {
1616
1653
  data: {
1617
1654
  method,
1618
1655
  phase: method.endsWith("/started") ? "started" : "completed",
1619
- reviewId: readString$5(params, "reviewId"),
1656
+ reviewId: readString$6(params, "reviewId"),
1620
1657
  targetItemId: readNullableString$1(params, "targetItemId"),
1621
- decisionSource: readString$5(params, "decisionSource"),
1622
- status: review ? readString$5(review, "status") : void 0,
1623
- riskLevel: review ? readString$5(review, "riskLevel") : void 0,
1624
- userAuthorization: review ? readString$5(review, "userAuthorization") : void 0,
1658
+ decisionSource: readString$6(params, "decisionSource"),
1659
+ status: review ? readString$6(review, "status") : void 0,
1660
+ riskLevel: review ? readString$6(review, "riskLevel") : void 0,
1661
+ userAuthorization: review ? readString$6(review, "userAuthorization") : void 0,
1625
1662
  rationale: review ? readNullableString$1(review, "rationale") : void 0,
1626
- actionType: action ? readString$5(action, "type") : void 0
1663
+ actionType: action ? readString$6(action, "type") : void 0
1627
1664
  }
1628
1665
  });
1629
1666
  }
@@ -1632,7 +1669,7 @@ var CodexEventProjection = class {
1632
1669
  stream: "codex_app_server.guardian",
1633
1670
  data: {
1634
1671
  phase: "warning",
1635
- message: readString$5(params, "message")
1672
+ message: readString$6(params, "message")
1636
1673
  }
1637
1674
  });
1638
1675
  }
@@ -1648,14 +1685,14 @@ var CodexEventProjection = class {
1648
1685
  phase: method === "hook/started" ? "started" : "completed",
1649
1686
  threadId: this.threadId,
1650
1687
  turnId: hookTurnId === void 0 ? this.turnId : hookTurnId,
1651
- hookRunId: readString$5(run, "id"),
1652
- eventName: readString$5(run, "eventName"),
1653
- handlerType: readString$5(run, "handlerType"),
1654
- executionMode: readString$5(run, "executionMode"),
1655
- scope: readString$5(run, "scope"),
1656
- source: readString$5(run, "source"),
1657
- sourcePath: readString$5(run, "sourcePath"),
1658
- status: readString$5(run, "status"),
1688
+ hookRunId: readString$6(run, "id"),
1689
+ eventName: readString$6(run, "eventName"),
1690
+ handlerType: readString$6(run, "handlerType"),
1691
+ executionMode: readString$6(run, "executionMode"),
1692
+ scope: readString$6(run, "scope"),
1693
+ source: readString$6(run, "source"),
1694
+ sourcePath: readString$6(run, "sourcePath"),
1695
+ status: readString$6(run, "status"),
1659
1696
  statusMessage: readNullableString$1(run, "statusMessage"),
1660
1697
  ...durationMs !== void 0 ? { durationMs } : {},
1661
1698
  ...entries.length > 0 ? { entries } : {}
@@ -1736,8 +1773,6 @@ var CodexEventProjection = class {
1736
1773
  //#endregion
1737
1774
  //#region extensions/codex/src/app-server/event-projector-media.ts
1738
1775
  const GENERATED_IMAGE_MEDIA_SUBDIR = "tool-image-generation";
1739
- const BYTES_PER_MB = 1024 * 1024;
1740
- const DEFAULT_GENERATED_IMAGE_MAX_BYTES = 6 * BYTES_PER_MB;
1741
1776
  var CodexGeneratedMediaProjection = class {
1742
1777
  constructor(config) {
1743
1778
  this.config = config;
@@ -1756,12 +1791,12 @@ var CodexGeneratedMediaProjection = class {
1756
1791
  });
1757
1792
  }
1758
1793
  async recordRaw(item) {
1759
- if (readString$5(item, "type") !== "image_generation_call") return;
1760
- const result = readString$5(item, "result");
1794
+ if (readString$6(item, "type") !== "image_generation_call") return;
1795
+ const result = readString$6(item, "result");
1761
1796
  if (!result) return;
1762
- const itemId = readString$5(item, "id") ?? `raw-image-${this.itemIds.size}`;
1797
+ const itemId = readString$6(item, "id") ?? `raw-image-${this.itemIds.size}`;
1763
1798
  this.itemIds.add(itemId);
1764
- const maxBytes = resolveGeneratedImageMaxBytes(this.config);
1799
+ const maxBytes = resolveGeneratedMediaMaxBytes(this.config, "image");
1765
1800
  const estimatedDecodedBytes = estimateBase64DecodedBytes(result);
1766
1801
  if (estimatedDecodedBytes !== void 0 && estimatedDecodedBytes > maxBytes) {
1767
1802
  embeddedAgentLog.warn("codex app-server raw image generation result exceeds media limit", {
@@ -1774,7 +1809,7 @@ var CodexGeneratedMediaProjection = class {
1774
1809
  const asset = generatedImageAssetFromBase64({
1775
1810
  base64: result,
1776
1811
  index: this.itemIds.size,
1777
- revisedPrompt: readString$5(item, "revised_prompt") ?? readString$5(item, "revisedPrompt"),
1812
+ revisedPrompt: readString$6(item, "revised_prompt") ?? readString$6(item, "revisedPrompt"),
1778
1813
  fileNamePrefix: "codex-image-generation",
1779
1814
  sniffMimeType: true
1780
1815
  });
@@ -1831,11 +1866,6 @@ function estimateBase64DecodedBytes(base64) {
1831
1866
  function isBase64WhitespaceCode(code) {
1832
1867
  return code === 32 || code === 9 || code === 10 || code === 13;
1833
1868
  }
1834
- function resolveGeneratedImageMaxBytes(config) {
1835
- const configured = config?.agents?.defaults?.mediaMaxMb;
1836
- if (typeof configured === "number" && Number.isFinite(configured) && configured > 0) return Math.floor(configured * BYTES_PER_MB);
1837
- return DEFAULT_GENERATED_IMAGE_MAX_BYTES;
1838
- }
1839
1869
  //#endregion
1840
1870
  //#region extensions/codex/src/app-server/event-projector-reasoning.ts
1841
1871
  var CodexReasoningProjection = class {
@@ -1849,8 +1879,8 @@ var CodexReasoningProjection = class {
1849
1879
  this.reasoningEnded = false;
1850
1880
  }
1851
1881
  async handleReasoningDelta(method, params) {
1852
- const itemId = readString$5(params, "itemId") ?? "reasoning";
1853
- const delta = readString$5(params, "delta") ?? "";
1882
+ const itemId = readString$6(params, "itemId") ?? "reasoning";
1883
+ const delta = readString$6(params, "delta") ?? "";
1854
1884
  if (!delta) return;
1855
1885
  this.reasoningStarted = true;
1856
1886
  if (!this.reasoningItemOrder.has(itemId)) this.reasoningItemOrder.set(itemId, this.reasoningItemOrder.size);
@@ -1869,8 +1899,8 @@ var CodexReasoningProjection = class {
1869
1899
  });
1870
1900
  }
1871
1901
  handlePlanDelta(params) {
1872
- const itemId = readString$5(params, "itemId") ?? "plan";
1873
- const delta = readString$5(params, "delta") ?? "";
1902
+ const itemId = readString$6(params, "itemId") ?? "plan";
1903
+ const delta = readString$6(params, "delta") ?? "";
1874
1904
  if (!delta) return;
1875
1905
  const text = `${this.planTextByItem.get(itemId) ?? ""}${delta}`;
1876
1906
  this.planTextByItem.set(itemId, text);
@@ -1887,11 +1917,11 @@ var CodexReasoningProjection = class {
1887
1917
  const plan = Array.isArray(params.plan) ? params.plan.flatMap((entry) => {
1888
1918
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) return [];
1889
1919
  const record = entry;
1890
- const step = readString$5(record, "step");
1920
+ const step = readString$6(record, "step");
1891
1921
  if (!step) return [];
1892
1922
  return [{
1893
1923
  step,
1894
- status: normalizePlanStepStatus(readString$5(record, "status"))
1924
+ status: normalizePlanStepStatus(readString$6(record, "status"))
1895
1925
  }];
1896
1926
  }) : void 0;
1897
1927
  const planText = [explanation, ...(plan ?? []).map(({ step, status }) => `- [${status}] ${step}`)].filter((part) => Boolean(part)).join("\n");
@@ -2086,7 +2116,7 @@ function readCodexErrorNotification(notification) {
2086
2116
  if (notification?.method !== "error" || !isJsonObject(notification.params)) return;
2087
2117
  const error = notification.params.error;
2088
2118
  return isJsonObject(error) ? {
2089
- message: readString$4(error, "message"),
2119
+ message: readString$5(error, "message"),
2090
2120
  codexErrorInfo: error.codexErrorInfo
2091
2121
  } : void 0;
2092
2122
  }
@@ -2098,12 +2128,12 @@ function readCodexErrorPayload(error) {
2098
2128
  const nestedError = isJsonObject(data.error) ? data.error : data;
2099
2129
  const rateLimits = nestedError.rateLimits ?? data.rateLimits;
2100
2130
  return {
2101
- message: readString$4(nestedError, "message") ?? message,
2131
+ message: readString$5(nestedError, "message") ?? message,
2102
2132
  codexErrorInfo: nestedError.codexErrorInfo,
2103
2133
  rateLimits
2104
2134
  };
2105
2135
  }
2106
- function readString$4(record, key) {
2136
+ function readString$5(record, key) {
2107
2137
  const value = record[key];
2108
2138
  return typeof value === "string" ? value : void 0;
2109
2139
  }
@@ -2131,6 +2161,7 @@ var CodexAppServerEventProjector = class {
2131
2161
  this.toolProgressProjection = new CodexToolProgressProjection(params);
2132
2162
  this.toolTranscriptProjection = new CodexToolTranscriptProjection(params, threadId, turnId, this.toolProgressProjection, () => this.nextTranscriptTimestamp(), {
2133
2163
  nativePostToolUseRelayEnabled: options.nativePostToolUseRelayEnabled,
2164
+ prepareNativeMcpAppResultDetails: options.prepareNativeMcpAppResultDetails,
2134
2165
  trajectoryRecorder: options.trajectoryRecorder
2135
2166
  });
2136
2167
  this.eventProjection = new CodexEventProjection(threadId, turnId, (event) => this.emitAgentEvent(event), this.toolProgressProjection, this.toolTranscriptProjection, options.onNativeToolResultRecorded);
@@ -2305,14 +2336,11 @@ var CodexAppServerEventProjector = class {
2305
2336
  const toolMetas = this.toolProgressProjection.toolMetas;
2306
2337
  const hadPotentialSideEffects = toolTelemetry.didSendViaMessagingTool || (toolTelemetry.successfulCronAdds ?? 0) > 0 || this.generatedMediaProjection.hasGeneratedMedia() || this.toolProgressProjection.hasPotentialSideEffects;
2307
2338
  return {
2308
- aborted: this.aborted,
2309
- externalAbort: false,
2310
- timedOut: false,
2311
- idleTimedOut: false,
2312
- timedOutDuringCompaction: false,
2313
- timedOutDuringToolExecution: false,
2314
- promptError,
2315
- promptErrorSource: promptError ? this.promptErrorSource || "prompt" : null,
2339
+ terminal: attemptTerminal.normalize({
2340
+ aborted: this.aborted,
2341
+ promptError,
2342
+ promptErrorSource: promptError ? this.promptErrorSource || "prompt" : null
2343
+ }),
2316
2344
  sessionIdUsed: this.params.sessionId,
2317
2345
  ...agentHarnessResultClassification ? { agentHarnessResultClassification } : {},
2318
2346
  bootstrapPromptWarningSignaturesSeen: this.params.bootstrapPromptWarningSignaturesSeen,
@@ -2371,7 +2399,7 @@ var CodexAppServerEventProjector = class {
2371
2399
  }
2372
2400
  async handleItemStarted(params) {
2373
2401
  const item = readItem(params.item);
2374
- const itemId = item?.id ?? readString$5(params, "itemId");
2402
+ const itemId = item?.id ?? readString$6(params, "itemId");
2375
2403
  this.assistantProjection.recordItemStarted(item, itemId);
2376
2404
  if (itemId) this.activeItemIds.add(itemId);
2377
2405
  this.recordNativeToolOutcome(item);
@@ -2427,7 +2455,7 @@ var CodexAppServerEventProjector = class {
2427
2455
  this.diagnostics.warnUnknownItemStatus(item);
2428
2456
  this.recordNativeToolOutcome(item);
2429
2457
  this.clearTerminalPresentationForNativeItem(item);
2430
- const itemId = item?.id ?? readString$5(params, "itemId");
2458
+ const itemId = item?.id ?? readString$6(params, "itemId");
2431
2459
  if (itemId) {
2432
2460
  this.activeItemIds.delete(itemId);
2433
2461
  this.completedItemIds.add(itemId);
@@ -2477,7 +2505,7 @@ var CodexAppServerEventProjector = class {
2477
2505
  item
2478
2506
  });
2479
2507
  this.toolTranscriptProjection.recordNativeToolCall(item);
2480
- this.toolTranscriptProjection.recordNativeToolResult(item);
2508
+ await this.toolTranscriptProjection.recordNativeToolResultWithDetails(item);
2481
2509
  this.toolProgressProjection.emitToolResultSummary(item);
2482
2510
  this.toolProgressProjection.emitToolResultOutput(item);
2483
2511
  this.emitAgentEvent({
@@ -2526,7 +2554,7 @@ var CodexAppServerEventProjector = class {
2526
2554
  this.toolProgressProjection.rememberCommandAggregateOutputEcho(item);
2527
2555
  await this.emitSnapshotOnlyNativeToolProgress(item);
2528
2556
  this.toolTranscriptProjection.recordNativeToolCall(item);
2529
- this.toolTranscriptProjection.recordNativeToolResult(item);
2557
+ await this.toolTranscriptProjection.recordNativeToolResultWithDetails(item);
2530
2558
  this.toolTranscriptProjection.emitAfterToolCallObservation(item);
2531
2559
  this.toolProgressProjection.emitToolResultSummary(item);
2532
2560
  this.toolProgressProjection.emitToolResultOutput(item);
@@ -2584,7 +2612,7 @@ var CodexAppServerEventProjector = class {
2584
2612
  formatCodexErrorMessage(params) {
2585
2613
  const error = isJsonObject(params.error) ? params.error : void 0;
2586
2614
  const usageLimitMessage = formatCodexUsageLimitErrorMessage({
2587
- message: error ? readString$5(error, "message") : void 0,
2615
+ message: error ? readString$6(error, "message") : void 0,
2588
2616
  codexErrorInfo: error?.codexErrorInfo,
2589
2617
  rateLimits: this.options.readRecentRateLimits?.()
2590
2618
  });
@@ -2616,7 +2644,7 @@ var CodexAppServerEventProjector = class {
2616
2644
  return threadId === this.threadId && turnId === this.turnId;
2617
2645
  }
2618
2646
  isHookNotificationForCurrentThread(params) {
2619
- const threadId = readString$5(params, "threadId");
2647
+ const threadId = readString$6(params, "threadId");
2620
2648
  const turnId = params.turnId;
2621
2649
  return threadId === this.threadId && (turnId === this.turnId || turnId === null);
2622
2650
  }
@@ -2625,6 +2653,128 @@ function isHookNotificationMethod(method) {
2625
2653
  return method === "hook/started" || method === "hook/completed";
2626
2654
  }
2627
2655
  //#endregion
2656
+ //#region extensions/codex/src/app-server/native-mcp-app.ts
2657
+ function asRecord(value) {
2658
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
2659
+ }
2660
+ function readString$4(value) {
2661
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
2662
+ }
2663
+ function readMcpAppResourceUri(item) {
2664
+ const uri = readString$4(asRecord(item.appContext)?.resourceUri) ?? readString$4(item.mcpAppResourceUri);
2665
+ return uri?.startsWith("ui://") ? uri : void 0;
2666
+ }
2667
+ function readMcpToolResult(item) {
2668
+ const result = asRecord(item.result);
2669
+ if (!result || !Array.isArray(result.content)) return;
2670
+ const resultMeta = asRecord(result["_meta"]);
2671
+ return {
2672
+ content: result.content,
2673
+ ...result.structuredContent !== void 0 ? { structuredContent: result.structuredContent } : {},
2674
+ ...result.isError === true ? { isError: true } : {},
2675
+ ...resultMeta ? { _meta: resultMeta } : {}
2676
+ };
2677
+ }
2678
+ function statusTools(status) {
2679
+ return Object.entries(status.tools).map(([name, value]) => Object.assign({}, asRecord(value), { name }));
2680
+ }
2681
+ function createNativeMcpRuntime(params) {
2682
+ let catalog = null;
2683
+ let statuses;
2684
+ const createdAt = Date.now();
2685
+ const loadStatuses = async () => {
2686
+ if (statuses) return statuses;
2687
+ statuses = (await params.client.request("mcpServerStatus/list", {
2688
+ threadId: params.threadId,
2689
+ detail: "full"
2690
+ })).data;
2691
+ return statuses;
2692
+ };
2693
+ const getCatalog = async () => {
2694
+ if (catalog) return catalog;
2695
+ const loaded = await loadStatuses();
2696
+ catalog = {
2697
+ version: 1,
2698
+ generatedAt: Date.now(),
2699
+ servers: Object.fromEntries(loaded.map((status) => [status.name, {
2700
+ serverName: status.name,
2701
+ launchSummary: "Codex native MCP connection",
2702
+ toolCount: Object.keys(status.tools).length
2703
+ }])),
2704
+ tools: loaded.flatMap((status) => statusTools(status).map((tool) => ({
2705
+ serverName: status.name,
2706
+ safeServerName: status.name,
2707
+ toolName: String(tool.name),
2708
+ inputSchema: asRecord(tool.inputSchema) ?? { type: "object" },
2709
+ fallbackDescription: readString$4(tool.description) ?? String(tool.name)
2710
+ })))
2711
+ };
2712
+ return catalog;
2713
+ };
2714
+ const runtime = {
2715
+ sessionId: params.attempt.sessionId,
2716
+ sessionKey: params.attempt.sessionKey,
2717
+ workspaceDir: params.attempt.workspaceDir,
2718
+ configFingerprint: `${getCodexAppServerClientInstanceId(params.client)}:${params.threadId}`,
2719
+ mcpAppsEnabled: true,
2720
+ createdAt,
2721
+ lastUsedAt: createdAt,
2722
+ acquireLease: () => retainSharedCodexAppServerClientIfCurrent(params.client) ?? (() => {}),
2723
+ getCatalog,
2724
+ peekCatalog: () => catalog,
2725
+ markUsed: () => {
2726
+ runtime.lastUsedAt = Date.now();
2727
+ },
2728
+ callTool: async (serverName, toolName, input) => await params.client.request("mcpServer/tool/call", {
2729
+ threadId: params.threadId,
2730
+ server: serverName,
2731
+ tool: toolName,
2732
+ arguments: asRecord(input) ?? {}
2733
+ }),
2734
+ listTools: async (serverName) => {
2735
+ const status = (await loadStatuses()).find((entry) => entry.name === serverName);
2736
+ return { tools: status ? statusTools(status) : [] };
2737
+ },
2738
+ readResource: async (serverName, uri) => await params.client.request("mcpServer/resource/read", {
2739
+ threadId: params.threadId,
2740
+ server: serverName,
2741
+ uri
2742
+ }),
2743
+ listResources: async (serverName) => {
2744
+ return { resources: (await loadStatuses()).find((entry) => entry.name === serverName)?.resources ?? [] };
2745
+ },
2746
+ listResourceTemplates: async (serverName) => {
2747
+ return { resourceTemplates: (await loadStatuses()).find((entry) => entry.name === serverName)?.resourceTemplates ?? [] };
2748
+ },
2749
+ dispose: async () => {}
2750
+ };
2751
+ return runtime;
2752
+ }
2753
+ function createCodexNativeMcpAppResultDetailsPreparer(params) {
2754
+ if (params.attempt.config?.mcp?.apps?.enabled !== true) return;
2755
+ const runtime = createNativeMcpRuntime(params);
2756
+ return async (item) => {
2757
+ const serverName = readString$4(item.server);
2758
+ const toolName = readString$4(item.tool);
2759
+ const uiResourceUri = readMcpAppResourceUri(item);
2760
+ const toolResult = readMcpToolResult(item);
2761
+ if (!serverName || !toolName || !uiResourceUri || !toolResult) return;
2762
+ const allowedAppToolNames = new Set((await runtime.getCatalog()).tools.filter((tool) => tool.serverName === serverName).map((tool) => tool.toolName));
2763
+ if (allowedAppToolNames.size === 0) return;
2764
+ return await prepareHarnessNativeMcpAppPreview({
2765
+ runtime,
2766
+ serverName,
2767
+ toolName,
2768
+ uiResourceUri,
2769
+ toolCallId: item.id,
2770
+ toolInput: item.arguments ?? {},
2771
+ toolResult,
2772
+ allowedAppToolNames,
2773
+ ...toolResult["_meta"] !== void 0 ? { resultMetaState: "unavailable" } : {}
2774
+ });
2775
+ };
2776
+ }
2777
+ //#endregion
2628
2778
  //#region extensions/codex/src/app-server/user-input-bridge.ts
2629
2779
  /** Bridges Codex request_user_input calls to gateway questions and secret text prompts. */
2630
2780
  const DEFAULT_USER_INPUT_TIMEOUT_MS = 15 * 6e4;
@@ -2693,6 +2843,7 @@ function createCodexUserInputBridge(params) {
2693
2843
  questions: requestParams.questions,
2694
2844
  sessionKey: params.paramsForRun.sessionKey ?? params.paramsForRun.sessionId,
2695
2845
  agentId: params.paramsForRun.agentId,
2846
+ runId: params.paramsForRun.runId,
2696
2847
  timeoutMs: requestParams.autoResolutionMs ?? params.paramsForRun.timeoutMs ?? DEFAULT_USER_INPUT_TIMEOUT_MS,
2697
2848
  gatewayCall,
2698
2849
  delivery: params.paramsForRun,
@@ -2812,6 +2963,11 @@ async function activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notif
2812
2963
  const { emitExecutionPhaseOnce, emitLifecycleStart, maybeAnnounceFastModeAutoOff } = lifecycle;
2813
2964
  const { enqueueNotification } = notifications;
2814
2965
  const activeTurnId = turn.turn.id;
2966
+ const prepareNativeMcpAppResultDetails = createCodexNativeMcpAppResultDetailsPreparer({
2967
+ client: resourceState.client,
2968
+ threadId: resourceState.thread.threadId,
2969
+ attempt: dynamicToolParams
2970
+ });
2815
2971
  const streamState = {
2816
2972
  eventEmitted: false,
2817
2973
  needsTerminalSnapshot: false
@@ -2844,6 +3000,7 @@ async function activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notif
2844
3000
  runAbortSignal: runAbortController.signal,
2845
3001
  trajectoryRecorder,
2846
3002
  onNativeToolResultRecorded: maybeAnnounceFastModeAutoOff,
3003
+ ...prepareNativeMcpAppResultDetails ? { prepareNativeMcpAppResultDetails } : {},
2847
3004
  upstreamUserText: turnState.codexTurnPromptText,
2848
3005
  onContextCompacted: () => {
2849
3006
  computerContextEpoch.value += 1;
@@ -2909,6 +3066,7 @@ async function activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notif
2909
3066
  await activeSteeringQueue.queue(text, optionsLocal);
2910
3067
  },
2911
3068
  isStreaming: () => !state.completed && !runAbortController.signal.aborted,
3069
+ isAborted: () => runAbortController.signal.aborted,
2912
3070
  isStopped: () => state.completed || state.timedOut || runAbortController.signal.aborted,
2913
3071
  isAbortable: () => !terminalState.terminalOutcomeFrozen || terminalState.sharedAbortAllowedAfterTerminalOutcome,
2914
3072
  isCompacting: () => projectorRef.current?.isCompacting() ?? false,
@@ -3049,7 +3207,8 @@ const codexWorkspaceDirCache = /* @__PURE__ */ new Set();
3049
3207
  //#region extensions/codex/src/app-server/run-attempt-lifecycle.ts
3050
3208
  const CODEX_APP_SERVER_PROJECTED_CHARS_PER_TOKEN = 4;
3051
3209
  function shouldKeepCodexSharedAbortOpen(params) {
3052
- if (params.explicitCancellationObserved || params.result.aborted || params.result.externalAbort) return false;
3210
+ const terminal = attemptTerminal.project(params.result.terminal);
3211
+ if (params.explicitCancellationObserved || terminal.aborted || terminal.externalAbort) return false;
3053
3212
  return params.trigger === "memory" || !params.attemptSucceeded;
3054
3213
  }
3055
3214
  function withCodexAppServerFastModeServiceTier(appServer, params) {
@@ -3400,7 +3559,7 @@ async function prepareCodexAttemptConnection({ params, options }) {
3400
3559
  const runtimeArtifactRequest = params.captureRuntimeArtifact || params.expectedRuntimeArtifact ? params.expectedRuntimeArtifact ? { expected: params.expectedRuntimeArtifact } : {} : void 0;
3401
3560
  const pluginConfig = readCodexPluginConfig(options.pluginConfig);
3402
3561
  const computerUseConfig = resolveCodexComputerUseConfig({ pluginConfig });
3403
- const { sessionAgentId } = resolveSessionAgentIds$1({
3562
+ const { sessionAgentId } = resolveSessionAgentIds({
3404
3563
  sessionKey: params.sessionKey,
3405
3564
  config: params.config,
3406
3565
  agentId: params.agentId
@@ -3424,7 +3583,7 @@ async function prepareCodexAttemptConnection({ params, options }) {
3424
3583
  config: params.config,
3425
3584
  agentId: sessionAgentId
3426
3585
  });
3427
- const agentDir = params.agentDir ?? resolveAgentDir(params.config ?? {}, sessionAgentId);
3586
+ const agentDir = params.agentDir ?? resolveAgentDir$1(params.config ?? {}, sessionAgentId);
3428
3587
  const bindingIdentity = sessionBindingIdentity({
3429
3588
  sessionId: params.sessionId,
3430
3589
  sessionKey: params.sessionKey,
@@ -3484,6 +3643,7 @@ async function prepareCodexAttemptConnection({ params, options }) {
3484
3643
  authProfileId: resolvedStartupAuthProfileId,
3485
3644
  authProfileStore: params.authProfileStore,
3486
3645
  agentDir,
3646
+ ...pluginConfig.appServer?.homeScope ? { homeScope: pluginConfig.appServer.homeScope } : {},
3487
3647
  config: params.config,
3488
3648
  subscriptionProfileRequiredError: "Prepared Codex subscription route requires a forwarded OpenAI OAuth or token profile.",
3489
3649
  subscriptionProfileUnusableError: "Prepared Codex subscription auth profile is unusable."
@@ -3665,20 +3825,18 @@ async function prepareCodexAttemptConnection({ params, options }) {
3665
3825
  * system-prompt reports, and context-engine projection decisions.
3666
3826
  */
3667
3827
  const CODEX_NATIVE_PROJECT_DOC_BASENAMES = /* @__PURE__ */ new Set(["agents.md"]);
3668
- const CODEX_INHERITED_WORKSPACE_DEVELOPER_CONTEXT_BASENAMES = /* @__PURE__ */ new Set(["tools.md"]);
3669
3828
  const CODEX_TURN_SCOPED_WORKSPACE_DEVELOPER_CONTEXT_BASENAMES = /* @__PURE__ */ new Set([
3670
3829
  "identity.md",
3671
3830
  "soul.md",
3672
3831
  "user.md"
3673
3832
  ]);
3674
- const CODEX_WORKSPACE_DEVELOPER_CONTEXT_BASENAMES = /* @__PURE__ */ new Set([...CODEX_INHERITED_WORKSPACE_DEVELOPER_CONTEXT_BASENAMES, ...CODEX_TURN_SCOPED_WORKSPACE_DEVELOPER_CONTEXT_BASENAMES]);
3833
+ const CODEX_WORKSPACE_DEVELOPER_CONTEXT_BASENAMES = new Set(CODEX_TURN_SCOPED_WORKSPACE_DEVELOPER_CONTEXT_BASENAMES);
3675
3834
  const CODEX_MEMORY_CONTEXT_BASENAME = "memory.md";
3676
3835
  const CODEX_MEMORY_TOOL_NAMES = /* @__PURE__ */ new Set(["memory_search", "memory_get"]);
3677
3836
  const CODEX_BOOTSTRAP_CONTEXT_ORDER = /* @__PURE__ */ new Map([
3678
3837
  ["soul.md", 10],
3679
3838
  ["identity.md", 20],
3680
3839
  ["user.md", 30],
3681
- ["tools.md", 40],
3682
3840
  ["bootstrap.md", 50],
3683
3841
  ["memory.md", 60]
3684
3842
  ]);
@@ -3779,20 +3937,17 @@ async function buildCodexWorkspaceBootstrapContext(params) {
3779
3937
  excludeMemory: memoryToolsAvailable,
3780
3938
  memoryWorkspaceDir: params.effectiveWorkspace
3781
3939
  });
3782
- const developerInstructionFiles = shouldInjectCodexOpenClawPromptContext(params.params) ? selectCodexWorkspaceInheritedDeveloperInstructionFiles(contextFiles) : [];
3783
3940
  const turnScopedDeveloperInstructionFiles = shouldInjectCodexOpenClawPromptContext(params.params) ? selectCodexWorkspaceTurnScopedDeveloperInstructionFiles(contextFiles) : [];
3784
3941
  return {
3785
3942
  bootstrapFiles,
3786
3943
  contextFiles,
3787
3944
  promptContextFiles,
3788
- developerInstructionFiles,
3789
3945
  turnScopedDeveloperInstructionFiles,
3790
3946
  memoryReferenceFiles,
3791
3947
  memoryToolRoutedBootstrapFiles,
3792
3948
  memoryToolNames: [...params.memoryToolNames],
3793
3949
  memoryToolRouted: memoryToolsAvailable,
3794
3950
  promptContext: renderCodexWorkspaceBootstrapPromptContext(promptContextFiles),
3795
- developerInstructions: renderCodexWorkspaceThreadDeveloperInstructions(developerInstructionFiles),
3796
3951
  turnScopedDeveloperInstructions: renderCodexWorkspaceCollaborationDeveloperInstructions(turnScopedDeveloperInstructionFiles),
3797
3952
  memoryCollaborationInstructions: shouldInjectCodexOpenClawPromptContext(params.params) ? await renderCodexWorkspaceMemoryCollaborationInstructions({
3798
3953
  files: memoryReferenceFiles,
@@ -3841,7 +3996,7 @@ function buildCodexSystemPromptReport(params) {
3841
3996
  injectedWorkspaceFiles: buildCodexBootstrapInjectionStats({
3842
3997
  bootstrapFiles: params.workspaceBootstrapContext.bootstrapFiles,
3843
3998
  injectedFiles: params.workspaceBootstrapContext.promptContextFiles ?? [],
3844
- developerInstructionFiles: [...params.workspaceBootstrapContext.developerInstructionFiles ?? [], ...params.workspaceBootstrapContext.turnScopedDeveloperInstructionFiles ?? []],
3999
+ developerInstructionFiles: params.workspaceBootstrapContext.turnScopedDeveloperInstructionFiles ?? [],
3845
4000
  memoryToolRoutedBootstrapFiles: params.workspaceBootstrapContext.memoryToolRoutedBootstrapFiles ?? [],
3846
4001
  memoryToolRouted: params.workspaceBootstrapContext.memoryToolRouted === true
3847
4002
  }),
@@ -4050,7 +4205,7 @@ function renderCodexWorkspaceBootstrapPromptContext(contextFiles) {
4050
4205
  const files = contextFiles;
4051
4206
  if (files.length === 0) return;
4052
4207
  const lines = [
4053
- "OpenClaw loaded these user-editable workspace files for the current turn. Codex loads AGENTS.md natively. TOOLS.md is provided as inherited Codex developer instructions. SOUL.md, IDENTITY.md, and USER.md are provided as turn-scoped collaboration instructions so native Codex subagents do not inherit them. Those files are not repeated here.",
4208
+ "OpenClaw loaded these user-editable workspace files for the current turn. Codex loads AGENTS.md natively. SOUL.md, IDENTITY.md, and USER.md are provided as turn-scoped collaboration instructions so native Codex subagents do not inherit them. Those files are not repeated here.",
4054
4209
  "",
4055
4210
  "# Project Context",
4056
4211
  "",
@@ -4070,9 +4225,6 @@ function selectCodexWorkspacePromptContextFiles(contextFiles, options = {}) {
4070
4225
  })) && !isMissingCodexBootstrapContextFile(file);
4071
4226
  }).toSorted(compareCodexContextFiles);
4072
4227
  }
4073
- function selectCodexWorkspaceInheritedDeveloperInstructionFiles(contextFiles) {
4074
- return selectCodexWorkspaceDeveloperInstructionFiles(contextFiles, CODEX_INHERITED_WORKSPACE_DEVELOPER_CONTEXT_BASENAMES);
4075
- }
4076
4228
  function selectCodexWorkspaceTurnScopedDeveloperInstructionFiles(contextFiles) {
4077
4229
  return selectCodexWorkspaceDeveloperInstructionFiles(contextFiles, CODEX_TURN_SCOPED_WORKSPACE_DEVELOPER_CONTEXT_BASENAMES);
4078
4230
  }
@@ -4082,13 +4234,6 @@ function selectCodexWorkspaceDeveloperInstructionFiles(contextFiles, basenames)
4082
4234
  return baseName && basenames.has(baseName) && !isMissingCodexBootstrapContextFile(file) && file.content.trim().length > 0;
4083
4235
  }).toSorted(compareCodexContextFiles);
4084
4236
  }
4085
- function renderCodexWorkspaceThreadDeveloperInstructions(files) {
4086
- return renderCodexWorkspaceDeveloperInstructions({
4087
- files,
4088
- header: "## OpenClaw Workspace Instructions",
4089
- preamble: "OpenClaw loaded these workspace instruction files from the active agent workspace. Internalize and follow them accordingly."
4090
- });
4091
- }
4092
4237
  function renderCodexWorkspaceCollaborationDeveloperInstructions(files) {
4093
4238
  return renderCodexWorkspaceDeveloperInstructions({
4094
4239
  files,
@@ -4246,107 +4391,6 @@ function isNonEmptyString$1(value) {
4246
4391
  return typeof value === "string" && value.length > 0;
4247
4392
  }
4248
4393
  //#endregion
4249
- //#region extensions/codex/src/app-server/run-attempt-state.ts
4250
- async function clearCodexBindingAfterInvalidImagePayload(bindingStore, identity, fields) {
4251
- const currentBinding = await bindingStore.read(identity);
4252
- const expectedThreadId = fields.threadId ?? currentBinding?.threadId;
4253
- if (!expectedThreadId) return;
4254
- if (currentBinding && currentBinding.threadId !== expectedThreadId) {
4255
- embeddedAgentLog.warn("codex app-server image payload error detected for unbound thread; preserving thread binding", {
4256
- ...fields,
4257
- boundThreadId: currentBinding.threadId
4258
- });
4259
- return;
4260
- }
4261
- if (currentBinding?.connectionScope === "supervision") {
4262
- embeddedAgentLog.warn("codex app-server image payload error detected for supervised thread; preserving native binding", fields);
4263
- return;
4264
- }
4265
- embeddedAgentLog.warn("codex app-server image payload error detected; clearing thread binding", fields);
4266
- await bindingStore.mutate(identity, {
4267
- kind: "clear",
4268
- threadId: expectedThreadId
4269
- });
4270
- }
4271
- async function markCodexAppServerBindingCoveredThroughTurn(params) {
4272
- await params.bindingStore.mutate(params.identity, {
4273
- kind: "patch",
4274
- threadId: params.threadId,
4275
- patch: { historyCoveredThrough: (/* @__PURE__ */ new Date()).toISOString() }
4276
- });
4277
- }
4278
- function isNonEmptyString(value) {
4279
- return typeof value === "string" && value.length > 0;
4280
- }
4281
- function shouldUseFreshCodexThreadAfterContextEngineOverflow(params) {
4282
- if (!params.contextEngineActive || params.thread.lifecycle.action !== "resumed") return false;
4283
- const message = formatErrorMessage(params.error);
4284
- return /ran out of room in the model'?s context window/iu.test(message) || /context window/iu.test(message) || /context length/iu.test(message) || /maximum context/iu.test(message) || /too many tokens/iu.test(message);
4285
- }
4286
- function isCodexActiveCompactTurnError(error) {
4287
- if (!(error instanceof CodexAppServerRpcError)) return false;
4288
- const data = isJsonObject(error.data) ? error.data : void 0;
4289
- const codexErrorInfo = isJsonObject(data?.codexErrorInfo) ? data.codexErrorInfo : void 0;
4290
- return (isJsonObject(codexErrorInfo?.activeTurnNotSteerable) ? codexErrorInfo.activeTurnNotSteerable : void 0)?.turnKind === "compact";
4291
- }
4292
- function readCodexFinalizationHookNotification(notification, threadId, turnId) {
4293
- if (notification.method !== "hook/started" && notification.method !== "hook/completed") return;
4294
- const params = isJsonObject(notification.params) ? notification.params : void 0;
4295
- const run = params && isJsonObject(params.run) ? params.run : void 0;
4296
- if (params?.threadId !== threadId || params.turnId !== turnId || run?.eventName !== "stop" && run?.eventName !== "subagentStop" || typeof run.id !== "string" || !run.id) return;
4297
- if (notification.method === "hook/started") return {
4298
- phase: "started",
4299
- runId: run.id
4300
- };
4301
- return {
4302
- phase: "completed",
4303
- runId: run.id,
4304
- status: typeof run.status === "string" ? run.status : void 0
4305
- };
4306
- }
4307
- function joinPresentSections(...sections) {
4308
- return sections.filter((section) => Boolean(section?.trim())).join("\n\n");
4309
- }
4310
- function prependCurrentInboundContext(prompt, context) {
4311
- const text = context?.text.trim();
4312
- return text ? [text, prompt].filter(Boolean).join("\n\n") : prompt;
4313
- }
4314
- function waitForCodexNotificationDispatchTurn() {
4315
- return new Promise((resolve) => {
4316
- setImmediate(resolve);
4317
- });
4318
- }
4319
- function buildCodexAppServerTimeoutDiagnostics(params) {
4320
- const readString = (key) => {
4321
- const value = params.details?.[key];
4322
- return typeof value === "string" && value.trim() ? value : void 0;
4323
- };
4324
- const readNumber = (key) => {
4325
- const value = params.details?.[key];
4326
- return typeof value === "number" && Number.isFinite(value) ? value : void 0;
4327
- };
4328
- const readBoolean = (key) => {
4329
- const value = params.details?.[key];
4330
- return typeof value === "boolean" ? value : void 0;
4331
- };
4332
- return {
4333
- ...params.idleMs !== void 0 ? { idleMs: params.idleMs } : {},
4334
- ...params.timeoutMs !== void 0 ? { timeoutMs: params.timeoutMs } : {},
4335
- ...params.lastActivityReason ? { lastActivityReason: params.lastActivityReason } : {},
4336
- ...readString("lastNotificationMethod") ? { lastNotificationMethod: readString("lastNotificationMethod") } : {},
4337
- ...readString("lastNotificationItemId") ? { lastNotificationItemId: readString("lastNotificationItemId") } : {},
4338
- ...readString("lastNotificationItemType") ? { lastNotificationItemType: readString("lastNotificationItemType") } : {},
4339
- ...readString("lastNotificationItemRole") ? { lastNotificationItemRole: readString("lastNotificationItemRole") } : {},
4340
- ...readString("lastAssistantTextPreview") ? { lastAssistantTextPreview: readString("lastAssistantTextPreview") } : {},
4341
- ...readNumber("activeAppServerTurnRequests") !== void 0 ? { activeAppServerTurnRequests: readNumber("activeAppServerTurnRequests") } : {},
4342
- ...readNumber("activeTurnItemCount") !== void 0 ? { activeTurnItemCount: readNumber("activeTurnItemCount") } : {},
4343
- ...readBoolean("terminalTurnNotificationQueued") !== void 0 ? { terminalTurnNotificationQueued: readBoolean("terminalTurnNotificationQueued") } : {},
4344
- ...readBoolean("completionIdleWatchArmed") !== void 0 ? { completionIdleWatchArmed: readBoolean("completionIdleWatchArmed") } : {},
4345
- ...readBoolean("assistantCompletionIdleWatchArmed") !== void 0 ? { assistantCompletionIdleWatchArmed: readBoolean("assistantCompletionIdleWatchArmed") } : {},
4346
- ...readBoolean("terminalIdleWatchArmed") !== void 0 ? { terminalIdleWatchArmed: readBoolean("terminalIdleWatchArmed") } : {}
4347
- };
4348
- }
4349
- //#endregion
4350
4394
  //#region extensions/codex/src/app-server/run-attempt-context.ts
4351
4395
  async function prepareCodexAttemptContext(runtime, attemptTools) {
4352
4396
  const { connection, runtimeParams, activeSessionId, activeSessionFile, buildActiveRunAttemptParams, effectiveContextWindowInfo, effectiveContextTokenBudget, effectiveRuntimeProviderId, effectiveRuntimeModelId, hookChannelId } = runtime;
@@ -4417,7 +4461,7 @@ async function prepareCodexAttemptContext(runtime, attemptTools) {
4417
4461
  memoryToolNames: getCodexWorkspaceMemoryToolNames(toolBridge.availableSpecs),
4418
4462
  sandboxed: sandbox?.enabled === true
4419
4463
  });
4420
- const baseDeveloperInstructions = joinPresentSections(buildDeveloperInstructions(runtimeParams, { dynamicTools: toolBridge.availableSpecs }), workspaceBootstrapContext.developerInstructions);
4464
+ const baseDeveloperInstructions = buildDeveloperInstructions(runtimeParams, { dynamicTools: toolBridge.availableSpecs });
4421
4465
  return {
4422
4466
  runtime,
4423
4467
  attemptTools,
@@ -4625,14 +4669,10 @@ function resolveCodexAppServerReplayBlockedReason(result) {
4625
4669
  /** Builds an attempt result for failures before the app-server turn starts. */
4626
4670
  function buildCodexTurnStartFailureResult(params) {
4627
4671
  return {
4628
- aborted: false,
4629
- externalAbort: false,
4630
- timedOut: false,
4631
- idleTimedOut: false,
4632
- timedOutDuringCompaction: false,
4633
- timedOutDuringToolExecution: false,
4634
- promptError: params.promptError ?? params.message,
4635
- promptErrorSource: "prompt",
4672
+ terminal: attemptTerminal.normalize({
4673
+ promptError: params.promptError ?? params.message,
4674
+ promptErrorSource: "prompt"
4675
+ }),
4636
4676
  sessionIdUsed: params.params.sessionId,
4637
4677
  messagesSnapshot: params.messagesSnapshot,
4638
4678
  assistantTexts: [],
@@ -4664,6 +4704,107 @@ function isInvalidCodexImagePayloadError(message) {
4664
4704
  return /\b(?:invalid|malformed)\b[\s\S]{0,120}\b(?:image|image url|base64)\b/iu.test(normalizedMessage) || /\b(?:image|image url|base64)\b[\s\S]{0,120}\b(?:invalid|malformed)\b/iu.test(normalizedMessage);
4665
4705
  }
4666
4706
  //#endregion
4707
+ //#region extensions/codex/src/app-server/run-attempt-state.ts
4708
+ async function clearCodexBindingAfterInvalidImagePayload(bindingStore, identity, fields) {
4709
+ const currentBinding = await bindingStore.read(identity);
4710
+ const expectedThreadId = fields.threadId ?? currentBinding?.threadId;
4711
+ if (!expectedThreadId) return;
4712
+ if (currentBinding && currentBinding.threadId !== expectedThreadId) {
4713
+ embeddedAgentLog.warn("codex app-server image payload error detected for unbound thread; preserving thread binding", {
4714
+ ...fields,
4715
+ boundThreadId: currentBinding.threadId
4716
+ });
4717
+ return;
4718
+ }
4719
+ if (currentBinding?.connectionScope === "supervision") {
4720
+ embeddedAgentLog.warn("codex app-server image payload error detected for supervised thread; preserving native binding", fields);
4721
+ return;
4722
+ }
4723
+ embeddedAgentLog.warn("codex app-server image payload error detected; clearing thread binding", fields);
4724
+ await bindingStore.mutate(identity, {
4725
+ kind: "clear",
4726
+ threadId: expectedThreadId
4727
+ });
4728
+ }
4729
+ async function markCodexAppServerBindingCoveredThroughTurn(params) {
4730
+ await params.bindingStore.mutate(params.identity, {
4731
+ kind: "patch",
4732
+ threadId: params.threadId,
4733
+ patch: { historyCoveredThrough: (/* @__PURE__ */ new Date()).toISOString() }
4734
+ });
4735
+ }
4736
+ function isNonEmptyString(value) {
4737
+ return typeof value === "string" && value.length > 0;
4738
+ }
4739
+ function shouldUseFreshCodexThreadAfterContextEngineOverflow(params) {
4740
+ if (!params.contextEngineActive || params.thread.lifecycle.action !== "resumed") return false;
4741
+ const message = formatErrorMessage(params.error);
4742
+ return /ran out of room in the model'?s context window/iu.test(message) || /context window/iu.test(message) || /context length/iu.test(message) || /maximum context/iu.test(message) || /too many tokens/iu.test(message);
4743
+ }
4744
+ function isCodexActiveCompactTurnError(error) {
4745
+ if (!(error instanceof CodexAppServerRpcError)) return false;
4746
+ const data = isJsonObject(error.data) ? error.data : void 0;
4747
+ const codexErrorInfo = isJsonObject(data?.codexErrorInfo) ? data.codexErrorInfo : void 0;
4748
+ return (isJsonObject(codexErrorInfo?.activeTurnNotSteerable) ? codexErrorInfo.activeTurnNotSteerable : void 0)?.turnKind === "compact";
4749
+ }
4750
+ function readCodexFinalizationHookNotification(notification, threadId, turnId) {
4751
+ if (notification.method !== "hook/started" && notification.method !== "hook/completed") return;
4752
+ const params = isJsonObject(notification.params) ? notification.params : void 0;
4753
+ const run = params && isJsonObject(params.run) ? params.run : void 0;
4754
+ if (params?.threadId !== threadId || params.turnId !== turnId || run?.eventName !== "stop" && run?.eventName !== "subagentStop" || typeof run.id !== "string" || !run.id) return;
4755
+ if (notification.method === "hook/started") return {
4756
+ phase: "started",
4757
+ runId: run.id
4758
+ };
4759
+ return {
4760
+ phase: "completed",
4761
+ runId: run.id,
4762
+ status: typeof run.status === "string" ? run.status : void 0
4763
+ };
4764
+ }
4765
+ function joinPresentSections(...sections) {
4766
+ return sections.filter((section) => Boolean(section?.trim())).join("\n\n");
4767
+ }
4768
+ function prependCurrentInboundContext(prompt, context) {
4769
+ const text = context?.text.trim();
4770
+ return text ? [text, prompt].filter(Boolean).join("\n\n") : prompt;
4771
+ }
4772
+ function waitForCodexNotificationDispatchTurn() {
4773
+ return new Promise((resolve) => {
4774
+ setImmediate(resolve);
4775
+ });
4776
+ }
4777
+ function buildCodexAppServerTimeoutDiagnostics(params) {
4778
+ const readString = (key) => {
4779
+ const value = params.details?.[key];
4780
+ return typeof value === "string" && value.trim() ? value : void 0;
4781
+ };
4782
+ const readNumber = (key) => {
4783
+ const value = params.details?.[key];
4784
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
4785
+ };
4786
+ const readBoolean = (key) => {
4787
+ const value = params.details?.[key];
4788
+ return typeof value === "boolean" ? value : void 0;
4789
+ };
4790
+ return {
4791
+ ...params.idleMs !== void 0 ? { idleMs: params.idleMs } : {},
4792
+ ...params.timeoutMs !== void 0 ? { timeoutMs: params.timeoutMs } : {},
4793
+ ...params.lastActivityReason ? { lastActivityReason: params.lastActivityReason } : {},
4794
+ ...readString("lastNotificationMethod") ? { lastNotificationMethod: readString("lastNotificationMethod") } : {},
4795
+ ...readString("lastNotificationItemId") ? { lastNotificationItemId: readString("lastNotificationItemId") } : {},
4796
+ ...readString("lastNotificationItemType") ? { lastNotificationItemType: readString("lastNotificationItemType") } : {},
4797
+ ...readString("lastNotificationItemRole") ? { lastNotificationItemRole: readString("lastNotificationItemRole") } : {},
4798
+ ...readString("lastAssistantTextPreview") ? { lastAssistantTextPreview: readString("lastAssistantTextPreview") } : {},
4799
+ ...readNumber("activeAppServerTurnRequests") !== void 0 ? { activeAppServerTurnRequests: readNumber("activeAppServerTurnRequests") } : {},
4800
+ ...readNumber("activeTurnItemCount") !== void 0 ? { activeTurnItemCount: readNumber("activeTurnItemCount") } : {},
4801
+ ...readBoolean("terminalTurnNotificationQueued") !== void 0 ? { terminalTurnNotificationQueued: readBoolean("terminalTurnNotificationQueued") } : {},
4802
+ ...readBoolean("completionIdleWatchArmed") !== void 0 ? { completionIdleWatchArmed: readBoolean("completionIdleWatchArmed") } : {},
4803
+ ...readBoolean("assistantCompletionIdleWatchArmed") !== void 0 ? { assistantCompletionIdleWatchArmed: readBoolean("assistantCompletionIdleWatchArmed") } : {},
4804
+ ...readBoolean("terminalIdleWatchArmed") !== void 0 ? { terminalIdleWatchArmed: readBoolean("terminalIdleWatchArmed") } : {}
4805
+ };
4806
+ }
4807
+ //#endregion
4667
4808
  //#region extensions/codex/src/app-server/settled-turn-context.ts
4668
4809
  function collectUniqueMessageIdentities(messages) {
4669
4810
  const identities = /* @__PURE__ */ new Map();
@@ -4843,13 +4984,14 @@ function recordCodexTrajectoryContext(recorder, params) {
4843
4984
  /** Records final Codex model completion metadata and assistant snapshots. */
4844
4985
  function recordCodexTrajectoryCompletion(recorder, params) {
4845
4986
  if (!recorder) return;
4987
+ const terminal = attemptTerminal.project(params.result.terminal);
4846
4988
  recorder.recordEvent("model.completed", {
4847
4989
  threadId: params.threadId,
4848
4990
  turnId: params.turnId,
4849
4991
  timedOut: params.timedOut,
4850
4992
  yieldDetected: params.yieldDetected ?? false,
4851
- aborted: params.result.aborted,
4852
- promptError: normalizeCodexTrajectoryError(params.result.promptError),
4993
+ aborted: terminal.aborted,
4994
+ promptError: normalizeCodexTrajectoryError(terminal.promptError),
4853
4995
  usage: params.result.attemptUsage,
4854
4996
  assistantTexts: params.result.assistantTexts,
4855
4997
  messagesSnapshot: params.result.messagesSnapshot
@@ -4943,11 +5085,12 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
4943
5085
  });
4944
5086
  }
4945
5087
  const result = activeProjector.buildResult(toolBridge.telemetry, { yieldDetected: toolState.yieldDetected });
5088
+ const projectedTerminal = attemptTerminal.project(result.terminal);
4946
5089
  const effectiveTimedOut = state.timedOut && !recoveredTurnWatchTimeout;
4947
5090
  const effectiveTurnCompletionIdleTimedOut = state.turnCompletionIdleTimedOut && !recoveredTurnWatchTimeout;
4948
- const isFinalAborted = () => result.aborted || terminalState.explicitCancellationObserved || runAbortController.signal.aborted && !state.clientClosedAbort && !recoveredTurnWatchTimeout;
5091
+ const isFinalAborted = () => projectedTerminal.aborted || terminalState.explicitCancellationObserved || runAbortController.signal.aborted && !state.clientClosedAbort && !recoveredTurnWatchTimeout;
4949
5092
  const clientClosedPromptErrorForFinal = state.clientClosedPromptError && hasRecoverableCompletedAssistant ? void 0 : state.clientClosedPromptError;
4950
- let finalPromptError = clientClosedPromptErrorForFinal ?? (effectiveTurnCompletionIdleTimedOut ? state.turnCompletionIdleTimeoutMessage : effectiveTimedOut ? "codex app-server attempt timed out" : result.promptError);
5093
+ let finalPromptError = clientClosedPromptErrorForFinal ?? (effectiveTurnCompletionIdleTimedOut ? state.turnCompletionIdleTimeoutMessage : effectiveTimedOut ? "codex app-server attempt timed out" : projectedTerminal.promptError);
4951
5094
  const finalPromptErrorMessage = typeof finalPromptError === "string" ? finalPromptError : finalPromptError instanceof Error ? finalPromptError.message : finalPromptError ? formatErrorMessage(finalPromptError) : void 0;
4952
5095
  if (isInvalidCodexImagePayloadError(finalPromptErrorMessage)) await clearCodexBindingAfterInvalidImagePayload(bindingStore, bindingIdentity, {
4953
5096
  phase: "turn_completed",
@@ -4988,7 +5131,7 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
4988
5131
  authProfileId: startupAuthProfileId,
4989
5132
  rateLimits: readRecentCodexRateLimits(resourceState.client)
4990
5133
  });
4991
- const finalPromptErrorSource = effectiveTimedOut || clientClosedPromptErrorForFinal ? "prompt" : result.promptErrorSource;
5134
+ const finalPromptErrorSource = effectiveTimedOut || clientClosedPromptErrorForFinal ? "prompt" : projectedTerminal.promptErrorSource;
4992
5135
  const codexAppServerFailureKind = clientClosedPromptErrorForFinal ? "client_closed_before_turn_completed" : effectiveTurnCompletionIdleTimedOut ? "turn_completion_idle_timeout" : void 0;
4993
5136
  const replayBlockedReason = codexAppServerFailureKind ? resolveCodexAppServerReplayBlockedReason(result) : void 0;
4994
5137
  const promptTimeoutOutcome = buildCodexAppServerPromptTimeoutOutcome({
@@ -5183,10 +5326,12 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
5183
5326
  });
5184
5327
  return {
5185
5328
  ...result,
5186
- timedOut: effectiveTimedOut,
5187
- aborted: finalAborted,
5188
- promptError: finalPromptError,
5189
- promptErrorSource: finalPromptErrorSource,
5329
+ terminal: attemptTerminal.normalize({
5330
+ timedOut: effectiveTimedOut,
5331
+ aborted: finalAborted,
5332
+ promptError: finalPromptError,
5333
+ promptErrorSource: finalPromptErrorSource
5334
+ }),
5190
5335
  ...codexAppServerFailure ? { codexAppServerFailure } : {},
5191
5336
  ...promptTimeoutOutcome ? { promptTimeoutOutcome } : {},
5192
5337
  ...assistantTranscriptOwned ? { assistantTranscriptOwned: true } : {},
@@ -9454,6 +9599,28 @@ async function prepareCodexAttemptRoute(resources, turnRuntime, notifications, h
9454
9599
  return { ensureCurrentThreadRoute };
9455
9600
  }
9456
9601
  //#endregion
9602
+ //#region extensions/codex/src/app-server/run-attempt-client-prewarm.ts
9603
+ /** Starts the shared process while tools and prompt context are still being prepared. */
9604
+ function prewarmCodexAttemptClient(params) {
9605
+ const { connection, authProfileStore, authBindingFingerprint } = params;
9606
+ const { appServer, attemptClientFactory, options, pluginConfig, runtimeArtifactRequest, startupAuthRequirement, startupClientAuthProfileId, startupPreparedAuth, agentDir, params: runParams, runAbortController } = connection;
9607
+ if (options.clientFactory || attemptClientFactory !== getLeasedSharedCodexAppServerClient || runtimeArtifactRequest) return;
9608
+ getSharedCodexAppServerClient({
9609
+ startOptions: appServer.start,
9610
+ pluginConfig,
9611
+ ...startupPreparedAuth ? { preparedAuth: startupPreparedAuth } : { authProfileId: startupClientAuthProfileId },
9612
+ authRequirement: startupAuthRequirement,
9613
+ authProfileStore,
9614
+ authBindingFingerprint,
9615
+ agentDir,
9616
+ config: runParams.config,
9617
+ timeoutMs: appServer.requestTimeoutMs,
9618
+ abandonSignal: runAbortController.signal
9619
+ }).catch((error) => {
9620
+ embeddedAgentLog.debug("codex app-server client prewarm failed", { error });
9621
+ });
9622
+ }
9623
+ //#endregion
9457
9624
  //#region extensions/codex/src/app-server/run-attempt-runtime.ts
9458
9625
  async function prepareCodexAttemptRuntime(connection) {
9459
9626
  const { params, pluginConfig, usesSupervisionConnection, appServer, startupAuthProfileId, startupPreparedAuth, startupClientAuthProfileId, agentDir, preDynamicStartupStages, effectiveWorkspace, contextSessionKey, sandboxSessionKey, sessionAgentId, sandbox, attemptClientFactory, runAbortController, activeContextEngine, mutable } = connection;
@@ -9464,6 +9631,11 @@ async function prepareCodexAttemptRuntime(connection) {
9464
9631
  config: params.config
9465
9632
  }) : void 0;
9466
9633
  const attemptAuthProfileStore = preparedAuthBinding?.authProfileStore ?? params.authProfileStore;
9634
+ prewarmCodexAttemptClient({
9635
+ connection,
9636
+ authProfileStore: attemptAuthProfileStore,
9637
+ authBindingFingerprint: preparedAuthBinding?.fingerprint
9638
+ });
9467
9639
  const effectiveContextWindowInfo = usesSupervisionConnection ? void 0 : params.contextWindowInfo;
9468
9640
  const effectiveContextTokenBudget = usesSupervisionConnection ? void 0 : params.contextTokenBudget;
9469
9641
  const effectiveRuntimeProviderId = usesSupervisionConnection ? mutable.startupBinding?.modelProvider ?? "codex" : params.provider;
@@ -9592,7 +9764,8 @@ function recordCodexDynamicToolResult(projector, call, response, protocolRespons
9592
9764
  success: protocolResponse.success,
9593
9765
  terminalType: response.diagnosticTerminalType ?? (protocolResponse.success ? "completed" : "error"),
9594
9766
  sideEffectEvidence: response.sideEffectEvidence === true || response.terminalResolution?.sideEffectEvidence === true,
9595
- contentItems: protocolResponse.contentItems
9767
+ contentItems: protocolResponse.contentItems,
9768
+ details: response.transcriptDetails
9596
9769
  });
9597
9770
  }
9598
9771
  //#endregion
@@ -10284,6 +10457,7 @@ async function startCodexAttemptThread(params) {
10284
10457
  const attemptParams = params.buildAttemptParams();
10285
10458
  startupClient = await params.attemptClientFactory({
10286
10459
  startOptions: params.appServer.start,
10460
+ pluginConfig: params.pluginConfig,
10287
10461
  ...params.startupPreparedAuth ? { preparedAuth: params.startupPreparedAuth } : { authProfileId: params.startupAuthProfileId },
10288
10462
  authRequirement: params.startupAuthRequirement,
10289
10463
  authProfileStore: attemptParams.authProfileStore,
@@ -10332,14 +10506,19 @@ async function startCodexAttemptThread(params) {
10332
10506
  config: params.config
10333
10507
  });
10334
10508
  const turnRouter = getCodexAppServerTurnRouter(activeStartupClient);
10335
- await ensureCodexComputerUse({
10336
- client: activeStartupClient,
10337
- pluginConfig: params.pluginConfig,
10338
- config: params.config,
10339
- agentDir: params.agentDir,
10340
- timeoutMs: params.appServer.requestTimeoutMs,
10341
- signal: startupAbandonController.signal
10342
- });
10509
+ try {
10510
+ await ensureCodexComputerUse({
10511
+ client: activeStartupClient,
10512
+ pluginConfig: params.pluginConfig,
10513
+ config: params.config,
10514
+ agentDir: params.agentDir,
10515
+ timeoutMs: params.appServer.requestTimeoutMs,
10516
+ signal: startupAbandonController.signal
10517
+ });
10518
+ } catch (error) {
10519
+ if (startupAbandonController.signal.aborted) throw error;
10520
+ throw new AgentHarnessPreflightError(`Codex Computer Use readiness failed: ${formatErrorMessage(error)}`, { cause: error });
10521
+ }
10343
10522
  const startupRuntimeIdentity = activeStartupClient.getRuntimeIdentity();
10344
10523
  const pluginAppCacheKey = buildCodexPluginAppCacheKey({
10345
10524
  appServer: params.appServer,
@@ -10807,7 +10986,7 @@ async function prepareCodexAttemptTools(runtime) {
10807
10986
  sessionId: params.sessionId,
10808
10987
  sessionKey: params.sessionKey,
10809
10988
  workspaceDir: effectiveWorkspace,
10810
- agentDir: agentDir ?? resolveAgentDir$1(params.config ?? {}, sessionAgentId),
10989
+ agentDir: agentDir ?? resolveAgentDir(params.config ?? {}, sessionAgentId),
10811
10990
  cfg: params.config,
10812
10991
  requesterSenderId: params.senderId,
10813
10992
  agentAccountId: params.agentAccountId,
@@ -10821,7 +11000,7 @@ async function prepareCodexAttemptTools(runtime) {
10821
11000
  sessionId: params.sessionId,
10822
11001
  runId: params.runId,
10823
11002
  agentId: sessionAgentId,
10824
- agentDir: agentDir ?? resolveAgentDir$1(params.config ?? {}, sessionAgentId),
11003
+ agentDir: agentDir ?? resolveAgentDir(params.config ?? {}, sessionAgentId),
10825
11004
  agentAccountId: params.agentAccountId,
10826
11005
  messageProvider: params.messageProvider ?? params.messageChannel,
10827
11006
  messageChannel: params.messageChannel,
@@ -10873,6 +11052,7 @@ async function prepareCodexAttemptTools(runtime) {
10873
11052
  hookContext: {
10874
11053
  agentId: sessionAgentId,
10875
11054
  config: params.config,
11055
+ contextWindowTokens: params.contextTokenBudget ?? params.model.contextWindow,
10876
11056
  workspaceDir: effectiveWorkspace,
10877
11057
  sessionId: params.sessionId,
10878
11058
  sessionKey: sandboxSessionKey,