@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,170 @@
1
- /* mar-release-protected */
2
- const _0x58656c=_0x4953;(function(_0x334080,_0x5cf304){const _0x161f4f=_0x4953,_0x38bc24=_0x334080();while(!![]){try{const _0xe3db40=-parseInt(_0x161f4f(0x157))/(-0x1808+-0x551+0x1d5a)+parseInt(_0x161f4f(0x13e))/(-0x14e0+-0x23a8+-0x2*-0x1c45)*(-parseInt(_0x161f4f(0x130))/(0x2576+0x4*0x7b+0x275f*-0x1))+parseInt(_0x161f4f(0x165))/(0x182b*-0x1+0x24ac+-0xc7d)*(parseInt(_0x161f4f(0x14e))/(0xd82+-0x1861*0x1+-0x1*-0xae4))+-parseInt(_0x161f4f(0x16c))/(-0x1f48+-0x1d*0xcf+-0x83*-0x6b)*(parseInt(_0x161f4f(0x14d))/(-0xcf1*-0x1+0x1f81+-0x1*0x2c6b))+-parseInt(_0x161f4f(0x145))/(-0xc8a+-0x2c2*0x2+0x1216)+parseInt(_0x161f4f(0x13c))/(-0x6d*0x56+0xe83*0x1+0x1624)+parseInt(_0x161f4f(0x154))/(0x1*-0x1011+0x5*0x692+-0x10bf);if(_0xe3db40===_0x5cf304)break;else _0x38bc24['push'](_0x38bc24['shift']());}catch(_0x2b662c){_0x38bc24['push'](_0x38bc24['shift']());}}}(_0x40d8,-0x7002f+0x128f*-0x13+0xdef2b));import{posix}from'node:path';const WATCH_TTL_MS=-0x119c6+-0x2011*0x1+-0x3667*-0x9;function _0x4953(_0x941032,_0x582d83){_0x941032=_0x941032-(0x8cb*-0x1+-0x7*-0x16c+0x0);const _0x25c373=_0x40d8();let _0x18b428=_0x25c373[_0x941032];if(_0x4953['zbjwyI']===undefined){var _0x3c4847=function(_0x41fa24){const _0x4b4c86='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xfdacb0='',_0x243b4b='';for(let _0x14089a=-0x562*0x6+-0xbe2+0x2c2e,_0x2f7047,_0x2b6083,_0x2cd252=-0xfa6*-0x2+-0x3*0x719+-0xa01;_0x2b6083=_0x41fa24['charAt'](_0x2cd252++);~_0x2b6083&&(_0x2f7047=_0x14089a%(0x8c8*-0x2+-0x1*-0x14f7+-0x363*0x1)?_0x2f7047*(-0x1675+-0x16a2*-0x1+0x13)+_0x2b6083:_0x2b6083,_0x14089a++%(-0x1*0x1cdb+0x218b+-0x17*0x34))?_0xfdacb0+=String['fromCharCode'](0x2*0x645+0x171f+-0x22aa&_0x2f7047>>(-(-0x175b+0x7*0x328+0x5*0x41)*_0x14089a&-0x1*0x1439+-0x1674+0x283*0x11)):-0x1a26+0x5*-0x3a6+0x3b3*0xc){_0x2b6083=_0x4b4c86['indexOf'](_0x2b6083);}for(let _0x50f8c8=0x2250+-0x535+-0x1d1b,_0x366e3b=_0xfdacb0['length'];_0x50f8c8<_0x366e3b;_0x50f8c8++){_0x243b4b+='%'+('00'+_0xfdacb0['charCodeAt'](_0x50f8c8)['toString'](-0x240a+0x77a+0xe5*0x20))['slice'](-(-0x16ab+-0x1177+0x1*0x2824));}return decodeURIComponent(_0x243b4b);};_0x4953['XRNUjl']=_0x3c4847,_0x4953['vBaKuD']={},_0x4953['zbjwyI']=!![];}const _0x55f993=_0x25c373[0x1342*-0x1+-0x19b3*0x1+-0x2a5*-0x11];_0x4953['DtihWj']!==_0x55f993&&(_0x4953['vBaKuD']={},_0x4953['DtihWj']=_0x55f993);const _0x1c88fb=_0x4953['vBaKuD'][_0x941032];return _0x1c88fb===undefined?(_0x18b428=_0x4953['XRNUjl'](_0x18b428),_0x4953['vBaKuD'][_0x941032]=_0x18b428):_0x18b428=_0x1c88fb,_0x18b428;}export class WorkspaceWatchService{[_0x58656c(0x14a)];[_0x58656c(0x136)];[_0x58656c(0x12c)];[_0x58656c(0x133)];constructor(_0xfc5c2d,_0x196c51,_0xd419fb,_0x5b969d){const _0x1f610f=_0x58656c;this[_0x1f610f(0x14a)]=_0xfc5c2d,this[_0x1f610f(0x136)]=_0x196c51,this[_0x1f610f(0x12c)]=_0xd419fb,this[_0x1f610f(0x133)]=_0x5b969d;}[_0x58656c(0x132)](_0x3d77f2){const _0x2b9440=_0x58656c;if(!plain(_0x3d77f2[_0x2b9440(0x151)]))throw new Error(_0x2b9440(0x14b));const _0x4c2760=_0x3d77f2[_0x2b9440(0x151)][_0x2b9440(0x134)]===!![],_0x49e0fc=_0x3d77f2[_0x2b9440(0x151)][_0x2b9440(0x15d)]===!![],_0x599103=_0x3d77f2[_0x2b9440(0x151)][_0x2b9440(0x164)];let _0x2954f7;if(_0x599103!==undefined){if(!plain(_0x599103)||typeof _0x599103[_0x2b9440(0x12b)]!==_0x2b9440(0x163))throw new Error(_0x2b9440(0x14b));if(_0x599103[_0x2b9440(0x168)]!==undefined&&typeof _0x599103[_0x2b9440(0x168)]!==_0x2b9440(0x163)||_0x599103[_0x2b9440(0x150)]!==undefined&&(typeof _0x599103[_0x2b9440(0x150)]!==_0x2b9440(0x148)||!Number[_0x2b9440(0x138)](_0x599103[_0x2b9440(0x150)])||_0x599103[_0x2b9440(0x150)]<0x1f88+-0x67a+0xb*-0x247||_0x599103[_0x2b9440(0x150)]>0x22ec+-0x77e*-0x1+-0x29a2))throw new Error(_0x2b9440(0x14b));_0x2954f7={'path':normalizeViewPath(_0x599103[_0x2b9440(0x12b)]),...typeof _0x599103[_0x2b9440(0x168)]===_0x2b9440(0x163)?{'cursor':_0x599103[_0x2b9440(0x168)]}:{},...typeof _0x599103[_0x2b9440(0x150)]===_0x2b9440(0x148)?{'limit':_0x599103[_0x2b9440(0x150)]}:{}};}if(!_0x4c2760&&!_0x49e0fc&&_0x2954f7===undefined)throw new Error(_0x2b9440(0x14b));return{'sessions':_0x4c2760,'changes':_0x49e0fc,'files':_0x2954f7};}[_0x58656c(0x147)](_0x227df7){const _0x251f8e=_0x58656c;return this[_0x251f8e(0x135)](_0x227df7)+':'+this[_0x251f8e(0x169)](_0x227df7);}[_0x58656c(0x135)](_0x2f26c8){const _0x1b5b6c=_0x58656c;return typeof _0x2f26c8[_0x1b5b6c(0x166)]===_0x1b5b6c(0x163)?_0x2f26c8[_0x1b5b6c(0x166)]:_0x1b5b6c(0x129);}[_0x58656c(0x169)](_0x113d28){const _0x174b38=_0x58656c;if(typeof _0x113d28[_0x174b38(0x13a)]!==_0x174b38(0x163))throw new Error(_0x174b38(0x14b));return _0x113d28[_0x174b38(0x13a)];}[_0x58656c(0x153)](_0x3b3302,_0x38d001,_0x2cea82,_0xaae653,_0x40a9c6,_0x4834a8){const _0x3c795d=_0x58656c,_0x1405c1=_0x2cea82+':'+_0xaae653;for(const [_0x172299,_0x4a9e49]of this[_0x3c795d(0x14a)][_0x3c795d(0x146)])if(_0x4a9e49[_0x3c795d(0x160)](_0x1405c1))this[_0x3c795d(0x14f)](_0x172299,_0x1405c1);const _0x1a5f63={'workspaceId':_0x3b3302,'watchId':_0x38d001,'sessionHash':_0x2cea82,'workbenchConnectionId':_0xaae653,'nodeGeneration':_0x40a9c6,'expiresAt':Date[_0x3c795d(0x15e)]()+WATCH_TTL_MS,'topics':_0x4834a8,'timer':undefined};_0x1a5f63[_0x3c795d(0x15f)]=this[_0x3c795d(0x158)](_0x3b3302,_0x1405c1);const _0x19dfb0=this[_0x3c795d(0x14a)][_0x3c795d(0x146)][_0x3c795d(0x13d)](_0x3b3302)??new Map();_0x19dfb0[_0x3c795d(0x167)](_0x1405c1,_0x1a5f63),this[_0x3c795d(0x14a)][_0x3c795d(0x146)][_0x3c795d(0x167)](_0x3b3302,_0x19dfb0);if(_0x4834a8[_0x3c795d(0x134)])this[_0x3c795d(0x136)](_0x3b3302);return _0x1a5f63;}[_0x58656c(0x16a)](_0x323803,_0x182ec7,_0x10520f){const _0x1b3dac=_0x58656c,_0x40196d=this[_0x1b3dac(0x14a)][_0x1b3dac(0x146)][_0x1b3dac(0x13d)](_0x323803)?.[_0x1b3dac(0x13d)](_0x182ec7);if(_0x40196d===undefined||_0x40196d[_0x1b3dac(0x16d)]!==_0x10520f)return undefined;if(_0x40196d[_0x1b3dac(0x152)]<=Date[_0x1b3dac(0x15e)]())return this[_0x1b3dac(0x14f)](_0x323803,_0x182ec7),undefined;return clearTimeout(_0x40196d[_0x1b3dac(0x15f)]),_0x40196d[_0x1b3dac(0x152)]=Date[_0x1b3dac(0x15e)]()+WATCH_TTL_MS,_0x40196d[_0x1b3dac(0x15f)]=this[_0x1b3dac(0x158)](_0x323803,_0x182ec7),_0x40196d;}[_0x58656c(0x156)](_0x5c9757,_0x3b9215,_0x1f00c){const _0x4f666c=_0x58656c,_0x4a0b2d=this[_0x4f666c(0x14a)][_0x4f666c(0x146)][_0x4f666c(0x13d)](_0x5c9757)?.[_0x4f666c(0x13d)](_0x3b9215);return _0x4a0b2d!==undefined&&_0x4a0b2d[_0x4f666c(0x16d)]===_0x1f00c&&_0x4a0b2d[_0x4f666c(0x152)]>Date[_0x4f666c(0x15e)]();}[_0x58656c(0x131)](_0x10edc5,_0x941032){const _0x1cbf36=_0x58656c,_0x582d83=this[_0x1cbf36(0x14a)][_0x1cbf36(0x146)][_0x1cbf36(0x13d)](_0x10edc5)?.[_0x1cbf36(0x13d)](_0x941032);return _0x582d83!==undefined&&_0x582d83[_0x1cbf36(0x152)]>Date[_0x1cbf36(0x15e)]()?_0x582d83:undefined;}[_0x58656c(0x14f)](_0x25c373,_0x18b428){const _0x2dee69=_0x58656c,_0x3c4847=this[_0x2dee69(0x14a)][_0x2dee69(0x146)][_0x2dee69(0x13d)](_0x25c373),_0x55f993=_0x3c4847?.[_0x2dee69(0x13d)](_0x18b428);if(_0x55f993===undefined)return;clearTimeout(_0x55f993[_0x2dee69(0x15f)]),_0x3c4847?.[_0x2dee69(0x15a)](_0x18b428);_0x3c4847?.[_0x2dee69(0x155)]===-0x16a2*-0x1+-0x1789+0xe7&&(this[_0x2dee69(0x14a)][_0x2dee69(0x146)][_0x2dee69(0x15a)](_0x25c373),this[_0x2dee69(0x144)](_0x25c373),this[_0x2dee69(0x133)](_0x25c373));if(!this[_0x2dee69(0x139)](_0x25c373,_0x2dee69(0x134)))this[_0x2dee69(0x12c)](_0x25c373);}[_0x58656c(0x12e)](_0x1c88fb){const _0x22b454=_0x58656c,_0x41fa24=this[_0x22b454(0x14a)][_0x22b454(0x146)][_0x22b454(0x13d)](_0x1c88fb);if(_0x41fa24!==undefined){for(const _0x4b4c86 of _0x41fa24[_0x22b454(0x162)]())clearTimeout(_0x4b4c86[_0x22b454(0x15f)]);}this[_0x22b454(0x14a)][_0x22b454(0x146)][_0x22b454(0x15a)](_0x1c88fb),this[_0x22b454(0x144)](_0x1c88fb),this[_0x22b454(0x12c)](_0x1c88fb),this[_0x22b454(0x133)](_0x1c88fb);}[_0x58656c(0x12f)](){const _0x22df2f=_0x58656c,_0xfdacb0=[...this[_0x22df2f(0x14a)][_0x22df2f(0x146)][_0x22df2f(0x12a)]()];for(const _0x243b4b of this[_0x22df2f(0x14a)][_0x22df2f(0x146)][_0x22df2f(0x162)]())for(const _0x14089a of _0x243b4b[_0x22df2f(0x162)]())clearTimeout(_0x14089a[_0x22df2f(0x15f)]);this[_0x22df2f(0x14a)][_0x22df2f(0x146)][_0x22df2f(0x12e)](),this[_0x22df2f(0x14a)][_0x22df2f(0x15c)][_0x22df2f(0x12e)]();for(const _0x2f7047 of _0xfdacb0){this[_0x22df2f(0x12c)](_0x2f7047),this[_0x22df2f(0x133)](_0x2f7047);}}[_0x58656c(0x140)](_0x2b6083){const _0x300496=_0x58656c,_0x2cd252=(this[_0x300496(0x14a)][_0x300496(0x15c)][_0x300496(0x13d)](_0x2b6083)??0x218b+0x3e6+-0x2d*0xd5)+(0x2*0x645+0x171f+-0x23a8);return this[_0x300496(0x14a)][_0x300496(0x15c)][_0x300496(0x167)](_0x2b6083,_0x2cd252),_0x2cd252;}[_0x58656c(0x12d)](){const _0x4077b1=_0x58656c;return this[_0x4077b1(0x14a)][_0x4077b1(0x13b)]+=-0x175b+0x7*0x328+0x3*0x6c,this[_0x4077b1(0x14a)][_0x4077b1(0x13b)];}[_0x58656c(0x139)](_0x50f8c8,_0x366e3b){const _0x36bdbb=_0x58656c;return[...this[_0x36bdbb(0x14a)][_0x36bdbb(0x146)][_0x36bdbb(0x13d)](_0x50f8c8)?.[_0x36bdbb(0x162)]()??[]][_0x36bdbb(0x14c)](_0x55a076=>_0x366e3b===_0x36bdbb(0x164)?_0x55a076[_0x36bdbb(0x151)][_0x36bdbb(0x164)]!==undefined:_0x55a076[_0x36bdbb(0x151)][_0x366e3b]);}[_0x58656c(0x15b)](_0x36edcf){const _0x412623=_0x58656c;return[...this[_0x412623(0x14a)][_0x412623(0x146)][_0x412623(0x13d)](_0x36edcf)?.[_0x412623(0x162)]()??[]][_0x412623(0x13f)](_0x137f91=>_0x137f91[_0x412623(0x152)]>Date[_0x412623(0x15e)]());}[_0x58656c(0x16b)](_0x1c7835){const _0x42e841=_0x58656c;return[...this[_0x42e841(0x14a)][_0x42e841(0x146)][_0x42e841(0x12a)]()][_0x42e841(0x13f)](_0x46dff0=>this[_0x42e841(0x139)](_0x46dff0,_0x1c7835));}[_0x58656c(0x158)](_0x388eeb,_0xf825cb){const _0x349956=_0x58656c,_0x1d808b=setTimeout(()=>this[_0x349956(0x14f)](_0x388eeb,_0xf825cb),WATCH_TTL_MS);return _0x1d808b[_0x349956(0x143)](),_0x1d808b;}[_0x58656c(0x144)](_0x765dee){const _0x1419cf=_0x58656c;for(const _0x5a7749 of[...this[_0x1419cf(0x14a)][_0x1419cf(0x15c)][_0x1419cf(0x12a)]()])if(_0x5a7749[_0x1419cf(0x149)](_0x765dee+':'))this[_0x1419cf(0x14a)][_0x1419cf(0x15c)][_0x1419cf(0x15a)](_0x5a7749);}}function _0x40d8(){const _0x3c6268=['zxHWAxj5vgLTzxi','CMvWBgfJzufSBa','zgvSzxrL','ywn0AxzLv2f0y2HLCW','D2f0y2HszxzPC2LVBNm','y2HHBMDLCW','BM93','DgLTzxi','AgfZ','BgvUz3rO','DMfSDwvZ','C3rYAw5N','zMLSzxm','nerrwvPrDG','x193B3jRC3bHy2vxyxrJAfnLC3nPB25iyxnO','C2v0','y3vYC29Y','y29UBMvJDgLVBKLK','CMvUzxC','ywn0AxzLv29YA3nWywnLswrZ','mti2wgnLwgHS','D2f0y2Hjza','Bg9JywWTDgvZDa','A2v5CW','Cgf0Aa','B25tzxnZAw9Uv2f0y2HvBNvZzwq','BMv4DfnUyxbZAg90u2vXDwvUy2u','y2XLyxi','y2XLyxjbBgW','mta5ndi5oe1frwzNBW','zxHPC3rPBMC','CgfYC2vuB3bPy3m','B25xB3jRC3bHy2vxyxrJAfvUDxnLza','C2vZC2LVBNm','C2vZC2LVBKHHC2G','B25tzxnZAw9Uv2f0y2Hszxf1AxjLza','BM9YBwfSAxPL','AxnjBNrLz2vY','Dg9WAwnby3rPDMu','D29YA2jLBMnOq29UBMvJDgLVBKLK','D2f0y2HtBMfWC2HVDfnLCxvLBMnL','ndy0nte2mwziCNrkrW','z2v0','mNDpAM12qW','zMLSDgvY','BMv4DfjLDMLZAw9U','AxnbCNjHEq','B2jQzwn0','Dw5Yzwy','y2XLyxjszxzPC2LVBNm','mZK5nJq0oe5Zt0LIyq','D2f0y2HLCW','A2v5','BNvTyMvY','C3rHCNrZv2L0Aa','C3rHDgu','v09ss1nqqunfx1Dbvenix0LovKfmsuq','C29Tzq','ndi0ntvmvgX1Cvq','mJy4mZu4nxP0wuvTyW','CMvTB3zL','BgLTAxq','Dg9WAwnZ','zxHWAxjLC0f0','y3jLyxrL','ndi4mdeZmevwD0DpEG','C2L6zq','Bwf0y2HLCW','mti1mdq1B3Lyr0LU'];_0x40d8=function(){return _0x3c6268;};return _0x40d8();}function normalizeViewPath(_0x354168){const _0x1f32b1=_0x58656c,_0x8c1e16=posix[_0x1f32b1(0x137)](_0x354168[_0x1f32b1(0x159)]('\x5c','/'));return _0x8c1e16[_0x1f32b1(0x161)]===-0x1*0x1439+-0x1674+0x1b5*0x19?'.':_0x8c1e16;}function plain(_0x5ef646){const _0xd1b1fd=_0x58656c;return typeof _0x5ef646===_0xd1b1fd(0x142)&&_0x5ef646!==null&&!Array[_0xd1b1fd(0x141)](_0x5ef646);}
1
+ import { posix } from 'node:path';
2
+ const WATCH_TTL_MS = 45_000;
3
+ export class WorkspaceWatchService {
4
+ state;
5
+ onSessionWatchRequired;
6
+ onSessionWatchUnused;
7
+ onWorkspaceWatchUnused;
8
+ constructor(state, onSessionWatchRequired, onSessionWatchUnused, onWorkspaceWatchUnused) {
9
+ this.state = state;
10
+ this.onSessionWatchRequired = onSessionWatchRequired;
11
+ this.onSessionWatchUnused = onSessionWatchUnused;
12
+ this.onWorkspaceWatchUnused = onWorkspaceWatchUnused;
13
+ }
14
+ parseTopics(input) {
15
+ if (!plain(input.topics))
16
+ throw new Error('WORKSPACE_WATCH_INVALID');
17
+ const sessions = input.topics.sessions === true;
18
+ const changes = input.topics.changes === true;
19
+ const rawFiles = input.topics.files;
20
+ let files;
21
+ if (rawFiles !== undefined) {
22
+ if (!plain(rawFiles) || typeof rawFiles.path !== 'string')
23
+ throw new Error('WORKSPACE_WATCH_INVALID');
24
+ if ((rawFiles.cursor !== undefined && typeof rawFiles.cursor !== 'string') ||
25
+ (rawFiles.limit !== undefined &&
26
+ (typeof rawFiles.limit !== 'number' ||
27
+ !Number.isInteger(rawFiles.limit) ||
28
+ rawFiles.limit < 1 ||
29
+ rawFiles.limit > 200)))
30
+ throw new Error('WORKSPACE_WATCH_INVALID');
31
+ files = {
32
+ path: normalizeViewPath(rawFiles.path),
33
+ ...(typeof rawFiles.cursor === 'string' ? { cursor: rawFiles.cursor } : {}),
34
+ ...(typeof rawFiles.limit === 'number' ? { limit: rawFiles.limit } : {})
35
+ };
36
+ }
37
+ if (!sessions && !changes && files === undefined)
38
+ throw new Error('WORKSPACE_WATCH_INVALID');
39
+ return { sessions, changes, files };
40
+ }
41
+ key(input) {
42
+ return `${this.sessionHash(input)}:${this.connectionId(input)}`;
43
+ }
44
+ sessionHash(input) {
45
+ return typeof input.__workspaceWatchSessionHash === 'string'
46
+ ? input.__workspaceWatchSessionHash
47
+ : 'local-test';
48
+ }
49
+ connectionId(input) {
50
+ if (typeof input.workbenchConnectionId !== 'string')
51
+ throw new Error('WORKSPACE_WATCH_INVALID');
52
+ return input.workbenchConnectionId;
53
+ }
54
+ create(workspaceId, watchId, sessionHash, workbenchConnectionId, nodeGeneration, topics) {
55
+ const key = `${sessionHash}:${workbenchConnectionId}`;
56
+ for (const [activeWorkspaceId, watches] of this.state.watches)
57
+ if (watches.has(key))
58
+ this.remove(activeWorkspaceId, key);
59
+ const watch = {
60
+ workspaceId,
61
+ watchId,
62
+ sessionHash,
63
+ workbenchConnectionId,
64
+ nodeGeneration,
65
+ expiresAt: Date.now() + WATCH_TTL_MS,
66
+ topics,
67
+ timer: undefined
68
+ };
69
+ watch.timer = this.expiryTimer(workspaceId, key);
70
+ const watches = this.state.watches.get(workspaceId) ?? new Map();
71
+ watches.set(key, watch);
72
+ this.state.watches.set(workspaceId, watches);
73
+ if (topics.sessions)
74
+ this.onSessionWatchRequired(workspaceId);
75
+ return watch;
76
+ }
77
+ renew(workspaceId, key, watchId) {
78
+ const watch = this.state.watches.get(workspaceId)?.get(key);
79
+ if (watch === undefined || watch.watchId !== watchId)
80
+ return undefined;
81
+ if (watch.expiresAt <= Date.now()) {
82
+ this.remove(workspaceId, key);
83
+ return undefined;
84
+ }
85
+ clearTimeout(watch.timer);
86
+ watch.expiresAt = Date.now() + WATCH_TTL_MS;
87
+ watch.timer = this.expiryTimer(workspaceId, key);
88
+ return watch;
89
+ }
90
+ matches(workspaceId, key, watchId) {
91
+ const watch = this.state.watches.get(workspaceId)?.get(key);
92
+ return watch !== undefined && watch.watchId === watchId && watch.expiresAt > Date.now();
93
+ }
94
+ existing(workspaceId, key) {
95
+ const watch = this.state.watches.get(workspaceId)?.get(key);
96
+ return watch !== undefined && watch.expiresAt > Date.now() ? watch : undefined;
97
+ }
98
+ remove(workspaceId, key) {
99
+ const watches = this.state.watches.get(workspaceId);
100
+ const watch = watches?.get(key);
101
+ if (watch === undefined)
102
+ return;
103
+ clearTimeout(watch.timer);
104
+ watches?.delete(key);
105
+ if (watches?.size === 0) {
106
+ this.state.watches.delete(workspaceId);
107
+ this.clearRevisions(workspaceId);
108
+ this.onWorkspaceWatchUnused(workspaceId);
109
+ }
110
+ if (!this.topicActive(workspaceId, 'sessions'))
111
+ this.onSessionWatchUnused(workspaceId);
112
+ }
113
+ clear(workspaceId) {
114
+ const watches = this.state.watches.get(workspaceId);
115
+ if (watches !== undefined)
116
+ for (const watch of watches.values())
117
+ clearTimeout(watch.timer);
118
+ this.state.watches.delete(workspaceId);
119
+ this.clearRevisions(workspaceId);
120
+ this.onSessionWatchUnused(workspaceId);
121
+ this.onWorkspaceWatchUnused(workspaceId);
122
+ }
123
+ clearAll() {
124
+ const workspaceIds = [...this.state.watches.keys()];
125
+ for (const watches of this.state.watches.values())
126
+ for (const watch of watches.values())
127
+ clearTimeout(watch.timer);
128
+ this.state.watches.clear();
129
+ this.state.watchRevisions.clear();
130
+ for (const workspaceId of workspaceIds) {
131
+ this.onSessionWatchUnused(workspaceId);
132
+ this.onWorkspaceWatchUnused(workspaceId);
133
+ }
134
+ }
135
+ nextRevision(viewKey) {
136
+ const revision = (this.state.watchRevisions.get(viewKey) ?? 0) + 1;
137
+ this.state.watchRevisions.set(viewKey, revision);
138
+ return revision;
139
+ }
140
+ nextSnapshotSequence() {
141
+ this.state.watchSnapshotSequence += 1;
142
+ return this.state.watchSnapshotSequence;
143
+ }
144
+ topicActive(workspaceId, topic) {
145
+ return [...(this.state.watches.get(workspaceId)?.values() ?? [])].some((watch) => topic === 'files' ? watch.topics.files !== undefined : watch.topics[topic]);
146
+ }
147
+ activeWatches(workspaceId) {
148
+ return [...(this.state.watches.get(workspaceId)?.values() ?? [])].filter((watch) => watch.expiresAt > Date.now());
149
+ }
150
+ activeWorkspaceIds(topic) {
151
+ return [...this.state.watches.keys()].filter((workspaceId) => this.topicActive(workspaceId, topic));
152
+ }
153
+ expiryTimer(workspaceId, key) {
154
+ const timer = setTimeout(() => this.remove(workspaceId, key), WATCH_TTL_MS);
155
+ timer.unref();
156
+ return timer;
157
+ }
158
+ clearRevisions(workspaceId) {
159
+ for (const key of [...this.state.watchRevisions.keys()])
160
+ if (key.startsWith(`${workspaceId}:`))
161
+ this.state.watchRevisions.delete(key);
162
+ }
163
+ }
164
+ function normalizeViewPath(value) {
165
+ const normalized = posix.normalize(value.replaceAll('\\', '/'));
166
+ return normalized.length === 0 ? '.' : normalized;
167
+ }
168
+ function plain(value) {
169
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
170
+ }
@@ -1,2 +1,218 @@
1
- /* mar-release-protected */
2
- const _0x10d2c6=_0x43f4;(function(_0x4e6e07,_0xcd4815){const _0x1c786c=_0x43f4,_0x5e8b76=_0x4e6e07();while(!![]){try{const _0x5da4a4=-parseInt(_0x1c786c(0x1a4))/(-0x17ac+0x2*-0xdc+-0x21*-0xc5)*(-parseInt(_0x1c786c(0x1a7))/(0x1e0b+0x5ec*0x4+0x1*-0x35b9))+-parseInt(_0x1c786c(0x1b4))/(0x168b+0x43f+-0x1ac7)+-parseInt(_0x1c786c(0x19e))/(-0x4d*-0x47+-0x18d5+-0x95*-0x6)+parseInt(_0x1c786c(0x1d7))/(-0x628*0x4+0x1*-0x1305+0x2baa)+-parseInt(_0x1c786c(0x1ae))/(0xae+-0x94f+0x1bb*0x5)+-parseInt(_0x1c786c(0x199))/(0xf4d*0x2+0x1*-0x17a7+-0x6ec)+parseInt(_0x1c786c(0x1a9))/(-0x1190+-0x1064+0xa*0x366);if(_0x5da4a4===_0xcd4815)break;else _0x5e8b76['push'](_0x5e8b76['shift']());}catch(_0x4912aa){_0x5e8b76['push'](_0x5e8b76['shift']());}}}(_0xbc37,0x27160+-0x1*0x5bf58+0x6553c));const FILES_REFRESH_INTERVAL_MS=0x326*-0x8+0xaada+-0x1*0x1c7a;export class WorkspaceWatchSnapshotService{[_0x10d2c6(0x196)];[_0x10d2c6(0x1c4)]=new Map();[_0x10d2c6(0x1c9)]=new Set();[_0x10d2c6(0x1b6)]=new Map();[_0x10d2c6(0x18e)]=new Map();[_0x10d2c6(0x1d8)];constructor(_0x487e28){const _0x54b47d=_0x10d2c6;this[_0x54b47d(0x196)]=_0x487e28;}async[_0x10d2c6(0x1b9)](_0x53aeaf,_0x574efd){const _0x28caad=_0x10d2c6;if(_0x574efd[_0x28caad(0x1b1)][_0x28caad(0x193)]!==undefined)this[_0x28caad(0x194)]();await Promise[_0x28caad(0x1d2)](this[_0x28caad(0x1be)](_0x574efd)[_0x28caad(0x1da)](async _0x3571ef=>{const _0x2df214=_0x28caad;try{const _0x35eea3=await this[_0x2df214(0x19b)](_0x53aeaf,_0x3571ef,_0x574efd);if(!this[_0x2df214(0x19f)](_0x53aeaf['id'],_0x574efd))return;this[_0x2df214(0x18e)][_0x2df214(0x1aa)](this[_0x2df214(0x1a2)](_0x53aeaf['id'],_0x3571ef,_0x574efd),signature(_0x35eea3)),this[_0x2df214(0x1ab)](_0x53aeaf,_0x574efd,_0x3571ef,_0x35eea3);}catch{this[_0x2df214(0x1a8)](_0x53aeaf['id'],_0x574efd,_0x3571ef);}}));}async[_0x10d2c6(0x195)](_0x4efa03,_0x744193){const _0xd5ba56=_0x10d2c6,_0x180098=_0x4efa03+':'+_0x744193,_0x5094f7=this[_0xd5ba56(0x1c4)][_0xd5ba56(0x1ca)](_0x180098);if(_0x5094f7!==undefined)return this[_0xd5ba56(0x1c9)][_0xd5ba56(0x1ce)](_0x180098),_0x5094f7;if(this[_0xd5ba56(0x1c6)](_0x4efa03,_0x744193))this[_0xd5ba56(0x1c9)][_0xd5ba56(0x1ce)](_0x180098);const _0x142e61=this[_0xd5ba56(0x197)](_0x4efa03,_0x744193)[_0xd5ba56(0x1a3)](()=>{const _0x12809a=_0xd5ba56;for(const _0x3db51a of this[_0x12809a(0x1d3)](_0x4efa03,_0x744193))this[_0x12809a(0x1a8)](_0x4efa03,_0x3db51a,_0x744193);});this[_0xd5ba56(0x1c4)][_0xd5ba56(0x1aa)](_0x180098,_0x142e61);try{await _0x142e61;}finally{if(this[_0xd5ba56(0x1c4)][_0xd5ba56(0x1ca)](_0x180098)===_0x142e61)this[_0xd5ba56(0x1c4)][_0xd5ba56(0x1a5)](_0x180098);if(this[_0xd5ba56(0x1c9)][_0xd5ba56(0x1a5)](_0x180098))void this[_0xd5ba56(0x195)](_0x4efa03,_0x744193);}}[_0x10d2c6(0x1c2)](_0x44952b,_0x5f423b){const _0x5530f3=_0x10d2c6;return this[_0x5530f3(0x1c4)][_0x5530f3(0x1ca)](_0x44952b+':'+_0x5f423b)??this[_0x5530f3(0x195)](_0x44952b,_0x5f423b);}[_0x10d2c6(0x1b0)](_0x316c77){const _0x51d4fc=_0x10d2c6;for(const _0x581c39 of[...this[_0x51d4fc(0x1c9)]])if(_0x581c39[_0x51d4fc(0x1cb)](_0x316c77+':'))this[_0x51d4fc(0x1c9)][_0x51d4fc(0x1a5)](_0x581c39);for(const _0x4ecb72 of[...this[_0x51d4fc(0x18e)][_0x51d4fc(0x1c0)]()])if(_0x4ecb72[_0x51d4fc(0x1cb)](_0x316c77+':'))this[_0x51d4fc(0x18e)][_0x51d4fc(0x1a5)](_0x4ecb72);}[_0x10d2c6(0x1c8)](){const _0x7f039b=_0x10d2c6;if(this[_0x7f039b(0x1d8)]!==undefined)clearInterval(this[_0x7f039b(0x1d8)]);this[_0x7f039b(0x1d8)]=undefined,this[_0x7f039b(0x1c9)][_0x7f039b(0x1b0)](),this[_0x7f039b(0x18e)][_0x7f039b(0x1b0)]();}[_0x10d2c6(0x194)](){const _0x217e2b=_0x10d2c6;if(this[_0x217e2b(0x1d8)]!==undefined)return;this[_0x217e2b(0x1d8)]=setInterval(()=>{const _0x19284d=_0x217e2b,_0x4d99a1=this[_0x19284d(0x196)][_0x19284d(0x1b8)][_0x19284d(0x1d4)](_0x19284d(0x193));if(_0x4d99a1[_0x19284d(0x1cf)]===0x2129*-0x1+0x385*-0xb+0x47e0){if(this[_0x19284d(0x1d8)]!==undefined)clearInterval(this[_0x19284d(0x1d8)]);this[_0x19284d(0x1d8)]=undefined;return;}for(const _0x41ffb9 of _0x4d99a1)void this[_0x19284d(0x195)](_0x41ffb9,_0x19284d(0x193));},this[_0x217e2b(0x196)][_0x217e2b(0x1c1)]??FILES_REFRESH_INTERVAL_MS),this[_0x217e2b(0x1d8)][_0x217e2b(0x1b2)]();}async[_0x10d2c6(0x197)](_0x4ad75a,_0x2a5509){const _0x10d75d=_0x10d2c6,_0x53f73f=this[_0x10d75d(0x196)][_0x10d75d(0x1d6)](_0x4ad75a),_0x2098e7=this[_0x10d75d(0x1d3)](_0x4ad75a,_0x2a5509);if(_0x2098e7[_0x10d75d(0x1cf)]===-0xc57*0x3+-0x6d*0x19+0x1*0x2faa)return;if(_0x2a5509!==_0x10d75d(0x193)){const _0x4b258f=_0x2098e7[0xe*-0x42+-0xe*0x3b+0x6d6];if(_0x4b258f===undefined)return;const _0x4b536a=await this[_0x10d75d(0x19b)](_0x53f73f,_0x2a5509,_0x4b258f),_0x167635=_0x2098e7[_0x10d75d(0x1bc)](_0x52b890=>this[_0x10d75d(0x19f)](_0x4ad75a,_0x52b890));if(_0x167635[_0x10d75d(0x1cf)]===0x2e3*-0x8+-0x1d88+0x34a0)return;if(!this[_0x10d75d(0x1cd)](this[_0x10d75d(0x1a2)](_0x4ad75a,_0x2a5509,_0x4b258f),_0x4b536a))return;for(const _0x25ddf1 of _0x167635)this[_0x10d75d(0x1ab)](_0x53f73f,_0x25ddf1,_0x2a5509,_0x4b536a);return;}const _0x4bb1f2=new Map();for(const _0x576d4e of _0x2098e7){const _0x361220=JSON[_0x10d75d(0x1ad)](_0x576d4e[_0x10d75d(0x1b1)][_0x10d75d(0x193)]);_0x4bb1f2[_0x10d75d(0x1aa)](_0x361220,[..._0x4bb1f2[_0x10d75d(0x1ca)](_0x361220)??[],_0x576d4e]);}await Promise[_0x10d75d(0x1d2)]([..._0x4bb1f2[_0x10d75d(0x1a0)]()][_0x10d75d(0x1da)](async _0x31a219=>{const _0x3fd376=_0x10d75d,_0x4f0c41=_0x31a219[-0xe11+-0xf47+-0x4*-0x756];if(_0x4f0c41===undefined)return;try{const _0xeda42e=await this[_0x3fd376(0x19b)](_0x53f73f,_0x2a5509,_0x4f0c41),_0x1e73f0=_0x31a219[_0x3fd376(0x1bc)](_0x3af728=>this[_0x3fd376(0x19f)](_0x4ad75a,_0x3af728));if(_0x1e73f0[_0x3fd376(0x1cf)]===0x347+0x229+-0x570)return;if(!this[_0x3fd376(0x1cd)](this[_0x3fd376(0x1a2)](_0x4ad75a,_0x2a5509,_0x4f0c41),_0xeda42e))return;for(const _0xb52a68 of _0x1e73f0)this[_0x3fd376(0x1ab)](_0x53f73f,_0xb52a68,_0x2a5509,_0xeda42e);}catch{for(const _0x2107da of _0x31a219)this[_0x3fd376(0x1a8)](_0x4ad75a,_0x2107da,_0x2a5509);}}));}[_0x10d2c6(0x19b)](_0x5ee3cd,_0x55a8b4,_0x2131d2){const _0x220f20=_0x10d2c6,_0xc84eb9=_0x55a8b4===_0x220f20(0x193)?_0x5ee3cd['id']+_0x220f20(0x1b7)+JSON[_0x220f20(0x1ad)](_0x2131d2[_0x220f20(0x1b1)][_0x220f20(0x193)]):_0x5ee3cd['id']+':'+_0x55a8b4,_0x8f9545=this[_0x220f20(0x1b6)][_0x220f20(0x1ca)](_0xc84eb9);if(_0x8f9545!==undefined)return _0x8f9545;const _0x583896=(_0x55a8b4===_0x220f20(0x1bb)?this[_0x220f20(0x196)][_0x220f20(0x19d)](_0x5ee3cd['id']):_0x55a8b4===_0x220f20(0x190)?_0x5ee3cd[_0x220f20(0x1c3)]===_0x220f20(0x1d1)?this[_0x220f20(0x196)][_0x220f20(0x190)][_0x220f20(0x1ac)](_0x5ee3cd):Promise[_0x220f20(0x191)](null):this[_0x220f20(0x196)][_0x220f20(0x193)][_0x220f20(0x1bf)](_0x5ee3cd,_0x2131d2[_0x220f20(0x1b1)][_0x220f20(0x193)])[_0x220f20(0x192)](_0x3c89cf=>({'files':_0x3c89cf})))[_0x220f20(0x1b5)](()=>{const _0x9d6c6=_0x220f20;if(this[_0x9d6c6(0x1b6)][_0x9d6c6(0x1ca)](_0xc84eb9)===_0x583896)this[_0x9d6c6(0x1b6)][_0x9d6c6(0x1a5)](_0xc84eb9);});return this[_0x220f20(0x1b6)][_0x220f20(0x1aa)](_0xc84eb9,_0x583896),_0x583896;}[_0x10d2c6(0x1cd)](_0x2255fc,_0x48294f){const _0x428c51=_0x10d2c6,_0x20d9ad=signature(_0x48294f);if(this[_0x428c51(0x18e)][_0x428c51(0x1ca)](_0x2255fc)===_0x20d9ad)return![];return this[_0x428c51(0x18e)][_0x428c51(0x1aa)](_0x2255fc,_0x20d9ad),!![];}[_0x10d2c6(0x1a2)](_0x28d63d,_0x5bbe8,_0x45f1ba){const _0x383c40=_0x10d2c6;return _0x5bbe8===_0x383c40(0x193)?_0x28d63d+_0x383c40(0x1b7)+JSON[_0x383c40(0x1ad)](_0x45f1ba[_0x383c40(0x1b1)][_0x383c40(0x193)]):_0x28d63d+':'+_0x5bbe8;}[_0x10d2c6(0x1c6)](_0x443b09,_0x4dfa8c){const _0x546fb0=_0x10d2c6,_0x3bc085=_0x443b09+':'+_0x4dfa8c;return[...this[_0x546fb0(0x1b6)][_0x546fb0(0x1c0)]()][_0x546fb0(0x1b3)](_0x56f094=>_0x56f094===_0x3bc085||_0x56f094[_0x546fb0(0x1cb)](_0x3bc085+':'));}[_0x10d2c6(0x1d3)](_0x5bfc53,_0xe222d8){const _0x4229b2=_0x10d2c6;return this[_0x4229b2(0x196)][_0x4229b2(0x1b8)][_0x4229b2(0x1d0)](_0x5bfc53)[_0x4229b2(0x1bc)](_0x3bbe18=>_0xe222d8===_0x4229b2(0x193)?_0x3bbe18[_0x4229b2(0x1b1)][_0x4229b2(0x193)]!==undefined:_0x3bbe18[_0x4229b2(0x1b1)][_0xe222d8]);}[_0x10d2c6(0x1be)](_0x131cc6){const _0x5d0638=_0x10d2c6;return[..._0x131cc6[_0x5d0638(0x1b1)][_0x5d0638(0x1bb)]?[_0x5d0638(0x1bb)]:[],..._0x131cc6[_0x5d0638(0x1b1)][_0x5d0638(0x193)]===undefined?[]:[_0x5d0638(0x193)],..._0x131cc6[_0x5d0638(0x1b1)][_0x5d0638(0x190)]?[_0x5d0638(0x190)]:[]];}[_0x10d2c6(0x1ab)](_0xb1879a,_0x477c3a,_0x27ec2e,_0x5b3099){const _0x621348=_0x10d2c6;if(!this[_0x621348(0x19f)](_0xb1879a['id'],_0x477c3a))return;this[_0x621348(0x196)][_0x621348(0x1cc)]({'type':_0x621348(0x19c),'workbenchConnectionId':_0x477c3a[_0x621348(0x1af)],'watchId':_0x477c3a[_0x621348(0x1a1)],'nodeGeneration':_0x477c3a[_0x621348(0x1d5)],'nodeId':this[_0x621348(0x196)][_0x621348(0x1a6)](),'workspaceId':_0xb1879a['id'],'topic':_0x27ec2e,'revision':this[_0x621348(0x196)][_0x621348(0x1b8)][_0x621348(0x18f)](this[_0x621348(0x1a2)](_0xb1879a['id'],_0x27ec2e,_0x477c3a)),'snapshotSequence':this[_0x621348(0x196)][_0x621348(0x1b8)][_0x621348(0x1c7)](),'expiresAt':_0x477c3a[_0x621348(0x1d9)],'payload':_0x5b3099});}[_0x10d2c6(0x1a8)](_0x287e56,_0x4a5a0a,_0x9d4a4){const _0xa4aa7a=_0x10d2c6;if(!this[_0xa4aa7a(0x19f)](_0x287e56,_0x4a5a0a))return;this[_0xa4aa7a(0x196)][_0xa4aa7a(0x1cc)]({'type':_0xa4aa7a(0x1ba),'workbenchConnectionId':_0x4a5a0a[_0xa4aa7a(0x1af)],'watchType':_0xa4aa7a(0x1c5),'watchId':_0x4a5a0a[_0xa4aa7a(0x1a1)],'nodeGeneration':_0x4a5a0a[_0xa4aa7a(0x1d5)],'nodeId':this[_0xa4aa7a(0x196)][_0xa4aa7a(0x1a6)](),'workspaceId':_0x287e56,'topic':_0x9d4a4,'code':_0xa4aa7a(0x198),'message':_0xa4aa7a(0x1bd)});}[_0x10d2c6(0x19f)](_0x36978d,_0x20f338){const _0x103b05=_0x10d2c6;return this[_0x103b05(0x196)][_0x103b05(0x1b8)][_0x103b05(0x19f)](_0x36978d,_0x20f338[_0x103b05(0x19a)]+':'+_0x20f338[_0x103b05(0x1af)],_0x20f338[_0x103b05(0x1a1)]);}}function _0x43f4(_0x2107da,_0x5ee3cd){_0x2107da=_0x2107da-(0x2bc+-0x1a*0x88+-0xb*-0x126);const _0x55a8b4=_0xbc37();let _0x2131d2=_0x55a8b4[_0x2107da];if(_0x43f4['gXVEHI']===undefined){var _0xc84eb9=function(_0x3c89cf){const _0x2255fc='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x48294f='',_0x20d9ad='';for(let _0x28d63d=0x1b64+0x1335+0x1*-0x2e99,_0x5bbe8,_0x45f1ba,_0x443b09=-0x1*-0x2082+-0x736+-0x194c;_0x45f1ba=_0x3c89cf['charAt'](_0x443b09++);~_0x45f1ba&&(_0x5bbe8=_0x28d63d%(0x2413*0x1+0x1f01+-0x4310)?_0x5bbe8*(-0xaa5+-0x257*-0x1+0x2*0x447)+_0x45f1ba:_0x45f1ba,_0x28d63d++%(0xe*-0x42+-0xe*0x3b+0x6da))?_0x48294f+=String['fromCharCode'](0x2e3*-0x8+-0x1d88+0x359f&_0x5bbe8>>(-(-0xe11+-0xf47+-0xd*-0x242)*_0x28d63d&0x347+0x229+-0x56a)):0x1*0x1453+0x12e*0x19+-0x31d1){_0x45f1ba=_0x2255fc['indexOf'](_0x45f1ba);}for(let _0x4dfa8c=-0x1368+0x3f*-0x8e+0x1*0x365a,_0x3bc085=_0x48294f['length'];_0x4dfa8c<_0x3bc085;_0x4dfa8c++){_0x20d9ad+='%'+('00'+_0x48294f['charCodeAt'](_0x4dfa8c)['toString'](0x1b*0x13a+-0x2*-0xcbe+-0x3b*0xfe))['slice'](-(-0x59*-0x42+-0x1*-0x167f+0x1*-0x2d6f));}return decodeURIComponent(_0x20d9ad);};_0x43f4['PwKytv']=_0xc84eb9,_0x43f4['psbSPD']={},_0x43f4['gXVEHI']=!![];}const _0x8f9545=_0x55a8b4[0x198+0x19b2+-0xda5*0x2];_0x43f4['csnVNc']!==_0x8f9545&&(_0x43f4['psbSPD']={},_0x43f4['csnVNc']=_0x8f9545);const _0x583896=_0x43f4['psbSPD'][_0x2107da];return _0x583896===undefined?(_0x2131d2=_0x43f4['PwKytv'](_0x2131d2),_0x43f4['psbSPD'][_0x2107da]=_0x2131d2):_0x2131d2=_0x583896,_0x2131d2;}function _0xbc37(){const _0x3d4d75=['y2HHBMDLza','ywrK','BgvUz3rO','ywn0AxzLv2f0y2HLCW','r0Lux1DpuKTtuefdrq','ywXS','C3vIC2nYAwjLCNm','ywn0AxzLv29YA3nWywnLswrZ','BM9KzuDLBMvYyxrPB24','CMvXDwLYzvDVCMTZCgfJzq','mtG3ndu1nuL5vefJva','zMLSzxnszwzYzxnOvgLTzxi','zxHWAxjLC0f0','BwfW','C2LNBMf0DxjLCW','BMv4DfjLDMLZAw9U','y2HHBMDLCW','CMvZB2X2zq','DgHLBG','zMLSzxm','zw5ZDxjLrMLSzxnszwzYzxnOvgLTzxi','Aw52ywXPzgf0zq','B3b0Aw9UCW','CMvMCMvZAa','v09ss1nqqunfx1Dbvenix1noqvbtse9ux0zbsuXfra','mte0otm1mvnpr0vgtq','C2vZC2LVBKHHC2G','CMvHza','D2f0y2GUD29YA3nWywnLlNnUyxbZAg90','BgLZDfnLC3nPB25Z','mtmWmtCXmMLoA295uG','Bwf0y2HLCW','DMfSDwvZ','D2f0y2Hjza','DMLLD0TLEq','y2f0y2G','odLfC2rhzuG','zgvSzxrL','BM9KzuLK','mtqXngz1r010va','zMfPBa','ndu4mZG1nMXcAujyrW','C2v0','zgvSAxzLCG','y3vYCMvUDa','C3rYAw5NAwz5','ndeWmdG4zMfHChLl','D29YA2jLBMnOq29UBMvJDgLVBKLK','y2XLyxi','Dg9WAwnZ','Dw5Yzwy','C29Tzq','nZyZmtm3vLPgBxze','zMLUywXSEq','CMvHzhm','oMzPBgvZoG','D2f0y2G','Aw5PDgLHBa','D2f0y2GUzMfPBgvK','C2vZC2LVBNm','zMLSDgvY','v29YA3nWywnLihDHDgnOihnUyxbZAg90igzHAwXLzc4','C3vIC2nYAwjLzfrVCgLJCW','BgLZDa','A2v5CW','zMLSzxnszwzYzxnOsw50zxj2ywXnCW','zw5ZDxjLu25HChnOB3q','A2LUza','CMvMCMvZAgvZ','D29YA3nWywnL','CMvHzefJDgL2zq','BMv4DfnUyxbZAg90u2vXDwvUy2u','y2XLyxjbBgW','zgLYDhK','z2v0','C3rHCNrZv2L0Aa','zw1PDfDHDgnOrxzLBNq'];_0xbc37=function(){return _0x3d4d75;};return _0xbc37();}function signature(_0xc6d820){const _0x41b8af=_0x10d2c6;return JSON[_0x41b8af(0x1ad)](_0xc6d820)??String(_0xc6d820);}
1
+ const FILES_REFRESH_INTERVAL_MS = 30_000;
2
+ /** Owns Workspace topic reads, single-flight invalidation and directed snapshot delivery. */
3
+ export class WorkspaceWatchSnapshotService {
4
+ options;
5
+ refreshes = new Map();
6
+ dirty = new Set();
7
+ reads = new Map();
8
+ signatures = new Map();
9
+ filesRefreshTimer;
10
+ constructor(options) {
11
+ this.options = options;
12
+ }
13
+ async initial(workspace, watch) {
14
+ if (watch.topics.files !== undefined)
15
+ this.ensureFilesRefreshTimer();
16
+ await Promise.all(this.subscribedTopics(watch).map(async (topic) => {
17
+ try {
18
+ const payload = await this.read(workspace, topic, watch);
19
+ if (!this.matches(workspace.id, watch))
20
+ return;
21
+ this.signatures.set(this.viewKey(workspace.id, topic, watch), signature(payload));
22
+ this.deliver(workspace, watch, topic, payload);
23
+ }
24
+ catch {
25
+ this.fail(workspace.id, watch, topic);
26
+ }
27
+ }));
28
+ }
29
+ async invalidate(workspaceId, topic) {
30
+ const key = `${workspaceId}:${topic}`;
31
+ const active = this.refreshes.get(key);
32
+ if (active !== undefined) {
33
+ this.dirty.add(key);
34
+ return active;
35
+ }
36
+ if (this.readActive(workspaceId, topic))
37
+ this.dirty.add(key);
38
+ const refresh = this.refresh(workspaceId, topic).catch(() => {
39
+ for (const watch of this.subscribers(workspaceId, topic))
40
+ this.fail(workspaceId, watch, topic);
41
+ });
42
+ this.refreshes.set(key, refresh);
43
+ try {
44
+ await refresh;
45
+ }
46
+ finally {
47
+ if (this.refreshes.get(key) === refresh)
48
+ this.refreshes.delete(key);
49
+ if (this.dirty.delete(key))
50
+ void this.invalidate(workspaceId, topic);
51
+ }
52
+ }
53
+ ensureSnapshot(workspaceId, topic) {
54
+ return this.refreshes.get(`${workspaceId}:${topic}`) ?? this.invalidate(workspaceId, topic);
55
+ }
56
+ clear(workspaceId) {
57
+ for (const key of [...this.dirty])
58
+ if (key.startsWith(`${workspaceId}:`))
59
+ this.dirty.delete(key);
60
+ for (const key of [...this.signatures.keys()])
61
+ if (key.startsWith(`${workspaceId}:`))
62
+ this.signatures.delete(key);
63
+ }
64
+ clearAll() {
65
+ if (this.filesRefreshTimer !== undefined)
66
+ clearInterval(this.filesRefreshTimer);
67
+ this.filesRefreshTimer = undefined;
68
+ this.dirty.clear();
69
+ this.signatures.clear();
70
+ }
71
+ ensureFilesRefreshTimer() {
72
+ if (this.filesRefreshTimer !== undefined)
73
+ return;
74
+ this.filesRefreshTimer = setInterval(() => {
75
+ const workspaceIds = this.options.watch.activeWorkspaceIds('files');
76
+ if (workspaceIds.length === 0) {
77
+ if (this.filesRefreshTimer !== undefined)
78
+ clearInterval(this.filesRefreshTimer);
79
+ this.filesRefreshTimer = undefined;
80
+ return;
81
+ }
82
+ for (const workspaceId of workspaceIds)
83
+ void this.invalidate(workspaceId, 'files');
84
+ }, this.options.filesRefreshIntervalMs ?? FILES_REFRESH_INTERVAL_MS);
85
+ this.filesRefreshTimer.unref();
86
+ }
87
+ async refresh(workspaceId, topic) {
88
+ const workspace = this.options.requireWorkspace(workspaceId);
89
+ const subscribers = this.subscribers(workspaceId, topic);
90
+ if (subscribers.length === 0)
91
+ return;
92
+ if (topic !== 'files') {
93
+ const first = subscribers[0];
94
+ if (first === undefined)
95
+ return;
96
+ const payload = await this.read(workspace, topic, first);
97
+ const activeSubscribers = subscribers.filter((watch) => this.matches(workspaceId, watch));
98
+ if (activeSubscribers.length === 0)
99
+ return;
100
+ if (!this.changed(this.viewKey(workspaceId, topic, first), payload))
101
+ return;
102
+ for (const watch of activeSubscribers)
103
+ this.deliver(workspace, watch, topic, payload);
104
+ return;
105
+ }
106
+ const views = new Map();
107
+ for (const watch of subscribers) {
108
+ const key = JSON.stringify(watch.topics.files);
109
+ views.set(key, [...(views.get(key) ?? []), watch]);
110
+ }
111
+ await Promise.all([...views.values()].map(async (viewSubscribers) => {
112
+ const first = viewSubscribers[0];
113
+ if (first === undefined)
114
+ return;
115
+ try {
116
+ const payload = await this.read(workspace, topic, first);
117
+ const activeSubscribers = viewSubscribers.filter((watch) => this.matches(workspaceId, watch));
118
+ if (activeSubscribers.length === 0)
119
+ return;
120
+ if (!this.changed(this.viewKey(workspaceId, topic, first), payload))
121
+ return;
122
+ for (const watch of activeSubscribers)
123
+ this.deliver(workspace, watch, topic, payload);
124
+ }
125
+ catch {
126
+ for (const watch of viewSubscribers)
127
+ this.fail(workspaceId, watch, topic);
128
+ }
129
+ }));
130
+ }
131
+ read(workspace, topic, watch) {
132
+ const key = topic === 'files'
133
+ ? `${workspace.id}:files:${JSON.stringify(watch.topics.files)}`
134
+ : `${workspace.id}:${topic}`;
135
+ const active = this.reads.get(key);
136
+ if (active !== undefined)
137
+ return active;
138
+ const read = (topic === 'sessions'
139
+ ? this.options.listSessions(workspace.id)
140
+ : topic === 'changes'
141
+ ? workspace.kind === 'GIT_WORKSPACE'
142
+ ? this.options.changes.current(workspace)
143
+ : Promise.resolve(null)
144
+ : this.options.files.list(workspace, watch.topics.files).then((files) => ({ files }))).finally(() => {
145
+ if (this.reads.get(key) === read)
146
+ this.reads.delete(key);
147
+ });
148
+ this.reads.set(key, read);
149
+ return read;
150
+ }
151
+ changed(key, payload) {
152
+ const next = signature(payload);
153
+ if (this.signatures.get(key) === next)
154
+ return false;
155
+ this.signatures.set(key, next);
156
+ return true;
157
+ }
158
+ viewKey(workspaceId, topic, watch) {
159
+ return topic === 'files'
160
+ ? `${workspaceId}:files:${JSON.stringify(watch.topics.files)}`
161
+ : `${workspaceId}:${topic}`;
162
+ }
163
+ readActive(workspaceId, topic) {
164
+ const prefix = `${workspaceId}:${topic}`;
165
+ return [...this.reads.keys()].some((key) => key === prefix || key.startsWith(`${prefix}:`));
166
+ }
167
+ subscribers(workspaceId, topic) {
168
+ return this.options.watch
169
+ .activeWatches(workspaceId)
170
+ .filter((watch) => topic === 'files' ? watch.topics.files !== undefined : watch.topics[topic]);
171
+ }
172
+ subscribedTopics(watch) {
173
+ return [
174
+ ...(watch.topics.sessions ? ['sessions'] : []),
175
+ ...(watch.topics.files === undefined ? [] : ['files']),
176
+ ...(watch.topics.changes ? ['changes'] : [])
177
+ ];
178
+ }
179
+ deliver(workspace, watch, topic, payload) {
180
+ if (!this.matches(workspace.id, watch))
181
+ return;
182
+ this.options.emitWatchEvent({
183
+ type: 'watch.workspace.snapshot',
184
+ workbenchConnectionId: watch.workbenchConnectionId,
185
+ watchId: watch.watchId,
186
+ nodeGeneration: watch.nodeGeneration,
187
+ nodeId: this.options.nodeId(),
188
+ workspaceId: workspace.id,
189
+ topic,
190
+ revision: this.options.watch.nextRevision(this.viewKey(workspace.id, topic, watch)),
191
+ snapshotSequence: this.options.watch.nextSnapshotSequence(),
192
+ expiresAt: watch.expiresAt,
193
+ payload
194
+ });
195
+ }
196
+ fail(workspaceId, watch, topic) {
197
+ if (!this.matches(workspaceId, watch))
198
+ return;
199
+ this.options.emitWatchEvent({
200
+ type: 'watch.failed',
201
+ workbenchConnectionId: watch.workbenchConnectionId,
202
+ watchType: 'workspace',
203
+ watchId: watch.watchId,
204
+ nodeGeneration: watch.nodeGeneration,
205
+ nodeId: this.options.nodeId(),
206
+ workspaceId,
207
+ topic,
208
+ code: 'WORKSPACE_WATCH_SNAPSHOT_FAILED',
209
+ message: 'Workspace watch snapshot failed.'
210
+ });
211
+ }
212
+ matches(workspaceId, watch) {
213
+ return this.options.watch.matches(workspaceId, `${watch.sessionHash}:${watch.workbenchConnectionId}`, watch.watchId);
214
+ }
215
+ }
216
+ function signature(payload) {
217
+ return JSON.stringify(payload) ?? String(payload);
218
+ }