@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
@@ -1,2 +1,355 @@
1
- /* mar-release-protected */
2
- function _0x2905(_0x33192f,_0x381c1d){_0x33192f=_0x33192f-(0x1d91+-0x74a+-0x1499);const _0x52d625=_0x2806();let _0x21351c=_0x52d625[_0x33192f];if(_0x2905['COoJnS']===undefined){var _0x444a5b=function(_0x37aade){const _0x35be40='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x57bd2e='',_0x44111f='';for(let _0x29f474=0x1*-0x1717+0xe9d+0x87a,_0xfc2ef5,_0x16cf8b,_0x1ffebd=0x2e*-0xa3+-0xd93+-0x1*-0x2add;_0x16cf8b=_0x37aade['charAt'](_0x1ffebd++);~_0x16cf8b&&(_0xfc2ef5=_0x29f474%(0x15*-0x9f+0x1acc+0xdbd*-0x1)?_0xfc2ef5*(0x1176+0x12b6+-0x1*0x23ec)+_0x16cf8b:_0x16cf8b,_0x29f474++%(-0x35*-0x27+-0x1*0x1ea0+-0x1691*-0x1))?_0x57bd2e+=String['fromCharCode'](-0x599+-0x1*0x2409+0x2aa1&_0xfc2ef5>>(-(0x150a*-0x1+-0x2e7*0x2+0x1ada)*_0x29f474&-0x2506*0x1+-0xdb9+0x32c5)):-0x1*-0x159a+-0x59a+0x40*-0x40){_0x16cf8b=_0x35be40['indexOf'](_0x16cf8b);}for(let _0x3071ce=-0x7be*-0x2+0x1*-0x1645+-0x1*-0x6c9,_0x3aea8a=_0x57bd2e['length'];_0x3071ce<_0x3aea8a;_0x3071ce++){_0x44111f+='%'+('00'+_0x57bd2e['charCodeAt'](_0x3071ce)['toString'](0x7*0x28e+0xd3a*0x1+0x1*-0x1f0c))['slice'](-(0xac+-0x27b*0x5+0x1*0xbbd));}return decodeURIComponent(_0x44111f);};_0x2905['zUKwDl']=_0x444a5b,_0x2905['lEQrnS']={},_0x2905['COoJnS']=!![];}const _0x56add2=_0x52d625[-0x1f93+-0x2209+0x419c];_0x2905['DxXEEu']!==_0x56add2&&(_0x2905['lEQrnS']={},_0x2905['DxXEEu']=_0x56add2);const _0x4f9ad5=_0x2905['lEQrnS'][_0x33192f];return _0x4f9ad5===undefined?(_0x21351c=_0x2905['zUKwDl'](_0x21351c),_0x2905['lEQrnS'][_0x33192f]=_0x21351c):_0x21351c=_0x4f9ad5,_0x21351c;}const _0x58e5ec=_0x2905;(function(_0x3e8aa2,_0x19522e){const _0x429dd0=_0x2905,_0x17c92e=_0x3e8aa2();while(!![]){try{const _0x1cac16=-parseInt(_0x429dd0(0x1b3))/(-0x833+0x1511+-0x25*0x59)*(parseInt(_0x429dd0(0x221))/(-0xf06*0x1+-0x17cd+0x1*0x26d5))+-parseInt(_0x429dd0(0x1bf))/(0x223*0x9+0x506+0x2*-0xc1f)+parseInt(_0x429dd0(0x208))/(-0x1*0xfb5+-0x71*0x20+0x1dd9)+-parseInt(_0x429dd0(0x225))/(0x17f1+-0x311*0x1+-0x14db)+parseInt(_0x429dd0(0x1c0))/(0x1ca+0x218b+-0x234f)+-parseInt(_0x429dd0(0x204))/(-0x6e6+-0x265d*-0x1+-0x1f70)*(-parseInt(_0x429dd0(0x1ff))/(-0x1d47+-0x23*-0x65+0xf80))+-parseInt(_0x429dd0(0x20e))/(-0x212*0x5+-0x706+-0x1*-0x1169);if(_0x1cac16===_0x19522e)break;else _0x17c92e['push'](_0x17c92e['shift']());}catch(_0x4d0721){_0x17c92e['push'](_0x17c92e['shift']());}}}(_0x2806,-0x4a8f7*-0x1+-0x12ca61*0x1+0x183acc));import{createEnvelope}from'@myagentroam/protocol';import{ClaudeChannelGate}from'../../claude-channel.js';function _0x2806(){const _0xf76e50=['y2XLyxjdB21Tyw5Ku3rHDgu','zw1PDa','vg9VBa','q09nueXfveve','rKfjteve','BMf0AxzLq29UDhjVBa','yxr0ywnOBwvUDhm','C2vZC2LVBL9Pza','uLvotKLorW','DhLWzq','CMvKywn0zwrFDgHPBMTPBMC','y2XHDwrLlxbSyw4','CMvTzw1IzxjoyxrPDMu','zMLSzv9JAgfUz2u','y2XHDwrLlwnVBxbHy3q','CNvUBMvYlwvYCM9Y','ywrK','C2vZC2LVBI5LEhrLCM5HBc1Pza','zw1PDeL0zw0','CNvUswq','CNvU','CNvUlNj1BM5PBMC','ywnJzxnZ','BwnWsw5ZDgfSBgf0Aw9UCW','y29TBwfUzfn0yxrLCW','CMvXDwvZDefWChjVDMfS','AgfZqwn0AxzLu2vZC2LVBKXLyxnL','CNvUBMvY','ugXHBIbnB2rL','BNvTyMvY','CNvUlMnVBxbSzxrLza','yxnZAxn0yw50','zgvSzxrL','zwzMB3j0','zgf0yujHC2u2na','BMf0AxzLu2vZC2LVBKLK','Dg9VBf9Uyw1L','C2vJCMv0rw52AxjVBM1LBNq','l2nVBxbHy3q','B3v0Chv0','tuvtu0fhrv9bvfrbq0Hnru5uu19jtLzbteLe','ody0mwfMEurgvq','C3rHDhvZ','Aw5PDgLHDgvKqNLvC2vYswq','Dgv4Da','su5Fufjpr1jfu1m','y29TBwfUzfn0yxrL','A2LUza','zxjYB3i','zxHLy3v0zunVBw1HBMq','C3LUy1rPDgXL','ve9ptf9svu5osu5hx1DjveHFrfvsqvrjt04','Dw5RBM93BG','nZCXmde4yKXjuvDb','ntm3otuXmgTPu01euG','qxnRvxnLCLf1zxn0Aw9U','rvHurvjoquXFu0vtu0LptL9pqLnfuLzfx09otfK','y29TBwfUzf9LEgvJDxrPB24','C2v0q2HHBM5LBfrVA2vU','C3rYAw5N','su5urvjsvvburuq','Bw9KzwW','DxnLCG','C3vJy2vZCW','u1rbuLrjtKC','l3bSyw4','CNvUlNn0yxj0zwq','y29TCgfJDa','Dg9VBfvZzuLK','y29TCgXLDgvK','CM91BMq','DgHLBG','y3DK','ve9ptf9svu5osu5h','y2XHDwrLlxjLyxnVBMLUzW','CNvUCW','sw1WBgvTzw50ihrOzsbWBgfUigfIB3zLlG','uLvotKvsx0nptu1btKrFvu5bvKfjtefcteu','Dg9VBf9JywXS','zxH0zxjUywXtzxnZAw9Uswq','BMfTzq','ywrVChq','DxvPza','CNvUlNjLAMvJDgvK','AgfZ','Dg9Rzw4','Cgf5Bg9Hza','BgvUz3rO','CgfYC2vbDhrHy2HTzw50CW','q2XHDwrLienVzguG','DhvYBI5JB21WBgv0zwq','y29TCgXLDgvdyw5JzwXSzwq','CNvUlMzHAwXLza','CMvHC29UAw5Nx3n1Bw1HCNK','DxnLCL9PBNb1Df9Yzxf1zxn0','ChjVBw90zq','C2v0q29TBwfUzfn0yxrL','oNbSyw4','BwnWu2vJCMv0rw52AxjVBM1LBNq','y2fUy2vS','Bwf4','zw5JCNLWDgvKx3rOAw5RAw5N','y2XHDwrLlxrVB2W','C2vUza','BwfUywDLze5HDgL2zuLKCW','C2v0','y2HHBM5LBc5YzxbSEq','BwnWq29UzMLNDxjHDgLVBG','C3rYzwfTx2nSB3nLza','igLZihj1BM5PBMC','ve9ptf9fwevdvvrjt05FrKfjteve','u3vIC2vXDwvUDcbTzxnZywDLCYbYDw4GAw4GCMvHzc1VBMX5ihrHz2DLzcbqBgfUie1VzguGyw5KihbYB2r1y2uGysbWBgfUignHCMqU','C2vZC2LVBKLK','tufsx01btKfhruq','BwLTzq','u1rbuLrfra','DhjPBq','nZa2nZuWnfjHthPgvW','BwfW','CMvZDwX0','CgXHBG','Aw5WDxq','n1jbBLHtEG','zw50CMLLCW','C2vZC2LVBI5JAgfUBMvSlNjLywr5','Dg9VBf91C2u','mZeWndK4mgTsrNzZBa','C3vIDhLWzq','CMvXDwvZDfvZzxjjBNb1Da','C2vZC2LVBG','Dg9VBf9WCM9NCMvZCW','zwXHChnLzf90Aw1Lx3nLy29Uzhm','nZC4mdiWm2TeDwvMEG','zxHLy3v0Aw9U','y2XHDwrLlwnVzgu6','Dgv4Dc5KzwX0yq','q0Xbvurfx1jvtL9gquLmruq','y2XHDwrLlwnVzgu','sw1WBgvTzw50','Ag9ZDa','Dg9VBfvZzuLe','Dg9VBf91C2vFAwq','u1vdq0vfreve','y29UDgv4Df9JB21Wywn0Aw9U','CNvUlNn0yxj0','q0Xbvurfx1jvtL9tvefsvf9gquLmruq','y2XHDwrLlwL0zw0','DgHPBMTPBMC','CMfUzg9Tvvvjra','zMfPBgvK','z2v0','mtm0wMHnvhD4','C3rHCNq','ihnLy29UzhmP','Dg9VBf9Yzxn1Bhq','oty5otuWDuX5AMXw','ywn0AxzL','C3rHCNrdAgfUBMvS','CgvYC29UywXjBNn0CNvJDgLVBNm','Dhj1BMnHDgvK','AxnFzxjYB3i','Aw50zxjJzxb0zwq','Aw5WDxruCNvUy2f0zwq'];_0x2806=function(){return _0xf76e50;};return _0x2806();}import{boundedConversationItemId,claudePlanText,compactRunnerText,extractClaudeText,extractClaudeThinkingSummaries,extractClaudeToolResults,extractClaudeToolUses}from'../codex/conversation-parser.js';import{normalizeClaudeTool}from'./tool-normalizer.js';import{claudeContentBlocks}from'../../util/node-operation-parsers.js';import{parseSecretEnvironment}from'../../util/secret-environment.js';import{safeErrorCode}from'../../util/safe-error.js';import{runnerErrorProjection}from'../../util/runner-error.js';export class ClaudeManagedRunController{[_0x58e5ec(0x248)];[_0x58e5ec(0x215)];constructor(_0x4a0d5b,_0x28da3d){const _0x285754=_0x58e5ec;this[_0x285754(0x248)]=_0x4a0d5b,this[_0x285754(0x215)]=_0x28da3d;}async[_0x58e5ec(0x1bb)](_0x41b0cf,_0x2eb583,_0xeed5b3,_0x5cbb2f){const _0x477ccf=_0x58e5ec;if(_0x2eb583['id']===_0x477ccf(0x1cd))return this[_0x477ccf(0x1cd)](_0x41b0cf,_0xeed5b3,_0x5cbb2f[_0x477ccf(0x1af)],_0x5cbb2f[_0x477ccf(0x1b5)]);if(_0x2eb583['id']!==_0x477ccf(0x202)||_0x41b0cf[_0x477ccf(0x243)]===_0x477ccf(0x202))throw new Error(_0x477ccf(0x1d7));const _0x4903c3=this[_0x477ccf(0x215)][_0x477ccf(0x1b8)](_0x41b0cf['id'],_0x477ccf(0x202));if(_0x4903c3?.[_0x477ccf(0x226)])this[_0x477ccf(0x215)][_0x477ccf(0x22d)](_0x41b0cf['id'],_0x477ccf(0x202));else this[_0x477ccf(0x215)][_0x477ccf(0x1ea)](_0x41b0cf['id'],{'commandId':_0x477ccf(0x202),'active':!![],'label':_0x477ccf(0x249),'detail':_0x477ccf(0x1f9),'closable':!![],'closeInput':_0x477ccf(0x1cb),'continuation':{'label':_0x477ccf(0x214),'prompt':_0x477ccf(0x1d6)}});return{'command':_0x2eb583['id'],'states':this[_0x477ccf(0x215)][_0x477ccf(0x245)](_0x41b0cf['id'])};}[_0x58e5ec(0x1cd)](_0x4296ec,_0x148297,_0x554d77,_0x9c61f9){const _0x27c65e=_0x58e5ec;if(_0x4296ec[_0x27c65e(0x1d9)]===null||_0x4296ec[_0x27c65e(0x232)]!==_0x27c65e(0x1fb)||this[_0x27c65e(0x215)][_0x27c65e(0x247)](_0x4296ec['id']))throw new Error(_0x27c65e(0x1d7));const _0x34b1df=crypto[_0x27c65e(0x21e)]();return this[_0x27c65e(0x215)][_0x27c65e(0x1db)]({'runId':_0x34b1df,'sessionId':_0x4296ec['id'],'runner':_0x27c65e(0x213),'cwd':_0x4296ec[_0x27c65e(0x1d2)],'externalSessionId':_0x4296ec[_0x27c65e(0x1d9)],..._0x9c61f9===undefined?{}:{'initiatedByUserId':_0x9c61f9}}),this[_0x27c65e(0x215)][_0x27c65e(0x239)](_0x4296ec[_0x27c65e(0x1d9)],_0x4296ec['id']),this[_0x27c65e(0x222)](createEnvelope(_0x27c65e(0x21a),{'runId':_0x34b1df,'sessionId':_0x4296ec['id'],'runner':_0x27c65e(0x213),'input':_0x148297,'cwd':_0x4296ec[_0x27c65e(0x1d2)],'externalSessionId':_0x4296ec[_0x27c65e(0x1d9)],'model':_0x4296ec[_0x27c65e(0x1c7)],'effort':_0x4296ec[_0x27c65e(0x24e)],'access':_0x4296ec[_0x27c65e(0x243)],'secretEnvironment':_0x554d77})),{'command':_0x27c65e(0x1cd),'run':this[_0x27c65e(0x215)][_0x27c65e(0x241)](_0x34b1df),'states':this[_0x27c65e(0x215)][_0x27c65e(0x245)](_0x4296ec['id'])};}[_0x58e5ec(0x222)](_0x33a056){const _0x3a8321=_0x58e5ec,_0x30eda0=_0x33a056[_0x3a8321(0x1e0)];if(_0x30eda0[_0x3a8321(0x248)]!==_0x3a8321(0x213)||typeof _0x30eda0[_0x3a8321(0x240)]!==_0x3a8321(0x1c5)||typeof _0x30eda0[_0x3a8321(0x1fa)]!==_0x3a8321(0x1c5)||typeof _0x30eda0[_0x3a8321(0x203)]!==_0x3a8321(0x1c5)||typeof _0x30eda0[_0x3a8321(0x1d2)]!==_0x3a8321(0x1c5)||this[_0x3a8321(0x215)][_0x3a8321(0x22b)]()||this[_0x3a8321(0x215)][_0x3a8321(0x226)][_0x3a8321(0x1de)](_0x30eda0[_0x3a8321(0x240)]))return;const _0x2d0b09=_0x30eda0[_0x3a8321(0x240)],_0x4583db=_0x30eda0[_0x3a8321(0x1fa)],_0x3fd54d=_0x30eda0[_0x3a8321(0x1d2)],_0x54111e=_0x30eda0[_0x3a8321(0x203)][_0x3a8321(0x1fe)]()===_0x3a8321(0x1b0)?boundedConversationItemId(_0x3a8321(0x23b),_0x2d0b09):undefined;let _0x3bd361,_0x39d147,_0x56d313;try{_0x3bd361=this[_0x3a8321(0x215)][_0x3a8321(0x1e2)](_0x30eda0[_0x3a8321(0x233)]),_0x39d147=parseSecretEnvironment(_0x30eda0[_0x3a8321(0x1af)]),_0x56d313=parseSecretEnvironment(_0x30eda0[_0x3a8321(0x1ec)]);}catch(_0x2d72f0){this[_0x3a8321(0x215)][_0x3a8321(0x22e)](_0x2d0b09,_0x3a8321(0x1dd),{'code':safeErrorCode(_0x2d72f0,_0x3a8321(0x1b2))},_0x3a8321(0x231));return;}this[_0x3a8321(0x215)][_0x3a8321(0x1db)]({'runId':_0x2d0b09,'sessionId':_0x4583db,'runner':_0x3a8321(0x213),'cwd':_0x3fd54d,...typeof _0x30eda0[_0x3a8321(0x1d9)]===_0x3a8321(0x1c5)?{'externalSessionId':_0x30eda0[_0x3a8321(0x1d9)]}:{}});if(this[_0x3a8321(0x215)][_0x3a8321(0x241)](_0x2d0b09)?.[_0x3a8321(0x1b4)]===_0x3a8321(0x1c6)){this[_0x3a8321(0x215)][_0x3a8321(0x22e)](_0x2d0b09,_0x3a8321(0x24b),{'status':_0x3a8321(0x1c6)},_0x3a8321(0x1c6));return;}if(this[_0x3a8321(0x215)][_0x3a8321(0x1e5)](_0x2d0b09,_0x3fd54d))return;if(typeof _0x30eda0[_0x3a8321(0x1d9)]===_0x3a8321(0x1c5)&&!this[_0x3a8321(0x248)][_0x3a8321(0x20f)][_0x3a8321(0x1f2)][_0x3a8321(0x1de)](_0x30eda0[_0x3a8321(0x1d9)])){this[_0x3a8321(0x215)][_0x3a8321(0x22e)](_0x2d0b09,_0x3a8321(0x1dd),{'code':_0x3a8321(0x1c2)},_0x3a8321(0x231));return;}this[_0x3a8321(0x215)][_0x3a8321(0x226)][_0x3a8321(0x23d)](_0x2d0b09),this[_0x3a8321(0x215)][_0x3a8321(0x22e)](_0x2d0b09,_0x3a8321(0x1cc),{},_0x3a8321(0x1ca));if(_0x54111e!==undefined)this[_0x3a8321(0x215)][_0x3a8321(0x23f)](_0x2d0b09,{'itemId':_0x54111e,'kind':_0x3a8321(0x219),'status':_0x3a8321(0x1b7),'payload':{'phase':_0x3a8321(0x1fd),'summary':null},'merge':!![]});let _0x3919fd=![],_0x378e34;const _0x3081ed=new Map(),_0x208d69=(_0x45ba62,_0x9fe508,_0x341365,_0x3b18d0,_0x9273d0=_0x3a8321(0x212))=>{const _0x2f6ba1=_0x3a8321;if(_0x3919fd)return;_0x3919fd=!![];const _0x625dfc=_0x45ba62===_0x2f6ba1(0x231)?runnerErrorProjection(_0x3b18d0??_0x341365,_0x9273d0):undefined;_0x625dfc!==undefined&&this[_0x2f6ba1(0x215)][_0x2f6ba1(0x23f)](_0x2d0b09,{'itemId':boundedConversationItemId(_0x2f6ba1(0x23c),_0x2d0b09),'kind':_0x2f6ba1(0x1ba),'status':_0x2f6ba1(0x231),'payload':{..._0x625dfc,'recoverable':!![],'retryAfterMs':null}});if(_0x45ba62===_0x2f6ba1(0x218)&&_0x54111e!==undefined)this[_0x2f6ba1(0x215)][_0x2f6ba1(0x23f)](_0x2d0b09,{'itemId':_0x54111e,'kind':_0x2f6ba1(0x219),'status':_0x2f6ba1(0x230),'payload':{'phase':_0x2f6ba1(0x230),'summary':null},'merge':!![]});this[_0x2f6ba1(0x215)][_0x2f6ba1(0x22e)](_0x2d0b09,_0x9fe508,_0x625dfc??_0x341365,_0x45ba62),this[_0x2f6ba1(0x248)][_0x2f6ba1(0x20f)][_0x2f6ba1(0x1d5)][_0x2f6ba1(0x24d)](_0x2d0b09),_0x378e34?.[_0x2f6ba1(0x1ed)](),this[_0x2f6ba1(0x215)][_0x2f6ba1(0x226)][_0x2f6ba1(0x24d)](_0x2d0b09);};try{const _0x14ed53=new ClaudeChannelGate(_0x4583db);_0x378e34=this[_0x3a8321(0x248)][_0x3a8321(0x227)]({'prompt':_0x30eda0[_0x3a8321(0x203)],'cwd':_0x3fd54d,...typeof _0x30eda0[_0x3a8321(0x1d9)]===_0x3a8321(0x1c5)?{'resumeSessionId':_0x30eda0[_0x3a8321(0x1d9)]}:{},...typeof _0x30eda0[_0x3a8321(0x1c7)]===_0x3a8321(0x1c5)?{'model':_0x30eda0[_0x3a8321(0x1c7)]}:{},...typeof _0x30eda0[_0x3a8321(0x24e)]===_0x3a8321(0x1c5)?{'effort':_0x30eda0[_0x3a8321(0x24e)]}:{},...typeof _0x30eda0[_0x3a8321(0x243)]===_0x3a8321(0x1c5)?{'access':_0x30eda0[_0x3a8321(0x243)]}:{},'environment':_0x39d147,...typeof _0x30eda0[_0x3a8321(0x228)]===_0x3a8321(0x1c5)?{'personalInstructions':_0x30eda0[_0x3a8321(0x228)]}:{},'mcpServers':this[_0x3a8321(0x248)][_0x3a8321(0x1f5)](_0x30eda0[_0x3a8321(0x244)],{..._0x39d147,..._0x56d313}),..._0x3bd361[_0x3a8321(0x1e1)]===-0xaed+0x2e*-0xa3+0x2837?{}:{'attachments':_0x3bd361[_0x3a8321(0x200)](_0x214c97=>({'mime':_0x214c97[_0x3a8321(0x1fc)],'dataBase64':_0x214c97[_0x3a8321(0x24f)]}))},'onPermission':(_0x26fca2,_0x33192f,_0x381c1d)=>_0x26fca2===_0x3a8321(0x1c1)?(_0x3081ed[_0x3a8321(0x1f3)](_0x381c1d[_0x3a8321(0x216)],_0x3a8321(0x1e8)),this[_0x3a8321(0x215)][_0x3a8321(0x20a)](_0x2d0b09,_0x33192f,_0x381c1d[_0x3a8321(0x216)])):this[_0x3a8321(0x215)][_0x3a8321(0x246)](_0x2d0b09,_0x26fca2,_0x33192f),'onChannelReply':_0x52d625=>this[_0x3a8321(0x215)][_0x3a8321(0x22e)](_0x2d0b09,_0x3a8321(0x1f4),{'content':_0x52d625}),'onMessage':_0x21351c=>{const _0x3f89e2=_0x3a8321,_0x444a5b=_0x21351c,_0x56add2=typeof _0x444a5b[_0x3f89e2(0x234)]===_0x3f89e2(0x1c5)?_0x444a5b[_0x3f89e2(0x234)]:undefined,_0x4f9ad5=this[_0x3f89e2(0x248)][_0x3f89e2(0x20f)][_0x3f89e2(0x1d5)][_0x3f89e2(0x220)](_0x2d0b09);if(_0x56add2!==undefined&&_0x4f9ad5!==undefined){const _0x37aade=_0x4f9ad5[_0x3f89e2(0x250)]===undefined;if(_0x37aade)this[_0x3f89e2(0x248)][_0x3f89e2(0x20f)][_0x3f89e2(0x1d5)][_0x3f89e2(0x1f3)](_0x2d0b09,{..._0x4f9ad5,'nativeSessionId':_0x56add2});const _0x35be40=this[_0x3f89e2(0x215)][_0x3f89e2(0x20b)](_0x4583db);if(_0x35be40?.[_0x3f89e2(0x232)]===_0x3f89e2(0x1fb))this[_0x3f89e2(0x215)][_0x3f89e2(0x239)](_0x56add2,_0x35be40['id']);if(_0x37aade&&typeof _0x30eda0[_0x3f89e2(0x1d9)]!==_0x3f89e2(0x1c5)){this[_0x3f89e2(0x215)][_0x3f89e2(0x1e9)](_0x4583db,_0x56add2),this[_0x3f89e2(0x215)][_0x3f89e2(0x1f1)](_0x3f89e2(0x23e),{'sessionId':_0x4583db,'externalSessionId':_0x56add2});const _0x57bd2e=this[_0x3f89e2(0x248)][_0x3f89e2(0x20f)][_0x3f89e2(0x1d5)][_0x3f89e2(0x220)](_0x2d0b09);if(_0x57bd2e!==undefined)this[_0x3f89e2(0x248)][_0x3f89e2(0x20f)][_0x3f89e2(0x1d5)][_0x3f89e2(0x1f3)](_0x2d0b09,{..._0x57bd2e,'marSessionId':_0x56add2});}}if(_0x444a5b[_0x3f89e2(0x236)]===_0x3f89e2(0x24c)){const _0x44111f=extractClaudeText(_0x444a5b),_0x29f474=claudePlanText(_0x44111f);if(_0x29f474!==undefined)this[_0x3f89e2(0x215)][_0x3f89e2(0x23f)](_0x2d0b09,{'itemId':boundedConversationItemId(_0x3f89e2(0x238),typeof _0x444a5b[_0x3f89e2(0x1dc)]===_0x3f89e2(0x1c5)?_0x444a5b[_0x3f89e2(0x1dc)]:_0x2d0b09+_0x3f89e2(0x1eb)),'kind':_0x3f89e2(0x202),'status':_0x3f89e2(0x230),'payload':{'explanation':compactRunnerText(_0x29f474,0x844c+0x10*-0x2eb+-0x1df*0x4),'steps':[]}});else{if(_0x44111f[_0x3f89e2(0x1e1)]>0x1*0xc5f+0x1838+-0x2497)this[_0x3f89e2(0x215)][_0x3f89e2(0x22e)](_0x2d0b09,_0x3f89e2(0x211),{'text':_0x44111f});}for(const [_0xfc2ef5,_0x16cf8b]of extractClaudeThinkingSummaries(_0x444a5b)[_0x3f89e2(0x205)]()){this[_0x3f89e2(0x215)][_0x3f89e2(0x23f)](_0x2d0b09,{'itemId':boundedConversationItemId(_0x3f89e2(0x1d4),(typeof _0x444a5b[_0x3f89e2(0x1dc)]===_0x3f89e2(0x1c5)?_0x444a5b[_0x3f89e2(0x1dc)]:_0x2d0b09)+':'+_0xfc2ef5),'kind':_0x3f89e2(0x1e7),'status':_0x3f89e2(0x230),'payload':{'sections':[{'index':_0xfc2ef5,'text':_0x16cf8b}]}});}for(const _0x1ffebd of extractClaudeToolUses(_0x444a5b)){if(_0x1ffebd[_0x3f89e2(0x1da)]===_0x3f89e2(0x1c1)){_0x3081ed[_0x3f89e2(0x1f3)](_0x1ffebd['id'],_0x3f89e2(0x1e8));continue;}const _0x3071ce=boundedConversationItemId(_0x3f89e2(0x1f0),_0x1ffebd['id']),_0x3aea8a=normalizeClaudeTool(_0x1ffebd[_0x3f89e2(0x1da)],_0x1ffebd[_0x3f89e2(0x203)],null,![],_0x1ffebd[_0x3f89e2(0x22c)]),_0x32eb0a=_0x3aea8a[_0x3f89e2(0x1b9)];_0x3081ed[_0x3f89e2(0x1f3)](_0x1ffebd['id'],_0x32eb0a),this[_0x3f89e2(0x215)][_0x3f89e2(0x23f)](_0x2d0b09,{'itemId':_0x3071ce,'kind':_0x32eb0a,'status':_0x3f89e2(0x1b7),'payload':_0x3aea8a[_0x3f89e2(0x1e0)]});}for(const [_0x55c387,_0x134b4d]of claudeContentBlocks(_0x444a5b)[_0x3f89e2(0x205)]()){const _0x3763c5=typeof _0x134b4d[_0x3f89e2(0x236)]===_0x3f89e2(0x1c5)?_0x134b4d[_0x3f89e2(0x236)]:_0x3f89e2(0x1be);if(_0x3763c5===_0x3f89e2(0x1b6)||_0x3763c5===_0x3f89e2(0x21d)||_0x3763c5===_0x3f89e2(0x237)||_0x3763c5===_0x3f89e2(0x1ef)||_0x3763c5===_0x3f89e2(0x207)||_0x3763c5===_0x3f89e2(0x224))continue;this[_0x3f89e2(0x215)][_0x3f89e2(0x23f)](_0x2d0b09,{'itemId':boundedConversationItemId(_0x3f89e2(0x21c),(typeof _0x444a5b[_0x3f89e2(0x1dc)]===_0x3f89e2(0x1c5)?_0x444a5b[_0x3f89e2(0x1dc)]:_0x2d0b09)+':'+_0x55c387),'kind':_0x3f89e2(0x1be),'status':_0x3f89e2(0x230),'payload':{'sourceEventType':_0x3f89e2(0x210)+_0x3763c5,'label':_0x3f89e2(0x1e3)+compactRunnerText(_0x3763c5,-0x2165*-0x1+-0x89*0x1+-0x1*0x205c)}});}}if(_0x444a5b[_0x3f89e2(0x236)]===_0x3f89e2(0x20c)&&typeof _0x444a5b[_0x3f89e2(0x217)]===_0x3f89e2(0x1c5)){const _0xd8ecfd=_0x3081ed[_0x3f89e2(0x220)](_0x444a5b[_0x3f89e2(0x217)]);if(_0xd8ecfd===_0x3f89e2(0x1d8)){const _0x45e238=typeof _0x444a5b[_0x3f89e2(0x20d)]===_0x3f89e2(0x24a)?'\x20('+Math[_0x3f89e2(0x1ee)](0x20df+-0x1fd1+-0x10e,Math[_0x3f89e2(0x1d0)](_0x444a5b[_0x3f89e2(0x20d)]))+_0x3f89e2(0x223):'';this[_0x3f89e2(0x215)][_0x3f89e2(0x23f)](_0x2d0b09,{'itemId':boundedConversationItemId(_0x3f89e2(0x1f0),_0x444a5b[_0x3f89e2(0x217)]),'kind':_0xd8ecfd,'status':_0x3f89e2(0x1b7),'payload':{'progressLabel':compactRunnerText((typeof _0x444a5b[_0x3f89e2(0x1ae)]===_0x3f89e2(0x1c5)?_0x444a5b[_0x3f89e2(0x1ae)]:_0x3f89e2(0x22f))+_0x3f89e2(0x1f7)+_0x45e238,0x199b+-0x59+-0x174e),'progressLabelCode':typeof _0x444a5b[_0x3f89e2(0x20d)]===_0x3f89e2(0x24a)?_0x3f89e2(0x1bd):_0x3f89e2(0x1d3),'progressLabelParameters':{'tool':typeof _0x444a5b[_0x3f89e2(0x1ae)]===_0x3f89e2(0x1c5)?_0x444a5b[_0x3f89e2(0x1ae)]:_0x3f89e2(0x22f),'seconds':typeof _0x444a5b[_0x3f89e2(0x20d)]===_0x3f89e2(0x24a)?Math[_0x3f89e2(0x1ee)](-0xa1*-0x2c+0x1ef9+-0x3aa5,Math[_0x3f89e2(0x1d0)](_0x444a5b[_0x3f89e2(0x20d)])):-0xdb9+0x211b+-0x1362}},'merge':!![]});}}if(_0x444a5b[_0x3f89e2(0x236)]===_0x3f89e2(0x1c8))for(const _0x14b466 of extractClaudeToolResults(_0x444a5b)){const _0xd7f8e0=_0x3081ed[_0x3f89e2(0x220)](_0x14b466[_0x3f89e2(0x1ce)])??_0x3f89e2(0x1d8);if(_0xd7f8e0===_0x3f89e2(0x1e8))continue;this[_0x3f89e2(0x215)][_0x3f89e2(0x23f)](_0x2d0b09,{'itemId':boundedConversationItemId(_0x3f89e2(0x1f0),_0x14b466[_0x3f89e2(0x1ce)]),'kind':_0xd7f8e0,'status':_0x14b466[_0x3f89e2(0x21f)]?_0x3f89e2(0x231):_0x3f89e2(0x230),'payload':_0xd7f8e0===_0x3f89e2(0x1c3)?{'outputPreview':_0x14b466[_0x3f89e2(0x1b1)],'exitCode':null,'durationMs':null,'truncated':_0x14b466[_0x3f89e2(0x229)]}:_0xd7f8e0===_0x3f89e2(0x23a)?{}:{'outputSummary':_0x14b466[_0x3f89e2(0x1b1)],'progressLabel':null,'errorCode':_0x14b466[_0x3f89e2(0x21f)]?_0x3f89e2(0x1f8):null,'truncated':_0x14b466[_0x3f89e2(0x229)]},'merge':!![]});}if(_0x444a5b[_0x3f89e2(0x236)]===_0x3f89e2(0x201)){const _0x4ed436=typeof _0x444a5b[_0x3f89e2(0x209)]===_0x3f89e2(0x1c5)?_0x444a5b[_0x3f89e2(0x209)]:_0x3f89e2(0x1be),_0xc7467e=this[_0x3f89e2(0x248)][_0x3f89e2(0x20f)][_0x3f89e2(0x1d5)][_0x3f89e2(0x220)](_0x2d0b09)?.[_0x3f89e2(0x250)]??_0x56add2;this[_0x3f89e2(0x215)][_0x3f89e2(0x22e)](_0x2d0b09,_0x3f89e2(0x1e4),{'subtype':_0x4ed436}),_0x208d69(_0x4ed436===_0x3f89e2(0x1c9)&&_0x444a5b[_0x3f89e2(0x22a)]!==!![]?_0x3f89e2(0x218):_0x3f89e2(0x231),_0x4ed436===_0x3f89e2(0x1c9)&&_0x444a5b[_0x3f89e2(0x22a)]!==!![]?_0x3f89e2(0x24b):_0x3f89e2(0x1e6),{'subtype':_0x4ed436},_0x444a5b);if(_0xc7467e!==undefined)void this[_0x3f89e2(0x215)][_0x3f89e2(0x1bc)](_0x4583db,_0xc7467e,_0x3fd54d);}}}),this[_0x3a8321(0x248)][_0x3a8321(0x20f)][_0x3a8321(0x1d5)][_0x3a8321(0x1f3)](_0x2d0b09,{'marSessionId':_0x4583db,'cwd':_0x3fd54d,'handle':_0x378e34,'gate':_0x14ed53}),this[_0x3a8321(0x215)][_0x3a8321(0x1c4)](_0x4583db,_0x14ed53[_0x3a8321(0x1df)]),this[_0x3a8321(0x215)][_0x3a8321(0x1f1)](_0x3a8321(0x206),{'sessionId':_0x4583db,'token':_0x14ed53[_0x3a8321(0x1df)]}),this[_0x3a8321(0x215)][_0x3a8321(0x22e)](_0x2d0b09,_0x3a8321(0x242),{},_0x3a8321(0x235)),void _0x378e34[_0x3a8321(0x1cf)][_0x3a8321(0x1d1)](()=>_0x208d69(_0x3a8321(0x218),_0x3a8321(0x24b),{'subtype':_0x3a8321(0x1f6)}),_0x15a0d5=>_0x208d69(_0x3a8321(0x231),_0x3a8321(0x1e6),{'code':safeErrorCode(_0x15a0d5,_0x3a8321(0x212))},_0x15a0d5));}catch(_0x2ecb6c){_0x208d69(_0x3a8321(0x231),_0x3a8321(0x1e6),{'code':safeErrorCode(_0x2ecb6c,_0x3a8321(0x21b))},_0x2ecb6c,_0x3a8321(0x21b));}}}
1
+ import { createEnvelope } from '@myagentroam/protocol';
2
+ import { ClaudeChannelGate } from '../../claude-channel.js';
3
+ import { boundedConversationItemId, claudePlanText, compactRunnerText, extractClaudeText, extractClaudeThinkingSummaries, extractClaudeToolResults, extractClaudeToolUses } from '../codex/conversation-parser.js';
4
+ import { normalizeClaudeTool } from './tool-normalizer.js';
5
+ import { claudeContentBlocks } from '../../util/node-operation-parsers.js';
6
+ import { parseSecretEnvironment } from '../../util/secret-environment.js';
7
+ import { safeErrorCode } from '../../util/safe-error.js';
8
+ import { runnerErrorProjection } from '../../util/runner-error.js';
9
+ export class ClaudeManagedRunController {
10
+ runner;
11
+ host;
12
+ constructor(runner, host) {
13
+ this.runner = runner;
14
+ this.host = host;
15
+ }
16
+ async executeCommand(session, command, input, context) {
17
+ if (command.id === 'compact')
18
+ return this.compact(session, input, context.secretEnvironment, context.initiatedByUserId);
19
+ if (command.id !== 'plan' || session.access === 'plan')
20
+ throw new Error('RUNNER_COMMAND_UNAVAILABLE');
21
+ const current = this.host.commandState(session.id, 'plan');
22
+ if (current?.active)
23
+ this.host.clearCommandState(session.id, 'plan');
24
+ else
25
+ this.host.setCommandState(session.id, {
26
+ commandId: 'plan',
27
+ active: true,
28
+ label: 'Plan Mode',
29
+ detail: 'Subsequent messages run in read-only tagged Plan Mode and produce a plan card.',
30
+ closable: true,
31
+ closeInput: '/plan',
32
+ continuation: { label: 'Implement', prompt: 'Implement the plan above.' }
33
+ });
34
+ return { command: command.id, states: this.host.commandStates(session.id) };
35
+ }
36
+ compact(session, input, secretEnvironment, initiatedByUserId) {
37
+ if (session.externalSessionId === null ||
38
+ session.nativeControl !== 'MAR_MANAGED' ||
39
+ this.host.hasActiveSessionLease(session.id))
40
+ throw new Error('RUNNER_COMMAND_UNAVAILABLE');
41
+ const runId = crypto.randomUUID();
42
+ this.host.adopt({
43
+ runId,
44
+ sessionId: session.id,
45
+ runner: 'claude-code',
46
+ cwd: session.cwd,
47
+ externalSessionId: session.externalSessionId,
48
+ ...(initiatedByUserId === undefined ? {} : { initiatedByUserId })
49
+ });
50
+ this.host.rememberNative(session.externalSessionId, session.id);
51
+ this.start(createEnvelope('run.start', {
52
+ runId,
53
+ sessionId: session.id,
54
+ runner: 'claude-code',
55
+ input,
56
+ cwd: session.cwd,
57
+ externalSessionId: session.externalSessionId,
58
+ model: session.model,
59
+ effort: session.effort,
60
+ access: session.access,
61
+ secretEnvironment
62
+ }));
63
+ return {
64
+ command: 'compact',
65
+ run: this.host.run(runId),
66
+ states: this.host.commandStates(session.id)
67
+ };
68
+ }
69
+ start(envelope) {
70
+ const payload = envelope.payload;
71
+ if (payload.runner !== 'claude-code' ||
72
+ typeof payload.runId !== 'string' ||
73
+ typeof payload.sessionId !== 'string' ||
74
+ typeof payload.input !== 'string' ||
75
+ typeof payload.cwd !== 'string' ||
76
+ this.host.intercepted() ||
77
+ this.host.active.has(payload.runId))
78
+ return;
79
+ const runId = payload.runId;
80
+ const sessionId = payload.sessionId;
81
+ const cwd = payload.cwd;
82
+ const contextCompactionItemId = payload.input.trim() === '/compact'
83
+ ? boundedConversationItemId('claude-compact', runId)
84
+ : undefined;
85
+ let attachments;
86
+ let secretEnvironment;
87
+ let mcpSecretEnvironment;
88
+ try {
89
+ attachments = this.host.parseAttachments(payload.attachments);
90
+ secretEnvironment = parseSecretEnvironment(payload.secretEnvironment);
91
+ mcpSecretEnvironment = parseSecretEnvironment(payload.mcpSecretEnvironment);
92
+ }
93
+ catch (error) {
94
+ this.host.emit(runId, 'run.rejected', { code: safeErrorCode(error, 'MESSAGE_ATTACHMENTS_INVALID') }, 'FAILED');
95
+ return;
96
+ }
97
+ this.host.adopt({
98
+ runId,
99
+ sessionId,
100
+ runner: 'claude-code',
101
+ cwd,
102
+ ...(typeof payload.externalSessionId === 'string'
103
+ ? { externalSessionId: payload.externalSessionId }
104
+ : {})
105
+ });
106
+ // An insert request may interrupt a Claude Run while its SDK Channel is
107
+ // still starting. Do not start that stale Channel after the replacement
108
+ // message has been accepted; emit its terminal projection to release the
109
+ // replacement queued behind it.
110
+ if (this.host.run(runId)?.status === 'INTERRUPTED') {
111
+ this.host.emit(runId, 'run.completed', { status: 'INTERRUPTED' }, 'INTERRUPTED');
112
+ return;
113
+ }
114
+ if (this.host.completeCancelled(runId, cwd))
115
+ return;
116
+ if (typeof payload.externalSessionId === 'string' &&
117
+ !this.runner.execution.managedNativeIds.has(payload.externalSessionId)) {
118
+ this.host.emit(runId, 'run.rejected', { code: 'EXTERNAL_SESSION_OBSERVE_ONLY' }, 'FAILED');
119
+ return;
120
+ }
121
+ this.host.active.add(runId);
122
+ this.host.emit(runId, 'run.started', {}, 'STARTING');
123
+ if (contextCompactionItemId !== undefined)
124
+ this.host.emitItem(runId, {
125
+ itemId: contextCompactionItemId,
126
+ kind: 'context_compaction',
127
+ status: 'IN_PROGRESS',
128
+ payload: { phase: 'STARTED', summary: null },
129
+ merge: true
130
+ });
131
+ let terminal = false;
132
+ let handle;
133
+ const toolKinds = new Map();
134
+ const finish = (status, eventType, eventPayload, failure, fallbackCode = 'CLAUDE_RUN_FAILED') => {
135
+ if (terminal)
136
+ return;
137
+ terminal = true;
138
+ const projected = status === 'FAILED'
139
+ ? runnerErrorProjection(failure ?? eventPayload, fallbackCode)
140
+ : undefined;
141
+ if (projected !== undefined) {
142
+ this.host.emitItem(runId, {
143
+ itemId: boundedConversationItemId('runner-error', runId),
144
+ kind: 'error',
145
+ status: 'FAILED',
146
+ payload: { ...projected, recoverable: true, retryAfterMs: null }
147
+ });
148
+ }
149
+ if (status === 'SUCCEEDED' && contextCompactionItemId !== undefined)
150
+ this.host.emitItem(runId, {
151
+ itemId: contextCompactionItemId,
152
+ kind: 'context_compaction',
153
+ status: 'COMPLETED',
154
+ payload: { phase: 'COMPLETED', summary: null },
155
+ merge: true
156
+ });
157
+ this.host.emit(runId, eventType, projected ?? eventPayload, status);
158
+ this.runner.execution.runs.delete(runId);
159
+ handle?.cancel();
160
+ this.host.active.delete(runId);
161
+ };
162
+ try {
163
+ const gate = new ClaudeChannelGate(sessionId);
164
+ handle = this.runner.startChannel({
165
+ prompt: payload.input,
166
+ cwd,
167
+ ...(typeof payload.externalSessionId === 'string'
168
+ ? { resumeSessionId: payload.externalSessionId }
169
+ : {}),
170
+ ...(typeof payload.model === 'string' ? { model: payload.model } : {}),
171
+ ...(typeof payload.effort === 'string' ? { effort: payload.effort } : {}),
172
+ ...(typeof payload.access === 'string' ? { access: payload.access } : {}),
173
+ environment: secretEnvironment,
174
+ ...(typeof payload.personalInstructions === 'string'
175
+ ? { personalInstructions: payload.personalInstructions }
176
+ : {}),
177
+ mcpServers: this.runner.mcpConfiguration(payload.mcpInstallations, {
178
+ ...secretEnvironment,
179
+ ...mcpSecretEnvironment
180
+ }),
181
+ ...(attachments.length === 0
182
+ ? {}
183
+ : {
184
+ attachments: attachments.map((attachment) => ({
185
+ mime: attachment.mime,
186
+ dataBase64: attachment.dataBase64
187
+ }))
188
+ }),
189
+ onPermission: (toolName, toolInput, options) => toolName === 'AskUserQuestion'
190
+ ? (toolKinds.set(options.toolUseID, 'user_input_request'),
191
+ this.host.requestUserInput(runId, toolInput, options.toolUseID))
192
+ : this.host.requestApproval(runId, toolName, toolInput),
193
+ onChannelReply: (content) => this.host.emit(runId, 'channel.reply', { content }),
194
+ onMessage: (message) => {
195
+ const record = message;
196
+ const nativeSessionId = typeof record.session_id === 'string' ? record.session_id : undefined;
197
+ const current = this.runner.execution.runs.get(runId);
198
+ if (nativeSessionId !== undefined && current !== undefined) {
199
+ const firstNativeSessionId = current.nativeSessionId === undefined;
200
+ if (firstNativeSessionId)
201
+ this.runner.execution.runs.set(runId, { ...current, nativeSessionId });
202
+ const managed = this.host.session(sessionId);
203
+ if (managed?.nativeControl === 'MAR_MANAGED')
204
+ this.host.rememberNative(nativeSessionId, managed.id);
205
+ if (firstNativeSessionId && typeof payload.externalSessionId !== 'string') {
206
+ this.host.promote(sessionId, nativeSessionId);
207
+ this.host.send('session.external-id', {
208
+ sessionId,
209
+ externalSessionId: nativeSessionId
210
+ });
211
+ const managed = this.runner.execution.runs.get(runId);
212
+ if (managed !== undefined)
213
+ this.runner.execution.runs.set(runId, {
214
+ ...managed,
215
+ marSessionId: nativeSessionId
216
+ });
217
+ }
218
+ }
219
+ if (record.type === 'assistant') {
220
+ const text = extractClaudeText(record);
221
+ const planText = claudePlanText(text);
222
+ if (planText !== undefined)
223
+ this.host.emitItem(runId, {
224
+ itemId: boundedConversationItemId('claude-plan', typeof record.uuid === 'string' ? record.uuid : `${runId}:plan`),
225
+ kind: 'plan',
226
+ status: 'COMPLETED',
227
+ payload: { explanation: compactRunnerText(planText, 20_000), steps: [] }
228
+ });
229
+ else if (text.length > 0)
230
+ this.host.emit(runId, 'text.delta', { text });
231
+ for (const [index, text] of extractClaudeThinkingSummaries(record).entries()) {
232
+ this.host.emitItem(runId, {
233
+ itemId: boundedConversationItemId('claude-reasoning', `${typeof record.uuid === 'string' ? record.uuid : runId}:${index}`),
234
+ kind: 'reasoning_summary',
235
+ status: 'COMPLETED',
236
+ payload: { sections: [{ index, text }] }
237
+ });
238
+ }
239
+ for (const tool of extractClaudeToolUses(record)) {
240
+ if (tool.name === 'AskUserQuestion') {
241
+ toolKinds.set(tool.id, 'user_input_request');
242
+ continue;
243
+ }
244
+ const itemId = boundedConversationItemId('claude-tool', tool.id);
245
+ const normalized = normalizeClaudeTool(tool.name, tool.input, null, false, tool.inputTruncated);
246
+ const kind = normalized.kind;
247
+ toolKinds.set(tool.id, kind);
248
+ this.host.emitItem(runId, {
249
+ itemId,
250
+ kind,
251
+ status: 'IN_PROGRESS',
252
+ payload: normalized.payload
253
+ });
254
+ }
255
+ for (const [index, block] of claudeContentBlocks(record).entries()) {
256
+ const type = typeof block.type === 'string' ? block.type : 'unknown';
257
+ if (type === 'text' ||
258
+ type === 'thinking' ||
259
+ type === 'redacted_thinking' ||
260
+ type === 'encrypted_thinking' ||
261
+ type === 'tool_use' ||
262
+ type === 'tool_result')
263
+ continue;
264
+ this.host.emitItem(runId, {
265
+ itemId: boundedConversationItemId('claude-item', `${typeof record.uuid === 'string' ? record.uuid : runId}:${index}`),
266
+ kind: 'unknown',
267
+ status: 'COMPLETED',
268
+ payload: {
269
+ sourceEventType: `claude-code:${type}`,
270
+ label: `Claude Code ${compactRunnerText(type, 128)}`
271
+ }
272
+ });
273
+ }
274
+ }
275
+ if (record.type === 'tool_progress' && typeof record.tool_use_id === 'string') {
276
+ const kind = toolKinds.get(record.tool_use_id);
277
+ if (kind === 'tool_call') {
278
+ const elapsed = typeof record.elapsed_time_seconds === 'number'
279
+ ? ` (${Math.max(0, Math.round(record.elapsed_time_seconds))} seconds)`
280
+ : '';
281
+ this.host.emitItem(runId, {
282
+ itemId: boundedConversationItemId('claude-tool', record.tool_use_id),
283
+ kind,
284
+ status: 'IN_PROGRESS',
285
+ payload: {
286
+ progressLabel: compactRunnerText(`${typeof record.tool_name === 'string' ? record.tool_name : 'Tool'} is running${elapsed}`, 500),
287
+ progressLabelCode: typeof record.elapsed_time_seconds === 'number'
288
+ ? 'TOOL_RUNNING_WITH_DURATION'
289
+ : 'TOOL_RUNNING',
290
+ progressLabelParameters: {
291
+ tool: typeof record.tool_name === 'string' ? record.tool_name : 'Tool',
292
+ seconds: typeof record.elapsed_time_seconds === 'number'
293
+ ? Math.max(0, Math.round(record.elapsed_time_seconds))
294
+ : 0
295
+ }
296
+ },
297
+ merge: true
298
+ });
299
+ }
300
+ }
301
+ if (record.type === 'user') {
302
+ for (const result of extractClaudeToolResults(record)) {
303
+ const kind = toolKinds.get(result.toolUseId) ?? 'tool_call';
304
+ if (kind === 'user_input_request')
305
+ continue;
306
+ this.host.emitItem(runId, {
307
+ itemId: boundedConversationItemId('claude-tool', result.toolUseId),
308
+ kind,
309
+ status: result.failed ? 'FAILED' : 'COMPLETED',
310
+ payload: kind === 'command_execution'
311
+ ? {
312
+ outputPreview: result.output,
313
+ exitCode: null,
314
+ durationMs: null,
315
+ truncated: result.truncated
316
+ }
317
+ : kind === 'file_change'
318
+ ? {}
319
+ : {
320
+ outputSummary: result.output,
321
+ progressLabel: null,
322
+ errorCode: result.failed ? 'TOOL_EXECUTION_FAILED' : null,
323
+ truncated: result.truncated
324
+ },
325
+ merge: true
326
+ });
327
+ }
328
+ }
329
+ if (record.type === 'result') {
330
+ const subtype = typeof record.subtype === 'string' ? record.subtype : 'unknown';
331
+ const completedNativeSessionId = this.runner.execution.runs.get(runId)?.nativeSessionId ?? nativeSessionId;
332
+ this.host.emit(runId, 'turn.completed', {
333
+ subtype
334
+ });
335
+ // A Channel uses a long-lived input iterable. Receiving an SDK
336
+ // result completes this AgentRun even though that iterable can
337
+ // remain open waiting for another user turn; waiting only for
338
+ // stream closure would leave the WorkspaceLease permanently held.
339
+ finish(subtype === 'success' && record.is_error !== true ? 'SUCCEEDED' : 'FAILED', subtype === 'success' && record.is_error !== true ? 'run.completed' : 'run.failed', { subtype }, record);
340
+ if (completedNativeSessionId !== undefined)
341
+ void this.host.syncTitle(sessionId, completedNativeSessionId, cwd);
342
+ }
343
+ }
344
+ });
345
+ this.runner.execution.runs.set(runId, { marSessionId: sessionId, cwd, handle, gate });
346
+ this.host.setChannelToken(sessionId, gate.token);
347
+ this.host.send('session.channel.ready', { sessionId, token: gate.token });
348
+ this.host.emit(runId, 'run.running', {}, 'RUNNING');
349
+ void handle.completed.then(() => finish('SUCCEEDED', 'run.completed', { subtype: 'stream_closed' }), (error) => finish('FAILED', 'run.failed', { code: safeErrorCode(error, 'CLAUDE_RUN_FAILED') }, error));
350
+ }
351
+ catch (error) {
352
+ finish('FAILED', 'run.failed', { code: safeErrorCode(error, 'CLAUDE_RUN_START_FAILED') }, error, 'CLAUDE_RUN_START_FAILED');
353
+ }
354
+ }
355
+ }
@@ -1,2 +1,120 @@
1
- /* mar-release-protected */
2
- (function(_0x1c1c1d,_0x130728){const _0x42718d=_0x2a5f,_0x5b6713=_0x1c1c1d();while(!![]){try{const _0x414754=-parseInt(_0x42718d(0x184))/(-0x32b*0xc+0xb6+0x254f)*(-parseInt(_0x42718d(0x19b))/(0x158d+-0x1637+0xac))+parseInt(_0x42718d(0x176))/(0x36b*0x1+0x1c16+-0x8b*0x3a)*(parseInt(_0x42718d(0x197))/(0xacf*-0x1+0x661*-0x1+0x1134))+-parseInt(_0x42718d(0x186))/(0x1a8*0x2+-0x610+0x2c5)+-parseInt(_0x42718d(0x172))/(0xfde*0x1+0x2615*0x1+-0x1*0x35ed)+parseInt(_0x42718d(0x173))/(-0x17e7+-0x5*-0x59f+-0x42d)*(-parseInt(_0x42718d(0x18f))/(0x1f5b+0x98d+0x368*-0xc))+-parseInt(_0x42718d(0x18a))/(-0x292*0x4+-0x1f36+0x1*0x2987)+parseInt(_0x42718d(0x18e))/(-0x1aa5+0x134f+0xec*0x8);if(_0x414754===_0x130728)break;else _0x5b6713['push'](_0x5b6713['shift']());}catch(_0xfac246){_0x5b6713['push'](_0x5b6713['shift']());}}}(_0x2508,-0x44f91+0x3*-0x22cd9+0xeb27b));import{compactRunnerText,compactRunnerValue}from'../../util/node-operation-parsers.js';export function normalizeClaudeTool(_0x5c6a00,_0x2d8cb1,_0x520c8f,_0x4543ad,_0x9d234e){const _0x216b8d=_0x2a5f,_0x3cf2a3=record(_0x2d8cb1),_0x7d3194=compactRunnerText(_0x5c6a00,-0x1c79+0xe15+-0x772*-0x2)||_0x216b8d(0x17b),_0x1e955a=_0x520c8f===null?null:compactRunnerText(_0x520c8f,-0xabf+-0x1500+0x46cf),_0x2ffcf4=_0x9d234e||(_0x520c8f?.[_0x216b8d(0x182)]??-0x13*-0x8b+0x40b*-0x1+-0x646)>-0x17dd+0x1dac+0x1*0x2141,_0x17e142=claudeSubagentProjection(_0x5c6a00,_0x2d8cb1,_0x520c8f);if(isCommandTool(_0x5c6a00))return{'kind':_0x216b8d(0x189),'payload':{'command':compactRunnerText(typeof _0x3cf2a3?.[_0x216b8d(0x185)]===_0x216b8d(0x16e)?_0x3cf2a3[_0x216b8d(0x185)]:_0x7d3194,0x3801+-0x1*0x21a1+0x10b0),'cwd':null,'outputPreview':_0x1e955a??'','outputRef':null,'exitCode':null,'durationMs':null,'truncated':_0x2ffcf4}};if(isFileTool(_0x5c6a00)){const _0x27e53f=typeof _0x3cf2a3?.[_0x216b8d(0x16c)]===_0x216b8d(0x16e)?_0x3cf2a3[_0x216b8d(0x16c)]:typeof _0x3cf2a3?.[_0x216b8d(0x191)]===_0x216b8d(0x16e)?_0x3cf2a3[_0x216b8d(0x191)]:typeof _0x3cf2a3?.[_0x216b8d(0x18b)]===_0x216b8d(0x16e)?_0x3cf2a3[_0x216b8d(0x18b)]:null,_0x23fbbe=_0x27e53f===null?null:compactRunnerText(_0x27e53f,-0x26*0xb2+0x1e09+0xc63);return{'kind':_0x216b8d(0x17e),'payload':{'changes':_0x23fbbe===null||_0x23fbbe[_0x216b8d(0x182)]===-0x1163*-0x2+0x1de7*0x1+-0x158f*0x3?[]:[{'path':_0x23fbbe,'change':_0x216b8d(0x199),'additions':null,'deletions':null,'diffAvailable':![]}]}};}return{'kind':_0x216b8d(0x170),'payload':{'namespace':_0x216b8d(0x18c),'toolName':_0x7d3194,'title':compactRunnerText(_0x5c6a00,-0x170b+-0x129b*0x1+0x2b9a)||_0x7d3194,'inputSummary':compactRunnerValue(_0x2d8cb1,0xc76+-0x3*-0x18d7+-0xff9*0x3)[_0x216b8d(0x192)]||null,'outputSummary':_0x1e955a,'progressLabel':null,'errorCode':_0x4543ad?_0x216b8d(0x174):null,'truncated':_0x2ffcf4,..._0x17e142}};}function isCommandTool(_0x179782){const _0x221909=_0x2a5f;return _0x179782===_0x221909(0x193)||_0x179782===_0x221909(0x187)||_0x179782===_0x221909(0x16d);}function isFileTool(_0x3c8984){const _0xec3d7e=_0x2a5f;return _0x3c8984===_0xec3d7e(0x171)||_0x3c8984===_0xec3d7e(0x196)||_0x3c8984===_0xec3d7e(0x179)||_0x3c8984===_0xec3d7e(0x175);}function _0x2a5f(_0x2fff78,_0x268c7b){_0x2fff78=_0x2fff78-(0x1664+0xbd8+-0x20d0);const _0x49530c=_0x2508();let _0x3e7cde=_0x49530c[_0x2fff78];if(_0x2a5f['BugKAX']===undefined){var _0xdb69f7=function(_0x520c8f){const _0x4543ad='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x9d234e='',_0x3cf2a3='';for(let _0x7d3194=0x10*0x8b+-0x166*-0x3+-0x671*0x2,_0x1e955a,_0x2ffcf4,_0x17e142=-0x2345+0x7e0+0x1b65;_0x2ffcf4=_0x520c8f['charAt'](_0x17e142++);~_0x2ffcf4&&(_0x1e955a=_0x7d3194%(-0x19ee+-0x1*0x104d+-0x15*-0x203)?_0x1e955a*(0x11a1+0x2536+-0x145*0x2b)+_0x2ffcf4:_0x2ffcf4,_0x7d3194++%(0x28*-0x5+0x1afe+-0x1a32))?_0x9d234e+=String['fromCharCode'](0x1936+-0x116d+0x365*-0x2&_0x1e955a>>(-(-0x1010+0xbee*-0x3+-0xcf7*-0x4)*_0x7d3194&-0x6f*-0x57+0x24e2+-0x4a95)):-0x1113+0xf84+0x18f*0x1){_0x2ffcf4=_0x4543ad['indexOf'](_0x2ffcf4);}for(let _0x27e53f=-0x1115+-0x951*-0x4+-0x142f*0x1,_0x23fbbe=_0x9d234e['length'];_0x27e53f<_0x23fbbe;_0x27e53f++){_0x3cf2a3+='%'+('00'+_0x9d234e['charCodeAt'](_0x27e53f)['toString'](-0x66a+0x1096+0x4*-0x287))['slice'](-(0x1*0x674+-0x7c3*0x3+-0x9*-0x1df));}return decodeURIComponent(_0x3cf2a3);};_0x2a5f['dNyxYO']=_0xdb69f7,_0x2a5f['RFYFcU']={},_0x2a5f['BugKAX']=!![];}const _0x5c6a00=_0x49530c[0x7d7+-0x1034*-0x2+-0x283f];_0x2a5f['abaqAM']!==_0x5c6a00&&(_0x2a5f['RFYFcU']={},_0x2a5f['abaqAM']=_0x5c6a00);const _0x2d8cb1=_0x2a5f['RFYFcU'][_0x2fff78];return _0x2d8cb1===undefined?(_0x3e7cde=_0x2a5f['dNyxYO'](_0x3e7cde),_0x2a5f['RFYFcU'][_0x2fff78]=_0x3e7cde):_0x3e7cde=_0x2d8cb1,_0x3e7cde;}function record(_0x691126){const _0x458141=_0x2a5f;return _0x691126!==null&&typeof _0x691126===_0x458141(0x183)&&!Array[_0x458141(0x17a)](_0x691126)?_0x691126:undefined;}function claudeSubagentProjection(_0x42e86b,_0x1b6bc0,_0x1a70e6){const _0x47f1cb=_0x2a5f,_0x5a1e11=_0x42e86b[_0x47f1cb(0x180)](),_0x145e05=_0x5a1e11===_0x47f1cb(0x195)?_0x47f1cb(0x181):_0x5a1e11===_0x47f1cb(0x18d)?_0x47f1cb(0x188):_0x5a1e11===_0x47f1cb(0x190)?_0x47f1cb(0x16f):_0x5a1e11===_0x47f1cb(0x17f)?_0x47f1cb(0x178):undefined;if(_0x145e05===undefined)return undefined;const _0x31f542=structuredRecord(_0x1b6bc0),_0x256640=structuredRecord(_0x1a70e6),_0x46bd54=_0x5a1e11===_0x47f1cb(0x195)?boundedId(_0x256640?.[_0x47f1cb(0x177)]):_0x5a1e11===_0x47f1cb(0x17f)?boundedId(_0x31f542?.['to']):boundedId(_0x31f542?.[_0x47f1cb(0x17c)])??boundedId(_0x256640?.[_0x47f1cb(0x17c)]),_0x35a196=_0x5a1e11===_0x47f1cb(0x195)&&typeof _0x31f542?.[_0x47f1cb(0x198)]===_0x47f1cb(0x16e)?compactRunnerText(_0x31f542[_0x47f1cb(0x198)],0x402+-0x43*0x5d+0x1649):'';return{'subagentOperation':_0x145e05,'subagentId':_0x46bd54??null,..._0x35a196[_0x47f1cb(0x182)]===-0xc3*-0x2e+0x1*0x1072+-0xa4c*0x5?{}:{'title':_0x35a196}};}function structuredRecord(_0x5781cb){const _0x4ee97c=_0x2a5f;if(typeof _0x5781cb!==_0x4ee97c(0x16e))return record(_0x5781cb);const _0x4379d8=_0x5781cb[_0x4ee97c(0x194)]();if(!_0x4379d8[_0x4ee97c(0x19a)]('{'))return undefined;try{return record(JSON[_0x4ee97c(0x17d)](_0x4379d8));}catch{return undefined;}}function boundedId(_0x5564de){const _0xf924d6=_0x2a5f;if(typeof _0x5564de!==_0xf924d6(0x16e))return undefined;const _0x3c044d=_0x5564de[_0xf924d6(0x194)]();return _0x3c044d[_0xf924d6(0x182)]>0x1f87*0x1+-0xddc+-0x11ab*0x1&&_0x3c044d[_0xf924d6(0x182)]<=-0x1689+0x5*0xd+0x16c8?_0x3c044d:undefined;}function _0x2508(){const _0x15b271=['C3rYAw5N','q0foq0vm','Dg9VBf9JywXS','v3jPDgu','mtuXotKYnKLTC3rbuq','mtq3mZvmuKXVr0u','ve9ptf9fwevdvvrjt05FrKfjteve','tM90zwjVB2TfzgL0','mJi1nta3wKDnzLzb','ywDLBNrjza','tuvtu0fhrq','txvSDgLfzgL0','AxnbCNjHEq','Dw5RBM93BG','DgfZA19Pza','CgfYC2u','zMLSzv9JAgfUz2u','C2vUzg1LC3nHz2u','Dg9mB3DLCKnHC2u','u1rbuLq','BgvUz3rO','B2jQzwn0','mti5neH0wKPJBW','y29TBwfUza','mti1mZm4nufsBM5ysa','yMfZAa','u1rbvfvt','y29TBwfUzf9LEgvJDxrPB24','mJa2mZG4mgXPr2Tewq','BM90zwjVB2TFCgf0Aa','y2XHDwrLlwnVzgu','DgfZA291Dhb1Da','nta5mtiYmg1tquzLta','odG4uhbRELjq','DgfZA3n0B3a','Cgf0Aa','Dgv4Da','qMfZAa','DhjPBq','ywDLBNq','rwrPDa','mtzTD1PQr1G','zgvZy3jPChrPB24','tu9esuzjruq','C3rHCNrZv2L0Aa','nJm0CxDJCxPZ','zMLSzv9WyxrO','u2HLBgW'];_0x2508=function(){return _0x15b271;};return _0x2508();}
1
+ import { compactRunnerText, compactRunnerValue } from '../../util/node-operation-parsers.js';
2
+ export function normalizeClaudeTool(toolName, input, output, failed, truncated) {
3
+ const values = record(input);
4
+ const normalizedToolName = compactRunnerText(toolName, 128) || 'unknown';
5
+ const normalizedOutput = output === null ? null : compactRunnerText(output, 10_000);
6
+ const outputTruncated = truncated || (output?.length ?? 0) > 10_000;
7
+ const subagent = claudeSubagentProjection(toolName, input, output);
8
+ if (isCommandTool(toolName))
9
+ return {
10
+ kind: 'command_execution',
11
+ payload: {
12
+ command: compactRunnerText(typeof values?.command === 'string' ? values.command : normalizedToolName, 10_000),
13
+ cwd: null,
14
+ outputPreview: normalizedOutput ?? '',
15
+ outputRef: null,
16
+ exitCode: null,
17
+ durationMs: null,
18
+ truncated: outputTruncated
19
+ }
20
+ };
21
+ if (isFileTool(toolName)) {
22
+ const path = typeof values?.file_path === 'string'
23
+ ? values.file_path
24
+ : typeof values?.path === 'string'
25
+ ? values.path
26
+ : typeof values?.notebook_path === 'string'
27
+ ? values.notebook_path
28
+ : null;
29
+ const normalizedPath = path === null ? null : compactRunnerText(path, 4_096);
30
+ return {
31
+ kind: 'file_change',
32
+ payload: {
33
+ changes: normalizedPath === null || normalizedPath.length === 0
34
+ ? []
35
+ : [
36
+ {
37
+ path: normalizedPath,
38
+ change: 'MODIFIED',
39
+ additions: null,
40
+ deletions: null,
41
+ diffAvailable: false
42
+ }
43
+ ]
44
+ }
45
+ };
46
+ }
47
+ return {
48
+ kind: 'tool_call',
49
+ payload: {
50
+ namespace: 'claude-code',
51
+ toolName: normalizedToolName,
52
+ title: compactRunnerText(toolName, 500) || normalizedToolName,
53
+ inputSummary: compactRunnerValue(input, 10_000).text || null,
54
+ outputSummary: normalizedOutput,
55
+ progressLabel: null,
56
+ errorCode: failed ? 'TOOL_EXECUTION_FAILED' : null,
57
+ truncated: outputTruncated,
58
+ ...subagent
59
+ }
60
+ };
61
+ }
62
+ function isCommandTool(name) {
63
+ return name === 'Bash' || name === 'bash' || name === 'Shell';
64
+ }
65
+ function isFileTool(name) {
66
+ return name === 'Write' || name === 'Edit' || name === 'MultiEdit' || name === 'NotebookEdit';
67
+ }
68
+ function record(value) {
69
+ return value !== null && typeof value === 'object' && !Array.isArray(value)
70
+ ? value
71
+ : undefined;
72
+ }
73
+ function claudeSubagentProjection(toolName, input, output) {
74
+ const normalizedName = toolName.toLowerCase();
75
+ const operation = normalizedName === 'agent'
76
+ ? 'START'
77
+ : normalizedName === 'taskoutput'
78
+ ? 'STATUS'
79
+ : normalizedName === 'taskstop'
80
+ ? 'CANCEL'
81
+ : normalizedName === 'sendmessage'
82
+ ? 'MESSAGE'
83
+ : undefined;
84
+ if (operation === undefined)
85
+ return undefined;
86
+ const inputData = structuredRecord(input);
87
+ const outputData = structuredRecord(output);
88
+ const subagentId = normalizedName === 'agent'
89
+ ? boundedId(outputData?.agentId)
90
+ : normalizedName === 'sendmessage'
91
+ ? boundedId(inputData?.to)
92
+ : (boundedId(inputData?.task_id) ?? boundedId(outputData?.task_id));
93
+ const title = normalizedName === 'agent' && typeof inputData?.description === 'string'
94
+ ? compactRunnerText(inputData.description, 500)
95
+ : '';
96
+ return {
97
+ subagentOperation: operation,
98
+ subagentId: subagentId ?? null,
99
+ ...(title.length === 0 ? {} : { title })
100
+ };
101
+ }
102
+ function structuredRecord(value) {
103
+ if (typeof value !== 'string')
104
+ return record(value);
105
+ const text = value.trim();
106
+ if (!text.startsWith('{'))
107
+ return undefined;
108
+ try {
109
+ return record(JSON.parse(text));
110
+ }
111
+ catch {
112
+ return undefined;
113
+ }
114
+ }
115
+ function boundedId(value) {
116
+ if (typeof value !== 'string')
117
+ return undefined;
118
+ const normalized = value.trim();
119
+ return normalized.length > 0 && normalized.length <= 128 ? normalized : undefined;
120
+ }