@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
|
@@ -22,19 +22,25 @@ from uuid import uuid4
|
|
|
22
22
|
import strands_harness
|
|
23
23
|
from strands import Agent, tool
|
|
24
24
|
from strands.hooks import HookOrder
|
|
25
|
-
from strands.hooks.events import BeforeToolCallEvent
|
|
26
|
-
from strands.
|
|
27
|
-
from strands.
|
|
25
|
+
from strands.hooks.events import BeforeModelCallEvent, BeforeToolCallEvent
|
|
26
|
+
from strands.models import Model
|
|
27
|
+
from strands.session import FileSessionManager, S3SessionManager, SnapshotSessionManager
|
|
28
|
+
from strands.storage import InMemoryStorage, LocalFileStorage, S3Storage
|
|
29
|
+
from strands.storage import storage as storage_types
|
|
28
30
|
from strands.tools.mcp import MCPClient
|
|
29
31
|
from strands.types.tools import ToolContext
|
|
32
|
+
from strands.vended_memory_stores.file_memory_store import FileMemoryStore
|
|
30
33
|
from strands.vended_plugins.context_offloader import ContextOffloader
|
|
34
|
+
from strands.vended_plugins.context_offloader import storage as offloader_storage
|
|
31
35
|
from strands.vended_plugins.skills import AgentSkills
|
|
32
36
|
from strands_harness import define_harness_agent_config, harness_agent_kwargs_from_config
|
|
33
37
|
from strands_harness.defaults import DEFAULT_MODEL
|
|
34
38
|
|
|
35
39
|
channel = os.fdopen(3, "w", buffering=1)
|
|
40
|
+
commands = os.fdopen(4, encoding="utf-8")
|
|
36
41
|
pending_permissions = {}
|
|
37
42
|
COMPACT_PRESERVE_RECENT_MESSAGES = 2
|
|
43
|
+
MAX_SAFE_INTEGER = 9_007_199_254_740_991
|
|
38
44
|
|
|
39
45
|
|
|
40
46
|
def encode(value):
|
|
@@ -65,6 +71,68 @@ def compacted_tokens(reported, estimated_before, estimated_after):
|
|
|
65
71
|
return max(0, reported - max(0, estimated_before - estimated_after))
|
|
66
72
|
|
|
67
73
|
|
|
74
|
+
async def estimate_context_categories(context):
|
|
75
|
+
system = context.system_prompt
|
|
76
|
+
estimates = {
|
|
77
|
+
"systemPrompt": await Model.count_tokens(
|
|
78
|
+
context.model,
|
|
79
|
+
[],
|
|
80
|
+
system_prompt=system if isinstance(system, str) else None,
|
|
81
|
+
system_prompt_content=system if isinstance(system, list) else None,
|
|
82
|
+
),
|
|
83
|
+
"tools": await Model.count_tokens(context.model, [], tool_specs=context.tool_specs),
|
|
84
|
+
}
|
|
85
|
+
grouped = {kind: [] for kind in ("userMessages", "assistantMessages", "toolResults", "injectedContext")}
|
|
86
|
+
last_user = next(
|
|
87
|
+
(index for index in range(len(context.messages) - 1, -1, -1) if context.messages[index]["role"] == "user"),
|
|
88
|
+
-1,
|
|
89
|
+
)
|
|
90
|
+
trailing = max(0, getattr(context, "dynamic_trailing_blocks", 0))
|
|
91
|
+
for index, message in enumerate(context.messages):
|
|
92
|
+
content = message["content"]
|
|
93
|
+
for block_index, block in enumerate(content):
|
|
94
|
+
if index == last_user and block_index >= len(content) - trailing:
|
|
95
|
+
kind = "injectedContext"
|
|
96
|
+
elif "toolResult" in block:
|
|
97
|
+
kind = "toolResults"
|
|
98
|
+
else:
|
|
99
|
+
kind = "assistantMessages" if message["role"] == "assistant" else "userMessages"
|
|
100
|
+
grouped[kind].append({"role": message["role"], "content": [block]})
|
|
101
|
+
for kind, messages in grouped.items():
|
|
102
|
+
estimates[kind] = await Model.count_tokens(context.model, messages)
|
|
103
|
+
return estimates
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def context_breakdown(estimates, current_tokens, projected_tokens):
|
|
107
|
+
if estimates is None or any(
|
|
108
|
+
type(value) is not int or value < 0 or value > MAX_SAFE_INTEGER
|
|
109
|
+
for value in (current_tokens, projected_tokens, *estimates.values())
|
|
110
|
+
):
|
|
111
|
+
return None
|
|
112
|
+
if projected_tokens < current_tokens:
|
|
113
|
+
return None
|
|
114
|
+
total = sum(estimates.values())
|
|
115
|
+
tokens = {
|
|
116
|
+
kind: value * current_tokens // total if total > current_tokens else value
|
|
117
|
+
for kind, value in estimates.items()
|
|
118
|
+
}
|
|
119
|
+
tokens["other"] = current_tokens - sum(tokens.values())
|
|
120
|
+
tokens["assistantMessages"] += projected_tokens - current_tokens
|
|
121
|
+
return {"categories": [{"kind": kind, "tokens": value} for kind, value in tokens.items() if value > 0]}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def context_model_usage(usage):
|
|
125
|
+
if not isinstance(usage, dict) or any(key not in usage for key in ("inputTokens", "outputTokens", "totalTokens")):
|
|
126
|
+
return None
|
|
127
|
+
numeric = {
|
|
128
|
+
key: usage.get(key, 0)
|
|
129
|
+
for key in ("inputTokens", "outputTokens", "totalTokens", "cacheReadInputTokens", "cacheWriteInputTokens")
|
|
130
|
+
}
|
|
131
|
+
if any(type(value) is not int or value < 0 or value > MAX_SAFE_INTEGER for value in numeric.values()):
|
|
132
|
+
return None
|
|
133
|
+
return numeric if any(numeric.values()) else None
|
|
134
|
+
|
|
135
|
+
|
|
68
136
|
async def authorize_tool(event):
|
|
69
137
|
tool_use = event.tool_use
|
|
70
138
|
if tool_use["name"] == "strands_config":
|
|
@@ -103,25 +171,59 @@ async def permission(request):
|
|
|
103
171
|
pending_permissions.pop(request_id, None)
|
|
104
172
|
|
|
105
173
|
|
|
106
|
-
def
|
|
174
|
+
def merge_assigned_option(authored, converted, paths, path):
|
|
175
|
+
if any(path == assigned or path.startswith(assigned + ".") for assigned in paths) or not isinstance(converted, dict):
|
|
176
|
+
return converted
|
|
177
|
+
if path == "builtinTools" and isinstance(authored, list):
|
|
178
|
+
authored = {"*": False, **dict.fromkeys(authored, True)}
|
|
179
|
+
merged: dict[str, object] = dict(authored) if isinstance(authored, dict) else {}
|
|
180
|
+
for name in {assigned[len(path) + 1:].split(".")[0] for assigned in paths if assigned.startswith(path + ".")}:
|
|
181
|
+
key = name if name in converted else re.sub(r"[A-Z]", lambda match: "_" + match[0].lower(), name)
|
|
182
|
+
merged[key] = merge_assigned_option(merged.get(key), converted.get(key), paths, f"{path}.{name}")
|
|
183
|
+
return merged
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def overrides_from_config(partial, authored, assignments):
|
|
107
187
|
if not partial:
|
|
108
188
|
return {}
|
|
109
189
|
config = define_harness_agent_config(partial)
|
|
110
190
|
options = harness_agent_kwargs_from_config(config)
|
|
111
191
|
# These values are normally omitted by the config loader when equal to defaults.
|
|
112
|
-
for key in ("builtinTools", "builtinPlugins", "caching", "description", "instructions"
|
|
192
|
+
for key in ("builtinTools", "builtinPlugins", "caching", "description", "instructions"):
|
|
113
193
|
if key in partial:
|
|
114
|
-
options
|
|
194
|
+
options.setdefault(re.sub(r"[A-Z]", lambda match: "_" + match[0].lower(), key), config[key])
|
|
115
195
|
aliases = {
|
|
116
196
|
"subagents": "tools",
|
|
117
197
|
"modelModule": "model",
|
|
118
|
-
"
|
|
119
|
-
"memoryStores": "memory_store",
|
|
198
|
+
"memoryStores": "memory",
|
|
120
199
|
"interventionModules": "interventions",
|
|
121
200
|
}
|
|
122
201
|
keys = {aliases.get(key, re.sub(r"[A-Z]", lambda match: "_" + match[0].lower(), key)) for key in partial}
|
|
123
202
|
keys.update(partial.get("agentConfig", {}))
|
|
124
203
|
keys.update(partial.get("agentConfigModules", {}))
|
|
204
|
+
for key, empty in {"tools": [], "plugins": [], "mcp_servers": {}, "interventions": None, "sandbox": None}.items():
|
|
205
|
+
if key in keys:
|
|
206
|
+
options.setdefault(key, empty)
|
|
207
|
+
paths = [assignment.split("=", 1)[0] for assignment in assignments]
|
|
208
|
+
for field in partial:
|
|
209
|
+
if field in aliases or field == "agentConfigModules":
|
|
210
|
+
continue
|
|
211
|
+
fields = partial[field] if field == "agentConfig" else [field]
|
|
212
|
+
for name in fields:
|
|
213
|
+
path = f"agentConfig.{name}" if field == "agentConfig" else name
|
|
214
|
+
key = name if field == "agentConfig" else re.sub(r"[A-Z]", lambda match: "_" + match[0].lower(), name)
|
|
215
|
+
if key in partial.get("agentConfigModules", {}) or any(
|
|
216
|
+
alias in partial and option == key for alias, option in aliases.items()
|
|
217
|
+
):
|
|
218
|
+
continue
|
|
219
|
+
if not any(assigned.startswith(path + ".") for assigned in paths):
|
|
220
|
+
continue
|
|
221
|
+
value = authored.get(key)
|
|
222
|
+
if key == "mcp_servers" and isinstance(value, str):
|
|
223
|
+
with open(value) as source:
|
|
224
|
+
document = json.load(source)
|
|
225
|
+
value = document.get("mcpServers", document)
|
|
226
|
+
options[key] = merge_assigned_option(value, options.get(key), paths, path)
|
|
125
227
|
return {
|
|
126
228
|
key: options[key]
|
|
127
229
|
for key in keys
|
|
@@ -172,71 +274,117 @@ def display_messages(agent):
|
|
|
172
274
|
return messages
|
|
173
275
|
|
|
174
276
|
|
|
175
|
-
def
|
|
277
|
+
def local_storage_paths(storage):
|
|
176
278
|
parts = []
|
|
177
|
-
while
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
279
|
+
while isinstance(storage, getattr(storage_types, "_NamespacedStorage", ())):
|
|
280
|
+
prefix = getattr(storage, "_prefix", None)
|
|
281
|
+
if not isinstance(prefix, str):
|
|
282
|
+
return None
|
|
283
|
+
parts.insert(0, prefix)
|
|
284
|
+
storage = getattr(storage, "_storage", None)
|
|
285
|
+
if isinstance(storage, LocalFileStorage):
|
|
286
|
+
directory = getattr(storage, "base_dir", None)
|
|
287
|
+
elif isinstance(storage, offloader_storage.FileStorage):
|
|
288
|
+
directory = getattr(storage, "_artifact_dir", None)
|
|
289
|
+
elif isinstance(storage, (InMemoryStorage, S3Storage, offloader_storage.InMemoryStorage, offloader_storage.S3Storage)):
|
|
290
|
+
return []
|
|
291
|
+
else:
|
|
181
292
|
return None
|
|
182
|
-
|
|
293
|
+
if not isinstance(directory, (str, os.PathLike)):
|
|
294
|
+
return None
|
|
295
|
+
return [str(Path(os.fsdecode(directory), *parts).resolve())]
|
|
183
296
|
|
|
184
297
|
|
|
185
298
|
def agent_stash(agent):
|
|
186
299
|
return getattr(getattr(agent, "context_manager", None), "stash", None)
|
|
187
300
|
|
|
188
301
|
|
|
189
|
-
def
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
302
|
+
def agent_private_paths(agent):
|
|
303
|
+
"""None disables export and watching when private storage cannot be identified."""
|
|
304
|
+
paths = []
|
|
305
|
+
storages = []
|
|
306
|
+
manager = getattr(agent, "_session_manager", None)
|
|
307
|
+
if isinstance(manager, SnapshotSessionManager):
|
|
308
|
+
storages.append(getattr(manager, "_storage", None))
|
|
309
|
+
elif isinstance(manager, FileSessionManager):
|
|
310
|
+
directory = getattr(manager, "storage_dir", None)
|
|
311
|
+
if not isinstance(directory, (str, os.PathLike)):
|
|
312
|
+
return None
|
|
313
|
+
paths.append(str(Path(os.fsdecode(directory)).resolve()))
|
|
314
|
+
elif manager is not None and not isinstance(manager, S3SessionManager):
|
|
194
315
|
return None
|
|
195
|
-
# The namespace's first segment holds every session's stash, not just this agent's.
|
|
196
|
-
return str(Path(base_directory, namespace.split("/")[0]))
|
|
197
316
|
|
|
317
|
+
stash = agent_stash(agent)
|
|
318
|
+
if stash is not None:
|
|
319
|
+
base_storage = getattr(stash, "_base_storage", None)
|
|
320
|
+
storage = getattr(stash, "_storage", None)
|
|
321
|
+
base_paths = local_storage_paths(base_storage)
|
|
322
|
+
if base_paths is None or local_storage_paths(storage) is None:
|
|
323
|
+
return None
|
|
324
|
+
if storage is base_storage:
|
|
325
|
+
paths.extend(base_paths)
|
|
326
|
+
elif isinstance(storage, getattr(storage_types, "_NamespacedStorage", ())):
|
|
327
|
+
namespace = getattr(storage, "_prefix", None)
|
|
328
|
+
if not isinstance(namespace, str) or not namespace:
|
|
329
|
+
return None
|
|
330
|
+
# Exclude every session's stash, not just this agent's.
|
|
331
|
+
paths.extend(str(Path(path, namespace.split("/")[0])) for path in base_paths)
|
|
332
|
+
else:
|
|
333
|
+
return None
|
|
198
334
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
335
|
+
plugins = getattr(getattr(agent, "_plugin_registry", None), "_plugins", None)
|
|
336
|
+
if not isinstance(plugins, dict):
|
|
337
|
+
return None
|
|
338
|
+
storages.extend(getattr(plugin, "_storage", None) for plugin in plugins.values() if isinstance(plugin, ContextOffloader))
|
|
339
|
+
memory = getattr(agent, "memory_manager", None)
|
|
340
|
+
if memory is not None:
|
|
341
|
+
stores = getattr(memory, "_stores", None)
|
|
342
|
+
if not isinstance(stores, (list, tuple)):
|
|
343
|
+
return None
|
|
344
|
+
for store in stores:
|
|
345
|
+
if isinstance(store, FileMemoryStore):
|
|
346
|
+
storages.append(getattr(store, "_storage", None))
|
|
347
|
+
else:
|
|
348
|
+
try:
|
|
349
|
+
from strands.vended_memory_stores.bedrock_knowledge_base import BedrockKnowledgeBaseStore
|
|
350
|
+
except ImportError:
|
|
351
|
+
return None
|
|
352
|
+
if not isinstance(store, BedrockKnowledgeBaseStore):
|
|
353
|
+
return None
|
|
354
|
+
for storage in storages:
|
|
355
|
+
local = local_storage_paths(storage)
|
|
356
|
+
if local is None:
|
|
357
|
+
return None
|
|
358
|
+
paths.extend(local)
|
|
359
|
+
return list(dict.fromkeys(paths))
|
|
207
360
|
|
|
208
361
|
|
|
209
362
|
class Runtime:
|
|
210
363
|
def __init__(self, module, command):
|
|
211
364
|
self.module = module
|
|
212
365
|
partial = command.get("overrides", {})
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
for key in keys[1:-1]:
|
|
228
|
-
if not isinstance(target.get(key), dict):
|
|
229
|
-
target[key] = {}
|
|
230
|
-
target = target[key]
|
|
231
|
-
target[keys[-1]] = value
|
|
232
|
-
self.options = overrides_from_config(partial)
|
|
233
|
-
for source, target in (("sessionId", "session_id"), ("sessionDir", "session_dir")):
|
|
234
|
-
if source in command:
|
|
235
|
-
self.options[target] = command[source]
|
|
366
|
+
authored = getattr(module, "_strands_options", {})
|
|
367
|
+
self.options = overrides_from_config(partial, authored, command.get("assignments", []))
|
|
368
|
+
flags = command.get("configFlags", {})
|
|
369
|
+
for key in ("session", "memory"):
|
|
370
|
+
if flags.get(key) == "off":
|
|
371
|
+
self.options[key] = False
|
|
372
|
+
elif flags.get(key) == "on":
|
|
373
|
+
value = self.options.get(key, authored.get(key))
|
|
374
|
+
self.options[key] = True if value is None or value is False else value
|
|
375
|
+
elif flags.get(key) is not None:
|
|
376
|
+
raise ValueError(f"--{key} must be 'on' or 'off'.")
|
|
377
|
+
session = self.options.get("session", authored.get("session", True))
|
|
378
|
+
if flags.get("sessionId") is not None and (session is True or isinstance(session, dict)):
|
|
379
|
+
self.options["session"] = {**(session if isinstance(session, dict) else {}), "id": flags["sessionId"]}
|
|
236
380
|
self.explicit_option_keys = set(self.options)
|
|
237
|
-
model = self.options.get("model")
|
|
381
|
+
model = self.options.get("model", authored.get("model"))
|
|
382
|
+
if model is None and hasattr(module, "_strands_options"):
|
|
383
|
+
model = DEFAULT_MODEL
|
|
238
384
|
self.source_configuration = (
|
|
239
|
-
{"model": model, "thinking": self.options.get("effort", "auto")}
|
|
385
|
+
{"model": model, "thinking": self.options.get("effort", authored.get("effort", "auto"))}
|
|
386
|
+
if isinstance(model, str)
|
|
387
|
+
else None
|
|
240
388
|
)
|
|
241
389
|
selection = command.get("sourceSelection")
|
|
242
390
|
if (
|
|
@@ -245,49 +393,75 @@ class Runtime:
|
|
|
245
393
|
and selection["source"] == module.__file__
|
|
246
394
|
and selection["configured"] == self.source_configuration
|
|
247
395
|
):
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
396
|
+
for field, option in (("model", "model"), ("thinking", "effort")):
|
|
397
|
+
if selection["selected"][field] != self.source_configuration[field]:
|
|
398
|
+
self.options[option] = selection["selected"][field]
|
|
399
|
+
self.explicit_option_keys.add(option)
|
|
400
|
+
session = self.options.get("session", authored.get("session", True))
|
|
401
|
+
session_options = session if isinstance(session, dict) else {}
|
|
252
402
|
self.session_configuration = {
|
|
253
|
-
"sessionId":
|
|
254
|
-
"sessionDir": str(
|
|
403
|
+
"sessionId": session_options.get("id"),
|
|
404
|
+
"sessionDir": str(session_options.get("dir", ".agent/sessions")),
|
|
255
405
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
406
|
+
restoration = command.get("restoreSession")
|
|
407
|
+
if restoration and (session is True or isinstance(session, dict)):
|
|
408
|
+
identity = restoration["identity"]
|
|
409
|
+
if restoration["preserve"] or identity["configured"] == self.session_configuration:
|
|
410
|
+
session_options = {
|
|
411
|
+
"id": identity["sessionId"],
|
|
412
|
+
"dir": str(Path(identity["sessionDirectory"]).parent),
|
|
413
|
+
}
|
|
414
|
+
self.options["session"] = session_options
|
|
415
|
+
self.explicit_option_keys.add("session")
|
|
416
|
+
if "sessionId" in command and (session is True or isinstance(session, dict)):
|
|
417
|
+
self.options["session"] = {
|
|
418
|
+
**session_options,
|
|
419
|
+
"id": command["sessionId"],
|
|
420
|
+
**(
|
|
421
|
+
{"dir": str(Path(command["sessionStorageDirectory"]).parent)}
|
|
422
|
+
if "sessionStorageDirectory" in command
|
|
423
|
+
else {}
|
|
424
|
+
),
|
|
425
|
+
**({"dir": str(Path(command["sessionDir"]).parent)} if "sessionDir" in command else {}),
|
|
426
|
+
}
|
|
427
|
+
self.explicit_option_keys.add("session")
|
|
263
428
|
self.agent: Agent
|
|
264
429
|
self.initial_agent = module.agent
|
|
265
430
|
self.factory = getattr(module, "create_agent", None)
|
|
266
431
|
self.interactive = command.get("interactive", False)
|
|
267
432
|
self.mcp_servers = command.get("mcpServers", {})
|
|
268
|
-
self.skill_paths = command.get("skillPaths", [])
|
|
433
|
+
self.skill_paths = command.get("skillPaths", []) if self.options.get("skills", authored.get("skills", True)) else []
|
|
269
434
|
self.cancel_signal = threading.Event()
|
|
270
435
|
self.reload_requested = False
|
|
436
|
+
self.context_estimates = None
|
|
437
|
+
self.context_usage = None
|
|
271
438
|
|
|
272
|
-
async def build(self, options, snapshot=None):
|
|
439
|
+
async def build(self, options, snapshot=None, *, resume=False):
|
|
273
440
|
previous = getattr(self, "agent", self.initial_agent)
|
|
274
441
|
factory_options = {key: options[key] for key in self.explicit_option_keys if key in options}
|
|
275
442
|
if self.initial_agent is not None and not factory_options:
|
|
276
443
|
candidate = self.initial_agent
|
|
277
444
|
self.initial_agent = None
|
|
278
445
|
else:
|
|
279
|
-
self.initial_agent = None
|
|
280
446
|
if not callable(self.factory):
|
|
281
447
|
raise ValueError(
|
|
282
448
|
"This source exports an agent instance but not create_agent(**overrides), "
|
|
283
449
|
"and is not a direct agent = create_harness(...) definition; recreation controls are unavailable."
|
|
284
450
|
)
|
|
451
|
+
manager = getattr(previous, "memory_manager", None)
|
|
452
|
+
if manager:
|
|
453
|
+
await manager.flush()
|
|
454
|
+
self.initial_agent = None
|
|
285
455
|
candidate = self.factory(**factory_options)
|
|
286
456
|
if inspect.isawaitable(candidate):
|
|
287
457
|
candidate = await candidate
|
|
288
458
|
if not isinstance(candidate, Agent):
|
|
289
459
|
raise TypeError("create_harness() must return a Strands Agent")
|
|
290
460
|
try:
|
|
461
|
+
if resume:
|
|
462
|
+
manager = candidate._session_manager
|
|
463
|
+
if not isinstance(manager, SnapshotSessionManager) or not await manager.restore_snapshot(candidate):
|
|
464
|
+
raise ValueError("No saved Python session was found for this agent.")
|
|
291
465
|
await self.augment(candidate)
|
|
292
466
|
if snapshot:
|
|
293
467
|
candidate.load_snapshot(snapshot)
|
|
@@ -323,10 +497,68 @@ class Runtime:
|
|
|
323
497
|
None,
|
|
324
498
|
)
|
|
325
499
|
if skills:
|
|
326
|
-
|
|
500
|
+
authored_skills = {skill.name: skill for skill in skills.get_available_skills(agent)}
|
|
501
|
+
skills.set_available_skills([*authored_skills.values(), *self.skill_paths])
|
|
327
502
|
await skills.init_agent(agent)
|
|
503
|
+
# Merge resolved skills: the SDK loads filesystem paths after Skill instances.
|
|
504
|
+
skills.set_available_skills(
|
|
505
|
+
[authored_skills.get(skill.name, skill) for skill in skills.get_available_skills(agent)]
|
|
506
|
+
)
|
|
328
507
|
else:
|
|
329
508
|
agent._plugin_registry.add_and_init(AgentSkills(skills=self.skill_paths))
|
|
509
|
+
self.attach_context_capture(agent)
|
|
510
|
+
|
|
511
|
+
def attach_context_capture(self, agent):
|
|
512
|
+
# Python exposes effective model requests only through the optional middleware registry.
|
|
513
|
+
try:
|
|
514
|
+
from strands.middleware import InvokeModelStage
|
|
515
|
+
except ImportError:
|
|
516
|
+
try:
|
|
517
|
+
from strands._middleware import InvokeModelStage
|
|
518
|
+
except ImportError:
|
|
519
|
+
return
|
|
520
|
+
registry = getattr(agent, "_middleware_registry", None)
|
|
521
|
+
add_middleware = getattr(agent, "add_middleware", None) or getattr(registry, "add_middleware", None)
|
|
522
|
+
handlers_by_stage = getattr(registry, "_handlers", None)
|
|
523
|
+
if not callable(add_middleware) or not isinstance(handlers_by_stage, dict):
|
|
524
|
+
return
|
|
525
|
+
capture_ready = False
|
|
526
|
+
|
|
527
|
+
def prepare(event):
|
|
528
|
+
nonlocal capture_ready
|
|
529
|
+
if event.agent is not agent:
|
|
530
|
+
return
|
|
531
|
+
self.context_estimates = None
|
|
532
|
+
self.context_usage = None
|
|
533
|
+
capture_ready = False
|
|
534
|
+
handlers = handlers_by_stage.get(InvokeModelStage)
|
|
535
|
+
if not isinstance(handlers, list):
|
|
536
|
+
return
|
|
537
|
+
# Hooks can register request transforms, so observe after every other Wrap handler.
|
|
538
|
+
for index, handler in enumerate(handlers):
|
|
539
|
+
if getattr(handler, "handler", None) is capture:
|
|
540
|
+
handlers.append(handlers.pop(index))
|
|
541
|
+
capture_ready = True
|
|
542
|
+
break
|
|
543
|
+
|
|
544
|
+
async def capture(context, next_handler):
|
|
545
|
+
estimates = None
|
|
546
|
+
if context.agent is agent:
|
|
547
|
+
self.context_estimates = None
|
|
548
|
+
self.context_usage = None
|
|
549
|
+
if capture_ready:
|
|
550
|
+
with contextlib.suppress(Exception):
|
|
551
|
+
handlers = handlers_by_stage.get(InvokeModelStage)
|
|
552
|
+
if isinstance(handlers, list) and getattr(handlers[-1], "handler", None) is capture:
|
|
553
|
+
estimates = await estimate_context_categories(context)
|
|
554
|
+
async for event in next_handler(context):
|
|
555
|
+
if context.agent is agent and "stop" in event:
|
|
556
|
+
self.context_usage = context_model_usage(event["stop"][2])
|
|
557
|
+
self.context_estimates = estimates if self.context_usage is not None else None
|
|
558
|
+
yield event
|
|
559
|
+
|
|
560
|
+
add_middleware(InvokeModelStage, capture)
|
|
561
|
+
agent.hooks.add_callback(BeforeModelCallEvent, prepare, order=HookOrder.SDK_LAST)
|
|
330
562
|
|
|
331
563
|
def configuration_tool(self):
|
|
332
564
|
runtime = self
|
|
@@ -354,15 +586,15 @@ class Runtime:
|
|
|
354
586
|
if revision != 0:
|
|
355
587
|
raise ValueError("Inspect the source before applying it, then pass revision 0.")
|
|
356
588
|
runtime.reload_requested = True
|
|
357
|
-
return
|
|
589
|
+
return (
|
|
590
|
+
"Source reload requested. Reload pending until this turn finishes; the conversation will be preserved."
|
|
591
|
+
)
|
|
358
592
|
|
|
359
593
|
return strands_config
|
|
360
594
|
|
|
361
595
|
async def cleanup(self, agent):
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
with contextlib.suppress(Exception):
|
|
365
|
-
await manager.flush()
|
|
596
|
+
with contextlib.suppress(Exception):
|
|
597
|
+
await agent.shutdown_async()
|
|
366
598
|
with contextlib.suppress(Exception):
|
|
367
599
|
agent.cleanup()
|
|
368
600
|
|
|
@@ -380,15 +612,19 @@ class Runtime:
|
|
|
380
612
|
|
|
381
613
|
def state(self):
|
|
382
614
|
model = self.options.get("model")
|
|
615
|
+
model_specifier = self.options.get(
|
|
616
|
+
"model", self.source_configuration["model"] if self.source_configuration else None
|
|
617
|
+
)
|
|
618
|
+
thinking = self.options.get(
|
|
619
|
+
"effort", self.source_configuration["thinking"] if self.source_configuration else "auto"
|
|
620
|
+
)
|
|
383
621
|
if not isinstance(model, str):
|
|
384
622
|
model = str(self.agent.model.get_config().get("model_id", type(self.agent.model).__name__))
|
|
385
623
|
manager = self.agent._session_manager
|
|
386
|
-
session_id = (
|
|
387
|
-
|
|
388
|
-
)
|
|
389
|
-
|
|
390
|
-
session_directory = local_session_directory(storage)
|
|
391
|
-
stash_directory = local_stash_directory(self.agent)
|
|
624
|
+
session_id = manager.session_id if isinstance(manager, SnapshotSessionManager) else None
|
|
625
|
+
storage = getattr(manager, "_storage", None) if isinstance(manager, SnapshotSessionManager) else None
|
|
626
|
+
session_paths = local_storage_paths(storage)
|
|
627
|
+
session_directory = session_paths[0] if session_paths else None
|
|
392
628
|
managed_session = session_directory is not None
|
|
393
629
|
skills = self.skills()
|
|
394
630
|
active = skills.get_activated_skills(self.agent) if skills else []
|
|
@@ -397,16 +633,16 @@ class Runtime:
|
|
|
397
633
|
"reconstructable": callable(self.factory),
|
|
398
634
|
"description": self.agent.description or "",
|
|
399
635
|
"model": model,
|
|
400
|
-
**({"modelSpecifier":
|
|
401
|
-
"thinking":
|
|
636
|
+
**({"modelSpecifier": model_specifier} if isinstance(model_specifier, str) else {}),
|
|
637
|
+
"thinking": thinking,
|
|
402
638
|
**(
|
|
403
639
|
{
|
|
404
640
|
"sourceSelection": {
|
|
405
641
|
"source": self.module.__file__,
|
|
406
642
|
"configured": self.source_configuration,
|
|
407
643
|
"selected": {
|
|
408
|
-
"model":
|
|
409
|
-
"thinking":
|
|
644
|
+
"model": model_specifier,
|
|
645
|
+
"thinking": thinking,
|
|
410
646
|
},
|
|
411
647
|
}
|
|
412
648
|
}
|
|
@@ -414,7 +650,7 @@ class Runtime:
|
|
|
414
650
|
else {}
|
|
415
651
|
),
|
|
416
652
|
**({"sessionId": session_id} if session_id else {}),
|
|
417
|
-
"sessionDirectory": session_directory or self.
|
|
653
|
+
"sessionDirectory": session_directory or str(Path(self.session_configuration["sessionDir"]).resolve()),
|
|
418
654
|
**(
|
|
419
655
|
{
|
|
420
656
|
"session": {
|
|
@@ -428,12 +664,7 @@ class Runtime:
|
|
|
428
664
|
else {}
|
|
429
665
|
),
|
|
430
666
|
"messages": display_messages(self.agent),
|
|
431
|
-
"privatePaths":
|
|
432
|
-
*([session_directory] if session_directory else []),
|
|
433
|
-
*([stash_directory] if stash_directory else []),
|
|
434
|
-
*local_offloader_directories(self.agent),
|
|
435
|
-
str(Path(self.options.get("memory_dir", ".agent/memory")).resolve()),
|
|
436
|
-
],
|
|
667
|
+
"privatePaths": agent_private_paths(self.agent),
|
|
437
668
|
"tools": [
|
|
438
669
|
{"name": spec["name"], "description": spec.get("description", "")}
|
|
439
670
|
for spec in self.agent.tool_registry.get_all_tool_specs()
|
|
@@ -460,7 +691,7 @@ class Runtime:
|
|
|
460
691
|
self.agent.messages,
|
|
461
692
|
tool_specs=self.agent.tool_registry.get_all_tool_specs(),
|
|
462
693
|
system_prompt=self.agent.system_prompt,
|
|
463
|
-
system_prompt_content=self.agent.
|
|
694
|
+
system_prompt_content=self.agent.system_prompt_content,
|
|
464
695
|
)
|
|
465
696
|
except Exception:
|
|
466
697
|
# The meter stays empty until the next model response reports usage.
|
|
@@ -493,6 +724,8 @@ class Runtime:
|
|
|
493
724
|
async def turn(self, prompt):
|
|
494
725
|
self.cancel_signal.clear()
|
|
495
726
|
self.reload_requested = False
|
|
727
|
+
self.context_estimates = None
|
|
728
|
+
self.context_usage = None
|
|
496
729
|
snapshot = self.agent.take_snapshot(preset="session")
|
|
497
730
|
emitted_tool_results = set()
|
|
498
731
|
try:
|
|
@@ -538,6 +771,16 @@ class Runtime:
|
|
|
538
771
|
"projectedTokens": result.projected_context_size,
|
|
539
772
|
"contextWindow": self.agent.model.context_window_limit,
|
|
540
773
|
}
|
|
774
|
+
invocations = getattr(result.metrics, "agent_invocations", [])
|
|
775
|
+
cycles = getattr(invocations[-1], "cycles", []) if invocations else []
|
|
776
|
+
latest_usage = context_model_usage(getattr(cycles[-1], "usage", None)) if cycles else None
|
|
777
|
+
breakdown = context_breakdown(
|
|
778
|
+
self.context_estimates if self.context_usage == latest_usage else None,
|
|
779
|
+
result.context_size,
|
|
780
|
+
result.projected_context_size,
|
|
781
|
+
)
|
|
782
|
+
if breakdown is not None:
|
|
783
|
+
context["breakdown"] = breakdown
|
|
541
784
|
self.result(
|
|
542
785
|
{
|
|
543
786
|
"stopReason": result.stop_reason,
|
|
@@ -591,7 +834,7 @@ class Runtime:
|
|
|
591
834
|
async def command(self, command):
|
|
592
835
|
kind = command["type"]
|
|
593
836
|
if kind == "conversation":
|
|
594
|
-
from strands.types
|
|
837
|
+
from strands.types import Snapshot
|
|
595
838
|
|
|
596
839
|
snapshot = command.get("snapshot")
|
|
597
840
|
if snapshot:
|
|
@@ -606,6 +849,9 @@ class Runtime:
|
|
|
606
849
|
await self.save()
|
|
607
850
|
self.result({"stopReason": "restored"})
|
|
608
851
|
else:
|
|
852
|
+
manager = getattr(self.agent, "memory_manager", None)
|
|
853
|
+
if manager:
|
|
854
|
+
await manager.flush()
|
|
609
855
|
snapshot = self.agent.take_snapshot(include=["messages", "state", "conversation_manager_state"])
|
|
610
856
|
self.result(
|
|
611
857
|
{
|
|
@@ -648,7 +894,7 @@ class Runtime:
|
|
|
648
894
|
entries = await stash.take_snapshot() if stash is not None else {}
|
|
649
895
|
self.result({"stopReason": "stash", "finalText": json.dumps(entries, default=encode)})
|
|
650
896
|
elif kind == "seed":
|
|
651
|
-
from strands.types
|
|
897
|
+
from strands.types import Snapshot
|
|
652
898
|
|
|
653
899
|
self.agent.load_snapshot(Snapshot.from_dict(json.loads(command["snapshot"], object_hook=decode)))
|
|
654
900
|
stash = agent_stash(self.agent)
|
|
@@ -666,9 +912,10 @@ class Runtime:
|
|
|
666
912
|
if "thinking" in command:
|
|
667
913
|
options["effort"] = command["thinking"]
|
|
668
914
|
self.explicit_option_keys.add("effort")
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
915
|
+
session = options.get("session", getattr(self.module, "_strands_options", {}).get("session", True))
|
|
916
|
+
if "sessionId" in command and (session is True or isinstance(session, dict)):
|
|
917
|
+
options["session"] = {**(session if isinstance(session, dict) else {}), "id": command["sessionId"]}
|
|
918
|
+
self.explicit_option_keys.add("session")
|
|
672
919
|
snapshot = None if command.get("clear") else self.agent.take_snapshot(preset="session")
|
|
673
920
|
await self.build(options, snapshot)
|
|
674
921
|
self.result({"stopReason": "reset"})
|
|
@@ -682,7 +929,7 @@ class Runtime:
|
|
|
682
929
|
skills = self.skills()
|
|
683
930
|
if not skills:
|
|
684
931
|
raise ValueError("This agent has no skills")
|
|
685
|
-
await skills.skills(
|
|
932
|
+
content = await skills.skills(
|
|
686
933
|
skill_name=command["name"],
|
|
687
934
|
tool_context=ToolContext(
|
|
688
935
|
tool_use={"toolUseId": str(uuid4()), "name": "skills", "input": {}},
|
|
@@ -691,7 +938,7 @@ class Runtime:
|
|
|
691
938
|
),
|
|
692
939
|
)
|
|
693
940
|
await self.save()
|
|
694
|
-
self.result({"stopReason": "activated"})
|
|
941
|
+
self.result({"stopReason": "activated", "finalText": content})
|
|
695
942
|
else:
|
|
696
943
|
raise ValueError(f"Unknown terminal command: {kind}")
|
|
697
944
|
|
|
@@ -747,7 +994,8 @@ def load_project(entrypoint, root):
|
|
|
747
994
|
|
|
748
995
|
def capture_create_harness(*args, **options):
|
|
749
996
|
agent = original_create_harness(*args, **options)
|
|
750
|
-
captured
|
|
997
|
+
if captured is not None:
|
|
998
|
+
captured.append((agent, args, options))
|
|
751
999
|
return agent
|
|
752
1000
|
|
|
753
1001
|
strands_harness.create_harness = capture_create_harness
|
|
@@ -766,8 +1014,11 @@ def load_project(entrypoint, root):
|
|
|
766
1014
|
agent = getattr(module, "agent", None)
|
|
767
1015
|
if not isinstance(agent, Agent):
|
|
768
1016
|
raise TypeError('Export a Strands Agent as "agent".')
|
|
1017
|
+
construction = next(((args, options) for candidate, args, options in captured if candidate is agent), None)
|
|
1018
|
+
captured = None
|
|
1019
|
+
if construction is not None:
|
|
1020
|
+
module._strands_options = construction[1]
|
|
769
1021
|
if not callable(getattr(module, "create_agent", None)) and direct_harness_assignment(entrypoint):
|
|
770
|
-
construction = next(((args, options) for candidate, args, options in captured if candidate is agent), None)
|
|
771
1022
|
if construction is not None:
|
|
772
1023
|
args, options = construction
|
|
773
1024
|
|
|
@@ -780,13 +1031,13 @@ def load_project(entrypoint, root):
|
|
|
780
1031
|
|
|
781
1032
|
async def main():
|
|
782
1033
|
module = load_project(Path(sys.argv[1]).resolve(), Path(sys.argv[2]).resolve())
|
|
783
|
-
command = json.loads(await asyncio.to_thread(
|
|
1034
|
+
command = json.loads(await asyncio.to_thread(commands.readline))
|
|
784
1035
|
runtime = Runtime(module, command)
|
|
785
|
-
await runtime.build(runtime.options)
|
|
1036
|
+
await runtime.build(runtime.options, resume=command.get("resume", False))
|
|
786
1037
|
send({"type": "ready", "state": runtime.state()})
|
|
787
1038
|
running = None
|
|
788
1039
|
try:
|
|
789
|
-
while line := await asyncio.to_thread(
|
|
1040
|
+
while line := await asyncio.to_thread(commands.readline):
|
|
790
1041
|
command = json.loads(line, object_hook=decode)
|
|
791
1042
|
kind = command["type"]
|
|
792
1043
|
if kind == "permission":
|
|
@@ -808,6 +1059,7 @@ async def main():
|
|
|
808
1059
|
await runtime.command(command)
|
|
809
1060
|
except Exception as error:
|
|
810
1061
|
send({"type": "error", "message": str(error)})
|
|
1062
|
+
del command, line
|
|
811
1063
|
finally:
|
|
812
1064
|
if running and not running.done():
|
|
813
1065
|
running.cancel()
|