lsd-pi 1.2.4 → 1.3.6
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 +22 -16
- package/dist/app-paths.d.ts +4 -0
- package/dist/app-paths.js +4 -0
- package/dist/bedrock-auth.d.ts +4 -0
- package/dist/bedrock-auth.js +4 -0
- package/dist/bundled-extension-paths.d.ts +4 -0
- package/dist/bundled-extension-paths.js +4 -0
- package/dist/cli-theme.d.ts +2 -2
- package/dist/cli-theme.js +13 -14
- package/dist/cli.js +43 -3
- package/dist/codex-rotate-settings.d.ts +4 -0
- package/dist/codex-rotate-settings.js +4 -0
- package/dist/help-text.d.ts +4 -0
- package/dist/help-text.js +4 -0
- package/dist/lsd-brand.d.ts +4 -0
- package/dist/lsd-brand.js +4 -0
- package/dist/onboarding-llm.d.ts +5 -0
- package/dist/onboarding-llm.js +5 -0
- package/dist/project-sessions.d.ts +4 -0
- package/dist/project-sessions.js +4 -0
- package/dist/resources/agents/generic.md +1 -0
- package/dist/resources/agents/scout.md +8 -1
- package/dist/resources/agents/worker.md +1 -0
- package/dist/resources/extensions/ask-user-questions.js +70 -0
- package/dist/resources/extensions/bg-shell/bg-shell-tool.js +6 -16
- package/dist/resources/extensions/browser-tools/tools/codegen.js +5 -5
- package/dist/resources/extensions/browser-tools/tools/navigation.js +107 -178
- package/dist/resources/extensions/browser-tools/tools/network-mock.js +112 -167
- package/dist/resources/extensions/browser-tools/tools/pages.js +182 -234
- package/dist/resources/extensions/browser-tools/tools/refs.js +202 -461
- package/dist/resources/extensions/browser-tools/tools/session.js +176 -323
- package/dist/resources/extensions/browser-tools/tools/state-persistence.js +91 -154
- package/dist/resources/extensions/browser-tools/utils.js +1 -1
- package/dist/resources/extensions/mac-tools/index.js +19 -34
- package/dist/resources/extensions/memory/index.js +20 -2
- package/dist/resources/extensions/shared/interview-ui.js +103 -20
- package/dist/resources/extensions/slash-commands/extension-manifest.json +2 -2
- package/dist/resources/extensions/slash-commands/fast.js +73 -0
- package/dist/resources/extensions/slash-commands/index.js +2 -0
- package/dist/resources/extensions/slash-commands/plan.js +54 -28
- package/dist/resources/extensions/slash-commands/tools.js +40 -4
- package/dist/resources/extensions/subagent/agent-switcher-component.js +208 -0
- package/dist/resources/extensions/subagent/agent-switcher-model.js +107 -0
- package/dist/resources/extensions/subagent/background-job-manager.js +24 -6
- package/dist/resources/extensions/subagent/background-runner.js +4 -0
- package/dist/resources/extensions/subagent/in-process-runner.js +387 -0
- package/dist/resources/extensions/subagent/index.js +715 -370
- package/dist/resources/extensions/subagent/launch-helpers.js +19 -5
- package/dist/resources/extensions/subagent/legacy-runner.js +503 -0
- package/dist/resources/extensions/voice/index.js +96 -36
- package/dist/resources/extensions/voice/push-to-talk.js +26 -0
- package/dist/shared-paths.d.ts +4 -0
- package/dist/shared-paths.js +4 -0
- package/dist/shared-preferences.d.ts +4 -0
- package/dist/shared-preferences.js +4 -0
- package/dist/startup-model-validation.d.ts +1 -1
- package/dist/startup-timings.d.ts +4 -0
- package/dist/startup-timings.js +4 -0
- package/dist/update-check.d.ts +4 -0
- package/dist/update-check.js +4 -0
- package/dist/update-cmd.d.ts +4 -0
- package/dist/update-cmd.js +4 -0
- package/dist/welcome-screen.js +4 -4
- package/dist/wizard.d.ts +4 -0
- package/dist/wizard.js +4 -0
- package/package.json +1 -1
- package/packages/pi-agent-core/dist/agent.d.ts +28 -0
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent.js +105 -5
- package/packages/pi-agent-core/dist/agent.js.map +1 -1
- package/packages/pi-agent-core/dist/types.d.ts +13 -2
- package/packages/pi-agent-core/dist/types.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/types.js.map +1 -1
- package/packages/pi-agent-core/src/agent.ts +142 -6
- package/packages/pi-agent-core/src/types.ts +12 -3
- package/packages/pi-ai/dist/adaptive/classifier.d.ts +29 -0
- package/packages/pi-ai/dist/adaptive/classifier.d.ts.map +1 -0
- package/packages/pi-ai/dist/adaptive/classifier.js +72 -0
- package/packages/pi-ai/dist/adaptive/classifier.js.map +1 -0
- package/packages/pi-ai/dist/adaptive/classifier.test.d.ts +2 -0
- package/packages/pi-ai/dist/adaptive/classifier.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/adaptive/classifier.test.js +32 -0
- package/packages/pi-ai/dist/adaptive/classifier.test.js.map +1 -0
- package/packages/pi-ai/dist/index.d.ts +1 -0
- package/packages/pi-ai/dist/index.d.ts.map +1 -1
- package/packages/pi-ai/dist/index.js +1 -0
- package/packages/pi-ai/dist/index.js.map +1 -1
- package/packages/pi-ai/dist/providers/amazon-bedrock.js +0 -2
- package/packages/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-shared.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-shared.js +0 -2
- package/packages/pi-ai/dist/providers/anthropic-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts +1 -1
- package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
- package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/google-gemini-cli.js +0 -4
- package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -1
- package/packages/pi-ai/dist/providers/google-vertex.js +0 -5
- package/packages/pi-ai/dist/providers/google-vertex.js.map +1 -1
- package/packages/pi-ai/dist/providers/google.js +0 -5
- package/packages/pi-ai/dist/providers/google.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts +35 -2
- package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-codex-responses.js +32 -6
- package/packages/pi-ai/dist/providers/openai-codex-responses.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-codex-responses.test.js +127 -16
- package/packages/pi-ai/dist/providers/openai-codex-responses.test.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.d.ts +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.js +0 -1
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-responses.d.ts +9 -2
- package/packages/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-responses.fast-mode.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/openai-responses.fast-mode.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/openai-responses.fast-mode.test.js +67 -0
- package/packages/pi-ai/dist/providers/openai-responses.fast-mode.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/openai-responses.js +21 -3
- package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-shared.d.ts +0 -1
- package/packages/pi-ai/dist/providers/openai-shared.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-shared.js +0 -4
- package/packages/pi-ai/dist/providers/openai-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/simple-options.js +2 -1
- package/packages/pi-ai/dist/providers/simple-options.js.map +1 -1
- package/packages/pi-ai/dist/types.d.ts +6 -2
- package/packages/pi-ai/dist/types.d.ts.map +1 -1
- package/packages/pi-ai/dist/types.js.map +1 -1
- package/packages/pi-ai/src/adaptive/classifier.test.ts +38 -0
- package/packages/pi-ai/src/adaptive/classifier.ts +107 -0
- package/packages/pi-ai/src/index.ts +1 -0
- package/packages/pi-ai/src/providers/amazon-bedrock.ts +0 -2
- package/packages/pi-ai/src/providers/anthropic-shared.ts +0 -2
- package/packages/pi-ai/src/providers/azure-openai-responses.ts +1 -1
- package/packages/pi-ai/src/providers/google-gemini-cli.ts +0 -4
- package/packages/pi-ai/src/providers/google-vertex.ts +0 -5
- package/packages/pi-ai/src/providers/google.ts +0 -5
- package/packages/pi-ai/src/providers/openai-codex-responses.test.ts +143 -20
- package/packages/pi-ai/src/providers/openai-codex-responses.ts +48 -7
- package/packages/pi-ai/src/providers/openai-completions.ts +1 -2
- package/packages/pi-ai/src/providers/openai-responses.fast-mode.test.ts +73 -0
- package/packages/pi-ai/src/providers/openai-responses.ts +27 -4
- package/packages/pi-ai/src/providers/openai-shared.ts +0 -3
- package/packages/pi-ai/src/providers/simple-options.ts +2 -1
- package/packages/pi-ai/src/types.ts +6 -2
- package/packages/pi-coding-agent/dist/cli/args.js +2 -2
- package/packages/pi-coding-agent/dist/cli/args.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts +7 -2
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +53 -20
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/keybindings.d.ts +1 -1
- package/packages/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/keybindings.js +2 -0
- package/packages/pi-coding-agent/dist/core/keybindings.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/lsp.md +3 -1
- package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.js +36 -8
- package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.test.js +37 -0
- package/packages/pi-coding-agent/dist/core/sdk.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts +8 -0
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.js +4 -0
- package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +18 -7
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.fast-mode.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.fast-mode.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.fast-mode.test.js +35 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.fast-mode.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.js +32 -2
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/skills.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/skills.js +4 -1
- package/packages/pi-coding-agent/dist/core/skills.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/slash-commands.js +2 -1
- package/packages/pi-coding-agent/dist/core/slash-commands.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.js +12 -3
- package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tool-priority.d.ts +4 -0
- package/packages/pi-coding-agent/dist/core/tool-priority.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tool-priority.js +18 -0
- package/packages/pi-coding-agent/dist/core/tool-priority.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tool-priority.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tool-priority.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tool-priority.test.js +27 -0
- package/packages/pi-coding-agent/dist/core/tool-priority.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/grep.js +1 -1
- package/packages/pi-coding-agent/dist/core/tools/grep.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/index.js +2 -0
- package/packages/pi-coding-agent/dist/core/tools/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/pty.d.ts +10 -1
- package/packages/pi-coding-agent/dist/core/tools/pty.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/pty.js +29 -3
- package/packages/pi-coding-agent/dist/core/tools/pty.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-summary-line.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-summary-line.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-summary-line.test.js +26 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-summary-line.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.d.ts +45 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.js +314 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.test.js +122 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/embedded-terminal.js +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/embedded-terminal.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +19 -2
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts +11 -2
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +49 -6
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js +1 -2
- package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +6 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +18 -4
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-summary-line.d.ts +13 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-summary-line.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-summary-line.js +49 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-summary-line.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/__tests__/chat-controller.collapsed-tool-summary.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/__tests__/chat-controller.collapsed-tool-summary.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/__tests__/chat-controller.collapsed-tool-summary.test.js +197 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/__tests__/chat-controller.collapsed-tool-summary.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +106 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.js +7 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts +3 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +4 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +88 -2
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +41 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +2 -2
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +10 -6
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/print-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/print-mode.js +6 -0
- package/packages/pi-coding-agent/dist/modes/print-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js +20 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/tests/path-display.test.js +15 -0
- package/packages/pi-coding-agent/dist/tests/path-display.test.js.map +1 -1
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/cli/args.ts +2 -2
- package/packages/pi-coding-agent/src/core/agent-session.ts +58 -21
- package/packages/pi-coding-agent/src/core/keybindings.ts +4 -1
- package/packages/pi-coding-agent/src/core/lsp/lsp.md +3 -1
- package/packages/pi-coding-agent/src/core/sdk.test.ts +45 -0
- package/packages/pi-coding-agent/src/core/sdk.ts +39 -8
- package/packages/pi-coding-agent/src/core/session-manager.ts +12 -0
- package/packages/pi-coding-agent/src/core/settings-manager.fast-mode.test.ts +46 -0
- package/packages/pi-coding-agent/src/core/settings-manager.ts +50 -9
- package/packages/pi-coding-agent/src/core/skills.ts +4 -1
- package/packages/pi-coding-agent/src/core/slash-commands.ts +2 -1
- package/packages/pi-coding-agent/src/core/system-prompt.ts +14 -3
- package/packages/pi-coding-agent/src/core/tool-priority.test.ts +30 -0
- package/packages/pi-coding-agent/src/core/tool-priority.ts +17 -0
- package/packages/pi-coding-agent/src/core/tools/grep.ts +1 -1
- package/packages/pi-coding-agent/src/core/tools/index.ts +3 -0
- package/packages/pi-coding-agent/src/core/tools/pty.ts +45 -6
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-summary-line.test.ts +31 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/btw-overlay.test.ts +172 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/btw-overlay.ts +402 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/embedded-terminal.ts +1 -1
- package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +18 -2
- package/packages/pi-coding-agent/src/modes/interactive/components/settings-selector.ts +63 -9
- package/packages/pi-coding-agent/src/modes/interactive/components/thinking-selector.ts +1 -2
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +1154 -1136
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-summary-line.ts +64 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/__tests__/chat-controller.collapsed-tool-summary.test.ts +228 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +494 -389
- package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.ts +7 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-state.ts +3 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +103 -3
- package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +60 -1
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +11 -7
- package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +1 -1
- package/packages/pi-coding-agent/src/modes/print-mode.ts +6 -0
- package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +29 -0
- package/packages/pi-coding-agent/src/tests/path-display.test.ts +17 -0
- package/packages/pi-tui/dist/components/loader.d.ts +5 -2
- package/packages/pi-tui/dist/components/loader.d.ts.map +1 -1
- package/packages/pi-tui/dist/components/loader.js +33 -3
- package/packages/pi-tui/dist/components/loader.js.map +1 -1
- package/packages/pi-tui/src/components/loader.ts +31 -3
- package/packages/rpc-client/src/index.ts +1 -1
- package/packages/rpc-client/src/rpc-client.ts +29 -0
- package/packages/rpc-client/src/rpc-types.ts +1 -1
- package/pkg/dist/modes/interactive/theme/theme.d.ts +2 -2
- package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.js +10 -6
- package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
- package/pkg/dist/modes/interactive/theme/themes.js +1 -1
- package/pkg/dist/modes/interactive/theme/themes.js.map +1 -1
- package/pkg/package.json +1 -1
- package/src/resources/agents/generic.md +1 -0
- package/src/resources/agents/scout.md +8 -1
- package/src/resources/agents/worker.md +1 -0
- package/src/resources/extensions/ask-user-questions.ts +88 -0
- package/src/resources/extensions/bg-shell/bg-shell-tool.ts +6 -16
- package/src/resources/extensions/browser-tools/tools/codegen.ts +5 -5
- package/src/resources/extensions/browser-tools/tools/navigation.ts +118 -196
- package/src/resources/extensions/browser-tools/tools/network-mock.ts +114 -205
- package/src/resources/extensions/browser-tools/tools/pages.ts +183 -237
- package/src/resources/extensions/browser-tools/tools/refs.ts +193 -507
- package/src/resources/extensions/browser-tools/tools/session.ts +182 -321
- package/src/resources/extensions/browser-tools/tools/state-persistence.ts +94 -172
- package/src/resources/extensions/browser-tools/utils.ts +1 -1
- package/src/resources/extensions/mac-tools/index.ts +19 -34
- package/src/resources/extensions/memory/index.ts +22 -2
- package/src/resources/extensions/shared/interview-ui.ts +108 -15
- package/src/resources/extensions/shared/tests/ask-user-freetext.test.ts +61 -0
- package/src/resources/extensions/shared/tests/custom-ui-fallbacks.test.ts +46 -0
- package/src/resources/extensions/slash-commands/extension-manifest.json +2 -2
- package/src/resources/extensions/slash-commands/fast.ts +89 -0
- package/src/resources/extensions/slash-commands/index.ts +2 -0
- package/src/resources/extensions/slash-commands/plan.ts +59 -30
- package/src/resources/extensions/slash-commands/tools.ts +43 -4
- package/src/resources/extensions/subagent/agent-switcher-component.ts +228 -0
- package/src/resources/extensions/subagent/agent-switcher-model.ts +160 -0
- package/src/resources/extensions/subagent/background-job-manager.ts +57 -6
- package/src/resources/extensions/subagent/background-runner.ts +8 -0
- package/src/resources/extensions/subagent/background-types.ts +4 -0
- package/src/resources/extensions/subagent/in-process-runner.ts +534 -0
- package/src/resources/extensions/subagent/index.ts +998 -493
- package/src/resources/extensions/subagent/launch-helpers.ts +15 -4
- package/src/resources/extensions/subagent/legacy-runner.ts +607 -0
- package/src/resources/extensions/voice/index.ts +308 -238
- package/src/resources/extensions/voice/push-to-talk.ts +42 -0
- package/src/resources/extensions/voice/tests/push-to-talk.test.ts +109 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { shortcutDesc } from "../shared/mod.js";
|
|
2
|
-
import { isKeyRelease, Key, matchesKey, truncateToWidth, visibleWidth } from "@gsd/pi-tui";
|
|
2
|
+
import { isKeyRelease, isKittyProtocolActive, Key, matchesKey, truncateToWidth, visibleWidth } from "@gsd/pi-tui";
|
|
3
3
|
import { spawn, execFileSync } from "node:child_process";
|
|
4
4
|
import * as fs from "node:fs";
|
|
5
5
|
import * as path from "node:path";
|
|
6
6
|
import * as readline from "node:readline";
|
|
7
7
|
import { linuxPython, diagnoseSounddeviceError, ensureVoiceVenv } from "./linux-ready.js";
|
|
8
|
+
import { handlePushToTalkInput } from "./push-to-talk.js";
|
|
8
9
|
const __extensionDir = import.meta.dirname;
|
|
9
10
|
const SWIFT_SRC = path.join(__extensionDir, "speech-recognizer.swift");
|
|
10
11
|
const RECOGNIZER_BIN = path.join(__extensionDir, "speech-recognizer");
|
|
@@ -76,10 +77,14 @@ export default function (pi) {
|
|
|
76
77
|
if (!IS_DARWIN && !IS_LINUX)
|
|
77
78
|
return;
|
|
78
79
|
let active = false;
|
|
80
|
+
let activationMode = null;
|
|
79
81
|
let recognizerProcess = null;
|
|
80
82
|
let flashOn = true;
|
|
81
83
|
let flashTimer = null;
|
|
82
84
|
let footerTui = null;
|
|
85
|
+
let closeVoiceOverlay = null;
|
|
86
|
+
let voiceSessionPromise = null;
|
|
87
|
+
let holdToTalkUnsupportedNotified = false;
|
|
83
88
|
function setVoiceFooter(ctx, on) {
|
|
84
89
|
if (!on) {
|
|
85
90
|
stopFlash();
|
|
@@ -153,41 +158,59 @@ export default function (pi) {
|
|
|
153
158
|
}
|
|
154
159
|
footerTui = null;
|
|
155
160
|
}
|
|
156
|
-
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
setVoiceFooter(ctx, false);
|
|
161
|
-
return;
|
|
161
|
+
function killRecognizer() {
|
|
162
|
+
if (recognizerProcess) {
|
|
163
|
+
recognizerProcess.kill("SIGTERM");
|
|
164
|
+
recognizerProcess = null;
|
|
162
165
|
}
|
|
166
|
+
}
|
|
167
|
+
function prepareVoice(ctx) {
|
|
163
168
|
if (IS_DARWIN) {
|
|
164
169
|
if (!ensureBinary()) {
|
|
165
170
|
ctx.ui.notify("Voice: failed to compile speech recognizer (need Xcode CLI tools)", "error");
|
|
166
|
-
return;
|
|
171
|
+
return false;
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
174
|
else if (IS_LINUX) {
|
|
170
175
|
if (!ensureLinuxReady(ctx)) {
|
|
171
|
-
return;
|
|
176
|
+
return false;
|
|
172
177
|
}
|
|
173
178
|
}
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
async function startVoice(ctx, mode) {
|
|
182
|
+
if (active)
|
|
183
|
+
return false;
|
|
184
|
+
if (!prepareVoice(ctx))
|
|
185
|
+
return false;
|
|
174
186
|
active = true;
|
|
187
|
+
activationMode = mode;
|
|
175
188
|
setVoiceFooter(ctx, true);
|
|
176
|
-
|
|
189
|
+
voiceSessionPromise = runVoiceSession(ctx).finally(() => {
|
|
190
|
+
if (voiceSessionPromise) {
|
|
191
|
+
voiceSessionPromise = null;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
return true;
|
|
177
195
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
196
|
+
async function stopVoice(ctx) {
|
|
197
|
+
if (!active && !closeVoiceOverlay && !recognizerProcess)
|
|
198
|
+
return;
|
|
199
|
+
killRecognizer();
|
|
200
|
+
active = false;
|
|
201
|
+
activationMode = null;
|
|
202
|
+
setVoiceFooter(ctx, false);
|
|
203
|
+
const close = closeVoiceOverlay;
|
|
204
|
+
closeVoiceOverlay = null;
|
|
205
|
+
close?.();
|
|
206
|
+
await voiceSessionPromise;
|
|
207
|
+
}
|
|
208
|
+
async function toggleVoice(ctx) {
|
|
209
|
+
if (active) {
|
|
210
|
+
await stopVoice(ctx);
|
|
211
|
+
return;
|
|
190
212
|
}
|
|
213
|
+
await startVoice(ctx, "toggle");
|
|
191
214
|
}
|
|
192
215
|
function startRecognizer(onPartial, onFinal, onError, onReady) {
|
|
193
216
|
if (IS_LINUX) {
|
|
@@ -224,20 +247,57 @@ export default function (pi) {
|
|
|
224
247
|
}, (text) => {
|
|
225
248
|
ctx.ui.setEditorText(text);
|
|
226
249
|
}, (msg) => ctx.ui.notify(`Voice: ${msg}`, "error"), () => { });
|
|
227
|
-
ctx.ui.custom((_tui, _theme, _kb, done) =>
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
250
|
+
ctx.ui.custom((_tui, _theme, _kb, done) => {
|
|
251
|
+
const close = () => done();
|
|
252
|
+
closeVoiceOverlay = close;
|
|
253
|
+
return {
|
|
254
|
+
render() { return []; },
|
|
255
|
+
handleInput(data) {
|
|
256
|
+
if (isKeyRelease(data))
|
|
257
|
+
return;
|
|
258
|
+
if (matchesKey(data, Key.escape) || matchesKey(data, Key.enter)) {
|
|
259
|
+
void stopVoice(ctx);
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
invalidate() { },
|
|
263
|
+
dispose() {
|
|
264
|
+
if (closeVoiceOverlay === close) {
|
|
265
|
+
closeVoiceOverlay = null;
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
}, { overlay: true, overlayOptions: { anchor: "bottom-center", width: "100%" } }).then(() => resolve());
|
|
241
270
|
});
|
|
242
271
|
}
|
|
272
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
273
|
+
ctx.ui.onTerminalInput((data) => handlePushToTalkInput(data, {
|
|
274
|
+
active,
|
|
275
|
+
activationMode,
|
|
276
|
+
editorText: ctx.ui.getEditorText(),
|
|
277
|
+
holdToTalkSupported: isKittyProtocolActive(),
|
|
278
|
+
onUnsupported: () => {
|
|
279
|
+
if (holdToTalkUnsupportedNotified)
|
|
280
|
+
return;
|
|
281
|
+
holdToTalkUnsupportedNotified = true;
|
|
282
|
+
ctx.ui.notify("Voice: hold Space requires Kitty key-release support in this terminal — use /voice or Ctrl+Alt+V", "warning");
|
|
283
|
+
},
|
|
284
|
+
startPushToTalk: async () => {
|
|
285
|
+
await startVoice(ctx, "push-to-talk");
|
|
286
|
+
},
|
|
287
|
+
stopVoice: async () => {
|
|
288
|
+
await stopVoice(ctx);
|
|
289
|
+
},
|
|
290
|
+
}));
|
|
291
|
+
});
|
|
292
|
+
pi.on("session_shutdown", async (_event, ctx) => {
|
|
293
|
+
await stopVoice(ctx);
|
|
294
|
+
});
|
|
295
|
+
pi.registerCommand("voice", {
|
|
296
|
+
description: "Toggle voice mode",
|
|
297
|
+
handler: async (_args, ctx) => toggleVoice(ctx),
|
|
298
|
+
});
|
|
299
|
+
pi.registerShortcut("ctrl+alt+v", {
|
|
300
|
+
description: shortcutDesc("Toggle voice mode", "/voice"),
|
|
301
|
+
handler: async (ctx) => toggleVoice(ctx),
|
|
302
|
+
});
|
|
243
303
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isKeyRelease, Key, matchesKey } from "@gsd/pi-tui";
|
|
2
|
+
export function handlePushToTalkInput(data, state) {
|
|
3
|
+
if (!matchesKey(data, Key.space))
|
|
4
|
+
return undefined;
|
|
5
|
+
if (isKeyRelease(data)) {
|
|
6
|
+
if (state.activationMode === "push-to-talk") {
|
|
7
|
+
void Promise.resolve(state.stopVoice());
|
|
8
|
+
return { consume: true };
|
|
9
|
+
}
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
if (state.activationMode === "push-to-talk") {
|
|
13
|
+
// Consume repeat events while the key is held so we do not leak spaces.
|
|
14
|
+
return { consume: true };
|
|
15
|
+
}
|
|
16
|
+
if (state.active)
|
|
17
|
+
return undefined;
|
|
18
|
+
if (state.editorText.length > 0)
|
|
19
|
+
return undefined;
|
|
20
|
+
if (!state.holdToTalkSupported) {
|
|
21
|
+
state.onUnsupported?.();
|
|
22
|
+
return { consume: true };
|
|
23
|
+
}
|
|
24
|
+
void Promise.resolve(state.startPushToTalk());
|
|
25
|
+
return { consume: true };
|
|
26
|
+
}
|
package/dist/shared-paths.d.ts
CHANGED
package/dist/shared-paths.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walks up from a given directory to find the nearest .lsd/ or .gsd/ project
|
|
3
|
+
* state directory. Shared between CLI entry points and the agent runtime.
|
|
4
|
+
*/
|
|
1
5
|
import { existsSync } from 'node:fs';
|
|
2
6
|
import { dirname, join, resolve } from 'node:path';
|
|
3
7
|
export function resolveProjectStateRoot(basePath) {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads user preferences from global (~/agent/) and project-level (.lsd/settings.json)
|
|
3
|
+
* config files, with project settings taking precedence.
|
|
4
|
+
*/
|
|
1
5
|
export type SearchProviderPreference = 'tavily' | 'brave' | 'ollama' | 'native' | 'auto';
|
|
2
6
|
export interface RemoteQuestionsConfig {
|
|
3
7
|
channel?: 'slack' | 'discord' | 'telegram';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads user preferences from global (~/agent/) and project-level (.lsd/settings.json)
|
|
3
|
+
* config files, with project settings taking precedence.
|
|
4
|
+
*/
|
|
1
5
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
6
|
import { join } from 'node:path';
|
|
3
7
|
import { parse as parseYaml } from 'yaml';
|
|
@@ -16,7 +16,7 @@ interface MinimalModelRegistry {
|
|
|
16
16
|
getAll(): MinimalModel[];
|
|
17
17
|
getAvailable(): MinimalModel[];
|
|
18
18
|
}
|
|
19
|
-
type ThinkingLevel = 'off' | '
|
|
19
|
+
type ThinkingLevel = 'off' | 'low' | 'medium' | 'high' | 'xhigh' | 'adaptive';
|
|
20
20
|
interface MinimalSettingsManager {
|
|
21
21
|
getDefaultProvider(): string | undefined;
|
|
22
22
|
getDefaultModel(): string | undefined;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight startup performance profiler. Opt-in via GSD_STARTUP_TIMING=1 or PI_TIMING=1;
|
|
3
|
+
* prints a delta timeline on startup when enabled.
|
|
4
|
+
*/
|
|
1
5
|
export declare function markStartup(label: string): void;
|
|
2
6
|
export declare function printStartupTimings(): void;
|
package/dist/startup-timings.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight startup performance profiler. Opt-in via GSD_STARTUP_TIMING=1 or PI_TIMING=1;
|
|
3
|
+
* prints a delta timeline on startup when enabled.
|
|
4
|
+
*/
|
|
1
5
|
const flag = (process.env.GSD_STARTUP_TIMING ?? process.env.PI_TIMING ?? "").toLowerCase();
|
|
2
6
|
const ENABLED = flag === "1" || flag === "true" || flag === "yes";
|
|
3
7
|
const timings = [];
|
package/dist/update-check.d.ts
CHANGED
package/dist/update-check.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Periodic update checker — queries npm once per 24h for the latest lsd-pi version
|
|
3
|
+
* and notifies the user when a newer version is available.
|
|
4
|
+
*/
|
|
1
5
|
import { existsSync, readFileSync, writeFileSync, mkdirSync, rmSync } from 'node:fs';
|
|
2
6
|
import { dirname, join } from 'node:path';
|
|
3
7
|
import chalk from 'chalk';
|
package/dist/update-cmd.d.ts
CHANGED
package/dist/update-cmd.js
CHANGED
package/dist/welcome-screen.js
CHANGED
|
@@ -52,15 +52,15 @@ export function printWelcomeScreen(opts) {
|
|
|
52
52
|
const termWidth = Math.min((process.stderr.columns || 80) - 1, 200);
|
|
53
53
|
// Narrow terminal fallback
|
|
54
54
|
if (termWidth < 70) {
|
|
55
|
-
process.stderr.write(`\n
|
|
55
|
+
process.stderr.write(`\n Lucent Software Developer v${version}\n ${shortCwd}\n\n`);
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
// ── Theme-adaptive palette ───────────────────────────────────────────────
|
|
59
59
|
// Keep welcome colors anchored to the active CLI theme accent so the banner
|
|
60
60
|
// feels native regardless of custom themes.
|
|
61
61
|
const ACCENT = accentHex();
|
|
62
|
-
const LOGO_EDGE = chalk.
|
|
63
|
-
const LOGO_CENTER = chalk.
|
|
62
|
+
const LOGO_EDGE = chalk.white;
|
|
63
|
+
const LOGO_CENTER = chalk.whiteBright;
|
|
64
64
|
const TITLE_BASE = chalk.bold;
|
|
65
65
|
const TITLE_MARK = chalk.hex(mixHex(ACCENT, '#ffffff', 0.35)).bold;
|
|
66
66
|
const VERSION = chalk.dim;
|
|
@@ -78,7 +78,7 @@ export function printWelcomeScreen(opts) {
|
|
|
78
78
|
// ── Left rows: blank + 6 logo lines + blank (8 total) ───────────────────────
|
|
79
79
|
const leftRows = [null, ...GSD_LOGO_SEGMENTS, null];
|
|
80
80
|
// ── Right rows (8 total, null = divider) ────────────────────────────────────
|
|
81
|
-
const titleLeft = ` ${TITLE_MARK('L')}${TITLE_BASE('
|
|
81
|
+
const titleLeft = ` ${TITLE_MARK('L')}${TITLE_BASE('ucent Software ')}${TITLE_MARK('D')}${TITLE_BASE('eveloper')}`;
|
|
82
82
|
const titleRight = VERSION(`v${version}`);
|
|
83
83
|
const titleFill = RIGHT_INNER - visLen(titleLeft) - visLen(titleRight);
|
|
84
84
|
const titleRow = titleLeft + ' '.repeat(Math.max(1, titleFill)) + titleRight;
|
package/dist/wizard.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared wizard utilities — env hydration from stored credentials and
|
|
3
|
+
* provider detection helpers used by both onboarding.ts and cli.ts.
|
|
4
|
+
*/
|
|
1
5
|
import type { AuthStorage } from '@gsd/pi-coding-agent';
|
|
2
6
|
/**
|
|
3
7
|
* Hydrate process.env from stored auth.json credentials for optional tool keys.
|
package/dist/wizard.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared wizard utilities — env hydration from stored credentials and
|
|
3
|
+
* provider detection helpers used by both onboarding.ts and cli.ts.
|
|
4
|
+
*/
|
|
1
5
|
import { BEDROCK_PROVIDER_ID, applyBedrockCredentialToEnv, decodeBedrockCredential } from './bedrock-auth.js';
|
|
2
6
|
// ─── Env hydration ────────────────────────────────────────────────────────────
|
|
3
7
|
/**
|
package/package.json
CHANGED
|
@@ -50,6 +50,15 @@ export interface AgentOptions {
|
|
|
50
50
|
* Preferred transport for providers that support multiple transports.
|
|
51
51
|
*/
|
|
52
52
|
transport?: Transport;
|
|
53
|
+
/**
|
|
54
|
+
* Enable provider fast mode for supported models/providers.
|
|
55
|
+
*/
|
|
56
|
+
fastMode?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Dynamic fast-mode resolver evaluated before each LLM call.
|
|
59
|
+
* Useful when settings can change at runtime via slash commands/extensions.
|
|
60
|
+
*/
|
|
61
|
+
getFastMode?: () => boolean;
|
|
53
62
|
/**
|
|
54
63
|
* Maximum delay in milliseconds to wait for a retry when the server requests a long wait.
|
|
55
64
|
* If the server's requested delay exceeds this value, the request fails immediately,
|
|
@@ -63,6 +72,11 @@ export interface AgentOptions {
|
|
|
63
72
|
* switches mid-session are handled correctly.
|
|
64
73
|
*/
|
|
65
74
|
externalToolExecution?: (model: Model<any>) => boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Model to use for LLM-based adaptive thinking classification.
|
|
77
|
+
* When unset, the active inference model is used as classifier.
|
|
78
|
+
*/
|
|
79
|
+
adaptiveClassifierModel?: Model<any>;
|
|
66
80
|
}
|
|
67
81
|
export declare class Agent {
|
|
68
82
|
private _state;
|
|
@@ -82,10 +96,13 @@ export declare class Agent {
|
|
|
82
96
|
private resolveRunningPrompt?;
|
|
83
97
|
private _thinkingBudgets?;
|
|
84
98
|
private _transport;
|
|
99
|
+
private _fastMode;
|
|
100
|
+
private _getFastMode?;
|
|
85
101
|
private _maxRetryDelayMs?;
|
|
86
102
|
private _beforeToolCall?;
|
|
87
103
|
private _afterToolCall?;
|
|
88
104
|
private _externalToolExecution?;
|
|
105
|
+
private _adaptiveClassifierModel?;
|
|
89
106
|
constructor(opts?: AgentOptions);
|
|
90
107
|
/**
|
|
91
108
|
* Get the current session ID used for provider caching.
|
|
@@ -112,6 +129,14 @@ export declare class Agent {
|
|
|
112
129
|
* Set the preferred transport.
|
|
113
130
|
*/
|
|
114
131
|
setTransport(value: Transport): void;
|
|
132
|
+
/**
|
|
133
|
+
* Get fast mode resolved for the next provider request.
|
|
134
|
+
*/
|
|
135
|
+
get fastMode(): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Set fast mode explicitly.
|
|
138
|
+
*/
|
|
139
|
+
setFastMode(value: boolean): void;
|
|
115
140
|
/**
|
|
116
141
|
* Get the current max retry delay in milliseconds.
|
|
117
142
|
*/
|
|
@@ -135,6 +160,7 @@ export declare class Agent {
|
|
|
135
160
|
subscribe(fn: (e: AgentEvent) => void): () => void;
|
|
136
161
|
setSystemPrompt(v: string): void;
|
|
137
162
|
setModel(m: Model<any>): void;
|
|
163
|
+
setAdaptiveClassifierModel(m: Model<any> | undefined): void;
|
|
138
164
|
setThinkingLevel(l: ThinkingLevel): void;
|
|
139
165
|
setSteeringMode(mode: "all" | "one-at-a-time"): void;
|
|
140
166
|
getSteeringMode(): "all" | "one-at-a-time";
|
|
@@ -178,6 +204,8 @@ export declare class Agent {
|
|
|
178
204
|
* Continue from current context (used for retries and resuming queued messages).
|
|
179
205
|
*/
|
|
180
206
|
continue(): Promise<void>;
|
|
207
|
+
private _getLatestUserMessage;
|
|
208
|
+
private _resolveReasoningForTurn;
|
|
181
209
|
/**
|
|
182
210
|
* Run the agent loop.
|
|
183
211
|
* If messages are provided, starts a new conversation turn with those messages.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{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.
|
|
4
4
|
*/
|
|
5
|
-
import { getModel, streamSimple, } from "@gsd/pi-ai";
|
|
5
|
+
import { classifyAdaptiveThinkingWithLLM, getModel, supportsAdaptiveThinking, streamSimple, } from "@gsd/pi-ai";
|
|
6
6
|
import { agentLoop, agentLoopContinue, ZERO_USAGE } from "./agent-loop.js";
|
|
7
7
|
/**
|
|
8
8
|
* Default convertToLlm: Keep only LLM-compatible messages, convert attachments.
|
|
@@ -26,6 +26,7 @@ export class Agent {
|
|
|
26
26
|
this.listeners = new Set();
|
|
27
27
|
this.steeringQueue = [];
|
|
28
28
|
this.followUpQueue = [];
|
|
29
|
+
this._fastMode = false;
|
|
29
30
|
this._state = { ...this._state, ...opts.initialState };
|
|
30
31
|
this.convertToLlm = opts.convertToLlm || defaultConvertToLlm;
|
|
31
32
|
this.transformContext = opts.transformContext;
|
|
@@ -37,8 +38,11 @@ export class Agent {
|
|
|
37
38
|
this._onPayload = opts.onPayload;
|
|
38
39
|
this._thinkingBudgets = opts.thinkingBudgets;
|
|
39
40
|
this._transport = opts.transport ?? "sse";
|
|
41
|
+
this._fastMode = opts.fastMode ?? false;
|
|
42
|
+
this._getFastMode = opts.getFastMode;
|
|
40
43
|
this._maxRetryDelayMs = opts.maxRetryDelayMs;
|
|
41
44
|
this._externalToolExecution = opts.externalToolExecution;
|
|
45
|
+
this._adaptiveClassifierModel = opts.adaptiveClassifierModel;
|
|
42
46
|
}
|
|
43
47
|
/**
|
|
44
48
|
* Get the current session ID used for provider caching.
|
|
@@ -77,6 +81,18 @@ export class Agent {
|
|
|
77
81
|
setTransport(value) {
|
|
78
82
|
this._transport = value;
|
|
79
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Get fast mode resolved for the next provider request.
|
|
86
|
+
*/
|
|
87
|
+
get fastMode() {
|
|
88
|
+
return this._getFastMode?.() ?? this._fastMode;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Set fast mode explicitly.
|
|
92
|
+
*/
|
|
93
|
+
setFastMode(value) {
|
|
94
|
+
this._fastMode = value;
|
|
95
|
+
}
|
|
80
96
|
/**
|
|
81
97
|
* Get the current max retry delay in milliseconds.
|
|
82
98
|
*/
|
|
@@ -118,8 +134,14 @@ export class Agent {
|
|
|
118
134
|
setModel(m) {
|
|
119
135
|
this._state.model = m;
|
|
120
136
|
}
|
|
137
|
+
setAdaptiveClassifierModel(m) {
|
|
138
|
+
this._adaptiveClassifierModel = m;
|
|
139
|
+
}
|
|
121
140
|
setThinkingLevel(l) {
|
|
122
141
|
this._state.thinkingLevel = l;
|
|
142
|
+
if (l !== "adaptive") {
|
|
143
|
+
this._state.lastAdaptiveDecision = undefined;
|
|
144
|
+
}
|
|
123
145
|
}
|
|
124
146
|
setSteeringMode(mode) {
|
|
125
147
|
this.steeringMode = mode;
|
|
@@ -282,6 +304,65 @@ export class Agent {
|
|
|
282
304
|
}
|
|
283
305
|
await this._runLoop(undefined);
|
|
284
306
|
}
|
|
307
|
+
_getLatestUserMessage(messages) {
|
|
308
|
+
const source = messages && messages.length > 0 ? messages : this._state.messages;
|
|
309
|
+
for (let i = source.length - 1; i >= 0; i--) {
|
|
310
|
+
const msg = source[i];
|
|
311
|
+
if (msg.role === "user") {
|
|
312
|
+
return msg;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return undefined;
|
|
316
|
+
}
|
|
317
|
+
async _resolveReasoningForTurn(messages) {
|
|
318
|
+
const configured = this._state.thinkingLevel;
|
|
319
|
+
if (configured === "off") {
|
|
320
|
+
return undefined;
|
|
321
|
+
}
|
|
322
|
+
if (configured !== "adaptive") {
|
|
323
|
+
return configured;
|
|
324
|
+
}
|
|
325
|
+
if (supportsAdaptiveThinking(this._state.model.id)) {
|
|
326
|
+
return "adaptive";
|
|
327
|
+
}
|
|
328
|
+
const latestUserMessage = this._getLatestUserMessage(messages);
|
|
329
|
+
if (!latestUserMessage) {
|
|
330
|
+
return "medium";
|
|
331
|
+
}
|
|
332
|
+
const previous = this._state.lastAdaptiveDecision;
|
|
333
|
+
if (previous && previous.messageTimestamp === latestUserMessage.timestamp) {
|
|
334
|
+
return previous.level;
|
|
335
|
+
}
|
|
336
|
+
const priorMessages = this._state.messages.filter((msg) => msg.role === "user" || msg.role === "assistant" || msg.role === "toolResult");
|
|
337
|
+
if (!this._adaptiveClassifierModel) {
|
|
338
|
+
const decision = {
|
|
339
|
+
level: "medium",
|
|
340
|
+
score: 55,
|
|
341
|
+
reasons: ["adaptive_classifier_model_not_set"],
|
|
342
|
+
at: Date.now(),
|
|
343
|
+
messageTimestamp: latestUserMessage.timestamp,
|
|
344
|
+
};
|
|
345
|
+
this._state.lastAdaptiveDecision = decision;
|
|
346
|
+
this.emit({ type: "adaptive_classified", decision });
|
|
347
|
+
return "medium";
|
|
348
|
+
}
|
|
349
|
+
const result = await classifyAdaptiveThinkingWithLLM({
|
|
350
|
+
latestUserMessage,
|
|
351
|
+
priorMessages: priorMessages.slice(-6),
|
|
352
|
+
classifierModel: this._adaptiveClassifierModel,
|
|
353
|
+
signal: this.abortController?.signal,
|
|
354
|
+
});
|
|
355
|
+
const decision = {
|
|
356
|
+
level: result.level,
|
|
357
|
+
score: result.score,
|
|
358
|
+
reasons: result.reasons,
|
|
359
|
+
at: Date.now(),
|
|
360
|
+
messageTimestamp: latestUserMessage.timestamp,
|
|
361
|
+
};
|
|
362
|
+
this._state.lastAdaptiveDecision = decision;
|
|
363
|
+
this.emit({ type: "adaptive_classified", decision });
|
|
364
|
+
return result.level;
|
|
365
|
+
}
|
|
285
366
|
/**
|
|
286
367
|
* Run the agent loop.
|
|
287
368
|
* If messages are provided, starts a new conversation turn with those messages.
|
|
@@ -299,7 +380,20 @@ export class Agent {
|
|
|
299
380
|
this._state.isStreaming = true;
|
|
300
381
|
this._state.streamMessage = null;
|
|
301
382
|
this._state.error = undefined;
|
|
302
|
-
|
|
383
|
+
// Start UI loading immediately, before adaptive reasoning/classifier work.
|
|
384
|
+
this.emit({ type: "agent_start" });
|
|
385
|
+
const emittedEarlyAgentStart = true;
|
|
386
|
+
// Optimistically render submitted messages immediately so user input appears
|
|
387
|
+
// without waiting for adaptive reasoning/classifier resolution.
|
|
388
|
+
const hasInjectedMessages = !!messages && messages.length > 0;
|
|
389
|
+
if (hasInjectedMessages) {
|
|
390
|
+
for (const message of messages) {
|
|
391
|
+
this.emit({ type: "message_start", message });
|
|
392
|
+
this.emit({ type: "message_end", message });
|
|
393
|
+
this.appendMessage(message);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
const reasoning = await this._resolveReasoningForTurn(messages);
|
|
303
397
|
const self = this;
|
|
304
398
|
const context = {
|
|
305
399
|
systemPrompt: this._state.systemPrompt,
|
|
@@ -315,6 +409,7 @@ export class Agent {
|
|
|
315
409
|
sessionId: this._sessionId,
|
|
316
410
|
onPayload: this._onPayload,
|
|
317
411
|
transport: this._transport,
|
|
412
|
+
fastMode: this.fastMode,
|
|
318
413
|
thinkingBudgets: this._thinkingBudgets,
|
|
319
414
|
maxRetryDelayMs: this._maxRetryDelayMs,
|
|
320
415
|
convertToLlm: this.convertToLlm,
|
|
@@ -334,10 +429,15 @@ export class Agent {
|
|
|
334
429
|
};
|
|
335
430
|
let partial = null;
|
|
336
431
|
try {
|
|
337
|
-
const stream =
|
|
338
|
-
?
|
|
339
|
-
:
|
|
432
|
+
const stream = hasInjectedMessages
|
|
433
|
+
? agentLoopContinue(context, config, this.abortController.signal, this.streamFn)
|
|
434
|
+
: messages
|
|
435
|
+
? agentLoop(messages, context, config, this.abortController.signal, this.streamFn)
|
|
436
|
+
: agentLoopContinue(context, config, this.abortController.signal, this.streamFn);
|
|
340
437
|
for await (const event of stream) {
|
|
438
|
+
if (emittedEarlyAgentStart && event.type === "agent_start") {
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
341
441
|
// Update internal state based on events
|
|
342
442
|
switch (event.type) {
|
|
343
443
|
case "message_start":
|