@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.
- package/LICENSE +202 -0
- package/NOTICE +4 -0
- package/dist/capabilities.js +110 -2
- package/dist/claude-agent-sdk.js +330 -2
- package/dist/claude-channel.js +44 -2
- package/dist/codex-app-server.js +510 -2
- package/dist/config.js +106 -2
- package/dist/connector/node-connector-options.js +1 -2
- package/dist/connector/node-operation-router.js +22 -2
- package/dist/connector.js +1736 -2
- package/dist/control-outbound-scheduler.js +153 -2
- package/dist/database.js +639 -2
- package/dist/fake-runner.js +129 -2
- package/dist/git-askpass.js +12 -0
- package/dist/git-execution-helper.js +266 -0
- package/dist/health.js +3 -2
- package/dist/main.js +57 -2
- package/dist/mcp-installation-model.js +1 -2
- package/dist/migrations/v004.js +55 -3
- package/dist/migrations/v005.js +13 -3
- package/dist/migrations/v006.js +90 -3
- package/dist/migrations/v007.js +22 -3
- package/dist/migrations/v008.js +18 -3
- package/dist/migrations/v009.js +70 -4
- package/dist/migrations/v010.js +43 -3
- package/dist/migrations/v011.js +20 -3
- package/dist/migrations/v012.js +8 -0
- package/dist/native-jsonl-reader.js +186 -2
- package/dist/native-session-history.js +1143 -2
- package/dist/opencode-runtime.js +80 -2
- package/dist/opencode-server.js +259 -2
- package/dist/operational.js +122 -2
- package/dist/process-tree.js +18 -2
- package/dist/ripgrep-binary.js +31 -2
- package/dist/rotating-log.js +67 -2
- package/dist/runner/abstract-runner.js +260 -2
- package/dist/runner/claude/managed-run-controller.js +355 -2
- package/dist/runner/claude/tool-normalizer.js +120 -2
- package/dist/runner/claude-code-runner.js +303 -2
- package/dist/runner/codex/composer-image-markers.js +8 -2
- package/dist/runner/codex/conversation-parser.js +913 -2
- package/dist/runner/codex/managed-run-controller.js +494 -2
- package/dist/runner/codex/tool-normalizer.js +214 -2
- package/dist/runner/codex-runner.js +585 -2
- package/dist/runner/fake-test-runner.js +47 -2
- package/dist/runner/mar-agent/conversation-normalizer.js +644 -2
- package/dist/runner/mar-agent/executor-stdio-client-transport.js +139 -2
- package/dist/runner/mar-agent/generated-images.js +41 -2
- package/dist/runner/mar-agent/history-projection.js +106 -2
- package/dist/runner/mar-agent/hosted-conversation-runtime.js +446 -2
- package/dist/runner/mar-agent/managed-run-controller.js +785 -2
- package/dist/runner/mar-agent/mcp-client-pool.js +233 -2
- package/dist/runner/mar-agent/runtime-model-factory.js +326 -2
- package/dist/runner/mar-agent-runner.js +458 -2
- package/dist/runner/opencode/conversation-parser.js +221 -2
- package/dist/runner/opencode/managed-run-controller.js +588 -2
- package/dist/runner/opencode/tool-normalizer.js +80 -2
- package/dist/runner/opencode-runner.js +426 -2
- package/dist/runner/runner-registry.js +87 -2
- package/dist/runner-command-engine.js +71 -2
- package/dist/runner-profiles.js +323 -2
- package/dist/runner-usage.js +190 -2
- package/dist/runtime-command-detector.js +73 -2
- package/dist/runtime-model.js +1 -2
- package/dist/runtime-state.js +1509 -2
- package/dist/service/attachment-domain-state.js +7 -2
- package/dist/service/bubblewrap-sandbox-executor.js +543 -2
- package/dist/service/continuous-run-coordinator.js +425 -2
- package/dist/service/conversation-history-service.js +552 -2
- package/dist/service/conversation-hosting-capability-service.js +61 -2
- package/dist/service/conversation-hosting-enablement-service.js +91 -2
- package/dist/service/conversation-hosting-maintenance-service.js +174 -2
- package/dist/service/conversation-segment-service.js +162 -2
- package/dist/service/conversation-template-node-service.js +992 -2
- package/dist/service/external-session-resume-service.js +152 -2
- package/dist/service/fake-managed-run-service.js +60 -2
- package/dist/service/git-execution-service.js +418 -0
- package/dist/service/git-operation-service.js +57 -0
- package/dist/service/hosted-conversation-node-service.js +1982 -2
- package/dist/service/hosted-conversation-store.js +1405 -2
- package/dist/service/managed-runner-session-service.js +35 -2
- package/dist/service/mar-agent-model-transport-test-service.js +88 -2
- package/dist/service/mcp-installation-verifier.js +87 -2
- package/dist/service/mcp-node-operation-service.js +90 -2
- package/dist/service/mission-mcp-server.js +124 -2
- package/dist/service/mission-mcp-stdio.js +40 -2
- package/dist/service/mission-runtime.js +142 -2
- package/dist/service/native-session-projection-service.js +274 -2
- package/dist/service/native-session-watch-service.js +683 -2
- package/dist/service/node-connection-lifecycle-service.js +88 -2
- package/dist/service/node-control-channel.js +85 -2
- package/dist/service/node-control-message-service.js +109 -2
- package/dist/service/node-request-service.js +62 -2
- package/dist/service/node-run-event-bridge.js +88 -2
- package/dist/service/node-terminal-channel.js +202 -2
- package/dist/service/node-upgrade-coordinator.js +137 -2
- package/dist/service/node-workspace-coordinator.js +97 -2
- package/dist/service/recent-run-projection-service.js +99 -2
- package/dist/service/run-attachment-service.js +321 -2
- package/dist/service/run-domain-state.js +4 -2
- package/dist/service/run-event-service.js +246 -2
- package/dist/service/run-ownership-policy.js +22 -2
- package/dist/service/run-workbench-service.js +120 -2
- package/dist/service/runner-channel-message-service.js +20 -2
- package/dist/service/runner-interaction-service.js +243 -2
- package/dist/service/runner-service.js +69 -2
- package/dist/service/runtime-credential-control-service.js +95 -2
- package/dist/service/session-catalog-service.js +404 -2
- package/dist/service/session-command-service.js +125 -2
- package/dist/service/session-context-service.js +128 -2
- package/dist/service/session-domain-state.js +9 -2
- package/dist/service/session-identity-service.js +86 -2
- package/dist/service/session-lifecycle-service.js +248 -2
- package/dist/service/session-message-service.js +270 -2
- package/dist/service/session-presentation-service.js +43 -2
- package/dist/service/session-query-service.js +82 -2
- package/dist/service/session-watch-slot-coordinator.js +21 -2
- package/dist/service/skill-directory-service.js +238 -2
- package/dist/service/skill-install-service.js +434 -2
- package/dist/service/skill-node-operation-service.js +206 -2
- package/dist/service/terminal-relay-state.js +3 -2
- package/dist/service/terminal-service.js +90 -2
- package/dist/service/web-search-error.js +40 -2
- package/dist/service/workbench-event-service.js +21 -2
- package/dist/service/workbench-manifest-service.js +69 -2
- package/dist/service/workspace-change-service.js +290 -2
- package/dist/service/workspace-content-search-service.js +457 -2
- package/dist/service/workspace-domain-state.js +41 -2
- package/dist/service/workspace-file-service.js +150 -2
- package/dist/service/workspace-git-exclude-service.js +119 -2
- package/dist/service/workspace-queue-workbench-service.js +176 -2
- package/dist/service/workspace-service.js +92 -2
- package/dist/service/workspace-session-service.js +154 -2
- package/dist/service/workspace-upload-service.js +262 -2
- package/dist/service/workspace-watch-controller.js +68 -2
- package/dist/service/workspace-watch-service.js +170 -2
- package/dist/service/workspace-watch-snapshot-service.js +218 -2
- package/dist/service/workspace-workbench-service.js +239 -2
- package/dist/service.js +91 -2
- package/dist/storage.js +32 -2
- package/dist/supervisor.js +136 -2
- package/dist/terminal.js +496 -2
- package/dist/util/git-credential-client.js +32 -0
- package/dist/util/node-operation-data.js +9 -2
- package/dist/util/node-operation-parsers.js +382 -2
- package/dist/util/personal-instructions.js +34 -2
- package/dist/util/runner-error.js +70 -2
- package/dist/util/runner-native-session-parsers.js +510 -2
- package/dist/util/safe-error.js +8 -2
- package/dist/util/secret-environment.js +25 -2
- package/dist/workspace.js +1793 -2
- package/package.json +11 -8
- package/vendor/ripgrep/darwin-arm64/rg +0 -0
- package/vendor/ripgrep/darwin-x64/rg +0 -0
- package/vendor/ripgrep/manifest.json +12 -0
- package/README.md +0 -42
- package/dist/event-buffer.js +0 -2
- package/dist/migrations/v001.js +0 -107
- package/dist/migrations/v002.js +0 -2
- package/dist/migrations/v003.js +0 -2
- package/dist/service/mcp-package-installer.js +0 -2
|
@@ -1,2 +1,142 @@
|
|
|
1
|
-
|
|
2
|
-
const _0x5f5203=_0x4a76;function _0x4a76(_0x50939a,_0x3ce876){_0x50939a=_0x50939a-(0x1ab5+0x1*0x21af+-0x3a7f);const _0x102479=_0xc762();let _0x582f4c=_0x102479[_0x50939a];if(_0x4a76['RFYLCs']===undefined){var _0x419445=function(_0x27f466){const _0x5917f6='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1acc16='',_0x33cfb2='';for(let _0x3785e3=0x2038+-0x2582+0x54a,_0x5a05bb,_0x296c7f,_0x3ca8ac=0x111c+0xee7+-0x2003*0x1;_0x296c7f=_0x27f466['charAt'](_0x3ca8ac++);~_0x296c7f&&(_0x5a05bb=_0x3785e3%(-0x1*-0x1ff9+-0x1be*0x11+-0x1*0x257)?_0x5a05bb*(-0x201b+-0x7c7*-0x1+0xb*0x23c)+_0x296c7f:_0x296c7f,_0x3785e3++%(0x1b95+-0x8b*0x28+0x3*-0x1f3))?_0x1acc16+=String['fromCharCode'](0x18f1*0x1+-0x1*0x11cf+-0x623&_0x5a05bb>>(-(0x2700+-0x1d8e+0x1*-0x970)*_0x3785e3&0x833+-0x52*0x52+0x1217)):0x55+0x184f+0x4c*-0x53){_0x296c7f=_0x5917f6['indexOf'](_0x296c7f);}for(let _0x42c153=0x698+0xe7b+-0x41*0x53,_0x3a2099=_0x1acc16['length'];_0x42c153<_0x3a2099;_0x42c153++){_0x33cfb2+='%'+('00'+_0x1acc16['charCodeAt'](_0x42c153)['toString'](0x14d8+0x2*-0x2be+0x3d3*-0x4))['slice'](-(-0x2*-0x60d+0x34+-0xc4c));}return decodeURIComponent(_0x33cfb2);};_0x4a76['ziCWFG']=_0x419445,_0x4a76['ViJbek']={},_0x4a76['RFYLCs']=!![];}const _0x40969e=_0x102479[-0xd17*-0x2+-0x130*0x7+0x1*-0x11de];_0x4a76['xLtJkc']!==_0x40969e&&(_0x4a76['ViJbek']={},_0x4a76['xLtJkc']=_0x40969e);const _0xfff95c=_0x4a76['ViJbek'][_0x50939a];return _0xfff95c===undefined?(_0x582f4c=_0x4a76['ziCWFG'](_0x582f4c),_0x4a76['ViJbek'][_0x50939a]=_0x582f4c):_0x582f4c=_0xfff95c,_0x582f4c;}(function(_0x457806,_0x52f643){const _0x6bdffb=_0x4a76,_0x443576=_0x457806();while(!![]){try{const _0x199000=-parseInt(_0x6bdffb(0x209))/(0x7*0x1a3+0x89e+-0x1412)+parseInt(_0x6bdffb(0x21a))/(0x2ad*-0x1+0x545*-0x1+0x7f4)+-parseInt(_0x6bdffb(0x207))/(0x1a0c+0x1e49*-0x1+0x44*0x10)+-parseInt(_0x6bdffb(0x1fb))/(-0xb43*0x1+-0x1*-0x2001+-0x14ba)*(parseInt(_0x6bdffb(0x1eb))/(0xa39+-0x19*-0x8d+-0x17f9))+-parseInt(_0x6bdffb(0x21d))/(0x4*0x3d0+0xe64+-0x1d9e)*(parseInt(_0x6bdffb(0x1f2))/(0x11fa+-0xbfc+-0x1*0x5f7))+parseInt(_0x6bdffb(0x217))/(-0x2dc+-0x234+-0x8*-0xa3)+parseInt(_0x6bdffb(0x1ef))/(-0x265f+-0xcd*0x23+0x426f)*(parseInt(_0x6bdffb(0x1e9))/(0x1*-0x12b3+-0xc06+0x20d*0xf));if(_0x199000===_0x52f643)break;else _0x443576['push'](_0x443576['shift']());}catch(_0x37679c){_0x443576['push'](_0x443576['shift']());}}}(_0xc762,-0x74996+0x38a4e*-0x3+-0xf3aa8*-0x2));import{randomUUID}from'node:crypto';export function missionUnrestrictedAccess(_0x3e7529){const _0x4692c2=_0x4a76;if(_0x3e7529===_0x4692c2(0x1fa)||_0x3e7529===_0x4692c2(0x1f3))return _0x4692c2(0x1f9);if(_0x3e7529===_0x4692c2(0x208))return _0x4692c2(0x216);return _0x4692c2(0x1e5);}function _0xc762(){const _0x1d64a0=['CMvXDwLYzun1CNjLBNq','yNLWyxnZ','odeWndKZnKPst2L0yW','CMvJB3jKrxHLy3v0Aw9UuMvZDwX0','BwLNCMf0zvnLC3nPB24','mJu4mJG2nK1LALHYtW','pc9TyxjFBwLZC2LVBL9ZDgfYDd4','y2XLyxi','mtm3otrur1jhqu0','yxv0BW','tuLtu0LptL9pqKPfq1rjvKvFsu5wquXjra','y2HHBMDLza','tuLtu0LptL9ot1rFrK9vtKq','mJGWmtC2ntbwyxzor0W','CMv0CNLszxf1AxjLza','nuD6shDjva','DxbKyxrL','cGPpCMLNAw5HBcbVyMPLy3rPDMu6cG','BwLZC2LVBNm','ow9mCuzerG','DhjPBvn0yxj0','qsbnAxnZAw9UigHHCYbZDgfYDgvKig9YignOyw5NzwqU','mJC1ohfICwPNuW','BwfYlwfNzw50','C2v0','CMvJB3jKvhvYBG','tuLtu0LptL9srvzju0LptL9tvefmrq','DhjPBq','B2jQzwn0AxzL','zNvSBc1Hy2nLC3m','y29KzxG','mJq4nJmXnMjns3ritG','tuLtu0LptL9cte9ds0vex1rpt19fqvjmwq','pg1HCL9TAxnZAw9Ux3n0yxj0pG','Aw5KzxHpzG','tuLtu0LptL9ot1rFqunusvzf','yMXVy2TLza','yMXVy2TbzNrLCLj1BNrPBwvgywLSDxjL','zgvSzxrL','ChjVBxb0','ywn0AxzL','C3rHCNrZv2L0Aa','CMv2AxnPB24','mZyYotuYme1mCNDzEG','y2XHDwrLlwnVzgu','mtu0nJyXmevyzMPowG','BgvUz3rO','C2XPy2u','zxHLy3v0Aw9UrMfPBhvYzxm','tuLtu0LptL9cte9ds0vex1jfvfjzx1jfuvvjuKve','cGPnAxnZAw9Uihj1BgvZoGOTifrOzsbnAxnZAw9UihbLCNnPC3rZigfJCM9ZCYb0DxjUCZSGzw5KAw5NihrOAxmGDhvYBIbKB2vZig5VDcbLBMqGAxqUcI0Grg8GBM90ig5HCNjVDYbVCIbYzxDYAxrLihrOzsbVCMLNAw5HBcbVyMPLy3rPDMuGDg8GzMLUAxnOigvHCMX5lIbdB250Aw51zsbTywTPBMCGy29Uy3jLDguGChjVz3jLC3mGD2HPBguGAxqGAxmGAw5JB21WBgv0zs4klsbczwzVCMuGy29TCgXLDgLVBIWGCMv2Awv3ihrOzsbMDwXSig9YAwDPBMfSig9IAMvJDgL2zsbHBMqGDMvYAwz5igL0ihDPDgGGywn0DwfSigv2AwrLBMnLihn1y2GGyxmGy29KzsWGDgvZDhmSignVBw1HBMrZlcbVCIbYDw50Aw1LihjLC3vSDhmUcI0Gq2fSBcbTyxjFDxbKyxrLx21PC3nPB24GD2L0AcbZDgf0Dxm9y29TCgXLDgvKig9UBhKGywz0zxiGzxzLCNKGCgfYDcbPCYbJB21WBgv0zsbHBMqGDMvYAwzPzwqUcI0GqsbZAw5NBguGzMfPBgvKignVBw1HBMqSihrLC3qSig9YigvKAxqGAxmGBM90igeGyMXVy2TLCI4Gqw5HBhL6zsbPDcWGywrHChqSigfUzcbYzxrYEs4klsbszxf1zxn0igjSB2nRzwqGB25SEsbHzNrLCIb0AguGC2fTzsbIBg9JA2vYigHHCYbWzxjZAxn0zwqGzM9YihrOCMvLie1PC3nPB24GDhvYBNmUie9UzsbHzgrPDgLVBMfSihjLywWGCMv0CNKGAxmGCMvXDwLYzwqGyMvMB3jLigjSB2nRzwqGy2fUigjLigfJy2vWDgvKlGOTifvZzsbTyxjFz2v0x21PC3nPB24GD2HLBMv2zxiGEw91ig5LzwqGDg8GCMvYzwfKihrOzsbHDxrOB3jPDgf0AxzLig9IAMvJDgL2zsbVCIbZDgf0DxmUcG','q29UDgLUDwuGDgHLigfJDgL2zsbnAxnZAw9UlG','C3rHCNq','z2v0','CMv0CNLtDgfYDgvKqxruDxjU','C3rHDhvZ','DhvYBNm'];_0xc762=function(){return _0x1d64a0;};return _0xc762();}const START_OPEN=_0x5f5203(0x1fd),START_CLOSE=_0x5f5203(0x21b);export function stripMissionStartPrompt(_0x2fefea){const _0x1df32b=_0x5f5203;if(!_0x2fefea[_0x1df32b(0x205)](START_OPEN))return _0x2fefea;const _0x414766=_0x2fefea[_0x1df32b(0x1fe)](START_CLOSE);return _0x414766===-(-0x459*0x3+0x111c+-0x410*0x1)?'':_0x2fefea[_0x1df32b(0x20b)](_0x414766+START_CLOSE[_0x1df32b(0x20a)])[_0x1df32b(0x1f0)]();}export class MissionRuntime{[_0x5f5203(0x1e7)];[_0x5f5203(0x1ee)]=new Map();[_0x5f5203(0x20c)]=new Map();constructor(_0x217748){const _0x112051=_0x5f5203;this[_0x112051(0x1e7)]=_0x217748;}[_0x5f5203(0x211)](_0xe13f60){const _0x616b10=_0x5f5203;return this[_0x616b10(0x1ee)][_0x616b10(0x211)](_0xe13f60);}[_0x5f5203(0x219)](_0xb83e89,_0x4fa43f){const _0x223e76=_0x5f5203;if(_0xb83e89===_0x4fa43f)return;const _0x258ae5=this[_0x223e76(0x1ee)][_0x223e76(0x211)](_0xb83e89);_0x258ae5!==undefined&&(this[_0x223e76(0x1ee)][_0x223e76(0x202)](_0xb83e89),this[_0x223e76(0x1ee)][_0x223e76(0x1f4)](_0x4fa43f,{..._0x258ae5,'sessionId':_0x4fa43f}));const _0x45e3de=this[_0x223e76(0x20c)][_0x223e76(0x211)](_0xb83e89);_0x45e3de!==undefined&&(this[_0x223e76(0x20c)][_0x223e76(0x202)](_0xb83e89),this[_0x223e76(0x20c)][_0x223e76(0x1f4)](_0x4fa43f,_0x45e3de));}[_0x5f5203(0x210)](_0xa2d3dc,_0x4add87){const _0x5a149d=_0x5f5203,_0x88ec62=_0x4add87[_0x5a149d(0x1f7)]();if(_0x88ec62[_0x5a149d(0x20a)]===-0x1*-0x1ff9+-0x1be*0x11+-0x3*0xc9||_0x88ec62[_0x5a149d(0x20a)]>-0x806d+-0xf8e*-0x2+0x3*0x3a7b)throw new Error(_0x5a149d(0x1e6));const _0x40ed16=this[_0x5a149d(0x1ee)][_0x5a149d(0x211)](_0xa2d3dc),_0x3157fa=_0x40ed16?.[_0x5a149d(0x213)]===_0x5a149d(0x204),_0x50939a={'id':_0x3157fa?_0x40ed16['id']:randomUUID(),'sessionId':_0xa2d3dc,'objective':_0x88ec62,'revision':_0x3157fa?_0x40ed16[_0x5a149d(0x206)]+(0x1b95+-0x8b*0x28+0xc*-0x7d):0x18f1*0x1+-0x1*0x11cf+-0x721,'status':_0x5a149d(0x204),'turns':0x0,'retryRequired':![],'retryStartedAtTurn':null};return this[_0x5a149d(0x1ee)][_0x5a149d(0x1f4)](_0xa2d3dc,_0x50939a),this[_0x5a149d(0x20c)][_0x5a149d(0x202)](_0xa2d3dc),this[_0x5a149d(0x1e7)](_0x50939a),_0x50939a;}[_0x5f5203(0x1f5)](_0x3ce876){const _0x402c32=_0x5f5203,_0x102479=this[_0x402c32(0x1ee)][_0x402c32(0x211)](_0x3ce876);if(_0x102479?.[_0x402c32(0x213)]!==_0x402c32(0x204))return _0x102479;const _0x582f4c={..._0x102479,'turns':_0x102479[_0x402c32(0x214)]+(0x2700+-0x1d8e+0x1*-0x971)};return this[_0x402c32(0x1ee)][_0x402c32(0x1f4)](_0x3ce876,_0x582f4c),_0x582f4c;}[_0x5f5203(0x218)](_0x419445,_0x40969e){const _0x505879=_0x5f5203,_0xfff95c=this[_0x505879(0x1ee)][_0x505879(0x211)](_0x419445);if(_0xfff95c?.[_0x505879(0x213)]!==_0x505879(0x204))return![];if(!_0x40969e)return this[_0x505879(0x20c)][_0x505879(0x202)](_0x419445),![];const _0x27f466=(this[_0x505879(0x20c)][_0x505879(0x211)](_0x419445)??0x833+-0x52*0x52+0x1211)+(0x55+0x184f+0x35*-0x77);this[_0x505879(0x20c)][_0x505879(0x1f4)](_0x419445,_0x27f466);if(_0x27f466<=0x698+0xe7b+-0x10*0x151)return![];const _0x5917f6={..._0xfff95c,'status':_0x505879(0x200)};return this[_0x505879(0x1ee)][_0x505879(0x1f4)](_0x419445,_0x5917f6),this[_0x505879(0x1e7)](_0x5917f6),!![];}[_0x5f5203(0x201)](_0x1acc16,_0x33cfb2,_0x3785e3){const _0x12257a=_0x5f5203,_0x5a05bb=this[_0x12257a(0x215)](_0x1acc16,_0x33cfb2,_0x3785e3),_0x296c7f={..._0x5a05bb,'status':_0x12257a(0x200)};return this[_0x12257a(0x1ee)][_0x12257a(0x1f4)](_0x1acc16,_0x296c7f),this[_0x12257a(0x20c)][_0x12257a(0x202)](_0x1acc16),this[_0x12257a(0x1e7)](_0x296c7f),_0x296c7f;}[_0x5f5203(0x1ec)](_0x3ca8ac,_0x42c153,_0x3a2099,_0xce5724){const _0x3412de=_0x5f5203,_0x20146f=this[_0x3412de(0x215)](_0x3ca8ac,_0x42c153,_0x3a2099);if(_0xce5724===_0x3412de(0x200)){if(_0x20146f[_0x3412de(0x214)]<0x14d8+0x2*-0x2be+0xf59*-0x1)throw new Error(_0x3412de(0x1fc));if(!_0x20146f[_0x3412de(0x1ea)]){const _0x392f18={..._0x20146f,'retryRequired':!![],'retryStartedAtTurn':_0x20146f[_0x3412de(0x214)]};return this[_0x3412de(0x1ee)][_0x3412de(0x1f4)](_0x3ca8ac,_0x392f18),this[_0x3412de(0x1e7)](_0x392f18),_0x392f18;}if(_0x20146f[_0x3412de(0x212)]===null||_0x20146f[_0x3412de(0x214)]<=_0x20146f[_0x3412de(0x212)])throw new Error(_0x3412de(0x20d));}const _0x4a7677={..._0x20146f,'status':_0xce5724};return this[_0x3412de(0x1ee)][_0x3412de(0x1f4)](_0x3ca8ac,_0x4a7677),this[_0x3412de(0x1e7)](_0x4a7677),_0x4a7677;}[_0x5f5203(0x21c)](_0x19e45b){const _0x342165=_0x5f5203,_0x41ed9b=this[_0x342165(0x1ee)][_0x342165(0x202)](_0x19e45b);this[_0x342165(0x20c)][_0x342165(0x202)](_0x19e45b);if(_0x41ed9b)this[_0x342165(0x1e7)](undefined);return _0x41ed9b;}[_0x5f5203(0x203)](_0x2345fc,_0x3bac29){const _0x45c1b4=_0x5f5203,_0x1b802c=this[_0x45c1b4(0x1ee)][_0x45c1b4(0x211)](_0x2345fc);if(_0x1b802c?.[_0x45c1b4(0x213)]!==_0x45c1b4(0x204))throw new Error(_0x45c1b4(0x1ff));const _0x3180ba=_0x3bac29===_0x45c1b4(0x210)?_0x45c1b4(0x1f1):_0x45c1b4(0x20f);return START_OPEN+'\x0a'+_0x3180ba+_0x45c1b4(0x1ed)+_0x1b802c[_0x45c1b4(0x1f8)]+_0x45c1b4(0x20e)+START_CLOSE;}[_0x5f5203(0x215)](_0x83df9d,_0x2b2cc3,_0x2fb171){const _0x46f690=_0x5f5203,_0x4e559c=this[_0x46f690(0x1ee)][_0x46f690(0x211)](_0x83df9d);if(_0x4e559c===undefined||_0x4e559c['id']!==_0x2b2cc3)throw new Error(_0x46f690(0x1e8));if(_0x4e559c[_0x46f690(0x206)]!==_0x2fb171)throw new Error(_0x46f690(0x1f6));if(_0x4e559c[_0x46f690(0x213)]!==_0x46f690(0x204))throw new Error(_0x46f690(0x1ff));return _0x4e559c;}}
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
export function missionUnrestrictedAccess(runner) {
|
|
3
|
+
if (runner === 'codex' || runner === 'mar-agent')
|
|
4
|
+
return 'full-access';
|
|
5
|
+
if (runner === 'claude-code')
|
|
6
|
+
return 'bypass';
|
|
7
|
+
return 'auto';
|
|
8
|
+
}
|
|
9
|
+
const START_OPEN = '<mar_mission_start>';
|
|
10
|
+
const START_CLOSE = '</mar_mission_start>';
|
|
11
|
+
export function stripMissionStartPrompt(text) {
|
|
12
|
+
if (!text.startsWith(START_OPEN))
|
|
13
|
+
return text;
|
|
14
|
+
const close = text.indexOf(START_CLOSE);
|
|
15
|
+
return close === -1 ? '' : text.slice(close + START_CLOSE.length).trimStart();
|
|
16
|
+
}
|
|
17
|
+
export class MissionRuntime {
|
|
18
|
+
changed;
|
|
19
|
+
missions = new Map();
|
|
20
|
+
executionFailures = new Map();
|
|
21
|
+
constructor(changed) {
|
|
22
|
+
this.changed = changed;
|
|
23
|
+
}
|
|
24
|
+
get(sessionId) {
|
|
25
|
+
return this.missions.get(sessionId);
|
|
26
|
+
}
|
|
27
|
+
migrateSession(previousId, nextId) {
|
|
28
|
+
if (previousId === nextId)
|
|
29
|
+
return;
|
|
30
|
+
const mission = this.missions.get(previousId);
|
|
31
|
+
if (mission !== undefined) {
|
|
32
|
+
this.missions.delete(previousId);
|
|
33
|
+
this.missions.set(nextId, { ...mission, sessionId: nextId });
|
|
34
|
+
}
|
|
35
|
+
const failures = this.executionFailures.get(previousId);
|
|
36
|
+
if (failures !== undefined) {
|
|
37
|
+
this.executionFailures.delete(previousId);
|
|
38
|
+
this.executionFailures.set(nextId, failures);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
start(sessionId, objective) {
|
|
42
|
+
const normalized = objective.trim();
|
|
43
|
+
if (normalized.length === 0 || normalized.length > 20_000)
|
|
44
|
+
throw new Error('MISSION_OBJECTIVE_INVALID');
|
|
45
|
+
const current = this.missions.get(sessionId);
|
|
46
|
+
const continuing = current?.status === 'active';
|
|
47
|
+
const mission = {
|
|
48
|
+
id: continuing ? current.id : randomUUID(),
|
|
49
|
+
sessionId,
|
|
50
|
+
objective: normalized,
|
|
51
|
+
revision: continuing ? current.revision + 1 : 1,
|
|
52
|
+
status: 'active',
|
|
53
|
+
turns: 0,
|
|
54
|
+
retryRequired: false,
|
|
55
|
+
retryStartedAtTurn: null
|
|
56
|
+
};
|
|
57
|
+
this.missions.set(sessionId, mission);
|
|
58
|
+
this.executionFailures.delete(sessionId);
|
|
59
|
+
this.changed(mission);
|
|
60
|
+
return mission;
|
|
61
|
+
}
|
|
62
|
+
recordTurn(sessionId) {
|
|
63
|
+
const current = this.missions.get(sessionId);
|
|
64
|
+
if (current?.status !== 'active')
|
|
65
|
+
return current;
|
|
66
|
+
const mission = { ...current, turns: current.turns + 1 };
|
|
67
|
+
this.missions.set(sessionId, mission);
|
|
68
|
+
return mission;
|
|
69
|
+
}
|
|
70
|
+
recordExecutionResult(sessionId, failed) {
|
|
71
|
+
const current = this.missions.get(sessionId);
|
|
72
|
+
if (current?.status !== 'active')
|
|
73
|
+
return false;
|
|
74
|
+
if (!failed) {
|
|
75
|
+
this.executionFailures.delete(sessionId);
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const failures = (this.executionFailures.get(sessionId) ?? 0) + 1;
|
|
79
|
+
this.executionFailures.set(sessionId, failures);
|
|
80
|
+
if (failures <= 3)
|
|
81
|
+
return false;
|
|
82
|
+
const blocked = { ...current, status: 'blocked' };
|
|
83
|
+
this.missions.set(sessionId, blocked);
|
|
84
|
+
this.changed(blocked);
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
blockAfterRuntimeFailure(sessionId, missionId, revision) {
|
|
88
|
+
const current = this.requireCurrent(sessionId, missionId, revision);
|
|
89
|
+
const blocked = { ...current, status: 'blocked' };
|
|
90
|
+
this.missions.set(sessionId, blocked);
|
|
91
|
+
this.executionFailures.delete(sessionId);
|
|
92
|
+
this.changed(blocked);
|
|
93
|
+
return blocked;
|
|
94
|
+
}
|
|
95
|
+
update(sessionId, missionId, revision, status) {
|
|
96
|
+
const current = this.requireCurrent(sessionId, missionId, revision);
|
|
97
|
+
if (status === 'blocked') {
|
|
98
|
+
if (current.turns < 3)
|
|
99
|
+
throw new Error('MISSION_BLOCKED_TOO_EARLY');
|
|
100
|
+
if (!current.retryRequired) {
|
|
101
|
+
const retry = {
|
|
102
|
+
...current,
|
|
103
|
+
retryRequired: true,
|
|
104
|
+
retryStartedAtTurn: current.turns
|
|
105
|
+
};
|
|
106
|
+
this.missions.set(sessionId, retry);
|
|
107
|
+
this.changed(retry);
|
|
108
|
+
return retry;
|
|
109
|
+
}
|
|
110
|
+
if (current.retryStartedAtTurn === null || current.turns <= current.retryStartedAtTurn)
|
|
111
|
+
throw new Error('MISSION_BLOCKED_RETRY_REQUIRED');
|
|
112
|
+
}
|
|
113
|
+
const mission = { ...current, status };
|
|
114
|
+
this.missions.set(sessionId, mission);
|
|
115
|
+
this.changed(mission);
|
|
116
|
+
return mission;
|
|
117
|
+
}
|
|
118
|
+
clear(sessionId) {
|
|
119
|
+
const removed = this.missions.delete(sessionId);
|
|
120
|
+
this.executionFailures.delete(sessionId);
|
|
121
|
+
if (removed)
|
|
122
|
+
this.changed(undefined);
|
|
123
|
+
return removed;
|
|
124
|
+
}
|
|
125
|
+
prompt(sessionId, kind) {
|
|
126
|
+
const mission = this.missions.get(sessionId);
|
|
127
|
+
if (mission?.status !== 'active')
|
|
128
|
+
throw new Error('MISSION_NOT_ACTIVE');
|
|
129
|
+
const heading = kind === 'start' ? 'A Mission has started or changed.' : 'Continue the active Mission.';
|
|
130
|
+
return `${START_OPEN}\n${heading}\n\nOriginal objective:\n${mission.objective}\n\nMission rules:\n- The Mission persists across turns; ending this turn does not end it.\n- Do not narrow or rewrite the original objective to finish early. Continue making concrete progress while it is incomplete.\n- Before completion, review the full original objective and verify it with actual evidence such as code, tests, commands, or runtime results.\n- Call mar_update_mission with status=completed only after every part is complete and verified.\n- A single failed command, test, or edit is not a blocker. Analyze it, adapt, and retry.\n- Request blocked only after the same blocker has persisted for three Mission turns. One additional real retry is required before blocked can be accepted.\n- Use mar_get_mission whenever you need to reread the authoritative objective or status.\n${START_CLOSE}`;
|
|
131
|
+
}
|
|
132
|
+
requireCurrent(sessionId, missionId, revision) {
|
|
133
|
+
const current = this.missions.get(sessionId);
|
|
134
|
+
if (current === undefined || current.id !== missionId)
|
|
135
|
+
throw new Error('MISSION_NOT_FOUND');
|
|
136
|
+
if (current.revision !== revision)
|
|
137
|
+
throw new Error('MISSION_REVISION_STALE');
|
|
138
|
+
if (current.status !== 'active')
|
|
139
|
+
throw new Error('MISSION_NOT_ACTIVE');
|
|
140
|
+
return current;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -1,2 +1,274 @@
|
|
|
1
|
-
|
|
2
|
-
const _0x21f6cf=_0x4e2c;(function(_0x69cee6,_0x1627c3){const _0x10bbd4=_0x4e2c,_0x446b53=_0x69cee6();while(!![]){try{const _0x1d7a40=parseInt(_0x10bbd4(0xfe))/(0xc1b*-0x2+-0x99a*-0x1+0xe9d)*(-parseInt(_0x10bbd4(0xca))/(0x1756*-0x1+0x13c*0x1f+-0xeec))+-parseInt(_0x10bbd4(0xbf))/(-0xd*-0x87+0xcd6+-0x13ae)+parseInt(_0x10bbd4(0xc8))/(0x62*0x60+0x1*0xadd+0x2f99*-0x1)+-parseInt(_0x10bbd4(0xf3))/(-0x899+-0x133*-0xe+-0x82c)+-parseInt(_0x10bbd4(0x10a))/(0x45a+0xc*-0x33f+0x22a0)*(parseInt(_0x10bbd4(0xf0))/(0x52*0x2c+0x1*-0x154c+0x73b))+-parseInt(_0x10bbd4(0xce))/(0xb3*-0x2e+0x3*-0x5c+0x10a3*0x2)+parseInt(_0x10bbd4(0xec))/(0x871+0x5*-0x2a1+-0x4bd*-0x1)*(parseInt(_0x10bbd4(0xb8))/(0x1*-0x23bb+0x409+0x1fbc));if(_0x1d7a40===_0x1627c3)break;else _0x446b53['push'](_0x446b53['shift']());}catch(_0x568e58){_0x446b53['push'](_0x446b53['shift']());}}}(_0x2ddc,-0x8b7bf*0x1+0x1d0a*-0x13+-0x7*-0x285a9));import{deduplicateDirectSessions}from'../util/runner-native-session-parsers.js';export class NativeSessionProjectionService{[_0x21f6cf(0xf2)];constructor(_0x1e6a53){const _0xe71ff6=_0x21f6cf;this[_0xe71ff6(0xf2)]=_0x1e6a53;}async[_0x21f6cf(0xfd)](_0x1f752e,_0x9f1e91){const _0x5eb031=_0x21f6cf,_0x2ce304=this[_0x5eb031(0xdb)](),_0x70aaf6=_0x9f1e91===undefined?undefined:_0x2ce304[_0x5eb031(0xf4)](_0x9f1e91);if(_0x9f1e91!==undefined&&_0x70aaf6===undefined)throw new Error(_0x5eb031(0xcf));const _0x3ef2d8=this[_0x5eb031(0xf2)][_0x5eb031(0xbc)][_0x5eb031(0x118)](_0x1f752e);if(_0x3ef2d8===undefined||!_0x3ef2d8[_0x5eb031(0xd8)](this[_0x5eb031(0xf2)][_0x5eb031(0x107)]()))throw new Error(_0x5eb031(0x11d));const _0x1cd8d0=await _0x3ef2d8[_0x5eb031(0x105)]({'workspaces':_0x2ce304[_0x5eb031(0x109)](),'createProjection':_0x1d4e03=>this[_0x5eb031(0xcb)](_0x1d4e03)},_0x70aaf6),_0x4cffc3=deduplicateDirectSessions(_0x1cd8d0);return this[_0x5eb031(0xba)](_0x4cffc3),_0x4cffc3;}async[_0x21f6cf(0x11e)](_0x582cb6){const _0xc4b2af=_0x21f6cf,_0x51cffb=await this[_0xc4b2af(0xfd)](_0xc4b2af(0x113),_0x582cb6);return{'sessions':_0x51cffb[_0xc4b2af(0xda)](this[_0xc4b2af(0xf2)][_0xc4b2af(0xe7)])};}async[_0x21f6cf(0xc0)](){const _0x1d7a29=_0x21f6cf,_0x2cf222=await Promise[_0x1d7a29(0xd1)](this[_0x1d7a29(0xf2)][_0x1d7a29(0xbc)][_0x1d7a29(0xf1)]()[_0x1d7a29(0x10e)](_0x2bc2da=>_0x2bc2da[_0x1d7a29(0xd8)](this[_0x1d7a29(0xf2)][_0x1d7a29(0x107)]()))[_0x1d7a29(0xda)](_0x1176e2=>this[_0x1d7a29(0xfd)](_0x1176e2[_0x1d7a29(0xd3)]))),_0x3a68df=deduplicateDirectSessions(_0x2cf222[_0x1d7a29(0xbd)]());return this[_0x1d7a29(0xba)](_0x3a68df),_0x3a68df[_0x1d7a29(0xda)](this[_0x1d7a29(0xf2)][_0x1d7a29(0xe7)]);}async[_0x21f6cf(0xe1)](_0x16e6bd){const _0x2ec26a=_0x21f6cf,_0x5136db=await Promise[_0x2ec26a(0xd1)](this[_0x2ec26a(0xf2)][_0x2ec26a(0xbc)][_0x2ec26a(0xf1)]()[_0x2ec26a(0x10e)](_0xc13c7c=>_0xc13c7c[_0x2ec26a(0xd8)](this[_0x2ec26a(0xf2)][_0x2ec26a(0x107)]()))[_0x2ec26a(0xda)](_0x19e4e1=>this[_0x2ec26a(0xfd)](_0x19e4e1[_0x2ec26a(0xd3)],_0x16e6bd))),_0x5cf071=deduplicateDirectSessions(_0x5136db[_0x2ec26a(0xbd)]());return this[_0x2ec26a(0xba)](_0x5cf071),_0x5cf071;}async[_0x21f6cf(0xdf)](_0x516556){const _0x327e53=_0x21f6cf,_0x48e994=this[_0x327e53(0xf2)][_0x327e53(0xcd)][_0x327e53(0xb6)][_0x327e53(0x10f)](_0x516556);if(_0x48e994!==undefined)return _0x48e994;const _0x2a8c53=(await this[_0x327e53(0xc0)]())[_0x327e53(0xf5)](_0x214415=>_0x214415['id']===_0x516556);if(_0x2a8c53!==undefined)return _0x2a8c53;const _0x679a38=this[_0x327e53(0xf2)][_0x327e53(0xe6)](),_0x493b84=_0x679a38?.[_0x327e53(0x109)]()[_0x327e53(0xe8)](_0x5bf8ff=>_0x679a38[_0x327e53(0xd6)](_0x5bf8ff['id']))[_0x327e53(0xf5)](_0x2cbbfb=>_0x2cbbfb['id']===_0x516556);if(_0x493b84===undefined)return undefined;const _0x30123c=_0x679a38?.[_0x327e53(0xf4)](_0x493b84[_0x327e53(0xeb)]);if(_0x30123c===undefined)return undefined;return{'id':_0x493b84['id'],'nodeId':this[_0x327e53(0xf2)][_0x327e53(0xfa)](),'workspaceId':_0x493b84[_0x327e53(0xeb)],'runner':_0x493b84[_0x327e53(0xf8)],'externalSessionId':_0x493b84['id'],'nativeControl':_0x327e53(0x11b),'channelToken':null,'cwd':_0x30123c[_0x327e53(0x10d)],'model':_0x493b84[_0x327e53(0x100)][_0x327e53(0x101)],'effort':_0x493b84[_0x327e53(0x100)][_0x327e53(0xb9)],'access':_0x493b84[_0x327e53(0x100)][_0x327e53(0xbe)],'customTitle':_0x493b84[_0x327e53(0x100)][_0x327e53(0xc2)],'runnerTitle':_0x493b84[_0x327e53(0x100)][_0x327e53(0x117)],'pinnedAt':_0x493b84[_0x327e53(0xc9)]===null?null:-0x1fb*0x1+0x189a+0x169e*-0x1,'pinOrder':_0x493b84[_0x327e53(0xc9)],'externalDiscovered':![],'titleSource':_0x493b84[_0x327e53(0x100)][_0x327e53(0xc2)]===null?_0x327e53(0xdc):_0x327e53(0x10c),'lastActivityAt':0x0,'createdAt':0x0};}async[_0x21f6cf(0xe5)](_0x19b499){const _0x5e0881=_0x21f6cf,_0x2db28a=await this[_0x5e0881(0xdf)](_0x19b499);return _0x2db28a===undefined?undefined:this[_0x5e0881(0xff)](_0x2db28a)??_0x2db28a;}async[_0x21f6cf(0xcc)](_0x566e2a){const _0x2ee983=_0x21f6cf,_0x5c9834=await this[_0x2ee983(0xdf)](_0x566e2a);if(_0x5c9834===undefined||_0x5c9834[_0x2ee983(0x11c)]===null)return undefined;const _0x203b70=this[_0x2ee983(0xf2)][_0x2ee983(0xbb)][_0x2ee983(0xc3)](_0x5c9834[_0x2ee983(0xf8)],_0x5c9834[_0x2ee983(0x11c)]);if(_0x203b70!==undefined&&_0x203b70[_0x2ee983(0xeb)]===_0x5c9834[_0x2ee983(0xeb)])return _0x203b70;return this[_0x2ee983(0xf2)][_0x2ee983(0xbb)][_0x2ee983(0x108)]({'workspaceId':_0x5c9834[_0x2ee983(0xeb)],'runner':_0x5c9834[_0x2ee983(0xf8)],'externalSessionId':_0x5c9834[_0x2ee983(0x11c)],'nativeControl':_0x2ee983(0x11b),'cwd':_0x5c9834[_0x2ee983(0x103)],..._0x5c9834[_0x2ee983(0x117)]===null?{}:{'title':_0x5c9834[_0x2ee983(0x117)]},..._0x5c9834[_0x2ee983(0xc2)]===null?{}:{'customTitle':_0x5c9834[_0x2ee983(0xc2)]}});}[_0x21f6cf(0xd5)](_0x33759d){const _0x34e4ab=_0x21f6cf,_0x45b1ca=this[_0x34e4ab(0xf2)][_0x34e4ab(0xe6)]()?.[_0x34e4ab(0xf4)](_0x33759d[_0x34e4ab(0xeb)]),_0x1d3b53={'runner':_0x33759d[_0x34e4ab(0xf8)],'model':_0x33759d[_0x34e4ab(0x101)],'effort':_0x33759d[_0x34e4ab(0xb9)],'access':_0x33759d[_0x34e4ab(0xbe)]};if(typeof _0x1d3b53[_0x34e4ab(0x101)]===_0x34e4ab(0xfb)&&typeof _0x1d3b53[_0x34e4ab(0xb9)]===_0x34e4ab(0xfb)&&typeof _0x1d3b53[_0x34e4ab(0xbe)]===_0x34e4ab(0xfb))return _0x1d3b53;const _0x48b3b1=this[_0x34e4ab(0xf2)][_0x34e4ab(0xe6)]()?.[_0x34e4ab(0xd4)]()[_0x34e4ab(0xf5)](_0x319158=>_0x319158[_0x34e4ab(0xf8)]===_0x33759d[_0x34e4ab(0xf8)]);return _0x48b3b1??this[_0x34e4ab(0xf2)][_0x34e4ab(0xbc)][_0x34e4ab(0xd9)](_0x33759d[_0x34e4ab(0xf8)])[_0x34e4ab(0xc7)](_0x45b1ca);}[_0x21f6cf(0xdd)](_0x12df76){const _0x654a7f=_0x21f6cf,_0x3a6469=this[_0x654a7f(0xd5)](_0x12df76);if(_0x12df76[_0x654a7f(0x101)]===_0x3a6469[_0x654a7f(0x101)]&&_0x12df76[_0x654a7f(0xb9)]===_0x3a6469[_0x654a7f(0xb9)]&&_0x12df76[_0x654a7f(0xbe)]===_0x3a6469[_0x654a7f(0xbe)])return _0x12df76;return this[_0x654a7f(0xf2)][_0x654a7f(0xbb)][_0x654a7f(0x114)]({'sessionId':_0x12df76['id'],'model':_0x3a6469[_0x654a7f(0x101)],'effort':_0x3a6469[_0x654a7f(0xb9)],'access':_0x3a6469[_0x654a7f(0xbe)]});}async[_0x21f6cf(0xee)](_0x3b31f3,_0x441908){const _0x19175e=_0x21f6cf;if(_0x3b31f3[_0x19175e(0x11c)]===null)return;await this[_0x19175e(0xf2)][_0x19175e(0xbc)][_0x19175e(0xd9)](_0x3b31f3[_0x19175e(0xf8)])[_0x19175e(0x102)](_0x3b31f3,_0x441908,this[_0x19175e(0xdb)]());}[_0x21f6cf(0xcb)](_0x4e7c82){const _0x6ad2ac=_0x21f6cf,_0x5bf0e1=_0x4e7c82[_0x6ad2ac(0x11a)]??0x1*0x8f6+-0x16ab+0xdb5,_0x366afd=this[_0x6ad2ac(0xf2)][_0x6ad2ac(0xe6)](),_0x43ea20=_0x366afd?.[_0x6ad2ac(0x112)](_0x4e7c82[_0x6ad2ac(0xf8)],_0x4e7c82[_0x6ad2ac(0x11c)],_0x4e7c82[_0x6ad2ac(0xd2)]['id']),_0x25a38d=this[_0x6ad2ac(0xf2)][_0x6ad2ac(0xbc)][_0x6ad2ac(0xd9)](_0x4e7c82[_0x6ad2ac(0xf8)])[_0x6ad2ac(0xd0)](_0x43ea20,{'externalSessionId':_0x4e7c82[_0x6ad2ac(0x11c)],'workspaceId':_0x4e7c82[_0x6ad2ac(0xd2)]['id'],..._0x4e7c82[_0x6ad2ac(0xe4)]===undefined?{}:{'title':_0x4e7c82[_0x6ad2ac(0xe4)]},..._0x4e7c82[_0x6ad2ac(0xc4)]===undefined?{}:{'titleOrigin':_0x4e7c82[_0x6ad2ac(0xc4)]}},_0x366afd);return{'id':_0x4e7c82[_0x6ad2ac(0x11c)],'nodeId':this[_0x6ad2ac(0xf2)][_0x6ad2ac(0xfa)](),'workspaceId':_0x4e7c82[_0x6ad2ac(0xd2)]['id'],'runner':_0x4e7c82[_0x6ad2ac(0xf8)],'externalSessionId':_0x4e7c82[_0x6ad2ac(0x11c)],'nativeControl':_0x6ad2ac(0x11b),'channelToken':null,'cwd':_0x4e7c82[_0x6ad2ac(0x103)],'model':_0x43ea20?.[_0x6ad2ac(0x101)]??null,'effort':_0x43ea20?.[_0x6ad2ac(0xb9)]??null,'access':_0x43ea20?.[_0x6ad2ac(0xbe)]??null,'customTitle':_0x43ea20?.[_0x6ad2ac(0xc2)]??null,'runnerTitle':_0x25a38d,'pinnedAt':_0x43ea20?.[_0x6ad2ac(0x110)]??null,'pinOrder':_0x43ea20?.[_0x6ad2ac(0xc9)]??null,'externalDiscovered':!![],'titleSource':_0x43ea20?.[_0x6ad2ac(0xc2)]===null||_0x43ea20?.[_0x6ad2ac(0xc2)]===undefined?_0x25a38d===null?_0x6ad2ac(0x111):_0x6ad2ac(0xdc):_0x6ad2ac(0x10c),'lastActivityAt':_0x5bf0e1,'createdAt':_0x5bf0e1};}[_0x21f6cf(0xba)](_0x484fce){const _0x5bf47f=_0x21f6cf;for(const _0x36d578 of _0x484fce)this[_0x5bf47f(0xf2)][_0x5bf47f(0xcd)][_0x5bf47f(0xb6)][_0x5bf47f(0xea)](_0x36d578['id'],_0x36d578);}[_0x21f6cf(0xff)](_0x471ca4){const _0xfb976=_0x21f6cf;if(_0x471ca4[_0xfb976(0x11c)]===null)return undefined;const _0x2407bc=this[_0xfb976(0xf2)][_0xfb976(0xbb)][_0xfb976(0xc3)](_0x471ca4[_0xfb976(0xf8)],_0x471ca4[_0xfb976(0x11c)]);if(_0x2407bc!==undefined&&_0x2407bc[_0xfb976(0xf8)]===_0x471ca4[_0xfb976(0xf8)]&&_0x2407bc[_0xfb976(0xeb)]===_0x471ca4[_0xfb976(0xeb)]&&_0x2407bc[_0xfb976(0x11c)]===_0x471ca4[_0xfb976(0x11c)])return _0x2407bc;return this[_0xfb976(0xde)](_0x471ca4);}[_0x21f6cf(0xde)](_0x161876){const _0x549c5e=_0x21f6cf;if(_0x161876[_0x549c5e(0x11c)]===null)return undefined;const _0x67693=this[_0x549c5e(0xf2)][_0x549c5e(0xbb)][_0x549c5e(0xc3)](_0x161876[_0x549c5e(0xf8)],_0x161876[_0x549c5e(0x11c)]);if(this[_0x549c5e(0xc5)](_0x67693,_0x161876,![]))return _0x67693;const _0xeeba5f=this[_0x549c5e(0xf2)][_0x549c5e(0xbc)][_0x549c5e(0xd9)](_0x161876[_0x549c5e(0xf8)])[_0x549c5e(0xf6)](_0x161876[_0x549c5e(0x11c)]),_0x2e9b52=_0xeeba5f===undefined?undefined:this[_0x549c5e(0xf2)][_0x549c5e(0xbb)][_0x549c5e(0xc6)](_0xeeba5f);return this[_0x549c5e(0xc5)](_0x2e9b52,_0x161876,!![])?_0x2e9b52:undefined;}[_0x21f6cf(0xef)](_0x125683){const _0x599039=_0x21f6cf,_0x5d27b6=new Set();if(_0x125683[_0x599039(0x11c)]!==null)_0x5d27b6[_0x599039(0x104)](_0x125683[_0x599039(0x11c)]);for(const _0x569d41 of this[_0x599039(0xf2)][_0x599039(0xbc)][_0x599039(0xd9)](_0x125683[_0x599039(0xf8)])[_0x599039(0xb7)](_0x125683['id']))_0x5d27b6[_0x599039(0x104)](_0x569d41);return _0x5d27b6;}[_0x21f6cf(0x106)](_0x2ef139,_0x5c7c46){const _0x13a83b=_0x21f6cf;if(_0x2ef139[_0x13a83b(0x11c)]===null)return;const _0x478b5b=new Set([_0x2ef139['id']]),_0x21aac3=new Set(_0x5c7c46),_0x3760d4=this[_0x13a83b(0xf2)][_0x13a83b(0xbc)][_0x13a83b(0xd9)](_0x2ef139[_0x13a83b(0xf8)]);for(const _0x270499 of _0x3760d4[_0x13a83b(0xb7)](_0x2ef139['id'])){const _0x4e7ff2=_0x3760d4[_0x13a83b(0xf6)](_0x270499);_0x4e7ff2!==undefined&&(_0x21aac3[_0x13a83b(0xc1)](_0x270499)||_0x4e7ff2===_0x2ef139['id'])&&(_0x478b5b[_0x13a83b(0x104)](_0x4e7ff2),_0x21aac3[_0x13a83b(0x104)](_0x270499),_0x3760d4[_0x13a83b(0x115)](_0x270499));}for(const [_0x1f38bb,_0x28b120]of this[_0x13a83b(0xf2)][_0x13a83b(0xcd)][_0x13a83b(0xb6)]){if(_0x28b120[_0x13a83b(0xf8)]===_0x2ef139[_0x13a83b(0xf8)]&&_0x28b120[_0x13a83b(0x103)]===_0x2ef139[_0x13a83b(0x103)]&&_0x28b120[_0x13a83b(0x11c)]!==null&&_0x21aac3[_0x13a83b(0xc1)](_0x28b120[_0x13a83b(0x11c)])){this[_0x13a83b(0xf2)][_0x13a83b(0xcd)][_0x13a83b(0xb6)][_0x13a83b(0xfc)](_0x1f38bb),this[_0x13a83b(0xf2)][_0x13a83b(0xcd)][_0x13a83b(0xe9)][_0x13a83b(0xfc)](_0x1f38bb),this[_0x13a83b(0xf2)][_0x13a83b(0xcd)][_0x13a83b(0x119)][_0x13a83b(0xfc)](_0x1f38bb),this[_0x13a83b(0xf2)][_0x13a83b(0xcd)][_0x13a83b(0xf9)][_0x13a83b(0xfc)](_0x1f38bb),this[_0x13a83b(0xf2)][_0x13a83b(0xcd)][_0x13a83b(0xd7)][_0x13a83b(0xfc)](_0x1f38bb),this[_0x13a83b(0xf2)][_0x13a83b(0xcd)][_0x13a83b(0xe0)][_0x13a83b(0xfc)](_0x1f38bb);const _0x59036a=this[_0x13a83b(0xf2)][_0x13a83b(0xcd)][_0x13a83b(0xf7)][_0x13a83b(0x10f)](_0x1f38bb);if(_0x59036a!==undefined)clearTimeout(_0x59036a);this[_0x13a83b(0xf2)][_0x13a83b(0xcd)][_0x13a83b(0xf7)][_0x13a83b(0xfc)](_0x1f38bb);}}for(const [_0x415c10,_0x1996b0]of this[_0x13a83b(0xf2)][_0x13a83b(0xcd)][_0x13a83b(0x119)])if(_0x478b5b[_0x13a83b(0xc1)](_0x1996b0))this[_0x13a83b(0xf2)][_0x13a83b(0xcd)][_0x13a83b(0x119)][_0x13a83b(0xfc)](_0x415c10);for(const _0xdabd73 of _0x478b5b){if(this[_0x13a83b(0xf2)][_0x13a83b(0xbb)][_0x13a83b(0xc6)](_0xdabd73)!==undefined)this[_0x13a83b(0xf2)][_0x13a83b(0xbb)][_0x13a83b(0x11f)](_0xdabd73);this[_0x13a83b(0xf2)][_0x13a83b(0xe2)][_0x13a83b(0x116)](_0xdabd73),this[_0x13a83b(0xf2)][_0x13a83b(0xcd)][_0x13a83b(0xe9)][_0x13a83b(0xfc)](_0xdabd73);}}[_0x21f6cf(0xc5)](_0x3064a6,_0x42b170,_0x1a630a){const _0xbc4e62=_0x21f6cf,_0x194eb7=_0x3064a6?.[_0xbc4e62(0x11c)]===_0x42b170[_0xbc4e62(0x11c)],_0x4aa0f5=_0x1a630a&&this[_0xbc4e62(0xf2)][_0xbc4e62(0xbc)][_0xbc4e62(0xd9)](_0x42b170[_0xbc4e62(0xf8)])[_0xbc4e62(0xf6)](_0x42b170[_0xbc4e62(0x11c)]??'')===_0x3064a6?.['id'];return _0x3064a6!==undefined&&_0x3064a6[_0xbc4e62(0xed)]===_0xbc4e62(0x10b)&&_0x3064a6[_0xbc4e62(0xf8)]===_0x42b170[_0xbc4e62(0xf8)]&&_0x3064a6[_0xbc4e62(0xeb)]===_0x42b170[_0xbc4e62(0xeb)]&&(_0x194eb7||_0x4aa0f5);}[_0x21f6cf(0xdb)](){const _0x118e98=_0x21f6cf,_0x55c67b=this[_0x118e98(0xf2)][_0x118e98(0xe6)]();if(_0x55c67b===undefined)throw new Error(_0x118e98(0xe3));return _0x55c67b;}}function _0x4e2c(_0x1996b0,_0xdabd73){_0x1996b0=_0x1996b0-(0x10c5+0x5*0x32b+-0x1fe6);const _0x3064a6=_0x2ddc();let _0x42b170=_0x3064a6[_0x1996b0];if(_0x4e2c['bxpOdv']===undefined){var _0x1a630a=function(_0x55c67b){const _0x24814f='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x21f682='',_0x295d83='';for(let _0x5a834f=-0x1*0x144d+-0x1893+0x2*0x1670,_0xb50069,_0x234e55,_0x11b26e=0x267c*-0x1+-0x9*0x9+0x3*0xcef;_0x234e55=_0x55c67b['charAt'](_0x11b26e++);~_0x234e55&&(_0xb50069=_0x5a834f%(-0x8ad+-0x691+0xf42)?_0xb50069*(-0xe*0x2a+-0x31*0xae+0x2c2*0xd)+_0x234e55:_0x234e55,_0x5a834f++%(-0x23f+0x8c9+-0x686))?_0x21f682+=String['fromCharCode'](0x1b78+0x2513+0xa6*-0x62&_0xb50069>>(-(0x1*-0x436+-0x21c4+-0x2*-0x12fe)*_0x5a834f&-0x1203*0x1+-0x1a2+0x35*0x5f)):-0x4f*0x31+0x2*0xa3f+0x7d*-0xb){_0x234e55=_0x24814f['indexOf'](_0x234e55);}for(let _0x3add4b=-0xe*-0x297+0x1*0x583+-0x11*0x275,_0x3a7320=_0x21f682['length'];_0x3add4b<_0x3a7320;_0x3add4b++){_0x295d83+='%'+('00'+_0x21f682['charCodeAt'](_0x3add4b)['toString'](-0x14f8+-0x26be+0x3bc6))['slice'](-(0x2540+0x1fe5+-0x4523*0x1));}return decodeURIComponent(_0x295d83);};_0x4e2c['xCeWkG']=_0x1a630a,_0x4e2c['rAfKDO']={},_0x4e2c['bxpOdv']=!![];}const _0x194eb7=_0x3064a6[-0x1*-0x64d+-0x71b+-0xce*-0x1];_0x4e2c['sAIscS']!==_0x194eb7&&(_0x4e2c['rAfKDO']={},_0x4e2c['sAIscS']=_0x194eb7);const _0x4aa0f5=_0x4e2c['rAfKDO'][_0x1996b0];return _0x4aa0f5===undefined?(_0x42b170=_0x4e2c['xCeWkG'](_0x42b170),_0x4e2c['rAfKDO'][_0x1996b0]=_0x42b170):_0x42b170=_0x4aa0f5,_0x42b170;}function _0x2ddc(){const _0x3e65b5=['zgLZy292zxjtzxnZAw9UCW','zM9Yz2v0','y2fWywjPBgL0AwvZ','y3jLyxrLqwDLBNrtzxnZAw9U','BgLZDfDVCMTZCgfJzxm','mtjwBKLoCK0','tufsx01btKfhruq','q1vtve9n','Cgf0Aa','zMLSDgvY','z2v0','CgLUBMvKqxq','qvvutW','z2v0tMf0AxzLu2vZC2LVBK1LDgfKyxrH','y29KzxG','DxbKyxrLqwDLBNrtzxnZAw9Uq29UzMLNDxjHDgLVBG','zM9Yz2v0tMf0AxzLqwXPyxm','CMvTB3zLu2vZC2LVBG','CNvUBMvYvgL0Bgu','ChjVzhvJDa','CMvZDw1Lzej5rgLYzwn0swq','BgfZDefJDgL2Axr5qxq','rvHurvjoquW','zxH0zxjUywXtzxnZAw9Uswq','uLvotKvsx1voqvzbsuXbqKXf','zgLZy292zxjdB2rLEa','CMvTB3zLqwDLBNrtzxnZAw9U','zgLYzwn0tMf0AxzL','BMf0AxzLqwXPyxnLC0zVCG','mJa4mtyXmZb0C2POqKC','zwzMB3j0','CMvTzw1Izxi','CNvUDgLTzq','CNvUBMvYCW','zMXHDa','ywnJzxnZ','mZuZnJu4Euvmsfrn','BgLZDa','AgfZ','y3vZDg9TvgL0Bgu','zMLUzefNzw50u2vZC2LVBKj5rxH0zxjUywXtzxnZAw9U','DgL0BgvpCMLNAw4','Axnnyw5Hz2vKuhjVAMvJDgLVBG','z2v0qwDLBNrtzxnZAw9U','zgvMyxvSDenVBMzPz3vYyxrPB24','mZe5mZu4nhjpyLv0sq','CgLUt3jKzxi','mJeYmZC2t1bgBgrc','ChjVAMvJDa','y3jLyxrLtwv0ywrHDgfqCM9Qzwn0Aw9U','C3rHDgu','ndq3mZe2mgfzDu9nAG','v09ss1nqqunfx05pvf9gt1vora','ChjVAMvJDgvKuNvUBMvYvgL0Bgu','ywXS','D29YA3nWywnL','BMfTzq','z2v0uNvUBMvYrgvMyxvSDhm','CMvZDw1LzenVBMzPz3vYyxrPB24','BgLZDfnLC3nPB25szwnVCMrZ','BwvZC2fNzvjLC3vTzuzHAwX1CMvZ','yxzHAwXHyMXL','CMvXDwLYzq','BwfW','CMvXDwLYzurHDgfIyxnL','uLvotKvs','zw5ZDxjLuMvZDw1LzenVBMzPz3vYyxrPB24','BwfUywDLzezVCK5HDgL2zq','CMvZB2X2zq','CMvZDw1LrMfPBhvYzurLDgfPBhm','zgLZy292zxjxB3jRC3bHy2u','y29TBwfUzhm','tK9erv9eqvrbqKftrv9vtKfwquLmqujmrq','DgL0Bgu','CMvZB2X2zun1CNjLBNq','zgf0ywjHC2u','ChjLC2vUDa','zMXHDe1HCa','zxH0zxjUywXby3rPDML0Eq','C2v0','D29YA3nWywnLswq','ow5tBffZsq','BMf0AxzLq29UDhjVBa','CMvUyw1L','BMf0AxzLswrZ','oda3otGYzMnwDvfP','ywr2zxj0AxnLza','B3b0Aw9UCW','mZm5mdG2meTewKrRAq','z2v0v29YA3nWywnL','zMLUza','BwfUywDLzefSAwfZswq','zMfPBhvYzvrPBwvYCW','CNvUBMvY','CMvZDw1LrMfPBhvYzxm','BM9KzuLK','C3rYAw5N','zgvSzxrL','zgLZy292zxi','ohHHBhDXqq','ChjVAMvJDgLVBKzVCK5HDgL2zq','Bwv0ywrHDge','Bw9KzwW','CMvUyw1LtMf0AxzL','y3DK','ywrK'];_0x2ddc=function(){return _0x3e65b5;};return _0x2ddc();}
|
|
1
|
+
import { deduplicateDirectSessions } from '../util/runner-native-session-parsers.js';
|
|
2
|
+
export class NativeSessionProjectionService {
|
|
3
|
+
options;
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this.options = options;
|
|
6
|
+
}
|
|
7
|
+
async discover(runnerName, workspaceId) {
|
|
8
|
+
const database = this.requireDatabase();
|
|
9
|
+
const workspace = workspaceId === undefined ? undefined : database.getWorkspace(workspaceId);
|
|
10
|
+
if (workspaceId !== undefined && workspace === undefined)
|
|
11
|
+
throw new Error('WORKSPACE_NOT_FOUND');
|
|
12
|
+
const runner = this.options.runners.product(runnerName);
|
|
13
|
+
if (runner === undefined || !runner.available(this.options.capabilities()))
|
|
14
|
+
throw new Error('RUNNER_UNAVAILABLE');
|
|
15
|
+
const sessions = await runner.discoverSessions({
|
|
16
|
+
workspaces: database.listWorkspaces(),
|
|
17
|
+
createProjection: (input) => this.project(input)
|
|
18
|
+
}, workspace);
|
|
19
|
+
const ordered = deduplicateDirectSessions(sessions);
|
|
20
|
+
this.remember(ordered);
|
|
21
|
+
return ordered;
|
|
22
|
+
}
|
|
23
|
+
async discoverCodex(workspaceId) {
|
|
24
|
+
const sessions = await this.discover('codex', workspaceId);
|
|
25
|
+
return { sessions: sessions.map(this.options.present) };
|
|
26
|
+
}
|
|
27
|
+
async list() {
|
|
28
|
+
const discovered = await Promise.all(this.options.runners
|
|
29
|
+
.advertised()
|
|
30
|
+
.filter((runner) => runner.available(this.options.capabilities()))
|
|
31
|
+
.map((runner) => this.discover(runner.name)));
|
|
32
|
+
const sessions = deduplicateDirectSessions(discovered.flat());
|
|
33
|
+
this.remember(sessions);
|
|
34
|
+
return sessions.map(this.options.present);
|
|
35
|
+
}
|
|
36
|
+
async discoverWorkspace(workspaceId) {
|
|
37
|
+
const discovered = await Promise.all(this.options.runners
|
|
38
|
+
.advertised()
|
|
39
|
+
.filter((runner) => runner.available(this.options.capabilities()))
|
|
40
|
+
.map((runner) => this.discover(runner.name, workspaceId)));
|
|
41
|
+
const sessions = deduplicateDirectSessions(discovered.flat());
|
|
42
|
+
this.remember(sessions);
|
|
43
|
+
return sessions;
|
|
44
|
+
}
|
|
45
|
+
async resolve(sessionId) {
|
|
46
|
+
const cached = this.options.state.directNative.get(sessionId);
|
|
47
|
+
if (cached !== undefined)
|
|
48
|
+
return cached;
|
|
49
|
+
const discovered = (await this.list()).find((session) => session.id === sessionId);
|
|
50
|
+
if (discovered !== undefined)
|
|
51
|
+
return discovered;
|
|
52
|
+
const database = this.options.database();
|
|
53
|
+
const record = database
|
|
54
|
+
?.listWorkspaces()
|
|
55
|
+
.flatMap((workspace) => database.listSessionRecords(workspace.id))
|
|
56
|
+
.find((candidate) => candidate.id === sessionId);
|
|
57
|
+
if (record === undefined)
|
|
58
|
+
return undefined;
|
|
59
|
+
const workspace = database?.getWorkspace(record.workspaceId);
|
|
60
|
+
if (workspace === undefined)
|
|
61
|
+
return undefined;
|
|
62
|
+
return {
|
|
63
|
+
id: record.id,
|
|
64
|
+
nodeId: this.options.nodeId(),
|
|
65
|
+
workspaceId: record.workspaceId,
|
|
66
|
+
runner: record.runner,
|
|
67
|
+
externalSessionId: record.id,
|
|
68
|
+
nativeControl: 'EXTERNAL',
|
|
69
|
+
channelToken: null,
|
|
70
|
+
cwd: workspace.path,
|
|
71
|
+
model: record.metadata.model,
|
|
72
|
+
effort: record.metadata.effort,
|
|
73
|
+
access: record.metadata.access,
|
|
74
|
+
customTitle: record.metadata.customTitle,
|
|
75
|
+
runnerTitle: record.metadata.runnerTitle,
|
|
76
|
+
pinnedAt: record.pinOrder === null ? null : 1,
|
|
77
|
+
pinOrder: record.pinOrder,
|
|
78
|
+
externalDiscovered: false,
|
|
79
|
+
titleSource: record.metadata.customTitle === null ? 'RUNNER' : 'CUSTOM',
|
|
80
|
+
lastActivityAt: 0,
|
|
81
|
+
createdAt: 0
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async resolveCurrent(sessionId) {
|
|
85
|
+
const direct = await this.resolve(sessionId);
|
|
86
|
+
return direct === undefined ? undefined : (this.projectionForNative(direct) ?? direct);
|
|
87
|
+
}
|
|
88
|
+
async createMetadataProjection(sessionId) {
|
|
89
|
+
const direct = await this.resolve(sessionId);
|
|
90
|
+
if (direct === undefined || direct.externalSessionId === null)
|
|
91
|
+
return undefined;
|
|
92
|
+
const existing = this.options.runtime.findAgentSessionByExternalSession(direct.runner, direct.externalSessionId);
|
|
93
|
+
if (existing !== undefined && existing.workspaceId === direct.workspaceId)
|
|
94
|
+
return existing;
|
|
95
|
+
return this.options.runtime.createAgentSession({
|
|
96
|
+
workspaceId: direct.workspaceId,
|
|
97
|
+
runner: direct.runner,
|
|
98
|
+
externalSessionId: direct.externalSessionId,
|
|
99
|
+
nativeControl: 'EXTERNAL',
|
|
100
|
+
cwd: direct.cwd,
|
|
101
|
+
...(direct.runnerTitle === null ? {} : { title: direct.runnerTitle }),
|
|
102
|
+
...(direct.customTitle === null ? {} : { customTitle: direct.customTitle })
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
resumedConfiguration(session) {
|
|
106
|
+
const workspace = this.options.database()?.getWorkspace(session.workspaceId);
|
|
107
|
+
const current = {
|
|
108
|
+
runner: session.runner,
|
|
109
|
+
model: session.model,
|
|
110
|
+
effort: session.effort,
|
|
111
|
+
access: session.access
|
|
112
|
+
};
|
|
113
|
+
if (typeof current.model === 'string' &&
|
|
114
|
+
typeof current.effort === 'string' &&
|
|
115
|
+
typeof current.access === 'string')
|
|
116
|
+
return current;
|
|
117
|
+
const saved = this.options
|
|
118
|
+
.database()
|
|
119
|
+
?.getRunnerDefaults()
|
|
120
|
+
.find((value) => value.runner === session.runner);
|
|
121
|
+
return saved ?? this.options.runners.require(session.runner).defaultConfiguration(workspace);
|
|
122
|
+
}
|
|
123
|
+
ensureResumedConfiguration(session) {
|
|
124
|
+
const configuration = this.resumedConfiguration(session);
|
|
125
|
+
if (session.model === configuration.model &&
|
|
126
|
+
session.effort === configuration.effort &&
|
|
127
|
+
session.access === configuration.access)
|
|
128
|
+
return session;
|
|
129
|
+
return this.options.runtime.updateAgentSessionConfiguration({
|
|
130
|
+
sessionId: session.id,
|
|
131
|
+
model: configuration.model,
|
|
132
|
+
effort: configuration.effort,
|
|
133
|
+
access: configuration.access
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
async rename(session, input) {
|
|
137
|
+
if (session.externalSessionId === null)
|
|
138
|
+
return;
|
|
139
|
+
await this.options.runners
|
|
140
|
+
.require(session.runner)
|
|
141
|
+
.renameNative(session, input, this.requireDatabase());
|
|
142
|
+
}
|
|
143
|
+
project(input) {
|
|
144
|
+
const timestamp = input.lastActivityAt ?? 0;
|
|
145
|
+
const database = this.options.database();
|
|
146
|
+
const metadata = database?.getNativeSessionMetadata(input.runner, input.externalSessionId, input.workspace.id);
|
|
147
|
+
const runnerTitle = this.options.runners.require(input.runner).projectedRunnerTitle(metadata, {
|
|
148
|
+
externalSessionId: input.externalSessionId,
|
|
149
|
+
workspaceId: input.workspace.id,
|
|
150
|
+
...(input.title === undefined ? {} : { title: input.title }),
|
|
151
|
+
...(input.titleOrigin === undefined ? {} : { titleOrigin: input.titleOrigin })
|
|
152
|
+
}, database);
|
|
153
|
+
return {
|
|
154
|
+
id: input.externalSessionId,
|
|
155
|
+
nodeId: this.options.nodeId(),
|
|
156
|
+
workspaceId: input.workspace.id,
|
|
157
|
+
runner: input.runner,
|
|
158
|
+
externalSessionId: input.externalSessionId,
|
|
159
|
+
nativeControl: 'EXTERNAL',
|
|
160
|
+
channelToken: null,
|
|
161
|
+
cwd: input.cwd,
|
|
162
|
+
model: metadata?.model ?? null,
|
|
163
|
+
effort: metadata?.effort ?? null,
|
|
164
|
+
access: metadata?.access ?? null,
|
|
165
|
+
customTitle: metadata?.customTitle ?? null,
|
|
166
|
+
runnerTitle,
|
|
167
|
+
pinnedAt: metadata?.pinnedAt ?? null,
|
|
168
|
+
pinOrder: metadata?.pinOrder ?? null,
|
|
169
|
+
externalDiscovered: true,
|
|
170
|
+
titleSource: metadata?.customTitle === null || metadata?.customTitle === undefined
|
|
171
|
+
? runnerTitle === null
|
|
172
|
+
? 'AUTO'
|
|
173
|
+
: 'RUNNER'
|
|
174
|
+
: 'CUSTOM',
|
|
175
|
+
lastActivityAt: timestamp,
|
|
176
|
+
createdAt: timestamp
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
remember(sessions) {
|
|
180
|
+
for (const session of sessions)
|
|
181
|
+
this.options.state.directNative.set(session.id, session);
|
|
182
|
+
}
|
|
183
|
+
projectionForNative(native) {
|
|
184
|
+
if (native.externalSessionId === null)
|
|
185
|
+
return undefined;
|
|
186
|
+
const exact = this.options.runtime.findAgentSessionByExternalSession(native.runner, native.externalSessionId);
|
|
187
|
+
if (exact !== undefined &&
|
|
188
|
+
exact.runner === native.runner &&
|
|
189
|
+
exact.workspaceId === native.workspaceId &&
|
|
190
|
+
exact.externalSessionId === native.externalSessionId)
|
|
191
|
+
return exact;
|
|
192
|
+
return this.managedForNative(native);
|
|
193
|
+
}
|
|
194
|
+
managedForNative(native) {
|
|
195
|
+
if (native.externalSessionId === null)
|
|
196
|
+
return undefined;
|
|
197
|
+
const exact = this.options.runtime.findAgentSessionByExternalSession(native.runner, native.externalSessionId);
|
|
198
|
+
if (this.isManagedProjection(exact, native, false))
|
|
199
|
+
return exact;
|
|
200
|
+
const aliasId = this.options.runners
|
|
201
|
+
.require(native.runner)
|
|
202
|
+
.managedAliasId(native.externalSessionId);
|
|
203
|
+
const alias = aliasId === undefined ? undefined : this.options.runtime.getAgentSession(aliasId);
|
|
204
|
+
return this.isManagedProjection(alias, native, true) ? alias : undefined;
|
|
205
|
+
}
|
|
206
|
+
nativeIds(session) {
|
|
207
|
+
const ids = new Set();
|
|
208
|
+
if (session.externalSessionId !== null)
|
|
209
|
+
ids.add(session.externalSessionId);
|
|
210
|
+
for (const nativeId of this.options.runners
|
|
211
|
+
.require(session.runner)
|
|
212
|
+
.nativeAliasesFor(session.id))
|
|
213
|
+
ids.add(nativeId);
|
|
214
|
+
return ids;
|
|
215
|
+
}
|
|
216
|
+
forget(session, knownNativeIds) {
|
|
217
|
+
if (session.externalSessionId === null)
|
|
218
|
+
return;
|
|
219
|
+
const projectionIds = new Set([session.id]);
|
|
220
|
+
const nativeIds = new Set(knownNativeIds);
|
|
221
|
+
const runner = this.options.runners.require(session.runner);
|
|
222
|
+
for (const nativeId of runner.nativeAliasesFor(session.id)) {
|
|
223
|
+
const managedId = runner.managedAliasId(nativeId);
|
|
224
|
+
if (managedId !== undefined && (nativeIds.has(nativeId) || managedId === session.id)) {
|
|
225
|
+
projectionIds.add(managedId);
|
|
226
|
+
nativeIds.add(nativeId);
|
|
227
|
+
runner.forgetNativeAlias(nativeId);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
for (const [directId, direct] of this.options.state.directNative) {
|
|
231
|
+
if (direct.runner === session.runner &&
|
|
232
|
+
direct.cwd === session.cwd &&
|
|
233
|
+
direct.externalSessionId !== null &&
|
|
234
|
+
nativeIds.has(direct.externalSessionId)) {
|
|
235
|
+
this.options.state.directNative.delete(directId);
|
|
236
|
+
this.options.state.externalActivity.delete(directId);
|
|
237
|
+
this.options.state.resumedByDirectId.delete(directId);
|
|
238
|
+
this.options.state.resumeFailures.delete(directId);
|
|
239
|
+
this.options.state.messageResumeFailures.delete(directId);
|
|
240
|
+
this.options.state.resumeFailureDetails.delete(directId);
|
|
241
|
+
const timer = this.options.state.failureTimers.get(directId);
|
|
242
|
+
if (timer !== undefined)
|
|
243
|
+
clearTimeout(timer);
|
|
244
|
+
this.options.state.failureTimers.delete(directId);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
for (const [directId, resumedId] of this.options.state.resumedByDirectId)
|
|
248
|
+
if (projectionIds.has(resumedId))
|
|
249
|
+
this.options.state.resumedByDirectId.delete(directId);
|
|
250
|
+
for (const projectionId of projectionIds) {
|
|
251
|
+
if (this.options.runtime.getAgentSession(projectionId) !== undefined)
|
|
252
|
+
this.options.runtime.removeAgentSession(projectionId);
|
|
253
|
+
this.options.commands.removeSession(projectionId);
|
|
254
|
+
this.options.state.externalActivity.delete(projectionId);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
isManagedProjection(candidate, native, allowAlias) {
|
|
258
|
+
const exactNativeId = candidate?.externalSessionId === native.externalSessionId;
|
|
259
|
+
const verifiedAlias = allowAlias &&
|
|
260
|
+
this.options.runners.require(native.runner).managedAliasId(native.externalSessionId ?? '') ===
|
|
261
|
+
candidate?.id;
|
|
262
|
+
return (candidate !== undefined &&
|
|
263
|
+
candidate.nativeControl === 'MAR_MANAGED' &&
|
|
264
|
+
candidate.runner === native.runner &&
|
|
265
|
+
candidate.workspaceId === native.workspaceId &&
|
|
266
|
+
(exactNativeId || verifiedAlias));
|
|
267
|
+
}
|
|
268
|
+
requireDatabase() {
|
|
269
|
+
const database = this.options.database();
|
|
270
|
+
if (database === undefined)
|
|
271
|
+
throw new Error('NODE_DATABASE_UNAVAILABLE');
|
|
272
|
+
return database;
|
|
273
|
+
}
|
|
274
|
+
}
|