@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,913 @@
|
|
|
1
|
-
|
|
2
|
-
(function(_0x4b567e,_0xbf4e67){const _0x2cdb51=_0x447c,_0x1aee35=_0x4b567e();while(!![]){try{const _0x57eafb=parseInt(_0x2cdb51(0x19d))/(-0x60c+-0x97f+0x1*0xf8c)*(-parseInt(_0x2cdb51(0x150))/(0x163e+-0x587*-0x5+-0x2ef*0x11))+-parseInt(_0x2cdb51(0x186))/(-0x1010+-0x9e9*0x1+0x19fc)*(-parseInt(_0x2cdb51(0xe8))/(0x1*-0x191b+0xd*-0xa6+0x7*0x4cb))+parseInt(_0x2cdb51(0x167))/(0x2*-0x124a+-0xb1b+0x2fb4)+-parseInt(_0x2cdb51(0x11a))/(-0x1a3d+-0x1e0e+0x455*0xd)+parseInt(_0x2cdb51(0xef))/(-0xd*0x1b1+-0x118d+0x2791)+parseInt(_0x2cdb51(0x15f))/(0x1641+-0x6*0x5d5+-0x1*-0xcc5)*(-parseInt(_0x2cdb51(0x119))/(-0x1ca*0x14+0x7bf*0x1+-0xe09*-0x2))+-parseInt(_0x2cdb51(0xed))/(0x5*0x33b+0xa29+-0x1a46)*(-parseInt(_0x2cdb51(0x188))/(-0x14e7+-0x935+0x1e27));if(_0x57eafb===_0xbf4e67)break;else _0x1aee35['push'](_0x1aee35['shift']());}catch(_0x509164){_0x1aee35['push'](_0x1aee35['shift']());}}}(_0x3bdc,-0x5a8df*-0x4+-0x64b6c+0x40*-0x686));import{parseCodexComposerImageMarkers}from'./composer-image-markers.js';import{normalizeCodexTool}from'./tool-normalizer.js';import{stripMissionStartPrompt}from'../../service/mission-runtime.js';const MAX_COMPOSER_ATTACHMENT_BYTES=(-0x24b*-0xd+0xbb4+-0x5e*0x71)*(0x2521+0x7*-0x397+-0x800)*(0xea+0x1*-0x10a5+0x13bb),MAX_COMPOSER_ATTACHMENTS_BYTES=(-0x66*-0x50+-0x1d*-0x13+-0x21fd)*(0xa6a+0x63c+0xca6*-0x1)*(0x1*0x6d1+-0x2193+-0x1ec2*-0x1),MAX_ASSISTANT_MESSAGE_CHARACTERS=(0xe87+-0x17*0x89+-0x1f8)*(-0x1*0xadd+0x1*0x817+0x2*0x363);export*from'../../util/runner-native-session-parsers.js';export function codexOfficialConversationPage(_0x5af853,_0x5f26da,_0x26995f,_0x37284a){const _0x459e3b=_0x447c;if(!isPlainRecord(_0x5f26da)||!isPlainRecord(_0x5f26da[_0x459e3b(0xf2)]))return undefined;const _0x456dbe=_0x5f26da[_0x459e3b(0xf2)];if(_0x456dbe['id']!==_0x5af853[_0x459e3b(0x134)]||!Array[_0x459e3b(0xf6)](_0x456dbe[_0x459e3b(0x10e)]))return undefined;const _0xc19f33=_0x456dbe[_0x459e3b(0x10e)][_0x459e3b(0x179)]((_0x3604a9,_0x59bbd4)=>{const _0x2f2a0d=_0x459e3b,_0x33016c=typeof _0x3604a9===_0x2f2a0d(0x163)&&_0x3604a9!==null&&typeof _0x3604a9['id']===_0x2f2a0d(0x12c)?_0x3604a9['id']:undefined,_0x56e792=codexOfficialTurn(_0x5af853,_0x3604a9,_0x59bbd4,_0x33016c===undefined?undefined:_0x37284a(_0x33016c));return _0x56e792===undefined||_0x33016c===undefined?[]:[{'nativeTurnId':_0x33016c,'turn':_0x56e792}];}),_0xfdc3d9=_0xc19f33[_0x459e3b(0x172)](({nativeTurnId:_0x317fd2,turn:_0x5b9e39},_0x56354d)=>({..._0x5b9e39,'rewind':{'before':_0xc19f33[_0x56354d-(0x9a*0x36+-0x1c0a+-0x471)]?.[_0x459e3b(0x112)]??null,'after':_0x317fd2}}));if(_0xfdc3d9[_0x459e3b(0x164)]===-0x1f36+-0x1*0x366+0x229c)return undefined;const _0x25fda0=Math[_0x459e3b(0xea)](Math[_0x459e3b(0x106)](_0x26995f[_0x459e3b(0xff)]??-0x104e*0x1+0x1d*-0xe2+0x2a06,0x8*0x1c1+0x7*0x36e+-0x2ed*0xd),-0x638*0x1+-0x16e1+0x1f0d),_0x38a8a3=nativePageEnd(_0x26995f[_0x459e3b(0x17e)],_0x5af853['id'],_0xfdc3d9[_0x459e3b(0x164)]),_0x5621c0=Math[_0x459e3b(0x106)](-0x18e+0xf8*0x10+-0xdf2,_0x38a8a3-_0x25fda0);return{'turns':_0xfdc3d9[_0x459e3b(0x142)](_0x5621c0,_0x38a8a3),'nextCursor':_0x5621c0>0x22ca+-0xc66+0x599*-0x4?Buffer[_0x459e3b(0x141)](JSON[_0x459e3b(0x19a)]({'sessionId':_0x5af853['id'],'end':_0x5621c0}))[_0x459e3b(0x11b)](_0x459e3b(0x169)):null};}function _0x447c(_0x281910,_0x13c3bc){_0x281910=_0x281910-(0x4*-0x1eb+-0xa70+0x656*0x3);const _0x37a93d=_0x3bdc();let _0x4d13ab=_0x37a93d[_0x281910];if(_0x447c['SBbAgh']===undefined){var _0xa8bd1e=function(_0x429aff){const _0x15abe1='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4419ea='',_0x511f84='';for(let _0x23d205=-0x237b+0x1*0x74f+-0x70b*-0x4,_0x5a25a1,_0x208e69,_0x4f3b70=-0x343+-0x76*-0x2b+-0x108f;_0x208e69=_0x429aff['charAt'](_0x4f3b70++);~_0x208e69&&(_0x5a25a1=_0x23d205%(0x201d+-0x21*-0x65+-0x2d1e)?_0x5a25a1*(0x19f+0x1*0xb87+-0x7f*0x1a)+_0x208e69:_0x208e69,_0x23d205++%(0x10d8+0x2*-0xc37+0x79a))?_0x4419ea+=String['fromCharCode'](0x1*-0x701+0x1f87+0x1*-0x1787&_0x5a25a1>>(-(-0x824+-0x17*-0x161+-0x1791)*_0x23d205&0x169f+-0xdd8+0x1*-0x8c1)):0x495*-0x1+0x5a5*0x5+-0x17a4){_0x208e69=_0x15abe1['indexOf'](_0x208e69);}for(let _0x34f540=0x15c3+0x16e2+-0x2ca5,_0x3aecc2=_0x4419ea['length'];_0x34f540<_0x3aecc2;_0x34f540++){_0x511f84+='%'+('00'+_0x4419ea['charCodeAt'](_0x34f540)['toString'](-0x1*0x366+-0x26c5+0x2a3b))['slice'](-(-0x199a+0x3*0x32b+0x101b));}return decodeURIComponent(_0x511f84);};_0x447c['OyzdFo']=_0xa8bd1e,_0x447c['HeShcF']={},_0x447c['SBbAgh']=!![];}const _0x1153d9=_0x37a93d[0x8*0x1c1+0x7*0x36e+-0x657*0x6];_0x447c['twhbKo']!==_0x1153d9&&(_0x447c['HeShcF']={},_0x447c['twhbKo']=_0x1153d9);const _0x2dcae0=_0x447c['HeShcF'][_0x281910];return _0x2dcae0===undefined?(_0x4d13ab=_0x447c['OyzdFo'](_0x4d13ab),_0x447c['HeShcF'][_0x281910]=_0x4d13ab):_0x4d13ab=_0x2dcae0,_0x4d13ab;}export function codexOfficialTurn(_0x348187,_0x4634b0,_0x14dc04,_0x5a6865){const _0x46b3cb=_0x447c;if(!isPlainRecord(_0x4634b0)||typeof _0x4634b0['id']!==_0x46b3cb(0x12c)||!Array[_0x46b3cb(0xf6)](_0x4634b0[_0x46b3cb(0xfa)]))return undefined;const _0x308096=codexTimestamp(_0x4634b0[_0x46b3cb(0x13d)]),_0x2839c4=codexTimestamp(_0x4634b0[_0x46b3cb(0x105)])??_0x308096,_0x314850=codexOfficialItems(_0x348187,_0x4634b0['id'],_0x4634b0[_0x46b3cb(0xfa)],_0x14dc04,_0x308096,_0x2839c4);if(_0x314850[_0x46b3cb(0x164)]===0xcdc*-0x2+-0x539*-0x3+0xa0d)return undefined;if(_0x5a6865!==undefined){const _0x4a9b18=_0x5a6865[_0x46b3cb(0xfa)][_0x46b3cb(0x14f)](_0x4afadb=>_0x4afadb[_0x46b3cb(0x136)]===_0x46b3cb(0x19e)),_0x13dfb4=codexNativeItemIds(_0x4634b0[_0x46b3cb(0xfa)]),_0x549bb6=_0x314850[_0x46b3cb(0x13c)](_0x1537b6=>_0x1537b6[_0x46b3cb(0x136)]===_0x46b3cb(0x17c))[_0x46b3cb(0x164)],_0x5a7ebd=_0x549bb6>-0xc7*-0x16+-0x28*0x3b+-0x2*0x3f1,_0x450632=_0x5a6865[_0x46b3cb(0xfa)][_0x46b3cb(0x13c)](_0x2e6e57=>_0x2e6e57[_0x46b3cb(0x136)]===_0x46b3cb(0x17c)&&conversationItemNativeId(_0x2e6e57['id'])===undefined),_0xac6d19=_0x549bb6===-0x133+0x656+-0x523?[]:_0x450632[_0x46b3cb(0x142)](-_0x549bb6),_0x441815=_0x42ca93=>_0x42ca93[_0x46b3cb(0x19f)]((_0x3d6924,_0x25cdbc)=>{const _0x163663=_0x46b3cb;if(_0x25cdbc[_0x163663(0x136)]!==_0x163663(0x17c)||!isPlainRecord(_0x25cdbc[_0x163663(0xfd)]))return _0x3d6924;return _0x3d6924+(typeof _0x25cdbc[_0x163663(0xfd)][_0x163663(0x18a)]===_0x163663(0x12c)?_0x25cdbc[_0x163663(0xfd)][_0x163663(0x18a)][_0x163663(0x164)]:-0x8f+0xd99*0x1+-0xd0a*0x1);},0x5df*-0x5+-0x2cd+-0x24c*-0xe),_0x3830b5=_0x5a7ebd&&(_0x441815(_0xac6d19)>_0x441815(_0x314850)||(_0x5a6865[_0x46b3cb(0x105)]??-0x25be*0x1+-0x1ba8+0x4166*0x1)>(_0x2839c4??0x16*-0x1b3+-0x6c7*-0x5+0x5*0xb3)&&_0x441815(_0xac6d19)>-0x2*-0x486+-0x1869+0xf5d),_0x83fb9d=new Set(_0x3830b5?[]:_0x549bb6===0x1245*-0x2+-0x3de+0x2868?[]:_0xac6d19[_0x46b3cb(0x172)](_0x139a40=>_0x139a40['id'])),_0x20d6bd=_0x5a6865[_0x46b3cb(0xfa)][_0x46b3cb(0x13c)](_0xb6dcf5=>{const _0x5a70df=_0x46b3cb;if(_0xb6dcf5[_0x5a70df(0x136)]===_0x5a70df(0x19e))return![];if(_0xb6dcf5[_0x5a70df(0x136)]===_0x5a70df(0x17c)&&_0x83fb9d[_0x5a70df(0xee)](_0xb6dcf5['id']))return![];const _0x372f43=conversationItemNativeId(_0xb6dcf5['id']);return _0x372f43===undefined||!_0x13dfb4[_0x5a70df(0xee)](_0x372f43);}),_0x27a967=[...retainManagedImageAttachments(_0x5a6865,_0x4634b0['id'],_0x314850[_0x46b3cb(0x13c)](_0x7a0331=>_0x7a0331[_0x46b3cb(0x136)]!==_0x46b3cb(0x17c)||!_0x3830b5)[_0x46b3cb(0x172)](_0x2c3a67=>_0x2c3a67[_0x46b3cb(0x136)]===_0x46b3cb(0x19e)&&_0x4a9b18!==undefined?{..._0x4a9b18,'turnId':_0x5a6865['id']}:{..._0x2c3a67,'turnId':_0x5a6865['id'],'runId':_0x5a6865[_0x46b3cb(0x16f)]}))];if(_0x4a9b18!==undefined&&!_0x27a967[_0x46b3cb(0x189)](_0xbffb0a=>_0xbffb0a[_0x46b3cb(0x136)]===_0x46b3cb(0x19e)))_0x27a967[_0x46b3cb(0x14e)]({..._0x4a9b18,'turnId':_0x5a6865['id']});const _0xfbc531=new Set(_0x20d6bd[_0x46b3cb(0x172)](_0x264529=>_0x264529['id'])),_0x364c39=new Set(),_0x17bd32=_0x27a967[_0x46b3cb(0x14f)](_0x5d03b5=>_0x5d03b5[_0x46b3cb(0x136)]===_0x46b3cb(0x19e)),_0x25a213=_0x27a967[_0x46b3cb(0x13c)](_0x5ea283=>_0x5ea283[_0x46b3cb(0x136)]===_0x46b3cb(0x17c)),_0x9bcbff=_0x27a967[_0x46b3cb(0x13c)](_0x4c30c4=>_0x4c30c4[_0x46b3cb(0x136)]===_0x46b3cb(0x10f)),_0x2e912c=_0x46b3cb(0x174)+_0x4634b0['id']+':',_0x2d75e6=new Map(_0x27a967[_0x46b3cb(0x179)](_0x7d8deb=>{const _0x267a2c=_0x46b3cb,_0x140d09=_0x7d8deb['id'][_0x267a2c(0x116)](_0x2e912c);return _0x140d09<-0x91*0x43+-0x16fd+0x3cf0?[]:[[_0x7d8deb['id'][_0x267a2c(0x142)](_0x140d09+_0x2e912c[_0x267a2c(0x164)]),_0x7d8deb]];})),_0x106698=[];for(const _0x2e674a of _0x5a6865[_0x46b3cb(0xfa)]){let _0x32b22b;if(_0x2e674a[_0x46b3cb(0x136)]===_0x46b3cb(0x19e))_0x32b22b=_0x17bd32;else{if(_0x2e674a[_0x46b3cb(0x136)]===_0x46b3cb(0x10f))_0x32b22b=_0x9bcbff[_0x46b3cb(0x14f)](_0x19f9f1=>!_0x364c39[_0x46b3cb(0xee)](_0x19f9f1['id']));else{const _0x86816b=conversationItemNativeId(_0x2e674a['id']);if(_0x86816b!==undefined)_0x32b22b=_0x2d75e6[_0x46b3cb(0x157)](_0x86816b);if(_0x32b22b===undefined&&_0x2e674a[_0x46b3cb(0x136)]===_0x46b3cb(0x17c)&&_0x83fb9d[_0x46b3cb(0xee)](_0x2e674a['id']))_0x32b22b=_0x25a213[_0x46b3cb(0x14f)](_0xaf406b=>!_0x364c39[_0x46b3cb(0xee)](_0xaf406b['id']));}}if(_0x32b22b!==undefined){if(_0x2e674a[_0x46b3cb(0x136)]===_0x46b3cb(0x17c)&&_0x32b22b[_0x46b3cb(0x136)]===_0x46b3cb(0x17c)&&(_0x441815([_0x2e674a])>_0x441815([_0x32b22b])||(_0x5a6865[_0x46b3cb(0x105)]??0x31b+-0x1c59+0x2ce*0x9)>(_0x2839c4??0x17d4+0x5e3+0x1db7*-0x1)&&_0x441815([_0x2e674a])>0xe*0x241+0x14e2+-0x8*0x68e)){_0x106698[_0x46b3cb(0x168)](_0x2e674a),_0x364c39[_0x46b3cb(0x170)](_0x32b22b['id']);continue;}!_0x364c39[_0x46b3cb(0xee)](_0x32b22b['id'])&&(_0x106698[_0x46b3cb(0x168)](_0x32b22b),_0x364c39[_0x46b3cb(0x170)](_0x32b22b['id']));}else{if(_0xfbc531[_0x46b3cb(0xee)](_0x2e674a['id']))_0x106698[_0x46b3cb(0x168)](_0x2e674a);}}for(const _0xa55e4e of _0x27a967)if(!_0x364c39[_0x46b3cb(0xee)](_0xa55e4e['id']))_0x106698[_0x46b3cb(0x168)](_0xa55e4e);return{..._0x5a6865,'status':_0x46b3cb(0x12d),'items':_0x106698,'startedAt':_0x308096,'completedAt':_0x2839c4};}return{'id':_0x348187['id']+_0x46b3cb(0x174)+_0x4634b0['id'],'sessionId':_0x348187['id'],'runId':null,'userItemId':_0x314850[_0x46b3cb(0x14f)](_0x30a508=>_0x30a508[_0x46b3cb(0x136)]===_0x46b3cb(0x19e))?.['id']??null,'status':_0x46b3cb(0x12d),'model':null,'effort':null,'access':null,'items':_0x314850,'startedAt':_0x308096,'completedAt':_0x2839c4};}export function retainManagedImageAttachments(_0x1945f4,_0x28b420,_0x196b1f){const _0x20be3c=_0x447c,_0x2f0dbc=new Map();for(const _0x2cca99 of _0x1945f4[_0x20be3c(0xfa)]){const _0x116e98=conversationItemNativeId(_0x2cca99['id']);if(_0x116e98===undefined||!isPlainRecord(_0x2cca99[_0x20be3c(0xfd)]))continue;if(!Array[_0x20be3c(0xf6)](_0x2cca99[_0x20be3c(0xfd)][_0x20be3c(0x110)])||_0x2cca99[_0x20be3c(0xfd)][_0x20be3c(0x110)][_0x20be3c(0x164)]===-0x5f7+-0xef4+0x42f*0x5)continue;_0x2f0dbc[_0x20be3c(0x192)](_0x116e98,_0x2cca99[_0x20be3c(0xfd)][_0x20be3c(0x110)]);}if(_0x2f0dbc[_0x20be3c(0x12f)]===0x4*0x2dd+-0x5cc+0x16a*-0x4)return _0x196b1f;const _0x5d681d=_0x20be3c(0x174)+_0x28b420+':';return _0x196b1f[_0x20be3c(0x172)](_0x50c750=>{const _0x497836=_0x20be3c;if(!isPlainRecord(_0x50c750[_0x497836(0xfd)])||Array[_0x497836(0xf6)](_0x50c750[_0x497836(0xfd)][_0x497836(0x110)]))return _0x50c750;const _0x186c48=_0x50c750['id'][_0x497836(0x116)](_0x5d681d);if(_0x186c48<-0x1*0x2a5+0x6*0x221+0x1*-0xa21)return _0x50c750;const _0x4ccf8e=_0x2f0dbc[_0x497836(0x157)](_0x50c750['id'][_0x497836(0x142)](_0x186c48+_0x5d681d[_0x497836(0x164)]));return _0x4ccf8e===undefined?_0x50c750:{..._0x50c750,'payload':{..._0x50c750[_0x497836(0xfd)],'attachments':_0x4ccf8e}};});}export function codexNativeItemIds(_0x52861b){const _0x8cf8fa=_0x447c;return new Set(_0x52861b[_0x8cf8fa(0x179)](_0x111352=>{const _0x2e9ea9=_0x8cf8fa;if(!isPlainRecord(_0x111352))return[];const _0x4951ff=typeof _0x111352[_0x2e9ea9(0x13f)]===_0x2e9ea9(0x12c)?_0x111352[_0x2e9ea9(0x13f)]:typeof _0x111352['id']===_0x2e9ea9(0x12c)?_0x111352['id']:undefined;return _0x4951ff===undefined?[]:[_0x4951ff];}));}export function conversationItemNativeId(_0x293e6f){const _0x4d063a=_0x447c;if(_0x293e6f[_0x4d063a(0xf9)](_0x4d063a(0x102)))return _0x293e6f[_0x4d063a(0x142)](_0x4d063a(0x102)[_0x4d063a(0x164)]);const _0x275ebf=_0x4d063a(0x171),_0x56cf81=_0x293e6f[_0x4d063a(0x116)](_0x275ebf);return _0x56cf81<0x11a8+-0x43*0x11+-0xd35?undefined:_0x293e6f[_0x4d063a(0x142)](_0x56cf81+_0x275ebf[_0x4d063a(0x164)]);}export function codexOfficialItems(_0x391454,_0x4ae3a1,_0xe55dcf,_0x250550,_0x4cf018,_0xdd69bb){const _0x3faa76=_0x447c,_0x6a4b88=[],_0x3ea852=new Map();for(const [_0xcda716,_0x444b54]of _0xe55dcf[_0x3faa76(0x123)]()){const _0x5b5f81=codexOfficialItem(_0x391454,_0x4ae3a1,_0x444b54,_0x250550,_0xcda716,_0x4cf018,_0xdd69bb);if(_0x5b5f81===undefined)continue;if(_0x5b5f81[_0x3faa76(0x136)]===_0x3faa76(0x10f)&&_0x6a4b88['at'](-(0x2*-0xc19+-0x1424+0x2c57))?.[_0x3faa76(0x136)]===_0x3faa76(0x10f))continue;const _0x1a34e0=codexPairedToolCallId(_0x444b54);if(_0x1a34e0===undefined){_0x6a4b88[_0x3faa76(0x168)](_0x5b5f81);continue;}const _0x588474=_0x3ea852[_0x3faa76(0x157)](_0x1a34e0);if(_0x588474===undefined){_0x3ea852[_0x3faa76(0x192)](_0x1a34e0,_0x6a4b88[_0x3faa76(0x164)]),_0x6a4b88[_0x3faa76(0x168)](_0x5b5f81);continue;}const _0x2699a8=_0x6a4b88[_0x588474],_0x63764c=isPlainRecord(_0x444b54)&&(_0x444b54[_0x3faa76(0x181)]===_0x3faa76(0x130)||_0x444b54[_0x3faa76(0x181)]===_0x3faa76(0x121))?_0x5b5f81:_0x2699a8,_0x231955=_0x63764c===_0x5b5f81?_0x2699a8:_0x5b5f81;_0x6a4b88[_0x588474]=mergeCodexCustomToolItems(_0x63764c,_0x231955);}return _0x6a4b88;}export function codexPairedToolCallId(_0x49542b){const _0x5272ad=_0x447c;if(!isPlainRecord(_0x49542b))return undefined;if(_0x49542b[_0x5272ad(0x181)]!==_0x5272ad(0x130)&&_0x49542b[_0x5272ad(0x181)]!==_0x5272ad(0x12b)&&_0x49542b[_0x5272ad(0x181)]!==_0x5272ad(0x121)&&_0x49542b[_0x5272ad(0x181)]!==_0x5272ad(0xec))return undefined;return typeof _0x49542b[_0x5272ad(0x13f)]===_0x5272ad(0x12c)?_0x49542b[_0x5272ad(0x13f)]:typeof _0x49542b['id']===_0x5272ad(0x12c)?_0x49542b['id']:undefined;}export function mergeCodexCustomToolItems(_0x108940,_0xada730){const _0x5a33a0=_0x447c,_0x22f618=isPlainRecord(_0x108940[_0x5a33a0(0xfd)])?_0x108940[_0x5a33a0(0xfd)]:{},_0x20c094=isPlainRecord(_0xada730[_0x5a33a0(0xfd)])?_0xada730[_0x5a33a0(0xfd)]:{};if(_0x108940[_0x5a33a0(0x136)]===_0x5a33a0(0xeb))return{..._0x108940,'status':_0xada730[_0x5a33a0(0x17b)],'completedAt':_0xada730[_0x5a33a0(0x105)],'payload':{..._0x22f618,'outputPreview':_0x20c094[_0x5a33a0(0x175)]??_0x20c094[_0x5a33a0(0x12a)]??_0x22f618[_0x5a33a0(0x175)],'exitCode':_0x20c094[_0x5a33a0(0xf8)]??_0x22f618[_0x5a33a0(0xf8)],'durationMs':_0x20c094[_0x5a33a0(0x16e)]??_0x22f618[_0x5a33a0(0x16e)],'truncated':_0x22f618[_0x5a33a0(0x13e)]===!![]||_0x20c094[_0x5a33a0(0x13e)]===!![],..._0x20c094[_0x5a33a0(0x110)]===undefined?{}:{'attachments':_0x20c094[_0x5a33a0(0x110)]}}};if(_0x108940[_0x5a33a0(0x136)]!==_0xada730[_0x5a33a0(0x136)])return _0x108940;if(_0x108940[_0x5a33a0(0x136)]!==_0x5a33a0(0xf3))return _0x108940;return{..._0x108940,'status':_0xada730[_0x5a33a0(0x17b)],'completedAt':_0xada730[_0x5a33a0(0x105)],'payload':{..._0x22f618,'outputSummary':_0x20c094[_0x5a33a0(0x12a)]??_0x22f618[_0x5a33a0(0x12a)],'errorCode':_0x20c094[_0x5a33a0(0x11c)]??_0x22f618[_0x5a33a0(0x11c)],'truncated':_0x22f618[_0x5a33a0(0x13e)]===!![]||_0x20c094[_0x5a33a0(0x13e)]===!![],..._0x20c094[_0x5a33a0(0x110)]===undefined?{}:{'attachments':_0x20c094[_0x5a33a0(0x110)]}}};}export function coalesceImageGenerationItems(_0x1e3776){const _0x1a3aff=_0x447c,_0x55487f=[];for(const _0x21e6a6 of _0x1e3776){const _0x3f23cb=isPlainRecord(_0x21e6a6[_0x1a3aff(0xfd)])?_0x21e6a6[_0x1a3aff(0xfd)]:undefined,_0x38556c=_0x55487f['at'](-(0x1d+-0x1*0x1163+0x1*0x1147)),_0x19e0e3=_0x38556c!==undefined&&isPlainRecord(_0x38556c[_0x1a3aff(0xfd)])?_0x38556c[_0x1a3aff(0xfd)]:undefined;if(_0x21e6a6[_0x1a3aff(0x136)]!==_0x1a3aff(0xf3)||_0x3f23cb?.[_0x1a3aff(0x120)]!==_0x1a3aff(0x13a)||_0x38556c?.[_0x1a3aff(0x136)]!==_0x1a3aff(0xf3)||_0x19e0e3?.[_0x1a3aff(0x120)]!==_0x1a3aff(0x13a)){_0x55487f[_0x1a3aff(0x168)](_0x21e6a6);continue;}const _0x2abc30=[...Array[_0x1a3aff(0xf6)](_0x19e0e3[_0x1a3aff(0x110)])?_0x19e0e3[_0x1a3aff(0x110)]:[],...Array[_0x1a3aff(0xf6)](_0x3f23cb[_0x1a3aff(0x110)])?_0x3f23cb[_0x1a3aff(0x110)]:[]];_0x55487f[_0x55487f[_0x1a3aff(0x164)]-(0x1883+-0x2*0xedb+0x534)]={..._0x38556c,'completedAt':_0x21e6a6[_0x1a3aff(0x105)]??_0x38556c[_0x1a3aff(0x105)],'payload':{..._0x19e0e3,'attachments':_0x2abc30}};}return _0x55487f;}export function codexPlanText(_0x3009a1){const _0x58d670=_0x447c;if(typeof _0x3009a1[_0x58d670(0x181)]!==_0x58d670(0x12c)||typeof _0x3009a1[_0x58d670(0x18a)]!==_0x58d670(0x12c))return undefined;const _0x2123e0=_0x3009a1[_0x58d670(0x18a)][_0x58d670(0x15a)]();if(_0x2123e0[_0x58d670(0x164)]===0x2422+-0x12b7+-0x5b*0x31)return undefined;if(_0x3009a1[_0x58d670(0x181)][_0x58d670(0x10c)]()===_0x58d670(0x15b))return _0x2123e0;if(_0x3009a1[_0x58d670(0x181)]!==_0x58d670(0x18e)||!_0x2123e0[_0x58d670(0xf9)](_0x58d670(0x125)))return undefined;const _0x4291a2=_0x2123e0[_0x58d670(0x142)](_0x58d670(0x125)[_0x58d670(0x164)])[_0x58d670(0x109)](/<\/proposed_plan>\s*$/,'')[_0x58d670(0x15a)]();return _0x4291a2[_0x58d670(0x164)]>0x80f*0x3+0x11bc+-0x29e9?_0x4291a2:undefined;}export function codexOfficialItem(_0x1e5e50,_0x58d520,_0x7e180c,_0x4e9044,_0x4d1e92,_0x60d85f,_0x47467c){const _0x9a1c3=_0x447c;if(!isPlainRecord(_0x7e180c)||typeof _0x7e180c[_0x9a1c3(0x181)]!==_0x9a1c3(0x12c))return undefined;const _0x532359=(_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x130)||_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x12b)||_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x121)||_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0xec))&&typeof _0x7e180c[_0x9a1c3(0x13f)]===_0x9a1c3(0x12c)?_0x7e180c[_0x9a1c3(0x13f)]:typeof _0x7e180c['id']===_0x9a1c3(0x12c)?_0x7e180c['id']:typeof _0x7e180c[_0x9a1c3(0x13f)]===_0x9a1c3(0x12c)?_0x7e180c[_0x9a1c3(0x13f)]:_0x58d520+':'+_0x4d1e92,_0x40720c={'id':_0x1e5e50['id']+_0x9a1c3(0x174)+_0x58d520+':'+_0x532359,'sessionId':_0x1e5e50['id'],'turnId':_0x1e5e50['id']+_0x9a1c3(0x174)+_0x58d520,'runId':null,'parentItemId':null,'sourceSequence':_0x4e9044*(0x27*0xbf+0x20*0x20+0x1fd*0x3)+_0x4d1e92,'revision':0x0,'status':_0x9a1c3(0x1a0),'startedAt':_0x60d85f,'completedAt':_0x47467c};if(_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x16b)){const _0x56d8c5=stripMissionStartPrompt(codexContentText(_0x7e180c[_0x9a1c3(0xfc)]));return _0x56d8c5[_0x9a1c3(0x164)]===0x2214+0x76e*0x2+-0x30f0?undefined:{..._0x40720c,'kind':_0x9a1c3(0x19e),'payload':{'clientMessageId':null,'text':_0x56d8c5,'contexts':[],'delivery':_0x9a1c3(0x108)}};}const _0x59c1e2=codexPlanText(_0x7e180c);if(_0x59c1e2!==undefined)return{..._0x40720c,'kind':_0x9a1c3(0x15b),'payload':{'explanation':_0x59c1e2,'steps':[]}};if(_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x18e)&&typeof _0x7e180c[_0x9a1c3(0x18a)]===_0x9a1c3(0x12c)&&_0x7e180c[_0x9a1c3(0x18a)][_0x9a1c3(0x15a)]()[_0x9a1c3(0x164)]>0x1e62+-0xf4d*-0x1+-0x2daf)return{..._0x40720c,'kind':_0x9a1c3(0x17c),'payload':{'text':_0x7e180c[_0x9a1c3(0x18a)],'format':_0x9a1c3(0x15e),'source':_0x9a1c3(0x19c)}};if(_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x100)){const _0x1fa5bb=Array[_0x9a1c3(0xf6)](_0x7e180c[_0x9a1c3(0x176)])?_0x7e180c[_0x9a1c3(0x176)][_0x9a1c3(0x179)]((_0x5a1844,_0x9b0608)=>typeof _0x5a1844===_0x9a1c3(0x12c)&&_0x5a1844[_0x9a1c3(0x15a)]()[_0x9a1c3(0x164)]>-0x1b67+0x1255+0x912?[{'index':_0x9b0608,'text':compactRunnerText(_0x5a1844,0x430c+0xc3*-0x1f+-0x45f)}]:[]):[];return{..._0x40720c,'kind':_0x9a1c3(0x103),'payload':{'sections':_0x1fa5bb}};}if(_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x14d)){const _0x1e6cf8=typeof _0x7e180c[_0x9a1c3(0x144)]===_0x9a1c3(0x12c)?_0x7e180c[_0x9a1c3(0x144)]:'';return{..._0x40720c,'kind':_0x9a1c3(0xeb),'payload':{'command':typeof _0x7e180c[_0x9a1c3(0x196)]===_0x9a1c3(0x12c)?compactRunnerText(_0x7e180c[_0x9a1c3(0x196)],0xa59+-0x25bf+-0xb5*-0x5e):_0x9a1c3(0x19b),'cwd':typeof _0x7e180c[_0x9a1c3(0x132)]===_0x9a1c3(0x12c)?compactRunnerText(_0x7e180c[_0x9a1c3(0x132)],0x202e+0x1*-0x2383+0x65*0x31):null,'outputPreview':compactRunnerText(_0x1e6cf8,-0x1229+0x1d6e+-0x1*-0x1bcb),'outputRef':null,'exitCode':typeof _0x7e180c[_0x9a1c3(0xf8)]===_0x9a1c3(0x11d)&&Number[_0x9a1c3(0x156)](_0x7e180c[_0x9a1c3(0xf8)])?_0x7e180c[_0x9a1c3(0xf8)]:null,'durationMs':typeof _0x7e180c[_0x9a1c3(0x16e)]===_0x9a1c3(0x11d)&&Number[_0x9a1c3(0x156)](_0x7e180c[_0x9a1c3(0x16e)])&&_0x7e180c[_0x9a1c3(0x16e)]>=-0x4*-0x803+0x1543+-0x354f?_0x7e180c[_0x9a1c3(0x16e)]:null,'truncated':_0x1e6cf8[_0x9a1c3(0x164)]>0x4459+-0x12f4*-0x1+-0x303d*0x1}};}if(_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0xf5))return{..._0x40720c,'kind':_0x9a1c3(0xf3),'payload':{'title':[typeof _0x7e180c[_0x9a1c3(0xe6)]===_0x9a1c3(0x12c)?_0x7e180c[_0x9a1c3(0xe6)]:'',typeof _0x7e180c[_0x9a1c3(0x117)]===_0x9a1c3(0x12c)?_0x7e180c[_0x9a1c3(0x117)]:''][_0x9a1c3(0x13c)](Boolean)[_0x9a1c3(0x122)]('.'),'namespace':typeof _0x7e180c[_0x9a1c3(0xe6)]===_0x9a1c3(0x12c)?_0x7e180c[_0x9a1c3(0xe6)]:'','toolName':typeof _0x7e180c[_0x9a1c3(0x117)]===_0x9a1c3(0x12c)?_0x7e180c[_0x9a1c3(0x117)]:'','inputSummary':codexCompactJson(_0x7e180c[_0x9a1c3(0x14a)]),'outputSummary':codexCompactJson(_0x7e180c[_0x9a1c3(0x154)]),..._0x7e180c[_0x9a1c3(0x17d)]===undefined?{}:{'errorCode':codexCompactJson(_0x7e180c[_0x9a1c3(0x17d)])}}};if(_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x10b))return{..._0x40720c,'kind':_0x9a1c3(0xf3),'payload':{'title':_0x9a1c3(0x15d),'namespace':_0x9a1c3(0x195),'toolName':_0x9a1c3(0x18c),'inputSummary':typeof _0x7e180c[_0x9a1c3(0x126)]===_0x9a1c3(0x12c)?_0x7e180c[_0x9a1c3(0x126)]:''}};if(_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x194))return{..._0x40720c,'kind':_0x9a1c3(0xf3),'payload':{'title':_0x9a1c3(0x13a),'namespace':_0x9a1c3(0x166),'toolName':_0x9a1c3(0x13a),'inputSummary':typeof _0x7e180c[_0x9a1c3(0x143)]===_0x9a1c3(0x12c)?_0x7e180c[_0x9a1c3(0x143)]:null,'outputSummary':_0x7e180c[_0x9a1c3(0x17b)]===_0x9a1c3(0x17f)?_0x9a1c3(0x15c):_0x9a1c3(0x16a),'progressLabel':null,'errorCode':_0x7e180c[_0x9a1c3(0x17b)]===_0x9a1c3(0x184)?_0x9a1c3(0x160):null,'truncated':![],'toolCategory':_0x9a1c3(0x151)}};if(_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x190)||_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x130)||_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x12b)||_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x121)||_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0xec)||_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0xf1)||_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x139)||_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x104)||_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x128)){const _0x3cd5fb=typeof _0x7e180c[_0x9a1c3(0x117)]===_0x9a1c3(0x12c)?_0x7e180c[_0x9a1c3(0x117)]:typeof _0x7e180c[_0x9a1c3(0x193)]===_0x9a1c3(0x12c)?_0x7e180c[_0x9a1c3(0x193)]:_0x9a1c3(0x117),_0x2eface=normalizeCodexTool({'name':_0x3cd5fb,'namespace':typeof _0x7e180c[_0x9a1c3(0x173)]===_0x9a1c3(0x12c)?_0x7e180c[_0x9a1c3(0x173)]:_0x9a1c3(0x166),'rawInput':_0x7e180c[_0x9a1c3(0x14a)]??_0x7e180c[_0x9a1c3(0x140)],'inputSummary':codexCompactJson(_0x7e180c[_0x9a1c3(0x14a)]??_0x7e180c[_0x9a1c3(0x140)]),'outputSummary':codexToolOutputSummary(_0x7e180c[_0x9a1c3(0x198)]??_0x7e180c[_0x9a1c3(0xf4)]),'outputOnly':_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x12b)||_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0xec)||_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x139)||_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x128)});return{..._0x40720c,'kind':_0x2eface[_0x9a1c3(0x136)],'payload':_0x2eface[_0x9a1c3(0xfd)]};}if(_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x118)&&Array[_0x9a1c3(0xf6)](_0x7e180c[_0x9a1c3(0x155)]))return{..._0x40720c,'kind':_0x9a1c3(0x159),'payload':{'changes':normalizeCodexFileChanges(_0x7e180c[_0x9a1c3(0x155)])}};if(_0x7e180c[_0x9a1c3(0x181)]===_0x9a1c3(0x146))return{..._0x40720c,'kind':_0x9a1c3(0x10f),'payload':{'phase':_0x9a1c3(0x1a0),'summary':_0x9a1c3(0x153),'summaryCode':_0x9a1c3(0x114)}};return codexUnknownOfficialItem(_0x40720c,_0x7e180c);}export function codexLiveConversationItem(_0x5b0aff,_0x366d5b,_0x3b4da9=[]){const _0x16f7b6=_0x447c;if(typeof _0x5b0aff[_0x16f7b6(0x181)]!==_0x16f7b6(0x12c))return undefined;const _0x16d94=typeof _0x5b0aff[_0x16f7b6(0x13f)]===_0x16f7b6(0x12c)?_0x5b0aff[_0x16f7b6(0x13f)]:typeof _0x5b0aff['id']===_0x16f7b6(0x12c)?_0x5b0aff['id']:undefined;if(_0x16d94===undefined)return undefined;const _0xb550e3=boundedConversationItemId(_0x16f7b6(0x166),_0x16d94);if(_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x100)){const _0x5860a8=Array[_0x16f7b6(0xf6)](_0x5b0aff[_0x16f7b6(0x176)])?_0x5b0aff[_0x16f7b6(0x176)][_0x16f7b6(0x179)]((_0x33cdc7,_0x23f854)=>typeof _0x33cdc7===_0x16f7b6(0x12c)&&_0x33cdc7[_0x16f7b6(0x15a)]()[_0x16f7b6(0x164)]>-0x19e2+0x1069*-0x1+0x2a4b?[{'index':_0x23f854,'text':compactRunnerText(_0x33cdc7,0x3cd8+-0x2196+0xbce)}]:[]):[];return{'itemId':_0xb550e3,'kind':_0x16f7b6(0x103),'status':_0x366d5b?_0x16f7b6(0x1a0):_0x16f7b6(0x10a),'payload':{'sections':_0x5860a8}};}const _0x2183b0=codexPlanText(_0x5b0aff);if(_0x2183b0!==undefined)return{'itemId':_0xb550e3,'kind':_0x16f7b6(0x15b),'status':_0x366d5b?_0x16f7b6(0x1a0):_0x16f7b6(0x10a),'payload':{'explanation':compactRunnerText(_0x2183b0,-0x6509*-0x1+-0x2de*0x16+0x317*0xd),'steps':[]}};if(_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x18e)){if(!_0x366d5b||typeof _0x5b0aff[_0x16f7b6(0x18a)]!==_0x16f7b6(0x12c)||_0x5b0aff[_0x16f7b6(0x18a)][_0x16f7b6(0x164)]===0x35e*-0x4+0x2504+0x2*-0xbc6)return undefined;return{'itemId':_0xb550e3,'kind':_0x16f7b6(0x17c),'status':_0x16f7b6(0x1a0),'payload':{'text':compactRunnerText(_0x5b0aff[_0x16f7b6(0x18a)],MAX_ASSISTANT_MESSAGE_CHARACTERS),'format':_0x16f7b6(0x15e),'model':null}};}if(_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x14d)){const _0x4b45cd=typeof _0x5b0aff[_0x16f7b6(0x144)]===_0x16f7b6(0x12c)?_0x5b0aff[_0x16f7b6(0x144)]:'';return{'itemId':_0xb550e3,'kind':_0x16f7b6(0xeb),'status':codexItemStatus(_0x5b0aff[_0x16f7b6(0x17b)],_0x366d5b),'payload':{'command':typeof _0x5b0aff[_0x16f7b6(0x196)]===_0x16f7b6(0x12c)?compactRunnerText(_0x5b0aff[_0x16f7b6(0x196)],-0xaff*-0x3+0x1*-0xef2+0x1*0x1505):_0x16f7b6(0x19b),'cwd':typeof _0x5b0aff[_0x16f7b6(0x132)]===_0x16f7b6(0x12c)?compactRunnerText(_0x5b0aff[_0x16f7b6(0x132)],0x253b+-0xe17+-0x724):null,'outputPreview':compactRunnerText(_0x4b45cd,-0x2715+-0x7b9*-0x6+-0x1df*-0x11),'outputRef':null,'exitCode':typeof _0x5b0aff[_0x16f7b6(0xf8)]===_0x16f7b6(0x11d)&&Number[_0x16f7b6(0x156)](_0x5b0aff[_0x16f7b6(0xf8)])?_0x5b0aff[_0x16f7b6(0xf8)]:null,'durationMs':typeof _0x5b0aff[_0x16f7b6(0x16e)]===_0x16f7b6(0x11d)&&Number[_0x16f7b6(0x156)](_0x5b0aff[_0x16f7b6(0x16e)])&&_0x5b0aff[_0x16f7b6(0x16e)]>=0x2a*0x75+0x90+-0x2*0x9e1?_0x5b0aff[_0x16f7b6(0x16e)]:null,'truncated':_0x4b45cd[_0x16f7b6(0x164)]>0x49aa+-0x268d+0x1*0x3f3}};}if(_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0xf5)){const _0x3fc252=compactRunnerValue(_0x5b0aff[_0x16f7b6(0x14a)],0x737*0x3+0xb3*-0x53+-0x25ba*-0x2),_0x47950c=compactRunnerValue(_0x5b0aff[_0x16f7b6(0x154)],-0x2959*-0x1+-0x3f3b*-0x1+-0x4184),_0x21fdc3=compactRunnerValue(_0x5b0aff[_0x16f7b6(0x17d)],-0xb*0xaf+0x1b42+-0x136d),_0x300c59=typeof _0x5b0aff[_0x16f7b6(0xe6)]===_0x16f7b6(0x12c)?_0x5b0aff[_0x16f7b6(0xe6)]:_0x16f7b6(0x131),_0x28e6e3=typeof _0x5b0aff[_0x16f7b6(0x117)]===_0x16f7b6(0x12c)?_0x5b0aff[_0x16f7b6(0x117)]:_0x16f7b6(0x117);return{'itemId':_0xb550e3,'kind':_0x16f7b6(0xf3),'status':codexItemStatus(_0x5b0aff[_0x16f7b6(0x17b)],_0x366d5b),'payload':{'namespace':compactRunnerText(_0x300c59,0x1*-0x1c57+0xe56+0x4f*0x2f),'toolName':compactRunnerText(_0x28e6e3,0x15*-0xed+0x1a8c*-0x1+0x2e7d*0x1),'title':compactRunnerText(_0x300c59+'.'+_0x28e6e3,-0x53d*0x3+-0x778+-0x75*-0x37),'inputSummary':_0x3fc252[_0x16f7b6(0x18a)]||null,'outputSummary':_0x47950c[_0x16f7b6(0x18a)]||null,'progressLabel':null,'errorCode':_0x21fdc3[_0x16f7b6(0x18a)]||null,'truncated':_0x3fc252[_0x16f7b6(0x13e)]||_0x47950c[_0x16f7b6(0x13e)]||_0x21fdc3[_0x16f7b6(0x13e)]}};}if(_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x10b))return{'itemId':_0xb550e3,'kind':_0x16f7b6(0xf3),'status':_0x366d5b?_0x16f7b6(0x1a0):_0x16f7b6(0x10a),'payload':{'namespace':_0x16f7b6(0x195),'toolName':_0x16f7b6(0x18c),'title':_0x16f7b6(0x15d),'inputSummary':typeof _0x5b0aff[_0x16f7b6(0x126)]===_0x16f7b6(0x12c)?compactRunnerText(_0x5b0aff[_0x16f7b6(0x126)],-0x1f6*-0x11+-0x1832+-0x4*-0x77b):null,'outputSummary':null,'progressLabel':_0x366d5b?null:_0x16f7b6(0x107),'progressLabelCode':_0x366d5b?null:_0x16f7b6(0x101),'errorCode':null,'truncated':![]}};if(_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x118)&&Array[_0x16f7b6(0xf6)](_0x5b0aff[_0x16f7b6(0x155)]))return{'itemId':_0xb550e3,'kind':_0x16f7b6(0x159),'status':_0x366d5b?_0x16f7b6(0x1a0):_0x16f7b6(0x10a),'payload':{'changes':normalizeCodexFileChanges(_0x5b0aff[_0x16f7b6(0x155)])},'merge':!![]};if(_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x194))return{'itemId':_0xb550e3,'kind':_0x16f7b6(0xf3),'status':codexItemStatus(_0x5b0aff[_0x16f7b6(0x17b)],_0x366d5b),'payload':{'namespace':_0x16f7b6(0x166),'toolName':_0x16f7b6(0x13a),'title':_0x16f7b6(0x13a),'inputSummary':typeof _0x5b0aff[_0x16f7b6(0x143)]===_0x16f7b6(0x12c)?compactRunnerText(_0x5b0aff[_0x16f7b6(0x143)],0x13*-0x3c7+0x1115+0x3*0x1f40):null,'outputSummary':_0x366d5b?_0x16f7b6(0x15c):null,'outputSummaryCode':_0x366d5b?_0x16f7b6(0x14b):null,'progressLabel':_0x366d5b?null:_0x16f7b6(0x187),'progressLabelCode':_0x366d5b?null:_0x16f7b6(0x16d),'errorCode':_0x5b0aff[_0x16f7b6(0x17b)]===_0x16f7b6(0x184)?_0x16f7b6(0x160):null,'truncated':![],'toolCategory':_0x16f7b6(0x151),..._0x3b4da9[_0x16f7b6(0x164)]===0x3*-0x4b2+0x134a+-0x534?{}:{'attachments':_0x3b4da9}},'merge':!![]};if(_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x146))return{'itemId':_0xb550e3,'kind':_0x16f7b6(0x10f),'status':_0x366d5b?_0x16f7b6(0x1a0):_0x16f7b6(0x10a),'payload':{'phase':_0x366d5b?_0x16f7b6(0x1a0):_0x16f7b6(0x148),'summary':null}};if(_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x190)||_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x130)||_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x12b)||_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x121)||_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0xec)||_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0xf1)||_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x139)||_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x104)||_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x128)){const _0x2fc598=typeof _0x5b0aff[_0x16f7b6(0x117)]===_0x16f7b6(0x12c)?_0x5b0aff[_0x16f7b6(0x117)]:typeof _0x5b0aff[_0x16f7b6(0x193)]===_0x16f7b6(0x12c)?_0x5b0aff[_0x16f7b6(0x193)]:_0x16f7b6(0x117),_0x1a35fc=compactRunnerValue(_0x5b0aff[_0x16f7b6(0x14a)]??_0x5b0aff[_0x16f7b6(0x140)],0x35a1+-0x4ae4*-0x1+-0x5975*0x1),_0x339948=compactRunnerValue(codexToolOutput(_0x5b0aff[_0x16f7b6(0x198)]??_0x5b0aff[_0x16f7b6(0xf4)]),0x45ce+0x44c8*-0x1+0xcae*0x3),_0x17f94f=_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x12b)||_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0xec)||_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x139)||_0x5b0aff[_0x16f7b6(0x181)]===_0x16f7b6(0x128),_0xf965d1=normalizeCodexTool({'name':_0x2fc598,'namespace':typeof _0x5b0aff[_0x16f7b6(0x173)]===_0x16f7b6(0x12c)?_0x5b0aff[_0x16f7b6(0x173)]:_0x16f7b6(0x166),'rawInput':_0x5b0aff[_0x16f7b6(0x14a)]??_0x5b0aff[_0x16f7b6(0x140)],'inputSummary':_0x1a35fc[_0x16f7b6(0x18a)]||null,'outputSummary':_0x339948[_0x16f7b6(0x18a)]||null,'truncated':_0x1a35fc[_0x16f7b6(0x13e)]||_0x339948[_0x16f7b6(0x13e)],'outputOnly':_0x17f94f,'attachments':_0x3b4da9});return{'itemId':_0xb550e3,'kind':_0xf965d1[_0x16f7b6(0x136)],'status':codexItemStatus(_0x5b0aff[_0x16f7b6(0x17b)],_0x366d5b),'payload':_0xf965d1[_0x16f7b6(0xfd)],'merge':!![]};}return codexUnknownLiveItem(_0xb550e3,_0x5b0aff[_0x16f7b6(0x181)],_0x366d5b);}function normalizeCodexFileChanges(_0x9e4476){const _0x4a1a28=_0x447c;return _0x9e4476[_0x4a1a28(0x179)](_0x21a93d=>{const _0x3b4790=_0x4a1a28;if(!isPlainRecord(_0x21a93d)||typeof _0x21a93d[_0x3b4790(0x113)]!==_0x3b4790(0x12c))return[];const _0x255402=compactRunnerText(_0x21a93d[_0x3b4790(0x113)],0x74f*-0x1+-0x16bf*-0x1+0x12*0x8);if(_0x255402[_0x3b4790(0x164)]===-0x2271+0x181+0x20f0)return[];const _0x24d2a9=typeof _0x21a93d[_0x3b4790(0x16c)]===_0x3b4790(0x12c)?_0x21a93d[_0x3b4790(0x16c)]:_0x21a93d[_0x3b4790(0x136)],_0xdd9739=_0x24d2a9===_0x3b4790(0x170)||_0x24d2a9===_0x3b4790(0x149)||_0x24d2a9===_0x3b4790(0xfb)?_0x3b4790(0xfb):_0x24d2a9===_0x3b4790(0x183)||_0x24d2a9===_0x3b4790(0x177)||_0x24d2a9===_0x3b4790(0x13b)?_0x3b4790(0x13b):_0x24d2a9===_0x3b4790(0x165)||_0x24d2a9===_0x3b4790(0x138)||_0x24d2a9===_0x3b4790(0xf0)?_0x3b4790(0xf0):_0x3b4790(0x147);return[{'path':_0x255402,'change':_0xdd9739,'additions':nonnegativeIntegerOrNull(_0x21a93d[_0x3b4790(0x129)]),'deletions':nonnegativeIntegerOrNull(_0x21a93d[_0x3b4790(0x18d)]),'diffAvailable':_0x21a93d[_0x3b4790(0x18f)]===!![]}];});}function nonnegativeIntegerOrNull(_0x29d8a7){const _0x83d679=_0x447c;return typeof _0x29d8a7===_0x83d679(0x11d)&&Number[_0x83d679(0x162)](_0x29d8a7)&&_0x29d8a7>=-0x1daf+0x761*-0x1+0x1*0x2510?_0x29d8a7:null;}function codexUnknownOfficialItem(_0x508440,_0x47e99b){const _0x4d3434=_0x447c;if(_0x47e99b[_0x4d3434(0x181)]===_0x4d3434(0x16b)||_0x47e99b[_0x4d3434(0x181)]===_0x4d3434(0x18e))return undefined;const _0x42098d=typeof _0x47e99b[_0x4d3434(0x181)]===_0x4d3434(0x12c)?_0x47e99b[_0x4d3434(0x181)]:_0x4d3434(0x197);return{..._0x508440,'kind':_0x4d3434(0x197),'payload':{'sourceEventType':_0x4d3434(0x102)+_0x42098d,'label':_0x4d3434(0x10d)+compactRunnerText(_0x42098d,0x1*-0x16c3+-0x1*0x25fd+0x3d40)}};}function codexUnknownLiveItem(_0x884fdf,_0x4b3d2c,_0x20834c){const _0x492fbf=_0x447c;if(_0x4b3d2c===_0x492fbf(0x16b)||_0x4b3d2c===_0x492fbf(0x18e))return undefined;return{'itemId':_0x884fdf,'kind':_0x492fbf(0x197),'status':_0x20834c?_0x492fbf(0x1a0):_0x492fbf(0x10a),'payload':{'sourceEventType':_0x492fbf(0x102)+_0x4b3d2c,'label':_0x492fbf(0x10d)+compactRunnerText(_0x4b3d2c,-0x8d+0x1*-0xb29+0x6*0x209)}};}export function codexImageAttachments(_0x3b9836){const _0x84b73=[];let _0x267d16=-0x139*0x4+0x23d8+-0x1ef4;const _0xc9fca5=(_0x227c36,_0x298629)=>{const _0x2936b1=_0x447c;if(_0x84b73[_0x2936b1(0x164)]>=-0xa97*0x3+0xac2+0x4*0x542||_0x298629>0x7d*0x47+-0x1a93+-0x2f*0x2c||_0x227c36===null||_0x227c36===undefined)return;if(Array[_0x2936b1(0xf6)](_0x227c36)){for(const _0x534ae7 of _0x227c36)_0xc9fca5(_0x534ae7,_0x298629+(0xeb1+-0x1de1*-0x1+-0x2c91*0x1));return;}if(!isPlainRecord(_0x227c36))return;const _0x5e2a1b=typeof _0x227c36[_0x2936b1(0x181)]===_0x2936b1(0x12c)?_0x227c36[_0x2936b1(0x181)]:'';if(_0x5e2a1b===_0x2936b1(0x11f)&&typeof _0x227c36[_0x2936b1(0x18a)]===_0x2936b1(0x12c)){const _0x13aafa=/["']image_url["']\s*:\s*["'](data:image\/[^"']+)["']/[_0x2936b1(0xfe)](_0x227c36[_0x2936b1(0x18a)])?.[0x1f64*-0x1+0x543*-0x2+0x7*0x5fd];_0x13aafa!==undefined&&_0xc9fca5({'type':_0x2936b1(0x152),'image_url':_0x13aafa},_0x298629+(0x237a+0x459*0x4+0x119f*-0x3));}const _0x41af77=typeof _0x227c36[_0x2936b1(0x185)]===_0x2936b1(0x12c)?_0x227c36[_0x2936b1(0x185)]:undefined,_0x3acb76=isPlainRecord(_0x227c36[_0x2936b1(0x199)])?typeof _0x227c36[_0x2936b1(0x199)][_0x2936b1(0x115)]===_0x2936b1(0x12c)?_0x227c36[_0x2936b1(0x199)][_0x2936b1(0x115)]:undefined:typeof _0x227c36[_0x2936b1(0x199)]===_0x2936b1(0x12c)?_0x227c36[_0x2936b1(0x199)]:undefined,_0x5d8530=_0x41af77??(_0x3acb76?.[_0x2936b1(0xf9)](_0x2936b1(0x145))?_0x3acb76:undefined);if((_0x5e2a1b===_0x2936b1(0x178)||_0x5e2a1b===_0x2936b1(0x152)||_0x5e2a1b===_0x2936b1(0xe7))&&_0x5d8530!==undefined){const _0x12bfbc=/^data:([^;,]+);base64,(.*)$/[_0x2936b1(0xfe)](_0x5d8530),_0x406e83=typeof _0x227c36[_0x2936b1(0x18b)]===_0x2936b1(0x12c)?_0x227c36[_0x2936b1(0x18b)]:typeof _0x227c36[_0x2936b1(0x180)]===_0x2936b1(0x12c)?_0x227c36[_0x2936b1(0x180)]:_0x12bfbc?.[0x14d7+0x1*0x14b3+0x1*-0x2989]??_0x2936b1(0xe9),_0x4f8a28=_0x12bfbc?.[0x1046+0x2f6*0x8+-0x27f4*0x1]??_0x5d8530;_0x406e83[_0x2936b1(0xf9)](_0x2936b1(0x111))&&isCanonicalBase64(_0x4f8a28)&&_0x4f8a28[_0x2936b1(0x164)]>0x1f*0xe1+-0x2ea+-0x1855&&Buffer[_0x2936b1(0x127)](_0x4f8a28,_0x2936b1(0x161))<=MAX_COMPOSER_ATTACHMENT_BYTES&&_0x267d16+Buffer[_0x2936b1(0x127)](_0x4f8a28,_0x2936b1(0x161))<=MAX_COMPOSER_ATTACHMENTS_BYTES&&(_0x267d16+=Buffer[_0x2936b1(0x127)](_0x4f8a28,_0x2936b1(0x161)),_0x84b73[_0x2936b1(0x168)]({'name':typeof _0x227c36[_0x2936b1(0x193)]===_0x2936b1(0x12c)?_0x227c36[_0x2936b1(0x193)]:_0x2936b1(0x11e)+(_0x84b73[_0x2936b1(0x164)]+(0xb*0x387+0x718+-0x2de4))+_0x2936b1(0x135),'mime':_0x406e83,'dataBase64':_0x4f8a28}));}for(const [_0x59ef21,_0x32418a]of Object[_0x2936b1(0x123)](_0x227c36)){if(_0x59ef21===_0x2936b1(0x185)||_0x59ef21===_0x2936b1(0x199))continue;_0xc9fca5(_0x32418a,_0x298629+(0x3*0x5fe+0x1*-0x1205+-0x3*-0x4));}};return _0xc9fca5(_0x3b9836,0x2*0x67f+0xd*-0x131+-0x27f*-0x1),_0x84b73;}export function codexUserInputQuestions(_0x4f55bb){const _0x40d29d=_0x447c;if(!Array[_0x40d29d(0xf6)](_0x4f55bb)||_0x4f55bb[_0x40d29d(0x164)]===0x256f+0x1c0a+-0x25*0x1c5||_0x4f55bb[_0x40d29d(0x164)]>0x3*0x69b+-0xf0c+-0x4c2)return[];const _0x2d2d91=_0x4f55bb[_0x40d29d(0x172)](_0x52e3ac=>{const _0x21d030=_0x40d29d;if(!isPlainRecord(_0x52e3ac)||typeof _0x52e3ac['id']!==_0x21d030(0x12c)||typeof _0x52e3ac[_0x21d030(0x17a)]!==_0x21d030(0x12c))return undefined;const _0x14c2ac=Array[_0x21d030(0xf6)](_0x52e3ac[_0x21d030(0xf7)])?_0x52e3ac[_0x21d030(0xf7)][_0x21d030(0x179)](_0x277a8a=>isPlainRecord(_0x277a8a)&&typeof _0x277a8a[_0x21d030(0x124)]===_0x21d030(0x12c)?[{'value':compactRunnerText(_0x277a8a[_0x21d030(0x124)],-0x13ea+0x366+0x1278),'label':compactRunnerText(_0x277a8a[_0x21d030(0x124)],0xb*-0x30f+-0xe*0xe+-0x245d*-0x1),'description':typeof _0x277a8a[_0x21d030(0x158)]===_0x21d030(0x12c)?compactRunnerText(_0x277a8a[_0x21d030(0x158)],0x24ca+-0xcde+0x7*-0x2dc):null}]:[]):[];return{'id':compactRunnerText(_0x52e3ac['id'],-0x2ea*-0x3+0x250c+-0x2d4a),'prompt':compactRunnerText(_0x52e3ac[_0x21d030(0x17a)],-0x35b*-0x9+0xca1*-0x2+0x19f*0x9),'options':_0x14c2ac,'allowOther':_0x52e3ac[_0x21d030(0x14c)]===!![]};});return _0x2d2d91[_0x40d29d(0x189)](_0xe8c916=>_0xe8c916===undefined)?[]:_0x2d2d91;}export function codexItemStatus(_0x4e6838,_0x33991f){const _0x54ac03=_0x447c;if(_0x4e6838===_0x54ac03(0x184))return _0x54ac03(0x137);if(_0x4e6838===_0x54ac03(0x182))return _0x54ac03(0x12e);return _0x33991f||_0x4e6838===_0x54ac03(0x17f)?_0x54ac03(0x1a0):_0x54ac03(0x10a);}export function codexContentText(_0x242b3e){const _0x511a36=_0x447c;if(!Array[_0x511a36(0xf6)](_0x242b3e))return'';const _0x5a40d5=_0x242b3e[_0x511a36(0x179)](_0x47513b=>{const _0x757555=_0x511a36;if(typeof _0x47513b===_0x757555(0x12c))return[_0x47513b];if(!isPlainRecord(_0x47513b))return[];return typeof _0x47513b[_0x757555(0x18a)]===_0x757555(0x12c)?[_0x47513b[_0x757555(0x18a)]]:[];})[_0x511a36(0x122)]('\x0a')[_0x511a36(0x15a)]();return parseCodexComposerImageMarkers(_0x5a40d5)[_0x511a36(0x18a)][_0x511a36(0x15a)]();}export function codexCompactJson(_0x36f849){const _0x2c724c=_0x447c;if(_0x36f849===undefined||_0x36f849===null)return'';if(typeof _0x36f849===_0x2c724c(0x12c))return compactRunnerText(_0x36f849,0x2f63+-0x3941+0x30ee);try{return compactRunnerText(JSON[_0x2c724c(0x19a)](_0x36f849),-0x69*0xbe+0x131c+0x61e2);}catch{return'';}}export function codexToolOutputSummary(_0x16a3e0){return codexCompactJson(codexToolOutput(_0x16a3e0));}export function codexToolOutput(_0x4581c3){const _0x7dd856=_0x447c;if(!Array[_0x7dd856(0xf6)](_0x4581c3))return _0x4581c3;const _0x51c7d8=_0x4581c3[_0x7dd856(0x179)](_0x35a87e=>{const _0x6cbe2b=_0x7dd856;if(typeof _0x35a87e===_0x6cbe2b(0x12c))return[_0x35a87e];if(!isPlainRecord(_0x35a87e))return[];if(typeof _0x35a87e[_0x6cbe2b(0x18a)]===_0x6cbe2b(0x12c)){const _0x40bfcc=codexVisibleToolText(_0x35a87e[_0x6cbe2b(0x18a)]);return _0x40bfcc[_0x6cbe2b(0x164)]>0x4e+-0x99d+-0x1*-0x94f?[_0x40bfcc]:[];}if(typeof _0x35a87e[_0x6cbe2b(0xfc)]===_0x6cbe2b(0x12c))return[_0x35a87e[_0x6cbe2b(0xfc)]];return[];});return _0x51c7d8[_0x7dd856(0x164)]>-0x1f8f*-0x1+-0x2ea*0xd+0x653?_0x51c7d8[_0x7dd856(0x122)](''):_0x4581c3[_0x7dd856(0x189)](isCodexImageBlock)?_0x7dd856(0x133):_0x4581c3;}export function codexVisibleToolText(_0x3a3b1){const _0x39f4ee=_0x447c;return _0x3a3b1[_0x39f4ee(0x109)](/(["']image_url["']\s*:\s*["'])data:image\/[^"']+(["'])/g,_0x39f4ee(0x191));}export function isCodexImageBlock(_0x259aee){const _0x24f388=_0x447c;if(!isPlainRecord(_0x259aee))return![];return _0x259aee[_0x24f388(0x181)]===_0x24f388(0x178)||_0x259aee[_0x24f388(0x181)]===_0x24f388(0x152)||_0x259aee[_0x24f388(0x181)]===_0x24f388(0xe7);}function _0x3bdc(){const _0x4751c7=['Aw1Hz2vNzw4','revmrvrfra','zMLSDgvY','C3rHCNrLzef0','Dhj1BMnHDgvK','y2fSBf9Pza','Aw5WDxq','zNjVBq','C2XPy2u','CMv2AxnLzfbYB21WDa','ywDNCMvNyxrLze91Dhb1Da','zgf0ytO','y29UDgv4DenVBxbHy3rPB24','tu9esuzjruq','u1rbuLrfra','ywrKzwq','yxjNDw1LBNrZ','su1br0vFr0vorvjbveLptL9dt01qtevuruq','AxnpDgHLCG','y29TBwfUzev4zwn1DgLVBG','Dw5ZAgLMDa','zMLUza','nKT5wfDiwa','su1br0vFr0vorvjbveLptG','Aw5WDxrFAw1Hz2u','q29UDgv4DcbJB21Wywn0zwq','CMvZDwX0','y2HHBMDLCW','AxnjBNrLz2vY','z2v0','zgvZy3jPChrPB24','zMLSzv9JAgfUz2u','DhjPBq','CgXHBG','sw1Hz2uGz2vUzxjHDgLVBIbJB21WBgv0zwq','v2vIifnLyxjJAa','BwfYA2rVD24','ohDhB3HNAG','su1br0vFr0vorvjbveLptL9gquLmruq','yMfZzty0','AxntywzLsw50zwDLCG','B2jQzwn0','BgvUz3rO','CMvUyw1L','y29KzxG','mtq0nZy0me9gsKjPva','ChvZAa','yMfZzty0DxjS','sw1Hz2uGz2vUzxjHDgLVBIbMywLSzwq','DxnLCK1LC3nHz2u','y2HHBMDL','r0vorvjbveLor19jtufhrq','zhvYyxrPB25nCW','CNvUswq','ywrK','oMnVzgv4oG','BwfW','BMfTzxnWywnL','oM9MzMLJAwfSoG','B3v0Chv0uhjLDMLLDW','C3vTBwfYEq','zgvSzxrLza','Aw1Hz2u','zMXHDe1HCa','CxvLC3rPB24','C3rHDhvZ','yxnZAxn0yw50x21LC3nHz2u','zxjYB3i','y3vYC29Y','y29TCgXLDgvK','BwLTzq','DhLWzq','zgvJBgLUzwq','zgvSzxrL','zMfPBgvK','zgf0yq','nZC3ndqXEgPVDu90','r2vUzxjHDgLUzYbPBwfNzq','nda3AeDXvxDl','C29Tzq','Dgv4Da','BwLTzvr5Cgu','C2vHCMnO','zgvSzxrPB25Z','ywDLBNrnzxnZywDL','zgLMzKf2ywLSywjSzq','zhLUyw1Py1rVB2XdywXS','jdfBsw1Hz2uGy29UDgvUDcbLEhrYywn0zwrDjdi','C2v0','BMfTzq','Aw1Hz2vhzw5LCMf0Aw9U','D2vI','y29TBwfUza','Dw5RBM93BG','y29UDgvUDeL0zw1Z','Aw1Hz2vFDxjS','C3rYAw5NAwz5','ke5VignVBw1HBMqGChjVDMLKzwqP','y29KzxGTyxbWlxnLCNzLCG','mtqXmtu2DKv1vLvt','DxnLCL9TzxnZywDL','CMvKDwnL','q09nueXfveve','C2vYDMvY','B3v0Chv0x2LTywDL','mtzPzMDpwLy','Aw1Hz2uVCg5N','BwLU','y29TBwfUzf9LEgvJDxrPB24','zNvUy3rPB25Fy2fSBf9VDxrWDxq','nJCWmJeWC2LQrer2','AgfZ','odCZnZi2DwLTChPI','uKvoqu1fra','y3vZDg9Tvg9VBenHBgW','DgHYzwfK','Dg9VBf9JywXS','B3v0Chv0','BwnWvg9VBenHBgW','AxnbCNjHEq','B3b0Aw9UCW','zxHPDenVzgu','C3rHCNrZv2L0Aa','AxrLBxm','qureruq','y29UDgvUDa','Cgf5Bg9Hza','zxHLyW','BgLTAxq','CMvHC29UAw5N','u0vbuKnisu5h','y29KzxG6','CMvHC29UAw5Nx3n1Bw1HCNK','zNvUy3rPB25dywXS','y29TCgXLDgvKqxq','Bwf4','u2vHCMnOAw5N','qundrvburuq','CMvWBgfJzq','su5Fufjpr1jfu1m','D2vIu2vHCMnO','Dg9mB2nHBgvmB3DLCKnHC2u','q29KzxGG','DhvYBNm','y29UDgv4Df9JB21Wywn0Aw9U','yxr0ywnOBwvUDhm','Aw1Hz2uV','BMf0AxzLvhvYBKLK','Cgf0Aa','q09ovevyvf9dt01qqunuruq','DxjS','BgfZDeLUzgv4t2y','Dg9VBa','zMLSzunOyw5Nzq','odeXmJeWnw9ZtMLzBq','otG0otK0ohbUAxHIvq','Dg9tDhjPBMC','zxjYB3jdB2rL','BNvTyMvY','z2vUzxjHDgvKlwLTywDLlq','Aw5WDxrFDgv4Da','Dg9VBe5HBwu','zNvUy3rPB25Fy2fSBa','AM9PBG','zw50CMLLCW','BgfIzwW','phbYB3bVC2vKx3bSyw4+','CxvLCNK','yNL0zuXLBMD0Aa','zNvUy3rPB25dywXSt3v0Chv0','ywrKAxrPB25Z','B3v0Chv0u3vTBwfYEq','y3vZDg9Tx3rVB2XFy2fSBf9VDxrWDxq','C3rYAw5N','u1vdq0vfreve','revdteLoruq','C2L6zq','y3vZDg9Tx3rVB2XFy2fSBa','BwnW','y3DK','sw1Hz2uGz2vUzxjHDgvK','zxH0zxjUywXtzxnZAw9Uswq','lNbUzW','A2LUza','rKfjteve','CMvUyw1Lza','y3vZDg9Tvg9VBenHBgXpDxrWDxq'];_0x3bdc=function(){return _0x4751c7;};return _0x3bdc();}import{codexTimestamp,compactRunnerText,compactRunnerValue,boundedConversationItemId,isCanonicalBase64,isPlainRecord,nativePageEnd}from'../../util/node-operation-parsers.js';export*from'../../util/node-operation-parsers.js';
|
|
1
|
+
import { parseCodexComposerImageMarkers } from './composer-image-markers.js';
|
|
2
|
+
import { normalizeCodexTool } from './tool-normalizer.js';
|
|
3
|
+
import { stripMissionStartPrompt } from '../../service/mission-runtime.js';
|
|
4
|
+
const MAX_COMPOSER_ATTACHMENT_BYTES = 5 * 1024 * 1024;
|
|
5
|
+
const MAX_COMPOSER_ATTACHMENTS_BYTES = 10 * 1024 * 1024;
|
|
6
|
+
const MAX_ASSISTANT_MESSAGE_CHARACTERS = 64 * 1024;
|
|
7
|
+
export * from '../../util/runner-native-session-parsers.js';
|
|
8
|
+
export function codexOfficialConversationPage(session, result, input, managedTurnForNative) {
|
|
9
|
+
if (!isPlainRecord(result) || !isPlainRecord(result.thread))
|
|
10
|
+
return undefined;
|
|
11
|
+
const thread = result.thread;
|
|
12
|
+
if (thread.id !== session.externalSessionId || !Array.isArray(thread.turns))
|
|
13
|
+
return undefined;
|
|
14
|
+
const parsedTurns = thread.turns.flatMap((value, sequence) => {
|
|
15
|
+
const nativeTurnId = typeof value === 'object' && value !== null && typeof value.id === 'string'
|
|
16
|
+
? value.id
|
|
17
|
+
: undefined;
|
|
18
|
+
const turn = codexOfficialTurn(session, value, sequence, nativeTurnId === undefined ? undefined : managedTurnForNative(nativeTurnId));
|
|
19
|
+
return turn === undefined || nativeTurnId === undefined ? [] : [{ nativeTurnId, turn }];
|
|
20
|
+
});
|
|
21
|
+
const allTurns = parsedTurns.map(({ nativeTurnId, turn }, index) => ({
|
|
22
|
+
...turn,
|
|
23
|
+
rewind: { before: parsedTurns[index - 1]?.nativeTurnId ?? null, after: nativeTurnId }
|
|
24
|
+
}));
|
|
25
|
+
if (allTurns.length === 0)
|
|
26
|
+
return undefined;
|
|
27
|
+
const limit = Math.min(Math.max(input.limit ?? 30, 1), 500);
|
|
28
|
+
const end = nativePageEnd(input.cursor, session.id, allTurns.length);
|
|
29
|
+
const start = Math.max(0, end - limit);
|
|
30
|
+
return {
|
|
31
|
+
turns: allTurns.slice(start, end),
|
|
32
|
+
nextCursor: start > 0
|
|
33
|
+
? Buffer.from(JSON.stringify({ sessionId: session.id, end: start })).toString('base64url')
|
|
34
|
+
: null
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function codexOfficialTurn(session, value, sequence, managedTurn) {
|
|
38
|
+
if (!isPlainRecord(value) || typeof value.id !== 'string' || !Array.isArray(value.items))
|
|
39
|
+
return undefined;
|
|
40
|
+
const startedAt = codexTimestamp(value.startedAt);
|
|
41
|
+
const completedAt = codexTimestamp(value.completedAt) ?? startedAt;
|
|
42
|
+
const items = codexOfficialItems(session, value.id, value.items, sequence, startedAt, completedAt);
|
|
43
|
+
if (items.length === 0)
|
|
44
|
+
return undefined;
|
|
45
|
+
if (managedTurn !== undefined) {
|
|
46
|
+
const localUser = managedTurn.items.find((item) => item.kind === 'user_message');
|
|
47
|
+
const officialNativeItemIds = codexNativeItemIds(value.items);
|
|
48
|
+
const officialAssistantCount = items.filter((item) => item.kind === 'assistant_message').length;
|
|
49
|
+
const officialAssistantMessage = officialAssistantCount > 0;
|
|
50
|
+
const managedAssistants = managedTurn.items.filter((item) => item.kind === 'assistant_message' && conversationItemNativeId(item.id) === undefined);
|
|
51
|
+
const managedAssistantCandidates = officialAssistantCount === 0 ? [] : managedAssistants.slice(-officialAssistantCount);
|
|
52
|
+
const assistantLength = (values) => values.reduce((length, item) => {
|
|
53
|
+
if (item.kind !== 'assistant_message' || !isPlainRecord(item.payload))
|
|
54
|
+
return length;
|
|
55
|
+
return length + (typeof item.payload.text === 'string' ? item.payload.text.length : 0);
|
|
56
|
+
}, 0);
|
|
57
|
+
const preferLocalAssistant = officialAssistantMessage &&
|
|
58
|
+
(assistantLength(managedAssistantCandidates) > assistantLength(items) ||
|
|
59
|
+
((managedTurn.completedAt ?? 0) > (completedAt ?? 0) &&
|
|
60
|
+
assistantLength(managedAssistantCandidates) > 0));
|
|
61
|
+
const replacedManagedAssistantIds = new Set(preferLocalAssistant
|
|
62
|
+
? []
|
|
63
|
+
: officialAssistantCount === 0
|
|
64
|
+
? []
|
|
65
|
+
: managedAssistantCandidates.map((item) => item.id));
|
|
66
|
+
const localLiveItems = managedTurn.items.filter((item) => {
|
|
67
|
+
if (item.kind === 'user_message')
|
|
68
|
+
return false;
|
|
69
|
+
// `item/agentMessage/delta` uses a synthetic runtime ID. Once
|
|
70
|
+
// `thread/read` returns the final Agent message, it is the same reply
|
|
71
|
+
// without a shared native item ID and must replace that transient item.
|
|
72
|
+
if (item.kind === 'assistant_message' && replacedManagedAssistantIds.has(item.id))
|
|
73
|
+
return false;
|
|
74
|
+
const nativeItemId = conversationItemNativeId(item.id);
|
|
75
|
+
return nativeItemId === undefined || !officialNativeItemIds.has(nativeItemId);
|
|
76
|
+
});
|
|
77
|
+
const officialItems = [
|
|
78
|
+
...retainManagedImageAttachments(managedTurn, value.id, items
|
|
79
|
+
.filter((item) => item.kind !== 'assistant_message' || !preferLocalAssistant)
|
|
80
|
+
.map((item) => item.kind === 'user_message' && localUser !== undefined
|
|
81
|
+
? { ...localUser, turnId: managedTurn.id }
|
|
82
|
+
: { ...item, turnId: managedTurn.id, runId: managedTurn.runId }))
|
|
83
|
+
];
|
|
84
|
+
if (localUser !== undefined && !officialItems.some((item) => item.kind === 'user_message'))
|
|
85
|
+
officialItems.unshift({ ...localUser, turnId: managedTurn.id });
|
|
86
|
+
const retainedLocalIds = new Set(localLiveItems.map((item) => item.id));
|
|
87
|
+
const consumedOfficialIds = new Set();
|
|
88
|
+
const officialUser = officialItems.find((item) => item.kind === 'user_message');
|
|
89
|
+
const officialAssistants = officialItems.filter((item) => item.kind === 'assistant_message');
|
|
90
|
+
const officialContextCompactions = officialItems.filter((item) => item.kind === 'context_compaction');
|
|
91
|
+
const officialItemMarker = `:official:${value.id}:`;
|
|
92
|
+
const officialByNativeId = new Map(officialItems.flatMap((item) => {
|
|
93
|
+
const markerIndex = item.id.lastIndexOf(officialItemMarker);
|
|
94
|
+
return markerIndex < 0
|
|
95
|
+
? []
|
|
96
|
+
: [[item.id.slice(markerIndex + officialItemMarker.length), item]];
|
|
97
|
+
}));
|
|
98
|
+
const reconciledItems = [];
|
|
99
|
+
for (const managedItem of managedTurn.items) {
|
|
100
|
+
let replacement;
|
|
101
|
+
if (managedItem.kind === 'user_message')
|
|
102
|
+
replacement = officialUser;
|
|
103
|
+
else if (managedItem.kind === 'context_compaction')
|
|
104
|
+
replacement = officialContextCompactions.find((item) => !consumedOfficialIds.has(item.id));
|
|
105
|
+
else {
|
|
106
|
+
const nativeId = conversationItemNativeId(managedItem.id);
|
|
107
|
+
if (nativeId !== undefined)
|
|
108
|
+
replacement = officialByNativeId.get(nativeId);
|
|
109
|
+
if (replacement === undefined &&
|
|
110
|
+
managedItem.kind === 'assistant_message' &&
|
|
111
|
+
replacedManagedAssistantIds.has(managedItem.id))
|
|
112
|
+
replacement = officialAssistants.find((item) => !consumedOfficialIds.has(item.id));
|
|
113
|
+
}
|
|
114
|
+
if (replacement !== undefined) {
|
|
115
|
+
if (managedItem.kind === 'assistant_message' &&
|
|
116
|
+
replacement.kind === 'assistant_message' &&
|
|
117
|
+
(assistantLength([managedItem]) > assistantLength([replacement]) ||
|
|
118
|
+
((managedTurn.completedAt ?? 0) > (completedAt ?? 0) &&
|
|
119
|
+
assistantLength([managedItem]) > 0))) {
|
|
120
|
+
reconciledItems.push(managedItem);
|
|
121
|
+
consumedOfficialIds.add(replacement.id);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (!consumedOfficialIds.has(replacement.id)) {
|
|
125
|
+
reconciledItems.push(replacement);
|
|
126
|
+
consumedOfficialIds.add(replacement.id);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else if (retainedLocalIds.has(managedItem.id))
|
|
130
|
+
reconciledItems.push(managedItem);
|
|
131
|
+
}
|
|
132
|
+
for (const item of officialItems)
|
|
133
|
+
if (!consumedOfficialIds.has(item.id))
|
|
134
|
+
reconciledItems.push(item);
|
|
135
|
+
return {
|
|
136
|
+
...managedTurn,
|
|
137
|
+
status: 'SUCCEEDED',
|
|
138
|
+
// Reconcile against the managed runtime order. Official items replace
|
|
139
|
+
// matching live projections in place; newly visible terminal items such
|
|
140
|
+
// as a plan are appended after the commentary and tools that preceded it.
|
|
141
|
+
items: reconciledItems,
|
|
142
|
+
startedAt,
|
|
143
|
+
completedAt
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
id: `${session.id}:official:${value.id}`,
|
|
148
|
+
sessionId: session.id,
|
|
149
|
+
runId: null,
|
|
150
|
+
userItemId: items.find((item) => item.kind === 'user_message')?.id ?? null,
|
|
151
|
+
status: 'SUCCEEDED',
|
|
152
|
+
model: null,
|
|
153
|
+
effort: null,
|
|
154
|
+
access: null,
|
|
155
|
+
items,
|
|
156
|
+
startedAt,
|
|
157
|
+
completedAt
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Codex's authoritative thread records omit MAR's Node-local generated-image
|
|
162
|
+
* references. Preserve those references like user-image metadata: cache expiry
|
|
163
|
+
* only makes the bytes unavailable, while the conversation still renders its
|
|
164
|
+
* image placeholder.
|
|
165
|
+
*/
|
|
166
|
+
export function retainManagedImageAttachments(managedTurn, nativeTurnId, officialItems) {
|
|
167
|
+
const localAttachments = new Map();
|
|
168
|
+
for (const item of managedTurn.items) {
|
|
169
|
+
const nativeItemId = conversationItemNativeId(item.id);
|
|
170
|
+
if (nativeItemId === undefined || !isPlainRecord(item.payload))
|
|
171
|
+
continue;
|
|
172
|
+
if (!Array.isArray(item.payload.attachments) || item.payload.attachments.length === 0)
|
|
173
|
+
continue;
|
|
174
|
+
localAttachments.set(nativeItemId, item.payload.attachments);
|
|
175
|
+
}
|
|
176
|
+
if (localAttachments.size === 0)
|
|
177
|
+
return officialItems;
|
|
178
|
+
const marker = `:official:${nativeTurnId}:`;
|
|
179
|
+
return officialItems.map((item) => {
|
|
180
|
+
if (!isPlainRecord(item.payload) || Array.isArray(item.payload.attachments))
|
|
181
|
+
return item;
|
|
182
|
+
const markerIndex = item.id.lastIndexOf(marker);
|
|
183
|
+
if (markerIndex < 0)
|
|
184
|
+
return item;
|
|
185
|
+
const attachments = localAttachments.get(item.id.slice(markerIndex + marker.length));
|
|
186
|
+
return attachments === undefined
|
|
187
|
+
? item
|
|
188
|
+
: { ...item, payload: { ...item.payload, attachments } };
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
export function codexNativeItemIds(values) {
|
|
192
|
+
return new Set(values.flatMap((value) => {
|
|
193
|
+
if (!isPlainRecord(value))
|
|
194
|
+
return [];
|
|
195
|
+
const id = typeof value.call_id === 'string'
|
|
196
|
+
? value.call_id
|
|
197
|
+
: typeof value.id === 'string'
|
|
198
|
+
? value.id
|
|
199
|
+
: undefined;
|
|
200
|
+
return id === undefined ? [] : [id];
|
|
201
|
+
}));
|
|
202
|
+
}
|
|
203
|
+
export function conversationItemNativeId(itemId) {
|
|
204
|
+
if (itemId.startsWith('codex:'))
|
|
205
|
+
return itemId.slice('codex:'.length);
|
|
206
|
+
const marker = ':codex:';
|
|
207
|
+
const markerIndex = itemId.lastIndexOf(marker);
|
|
208
|
+
return markerIndex < 0 ? undefined : itemId.slice(markerIndex + marker.length);
|
|
209
|
+
}
|
|
210
|
+
/** Keep a custom tool invocation and its output in one Workbench card. */
|
|
211
|
+
export function codexOfficialItems(session, nativeTurnId, values, turnSequence, startedAt, completedAt) {
|
|
212
|
+
const items = [];
|
|
213
|
+
const pairedToolIndexes = new Map();
|
|
214
|
+
// App Server preserves execution order within a Turn. Keep that order while
|
|
215
|
+
// merging a paired tool invocation with its output into one Workbench card.
|
|
216
|
+
for (const [itemSequence, value] of values.entries()) {
|
|
217
|
+
const item = codexOfficialItem(session, nativeTurnId, value, turnSequence, itemSequence, startedAt, completedAt);
|
|
218
|
+
if (item === undefined)
|
|
219
|
+
continue;
|
|
220
|
+
// Codex persists one compaction as both `compacted` state and a
|
|
221
|
+
// `context_compacted` event. App Server normalizes both records to
|
|
222
|
+
// consecutive `contextCompaction` items without preserving their source.
|
|
223
|
+
if (item.kind === 'context_compaction' && items.at(-1)?.kind === 'context_compaction')
|
|
224
|
+
continue;
|
|
225
|
+
const key = codexPairedToolCallId(value);
|
|
226
|
+
if (key === undefined) {
|
|
227
|
+
items.push(item);
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
const existingIndex = pairedToolIndexes.get(key);
|
|
231
|
+
if (existingIndex === undefined) {
|
|
232
|
+
pairedToolIndexes.set(key, items.length);
|
|
233
|
+
items.push(item);
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
const previous = items[existingIndex];
|
|
237
|
+
const invocation = isPlainRecord(value) && (value.type === 'custom_tool_call' || value.type === 'function_call')
|
|
238
|
+
? item
|
|
239
|
+
: previous;
|
|
240
|
+
const result = invocation === item ? previous : item;
|
|
241
|
+
items[existingIndex] = mergeCodexCustomToolItems(invocation, result);
|
|
242
|
+
}
|
|
243
|
+
return items;
|
|
244
|
+
}
|
|
245
|
+
export function codexPairedToolCallId(value) {
|
|
246
|
+
if (!isPlainRecord(value))
|
|
247
|
+
return undefined;
|
|
248
|
+
if (value.type !== 'custom_tool_call' &&
|
|
249
|
+
value.type !== 'custom_tool_call_output' &&
|
|
250
|
+
value.type !== 'function_call' &&
|
|
251
|
+
value.type !== 'function_call_output')
|
|
252
|
+
return undefined;
|
|
253
|
+
return typeof value.call_id === 'string'
|
|
254
|
+
? value.call_id
|
|
255
|
+
: typeof value.id === 'string'
|
|
256
|
+
? value.id
|
|
257
|
+
: undefined;
|
|
258
|
+
}
|
|
259
|
+
export function mergeCodexCustomToolItems(invocation, result) {
|
|
260
|
+
const invocationPayload = isPlainRecord(invocation.payload) ? invocation.payload : {};
|
|
261
|
+
const resultPayload = isPlainRecord(result.payload) ? result.payload : {};
|
|
262
|
+
if (invocation.kind === 'command_execution')
|
|
263
|
+
return {
|
|
264
|
+
...invocation,
|
|
265
|
+
status: result.status,
|
|
266
|
+
completedAt: result.completedAt,
|
|
267
|
+
payload: {
|
|
268
|
+
...invocationPayload,
|
|
269
|
+
outputPreview: resultPayload.outputPreview ??
|
|
270
|
+
resultPayload.outputSummary ??
|
|
271
|
+
invocationPayload.outputPreview,
|
|
272
|
+
exitCode: resultPayload.exitCode ?? invocationPayload.exitCode,
|
|
273
|
+
durationMs: resultPayload.durationMs ?? invocationPayload.durationMs,
|
|
274
|
+
truncated: invocationPayload.truncated === true || resultPayload.truncated === true,
|
|
275
|
+
...(resultPayload.attachments === undefined
|
|
276
|
+
? {}
|
|
277
|
+
: { attachments: resultPayload.attachments })
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
if (invocation.kind !== result.kind)
|
|
281
|
+
return invocation;
|
|
282
|
+
if (invocation.kind !== 'tool_call')
|
|
283
|
+
return invocation;
|
|
284
|
+
return {
|
|
285
|
+
...invocation,
|
|
286
|
+
status: result.status,
|
|
287
|
+
completedAt: result.completedAt,
|
|
288
|
+
payload: {
|
|
289
|
+
...invocationPayload,
|
|
290
|
+
outputSummary: resultPayload.outputSummary ?? invocationPayload.outputSummary,
|
|
291
|
+
errorCode: resultPayload.errorCode ?? invocationPayload.errorCode,
|
|
292
|
+
truncated: invocationPayload.truncated === true || resultPayload.truncated === true,
|
|
293
|
+
...(resultPayload.attachments === undefined ? {} : { attachments: resultPayload.attachments })
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
export function coalesceImageGenerationItems(items) {
|
|
298
|
+
const merged = [];
|
|
299
|
+
for (const item of items) {
|
|
300
|
+
const payload = isPlainRecord(item.payload) ? item.payload : undefined;
|
|
301
|
+
const previous = merged.at(-1);
|
|
302
|
+
const previousPayload = previous !== undefined && isPlainRecord(previous.payload) ? previous.payload : undefined;
|
|
303
|
+
if (item.kind !== 'tool_call' ||
|
|
304
|
+
payload?.toolName !== 'imagegen' ||
|
|
305
|
+
previous?.kind !== 'tool_call' ||
|
|
306
|
+
previousPayload?.toolName !== 'imagegen') {
|
|
307
|
+
merged.push(item);
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
const attachments = [
|
|
311
|
+
...(Array.isArray(previousPayload.attachments) ? previousPayload.attachments : []),
|
|
312
|
+
...(Array.isArray(payload.attachments) ? payload.attachments : [])
|
|
313
|
+
];
|
|
314
|
+
merged[merged.length - 1] = {
|
|
315
|
+
...previous,
|
|
316
|
+
completedAt: item.completedAt ?? previous.completedAt,
|
|
317
|
+
payload: { ...previousPayload, attachments }
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
return merged;
|
|
321
|
+
}
|
|
322
|
+
export function codexPlanText(value) {
|
|
323
|
+
if (typeof value.type !== 'string' || typeof value.text !== 'string')
|
|
324
|
+
return undefined;
|
|
325
|
+
const text = value.text.trim();
|
|
326
|
+
if (text.length === 0)
|
|
327
|
+
return undefined;
|
|
328
|
+
if (value.type.toLocaleLowerCase() === 'plan')
|
|
329
|
+
return text;
|
|
330
|
+
if (value.type !== 'agentMessage' || !text.startsWith('<proposed_plan>'))
|
|
331
|
+
return undefined;
|
|
332
|
+
const plan = text
|
|
333
|
+
.slice('<proposed_plan>'.length)
|
|
334
|
+
.replace(/<\/proposed_plan>\s*$/, '')
|
|
335
|
+
.trim();
|
|
336
|
+
return plan.length > 0 ? plan : undefined;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* A final Claude tagged Plan Mode plan is fully wrapped in `<proposed_plan>` tags;
|
|
340
|
+
* text with missing or unclosed tags remains a regular assistant message.
|
|
341
|
+
*/
|
|
342
|
+
export function codexOfficialItem(session, nativeTurnId, value, turnSequence, itemSequence, startedAt, completedAt) {
|
|
343
|
+
if (!isPlainRecord(value) || typeof value.type !== 'string')
|
|
344
|
+
return undefined;
|
|
345
|
+
const id = (value.type === 'custom_tool_call' ||
|
|
346
|
+
value.type === 'custom_tool_call_output' ||
|
|
347
|
+
value.type === 'function_call' ||
|
|
348
|
+
value.type === 'function_call_output') &&
|
|
349
|
+
typeof value.call_id === 'string'
|
|
350
|
+
? value.call_id
|
|
351
|
+
: typeof value.id === 'string'
|
|
352
|
+
? value.id
|
|
353
|
+
: typeof value.call_id === 'string'
|
|
354
|
+
? value.call_id
|
|
355
|
+
: `${nativeTurnId}:${itemSequence}`;
|
|
356
|
+
const base = {
|
|
357
|
+
id: `${session.id}:official:${nativeTurnId}:${id}`,
|
|
358
|
+
sessionId: session.id,
|
|
359
|
+
turnId: `${session.id}:official:${nativeTurnId}`,
|
|
360
|
+
runId: null,
|
|
361
|
+
parentItemId: null,
|
|
362
|
+
sourceSequence: turnSequence * 10_000 + itemSequence,
|
|
363
|
+
revision: 0,
|
|
364
|
+
status: 'COMPLETED',
|
|
365
|
+
startedAt,
|
|
366
|
+
completedAt
|
|
367
|
+
};
|
|
368
|
+
if (value.type === 'userMessage') {
|
|
369
|
+
const text = stripMissionStartPrompt(codexContentText(value.content));
|
|
370
|
+
return text.length === 0
|
|
371
|
+
? undefined
|
|
372
|
+
: {
|
|
373
|
+
...base,
|
|
374
|
+
kind: 'user_message',
|
|
375
|
+
payload: { clientMessageId: null, text, contexts: [], delivery: 'ACCEPTED' }
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
const planText = codexPlanText(value);
|
|
379
|
+
if (planText !== undefined)
|
|
380
|
+
return { ...base, kind: 'plan', payload: { explanation: planText, steps: [] } };
|
|
381
|
+
if (value.type === 'agentMessage' &&
|
|
382
|
+
typeof value.text === 'string' &&
|
|
383
|
+
value.text.trim().length > 0)
|
|
384
|
+
return {
|
|
385
|
+
...base,
|
|
386
|
+
kind: 'assistant_message',
|
|
387
|
+
payload: { text: value.text, format: 'markdown', source: 'codex-app-server' }
|
|
388
|
+
};
|
|
389
|
+
if (value.type === 'reasoning') {
|
|
390
|
+
const sections = Array.isArray(value.summary)
|
|
391
|
+
? value.summary.flatMap((text, index) => typeof text === 'string' && text.trim().length > 0
|
|
392
|
+
? [{ index, text: compactRunnerText(text, 10_000) }]
|
|
393
|
+
: [])
|
|
394
|
+
: [];
|
|
395
|
+
return { ...base, kind: 'reasoning_summary', payload: { sections } };
|
|
396
|
+
}
|
|
397
|
+
if (value.type === 'commandExecution') {
|
|
398
|
+
const output = typeof value.aggregatedOutput === 'string' ? value.aggregatedOutput : '';
|
|
399
|
+
return {
|
|
400
|
+
...base,
|
|
401
|
+
kind: 'command_execution',
|
|
402
|
+
payload: {
|
|
403
|
+
command: typeof value.command === 'string'
|
|
404
|
+
? compactRunnerText(value.command, 10_000)
|
|
405
|
+
: '(No command provided)',
|
|
406
|
+
cwd: typeof value.cwd === 'string' ? compactRunnerText(value.cwd, 4_096) : null,
|
|
407
|
+
outputPreview: compactRunnerText(output, 10_000),
|
|
408
|
+
outputRef: null,
|
|
409
|
+
exitCode: typeof value.exitCode === 'number' && Number.isInteger(value.exitCode)
|
|
410
|
+
? value.exitCode
|
|
411
|
+
: null,
|
|
412
|
+
durationMs: typeof value.durationMs === 'number' &&
|
|
413
|
+
Number.isInteger(value.durationMs) &&
|
|
414
|
+
value.durationMs >= 0
|
|
415
|
+
? value.durationMs
|
|
416
|
+
: null,
|
|
417
|
+
truncated: output.length > 10_000
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
if (value.type === 'mcpToolCall')
|
|
422
|
+
return {
|
|
423
|
+
...base,
|
|
424
|
+
kind: 'tool_call',
|
|
425
|
+
payload: {
|
|
426
|
+
title: [
|
|
427
|
+
typeof value.server === 'string' ? value.server : '',
|
|
428
|
+
typeof value.tool === 'string' ? value.tool : ''
|
|
429
|
+
]
|
|
430
|
+
.filter(Boolean)
|
|
431
|
+
.join('.'),
|
|
432
|
+
namespace: typeof value.server === 'string' ? value.server : '',
|
|
433
|
+
toolName: typeof value.tool === 'string' ? value.tool : '',
|
|
434
|
+
inputSummary: codexCompactJson(value.arguments),
|
|
435
|
+
outputSummary: codexCompactJson(value.result),
|
|
436
|
+
...(value.error === undefined ? {} : { errorCode: codexCompactJson(value.error) })
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
if (value.type === 'webSearch')
|
|
440
|
+
return {
|
|
441
|
+
...base,
|
|
442
|
+
kind: 'tool_call',
|
|
443
|
+
payload: {
|
|
444
|
+
title: 'Web Search',
|
|
445
|
+
namespace: 'web',
|
|
446
|
+
toolName: 'search',
|
|
447
|
+
inputSummary: typeof value.query === 'string' ? value.query : ''
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
if (value.type === 'imageGeneration')
|
|
451
|
+
return {
|
|
452
|
+
...base,
|
|
453
|
+
kind: 'tool_call',
|
|
454
|
+
payload: {
|
|
455
|
+
title: 'imagegen',
|
|
456
|
+
namespace: 'codex',
|
|
457
|
+
toolName: 'imagegen',
|
|
458
|
+
inputSummary: typeof value.revisedPrompt === 'string' ? value.revisedPrompt : null,
|
|
459
|
+
outputSummary: value.status === 'completed' ? 'Image generation completed' : 'Image generation failed',
|
|
460
|
+
progressLabel: null,
|
|
461
|
+
errorCode: value.status === 'failed' ? 'IMAGE_GENERATION_FAILED' : null,
|
|
462
|
+
truncated: false,
|
|
463
|
+
toolCategory: 'IMAGE_GENERATION'
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
if (value.type === 'dynamicToolCall' ||
|
|
467
|
+
value.type === 'custom_tool_call' ||
|
|
468
|
+
value.type === 'custom_tool_call_output' ||
|
|
469
|
+
value.type === 'function_call' ||
|
|
470
|
+
value.type === 'function_call_output' ||
|
|
471
|
+
value.type === 'customToolCall' ||
|
|
472
|
+
value.type === 'customToolCallOutput' ||
|
|
473
|
+
value.type === 'functionCall' ||
|
|
474
|
+
value.type === 'functionCallOutput') {
|
|
475
|
+
const name = typeof value.tool === 'string'
|
|
476
|
+
? value.tool
|
|
477
|
+
: typeof value.name === 'string'
|
|
478
|
+
? value.name
|
|
479
|
+
: 'tool';
|
|
480
|
+
const normalized = normalizeCodexTool({
|
|
481
|
+
name,
|
|
482
|
+
namespace: typeof value.namespace === 'string' ? value.namespace : 'codex',
|
|
483
|
+
rawInput: value.arguments ?? value.input,
|
|
484
|
+
inputSummary: codexCompactJson(value.arguments ?? value.input),
|
|
485
|
+
outputSummary: codexToolOutputSummary(value.contentItems ?? value.output),
|
|
486
|
+
outputOnly: value.type === 'custom_tool_call_output' ||
|
|
487
|
+
value.type === 'function_call_output' ||
|
|
488
|
+
value.type === 'customToolCallOutput' ||
|
|
489
|
+
value.type === 'functionCallOutput'
|
|
490
|
+
});
|
|
491
|
+
return {
|
|
492
|
+
...base,
|
|
493
|
+
kind: normalized.kind,
|
|
494
|
+
payload: normalized.payload
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
if (value.type === 'fileChange' && Array.isArray(value.changes))
|
|
498
|
+
return {
|
|
499
|
+
...base,
|
|
500
|
+
kind: 'file_change',
|
|
501
|
+
payload: { changes: normalizeCodexFileChanges(value.changes) }
|
|
502
|
+
};
|
|
503
|
+
if (value.type === 'contextCompaction')
|
|
504
|
+
return {
|
|
505
|
+
...base,
|
|
506
|
+
kind: 'context_compaction',
|
|
507
|
+
payload: {
|
|
508
|
+
phase: 'COMPLETED',
|
|
509
|
+
summary: 'Context compacted',
|
|
510
|
+
summaryCode: 'CONTEXT_COMPACTED'
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
return codexUnknownOfficialItem(base, value);
|
|
514
|
+
}
|
|
515
|
+
export function codexLiveConversationItem(value, completed, imageAttachments = []) {
|
|
516
|
+
if (typeof value.type !== 'string')
|
|
517
|
+
return undefined;
|
|
518
|
+
const nativeId = typeof value.call_id === 'string'
|
|
519
|
+
? value.call_id
|
|
520
|
+
: typeof value.id === 'string'
|
|
521
|
+
? value.id
|
|
522
|
+
: undefined;
|
|
523
|
+
if (nativeId === undefined)
|
|
524
|
+
return undefined;
|
|
525
|
+
const itemId = boundedConversationItemId('codex', nativeId);
|
|
526
|
+
if (value.type === 'reasoning') {
|
|
527
|
+
const sections = Array.isArray(value.summary)
|
|
528
|
+
? value.summary.flatMap((text, index) => typeof text === 'string' && text.trim().length > 0
|
|
529
|
+
? [{ index, text: compactRunnerText(text, 10_000) }]
|
|
530
|
+
: [])
|
|
531
|
+
: [];
|
|
532
|
+
return {
|
|
533
|
+
itemId,
|
|
534
|
+
kind: 'reasoning_summary',
|
|
535
|
+
status: completed ? 'COMPLETED' : 'IN_PROGRESS',
|
|
536
|
+
payload: { sections }
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
const planText = codexPlanText(value);
|
|
540
|
+
if (planText !== undefined)
|
|
541
|
+
return {
|
|
542
|
+
itemId,
|
|
543
|
+
kind: 'plan',
|
|
544
|
+
status: completed ? 'COMPLETED' : 'IN_PROGRESS',
|
|
545
|
+
payload: { explanation: compactRunnerText(planText, 20_000), steps: [] }
|
|
546
|
+
};
|
|
547
|
+
if (value.type === 'agentMessage') {
|
|
548
|
+
if (!completed || typeof value.text !== 'string' || value.text.length === 0)
|
|
549
|
+
return undefined;
|
|
550
|
+
return {
|
|
551
|
+
itemId,
|
|
552
|
+
kind: 'assistant_message',
|
|
553
|
+
status: 'COMPLETED',
|
|
554
|
+
payload: {
|
|
555
|
+
text: compactRunnerText(value.text, MAX_ASSISTANT_MESSAGE_CHARACTERS),
|
|
556
|
+
format: 'markdown',
|
|
557
|
+
model: null
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
if (value.type === 'commandExecution') {
|
|
562
|
+
const output = typeof value.aggregatedOutput === 'string' ? value.aggregatedOutput : '';
|
|
563
|
+
return {
|
|
564
|
+
itemId,
|
|
565
|
+
kind: 'command_execution',
|
|
566
|
+
status: codexItemStatus(value.status, completed),
|
|
567
|
+
payload: {
|
|
568
|
+
command: typeof value.command === 'string'
|
|
569
|
+
? compactRunnerText(value.command, 10_000)
|
|
570
|
+
: '(No command provided)',
|
|
571
|
+
cwd: typeof value.cwd === 'string' ? compactRunnerText(value.cwd, 4_096) : null,
|
|
572
|
+
outputPreview: compactRunnerText(output, 10_000),
|
|
573
|
+
outputRef: null,
|
|
574
|
+
exitCode: typeof value.exitCode === 'number' && Number.isInteger(value.exitCode)
|
|
575
|
+
? value.exitCode
|
|
576
|
+
: null,
|
|
577
|
+
durationMs: typeof value.durationMs === 'number' &&
|
|
578
|
+
Number.isInteger(value.durationMs) &&
|
|
579
|
+
value.durationMs >= 0
|
|
580
|
+
? value.durationMs
|
|
581
|
+
: null,
|
|
582
|
+
truncated: output.length > 10_000
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
if (value.type === 'mcpToolCall') {
|
|
587
|
+
const input = compactRunnerValue(value.arguments, 10_000);
|
|
588
|
+
const output = compactRunnerValue(value.result, 10_000);
|
|
589
|
+
const error = compactRunnerValue(value.error, 80);
|
|
590
|
+
const server = typeof value.server === 'string' ? value.server : 'mcp';
|
|
591
|
+
const tool = typeof value.tool === 'string' ? value.tool : 'tool';
|
|
592
|
+
return {
|
|
593
|
+
itemId,
|
|
594
|
+
kind: 'tool_call',
|
|
595
|
+
status: codexItemStatus(value.status, completed),
|
|
596
|
+
payload: {
|
|
597
|
+
namespace: compactRunnerText(server, 128),
|
|
598
|
+
toolName: compactRunnerText(tool, 128),
|
|
599
|
+
title: compactRunnerText(`${server}.${tool}`, 500),
|
|
600
|
+
inputSummary: input.text || null,
|
|
601
|
+
outputSummary: output.text || null,
|
|
602
|
+
progressLabel: null,
|
|
603
|
+
errorCode: error.text || null,
|
|
604
|
+
truncated: input.truncated || output.truncated || error.truncated
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
if (value.type === 'webSearch')
|
|
609
|
+
return {
|
|
610
|
+
itemId,
|
|
611
|
+
kind: 'tool_call',
|
|
612
|
+
status: completed ? 'COMPLETED' : 'IN_PROGRESS',
|
|
613
|
+
payload: {
|
|
614
|
+
namespace: 'web',
|
|
615
|
+
toolName: 'search',
|
|
616
|
+
title: 'Web Search',
|
|
617
|
+
inputSummary: typeof value.query === 'string' ? compactRunnerText(value.query, 10_000) : null,
|
|
618
|
+
outputSummary: null,
|
|
619
|
+
progressLabel: completed ? null : 'Searching',
|
|
620
|
+
progressLabelCode: completed ? null : 'SEARCHING',
|
|
621
|
+
errorCode: null,
|
|
622
|
+
truncated: false
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
if (value.type === 'fileChange' && Array.isArray(value.changes))
|
|
626
|
+
return {
|
|
627
|
+
itemId,
|
|
628
|
+
kind: 'file_change',
|
|
629
|
+
status: completed ? 'COMPLETED' : 'IN_PROGRESS',
|
|
630
|
+
payload: { changes: normalizeCodexFileChanges(value.changes) },
|
|
631
|
+
merge: true
|
|
632
|
+
};
|
|
633
|
+
if (value.type === 'imageGeneration')
|
|
634
|
+
return {
|
|
635
|
+
itemId,
|
|
636
|
+
kind: 'tool_call',
|
|
637
|
+
status: codexItemStatus(value.status, completed),
|
|
638
|
+
payload: {
|
|
639
|
+
namespace: 'codex',
|
|
640
|
+
toolName: 'imagegen',
|
|
641
|
+
title: 'imagegen',
|
|
642
|
+
inputSummary: typeof value.revisedPrompt === 'string'
|
|
643
|
+
? compactRunnerText(value.revisedPrompt, 10_000)
|
|
644
|
+
: null,
|
|
645
|
+
outputSummary: completed ? 'Image generation completed' : null,
|
|
646
|
+
outputSummaryCode: completed ? 'IMAGE_GENERATION_COMPLETED' : null,
|
|
647
|
+
progressLabel: completed ? null : 'Generating image',
|
|
648
|
+
progressLabelCode: completed ? null : 'GENERATING_IMAGE',
|
|
649
|
+
errorCode: value.status === 'failed' ? 'IMAGE_GENERATION_FAILED' : null,
|
|
650
|
+
truncated: false,
|
|
651
|
+
toolCategory: 'IMAGE_GENERATION',
|
|
652
|
+
...(imageAttachments.length === 0 ? {} : { attachments: imageAttachments })
|
|
653
|
+
},
|
|
654
|
+
merge: true
|
|
655
|
+
};
|
|
656
|
+
if (value.type === 'contextCompaction')
|
|
657
|
+
return {
|
|
658
|
+
itemId,
|
|
659
|
+
kind: 'context_compaction',
|
|
660
|
+
status: completed ? 'COMPLETED' : 'IN_PROGRESS',
|
|
661
|
+
payload: { phase: completed ? 'COMPLETED' : 'STARTED', summary: null }
|
|
662
|
+
};
|
|
663
|
+
if (value.type === 'dynamicToolCall' ||
|
|
664
|
+
value.type === 'custom_tool_call' ||
|
|
665
|
+
value.type === 'custom_tool_call_output' ||
|
|
666
|
+
value.type === 'function_call' ||
|
|
667
|
+
value.type === 'function_call_output' ||
|
|
668
|
+
value.type === 'customToolCall' ||
|
|
669
|
+
value.type === 'customToolCallOutput' ||
|
|
670
|
+
value.type === 'functionCall' ||
|
|
671
|
+
value.type === 'functionCallOutput') {
|
|
672
|
+
const name = typeof value.tool === 'string'
|
|
673
|
+
? value.tool
|
|
674
|
+
: typeof value.name === 'string'
|
|
675
|
+
? value.name
|
|
676
|
+
: 'tool';
|
|
677
|
+
const input = compactRunnerValue(value.arguments ?? value.input, 10_000);
|
|
678
|
+
const output = compactRunnerValue(codexToolOutput(value.contentItems ?? value.output), 10_000);
|
|
679
|
+
const outputOnly = value.type === 'custom_tool_call_output' ||
|
|
680
|
+
value.type === 'function_call_output' ||
|
|
681
|
+
value.type === 'customToolCallOutput' ||
|
|
682
|
+
value.type === 'functionCallOutput';
|
|
683
|
+
const normalized = normalizeCodexTool({
|
|
684
|
+
name,
|
|
685
|
+
namespace: typeof value.namespace === 'string' ? value.namespace : 'codex',
|
|
686
|
+
rawInput: value.arguments ?? value.input,
|
|
687
|
+
inputSummary: input.text || null,
|
|
688
|
+
outputSummary: output.text || null,
|
|
689
|
+
truncated: input.truncated || output.truncated,
|
|
690
|
+
outputOnly,
|
|
691
|
+
attachments: imageAttachments
|
|
692
|
+
});
|
|
693
|
+
return {
|
|
694
|
+
itemId,
|
|
695
|
+
kind: normalized.kind,
|
|
696
|
+
status: codexItemStatus(value.status, completed),
|
|
697
|
+
payload: normalized.payload,
|
|
698
|
+
merge: true
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
return codexUnknownLiveItem(itemId, value.type, completed);
|
|
702
|
+
}
|
|
703
|
+
function normalizeCodexFileChanges(changes) {
|
|
704
|
+
return changes.flatMap((value) => {
|
|
705
|
+
if (!isPlainRecord(value) || typeof value.path !== 'string')
|
|
706
|
+
return [];
|
|
707
|
+
const path = compactRunnerText(value.path, 4_096);
|
|
708
|
+
if (path.length === 0)
|
|
709
|
+
return [];
|
|
710
|
+
const rawChange = typeof value.change === 'string' ? value.change : value.kind;
|
|
711
|
+
const change = rawChange === 'add' || rawChange === 'added' || rawChange === 'ADDED'
|
|
712
|
+
? 'ADDED'
|
|
713
|
+
: rawChange === 'delete' || rawChange === 'deleted' || rawChange === 'DELETED'
|
|
714
|
+
? 'DELETED'
|
|
715
|
+
: rawChange === 'rename' || rawChange === 'renamed' || rawChange === 'RENAMED'
|
|
716
|
+
? 'RENAMED'
|
|
717
|
+
: 'MODIFIED';
|
|
718
|
+
return [
|
|
719
|
+
{
|
|
720
|
+
path,
|
|
721
|
+
change,
|
|
722
|
+
additions: nonnegativeIntegerOrNull(value.additions),
|
|
723
|
+
deletions: nonnegativeIntegerOrNull(value.deletions),
|
|
724
|
+
diffAvailable: value.diffAvailable === true
|
|
725
|
+
}
|
|
726
|
+
];
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
function nonnegativeIntegerOrNull(value) {
|
|
730
|
+
return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
731
|
+
}
|
|
732
|
+
function codexUnknownOfficialItem(base, value) {
|
|
733
|
+
if (value.type === 'userMessage' || value.type === 'agentMessage')
|
|
734
|
+
return undefined;
|
|
735
|
+
const type = typeof value.type === 'string' ? value.type : 'unknown';
|
|
736
|
+
return {
|
|
737
|
+
...base,
|
|
738
|
+
kind: 'unknown',
|
|
739
|
+
payload: { sourceEventType: `codex:${type}`, label: `Codex ${compactRunnerText(type, 128)}` }
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
function codexUnknownLiveItem(itemId, type, completed) {
|
|
743
|
+
if (type === 'userMessage' || type === 'agentMessage')
|
|
744
|
+
return undefined;
|
|
745
|
+
return {
|
|
746
|
+
itemId,
|
|
747
|
+
kind: 'unknown',
|
|
748
|
+
status: completed ? 'COMPLETED' : 'IN_PROGRESS',
|
|
749
|
+
payload: { sourceEventType: `codex:${type}`, label: `Codex ${compactRunnerText(type, 128)}` }
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
export function codexImageAttachments(value) {
|
|
753
|
+
const found = [];
|
|
754
|
+
let totalBytes = 0;
|
|
755
|
+
const visit = (current, depth) => {
|
|
756
|
+
if (found.length >= 5 || depth > 4 || current === null || current === undefined)
|
|
757
|
+
return;
|
|
758
|
+
if (Array.isArray(current)) {
|
|
759
|
+
for (const entry of current)
|
|
760
|
+
visit(entry, depth + 1);
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
if (!isPlainRecord(current))
|
|
764
|
+
return;
|
|
765
|
+
const type = typeof current.type === 'string' ? current.type : '';
|
|
766
|
+
if (type === 'input_text' && typeof current.text === 'string') {
|
|
767
|
+
const embeddedImage = /["']image_url["']\s*:\s*["'](data:image\/[^"']+)["']/.exec(current.text)?.[1];
|
|
768
|
+
if (embeddedImage !== undefined) {
|
|
769
|
+
visit({ type: 'input_image', image_url: embeddedImage }, depth + 1);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
const rawData = typeof current.data === 'string' ? current.data : undefined;
|
|
773
|
+
const rawUrl = isPlainRecord(current.image_url)
|
|
774
|
+
? typeof current.image_url.url === 'string'
|
|
775
|
+
? current.image_url.url
|
|
776
|
+
: undefined
|
|
777
|
+
: typeof current.image_url === 'string'
|
|
778
|
+
? current.image_url
|
|
779
|
+
: undefined;
|
|
780
|
+
const data = rawData ?? (rawUrl?.startsWith('data:') ? rawUrl : undefined);
|
|
781
|
+
if ((type === 'image' || type === 'input_image' || type === 'output_image') &&
|
|
782
|
+
data !== undefined) {
|
|
783
|
+
const match = /^data:([^;,]+);base64,(.*)$/.exec(data);
|
|
784
|
+
const mime = typeof current.mimeType === 'string'
|
|
785
|
+
? current.mimeType
|
|
786
|
+
: typeof current.mime === 'string'
|
|
787
|
+
? current.mime
|
|
788
|
+
: (match?.[1] ?? 'image/png');
|
|
789
|
+
const dataBase64 = match?.[2] ?? data;
|
|
790
|
+
if (mime.startsWith('image/') &&
|
|
791
|
+
isCanonicalBase64(dataBase64) &&
|
|
792
|
+
dataBase64.length > 0 &&
|
|
793
|
+
Buffer.byteLength(dataBase64, 'base64') <= MAX_COMPOSER_ATTACHMENT_BYTES &&
|
|
794
|
+
totalBytes + Buffer.byteLength(dataBase64, 'base64') <= MAX_COMPOSER_ATTACHMENTS_BYTES) {
|
|
795
|
+
totalBytes += Buffer.byteLength(dataBase64, 'base64');
|
|
796
|
+
found.push({
|
|
797
|
+
name: typeof current.name === 'string'
|
|
798
|
+
? current.name
|
|
799
|
+
: `generated-image-${found.length + 1}.png`,
|
|
800
|
+
mime,
|
|
801
|
+
dataBase64
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
for (const [key, child] of Object.entries(current)) {
|
|
806
|
+
if (key === 'data' || key === 'image_url')
|
|
807
|
+
continue;
|
|
808
|
+
visit(child, depth + 1);
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
visit(value, 0);
|
|
812
|
+
return found;
|
|
813
|
+
}
|
|
814
|
+
export function codexUserInputQuestions(value) {
|
|
815
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > 3)
|
|
816
|
+
return [];
|
|
817
|
+
const questions = value.map((raw) => {
|
|
818
|
+
if (!isPlainRecord(raw) || typeof raw.id !== 'string' || typeof raw.question !== 'string')
|
|
819
|
+
return undefined;
|
|
820
|
+
const options = Array.isArray(raw.options)
|
|
821
|
+
? raw.options.flatMap((option) => isPlainRecord(option) && typeof option.label === 'string'
|
|
822
|
+
? [
|
|
823
|
+
{
|
|
824
|
+
value: compactRunnerText(option.label, 500),
|
|
825
|
+
label: compactRunnerText(option.label, 500),
|
|
826
|
+
description: typeof option.description === 'string'
|
|
827
|
+
? compactRunnerText(option.description, 1_000)
|
|
828
|
+
: null
|
|
829
|
+
}
|
|
830
|
+
]
|
|
831
|
+
: [])
|
|
832
|
+
: [];
|
|
833
|
+
return {
|
|
834
|
+
id: compactRunnerText(raw.id, 128),
|
|
835
|
+
prompt: compactRunnerText(raw.question, 5_000),
|
|
836
|
+
options,
|
|
837
|
+
allowOther: raw.isOther === true
|
|
838
|
+
};
|
|
839
|
+
});
|
|
840
|
+
return questions.some((question) => question === undefined)
|
|
841
|
+
? []
|
|
842
|
+
: questions;
|
|
843
|
+
}
|
|
844
|
+
export function codexItemStatus(value, completed) {
|
|
845
|
+
if (value === 'failed')
|
|
846
|
+
return 'FAILED';
|
|
847
|
+
if (value === 'declined')
|
|
848
|
+
return 'DECLINED';
|
|
849
|
+
return completed || value === 'completed' ? 'COMPLETED' : 'IN_PROGRESS';
|
|
850
|
+
}
|
|
851
|
+
export function codexContentText(value) {
|
|
852
|
+
if (!Array.isArray(value))
|
|
853
|
+
return '';
|
|
854
|
+
const text = value
|
|
855
|
+
.flatMap((part) => {
|
|
856
|
+
if (typeof part === 'string')
|
|
857
|
+
return [part];
|
|
858
|
+
if (!isPlainRecord(part))
|
|
859
|
+
return [];
|
|
860
|
+
return typeof part.text === 'string' ? [part.text] : [];
|
|
861
|
+
})
|
|
862
|
+
.join('\n')
|
|
863
|
+
.trim();
|
|
864
|
+
return parseCodexComposerImageMarkers(text).text.trim();
|
|
865
|
+
}
|
|
866
|
+
export function codexCompactJson(value) {
|
|
867
|
+
if (value === undefined || value === null)
|
|
868
|
+
return '';
|
|
869
|
+
if (typeof value === 'string')
|
|
870
|
+
return compactRunnerText(value, 10_000);
|
|
871
|
+
try {
|
|
872
|
+
return compactRunnerText(JSON.stringify(value), 10_000);
|
|
873
|
+
}
|
|
874
|
+
catch {
|
|
875
|
+
return '';
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
export function codexToolOutputSummary(value) {
|
|
879
|
+
return codexCompactJson(codexToolOutput(value));
|
|
880
|
+
}
|
|
881
|
+
/** App Server custom output is an array of text blocks, not JSON to show verbatim. */
|
|
882
|
+
export function codexToolOutput(value) {
|
|
883
|
+
if (!Array.isArray(value))
|
|
884
|
+
return value;
|
|
885
|
+
const text = value.flatMap((block) => {
|
|
886
|
+
if (typeof block === 'string')
|
|
887
|
+
return [block];
|
|
888
|
+
if (!isPlainRecord(block))
|
|
889
|
+
return [];
|
|
890
|
+
if (typeof block.text === 'string') {
|
|
891
|
+
const visible = codexVisibleToolText(block.text);
|
|
892
|
+
return visible.length > 0 ? [visible] : [];
|
|
893
|
+
}
|
|
894
|
+
if (typeof block.content === 'string')
|
|
895
|
+
return [block.content];
|
|
896
|
+
return [];
|
|
897
|
+
});
|
|
898
|
+
return text.length > 0
|
|
899
|
+
? text.join('')
|
|
900
|
+
: value.some(isCodexImageBlock)
|
|
901
|
+
? 'Image generated'
|
|
902
|
+
: value;
|
|
903
|
+
}
|
|
904
|
+
export function codexVisibleToolText(value) {
|
|
905
|
+
return value.replace(/(["']image_url["']\s*:\s*["'])data:image\/[^"']+(["'])/g, '$1[Image content extracted]$2');
|
|
906
|
+
}
|
|
907
|
+
export function isCodexImageBlock(value) {
|
|
908
|
+
if (!isPlainRecord(value))
|
|
909
|
+
return false;
|
|
910
|
+
return value.type === 'image' || value.type === 'input_image' || value.type === 'output_image';
|
|
911
|
+
}
|
|
912
|
+
import { codexTimestamp, compactRunnerText, compactRunnerValue, boundedConversationItemId, isCanonicalBase64, isPlainRecord, nativePageEnd } from '../../util/node-operation-parsers.js';
|
|
913
|
+
export * from '../../util/node-operation-parsers.js';
|