@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
package/dist/codex-app-server.js
CHANGED
|
@@ -1,2 +1,510 @@
|
|
|
1
|
-
|
|
2
|
-
const _0x292b40=_0x66a0;(function(_0x32d508,_0x32de1b){const _0x4ef995=_0x66a0,_0x2bad45=_0x32d508();while(!![]){try{const _0x19f5a2=parseInt(_0x4ef995(0x120))/(-0x93e*0x1+0xa09+-0xca)*(parseInt(_0x4ef995(0x100))/(0x7*-0x2bb+0xb*0x386+-0xb*0x1c9))+parseInt(_0x4ef995(0x147))/(0x1*-0x214f+-0x2*0xe4b+0x3de8)+parseInt(_0x4ef995(0x18a))/(-0x2586+-0x9*0x100+0x2e8a)*(parseInt(_0x4ef995(0x13b))/(0x40*0x98+-0x98*0x26+-0xf6b))+-parseInt(_0x4ef995(0x183))/(0x259*0x1+0x1466+-0x793*0x3)*(parseInt(_0x4ef995(0xdf))/(0x65*0x6+-0x250f*0x1+0x8ae*0x4))+-parseInt(_0x4ef995(0x135))/(-0x7*0x1b5+-0x1365+-0x1f6*-0x10)+parseInt(_0x4ef995(0xeb))/(0x3*0x3bd+0x1236+0x1d64*-0x1)*(parseInt(_0x4ef995(0x16c))/(0x14e*-0x1+-0x23aa+0x6*0x62b))+-parseInt(_0x4ef995(0x103))/(-0x1c*-0xda+-0x17d2+-0x1*-0x5);if(_0x19f5a2===_0x32de1b)break;else _0x2bad45['push'](_0x2bad45['shift']());}catch(_0x5bb4fd){_0x2bad45['push'](_0x2bad45['shift']());}}}(_0xcaa8,0x5cb4f*0x1+-0x501ad*0x1+0xc669*0x7));import{spawn,spawnSync}from'node:child_process';import{randomUUID}from'node:crypto';function _0x66a0(_0xb40192,_0x51b101){_0xb40192=_0xb40192-(-0x1ba1+-0xce8+0x2962);const _0x52336d=_0xcaa8();let _0x255f57=_0x52336d[_0xb40192];if(_0x66a0['mTQUgz']===undefined){var _0x555a0c=function(_0x38a866){const _0xc4dcab='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3fbd81='',_0x28bff8='';for(let _0x412810=-0x9dd+-0x5*-0x4f6+-0x2fd*0x5,_0x3943f0,_0xd43030,_0x2729f6=0xea*-0x15+0x3*-0x122+-0x18*-0xf1;_0xd43030=_0x38a866['charAt'](_0x2729f6++);~_0xd43030&&(_0x3943f0=_0x412810%(-0x1*-0x53+0x13ed*-0x1+0x139e)?_0x3943f0*(0x1*-0x326+0x196b+0x757*-0x3)+_0xd43030:_0xd43030,_0x412810++%(-0x561+-0x9*-0x455+-0x6b8*0x5))?_0x3fbd81+=String['fromCharCode'](0x2*0x1bb+-0x185b+0x2*0xaf2&_0x3943f0>>(-(0x15b2*-0x1+0x222a+0xb*-0x122)*_0x412810&0x1626+-0xec8+-0x758)):0x152f+0x1*-0x2413+0xee4){_0xd43030=_0xc4dcab['indexOf'](_0xd43030);}for(let _0x2fc403=-0x18ce+0x1*0x1c0c+-0x33e,_0xbf5d01=_0x3fbd81['length'];_0x2fc403<_0xbf5d01;_0x2fc403++){_0x28bff8+='%'+('00'+_0x3fbd81['charCodeAt'](_0x2fc403)['toString'](0x16e5+0xf40+-0x2615*0x1))['slice'](-(0x13e7+-0x1ace+0x6e9));}return decodeURIComponent(_0x28bff8);};_0x66a0['eFQWZQ']=_0x555a0c,_0x66a0['SRDplG']={},_0x66a0['mTQUgz']=!![];}const _0x5d825f=_0x52336d[-0x909+-0x19e6+0x22ef];_0x66a0['IrBVgm']!==_0x5d825f&&(_0x66a0['SRDplG']={},_0x66a0['IrBVgm']=_0x5d825f);const _0x5b9d68=_0x66a0['SRDplG'][_0xb40192];return _0x5b9d68===undefined?(_0x255f57=_0x66a0['eFQWZQ'](_0x255f57),_0x66a0['SRDplG'][_0xb40192]=_0x255f57):_0x255f57=_0x5b9d68,_0x255f57;}import{existsSync}from'node:fs';import{unlink}from'node:fs/promises';import{connect}from'node:net';function _0xcaa8(){const _0x31e319=['uKvtvu1bqKXf','BM90Awz5','y29SBgfIB3jHDgLVBK1Vzgu','mJy0nty0zMLUy3Lx','Dw5PEa','DgvZDa','BgvUz3rO','D3jPDgfIBgu','DhvYBI9ZDgfYDa','BgLMzwn5y2XLuMv2AxnPB24','CMvXDwvZDerPCMvJDa','y2HPBgq','CMvHze9UBhK','C3bHD25qCM9JzxnZ','CgXHDgzVCM0','BMv4DeLK','y3DK','BMf0AxzLvgHYzwfKswq','DgHYzwfKl2zVCMS','CMvXDwvZDa','BgLUzq','zw52','DhjHBNnWB3j0tw9Kzq','C3rHCNruDxjU','otKZmtb1uMreu3e','DhvYBI9PBNrLCNj1Chq','CMvQzwn0','mZeYndyWnuDRqxDdua','D2fPDezVCLbLBMrPBMDszxf1zxn0CW','CMvZB2X2zvbLBMrPBMDeCMfPBG','D29YA3nWywnLv3jPDgu','C3rHCNrnyw5Hz2vK','zgfUz2vYrNvSBefJy2vZCW','B25Jzq','q09ervHFvu5jwf9tt0nlrvrFq09otKvdvf9gquLmruq6','y29KzxG','CgLK','C3rKAw8','zgvSzxrL','C2L6zq','q09ervHFqvbqx1nfuLzfuL9fweLuruq','C3rLzxjuDxjU','q09ervHFqvbqx1nfuLzfuL9btfjfqurzx1nuqvjuruq','q29KzxGGqxbWifnLCNzLCIbYzxf1zxn0igzHAwXLza','Dw5PEdOVlW','q09ervHFvu5jwf9tt0nlrvrFueXbvezpuK1Fvu5tvvbqt1juruq','DhvYBI5PBNrLCNj1Chq','zMfPBefSBa','DxrMoa','BwnWu2vYDMvYCW','CMvHzc1VBMX5','DhvYBI9ZDgvLCG','CMvZDw1LvgHYzwfK','y29SBgfIB3jHDgLVBK1VzguVBgLZDa','AgfUzgXLtgLUzq','Aw5PDgLHBgL6zwq','mtnoyNzdBfq','C3rKB3v0','Dgv4Da','B24TCMvXDwvZDa','ls1SAxn0zw4','C3rKAw4','DgHYzwfKl3jLC3vTzq','AgLZDg9YEs5YzwfK','B3b0Aw9UCW','zxHPDa','BMfTzq','BM93','q09ervHFqvbqx1nfuLzfuL9tvefsvf9gquLmruq6','zMfZDa','yxv0BW','u0HbuKvex0nptLrst0W','y29UzMLNDxjLrw52AxjVBM1LBNq','zxzLBNrZlMXPDMu','A2LSBa','BMv2zxi','CgvUzgLUz0rYywLUv2fPDgvYCW','mJaXmda4mgPcuuPKDq','C3rHCNq','CgLWzq','Aw50zxjYDxb0vhvYBG','D3jPDgu','BxLHz2vUDhjVyw0Ty29KzxGT','mJbcDeDTBva','B25oB3rPzMLJyxrPB24','C3rKzxjY','CMvZDwX0','C3rYAw5NAwz5','DhvYBI5ZDgvLCG','BgLZDfrOCMvHzhm','CMvZDgfYDgLUzW','zgv2zwXVCgvYsw5ZDhj1y3rPB25Z','q29KzxHbChbtzxj2zxjsCgnfCNjVCG','DgHYzwfKl2XPC3q','lNnVy2S','nZqYmtaXAwPMEwfi','ywn0AxzLvhvYBG','DgHYzwfKl3n0yxj0','C29JA2v0ugf0Aa','CgfYyw1Z','DhjHBNnWB3j0','ls12zxjZAw9U','t0jtrvjwrv9ptKXz','CNbJtwvZC2fNzq','yxjNCW','Bw9KzwWVBgLZDa','zw52AxjVBM1LBNq','Bwv0Ag9K','BwvZC2fNzq','q09ervHFqvbqx1nfuLzfuL9usu1ft1vu','Aw5PDgLHBgL6zq','DgLTzw91De1Z','zNvSBc1Hy2nLC3m','zxjYB3i','y2XLyxjfBNzPCM9UBwvUDa','zgfUz2vYlwz1BgWTywnJzxnZ','DgHYzwfKl25HBwuVC2v0','CMvZDgfYDa','Bw9KzwW','BgLZDe1VzgvSCW','y29KzxHFDNnJB2rL','rvHurvjoquW','ywrK','C2v0','mc4XlJq','DgHLBG','CgfYC2u','C3rHCNrPBMC','C2vYDMLJzvrPzxi','zM9YA1rOCMvHza','CMvZDgfYDe1HBMfNzwq','y29Kzq','mtGWCK1Ov2Pf','C3rVCe1HBMfNzwq','q09ervHFqvbqx1nfuLzfuL9vtKfwquLmqujmrq','zgf0yq','vu5bvKfjtefcteu','BgLUDxG','ywnJzxnZ','DhvYBG','BM90AwzPy2f0Aw9UCW','DhjPBq','z3b0ltuUnI1ZB2W','zwzMB3j0','y29UBMvJDa','BwLU','DhvYBI5ZDgfYDa','CMvZB2X2zq','DgLTzxi','yxbWlxnLCNzLCG','D29YA3nWywnLlxDYAxrL','C3rHDhvZ','C3rYAw5N','zgvZDhjVEq','txLbz2vUDfjVyw0','mtjuDw9Qtui','BMf0AxzLq29UDhjVBa','BgLZDenVBgXHyM9YyxrPB25nB2rLCW','CMvZCg9Uza','C2v0vgHYzwfKtMfTzq','C3rVCa','C2HHCMvKq29UDhjVBa','mJiXnZa0BMLMC01v','q09ervHFqvbqx1nfuLzfuL9suenFrvjst1i6','q09ervHFqvbqx1nfuLzfuL9tve9queve','y29TBwfUza','C3rHCNruAhjLywq','AxnbCNjHEq','tufoquDfra','mJq1ndmWnw1LEhrvCW','B2jQzwn0','z2v0','BNvTyMvY','DgHYzwfK','y2XLyxi','CgvUzgLUzW','yxzHAwXHyMXL','C2XPy2u'];_0xcaa8=function(){return _0x31e319;};return _0xcaa8();}import{tmpdir}from'node:os';import{join}from'node:path';import{createInterface}from'node:readline';import{minimalRunnerEnvironment,platformCliInvocation,runRunnerProbe}from'./operational.js';const REQUEST_TIMEOUT_MS=0x1894+-0x64fc+0x2d0*0x30;export function codexSessionControl(_0x2f7828){const _0x18dae7=_0x66a0;if(!_0x2f7828[_0x18dae7(0xe6)])return{'level':_0x18dae7(0x170),'capabilities':[]};if(_0x2f7828[_0x18dae7(0x189)])return{'level':_0x18dae7(0x12f),'capabilities':[_0x18dae7(0x127),_0x18dae7(0x131),_0x18dae7(0x17a),_0x18dae7(0x140),_0x18dae7(0x116)]};if(_0x2f7828[_0x18dae7(0xf9)]!==null&&_0x2f7828[_0x18dae7(0x184)]===_0x18dae7(0x161))return{'level':_0x18dae7(0x14e),'capabilities':[_0x18dae7(0x127)]};if(_0x2f7828[_0x18dae7(0x148)])return{'level':_0x18dae7(0xde),'capabilities':[_0x18dae7(0x127),_0x18dae7(0x131),_0x18dae7(0x140),_0x18dae7(0x116)]};return{'level':_0x18dae7(0xe8),'capabilities':[_0x18dae7(0x127),_0x18dae7(0x17a)]};}export class CodexAppServerRpcError extends Error{[_0x292b40(0x16b)];[_0x292b40(0x14f)];[_0x292b40(0x16f)];constructor(_0x25dd62){const _0x5ec982=_0x292b40,_0x305cfb=typeof _0x25dd62[_0x5ec982(0x154)]===_0x5ec982(0x180)?_0x25dd62[_0x5ec982(0x154)]:_0x5ec982(0x113);super(_0x5ec982(0xd9)+JSON[_0x5ec982(0x13f)](_0x25dd62)),this[_0x5ec982(0x12a)]=_0x5ec982(0x144),this[_0x5ec982(0x16b)]=_0x25dd62[_0x5ec982(0x16b)],this[_0x5ec982(0x14f)]=_0x305cfb,this[_0x5ec982(0x16f)]=_0x25dd62[_0x5ec982(0x16f)];}}export function isCodexRolloutMissingError(_0x1bd3be){const _0x2464cc=_0x292b40;return _0x1bd3be instanceof CodexAppServerRpcError&&_0x1bd3be[_0x2464cc(0x16b)]===-(-0x13*-0xa49+-0x87*-0x53+-0x8*0xdfb)&&(/^no rollout found for thread id\b/i[_0x2464cc(0xed)](_0x1bd3be[_0x2464cc(0x14f)])||/^thread not loaded:\s*/i[_0x2464cc(0xed)](_0x1bd3be[_0x2464cc(0x14f)]));}export class CodexAppServerClient{[_0x292b40(0x128)];[_0x292b40(0xf3)];[_0x292b40(0x14c)];[_0x292b40(0x14a)];[_0x292b40(0xf7)]=0x10e+0x16cc+0x21*-0xb9;[_0x292b40(0xe5)]=new Map();[_0x292b40(0x134)]=new Set();[_0x292b40(0x174)]=new Set();[_0x292b40(0x152)]={};[_0x292b40(0x167)];[_0x292b40(0x142)];[_0x292b40(0xf1)]=0x31d*0x1+-0x16d5+-0x13b8*-0x1;constructor(_0x381369={}){const _0x5645ed=_0x292b40;this[_0x5645ed(0x128)]=_0x381369;}[_0x292b40(0x130)](_0x4ce9e4){const _0x3d3074=_0x292b40;if(this[_0x3d3074(0xf3)]!==undefined)throw new Error(_0x3d3074(0x112));this[_0x3d3074(0x152)]={..._0x4ce9e4};}[_0x292b40(0x15a)](){const _0x6a8ed0=_0x292b40;if(this[_0x6a8ed0(0xf3)]!==undefined)throw new Error(_0x6a8ed0(0x112));this[_0x6a8ed0(0x152)]={};}[_0x292b40(0x136)](){const _0x3ff32e=_0x292b40;if(this[_0x3ff32e(0x142)]!==undefined)return this[_0x3ff32e(0x142)];if(this[_0x3ff32e(0x167)]!==undefined)return this[_0x3ff32e(0x167)];if(this[_0x3ff32e(0xf3)]!==undefined)return Promise[_0x3ff32e(0x17b)]();const _0x108840=this[_0x3ff32e(0x107)]();this[_0x3ff32e(0x167)]=_0x108840;const _0x20b572=()=>{const _0x5859ef=_0x3ff32e;if(this[_0x5859ef(0x167)]===_0x108840)this[_0x5859ef(0x167)]=undefined;};return void _0x108840[_0x3ff32e(0x165)](_0x20b572,_0x20b572),_0x108840;}[_0x292b40(0x15d)](){const _0x5e8162=_0x292b40;if(this[_0x5e8162(0x142)]!==undefined)return this[_0x5e8162(0x142)];const _0x45dc3e=this[_0x5e8162(0x16a)](this[_0x5e8162(0xf1)]);this[_0x5e8162(0x142)]=_0x45dc3e;const _0x41697c=()=>{const _0x5b071d=_0x5e8162;if(this[_0x5b071d(0x142)]===_0x45dc3e)this[_0x5b071d(0x142)]=undefined;};return void _0x45dc3e[_0x5e8162(0x165)](_0x41697c,_0x41697c),_0x45dc3e;}async[_0x292b40(0x107)](){const _0x1db718=_0x292b40,_0x46a11b=this[_0x1db718(0x128)][_0x1db718(0xdb)]??_0x1db718(0x10b),_0x2d48bb=this[_0x1db718(0xfe)]();this[_0x1db718(0x14a)]=_0x2d48bb===_0x1db718(0xec)?this[_0x1db718(0x128)][_0x1db718(0x14a)]??privateSocketPath():undefined;const _0x100ec8=this[_0x1db718(0x128)][_0x1db718(0x150)]??[_0x1db718(0x17d)],_0x333dc6=[..._0x100ec8,..._0x2d48bb===_0x1db718(0xec)?[_0x1db718(0x124),_0x1db718(0x114)+this[_0x1db718(0x14a)]]:[]],_0x469a0e=this[_0x1db718(0x128)][_0x1db718(0xf5)]??defaultSpawn;let _0x2d79e2=_0x469a0e(_0x46a11b,_0x333dc6,{...this[_0x1db718(0x128)][_0x1db718(0xf8)]===undefined?{}:{'cwd':this[_0x1db718(0x128)][_0x1db718(0xf8)]},'env':{...minimalRunnerEnvironment(),...this[_0x1db718(0x152)]}});this[_0x1db718(0xf3)]=_0x2d79e2;let _0x11a0da;if(_0x2d48bb===_0x1db718(0xec))try{_0x11a0da=await connectUnix(this[_0x1db718(0x14a)],(this[_0x1db718(0x128)][_0x1db718(0x14c)]??_0x1db718(0x12e))===_0x1db718(0x12e)?Math[_0x1db718(0x179)](this[_0x1db718(0x128)][_0x1db718(0x157)]??REQUEST_TIMEOUT_MS,-0xa88*-0x3+-0x99*0x1f+0x23*-0x43):this[_0x1db718(0x128)][_0x1db718(0x157)]??REQUEST_TIMEOUT_MS);}catch(_0x12c0f3){if((this[_0x1db718(0x128)][_0x1db718(0x14c)]??_0x1db718(0x12e))!==_0x1db718(0x12e))throw _0x12c0f3;_0x2d79e2[_0x1db718(0x132)]();if(this[_0x1db718(0x14a)]!==undefined&&existsSync(this[_0x1db718(0x14a)]))await unlink(this[_0x1db718(0x14a)]);this[_0x1db718(0x14a)]=undefined,_0x2d79e2=_0x469a0e(_0x46a11b,_0x100ec8,{...this[_0x1db718(0x128)][_0x1db718(0xf8)]===undefined?{}:{'cwd':this[_0x1db718(0x128)][_0x1db718(0xf8)]},'env':{...minimalRunnerEnvironment(),...this[_0x1db718(0x152)]}}),this[_0x1db718(0xf3)]=_0x2d79e2;}this[_0x1db718(0x14c)]=_0x11a0da??stdioTransport(_0x2d79e2);const _0x1af381=createInterface({'input':_0x11a0da??_0x2d79e2[_0x1db718(0x121)]});_0x1af381['on'](_0x1db718(0xfc),_0x105e1a=>this[_0x1db718(0x11e)](_0x105e1a));const _0x2bdc56=_0x2d79e2;_0x2d79e2[_0x1db718(0x109)](_0x1db718(0x159),_0x449a6b=>{const _0x3113b0=_0x1db718;if(this[_0x3113b0(0xf3)]!==_0x2bdc56)return;this[_0x3113b0(0x117)](new Error(_0x3113b0(0x12c)+_0x449a6b[_0x3113b0(0x154)]));}),_0x2d79e2[_0x1db718(0x109)](_0x1db718(0x129),()=>{const _0x53ea08=_0x1db718;if(this[_0x53ea08(0xf3)]!==_0x2bdc56)return;this[_0x53ea08(0xf3)]=undefined,this[_0x53ea08(0x117)](new Error(_0x53ea08(0x110)));}),await this[_0x1db718(0xf2)](_0x1db718(0x156),{'clientInfo':{'name':_0x1db718(0x160),'title':_0x1db718(0x182),'version':_0x1db718(0x164)},'capabilities':{'experimentalApi':!![]}}),this[_0x1db718(0xe9)](_0x1db718(0x11f),{});}async[_0x292b40(0x16a)](_0x1b1517){const _0xc4dffe=_0x292b40;await Promise[_0xc4dffe(0x17b)]();if(this[_0xc4dffe(0x167)]!==undefined)await this[_0xc4dffe(0x167)];await this[_0xc4dffe(0x104)]();if(this[_0xc4dffe(0xf1)]!==_0x1b1517)throw new Error(_0xc4dffe(0xda));this[_0xc4dffe(0x16d)](),await this[_0xc4dffe(0x107)]();}[_0x292b40(0x188)](){const _0x23c2c6=_0x292b40;this[_0x23c2c6(0xf1)]+=-0x3d*0x10+0x1*0x18bb+-0x14ea*0x1,this[_0x23c2c6(0x16d)]();}[_0x292b40(0x16d)](){const _0x408117=_0x292b40;this[_0x408117(0x14c)]?.[_0x408117(0x181)](),this[_0x408117(0x14c)]=undefined,this[_0x408117(0xf3)]?.[_0x408117(0x132)](),this[_0x408117(0xf3)]=undefined;if(this[_0x408117(0x14a)]!==undefined&&existsSync(this[_0x408117(0x14a)]))void unlink(this[_0x408117(0x14a)]);this[_0x408117(0x14a)]=undefined,this[_0x408117(0x117)](new Error(_0x408117(0xda)));}[_0x292b40(0x13c)](_0x5da9c5){const _0x4b9444=_0x292b40;return this[_0x4b9444(0x174)][_0x4b9444(0x162)](_0x5da9c5),()=>this[_0x4b9444(0x174)][_0x4b9444(0x10e)](_0x5da9c5);}async[_0x292b40(0xfb)](_0x455941,_0x50aa44){const _0x59015f=_0x292b40;if(this[_0x59015f(0x142)]!==undefined)await this[_0x59015f(0x142)];else{if(this[_0x59015f(0x167)]!==undefined)await this[_0x59015f(0x167)];}return this[_0x59015f(0xf2)](_0x455941,_0x50aa44);}[_0x292b40(0xf2)](_0x40b8e7,_0xd2bd63){const _0xbdfee3=_0x292b40,_0xe23af9=this[_0xbdfee3(0x14c)];if(_0xe23af9===undefined||!_0xe23af9[_0xbdfee3(0xef)])throw new Error(_0xbdfee3(0x16e));const _0x13fc41=this[_0xbdfee3(0xf7)]++,_0x52c328=this[_0xbdfee3(0x128)][_0xbdfee3(0x157)]??REQUEST_TIMEOUT_MS,_0x4935d3=new Promise((_0x1f873d,_0x13fd9e)=>{const _0x4dbfd0=_0xbdfee3,_0x320218=setTimeout(()=>{const _0x4b22b0=_0x66a0;this[_0x4b22b0(0xe5)][_0x4b22b0(0x10e)](_0x13fc41),this[_0x4b22b0(0x105)](),_0x13fd9e(new Error(_0x4b22b0(0x155)));},_0x52c328);this[_0x4dbfd0(0xe5)][_0x4dbfd0(0x163)](_0x13fc41,{'resolve':_0x1f873d,'reject':_0x13fd9e,'timer':_0x320218});});return _0xe23af9[_0xbdfee3(0x139)](JSON[_0xbdfee3(0x13f)]({'method':_0x40b8e7,'id':_0x13fc41,'params':_0xd2bd63})+'\x0a'),_0x4935d3;}[_0x292b40(0x104)](){const _0x2b061b=_0x292b40;if(this[_0x2b061b(0xe5)][_0x2b061b(0x10f)]===-0xa*-0x30a+0xa86+-0x28ea)return Promise[_0x2b061b(0x17b)]();return new Promise(_0x2b883e=>this[_0x2b061b(0x134)][_0x2b061b(0x162)](_0x2b883e));}[_0x292b40(0x105)](){const _0x2a9358=_0x292b40;if(this[_0x2a9358(0xe5)][_0x2a9358(0x10f)]!==-0x994+0x152f+0x1*-0xb9b)return;for(const _0x16112f of this[_0x2a9358(0x134)])_0x16112f();this[_0x2a9358(0x134)][_0x2a9358(0xe4)]();}[_0x292b40(0xe9)](_0x5080ea,_0x8cfda4){const _0x2e60ce=_0x292b40,_0x212736=this[_0x2e60ce(0x14c)];if(_0x212736===undefined||!_0x212736[_0x2e60ce(0xef)])throw new Error(_0x2e60ce(0x16e));_0x212736[_0x2e60ce(0x139)](JSON[_0x2e60ce(0x13f)]({'method':_0x5080ea,'params':_0x8cfda4})+'\x0a');}[_0x292b40(0x186)](_0x127223,_0x487b57){const _0x2919f2=_0x292b40,_0x22fd25=this[_0x2919f2(0x14c)];if(_0x22fd25===undefined||!_0x22fd25[_0x2919f2(0xef)])throw new Error(_0x2919f2(0x16e));_0x22fd25[_0x2919f2(0x139)](JSON[_0x2919f2(0x13f)]({'id':_0x127223,'result':_0x487b57})+'\x0a');}[_0x292b40(0xdc)](_0x2c430c,_0x31ddde={}){const _0x5a4a13=_0x292b40;return this[_0x5a4a13(0xfb)](_0x5a4a13(0x149),{'cwd':_0x2c430c,...codexThreadConfiguration(_0x2c430c,_0x31ddde)});}[_0x292b40(0x141)](){const _0x320c6c=_0x292b40;return this[_0x320c6c(0xfb)](_0x320c6c(0x145),{});}[_0x292b40(0x185)](){const _0x5722ca=_0x292b40;return this[_0x5722ca(0xfb)](_0x5722ca(0x11d),{});}[_0x292b40(0x15f)](_0x3269ec){const _0x58b03a=_0x292b40;return this[_0x58b03a(0xfb)](_0x58b03a(0x151),_0x3269ec);}[_0x292b40(0x169)](_0x284c28,_0x1d4ea0,_0x5d7c9a,_0x38dc8f={}){const _0x3da6a3=_0x292b40;return this[_0x3da6a3(0xfb)](_0x3da6a3(0xfa),{'threadId':_0x284c28,'lastTurnId':_0x5d7c9a,'cwd':_0x1d4ea0,...codexThreadConfiguration(_0x1d4ea0,_0x38dc8f)});}[_0x292b40(0x187)](_0x15e21a,_0x24f456){const _0x251293=_0x292b40;return this[_0x251293(0xfb)](_0x251293(0x15c),{'threadId':_0x15e21a,'name':_0x24f456});}[_0x292b40(0x11c)](_0x26d597,_0x189f9b,_0x55520d={}){const _0x1d1f72=_0x292b40;return this[_0x1d1f72(0xfb)](_0x1d1f72(0x126),{'threadId':_0x26d597,'cwd':_0x189f9b,...codexThreadConfiguration(_0x189f9b,_0x55520d)});}[_0x292b40(0xff)](_0x363e24,_0x577563,_0x5d9651,_0x1aa842={},_0x356192=[]){const _0x33f6bb=_0x292b40;return this[_0x33f6bb(0xfb)](_0x33f6bb(0xf0),{'threadId':_0x363e24,'cwd':_0x5d9651,'input':[{'type':_0x33f6bb(0x122),'text':_0x577563},..._0x356192],...codexTurnConfiguration(_0x5d9651,_0x1aa842)});}[_0x292b40(0x111)](_0x5b082d,_0x48e148,_0x172e77){const _0x48b110=_0x292b40;return this[_0x48b110(0xfb)](_0x48b110(0x11b),{'threadId':_0x5b082d,'expectedTurnId':_0x48e148,'input':[{'type':_0x48b110(0x122),'text':_0x172e77}]});}[_0x292b40(0x138)](_0x5f1e8e,_0xac3dcb){const _0x23ebc7=_0x292b40;return this[_0x23ebc7(0xfb)](_0x23ebc7(0x101),{'threadId':_0x5f1e8e,'turnId':_0xac3dcb});}[_0x292b40(0x11e)](_0x16a226){const _0x21ed3e=_0x292b40;let _0x51050e;try{_0x51050e=JSON[_0x21ed3e(0x166)](_0x16a226);}catch{return;}if((typeof _0x51050e['id']===_0x21ed3e(0xe2)||typeof _0x51050e['id']===_0x21ed3e(0x180))&&typeof _0x51050e[_0x21ed3e(0x153)]===_0x21ed3e(0x180)){for(const _0x220c68 of this[_0x21ed3e(0x174)]){_0x220c68({'method':_0x51050e[_0x21ed3e(0x153)],'params':_0x51050e[_0x21ed3e(0x14b)],'requestId':_0x51050e['id']});}return;}if(typeof _0x51050e['id']===_0x21ed3e(0xe2)){const _0x5c889f=this[_0x21ed3e(0xe5)][_0x21ed3e(0xe1)](_0x51050e['id']);if(_0x5c889f===undefined)return;clearTimeout(_0x5c889f[_0x21ed3e(0x17c)]),this[_0x21ed3e(0xe5)][_0x21ed3e(0x10e)](_0x51050e['id']),this[_0x21ed3e(0x105)]();_0x51050e[_0x21ed3e(0x159)]!==undefined?_0x5c889f[_0x21ed3e(0x102)](new CodexAppServerRpcError(isRecord(_0x51050e[_0x21ed3e(0x159)])?_0x51050e[_0x21ed3e(0x159)]:{'message':String(_0x51050e[_0x21ed3e(0x159)])})):_0x5c889f[_0x21ed3e(0x17b)](_0x51050e[_0x21ed3e(0x13e)]);return;}if(typeof _0x51050e[_0x21ed3e(0x153)]===_0x21ed3e(0x180)){for(const _0x21d21a of this[_0x21ed3e(0x174)])_0x21d21a({'method':_0x51050e[_0x21ed3e(0x153)],'params':_0x51050e[_0x21ed3e(0x14b)]});}}[_0x292b40(0x117)](_0x3b06fd){const _0x5789dd=_0x292b40;for(const [_0x296dc1,_0x24f434]of this[_0x5789dd(0xe5)]){clearTimeout(_0x24f434[_0x5789dd(0x17c)]),_0x24f434[_0x5789dd(0x102)](_0x3b06fd),this[_0x5789dd(0xe5)][_0x5789dd(0x10e)](_0x296dc1);}this[_0x5789dd(0x105)]();}[_0x292b40(0xfe)](){const _0x4e9adb=_0x292b40,_0x58c573=this[_0x4e9adb(0x128)][_0x4e9adb(0x14c)]??_0x4e9adb(0x12e);if(_0x58c573===_0x4e9adb(0x12e))return process[_0x4e9adb(0xf6)]===_0x4e9adb(0x171)?_0x4e9adb(0xec):_0x4e9adb(0x10d);if(_0x58c573===_0x4e9adb(0xec)&&process[_0x4e9adb(0xf6)]!==_0x4e9adb(0x171))throw new Error(_0x4e9adb(0x115));return _0x58c573;}}function codexThreadConfiguration(_0x5916f9,_0x2c17c2){const _0x5930ed=_0x292b40;return{...modelOption(_0x2c17c2[_0x5930ed(0x15e)]),..._0x2c17c2[_0x5930ed(0x143)]===undefined?{}:{'developerInstructions':_0x2c17c2[_0x5930ed(0x143)]},..._0x2c17c2[_0x5930ed(0x119)]===undefined?{}:{'config':{'mcp_servers':_0x2c17c2[_0x5930ed(0x119)]}},...codexPermissionConfiguration(_0x5916f9,_0x2c17c2[_0x5930ed(0x172)],_0x5930ed(0xe3))};}function codexTurnConfiguration(_0x386f03,_0x25effd){const _0x4ba4fa=_0x292b40,_0xa170de=typeof _0x25effd[_0x4ba4fa(0x177)]===_0x4ba4fa(0x180)&&_0x25effd[_0x4ba4fa(0x177)][_0x4ba4fa(0x175)]()[_0x4ba4fa(0xee)]>-0x6d1*0x4+0x1*-0x18ce+0x3412?_0x25effd[_0x4ba4fa(0x177)]:null;return{...modelOption(_0x25effd[_0x4ba4fa(0x15e)]),..._0xa170de===null?{}:{'effort':_0xa170de},..._0x25effd[_0x4ba4fa(0x168)]===_0x4ba4fa(0x12d)?{'serviceTier':_0x4ba4fa(0x12d)}:{},..._0x25effd[_0x4ba4fa(0xea)]===undefined?{}:{'collaborationMode':{'mode':_0x25effd[_0x4ba4fa(0xea)],'settings':{'model':_0x25effd[_0x4ba4fa(0x15e)]??_0x4ba4fa(0x176),'reasoningEffort':_0xa170de}}},...codexPermissionConfiguration(_0x386f03,_0x25effd[_0x4ba4fa(0x172)],_0x4ba4fa(0x173))};}function modelOption(_0x52b1c5){return _0x52b1c5===undefined||_0x52b1c5===null?{}:{'model':_0x52b1c5};}function codexPermissionConfiguration(_0x4d8163,_0x5038a7,_0x39f6ed){const _0x29b4a=_0x292b40,_0x14a86f=_0x5038a7===_0x29b4a(0x11a)?_0x29b4a(0x11a):_0x5038a7===_0x29b4a(0x17e)||_0x5038a7===_0x29b4a(0x123)?_0x29b4a(0x17e):_0x5038a7===_0x29b4a(0x158)?_0x29b4a(0x15b):undefined,_0x3dc8ba=_0x5038a7===_0x29b4a(0x17e)||_0x5038a7===_0x29b4a(0x158)?_0x29b4a(0x133):_0x29b4a(0x123);if(_0x39f6ed===_0x29b4a(0xe3))return{..._0x14a86f===undefined?{}:{'sandbox':_0x14a86f},'approvalPolicy':_0x3dc8ba};return{..._0x14a86f===undefined?{}:{'sandboxPolicy':_0x14a86f===_0x29b4a(0x11a)?{'type':_0x29b4a(0xf4)}:_0x14a86f===_0x29b4a(0x15b)?{'type':_0x29b4a(0x108)}:{'type':_0x29b4a(0x106),'writableRoots':[_0x4d8163],'networkAccess':!![]}},'approvalPolicy':_0x3dc8ba};}export function probeCodex(_0x2f1f5e=_0x292b40(0x10b)){const _0x4fb672=_0x292b40,_0x4e453f=platformCliInvocation(_0x2f1f5e,[_0x4fb672(0x14d)]),_0x78b464=spawnSync(_0x4e453f[_0x4fb672(0xdb)],_0x4e453f[_0x4fb672(0x150)],{'windowsHide':!![],'env':minimalRunnerEnvironment(),'timeout':0xbb8,'encoding':_0x4fb672(0x118)});if(_0x78b464[_0x4fb672(0x17f)]!==0x16e5+0xf40+-0x28b*0xf||_0x78b464[_0x4fb672(0x159)]!==undefined)return{'available':![],'compatible':![]};const _0x290545=(''+_0x78b464[_0x4fb672(0x121)]+_0x78b464[_0x4fb672(0x13d)])[_0x4fb672(0x175)]()[_0x4fb672(0xe7)](0x13e7+-0x1ace+0x6e7,-0x909+-0x19e6+0x236f);return{'available':!![],..._0x290545[_0x4fb672(0xee)]===-0x1ddb+0x1bdc+-0x1ff*-0x1?{}:{'version':_0x290545},'compatible':!![]};}export async function probeCodexAsync(_0x3e8886=_0x292b40(0x10b)){const _0x3cd3bf=_0x292b40,_0x101d74=platformCliInvocation(_0x3e8886,[_0x3cd3bf(0x14d)]),_0x532b6a=await runRunnerProbe(_0x101d74[_0x3cd3bf(0xdb)],_0x101d74[_0x3cd3bf(0x150)],{'env':minimalRunnerEnvironment(),'timeoutMs':0xbb8});if(_0x532b6a[_0x3cd3bf(0x17f)]!==0x23fd+-0x3*-0x273+0x3*-0xe72)return{'available':![],'compatible':![]};const _0xe26f04=(''+_0x532b6a[_0x3cd3bf(0x121)]+_0x532b6a[_0x3cd3bf(0x13d)])[_0x3cd3bf(0x175)]()[_0x3cd3bf(0xe7)](-0xf9*0x1d+-0x6fc+0x2331,-0x318*-0x4+0xee3+0x1f*-0xdd);return{'available':!![],..._0xe26f04[_0x3cd3bf(0xee)]===0x6c9*-0x1+0xb*-0x31c+0x28fd?{}:{'version':_0xe26f04},'compatible':!![]};}export function isSupportedCodexVersion(_0x18896c){const _0x4e1094=_0x292b40;return _0x18896c[_0x4e1094(0x175)]()[_0x4e1094(0xee)]>-0x1*0x10a9+-0x4*0x43a+0x295*0xd;}function defaultSpawn(_0x38d22d,_0x41174e,_0x416668){const _0x1aac8e=_0x292b40,_0x5238e8=platformCliInvocation(_0x38d22d,_0x41174e);return spawn(_0x5238e8[_0x1aac8e(0xdb)],_0x5238e8[_0x1aac8e(0x150)],{'stdio':[_0x1aac8e(0x137),_0x1aac8e(0x137),_0x1aac8e(0x137)],'shell':![],'windowsHide':!![],..._0x416668[_0x1aac8e(0xf8)]===undefined?{}:{'cwd':_0x416668[_0x1aac8e(0xf8)]},..._0x416668[_0x1aac8e(0xfd)]===undefined?{}:{'env':_0x416668[_0x1aac8e(0xfd)]}});}function isRecord(_0x2513c5){const _0x1b3bfb=_0x292b40;return typeof _0x2513c5===_0x1b3bfb(0xe0)&&_0x2513c5!==null&&!Array[_0x1b3bfb(0xdd)](_0x2513c5);}function stdioTransport(_0x102f97){const _0x2da9e3=_0x292b40;return{get 'writable'(){const _0x27c30f=_0x66a0;return _0x102f97[_0x27c30f(0x125)][_0x27c30f(0xef)];},'write':_0x13b538=>_0x102f97[_0x2da9e3(0x125)][_0x2da9e3(0x139)](_0x13b538),'on':(_0xb713e4,_0x32ddec)=>_0x102f97[_0x2da9e3(0x121)]['on'](_0xb713e4,_0x32ddec),'once':(_0x3b1b53,_0x538196)=>_0x102f97[_0x2da9e3(0x121)][_0x2da9e3(0x109)](_0x3b1b53,_0x538196),'destroy':()=>_0x102f97[_0x2da9e3(0x121)][_0x2da9e3(0x181)]()};}function privateSocketPath(){const _0x40bcef=_0x292b40;return join(tmpdir(),_0x40bcef(0x13a)+process[_0x40bcef(0x10c)]+'-'+randomUUID()+_0x40bcef(0x146));}function connectUnix(_0x48bd22,_0x539789){return new Promise((_0x41b5d5,_0x113c95)=>{const _0x211594=_0x66a0,_0x2f6040=Date[_0x211594(0x12b)]()+_0x539789,_0x33b785=()=>{const _0x5a9f18=_0x211594,_0x1a39a5=connect(_0x48bd22),_0x49f926=_0x19bda8=>{const _0x4a8e2f=_0x66a0;_0x1a39a5[_0x4a8e2f(0x181)]();if(Date[_0x4a8e2f(0x12b)]()>=_0x2f6040){_0x113c95(new Error(_0x4a8e2f(0x10a)+_0x19bda8[_0x4a8e2f(0x154)]));return;}setTimeout(_0x33b785,0x965+0x55*0x7+-0xb9f);};_0x1a39a5[_0x5a9f18(0x109)](_0x5a9f18(0x178),()=>_0x41b5d5(_0x1a39a5)),_0x1a39a5[_0x5a9f18(0x109)](_0x5a9f18(0x159),_0x49f926);};_0x33b785();});}
|
|
1
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { unlink } from 'node:fs/promises';
|
|
5
|
+
import { connect } from 'node:net';
|
|
6
|
+
import { tmpdir } from 'node:os';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { createInterface } from 'node:readline';
|
|
9
|
+
import { minimalRunnerEnvironment, platformCliInvocation, runRunnerProbe } from './operational.js';
|
|
10
|
+
const REQUEST_TIMEOUT_MS = 15_000;
|
|
11
|
+
/**
|
|
12
|
+
* Maps the facts that the Node can actually establish to user-visible
|
|
13
|
+
* controls. In particular, seeing an external thread never implies that it
|
|
14
|
+
* is safe to write to its active turn.
|
|
15
|
+
*/
|
|
16
|
+
export function codexSessionControl(input) {
|
|
17
|
+
if (!input.available)
|
|
18
|
+
return { level: 'UNAVAILABLE', capabilities: [] };
|
|
19
|
+
if (input.sharedControl) {
|
|
20
|
+
return {
|
|
21
|
+
level: 'SHARED_CONTROL',
|
|
22
|
+
capabilities: ['history.read', 'events.live', 'turn.start', 'turn.steer', 'turn.interrupt']
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (input.nativeThreadId !== null && input.nativeControl === 'EXTERNAL') {
|
|
26
|
+
return { level: 'OBSERVE_ONLY', capabilities: ['history.read'] };
|
|
27
|
+
}
|
|
28
|
+
if (input.activeTurn) {
|
|
29
|
+
return {
|
|
30
|
+
level: 'MANAGED',
|
|
31
|
+
capabilities: ['history.read', 'events.live', 'turn.steer', 'turn.interrupt']
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
level: 'RESUMABLE',
|
|
36
|
+
capabilities: ['history.read', 'turn.start']
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export class CodexAppServerRpcError extends Error {
|
|
40
|
+
code;
|
|
41
|
+
rpcMessage;
|
|
42
|
+
data;
|
|
43
|
+
constructor(payload) {
|
|
44
|
+
const rpcMessage = typeof payload.message === 'string' ? payload.message : 'Codex App Server request failed';
|
|
45
|
+
super(`CODEX_APP_SERVER_RPC_ERROR:${JSON.stringify(payload)}`);
|
|
46
|
+
this.name = 'CodexAppServerRpcError';
|
|
47
|
+
this.code = payload.code;
|
|
48
|
+
this.rpcMessage = rpcMessage;
|
|
49
|
+
this.data = payload.data;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function isCodexRolloutMissingError(error) {
|
|
53
|
+
return (error instanceof CodexAppServerRpcError &&
|
|
54
|
+
error.code === -32600 &&
|
|
55
|
+
(/^no rollout found for thread id\b/i.test(error.rpcMessage) ||
|
|
56
|
+
/^thread not loaded:\s*/i.test(error.rpcMessage)));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Local JSON-RPC client for a Node-supervised Codex App Server. Linux/macOS
|
|
60
|
+
* use a private Unix socket by default; Windows uses stdio. Neither is exposed
|
|
61
|
+
* to MAR Server or the browser.
|
|
62
|
+
*/
|
|
63
|
+
export class CodexAppServerClient {
|
|
64
|
+
options;
|
|
65
|
+
child;
|
|
66
|
+
transport;
|
|
67
|
+
socketPath;
|
|
68
|
+
nextId = 1;
|
|
69
|
+
pending = new Map();
|
|
70
|
+
pendingDrainWaiters = new Set();
|
|
71
|
+
notifications = new Set();
|
|
72
|
+
environment = {};
|
|
73
|
+
starting;
|
|
74
|
+
restarting;
|
|
75
|
+
lifecycleRevision = 0;
|
|
76
|
+
constructor(options = {}) {
|
|
77
|
+
this.options = options;
|
|
78
|
+
}
|
|
79
|
+
configureEnvironment(environment) {
|
|
80
|
+
if (this.child !== undefined)
|
|
81
|
+
throw new Error('CODEX_APP_SERVER_ALREADY_STARTED');
|
|
82
|
+
this.environment = { ...environment };
|
|
83
|
+
}
|
|
84
|
+
clearEnvironment() {
|
|
85
|
+
if (this.child !== undefined)
|
|
86
|
+
throw new Error('CODEX_APP_SERVER_ALREADY_STARTED');
|
|
87
|
+
this.environment = {};
|
|
88
|
+
}
|
|
89
|
+
start() {
|
|
90
|
+
if (this.restarting !== undefined)
|
|
91
|
+
return this.restarting;
|
|
92
|
+
if (this.starting !== undefined)
|
|
93
|
+
return this.starting;
|
|
94
|
+
if (this.child !== undefined)
|
|
95
|
+
return Promise.resolve();
|
|
96
|
+
const starting = this.startManaged();
|
|
97
|
+
this.starting = starting;
|
|
98
|
+
const clearStarting = () => {
|
|
99
|
+
if (this.starting === starting)
|
|
100
|
+
this.starting = undefined;
|
|
101
|
+
};
|
|
102
|
+
void starting.then(clearStarting, clearStarting);
|
|
103
|
+
return starting;
|
|
104
|
+
}
|
|
105
|
+
restart() {
|
|
106
|
+
if (this.restarting !== undefined)
|
|
107
|
+
return this.restarting;
|
|
108
|
+
const restarting = this.restartManaged(this.lifecycleRevision);
|
|
109
|
+
this.restarting = restarting;
|
|
110
|
+
const clearRestarting = () => {
|
|
111
|
+
if (this.restarting === restarting)
|
|
112
|
+
this.restarting = undefined;
|
|
113
|
+
};
|
|
114
|
+
void restarting.then(clearRestarting, clearRestarting);
|
|
115
|
+
return restarting;
|
|
116
|
+
}
|
|
117
|
+
async startManaged() {
|
|
118
|
+
const command = this.options.command ?? 'codex';
|
|
119
|
+
const mode = this.transportMode();
|
|
120
|
+
this.socketPath =
|
|
121
|
+
mode === 'unix' ? (this.options.socketPath ?? privateSocketPath()) : undefined;
|
|
122
|
+
const baseArgs = this.options.args ?? ['app-server'];
|
|
123
|
+
const args = [
|
|
124
|
+
...baseArgs,
|
|
125
|
+
...(mode === 'unix' ? ['--listen', `unix://${this.socketPath}`] : [])
|
|
126
|
+
];
|
|
127
|
+
const spawnProcess = this.options.spawnProcess ?? defaultSpawn;
|
|
128
|
+
let child = spawnProcess(command, args, {
|
|
129
|
+
...(this.options.cwd === undefined ? {} : { cwd: this.options.cwd }),
|
|
130
|
+
env: { ...minimalRunnerEnvironment(), ...this.environment }
|
|
131
|
+
});
|
|
132
|
+
this.child = child;
|
|
133
|
+
let socket;
|
|
134
|
+
if (mode === 'unix') {
|
|
135
|
+
try {
|
|
136
|
+
socket = await connectUnix(this.socketPath, (this.options.transport ?? 'auto') === 'auto'
|
|
137
|
+
? Math.min(this.options.timeoutMs ?? REQUEST_TIMEOUT_MS, 1_000)
|
|
138
|
+
: (this.options.timeoutMs ?? REQUEST_TIMEOUT_MS));
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
if ((this.options.transport ?? 'auto') !== 'auto')
|
|
142
|
+
throw error;
|
|
143
|
+
child.kill();
|
|
144
|
+
if (this.socketPath !== undefined && existsSync(this.socketPath))
|
|
145
|
+
await unlink(this.socketPath);
|
|
146
|
+
this.socketPath = undefined;
|
|
147
|
+
child = spawnProcess(command, baseArgs, {
|
|
148
|
+
...(this.options.cwd === undefined ? {} : { cwd: this.options.cwd }),
|
|
149
|
+
env: { ...minimalRunnerEnvironment(), ...this.environment }
|
|
150
|
+
});
|
|
151
|
+
this.child = child;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
this.transport = socket ?? stdioTransport(child);
|
|
155
|
+
const lines = createInterface({ input: socket ?? child.stdout });
|
|
156
|
+
lines.on('line', (line) => this.handleLine(line));
|
|
157
|
+
const managedChild = child;
|
|
158
|
+
child.once('error', (error) => {
|
|
159
|
+
if (this.child !== managedChild)
|
|
160
|
+
return;
|
|
161
|
+
this.failAll(new Error(`CODEX_APP_SERVER_START_FAILED:${error.message}`));
|
|
162
|
+
});
|
|
163
|
+
child.once('exit', () => {
|
|
164
|
+
if (this.child !== managedChild)
|
|
165
|
+
return;
|
|
166
|
+
this.child = undefined;
|
|
167
|
+
this.failAll(new Error('CODEX_APP_SERVER_EXITED'));
|
|
168
|
+
});
|
|
169
|
+
await this.requestDirect('initialize', {
|
|
170
|
+
clientInfo: { name: 'codex_vscode', title: 'MyAgentRoam', version: '0.1.4' },
|
|
171
|
+
capabilities: { experimentalApi: true }
|
|
172
|
+
});
|
|
173
|
+
this.notify('initialized', {});
|
|
174
|
+
}
|
|
175
|
+
async restartManaged(lifecycleRevision) {
|
|
176
|
+
await Promise.resolve();
|
|
177
|
+
if (this.starting !== undefined)
|
|
178
|
+
await this.starting;
|
|
179
|
+
await this.waitForPendingRequests();
|
|
180
|
+
if (this.lifecycleRevision !== lifecycleRevision)
|
|
181
|
+
throw new Error('CODEX_APP_SERVER_STOPPED');
|
|
182
|
+
this.stopManaged();
|
|
183
|
+
await this.startManaged();
|
|
184
|
+
}
|
|
185
|
+
stop() {
|
|
186
|
+
this.lifecycleRevision += 1;
|
|
187
|
+
this.stopManaged();
|
|
188
|
+
}
|
|
189
|
+
stopManaged() {
|
|
190
|
+
this.transport?.destroy();
|
|
191
|
+
this.transport = undefined;
|
|
192
|
+
this.child?.kill();
|
|
193
|
+
this.child = undefined;
|
|
194
|
+
if (this.socketPath !== undefined && existsSync(this.socketPath))
|
|
195
|
+
void unlink(this.socketPath);
|
|
196
|
+
this.socketPath = undefined;
|
|
197
|
+
this.failAll(new Error('CODEX_APP_SERVER_STOPPED'));
|
|
198
|
+
}
|
|
199
|
+
onNotification(listener) {
|
|
200
|
+
this.notifications.add(listener);
|
|
201
|
+
return () => this.notifications.delete(listener);
|
|
202
|
+
}
|
|
203
|
+
async request(method, params) {
|
|
204
|
+
if (this.restarting !== undefined)
|
|
205
|
+
await this.restarting;
|
|
206
|
+
else if (this.starting !== undefined)
|
|
207
|
+
await this.starting;
|
|
208
|
+
return this.requestDirect(method, params);
|
|
209
|
+
}
|
|
210
|
+
requestDirect(method, params) {
|
|
211
|
+
const transport = this.transport;
|
|
212
|
+
if (transport === undefined || !transport.writable)
|
|
213
|
+
throw new Error('CODEX_APP_SERVER_UNAVAILABLE');
|
|
214
|
+
const id = this.nextId++;
|
|
215
|
+
const timeoutMs = this.options.timeoutMs ?? REQUEST_TIMEOUT_MS;
|
|
216
|
+
const result = new Promise((resolve, reject) => {
|
|
217
|
+
const timer = setTimeout(() => {
|
|
218
|
+
this.pending.delete(id);
|
|
219
|
+
this.resolvePendingDrain();
|
|
220
|
+
reject(new Error('CODEX_APP_SERVER_TIMEOUT'));
|
|
221
|
+
}, timeoutMs);
|
|
222
|
+
this.pending.set(id, { resolve, reject, timer });
|
|
223
|
+
});
|
|
224
|
+
transport.write(`${JSON.stringify({ method, id, params })}\n`);
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
waitForPendingRequests() {
|
|
228
|
+
if (this.pending.size === 0)
|
|
229
|
+
return Promise.resolve();
|
|
230
|
+
return new Promise((resolve) => this.pendingDrainWaiters.add(resolve));
|
|
231
|
+
}
|
|
232
|
+
resolvePendingDrain() {
|
|
233
|
+
if (this.pending.size !== 0)
|
|
234
|
+
return;
|
|
235
|
+
for (const resolve of this.pendingDrainWaiters)
|
|
236
|
+
resolve();
|
|
237
|
+
this.pendingDrainWaiters.clear();
|
|
238
|
+
}
|
|
239
|
+
notify(method, params) {
|
|
240
|
+
const transport = this.transport;
|
|
241
|
+
if (transport === undefined || !transport.writable)
|
|
242
|
+
throw new Error('CODEX_APP_SERVER_UNAVAILABLE');
|
|
243
|
+
transport.write(`${JSON.stringify({ method, params })}\n`);
|
|
244
|
+
}
|
|
245
|
+
respond(requestId, result) {
|
|
246
|
+
const transport = this.transport;
|
|
247
|
+
if (transport === undefined || !transport.writable)
|
|
248
|
+
throw new Error('CODEX_APP_SERVER_UNAVAILABLE');
|
|
249
|
+
transport.write(`${JSON.stringify({ id: requestId, result })}\n`);
|
|
250
|
+
}
|
|
251
|
+
startThread(cwd, configuration = {}) {
|
|
252
|
+
return this.request('thread/start', {
|
|
253
|
+
cwd,
|
|
254
|
+
...codexThreadConfiguration(cwd, configuration)
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
listThreads() {
|
|
258
|
+
return this.request('thread/list', {});
|
|
259
|
+
}
|
|
260
|
+
listCollaborationModes() {
|
|
261
|
+
return this.request('collaborationMode/list', {});
|
|
262
|
+
}
|
|
263
|
+
listModels(params) {
|
|
264
|
+
return this.request('model/list', params);
|
|
265
|
+
}
|
|
266
|
+
forkThread(threadId, cwd, lastTurnId, configuration = {}) {
|
|
267
|
+
return this.request('thread/fork', {
|
|
268
|
+
threadId,
|
|
269
|
+
lastTurnId,
|
|
270
|
+
cwd,
|
|
271
|
+
...codexThreadConfiguration(cwd, configuration)
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
setThreadName(threadId, name) {
|
|
275
|
+
return this.request('thread/name/set', { threadId, name });
|
|
276
|
+
}
|
|
277
|
+
resumeThread(threadId, cwd, configuration = {}) {
|
|
278
|
+
return this.request('thread/resume', {
|
|
279
|
+
threadId,
|
|
280
|
+
cwd,
|
|
281
|
+
...codexThreadConfiguration(cwd, configuration)
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
startTurn(threadId, text, cwd, configuration = {}, attachments = []) {
|
|
285
|
+
return this.request('turn/start', {
|
|
286
|
+
threadId,
|
|
287
|
+
cwd,
|
|
288
|
+
input: [{ type: 'text', text }, ...attachments],
|
|
289
|
+
...codexTurnConfiguration(cwd, configuration)
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
steerTurn(threadId, expectedTurnId, text) {
|
|
293
|
+
return this.request('turn/steer', {
|
|
294
|
+
threadId,
|
|
295
|
+
expectedTurnId,
|
|
296
|
+
input: [{ type: 'text', text }]
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
interruptTurn(threadId, turnId) {
|
|
300
|
+
return this.request('turn/interrupt', { threadId, turnId });
|
|
301
|
+
}
|
|
302
|
+
handleLine(line) {
|
|
303
|
+
let message;
|
|
304
|
+
try {
|
|
305
|
+
message = JSON.parse(line);
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
if ((typeof message.id === 'number' || typeof message.id === 'string') &&
|
|
311
|
+
typeof message.method === 'string') {
|
|
312
|
+
for (const listener of this.notifications) {
|
|
313
|
+
listener({ method: message.method, params: message.params, requestId: message.id });
|
|
314
|
+
}
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
if (typeof message.id === 'number') {
|
|
318
|
+
const pending = this.pending.get(message.id);
|
|
319
|
+
if (pending === undefined)
|
|
320
|
+
return;
|
|
321
|
+
clearTimeout(pending.timer);
|
|
322
|
+
this.pending.delete(message.id);
|
|
323
|
+
this.resolvePendingDrain();
|
|
324
|
+
if (message.error !== undefined) {
|
|
325
|
+
pending.reject(new CodexAppServerRpcError(isRecord(message.error) ? message.error : { message: String(message.error) }));
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
pending.resolve(message.result);
|
|
329
|
+
}
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (typeof message.method === 'string') {
|
|
333
|
+
for (const listener of this.notifications)
|
|
334
|
+
listener({ method: message.method, params: message.params });
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
failAll(error) {
|
|
338
|
+
for (const [id, pending] of this.pending) {
|
|
339
|
+
clearTimeout(pending.timer);
|
|
340
|
+
pending.reject(error);
|
|
341
|
+
this.pending.delete(id);
|
|
342
|
+
}
|
|
343
|
+
this.resolvePendingDrain();
|
|
344
|
+
}
|
|
345
|
+
transportMode() {
|
|
346
|
+
const requested = this.options.transport ?? 'auto';
|
|
347
|
+
if (requested === 'auto')
|
|
348
|
+
return process.platform === 'linux' || process.platform === 'darwin' ? 'unix' : 'stdio';
|
|
349
|
+
if (requested === 'unix' && process.platform !== 'linux' && process.platform !== 'darwin') {
|
|
350
|
+
throw new Error('CODEX_UNIX_SOCKET_PLATFORM_UNSUPPORTED');
|
|
351
|
+
}
|
|
352
|
+
return requested;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
function codexThreadConfiguration(cwd, configuration) {
|
|
356
|
+
return {
|
|
357
|
+
...modelOption(configuration.model),
|
|
358
|
+
...(configuration.developerInstructions === undefined
|
|
359
|
+
? {}
|
|
360
|
+
: { developerInstructions: configuration.developerInstructions }),
|
|
361
|
+
...(configuration.mcpServers === undefined
|
|
362
|
+
? {}
|
|
363
|
+
: {
|
|
364
|
+
config: {
|
|
365
|
+
mcp_servers: configuration.mcpServers
|
|
366
|
+
}
|
|
367
|
+
}),
|
|
368
|
+
...codexPermissionConfiguration(cwd, configuration.access, 'thread')
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function codexTurnConfiguration(cwd, configuration) {
|
|
372
|
+
const effort = typeof configuration.effort === 'string' && configuration.effort.trim().length > 0
|
|
373
|
+
? configuration.effort
|
|
374
|
+
: null;
|
|
375
|
+
return {
|
|
376
|
+
...modelOption(configuration.model),
|
|
377
|
+
...(effort === null ? {} : { effort }),
|
|
378
|
+
...(configuration.serviceTier === 'fast' ? { serviceTier: 'fast' } : {}),
|
|
379
|
+
...(configuration.collaborationMode === undefined
|
|
380
|
+
? {}
|
|
381
|
+
: {
|
|
382
|
+
collaborationMode: {
|
|
383
|
+
mode: configuration.collaborationMode,
|
|
384
|
+
settings: {
|
|
385
|
+
model: configuration.model ?? 'gpt-5.6-sol',
|
|
386
|
+
reasoningEffort: effort
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}),
|
|
390
|
+
...codexPermissionConfiguration(cwd, configuration.access, 'turn')
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
function modelOption(model) {
|
|
394
|
+
return model === undefined || model === null ? {} : { model };
|
|
395
|
+
}
|
|
396
|
+
function codexPermissionConfiguration(cwd, access, phase) {
|
|
397
|
+
const sandbox = access === 'read-only'
|
|
398
|
+
? 'read-only'
|
|
399
|
+
: access === 'workspace-write' || access === 'on-request'
|
|
400
|
+
? 'workspace-write'
|
|
401
|
+
: access === 'full-access'
|
|
402
|
+
? 'danger-full-access'
|
|
403
|
+
: undefined;
|
|
404
|
+
const approvalPolicy = access === 'workspace-write' || access === 'full-access' ? 'never' : 'on-request';
|
|
405
|
+
if (phase === 'thread')
|
|
406
|
+
return {
|
|
407
|
+
...(sandbox === undefined ? {} : { sandbox }),
|
|
408
|
+
approvalPolicy
|
|
409
|
+
};
|
|
410
|
+
return {
|
|
411
|
+
...(sandbox === undefined
|
|
412
|
+
? {}
|
|
413
|
+
: {
|
|
414
|
+
sandboxPolicy: sandbox === 'read-only'
|
|
415
|
+
? { type: 'readOnly' }
|
|
416
|
+
: sandbox === 'danger-full-access'
|
|
417
|
+
? { type: 'dangerFullAccess' }
|
|
418
|
+
: { type: 'workspaceWrite', writableRoots: [cwd], networkAccess: true }
|
|
419
|
+
}),
|
|
420
|
+
approvalPolicy
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
export function probeCodex(command = 'codex') {
|
|
424
|
+
const invocation = platformCliInvocation(command, ['--version']);
|
|
425
|
+
const result = spawnSync(invocation.command, invocation.args, {
|
|
426
|
+
windowsHide: true,
|
|
427
|
+
env: minimalRunnerEnvironment(),
|
|
428
|
+
timeout: 3_000,
|
|
429
|
+
encoding: 'utf8'
|
|
430
|
+
});
|
|
431
|
+
if (result.status !== 0 || result.error !== undefined)
|
|
432
|
+
return { available: false, compatible: false };
|
|
433
|
+
const version = `${result.stdout}${result.stderr}`.trim().slice(0, 128);
|
|
434
|
+
return {
|
|
435
|
+
available: true,
|
|
436
|
+
...(version.length === 0 ? {} : { version }),
|
|
437
|
+
// The CLI version is metadata only. Actual compatibility is established
|
|
438
|
+
// by the App Server initialize handshake when the client starts.
|
|
439
|
+
compatible: true
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
export async function probeCodexAsync(command = 'codex') {
|
|
443
|
+
const invocation = platformCliInvocation(command, ['--version']);
|
|
444
|
+
const result = await runRunnerProbe(invocation.command, invocation.args, {
|
|
445
|
+
env: minimalRunnerEnvironment(),
|
|
446
|
+
timeoutMs: 3_000
|
|
447
|
+
});
|
|
448
|
+
if (result.status !== 0)
|
|
449
|
+
return { available: false, compatible: false };
|
|
450
|
+
const version = `${result.stdout}${result.stderr}`.trim().slice(0, 128);
|
|
451
|
+
return {
|
|
452
|
+
available: true,
|
|
453
|
+
...(version.length === 0 ? {} : { version }),
|
|
454
|
+
// Do not reject a newer CLI before its App Server has had a chance to
|
|
455
|
+
// negotiate the protocol it actually supports.
|
|
456
|
+
compatible: true
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
export function isSupportedCodexVersion(version) {
|
|
460
|
+
return version.trim().length > 0;
|
|
461
|
+
}
|
|
462
|
+
function defaultSpawn(command, args, options) {
|
|
463
|
+
const invocation = platformCliInvocation(command, args);
|
|
464
|
+
return spawn(invocation.command, invocation.args, {
|
|
465
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
466
|
+
shell: false,
|
|
467
|
+
windowsHide: true,
|
|
468
|
+
...(options.cwd === undefined ? {} : { cwd: options.cwd }),
|
|
469
|
+
...(options.env === undefined ? {} : { env: options.env })
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
function isRecord(value) {
|
|
473
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
474
|
+
}
|
|
475
|
+
function stdioTransport(child) {
|
|
476
|
+
return {
|
|
477
|
+
get writable() {
|
|
478
|
+
return child.stdin.writable;
|
|
479
|
+
},
|
|
480
|
+
write: (data) => child.stdin.write(data),
|
|
481
|
+
on: (event, listener) => child.stdout.on(event, listener),
|
|
482
|
+
once: (event, listener) => child.stdout.once(event, listener),
|
|
483
|
+
destroy: () => child.stdout.destroy()
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
export function privateSocketPath(directory = tmpdir(), processId = process.pid, entropy = randomUUID()) {
|
|
487
|
+
// macOS has a shorter Unix-domain socket pathname limit than Linux, and its
|
|
488
|
+
// per-user TMPDIR is comparatively long. The process ID plus 64 random bits
|
|
489
|
+
// keeps concurrent sockets distinct while leaving room for that directory.
|
|
490
|
+
return join(directory, `m-${processId}-${entropy.replaceAll('-', '').slice(0, 16)}.sock`);
|
|
491
|
+
}
|
|
492
|
+
function connectUnix(socketPath, timeoutMs) {
|
|
493
|
+
return new Promise((resolve, reject) => {
|
|
494
|
+
const deadline = Date.now() + timeoutMs;
|
|
495
|
+
const attempt = () => {
|
|
496
|
+
const socket = connect(socketPath);
|
|
497
|
+
const retry = (error) => {
|
|
498
|
+
socket.destroy();
|
|
499
|
+
if (Date.now() >= deadline) {
|
|
500
|
+
reject(new Error(`CODEX_UNIX_SOCKET_CONNECT_FAILED:${error.message}`));
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
setTimeout(attempt, 25);
|
|
504
|
+
};
|
|
505
|
+
socket.once('connect', () => resolve(socket));
|
|
506
|
+
socket.once('error', retry);
|
|
507
|
+
};
|
|
508
|
+
attempt();
|
|
509
|
+
});
|
|
510
|
+
}
|