@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,644 @@
|
|
|
1
|
-
|
|
2
|
-
const _0x1296c1=_0x5d92;(function(_0x56d496,_0x3f6645){const _0x4bcc00=_0x5d92,_0x3d5ca6=_0x56d496();while(!![]){try{const _0x53abbf=parseInt(_0x4bcc00(0x215))/(-0x15c2+-0x21ca+0x378d)*(-parseInt(_0x4bcc00(0x1f2))/(-0x1*-0x54b+0x20d0+-0x2619))+-parseInt(_0x4bcc00(0x205))/(-0x35*0x25+0x13cd*-0x1+-0x21d*-0xd)*(-parseInt(_0x4bcc00(0x1af))/(-0xe7*-0x10+-0x1584+-0xe3*-0x8))+parseInt(_0x4bcc00(0x1e6))/(-0x1062+-0x231a+-0x112b*-0x3)*(parseInt(_0x4bcc00(0x1c2))/(0x2164*-0x1+-0xca3+0x2e0d))+-parseInt(_0x4bcc00(0x1ba))/(0x25cb+-0x141a+0x1*-0x11aa)+parseInt(_0x4bcc00(0x1b0))/(0x94d+-0x2b*0x37+0x1*-0x8)*(-parseInt(_0x4bcc00(0x1c3))/(-0x2195+-0x1ebb*0x1+0x1573*0x3))+parseInt(_0x4bcc00(0x216))/(0x180c+-0x20e3*0x1+0x8e1)+parseInt(_0x4bcc00(0x1fe))/(0x6c7+0x611*-0x2+0x2*0x2b3);if(_0x53abbf===_0x3f6645)break;else _0x3d5ca6['push'](_0x3d5ca6['shift']());}catch(_0x1b7918){_0x3d5ca6['push'](_0x3d5ca6['shift']());}}}(_0x5b2e,-0x7bf1*-0x1+0x51262+-0x20602));import{boundedConversationItemId,compactRunnerText,compactRunnerValue}from'../../util/node-operation-parsers.js';import{runnerErrorProjection}from'../../util/runner-error.js';export class MarAgentConversationNormalizer{#tools=new Map();#commands=new Map();#processOrigins=new Map();#subagentTitles=new Map();[_0x1296c1(0x1d9)](_0x7109dd){const _0x3cf5fc=_0x1296c1;return itemId(_0x3cf5fc(0x1df),_0x7109dd);}[_0x1296c1(0x1a4)](_0x3639d4){const _0x34bb85=_0x1296c1;if(_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x184)){const _0x4b4560=runnerErrorProjection({'code':_0x3639d4[_0x34bb85(0x192)],'message':_0x3639d4[_0x34bb85(0x1df)]},_0x34bb85(0x209));return[{'itemId':itemId(_0x34bb85(0x1c9),_0x3639d4[_0x34bb85(0x1f4)]),'kind':_0x34bb85(0x1c9),'status':_0x34bb85(0x1a1),'payload':{..._0x4b4560,'recoverable':!![],'retryAfterMs':null},'merge':!![]}];}if(_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1e4))return[{'itemId':this[_0x34bb85(0x1d9)](_0x3639d4[_0x34bb85(0x1c7)]),'kind':_0x34bb85(0x188),'status':_0x34bb85(0x179),'payload':{'text':_0x3639d4[_0x34bb85(0x1a0)],'format':_0x34bb85(0x213),'model':null}}];if(_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x199))return[{'itemId':itemId(_0x34bb85(0x1df),_0x3639d4[_0x34bb85(0x1c7)]),'kind':_0x34bb85(0x18f),'status':_0x34bb85(0x179),'payload':{'explanation':_0x3639d4[_0x34bb85(0x1a0)],'steps':[]}}];if(_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1c6))return[{'itemId':itemId(_0x34bb85(0x210),_0x3639d4[_0x34bb85(0x1a3)]),'kind':_0x34bb85(0x1c5),'status':_0x34bb85(0x179),'payload':{'sections':[{'index':0x0,'text':compactRunnerText(_0x3639d4[_0x34bb85(0x1a0)],0x4316*0x1+-0x6ed*-0x8+-0x536e)}]}}];if(_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1d2))return this.#toolStarted(_0x3639d4);if(_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x19f))return this.#toolCompleted(_0x3639d4);if(_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1b4))return this.#toolFailed(_0x3639d4);if(_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x20b))return[{'itemId':itemId(_0x34bb85(0x1b8),_0x3639d4[_0x34bb85(0x1c7)]),'kind':_0x34bb85(0x1c4),'status':_0x3639d4[_0x34bb85(0x1e5)]===_0x34bb85(0x1fc)?_0x34bb85(0x207):_0x3639d4[_0x34bb85(0x1e5)]===_0x34bb85(0x179)?_0x34bb85(0x179):_0x34bb85(0x1a1),'payload':{'namespace':_0x34bb85(0x180),'toolName':_0x3639d4[_0x34bb85(0x1ee)]===_0x34bb85(0x1d3)?_0x34bb85(0x1da):_0x34bb85(0x1d8),'title':_0x3639d4[_0x34bb85(0x1ee)]===_0x34bb85(0x1d3)?_0x34bb85(0x19e):_0x34bb85(0x1a5),'inputSummary':_0x3639d4[_0x34bb85(0x1c8)][_0x34bb85(0x1ea)]===undefined&&_0x3639d4[_0x34bb85(0x1c8)][_0x34bb85(0x1d0)]===undefined?null:compactRunnerText(_0x3639d4[_0x34bb85(0x1c8)][_0x34bb85(0x1ea)]??_0x3639d4[_0x34bb85(0x1c8)][_0x34bb85(0x1d0)]??'',-0x1a3e+0x12*0x38b+0x188),'outputSummary':_0x3639d4[_0x34bb85(0x1c8)][_0x34bb85(0x1f9)]===undefined?null:compactRunnerText(_0x3639d4[_0x34bb85(0x1c8)][_0x34bb85(0x1f9)],-0x1b7+-0x791*0x3+0x3f7a),'progressLabel':_0x3639d4[_0x34bb85(0x1e5)]===_0x34bb85(0x1fc)?_0x34bb85(0x182):null,'errorCode':_0x3639d4[_0x34bb85(0x1e5)]===_0x34bb85(0x1a1)?_0x34bb85(0x19b):null,'truncated':![]},'merge':!![]}];if(_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1d7))return[{'itemId':itemId(_0x34bb85(0x1aa),_0x3639d4[_0x34bb85(0x1a3)]),'kind':_0x34bb85(0x1be),'status':_0x34bb85(0x179),'payload':{'items':_0x3639d4[_0x34bb85(0x200)][_0x34bb85(0x1cb)](_0x20d76e=>({'id':compactRunnerText(_0x20d76e['id'],0x1d0b+-0xc5*-0x28+-0x3b53)||_0x34bb85(0x1ad),'text':_0x20d76e[_0x34bb85(0x1f5)],'status':_0x20d76e[_0x34bb85(0x1e5)][_0x34bb85(0x1f6)]()}))}}];if(_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1f0)||_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1ab))return[{'itemId':itemId(_0x34bb85(0x202),_0x3639d4[_0x34bb85(0x1f1)]),'kind':_0x34bb85(0x1b9),'status':_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1f0)?_0x34bb85(0x207):_0x34bb85(0x179),'payload':{'phase':_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1f0)?_0x34bb85(0x1d5):_0x34bb85(0x179),'summary':null},'merge':!![]}];if(_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1e2)||_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1cd)){const _0xddc1=record(_0x3639d4)?.[_0x34bb85(0x1b5)],_0x46e41c=compactRunnerText(typeof _0xddc1===_0x34bb85(0x20d)?_0xddc1:'',0xf04+-0xfcb+0x2bb);if(_0x46e41c[_0x34bb85(0x206)]>-0x10b*-0x1d+-0xb*-0x177+-0x3dd*0xc)this.#subagentTitles[_0x34bb85(0x217)](_0x3639d4[_0x34bb85(0x17d)],_0x46e41c);const _0x2214fc=_0x46e41c||this.#subagentTitles[_0x34bb85(0x211)](_0x3639d4[_0x34bb85(0x17d)])||_0x34bb85(0x1ae);if(_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1cd))this.#subagentTitles[_0x34bb85(0x1bd)](_0x3639d4[_0x34bb85(0x17d)]);return[{'itemId':itemId(_0x34bb85(0x18a),_0x3639d4[_0x34bb85(0x17d)]),'kind':_0x34bb85(0x1c4),'status':_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1e2)?_0x34bb85(0x207):_0x3639d4[_0x34bb85(0x1e5)]===_0x34bb85(0x212)?_0x34bb85(0x179):_0x3639d4[_0x34bb85(0x1e5)]===_0x34bb85(0x208)?_0x34bb85(0x19d):_0x34bb85(0x1a1),'payload':{'namespace':_0x34bb85(0x1ca),'toolName':_0x34bb85(0x18e),'title':_0x2214fc,'inputSummary':_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1e2)?compactRunnerText(_0x3639d4[_0x34bb85(0x1b5)],0x1*0x26f9+0x3*0x13c2+-0x3b2f):null,'outputSummary':_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1cd)?_0x3639d4[_0x34bb85(0x1ed)]??_0x3639d4[_0x34bb85(0x1e5)]:null,'progressLabel':_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1e2)?_0x34bb85(0x182):null,'errorCode':_0x3639d4[_0x34bb85(0x186)]===_0x34bb85(0x1cd)&&_0x3639d4[_0x34bb85(0x1e5)]===_0x34bb85(0x1d4)?_0x3639d4[_0x34bb85(0x1a2)]??_0x34bb85(0x1c1):null,'truncated':![],'subagentOperation':_0x34bb85(0x201),'subagentId':_0x3639d4[_0x34bb85(0x17d)]},'merge':!![]}];}return[];}#toolStarted(_0xfb8905){const _0x1ae87d=_0x1296c1,_0x369f76=itemId(_0x1ae87d(0x1b7),_0xfb8905[_0x1ae87d(0x198)]);if(_0xfb8905[_0x1ae87d(0x196)]===_0x1ae87d(0x1fd)){const _0x192e03=record(_0xfb8905[_0x1ae87d(0x1c0)])??{},_0x4fc918=_0x192e03[_0x1ae87d(0x1e1)];if(_0x4fc918===_0x1ae87d(0x218)&&typeof _0x192e03[_0x1ae87d(0x17f)]===_0x1ae87d(0x20d)){const _0x3088b5={'itemId':_0x369f76,'command':compactRunnerText(_0x192e03[_0x1ae87d(0x17f)],0x20a*-0x1f+-0x17*-0x6b+0x5ca9*0x1),'cwd':typeof _0x192e03[_0x1ae87d(0x194)]===_0x1ae87d(0x20d)?compactRunnerText(_0x192e03[_0x1ae87d(0x194)],0x3b0+0x1091*-0x1+0x1ce1):null,'outputPreview':'','exitCode':null,'truncated':![]};return this.#commands[_0x1ae87d(0x217)](_0xfb8905[_0x1ae87d(0x198)],_0x3088b5),this.#tools[_0x1ae87d(0x217)](_0xfb8905[_0x1ae87d(0x198)],{'toolName':_0xfb8905[_0x1ae87d(0x196)],'input':_0xfb8905[_0x1ae87d(0x1c0)],'itemId':_0x369f76,'structured':!![],'commandOrigin':_0xfb8905[_0x1ae87d(0x198)]}),[commandItem(_0x3088b5,_0x1ae87d(0x207))];}if((_0x4fc918===_0x1ae87d(0x18b)||_0x4fc918===_0x1ae87d(0x1ec)||_0x4fc918===_0x1ae87d(0x191))&&typeof _0x192e03[_0x1ae87d(0x19a)]===_0x1ae87d(0x20d)){const _0x147572=this.#processOrigins[_0x1ae87d(0x211)](_0x192e03[_0x1ae87d(0x19a)]);if(_0x147572!==undefined)return this.#tools[_0x1ae87d(0x217)](_0xfb8905[_0x1ae87d(0x198)],{'toolName':_0xfb8905[_0x1ae87d(0x196)],'input':_0xfb8905[_0x1ae87d(0x1c0)],'itemId':_0x369f76,'structured':!![],'commandOrigin':_0x147572}),[];}}const _0x427288=marAgentAgentId(_0xfb8905[_0x1ae87d(0x1c0)]),_0x5ccdd2=_0x427288===undefined?undefined:this.#subagentTitles[_0x1ae87d(0x211)](_0x427288);this.#tools[_0x1ae87d(0x217)](_0xfb8905[_0x1ae87d(0x198)],{'toolName':_0xfb8905[_0x1ae87d(0x196)],'input':_0xfb8905[_0x1ae87d(0x1c0)],'itemId':_0x369f76,'structured':_0x1ae87d(0x1c0)in _0xfb8905,..._0x5ccdd2===undefined?{}:{'subagentTitle':_0x5ccdd2}});if(_0xfb8905[_0x1ae87d(0x196)]===_0x1ae87d(0x1ac)&&_0x1ae87d(0x1c0)in _0xfb8905)return[fileChangeItem(_0x369f76,_0x1ae87d(0x207),[])];return[genericToolItem(_0x369f76,_0xfb8905[_0x1ae87d(0x196)],_0x1ae87d(0x207),_0xfb8905[_0x1ae87d(0x1c0)],null,null,![],undefined,_0x5ccdd2)];}#toolCompleted(_0x198dd7){const _0x319a16=_0x1296c1,_0xe201f2=this.#tools[_0x319a16(0x211)](_0x198dd7[_0x319a16(0x198)]);if(_0x198dd7[_0x319a16(0x196)]===_0x319a16(0x1fd)&&_0xe201f2?.[_0x319a16(0x1d6)]!==undefined){const _0x333add=this.#commands[_0x319a16(0x211)](_0xe201f2[_0x319a16(0x1d6)]),_0x5e4482=execResult(_0x198dd7[_0x319a16(0x1b6)],_0x198dd7[_0x319a16(0x1c8)],_0x198dd7[_0x319a16(0x17b)]===!![]);if(_0x333add!==undefined&&_0x5e4482!==undefined){if(_0x5e4482[_0x319a16(0x19a)]!==undefined)this.#processOrigins[_0x319a16(0x217)](_0x5e4482[_0x319a16(0x19a)],_0xe201f2[_0x319a16(0x1d6)]);applyCommandResult(_0x333add,_0x5e4482);const _0x1d5ba5=_0x5e4482[_0x319a16(0x1e5)]===_0x319a16(0x195)?_0x319a16(0x207):_0x5e4482[_0x319a16(0x1e5)]===_0x319a16(0x212)&&_0x5e4482[_0x319a16(0x185)]===0x5a*-0x4a+-0xe1*0x19+0x2ffd?_0x319a16(0x179):_0x319a16(0x1a1);return[commandItem(_0x333add,_0x1d5ba5)];}}if(_0x198dd7[_0x319a16(0x196)]===_0x319a16(0x1ac)&&(_0xe201f2?.[_0x319a16(0x203)]===!![]||Array[_0x319a16(0x1f7)](record(_0x198dd7[_0x319a16(0x1b6)])?.[_0x319a16(0x1e0)])))return[fileChangeItem(_0xe201f2?.[_0x319a16(0x1c7)]??itemId(_0x319a16(0x1b7),_0x198dd7[_0x319a16(0x198)]),_0x319a16(0x179),patchChanges(_0x198dd7[_0x319a16(0x1b6)]))];const _0x627b92=imageArtifacts(_0x198dd7),_0x3566b4=genericToolItem(_0xe201f2?.[_0x319a16(0x1c7)]??itemId(_0x319a16(0x1b7),_0x198dd7[_0x319a16(0x198)]),_0x198dd7[_0x319a16(0x196)],_0x319a16(0x179),_0xe201f2?.[_0x319a16(0x1c0)],_0x627b92[_0x319a16(0x206)]===0x7*-0x211+0xd5d+-0x2*-0x8d?_0x198dd7[_0x319a16(0x1c8)]:_0x627b92[_0x319a16(0x1cb)](_0x6280c1=>_0x6280c1[_0x319a16(0x190)])[_0x319a16(0x1fb)](',\x20'),null,_0x198dd7[_0x319a16(0x17b)],_0x198dd7[_0x319a16(0x1b6)],_0xe201f2?.[_0x319a16(0x1a8)]);return[{..._0x3566b4,..._0x627b92[_0x319a16(0x206)]===0x1f8e+-0x1296+0x5*-0x298?{}:{'generatedImages':_0x627b92}}];}#toolFailed(_0xc0c434){const _0x4f5c88=_0x1296c1,_0x35fd66=this.#tools[_0x4f5c88(0x211)](_0xc0c434[_0x4f5c88(0x198)]);if(_0xc0c434[_0x4f5c88(0x196)]===_0x4f5c88(0x1fd)&&_0x35fd66?.[_0x4f5c88(0x1d6)]!==undefined){const _0x4431be=this.#commands[_0x4f5c88(0x211)](_0x35fd66[_0x4f5c88(0x1d6)]);if(_0x4431be!==undefined)return[commandItem(_0x4431be,_0x4f5c88(0x1a1))];}if(_0xc0c434[_0x4f5c88(0x196)]===_0x4f5c88(0x1ac)&&_0x35fd66?.[_0x4f5c88(0x203)]===!![])return[fileChangeItem(_0x35fd66?.[_0x4f5c88(0x1c7)]??itemId(_0x4f5c88(0x1b7),_0xc0c434[_0x4f5c88(0x198)]),_0x4f5c88(0x1a1),[])];return[genericToolItem(_0x35fd66?.[_0x4f5c88(0x1c7)]??itemId(_0x4f5c88(0x1b7),_0xc0c434[_0x4f5c88(0x198)]),_0xc0c434[_0x4f5c88(0x196)],_0x4f5c88(0x1a1),_0x35fd66?.[_0x4f5c88(0x1c0)],_0xc0c434[_0x4f5c88(0x1df)]??_0xc0c434[_0x4f5c88(0x192)],_0xc0c434[_0x4f5c88(0x192)],![],undefined,_0x35fd66?.[_0x4f5c88(0x1a8)])];}}function itemId(_0x3a6778,_0x2f0302){const _0x4b9efa=_0x1296c1;return boundedConversationItemId(_0x4b9efa(0x204)+_0x3a6778,_0x2f0302);}function genericToolItem(_0x5e2011,_0x31e99c,_0x1f49c6,_0x1b26de,_0x3bf13d=null,_0x5925eb=null,_0x3aacbc=![],_0x432737,_0x367112){const _0x52a880=_0x1296c1,_0x3deba5=marAgentSubagentProjection(_0x31e99c,_0x1b26de,_0x432737,_0x367112),_0x2fc182=[_0x52a880(0x1d1),_0x52a880(0x1db)][_0x52a880(0x1e7)](_0x31e99c)?_0x52a880(0x193):undefined;return{'itemId':_0x5e2011,'kind':_0x52a880(0x1c4),'status':_0x1f49c6,'payload':{'namespace':_0x52a880(0x1ca),'toolName':compactRunnerText(_0x31e99c,-0x1f22+-0x33*-0x52+-0x4*-0x3d3)||_0x52a880(0x1ad),'title':compactRunnerText(_0x31e99c,-0xaa5*0x1+0x13c8+-0x72f)||_0x52a880(0x1ad),'inputSummary':compactRunnerValue(_0x1b26de,-0x24d*0x7+-0x49b1+0x80dc)[_0x52a880(0x1a0)]||null,'outputSummary':_0x3bf13d===null?null:compactRunnerText(_0x3bf13d,0x1f36+-0x1a35*-0x2+-0x2c90),'progressLabel':_0x1f49c6===_0x52a880(0x207)?_0x52a880(0x182):null,'errorCode':_0x5925eb===null?null:compactRunnerText(_0x5925eb,0x16*-0x17b+0x1d1b+0x3c7*0x1),'truncated':_0x3aacbc,..._0x2fc182===undefined?{}:{'toolCategory':_0x2fc182},..._0x3deba5},'merge':!![]};}function commandItem(_0x2132e6,_0xd2c445){const _0x480ba0=_0x1296c1;return{'itemId':_0x2132e6[_0x480ba0(0x1c7)],'kind':_0x480ba0(0x1e3),'status':_0xd2c445,'payload':{'command':_0x2132e6[_0x480ba0(0x17f)],'cwd':_0x2132e6[_0x480ba0(0x194)],'outputPreview':_0x2132e6[_0x480ba0(0x1bb)],'outputRef':null,'exitCode':_0x2132e6[_0x480ba0(0x185)],'durationMs':null,'truncated':_0x2132e6[_0x480ba0(0x17b)]},'merge':!![]};}function applyCommandResult(_0x8c5639,_0x33ca49){const _0x5716c5=_0x1296c1,_0x1d76a7=[_0x33ca49[_0x5716c5(0x1dc)],_0x33ca49[_0x5716c5(0x1eb)]][_0x5716c5(0x197)](Boolean)[_0x5716c5(0x1fb)]('\x0a');if(_0x1d76a7[_0x5716c5(0x206)]>0x315*-0x8+-0xd78*-0x1+-0xb3*-0x10){const _0x408406=[_0x8c5639[_0x5716c5(0x1bb)],_0x1d76a7][_0x5716c5(0x197)](Boolean)[_0x5716c5(0x1fb)]('\x0a');_0x8c5639[_0x5716c5(0x17b)]||=_0x408406[_0x5716c5(0x206)]>-0x3fca+-0x11b*-0xe+0x5760,_0x8c5639[_0x5716c5(0x1bb)]=compactRunnerText(_0x408406,-0x234e+-0x3e72+0x88d0);}_0x8c5639[_0x5716c5(0x185)]=_0x33ca49[_0x5716c5(0x185)]??_0x8c5639[_0x5716c5(0x185)],_0x8c5639[_0x5716c5(0x17b)]||=_0x33ca49[_0x5716c5(0x17b)];}function _0x5d92(_0x372a4e,_0x19ff25){_0x372a4e=_0x372a4e-(0x8be*0x1+-0x1fec+0x18a6);const _0x4d8195=_0x5b2e();let _0x24afa7=_0x4d8195[_0x372a4e];if(_0x5d92['ClELdz']===undefined){var _0x22b1c1=function(_0x3f127e){const _0x2dc2a4='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x467566='',_0x25dc28='';for(let _0x2b753c=0x14c9+-0x355+0x8ba*-0x2,_0x43f3e6,_0x919a36,_0x248904=-0x1a4*-0x13+0x2623+-0x454f;_0x919a36=_0x3f127e['charAt'](_0x248904++);~_0x919a36&&(_0x43f3e6=_0x2b753c%(0x9*0x38b+-0xc41+-0x139e)?_0x43f3e6*(-0x245*0x5+-0xf82+0x909*0x3)+_0x919a36:_0x919a36,_0x2b753c++%(-0x1fd4+0x1fc3+-0x3*-0x7))?_0x467566+=String['fromCharCode'](-0x2134+0x1a*-0x92+-0x475*-0xb&_0x43f3e6>>(-(-0x4c*-0x2+0x197*-0x5+0x1*0x75d)*_0x2b753c&0x1628+0x543+0x1b65*-0x1)):0x1aac+0x1673*0x1+-0x19*0x1f7){_0x919a36=_0x2dc2a4['indexOf'](_0x919a36);}for(let _0xde8d0f=-0x217a*0x1+0x20b+0x1f6f,_0x42bc1b=_0x467566['length'];_0xde8d0f<_0x42bc1b;_0xde8d0f++){_0x25dc28+='%'+('00'+_0x467566['charCodeAt'](_0xde8d0f)['toString'](-0x757*-0x5+0x1477+-0x391a))['slice'](-(-0x1*-0xd5d+-0x1*-0x23ce+-0xf*0x347));}return decodeURIComponent(_0x25dc28);};_0x5d92['pBnsCy']=_0x22b1c1,_0x5d92['SdUQnt']={},_0x5d92['ClELdz']=!![];}const _0x47d535=_0x4d8195[0x1*-0x1d63+-0xf48+-0x1*-0x2cab];_0x5d92['EjGNYn']!==_0x47d535&&(_0x5d92['SdUQnt']={},_0x5d92['EjGNYn']=_0x47d535);const _0x5ae3bd=_0x5d92['SdUQnt'][_0x372a4e];return _0x5ae3bd===undefined?(_0x24afa7=_0x5d92['pBnsCy'](_0x24afa7),_0x5d92['SdUQnt'][_0x372a4e]=_0x24afa7):_0x24afa7=_0x5ae3bd,_0x24afa7;}function fileChangeItem(_0x3fca56,_0x29b890,_0x5463ef){const _0x57fed8=_0x1296c1;return{'itemId':_0x3fca56,'kind':_0x57fed8(0x20c),'status':_0x29b890,'payload':{'changes':_0x5463ef},'merge':!![]};}function patchChanges(_0x45504b){const _0x3b7cb2=_0x1296c1,_0x7579f5=record(_0x45504b)?.[_0x3b7cb2(0x1e0)];if(!Array[_0x3b7cb2(0x1f7)](_0x7579f5))return[];return _0x7579f5[_0x3b7cb2(0x17c)](_0x59cc3d=>{const _0x797a5c=_0x3b7cb2,_0x577043=record(_0x59cc3d);if(typeof _0x577043?.[_0x797a5c(0x19c)]!==_0x797a5c(0x20d))return[];const _0x4c926a=compactRunnerText(_0x577043[_0x797a5c(0x19c)],0x1e91+-0x24fc+0x166b);if(_0x4c926a[_0x797a5c(0x206)]===0x22a1+0x188b+0xecb*-0x4)return[];const _0x4c000e=nonnegativeInteger(_0x577043[_0x797a5c(0x17e)]),_0x509ef3=nonnegativeInteger(_0x577043[_0x797a5c(0x214)]);if(_0x577043[_0x797a5c(0x1cc)]===_0x797a5c(0x1fa)&&typeof _0x577043[_0x797a5c(0x18d)]===_0x797a5c(0x20d)){const _0x1f7f4b=compactRunnerText(_0x577043[_0x797a5c(0x18d)],0x47e*-0x5+0x1635+0x49*0x39);if(_0x1f7f4b[_0x797a5c(0x206)]===-0x1d0f+-0x802+0x2511)return[change(_0x4c926a,_0x797a5c(0x1f8),_0x4c000e,_0x509ef3)];return[change(_0x4c926a,_0x797a5c(0x1a7),_0x4c000e,_0x509ef3),change(_0x1f7f4b,_0x797a5c(0x1e9),_0x4c000e,_0x509ef3)];}const _0x147939=_0x577043[_0x797a5c(0x1cc)]===_0x797a5c(0x1f3)?_0x797a5c(0x1e9):_0x577043[_0x797a5c(0x1cc)]===_0x797a5c(0x1cf)?_0x797a5c(0x1a7):_0x797a5c(0x1f8);return[change(_0x4c926a,_0x147939,_0x4c000e,_0x509ef3)];});}function change(_0x14a7d7,_0x2acb1e,_0xb1e839,_0x553cda){return{'path':_0x14a7d7,'change':_0x2acb1e,'additions':_0xb1e839,'deletions':_0x553cda,'diffAvailable':![]};}function execResult(_0x1c0a4f,_0xd4c297,_0x3ed1f7=![]){const _0x556894=_0x1296c1,_0x567a4e=record(_0x1c0a4f),_0x4e22bb=structuredRecord(_0xd4c297),_0x43285b=typeof _0x567a4e?.[_0x556894(0x1dc)]!==_0x556894(0x20d)&&typeof _0x567a4e?.[_0x556894(0x1eb)]!==_0x556894(0x20d),_0x2f6b35=_0x43285b&&typeof _0xd4c297===_0x556894(0x20d)&&_0xd4c297[_0x556894(0x1bf)]()[_0x556894(0x17a)]('{')&&_0x4e22bb===undefined,_0x4d6c5c=_0x567a4e?.[_0x556894(0x1e5)]===_0x556894(0x195)||_0x567a4e?.[_0x556894(0x1e5)]===_0x556894(0x212)||_0x567a4e?.[_0x556894(0x1e5)]===_0x556894(0x208)?_0x567a4e[_0x556894(0x1e5)]:_0x4e22bb?.[_0x556894(0x1e5)]===_0x556894(0x195)||_0x4e22bb?.[_0x556894(0x1e5)]===_0x556894(0x212)||_0x4e22bb?.[_0x556894(0x1e5)]===_0x556894(0x208)?_0x4e22bb[_0x556894(0x1e5)]:undefined;if(_0x4d6c5c===undefined)return undefined;const _0x2e0191=typeof _0x567a4e?.[_0x556894(0x19a)]===_0x556894(0x20d)?_0x567a4e[_0x556894(0x19a)]:typeof _0x4e22bb?.[_0x556894(0x19a)]===_0x556894(0x20d)?_0x4e22bb[_0x556894(0x19a)]:undefined,_0x128ae0=typeof _0x567a4e?.[_0x556894(0x1dc)]===_0x556894(0x20d)?_0x567a4e[_0x556894(0x1dc)]:typeof _0x4e22bb?.[_0x556894(0x1dc)]===_0x556894(0x20d)?_0x4e22bb[_0x556894(0x1dc)]:'',_0xfa8c88=typeof _0x567a4e?.[_0x556894(0x1eb)]===_0x556894(0x20d)?_0x567a4e[_0x556894(0x1eb)]:typeof _0x4e22bb?.[_0x556894(0x1eb)]===_0x556894(0x20d)?_0x4e22bb[_0x556894(0x1eb)]:'',_0x40630c=typeof _0x567a4e?.[_0x556894(0x185)]===_0x556894(0x1b3)||_0x567a4e?.[_0x556894(0x185)]===null?_0x567a4e[_0x556894(0x185)]:typeof _0x4e22bb?.[_0x556894(0x185)]===_0x556894(0x1b3)||_0x4e22bb?.[_0x556894(0x185)]===null?_0x4e22bb[_0x556894(0x185)]:undefined;return{'status':_0x4d6c5c,..._0x2e0191===undefined?{}:{'processId':_0x2e0191},'stdout':_0x128ae0,'stderr':_0xfa8c88,..._0x40630c===undefined?{}:{'exitCode':_0x40630c},'truncated':_0x3ed1f7||_0x567a4e?.[_0x556894(0x17b)]===!![]||_0x4e22bb?.[_0x556894(0x17b)]===!![]||_0x2f6b35};}function record(_0xa04e1b){const _0x5c9173=_0x1296c1;return _0xa04e1b!==null&&typeof _0xa04e1b===_0x5c9173(0x1b2)&&!Array[_0x5c9173(0x1f7)](_0xa04e1b)?_0xa04e1b:undefined;}function marAgentSubagentProjection(_0x33741c,_0x1640b8,_0x736018,_0x4575b3){const _0xeb9807=_0x1296c1,_0x35f079=_0x33741c===_0xeb9807(0x1a9)?_0xeb9807(0x20e):_0x33741c===_0xeb9807(0x18e)?_0xeb9807(0x201):_0x33741c===_0xeb9807(0x18c)?_0xeb9807(0x1a6):undefined;if(_0x35f079===undefined)return undefined;const _0x14342f=structuredRecord(_0x1640b8),_0x5c1167=structuredRecord(_0x736018),_0x5881b6=compactRunnerText(_0x4575b3??(typeof _0x5c1167?.[_0xeb9807(0x1b5)]===_0xeb9807(0x20d)?_0x5c1167[_0xeb9807(0x1b5)]:_0x35f079===_0xeb9807(0x20e)&&typeof _0x14342f?.[_0xeb9807(0x1b5)]===_0xeb9807(0x20d)?_0x14342f[_0xeb9807(0x1b5)]:''),0xca*0x1d+0xa6+0x1*-0x1594);return{'subagentOperation':_0x35f079,'subagentId':marAgentAgentId(_0x1640b8)??marAgentAgentId(_0x736018)??null,..._0x5881b6[_0xeb9807(0x206)]===-0x88c+0x7cf*-0x4+0x1*0x27c8?{}:{'title':_0x5881b6}};}function marAgentAgentId(_0xf4b544){const _0x34e85e=_0x1296c1,_0x114bd4=structuredRecord(_0xf4b544);if(_0x114bd4===undefined)return undefined;const _0x55cdfe=boundedId(_0x114bd4[_0x34e85e(0x17d)]);if(_0x55cdfe!==undefined)return _0x55cdfe;for(const _0x17aecc of[_0x34e85e(0x1b6),_0x34e85e(0x1ef),_0x34e85e(0x1e8)]){const _0x20709=marAgentAgentId(_0x114bd4[_0x17aecc]);if(_0x20709!==undefined)return _0x20709;}return undefined;}function structuredRecord(_0x64f413){const _0x45a0b1=_0x1296c1;if(typeof _0x64f413!==_0x45a0b1(0x20d))return record(_0x64f413);const _0x43d903=_0x64f413[_0x45a0b1(0x1bf)]();if(!_0x43d903[_0x45a0b1(0x17a)]('{'))return undefined;try{return record(JSON[_0x45a0b1(0x1ce)](_0x43d903));}catch{return undefined;}}function boundedId(_0x3deadc){const _0x2e563f=_0x1296c1;if(typeof _0x3deadc!==_0x2e563f(0x20d))return undefined;const _0xe163bf=_0x3deadc[_0x2e563f(0x1bf)]();return _0xe163bf[_0x2e563f(0x206)]>0x1449+-0x16e*-0xd+-0xcf5*0x3&&_0xe163bf[_0x2e563f(0x206)]<=-0x100f+-0x11a*0xb+0x98f*0x3?_0xe163bf:undefined;}function nonnegativeInteger(_0x4dc1e5){const _0x3ec4be=_0x1296c1;return typeof _0x4dc1e5===_0x3ec4be(0x1b3)&&Number[_0x3ec4be(0x189)](_0x4dc1e5)&&_0x4dc1e5>=-0x1e0e+-0xe60+-0x2c6e*-0x1?_0x4dc1e5:null;}function _0x5b2e(){const _0x2784bf=['y29TBwfUze9YAwDPBG','Dg9KBY51CgrHDgvK','D2vIx2zLDgnO','BwvZC2fNzuL0zw1jza','D2vIx3nLyxjJAa','yNL0zwrFyxjRx2LTywDLx2DLBG','C3rKB3v0','BwLTzvr5Cgu','zMLSzu5HBwu','BwvZC2fNzq','zMLSzxm','ywn0Aw9U','C3vIywDLBNqUC3rHCNrLza','y29TBwfUzf9LEgvJDxrPB24','BwvZC2fNzs5JB21WBgv0zwq','C3rHDhvZ','mteWndCWAxbXB3DZ','Aw5JBhvKzxm','B3v0Chv0','qureruq','CxvLCNK','C3rKzxjY','D3jPDgu','zxjYB3jnzxnZywDL','A2LUza','CMvZDwX0','y29UDgv4Dc5JB21Wywn0Aw5N','y29TCgfJDgLVBKLK','mMj6AfneAq','ywrKzwq','zxHLy3v0Aw9Uswq','C3rLCa','Dg9vChbLCKnHC2u','AxnbCNjHEq','tu9esuzjruq','DgL0Bgu','Bw92zwq','AM9PBG','uLvotKLorW','zxHLyW','mtiXndG1mxLcBurRzW','DgvZDa','AxrLBxm','u1rbvfvt','y29TCgfJDa','C3rYDwn0DxjLza','BwfYlwfNzw50lq','mZe0n2fhCvH6va','BgvUz3rO','su5Fufjpr1jfu1m','y2fUy2vSBgvK','tufsx0fhru5ux1jvtL9gquLmruq','Aw1Hz2u','Ag9ZDgvKx3rVB2WUDxbKyxrLza','zMLSzv9JAgfUz2u','C3rYAw5N','u1rbuLq','zw5KC1DPDgG','CMvHC29UAw5N','z2v0','y29TCgXLDgvK','BwfYA2rVD24','zgvSzxrLzeXPBMvZ','mJe3otaWzvPgvure','mZeXmtm3mfzfDufdCq','C2v0','C3rHCNq','Dg9mB2nHBgvmB3DLCKnHC2u','q09nueXfveve','C3rHCNrZv2L0Aa','Dhj1BMnHDgvK','zMXHDe1HCa','ywDLBNrjza','ywrKzwrmAw5LCW','y29TBwfUza','Ag9ZDgvKlxDLyG','yNL0zvnPEMu','uNvUBMLUzW','lNbUzW','zxHLy3v0Aw9UlMzHAwXLza','zxHPDenVzgu','DhLWzq','yxj0AwzHy3rZ','yxnZAxn0yw50x21LC3nHz2u','AxnjBNrLz2vY','C3vIywDLBNq','Cg9SBa','ywDLBNrFy2fUy2vS','DgfYz2v0ugf0Aa','ywDLBNrFD2fPDa','CgXHBG','BMfTzq','y2fUy2vS','y29Kzq','su1br0vFr0vorvjbveLptG','y3DK','CNvUBMLUzW','Dg9VBe5HBwu','zMLSDgvY','y2fSBeLK','CgXHBI5JB21WBgv0zwq','ChjVy2vZC0LK','se9tvevex1rpt0XFrKfjteve','Cgf0Aa','q0foq0vmteve','v2vIihnLyxjJAa','Dg9VBc5JB21WBgv0zwq','Dgv4Da','rKfjteve','zxjYB3jdB2rL','zxzLBNrjza','BM9YBwfSAxPL','v2vIigzLDgnO','q0foq0vm','revmrvrfra','C3vIywDLBNruAxrSzq','ywDLBNrFC3rHCNq','Dg9KBY1SAxn0','y29UDgv4Dc5JB21Wywn0zwq','yxbWBhLFCgf0y2G','Dw5RBM93BG','u3vIywDLBNq','mtuXnLnJDfbcwq','mti2otyWEuPfBNPe','C2HHmJu2','B2jQzwn0','BNvTyMvY','Dg9VBc5MywLSzwq','zgvZy3jPChrPB24','zgf0yq','Dg9VBa','Ag9ZDgvK','y29UDgv4Df9JB21Wywn0Aw9U','odi2mdqYzMLQEuTi','B3v0Chv0uhjLDMLLDW','Aw1Hz2uVCg5N','zgvSzxrL','Dg9KB19SAxn0','DhjPBq','Aw5WDxq','tufsx0fhru5ux1nvqKfhru5ux0zbsuXfra','ndH5twHrq1a','mJqZt3bHr2ng','Dg9VBf9JywXS','CMvHC29UAw5Nx3n1Bw1HCNK','CMvHC29UAw5NlNn1Bw1HCNK','AxrLBuLK','C3vTBwfYEq','zxjYB3i','BwfYlwfNzw50','BwfW','B3bLCMf0Aw9U','C3vIywDLBNqUy29TCgXLDgvK','CgfYC2u','zgvSzxrLza','DxjS','y29KzxHFAw1Hz2vFz2vU','Dg9VBc5ZDgfYDgvK','v0vcx1nfqvjdsa','zMfPBgvK','u1rbuLrfra'];_0x5b2e=function(){return _0x2784bf;};return _0x5b2e();}function imageArtifacts(_0x1b0ce2){const _0x369899=_0x1296c1;if(![_0x369899(0x1d1),_0x369899(0x1db)][_0x369899(0x1e7)](_0x1b0ce2[_0x369899(0x196)])||!Array[_0x369899(0x1f7)](_0x1b0ce2[_0x369899(0x187)]))return[];return _0x1b0ce2[_0x369899(0x187)][_0x369899(0x17c)](_0x384b4a=>{const _0x2a585a=_0x369899,_0x374ea2=record(_0x384b4a),_0x4801db=typeof _0x374ea2?.[_0x2a585a(0x1de)]===_0x2a585a(0x20d)?_0x374ea2[_0x2a585a(0x1de)][_0x2a585a(0x1bf)]():'',_0x2eb39d=typeof _0x374ea2?.[_0x2a585a(0x190)]===_0x2a585a(0x20d)?compactRunnerText(_0x374ea2[_0x2a585a(0x190)],0x14b*0x1d+0x181b+-0x1*0x3c9b):'',_0x2ce56d=nonnegativeInteger(_0x374ea2?.[_0x2a585a(0x181)]);if(_0x374ea2?.[_0x2a585a(0x1ee)]!==_0x2a585a(0x20a)||_0x374ea2[_0x2a585a(0x1dd)]!==_0x2a585a(0x1bc)||typeof _0x374ea2[_0x2a585a(0x1b1)]!==_0x2a585a(0x20d)||!/^[a-f0-9]{64}$/iu[_0x2a585a(0x1ff)](_0x374ea2[_0x2a585a(0x1b1)])||_0x2eb39d[_0x2a585a(0x206)]===0x1f68+0x184b+-0x37b3||_0x2ce56d===null||_0x2ce56d===0x1936+0x23*0x95+-0x2d95*0x1||_0x4801db[_0x2a585a(0x206)]===0x1c11+0x1*-0x8d+0x3*-0x92c||_0x4801db[_0x2a585a(0x206)]>0x2c8*-0x1+0x1*0x565+-0x3*0x8a||_0x4801db==='.'||_0x4801db==='..'||_0x4801db[_0x2a585a(0x1e7)]('/')||_0x4801db[_0x2a585a(0x1e7)]('\x5c')||!_0x4801db[_0x2a585a(0x178)]()[_0x2a585a(0x20f)](_0x2a585a(0x183)))return[];return[{'name':_0x2eb39d,'mime':_0x2a585a(0x1bc),'byteSize':_0x2ce56d,'fileName':_0x4801db}];});}
|
|
1
|
+
import { boundedConversationItemId, compactRunnerText, compactRunnerValue } from '../../util/node-operation-parsers.js';
|
|
2
|
+
import { runnerErrorProjection } from '../../util/runner-error.js';
|
|
3
|
+
export class MarAgentConversationNormalizer {
|
|
4
|
+
#tools = new Map();
|
|
5
|
+
#commands = new Map();
|
|
6
|
+
#processOrigins = new Map();
|
|
7
|
+
#subagentTitles = new Map();
|
|
8
|
+
#subagentDetails = new Map();
|
|
9
|
+
messageItemId(nativeItemId) {
|
|
10
|
+
return itemId('message', nativeItemId);
|
|
11
|
+
}
|
|
12
|
+
normalize(event) {
|
|
13
|
+
if (event.type === 'execution.failed') {
|
|
14
|
+
const projected = runnerErrorProjection({ code: event.code, message: event.message }, 'MAR_AGENT_RUN_FAILED');
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
itemId: itemId('error', event.executionId),
|
|
18
|
+
kind: 'error',
|
|
19
|
+
status: 'FAILED',
|
|
20
|
+
payload: {
|
|
21
|
+
...projected,
|
|
22
|
+
recoverable: true,
|
|
23
|
+
retryAfterMs: null
|
|
24
|
+
},
|
|
25
|
+
merge: true
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
if (event.type === 'message.completed') {
|
|
30
|
+
const modelName = record(event)?.modelName;
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
itemId: this.messageItemId(event.itemId),
|
|
34
|
+
kind: 'assistant_message',
|
|
35
|
+
status: 'COMPLETED',
|
|
36
|
+
payload: {
|
|
37
|
+
text: event.text,
|
|
38
|
+
format: 'markdown',
|
|
39
|
+
model: typeof modelName === 'string' ? modelName : null
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
if (event.type === 'plan.completed')
|
|
45
|
+
return [
|
|
46
|
+
{
|
|
47
|
+
itemId: itemId('message', event.itemId),
|
|
48
|
+
kind: 'plan',
|
|
49
|
+
status: 'COMPLETED',
|
|
50
|
+
payload: { explanation: event.text, steps: [] }
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
if (event.type === 'reasoning.summary')
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
56
|
+
itemId: itemId('reasoning', event.eventId),
|
|
57
|
+
kind: 'reasoning_summary',
|
|
58
|
+
status: 'COMPLETED',
|
|
59
|
+
payload: { sections: [{ index: 0, text: compactRunnerText(event.text, 10_000) }] }
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
if (event.type === 'tool.started')
|
|
63
|
+
return this.#toolStarted(event);
|
|
64
|
+
if (event.type === 'tool.completed')
|
|
65
|
+
return this.#toolCompleted(event);
|
|
66
|
+
if (event.type === 'tool.failed')
|
|
67
|
+
return this.#toolFailed(event);
|
|
68
|
+
if (event.type === 'hosted_tool.updated')
|
|
69
|
+
return [
|
|
70
|
+
{
|
|
71
|
+
itemId: itemId('hosted', event.itemId),
|
|
72
|
+
kind: 'tool_call',
|
|
73
|
+
status: event.status === 'RUNNING'
|
|
74
|
+
? 'IN_PROGRESS'
|
|
75
|
+
: event.status === 'COMPLETED'
|
|
76
|
+
? 'COMPLETED'
|
|
77
|
+
: 'FAILED',
|
|
78
|
+
payload: {
|
|
79
|
+
namespace: 'hosted-web',
|
|
80
|
+
toolName: event.kind === 'WEB_SEARCH' ? 'web_search' : 'web_fetch',
|
|
81
|
+
title: event.kind === 'WEB_SEARCH' ? 'Web search' : 'Web fetch',
|
|
82
|
+
inputSummary: event.summary.query === undefined && event.summary.url === undefined
|
|
83
|
+
? null
|
|
84
|
+
: compactRunnerText(event.summary.query ?? event.summary.url ?? '', 10_000),
|
|
85
|
+
outputSummary: event.summary.title === undefined
|
|
86
|
+
? null
|
|
87
|
+
: compactRunnerText(event.summary.title, 10_000),
|
|
88
|
+
progressLabel: event.status === 'RUNNING' ? 'Running' : null,
|
|
89
|
+
errorCode: event.status === 'FAILED' ? 'HOSTED_TOOL_FAILED' : null,
|
|
90
|
+
truncated: false
|
|
91
|
+
},
|
|
92
|
+
merge: true
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
if (event.type === 'todo.updated')
|
|
96
|
+
return [
|
|
97
|
+
{
|
|
98
|
+
itemId: itemId('todo-list', event.eventId),
|
|
99
|
+
kind: 'todo_list',
|
|
100
|
+
status: 'COMPLETED',
|
|
101
|
+
payload: {
|
|
102
|
+
items: event.items.map((entry) => ({
|
|
103
|
+
id: compactRunnerText(entry.id, 128) || 'unknown',
|
|
104
|
+
text: entry.step,
|
|
105
|
+
status: entry.status.toUpperCase()
|
|
106
|
+
}))
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
if (event.type === 'context.compacting' || event.type === 'context.compacted')
|
|
111
|
+
return [
|
|
112
|
+
{
|
|
113
|
+
itemId: itemId('compact', event.compactionId),
|
|
114
|
+
kind: 'context_compaction',
|
|
115
|
+
status: event.type === 'context.compacting' ? 'IN_PROGRESS' : 'COMPLETED',
|
|
116
|
+
payload: {
|
|
117
|
+
phase: event.type === 'context.compacting' ? 'STARTED' : 'COMPLETED',
|
|
118
|
+
summary: null
|
|
119
|
+
},
|
|
120
|
+
merge: true
|
|
121
|
+
}
|
|
122
|
+
];
|
|
123
|
+
if (event.type === 'subagent.started' || event.type === 'subagent.completed') {
|
|
124
|
+
const eventDescription = record(event)?.description;
|
|
125
|
+
const eventTitle = compactRunnerText(typeof eventDescription === 'string' ? eventDescription : '', 500);
|
|
126
|
+
if (eventTitle.length > 0)
|
|
127
|
+
this.#subagentTitles.set(event.agentId, eventTitle);
|
|
128
|
+
const title = eventTitle || this.#subagentTitles.get(event.agentId) || 'Subagent';
|
|
129
|
+
const details = mergeSubagentDetails(this.#subagentDetails.get(event.agentId), subagentDetails(event));
|
|
130
|
+
if (Object.keys(details).length > 0)
|
|
131
|
+
this.#subagentDetails.set(event.agentId, details);
|
|
132
|
+
const latestText = typeof details.latestMessage?.text === 'string' ? details.latestMessage.text : undefined;
|
|
133
|
+
const outputSummary = event.type === 'subagent.completed'
|
|
134
|
+
? latestText === undefined
|
|
135
|
+
? event.errorMessage === undefined
|
|
136
|
+
? null
|
|
137
|
+
: boundedToolSummary(event.errorMessage)
|
|
138
|
+
: boundedToolSummary(latestText)
|
|
139
|
+
: null;
|
|
140
|
+
return [
|
|
141
|
+
{
|
|
142
|
+
itemId: itemId('subagent', event.agentId),
|
|
143
|
+
kind: 'tool_call',
|
|
144
|
+
status: event.type === 'subagent.started'
|
|
145
|
+
? 'IN_PROGRESS'
|
|
146
|
+
: event.status === 'completed'
|
|
147
|
+
? 'COMPLETED'
|
|
148
|
+
: event.status === 'cancelled'
|
|
149
|
+
? 'CANCELLED'
|
|
150
|
+
: event.status === 'interrupted'
|
|
151
|
+
? 'INTERRUPTED'
|
|
152
|
+
: 'FAILED',
|
|
153
|
+
payload: {
|
|
154
|
+
namespace: 'mar-agent',
|
|
155
|
+
toolName: 'agent_wait',
|
|
156
|
+
title,
|
|
157
|
+
inputSummary: event.type === 'subagent.started'
|
|
158
|
+
? compactRunnerText(event.description, 10_000)
|
|
159
|
+
: null,
|
|
160
|
+
outputSummary,
|
|
161
|
+
progressLabel: event.type === 'subagent.started' ? 'Running' : null,
|
|
162
|
+
errorCode: event.type === 'subagent.completed' && event.status === 'failed'
|
|
163
|
+
? (event.errorCode ?? 'MAR_AGENT_SUBAGENT_FAILED')
|
|
164
|
+
: null,
|
|
165
|
+
truncated: latestText !== undefined && outputSummary !== latestText,
|
|
166
|
+
subagentOperation: 'STATUS',
|
|
167
|
+
subagentId: event.agentId,
|
|
168
|
+
...subagentPayload(details)
|
|
169
|
+
},
|
|
170
|
+
merge: true
|
|
171
|
+
}
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
#toolStarted(event) {
|
|
177
|
+
const ownItemId = itemId('tool', event.callId);
|
|
178
|
+
if (event.toolName === 'exec') {
|
|
179
|
+
const input = record(event.input) ?? {};
|
|
180
|
+
const action = input.action;
|
|
181
|
+
if (action === 'start' && typeof input.command === 'string') {
|
|
182
|
+
const command = {
|
|
183
|
+
itemId: ownItemId,
|
|
184
|
+
command: compactRunnerText(input.command, 10_000),
|
|
185
|
+
cwd: typeof input.cwd === 'string' ? compactRunnerText(input.cwd, 4_096) : null,
|
|
186
|
+
outputPreview: '',
|
|
187
|
+
exitCode: null,
|
|
188
|
+
truncated: false
|
|
189
|
+
};
|
|
190
|
+
this.#commands.set(event.callId, command);
|
|
191
|
+
this.#tools.set(event.callId, {
|
|
192
|
+
toolName: event.toolName,
|
|
193
|
+
input: event.input,
|
|
194
|
+
itemId: ownItemId,
|
|
195
|
+
structured: true,
|
|
196
|
+
commandOrigin: event.callId
|
|
197
|
+
});
|
|
198
|
+
return [commandItem(command, 'IN_PROGRESS')];
|
|
199
|
+
}
|
|
200
|
+
if ((action === 'poll' || action === 'write' || action === 'cancel') &&
|
|
201
|
+
typeof input.processId === 'string') {
|
|
202
|
+
const origin = this.#processOrigins.get(input.processId);
|
|
203
|
+
if (origin !== undefined) {
|
|
204
|
+
this.#tools.set(event.callId, {
|
|
205
|
+
toolName: event.toolName,
|
|
206
|
+
input: event.input,
|
|
207
|
+
itemId: ownItemId,
|
|
208
|
+
structured: true,
|
|
209
|
+
commandOrigin: origin
|
|
210
|
+
});
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const agentId = isMarAgentControlTool(event.toolName)
|
|
216
|
+
? marAgentAgentId(event.input)
|
|
217
|
+
: undefined;
|
|
218
|
+
const subagentTitle = agentId === undefined ? undefined : this.#subagentTitles.get(agentId);
|
|
219
|
+
const subagentDetails = agentId === undefined ? undefined : this.#subagentDetails.get(agentId);
|
|
220
|
+
this.#tools.set(event.callId, {
|
|
221
|
+
toolName: event.toolName,
|
|
222
|
+
input: event.input,
|
|
223
|
+
itemId: ownItemId,
|
|
224
|
+
structured: 'input' in event,
|
|
225
|
+
...(subagentTitle === undefined ? {} : { subagentTitle }),
|
|
226
|
+
...(subagentDetails === undefined ? {} : { subagentDetails })
|
|
227
|
+
});
|
|
228
|
+
if (event.toolName === 'apply_patch' && 'input' in event)
|
|
229
|
+
return [fileChangeItem(ownItemId, 'IN_PROGRESS', [])];
|
|
230
|
+
return [
|
|
231
|
+
genericToolItem(ownItemId, event.toolName, 'IN_PROGRESS', event.input, null, null, false, undefined, subagentTitle, subagentDetails)
|
|
232
|
+
];
|
|
233
|
+
}
|
|
234
|
+
#toolCompleted(event) {
|
|
235
|
+
const state = this.#tools.get(event.callId);
|
|
236
|
+
if (event.toolName === 'exec' && state?.commandOrigin !== undefined) {
|
|
237
|
+
const command = this.#commands.get(state.commandOrigin);
|
|
238
|
+
const result = execResult(event.data, event.summary, event.truncated === true);
|
|
239
|
+
if (command !== undefined && result !== undefined) {
|
|
240
|
+
if (result.processId !== undefined)
|
|
241
|
+
this.#processOrigins.set(result.processId, state.commandOrigin);
|
|
242
|
+
applyCommandResult(command, result);
|
|
243
|
+
const status = result.status === 'running'
|
|
244
|
+
? 'IN_PROGRESS'
|
|
245
|
+
: result.status === 'completed' && result.exitCode === 0
|
|
246
|
+
? 'COMPLETED'
|
|
247
|
+
: 'FAILED';
|
|
248
|
+
return [commandItem(command, status)];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (event.toolName === 'apply_patch' &&
|
|
252
|
+
(state?.structured === true || Array.isArray(record(event.data)?.files)))
|
|
253
|
+
return [
|
|
254
|
+
fileChangeItem(state?.itemId ?? itemId('tool', event.callId), 'COMPLETED', patchChanges(event.data))
|
|
255
|
+
];
|
|
256
|
+
const generatedImages = imageArtifacts(event);
|
|
257
|
+
const controlTool = isMarAgentControlTool(event.toolName);
|
|
258
|
+
const controlOutput = controlTool
|
|
259
|
+
? matchingSubagentControlOutput(event.toolName, state?.input, event.data)
|
|
260
|
+
: undefined;
|
|
261
|
+
const agentId = controlTool
|
|
262
|
+
? (marAgentAgentId(state?.input) ?? marAgentAgentId(controlOutput))
|
|
263
|
+
: undefined;
|
|
264
|
+
const details = controlTool
|
|
265
|
+
? mergeSubagentDetails(state?.subagentDetails, subagentDetails(controlOutput))
|
|
266
|
+
: {};
|
|
267
|
+
if (agentId !== undefined) {
|
|
268
|
+
const output = structuredRecord(controlOutput);
|
|
269
|
+
if (typeof output?.description === 'string') {
|
|
270
|
+
const title = compactRunnerText(output.description, 500);
|
|
271
|
+
if (title.length > 0)
|
|
272
|
+
this.#subagentTitles.set(agentId, title);
|
|
273
|
+
}
|
|
274
|
+
if (Object.keys(details).length > 0)
|
|
275
|
+
this.#subagentDetails.set(agentId, details);
|
|
276
|
+
}
|
|
277
|
+
const item = genericToolItem(state?.itemId ?? itemId('tool', event.callId), event.toolName, 'COMPLETED', state?.input, generatedImages.length === 0
|
|
278
|
+
? event.summary
|
|
279
|
+
: generatedImages.map((image) => image.name).join(', '), null, event.truncated, event.data, state?.subagentTitle, details);
|
|
280
|
+
return [
|
|
281
|
+
{
|
|
282
|
+
...item,
|
|
283
|
+
...(generatedImages.length === 0 ? {} : { generatedImages })
|
|
284
|
+
}
|
|
285
|
+
];
|
|
286
|
+
}
|
|
287
|
+
#toolFailed(event) {
|
|
288
|
+
const state = this.#tools.get(event.callId);
|
|
289
|
+
if (event.toolName === 'exec' && state?.commandOrigin !== undefined) {
|
|
290
|
+
const command = this.#commands.get(state.commandOrigin);
|
|
291
|
+
if (command !== undefined)
|
|
292
|
+
return [commandItem(command, 'FAILED')];
|
|
293
|
+
}
|
|
294
|
+
if (event.toolName === 'apply_patch' && state?.structured === true)
|
|
295
|
+
return [fileChangeItem(state?.itemId ?? itemId('tool', event.callId), 'FAILED', [])];
|
|
296
|
+
return [
|
|
297
|
+
genericToolItem(state?.itemId ?? itemId('tool', event.callId), event.toolName, 'FAILED', state?.input, event.message ?? event.code, event.code, false, undefined, state?.subagentTitle, state?.subagentDetails)
|
|
298
|
+
];
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function itemId(kind, value) {
|
|
302
|
+
return boundedConversationItemId(`mar-agent-${kind}`, value);
|
|
303
|
+
}
|
|
304
|
+
function genericToolItem(id, toolName, status, input, outputSummary = null, errorCode = null, truncated = false, output, subagentTitle, knownSubagentDetails) {
|
|
305
|
+
const subagent = marAgentSubagentProjection(toolName, input, output, subagentTitle, knownSubagentDetails);
|
|
306
|
+
const toolCategory = ['codex_image_gen', 'byted_ark_image_gen'].includes(toolName)
|
|
307
|
+
? 'IMAGE_GENERATION'
|
|
308
|
+
: undefined;
|
|
309
|
+
return {
|
|
310
|
+
itemId: id,
|
|
311
|
+
kind: 'tool_call',
|
|
312
|
+
status,
|
|
313
|
+
payload: {
|
|
314
|
+
namespace: 'mar-agent',
|
|
315
|
+
toolName: compactRunnerText(toolName, 128) || 'unknown',
|
|
316
|
+
title: compactRunnerText(toolName, 500) || 'unknown',
|
|
317
|
+
inputSummary: compactRunnerValue(input, 10_000).text || null,
|
|
318
|
+
outputSummary: outputSummary === null ? null : compactRunnerText(outputSummary, 10_000),
|
|
319
|
+
progressLabel: status === 'IN_PROGRESS' ? 'Running' : null,
|
|
320
|
+
errorCode: errorCode === null ? null : compactRunnerText(errorCode, 80),
|
|
321
|
+
truncated,
|
|
322
|
+
...(toolCategory === undefined ? {} : { toolCategory }),
|
|
323
|
+
...subagent
|
|
324
|
+
},
|
|
325
|
+
merge: true
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function commandItem(command, status) {
|
|
329
|
+
return {
|
|
330
|
+
itemId: command.itemId,
|
|
331
|
+
kind: 'command_execution',
|
|
332
|
+
status,
|
|
333
|
+
payload: {
|
|
334
|
+
command: command.command,
|
|
335
|
+
cwd: command.cwd,
|
|
336
|
+
outputPreview: command.outputPreview,
|
|
337
|
+
outputRef: null,
|
|
338
|
+
exitCode: command.exitCode,
|
|
339
|
+
durationMs: null,
|
|
340
|
+
truncated: command.truncated
|
|
341
|
+
},
|
|
342
|
+
merge: true
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function applyCommandResult(command, result) {
|
|
346
|
+
const output = [result.stdout, result.stderr].filter(Boolean).join('\n');
|
|
347
|
+
if (output.length > 0) {
|
|
348
|
+
const combined = [command.outputPreview, output].filter(Boolean).join('\n');
|
|
349
|
+
command.truncated ||= combined.length > 10_000;
|
|
350
|
+
command.outputPreview = compactRunnerText(combined, 10_000);
|
|
351
|
+
}
|
|
352
|
+
command.exitCode = result.exitCode ?? command.exitCode;
|
|
353
|
+
command.truncated ||= result.truncated;
|
|
354
|
+
}
|
|
355
|
+
function fileChangeItem(id, status, changes) {
|
|
356
|
+
return { itemId: id, kind: 'file_change', status, payload: { changes }, merge: true };
|
|
357
|
+
}
|
|
358
|
+
function patchChanges(value) {
|
|
359
|
+
const files = record(value)?.files;
|
|
360
|
+
if (!Array.isArray(files))
|
|
361
|
+
return [];
|
|
362
|
+
return files.flatMap((entry) => {
|
|
363
|
+
const file = record(entry);
|
|
364
|
+
if (typeof file?.path !== 'string')
|
|
365
|
+
return [];
|
|
366
|
+
const path = compactRunnerText(file.path, 4_096);
|
|
367
|
+
if (path.length === 0)
|
|
368
|
+
return [];
|
|
369
|
+
const additions = nonnegativeInteger(file.addedLines);
|
|
370
|
+
const deletions = nonnegativeInteger(file.deletedLines);
|
|
371
|
+
if (file.operation === 'moved' && typeof file.targetPath === 'string') {
|
|
372
|
+
const targetPath = compactRunnerText(file.targetPath, 4_096);
|
|
373
|
+
if (targetPath.length === 0)
|
|
374
|
+
return [change(path, 'MODIFIED', additions, deletions)];
|
|
375
|
+
return [
|
|
376
|
+
change(path, 'DELETED', additions, deletions),
|
|
377
|
+
change(targetPath, 'ADDED', additions, deletions)
|
|
378
|
+
];
|
|
379
|
+
}
|
|
380
|
+
const operation = file.operation === 'added' ? 'ADDED' : file.operation === 'deleted' ? 'DELETED' : 'MODIFIED';
|
|
381
|
+
return [change(path, operation, additions, deletions)];
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
function change(path, operation, additions, deletions) {
|
|
385
|
+
return { path, change: operation, additions, deletions, diffAvailable: false };
|
|
386
|
+
}
|
|
387
|
+
function execResult(value, summary, eventTruncated = false) {
|
|
388
|
+
const data = record(value);
|
|
389
|
+
const summaryData = structuredRecord(summary);
|
|
390
|
+
const persistedOutputOmitted = typeof data?.stdout !== 'string' && typeof data?.stderr !== 'string';
|
|
391
|
+
const structuredSummaryIncomplete = persistedOutputOmitted &&
|
|
392
|
+
typeof summary === 'string' &&
|
|
393
|
+
summary.trim().startsWith('{') &&
|
|
394
|
+
summaryData === undefined;
|
|
395
|
+
const status = data?.status === 'running' || data?.status === 'completed' || data?.status === 'cancelled'
|
|
396
|
+
? data.status
|
|
397
|
+
: summaryData?.status === 'running' ||
|
|
398
|
+
summaryData?.status === 'completed' ||
|
|
399
|
+
summaryData?.status === 'cancelled'
|
|
400
|
+
? summaryData.status
|
|
401
|
+
: undefined;
|
|
402
|
+
if (status === undefined)
|
|
403
|
+
return undefined;
|
|
404
|
+
const processId = typeof data?.processId === 'string'
|
|
405
|
+
? data.processId
|
|
406
|
+
: typeof summaryData?.processId === 'string'
|
|
407
|
+
? summaryData.processId
|
|
408
|
+
: undefined;
|
|
409
|
+
const stdout = typeof data?.stdout === 'string'
|
|
410
|
+
? data.stdout
|
|
411
|
+
: typeof summaryData?.stdout === 'string'
|
|
412
|
+
? summaryData.stdout
|
|
413
|
+
: '';
|
|
414
|
+
const stderr = typeof data?.stderr === 'string'
|
|
415
|
+
? data.stderr
|
|
416
|
+
: typeof summaryData?.stderr === 'string'
|
|
417
|
+
? summaryData.stderr
|
|
418
|
+
: '';
|
|
419
|
+
const exitCode = typeof data?.exitCode === 'number' || data?.exitCode === null
|
|
420
|
+
? data.exitCode
|
|
421
|
+
: typeof summaryData?.exitCode === 'number' || summaryData?.exitCode === null
|
|
422
|
+
? summaryData.exitCode
|
|
423
|
+
: undefined;
|
|
424
|
+
return {
|
|
425
|
+
status,
|
|
426
|
+
...(processId === undefined ? {} : { processId }),
|
|
427
|
+
stdout,
|
|
428
|
+
stderr,
|
|
429
|
+
...(exitCode === undefined ? {} : { exitCode }),
|
|
430
|
+
truncated: eventTruncated ||
|
|
431
|
+
data?.truncated === true ||
|
|
432
|
+
summaryData?.truncated === true ||
|
|
433
|
+
structuredSummaryIncomplete
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
function record(value) {
|
|
437
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
438
|
+
? value
|
|
439
|
+
: undefined;
|
|
440
|
+
}
|
|
441
|
+
function marAgentSubagentProjection(toolName, input, output, knownTitle, knownDetails) {
|
|
442
|
+
const operation = marAgentSubagentOperation(toolName);
|
|
443
|
+
if (operation === undefined)
|
|
444
|
+
return undefined;
|
|
445
|
+
const inputData = structuredRecord(input);
|
|
446
|
+
const controlOutput = matchingSubagentControlOutput(toolName, input, output);
|
|
447
|
+
const outputData = structuredRecord(controlOutput);
|
|
448
|
+
const details = mergeSubagentDetails(knownDetails, subagentDetails(controlOutput));
|
|
449
|
+
const title = compactRunnerText(knownTitle ??
|
|
450
|
+
(typeof outputData?.description === 'string'
|
|
451
|
+
? outputData.description
|
|
452
|
+
: operation === 'START' && typeof inputData?.description === 'string'
|
|
453
|
+
? inputData.description
|
|
454
|
+
: ''), 500);
|
|
455
|
+
return {
|
|
456
|
+
subagentOperation: operation,
|
|
457
|
+
subagentId: marAgentAgentId(input) ?? marAgentAgentId(controlOutput) ?? null,
|
|
458
|
+
...(title.length === 0 ? {} : { title }),
|
|
459
|
+
...subagentPayload(details),
|
|
460
|
+
...(typeof details.latestMessage?.text === 'string'
|
|
461
|
+
? { outputSummary: boundedToolSummary(details.latestMessage.text) }
|
|
462
|
+
: typeof outputData?.errorMessage === 'string'
|
|
463
|
+
? { outputSummary: compactRunnerText(outputData.errorMessage, 10_000) }
|
|
464
|
+
: {}),
|
|
465
|
+
...(typeof outputData?.errorCode === 'string'
|
|
466
|
+
? { errorCode: compactRunnerText(outputData.errorCode, 80) }
|
|
467
|
+
: {})
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
function matchingSubagentControlOutput(toolName, input, output) {
|
|
471
|
+
const operation = marAgentSubagentOperation(toolName);
|
|
472
|
+
if (operation === undefined)
|
|
473
|
+
return undefined;
|
|
474
|
+
const outputAgentId = marAgentAgentId(output);
|
|
475
|
+
if (operation === 'START')
|
|
476
|
+
return outputAgentId === undefined ? undefined : output;
|
|
477
|
+
const inputAgentId = marAgentAgentId(input);
|
|
478
|
+
if (inputAgentId === undefined)
|
|
479
|
+
return outputAgentId === undefined ? undefined : output;
|
|
480
|
+
return outputAgentId === inputAgentId ? output : undefined;
|
|
481
|
+
}
|
|
482
|
+
function isMarAgentControlTool(toolName) {
|
|
483
|
+
return marAgentSubagentOperation(toolName) !== undefined;
|
|
484
|
+
}
|
|
485
|
+
function marAgentSubagentOperation(toolName) {
|
|
486
|
+
if (toolName === 'agent_start')
|
|
487
|
+
return 'START';
|
|
488
|
+
if (toolName === 'agent_wait')
|
|
489
|
+
return 'STATUS';
|
|
490
|
+
if (toolName === 'agent_message')
|
|
491
|
+
return 'MESSAGE';
|
|
492
|
+
if (toolName === 'agent_cancel')
|
|
493
|
+
return 'CANCEL';
|
|
494
|
+
return undefined;
|
|
495
|
+
}
|
|
496
|
+
function subagentDetails(value) {
|
|
497
|
+
const data = structuredRecord(value);
|
|
498
|
+
if (data === undefined)
|
|
499
|
+
return {};
|
|
500
|
+
const modelId = boundedText(data.modelId, 128);
|
|
501
|
+
const modelName = boundedText(data.modelName, 128);
|
|
502
|
+
const reasoningEffort = isReasoningEffort(data.reasoningEffort)
|
|
503
|
+
? data.reasoningEffort
|
|
504
|
+
: undefined;
|
|
505
|
+
const latestMessage = normalizedSubagentLatestMessage(data.latestMessage);
|
|
506
|
+
return {
|
|
507
|
+
...(modelId === undefined ? {} : { modelId }),
|
|
508
|
+
...(modelName === undefined ? {} : { modelName }),
|
|
509
|
+
...(reasoningEffort === undefined ? {} : { reasoningEffort }),
|
|
510
|
+
...(latestMessage === undefined ? {} : { latestMessage })
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
function mergeSubagentDetails(current, update) {
|
|
514
|
+
return {
|
|
515
|
+
...(current ?? {}),
|
|
516
|
+
...update
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
function subagentPayload(details) {
|
|
520
|
+
return {
|
|
521
|
+
...(details.modelId === undefined ? {} : { subagentModelId: details.modelId }),
|
|
522
|
+
...(details.modelName === undefined ? {} : { subagentModelName: details.modelName }),
|
|
523
|
+
...(details.reasoningEffort === undefined
|
|
524
|
+
? {}
|
|
525
|
+
: { subagentReasoningEffort: details.reasoningEffort }),
|
|
526
|
+
...(details.latestMessage === undefined ? {} : { subagentLatestMessage: details.latestMessage })
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
function normalizedSubagentLatestMessage(value) {
|
|
530
|
+
const data = record(value);
|
|
531
|
+
if (data === undefined ||
|
|
532
|
+
typeof data.itemId !== 'string' ||
|
|
533
|
+
typeof data.turnId !== 'string' ||
|
|
534
|
+
(data.phase !== 'commentary' && data.phase !== 'final_answer') ||
|
|
535
|
+
typeof data.text !== 'string' ||
|
|
536
|
+
typeof data.timestamp !== 'string')
|
|
537
|
+
return undefined;
|
|
538
|
+
const text = truncateCharacters(data.text, 10_000);
|
|
539
|
+
return {
|
|
540
|
+
itemId: compactRunnerText(data.itemId, 128),
|
|
541
|
+
turnId: compactRunnerText(data.turnId, 128),
|
|
542
|
+
phase: data.phase,
|
|
543
|
+
text,
|
|
544
|
+
timestamp: data.timestamp,
|
|
545
|
+
truncated: data.truncated === true || text !== data.text
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
function boundedText(value, maximumLength) {
|
|
549
|
+
if (typeof value !== 'string')
|
|
550
|
+
return undefined;
|
|
551
|
+
const text = compactRunnerText(value.trim(), maximumLength);
|
|
552
|
+
return text.length === 0 ? undefined : text;
|
|
553
|
+
}
|
|
554
|
+
function isReasoningEffort(value) {
|
|
555
|
+
return (value === 'low' ||
|
|
556
|
+
value === 'medium' ||
|
|
557
|
+
value === 'high' ||
|
|
558
|
+
value === 'xhigh' ||
|
|
559
|
+
value === 'max' ||
|
|
560
|
+
value === 'ultra');
|
|
561
|
+
}
|
|
562
|
+
function truncateCharacters(value, maximumCharacters) {
|
|
563
|
+
const characters = [...value];
|
|
564
|
+
return characters.length <= maximumCharacters
|
|
565
|
+
? value
|
|
566
|
+
: characters.slice(0, maximumCharacters).join('');
|
|
567
|
+
}
|
|
568
|
+
function boundedToolSummary(value) {
|
|
569
|
+
const maximumCodeUnits = 10_000;
|
|
570
|
+
if (value.length <= maximumCodeUnits)
|
|
571
|
+
return value;
|
|
572
|
+
let end = maximumCodeUnits - 1;
|
|
573
|
+
const lastIncluded = value.charCodeAt(end - 1);
|
|
574
|
+
const firstExcluded = value.charCodeAt(end);
|
|
575
|
+
if (lastIncluded >= 0xd800 &&
|
|
576
|
+
lastIncluded <= 0xdbff &&
|
|
577
|
+
firstExcluded >= 0xdc00 &&
|
|
578
|
+
firstExcluded <= 0xdfff)
|
|
579
|
+
end--;
|
|
580
|
+
return `${value.slice(0, end)}…`;
|
|
581
|
+
}
|
|
582
|
+
function marAgentAgentId(value) {
|
|
583
|
+
const data = structuredRecord(value);
|
|
584
|
+
if (data === undefined)
|
|
585
|
+
return undefined;
|
|
586
|
+
const direct = boundedId(data.agentId);
|
|
587
|
+
if (direct !== undefined)
|
|
588
|
+
return direct;
|
|
589
|
+
for (const key of ['data', 'result', 'output']) {
|
|
590
|
+
const nested = marAgentAgentId(data[key]);
|
|
591
|
+
if (nested !== undefined)
|
|
592
|
+
return nested;
|
|
593
|
+
}
|
|
594
|
+
return undefined;
|
|
595
|
+
}
|
|
596
|
+
function structuredRecord(value) {
|
|
597
|
+
if (typeof value !== 'string')
|
|
598
|
+
return record(value);
|
|
599
|
+
const text = value.trim();
|
|
600
|
+
if (!text.startsWith('{'))
|
|
601
|
+
return undefined;
|
|
602
|
+
try {
|
|
603
|
+
return record(JSON.parse(text));
|
|
604
|
+
}
|
|
605
|
+
catch {
|
|
606
|
+
return undefined;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
function boundedId(value) {
|
|
610
|
+
if (typeof value !== 'string')
|
|
611
|
+
return undefined;
|
|
612
|
+
const normalized = value.trim();
|
|
613
|
+
return normalized.length > 0 && normalized.length <= 128 ? normalized : undefined;
|
|
614
|
+
}
|
|
615
|
+
function nonnegativeInteger(value) {
|
|
616
|
+
return typeof value === 'number' && Number.isInteger(value) && value >= 0 ? value : null;
|
|
617
|
+
}
|
|
618
|
+
function imageArtifacts(event) {
|
|
619
|
+
if (!['codex_image_gen', 'byted_ark_image_gen'].includes(event.toolName) ||
|
|
620
|
+
!Array.isArray(event.artifacts))
|
|
621
|
+
return [];
|
|
622
|
+
return event.artifacts.flatMap((value) => {
|
|
623
|
+
const artifact = record(value);
|
|
624
|
+
const fileName = typeof artifact?.fileName === 'string' ? artifact.fileName.trim() : '';
|
|
625
|
+
const name = typeof artifact?.name === 'string' ? compactRunnerText(artifact.name, 255) : '';
|
|
626
|
+
const byteSize = nonnegativeInteger(artifact?.byteSize);
|
|
627
|
+
if (artifact?.kind !== 'image' ||
|
|
628
|
+
artifact.mimeType !== 'image/png' ||
|
|
629
|
+
typeof artifact.sha256 !== 'string' ||
|
|
630
|
+
!/^[a-f0-9]{64}$/iu.test(artifact.sha256) ||
|
|
631
|
+
name.length === 0 ||
|
|
632
|
+
byteSize === null ||
|
|
633
|
+
byteSize === 0 ||
|
|
634
|
+
fileName.length === 0 ||
|
|
635
|
+
fileName.length > 255 ||
|
|
636
|
+
fileName === '.' ||
|
|
637
|
+
fileName === '..' ||
|
|
638
|
+
fileName.includes('/') ||
|
|
639
|
+
fileName.includes('\\') ||
|
|
640
|
+
!fileName.toLocaleLowerCase().endsWith('.png'))
|
|
641
|
+
return [];
|
|
642
|
+
return [{ name, mime: 'image/png', byteSize, fileName }];
|
|
643
|
+
});
|
|
644
|
+
}
|