@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,510 @@
|
|
|
1
|
-
|
|
2
|
-
(function(_0x3f4f8d,_0x1a7fd8){const _0x500baa=_0x529e,_0x3133bd=_0x3f4f8d();while(!![]){try{const _0x50fc74=parseInt(_0x500baa(0x19d))/(0x89*0x3b+-0x17db+0x19*-0x4f)*(parseInt(_0x500baa(0x17f))/(0x1*-0x87b+-0x19bc+0x2239*0x1))+-parseInt(_0x500baa(0x1be))/(-0x1f89+0x298+0x1cf4)*(parseInt(_0x500baa(0x144))/(-0x98f+-0x24ab+0x3*0xf6a))+-parseInt(_0x500baa(0x14c))/(0x86+0x1c67+-0x1ce8)*(parseInt(_0x500baa(0x140))/(0x1e19*-0x1+-0x238e+0x41ad))+parseInt(_0x500baa(0x181))/(-0x212d+0x82f*-0x1+-0x1*-0x2963)*(parseInt(_0x500baa(0x170))/(0x5*0x6f8+0x1edf+0x5*-0xd23))+parseInt(_0x500baa(0x1af))/(0x1990+-0x523*0x3+-0xa1e)+-parseInt(_0x500baa(0x166))/(-0x782*-0x1+0x19ed+-0x2165*0x1)*(-parseInt(_0x500baa(0x174))/(-0x7*-0x2cf+0x1*-0x2333+-0x1*-0xf95))+-parseInt(_0x500baa(0x183))/(0x1*-0x13ca+-0xb3*0x13+-0x3d*-0x8b)*(parseInt(_0x500baa(0x182))/(0x2462*0x1+-0x1e74+-0x5e1));if(_0x50fc74===_0x1a7fd8)break;else _0x3133bd['push'](_0x3133bd['shift']());}catch(_0x26e35d){_0x3133bd['push'](_0x3133bd['shift']());}}}(_0x2ba6,-0x781b5*-0x3+0x1d6793+0x257*-0xfb3));import{createHash}from'node:crypto';import{fileURLToPath}from'node:url';import{stripClaudePlanTag}from'../runner-command-engine.js';import{stripMissionStartPrompt}from'../service/mission-runtime.js';import{parseCodexComposerImageMarkers}from'../runner/codex/composer-image-markers.js';import{normalizeCodexTool}from'../runner/codex/tool-normalizer.js';import{normalizeClaudeTool}from'../runner/claude/tool-normalizer.js';function _0x2ba6(){const _0x3e2e10=['z2v0','qxnRvxnLCLf1zxn0Aw9U','CMvKDwnL','zMXHDe1HCa','zMLUza','oML0zw06','y29TCgXLDgvKqxq','D2LUzg93u3rHCNq','u0Lor0Xfx1nftevdva','C2v0','B3v0Chv0u3vTBwfYEq','oM5HDgL2ztO','Dw5RBM93BG','Dg9VBf9JywXS','BwvZC2fNzq','Aw5WDxq','yMfZzty0DxjS','zgLZDgfUy2u','C291CMnLs2LUza','BMf0AxzLlwzPBgu','B3b0Aw9UCW','qundrvburuq','mtq4odK0menKvKjeva','Aw1Hz2vbDhrHy2HTzw50CW','Dg9tDhjPBMC','D2LUmZi','DxnLCL9TzxnZywDL','C2HHmJu2','DgvZDa','CMvHC29UAw5Nx3n1Bw1HCNK','zMLUzeXHC3q','A2LUza','C3rYAw5NAwz5','AxrLBs0','CgXHBG','CMvWBgfJzq','DxnLzfrVA2vUCW','DhjPBq','y3vYC29Y','zMLSzufUy2HVCG','mtiYmZy3nJLpv1H4vfi','C3rHCNrLzef0','y29KzxG','BwLU','Dg9VBfvZzuLK','tvvmveLFu0vmrunu','q09ervHF','AxrLBxm','y3vYC29YuMvZzxq','BgLTAxq','C3rYAw5N','D2LUzg93rw5K','Bw9KzwW','CxvLC3rPB24','C3vIywDLBNq','m05sA1jztG','BMf0AxzLswq','C3vIqwDLBNq','BMf0AxzLoG','Aw5WDxrtDw1Tyxj5','D2LUzg93uMvHzeXPBwL0','y29UDgv4Df9JB21Wywn0Aw9U','zxjYB3i','yw5JAg9YqNL0zxm','BgfIzwW','zgf0yq','vvnfuG','q09ervHFveHsrufex0nxrf9jtLzbteLe','BMfTzq','BxvSDgLtzwXLy3q','ywjZ','y2XHDwrLlxf1zxn0Aw9Ulq','CxvLC3rPB25Z','C2vZC2LVBKLK','C2XPy2u','B2jQzwn0','mJq2D0HIqu5y','BwfYA2rVD24','ChvZAa','BwfW','mJyYnJC0ohzIwvb0sW','DgL0Bgu','AxnbCNjHEq','y3jLyxrLzef0','CgHHC2u','u1vdq0vfreve','y2XHDwrLlwnVzgu','u0HpuLrFvevyva','mti1mdm1t0zHALrU','Dhj1BMnHDgvK','C29YDa','CNvUBMvY','rKfjteve','zw50CMLLCW','DxbKyxrL','Bwf4vg9Rzw5Z','CNvUswq','y2HHCMfJDgvYCW','C3vTBwfYEq','q09nueXfveve','Dg9vChbLCKnHC2u','y3DK','DxnLCL9PBNb1Df9Yzxf1zxn0','Dw5Yzwy','zw50CNK','zMLSDgvY','C25HChnOB3rfBMq','C2vJDgLVBNm','zgvZy3jPChrPB24','Bwf4','C29Tzq','ve9ptf9fwevdvvrjt05FrKfjteve','C291CMnLrxzLBNruExbL','y2XPzw50twvZC2fNzuLK','ntqYmhn4Avzkra','phbYB3bVC2vKx3bSyw4+','Dg9VBe5HBwu','AxntAwrLy2HHAw4','BgvUz3rO','Dg9VBenHDgvNB3j5','Aw5WDxruCNvUy2f0zwq','DMfSDwvZ','zMLSztO','Dgv4Da','nJGWEwPbDuHK','y291BNq','CgXHDgzVCM0','C3rHCNrZv2L0Aa','mtm2mtHdB05iDhy','CM9Szq','ChjLDMLLDW','BgfZDefJDgL2Axr5qxq','zMfPBgvK','C291CMnL','Dg9mB3DLCKnHC2u','zgLNzxn0','zNjVBq','x0Lex01ju1njtKC','B3v0Chv0vhj1BMnHDgvK','mKf4AK1iua','yxr0ywnOBwvUDhm','nJmZmdfPDNvey3m','ntm0m2Ptu3DjBa','ndCWmJHcAu9pvvi','Cgf5Bg9Hza','CMfJzq','yxnZAxn0yw50x21LC3nHz2u'];_0x2ba6=function(){return _0x3e2e10;};return _0x2ba6();}import{compactRunnerText,isPlainRecord,nativePageEnd}from'./node-operation-parsers.js';function _0x529e(_0xd3fb47,_0x4656af){_0xd3fb47=_0xd3fb47-(0xae+0x1884*-0x1+0x1910);const _0x3b6500=_0x2ba6();let _0x52da1f=_0x3b6500[_0xd3fb47];if(_0x529e['mKJCuK']===undefined){var _0x2d7b5f=function(_0x11e0e6){const _0x3ea917='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x13d715='',_0x21017d='';for(let _0x3c5714=0x1*-0x259f+-0xb5*0x2b+-0x4406*-0x1,_0x5480df,_0x28b470,_0xbef550=-0x1979*-0x1+-0x5f4*-0x3+-0x2b55;_0x28b470=_0x11e0e6['charAt'](_0xbef550++);~_0x28b470&&(_0x5480df=_0x3c5714%(-0x562+0x1c32+-0x16cc)?_0x5480df*(0x635+-0x45d*-0x5+-0x1bc6)+_0x28b470:_0x28b470,_0x3c5714++%(-0x46f+0x2405+0x2*-0xfc9))?_0x13d715+=String['fromCharCode'](-0x17b*-0x5+-0x82b+0xb*0x29&_0x5480df>>(-(0x7e9+-0x1*0x70+-0x777)*_0x3c5714&0x1385*-0x2+-0x488+-0x28*-0x117)):0x1*0x26c5+-0xfbd+-0xb*0x218){_0x28b470=_0x3ea917['indexOf'](_0x28b470);}for(let _0x2a6ed0=-0x10*-0x1f6+0x1223*0x1+0x5*-0x9e7,_0x41a183=_0x13d715['length'];_0x2a6ed0<_0x41a183;_0x2a6ed0++){_0x21017d+='%'+('00'+_0x13d715['charCodeAt'](_0x2a6ed0)['toString'](-0x10b3+-0x257a+0x363d))['slice'](-(0x1*-0x168e+0x1*0x160a+0x2*0x43));}return decodeURIComponent(_0x21017d);};_0x529e['nmzdDt']=_0x2d7b5f,_0x529e['LEzYFC']={},_0x529e['mKJCuK']=!![];}const _0x4583cd=_0x3b6500[-0x35*-0x61+0x10*-0x185+0x3*0x169];_0x529e['qlQNyH']!==_0x4583cd&&(_0x529e['LEzYFC']={},_0x529e['qlQNyH']=_0x4583cd);const _0x4e86a7=_0x529e['LEzYFC'][_0xd3fb47];return _0x4e86a7===undefined?(_0x52da1f=_0x529e['nmzdDt'](_0x52da1f),_0x529e['LEzYFC'][_0xd3fb47]=_0x52da1f):_0x52da1f=_0x4e86a7,_0x52da1f;}export function extractId(_0x5c29da,_0x33bff8){const _0x3c3af7=_0x529e;if(typeof _0x5c29da===_0x3c3af7(0x13f)&&_0x5c29da!==null&&_0x33bff8 in _0x5c29da&&typeof _0x5c29da[_0x33bff8]===_0x3c3af7(0x13f)&&_0x5c29da[_0x33bff8]!==null&&typeof _0x5c29da[_0x33bff8]['id']===_0x3c3af7(0x1b9))return _0x5c29da[_0x33bff8]['id'];throw new Error(_0x3c3af7(0x1b5)+_0x33bff8[_0x3c3af7(0x158)]()+_0x3c3af7(0x17d));}export async function settleWithin(_0x3dded1,_0xc3753a){const _0x171998=_0x529e;let _0x587527;try{return await Promise[_0x171998(0x185)]([_0x3dded1,new Promise(_0x1f7520=>{const _0x16895c=_0x171998;_0x587527=setTimeout(()=>_0x1f7520(undefined),_0xc3753a),_0x587527[_0x16895c(0x15b)]();})]);}finally{if(_0x587527!==undefined)clearTimeout(_0x587527);}}export function extractCodexThreads(_0xdd1eaa){const _0x56da1e=_0x529e;if(typeof _0xdd1eaa!==_0x56da1e(0x13f)||_0xdd1eaa===null||!(_0x56da1e(0x1c8)in _0xdd1eaa))return[];const _0x2f7e55=_0xdd1eaa[_0x56da1e(0x1c8)];if(!Array[_0x56da1e(0x146)](_0x2f7e55))return[];return _0x2f7e55[_0x56da1e(0x18a)](_0x4d9003=>{const _0x2ba5d2=_0x56da1e;if(typeof _0x4d9003!==_0x2ba5d2(0x13f)||_0x4d9003===null)return[];const _0xf768ee=_0x4d9003;if(typeof _0xf768ee['id']!==_0x2ba5d2(0x1b9))return[];const _0x40ae8b=typeof _0xf768ee[_0x2ba5d2(0x199)]===_0x2ba5d2(0x1b9)?_0xf768ee[_0x2ba5d2(0x199)]:typeof _0xf768ee[_0x2ba5d2(0x179)]===_0x2ba5d2(0x1b9)?_0xf768ee[_0x2ba5d2(0x179)]:typeof _0xf768ee[_0x2ba5d2(0x179)]===_0x2ba5d2(0x13f)&&_0xf768ee[_0x2ba5d2(0x179)]!==null&&typeof _0xf768ee[_0x2ba5d2(0x179)][_0x2ba5d2(0x1a6)]===_0x2ba5d2(0x1b9)?_0xf768ee[_0x2ba5d2(0x179)][_0x2ba5d2(0x1a6)]:undefined,_0x402c9c=isPlainRecord(_0xf768ee[_0x2ba5d2(0x179)])?_0xf768ee[_0x2ba5d2(0x179)]:undefined,_0x52b897=_0x40ae8b===_0x2ba5d2(0x1bd)||_0x402c9c?.[_0x2ba5d2(0x1a6)]===_0x2ba5d2(0x1bd)||isPlainRecord(_0x402c9c?.[_0x2ba5d2(0x1bd)])||isPlainRecord(_0x402c9c?.[_0x2ba5d2(0x1c0)]),_0xd520f3=typeof _0xf768ee[_0x2ba5d2(0x1cb)]===_0x2ba5d2(0x1b9)&&_0xf768ee[_0x2ba5d2(0x1cb)][_0x2ba5d2(0x1ac)]()[_0x2ba5d2(0x16a)]>-0x457*-0x3+0x6*-0x43f+-0x427*-0x3?_0xf768ee[_0x2ba5d2(0x1cb)][_0x2ba5d2(0x1ac)]():typeof _0xf768ee[_0x2ba5d2(0x176)]===_0x2ba5d2(0x1b9)&&_0xf768ee[_0x2ba5d2(0x176)][_0x2ba5d2(0x1ac)]()[_0x2ba5d2(0x16a)]>0x1eca+-0x20ca+-0x10*-0x20?_0xf768ee[_0x2ba5d2(0x176)][_0x2ba5d2(0x1ac)]():undefined;return[{'id':_0xf768ee['id'],'source':_0x40ae8b,'derived':_0x52b897,'cwd':_0xf768ee[_0x2ba5d2(0x159)],'title':_0xd520f3}];});}export function codexThreadCwd(_0x54b8ed){const _0x8507c1=_0x529e;if(typeof _0x54b8ed!==_0x8507c1(0x1b9)||_0x54b8ed[_0x8507c1(0x16a)]===0xa9*-0x38+-0xc8+-0x25c*-0x10)throw new Error(_0x8507c1(0x1ca));if(!_0x54b8ed[_0x8507c1(0x173)](_0x8507c1(0x16e)))return _0x54b8ed;try{return fileURLToPath(_0x54b8ed);}catch{throw new Error(_0x8507c1(0x1ca));}}export function isWithinWorkspace(_0x205649,_0x3c57d7){const _0xcb919a=_0x529e,_0x275c9d=_0x42527a=>{const _0x358822=_0x529e,_0x3f87c7=_0x42527a[_0x358822(0x1aa)](/[\\/]+/g,'/')[_0x358822(0x1aa)](/\/$/,'');return process[_0x358822(0x172)]===_0x358822(0x1a0)?_0x3f87c7[_0x358822(0x17a)]():_0x3f87c7;},_0x5c7852=_0x275c9d(_0x205649),_0x20afdb=_0x275c9d(_0x3c57d7);if(_0x5c7852===_0x20afdb)return!![];return _0x5c7852[_0xcb919a(0x173)](_0x20afdb+'/');}export function claudeDiscoveredSession(_0x17271e,_0x37bcf3){const _0x3f0b7f=_0x529e;if(typeof _0x17271e!==_0x3f0b7f(0x13f)||_0x17271e===null)return undefined;const _0x1ca2c9=_0x17271e;if(_0x1ca2c9[_0x3f0b7f(0x169)]===!![])return undefined;const _0x8976e9=typeof _0x1ca2c9[_0x3f0b7f(0x13d)]===_0x3f0b7f(0x1b9)?_0x1ca2c9[_0x3f0b7f(0x13d)]:typeof _0x1ca2c9['id']===_0x3f0b7f(0x1b9)?_0x1ca2c9['id']:undefined;if(_0x8976e9===undefined||_0x8976e9[_0x3f0b7f(0x16a)]===-0x129a*0x2+-0x46f+0xb*0x3c9)return undefined;const _0xacbdce=typeof _0x1ca2c9[_0x3f0b7f(0x156)]===_0x3f0b7f(0x1b9)?_0x1ca2c9[_0x3f0b7f(0x156)]:typeof _0x1ca2c9[_0x3f0b7f(0x145)]===_0x3f0b7f(0x1b9)?_0x1ca2c9[_0x3f0b7f(0x145)]:undefined,_0x29dbb8=typeof _0x1ca2c9[_0x3f0b7f(0x159)]===_0x3f0b7f(0x1b9)&&_0x1ca2c9[_0x3f0b7f(0x159)][_0x3f0b7f(0x16a)]>-0x17b*-0x5+-0x82b+0x4*0x31?_0x1ca2c9[_0x3f0b7f(0x159)]:_0x37bcf3;return{'externalSessionId':_0x8976e9,'cwd':_0x29dbb8,..._0xacbdce===undefined?{}:{'title':_0xacbdce[_0x3f0b7f(0x13e)](0x7e9+-0x1*0x70+-0x779,0x1385*-0x2+-0x488+-0x29*-0x112)}};}export function latestNativeActivity(_0x334b3a){const _0x56ea90=_0x529e;return _0x334b3a[_0x56ea90(0x177)];}export function sameContextUsage(_0x2ccf23,_0x1b5b35){const _0x320245=_0x529e;return _0x2ccf23[_0x320245(0x1bb)]===_0x1b5b35[_0x320245(0x1bb)]&&_0x2ccf23[_0x320245(0x1ab)]===_0x1b5b35[_0x320245(0x1ab)]&&_0x2ccf23[_0x320245(0x153)]===_0x1b5b35[_0x320245(0x153)];}export function isNativeHistory(_0x3a22ef){const _0x24eb51=_0x529e;return typeof _0x3a22ef===_0x24eb51(0x13f)&&_0x3a22ef!==null&&Array[_0x24eb51(0x146)](_0x3a22ef[_0x24eb51(0x1b6)]);}export function deduplicateDirectSessions(_0xe8f577){const _0x43e2df=_0x529e,_0x27982a=new Map();for(const _0x5a3ae8 of _0xe8f577){const _0x31d2b3=_0x27982a[_0x43e2df(0x187)](_0x5a3ae8['id']);if(_0x31d2b3===undefined||_0x31d2b3[_0x43e2df(0x177)]<_0x5a3ae8[_0x43e2df(0x177)])_0x27982a[_0x43e2df(0x190)](_0x5a3ae8['id'],_0x5a3ae8);}return[..._0x27982a[_0x43e2df(0x16d)]()][_0x43e2df(0x14e)]((_0x45c49c,_0x4fded0)=>_0x4fded0[_0x43e2df(0x177)]-_0x45c49c[_0x43e2df(0x177)]);}export function nativeConversationPage(_0x2e9185,_0x5059e0,_0x2b77cd,_0x455273=[],_0x5f412e=()=>[]){const _0x4f564c=_0x529e,_0x459634=Math[_0x4f564c(0x1b2)](Math[_0x4f564c(0x161)](_0x2b77cd[_0x4f564c(0x1b8)]??0x1*0x26c5+-0xfbd+-0x7*0x346,-0x10*-0x1f6+0x1223*0x1+0x1*-0x3182),-0x10b3+-0x257a+0x3821),_0x4179fd=_0x5059e0[_0x4f564c(0x1b7)]===!![]?undefined:_0x2b77cd[_0x4f564c(0x1ad)],_0x674d00=nativeTranscriptTurns(_0x5059e0[_0x4f564c(0x1b6)]),_0x5aea52=nativeTranscriptTurnIds(_0x2e9185['id'],_0x674d00),_0x11d77b=nativePageEnd(_0x4179fd,_0x2e9185['id'],_0x674d00[_0x4f564c(0x16a)]),_0x1b6ff7=Math[_0x4f564c(0x161)](0x1*-0x168e+0x1*0x160a+0xb*0xc,_0x11d77b-_0x459634),_0x380b40=_0x674d00[_0x4f564c(0x13e)](_0x1b6ff7,_0x11d77b)[_0x4f564c(0x143)]((_0x10be13,_0x16a7a6)=>{const _0x3f88aa=_0x4f564c,_0x47b1d0=_0x10be13[_0x3f88aa(0x18b)](({entry:_0x46a25a})=>_0x46a25a[_0x3f88aa(0x1a6)]===_0x3f88aa(0x195)&&_0x46a25a[_0x3f88aa(0x175)]===_0x3f88aa(0x1c9))?.[_0x3f88aa(0x15c)],_0x55ca39=_0x47b1d0?.[_0x3f88aa(0x1a6)]===_0x3f88aa(0x195)?nativeUserClientMessageId(_0x2e9185[_0x3f88aa(0x14f)],_0x47b1d0,_0x47b1d0[_0x3f88aa(0x147)],_0x455273):null,_0x1a5dc6=typeof _0x55ca39===_0x3f88aa(0x1b9)?_0x455273[_0x3f88aa(0x18b)](_0x569fb7=>runtimeTurnClientMessageId(_0x569fb7)===_0x55ca39):undefined,_0x592ac8=_0x1a5dc6?.['id']??_0x5aea52[_0x1b6ff7+_0x16a7a6],_0x12238d=nativeTranscriptItemIdentities(_0x10be13),_0x46cfb2=_0x10be13[_0x3f88aa(0x143)](({entry:_0x1efc98,index:_0x34a55d},_0x1318ae)=>({...nativeTranscriptConversationItem(_0x2e9185,_0x1efc98,_0x34a55d,_0x12238d[_0x1318ae],_0x592ac8,_0x455273,_0x5f412e),'runId':_0x1a5dc6?.[_0x3f88aa(0x154)]??null})),_0x558b00=(_0x1a5dc6?.[_0x3f88aa(0x1b6)]??[])[_0x3f88aa(0x15d)](_0xef6697=>_0xef6697[_0x3f88aa(0x1a6)]===_0x3f88aa(0x1c5))[_0x3f88aa(0x143)](_0x388ca0=>({..._0x388ca0,'turnId':_0x592ac8,'runId':_0x1a5dc6?.[_0x3f88aa(0x154)]??null})),_0x45dca9=runtimeAssistantProjectionMoreComplete(_0x1a5dc6,_0x46cfb2)?_0x1a5dc6[_0x3f88aa(0x1b6)][_0x3f88aa(0x143)](_0x5322ec=>({..._0x5322ec,'turnId':_0x592ac8,'runId':_0x1a5dc6[_0x3f88aa(0x154)]})):[..._0x46cfb2,..._0x558b00[_0x3f88aa(0x15d)](_0x31bfd7=>!_0x46cfb2[_0x3f88aa(0x162)](_0x22c4c4=>_0x22c4c4['id']===_0x31bfd7['id']))],_0x2d6721=_0x45dca9[-0x35*-0x61+0x10*-0x185+0x3*0x169]?.[_0x3f88aa(0x1b0)]??null,_0x580bd3=_0x45dca9['at'](-(0x204*-0xe+0x128f+0x4d5*0x2))?.[_0x3f88aa(0x18d)]??_0x2d6721,_0x4dc1e5=lastNativeItemId(_0x10be13);return{'id':_0x592ac8,'sessionId':_0x2e9185['id'],'runId':_0x1a5dc6?.[_0x3f88aa(0x154)]??null,'userItemId':_0x45dca9[_0x3f88aa(0x18b)](_0x438a6f=>_0x438a6f[_0x3f88aa(0x1a6)]===_0x3f88aa(0x1a1))?.['id']??null,'status':_0x558b00[_0x3f88aa(0x16a)]>-0x186d+0xc44+0xc29*0x1?_0x3f88aa(0x150):_0x3f88aa(0x149),'model':null,'effort':null,'access':null,..._0x4dc1e5===undefined||_0x2e9185[_0x3f88aa(0x14f)]!==_0x3f88aa(0x14a)?{}:{'rewind':{'before':lastNativeItemId(_0x674d00[_0x1b6ff7+_0x16a7a6-(-0x5b9+0x1*-0x1d4b+0xb*0x32f)]??[])??null,'after':_0x4dc1e5}},'items':_0x45dca9,'startedAt':_0x2d6721,'completedAt':_0x580bd3};}),_0x3d8d5b=_0x380b40,_0x2a546b=_0x1b6ff7,_0x33ed2e={'sessionId':_0x2e9185['id'],..._0x5059e0[_0x4f564c(0x15e)]===undefined?{}:{'snapshotEnd':_0x5059e0[_0x4f564c(0x15e)]},..._0x5059e0[_0x4f564c(0x1ba)]===undefined?{}:{'nextEnd':_0x5059e0[_0x4f564c(0x1ba)]},..._0x5059e0[_0x4f564c(0x1ae)]===undefined?{}:{'fileAnchor':_0x5059e0[_0x4f564c(0x1ae)]},..._0x5059e0[_0x4f564c(0x1c6)]===undefined?{}:{'anchorBytes':_0x5059e0[_0x4f564c(0x1c6)]},'readLimit':_0x5059e0[_0x4f564c(0x1c3)]??_0x459634},_0x50ea44=_0x5059e0[_0x4f564c(0x14d)]===!![]&&_0x5059e0[_0x4f564c(0x18e)]!==undefined&&_0x5059e0[_0x4f564c(0x15e)]!==undefined&&_0x5059e0[_0x4f564c(0x1ae)]!==undefined&&_0x5059e0[_0x4f564c(0x1c6)]!==undefined?Buffer[_0x4f564c(0x17c)](JSON[_0x4f564c(0x1a7)]({'sessionId':_0x2e9185['id'],'snapshotEnd':_0x5059e0[_0x4f564c(0x15e)],'nextEnd':_0x5059e0[_0x4f564c(0x18e)],'fileAnchor':_0x5059e0[_0x4f564c(0x1ae)],'anchorBytes':_0x5059e0[_0x4f564c(0x1c6)],'readLimit':_0x5059e0[_0x4f564c(0x1c3)]??_0x459634}))[_0x4f564c(0x19f)](_0x4f564c(0x197)):null;return{'turns':_0x3d8d5b,'nextCursor':_0x2a546b>0x2*-0xdf7+0x11*0x183+-0x1*-0x23b?Buffer[_0x4f564c(0x17c)](JSON[_0x4f564c(0x1a7)]({..._0x33ed2e,'end':_0x2a546b}))[_0x4f564c(0x19f)](_0x4f564c(0x197)):_0x50ea44};}export function runtimeAssistantProjectionMoreComplete(_0x5f44da,_0x1c2772){const _0x2a42aa=_0x529e;if(_0x5f44da===undefined)return![];const _0xf303ba=_0x221ef0=>_0x221ef0[_0x2a42aa(0x189)]((_0x3bae90,_0xcdadab)=>{const _0xf2e965=_0x2a42aa;if(_0xcdadab[_0xf2e965(0x1a6)]!==_0xf2e965(0x186)||!isPlainRecord(_0xcdadab[_0xf2e965(0x184)]))return _0x3bae90;return{'count':_0x3bae90[_0xf2e965(0x171)]+(0xd81*0x1+-0x11fb*0x2+0x1676),'characters':_0x3bae90[_0xf2e965(0x155)]+(typeof _0xcdadab[_0xf2e965(0x184)][_0xf2e965(0x16f)]===_0xf2e965(0x1b9)?_0xcdadab[_0xf2e965(0x184)][_0xf2e965(0x16f)][_0xf2e965(0x16a)]:-0x1*-0x219d+0x24f5*0x1+0x1786*-0x3)};},{'count':0x0,'characters':0x0}),_0x2fd6b1=_0xf303ba(_0x5f44da[_0x2a42aa(0x1b6)]),_0x5cdad3=_0xf303ba(_0x1c2772);return _0x2fd6b1[_0x2a42aa(0x171)]>_0x5cdad3[_0x2a42aa(0x171)]||_0x2fd6b1[_0x2a42aa(0x155)]>_0x5cdad3[_0x2a42aa(0x155)];}function runtimeTurnClientMessageId(_0x27a4aa){const _0x309d60=_0x529e,_0x427a7d=_0x27a4aa[_0x309d60(0x1b6)][_0x309d60(0x18b)](_0x21502f=>_0x21502f[_0x309d60(0x1a6)]===_0x309d60(0x1a1));return isPlainRecord(_0x427a7d?.[_0x309d60(0x184)])&&typeof _0x427a7d[_0x309d60(0x184)][_0x309d60(0x165)]===_0x309d60(0x1b9)?_0x427a7d[_0x309d60(0x184)][_0x309d60(0x165)]:undefined;}function lastNativeItemId(_0x4895fd){const _0x2b6e85=_0x529e;return _0x4895fd[_0x2b6e85(0x1a5)](({entry:_0x378454})=>_0x378454[_0x2b6e85(0x1bf)]!==undefined)?.[_0x2b6e85(0x15c)][_0x2b6e85(0x1bf)];}function nativeTranscriptTurnIds(_0x2f2ff1,_0x146964){const _0x14eeb5=_0x529e,_0x2f0c4e=new Map();return _0x146964[_0x14eeb5(0x143)](_0x160fcc=>{const _0x11dafc=_0x14eeb5,_0x358aa4=_0x160fcc[_0x11dafc(0x18b)](({entry:_0x2fc343})=>_0x2fc343[_0x11dafc(0x1a6)]===_0x11dafc(0x195)&&_0x2fc343[_0x11dafc(0x175)]===_0x11dafc(0x1c9))?.[_0x11dafc(0x15c)],_0x32e406=_0x358aa4??_0x160fcc[-0x15e+-0x151d+-0x167b*-0x1]?.[_0x11dafc(0x15c)],_0x2432a8=_0x32e406?.[_0x11dafc(0x1bf)]??nativeTranscriptItemFingerprint(_0x32e406),_0xb4e567=_0x2f0c4e[_0x11dafc(0x187)](_0x2432a8)??-0xed*-0x1+-0x5*-0x607+0x470*-0x7;return _0x2f0c4e[_0x11dafc(0x190)](_0x2432a8,_0xb4e567+(-0x94e+0x76a+0x1e5)),_0x2f2ff1+_0x11dafc(0x192)+_0x2432a8+(_0xb4e567===-0x18c7*0x1+-0x9af+0x2276?'':':'+_0xb4e567);});}function nativeTranscriptItemIdentities(_0x54015f){const _0x2b2010=_0x529e,_0x11922f=new Map();for(const {entry:_0x5dbbb8}of _0x54015f)if(_0x5dbbb8[_0x2b2010(0x1bf)]!==undefined)_0x11922f[_0x2b2010(0x190)](_0x5dbbb8[_0x2b2010(0x1bf)],(_0x11922f[_0x2b2010(0x187)](_0x5dbbb8[_0x2b2010(0x1bf)])??0xfd7+0x58d+-0x1564)+(0x26f8+0x1ce9*-0x1+0x63*-0x1a));const _0x559461=new Map();return _0x54015f[_0x2b2010(0x143)](({entry:_0x3233c6})=>{const _0x35967f=_0x2b2010,_0x4b934c=_0x3233c6[_0x35967f(0x1bf)]!==undefined&&_0x11922f[_0x35967f(0x187)](_0x3233c6[_0x35967f(0x1bf)])===-0x1731+-0x4e3+0x1*0x1c15?_0x3233c6[_0x35967f(0x1bf)]:''+(_0x3233c6[_0x35967f(0x1bf)]===undefined?'':_0x3233c6[_0x35967f(0x1bf)]+':')+nativeTranscriptItemFingerprint(_0x3233c6),_0x5b0283=_0x559461[_0x35967f(0x187)](_0x4b934c)??-0x56d*-0x5+0xe*0x181+-0x1*0x302f;return _0x559461[_0x35967f(0x190)](_0x4b934c,_0x5b0283+(0xa*-0x140+0x234e+-0x16cd)),_0x5b0283===0x19cf*0x1+0xd34+-0x1*0x2703?_0x4b934c:_0x4b934c+':'+_0x5b0283;});}function nativeTranscriptItemFingerprint(_0x24b13f){const _0x260d02=_0x529e;return createHash(_0x260d02(0x1a2))[_0x260d02(0x152)](JSON[_0x260d02(0x1a7)](_0x24b13f??null))[_0x260d02(0x17b)](_0x260d02(0x197))[_0x260d02(0x13e)](-0x1*-0x99f+0xb11+-0x14b0,-0x450+0xa82+-0x61a);}function nativeTranscriptTurns(_0x56a1e3){const _0xf6077c=_0x529e,_0x4e35f7=[];let _0x5bdfdb=[];for(const [_0x2f94ed,_0x45b241]of _0x56a1e3[_0xf6077c(0x151)]()){_0x45b241[_0xf6077c(0x1a6)]===_0xf6077c(0x195)&&_0x45b241[_0xf6077c(0x175)]===_0xf6077c(0x1c9)&&_0x5bdfdb[_0xf6077c(0x16a)]>-0xacb+-0x4b7*0x1+0xf82&&(_0x4e35f7[_0xf6077c(0x142)](_0x5bdfdb),_0x5bdfdb=[]),_0x5bdfdb[_0xf6077c(0x142)]({'entry':_0x45b241,'index':_0x2f94ed});}if(_0x5bdfdb[_0xf6077c(0x16a)]>-0x29f*0x6+0x179b*0x1+-0x1*0x7e1)_0x4e35f7[_0xf6077c(0x142)](_0x5bdfdb);return _0x4e35f7;}function nativeTranscriptConversationItem(_0x54d90e,_0x5e632c,_0x570b9a,_0x3b8163,_0x28b173,_0x1d723a,_0x27b4f9){const _0x5d1ecb=_0x529e,_0x420a42=_0x5e632c[_0x5d1ecb(0x147)],_0x51e7bb=_0x5e632c[_0x5d1ecb(0x1a6)]===_0x5d1ecb(0x194),_0x24e3a4=_0x5e632c[_0x5d1ecb(0x1a6)]===_0x5d1ecb(0x193),_0x127761=_0x5e632c[_0x5d1ecb(0x1a6)]===_0x5d1ecb(0x1a4),_0x1cd6a5=_0x5e632c[_0x5d1ecb(0x1a6)]===_0x5d1ecb(0x1c4),_0x30ee34=_0x54d90e[_0x5d1ecb(0x14f)]===_0x5d1ecb(0x14a)&&_0x51e7bb?normalizeClaudeTool(_0x5e632c[_0x5d1ecb(0x168)],_0x5e632c[_0x5d1ecb(0x196)],_0x5e632c[_0x5d1ecb(0x191)],_0x5e632c[_0x5d1ecb(0x178)],_0x5e632c[_0x5d1ecb(0x16c)]||_0x5e632c[_0x5d1ecb(0x17e)]):undefined,_0x38e3d1=_0x54d90e[_0x5d1ecb(0x14f)]===_0x5d1ecb(0x1b1)&&_0x51e7bb?normalizeCodexTool({'name':_0x5e632c[_0x5d1ecb(0x168)],'namespace':_0x5d1ecb(0x1b1),'rawInput':_0x5e632c[_0x5d1ecb(0x196)],'inputSummary':_0x5e632c[_0x5d1ecb(0x1c2)],'outputSummary':_0x5e632c[_0x5d1ecb(0x191)],'truncated':_0x5e632c[_0x5d1ecb(0x16c)]||_0x5e632c[_0x5d1ecb(0x17e)],..._0x5e632c[_0x5d1ecb(0x19e)]===undefined?{}:{'attachments':_0x5e632c[_0x5d1ecb(0x19e)]}}):undefined,_0x18b8aa=_0x54d90e[_0x5d1ecb(0x14f)]===_0x5d1ecb(0x14a)&&_0x51e7bb&&_0x5e632c[_0x5d1ecb(0x168)]===_0x5d1ecb(0x188)&&isPlainRecord(_0x5e632c[_0x5d1ecb(0x196)])?claudeUserInputQuestions(_0x5e632c[_0x5d1ecb(0x196)]):[],_0x48fefa=_0x18b8aa[_0x5d1ecb(0x16a)]>0xe3*-0x19+-0x63d+-0x6*-0x4bc,_0xf1f5cc=_0x5e632c[_0x5d1ecb(0x1a6)]===_0x5d1ecb(0x195)&&_0x5e632c[_0x5d1ecb(0x175)]===_0x5d1ecb(0x1c9)?nativeUserClientMessageId(_0x54d90e[_0x5d1ecb(0x14f)],_0x5e632c,_0x420a42,_0x1d723a):null,_0x1b645d=_0x5e632c[_0x5d1ecb(0x1a6)]===_0x5d1ecb(0x195)?_0x5e632c[_0x5d1ecb(0x175)]===_0x5d1ecb(0x1c9)?nativeUserMessageText(_0x54d90e[_0x5d1ecb(0x14f)],_0x5e632c[_0x5d1ecb(0x16f)]):_0x5e632c[_0x5d1ecb(0x16f)]:'',_0x1765e8=_0xf1f5cc===null?undefined:runtimeUserMessagePayload(_0xf1f5cc,_0x1d723a),_0x7f400e=Array[_0x5d1ecb(0x146)](_0x1765e8?.[_0x5d1ecb(0x180)])?_0x1765e8[_0x5d1ecb(0x180)]:_0x5e632c[_0x5d1ecb(0x1a6)]===_0x5d1ecb(0x195)&&_0x5e632c[_0x5d1ecb(0x175)]===_0x5d1ecb(0x1c9)&&_0x5e632c[_0x5d1ecb(0x19e)]!==undefined?_0x27b4f9(_0x5e632c[_0x5d1ecb(0x19e)]):[],_0x3f22dd=_0x5e632c[_0x5d1ecb(0x1a6)]===_0x5d1ecb(0x195)&&_0x5e632c[_0x5d1ecb(0x175)]!==_0x5d1ecb(0x1c9)?claudePlanText(_0x1b645d):undefined,_0x50e5ca={'id':_0x28b173+_0x5d1ecb(0x18c)+_0x3b8163,'sessionId':_0x54d90e['id'],'turnId':_0x28b173,'runId':null,'parentItemId':null,'sourceSequence':_0x570b9a,'revision':0x0,'kind':_0x48fefa?_0x5d1ecb(0x15a):_0x127761?_0x5d1ecb(0x1a4):_0x1cd6a5?_0x5d1ecb(0x1c4):_0x51e7bb?_0x30ee34?.[_0x5d1ecb(0x1a6)]??_0x38e3d1?.[_0x5d1ecb(0x1a6)]??_0x5d1ecb(0x194):_0x24e3a4?_0x5d1ecb(0x193):_0x5e632c[_0x5d1ecb(0x1a6)]===_0x5d1ecb(0x195)&&_0x5e632c[_0x5d1ecb(0x175)]===_0x5d1ecb(0x1c9)?_0x5d1ecb(0x1a1):_0x3f22dd!==undefined?_0x5d1ecb(0x1a9):_0x5d1ecb(0x186),'status':_0x5d1ecb(0x157),'payload':_0x48fefa?{'requestId':_0x5d1ecb(0x1c1)+(_0x5e632c[_0x5d1ecb(0x1a6)]===_0x5d1ecb(0x194)?_0x5e632c[_0x5d1ecb(0x1b3)]:_0x5d1ecb(0x1a8)+_0x3b8163),'questions':_0x18b8aa}:_0x127761?{'sections':_0x5e632c[_0x5d1ecb(0x15f)]}:_0x1cd6a5?{'phase':_0x5e632c[_0x5d1ecb(0x148)],'summary':_0x5e632c[_0x5d1ecb(0x156)]}:_0x51e7bb?{..._0x30ee34?.[_0x5d1ecb(0x184)]??_0x38e3d1?.[_0x5d1ecb(0x184)]??{'namespace':_0x54d90e[_0x5d1ecb(0x14f)],'toolName':_0x5e632c[_0x5d1ecb(0x168)],'title':_0x5e632c[_0x5d1ecb(0x168)],'inputSummary':_0x5e632c[_0x5d1ecb(0x1c2)],'outputSummary':_0x5e632c[_0x5d1ecb(0x191)],'progressLabel':null,'errorCode':_0x5e632c[_0x5d1ecb(0x178)]?_0x5d1ecb(0x163):null,'truncated':_0x5e632c[_0x5d1ecb(0x16c)]||_0x5e632c[_0x5d1ecb(0x17e)]},..._0x5e632c[_0x5d1ecb(0x16b)]===undefined?{}:{'toolCategory':_0x5e632c[_0x5d1ecb(0x16b)]},..._0x5e632c[_0x5d1ecb(0x19e)]===undefined?{}:{'attachments':_0x27b4f9(_0x5e632c[_0x5d1ecb(0x19e)])}}:_0x24e3a4?{'sourceEventType':_0x5e632c[_0x5d1ecb(0x164)],'label':_0x5e632c[_0x5d1ecb(0x1c7)]}:_0x5e632c[_0x5d1ecb(0x1a6)]===_0x5d1ecb(0x195)&&_0x5e632c[_0x5d1ecb(0x175)]===_0x5d1ecb(0x1c9)?{'clientMessageId':_0xf1f5cc,'text':_0x1b645d,'contexts':[],'delivery':_0x5d1ecb(0x19c),..._0x7f400e[_0x5d1ecb(0x16a)]===0x155f*0x1+-0x133*-0x4+0x57*-0x4d?{}:{'attachments':_0x7f400e}}:_0x3f22dd!==undefined?{'explanation':compactRunnerText(_0x3f22dd,-0x9473+0x67e7+0x7aac),'steps':[]}:{'text':_0x1b645d,'format':_0x5d1ecb(0x141),'source':_0x5d1ecb(0x19a)},'startedAt':_0x420a42,'completedAt':_0x420a42};return _0x50e5ca;}export function nativeUserClientMessageId(_0x2959fe,_0x4961cb,_0x14acc2,_0x39411c){const _0x582467=_0x529e,_0x12a3e8=[];for(const _0x23ebf3 of _0x39411c){const _0x436696=_0x23ebf3[_0x582467(0x1b6)][_0x582467(0x18b)](_0x229b8a=>_0x229b8a[_0x582467(0x1a6)]===_0x582467(0x1a1));if(_0x436696===undefined||!isPlainRecord(_0x436696[_0x582467(0x184)]))continue;const _0x542ab5=_0x436696[_0x582467(0x184)],_0x13c47d=typeof _0x542ab5[_0x582467(0x165)]===_0x582467(0x1b9)?_0x542ab5[_0x582467(0x165)]:null;if(_0x13c47d===null||_0x542ab5[_0x582467(0x16f)]!==nativeUserMessageText(_0x2959fe,_0x4961cb[_0x582467(0x16f)]))continue;const _0xb0e243=_0x436696[_0x582467(0x1b0)]??_0x23ebf3[_0x582467(0x1b0)];_0x12a3e8[_0x582467(0x142)]({'clientMessageId':_0x13c47d,'createdAt':_0xb0e243??null});}if(_0x14acc2===null)return _0x12a3e8[_0x582467(0x16a)]===-0x1b07+0x476*0x8+-0x8a8?_0x12a3e8[0xdb3+-0x2*0xc62+0xb11][_0x582467(0x165)]:null;const _0xef993b=_0x12a3e8[_0x582467(0x15d)](_0x59352f=>_0x59352f[_0x582467(0x147)]!==null)[_0x582467(0x143)](_0x38eb26=>({..._0x38eb26,'distance':Math[_0x582467(0x13a)](_0x14acc2-_0x38eb26[_0x582467(0x147)])}))[_0x582467(0x15d)](_0x3bf1d3=>_0x3bf1d3[_0x582467(0x198)]<=-0x17c*-0xfd+0x148fd+-0x1d629)[_0x582467(0x14e)]((_0x24a0d7,_0x5c2783)=>_0x24a0d7[_0x582467(0x198)]-_0x5c2783[_0x582467(0x198)]);return _0xef993b[0x1ecb+0x1054+0x3*-0xfb5]?.[_0x582467(0x165)]??null;}function runtimeUserMessagePayload(_0x23d3b4,_0x5b1fa4){const _0x1f49f4=_0x529e;for(const _0x50a372 of _0x5b1fa4){const _0x1e41ab=_0x50a372[_0x1f49f4(0x1b6)][_0x1f49f4(0x18b)](_0x2a8d90=>_0x2a8d90[_0x1f49f4(0x1a6)]===_0x1f49f4(0x1a1));if(!isPlainRecord(_0x1e41ab?.[_0x1f49f4(0x184)])||_0x1e41ab[_0x1f49f4(0x184)][_0x1f49f4(0x165)]!==_0x23d3b4)continue;return _0x1e41ab[_0x1f49f4(0x184)];}return undefined;}function nativeUserMessageText(_0x2d3d40,_0x3c8150){const _0x3aa01b=_0x529e,_0x5ba817=stripMissionStartPrompt(_0x3c8150),_0x147b50=_0x2d3d40===_0x3aa01b(0x14a)?stripClaudePlanTag(_0x5ba817):_0x5ba817;if(_0x2d3d40!==_0x3aa01b(0x1b1))return _0x147b50;return parseCodexComposerImageMarkers(_0x147b50)[_0x3aa01b(0x16f)];}export function claudePlanText(_0x4590c6){const _0x103fab=_0x529e,_0x4dd769=_0x4590c6[_0x103fab(0x1ac)]();if(!_0x4dd769[_0x103fab(0x173)](_0x103fab(0x167))||!/<\/proposed_plan>\s*$/[_0x103fab(0x1a3)](_0x4dd769))return undefined;const _0x4eb973=_0x4dd769[_0x103fab(0x13e)](_0x103fab(0x167)[_0x103fab(0x16a)])[_0x103fab(0x1aa)](/<\/proposed_plan>\s*$/,'')[_0x103fab(0x1ac)]();return _0x4eb973[_0x103fab(0x16a)]>0x14d*-0x17+-0x30a*0x3+0x2709?_0x4eb973:undefined;}export function claudeUserInputQuestions(_0x18a78c){const _0x5709a0=_0x529e;if(!Array[_0x5709a0(0x146)](_0x18a78c[_0x5709a0(0x13c)])||_0x18a78c[_0x5709a0(0x13c)][_0x5709a0(0x16a)]===0x112d+-0x106b+-0x61*0x2||_0x18a78c[_0x5709a0(0x13c)][_0x5709a0(0x16a)]>0x6*0x52+0x15f6+-0x263*0xa)return[];const _0x2c9c85=_0x18a78c[_0x5709a0(0x13c)][_0x5709a0(0x143)]((_0x5d4106,_0x2740a5)=>{const _0x36cb34=_0x5709a0;if(!isPlainRecord(_0x5d4106)||typeof _0x5d4106[_0x36cb34(0x1bc)]!==_0x36cb34(0x1b9))return undefined;const _0x302f1c=Array[_0x36cb34(0x146)](_0x5d4106[_0x36cb34(0x19b)])?_0x5d4106[_0x36cb34(0x19b)][_0x36cb34(0x18a)](_0x41bdb7=>{const _0x2d7985=_0x36cb34;if(!isPlainRecord(_0x41bdb7)||typeof _0x41bdb7[_0x2d7985(0x1c7)]!==_0x2d7985(0x1b9))return[];const _0x394906=compactRunnerText(_0x41bdb7[_0x2d7985(0x1c7)],-0x979+0x112e+-0x5c1);return _0x394906[_0x2d7985(0x16a)]===-0x228f+-0x1843*0x1+0x3ad2?[]:[{'value':_0x394906,'label':_0x394906,'description':typeof _0x41bdb7[_0x2d7985(0x160)]===_0x2d7985(0x1b9)?compactRunnerText(_0x41bdb7[_0x2d7985(0x160)],-0x1*0x18d+-0x3*0xec+0x839):null}];}):[],_0x334787=_0x5d4106[_0x36cb34(0x1cc)]===!![];return{'id':_0x36cb34(0x13b)+_0x2740a5,'prompt':compactRunnerText(_0x5d4106[_0x36cb34(0x1bc)],-0x3*-0x5c7+-0x2d3+-0x2*-0x283),'input':_0x302f1c[_0x36cb34(0x16a)]===0x227*0x5+0x6f8+-0x11bb?_0x36cb34(0x14b):_0x334787?_0x36cb34(0x1b4):_0x36cb34(0x18f),'options':_0x302f1c,'allowOther':!![],'multiSelect':_0x334787};});return _0x2c9c85[_0x5709a0(0x162)](_0x5e7931=>_0x5e7931===undefined)?[]:_0x2c9c85;}
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { stripClaudePlanTag } from '../runner-command-engine.js';
|
|
4
|
+
import { stripMissionStartPrompt } from '../service/mission-runtime.js';
|
|
5
|
+
import { parseCodexComposerImageMarkers } from '../runner/codex/composer-image-markers.js';
|
|
6
|
+
import { normalizeCodexTool } from '../runner/codex/tool-normalizer.js';
|
|
7
|
+
import { normalizeClaudeTool } from '../runner/claude/tool-normalizer.js';
|
|
8
|
+
import { compactRunnerText, isPlainRecord, nativePageEnd } from './node-operation-parsers.js';
|
|
9
|
+
export function extractId(result, key) {
|
|
10
|
+
if (typeof result === 'object' &&
|
|
11
|
+
result !== null &&
|
|
12
|
+
key in result &&
|
|
13
|
+
typeof result[key] === 'object' &&
|
|
14
|
+
result[key] !== null &&
|
|
15
|
+
typeof result[key]['id'] === 'string') {
|
|
16
|
+
return result[key]['id'];
|
|
17
|
+
}
|
|
18
|
+
throw new Error(`CODEX_${key.toUpperCase()}_ID_MISSING`);
|
|
19
|
+
}
|
|
20
|
+
export async function settleWithin(promise, milliseconds) {
|
|
21
|
+
let timer;
|
|
22
|
+
try {
|
|
23
|
+
return await Promise.race([
|
|
24
|
+
promise,
|
|
25
|
+
new Promise((resolve) => {
|
|
26
|
+
timer = setTimeout(() => resolve(undefined), milliseconds);
|
|
27
|
+
timer.unref();
|
|
28
|
+
})
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
if (timer !== undefined)
|
|
33
|
+
clearTimeout(timer);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function extractCodexThreads(result) {
|
|
37
|
+
if (typeof result !== 'object' || result === null || !('data' in result))
|
|
38
|
+
return [];
|
|
39
|
+
const data = result.data;
|
|
40
|
+
if (!Array.isArray(data))
|
|
41
|
+
return [];
|
|
42
|
+
return data.flatMap((entry) => {
|
|
43
|
+
if (typeof entry !== 'object' || entry === null)
|
|
44
|
+
return [];
|
|
45
|
+
const value = entry;
|
|
46
|
+
if (typeof value.id !== 'string')
|
|
47
|
+
return [];
|
|
48
|
+
const source = typeof value.sourceKind === 'string'
|
|
49
|
+
? value.sourceKind
|
|
50
|
+
: typeof value.source === 'string'
|
|
51
|
+
? value.source
|
|
52
|
+
: typeof value.source === 'object' &&
|
|
53
|
+
value.source !== null &&
|
|
54
|
+
typeof value.source.kind === 'string'
|
|
55
|
+
? value.source.kind
|
|
56
|
+
: undefined;
|
|
57
|
+
const sourceRecord = isPlainRecord(value.source) ? value.source : undefined;
|
|
58
|
+
const derived = source === 'subagent' ||
|
|
59
|
+
sourceRecord?.kind === 'subagent' ||
|
|
60
|
+
isPlainRecord(sourceRecord?.subagent) ||
|
|
61
|
+
isPlainRecord(sourceRecord?.subAgent);
|
|
62
|
+
const title = typeof value.name === 'string' && value.name.trim().length > 0
|
|
63
|
+
? value.name.trim()
|
|
64
|
+
: typeof value.preview === 'string' && value.preview.trim().length > 0
|
|
65
|
+
? value.preview.trim()
|
|
66
|
+
: undefined;
|
|
67
|
+
return [{ id: value.id, source, derived, cwd: value.cwd, title }];
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
export function codexThreadCwd(value) {
|
|
71
|
+
if (typeof value !== 'string' || value.length === 0)
|
|
72
|
+
throw new Error('CODEX_THREAD_CWD_INVALID');
|
|
73
|
+
if (!value.startsWith('file:'))
|
|
74
|
+
return value;
|
|
75
|
+
try {
|
|
76
|
+
return fileURLToPath(value);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
throw new Error('CODEX_THREAD_CWD_INVALID');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export function isWithinWorkspace(cwd, workspacePath) {
|
|
83
|
+
const normalize = (value) => {
|
|
84
|
+
const compact = value.replace(/[\\/]+/g, '/').replace(/\/$/, '');
|
|
85
|
+
return process.platform === 'win32' ? compact.toLowerCase() : compact;
|
|
86
|
+
};
|
|
87
|
+
const normalizedCwd = normalize(cwd);
|
|
88
|
+
const normalizedWorkspace = normalize(workspacePath);
|
|
89
|
+
if (normalizedCwd === normalizedWorkspace)
|
|
90
|
+
return true;
|
|
91
|
+
return normalizedCwd.startsWith(`${normalizedWorkspace}/`);
|
|
92
|
+
}
|
|
93
|
+
export function claudeDiscoveredSession(value, fallbackCwd) {
|
|
94
|
+
if (typeof value !== 'object' || value === null)
|
|
95
|
+
return undefined;
|
|
96
|
+
const record = value;
|
|
97
|
+
if (record.isSidechain === true)
|
|
98
|
+
return undefined;
|
|
99
|
+
const externalSessionId = typeof record.sessionId === 'string'
|
|
100
|
+
? record.sessionId
|
|
101
|
+
: typeof record.id === 'string'
|
|
102
|
+
? record.id
|
|
103
|
+
: undefined;
|
|
104
|
+
if (externalSessionId === undefined || externalSessionId.length === 0)
|
|
105
|
+
return undefined;
|
|
106
|
+
const title = typeof record.summary === 'string'
|
|
107
|
+
? record.summary
|
|
108
|
+
: typeof record.title === 'string'
|
|
109
|
+
? record.title
|
|
110
|
+
: undefined;
|
|
111
|
+
const cwd = typeof record.cwd === 'string' && record.cwd.length > 0 ? record.cwd : fallbackCwd;
|
|
112
|
+
return { externalSessionId, cwd, ...(title === undefined ? {} : { title: title.slice(0, 80) }) };
|
|
113
|
+
}
|
|
114
|
+
export function latestNativeActivity(history) {
|
|
115
|
+
return history.lastActivityAt;
|
|
116
|
+
}
|
|
117
|
+
export function sameContextUsage(left, right) {
|
|
118
|
+
return (left.model === right.model &&
|
|
119
|
+
left.usedTokens === right.usedTokens &&
|
|
120
|
+
left.maxTokens === right.maxTokens);
|
|
121
|
+
}
|
|
122
|
+
export function isNativeHistory(value) {
|
|
123
|
+
return (typeof value === 'object' &&
|
|
124
|
+
value !== null &&
|
|
125
|
+
Array.isArray(value.items));
|
|
126
|
+
}
|
|
127
|
+
export function deduplicateDirectSessions(sessions) {
|
|
128
|
+
const values = new Map();
|
|
129
|
+
for (const session of sessions) {
|
|
130
|
+
const existing = values.get(session.id);
|
|
131
|
+
if (existing === undefined || existing.lastActivityAt < session.lastActivityAt)
|
|
132
|
+
values.set(session.id, session);
|
|
133
|
+
}
|
|
134
|
+
return [...values.values()].sort((left, right) => right.lastActivityAt - left.lastActivityAt);
|
|
135
|
+
}
|
|
136
|
+
export function nativeConversationPage(session, history, input, runtimeTurns = [], registerImages = () => []) {
|
|
137
|
+
const limit = Math.min(Math.max(input.limit ?? 30, 1), 500);
|
|
138
|
+
const effectiveCursor = history.cursorReset === true ? undefined : input.cursor;
|
|
139
|
+
const nativeTurns = nativeTranscriptTurns(history.items);
|
|
140
|
+
const nativeTurnIds = nativeTranscriptTurnIds(session.id, nativeTurns);
|
|
141
|
+
const end = nativePageEnd(effectiveCursor, session.id, nativeTurns.length);
|
|
142
|
+
const start = Math.max(0, end - limit);
|
|
143
|
+
const nativePageTurns = nativeTurns
|
|
144
|
+
.slice(start, end)
|
|
145
|
+
.map((entries, relativeIndex) => {
|
|
146
|
+
const nativeUser = entries.find(({ entry }) => entry.kind === 'message' && entry.role === 'USER')?.entry;
|
|
147
|
+
const matchedClientMessageId = nativeUser?.kind === 'message'
|
|
148
|
+
? nativeUserClientMessageId(session.runner, nativeUser, nativeUser.createdAt, runtimeTurns)
|
|
149
|
+
: null;
|
|
150
|
+
const runtimeTurn = typeof matchedClientMessageId === 'string'
|
|
151
|
+
? runtimeTurns.find((turn) => runtimeTurnClientMessageId(turn) === matchedClientMessageId)
|
|
152
|
+
: undefined;
|
|
153
|
+
const turnId = runtimeTurn?.id ?? nativeTurnIds[start + relativeIndex];
|
|
154
|
+
const itemIdentities = nativeTranscriptItemIdentities(entries);
|
|
155
|
+
const nativeItems = entries.map(({ entry, index }, entryIndex) => ({
|
|
156
|
+
...nativeTranscriptConversationItem(session, entry, index, itemIdentities[entryIndex], turnId, runtimeTurns, registerImages),
|
|
157
|
+
runId: runtimeTurn?.runId ?? null
|
|
158
|
+
}));
|
|
159
|
+
const runtimeErrors = (runtimeTurn?.items ?? [])
|
|
160
|
+
.filter((item) => item.kind === 'error')
|
|
161
|
+
.map((item) => ({ ...item, turnId, runId: runtimeTurn?.runId ?? null }));
|
|
162
|
+
const items = runtimeAssistantProjectionMoreComplete(runtimeTurn, nativeItems)
|
|
163
|
+
? runtimeTurn.items.map((item) => ({
|
|
164
|
+
...item,
|
|
165
|
+
turnId,
|
|
166
|
+
runId: runtimeTurn.runId
|
|
167
|
+
}))
|
|
168
|
+
: [
|
|
169
|
+
...nativeItems,
|
|
170
|
+
...runtimeErrors.filter((error) => !nativeItems.some((item) => item.id === error.id))
|
|
171
|
+
];
|
|
172
|
+
const startedAt = items[0]?.startedAt ?? null;
|
|
173
|
+
const completedAt = items.at(-1)?.completedAt ?? startedAt;
|
|
174
|
+
const after = lastNativeItemId(entries);
|
|
175
|
+
return {
|
|
176
|
+
id: turnId,
|
|
177
|
+
sessionId: session.id,
|
|
178
|
+
runId: runtimeTurn?.runId ?? null,
|
|
179
|
+
userItemId: items.find((item) => item.kind === 'user_message')?.id ?? null,
|
|
180
|
+
status: runtimeErrors.length > 0 ? 'FAILED' : 'SUCCEEDED',
|
|
181
|
+
model: null,
|
|
182
|
+
effort: null,
|
|
183
|
+
access: null,
|
|
184
|
+
...(after === undefined || session.runner !== 'claude-code'
|
|
185
|
+
? {}
|
|
186
|
+
: {
|
|
187
|
+
rewind: {
|
|
188
|
+
before: lastNativeItemId(nativeTurns[start + relativeIndex - 1] ?? []) ?? null,
|
|
189
|
+
after
|
|
190
|
+
}
|
|
191
|
+
}),
|
|
192
|
+
items,
|
|
193
|
+
startedAt,
|
|
194
|
+
completedAt
|
|
195
|
+
};
|
|
196
|
+
});
|
|
197
|
+
const turns = nativePageTurns;
|
|
198
|
+
const nextEnd = start;
|
|
199
|
+
const cursorBase = {
|
|
200
|
+
sessionId: session.id,
|
|
201
|
+
...(history.snapshotEnd === undefined ? {} : { snapshotEnd: history.snapshotEnd }),
|
|
202
|
+
...(history.windowEnd === undefined ? {} : { nextEnd: history.windowEnd }),
|
|
203
|
+
...(history.fileAnchor === undefined ? {} : { fileAnchor: history.fileAnchor }),
|
|
204
|
+
...(history.anchorBytes === undefined ? {} : { anchorBytes: history.anchorBytes }),
|
|
205
|
+
readLimit: history.windowReadLimit ?? limit
|
|
206
|
+
};
|
|
207
|
+
const precedingWindow = history.truncated === true &&
|
|
208
|
+
history.windowStart !== undefined &&
|
|
209
|
+
history.snapshotEnd !== undefined &&
|
|
210
|
+
history.fileAnchor !== undefined &&
|
|
211
|
+
history.anchorBytes !== undefined
|
|
212
|
+
? Buffer.from(JSON.stringify({
|
|
213
|
+
sessionId: session.id,
|
|
214
|
+
snapshotEnd: history.snapshotEnd,
|
|
215
|
+
nextEnd: history.windowStart,
|
|
216
|
+
fileAnchor: history.fileAnchor,
|
|
217
|
+
anchorBytes: history.anchorBytes,
|
|
218
|
+
readLimit: history.windowReadLimit ?? limit
|
|
219
|
+
})).toString('base64url')
|
|
220
|
+
: null;
|
|
221
|
+
return {
|
|
222
|
+
turns,
|
|
223
|
+
nextCursor: nextEnd > 0
|
|
224
|
+
? Buffer.from(JSON.stringify({ ...cursorBase, end: nextEnd })).toString('base64url')
|
|
225
|
+
: precedingWindow
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
export function runtimeAssistantProjectionMoreComplete(runtimeTurn, projectedItems) {
|
|
229
|
+
if (runtimeTurn === undefined)
|
|
230
|
+
return false;
|
|
231
|
+
const assistantStats = (items) => items.reduce((stats, item) => {
|
|
232
|
+
if (item.kind !== 'assistant_message' || !isPlainRecord(item.payload))
|
|
233
|
+
return stats;
|
|
234
|
+
return {
|
|
235
|
+
count: stats.count + 1,
|
|
236
|
+
characters: stats.characters +
|
|
237
|
+
(typeof item.payload.text === 'string' ? item.payload.text.length : 0)
|
|
238
|
+
};
|
|
239
|
+
}, { count: 0, characters: 0 });
|
|
240
|
+
const runtime = assistantStats(runtimeTurn.items);
|
|
241
|
+
const projected = assistantStats(projectedItems);
|
|
242
|
+
return runtime.count > projected.count || runtime.characters > projected.characters;
|
|
243
|
+
}
|
|
244
|
+
function runtimeTurnClientMessageId(turn) {
|
|
245
|
+
const user = turn.items.find((item) => item.kind === 'user_message');
|
|
246
|
+
return isPlainRecord(user?.payload) && typeof user.payload.clientMessageId === 'string'
|
|
247
|
+
? user.payload.clientMessageId
|
|
248
|
+
: undefined;
|
|
249
|
+
}
|
|
250
|
+
function lastNativeItemId(entries) {
|
|
251
|
+
return entries.findLast(({ entry }) => entry.nativeId !== undefined)?.entry.nativeId;
|
|
252
|
+
}
|
|
253
|
+
function nativeTranscriptTurnIds(sessionId, turns) {
|
|
254
|
+
const occurrences = new Map();
|
|
255
|
+
return turns.map((entries) => {
|
|
256
|
+
const user = entries.find(({ entry }) => entry.kind === 'message' && entry.role === 'USER')?.entry;
|
|
257
|
+
const first = user ?? entries[0]?.entry;
|
|
258
|
+
const base = first?.nativeId ?? nativeTranscriptItemFingerprint(first);
|
|
259
|
+
const occurrence = occurrences.get(base) ?? 0;
|
|
260
|
+
occurrences.set(base, occurrence + 1);
|
|
261
|
+
return `${sessionId}:native:${base}${occurrence === 0 ? '' : `:${occurrence}`}`;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
function nativeTranscriptItemIdentities(entries) {
|
|
265
|
+
const nativeIdCounts = new Map();
|
|
266
|
+
for (const { entry } of entries)
|
|
267
|
+
if (entry.nativeId !== undefined)
|
|
268
|
+
nativeIdCounts.set(entry.nativeId, (nativeIdCounts.get(entry.nativeId) ?? 0) + 1);
|
|
269
|
+
const occurrences = new Map();
|
|
270
|
+
return entries.map(({ entry }) => {
|
|
271
|
+
const base = entry.nativeId !== undefined && nativeIdCounts.get(entry.nativeId) === 1
|
|
272
|
+
? entry.nativeId
|
|
273
|
+
: `${entry.nativeId === undefined ? '' : `${entry.nativeId}:`}${nativeTranscriptItemFingerprint(entry)}`;
|
|
274
|
+
const occurrence = occurrences.get(base) ?? 0;
|
|
275
|
+
occurrences.set(base, occurrence + 1);
|
|
276
|
+
return occurrence === 0 ? base : `${base}:${occurrence}`;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
function nativeTranscriptItemFingerprint(entry) {
|
|
280
|
+
return createHash('sha256')
|
|
281
|
+
.update(JSON.stringify(entry ?? null))
|
|
282
|
+
.digest('base64url')
|
|
283
|
+
.slice(0, 24);
|
|
284
|
+
}
|
|
285
|
+
function nativeTranscriptTurns(items) {
|
|
286
|
+
const turns = [];
|
|
287
|
+
let current = [];
|
|
288
|
+
for (const [index, entry] of items.entries()) {
|
|
289
|
+
if (entry.kind === 'message' && entry.role === 'USER' && current.length > 0) {
|
|
290
|
+
turns.push(current);
|
|
291
|
+
current = [];
|
|
292
|
+
}
|
|
293
|
+
current.push({ entry, index });
|
|
294
|
+
}
|
|
295
|
+
if (current.length > 0)
|
|
296
|
+
turns.push(current);
|
|
297
|
+
return turns;
|
|
298
|
+
}
|
|
299
|
+
function nativeTranscriptConversationItem(session, entry, index, itemIdentity, turnId, runtimeTurns, registerImages) {
|
|
300
|
+
const time = entry.createdAt;
|
|
301
|
+
const isToolCall = entry.kind === 'tool_call';
|
|
302
|
+
const isUnknown = entry.kind === 'unknown';
|
|
303
|
+
const isReasoning = entry.kind === 'reasoning_summary';
|
|
304
|
+
const isContextCompaction = entry.kind === 'context_compaction';
|
|
305
|
+
const normalizedClaudeTool = session.runner === 'claude-code' && isToolCall
|
|
306
|
+
? normalizeClaudeTool(entry.toolName, entry.input, entry.outputSummary, entry.failed, entry.inputTruncated || entry.outputTruncated)
|
|
307
|
+
: undefined;
|
|
308
|
+
const normalizedCodexTool = session.runner === 'codex' && isToolCall
|
|
309
|
+
? normalizeCodexTool({
|
|
310
|
+
name: entry.toolName,
|
|
311
|
+
namespace: 'codex',
|
|
312
|
+
rawInput: entry.input,
|
|
313
|
+
inputSummary: entry.inputSummary,
|
|
314
|
+
outputSummary: entry.outputSummary,
|
|
315
|
+
truncated: entry.inputTruncated || entry.outputTruncated,
|
|
316
|
+
...(entry.imageAttachments === undefined ? {} : { attachments: entry.imageAttachments })
|
|
317
|
+
})
|
|
318
|
+
: undefined;
|
|
319
|
+
const userInputQuestions = session.runner === 'claude-code' &&
|
|
320
|
+
isToolCall &&
|
|
321
|
+
entry.toolName === 'AskUserQuestion' &&
|
|
322
|
+
isPlainRecord(entry.input)
|
|
323
|
+
? claudeUserInputQuestions(entry.input)
|
|
324
|
+
: [];
|
|
325
|
+
const isUserInputRequest = userInputQuestions.length > 0;
|
|
326
|
+
const clientMessageId = entry.kind === 'message' && entry.role === 'USER'
|
|
327
|
+
? nativeUserClientMessageId(session.runner, entry, time, runtimeTurns)
|
|
328
|
+
: null;
|
|
329
|
+
// Claude tagged Plan Mode strips the injected planning instruction label from user content
|
|
330
|
+
// and normalizes a complete <proposed_plan> Agent response into a plan card.
|
|
331
|
+
const entryText = entry.kind === 'message'
|
|
332
|
+
? entry.role === 'USER'
|
|
333
|
+
? nativeUserMessageText(session.runner, entry.text)
|
|
334
|
+
: entry.text
|
|
335
|
+
: '';
|
|
336
|
+
const runtimeUserPayload = clientMessageId === null ? undefined : runtimeUserMessagePayload(clientMessageId, runtimeTurns);
|
|
337
|
+
const userAttachments = Array.isArray(runtimeUserPayload?.attachments)
|
|
338
|
+
? runtimeUserPayload.attachments
|
|
339
|
+
: entry.kind === 'message' && entry.role === 'USER' && entry.imageAttachments !== undefined
|
|
340
|
+
? registerImages(entry.imageAttachments)
|
|
341
|
+
: [];
|
|
342
|
+
const planText = entry.kind === 'message' && entry.role !== 'USER' ? claudePlanText(entryText) : undefined;
|
|
343
|
+
const item = {
|
|
344
|
+
id: `${turnId}:item:${itemIdentity}`,
|
|
345
|
+
sessionId: session.id,
|
|
346
|
+
turnId,
|
|
347
|
+
runId: null,
|
|
348
|
+
parentItemId: null,
|
|
349
|
+
sourceSequence: index,
|
|
350
|
+
revision: 0,
|
|
351
|
+
kind: isUserInputRequest
|
|
352
|
+
? 'user_input_request'
|
|
353
|
+
: isReasoning
|
|
354
|
+
? 'reasoning_summary'
|
|
355
|
+
: isContextCompaction
|
|
356
|
+
? 'context_compaction'
|
|
357
|
+
: isToolCall
|
|
358
|
+
? (normalizedClaudeTool?.kind ?? normalizedCodexTool?.kind ?? 'tool_call')
|
|
359
|
+
: isUnknown
|
|
360
|
+
? 'unknown'
|
|
361
|
+
: entry.kind === 'message' && entry.role === 'USER'
|
|
362
|
+
? 'user_message'
|
|
363
|
+
: planText !== undefined
|
|
364
|
+
? 'plan'
|
|
365
|
+
: 'assistant_message',
|
|
366
|
+
status: 'COMPLETED',
|
|
367
|
+
payload: isUserInputRequest
|
|
368
|
+
? {
|
|
369
|
+
requestId: `native:${entry.kind === 'tool_call' ? entry.toolUseId : `item-${itemIdentity}`}`,
|
|
370
|
+
questions: userInputQuestions
|
|
371
|
+
}
|
|
372
|
+
: isReasoning
|
|
373
|
+
? { sections: entry.sections }
|
|
374
|
+
: isContextCompaction
|
|
375
|
+
? { phase: entry.phase, summary: entry.summary }
|
|
376
|
+
: isToolCall
|
|
377
|
+
? {
|
|
378
|
+
...(normalizedClaudeTool?.payload ??
|
|
379
|
+
normalizedCodexTool?.payload ?? {
|
|
380
|
+
namespace: session.runner,
|
|
381
|
+
toolName: entry.toolName,
|
|
382
|
+
title: entry.toolName,
|
|
383
|
+
inputSummary: entry.inputSummary,
|
|
384
|
+
outputSummary: entry.outputSummary,
|
|
385
|
+
progressLabel: null,
|
|
386
|
+
errorCode: entry.failed ? 'TOOL_EXECUTION_FAILED' : null,
|
|
387
|
+
truncated: entry.inputTruncated || entry.outputTruncated
|
|
388
|
+
}),
|
|
389
|
+
...(entry.toolCategory === undefined ? {} : { toolCategory: entry.toolCategory }),
|
|
390
|
+
...(entry.imageAttachments === undefined
|
|
391
|
+
? {}
|
|
392
|
+
: { attachments: registerImages(entry.imageAttachments) })
|
|
393
|
+
}
|
|
394
|
+
: isUnknown
|
|
395
|
+
? { sourceEventType: entry.sourceEventType, label: entry.label }
|
|
396
|
+
: entry.kind === 'message' && entry.role === 'USER'
|
|
397
|
+
? {
|
|
398
|
+
clientMessageId,
|
|
399
|
+
text: entryText,
|
|
400
|
+
contexts: [],
|
|
401
|
+
delivery: 'ACCEPTED',
|
|
402
|
+
...(userAttachments.length === 0 ? {} : { attachments: userAttachments })
|
|
403
|
+
}
|
|
404
|
+
: planText !== undefined
|
|
405
|
+
? { explanation: compactRunnerText(planText, 20_000), steps: [] }
|
|
406
|
+
: { text: entryText, format: 'markdown', source: 'native-file' },
|
|
407
|
+
startedAt: time,
|
|
408
|
+
completedAt: time
|
|
409
|
+
};
|
|
410
|
+
return item;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Claude JSONL does not retain browser request IDs. While the Node process is alive, match current
|
|
414
|
+
* runtime user messages by content and creation time so native history replaces the optimistic Turn.
|
|
415
|
+
*/
|
|
416
|
+
export function nativeUserClientMessageId(runner, entry, createdAt, runtimeTurns) {
|
|
417
|
+
const candidates = [];
|
|
418
|
+
for (const turn of runtimeTurns) {
|
|
419
|
+
const user = turn.items.find((item) => item.kind === 'user_message');
|
|
420
|
+
if (user === undefined || !isPlainRecord(user.payload))
|
|
421
|
+
continue;
|
|
422
|
+
const payload = user.payload;
|
|
423
|
+
const clientMessageId = typeof payload.clientMessageId === 'string' ? payload.clientMessageId : null;
|
|
424
|
+
// Tagged Plan Mode instruction labels exist only in native transcripts; runtime bubbles retain the original content.
|
|
425
|
+
if (clientMessageId === null || payload.text !== nativeUserMessageText(runner, entry.text))
|
|
426
|
+
continue;
|
|
427
|
+
const runtimeCreatedAt = user.startedAt ?? turn.startedAt;
|
|
428
|
+
candidates.push({ clientMessageId, createdAt: runtimeCreatedAt ?? null });
|
|
429
|
+
}
|
|
430
|
+
if (createdAt === null)
|
|
431
|
+
return candidates.length === 1 ? candidates[0].clientMessageId : null;
|
|
432
|
+
const timed = candidates
|
|
433
|
+
.filter((candidate) => candidate.createdAt !== null)
|
|
434
|
+
.map((candidate) => ({
|
|
435
|
+
...candidate,
|
|
436
|
+
distance: Math.abs(createdAt - candidate.createdAt)
|
|
437
|
+
}))
|
|
438
|
+
.filter((candidate) => candidate.distance <= 60_000)
|
|
439
|
+
.sort((left, right) => left.distance - right.distance);
|
|
440
|
+
return timed[0]?.clientMessageId ?? null;
|
|
441
|
+
}
|
|
442
|
+
function runtimeUserMessagePayload(clientMessageId, runtimeTurns) {
|
|
443
|
+
for (const turn of runtimeTurns) {
|
|
444
|
+
const user = turn.items.find((item) => item.kind === 'user_message');
|
|
445
|
+
if (!isPlainRecord(user?.payload) || user.payload.clientMessageId !== clientMessageId)
|
|
446
|
+
continue;
|
|
447
|
+
return user.payload;
|
|
448
|
+
}
|
|
449
|
+
return undefined;
|
|
450
|
+
}
|
|
451
|
+
function nativeUserMessageText(runner, text) {
|
|
452
|
+
const missionFiltered = stripMissionStartPrompt(text);
|
|
453
|
+
const normalized = runner === 'claude-code' ? stripClaudePlanTag(missionFiltered) : missionFiltered;
|
|
454
|
+
if (runner !== 'codex')
|
|
455
|
+
return normalized;
|
|
456
|
+
return parseCodexComposerImageMarkers(normalized).text;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Normalize the documented App Server `thread/read(includeTurns: true)`
|
|
460
|
+
* result. Only items with a user-visible Workbench representation are kept;
|
|
461
|
+
* raw protocol envelopes are deliberately never exposed to Web.
|
|
462
|
+
*/
|
|
463
|
+
export function claudePlanText(text) {
|
|
464
|
+
const trimmed = text.trim();
|
|
465
|
+
if (!trimmed.startsWith('<proposed_plan>') || !/<\/proposed_plan>\s*$/.test(trimmed))
|
|
466
|
+
return undefined;
|
|
467
|
+
const plan = trimmed
|
|
468
|
+
.slice('<proposed_plan>'.length)
|
|
469
|
+
.replace(/<\/proposed_plan>\s*$/, '')
|
|
470
|
+
.trim();
|
|
471
|
+
return plan.length > 0 ? plan : undefined;
|
|
472
|
+
}
|
|
473
|
+
export function claudeUserInputQuestions(value) {
|
|
474
|
+
if (!Array.isArray(value.questions) || value.questions.length === 0 || value.questions.length > 4)
|
|
475
|
+
return [];
|
|
476
|
+
const questions = value.questions.map((raw, index) => {
|
|
477
|
+
if (!isPlainRecord(raw) || typeof raw.question !== 'string')
|
|
478
|
+
return undefined;
|
|
479
|
+
const options = Array.isArray(raw.options)
|
|
480
|
+
? raw.options.flatMap((option) => {
|
|
481
|
+
if (!isPlainRecord(option) || typeof option.label !== 'string')
|
|
482
|
+
return [];
|
|
483
|
+
const label = compactRunnerText(option.label, 500);
|
|
484
|
+
return label.length === 0
|
|
485
|
+
? []
|
|
486
|
+
: [
|
|
487
|
+
{
|
|
488
|
+
value: label,
|
|
489
|
+
label,
|
|
490
|
+
description: typeof option.description === 'string'
|
|
491
|
+
? compactRunnerText(option.description, 1_000)
|
|
492
|
+
: null
|
|
493
|
+
}
|
|
494
|
+
];
|
|
495
|
+
})
|
|
496
|
+
: [];
|
|
497
|
+
const multiSelect = raw.multiSelect === true;
|
|
498
|
+
return {
|
|
499
|
+
id: `claude-question-${index}`,
|
|
500
|
+
prompt: compactRunnerText(raw.question, 5_000),
|
|
501
|
+
input: options.length === 0 ? 'SHORT_TEXT' : multiSelect ? 'MULTI_SELECT' : 'SINGLE_SELECT',
|
|
502
|
+
options,
|
|
503
|
+
allowOther: true,
|
|
504
|
+
multiSelect
|
|
505
|
+
};
|
|
506
|
+
});
|
|
507
|
+
return questions.some((question) => question === undefined)
|
|
508
|
+
? []
|
|
509
|
+
: questions;
|
|
510
|
+
}
|
package/dist/util/safe-error.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { safePublicError as sharedSafePublicError } from '@myagentroam/protocol';
|
|
2
|
+
export function safeErrorCode(error, fallback) {
|
|
3
|
+
return safePublicError(error, fallback).code;
|
|
4
|
+
}
|
|
5
|
+
/** Builds the bounded error shape that may cross the Node control boundary. */
|
|
6
|
+
export function safePublicError(error, fallback) {
|
|
7
|
+
return sharedSafePublicError(error, fallback);
|
|
8
|
+
}
|
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const ENVIRONMENT_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
2
|
+
const MAX_SECRET_COUNT = 128;
|
|
3
|
+
const MAX_SECRET_VALUE_BYTES = 16 * 1024;
|
|
4
|
+
const MAX_SECRET_TOTAL_BYTES = 64 * 1024;
|
|
5
|
+
export function parseSecretEnvironment(value) {
|
|
6
|
+
if (value === undefined)
|
|
7
|
+
return {};
|
|
8
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
9
|
+
throw new Error('SECRET_ENVIRONMENT_INVALID');
|
|
10
|
+
const entries = Object.entries(value);
|
|
11
|
+
if (entries.length > MAX_SECRET_COUNT)
|
|
12
|
+
throw new Error('SECRET_ENVIRONMENT_LIMIT_EXCEEDED');
|
|
13
|
+
const environment = {};
|
|
14
|
+
let bytes = 0;
|
|
15
|
+
for (const [name, secret] of entries) {
|
|
16
|
+
if (!ENVIRONMENT_NAME.test(name) || typeof secret !== 'string' || secret.includes('\0'))
|
|
17
|
+
throw new Error('SECRET_ENVIRONMENT_INVALID');
|
|
18
|
+
const valueBytes = Buffer.byteLength(secret);
|
|
19
|
+
bytes += Buffer.byteLength(name) + valueBytes;
|
|
20
|
+
if (valueBytes > MAX_SECRET_VALUE_BYTES || bytes > MAX_SECRET_TOTAL_BYTES)
|
|
21
|
+
throw new Error('SECRET_ENVIRONMENT_LIMIT_EXCEEDED');
|
|
22
|
+
environment[name] = secret;
|
|
23
|
+
}
|
|
24
|
+
return environment;
|
|
25
|
+
}
|