@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,585 @@
|
|
|
1
|
-
|
|
2
|
-
const _0x491b3d=_0xa01e;(function(_0x37979e,_0x4b219f){const _0x3f9095=_0xa01e,_0x147274=_0x37979e();while(!![]){try{const _0x35ddd0=-parseInt(_0x3f9095(0xcf))/(0x1a6a+-0xe8c+-0xbdd)*(parseInt(_0x3f9095(0xd1))/(0x24cb+-0x7*-0x3af+-0x3e92))+parseInt(_0x3f9095(0x142))/(-0x5*-0x4eb+0x1*-0x182d+0x1*-0x67)+-parseInt(_0x3f9095(0x107))/(-0xce0+-0x67*0x10+-0x2*-0x9aa)+-parseInt(_0x3f9095(0xb2))/(0x1*-0x40f+0x215*0x3+0xb9*-0x3)+parseInt(_0x3f9095(0xf4))/(0x251*-0x2+0x135+0x373)+-parseInt(_0x3f9095(0xa7))/(-0xdb*0x5+-0x1460*0x1+0x18ae)+parseInt(_0x3f9095(0x116))/(0x528+0x3*-0x66e+0xe2a)*(parseInt(_0x3f9095(0x9f))/(0x1852+-0x19ef*0x1+0x1a6));if(_0x35ddd0===_0x4b219f)break;else _0x147274['push'](_0x147274['shift']());}catch(_0x30340b){_0x147274['push'](_0x147274['shift']());}}}(_0x5c9b,0x3fad*-0x17+0xd*-0x15a6+0xb1d9e));function _0x5c9b(){const _0xa20b4=['CNvUBMvY','B2zM','zM9YA1rOCMvHza','yxbWCM92ywXZ','DMfSAwrHDgLVBG','BMf0AxzLsw1Hz2vsB290CW','yMfZzty0DxjS','CNvUlMnHBMnLBa','zMLUza','zNjVBuvUDhjPzxm','C3rHCNq','BwfUywDLzfr1CM5Z','tufoquDfra','Bgf0zxn0uhjVzMLSzunHy2HL','zgLNzxn0','DgHLBG','y3jLyxrL','zw52AxjVBM1LBNrgAw5NzxjWCMLUDa','CMvUyw1LtMf0AxzL','vu5bvKfjtefcteu','mti0mdqXnLD6A0DhDG','ChjVAMvJDgLVBKzVCG','y2XP','zM9YA05HDgL2zq','C2vZC2LVBKLK','C29YDa','C3rYAw5NAwz5','BgvUz3rO','BgLZDfrOCMvHzhm','DgL0BgvtB3vYy2u','zw52AxjVBM1LBNrsDw5Z','D29YA3nWywnLswq','C2vSzwn0q2fJAgvKuhjVzMLSzq','uLvotKvsx0nptu1btKrFsu5wquXjra','zMv0y2HdB2rLEfbYB2zPBgu','ChvZAa','yxzHAwXHyMXL','C2vSzwn0zwrqCM9MAwXLs2v5','rvHurvjoquW','mtm0mJGWogfoEePWuq','CMvZDw1LvgHYzwfK','ChjVzMLSzunHy2HLrM9Yrw52AxjVBM1LBNq','y29KzxG','DhvYBKLK','Aw5JBhvKzxm','C3bSAxq','zMLUywXSEq','y29TBwfUza','CMvMCMvZAfbYB2zPBgu','Bw9KzwW','C2v0vgHYzwfKtMfTzq','DhjHBNnWB3j0','CMvJB3zLCK1PC3nPBMDsB2XSB3v0','Dw5Yzwy','ofPrsLfNqW','BwfW','C3vWCg9YDgvKrwzMB3j0CW','C291CMnL','u0vtu0LptL9srvDjtKrFvu5bvKfjtefcteu','DxjS','zw50CMLLCW','CMv0CNLbDa','zwzMB3j0','C2HHmJu2','AgLKzgvU','surmrq','B3bLBKnVzgu','DxnLC1j1BM5LCLrPDgXLrM9YuMvUyw1L','BwfUywDLzfj1BKzVCK5HDgL2zvr1CM4','y2XHDwrLq29Kzq','zMv0y2HLzef0','Bgv2zwW','DgvZDa','q09ervHFtu9eruXtx0LovKfmsuq','zgLZy292zxj5u2nVCgu','zw5ZDxjLq29UzMLNDxjHDgLVBG','C2vYDMLJzvrPzxi','zMfZDevUywjSzwq','BMv4Den1CNnVCG','C2L6zq','CNvUCW','CNvUBMvYlMnVzgv4lNjVBgXVDxqUCMvJB3zLCMLUzW','Dg9mB3DLCKnHC2u','zgvMyxvSDfjLyxnVBMLUz0vMzM9YDa','Bg9JywXLq29TCgfYzq','ChjVzMLSzuzVCLzHBgLKyxrPB24','B24TCMvXDwvZDa','CNvUBMvYvgL0Bgvqzw5KAw5N','zMLUzeLUzgv4','C2vZC2LVBI5YzxDPBMq','CMvHzenVBNzLCNnHDgLVBKHPC3rVCNK','CgLUBMvK','ChjVzMLSzq','t0zgsunjquW','Cgf0Aa','C3rVCa','CMvSzwfZzuvUDMLYB25Tzw50','AgvHzgvYCW','mti5odu4yNLszeDz','BgLZDenVBgXHyM9YyxrPB25nB2rLCW','BMf0AxzLq29UDhjVBa','C3rHCNruDxjU','y29TBwfUzfn0yxrLCW','AgfZ','C3rHCNruAhjLywq','zxH0zxjUywXby3rPDML0Eq','DMfSDwvZ','ChjVzMLSzvjLzNjLC2HLCW','zMfZDa','y2XPzw50','y2fJAgvqCM9MAwXL','ChjLC2vUDfnLC3nPB24','ChjVzMLSzuTLEuj5rw52AxjVBM1LBNq','C3rHDhvZ','zw52AxjVBM1LBNq','ChjVzMLSzunHy2HL','y2fWywjPBgL0AwvZ','DgL0BgvpCMLNAw4','A2v5CW','y2f0y2G','y3jLyxrLuhjVAMvJDgLVBG','CMvZDw1LrxH0zxjUywW','lMnVzgv4','AxnezwzHDwX0','CMvHC29UAw5NrwzMB3j0','zxHLy3v0Aw9U','z2v0','BwfUywDLzefJDgL2zq','zxH0zxjUywXtzxnZAw9Uswq','C29Tzq','DgHYzwfK','BMfTzq','DhvYBI5XDwv1zq','zgLZy292zxjtzxnZAw9UCW','AxnbCNjHEq','C2vZC2LVBI5Yzw5HBwu','ywnJzxb0C1rYDw5JyxrLze5HDgL2zuHPC3rVCNK','BgLZDe1VzgvSCW','CMvHze1HBMfNzwrsDw5UzxjuAxrSzq','zgvSzxrL','ChjLCgfYzuvUDMLYB25Tzw50','y2XLyxjfBNzPCM9UBwvUDa','CNvUswq','CMvZDgfYDa','tufoquDfrf9bq1rjvKu','mtiXmtK1mtDZB3Hlz3a','C2vZC2LVBI5Yzw1VDMu','Bw9KzwXZ','CMvHzenVBNrLEhrvC2fNzq','C3rYAw5N','zxHLy3v0zuDSB2jHBenVBw1HBMq','zgvMyxvSDevMzM9YDa','ChjVBw90zq','mtu4mZK4mwrAuM9Stq','DxbKyxrL','y2XLyxi','uLvotKvsx1jfu1vnrv9gquLmruq','q09ervHFu0vduKvux0vovKLst05nru5ux0nptKzmsunu','zgLZCgXHEu5HBwu','C2f2zu5HDgL2zvnLC3nPB25nzxrHzgf0yq','DMvYC2LVBG','y29UzMLNDxjLrw52AxjVBM1LBNq','zMXHDe1HCa','BMf0AxzL','mtKZntuZnvfKz2zmza','D29YA3nWywnLCW','B2jQzwn0','CMvXDwvZDa','DNnJB2rL','DhjPBq','CMvZB2X2zq','CNvUBMvYvgL0Bgu','y3DK','ywnJzxnZ','C3vJy2vZC2z1Ba','C3vWCg9YDhndB25MAwD1CMf0Aw9U','zgvMyxvSDenVBMzPz3vYyxrPB24','C2vZC2LVBI5WAw4','ChjVzMLSzunSAwvUDezHy3rVCNK','uLvotKvsx1voqvzbsuXbqKXf','ChjVAMvJDgvKuNvUBMvYvgL0Bgu','yxbWCM92ywWUCMvZCg9Uza','BwnWq29UzMLNDxjHDgLVBG','DxnLCKLUChv0CW','q09ervHFtu9eruXtx0nvuLnpuL9srvbfqvrfra','u1resu8','ChjVzMLSzunHy2HLvgLTzxjZ','z2vUzxjHDgvKx2LTywDLCW','tKfusvzf','ywrK','BwvZC2fNzq','ChjVzMLSzunSAwvUDhm','CMvZCg9Uza','nZK0tgD2wMvt','BM93','otiYs1DnsvPk','B25oB3rPzMLJyxrPB24','yxjNCW','ywnJzxnZt3b0Aw9UCW','quXmx1DpuKTtuefdrvm','zgvYAxzLza','zgf0yq','DgL0Bgu','C2v0','CNvUBMvYlMnVzgv4lM1VzgvSCY5YzwzYzxnOlwzHAwXLza','C3vWCg9YDgvKuMvHC29UAw5NrwzMB3j0CW','Aw50zxjYDxb0vhvYBG','CMvMCMvZAenVzgv4uhjVzMLSzq','BgLUDxG','zMLSDgvY'];_0x5c9b=function(){return _0xa20b4;};return _0x5c9b();}function _0xa01e(_0x3e9fe7,_0x4e3492){_0x3e9fe7=_0x3e9fe7-(-0x8cd*0x3+0x146*0xc+0xbb9);const _0x124937=_0x5c9b();let _0x57e14e=_0x124937[_0x3e9fe7];if(_0xa01e['qpuxcI']===undefined){var _0xdcdc20=function(_0x1e03ad){const _0x1d5fbf='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x158faf='',_0x40e643='';for(let _0x2a94ad=0x2*-0x482+-0xf79+0x187d,_0x291105,_0x156443,_0x174c34=-0x1*-0x1eb2+0x226a+-0x411c;_0x156443=_0x1e03ad['charAt'](_0x174c34++);~_0x156443&&(_0x291105=_0x2a94ad%(-0x2240+0x1d05+0x11*0x4f)?_0x291105*(0x49a+-0x1*-0x86b+-0x1d3*0x7)+_0x156443:_0x156443,_0x2a94ad++%(0x6e+0x2030+0xade*-0x3))?_0x158faf+=String['fromCharCode'](-0x1758+-0x261f+0x3e76&_0x291105>>(-(0x10c*-0x8+-0x24ea+0x1*0x2d4c)*_0x2a94ad&-0x1*-0x1d11+-0x2078+0x36d)):0xbf0+0x13f5*-0x1+0x805*0x1){_0x156443=_0x1d5fbf['indexOf'](_0x156443);}for(let _0x4ab096=-0xc89*-0x1+-0x15*-0x7+-0x347*0x4,_0x48e8fc=_0x158faf['length'];_0x4ab096<_0x48e8fc;_0x4ab096++){_0x40e643+='%'+('00'+_0x158faf['charCodeAt'](_0x4ab096)['toString'](0x2419*-0x1+0x1eb*0x3+0x1e68))['slice'](-(0xd96+-0x766+0x71*-0xe));}return decodeURIComponent(_0x40e643);};_0xa01e['TpMLlV']=_0xdcdc20,_0xa01e['LMUtAe']={},_0xa01e['qpuxcI']=!![];}const _0x100fb8=_0x124937[0x1d9*0x1+0x255f+-0x4*0x9ce];_0xa01e['aWOvlr']!==_0x100fb8&&(_0xa01e['LMUtAe']={},_0xa01e['aWOvlr']=_0x100fb8);const _0x1e0627=_0xa01e['LMUtAe'][_0x3e9fe7];return _0x1e0627===undefined?(_0x57e14e=_0xa01e['TpMLlV'](_0x57e14e),_0xa01e['LMUtAe'][_0x3e9fe7]=_0x57e14e):_0x57e14e=_0x1e0627,_0x57e14e;}import{CodexAppServerClient,isCodexRolloutMissingError}from'../codex-app-server.js';import{AbstractRunner}from'./abstract-runner.js';import{declaredRunnerProfiles}from'../runner-profiles.js';import{homedir}from'node:os';import{resolve}from'node:path';import{createHash}from'node:crypto';import{discoverAllNativeSessions}from'../native-session-history.js';import{readCodexNativeContextUsage}from'../native-session-history.js';import{codexThreadCwd,deduplicateDirectSessions,extractCodexThreads,isWithinWorkspace,latestNativeActivity}from'./codex/conversation-parser.js';import{codexSessionControl}from'../codex-app-server.js';import{extractId}from'../util/runner-native-session-parsers.js';import{nodeLog}from'../operational.js';const CODEX_MODEL_CACHE_MS=(0x8e2+0x23ea*-0x1+-0x6*-0x483)*(-0x4d0+-0x2c*0x40+0x100c)*(0x8*0x2da+0xbe5+-0x1*0x1ecd),CODEX_PROFILE_ENTRY_TTL_MS=(0xcfe*0x2+-0x13ee+-0x5f0)*(0xf26+0x20d9+-0x2fc3)*(-0x2394+-0x1ac1+0x223*0x1f),CODEX_MODEL_FAILURE_RETRY_MS=(0x157*-0xc+0x1f46+-0x2*0x78a)*(-0x6d*0x1a+-0x21a5+0x309f*0x1),CODEX_MODEL_PAGE_SIZE=0x1*0x21+-0x271*-0xd+-0x9e*0x33;export class CodexRunner extends AbstractRunner{[_0x491b3d(0x14d)];[_0x491b3d(0xc0)];[_0x491b3d(0x163)]=_0x491b3d(0x10a);[_0x491b3d(0x12a)]=_0x491b3d(0xd5);[_0x491b3d(0x15d)]=new CodexExecutionState();[_0x491b3d(0x12d)]=![];[_0x491b3d(0xf1)];[_0x491b3d(0xfe)]=new Set();[_0x491b3d(0x153)]=new Map();[_0x491b3d(0xc8)]=new Map();[_0x491b3d(0x14b)]=new Map();[_0x491b3d(0xcd)]=new Set();[_0x491b3d(0x150)]=new Map();[_0x491b3d(0xed)];[_0x491b3d(0x105)];constructor(_0x2a4f5b=new CodexAppServerClient(),_0x4de53b=()=>new CodexAppServerClient()){const _0x50fd6f=_0x491b3d;super(),this[_0x50fd6f(0x14d)]=_0x2a4f5b,this[_0x50fd6f(0xc0)]=_0x4de53b;}[_0x491b3d(0x13c)](_0x56f953){const _0x52c05a=_0x491b3d,_0xb8afcc=declaredRunnerProfiles({'codexAvailable':_0x56f953[_0x52c05a(0x10a)][_0x52c05a(0x104)],'claudeCodeAvailable':_0x56f953[_0x52c05a(0x125)][_0x52c05a(0x104)],'openCodeAvailable':_0x56f953[_0x52c05a(0x122)]?.[_0x52c05a(0x104)]===!![]})[_0x52c05a(0xe8)](_0x1b5652=>_0x1b5652[_0x52c05a(0xe0)]===this[_0x52c05a(0x163)]);return{..._0xb8afcc,'models':this[_0x52c05a(0xed)]?.[_0x52c05a(0x13c)][_0x52c05a(0xa1)]??[]};}async[_0x491b3d(0x110)](_0x24283f,_0x182ecc,_0x55cb09={}){const _0x42f52a=_0x491b3d;void _0x182ecc;const _0x1f65a5=this[_0x42f52a(0x13c)](_0x24283f);if(!_0x24283f[_0x42f52a(0x10a)][_0x42f52a(0x104)])return{..._0x1f65a5,'models':[]};const _0x153895=codexEnvironmentFingerprint(_0x55cb09,_0x24283f[_0x42f52a(0x10a)][_0x42f52a(0xae)]);this[_0x42f52a(0x150)][_0x42f52a(0xd9)](codexSecretEnvironmentFingerprint(_0x55cb09),_0x153895),this[_0x42f52a(0x105)]=_0x153895;const _0x399416=Date[_0x42f52a(0xd0)](),_0x43e4b8=this[_0x42f52a(0x153)][_0x42f52a(0x15e)](_0x153895);if(_0x43e4b8?.[_0x42f52a(0xbc)]===!![]&&_0x399416<_0x43e4b8[_0x42f52a(0x126)]+CODEX_MODEL_CACHE_MS)return this[_0x42f52a(0x100)](_0x153895,_0x43e4b8);if(_0x43e4b8?.[_0x42f52a(0xbc)]===!![]){if(_0x399416>=_0x43e4b8[_0x42f52a(0x11d)])void this[_0x42f52a(0xdd)](_0x153895,_0x1f65a5,_0x55cb09);return this[_0x42f52a(0x100)](_0x153895,_0x43e4b8);}if(_0x43e4b8!==undefined&&_0x399416<_0x43e4b8[_0x42f52a(0x11d)])return _0x43e4b8[_0x42f52a(0x13c)];return this[_0x42f52a(0xdd)](_0x153895,_0x1f65a5,_0x55cb09);}[_0x491b3d(0xdd)](_0xe82e8b,_0x38f068,_0x226167){const _0x12fe0e=_0x491b3d,_0x1f3c32=this[_0x12fe0e(0x14b)][_0x12fe0e(0x15e)](_0xe82e8b);if(_0x1f3c32!==undefined)return _0x1f3c32;const _0x4c6964=this[_0x12fe0e(0x102)](_0x38f068,_0x226167)[_0x12fe0e(0xef)](_0xbab116=>{const _0x19ed9d=_0x12fe0e,_0x1db037={..._0xbab116,'fetchedAt':Date[_0x19ed9d(0xd0)](),'successful':!![],'retryAt':0x0};this[_0x19ed9d(0x14e)](_0xe82e8b,_0x1db037);if(this[_0x19ed9d(0x105)]===_0xe82e8b)this[_0x19ed9d(0xed)]=_0x1db037;return _0x1db037[_0x19ed9d(0x13c)];})[_0x12fe0e(0x157)](_0x54dfb9=>{const _0x370bc2=_0x12fe0e;nodeLog(_0x370bc2(0xda),{'error':_0x54dfb9 instanceof Error?_0x54dfb9[_0x370bc2(0xcc)]:String(_0x54dfb9)});const _0x351f9f=this[_0x370bc2(0x153)][_0x370bc2(0x15e)](_0xe82e8b);if(_0x351f9f!==undefined)return _0x351f9f[_0x370bc2(0x11d)]=Date[_0x370bc2(0xd0)]()+CODEX_MODEL_FAILURE_RETRY_MS,_0x351f9f[_0x370bc2(0x13c)];return this[_0x370bc2(0x14e)](_0xe82e8b,{'profile':{..._0x38f068,'models':[]},'defaultConfiguration':emptyCodexConfiguration(),'fetchedAt':0x0,'successful':![],'retryAt':Date[_0x370bc2(0xd0)]()+CODEX_MODEL_FAILURE_RETRY_MS}),{..._0x38f068,'models':[]};})[_0x12fe0e(0x10e)](()=>this[_0x12fe0e(0x14b)][_0x12fe0e(0x16b)](_0xe82e8b));return this[_0x12fe0e(0x14b)][_0x12fe0e(0xd9)](_0xe82e8b,_0x4c6964),_0x4c6964;}[_0x491b3d(0x100)](_0x24c37b,_0x34f6b1){const _0xe734c6=_0x491b3d;if(_0x34f6b1[_0xe734c6(0xbc)]&&this[_0xe734c6(0x105)]===_0x24c37b)this[_0xe734c6(0xed)]=_0x34f6b1;return _0x34f6b1[_0xe734c6(0x13c)];}[_0x491b3d(0x14e)](_0x5e4ba3,_0x5f34af){const _0x4e77ad=_0x491b3d,_0xf316ca=this[_0x4e77ad(0xc8)][_0x4e77ad(0x15e)](_0x5e4ba3);if(_0xf316ca!==undefined)clearTimeout(_0xf316ca);this[_0x4e77ad(0x153)][_0x4e77ad(0xd9)](_0x5e4ba3,_0x5f34af);const _0x43e46d=setTimeout(()=>{const _0x36713d=_0x4e77ad;this[_0x36713d(0xc8)][_0x36713d(0x16b)](_0x5e4ba3),this[_0x36713d(0x153)][_0x36713d(0x16b)](_0x5e4ba3);for(const [_0x1902d3,_0x4b1884]of this[_0x36713d(0x150)])if(_0x4b1884===_0x5e4ba3)this[_0x36713d(0x150)][_0x36713d(0x16b)](_0x1902d3);this[_0x36713d(0x105)]===_0x5e4ba3&&(this[_0x36713d(0x105)]=undefined,this[_0x36713d(0xed)]=undefined);},CODEX_PROFILE_ENTRY_TTL_MS);_0x43e46d[_0x4e77ad(0x115)](),this[_0x4e77ad(0xc8)][_0x4e77ad(0xd9)](_0x5e4ba3,_0x43e46d);}async[_0x491b3d(0x102)](_0x452919,_0x2ba46c){const _0x24fee4=_0x491b3d,_0x22b5bb=this[_0x24fee4(0xc0)]();this[_0x24fee4(0xcd)][_0x24fee4(0xcb)](_0x22b5bb);if(Object[_0x24fee4(0x156)](_0x2ba46c)[_0x24fee4(0xfb)]>0x91b+0x184d*-0x1+0x2*0x799)_0x22b5bb[_0x24fee4(0xaf)](_0x2ba46c);try{await _0x22b5bb[_0x24fee4(0xea)]();const _0x3a27b1=[];let _0x3753ea=null;const _0x4741af=new Set();do{const _0x15a312=codexModelPage(await _0x22b5bb[_0x24fee4(0x169)]({'cursor':_0x3753ea,'limit':CODEX_MODEL_PAGE_SIZE,'includeHidden':![]}));_0x3a27b1[_0x24fee4(0x103)](..._0x15a312[_0x24fee4(0xa1)]),_0x3753ea=_0x15a312[_0x24fee4(0x12e)];if(_0x3753ea!==null&&_0x4741af[_0x24fee4(0x147)](_0x3753ea))throw new Error(_0x24fee4(0xc6));if(_0x3753ea!==null)_0x4741af[_0x24fee4(0xcb)](_0x3753ea);}while(_0x3753ea!==null);const _0x1feb6e=_0x3a27b1[_0x24fee4(0xdf)]((_0x1d313f,_0x2ff0a6)=>_0x3a27b1[_0x24fee4(0x138)](_0x3ec14e=>_0x3ec14e[_0x24fee4(0x111)]===_0x1d313f[_0x24fee4(0x111)])===_0x2ff0a6),_0x26a4eb=_0x1feb6e[_0x24fee4(0x117)](_0x52ef45=>({'id':_0x52ef45[_0x24fee4(0x111)],'label':_0x52ef45[_0x24fee4(0xac)],'supportedEfforts':[..._0x52ef45[_0x24fee4(0x118)]],'isDefault':_0x52ef45[_0x24fee4(0x15b)],'defaultEffort':_0x52ef45[_0x24fee4(0xa5)]})),_0x188b2b=_0x1feb6e[_0x24fee4(0xe8)](_0x48a612=>_0x48a612[_0x24fee4(0x15b)])??_0x1feb6e[-0x1*-0x15ce+-0x1cf1+0x723];return{'profile':{..._0x452919,'models':_0x26a4eb},'defaultConfiguration':_0x188b2b===undefined?emptyCodexConfiguration():{'runner':this[_0x24fee4(0x163)],'model':_0x188b2b[_0x24fee4(0x111)],'effort':_0x188b2b[_0x24fee4(0xa5)],'access':_0x24fee4(0x136)}};}finally{if(this[_0x24fee4(0xcd)][_0x24fee4(0x16b)](_0x22b5bb))_0x22b5bb[_0x24fee4(0x13f)]();}}[_0x491b3d(0x104)](_0x5f26da){const _0x1ffd9e=_0x491b3d;return _0x5f26da[_0x1ffd9e(0x10a)][_0x1ffd9e(0x104)];}[_0x491b3d(0xa4)](_0xc4c9c,_0x417db4){const _0x33f806=_0x491b3d;if(_0xc4c9c!==_0x33f806(0x14c)||!/^\/fast(?:\s+(on|off|status))?\s*$/i[_0x33f806(0x128)](_0x417db4))throw new Error(_0x33f806(0x101));const _0x5f0190=_0x417db4[_0x33f806(0xb7)]()[_0x33f806(0x10d)](/\s+/,0x1069*0x1+0x1829*0x1+-0x2890)[0x102*0x23+-0x740+-0x957*0x3]?.[_0x33f806(0x132)]()??_0x33f806(0x151);if(_0x5f0190==='on')this[_0x33f806(0x12d)]=!![];else{if(_0x5f0190===_0x33f806(0xe1))this[_0x33f806(0x12d)]=![];}return{'command':_0x33f806(0x14c),'enabled':this[_0x33f806(0x12d)]};}[_0x491b3d(0x12c)](){const _0x2c76b1=_0x491b3d;return this[_0x2c76b1(0x12d)]?_0x2c76b1(0x14c):undefined;}[_0x491b3d(0xc4)](_0x4154aa,_0x3bc34e){const _0x1060ce=_0x491b3d,_0x56e27f=super[_0x1060ce(0xc4)](_0x4154aa,_0x3bc34e);return Object[_0x1060ce(0xe9)](_0x56e27f[_0x1060ce(0x117)](_0x383e2c=>[_0x383e2c[_0x1060ce(0x163)],_0x383e2c[_0x1060ce(0x113)]===_0x1060ce(0xc7)?{'command':_0x383e2c[_0x1060ce(0x10f)],'args':[..._0x383e2c[_0x1060ce(0xd3)]??[]],'env':{..._0x383e2c[_0x1060ce(0x152)]??{}}}:{'url':_0x383e2c[_0x1060ce(0x11b)],'http_headers':{..._0x383e2c[_0x1060ce(0x141)]??{}}}]));}[_0x491b3d(0x123)](){return!![];}async[_0x491b3d(0xf2)](_0x4d2d71,_0x5ef25c,_0x37057a){const _0x473127=_0x491b3d;if(_0x4d2d71[_0x473127(0x160)]===null)return;_0x5ef25c[_0x473127(0xd8)]!==undefined&&(await this[_0x473127(0xea)](),await this[_0x473127(0x112)](_0x4d2d71[_0x473127(0x160)],_0x5ef25c[_0x473127(0xd8)]??'')),_0x37057a[_0x473127(0xad)]({'runner':this[_0x473127(0x163)],'externalSessionId':_0x4d2d71[_0x473127(0x160)],'workspaceId':_0x4d2d71[_0x473127(0xff)],..._0x5ef25c[_0x473127(0xd8)]===undefined?{}:{'runnerTitle':_0x5ef25c[_0x473127(0xd8)]},..._0x5ef25c[_0x473127(0xd8)]===undefined?{}:{'runnerTitlePending':_0x5ef25c[_0x473127(0xd8)]!==null&&_0x5ef25c[_0x473127(0xd8)][_0x473127(0xb7)]()[_0x473127(0xfb)]>-0x19ea+-0xe79+0x2863},..._0x5ef25c[_0x473127(0x13b)]===undefined?{}:{'pinned':_0x5ef25c[_0x473127(0x13b)]}});}[_0x491b3d(0xc2)](_0x21b702,_0x5dfb5c,_0x2cebb1){const _0x5081d5=_0x491b3d,_0x12e901=_0x21b702?.[_0x5081d5(0xb9)]??null;if(_0x5dfb5c[_0x5081d5(0x155)]!==_0x5081d5(0x13d)||_0x5dfb5c[_0x5081d5(0xd8)]===undefined)return _0x12e901??_0x5dfb5c[_0x5081d5(0xd8)]??null;if(_0x21b702?.[_0x5081d5(0x137)]===!![]){if(_0x5dfb5c[_0x5081d5(0xd8)]===_0x12e901)_0x2cebb1?.[_0x5081d5(0xad)]({'runner':this[_0x5081d5(0x163)],'externalSessionId':_0x5dfb5c[_0x5081d5(0x160)],'workspaceId':_0x5dfb5c[_0x5081d5(0xff)],'runnerTitle':_0x12e901,'runnerTitlePending':![]});return _0x12e901??_0x5dfb5c[_0x5081d5(0xd8)];}return _0x5dfb5c[_0x5081d5(0xd8)];}async[_0x491b3d(0x13a)](_0x561b35){const _0x3c3252=_0x491b3d,_0x115508=await _0x561b35[_0x3c3252(0xb1)]();return _0x115508===undefined?undefined:{..._0x115508,'source':_0x3c3252(0xb1)};}[_0x491b3d(0x168)](){return!![];}async[_0x491b3d(0x16a)](_0x30a2ce,_0x5dfda2){const _0x4daa1f=_0x491b3d;return void _0x30a2ce,await this[_0x4daa1f(0xea)](),extractCodexThreads(await this[_0x4daa1f(0xfc)]())[_0x4daa1f(0xe8)](_0x495046=>_0x495046['id']===_0x5dfda2)?.[_0x4daa1f(0xd8)];}[_0x491b3d(0xe5)](_0x2f0ad9){const _0x4d6d55=_0x491b3d;return[_0x2f0ad9[_0x4d6d55(0xba)],..._0x2f0ad9[_0x4d6d55(0x160)]===null?[]:[resolve(homedir(),_0x4d6d55(0x15a),_0x4d6d55(0xc9),_0x2f0ad9[_0x4d6d55(0x160)])]];}[_0x491b3d(0x124)](_0x367ad1){const _0x442cde=_0x491b3d;return this[_0x442cde(0x15d)][_0x442cde(0xeb)][_0x442cde(0x15e)](_0x367ad1)?.[_0x442cde(0x9c)];}[_0x491b3d(0x135)](){const _0x1f37ce=_0x491b3d;return this[_0x1f37ce(0x13c)]({'platform':_0x1f37ce(0xde),'architecture':_0x1f37ce(0xe4),'nodeAppVersion':_0x1f37ce(0xe4),'nodeVersion':_0x1f37ce(0xe4),'codex':{'available':!![]},'claudeCode':{'available':![]},'openCode':{'available':![]}});}[_0x491b3d(0xbe)](_0x2070db,_0x2e412b){const _0x67c9a4=_0x491b3d;return this[_0x67c9a4(0x109)](_0x2e412b)?.[_0x67c9a4(0xbe)]??emptyCodexConfiguration();}[_0x491b3d(0xbd)](_0x293170,_0x5cbee0,_0x33e9bd){const _0x579c76=_0x491b3d;if(_0x293170[_0x579c76(0xe0)]!==this[_0x579c76(0x163)])return![];const _0x4504eb=this[_0x579c76(0x109)](_0x33e9bd)?.[_0x579c76(0x13c)];return _0x4504eb!==undefined&&_0x4504eb[_0x579c76(0xa1)][_0x579c76(0x161)](_0x3c1841=>_0x3c1841['id']===_0x293170[_0x579c76(0x111)]&&_0x3c1841[_0x579c76(0x118)][_0x579c76(0x10c)](_0x293170[_0x579c76(0x11e)]))&&_0x4504eb[_0x579c76(0xd4)][_0x579c76(0x161)](_0x56d2c9=>_0x56d2c9['id']===_0x293170[_0x579c76(0xbb)]);}[_0x491b3d(0x109)](_0x15f01a){const _0x3d98f3=_0x491b3d;if(_0x15f01a===undefined)return this[_0x3d98f3(0xed)];const _0x20a718=this[_0x3d98f3(0x150)][_0x3d98f3(0x15e)](codexSecretEnvironmentFingerprint(_0x15f01a));return _0x20a718===undefined?undefined:this[_0x3d98f3(0x153)][_0x3d98f3(0x15e)](_0x20a718);}async[_0x491b3d(0x159)](_0x3cec73,_0x454c53){const _0x58e266=_0x491b3d;if(_0x3cec73[_0x58e266(0xe0)]!==this[_0x58e266(0x163)]||_0x3cec73[_0x58e266(0x144)]!==_0x58e266(0x106)||_0x3cec73[_0x58e266(0x160)]===null||!_0x454c53[_0x58e266(0x104)])return{'failureCode':_0x58e266(0xc1)};try{await this[_0x58e266(0x108)](_0x3cec73[_0x58e266(0x160)],_0x3cec73[_0x58e266(0xba)]);const _0x4a1a66=_0x454c53[_0x58e266(0xf5)](_0x3cec73);if(_0x4a1a66!==undefined){const _0xfd03f8=_0x454c53[_0x58e266(0xa6)](_0x4a1a66['id']);if(_0xfd03f8!==undefined)return{'activity':_0x58e266(0x121),'session':_0x454c53[_0x58e266(0x12b)](_0xfd03f8)};}return{'activity':_0x58e266(0x121),'session':_0x454c53[_0x58e266(0xf0)](_0x3cec73)};}catch{return{'activity':_0x58e266(0xf3),'failureCode':_0x58e266(0xaa)};}}async[_0x491b3d(0x165)](_0x2b9b2a,_0x324c03){const _0x57dfe5=_0x491b3d;let _0xe3ffcf=[];try{await this[_0x57dfe5(0xea)](),_0xe3ffcf=extractCodexThreads(await this[_0x57dfe5(0xfc)]());}catch{}const _0x5e7854=[];for(const _0x3f9598 of _0xe3ffcf){if(_0x3f9598[_0x57dfe5(0xd6)]||_0x3f9598[_0x57dfe5(0x119)]!==_0x57dfe5(0xf6)&&_0x3f9598[_0x57dfe5(0x119)]!==_0x57dfe5(0xb6))continue;let _0x2e2ad3;try{_0x2e2ad3=codexThreadCwd(_0x3f9598[_0x57dfe5(0xba)]);}catch{continue;}const _0x1a8467=_0x324c03??_0x2b9b2a[_0x57dfe5(0xb3)][_0x57dfe5(0xe8)](_0x58e4ab=>isWithinWorkspace(_0x2e2ad3,_0x58e4ab[_0x57dfe5(0x13e)]));if(_0x1a8467===undefined||!isWithinWorkspace(_0x2e2ad3,_0x1a8467[_0x57dfe5(0x13e)]))continue;_0x5e7854[_0x57dfe5(0x103)](_0x2b9b2a[_0x57dfe5(0x158)]({'workspace':_0x1a8467,'runner':this[_0x57dfe5(0x163)],'externalSessionId':_0x3f9598['id'],'cwd':_0x2e2ad3,..._0x3f9598[_0x57dfe5(0xd8)]===undefined?{}:{'title':_0x3f9598[_0x57dfe5(0xd8)]},'titleOrigin':_0x57dfe5(0x13d)}));}for(const _0x157ce8 of await discoverAllNativeSessions(this[_0x57dfe5(0x163)])){const _0x2e46dd=_0x324c03??_0x2b9b2a[_0x57dfe5(0xb3)][_0x57dfe5(0xe8)](_0x1fb887=>isWithinWorkspace(_0x157ce8[_0x57dfe5(0xba)],_0x1fb887[_0x57dfe5(0x13e)]));if(_0x2e46dd===undefined||!isWithinWorkspace(_0x157ce8[_0x57dfe5(0xba)],_0x2e46dd[_0x57dfe5(0x13e)]))continue;const _0x5ecbfb=_0x2b9b2a[_0x57dfe5(0x158)]({'workspace':_0x2e46dd,'runner':this[_0x57dfe5(0x163)],'externalSessionId':_0x157ce8[_0x57dfe5(0x160)],'cwd':_0x157ce8[_0x57dfe5(0xba)],..._0x157ce8[_0x57dfe5(0xd8)]===undefined?{}:{'title':_0x157ce8[_0x57dfe5(0xd8)]},'titleOrigin':_0x57dfe5(0xca),'lastActivityAt':latestNativeActivity(_0x157ce8)}),_0x28c605=_0x5e7854[_0x57dfe5(0x138)](_0x1fc280=>_0x1fc280['id']===_0x5ecbfb['id']);if(_0x28c605<0xe1a+-0x42f+-0x9eb)_0x5e7854[_0x57dfe5(0x103)](_0x5ecbfb);else{const _0x34891f=_0x5e7854[_0x28c605];_0x5e7854[_0x28c605]=_0x34891f[_0x57dfe5(0xb9)]===null?_0x5ecbfb:{..._0x5ecbfb,'runnerTitle':_0x34891f[_0x57dfe5(0xb9)],'titleSource':_0x34891f[_0x57dfe5(0xfd)]};}}return deduplicateDirectSessions(_0x5e7854);}[_0x491b3d(0xa2)](_0x3c4cbd){const _0x55fa5d=_0x491b3d;return _0x3c4cbd[_0x55fa5d(0x160)]===null?Promise[_0x55fa5d(0xb8)](undefined):readCodexNativeContextUsage(_0x3c4cbd[_0x55fa5d(0xba)],_0x3c4cbd[_0x55fa5d(0x160)]);}[_0x491b3d(0x14f)](_0x209ac1,_0x5631c2,_0x23fbc3){const _0x3f8516=_0x491b3d,_0x339815=[...this[_0x3f8516(0x15d)][_0x3f8516(0x130)][_0x3f8516(0x14a)]()][_0x3f8516(0x161)](_0x80dffa=>_0x80dffa[_0x3f8516(0xf8)]===_0x209ac1['id']&&_0x80dffa[_0x3f8516(0x10b)]!==undefined),_0x141942=codexSessionControl({'available':_0x5631c2[_0x3f8516(0x10a)][_0x3f8516(0x104)],'nativeThreadId':_0x209ac1[_0x3f8516(0x160)],'nativeControl':_0x209ac1[_0x3f8516(0x144)],'activeTurn':_0x339815}),_0x37307c=!_0x5631c2[_0x3f8516(0x10a)][_0x3f8516(0x104)]?_0x3f8516(0xf3):_0x23fbc3[_0x3f8516(0x15f)]?_0x3f8516(0x9e):_0x209ac1[_0x3f8516(0x144)]===_0x3f8516(0x106)?_0x23fbc3[_0x3f8516(0x149)]??_0x3f8516(0x121):_0x3f8516(0x121);return{'control':_0x141942,'activity':_0x37307c,'commandStates':_0x23fbc3[_0x3f8516(0x146)],'runtime':{'level':_0x141942[_0x3f8516(0x127)],'capabilities':[..._0x141942[_0x3f8516(0x154)],..._0x141942[_0x3f8516(0x127)]===_0x3f8516(0xec)?[_0x3f8516(0x164),_0x3f8516(0xe7),_0x3f8516(0xc3)]:[],_0x3f8516(0x167),_0x3f8516(0xa0),_0x3f8516(0xbf),..._0x209ac1[_0x3f8516(0x160)]===null?[]:[_0x3f8516(0x139)]],'reasonCode':_0x141942[_0x3f8516(0x127)]===_0x3f8516(0xf3)?_0x3f8516(0xc1):null}};}[_0x491b3d(0xd2)](_0x138faa){const _0x11bf3e=_0x491b3d;return this[_0x11bf3e(0x14d)][_0x11bf3e(0xd2)](_0x138faa);}[_0x491b3d(0xea)](){const _0x41ea9b=_0x491b3d;return this[_0x41ea9b(0x14d)][_0x41ea9b(0xea)]();}async[_0x491b3d(0x114)](_0x2fbc82,_0x4cc3ab){const _0xb0c120=_0x491b3d;if(!isCodexRolloutMissingError(_0x4cc3ab))return![];if([...this[_0xb0c120(0xfe)]][_0xb0c120(0x161)](_0x2ee244=>_0x2ee244!==_0x2fbc82))return![];if([...this[_0xb0c120(0x15d)][_0xb0c120(0x130)][_0xb0c120(0x156)]()][_0xb0c120(0x161)](_0x25b886=>_0x25b886!==_0x2fbc82))return![];return nodeLog(_0xb0c120(0x131),{'runId':_0x2fbc82}),await this[_0xb0c120(0x14d)][_0xb0c120(0x9d)](),!![];}[_0x491b3d(0x9a)](_0x40047e,_0x360bb9){const _0x3c626a=_0x491b3d;if(Object[_0x3c626a(0x156)](_0x40047e)[_0x3c626a(0xfb)]===0x161f+-0xe6*-0x17+-0x3*0xe43&&this[_0x3c626a(0xf1)]===undefined){this[_0x3c626a(0xfe)][_0x3c626a(0xcb)](_0x360bb9);return;}const _0x20be9d=createHash(_0x3c626a(0x11f))[_0x3c626a(0xa8)](JSON[_0x3c626a(0xfa)](Object[_0x3c626a(0x11c)](_0x40047e)[_0x3c626a(0xf9)](([_0x3c09bf],[_0x1e51c1])=>_0x3c09bf[_0x3c626a(0x134)](_0x1e51c1))))[_0x3c626a(0xee)](_0x3c626a(0xe6));if(_0x20be9d===this[_0x3c626a(0xf1)]){this[_0x3c626a(0xfe)][_0x3c626a(0xcb)](_0x360bb9);return;}if(this[_0x3c626a(0xfe)][_0x3c626a(0x12f)]>-0x174+0x11ab*0x1+-0x1037||this[_0x3c626a(0x15d)][_0x3c626a(0x130)][_0x3c626a(0x12f)]>-0x1a41+0x1f3a+0x1*-0x4f9)throw new Error(_0x3c626a(0xab));this[_0x3c626a(0x14d)][_0x3c626a(0x13f)](),this[_0x3c626a(0x14d)][_0x3c626a(0xaf)](_0x40047e),this[_0x3c626a(0xf1)]=_0x20be9d,this[_0x3c626a(0xfe)][_0x3c626a(0xcb)](_0x360bb9);}[_0x491b3d(0x140)](_0x28c6d2){const _0x51d1d5=_0x491b3d;this[_0x51d1d5(0xfe)][_0x51d1d5(0x16b)](_0x28c6d2);if(this[_0x51d1d5(0xfe)][_0x51d1d5(0x12f)]!==0x12d9+-0x5*0x294+-0x5f5||this[_0x51d1d5(0xf1)]===undefined)return;this[_0x51d1d5(0x14d)][_0x51d1d5(0x13f)](),this[_0x51d1d5(0x14d)][_0x51d1d5(0x9b)](),this[_0x51d1d5(0xf1)]=undefined;}[_0x491b3d(0x13f)](){const _0x8fcc2f=_0x491b3d;for(const _0x2a4ff4 of this[_0x8fcc2f(0xcd)])_0x2a4ff4[_0x8fcc2f(0x13f)]();this[_0x8fcc2f(0xcd)][_0x8fcc2f(0xa9)](),this[_0x8fcc2f(0x14d)][_0x8fcc2f(0x13f)]();if(this[_0x8fcc2f(0xf1)]!==undefined)this[_0x8fcc2f(0x14d)][_0x8fcc2f(0x9b)]();this[_0x8fcc2f(0xf1)]=undefined,this[_0x8fcc2f(0xfe)][_0x8fcc2f(0xa9)]();for(const _0x5d5f33 of this[_0x8fcc2f(0xc8)][_0x8fcc2f(0x14a)]())clearTimeout(_0x5d5f33);this[_0x8fcc2f(0xc8)][_0x8fcc2f(0xa9)](),this[_0x8fcc2f(0x153)][_0x8fcc2f(0xa9)](),this[_0x8fcc2f(0x150)][_0x8fcc2f(0xa9)](),this[_0x8fcc2f(0xed)]=undefined,this[_0x8fcc2f(0x105)]=undefined;}[_0x491b3d(0xb5)](_0x44f722,_0x2f0755){const _0x16f3ea=_0x491b3d;return this[_0x16f3ea(0x14d)][_0x16f3ea(0xb5)](_0x44f722,_0x2f0755);}[_0x491b3d(0xce)](_0x20a27b,_0x355220){const _0x3d5bcd=_0x491b3d;this[_0x3d5bcd(0x14d)][_0x3d5bcd(0xce)](_0x20a27b,_0x355220);}[_0x491b3d(0xfc)](){const _0x73d9f5=_0x491b3d;return this[_0x73d9f5(0x14d)][_0x73d9f5(0xfc)]();}[_0x491b3d(0x148)](_0x9ed114,_0x2696cc){const _0x491f59=_0x491b3d;return this[_0x491f59(0x14d)][_0x491f59(0x148)](_0x9ed114,_0x2696cc);}[_0x491b3d(0xe2)](_0x41c028,_0x245af2,_0x3e5b8e,_0x4af022){const _0x5b7d90=_0x491b3d;return this[_0x5b7d90(0x14d)][_0x5b7d90(0xe2)](_0x41c028,_0x245af2,_0x3e5b8e,_0x4af022);}async[_0x491b3d(0xf7)](_0x87e608,_0x3db228,_0x1e3c9f){const _0x49b3e4=_0x491b3d;if(_0x87e608[_0x49b3e4(0x160)]===null)throw new Error(_0x49b3e4(0x11a));await this[_0x49b3e4(0xea)]();const _0x36e4b0={'model':_0x87e608[_0x49b3e4(0x111)],'effort':_0x87e608[_0x49b3e4(0x11e)],'access':_0x87e608[_0x49b3e4(0xbb)]},_0x3fb92e=_0x3db228===null?await this[_0x49b3e4(0x148)](_0x87e608[_0x49b3e4(0xba)],_0x36e4b0):await this[_0x49b3e4(0xe2)](_0x87e608[_0x49b3e4(0x160)],_0x87e608[_0x49b3e4(0xba)],_0x3db228,_0x36e4b0),_0x3292d5=extractId(_0x3fb92e,_0x49b3e4(0x162));return await this[_0x49b3e4(0x112)](_0x3292d5,_0x1e3c9f),_0x3292d5;}[_0x491b3d(0x108)](_0x299980,_0x16abc5,_0x22cc3a){const _0x1198b5=_0x491b3d;return this[_0x1198b5(0x14d)][_0x1198b5(0x108)](_0x299980,_0x16abc5,_0x22cc3a);}[_0x491b3d(0x145)](_0xc0228b,_0x4dfd40,_0x51c13a,_0x2220f1,_0x37963c){const _0x2b5ea2=_0x491b3d;return this[_0x2b5ea2(0x14d)][_0x2b5ea2(0x145)](_0xc0228b,_0x4dfd40,_0x51c13a,_0x2220f1,_0x37963c);}[_0x491b3d(0xdc)](_0x2860c3,_0x58e62a){const _0x26115d=_0x491b3d;return this[_0x26115d(0x14d)][_0x26115d(0xdc)](_0x2860c3,_0x58e62a);}[_0x491b3d(0x112)](_0x177ded,_0x5be146){const _0x188cd6=_0x491b3d;return this[_0x188cd6(0x14d)][_0x188cd6(0x112)](_0x177ded,_0x5be146);}[_0x491b3d(0x143)](){const _0x40141d=_0x491b3d;return this[_0x40141d(0x14d)][_0x40141d(0x143)]();}}function emptyCodexConfiguration(){const _0x37935e=_0x491b3d;return{'runner':_0x37935e(0x10a),'model':'','effort':'','access':_0x37935e(0x136)};}function codexEnvironmentFingerprint(_0x1455e7,_0x573f3a){const _0x516339=_0x491b3d;return createHash(_0x516339(0x11f))[_0x516339(0xa8)](JSON[_0x516339(0xfa)]({'environment':Object[_0x516339(0x11c)](_0x1455e7)[_0x516339(0xf9)](([_0x2bac5f],[_0x237b57])=>_0x2bac5f[_0x516339(0x134)](_0x237b57)),'version':_0x573f3a??null}))[_0x516339(0xee)](_0x516339(0xe6));}function codexSecretEnvironmentFingerprint(_0x148323){const _0x5f4508=_0x491b3d;return createHash(_0x5f4508(0x11f))[_0x5f4508(0xa8)](JSON[_0x5f4508(0xfa)](Object[_0x5f4508(0x11c)](_0x148323)[_0x5f4508(0xf9)](([_0x5bb160],[_0x51b561])=>_0x5bb160[_0x5f4508(0x134)](_0x51b561))))[_0x5f4508(0xee)](_0x5f4508(0xe6));}function codexModelPage(_0x245810){const _0x29f639=_0x491b3d;if(!isPlainRecord(_0x245810)||!Array[_0x29f639(0x166)](_0x245810[_0x29f639(0xd7)]))throw new Error(_0x29f639(0x129));return{'models':_0x245810[_0x29f639(0xd7)][_0x29f639(0xb0)](_0x107b78=>{const _0x3e43c2=_0x29f639;if(!isPlainRecord(_0x107b78)||_0x107b78[_0x3e43c2(0x120)]===!![])return[];const _0x3727b2=typeof _0x107b78[_0x3e43c2(0x111)]===_0x3e43c2(0xa3)?_0x107b78[_0x3e43c2(0x111)][_0x3e43c2(0xb7)]():'',_0x5d5594=typeof _0x107b78[_0x3e43c2(0xac)]===_0x3e43c2(0xa3)?_0x107b78[_0x3e43c2(0xac)][_0x3e43c2(0xb7)]():'',_0x4c09d9=typeof _0x107b78[_0x3e43c2(0x133)]===_0x3e43c2(0xa3)?_0x107b78[_0x3e43c2(0x133)][_0x3e43c2(0xb7)]():'',_0x2e2c37=Array[_0x3e43c2(0x166)](_0x107b78[_0x3e43c2(0xdb)])?_0x107b78[_0x3e43c2(0xdb)][_0x3e43c2(0xb0)](_0xe23e5f=>isPlainRecord(_0xe23e5f)&&typeof _0xe23e5f[_0x3e43c2(0x15c)]===_0x3e43c2(0xa3)?[_0xe23e5f[_0x3e43c2(0x15c)][_0x3e43c2(0xb7)]()]:[]):[];if(_0x3727b2[_0x3e43c2(0xfb)]===-0x2606+0x1fe*0xd+0x20*0x61||_0x3727b2[_0x3e43c2(0xfb)]>-0x87a+0xc63+-0x123*0x3||_0x5d5594[_0x3e43c2(0xfb)]===0x4a9*-0x6+-0xacf*0x2+0x3194||_0x5d5594[_0x3e43c2(0xfb)]>-0x1bbd+0xbd9+0x1064||_0x4c09d9[_0x3e43c2(0xfb)]===-0x1b7f+-0xfaf+0x2b2e*0x1||_0x4c09d9[_0x3e43c2(0xfb)]>-0x21ac+-0x1*0x1279+0x3465||_0x2e2c37[_0x3e43c2(0xfb)]>0x3*0x16b+0x4cc*0x6+-0x20e9||_0x2e2c37[_0x3e43c2(0x161)](_0x42dc40=>_0x42dc40[_0x3e43c2(0xfb)]===0xfc4+-0x22*-0x86+-0x598*0x6||_0x42dc40[_0x3e43c2(0xfb)]>0x512+0x279+0x74b*-0x1)||!_0x2e2c37[_0x3e43c2(0x10c)](_0x4c09d9))return[];return[{'model':_0x3727b2,'displayName':_0x5d5594,'isDefault':_0x107b78[_0x3e43c2(0x15b)]===!![],'defaultEffort':_0x4c09d9,'supportedEfforts':[...new Set(_0x2e2c37[_0x3e43c2(0xdf)](Boolean))]}];}),'nextCursor':typeof _0x245810[_0x29f639(0x12e)]===_0x29f639(0xa3)&&_0x245810[_0x29f639(0x12e)][_0x29f639(0xfb)]>-0x1af5+-0x7fc+0x22f1?_0x245810[_0x29f639(0x12e)]:null};}function isPlainRecord(_0x3f2720){const _0x5fb0f3=_0x491b3d;return typeof _0x3f2720===_0x5fb0f3(0xb4)&&_0x3f2720!==null&&!Array[_0x5fb0f3(0x166)](_0x3f2720);}export class CodexExecutionState{[_0x491b3d(0x130)]=new Map();[_0x491b3d(0xeb)]=new Map();[_0x491b3d(0xe3)]=new Map();[_0x491b3d(0xc5)]=new Map();}
|
|
1
|
+
import { CodexAppServerClient, isCodexRolloutMissingError } from '../codex-app-server.js';
|
|
2
|
+
import { AbstractRunner } from './abstract-runner.js';
|
|
3
|
+
import { declaredRunnerProfiles } from '../runner-profiles.js';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { resolve } from 'node:path';
|
|
6
|
+
import { createHash } from 'node:crypto';
|
|
7
|
+
import { discoverAllNativeSessions } from '../native-session-history.js';
|
|
8
|
+
import { readCodexNativeContextUsage } from '../native-session-history.js';
|
|
9
|
+
import { codexThreadCwd, deduplicateDirectSessions, extractCodexThreads, isWithinWorkspace, latestNativeActivity } from './codex/conversation-parser.js';
|
|
10
|
+
import { codexSessionControl } from '../codex-app-server.js';
|
|
11
|
+
import { extractId } from '../util/runner-native-session-parsers.js';
|
|
12
|
+
import { nodeLog } from '../operational.js';
|
|
13
|
+
const CODEX_MODEL_CACHE_MS = 10 * 60 * 1_000;
|
|
14
|
+
const CODEX_PROFILE_ENTRY_TTL_MS = 30 * 60 * 1_000;
|
|
15
|
+
const CODEX_MODEL_FAILURE_RETRY_MS = 30 * 1_000;
|
|
16
|
+
const CODEX_MODEL_PAGE_SIZE = 100;
|
|
17
|
+
export class CodexRunner extends AbstractRunner {
|
|
18
|
+
client;
|
|
19
|
+
profileClientFactory;
|
|
20
|
+
name = 'codex';
|
|
21
|
+
discoveryScope = 'ALL_WORKSPACES';
|
|
22
|
+
execution = new CodexExecutionState();
|
|
23
|
+
fastEnabled = false;
|
|
24
|
+
environmentFingerprint;
|
|
25
|
+
environmentRuns = new Set();
|
|
26
|
+
profileCache = new Map();
|
|
27
|
+
profileCacheTimers = new Map();
|
|
28
|
+
profileRefreshes = new Map();
|
|
29
|
+
profileClients = new Set();
|
|
30
|
+
profileKeyByEnvironment = new Map();
|
|
31
|
+
latestProfileCache;
|
|
32
|
+
selectedProfileKey;
|
|
33
|
+
constructor(client = new CodexAppServerClient(), profileClientFactory = () => new CodexAppServerClient()) {
|
|
34
|
+
super();
|
|
35
|
+
this.client = client;
|
|
36
|
+
this.profileClientFactory = profileClientFactory;
|
|
37
|
+
}
|
|
38
|
+
profile(capabilities) {
|
|
39
|
+
const base = declaredRunnerProfiles({
|
|
40
|
+
codexAvailable: capabilities.codex.available,
|
|
41
|
+
claudeCodeAvailable: capabilities.claudeCode.available,
|
|
42
|
+
openCodeAvailable: capabilities.openCode?.available === true
|
|
43
|
+
}).find((profile) => profile.runner === this.name);
|
|
44
|
+
return { ...base, models: this.latestProfileCache?.profile.models ?? [] };
|
|
45
|
+
}
|
|
46
|
+
async refreshProfile(capabilities, workspace, environment = {}) {
|
|
47
|
+
void workspace;
|
|
48
|
+
const base = this.profile(capabilities);
|
|
49
|
+
if (!capabilities.codex.available)
|
|
50
|
+
return { ...base, models: [] };
|
|
51
|
+
const key = codexEnvironmentFingerprint(environment, capabilities.codex.version);
|
|
52
|
+
this.profileKeyByEnvironment.set(codexSecretEnvironmentFingerprint(environment), key);
|
|
53
|
+
this.selectedProfileKey = key;
|
|
54
|
+
const now = Date.now();
|
|
55
|
+
const cached = this.profileCache.get(key);
|
|
56
|
+
if (cached?.successful === true && now < cached.fetchedAt + CODEX_MODEL_CACHE_MS)
|
|
57
|
+
return this.selectCachedProfile(key, cached);
|
|
58
|
+
if (cached?.successful === true) {
|
|
59
|
+
if (now >= cached.retryAt)
|
|
60
|
+
void this.refreshCodexProfile(key, base, environment);
|
|
61
|
+
return this.selectCachedProfile(key, cached);
|
|
62
|
+
}
|
|
63
|
+
if (cached !== undefined && now < cached.retryAt)
|
|
64
|
+
return cached.profile;
|
|
65
|
+
return this.refreshCodexProfile(key, base, environment);
|
|
66
|
+
}
|
|
67
|
+
refreshCodexProfile(key, base, environment) {
|
|
68
|
+
const existing = this.profileRefreshes.get(key);
|
|
69
|
+
if (existing !== undefined)
|
|
70
|
+
return existing;
|
|
71
|
+
const refresh = this.fetchCodexProfile(base, environment)
|
|
72
|
+
.then((value) => {
|
|
73
|
+
const cache = {
|
|
74
|
+
...value,
|
|
75
|
+
fetchedAt: Date.now(),
|
|
76
|
+
successful: true,
|
|
77
|
+
retryAt: 0
|
|
78
|
+
};
|
|
79
|
+
this.cacheProfile(key, cache);
|
|
80
|
+
if (this.selectedProfileKey === key)
|
|
81
|
+
this.latestProfileCache = cache;
|
|
82
|
+
return cache.profile;
|
|
83
|
+
})
|
|
84
|
+
.catch((error) => {
|
|
85
|
+
nodeLog('runner.codex.models.refresh-failed', {
|
|
86
|
+
error: error instanceof Error ? error.message : String(error)
|
|
87
|
+
});
|
|
88
|
+
const cached = this.profileCache.get(key);
|
|
89
|
+
if (cached !== undefined) {
|
|
90
|
+
cached.retryAt = Date.now() + CODEX_MODEL_FAILURE_RETRY_MS;
|
|
91
|
+
return cached.profile;
|
|
92
|
+
}
|
|
93
|
+
this.cacheProfile(key, {
|
|
94
|
+
profile: { ...base, models: [] },
|
|
95
|
+
defaultConfiguration: emptyCodexConfiguration(),
|
|
96
|
+
fetchedAt: 0,
|
|
97
|
+
successful: false,
|
|
98
|
+
retryAt: Date.now() + CODEX_MODEL_FAILURE_RETRY_MS
|
|
99
|
+
});
|
|
100
|
+
return { ...base, models: [] };
|
|
101
|
+
})
|
|
102
|
+
.finally(() => this.profileRefreshes.delete(key));
|
|
103
|
+
this.profileRefreshes.set(key, refresh);
|
|
104
|
+
return refresh;
|
|
105
|
+
}
|
|
106
|
+
selectCachedProfile(key, cached) {
|
|
107
|
+
if (cached.successful && this.selectedProfileKey === key)
|
|
108
|
+
this.latestProfileCache = cached;
|
|
109
|
+
return cached.profile;
|
|
110
|
+
}
|
|
111
|
+
cacheProfile(key, cache) {
|
|
112
|
+
const previousTimer = this.profileCacheTimers.get(key);
|
|
113
|
+
if (previousTimer !== undefined)
|
|
114
|
+
clearTimeout(previousTimer);
|
|
115
|
+
this.profileCache.set(key, cache);
|
|
116
|
+
const timer = setTimeout(() => {
|
|
117
|
+
this.profileCacheTimers.delete(key);
|
|
118
|
+
this.profileCache.delete(key);
|
|
119
|
+
for (const [environmentKey, profileKey] of this.profileKeyByEnvironment)
|
|
120
|
+
if (profileKey === key)
|
|
121
|
+
this.profileKeyByEnvironment.delete(environmentKey);
|
|
122
|
+
if (this.selectedProfileKey === key) {
|
|
123
|
+
this.selectedProfileKey = undefined;
|
|
124
|
+
this.latestProfileCache = undefined;
|
|
125
|
+
}
|
|
126
|
+
}, CODEX_PROFILE_ENTRY_TTL_MS);
|
|
127
|
+
timer.unref();
|
|
128
|
+
this.profileCacheTimers.set(key, timer);
|
|
129
|
+
}
|
|
130
|
+
async fetchCodexProfile(base, environment) {
|
|
131
|
+
const client = this.profileClientFactory();
|
|
132
|
+
this.profileClients.add(client);
|
|
133
|
+
if (Object.keys(environment).length > 0)
|
|
134
|
+
client.configureEnvironment(environment);
|
|
135
|
+
try {
|
|
136
|
+
await client.start();
|
|
137
|
+
const models = [];
|
|
138
|
+
let cursor = null;
|
|
139
|
+
const cursors = new Set();
|
|
140
|
+
do {
|
|
141
|
+
const page = codexModelPage(await client.listModels({ cursor, limit: CODEX_MODEL_PAGE_SIZE, includeHidden: false }));
|
|
142
|
+
models.push(...page.models);
|
|
143
|
+
cursor = page.nextCursor;
|
|
144
|
+
if (cursor !== null && cursors.has(cursor))
|
|
145
|
+
throw new Error('CODEX_MODELS_CURSOR_REPEATED');
|
|
146
|
+
if (cursor !== null)
|
|
147
|
+
cursors.add(cursor);
|
|
148
|
+
} while (cursor !== null);
|
|
149
|
+
const uniqueModels = models.filter((model, index) => models.findIndex((candidate) => candidate.model === model.model) === index);
|
|
150
|
+
const profileModels = uniqueModels.map((model) => ({
|
|
151
|
+
id: model.model,
|
|
152
|
+
label: model.displayName,
|
|
153
|
+
supportedEfforts: [...model.supportedEfforts],
|
|
154
|
+
isDefault: model.isDefault,
|
|
155
|
+
defaultEffort: model.defaultEffort
|
|
156
|
+
}));
|
|
157
|
+
const selected = uniqueModels.find((model) => model.isDefault) ?? uniqueModels[0];
|
|
158
|
+
return {
|
|
159
|
+
profile: { ...base, models: profileModels },
|
|
160
|
+
defaultConfiguration: selected === undefined
|
|
161
|
+
? emptyCodexConfiguration()
|
|
162
|
+
: {
|
|
163
|
+
runner: this.name,
|
|
164
|
+
model: selected.model,
|
|
165
|
+
effort: selected.defaultEffort,
|
|
166
|
+
access: 'on-request'
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
finally {
|
|
171
|
+
if (this.profileClients.delete(client))
|
|
172
|
+
client.stop();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
available(capabilities) {
|
|
176
|
+
return capabilities.codex.available;
|
|
177
|
+
}
|
|
178
|
+
executeGlobalCommand(commandId, input) {
|
|
179
|
+
if (commandId !== 'fast' || !/^\/fast(?:\s+(on|off|status))?\s*$/i.test(input))
|
|
180
|
+
throw new Error('RUNNER_COMMAND_INVALID');
|
|
181
|
+
const argument = input.trim().split(/\s+/, 2)[1]?.toLowerCase() ?? 'status';
|
|
182
|
+
if (argument === 'on')
|
|
183
|
+
this.fastEnabled = true;
|
|
184
|
+
else if (argument === 'off')
|
|
185
|
+
this.fastEnabled = false;
|
|
186
|
+
return { command: 'fast', enabled: this.fastEnabled };
|
|
187
|
+
}
|
|
188
|
+
serviceTier() {
|
|
189
|
+
return this.fastEnabled ? 'fast' : undefined;
|
|
190
|
+
}
|
|
191
|
+
mcpConfiguration(raw, secrets) {
|
|
192
|
+
const servers = super.mcpConfiguration(raw, secrets);
|
|
193
|
+
return Object.fromEntries(servers.map((server) => [
|
|
194
|
+
server.name,
|
|
195
|
+
server.transport === 'STDIO'
|
|
196
|
+
? {
|
|
197
|
+
command: server.command,
|
|
198
|
+
args: [...(server.args ?? [])],
|
|
199
|
+
env: { ...(server.environment ?? {}) }
|
|
200
|
+
}
|
|
201
|
+
: { url: server.url, http_headers: { ...(server.headers ?? {}) } }
|
|
202
|
+
]));
|
|
203
|
+
}
|
|
204
|
+
usesRunnerTitleForRename() {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
async renameNative(session, input, database) {
|
|
208
|
+
if (session.externalSessionId === null)
|
|
209
|
+
return;
|
|
210
|
+
if (input.title !== undefined) {
|
|
211
|
+
await this.start();
|
|
212
|
+
await this.setThreadName(session.externalSessionId, input.title ?? '');
|
|
213
|
+
}
|
|
214
|
+
database.saveNativeSessionMetadata({
|
|
215
|
+
runner: this.name,
|
|
216
|
+
externalSessionId: session.externalSessionId,
|
|
217
|
+
workspaceId: session.workspaceId,
|
|
218
|
+
...(input.title === undefined ? {} : { runnerTitle: input.title }),
|
|
219
|
+
...(input.title === undefined
|
|
220
|
+
? {}
|
|
221
|
+
: { runnerTitlePending: input.title !== null && input.title.trim().length > 0 }),
|
|
222
|
+
...(input.pinned === undefined ? {} : { pinned: input.pinned })
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
projectedRunnerTitle(metadata, input, database) {
|
|
226
|
+
const cached = metadata?.runnerTitle ?? null;
|
|
227
|
+
if (input.titleOrigin !== 'OFFICIAL' || input.title === undefined)
|
|
228
|
+
return cached ?? input.title ?? null;
|
|
229
|
+
if (metadata?.runnerTitlePending === true) {
|
|
230
|
+
if (input.title === cached)
|
|
231
|
+
database?.saveNativeSessionMetadata({
|
|
232
|
+
runner: this.name,
|
|
233
|
+
externalSessionId: input.externalSessionId,
|
|
234
|
+
workspaceId: input.workspaceId,
|
|
235
|
+
runnerTitle: cached,
|
|
236
|
+
runnerTitlePending: false
|
|
237
|
+
});
|
|
238
|
+
return cached ?? input.title;
|
|
239
|
+
}
|
|
240
|
+
return input.title;
|
|
241
|
+
}
|
|
242
|
+
async readConversationHistory(readers) {
|
|
243
|
+
// Codex JSONL is the only source for normal history reads.
|
|
244
|
+
const native = await readers.native();
|
|
245
|
+
return native === undefined ? undefined : { ...native, source: 'native' };
|
|
246
|
+
}
|
|
247
|
+
acceptsTruncatedNativeHistory() {
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
async readManagedRunnerTitle(session, nativeSessionId) {
|
|
251
|
+
void session;
|
|
252
|
+
await this.start();
|
|
253
|
+
return extractCodexThreads(await this.listThreads()).find((thread) => thread.id === nativeSessionId)?.title;
|
|
254
|
+
}
|
|
255
|
+
nativeImageRoots(session) {
|
|
256
|
+
return [
|
|
257
|
+
session.cwd,
|
|
258
|
+
...(session.externalSessionId === null
|
|
259
|
+
? []
|
|
260
|
+
: [resolve(homedir(), '.codex', 'generated_images', session.externalSessionId)])
|
|
261
|
+
];
|
|
262
|
+
}
|
|
263
|
+
managedRunForNativeTurn(nativeTurnId) {
|
|
264
|
+
return this.execution.managedTurns.get(nativeTurnId)?.runId;
|
|
265
|
+
}
|
|
266
|
+
profileForValidation() {
|
|
267
|
+
return this.profile({
|
|
268
|
+
platform: 'linux',
|
|
269
|
+
architecture: 'validation',
|
|
270
|
+
nodeAppVersion: 'validation',
|
|
271
|
+
nodeVersion: 'validation',
|
|
272
|
+
codex: { available: true },
|
|
273
|
+
claudeCode: { available: false },
|
|
274
|
+
openCode: { available: false }
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
defaultConfiguration(_workspace, environment) {
|
|
278
|
+
return (this.profileCacheForEnvironment(environment)?.defaultConfiguration ??
|
|
279
|
+
emptyCodexConfiguration());
|
|
280
|
+
}
|
|
281
|
+
supportsConfiguration(configuration, _workspace, environment) {
|
|
282
|
+
if (configuration.runner !== this.name)
|
|
283
|
+
return false;
|
|
284
|
+
const profile = this.profileCacheForEnvironment(environment)?.profile;
|
|
285
|
+
return (profile !== undefined &&
|
|
286
|
+
profile.models.some((model) => model.id === configuration.model && model.supportedEfforts.includes(configuration.effort)) &&
|
|
287
|
+
profile.accessOptions.some((option) => option.id === configuration.access));
|
|
288
|
+
}
|
|
289
|
+
profileCacheForEnvironment(environment) {
|
|
290
|
+
if (environment === undefined)
|
|
291
|
+
return this.latestProfileCache;
|
|
292
|
+
const key = this.profileKeyByEnvironment.get(codexSecretEnvironmentFingerprint(environment));
|
|
293
|
+
return key === undefined ? undefined : this.profileCache.get(key);
|
|
294
|
+
}
|
|
295
|
+
async resumeExternal(external, context) {
|
|
296
|
+
if (external.runner !== this.name ||
|
|
297
|
+
external.nativeControl !== 'EXTERNAL' ||
|
|
298
|
+
external.externalSessionId === null ||
|
|
299
|
+
!context.available)
|
|
300
|
+
return { failureCode: 'RUNNER_UNAVAILABLE' };
|
|
301
|
+
try {
|
|
302
|
+
await this.resumeThread(external.externalSessionId, external.cwd);
|
|
303
|
+
const projection = context.projectionFor(external);
|
|
304
|
+
if (projection !== undefined) {
|
|
305
|
+
const promoted = context.promote(projection.id);
|
|
306
|
+
if (promoted !== undefined)
|
|
307
|
+
return { activity: 'IDLE', session: context.ensureConfiguration(promoted) };
|
|
308
|
+
}
|
|
309
|
+
return { activity: 'IDLE', session: context.create(external) };
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
return {
|
|
313
|
+
activity: 'UNAVAILABLE',
|
|
314
|
+
failureCode: 'RUNNER_RESUME_FAILED'
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
async discoverSessions(context, workspace) {
|
|
319
|
+
let threads = [];
|
|
320
|
+
try {
|
|
321
|
+
await this.start();
|
|
322
|
+
threads = extractCodexThreads(await this.listThreads());
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
// Native transcripts remain a valid read-only discovery source.
|
|
326
|
+
}
|
|
327
|
+
const sessions = [];
|
|
328
|
+
for (const thread of threads) {
|
|
329
|
+
if (thread.derived || (thread.source !== 'cli' && thread.source !== 'vscode'))
|
|
330
|
+
continue;
|
|
331
|
+
let cwd;
|
|
332
|
+
try {
|
|
333
|
+
cwd = codexThreadCwd(thread.cwd);
|
|
334
|
+
}
|
|
335
|
+
catch {
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
const target = workspace ?? context.workspaces.find((candidate) => isWithinWorkspace(cwd, candidate.path));
|
|
339
|
+
if (target === undefined || !isWithinWorkspace(cwd, target.path))
|
|
340
|
+
continue;
|
|
341
|
+
sessions.push(context.createProjection({
|
|
342
|
+
workspace: target,
|
|
343
|
+
runner: this.name,
|
|
344
|
+
externalSessionId: thread.id,
|
|
345
|
+
cwd,
|
|
346
|
+
...(thread.title === undefined ? {} : { title: thread.title }),
|
|
347
|
+
titleOrigin: 'OFFICIAL'
|
|
348
|
+
}));
|
|
349
|
+
}
|
|
350
|
+
for (const entry of await discoverAllNativeSessions(this.name)) {
|
|
351
|
+
const target = workspace ??
|
|
352
|
+
context.workspaces.find((candidate) => isWithinWorkspace(entry.cwd, candidate.path));
|
|
353
|
+
if (target === undefined || !isWithinWorkspace(entry.cwd, target.path))
|
|
354
|
+
continue;
|
|
355
|
+
const native = context.createProjection({
|
|
356
|
+
workspace: target,
|
|
357
|
+
runner: this.name,
|
|
358
|
+
externalSessionId: entry.externalSessionId,
|
|
359
|
+
cwd: entry.cwd,
|
|
360
|
+
...(entry.title === undefined ? {} : { title: entry.title }),
|
|
361
|
+
titleOrigin: 'NATIVE',
|
|
362
|
+
lastActivityAt: latestNativeActivity(entry)
|
|
363
|
+
});
|
|
364
|
+
const index = sessions.findIndex((candidate) => candidate.id === native.id);
|
|
365
|
+
if (index < 0)
|
|
366
|
+
sessions.push(native);
|
|
367
|
+
else {
|
|
368
|
+
const official = sessions[index];
|
|
369
|
+
sessions[index] =
|
|
370
|
+
official.runnerTitle === null
|
|
371
|
+
? native
|
|
372
|
+
: {
|
|
373
|
+
...native,
|
|
374
|
+
runnerTitle: official.runnerTitle,
|
|
375
|
+
titleSource: official.titleSource
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return deduplicateDirectSessions(sessions);
|
|
380
|
+
}
|
|
381
|
+
readContextUsage(session) {
|
|
382
|
+
return session.externalSessionId === null
|
|
383
|
+
? Promise.resolve(undefined)
|
|
384
|
+
: readCodexNativeContextUsage(session.cwd, session.externalSessionId);
|
|
385
|
+
}
|
|
386
|
+
presentSession(session, capabilities, context) {
|
|
387
|
+
const activeTurn = [...this.execution.runs.values()].some((run) => run.sessionId === session.id && run.turnId !== undefined);
|
|
388
|
+
const control = codexSessionControl({
|
|
389
|
+
available: capabilities.codex.available,
|
|
390
|
+
nativeThreadId: session.externalSessionId,
|
|
391
|
+
nativeControl: session.nativeControl,
|
|
392
|
+
activeTurn
|
|
393
|
+
});
|
|
394
|
+
const activity = !capabilities.codex.available
|
|
395
|
+
? 'UNAVAILABLE'
|
|
396
|
+
: context.managedActive
|
|
397
|
+
? 'MANAGED_ACTIVE'
|
|
398
|
+
: session.nativeControl === 'EXTERNAL'
|
|
399
|
+
? (context.externalActivity ?? 'IDLE')
|
|
400
|
+
: 'IDLE';
|
|
401
|
+
return {
|
|
402
|
+
control,
|
|
403
|
+
activity,
|
|
404
|
+
commandStates: context.commandStates,
|
|
405
|
+
runtime: {
|
|
406
|
+
level: control.level,
|
|
407
|
+
capabilities: [
|
|
408
|
+
...control.capabilities,
|
|
409
|
+
...(control.level === 'MANAGED' ? ['turn.queue', 'run.cancel', 'approval.respond'] : []),
|
|
410
|
+
'session.rename',
|
|
411
|
+
'session.remove',
|
|
412
|
+
'session.pin',
|
|
413
|
+
...(session.externalSessionId === null ? [] : ['session.rewind'])
|
|
414
|
+
],
|
|
415
|
+
reasonCode: control.level === 'UNAVAILABLE' ? 'RUNNER_UNAVAILABLE' : null
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
onNotification(listener) {
|
|
420
|
+
return this.client.onNotification(listener);
|
|
421
|
+
}
|
|
422
|
+
start() {
|
|
423
|
+
return this.client.start();
|
|
424
|
+
}
|
|
425
|
+
async recoverMissingRollout(runId, error) {
|
|
426
|
+
if (!isCodexRolloutMissingError(error))
|
|
427
|
+
return false;
|
|
428
|
+
if ([...this.environmentRuns].some((activeRunId) => activeRunId !== runId))
|
|
429
|
+
return false;
|
|
430
|
+
if ([...this.execution.runs.keys()].some((activeRunId) => activeRunId !== runId))
|
|
431
|
+
return false;
|
|
432
|
+
nodeLog('runner.codex.rollout.recovering', { runId });
|
|
433
|
+
await this.client.restart();
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
prepareEnvironment(environment, runId) {
|
|
437
|
+
if (Object.keys(environment).length === 0 && this.environmentFingerprint === undefined) {
|
|
438
|
+
this.environmentRuns.add(runId);
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const fingerprint = createHash('sha256')
|
|
442
|
+
.update(JSON.stringify(Object.entries(environment).sort(([left], [right]) => left.localeCompare(right))))
|
|
443
|
+
.digest('base64url');
|
|
444
|
+
if (fingerprint === this.environmentFingerprint) {
|
|
445
|
+
this.environmentRuns.add(runId);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
if (this.environmentRuns.size > 0 || this.execution.runs.size > 0)
|
|
449
|
+
throw new Error('CODEX_SECRET_ENVIRONMENT_CONFLICT');
|
|
450
|
+
this.client.stop();
|
|
451
|
+
this.client.configureEnvironment(environment);
|
|
452
|
+
this.environmentFingerprint = fingerprint;
|
|
453
|
+
this.environmentRuns.add(runId);
|
|
454
|
+
}
|
|
455
|
+
releaseEnvironment(runId) {
|
|
456
|
+
this.environmentRuns.delete(runId);
|
|
457
|
+
if (this.environmentRuns.size !== 0 || this.environmentFingerprint === undefined)
|
|
458
|
+
return;
|
|
459
|
+
this.client.stop();
|
|
460
|
+
this.client.clearEnvironment();
|
|
461
|
+
this.environmentFingerprint = undefined;
|
|
462
|
+
}
|
|
463
|
+
stop() {
|
|
464
|
+
for (const profileClient of this.profileClients)
|
|
465
|
+
profileClient.stop();
|
|
466
|
+
this.profileClients.clear();
|
|
467
|
+
this.client.stop();
|
|
468
|
+
if (this.environmentFingerprint !== undefined)
|
|
469
|
+
this.client.clearEnvironment();
|
|
470
|
+
this.environmentFingerprint = undefined;
|
|
471
|
+
this.environmentRuns.clear();
|
|
472
|
+
for (const timer of this.profileCacheTimers.values())
|
|
473
|
+
clearTimeout(timer);
|
|
474
|
+
this.profileCacheTimers.clear();
|
|
475
|
+
this.profileCache.clear();
|
|
476
|
+
this.profileKeyByEnvironment.clear();
|
|
477
|
+
this.latestProfileCache = undefined;
|
|
478
|
+
this.selectedProfileKey = undefined;
|
|
479
|
+
}
|
|
480
|
+
request(method, params) {
|
|
481
|
+
return this.client.request(method, params);
|
|
482
|
+
}
|
|
483
|
+
respond(requestId, result) {
|
|
484
|
+
this.client.respond(requestId, result);
|
|
485
|
+
}
|
|
486
|
+
listThreads() {
|
|
487
|
+
return this.client.listThreads();
|
|
488
|
+
}
|
|
489
|
+
startThread(cwd, configuration) {
|
|
490
|
+
return this.client.startThread(cwd, configuration);
|
|
491
|
+
}
|
|
492
|
+
forkThread(threadId, cwd, lastTurnId, configuration) {
|
|
493
|
+
return this.client.forkThread(threadId, cwd, lastTurnId, configuration);
|
|
494
|
+
}
|
|
495
|
+
async forkNative(session, boundary, title) {
|
|
496
|
+
if (session.externalSessionId === null)
|
|
497
|
+
throw new Error('SESSION_REWIND_UNAVAILABLE');
|
|
498
|
+
await this.start();
|
|
499
|
+
const configuration = { model: session.model, effort: session.effort, access: session.access };
|
|
500
|
+
const result = boundary === null
|
|
501
|
+
? await this.startThread(session.cwd, configuration)
|
|
502
|
+
: await this.forkThread(session.externalSessionId, session.cwd, boundary, configuration);
|
|
503
|
+
const threadId = extractId(result, 'thread');
|
|
504
|
+
await this.setThreadName(threadId, title);
|
|
505
|
+
return threadId;
|
|
506
|
+
}
|
|
507
|
+
resumeThread(threadId, cwd, configuration) {
|
|
508
|
+
return this.client.resumeThread(threadId, cwd, configuration);
|
|
509
|
+
}
|
|
510
|
+
startTurn(threadId, text, cwd, configuration, attachments) {
|
|
511
|
+
return this.client.startTurn(threadId, text, cwd, configuration, attachments);
|
|
512
|
+
}
|
|
513
|
+
interruptTurn(threadId, turnId) {
|
|
514
|
+
return this.client.interruptTurn(threadId, turnId);
|
|
515
|
+
}
|
|
516
|
+
setThreadName(threadId, name) {
|
|
517
|
+
return this.client.setThreadName(threadId, name);
|
|
518
|
+
}
|
|
519
|
+
listCollaborationModes() {
|
|
520
|
+
return this.client.listCollaborationModes();
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
function emptyCodexConfiguration() {
|
|
524
|
+
return { runner: 'codex', model: '', effort: '', access: 'on-request' };
|
|
525
|
+
}
|
|
526
|
+
function codexEnvironmentFingerprint(environment, version) {
|
|
527
|
+
return createHash('sha256')
|
|
528
|
+
.update(JSON.stringify({
|
|
529
|
+
environment: Object.entries(environment).sort(([left], [right]) => left.localeCompare(right)),
|
|
530
|
+
version: version ?? null
|
|
531
|
+
}))
|
|
532
|
+
.digest('base64url');
|
|
533
|
+
}
|
|
534
|
+
function codexSecretEnvironmentFingerprint(environment) {
|
|
535
|
+
return createHash('sha256')
|
|
536
|
+
.update(JSON.stringify(Object.entries(environment).sort(([left], [right]) => left.localeCompare(right))))
|
|
537
|
+
.digest('base64url');
|
|
538
|
+
}
|
|
539
|
+
function codexModelPage(value) {
|
|
540
|
+
if (!isPlainRecord(value) || !Array.isArray(value.data))
|
|
541
|
+
throw new Error('CODEX_MODELS_INVALID');
|
|
542
|
+
return {
|
|
543
|
+
models: value.data.flatMap((entry) => {
|
|
544
|
+
if (!isPlainRecord(entry) || entry.hidden === true)
|
|
545
|
+
return [];
|
|
546
|
+
const model = typeof entry.model === 'string' ? entry.model.trim() : '';
|
|
547
|
+
const displayName = typeof entry.displayName === 'string' ? entry.displayName.trim() : '';
|
|
548
|
+
const defaultEffort = typeof entry.defaultReasoningEffort === 'string' ? entry.defaultReasoningEffort.trim() : '';
|
|
549
|
+
const supportedEfforts = Array.isArray(entry.supportedReasoningEfforts)
|
|
550
|
+
? entry.supportedReasoningEfforts.flatMap((option) => isPlainRecord(option) && typeof option.reasoningEffort === 'string'
|
|
551
|
+
? [option.reasoningEffort.trim()]
|
|
552
|
+
: [])
|
|
553
|
+
: [];
|
|
554
|
+
if (model.length === 0 ||
|
|
555
|
+
model.length > 128 ||
|
|
556
|
+
displayName.length === 0 ||
|
|
557
|
+
displayName.length > 128 ||
|
|
558
|
+
defaultEffort.length === 0 ||
|
|
559
|
+
defaultEffort.length > 64 ||
|
|
560
|
+
supportedEfforts.length > 32 ||
|
|
561
|
+
supportedEfforts.some((effort) => effort.length === 0 || effort.length > 64) ||
|
|
562
|
+
!supportedEfforts.includes(defaultEffort))
|
|
563
|
+
return [];
|
|
564
|
+
return [
|
|
565
|
+
{
|
|
566
|
+
model,
|
|
567
|
+
displayName,
|
|
568
|
+
isDefault: entry.isDefault === true,
|
|
569
|
+
defaultEffort,
|
|
570
|
+
supportedEfforts: [...new Set(supportedEfforts.filter(Boolean))]
|
|
571
|
+
}
|
|
572
|
+
];
|
|
573
|
+
}),
|
|
574
|
+
nextCursor: typeof value.nextCursor === 'string' && value.nextCursor.length > 0 ? value.nextCursor : null
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
function isPlainRecord(value) {
|
|
578
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
579
|
+
}
|
|
580
|
+
export class CodexExecutionState {
|
|
581
|
+
runs = new Map();
|
|
582
|
+
managedTurns = new Map();
|
|
583
|
+
approvals = new Map();
|
|
584
|
+
userInputs = new Map();
|
|
585
|
+
}
|