@pentoshi/clai 2.0.62 → 3.0.0
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/README.md +262 -368
- package/dist/agent/context-manager.d.ts +5 -0
- package/dist/agent/context-manager.js +14 -2
- package/dist/agent/context-manager.js.map +1 -1
- package/dist/agent/events.d.ts +4 -1
- package/dist/agent/runner.js +150 -83
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/tool-call-parser.d.ts +15 -0
- package/dist/agent/tool-call-parser.js +171 -2
- package/dist/agent/tool-call-parser.js.map +1 -1
- package/dist/app/adapters/agent-event-adapter.d.ts +29 -0
- package/dist/app/adapters/agent-event-adapter.js +143 -0
- package/dist/app/adapters/agent-event-adapter.js.map +1 -0
- package/dist/app/adapters/current-agent-adapter.d.ts +7 -0
- package/dist/app/adapters/current-agent-adapter.js +27 -0
- package/dist/app/adapters/current-agent-adapter.js.map +1 -0
- package/dist/app/adapters/current-jobs-adapter.d.ts +4 -0
- package/dist/app/adapters/current-jobs-adapter.js +13 -0
- package/dist/app/adapters/current-jobs-adapter.js.map +1 -0
- package/dist/app/adapters/current-store-adapter.d.ts +3 -0
- package/dist/app/adapters/current-store-adapter.js +22 -0
- package/dist/app/adapters/current-store-adapter.js.map +1 -0
- package/dist/app/adapters/current-terminal-adapter.d.ts +9 -0
- package/dist/app/adapters/current-terminal-adapter.js +31 -0
- package/dist/app/adapters/current-terminal-adapter.js.map +1 -0
- package/dist/app/adapters/current-updates-adapter.d.ts +7 -0
- package/dist/app/adapters/current-updates-adapter.js +31 -0
- package/dist/app/adapters/current-updates-adapter.js.map +1 -0
- package/dist/app/adapters/in-memory-clipboard-adapter.d.ts +10 -0
- package/dist/app/adapters/in-memory-clipboard-adapter.js +20 -0
- package/dist/app/adapters/in-memory-clipboard-adapter.js.map +1 -0
- package/dist/app/commands/command.d.ts +24 -0
- package/dist/app/commands/command.js +4 -0
- package/dist/app/commands/command.js.map +1 -0
- package/dist/app/commands/registry.d.ts +45 -0
- package/dist/app/commands/registry.js +164 -0
- package/dist/app/commands/registry.js.map +1 -0
- package/dist/app/controllers/disposable.d.ts +15 -0
- package/dist/app/controllers/disposable.js +38 -0
- package/dist/app/controllers/disposable.js.map +1 -0
- package/dist/app/controllers/job-controller.d.ts +22 -0
- package/dist/app/controllers/job-controller.js +35 -0
- package/dist/app/controllers/job-controller.js.map +1 -0
- package/dist/app/controllers/plan-controller.d.ts +31 -0
- package/dist/app/controllers/plan-controller.js +69 -0
- package/dist/app/controllers/plan-controller.js.map +1 -0
- package/dist/app/controllers/session-controller.d.ts +167 -0
- package/dist/app/controllers/session-controller.js +467 -0
- package/dist/app/controllers/session-controller.js.map +1 -0
- package/dist/app/controllers/turn-controller.d.ts +52 -0
- package/dist/app/controllers/turn-controller.js +118 -0
- package/dist/app/controllers/turn-controller.js.map +1 -0
- package/dist/app/events/app-event.d.ts +118 -0
- package/dist/app/events/app-event.js +25 -0
- package/dist/app/events/app-event.js.map +1 -0
- package/dist/app/events/event-buffer.d.ts +51 -0
- package/dist/app/events/event-buffer.js +109 -0
- package/dist/app/events/event-buffer.js.map +1 -0
- package/dist/app/events/sequencer.d.ts +32 -0
- package/dist/app/events/sequencer.js +55 -0
- package/dist/app/events/sequencer.js.map +1 -0
- package/dist/app/ports/agent-port.d.ts +29 -0
- package/dist/app/ports/agent-port.js +2 -0
- package/dist/app/ports/agent-port.js.map +1 -0
- package/dist/app/ports/clipboard-port.d.ts +9 -0
- package/dist/app/ports/clipboard-port.js +2 -0
- package/dist/app/ports/clipboard-port.js.map +1 -0
- package/dist/app/ports/confirm-port.d.ts +17 -0
- package/dist/app/ports/confirm-port.js +2 -0
- package/dist/app/ports/confirm-port.js.map +1 -0
- package/dist/app/ports/jobs-port.d.ts +18 -0
- package/dist/app/ports/jobs-port.js +2 -0
- package/dist/app/ports/jobs-port.js.map +1 -0
- package/dist/app/ports/persistence-port.d.ts +21 -0
- package/dist/app/ports/persistence-port.js +2 -0
- package/dist/app/ports/persistence-port.js.map +1 -0
- package/dist/app/ports/secret-port.d.ts +12 -0
- package/dist/app/ports/secret-port.js +2 -0
- package/dist/app/ports/secret-port.js.map +1 -0
- package/dist/app/ports/terminal-port.d.ts +18 -0
- package/dist/app/ports/terminal-port.js +2 -0
- package/dist/app/ports/terminal-port.js.map +1 -0
- package/dist/app/ports/updates-port.d.ts +12 -0
- package/dist/app/ports/updates-port.js +2 -0
- package/dist/app/ports/updates-port.js.map +1 -0
- package/dist/commands/doctor.js +9 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/update.js +1 -1
- package/dist/commands/update.js.map +1 -1
- package/dist/index.js +9 -6
- package/dist/index.js.map +1 -1
- package/dist/llm/router.js +4 -2
- package/dist/llm/router.js.map +1 -1
- package/dist/prompts/index.d.ts +1 -1
- package/dist/prompts/index.js +5 -3
- package/dist/prompts/index.js.map +1 -1
- package/dist/repl/slash-commands.js +1 -1
- package/dist/repl/slash-commands.js.map +1 -1
- package/dist/repl.js +35 -107
- package/dist/repl.js.map +1 -1
- package/dist/store/config.js +3 -1
- package/dist/store/config.js.map +1 -1
- package/dist/store/history.d.ts +26 -2
- package/dist/store/history.js +383 -72
- package/dist/store/history.js.map +1 -1
- package/dist/store/logs.js +3 -3
- package/dist/store/logs.js.map +1 -1
- package/dist/store/paths.d.ts +6 -0
- package/dist/store/paths.js +38 -0
- package/dist/store/paths.js.map +1 -0
- package/dist/store/plan.js +8 -5
- package/dist/store/plan.js.map +1 -1
- package/dist/tools/jobs.js +2 -2
- package/dist/tools/jobs.js.map +1 -1
- package/dist/tools/registry.js +117 -46
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/shell.js +2 -2
- package/dist/tools/shell.js.map +1 -1
- package/dist/tui/state.js +20 -17
- package/dist/tui/state.js.map +1 -1
- package/dist/tui-v2/actions/action-id.d.ts +14 -0
- package/dist/tui-v2/actions/action-id.js +109 -0
- package/dist/tui-v2/actions/action-id.js.map +1 -0
- package/dist/tui-v2/actions/action-router.d.ts +18 -0
- package/dist/tui-v2/actions/action-router.js +62 -0
- package/dist/tui-v2/actions/action-router.js.map +1 -0
- package/dist/tui-v2/actions/chord-from-key.d.ts +26 -0
- package/dist/tui-v2/actions/chord-from-key.js +45 -0
- package/dist/tui-v2/actions/chord-from-key.js.map +1 -0
- package/dist/tui-v2/actions/keymap.d.ts +24 -0
- package/dist/tui-v2/actions/keymap.js +134 -0
- package/dist/tui-v2/actions/keymap.js.map +1 -0
- package/dist/tui-v2/app/App.d.ts +13 -0
- package/dist/tui-v2/app/App.js +320 -0
- package/dist/tui-v2/app/App.js.map +1 -0
- package/dist/tui-v2/app/command-handlers.d.ts +8 -0
- package/dist/tui-v2/app/command-handlers.js +66 -0
- package/dist/tui-v2/app/command-handlers.js.map +1 -0
- package/dist/tui-v2/app/commands/config-commands.d.ts +14 -0
- package/dist/tui-v2/app/commands/config-commands.js +161 -0
- package/dist/tui-v2/app/commands/config-commands.js.map +1 -0
- package/dist/tui-v2/app/commands/key-commands.d.ts +9 -0
- package/dist/tui-v2/app/commands/key-commands.js +263 -0
- package/dist/tui-v2/app/commands/key-commands.js.map +1 -0
- package/dist/tui-v2/app/commands/picker-commands.d.ts +24 -0
- package/dist/tui-v2/app/commands/picker-commands.js +423 -0
- package/dist/tui-v2/app/commands/picker-commands.js.map +1 -0
- package/dist/tui-v2/app/commands/session-commands.d.ts +19 -0
- package/dist/tui-v2/app/commands/session-commands.js +162 -0
- package/dist/tui-v2/app/commands/session-commands.js.map +1 -0
- package/dist/tui-v2/app/plan-lifecycle.d.ts +16 -0
- package/dist/tui-v2/app/plan-lifecycle.js +59 -0
- package/dist/tui-v2/app/plan-lifecycle.js.map +1 -0
- package/dist/tui-v2/app/providers.d.ts +17 -0
- package/dist/tui-v2/app/providers.js +32 -0
- package/dist/tui-v2/app/providers.js.map +1 -0
- package/dist/tui-v2/bootstrap/capabilities.d.ts +35 -0
- package/dist/tui-v2/bootstrap/capabilities.js +93 -0
- package/dist/tui-v2/bootstrap/capabilities.js.map +1 -0
- package/dist/tui-v2/bootstrap/composition-root.d.ts +85 -0
- package/dist/tui-v2/bootstrap/composition-root.js +131 -0
- package/dist/tui-v2/bootstrap/composition-root.js.map +1 -0
- package/dist/tui-v2/bootstrap/disable-native-selection.d.ts +11 -0
- package/dist/tui-v2/bootstrap/disable-native-selection.js +13 -0
- package/dist/tui-v2/bootstrap/disable-native-selection.js.map +1 -0
- package/dist/tui-v2/bootstrap/lifecycle.d.ts +62 -0
- package/dist/tui-v2/bootstrap/lifecycle.js +123 -0
- package/dist/tui-v2/bootstrap/lifecycle.js.map +1 -0
- package/dist/tui-v2/bootstrap/osc52-clipboard.d.ts +28 -0
- package/dist/tui-v2/bootstrap/osc52-clipboard.js +44 -0
- package/dist/tui-v2/bootstrap/osc52-clipboard.js.map +1 -0
- package/dist/tui-v2/bootstrap/overlay-ports.d.ts +12 -0
- package/dist/{tui/confirm.js → tui-v2/bootstrap/overlay-ports.js} +17 -25
- package/dist/tui-v2/bootstrap/overlay-ports.js.map +1 -0
- package/dist/tui-v2/bootstrap/pager-export.d.ts +24 -0
- package/dist/tui-v2/bootstrap/pager-export.js +87 -0
- package/dist/tui-v2/bootstrap/pager-export.js.map +1 -0
- package/dist/tui-v2/bootstrap/start-tui-v2.d.ts +15 -0
- package/dist/tui-v2/bootstrap/start-tui-v2.js +95 -0
- package/dist/tui-v2/bootstrap/start-tui-v2.js.map +1 -0
- package/dist/tui-v2/bootstrap/ui-selection.d.ts +30 -0
- package/dist/tui-v2/bootstrap/ui-selection.js +59 -0
- package/dist/tui-v2/bootstrap/ui-selection.js.map +1 -0
- package/dist/tui-v2/components/completion/completion-menu.d.ts +23 -0
- package/dist/tui-v2/components/completion/completion-menu.js +84 -0
- package/dist/tui-v2/components/completion/completion-menu.js.map +1 -0
- package/dist/tui-v2/components/jobs/jobs-panel.d.ts +16 -0
- package/dist/tui-v2/components/jobs/jobs-panel.js +92 -0
- package/dist/tui-v2/components/jobs/jobs-panel.js.map +1 -0
- package/dist/tui-v2/components/modal/confirm-modal.d.ts +21 -0
- package/dist/tui-v2/components/modal/confirm-modal.js +71 -0
- package/dist/tui-v2/components/modal/confirm-modal.js.map +1 -0
- package/dist/tui-v2/components/modal/prompt-actions-modal.d.ts +15 -0
- package/dist/tui-v2/components/modal/prompt-actions-modal.js +80 -0
- package/dist/tui-v2/components/modal/prompt-actions-modal.js.map +1 -0
- package/dist/tui-v2/components/modal/secret-modal.d.ts +24 -0
- package/dist/tui-v2/components/modal/secret-modal.js +50 -0
- package/dist/tui-v2/components/modal/secret-modal.js.map +1 -0
- package/dist/tui-v2/components/overlay/overlay-host.d.ts +17 -0
- package/dist/tui-v2/components/overlay/overlay-host.js +28 -0
- package/dist/tui-v2/components/overlay/overlay-host.js.map +1 -0
- package/dist/tui-v2/components/pager/pager.d.ts +20 -0
- package/dist/tui-v2/components/pager/pager.js +396 -0
- package/dist/tui-v2/components/pager/pager.js.map +1 -0
- package/dist/tui-v2/components/picker/picker.d.ts +17 -0
- package/dist/tui-v2/components/picker/picker.js +222 -0
- package/dist/tui-v2/components/picker/picker.js.map +1 -0
- package/dist/tui-v2/components/plan/plan-view.d.ts +20 -0
- package/dist/tui-v2/components/plan/plan-view.js +116 -0
- package/dist/tui-v2/components/plan/plan-view.js.map +1 -0
- package/dist/tui-v2/components/queue/queue-panel.d.ts +23 -0
- package/dist/tui-v2/components/queue/queue-panel.js +58 -0
- package/dist/tui-v2/components/queue/queue-panel.js.map +1 -0
- package/dist/tui-v2/components/status/status-line.d.ts +27 -0
- package/dist/tui-v2/components/status/status-line.js +158 -0
- package/dist/tui-v2/components/status/status-line.js.map +1 -0
- package/dist/tui-v2/components/toast/toast-host.d.ts +15 -0
- package/dist/tui-v2/components/toast/toast-host.js +48 -0
- package/dist/tui-v2/components/toast/toast-host.js.map +1 -0
- package/dist/tui-v2/components/transcript/assistant-message.d.ts +20 -0
- package/dist/tui-v2/components/transcript/assistant-message.js +35 -0
- package/dist/tui-v2/components/transcript/assistant-message.js.map +1 -0
- package/dist/tui-v2/components/transcript/compacted-row.d.ts +19 -0
- package/dist/tui-v2/components/transcript/compacted-row.js +94 -0
- package/dist/tui-v2/components/transcript/compacted-row.js.map +1 -0
- package/dist/tui-v2/components/transcript/intro-card.d.ts +19 -0
- package/dist/tui-v2/components/transcript/intro-card.js +50 -0
- package/dist/tui-v2/components/transcript/intro-card.js.map +1 -0
- package/dist/tui-v2/components/transcript/linkable-text.d.ts +21 -0
- package/dist/tui-v2/components/transcript/linkable-text.js +46 -0
- package/dist/tui-v2/components/transcript/linkable-text.js.map +1 -0
- package/dist/tui-v2/components/transcript/notice-row.d.ts +14 -0
- package/dist/tui-v2/components/transcript/notice-row.js +40 -0
- package/dist/tui-v2/components/transcript/notice-row.js.map +1 -0
- package/dist/tui-v2/components/transcript/search-bar.d.ts +19 -0
- package/dist/tui-v2/components/transcript/search-bar.js +7 -0
- package/dist/tui-v2/components/transcript/search-bar.js.map +1 -0
- package/dist/tui-v2/components/transcript/thinking-block.d.ts +22 -0
- package/dist/tui-v2/components/transcript/thinking-block.js +27 -0
- package/dist/tui-v2/components/transcript/thinking-block.js.map +1 -0
- package/dist/tui-v2/components/transcript/tool-card.d.ts +26 -0
- package/dist/tui-v2/components/transcript/tool-card.js +175 -0
- package/dist/tui-v2/components/transcript/tool-card.js.map +1 -0
- package/dist/tui-v2/components/transcript/transcript-row.d.ts +25 -0
- package/dist/tui-v2/components/transcript/transcript-row.js +30 -0
- package/dist/tui-v2/components/transcript/transcript-row.js.map +1 -0
- package/dist/tui-v2/components/transcript/transcript-scroll-port.d.ts +52 -0
- package/dist/tui-v2/components/transcript/transcript-scroll-port.js +86 -0
- package/dist/tui-v2/components/transcript/transcript-scroll-port.js.map +1 -0
- package/dist/tui-v2/components/transcript/transcript-view.d.ts +24 -0
- package/dist/tui-v2/components/transcript/transcript-view.js +403 -0
- package/dist/tui-v2/components/transcript/transcript-view.js.map +1 -0
- package/dist/tui-v2/components/transcript/use-click-without-drag.d.ts +13 -0
- package/dist/tui-v2/components/transcript/use-click-without-drag.js +35 -0
- package/dist/tui-v2/components/transcript/use-click-without-drag.js.map +1 -0
- package/dist/tui-v2/components/transcript/use-native-selection-copy.d.ts +10 -0
- package/dist/tui-v2/components/transcript/use-native-selection-copy.js +37 -0
- package/dist/tui-v2/components/transcript/use-native-selection-copy.js.map +1 -0
- package/dist/tui-v2/components/transcript/use-transcript-selection.d.ts +23 -0
- package/dist/tui-v2/components/transcript/use-transcript-selection.js +136 -0
- package/dist/tui-v2/components/transcript/use-transcript-selection.js.map +1 -0
- package/dist/tui-v2/components/transcript/user-message.d.ts +10 -0
- package/dist/tui-v2/components/transcript/user-message.js +23 -0
- package/dist/tui-v2/components/transcript/user-message.js.map +1 -0
- package/dist/tui-v2/composer/arrow-intent.d.ts +23 -0
- package/dist/tui-v2/composer/arrow-intent.js +35 -0
- package/dist/tui-v2/composer/arrow-intent.js.map +1 -0
- package/dist/tui-v2/composer/completion.d.ts +37 -0
- package/dist/tui-v2/composer/completion.js +67 -0
- package/dist/tui-v2/composer/completion.js.map +1 -0
- package/dist/tui-v2/composer/composer-editor.d.ts +33 -0
- package/dist/tui-v2/composer/composer-editor.js +620 -0
- package/dist/tui-v2/composer/composer-editor.js.map +1 -0
- package/dist/tui-v2/composer/composer-height.d.ts +21 -0
- package/dist/tui-v2/composer/composer-height.js +29 -0
- package/dist/tui-v2/composer/composer-height.js.map +1 -0
- package/dist/tui-v2/composer/composer-meta.d.ts +9 -0
- package/dist/tui-v2/composer/composer-meta.js +38 -0
- package/dist/tui-v2/composer/composer-meta.js.map +1 -0
- package/dist/tui-v2/composer/history-nav.d.ts +15 -0
- package/dist/tui-v2/composer/history-nav.js +16 -0
- package/dist/tui-v2/composer/history-nav.js.map +1 -0
- package/dist/tui-v2/composer/newline-hint.d.ts +13 -0
- package/dist/tui-v2/composer/newline-hint.js +13 -0
- package/dist/tui-v2/composer/newline-hint.js.map +1 -0
- package/dist/tui-v2/composer/paste-placeholder.d.ts +35 -0
- package/dist/tui-v2/composer/paste-placeholder.js +55 -0
- package/dist/tui-v2/composer/paste-placeholder.js.map +1 -0
- package/dist/tui-v2/composer/prompt-history.d.ts +22 -0
- package/dist/tui-v2/composer/prompt-history.js +51 -0
- package/dist/tui-v2/composer/prompt-history.js.map +1 -0
- package/dist/tui-v2/composer/secret-buffer.d.ts +20 -0
- package/dist/tui-v2/composer/secret-buffer.js +42 -0
- package/dist/tui-v2/composer/secret-buffer.js.map +1 -0
- package/dist/tui-v2/composer/textarea-keybindings.d.ts +22 -0
- package/dist/tui-v2/composer/textarea-keybindings.js +27 -0
- package/dist/tui-v2/composer/textarea-keybindings.js.map +1 -0
- package/dist/tui-v2/controllers/focus-controller.d.ts +30 -0
- package/dist/tui-v2/controllers/focus-controller.js +80 -0
- package/dist/tui-v2/controllers/focus-controller.js.map +1 -0
- package/dist/tui-v2/controllers/overlay-controller.d.ts +99 -0
- package/dist/tui-v2/controllers/overlay-controller.js +195 -0
- package/dist/tui-v2/controllers/overlay-controller.js.map +1 -0
- package/dist/tui-v2/controllers/selection-controller.d.ts +76 -0
- package/dist/tui-v2/controllers/selection-controller.js +238 -0
- package/dist/tui-v2/controllers/selection-controller.js.map +1 -0
- package/dist/tui-v2/controllers/toast-controller.d.ts +35 -0
- package/dist/tui-v2/controllers/toast-controller.js +88 -0
- package/dist/tui-v2/controllers/toast-controller.js.map +1 -0
- package/dist/tui-v2/layout/compute-layout.d.ts +59 -0
- package/dist/tui-v2/layout/compute-layout.js +170 -0
- package/dist/tui-v2/layout/compute-layout.js.map +1 -0
- package/dist/tui-v2/rendering/ansi-to-styled.d.ts +17 -0
- package/dist/tui-v2/rendering/ansi-to-styled.js +217 -0
- package/dist/tui-v2/rendering/ansi-to-styled.js.map +1 -0
- package/dist/tui-v2/rendering/batch-sections.d.ts +45 -0
- package/dist/tui-v2/rendering/batch-sections.js +109 -0
- package/dist/tui-v2/rendering/batch-sections.js.map +1 -0
- package/dist/tui-v2/rendering/link-detector.d.ts +16 -0
- package/dist/tui-v2/rendering/link-detector.js +43 -0
- package/dist/tui-v2/rendering/link-detector.js.map +1 -0
- package/dist/tui-v2/rendering/open-tool-output.d.ts +28 -0
- package/dist/tui-v2/rendering/open-tool-output.js +138 -0
- package/dist/tui-v2/rendering/open-tool-output.js.map +1 -0
- package/dist/tui-v2/rendering/picker-filter.d.ts +22 -0
- package/dist/tui-v2/rendering/picker-filter.js +68 -0
- package/dist/tui-v2/rendering/picker-filter.js.map +1 -0
- package/dist/tui-v2/rendering/plan-view.d.ts +32 -0
- package/dist/tui-v2/rendering/plan-view.js +196 -0
- package/dist/tui-v2/rendering/plan-view.js.map +1 -0
- package/dist/tui-v2/rendering/render-markdown-lines.d.ts +29 -0
- package/dist/tui-v2/rendering/render-markdown-lines.js +46 -0
- package/dist/tui-v2/rendering/render-markdown-lines.js.map +1 -0
- package/dist/tui-v2/rendering/sanitize-display.d.ts +13 -0
- package/dist/tui-v2/rendering/sanitize-display.js +24 -0
- package/dist/tui-v2/rendering/sanitize-display.js.map +1 -0
- package/dist/tui-v2/rendering/theme.d.ts +67 -0
- package/dist/tui-v2/rendering/theme.js +74 -0
- package/dist/tui-v2/rendering/theme.js.map +1 -0
- package/dist/tui-v2/rendering/tool-presenter.d.ts +39 -0
- package/dist/tui-v2/rendering/tool-presenter.js +207 -0
- package/dist/tui-v2/rendering/tool-presenter.js.map +1 -0
- package/dist/tui-v2/rendering/transcript-export.d.ts +11 -0
- package/dist/tui-v2/rendering/transcript-export.js +18 -0
- package/dist/tui-v2/rendering/transcript-export.js.map +1 -0
- package/dist/tui-v2/rendering/transcript-semantic.d.ts +17 -0
- package/dist/tui-v2/rendering/transcript-semantic.js +67 -0
- package/dist/tui-v2/rendering/transcript-semantic.js.map +1 -0
- package/dist/tui-v2/state/pager-search.d.ts +22 -0
- package/dist/tui-v2/state/pager-search.js +78 -0
- package/dist/tui-v2/state/pager-search.js.map +1 -0
- package/dist/tui-v2/state/semantic-document.d.ts +34 -0
- package/dist/tui-v2/state/semantic-document.js +201 -0
- package/dist/tui-v2/state/semantic-document.js.map +1 -0
- package/dist/tui-v2/state/transcript-compaction.d.ts +24 -0
- package/dist/tui-v2/state/transcript-compaction.js +79 -0
- package/dist/tui-v2/state/transcript-compaction.js.map +1 -0
- package/dist/tui-v2/state/transcript-hydrate.d.ts +27 -0
- package/dist/tui-v2/state/transcript-hydrate.js +272 -0
- package/dist/tui-v2/state/transcript-hydrate.js.map +1 -0
- package/dist/tui-v2/state/transcript-reducer.d.ts +10 -0
- package/dist/tui-v2/state/transcript-reducer.js +281 -0
- package/dist/tui-v2/state/transcript-reducer.js.map +1 -0
- package/dist/tui-v2/state/transcript-search.d.ts +17 -0
- package/dist/tui-v2/state/transcript-search.js +38 -0
- package/dist/tui-v2/state/transcript-search.js.map +1 -0
- package/dist/tui-v2/state/transcript-store.d.ts +32 -0
- package/dist/tui-v2/state/transcript-store.js +66 -0
- package/dist/tui-v2/state/transcript-store.js.map +1 -0
- package/dist/tui-v2/state/transcript-struct.d.ts +15 -0
- package/dist/tui-v2/state/transcript-struct.js +133 -0
- package/dist/tui-v2/state/transcript-struct.js.map +1 -0
- package/dist/tui-v2/state/transcript-types.d.ts +76 -0
- package/dist/tui-v2/state/transcript-types.js +65 -0
- package/dist/tui-v2/state/transcript-types.js.map +1 -0
- package/dist/tui-v2/state/use-overlay.d.ts +3 -0
- package/dist/tui-v2/state/use-overlay.js +6 -0
- package/dist/tui-v2/state/use-overlay.js.map +1 -0
- package/dist/tui-v2/state/use-plan.d.ts +4 -0
- package/dist/tui-v2/state/use-plan.js +6 -0
- package/dist/tui-v2/state/use-plan.js.map +1 -0
- package/dist/tui-v2/state/use-session-state.d.ts +2 -0
- package/dist/tui-v2/state/use-session-state.js +7 -0
- package/dist/tui-v2/state/use-session-state.js.map +1 -0
- package/dist/tui-v2/state/use-toast.d.ts +3 -0
- package/dist/tui-v2/state/use-toast.js +15 -0
- package/dist/tui-v2/state/use-toast.js.map +1 -0
- package/dist/tui-v2/state/use-transcript-store.d.ts +10 -0
- package/dist/tui-v2/state/use-transcript-store.js +12 -0
- package/dist/tui-v2/state/use-transcript-store.js.map +1 -0
- package/dist/ui/intro-card.js +3 -3
- package/dist/ui/intro-card.js.map +1 -1
- package/dist/ui/intro-header.d.ts +23 -0
- package/dist/ui/intro-header.js +232 -0
- package/dist/ui/intro-header.js.map +1 -0
- package/dist/ui/markdown.js +0 -1
- package/dist/ui/markdown.js.map +1 -1
- package/dist/ui/mentions.d.ts +9 -2
- package/dist/ui/mentions.js +102 -4
- package/dist/ui/mentions.js.map +1 -1
- package/dist/ui/output-pane.js +1 -1
- package/dist/ui/output-pane.js.map +1 -1
- package/dist/ui/plan-pane.d.ts +8 -0
- package/dist/ui/plan-pane.js +38 -0
- package/dist/ui/plan-pane.js.map +1 -1
- package/dist/ui/wordmark.d.ts +5 -0
- package/dist/ui/wordmark.js +6 -1
- package/dist/ui/wordmark.js.map +1 -1
- package/package.json +14 -10
- package/dist/tui/App.d.ts +0 -12
- package/dist/tui/App.js +0 -2174
- package/dist/tui/App.js.map +0 -1
- package/dist/tui/components/ConfirmModal.d.ts +0 -9
- package/dist/tui/components/ConfirmModal.js +0 -55
- package/dist/tui/components/ConfirmModal.js.map +0 -1
- package/dist/tui/components/JobsPanel.d.ts +0 -11
- package/dist/tui/components/JobsPanel.js +0 -55
- package/dist/tui/components/JobsPanel.js.map +0 -1
- package/dist/tui/components/Pager.d.ts +0 -14
- package/dist/tui/components/Pager.js +0 -56
- package/dist/tui/components/Pager.js.map +0 -1
- package/dist/tui/components/PickerPanel.d.ts +0 -15
- package/dist/tui/components/PickerPanel.js +0 -126
- package/dist/tui/components/PickerPanel.js.map +0 -1
- package/dist/tui/components/PlanSidebar.d.ts +0 -6
- package/dist/tui/components/PlanSidebar.js +0 -99
- package/dist/tui/components/PlanSidebar.js.map +0 -1
- package/dist/tui/components/SecretInputPanel.d.ts +0 -7
- package/dist/tui/components/SecretInputPanel.js +0 -38
- package/dist/tui/components/SecretInputPanel.js.map +0 -1
- package/dist/tui/confirm.d.ts +0 -16
- package/dist/tui/confirm.js.map +0 -1
- package/dist/tui/default.d.ts +0 -6
- package/dist/tui/default.js +0 -11
- package/dist/tui/default.js.map +0 -1
- package/dist/tui/hooks/useAgentRunner.d.ts +0 -73
- package/dist/tui/hooks/useAgentRunner.js +0 -277
- package/dist/tui/hooks/useAgentRunner.js.map +0 -1
- package/dist/tui/hooks/useJobs.d.ts +0 -7
- package/dist/tui/hooks/useJobs.js +0 -39
- package/dist/tui/hooks/useJobs.js.map +0 -1
- package/dist/tui/hooks/useSpinner.d.ts +0 -5
- package/dist/tui/hooks/useSpinner.js +0 -21
- package/dist/tui/hooks/useSpinner.js.map +0 -1
- package/dist/tui/hooks/useTerminalSize.d.ts +0 -9
- package/dist/tui/hooks/useTerminalSize.js +0 -26
- package/dist/tui/hooks/useTerminalSize.js.map +0 -1
- package/dist/tui/index.d.ts +0 -10
- package/dist/tui/index.js +0 -37
- package/dist/tui/index.js.map +0 -1
- package/dist/tui/key-intent.d.ts +0 -36
- package/dist/tui/key-intent.js +0 -54
- package/dist/tui/key-intent.js.map +0 -1
- package/dist/tui/mouse.d.ts +0 -8
- package/dist/tui/mouse.js +0 -34
- package/dist/tui/mouse.js.map +0 -1
- package/dist/tui/plan-sidebar-lines.d.ts +0 -2
- package/dist/tui/plan-sidebar-lines.js +0 -140
- package/dist/tui/plan-sidebar-lines.js.map +0 -1
- package/dist/tui/render-lines.d.ts +0 -22
- package/dist/tui/render-lines.js +0 -611
- package/dist/tui/render-lines.js.map +0 -1
|
@@ -8,6 +8,11 @@ import type { ChatMessage } from "../types.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function estimateTokens(text: string): number;
|
|
10
10
|
export declare function estimateMessagesTokens(messages: ChatMessage[]): number;
|
|
11
|
+
/**
|
|
12
|
+
* Agent-loop auto-compact threshold (estimated tokens). Shared with `/context`
|
|
13
|
+
* so the reported % of budget matches when auto-compaction fires.
|
|
14
|
+
*/
|
|
15
|
+
export declare const AUTO_COMPACT_TOKEN_BUDGET = 150000;
|
|
11
16
|
export interface CompactOptions {
|
|
12
17
|
/** Soft budget (tokens). When estimated tokens exceed this, compact. */
|
|
13
18
|
budgetTokens?: number | undefined;
|
|
@@ -21,6 +21,11 @@ export function estimateMessagesTokens(messages) {
|
|
|
21
21
|
}
|
|
22
22
|
return sum;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Agent-loop auto-compact threshold (estimated tokens). Shared with `/context`
|
|
26
|
+
* so the reported % of budget matches when auto-compaction fires.
|
|
27
|
+
*/
|
|
28
|
+
export const AUTO_COMPACT_TOKEN_BUDGET = 150_000;
|
|
24
29
|
const DEFAULT_BUDGET_TOKENS = 32_000;
|
|
25
30
|
const DEFAULT_KEEP_RECENT = 6;
|
|
26
31
|
/**
|
|
@@ -131,11 +136,18 @@ export async function compactMessagesWithSummary(messages, summarize, options =
|
|
|
131
136
|
return `${message.role.toUpperCase()}: ${content}`;
|
|
132
137
|
})
|
|
133
138
|
.join("\n\n");
|
|
134
|
-
|
|
139
|
+
// Prefer combining visual session material (tools/prompts) with older model
|
|
140
|
+
// turns so /compact after /history + new messages never loses either side.
|
|
141
|
+
const visual = sessionTranscript?.trim()
|
|
135
142
|
? redactSecrets(sessionTranscript.trim())
|
|
136
|
-
:
|
|
143
|
+
: "";
|
|
144
|
+
const fromMessages = messageTranscript.trim();
|
|
145
|
+
const transcript = visual && fromMessages
|
|
146
|
+
? `${visual}\n\n---\n\nOLDER MODEL TURNS:\n\n${fromMessages}`
|
|
147
|
+
: visual || fromMessages;
|
|
137
148
|
const prompt = [
|
|
138
149
|
"Create a complete but compact continuation memory of the entire session below for another assistant that will continue it.",
|
|
150
|
+
"The material may include a resumed history session plus newer turns — treat it as one continuous conversation.",
|
|
139
151
|
"Preserve user intentions and prompts, decisions, constraints, file paths, commands/tools run, steps taken, task states, outputs and results, errors and failed approaches, completed work, and exactly what remains.",
|
|
140
152
|
"Organize the memory under concise sections: User goals, Decisions and constraints, Work completed, Commands/tools and results, Current state, Remaining work.",
|
|
141
153
|
"Do not add facts, commentary, or markdown framing. Be concise but specific. Never include secrets or credentials.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-manager.js","sourceRoot":"","sources":["../../src/agent/context-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,QAAuB;IAC5D,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,gBAAgB;QAC5D,gEAAgE;QAChE,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;QACtC,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;
|
|
1
|
+
{"version":3,"file":"context-manager.js","sourceRoot":"","sources":["../../src/agent/context-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,QAAuB;IAC5D,IAAI,GAAG,GAA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AAY;QACZ,WAAW;QACX,UAAU,EAAE,IAAI;KACjB,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,IAAY,EAAE,QAAgB;IAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACjD,IAAI,OAAO,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,OAAO,CAAC;IAC/C,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC;AAC9C,CAAC"}
|
package/dist/agent/events.d.ts
CHANGED
|
@@ -26,10 +26,13 @@ export type AgentEvent = {
|
|
|
26
26
|
id: string;
|
|
27
27
|
name: string;
|
|
28
28
|
argsDisplay: string;
|
|
29
|
-
}
|
|
29
|
+
}
|
|
30
|
+
/** `replace: true` sets the full body (never append) so the UI never keeps a truncated live preview. */
|
|
31
|
+
| {
|
|
30
32
|
type: "tool-output";
|
|
31
33
|
id: string;
|
|
32
34
|
chunk: string;
|
|
35
|
+
replace?: boolean;
|
|
33
36
|
} | {
|
|
34
37
|
type: "tool-result";
|
|
35
38
|
id: string;
|
package/dist/agent/runner.js
CHANGED
|
@@ -11,7 +11,7 @@ import { classifyToolCall, isPentestToolCall, scopeHint, scopeTargetForToolCall,
|
|
|
11
11
|
import { availableToolNames, normalizeToolCall, runToolCall, BATCH_SAFE_TOOLS, } from "../tools/registry.js";
|
|
12
12
|
import { looksInteractiveStdin } from "../tools/shell.js";
|
|
13
13
|
import { formatViewportHint, registerViewport } from "../ui/output-pane.js";
|
|
14
|
-
import { compactMessagesWithSummary, estimateTokens, estimateMessagesTokens, COMPACTION_MEMORY_PREFIX, } from "./context-manager.js";
|
|
14
|
+
import { compactMessagesWithSummary, estimateTokens, estimateMessagesTokens, AUTO_COMPACT_TOKEN_BUDGET, COMPACTION_MEMORY_PREFIX, } from "./context-manager.js";
|
|
15
15
|
import { auditLog } from "../store/logs.js";
|
|
16
16
|
import { loadProjectContext } from "../store/project.js";
|
|
17
17
|
import { loadScope, isScopeActive, targetInScope } from "../store/scope.js";
|
|
@@ -24,7 +24,7 @@ import { analyzeTask } from "./task-analyzer.js";
|
|
|
24
24
|
import { LoopGuard } from "./loop-guard.js";
|
|
25
25
|
import { loadPlan } from "../store/plan.js";
|
|
26
26
|
import { pathInsideSandbox, fsWrite } from "../tools/fs.js";
|
|
27
|
-
import { stripSentinelTokens, parseToolCall, recognizeBareToolJson, looksLikeTruncatedToolCall, salvageTruncatedWrite, countToolFences, parseAllToolCalls, groupToolCallsForExecution, buildTurnHistory, collapseRepeatedText, textBeforeToolCall, formatToolArgs, looksLikePentestTask, looksLikeBuildTask, looksLikeInformationalQuery, looksLikeActionNarration, looksLikePlanNarration, requiresFreshWebSearch, freshnessGuardMessage, buildWorkflowDirective, pentestWorkflowDirective, shouldDimToolChatter, looksLikePromptLeak, } from "./tool-call-parser.js";
|
|
27
|
+
import { stripSentinelTokens, parseToolCall, recognizeBareToolJson, looksLikeTruncatedToolCall, salvageTruncatedWrite, countToolFences, parseAllToolCalls, groupToolCallsForExecution, buildTurnHistory, collapseRepeatedText, textBeforeToolCall, formatToolArgs, looksLikePentestTask, looksLikeBuildTask, looksLikeInformationalQuery, looksLikeIdleOrSocialPrompt, looksLikeActionNarration, looksLikeWebActionNarration, looksLikePlanNarration, requiresFreshWebSearch, freshnessGuardMessage, buildWorkflowDirective, pentestWorkflowDirective, shouldDimToolChatter, looksLikePromptLeak, } from "./tool-call-parser.js";
|
|
28
28
|
import { createSessionPolicy, isPreApprovalAllowedTool, isPlanApprovedByStatus, planHasOpenWork, isAbortError, shouldEnableImageOcr, } from "./session-policy.js";
|
|
29
29
|
import { saveToolOutput, summarizeOutput, formatToolContext, } from "./tool-output-formatting.js";
|
|
30
30
|
import { planContextMessage, handlePlanTool, } from "./plan-tool.js";
|
|
@@ -128,7 +128,9 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
128
128
|
stop: () => { },
|
|
129
129
|
};
|
|
130
130
|
const writeStatus = (text, rendered = chalk.dim(text)) => {
|
|
131
|
-
|
|
131
|
+
// Footer activity is single-line; strip classic stdout newlines/indents.
|
|
132
|
+
const cleaned = text.replace(/\s+/g, " ").trim();
|
|
133
|
+
emit({ type: "status", text: cleaned || text });
|
|
132
134
|
if (writesDirectly)
|
|
133
135
|
process.stdout.write(rendered);
|
|
134
136
|
};
|
|
@@ -154,9 +156,14 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
154
156
|
if (writesDirectly)
|
|
155
157
|
process.stdout.write(`${renderThinkingSummary(content)}\n`);
|
|
156
158
|
};
|
|
157
|
-
const writeToolOutput = (id, chunk, rendered) => {
|
|
158
|
-
emit({
|
|
159
|
-
|
|
159
|
+
const writeToolOutput = (id, chunk, rendered, options) => {
|
|
160
|
+
emit({
|
|
161
|
+
type: "tool-output",
|
|
162
|
+
id,
|
|
163
|
+
chunk,
|
|
164
|
+
...(options?.replace ? { replace: true } : {}),
|
|
165
|
+
});
|
|
166
|
+
if (writesDirectly && rendered)
|
|
160
167
|
process.stdout.write(rendered);
|
|
161
168
|
};
|
|
162
169
|
const writeToolCall = (id, call, rendered) => {
|
|
@@ -257,8 +264,13 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
257
264
|
// brand-new plan (the exact failure where "what do u know till now"
|
|
258
265
|
// triggered explore→plan and created an unrelated "Enhance clai" plan).
|
|
259
266
|
const informationalQuery = looksLikeInformationalQuery(prompt);
|
|
267
|
+
// Greetings / thanks / short acks must never force tools, plans, or
|
|
268
|
+
// freshness retries — a false "act don't narrate" path burned tokens on
|
|
269
|
+
// web.search recovery loops after a simple "hi".
|
|
270
|
+
const idleOrSocialPrompt = looksLikeIdleOrSocialPrompt(prompt);
|
|
260
271
|
const freshWebSearchRequired = !buildLikeTurn &&
|
|
261
272
|
!pentestLikeTurn &&
|
|
273
|
+
!idleOrSocialPrompt &&
|
|
262
274
|
toolNames.includes("web.search") &&
|
|
263
275
|
requiresFreshWebSearch(prompt);
|
|
264
276
|
let provider = options.provider ?? config.defaultProvider;
|
|
@@ -307,7 +319,10 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
307
319
|
// what's already there, create a comprehensive multi-task plan, then
|
|
308
320
|
// implement task by task until the goal is met. This mirrors how a careful
|
|
309
321
|
// coding agent (Claude Code) operates.
|
|
310
|
-
if (buildLikeTurn &&
|
|
322
|
+
if (buildLikeTurn &&
|
|
323
|
+
!activePlan &&
|
|
324
|
+
!informationalQuery &&
|
|
325
|
+
!idleOrSocialPrompt) {
|
|
311
326
|
systemSections.push(buildWorkflowDirective());
|
|
312
327
|
}
|
|
313
328
|
// Pentest / security engagements need a different shape than a coding
|
|
@@ -316,7 +331,10 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
316
331
|
// directive is only injected before a plan exists; once a plan is in
|
|
317
332
|
// place (or being refined), the ACTIVE PLAN block already carries the
|
|
318
333
|
// current task state and recon-vs-active-tool guidance.
|
|
319
|
-
if (pentestLikeTurn &&
|
|
334
|
+
if (pentestLikeTurn &&
|
|
335
|
+
!activePlan &&
|
|
336
|
+
!informationalQuery &&
|
|
337
|
+
!idleOrSocialPrompt) {
|
|
320
338
|
systemSections.push(pentestWorkflowDirective());
|
|
321
339
|
}
|
|
322
340
|
const renderedSystemPrompt = systemSections.join("\n\n");
|
|
@@ -724,38 +742,20 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
724
742
|
parentSignal.addEventListener("abort", onParentAbort);
|
|
725
743
|
let result;
|
|
726
744
|
let liveBytes = 0;
|
|
727
|
-
const liveCap = 16_000;
|
|
728
|
-
let liveTruncatedNotified = false;
|
|
729
|
-
let lastProgressAt = 0;
|
|
730
745
|
const shouldDimLive = !interactiveCommand;
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
};
|
|
746
|
+
// Stream every live byte — never drop mid-run. After the tool finishes we
|
|
747
|
+
// still replace the spool with the authoritative full `result.output`.
|
|
734
748
|
const printLive = (chunk) => {
|
|
735
749
|
if (call.name === "fs.read" ||
|
|
736
750
|
call.name === "fs.list" ||
|
|
737
751
|
call.name === "fs.search")
|
|
738
752
|
return;
|
|
739
|
-
if (
|
|
740
|
-
if (!liveTruncatedNotified) {
|
|
741
|
-
liveTruncatedNotified = true;
|
|
742
|
-
writeToolInfo("... live preview truncated, full output saved");
|
|
743
|
-
writeToolInfo("(tool still running — ESC or Ctrl+C to abort)");
|
|
744
|
-
lastProgressAt = Date.now();
|
|
745
|
-
}
|
|
746
|
-
const now = Date.now();
|
|
747
|
-
if (now - lastProgressAt > 5_000) {
|
|
748
|
-
lastProgressAt = now;
|
|
749
|
-
writeToolOutput(toolEventId, ".", chalk.dim("."));
|
|
750
|
-
}
|
|
753
|
+
if (!chunk)
|
|
751
754
|
return;
|
|
752
|
-
|
|
753
|
-
const
|
|
754
|
-
const slice = chunk.length > remaining ? chunk.slice(0, remaining) : chunk;
|
|
755
|
-
liveBytes += slice.length;
|
|
756
|
-
const indented = slice.replace(/\r/g, "").replace(/\n(?!$)/g, "\n ");
|
|
755
|
+
liveBytes += chunk.length;
|
|
756
|
+
const indented = chunk.replace(/\r/g, "").replace(/\n(?!$)/g, "\n ");
|
|
757
757
|
const body = indented.startsWith("\n") ? indented : ` ${indented}`;
|
|
758
|
-
writeToolOutput(toolEventId,
|
|
758
|
+
writeToolOutput(toolEventId, chunk, shouldDimLive ? chalk.dim(body) : body);
|
|
759
759
|
};
|
|
760
760
|
const jobId = randomUUID().slice(0, 8);
|
|
761
761
|
const backgroundJob = {
|
|
@@ -798,7 +798,7 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
798
798
|
confirmed: true,
|
|
799
799
|
userPrompt: prompt,
|
|
800
800
|
});
|
|
801
|
-
if (liveBytes > 0
|
|
801
|
+
if (liveBytes > 0) {
|
|
802
802
|
writeToolOutput(toolEventId, "\n", "\n");
|
|
803
803
|
}
|
|
804
804
|
jobManager.updateJobStatus(jobId, result.ok ? "exited" : "failed", result.exitCode);
|
|
@@ -839,11 +839,10 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
839
839
|
parentSignal.removeEventListener("abort", onParentAbort);
|
|
840
840
|
}
|
|
841
841
|
const output = result.output.trim();
|
|
842
|
-
|
|
842
|
+
// Always keep a full on-disk copy of tool output (any size) so the
|
|
843
|
+
// pager never depends on a truncated in-memory preview.
|
|
843
844
|
const savedOutputPath = result.outputPath ??
|
|
844
|
-
(output
|
|
845
|
-
? await saveToolOutput(call, output)
|
|
846
|
-
: undefined);
|
|
845
|
+
(output ? await saveToolOutput(call, output) : undefined);
|
|
847
846
|
const resultWithArtifact = {
|
|
848
847
|
...result,
|
|
849
848
|
outputPath: savedOutputPath,
|
|
@@ -878,20 +877,30 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
878
877
|
}
|
|
879
878
|
}
|
|
880
879
|
const statusIcon = result.ok ? chalk.green(" ✓") : chalk.red(" ✗");
|
|
881
|
-
|
|
880
|
+
// Classic stdout gets a short status glyph; the event stream / spool
|
|
881
|
+
// must NOT be polluted with "ok"/"failed" (the card already shows status).
|
|
882
|
+
if (writesDirectly) {
|
|
883
|
+
process.stdout.write(statusIcon + "\n");
|
|
884
|
+
}
|
|
882
885
|
if (output) {
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
if (savedOutputPath) {
|
|
889
|
-
writeToolInfo(`full output saved to ${savedOutputPath}`);
|
|
890
|
-
}
|
|
886
|
+
// Authoritative FULL body — replace any live stream so the pager
|
|
887
|
+
// never shows a truncated mid-run preview. Never cap for the UI.
|
|
888
|
+
const fullChunk = output.endsWith("\n") ? output : `${output}\n`;
|
|
889
|
+
if (!writesDirectly) {
|
|
890
|
+
writeToolOutput(toolEventId, fullChunk, "", { replace: true });
|
|
891
891
|
}
|
|
892
892
|
else {
|
|
893
|
+
// Classic stdout: short preview only; full text is on disk.
|
|
894
|
+
const displayMax = 6_000;
|
|
895
|
+
const displaySummary = summarizeOutput(output, displayMax);
|
|
896
|
+
const displayText = displaySummary.truncated
|
|
897
|
+
? `${displaySummary.text}${savedOutputPath ? chalk.dim(`\n ... full output saved to ${savedOutputPath}`) : ""}`
|
|
898
|
+
: displaySummary.text;
|
|
893
899
|
const renderedOutput = indentAndWrapText(displayText);
|
|
894
|
-
|
|
900
|
+
process.stdout.write(styleToolChatter(call, renderedOutput) + "\n");
|
|
901
|
+
if (savedOutputPath && displaySummary.truncated) {
|
|
902
|
+
process.stdout.write(chalk.dim(` full output saved to ${savedOutputPath}\n`));
|
|
903
|
+
}
|
|
895
904
|
}
|
|
896
905
|
}
|
|
897
906
|
if (output) {
|
|
@@ -917,7 +926,6 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
917
926
|
// what is done, and what remains. The estimate is chars/4; the budget is
|
|
918
927
|
// deliberately conservative so we compact a little early rather than hit a
|
|
919
928
|
// provider context-window error mid-task.
|
|
920
|
-
const AUTO_COMPACT_TOKEN_BUDGET = 150_000;
|
|
921
929
|
const AUTO_COMPACT_KEEP_RECENT = 6;
|
|
922
930
|
let lastCompactionMsgCount = 0;
|
|
923
931
|
const summarizeForCompaction = async (summaryPrompt) => {
|
|
@@ -953,6 +961,8 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
953
961
|
return;
|
|
954
962
|
messages.splice(0, messages.length, ...result.messages);
|
|
955
963
|
loopGuard.resetReadOnly();
|
|
964
|
+
// Token stats BEFORE plan re-injection so the reduction is accurate.
|
|
965
|
+
const compactedTokens = estimateMessagesTokens(messages);
|
|
956
966
|
// Re-inject the live plan so the model keeps full plan awareness even
|
|
957
967
|
// after older turns (which carried the plan context) were summarized.
|
|
958
968
|
const livePlan = await loadPlan(session.sessionId).catch(() => undefined);
|
|
@@ -963,13 +973,11 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
963
973
|
});
|
|
964
974
|
}
|
|
965
975
|
lastCompactionMsgCount = messages.length;
|
|
966
|
-
//
|
|
967
|
-
|
|
968
|
-
// final count (which is what the model actually receives) separately.
|
|
969
|
-
const compactedTokens = estimateMessagesTokens(messages);
|
|
976
|
+
// Final count the model actually receives (may include re-injected plan).
|
|
977
|
+
const afterTokens = estimateMessagesTokens(messages);
|
|
970
978
|
await auditLog("agent.compact", {
|
|
971
979
|
newLength: messages.length,
|
|
972
|
-
estimatedTokens:
|
|
980
|
+
estimatedTokens: afterTokens,
|
|
973
981
|
reason,
|
|
974
982
|
});
|
|
975
983
|
// Extract the inserted compaction memory so we can surface the
|
|
@@ -981,12 +989,12 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
981
989
|
const summaryText = insertedSummary.startsWith(`${COMPACTION_MEMORY_PREFIX}\n\n`)
|
|
982
990
|
? insertedText(insertedSummary, `${COMPACTION_MEMORY_PREFIX}\n\n`)
|
|
983
991
|
: insertedText(insertedSummary, COMPACTION_MEMORY_PREFIX);
|
|
984
|
-
|
|
985
|
-
writeCompacted(summaryText, beforeTokens,
|
|
992
|
+
// Card shows pre/post of the summarization; plan re-injection is noted.
|
|
993
|
+
writeCompacted(summaryText, beforeTokens, compactedTokens);
|
|
986
994
|
const planNote = afterTokens > compactedTokens
|
|
987
995
|
? ` (compacted to ~${compactedTokens.toLocaleString()}, +plan → ~${afterTokens.toLocaleString()})`
|
|
988
996
|
: "";
|
|
989
|
-
writeNotice("info", `context auto-compacted to fit the window (~${beforeTokens.toLocaleString()} → ~${
|
|
997
|
+
writeNotice("info", `context auto-compacted to fit the window (~${beforeTokens.toLocaleString()} → ~${compactedTokens.toLocaleString()} tokens${planNote})`, chalk.dim(` ℹ context auto-compacted (~${beforeTokens.toLocaleString()} → ~${compactedTokens.toLocaleString()} tokens${planNote})\n`));
|
|
990
998
|
}
|
|
991
999
|
catch (error) {
|
|
992
1000
|
if (error instanceof Error &&
|
|
@@ -1111,10 +1119,11 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
1111
1119
|
completion = await streamWithProvider({
|
|
1112
1120
|
provider,
|
|
1113
1121
|
model,
|
|
1114
|
-
//
|
|
1115
|
-
//
|
|
1116
|
-
//
|
|
1117
|
-
|
|
1122
|
+
// Stay on the user's selected provider/model. Cross-provider
|
|
1123
|
+
// hops (e.g. bynara → gemini on a 429) only happen when the
|
|
1124
|
+
// user has explicitly enabled `providerFallback` AND this is
|
|
1125
|
+
// the provider's default model. Never force fallback mid-turn.
|
|
1126
|
+
allowModelFallback: false,
|
|
1118
1127
|
messages,
|
|
1119
1128
|
// MiniMax M3 degenerates at the generic agent temperature. The
|
|
1120
1129
|
// HTTP layer also applies its `top_p` override for both the
|
|
@@ -1481,6 +1490,7 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
1481
1490
|
// final answer ends the turn with nothing done and no real plan saved.
|
|
1482
1491
|
// Nudge it to emit a real tool call, with a concrete example.
|
|
1483
1492
|
const narratedAction = looksLikeActionNarration(cleaned);
|
|
1493
|
+
const narratedWebAction = looksLikeWebActionNarration(cleaned);
|
|
1484
1494
|
// `activePlan` is the snapshot loaded at the start of this turn.
|
|
1485
1495
|
// A final task.update mutates and persists a separate plan instance,
|
|
1486
1496
|
// so re-read it here before deciding whether a final response should
|
|
@@ -1493,15 +1503,24 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
1493
1503
|
const completedPlanDuringThisTurn = activePlan?.status !== "completed" &&
|
|
1494
1504
|
planStatusAtCompletion === "completed";
|
|
1495
1505
|
const planHasOpenWorkNow = planHasOpenWork(planStatusAtCompletion);
|
|
1506
|
+
// User-driven reasons to require tools this turn (build/pentest/
|
|
1507
|
+
// approved plan / freshness). Idle greetings never qualify.
|
|
1508
|
+
const userExpectsWork = freshWebSearchRequired ||
|
|
1509
|
+
(planHasOpenWorkNow && session.planApproved.value) ||
|
|
1510
|
+
(!informationalQuery &&
|
|
1511
|
+
!idleOrSocialPrompt &&
|
|
1512
|
+
(buildLikeTurn || pentestLikeTurn));
|
|
1496
1513
|
// History-inherited build/pentest intent only forces action when
|
|
1497
|
-
// THIS prompt is not itself a plain question
|
|
1498
|
-
//
|
|
1499
|
-
//
|
|
1514
|
+
// THIS prompt is not itself a plain question/idle turn. Narration
|
|
1515
|
+
// stalls ("I'll list the files") still force a tool when the user
|
|
1516
|
+
// is not asking an informational question — but capability menus
|
|
1517
|
+
// and greetings are filtered out by looksLikeActionNarration /
|
|
1518
|
+
// idleOrSocialPrompt so they cannot burn recovery turns.
|
|
1500
1519
|
const wantsAction = !completedPlanDuringThisTurn &&
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
(
|
|
1504
|
-
(
|
|
1520
|
+
!idleOrSocialPrompt &&
|
|
1521
|
+
(userExpectsWork ||
|
|
1522
|
+
(narratedAction && !informationalQuery) ||
|
|
1523
|
+
(narratedWebAction && !informationalQuery));
|
|
1505
1524
|
const planNarrated = (buildLikeTurn || pentestLikeTurn) &&
|
|
1506
1525
|
!activePlan &&
|
|
1507
1526
|
looksLikePlanNarration(cleaned);
|
|
@@ -1528,14 +1547,20 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
1528
1547
|
"Every turn MUST contain a ```tool block until the task is done.";
|
|
1529
1548
|
writeNotice("warn", "described a security/pentest action but emitted no tool call — nudging it to run one", chalk.yellow(" ⚠ described a security/pentest action but emitted no tool call — nudging it to run one\n"));
|
|
1530
1549
|
}
|
|
1531
|
-
else if (
|
|
1550
|
+
else if (freshWebSearchRequired || narratedWebAction) {
|
|
1551
|
+
// Web-specific recovery ONLY when the user asked for current
|
|
1552
|
+
// info or the model explicitly claimed a fetch/search step.
|
|
1553
|
+
// Previously every non-build stall used this path, so a "hi"
|
|
1554
|
+
// greeting that said "I'll start executing" was forced into
|
|
1555
|
+
// pointless web.search recovery loops.
|
|
1532
1556
|
nudge =
|
|
1533
1557
|
"You wrote that you would fetch/search/read something but emitted NO ```tool block, so NOTHING ran. Do NOT narrate the next browsing step — DO it. Emit exactly one valid ```tool block now. If you know the exact page, use:\n" +
|
|
1534
1558
|
'```tool\n{"name":"web.fetch","args":{"url":"https://example.com/page","responseMode":"readable"}}\n```\n' +
|
|
1535
1559
|
"If you do not know the exact page URL, use web.search first. After the tool output, answer from the fetched page content.";
|
|
1536
1560
|
writeNotice("warn", "described a web action but emitted no tool call — nudging it to run one", chalk.yellow(" ⚠ described a web action but emitted no tool call — nudging it to run one\n"));
|
|
1537
1561
|
}
|
|
1538
|
-
else if (
|
|
1562
|
+
else if (buildLikeTurn &&
|
|
1563
|
+
(planNarrated || productiveSteps > 0)) {
|
|
1539
1564
|
const kind = pentestLikeTurn ? "pentest" : "coding";
|
|
1540
1565
|
nudge =
|
|
1541
1566
|
"You wrote the plan as PROSE but did NOT call plan.create, so no plan was saved and the user cannot /implement it. Emit it as a real tool call NOW — exactly one ```tool block:\n" +
|
|
@@ -1543,17 +1568,17 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
1543
1568
|
"Do not describe the plan again in prose — just emit the plan.create tool block.";
|
|
1544
1569
|
writeNotice("warn", "plan was written as text, not created — nudging it to call plan.create", chalk.yellow(" ⚠ plan was written as text, not created — nudging it to call plan.create\n"));
|
|
1545
1570
|
}
|
|
1571
|
+
else if (buildLikeTurn) {
|
|
1572
|
+
nudge =
|
|
1573
|
+
"You described what you will do but emitted NO ```tool block, so NOTHING actually happened — narration is not action. Emit a real tool call NOW. For this build task, explore first like this:\n" +
|
|
1574
|
+
'```tool\n{"name":"fs.list","args":{"path":"."}}\n```\n' +
|
|
1575
|
+
"Then read key files, and once you understand the directory, call plan.create. Every turn MUST contain a ```tool block until the task is done.";
|
|
1576
|
+
writeNotice("warn", "described an action but emitted no tool call — nudging it to run one", chalk.yellow(" ⚠ described an action but emitted no tool call — nudging it to run one\n"));
|
|
1577
|
+
}
|
|
1546
1578
|
else {
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
}
|
|
1551
|
-
else {
|
|
1552
|
-
nudge =
|
|
1553
|
-
"You described what you will do but emitted NO ```tool block, so NOTHING actually happened — narration is not action. Emit a real tool call NOW. For this build task, explore first like this:\n" +
|
|
1554
|
-
'```tool\n{"name":"fs.list","args":{"path":"."}}\n```\n' +
|
|
1555
|
-
"Then read key files, and once you understand the directory, call plan.create. Every turn MUST contain a ```tool block until the task is done.";
|
|
1556
|
-
}
|
|
1579
|
+
// Generic non-build, non-web stall (e.g. "I'll list the files").
|
|
1580
|
+
nudge =
|
|
1581
|
+
"You described what you will do but emitted NO ```tool block, so NOTHING actually happened — narration is not action. Emit a real tool call NOW for the step you just described. Every turn that claims an action MUST contain a ```tool block.";
|
|
1557
1582
|
writeNotice("warn", "described an action but emitted no tool call — nudging it to run one", chalk.yellow(" ⚠ described an action but emitted no tool call — nudging it to run one\n"));
|
|
1558
1583
|
}
|
|
1559
1584
|
pushAssistantHistory(assistantText.visible);
|
|
@@ -1740,7 +1765,12 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
1740
1765
|
`${omittedCallCount} were not run. After reviewing results, issue a small, prioritized next batch.`,
|
|
1741
1766
|
});
|
|
1742
1767
|
}
|
|
1743
|
-
//
|
|
1768
|
+
// Notice BEFORE tool cards so the transcript reads:
|
|
1769
|
+
// thinking → response → "N tool calls…" → tool cards (not tools then info).
|
|
1770
|
+
if (allCalls.length > 1) {
|
|
1771
|
+
writeNotice("info", `${allCalls.length} tool calls in this message — running scoped (independent read-only lookups in parallel, everything else in order)`, chalk.dim(` ℹ ${allCalls.length} tool calls — read-only lookups in parallel, the rest in order\n`));
|
|
1772
|
+
}
|
|
1773
|
+
// Emit only the calls that will actually execute, after thinking
|
|
1744
1774
|
// + assistant text so transcript order remains correct.
|
|
1745
1775
|
for (const deferred of activeDeferredToolCalls.slice(0, allCalls.length)) {
|
|
1746
1776
|
writeToolCall(deferred.eventId, deferred.call, deferred.rendered);
|
|
@@ -1750,9 +1780,6 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
1750
1780
|
.map((c) => `\`\`\`tool\n${JSON.stringify(c)}\n\`\`\``)
|
|
1751
1781
|
.join("\n\n");
|
|
1752
1782
|
pushAssistantHistory(standardizedContent);
|
|
1753
|
-
if (allCalls.length > 1) {
|
|
1754
|
-
writeNotice("info", `${allCalls.length} tool calls in this message — running scoped (independent read-only lookups in parallel, everything else in order)`, chalk.dim(` ℹ ${allCalls.length} tool calls — read-only lookups in parallel, the rest in order\n`));
|
|
1755
|
-
}
|
|
1756
1783
|
// Scoped-parallel batch execution
|
|
1757
1784
|
// The model may emit several calls in one message. We partition them,
|
|
1758
1785
|
// IN DOCUMENT ORDER, into segments:
|
|
@@ -1788,7 +1815,12 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
1788
1815
|
let blockedResult = null;
|
|
1789
1816
|
let failed = false;
|
|
1790
1817
|
let awaitingPlanApproval = false;
|
|
1818
|
+
/** Indices into allCalls that actually ran (got a tool-result). */
|
|
1819
|
+
const executedIndices = new Set();
|
|
1791
1820
|
const recordResult = (res, continueAfterFailure = false) => {
|
|
1821
|
+
const idx = allCalls.indexOf(res.call);
|
|
1822
|
+
if (idx >= 0)
|
|
1823
|
+
executedIndices.add(idx);
|
|
1792
1824
|
messages.push({
|
|
1793
1825
|
role: "tool",
|
|
1794
1826
|
content: `Tool ${res.call.name} result (exit=${res.result.exitCode ?? 0}, ok=${res.result.ok}):\n${res.contextOutput}`,
|
|
@@ -1853,6 +1885,41 @@ export async function runAgentLoop(prompt, options = {}) {
|
|
|
1853
1885
|
recordResult(res, true);
|
|
1854
1886
|
}
|
|
1855
1887
|
}
|
|
1888
|
+
// Cards were emitted for every call up front. If the batch stopped
|
|
1889
|
+
// early (failure / abort / plan gate), any card still on "running"
|
|
1890
|
+
// must get a terminal result so the TUI never spins forever.
|
|
1891
|
+
for (let i = 0; i < allCalls.length; i += 1) {
|
|
1892
|
+
if (executedIndices.has(i))
|
|
1893
|
+
continue;
|
|
1894
|
+
const call = allCalls[i];
|
|
1895
|
+
if (i >= 0 && !callIds[i]) {
|
|
1896
|
+
callIds[i] = `tool-${++nextToolEventId}`;
|
|
1897
|
+
}
|
|
1898
|
+
const id = callIds[i];
|
|
1899
|
+
if (!alreadyPrintedIds.has(id)) {
|
|
1900
|
+
// Never shown in the transcript — skip.
|
|
1901
|
+
continue;
|
|
1902
|
+
}
|
|
1903
|
+
const reason = aborted
|
|
1904
|
+
? "Cancelled — turn aborted before this call ran."
|
|
1905
|
+
: blocked
|
|
1906
|
+
? "Cancelled — earlier tool was blocked or declined."
|
|
1907
|
+
: awaitingPlanApproval
|
|
1908
|
+
? "Deferred — waiting for plan approval."
|
|
1909
|
+
: failed
|
|
1910
|
+
? "Cancelled — earlier tool in this batch failed."
|
|
1911
|
+
: "Cancelled — not executed.";
|
|
1912
|
+
const result = {
|
|
1913
|
+
ok: false,
|
|
1914
|
+
output: reason,
|
|
1915
|
+
exitCode: 130,
|
|
1916
|
+
};
|
|
1917
|
+
emitToolResult(id, result, reason);
|
|
1918
|
+
messages.push({
|
|
1919
|
+
role: "tool",
|
|
1920
|
+
content: `Tool ${call.name} result (exit=130, ok=false):\n${reason}`,
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1856
1923
|
// plan.create is a hard transaction boundary. Its successful handler
|
|
1857
1924
|
// persists and displays the plan; returning immediately prevents a
|
|
1858
1925
|
// stale pre-loop activePlan snapshot from nudging a duplicate plan and
|