@xopcai/xopc 0.0.124 → 0.0.125
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/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/Combination-BzaXOLd9.js +41 -0
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B5uSVAyJ.js → agent-avatar-dicebear-BKDKICZV.js} +1 -1
- package/dist/gateway/static/root/assets/agents-BnTB7-c5.js +2 -0
- package/dist/gateway/static/root/assets/app-management-settings-panel-DI4BqHKW.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-6_ie3NQ4.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-B6bG65SW.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CXUGRp2i.js → archive-plugin-kUHEJ1HK.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Cmiub3Wg.js → attachment-load-Dm-9prpU.js} +1 -1
- package/dist/gateway/static/root/assets/automation-suggestion-card-OTxQTPnC.js +1 -0
- package/dist/gateway/static/root/assets/automations-page-1lVbo0dS.js +1 -0
- package/dist/gateway/static/root/assets/{binary-plugins-0Izz-N3p.js → binary-plugins-DllA_jQ0.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-C1Kv0IkJ.js → block-editor-Cm6CWNj1.js} +6 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CzDBlOK0.js +8 -0
- package/dist/gateway/static/root/assets/capability-presets-api-VJ89b6I2.js +1 -0
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-BaPj8wC2.js +1 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-BeA2aVor.js → channel-recipient-api-B5PwBEUx.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-Df4m7p1k.js +1 -0
- package/dist/gateway/static/root/assets/code-editor-gbRgS14t.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-BMTphmHS.js +2 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-2rjzUu57.js → directory-picker-path-field-DySMzOF6.js} +1 -1
- package/dist/gateway/static/root/assets/dist-By6Rh2ee.js +1 -0
- package/dist/gateway/static/root/assets/dist-CkobR7mk.js +1 -0
- package/dist/gateway/static/root/assets/dist-DokQNVMQ.js +1 -0
- package/dist/gateway/static/root/assets/dreaming-settings-D_AjSnV_.js +3 -0
- package/dist/gateway/static/root/assets/extension-debug-page-BaM0FpW7.js +1 -0
- package/dist/gateway/static/root/assets/extension-page-DuZWVOGA.js +1 -0
- package/dist/gateway/static/root/assets/extension-settings-page-DarVtbmJ.js +1 -0
- package/dist/gateway/static/root/assets/{fetch-BU5S0Sn7.js → fetch-NFKfkqrd.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-BIPGwrl1.js → gateway-config-api-CFEm9rgy.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-BMk2S5td.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-Cd0Zz30N.js → gateway-startup-retry-Dtwh_yGg.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-BKP7ylcG.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-C2cTxf71.js +1 -0
- package/dist/gateway/static/root/assets/{goals-config-api-B95KdGMj.js → goals-config-api-DTWZNA_Y.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-CTmA3hWK.js +2 -0
- package/dist/gateway/static/root/assets/goals-settings-Bhct0ZT-.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-settings-C-UxSU4a.js +1 -0
- package/dist/gateway/static/root/assets/{html-workspace-editor-CQLWDiwE.js → html-workspace-editor-DV90ddkE.js} +1 -1
- package/dist/gateway/static/root/assets/index-BNHDd2j1.css +1 -0
- package/dist/gateway/static/root/assets/index-BPXLPMuY.js +193 -0
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-DCjy2y4d.js +1 -0
- package/dist/gateway/static/root/assets/logs-page-CGc3_CQU.js +2 -0
- package/dist/gateway/static/root/assets/{markdown-editor-AssmZFx4.js → markdown-editor-BFOjBBla.js} +2 -2
- package/dist/gateway/static/root/assets/markdown-split-BaqxP-GQ.js +1 -0
- package/dist/gateway/static/root/assets/{media-plugins-BhIQU5yS.js → media-plugins-DQ_EXloK.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CjuIJcZl.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-Drz4UQMb.js +2 -0
- package/dist/gateway/static/root/assets/notes-page-CY1ylng1.js +1 -0
- package/dist/gateway/static/root/assets/notes-workbench-X7IaD--t.js +2 -0
- package/dist/gateway/static/root/assets/page-tabs-EIZhLppK.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DGzet1d7.js → preview-open-alternatives-r_uB4Epr.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DE5adRBE.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-CuOb1k6F.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-BOxNrUVA.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-Cqgb-jqa.js → save-bar-controls-B132Uf-2.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-DVZcI8Yt.js → schedule-field-B5qshALm.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-Bj7sOxC8.js → schema-form-CvLmkdS9.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-CY0IQcGW.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-D4NBNVCB.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-BmXn-8N6.js → settings-collapsible-section-pRlvqsAf.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-BnqYMWHR.js → settings-form-section-BBYUDLVd.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-DaO7zYZM.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-CdWZU1hd.js → settings-page-layout-D8g9PAek.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Bks0CLLT.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-IB1v8i86.js → share-preview-page-v6-IOp8t.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CEZsKm9r.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-oTkHbb9W.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DigsbZ6K.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-BxQ384RC.js → system-settings-panel-HUU2FFjM.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-BkcpvFYO.js → typed-models-lib-AH160QHh.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-Cd0FaEQ4.js → use-channel-catalog-BXzDmjCQ.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-DQ7NnRSY.js → user-profile-settings-panel-DxwnQvQ3.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-YKhVf7Ka.js → utils-i5POEtqd.js} +1 -1
- package/dist/gateway/static/root/assets/{vendor-codemirror-CNP1wPe7.js → vendor-codemirror-BvNgyE1Q.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-CEJklEgb.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-CD6FL_Rs.js +1 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-ClVVMgN-.js +3 -0
- package/dist/gateway/static/root/assets/{workflow-start-dialog-BNJVCWoS.js → workflow-start-dialog-Dv4ZA1T0.js} +1 -1
- package/dist/gateway/static/root/assets/workflows-page-OLQiUpoW.js +18 -0
- package/dist/gateway/static/root/index.html +8 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +6 -2
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/child-agent-factory.d.ts +2 -0
- package/dist/src/agent/child-agent-factory.js +2 -0
- package/dist/src/agent/child-agent-factory.js.map +1 -1
- package/dist/src/agent/coding/index.d.ts +1 -0
- package/dist/src/agent/coding/index.js +2 -0
- package/dist/src/agent/coding/turn-diff-tracker.d.ts +67 -0
- package/dist/src/agent/coding/turn-diff-tracker.js +233 -0
- package/dist/src/agent/coding/turn-diff-tracker.js.map +1 -0
- package/dist/src/agent/memory/dreaming/config.d.ts +2 -2
- package/dist/src/agent/memory/dreaming/config.js +3 -3
- package/dist/src/agent/memory/dreaming/config.js.map +1 -1
- package/dist/src/agent/memory/dreaming/constants.d.ts +1 -1
- package/dist/src/agent/memory/dreaming/constants.js +1 -1
- package/dist/src/agent/memory/dreaming/constants.js.map +1 -1
- package/dist/src/agent/memory/dreaming/deep-promotion.d.ts +1 -0
- package/dist/src/agent/memory/dreaming/deep-promotion.js +11 -20
- package/dist/src/agent/memory/dreaming/deep-promotion.js.map +1 -1
- package/dist/src/agent/memory/dreaming/events.d.ts +3 -3
- package/dist/src/agent/memory/dreaming/events.js +6 -6
- package/dist/src/agent/memory/dreaming/events.js.map +1 -1
- package/dist/src/agent/memory/dreaming/last-run.d.ts +2 -2
- package/dist/src/agent/memory/dreaming/last-run.js +1 -1
- package/dist/src/agent/memory/dreaming/last-run.js.map +1 -1
- package/dist/src/agent/memory/dreaming/light-sweep.d.ts +1 -1
- package/dist/src/agent/memory/dreaming/light-sweep.js +3 -3
- package/dist/src/agent/memory/dreaming/light-sweep.js.map +1 -1
- package/dist/src/agent/memory/dreaming/preview.d.ts +1 -0
- package/dist/src/agent/memory/dreaming/preview.js +2 -2
- package/dist/src/agent/memory/dreaming/preview.js.map +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.d.ts +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.js +13 -13
- package/dist/src/agent/memory/dreaming/rem-patterns.js.map +1 -1
- package/dist/src/agent/memory/dreaming/scope.d.ts +14 -0
- package/dist/src/agent/memory/dreaming/scope.js +27 -0
- package/dist/src/agent/memory/dreaming/scope.js.map +1 -0
- package/dist/src/agent/memory/dreaming/short-term-store.d.ts +4 -4
- package/dist/src/agent/memory/dreaming/short-term-store.js +17 -17
- package/dist/src/agent/memory/dreaming/short-term-store.js.map +1 -1
- package/dist/src/agent/orchestration/agent-event-handler.d.ts +2 -0
- package/dist/src/agent/orchestration/agent-event-handler.js +13 -0
- package/dist/src/agent/orchestration/agent-event-handler.js.map +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js +22 -12
- package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
- package/dist/src/agent/sandbox/command-validator.js +12 -0
- package/dist/src/agent/sandbox/command-validator.js.map +1 -1
- package/dist/src/agent/service.d.ts +2 -1
- package/dist/src/agent/service.js +18 -6
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/session/session-inspector.d.ts +5 -3
- package/dist/src/agent/session/session-inspector.js +16 -7
- package/dist/src/agent/session/session-inspector.js.map +1 -1
- package/dist/src/agent/source-context/types.d.ts +1 -1
- package/dist/src/agent/source-context/types.js +1 -1
- package/dist/src/agent/source-context/types.js.map +1 -1
- package/dist/src/agent/tools/apply-patch.js +116 -62
- package/dist/src/agent/tools/apply-patch.js.map +1 -1
- package/dist/src/agent/tools/concurrency.d.ts +8 -0
- package/dist/src/agent/tools/concurrency.js +31 -0
- package/dist/src/agent/tools/concurrency.js.map +1 -0
- package/dist/src/agent/tools/dreaming-tool.d.ts +2 -0
- package/dist/src/agent/tools/dreaming-tool.js +13 -10
- package/dist/src/agent/tools/dreaming-tool.js.map +1 -1
- package/dist/src/agent/tools/exec-command.js +4 -0
- package/dist/src/agent/tools/exec-command.js.map +1 -1
- package/dist/src/agent/tools/executor.d.ts +6 -4
- package/dist/src/agent/tools/executor.js +7 -4
- package/dist/src/agent/tools/executor.js.map +1 -1
- package/dist/src/agent/tools/factory.d.ts +3 -0
- package/dist/src/agent/tools/factory.js +7 -1
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/find.js +2 -0
- package/dist/src/agent/tools/find.js.map +1 -1
- package/dist/src/agent/tools/grep.js +2 -0
- package/dist/src/agent/tools/grep.js.map +1 -1
- package/dist/src/agent/tools/index.d.ts +2 -0
- package/dist/src/agent/tools/index.js +3 -1
- package/dist/src/agent/tools/list-dir.js +2 -0
- package/dist/src/agent/tools/list-dir.js.map +1 -1
- package/dist/src/agent/tools/memory-tool.d.ts +1 -0
- package/dist/src/agent/tools/memory-tool.js +2 -2
- package/dist/src/agent/tools/memory-tool.js.map +1 -1
- package/dist/src/agent/tools/metadata.d.ts +15 -0
- package/dist/src/agent/tools/metadata.js +26 -0
- package/dist/src/agent/tools/metadata.js.map +1 -0
- package/dist/src/agent/tools/read.js +2 -0
- package/dist/src/agent/tools/read.js.map +1 -1
- package/dist/src/agent/tools/write.js +6 -0
- package/dist/src/agent/tools/write.js.map +1 -1
- package/dist/src/agent/workflow/subagent-runner.d.ts +1 -0
- package/dist/src/agent/workflow/subagent-runner.js +5 -1
- package/dist/src/agent/workflow/subagent-runner.js.map +1 -1
- package/dist/src/agent/workflow/workflow-child-tools.js +5 -0
- package/dist/src/agent/workflow/workflow-child-tools.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/connectors/health.d.ts +2 -1
- package/dist/src/connectors/health.js +59 -1
- package/dist/src/connectors/health.js.map +1 -1
- package/dist/src/connectors/install.d.ts +1 -0
- package/dist/src/connectors/install.js +28 -1
- package/dist/src/connectors/install.js.map +1 -1
- package/dist/src/connectors/instances.js +7 -0
- package/dist/src/connectors/instances.js.map +1 -1
- package/dist/src/connectors/materialize.js +2 -1
- package/dist/src/connectors/materialize.js.map +1 -1
- package/dist/src/connectors/registries/modelscope.js +38 -13
- package/dist/src/connectors/registries/modelscope.js.map +1 -1
- package/dist/src/connectors/types.d.ts +2 -0
- package/dist/src/gateway/dreaming-automation-reconciler.d.ts +1 -0
- package/dist/src/gateway/dreaming-automation-reconciler.js +62 -42
- package/dist/src/gateway/dreaming-automation-reconciler.js.map +1 -1
- package/dist/src/gateway/hono/app.js +7 -1
- package/dist/src/gateway/hono/app.js.map +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +46 -2
- package/dist/src/gateway/hono/routes/connectors.js.map +1 -1
- package/dist/src/gateway/hono/routes/dreaming.js +111 -66
- package/dist/src/gateway/hono/routes/dreaming.js.map +1 -1
- package/dist/src/gateway/hono/routes/projects.js +846 -43
- package/dist/src/gateway/hono/routes/projects.js.map +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +1 -0
- package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
- package/dist/src/gateway/service.js +17 -8
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/media/store.js +1 -1
- package/dist/src/media/store.js.map +1 -1
- package/dist/src/media/types.d.ts +1 -1
- package/dist/src/media/uri.js +2 -1
- package/dist/src/media/uri.js.map +1 -1
- package/dist/src/session/session-context-for-llm.d.ts +2 -0
- package/dist/src/session/session-context-for-llm.js +14 -1
- package/dist/src/session/session-context-for-llm.js.map +1 -1
- package/dist/src/session/store.js +2 -2
- package/dist/src/session/store.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/022_work_items.sql +61 -0
- package/dist/src/storage/sqlite/migrations/023_work_item_attachments.sql +15 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +78 -0
- package/dist/src/tui/components/assistant-message.js +12 -2
- package/dist/src/tui/components/assistant-message.js.map +1 -1
- package/dist/src/tui/components/tool-execution.d.ts +8 -0
- package/dist/src/tui/components/tool-execution.js +87 -77
- package/dist/src/tui/components/tool-execution.js.map +1 -1
- package/dist/src/tui/components/visual-truncate.d.ts +1 -0
- package/dist/src/tui/components/visual-truncate.js +28 -1
- package/dist/src/tui/components/visual-truncate.js.map +1 -1
- package/dist/src/tui/tool-summary.d.ts +22 -0
- package/dist/src/tui/tool-summary.js +212 -0
- package/dist/src/tui/tool-summary.js.map +1 -0
- package/dist/src/tui/tui-tool-diff.d.ts +15 -0
- package/dist/src/tui/tui-tool-diff.js +178 -7
- package/dist/src/tui/tui-tool-diff.js.map +1 -1
- package/dist/src/work-items/agent-context.d.ts +3 -0
- package/dist/src/work-items/agent-context.js +39 -0
- package/dist/src/work-items/agent-context.js.map +1 -0
- package/dist/src/work-items/index.d.ts +4 -0
- package/dist/src/work-items/index.js +4 -0
- package/dist/src/work-items/types.d.ts +112 -0
- package/dist/src/work-items/types.js +1 -0
- package/dist/src/work-items/work-item-service.d.ts +33 -0
- package/dist/src/work-items/work-item-service.js +180 -0
- package/dist/src/work-items/work-item-service.js.map +1 -0
- package/dist/src/work-items/work-item-store.d.ts +21 -0
- package/dist/src/work-items/work-item-store.js +302 -0
- package/dist/src/work-items/work-item-store.js.map +1 -0
- package/dist/src/workflows/service/workflow-run-service.js +4 -3
- package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
- package/dist/src/workflows/service/workflow-session-bridge.js +3 -0
- package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/Combination-HAlzriaz.js +0 -41
- package/dist/gateway/static/root/assets/agents-BjIxt67Z.js +0 -2
- package/dist/gateway/static/root/assets/app-management-settings-panel-CYCONLIL.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-Clw3ryKg.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-QICTeGjX.js +0 -1
- package/dist/gateway/static/root/assets/automation-suggestion-card-CU0-4nQ-.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-Car-jtiz.js +0 -1
- package/dist/gateway/static/root/assets/browser-settings-page-CMeBJzlS.js +0 -8
- package/dist/gateway/static/root/assets/capability-presets-api-BmQTM9Il.js +0 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DZEJEoCF.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-kkW-xFau.js +0 -1
- package/dist/gateway/static/root/assets/code-editor-dZTY2dRW.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BvaQvO5F.js +0 -2
- package/dist/gateway/static/root/assets/dist-Mys7eFJ5.js +0 -1
- package/dist/gateway/static/root/assets/dist-wO9a2_ID.js +0 -1
- package/dist/gateway/static/root/assets/dreaming-settings-DnHO686d.js +0 -1
- package/dist/gateway/static/root/assets/extension-debug-page-BGLRuWVN.js +0 -1
- package/dist/gateway/static/root/assets/extension-page-D978ePp9.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-B6Ih4Swx.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-CMEA3r5u.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-B-KHKeXN.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-BxrSoWdj.js +0 -1
- package/dist/gateway/static/root/assets/goals-page-BTJzIl28.js +0 -2
- package/dist/gateway/static/root/assets/goals-settings-BJyEuLLm.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-wkOjYNQT.js +0 -1
- package/dist/gateway/static/root/assets/index-BLaXr6Ev.css +0 -1
- package/dist/gateway/static/root/assets/index-c_9TVr_C.js +0 -191
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-BT8T4DyC.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-CrxBJUgI.js +0 -2
- package/dist/gateway/static/root/assets/markdown-split-Dv66bO2b.js +0 -1
- package/dist/gateway/static/root/assets/messages-O6TAtdFC.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-DOOpz6y1.js +0 -2
- package/dist/gateway/static/root/assets/notes-page-Br16pK9v.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-PSJAi0ZC.js +0 -2
- package/dist/gateway/static/root/assets/project-detail-page-CIGGgKuw.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-B2grhsBt.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CXMORxBD.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-Bi2wkBzU.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-B1L3G4IA.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-BfRSHJmO.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CWtPM7RK.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-ngbsBgij.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BIe442Gv.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-BfchZRVa.js +0 -2
- package/dist/gateway/static/root/assets/voice-api-key-field-C5Ov8Uk_.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-BYD9BtOq.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-BYF29ANm.js +0 -18
|
@@ -404,6 +404,84 @@ CREATE INDEX IF NOT EXISTS idx_goals_agent_updated
|
|
|
404
404
|
CREATE INDEX IF NOT EXISTS idx_goals_active_session
|
|
405
405
|
ON goals(active_session_key);
|
|
406
406
|
|
|
407
|
+
CREATE TABLE IF NOT EXISTS work_items (
|
|
408
|
+
id TEXT PRIMARY KEY,
|
|
409
|
+
project_id TEXT NOT NULL,
|
|
410
|
+
title TEXT NOT NULL,
|
|
411
|
+
description TEXT,
|
|
412
|
+
status TEXT NOT NULL,
|
|
413
|
+
priority TEXT NOT NULL DEFAULT 'normal',
|
|
414
|
+
owner_agent_id TEXT,
|
|
415
|
+
next_action TEXT,
|
|
416
|
+
blocked_reason TEXT,
|
|
417
|
+
due_at INTEGER,
|
|
418
|
+
completed_at INTEGER,
|
|
419
|
+
archived_at INTEGER,
|
|
420
|
+
created_at INTEGER NOT NULL,
|
|
421
|
+
updated_at INTEGER NOT NULL
|
|
422
|
+
);
|
|
423
|
+
|
|
424
|
+
CREATE INDEX IF NOT EXISTS idx_work_items_project_status
|
|
425
|
+
ON work_items(project_id, status, archived_at, updated_at DESC);
|
|
426
|
+
|
|
427
|
+
CREATE TABLE IF NOT EXISTS work_item_links (
|
|
428
|
+
id TEXT PRIMARY KEY,
|
|
429
|
+
work_item_id TEXT NOT NULL,
|
|
430
|
+
kind TEXT NOT NULL,
|
|
431
|
+
target_id TEXT NOT NULL,
|
|
432
|
+
title TEXT,
|
|
433
|
+
status_snapshot TEXT,
|
|
434
|
+
created_at INTEGER NOT NULL
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
CREATE INDEX IF NOT EXISTS idx_work_item_links_item
|
|
438
|
+
ON work_item_links(work_item_id, created_at DESC);
|
|
439
|
+
|
|
440
|
+
CREATE TABLE IF NOT EXISTS work_item_events (
|
|
441
|
+
id TEXT PRIMARY KEY,
|
|
442
|
+
work_item_id TEXT NOT NULL,
|
|
443
|
+
type TEXT NOT NULL,
|
|
444
|
+
payload_json TEXT,
|
|
445
|
+
created_at INTEGER NOT NULL
|
|
446
|
+
);
|
|
447
|
+
|
|
448
|
+
CREATE INDEX IF NOT EXISTS idx_work_item_events_item
|
|
449
|
+
ON work_item_events(work_item_id, created_at DESC);
|
|
450
|
+
|
|
451
|
+
CREATE TABLE IF NOT EXISTS work_item_attachments (
|
|
452
|
+
id TEXT PRIMARY KEY,
|
|
453
|
+
work_item_id TEXT NOT NULL,
|
|
454
|
+
media_uri TEXT NOT NULL,
|
|
455
|
+
media_id TEXT NOT NULL,
|
|
456
|
+
bucket TEXT NOT NULL,
|
|
457
|
+
type TEXT NOT NULL,
|
|
458
|
+
mime_type TEXT NOT NULL,
|
|
459
|
+
file_name TEXT NOT NULL,
|
|
460
|
+
size INTEGER NOT NULL,
|
|
461
|
+
created_at INTEGER NOT NULL
|
|
462
|
+
);
|
|
463
|
+
|
|
464
|
+
CREATE INDEX IF NOT EXISTS idx_work_item_attachments_item
|
|
465
|
+
ON work_item_attachments(work_item_id, created_at DESC);
|
|
466
|
+
|
|
467
|
+
CREATE TABLE IF NOT EXISTS work_item_update_suggestions (
|
|
468
|
+
id TEXT PRIMARY KEY,
|
|
469
|
+
work_item_id TEXT NOT NULL,
|
|
470
|
+
source_kind TEXT NOT NULL,
|
|
471
|
+
source_id TEXT NOT NULL,
|
|
472
|
+
status TEXT NOT NULL,
|
|
473
|
+
patch_json TEXT NOT NULL DEFAULT '{}',
|
|
474
|
+
progress_note TEXT,
|
|
475
|
+
rationale TEXT,
|
|
476
|
+
confidence REAL,
|
|
477
|
+
created_at INTEGER NOT NULL,
|
|
478
|
+
applied_at INTEGER,
|
|
479
|
+
dismissed_at INTEGER
|
|
480
|
+
);
|
|
481
|
+
|
|
482
|
+
CREATE INDEX IF NOT EXISTS idx_work_item_update_suggestions_item
|
|
483
|
+
ON work_item_update_suggestions(work_item_id, status, created_at DESC);
|
|
484
|
+
|
|
407
485
|
CREATE TABLE IF NOT EXISTS goal_context_messages (
|
|
408
486
|
goal_id TEXT PRIMARY KEY,
|
|
409
487
|
text TEXT NOT NULL DEFAULT '',
|
|
@@ -16,6 +16,16 @@ function blockText(block, key) {
|
|
|
16
16
|
const value = block[key];
|
|
17
17
|
return typeof value === "string" ? value : "";
|
|
18
18
|
}
|
|
19
|
+
function compactToolAdjacentText(text, linkedToolCall) {
|
|
20
|
+
if (!linkedToolCall) return text;
|
|
21
|
+
return text.split("\n").filter((line) => !isMechanicalToolSummaryLine(line)).join("\n").trim();
|
|
22
|
+
}
|
|
23
|
+
function isMechanicalToolSummaryLine(line) {
|
|
24
|
+
const normalized = line.trim();
|
|
25
|
+
if (!normalized) return false;
|
|
26
|
+
const withoutBullet = normalized.replace(/^[-*•]\s+/, "");
|
|
27
|
+
return /^(Added|Deleted|Edited|Modified|Updated)\s+.+\(\+\d+\s+-\d+\)\.?$/i.test(withoutBullet) || /^Edited\s+\d+\s+files?\s+\(\+\d+\s+-\d+\)\.?$/i.test(withoutBullet) || /^Created\s+.+\(\+\d+\s+-0\)\.?$/i.test(withoutBullet) || /^Removed\s+.+\(\+0\s+-\d+\)\.?$/i.test(withoutBullet);
|
|
28
|
+
}
|
|
19
29
|
function reviewMarkdown(block) {
|
|
20
30
|
const findings = Array.isArray(block.findings) ? block.findings : [];
|
|
21
31
|
const lines = ["Code review", ""];
|
|
@@ -109,7 +119,7 @@ var AssistantMessageComponent = class extends Container {
|
|
|
109
119
|
this.contentContainer.clear();
|
|
110
120
|
const blocks = contentBlocks(this.message);
|
|
111
121
|
const visibleBlocks = blocks.filter((block) => {
|
|
112
|
-
if (block.type === "text") return blockText(block, "text").trim().length > 0;
|
|
122
|
+
if (block.type === "text") return compactToolAdjacentText(blockText(block, "text"), this.linkedToolCall).trim().length > 0;
|
|
113
123
|
if (block.type === "thinking") return blockText(block, "thinking").trim().length > 0;
|
|
114
124
|
if (block.type === "image" || block.type === "image_url") return true;
|
|
115
125
|
if (block.type === "review") return true;
|
|
@@ -123,7 +133,7 @@ var AssistantMessageComponent = class extends Container {
|
|
|
123
133
|
for (let i = 0; i < blocks.length; i++) {
|
|
124
134
|
const block = blocks[i];
|
|
125
135
|
if (block.type === "text") {
|
|
126
|
-
const text = blockText(block, "text").trim();
|
|
136
|
+
const text = compactToolAdjacentText(blockText(block, "text"), this.linkedToolCall).trim();
|
|
127
137
|
if (!text) continue;
|
|
128
138
|
if (renderedVisible > 0) this.contentContainer.addChild(new Spacer(1));
|
|
129
139
|
this.contentContainer.addChild(new Markdown(text, 1, 0, markdownTheme, { color: (line) => theme.assistantText(line) }, { preserveOrderedListMarkers: true }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-message.js","names":[],"sources":["../../../../src/tui/components/assistant-message.ts"],"sourcesContent":["import type { AgentMessage } from '@earendil-works/pi-agent-core';\nimport { Container, Markdown, Spacer, Text } from '@earendil-works/pi-tui';\n\nimport { markdownTheme, theme } from '../theme.js';\n\nconst OSC133_ZONE_START = '\\x1b]133;A\\x07';\nconst OSC133_ZONE_END = '\\x1b]133;B\\x07';\nconst OSC133_ZONE_FINAL = '\\x1b]133;C\\x07';\n\nexport type AssistantMessageOptions = {\n hideThinkingBlock?: boolean;\n hiddenThinkingLabel?: string;\n};\n\ntype ContentBlock = Record<string, unknown> & { type?: string };\n\nfunction contentBlocks(message: AgentMessage | undefined): ContentBlock[] {\n const content = (message as { content?: unknown } | undefined)?.content;\n if (typeof content === 'string') {\n return content.trim() ? [{ type: 'text', text: content }] : [];\n }\n return Array.isArray(content)\n ? content.filter((block): block is ContentBlock => !!block && typeof block === 'object')\n : [];\n}\n\nfunction blockText(block: ContentBlock, key: 'text' | 'thinking'): string {\n const value = block[key];\n return typeof value === 'string' ? value : '';\n}\n\nfunction reviewMarkdown(block: ContentBlock): string {\n const findings = Array.isArray(block.findings) ? block.findings : [];\n const lines: string[] = ['Code review', ''];\n if (findings.length === 0) {\n lines.push('No findings.');\n } else {\n lines.push('Findings:');\n for (const item of findings) {\n if (!item || typeof item !== 'object' || Array.isArray(item)) continue;\n const rec = item as Record<string, unknown>;\n const title = typeof rec.title === 'string' ? rec.title : '';\n const body = typeof rec.body === 'string' ? rec.body : '';\n const priority = typeof rec.priority === 'number' ? rec.priority : 2;\n const filePath = typeof rec.filePath === 'string' ? rec.filePath : '';\n const lineStart = typeof rec.lineStart === 'number' ? rec.lineStart : undefined;\n const lineEnd = typeof rec.lineEnd === 'number' ? rec.lineEnd : undefined;\n const loc = filePath\n ? `${filePath}${lineStart ? `:${lineStart}${lineEnd && lineEnd !== lineStart ? `-${lineEnd}` : ''}` : ''}`\n : '';\n const suffix = loc ? ` - ${loc}` : '';\n lines.push(`- [P${priority}] ${title || body.slice(0, 80)}${suffix}`);\n if (body) lines.push(` ${body.replace(/\\n+/g, '\\n ')}`);\n }\n }\n const correctness = typeof block.overallCorrectness === 'string' ? block.overallCorrectness : 'unknown';\n const explanation = typeof block.overallExplanation === 'string' ? block.overallExplanation : '';\n lines.push('');\n lines.push(`Overall correctness: ${correctness}`);\n if (explanation) lines.push(explanation);\n return lines.join('\\n');\n}\n\nfunction hasToolCalls(message: AgentMessage | undefined): boolean {\n return contentBlocks(message).some((block) => block.type === 'toolCall' || block.type === 'tool_use');\n}\n\nfunction stopReason(message: AgentMessage | undefined): string | undefined {\n return (message as { stopReason?: string } | undefined)?.stopReason;\n}\n\nfunction errorMessage(message: AgentMessage | undefined): string | undefined {\n return (message as { errorMessage?: string } | undefined)?.errorMessage;\n}\n\nexport function createAssistantMessageFromText(text: string): AgentMessage {\n return {\n role: 'assistant',\n content: [{ type: 'text', text }],\n timestamp: Date.now(),\n } as AgentMessage;\n}\n\nexport class AssistantMessageComponent extends Container {\n private readonly contentContainer = new Container();\n private message: AgentMessage | undefined;\n private linkedToolCall = false;\n private hideThinkingBlock = false;\n private hiddenThinkingLabel = 'Thinking...';\n\n constructor(message?: AgentMessage, options: AssistantMessageOptions = {}) {\n super();\n this.hideThinkingBlock = options.hideThinkingBlock ?? false;\n this.hiddenThinkingLabel = options.hiddenThinkingLabel ?? 'Thinking...';\n this.addChild(this.contentContainer);\n if (message) {\n this.updateContent(message);\n }\n }\n\n updateContent(message: AgentMessage): void {\n this.message = message;\n this.refresh();\n }\n\n setHasToolCalls(hasTools: boolean): void {\n this.linkedToolCall = hasTools;\n this.refresh();\n }\n\n setHideThinkingBlock(hide: boolean): void {\n if (this.hideThinkingBlock === hide) return;\n this.hideThinkingBlock = hide;\n this.refresh();\n }\n\n setHiddenThinkingLabel(label: string): void {\n if (this.hiddenThinkingLabel === label) return;\n this.hiddenThinkingLabel = label;\n this.refresh();\n }\n\n override invalidate(): void {\n super.invalidate();\n this.refresh();\n }\n\n override render(width: number): string[] {\n const lines = super.render(width);\n if (hasToolCalls(this.message) || this.linkedToolCall || lines.length === 0) return lines;\n lines[0] = OSC133_ZONE_START + lines[0];\n lines[lines.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + lines[lines.length - 1];\n return lines;\n }\n\n private refresh(): void {\n this.contentContainer.clear();\n const blocks = contentBlocks(this.message);\n const visibleBlocks = blocks.filter((block) => {\n if (block.type === 'text') return blockText(block, 'text').trim().length > 0;\n if (block.type === 'thinking') return blockText(block, 'thinking').trim().length > 0;\n if (block.type === 'image' || block.type === 'image_url') return true;\n if (block.type === 'review') return true;\n return false;\n });\n const reason = stopReason(this.message);\n const hasErrorState =\n !hasToolCalls(this.message) && !this.linkedToolCall && (reason === 'aborted' || reason === 'error');\n if (visibleBlocks.length === 0 && !hasErrorState) return;\n\n this.contentContainer.addChild(new Spacer(1));\n let renderedVisible = 0;\n for (let i = 0; i < blocks.length; i++) {\n const block = blocks[i]!;\n if (block.type === 'text') {\n const text = blockText(block, 'text').trim();\n if (!text) continue;\n if (renderedVisible > 0) this.contentContainer.addChild(new Spacer(1));\n this.contentContainer.addChild(\n new Markdown(\n text,\n 1,\n 0,\n markdownTheme,\n { color: (line) => theme.assistantText(line) },\n { preserveOrderedListMarkers: true },\n ),\n );\n renderedVisible++;\n } else if (block.type === 'thinking') {\n const thinking = blockText(block, 'thinking').trim();\n if (!thinking) continue;\n if (renderedVisible > 0) this.contentContainer.addChild(new Spacer(1));\n const text = this.hideThinkingBlock ? this.hiddenThinkingLabel : thinking;\n this.contentContainer.addChild(\n new Markdown(\n text,\n 1,\n 0,\n markdownTheme,\n { color: (line) => theme.dim(theme.italic(line)) },\n { preserveOrderedListMarkers: true },\n ),\n );\n renderedVisible++;\n } else if (block.type === 'image' || block.type === 'image_url') {\n if (renderedVisible > 0) this.contentContainer.addChild(new Spacer(1));\n this.contentContainer.addChild(new Text(theme.dim('[image]'), 1, 0));\n renderedVisible++;\n } else if (block.type === 'review') {\n const text = reviewMarkdown(block).trim();\n if (!text) continue;\n if (renderedVisible > 0) this.contentContainer.addChild(new Spacer(1));\n this.contentContainer.addChild(\n new Markdown(\n text,\n 1,\n 0,\n markdownTheme,\n { color: (line) => theme.assistantText(line) },\n { preserveOrderedListMarkers: true },\n ),\n );\n renderedVisible++;\n }\n }\n\n if (hasErrorState) {\n if (renderedVisible > 0) this.contentContainer.addChild(new Spacer(1));\n const text =\n reason === 'aborted'\n ? errorMessage(this.message) && errorMessage(this.message) !== 'Request was aborted'\n ? errorMessage(this.message)!\n : 'Operation aborted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K,iBAAiB,SAAS,IAAI,OAAO,EAAE,CAAC;GACtE,MAAM,OACJ,WAAW,YACP,aAAa,KAAK,QAAQ,IAAI,aAAa,KAAK,QAAQ,KAAK,wBAC3D,aAAa,KAAK,QAAQ,GAC1B,sBACF,UAAU,aAAa,KAAK,QAAQ,IAAI;AAC9C,QAAK,iBAAiB,SAAS,IAAI,KAAK,MAAM,MAAM,KAAK,EAAE,GAAG,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"assistant-message.js","names":[],"sources":["../../../../src/tui/components/assistant-message.ts"],"sourcesContent":["import type { AgentMessage } from '@earendil-works/pi-agent-core';\nimport { Container, Markdown, Spacer, Text } from '@earendil-works/pi-tui';\n\nimport { markdownTheme, theme } from '../theme.js';\n\nconst OSC133_ZONE_START = '\\x1b]133;A\\x07';\nconst OSC133_ZONE_END = '\\x1b]133;B\\x07';\nconst OSC133_ZONE_FINAL = '\\x1b]133;C\\x07';\n\nexport type AssistantMessageOptions = {\n hideThinkingBlock?: boolean;\n hiddenThinkingLabel?: string;\n};\n\ntype ContentBlock = Record<string, unknown> & { type?: string };\n\nfunction contentBlocks(message: AgentMessage | undefined): ContentBlock[] {\n const content = (message as { content?: unknown } | undefined)?.content;\n if (typeof content === 'string') {\n return content.trim() ? [{ type: 'text', text: content }] : [];\n }\n return Array.isArray(content)\n ? content.filter((block): block is ContentBlock => !!block && typeof block === 'object')\n : [];\n}\n\nfunction blockText(block: ContentBlock, key: 'text' | 'thinking'): string {\n const value = block[key];\n return typeof value === 'string' ? value : '';\n}\n\nfunction compactToolAdjacentText(text: string, linkedToolCall: boolean): string {\n if (!linkedToolCall) return text;\n const lines = text.split('\\n');\n const kept = lines.filter((line) => !isMechanicalToolSummaryLine(line));\n return kept.join('\\n').trim();\n}\n\nfunction isMechanicalToolSummaryLine(line: string): boolean {\n const normalized = line.trim();\n if (!normalized) return false;\n const withoutBullet = normalized.replace(/^[-*•]\\s+/, '');\n return (\n /^(Added|Deleted|Edited|Modified|Updated)\\s+.+\\(\\+\\d+\\s+-\\d+\\)\\.?$/i.test(withoutBullet) ||\n /^Edited\\s+\\d+\\s+files?\\s+\\(\\+\\d+\\s+-\\d+\\)\\.?$/i.test(withoutBullet) ||\n /^Created\\s+.+\\(\\+\\d+\\s+-0\\)\\.?$/i.test(withoutBullet) ||\n /^Removed\\s+.+\\(\\+0\\s+-\\d+\\)\\.?$/i.test(withoutBullet)\n );\n}\n\nfunction reviewMarkdown(block: ContentBlock): string {\n const findings = Array.isArray(block.findings) ? block.findings : [];\n const lines: string[] = ['Code review', ''];\n if (findings.length === 0) {\n lines.push('No findings.');\n } else {\n lines.push('Findings:');\n for (const item of findings) {\n if (!item || typeof item !== 'object' || Array.isArray(item)) continue;\n const rec = item as Record<string, unknown>;\n const title = typeof rec.title === 'string' ? rec.title : '';\n const body = typeof rec.body === 'string' ? rec.body : '';\n const priority = typeof rec.priority === 'number' ? rec.priority : 2;\n const filePath = typeof rec.filePath === 'string' ? rec.filePath : '';\n const lineStart = typeof rec.lineStart === 'number' ? rec.lineStart : undefined;\n const lineEnd = typeof rec.lineEnd === 'number' ? rec.lineEnd : undefined;\n const loc = filePath\n ? `${filePath}${lineStart ? `:${lineStart}${lineEnd && lineEnd !== lineStart ? `-${lineEnd}` : ''}` : ''}`\n : '';\n const suffix = loc ? ` - ${loc}` : '';\n lines.push(`- [P${priority}] ${title || body.slice(0, 80)}${suffix}`);\n if (body) lines.push(` ${body.replace(/\\n+/g, '\\n ')}`);\n }\n }\n const correctness = typeof block.overallCorrectness === 'string' ? block.overallCorrectness : 'unknown';\n const explanation = typeof block.overallExplanation === 'string' ? block.overallExplanation : '';\n lines.push('');\n lines.push(`Overall correctness: ${correctness}`);\n if (explanation) lines.push(explanation);\n return lines.join('\\n');\n}\n\nfunction hasToolCalls(message: AgentMessage | undefined): boolean {\n return contentBlocks(message).some((block) => block.type === 'toolCall' || block.type === 'tool_use');\n}\n\nfunction stopReason(message: AgentMessage | undefined): string | undefined {\n return (message as { stopReason?: string } | undefined)?.stopReason;\n}\n\nfunction errorMessage(message: AgentMessage | undefined): string | undefined {\n return (message as { errorMessage?: string } | undefined)?.errorMessage;\n}\n\nexport function createAssistantMessageFromText(text: string): AgentMessage {\n return {\n role: 'assistant',\n content: [{ type: 'text', text }],\n timestamp: Date.now(),\n } as AgentMessage;\n}\n\nexport class AssistantMessageComponent extends Container {\n private readonly contentContainer = new Container();\n private message: AgentMessage | undefined;\n private linkedToolCall = false;\n private hideThinkingBlock = false;\n private hiddenThinkingLabel = 'Thinking...';\n\n constructor(message?: AgentMessage, options: AssistantMessageOptions = {}) {\n super();\n this.hideThinkingBlock = options.hideThinkingBlock ?? false;\n this.hiddenThinkingLabel = options.hiddenThinkingLabel ?? 'Thinking...';\n this.addChild(this.contentContainer);\n if (message) {\n this.updateContent(message);\n }\n }\n\n updateContent(message: AgentMessage): void {\n this.message = message;\n this.refresh();\n }\n\n setHasToolCalls(hasTools: boolean): void {\n this.linkedToolCall = hasTools;\n this.refresh();\n }\n\n setHideThinkingBlock(hide: boolean): void {\n if (this.hideThinkingBlock === hide) return;\n this.hideThinkingBlock = hide;\n this.refresh();\n }\n\n setHiddenThinkingLabel(label: string): void {\n if (this.hiddenThinkingLabel === label) return;\n this.hiddenThinkingLabel = label;\n this.refresh();\n }\n\n override invalidate(): void {\n super.invalidate();\n this.refresh();\n }\n\n override render(width: number): string[] {\n const lines = super.render(width);\n if (hasToolCalls(this.message) || this.linkedToolCall || lines.length === 0) return lines;\n lines[0] = OSC133_ZONE_START + lines[0];\n lines[lines.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + lines[lines.length - 1];\n return lines;\n }\n\n private refresh(): void {\n this.contentContainer.clear();\n const blocks = contentBlocks(this.message);\n const visibleBlocks = blocks.filter((block) => {\n if (block.type === 'text') {\n return compactToolAdjacentText(blockText(block, 'text'), this.linkedToolCall).trim().length > 0;\n }\n if (block.type === 'thinking') return blockText(block, 'thinking').trim().length > 0;\n if (block.type === 'image' || block.type === 'image_url') return true;\n if (block.type === 'review') return true;\n return false;\n });\n const reason = stopReason(this.message);\n const hasErrorState =\n !hasToolCalls(this.message) && !this.linkedToolCall && (reason === 'aborted' || reason === 'error');\n if (visibleBlocks.length === 0 && !hasErrorState) return;\n\n this.contentContainer.addChild(new Spacer(1));\n let renderedVisible = 0;\n for (let i = 0; i < blocks.length; i++) {\n const block = blocks[i]!;\n if (block.type === 'text') {\n const text = compactToolAdjacentText(blockText(block, 'text'), this.linkedToolCall).trim();\n if (!text) continue;\n if (renderedVisible > 0) this.contentContainer.addChild(new Spacer(1));\n this.contentContainer.addChild(\n new Markdown(\n text,\n 1,\n 0,\n markdownTheme,\n { color: (line) => theme.assistantText(line) },\n { preserveOrderedListMarkers: true },\n ),\n );\n renderedVisible++;\n } else if (block.type === 'thinking') {\n const thinking = blockText(block, 'thinking').trim();\n if (!thinking) continue;\n if (renderedVisible > 0) this.contentContainer.addChild(new Spacer(1));\n const text = this.hideThinkingBlock ? this.hiddenThinkingLabel : thinking;\n this.contentContainer.addChild(\n new Markdown(\n text,\n 1,\n 0,\n markdownTheme,\n { color: (line) => theme.dim(theme.italic(line)) },\n { preserveOrderedListMarkers: true },\n ),\n );\n renderedVisible++;\n } else if (block.type === 'image' || block.type === 'image_url') {\n if (renderedVisible > 0) this.contentContainer.addChild(new Spacer(1));\n this.contentContainer.addChild(new Text(theme.dim('[image]'), 1, 0));\n renderedVisible++;\n } else if (block.type === 'review') {\n const text = reviewMarkdown(block).trim();\n if (!text) continue;\n if (renderedVisible > 0) this.contentContainer.addChild(new Spacer(1));\n this.contentContainer.addChild(\n new Markdown(\n text,\n 1,\n 0,\n markdownTheme,\n { color: (line) => theme.assistantText(line) },\n { preserveOrderedListMarkers: true },\n ),\n );\n renderedVisible++;\n }\n }\n\n if (hasErrorState) {\n if (renderedVisible > 0) this.contentContainer.addChild(new Spacer(1));\n const text =\n reason === 'aborted'\n ? errorMessage(this.message) && errorMessage(this.message) !== 'Request was aborted'\n ? errorMessage(this.message)!\n : 'Operation aborted'\n : `Error: ${errorMessage(this.message) || 'Unknown error'}`;\n this.contentContainer.addChild(new Text(theme.error(text), 1, 0));\n }\n }\n}\n"],"mappings":";;;AAKA,MAAM,oBAAoB;AAC1B,MAAM,kBAAkB;AACxB,MAAM,oBAAoB;AAS1B,SAAS,cAAc,SAAmD;CACxE,MAAM,UAAW,SAA+C;AAChE,KAAI,OAAO,YAAY,SACrB,QAAO,QAAQ,MAAM,GAAG,CAAC;EAAE,MAAM;EAAQ,MAAM;EAAS,CAAC,GAAG,EAAE;AAEhE,QAAO,MAAM,QAAQ,QAAQ,GACzB,QAAQ,QAAQ,UAAiC,CAAC,CAAC,SAAS,OAAO,UAAU,SAAS,GACtF,EAAE;;AAGR,SAAS,UAAU,OAAqB,KAAkC;CACxE,MAAM,QAAQ,MAAM;AACpB,QAAO,OAAO,UAAU,WAAW,QAAQ;;AAG7C,SAAS,wBAAwB,MAAc,gBAAiC;AAC9E,KAAI,CAAC,eAAgB,QAAO;AAG5B,QAFc,KAAK,MAAM,KACP,CAAC,QAAQ,SAAS,CAAC,4BAA4B,KAAK,CAC3D,CAAC,KAAK,KAAK,CAAC,MAAM;;AAG/B,SAAS,4BAA4B,MAAuB;CAC1D,MAAM,aAAa,KAAK,MAAM;AAC9B,KAAI,CAAC,WAAY,QAAO;CACxB,MAAM,gBAAgB,WAAW,QAAQ,aAAa,GAAG;AACzD,QACE,qEAAqE,KAAK,cAAc,IACxF,iDAAiD,KAAK,cAAc,IACpE,mCAAmC,KAAK,cAAc,IACtD,mCAAmC,KAAK,cAAc;;AAI1D,SAAS,eAAe,OAA6B;CACnD,MAAM,WAAW,MAAM,QAAQ,MAAM,SAAS,GAAG,MAAM,WAAW,EAAE;CACpE,MAAM,QAAkB,CAAC,eAAe,GAAG;AAC3C,KAAI,SAAS,WAAW,EACtB,OAAM,KAAK,eAAe;MACrB;AACL,QAAM,KAAK,YAAY;AACvB,OAAK,MAAM,QAAQ,UAAU;AAC3B,OAAI,C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AkB,EAAG,MAAK,iBAAiB,SAAS,IAAI,OAAO,EAAE,CAAC;AACtE,SAAK,iBAAiB,SAAS,IAAI,KAAK,MAAM,IAAI,UAAU,EAAE,GAAG,EAAE,CAAC;AACpE;cACS,MAAM,SAAS,UAAU;IAClC,MAAM,OAAO,eAAe,MAAM,CAAC,MAAM;AACzC,QAAI,CAAC,KAAM;AACX,QAAI,kBAAkB,EAAG,MAAK,iBAAiB,SAAS,IAAI,OAAO,EAAE,CAAC;AACtE,SAAK,iBAAiB,SACpB,IAAI,SACF,MACA,GACA,GACA,eACA,EAAE,QAAQ,SAAS,MAAM,cAAc,KAAK,EAAE,EAC9C,EAAE,4BAA4B,MAAM,CACrC,CACF;AACD;;;AAIJ,MAAI,eAAe;AACjB,OAAI,kBAAkB,EAAG,MAAK,iBAAiB,SAAS,IAAI,OAAO,EAAE,CAAC;GACtE,MAAM,OACJ,WAAW,YACP,aAAa,KAAK,QAAQ,IAAI,aAAa,KAAK,QAAQ,KAAK,wBAC3D,aAAa,KAAK,QAAQ,GAC1B,sBACF,UAAU,aAAa,KAAK,QAAQ,IAAI;AAC9C,QAAK,iBAAiB,SAAS,IAAI,KAAK,MAAM,MAAM,KAAK,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -17,6 +17,7 @@ export declare class ToolExecutionComponent extends Container {
|
|
|
17
17
|
private contentText;
|
|
18
18
|
private collapsedOutputComponent;
|
|
19
19
|
private collapsedReadSummaryComponent;
|
|
20
|
+
private expandedOutputComponent;
|
|
20
21
|
private toolName;
|
|
21
22
|
private toolCallId;
|
|
22
23
|
private args;
|
|
@@ -42,6 +43,8 @@ export declare class ToolExecutionComponent extends Container {
|
|
|
42
43
|
private isError;
|
|
43
44
|
private isPartial;
|
|
44
45
|
private executionStarted;
|
|
46
|
+
private startedAt;
|
|
47
|
+
private completedAt;
|
|
45
48
|
constructor(toolName: string, toolCallId: string, args: unknown, options?: ToolExecutionOptions);
|
|
46
49
|
setArgs(args: unknown): void;
|
|
47
50
|
markExecutionStarted(): void;
|
|
@@ -63,8 +66,13 @@ export declare class ToolExecutionComponent extends Container {
|
|
|
63
66
|
private formatToolCallFallback;
|
|
64
67
|
private formatToolResultFallback;
|
|
65
68
|
private formatToolExecution;
|
|
69
|
+
private toolStatusLabel;
|
|
70
|
+
private toolDurationLabel;
|
|
71
|
+
private collapsedSpecializedSummary;
|
|
72
|
+
private shouldRenderDetailsPreview;
|
|
66
73
|
private getDisplayResultText;
|
|
67
74
|
private refreshImages;
|
|
68
75
|
private refreshCollapsedOutput;
|
|
69
76
|
private refreshCollapsedReadSummary;
|
|
77
|
+
private refreshExpandedOutput;
|
|
70
78
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { theme } from "../theme.js";
|
|
2
2
|
import { formatKeyIds } from "../format-tui-hotkeys.js";
|
|
3
|
-
import {
|
|
3
|
+
import { displayToolName, formatArgsSummary, formatCollapsedToolSummary, formatExecExpandedOutput, getToolSummaryKind, isExecStyleTool, isReadStyleTool } from "../tool-summary.js";
|
|
4
|
+
import { isDiffFriendlyTool, looksLikeUnifiedDiff, renderPatchSummary, renderUnifiedDiff } from "../tui-tool-diff.js";
|
|
4
5
|
import { parseTuiToolResult } from "../tui-tool-result.js";
|
|
5
|
-
import { truncateToVisualLines } from "./visual-truncate.js";
|
|
6
|
+
import { truncateToVisualLines, truncateToVisualLinesMiddle } from "./visual-truncate.js";
|
|
6
7
|
import { hasStructuredTuiToolRenderer, renderToolCallWithExtensions, renderToolResultWithExtensions, renderToolWithExtensions } from "../extension-host/tool-renderers.js";
|
|
7
|
-
import { basename, dirname } from "node:path";
|
|
8
8
|
import { Container, Image, Spacer, Text, getCapabilities } from "@earendil-works/pi-tui";
|
|
9
9
|
//#region src/tui/components/tool-execution.ts
|
|
10
|
-
const MAX_ARG_VALUE_LENGTH = 120;
|
|
11
10
|
const COLLAPSED_RESULT_VISUAL_LINES = 4;
|
|
11
|
+
const EXPANDED_RESULT_VISUAL_LINES = 80;
|
|
12
12
|
function sanitize(text) {
|
|
13
13
|
return text.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "");
|
|
14
14
|
}
|
|
@@ -30,65 +30,6 @@ function getToolResultDisplayText(content, options) {
|
|
|
30
30
|
}
|
|
31
31
|
return trimTrailingBlankDisplayLines(parts.filter(Boolean).join("\n"));
|
|
32
32
|
}
|
|
33
|
-
function formatArgsSummary(args, toolName) {
|
|
34
|
-
if (!args || typeof args !== "object") return "";
|
|
35
|
-
const compactRead = isReadStyleTool(toolName) ? formatCompactReadArgs(args) : null;
|
|
36
|
-
if (compactRead) return compactRead;
|
|
37
|
-
const entries = Object.entries(args);
|
|
38
|
-
if (entries.length === 0) return "";
|
|
39
|
-
return entries.map(([key, value]) => {
|
|
40
|
-
const stringValue = formatArgValue(value);
|
|
41
|
-
return `${key}=${stringValue.length > MAX_ARG_VALUE_LENGTH ? `${stringValue.slice(0, MAX_ARG_VALUE_LENGTH - 3)}...` : stringValue}`;
|
|
42
|
-
}).join(", ");
|
|
43
|
-
}
|
|
44
|
-
function isReadStyleTool(toolName) {
|
|
45
|
-
return [
|
|
46
|
-
"read",
|
|
47
|
-
"read_file",
|
|
48
|
-
"memory_get"
|
|
49
|
-
].includes(toolName);
|
|
50
|
-
}
|
|
51
|
-
function formatCompactReadArgs(args) {
|
|
52
|
-
if (!args || typeof args !== "object") return null;
|
|
53
|
-
const record = args;
|
|
54
|
-
const rawPath = typeof record.path === "string" ? record.path : typeof record.file_path === "string" ? record.file_path : void 0;
|
|
55
|
-
if (!rawPath) return null;
|
|
56
|
-
const normalized = rawPath.replace(/\\/g, "/");
|
|
57
|
-
const base = basename(normalized);
|
|
58
|
-
let label = null;
|
|
59
|
-
if (base === "SKILL.md") {
|
|
60
|
-
const parent = basename(dirname(normalized));
|
|
61
|
-
label = parent ? `[skill] ${parent}` : "[skill]";
|
|
62
|
-
} else if (base === "AGENTS.md") label = `read resource ${normalized}`;
|
|
63
|
-
if (!label) return null;
|
|
64
|
-
const start = firstFiniteNumber(record.offset, record.from, record.start, record.line);
|
|
65
|
-
const count = firstFiniteNumber(record.limit, record.lines, record.count);
|
|
66
|
-
if (start != null && count != null && count > 0) label += `:${start}-${start + count - 1}`;
|
|
67
|
-
return label;
|
|
68
|
-
}
|
|
69
|
-
function firstFiniteNumber(...values) {
|
|
70
|
-
for (const value of values) {
|
|
71
|
-
if (typeof value === "number" && Number.isFinite(value)) return Math.floor(value);
|
|
72
|
-
if (typeof value === "string" && value.trim()) {
|
|
73
|
-
const parsed = Number(value);
|
|
74
|
-
if (Number.isFinite(parsed)) return Math.floor(parsed);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
function formatArgValue(value) {
|
|
80
|
-
if (typeof value === "string") return value;
|
|
81
|
-
if (typeof value === "bigint") return `${value.toString()}n`;
|
|
82
|
-
if (typeof value === "function") return "[function]";
|
|
83
|
-
if (typeof value === "symbol") return String(value);
|
|
84
|
-
if (value instanceof Error) return value.message || value.name;
|
|
85
|
-
try {
|
|
86
|
-
const json = JSON.stringify(value);
|
|
87
|
-
return json === void 0 ? String(value) : json;
|
|
88
|
-
} catch {
|
|
89
|
-
return String(value);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
33
|
function isTuiComponent(value) {
|
|
93
34
|
return Boolean(value && typeof value === "object" && typeof value.render === "function");
|
|
94
35
|
}
|
|
@@ -97,6 +38,7 @@ var ToolExecutionComponent = class extends Container {
|
|
|
97
38
|
contentText;
|
|
98
39
|
collapsedOutputComponent = null;
|
|
99
40
|
collapsedReadSummaryComponent = null;
|
|
41
|
+
expandedOutputComponent = null;
|
|
100
42
|
toolName;
|
|
101
43
|
toolCallId;
|
|
102
44
|
args;
|
|
@@ -122,6 +64,8 @@ var ToolExecutionComponent = class extends Container {
|
|
|
122
64
|
isError = false;
|
|
123
65
|
isPartial = true;
|
|
124
66
|
executionStarted = false;
|
|
67
|
+
startedAt = Date.now();
|
|
68
|
+
completedAt;
|
|
125
69
|
constructor(toolName, toolCallId, args, options = {}) {
|
|
126
70
|
super();
|
|
127
71
|
this.toolName = toolName;
|
|
@@ -145,6 +89,7 @@ var ToolExecutionComponent = class extends Container {
|
|
|
145
89
|
}
|
|
146
90
|
markExecutionStarted() {
|
|
147
91
|
this.executionStarted = true;
|
|
92
|
+
this.startedAt = Date.now();
|
|
148
93
|
this.refresh();
|
|
149
94
|
}
|
|
150
95
|
setArgsComplete() {
|
|
@@ -162,6 +107,7 @@ var ToolExecutionComponent = class extends Container {
|
|
|
162
107
|
this.resultDetails = parsed.envelope?.details;
|
|
163
108
|
this.isError = isError;
|
|
164
109
|
this.isPartial = isPartial;
|
|
110
|
+
if (!isPartial) this.completedAt = Date.now();
|
|
165
111
|
this.refresh();
|
|
166
112
|
}
|
|
167
113
|
setImageOptions(options) {
|
|
@@ -180,6 +126,7 @@ var ToolExecutionComponent = class extends Container {
|
|
|
180
126
|
const bgFn = this.isPartial ? (text) => theme.toolPendingBg(text) : this.isError ? (text) => theme.toolErrorBg(text) : (text) => theme.toolSuccessBg(text);
|
|
181
127
|
this.refreshCollapsedOutput(null);
|
|
182
128
|
this.refreshCollapsedReadSummary(null);
|
|
129
|
+
this.refreshExpandedOutput(null);
|
|
183
130
|
if (this.customRendererComponent) {
|
|
184
131
|
this.contentContainer.removeChild(this.customRendererComponent);
|
|
185
132
|
this.customRendererComponent = void 0;
|
|
@@ -290,8 +237,10 @@ var ToolExecutionComponent = class extends Container {
|
|
|
290
237
|
}
|
|
291
238
|
formatToolCallFallback() {
|
|
292
239
|
const argsStr = formatArgsSummary(this.args, this.toolName);
|
|
293
|
-
const titleParts = [theme.toolTitle(theme.bold(this.toolName))];
|
|
240
|
+
const titleParts = [theme.dim(this.toolStatusLabel()), theme.toolTitle(theme.bold(displayToolName(this.toolName)))];
|
|
294
241
|
if (argsStr) titleParts.push(theme.dim(`(${argsStr})`));
|
|
242
|
+
const duration = this.toolDurationLabel();
|
|
243
|
+
if (duration) titleParts.push(theme.dim(duration));
|
|
295
244
|
if (this.isPartial && !this.resultText && !this.resultContent && this.resultDetails === void 0) titleParts.push(theme.dim("…"));
|
|
296
245
|
return titleParts.join(" ");
|
|
297
246
|
}
|
|
@@ -301,18 +250,18 @@ var ToolExecutionComponent = class extends Container {
|
|
|
301
250
|
if (output) {
|
|
302
251
|
const expandKey = this.keybindings ? formatKeyIds(this.keybindings, "app.tools.expand", { capitalize: true }) : "Ctrl+O";
|
|
303
252
|
const lineCount = output.split("\n").length;
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
else if (
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
253
|
+
const useDiff = isDiffFriendlyTool(this.toolName) && looksLikeUnifiedDiff(output);
|
|
254
|
+
if (this.expanded && useDiff) text += renderPatchSummary(output) ?? renderUnifiedDiff(output);
|
|
255
|
+
else if (this.expanded && isExecStyleTool(this.toolName)) this.refreshExpandedOutput(theme.toolOutput(formatExecExpandedOutput(output, this.resultDetails)));
|
|
256
|
+
else if (this.expanded) this.refreshExpandedOutput(theme.toolOutput(output));
|
|
257
|
+
else if (useDiff) text += theme.dim("preview");
|
|
258
|
+
else if (getToolSummaryKind(this.toolName) !== "generic") text += this.collapsedSpecializedSummary(output, expandKey);
|
|
259
|
+
else {
|
|
311
260
|
const suffix = lineCount > COLLAPSED_RESULT_VISUAL_LINES ? theme.dim(` (${lineCount} lines; ${expandKey} to expand)`) : "";
|
|
312
261
|
text += theme.dim(`preview${suffix}`);
|
|
313
262
|
}
|
|
314
263
|
}
|
|
315
|
-
if (this.
|
|
264
|
+
if (this.shouldRenderDetailsPreview()) {
|
|
316
265
|
const detailsText = formatDetailsPreview(this.resultDetails);
|
|
317
266
|
if (detailsText) text = [text, theme.dim(detailsText)].filter(Boolean).join("\n");
|
|
318
267
|
}
|
|
@@ -320,28 +269,62 @@ var ToolExecutionComponent = class extends Container {
|
|
|
320
269
|
}
|
|
321
270
|
formatToolExecution() {
|
|
322
271
|
const argsStr = formatArgsSummary(this.args, this.toolName);
|
|
323
|
-
const titleParts = [theme.toolTitle(theme.bold(this.toolName))];
|
|
272
|
+
const titleParts = [theme.dim(this.toolStatusLabel()), theme.toolTitle(theme.bold(displayToolName(this.toolName)))];
|
|
324
273
|
if (argsStr) titleParts.push(theme.dim(`(${argsStr})`));
|
|
274
|
+
const duration = this.toolDurationLabel();
|
|
275
|
+
if (duration) titleParts.push(theme.dim(duration));
|
|
325
276
|
let text = titleParts.join(" ");
|
|
326
277
|
const output = this.getDisplayResultText();
|
|
327
278
|
if (output) {
|
|
328
279
|
const expandKey = this.keybindings ? formatKeyIds(this.keybindings, "app.tools.expand", { capitalize: true }) : "Ctrl+O";
|
|
329
280
|
const lineCount = output.split("\n").length;
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
else if (
|
|
281
|
+
const useDiff = isDiffFriendlyTool(this.toolName) && looksLikeUnifiedDiff(output);
|
|
282
|
+
if (this.expanded && useDiff) text += `\n${renderPatchSummary(output) ?? renderUnifiedDiff(output)}`;
|
|
283
|
+
else if (this.expanded && isExecStyleTool(this.toolName)) this.refreshExpandedOutput(theme.toolOutput(formatExecExpandedOutput(output, this.resultDetails)));
|
|
284
|
+
else if (this.expanded) this.refreshExpandedOutput(theme.toolOutput(output));
|
|
285
|
+
else if (useDiff) {
|
|
286
|
+
const suffix = output.split("\n").length > COLLAPSED_RESULT_VISUAL_LINES ? theme.dim(` (${output.split("\n").length} lines; ${expandKey} to expand)`) : "";
|
|
287
|
+
text += `\n${theme.dim(`preview${suffix}`)}`;
|
|
288
|
+
} else if (isReadStyleTool(this.toolName)) this.refreshCollapsedReadSummary(output, expandKey);
|
|
289
|
+
else if (getToolSummaryKind(this.toolName) !== "generic") text += `\n${this.collapsedSpecializedSummary(output, expandKey)}`;
|
|
333
290
|
else {
|
|
334
291
|
const suffix = lineCount > COLLAPSED_RESULT_VISUAL_LINES ? theme.dim(` (${lineCount} lines; ${expandKey} to expand)`) : "";
|
|
335
292
|
text += `\n${theme.dim(`preview${suffix}`)}`;
|
|
336
293
|
this.refreshCollapsedOutput(theme.toolOutput(output), lineCount > COLLAPSED_RESULT_VISUAL_LINES ? void 0 : `${expandKey} to expand`);
|
|
337
294
|
}
|
|
338
295
|
} else if (this.isPartial) text += `\n${theme.dim("…")}`;
|
|
339
|
-
if (this.
|
|
296
|
+
if (this.shouldRenderDetailsPreview()) {
|
|
340
297
|
const detailsText = formatDetailsPreview(this.resultDetails);
|
|
341
298
|
if (detailsText) text += `\n${theme.dim(detailsText)}`;
|
|
342
299
|
}
|
|
343
300
|
return text;
|
|
344
301
|
}
|
|
302
|
+
toolStatusLabel() {
|
|
303
|
+
if (this.isError) return "Failed";
|
|
304
|
+
if (this.isPartial && !this.resultText && !this.resultContent && this.resultDetails === void 0) return this.executionStarted ? "Calling" : "Queued";
|
|
305
|
+
if (this.isPartial) return "Calling";
|
|
306
|
+
return "Called";
|
|
307
|
+
}
|
|
308
|
+
toolDurationLabel() {
|
|
309
|
+
if (this.completedAt === void 0) return "";
|
|
310
|
+
const durationMs = Math.max(0, this.completedAt - this.startedAt);
|
|
311
|
+
if (durationMs < 100) return "";
|
|
312
|
+
return `${durationMs}ms`;
|
|
313
|
+
}
|
|
314
|
+
collapsedSpecializedSummary(output, expandKey) {
|
|
315
|
+
return theme.dim(formatCollapsedToolSummary({
|
|
316
|
+
toolName: this.toolName,
|
|
317
|
+
args: this.args,
|
|
318
|
+
output,
|
|
319
|
+
content: this.resultContent,
|
|
320
|
+
details: this.resultDetails,
|
|
321
|
+
isError: this.isError,
|
|
322
|
+
expandKey
|
|
323
|
+
}));
|
|
324
|
+
}
|
|
325
|
+
shouldRenderDetailsPreview() {
|
|
326
|
+
return this.expanded && this.resultDetails !== void 0 && !isExecStyleTool(this.toolName);
|
|
327
|
+
}
|
|
345
328
|
getDisplayResultText() {
|
|
346
329
|
if (!this.resultContent) return trimTrailingBlankDisplayLines(this.resultText);
|
|
347
330
|
return getToolResultDisplayText(this.resultContent, {
|
|
@@ -384,6 +367,15 @@ var ToolExecutionComponent = class extends Container {
|
|
|
384
367
|
this.collapsedReadSummaryComponent = createCollapsedReadSummaryComponent(text, expandKey, 1);
|
|
385
368
|
this.contentContainer.addChild(this.collapsedReadSummaryComponent);
|
|
386
369
|
}
|
|
370
|
+
refreshExpandedOutput(text) {
|
|
371
|
+
if (this.expandedOutputComponent) {
|
|
372
|
+
this.contentContainer.removeChild(this.expandedOutputComponent);
|
|
373
|
+
this.expandedOutputComponent = null;
|
|
374
|
+
}
|
|
375
|
+
if (!text) return;
|
|
376
|
+
this.expandedOutputComponent = createVisualMiddleComponent(text, EXPANDED_RESULT_VISUAL_LINES, 1);
|
|
377
|
+
this.contentContainer.addChild(this.expandedOutputComponent);
|
|
378
|
+
}
|
|
387
379
|
};
|
|
388
380
|
function formatDetailsPreview(details) {
|
|
389
381
|
if (details === null) return "";
|
|
@@ -412,6 +404,24 @@ function createVisualTailComponent(text, maxVisualLines, paddingX, truncationHin
|
|
|
412
404
|
}
|
|
413
405
|
};
|
|
414
406
|
}
|
|
407
|
+
function createVisualMiddleComponent(text, maxVisualLines, paddingX) {
|
|
408
|
+
let cachedWidth;
|
|
409
|
+
let cachedLines;
|
|
410
|
+
return {
|
|
411
|
+
render(width) {
|
|
412
|
+
if (cachedWidth !== width || cachedLines === void 0) {
|
|
413
|
+
const result = truncateToVisualLinesMiddle(text, maxVisualLines, width, paddingX);
|
|
414
|
+
cachedWidth = width;
|
|
415
|
+
cachedLines = result.visualLines;
|
|
416
|
+
}
|
|
417
|
+
return cachedLines;
|
|
418
|
+
},
|
|
419
|
+
invalidate() {
|
|
420
|
+
cachedWidth = void 0;
|
|
421
|
+
cachedLines = void 0;
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
}
|
|
415
425
|
function createCollapsedReadSummaryComponent(text, expandKey, paddingX) {
|
|
416
426
|
let cachedWidth;
|
|
417
427
|
let cachedLine;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-execution.js","names":[],"sources":["../../../../src/tui/components/tool-execution.ts"],"sourcesContent":["import {\n Container,\n type Component,\n getCapabilities,\n Image,\n type KeybindingsManager,\n Spacer,\n Text,\n} from '@earendil-works/pi-tui';\nimport { basename, dirname } from 'node:path';\nimport type { AgentToolResult } from '@earendil-works/pi-agent-core';\n\nimport { theme } from '../theme.js';\nimport { formatKeyIds } from '../format-tui-hotkeys.js';\nimport { isDiffFriendlyTool, looksLikeUnifiedDiff, renderUnifiedDiff } from '../tui-tool-diff.js';\nimport {\n hasStructuredTuiToolRenderer,\n renderToolCallWithExtensions,\n renderToolResultWithExtensions,\n renderToolWithExtensions,\n} from '../extension-host/tool-renderers.js';\nimport {\n parseTuiToolResult,\n type TuiToolContentBlock,\n} from '../tui-tool-result.js';\nimport { truncateToVisualLines } from './visual-truncate.js';\n\nconst MAX_ARG_VALUE_LENGTH = 120;\nconst COLLAPSED_RESULT_VISUAL_LINES = 4;\n\nexport interface ToolExecutionOptions {\n showImages?: boolean;\n imageWidthCells?: number;\n keybindings?: KeybindingsManager;\n toolCallId?: string;\n cwd?: string;\n}\n\nfunction sanitize(text: string): string {\n return text.replace(/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]/g, '');\n}\n\nfunction trimTrailingBlankDisplayLines(text: string): string {\n return text.replace(/(?:\\r?\\n[ \\t]*)+$/g, '');\n}\n\nexport function getToolResultDisplayText(\n content: TuiToolContentBlock[],\n options: { showImages: boolean; supportsInlineImages: boolean },\n): string {\n const parts: string[] = [];\n for (const block of content) {\n if (block.type === 'text') {\n if (block.text) parts.push(sanitize(block.text));\n continue;\n }\n if (block.type === 'image' && (!options.supportsInlineImages || !options.showImages)) {\n parts.push(block.mimeType ? `[image:${block.mimeType}]` : '[image]');\n continue;\n }\n if (block.type !== 'image') {\n parts.push(block.text ? sanitize(block.text) : `[${block.type}]`);\n }\n }\n return trimTrailingBlankDisplayLines(parts.filter(Boolean).join('\\n'));\n}\n\nfunction formatArgsSummary(args: unknown, toolName: string): string {\n if (!args || typeof args !== 'object') return '';\n const compactRead = isReadStyleTool(toolName) ? formatCompactReadArgs(args) : null;\n if (compactRead) return compactRead;\n const entries = Object.entries(args as Record<string, unknown>);\n if (entries.length === 0) return '';\n return entries\n .map(([key, value]) => {\n const stringValue = formatArgValue(value);\n const truncated =\n stringValue.length > MAX_ARG_VALUE_LENGTH\n ? `${stringValue.slice(0, MAX_ARG_VALUE_LENGTH - 3)}...`\n : stringValue;\n return `${key}=${truncated}`;\n })\n .join(', ');\n}\n\nfunction isReadStyleTool(toolName: string): boolean {\n return ['read', 'read_file', 'memory_get'].includes(toolName);\n}\n\nfunction formatCompactReadArgs(args: unknown): string | null {\n if (!args || typeof args !== 'object') return null;\n const record = args as Record<string, unknown>;\n const rawPath = typeof record.path === 'string'\n ? record.path\n : typeof record.file_path === 'string'\n ? record.file_path\n : undefined;\n if (!rawPath) return null;\n\n const normalized = rawPath.replace(/\\\\/g, '/');\n const base = basename(normalized);\n let label: string | null = null;\n if (base === 'SKILL.md') {\n const parent = basename(dirname(normalized));\n label = parent ? `[skill] ${parent}` : '[skill]';\n } else if (base === 'AGENTS.md') {\n label = `read resource ${normalized}`;\n }\n if (!label) return null;\n\n const start = firstFiniteNumber(record.offset, record.from, record.start, record.line);\n const count = firstFiniteNumber(record.limit, record.lines, record.count);\n if (start != null && count != null && count > 0) {\n label += `:${start}-${start + count - 1}`;\n }\n return label;\n}\n\nfunction firstFiniteNumber(...values: unknown[]): number | null {\n for (const value of values) {\n if (typeof value === 'number' && Number.isFinite(value)) return Math.floor(value);\n if (typeof value === 'string' && value.trim()) {\n const parsed = Number(value);\n if (Number.isFinite(parsed)) return Math.floor(parsed);\n }\n }\n return null;\n}\n\nfunction formatArgValue(value: unknown): string {\n if (typeof value === 'string') return value;\n if (typeof value === 'bigint') return `${value.toString()}n`;\n if (typeof value === 'function') return '[function]';\n if (typeof value === 'symbol') return String(value);\n if (value instanceof Error) return value.message || value.name;\n try {\n const json = JSON.stringify(value);\n return json === undefined ? String(value) : json;\n } catch {\n return String(value);\n }\n}\n\nfunction isTuiComponent(value: unknown): value is Component {\n return Boolean(\n value &&\n typeof value === 'object' &&\n typeof (value as { render?: unknown }).render === 'function',\n );\n}\n\nexport class ToolExecutionComponent extends Container {\n private contentContainer: Container;\n private contentText: Text;\n private collapsedOutputComponent: ReturnType<typeof createVisualTailComponent> | null = null;\n private collapsedReadSummaryComponent: ReturnType<typeof createCollapsedReadSummaryComponent> | null = null;\n private toolName: string;\n private toolCallId: string;\n private args: unknown;\n private argsComplete = true;\n private resultText = '';\n private resultContent: TuiToolContentBlock[] | undefined;\n private resultDetails: unknown;\n private rendererState: Record<string, unknown> = {};\n private lastRendererOutput: string[] | Component | undefined;\n private lastCallRendererOutput: string[] | Component | undefined;\n private lastResultRendererOutput: string[] | Component | undefined;\n private customRendererComponent: Component | undefined;\n private structuredRendererComponents: Component[] = [];\n private contentTextAttached = true;\n private rendererInvalidationQueued = false;\n private imageComponents: Image[] = [];\n private imageSpacers: Spacer[] = [];\n private showImages: boolean;\n private imageWidthCells: number;\n private keybindings: KeybindingsManager | undefined;\n private cwd: string;\n private expanded = false;\n private isError = false;\n private isPartial = true;\n private executionStarted = false;\n\n constructor(toolName: string, toolCallId: string, args: unknown, options: ToolExecutionOptions = {}) {\n super();\n this.toolName = toolName;\n this.toolCallId = toolCallId;\n this.args = args;\n this.showImages = options.showImages ?? true;\n this.imageWidthCells = Math.max(1, Math.floor(options.imageWidthCells ?? 60));\n this.keybindings = options.keybindings;\n this.cwd = options.cwd ?? process.cwd();\n\n this.addChild(new Spacer(1));\n\n const bgFn = (text: string) => theme.toolPendingBg(text);\n this.contentContainer = new Container();\n this.contentText = new Text('', 1, 1, bgFn);\n this.contentContainer.addChild(this.contentText);\n this.addChild(this.contentContainer);\n\n this.refresh();\n }\n\n setArgs(args: unknown): void {\n this.args = args;\n this.refresh();\n }\n\n markExecutionStarted(): void {\n this.executionStarted = true;\n this.refresh();\n }\n\n setArgsComplete(): void {\n this.argsComplete = true;\n this.refresh();\n }\n\n setExpanded(expanded: boolean): void {\n this.expanded = expanded;\n this.refresh();\n }\n\n updateResult(result: AgentToolResult<any> | unknown, isPartial = false, isError = false): void {\n const parsed = parseTuiToolResult(result);\n this.resultText = sanitize(parsed.text);\n this.resultContent = parsed.envelope?.content;\n this.resultDetails = parsed.envelope?.details;\n this.isError = isError;\n this.isPartial = isPartial;\n this.refresh();\n }\n\n setImageOptions(options: ToolExecutionOptions): void {\n if (options.showImages !== undefined) {\n this.showImages = options.showImages;\n }\n if (options.imageWidthCells !== undefined) {\n this.imageWidthCells = Math.max(1, Math.floor(options.imageWidthCells));\n }\n if (options.keybindings !== undefined) {\n this.keybindings = options.keybindings;\n }\n if (options.cwd !== undefined) {\n this.cwd = options.cwd;\n }\n this.refresh();\n }\n\n setPartialDetails(details: unknown): void {\n this.resultDetails = details;\n this.isPartial = true;\n this.refresh();\n }\n\n private refresh(): void {\n const bgFn = this.isPartial\n ? (text: string) => theme.toolPendingBg(text)\n : this.isError\n ? (text: string) => theme.toolErrorBg(text)\n : (text: string) => theme.toolSuccessBg(text);\n this.refreshCollapsedOutput(null);\n this.refreshCollapsedReadSummary(null);\n if (this.customRendererComponent) {\n this.contentContainer.removeChild(this.customRendererComponent);\n this.customRendererComponent = undefined;\n }\n for (const component of this.structuredRendererComponents) {\n this.contentContainer.removeChild(component);\n }\n this.structuredRendererComponents = [];\n this.contentText.setCustomBgFn(bgFn);\n\n if (hasStructuredTuiToolRenderer(this.toolName)) {\n this.detachContentText();\n this.renderStructuredExtensionTool();\n } else {\n const custom = this.renderExtensionTool();\n if (Array.isArray(custom) && custom.length > 0) {\n this.ensureContentTextAttached();\n this.lastRendererOutput = custom;\n this.contentText.setText(custom.join('\\n'));\n } else if (isTuiComponent(custom)) {\n this.detachContentText();\n this.customRendererComponent = custom;\n this.lastRendererOutput = custom;\n this.contentContainer.addChild(custom);\n } else {\n this.ensureContentTextAttached();\n this.lastRendererOutput = undefined;\n this.contentText.setText(this.formatToolExecution());\n }\n }\n this.refreshImages();\n }\n\n private appendRendererResult(result: ReturnType<typeof renderToolWithExtensions>): boolean {\n if (Array.isArray(result) && result.length > 0) {\n const component = new Text(result.join('\\n'), 1, 1);\n this.structuredRendererComponents.push(component);\n this.contentContainer.addChild(component);\n return true;\n }\n if (isTuiComponent(result)) {\n this.structuredRendererComponents.push(result);\n this.contentContainer.addChild(result);\n return true;\n }\n return false;\n }\n\n private renderStructuredExtensionTool(): void {\n const call = this.renderExtensionToolCall();\n if (this.appendRendererResult(call)) {\n this.lastCallRendererOutput = call as string[] | Component;\n } else {\n this.lastCallRendererOutput = undefined;\n this.ensureContentTextAttached();\n this.contentText.setText(this.formatToolCallFallback());\n }\n\n if (!this.isPartial || this.resultDetails !== undefined || this.resultText || this.resultContent) {\n const result = this.renderExtensionToolResult();\n if (this.appendRendererResult(result)) {\n this.lastResultRendererOutput = result as string[] | Component;\n } else {\n this.appendRendererResult([this.formatToolResultFallback()].filter(Boolean));\n this.lastResultRendererOutput = undefined;\n }\n }\n }\n\n private ensureContentTextAttached(): void {\n if (this.contentTextAttached) return;\n this.contentContainer.addChild(this.contentText);\n this.contentTextAttached = true;\n }\n\n private detachContentText(): void {\n if (!this.contentTextAttached) return;\n this.contentContainer.removeChild(this.contentText);\n this.contentTextAttached = false;\n }\n\n private requestRendererInvalidate(): void {\n if (this.rendererInvalidationQueued) return;\n this.rendererInvalidationQueued = true;\n queueMicrotask(() => {\n this.rendererInvalidationQueued = false;\n this.refresh();\n this.invalidate();\n });\n }\n\n private renderExtensionTool(): ReturnType<typeof renderToolWithExtensions> {\n return renderToolWithExtensions(this.createRenderContext(this.lastRendererOutput));\n }\n\n private renderExtensionToolCall(): ReturnType<typeof renderToolWithExtensions> {\n return renderToolCallWithExtensions(\n this.createRenderContext(this.lastCallRendererOutput),\n theme,\n );\n }\n\n private renderExtensionToolResult(): ReturnType<typeof renderToolWithExtensions> {\n return renderToolResultWithExtensions(\n this.createRenderContext(this.lastResultRendererOutput),\n theme,\n );\n }\n\n private createRenderContext(lastComponent: string[] | Component | undefined) {\n return {\n toolName: this.toolName,\n toolCallId: this.toolCallId,\n args: this.args,\n resultText: this.getDisplayResultText(),\n content: this.resultContent,\n details: this.resultDetails,\n invalidate: () => this.requestRendererInvalidate(),\n lastComponent,\n state: this.rendererState,\n cwd: this.cwd,\n executionStarted: this.executionStarted,\n argsComplete: this.argsComplete,\n isError: this.isError,\n isPartial: this.isPartial,\n expanded: this.expanded,\n showImages: this.showImages,\n };\n }\n\n private formatToolCallFallback(): string {\n const argsStr = formatArgsSummary(this.args, this.toolName);\n const titleParts = [theme.toolTitle(theme.bold(this.toolName))];\n if (argsStr) {\n titleParts.push(theme.dim(`(${argsStr})`));\n }\n if (this.isPartial && !this.resultText && !this.resultContent && this.resultDetails === undefined) {\n titleParts.push(theme.dim('…'));\n }\n return titleParts.join(' ');\n }\n\n private formatToolResultFallback(): string {\n const output = this.getDisplayResultText();\n let text = '';\n if (output) {\n const expandKey = this.keybindings\n ? formatKeyIds(this.keybindings, 'app.tools.expand', { capitalize: true })\n : 'Ctrl+O';\n const lineCount = output.split('\\n').length;\n const useDiff =\n this.expanded &&\n isDiffFriendlyTool(this.toolName) &&\n looksLikeUnifiedDiff(output);\n if (useDiff) {\n text += renderUnifiedDiff(output);\n } else if (this.expanded) {\n text += theme.toolOutput(output);\n } else if (isReadStyleTool(this.toolName)) {\n const rows = new Text(output, 1, 0).render(80).length;\n const plural = rows === 1 ? 'row' : 'rows';\n text += theme.dim(` ${rows} ${plural}; ${expandKey} to expand`);\n } else {\n const suffix = lineCount > COLLAPSED_RESULT_VISUAL_LINES\n ? theme.dim(` (${lineCount} lines; ${expandKey} to expand)`)\n : '';\n text += theme.dim(`preview${suffix}`);\n }\n }\n if (this.expanded && this.resultDetails !== undefined) {\n const detailsText = formatDetailsPreview(this.resultDetails);\n if (detailsText) {\n text = [text, theme.dim(detailsText)].filter(Boolean).join('\\n');\n }\n }\n return text;\n }\n\n private formatToolExecution(): string {\n // Title line: 🔧 tool_name (args_summary)\n const argsStr = formatArgsSummary(this.args, this.toolName);\n const titleParts = [theme.toolTitle(theme.bold(this.toolName))];\n if (argsStr) {\n titleParts.push(theme.dim(`(${argsStr})`));\n }\n let text = titleParts.join(' ');\n\n // Output / result — collapsed: single-line summary; expanded: full output\n const output = this.getDisplayResultText();\n if (output) {\n const expandKey = this.keybindings\n ? formatKeyIds(this.keybindings, 'app.tools.expand', { capitalize: true })\n : 'Ctrl+O';\n const lineCount = output.split('\\n').length;\n const useDiff =\n this.expanded &&\n isDiffFriendlyTool(this.toolName) &&\n looksLikeUnifiedDiff(output);\n if (useDiff) {\n text += `\\n${renderUnifiedDiff(output)}`;\n } else if (this.expanded) {\n text += `\\n${theme.toolOutput(output)}`;\n } else if (isReadStyleTool(this.toolName)) {\n this.refreshCollapsedReadSummary(output, expandKey);\n } else {\n const suffix = lineCount > COLLAPSED_RESULT_VISUAL_LINES\n ? theme.dim(` (${lineCount} lines; ${expandKey} to expand)`)\n : '';\n text += `\\n${theme.dim(`preview${suffix}`)}`;\n this.refreshCollapsedOutput(\n theme.toolOutput(output),\n lineCount > COLLAPSED_RESULT_VISUAL_LINES ? undefined : `${expandKey} to expand`,\n );\n }\n } else if (this.isPartial) {\n text += `\\n${theme.dim('…')}`;\n }\n\n if (this.expanded && this.resultDetails !== undefined) {\n const detailsText = formatDetailsPreview(this.resultDetails);\n if (detailsText) {\n text += `\\n${theme.dim(detailsText)}`;\n }\n }\n\n return text;\n }\n\n private getDisplayResultText(): string {\n if (!this.resultContent) {\n return trimTrailingBlankDisplayLines(this.resultText);\n }\n return getToolResultDisplayText(this.resultContent, {\n showImages: this.showImages,\n supportsInlineImages: Boolean(getCapabilities().images),\n });\n }\n\n private refreshImages(): void {\n for (const image of this.imageComponents) {\n this.removeChild(image);\n }\n this.imageComponents = [];\n for (const spacer of this.imageSpacers) {\n this.removeChild(spacer);\n }\n this.imageSpacers = [];\n\n const imageBlocks = this.resultContent?.filter(\n (block) => block.type === 'image' && block.data && block.mimeType,\n ) ?? [];\n if (imageBlocks.length === 0) return;\n\n const capabilities = getCapabilities();\n if (!capabilities.images || !this.showImages) return;\n\n for (const block of imageBlocks) {\n const spacer = new Spacer(1);\n const image = new Image(\n block.data!,\n block.mimeType!,\n { fallbackColor: (text: string) => theme.toolOutput(text) },\n { maxWidthCells: this.imageWidthCells },\n );\n this.imageSpacers.push(spacer);\n this.imageComponents.push(image);\n this.addChild(spacer);\n this.addChild(image);\n }\n }\n\n private refreshCollapsedOutput(text: string | null, truncationHint?: string): void {\n if (this.collapsedOutputComponent) {\n this.contentContainer.removeChild(this.collapsedOutputComponent);\n this.collapsedOutputComponent = null;\n }\n if (!text) return;\n this.collapsedOutputComponent = createVisualTailComponent(\n text,\n COLLAPSED_RESULT_VISUAL_LINES,\n 1,\n truncationHint,\n );\n this.contentContainer.addChild(this.collapsedOutputComponent);\n }\n\n private refreshCollapsedReadSummary(text: string | null, expandKey?: string): void {\n if (this.collapsedReadSummaryComponent) {\n this.contentContainer.removeChild(this.collapsedReadSummaryComponent);\n this.collapsedReadSummaryComponent = null;\n }\n if (!text || !expandKey) return;\n this.collapsedReadSummaryComponent = createCollapsedReadSummaryComponent(text, expandKey, 1);\n this.contentContainer.addChild(this.collapsedReadSummaryComponent);\n }\n}\n\nfunction formatDetailsPreview(details: unknown): string {\n if (details === null) return '';\n if (typeof details === 'string') return details;\n try {\n return JSON.stringify(details, null, 2);\n } catch {\n return String(details);\n }\n}\n\nfunction createVisualTailComponent(\n text: string,\n maxVisualLines: number,\n paddingX: number,\n truncationHint?: string,\n) {\n let cachedWidth: number | undefined;\n let cachedLines: string[] | undefined;\n return {\n render(width: number): string[] {\n if (cachedWidth !== width || cachedLines === undefined) {\n const result = truncateToVisualLines(text, maxVisualLines, width, paddingX);\n cachedWidth = width;\n cachedLines =\n result.skippedCount > 0 && truncationHint\n ? [theme.dim(` (${result.skippedCount} rows hidden; ${truncationHint})`), ...result.visualLines]\n : result.visualLines;\n }\n return cachedLines;\n },\n invalidate(): void {\n cachedWidth = undefined;\n cachedLines = undefined;\n },\n };\n}\n\nfunction createCollapsedReadSummaryComponent(text: string, expandKey: string, paddingX: number) {\n let cachedWidth: number | undefined;\n let cachedLine: string | undefined;\n return {\n render(width: number): string[] {\n if (cachedWidth !== width || cachedLine === undefined) {\n const rows = new Text(text, paddingX, 0).render(width).length;\n const plural = rows === 1 ? 'row' : 'rows';\n cachedWidth = width;\n cachedLine = theme.dim(` ${rows} ${plural}; ${expandKey} to expand`);\n }\n return [cachedLine];\n },\n invalidate(): void {\n cachedWidth = undefined;\n cachedLine = undefined;\n },\n };\n}\n"],"mappings":";;;;;;;;;AA2BA,MAAM,uBAAuB;AAC7B,MAAM,gCAAgC;AAUtC,SAAS,SAAS,MAAsB;AACtC,QAAO,KAAK,QAAQ,iCAAiC,GAAG;;AAG1D,SAAS,8BAA8B,MAAsB;AAC3D,QAAO,KAAK,QAAQ,sBAAsB,GAAG;;AAG/C,SAAgB,yBACd,SACA,SACQ;CACR,MAAM,QAAkB,EAAE;AAC1B,MAAK,MAAM,SAAS,SAAS;AAC3B,MAAI,MAAM,SAAS,QAAQ;AACzB,OAAI,MAAM,KAAM,OAAM,KAAK,SAAS,MAAM,KAAK,CAAC;AAChD;;AAEF,MAAI,MAAM,SAAS,YAAY,CAAC,QAAQ,wBAAwB,CAAC,QAAQ,aAAa;AACpF,SAAM,KAAK,MAAM,WAAW,UAAU,MAAM,SAAS,KAAK,UAAU;AACpE;;AAEF,MAAI,MAAM,SAAS,QACjB,OAAM,KAAK,MAAM,OAAO,SAAS,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG;;AAGrE,QAAO,8BAA8B,MAAM,OAAO,QAAQ,CAAC,KAAK,KAAK,CAAC;;AAGxE,SAAS,kBAAkB,MAAe,UAA0B;AAClE,KAAI,CAAC,QAAQ,OAAO,SAAS,SAAU,QAAO;CAC9C,MAAM,cAAc,gBAAgB,SAAS,GAAG,sBA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AAgC;;AAEvC,MAAI,CAAC,QAAQ,CAAC,UAAW;AACzB,OAAK,gCAAgC,oCAAoC,MAAM,WAAW,EAAE;AAC5F,OAAK,iBAAiB,SAAS,KAAK,8BAA8B;;;AAItE,SAAS,qBAAqB,SAA0B;AACtD,KAAI,YAAY,KAAM,QAAO;AAC7B,KAAI,OAAO,YAAY,SAAU,QAAO;AACxC,KAAI;AACF,SAAO,KAAK,UAAU,SAAS,MAAM,EAAE;SACjC;AACN,SAAO,OAAO,QAAQ;;;AAI1B,SAAS,0BACP,MACA,gBACA,UACA,gBACA;CACA,IAAI;CACJ,IAAI;AACJ,QAAO;EACL,OAAO,OAAyB;AAC9B,OAAI,gBAAgB,SAAS,gBAAgB,KAAA,GAAW;IACtD,MAAM,SAAS,sBAAsB,MAAM,gBAAgB,OAAO,SAAS;AAC3E,kBAAc;AACd,kBACE,OAAO,eAAe,KAAK,iBACvB,CAAC,MAAM,IAAI,MAAM,OAAO,aAAa,gBAAgB,eAAe,GAAG,EAAE,GAAG,OAAO,YAAY,GAC/F,OAAO;;AAEf,UAAO;;EAET,aAAmB;AACjB,iBAAc,KAAA;AACd,iBAAc,KAAA;;EAEjB;;AAGH,SAAS,oCAAoC,MAAc,WAAmB,UAAkB;CAC9F,IAAI;CACJ,IAAI;AACJ,QAAO;EACL,OAAO,OAAyB;AAC9B,OAAI,gBAAgB,SAAS,eAAe,KAAA,GAAW;IACrD,MAAM,OAAO,IAAI,KAAK,MAAM,UAAU,EAAE,CAAC,OAAO,MAAM,CAAC;IACvD,MAAM,SAAS,SAAS,IAAI,QAAQ;AACpC,kBAAc;AACd,iBAAa,MAAM,IAAI,KAAK,KAAK,GAAG,OAAO,IAAI,UAAU,YAAY;;AAEvE,UAAO,CAAC,WAAW;;EAErB,aAAmB;AACjB,iBAAc,KAAA;AACd,gBAAa,KAAA;;EAEhB"}
|
|
1
|
+
{"version":3,"file":"tool-execution.js","names":[],"sources":["../../../../src/tui/components/tool-execution.ts"],"sourcesContent":["import {\n Container,\n type Component,\n getCapabilities,\n Image,\n type KeybindingsManager,\n Spacer,\n Text,\n} from '@earendil-works/pi-tui';\nimport type { AgentToolResult } from '@earendil-works/pi-agent-core';\n\nimport { theme } from '../theme.js';\nimport { formatKeyIds } from '../format-tui-hotkeys.js';\nimport {\n isDiffFriendlyTool,\n looksLikeUnifiedDiff,\n renderPatchSummary,\n renderUnifiedDiff,\n} from '../tui-tool-diff.js';\nimport {\n hasStructuredTuiToolRenderer,\n renderToolCallWithExtensions,\n renderToolResultWithExtensions,\n renderToolWithExtensions,\n} from '../extension-host/tool-renderers.js';\nimport {\n parseTuiToolResult,\n type TuiToolContentBlock,\n} from '../tui-tool-result.js';\nimport {\n displayToolName,\n formatArgsSummary,\n formatCollapsedToolSummary,\n formatExecExpandedOutput,\n getToolSummaryKind,\n isExecStyleTool,\n isReadStyleTool,\n} from '../tool-summary.js';\nimport { truncateToVisualLines, truncateToVisualLinesMiddle } from './visual-truncate.js';\n\nconst COLLAPSED_RESULT_VISUAL_LINES = 4;\nconst EXPANDED_RESULT_VISUAL_LINES = 80;\n\nexport interface ToolExecutionOptions {\n showImages?: boolean;\n imageWidthCells?: number;\n keybindings?: KeybindingsManager;\n toolCallId?: string;\n cwd?: string;\n}\n\nfunction sanitize(text: string): string {\n return text.replace(/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]/g, '');\n}\n\nfunction trimTrailingBlankDisplayLines(text: string): string {\n return text.replace(/(?:\\r?\\n[ \\t]*)+$/g, '');\n}\n\nexport function getToolResultDisplayText(\n content: TuiToolContentBlock[],\n options: { showImages: boolean; supportsInlineImages: boolean },\n): string {\n const parts: string[] = [];\n for (const block of content) {\n if (block.type === 'text') {\n if (block.text) parts.push(sanitize(block.text));\n continue;\n }\n if (block.type === 'image' && (!options.supportsInlineImages || !options.showImages)) {\n parts.push(block.mimeType ? `[image:${block.mimeType}]` : '[image]');\n continue;\n }\n if (block.type !== 'image') {\n parts.push(block.text ? sanitize(block.text) : `[${block.type}]`);\n }\n }\n return trimTrailingBlankDisplayLines(parts.filter(Boolean).join('\\n'));\n}\n\nfunction isTuiComponent(value: unknown): value is Component {\n return Boolean(\n value &&\n typeof value === 'object' &&\n typeof (value as { render?: unknown }).render === 'function',\n );\n}\n\nexport class ToolExecutionComponent extends Container {\n private contentContainer: Container;\n private contentText: Text;\n private collapsedOutputComponent: ReturnType<typeof createVisualTailComponent> | null = null;\n private collapsedReadSummaryComponent: ReturnType<typeof createCollapsedReadSummaryComponent> | null = null;\n private expandedOutputComponent: ReturnType<typeof createVisualMiddleComponent> | null = null;\n private toolName: string;\n private toolCallId: string;\n private args: unknown;\n private argsComplete = true;\n private resultText = '';\n private resultContent: TuiToolContentBlock[] | undefined;\n private resultDetails: unknown;\n private rendererState: Record<string, unknown> = {};\n private lastRendererOutput: string[] | Component | undefined;\n private lastCallRendererOutput: string[] | Component | undefined;\n private lastResultRendererOutput: string[] | Component | undefined;\n private customRendererComponent: Component | undefined;\n private structuredRendererComponents: Component[] = [];\n private contentTextAttached = true;\n private rendererInvalidationQueued = false;\n private imageComponents: Image[] = [];\n private imageSpacers: Spacer[] = [];\n private showImages: boolean;\n private imageWidthCells: number;\n private keybindings: KeybindingsManager | undefined;\n private cwd: string;\n private expanded = false;\n private isError = false;\n private isPartial = true;\n private executionStarted = false;\n private startedAt = Date.now();\n private completedAt: number | undefined;\n\n constructor(toolName: string, toolCallId: string, args: unknown, options: ToolExecutionOptions = {}) {\n super();\n this.toolName = toolName;\n this.toolCallId = toolCallId;\n this.args = args;\n this.showImages = options.showImages ?? true;\n this.imageWidthCells = Math.max(1, Math.floor(options.imageWidthCells ?? 60));\n this.keybindings = options.keybindings;\n this.cwd = options.cwd ?? process.cwd();\n\n this.addChild(new Spacer(1));\n\n const bgFn = (text: string) => theme.toolPendingBg(text);\n this.contentContainer = new Container();\n this.contentText = new Text('', 1, 1, bgFn);\n this.contentContainer.addChild(this.contentText);\n this.addChild(this.contentContainer);\n\n this.refresh();\n }\n\n setArgs(args: unknown): void {\n this.args = args;\n this.refresh();\n }\n\n markExecutionStarted(): void {\n this.executionStarted = true;\n this.startedAt = Date.now();\n this.refresh();\n }\n\n setArgsComplete(): void {\n this.argsComplete = true;\n this.refresh();\n }\n\n setExpanded(expanded: boolean): void {\n this.expanded = expanded;\n this.refresh();\n }\n\n updateResult(result: AgentToolResult<any> | unknown, isPartial = false, isError = false): void {\n const parsed = parseTuiToolResult(result);\n this.resultText = sanitize(parsed.text);\n this.resultContent = parsed.envelope?.content;\n this.resultDetails = parsed.envelope?.details;\n this.isError = isError;\n this.isPartial = isPartial;\n if (!isPartial) {\n this.completedAt = Date.now();\n }\n this.refresh();\n }\n\n setImageOptions(options: ToolExecutionOptions): void {\n if (options.showImages !== undefined) {\n this.showImages = options.showImages;\n }\n if (options.imageWidthCells !== undefined) {\n this.imageWidthCells = Math.max(1, Math.floor(options.imageWidthCells));\n }\n if (options.keybindings !== undefined) {\n this.keybindings = options.keybindings;\n }\n if (options.cwd !== undefined) {\n this.cwd = options.cwd;\n }\n this.refresh();\n }\n\n setPartialDetails(details: unknown): void {\n this.resultDetails = details;\n this.isPartial = true;\n this.refresh();\n }\n\n private refresh(): void {\n const bgFn = this.isPartial\n ? (text: string) => theme.toolPendingBg(text)\n : this.isError\n ? (text: string) => theme.toolErrorBg(text)\n : (text: string) => theme.toolSuccessBg(text);\n this.refreshCollapsedOutput(null);\n this.refreshCollapsedReadSummary(null);\n this.refreshExpandedOutput(null);\n if (this.customRendererComponent) {\n this.contentContainer.removeChild(this.customRendererComponent);\n this.customRendererComponent = undefined;\n }\n for (const component of this.structuredRendererComponents) {\n this.contentContainer.removeChild(component);\n }\n this.structuredRendererComponents = [];\n this.contentText.setCustomBgFn(bgFn);\n\n if (hasStructuredTuiToolRenderer(this.toolName)) {\n this.detachContentText();\n this.renderStructuredExtensionTool();\n } else {\n const custom = this.renderExtensionTool();\n if (Array.isArray(custom) && custom.length > 0) {\n this.ensureContentTextAttached();\n this.lastRendererOutput = custom;\n this.contentText.setText(custom.join('\\n'));\n } else if (isTuiComponent(custom)) {\n this.detachContentText();\n this.customRendererComponent = custom;\n this.lastRendererOutput = custom;\n this.contentContainer.addChild(custom);\n } else {\n this.ensureContentTextAttached();\n this.lastRendererOutput = undefined;\n this.contentText.setText(this.formatToolExecution());\n }\n }\n this.refreshImages();\n }\n\n private appendRendererResult(result: ReturnType<typeof renderToolWithExtensions>): boolean {\n if (Array.isArray(result) && result.length > 0) {\n const component = new Text(result.join('\\n'), 1, 1);\n this.structuredRendererComponents.push(component);\n this.contentContainer.addChild(component);\n return true;\n }\n if (isTuiComponent(result)) {\n this.structuredRendererComponents.push(result);\n this.contentContainer.addChild(result);\n return true;\n }\n return false;\n }\n\n private renderStructuredExtensionTool(): void {\n const call = this.renderExtensionToolCall();\n if (this.appendRendererResult(call)) {\n this.lastCallRendererOutput = call as string[] | Component;\n } else {\n this.lastCallRendererOutput = undefined;\n this.ensureContentTextAttached();\n this.contentText.setText(this.formatToolCallFallback());\n }\n\n if (!this.isPartial || this.resultDetails !== undefined || this.resultText || this.resultContent) {\n const result = this.renderExtensionToolResult();\n if (this.appendRendererResult(result)) {\n this.lastResultRendererOutput = result as string[] | Component;\n } else {\n this.appendRendererResult([this.formatToolResultFallback()].filter(Boolean));\n this.lastResultRendererOutput = undefined;\n }\n }\n }\n\n private ensureContentTextAttached(): void {\n if (this.contentTextAttached) return;\n this.contentContainer.addChild(this.contentText);\n this.contentTextAttached = true;\n }\n\n private detachContentText(): void {\n if (!this.contentTextAttached) return;\n this.contentContainer.removeChild(this.contentText);\n this.contentTextAttached = false;\n }\n\n private requestRendererInvalidate(): void {\n if (this.rendererInvalidationQueued) return;\n this.rendererInvalidationQueued = true;\n queueMicrotask(() => {\n this.rendererInvalidationQueued = false;\n this.refresh();\n this.invalidate();\n });\n }\n\n private renderExtensionTool(): ReturnType<typeof renderToolWithExtensions> {\n return renderToolWithExtensions(this.createRenderContext(this.lastRendererOutput));\n }\n\n private renderExtensionToolCall(): ReturnType<typeof renderToolWithExtensions> {\n return renderToolCallWithExtensions(\n this.createRenderContext(this.lastCallRendererOutput),\n theme,\n );\n }\n\n private renderExtensionToolResult(): ReturnType<typeof renderToolWithExtensions> {\n return renderToolResultWithExtensions(\n this.createRenderContext(this.lastResultRendererOutput),\n theme,\n );\n }\n\n private createRenderContext(lastComponent: string[] | Component | undefined) {\n return {\n toolName: this.toolName,\n toolCallId: this.toolCallId,\n args: this.args,\n resultText: this.getDisplayResultText(),\n content: this.resultContent,\n details: this.resultDetails,\n invalidate: () => this.requestRendererInvalidate(),\n lastComponent,\n state: this.rendererState,\n cwd: this.cwd,\n executionStarted: this.executionStarted,\n argsComplete: this.argsComplete,\n isError: this.isError,\n isPartial: this.isPartial,\n expanded: this.expanded,\n showImages: this.showImages,\n };\n }\n\n private formatToolCallFallback(): string {\n const argsStr = formatArgsSummary(this.args, this.toolName);\n const titleParts = [\n theme.dim(this.toolStatusLabel()),\n theme.toolTitle(theme.bold(displayToolName(this.toolName))),\n ];\n if (argsStr) {\n titleParts.push(theme.dim(`(${argsStr})`));\n }\n const duration = this.toolDurationLabel();\n if (duration) {\n titleParts.push(theme.dim(duration));\n }\n if (this.isPartial && !this.resultText && !this.resultContent && this.resultDetails === undefined) {\n titleParts.push(theme.dim('…'));\n }\n return titleParts.join(' ');\n }\n\n private formatToolResultFallback(): string {\n const output = this.getDisplayResultText();\n let text = '';\n if (output) {\n const expandKey = this.keybindings\n ? formatKeyIds(this.keybindings, 'app.tools.expand', { capitalize: true })\n : 'Ctrl+O';\n const lineCount = output.split('\\n').length;\n const useDiff =\n isDiffFriendlyTool(this.toolName) &&\n looksLikeUnifiedDiff(output);\n if (this.expanded && useDiff) {\n text += renderPatchSummary(output) ?? renderUnifiedDiff(output);\n } else if (this.expanded && isExecStyleTool(this.toolName)) {\n this.refreshExpandedOutput(theme.toolOutput(formatExecExpandedOutput(output, this.resultDetails)));\n } else if (this.expanded) {\n this.refreshExpandedOutput(theme.toolOutput(output));\n } else if (useDiff) {\n text += theme.dim('preview');\n } else if (getToolSummaryKind(this.toolName) !== 'generic') {\n text += this.collapsedSpecializedSummary(output, expandKey);\n } else {\n const suffix = lineCount > COLLAPSED_RESULT_VISUAL_LINES\n ? theme.dim(` (${lineCount} lines; ${expandKey} to expand)`)\n : '';\n text += theme.dim(`preview${suffix}`);\n }\n }\n if (this.shouldRenderDetailsPreview()) {\n const detailsText = formatDetailsPreview(this.resultDetails);\n if (detailsText) {\n text = [text, theme.dim(detailsText)].filter(Boolean).join('\\n');\n }\n }\n return text;\n }\n\n private formatToolExecution(): string {\n const argsStr = formatArgsSummary(this.args, this.toolName);\n const titleParts = [\n theme.dim(this.toolStatusLabel()),\n theme.toolTitle(theme.bold(displayToolName(this.toolName))),\n ];\n if (argsStr) {\n titleParts.push(theme.dim(`(${argsStr})`));\n }\n const duration = this.toolDurationLabel();\n if (duration) {\n titleParts.push(theme.dim(duration));\n }\n let text = titleParts.join(' ');\n\n // Output / result — collapsed: single-line summary; expanded: full output\n const output = this.getDisplayResultText();\n if (output) {\n const expandKey = this.keybindings\n ? formatKeyIds(this.keybindings, 'app.tools.expand', { capitalize: true })\n : 'Ctrl+O';\n const lineCount = output.split('\\n').length;\n const useDiff =\n isDiffFriendlyTool(this.toolName) &&\n looksLikeUnifiedDiff(output);\n if (this.expanded && useDiff) {\n text += `\\n${renderPatchSummary(output) ?? renderUnifiedDiff(output)}`;\n } else if (this.expanded && isExecStyleTool(this.toolName)) {\n this.refreshExpandedOutput(theme.toolOutput(formatExecExpandedOutput(output, this.resultDetails)));\n } else if (this.expanded) {\n this.refreshExpandedOutput(theme.toolOutput(output));\n } else if (useDiff) {\n const suffix = output.split('\\n').length > COLLAPSED_RESULT_VISUAL_LINES\n ? theme.dim(` (${output.split('\\n').length} lines; ${expandKey} to expand)`)\n : '';\n text += `\\n${theme.dim(`preview${suffix}`)}`;\n } else if (isReadStyleTool(this.toolName)) {\n this.refreshCollapsedReadSummary(output, expandKey);\n } else if (getToolSummaryKind(this.toolName) !== 'generic') {\n text += `\\n${this.collapsedSpecializedSummary(output, expandKey)}`;\n } else {\n const suffix = lineCount > COLLAPSED_RESULT_VISUAL_LINES\n ? theme.dim(` (${lineCount} lines; ${expandKey} to expand)`)\n : '';\n text += `\\n${theme.dim(`preview${suffix}`)}`;\n this.refreshCollapsedOutput(\n theme.toolOutput(output),\n lineCount > COLLAPSED_RESULT_VISUAL_LINES ? undefined : `${expandKey} to expand`,\n );\n }\n } else if (this.isPartial) {\n text += `\\n${theme.dim('…')}`;\n }\n\n if (this.shouldRenderDetailsPreview()) {\n const detailsText = formatDetailsPreview(this.resultDetails);\n if (detailsText) {\n text += `\\n${theme.dim(detailsText)}`;\n }\n }\n\n return text;\n }\n\n private toolStatusLabel(): string {\n if (this.isError) return 'Failed';\n if (this.isPartial && !this.resultText && !this.resultContent && this.resultDetails === undefined) {\n return this.executionStarted ? 'Calling' : 'Queued';\n }\n if (this.isPartial) return 'Calling';\n return 'Called';\n }\n\n private toolDurationLabel(): string {\n if (this.completedAt === undefined) return '';\n const durationMs = Math.max(0, this.completedAt - this.startedAt);\n if (durationMs < 100) return '';\n return `${durationMs}ms`;\n }\n\n private collapsedSpecializedSummary(output: string, expandKey: string): string {\n return theme.dim(formatCollapsedToolSummary({\n toolName: this.toolName,\n args: this.args,\n output,\n content: this.resultContent,\n details: this.resultDetails,\n isError: this.isError,\n expandKey,\n }));\n }\n\n private shouldRenderDetailsPreview(): boolean {\n return this.expanded && this.resultDetails !== undefined && !isExecStyleTool(this.toolName);\n }\n\n private getDisplayResultText(): string {\n if (!this.resultContent) {\n return trimTrailingBlankDisplayLines(this.resultText);\n }\n return getToolResultDisplayText(this.resultContent, {\n showImages: this.showImages,\n supportsInlineImages: Boolean(getCapabilities().images),\n });\n }\n\n private refreshImages(): void {\n for (const image of this.imageComponents) {\n this.removeChild(image);\n }\n this.imageComponents = [];\n for (const spacer of this.imageSpacers) {\n this.removeChild(spacer);\n }\n this.imageSpacers = [];\n\n const imageBlocks = this.resultContent?.filter(\n (block) => block.type === 'image' && block.data && block.mimeType,\n ) ?? [];\n if (imageBlocks.length === 0) return;\n\n const capabilities = getCapabilities();\n if (!capabilities.images || !this.showImages) return;\n\n for (const block of imageBlocks) {\n const spacer = new Spacer(1);\n const image = new Image(\n block.data!,\n block.mimeType!,\n { fallbackColor: (text: string) => theme.toolOutput(text) },\n { maxWidthCells: this.imageWidthCells },\n );\n this.imageSpacers.push(spacer);\n this.imageComponents.push(image);\n this.addChild(spacer);\n this.addChild(image);\n }\n }\n\n private refreshCollapsedOutput(text: string | null, truncationHint?: string): void {\n if (this.collapsedOutputComponent) {\n this.contentContainer.removeChild(this.collapsedOutputComponent);\n this.collapsedOutputComponent = null;\n }\n if (!text) return;\n this.collapsedOutputComponent = createVisualTailComponent(\n text,\n COLLAPSED_RESULT_VISUAL_LINES,\n 1,\n truncationHint,\n );\n this.contentContainer.addChild(this.collapsedOutputComponent);\n }\n\n private refreshCollapsedReadSummary(text: string | null, expandKey?: string): void {\n if (this.collapsedReadSummaryComponent) {\n this.contentContainer.removeChild(this.collapsedReadSummaryComponent);\n this.collapsedReadSummaryComponent = null;\n }\n if (!text || !expandKey) return;\n this.collapsedReadSummaryComponent = createCollapsedReadSummaryComponent(text, expandKey, 1);\n this.contentContainer.addChild(this.collapsedReadSummaryComponent);\n }\n\n private refreshExpandedOutput(text: string | null): void {\n if (this.expandedOutputComponent) {\n this.contentContainer.removeChild(this.expandedOutputComponent);\n this.expandedOutputComponent = null;\n }\n if (!text) return;\n this.expandedOutputComponent = createVisualMiddleComponent(\n text,\n EXPANDED_RESULT_VISUAL_LINES,\n 1,\n );\n this.contentContainer.addChild(this.expandedOutputComponent);\n }\n}\n\nfunction formatDetailsPreview(details: unknown): string {\n if (details === null) return '';\n if (typeof details === 'string') return details;\n try {\n return JSON.stringify(details, null, 2);\n } catch {\n return String(details);\n }\n}\n\nfunction createVisualTailComponent(\n text: string,\n maxVisualLines: number,\n paddingX: number,\n truncationHint?: string,\n) {\n let cachedWidth: number | undefined;\n let cachedLines: string[] | undefined;\n return {\n render(width: number): string[] {\n if (cachedWidth !== width || cachedLines === undefined) {\n const result = truncateToVisualLines(text, maxVisualLines, width, paddingX);\n cachedWidth = width;\n cachedLines =\n result.skippedCount > 0 && truncationHint\n ? [theme.dim(` (${result.skippedCount} rows hidden; ${truncationHint})`), ...result.visualLines]\n : result.visualLines;\n }\n return cachedLines;\n },\n invalidate(): void {\n cachedWidth = undefined;\n cachedLines = undefined;\n },\n };\n}\n\nfunction createVisualMiddleComponent(\n text: string,\n maxVisualLines: number,\n paddingX: number,\n) {\n let cachedWidth: number | undefined;\n let cachedLines: string[] | undefined;\n return {\n render(width: number): string[] {\n if (cachedWidth !== width || cachedLines === undefined) {\n const result = truncateToVisualLinesMiddle(text, maxVisualLines, width, paddingX);\n cachedWidth = width;\n cachedLines = result.visualLines;\n }\n return cachedLines;\n },\n invalidate(): void {\n cachedWidth = undefined;\n cachedLines = undefined;\n },\n };\n}\n\nfunction createCollapsedReadSummaryComponent(text: string, expandKey: string, paddingX: number) {\n let cachedWidth: number | undefined;\n let cachedLine: string | undefined;\n return {\n render(width: number): string[] {\n if (cachedWidth !== width || cachedLine === undefined) {\n const rows = new Text(text, paddingX, 0).render(width).length;\n const plural = rows === 1 ? 'row' : 'rows';\n cachedWidth = width;\n cachedLine = theme.dim(` ${rows} ${plural}; ${expandKey} to expand`);\n }\n return [cachedLine];\n },\n invalidate(): void {\n cachedWidth = undefined;\n cachedLine = undefined;\n },\n };\n}\n"],"mappings":";;;;;;;;;AAwCA,MAAM,gCAAgC;AACtC,MAAM,+BAA+B;AAUrC,SAAS,SAAS,MAAsB;AACtC,QAAO,KAAK,QAAQ,iCAAiC,GAAG;;AAG1D,SAAS,8BAA8B,MAAsB;AAC3D,QAAO,KAAK,QAAQ,sBAAsB,GAAG;;AAG/C,SAAgB,yBACd,SACA,SACQ;CACR,MAAM,QAAkB,EAAE;AAC1B,MAAK,MAAM,SAAS,SAAS;A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