@strands-agents/cli 0.2.4 → 0.3.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 +217 -133
- package/bin/strands.js +1 -5
- package/dist/src/{tui/strands-backend.js → agent/backend.js} +90 -28
- package/dist/src/agent/backend.js.map +1 -0
- package/dist/src/{tui/background/activity.js → agent/background.js} +173 -6
- package/dist/src/agent/background.js.map +1 -0
- package/dist/src/{tui/agent-configuration.js → agent/configuration.js} +62 -105
- package/dist/src/agent/configuration.js.map +1 -0
- package/dist/src/agent/context.js +112 -0
- package/dist/src/agent/context.js.map +1 -0
- package/dist/src/{tui/chat/sdk-projector.js → agent/events.js} +6 -5
- package/dist/src/agent/events.js.map +1 -0
- package/dist/src/{tui/permissions/file-change-preview.js → agent/file-changes.js} +10 -8
- package/dist/src/agent/file-changes.js.map +1 -0
- package/dist/src/agent/mcp.js +436 -0
- package/dist/src/agent/mcp.js.map +1 -0
- package/dist/src/agent/messaging.js +424 -0
- package/dist/src/agent/messaging.js.map +1 -0
- package/dist/src/agent/permission-rules.js +267 -0
- package/dist/src/agent/permission-rules.js.map +1 -0
- package/dist/src/agent/permissions.js +288 -0
- package/dist/src/agent/permissions.js.map +1 -0
- package/dist/src/agent/runtime.js +524 -0
- package/dist/src/agent/runtime.js.map +1 -0
- package/dist/src/{tui/workspace → agent}/sandbox.js +92 -25
- package/dist/src/agent/sandbox.js.map +1 -0
- package/dist/src/{tui/chat → agent}/shell.js +1 -1
- package/dist/src/agent/shell.js.map +1 -0
- package/dist/src/{tui → agent}/skills.js +37 -56
- package/dist/src/agent/skills.js.map +1 -0
- package/dist/src/{tui/builtin-tools.js → agent/tools.js} +2 -3
- package/dist/src/agent/tools.js.map +1 -0
- package/dist/src/agent/types.js.map +1 -0
- package/dist/src/{tui/voice/session.js → agent/voice.js} +221 -224
- package/dist/src/agent/voice.js.map +1 -0
- package/dist/src/{tui/acp/projection.js → cli/acp-events.js} +19 -4
- package/dist/src/cli/acp-events.js.map +1 -0
- package/dist/src/{tui/project/acp.js → cli/acp-python.js} +41 -18
- package/dist/src/cli/acp-python.js.map +1 -0
- package/dist/src/{tui/acp/server.js → cli/acp.js} +149 -46
- package/dist/src/cli/acp.js.map +1 -0
- package/dist/src/cli/arguments.js +8 -3
- package/dist/src/cli/arguments.js.map +1 -1
- package/dist/src/{console.js → cli/console.js} +69 -4
- package/dist/src/cli/console.js.map +1 -0
- package/dist/src/cli/invocation.js +75 -44
- package/dist/src/cli/invocation.js.map +1 -1
- package/dist/src/cli/run.js +66 -38
- package/dist/src/cli/run.js.map +1 -1
- package/dist/src/{tui → cli}/telemetry.js +2 -2
- package/dist/src/{tui → cli}/telemetry.js.map +1 -1
- package/dist/src/cli/update.js +35 -7
- package/dist/src/cli/update.js.map +1 -1
- package/dist/src/{tui/mcp/config.js → config/mcp.js} +25 -35
- package/dist/src/config/mcp.js.map +1 -0
- package/dist/src/{tui → config}/settings.js +78 -130
- package/dist/src/config/settings.js.map +1 -0
- package/dist/src/config/source.js +87 -0
- package/dist/src/config/source.js.map +1 -0
- package/dist/src/{tui/config.js → config/store.js} +178 -49
- package/dist/src/config/store.js.map +1 -0
- package/dist/src/{tui/workspace → config}/trust.js +12 -16
- package/dist/src/config/trust.js.map +1 -0
- package/dist/src/logging.js +3 -4
- package/dist/src/logging.js.map +1 -1
- package/dist/src/{tui/provider → model}/aws-config.js +13 -4
- package/dist/src/model/aws-config.js.map +1 -0
- package/dist/src/{tui/provider/bedrock-catalog.js → model/bedrock.js} +70 -3
- package/dist/src/model/bedrock.js.map +1 -0
- package/dist/src/{tui/provider → model}/discovery.js +11 -10
- package/dist/src/model/discovery.js.map +1 -0
- package/dist/src/{tui/provider → model}/environment.js +19 -16
- package/dist/src/model/environment.js.map +1 -0
- package/dist/src/{tui/model/display.js → model/metadata.js} +6 -1
- package/dist/src/model/metadata.js.map +1 -0
- package/dist/src/model/packages.js.map +1 -0
- package/dist/src/{tui/model → model}/runtime.js +31 -62
- package/dist/src/model/runtime.js.map +1 -0
- package/dist/src/{tui/model → model}/selection.js +9 -15
- package/dist/src/model/selection.js.map +1 -0
- package/dist/src/{tui/package-version.js → package-version.js} +6 -0
- package/dist/src/package-version.js.map +1 -0
- package/dist/src/paths.js +23 -0
- package/dist/src/paths.js.map +1 -0
- package/dist/src/project/archive.js +461 -0
- package/dist/src/project/archive.js.map +1 -0
- package/dist/src/{tui/project → project}/export.js +249 -72
- package/dist/src/project/export.js.map +1 -0
- package/dist/src/{tui/project → project}/import.js +58 -6
- package/dist/src/project/import.js.map +1 -0
- package/dist/src/{tui/project → project}/module-loader.js +1 -5
- package/dist/src/project/module-loader.js.map +1 -0
- package/dist/src/{tui/project → project}/packaging.js +25 -8
- package/dist/src/project/packaging.js.map +1 -0
- package/dist/src/project/portability.js +455 -0
- package/dist/src/project/portability.js.map +1 -0
- package/dist/src/{tui/project → project}/python.js +46 -31
- package/dist/src/project/python.js.map +1 -0
- package/dist/src/{tui/project → project}/source.js +45 -26
- package/dist/src/project/source.js.map +1 -0
- package/dist/src/project/typescript-backend.js +733 -0
- package/dist/src/project/typescript-backend.js.map +1 -0
- package/dist/src/project/typescript-worker.js +488 -0
- package/dist/src/project/typescript-worker.js.map +1 -0
- package/dist/src/{tui/project → project}/typescript.js +19 -7
- package/dist/src/project/typescript.js.map +1 -0
- package/dist/src/project/watch.js +33 -0
- package/dist/src/project/watch.js.map +1 -0
- package/dist/src/{tui/project → project}/worker.py +358 -106
- package/dist/src/session/agent-definition.js +35 -0
- package/dist/src/session/agent-definition.js.map +1 -0
- package/dist/src/session/catalog.js +156 -0
- package/dist/src/session/catalog.js.map +1 -0
- package/dist/src/{tui/session → session}/context.js +45 -5
- package/dist/src/session/context.js.map +1 -0
- package/dist/src/{tui/session → session}/desktop-profile.js +1 -0
- package/dist/src/session/desktop-profile.js.map +1 -0
- package/dist/src/{tui/session → session}/sessions.js +126 -27
- package/dist/src/session/sessions.js.map +1 -0
- package/dist/src/terminal/arguments.js +53 -0
- package/dist/src/terminal/arguments.js.map +1 -0
- package/dist/src/{tui/terminal → terminal}/composer.js +51 -24
- package/dist/src/terminal/composer.js.map +1 -0
- package/dist/src/terminal/directory-picker.js +182 -0
- package/dist/src/terminal/directory-picker.js.map +1 -0
- package/dist/src/terminal/ink.js.map +1 -0
- package/dist/src/terminal/mouse-input.js.map +1 -0
- package/dist/src/terminal/npm.js.map +1 -0
- package/dist/src/terminal/open-editor.js +40 -0
- package/dist/src/terminal/open-editor.js.map +1 -0
- package/dist/src/terminal/open-url.js +26 -0
- package/dist/src/terminal/open-url.js.map +1 -0
- package/dist/src/terminal/process-tree.js.map +1 -0
- package/dist/src/terminal/shell-output.js.map +1 -0
- package/dist/src/{tui/terminal → terminal}/terminal.js +40 -2
- package/dist/src/terminal/terminal.js.map +1 -0
- package/dist/src/{tui/terminal/sanitize.js → terminal/text.js} +40 -6
- package/dist/src/terminal/text.js.map +1 -0
- package/dist/src/terminal/theme-detection.js +197 -0
- package/dist/src/terminal/theme-detection.js.map +1 -0
- package/dist/src/{tui/view/fade-in.js → ui/animation.js} +26 -1
- package/dist/src/ui/animation.js.map +1 -0
- package/dist/src/ui/app.js +176 -0
- package/dist/src/ui/app.js.map +1 -0
- package/dist/src/ui/chat/attachments.js +135 -0
- package/dist/src/ui/chat/attachments.js.map +1 -0
- package/dist/src/{tui → ui}/chat/commands.js +55 -7
- package/dist/src/ui/chat/commands.js.map +1 -0
- package/dist/src/{tui → ui}/chat/controller.js +1176 -345
- package/dist/src/ui/chat/controller.js.map +1 -0
- package/dist/src/ui/chat/conversations.js +692 -0
- package/dist/src/ui/chat/conversations.js.map +1 -0
- package/dist/src/{tui → ui}/chat/help.js +11 -5
- package/dist/src/ui/chat/help.js.map +1 -0
- package/dist/src/ui/chat/panel-state.js +513 -0
- package/dist/src/ui/chat/panel-state.js.map +1 -0
- package/dist/src/{tui → ui}/chat/projector.js +93 -8
- package/dist/src/ui/chat/projector.js.map +1 -0
- package/dist/src/ui/chat/prompt.js +176 -0
- package/dist/src/ui/chat/prompt.js.map +1 -0
- package/dist/src/ui/chat/runtime.js +589 -0
- package/dist/src/ui/chat/runtime.js.map +1 -0
- package/dist/src/ui/chat/screen.js +1907 -0
- package/dist/src/ui/chat/screen.js.map +1 -0
- package/dist/src/{tui/chat/controller-helpers.js → ui/chat/state.js} +39 -3
- package/dist/src/ui/chat/state.js.map +1 -0
- package/dist/src/ui/chat/stream-presentation.js.map +1 -0
- package/dist/src/ui/chat/transcript-turn.js +189 -0
- package/dist/src/ui/chat/transcript-turn.js.map +1 -0
- package/dist/src/{tui/view → ui/chat}/transcript.js +66 -6
- package/dist/src/ui/chat/transcript.js.map +1 -0
- package/dist/src/ui/chat/types.js +2 -0
- package/dist/src/ui/chat/types.js.map +1 -0
- package/dist/src/ui/chat/view.js +249 -0
- package/dist/src/ui/chat/view.js.map +1 -0
- package/dist/src/ui/chat/voice.js +388 -0
- package/dist/src/ui/chat/voice.js.map +1 -0
- package/dist/src/ui/footer.js +110 -0
- package/dist/src/ui/footer.js.map +1 -0
- package/dist/src/{tui/view → ui}/frog-canvas.js +47 -50
- package/dist/src/ui/frog-canvas.js.map +1 -0
- package/dist/src/{tui/view → ui}/frog-drawing.js +36 -29
- package/dist/src/ui/frog-drawing.js.map +1 -0
- package/dist/src/{tui/view/frog-intro-renderer.js → ui/frog-renderer.js} +63 -46
- package/dist/src/ui/frog-renderer.js.map +1 -0
- package/dist/src/{tui/view/frog-easter-egg.js → ui/frog.js} +34 -6
- package/dist/src/ui/frog.js.map +1 -0
- package/dist/src/ui/interaction.js +525 -0
- package/dist/src/ui/interaction.js.map +1 -0
- package/dist/src/{tui/view → ui}/markdown.js +12 -9
- package/dist/src/ui/markdown.js.map +1 -0
- package/dist/src/ui/mcp-diagnostics.js +56 -0
- package/dist/src/ui/mcp-diagnostics.js.map +1 -0
- package/dist/src/ui/media.js +59 -0
- package/dist/src/ui/media.js.map +1 -0
- package/dist/src/ui/panels/agents.js +97 -0
- package/dist/src/ui/panels/agents.js.map +1 -0
- package/dist/src/ui/panels/configuration.js +201 -0
- package/dist/src/ui/panels/configuration.js.map +1 -0
- package/dist/src/ui/panels/context.js +102 -0
- package/dist/src/ui/panels/context.js.map +1 -0
- package/dist/src/ui/panels/export.js +17 -0
- package/dist/src/ui/panels/export.js.map +1 -0
- package/dist/src/ui/panels/help.js +22 -0
- package/dist/src/ui/panels/help.js.map +1 -0
- package/dist/src/ui/panels/models.js +180 -0
- package/dist/src/ui/panels/models.js.map +1 -0
- package/dist/src/ui/panels/panel.js +122 -0
- package/dist/src/ui/panels/panel.js.map +1 -0
- package/dist/src/ui/panels/permissions.js +90 -0
- package/dist/src/ui/panels/permissions.js.map +1 -0
- package/dist/src/ui/panels/sessions.js +54 -0
- package/dist/src/ui/panels/sessions.js.map +1 -0
- package/dist/src/ui/panels/settings.js +125 -0
- package/dist/src/ui/panels/settings.js.map +1 -0
- package/dist/src/ui/panels/shared.js +50 -0
- package/dist/src/ui/panels/shared.js.map +1 -0
- package/dist/src/ui/panels/tasks.js +15 -0
- package/dist/src/ui/panels/tasks.js.map +1 -0
- package/dist/src/ui/panels/voice.js +142 -0
- package/dist/src/ui/panels/voice.js.map +1 -0
- package/dist/src/{tui/permissions/settings.js → ui/permission-options.js} +13 -2
- package/dist/src/ui/permission-options.js.map +1 -0
- package/dist/src/{tui/view → ui}/presentation.js +170 -112
- package/dist/src/ui/presentation.js.map +1 -0
- package/dist/src/{tui → ui}/run.js +173 -36
- package/dist/src/ui/run.js.map +1 -0
- package/dist/src/{tui/view/setup-wizard/settings-panel.js → ui/setup/form.js} +6 -6
- package/dist/src/ui/setup/form.js.map +1 -0
- package/dist/src/ui/setup/menu.js +133 -0
- package/dist/src/ui/setup/menu.js.map +1 -0
- package/dist/src/{tui/view/setup-wizard → ui/setup}/providers.js +157 -20
- package/dist/src/ui/setup/providers.js.map +1 -0
- package/dist/src/{tui/view/setup-wizard → ui/setup}/steps.js +193 -147
- package/dist/src/ui/setup/steps.js.map +1 -0
- package/dist/src/ui/setup/wizard.js +2075 -0
- package/dist/src/ui/setup/wizard.js.map +1 -0
- package/dist/src/ui/startup.js +147 -0
- package/dist/src/ui/startup.js.map +1 -0
- package/dist/src/{tui/terminal/size.js → ui/terminal-size.js} +1 -1
- package/dist/src/ui/terminal-size.js.map +1 -0
- package/dist/src/ui/text-input.js +50 -0
- package/dist/src/ui/text-input.js.map +1 -0
- package/dist/src/{tui/view → ui}/theme.js +24 -31
- package/dist/src/ui/theme.js.map +1 -0
- package/dist/src/ui/update.js +126 -0
- package/dist/src/ui/update.js.map +1 -0
- package/dist/src/usage.js +0 -5
- package/dist/src/usage.js.map +1 -1
- package/dist/src/values.js +5 -0
- package/dist/src/values.js.map +1 -0
- package/package.json +16 -8
- package/src/agent/voice-sidecar.py +730 -0
- package/dist/src/console.js.map +0 -1
- package/dist/src/tui/acp/projection.js.map +0 -1
- package/dist/src/tui/acp/server.js.map +0 -1
- package/dist/src/tui/agent-configuration.js.map +0 -1
- package/dist/src/tui/background/activity.js.map +0 -1
- package/dist/src/tui/background/inbox.js +0 -120
- package/dist/src/tui/background/inbox.js.map +0 -1
- package/dist/src/tui/background/tasks.js +0 -98
- package/dist/src/tui/background/tasks.js.map +0 -1
- package/dist/src/tui/builtin-tools.js.map +0 -1
- package/dist/src/tui/chat/commands.js.map +0 -1
- package/dist/src/tui/chat/controller-helpers.js.map +0 -1
- package/dist/src/tui/chat/controller.js.map +0 -1
- package/dist/src/tui/chat/help.js.map +0 -1
- package/dist/src/tui/chat/panels.js +0 -407
- package/dist/src/tui/chat/panels.js.map +0 -1
- package/dist/src/tui/chat/projector.js.map +0 -1
- package/dist/src/tui/chat/sdk-projector.js.map +0 -1
- package/dist/src/tui/chat/shell.js.map +0 -1
- package/dist/src/tui/chat/types.js +0 -2
- package/dist/src/tui/chat/types.js.map +0 -1
- package/dist/src/tui/config.js.map +0 -1
- package/dist/src/tui/configuration-instructions.js +0 -14
- package/dist/src/tui/configuration-instructions.js.map +0 -1
- package/dist/src/tui/mcp/config.js.map +0 -1
- package/dist/src/tui/mcp.js +0 -98
- package/dist/src/tui/mcp.js.map +0 -1
- package/dist/src/tui/memory-options.js +0 -10
- package/dist/src/tui/memory-options.js.map +0 -1
- package/dist/src/tui/messaging.js +0 -193
- package/dist/src/tui/messaging.js.map +0 -1
- package/dist/src/tui/model/context.js +0 -69
- package/dist/src/tui/model/context.js.map +0 -1
- package/dist/src/tui/model/display.js.map +0 -1
- package/dist/src/tui/model/runtime.js.map +0 -1
- package/dist/src/tui/model/selection.js.map +0 -1
- package/dist/src/tui/npm.js.map +0 -1
- package/dist/src/tui/package-version.js.map +0 -1
- package/dist/src/tui/permissions/file-change-preview.js.map +0 -1
- package/dist/src/tui/permissions/policy.js +0 -222
- package/dist/src/tui/permissions/policy.js.map +0 -1
- package/dist/src/tui/permissions/settings.js.map +0 -1
- package/dist/src/tui/project/acp.js.map +0 -1
- package/dist/src/tui/project/archive.js +0 -241
- package/dist/src/tui/project/archive.js.map +0 -1
- package/dist/src/tui/project/configuration-secrets.js +0 -107
- package/dist/src/tui/project/configuration-secrets.js.map +0 -1
- package/dist/src/tui/project/configuration.js +0 -201
- package/dist/src/tui/project/configuration.js.map +0 -1
- package/dist/src/tui/project/export.js.map +0 -1
- package/dist/src/tui/project/import.js.map +0 -1
- package/dist/src/tui/project/module-loader.js.map +0 -1
- package/dist/src/tui/project/packaging.js.map +0 -1
- package/dist/src/tui/project/portable-dependencies.js +0 -34
- package/dist/src/tui/project/portable-dependencies.js.map +0 -1
- package/dist/src/tui/project/portable-mcp.js +0 -118
- package/dist/src/tui/project/portable-mcp.js.map +0 -1
- package/dist/src/tui/project/python.js.map +0 -1
- package/dist/src/tui/project/run.js +0 -116
- package/dist/src/tui/project/run.js.map +0 -1
- package/dist/src/tui/project/source.js.map +0 -1
- package/dist/src/tui/project/typescript.js.map +0 -1
- package/dist/src/tui/provider/aws-client.js +0 -67
- package/dist/src/tui/provider/aws-client.js.map +0 -1
- package/dist/src/tui/provider/aws-config.js.map +0 -1
- package/dist/src/tui/provider/bedrock-catalog.js.map +0 -1
- package/dist/src/tui/provider/discovery.js.map +0 -1
- package/dist/src/tui/provider/environment.js.map +0 -1
- package/dist/src/tui/provider/packages.js.map +0 -1
- package/dist/src/tui/run.js.map +0 -1
- package/dist/src/tui/runtime.js +0 -524
- package/dist/src/tui/runtime.js.map +0 -1
- package/dist/src/tui/session/agent-definition.js +0 -100
- package/dist/src/tui/session/agent-definition.js.map +0 -1
- package/dist/src/tui/session/catalog.js +0 -159
- package/dist/src/tui/session/catalog.js.map +0 -1
- package/dist/src/tui/session/context.js.map +0 -1
- package/dist/src/tui/session/conversation-helpers.js +0 -46
- package/dist/src/tui/session/conversation-helpers.js.map +0 -1
- package/dist/src/tui/session/conversations.js +0 -471
- package/dist/src/tui/session/conversations.js.map +0 -1
- package/dist/src/tui/session/desktop-profile.js.map +0 -1
- package/dist/src/tui/session/options.js +0 -44
- package/dist/src/tui/session/options.js.map +0 -1
- package/dist/src/tui/session/sessions.js.map +0 -1
- package/dist/src/tui/session/voice.js +0 -353
- package/dist/src/tui/session/voice.js.map +0 -1
- package/dist/src/tui/settings.js.map +0 -1
- package/dist/src/tui/skills.js.map +0 -1
- package/dist/src/tui/steering.js +0 -67
- package/dist/src/tui/steering.js.map +0 -1
- package/dist/src/tui/strands-backend.js.map +0 -1
- package/dist/src/tui/stream-presentation.js.map +0 -1
- package/dist/src/tui/terminal/composer.js.map +0 -1
- package/dist/src/tui/terminal/directory-picker.js +0 -76
- package/dist/src/tui/terminal/directory-picker.js.map +0 -1
- package/dist/src/tui/terminal/ink.js.map +0 -1
- package/dist/src/tui/terminal/mouse-input.js.map +0 -1
- package/dist/src/tui/terminal/open-url.js +0 -21
- package/dist/src/tui/terminal/open-url.js.map +0 -1
- package/dist/src/tui/terminal/process-tree.js.map +0 -1
- package/dist/src/tui/terminal/sanitize.js.map +0 -1
- package/dist/src/tui/terminal/shell-output.js.map +0 -1
- package/dist/src/tui/terminal/size.js.map +0 -1
- package/dist/src/tui/terminal/terminal.js.map +0 -1
- package/dist/src/tui/update-check.js +0 -37
- package/dist/src/tui/update-check.js.map +0 -1
- package/dist/src/tui/view/agents-panel.js +0 -21
- package/dist/src/tui/view/agents-panel.js.map +0 -1
- package/dist/src/tui/view/app.js +0 -1061
- package/dist/src/tui/view/app.js.map +0 -1
- package/dist/src/tui/view/chat-root.js +0 -49
- package/dist/src/tui/view/chat-root.js.map +0 -1
- package/dist/src/tui/view/chat-view.js +0 -145
- package/dist/src/tui/view/chat-view.js.map +0 -1
- package/dist/src/tui/view/command-palette.js +0 -15
- package/dist/src/tui/view/command-palette.js.map +0 -1
- package/dist/src/tui/view/custom-theme-editor.js +0 -301
- package/dist/src/tui/view/custom-theme-editor.js.map +0 -1
- package/dist/src/tui/view/effort-panel.js +0 -15
- package/dist/src/tui/view/effort-panel.js.map +0 -1
- package/dist/src/tui/view/export-panel.js +0 -14
- package/dist/src/tui/view/export-panel.js.map +0 -1
- package/dist/src/tui/view/fade-in.js.map +0 -1
- package/dist/src/tui/view/frog-canvas.js.map +0 -1
- package/dist/src/tui/view/frog-drawing.js.map +0 -1
- package/dist/src/tui/view/frog-easter-egg.js.map +0 -1
- package/dist/src/tui/view/frog-intro-renderer.js.map +0 -1
- package/dist/src/tui/view/help-footer.js +0 -48
- package/dist/src/tui/view/help-footer.js.map +0 -1
- package/dist/src/tui/view/interaction.js +0 -352
- package/dist/src/tui/view/interaction.js.map +0 -1
- package/dist/src/tui/view/markdown.js.map +0 -1
- package/dist/src/tui/view/mcp-trust-prompt.js +0 -17
- package/dist/src/tui/view/mcp-trust-prompt.js.map +0 -1
- package/dist/src/tui/view/media.js +0 -70
- package/dist/src/tui/view/media.js.map +0 -1
- package/dist/src/tui/view/model-panel.js +0 -77
- package/dist/src/tui/view/model-panel.js.map +0 -1
- package/dist/src/tui/view/panel-components.js +0 -17
- package/dist/src/tui/view/panel-components.js.map +0 -1
- package/dist/src/tui/view/panels.js +0 -139
- package/dist/src/tui/view/panels.js.map +0 -1
- package/dist/src/tui/view/presentation.js.map +0 -1
- package/dist/src/tui/view/prompt-editor.js +0 -82
- package/dist/src/tui/view/prompt-editor.js.map +0 -1
- package/dist/src/tui/view/provider-list.js +0 -14
- package/dist/src/tui/view/provider-list.js.map +0 -1
- package/dist/src/tui/view/rename-panel.js +0 -11
- package/dist/src/tui/view/rename-panel.js.map +0 -1
- package/dist/src/tui/view/sessions-panel.js +0 -15
- package/dist/src/tui/view/sessions-panel.js.map +0 -1
- package/dist/src/tui/view/settings-panel.js +0 -146
- package/dist/src/tui/view/settings-panel.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/brand.js +0 -34
- package/dist/src/tui/view/setup-wizard/brand.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/index.js +0 -1638
- package/dist/src/tui/view/setup-wizard/index.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/opening-menu.js +0 -99
- package/dist/src/tui/view/setup-wizard/opening-menu.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/path-completion.js +0 -53
- package/dist/src/tui/view/setup-wizard/path-completion.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/profile-fields.js +0 -29
- package/dist/src/tui/view/setup-wizard/profile-fields.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/progress.js +0 -43
- package/dist/src/tui/view/setup-wizard/progress.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/providers.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/settings-panel.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/steps.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/types.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/use-provider-discovery.js +0 -143
- package/dist/src/tui/view/setup-wizard/use-provider-discovery.js.map +0 -1
- package/dist/src/tui/view/startup-view.js +0 -79
- package/dist/src/tui/view/startup-view.js.map +0 -1
- package/dist/src/tui/view/text-input.js +0 -33
- package/dist/src/tui/view/text-input.js.map +0 -1
- package/dist/src/tui/view/theme-detection.js +0 -45
- package/dist/src/tui/view/theme-detection.js.map +0 -1
- package/dist/src/tui/view/theme.js.map +0 -1
- package/dist/src/tui/view/transcript-layout.js +0 -60
- package/dist/src/tui/view/transcript-layout.js.map +0 -1
- package/dist/src/tui/view/transcript-turn.js +0 -135
- package/dist/src/tui/view/transcript-turn.js.map +0 -1
- package/dist/src/tui/view/transcript.js.map +0 -1
- package/dist/src/tui/view/use-party-frame.js +0 -15
- package/dist/src/tui/view/use-party-frame.js.map +0 -1
- package/dist/src/tui/view/use-spinner.js +0 -14
- package/dist/src/tui/view/use-spinner.js.map +0 -1
- package/dist/src/tui/voice/session.js.map +0 -1
- package/dist/src/tui/workspace/sandbox.js.map +0 -1
- package/dist/src/tui/workspace/trust.js.map +0 -1
- package/src/tui/voice/sidecar.py +0 -631
- /package/dist/src/{tui/view/setup-wizard → agent}/types.js +0 -0
- /package/dist/src/{tui/provider → model}/packages.js +0 -0
- /package/dist/src/{tui/terminal → terminal}/ink.js +0 -0
- /package/dist/src/{tui/terminal → terminal}/mouse-input.js +0 -0
- /package/dist/src/{tui → terminal}/npm.js +0 -0
- /package/dist/src/{tui/terminal → terminal}/process-tree.js +0 -0
- /package/dist/src/{tui/terminal → terminal}/shell-output.js +0 -0
- /package/dist/src/{tui → ui/chat}/stream-presentation.js +0 -0
|
@@ -0,0 +1,733 @@
|
|
|
1
|
+
import { Message } from '@strands-agents/sdk';
|
|
2
|
+
import { fork } from 'node:child_process';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
5
|
+
import { modelChangeMode } from '../model/runtime.js';
|
|
6
|
+
import { effortDisplayLabel, effortOptions, effortValue, validateEffortSelection } from '../model/selection.js';
|
|
7
|
+
import { terminateProcessTree } from '../terminal/process-tree.js';
|
|
8
|
+
import { errorMessage, sanitizeTerminalText } from '../terminal/text.js';
|
|
9
|
+
const connections = new WeakMap();
|
|
10
|
+
/** One process owns one authored module graph and one constructed agent. */
|
|
11
|
+
class TypescriptConnection {
|
|
12
|
+
_child;
|
|
13
|
+
_config;
|
|
14
|
+
_messaging;
|
|
15
|
+
_endpointId;
|
|
16
|
+
metadata;
|
|
17
|
+
tasks = [];
|
|
18
|
+
permission;
|
|
19
|
+
activities = new Map();
|
|
20
|
+
onMessage;
|
|
21
|
+
_pending = new Map();
|
|
22
|
+
_usage = new Map();
|
|
23
|
+
_peers = new Map();
|
|
24
|
+
_namespace = randomUUID();
|
|
25
|
+
_sequence = 0;
|
|
26
|
+
_diagnostics = '';
|
|
27
|
+
_failure;
|
|
28
|
+
_disposal;
|
|
29
|
+
constructor(_child, _config, _messaging, _endpointId) {
|
|
30
|
+
this._child = _child;
|
|
31
|
+
this._config = _config;
|
|
32
|
+
this._messaging = _messaging;
|
|
33
|
+
this._endpointId = _endpointId;
|
|
34
|
+
let current = connections.get(_config);
|
|
35
|
+
if (!current)
|
|
36
|
+
connections.set(_config, (current = new Set()));
|
|
37
|
+
current.add(this);
|
|
38
|
+
for (const output of [_child.stdout, _child.stderr]) {
|
|
39
|
+
output?.on('data', (chunk) => {
|
|
40
|
+
this._diagnostics = (this._diagnostics + chunk.toString()).slice(-8_192);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
_child.on('message', (message) => this._receive(message));
|
|
44
|
+
_child.on('error', (error) => this.fail(error));
|
|
45
|
+
_child.on('exit', (code, signal) => {
|
|
46
|
+
this.fail(new Error(`TypeScript agent exited (${signal ?? code}). ${sanitizeTerminalText(this._diagnostics).trim()}`));
|
|
47
|
+
});
|
|
48
|
+
_child.on('disconnect', () => this.fail(new Error('TypeScript agent disconnected.')));
|
|
49
|
+
}
|
|
50
|
+
static async open(init, config, messaging, signal) {
|
|
51
|
+
signal?.throwIfAborted();
|
|
52
|
+
config.applyProviderEnvironment();
|
|
53
|
+
const source = import.meta.url.endsWith('.ts');
|
|
54
|
+
const worker = new URL(source ? './typescript-worker.ts' : './typescript-worker.js', import.meta.url);
|
|
55
|
+
const child = fork(fileURLToPath(worker), [], {
|
|
56
|
+
cwd: init.cwd,
|
|
57
|
+
env: { ...process.env },
|
|
58
|
+
execArgv: source ? ['--import', import.meta.resolve('tsx')] : [],
|
|
59
|
+
serialization: 'advanced',
|
|
60
|
+
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
|
61
|
+
detached: process.platform !== 'win32',
|
|
62
|
+
});
|
|
63
|
+
const connection = new TypescriptConnection(child, config, messaging, init.peerEndpointId);
|
|
64
|
+
const cancel = () => connection.fail(new Error('TypeScript agent loading cancelled.'));
|
|
65
|
+
signal?.addEventListener('abort', cancel, { once: true });
|
|
66
|
+
let timeout;
|
|
67
|
+
try {
|
|
68
|
+
signal?.throwIfAborted();
|
|
69
|
+
// Dependency installation has its own deadline and can outlast source loading.
|
|
70
|
+
await connection.call('prepare', init.project);
|
|
71
|
+
timeout = setTimeout(() => connection.fail(new Error('TypeScript agent loading timed out.')), 60_000);
|
|
72
|
+
const result = await connection.call('init', init);
|
|
73
|
+
connection.metadata = result.metadata;
|
|
74
|
+
return { connection, messages: result.messages.map((message) => Message.fromJSON(message)) };
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
await connection.dispose();
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
clearTimeout(timeout);
|
|
82
|
+
signal?.removeEventListener('abort', cancel);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
call(operation, input) {
|
|
86
|
+
if (this._failure)
|
|
87
|
+
return Promise.reject(this._failure);
|
|
88
|
+
if (this._disposal)
|
|
89
|
+
return Promise.reject(new Error('TypeScript agent is closing.'));
|
|
90
|
+
const id = ++this._sequence;
|
|
91
|
+
return new Promise((resolve, reject) => {
|
|
92
|
+
this._pending.set(id, {
|
|
93
|
+
operation,
|
|
94
|
+
resolve: (value) => resolve(value),
|
|
95
|
+
reject,
|
|
96
|
+
});
|
|
97
|
+
this._send({ type: 'call', id, operation, input });
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
notify(operation, input) {
|
|
101
|
+
void this.call(operation, input).catch((error) => this.fail(new Error(errorMessage(error))));
|
|
102
|
+
}
|
|
103
|
+
_send(message) {
|
|
104
|
+
try {
|
|
105
|
+
this._child.send(message, (error) => {
|
|
106
|
+
if (error)
|
|
107
|
+
this.fail(error);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
this.fail(new Error(errorMessage(error)));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
_receive(message) {
|
|
115
|
+
if (this._failure)
|
|
116
|
+
return;
|
|
117
|
+
if (message.type === 'response' || message.type === 'error') {
|
|
118
|
+
const pending = this._pending.get(message.id);
|
|
119
|
+
if (!pending)
|
|
120
|
+
return;
|
|
121
|
+
this._pending.delete(message.id);
|
|
122
|
+
if (message.type === 'error') {
|
|
123
|
+
pending.reject(new Error(sanitizeTerminalText(message.message)));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
if (pending.operation === 'next') {
|
|
127
|
+
const result = message.result;
|
|
128
|
+
if (result.done && result.value.usageId !== undefined) {
|
|
129
|
+
const id = result.value.usageId;
|
|
130
|
+
const receipt = { settled: false, value: undefined, listeners: new Set() };
|
|
131
|
+
this._usage.set(id, receipt);
|
|
132
|
+
const value = {
|
|
133
|
+
...result.value,
|
|
134
|
+
watchUsage: (listener) => {
|
|
135
|
+
if (receipt.settled) {
|
|
136
|
+
listener(receipt.value);
|
|
137
|
+
return () => { };
|
|
138
|
+
}
|
|
139
|
+
receipt.listeners.add(listener);
|
|
140
|
+
return () => {
|
|
141
|
+
receipt.listeners.delete(listener);
|
|
142
|
+
if (receipt.listeners.size === 0 && this._usage.delete(id))
|
|
143
|
+
this.notify('unwatchUsage', id);
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
pending.resolve({ done: true, value });
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
pending.resolve(message.result);
|
|
152
|
+
}
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (message.type === 'hostCall') {
|
|
156
|
+
void this._hostCall(message.call).then((result) => this._send({ type: 'hostResponse', id: message.id, result }), (error) => this._send({ type: 'hostError', id: message.id, message: errorMessage(error) }));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (message.type === 'metadata')
|
|
160
|
+
this.metadata = message.value;
|
|
161
|
+
if (message.type === 'tasks')
|
|
162
|
+
this.tasks = message.value;
|
|
163
|
+
if (message.type === 'permission')
|
|
164
|
+
this.permission = message.value;
|
|
165
|
+
if (message.type === 'peers')
|
|
166
|
+
this._updatePeers(message.value);
|
|
167
|
+
if (message.type === 'usage') {
|
|
168
|
+
const receipt = this._usage.get(message.id);
|
|
169
|
+
if (receipt) {
|
|
170
|
+
this._usage.delete(message.id);
|
|
171
|
+
receipt.settled = true;
|
|
172
|
+
receipt.value = message.value;
|
|
173
|
+
for (const listener of receipt.listeners)
|
|
174
|
+
listener(message.value);
|
|
175
|
+
receipt.listeners.clear();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
this.onMessage?.(message);
|
|
179
|
+
}
|
|
180
|
+
async _hostCall(call) {
|
|
181
|
+
if (this._disposal)
|
|
182
|
+
throw new Error('TypeScript agent is closing.');
|
|
183
|
+
if (call.operation === 'permission') {
|
|
184
|
+
if (call.method === 'setPermissionMode') {
|
|
185
|
+
if (call.value !== 'default' && call.value !== 'bypassPermissions')
|
|
186
|
+
throw new Error('Invalid permission mode.');
|
|
187
|
+
await this._config.setPermissionMode(call.value);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
await this._config[call.method](call.value);
|
|
191
|
+
}
|
|
192
|
+
await TypescriptBackend.syncConfiguration(this._config);
|
|
193
|
+
return { snapshot: this._config.snapshot(), environment: this._config.providerEnvironment() };
|
|
194
|
+
}
|
|
195
|
+
const sender = call.senderId === this._endpointId ? this._endpointId : this._peers.get(call.senderId)?.id;
|
|
196
|
+
if (!sender)
|
|
197
|
+
throw new Error('This agent is not registered for peer messaging.');
|
|
198
|
+
if (call.operation === 'listPeers')
|
|
199
|
+
return this._messaging.list(sender);
|
|
200
|
+
return this._messaging.send(sender, call.to, call.body);
|
|
201
|
+
}
|
|
202
|
+
_updatePeers(peers) {
|
|
203
|
+
const present = new Set(peers.map((peer) => peer.id));
|
|
204
|
+
for (const [localId, peer] of this._peers) {
|
|
205
|
+
if (present.has(localId))
|
|
206
|
+
continue;
|
|
207
|
+
this._messaging.unregister(peer.id);
|
|
208
|
+
this._peers.delete(localId);
|
|
209
|
+
}
|
|
210
|
+
for (const value of peers) {
|
|
211
|
+
const existing = this._peers.get(value.id);
|
|
212
|
+
if (existing) {
|
|
213
|
+
existing.value = value;
|
|
214
|
+
this._messaging.rename(existing.id, value.name);
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
const peer = { id: `${this._namespace}:${value.id}`, value };
|
|
218
|
+
this._peers.set(value.id, peer);
|
|
219
|
+
this._messaging.register({
|
|
220
|
+
id: peer.id,
|
|
221
|
+
name: value.name,
|
|
222
|
+
...(value.description ? { description: value.description } : {}),
|
|
223
|
+
...(value.backgroundTask ? { backgroundTask: value.backgroundTask } : {}),
|
|
224
|
+
status: () => (this._failure || this._disposal ? undefined : peer.value.status),
|
|
225
|
+
enqueue: (message) => this.call('deliverPeer', { id: value.id, message }),
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
fail(error) {
|
|
230
|
+
if (this._failure)
|
|
231
|
+
return;
|
|
232
|
+
this._failure = error;
|
|
233
|
+
for (const request of this._pending.values())
|
|
234
|
+
request.reject(error);
|
|
235
|
+
this._pending.clear();
|
|
236
|
+
for (const receipt of this._usage.values()) {
|
|
237
|
+
receipt.settled = true;
|
|
238
|
+
for (const listener of receipt.listeners)
|
|
239
|
+
listener(undefined);
|
|
240
|
+
receipt.listeners.clear();
|
|
241
|
+
}
|
|
242
|
+
this._usage.clear();
|
|
243
|
+
this.permission = undefined;
|
|
244
|
+
this.onMessage?.({ type: 'permission', value: undefined });
|
|
245
|
+
this.tasks = this.tasks.map((task) => task.source === 'background' && ['pending', 'queued', 'in_progress', 'working', 'paused'].includes(task.status)
|
|
246
|
+
? { ...task, status: 'failed', deliveryState: 'delivered', error: error.message }
|
|
247
|
+
: task);
|
|
248
|
+
this.onMessage?.({ type: 'tasks', value: this.tasks });
|
|
249
|
+
for (const peer of this._peers.values())
|
|
250
|
+
this._messaging.unregister(peer.id);
|
|
251
|
+
this._peers.clear();
|
|
252
|
+
for (const id of this.activities.keys())
|
|
253
|
+
this.onMessage?.({ type: 'activity', id, value: undefined });
|
|
254
|
+
this.activities.clear();
|
|
255
|
+
connections.get(this._config)?.delete(this);
|
|
256
|
+
void this.dispose();
|
|
257
|
+
}
|
|
258
|
+
dispose() {
|
|
259
|
+
return (this._disposal ??= this._close());
|
|
260
|
+
}
|
|
261
|
+
async _close() {
|
|
262
|
+
connections.get(this._config)?.delete(this);
|
|
263
|
+
const closing = this.call('close', undefined).catch(() => { });
|
|
264
|
+
let timeout;
|
|
265
|
+
await Promise.race([
|
|
266
|
+
closing,
|
|
267
|
+
new Promise((resolve) => {
|
|
268
|
+
timeout = setTimeout(resolve, this._failure ? 1_000 : 60_000);
|
|
269
|
+
}),
|
|
270
|
+
]);
|
|
271
|
+
clearTimeout(timeout);
|
|
272
|
+
await terminateProcessTree(this._child);
|
|
273
|
+
this.fail(new Error('TypeScript agent closed.'));
|
|
274
|
+
this.onMessage = undefined;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
export class TypescriptBackend {
|
|
278
|
+
_connection;
|
|
279
|
+
_config;
|
|
280
|
+
_messaging;
|
|
281
|
+
id = 'typescript';
|
|
282
|
+
protocol = 'strands';
|
|
283
|
+
mcp;
|
|
284
|
+
skills;
|
|
285
|
+
_taskListeners = new Set();
|
|
286
|
+
_permissionListeners = new Set();
|
|
287
|
+
_metadataListeners = new Set();
|
|
288
|
+
_configurationListeners = new Set();
|
|
289
|
+
_disposeListeners = new Set();
|
|
290
|
+
_activityListeners = new Map();
|
|
291
|
+
_steering = new Map();
|
|
292
|
+
_options;
|
|
293
|
+
_sequence = 0;
|
|
294
|
+
_invocation;
|
|
295
|
+
_loading;
|
|
296
|
+
_draining = false;
|
|
297
|
+
_thinking;
|
|
298
|
+
_configuration;
|
|
299
|
+
_disposal;
|
|
300
|
+
constructor(_connection, options, _config, _messaging) {
|
|
301
|
+
this._connection = _connection;
|
|
302
|
+
this._config = _config;
|
|
303
|
+
this._messaging = _messaging;
|
|
304
|
+
this._options = { ...options };
|
|
305
|
+
delete this._options.seed;
|
|
306
|
+
delete this._options.conversation;
|
|
307
|
+
delete this._options.freshSession;
|
|
308
|
+
delete this._options.preserveSession;
|
|
309
|
+
delete this._options.restoreSeedMessages;
|
|
310
|
+
delete this._options.sessionId;
|
|
311
|
+
this._observe(_connection);
|
|
312
|
+
const mcpState = () => this.state.mcp;
|
|
313
|
+
this.mcp = {
|
|
314
|
+
get paths() {
|
|
315
|
+
return mcpState().paths;
|
|
316
|
+
},
|
|
317
|
+
get warnings() {
|
|
318
|
+
return mcpState().warnings;
|
|
319
|
+
},
|
|
320
|
+
...(this.state.mcp.startup
|
|
321
|
+
? {
|
|
322
|
+
startup: {
|
|
323
|
+
progress: () => mcpState().startup,
|
|
324
|
+
subscribe: (listener) => {
|
|
325
|
+
this._metadataListeners.add(listener);
|
|
326
|
+
return () => {
|
|
327
|
+
this._metadataListeners.delete(listener);
|
|
328
|
+
};
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
}
|
|
332
|
+
: {}),
|
|
333
|
+
list: (connect = false) => this._connection.call('listMcp', connect),
|
|
334
|
+
setEnabled: (name, enabled) => this._connection.call('enableMcp', { name, enabled }),
|
|
335
|
+
dispose: () => this.dispose(),
|
|
336
|
+
};
|
|
337
|
+
this.skills = {
|
|
338
|
+
list: () => this._connection.call('listSkills', undefined),
|
|
339
|
+
activate: (name) => this._connection.call('activateSkill', name),
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
static async open(init, config, messaging, signal) {
|
|
343
|
+
const { connection, messages } = await TypescriptConnection.open({ ...init, config: { snapshot: config.snapshot(), environment: config.providerEnvironment() } }, config, messaging, signal);
|
|
344
|
+
return { backend: new TypescriptBackend(connection, init, config, messaging), messages };
|
|
345
|
+
}
|
|
346
|
+
static async syncConfiguration(config) {
|
|
347
|
+
const value = { snapshot: config.snapshot(), environment: config.providerEnvironment() };
|
|
348
|
+
await Promise.all([...(connections.get(config) ?? [])].map((connection) => connection.call('config', value)));
|
|
349
|
+
}
|
|
350
|
+
syncConfiguration() {
|
|
351
|
+
return TypescriptBackend.syncConfiguration(this._config);
|
|
352
|
+
}
|
|
353
|
+
get state() {
|
|
354
|
+
return this._connection.metadata;
|
|
355
|
+
}
|
|
356
|
+
get cwd() {
|
|
357
|
+
return this._options.cwd;
|
|
358
|
+
}
|
|
359
|
+
get name() {
|
|
360
|
+
return this.state.name;
|
|
361
|
+
}
|
|
362
|
+
get sessionId() {
|
|
363
|
+
return this.state.sessionId;
|
|
364
|
+
}
|
|
365
|
+
get sessionDirectory() {
|
|
366
|
+
return this.state.sessionDirectory;
|
|
367
|
+
}
|
|
368
|
+
get sessionIdentity() {
|
|
369
|
+
return this.state.sessionIdentity;
|
|
370
|
+
}
|
|
371
|
+
get privatePaths() {
|
|
372
|
+
return this.state.privatePaths;
|
|
373
|
+
}
|
|
374
|
+
reconstructable() {
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
info() {
|
|
378
|
+
return {
|
|
379
|
+
...this.state.info,
|
|
380
|
+
...(this._thinking !== undefined ? { effort: effortDisplayLabel(this._thinking) } : {}),
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
contextUsage() {
|
|
384
|
+
return this.state.context;
|
|
385
|
+
}
|
|
386
|
+
modelSelection() {
|
|
387
|
+
return {
|
|
388
|
+
...this.state.selection,
|
|
389
|
+
thinking: this._thinking === undefined ? this.state.selection.thinking : this._thinking,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
sourceSelection() {
|
|
393
|
+
const source = this.state.sourceSelection;
|
|
394
|
+
return source ? { ...source, selected: this.modelSelection() } : undefined;
|
|
395
|
+
}
|
|
396
|
+
listModels() {
|
|
397
|
+
return this._connection.call('listModels', undefined);
|
|
398
|
+
}
|
|
399
|
+
modelChangeMode(modelId) {
|
|
400
|
+
return modelChangeMode(this.state.currentModel, this.state.provider, modelId);
|
|
401
|
+
}
|
|
402
|
+
switchModel(modelId) {
|
|
403
|
+
return this._connection.call('switchModel', modelId);
|
|
404
|
+
}
|
|
405
|
+
async restartModel(modelId) {
|
|
406
|
+
await this._rotate({ kind: 'model', modelId, thinking: this.modelSelection().thinking });
|
|
407
|
+
return this.state.currentModel;
|
|
408
|
+
}
|
|
409
|
+
listEfforts() {
|
|
410
|
+
return effortOptions(this.state.selection.model, this.modelSelection().thinking);
|
|
411
|
+
}
|
|
412
|
+
async setEffort(effort) {
|
|
413
|
+
validateEffortSelection(effort, this.listEfforts());
|
|
414
|
+
if (effortValue(effort) === effortValue(this.state.selection.thinking)) {
|
|
415
|
+
await this._connection.call('setEffort', effort);
|
|
416
|
+
this._thinking = undefined;
|
|
417
|
+
return effort;
|
|
418
|
+
}
|
|
419
|
+
this._thinking = effort;
|
|
420
|
+
return effort;
|
|
421
|
+
}
|
|
422
|
+
async clear() {
|
|
423
|
+
await this._rotate({ kind: 'clear', thinking: this.modelSelection().thinking });
|
|
424
|
+
}
|
|
425
|
+
compact() {
|
|
426
|
+
return this._connection.call('compact', undefined);
|
|
427
|
+
}
|
|
428
|
+
captureConversation() {
|
|
429
|
+
return this._connection.call('captureConversation', undefined);
|
|
430
|
+
}
|
|
431
|
+
flush() {
|
|
432
|
+
return this._connection.call('flush', undefined);
|
|
433
|
+
}
|
|
434
|
+
async captureFork() {
|
|
435
|
+
return { ...(await this._connection.call('captureFork', undefined)), ...this.modelSelection() };
|
|
436
|
+
}
|
|
437
|
+
_rotate(rotation) {
|
|
438
|
+
if (this._loading)
|
|
439
|
+
return Promise.reject(new Error('The TypeScript agent is already loading.'));
|
|
440
|
+
const controller = new AbortController();
|
|
441
|
+
const promise = this._replace(rotation, controller.signal).finally(() => {
|
|
442
|
+
this._loading = undefined;
|
|
443
|
+
});
|
|
444
|
+
this._loading = { controller, promise };
|
|
445
|
+
return promise;
|
|
446
|
+
}
|
|
447
|
+
async _replace(rotation, signal) {
|
|
448
|
+
const previous = this._connection;
|
|
449
|
+
const { selection, seed } = await previous.call('prepareRotation', rotation);
|
|
450
|
+
signal.throwIfAborted();
|
|
451
|
+
const options = {
|
|
452
|
+
...this._options,
|
|
453
|
+
selection,
|
|
454
|
+
sessionDirectory: previous.metadata.sessionDirectory,
|
|
455
|
+
...(rotation.kind === 'clear'
|
|
456
|
+
? { freshSession: true }
|
|
457
|
+
: {
|
|
458
|
+
...(previous.metadata.sessionId ? { sessionId: previous.metadata.sessionId } : {}),
|
|
459
|
+
...(seed ? { seed } : {}),
|
|
460
|
+
restoreSeedMessages: true,
|
|
461
|
+
}),
|
|
462
|
+
};
|
|
463
|
+
const { connection } = await TypescriptConnection.open({ ...options, config: { snapshot: this._config.snapshot(), environment: this._config.providerEnvironment() } }, this._config, this._messaging, signal);
|
|
464
|
+
if (this._disposal) {
|
|
465
|
+
await connection.dispose();
|
|
466
|
+
throw new Error('TypeScript agent closed.');
|
|
467
|
+
}
|
|
468
|
+
this._connection = connection;
|
|
469
|
+
this._thinking = undefined;
|
|
470
|
+
this._observe(connection);
|
|
471
|
+
for (const [id, listeners] of this._activityListeners) {
|
|
472
|
+
for (const listener of listeners)
|
|
473
|
+
listener(undefined);
|
|
474
|
+
if (this._activityListeners.has(id))
|
|
475
|
+
connection.notify('watchActivity', { id, enabled: true });
|
|
476
|
+
}
|
|
477
|
+
previous.onMessage = undefined;
|
|
478
|
+
await previous.dispose();
|
|
479
|
+
for (const listener of this._taskListeners)
|
|
480
|
+
listener(connection.tasks);
|
|
481
|
+
for (const listener of this._permissionListeners)
|
|
482
|
+
listener(connection.permission);
|
|
483
|
+
for (const listener of this._metadataListeners)
|
|
484
|
+
listener();
|
|
485
|
+
}
|
|
486
|
+
stream(prompt) {
|
|
487
|
+
return this._stream({ kind: 'model', prompt });
|
|
488
|
+
}
|
|
489
|
+
streamPeer(message) {
|
|
490
|
+
return this._stream({ kind: 'peer', message });
|
|
491
|
+
}
|
|
492
|
+
streamShell(command) {
|
|
493
|
+
return this._stream({ kind: 'shell', command });
|
|
494
|
+
}
|
|
495
|
+
streamBackgroundResults() {
|
|
496
|
+
return this._stream({ kind: 'background' });
|
|
497
|
+
}
|
|
498
|
+
async *_stream(input) {
|
|
499
|
+
if (this._invocation)
|
|
500
|
+
throw new Error('The TypeScript agent is busy.');
|
|
501
|
+
const invocation = { cancelled: false };
|
|
502
|
+
this._invocation = invocation;
|
|
503
|
+
let connection = this._connection;
|
|
504
|
+
let streamId;
|
|
505
|
+
let completed = false;
|
|
506
|
+
try {
|
|
507
|
+
if (input.kind !== 'shell' &&
|
|
508
|
+
effortValue(this.modelSelection().thinking) !== effortValue(this.state.selection.thinking)) {
|
|
509
|
+
await this._rotate({ kind: 'effort', thinking: this.modelSelection().thinking });
|
|
510
|
+
connection = this._connection;
|
|
511
|
+
}
|
|
512
|
+
if (invocation.cancelled)
|
|
513
|
+
throw new Error('TypeScript invocation cancelled.');
|
|
514
|
+
invocation.connection = connection;
|
|
515
|
+
streamId = await connection.call('start', input);
|
|
516
|
+
if (invocation.cancelled)
|
|
517
|
+
throw new Error('TypeScript invocation cancelled.');
|
|
518
|
+
while (true) {
|
|
519
|
+
const result = await connection.call('next', streamId);
|
|
520
|
+
if (result.done) {
|
|
521
|
+
completed = true;
|
|
522
|
+
return result.value;
|
|
523
|
+
}
|
|
524
|
+
yield result.value;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
finally {
|
|
528
|
+
if (!completed && streamId !== undefined) {
|
|
529
|
+
this.cancel();
|
|
530
|
+
await connection.call('return', streamId).catch(() => { });
|
|
531
|
+
}
|
|
532
|
+
this._invocation = undefined;
|
|
533
|
+
clearTimeout(invocation.cancelTimeout);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
cancel() {
|
|
537
|
+
const invocation = this._invocation;
|
|
538
|
+
if (invocation) {
|
|
539
|
+
invocation.cancelled = true;
|
|
540
|
+
this._loading?.controller.abort();
|
|
541
|
+
}
|
|
542
|
+
this._connection.notify('cancel', undefined);
|
|
543
|
+
if (!invocation || invocation.cancelTimeout)
|
|
544
|
+
return;
|
|
545
|
+
const connection = this._connection;
|
|
546
|
+
invocation.cancelTimeout = setTimeout(() => {
|
|
547
|
+
connection.fail(new Error('The TypeScript agent did not stop after cancellation. Reload it to continue.'));
|
|
548
|
+
void connection.dispose();
|
|
549
|
+
}, 3_000);
|
|
550
|
+
}
|
|
551
|
+
queueSteering(prompt, onConsumed) {
|
|
552
|
+
const connection = this._invocation?.connection;
|
|
553
|
+
if (!connection || this._draining || this._disposal || !prompt.trim())
|
|
554
|
+
return false;
|
|
555
|
+
const id = ++this._sequence;
|
|
556
|
+
this._steering.set(id, { prompt, consumed: onConsumed });
|
|
557
|
+
void connection.call('steer', { id, prompt }).catch((error) => {
|
|
558
|
+
connection.fail(new Error(errorMessage(error)));
|
|
559
|
+
});
|
|
560
|
+
return true;
|
|
561
|
+
}
|
|
562
|
+
async drainSteering() {
|
|
563
|
+
this._draining = true;
|
|
564
|
+
try {
|
|
565
|
+
await this._connection.call('drainSteering', undefined);
|
|
566
|
+
const pending = [...this._steering.values()].map((item) => item.prompt);
|
|
567
|
+
this._steering.clear();
|
|
568
|
+
return pending;
|
|
569
|
+
}
|
|
570
|
+
catch (error) {
|
|
571
|
+
this._steering.clear();
|
|
572
|
+
throw error;
|
|
573
|
+
}
|
|
574
|
+
finally {
|
|
575
|
+
this._draining = false;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
async generateSessionName(signal) {
|
|
579
|
+
signal.throwIfAborted();
|
|
580
|
+
const id = ++this._sequence;
|
|
581
|
+
const connection = this._connection;
|
|
582
|
+
const cancel = () => connection.notify('cancelNaming', id);
|
|
583
|
+
signal.addEventListener('abort', cancel, { once: true });
|
|
584
|
+
try {
|
|
585
|
+
return await connection.call('nameSession', id);
|
|
586
|
+
}
|
|
587
|
+
finally {
|
|
588
|
+
signal.removeEventListener('abort', cancel);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
permissionStatus() {
|
|
592
|
+
const snapshot = this._config.snapshot();
|
|
593
|
+
return {
|
|
594
|
+
mode: snapshot.permissions.mode,
|
|
595
|
+
allowedTools: snapshot.permissions.allow,
|
|
596
|
+
deniedTools: snapshot.permissions.deny,
|
|
597
|
+
configPath: snapshot.path,
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
setPermissionMode(mode) {
|
|
601
|
+
return this._connection.call('setPermissionMode', mode);
|
|
602
|
+
}
|
|
603
|
+
allowPermission(rule) {
|
|
604
|
+
return this._connection.call('allowPermission', rule);
|
|
605
|
+
}
|
|
606
|
+
removeAllowedPermission(rule) {
|
|
607
|
+
return this._connection.call('removeAllowedPermission', rule);
|
|
608
|
+
}
|
|
609
|
+
removeDeniedPermission(rule) {
|
|
610
|
+
return this._connection.call('removeDeniedPermission', rule);
|
|
611
|
+
}
|
|
612
|
+
respondPermission(requestId, optionId, rule) {
|
|
613
|
+
return this._connection.call('respondPermission', {
|
|
614
|
+
requestId,
|
|
615
|
+
...(optionId ? { optionId } : {}),
|
|
616
|
+
...(rule ? { rule } : {}),
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
hasReadyBackgroundResults() {
|
|
620
|
+
return this._connection.tasks.some((task) => task.source === 'background' && task.deliveryState === 'ready');
|
|
621
|
+
}
|
|
622
|
+
watchTasks(listener) {
|
|
623
|
+
this._taskListeners.add(listener);
|
|
624
|
+
listener(this._connection.tasks);
|
|
625
|
+
return () => {
|
|
626
|
+
this._taskListeners.delete(listener);
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
watchPermissions(listener) {
|
|
630
|
+
this._permissionListeners.add(listener);
|
|
631
|
+
listener(this._connection.permission);
|
|
632
|
+
return () => {
|
|
633
|
+
this._permissionListeners.delete(listener);
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
getTaskActivity(taskId) {
|
|
637
|
+
return this._connection.activities.get(taskId);
|
|
638
|
+
}
|
|
639
|
+
watchTaskActivity(taskId, listener) {
|
|
640
|
+
let listeners = this._activityListeners.get(taskId);
|
|
641
|
+
if (!listeners) {
|
|
642
|
+
this._activityListeners.set(taskId, (listeners = new Set()));
|
|
643
|
+
this._connection.notify('watchActivity', { id: taskId, enabled: true });
|
|
644
|
+
}
|
|
645
|
+
listeners.add(listener);
|
|
646
|
+
listener(this.getTaskActivity(taskId));
|
|
647
|
+
return () => {
|
|
648
|
+
listeners.delete(listener);
|
|
649
|
+
if (listeners.size > 0)
|
|
650
|
+
return;
|
|
651
|
+
this._activityListeners.delete(taskId);
|
|
652
|
+
this._connection.activities.delete(taskId);
|
|
653
|
+
this._connection.notify('watchActivity', { id: taskId, enabled: false });
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
subscribeConfiguration(listener) {
|
|
657
|
+
this._configurationListeners.add(listener);
|
|
658
|
+
return () => {
|
|
659
|
+
this._configurationListeners.delete(listener);
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
takeConfigurationChange() {
|
|
663
|
+
const pending = this._configuration;
|
|
664
|
+
if (!pending)
|
|
665
|
+
return undefined;
|
|
666
|
+
this._configuration = undefined;
|
|
667
|
+
const connection = this._connection;
|
|
668
|
+
return {
|
|
669
|
+
...pending.change,
|
|
670
|
+
onFailure: (message) => connection.call('configurationFailed', { token: pending.token, message }),
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
onDispose(listener) {
|
|
674
|
+
this._disposeListeners.add(listener);
|
|
675
|
+
return () => {
|
|
676
|
+
this._disposeListeners.delete(listener);
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
_observe(connection) {
|
|
680
|
+
connection.onMessage = (message) => {
|
|
681
|
+
if (this._connection !== connection || this._disposal)
|
|
682
|
+
return;
|
|
683
|
+
if (message.type === 'tasks')
|
|
684
|
+
for (const listener of this._taskListeners)
|
|
685
|
+
listener(message.value);
|
|
686
|
+
if (message.type === 'permission')
|
|
687
|
+
for (const listener of this._permissionListeners)
|
|
688
|
+
listener(message.value);
|
|
689
|
+
if (message.type === 'metadata')
|
|
690
|
+
for (const listener of this._metadataListeners)
|
|
691
|
+
listener();
|
|
692
|
+
if (message.type === 'activity') {
|
|
693
|
+
const listeners = this._activityListeners.get(message.id);
|
|
694
|
+
if (listeners) {
|
|
695
|
+
connection.activities.set(message.id, message.value);
|
|
696
|
+
for (const listener of listeners)
|
|
697
|
+
listener(message.value);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
if (message.type === 'consumed') {
|
|
701
|
+
const item = this._steering.get(message.id);
|
|
702
|
+
this._steering.delete(message.id);
|
|
703
|
+
item?.consumed();
|
|
704
|
+
}
|
|
705
|
+
if (message.type === 'configuration') {
|
|
706
|
+
this._configuration = message.value;
|
|
707
|
+
for (const listener of this._configurationListeners)
|
|
708
|
+
listener();
|
|
709
|
+
}
|
|
710
|
+
if (message.type === 'configurationDiscarded')
|
|
711
|
+
this._configuration = undefined;
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
dispose() {
|
|
715
|
+
if (this._disposal)
|
|
716
|
+
return this._disposal;
|
|
717
|
+
for (const listener of this._disposeListeners)
|
|
718
|
+
listener();
|
|
719
|
+
this._disposeListeners.clear();
|
|
720
|
+
this._loading?.controller.abort();
|
|
721
|
+
clearTimeout(this._invocation?.cancelTimeout);
|
|
722
|
+
this._steering.clear();
|
|
723
|
+
this._configuration = undefined;
|
|
724
|
+
this._taskListeners.clear();
|
|
725
|
+
this._permissionListeners.clear();
|
|
726
|
+
this._metadataListeners.clear();
|
|
727
|
+
this._configurationListeners.clear();
|
|
728
|
+
this._activityListeners.clear();
|
|
729
|
+
this._disposal = Promise.allSettled([this._connection.dispose(), this._loading?.promise]).then(() => { });
|
|
730
|
+
return this._disposal;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
//# sourceMappingURL=typescript-backend.js.map
|