@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,588 @@
|
|
|
1
|
-
|
|
2
|
-
const _0x195185=_0x48c8;(function(_0x4534bf,_0xa78ba7){const _0x39b582=_0x48c8,_0x46dcc9=_0x4534bf();while(!![]){try{const _0x2cffb4=parseInt(_0x39b582(0x8e))/(-0x5ab*0x3+0x302+-0x2*-0x700)*(parseInt(_0x39b582(0x69))/(-0x1331+0xd9*0xd+0x82e))+-parseInt(_0x39b582(0x7f))/(0x118d*-0x1+-0xcba+-0x2*-0xf25)+parseInt(_0x39b582(0x81))/(0x1823*0x1+-0x2654*0x1+-0x1*-0xe35)+parseInt(_0x39b582(0x96))/(-0x1a7+0x1489*0x1+-0x12dd)*(parseInt(_0x39b582(0xc0))/(-0x221c+-0x1125+-0x1*-0x3347))+-parseInt(_0x39b582(0x110))/(0x1d3f*-0x1+0x1*-0xf6c+0x2cb2)+-parseInt(_0x39b582(0x128))/(0x6*0x4cf+0x3dd*0x1+-0x20af)*(parseInt(_0x39b582(0xac))/(-0x16*-0x86+-0x8b*0x32+0xfab))+-parseInt(_0x39b582(0xc3))/(0x2ab*-0x4+-0x1*-0x1f91+-0x13*0x119)*(-parseInt(_0x39b582(0x107))/(0x1ca1+-0x1*-0x1319+-0x2faf));if(_0x2cffb4===_0xa78ba7)break;else _0x46dcc9['push'](_0x46dcc9['shift']());}catch(_0x183027){_0x46dcc9['push'](_0x46dcc9['shift']());}}}(_0x4360,-0xef*0x88a+0xa443b+0x29*0x315a));import{parseSecretEnvironment}from'../../util/secret-environment.js';import{runnerErrorProjection}from'../../util/runner-error.js';import{boundedConversationItemId,compactRunnerText}from'../codex/conversation-parser.js';import{openCodePatchToolPayload,openCodeQuestions}from'./conversation-parser.js';import{normalizeOpenCodeTool}from'./tool-normalizer.js';function _0x48c8(_0x1223e1,_0x43b9c1){_0x1223e1=_0x1223e1-(0x6a1*0x1+0x186d+-0x1ea8);const _0x3a0196=_0x4360();let _0x17d6e4=_0x3a0196[_0x1223e1];if(_0x48c8['liZrrR']===undefined){var _0x1dd52c=function(_0x4524d5){const _0x4fe7e5='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x546179='',_0x74bac4='';for(let _0x5720da=0x19a4+0x2b*-0x78+-0x57c,_0x1909f6,_0x65b5a5,_0x415068=-0x8*0x2f9+-0x22*-0x121+-0xe9a;_0x65b5a5=_0x4524d5['charAt'](_0x415068++);~_0x65b5a5&&(_0x1909f6=_0x5720da%(0x92*-0x10+-0x6*0xca+0x4a*0x30)?_0x1909f6*(0x1*-0x248f+-0x13a2+0x1*0x3871)+_0x65b5a5:_0x65b5a5,_0x5720da++%(-0xae*0x2e+-0x173b*0x1+-0x3683*-0x1))?_0x546179+=String['fromCharCode'](0x20d9+-0x237*-0x7+-0x2f5b&_0x1909f6>>(-(-0x2a5+0xf83+-0xcdc)*_0x5720da&-0x74+-0x79a*-0x3+0x2*-0xb2a)):0x3*-0x989+0x1dc5+-0x12a){_0x65b5a5=_0x4fe7e5['indexOf'](_0x65b5a5);}for(let _0x49bdf2=0x10f*0x14+-0xe08*0x2+0x6e4,_0x326a46=_0x546179['length'];_0x49bdf2<_0x326a46;_0x49bdf2++){_0x74bac4+='%'+('00'+_0x546179['charCodeAt'](_0x49bdf2)['toString'](0x10a3*0x1+-0x201e+0xad*0x17))['slice'](-(0x18ec+0x1540+-0x2e2a));}return decodeURIComponent(_0x74bac4);};_0x48c8['MFqsYV']=_0x1dd52c,_0x48c8['dXLhBp']={},_0x48c8['liZrrR']=!![];}const _0x3c5025=_0x3a0196[0x11d5*-0x2+-0x13b2+0x375c];_0x48c8['MzyNZs']!==_0x3c5025&&(_0x48c8['dXLhBp']={},_0x48c8['MzyNZs']=_0x3c5025);const _0x5eeb4b=_0x48c8['dXLhBp'][_0x1223e1];return _0x5eeb4b===undefined?(_0x17d6e4=_0x48c8['MFqsYV'](_0x17d6e4),_0x48c8['dXLhBp'][_0x1223e1]=_0x17d6e4):_0x17d6e4=_0x5eeb4b,_0x17d6e4;}export class OpenCodeManagedRunController{[_0x195185(0xdb)];[_0x195185(0x6d)];[_0x195185(0xb5)];[_0x195185(0xa0)]=new Map();[_0x195185(0x12b)]=new Map();[_0x195185(0xe9)]=new Map();[_0x195185(0x114)]=new Set();[_0x195185(0x93)]=new Set();[_0x195185(0x87)]=new Map();[_0x195185(0xfa)]=new Map();[_0x195185(0xf4)]=new Map();[_0x195185(0x7e)]=new Map();[_0x195185(0xc6)]=new Map();constructor(_0x1223e1,_0x43b9c1,_0x3a0196=(0x11e5+0xd64*-0x1+-0x477)*(0x47f2+-0xce82+0x170f0)){const _0x43b428=_0x195185;this[_0x43b428(0xdb)]=_0x1223e1,this[_0x43b428(0x6d)]=_0x43b9c1,this[_0x43b428(0xb5)]=_0x3a0196;}async[_0x195185(0xfd)](_0x17d6e4,_0x1dd52c,_0x3c5025){const _0x5be706=_0x195185;if(_0x1dd52c['id']===_0x5be706(0xba))return this[_0x5be706(0xba)](_0x17d6e4,_0x3c5025[_0x5be706(0xbf)],_0x3c5025[_0x5be706(0xc4)]);if(_0x1dd52c['id']!==_0x5be706(0xe4))throw new Error(_0x5be706(0xf9));const _0x5eeb4b=this[_0x5be706(0x6d)][_0x5be706(0xae)](_0x17d6e4['id'],_0x5be706(0xe4));if(_0x5eeb4b?.[_0x5be706(0xad)])this[_0x5be706(0x6d)][_0x5be706(0x82)](_0x17d6e4['id'],_0x5be706(0xe4));else this[_0x5be706(0x6d)][_0x5be706(0x111)](_0x17d6e4['id'],{'commandId':_0x5be706(0xe4),'active':!![],'label':_0x5be706(0x77),'detail':_0x5be706(0x11f),'closable':!![],'closeInput':_0x5be706(0xbd),'continuation':{'label':_0x5be706(0x8d),'prompt':_0x5be706(0xc1)}});return{'command':_0x1dd52c['id'],'states':this[_0x5be706(0x6d)][_0x5be706(0x10d)](_0x17d6e4['id'])};}[_0x195185(0xba)](_0x4524d5,_0x4fe7e5,_0x546179){const _0x1afe2a=_0x195185;if(_0x4524d5[_0x1afe2a(0xcc)]===null||_0x4524d5[_0x1afe2a(0xbe)]===null||_0x4524d5[_0x1afe2a(0xa5)]!==_0x1afe2a(0x117)||this[_0x1afe2a(0x6d)][_0x1afe2a(0x124)](_0x4524d5['id']))throw new Error(_0x1afe2a(0xf9));const _0x74bac4=crypto[_0x1afe2a(0x7a)](),_0x5720da=this[_0x1afe2a(0xdb)][_0x1afe2a(0xed)](_0x4fe7e5);return this[_0x1afe2a(0x6d)][_0x1afe2a(0x8f)]({'runId':_0x74bac4,'sessionId':_0x4524d5['id'],'runner':_0x1afe2a(0x126),'cwd':_0x4524d5[_0x1afe2a(0x85)],'externalSessionId':_0x4524d5[_0x1afe2a(0xcc)],..._0x546179===undefined?{}:{'initiatedByUserId':_0x546179}}),this[_0x1afe2a(0x6d)][_0x1afe2a(0xad)][_0x1afe2a(0x83)](_0x74bac4),this[_0x1afe2a(0xdb)][_0x1afe2a(0xb9)][_0x1afe2a(0xe6)](_0x74bac4,{'runId':_0x74bac4,'sessionId':_0x4524d5['id'],'nativeSessionId':_0x4524d5[_0x1afe2a(0xcc)],'cwd':_0x4524d5[_0x1afe2a(0x85)],'client':_0x5720da,'abort':new AbortController(),'access':_0x4524d5[_0x1afe2a(0x12f)]??_0x1afe2a(0xc8),'agent':_0x1afe2a(0xbc)}),this[_0x1afe2a(0x6d)][_0x1afe2a(0xf3)](_0x74bac4,_0x1afe2a(0xcf),{'command':_0x1afe2a(0xba)},_0x1afe2a(0xfe)),this[_0x1afe2a(0x6d)][_0x1afe2a(0x6e)](_0x74bac4,openCodeCompactionItem(_0x1afe2a(0xc2),_0x74bac4,![])),void this[_0x1afe2a(0xe2)](_0x74bac4,_0x4524d5[_0x1afe2a(0xbe)]),{'command':_0x1afe2a(0xba),'run':this[_0x1afe2a(0x6d)][_0x1afe2a(0x91)](_0x74bac4),'states':this[_0x1afe2a(0x6d)][_0x1afe2a(0x10d)](_0x4524d5['id'])};}async[_0x195185(0xe2)](_0x1909f6,_0x65b5a5){const _0x451df3=_0x195185,_0x415068=this[_0x451df3(0xdb)][_0x451df3(0xb9)][_0x451df3(0x127)](_0x1909f6);if(_0x415068===undefined)return;this[_0x451df3(0x6d)][_0x451df3(0xf3)](_0x1909f6,_0x451df3(0x86),{'command':_0x451df3(0xba)},_0x451df3(0xd8));try{await _0x415068[_0x451df3(0xd4)][_0x451df3(0x9e)](_0x415068[_0x451df3(0x85)],_0x415068[_0x451df3(0xe0)],_0x65b5a5),this[_0x451df3(0x6d)][_0x451df3(0x6e)](_0x1909f6,openCodeCompactionItem(_0x451df3(0xc2),_0x1909f6,!![])),this[_0x451df3(0x9c)](_0x1909f6,_0x451df3(0x101),_0x451df3(0x121),{'status':_0x451df3(0x101)});}catch(_0x49bdf2){this[_0x451df3(0x9c)](_0x1909f6,_0x451df3(0x90),_0x451df3(0x132),_0x49bdf2,_0x451df3(0xfc));}}[_0x195185(0x78)](_0x326a46){const _0x1cc06a=_0x195185,_0x42e54c=_0x326a46[_0x1cc06a(0x104)];if(_0x42e54c[_0x1cc06a(0xdb)]!==_0x1cc06a(0x126)||typeof _0x42e54c[_0x1cc06a(0x123)]!==_0x1cc06a(0x11e)||typeof _0x42e54c[_0x1cc06a(0xd5)]!==_0x1cc06a(0x11e)||typeof _0x42e54c[_0x1cc06a(0xf1)]!==_0x1cc06a(0x11e)||typeof _0x42e54c[_0x1cc06a(0x85)]!==_0x1cc06a(0x11e)||typeof _0x42e54c[_0x1cc06a(0xbe)]!==_0x1cc06a(0x11e)||this[_0x1cc06a(0x6d)][_0x1cc06a(0x92)]()||this[_0x1cc06a(0x6d)][_0x1cc06a(0xad)][_0x1cc06a(0xa2)](_0x42e54c[_0x1cc06a(0x123)]))return;let _0x34cd1e,_0x12bc7e,_0x1200d4,_0x8e6639;try{_0x34cd1e=parseSecretEnvironment(_0x42e54c[_0x1cc06a(0xbf)]),_0x12bc7e=parseSecretEnvironment(_0x42e54c[_0x1cc06a(0xb7)]),_0x1200d4=this[_0x1cc06a(0xdb)][_0x1cc06a(0x122)](_0x42e54c[_0x1cc06a(0x11c)],{..._0x34cd1e,..._0x12bc7e}),_0x8e6639=this[_0x1cc06a(0x6d)][_0x1cc06a(0x9f)](_0x42e54c[_0x1cc06a(0x120)]);}catch(_0x27887c){const _0x34f1cf=runnerErrorProjection(_0x27887c,_0x1cc06a(0xd2));this[_0x1cc06a(0x6d)][_0x1cc06a(0x6e)](_0x42e54c[_0x1cc06a(0x123)],{'itemId':boundedConversationItemId(_0x1cc06a(0xc7),_0x42e54c[_0x1cc06a(0x123)]),'kind':_0x1cc06a(0xd9),'status':_0x1cc06a(0x90),'payload':{..._0x34f1cf,'recoverable':!![],'retryAfterMs':null}}),this[_0x1cc06a(0x6d)][_0x1cc06a(0xf3)](_0x42e54c[_0x1cc06a(0x123)],_0x1cc06a(0xfb),_0x34f1cf,_0x1cc06a(0x90));return;}void this[_0x1cc06a(0x91)]({'runId':_0x42e54c[_0x1cc06a(0x123)],'sessionId':_0x42e54c[_0x1cc06a(0xd5)],'input':_0x42e54c[_0x1cc06a(0xf1)],'cwd':_0x42e54c[_0x1cc06a(0x85)],'model':_0x42e54c[_0x1cc06a(0xbe)],'effort':typeof _0x42e54c[_0x1cc06a(0x67)]===_0x1cc06a(0x11e)?_0x42e54c[_0x1cc06a(0x67)]:'',...typeof _0x42e54c[_0x1cc06a(0xcc)]===_0x1cc06a(0x11e)?{'externalSessionId':_0x42e54c[_0x1cc06a(0xcc)]}:{},'environment':_0x34cd1e,'attachments':_0x8e6639,'access':typeof _0x42e54c[_0x1cc06a(0x12f)]===_0x1cc06a(0x11e)?_0x42e54c[_0x1cc06a(0x12f)]:_0x1cc06a(0xc8),'agent':_0x42e54c[_0x1cc06a(0x98)]===_0x1cc06a(0xe4)?_0x1cc06a(0xe4):_0x1cc06a(0xbc),...typeof _0x42e54c[_0x1cc06a(0x9d)]===_0x1cc06a(0x11e)?{'personalInstructions':_0x42e54c[_0x1cc06a(0x9d)]}:{},'mcp':_0x1200d4});}[_0x195185(0xdc)](_0x5e0cbb,_0x33817b){const _0x5cc4bf=_0x195185,_0x5dcf70=this[_0x5cc4bf(0xdb)][_0x5cc4bf(0xb9)][_0x5cc4bf(0x127)](_0x5e0cbb);if(_0x5dcf70===undefined)return![];return void _0x5dcf70[_0x5cc4bf(0xd4)][_0x5cc4bf(0x9a)](_0x5dcf70[_0x5cc4bf(0x85)],_0x5dcf70[_0x5cc4bf(0xe0)])[_0x5cc4bf(0xd6)](()=>{const _0x30a2a1=_0x5cc4bf;this[_0x30a2a1(0x9c)](_0x5e0cbb,_0x33817b===_0x30a2a1(0xc9)?_0x30a2a1(0x80):_0x30a2a1(0x103),_0x30a2a1(0x121),{'status':_0x33817b===_0x30a2a1(0xc9)?_0x30a2a1(0x80):_0x30a2a1(0x103)});}),!![];}[_0x195185(0xe7)](_0x11a6be){const _0x5d7e9d=_0x195185,_0x4d9d26=this[_0x5d7e9d(0xa0)][_0x5d7e9d(0x127)](_0x11a6be[_0x5d7e9d(0xf7)]);if(_0x4d9d26===undefined||_0x4d9d26[_0x5d7e9d(0x123)]!==_0x11a6be[_0x5d7e9d(0x123)])return![];return clearTimeout(_0x4d9d26[_0x5d7e9d(0x6b)]),this[_0x5d7e9d(0xa0)][_0x5d7e9d(0x116)](_0x11a6be[_0x5d7e9d(0xf7)]),void _0x4d9d26[_0x5d7e9d(0xd4)][_0x5d7e9d(0xb6)](_0x4d9d26[_0x5d7e9d(0x85)],_0x4d9d26[_0x5d7e9d(0x66)],_0x11a6be[_0x5d7e9d(0xda)]),!![];}[_0x195185(0x115)](_0x5a0097,_0x36bd32,_0x153843){const _0x16cab2=_0x195185,_0x1c0f26=this[_0x16cab2(0x12b)][_0x16cab2(0x127)](_0x36bd32);if(_0x1c0f26===undefined||_0x1c0f26[_0x16cab2(0x123)]!==_0x5a0097)return![];const _0x5ae8f8=_0x1c0f26[_0x16cab2(0x100)][_0x16cab2(0x6a)](_0x59d708=>{const _0x446ad7=_0x16cab2,_0x2e5987=_0x153843[_0x59d708],_0x415d31=Array[_0x446ad7(0xab)](_0x2e5987)?_0x2e5987:typeof _0x2e5987===_0x446ad7(0x11e)?[_0x2e5987]:[];if(_0x415d31[_0x446ad7(0x72)]===-0x11*-0xd1+0x7b5*0x3+-0x2500||_0x415d31[_0x446ad7(0x72)]>-0xe*0x167+0x1*0x251+0x1159||_0x415d31[_0x446ad7(0x12a)](_0x5c3ace=>typeof _0x5c3ace!==_0x446ad7(0x11e)||_0x5c3ace[_0x446ad7(0x72)]===-0x173b+-0x637*-0x2+-0xacd*-0x1||_0x5c3ace[_0x446ad7(0x72)]>0x20d9+-0x237*-0x7+-0x2e66))throw new Error(_0x446ad7(0x7d));return _0x415d31;});return clearTimeout(_0x1c0f26[_0x16cab2(0x6b)]),this[_0x16cab2(0x12b)][_0x16cab2(0x116)](_0x36bd32),void _0x1c0f26[_0x16cab2(0xd4)][_0x16cab2(0x68)](_0x1c0f26[_0x16cab2(0x85)],_0x1c0f26[_0x16cab2(0x66)],_0x5ae8f8),this[_0x16cab2(0x6d)][_0x16cab2(0x6e)](_0x5a0097,{'itemId':boundedConversationItemId(_0x16cab2(0xea),_0x36bd32),'kind':_0x16cab2(0xa3),'status':_0x16cab2(0x8c),'payload':{},'merge':!![]}),!![];}async[_0x195185(0x91)](_0x434670){const _0x105fed=_0x195185,_0x18c669=this[_0x105fed(0xdb)][_0x105fed(0xed)](_0x434670[_0x105fed(0x8a)],hasMcpConfiguration(_0x434670[_0x105fed(0x94)])?_0x434670[_0x105fed(0x123)]:undefined);this[_0x105fed(0xc6)][_0x105fed(0xe6)](_0x434670[_0x105fed(0x123)],_0x18c669),this[_0x105fed(0xe9)][_0x105fed(0xe6)](_0x434670[_0x105fed(0x123)],_0x434670[_0x105fed(0x85)]),this[_0x105fed(0x6d)][_0x105fed(0xad)][_0x105fed(0x83)](_0x434670[_0x105fed(0x123)]),this[_0x105fed(0x6d)][_0x105fed(0xf3)](_0x434670[_0x105fed(0x123)],_0x105fed(0xcf),{},_0x105fed(0xfe));try{if(hasMcpConfiguration(_0x434670[_0x105fed(0x94)]))await _0x18c669[_0x105fed(0xef)](_0x434670[_0x105fed(0x85)],_0x434670[_0x105fed(0x94)]);const _0x394134=_0x434670[_0x105fed(0xcc)]??openCodeSessionId(await _0x18c669[_0x105fed(0x89)](_0x434670[_0x105fed(0x85)]));if(_0x394134===undefined)throw new Error(_0x105fed(0x79));this[_0x105fed(0x6d)][_0x105fed(0x8f)]({'runId':_0x434670[_0x105fed(0x123)],'sessionId':_0x434670[_0x105fed(0xd5)],'runner':_0x105fed(0x126),'cwd':_0x434670[_0x105fed(0x85)],'externalSessionId':_0x394134}),this[_0x105fed(0x6d)][_0x105fed(0xb2)](_0x394134,_0x434670[_0x105fed(0xd5)]);_0x434670[_0x105fed(0xcc)]===undefined&&(this[_0x105fed(0x6d)][_0x105fed(0x10a)](_0x434670[_0x105fed(0xd5)],_0x394134),this[_0x105fed(0x6d)][_0x105fed(0x129)](_0x105fed(0x125),{'sessionId':_0x434670[_0x105fed(0xd5)],'externalSessionId':_0x394134}));const _0x27ba15=new AbortController();this[_0x105fed(0xdb)][_0x105fed(0xb9)][_0x105fed(0xe6)](_0x434670[_0x105fed(0x123)],{'runId':_0x434670[_0x105fed(0x123)],'sessionId':_0x434670[_0x105fed(0xd5)],'nativeSessionId':_0x394134,'cwd':_0x434670[_0x105fed(0x85)],'client':_0x18c669,'abort':_0x27ba15,'access':_0x434670[_0x105fed(0x12f)],'agent':_0x434670[_0x105fed(0xf2)]});let _0x3ddb62=![],_0x17f272,_0x312b17;const _0x48ab94=new Promise((_0x1414c5,_0x494038)=>{_0x17f272=()=>{_0x3ddb62=!![],_0x1414c5();},_0x312b17=_0x494038;});void _0x18c669[_0x105fed(0x74)](_0x434670[_0x105fed(0x85)],_0x27ba15[_0x105fed(0xcd)],_0xeb7993=>this[_0x105fed(0xa4)](_0x434670[_0x105fed(0x123)],_0x394134,_0xeb7993),_0x17f272)[_0x105fed(0xff)](_0x3a5a27=>{const _0x2b42a4=_0x105fed;if(_0x27ba15[_0x2b42a4(0xcd)][_0x2b42a4(0xe5)])return;if(!_0x3ddb62){_0x312b17(_0x3a5a27);return;}this[_0x2b42a4(0x9c)](_0x434670[_0x2b42a4(0x123)],_0x2b42a4(0x90),_0x2b42a4(0x132),_0x3a5a27,_0x2b42a4(0x6f));}),await _0x48ab94,this[_0x105fed(0x6d)][_0x105fed(0xf3)](_0x434670[_0x105fed(0x123)],_0x105fed(0x86),{},_0x105fed(0xd8)),this[_0x105fed(0x93)][_0x105fed(0x116)](_0x434670[_0x105fed(0x123)]);const _0x1b79d7=_0x434670[_0x105fed(0x120)][_0x105fed(0x72)]===-0x2a5+0xf83+-0xcde?[]:await this[_0x105fed(0x6d)][_0x105fed(0xdd)](_0x434670[_0x105fed(0x85)],_0x434670[_0x105fed(0x123)],_0x434670[_0x105fed(0x120)]);await _0x18c669[_0x105fed(0x12c)]({'directory':_0x434670[_0x105fed(0x85)],'sessionID':_0x394134,'text':openCodeImageInput(_0x434670[_0x105fed(0xf1)],_0x1b79d7),'model':_0x434670[_0x105fed(0xbe)],'variant':_0x434670[_0x105fed(0x67)],'agent':_0x434670[_0x105fed(0xf2)],..._0x434670[_0x105fed(0x9d)]===undefined?{}:{'system':_0x434670[_0x105fed(0x9d)]},'attachments':_0x434670[_0x105fed(0x120)]}),this[_0x105fed(0x114)][_0x105fed(0x83)](_0x434670[_0x105fed(0x123)]);if(this[_0x105fed(0x93)][_0x105fed(0x116)](_0x434670[_0x105fed(0x123)]))this[_0x105fed(0x9c)](_0x434670[_0x105fed(0x123)],_0x105fed(0x101),_0x105fed(0x121),{'status':_0x105fed(0x101)});}catch(_0x4d475d){this[_0x105fed(0x9c)](_0x434670[_0x105fed(0x123)],_0x105fed(0x90),_0x105fed(0x132),_0x4d475d,_0x105fed(0x7b));}}[_0x195185(0xa4)](_0x365308,_0x3a6895,_0xcb9cfe){const _0x48aeb8=_0x195185,_0x2d528a=record(_0xcb9cfe),_0x9ff35a=record(_0x2d528a?.[_0x48aeb8(0x97)]),_0x26975e=record(_0x9ff35a?.[_0x48aeb8(0x10f)])??record(_0x9ff35a?.[_0x48aeb8(0xb4)]),_0x5e550c=typeof _0x9ff35a?.[_0x48aeb8(0xaa)]===_0x48aeb8(0x11e)?_0x9ff35a[_0x48aeb8(0xaa)]:typeof _0x26975e?.[_0x48aeb8(0xaa)]===_0x48aeb8(0x11e)?_0x26975e[_0x48aeb8(0xaa)]:undefined;if(_0x5e550c!==_0x3a6895)return;if(_0x2d528a?.[_0x48aeb8(0x99)]===_0x48aeb8(0x11b)){if(!this[_0x48aeb8(0x114)][_0x48aeb8(0xa2)](_0x365308)){this[_0x48aeb8(0x93)][_0x48aeb8(0x83)](_0x365308);return;}this[_0x48aeb8(0x9c)](_0x365308,_0x48aeb8(0x101),_0x48aeb8(0x121),{'status':_0x48aeb8(0x101)});return;}if(_0x2d528a?.[_0x48aeb8(0x99)]===_0x48aeb8(0xb8)){this[_0x48aeb8(0x9c)](_0x365308,_0x48aeb8(0x90),_0x48aeb8(0x132),_0x9ff35a?.[_0x48aeb8(0xd9)]??_0x9ff35a);return;}if(_0x2d528a?.[_0x48aeb8(0x99)]===_0x48aeb8(0xd0)){const _0x53d8c6=record(_0x9ff35a?.[_0x48aeb8(0xb4)]);if(typeof _0x53d8c6?.['id']===_0x48aeb8(0x11e)&&(_0x53d8c6[_0x48aeb8(0x12e)]===_0x48aeb8(0xbb)||_0x53d8c6[_0x48aeb8(0x12e)]===_0x48aeb8(0xf5))){const _0x1eed56=this[_0x48aeb8(0x87)][_0x48aeb8(0x127)](_0x365308)??new Map();_0x1eed56[_0x48aeb8(0xe6)](_0x53d8c6['id'],_0x53d8c6[_0x48aeb8(0x12e)]),this[_0x48aeb8(0x87)][_0x48aeb8(0xe6)](_0x365308,_0x1eed56);}if(_0x53d8c6?.[_0x48aeb8(0x12e)]===_0x48aeb8(0xf5)&&typeof _0x53d8c6['id']===_0x48aeb8(0x11e)&&typeof _0x53d8c6[_0x48aeb8(0xd3)]===_0x48aeb8(0x11e)){const _0x3df221=this[_0x48aeb8(0xfa)][_0x48aeb8(0x127)](_0x365308)??new Map();_0x3df221[_0x48aeb8(0xe6)](_0x53d8c6['id'],_0x53d8c6[_0x48aeb8(0xd3)]),this[_0x48aeb8(0xfa)][_0x48aeb8(0xe6)](_0x365308,_0x3df221),this[_0x48aeb8(0xdb)][_0x48aeb8(0xb0)][_0x48aeb8(0xe6)](_0x53d8c6[_0x48aeb8(0xd3)],_0x365308);}if(_0x53d8c6?.[_0x48aeb8(0x12e)]===_0x48aeb8(0xf5)&&typeof _0x53d8c6[_0x48aeb8(0xd3)]===_0x48aeb8(0x11e)&&typeof record(_0x53d8c6[_0x48aeb8(0xd1)])?.[_0x48aeb8(0xde)]===_0x48aeb8(0x102)){const _0x1265dc=this[_0x48aeb8(0x7e)][_0x48aeb8(0x127)](_0x365308)??new Set(),_0x22c545=_0x1265dc[_0x48aeb8(0xa2)](_0x53d8c6[_0x48aeb8(0xd3)]);_0x1265dc[_0x48aeb8(0x83)](_0x53d8c6[_0x48aeb8(0xd3)]),this[_0x48aeb8(0x7e)][_0x48aeb8(0xe6)](_0x365308,_0x1265dc);const _0xd3eb5f=this[_0x48aeb8(0xf4)][_0x48aeb8(0x127)](_0x365308)?.[_0x48aeb8(0x127)](_0x53d8c6[_0x48aeb8(0xd3)]);if(!_0x22c545&&_0xd3eb5f!==undefined)this[_0x48aeb8(0x6d)][_0x48aeb8(0x6e)](_0x365308,openCodeCompactionItem(_0x48aeb8(0x126),_0xd3eb5f,!![]));}return;}if(_0x2d528a?.[_0x48aeb8(0x99)]===_0x48aeb8(0x8b)){const _0x22c8a8=record(_0x9ff35a?.[_0x48aeb8(0x10f)]);if(_0x22c8a8?.[_0x48aeb8(0x99)]===_0x48aeb8(0x84)&&typeof _0x22c8a8['id']===_0x48aeb8(0x11e)&&typeof _0x22c8a8[_0x48aeb8(0x6c)]===_0x48aeb8(0x11e)&&this[_0x48aeb8(0x87)][_0x48aeb8(0x127)](_0x365308)?.[_0x48aeb8(0x127)](_0x22c8a8[_0x48aeb8(0x6c)])===_0x48aeb8(0xbb)){const _0x822d6c=this[_0x48aeb8(0xf4)][_0x48aeb8(0x127)](_0x365308)??new Map();if(_0x822d6c[_0x48aeb8(0x127)](_0x22c8a8[_0x48aeb8(0x6c)])===_0x22c8a8['id'])return;_0x822d6c[_0x48aeb8(0xe6)](_0x22c8a8[_0x48aeb8(0x6c)],_0x22c8a8['id']),this[_0x48aeb8(0xf4)][_0x48aeb8(0xe6)](_0x365308,_0x822d6c),this[_0x48aeb8(0x6d)][_0x48aeb8(0x6e)](_0x365308,openCodeCompactionItem(_0x48aeb8(0x126),_0x22c8a8['id'],![]));if(this[_0x48aeb8(0x7e)][_0x48aeb8(0x127)](_0x365308)?.[_0x48aeb8(0xa2)](_0x22c8a8[_0x48aeb8(0x6c)]))this[_0x48aeb8(0x6d)][_0x48aeb8(0x6e)](_0x365308,openCodeCompactionItem(_0x48aeb8(0x126),_0x22c8a8['id'],!![]));return;}if(typeof _0x22c8a8?.[_0x48aeb8(0x6c)]!==_0x48aeb8(0x11e)||this[_0x48aeb8(0x87)][_0x48aeb8(0x127)](_0x365308)?.[_0x48aeb8(0x127)](_0x22c8a8[_0x48aeb8(0x6c)])!==_0x48aeb8(0xf5))return;const _0x2b3d13=this[_0x48aeb8(0xfa)][_0x48aeb8(0x127)](_0x365308)?.[_0x48aeb8(0x127)](_0x22c8a8[_0x48aeb8(0x6c)]);if(_0x2b3d13!==undefined&&this[_0x48aeb8(0xf4)][_0x48aeb8(0x127)](_0x365308)?.[_0x48aeb8(0xa2)](_0x2b3d13))return;const _0x210c52=openCodePart(_0x22c8a8,this[_0x48aeb8(0xdb)][_0x48aeb8(0xb9)][_0x48aeb8(0x127)](_0x365308)?.[_0x48aeb8(0xf2)]===_0x48aeb8(0xe4));if(_0x210c52!==undefined)this[_0x48aeb8(0x6d)][_0x48aeb8(0x6e)](_0x365308,_0x210c52);return;}if(_0x2d528a?.[_0x48aeb8(0x99)]===_0x48aeb8(0x112))this[_0x48aeb8(0xce)](_0x365308,_0x9ff35a);if(_0x2d528a?.[_0x48aeb8(0x99)]===_0x48aeb8(0x71))this[_0x48aeb8(0xeb)](_0x365308,_0x9ff35a);}[_0x195185(0xce)](_0x49d830,_0x18dd9e){const _0x75ceeb=_0x195185,_0x5ac1d7=this[_0x75ceeb(0xdb)][_0x75ceeb(0xb9)][_0x75ceeb(0x127)](_0x49d830),_0x1baa1e=typeof _0x18dd9e?.['id']===_0x75ceeb(0x11e)?_0x18dd9e['id']:undefined;if(_0x5ac1d7===undefined||_0x1baa1e===undefined)return;if(_0x5ac1d7[_0x75ceeb(0x12f)]===_0x75ceeb(0xe1)){void _0x5ac1d7[_0x75ceeb(0xd4)][_0x75ceeb(0xb6)](_0x5ac1d7[_0x75ceeb(0x85)],_0x1baa1e,_0x75ceeb(0xf6));return;}const _0x15c93b=_0x75ceeb(0xa8)+_0x1baa1e,_0x39f7a4=Date[_0x75ceeb(0x109)]()+this[_0x75ceeb(0xb5)],_0x5a687a={'toolName':typeof _0x18dd9e?.[_0x75ceeb(0x10e)]===_0x75ceeb(0x11e)?_0x18dd9e[_0x75ceeb(0x10e)]:_0x75ceeb(0xe3),'input':{'patterns':Array[_0x75ceeb(0xab)](_0x18dd9e?.[_0x75ceeb(0x10c)])?_0x18dd9e[_0x75ceeb(0x10c)]:[]}};try{this[_0x75ceeb(0x6d)][_0x75ceeb(0xdf)]({'runId':_0x49d830,'approvalId':_0x15c93b,'payload':_0x5a687a,'expiresAt':_0x39f7a4});}catch{void _0x5ac1d7[_0x75ceeb(0xd4)][_0x75ceeb(0xb6)](_0x5ac1d7[_0x75ceeb(0x85)],_0x1baa1e,_0x75ceeb(0x118));return;}const _0xa998b3=()=>{const _0xc54fc5=_0x75ceeb,_0x2d5edb=this[_0xc54fc5(0xa0)][_0xc54fc5(0x127)](_0x15c93b);if(_0x2d5edb===undefined)return;try{this[_0xc54fc5(0x6d)][_0xc54fc5(0x133)](_0x15c93b);}catch(_0x567929){if(_0x567929 instanceof Error&&_0x567929[_0xc54fc5(0x88)]===_0xc54fc5(0xaf)){const _0xe18615=setTimeout(_0xa998b3,Math[_0xc54fc5(0xc5)](-0x74+-0x79a*-0x3+0x1*-0x1659,_0x39f7a4-Date[_0xc54fc5(0x109)]()));this[_0xc54fc5(0xa0)][_0xc54fc5(0xe6)](_0x15c93b,{..._0x2d5edb,'timer':_0xe18615});return;}}this[_0xc54fc5(0xa0)][_0xc54fc5(0x116)](_0x15c93b),this[_0xc54fc5(0x6d)][_0xc54fc5(0xf3)](_0x49d830,_0xc54fc5(0x105),{'approvalId':_0x15c93b}),void _0x5ac1d7[_0xc54fc5(0xd4)][_0xc54fc5(0xb6)](_0x5ac1d7[_0xc54fc5(0x85)],_0x1baa1e,_0xc54fc5(0x118));},_0x26e0d2=setTimeout(_0xa998b3,this[_0x75ceeb(0xb5)]);this[_0x75ceeb(0xa0)][_0x75ceeb(0xe6)](_0x15c93b,{'runId':_0x49d830,'requestId':_0x1baa1e,'client':_0x5ac1d7[_0x75ceeb(0xd4)],'cwd':_0x5ac1d7[_0x75ceeb(0x85)],'timer':_0x26e0d2}),this[_0x75ceeb(0x6d)][_0x75ceeb(0x11a)]({'runId':_0x49d830,'approvalId':_0x15c93b,'payload':_0x5a687a,'expiresAt':_0x39f7a4});}[_0x195185(0xeb)](_0x438ff3,_0x3f9430){const _0xa8b040=_0x195185,_0xa25498=this[_0xa8b040(0xdb)][_0xa8b040(0xb9)][_0xa8b040(0x127)](_0x438ff3),_0x38f9a0=typeof _0x3f9430?.['id']===_0xa8b040(0x11e)?_0x3f9430['id']:undefined,_0x538d03=_0x3f9430?.[_0xa8b040(0x12b)];if(_0xa25498===undefined||_0x38f9a0===undefined)return;const _0x5271e0=openCodeQuestions(_0x538d03);if(_0x5271e0[_0xa8b040(0x72)]===0x3*-0x989+0x1dc5+-0x12a||this[_0xa8b040(0x12b)][_0xa8b040(0xa2)](_0x38f9a0))return;const _0x8a554f=setTimeout(()=>{const _0x435b0e=_0xa8b040,_0x2dd00b=this[_0x435b0e(0x12b)][_0x435b0e(0x127)](_0x38f9a0);if(_0x2dd00b===undefined)return;this[_0x435b0e(0x12b)][_0x435b0e(0x116)](_0x38f9a0),void _0x2dd00b[_0x435b0e(0xd4)][_0x435b0e(0x9b)](_0x2dd00b[_0x435b0e(0x85)],_0x2dd00b[_0x435b0e(0x66)]),this[_0x435b0e(0x6d)][_0x435b0e(0x6e)](_0x438ff3,{'itemId':boundedConversationItemId(_0x435b0e(0xea),_0x38f9a0),'kind':_0x435b0e(0xa3),'status':_0x435b0e(0x90),'payload':{'requestId':_0x38f9a0,'questions':_0x5271e0,'errorCode':_0x435b0e(0xec)},'merge':!![]});},this[_0xa8b040(0xb5)]);this[_0xa8b040(0x12b)][_0xa8b040(0xe6)](_0x38f9a0,{'runId':_0x438ff3,'requestId':_0x38f9a0,'client':_0xa25498[_0xa8b040(0xd4)],'cwd':_0xa25498[_0xa8b040(0x85)],'questionIds':_0x5271e0[_0xa8b040(0x6a)](_0x518c57=>_0x518c57['id']),'timer':_0x8a554f}),this[_0xa8b040(0x6d)][_0xa8b040(0x6e)](_0x438ff3,{'itemId':boundedConversationItemId(_0xa8b040(0xea),_0x38f9a0),'kind':_0xa8b040(0xa3),'status':_0xa8b040(0xe8),'payload':{'requestId':_0x38f9a0,'questions':_0x5271e0}});}[_0x195185(0x9c)](_0x276aa1,_0x326de0,_0x1fb15b,_0x23245b,_0x1dfd28=_0x195185(0xa6)){const _0x5266b0=_0x195185,_0x2b51be=this[_0x5266b0(0xdb)][_0x5266b0(0xb9)][_0x5266b0(0x127)](_0x276aa1),_0x25a0bb=_0x2b51be?.[_0x5266b0(0x85)]??this[_0x5266b0(0xe9)][_0x5266b0(0x127)](_0x276aa1),_0x5e416e=_0x2b51be?.[_0x5266b0(0xd4)]??this[_0x5266b0(0xc6)][_0x5266b0(0x127)](_0x276aa1);if(_0x2b51be===undefined&&_0x25a0bb===undefined&&_0x5e416e===undefined)return;_0x2b51be?.[_0x5266b0(0x9a)][_0x5266b0(0x9a)](),this[_0x5266b0(0xdb)][_0x5266b0(0xb9)][_0x5266b0(0x116)](_0x276aa1),this[_0x5266b0(0xe9)][_0x5266b0(0x116)](_0x276aa1),this[_0x5266b0(0xc6)][_0x5266b0(0x116)](_0x276aa1),this[_0x5266b0(0x114)][_0x5266b0(0x116)](_0x276aa1),this[_0x5266b0(0x93)][_0x5266b0(0x116)](_0x276aa1),this[_0x5266b0(0x87)][_0x5266b0(0x116)](_0x276aa1),this[_0x5266b0(0xfa)][_0x5266b0(0x116)](_0x276aa1),this[_0x5266b0(0xf4)][_0x5266b0(0x116)](_0x276aa1),this[_0x5266b0(0x7e)][_0x5266b0(0x116)](_0x276aa1),this[_0x5266b0(0x6d)][_0x5266b0(0xad)][_0x5266b0(0x116)](_0x276aa1);for(const [_0x5b0490,_0x33b266]of this[_0x5266b0(0xa0)])_0x33b266[_0x5266b0(0x123)]===_0x276aa1&&(clearTimeout(_0x33b266[_0x5266b0(0x6b)]),this[_0x5266b0(0xa0)][_0x5266b0(0x116)](_0x5b0490));for(const [_0x4601a4,_0x4bf27d]of this[_0x5266b0(0x12b)])_0x4bf27d[_0x5266b0(0x123)]===_0x276aa1&&(clearTimeout(_0x4bf27d[_0x5266b0(0x6b)]),this[_0x5266b0(0x12b)][_0x5266b0(0x116)](_0x4601a4));if(_0x326de0===_0x5266b0(0x90)){const _0x1a1a3c=runnerErrorProjection(_0x23245b,_0x1dfd28);this[_0x5266b0(0x6d)][_0x5266b0(0x6e)](_0x276aa1,{'itemId':boundedConversationItemId(_0x5266b0(0xc7),_0x276aa1),'kind':_0x5266b0(0xd9),'status':_0x5266b0(0x90),'payload':{..._0x1a1a3c,'recoverable':!![],'retryAfterMs':null}}),_0x23245b=_0x1a1a3c;}this[_0x5266b0(0x6d)][_0x5266b0(0xf3)](_0x276aa1,_0x1fb15b,_0x23245b,_0x326de0);if(_0x5e416e!==undefined)this[_0x5266b0(0xdb)][_0x5266b0(0x10b)](_0x5e416e);}}function openCodeImageInput(_0x2b777a,_0x2836ae){const _0x10fb5b=_0x195185;if(_0x2836ae[_0x10fb5b(0x72)]===0x10f*0x14+-0xe08*0x2+0x6e4)return _0x2b777a;const _0x9006d3=_0x2836ae[_0x10fb5b(0x6a)](_0x23fe57=>'-\x20'+JSON[_0x10fb5b(0xb1)](_0x23fe57))[_0x10fb5b(0x76)]('\x0a');return _0x2b777a+_0x10fb5b(0x108)+_0x9006d3;}function hasMcpConfiguration(_0x5daf70){const _0x22ca8e=_0x195185;return _0x5daf70!==null&&typeof _0x5daf70===_0x22ca8e(0x131)&&Object[_0x22ca8e(0xa1)](_0x5daf70)[_0x22ca8e(0x72)]>0x10a3*0x1+-0x201e+0x529*0x3;}function openCodePart(_0x21083b,_0x14f6f9=![]){const _0x3c00f5=_0x195185,_0x4bc862=typeof _0x21083b?.['id']===_0x3c00f5(0x11e)?_0x21083b['id']:undefined;if(_0x4bc862===undefined||typeof _0x21083b?.[_0x3c00f5(0x99)]!==_0x3c00f5(0x11e))return undefined;const _0x5bbeb9=boundedConversationItemId(_0x3c00f5(0x126),_0x4bc862);if(_0x21083b[_0x3c00f5(0x99)]===_0x3c00f5(0xf0)&&typeof _0x21083b[_0x3c00f5(0xf0)]===_0x3c00f5(0x11e))return{'itemId':_0x5bbeb9,'kind':_0x14f6f9?_0x3c00f5(0xe4):_0x3c00f5(0x106),'status':record(_0x21083b[_0x3c00f5(0xd1)])?.[_0x3c00f5(0x95)]===undefined?_0x3c00f5(0xf8):_0x3c00f5(0x8c),'payload':_0x14f6f9?{'explanation':compactRunnerText(_0x21083b[_0x3c00f5(0xf0)],0x63b1+0x54fe+-0x6a8f),'steps':[]}:{'text':_0x21083b[_0x3c00f5(0xf0)],'format':_0x3c00f5(0x113),'model':null},'merge':!![]};if(_0x21083b[_0x3c00f5(0x99)]===_0x3c00f5(0x11d)&&typeof _0x21083b[_0x3c00f5(0xf0)]===_0x3c00f5(0x11e))return{'itemId':_0x5bbeb9,'kind':_0x3c00f5(0xa9),'status':record(_0x21083b[_0x3c00f5(0xd1)])?.[_0x3c00f5(0x95)]===undefined?_0x3c00f5(0xf8):_0x3c00f5(0x8c),'payload':{'sections':[{'index':0x0,'text':_0x21083b[_0x3c00f5(0xf0)]}]},'merge':!![]};if(_0x21083b[_0x3c00f5(0x99)]===_0x3c00f5(0x7c)&&typeof _0x21083b[_0x3c00f5(0x7c)]===_0x3c00f5(0x11e)){if(_0x21083b[_0x3c00f5(0x7c)]===_0x3c00f5(0xd7))return undefined;const _0x9fd428=record(_0x21083b[_0x3c00f5(0xca)]),_0x149aa5=_0x9fd428?.[_0x3c00f5(0x75)]===_0x3c00f5(0xde)?_0x3c00f5(0x8c):_0x9fd428?.[_0x3c00f5(0x75)]===_0x3c00f5(0xd9)?_0x3c00f5(0x90):_0x3c00f5(0xf8),_0x2ac7dc=normalizeOpenCodeTool(_0x21083b[_0x3c00f5(0x7c)],_0x9fd428);return{'itemId':_0x5bbeb9,'kind':_0x2ac7dc[_0x3c00f5(0xee)],'status':_0x149aa5,'payload':_0x2ac7dc[_0x3c00f5(0x104)],'merge':!![]};}if(_0x21083b[_0x3c00f5(0x99)]===_0x3c00f5(0x84))return openCodeCompactionItem(_0x3c00f5(0x126),_0x4bc862,![]);if(_0x21083b[_0x3c00f5(0x99)]===_0x3c00f5(0x130))return{'itemId':_0x5bbeb9,'kind':_0x3c00f5(0x119),'status':_0x3c00f5(0x8c),'payload':openCodePatchToolPayload(),'merge':!![]};if(_0x21083b[_0x3c00f5(0x99)]===_0x3c00f5(0xcb)||_0x21083b[_0x3c00f5(0x99)]===_0x3c00f5(0x73))return undefined;if(_0x21083b[_0x3c00f5(0x99)]===_0x3c00f5(0xf0)||_0x21083b[_0x3c00f5(0x99)]===_0x3c00f5(0x11d))return undefined;return{'itemId':_0x5bbeb9,'kind':_0x3c00f5(0xa7),'status':record(_0x21083b[_0x3c00f5(0xd1)])?.[_0x3c00f5(0x95)]===undefined?_0x3c00f5(0xf8):_0x3c00f5(0x8c),'payload':{'sourceEventType':_0x3c00f5(0xa8)+_0x21083b[_0x3c00f5(0x99)],'label':_0x3c00f5(0x12d)+compactRunnerText(_0x21083b[_0x3c00f5(0x99)],0x11d5*-0x2+-0x13b2+0x37dc)},'merge':!![]};}function _0x4360(){const _0x17843f=['zgvMyxvSDa','su5urvjsvvbu','C3rHDgu','C3rLCc1ZDgfYDa','zxH0zxjUywXtzxnZAw9Uswq','C2LNBMfS','CMvXDwvZDfbLCM1PC3nPB24','CNvUlNn0yxj0zwq','BwvZC2fNzs51CgrHDgvK','DgLTzq','uLvotKvsx0Loufvux0LovKfmsuq','CgfYzw50suq','y2XPzw50','C2vZC2LVBKLK','zMLUywXSEq','CxvLC3rPB24','uLvotKLorW','zxjYB3i','zgvJAxnPB24','CNvUBMvY','y2fUy2vS','CgvYC2LZDef0DgfJAg1LBNrZ','y29TCgXLDgvK','y3jLyxrLqxbWCM92ywW','BMf0AxzLu2vZC2LVBKLK','yxv0BW','CNvUq29TCgfJDa','t3bLBKnVzguGCgvYBwLZC2LVBG','CgXHBG','ywjVCNrLza','C2v0','zgvJAwrLqxbWCM92ywW','uevoreLorW','C3rHCNrPBMDdD2rZ','B3bLBMnVzguTAw5WDxq','CMvXDwvZDff1zxn0Aw9U','vvnfuL9jtLbvvf9fwfbjuKve','BwfUywDLzenSAwvUDa','A2LUza','y29UzMLNDxjLtwnW','Dgv4Da','Aw5WDxq','ywDLBNq','zw1PDa','y29TCgfJDgLVBLbHCNrjzhm','yxnZAxn0yw50','qvbquK9wruq','yxbWCM92ywXjza','su5Fufjpr1jfu1m','uLvotKvsx0nptu1btKrFvu5bvKfjtefcteu','BwvZC2fNzvbHCMvUDhm','CNvUlNjLAMvJDgvK','t1bftKnprevFq09nuefdvf9gquLmruq','zxHLy3v0zunVBw1HBMq','u1rbuLrjtKC','y2f0y2G','CxvLC3rPB25jzhm','u1vdq0vfreve','BNvTyMvY','q0foq0vmteve','Cgf5Bg9Hza','yxbWCM92ywWUzxHWAxjLza','yxnZAxn0yw50x21LC3nHz2u','mZntqw5xBue','cGPjzIbHBIbPBMXPBMuGAw1Hz2uGAw4GDgHPCYbTzxnZywDLigLZihvUyxzHAwXHyMXLlcb1C2uGDgHLihjLywqGDg9VBcbVBIb0AguGy29YCMvZCg9UzgLUzYbJB3b5igjLBg93lIbeBYbUB3qGCMvHzcbPDcbHz2fPBIb3AgvUihrOzsbPBMXPBMuGAw1Hz2uGAxmGywXYzwfKEsb2AxnPyMXLoGO','BM93','ChjVBw90zq','CMvSzwfZzu1HBMfNzwrdBgLLBNq','Cgf0DgvYBNm','y29TBwfUzfn0yxrLCW','CgvYBwLZC2LVBG','CgfYDa','oda4nJqYohvZq0HKvG','C2v0q29TBwfUzfn0yxrL','CgvYBwLZC2LVBI5HC2TLza','BwfYA2rVD24','ChjVBxb0qwrTAxr0zwq','CMvZCg9UzfvZzxjjBNb1Da','zgvSzxrL','tufsx01btKfhruq','uKvkrunuruq','Dg9VBf9JywXS','ChvIBgLZAefWChjVDMfS','C2vZC2LVBI5PzgXL','BwnWsw5ZDgfSBgf0Aw9UCW','CMvHC29UAw5N','C3rYAw5N','u3vIC2vXDwvUDcbTzxnZywDLCYb1C2uGDgHLie9Wzw5dB2rLifbSyw4GqwDLBNqGzM9YihjLywqTB25SEsbHBMfSExnPCY4','yxr0ywnOBwvUDhm','CNvUlMnVBxbSzxrLza','BwnWq29UzMLNDxjHDgLVBG','CNvUswq','AgfZqwn0AxzLu2vZC2LVBKXLyxnL','C2vZC2LVBI5LEhrLCM5HBc1Pza','B3bLBMnVzgu','z2v0','oti4v1v5AurM','C2vUza','C29Tzq','CxvLC3rPB25Z','ChjVBxb0','t3bLBKnVzguG','CM9Szq','ywnJzxnZ','Cgf0y2G','B2jQzwn0','CNvUlMzHAwXLza','zxHWAxjLqxbWCM92ywW','CMvXDwvZDeLK','zwzMB3j0','CMvWBhLrDwvZDgLVBG','ntaWswX6AuTQ','BwfW','DgLTzxi','BwvZC2fNzuLe','Ag9ZDa','zw1PDeL0zw0','t1bftKnprevFrvzftLrFrKfjteve','u1rbuLrfra','CxvLC3rPB24UyxnRzwq','BgvUz3rO','C3rLCc1MAw5PC2G','C3vIC2nYAwjL','C3rHDhvZ','AM9PBG','ugXHBIbnB2rL','C3rHCNq','t1bftKnprevFu0vtu0LptL9jtLzbteLe','CMfUzg9Tvvvjra','t1bftKnprevFuLvox1nuqvjux0zbsuXfra','Dg9VBa','vvnfuL9jtLbvvf9jtLzbteLe','y29TCgXLDgvKq29TCgfJDgLVBLbHCMvUDhm','mJq3odC2nxfWqvfgCG','su5urvjsvvburuq','mZiZmJi1nKzhyNPLuq','y2XLyxjdB21Tyw5Ku3rHDgu','ywrK','y29TCgfJDgLVBG','y3DK','CNvUlNj1BM5PBMC','BwvZC2fNzvjVBgvZ','BwvZC2fNzq','y3jLyxrLu2vZC2LVBG','zw52AxjVBM1LBNq','BwvZC2fNzs5Wyxj0lNvWzgf0zwq','q09nueXfveve','sw1WBgvTzw50','mZe3oxbRDvLoBW','ywrVChq','rKfjteve','CNvU','Aw50zxjJzxb0zwq','CgvUzgLUz0LKBgu','BwnW','zw5K','ntKWmJG5nw52Cg54zW','ChjVCgvYDgLLCW','y29SBgfIB3jHDgLVBK1Vzgu','DhLWzq','ywjVCNq','CMvQzwn0uxvLC3rPB24','zMLUAxnO','CgvYC29UywXjBNn0CNvJDgLVBNm','C3vTBwfYAxPL','CgfYC2vbDhrHy2HTzw50CW','CgvYBwLZC2LVBNm','A2v5CW','AgfZ','DxnLCL9PBNb1Df9Yzxf1zxn0','zxzLBNq','BMf0AxzLq29UDhjVBa','t1bftKnprevFuLvox0zbsuXfra','Dw5RBM93BG','B3bLBMnVzgu6','CMvHC29UAw5Nx3n1Bw1HCNK','C2vZC2LVBKLe','AxnbCNjHEq','nZiYmtzsAuTuvfe','ywn0AxzL','y29TBwfUzfn0yxrL','qvbquK9wquXFtK9ux0vyueLsruq','BwfUywDLzfr1CM5Z','C3rYAw5NAwz5','CMvTzw1IzxjoyxrPDMu','y29UDgv4Df9JB21Wywn0Aw9U','Aw5MBW','Aw50zxjHy3rPB25uAw1LB3v0txm','CMvWBhLqzxjTAxnZAw9U','BwnWu2vJCMv0rw52AxjVBM1LBNq','C2vZC2LVBI5LCNjVCG','zxHLy3v0Aw9U','y29TCgfJDa','DxnLCG','yNvPBgq','l3bSyw4','Bw9KzwW','C2vJCMv0rw52AxjVBM1LBNq','nKrMDgzdvG','sw1WBgvTzw50ihrOzsbWBgfUigfIB3zLlG','B3bLBMnVzguTy29TCgfJDa','mJy1nZm5merLrezqBq','Aw5PDgLHDgvKqNLvC2vYswq','Bwf4','C3rHCNrPBMDdBgLLBNrZ','CNvUBMvYlwvYCM9Y'];_0x4360=function(){return _0x17843f;};return _0x4360();}function openCodeCompactionItem(_0x50a6fb,_0x4b4aa8,_0x508e2b){const _0x36d6be=_0x195185;return{'itemId':boundedConversationItemId(_0x50a6fb,_0x4b4aa8),'kind':_0x36d6be(0xb3),'status':_0x508e2b?_0x36d6be(0x8c):_0x36d6be(0xf8),'payload':{'phase':_0x508e2b?_0x36d6be(0x8c):_0x36d6be(0x70),'summary':null},'merge':!![]};}function openCodeSessionId(_0x4c274b){const _0x424333=_0x195185,_0x4a60b6=record(_0x4c274b);return typeof _0x4a60b6?.['id']===_0x424333(0x11e)?_0x4a60b6['id']:undefined;}function record(_0x58e01c){const _0x453f3f=_0x195185;return typeof _0x58e01c===_0x453f3f(0x131)&&_0x58e01c!==null&&!Array[_0x453f3f(0xab)](_0x58e01c)?_0x58e01c:undefined;}
|
|
1
|
+
import { parseSecretEnvironment } from '../../util/secret-environment.js';
|
|
2
|
+
import { runnerErrorProjection } from '../../util/runner-error.js';
|
|
3
|
+
import { boundedConversationItemId, compactRunnerText } from '../codex/conversation-parser.js';
|
|
4
|
+
import { openCodePatchToolPayload, openCodeQuestions } from './conversation-parser.js';
|
|
5
|
+
import { normalizeOpenCodeTool } from './tool-normalizer.js';
|
|
6
|
+
export class OpenCodeManagedRunController {
|
|
7
|
+
runner;
|
|
8
|
+
host;
|
|
9
|
+
interactionTimeoutMs;
|
|
10
|
+
permissions = new Map();
|
|
11
|
+
questions = new Map();
|
|
12
|
+
startingCwds = new Map();
|
|
13
|
+
promptAdmitted = new Set();
|
|
14
|
+
pendingIdle = new Set();
|
|
15
|
+
messageRoles = new Map();
|
|
16
|
+
messageParents = new Map();
|
|
17
|
+
compactionPartIds = new Map();
|
|
18
|
+
completedCompactionParents = new Map();
|
|
19
|
+
startingClients = new Map();
|
|
20
|
+
constructor(runner, host, interactionTimeoutMs = 10 * 60_000) {
|
|
21
|
+
this.runner = runner;
|
|
22
|
+
this.host = host;
|
|
23
|
+
this.interactionTimeoutMs = interactionTimeoutMs;
|
|
24
|
+
}
|
|
25
|
+
async executeCommand(session, command, context) {
|
|
26
|
+
if (command.id === 'compact')
|
|
27
|
+
return this.compact(session, context.secretEnvironment, context.initiatedByUserId);
|
|
28
|
+
if (command.id !== 'plan')
|
|
29
|
+
throw new Error('RUNNER_COMMAND_UNAVAILABLE');
|
|
30
|
+
const current = this.host.commandState(session.id, 'plan');
|
|
31
|
+
if (current?.active)
|
|
32
|
+
this.host.clearCommandState(session.id, 'plan');
|
|
33
|
+
else
|
|
34
|
+
this.host.setCommandState(session.id, {
|
|
35
|
+
commandId: 'plan',
|
|
36
|
+
active: true,
|
|
37
|
+
label: 'Plan Mode',
|
|
38
|
+
detail: 'Subsequent messages use the OpenCode Plan Agent for read-only analysis.',
|
|
39
|
+
closable: true,
|
|
40
|
+
closeInput: '/plan',
|
|
41
|
+
continuation: { label: 'Implement', prompt: 'Implement the plan above.' }
|
|
42
|
+
});
|
|
43
|
+
return { command: command.id, states: this.host.commandStates(session.id) };
|
|
44
|
+
}
|
|
45
|
+
compact(session, environment, initiatedByUserId) {
|
|
46
|
+
if (session.externalSessionId === null ||
|
|
47
|
+
session.model === null ||
|
|
48
|
+
session.nativeControl !== 'MAR_MANAGED' ||
|
|
49
|
+
this.host.hasActiveSessionLease(session.id))
|
|
50
|
+
throw new Error('RUNNER_COMMAND_UNAVAILABLE');
|
|
51
|
+
const runId = crypto.randomUUID();
|
|
52
|
+
const client = this.runner.managedClient(environment);
|
|
53
|
+
this.host.adopt({
|
|
54
|
+
runId,
|
|
55
|
+
sessionId: session.id,
|
|
56
|
+
runner: 'opencode',
|
|
57
|
+
cwd: session.cwd,
|
|
58
|
+
externalSessionId: session.externalSessionId,
|
|
59
|
+
...(initiatedByUserId === undefined ? {} : { initiatedByUserId })
|
|
60
|
+
});
|
|
61
|
+
this.host.active.add(runId);
|
|
62
|
+
this.runner.execution.set(runId, {
|
|
63
|
+
runId,
|
|
64
|
+
sessionId: session.id,
|
|
65
|
+
nativeSessionId: session.externalSessionId,
|
|
66
|
+
cwd: session.cwd,
|
|
67
|
+
client,
|
|
68
|
+
abort: new AbortController(),
|
|
69
|
+
access: session.access ?? 'default',
|
|
70
|
+
agent: 'build'
|
|
71
|
+
});
|
|
72
|
+
this.host.emit(runId, 'run.started', { command: 'compact' }, 'STARTING');
|
|
73
|
+
this.host.emitItem(runId, openCodeCompactionItem('opencode-compact', runId, false));
|
|
74
|
+
void this.runCompact(runId, session.model);
|
|
75
|
+
return {
|
|
76
|
+
command: 'compact',
|
|
77
|
+
run: this.host.run(runId),
|
|
78
|
+
states: this.host.commandStates(session.id)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async runCompact(runId, model) {
|
|
82
|
+
const execution = this.runner.execution.get(runId);
|
|
83
|
+
if (execution === undefined)
|
|
84
|
+
return;
|
|
85
|
+
this.host.emit(runId, 'run.running', { command: 'compact' }, 'RUNNING');
|
|
86
|
+
try {
|
|
87
|
+
await execution.client.summarize(execution.cwd, execution.nativeSessionId, model);
|
|
88
|
+
this.host.emitItem(runId, openCodeCompactionItem('opencode-compact', runId, true));
|
|
89
|
+
this.finish(runId, 'SUCCEEDED', 'run.completed', { status: 'SUCCEEDED' });
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
this.finish(runId, 'FAILED', 'run.failed', error, 'OPENCODE_COMPACT_FAILED');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
start(envelope) {
|
|
96
|
+
const payload = envelope.payload;
|
|
97
|
+
if (payload.runner !== 'opencode' ||
|
|
98
|
+
typeof payload.runId !== 'string' ||
|
|
99
|
+
typeof payload.sessionId !== 'string' ||
|
|
100
|
+
typeof payload.input !== 'string' ||
|
|
101
|
+
typeof payload.cwd !== 'string' ||
|
|
102
|
+
typeof payload.model !== 'string' ||
|
|
103
|
+
this.host.intercepted() ||
|
|
104
|
+
this.host.active.has(payload.runId))
|
|
105
|
+
return;
|
|
106
|
+
let environment;
|
|
107
|
+
let mcpSecretEnvironment;
|
|
108
|
+
let mcp;
|
|
109
|
+
let attachments;
|
|
110
|
+
try {
|
|
111
|
+
environment = parseSecretEnvironment(payload.secretEnvironment);
|
|
112
|
+
mcpSecretEnvironment = parseSecretEnvironment(payload.mcpSecretEnvironment);
|
|
113
|
+
mcp = this.runner.mcpConfiguration(payload.mcpInstallations, {
|
|
114
|
+
...environment,
|
|
115
|
+
...mcpSecretEnvironment
|
|
116
|
+
});
|
|
117
|
+
attachments = this.host.parseAttachments(payload.attachments);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
const projected = runnerErrorProjection(error, 'RUNNER_INPUT_INVALID');
|
|
121
|
+
this.host.emitItem(payload.runId, {
|
|
122
|
+
itemId: boundedConversationItemId('runner-error', payload.runId),
|
|
123
|
+
kind: 'error',
|
|
124
|
+
status: 'FAILED',
|
|
125
|
+
payload: { ...projected, recoverable: true, retryAfterMs: null }
|
|
126
|
+
});
|
|
127
|
+
this.host.emit(payload.runId, 'run.rejected', projected, 'FAILED');
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
void this.run({
|
|
131
|
+
runId: payload.runId,
|
|
132
|
+
sessionId: payload.sessionId,
|
|
133
|
+
input: payload.input,
|
|
134
|
+
cwd: payload.cwd,
|
|
135
|
+
model: payload.model,
|
|
136
|
+
effort: typeof payload.effort === 'string' ? payload.effort : '',
|
|
137
|
+
...(typeof payload.externalSessionId === 'string'
|
|
138
|
+
? { externalSessionId: payload.externalSessionId }
|
|
139
|
+
: {}),
|
|
140
|
+
environment,
|
|
141
|
+
attachments,
|
|
142
|
+
access: typeof payload.access === 'string' ? payload.access : 'default',
|
|
143
|
+
agent: payload.collaborationMode === 'plan' ? 'plan' : 'build',
|
|
144
|
+
...(typeof payload.personalInstructions === 'string'
|
|
145
|
+
? { personalInstructions: payload.personalInstructions }
|
|
146
|
+
: {}),
|
|
147
|
+
mcp
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
cancel(runId, intent) {
|
|
151
|
+
const execution = this.runner.execution.get(runId);
|
|
152
|
+
if (execution === undefined)
|
|
153
|
+
return false;
|
|
154
|
+
void execution.client.abort(execution.cwd, execution.nativeSessionId).finally(() => {
|
|
155
|
+
this.finish(runId, intent === 'INTERRUPT' ? 'INTERRUPTED' : 'CANCELLED', 'run.completed', {
|
|
156
|
+
status: intent === 'INTERRUPT' ? 'INTERRUPTED' : 'CANCELLED'
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
decideApproval(input) {
|
|
162
|
+
const pending = this.permissions.get(input.approvalId);
|
|
163
|
+
if (pending === undefined || pending.runId !== input.runId)
|
|
164
|
+
return false;
|
|
165
|
+
clearTimeout(pending.timer);
|
|
166
|
+
this.permissions.delete(input.approvalId);
|
|
167
|
+
void pending.client.replyPermission(pending.cwd, pending.requestId, input.decision);
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
respondUserInput(runId, requestId, answers) {
|
|
171
|
+
const pending = this.questions.get(requestId);
|
|
172
|
+
if (pending === undefined || pending.runId !== runId)
|
|
173
|
+
return false;
|
|
174
|
+
const normalized = pending.questionIds.map((id) => {
|
|
175
|
+
const value = answers[id];
|
|
176
|
+
const values = Array.isArray(value) ? value : typeof value === 'string' ? [value] : [];
|
|
177
|
+
if (values.length === 0 ||
|
|
178
|
+
values.length > 8 ||
|
|
179
|
+
values.some((item) => typeof item !== 'string' || item.length === 0 || item.length > 500))
|
|
180
|
+
throw new Error('USER_INPUT_INVALID');
|
|
181
|
+
return values;
|
|
182
|
+
});
|
|
183
|
+
clearTimeout(pending.timer);
|
|
184
|
+
this.questions.delete(requestId);
|
|
185
|
+
void pending.client.replyQuestion(pending.cwd, pending.requestId, normalized);
|
|
186
|
+
this.host.emitItem(runId, {
|
|
187
|
+
itemId: boundedConversationItemId('opencode-input', requestId),
|
|
188
|
+
kind: 'user_input_request',
|
|
189
|
+
status: 'COMPLETED',
|
|
190
|
+
payload: {},
|
|
191
|
+
merge: true
|
|
192
|
+
});
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
async run(input) {
|
|
196
|
+
// OpenCode dynamic MCP registration belongs to Server process state. Runs that load MCP use an
|
|
197
|
+
// isolated Server so parallel sessions in one workspace do not share MCP processes or context.
|
|
198
|
+
const client = this.runner.managedClient(input.environment, hasMcpConfiguration(input.mcp) ? input.runId : undefined);
|
|
199
|
+
this.startingClients.set(input.runId, client);
|
|
200
|
+
this.startingCwds.set(input.runId, input.cwd);
|
|
201
|
+
this.host.active.add(input.runId);
|
|
202
|
+
this.host.emit(input.runId, 'run.started', {}, 'STARTING');
|
|
203
|
+
try {
|
|
204
|
+
if (hasMcpConfiguration(input.mcp))
|
|
205
|
+
await client.configureMcp(input.cwd, input.mcp);
|
|
206
|
+
const nativeSessionId = input.externalSessionId ?? openCodeSessionId(await client.createSession(input.cwd));
|
|
207
|
+
if (nativeSessionId === undefined)
|
|
208
|
+
throw new Error('OPENCODE_SESSION_INVALID');
|
|
209
|
+
this.host.adopt({
|
|
210
|
+
runId: input.runId,
|
|
211
|
+
sessionId: input.sessionId,
|
|
212
|
+
runner: 'opencode',
|
|
213
|
+
cwd: input.cwd,
|
|
214
|
+
externalSessionId: nativeSessionId
|
|
215
|
+
});
|
|
216
|
+
this.host.rememberNative(nativeSessionId, input.sessionId);
|
|
217
|
+
if (input.externalSessionId === undefined) {
|
|
218
|
+
this.host.promote(input.sessionId, nativeSessionId);
|
|
219
|
+
this.host.send('session.external-id', {
|
|
220
|
+
sessionId: input.sessionId,
|
|
221
|
+
externalSessionId: nativeSessionId
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
const abort = new AbortController();
|
|
225
|
+
this.runner.execution.set(input.runId, {
|
|
226
|
+
runId: input.runId,
|
|
227
|
+
sessionId: input.sessionId,
|
|
228
|
+
nativeSessionId,
|
|
229
|
+
cwd: input.cwd,
|
|
230
|
+
client,
|
|
231
|
+
abort,
|
|
232
|
+
access: input.access,
|
|
233
|
+
agent: input.agent
|
|
234
|
+
});
|
|
235
|
+
let subscriptionStarted = false;
|
|
236
|
+
let ready;
|
|
237
|
+
let rejectReady;
|
|
238
|
+
const subscriptionReady = new Promise((resolve, reject) => {
|
|
239
|
+
ready = () => {
|
|
240
|
+
subscriptionStarted = true;
|
|
241
|
+
resolve();
|
|
242
|
+
};
|
|
243
|
+
rejectReady = reject;
|
|
244
|
+
});
|
|
245
|
+
void client
|
|
246
|
+
.subscribe(input.cwd, abort.signal, (event) => this.event(input.runId, nativeSessionId, event), ready)
|
|
247
|
+
.catch((error) => {
|
|
248
|
+
if (abort.signal.aborted)
|
|
249
|
+
return;
|
|
250
|
+
if (!subscriptionStarted) {
|
|
251
|
+
rejectReady(error);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
this.finish(input.runId, 'FAILED', 'run.failed', error, 'OPENCODE_EVENT_FAILED');
|
|
255
|
+
});
|
|
256
|
+
await subscriptionReady;
|
|
257
|
+
this.host.emit(input.runId, 'run.running', {}, 'RUNNING');
|
|
258
|
+
// The initial SSE snapshot can contain an idle event from before this prompt.
|
|
259
|
+
this.pendingIdle.delete(input.runId);
|
|
260
|
+
const attachmentPaths = input.attachments.length === 0
|
|
261
|
+
? []
|
|
262
|
+
: await this.host.persistAttachments(input.cwd, input.runId, input.attachments);
|
|
263
|
+
await client.prompt({
|
|
264
|
+
directory: input.cwd,
|
|
265
|
+
sessionID: nativeSessionId,
|
|
266
|
+
text: openCodeImageInput(input.input, attachmentPaths),
|
|
267
|
+
model: input.model,
|
|
268
|
+
variant: input.effort,
|
|
269
|
+
agent: input.agent,
|
|
270
|
+
...(input.personalInstructions === undefined ? {} : { system: input.personalInstructions }),
|
|
271
|
+
attachments: input.attachments
|
|
272
|
+
});
|
|
273
|
+
this.promptAdmitted.add(input.runId);
|
|
274
|
+
if (this.pendingIdle.delete(input.runId))
|
|
275
|
+
this.finish(input.runId, 'SUCCEEDED', 'run.completed', { status: 'SUCCEEDED' });
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
this.finish(input.runId, 'FAILED', 'run.failed', error, 'OPENCODE_RUN_START_FAILED');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
event(runId, nativeSessionId, value) {
|
|
282
|
+
const event = record(value);
|
|
283
|
+
const properties = record(event?.properties);
|
|
284
|
+
const nested = record(properties?.part) ?? record(properties?.info);
|
|
285
|
+
const sessionID = typeof properties?.sessionID === 'string'
|
|
286
|
+
? properties.sessionID
|
|
287
|
+
: typeof nested?.sessionID === 'string'
|
|
288
|
+
? nested.sessionID
|
|
289
|
+
: undefined;
|
|
290
|
+
if (sessionID !== nativeSessionId)
|
|
291
|
+
return;
|
|
292
|
+
if (event?.type === 'session.idle') {
|
|
293
|
+
if (!this.promptAdmitted.has(runId)) {
|
|
294
|
+
this.pendingIdle.add(runId);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
this.finish(runId, 'SUCCEEDED', 'run.completed', { status: 'SUCCEEDED' });
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (event?.type === 'session.error') {
|
|
301
|
+
this.finish(runId, 'FAILED', 'run.failed', properties?.error ?? properties);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (event?.type === 'message.updated') {
|
|
305
|
+
const info = record(properties?.info);
|
|
306
|
+
if (typeof info?.id === 'string' && (info.role === 'user' || info.role === 'assistant')) {
|
|
307
|
+
const roles = this.messageRoles.get(runId) ?? new Map();
|
|
308
|
+
roles.set(info.id, info.role);
|
|
309
|
+
this.messageRoles.set(runId, roles);
|
|
310
|
+
}
|
|
311
|
+
if (info?.role === 'assistant' &&
|
|
312
|
+
typeof info.id === 'string' &&
|
|
313
|
+
typeof info.parentID === 'string') {
|
|
314
|
+
const parents = this.messageParents.get(runId) ?? new Map();
|
|
315
|
+
parents.set(info.id, info.parentID);
|
|
316
|
+
this.messageParents.set(runId, parents);
|
|
317
|
+
this.runner.managedTurns.set(info.parentID, runId);
|
|
318
|
+
}
|
|
319
|
+
if (info?.role === 'assistant' &&
|
|
320
|
+
typeof info.parentID === 'string' &&
|
|
321
|
+
typeof record(info.time)?.completed === 'number') {
|
|
322
|
+
const completedParents = this.completedCompactionParents.get(runId) ?? new Set();
|
|
323
|
+
const alreadyCompleted = completedParents.has(info.parentID);
|
|
324
|
+
completedParents.add(info.parentID);
|
|
325
|
+
this.completedCompactionParents.set(runId, completedParents);
|
|
326
|
+
const partId = this.compactionPartIds.get(runId)?.get(info.parentID);
|
|
327
|
+
if (!alreadyCompleted && partId !== undefined)
|
|
328
|
+
this.host.emitItem(runId, openCodeCompactionItem('opencode', partId, true));
|
|
329
|
+
}
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (event?.type === 'message.part.updated') {
|
|
333
|
+
const part = record(properties?.part);
|
|
334
|
+
if (part?.type === 'compaction' &&
|
|
335
|
+
typeof part.id === 'string' &&
|
|
336
|
+
typeof part.messageID === 'string' &&
|
|
337
|
+
this.messageRoles.get(runId)?.get(part.messageID) === 'user') {
|
|
338
|
+
const partIds = this.compactionPartIds.get(runId) ?? new Map();
|
|
339
|
+
if (partIds.get(part.messageID) === part.id)
|
|
340
|
+
return;
|
|
341
|
+
partIds.set(part.messageID, part.id);
|
|
342
|
+
this.compactionPartIds.set(runId, partIds);
|
|
343
|
+
this.host.emitItem(runId, openCodeCompactionItem('opencode', part.id, false));
|
|
344
|
+
if (this.completedCompactionParents.get(runId)?.has(part.messageID))
|
|
345
|
+
this.host.emitItem(runId, openCodeCompactionItem('opencode', part.id, true));
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (typeof part?.messageID !== 'string' ||
|
|
349
|
+
this.messageRoles.get(runId)?.get(part.messageID) !== 'assistant')
|
|
350
|
+
return;
|
|
351
|
+
const parentId = this.messageParents.get(runId)?.get(part.messageID);
|
|
352
|
+
if (parentId !== undefined && this.compactionPartIds.get(runId)?.has(parentId))
|
|
353
|
+
return;
|
|
354
|
+
const item = openCodePart(part, this.runner.execution.get(runId)?.agent === 'plan');
|
|
355
|
+
if (item !== undefined)
|
|
356
|
+
this.host.emitItem(runId, item);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
if (event?.type === 'permission.asked')
|
|
360
|
+
this.requestPermission(runId, properties);
|
|
361
|
+
if (event?.type === 'question.asked')
|
|
362
|
+
this.requestQuestion(runId, properties);
|
|
363
|
+
}
|
|
364
|
+
requestPermission(runId, properties) {
|
|
365
|
+
const execution = this.runner.execution.get(runId);
|
|
366
|
+
const requestId = typeof properties?.id === 'string' ? properties.id : undefined;
|
|
367
|
+
if (execution === undefined || requestId === undefined)
|
|
368
|
+
return;
|
|
369
|
+
if (execution.access === 'auto') {
|
|
370
|
+
void execution.client.replyPermission(execution.cwd, requestId, 'APPROVED');
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const approvalId = `opencode:${requestId}`;
|
|
374
|
+
const expiresAt = Date.now() + this.interactionTimeoutMs;
|
|
375
|
+
const payload = {
|
|
376
|
+
toolName: typeof properties?.permission === 'string' ? properties.permission : 'OpenCode permission',
|
|
377
|
+
input: { patterns: Array.isArray(properties?.patterns) ? properties.patterns : [] }
|
|
378
|
+
};
|
|
379
|
+
try {
|
|
380
|
+
this.host.createApproval({ runId, approvalId, payload, expiresAt });
|
|
381
|
+
}
|
|
382
|
+
catch {
|
|
383
|
+
void execution.client.replyPermission(execution.cwd, requestId, 'REJECTED');
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
const expire = () => {
|
|
387
|
+
const pending = this.permissions.get(approvalId);
|
|
388
|
+
if (pending === undefined)
|
|
389
|
+
return;
|
|
390
|
+
try {
|
|
391
|
+
this.host.expireApproval(approvalId);
|
|
392
|
+
}
|
|
393
|
+
catch (error) {
|
|
394
|
+
if (error instanceof Error && error.message === 'APPROVAL_NOT_EXPIRED') {
|
|
395
|
+
const timer = setTimeout(expire, Math.max(1, expiresAt - Date.now()));
|
|
396
|
+
this.permissions.set(approvalId, { ...pending, timer });
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
this.permissions.delete(approvalId);
|
|
401
|
+
this.host.emit(runId, 'approval.expired', { approvalId });
|
|
402
|
+
void execution.client.replyPermission(execution.cwd, requestId, 'REJECTED');
|
|
403
|
+
};
|
|
404
|
+
const timer = setTimeout(expire, this.interactionTimeoutMs);
|
|
405
|
+
this.permissions.set(approvalId, {
|
|
406
|
+
runId,
|
|
407
|
+
requestId,
|
|
408
|
+
client: execution.client,
|
|
409
|
+
cwd: execution.cwd,
|
|
410
|
+
timer
|
|
411
|
+
});
|
|
412
|
+
this.host.publishApproval({ runId, approvalId, payload, expiresAt });
|
|
413
|
+
}
|
|
414
|
+
requestQuestion(runId, properties) {
|
|
415
|
+
const execution = this.runner.execution.get(runId);
|
|
416
|
+
const requestId = typeof properties?.id === 'string' ? properties.id : undefined;
|
|
417
|
+
const rawQuestions = properties?.questions;
|
|
418
|
+
if (execution === undefined || requestId === undefined)
|
|
419
|
+
return;
|
|
420
|
+
const questions = openCodeQuestions(rawQuestions);
|
|
421
|
+
if (questions.length === 0 || this.questions.has(requestId))
|
|
422
|
+
return;
|
|
423
|
+
const timer = setTimeout(() => {
|
|
424
|
+
const pending = this.questions.get(requestId);
|
|
425
|
+
if (pending === undefined)
|
|
426
|
+
return;
|
|
427
|
+
this.questions.delete(requestId);
|
|
428
|
+
void pending.client.rejectQuestion(pending.cwd, pending.requestId);
|
|
429
|
+
this.host.emitItem(runId, {
|
|
430
|
+
itemId: boundedConversationItemId('opencode-input', requestId),
|
|
431
|
+
kind: 'user_input_request',
|
|
432
|
+
status: 'FAILED',
|
|
433
|
+
payload: { requestId, questions, errorCode: 'USER_INPUT_EXPIRED' },
|
|
434
|
+
merge: true
|
|
435
|
+
});
|
|
436
|
+
}, this.interactionTimeoutMs);
|
|
437
|
+
this.questions.set(requestId, {
|
|
438
|
+
runId,
|
|
439
|
+
requestId,
|
|
440
|
+
client: execution.client,
|
|
441
|
+
cwd: execution.cwd,
|
|
442
|
+
questionIds: questions.map((question) => question.id),
|
|
443
|
+
timer
|
|
444
|
+
});
|
|
445
|
+
this.host.emitItem(runId, {
|
|
446
|
+
itemId: boundedConversationItemId('opencode-input', requestId),
|
|
447
|
+
kind: 'user_input_request',
|
|
448
|
+
status: 'PENDING',
|
|
449
|
+
payload: { requestId, questions }
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
finish(runId, status, eventType, payload, fallbackCode = 'OPENCODE_RUN_FAILED') {
|
|
453
|
+
const execution = this.runner.execution.get(runId);
|
|
454
|
+
const cwd = execution?.cwd ?? this.startingCwds.get(runId);
|
|
455
|
+
const client = execution?.client ?? this.startingClients.get(runId);
|
|
456
|
+
if (execution === undefined && cwd === undefined && client === undefined)
|
|
457
|
+
return;
|
|
458
|
+
execution?.abort.abort();
|
|
459
|
+
this.runner.execution.delete(runId);
|
|
460
|
+
this.startingCwds.delete(runId);
|
|
461
|
+
this.startingClients.delete(runId);
|
|
462
|
+
this.promptAdmitted.delete(runId);
|
|
463
|
+
this.pendingIdle.delete(runId);
|
|
464
|
+
this.messageRoles.delete(runId);
|
|
465
|
+
this.messageParents.delete(runId);
|
|
466
|
+
this.compactionPartIds.delete(runId);
|
|
467
|
+
this.completedCompactionParents.delete(runId);
|
|
468
|
+
this.host.active.delete(runId);
|
|
469
|
+
for (const [id, pending] of this.permissions)
|
|
470
|
+
if (pending.runId === runId) {
|
|
471
|
+
clearTimeout(pending.timer);
|
|
472
|
+
this.permissions.delete(id);
|
|
473
|
+
}
|
|
474
|
+
for (const [id, pending] of this.questions)
|
|
475
|
+
if (pending.runId === runId) {
|
|
476
|
+
clearTimeout(pending.timer);
|
|
477
|
+
this.questions.delete(id);
|
|
478
|
+
}
|
|
479
|
+
if (status === 'FAILED') {
|
|
480
|
+
const projected = runnerErrorProjection(payload, fallbackCode);
|
|
481
|
+
this.host.emitItem(runId, {
|
|
482
|
+
itemId: boundedConversationItemId('runner-error', runId),
|
|
483
|
+
kind: 'error',
|
|
484
|
+
status: 'FAILED',
|
|
485
|
+
payload: { ...projected, recoverable: true, retryAfterMs: null }
|
|
486
|
+
});
|
|
487
|
+
payload = projected;
|
|
488
|
+
}
|
|
489
|
+
this.host.emit(runId, eventType, payload, status);
|
|
490
|
+
if (client !== undefined)
|
|
491
|
+
this.runner.releaseManagedClient(client);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
function openCodeImageInput(input, attachmentPaths) {
|
|
495
|
+
if (attachmentPaths.length === 0)
|
|
496
|
+
return input;
|
|
497
|
+
const paths = attachmentPaths.map((path) => `- ${JSON.stringify(path)}`).join('\n');
|
|
498
|
+
return `${input}\n\nIf an inline image in this message is unavailable, use the read tool on the corresponding copy below. Do not read it again when the inline image is already visible:\n${paths}`;
|
|
499
|
+
}
|
|
500
|
+
function hasMcpConfiguration(value) {
|
|
501
|
+
return value !== null && typeof value === 'object' && Object.keys(value).length > 0;
|
|
502
|
+
}
|
|
503
|
+
function openCodePart(part, planMode = false) {
|
|
504
|
+
const id = typeof part?.id === 'string' ? part.id : undefined;
|
|
505
|
+
if (id === undefined || typeof part?.type !== 'string')
|
|
506
|
+
return undefined;
|
|
507
|
+
const itemId = boundedConversationItemId('opencode', id);
|
|
508
|
+
if (part.type === 'text' && typeof part.text === 'string')
|
|
509
|
+
return {
|
|
510
|
+
itemId,
|
|
511
|
+
kind: planMode ? 'plan' : 'assistant_message',
|
|
512
|
+
status: record(part.time)?.end === undefined ? 'IN_PROGRESS' : 'COMPLETED',
|
|
513
|
+
payload: planMode
|
|
514
|
+
? { explanation: compactRunnerText(part.text, 20_000), steps: [] }
|
|
515
|
+
: { text: part.text, format: 'markdown', model: null },
|
|
516
|
+
merge: true
|
|
517
|
+
};
|
|
518
|
+
if (part.type === 'reasoning' && typeof part.text === 'string')
|
|
519
|
+
return {
|
|
520
|
+
itemId,
|
|
521
|
+
kind: 'reasoning_summary',
|
|
522
|
+
status: record(part.time)?.end === undefined ? 'IN_PROGRESS' : 'COMPLETED',
|
|
523
|
+
payload: { sections: [{ index: 0, text: part.text }] },
|
|
524
|
+
merge: true
|
|
525
|
+
};
|
|
526
|
+
if (part.type === 'tool' && typeof part.tool === 'string') {
|
|
527
|
+
// `question.asked` carries the canonical request ID required for reply;
|
|
528
|
+
// the mirrored tool Part is presentation/history metadata only.
|
|
529
|
+
if (part.tool === 'question')
|
|
530
|
+
return undefined;
|
|
531
|
+
const state = record(part.state);
|
|
532
|
+
const status = state?.status === 'completed'
|
|
533
|
+
? 'COMPLETED'
|
|
534
|
+
: state?.status === 'error'
|
|
535
|
+
? 'FAILED'
|
|
536
|
+
: 'IN_PROGRESS';
|
|
537
|
+
const normalized = normalizeOpenCodeTool(part.tool, state);
|
|
538
|
+
return {
|
|
539
|
+
itemId,
|
|
540
|
+
kind: normalized.kind,
|
|
541
|
+
status,
|
|
542
|
+
payload: normalized.payload,
|
|
543
|
+
merge: true
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
if (part.type === 'compaction')
|
|
547
|
+
return openCodeCompactionItem('opencode', id, false);
|
|
548
|
+
if (part.type === 'patch')
|
|
549
|
+
return {
|
|
550
|
+
itemId,
|
|
551
|
+
kind: 'tool_call',
|
|
552
|
+
status: 'COMPLETED',
|
|
553
|
+
payload: openCodePatchToolPayload(),
|
|
554
|
+
merge: true
|
|
555
|
+
};
|
|
556
|
+
if (part.type === 'step-start' || part.type === 'step-finish')
|
|
557
|
+
return undefined;
|
|
558
|
+
if (part.type === 'text' || part.type === 'reasoning')
|
|
559
|
+
return undefined;
|
|
560
|
+
return {
|
|
561
|
+
itemId,
|
|
562
|
+
kind: 'unknown',
|
|
563
|
+
status: record(part.time)?.end === undefined ? 'IN_PROGRESS' : 'COMPLETED',
|
|
564
|
+
payload: {
|
|
565
|
+
sourceEventType: `opencode:${part.type}`,
|
|
566
|
+
label: `OpenCode ${compactRunnerText(part.type, 128)}`
|
|
567
|
+
},
|
|
568
|
+
merge: true
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function openCodeCompactionItem(namespace, id, completed) {
|
|
572
|
+
return {
|
|
573
|
+
itemId: boundedConversationItemId(namespace, id),
|
|
574
|
+
kind: 'context_compaction',
|
|
575
|
+
status: completed ? 'COMPLETED' : 'IN_PROGRESS',
|
|
576
|
+
payload: { phase: completed ? 'COMPLETED' : 'STARTED', summary: null },
|
|
577
|
+
merge: true
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
function openCodeSessionId(value) {
|
|
581
|
+
const session = record(value);
|
|
582
|
+
return typeof session?.id === 'string' ? session.id : undefined;
|
|
583
|
+
}
|
|
584
|
+
function record(value) {
|
|
585
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
586
|
+
? value
|
|
587
|
+
: undefined;
|
|
588
|
+
}
|