@strands-agents/cli 0.2.4 → 0.4.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,730 @@
|
|
|
1
|
+
# /// script
|
|
2
|
+
# requires-python = ">=3.12,<3.15"
|
|
3
|
+
# dependencies = [
|
|
4
|
+
# "strands-agents[bidi,bidi-aec,bidi-io,bidi-openai,bidi-pyaudio]==1.60.0",
|
|
5
|
+
# ]
|
|
6
|
+
# ///
|
|
7
|
+
|
|
8
|
+
"""Bidirectional audio sidecar for the Strands CLI voice runtime."""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import argparse
|
|
13
|
+
import asyncio
|
|
14
|
+
import json
|
|
15
|
+
import logging
|
|
16
|
+
import math
|
|
17
|
+
import os
|
|
18
|
+
import signal
|
|
19
|
+
import sys
|
|
20
|
+
import threading
|
|
21
|
+
import time
|
|
22
|
+
from array import array
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
from typing import Any, Literal, cast
|
|
25
|
+
|
|
26
|
+
import boto3
|
|
27
|
+
|
|
28
|
+
PORTAUDIO_INSTALL_GUIDANCE = (
|
|
29
|
+
"Audio is unavailable: PyAudio could not load the PortAudio system library.\n"
|
|
30
|
+
"Install PortAudio, restart the CLI, and try /voice again:\n"
|
|
31
|
+
" macOS brew install portaudio\n"
|
|
32
|
+
" Ubuntu sudo apt-get install libportaudio2\n"
|
|
33
|
+
" Fedora sudo dnf install portaudio\n"
|
|
34
|
+
" Arch sudo pacman -S portaudio"
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
# Import PyAudio before the strands.bidi imports below, which reach the same native
|
|
39
|
+
# library: on a first run without PortAudio installed (#5413) the PyAudio wheel is
|
|
40
|
+
# present but its native dependency is not, and the import raises OSError. The TUI
|
|
41
|
+
# surfaces this process's stderr, so print the install steps and exit instead of
|
|
42
|
+
# showing a traceback.
|
|
43
|
+
import pyaudio # pyright: ignore[reportMissingModuleSource]
|
|
44
|
+
except OSError as error:
|
|
45
|
+
sys.stderr.write(f"{PORTAUDIO_INSTALL_GUIDANCE}\nDetails: {error}\n")
|
|
46
|
+
raise SystemExit(1) from error
|
|
47
|
+
|
|
48
|
+
from strands import tool
|
|
49
|
+
from strands.bidi import BidiAgent # pyright: ignore[reportMissingImports]
|
|
50
|
+
from strands.bidi.io import AudioIO, AudioProcessorConfig, ConsoleIO # pyright: ignore[reportMissingImports]
|
|
51
|
+
from strands.bidi.models import BedrockNovaSonicModel, OpenAIRealtimeModel # pyright: ignore[reportMissingImports]
|
|
52
|
+
from strands.bidi.types import ( # pyright: ignore[reportMissingImports]
|
|
53
|
+
AudioDelta,
|
|
54
|
+
BidiAudioDeltaEvent,
|
|
55
|
+
BidiBargeInEvent,
|
|
56
|
+
BidiConnectionRestartEvent,
|
|
57
|
+
BidiConnectionStartEvent,
|
|
58
|
+
BidiConnectionStopEvent,
|
|
59
|
+
BidiOutputEvent,
|
|
60
|
+
BidiResponseStartEvent,
|
|
61
|
+
BidiResponseStopEvent,
|
|
62
|
+
BidiToolUseBlocksEvent,
|
|
63
|
+
BidiTranscriptBlockEvent,
|
|
64
|
+
BidiTranscriptDeltaEvent,
|
|
65
|
+
InputStream,
|
|
66
|
+
OutputStream,
|
|
67
|
+
)
|
|
68
|
+
from strands.types.tools import ToolResultBlock, ToolSpec # pyright: ignore[reportAttributeAccessIssue]
|
|
69
|
+
|
|
70
|
+
DEFAULT_MODELS = {
|
|
71
|
+
"bedrock": "amazon.nova-2-5-sonic",
|
|
72
|
+
"openai": "gpt-realtime-2.1",
|
|
73
|
+
}
|
|
74
|
+
DEFAULT_VOICES = {
|
|
75
|
+
"bedrock": "tiffany",
|
|
76
|
+
"openai": "coral",
|
|
77
|
+
}
|
|
78
|
+
OPENAI_TRANSCRIPTION_MODEL = "gpt-transcribe"
|
|
79
|
+
DEFAULT_ENDPOINTING_SENSITIVITY = "LOW"
|
|
80
|
+
OPENAI_SILENCE_DURATION_MS = {
|
|
81
|
+
"HIGH": 350,
|
|
82
|
+
"MEDIUM": 500,
|
|
83
|
+
"LOW": 800,
|
|
84
|
+
}
|
|
85
|
+
SYSTEM_PROMPT = """
|
|
86
|
+
You are Strands Voice, the user's persistent real-time conversational supervisor over the active
|
|
87
|
+
Strands harness coding agent.
|
|
88
|
+
|
|
89
|
+
At the beginning of every response, call route_voice_turn exactly once:
|
|
90
|
+
- conversation: casual conversation, a general question you can answer confidently, or a
|
|
91
|
+
clarification that needs no workspace state, live information, tools, or external action.
|
|
92
|
+
- status: a question about what the harness agent is doing, what happened, or whether work finished.
|
|
93
|
+
- delegate: any request to inspect, change, run, search, research, create, fix, continue, or otherwise
|
|
94
|
+
act through the harness agent.
|
|
95
|
+
- cancel: a clear request to stop the harness agent's current work.
|
|
96
|
+
- narration: only for an internal grounded harness update.
|
|
97
|
+
|
|
98
|
+
For delegation, preserve the user's complete request. The harness agent owns files, tools, approvals,
|
|
99
|
+
coding work, and detailed execution. Do not claim that work started, changed, finished, or failed
|
|
100
|
+
unless the routing result says so. After routing, respond naturally and briefly. Continue talking
|
|
101
|
+
with the user while harness work runs. If the user interrupts you, stop speaking and listen.
|
|
102
|
+
""".strip()
|
|
103
|
+
NARRATION_PROMPT = """
|
|
104
|
+
Route this internal request as narration, then give the user a concise, natural update. Preserve the
|
|
105
|
+
grounded facts, omit awkward markdown and code syntax, and do not invent progress.
|
|
106
|
+
|
|
107
|
+
<harness_update>
|
|
108
|
+
{text}
|
|
109
|
+
</harness_update>
|
|
110
|
+
""".strip()
|
|
111
|
+
INPUT_LEVEL_FLOOR_DB = -60.0
|
|
112
|
+
INPUT_LEVEL_INTERVAL_SECONDS = 0.08
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def emit(event_type: str, **payload: Any) -> None:
|
|
116
|
+
"""Write one event to the Node parent process."""
|
|
117
|
+
print(json.dumps({"type": event_type, **payload}, default=str, separators=(",", ":")), flush=True)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class SupervisorBridge:
|
|
121
|
+
"""Resolve BiDi routing tools through the Node conversation manager."""
|
|
122
|
+
|
|
123
|
+
def __init__(self) -> None:
|
|
124
|
+
self._next_request_id = 0
|
|
125
|
+
self._pending: dict[str, asyncio.Future[Any]] = {}
|
|
126
|
+
|
|
127
|
+
async def request(self, action: str, **payload: Any) -> Any:
|
|
128
|
+
"""Send one supervisor request and await its correlated result."""
|
|
129
|
+
self._next_request_id += 1
|
|
130
|
+
request_id = f"supervisor-{self._next_request_id}"
|
|
131
|
+
future = asyncio.get_running_loop().create_future()
|
|
132
|
+
self._pending[request_id] = future
|
|
133
|
+
emit("supervisor_request", request_id=request_id, action=action, **payload)
|
|
134
|
+
try:
|
|
135
|
+
return await asyncio.wait_for(future, timeout=30)
|
|
136
|
+
finally:
|
|
137
|
+
self._pending.pop(request_id, None)
|
|
138
|
+
|
|
139
|
+
def resolve(self, command: dict[str, Any]) -> None:
|
|
140
|
+
"""Resolve a pending request from a parent control message."""
|
|
141
|
+
request_id = str(command.get("request_id", ""))
|
|
142
|
+
future = self._pending.get(request_id)
|
|
143
|
+
if future is None or future.done():
|
|
144
|
+
return
|
|
145
|
+
if command.get("ok") is True:
|
|
146
|
+
future.set_result(command.get("result"))
|
|
147
|
+
else:
|
|
148
|
+
future.set_exception(RuntimeError(str(command.get("error", "The harness action failed."))))
|
|
149
|
+
|
|
150
|
+
def cancel(self) -> None:
|
|
151
|
+
"""Cancel unresolved requests during shutdown."""
|
|
152
|
+
for future in self._pending.values():
|
|
153
|
+
if not future.done():
|
|
154
|
+
future.cancel()
|
|
155
|
+
self._pending.clear()
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
_supervisor_bridge: SupervisorBridge | None = None
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def supervisor_bridge() -> SupervisorBridge:
|
|
162
|
+
"""Return the bridge for the active sidecar session."""
|
|
163
|
+
if _supervisor_bridge is None:
|
|
164
|
+
raise RuntimeError("The voice supervisor is not connected.")
|
|
165
|
+
return _supervisor_bridge
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
VoiceTurnIntent = Literal["conversation", "status", "delegate", "cancel", "narration"]
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
@tool
|
|
172
|
+
async def route_voice_turn(intent: VoiceTurnIntent, request: str) -> Any:
|
|
173
|
+
"""Route every voice turn before responding.
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
intent: Whether this turn is conversation, status, delegation, cancellation, or narration.
|
|
177
|
+
request: The user's complete request or the supplied grounded harness update.
|
|
178
|
+
"""
|
|
179
|
+
text = request.strip()
|
|
180
|
+
if intent == "conversation":
|
|
181
|
+
return {"mode": "conversation", "instruction": "Answer the user directly, naturally, and briefly."}
|
|
182
|
+
if intent == "status":
|
|
183
|
+
return await supervisor_bridge().request("get_current_work")
|
|
184
|
+
if intent == "cancel":
|
|
185
|
+
return await supervisor_bridge().request("cancel_current_work")
|
|
186
|
+
if not text:
|
|
187
|
+
raise ValueError("The routed request cannot be empty.")
|
|
188
|
+
if intent == "delegate":
|
|
189
|
+
return await supervisor_bridge().request("send_instruction", instruction=text)
|
|
190
|
+
return {
|
|
191
|
+
"mode": "narration",
|
|
192
|
+
"instruction": "Summarize this grounded update naturally without adding facts.",
|
|
193
|
+
"content": text,
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
class RoutedNovaSonicModel(BedrockNovaSonicModel):
|
|
198
|
+
"""Require one routing tool call before each spoken response."""
|
|
199
|
+
|
|
200
|
+
def _get_prompt_start_event(self, tools: list[ToolSpec]) -> str:
|
|
201
|
+
event = json.loads(super()._get_prompt_start_event(tools))
|
|
202
|
+
tool_configuration = event["event"]["promptStart"].get("toolConfiguration")
|
|
203
|
+
if tool_configuration is not None:
|
|
204
|
+
tool_configuration["toolChoice"] = {"tool": {"name": "route_voice_turn"}}
|
|
205
|
+
return json.dumps(event, separators=(",", ":"))
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class RoutedOpenAIRealtimeModel(OpenAIRealtimeModel):
|
|
209
|
+
"""Require routing for user turns and allow speech after the routing result."""
|
|
210
|
+
|
|
211
|
+
def __init__(self, **kwargs: Any) -> None:
|
|
212
|
+
self._route_result_pending = False
|
|
213
|
+
super().__init__(**kwargs)
|
|
214
|
+
|
|
215
|
+
async def _send_tool_result(self, tool_result: ToolResultBlock) -> None:
|
|
216
|
+
# The SDK may defer response.create until the active response stops.
|
|
217
|
+
self._route_result_pending = True
|
|
218
|
+
await super()._send_tool_result(tool_result)
|
|
219
|
+
|
|
220
|
+
async def _send_event(self, event: dict[str, Any]) -> None:
|
|
221
|
+
routed_response = self._route_result_pending and event.get("type") == "response.create"
|
|
222
|
+
if routed_response:
|
|
223
|
+
event = {**event, "response": {**event.get("response", {}), "tool_choice": "none"}}
|
|
224
|
+
await super()._send_event(event)
|
|
225
|
+
if routed_response:
|
|
226
|
+
self._route_result_pending = False
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
class MutableAudioInput:
|
|
230
|
+
"""Capture microphone audio while allowing mute and level reporting."""
|
|
231
|
+
|
|
232
|
+
def __init__(self, input_stream: InputStream) -> None:
|
|
233
|
+
self._input_stream = input_stream
|
|
234
|
+
self._muted = False
|
|
235
|
+
self._smoothed_level = 0.0
|
|
236
|
+
self._last_level_emit = 0.0
|
|
237
|
+
|
|
238
|
+
async def start(self, agent: BidiAgent) -> None:
|
|
239
|
+
"""Start microphone capture."""
|
|
240
|
+
await self._input_stream.start(agent)
|
|
241
|
+
|
|
242
|
+
async def stop(self) -> None:
|
|
243
|
+
"""Stop microphone capture."""
|
|
244
|
+
await self._input_stream.stop()
|
|
245
|
+
|
|
246
|
+
async def __call__(self) -> AudioDelta:
|
|
247
|
+
"""Return captured audio, replacing it with silence while muted."""
|
|
248
|
+
event = await self._input_stream()
|
|
249
|
+
if not isinstance(event, AudioDelta):
|
|
250
|
+
raise TypeError(f"Expected audio input, received {type(event).__name__}.")
|
|
251
|
+
audio = event.source.get("bytes")
|
|
252
|
+
if not isinstance(audio, bytes):
|
|
253
|
+
raise TypeError("Expected microphone audio bytes.")
|
|
254
|
+
self._report_input_level(audio)
|
|
255
|
+
if not self._muted:
|
|
256
|
+
return event
|
|
257
|
+
return AudioDelta(format=event.format, source={"bytes": bytes(len(audio))})
|
|
258
|
+
|
|
259
|
+
def set_muted(self, muted: bool) -> None:
|
|
260
|
+
"""Enable or disable microphone audio."""
|
|
261
|
+
self._muted = muted
|
|
262
|
+
if muted:
|
|
263
|
+
self._smoothed_level = 0.0
|
|
264
|
+
self._emit_input_level(0.0, INPUT_LEVEL_FLOOR_DB)
|
|
265
|
+
|
|
266
|
+
def _report_input_level(self, audio: bytes) -> None:
|
|
267
|
+
now = time.monotonic()
|
|
268
|
+
if now - self._last_level_emit < INPUT_LEVEL_INTERVAL_SECONDS:
|
|
269
|
+
return
|
|
270
|
+
self._last_level_emit = now
|
|
271
|
+
if self._muted:
|
|
272
|
+
self._emit_input_level(0.0, INPUT_LEVEL_FLOOR_DB)
|
|
273
|
+
return
|
|
274
|
+
if len(audio) < 2:
|
|
275
|
+
self._smoothed_level = 0.0
|
|
276
|
+
self._emit_input_level(0.0, INPUT_LEVEL_FLOOR_DB)
|
|
277
|
+
return
|
|
278
|
+
|
|
279
|
+
samples = array("h")
|
|
280
|
+
samples.frombytes(audio[: len(audio) - (len(audio) % 2)])
|
|
281
|
+
if sys.byteorder != "little":
|
|
282
|
+
samples.byteswap()
|
|
283
|
+
|
|
284
|
+
rms = math.sqrt(sum(sample * sample for sample in samples) / len(samples)) / 32768.0
|
|
285
|
+
db = max(INPUT_LEVEL_FLOOR_DB, 20.0 * math.log10(max(rms, 1e-6)))
|
|
286
|
+
level = (db - INPUT_LEVEL_FLOOR_DB) / -INPUT_LEVEL_FLOOR_DB
|
|
287
|
+
smoothing = 0.45 if level > self._smoothed_level else 0.2
|
|
288
|
+
self._smoothed_level += (level - self._smoothed_level) * smoothing
|
|
289
|
+
smoothed_db = INPUT_LEVEL_FLOOR_DB + self._smoothed_level * -INPUT_LEVEL_FLOOR_DB
|
|
290
|
+
self._emit_input_level(self._smoothed_level, smoothed_db)
|
|
291
|
+
|
|
292
|
+
@staticmethod
|
|
293
|
+
def _emit_input_level(level: float, db: float) -> None:
|
|
294
|
+
emit("input_level", level=round(level, 3), db=round(db, 1))
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
class SidecarControl:
|
|
298
|
+
"""Read newline-delimited control messages from the Node parent process."""
|
|
299
|
+
|
|
300
|
+
def __init__(self) -> None:
|
|
301
|
+
self._commands: asyncio.Queue[dict[str, Any]] = asyncio.Queue()
|
|
302
|
+
self._loop: asyncio.AbstractEventLoop | None = None
|
|
303
|
+
self._stopped = threading.Event()
|
|
304
|
+
|
|
305
|
+
async def start(self) -> None:
|
|
306
|
+
"""Start reading control messages."""
|
|
307
|
+
self._loop = asyncio.get_running_loop()
|
|
308
|
+
threading.Thread(target=self._read_lines, name="voice-sidecar-control", daemon=True).start()
|
|
309
|
+
|
|
310
|
+
async def stop(self) -> None:
|
|
311
|
+
"""Stop reading control messages."""
|
|
312
|
+
self._stopped.set()
|
|
313
|
+
self._loop = None
|
|
314
|
+
|
|
315
|
+
async def next(self) -> dict[str, Any]:
|
|
316
|
+
"""Wait for the next control message."""
|
|
317
|
+
return await self._commands.get()
|
|
318
|
+
|
|
319
|
+
def _read_lines(self) -> None:
|
|
320
|
+
while not self._stopped.is_set():
|
|
321
|
+
line = sys.stdin.readline()
|
|
322
|
+
if not line:
|
|
323
|
+
self._enqueue({"type": "stop"})
|
|
324
|
+
return
|
|
325
|
+
try:
|
|
326
|
+
command = json.loads(line)
|
|
327
|
+
except json.JSONDecodeError as error:
|
|
328
|
+
self._enqueue({"type": "control_error", "message": str(error)})
|
|
329
|
+
continue
|
|
330
|
+
if isinstance(command, dict):
|
|
331
|
+
self._enqueue(command)
|
|
332
|
+
|
|
333
|
+
def _enqueue(self, command: dict[str, Any]) -> None:
|
|
334
|
+
loop = self._loop
|
|
335
|
+
if loop is not None and not loop.is_closed():
|
|
336
|
+
loop.call_soon_threadsafe(self._commands.put_nowait, command)
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
class JsonEventOutput:
|
|
340
|
+
"""Project the stable Bidi event stream onto the CLI sidecar protocol."""
|
|
341
|
+
|
|
342
|
+
def __init__(self) -> None:
|
|
343
|
+
self._transcripts: dict[str, str] = {}
|
|
344
|
+
|
|
345
|
+
async def start(self, agent: BidiAgent) -> None:
|
|
346
|
+
"""Prepare event projection."""
|
|
347
|
+
del agent
|
|
348
|
+
|
|
349
|
+
async def stop(self) -> None:
|
|
350
|
+
"""Clear incomplete transcripts."""
|
|
351
|
+
self._transcripts.clear()
|
|
352
|
+
|
|
353
|
+
async def __call__(self, event: BidiOutputEvent) -> None:
|
|
354
|
+
"""Emit the subset of events consumed by the Node parent."""
|
|
355
|
+
if isinstance(event, BidiConnectionStartEvent):
|
|
356
|
+
emit("connection_start", connection_id=event.connection_id, model=event.model)
|
|
357
|
+
elif isinstance(event, BidiConnectionRestartEvent):
|
|
358
|
+
self._transcripts.clear()
|
|
359
|
+
emit(
|
|
360
|
+
"connection_restart",
|
|
361
|
+
reason=event.reason,
|
|
362
|
+
turn_interrupted=event.turn_interrupted,
|
|
363
|
+
error=str(event.timeout_error) if event.timeout_error is not None else None,
|
|
364
|
+
)
|
|
365
|
+
elif isinstance(event, BidiTranscriptDeltaEvent):
|
|
366
|
+
transcript = f"{self._transcripts.get(event.content_id, '')}{event.delta}"
|
|
367
|
+
self._transcripts[event.content_id] = transcript
|
|
368
|
+
emit(
|
|
369
|
+
"transcript",
|
|
370
|
+
role=event.role,
|
|
371
|
+
current_transcript=transcript,
|
|
372
|
+
is_final=False,
|
|
373
|
+
)
|
|
374
|
+
elif isinstance(event, BidiTranscriptBlockEvent):
|
|
375
|
+
self._transcripts.pop(event.content_id, None)
|
|
376
|
+
emit(
|
|
377
|
+
"transcript",
|
|
378
|
+
role=event.role,
|
|
379
|
+
current_transcript=event.transcript,
|
|
380
|
+
is_final=True,
|
|
381
|
+
)
|
|
382
|
+
elif isinstance(event, BidiConnectionStopEvent):
|
|
383
|
+
self._transcripts.clear()
|
|
384
|
+
emit("connection_stop", connection_id=event.connection_id, reason=event.reason)
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
class _SilentOutput:
|
|
388
|
+
"""Suppress the console output bundled with AudioIO."""
|
|
389
|
+
|
|
390
|
+
async def start(self, agent: BidiAgent) -> None:
|
|
391
|
+
del agent
|
|
392
|
+
|
|
393
|
+
async def stop(self) -> None:
|
|
394
|
+
return
|
|
395
|
+
|
|
396
|
+
async def __call__(self, event: BidiOutputEvent) -> None:
|
|
397
|
+
del event
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
class _SilentConsoleIO:
|
|
401
|
+
"""Provide AudioIO with a console that never writes to the terminal."""
|
|
402
|
+
|
|
403
|
+
def output(self) -> OutputStream:
|
|
404
|
+
"""Return a no-op output stream."""
|
|
405
|
+
return _SilentOutput()
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
class ControlledAudioOutput:
|
|
409
|
+
"""Play conversational and narrated replies with interruption handling."""
|
|
410
|
+
|
|
411
|
+
def __init__(self, output_stream: OutputStream) -> None:
|
|
412
|
+
self._output_stream = output_stream
|
|
413
|
+
self._response_id: str | None = None
|
|
414
|
+
self._playback: Literal["stopped", "ready", "playing"] = "stopped"
|
|
415
|
+
self._tool_response = False
|
|
416
|
+
self._interrupted_response_id: str | None = None
|
|
417
|
+
self._idle = asyncio.Event()
|
|
418
|
+
|
|
419
|
+
async def start(self, agent: BidiAgent) -> None:
|
|
420
|
+
"""Start speaker output."""
|
|
421
|
+
await self._output_stream.start(agent)
|
|
422
|
+
|
|
423
|
+
async def stop(self) -> None:
|
|
424
|
+
"""Stop speaker output."""
|
|
425
|
+
await self._output_stream.stop()
|
|
426
|
+
self._interrupted_response_id = None
|
|
427
|
+
self._finish_response(idle=False)
|
|
428
|
+
|
|
429
|
+
async def __call__(self, event: BidiOutputEvent) -> None:
|
|
430
|
+
"""Route response audio according to the current playback request."""
|
|
431
|
+
if isinstance(event, BidiConnectionStartEvent):
|
|
432
|
+
self._interrupted_response_id = None
|
|
433
|
+
self._finish_response()
|
|
434
|
+
elif isinstance(event, BidiResponseStartEvent):
|
|
435
|
+
self._response_id = event.response_id
|
|
436
|
+
self._idle.clear()
|
|
437
|
+
self._playback = "ready"
|
|
438
|
+
self._tool_response = False
|
|
439
|
+
elif isinstance(event, BidiToolUseBlocksEvent):
|
|
440
|
+
self._tool_response = True
|
|
441
|
+
elif isinstance(event, BidiAudioDeltaEvent):
|
|
442
|
+
self._tool_response = False
|
|
443
|
+
if self._playback == "stopped":
|
|
444
|
+
return
|
|
445
|
+
if self._playback == "ready":
|
|
446
|
+
self._playback = "playing"
|
|
447
|
+
emit("speech_output_start")
|
|
448
|
+
await self._output_stream(event)
|
|
449
|
+
elif isinstance(event, BidiBargeInEvent):
|
|
450
|
+
await self._output_stream(event)
|
|
451
|
+
if self._response_id is None:
|
|
452
|
+
self._idle.clear()
|
|
453
|
+
return
|
|
454
|
+
if self._playback == "playing":
|
|
455
|
+
emit("speech_output_interrupted")
|
|
456
|
+
self._interrupted_response_id = self._response_id
|
|
457
|
+
self._finish_response(idle=False)
|
|
458
|
+
elif isinstance(event, BidiResponseStopEvent):
|
|
459
|
+
if event.response_id == self._interrupted_response_id:
|
|
460
|
+
self._interrupted_response_id = None
|
|
461
|
+
return
|
|
462
|
+
if self._tool_response:
|
|
463
|
+
self._finish_response(idle=False)
|
|
464
|
+
return
|
|
465
|
+
if self._playback == "playing":
|
|
466
|
+
emit("speech_output_complete", response_id=event.response_id)
|
|
467
|
+
self._finish_response()
|
|
468
|
+
elif isinstance(event, (BidiConnectionRestartEvent, BidiConnectionStopEvent)):
|
|
469
|
+
await self.stop_speaking()
|
|
470
|
+
self._interrupted_response_id = None
|
|
471
|
+
self._finish_response(idle=False)
|
|
472
|
+
|
|
473
|
+
async def wait_until_idle(self) -> None:
|
|
474
|
+
"""Wait until the model finishes its current response."""
|
|
475
|
+
await self._idle.wait()
|
|
476
|
+
|
|
477
|
+
def mark_response_pending(self) -> None:
|
|
478
|
+
"""Reserve playback before a programmatic response is submitted."""
|
|
479
|
+
self._finish_response(idle=False)
|
|
480
|
+
|
|
481
|
+
async def stop_speaking(self) -> None:
|
|
482
|
+
"""Clear speaker output without ending the model's turn."""
|
|
483
|
+
was_speaking = self._playback == "playing"
|
|
484
|
+
await self._output_stream(BidiBargeInEvent())
|
|
485
|
+
self._playback = "stopped"
|
|
486
|
+
if was_speaking:
|
|
487
|
+
emit("speech_output_stopped")
|
|
488
|
+
|
|
489
|
+
def _finish_response(self, *, idle: bool = True) -> None:
|
|
490
|
+
self._response_id = None
|
|
491
|
+
self._playback = "stopped"
|
|
492
|
+
self._tool_response = False
|
|
493
|
+
if idle:
|
|
494
|
+
self._idle.set()
|
|
495
|
+
else:
|
|
496
|
+
self._idle.clear()
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
def parse_args() -> argparse.Namespace:
|
|
500
|
+
"""Parse sidecar configuration."""
|
|
501
|
+
parser = argparse.ArgumentParser(description="Run the Strands CLI bidirectional voice supervisor.")
|
|
502
|
+
parser.add_argument("--provider", choices=["bedrock", "openai"], default="bedrock")
|
|
503
|
+
parser.add_argument("--model")
|
|
504
|
+
parser.add_argument("--region", help="AWS region; defaults to the active AWS configuration.")
|
|
505
|
+
parser.add_argument("--voice")
|
|
506
|
+
parser.add_argument(
|
|
507
|
+
"--endpointing-sensitivity",
|
|
508
|
+
choices=["HIGH", "MEDIUM", "LOW"],
|
|
509
|
+
default=DEFAULT_ENDPOINTING_SENSITIVITY,
|
|
510
|
+
)
|
|
511
|
+
parser.add_argument("--input-device", type=int)
|
|
512
|
+
parser.add_argument("--output-device", type=int)
|
|
513
|
+
parser.add_argument("--muted", action="store_true")
|
|
514
|
+
parser.add_argument("--list-devices", action="store_true")
|
|
515
|
+
parser.add_argument(
|
|
516
|
+
"--check", action="store_true", help="Validate credentials and audio devices without connecting."
|
|
517
|
+
)
|
|
518
|
+
return parser.parse_args()
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
def audio_devices() -> list[dict[str, Any]]:
|
|
522
|
+
"""List local audio devices."""
|
|
523
|
+
try:
|
|
524
|
+
audio = pyaudio.PyAudio()
|
|
525
|
+
except OSError as error:
|
|
526
|
+
# Same first-run dead end as the import, for layouts where PyAudio imports but the
|
|
527
|
+
# PortAudio init fails; --check would otherwise show a bare OSError.
|
|
528
|
+
raise OSError(f"{PORTAUDIO_INSTALL_GUIDANCE}\nDetails: {error}") from error
|
|
529
|
+
try:
|
|
530
|
+
devices = []
|
|
531
|
+
for index in range(audio.get_device_count()):
|
|
532
|
+
info = audio.get_device_info_by_index(index)
|
|
533
|
+
devices.append(
|
|
534
|
+
{
|
|
535
|
+
"index": index,
|
|
536
|
+
"name": info.get("name"),
|
|
537
|
+
"input_channels": int(info.get("maxInputChannels", 0)),
|
|
538
|
+
"output_channels": int(info.get("maxOutputChannels", 0)),
|
|
539
|
+
"default_sample_rate": int(info.get("defaultSampleRate", 0)),
|
|
540
|
+
}
|
|
541
|
+
)
|
|
542
|
+
return devices
|
|
543
|
+
finally:
|
|
544
|
+
audio.terminate()
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
def preflight(args: argparse.Namespace) -> tuple[str | None, list[dict[str, Any]]]:
|
|
548
|
+
"""Validate credentials, region, and local audio devices."""
|
|
549
|
+
args.model = args.model or DEFAULT_MODELS[args.provider]
|
|
550
|
+
args.voice = args.voice or DEFAULT_VOICES[args.provider]
|
|
551
|
+
region: str | None = None
|
|
552
|
+
if args.provider == "bedrock":
|
|
553
|
+
session = boto3.Session()
|
|
554
|
+
if session.get_credentials() is None:
|
|
555
|
+
raise RuntimeError("AWS credentials were not found. Configure Bedrock with /setup, then try again.")
|
|
556
|
+
region = (
|
|
557
|
+
args.region
|
|
558
|
+
or session.region_name
|
|
559
|
+
or os.getenv("AWS_REGION")
|
|
560
|
+
or os.getenv("AWS_DEFAULT_REGION")
|
|
561
|
+
or "us-east-1"
|
|
562
|
+
)
|
|
563
|
+
elif not os.getenv("OPENAI_API_KEY"):
|
|
564
|
+
raise RuntimeError("OPENAI_API_KEY is not configured. Add OpenAI credentials with /setup, then try again.")
|
|
565
|
+
|
|
566
|
+
devices = audio_devices()
|
|
567
|
+
if not any(device["input_channels"] > 0 for device in devices):
|
|
568
|
+
raise RuntimeError("No microphone input device was found.")
|
|
569
|
+
if not any(device["output_channels"] > 0 for device in devices):
|
|
570
|
+
raise RuntimeError("No speaker output device was found.")
|
|
571
|
+
|
|
572
|
+
emit(
|
|
573
|
+
"preflight",
|
|
574
|
+
ok=True,
|
|
575
|
+
provider=args.provider,
|
|
576
|
+
model=args.model,
|
|
577
|
+
region=region,
|
|
578
|
+
cwd=str(Path.cwd()),
|
|
579
|
+
input_device=args.input_device,
|
|
580
|
+
output_device=args.output_device,
|
|
581
|
+
device_count=len(devices),
|
|
582
|
+
)
|
|
583
|
+
return region, devices
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
async def run_voice(args: argparse.Namespace, region: str | None) -> None:
|
|
587
|
+
"""Run the sidecar until the parent, signal, or model ends the session."""
|
|
588
|
+
global _supervisor_bridge
|
|
589
|
+
bridge = SupervisorBridge()
|
|
590
|
+
_supervisor_bridge = bridge
|
|
591
|
+
if args.provider == "bedrock":
|
|
592
|
+
model = RoutedNovaSonicModel(
|
|
593
|
+
model_id=args.model,
|
|
594
|
+
region=region,
|
|
595
|
+
voice=args.voice,
|
|
596
|
+
params={
|
|
597
|
+
"turnDetectionConfiguration": {
|
|
598
|
+
"endpointingSensitivity": args.endpointing_sensitivity,
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
)
|
|
602
|
+
else:
|
|
603
|
+
model = RoutedOpenAIRealtimeModel(
|
|
604
|
+
model_id=args.model,
|
|
605
|
+
transcription_model_id=OPENAI_TRANSCRIPTION_MODEL,
|
|
606
|
+
voice=args.voice,
|
|
607
|
+
params={
|
|
608
|
+
"tool_choice": {"type": "function", "name": "route_voice_turn"},
|
|
609
|
+
"audio": {
|
|
610
|
+
"input": {
|
|
611
|
+
"turn_detection": {
|
|
612
|
+
"silence_duration_ms": OPENAI_SILENCE_DURATION_MS[args.endpointing_sensitivity],
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
},
|
|
616
|
+
},
|
|
617
|
+
)
|
|
618
|
+
audio = AudioIO(
|
|
619
|
+
audio_processor=AudioProcessorConfig(),
|
|
620
|
+
console=cast(ConsoleIO, _SilentConsoleIO()),
|
|
621
|
+
input_device_index=args.input_device,
|
|
622
|
+
output_device_index=args.output_device,
|
|
623
|
+
)
|
|
624
|
+
agent = BidiAgent(
|
|
625
|
+
model=model,
|
|
626
|
+
tools=[route_voice_turn],
|
|
627
|
+
system_prompt=SYSTEM_PROMPT,
|
|
628
|
+
name="Strands Voice",
|
|
629
|
+
)
|
|
630
|
+
audio_input = MutableAudioInput(audio.input())
|
|
631
|
+
audio_input.set_muted(args.muted)
|
|
632
|
+
audio_output = ControlledAudioOutput(audio.output())
|
|
633
|
+
event_output = JsonEventOutput()
|
|
634
|
+
control = SidecarControl()
|
|
635
|
+
narrations: asyncio.Queue[str] = asyncio.Queue()
|
|
636
|
+
stop_requested = asyncio.Event()
|
|
637
|
+
loop = asyncio.get_running_loop()
|
|
638
|
+
registered_signals: list[signal.Signals] = []
|
|
639
|
+
|
|
640
|
+
for signal_number in (signal.SIGINT, signal.SIGTERM):
|
|
641
|
+
try:
|
|
642
|
+
loop.add_signal_handler(signal_number, stop_requested.set)
|
|
643
|
+
registered_signals.append(signal_number)
|
|
644
|
+
except NotImplementedError:
|
|
645
|
+
pass
|
|
646
|
+
|
|
647
|
+
async def run_controls() -> None:
|
|
648
|
+
while True:
|
|
649
|
+
command = await control.next()
|
|
650
|
+
command_type = command.get("type")
|
|
651
|
+
if command_type == "set_muted":
|
|
652
|
+
muted = command.get("muted") is True
|
|
653
|
+
audio_input.set_muted(muted)
|
|
654
|
+
emit("mute_changed", muted=muted)
|
|
655
|
+
elif command_type == "narrate":
|
|
656
|
+
text = str(command.get("text", "")).strip()
|
|
657
|
+
if not text:
|
|
658
|
+
emit("control_error", message="The narration command requires non-empty text.")
|
|
659
|
+
continue
|
|
660
|
+
await narrations.put(text)
|
|
661
|
+
elif command_type == "supervisor_result":
|
|
662
|
+
bridge.resolve(command)
|
|
663
|
+
elif command_type == "stop_speaking":
|
|
664
|
+
await audio_output.stop_speaking()
|
|
665
|
+
elif command_type == "stop":
|
|
666
|
+
return
|
|
667
|
+
elif command_type == "control_error":
|
|
668
|
+
emit("control_error", message=command.get("message"))
|
|
669
|
+
else:
|
|
670
|
+
emit("control_error", message=f"Unknown control message: {command_type}")
|
|
671
|
+
|
|
672
|
+
async def run_narrations() -> None:
|
|
673
|
+
while True:
|
|
674
|
+
text = await narrations.get()
|
|
675
|
+
await audio_output.wait_until_idle()
|
|
676
|
+
audio_output.mark_response_pending()
|
|
677
|
+
try:
|
|
678
|
+
await agent.send(NARRATION_PROMPT.format(text=text))
|
|
679
|
+
except BaseException:
|
|
680
|
+
await audio_output.stop_speaking()
|
|
681
|
+
raise
|
|
682
|
+
|
|
683
|
+
tasks: list[asyncio.Task[Any]] = []
|
|
684
|
+
await control.start()
|
|
685
|
+
try:
|
|
686
|
+
tasks = [
|
|
687
|
+
asyncio.create_task(agent.run(inputs=[audio_input], outputs=[audio_output, event_output])),
|
|
688
|
+
asyncio.create_task(run_controls()),
|
|
689
|
+
asyncio.create_task(run_narrations()),
|
|
690
|
+
asyncio.create_task(stop_requested.wait()),
|
|
691
|
+
]
|
|
692
|
+
done, _ = await asyncio.wait(tasks, return_when=asyncio.FIRST_COMPLETED)
|
|
693
|
+
for task in done:
|
|
694
|
+
if task is tasks[3] or task.cancelled():
|
|
695
|
+
continue
|
|
696
|
+
task.result()
|
|
697
|
+
finally:
|
|
698
|
+
for task in tasks:
|
|
699
|
+
task.cancel()
|
|
700
|
+
await asyncio.gather(*tasks, return_exceptions=True)
|
|
701
|
+
bridge.cancel()
|
|
702
|
+
_supervisor_bridge = None
|
|
703
|
+
await control.stop()
|
|
704
|
+
for signal_number in registered_signals:
|
|
705
|
+
loop.remove_signal_handler(signal_number)
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
def main() -> int:
|
|
709
|
+
"""Run the voice sidecar."""
|
|
710
|
+
logging.basicConfig(level=logging.WARNING, stream=sys.stderr)
|
|
711
|
+
args = parse_args()
|
|
712
|
+
|
|
713
|
+
try:
|
|
714
|
+
region, devices = preflight(args)
|
|
715
|
+
if args.list_devices:
|
|
716
|
+
for device in devices:
|
|
717
|
+
emit("audio_device", **device)
|
|
718
|
+
if args.check or args.list_devices:
|
|
719
|
+
return 0
|
|
720
|
+
asyncio.run(run_voice(args, region))
|
|
721
|
+
return 0
|
|
722
|
+
except KeyboardInterrupt:
|
|
723
|
+
return 0
|
|
724
|
+
except Exception as error:
|
|
725
|
+
emit("fatal_error", code=type(error).__name__, message=str(error))
|
|
726
|
+
return 1
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
if __name__ == "__main__":
|
|
730
|
+
raise SystemExit(main())
|