@myagentroam/node 0.9.62 → 0.9.65

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 (161) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/dist/capabilities.js +110 -2
  4. package/dist/claude-agent-sdk.js +330 -2
  5. package/dist/claude-channel.js +44 -2
  6. package/dist/codex-app-server.js +510 -2
  7. package/dist/config.js +106 -2
  8. package/dist/connector/node-connector-options.js +1 -2
  9. package/dist/connector/node-operation-router.js +22 -2
  10. package/dist/connector.js +1736 -2
  11. package/dist/control-outbound-scheduler.js +153 -2
  12. package/dist/database.js +639 -2
  13. package/dist/fake-runner.js +129 -2
  14. package/dist/git-askpass.js +12 -0
  15. package/dist/git-execution-helper.js +266 -0
  16. package/dist/health.js +3 -2
  17. package/dist/main.js +57 -2
  18. package/dist/mcp-installation-model.js +1 -2
  19. package/dist/migrations/v004.js +55 -3
  20. package/dist/migrations/v005.js +13 -3
  21. package/dist/migrations/v006.js +90 -3
  22. package/dist/migrations/v007.js +22 -3
  23. package/dist/migrations/v008.js +18 -3
  24. package/dist/migrations/v009.js +70 -4
  25. package/dist/migrations/v010.js +43 -3
  26. package/dist/migrations/v011.js +20 -3
  27. package/dist/migrations/v012.js +8 -0
  28. package/dist/native-jsonl-reader.js +186 -2
  29. package/dist/native-session-history.js +1143 -2
  30. package/dist/opencode-runtime.js +80 -2
  31. package/dist/opencode-server.js +259 -2
  32. package/dist/operational.js +122 -2
  33. package/dist/process-tree.js +18 -2
  34. package/dist/ripgrep-binary.js +31 -2
  35. package/dist/rotating-log.js +67 -2
  36. package/dist/runner/abstract-runner.js +260 -2
  37. package/dist/runner/claude/managed-run-controller.js +355 -2
  38. package/dist/runner/claude/tool-normalizer.js +120 -2
  39. package/dist/runner/claude-code-runner.js +303 -2
  40. package/dist/runner/codex/composer-image-markers.js +8 -2
  41. package/dist/runner/codex/conversation-parser.js +913 -2
  42. package/dist/runner/codex/managed-run-controller.js +494 -2
  43. package/dist/runner/codex/tool-normalizer.js +214 -2
  44. package/dist/runner/codex-runner.js +585 -2
  45. package/dist/runner/fake-test-runner.js +47 -2
  46. package/dist/runner/mar-agent/conversation-normalizer.js +644 -2
  47. package/dist/runner/mar-agent/executor-stdio-client-transport.js +139 -2
  48. package/dist/runner/mar-agent/generated-images.js +41 -2
  49. package/dist/runner/mar-agent/history-projection.js +106 -2
  50. package/dist/runner/mar-agent/hosted-conversation-runtime.js +446 -2
  51. package/dist/runner/mar-agent/managed-run-controller.js +785 -2
  52. package/dist/runner/mar-agent/mcp-client-pool.js +233 -2
  53. package/dist/runner/mar-agent/runtime-model-factory.js +326 -2
  54. package/dist/runner/mar-agent-runner.js +458 -2
  55. package/dist/runner/opencode/conversation-parser.js +221 -2
  56. package/dist/runner/opencode/managed-run-controller.js +588 -2
  57. package/dist/runner/opencode/tool-normalizer.js +80 -2
  58. package/dist/runner/opencode-runner.js +426 -2
  59. package/dist/runner/runner-registry.js +87 -2
  60. package/dist/runner-command-engine.js +71 -2
  61. package/dist/runner-profiles.js +323 -2
  62. package/dist/runner-usage.js +190 -2
  63. package/dist/runtime-command-detector.js +73 -2
  64. package/dist/runtime-model.js +1 -2
  65. package/dist/runtime-state.js +1509 -2
  66. package/dist/service/attachment-domain-state.js +7 -2
  67. package/dist/service/bubblewrap-sandbox-executor.js +543 -2
  68. package/dist/service/continuous-run-coordinator.js +425 -2
  69. package/dist/service/conversation-history-service.js +552 -2
  70. package/dist/service/conversation-hosting-capability-service.js +61 -2
  71. package/dist/service/conversation-hosting-enablement-service.js +91 -2
  72. package/dist/service/conversation-hosting-maintenance-service.js +174 -2
  73. package/dist/service/conversation-segment-service.js +162 -2
  74. package/dist/service/conversation-template-node-service.js +992 -2
  75. package/dist/service/external-session-resume-service.js +152 -2
  76. package/dist/service/fake-managed-run-service.js +60 -2
  77. package/dist/service/git-execution-service.js +418 -0
  78. package/dist/service/git-operation-service.js +57 -0
  79. package/dist/service/hosted-conversation-node-service.js +1982 -2
  80. package/dist/service/hosted-conversation-store.js +1405 -2
  81. package/dist/service/managed-runner-session-service.js +35 -2
  82. package/dist/service/mar-agent-model-transport-test-service.js +88 -2
  83. package/dist/service/mcp-installation-verifier.js +87 -2
  84. package/dist/service/mcp-node-operation-service.js +90 -2
  85. package/dist/service/mission-mcp-server.js +124 -2
  86. package/dist/service/mission-mcp-stdio.js +40 -2
  87. package/dist/service/mission-runtime.js +142 -2
  88. package/dist/service/native-session-projection-service.js +274 -2
  89. package/dist/service/native-session-watch-service.js +683 -2
  90. package/dist/service/node-connection-lifecycle-service.js +88 -2
  91. package/dist/service/node-control-channel.js +85 -2
  92. package/dist/service/node-control-message-service.js +109 -2
  93. package/dist/service/node-request-service.js +62 -2
  94. package/dist/service/node-run-event-bridge.js +88 -2
  95. package/dist/service/node-terminal-channel.js +202 -2
  96. package/dist/service/node-upgrade-coordinator.js +137 -2
  97. package/dist/service/node-workspace-coordinator.js +97 -2
  98. package/dist/service/recent-run-projection-service.js +99 -2
  99. package/dist/service/run-attachment-service.js +321 -2
  100. package/dist/service/run-domain-state.js +4 -2
  101. package/dist/service/run-event-service.js +246 -2
  102. package/dist/service/run-ownership-policy.js +22 -2
  103. package/dist/service/run-workbench-service.js +120 -2
  104. package/dist/service/runner-channel-message-service.js +20 -2
  105. package/dist/service/runner-interaction-service.js +243 -2
  106. package/dist/service/runner-service.js +69 -2
  107. package/dist/service/runtime-credential-control-service.js +95 -2
  108. package/dist/service/session-catalog-service.js +404 -2
  109. package/dist/service/session-command-service.js +125 -2
  110. package/dist/service/session-context-service.js +128 -2
  111. package/dist/service/session-domain-state.js +9 -2
  112. package/dist/service/session-identity-service.js +86 -2
  113. package/dist/service/session-lifecycle-service.js +248 -2
  114. package/dist/service/session-message-service.js +270 -2
  115. package/dist/service/session-presentation-service.js +43 -2
  116. package/dist/service/session-query-service.js +82 -2
  117. package/dist/service/session-watch-slot-coordinator.js +21 -2
  118. package/dist/service/skill-directory-service.js +238 -2
  119. package/dist/service/skill-install-service.js +434 -2
  120. package/dist/service/skill-node-operation-service.js +206 -2
  121. package/dist/service/terminal-relay-state.js +3 -2
  122. package/dist/service/terminal-service.js +90 -2
  123. package/dist/service/web-search-error.js +40 -2
  124. package/dist/service/workbench-event-service.js +21 -2
  125. package/dist/service/workbench-manifest-service.js +69 -2
  126. package/dist/service/workspace-change-service.js +290 -2
  127. package/dist/service/workspace-content-search-service.js +457 -2
  128. package/dist/service/workspace-domain-state.js +41 -2
  129. package/dist/service/workspace-file-service.js +150 -2
  130. package/dist/service/workspace-git-exclude-service.js +119 -2
  131. package/dist/service/workspace-queue-workbench-service.js +176 -2
  132. package/dist/service/workspace-service.js +92 -2
  133. package/dist/service/workspace-session-service.js +154 -2
  134. package/dist/service/workspace-upload-service.js +262 -2
  135. package/dist/service/workspace-watch-controller.js +68 -2
  136. package/dist/service/workspace-watch-service.js +170 -2
  137. package/dist/service/workspace-watch-snapshot-service.js +218 -2
  138. package/dist/service/workspace-workbench-service.js +239 -2
  139. package/dist/service.js +91 -2
  140. package/dist/storage.js +32 -2
  141. package/dist/supervisor.js +136 -2
  142. package/dist/terminal.js +496 -2
  143. package/dist/util/git-credential-client.js +32 -0
  144. package/dist/util/node-operation-data.js +9 -2
  145. package/dist/util/node-operation-parsers.js +382 -2
  146. package/dist/util/personal-instructions.js +34 -2
  147. package/dist/util/runner-error.js +70 -2
  148. package/dist/util/runner-native-session-parsers.js +510 -2
  149. package/dist/util/safe-error.js +8 -2
  150. package/dist/util/secret-environment.js +25 -2
  151. package/dist/workspace.js +1793 -2
  152. package/package.json +11 -8
  153. package/vendor/ripgrep/darwin-arm64/rg +0 -0
  154. package/vendor/ripgrep/darwin-x64/rg +0 -0
  155. package/vendor/ripgrep/manifest.json +12 -0
  156. package/README.md +0 -42
  157. package/dist/event-buffer.js +0 -2
  158. package/dist/migrations/v001.js +0 -107
  159. package/dist/migrations/v002.js +0 -2
  160. package/dist/migrations/v003.js +0 -2
  161. package/dist/service/mcp-package-installer.js +0 -2
package/dist/connector.js CHANGED
@@ -1,2 +1,1736 @@
1
- /* mar-release-protected */
2
- const _0x4ce2c3=_0x4f09;(function(_0x17f671,_0x3be13f){const _0x156a8a=_0x4f09,_0x4d38d5=_0x17f671();while(!![]){try{const _0x475ae3=parseInt(_0x156a8a(0x29f))/(0x147a+0x1816+-0x2c8f)*(-parseInt(_0x156a8a(0x20a))/(-0x2008+0x2452+-0x448))+parseInt(_0x156a8a(0x224))/(-0x13af+-0x12f8+0x26aa)*(parseInt(_0x156a8a(0x1f0))/(0xd4*0x22+0xaf*-0x39+0x11*0xa3))+-parseInt(_0x156a8a(0x2a6))/(-0x2316+-0x2*0x118d+0x4635)+parseInt(_0x156a8a(0x1c8))/(0x1af7+-0x100*0x4+0x7*-0x347)*(-parseInt(_0x156a8a(0x1c1))/(-0xd0a+0x222d+-0x151c))+parseInt(_0x156a8a(0x2db))/(0x852+0x27a*-0xf+-0xe6e*-0x2)+parseInt(_0x156a8a(0x239))/(-0x3b*0x31+-0x1583+-0x1*-0x20d7)*(-parseInt(_0x156a8a(0x22d))/(0x1b61+-0x1d33+-0x44*-0x7))+parseInt(_0x156a8a(0x1eb))/(-0x188d+-0x2641+-0x207*-0x1f)*(parseInt(_0x156a8a(0x2c7))/(-0x2399*0x1+0x24*0xfc+0x35*0x1));if(_0x475ae3===_0x3be13f)break;else _0x4d38d5['push'](_0x4d38d5['shift']());}catch(_0x47f0a4){_0x4d38d5['push'](_0x4d38d5['shift']());}}}(_0x38ba,0xcff3d+0xc1*-0xa63+0x2ae3f));import{dirname,resolve}from'node:path';import{createEnvelope}from'@myagentroam/protocol';import{hostedConversationStorePath,loadNodeConfig,nodeDataDirectory,nodeDatabasePath}from'./config.js';import{NodeMetrics,nodeLog}from'./operational.js';import{assertLocalSqlitePath}from'./storage.js';import{detectCapabilitiesAsync,unavailableCapabilities}from'./capabilities.js';import{NodeDatabase}from'./database.js';import{TerminalManager}from'./terminal.js';import{NodeRuntimeState}from'./runtime-state.js';import{CommandStateStore}from'./runner-command-engine.js';import{missionUnrestrictedAccess,MissionRuntime}from'./service/mission-runtime.js';import{MissionMcpServer}from'./service/mission-mcp-server.js';import{RunnerUsageReader}from'./runner-usage.js';import{ClaudeCodeRunner}from'./runner/claude-code-runner.js';import{ClaudeManagedRunController}from'./runner/claude/managed-run-controller.js';import{CodexRunner}from'./runner/codex-runner.js';import{CodexManagedRunController}from'./runner/codex/managed-run-controller.js';import{FakeTestRunner}from'./runner/fake-test-runner.js';import{RunnerRegistry}from'./runner/runner-registry.js';import{OpenCodeRunner}from'./runner/opencode-runner.js';import{MarAgentRunner}from'./runner/mar-agent-runner.js';import{MarAgentManagedRunController}from'./runner/mar-agent/managed-run-controller.js';import{OpenCodeManagedRunController}from'./runner/opencode/managed-run-controller.js';import{NodeOperationRouter}from'./connector/node-operation-router.js';import{SkillNodeOperationService}from'./service/skill-node-operation-service.js';import{McpNodeOperationService}from'./service/mcp-node-operation-service.js';import{RunnerService}from'./service/runner-service.js';import{TerminalService}from'./service/terminal-service.js';import{WorkspaceService}from'./service/workspace-service.js';import{WorkspaceWatchService}from'./service/workspace-watch-service.js';import{WorkspaceFileService}from'./service/workspace-file-service.js';function _0x38ba(){const _0x1e6e22=['CMv2AxnPB24','mZGWAKroDNHA','y29KzxHqCM9MAwXLq2XPzw50rMfJDg9YEq','D2LUmZi','C3rVCa','CMvNAxn0zxjhzw5LCMf0zwrjBwfNzxm','vgHPCYboB2rLignVBM5Ly3rPB24GD2fZihjLCgXHy2vKigj5igeGBMv3zxiGAw5ZDgfUy2uGD2L0Acb0AguGC2fTzsbPzgvUDgL0Es4Gq2HLy2SGzM9Yigr1CgXPy2f0zsbWCM9JzxnZzxmU','zw1PDfj1BG','y29UDMvYC2f0Aw9UlMHVC3rLzc5PBNrLCNj1Chq','ChvIBgLZAe1PC3nPB25tDgf0zq','CMvJB25JAwXL','Dw5Yzwy','CMv2B2TL','mtC2mZKXy2PbsK5O','DgLTzxi','CNvUBMvYvxnHz2vszwfKzxi','DgvYBwLUywXdAgfUBMvS','Cgf1C2vtzxnZAw9UuxvLDwu','y29UDMvYC2f0Aw9UvhvYBKzVCLj1BG','CMvJzw50lxj1BNm','C2vZC2LVBKLKzw50Axr5u2vYDMLJzq','BMf0AxzLlNnLC3nPB24UzgLZy292zxj5lNbLBMrPBMC','C2vZC2LVBLbYzxnLBNrHDgLVBLnLCNzPy2u','C2vZC2LVBKLK','D29YA3nWywnLq29VCMrPBMf0B3i','ywnJzxnZ','y29UDMvYC2f0Aw9UlMHVC3rPBMCUy2XLyw51Cc5LEgvJDxrL','y29UDMvYC2f0Aw9UlML0zw0','CMvWBgfJzq','yxbWBgLJyxrPB24VANnVBG','CMfUzg9Tvvvjra','Bwv0ywrHDge','Ag9ZDgvKq29UDMvYC2f0Aw9UuNvUDgLTzq','zw5HyMXLza','ChjVAMvJDeLUAxrPywW','y2fWywnPDhK','y29UDMvYC2f0Aw9UlMHVC3rLzc5YB2XSyMfJAW','tuLtu0LptL9ot1rFqunusvzf','BgLZDa','Ag9ZDgvKq29UDMvYC2f0Aw9Ut3bLCMf0Aw9UCW','CgvYC2LZDezPBgvZ','CMvZDw1Lqwz0zxjdB21Tyw5KuNvU','AgfZrxHLy3v0Aw9Uu3rHCNrLza','ANnVBG','Dgv4Dc5KzwX0yq','CMvTB3zLugvUzgLUz1f1zxvL','q09ovKvsu0fusu9ox0Hpu1rjtKDFu1rpuKfhrv9vtKfwquLmqujmrq','ChjVBw90zq','zw1PDfnLC3nPB25xB3jRyMvUy2HfDMvUDa','C3rVCfDHDgnO','BM9KzuLK','CNvUBMvYq2HHBM5LBe1LC3nHz2vZ','C3rVChbPBMC','ms4WlJa','q0foq0vmteLorW','CMvTB3zLtwLZC2LVBLf1zxvL','ChvIBgLZAa','D29YA3nWywnLv2f0y2Htzxj2AwnL','CNvUDgLTzs1UB2rL','zw5ZDxjLuMvZDw1LzenVBMzPz3vYyxrPB24','B3bLBKnVzgvsDw5dB250CM9SBgvY','zgLZy29UBMvJDgvK','y29UDMvYC2f0Aw9UlMHVC3rLzc5PBwfNzs5YzwfK','D29YA3nWywnLv29YA2jLBMnOu2vYDMLJzq','Dw5RBM93BG','y29UDgLUDw91C1j1BKnVB3jKAw5HDg9Y','y2XLyw51Ca','BMf0AxzLsw1Hz2vsB290CW','y29UDMvYC2f0Aw9UlMHVC3rPBMCUy2XLyw51Cc5WCMv2Awv3','q09ovKvsu0fusu9ox0Hpu1rjtKDFvu5bvKfjtefcteu','CMvZB2X2zun1CNjLBNq','DgvYBwLUywXnyw5Hz2vY','D29YA3nWywnLswq','CMvHzeHPC3rVCNLqywDL','yMLUzenVBNrYB2W','D2LUzg93CW','ChjLC2vUDa','rvHurvjoquW','BM9KzuDLBMvYyxrPB24','y2f0y2G','y29UDMvYC2f0Aw9UlMHVC3rLzc5MAwXLCY51CgXVywqUC3rHDhvZ','zxHLy3v0zunVBw1HBMq','y29UDMvYC2f0Aw9UlMHVC3rLzc5MAwXLlNjLywq','C2vZC2LVBLf1zxj5u2vYDMLJzq','CNvUlMzHAwXLza','zxHLy3v0zu5VzgvpCgvYyxrPB24','y2HHBM5LBfrVA2vU','y3jLzgvUDgLHBa','BwfYqwDLBNrdBgLLBNq','C3rHCNrdyxbHyMLSAxr5uMvMCMvZAa','AxndB252zxjZyxrPB25jBLvZzq','Cgf5Bg9Hza','BM9Kzs5JB25Uzwn0Aw9UlNjLCgXHy2vK','Dg9WAwnby3rPDMu','twLZC2LVBG','y29UDMvYC2f0Aw9UlMHVC3rLzc5Nzxq','y3DK','DxbKyxrLqwDLBNrtzxnZAw9UqwnJzxnZ','y2XLyxjxB3jRC3bHy2u','CMvJB3jKzwqTC2vZC2LVBG','yMXVy2TbzNrLCLj1BNrPBwvgywLSDxjL','y29KzxHdBgLLBNq','Dw5YzwDPC3rLCMvK','AxnbCNjHEq','D2f0y2GUzxzLBNq','C2vZC2LVBLn0yxrL','qvzbsuXbqKXf','CMvZDw1LzenVBMzPz3vYyxrPB24','y29UDMvYC2f0Aw9Usg9ZDgLUz1bYB2jL','l2fWAs9UB2rLlxrVB2XZl3DLyI1ZzwfYy2G','zxHLy3v0Aw9U','AgfUzgXLtwvZC2fNzq','DxbNCMfKzunVB3jKAw5HDg9Y','yMLUzenVBw1HBMrdB250CM9S','C2v0r2vUzxjHDgvKsw1Hz2vszwDPC3rYyxi','mtqZm2nnwLbnvG','D29YA3nWywnLrMLSzvnLCNzPy2u','y29UDMvYC2f0Aw9Usg9ZDgLUz01HAw50zw5HBMnLt3bLCMf0Aw9UCW','BMv4Da','C25HChnOB3rtzxf1zw5Jzq','Aw5PDgLHBgL6zunVBNzLCNnHDgLVBKHVC3rPBMC','rKfjteve','nJi1odmWsgTAEuvl','zw1PDfDVCMTIzw5JAev2zw50','DhvYBKLK','CMvMCMvZAfrPDgXL','y29UBMvJDgLVBKXPzMvJEwnSzq','y29UDMvYC2f0Aw9Usg9ZDgLUz0zHAwX1CMvdB2rL','CNvUlMnVBxbSzxrLza','y29UDMvYC2f0Aw9UlMHVC3rLzc51BNDHDgnO','C2v0','zw1PDfjLywX0Aw1L','zgLZy292zxi','C2vZC2LVBNm','zM9Yz2v0','CNvUBMvYu2vYDMLJzq','su5urvjsvvburuq','y3vZDg9TvgL0Bgu','CNvUswq','y29UzMLNugf0Aa','y2fUy2vS','CMvJB25Uzwn0u2nOzwr1BgvK','C2vZC2LVBK1LC3nHz2vtzxj2AwnL','v09ss1nqqunf','y2fJAgvKu2vZC2LVBNm','CNvUDgLTzq','y3jLyxrLqxbWCM92ywW','ChjLCgfYzu1PC3nPB25tzxnZAw9U','BgLUDxG','ChvIBgLZAfnUyxbZAg90','B3bLCMf0Aw9UCW','l21PC3nPB24Gls1JBgvHCG','y29UDMvYC2f0Aw9UlMHVC3rLzc53yxrJAa','D29YA3nWywnLu3rHDgu','y29UDgLUDwu','mtjVyuTqDem','y2fUy2vSq29KzxHuDxjU','zxH0zxjUywXby3rPDML0Eq','zxHWAxjL','BwLZC2LVBLjLDhj5vgLTzxjZ','y29UDMvYC2f0Aw9Usg9ZDgLUz01HAw50zw5HBMnLu2vYDMLJzq','CMvMCMvZAenHCgfIAwXPDgLLCW','CMvJB3jKrxHLy3v0Aw9UuMvZDwX0','z2v0v29YA3nWywnL','y29UDMvYC2f0Aw9UlNrLBxbSyxrLlNzLCNnPB24UAw5ZCgvJDa','AgfZqwn0AxzLu2vZC2LVBKXLyxnL','Bw9KzwW','zgLZy29UBMvJDa','y29UBMvJDgvKqxr0zw1WDa','B25tDw1Tyxj5','y29TCgXLDgvKqxq','ChjVBw90zvnLC3nPB25jzgvUDgL0Eq','qMvHCMvYia','C2vUza','y29UDMvYC2f0Aw9UlMHVC3rLzc5MAwXLCY51CgXVywqUy3jLyxrL','nJC3mZCWnhrYz09HrW','CMvNAxn0zxjoyxrPDMu','BwfYqwDLBNrnB2rLBfrYyw5ZCg9YDfrLC3rZ','y2XHDwrLqxbWCM92ywXuAw1LB3v0txm','y2XHDwrLuNvUq29UDhjVBgXLCG','zgLZy292zxjxB3jRC3bHy2vtzxnZAw9UCW','CMvMCMvZAev4DgvYBMfSqwn0AxzPDhK','zMLUywXSEq','zgLZCgf0y2G','DhvYBG','yxbWzw5K','y29UDMvYC2f0Aw9UlNrLBxbSyxrLlNb1yMXPC2G','zwzMB3j0','zxH0zxjUywXtzxnZAw9Uswq','zxHWAxjLqxbWCM92ywW','y29UDMvYC2f0Aw9Usg9ZDgLUzW','y29UDMvYC2f0Aw9UlMHVC3rLzc5KzwXLDgu','CNvUv29YA2jLBMnOu2vYDMLJzq','BwfUywDLzfj1BM5LCLnLC3nPB25Z','B25oB3rPzMLJyxrPB24','BgLZDfDVCMTZCgfJzxm','ChvIBgLZAfDVCMTIzw5JAev2zw50','y29UDMvYC2f0Aw9Usg9ZDgLUz1n0B3jHz2vszwfKEq','D29YA2jLBMnOrxzLBNrtzxj2AwnL','zxHPDa','BM9KzvjLCxvLC3rZ','CNvUlNj1BM5PBMC','Aw52ywXPzgf0zq','BwfUywDLzezVCK5HDgL2zq','zw1PDff1zxvL','y29UDMvYC2f0Aw9UlNrLBxbSyxrLlNnVDxjJzs5PBNnWzwn0','y29TBwL0twv0ywrHDge','q09ovKvsu0fusu9ox0Hpu1rjtKDFq0Xfqu5vuf9gquLmruq','AgfUzgXLtM90AwzPy2f0Aw9U','BwfYqwDLBNrnB2rLBhm','CMvHze5HDgL2zq','y2XVC2vsDw5UAw5NvgvYBwLUywXtzxnZAw9UCW','u1vdq0vfreve','C2XPy2u','CNvUrxzLBNrtzxj2AwnL','y29UDMvYC2f0Aw9U','yxnZzxj0q2fUq3jLyxrL','DxnLCKLUChv0CW','D29YA3nWywnLvxbSB2fKu2vYDMLJzq','AxrLBxm','uKvkrunuruq','C2vZC2LVBKnHDgfSB2Dtzxj2AwnL','BMf0AxzLu2vZC2LVBLDHDgnOu2vYDMLJzq','BwfYqwDLBNrsDw50Aw1Lu2nVCgvjza','CgvUzgLUz01PC3nPB25dB21Tyw5Ku3rHDgu','yM9VDhn0CMfWswrZ','Ag9ZDgvKq29UDMvYC2f0Aw9Uu2vYDMLJzq','C2vJCMv0CW','uLvox05pvf9gt1vora','DhvYBNm','Aw5Hy3rPDMvszxrLBNrPB25eyxLZ','CMvJB25Uzwn0','y29UDhjVBenOyw5UzwW','C29JA2v0','BwfYqwDLBNrsDw5dB250CM9SBgvY','zgvJAwrL','C2vZC2LVBLDHDgnOu2XVDhm','y29UDhjVBe1LC3nHz2vZ','yxbWCM92ywXjza','y29KzxG','ChvIBgLZAefWChjVDMfS','z2v0uNvU','y29UDMvYC2f0Aw9UlMHVC3rPBMCUy2XLyw51Cc5MywLSzwq','Aw5PDgLHBgL6zq','y29KzxHsDw5dB250CM9SBgvY','CMvZCg9UzfvZzxjjBNb1Da','rKflrv9svu5orvjFreLtq09otKvdva','y2XHDwrLq2XPzw50','q0foq0vmteve','sfruua','CgXHDgzVCM0','D29YA2jLBMnOtwfUAwzLC3rtzxj2AwnL','y29UBMvJDa','BM9Kzs5TzxrYAwnZ','Aw5KzxG','y29UDMvYC2f0Aw9UlMHVC3rLzc5SAxn0','C2vUzevUDMvSB3bL','y2HHBMDLza','C3rHCNrLzef0','Aw5ZCgvJDe1LDgfKyxrH','y2XLyxjxyxrJAgvZ','yxzHAwXHyMXL','CMvZB2X2zq','tK9erv9eqvrbqKftrv9vtKfwquLmqujmrq','zgLYzwn0tMf0AxzL','zMLUAxnOswrSzu1PC3nPB25sDw4','y29TBwfUzfn0yxrLCW','ywn0AxzL','D29YA3nWywnLuxvLDwvxB3jRyMvUy2Htzxj2AwnL','lw9Wzw5JB2rLlwLTywDLCW','Aw5ZDgfSBgf0Aw9U','C2vZC2LVBI13yxrJAc1ZBMfWC2HVDa','y29UDMvYC2f0Aw9UlMHVC3rLzc5MAwXLCY5SAxn0','C2vJCMv0rw52AxjVBM1LBNq','C2f2zu5HDgL2zvnLC3nPB25nzxrHzgf0yq','y29UDMvYC2f0Aw9UlNrLBxbSyxrLlNb1yMXPC2GUC3rHDhvZ','zgvJAwrLq2XHDwrLqxbWCM92ywW','DxbNCMfKzq','tK9erv9tve9queve','C2vYDMvYvxjS','BwLZC2LVBKnVBNrPBNvHDgLVBLbLBMrPBMC','yxbWCM92ywXZ','CNvUlNn0yxj0zwq','CMvJzw50uNvUuhjVAMvJDgLVBLnLCNzPy2u','DxbNCMfKzs1Yzxn1BhqUANnVBG','CNvUDgLTzunYzwrLBNrPywXZ','C3rHCNq','C2vZC2LVBI5SAxn0','BwLNCMf0zvnLC3nPB24','zgvSzxrL','Aw52ywXPzgf0zunHy2HL','CMvJB3jK','q0foq0vm','tK9erv9vtKfvveHftLrjq0furuq','BM9Kzs5JB25Uzwn0Aw5N','CMvHza','CNvUCW','BM9Kzs51CgDYywrLlNjLCxvLC3q','Aw50zxjYDxb0uMvXDwvZDgvK','zw1PDenVBNzLCNnHDgLVBKL0zw0','BMf0AxzLswrZ','C2H1DgrVD24','tuLtu0LptL9dt05usu5vqvrjt05FrKfjteve','DhjHBNnPDgLVBMLUzW','y29UDMvYC2f0Aw9UlMHVC3rPBMCUC3rVCMfNzs5PBNnWzwn0','CMvJB3jKvhvYBG','BwfYqwDLBNrsDw50Aw1Ltw9KzwXZ','y2XLyxi','BgLZDfj1BNngB3jtzxnZAw9U','C3rHDhvZ','CMvXDwvZDa','ChjVAMvJDenVBNzLCNnHDgLVBKHVC3rPBMDdyxbHyMLSAxr5','CNvUqxr0ywnOBwvUDfnLCNzPy2u','y3vYCMvUDev4zwn1DgLVBKLK','BwfYlwLUDgvYBMfSlw1PC3nPB24','zgvJAwrLqxbWCM92ywW','yMvNAw5dB252zxjZyxrPB25dBgvHBNvW','zgvJAwrLq29KzxHbChbYB3zHBa','zgf0ywjHC2u','DgHYzwfKswq','y29UDMvYC2f0Aw9Uu2vNBwvUDfnLCNzPy2u','Ahr0Chm6lY8XmJCUmc4WlJeUAw52ywXPzc9Ty3a','zgLZCg9Zzq','C2vXDwvUy2u','tK9erv9vueDsqurfx1bftKrjtKC','CMvNAxn0zxjoyxrPDMvjBwfNzxm','zw5XDwv1zu1PC3nPB25dB250Aw51yxrPB24','C2vZC2LVBKnVBNrLEhrtzxj2AwnL','BM9Kzs51CgDYywrLlMnHBMnLBa','CNvUBMvYsw50zxjHy3rPB25tzxj2AwnL','CMvJB25JAwXLugvYC2LZDgvKuNvUCW','ChjVzMLSzxm','ue9tva','B3bLCMf0Aw9UuM91DgvY','zMfZDa','y2XLyxjnAxnZAw9UuMv0CNK','ywnJzxb0rM9YtwvZC2fNzq','zxHLy3v0Aw9Uu3rHCNrLza','y29UDMvYC2f0Aw9UlMHVC3rLzc5MAwXLCY51CgXVywqUy2H1BMS','C3rHDgu','C3rVCMfNzunHCgfJAxr5','ywn0AxzLu2vZC2LVBLj1BG','yMXVy2TZ','Bwf4','CMvSzwfZzvnLC3nPB24','C3rVChbLza','zxHLy3v0zq','AgfUzgXL','zxzLBNruExbL','CMvWBgfJzvnVy2TLDezVCLrLC3rPBMC','zw1PDfj1BKv2zw50','ChjVBxb0','tK9erv9dt05gsuDFvu5bvKfjtefcteu','y3jLyxrLzef0','C2L6zq','zxzLBNq','CMvQzwn0','ywn0AxzLv29YA3nWywnLtgvHC2vdB3vUDa','C3rYAw5NAwz5','CNvUu3rHDgu','y2fWywjPBgL0EurLDgvJDg9Y','D29YA3nWywnLq2HHBMDLu2vYDMLJzq','Aw52ywXPzgf0zvDVCMTZCgfJzvDHDgnOvg9WAwnZ','y29UDMvYC2f0Aw9UlMHVC3rLzc5JB25MAwCUDxbKyxrL','Bwv0CMLJCW','yxbWCM92ywW6','D2vIu2vHCMnO','Bg9HzfjLC3vSDa','ywXSB3DLzfjVB3rZ','CMvXDwLYzq','BxLHz2vUDhjVyw1FBwLZC2LVBG','CNvUBMvYCW','BMf0AxzLu2vZC2LVBLbYB2PLy3rPB25tzxj2AwnL','CMvJB3zLCKLUDgvYCNvWDgvKuhvIBgLJyxrPB25Z','y29UBMvJDgvK','BwLZC2LVBLj1BNrPBwu','y29UDMvYC2f0Aw9UlMHVC3rLzc5TzxrHzgf0ys51CgrHDgu','D29YA3nWywnLu2vZC2LVBLnLCNzPy2u','mZyXnJiWn3jsDfDWCW','C3rYAw5N','C25HChnOB3q','zMX1C2Hqzw5KAw5Nvgv4Da','CNvUBMvYlMnVBw1HBMqUzxHLy3v0zq','y29UDMvYC2f0Aw9UlMHVC3rLzc5MAwXLCY51CgXVywqUy2fUy2vS','C2vZC2LVBKnVBw1HBMrtzxj2AwnL','nNvRuNrYvq','C2vZC2LVBKXPzMvJEwnSzvnLCNzPy2u','y2fUy2vSq2XHDwrLuNvU','C2vZC2LVBG','CNvUrxzLBNrcCMLKz2u','y2fWywjPBgL0AwvZuhjVDMLKzwq','CMvXDwvZDenSyxvKzvvZzxjjBNb1Da','y29UDMvYC2f0Aw9UlMHVC3rLzc5MAwXLCY51CgXVywqUChjLzMXPz2H0','y29UDMvYC2f0Aw9UlMHVC3rLzc5JCMvHDgu','zwzMzwn0AxzLtwnWsw5ZDgfSBgf0Aw9UCW','BM9Kzs53B3jRyMvUy2GUy2fWywjPBgL0AwvZ','u0vora','q09ovKvsu0fusu9ox0Hpu1rjtKDFuKvdt1zfuLLFrKfjteve','Aw52ywXPzgf0zvrVCgLJ','Bw92zq','C2v0q2HHBM5LBfrVA2vU','y29UDMvYC2f0Aw9UsgLZDg9YEvnLCNzPy2u','y29UDMvYC2f0Aw9UvgvTCgXHDgvpCgvYyxrPB25Z','CMvXDwvZDenSyxvKzufWChjVDMfS','DMfSDwvZ','ChjVAMvJDgLVBKzVCK5HDgL2zq','z2v0','y29UDMvYC2f0Aw9UlMHVC3rPBMCUAw5PDgLHBgL6yxrPB24UzMfPBgvK','CNvU','BM9Kzs5VCgvYyxrPB24','zMfRzvnJCMLWDa','AxrLBuLK','yxnZAxn0yw50x21LC3nHz2u','uKvqtefdrv9dvvjsru5u','BM93','Aw50zxjYDxb0','y29UzMLN','y29UDMvYC2f0Aw9UlMHVC3rLzc5TzxnZywDL','DgvYBwLUywXtzxj2AwnL','y29UDMvYC2f0Aw9UlMHVC3rLzc5MAwXLCY51CgXVywqUy29TCgXLDgu','nZa4mJe3nerpyKXPvW','CMvSzwfZzunVBNzLCNnHDgLVBKzVCKnSzwfUDxa','BwfYqwDLBNrnB2rLBa','ywrVChrsDw4','BwLNCMf0zvj1BM5LCLnLC3nPB25jzgvUDgL0Eq','mJK3mdGXmNf1ELDezq','BM90AwzPy2f0Aw9U','zxH0zxjUywXtzxnZAw9UuMvZDw1Lu2vYDMLJzq','C2nOzwr1Bgu','D29YA3nWywnLu2vYDMLJzq','CMvIDwLSzenVBNzLCNnHDgLVBKLUzgv4','BwLU','l21PC3nPB24','CMvTB3zL','zMLUza','CNvUBMvYvgL0Bgu','A2LUza','Aw52ywXPzgf0zunOyw5Nzxm','ChjLCgfYzuzVCKrPC2fIBgu','CNvUBMvY','y3jLyxrLqwDLBNrtzxnZAw9U','AgfZ','BwLZC2LVBK1JCfnLCNzLCG','DxbNCMfKzvjLywr5','zgLZy292zxjxB3jRC3bHy2u','ywrK','C3vIBwL0twLZC2LVBG','y2XVC2u','zMLSDgvY','zw5ZDxjLvg9WAwntBMfWC2HVDa','zMfPBgvKqxr0zw1WDhm','ndy0y0HsveLx','CMvNAxn0zxjbBgW','C2v0u2vZC2LVBLjLC291CMnLuMvSzwfZzxi','Aw5ZCgvJDa','AxnxyxrJAgLUzW','z2v0qwDLBNrtzxnZAw9U','zgvJAxnPB24','CgvUzgLUzW','zw5ZDxjLv2f0y2G','Ag9ZDgvKlwnVBNzLCNnHDgLVBG','y29TCgXLDgvdyw5JzwXSzwrsDw4','CMvNAxn0zxi','BNvTyMvY','Bwf0zxjPywXPEMvdB2rLEa','y2XLyxjbBgW','CMvTzw1Izxi','tK9erv9dt05orunusu9ox1jfueXbq0ve','y2fWywjPBgL0AwvZ','zMfRzvj1BM5LCG','uvvfvuu','B3bLBKnVzgvdBgLLBNq','CgvYC29UywXjBNn0CNvJDgLVBNm','Dgv4Da','ChjLCgfYzu1LC3nHz2vjBNb1Da','C3vWzxj2AxnLzfvWz3jHzgu','BwLZC2LVBG','m0T2v3vQDG','Cgf0Aa','BM9KzufWCfzLCNnPB24','B2jQzwn0AxzL','zMfRztO','surmrq','zw1PDenVBNzLCNnHDgLVBLr1CM4','CgvYC2LZDfrLCM1PBMfS'];_0x38ba=function(){return _0x1e6e22;};return _0x38ba();}import{WorkspaceUploadService}from'./service/workspace-upload-service.js';import{WorkspaceChangeService}from'./service/workspace-change-service.js';import{WorkspaceSessionService}from'./service/workspace-session-service.js';import{WorkbenchEventService}from'./service/workbench-event-service.js';import{RunDomainState}from'./service/run-domain-state.js';import{RecentRunProjectionService}from'./service/recent-run-projection-service.js';import{SessionDomainState}from'./service/session-domain-state.js';import{RunEventService}from'./service/run-event-service.js';import{RunAttachmentService}from'./service/run-attachment-service.js';import{NodeTerminalChannel}from'./service/node-terminal-channel.js';import{WorkspaceWorkbenchService}from'./service/workspace-workbench-service.js';import{NativeSessionWatchService}from'./service/native-session-watch-service.js';import{SessionWatchSlotCoordinator}from'./service/session-watch-slot-coordinator.js';import{SessionContextService}from'./service/session-context-service.js';import{WorkspaceDomainState}from'./service/workspace-domain-state.js';import{RunWorkbenchService}from'./service/run-workbench-service.js';import{SessionQueryService}from'./service/session-query-service.js';import{WorkspaceQueueWorkbenchService}from'./service/workspace-queue-workbench-service.js';import{ContinuousRunCoordinator}from'./service/continuous-run-coordinator.js';import{SessionIdentityService}from'./service/session-identity-service.js';import{NativeSessionProjectionService}from'./service/native-session-projection-service.js';import{composeConversationRuntimePage,ConversationHistoryService,convergeConversationWatchPage,hasManagedActiveRun}from'./service/conversation-history-service.js';import{ConversationSegmentService,conversationSegmentIdentityForItem,conversationSegments}from'./service/conversation-segment-service.js';import{RunnerInteractionService}from'./service/runner-interaction-service.js';import{SessionLifecycleService}from'./service/session-lifecycle-service.js';import{ExternalSessionResumeService}from'./service/external-session-resume-service.js';import{SessionMessageService}from'./service/session-message-service.js';import{SessionCatalogService}from'./service/session-catalog-service.js';import{SessionCommandService}from'./service/session-command-service.js';import{SessionPresentationService}from'./service/session-presentation-service.js';import{isPlainRecord,isRunnerImageAttachment,parseRunnerImageAttachments}from'./runner/codex/conversation-parser.js';import{readWebSearchError}from'./service/web-search-error.js';export{nodeConnectEndpoint,validatedCapabilities}from'./runner/codex/conversation-parser.js';import{NodeControlChannel}from'./service/node-control-channel.js';import{NodeControlMessageService}from'./service/node-control-message-service.js';import{NodeRequestService}from'./service/node-request-service.js';import{WorkbenchManifestService}from'./service/workbench-manifest-service.js';import{NodeRunEventBridge,workbenchPayloadSessionId}from'./service/node-run-event-bridge.js';import{NodeWorkspaceCoordinator}from'./service/node-workspace-coordinator.js';import{FakeManagedRunService}from'./service/fake-managed-run-service.js';import{RunnerChannelMessageService}from'./service/runner-channel-message-service.js';import{ManagedRunnerSessionService}from'./service/managed-runner-session-service.js';import{NodeConnectionLifecycleService}from'./service/node-connection-lifecycle-service.js';import{NodeUpgradeCoordinator,nodeUpgradeRequestPath}from'./service/node-upgrade-coordinator.js';import{HostedConversationStore}from'./service/hosted-conversation-store.js';import{ConversationTemplateNodeService}from'./service/conversation-template-node-service.js';import{HostedConversationNodeService}from'./service/hosted-conversation-node-service.js';import{BubblewrapSandboxExecutor}from'./service/bubblewrap-sandbox-executor.js';import{MarAgentHostedConversationRuntime}from'./runner/mar-agent/hosted-conversation-runtime.js';function _0x4f09(_0x3b8208,_0x4b425c){_0x3b8208=_0x3b8208-(0x63*0xd+-0x26ff+0x231f);const _0x50d9be=_0x38ba();let _0x6a03de=_0x50d9be[_0x3b8208];if(_0x4f09['SlHbEy']===undefined){var _0x41ceb2=function(_0x565ee5){const _0x58f598='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x202dff='',_0x37a61f='';for(let _0x47213c=-0x1219+0x25ac+-0x1393,_0x29760a,_0x5babf8,_0x2f87ee=-0x380+0x1b*-0x9+-0x43*-0x11;_0x5babf8=_0x565ee5['charAt'](_0x2f87ee++);~_0x5babf8&&(_0x29760a=_0x47213c%(-0x1f94+-0x10fe+0x3096)?_0x29760a*(0x16ff+0x14ca+-0x2b89)+_0x5babf8:_0x5babf8,_0x47213c++%(0x489+-0x24b*0x3+0x25c))?_0x202dff+=String['fromCharCode'](-0x1*0x18a3+0x1efa+-0x39*0x18&_0x29760a>>(-(0x1*0x1ca9+-0xb46+-0x5cb*0x3)*_0x47213c&-0x23f7+0xd5e+-0x169f*-0x1)):0xb*0x1a3+-0x5*-0x2c8+-0x1fe9){_0x5babf8=_0x58f598['indexOf'](_0x5babf8);}for(let _0x233107=0x11b*0x5+-0x1*0x22b7+-0x4*-0x74c,_0x3afc02=_0x202dff['length'];_0x233107<_0x3afc02;_0x233107++){_0x37a61f+='%'+('00'+_0x202dff['charCodeAt'](_0x233107)['toString'](-0x2644+0x237f+0x2d5*0x1))['slice'](-(0x1c1f+0xab5+-0x26d2));}return decodeURIComponent(_0x37a61f);};_0x4f09['TNrKqf']=_0x41ceb2,_0x4f09['IkqfUk']={},_0x4f09['SlHbEy']=!![];}const _0x25a1a2=_0x50d9be[-0x1*-0x56f+-0xea6+0x937];_0x4f09['BQmclQ']!==_0x25a1a2&&(_0x4f09['IkqfUk']={},_0x4f09['BQmclQ']=_0x25a1a2);const _0x3d3df1=_0x4f09['IkqfUk'][_0x3b8208];return _0x3d3df1===undefined?(_0x6a03de=_0x4f09['TNrKqf'](_0x6a03de),_0x4f09['IkqfUk'][_0x3b8208]=_0x6a03de):_0x6a03de=_0x3d3df1,_0x6a03de;}import{conversationHostingCapability,probeBubblewrap}from'./service/conversation-hosting-capability-service.js';import{ConversationHostingMaintenanceService}from'./service/conversation-hosting-maintenance-service.js';import{ConversationHostingEnablementService}from'./service/conversation-hosting-enablement-service.js';import{safeErrorCode}from'./util/safe-error.js';import{RuntimeCredentialControlService}from'./service/runtime-credential-control-service.js';import{MarAgentRuntimeModelFactory}from'./runner/mar-agent/runtime-model-factory.js';import{MarAgentModelTransportTestService}from'./service/mar-agent-model-transport-test-service.js';const HEARTBEAT_MS=-0x3883+-0xa80+0x221*0x3b,CAPABILITY_REFRESH_MS=0x8170+-0xffa1+0x16891,RETRY_MIN_MS=0x79f*-0x2+-0x14b7+0x25e9,RETRY_MAX_MS=-0x2e4f+0x1b35+-0x916*-0xf,CLAUDE_APPROVAL_TIMEOUT_MS=(0x1*-0xe9+-0x18a3+0x1996)*(-0x2*-0xe027+0x3*-0x56af+0x2e1f),CONVERSATION_TEMPLATE_OPERATIONS=[_0x4ce2c3(0x2f9),_0x4ce2c3(0x2e6),_0x4ce2c3(0x15a),_0x4ce2c3(0x2d0)],HOSTED_CONVERSATION_OPERATIONS=[_0x4ce2c3(0x146),_0x4ce2c3(0x1d0),_0x4ce2c3(0x28b),_0x4ce2c3(0x2c4),_0x4ce2c3(0x2ad),_0x4ce2c3(0x1e8),_0x4ce2c3(0x250),_0x4ce2c3(0x234),_0x4ce2c3(0x1b2),_0x4ce2c3(0x1bf),_0x4ce2c3(0x26a),_0x4ce2c3(0x157),_0x4ce2c3(0x27e),_0x4ce2c3(0x1cf),_0x4ce2c3(0x2da),_0x4ce2c3(0x199),_0x4ce2c3(0x27c),_0x4ce2c3(0x1ea),_0x4ce2c3(0x1c6),_0x4ce2c3(0x2eb)],CONVERSATION_HOSTING_MAINTENANCE_OPERATIONS=[_0x4ce2c3(0x177),_0x4ce2c3(0x270),_0x4ce2c3(0x246)];export function nextReconnectDelay(_0x154549){const _0x400ebe=_0x4ce2c3;return Math[_0x400ebe(0x1f6)](RETRY_MAX_MS,RETRY_MIN_MS*(0x1f58+-0x3*0x899+-0x58b)**Math[_0x400ebe(0x1f6)](Math[_0x400ebe(0x19e)](_0x154549,0xb*0x19b+0x43*-0x53+-0x8*-0x82),-0xb5c+0x11b*0x5+-0x1*-0x5e5));}function upgradeMetadata(_0x4c9c97,_0x483cd8){const _0x165409=_0x4ce2c3,_0x377fdb={..._0x4c9c97??{}};if(process.env['MAR_NODE_SUPERVISED']==='1')_0x377fdb[_0x165409(0x222)]=!![];else delete _0x377fdb[_0x165409(0x222)];if(_0x483cd8[_0x165409(0x19a)]===_0x165409(0x229))delete _0x377fdb[_0x165409(0x15c)];else _0x377fdb[_0x165409(0x15c)]=_0x483cd8;return _0x377fdb;}export class NodeConnector{[_0x4ce2c3(0x27a)]=crypto[_0x4ce2c3(0x24a)]()[_0x4ce2c3(0x248)](/-/g,'');[_0x4ce2c3(0x12f)];[_0x4ce2c3(0x134)];[_0x4ce2c3(0x2f4)];[_0x4ce2c3(0x2aa)];[_0x4ce2c3(0x164)]=new RuntimeCredentialControlService({'send':envelope=>this[_0x4ce2c3(0x147)](envelope)});[_0x4ce2c3(0x179)]=new MarAgentRuntimeModelFactory(this[_0x4ce2c3(0x164)]);[_0x4ce2c3(0x2dd)]=new MarAgentModelTransportTestService({'modelFactory':this[_0x4ce2c3(0x179)]});set[_0x4ce2c3(0x130)](_0x34cab2){const _0x5847b9=_0x4ce2c3;this[_0x5847b9(0x12f)][_0x5847b9(0x1a4)](_0x34cab2);}[_0x4ce2c3(0x1a0)]=![];[_0x4ce2c3(0x260)];[_0x4ce2c3(0x1e7)];[_0x4ce2c3(0x1cd)];[_0x4ce2c3(0x21b)];[_0x4ce2c3(0x1af)];[_0x4ce2c3(0x298)];[_0x4ce2c3(0x2f1)]=![];[_0x4ce2c3(0x2ab)];[_0x4ce2c3(0x1d9)];[_0x4ce2c3(0x253)];[_0x4ce2c3(0x2a1)];[_0x4ce2c3(0x24c)];[_0x4ce2c3(0x129)];[_0x4ce2c3(0x2cc)];[_0x4ce2c3(0x2b7)];[_0x4ce2c3(0x12e)];[_0x4ce2c3(0x2de)];[_0x4ce2c3(0x2f2)]=new WorkbenchEventService(envelope=>this[_0x4ce2c3(0x147)](envelope),(category,payload)=>{const _0x471d84=_0x4ce2c3,sessionId=workbenchPayloadSessionId(this[_0x471d84(0x2bd)],category,payload);return sessionId===undefined||!this[_0x471d84(0x240)][_0x471d84(0x128)][_0x471d84(0x200)](sessionId);});[_0x4ce2c3(0x21c)];[_0x4ce2c3(0x1e1)];[_0x4ce2c3(0x1ae)]=new RunDomainState();[_0x4ce2c3(0x1cc)];[_0x4ce2c3(0x244)];[_0x4ce2c3(0x295)]=new SessionDomainState();[_0x4ce2c3(0x240)];[_0x4ce2c3(0x1bb)];[_0x4ce2c3(0x1d8)];[_0x4ce2c3(0x187)];[_0x4ce2c3(0x190)];[_0x4ce2c3(0x25f)];[_0x4ce2c3(0x2ed)];[_0x4ce2c3(0x242)];[_0x4ce2c3(0x1c9)];[_0x4ce2c3(0x1f2)];[_0x4ce2c3(0x2ba)];[_0x4ce2c3(0x309)];[_0x4ce2c3(0x1c7)];[_0x4ce2c3(0x17f)];[_0x4ce2c3(0x23c)];[_0x4ce2c3(0x291)];[_0x4ce2c3(0x13b)];[_0x4ce2c3(0x13e)];[_0x4ce2c3(0x21e)];[_0x4ce2c3(0x284)];[_0x4ce2c3(0x131)];[_0x4ce2c3(0x268)];[_0x4ce2c3(0x2df)];[_0x4ce2c3(0x1ba)];[_0x4ce2c3(0x18e)];[_0x4ce2c3(0x2ec)];[_0x4ce2c3(0x27f)];[_0x4ce2c3(0x26d)];[_0x4ce2c3(0x153)];[_0x4ce2c3(0x194)]=new NodeOperationRouter();[_0x4ce2c3(0x2b3)];[_0x4ce2c3(0x142)];[_0x4ce2c3(0x1e9)];[_0x4ce2c3(0x1f4)];[_0x4ce2c3(0x151)]=new CommandStateStore();[_0x4ce2c3(0x1be)]=new MissionRuntime(()=>undefined);[_0x4ce2c3(0x2cb)]=new Map();[_0x4ce2c3(0x15f)]=new Map();[_0x4ce2c3(0x201)]=new MissionMcpServer(this[_0x4ce2c3(0x1be)],sessionId=>{const _0x108e3c=_0x4ce2c3,mission=this[_0x108e3c(0x1be)][_0x108e3c(0x1dd)](sessionId),session=this[_0x108e3c(0x2bd)][_0x108e3c(0x20f)](sessionId);if(mission===undefined||session===undefined)return;if(mission[_0x108e3c(0x17c)]!==_0x108e3c(0x152))this[_0x108e3c(0x26d)][_0x108e3c(0x263)](sessionId);this[_0x108e3c(0x235)](session,mission);});[_0x4ce2c3(0x23b)];[_0x4ce2c3(0x273)];[_0x4ce2c3(0x29c)];[_0x4ce2c3(0x2c5)]=new WorkspaceDomainState();[_0x4ce2c3(0x265)]=new WorkspaceWatchService(this[_0x4ce2c3(0x2c5)],workspaceId=>this[_0x4ce2c3(0x1c0)][_0x4ce2c3(0x212)](workspaceId),workspaceId=>this[_0x4ce2c3(0x1c0)][_0x4ce2c3(0x25d)](workspaceId),workspaceId=>this[_0x4ce2c3(0x26b)]?.[_0x4ce2c3(0x28e)](workspaceId));[_0x4ce2c3(0x1c0)]=new WorkspaceSessionService(this[_0x4ce2c3(0x2c5)],{'discover':workspaceId=>this[_0x4ce2c3(0x2e0)](workspaceId),'listPage':workspaceId=>this[_0x4ce2c3(0x281)](_0x4ce2c3(0x166),{'workspaceId':workspaceId,'limit':0x14}),'active':workspaceId=>this[_0x4ce2c3(0x265)][_0x4ce2c3(0x289)](workspaceId,_0x4ce2c3(0x2b1)),'invalidate':workspaceId=>void this[_0x4ce2c3(0x26b)]?.[_0x4ce2c3(0x1d5)](workspaceId,_0x4ce2c3(0x2b1)),'onPending':(workspaceId,waitMs)=>nodeLog(_0x4ce2c3(0x241),{'nodeId':this[_0x4ce2c3(0x1e7)]?.[_0x4ce2c3(0x25e)],'workspaceId':workspaceId,'waitMs':waitMs})});[_0x4ce2c3(0x2a0)]=new WorkspaceFileService(this[_0x4ce2c3(0x2c5)],()=>this[_0x4ce2c3(0x1e7)]?.[_0x4ce2c3(0x1b7)]??[],workspaceId=>this[_0x4ce2c3(0x244)][_0x4ce2c3(0x2f6)](workspaceId));[_0x4ce2c3(0x306)]=new WorkspaceUploadService(this[_0x4ce2c3(0x2c5)],workspaceId=>{const _0x3b9ae9=_0x4ce2c3;this[_0x3b9ae9(0x2a0)][_0x3b9ae9(0x189)](workspaceId),this[_0x3b9ae9(0x244)][_0x3b9ae9(0x2f6)](workspaceId);});[_0x4ce2c3(0x1b0)]=new WorkspaceChangeService(this[_0x4ce2c3(0x2c5)]);[_0x4ce2c3(0x26b)];[_0x4ce2c3(0x185)];[_0x4ce2c3(0x162)]=new RecentRunProjectionService(message=>this[_0x4ce2c3(0x2d9)](_0x4ce2c3(0x23f),message));[_0x4ce2c3(0x2bd)]=new NodeRuntimeState(()=>this[_0x4ce2c3(0x1e7)]?.[_0x4ce2c3(0x25e)]??_0x4ce2c3(0x266),workspaceId=>this[_0x4ce2c3(0x185)]?.[_0x4ce2c3(0x2cf)](workspaceId),Date[_0x4ce2c3(0x1e5)],(run,session,userMessage)=>this[_0x4ce2c3(0x162)][_0x4ce2c3(0x16a)](run,session,userMessage));[_0x4ce2c3(0x1b3)]=new NodeMetrics();[_0x4ce2c3(0x302)]=new RunEventService({'runtime':this[_0x4ce2c3(0x2bd)],'metrics':this[_0x4ce2c3(0x1b3)],'state':this[_0x4ce2c3(0x1ae)],'isBootstrapSession':sessionId=>this[_0x4ce2c3(0x240)][_0x4ce2c3(0x128)][_0x4ce2c3(0x200)](sessionId),'presentSession':session=>this[_0x4ce2c3(0x242)][_0x4ce2c3(0x278)](session),'rejectBootstrap':(sessionId,code)=>this[_0x4ce2c3(0x240)][_0x4ce2c3(0x1ab)](sessionId,code),'emitWorkbench':(category,payload)=>{const _0x3b61ba=_0x4ce2c3;if(category===_0x3b61ba(0x303)&&isPlainRecord(payload)&&_0x3b61ba(0x2e4)in payload)this[_0x3b61ba(0x22a)](payload[_0x3b61ba(0x2e4)]);else this[_0x3b61ba(0x2f0)](category,payload);},'cleanupAttachments':runId=>this[_0x4ce2c3(0x17f)][_0x4ce2c3(0x26e)](runId),'expireImages':runId=>this[_0x4ce2c3(0x17f)][_0x4ce2c3(0x2ca)](runId),'scheduleContextRefresh':sessionId=>this[_0x4ce2c3(0x18e)][_0x4ce2c3(0x1f3)](sessionId),'refreshWorkspaceSessions':workspaceId=>this[_0x4ce2c3(0x26b)][_0x4ce2c3(0x208)](workspaceId,_0x4ce2c3(0x2b1)),'dispatchQueue':async(sessionId,delayMs=0x1cfc+-0x2*0x449+-0x146a)=>{const _0x294b04=_0x4ce2c3;if(this[_0x294b04(0x29c)][_0x294b04(0x211)]())return;if(delayMs>0x3b*0x4f+0x20c9+-0x32fe){this[_0x294b04(0x26d)][_0x294b04(0x1f3)](sessionId,delayMs);return;}await this[_0x294b04(0x26d)][_0x294b04(0x2e3)](sessionId);},'executionStarted':executionId=>this[_0x4ce2c3(0x26d)][_0x4ce2c3(0x198)](executionId),'keepRunActive':sessionId=>(this[_0x4ce2c3(0x2cb)][_0x4ce2c3(0x200)](sessionId)||this[_0x4ce2c3(0x15f)][_0x4ce2c3(0x200)](sessionId))&&this[_0x4ce2c3(0x1be)][_0x4ce2c3(0x1dd)](sessionId)?.[_0x4ce2c3(0x17c)]===_0x4ce2c3(0x152),'executionTerminating':(executionId,status)=>{const _0x5f2f87=_0x4ce2c3,pending=this[_0x5f2f87(0x26d)][_0x5f2f87(0x211)](executionId);if(pending?.[_0x5f2f87(0x223)]===undefined)return;const started=this[_0x5f2f87(0x26d)][_0x5f2f87(0x256)](executionId),blocked=this[_0x5f2f87(0x1be)][_0x5f2f87(0x2ce)](pending[_0x5f2f87(0x243)],status===_0x5f2f87(0x2a5));if(blocked){this[_0x5f2f87(0x196)](pending[_0x5f2f87(0x243)]),this[_0x5f2f87(0x26d)][_0x5f2f87(0x263)](pending[_0x5f2f87(0x243)]);const terminalMission=this[_0x5f2f87(0x1be)][_0x5f2f87(0x1dd)](pending[_0x5f2f87(0x243)]),session=this[_0x5f2f87(0x2bd)][_0x5f2f87(0x20f)](pending[_0x5f2f87(0x243)]);if(terminalMission!==undefined&&session!==undefined)this[_0x5f2f87(0x235)](session,terminalMission);return;}if(status!==_0x5f2f87(0x2a5)||started)return;this[_0x5f2f87(0x196)](pending[_0x5f2f87(0x243)]);const retry={'sessionId':pending[_0x5f2f87(0x243)],'timer':setTimeout(()=>{const _0x27704c=_0x5f2f87;this[_0x27704c(0x2cb)][_0x27704c(0x168)](retry[_0x27704c(0x243)]);const mission=this[_0x27704c(0x1be)][_0x27704c(0x1dd)](retry[_0x27704c(0x243)]);if(mission?.[_0x27704c(0x17c)]!==_0x27704c(0x152)||mission['id']!==pending[_0x27704c(0x223)]?.['id']||mission[_0x27704c(0x22c)]!==pending[_0x27704c(0x223)][_0x27704c(0x22c)])return;void this[_0x27704c(0x2ba)][_0x27704c(0x205)]({'sessionId':retry[_0x27704c(0x243)],'kind':_0x27704c(0x2c6),'content':this[_0x27704c(0x1be)][_0x27704c(0x1a6)](retry[_0x27704c(0x243)],_0x27704c(0x2c6)),'deliveryIntent':_0x27704c(0x1d3),'mission':{'id':mission['id'],'revision':mission[_0x27704c(0x22c)]},'secretEnvironment':pending[_0x27704c(0x158)],...pending[_0x27704c(0x21f)]===undefined?{}:{'personalInstructions':pending[_0x27704c(0x21f)]},...pending[_0x27704c(0x1ed)]===undefined?{}:{'marAgentModel':pending[_0x27704c(0x1ed)]},...pending[_0x27704c(0x2fd)]===undefined?{}:{'marAgentModels':pending[_0x27704c(0x2fd)]},...pending[_0x27704c(0x30b)]===undefined?{}:{'marAgentRuntimeScopeId':pending[_0x27704c(0x30b)]}})[_0x27704c(0x27b)](()=>undefined);},-0x6575+-0x3*-0x56f+0x8fc0)};this[_0x5f2f87(0x2cb)][_0x5f2f87(0x2ae)](pending[_0x5f2f87(0x243)],retry),retry[_0x5f2f87(0x23a)][_0x5f2f87(0x237)]();},'releaseExecution':executionId=>{const _0x502b98=_0x4ce2c3;this[_0x502b98(0x201)][_0x502b98(0x238)](executionId),this[_0x502b98(0x26d)][_0x502b98(0x1f8)](executionId);}});[_0x4ce2c3(0x133)]=new SessionWatchSlotCoordinator();[_0x4ce2c3(0x30a)]=new NativeSessionWatchService({'resolve':async sessionId=>this[_0x4ce2c3(0x2bd)][_0x4ce2c3(0x20f)](sessionId)??this[_0x4ce2c3(0x1bb)][_0x4ce2c3(0x272)](sessionId),'managedActive':session=>hasManagedActiveRun(this[_0x4ce2c3(0x2bd)],session),'suspended':sessionId=>this[_0x4ce2c3(0x1f2)][_0x4ce2c3(0x176)](sessionId),'refreshActivity':session=>this[_0x4ce2c3(0x1d8)][_0x4ce2c3(0x2e1)](session),'present':session=>this[_0x4ce2c3(0x242)][_0x4ce2c3(0x278)](session),'readPage':(session,limit)=>this[_0x4ce2c3(0x1d8)][_0x4ce2c3(0x16e)](session,{'limit':limit}),'readHistoryPage':(session,limit)=>this[_0x4ce2c3(0x1d8)][_0x4ce2c3(0x275)](session,{'limit':limit}),'convergePage':convergeConversationWatchPage,'composeRuntimePage':composeConversationRuntimePage,'projectInitialPage':(session,page,_unit,limit)=>{const _0x12caf7=_0x4ce2c3,context=this[_0x12caf7(0x18e)][_0x12caf7(0x1c3)](session['id']);return this[_0x12caf7(0x18e)][_0x12caf7(0x1f3)](session),{'kind':_0x12caf7(0x156),'sequence':this[_0x12caf7(0x2f2)][_0x12caf7(0x2a3)](),'session':this[_0x12caf7(0x242)][_0x12caf7(0x278)](session),'runs':this[_0x12caf7(0x2bd)][_0x12caf7(0x17b)](session['id']),'queue':this[_0x12caf7(0x153)][_0x12caf7(0x1c3)](session['id']),'context':context,'conversation':this[_0x12caf7(0x187)][_0x12caf7(0x24e)](session,page,limit)};},'emitSession':session=>this[_0x4ce2c3(0x25c)]({'session':session}),'emitPage':(session,page)=>this[_0x4ce2c3(0x2a7)](_0x4ce2c3(0x303),{'sessionId':session['id'],'snapshot':this[_0x4ce2c3(0x187)][_0x4ce2c3(0x24e)](session,page,0x469*-0x7+0x9af+-0xd*-0x1a2)}),'nodeId':()=>this[_0x4ce2c3(0x1e7)]?.[_0x4ce2c3(0x25e)]??_0x4ce2c3(0x266),'nodeGeneration':()=>this[_0x4ce2c3(0x27a)],'emitWatchEvent':payload=>this[_0x4ce2c3(0x2d9)](_0x4ce2c3(0x294),payload),'sessionWatchSlots':this[_0x4ce2c3(0x133)],'log':nodeLog});constructor(_0x1a4902={}){const _0x13a99f=_0x4ce2c3;this[_0x13a99f(0x1e7)]=_0x1a4902[_0x13a99f(0x1e7)],this[_0x13a99f(0x2b7)]=_0x1a4902[_0x13a99f(0x2b7)],this[_0x13a99f(0x2de)]=_0x1a4902[_0x13a99f(0x2de)]??CLAUDE_APPROVAL_TIMEOUT_MS,this[_0x13a99f(0x1cd)]=_0x1a4902[_0x13a99f(0x21b)]!==undefined,this[_0x13a99f(0x21b)]=_0x1a4902[_0x13a99f(0x21b)]??unavailableCapabilities(),this[_0x13a99f(0x298)]=_0x1a4902[_0x13a99f(0x298)]??probeBubblewrap,this[_0x13a99f(0x29c)]=new NodeUpgradeCoordinator(()=>{const _0x3a4170=_0x13a99f;if(this[_0x3a4170(0x1e7)]===undefined)throw new Error(_0x3a4170(0x1a7));return nodeUpgradeRequestPath(nodeDatabasePath(this[_0x3a4170(0x1e7)],this[_0x3a4170(0x2b7)]));},()=>this[_0x13a99f(0x1ae)][_0x13a99f(0x152)][_0x13a99f(0x1a9)],_0x487a44=>{const _0x3f410e=_0x13a99f;this[_0x3f410e(0x21b)]={...this[_0x3f410e(0x21b)],'metadata':upgradeMetadata(this[_0x3f410e(0x21b)][_0x3f410e(0x24b)],_0x487a44)},this[_0x3f410e(0x12f)]?.[_0x3f410e(0x2d9)](_0x3f410e(0x21b),this[_0x3f410e(0x21b)]);},_0x1a4902[_0x13a99f(0x202)]??(()=>{const _0x35492e=_0x13a99f;void this[_0x35492e(0x230)]()[_0x35492e(0x2e2)](()=>process[_0x35492e(0x2f3)](-0x1*-0xb1b+0x3d*0x85+-0x2a81));})),this[_0x13a99f(0x21b)]={...this[_0x13a99f(0x21b)],'metadata':upgradeMetadata(this[_0x13a99f(0x21b)][_0x13a99f(0x24b)],this[_0x13a99f(0x29c)][_0x13a99f(0x1c3)]())};const _0x538b75=_0x1a4902[_0x13a99f(0x1af)]??detectCapabilitiesAsync;this[_0x13a99f(0x1af)]=async()=>{const _0x490000=_0x13a99f,_0x2d7f7e=await _0x538b75();return this[_0x490000(0x17e)]({..._0x2d7f7e,'metadata':upgradeMetadata(_0x2d7f7e[_0x490000(0x24b)],this[_0x490000(0x29c)][_0x490000(0x1c3)]())});},this[_0x13a99f(0x12e)]=_0x1a4902[_0x13a99f(0x12e)]??!![],this[_0x13a99f(0x21c)]=_0x1a4902[_0x13a99f(0x21c)]===undefined?undefined:new FakeTestRunner(_0x1a4902[_0x13a99f(0x21c)]),this[_0x13a99f(0x1e1)]=_0x1a4902[_0x13a99f(0x1e1)],this[_0x13a99f(0x17f)]=new RunAttachmentService(_0x296177=>this[_0x13a99f(0x1ba)][_0x13a99f(0x1b8)](_0x296177[_0x13a99f(0x1fe)])[_0x13a99f(0x26f)](_0x296177)),this[_0x13a99f(0x291)]=new CodexRunner(_0x1a4902[_0x13a99f(0x291)],_0x1a4902[_0x13a99f(0x22e)]),this[_0x13a99f(0x13b)]=new CodexManagedRunController(this[_0x13a99f(0x291)],{'available':()=>this[_0x13a99f(0x21b)][_0x13a99f(0x136)][_0x13a99f(0x14c)],'intercepted':()=>this[_0x13a99f(0x21c)]!==undefined,'active':this[_0x13a99f(0x1ae)][_0x13a99f(0x152)],'addActive':_0x532db2=>this[_0x13a99f(0x1ae)][_0x13a99f(0x152)][_0x13a99f(0x204)](_0x532db2),'removeActive':_0x1d2476=>this[_0x13a99f(0x1ae)][_0x13a99f(0x152)][_0x13a99f(0x168)](_0x1d2476),'adopt':_0x3720e3=>this[_0x13a99f(0x2bd)][_0x13a99f(0x1ee)](_0x3720e3),'session':_0x546f63=>this[_0x13a99f(0x2bd)][_0x13a99f(0x20f)](_0x546f63),'runStatus':_0x4e86bf=>this[_0x13a99f(0x2bd)][_0x13a99f(0x138)](_0x4e86bf)?.[_0x13a99f(0x17c)],'run':_0x3baccf=>this[_0x13a99f(0x2bd)][_0x13a99f(0x138)](_0x3baccf),'interrupted':_0x2bc351=>this[_0x13a99f(0x1ae)][_0x13a99f(0x171)][_0x13a99f(0x200)](_0x2bc351),'parseAttachments':parseRunnerImageAttachments,'materialize':(_0x48295a,_0x5df1bb)=>this[_0x13a99f(0x17f)][_0x13a99f(0x217)](_0x48295a,_0x5df1bb),'completeCancelled':_0x1feee5=>this[_0x13a99f(0x190)][_0x13a99f(0x214)](_0x1feee5),'promoteSession':(_0x4939e0,_0x311397)=>this[_0x13a99f(0x240)][_0x13a99f(0x25b)](_0x4939e0,_0x311397),'send':(_0x176229,_0x10e556)=>this[_0x13a99f(0x2d9)](_0x176229,_0x10e556),'emit':(_0x1023d1,_0x2f9f43,_0x433ffc,_0x1fbc42)=>this[_0x13a99f(0x1cc)][_0x13a99f(0x233)](_0x1023d1,_0x2f9f43,_0x433ffc,_0x1fbc42),'cancel':(_0x13f73c,_0x39aa60,_0x2b676f,_0x2001fe,_0x42bb86)=>this[_0x13a99f(0x190)][_0x13a99f(0x2c8)](_0x13f73c,_0x39aa60,_0x2b676f,_0x2001fe,_0x42bb86),'createApproval':_0x5b293c=>this[_0x13a99f(0x2bd)][_0x13a99f(0x2be)](_0x5b293c),'publishApproval':_0x39dc7f=>this[_0x13a99f(0x1cc)][_0x13a99f(0x137)](_0x39dc7f),'emitItem':(_0x42cd75,_0x485bbf)=>this[_0x13a99f(0x172)](_0x42cd75,_0x485bbf),'appendImages':(_0x4881ae,_0x3bb785)=>this[_0x13a99f(0x17f)][_0x13a99f(0x2e5)](_0x4881ae,_0x3bb785[_0x13a99f(0x207)](isRunnerImageAttachment)),'syncTitle':(_0x5e0584,_0x2e0fe9,_0x3fbe3b)=>this[_0x13a99f(0x2ed)][_0x13a99f(0x2a9)](_0x5e0584,_0x2e0fe9,_0x3fbe3b),'commandState':(_0x4e6708,_0x23de52)=>this[_0x13a99f(0x151)][_0x13a99f(0x1dd)](_0x4e6708,_0x23de52),'setCommandState':(_0x550d9d,_0x457b74)=>this[_0x13a99f(0x151)][_0x13a99f(0x2ae)](_0x550d9d,_0x457b74),'clearCommandState':(_0xb4154a,_0x938786)=>this[_0x13a99f(0x151)][_0x13a99f(0x17a)](_0xb4154a,_0x938786),'commandStates':_0x7d693a=>this[_0x13a99f(0x151)][_0x13a99f(0x252)](_0x7d693a),'hasActiveSessionLease':_0x390b02=>this[_0x13a99f(0x2bd)][_0x13a99f(0x2d1)](_0x390b02),'fast':_0x40503a=>this[_0x13a99f(0x281)](_0x13a99f(0x1c5),{'runner':_0x13a99f(0x136),'commandId':_0x13a99f(0x195),'input':_0x40503a})}),this[_0x13a99f(0x291)][_0x13a99f(0x2ee)](_0x8893f5=>this[_0x13a99f(0x13b)][_0x13a99f(0x2fc)](_0x8893f5)),this[_0x13a99f(0x13e)]=new ClaudeCodeRunner(_0x1a4902[_0x13a99f(0x13e)]),this[_0x13a99f(0x21e)]=new OpenCodeRunner(_0x1a4902[_0x13a99f(0x21e)]),this[_0x13a99f(0x284)]=new MarAgentRunner(),this[_0x13a99f(0x284)][_0x13a99f(0x29e)]((_0x568ddd,_0xe0d2ea)=>this[_0x13a99f(0x17f)][_0x13a99f(0x2dc)](_0x568ddd,_0xe0d2ea)),this[_0x13a99f(0x131)]=new MarAgentManagedRunController(this[_0x13a99f(0x284)],{'active':this[_0x13a99f(0x1ae)][_0x13a99f(0x152)],'adopt':_0x361482=>this[_0x13a99f(0x2bd)][_0x13a99f(0x1ee)](_0x361482),'promote':(_0x153d87,_0x535561)=>this[_0x13a99f(0x240)][_0x13a99f(0x25b)](_0x153d87,_0x535561),'syncTitle':(_0x50ba16,_0x39d253)=>this[_0x13a99f(0x2ed)][_0x13a99f(0x2a9)](_0x50ba16,_0x50ba16,_0x39d253),'emit':(_0xe17fbd,_0x170351,_0x4b506a,_0xe7f180)=>this[_0x13a99f(0x1cc)][_0x13a99f(0x233)](_0xe17fbd,_0x170351,_0x4b506a,_0xe7f180),'emitItem':(_0x52184f,_0x1395aa)=>this[_0x13a99f(0x172)](_0x52184f,_0x1395aa),'refreshContext':_0x4c87dc=>{const _0x1a0cfa=_0x13a99f,_0x1d852a=this[_0x1a0cfa(0x2bd)][_0x1a0cfa(0x138)](_0x4c87dc)?.[_0x1a0cfa(0x243)];if(_0x1d852a!==undefined)this[_0x1a0cfa(0x18e)][_0x1a0cfa(0x1f3)](_0x1d852a);},'createApproval':_0x3fe756=>this[_0x13a99f(0x2bd)][_0x13a99f(0x2be)](_0x3fe756),'publishApproval':_0x5acd39=>this[_0x13a99f(0x1cc)][_0x13a99f(0x137)](_0x5acd39),'run':_0x3a587c=>this[_0x13a99f(0x2bd)][_0x13a99f(0x138)](_0x3a587c),'commandState':(_0x576114,_0x39edee)=>this[_0x13a99f(0x151)][_0x13a99f(0x1dd)](_0x576114,_0x39edee),'setCommandState':(_0xf7acc7,_0x372b25)=>this[_0x13a99f(0x151)][_0x13a99f(0x2ae)](_0xf7acc7,_0x372b25),'clearCommandState':(_0x52176c,_0x5ebede)=>this[_0x13a99f(0x151)][_0x13a99f(0x17a)](_0x52176c,_0x5ebede),'commandStates':_0x1c6a2a=>this[_0x13a99f(0x151)][_0x13a99f(0x252)](_0x1c6a2a),'webSearch':(_0xab093,_0x2bc250)=>this[_0x13a99f(0x1b5)](_0xab093,_0x2bc250),'registerGeneratedImages':(_0x13f505,_0x1197ab,_0x147959)=>{const _0x2d46b0=_0x13a99f,_0x346f1c=this[_0x2d46b0(0x2bd)][_0x2d46b0(0x23e)](_0x13f505),_0x449e98=_0x346f1c===undefined?undefined:this[_0x2d46b0(0x2bd)][_0x2d46b0(0x20f)](_0x346f1c[_0x2d46b0(0x243)]);return _0x449e98===undefined?[]:this[_0x2d46b0(0x284)][_0x2d46b0(0x231)](_0x449e98,_0x1197ab,_0x147959);}},{'modelFactory':this[_0x13a99f(0x179)]}),this[_0x13a99f(0x284)][_0x13a99f(0x20c)](_0x38779c=>this[_0x13a99f(0x131)][_0x13a99f(0x19f)](_0x38779c)),this[_0x13a99f(0x268)]=new OpenCodeManagedRunController(this[_0x13a99f(0x21e)],{'intercepted':()=>this[_0x13a99f(0x21c)]!==undefined,'active':this[_0x13a99f(0x1ae)][_0x13a99f(0x152)],'parseAttachments':parseRunnerImageAttachments,'persistAttachments':(_0x5e0ad6,_0xe6894,_0x3936a4)=>this[_0x13a99f(0x17f)][_0x13a99f(0x254)](_0x5e0ad6,_0xe6894+_0x13a99f(0x154),_0x3936a4),'emit':(_0x445960,_0xb4bef1,_0x4b8f32,_0x91134d)=>this[_0x13a99f(0x1cc)][_0x13a99f(0x233)](_0x445960,_0xb4bef1,_0x4b8f32,_0x91134d),'emitItem':(_0x10a433,_0x41f2c1)=>this[_0x13a99f(0x172)](_0x10a433,_0x41f2c1),'adopt':_0x14fb59=>this[_0x13a99f(0x2bd)][_0x13a99f(0x1ee)](_0x14fb59),'run':_0x5cfb10=>{const _0x18a2b2=_0x13a99f,_0x53d1a4=this[_0x18a2b2(0x2bd)][_0x18a2b2(0x138)](_0x5cfb10);if(_0x53d1a4===undefined)throw new Error(_0x18a2b2(0x12b));return _0x53d1a4;},'hasActiveSessionLease':_0x59f3d1=>this[_0x13a99f(0x2bd)][_0x13a99f(0x2d1)](_0x59f3d1),'promote':(_0x4b6bf8,_0x3d6454)=>this[_0x13a99f(0x240)][_0x13a99f(0x25b)](_0x4b6bf8,_0x3d6454),'rememberNative':(_0x18c66d,_0x570115)=>this[_0x13a99f(0x2ed)][_0x13a99f(0x219)](_0x18c66d,_0x570115),'send':(_0x3d709a,_0x2c81cc)=>this[_0x13a99f(0x2d9)](_0x3d709a,_0x2c81cc),'createApproval':_0x4bcf31=>this[_0x13a99f(0x2bd)][_0x13a99f(0x2be)](_0x4bcf31),'expireApproval':_0x5cfa23=>{const _0x16582c=_0x13a99f;this[_0x16582c(0x2bd)][_0x16582c(0x2e9)](_0x5cfa23);},'publishApproval':_0x1b7002=>this[_0x13a99f(0x1cc)][_0x13a99f(0x137)](_0x1b7002),'commandState':(_0x5843be,_0x315b0f)=>this[_0x13a99f(0x151)][_0x13a99f(0x1dd)](_0x5843be,_0x315b0f),'setCommandState':(_0x5e4a16,_0xfc9272)=>this[_0x13a99f(0x151)][_0x13a99f(0x2ae)](_0x5e4a16,_0xfc9272),'clearCommandState':(_0x1ba964,_0x10c412)=>this[_0x13a99f(0x151)][_0x13a99f(0x17a)](_0x1ba964,_0x10c412),'commandStates':_0x2ea597=>this[_0x13a99f(0x151)][_0x13a99f(0x252)](_0x2ea597)},this[_0x13a99f(0x2de)]),this[_0x13a99f(0x2df)]=new ClaudeManagedRunController(this[_0x13a99f(0x13e)],{'intercepted':()=>this[_0x13a99f(0x21c)]!==undefined,'active':this[_0x13a99f(0x1ae)][_0x13a99f(0x152)],'parseAttachments':parseRunnerImageAttachments,'emit':(_0x1c46eb,_0x257842,_0x1d671d,_0x3a52ab)=>this[_0x13a99f(0x1cc)][_0x13a99f(0x233)](_0x1c46eb,_0x257842,_0x1d671d,_0x3a52ab),'adopt':_0xad27da=>this[_0x13a99f(0x2bd)][_0x13a99f(0x1ee)](_0xad27da),'run':_0x32d63f=>this[_0x13a99f(0x2bd)][_0x13a99f(0x138)](_0x32d63f),'hasActiveSessionLease':_0x512a83=>this[_0x13a99f(0x2bd)][_0x13a99f(0x2d1)](_0x512a83),'session':_0x220af2=>this[_0x13a99f(0x2bd)][_0x13a99f(0x20f)](_0x220af2),'completeCancelled':_0x5abba3=>this[_0x13a99f(0x190)][_0x13a99f(0x214)](_0x5abba3),'requestUserInput':(_0x8073ce,_0x2bf072,_0x27ba69)=>this[_0x13a99f(0x190)][_0x13a99f(0x1ce)](_0x8073ce,_0x2bf072,_0x27ba69),'requestApproval':(_0x452b60,_0x270eb5,_0x36389d)=>this[_0x13a99f(0x190)][_0x13a99f(0x1da)](_0x452b60,_0x270eb5,_0x36389d),'rememberNative':(_0x153ebf,_0x137fe7)=>this[_0x13a99f(0x2ed)][_0x13a99f(0x219)](_0x153ebf,_0x137fe7),'promote':(_0x276f4d,_0x4712c7)=>this[_0x13a99f(0x240)][_0x13a99f(0x25b)](_0x276f4d,_0x4712c7),'send':(_0x5bcaef,_0x50dff6)=>this[_0x13a99f(0x2d9)](_0x5bcaef,_0x50dff6),'emitItem':(_0x16c446,_0x1ecc3c)=>this[_0x13a99f(0x172)](_0x16c446,_0x1ecc3c),'syncTitle':(_0x12a838,_0x802628,_0x400f98)=>this[_0x13a99f(0x2ed)][_0x13a99f(0x2a9)](_0x12a838,_0x802628,_0x400f98),'setChannelToken':(_0x3dc066,_0x40a9c1)=>this[_0x13a99f(0x2bd)][_0x13a99f(0x1d7)](_0x3dc066,_0x40a9c1),'commandState':(_0x2cf4f4,_0x2d3dce)=>this[_0x13a99f(0x151)][_0x13a99f(0x1dd)](_0x2cf4f4,_0x2d3dce),'setCommandState':(_0x207ed9,_0x585c81)=>this[_0x13a99f(0x151)][_0x13a99f(0x2ae)](_0x207ed9,_0x585c81),'clearCommandState':(_0xd9e759,_0xd803e9)=>this[_0x13a99f(0x151)][_0x13a99f(0x17a)](_0xd9e759,_0xd803e9),'commandStates':_0x279dac=>this[_0x13a99f(0x151)][_0x13a99f(0x252)](_0x279dac)}),this[_0x13a99f(0x1ba)]=new RunnerRegistry([this[_0x13a99f(0x21e)],this[_0x13a99f(0x284)],this[_0x13a99f(0x291)],this[_0x13a99f(0x13e)],...this[_0x13a99f(0x21c)]===undefined?[]:[this[_0x13a99f(0x21c)]]]),this[_0x13a99f(0x2ed)]=new ManagedRunnerSessionService(this[_0x13a99f(0x2bd)],this[_0x13a99f(0x1ba)],_0x527488=>this[_0x13a99f(0x25c)]({'session':this[_0x13a99f(0x242)][_0x13a99f(0x278)](_0x527488)})),this[_0x13a99f(0x190)]=new RunnerInteractionService({'runtime':this[_0x13a99f(0x2bd)],'state':this[_0x13a99f(0x1ae)],'codex':()=>this[_0x13a99f(0x291)],'claude':()=>this[_0x13a99f(0x13e)],'runners':this[_0x13a99f(0x1ba)],'emitRun':(_0x2a2e28,_0xc47cbf,_0xaf3409,_0x4cbb57)=>this[_0x13a99f(0x1cc)][_0x13a99f(0x233)](_0x2a2e28,_0xc47cbf,_0xaf3409,_0x4cbb57),'emitItem':(_0x532808,_0x35d679)=>this[_0x13a99f(0x172)](_0x532808,_0x35d679),'approvalTimeoutMs':this[_0x13a99f(0x2de)],'publishApproval':_0x5c0a4c=>this[_0x13a99f(0x1cc)][_0x13a99f(0x137)](_0x5c0a4c)}),this[_0x13a99f(0x25f)]=new RunnerChannelMessageService({'interactions':this[_0x13a99f(0x190)],'send':(_0x147e85,_0x18af9c,_0x5948ce)=>this[_0x13a99f(0x2d9)](_0x147e85,_0x18af9c,_0x5948ce)}),this[_0x13a99f(0x242)]=new SessionPresentationService({'database':()=>this[_0x13a99f(0x185)],'runtime':this[_0x13a99f(0x2bd)],'commands':this[_0x13a99f(0x151)],'runners':this[_0x13a99f(0x1ba)],'capabilities':()=>this[_0x13a99f(0x21b)],'hasManagedActiveRun':_0x460ab5=>hasManagedActiveRun(this[_0x13a99f(0x2bd)],_0x460ab5),'externalActivity':_0x8e597=>this[_0x13a99f(0x295)][_0x13a99f(0x2c9)][_0x13a99f(0x1dd)](_0x8e597),'projectionForNative':_0x24fea3=>this[_0x13a99f(0x1bb)][_0x13a99f(0x1dc)](_0x24fea3)}),this[_0x13a99f(0x1bb)]=new NativeSessionProjectionService({'database':()=>this[_0x13a99f(0x185)],'nodeId':()=>this[_0x13a99f(0x1e7)]?.[_0x13a99f(0x25e)]??_0x13a99f(0x28f),'runtime':this[_0x13a99f(0x2bd)],'runners':this[_0x13a99f(0x1ba)],'capabilities':()=>this[_0x13a99f(0x21b)],'state':this[_0x13a99f(0x295)],'commands':this[_0x13a99f(0x151)],'present':_0xed7b69=>this[_0x13a99f(0x242)][_0x13a99f(0x278)](_0xed7b69)}),this[_0x13a99f(0x1d8)]=new ConversationHistoryService({'runtime':this[_0x13a99f(0x2bd)],'runners':this[_0x13a99f(0x1ba)],'capabilities':()=>this[_0x13a99f(0x21b)],'attachments':this[_0x13a99f(0x17f)],'snapshotSequence':()=>this[_0x13a99f(0x2f2)][_0x13a99f(0x2a3)](),'hasManagedActiveRun':_0x19a2d5=>hasManagedActiveRun(this[_0x13a99f(0x2bd)],_0x19a2d5),'setExternalActivity':(_0x24018c,_0x546244)=>this[_0x13a99f(0x295)][_0x13a99f(0x2c9)][_0x13a99f(0x2ae)](_0x24018c,_0x546244)}),this[_0x13a99f(0x187)]=new ConversationSegmentService((_0x3fa809,_0xbd6c1e)=>this[_0x13a99f(0x1d8)][_0x13a99f(0x16e)](_0x3fa809,_0xbd6c1e)),this[_0x13a99f(0x18e)]=new SessionContextService({'runners':this[_0x13a99f(0x1ba)],'session':_0x8a5ff6=>this[_0x13a99f(0x2bd)][_0x13a99f(0x20f)](_0x8a5ff6),'stopped':()=>this[_0x13a99f(0x1a0)],'publish':_0x35e331=>this[_0x13a99f(0x25c)](_0x35e331)}),this[_0x13a99f(0x2ec)]=new RunWorkbenchService({'runtime':this[_0x13a99f(0x2bd)],'readImage':async(_0xfd3715,_0x53063f)=>this[_0x13a99f(0x17f)][_0x13a99f(0x16e)](_0xfd3715,_0x53063f)??await this[_0x13a99f(0x17f)][_0x13a99f(0x2fe)](_0xfd3715,_0x53063f),'respondUserInput':(_0x17f992,_0x1add63,_0x1a93a5)=>this[_0x13a99f(0x190)][_0x13a99f(0x13c)](_0x17f992,_0x1add63,_0x1a93a5),'pauseQueue':_0xd94d8b=>this[_0x13a99f(0x153)][_0x13a99f(0x23d)](_0xd94d8b),'emitRun':(_0x42b0a3,_0x1548ab,_0x5564a1,_0x104149)=>this[_0x13a99f(0x1cc)][_0x13a99f(0x233)](_0x42b0a3,_0x1548ab,_0x5564a1,_0x104149),'control':(_0x37027f,_0x8bcc4)=>this[_0x13a99f(0x134)][_0x13a99f(0x1a2)](JSON[_0x13a99f(0x1ad)](createEnvelope(_0x37027f,_0x8bcc4))),'markInterrupted':_0xa8dc3=>this[_0x13a99f(0x1ae)][_0x13a99f(0x171)][_0x13a99f(0x204)](_0xa8dc3)}),this[_0x13a99f(0x27f)]=new SessionQueryService({'runtime':this[_0x13a99f(0x2bd)],'runners':this[_0x13a99f(0x1ba)],'resolve':_0x5c9346=>this[_0x13a99f(0x1bb)][_0x13a99f(0x14d)](_0x5c9346),'present':_0x571e3e=>this[_0x13a99f(0x242)][_0x13a99f(0x278)](_0x571e3e),'history':(_0x2beef9,_0x59e847)=>this[_0x13a99f(0x1d8)][_0x13a99f(0x16e)](_0x2beef9,_0x59e847),'segments':(_0x5d0212,_0x5f1c67)=>this[_0x13a99f(0x187)][_0x13a99f(0x16e)](_0x5d0212,_0x5f1c67),'context':this[_0x13a99f(0x18e)],'discover':(_0x30c03c,_0x27980f)=>this[_0x13a99f(0x1bb)][_0x13a99f(0x2b0)](_0x30c03c,_0x27980f),'workspaceIdForCwd':_0x55eb5c=>this[_0x13a99f(0x185)]?.[_0x13a99f(0x2ef)]()[_0x13a99f(0x1f9)](_0x57c5bb=>_0x57c5bb[_0x13a99f(0x225)]===_0x55eb5c)?.['id']}),this[_0x13a99f(0x26d)]=new ContinuousRunCoordinator({'runtime':this[_0x13a99f(0x2bd)],'emitQueue':(_0x1c285f,_0x133032)=>this[_0x13a99f(0x1cc)][_0x13a99f(0x2f8)](_0x1c285f,_0x133032),'clearImages':_0x3b9d8e=>this[_0x13a99f(0x17f)][_0x13a99f(0x17a)](_0x3b9d8e),'cleanupAttachments':_0x1fbd69=>this[_0x13a99f(0x17f)][_0x13a99f(0x26e)](_0x1fbd69),'migrateAssets':(_0x357bfd,_0x49853a)=>this[_0x13a99f(0x17f)][_0x13a99f(0x1d6)](_0x357bfd,_0x49853a),'emitRun':(_0x1133d8,_0x1f9a25,_0x2f6c35,_0x5df3a6)=>this[_0x13a99f(0x1cc)][_0x13a99f(0x233)](_0x1133d8,_0x1f9a25,_0x2f6c35,_0x5df3a6),'emitConversation':_0x4ee9ee=>this[_0x13a99f(0x22a)](_0x4ee9ee),'control':(_0x5792be,_0x3ce341)=>this[_0x13a99f(0x134)][_0x13a99f(0x1a2)](JSON[_0x13a99f(0x1ad)](createEnvelope(_0x5792be,_0x3ce341))),'stopped':()=>this[_0x13a99f(0x1a0)],'markInterrupted':_0x53c011=>this[_0x13a99f(0x1ae)][_0x13a99f(0x171)][_0x13a99f(0x204)](_0x53c011),'mcps':_0x34efa8=>this[_0x13a99f(0x185)]?.[_0x13a99f(0x1d1)](_0x34efa8)??[],'afterExecutionStarted':async _0x196fa1=>{const _0x46e0e4=_0x13a99f;if(_0x196fa1[_0x46e0e4(0x223)]===undefined)return;const _0x248b65=this[_0x46e0e4(0x1be)][_0x46e0e4(0x1dd)](_0x196fa1[_0x46e0e4(0x243)]);if(_0x248b65?.[_0x46e0e4(0x17c)]!==_0x46e0e4(0x152)||_0x248b65['id']!==_0x196fa1[_0x46e0e4(0x223)]['id']||_0x248b65[_0x46e0e4(0x22c)]!==_0x196fa1[_0x46e0e4(0x223)][_0x46e0e4(0x22c)])return;const _0x2c17de=this[_0x46e0e4(0x1be)][_0x46e0e4(0x178)](_0x196fa1[_0x46e0e4(0x243)]),_0x3d9bd7=this[_0x46e0e4(0x2bd)][_0x46e0e4(0x20f)](_0x196fa1[_0x46e0e4(0x243)]);if(_0x2c17de!==undefined&&_0x3d9bd7!==undefined)this[_0x46e0e4(0x235)](_0x3d9bd7,_0x2c17de);await this[_0x46e0e4(0x18d)]({'sessionId':_0x196fa1[_0x46e0e4(0x243)],'mission':{'id':_0x248b65['id'],'revision':_0x248b65[_0x46e0e4(0x22c)]},'secretEnvironment':_0x196fa1[_0x46e0e4(0x158)],..._0x196fa1[_0x46e0e4(0x21f)]===undefined?{}:{'personalInstructions':_0x196fa1[_0x46e0e4(0x21f)]},..._0x196fa1[_0x46e0e4(0x1ed)]===undefined?{}:{'marAgentModel':_0x196fa1[_0x46e0e4(0x1ed)]},..._0x196fa1[_0x46e0e4(0x2fd)]===undefined?{}:{'marAgentModels':_0x196fa1[_0x46e0e4(0x2fd)]},..._0x196fa1[_0x46e0e4(0x30b)]===undefined?{}:{'marAgentRuntimeScopeId':_0x196fa1[_0x46e0e4(0x30b)]}});},'missionMcp':async _0x4018ad=>{const _0x18a9fc=_0x13a99f;if(_0x4018ad[_0x18a9fc(0x223)]===undefined)throw new Error(_0x18a9fc(0x251));const _0x5a3d39=await this[_0x18a9fc(0x201)][_0x18a9fc(0x155)]({'executionId':_0x4018ad[_0x18a9fc(0x2b6)],'sessionId':_0x4018ad[_0x18a9fc(0x243)],'missionId':_0x4018ad[_0x18a9fc(0x223)]['id'],'revision':_0x4018ad[_0x18a9fc(0x223)][_0x18a9fc(0x22c)]});return{'installation':{'targetKind':_0x18a9fc(0x2bb),'targetId':_0x4018ad[_0x18a9fc(0x274)],'catalogEntryId':_0x18a9fc(0x181),'serverName':_0x18a9fc(0x1b9),'displayName':_0x18a9fc(0x28a),'version':_0x18a9fc(0x261),'enabled':!![],'runtime':{'transport':_0x18a9fc(0x140),'url':_0x18a9fc(0x188),'headers':{}},'configuration':_0x5a3d39[_0x18a9fc(0x155)],'installedAt':Date[_0x18a9fc(0x1e5)](),..._0x5a3d39[_0x18a9fc(0x155)]},'secrets':_0x5a3d39[_0x18a9fc(0x12a)]};}}),this[_0x13a99f(0x153)]=new WorkspaceQueueWorkbenchService({'runtime':this[_0x13a99f(0x2bd)],'coordinator':this[_0x13a99f(0x26d)],'emit':(_0x31ee36,_0x459388)=>this[_0x13a99f(0x1cc)][_0x13a99f(0x2f8)](_0x31ee36,_0x459388),'prepareInput':(_0x32abd7,_0x577c68,_0x5b7472)=>this[_0x13a99f(0x1ba)][_0x13a99f(0x1b8)](_0x32abd7)[_0x13a99f(0x221)](_0x577c68,_0x5b7472)}),this[_0x13a99f(0x240)]=new SessionIdentityService({'runtime':this[_0x13a99f(0x2bd)],'persist':(_0x523dac,_0x592b4b)=>{const _0x19f045=_0x13a99f;if(_0x523dac[_0x19f045(0x2d2)]===null||_0x523dac[_0x19f045(0x2e7)]===null||_0x523dac[_0x19f045(0x245)]===null)return;this[_0x19f045(0x185)]?.[_0x19f045(0x159)]({'runner':_0x523dac[_0x19f045(0x1fe)],'externalSessionId':_0x592b4b,'workspaceId':_0x523dac[_0x19f045(0x274)],'model':_0x523dac[_0x19f045(0x2d2)],'effort':_0x523dac[_0x19f045(0x2e7)],'access':_0x523dac[_0x19f045(0x245)]});},'migrateCommands':(_0x28a119,_0x288661)=>this[_0x13a99f(0x151)][_0x13a99f(0x2d7)](_0x28a119,_0x288661),'migrateMission':(_0xc8cb95,_0x30b6b2)=>{const _0xde529c=_0x13a99f;this[_0xde529c(0x1be)][_0xde529c(0x167)](_0xc8cb95,_0x30b6b2),this[_0xde529c(0x201)][_0xde529c(0x167)](_0xc8cb95,_0x30b6b2);const _0x4852ed=this[_0xde529c(0x2cb)][_0xde529c(0x1dd)](_0xc8cb95);_0x4852ed!==undefined&&(this[_0xde529c(0x2cb)][_0xde529c(0x168)](_0xc8cb95),_0x4852ed[_0xde529c(0x243)]=_0x30b6b2,this[_0xde529c(0x2cb)][_0xde529c(0x2ae)](_0x30b6b2,_0x4852ed));const _0x20d2d5=this[_0xde529c(0x15f)][_0xde529c(0x1dd)](_0xc8cb95);_0x20d2d5!==undefined&&(this[_0xde529c(0x15f)][_0xde529c(0x168)](_0xc8cb95),this[_0xde529c(0x15f)][_0xde529c(0x2ae)](_0x30b6b2,_0x20d2d5));},'migrateQueue':(_0x1f3728,_0x4f1719)=>this[_0x13a99f(0x26d)][_0x13a99f(0x167)](_0x1f3728,_0x4f1719),'migrateRunnerState':(_0x4b299c,_0x480bc7)=>this[_0x13a99f(0x1cc)][_0x13a99f(0x1ef)](_0x4b299c,_0x480bc7),'emitSession':_0x349cfe=>this[_0x13a99f(0x25c)]({'session':_0x349cfe}),'emitRun':_0x3ce9e9=>this[_0x13a99f(0x2a7)](_0x13a99f(0x1df),{'run':_0x3ce9e9}),'emitQueue':_0x1b2c5c=>this[_0x13a99f(0x26d)][_0x13a99f(0x264)](_0x1b2c5c),'emitTurn':_0x59704a=>this[_0x13a99f(0x22a)](_0x59704a)}),this[_0x13a99f(0x1c9)]=new SessionLifecycleService({'database':()=>{const _0x1c4452=_0x13a99f;if(this[_0x1c4452(0x185)]===undefined)throw new Error(_0x1c4452(0x14e));return this[_0x1c4452(0x185)];},'runtime':this[_0x13a99f(0x2bd)],'runners':this[_0x13a99f(0x1ba)],'projection':this[_0x13a99f(0x1bb)],'identity':this[_0x13a99f(0x240)],'present':_0x2c0f00=>this[_0x13a99f(0x242)][_0x13a99f(0x278)](_0x2c0f00),'emitSession':_0xa5bd32=>this[_0x13a99f(0x25c)]({'session':this[_0x13a99f(0x242)][_0x13a99f(0x278)](_0xa5bd32)}),'execute':(_0xc7cbf0,_0x3bf835)=>this[_0x13a99f(0x281)](_0xc7cbf0,_0x3bf835),'interceptedSessionId':_0x558d12=>this[_0x13a99f(0x21c)]===undefined?undefined:_0x13a99f(0x228)+_0x558d12}),this[_0x13a99f(0x1f2)]=new ExternalSessionResumeService({'runtime':this[_0x13a99f(0x2bd)],'runners':this[_0x13a99f(0x1ba)],'state':this[_0x13a99f(0x295)],'available':_0x3df02e=>this[_0x13a99f(0x1ba)][_0x13a99f(0x1b8)](_0x3df02e)[_0x13a99f(0x14c)](this[_0x13a99f(0x21b)]),'projectionFor':_0x1227de=>this[_0x13a99f(0x1bb)][_0x13a99f(0x1dc)](_0x1227de),'managedAliasFor':_0x4d8f03=>this[_0x13a99f(0x1bb)][_0x13a99f(0x2f7)](_0x4d8f03),'ensureConfiguration':_0xa6ea9a=>this[_0x13a99f(0x1bb)][_0x13a99f(0x267)](_0xa6ea9a),'configuration':_0x1db806=>this[_0x13a99f(0x1bb)][_0x13a99f(0x297)](_0x1db806),'workspacePath':_0x19ea46=>this[_0x13a99f(0x185)]?.[_0x13a99f(0x2cf)](_0x19ea46)?.[_0x13a99f(0x225)],'rememberNative':(_0x553287,_0xa76b6a)=>this[_0x13a99f(0x2ed)][_0x13a99f(0x219)](_0x553287,_0xa76b6a),'stage':_0x58f458=>{const _0x219b0c=_0x13a99f,_0x5a1da0=this[_0x219b0c(0x1bb)][_0x219b0c(0x297)](_0x58f458);return this[_0x219b0c(0x2bd)][_0x219b0c(0x1ff)]({'workspaceId':_0x58f458[_0x219b0c(0x274)],'runner':_0x58f458[_0x219b0c(0x1fe)],'externalSessionId':_0x58f458[_0x219b0c(0x2e8)]??_0x58f458['id'],'nativeControl':_0x219b0c(0x279),'cwd':_0x58f458[_0x219b0c(0x28c)],'model':_0x5a1da0[_0x219b0c(0x2d2)],'effort':_0x5a1da0[_0x219b0c(0x2e7)],'access':_0x5a1da0[_0x219b0c(0x245)],..._0x58f458[_0x219b0c(0x1fa)]===null?{}:{'title':_0x58f458[_0x219b0c(0x1fa)]},..._0x58f458[_0x219b0c(0x2b5)]===null?{}:{'customTitle':_0x58f458[_0x219b0c(0x2b5)]}});},'resolve':_0xd0920c=>this[_0x13a99f(0x1bb)][_0x13a99f(0x14d)](_0xd0920c)}),this[_0x13a99f(0x1c7)]=new SessionCommandService({'runtime':this[_0x13a99f(0x2bd)],'runners':this[_0x13a99f(0x1ba)],'projection':this[_0x13a99f(0x1bb)],'resume':this[_0x13a99f(0x1f2)],'profiles':()=>this[_0x13a99f(0x2b3)][_0x13a99f(0x192)](),'present':_0x2f576f=>this[_0x13a99f(0x242)][_0x13a99f(0x278)](_0x2f576f),'resumeQueueAfterCommandRun':_0x43ed2a=>this[_0x13a99f(0x153)][_0x13a99f(0x255)](_0x43ed2a),'beginMission':_0xbd4437=>{const _0x5efb39=_0x13a99f,_0x12e192=this[_0x5efb39(0x151)][_0x5efb39(0x1dd)](_0xbd4437['id'],_0x5efb39(0x223));if(_0x12e192?.[_0x5efb39(0x152)]===!![])return{'session':this[_0x5efb39(0x242)][_0x5efb39(0x278)](_0xbd4437),'missionAlreadyActive':!![]};_0x12e192!==undefined&&(this[_0x5efb39(0x1be)][_0x5efb39(0x17a)](_0xbd4437['id']),this[_0x5efb39(0x151)][_0x5efb39(0x17a)](_0xbd4437['id'],_0x5efb39(0x223)));const _0x5594ca=this[_0x5efb39(0x2bf)](_0xbd4437);return this[_0x5efb39(0x26d)][_0x5efb39(0x259)](_0xbd4437['id']),this[_0x5efb39(0x151)][_0x5efb39(0x2ae)](_0xbd4437['id'],this[_0x5efb39(0x127)]()),this[_0x5efb39(0x2a7)](_0x5efb39(0x1cb),{'session':this[_0x5efb39(0x242)][_0x5efb39(0x278)](_0x5594ca[_0x5efb39(0x1cb)])}),{'session':this[_0x5efb39(0x242)][_0x5efb39(0x278)](_0x5594ca[_0x5efb39(0x1cb)]),'missionAccessChanged':_0x5594ca[_0x5efb39(0x148)]};},'mission':async({session:_0x3dbb27,objective:_0x235c24,secretEnvironment:_0x5698cc,personalInstructions:_0x590bc1,marAgentModel:_0x78eafb,marAgentModels:_0xed15fe,marAgentRuntimeScopeId:_0x577b35})=>{const _0x4d684a=_0x13a99f;this[_0x4d684a(0x196)](_0x3dbb27['id']);const _0x563e01=this[_0x4d684a(0x2bf)](_0x3dbb27),_0x1eed4e=_0x563e01[_0x4d684a(0x1cb)],_0x149730=this[_0x4d684a(0x1be)][_0x4d684a(0x1dd)](_0x3dbb27['id'])?.[_0x4d684a(0x17c)]===_0x4d684a(0x152);this[_0x4d684a(0x26d)][_0x4d684a(0x263)](_0x3dbb27['id']);const _0x22208f=this[_0x4d684a(0x1be)][_0x4d684a(0x165)](_0x3dbb27['id'],_0x235c24);this[_0x4d684a(0x235)](_0x1eed4e,_0x22208f);const _0x43c4a8=await this[_0x4d684a(0x2ba)][_0x4d684a(0x205)]({'sessionId':_0x3dbb27['id'],'kind':_0x4d684a(0x165),'content':this[_0x4d684a(0x1be)][_0x4d684a(0x1a6)](_0x3dbb27['id'],_0x4d684a(0x165)),'deliveryIntent':_0x149730?_0x4d684a(0x1e4):_0x4d684a(0x1d3),'mission':{'id':_0x22208f['id'],'revision':_0x22208f[_0x4d684a(0x22c)]},'secretEnvironment':_0x5698cc,..._0x590bc1===undefined?{}:{'personalInstructions':_0x590bc1},..._0x78eafb===undefined?{}:{'marAgentModel':_0x78eafb},..._0xed15fe===undefined?{}:{'marAgentModels':_0xed15fe},..._0x577b35===undefined?{}:{'marAgentRuntimeScopeId':_0x577b35}});return{...isPlainRecord(_0x43c4a8)?_0x43c4a8:{'result':_0x43c4a8},'missionAccessChanged':_0x563e01[_0x4d684a(0x148)]};},'clearMission':_0x62eb1a=>{const _0x3ba50d=_0x13a99f;return this[_0x3ba50d(0x196)](_0x62eb1a['id']),this[_0x3ba50d(0x1be)][_0x3ba50d(0x17a)](_0x62eb1a['id']),this[_0x3ba50d(0x26d)][_0x3ba50d(0x263)](_0x62eb1a['id']),this[_0x3ba50d(0x150)](_0x62eb1a['id'],_0x3ba50d(0x300)),this[_0x3ba50d(0x151)][_0x3ba50d(0x17a)](_0x62eb1a['id'],_0x3ba50d(0x223)),this[_0x3ba50d(0x2a7)](_0x3ba50d(0x1cb),{'session':this[_0x3ba50d(0x242)][_0x3ba50d(0x278)](_0x62eb1a)}),{'session':this[_0x3ba50d(0x242)][_0x3ba50d(0x278)](_0x62eb1a),'cleared':!![]};}}),this[_0x13a99f(0x2ba)]=new SessionMessageService({'runtime':this[_0x13a99f(0x2bd)],'uploads':this[_0x13a99f(0x306)],'attachments':this[_0x13a99f(0x17f)],'commands':this[_0x13a99f(0x151)],'coordinator':this[_0x13a99f(0x26d)],'runners':this[_0x13a99f(0x1ba)],'resolve':_0x5f2764=>this[_0x13a99f(0x1f2)][_0x13a99f(0x197)](_0x5f2764),'present':_0xaf1743=>this[_0x13a99f(0x242)][_0x13a99f(0x278)](_0xaf1743),'emitSession':_0x4a4e6a=>this[_0x13a99f(0x25c)]({'session':this[_0x13a99f(0x242)][_0x13a99f(0x278)](_0x4a4e6a)}),'channelToken':_0x4d39a7=>{const _0x50d447=_0x13a99f,_0x3b8946=this[_0x50d447(0x2bd)][_0x50d447(0x20f)](_0x4d39a7);return _0x3b8946?.[_0x50d447(0x282)]??undefined;},'missionMessage':(_0x4abe2c,_0x174b5f)=>{const _0x105e47=_0x13a99f,_0x206afd=this[_0x105e47(0x151)][_0x105e47(0x1dd)](_0x4abe2c['id'],_0x105e47(0x223));if(_0x206afd?.[_0x105e47(0x152)]!==!![])return undefined;const _0x2601fc=this[_0x105e47(0x1be)][_0x105e47(0x1dd)](_0x4abe2c['id']);if(_0x2601fc?.[_0x105e47(0x17c)]===_0x105e47(0x152))return{'runnerContent':_0x174b5f,'mission':{'id':_0x2601fc['id'],'revision':_0x2601fc[_0x105e47(0x22c)]},'activated':![]};const _0x517491=this[_0x105e47(0x1be)][_0x105e47(0x165)](_0x4abe2c['id'],_0x174b5f);return this[_0x105e47(0x235)](_0x4abe2c,_0x517491),{'runnerContent':this[_0x105e47(0x1be)][_0x105e47(0x1a6)](_0x4abe2c['id'],_0x105e47(0x165)),'mission':{'id':_0x517491['id'],'revision':_0x517491[_0x105e47(0x22c)]},'activated':!![]};},'prepareMissionInsertion':(_0x5032d3,_0x4b8d7)=>this[_0x13a99f(0x26d)][_0x13a99f(0x259)](_0x5032d3,_0x4b8d7),'missionPreparationFailed':(_0x5033fe,_0x5569e7,_0x146ff2)=>{const _0x110326=_0x13a99f;if(!_0x146ff2)return;const _0x116105=this[_0x110326(0x1be)][_0x110326(0x1dd)](_0x5033fe['id']);if(_0x116105?.['id']!==_0x5569e7['id']||_0x116105[_0x110326(0x22c)]!==_0x5569e7[_0x110326(0x22c)])return;this[_0x110326(0x1be)][_0x110326(0x17a)](_0x5033fe['id']),this[_0x110326(0x150)](_0x5033fe['id'],_0x110326(0x2a5)),this[_0x110326(0x151)][_0x110326(0x2ae)](_0x5033fe['id'],this[_0x110326(0x127)]()),this[_0x110326(0x2a7)](_0x110326(0x1cb),{'session':this[_0x110326(0x242)][_0x110326(0x278)](_0x5033fe)});}}),this[_0x13a99f(0x309)]=new SessionCatalogService({'database':()=>{const _0x142cc4=_0x13a99f;if(this[_0x142cc4(0x185)]===undefined)throw new Error(_0x142cc4(0x14e));return this[_0x142cc4(0x185)];},'nodeId':()=>this[_0x13a99f(0x1e7)]?.[_0x13a99f(0x25e)]??_0x13a99f(0x28f),'runtime':this[_0x13a99f(0x2bd)],'runners':this[_0x13a99f(0x1ba)],'projection':this[_0x13a99f(0x1bb)],'resume':this[_0x13a99f(0x1f2)],'cachedNative':()=>[...this[_0x13a99f(0x295)][_0x13a99f(0x14f)][_0x13a99f(0x1db)]()],'cachedWorkspace':_0x57e640=>this[_0x13a99f(0x244)][_0x13a99f(0x2bc)](_0x57e640),'discoverWorkspace':_0x360aef=>this[_0x13a99f(0x1bb)][_0x13a99f(0x203)](_0x360aef),'present':_0x278581=>this[_0x13a99f(0x242)][_0x13a99f(0x278)](_0x278581),'projectionForNative':_0x48f8b9=>this[_0x13a99f(0x1bb)][_0x13a99f(0x1dc)](_0x48f8b9),'nativeIds':_0x57b581=>this[_0x13a99f(0x1bb)][_0x13a99f(0x173)](_0x57b581),'forget':(_0x46be4c,_0x23751f)=>this[_0x13a99f(0x1bb)][_0x13a99f(0x2b2)](_0x46be4c,_0x23751f),'refreshActivity':_0xe48506=>this[_0x13a99f(0x1d8)][_0x13a99f(0x2e1)](_0xe48506),'externalActivity':_0x45aedf=>this[_0x13a99f(0x295)][_0x13a99f(0x2c9)][_0x13a99f(0x1dd)](_0x45aedf),'isWatching':_0x383350=>this[_0x13a99f(0x30a)][_0x13a99f(0x20e)](_0x383350),'history':(_0x3b0b31,_0x15cf39)=>this[_0x13a99f(0x1d8)][_0x13a99f(0x16e)](_0x3b0b31,_0x15cf39),'invalidateHistory':_0xc26dd=>this[_0x13a99f(0x30a)][_0x13a99f(0x2f6)](_0xc26dd),'invalidateWorkspaceSessions':_0x558cb2=>{const _0x5785af=_0x13a99f;this[_0x5785af(0x1c0)][_0x5785af(0x169)](_0x558cb2),void this[_0x5785af(0x26b)]?.[_0x5785af(0x1d5)](_0x558cb2,_0x5785af(0x2b1));},'emitSession':_0x4f8358=>this[_0x13a99f(0x25c)]({'session':this[_0x13a99f(0x242)][_0x13a99f(0x278)](_0x4f8358)})}),this[_0x13a99f(0x291)][_0x13a99f(0x276)]({'start':_0x5924c1=>this[_0x13a99f(0x13b)][_0x13a99f(0x165)](_0x5924c1),'cancel':(_0x259a1c,_0x230f6e)=>{const _0x4d6889=_0x13a99f,_0x6ec674=this[_0x4d6889(0x291)][_0x4d6889(0x29a)][_0x4d6889(0x16f)][_0x4d6889(0x1dd)](_0x259a1c);if(_0x6ec674?.[_0x4d6889(0x2a8)]===undefined)return![];return void this[_0x4d6889(0x190)][_0x4d6889(0x2c8)](_0x259a1c,_0x6ec674[_0x4d6889(0x186)],_0x6ec674[_0x4d6889(0x2a8)],_0x6ec674[_0x4d6889(0x28c)],_0x230f6e===_0x4d6889(0x16b)?_0x4d6889(0x13f):_0x4d6889(0x2b4)),!![];},'decideApproval':_0x5dee91=>this[_0x13a99f(0x190)][_0x13a99f(0x184)](_0x5dee91[_0x13a99f(0x135)],_0x5dee91[_0x13a99f(0x210)])}),this[_0x13a99f(0x13e)][_0x13a99f(0x276)]({'start':_0x2540a0=>this[_0x13a99f(0x2df)][_0x13a99f(0x165)](_0x2540a0),'cancel':(_0x49cd15,_0x4a3b25)=>this[_0x13a99f(0x190)][_0x13a99f(0x1ca)](_0x49cd15,_0x4a3b25),'decideApproval':_0x300412=>this[_0x13a99f(0x190)][_0x13a99f(0x15b)](_0x300412[_0x13a99f(0x135)],_0x300412[_0x13a99f(0x210)])}),this[_0x13a99f(0x21e)][_0x13a99f(0x276)]({'start':_0x571e6c=>this[_0x13a99f(0x268)][_0x13a99f(0x165)](_0x571e6c),'cancel':(_0x22671f,_0x43baa7)=>this[_0x13a99f(0x268)][_0x13a99f(0x2b8)](_0x22671f,_0x43baa7),'decideApproval':_0x27201e=>this[_0x13a99f(0x268)][_0x13a99f(0x182)](_0x27201e),'respondUserInput':(_0x2f89d1,_0x3121a0,_0x3e6dd0)=>this[_0x13a99f(0x268)][_0x13a99f(0x13c)](_0x2f89d1,_0x3121a0,_0x3e6dd0)}),this[_0x13a99f(0x284)][_0x13a99f(0x276)]({'start':_0x318d26=>this[_0x13a99f(0x131)][_0x13a99f(0x165)](_0x318d26),'cancel':(_0x426c6b,_0x4b63e3)=>this[_0x13a99f(0x131)][_0x13a99f(0x2b8)](_0x426c6b,_0x4b63e3),'decideApproval':_0x284c0e=>this[_0x13a99f(0x131)][_0x13a99f(0x182)](_0x284c0e),'respondUserInput':(_0x2504b1,_0x4b2ccd,_0x2ccb00)=>this[_0x13a99f(0x131)][_0x13a99f(0x13c)](_0x2504b1,_0x4b2ccd,_0x2ccb00)}),this[_0x13a99f(0x291)][_0x13a99f(0x29d)]({'execute':(_0xde5c78,_0x15e563,_0x4a1dd3,_0x55d196)=>this[_0x13a99f(0x13b)][_0x13a99f(0x27d)](_0xde5c78,_0x15e563,_0x4a1dd3,_0x55d196)}),this[_0x13a99f(0x13e)][_0x13a99f(0x29d)]({'execute':(_0x4619b5,_0x52f48f,_0x21f077,_0xa8e514)=>this[_0x13a99f(0x2df)][_0x13a99f(0x27d)](_0x4619b5,_0x52f48f,_0x21f077,_0xa8e514)}),this[_0x13a99f(0x21e)][_0x13a99f(0x29d)]({'execute':(_0x2157e6,_0x1d77fc,_0x31502f,_0x3c0775)=>this[_0x13a99f(0x268)][_0x13a99f(0x27d)](_0x2157e6,_0x1d77fc,_0x3c0775)}),this[_0x13a99f(0x284)][_0x13a99f(0x29d)]({'execute':(_0x37916b,_0x3fdc8c,_0x5d32e7,_0xd01e08)=>this[_0x13a99f(0x131)][_0x13a99f(0x27d)](_0x37916b,_0x3fdc8c,_0x5d32e7,_0xd01e08)});const _0x2f1b69=this[_0x13a99f(0x21c)]===undefined||this[_0x13a99f(0x1e1)]===undefined?undefined:new FakeManagedRunService({'runner':this[_0x13a99f(0x21c)],'script':this[_0x13a99f(0x1e1)],'runners':this[_0x13a99f(0x1ba)],'runtime':this[_0x13a99f(0x2bd)],'state':this[_0x13a99f(0x1ae)],'emitRun':(_0x5a6b83,_0x52f680,_0x68639e,_0x1f4b39)=>this[_0x13a99f(0x1cc)][_0x13a99f(0x233)](_0x5a6b83,_0x52f680,_0x68639e,_0x1f4b39),'publishApproval':_0xa0a56e=>this[_0x13a99f(0x1cc)][_0x13a99f(0x137)](_0xa0a56e),'disconnect':()=>this[_0x13a99f(0x12f)][_0x13a99f(0x206)](0x2409+-0x1*0x21+-0x143e,_0x13a99f(0x13d))});this[_0x13a99f(0x21c)]?.[_0x13a99f(0x276)]({'start':_0x4cb4b2=>_0x2f1b69?.[_0x13a99f(0x165)](_0x4cb4b2),'cancel':(_0x283b67,_0x435884)=>_0x435884===_0x13a99f(0x16b)?this[_0x13a99f(0x21c)]?.[_0x13a99f(0x2b8)](_0x283b67)??![]:this[_0x13a99f(0x21c)]?.[_0x13a99f(0x1e6)](_0x283b67)??![],'decideApproval':_0x446f9a=>this[_0x13a99f(0x21c)]?.[_0x13a99f(0x132)](_0x446f9a[_0x13a99f(0x2b6)],_0x446f9a[_0x13a99f(0x135)],_0x446f9a[_0x13a99f(0x210)])??![]}),this[_0x13a99f(0x23b)]=_0x1a4902[_0x13a99f(0x23b)]??new RunnerUsageReader(),this[_0x13a99f(0x185)]=_0x1a4902[_0x13a99f(0x185)],this[_0x13a99f(0x273)]=_0x1a4902[_0x13a99f(0x273)]??new TerminalManager({'platform':this[_0x13a99f(0x21b)][_0x13a99f(0x141)]===_0x13a99f(0x277)?_0x13a99f(0x22f):_0x13a99f(0x2c0)}),this[_0x13a99f(0x273)][_0x13a99f(0x2d5)](_0x31215a=>this[_0x13a99f(0x244)][_0x13a99f(0x22b)](_0x31215a)),this[_0x13a99f(0x23c)]=new NodeTerminalChannel({'config':()=>this[_0x13a99f(0x1e7)],'controlConnected':()=>this[_0x13a99f(0x12f)][_0x13a99f(0x1bd)](),'stopped':()=>this[_0x13a99f(0x1a0)],'reconnect':this[_0x13a99f(0x12e)],'reconnectDelay':nextReconnectDelay,'manager':this[_0x13a99f(0x273)]}),this[_0x13a99f(0x12f)]=new NodeControlChannel({'config':()=>this[_0x13a99f(0x1e7)],'capabilities':()=>this[_0x13a99f(0x21b)],'stopped':()=>this[_0x13a99f(0x1a0)],'reconnect':this[_0x13a99f(0x12e)],'reconnectDelay':nextReconnectDelay,'onConnecting':_0x1b721b=>{const _0x165bfe=_0x13a99f;this[_0x165bfe(0x1b3)][_0x165bfe(0x2d4)](),nodeLog(_0x165bfe(0x16d),{'attempt':_0x1b721b});},'onReconnectScheduled':()=>this[_0x13a99f(0x1b3)][_0x13a99f(0x2b9)](),'onMessage':_0x100de7=>this[_0x13a99f(0x29b)](_0x100de7),'onClose':(_0x49d280,_0xc81381)=>{const _0x5ad4c5=_0x13a99f;this[_0x5ad4c5(0x164)][_0x5ad4c5(0x269)](),this[_0x5ad4c5(0x23c)][_0x5ad4c5(0x2d3)]();if(_0x49d280===-0x1e*0x9d+-0x1*0x1401+-0x1*-0x3607&&_0xc81381===_0x5ad4c5(0x21a))nodeLog(_0x5ad4c5(0x288),{'message':_0x5ad4c5(0x232)});if(_0x49d280===-0x13*-0x9d+-0x8e0+0xcdc||_0x49d280===0x2*-0x1373+0xde*-0x8+0x31bf)void this[_0x5ad4c5(0x273)][_0x5ad4c5(0x174)]();}}),this[_0x13a99f(0x134)]=new NodeControlMessageService({'config':()=>this[_0x13a99f(0x1e7)],'register':(_0x4a9b6d,_0x37cdad)=>this[_0x13a99f(0x2aa)][_0x13a99f(0x215)](_0x4a9b6d,_0x37cdad),'connected':()=>this[_0x13a99f(0x2aa)][_0x13a99f(0x1bd)](),'close':(_0x52f9c6,_0x2d61c4)=>this[_0x13a99f(0x12f)][_0x13a99f(0x206)](_0x52f9c6,_0x2d61c4),'inspectWorkspace':_0x4e026d=>this[_0x13a99f(0x244)][_0x13a99f(0x20d)](_0x4e026d),'handleNodeRequest':_0x49ab3d=>this[_0x13a99f(0x2f4)][_0x13a99f(0x1a2)](_0x49ab3d),'handleRuntimeCredentialResponse':_0x1c041d=>this[_0x13a99f(0x164)][_0x13a99f(0x1a2)](_0x1c041d),'reconcileRuns':_0x15dc90=>this[_0x13a99f(0x1cc)][_0x13a99f(0x236)](_0x15dc90),'runners':this[_0x13a99f(0x1ba)],'deliverSessionChannelMessage':_0x4d4f34=>this[_0x13a99f(0x25f)][_0x13a99f(0x1a2)](_0x4d4f34),'completeUncontrolledCancellation':_0xc49832=>{const _0x3d7583=_0x13a99f,_0x440463=this[_0x3d7583(0x2bd)][_0x3d7583(0x138)](_0xc49832);if(_0x440463?.[_0x3d7583(0x17c)]===_0x3d7583(0x262))this[_0x3d7583(0x190)][_0x3d7583(0x214)](_0xc49832);},'send':(_0x2466d7,_0x514358,_0x3ee621)=>this[_0x13a99f(0x2d9)](_0x2466d7,_0x514358,_0x3ee621)}),this[_0x13a99f(0x2f4)]=new NodeRequestService({'nodeId':()=>this[_0x13a99f(0x1e7)]?.[_0x13a99f(0x25e)],'databaseAvailable':()=>this[_0x13a99f(0x185)]!==undefined,'execute':(_0x8d1c3e,_0x39b7b4)=>this[_0x13a99f(0x281)](_0x8d1c3e,_0x39b7b4),'send':(_0x5dc8d3,_0xbee1fc,_0x4178e5)=>this[_0x13a99f(0x2d9)](_0x5dc8d3,_0xbee1fc,_0x4178e5)}),this[_0x13a99f(0x244)]=new NodeWorkspaceCoordinator({'config':()=>this[_0x13a99f(0x1e7)],'database':()=>this[_0x13a99f(0x185)],'watches':this[_0x13a99f(0x265)],'sessions':this[_0x13a99f(0x1c0)],'changes':this[_0x13a99f(0x1b0)],'emit':(_0x238c41,_0x3aeda6)=>void this[_0x13a99f(0x26b)]?.[_0x13a99f(0x1d5)](_0x238c41,_0x3aeda6),'send':(_0x383bb5,_0x594f23,_0x4e0620)=>this[_0x13a99f(0x2d9)](_0x383bb5,_0x594f23,_0x4e0620)}),this[_0x13a99f(0x1cc)]=new NodeRunEventBridge({'runtime':this[_0x13a99f(0x2bd)],'state':this[_0x13a99f(0x1ae)],'events':this[_0x13a99f(0x302)],'emitWorkbench':(_0x5db45a,_0x5f5dd7)=>this[_0x13a99f(0x2f0)](_0x5db45a,_0x5f5dd7),'queues':this[_0x13a99f(0x153)],'codex':this[_0x13a99f(0x291)],'claude':this[_0x13a99f(0x13e)],'openCode':this[_0x13a99f(0x21e)],'send':(_0x52ec14,_0x38536d,_0x17a0b7)=>this[_0x13a99f(0x2d9)](_0x52ec14,_0x38536d,_0x17a0b7)}),this[_0x13a99f(0x2aa)]=new NodeConnectionLifecycleService({'config':()=>this[_0x13a99f(0x1e7)],'setConfig':_0x1c47a8=>this[_0x13a99f(0x1e7)]=_0x1c47a8,'configPath':this[_0x13a99f(0x2b7)],'capabilities':()=>this[_0x13a99f(0x21b)],'detectCapabilities':this[_0x13a99f(0x1af)],'capabilitiesProvided':this[_0x13a99f(0x1cd)],'stopped':()=>this[_0x13a99f(0x1a0)],'setCapabilities':_0x122ff5=>this[_0x13a99f(0x21b)]={..._0x122ff5,'metadata':upgradeMetadata(_0x122ff5[_0x13a99f(0x24b)],this[_0x13a99f(0x29c)][_0x13a99f(0x1c3)]())},'control':this[_0x13a99f(0x12f)],'terminal':this[_0x13a99f(0x23c)],'metrics':this[_0x13a99f(0x1b3)],'heartbeatMs':HEARTBEAT_MS,'refreshMs':CAPABILITY_REFRESH_MS,'onRegistered':()=>this[_0x13a99f(0x2a4)](),'onConnected':()=>{const _0x4464bf=_0x13a99f;this[_0x4464bf(0x164)][_0x4464bf(0x1bd)](),this[_0x4464bf(0x162)][_0x4464bf(0x2c1)]();}});const _0x160531=()=>{const _0x31402a=_0x13a99f;if(this[_0x31402a(0x185)]===undefined)throw new Error(_0x31402a(0x14e));return this[_0x31402a(0x185)];};this[_0x13a99f(0x2b3)]=new RunnerService(_0x160531,()=>this[_0x13a99f(0x21b)],this[_0x13a99f(0x1ba)],this[_0x13a99f(0x23b)]),this[_0x13a99f(0x142)]=new WorkbenchManifestService({'capabilities':()=>this[_0x13a99f(0x21b)],'runners':this[_0x13a99f(0x2b3)],'terminals':this[_0x13a99f(0x273)]}),this[_0x13a99f(0x1e9)]=new TerminalService(_0x160531,this[_0x13a99f(0x273)]),this[_0x13a99f(0x1f4)]=new WorkspaceService(_0x160531,()=>{const _0x3dba5c=_0x13a99f;if(this[_0x3dba5c(0x1e7)]===undefined)throw new Error(_0x3dba5c(0x1a7));return this[_0x3dba5c(0x1e7)];},this[_0x13a99f(0x2bd)],_0x491d99=>{const _0xb36f94=_0x13a99f;this[_0xb36f94(0x2a0)][_0xb36f94(0x189)](_0x491d99),this[_0xb36f94(0x244)][_0xb36f94(0x1fc)](_0x491d99),this[_0xb36f94(0x1c0)][_0xb36f94(0x2f6)](_0x491d99),this[_0xb36f94(0x244)][_0xb36f94(0x14b)](_0x491d99);}),this[_0x13a99f(0x26b)]=new WorkspaceWorkbenchService({'requireWorkspace':_0x431bca=>this[_0x13a99f(0x244)][_0x13a99f(0x1b8)](_0x431bca),'inspectWorkspace':_0x3459a2=>this[_0x13a99f(0x244)][_0x13a99f(0x14a)](_0x3459a2),'commitWorkspace':(_0x32d467,_0x306f6b)=>this[_0x13a99f(0x244)][_0x13a99f(0x2fa)](_0x32d467,_0x306f6b),'watch':this[_0x13a99f(0x265)],'files':this[_0x13a99f(0x2a0)],'uploads':this[_0x13a99f(0x306)],'changes':this[_0x13a99f(0x1b0)],'listSessions':_0x19d55f=>this[_0x13a99f(0x281)](_0x13a99f(0x166),{'workspaceId':_0x19d55f,'limit':0x14}),'invalidate':_0x42a6a1=>{const _0x16c1b9=_0x13a99f;this[_0x16c1b9(0x2a0)][_0x16c1b9(0x189)](_0x42a6a1),this[_0x16c1b9(0x244)][_0x16c1b9(0x2f6)](_0x42a6a1);},'nodeId':()=>this[_0x13a99f(0x1e7)]?.[_0x13a99f(0x25e)]??_0x13a99f(0x266),'nodeGeneration':()=>this[_0x13a99f(0x27a)],'emitWatchEvent':_0x25247b=>this[_0x13a99f(0x2d9)](_0x13a99f(0x294),_0x25247b)});for(const _0x210008 of CONVERSATION_TEMPLATE_OPERATIONS)this[_0x13a99f(0x194)][_0x13a99f(0x215)](_0x210008,_0x46af93=>{const _0x5cf782=_0x13a99f,_0x29bf84=this[_0x5cf782(0x1d9)]?.[_0x210008];if(_0x29bf84===undefined)throw new Error(_0x5cf782(0x271));return _0x29bf84(_0x46af93);});for(const _0x581723 of HOSTED_CONVERSATION_OPERATIONS)this[_0x13a99f(0x194)][_0x13a99f(0x215)](_0x581723,_0x18049d=>{const _0x116513=_0x13a99f,_0x441ab6=this[_0x116513(0x253)]?.[_0x581723];if(_0x441ab6===undefined)throw new Error(_0x116513(0x271));return _0x441ab6(_0x18049d);});for(const _0x52a646 of CONVERSATION_HOSTING_MAINTENANCE_OPERATIONS)this[_0x13a99f(0x194)][_0x13a99f(0x215)](_0x52a646,_0x102890=>{const _0x1cd341=_0x13a99f,_0x20055a=this[_0x1cd341(0x2a1)]?.[_0x52a646];if(_0x20055a===undefined)throw new Error(_0x1cd341(0x271));return _0x20055a(_0x102890);});this[_0x13a99f(0x194)][_0x13a99f(0x20b)](this[_0x13a99f(0x2b3)][_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](this[_0x13a99f(0x1e9)][_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](this[_0x13a99f(0x1f4)][_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](this[_0x13a99f(0x26b)][_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](this[_0x13a99f(0x2ec)][_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](this[_0x13a99f(0x30a)][_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](this[_0x13a99f(0x27f)][_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](this[_0x13a99f(0x1c9)][_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](this[_0x13a99f(0x2ba)][_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](this[_0x13a99f(0x309)][_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](this[_0x13a99f(0x1c7)][_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](this[_0x13a99f(0x153)][_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](this[_0x13a99f(0x2dd)][_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](new ConversationHostingEnablementService({'config':()=>this[_0x13a99f(0x1e7)],'setConfig':_0x3361a7=>this[_0x13a99f(0x1e7)]=_0x3361a7,'configPath':this[_0x13a99f(0x2b7)],'platform':()=>this[_0x13a99f(0x21b)][_0x13a99f(0x141)],'capability':()=>this[_0x13a99f(0x21b)][_0x13a99f(0x2ea)],'initialize':()=>this[_0x13a99f(0x2a4)](),'prepareForDisable':()=>this[_0x13a99f(0x129)]?.[_0x13a99f(0x1fd)]()??(()=>{}),'publishCapabilities':()=>this[_0x13a99f(0x2d9)](_0x13a99f(0x21b),this[_0x13a99f(0x21b)])})[_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](new SkillNodeOperationService(_0x160531,()=>{const _0x475236=_0x13a99f;if(this[_0x475236(0x1e7)]===undefined)throw new Error(_0x475236(0x1a7));return this[_0x475236(0x1e7)];})[_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x20b)](new McpNodeOperationService(_0x160531)[_0x13a99f(0x2c2)]()),this[_0x13a99f(0x194)][_0x13a99f(0x215)](_0x13a99f(0x144),()=>({'metrics':{...this[_0x13a99f(0x1b3)][_0x13a99f(0x1c3)](),'activeRuns':this[_0x13a99f(0x1ae)][_0x13a99f(0x152)][_0x13a99f(0x1a9)],'workspaceLeases':this[_0x13a99f(0x2bd)][_0x13a99f(0x1ac)]()}})),this[_0x13a99f(0x194)][_0x13a99f(0x215)](_0x13a99f(0x170),_0x3db199=>this[_0x13a99f(0x29c)][_0x13a99f(0x17d)](_0x3db199)),this[_0x13a99f(0x194)][_0x13a99f(0x215)](_0x13a99f(0x18f),()=>this[_0x13a99f(0x29c)][_0x13a99f(0x2b8)]()),this[_0x13a99f(0x194)][_0x13a99f(0x215)](_0x13a99f(0x1d2),async()=>({'manifest':await this[_0x13a99f(0x142)][_0x13a99f(0x16e)]()}));}async[_0x4ce2c3(0x2a4)](){const _0x38e137=_0x4ce2c3,_0xb5928a=this[_0x38e137(0x24c)],_0x402dd0=this[_0x38e137(0x129)],_0x7f6589=this[_0x38e137(0x2cc)];this[_0x38e137(0x24c)]=undefined,this[_0x38e137(0x129)]=undefined,this[_0x38e137(0x2cc)]=undefined,this[_0x38e137(0x253)]=undefined,this[_0x38e137(0x2a1)]=undefined,this[_0x38e137(0x1d9)]=undefined,this[_0x38e137(0x2f1)]=![],this[_0x38e137(0x2ab)]=undefined,await _0x7f6589?.[_0x38e137(0x189)](),_0x402dd0?.[_0x38e137(0x189)](),await _0xb5928a?.[_0x38e137(0x189)]()[_0x38e137(0x27b)](()=>undefined);const _0xc9c65b=this[_0x38e137(0x1e7)];if(_0xc9c65b?.[_0x38e137(0x2ea)]?.[_0x38e137(0x24d)]===!![]&&this[_0x38e137(0x21b)][_0x38e137(0x141)]===_0x38e137(0x2c0)){if(_0xc9c65b[_0x38e137(0x25e)]===undefined)this[_0x38e137(0x2ab)]=_0x38e137(0x16c);else{let _0x323592,_0x1a306b,_0x1f3a10;try{if(this[_0x38e137(0x185)]===undefined)throw new Error(_0x38e137(0x14e));const _0x303e84=hostedConversationStorePath(_0xc9c65b,this[_0x38e137(0x2b7)]);if(_0x303e84===undefined)throw new Error(_0x38e137(0x25a));const _0x534e0a=new HostedConversationStore({'dataDirectory':nodeDataDirectory(_0xc9c65b,this[_0x38e137(0x2b7)]),'rootDirectory':_0x303e84,'nodeId':_0xc9c65b[_0x38e137(0x25e)],'database':this[_0x38e137(0x185)]});await _0x534e0a[_0x38e137(0x13a)]();const _0xcbc6d0=new ConversationTemplateNodeService({'database':this[_0x38e137(0x185)],'store':_0x534e0a,'nodeId':()=>this[_0x38e137(0x1e7)]?.[_0x38e137(0x25e)]??_0x38e137(0x292)});await _0xcbc6d0[_0x38e137(0x1bc)](),await _0x534e0a[_0x38e137(0x1f5)](),_0x323592=new MarAgentHostedConversationRuntime({'webSearch':(_0x3d731b,_0x3bc599)=>this[_0x38e137(0x1b5)](_0x3d731b,_0x3bc599),'modelFactory':this[_0x38e137(0x179)],'registerNativeImages':(_0x175d1a,_0x395aa5,_0xc768d5)=>this[_0x38e137(0x17f)][_0x38e137(0x18c)](_0x175d1a,_0x395aa5,_0xc768d5,{'reuseCachedRunImages':![]})}),_0x1a306b=new HostedConversationNodeService({'database':this[_0x38e137(0x185)],'store':_0x534e0a,'runtime':_0x323592,'nodeId':()=>this[_0x38e137(0x1e7)]?.[_0x38e137(0x25e)]??_0x38e137(0x292),'nodeAppVersion':()=>this[_0x38e137(0x21b)][_0x38e137(0x226)]??_0x38e137(0x26c),'nodeGeneration':()=>this[_0x38e137(0x27a)],'sessionWatchSlots':this[_0x38e137(0x133)],'emitWatchEvent':_0x500bda=>this[_0x38e137(0x2d9)](_0x38e137(0x294),_0x500bda),'nextWorkbenchEvent':_0x1bf16f=>this[_0x38e137(0x2f2)][_0x38e137(0x2a2)](_0x38e137(0x213),_0x1bf16f),'emitWorkbenchEvent':_0x4e6994=>this[_0x38e137(0x2f2)][_0x38e137(0x264)](_0x4e6994),'readImage':async(_0x3d7ca0,_0x43d6f4)=>this[_0x38e137(0x17f)][_0x38e137(0x16e)](_0x3d7ca0,_0x43d6f4)??await this[_0x38e137(0x17f)][_0x38e137(0x2fe)](_0x3d7ca0,_0x43d6f4),'processExecutorFactory':_0x2cfd4b=>new BubblewrapSandboxExecutor(_0x2cfd4b),'assertCanCreate':()=>{const _0x579429=_0x38e137;if(_0x1f3a10===undefined)throw new Error(_0x579429(0x271));return _0x1f3a10[_0x579429(0x304)]();}}),_0x1f3a10=new ConversationHostingMaintenanceService({'store':_0x534e0a,'inactiveRetentionDays':_0xc9c65b[_0x38e137(0x2ea)][_0x38e137(0x12d)]??-0x1*-0x1767+-0x1f00+-0x1*-0x7d5,'isConversationInUse':_0x307195=>_0x1a306b?.[_0x38e137(0x286)](_0x307195)??!![],'beginConversationCleanup':_0x5305b5=>_0x1a306b?.[_0x38e137(0x183)](_0x5305b5),'releaseConversation':_0x3c7722=>{const _0x3a4438=_0x38e137;if(_0x1a306b===undefined)throw new Error(_0x3a4438(0x271));return _0x1a306b[_0x3a4438(0x1ec)](_0x3c7722);},'onAutomaticCleanupError':_0x5249dc=>nodeLog(_0x38e137(0x139),{'nodeId':_0xc9c65b[_0x38e137(0x25e)],'code':safeErrorCode(_0x5249dc,_0x38e137(0x2fb))})}),this[_0x38e137(0x1d9)]=_0xcbc6d0[_0x38e137(0x2c2)](),this[_0x38e137(0x253)]=_0x1a306b[_0x38e137(0x2c2)](),this[_0x38e137(0x2a1)]=_0x1f3a10[_0x38e137(0x2c2)](),this[_0x38e137(0x24c)]=_0x323592,this[_0x38e137(0x129)]=_0x1a306b,this[_0x38e137(0x2cc)]=_0x1f3a10,await _0x1f3a10[_0x38e137(0x165)](),this[_0x38e137(0x2f1)]=!![];}catch(_0x250df3){await _0x1f3a10?.[_0x38e137(0x189)](),_0x1a306b?.[_0x38e137(0x189)](),await _0x323592?.[_0x38e137(0x189)]()[_0x38e137(0x27b)](()=>undefined),this[_0x38e137(0x2ab)]=safeErrorCode(_0x250df3,_0x38e137(0x1d4)),nodeLog(_0x38e137(0x1de),{'nodeId':_0xc9c65b[_0x38e137(0x25e)],'code':this[_0x38e137(0x2ab)]});}}}this[_0x38e137(0x21b)]=await this[_0x38e137(0x17e)](this[_0x38e137(0x21b)]);}async[_0x4ce2c3(0x17e)](_0x1757b0){const _0x3ff65a=_0x4ce2c3;let _0x13e458=this[_0x3ff65a(0x2f1)],_0x5750a0=this[_0x3ff65a(0x2ab)],_0x12aec=_0x3ff65a(0x296);if(_0x13e458&&this[_0x3ff65a(0x2cc)]!==undefined)try{_0x12aec=(await this[_0x3ff65a(0x2cc)][_0x3ff65a(0x19b)]())[_0x3ff65a(0x24f)];}catch(_0x108b89){_0x13e458=![],_0x5750a0=safeErrorCode(_0x108b89,_0x3ff65a(0x25a));}return{..._0x1757b0,'conversationHosting':await conversationHostingCapability(_0x1757b0,this[_0x3ff65a(0x1e7)],_0x13e458,_0x5750a0,this[_0x3ff65a(0x298)],_0x12aec)};}async[_0x4ce2c3(0x165)](){const _0x3964e8=_0x4ce2c3;if(this[_0x3964e8(0x260)]!==undefined)await this[_0x3964e8(0x260)];this[_0x3964e8(0x260)]=undefined,this[_0x3964e8(0x1a0)]=![],this[_0x3964e8(0x1e7)]??=await loadNodeConfig(this[_0x3964e8(0x2b7)]),await this[_0x3964e8(0x29c)][_0x3964e8(0x1b6)](resolve(dirname(nodeDatabasePath(this[_0x3964e8(0x1e7)],this[_0x3964e8(0x2b7)])),_0x3964e8(0x163))),await assertLocalSqlitePath(nodeDatabasePath(this[_0x3964e8(0x1e7)],this[_0x3964e8(0x2b7)])),this[_0x3964e8(0x185)]??=new NodeDatabase(nodeDatabasePath(this[_0x3964e8(0x1e7)],this[_0x3964e8(0x2b7)]),()=>this[_0x3964e8(0x1e7)]?.[_0x3964e8(0x25e)]??_0x3964e8(0x292)),this[_0x3964e8(0x185)][_0x3964e8(0x2ff)](),await this[_0x3964e8(0x2a4)](),this[_0x3964e8(0x2aa)][_0x3964e8(0x165)](),this[_0x3964e8(0x12f)][_0x3964e8(0x143)]();}[_0x4ce2c3(0x196)](_0x32ad05){const _0x22158f=_0x4ce2c3,_0x41f729=this[_0x22158f(0x2cb)][_0x22158f(0x1dd)](_0x32ad05);if(_0x41f729!==undefined)clearTimeout(_0x41f729[_0x22158f(0x23a)]);this[_0x22158f(0x2cb)][_0x22158f(0x168)](_0x32ad05),this[_0x22158f(0x15f)][_0x22158f(0x168)](_0x32ad05);}async[_0x4ce2c3(0x18d)](_0x4f24c4){const _0xba5f2f=_0x4ce2c3,_0x284930=_0x4f24c4[_0xba5f2f(0x223)]['id']+':'+_0x4f24c4[_0xba5f2f(0x223)][_0xba5f2f(0x22c)];this[_0xba5f2f(0x15f)][_0xba5f2f(0x2ae)](_0x4f24c4[_0xba5f2f(0x243)],_0x284930);try{await this[_0xba5f2f(0x2ba)][_0xba5f2f(0x205)]({'sessionId':_0x4f24c4[_0xba5f2f(0x243)],'kind':_0xba5f2f(0x2c6),'content':this[_0xba5f2f(0x1be)][_0xba5f2f(0x1a6)](_0x4f24c4[_0xba5f2f(0x243)],_0xba5f2f(0x2c6)),'deliveryIntent':_0xba5f2f(0x21d),'mission':_0x4f24c4[_0xba5f2f(0x223)],'secretEnvironment':_0x4f24c4[_0xba5f2f(0x158)],..._0x4f24c4[_0xba5f2f(0x21f)]===undefined?{}:{'personalInstructions':_0x4f24c4[_0xba5f2f(0x21f)]},..._0x4f24c4[_0xba5f2f(0x1ed)]===undefined?{}:{'marAgentModel':_0x4f24c4[_0xba5f2f(0x1ed)]},..._0x4f24c4[_0xba5f2f(0x2fd)]===undefined?{}:{'marAgentModels':_0x4f24c4[_0xba5f2f(0x2fd)]},..._0x4f24c4[_0xba5f2f(0x30b)]===undefined?{}:{'marAgentRuntimeScopeId':_0x4f24c4[_0xba5f2f(0x30b)]}});const _0x3a6498=this[_0xba5f2f(0x1be)][_0xba5f2f(0x1dd)](_0x4f24c4[_0xba5f2f(0x243)]);if(_0x3a6498?.[_0xba5f2f(0x17c)]!==_0xba5f2f(0x152)||_0x3a6498['id']!==_0x4f24c4[_0xba5f2f(0x223)]['id']||_0x3a6498[_0xba5f2f(0x22c)]!==_0x4f24c4[_0xba5f2f(0x223)][_0xba5f2f(0x22c)]){if(this[_0xba5f2f(0x15f)][_0xba5f2f(0x1dd)](_0x4f24c4[_0xba5f2f(0x243)])===_0x284930)this[_0xba5f2f(0x15f)][_0xba5f2f(0x168)](_0x4f24c4[_0xba5f2f(0x243)]);return;}this[_0xba5f2f(0x196)](_0x4f24c4[_0xba5f2f(0x243)]);}catch{const _0x34db41=this[_0xba5f2f(0x1be)][_0xba5f2f(0x1dd)](_0x4f24c4[_0xba5f2f(0x243)]);if(_0x34db41?.[_0xba5f2f(0x17c)]!==_0xba5f2f(0x152)||_0x34db41['id']!==_0x4f24c4[_0xba5f2f(0x223)]['id']||_0x34db41[_0xba5f2f(0x22c)]!==_0x4f24c4[_0xba5f2f(0x223)][_0xba5f2f(0x22c)]){if(this[_0xba5f2f(0x15f)][_0xba5f2f(0x1dd)](_0x4f24c4[_0xba5f2f(0x243)])===_0x284930)this[_0xba5f2f(0x15f)][_0xba5f2f(0x168)](_0x4f24c4[_0xba5f2f(0x243)]);return;}const _0x1ca5ad=(_0x4f24c4[_0xba5f2f(0x209)]??0x1e0a+0x4*-0x107+-0x19ee)+(-0x14a9+0x3*-0xaa2+0x3490),_0x3720b0=this[_0xba5f2f(0x2bd)][_0xba5f2f(0x20f)](_0x4f24c4[_0xba5f2f(0x243)]);if(_0x1ca5ad>0x1*0xe57+0x555*-0x1+-0x1*0x8ff||_0x3720b0===undefined){this[_0xba5f2f(0x196)](_0x4f24c4[_0xba5f2f(0x243)]);if(_0x1ca5ad>0x9*0xeb+0xe96+-0x16d6){const _0x28dcb7=this[_0xba5f2f(0x1be)][_0xba5f2f(0x290)](_0x4f24c4[_0xba5f2f(0x243)],_0x4f24c4[_0xba5f2f(0x223)]['id'],_0x4f24c4[_0xba5f2f(0x223)][_0xba5f2f(0x22c)]);this[_0xba5f2f(0x26d)][_0xba5f2f(0x263)](_0x4f24c4[_0xba5f2f(0x243)]),this[_0xba5f2f(0x150)](_0x4f24c4[_0xba5f2f(0x243)],_0xba5f2f(0x2a5));if(_0x3720b0!==undefined)this[_0xba5f2f(0x235)](_0x3720b0,_0x28dcb7);}return;}this[_0xba5f2f(0x196)](_0x4f24c4[_0xba5f2f(0x243)]);const _0x585298={'sessionId':_0x4f24c4[_0xba5f2f(0x243)],'timer':setTimeout(()=>{const _0x339a5c=_0xba5f2f,_0x131248=this[_0x339a5c(0x1be)][_0x339a5c(0x1dd)](_0x585298[_0x339a5c(0x243)]);if(_0x131248?.[_0x339a5c(0x17c)]!==_0x339a5c(0x152)||_0x131248['id']!==_0x4f24c4[_0x339a5c(0x223)]['id']||_0x131248[_0x339a5c(0x22c)]!==_0x4f24c4[_0x339a5c(0x223)][_0x339a5c(0x22c)])return;void this[_0x339a5c(0x18d)]({..._0x4f24c4,'sessionId':_0x585298[_0x339a5c(0x243)],'failedAttempts':_0x1ca5ad});},0xb*-0x6da+-0x1*0x2b+0x8621)};this[_0xba5f2f(0x2cb)][_0xba5f2f(0x2ae)](_0x4f24c4[_0xba5f2f(0x243)],_0x585298),_0x585298[_0xba5f2f(0x23a)][_0xba5f2f(0x237)]();}}[_0x4ce2c3(0x150)](_0x4284a3,_0x596a33){const _0x1db7b0=_0x4ce2c3,_0x225829=this[_0x1db7b0(0x2bd)][_0x1db7b0(0x19c)](_0x4284a3);if(_0x225829===undefined||this[_0x1db7b0(0x2bd)][_0x1db7b0(0x180)](_0x225829['id'])!==undefined)return;this[_0x1db7b0(0x1cc)][_0x1db7b0(0x233)](_0x225829['id'],_0x596a33===_0x1db7b0(0x300)?_0x1db7b0(0x2ac):_0x1db7b0(0x280),_0x596a33===_0x1db7b0(0x300)?{}:{'code':_0x1db7b0(0x175)},_0x596a33);}[_0x4ce2c3(0x2bf)](_0x4ce38a){const _0x54829a=_0x4ce2c3,_0x3ed946=missionUnrestrictedAccess(_0x4ce38a[_0x54829a(0x1fe)]),_0x417c9e=_0x4ce38a[_0x54829a(0x245)]!==_0x3ed946,_0x32e2c9=_0x417c9e?this[_0x54829a(0x2bd)][_0x54829a(0x28d)](_0x4ce38a['id'],_0x3ed946):_0x4ce38a;if(_0x417c9e&&_0x32e2c9[_0x54829a(0x2e8)]!==null&&_0x32e2c9[_0x54829a(0x2d2)]!==null&&_0x32e2c9[_0x54829a(0x2e7)]!==null)this[_0x54829a(0x185)]?.[_0x54829a(0x159)]({'runner':_0x32e2c9[_0x54829a(0x1fe)],'externalSessionId':_0x32e2c9[_0x54829a(0x2e8)],'workspaceId':_0x32e2c9[_0x54829a(0x274)],'model':_0x32e2c9[_0x54829a(0x2d2)],'effort':_0x32e2c9[_0x54829a(0x2e7)],'access':_0x3ed946});return{'session':_0x32e2c9,'changed':_0x417c9e};}[_0x4ce2c3(0x127)](){const _0xa1ac39=_0x4ce2c3;return{'commandId':_0xa1ac39(0x223),'active':!![],'label':_0xa1ac39(0x28a),'detail':null,'closable':!![],'closeInput':_0xa1ac39(0x2c3)};}[_0x4ce2c3(0x230)](){const _0x636a19=_0x4ce2c3;if(this[_0x636a19(0x260)]!==undefined)return this[_0x636a19(0x260)];this[_0x636a19(0x1a0)]=!![],this[_0x636a19(0x162)][_0x636a19(0x189)](),this[_0x636a19(0x29c)][_0x636a19(0x230)](),this[_0x636a19(0x2aa)][_0x636a19(0x230)]();for(const _0x577c42 of this[_0x636a19(0x13e)][_0x636a19(0x29a)][_0x636a19(0x160)][_0x636a19(0x1db)]()){clearTimeout(_0x577c42[_0x636a19(0x23a)]),_0x577c42[_0x636a19(0x14d)](_0x636a19(0x308));}this[_0x636a19(0x13e)][_0x636a19(0x29a)][_0x636a19(0x160)][_0x636a19(0x17a)]();for(const _0xacdac0 of this[_0x636a19(0x13e)][_0x636a19(0x29a)][_0x636a19(0x305)][_0x636a19(0x1db)]()){clearTimeout(_0xacdac0[_0x636a19(0x23a)]),_0xacdac0[_0x636a19(0x1ab)](_0x636a19(0x15d));}this[_0x636a19(0x13e)][_0x636a19(0x29a)][_0x636a19(0x305)][_0x636a19(0x17a)](),this[_0x636a19(0x30a)][_0x636a19(0x17a)](),this[_0x636a19(0x240)][_0x636a19(0x189)](),this[_0x636a19(0x1c9)][_0x636a19(0x17a)](),this[_0x636a19(0x26d)][_0x636a19(0x17a)]();for(const _0x2e857c of this[_0x636a19(0x2cb)][_0x636a19(0x1db)]())clearTimeout(_0x2e857c[_0x636a19(0x23a)]);this[_0x636a19(0x2cb)][_0x636a19(0x17a)](),this[_0x636a19(0x15f)][_0x636a19(0x17a)](),this[_0x636a19(0x302)][_0x636a19(0x17a)](),this[_0x636a19(0x18e)][_0x636a19(0x189)]();for(const _0x1f002d of this[_0x636a19(0x13e)][_0x636a19(0x29a)][_0x636a19(0x16f)][_0x636a19(0x1db)]())_0x1f002d[_0x636a19(0x1a2)][_0x636a19(0x2b8)]();this[_0x636a19(0x13e)][_0x636a19(0x29a)][_0x636a19(0x16f)][_0x636a19(0x17a)](),this[_0x636a19(0x17f)][_0x636a19(0x189)](),void this[_0x636a19(0x131)][_0x636a19(0x189)]();const _0x16c7a=this[_0x636a19(0x2cc)]?.[_0x636a19(0x189)]();this[_0x636a19(0x2cc)]=undefined,this[_0x636a19(0x129)]?.[_0x636a19(0x189)](),this[_0x636a19(0x129)]=undefined;const _0x246d8b=this[_0x636a19(0x24c)];this[_0x636a19(0x24c)]=undefined,this[_0x636a19(0x253)]=undefined,this[_0x636a19(0x2a1)]=undefined,void this[_0x636a19(0x306)][_0x636a19(0x174)](),this[_0x636a19(0x2a0)][_0x636a19(0x189)](),this[_0x636a19(0x265)][_0x636a19(0x218)](),this[_0x636a19(0x26b)][_0x636a19(0x17a)](),this[_0x636a19(0x1c0)][_0x636a19(0x17a)](),this[_0x636a19(0x1b0)][_0x636a19(0x17a)](),void this[_0x636a19(0x1ba)][_0x636a19(0x230)](),void this[_0x636a19(0x201)][_0x636a19(0x206)](),void this[_0x636a19(0x273)][_0x636a19(0x174)](),this[_0x636a19(0x23c)][_0x636a19(0x230)](),this[_0x636a19(0x164)][_0x636a19(0x206)](),this[_0x636a19(0x12f)][_0x636a19(0x230)]();const _0x21513d=this[_0x636a19(0x185)];return this[_0x636a19(0x185)]=undefined,this[_0x636a19(0x260)]=((async()=>{const _0x1fded1=_0x636a19;try{await _0x16c7a;}finally{await _0x246d8b?.[_0x1fded1(0x189)]()[_0x1fded1(0x27b)](()=>undefined),_0x21513d?.[_0x1fded1(0x206)]();}})()),this[_0x636a19(0x260)];}[_0x4ce2c3(0x29b)]=_0x1b3f36=>this[_0x4ce2c3(0x134)][_0x4ce2c3(0x1a2)](_0x1b3f36);[_0x4ce2c3(0x1a5)]=(_0x55061e,_0x5062c8,_0x34c180,_0x7c0b96)=>this[_0x4ce2c3(0x1cc)][_0x4ce2c3(0x233)](_0x55061e,_0x5062c8,_0x34c180,_0x7c0b96);[_0x4ce2c3(0x172)]=(_0x13c1d5,_0x592e4e)=>{const _0x547d78=_0x4ce2c3;this[_0x547d78(0x302)][_0x547d78(0x1c4)](_0x13c1d5);const _0x54fca0=isPlainRecord(_0x592e4e)&&typeof _0x592e4e[_0x547d78(0x1e2)]===_0x547d78(0x1c2)?_0x592e4e[_0x547d78(0x1e2)]:undefined,_0x5d6540=isPlainRecord(_0x592e4e)&&typeof _0x592e4e[_0x547d78(0x1fb)]===_0x547d78(0x1c2)?_0x592e4e[_0x547d78(0x1fb)]:undefined,_0x55cd28=this[_0x547d78(0x2bd)][_0x547d78(0x23e)](_0x13c1d5),_0x50a1dd=_0x54fca0===undefined||_0x55cd28===undefined?undefined:conversationSegmentIdentityForItem(_0x55cd28,_0x54fca0,_0x5d6540);this[_0x547d78(0x1cc)][_0x547d78(0x233)](_0x13c1d5,_0x547d78(0x247),_0x50a1dd===undefined||!isPlainRecord(_0x592e4e)?_0x592e4e:{..._0x592e4e,'segmentId':_0x50a1dd['id'],'segmentIndex':_0x50a1dd[_0x547d78(0x145)]});};[_0x4ce2c3(0x22a)]=_0x15f3af=>{const _0x3786b6=_0x4ce2c3,_0x270e93=isPlainRecord(_0x15f3af)&&Array[_0x3786b6(0x293)](_0x15f3af[_0x3786b6(0x307)])?conversationSegments(_0x15f3af):[];this[_0x3786b6(0x2a7)](_0x3786b6(0x303),{'turn':_0x15f3af,'segments':_0x270e93});};[_0x4ce2c3(0x2f0)]=(_0x1e5a3e,_0x52a5ef)=>{const _0x403db1=_0x4ce2c3;if(_0x1e5a3e===_0x403db1(0x1cb)){this[_0x403db1(0x25c)](_0x52a5ef);return;}this[_0x403db1(0x2a7)](_0x1e5a3e,_0x52a5ef);};[_0x4ce2c3(0x25c)]=_0x3c4102=>{const _0x206208=_0x4ce2c3;if(isPlainRecord(_0x3c4102)&&isPlainRecord(_0x3c4102[_0x206208(0x1cb)])){const _0x2bca86=_0x3c4102[_0x206208(0x1cb)][_0x206208(0x274)];typeof _0x2bca86===_0x206208(0x1c2)&&(this[_0x206208(0x1c0)][_0x206208(0x169)](_0x2bca86),void this[_0x206208(0x26b)]?.[_0x206208(0x1d5)](_0x2bca86,_0x206208(0x2b1)));}this[_0x206208(0x2a7)](_0x206208(0x1cb),_0x3c4102);};[_0x4ce2c3(0x2a7)]=(_0x2a4af2,_0x342139)=>{const _0x383757=_0x4ce2c3;if(_0x2a4af2===_0x383757(0x303)&&isPlainRecord(_0x342139)&&isPlainRecord(_0x342139[_0x383757(0x1aa)])&&_0x342139[_0x383757(0x1aa)][_0x383757(0x1a3)]!==_0x383757(0x1f1)){const _0x1b2daf=typeof _0x342139[_0x383757(0x1aa)][_0x383757(0x2b6)]===_0x383757(0x1c2)?_0x342139[_0x383757(0x1aa)][_0x383757(0x2b6)]:undefined,_0x2497ce=typeof _0x342139[_0x383757(0x1aa)][_0x383757(0x18a)]===_0x383757(0x216)?_0x342139[_0x383757(0x1aa)][_0x383757(0x18a)]:undefined,_0x15e96a=_0x1b2daf===undefined?undefined:this[_0x383757(0x2bd)][_0x383757(0x23e)](_0x1b2daf);if(_0x15e96a===undefined)return;const _0x5f6382=isPlainRecord(_0x342139[_0x383757(0x1aa)][_0x383757(0x287)])?_0x342139[_0x383757(0x1aa)][_0x383757(0x287)]:undefined,_0x165404=_0x342139[_0x383757(0x1aa)][_0x383757(0x1a3)]===_0x383757(0x258)&&typeof _0x5f6382?.[_0x383757(0x220)]===_0x383757(0x1c2)?_0x5f6382[_0x383757(0x220)]:undefined,_0xba5e93=typeof _0x5f6382?.[_0x383757(0x1e2)]===_0x383757(0x1c2)?_0x5f6382[_0x383757(0x1e2)]:typeof _0x5f6382?.[_0x383757(0x135)]===_0x383757(0x1c2)?_0x383757(0x1b4)+_0x5f6382[_0x383757(0x135)]:undefined,_0x2820bb=_0x165404!==undefined&&_0x2497ce!==undefined?_0x15e96a[_0x383757(0x307)][_0x383757(0x1f9)](_0x4e12a2=>_0x4e12a2[_0x383757(0x1fb)]===_0x383757(0x1e3)&&_0x4e12a2[_0x383757(0x22c)]===_0x2497ce):_0xba5e93===undefined?undefined:_0x15e96a[_0x383757(0x307)][_0x383757(0x1f9)](_0x71c4e3=>_0x71c4e3['id']===_0x1b2daf+':'+_0xba5e93);if(_0x165404!==undefined&&_0x2820bb?.[_0x383757(0x1fb)]===_0x383757(0x1e3))_0x342139={'sessionId':_0x15e96a[_0x383757(0x243)],'delta':{'runId':_0x15e96a[_0x383757(0x2b6)],'itemId':_0x2820bb['id'],'text':_0x165404,'createdAt':typeof _0x342139[_0x383757(0x1aa)][_0x383757(0x1a8)]===_0x383757(0x216)?_0x342139[_0x383757(0x1aa)][_0x383757(0x1a8)]:Date[_0x383757(0x1e5)]()}};else{if(_0x2820bb!==undefined){const _0x2cebd7=conversationSegmentIdentityForItem(_0x15e96a,_0x2820bb['id'],_0x2820bb[_0x383757(0x1fb)]);_0x342139={'sessionId':_0x15e96a[_0x383757(0x243)],'runId':_0x15e96a[_0x383757(0x2b6)],'item':{'itemId':_0x2820bb['id'],'kind':_0x2820bb[_0x383757(0x1fb)],'status':_0x2820bb[_0x383757(0x17c)],'payload':_0x2820bb[_0x383757(0x287)],'startedAt':_0x2820bb[_0x383757(0x149)],'completedAt':_0x2820bb[_0x383757(0x2d6)],'segmentId':_0x2cebd7['id'],'segmentIndex':_0x2cebd7[_0x383757(0x145)]}};}else{if(_0x342139[_0x383757(0x1aa)][_0x383757(0x1a3)]!==_0x383757(0x161)&&_0x342139[_0x383757(0x1aa)][_0x383757(0x1a3)]!==_0x383757(0x2f5))return;_0x342139={'turn':_0x15e96a,'segments':conversationSegments(_0x15e96a)};}}}const _0x5d87f3=this[_0x383757(0x2f2)][_0x383757(0x2a2)](_0x2a4af2,_0x342139);if(_0x5d87f3===undefined)return;const _0x508b6c=_0x2a4af2===_0x383757(0x303)&&isPlainRecord(_0x342139)&&isPlainRecord(_0x342139[_0x383757(0x1aa)])&&_0x342139[_0x383757(0x1aa)][_0x383757(0x1a3)]===_0x383757(0x1f1),_0x5597ec=workbenchPayloadSessionId(this[_0x383757(0x2bd)],_0x2a4af2,_0x342139);if(!_0x508b6c&&_0x5597ec!==undefined){this[_0x383757(0x30a)][_0x383757(0x2af)](_0x5597ec,_0x5d87f3);return;}this[_0x383757(0x2f2)][_0x383757(0x264)](_0x5d87f3);};[_0x4ce2c3(0x2e0)]=_0xa9c91b=>this[_0x4ce2c3(0x1bb)][_0x4ce2c3(0x203)](_0xa9c91b);[_0x4ce2c3(0x1b1)]=_0x362085=>this[_0x4ce2c3(0x244)][_0x4ce2c3(0x2f6)](_0x362085);[_0x4ce2c3(0x191)]=()=>undefined;[_0x4ce2c3(0x285)]=()=>this[_0x4ce2c3(0x2aa)][_0x4ce2c3(0x285)]();[_0x4ce2c3(0x2cd)]=()=>this[_0x4ce2c3(0x2aa)][_0x4ce2c3(0x2cd)]();async[_0x4ce2c3(0x281)](_0x320f28,_0x17a536){const _0x37d6fe=_0x4ce2c3;if(this[_0x37d6fe(0x185)]===undefined)throw new Error(_0x37d6fe(0x14e));if(this[_0x37d6fe(0x29c)][_0x37d6fe(0x19d)](_0x320f28))throw new Error(_0x37d6fe(0x18b));return nodeLog(_0x37d6fe(0x1e0),{'nodeId':this[_0x37d6fe(0x1e7)]?.[_0x37d6fe(0x25e)],'operation':_0x320f28}),this[_0x37d6fe(0x194)][_0x37d6fe(0x1a1)](_0x320f28,_0x17a536);}async[_0x4ce2c3(0x1b5)](_0x59bb44,_0x5efd8e){const _0x499bc3=_0x4ce2c3,_0x144a06=this[_0x499bc3(0x1e7)];if(_0x144a06?.[_0x499bc3(0x25e)]===undefined||_0x144a06[_0x499bc3(0x283)]===undefined)throw new Error(_0x499bc3(0x16c));const _0x5c0f13=await fetch(_0x144a06[_0x499bc3(0x15e)][_0x499bc3(0x248)](/\/$/u,'')+_0x499bc3(0x299),{'method':_0x499bc3(0x193),'headers':{'content-type':_0x499bc3(0x249),'x-mar-node-id':_0x144a06[_0x499bc3(0x25e)],'authorization':_0x499bc3(0x2d8)+_0x144a06[_0x499bc3(0x283)]},'body':JSON[_0x499bc3(0x1ad)](_0x59bb44),'signal':_0x5efd8e});if(!_0x5c0f13['ok'])throw await readWebSearchError(_0x5c0f13);const _0x1745ef=await _0x5c0f13[_0x499bc3(0x257)]();return{'content':JSON[_0x499bc3(0x1ad)](_0x1745ef),'data':_0x1745ef};}[_0x4ce2c3(0x235)](_0x964959,_0xe52573){const _0x271840=_0x4ce2c3;if(_0xe52573[_0x271840(0x17c)]!==_0x271840(0x152)){this[_0x271840(0x151)][_0x271840(0x17a)](_0x964959['id'],_0x271840(0x223)),this[_0x271840(0x2a7)](_0x271840(0x1cb),{'session':this[_0x271840(0x242)][_0x271840(0x278)](_0x964959)});return;}this[_0x271840(0x151)][_0x271840(0x2ae)](_0x964959['id'],{'commandId':_0x271840(0x223),'active':_0xe52573[_0x271840(0x17c)]===_0x271840(0x152),'label':_0x271840(0x28a),'detail':_0xe52573[_0x271840(0x227)][_0x271840(0x301)](0x22b9+-0x2*-0x107+0x23*-0x10d,0x1760+0x144+-0x16b0),'closable':!![],'closeInput':_0x271840(0x1f7),'mission':{'id':_0xe52573['id'],'objective':_0xe52573[_0x271840(0x227)],'revision':_0xe52573[_0x271840(0x22c)],'status':_0xe52573[_0x271840(0x17c)],'turns':_0xe52573[_0x271840(0x12c)]}}),this[_0x271840(0x2a7)](_0x271840(0x1cb),{'session':this[_0x271840(0x242)][_0x271840(0x278)](_0x964959)});}[_0x4ce2c3(0x2d9)](_0x3b28e2,_0xb949a2,_0x29c608){const _0x46db54=_0x4ce2c3;this[_0x46db54(0x12f)][_0x46db54(0x2d9)](_0x3b28e2,_0xb949a2,_0x29c608);}[_0x4ce2c3(0x147)](_0x3ef6c2){const _0x3d8375=_0x4ce2c3;this[_0x3d8375(0x12f)][_0x3d8375(0x147)](_0x3ef6c2);}}
1
+ import { dirname, resolve } from 'node:path';
2
+ import { createEnvelope } from '@myagentroam/protocol';
3
+ import { hostedConversationStorePath, loadNodeConfig, nodeDataDirectory, nodeDatabasePath } from './config.js';
4
+ import { NodeMetrics, nodeLog } from './operational.js';
5
+ import { assertLocalSqlitePath } from './storage.js';
6
+ import { detectCapabilitiesAsync, unavailableCapabilities } from './capabilities.js';
7
+ import { NodeDatabase } from './database.js';
8
+ import { TerminalManager } from './terminal.js';
9
+ import { NodeRuntimeState } from './runtime-state.js';
10
+ import { CommandStateStore } from './runner-command-engine.js';
11
+ import { missionUnrestrictedAccess, MissionRuntime } from './service/mission-runtime.js';
12
+ import { MissionMcpServer } from './service/mission-mcp-server.js';
13
+ import { RunnerUsageReader } from './runner-usage.js';
14
+ import { ClaudeCodeRunner } from './runner/claude-code-runner.js';
15
+ import { ClaudeManagedRunController } from './runner/claude/managed-run-controller.js';
16
+ import { CodexRunner } from './runner/codex-runner.js';
17
+ import { CodexManagedRunController } from './runner/codex/managed-run-controller.js';
18
+ import { FakeTestRunner } from './runner/fake-test-runner.js';
19
+ import { RunnerRegistry } from './runner/runner-registry.js';
20
+ import { OpenCodeRunner } from './runner/opencode-runner.js';
21
+ import { MarAgentRunner } from './runner/mar-agent-runner.js';
22
+ import { MarAgentManagedRunController } from './runner/mar-agent/managed-run-controller.js';
23
+ import { OpenCodeManagedRunController } from './runner/opencode/managed-run-controller.js';
24
+ import { NodeOperationRouter } from './connector/node-operation-router.js';
25
+ import { SkillNodeOperationService } from './service/skill-node-operation-service.js';
26
+ import { McpNodeOperationService } from './service/mcp-node-operation-service.js';
27
+ import { RunnerService } from './service/runner-service.js';
28
+ import { TerminalService } from './service/terminal-service.js';
29
+ import { GitExecutionService } from './service/git-execution-service.js';
30
+ import { GitOperationService } from './service/git-operation-service.js';
31
+ import { WorkspaceService } from './service/workspace-service.js';
32
+ import { WorkspaceWatchService } from './service/workspace-watch-service.js';
33
+ import { WorkspaceFileService } from './service/workspace-file-service.js';
34
+ import { WorkspaceUploadService } from './service/workspace-upload-service.js';
35
+ import { WorkspaceChangeService } from './service/workspace-change-service.js';
36
+ import { WorkspaceSessionService } from './service/workspace-session-service.js';
37
+ import { WorkbenchEventService } from './service/workbench-event-service.js';
38
+ import { RunDomainState } from './service/run-domain-state.js';
39
+ import { RecentRunProjectionService } from './service/recent-run-projection-service.js';
40
+ import { SessionDomainState } from './service/session-domain-state.js';
41
+ import { RunEventService } from './service/run-event-service.js';
42
+ import { RunAttachmentService } from './service/run-attachment-service.js';
43
+ import { NodeTerminalChannel } from './service/node-terminal-channel.js';
44
+ import { WorkspaceWorkbenchService } from './service/workspace-workbench-service.js';
45
+ import { NativeSessionWatchService } from './service/native-session-watch-service.js';
46
+ import { SessionWatchSlotCoordinator } from './service/session-watch-slot-coordinator.js';
47
+ import { SessionContextService } from './service/session-context-service.js';
48
+ import { WorkspaceDomainState } from './service/workspace-domain-state.js';
49
+ import { RunWorkbenchService } from './service/run-workbench-service.js';
50
+ import { SessionQueryService } from './service/session-query-service.js';
51
+ import { WorkspaceQueueWorkbenchService } from './service/workspace-queue-workbench-service.js';
52
+ import { ContinuousRunCoordinator } from './service/continuous-run-coordinator.js';
53
+ import { SessionIdentityService } from './service/session-identity-service.js';
54
+ import { NativeSessionProjectionService } from './service/native-session-projection-service.js';
55
+ import { composeConversationRuntimePage, ConversationHistoryService, convergeConversationWatchPage, hasManagedActiveRun } from './service/conversation-history-service.js';
56
+ import { ConversationSegmentService, conversationSegmentIdentityForItem, conversationSegments } from './service/conversation-segment-service.js';
57
+ import { RunnerInteractionService } from './service/runner-interaction-service.js';
58
+ import { SessionLifecycleService } from './service/session-lifecycle-service.js';
59
+ import { ExternalSessionResumeService } from './service/external-session-resume-service.js';
60
+ import { SessionMessageService } from './service/session-message-service.js';
61
+ import { SessionCatalogService } from './service/session-catalog-service.js';
62
+ import { SessionCommandService } from './service/session-command-service.js';
63
+ import { SessionPresentationService } from './service/session-presentation-service.js';
64
+ import { isPlainRecord, isRunnerImageAttachment, parseRunnerImageAttachments } from './runner/codex/conversation-parser.js';
65
+ import { readWebSearchError } from './service/web-search-error.js';
66
+ export { nodeConnectEndpoint, validatedCapabilities } from './runner/codex/conversation-parser.js';
67
+ import { NodeControlChannel } from './service/node-control-channel.js';
68
+ import { NodeControlMessageService } from './service/node-control-message-service.js';
69
+ import { NodeRequestService } from './service/node-request-service.js';
70
+ import { WorkbenchManifestService } from './service/workbench-manifest-service.js';
71
+ import { NodeRunEventBridge, workbenchPayloadSessionId } from './service/node-run-event-bridge.js';
72
+ import { NodeWorkspaceCoordinator } from './service/node-workspace-coordinator.js';
73
+ import { FakeManagedRunService } from './service/fake-managed-run-service.js';
74
+ import { RunnerChannelMessageService } from './service/runner-channel-message-service.js';
75
+ import { ManagedRunnerSessionService } from './service/managed-runner-session-service.js';
76
+ import { NodeConnectionLifecycleService } from './service/node-connection-lifecycle-service.js';
77
+ import { NodeUpgradeCoordinator, nodeUpgradeRequestPath } from './service/node-upgrade-coordinator.js';
78
+ import { HostedConversationStore } from './service/hosted-conversation-store.js';
79
+ import { ConversationTemplateNodeService } from './service/conversation-template-node-service.js';
80
+ import { HostedConversationNodeService } from './service/hosted-conversation-node-service.js';
81
+ import { BubblewrapSandboxExecutor } from './service/bubblewrap-sandbox-executor.js';
82
+ import { MarAgentHostedConversationRuntime } from './runner/mar-agent/hosted-conversation-runtime.js';
83
+ import { conversationHostingCapability, probeBubblewrap } from './service/conversation-hosting-capability-service.js';
84
+ import { ConversationHostingMaintenanceService } from './service/conversation-hosting-maintenance-service.js';
85
+ import { ConversationHostingEnablementService } from './service/conversation-hosting-enablement-service.js';
86
+ import { safeErrorCode } from './util/safe-error.js';
87
+ import { RuntimeCredentialControlService } from './service/runtime-credential-control-service.js';
88
+ import { MarAgentRuntimeModelFactory } from './runner/mar-agent/runtime-model-factory.js';
89
+ import { MarAgentModelTransportTestService } from './service/mar-agent-model-transport-test-service.js';
90
+ const HEARTBEAT_MS = 15_000;
91
+ const CAPABILITY_REFRESH_MS = 60_000;
92
+ const RETRY_MIN_MS = 500;
93
+ const RETRY_MAX_MS = 30_000;
94
+ const CLAUDE_APPROVAL_TIMEOUT_MS = 10 * 60_000;
95
+ const CONVERSATION_TEMPLATE_OPERATIONS = [
96
+ 'conversation.template.source.inspect',
97
+ 'conversation.template.publish',
98
+ 'conversation.template.publish.status',
99
+ 'conversation.template.version.inspect'
100
+ ];
101
+ const HOSTED_CONVERSATION_OPERATIONS = [
102
+ 'conversation.hosted.list',
103
+ 'conversation.hosted.create',
104
+ 'conversation.hosted.get',
105
+ 'conversation.hosted.watch',
106
+ 'conversation.hosted.unwatch',
107
+ 'conversation.hosted.message',
108
+ 'conversation.hosted.rollback',
109
+ 'conversation.hosted.interrupt',
110
+ 'conversation.hosted.config.update',
111
+ 'conversation.hosted.metadata.update',
112
+ 'conversation.hosted.image.read',
113
+ 'conversation.hosted.files.list',
114
+ 'conversation.hosted.file.read',
115
+ 'conversation.hosted.files.upload.preflight',
116
+ 'conversation.hosted.files.upload.create',
117
+ 'conversation.hosted.files.upload.chunk',
118
+ 'conversation.hosted.files.upload.status',
119
+ 'conversation.hosted.files.upload.complete',
120
+ 'conversation.hosted.files.upload.cancel',
121
+ 'conversation.hosted.delete'
122
+ ];
123
+ const CONVERSATION_HOSTING_MAINTENANCE_OPERATIONS = [
124
+ 'conversation.hosting.storage.inspect',
125
+ 'conversation.hosting.cleanup.preview',
126
+ 'conversation.hosting.cleanup.execute'
127
+ ];
128
+ export function nextReconnectDelay(attempt) {
129
+ return Math.min(RETRY_MAX_MS, RETRY_MIN_MS * 2 ** Math.min(Math.max(attempt, 0), 16));
130
+ }
131
+ function upgradeMetadata(metadata, status) {
132
+ const next = { ...(metadata ?? {}) };
133
+ if (process.env['MAR_NODE_SUPERVISED'] === '1')
134
+ next.supervisedUpgrade = true;
135
+ else
136
+ delete next.supervisedUpgrade;
137
+ if (status.state === 'IDLE')
138
+ delete next.upgrade;
139
+ else
140
+ next.upgrade = status;
141
+ return next;
142
+ }
143
+ export class NodeConnector {
144
+ nodeGeneration = crypto.randomUUID().replace(/-/g, '');
145
+ controlChannel;
146
+ controlMessages;
147
+ nodeRequests;
148
+ connectionLifecycle;
149
+ runtimeCredentials = new RuntimeCredentialControlService({
150
+ send: (envelope) => this.sendEnvelope(envelope)
151
+ });
152
+ marAgentRuntimeModels = new MarAgentRuntimeModelFactory(this.runtimeCredentials);
153
+ marAgentModelTransportTests = new MarAgentModelTransportTestService({
154
+ modelFactory: this.marAgentRuntimeModels
155
+ });
156
+ /** @internal Existing contract tests inject their socket through this boundary. */
157
+ set socket(value) {
158
+ this.controlChannel.replaceSocketForTesting(value);
159
+ }
160
+ stopped = false;
161
+ stopping;
162
+ config;
163
+ capabilitiesProvided;
164
+ capabilities;
165
+ capabilityDetector;
166
+ conversationHostingProbe;
167
+ conversationHostingStorageReady = false;
168
+ conversationHostingFailureCode;
169
+ conversationTemplateOperations;
170
+ hostedConversationOperations;
171
+ conversationHostingMaintenanceOperations;
172
+ hostedConversationRuntime;
173
+ hostedConversationService;
174
+ conversationHostingMaintenanceService;
175
+ configPath;
176
+ reconnect;
177
+ claudeApprovalTimeoutMs;
178
+ workbenchEventService = new WorkbenchEventService((envelope) => this.sendEnvelope(envelope), (category, payload) => {
179
+ const sessionId = workbenchPayloadSessionId(this.runtime, category, payload);
180
+ return sessionId === undefined || !this.sessionIdentityService.bootstrapIds.has(sessionId);
181
+ });
182
+ fakeRunner;
183
+ fakeScript;
184
+ runState = new RunDomainState();
185
+ runEventBridge;
186
+ workspaceCoordinator;
187
+ sessionState = new SessionDomainState();
188
+ sessionIdentityService;
189
+ nativeSessionProjectionService;
190
+ conversationHistoryService;
191
+ conversationSegmentService;
192
+ runnerInteractionService;
193
+ runnerChannelMessages;
194
+ managedRunnerSessions;
195
+ sessionPresentationService;
196
+ sessionLifecycleService;
197
+ externalSessionResumeService;
198
+ sessionMessageService;
199
+ sessionCatalogService;
200
+ sessionCommandService;
201
+ runAttachmentService;
202
+ terminalChannel;
203
+ codexClient;
204
+ codexRunController;
205
+ claudeClient;
206
+ openCodeClient;
207
+ marAgentClient;
208
+ marAgentRunController;
209
+ openCodeRunController;
210
+ claudeRunController;
211
+ runners;
212
+ sessionContextService;
213
+ runWorkbenchService;
214
+ sessionQueryService;
215
+ continuousRunCoordinator;
216
+ workspaceQueueWorkbenchService;
217
+ operationRouter = new NodeOperationRouter();
218
+ gitExecutionService;
219
+ gitOperationService = new GitOperationService({
220
+ git: () => this.gitExecution(),
221
+ workspace: async (input) => {
222
+ const session = typeof input.sessionId === 'string'
223
+ ? (this.runtime.getAgentSession(input.sessionId) ??
224
+ (await this.nativeSessionProjectionService.resolveCurrent(input.sessionId)))
225
+ : undefined;
226
+ const workspaceId = session?.workspaceId ??
227
+ (typeof input.workspaceId === 'string' ? input.workspaceId : undefined);
228
+ return workspaceId === undefined ? undefined : this.database?.getWorkspace(workspaceId);
229
+ },
230
+ runActive: (id) => {
231
+ const run = this.runtime.getRun(id);
232
+ return run !== undefined && !['SUCCEEDED', 'FAILED', 'INTERRUPTED'].includes(run.status);
233
+ }
234
+ });
235
+ runnerService;
236
+ workbenchManifestService;
237
+ terminalService;
238
+ workspaceService;
239
+ commandStates = new CommandStateStore();
240
+ missionRuntime = new MissionRuntime(() => undefined);
241
+ missionRetryTimers = new Map();
242
+ missionContinuationPending = new Map();
243
+ missionMcpServer = new MissionMcpServer(this.missionRuntime, (sessionId) => {
244
+ const mission = this.missionRuntime.get(sessionId);
245
+ const session = this.runtime.getAgentSession(sessionId);
246
+ if (mission === undefined || session === undefined)
247
+ return;
248
+ if (mission.status !== 'active')
249
+ this.continuousRunCoordinator.removeMissionQueue(sessionId);
250
+ this.publishMissionState(session, mission);
251
+ });
252
+ runnerUsageReader;
253
+ terminalManager;
254
+ upgradeCoordinator;
255
+ workspaceState = new WorkspaceDomainState();
256
+ workspaceWatchService = new WorkspaceWatchService(this.workspaceState, (workspaceId) => this.workspaceSessionService.ensureWatch(workspaceId), (workspaceId) => this.workspaceSessionService.stopWatch(workspaceId), (workspaceId) => this.workspaceWorkbenchService?.clearWorkspace(workspaceId));
257
+ workspaceSessionService = new WorkspaceSessionService(this.workspaceState, {
258
+ discover: (workspaceId) => this.discoverWorkspaceSessions(workspaceId),
259
+ listPage: (workspaceId) => this.executeNodeOperation('session.list', { workspaceId, limit: 20 }),
260
+ active: (workspaceId) => this.workspaceWatchService.topicActive(workspaceId, 'sessions'),
261
+ invalidate: (workspaceId) => void this.workspaceWorkbenchService?.invalidateTopic(workspaceId, 'sessions'),
262
+ onPending: (workspaceId, waitMs) => nodeLog('native.session.discovery.pending', {
263
+ nodeId: this.config?.nodeId,
264
+ workspaceId,
265
+ waitMs
266
+ })
267
+ });
268
+ workspaceFileService = new WorkspaceFileService(this.workspaceState, () => this.config?.allowedRoots ?? [], (workspaceId) => this.workspaceCoordinator.invalidate(workspaceId));
269
+ workspaceUploadService = new WorkspaceUploadService(this.workspaceState, (workspaceId) => {
270
+ this.workspaceFileService.dispose(workspaceId);
271
+ this.workspaceCoordinator.invalidate(workspaceId);
272
+ });
273
+ workspaceChangeService = new WorkspaceChangeService(this.workspaceState);
274
+ workspaceWorkbenchService;
275
+ database;
276
+ recentRunProjectionService = new RecentRunProjectionService((message) => this.send('recent-runs', message));
277
+ /** Runtime/session state is intentionally not persisted to Node SQLite. */
278
+ runtime = new NodeRuntimeState(() => this.config?.nodeId ?? 'runtime-node', (workspaceId) => this.database?.getWorkspace(workspaceId), Date.now, (run, session, userMessage) => this.recentRunProjectionService.record(run, session, userMessage));
279
+ metrics = new NodeMetrics();
280
+ runEventService = new RunEventService({
281
+ runtime: this.runtime,
282
+ metrics: this.metrics,
283
+ state: this.runState,
284
+ isBootstrapSession: (sessionId) => this.sessionIdentityService.bootstrapIds.has(sessionId),
285
+ presentSession: (session) => this.sessionPresentationService.present(session),
286
+ rejectBootstrap: (sessionId, code) => this.sessionIdentityService.reject(sessionId, code),
287
+ emitWorkbench: (category, payload) => {
288
+ if (category === 'conversation' && isPlainRecord(payload) && 'turn' in payload)
289
+ this.emitConversationTurn(payload.turn);
290
+ else
291
+ this.publishWorkbenchEvent(category, payload);
292
+ },
293
+ cleanupAttachments: (runId) => this.runAttachmentService.cleanup(runId),
294
+ expireImages: (runId) => this.runAttachmentService.expire(runId),
295
+ scheduleContextRefresh: (sessionId) => this.sessionContextService.schedule(sessionId),
296
+ refreshWorkspaceSessions: (workspaceId) => this.workspaceWorkbenchService.ensureTopicSnapshot(workspaceId, 'sessions'),
297
+ dispatchQueue: async (sessionId, delayMs = 0) => {
298
+ if (this.upgradeCoordinator.pending())
299
+ return;
300
+ if (delayMs > 0) {
301
+ this.continuousRunCoordinator.schedule(sessionId, delayMs);
302
+ return;
303
+ }
304
+ await this.continuousRunCoordinator.dispatch(sessionId);
305
+ },
306
+ executionStarted: (executionId) => this.continuousRunCoordinator.executionStarted(executionId),
307
+ keepRunActive: (sessionId) => (this.missionRetryTimers.has(sessionId) || this.missionContinuationPending.has(sessionId)) &&
308
+ this.missionRuntime.get(sessionId)?.status === 'active',
309
+ executionTerminating: (executionId, status) => {
310
+ this.gitOperationService.executionFinished(executionId);
311
+ const pending = this.continuousRunCoordinator.pending(executionId);
312
+ if (pending?.mission === undefined)
313
+ return;
314
+ const started = this.continuousRunCoordinator.hasExecutionStarted(executionId);
315
+ const blocked = this.missionRuntime.recordExecutionResult(pending.sessionId, status === 'FAILED');
316
+ if (blocked) {
317
+ this.clearMissionRetry(pending.sessionId);
318
+ this.continuousRunCoordinator.removeMissionQueue(pending.sessionId);
319
+ const terminalMission = this.missionRuntime.get(pending.sessionId);
320
+ const session = this.runtime.getAgentSession(pending.sessionId);
321
+ if (terminalMission !== undefined && session !== undefined)
322
+ this.publishMissionState(session, terminalMission);
323
+ return;
324
+ }
325
+ if (status !== 'FAILED' || started)
326
+ return;
327
+ this.clearMissionRetry(pending.sessionId);
328
+ const retry = {
329
+ sessionId: pending.sessionId,
330
+ timer: setTimeout(() => {
331
+ this.missionRetryTimers.delete(retry.sessionId);
332
+ const mission = this.missionRuntime.get(retry.sessionId);
333
+ if (mission?.status !== 'active' ||
334
+ mission.id !== pending.mission?.id ||
335
+ mission.revision !== pending.mission.revision)
336
+ return;
337
+ void this.sessionMessageService
338
+ .submitMission({
339
+ sessionId: retry.sessionId,
340
+ kind: 'continue',
341
+ content: this.missionRuntime.prompt(retry.sessionId, 'continue'),
342
+ deliveryIntent: 'SEND',
343
+ mission: { id: mission.id, revision: mission.revision },
344
+ secretEnvironment: pending.secretEnvironment,
345
+ ...(pending.personalInstructions === undefined
346
+ ? {}
347
+ : { personalInstructions: pending.personalInstructions }),
348
+ ...(pending.marAgentModel === undefined
349
+ ? {}
350
+ : { marAgentModel: pending.marAgentModel }),
351
+ ...(pending.marAgentModels === undefined
352
+ ? {}
353
+ : { marAgentModels: pending.marAgentModels }),
354
+ ...(pending.marAgentRuntimeScopeId === undefined
355
+ ? {}
356
+ : { marAgentRuntimeScopeId: pending.marAgentRuntimeScopeId })
357
+ })
358
+ .catch(() => undefined);
359
+ }, 15_000)
360
+ };
361
+ this.missionRetryTimers.set(pending.sessionId, retry);
362
+ retry.timer.unref();
363
+ },
364
+ releaseExecution: (executionId) => {
365
+ this.missionMcpServer.revoke(executionId);
366
+ this.continuousRunCoordinator.remove(executionId);
367
+ }
368
+ });
369
+ sessionWatchSlots = new SessionWatchSlotCoordinator();
370
+ nativeSessionWatchService = new NativeSessionWatchService({
371
+ resolve: async (sessionId) => this.runtime.getAgentSession(sessionId) ??
372
+ this.nativeSessionProjectionService.resolveCurrent(sessionId),
373
+ managedActive: (session) => hasManagedActiveRun(this.runtime, session),
374
+ suspended: (sessionId) => this.externalSessionResumeService.transitioning(sessionId),
375
+ refreshActivity: (session) => this.conversationHistoryService.refreshExternalActivity(session),
376
+ present: (session) => this.sessionPresentationService.present(session),
377
+ readPage: (session, limit) => this.conversationHistoryService.read(session, { limit }),
378
+ readHistoryPage: (session, limit) => this.conversationHistoryService.readHistoryPage(session, { limit }),
379
+ convergePage: convergeConversationWatchPage,
380
+ composeRuntimePage: composeConversationRuntimePage,
381
+ projectInitialPage: (session, page, _unit, limit) => {
382
+ const context = this.sessionContextService.snapshot(session.id);
383
+ this.sessionContextService.schedule(session);
384
+ return {
385
+ kind: 'session-watch-snapshot',
386
+ sequence: this.workbenchEventService.snapshotSequence(),
387
+ session: this.sessionPresentationService.present(session),
388
+ runs: this.runtime.listRunsForSession(session.id),
389
+ queue: this.workspaceQueueWorkbenchService.snapshot(session.id),
390
+ context,
391
+ conversation: this.conversationSegmentService.projectInitial(session, page, limit)
392
+ };
393
+ },
394
+ emitSession: (session) => this.emitSessionWorkbenchEvent({ session }),
395
+ emitPage: (session, page) => this.emitWorkbenchEvent('conversation', {
396
+ sessionId: session.id,
397
+ snapshot: this.conversationSegmentService.projectInitial(session, page, 10)
398
+ }),
399
+ nodeId: () => this.config?.nodeId ?? 'runtime-node',
400
+ nodeGeneration: () => this.nodeGeneration,
401
+ emitWatchEvent: (payload) => this.send('watch.event', payload),
402
+ sessionWatchSlots: this.sessionWatchSlots,
403
+ log: nodeLog
404
+ });
405
+ constructor(options = {}) {
406
+ this.config = options.config;
407
+ this.configPath = options.configPath;
408
+ this.claudeApprovalTimeoutMs = options.claudeApprovalTimeoutMs ?? CLAUDE_APPROVAL_TIMEOUT_MS;
409
+ this.capabilitiesProvided = options.capabilities !== undefined;
410
+ this.capabilities = options.capabilities ?? unavailableCapabilities();
411
+ this.conversationHostingProbe = options.conversationHostingProbe ?? probeBubblewrap;
412
+ this.upgradeCoordinator = new NodeUpgradeCoordinator(() => {
413
+ if (this.config === undefined)
414
+ throw new Error('NODE_CONFIG_UNAVAILABLE');
415
+ return nodeUpgradeRequestPath(nodeDatabasePath(this.config, this.configPath));
416
+ }, () => this.runState.active.size, (status) => {
417
+ this.capabilities = {
418
+ ...this.capabilities,
419
+ metadata: upgradeMetadata(this.capabilities.metadata, status)
420
+ };
421
+ this.controlChannel?.send('capabilities', this.capabilities);
422
+ }, options.upgradeReady ??
423
+ (() => {
424
+ void this.stop().finally(() => process.exit(75));
425
+ }));
426
+ this.capabilities = {
427
+ ...this.capabilities,
428
+ metadata: upgradeMetadata(this.capabilities.metadata, this.upgradeCoordinator.snapshot())
429
+ };
430
+ const detect = options.capabilityDetector ?? detectCapabilitiesAsync;
431
+ this.capabilityDetector = async () => {
432
+ const capabilities = await detect();
433
+ return this.projectConversationHostingCapability({
434
+ ...capabilities,
435
+ metadata: upgradeMetadata(capabilities.metadata, this.upgradeCoordinator.snapshot())
436
+ });
437
+ };
438
+ this.reconnect = options.reconnect ?? true;
439
+ this.fakeRunner =
440
+ options.fakeRunner === undefined ? undefined : new FakeTestRunner(options.fakeRunner);
441
+ this.fakeScript = options.fakeScript;
442
+ this.runAttachmentService = new RunAttachmentService((session) => this.runners.require(session.runner).nativeImageRoots(session));
443
+ this.codexClient = new CodexRunner(options.codexClient, options.codexProfileClientFactory);
444
+ this.codexRunController = new CodexManagedRunController(this.codexClient, {
445
+ available: () => this.capabilities.codex.available,
446
+ intercepted: () => this.fakeRunner !== undefined,
447
+ active: this.runState.active,
448
+ addActive: (runId) => this.runState.active.add(runId),
449
+ removeActive: (runId) => this.runState.active.delete(runId),
450
+ adopt: (input) => this.runtime.adoptRun(input),
451
+ session: (sessionId) => this.runtime.getAgentSession(sessionId),
452
+ runStatus: (runId) => this.runtime.getRun(runId)?.status,
453
+ run: (runId) => this.runtime.getRun(runId),
454
+ interrupted: (runId) => this.runState.interruptRequested.has(runId),
455
+ parseAttachments: parseRunnerImageAttachments,
456
+ materialize: (runId, attachments) => this.runAttachmentService.materializeCodex(runId, attachments),
457
+ completeCancelled: (runId) => this.runnerInteractionService.completeCancelledRun(runId),
458
+ promoteSession: (sessionId, nativeSessionId) => this.sessionIdentityService.promote(sessionId, nativeSessionId),
459
+ send: (type, payload) => this.send(type, payload),
460
+ emit: (runId, eventType, payload, status) => this.runEventBridge.emitRun(runId, eventType, payload, status),
461
+ cancel: (runId, threadId, turnId, cwd, status) => this.runnerInteractionService.cancelCodexTurn(runId, threadId, turnId, cwd, status),
462
+ createApproval: (input) => this.runtime.createApproval(input),
463
+ publishApproval: (input) => this.runEventBridge.publishApproval(input),
464
+ emitItem: (runId, item) => this.emitConversationItem(runId, item),
465
+ appendImages: (runId, images) => this.runAttachmentService.append(runId, images.filter(isRunnerImageAttachment)),
466
+ syncTitle: (sessionId, nativeSessionId, cwd) => this.managedRunnerSessions.refreshTitle(sessionId, nativeSessionId, cwd),
467
+ commandState: (sessionId, commandId) => this.commandStates.get(sessionId, commandId),
468
+ setCommandState: (sessionId, state) => this.commandStates.set(sessionId, state),
469
+ clearCommandState: (sessionId, commandId) => this.commandStates.clear(sessionId, commandId),
470
+ commandStates: (sessionId) => this.commandStates.list(sessionId),
471
+ hasActiveSessionLease: (sessionId) => this.runtime.hasActiveSessionLease(sessionId),
472
+ fast: (input) => this.executeNodeOperation('runner.command.execute', {
473
+ runner: 'codex',
474
+ commandId: 'fast',
475
+ input
476
+ })
477
+ });
478
+ this.codexClient.onNotification((notification) => this.codexRunController.handleNotification(notification));
479
+ this.claudeClient = new ClaudeCodeRunner(options.claudeClient);
480
+ this.openCodeClient = new OpenCodeRunner(options.openCodeClient);
481
+ this.marAgentClient = new MarAgentRunner();
482
+ this.marAgentClient.setGeneratedImageRegistrar((session, images) => this.runAttachmentService.registerNative(session, images));
483
+ this.marAgentRunController = new MarAgentManagedRunController(this.marAgentClient, {
484
+ active: this.runState.active,
485
+ adopt: (input) => this.runtime.adoptRun(input),
486
+ promote: (sessionId, nativeSessionId) => this.sessionIdentityService.promote(sessionId, nativeSessionId),
487
+ syncTitle: (nativeSessionId, cwd) => this.managedRunnerSessions.refreshTitle(nativeSessionId, nativeSessionId, cwd),
488
+ emit: (runId, eventType, payload, status) => this.runEventBridge.emitRun(runId, eventType, payload, status),
489
+ emitItem: (runId, item) => this.emitConversationItem(runId, item),
490
+ refreshContext: (runId) => {
491
+ const sessionId = this.runtime.getRun(runId)?.sessionId;
492
+ if (sessionId !== undefined)
493
+ this.sessionContextService.schedule(sessionId);
494
+ },
495
+ createApproval: (input) => this.runtime.createApproval(input),
496
+ publishApproval: (input) => this.runEventBridge.publishApproval(input),
497
+ run: (runId) => this.runtime.getRun(runId),
498
+ commandState: (sessionId, commandId) => this.commandStates.get(sessionId, commandId),
499
+ setCommandState: (sessionId, state) => this.commandStates.set(sessionId, state),
500
+ clearCommandState: (sessionId, commandId) => this.commandStates.clear(sessionId, commandId),
501
+ commandStates: (sessionId) => this.commandStates.list(sessionId),
502
+ webSearch: (input, signal) => this.webSearch(input, signal),
503
+ registerGeneratedImages: (runId, nativeSessionId, images) => {
504
+ const turn = this.runtime.conversationTurnForRun(runId);
505
+ const session = turn === undefined ? undefined : this.runtime.getAgentSession(turn.sessionId);
506
+ return session === undefined
507
+ ? []
508
+ : this.marAgentClient.registerGeneratedImages(session, nativeSessionId, images);
509
+ }
510
+ }, {
511
+ modelFactory: this.marAgentRuntimeModels
512
+ });
513
+ this.marAgentClient.setSessionResourceReleaser((sessionId) => this.marAgentRunController.releaseSession(sessionId));
514
+ this.openCodeRunController = new OpenCodeManagedRunController(this.openCodeClient, {
515
+ intercepted: () => this.fakeRunner !== undefined,
516
+ active: this.runState.active,
517
+ parseAttachments: parseRunnerImageAttachments,
518
+ persistAttachments: (cwd, runId, attachments) => this.runAttachmentService.persistFiles(cwd, `${runId}-opencode-images`, attachments),
519
+ emit: (runId, eventType, payload, status) => this.runEventBridge.emitRun(runId, eventType, payload, status),
520
+ emitItem: (runId, item) => this.emitConversationItem(runId, item),
521
+ adopt: (input) => this.runtime.adoptRun(input),
522
+ run: (runId) => {
523
+ const run = this.runtime.getRun(runId);
524
+ if (run === undefined)
525
+ throw new Error('RUN_NOT_FOUND');
526
+ return run;
527
+ },
528
+ hasActiveSessionLease: (sessionId) => this.runtime.hasActiveSessionLease(sessionId),
529
+ promote: (sessionId, nativeSessionId) => this.sessionIdentityService.promote(sessionId, nativeSessionId),
530
+ rememberNative: (nativeSessionId, sessionId) => this.managedRunnerSessions.remember(nativeSessionId, sessionId),
531
+ send: (type, payload) => this.send(type, payload),
532
+ createApproval: (input) => this.runtime.createApproval(input),
533
+ expireApproval: (approvalId) => {
534
+ this.runtime.expireApproval(approvalId);
535
+ },
536
+ publishApproval: (input) => this.runEventBridge.publishApproval(input),
537
+ commandState: (sessionId, commandId) => this.commandStates.get(sessionId, commandId),
538
+ setCommandState: (sessionId, state) => this.commandStates.set(sessionId, state),
539
+ clearCommandState: (sessionId, commandId) => this.commandStates.clear(sessionId, commandId),
540
+ commandStates: (sessionId) => this.commandStates.list(sessionId)
541
+ }, this.claudeApprovalTimeoutMs);
542
+ this.claudeRunController = new ClaudeManagedRunController(this.claudeClient, {
543
+ intercepted: () => this.fakeRunner !== undefined,
544
+ active: this.runState.active,
545
+ parseAttachments: parseRunnerImageAttachments,
546
+ emit: (runId, eventType, payload, status) => this.runEventBridge.emitRun(runId, eventType, payload, status),
547
+ adopt: (input) => this.runtime.adoptRun(input),
548
+ run: (runId) => this.runtime.getRun(runId),
549
+ hasActiveSessionLease: (sessionId) => this.runtime.hasActiveSessionLease(sessionId),
550
+ session: (sessionId) => this.runtime.getAgentSession(sessionId),
551
+ completeCancelled: (runId) => this.runnerInteractionService.completeCancelledRun(runId),
552
+ requestUserInput: (runId, input, toolUseId) => this.runnerInteractionService.requestClaudeUserInput(runId, input, toolUseId),
553
+ requestApproval: (runId, toolName, input) => this.runnerInteractionService.requestClaudeApproval(runId, toolName, input),
554
+ rememberNative: (nativeSessionId, sessionId) => this.managedRunnerSessions.remember(nativeSessionId, sessionId),
555
+ promote: (sessionId, nativeSessionId) => this.sessionIdentityService.promote(sessionId, nativeSessionId),
556
+ send: (type, payload) => this.send(type, payload),
557
+ emitItem: (runId, item) => this.emitConversationItem(runId, item),
558
+ syncTitle: (sessionId, nativeSessionId, cwd) => this.managedRunnerSessions.refreshTitle(sessionId, nativeSessionId, cwd),
559
+ setChannelToken: (sessionId, token) => this.runtime.setChannelToken(sessionId, token),
560
+ commandState: (sessionId, commandId) => this.commandStates.get(sessionId, commandId),
561
+ setCommandState: (sessionId, state) => this.commandStates.set(sessionId, state),
562
+ clearCommandState: (sessionId, commandId) => this.commandStates.clear(sessionId, commandId),
563
+ commandStates: (sessionId) => this.commandStates.list(sessionId)
564
+ });
565
+ this.runners = new RunnerRegistry([
566
+ this.openCodeClient,
567
+ this.marAgentClient,
568
+ this.codexClient,
569
+ this.claudeClient,
570
+ ...(this.fakeRunner === undefined ? [] : [this.fakeRunner])
571
+ ]);
572
+ this.managedRunnerSessions = new ManagedRunnerSessionService(this.runtime, this.runners, (session) => this.emitSessionWorkbenchEvent({
573
+ session: this.sessionPresentationService.present(session)
574
+ }));
575
+ this.runnerInteractionService = new RunnerInteractionService({
576
+ runtime: this.runtime,
577
+ state: this.runState,
578
+ codex: () => this.codexClient,
579
+ claude: () => this.claudeClient,
580
+ runners: this.runners,
581
+ emitRun: (runId, eventType, payload, status) => this.runEventBridge.emitRun(runId, eventType, payload, status),
582
+ emitItem: (runId, item) => this.emitConversationItem(runId, item),
583
+ approvalTimeoutMs: this.claudeApprovalTimeoutMs,
584
+ publishApproval: (input) => this.runEventBridge.publishApproval(input)
585
+ });
586
+ this.runnerChannelMessages = new RunnerChannelMessageService({
587
+ interactions: this.runnerInteractionService,
588
+ send: (type, payload, replyTo) => this.send(type, payload, replyTo)
589
+ });
590
+ this.sessionPresentationService = new SessionPresentationService({
591
+ database: () => this.database,
592
+ runtime: this.runtime,
593
+ commands: this.commandStates,
594
+ runners: this.runners,
595
+ capabilities: () => this.capabilities,
596
+ hasManagedActiveRun: (session) => hasManagedActiveRun(this.runtime, session),
597
+ externalActivity: (sessionId) => this.sessionState.externalActivity.get(sessionId),
598
+ projectionForNative: (session) => this.nativeSessionProjectionService.projectionForNative(session)
599
+ });
600
+ this.nativeSessionProjectionService = new NativeSessionProjectionService({
601
+ database: () => this.database,
602
+ nodeId: () => this.config?.nodeId ?? 'recorded-session',
603
+ runtime: this.runtime,
604
+ runners: this.runners,
605
+ capabilities: () => this.capabilities,
606
+ state: this.sessionState,
607
+ commands: this.commandStates,
608
+ present: (session) => this.sessionPresentationService.present(session)
609
+ });
610
+ this.conversationHistoryService = new ConversationHistoryService({
611
+ runtime: this.runtime,
612
+ runners: this.runners,
613
+ capabilities: () => this.capabilities,
614
+ attachments: this.runAttachmentService,
615
+ snapshotSequence: () => this.workbenchEventService.snapshotSequence(),
616
+ hasManagedActiveRun: (session) => hasManagedActiveRun(this.runtime, session),
617
+ setExternalActivity: (sessionId, activity) => this.sessionState.externalActivity.set(sessionId, activity)
618
+ });
619
+ this.conversationSegmentService = new ConversationSegmentService((session, input) => this.conversationHistoryService.read(session, input));
620
+ this.sessionContextService = new SessionContextService({
621
+ runners: this.runners,
622
+ session: (sessionId) => this.runtime.getAgentSession(sessionId),
623
+ stopped: () => this.stopped,
624
+ publish: (payload) => this.emitSessionWorkbenchEvent(payload)
625
+ });
626
+ this.runWorkbenchService = new RunWorkbenchService({
627
+ runtime: this.runtime,
628
+ readImage: async (runId, imageIndex) => this.runAttachmentService.read(runId, imageIndex) ??
629
+ (await this.runAttachmentService.readNative(runId, imageIndex)),
630
+ respondUserInput: (runId, requestId, answers) => this.runnerInteractionService.respondUserInput(runId, requestId, answers),
631
+ pauseQueue: (sessionId) => this.workspaceQueueWorkbenchService.pauseSessionQueue(sessionId),
632
+ emitRun: (runId, eventType, payload, status) => this.runEventBridge.emitRun(runId, eventType, payload, status),
633
+ control: (operation, payload) => this.controlMessages.handle(JSON.stringify(createEnvelope(operation, payload))),
634
+ markInterrupted: (runId) => this.runState.interruptRequested.add(runId)
635
+ });
636
+ this.sessionQueryService = new SessionQueryService({
637
+ runtime: this.runtime,
638
+ runners: this.runners,
639
+ resolve: (sessionId) => this.nativeSessionProjectionService.resolve(sessionId),
640
+ present: (session) => this.sessionPresentationService.present(session),
641
+ history: (session, input) => this.conversationHistoryService.read(session, input),
642
+ segments: (session, input) => this.conversationSegmentService.read(session, input),
643
+ context: this.sessionContextService,
644
+ discover: (runner, workspaceId) => this.nativeSessionProjectionService.discover(runner, workspaceId),
645
+ workspaceIdForCwd: (cwd) => this.database?.listWorkspaces().find((candidate) => candidate.path === cwd)?.id
646
+ });
647
+ this.continuousRunCoordinator = new ContinuousRunCoordinator({
648
+ runtime: this.runtime,
649
+ emitQueue: (workspaceId, sessionId) => this.runEventBridge.emitQueue(workspaceId, sessionId),
650
+ clearImages: (runId) => this.runAttachmentService.clear(runId),
651
+ cleanupAttachments: (runId) => this.runAttachmentService.cleanup(runId),
652
+ migrateAssets: (previousId, nextId) => this.runAttachmentService.move(previousId, nextId),
653
+ emitRun: (runId, eventType, payload, status) => this.runEventBridge.emitRun(runId, eventType, payload, status),
654
+ emitConversation: (turn) => this.emitConversationTurn(turn),
655
+ control: (operation, payload) => this.controlMessages.handle(JSON.stringify(createEnvelope(operation, payload))),
656
+ stopped: () => this.stopped,
657
+ markInterrupted: (runId) => this.runState.interruptRequested.add(runId),
658
+ mcps: (workspaceId) => this.database?.effectiveMcpInstallations(workspaceId) ?? [],
659
+ retainEnvironment: (environment) => this.gitExecution().retain(environment),
660
+ afterExecutionStarted: async (input) => {
661
+ if (input.mission === undefined)
662
+ return;
663
+ const mission = this.missionRuntime.get(input.sessionId);
664
+ if (mission?.status !== 'active' ||
665
+ mission.id !== input.mission.id ||
666
+ mission.revision !== input.mission.revision)
667
+ return;
668
+ const updated = this.missionRuntime.recordTurn(input.sessionId);
669
+ const session = this.runtime.getAgentSession(input.sessionId);
670
+ if (updated !== undefined && session !== undefined)
671
+ this.publishMissionState(session, updated);
672
+ await this.enqueueMissionContinuation({
673
+ sessionId: input.sessionId,
674
+ mission: { id: mission.id, revision: mission.revision },
675
+ secretEnvironment: input.secretEnvironment,
676
+ ...(input.personalInstructions === undefined
677
+ ? {}
678
+ : { personalInstructions: input.personalInstructions }),
679
+ ...(input.marAgentModel === undefined ? {} : { marAgentModel: input.marAgentModel }),
680
+ ...(input.marAgentModels === undefined ? {} : { marAgentModels: input.marAgentModels }),
681
+ ...(input.marAgentRuntimeScopeId === undefined
682
+ ? {}
683
+ : { marAgentRuntimeScopeId: input.marAgentRuntimeScopeId })
684
+ });
685
+ },
686
+ missionMcp: async (input) => {
687
+ if (input.mission === undefined)
688
+ throw new Error('MISSION_NOT_ACTIVE');
689
+ const resolved = await this.missionMcpServer.installation({
690
+ executionId: input.runId,
691
+ sessionId: input.sessionId,
692
+ missionId: input.mission.id,
693
+ revision: input.mission.revision
694
+ });
695
+ return {
696
+ installation: {
697
+ targetKind: 'WORKSPACE',
698
+ targetId: input.workspaceId,
699
+ catalogEntryId: 'mar-internal-mission',
700
+ serverName: 'myagentroam_mission',
701
+ displayName: 'Mission',
702
+ version: '1.0.0',
703
+ enabled: true,
704
+ runtime: { transport: 'HTTP', url: 'https://127.0.0.1.invalid/mcp', headers: {} },
705
+ configuration: resolved.installation,
706
+ installedAt: Date.now(),
707
+ ...resolved.installation
708
+ },
709
+ secrets: resolved.secrets
710
+ };
711
+ }
712
+ });
713
+ this.workspaceQueueWorkbenchService = new WorkspaceQueueWorkbenchService({
714
+ runtime: this.runtime,
715
+ coordinator: this.continuousRunCoordinator,
716
+ emit: (workspaceId, sessionId) => this.runEventBridge.emitQueue(workspaceId, sessionId),
717
+ prepareInput: (runner, input, collaborationMode) => this.runners.require(runner).prepareMessageInput(input, collaborationMode)
718
+ });
719
+ this.sessionIdentityService = new SessionIdentityService({
720
+ runtime: this.runtime,
721
+ persist: (session, nativeSessionId) => {
722
+ if (session.model === null || session.effort === null || session.access === null)
723
+ return;
724
+ this.database?.saveNativeSessionMetadata({
725
+ runner: session.runner,
726
+ externalSessionId: nativeSessionId,
727
+ workspaceId: session.workspaceId,
728
+ model: session.model,
729
+ effort: session.effort,
730
+ access: session.access
731
+ });
732
+ },
733
+ migrateCommands: (previousId, nextId) => this.commandStates.promoteSessionIdentity(previousId, nextId),
734
+ migrateMission: (previousId, nextId) => {
735
+ this.missionRuntime.migrateSession(previousId, nextId);
736
+ this.missionMcpServer.migrateSession(previousId, nextId);
737
+ const retry = this.missionRetryTimers.get(previousId);
738
+ if (retry !== undefined) {
739
+ this.missionRetryTimers.delete(previousId);
740
+ retry.sessionId = nextId;
741
+ this.missionRetryTimers.set(nextId, retry);
742
+ }
743
+ const pendingContinuation = this.missionContinuationPending.get(previousId);
744
+ if (pendingContinuation !== undefined) {
745
+ this.missionContinuationPending.delete(previousId);
746
+ this.missionContinuationPending.set(nextId, pendingContinuation);
747
+ }
748
+ },
749
+ migrateQueue: (previousId, nextId) => this.continuousRunCoordinator.migrateSession(previousId, nextId),
750
+ migrateRunnerState: (previousId, nextId) => this.runEventBridge.migrateRunnerSessionIdentity(previousId, nextId),
751
+ emitSession: (session) => this.emitSessionWorkbenchEvent({ session }),
752
+ emitRun: (run) => this.emitWorkbenchEvent('run', { run }),
753
+ emitQueue: (sessionId) => this.continuousRunCoordinator.publish(sessionId),
754
+ emitTurn: (turn) => this.emitConversationTurn(turn)
755
+ });
756
+ this.sessionLifecycleService = new SessionLifecycleService({
757
+ database: () => {
758
+ if (this.database === undefined)
759
+ throw new Error('NODE_DATABASE_UNAVAILABLE');
760
+ return this.database;
761
+ },
762
+ runtime: this.runtime,
763
+ runners: this.runners,
764
+ projection: this.nativeSessionProjectionService,
765
+ identity: this.sessionIdentityService,
766
+ present: (session) => this.sessionPresentationService.present(session),
767
+ emitSession: (session) => this.emitSessionWorkbenchEvent({
768
+ session: this.sessionPresentationService.present(session)
769
+ }),
770
+ execute: (operation, data) => this.executeNodeOperation(operation, data),
771
+ interceptedSessionId: (clientMessageId) => this.fakeRunner === undefined ? undefined : `fake:${clientMessageId}`
772
+ });
773
+ this.externalSessionResumeService = new ExternalSessionResumeService({
774
+ runtime: this.runtime,
775
+ runners: this.runners,
776
+ state: this.sessionState,
777
+ available: (runner) => this.runners.require(runner).available(this.capabilities),
778
+ projectionFor: (session) => this.nativeSessionProjectionService.projectionForNative(session),
779
+ managedAliasFor: (session) => this.nativeSessionProjectionService.managedForNative(session),
780
+ ensureConfiguration: (session) => this.nativeSessionProjectionService.ensureResumedConfiguration(session),
781
+ configuration: (session) => this.nativeSessionProjectionService.resumedConfiguration(session),
782
+ workspacePath: (workspaceId) => this.database?.getWorkspace(workspaceId)?.path,
783
+ rememberNative: (nativeSessionId, sessionId) => this.managedRunnerSessions.remember(nativeSessionId, sessionId),
784
+ stage: (session) => {
785
+ const configuration = this.nativeSessionProjectionService.resumedConfiguration(session);
786
+ return this.runtime.createAgentSession({
787
+ workspaceId: session.workspaceId,
788
+ runner: session.runner,
789
+ externalSessionId: session.externalSessionId ?? session.id,
790
+ nativeControl: 'EXTERNAL',
791
+ cwd: session.cwd,
792
+ model: configuration.model,
793
+ effort: configuration.effort,
794
+ access: configuration.access,
795
+ ...(session.runnerTitle === null ? {} : { title: session.runnerTitle }),
796
+ ...(session.customTitle === null ? {} : { customTitle: session.customTitle })
797
+ });
798
+ },
799
+ resolve: (sessionId) => this.nativeSessionProjectionService.resolve(sessionId)
800
+ });
801
+ this.sessionCommandService = new SessionCommandService({
802
+ runtime: this.runtime,
803
+ runners: this.runners,
804
+ projection: this.nativeSessionProjectionService,
805
+ resume: this.externalSessionResumeService,
806
+ profiles: () => this.runnerService.profiles(),
807
+ present: (session) => this.sessionPresentationService.present(session),
808
+ resumeQueueAfterCommandRun: (sessionId) => this.workspaceQueueWorkbenchService.resumeAfterCommandRun(sessionId),
809
+ invalidateHistory: (sessionId) => this.nativeSessionWatchService.invalidate(sessionId),
810
+ invalidateWorkspaceSessions: (workspaceId) => {
811
+ this.workspaceSessionService.invalidateCache(workspaceId);
812
+ void this.workspaceWorkbenchService?.invalidateTopic(workspaceId, 'sessions');
813
+ },
814
+ emitSession: (session) => this.emitSessionWorkbenchEvent({
815
+ session: this.sessionPresentationService.present(session)
816
+ }),
817
+ beginMission: (session) => {
818
+ const existing = this.commandStates.get(session.id, 'mission');
819
+ if (existing?.active === true)
820
+ return {
821
+ session: this.sessionPresentationService.present(session),
822
+ missionAlreadyActive: true
823
+ };
824
+ if (existing !== undefined) {
825
+ this.missionRuntime.clear(session.id);
826
+ this.commandStates.clear(session.id, 'mission');
827
+ }
828
+ const prepared = this.prepareMissionSession(session);
829
+ this.continuousRunCoordinator.removePendingQueue(session.id);
830
+ this.commandStates.set(session.id, this.pendingMissionCommandState());
831
+ this.emitWorkbenchEvent('session', {
832
+ session: this.sessionPresentationService.present(prepared.session)
833
+ });
834
+ return {
835
+ session: this.sessionPresentationService.present(prepared.session),
836
+ missionAccessChanged: prepared.changed
837
+ };
838
+ },
839
+ mission: async ({ session, objective, secretEnvironment, personalInstructions, marAgentModel, marAgentModels, marAgentRuntimeScopeId }) => {
840
+ this.clearMissionRetry(session.id);
841
+ const prepared = this.prepareMissionSession(session);
842
+ const missionSession = prepared.session;
843
+ const activeRun = this.runtime.activeSessionRun(session.id);
844
+ const replacing = activeRun !== undefined && this.runtime.currentExecutionId(activeRun.id) !== undefined;
845
+ this.continuousRunCoordinator.removeMissionQueue(session.id);
846
+ const mission = this.missionRuntime.start(session.id, objective);
847
+ this.publishMissionState(missionSession, mission);
848
+ const result = await this.sessionMessageService.submitMission({
849
+ sessionId: session.id,
850
+ kind: 'start',
851
+ content: this.missionRuntime.prompt(session.id, 'start'),
852
+ deliveryIntent: replacing ? 'REPLACE_CURRENT' : 'SEND',
853
+ mission: { id: mission.id, revision: mission.revision },
854
+ secretEnvironment,
855
+ ...(personalInstructions === undefined ? {} : { personalInstructions }),
856
+ ...(marAgentModel === undefined ? {} : { marAgentModel }),
857
+ ...(marAgentModels === undefined ? {} : { marAgentModels }),
858
+ ...(marAgentRuntimeScopeId === undefined ? {} : { marAgentRuntimeScopeId })
859
+ });
860
+ return {
861
+ ...(isPlainRecord(result) ? result : { result }),
862
+ missionAccessChanged: prepared.changed
863
+ };
864
+ },
865
+ clearMission: (session) => {
866
+ this.clearMissionRetry(session.id);
867
+ this.missionRuntime.clear(session.id);
868
+ this.continuousRunCoordinator.removeMissionQueue(session.id);
869
+ this.finishIdleMissionRun(session.id, 'SUCCEEDED');
870
+ this.commandStates.clear(session.id, 'mission');
871
+ this.emitWorkbenchEvent('session', {
872
+ session: this.sessionPresentationService.present(session)
873
+ });
874
+ return { session: this.sessionPresentationService.present(session), cleared: true };
875
+ }
876
+ });
877
+ this.sessionMessageService = new SessionMessageService({
878
+ runtime: this.runtime,
879
+ uploads: this.workspaceUploadService,
880
+ attachments: this.runAttachmentService,
881
+ commands: this.commandStates,
882
+ coordinator: this.continuousRunCoordinator,
883
+ runners: this.runners,
884
+ resolve: (sessionId) => this.externalSessionResumeService.acceptForMessage(sessionId),
885
+ present: (session) => this.sessionPresentationService.present(session),
886
+ emitSession: (session) => this.emitSessionWorkbenchEvent({
887
+ session: this.sessionPresentationService.present(session)
888
+ }),
889
+ channelToken: (sessionId) => {
890
+ const session = this.runtime.getAgentSession(sessionId);
891
+ return session?.channelToken ?? undefined;
892
+ },
893
+ missionMessage: (session, content) => {
894
+ const state = this.commandStates.get(session.id, 'mission');
895
+ if (state?.active !== true)
896
+ return undefined;
897
+ const current = this.missionRuntime.get(session.id);
898
+ if (current?.status === 'active') {
899
+ return {
900
+ runnerContent: content,
901
+ mission: { id: current.id, revision: current.revision },
902
+ activated: false
903
+ };
904
+ }
905
+ const mission = this.missionRuntime.start(session.id, content);
906
+ this.publishMissionState(session, mission);
907
+ return {
908
+ runnerContent: this.missionRuntime.prompt(session.id, 'start'),
909
+ mission: { id: mission.id, revision: mission.revision },
910
+ activated: true
911
+ };
912
+ },
913
+ prepareMissionInsertion: (sessionId, submissionId) => this.continuousRunCoordinator.removePendingQueue(sessionId, submissionId),
914
+ missionPreparationFailed: (session, mission, activated) => {
915
+ if (!activated)
916
+ return;
917
+ const current = this.missionRuntime.get(session.id);
918
+ if (current?.id !== mission.id || current.revision !== mission.revision)
919
+ return;
920
+ this.missionRuntime.clear(session.id);
921
+ this.finishIdleMissionRun(session.id, 'FAILED');
922
+ this.commandStates.set(session.id, this.pendingMissionCommandState());
923
+ this.emitWorkbenchEvent('session', {
924
+ session: this.sessionPresentationService.present(session)
925
+ });
926
+ }
927
+ });
928
+ this.sessionCatalogService = new SessionCatalogService({
929
+ database: () => {
930
+ if (this.database === undefined)
931
+ throw new Error('NODE_DATABASE_UNAVAILABLE');
932
+ return this.database;
933
+ },
934
+ nodeId: () => this.config?.nodeId ?? 'recorded-session',
935
+ runtime: this.runtime,
936
+ runners: this.runners,
937
+ projection: this.nativeSessionProjectionService,
938
+ resume: this.externalSessionResumeService,
939
+ cachedNative: () => [...this.sessionState.directNative.values()],
940
+ cachedWorkspace: (workspaceId) => this.workspaceCoordinator.cachedSessions(workspaceId),
941
+ discoverWorkspace: (workspaceId) => this.nativeSessionProjectionService.discoverWorkspace(workspaceId),
942
+ present: (session) => this.sessionPresentationService.present(session),
943
+ projectionForNative: (session) => this.nativeSessionProjectionService.projectionForNative(session),
944
+ nativeIds: (session) => this.nativeSessionProjectionService.nativeIds(session),
945
+ forget: (session, nativeIds) => this.nativeSessionProjectionService.forget(session, nativeIds),
946
+ refreshActivity: (session) => this.conversationHistoryService.refreshExternalActivity(session),
947
+ externalActivity: (sessionId) => this.sessionState.externalActivity.get(sessionId),
948
+ isWatching: (sessionId) => this.nativeSessionWatchService.isWatching(sessionId),
949
+ history: (session, input) => this.conversationHistoryService.read(session, input),
950
+ invalidateHistory: (sessionId) => this.nativeSessionWatchService.invalidate(sessionId),
951
+ invalidateWorkspaceSessions: (workspaceId) => {
952
+ this.workspaceSessionService.invalidateCache(workspaceId);
953
+ void this.workspaceWorkbenchService?.invalidateTopic(workspaceId, 'sessions');
954
+ },
955
+ emitSession: (session) => this.emitSessionWorkbenchEvent({
956
+ session: this.sessionPresentationService.present(session)
957
+ })
958
+ });
959
+ this.codexClient.bindControl({
960
+ start: (envelope) => this.codexRunController.start(envelope),
961
+ cancel: (runId, intent) => {
962
+ const run = this.codexClient.execution.runs.get(runId);
963
+ if (run?.turnId === undefined)
964
+ return false;
965
+ void this.runnerInteractionService.cancelCodexTurn(runId, run.threadId, run.turnId, run.cwd, intent === 'CANCEL' ? 'CANCELLED' : 'INTERRUPTED');
966
+ return true;
967
+ },
968
+ decideApproval: (input) => this.runnerInteractionService.decideCodexApproval(input.approvalId, input.decision)
969
+ });
970
+ this.claudeClient.bindControl({
971
+ start: (envelope) => this.claudeRunController.start(envelope),
972
+ cancel: (runId, intent) => this.runnerInteractionService.cancelClaudeRun(runId, intent),
973
+ decideApproval: (input) => this.runnerInteractionService.decideClaudeApproval(input.approvalId, input.decision)
974
+ });
975
+ this.openCodeClient.bindControl({
976
+ start: (envelope) => this.openCodeRunController.start(envelope),
977
+ cancel: (runId, intent) => this.openCodeRunController.cancel(runId, intent),
978
+ decideApproval: (input) => this.openCodeRunController.decideApproval(input),
979
+ respondUserInput: (runId, requestId, answers) => this.openCodeRunController.respondUserInput(runId, requestId, answers)
980
+ });
981
+ this.marAgentClient.bindControl({
982
+ start: (envelope) => this.marAgentRunController.start(envelope),
983
+ cancel: (runId, intent) => this.marAgentRunController.cancel(runId, intent),
984
+ decideApproval: (input) => this.marAgentRunController.decideApproval(input),
985
+ respondUserInput: (runId, requestId, answers) => this.marAgentRunController.respondUserInput(runId, requestId, answers)
986
+ });
987
+ this.codexClient.bindCommandControl({
988
+ execute: (session, command, input, context) => this.codexRunController.executeCommand(session, command, input, context)
989
+ });
990
+ this.claudeClient.bindCommandControl({
991
+ execute: (session, command, input, context) => this.claudeRunController.executeCommand(session, command, input, context)
992
+ });
993
+ this.openCodeClient.bindCommandControl({
994
+ execute: (session, command, _input, context) => this.openCodeRunController.executeCommand(session, command, context)
995
+ });
996
+ this.marAgentClient.bindCommandControl({
997
+ execute: (session, command, input, context) => this.marAgentRunController.executeCommand(session, command, input, context)
998
+ });
999
+ const fakeRuns = this.fakeRunner === undefined || this.fakeScript === undefined
1000
+ ? undefined
1001
+ : new FakeManagedRunService({
1002
+ runner: this.fakeRunner,
1003
+ script: this.fakeScript,
1004
+ runners: this.runners,
1005
+ runtime: this.runtime,
1006
+ state: this.runState,
1007
+ emitRun: (runId, type, payload, status) => this.runEventBridge.emitRun(runId, type, payload, status),
1008
+ publishApproval: (input) => this.runEventBridge.publishApproval(input),
1009
+ disconnect: () => this.controlChannel.close(4010, 'FAKE_RUNNER_DISCONNECT')
1010
+ });
1011
+ this.fakeRunner?.bindControl({
1012
+ start: (envelope) => fakeRuns?.start(envelope),
1013
+ cancel: (runId, intent) => intent === 'CANCEL'
1014
+ ? (this.fakeRunner?.cancel(runId) ?? false)
1015
+ : (this.fakeRunner?.interrupt(runId) ?? false),
1016
+ decideApproval: (input) => this.fakeRunner?.decide(input.runId, input.approvalId, input.decision) ?? false
1017
+ });
1018
+ this.runnerUsageReader = options.runnerUsageReader ?? new RunnerUsageReader();
1019
+ this.database = options.database;
1020
+ this.terminalManager =
1021
+ options.terminalManager ??
1022
+ new TerminalManager({
1023
+ platform: this.capabilities.platform === 'windows'
1024
+ ? 'win32'
1025
+ : this.capabilities.platform === 'macos'
1026
+ ? 'darwin'
1027
+ : 'linux'
1028
+ });
1029
+ this.terminalManager.onSummary((summary) => this.workspaceCoordinator.persistTerminal(summary));
1030
+ this.terminalChannel = new NodeTerminalChannel({
1031
+ config: () => this.config,
1032
+ controlConnected: () => this.controlChannel.connected(),
1033
+ stopped: () => this.stopped,
1034
+ reconnect: this.reconnect,
1035
+ reconnectDelay: nextReconnectDelay,
1036
+ manager: this.terminalManager
1037
+ });
1038
+ this.controlChannel = new NodeControlChannel({
1039
+ config: () => this.config,
1040
+ capabilities: () => this.capabilities,
1041
+ stopped: () => this.stopped,
1042
+ reconnect: this.reconnect,
1043
+ reconnectDelay: nextReconnectDelay,
1044
+ onConnecting: (attempt) => {
1045
+ this.metrics.connectedAttempt();
1046
+ nodeLog('node.connecting', { attempt });
1047
+ },
1048
+ onReconnectScheduled: () => this.metrics.reconnectScheduled(),
1049
+ onMessage: (raw) => this.handleMessage(raw),
1050
+ onClose: (code, reason) => {
1051
+ this.runtimeCredentials.disconnected();
1052
+ this.terminalChannel.disconnect();
1053
+ if (code === 4000 && reason === 'NODE_CONNECTION_REPLACED')
1054
+ nodeLog('node.connection.replaced', {
1055
+ message: 'This Node connection was replaced by a newer instance with the same identity. Check for duplicate processes.'
1056
+ });
1057
+ if (code === 4003 || code === 1001)
1058
+ void this.terminalManager.shutdown();
1059
+ }
1060
+ });
1061
+ this.controlMessages = new NodeControlMessageService({
1062
+ config: () => this.config,
1063
+ register: (nodeId, credential) => this.connectionLifecycle.register(nodeId, credential),
1064
+ connected: () => this.connectionLifecycle.connected(),
1065
+ close: (code, reason) => this.controlChannel.close(code, reason),
1066
+ inspectWorkspace: (envelope) => this.workspaceCoordinator.inspect(envelope),
1067
+ handleNodeRequest: (envelope) => this.nodeRequests.handle(envelope),
1068
+ handleRuntimeCredentialResponse: (envelope) => this.runtimeCredentials.handle(envelope),
1069
+ reconcileRuns: (envelope) => this.runEventBridge.reconcile(envelope),
1070
+ runners: this.runners,
1071
+ deliverSessionChannelMessage: (envelope) => this.runnerChannelMessages.handle(envelope),
1072
+ completeUncontrolledCancellation: (runId) => {
1073
+ const run = this.runtime.getRun(runId);
1074
+ if (run?.status === 'CANCELLING')
1075
+ this.runnerInteractionService.completeCancelledRun(runId);
1076
+ },
1077
+ send: (type, payload, replyTo) => this.send(type, payload, replyTo)
1078
+ });
1079
+ this.nodeRequests = new NodeRequestService({
1080
+ nodeId: () => this.config?.nodeId,
1081
+ databaseAvailable: () => this.database !== undefined,
1082
+ execute: (operation, data) => this.executeNodeOperation(operation, data),
1083
+ send: (type, payload, replyTo) => this.send(type, payload, replyTo)
1084
+ });
1085
+ this.workspaceCoordinator = new NodeWorkspaceCoordinator({
1086
+ config: () => this.config,
1087
+ database: () => this.database,
1088
+ watches: this.workspaceWatchService,
1089
+ sessions: this.workspaceSessionService,
1090
+ changes: this.workspaceChangeService,
1091
+ emit: (workspaceId, topic) => void this.workspaceWorkbenchService?.invalidateTopic(workspaceId, topic),
1092
+ send: (type, payload, replyTo) => this.send(type, payload, replyTo)
1093
+ });
1094
+ this.runEventBridge = new NodeRunEventBridge({
1095
+ runtime: this.runtime,
1096
+ state: this.runState,
1097
+ events: this.runEventService,
1098
+ emitWorkbench: (category, payload) => this.publishWorkbenchEvent(category, payload),
1099
+ queues: this.workspaceQueueWorkbenchService,
1100
+ codex: this.codexClient,
1101
+ claude: this.claudeClient,
1102
+ openCode: this.openCodeClient,
1103
+ send: (type, payload, replyTo) => this.send(type, payload, replyTo)
1104
+ });
1105
+ this.connectionLifecycle = new NodeConnectionLifecycleService({
1106
+ config: () => this.config,
1107
+ setConfig: (config) => (this.config = config),
1108
+ configPath: this.configPath,
1109
+ capabilities: () => this.capabilities,
1110
+ detectCapabilities: this.capabilityDetector,
1111
+ capabilitiesProvided: this.capabilitiesProvided,
1112
+ stopped: () => this.stopped,
1113
+ setCapabilities: (capabilities) => (this.capabilities = {
1114
+ ...capabilities,
1115
+ metadata: upgradeMetadata(capabilities.metadata, this.upgradeCoordinator.snapshot())
1116
+ }),
1117
+ control: this.controlChannel,
1118
+ terminal: this.terminalChannel,
1119
+ metrics: this.metrics,
1120
+ heartbeatMs: HEARTBEAT_MS,
1121
+ refreshMs: CAPABILITY_REFRESH_MS,
1122
+ onRegistered: () => this.initializeConversationHosting(),
1123
+ onConnected: () => {
1124
+ this.runtimeCredentials.connected();
1125
+ this.recentRunProjectionService.publishSnapshot();
1126
+ }
1127
+ });
1128
+ const requireDatabase = () => {
1129
+ if (this.database === undefined)
1130
+ throw new Error('NODE_DATABASE_UNAVAILABLE');
1131
+ return this.database;
1132
+ };
1133
+ this.runnerService = new RunnerService(requireDatabase, () => this.capabilities, this.runners, this.runnerUsageReader);
1134
+ this.workbenchManifestService = new WorkbenchManifestService({
1135
+ capabilities: () => this.capabilities,
1136
+ runners: this.runnerService,
1137
+ terminals: this.terminalManager
1138
+ });
1139
+ this.terminalService = new TerminalService(requireDatabase, this.terminalManager, (environment) => this.gitExecution().retain(environment));
1140
+ this.workspaceService = new WorkspaceService(requireDatabase, () => {
1141
+ if (this.config === undefined)
1142
+ throw new Error('NODE_CONFIG_UNAVAILABLE');
1143
+ return this.config;
1144
+ }, this.runtime, (workspaceId) => {
1145
+ this.workspaceFileService.dispose(workspaceId);
1146
+ this.workspaceCoordinator.invalidateChanges(workspaceId);
1147
+ this.workspaceSessionService.invalidate(workspaceId);
1148
+ this.workspaceCoordinator.clearWatches(workspaceId);
1149
+ });
1150
+ this.workspaceWorkbenchService = new WorkspaceWorkbenchService({
1151
+ requireWorkspace: (workspaceId) => this.workspaceCoordinator.require(workspaceId),
1152
+ inspectWorkspace: (workspace) => this.workspaceCoordinator.inspectMetadata(workspace),
1153
+ commitWorkspace: (workspace, inspection) => this.workspaceCoordinator.commitMetadata(workspace, inspection),
1154
+ watch: this.workspaceWatchService,
1155
+ files: this.workspaceFileService,
1156
+ uploads: this.workspaceUploadService,
1157
+ changes: this.workspaceChangeService,
1158
+ listSessions: (workspaceId) => this.executeNodeOperation('session.list', { workspaceId, limit: 20 }),
1159
+ invalidate: (workspaceId) => {
1160
+ this.workspaceFileService.dispose(workspaceId);
1161
+ this.workspaceCoordinator.invalidate(workspaceId);
1162
+ },
1163
+ nodeId: () => this.config?.nodeId ?? 'runtime-node',
1164
+ nodeGeneration: () => this.nodeGeneration,
1165
+ emitWatchEvent: (payload) => this.send('watch.event', payload)
1166
+ });
1167
+ for (const operation of CONVERSATION_TEMPLATE_OPERATIONS)
1168
+ this.operationRouter.register(operation, (data) => {
1169
+ const handler = this.conversationTemplateOperations?.[operation];
1170
+ if (handler === undefined)
1171
+ throw new Error('CONVERSATION_HOSTING_UNAVAILABLE');
1172
+ return handler(data);
1173
+ });
1174
+ for (const operation of HOSTED_CONVERSATION_OPERATIONS)
1175
+ this.operationRouter.register(operation, (data) => {
1176
+ const handler = this.hostedConversationOperations?.[operation];
1177
+ if (handler === undefined)
1178
+ throw new Error('CONVERSATION_HOSTING_UNAVAILABLE');
1179
+ return handler(data);
1180
+ });
1181
+ for (const operation of CONVERSATION_HOSTING_MAINTENANCE_OPERATIONS)
1182
+ this.operationRouter.register(operation, (data) => {
1183
+ const handler = this.conversationHostingMaintenanceOperations?.[operation];
1184
+ if (handler === undefined)
1185
+ throw new Error('CONVERSATION_HOSTING_UNAVAILABLE');
1186
+ return handler(data);
1187
+ });
1188
+ this.operationRouter.registerAll(this.runnerService.operations());
1189
+ this.operationRouter.registerAll(this.terminalService.operations());
1190
+ this.operationRouter.registerAll(this.workspaceService.operations());
1191
+ this.operationRouter.registerAll(this.workspaceWorkbenchService.operations());
1192
+ this.operationRouter.registerAll(this.runWorkbenchService.operations());
1193
+ this.operationRouter.registerAll(this.nativeSessionWatchService.operations());
1194
+ this.operationRouter.registerAll(this.sessionQueryService.operations());
1195
+ this.operationRouter.registerAll(this.sessionLifecycleService.operations());
1196
+ this.operationRouter.registerAll(this.sessionMessageService.operations());
1197
+ this.operationRouter.registerAll(this.sessionCatalogService.operations());
1198
+ this.operationRouter.registerAll(this.sessionCommandService.operations());
1199
+ this.operationRouter.registerAll(this.workspaceQueueWorkbenchService.operations());
1200
+ this.operationRouter.registerAll(this.marAgentModelTransportTests.operations());
1201
+ this.operationRouter.registerAll(new ConversationHostingEnablementService({
1202
+ config: () => this.config,
1203
+ setConfig: (config) => (this.config = config),
1204
+ configPath: this.configPath,
1205
+ platform: () => this.capabilities.platform,
1206
+ capability: () => this.capabilities.conversationHosting,
1207
+ initialize: () => this.initializeConversationHosting(),
1208
+ prepareForDisable: () => this.hostedConversationService?.prepareForDisable() ?? (() => { }),
1209
+ publishCapabilities: () => this.send('capabilities', this.capabilities)
1210
+ }).operations());
1211
+ this.operationRouter.registerAll(new SkillNodeOperationService(requireDatabase, () => {
1212
+ if (this.config === undefined)
1213
+ throw new Error('NODE_CONFIG_UNAVAILABLE');
1214
+ return this.config;
1215
+ }).operations());
1216
+ this.operationRouter.registerAll(new McpNodeOperationService(requireDatabase).operations());
1217
+ this.operationRouter.register('node.metrics', () => ({
1218
+ metrics: {
1219
+ ...this.metrics.snapshot(),
1220
+ activeRuns: this.runState.active.size,
1221
+ workspaceLeases: this.runtime.activeWorkspaceLeaseCount()
1222
+ }
1223
+ }));
1224
+ this.operationRouter.register('node.upgrade.request', (data) => this.upgradeCoordinator.request(data));
1225
+ this.operationRouter.register('node.upgrade.cancel', () => this.upgradeCoordinator.cancel());
1226
+ this.operationRouter.register('node.workbench.capabilities', async () => ({
1227
+ manifest: await this.workbenchManifestService.read()
1228
+ }));
1229
+ }
1230
+ async initializeConversationHosting() {
1231
+ const previousRuntime = this.hostedConversationRuntime;
1232
+ const previousService = this.hostedConversationService;
1233
+ const previousMaintenance = this.conversationHostingMaintenanceService;
1234
+ this.hostedConversationRuntime = undefined;
1235
+ this.hostedConversationService = undefined;
1236
+ this.conversationHostingMaintenanceService = undefined;
1237
+ this.hostedConversationOperations = undefined;
1238
+ this.conversationHostingMaintenanceOperations = undefined;
1239
+ this.conversationTemplateOperations = undefined;
1240
+ this.conversationHostingStorageReady = false;
1241
+ this.conversationHostingFailureCode = undefined;
1242
+ await previousMaintenance?.dispose();
1243
+ previousService?.dispose();
1244
+ await previousRuntime?.dispose().catch(() => undefined);
1245
+ const config = this.config;
1246
+ if (config?.conversationHosting?.enabled === true && this.capabilities.platform === 'linux') {
1247
+ if (config.nodeId === undefined) {
1248
+ this.conversationHostingFailureCode = 'NODE_UNAUTHENTICATED';
1249
+ }
1250
+ else {
1251
+ let runtime;
1252
+ let hostedService;
1253
+ let maintenanceService;
1254
+ try {
1255
+ if (this.database === undefined)
1256
+ throw new Error('NODE_DATABASE_UNAVAILABLE');
1257
+ const rootDirectory = hostedConversationStorePath(config, this.configPath);
1258
+ if (rootDirectory === undefined)
1259
+ throw new Error('CONVERSATION_HOSTING_STORAGE_UNAVAILABLE');
1260
+ const store = new HostedConversationStore({
1261
+ dataDirectory: nodeDataDirectory(config, this.configPath),
1262
+ rootDirectory,
1263
+ nodeId: config.nodeId,
1264
+ database: this.database
1265
+ });
1266
+ await store.initialize();
1267
+ const templateService = new ConversationTemplateNodeService({
1268
+ database: this.database,
1269
+ store,
1270
+ nodeId: () => this.config?.nodeId ?? 'unregistered'
1271
+ });
1272
+ await templateService.recoverInterruptedPublications();
1273
+ await store.rebuildConversationIndex();
1274
+ runtime = new MarAgentHostedConversationRuntime({
1275
+ webSearch: (input, signal) => this.webSearch(input, signal),
1276
+ modelFactory: this.marAgentRuntimeModels,
1277
+ registerNativeImages: (runId, roots, images) => this.runAttachmentService.registerNativeImages(runId, roots, images, {
1278
+ reuseCachedRunImages: false
1279
+ })
1280
+ });
1281
+ hostedService = new HostedConversationNodeService({
1282
+ database: this.database,
1283
+ store,
1284
+ runtime,
1285
+ nodeId: () => this.config?.nodeId ?? 'unregistered',
1286
+ nodeAppVersion: () => this.capabilities.nodeAppVersion ?? 'unknown',
1287
+ nodeGeneration: () => this.nodeGeneration,
1288
+ sessionWatchSlots: this.sessionWatchSlots,
1289
+ emitWatchEvent: (payload) => this.send('watch.event', payload),
1290
+ nextWorkbenchEvent: (payload) => this.workbenchEventService.next('hosted-conversation', payload),
1291
+ emitWorkbenchEvent: (event) => this.workbenchEventService.publish(event),
1292
+ readImage: async (runId, imageIndex) => this.runAttachmentService.read(runId, imageIndex) ??
1293
+ (await this.runAttachmentService.readNative(runId, imageIndex)),
1294
+ processExecutorFactory: (input) => new BubblewrapSandboxExecutor(input),
1295
+ assertCanCreate: () => {
1296
+ if (maintenanceService === undefined)
1297
+ throw new Error('CONVERSATION_HOSTING_UNAVAILABLE');
1298
+ return maintenanceService.assertCanCreate();
1299
+ }
1300
+ });
1301
+ maintenanceService = new ConversationHostingMaintenanceService({
1302
+ store,
1303
+ inactiveRetentionDays: config.conversationHosting.inactiveRetentionDays ?? 60,
1304
+ isConversationInUse: (conversationId) => hostedService?.isConversationInUse(conversationId) ?? true,
1305
+ beginConversationCleanup: (conversationId) => hostedService?.beginConversationCleanup(conversationId),
1306
+ releaseConversation: (conversation) => {
1307
+ if (hostedService === undefined)
1308
+ throw new Error('CONVERSATION_HOSTING_UNAVAILABLE');
1309
+ return hostedService.releaseConversationForCleanup(conversation);
1310
+ },
1311
+ onAutomaticCleanupError: (error) => nodeLog('conversation.hosting.cleanup.failed', {
1312
+ nodeId: config.nodeId,
1313
+ code: safeErrorCode(error, 'CONVERSATION_HOSTING_CLEANUP_FAILED')
1314
+ })
1315
+ });
1316
+ this.conversationTemplateOperations = templateService.operations();
1317
+ this.hostedConversationOperations = hostedService.operations();
1318
+ this.conversationHostingMaintenanceOperations = maintenanceService.operations();
1319
+ this.hostedConversationRuntime = runtime;
1320
+ this.hostedConversationService = hostedService;
1321
+ this.conversationHostingMaintenanceService = maintenanceService;
1322
+ await maintenanceService.start();
1323
+ this.conversationHostingStorageReady = true;
1324
+ }
1325
+ catch (error) {
1326
+ await maintenanceService?.dispose();
1327
+ hostedService?.dispose();
1328
+ await runtime?.dispose().catch(() => undefined);
1329
+ this.conversationHostingFailureCode = safeErrorCode(error, 'CONVERSATION_HOSTING_RECOVERY_FAILED');
1330
+ nodeLog('conversation.hosting.initialization.failed', {
1331
+ nodeId: config.nodeId,
1332
+ code: this.conversationHostingFailureCode
1333
+ });
1334
+ }
1335
+ }
1336
+ }
1337
+ this.capabilities = await this.projectConversationHostingCapability(this.capabilities);
1338
+ }
1339
+ async projectConversationHostingCapability(capabilities) {
1340
+ let storageReady = this.conversationHostingStorageReady;
1341
+ let storageFailureCode = this.conversationHostingFailureCode;
1342
+ let capacity = 'AVAILABLE';
1343
+ if (storageReady && this.conversationHostingMaintenanceService !== undefined) {
1344
+ try {
1345
+ capacity = (await this.conversationHostingMaintenanceService.storageCapacity()).capacity;
1346
+ }
1347
+ catch (error) {
1348
+ storageReady = false;
1349
+ storageFailureCode = safeErrorCode(error, 'CONVERSATION_HOSTING_STORAGE_UNAVAILABLE');
1350
+ }
1351
+ }
1352
+ return {
1353
+ ...capabilities,
1354
+ conversationHosting: await conversationHostingCapability(capabilities, this.config, storageReady, storageFailureCode, this.conversationHostingProbe, capacity)
1355
+ };
1356
+ }
1357
+ async start() {
1358
+ if (this.stopping !== undefined)
1359
+ await this.stopping;
1360
+ this.stopping = undefined;
1361
+ this.stopped = false;
1362
+ this.config ??= await loadNodeConfig(this.configPath);
1363
+ await this.upgradeCoordinator.loadResult(resolve(dirname(nodeDatabasePath(this.config, this.configPath)), 'upgrade-result.json'));
1364
+ await assertLocalSqlitePath(nodeDatabasePath(this.config, this.configPath));
1365
+ this.database ??= new NodeDatabase(nodeDatabasePath(this.config, this.configPath), () => this.config?.nodeId ?? 'unregistered');
1366
+ this.database.closeRunningTerminalSessions();
1367
+ await this.initializeConversationHosting();
1368
+ this.connectionLifecycle.start();
1369
+ this.controlChannel.connect();
1370
+ }
1371
+ clearMissionRetry(sessionId) {
1372
+ const retry = this.missionRetryTimers.get(sessionId);
1373
+ if (retry !== undefined)
1374
+ clearTimeout(retry.timer);
1375
+ this.missionRetryTimers.delete(sessionId);
1376
+ this.missionContinuationPending.delete(sessionId);
1377
+ }
1378
+ async enqueueMissionContinuation(input) {
1379
+ const attemptKey = `${input.mission.id}:${input.mission.revision}`;
1380
+ this.missionContinuationPending.set(input.sessionId, attemptKey);
1381
+ try {
1382
+ await this.sessionMessageService.submitMission({
1383
+ sessionId: input.sessionId,
1384
+ kind: 'continue',
1385
+ content: this.missionRuntime.prompt(input.sessionId, 'continue'),
1386
+ deliveryIntent: 'QUEUE',
1387
+ mission: input.mission,
1388
+ secretEnvironment: input.secretEnvironment,
1389
+ ...(input.personalInstructions === undefined
1390
+ ? {}
1391
+ : { personalInstructions: input.personalInstructions }),
1392
+ ...(input.marAgentModel === undefined ? {} : { marAgentModel: input.marAgentModel }),
1393
+ ...(input.marAgentModels === undefined ? {} : { marAgentModels: input.marAgentModels }),
1394
+ ...(input.marAgentRuntimeScopeId === undefined
1395
+ ? {}
1396
+ : { marAgentRuntimeScopeId: input.marAgentRuntimeScopeId })
1397
+ });
1398
+ const current = this.missionRuntime.get(input.sessionId);
1399
+ if (current?.status !== 'active' ||
1400
+ current.id !== input.mission.id ||
1401
+ current.revision !== input.mission.revision) {
1402
+ this.continuousRunCoordinator.removeMissionQueue(input.sessionId, current?.status === 'active' ? { id: current.id, revision: current.revision } : undefined);
1403
+ if (this.missionContinuationPending.get(input.sessionId) === attemptKey)
1404
+ this.missionContinuationPending.delete(input.sessionId);
1405
+ return;
1406
+ }
1407
+ this.clearMissionRetry(input.sessionId);
1408
+ }
1409
+ catch {
1410
+ const current = this.missionRuntime.get(input.sessionId);
1411
+ if (current?.status !== 'active' ||
1412
+ current.id !== input.mission.id ||
1413
+ current.revision !== input.mission.revision) {
1414
+ if (this.missionContinuationPending.get(input.sessionId) === attemptKey)
1415
+ this.missionContinuationPending.delete(input.sessionId);
1416
+ return;
1417
+ }
1418
+ const failedAttempts = (input.failedAttempts ?? 0) + 1;
1419
+ const session = this.runtime.getAgentSession(input.sessionId);
1420
+ if (failedAttempts > 3 || session === undefined) {
1421
+ this.clearMissionRetry(input.sessionId);
1422
+ if (failedAttempts > 3) {
1423
+ const blocked = this.missionRuntime.blockAfterRuntimeFailure(input.sessionId, input.mission.id, input.mission.revision);
1424
+ this.continuousRunCoordinator.removeMissionQueue(input.sessionId);
1425
+ this.finishIdleMissionRun(input.sessionId, 'FAILED');
1426
+ if (session !== undefined)
1427
+ this.publishMissionState(session, blocked);
1428
+ }
1429
+ return;
1430
+ }
1431
+ this.clearMissionRetry(input.sessionId);
1432
+ const retry = {
1433
+ sessionId: input.sessionId,
1434
+ timer: setTimeout(() => {
1435
+ const current = this.missionRuntime.get(retry.sessionId);
1436
+ if (current?.status !== 'active' ||
1437
+ current.id !== input.mission.id ||
1438
+ current.revision !== input.mission.revision)
1439
+ return;
1440
+ void this.enqueueMissionContinuation({
1441
+ ...input,
1442
+ sessionId: retry.sessionId,
1443
+ failedAttempts
1444
+ });
1445
+ }, 15_000)
1446
+ };
1447
+ this.missionRetryTimers.set(input.sessionId, retry);
1448
+ retry.timer.unref();
1449
+ }
1450
+ }
1451
+ finishIdleMissionRun(sessionId, status) {
1452
+ const run = this.runtime.activeSessionRun(sessionId);
1453
+ if (run === undefined || this.runtime.currentExecutionId(run.id) !== undefined)
1454
+ return;
1455
+ this.runEventBridge.emitRun(run.id, status === 'SUCCEEDED' ? 'run.completed' : 'run.failed', status === 'SUCCEEDED' ? {} : { code: 'MISSION_CONTINUATION_FAILED' }, status);
1456
+ }
1457
+ prepareMissionSession(session) {
1458
+ const access = missionUnrestrictedAccess(session.runner);
1459
+ const changed = session.access !== access;
1460
+ const prepared = changed ? this.runtime.updateAgentSessionAccess(session.id, access) : session;
1461
+ if (changed &&
1462
+ prepared.externalSessionId !== null &&
1463
+ prepared.model !== null &&
1464
+ prepared.effort !== null)
1465
+ this.database?.saveNativeSessionMetadata({
1466
+ runner: prepared.runner,
1467
+ externalSessionId: prepared.externalSessionId,
1468
+ workspaceId: prepared.workspaceId,
1469
+ model: prepared.model,
1470
+ effort: prepared.effort,
1471
+ access
1472
+ });
1473
+ return { session: prepared, changed };
1474
+ }
1475
+ pendingMissionCommandState() {
1476
+ return {
1477
+ commandId: 'mission',
1478
+ active: true,
1479
+ label: 'Mission',
1480
+ detail: null,
1481
+ closable: true,
1482
+ closeInput: '/mission --clear'
1483
+ };
1484
+ }
1485
+ stop() {
1486
+ if (this.stopping !== undefined)
1487
+ return this.stopping;
1488
+ this.stopped = true;
1489
+ this.recentRunProjectionService.dispose();
1490
+ this.upgradeCoordinator.stop();
1491
+ this.connectionLifecycle.stop();
1492
+ for (const approval of this.claudeClient.execution.approvals.values()) {
1493
+ clearTimeout(approval.timer);
1494
+ approval.resolve('REJECTED');
1495
+ }
1496
+ this.claudeClient.execution.approvals.clear();
1497
+ for (const pending of this.claudeClient.execution.userInputs.values()) {
1498
+ clearTimeout(pending.timer);
1499
+ pending.reject('NODE_STOPPED');
1500
+ }
1501
+ this.claudeClient.execution.userInputs.clear();
1502
+ this.nativeSessionWatchService.clear();
1503
+ this.sessionIdentityService.dispose();
1504
+ this.sessionLifecycleService.clear();
1505
+ this.continuousRunCoordinator.clear();
1506
+ this.gitOperationService.clear();
1507
+ for (const retry of this.missionRetryTimers.values())
1508
+ clearTimeout(retry.timer);
1509
+ this.missionRetryTimers.clear();
1510
+ this.missionContinuationPending.clear();
1511
+ this.runEventService.clear();
1512
+ this.sessionContextService.dispose();
1513
+ for (const run of this.claudeClient.execution.runs.values())
1514
+ run.handle.cancel();
1515
+ this.claudeClient.execution.runs.clear();
1516
+ this.runAttachmentService.dispose();
1517
+ const marAgentDrain = this.marAgentRunController.dispose();
1518
+ const conversationHostingMaintenanceDrain = this.conversationHostingMaintenanceService?.dispose();
1519
+ this.conversationHostingMaintenanceService = undefined;
1520
+ this.hostedConversationService?.dispose();
1521
+ this.hostedConversationService = undefined;
1522
+ const hostedConversationRuntime = this.hostedConversationRuntime;
1523
+ this.hostedConversationRuntime = undefined;
1524
+ this.hostedConversationOperations = undefined;
1525
+ this.conversationHostingMaintenanceOperations = undefined;
1526
+ void this.workspaceUploadService.shutdown();
1527
+ this.workspaceFileService.dispose();
1528
+ this.workspaceWatchService.clearAll();
1529
+ this.workspaceWorkbenchService.clear();
1530
+ this.workspaceSessionService.clear();
1531
+ this.workspaceChangeService.clear();
1532
+ const runnerDrain = this.runners.stop();
1533
+ void this.missionMcpServer.close();
1534
+ // close() transitions metadata before awaiting process-tree termination,
1535
+ // so the lifecycle is persisted before this synchronous shutdown returns.
1536
+ const terminalDrain = this.terminalManager.shutdown();
1537
+ this.terminalChannel.stop();
1538
+ this.runtimeCredentials.close();
1539
+ this.controlChannel.stop();
1540
+ const database = this.database;
1541
+ this.database = undefined;
1542
+ this.stopping = (async () => {
1543
+ try {
1544
+ await conversationHostingMaintenanceDrain;
1545
+ }
1546
+ finally {
1547
+ await hostedConversationRuntime?.dispose().catch(() => undefined);
1548
+ await Promise.allSettled([marAgentDrain, runnerDrain, terminalDrain]);
1549
+ await this.gitExecutionService?.close();
1550
+ database?.close();
1551
+ }
1552
+ })();
1553
+ return this.stopping;
1554
+ }
1555
+ /** @internal Thin compatibility delegates; all behavior remains in the extracted services. */
1556
+ handleMessage = (raw) => this.controlMessages.handle(raw);
1557
+ emitRunEvent = (runId, eventType, payload, status) => this.runEventBridge.emitRun(runId, eventType, payload, status);
1558
+ emitConversationItem = (runId, item) => {
1559
+ this.runEventService.flushPendingText(runId);
1560
+ const itemId = isPlainRecord(item) && typeof item.itemId === 'string' ? item.itemId : undefined;
1561
+ const itemKind = isPlainRecord(item) && typeof item.kind === 'string' ? item.kind : undefined;
1562
+ const turn = this.runtime.conversationTurnForRun(runId);
1563
+ const segment = itemId === undefined || turn === undefined
1564
+ ? undefined
1565
+ : conversationSegmentIdentityForItem(turn, itemId, itemKind);
1566
+ this.runEventBridge.emitRun(runId, 'conversation.item', segment === undefined || !isPlainRecord(item)
1567
+ ? item
1568
+ : { ...item, segmentId: segment.id, segmentIndex: segment.index });
1569
+ };
1570
+ emitConversationTurn = (turn) => {
1571
+ const segments = isPlainRecord(turn) && Array.isArray(turn.items) ? conversationSegments(turn) : [];
1572
+ this.emitWorkbenchEvent('conversation', { turn, segments });
1573
+ };
1574
+ publishWorkbenchEvent = (category, payload) => {
1575
+ if (category === 'session') {
1576
+ this.emitSessionWorkbenchEvent(payload);
1577
+ return;
1578
+ }
1579
+ this.emitWorkbenchEvent(category, payload);
1580
+ };
1581
+ emitSessionWorkbenchEvent = (payload) => {
1582
+ if (isPlainRecord(payload) && isPlainRecord(payload.session)) {
1583
+ const workspaceId = payload.session.workspaceId;
1584
+ if (typeof workspaceId === 'string') {
1585
+ this.workspaceSessionService.invalidateCache(workspaceId);
1586
+ void this.workspaceWorkbenchService?.invalidateTopic(workspaceId, 'sessions');
1587
+ }
1588
+ }
1589
+ this.emitWorkbenchEvent('session', payload);
1590
+ };
1591
+ emitWorkbenchEvent = (category, payload) => {
1592
+ if (category === 'conversation' &&
1593
+ isPlainRecord(payload) &&
1594
+ isPlainRecord(payload.event) &&
1595
+ payload.event.eventType !== 'notification') {
1596
+ const runId = typeof payload.event.runId === 'string' ? payload.event.runId : undefined;
1597
+ const sequence = typeof payload.event.sequence === 'number' ? payload.event.sequence : undefined;
1598
+ const turn = runId === undefined ? undefined : this.runtime.conversationTurnForRun(runId);
1599
+ if (turn === undefined)
1600
+ return;
1601
+ const rawPayload = isPlainRecord(payload.event.payload) ? payload.event.payload : undefined;
1602
+ const text = payload.event.eventType === 'text.delta' && typeof rawPayload?.text === 'string'
1603
+ ? rawPayload.text
1604
+ : undefined;
1605
+ const nativeItemId = typeof rawPayload?.itemId === 'string'
1606
+ ? rawPayload.itemId
1607
+ : typeof rawPayload?.approvalId === 'string'
1608
+ ? `approval:${rawPayload.approvalId}`
1609
+ : undefined;
1610
+ const item = text !== undefined && sequence !== undefined
1611
+ ? turn.items.find((candidate) => candidate.kind === 'assistant_message' && candidate.revision === sequence)
1612
+ : nativeItemId === undefined
1613
+ ? undefined
1614
+ : turn.items.find((candidate) => candidate.id === `${runId}:${nativeItemId}`);
1615
+ if (text !== undefined && item?.kind === 'assistant_message') {
1616
+ payload = {
1617
+ sessionId: turn.sessionId,
1618
+ delta: {
1619
+ runId: turn.runId,
1620
+ itemId: item.id,
1621
+ text,
1622
+ createdAt: typeof payload.event.createdAt === 'number' ? payload.event.createdAt : Date.now()
1623
+ }
1624
+ };
1625
+ }
1626
+ else if (item !== undefined) {
1627
+ const segment = conversationSegmentIdentityForItem(turn, item.id, item.kind);
1628
+ payload = {
1629
+ sessionId: turn.sessionId,
1630
+ runId: turn.runId,
1631
+ item: {
1632
+ itemId: item.id,
1633
+ kind: item.kind,
1634
+ status: item.status,
1635
+ payload: item.payload,
1636
+ startedAt: item.startedAt,
1637
+ completedAt: item.completedAt,
1638
+ segmentId: segment.id,
1639
+ segmentIndex: segment.index
1640
+ }
1641
+ };
1642
+ }
1643
+ else {
1644
+ if (payload.event.eventType !== 'run.started' && payload.event.eventType !== 'run.running')
1645
+ return;
1646
+ payload = { turn, segments: conversationSegments(turn) };
1647
+ }
1648
+ }
1649
+ const event = this.workbenchEventService.next(category, payload);
1650
+ if (event === undefined)
1651
+ return;
1652
+ const notification = category === 'conversation' &&
1653
+ isPlainRecord(payload) &&
1654
+ isPlainRecord(payload.event) &&
1655
+ payload.event.eventType === 'notification';
1656
+ const sessionId = workbenchPayloadSessionId(this.runtime, category, payload);
1657
+ if (!notification && sessionId !== undefined) {
1658
+ this.nativeSessionWatchService.emitRealtime(sessionId, event);
1659
+ return;
1660
+ }
1661
+ this.workbenchEventService.publish(event);
1662
+ };
1663
+ discoverWorkspaceSessions = (workspaceId) => this.nativeSessionProjectionService.discoverWorkspace(workspaceId);
1664
+ invalidateWorkspaceWatchTopics = (workspaceId) => this.workspaceCoordinator.invalidate(workspaceId);
1665
+ reconcilePersistedRuns = () => undefined;
1666
+ startCapabilityRefresh = () => this.connectionLifecycle.startCapabilityRefresh();
1667
+ refreshCapabilities = () => this.connectionLifecycle.refreshCapabilities();
1668
+ async executeNodeOperation(operation, data) {
1669
+ if (this.database === undefined)
1670
+ throw new Error('NODE_DATABASE_UNAVAILABLE');
1671
+ if (this.upgradeCoordinator.blocks(operation))
1672
+ throw new Error('NODE_UPGRADE_PENDING');
1673
+ nodeLog('node.operation', { nodeId: this.config?.nodeId, operation });
1674
+ return this.gitOperationService.execute(operation, data, (input) => this.operationRouter.execute(operation, input));
1675
+ }
1676
+ gitExecution() {
1677
+ this.gitExecutionService ??= new GitExecutionService({
1678
+ ...(this.config === undefined
1679
+ ? {}
1680
+ : { directory: resolve(nodeDataDirectory(this.config, this.configPath), 'git-runtime') })
1681
+ });
1682
+ return this.gitExecutionService;
1683
+ }
1684
+ async webSearch(input, signal) {
1685
+ const config = this.config;
1686
+ if (config?.nodeId === undefined || config.credential === undefined)
1687
+ throw new Error('NODE_UNAUTHENTICATED');
1688
+ const response = await fetch(`${config.serverUrl.replace(/\/$/u, '')}/api/node-tools/web-search`, {
1689
+ method: 'POST',
1690
+ headers: {
1691
+ 'content-type': 'application/json',
1692
+ 'x-mar-node-id': config.nodeId,
1693
+ authorization: `Bearer ${config.credential}`
1694
+ },
1695
+ body: JSON.stringify(input),
1696
+ signal
1697
+ });
1698
+ if (!response.ok)
1699
+ throw await readWebSearchError(response);
1700
+ const result = await response.json();
1701
+ return { content: JSON.stringify(result), data: result };
1702
+ }
1703
+ publishMissionState(session, mission) {
1704
+ if (mission.status !== 'active') {
1705
+ this.commandStates.clear(session.id, 'mission');
1706
+ this.emitWorkbenchEvent('session', {
1707
+ session: this.sessionPresentationService.present(session)
1708
+ });
1709
+ return;
1710
+ }
1711
+ this.commandStates.set(session.id, {
1712
+ commandId: 'mission',
1713
+ active: mission.status === 'active',
1714
+ label: 'Mission',
1715
+ detail: mission.objective.slice(0, 500),
1716
+ closable: true,
1717
+ closeInput: '/mission',
1718
+ mission: {
1719
+ id: mission.id,
1720
+ objective: mission.objective,
1721
+ revision: mission.revision,
1722
+ status: mission.status,
1723
+ turns: mission.turns
1724
+ }
1725
+ });
1726
+ this.emitWorkbenchEvent('session', {
1727
+ session: this.sessionPresentationService.present(session)
1728
+ });
1729
+ }
1730
+ send(type, payload, replyTo) {
1731
+ this.controlChannel.send(type, payload, replyTo);
1732
+ }
1733
+ sendEnvelope(envelope) {
1734
+ this.controlChannel.sendEnvelope(envelope);
1735
+ }
1736
+ }