@strands-agents/cli 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +217 -133
- package/bin/strands.js +1 -5
- package/dist/src/{tui/strands-backend.js → agent/backend.js} +90 -28
- package/dist/src/agent/backend.js.map +1 -0
- package/dist/src/{tui/background/activity.js → agent/background.js} +173 -6
- package/dist/src/agent/background.js.map +1 -0
- package/dist/src/{tui/agent-configuration.js → agent/configuration.js} +62 -105
- package/dist/src/agent/configuration.js.map +1 -0
- package/dist/src/agent/context.js +112 -0
- package/dist/src/agent/context.js.map +1 -0
- package/dist/src/{tui/chat/sdk-projector.js → agent/events.js} +6 -5
- package/dist/src/agent/events.js.map +1 -0
- package/dist/src/{tui/permissions/file-change-preview.js → agent/file-changes.js} +10 -8
- package/dist/src/agent/file-changes.js.map +1 -0
- package/dist/src/agent/mcp.js +436 -0
- package/dist/src/agent/mcp.js.map +1 -0
- package/dist/src/agent/messaging.js +424 -0
- package/dist/src/agent/messaging.js.map +1 -0
- package/dist/src/agent/permission-rules.js +267 -0
- package/dist/src/agent/permission-rules.js.map +1 -0
- package/dist/src/agent/permissions.js +288 -0
- package/dist/src/agent/permissions.js.map +1 -0
- package/dist/src/agent/runtime.js +524 -0
- package/dist/src/agent/runtime.js.map +1 -0
- package/dist/src/{tui/workspace → agent}/sandbox.js +92 -25
- package/dist/src/agent/sandbox.js.map +1 -0
- package/dist/src/{tui/chat → agent}/shell.js +1 -1
- package/dist/src/agent/shell.js.map +1 -0
- package/dist/src/{tui → agent}/skills.js +37 -56
- package/dist/src/agent/skills.js.map +1 -0
- package/dist/src/{tui/builtin-tools.js → agent/tools.js} +2 -3
- package/dist/src/agent/tools.js.map +1 -0
- package/dist/src/agent/types.js.map +1 -0
- package/dist/src/{tui/voice/session.js → agent/voice.js} +221 -224
- package/dist/src/agent/voice.js.map +1 -0
- package/dist/src/{tui/acp/projection.js → cli/acp-events.js} +19 -4
- package/dist/src/cli/acp-events.js.map +1 -0
- package/dist/src/{tui/project/acp.js → cli/acp-python.js} +41 -18
- package/dist/src/cli/acp-python.js.map +1 -0
- package/dist/src/{tui/acp/server.js → cli/acp.js} +149 -46
- package/dist/src/cli/acp.js.map +1 -0
- package/dist/src/cli/arguments.js +8 -3
- package/dist/src/cli/arguments.js.map +1 -1
- package/dist/src/{console.js → cli/console.js} +69 -4
- package/dist/src/cli/console.js.map +1 -0
- package/dist/src/cli/invocation.js +75 -44
- package/dist/src/cli/invocation.js.map +1 -1
- package/dist/src/cli/run.js +66 -38
- package/dist/src/cli/run.js.map +1 -1
- package/dist/src/{tui → cli}/telemetry.js +2 -2
- package/dist/src/{tui → cli}/telemetry.js.map +1 -1
- package/dist/src/cli/update.js +35 -7
- package/dist/src/cli/update.js.map +1 -1
- package/dist/src/{tui/mcp/config.js → config/mcp.js} +25 -35
- package/dist/src/config/mcp.js.map +1 -0
- package/dist/src/{tui → config}/settings.js +78 -130
- package/dist/src/config/settings.js.map +1 -0
- package/dist/src/config/source.js +87 -0
- package/dist/src/config/source.js.map +1 -0
- package/dist/src/{tui/config.js → config/store.js} +178 -49
- package/dist/src/config/store.js.map +1 -0
- package/dist/src/{tui/workspace → config}/trust.js +12 -16
- package/dist/src/config/trust.js.map +1 -0
- package/dist/src/logging.js +3 -4
- package/dist/src/logging.js.map +1 -1
- package/dist/src/{tui/provider → model}/aws-config.js +13 -4
- package/dist/src/model/aws-config.js.map +1 -0
- package/dist/src/{tui/provider/bedrock-catalog.js → model/bedrock.js} +70 -3
- package/dist/src/model/bedrock.js.map +1 -0
- package/dist/src/{tui/provider → model}/discovery.js +11 -10
- package/dist/src/model/discovery.js.map +1 -0
- package/dist/src/{tui/provider → model}/environment.js +19 -16
- package/dist/src/model/environment.js.map +1 -0
- package/dist/src/{tui/model/display.js → model/metadata.js} +6 -1
- package/dist/src/model/metadata.js.map +1 -0
- package/dist/src/model/packages.js.map +1 -0
- package/dist/src/{tui/model → model}/runtime.js +31 -62
- package/dist/src/model/runtime.js.map +1 -0
- package/dist/src/{tui/model → model}/selection.js +9 -15
- package/dist/src/model/selection.js.map +1 -0
- package/dist/src/{tui/package-version.js → package-version.js} +6 -0
- package/dist/src/package-version.js.map +1 -0
- package/dist/src/paths.js +23 -0
- package/dist/src/paths.js.map +1 -0
- package/dist/src/project/archive.js +461 -0
- package/dist/src/project/archive.js.map +1 -0
- package/dist/src/{tui/project → project}/export.js +249 -72
- package/dist/src/project/export.js.map +1 -0
- package/dist/src/{tui/project → project}/import.js +58 -6
- package/dist/src/project/import.js.map +1 -0
- package/dist/src/{tui/project → project}/module-loader.js +1 -5
- package/dist/src/project/module-loader.js.map +1 -0
- package/dist/src/{tui/project → project}/packaging.js +25 -8
- package/dist/src/project/packaging.js.map +1 -0
- package/dist/src/project/portability.js +455 -0
- package/dist/src/project/portability.js.map +1 -0
- package/dist/src/{tui/project → project}/python.js +46 -31
- package/dist/src/project/python.js.map +1 -0
- package/dist/src/{tui/project → project}/source.js +45 -26
- package/dist/src/project/source.js.map +1 -0
- package/dist/src/project/typescript-backend.js +733 -0
- package/dist/src/project/typescript-backend.js.map +1 -0
- package/dist/src/project/typescript-worker.js +488 -0
- package/dist/src/project/typescript-worker.js.map +1 -0
- package/dist/src/{tui/project → project}/typescript.js +19 -7
- package/dist/src/project/typescript.js.map +1 -0
- package/dist/src/project/watch.js +33 -0
- package/dist/src/project/watch.js.map +1 -0
- package/dist/src/{tui/project → project}/worker.py +358 -106
- package/dist/src/session/agent-definition.js +35 -0
- package/dist/src/session/agent-definition.js.map +1 -0
- package/dist/src/session/catalog.js +156 -0
- package/dist/src/session/catalog.js.map +1 -0
- package/dist/src/{tui/session → session}/context.js +45 -5
- package/dist/src/session/context.js.map +1 -0
- package/dist/src/{tui/session → session}/desktop-profile.js +1 -0
- package/dist/src/session/desktop-profile.js.map +1 -0
- package/dist/src/{tui/session → session}/sessions.js +126 -27
- package/dist/src/session/sessions.js.map +1 -0
- package/dist/src/terminal/arguments.js +53 -0
- package/dist/src/terminal/arguments.js.map +1 -0
- package/dist/src/{tui/terminal → terminal}/composer.js +51 -24
- package/dist/src/terminal/composer.js.map +1 -0
- package/dist/src/terminal/directory-picker.js +182 -0
- package/dist/src/terminal/directory-picker.js.map +1 -0
- package/dist/src/terminal/ink.js.map +1 -0
- package/dist/src/terminal/mouse-input.js.map +1 -0
- package/dist/src/terminal/npm.js.map +1 -0
- package/dist/src/terminal/open-editor.js +40 -0
- package/dist/src/terminal/open-editor.js.map +1 -0
- package/dist/src/terminal/open-url.js +26 -0
- package/dist/src/terminal/open-url.js.map +1 -0
- package/dist/src/terminal/process-tree.js.map +1 -0
- package/dist/src/terminal/shell-output.js.map +1 -0
- package/dist/src/{tui/terminal → terminal}/terminal.js +40 -2
- package/dist/src/terminal/terminal.js.map +1 -0
- package/dist/src/{tui/terminal/sanitize.js → terminal/text.js} +40 -6
- package/dist/src/terminal/text.js.map +1 -0
- package/dist/src/terminal/theme-detection.js +197 -0
- package/dist/src/terminal/theme-detection.js.map +1 -0
- package/dist/src/{tui/view/fade-in.js → ui/animation.js} +26 -1
- package/dist/src/ui/animation.js.map +1 -0
- package/dist/src/ui/app.js +176 -0
- package/dist/src/ui/app.js.map +1 -0
- package/dist/src/ui/chat/attachments.js +135 -0
- package/dist/src/ui/chat/attachments.js.map +1 -0
- package/dist/src/{tui → ui}/chat/commands.js +55 -7
- package/dist/src/ui/chat/commands.js.map +1 -0
- package/dist/src/{tui → ui}/chat/controller.js +1176 -345
- package/dist/src/ui/chat/controller.js.map +1 -0
- package/dist/src/ui/chat/conversations.js +692 -0
- package/dist/src/ui/chat/conversations.js.map +1 -0
- package/dist/src/{tui → ui}/chat/help.js +11 -5
- package/dist/src/ui/chat/help.js.map +1 -0
- package/dist/src/ui/chat/panel-state.js +513 -0
- package/dist/src/ui/chat/panel-state.js.map +1 -0
- package/dist/src/{tui → ui}/chat/projector.js +93 -8
- package/dist/src/ui/chat/projector.js.map +1 -0
- package/dist/src/ui/chat/prompt.js +176 -0
- package/dist/src/ui/chat/prompt.js.map +1 -0
- package/dist/src/ui/chat/runtime.js +589 -0
- package/dist/src/ui/chat/runtime.js.map +1 -0
- package/dist/src/ui/chat/screen.js +1907 -0
- package/dist/src/ui/chat/screen.js.map +1 -0
- package/dist/src/{tui/chat/controller-helpers.js → ui/chat/state.js} +39 -3
- package/dist/src/ui/chat/state.js.map +1 -0
- package/dist/src/ui/chat/stream-presentation.js.map +1 -0
- package/dist/src/ui/chat/transcript-turn.js +189 -0
- package/dist/src/ui/chat/transcript-turn.js.map +1 -0
- package/dist/src/{tui/view → ui/chat}/transcript.js +66 -6
- package/dist/src/ui/chat/transcript.js.map +1 -0
- package/dist/src/ui/chat/types.js +2 -0
- package/dist/src/ui/chat/types.js.map +1 -0
- package/dist/src/ui/chat/view.js +249 -0
- package/dist/src/ui/chat/view.js.map +1 -0
- package/dist/src/ui/chat/voice.js +388 -0
- package/dist/src/ui/chat/voice.js.map +1 -0
- package/dist/src/ui/footer.js +110 -0
- package/dist/src/ui/footer.js.map +1 -0
- package/dist/src/{tui/view → ui}/frog-canvas.js +47 -50
- package/dist/src/ui/frog-canvas.js.map +1 -0
- package/dist/src/{tui/view → ui}/frog-drawing.js +36 -29
- package/dist/src/ui/frog-drawing.js.map +1 -0
- package/dist/src/{tui/view/frog-intro-renderer.js → ui/frog-renderer.js} +63 -46
- package/dist/src/ui/frog-renderer.js.map +1 -0
- package/dist/src/{tui/view/frog-easter-egg.js → ui/frog.js} +34 -6
- package/dist/src/ui/frog.js.map +1 -0
- package/dist/src/ui/interaction.js +525 -0
- package/dist/src/ui/interaction.js.map +1 -0
- package/dist/src/{tui/view → ui}/markdown.js +12 -9
- package/dist/src/ui/markdown.js.map +1 -0
- package/dist/src/ui/mcp-diagnostics.js +56 -0
- package/dist/src/ui/mcp-diagnostics.js.map +1 -0
- package/dist/src/ui/media.js +59 -0
- package/dist/src/ui/media.js.map +1 -0
- package/dist/src/ui/panels/agents.js +97 -0
- package/dist/src/ui/panels/agents.js.map +1 -0
- package/dist/src/ui/panels/configuration.js +201 -0
- package/dist/src/ui/panels/configuration.js.map +1 -0
- package/dist/src/ui/panels/context.js +102 -0
- package/dist/src/ui/panels/context.js.map +1 -0
- package/dist/src/ui/panels/export.js +17 -0
- package/dist/src/ui/panels/export.js.map +1 -0
- package/dist/src/ui/panels/help.js +22 -0
- package/dist/src/ui/panels/help.js.map +1 -0
- package/dist/src/ui/panels/models.js +180 -0
- package/dist/src/ui/panels/models.js.map +1 -0
- package/dist/src/ui/panels/panel.js +122 -0
- package/dist/src/ui/panels/panel.js.map +1 -0
- package/dist/src/ui/panels/permissions.js +90 -0
- package/dist/src/ui/panels/permissions.js.map +1 -0
- package/dist/src/ui/panels/sessions.js +54 -0
- package/dist/src/ui/panels/sessions.js.map +1 -0
- package/dist/src/ui/panels/settings.js +125 -0
- package/dist/src/ui/panels/settings.js.map +1 -0
- package/dist/src/ui/panels/shared.js +50 -0
- package/dist/src/ui/panels/shared.js.map +1 -0
- package/dist/src/ui/panels/tasks.js +15 -0
- package/dist/src/ui/panels/tasks.js.map +1 -0
- package/dist/src/ui/panels/voice.js +142 -0
- package/dist/src/ui/panels/voice.js.map +1 -0
- package/dist/src/{tui/permissions/settings.js → ui/permission-options.js} +13 -2
- package/dist/src/ui/permission-options.js.map +1 -0
- package/dist/src/{tui/view → ui}/presentation.js +170 -112
- package/dist/src/ui/presentation.js.map +1 -0
- package/dist/src/{tui → ui}/run.js +173 -36
- package/dist/src/ui/run.js.map +1 -0
- package/dist/src/{tui/view/setup-wizard/settings-panel.js → ui/setup/form.js} +6 -6
- package/dist/src/ui/setup/form.js.map +1 -0
- package/dist/src/ui/setup/menu.js +133 -0
- package/dist/src/ui/setup/menu.js.map +1 -0
- package/dist/src/{tui/view/setup-wizard → ui/setup}/providers.js +157 -20
- package/dist/src/ui/setup/providers.js.map +1 -0
- package/dist/src/{tui/view/setup-wizard → ui/setup}/steps.js +193 -147
- package/dist/src/ui/setup/steps.js.map +1 -0
- package/dist/src/ui/setup/wizard.js +2075 -0
- package/dist/src/ui/setup/wizard.js.map +1 -0
- package/dist/src/ui/startup.js +147 -0
- package/dist/src/ui/startup.js.map +1 -0
- package/dist/src/{tui/terminal/size.js → ui/terminal-size.js} +1 -1
- package/dist/src/ui/terminal-size.js.map +1 -0
- package/dist/src/ui/text-input.js +50 -0
- package/dist/src/ui/text-input.js.map +1 -0
- package/dist/src/{tui/view → ui}/theme.js +24 -31
- package/dist/src/ui/theme.js.map +1 -0
- package/dist/src/ui/update.js +126 -0
- package/dist/src/ui/update.js.map +1 -0
- package/dist/src/usage.js +0 -5
- package/dist/src/usage.js.map +1 -1
- package/dist/src/values.js +5 -0
- package/dist/src/values.js.map +1 -0
- package/package.json +16 -8
- package/src/agent/voice-sidecar.py +730 -0
- package/dist/src/console.js.map +0 -1
- package/dist/src/tui/acp/projection.js.map +0 -1
- package/dist/src/tui/acp/server.js.map +0 -1
- package/dist/src/tui/agent-configuration.js.map +0 -1
- package/dist/src/tui/background/activity.js.map +0 -1
- package/dist/src/tui/background/inbox.js +0 -120
- package/dist/src/tui/background/inbox.js.map +0 -1
- package/dist/src/tui/background/tasks.js +0 -98
- package/dist/src/tui/background/tasks.js.map +0 -1
- package/dist/src/tui/builtin-tools.js.map +0 -1
- package/dist/src/tui/chat/commands.js.map +0 -1
- package/dist/src/tui/chat/controller-helpers.js.map +0 -1
- package/dist/src/tui/chat/controller.js.map +0 -1
- package/dist/src/tui/chat/help.js.map +0 -1
- package/dist/src/tui/chat/panels.js +0 -407
- package/dist/src/tui/chat/panels.js.map +0 -1
- package/dist/src/tui/chat/projector.js.map +0 -1
- package/dist/src/tui/chat/sdk-projector.js.map +0 -1
- package/dist/src/tui/chat/shell.js.map +0 -1
- package/dist/src/tui/chat/types.js +0 -2
- package/dist/src/tui/chat/types.js.map +0 -1
- package/dist/src/tui/config.js.map +0 -1
- package/dist/src/tui/configuration-instructions.js +0 -14
- package/dist/src/tui/configuration-instructions.js.map +0 -1
- package/dist/src/tui/mcp/config.js.map +0 -1
- package/dist/src/tui/mcp.js +0 -98
- package/dist/src/tui/mcp.js.map +0 -1
- package/dist/src/tui/memory-options.js +0 -10
- package/dist/src/tui/memory-options.js.map +0 -1
- package/dist/src/tui/messaging.js +0 -193
- package/dist/src/tui/messaging.js.map +0 -1
- package/dist/src/tui/model/context.js +0 -69
- package/dist/src/tui/model/context.js.map +0 -1
- package/dist/src/tui/model/display.js.map +0 -1
- package/dist/src/tui/model/runtime.js.map +0 -1
- package/dist/src/tui/model/selection.js.map +0 -1
- package/dist/src/tui/npm.js.map +0 -1
- package/dist/src/tui/package-version.js.map +0 -1
- package/dist/src/tui/permissions/file-change-preview.js.map +0 -1
- package/dist/src/tui/permissions/policy.js +0 -222
- package/dist/src/tui/permissions/policy.js.map +0 -1
- package/dist/src/tui/permissions/settings.js.map +0 -1
- package/dist/src/tui/project/acp.js.map +0 -1
- package/dist/src/tui/project/archive.js +0 -241
- package/dist/src/tui/project/archive.js.map +0 -1
- package/dist/src/tui/project/configuration-secrets.js +0 -107
- package/dist/src/tui/project/configuration-secrets.js.map +0 -1
- package/dist/src/tui/project/configuration.js +0 -201
- package/dist/src/tui/project/configuration.js.map +0 -1
- package/dist/src/tui/project/export.js.map +0 -1
- package/dist/src/tui/project/import.js.map +0 -1
- package/dist/src/tui/project/module-loader.js.map +0 -1
- package/dist/src/tui/project/packaging.js.map +0 -1
- package/dist/src/tui/project/portable-dependencies.js +0 -34
- package/dist/src/tui/project/portable-dependencies.js.map +0 -1
- package/dist/src/tui/project/portable-mcp.js +0 -118
- package/dist/src/tui/project/portable-mcp.js.map +0 -1
- package/dist/src/tui/project/python.js.map +0 -1
- package/dist/src/tui/project/run.js +0 -116
- package/dist/src/tui/project/run.js.map +0 -1
- package/dist/src/tui/project/source.js.map +0 -1
- package/dist/src/tui/project/typescript.js.map +0 -1
- package/dist/src/tui/provider/aws-client.js +0 -67
- package/dist/src/tui/provider/aws-client.js.map +0 -1
- package/dist/src/tui/provider/aws-config.js.map +0 -1
- package/dist/src/tui/provider/bedrock-catalog.js.map +0 -1
- package/dist/src/tui/provider/discovery.js.map +0 -1
- package/dist/src/tui/provider/environment.js.map +0 -1
- package/dist/src/tui/provider/packages.js.map +0 -1
- package/dist/src/tui/run.js.map +0 -1
- package/dist/src/tui/runtime.js +0 -524
- package/dist/src/tui/runtime.js.map +0 -1
- package/dist/src/tui/session/agent-definition.js +0 -100
- package/dist/src/tui/session/agent-definition.js.map +0 -1
- package/dist/src/tui/session/catalog.js +0 -159
- package/dist/src/tui/session/catalog.js.map +0 -1
- package/dist/src/tui/session/context.js.map +0 -1
- package/dist/src/tui/session/conversation-helpers.js +0 -46
- package/dist/src/tui/session/conversation-helpers.js.map +0 -1
- package/dist/src/tui/session/conversations.js +0 -471
- package/dist/src/tui/session/conversations.js.map +0 -1
- package/dist/src/tui/session/desktop-profile.js.map +0 -1
- package/dist/src/tui/session/options.js +0 -44
- package/dist/src/tui/session/options.js.map +0 -1
- package/dist/src/tui/session/sessions.js.map +0 -1
- package/dist/src/tui/session/voice.js +0 -353
- package/dist/src/tui/session/voice.js.map +0 -1
- package/dist/src/tui/settings.js.map +0 -1
- package/dist/src/tui/skills.js.map +0 -1
- package/dist/src/tui/steering.js +0 -67
- package/dist/src/tui/steering.js.map +0 -1
- package/dist/src/tui/strands-backend.js.map +0 -1
- package/dist/src/tui/stream-presentation.js.map +0 -1
- package/dist/src/tui/terminal/composer.js.map +0 -1
- package/dist/src/tui/terminal/directory-picker.js +0 -76
- package/dist/src/tui/terminal/directory-picker.js.map +0 -1
- package/dist/src/tui/terminal/ink.js.map +0 -1
- package/dist/src/tui/terminal/mouse-input.js.map +0 -1
- package/dist/src/tui/terminal/open-url.js +0 -21
- package/dist/src/tui/terminal/open-url.js.map +0 -1
- package/dist/src/tui/terminal/process-tree.js.map +0 -1
- package/dist/src/tui/terminal/sanitize.js.map +0 -1
- package/dist/src/tui/terminal/shell-output.js.map +0 -1
- package/dist/src/tui/terminal/size.js.map +0 -1
- package/dist/src/tui/terminal/terminal.js.map +0 -1
- package/dist/src/tui/update-check.js +0 -37
- package/dist/src/tui/update-check.js.map +0 -1
- package/dist/src/tui/view/agents-panel.js +0 -21
- package/dist/src/tui/view/agents-panel.js.map +0 -1
- package/dist/src/tui/view/app.js +0 -1061
- package/dist/src/tui/view/app.js.map +0 -1
- package/dist/src/tui/view/chat-root.js +0 -49
- package/dist/src/tui/view/chat-root.js.map +0 -1
- package/dist/src/tui/view/chat-view.js +0 -145
- package/dist/src/tui/view/chat-view.js.map +0 -1
- package/dist/src/tui/view/command-palette.js +0 -15
- package/dist/src/tui/view/command-palette.js.map +0 -1
- package/dist/src/tui/view/custom-theme-editor.js +0 -301
- package/dist/src/tui/view/custom-theme-editor.js.map +0 -1
- package/dist/src/tui/view/effort-panel.js +0 -15
- package/dist/src/tui/view/effort-panel.js.map +0 -1
- package/dist/src/tui/view/export-panel.js +0 -14
- package/dist/src/tui/view/export-panel.js.map +0 -1
- package/dist/src/tui/view/fade-in.js.map +0 -1
- package/dist/src/tui/view/frog-canvas.js.map +0 -1
- package/dist/src/tui/view/frog-drawing.js.map +0 -1
- package/dist/src/tui/view/frog-easter-egg.js.map +0 -1
- package/dist/src/tui/view/frog-intro-renderer.js.map +0 -1
- package/dist/src/tui/view/help-footer.js +0 -48
- package/dist/src/tui/view/help-footer.js.map +0 -1
- package/dist/src/tui/view/interaction.js +0 -352
- package/dist/src/tui/view/interaction.js.map +0 -1
- package/dist/src/tui/view/markdown.js.map +0 -1
- package/dist/src/tui/view/mcp-trust-prompt.js +0 -17
- package/dist/src/tui/view/mcp-trust-prompt.js.map +0 -1
- package/dist/src/tui/view/media.js +0 -70
- package/dist/src/tui/view/media.js.map +0 -1
- package/dist/src/tui/view/model-panel.js +0 -77
- package/dist/src/tui/view/model-panel.js.map +0 -1
- package/dist/src/tui/view/panel-components.js +0 -17
- package/dist/src/tui/view/panel-components.js.map +0 -1
- package/dist/src/tui/view/panels.js +0 -139
- package/dist/src/tui/view/panels.js.map +0 -1
- package/dist/src/tui/view/presentation.js.map +0 -1
- package/dist/src/tui/view/prompt-editor.js +0 -82
- package/dist/src/tui/view/prompt-editor.js.map +0 -1
- package/dist/src/tui/view/provider-list.js +0 -14
- package/dist/src/tui/view/provider-list.js.map +0 -1
- package/dist/src/tui/view/rename-panel.js +0 -11
- package/dist/src/tui/view/rename-panel.js.map +0 -1
- package/dist/src/tui/view/sessions-panel.js +0 -15
- package/dist/src/tui/view/sessions-panel.js.map +0 -1
- package/dist/src/tui/view/settings-panel.js +0 -146
- package/dist/src/tui/view/settings-panel.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/brand.js +0 -34
- package/dist/src/tui/view/setup-wizard/brand.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/index.js +0 -1638
- package/dist/src/tui/view/setup-wizard/index.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/opening-menu.js +0 -99
- package/dist/src/tui/view/setup-wizard/opening-menu.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/path-completion.js +0 -53
- package/dist/src/tui/view/setup-wizard/path-completion.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/profile-fields.js +0 -29
- package/dist/src/tui/view/setup-wizard/profile-fields.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/progress.js +0 -43
- package/dist/src/tui/view/setup-wizard/progress.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/providers.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/settings-panel.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/steps.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/types.js.map +0 -1
- package/dist/src/tui/view/setup-wizard/use-provider-discovery.js +0 -143
- package/dist/src/tui/view/setup-wizard/use-provider-discovery.js.map +0 -1
- package/dist/src/tui/view/startup-view.js +0 -79
- package/dist/src/tui/view/startup-view.js.map +0 -1
- package/dist/src/tui/view/text-input.js +0 -33
- package/dist/src/tui/view/text-input.js.map +0 -1
- package/dist/src/tui/view/theme-detection.js +0 -45
- package/dist/src/tui/view/theme-detection.js.map +0 -1
- package/dist/src/tui/view/theme.js.map +0 -1
- package/dist/src/tui/view/transcript-layout.js +0 -60
- package/dist/src/tui/view/transcript-layout.js.map +0 -1
- package/dist/src/tui/view/transcript-turn.js +0 -135
- package/dist/src/tui/view/transcript-turn.js.map +0 -1
- package/dist/src/tui/view/transcript.js.map +0 -1
- package/dist/src/tui/view/use-party-frame.js +0 -15
- package/dist/src/tui/view/use-party-frame.js.map +0 -1
- package/dist/src/tui/view/use-spinner.js +0 -14
- package/dist/src/tui/view/use-spinner.js.map +0 -1
- package/dist/src/tui/voice/session.js.map +0 -1
- package/dist/src/tui/workspace/sandbox.js.map +0 -1
- package/dist/src/tui/workspace/trust.js.map +0 -1
- package/src/tui/voice/sidecar.py +0 -631
- /package/dist/src/{tui/view/setup-wizard → agent}/types.js +0 -0
- /package/dist/src/{tui/provider → model}/packages.js +0 -0
- /package/dist/src/{tui/terminal → terminal}/ink.js +0 -0
- /package/dist/src/{tui/terminal → terminal}/mouse-input.js +0 -0
- /package/dist/src/{tui → terminal}/npm.js +0 -0
- /package/dist/src/{tui/terminal → terminal}/process-tree.js +0 -0
- /package/dist/src/{tui/terminal → terminal}/shell-output.js +0 -0
- /package/dist/src/{tui → ui/chat}/stream-presentation.js +0 -0
|
@@ -0,0 +1,2075 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
3
|
+
import { Box, useInput, useStdout } from 'ink';
|
|
4
|
+
import { useTerminalSize } from '../terminal-size.js';
|
|
5
|
+
import { DEFAULT_HARNESS_AGENT_CONFIG, supportsWebSearch } from '@strands-agents/harness';
|
|
6
|
+
import stringWidth from 'string-width';
|
|
7
|
+
import { PROVIDER_CREDENTIAL_KEYS, PROVIDER_ENVIRONMENT_KEYS, PROVIDER_LABELS, PROVIDER_IDS, } from '../../config/store.js';
|
|
8
|
+
import { importAgentProject, importPathCompletions } from '../../project/import.js';
|
|
9
|
+
import { configurationFromStore } from '../../agent/configuration.js';
|
|
10
|
+
import { DEFAULT_SETTINGS_CATEGORY, SETTINGS_CATEGORIES } from '../../config/settings.js';
|
|
11
|
+
import { parseMouseInput } from '../../terminal/mouse-input.js';
|
|
12
|
+
import { emptyEditor, reduceInputSequence } from '../../terminal/composer.js';
|
|
13
|
+
import { errorMessage, graphemes, sanitizeTerminalText, wrapLines } from '../../terminal/text.js';
|
|
14
|
+
import { canUseNativePicker, chooseAgentProject, chooseDirectory } from '../../terminal/directory-picker.js';
|
|
15
|
+
import { setTerminalMouseMotion } from '../../terminal/terminal.js';
|
|
16
|
+
import { elementAtMouse, elementContainsMouse, registerElement, mouseScrollDirection, scrollPanelViewport, revealPanelSelection, sliderOptionAtMouse, } from '../interaction.js';
|
|
17
|
+
import { Text, ThemeProvider, useTheme } from '../theme.js';
|
|
18
|
+
import { Cursor, EditableText } from '../text-input.js';
|
|
19
|
+
import { Fade, useFadeTransition } from '../animation.js';
|
|
20
|
+
import { compatibleProfile, exaWebSearchActive, providerAssessment, providerFromModel, quickstartDraft, useProviderDiscovery, useProviderDiscoveryEffects, } from './providers.js';
|
|
21
|
+
import { EXA_WEB_SEARCH_WARNING } from '../../agent/tools.js';
|
|
22
|
+
import { memoryForDir, SETTINGS_STEP, appearanceSettings, CUSTOMIZE_STEPS, OPENING_CHOICES, rowsForStep, setupStepProgress, wizardSettingsRows, } from './steps.js';
|
|
23
|
+
import { useBrandAnimation, useBrandAnimationFrame, SetupBrand, setupBrandFrame } from '../startup.js';
|
|
24
|
+
import { OpeningMenu, openingGridLayout, openingNeighbor, SetupProgress } from './menu.js';
|
|
25
|
+
import { SetupSettingsPanel } from './form.js';
|
|
26
|
+
import { EffortSlider } from '../panels/models.js';
|
|
27
|
+
import { ProviderList, PanelSection } from '../panels/shared.js';
|
|
28
|
+
import { availableCliUpdate } from '../../cli/update.js';
|
|
29
|
+
function setupRowSection(flow, step, row) {
|
|
30
|
+
if (step === SETTINGS_STEP)
|
|
31
|
+
return 'settings';
|
|
32
|
+
if (flow === 'import')
|
|
33
|
+
return 'import';
|
|
34
|
+
if (step === 2 || step === 5)
|
|
35
|
+
return 'form';
|
|
36
|
+
if (step === 3 || step === 4)
|
|
37
|
+
return row?.id === 'select-all' ? 'bulk' : 'items';
|
|
38
|
+
if (step === 6)
|
|
39
|
+
return row?.id.startsWith('permission-tool:') ? 'tools' : 'modes';
|
|
40
|
+
return 'list';
|
|
41
|
+
}
|
|
42
|
+
function dataRowHeight(row, stacked) {
|
|
43
|
+
return row.active !== undefined ? 1 : stacked ? 4 : 3;
|
|
44
|
+
}
|
|
45
|
+
function setupRowViewport(heights, selected, availableHeight, previousStart) {
|
|
46
|
+
let start = Math.min(previousStart, selected);
|
|
47
|
+
let end = start;
|
|
48
|
+
let used = 0;
|
|
49
|
+
while (end < heights.length && used + heights[end] <= availableHeight)
|
|
50
|
+
used += heights[end++];
|
|
51
|
+
while (end === heights.length && start > 0 && used + heights[start - 1] <= availableHeight) {
|
|
52
|
+
used += heights[--start];
|
|
53
|
+
}
|
|
54
|
+
if (selected < end)
|
|
55
|
+
return { start, end };
|
|
56
|
+
start = selected;
|
|
57
|
+
end = selected + 1;
|
|
58
|
+
used = heights[selected] ?? 0;
|
|
59
|
+
while (start > 0 && used + heights[start - 1] <= availableHeight)
|
|
60
|
+
used += heights[--start];
|
|
61
|
+
while (end < heights.length && used + heights[end] <= availableHeight)
|
|
62
|
+
used += heights[end++];
|
|
63
|
+
return { start, end };
|
|
64
|
+
}
|
|
65
|
+
const SHORT_PROVIDER_LABELS = {
|
|
66
|
+
...PROVIDER_LABELS,
|
|
67
|
+
bedrock: 'Bedrock',
|
|
68
|
+
'bedrock-mantle': 'Mantle',
|
|
69
|
+
google: 'Gemini',
|
|
70
|
+
};
|
|
71
|
+
export function SetupWizard(props) {
|
|
72
|
+
const [appearance, setAppearance] = useState(() => appearanceSettings({ ...props.config.snapshot().settings, ...props.initialSettings }));
|
|
73
|
+
return (_jsx(ThemeProvider, { settings: appearance, children: _jsx(SetupWizardContent, { ...props, appearance: appearance, setAppearance: setAppearance }) }));
|
|
74
|
+
}
|
|
75
|
+
function SetupWizardContent({ appearance, setAppearance, config, deferred = false, onComplete, onCancel, escapeHint = 'Esc to open chat', introStartedAt, initialSettings, checkForUpdate = availableCliUpdate, }) {
|
|
76
|
+
const { stdout } = useStdout();
|
|
77
|
+
const { columns, rows: terminalRows } = useTerminalSize();
|
|
78
|
+
const [flow, setFlow] = useState();
|
|
79
|
+
const [step, setStep] = useState(0);
|
|
80
|
+
const [settingsReturn, setSettingsReturn] = useState();
|
|
81
|
+
const [settingsCategory, setSettingsCategory] = useState(DEFAULT_SETTINGS_CATEGORY);
|
|
82
|
+
const [settingsFocus, setSettingsFocus] = useState('settings');
|
|
83
|
+
const setupSectionSelections = useRef({});
|
|
84
|
+
const [panelSettings, setPanelSettings] = useState(() => globalThis.structuredClone({ ...config.snapshot().settings, ...initialSettings }));
|
|
85
|
+
const palette = useTheme();
|
|
86
|
+
const panelTransition = useFadeTransition(appearance.animations);
|
|
87
|
+
const [selection, setSelection] = useState(0);
|
|
88
|
+
const rowViewportStart = useRef(0);
|
|
89
|
+
const [hoveredControl, setHoveredControl] = useState();
|
|
90
|
+
const [focusedAction, setFocusedAction] = useState();
|
|
91
|
+
const [draft, setDraft] = useState(() => {
|
|
92
|
+
const snapshot = config.snapshot();
|
|
93
|
+
const settings = { ...snapshot.settings, ...initialSettings };
|
|
94
|
+
return {
|
|
95
|
+
providers: [...snapshot.providers.enabled],
|
|
96
|
+
profile: snapshot.profile,
|
|
97
|
+
permissionMode: snapshot.permissions.mode,
|
|
98
|
+
allowedTools: [...snapshot.permissions.allow],
|
|
99
|
+
customPermissions: snapshot.permissions.mode === 'default' && snapshot.permissions.allow.length > 0,
|
|
100
|
+
settings: {
|
|
101
|
+
mcpDiscovery: settings.mcpDiscovery,
|
|
102
|
+
skillDiscovery: settings.skillDiscovery,
|
|
103
|
+
agentMessaging: settings.agentMessaging,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
const [profileBaseDir] = useState(() => config.snapshot().profileBaseDir);
|
|
108
|
+
const [importPath, setImportPath] = useState('');
|
|
109
|
+
const [editing, setEditing] = useState();
|
|
110
|
+
const [pathCompletionIndex, setPathCompletionIndex] = useState(-1);
|
|
111
|
+
const [error, setError] = useState();
|
|
112
|
+
const [availableUpdate, setAvailableUpdate] = useState();
|
|
113
|
+
const [saving, setSaving] = useState(false);
|
|
114
|
+
const [choosingDirectory, setChoosingDirectory] = useState(false);
|
|
115
|
+
const choosingDirectoryRef = useRef(false);
|
|
116
|
+
const discovery = useProviderDiscovery(config);
|
|
117
|
+
const { detectedEnvironment, providerEnvironment, setProviderEnvironment, awsDiscovery, ollamaDiscovery, liteLlmDiscovery, providerModels, effectiveEnvironment, readyProviders, recheck, } = discovery;
|
|
118
|
+
const [modelViewportStart, setModelViewportStart] = useState(0);
|
|
119
|
+
const [modelQuery, setModelQuery] = useState('');
|
|
120
|
+
const [modelSearchFocused, setModelSearchFocused] = useState(false);
|
|
121
|
+
const [providerDetailSection, setProviderDetailSection] = useState('models');
|
|
122
|
+
const providerSectionSelections = useRef({});
|
|
123
|
+
const previousModelOffset = useRef(undefined);
|
|
124
|
+
const [deselectedModel, setDeselectedModel] = useState();
|
|
125
|
+
const providerListElement = useRef(null);
|
|
126
|
+
const modelListElement = useRef(null);
|
|
127
|
+
const modelSearchElement = useRef(null);
|
|
128
|
+
const modelPreviousElement = useRef(null);
|
|
129
|
+
const modelNextElement = useRef(null);
|
|
130
|
+
const modelSectionElement = useRef(null);
|
|
131
|
+
const optionsSectionElement = useRef(null);
|
|
132
|
+
const modelOptionsElement = useRef(null);
|
|
133
|
+
const connectionFieldsElement = useRef(null);
|
|
134
|
+
const setupEffortSliderElement = useRef(null);
|
|
135
|
+
const [quickstartProvider, setQuickstartProvider] = useState('bedrock');
|
|
136
|
+
const [selecting, setSelecting] = useState();
|
|
137
|
+
const [frogAnimationId, setFrogAnimationId] = useState();
|
|
138
|
+
const rowElements = useRef(new Map());
|
|
139
|
+
const directoryElements = useRef(new Map());
|
|
140
|
+
const pathCompletionElements = useRef(new Map());
|
|
141
|
+
const selectOptionElements = useRef(new Map());
|
|
142
|
+
const choiceElements = useRef(new Map());
|
|
143
|
+
const backElement = useRef(undefined);
|
|
144
|
+
const nextElement = useRef(undefined);
|
|
145
|
+
const settingsElement = useRef(undefined);
|
|
146
|
+
const settingsCategoriesElement = useRef(null);
|
|
147
|
+
const escapeHintElement = useRef(undefined);
|
|
148
|
+
const frogElement = useRef(undefined);
|
|
149
|
+
const frogPress = useRef(undefined);
|
|
150
|
+
const hoverPointer = useRef(undefined);
|
|
151
|
+
const pressedElement = useRef(undefined);
|
|
152
|
+
const width = Math.max(1, columns);
|
|
153
|
+
const height = Math.max(1, terminalRows);
|
|
154
|
+
const navigationHeight = width < 32 ? 2 : 3;
|
|
155
|
+
const accent = palette.accent;
|
|
156
|
+
const pathEditing = editing?.field === 'importPath' ? editing : undefined;
|
|
157
|
+
const pathCompletions = useMemo(() => {
|
|
158
|
+
if (!pathEditing ||
|
|
159
|
+
(pathEditing.cursor ?? graphemes(pathEditing.value).length) !== graphemes(pathEditing.value).length) {
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
return importPathCompletions(pathEditing.value);
|
|
163
|
+
}, [pathEditing]);
|
|
164
|
+
const importCompletionCapacity = Math.min(pathCompletions.length, 4);
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
setPathCompletionIndex(-1);
|
|
167
|
+
}, [pathEditing?.value]);
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
let active = true;
|
|
170
|
+
void checkForUpdate().then((version) => {
|
|
171
|
+
if (active) {
|
|
172
|
+
setAvailableUpdate(version);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
return () => {
|
|
176
|
+
active = false;
|
|
177
|
+
};
|
|
178
|
+
}, [checkForUpdate]);
|
|
179
|
+
const isSettings = step === SETTINGS_STEP;
|
|
180
|
+
const progress = setupStepProgress(flow, step);
|
|
181
|
+
const progressHeight = progress ? 3 : 0;
|
|
182
|
+
const updateSettings = useCallback((next) => {
|
|
183
|
+
setPanelSettings(next);
|
|
184
|
+
setAppearance(appearanceSettings(next));
|
|
185
|
+
setDraft((current) => ({
|
|
186
|
+
...current,
|
|
187
|
+
settings: {
|
|
188
|
+
...current.settings,
|
|
189
|
+
mcpDiscovery: next.mcpDiscovery,
|
|
190
|
+
skillDiscovery: next.skillDiscovery,
|
|
191
|
+
agentMessaging: next.agentMessaging,
|
|
192
|
+
},
|
|
193
|
+
}));
|
|
194
|
+
setError(undefined);
|
|
195
|
+
void config.setSettings(next).catch((cause) => setError(errorMessage(cause)));
|
|
196
|
+
}, [config, setAppearance]);
|
|
197
|
+
const isProviderSetup = (flow === 'quickstart' || flow === 'customize') && step === 1;
|
|
198
|
+
const isTools = flow === 'customize' && step === 3;
|
|
199
|
+
const isPlugins = flow === 'customize' && step === 4;
|
|
200
|
+
const isCapabilities = isTools || isPlugins;
|
|
201
|
+
const isData = flow === 'customize' && step === 5;
|
|
202
|
+
const isReview = flow === 'customize' && step === CUSTOMIZE_STEPS.length;
|
|
203
|
+
const isPermissions = flow === 'customize' && step === 6;
|
|
204
|
+
const isImport = flow === 'import' && step === 1;
|
|
205
|
+
const hasExternalActions = !isSettings && (isProviderSetup || isImport || isCapabilities || flow === 'customize');
|
|
206
|
+
const bubbleWidth = Math.max(1, Math.min(isProviderSetup ? 144 : 112, width - 2));
|
|
207
|
+
const stackedData = bubbleWidth < 72;
|
|
208
|
+
const stackedReview = bubbleWidth < 72;
|
|
209
|
+
const lockupWidth = Math.max(1, width - 2);
|
|
210
|
+
const brandFrame = setupBrandFrame(lockupWidth, height);
|
|
211
|
+
const lockupHeight = brandFrame.height;
|
|
212
|
+
const showBrand = lockupHeight > 1;
|
|
213
|
+
const brandHeight = showBrand ? lockupHeight + brandFrame.top : 0;
|
|
214
|
+
const { columns: openingColumns, rows: openingRows, rowGap: openingRowGap, gridWidth: openingGridWidth, } = openingGridLayout(lockupWidth);
|
|
215
|
+
// The opening error sits one row below the grid and wraps to the grid's width.
|
|
216
|
+
const openingErrorHeight = error ? wrapLines(error, Math.max(1, openingGridWidth)).length + 1 : 0;
|
|
217
|
+
// The Esc hint takes one row below the grid plus its gap.
|
|
218
|
+
const openingContentHeight = height - brandHeight - navigationHeight - openingErrorHeight - 2;
|
|
219
|
+
const openingTopGap = openingContentHeight >= openingRows * (openingColumns === 2 ? 9 : 5) + (openingRows - 1) * openingRowGap + 3
|
|
220
|
+
? 3
|
|
221
|
+
: openingContentHeight >= openingRows * (openingColumns === 2 ? 8 : 5) + (openingRows - 1) * openingRowGap + 2
|
|
222
|
+
? 2
|
|
223
|
+
: openingContentHeight >= openingRows * 3 + (openingRows - 1) * openingRowGap + 1
|
|
224
|
+
? 1
|
|
225
|
+
: 0;
|
|
226
|
+
const openingButtonHeight = Math.max(1, Math.min(openingColumns === 2 ? 9 : 5, Math.floor((openingContentHeight - openingTopGap - (openingRows - 1) * openingRowGap) / openingRows)));
|
|
227
|
+
const actionHeight = height >= 20 ? 3 : 1;
|
|
228
|
+
const actionGap = height >= 24 ? 1 : 0;
|
|
229
|
+
const actionColumnGap = bubbleWidth >= 3 ? 1 : 0;
|
|
230
|
+
const actionWidth = Math.max(1, Math.floor((bubbleWidth - actionColumnGap) / 2));
|
|
231
|
+
const splitQuickstart = isProviderSetup && bubbleWidth >= 38;
|
|
232
|
+
const quickstartProviderColumnWidth = quickstartProvider === 'bedrock' || quickstartProvider === 'bedrock-mantle'
|
|
233
|
+
? Math.min(52, Math.floor(bubbleWidth / 2))
|
|
234
|
+
: Math.max(16, Math.min(31, Math.floor(bubbleWidth * 0.34)));
|
|
235
|
+
const quickstartDetailColumnWidth = bubbleWidth - quickstartProviderColumnWidth;
|
|
236
|
+
const rowHeight = isSettings
|
|
237
|
+
? 1
|
|
238
|
+
: isProviderSetup
|
|
239
|
+
? 4
|
|
240
|
+
: isCapabilities
|
|
241
|
+
? 1
|
|
242
|
+
: isPermissions
|
|
243
|
+
? 2
|
|
244
|
+
: flow === 'customize'
|
|
245
|
+
? step === 2
|
|
246
|
+
? 5
|
|
247
|
+
: step === 5
|
|
248
|
+
? 4
|
|
249
|
+
: 3
|
|
250
|
+
: 2;
|
|
251
|
+
const updateProfile = useCallback((update) => {
|
|
252
|
+
setDraft((current) => ({ ...current, profile: { ...current.profile, ...update } }));
|
|
253
|
+
}, []);
|
|
254
|
+
const credentialRejectedProvider = providerModels.provider === quickstartProvider &&
|
|
255
|
+
!providerModels.loading &&
|
|
256
|
+
providerModels.credentialRejected === true
|
|
257
|
+
? quickstartProvider
|
|
258
|
+
: undefined;
|
|
259
|
+
const keyCredentialProvider = ['anthropic', 'openai', 'google'].includes(quickstartProvider);
|
|
260
|
+
const credentialValidationProvider = isProviderSetup &&
|
|
261
|
+
keyCredentialProvider &&
|
|
262
|
+
readyProviders.includes(quickstartProvider) &&
|
|
263
|
+
(providerModels.provider !== quickstartProvider || providerModels.loading)
|
|
264
|
+
? quickstartProvider
|
|
265
|
+
: undefined;
|
|
266
|
+
const unavailableCredentialProvider = credentialRejectedProvider ?? credentialValidationProvider;
|
|
267
|
+
const setupReadyProviders = useMemo(() => unavailableCredentialProvider
|
|
268
|
+
? readyProviders.filter((provider) => provider !== unavailableCredentialProvider)
|
|
269
|
+
: readyProviders, [readyProviders, unavailableCredentialProvider]);
|
|
270
|
+
const rows = useMemo(() => {
|
|
271
|
+
const stepRows = isSettings
|
|
272
|
+
? wizardSettingsRows({ ...panelSettings, ...draft.settings, ...appearance }, updateSettings).filter(({ section }) => section === settingsCategory)
|
|
273
|
+
: rowsForStep(step, flow, draft, importPath, providerEnvironment, detectedEnvironment, quickstartProvider, setupReadyProviders, awsDiscovery, ollamaDiscovery, setDraft, updateProfile, setEditing, liteLlmDiscovery, credentialRejectedProvider, credentialValidationProvider, providerModels.error);
|
|
274
|
+
return isProviderSetup
|
|
275
|
+
? [
|
|
276
|
+
...stepRows,
|
|
277
|
+
{
|
|
278
|
+
id: 'refresh-provider',
|
|
279
|
+
label: '↻ Refresh',
|
|
280
|
+
description: '',
|
|
281
|
+
activate: () => {
|
|
282
|
+
try {
|
|
283
|
+
recheck();
|
|
284
|
+
setError(undefined);
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
setError(errorMessage(error));
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
]
|
|
292
|
+
: stepRows;
|
|
293
|
+
}, [
|
|
294
|
+
appearance,
|
|
295
|
+
panelSettings,
|
|
296
|
+
updateSettings,
|
|
297
|
+
isSettings,
|
|
298
|
+
settingsCategory,
|
|
299
|
+
isProviderSetup,
|
|
300
|
+
awsDiscovery,
|
|
301
|
+
detectedEnvironment,
|
|
302
|
+
draft,
|
|
303
|
+
flow,
|
|
304
|
+
importPath,
|
|
305
|
+
ollamaDiscovery,
|
|
306
|
+
liteLlmDiscovery,
|
|
307
|
+
providerEnvironment,
|
|
308
|
+
quickstartProvider,
|
|
309
|
+
setupReadyProviders,
|
|
310
|
+
credentialRejectedProvider,
|
|
311
|
+
credentialValidationProvider,
|
|
312
|
+
providerModels.error,
|
|
313
|
+
recheck,
|
|
314
|
+
step,
|
|
315
|
+
updateProfile,
|
|
316
|
+
]);
|
|
317
|
+
const selectedModelProvider = providerFromModel(draft.profile.model);
|
|
318
|
+
const hasSelectedModel = deselectedModel !== draft.profile.model;
|
|
319
|
+
const selectedModelAvailable = hasSelectedModel &&
|
|
320
|
+
providerModels.provider === quickstartProvider &&
|
|
321
|
+
providerModels.available &&
|
|
322
|
+
!providerModels.loading &&
|
|
323
|
+
providerModels.models.some((model) => `${quickstartProvider}/${model.id}` === draft.profile.model);
|
|
324
|
+
const keepingConfiguredModel = !config.needsSetup() && draft.profile.model === config.snapshot().profile.model;
|
|
325
|
+
const canContinue = step !== 1 ||
|
|
326
|
+
(flow === 'import'
|
|
327
|
+
? importPath.trim().length > 0
|
|
328
|
+
: isProviderSetup
|
|
329
|
+
? hasSelectedModel &&
|
|
330
|
+
selectedModelProvider === quickstartProvider &&
|
|
331
|
+
setupReadyProviders.includes(quickstartProvider) &&
|
|
332
|
+
(selectedModelAvailable || keepingConfiguredModel)
|
|
333
|
+
: draft.providers.some((provider) => readyProviders.includes(provider)));
|
|
334
|
+
const inspectedProvider = isProviderSetup ? quickstartProvider : undefined;
|
|
335
|
+
const inspectedAssessment = inspectedProvider
|
|
336
|
+
? providerAssessment(inspectedProvider, effectiveEnvironment, awsDiscovery, ollamaDiscovery, liteLlmDiscovery)
|
|
337
|
+
: undefined;
|
|
338
|
+
const warning = keyCredentialProvider || !inspectedAssessment?.warning
|
|
339
|
+
? undefined
|
|
340
|
+
: sanitizeTerminalText(inspectedAssessment.warning);
|
|
341
|
+
const assessmentFacts = inspectedAssessment?.facts ?? [];
|
|
342
|
+
const quickstartExaSearchActive = flow === 'quickstart' && step === 1 && exaWebSearchActive(draft.profile);
|
|
343
|
+
const quickstartWebSearchOffered = rows.some((row) => row.id === 'quickstart-web-search');
|
|
344
|
+
const showModelOptionsPanel = splitQuickstart && quickstartDetailColumnWidth >= 66;
|
|
345
|
+
const quickstartOptionsColumnWidth = 32;
|
|
346
|
+
const quickstartModelColumnWidth = quickstartDetailColumnWidth - (showModelOptionsPanel ? quickstartOptionsColumnWidth : 0);
|
|
347
|
+
const quickstartDetailContentWidth = Math.max(1, quickstartModelColumnWidth - 4);
|
|
348
|
+
const bannerWarning = warning
|
|
349
|
+
? assessmentFacts.length > 0
|
|
350
|
+
? [
|
|
351
|
+
PROVIDER_LABELS[inspectedProvider],
|
|
352
|
+
...assessmentFacts.map((fact) => `${fact.label}: ${fact.value}`),
|
|
353
|
+
'',
|
|
354
|
+
warning,
|
|
355
|
+
].join('\n')
|
|
356
|
+
: `${PROVIDER_LABELS[inspectedProvider]}: ${warning}`
|
|
357
|
+
: isTools || quickstartExaSearchActive
|
|
358
|
+
? EXA_WEB_SEARCH_WARNING
|
|
359
|
+
: undefined;
|
|
360
|
+
const bannerWarningStatus = warning ? inspectedAssessment.status : 'warning';
|
|
361
|
+
const providerReady = isProviderSetup && setupReadyProviders.includes(quickstartProvider);
|
|
362
|
+
const showProviderConfiguration = isProviderSetup && !providerReady;
|
|
363
|
+
const modelPanelVisible = splitQuickstart && providerReady;
|
|
364
|
+
const availableBubbleHeight = Math.max(1, height - brandHeight - progressHeight - (hasExternalActions ? actionHeight + actionGap : 0) - navigationHeight);
|
|
365
|
+
const capabilityHeaderHeight = height >= 20 ? 3 : 1;
|
|
366
|
+
const warningChromeHeight = isCapabilities ? capabilityHeaderHeight + 3 : 1;
|
|
367
|
+
const bannerLines = (text) => wrapLines(`⚠ ${text}`, Math.max(1, bubbleWidth - 4)).slice(0, Math.max(0, availableBubbleHeight - rowHeight - warningChromeHeight - Number(error !== undefined)));
|
|
368
|
+
const warningLines = bannerWarning && !splitQuickstart ? bannerLines(bannerWarning) : [];
|
|
369
|
+
// Reserve the Exa banner's space whether or not web_search is on, so toggling it doesn't resize the panel.
|
|
370
|
+
const warningHeight = (isTools || (quickstartWebSearchOffered && !splitQuickstart)) && !warning && !supportsWebSearch(draft.profile.model)
|
|
371
|
+
? bannerLines(EXA_WEB_SEARCH_WARNING).length
|
|
372
|
+
: warningLines.length;
|
|
373
|
+
const warningGap = (isCapabilities || flow === 'quickstart') &&
|
|
374
|
+
warningHeight > 0 &&
|
|
375
|
+
(!isCapabilities ||
|
|
376
|
+
availableBubbleHeight > warningChromeHeight + rowHeight + warningHeight + Number(error !== undefined))
|
|
377
|
+
? 1
|
|
378
|
+
: 0;
|
|
379
|
+
const extraRows = Number(error !== undefined) + warningGap + warningHeight;
|
|
380
|
+
const capabilityContentHeight = Math.max(0, rows.length - 1) * rowHeight + capabilityHeaderHeight + 3;
|
|
381
|
+
const reviewSummaryWidth = Math.max(1, bubbleWidth - (stackedReview ? 6 : 36));
|
|
382
|
+
const reviewSummaries = isReview
|
|
383
|
+
? rows.map((row) => {
|
|
384
|
+
const lines = wrapLines(sanitizeTerminalText(row.description), reviewSummaryWidth);
|
|
385
|
+
return lines.length > 3
|
|
386
|
+
? [...lines.slice(0, 2), `${wrapLines(lines[2], Math.max(1, reviewSummaryWidth - 1))[0]}…`]
|
|
387
|
+
: lines;
|
|
388
|
+
})
|
|
389
|
+
: [];
|
|
390
|
+
const reviewButtonsOutlined = isReview && !stackedReview && availableBubbleHeight >= rows.length * 3 + 4 + extraRows;
|
|
391
|
+
const reviewContentHeights = reviewSummaries.map((lines) => Math.max(reviewButtonsOutlined ? 3 : 1, lines.length + Number(stackedReview)));
|
|
392
|
+
const reviewGap = !reviewButtonsOutlined &&
|
|
393
|
+
availableBubbleHeight >=
|
|
394
|
+
reviewContentHeights.reduce((total, row) => total + row, 0) + rows.length - 1 + 4 + extraRows
|
|
395
|
+
? 1
|
|
396
|
+
: 0;
|
|
397
|
+
const contentRowHeights = isData
|
|
398
|
+
? rows.map((row) => dataRowHeight(row, stackedData))
|
|
399
|
+
: isReview
|
|
400
|
+
? reviewContentHeights.map((row, index) => row + (index < rows.length - 1 ? reviewGap : 0))
|
|
401
|
+
: [];
|
|
402
|
+
const bubbleHeight = isImport
|
|
403
|
+
? Math.min(10 + extraRows + (pathEditing ? importCompletionCapacity + 1 : 0), availableBubbleHeight)
|
|
404
|
+
: isCapabilities
|
|
405
|
+
? Math.min(capabilityContentHeight + extraRows, availableBubbleHeight)
|
|
406
|
+
: isPermissions
|
|
407
|
+
? availableBubbleHeight
|
|
408
|
+
: isSettings
|
|
409
|
+
? availableBubbleHeight
|
|
410
|
+
: flow === 'customize' && !isProviderSetup
|
|
411
|
+
? Math.min((isData || isReview
|
|
412
|
+
? contentRowHeights.reduce((total, row) => total + row, 0)
|
|
413
|
+
: rows.length * rowHeight) +
|
|
414
|
+
4 +
|
|
415
|
+
extraRows, availableBubbleHeight)
|
|
416
|
+
: availableBubbleHeight;
|
|
417
|
+
const panelChromeHeight = isProviderSetup ? 2 : isCapabilities ? capabilityHeaderHeight + 3 : 4;
|
|
418
|
+
const rowCapacity = Math.max(1, Math.floor((bubbleHeight - panelChromeHeight - extraRows) / rowHeight));
|
|
419
|
+
const firstListRow = isCapabilities ? 1 : 0;
|
|
420
|
+
const contentRange = isData || isReview
|
|
421
|
+
? setupRowViewport(contentRowHeights, selection, Math.max(1, bubbleHeight - panelChromeHeight - extraRows), rowViewportStart.current)
|
|
422
|
+
: undefined;
|
|
423
|
+
useEffect(() => {
|
|
424
|
+
rowViewportStart.current = contentRange?.start ?? 0;
|
|
425
|
+
}, [contentRange?.start]);
|
|
426
|
+
const viewportStart = contentRange?.start ?? Math.max(firstListRow, Math.min(selection - rowCapacity + 1, rows.length - rowCapacity));
|
|
427
|
+
const visibleRows = rows.slice(viewportStart, contentRange?.end ?? viewportStart + rowCapacity);
|
|
428
|
+
const hiddenRowsBefore = viewportStart;
|
|
429
|
+
const hiddenRowsAfter = Math.max(0, rows.length - viewportStart - visibleRows.length);
|
|
430
|
+
const customizeOverflowLabel = [
|
|
431
|
+
hiddenRowsBefore > 0 ? `↑ ${hiddenRowsBefore} previous` : '',
|
|
432
|
+
hiddenRowsAfter > 0 ? `↓ ${hiddenRowsAfter} more` : '',
|
|
433
|
+
]
|
|
434
|
+
.filter(Boolean)
|
|
435
|
+
.join(' · ');
|
|
436
|
+
const visibleCapabilityRows = isCapabilities ? visibleRows.filter((row) => row.id !== 'select-all') : [];
|
|
437
|
+
const permissionModeHeight = bubbleWidth < 72 || bubbleHeight - extraRows < 14 ? 3 : bubbleHeight - extraRows < 18 ? 5 : 7;
|
|
438
|
+
const permissionToolCapacity = Math.max(1, Math.floor((bubbleHeight - panelChromeHeight - permissionModeHeight - 2 - extraRows) / rowHeight));
|
|
439
|
+
const permissionViewportStart = Math.max(3, Math.min(selection - permissionToolCapacity + 1, rows.length - permissionToolCapacity));
|
|
440
|
+
const visiblePermissionTools = rows.slice(permissionViewportStart, permissionViewportStart + permissionToolCapacity);
|
|
441
|
+
const providerRows = isProviderSetup ? rows.slice(0, PROVIDER_IDS.length) : [];
|
|
442
|
+
const providerFieldRows = isProviderSetup ? rows.slice(PROVIDER_IDS.length) : [];
|
|
443
|
+
const refreshRow = providerFieldRows.find((row) => row.id === 'refresh-provider');
|
|
444
|
+
const awsProfileRow = providerFieldRows.find((row) => row.field === 'AWS_PROFILE');
|
|
445
|
+
const quickstartProviderListWidth = awsProfileRow
|
|
446
|
+
? Math.max(8, Math.floor((quickstartProviderColumnWidth - 3) * 0.45))
|
|
447
|
+
: quickstartProviderColumnWidth - 2;
|
|
448
|
+
const quickstartProfileWidth = quickstartProviderColumnWidth - quickstartProviderListWidth - 3;
|
|
449
|
+
const providerConfigurationRows = providerFieldRows.filter((row) => row.id !== 'refresh-provider' && row !== awsProfileRow);
|
|
450
|
+
const providerWarningStatus = providerConfigurationRows.some((row) => row.input === true && PROVIDER_CREDENTIAL_KEYS.includes(row.field))
|
|
451
|
+
? 'error'
|
|
452
|
+
: bannerWarningStatus;
|
|
453
|
+
const availableReasoningRow = providerConfigurationRows.find((row) => row.id === 'thinking');
|
|
454
|
+
const reasoningRow = selectedModelAvailable ? availableReasoningRow : undefined;
|
|
455
|
+
const reasoningRowIndex = reasoningRow ? rows.indexOf(reasoningRow) : -1;
|
|
456
|
+
const hiddenReasoningRowIndex = availableReasoningRow && !reasoningRow ? rows.indexOf(availableReasoningRow) : -1;
|
|
457
|
+
const reasoningSlider = reasoningRow?.choices && reasoningRow.choices.length > 0
|
|
458
|
+
? {
|
|
459
|
+
label: 'Effort',
|
|
460
|
+
options: reasoningRow.choices.map((choice, index) => ({
|
|
461
|
+
id: String(index),
|
|
462
|
+
label: choice.label,
|
|
463
|
+
...(choice.active ? { active: true } : {}),
|
|
464
|
+
})),
|
|
465
|
+
...(reasoningRow.disabled ? { disabled: true } : {}),
|
|
466
|
+
}
|
|
467
|
+
: undefined;
|
|
468
|
+
const modelOptionRows = providerReady
|
|
469
|
+
? providerConfigurationRows.filter((row) => row.id !== 'thinking' || reasoningRow !== undefined)
|
|
470
|
+
: [];
|
|
471
|
+
const directoryRows = new Map(rows.flatMap((row, index) => canUseNativePicker() && !row.disabled && (row.field === 'memoryDir' || row.field === 'skills')
|
|
472
|
+
? [[index, row.field]]
|
|
473
|
+
: []));
|
|
474
|
+
const quickstartBodyHeight = bubbleHeight - panelChromeHeight - extraRows;
|
|
475
|
+
const compactProviderControls = quickstartBodyHeight - 2 - (refreshRow ? 4 : 0) < PROVIDER_IDS.length;
|
|
476
|
+
const providerRefreshHeight = compactProviderControls ? 1 : 4;
|
|
477
|
+
const providerFooterHeight = refreshRow ? providerRefreshHeight : 0;
|
|
478
|
+
const quickstartProviderListCapacity = Math.max(1, quickstartBodyHeight - 2 - providerFooterHeight);
|
|
479
|
+
const quickstartProviderRowHeight = quickstartProviderListCapacity >= PROVIDER_IDS.length * 3 - 1
|
|
480
|
+
? 3
|
|
481
|
+
: quickstartProviderListCapacity >= PROVIDER_IDS.length * 2
|
|
482
|
+
? 2
|
|
483
|
+
: 1;
|
|
484
|
+
const quickstartProviderListHeight = Math.min(quickstartProviderListCapacity, PROVIDER_IDS.length * quickstartProviderRowHeight);
|
|
485
|
+
const quickstartVisibleProviderCount = Math.max(1, Math.floor(quickstartProviderListHeight / quickstartProviderRowHeight));
|
|
486
|
+
const quickstartProviderViewportStart = Math.max(0, Math.min(PROVIDER_IDS.indexOf(quickstartProvider) - quickstartVisibleProviderCount + 1, providerRows.length - quickstartVisibleProviderCount));
|
|
487
|
+
const visibleProviderRows = providerRows.slice(quickstartProviderViewportStart, quickstartProviderViewportStart + quickstartVisibleProviderCount);
|
|
488
|
+
const quickstartFieldRowHeight = 5;
|
|
489
|
+
const middleFacts = splitQuickstart && showProviderConfiguration && !showModelOptionsPanel ? assessmentFacts : [];
|
|
490
|
+
const middleFactsHeight = middleFacts.length;
|
|
491
|
+
const middleDetailGap = middleFacts.length > 0 && warning ? 1 : 0;
|
|
492
|
+
const middleFieldGap = warning && providerConfigurationRows.length > 0 && !showModelOptionsPanel ? 1 : 0;
|
|
493
|
+
const quickstartFieldReserve = providerConfigurationRows.length > 0 ? quickstartFieldRowHeight : 0;
|
|
494
|
+
const middleWarningLines = splitQuickstart && showProviderConfiguration && !showModelOptionsPanel && warning
|
|
495
|
+
? wrapLines(warning, quickstartDetailContentWidth).slice(0, Math.max(0, quickstartBodyHeight - 2 - quickstartFieldReserve - middleFactsHeight - middleDetailGap - middleFieldGap))
|
|
496
|
+
: [];
|
|
497
|
+
const middleDetailHeight = middleFactsHeight + middleDetailGap + middleWarningLines.length + middleFieldGap;
|
|
498
|
+
const quickstartFieldCapacity = Math.max(1, Math.floor((quickstartBodyHeight - 2 - middleDetailHeight) / quickstartFieldRowHeight));
|
|
499
|
+
const selectedField = providerConfigurationRows.findIndex((row) => row === rows[selection]);
|
|
500
|
+
const quickstartFieldViewportStart = Math.max(0, Math.min(selectedField - quickstartFieldCapacity + 1, providerConfigurationRows.length - quickstartFieldCapacity));
|
|
501
|
+
const visibleProviderFieldRows = providerConfigurationRows.slice(quickstartFieldViewportStart, quickstartFieldViewportStart + quickstartFieldCapacity);
|
|
502
|
+
const filteredProviderModels = useMemo(() => {
|
|
503
|
+
const query = modelQuery.trim().toLowerCase();
|
|
504
|
+
return providerModels.models.filter((model) => `${model.name} ${model.id}`.toLowerCase().includes(query));
|
|
505
|
+
}, [modelQuery, providerModels.models]);
|
|
506
|
+
const quickstartModelOffset = rows.length;
|
|
507
|
+
const defaultModel = DEFAULT_HARNESS_AGENT_CONFIG.model;
|
|
508
|
+
const quickstartDefaultModel = providerFromModel(defaultModel) === quickstartProvider
|
|
509
|
+
? defaultModel.slice(defaultModel.indexOf('/') + 1)
|
|
510
|
+
: undefined;
|
|
511
|
+
const selectedModelOption = Math.max(0, modelOptionRows.findIndex((row) => row === rows[selection]));
|
|
512
|
+
const modelOptionsContentHeight = Math.max(1, quickstartBodyHeight - 2);
|
|
513
|
+
const compactModelOptions = modelOptionRows.length * 6 > modelOptionsContentHeight;
|
|
514
|
+
const reasoningControlHeight = compactModelOptions ? 4 : 6;
|
|
515
|
+
const webSearchControlHeight = modelOptionsContentHeight < 6 ? 4 : 6;
|
|
516
|
+
const visibleModelOptionRows = modelOptionRows.reduce((height, row) => height + (row.id === 'thinking' ? reasoningControlHeight : webSearchControlHeight), 0) > modelOptionsContentHeight
|
|
517
|
+
? modelOptionRows.slice(selectedModelOption, selectedModelOption + 1)
|
|
518
|
+
: modelOptionRows;
|
|
519
|
+
const quickstartModelRowHeight = 1;
|
|
520
|
+
const quickstartSearchHeight = quickstartBodyHeight >= 8 ? 3 : 1;
|
|
521
|
+
const quickstartModelCapacity = Math.max(1, Math.floor((quickstartBodyHeight - quickstartSearchHeight - 4) / quickstartModelRowHeight));
|
|
522
|
+
const quickstartModelViewportStart = Math.max(0, Math.min(modelViewportStart, filteredProviderModels.length - quickstartModelCapacity));
|
|
523
|
+
const visibleProviderModels = filteredProviderModels.slice(quickstartModelViewportStart, quickstartModelViewportStart + quickstartModelCapacity);
|
|
524
|
+
const previousModelCount = quickstartModelViewportStart;
|
|
525
|
+
const nextModelCount = Math.max(0, filteredProviderModels.length - quickstartModelViewportStart - visibleProviderModels.length);
|
|
526
|
+
const showModelPagination = providerModels.provider === quickstartProvider && providerModels.available && visibleProviderModels.length > 0;
|
|
527
|
+
const quickstartModelContentWidth = Math.max(1, quickstartDetailContentWidth - 4);
|
|
528
|
+
const showModelIds = !showModelOptionsPanel && quickstartDetailContentWidth >= 44;
|
|
529
|
+
const quickstartModelNameWidth = Math.min(Math.max(1, ...filteredProviderModels.map((model) => stringWidth(model.name) + (model.id === quickstartDefaultModel ? 2 : 0))), Math.max(1, quickstartModelContentWidth - 15));
|
|
530
|
+
const quickstartModelIdWidth = Math.max(1, quickstartModelContentWidth - quickstartModelNameWidth - 3);
|
|
531
|
+
const quickstartSelectableRows = rows.length + (modelPanelVisible && providerModels.available ? filteredProviderModels.length : 0);
|
|
532
|
+
const providerSectionRows = {
|
|
533
|
+
providers: [...providerRows.map((row) => rows.indexOf(row)), ...(refreshRow ? [rows.indexOf(refreshRow)] : [])],
|
|
534
|
+
profiles: awsProfileRow ? [rows.indexOf(awsProfileRow)] : [],
|
|
535
|
+
models: providerReady
|
|
536
|
+
? Array.from({ length: Math.max(0, quickstartSelectableRows - quickstartModelOffset) }, (_, index) => quickstartModelOffset + index)
|
|
537
|
+
: providerConfigurationRows.map((row) => rows.indexOf(row)),
|
|
538
|
+
options: providerReady
|
|
539
|
+
? providerConfigurationRows
|
|
540
|
+
.map((row) => rows.indexOf(row))
|
|
541
|
+
.filter((index) => !rows[index]?.disabled && index !== hiddenReasoningRowIndex)
|
|
542
|
+
: [],
|
|
543
|
+
};
|
|
544
|
+
const providerSections = [
|
|
545
|
+
'providers',
|
|
546
|
+
...(awsProfileRow ? ['profiles'] : []),
|
|
547
|
+
...(modelPanelVisible || providerSectionRows.models.length > 0 ? ['models'] : []),
|
|
548
|
+
...(providerSectionRows.options.length > 0 ? ['options'] : []),
|
|
549
|
+
'actions',
|
|
550
|
+
];
|
|
551
|
+
const focusedProviderSection = focusedAction === 'back' || focusedAction === 'next'
|
|
552
|
+
? 'actions'
|
|
553
|
+
: modelSearchFocused || selection >= quickstartModelOffset
|
|
554
|
+
? 'models'
|
|
555
|
+
: providerSectionRows.providers.includes(selection)
|
|
556
|
+
? 'providers'
|
|
557
|
+
: providerSectionRows.profiles.includes(selection)
|
|
558
|
+
? 'profiles'
|
|
559
|
+
: providerReady
|
|
560
|
+
? 'options'
|
|
561
|
+
: 'models';
|
|
562
|
+
const providerSelectionKey = focusedProviderSection === 'actions'
|
|
563
|
+
? focusedAction
|
|
564
|
+
: modelSearchFocused
|
|
565
|
+
? 'search'
|
|
566
|
+
: selection >= quickstartModelOffset
|
|
567
|
+
? filteredProviderModels[selection - quickstartModelOffset]?.id
|
|
568
|
+
: rows[selection]?.id;
|
|
569
|
+
useEffect(() => {
|
|
570
|
+
if (!isProviderSetup) {
|
|
571
|
+
previousModelOffset.current = undefined;
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
const previousOffset = previousModelOffset.current;
|
|
575
|
+
previousModelOffset.current = quickstartModelOffset;
|
|
576
|
+
if (previousOffset !== undefined &&
|
|
577
|
+
previousOffset !== quickstartModelOffset &&
|
|
578
|
+
selection >= previousOffset &&
|
|
579
|
+
!focusedAction &&
|
|
580
|
+
!modelSearchFocused) {
|
|
581
|
+
setSelection(selection + quickstartModelOffset - previousOffset);
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
if (providerSelectionKey !== undefined) {
|
|
585
|
+
providerSectionSelections.current[focusedProviderSection] = providerSelectionKey;
|
|
586
|
+
}
|
|
587
|
+
}, [
|
|
588
|
+
focusedAction,
|
|
589
|
+
focusedProviderSection,
|
|
590
|
+
isProviderSetup,
|
|
591
|
+
modelSearchFocused,
|
|
592
|
+
providerSelectionKey,
|
|
593
|
+
quickstartModelOffset,
|
|
594
|
+
selection,
|
|
595
|
+
]);
|
|
596
|
+
const setupSectionRows = {};
|
|
597
|
+
if (!isProviderSetup && step > 0) {
|
|
598
|
+
rows.forEach((row, index) => {
|
|
599
|
+
if (row.disabled)
|
|
600
|
+
return;
|
|
601
|
+
const section = setupRowSection(flow, step, row);
|
|
602
|
+
(setupSectionRows[section] ??= []).push(index);
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
const setupSections = [
|
|
606
|
+
...(isSettings ? ['categories'] : []),
|
|
607
|
+
...Object.keys(setupSectionRows),
|
|
608
|
+
...(hasExternalActions ? ['actions'] : []),
|
|
609
|
+
];
|
|
610
|
+
const focusedSetupSection = focusedAction === 'back' || focusedAction === 'next'
|
|
611
|
+
? 'actions'
|
|
612
|
+
: isSettings
|
|
613
|
+
? settingsFocus
|
|
614
|
+
: setupRowSection(flow, step, rows[selection]);
|
|
615
|
+
const setupSelectionScope = `${flow ?? 'appearance'}:${step}${isSettings ? `:${settingsCategory}` : ''}`;
|
|
616
|
+
useEffect(() => {
|
|
617
|
+
if (isProviderSetup || step === 0 || focusedSetupSection === 'categories')
|
|
618
|
+
return;
|
|
619
|
+
const key = focusedSetupSection === 'actions'
|
|
620
|
+
? focusedAction
|
|
621
|
+
: focusedAction?.startsWith('browse:')
|
|
622
|
+
? `browse:${rows[selection]?.id}`
|
|
623
|
+
: rows[selection]?.id;
|
|
624
|
+
if (key)
|
|
625
|
+
setupSectionSelections.current[`${setupSelectionScope}:${focusedSetupSection}`] = key;
|
|
626
|
+
}, [focusedAction, focusedSetupSection, isProviderSetup, rows, selection, setupSelectionScope, step]);
|
|
627
|
+
const rowHighlighted = (index) => !saving &&
|
|
628
|
+
(hoveredControl === index ||
|
|
629
|
+
(typeof hoveredControl === 'string' && hoveredControl.startsWith(`choice:${index}:`)) ||
|
|
630
|
+
(focusedAction === undefined && !modelSearchFocused && index === selection));
|
|
631
|
+
// Sized from every row, not just the visible ones, so descriptions stay aligned while scrolling.
|
|
632
|
+
const capabilityLabelWidth = Math.max(0, ...rows.filter((row) => row.id !== 'select-all').map((row) => graphemes(row.label).length));
|
|
633
|
+
const showCapabilityDescriptions = bubbleWidth >= 64;
|
|
634
|
+
const renderCapabilityRows = (capabilityRows) => (_jsx(Box, { flexGrow: 1, paddingX: 1, flexDirection: "column", overflow: "hidden", children: capabilityRows.map((row) => {
|
|
635
|
+
const index = rows.indexOf(row);
|
|
636
|
+
return (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), height: 1, flexShrink: 0, children: [_jsx(Text, { color: accent, children: rowHighlighted(index) ? '›' : ' ' }), _jsx(SetupToggle, { checked: row.active === true, focused: rowHighlighted(index) }), _jsx(Box, { ...(showCapabilityDescriptions
|
|
637
|
+
? { width: capabilityLabelWidth + 1, flexShrink: 0 }
|
|
638
|
+
: { flexGrow: 1, flexBasis: 0 }), children: _jsx(Text, { color: row.active || rowHighlighted(index) ? accent : palette.foreground, bold: rowHighlighted(index), wrap: "truncate-end", children: row.label }) }), showCapabilityDescriptions ? (_jsx(Text, { ...(row.descriptionColor ? { color: row.descriptionColor } : { dimColor: true }), wrap: "truncate-end", children: row.description })) : null] }, row.id));
|
|
639
|
+
}) }));
|
|
640
|
+
const renderChoices = (choices, index, outlined = false) => (_jsx(Box, { flexWrap: "wrap", columnGap: 1, children: choices.map((choice, choiceIndex) => {
|
|
641
|
+
const target = `choice:${index}:${choiceIndex}`;
|
|
642
|
+
return (_jsx(Box, { ref: (element) => registerElement(choiceElements.current, target, element), paddingX: 1, ...(outlined && bubbleWidth >= 38
|
|
643
|
+
? {
|
|
644
|
+
height: 3,
|
|
645
|
+
borderStyle: 'single',
|
|
646
|
+
borderColor: choice.active || hoveredControl === target ? accent : undefined,
|
|
647
|
+
borderDimColor: !choice.active && hoveredControl !== target,
|
|
648
|
+
}
|
|
649
|
+
: {}), children: _jsx(Text, { bold: choice.active, ...(choice.active ? { color: accent } : {}), children: choice.label }) }, choice.label));
|
|
650
|
+
}) }));
|
|
651
|
+
const renderSetupRow = (row, index) => {
|
|
652
|
+
const activeEditing = editing?.field === row.field ? editing : undefined;
|
|
653
|
+
const defaultName = row.field === 'name' && row.description === DEFAULT_HARNESS_AGENT_CONFIG.name;
|
|
654
|
+
const highlighted = !row.disabled && rowHighlighted(index);
|
|
655
|
+
return (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), height: rowHeight, flexShrink: 0, flexDirection: "column", overflow: "hidden", children: [_jsxs(Text, { bold: row.field !== undefined || highlighted, color: highlighted || row.active ? accent : palette.foreground, dimColor: row.disabled === true, wrap: "truncate-end", children: [highlighted ? '› ' : ' ', row.active === undefined ? '' : row.active ? '☑ ' : '☐ ', row.label] }), row.choices?.length ? (renderChoices(row.choices, index, true)) : row.field ? (_jsxs(Box, { flexGrow: 1, flexDirection: "row", children: [_jsx(Box, { flexGrow: 1, flexBasis: 0, flexDirection: "column", justifyContent: row.field === 'instructions' ? 'flex-start' : 'center', paddingX: 1, borderStyle: "single", borderColor: highlighted ? accent : undefined, borderDimColor: !highlighted, overflow: "hidden", children: _jsx(EditableText, { value: activeEditing?.value ?? (defaultName ? '' : row.description), cursor: activeEditing
|
|
656
|
+
? (activeEditing.cursor ?? graphemes(activeEditing.value).length)
|
|
657
|
+
: defaultName
|
|
658
|
+
? 0
|
|
659
|
+
: graphemes(row.description).length, width: Math.max(1, bubbleWidth - (directoryRows.has(index) ? 21 : 8)), maxRows: row.field === 'instructions' ? Math.max(1, rowHeight - 3) : 1, active: Boolean(activeEditing), ...(defaultName ? { placeholder: DEFAULT_HARNESS_AGENT_CONFIG.name } : {}) }) }), directoryRows.has(index) ? (_jsx(Box, { ref: (element) => registerElement(directoryElements.current, index, element), width: 12, marginLeft: 1, flexShrink: 0, alignItems: "center", justifyContent: "center", borderStyle: "single", borderColor: focusedAction === `browse:${index}` || hoveredControl === `browse:${index}` ? accent : undefined, borderDimColor: focusedAction !== `browse:${index}` && hoveredControl !== `browse:${index}`, children: _jsx(Text, { bold: true, wrap: "truncate-end", children: choosingDirectory && focusedAction === `browse:${index}` ? 'Opening...' : 'Browse' }) })) : null] })) : (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: row.description }))] }, row.id));
|
|
660
|
+
};
|
|
661
|
+
const renderDataRow = (row, index) => {
|
|
662
|
+
const highlighted = !row.disabled && rowHighlighted(index);
|
|
663
|
+
const activeEditing = editing?.field === row.field ? editing : undefined;
|
|
664
|
+
const stacked = stackedData && row.active === undefined;
|
|
665
|
+
const controlWidth = Math.max(1, bubbleWidth - 4 - (stackedData ? 0 : 22));
|
|
666
|
+
const browseFocused = focusedAction === `browse:${index}` || hoveredControl === `browse:${index}`;
|
|
667
|
+
return (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), height: dataRowHeight(row, stackedData), flexShrink: 0, flexDirection: stacked ? 'column' : 'row', alignItems: stacked ? 'stretch' : 'center', overflow: "hidden", children: [_jsx(Box, { ...(stacked ? {} : stackedData ? { flexGrow: 1, flexBasis: 0 } : { width: 22 }), flexShrink: 0, children: _jsxs(Text, { bold: highlighted, color: highlighted ? accent : palette.foreground, dimColor: row.disabled === true, wrap: "truncate-end", children: [highlighted ? '› ' : ' ', row.label] }) }), row.active !== undefined ? (_jsx(SetupToggle, { checked: row.active, focused: highlighted })) : row.choices ? (renderChoices(row.choices, index, true)) : (_jsxs(Box, { height: 3, flexGrow: 1, flexShrink: 0, ...(stacked ? {} : { flexBasis: 0 }), children: [_jsx(Box, { flexGrow: 1, flexBasis: 0, paddingX: 1, borderStyle: "single", borderColor: highlighted ? accent : undefined, borderDimColor: !highlighted, overflow: "hidden", children: _jsx(EditableText, { value: activeEditing?.value ?? row.description, cursor: activeEditing?.cursor ?? graphemes(activeEditing?.value ?? row.description).length, width: Math.max(1, controlWidth - 4 - (directoryRows.has(index) ? 13 : 0)), maxRows: 1, active: Boolean(activeEditing) }) }), directoryRows.has(index) ? (_jsx(Box, { ref: (element) => registerElement(directoryElements.current, index, element), width: 12, marginLeft: 1, flexShrink: 0, alignItems: "center", justifyContent: "center", borderStyle: "single", borderColor: browseFocused ? accent : undefined, borderDimColor: !browseFocused, children: _jsx(Text, { bold: true, wrap: "truncate-end", children: choosingDirectory && browseFocused ? 'Opening...' : 'Browse' }) })) : null] }))] }, row.id));
|
|
668
|
+
};
|
|
669
|
+
const renderReviewRow = (row, index) => {
|
|
670
|
+
const highlighted = rowHighlighted(index);
|
|
671
|
+
const label = (_jsxs(Text, { bold: true, color: highlighted ? accent : palette.foreground, wrap: "truncate-end", children: [highlighted ? '› ' : ' ', row.label] }));
|
|
672
|
+
const edit = (_jsx(Box, { width: 9, height: reviewButtonsOutlined ? 3 : 1, flexShrink: 0, alignItems: "center", justifyContent: "center", ...(reviewButtonsOutlined
|
|
673
|
+
? {
|
|
674
|
+
borderStyle: 'single',
|
|
675
|
+
borderColor: highlighted ? accent : undefined,
|
|
676
|
+
borderDimColor: !highlighted,
|
|
677
|
+
}
|
|
678
|
+
: {}), children: _jsx(Text, { bold: highlighted, color: highlighted ? accent : palette.foreground, children: "Edit \u2192" }) }));
|
|
679
|
+
return (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), height: contentRowHeights[index], paddingBottom: index < rows.length - 1 ? reviewGap : 0, flexShrink: 0, flexDirection: stackedReview ? 'column' : 'row', alignItems: stackedReview ? 'stretch' : 'center', overflow: "hidden", children: [stackedReview ? (_jsxs(Box, { justifyContent: "space-between", flexShrink: 0, children: [_jsx(Box, { flexGrow: 1, flexBasis: 0, children: label }), edit] })) : (_jsx(Box, { width: 22, flexShrink: 0, children: label })), _jsx(Box, { ...(stackedReview ? { paddingLeft: 2 } : { width: reviewSummaryWidth, marginRight: 1 }), flexShrink: 0, children: _jsx(Text, { dimColor: true, wrap: "truncate-end", children: reviewSummaries[index]?.join('\n') }) }), stackedReview ? null : edit] }, row.id));
|
|
680
|
+
};
|
|
681
|
+
const renderRefreshButton = (row, fieldWidth, compact = false) => {
|
|
682
|
+
const index = rows.indexOf(row);
|
|
683
|
+
const buttonWidth = Math.min(fieldWidth, Math.max(13, Math.floor(fieldWidth / 2)));
|
|
684
|
+
const singleRow = compact && compactProviderControls;
|
|
685
|
+
return (_jsx(Box, { height: compact ? providerRefreshHeight : quickstartFieldRowHeight, flexShrink: 0, flexDirection: "column", justifyContent: compact ? 'flex-end' : 'flex-start', alignItems: "center", children: _jsx(Box, { ref: (element) => registerElement(rowElements.current, index, element), width: buttonWidth, height: singleRow ? 1 : 3, borderStyle: singleRow ? undefined : 'single', borderColor: rowHighlighted(index) ? accent : undefined, borderDimColor: !rowHighlighted(index), backgroundColor: singleRow && rowHighlighted(index) ? palette.selection : undefined, flexDirection: "column", justifyContent: "center", alignItems: "center", children: _jsx(Text, { bold: true, color: rowHighlighted(index) ? accent : palette.foreground, wrap: "truncate-end", children: row.label }) }) }, row.id));
|
|
686
|
+
};
|
|
687
|
+
const renderProviderField = (row, fieldWidth, compact = false) => {
|
|
688
|
+
const index = rows.indexOf(row);
|
|
689
|
+
const activeEditing = editing?.field === row.field ? editing : undefined;
|
|
690
|
+
const credential = PROVIDER_CREDENTIAL_KEYS.includes(row.field);
|
|
691
|
+
const editable = row.input === true;
|
|
692
|
+
const shortControl = compact && (fieldWidth < 16 || quickstartBodyHeight < 8);
|
|
693
|
+
return (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), height: compact ? (shortControl ? 2 : 4) : quickstartFieldRowHeight, flexShrink: 0, flexDirection: "column", backgroundColor: rowHighlighted(index) ? palette.selection : undefined, children: [_jsx(Text, { bold: true, ...(rowHighlighted(index) ? { color: accent } : {}), wrap: "truncate-end", children: compact && fieldWidth < 11 ? 'Profile' : row.label }), editable ? (_jsxs(_Fragment, { children: [_jsx(Box, { width: fieldWidth, height: shortControl ? 1 : 3, paddingX: shortControl ? 0 : 1, alignItems: "center", borderStyle: shortControl ? undefined : 'single', borderColor: rowHighlighted(index) ? accent : undefined, borderDimColor: !rowHighlighted(index), children: compact && !activeEditing ? (_jsxs(_Fragment, { children: [_jsx(Box, { flexGrow: 1, flexBasis: 0, children: _jsx(Text, { dimColor: true, wrap: "truncate-end", children: sanitizeTerminalText(providerEnvironment.AWS_PROFILE ??
|
|
694
|
+
(effectiveEnvironment.AWS_BEARER_TOKEN_BEDROCK
|
|
695
|
+
? 'Environment'
|
|
696
|
+
: (effectiveEnvironment.AWS_PROFILE?.value ?? 'Environment'))) }) }), _jsx(Text, { dimColor: true, children: " \u25BE" })] })) : (_jsx(EditableText, { value: activeEditing?.value ?? (row.selectOptions ? row.description : ''), cursor: activeEditing?.cursor ?? graphemes(activeEditing?.value ?? '').length, width: Math.max(1, fieldWidth - (shortControl ? 0 : 4)), active: Boolean(activeEditing), masked: credential })) }), credential ? (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: row.description })) : null] })) : row.choices?.length ? (renderChoices(row.choices, index)) : activeEditing ? (_jsx(EditableText, { value: activeEditing.value, cursor: activeEditing.cursor ?? graphemes(activeEditing.value).length, width: Math.max(1, fieldWidth - 4), active: true })) : (_jsx(Text, { dimColor: true, children: row.description || ' ' }))] }, row.id));
|
|
697
|
+
};
|
|
698
|
+
// The note keeps a fixed height so toggling Exa never resizes the panel.
|
|
699
|
+
const renderQuickstartWebSearch = (row) => {
|
|
700
|
+
const index = rows.indexOf(row);
|
|
701
|
+
return (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), height: webSearchControlHeight, flexShrink: 0, flexDirection: "column", backgroundColor: rowHighlighted(index) ? palette.selection : undefined, children: [_jsxs(Text, { bold: true, color: accent, children: [rowHighlighted(index) ? '› ' : '', row.label] }), _jsx(Box, { flexShrink: 0, alignSelf: "flex-start", columnGap: 1, children: row.choices?.map((choice, choiceIndex) => {
|
|
702
|
+
const target = `choice:${index}:${choiceIndex}`;
|
|
703
|
+
const highlighted = !saving && (choice.active || hoveredControl === target);
|
|
704
|
+
return (_jsx(Box, { ref: (element) => registerElement(choiceElements.current, target, element), paddingX: 1, height: modelOptionsContentHeight >= 6 ? 3 : 1, borderStyle: modelOptionsContentHeight >= 6 ? 'single' : undefined, borderColor: highlighted ? accent : undefined, borderDimColor: !highlighted, children: _jsx(Text, { bold: choice.active, ...(choice.active ? { color: accent } : { dimColor: true }), children: choice.label }) }, choice.label));
|
|
705
|
+
}) }), quickstartExaSearchActive ? (_jsxs(_Fragment, { children: [_jsx(Text, { color: palette.warning, wrap: "truncate-end", children: "\u26A0 Third-party search via Exa" }), _jsx(Text, { dimColor: true, wrap: "truncate-end", children: "https://exa.ai/privacy-policy" })] })) : (_jsxs(_Fragment, { children: [_jsx(Text, { dimColor: true, wrap: "truncate-end", children: row.description }), _jsx(Text, { children: " " })] }))] }, row.id));
|
|
706
|
+
};
|
|
707
|
+
const renderProviderSelect = (state) => {
|
|
708
|
+
const capacity = Math.max(1, quickstartBodyHeight - (state.field === 'AWS_PROFILE' && splitQuickstart ? 0 : middleDetailHeight) - 3);
|
|
709
|
+
const start = Math.max(0, Math.min(state.selection - capacity + 1, state.options.length - capacity));
|
|
710
|
+
return (_jsxs(Box, { width: "100%", flexGrow: 1, paddingX: state.field === 'AWS_PROFILE' && splitQuickstart ? 0 : 1, flexDirection: "column", overflow: "hidden", children: [_jsx(Text, { bold: true, wrap: "truncate-end", children: state.field === 'AWS_PROFILE' && splitQuickstart && quickstartProfileWidth < 11
|
|
711
|
+
? 'Profile'
|
|
712
|
+
: (providerFieldRows.find((row) => row.field === state.field)?.label ?? 'Choose') }), state.options.slice(start, start + capacity).map((option, index) => {
|
|
713
|
+
const optionIndex = start + index;
|
|
714
|
+
return (_jsx(Box, { ref: (element) => registerElement(selectOptionElements.current, optionIndex, element), flexShrink: 0, backgroundColor: optionIndex === state.selection || hoveredControl === `option:${optionIndex}`
|
|
715
|
+
? palette.selection
|
|
716
|
+
: undefined, children: _jsxs(Text, { ...(optionIndex === state.selection ? { color: accent } : {}), wrap: "truncate-end", children: [optionIndex === state.selection ? '› ' : ' ', sanitizeTerminalText(option.label)] }) }, `${option.label}:${option.value ?? 'custom'}`));
|
|
717
|
+
})] }));
|
|
718
|
+
};
|
|
719
|
+
const renderModelOptions = (fieldWidth) => (_jsxs(Box, { ref: modelOptionsElement, paddingX: 1, flexGrow: 1, flexDirection: "column", overflow: "hidden", children: [visibleModelOptionRows.map((row) => row.id === 'thinking' && reasoningSlider ? (_jsxs(Box, { height: reasoningControlHeight, flexShrink: 0, flexDirection: "column", backgroundColor: rowHighlighted(reasoningRowIndex) ? palette.selection : undefined, children: [_jsxs(Text, { bold: true, color: accent, children: [rowHighlighted(reasoningRowIndex) ? '› ' : '', "Reasoning"] }), _jsx(EffortSlider, { slider: reasoningSlider, width: Math.max(1, Math.min(26, fieldWidth)), compact: compactModelOptions, focused: focusedProviderSection === 'options' && reasoningRowIndex === selection, paintBackground: false, onElement: (element) => {
|
|
720
|
+
setupEffortSliderElement.current = element;
|
|
721
|
+
registerElement(rowElements.current, reasoningRowIndex, element);
|
|
722
|
+
} })] }, row.id)) : (renderQuickstartWebSearch(row))), modelOptionRows.length === 0 ? _jsx(Text, { dimColor: true, children: "No options for this model." }) : null] }));
|
|
723
|
+
function setProviderValue(field, value) {
|
|
724
|
+
setProviderEnvironment((current) => {
|
|
725
|
+
const next = { ...current };
|
|
726
|
+
const normalized = value.trim();
|
|
727
|
+
if (normalized) {
|
|
728
|
+
next[field] = normalized;
|
|
729
|
+
}
|
|
730
|
+
else {
|
|
731
|
+
delete next[field];
|
|
732
|
+
}
|
|
733
|
+
return next;
|
|
734
|
+
});
|
|
735
|
+
setError(undefined);
|
|
736
|
+
}
|
|
737
|
+
function focusNextProviderField(field) {
|
|
738
|
+
if (field === 'AWS_PROFILE')
|
|
739
|
+
return;
|
|
740
|
+
const current = rows.findIndex((row) => row.field === field);
|
|
741
|
+
const next = rows.findIndex((row, index) => index > current && !row.disabled);
|
|
742
|
+
if (next >= 0) {
|
|
743
|
+
setSelection(next);
|
|
744
|
+
setFocusedAction(undefined);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
function chooseSelectOption(option) {
|
|
748
|
+
if (!selecting) {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
if (option.custom) {
|
|
752
|
+
const current = providerEnvironment[selecting.field] ?? effectiveEnvironment[selecting.field]?.value ?? '';
|
|
753
|
+
setEditing({ field: selecting.field, value: current });
|
|
754
|
+
}
|
|
755
|
+
else {
|
|
756
|
+
setProviderValue(selecting.field, option.value ?? '');
|
|
757
|
+
focusNextProviderField(selecting.field);
|
|
758
|
+
}
|
|
759
|
+
setSelecting(undefined);
|
|
760
|
+
}
|
|
761
|
+
const selectWizardRow = useCallback((index) => {
|
|
762
|
+
setFocusedAction(undefined);
|
|
763
|
+
setModelSearchFocused(false);
|
|
764
|
+
if (isSettings)
|
|
765
|
+
setSettingsFocus('settings');
|
|
766
|
+
setSelection(index);
|
|
767
|
+
if (isProviderSetup && index >= quickstartModelOffset) {
|
|
768
|
+
setProviderDetailSection('models');
|
|
769
|
+
setModelViewportStart((start) => revealPanelSelection(index - quickstartModelOffset, start, quickstartModelCapacity, filteredProviderModels.length));
|
|
770
|
+
}
|
|
771
|
+
else if (isProviderSetup &&
|
|
772
|
+
index >= PROVIDER_IDS.length &&
|
|
773
|
+
rows[index]?.id !== 'refresh-provider' &&
|
|
774
|
+
rows[index]?.field !== 'AWS_PROFILE') {
|
|
775
|
+
setProviderDetailSection(providerReady ? 'options' : 'models');
|
|
776
|
+
}
|
|
777
|
+
if (isProviderSetup && index >= 0 && index < PROVIDER_IDS.length) {
|
|
778
|
+
if (PROVIDER_IDS[index] !== quickstartProvider) {
|
|
779
|
+
setProviderDetailSection('models');
|
|
780
|
+
setModelQuery('');
|
|
781
|
+
setModelViewportStart(0);
|
|
782
|
+
setDeselectedModel(undefined);
|
|
783
|
+
}
|
|
784
|
+
setQuickstartProvider(PROVIDER_IDS[index]);
|
|
785
|
+
setSelecting(undefined);
|
|
786
|
+
setEditing(undefined);
|
|
787
|
+
}
|
|
788
|
+
}, [
|
|
789
|
+
isProviderSetup,
|
|
790
|
+
quickstartModelOffset,
|
|
791
|
+
quickstartModelCapacity,
|
|
792
|
+
filteredProviderModels.length,
|
|
793
|
+
quickstartProvider,
|
|
794
|
+
providerReady,
|
|
795
|
+
rows,
|
|
796
|
+
isSettings,
|
|
797
|
+
]);
|
|
798
|
+
const updateModelQuery = (query) => {
|
|
799
|
+
setModelQuery(query);
|
|
800
|
+
setProviderDetailSection('models');
|
|
801
|
+
setModelSearchFocused(true);
|
|
802
|
+
setFocusedAction(undefined);
|
|
803
|
+
setModelViewportStart(0);
|
|
804
|
+
setSelection(quickstartModelOffset);
|
|
805
|
+
setHoveredControl(undefined);
|
|
806
|
+
};
|
|
807
|
+
function focusProviderSection(direction) {
|
|
808
|
+
const current = Math.max(0, providerSections.indexOf(focusedProviderSection));
|
|
809
|
+
const section = providerSections[(current + direction + providerSections.length) % providerSections.length];
|
|
810
|
+
focusProviderSectionTarget(section, direction);
|
|
811
|
+
}
|
|
812
|
+
function focusProviderSectionTarget(section, direction = 1) {
|
|
813
|
+
if (section === 'models' || section === 'options')
|
|
814
|
+
setProviderDetailSection(section);
|
|
815
|
+
const previous = providerSectionSelections.current[section];
|
|
816
|
+
if (section === 'actions') {
|
|
817
|
+
const preferred = previous ?? (direction < 0 ? 'next' : 'back');
|
|
818
|
+
setFocusedAction(preferred === 'next' && canContinue ? 'next' : 'back');
|
|
819
|
+
setModelSearchFocused(false);
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
if (section === 'models' &&
|
|
823
|
+
modelPanelVisible &&
|
|
824
|
+
(previous === 'search' || providerSectionRows.models.length === 0)) {
|
|
825
|
+
setModelSearchFocused(true);
|
|
826
|
+
setFocusedAction(undefined);
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
const candidates = providerSectionRows[section].filter((index) => !rows[index]?.disabled);
|
|
830
|
+
const remembered = candidates.find((index) => index >= quickstartModelOffset
|
|
831
|
+
? filteredProviderModels[index - quickstartModelOffset]?.id === previous
|
|
832
|
+
: rows[index]?.id === previous);
|
|
833
|
+
const defaultRow = section === 'providers'
|
|
834
|
+
? PROVIDER_IDS.indexOf(quickstartProvider)
|
|
835
|
+
: section === 'models' && modelPanelVisible
|
|
836
|
+
? candidates.find((index) => `${quickstartProvider}/${filteredProviderModels[index - quickstartModelOffset]?.id}` ===
|
|
837
|
+
draft.profile.model)
|
|
838
|
+
: undefined;
|
|
839
|
+
const target = remembered ?? defaultRow ?? candidates[0];
|
|
840
|
+
if (target === undefined)
|
|
841
|
+
return;
|
|
842
|
+
selectWizardRow(target);
|
|
843
|
+
const row = rows[target];
|
|
844
|
+
if (row?.field && row.input === true && !row.selectOptions)
|
|
845
|
+
row.activate();
|
|
846
|
+
}
|
|
847
|
+
function focusSetupSectionTarget(section, direction = 1) {
|
|
848
|
+
const previous = setupSectionSelections.current[`${setupSelectionScope}:${section}`];
|
|
849
|
+
if (section === 'actions') {
|
|
850
|
+
const preferred = previous ?? (direction < 0 ? 'next' : 'back');
|
|
851
|
+
setFocusedAction(preferred === 'next' && canContinue ? 'next' : 'back');
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
setFocusedAction(undefined);
|
|
855
|
+
if (section === 'categories') {
|
|
856
|
+
setSettingsFocus('categories');
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
const candidates = setupSectionRows[section] ?? [];
|
|
860
|
+
const rowId = previous?.startsWith('browse:') ? previous.slice('browse:'.length) : previous;
|
|
861
|
+
const target = candidates.find((index) => rows[index]?.id === rowId) ?? candidates[0];
|
|
862
|
+
if (target === undefined)
|
|
863
|
+
return;
|
|
864
|
+
selectWizardRow(target);
|
|
865
|
+
if (previous?.startsWith('browse:') && directoryRows.has(target))
|
|
866
|
+
setFocusedAction(`browse:${target}`);
|
|
867
|
+
}
|
|
868
|
+
function focusSetupSection(direction) {
|
|
869
|
+
const current = Math.max(0, setupSections.indexOf(focusedSetupSection));
|
|
870
|
+
const target = setupSections[(current + direction + setupSections.length) % setupSections.length];
|
|
871
|
+
if (target)
|
|
872
|
+
focusSetupSectionTarget(target, direction);
|
|
873
|
+
}
|
|
874
|
+
function selectSettingsCategory(category) {
|
|
875
|
+
setSettingsCategory(category);
|
|
876
|
+
setSettingsFocus('categories');
|
|
877
|
+
setSelection(0);
|
|
878
|
+
setFocusedAction(undefined);
|
|
879
|
+
}
|
|
880
|
+
function paginateModels(direction) {
|
|
881
|
+
const lastPageStart = Math.max(0, filteredProviderModels.length - quickstartModelCapacity);
|
|
882
|
+
const nextStart = Math.max(0, Math.min(lastPageStart, quickstartModelViewportStart + direction * quickstartModelCapacity));
|
|
883
|
+
setModelViewportStart(nextStart);
|
|
884
|
+
setProviderDetailSection('models');
|
|
885
|
+
setSelection(quickstartModelOffset + nextStart);
|
|
886
|
+
setModelSearchFocused(false);
|
|
887
|
+
setFocusedAction(undefined);
|
|
888
|
+
}
|
|
889
|
+
function browseForDirectory(field) {
|
|
890
|
+
if (choosingDirectoryRef.current) {
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
choosingDirectoryRef.current = true;
|
|
894
|
+
setChoosingDirectory(true);
|
|
895
|
+
setEditing(undefined);
|
|
896
|
+
setError(undefined);
|
|
897
|
+
const selection = field === 'importPath'
|
|
898
|
+
? chooseAgentProject()
|
|
899
|
+
: chooseDirectory(field === 'memoryDir' ? 'Choose a directory for agent memory' : 'Choose a directory containing agent skills');
|
|
900
|
+
void selection
|
|
901
|
+
.then((path) => {
|
|
902
|
+
if (!path)
|
|
903
|
+
return;
|
|
904
|
+
if (field === 'importPath') {
|
|
905
|
+
setImportPath(path);
|
|
906
|
+
setSelection(0);
|
|
907
|
+
}
|
|
908
|
+
else {
|
|
909
|
+
updateProfile(field === 'skills' ? { skills: [path] } : { memory: memoryForDir(path) });
|
|
910
|
+
}
|
|
911
|
+
})
|
|
912
|
+
.catch((cause) => {
|
|
913
|
+
setError(errorMessage(cause));
|
|
914
|
+
})
|
|
915
|
+
.finally(() => {
|
|
916
|
+
choosingDirectoryRef.current = false;
|
|
917
|
+
setChoosingDirectory(false);
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
function chooseFlow(nextFlow) {
|
|
921
|
+
panelTransition.transition(() => {
|
|
922
|
+
setHoveredControl(undefined);
|
|
923
|
+
setFocusedAction(undefined);
|
|
924
|
+
setModelQuery('');
|
|
925
|
+
setModelSearchFocused(false);
|
|
926
|
+
setProviderDetailSection('models');
|
|
927
|
+
setFlow(nextFlow);
|
|
928
|
+
setStep(1);
|
|
929
|
+
setError(undefined);
|
|
930
|
+
if (nextFlow !== 'import') {
|
|
931
|
+
const provider = providerFromModel(draft.profile.model) ?? 'bedrock';
|
|
932
|
+
if (nextFlow === 'quickstart') {
|
|
933
|
+
const next = quickstartDraft(draft.profile.model);
|
|
934
|
+
setDraft({ ...next, profile: { ...next.profile, modelModule: draft.profile.modelModule } });
|
|
935
|
+
}
|
|
936
|
+
setQuickstartProvider(provider);
|
|
937
|
+
setSelection(PROVIDER_IDS.indexOf(provider));
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
setSelection(0);
|
|
941
|
+
setImportPath('');
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
function completeSetup(completedDraft = draft, agentProject) {
|
|
946
|
+
let saved;
|
|
947
|
+
setSaving(true);
|
|
948
|
+
if (agentProject) {
|
|
949
|
+
const configuration = {
|
|
950
|
+
...configurationFromStore(config),
|
|
951
|
+
providerEnvironment,
|
|
952
|
+
settings: { ...panelSettings, ...completedDraft.settings, ...appearance },
|
|
953
|
+
};
|
|
954
|
+
if (deferred) {
|
|
955
|
+
onComplete({
|
|
956
|
+
configuration,
|
|
957
|
+
agentProject,
|
|
958
|
+
});
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
saved = config.saveSetup(configuration, { agentProject });
|
|
962
|
+
}
|
|
963
|
+
else {
|
|
964
|
+
setError(undefined);
|
|
965
|
+
const configuration = {
|
|
966
|
+
providers: completedDraft.providers,
|
|
967
|
+
profile: compatibleProfile(completedDraft.profile),
|
|
968
|
+
...(profileBaseDir !== undefined ? { profileBaseDir } : {}),
|
|
969
|
+
permissionMode: completedDraft.permissionMode,
|
|
970
|
+
allowedTools: completedDraft.customPermissions || completedDraft.permissionMode === 'bypassPermissions'
|
|
971
|
+
? completedDraft.allowedTools
|
|
972
|
+
: [],
|
|
973
|
+
providerEnvironment,
|
|
974
|
+
settings: { ...panelSettings, ...completedDraft.settings, ...appearance },
|
|
975
|
+
};
|
|
976
|
+
if (deferred) {
|
|
977
|
+
onComplete({ configuration });
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
saved = config.saveSetup(configuration);
|
|
981
|
+
}
|
|
982
|
+
void saved
|
|
983
|
+
.then(() => onComplete())
|
|
984
|
+
.catch((cause) => {
|
|
985
|
+
setSaving(false);
|
|
986
|
+
setError(errorMessage(cause));
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
function continueFlow() {
|
|
990
|
+
if (editing || selecting || saving) {
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
if (step === 0) {
|
|
994
|
+
chooseFlow(OPENING_CHOICES[selection].id);
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
if (flow === 'import') {
|
|
998
|
+
try {
|
|
999
|
+
const imported = importAgentProject(importPath);
|
|
1000
|
+
completeSetup(draft, imported.entrypoint);
|
|
1001
|
+
}
|
|
1002
|
+
catch (cause) {
|
|
1003
|
+
setError(errorMessage(cause));
|
|
1004
|
+
}
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
if (!canContinue) {
|
|
1008
|
+
setError(setupReadyProviders.includes(quickstartProvider)
|
|
1009
|
+
? 'Select an available model to continue.'
|
|
1010
|
+
: 'Select a provider with detected credentials; follow the provider setup instructions.');
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
if (flow === 'quickstart') {
|
|
1014
|
+
const provider = providerFromModel(draft.profile.model);
|
|
1015
|
+
if (!provider || !readyProviders.includes(provider)) {
|
|
1016
|
+
setError('The selected model provider needs setup.');
|
|
1017
|
+
panelTransition.transition(() => setStep(1));
|
|
1018
|
+
return;
|
|
1019
|
+
}
|
|
1020
|
+
const completedDraft = {
|
|
1021
|
+
...draft,
|
|
1022
|
+
providers: [provider, ...draft.providers.filter((candidate) => candidate !== provider)],
|
|
1023
|
+
};
|
|
1024
|
+
setDraft(completedDraft);
|
|
1025
|
+
completeSetup(completedDraft);
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
if (step < CUSTOMIZE_STEPS.length) {
|
|
1029
|
+
panelTransition.transition(() => {
|
|
1030
|
+
setStep((current) => current + 1);
|
|
1031
|
+
setFocusedAction(undefined);
|
|
1032
|
+
setSelection(0);
|
|
1033
|
+
setError(undefined);
|
|
1034
|
+
setModelSearchFocused(false);
|
|
1035
|
+
});
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
const selectedProvider = providerFromModel(draft.profile.model);
|
|
1039
|
+
if (selectedProvider && !readyProviders.includes(selectedProvider)) {
|
|
1040
|
+
setError('The selected model provider needs setup.');
|
|
1041
|
+
panelTransition.transition(() => {
|
|
1042
|
+
setStep(1);
|
|
1043
|
+
setSelection(PROVIDER_IDS.indexOf(selectedProvider));
|
|
1044
|
+
});
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
completeSetup();
|
|
1048
|
+
}
|
|
1049
|
+
function moveBack() {
|
|
1050
|
+
if (editing || selecting || saving) {
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
setFocusedAction(undefined);
|
|
1054
|
+
if (isSettings && settingsReturn) {
|
|
1055
|
+
const destination = settingsReturn;
|
|
1056
|
+
panelTransition.transition(() => {
|
|
1057
|
+
setFlow(destination.flow);
|
|
1058
|
+
setStep(destination.step);
|
|
1059
|
+
setSelection(destination.selection);
|
|
1060
|
+
setSettingsReturn(undefined);
|
|
1061
|
+
setError(undefined);
|
|
1062
|
+
});
|
|
1063
|
+
return;
|
|
1064
|
+
}
|
|
1065
|
+
if (step <= 1) {
|
|
1066
|
+
if (step === 0) {
|
|
1067
|
+
onCancel?.(0);
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
panelTransition.transition(() => {
|
|
1071
|
+
setFlow(undefined);
|
|
1072
|
+
setStep(0);
|
|
1073
|
+
setSelection(0);
|
|
1074
|
+
setError(undefined);
|
|
1075
|
+
});
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
panelTransition.transition(() => {
|
|
1079
|
+
setStep((current) => current - 1);
|
|
1080
|
+
setSelection(step === 2 ? PROVIDER_IDS.indexOf(quickstartProvider) : 0);
|
|
1081
|
+
setError(undefined);
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
function openSettings() {
|
|
1085
|
+
if (isSettings) {
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
leaveEdit();
|
|
1089
|
+
setSelecting(undefined);
|
|
1090
|
+
panelTransition.transition(() => {
|
|
1091
|
+
setSettingsReturn({ flow, step, selection });
|
|
1092
|
+
setSettingsCategory(DEFAULT_SETTINGS_CATEGORY);
|
|
1093
|
+
setSettingsFocus('settings');
|
|
1094
|
+
setStep(SETTINGS_STEP);
|
|
1095
|
+
setSelection(0);
|
|
1096
|
+
setFocusedAction(undefined);
|
|
1097
|
+
setError(undefined);
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
function commitEdit() {
|
|
1101
|
+
if (!editing) {
|
|
1102
|
+
return true;
|
|
1103
|
+
}
|
|
1104
|
+
const value = editing.value.trim() || (editing.field === 'name' ? DEFAULT_HARNESS_AGENT_CONFIG.name : '');
|
|
1105
|
+
if (isProviderEnvironmentKey(editing.field)) {
|
|
1106
|
+
if (PROVIDER_CREDENTIAL_KEYS.includes(editing.field)) {
|
|
1107
|
+
if (!value) {
|
|
1108
|
+
setError('API key cannot be empty.');
|
|
1109
|
+
return false;
|
|
1110
|
+
}
|
|
1111
|
+
try {
|
|
1112
|
+
config.setSessionProviderCredential(editing.field, value);
|
|
1113
|
+
recheck();
|
|
1114
|
+
}
|
|
1115
|
+
catch (cause) {
|
|
1116
|
+
setError(errorMessage(cause));
|
|
1117
|
+
return false;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
else {
|
|
1121
|
+
setProviderValue(editing.field, value);
|
|
1122
|
+
focusNextProviderField(editing.field);
|
|
1123
|
+
}
|
|
1124
|
+
setEditing(undefined);
|
|
1125
|
+
setError(undefined);
|
|
1126
|
+
return true;
|
|
1127
|
+
}
|
|
1128
|
+
if (!value && editing.field !== 'instructions') {
|
|
1129
|
+
setError('This field cannot be empty.');
|
|
1130
|
+
return false;
|
|
1131
|
+
}
|
|
1132
|
+
if (editing.field === 'importPath') {
|
|
1133
|
+
setImportPath(value);
|
|
1134
|
+
}
|
|
1135
|
+
else if (editing.field === 'memoryDir') {
|
|
1136
|
+
updateProfile({ memory: memoryForDir(value) });
|
|
1137
|
+
}
|
|
1138
|
+
else if (editing.field === 'skills') {
|
|
1139
|
+
const paths = value
|
|
1140
|
+
.split(',')
|
|
1141
|
+
.map((path) => path.trim())
|
|
1142
|
+
.filter(Boolean);
|
|
1143
|
+
// No directories keeps the library default (`true`) rather than turning skills off.
|
|
1144
|
+
updateProfile({ skills: paths.length === 0 ? true : paths });
|
|
1145
|
+
}
|
|
1146
|
+
else {
|
|
1147
|
+
updateProfile({ [editing.field]: value });
|
|
1148
|
+
}
|
|
1149
|
+
setEditing(undefined);
|
|
1150
|
+
setError(undefined);
|
|
1151
|
+
return true;
|
|
1152
|
+
}
|
|
1153
|
+
function leaveEdit() {
|
|
1154
|
+
setEditing(undefined);
|
|
1155
|
+
setError(undefined);
|
|
1156
|
+
}
|
|
1157
|
+
function applyPathCompletion(index = pathCompletionIndex < 0 ? 0 : pathCompletionIndex) {
|
|
1158
|
+
const completion = pathCompletions[index];
|
|
1159
|
+
if (!completion || !pathEditing) {
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
setEditing({
|
|
1163
|
+
...pathEditing,
|
|
1164
|
+
value: completion.value,
|
|
1165
|
+
cursor: graphemes(completion.value).length,
|
|
1166
|
+
});
|
|
1167
|
+
setError(undefined);
|
|
1168
|
+
}
|
|
1169
|
+
function activateRow(index) {
|
|
1170
|
+
if (step === 0) {
|
|
1171
|
+
chooseFlow(OPENING_CHOICES[index].id);
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
if (isImport && index === 1) {
|
|
1175
|
+
browseForDirectory('importPath');
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1178
|
+
if (isProviderSetup && index >= quickstartModelOffset) {
|
|
1179
|
+
const model = filteredProviderModels[index - quickstartModelOffset];
|
|
1180
|
+
if (!model) {
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
providerSectionSelections.current.models = model.id;
|
|
1184
|
+
const modelSpecifier = `${quickstartProvider}/${model.id}`;
|
|
1185
|
+
const profile = quickstartDraft(modelSpecifier).profile;
|
|
1186
|
+
if (draft.profile.model === modelSpecifier && deselectedModel !== modelSpecifier) {
|
|
1187
|
+
setDeselectedModel(modelSpecifier);
|
|
1188
|
+
setError(undefined);
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
setDeselectedModel(undefined);
|
|
1192
|
+
setDraft((current) => ({
|
|
1193
|
+
...current,
|
|
1194
|
+
providers: [quickstartProvider, ...current.providers.filter((provider) => provider !== quickstartProvider)],
|
|
1195
|
+
profile: compatibleProfile({
|
|
1196
|
+
...current.profile,
|
|
1197
|
+
effort: profile.effort,
|
|
1198
|
+
caching: profile.caching,
|
|
1199
|
+
model: modelSpecifier,
|
|
1200
|
+
modelModule: null,
|
|
1201
|
+
}),
|
|
1202
|
+
}));
|
|
1203
|
+
setError(undefined);
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1206
|
+
if (isProviderSetup && index < PROVIDER_IDS.length && !readyProviders.includes(PROVIDER_IDS[index])) {
|
|
1207
|
+
const fieldIndex = rows.findIndex((row) => row.field !== undefined && row.input === true);
|
|
1208
|
+
const field = rows[fieldIndex];
|
|
1209
|
+
if (fieldIndex >= PROVIDER_IDS.length && field) {
|
|
1210
|
+
setSelection(fieldIndex);
|
|
1211
|
+
field.activate();
|
|
1212
|
+
}
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
const row = rows[index];
|
|
1216
|
+
if (!row || row.disabled) {
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
if (editing && editing.field === row.field) {
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
if (flow === 'customize' && step === CUSTOMIZE_STEPS.length) {
|
|
1223
|
+
const destination = [1, 2, 1, 3, 4, 5, 6][index];
|
|
1224
|
+
panelTransition.transition(() => {
|
|
1225
|
+
setStep(destination);
|
|
1226
|
+
setSelection(destination === 1 ? PROVIDER_IDS.indexOf(quickstartProvider) : 0);
|
|
1227
|
+
setFocusedAction(undefined);
|
|
1228
|
+
});
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
if (row.choices?.length) {
|
|
1232
|
+
const selected = row.choices.findIndex((choice) => choice.active);
|
|
1233
|
+
row.choices[(selected + 1) % row.choices.length].activate();
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
if (row.selectOptions && row.field && isProviderEnvironmentKey(row.field)) {
|
|
1237
|
+
const current = row.field === 'AWS_PROFILE'
|
|
1238
|
+
? (providerEnvironment.AWS_PROFILE ?? '')
|
|
1239
|
+
: (providerEnvironment[row.field] ?? effectiveEnvironment[row.field]?.value);
|
|
1240
|
+
const selected = Math.max(0, row.selectOptions.findIndex((option) => !option.custom && option.value === current));
|
|
1241
|
+
setSelecting({ field: row.field, options: row.selectOptions, selection: selected });
|
|
1242
|
+
setEditing(undefined);
|
|
1243
|
+
return;
|
|
1244
|
+
}
|
|
1245
|
+
row.activate();
|
|
1246
|
+
}
|
|
1247
|
+
useEffect(() => {
|
|
1248
|
+
setTerminalMouseMotion(true, stdout);
|
|
1249
|
+
return () => setTerminalMouseMotion(false, stdout);
|
|
1250
|
+
}, [stdout]);
|
|
1251
|
+
useEffect(() => {
|
|
1252
|
+
hoverPointer.current = undefined;
|
|
1253
|
+
setHoveredControl(undefined);
|
|
1254
|
+
pressedElement.current = undefined;
|
|
1255
|
+
}, [step, flow, quickstartProvider, selecting?.field, modelViewportStart]);
|
|
1256
|
+
useEffect(() => {
|
|
1257
|
+
pressedElement.current = undefined;
|
|
1258
|
+
frogPress.current = undefined;
|
|
1259
|
+
const mouse = hoverPointer.current;
|
|
1260
|
+
if (step !== 0 || !mouse) {
|
|
1261
|
+
setHoveredControl(undefined);
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
const row = elementAtMouse(rowElements.current, mouse);
|
|
1265
|
+
const settings = settingsElement.current && elementContainsMouse(settingsElement.current, mouse);
|
|
1266
|
+
const escapeHint = escapeHintElement.current && elementContainsMouse(escapeHintElement.current, mouse);
|
|
1267
|
+
setHoveredControl(row ?? (settings ? 'settings' : escapeHint ? 'escape' : undefined));
|
|
1268
|
+
}, [width, height]);
|
|
1269
|
+
useEffect(() => {
|
|
1270
|
+
if (isProviderSetup && !modelPanelVisible && (modelSearchFocused || selection >= quickstartModelOffset)) {
|
|
1271
|
+
selectWizardRow(PROVIDER_IDS.indexOf(quickstartProvider));
|
|
1272
|
+
}
|
|
1273
|
+
}, [
|
|
1274
|
+
isProviderSetup,
|
|
1275
|
+
modelPanelVisible,
|
|
1276
|
+
modelSearchFocused,
|
|
1277
|
+
selection,
|
|
1278
|
+
quickstartModelOffset,
|
|
1279
|
+
quickstartProvider,
|
|
1280
|
+
selectWizardRow,
|
|
1281
|
+
]);
|
|
1282
|
+
useProviderDiscoveryEffects(discovery, isProviderSetup, quickstartProvider);
|
|
1283
|
+
useEffect(() => {
|
|
1284
|
+
if (!isProviderSetup || awsDiscovery.credentialStatus === undefined || !ollamaDiscovery) {
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
setDraft((current) => {
|
|
1288
|
+
const providers = [
|
|
1289
|
+
...current.providers.filter((provider) => !config.needsSetup() || readyProviders.includes(provider)),
|
|
1290
|
+
...readyProviders.filter((provider) => !current.providers.includes(provider)),
|
|
1291
|
+
];
|
|
1292
|
+
const sameProviders = providers.length === current.providers.length &&
|
|
1293
|
+
providers.every((provider, index) => provider === current.providers[index]);
|
|
1294
|
+
const modelProvider = providerFromModel(current.profile.model);
|
|
1295
|
+
let profile = current.profile;
|
|
1296
|
+
const environmentModel = quickstartProvider === 'ollama'
|
|
1297
|
+
? effectiveEnvironment.OLLAMA_MODEL?.value
|
|
1298
|
+
: quickstartProvider === 'litellm'
|
|
1299
|
+
? effectiveEnvironment.LITELLM_MODEL?.value
|
|
1300
|
+
: undefined;
|
|
1301
|
+
const discoveredModel = providerModels.provider === quickstartProvider
|
|
1302
|
+
? providerModels.models.find(({ id }) => id === environmentModel ||
|
|
1303
|
+
(quickstartProvider === 'ollama' &&
|
|
1304
|
+
id.replace(/:latest$/, '') === environmentModel?.replace(/:latest$/, '')))
|
|
1305
|
+
: undefined;
|
|
1306
|
+
if (config.needsSetup() && modelProvider !== quickstartProvider && discoveredModel) {
|
|
1307
|
+
const defaults = quickstartDraft(`${quickstartProvider}/${discoveredModel.id}`).profile;
|
|
1308
|
+
profile = compatibleProfile({
|
|
1309
|
+
...profile,
|
|
1310
|
+
model: defaults.model,
|
|
1311
|
+
modelModule: null,
|
|
1312
|
+
effort: defaults.effort,
|
|
1313
|
+
caching: defaults.caching,
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
if (sameProviders && profile === current.profile) {
|
|
1317
|
+
return current;
|
|
1318
|
+
}
|
|
1319
|
+
return { ...current, providers, profile };
|
|
1320
|
+
});
|
|
1321
|
+
}, [
|
|
1322
|
+
awsDiscovery.credentialStatus,
|
|
1323
|
+
config,
|
|
1324
|
+
effectiveEnvironment,
|
|
1325
|
+
isProviderSetup,
|
|
1326
|
+
ollamaDiscovery,
|
|
1327
|
+
providerModels,
|
|
1328
|
+
quickstartProvider,
|
|
1329
|
+
readyProviders,
|
|
1330
|
+
]);
|
|
1331
|
+
const frogClockMs = useBrandAnimation(frogAnimationId);
|
|
1332
|
+
const frogElapsedMs = useBrandAnimationFrame(frogClockMs, brandFrame.width, brandFrame.height);
|
|
1333
|
+
useInput((input, key) => {
|
|
1334
|
+
if (panelTransition.transitioning)
|
|
1335
|
+
return;
|
|
1336
|
+
const mouse = parseMouseInput(input);
|
|
1337
|
+
if (mouse) {
|
|
1338
|
+
hoverPointer.current = mouse;
|
|
1339
|
+
const scroll = mouseScrollDirection(mouse);
|
|
1340
|
+
if (scroll !== undefined) {
|
|
1341
|
+
hoverPointer.current = undefined;
|
|
1342
|
+
setHoveredControl(undefined);
|
|
1343
|
+
if (isProviderSetup &&
|
|
1344
|
+
providerListElement.current &&
|
|
1345
|
+
elementContainsMouse(providerListElement.current, mouse)) {
|
|
1346
|
+
const current = PROVIDER_IDS.indexOf(quickstartProvider);
|
|
1347
|
+
const target = providerRows[Math.max(0, Math.min(providerRows.length - 1, current + scroll))];
|
|
1348
|
+
if (target)
|
|
1349
|
+
selectWizardRow(rows.indexOf(target));
|
|
1350
|
+
}
|
|
1351
|
+
else if (isProviderSetup &&
|
|
1352
|
+
connectionFieldsElement.current &&
|
|
1353
|
+
elementContainsMouse(connectionFieldsElement.current, mouse)) {
|
|
1354
|
+
if (selecting)
|
|
1355
|
+
return;
|
|
1356
|
+
const candidates = providerSectionRows.models.filter((index) => !rows[index]?.disabled);
|
|
1357
|
+
const current = Math.max(0, candidates.findIndex((index) => rows[index]?.id === providerSectionSelections.current.models));
|
|
1358
|
+
const target = candidates[Math.max(0, Math.min(candidates.length - 1, current + scroll))];
|
|
1359
|
+
if (target !== undefined) {
|
|
1360
|
+
leaveEdit();
|
|
1361
|
+
selectWizardRow(target);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
else if (isProviderSetup &&
|
|
1365
|
+
modelOptionsElement.current &&
|
|
1366
|
+
elementContainsMouse(modelOptionsElement.current, mouse)) {
|
|
1367
|
+
if (selecting)
|
|
1368
|
+
return;
|
|
1369
|
+
const candidates = providerSectionRows.options;
|
|
1370
|
+
const current = Math.max(0, candidates.findIndex((index) => rows[index]?.id === providerSectionSelections.current.options));
|
|
1371
|
+
const target = candidates[Math.max(0, Math.min(candidates.length - 1, current + scroll))];
|
|
1372
|
+
if (target !== undefined)
|
|
1373
|
+
selectWizardRow(target);
|
|
1374
|
+
}
|
|
1375
|
+
else if (isProviderSetup &&
|
|
1376
|
+
modelListElement.current &&
|
|
1377
|
+
elementContainsMouse(modelListElement.current, mouse)) {
|
|
1378
|
+
setModelViewportStart((start) => scrollPanelViewport(start, scroll, filteredProviderModels.length, quickstartModelCapacity));
|
|
1379
|
+
}
|
|
1380
|
+
else if (isSettings) {
|
|
1381
|
+
const target = elementAtMouse(choiceElements.current, mouse);
|
|
1382
|
+
if (target?.startsWith('category:') ||
|
|
1383
|
+
(settingsCategoriesElement.current && elementContainsMouse(settingsCategoriesElement.current, mouse))) {
|
|
1384
|
+
const current = SETTINGS_CATEGORIES.findIndex(({ id }) => id === settingsCategory);
|
|
1385
|
+
const category = SETTINGS_CATEGORIES[Math.max(0, Math.min(SETTINGS_CATEGORIES.length - 1, current + scroll))];
|
|
1386
|
+
if (category)
|
|
1387
|
+
selectSettingsCategory(category.id);
|
|
1388
|
+
}
|
|
1389
|
+
else {
|
|
1390
|
+
selectWizardRow(scrollPanelViewport(selection, scroll, rows.length, 1));
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
else if (!isProviderSetup && (flow === 'customize' || isImport)) {
|
|
1394
|
+
const pointedRow = elementAtMouse(rowElements.current, mouse);
|
|
1395
|
+
const section = setupRowSection(flow, step, rows[pointedRow ?? selection]);
|
|
1396
|
+
const candidates = setupSectionRows[section] ?? [];
|
|
1397
|
+
const current = Math.max(0, candidates.indexOf(selection));
|
|
1398
|
+
const target = candidates[Math.max(0, Math.min(candidates.length - 1, current + scroll))];
|
|
1399
|
+
if (target !== undefined) {
|
|
1400
|
+
leaveEdit();
|
|
1401
|
+
selectWizardRow(target);
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
else if (flow === 'customize') {
|
|
1405
|
+
setFocusedAction(undefined);
|
|
1406
|
+
setSelection((current) => scrollPanelViewport(current, scroll, rows.length, 1));
|
|
1407
|
+
}
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
const selectOption = elementAtMouse(selectOptionElements.current, mouse);
|
|
1411
|
+
const choice = elementAtMouse(choiceElements.current, mouse);
|
|
1412
|
+
const pathCompletion = elementAtMouse(pathCompletionElements.current, mouse);
|
|
1413
|
+
const directory = elementAtMouse(directoryElements.current, mouse);
|
|
1414
|
+
const row = elementAtMouse(rowElements.current, mouse);
|
|
1415
|
+
const back = backElement.current ? elementContainsMouse(backElement.current, mouse) : false;
|
|
1416
|
+
const next = nextElement.current ? elementContainsMouse(nextElement.current, mouse) : false;
|
|
1417
|
+
const settings = settingsElement.current ? elementContainsMouse(settingsElement.current, mouse) : false;
|
|
1418
|
+
const escapeHint = escapeHintElement.current ? elementContainsMouse(escapeHintElement.current, mouse) : false;
|
|
1419
|
+
const frog = frogElement.current ? elementContainsMouse(frogElement.current, mouse) : false;
|
|
1420
|
+
const search = modelSearchElement.current ? elementContainsMouse(modelSearchElement.current, mouse) : false;
|
|
1421
|
+
const modelSection = modelSectionElement.current
|
|
1422
|
+
? elementContainsMouse(modelSectionElement.current, mouse)
|
|
1423
|
+
: false;
|
|
1424
|
+
const optionsSection = optionsSectionElement.current
|
|
1425
|
+
? elementContainsMouse(optionsSectionElement.current, mouse)
|
|
1426
|
+
: false;
|
|
1427
|
+
const modelsPrevious = previousModelCount > 0 && modelPreviousElement.current
|
|
1428
|
+
? elementContainsMouse(modelPreviousElement.current, mouse)
|
|
1429
|
+
: false;
|
|
1430
|
+
const modelsNext = nextModelCount > 0 && modelNextElement.current ? elementContainsMouse(modelNextElement.current, mouse) : false;
|
|
1431
|
+
const effortSliderHit = setupEffortSliderElement.current
|
|
1432
|
+
? elementContainsMouse(setupEffortSliderElement.current, mouse)
|
|
1433
|
+
: false;
|
|
1434
|
+
const target = modelSection || optionsSection
|
|
1435
|
+
? modelSection
|
|
1436
|
+
? 'section:models'
|
|
1437
|
+
: 'section:options'
|
|
1438
|
+
: modelsPrevious || modelsNext
|
|
1439
|
+
? modelsPrevious
|
|
1440
|
+
? 'models-previous'
|
|
1441
|
+
: 'models-next'
|
|
1442
|
+
: ((pathCompletion !== undefined ? `completion:${pathCompletion}` : undefined) ??
|
|
1443
|
+
(directory !== undefined ? `browse:${directory}` : undefined) ??
|
|
1444
|
+
choice ??
|
|
1445
|
+
(selectOption !== undefined
|
|
1446
|
+
? `option:${selectOption}`
|
|
1447
|
+
: row !== undefined && !rows[row]?.disabled && !(isImport && row === 1 && choosingDirectory)
|
|
1448
|
+
? row
|
|
1449
|
+
: back
|
|
1450
|
+
? 'back'
|
|
1451
|
+
: next && canContinue
|
|
1452
|
+
? 'next'
|
|
1453
|
+
: settings
|
|
1454
|
+
? 'settings'
|
|
1455
|
+
: escapeHint
|
|
1456
|
+
? 'escape'
|
|
1457
|
+
: search
|
|
1458
|
+
? 'search'
|
|
1459
|
+
: undefined));
|
|
1460
|
+
if (saving || choosingDirectory) {
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
if (mouse.action === 'press' && (mouse.button & 3) === 0) {
|
|
1464
|
+
if (editing &&
|
|
1465
|
+
!(typeof target === 'string' && target.startsWith('completion:')) &&
|
|
1466
|
+
(target === undefined || typeof target !== 'number' || rows[target]?.field !== editing.field)) {
|
|
1467
|
+
leaveEdit();
|
|
1468
|
+
}
|
|
1469
|
+
if (selecting && selectOption === undefined) {
|
|
1470
|
+
setSelecting(undefined);
|
|
1471
|
+
}
|
|
1472
|
+
if (effortSliderHit && reasoningSlider && reasoningRow?.choices) {
|
|
1473
|
+
pressedElement.current = undefined;
|
|
1474
|
+
const option = sliderOptionAtMouse(reasoningSlider, setupEffortSliderElement.current, mouse);
|
|
1475
|
+
const choice = option ? reasoningRow.choices[Number(option.id)] : undefined;
|
|
1476
|
+
if (choice) {
|
|
1477
|
+
choice.activate();
|
|
1478
|
+
selectWizardRow(reasoningRowIndex);
|
|
1479
|
+
}
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1482
|
+
frogPress.current = frog ? { column: mouse.column, row: mouse.row } : undefined;
|
|
1483
|
+
pressedElement.current = target;
|
|
1484
|
+
if (selectOption !== undefined && selecting) {
|
|
1485
|
+
setSelecting({ ...selecting, selection: selectOption });
|
|
1486
|
+
}
|
|
1487
|
+
else if (pathCompletion !== undefined) {
|
|
1488
|
+
setPathCompletionIndex(pathCompletion);
|
|
1489
|
+
}
|
|
1490
|
+
else if (typeof target === 'number') {
|
|
1491
|
+
selectWizardRow(target);
|
|
1492
|
+
}
|
|
1493
|
+
else if (typeof target === 'string' && target.startsWith('browse:')) {
|
|
1494
|
+
selectWizardRow(directory);
|
|
1495
|
+
setFocusedAction(`browse:${directory}`);
|
|
1496
|
+
}
|
|
1497
|
+
else if (target === 'back' || target === 'next' || target === 'escape' || target === 'settings') {
|
|
1498
|
+
setFocusedAction(target);
|
|
1499
|
+
setModelSearchFocused(false);
|
|
1500
|
+
}
|
|
1501
|
+
else if (target === 'search') {
|
|
1502
|
+
setProviderDetailSection('models');
|
|
1503
|
+
setModelSearchFocused(true);
|
|
1504
|
+
setFocusedAction(undefined);
|
|
1505
|
+
setEditing(undefined);
|
|
1506
|
+
}
|
|
1507
|
+
else if (target === 'models-previous' || target === 'models-next') {
|
|
1508
|
+
pressedElement.current = undefined;
|
|
1509
|
+
paginateModels(target === 'models-previous' ? -1 : 1);
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1512
|
+
else if (choice?.startsWith('choice:')) {
|
|
1513
|
+
selectWizardRow(Number(choice.split(':')[1]));
|
|
1514
|
+
}
|
|
1515
|
+
else if (choice?.startsWith('category:')) {
|
|
1516
|
+
setSettingsFocus('categories');
|
|
1517
|
+
setFocusedAction(undefined);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
else if (mouse.action === 'release') {
|
|
1521
|
+
const frogClicked = frog && frogPress.current?.column === mouse.column && frogPress.current?.row === mouse.row;
|
|
1522
|
+
frogPress.current = undefined;
|
|
1523
|
+
const pressed = pressedElement.current;
|
|
1524
|
+
pressedElement.current = undefined;
|
|
1525
|
+
if (frogClicked && appearance.animations) {
|
|
1526
|
+
setFrogAnimationId((current) => (current ?? 0) + 1);
|
|
1527
|
+
}
|
|
1528
|
+
else if (directory !== undefined && pressed === `browse:${directory}` && directoryRows.has(directory)) {
|
|
1529
|
+
browseForDirectory(directoryRows.get(directory));
|
|
1530
|
+
}
|
|
1531
|
+
else if (typeof pressed === 'string' && pressed.startsWith('choice:') && pressed === choice) {
|
|
1532
|
+
const [, rowIndex, choiceIndex] = pressed.split(':');
|
|
1533
|
+
rows[Number(rowIndex)]?.choices?.[Number(choiceIndex)]?.activate();
|
|
1534
|
+
}
|
|
1535
|
+
else if (typeof pressed === 'string' && pressed.startsWith('category:') && pressed === choice) {
|
|
1536
|
+
selectSettingsCategory(pressed.slice('category:'.length));
|
|
1537
|
+
}
|
|
1538
|
+
else if (typeof pressed === 'string' && pressed.startsWith('option:')) {
|
|
1539
|
+
const optionIndex = Number(pressed.slice('option:'.length));
|
|
1540
|
+
const option = selecting?.options[optionIndex];
|
|
1541
|
+
if (selectOption === optionIndex && option) {
|
|
1542
|
+
chooseSelectOption(option);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
else if (typeof pressed === 'string' && pressed.startsWith('completion:')) {
|
|
1546
|
+
const completionIndex = Number(pressed.slice('completion:'.length));
|
|
1547
|
+
if (pathCompletion === completionIndex) {
|
|
1548
|
+
applyPathCompletion(completionIndex);
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
else if (typeof pressed === 'number' && pressed === row && (!isSettings || !rows[pressed]?.choices?.length)) {
|
|
1552
|
+
activateRow(pressed);
|
|
1553
|
+
}
|
|
1554
|
+
else if (pressed === 'back' && back) {
|
|
1555
|
+
moveBack();
|
|
1556
|
+
}
|
|
1557
|
+
else if (pressed === 'next' && next) {
|
|
1558
|
+
continueFlow();
|
|
1559
|
+
}
|
|
1560
|
+
else if (pressed === 'settings' && settings) {
|
|
1561
|
+
if (isSettings)
|
|
1562
|
+
moveBack();
|
|
1563
|
+
else
|
|
1564
|
+
openSettings();
|
|
1565
|
+
}
|
|
1566
|
+
else if (pressed === 'escape' && escapeHint) {
|
|
1567
|
+
moveBack();
|
|
1568
|
+
}
|
|
1569
|
+
else if (pressed === 'section:models' && modelSection) {
|
|
1570
|
+
focusProviderSectionTarget('models');
|
|
1571
|
+
}
|
|
1572
|
+
else if (pressed === 'section:options' && optionsSection) {
|
|
1573
|
+
focusProviderSectionTarget('options');
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
else if (mouse.action === 'move') {
|
|
1577
|
+
// Opening cards have no hover fill; pointing at one selects it.
|
|
1578
|
+
if (step === 0 && typeof target === 'number') {
|
|
1579
|
+
selectWizardRow(target);
|
|
1580
|
+
}
|
|
1581
|
+
setHoveredControl(isCapabilities && row !== undefined ? row : target);
|
|
1582
|
+
}
|
|
1583
|
+
return;
|
|
1584
|
+
}
|
|
1585
|
+
hoverPointer.current = undefined;
|
|
1586
|
+
if (key.ctrl && input === 'c') {
|
|
1587
|
+
onCancel?.(130);
|
|
1588
|
+
return;
|
|
1589
|
+
}
|
|
1590
|
+
if (key.ctrl && input === 's') {
|
|
1591
|
+
if (isSettings)
|
|
1592
|
+
moveBack();
|
|
1593
|
+
else
|
|
1594
|
+
openSettings();
|
|
1595
|
+
return;
|
|
1596
|
+
}
|
|
1597
|
+
setHoveredControl(undefined);
|
|
1598
|
+
if (saving || choosingDirectory) {
|
|
1599
|
+
return;
|
|
1600
|
+
}
|
|
1601
|
+
if (selecting) {
|
|
1602
|
+
if (key.escape) {
|
|
1603
|
+
setSelecting(undefined);
|
|
1604
|
+
}
|
|
1605
|
+
else if (key.tab) {
|
|
1606
|
+
setSelecting(undefined);
|
|
1607
|
+
focusProviderSection(key.shift ? -1 : 1);
|
|
1608
|
+
}
|
|
1609
|
+
else if (key.upArrow || key.leftArrow) {
|
|
1610
|
+
setSelecting({
|
|
1611
|
+
...selecting,
|
|
1612
|
+
selection: Math.max(0, selecting.selection - 1),
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
else if (key.downArrow || key.rightArrow) {
|
|
1616
|
+
setSelecting({
|
|
1617
|
+
...selecting,
|
|
1618
|
+
selection: Math.min(selecting.options.length - 1, selecting.selection + 1),
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
1621
|
+
else if (key.return) {
|
|
1622
|
+
const option = selecting.options[selecting.selection];
|
|
1623
|
+
if (option) {
|
|
1624
|
+
chooseSelectOption(option);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
return;
|
|
1628
|
+
}
|
|
1629
|
+
if (editing) {
|
|
1630
|
+
if (key.escape) {
|
|
1631
|
+
setEditing(undefined);
|
|
1632
|
+
setError(undefined);
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1635
|
+
if (editing.field === 'importPath' && importCompletionCapacity > 0) {
|
|
1636
|
+
if (key.upArrow) {
|
|
1637
|
+
setPathCompletionIndex((current) => current < 0
|
|
1638
|
+
? importCompletionCapacity - 1
|
|
1639
|
+
: (current - 1 + importCompletionCapacity) % importCompletionCapacity);
|
|
1640
|
+
return;
|
|
1641
|
+
}
|
|
1642
|
+
if (key.downArrow) {
|
|
1643
|
+
setPathCompletionIndex((current) => (current + 1) % importCompletionCapacity);
|
|
1644
|
+
return;
|
|
1645
|
+
}
|
|
1646
|
+
if ((key.tab && !key.shift) || (key.return && pathCompletionIndex >= 0)) {
|
|
1647
|
+
applyPathCompletion();
|
|
1648
|
+
return;
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
if (key.tab) {
|
|
1652
|
+
leaveEdit();
|
|
1653
|
+
}
|
|
1654
|
+
else if (key.return) {
|
|
1655
|
+
commitEdit();
|
|
1656
|
+
return;
|
|
1657
|
+
}
|
|
1658
|
+
else {
|
|
1659
|
+
const multiline = editing.field === 'instructions';
|
|
1660
|
+
const result = reduceInputSequence({ ...emptyEditor(), input: editing.value, cursor: editing.cursor ?? graphemes(editing.value).length }, multiline ? input : input.replace(/[\r\n]/g, ''), key, 'idle');
|
|
1661
|
+
setEditing({ ...editing, value: result.state.input, cursor: result.state.cursor });
|
|
1662
|
+
setError(undefined);
|
|
1663
|
+
return;
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
if (modelPanelVisible) {
|
|
1667
|
+
if (key.escape && (modelQuery || modelSearchFocused)) {
|
|
1668
|
+
if (modelQuery) {
|
|
1669
|
+
updateModelQuery('');
|
|
1670
|
+
}
|
|
1671
|
+
else {
|
|
1672
|
+
selectWizardRow(PROVIDER_IDS.indexOf(quickstartProvider));
|
|
1673
|
+
}
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
if (modelSearchFocused && (key.downArrow || key.return)) {
|
|
1677
|
+
if (filteredProviderModels.length > 0) {
|
|
1678
|
+
selectWizardRow(quickstartModelOffset);
|
|
1679
|
+
}
|
|
1680
|
+
return;
|
|
1681
|
+
}
|
|
1682
|
+
if (modelSearchFocused && (key.leftArrow || key.rightArrow || key.upArrow)) {
|
|
1683
|
+
return;
|
|
1684
|
+
}
|
|
1685
|
+
if (!focusedAction && key.upArrow && selection === quickstartModelOffset) {
|
|
1686
|
+
setModelSearchFocused(true);
|
|
1687
|
+
return;
|
|
1688
|
+
}
|
|
1689
|
+
if (key.backspace || key.delete) {
|
|
1690
|
+
updateModelQuery(graphemes(modelQuery).slice(0, -1).join(''));
|
|
1691
|
+
return;
|
|
1692
|
+
}
|
|
1693
|
+
if (key.ctrl && input === 'u') {
|
|
1694
|
+
updateModelQuery('');
|
|
1695
|
+
return;
|
|
1696
|
+
}
|
|
1697
|
+
if (!key.ctrl &&
|
|
1698
|
+
!key.meta &&
|
|
1699
|
+
input &&
|
|
1700
|
+
!input.startsWith('\u001b') &&
|
|
1701
|
+
[...input].every((character) => (character.codePointAt(0) ?? 0) >= 0x20) &&
|
|
1702
|
+
(input !== ' ' || modelSearchFocused)) {
|
|
1703
|
+
updateModelQuery(input === '/' && !modelSearchFocused
|
|
1704
|
+
? modelQuery
|
|
1705
|
+
: modelQuery + sanitizeTerminalText(input).replaceAll('\n', ''));
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
const rowCount = isProviderSetup ? quickstartSelectableRows : rows.length;
|
|
1710
|
+
const focusableRows = Array.from({ length: rowCount }, (_, index) => index).filter((index) => !rows[index]?.disabled && index !== hiddenReasoningRowIndex);
|
|
1711
|
+
const moveRow = (direction, start = 0, end = rowCount - 1) => {
|
|
1712
|
+
const candidates = focusableRows.filter((index) => index >= start && index <= end);
|
|
1713
|
+
const target = direction === 1
|
|
1714
|
+
? candidates.find((index) => index > selection)
|
|
1715
|
+
: candidates.reverse().find((index) => index < selection);
|
|
1716
|
+
if (target !== undefined) {
|
|
1717
|
+
selectWizardRow(target);
|
|
1718
|
+
}
|
|
1719
|
+
};
|
|
1720
|
+
if (key.escape) {
|
|
1721
|
+
moveBack();
|
|
1722
|
+
}
|
|
1723
|
+
else if (key.tab) {
|
|
1724
|
+
if (isProviderSetup) {
|
|
1725
|
+
focusProviderSection(key.shift ? -1 : 1);
|
|
1726
|
+
return;
|
|
1727
|
+
}
|
|
1728
|
+
if (step === 0) {
|
|
1729
|
+
const sections = [undefined, 'escape', 'settings'];
|
|
1730
|
+
const current = sections.findIndex((section) => section === focusedAction);
|
|
1731
|
+
setFocusedAction(sections[(current + (key.shift ? -1 : 1) + sections.length) % sections.length]);
|
|
1732
|
+
setModelSearchFocused(false);
|
|
1733
|
+
return;
|
|
1734
|
+
}
|
|
1735
|
+
focusSetupSection(key.shift ? -1 : 1);
|
|
1736
|
+
}
|
|
1737
|
+
else if (isSettings && !focusedAction && settingsFocus === 'categories') {
|
|
1738
|
+
const current = SETTINGS_CATEGORIES.findIndex(({ id }) => id === settingsCategory);
|
|
1739
|
+
const target = key.home
|
|
1740
|
+
? 0
|
|
1741
|
+
: key.end
|
|
1742
|
+
? SETTINGS_CATEGORIES.length - 1
|
|
1743
|
+
: key.upArrow
|
|
1744
|
+
? Math.max(0, current - 1)
|
|
1745
|
+
: key.downArrow
|
|
1746
|
+
? Math.min(SETTINGS_CATEGORIES.length - 1, current + 1)
|
|
1747
|
+
: undefined;
|
|
1748
|
+
if (target !== undefined)
|
|
1749
|
+
selectSettingsCategory(SETTINGS_CATEGORIES[target].id);
|
|
1750
|
+
else if (key.return || key.rightArrow)
|
|
1751
|
+
focusSetupSectionTarget('settings');
|
|
1752
|
+
}
|
|
1753
|
+
else if (focusedAction) {
|
|
1754
|
+
if (focusedAction === 'escape') {
|
|
1755
|
+
if (key.return || input === ' ')
|
|
1756
|
+
moveBack();
|
|
1757
|
+
}
|
|
1758
|
+
else if (focusedAction === 'settings') {
|
|
1759
|
+
if (key.return || input === ' ') {
|
|
1760
|
+
if (isSettings)
|
|
1761
|
+
moveBack();
|
|
1762
|
+
else
|
|
1763
|
+
openSettings();
|
|
1764
|
+
}
|
|
1765
|
+
else if (key.upArrow && step !== 0) {
|
|
1766
|
+
setFocusedAction(undefined);
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
else if (focusedAction.startsWith('browse:')) {
|
|
1770
|
+
const index = Number(focusedAction.slice('browse:'.length));
|
|
1771
|
+
if (key.return || input === ' ') {
|
|
1772
|
+
browseForDirectory(directoryRows.get(index));
|
|
1773
|
+
}
|
|
1774
|
+
else if (key.leftArrow || key.upArrow) {
|
|
1775
|
+
selectWizardRow(index);
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
else if (key.leftArrow) {
|
|
1779
|
+
setFocusedAction('back');
|
|
1780
|
+
}
|
|
1781
|
+
else if (key.rightArrow) {
|
|
1782
|
+
if (canContinue)
|
|
1783
|
+
setFocusedAction('next');
|
|
1784
|
+
}
|
|
1785
|
+
else if (key.upArrow) {
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
else if (key.return || input === ' ') {
|
|
1789
|
+
if (focusedAction === 'back')
|
|
1790
|
+
moveBack();
|
|
1791
|
+
else
|
|
1792
|
+
continueFlow();
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
else if ((key.leftArrow || key.rightArrow) && rows[selection]?.choices?.length) {
|
|
1796
|
+
const choices = rows[selection].choices;
|
|
1797
|
+
const selected = choices.findIndex((choice) => choice.active);
|
|
1798
|
+
const next = selected < 0
|
|
1799
|
+
? key.leftArrow
|
|
1800
|
+
? 0
|
|
1801
|
+
: choices.length - 1
|
|
1802
|
+
: (selected + (key.leftArrow ? -1 : 1) + choices.length) % choices.length;
|
|
1803
|
+
choices[next].activate();
|
|
1804
|
+
}
|
|
1805
|
+
else if ((isCapabilities || isData) &&
|
|
1806
|
+
(key.leftArrow || key.rightArrow) &&
|
|
1807
|
+
rows[selection]?.active !== undefined) {
|
|
1808
|
+
const row = rows[selection];
|
|
1809
|
+
if (!row.disabled && row.active !== key.rightArrow)
|
|
1810
|
+
row.activate();
|
|
1811
|
+
}
|
|
1812
|
+
else if (isProviderSetup &&
|
|
1813
|
+
(key.upArrow ||
|
|
1814
|
+
key.downArrow ||
|
|
1815
|
+
key.leftArrow ||
|
|
1816
|
+
key.rightArrow ||
|
|
1817
|
+
key.home ||
|
|
1818
|
+
key.end ||
|
|
1819
|
+
key.pageUp ||
|
|
1820
|
+
key.pageDown)) {
|
|
1821
|
+
if (focusedProviderSection === 'actions')
|
|
1822
|
+
return;
|
|
1823
|
+
if (modelPanelVisible && focusedProviderSection === 'models' && (key.pageUp || key.pageDown)) {
|
|
1824
|
+
paginateModels(key.pageUp ? -1 : 1);
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1827
|
+
const candidates = providerSectionRows[focusedProviderSection].filter((index) => !rows[index]?.disabled);
|
|
1828
|
+
const current = candidates.indexOf(selection);
|
|
1829
|
+
const target = key.home
|
|
1830
|
+
? candidates[0]
|
|
1831
|
+
: key.end
|
|
1832
|
+
? candidates.at(-1)
|
|
1833
|
+
: key.upArrow || key.pageUp
|
|
1834
|
+
? candidates[Math.max(0, current - 1)]
|
|
1835
|
+
: key.downArrow || key.pageDown
|
|
1836
|
+
? candidates[Math.min(candidates.length - 1, current + 1)]
|
|
1837
|
+
: undefined;
|
|
1838
|
+
if (target !== undefined)
|
|
1839
|
+
selectWizardRow(target);
|
|
1840
|
+
}
|
|
1841
|
+
else if (step > 0 &&
|
|
1842
|
+
!isProviderSetup &&
|
|
1843
|
+
(key.upArrow ||
|
|
1844
|
+
key.downArrow ||
|
|
1845
|
+
key.leftArrow ||
|
|
1846
|
+
key.rightArrow ||
|
|
1847
|
+
key.home ||
|
|
1848
|
+
key.end ||
|
|
1849
|
+
key.pageUp ||
|
|
1850
|
+
key.pageDown)) {
|
|
1851
|
+
if (key.rightArrow && directoryRows.has(selection)) {
|
|
1852
|
+
setFocusedAction(`browse:${selection}`);
|
|
1853
|
+
return;
|
|
1854
|
+
}
|
|
1855
|
+
const candidates = setupSectionRows[focusedSetupSection] ?? [];
|
|
1856
|
+
const current = Math.max(0, candidates.indexOf(selection));
|
|
1857
|
+
const target = key.home
|
|
1858
|
+
? candidates[0]
|
|
1859
|
+
: key.end
|
|
1860
|
+
? candidates.at(-1)
|
|
1861
|
+
: key.upArrow ||
|
|
1862
|
+
key.pageUp ||
|
|
1863
|
+
(isImport && key.leftArrow) ||
|
|
1864
|
+
(isPermissions && focusedSetupSection === 'modes' && key.leftArrow)
|
|
1865
|
+
? candidates[Math.max(0, current - 1)]
|
|
1866
|
+
: key.downArrow ||
|
|
1867
|
+
key.pageDown ||
|
|
1868
|
+
(isImport && key.rightArrow) ||
|
|
1869
|
+
(isPermissions && focusedSetupSection === 'modes' && key.rightArrow)
|
|
1870
|
+
? candidates[Math.min(candidates.length - 1, current + 1)]
|
|
1871
|
+
: undefined;
|
|
1872
|
+
if (target !== undefined)
|
|
1873
|
+
selectWizardRow(target);
|
|
1874
|
+
}
|
|
1875
|
+
else if (step === 0 &&
|
|
1876
|
+
openingColumns === 2 &&
|
|
1877
|
+
(key.leftArrow || key.rightArrow || key.upArrow || key.downArrow)) {
|
|
1878
|
+
selectWizardRow(openingNeighbor(selection, key.leftArrow ? 'left' : key.rightArrow ? 'right' : key.upArrow ? 'up' : 'down', openingColumns));
|
|
1879
|
+
}
|
|
1880
|
+
else if (key.upArrow || key.leftArrow) {
|
|
1881
|
+
moveRow(-1);
|
|
1882
|
+
}
|
|
1883
|
+
else if (key.downArrow || key.rightArrow) {
|
|
1884
|
+
moveRow(1);
|
|
1885
|
+
}
|
|
1886
|
+
else if (key.return || input === ' ') {
|
|
1887
|
+
activateRow(selection);
|
|
1888
|
+
}
|
|
1889
|
+
else if (rows[selection]?.field &&
|
|
1890
|
+
rows[selection]?.input !== false &&
|
|
1891
|
+
!rows[selection]?.disabled &&
|
|
1892
|
+
!rows[selection]?.selectOptions &&
|
|
1893
|
+
input &&
|
|
1894
|
+
!key.ctrl &&
|
|
1895
|
+
!key.meta) {
|
|
1896
|
+
rows[selection].activate();
|
|
1897
|
+
setEditing((current) => {
|
|
1898
|
+
if (!current)
|
|
1899
|
+
return current;
|
|
1900
|
+
const result = reduceInputSequence({ ...emptyEditor(), input: current.value, cursor: graphemes(current.value).length }, input, key, 'idle');
|
|
1901
|
+
return { ...current, value: result.state.input, cursor: result.state.cursor };
|
|
1902
|
+
});
|
|
1903
|
+
}
|
|
1904
|
+
});
|
|
1905
|
+
const isSetupCompletion = (flow === 'quickstart' && step === 1) ||
|
|
1906
|
+
(flow === 'customize' && step === CUSTOMIZE_STEPS.length) ||
|
|
1907
|
+
(flow === 'import' && step === 1);
|
|
1908
|
+
const primaryLabel = saving
|
|
1909
|
+
? 'Saving...'
|
|
1910
|
+
: isSetupCompletion
|
|
1911
|
+
? deferred || !config.needsSetup()
|
|
1912
|
+
? 'Save and Launch'
|
|
1913
|
+
: 'Launch Strands harness'
|
|
1914
|
+
: 'Continue';
|
|
1915
|
+
const escapeAction = editing || selecting ? 'cancel' : 'back';
|
|
1916
|
+
const navigationHints = editing
|
|
1917
|
+
? [
|
|
1918
|
+
width < 32 ? 'Enter save · Tab move' : 'Enter save · Tab/Shift+Tab move',
|
|
1919
|
+
editing.field === 'instructions'
|
|
1920
|
+
? 'Ctrl+J newline · Esc cancel'
|
|
1921
|
+
: width < 60
|
|
1922
|
+
? 'Click focus · Esc cancel'
|
|
1923
|
+
: 'Mouse click: switch controls · Ctrl+U: clear · Esc: cancel',
|
|
1924
|
+
]
|
|
1925
|
+
: [
|
|
1926
|
+
width < 32
|
|
1927
|
+
? 'Click/Enter · ↑↓'
|
|
1928
|
+
: width < 60
|
|
1929
|
+
? `Click/Enter ${isReview ? 'edit' : 'choose'} · ↑↓ move`
|
|
1930
|
+
: `Click or Enter to ${isReview ? 'edit' : 'choose'} · Arrow keys (↑↓) to move`,
|
|
1931
|
+
width < 32
|
|
1932
|
+
? 'Shift+Tab'
|
|
1933
|
+
: width < 60
|
|
1934
|
+
? step === 0
|
|
1935
|
+
? 'Tab/Shift+Tab focus'
|
|
1936
|
+
: `Tab/Shift+Tab focus · Esc ${escapeAction}`
|
|
1937
|
+
: step === 0
|
|
1938
|
+
? 'Tab / Shift+Tab: grid ↔ Esc ↔ Settings'
|
|
1939
|
+
: `Tab / Shift+Tab to move focus · Esc to ${escapeAction}`,
|
|
1940
|
+
];
|
|
1941
|
+
const settingsHovered = hoveredControl === 'settings';
|
|
1942
|
+
const settingsButton = (_jsx(Box, { ref: (element) => {
|
|
1943
|
+
settingsElement.current = element ?? undefined;
|
|
1944
|
+
}, height: 1, flexShrink: 0, children: _jsx(Text, { color: settingsHovered || focusedAction === 'settings' ? accent : palette.foreground, children: isSettings ? 'Back' : '/settings' }) }));
|
|
1945
|
+
return (_jsxs(Box, { width: width, height: height, paddingX: 1, flexDirection: "column", overflow: "hidden", children: [showBrand ? (_jsx(SetupBrand, { frame: brandFrame, containerWidth: lockupWidth, appearance: appearance, animationId: frogAnimationId, ...(introStartedAt !== undefined ? { introStartedAt } : {}), elapsedMs: frogElapsedMs, onFrogElement: (element) => {
|
|
1946
|
+
frogElement.current = element ?? undefined;
|
|
1947
|
+
} })) : null, step === 0 ? (_jsx(Fade, { background: palette.background, progress: panelTransition.progress, children: _jsx(OpeningMenu, { width: lockupWidth, buttonHeight: openingButtonHeight, selection: selection, showSelection: focusedAction === undefined, topGap: openingTopGap, animate: appearance.animations, ...(error ? { error } : {}), ...(availableUpdate ? { availableUpdate } : {}), escapeHint: escapeHint, escapeFocused: focusedAction === 'escape', escapeHovered: hoveredControl === 'escape', onEscapeElement: (element) => {
|
|
1948
|
+
escapeHintElement.current = element ?? undefined;
|
|
1949
|
+
}, onRowElement: (index, element) => registerElement(rowElements.current, index, element) }) })) : null, step === 0 ? null : (_jsx(Fade, { background: palette.background, progress: panelTransition.progress, children: _jsxs(Box, { flexGrow: 1, alignItems: "center", justifyContent: "center", flexDirection: "column", overflow: "hidden", children: [progress ? (_jsxs(Box, { width: bubbleWidth, marginBottom: 1, alignItems: "center", flexDirection: "column", flexShrink: 0, children: [_jsx(Text, { bold: true, color: accent, wrap: "truncate-end", children: progress.instruction }), _jsx(SetupProgress, { current: progress.current, total: progress.total, ...(progress.label ? { label: progress.label } : {}), width: Math.min(bubbleWidth, 48), animate: appearance.animations })] })) : null, _jsxs(Box, { width: bubbleWidth, height: bubbleHeight, flexDirection: "column", overflow: "hidden", ...(!splitQuickstart && !isSettings && bubbleHeight >= 3
|
|
1950
|
+
? {
|
|
1951
|
+
borderStyle: 'single',
|
|
1952
|
+
borderColor: focusedAction === 'back' || focusedAction === 'next' ? undefined : accent,
|
|
1953
|
+
borderDimColor: focusedAction === 'back' || focusedAction === 'next',
|
|
1954
|
+
}
|
|
1955
|
+
: {}), children: [!isSettings && flow === 'customize' && !isProviderSetup && !isCapabilities ? (_jsxs(Box, { paddingX: 1, marginBottom: 1, justifyContent: "space-between", flexShrink: 0, children: [_jsx(Text, { bold: true, color: accent, children: CUSTOMIZE_STEPS[step - 1] }), customizeOverflowLabel ? _jsx(Text, { dimColor: true, children: customizeOverflowLabel }) : null] })) : null, isCapabilities ? (_jsxs(_Fragment, { children: [_jsxs(Box, { paddingX: 1, height: capabilityHeaderHeight, marginBottom: 1, justifyContent: "space-between", alignItems: "center", flexShrink: 0, children: [_jsx(Text, { bold: true, color: accent, children: isTools ? 'Tools' : bubbleWidth < 64 ? 'Plugins' : 'Plugins & features' }), _jsx(Text, { dimColor: true, children: [
|
|
1956
|
+
hiddenRowsBefore > 1 ? `↑ ${hiddenRowsBefore - 1}` : '',
|
|
1957
|
+
hiddenRowsAfter > 0 ? `↓ ${hiddenRowsAfter}` : '',
|
|
1958
|
+
]
|
|
1959
|
+
.filter(Boolean)
|
|
1960
|
+
.join(' · ') }), _jsx(Box, { ref: (element) => registerElement(rowElements.current, 0, element), paddingX: 1, height: capabilityHeaderHeight, borderStyle: capabilityHeaderHeight >= 3 ? 'single' : undefined, borderColor: rowHighlighted(0) ? accent : undefined, borderDimColor: !rowHighlighted(0), children: _jsx(Text, { bold: true, color: rowHighlighted(0) ? accent : palette.foreground, children: rows[0].label }) })] }), renderCapabilityRows(visibleCapabilityRows)] })) : isImport ? (_jsxs(Box, { flexGrow: 1, paddingX: 1, paddingY: 1, flexDirection: "column", overflow: "hidden", children: [_jsx(Text, { bold: true, wrap: "truncate-end", children: "Import an agent" }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { bold: true, ...(selection === 0 ? { color: accent } : {}), wrap: "truncate-end", children: "Path to ZIP, file, or folder" }) }), _jsxs(Box, { height: 3, flexShrink: 0, flexDirection: "row", children: [_jsx(Box, { ref: (element) => registerElement(rowElements.current, 0, element), flexGrow: 1, flexBasis: 0, paddingX: 1, flexDirection: "column", justifyContent: "center", borderStyle: "single", borderColor: rowHighlighted(0) ? accent : undefined, borderDimColor: !rowHighlighted(0), children: _jsx(EditableText, { value: editing?.field === 'importPath' ? editing.value : importPath, cursor: editing?.field === 'importPath'
|
|
1961
|
+
? (editing.cursor ?? graphemes(editing.value).length)
|
|
1962
|
+
: graphemes(importPath).length, width: Math.max(1, bubbleWidth - (canUseNativePicker() ? 21 : 8)), active: editing?.field === 'importPath' }) }), canUseNativePicker() ? (_jsx(Box, { ref: (element) => registerElement(rowElements.current, 1, element), width: 12, flexShrink: 0, marginLeft: 1, alignItems: "center", justifyContent: "center", borderStyle: "single", borderColor: rowHighlighted(1) && !choosingDirectory ? accent : undefined, borderDimColor: !rowHighlighted(1) || choosingDirectory, children: _jsx(Text, { bold: true, ...(selection === 1 && !choosingDirectory ? { color: accent } : {}), dimColor: choosingDirectory, children: choosingDirectory ? 'Opening...' : 'Browse' }) })) : null] }), pathEditing && importCompletionCapacity > 0 ? (_jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [_jsx(Box, { paddingX: 1, height: 1, flexShrink: 0, children: _jsx(Text, { dimColor: true, wrap: "truncate-end", children: "Suggestions \u00B7 \u2191\u2193 choose \u00B7 Tab complete" }) }), pathCompletions.slice(0, importCompletionCapacity).map((completion, index) => (_jsx(Box, { ref: (element) => registerElement(pathCompletionElements.current, index, element), height: 1, paddingX: 1, flexShrink: 0, children: _jsxs(Text, { color: pathCompletionIndex === index || hoveredControl === `completion:${index}`
|
|
1963
|
+
? accent
|
|
1964
|
+
: palette.foreground, bold: pathCompletionIndex === index, wrap: "truncate-end", children: [pathCompletionIndex === index ? '› ' : ' ', sanitizeTerminalText(completion.label).replaceAll('\n', '\\n').replaceAll('\t', '\\t'), _jsx(Text, { dimColor: true, children: completion.directory ? ' folder' : ' file' })] }) }, completion.value)))] })) : null] })) : splitQuickstart ? (_jsxs(Box, { flexGrow: 1, flexDirection: "row", overflow: "hidden", children: [_jsx(PanelSection, { width: quickstartProviderColumnWidth, focused: focusedProviderSection === 'providers' || focusedProviderSection === 'profiles', header: _jsx(Text, { dimColor: true, children: "Providers" }), meta: [
|
|
1965
|
+
quickstartProviderViewportStart > 0 ? '↑' : '',
|
|
1966
|
+
quickstartProviderViewportStart + visibleProviderRows.length < providerRows.length ? '↓' : '',
|
|
1967
|
+
].join(''), children: _jsxs(Box, { flexGrow: 1, columnGap: awsProfileRow ? 1 : 0, overflow: "hidden", children: [_jsxs(Box, { width: quickstartProviderListWidth, flexShrink: 0, flexDirection: "column", children: [_jsx(Box, { ref: providerListElement, height: quickstartProviderListHeight, flexShrink: 0, flexDirection: "column", overflow: "hidden", children: _jsx(ProviderList, { items: visibleProviderRows.map((row) => ({
|
|
1968
|
+
id: row.id,
|
|
1969
|
+
label: quickstartProviderListWidth < 29
|
|
1970
|
+
? SHORT_PROVIDER_LABELS[row.id]
|
|
1971
|
+
: row.label,
|
|
1972
|
+
description: row.description,
|
|
1973
|
+
...(row.status ? { status: row.status } : {}),
|
|
1974
|
+
})), selected: quickstartProvider, width: quickstartProviderListWidth, rowHeight: quickstartProviderRowHeight, focused: focusedProviderSection === 'providers', selectedBackground: true, ...(typeof hoveredControl === 'number' &&
|
|
1975
|
+
hoveredControl >= 0 &&
|
|
1976
|
+
hoveredControl < PROVIDER_IDS.length
|
|
1977
|
+
? { hovered: PROVIDER_IDS[hoveredControl] }
|
|
1978
|
+
: {}), onElement: (id, element) => registerElement(rowElements.current, PROVIDER_IDS.indexOf(id), element) }) }), _jsx(Box, { flexGrow: 1 }), refreshRow ? renderRefreshButton(refreshRow, quickstartProviderListWidth, true) : null] }), awsProfileRow ? (_jsx(Box, { width: quickstartProfileWidth, flexShrink: 0, flexDirection: "column", overflow: "hidden", children: selecting?.field === 'AWS_PROFILE'
|
|
1979
|
+
? renderProviderSelect(selecting)
|
|
1980
|
+
: renderProviderField(awsProfileRow, quickstartProfileWidth, true) })) : null] }) }), _jsx(Box, { width: quickstartDetailColumnWidth, flexShrink: 0, flexDirection: "row", overflow: "hidden", children: showProviderConfiguration ? (_jsxs(_Fragment, { children: [_jsx(PanelSection, { width: quickstartModelColumnWidth, focused: focusedProviderSection === 'models', header: _jsx(Text, { dimColor: true, children: "Connection" }), children: _jsxs(Box, { ref: connectionFieldsElement, paddingX: 1, flexGrow: 1, flexDirection: "column", overflow: "hidden", children: [middleFacts.length > 0 || middleWarningLines.length > 0 ? (_jsxs(Box, { marginBottom: middleFieldGap, flexShrink: 0, flexDirection: "column", children: [middleFacts.map((fact) => (_jsxs(Box, { children: [_jsxs(Text, { dimColor: true, children: [fact.label, ": "] }), _jsx(Text, { bold: true, color: palette[fact.status], children: fact.value })] }, fact.label))), middleWarningLines.length > 0 ? (_jsx(Box, { marginTop: middleFacts.length > 0 ? 1 : 0, children: _jsx(Text, { color: palette[providerWarningStatus], children: middleWarningLines.join('\n') }) })) : null] })) : null, selecting && selecting.field !== 'AWS_PROFILE'
|
|
1981
|
+
? renderProviderSelect(selecting)
|
|
1982
|
+
: visibleProviderFieldRows.map((row) => renderProviderField(row, quickstartDetailContentWidth))] }) }), showModelOptionsPanel ? (_jsx(PanelSection, { width: quickstartOptionsColumnWidth, focused: false, header: _jsx(Text, { dimColor: true, children: "Connection status" }), children: _jsxs(Box, { paddingX: 1, flexDirection: "column", children: [assessmentFacts.map((fact) => (_jsxs(Text, { children: [_jsxs(Text, { dimColor: true, children: [fact.label, ": "] }), _jsx(Text, { bold: true, color: palette[fact.status], children: fact.value })] }, fact.label))), _jsx(Box, { marginTop: assessmentFacts.length > 0 ? 1 : 0, children: warning ? (_jsx(Text, { color: palette[providerWarningStatus], children: warning })) : (_jsx(Text, { dimColor: true, children: "Connect this provider to browse its models." })) })] }) })) : null] })) : (_jsxs(Box, { flexGrow: 1, flexDirection: "row", overflow: "hidden", children: [_jsx(PanelSection, { width: quickstartModelColumnWidth, focused: focusedProviderSection === 'models' ||
|
|
1983
|
+
(!showModelOptionsPanel && focusedProviderSection === 'options'), meta: !showModelOptionsPanel &&
|
|
1984
|
+
providerDetailSection === 'options' &&
|
|
1985
|
+
visibleModelOptionRows.length < modelOptionRows.length
|
|
1986
|
+
? '↕'
|
|
1987
|
+
: '', header: !showModelOptionsPanel && modelOptionRows.length > 0 ? (_jsxs(Box, { columnGap: quickstartModelColumnWidth < 22 ? 0 : 1, children: [_jsx(Box, { ref: modelSectionElement, flexShrink: 0, children: _jsx(Text, { color: providerDetailSection === 'models' || hoveredControl === 'section:models'
|
|
1988
|
+
? accent
|
|
1989
|
+
: palette.muted, bold: providerDetailSection === 'models', children: "Models" }) }), _jsx(Text, { dimColor: true, children: "\u2502" }), _jsx(Box, { ref: optionsSectionElement, flexShrink: 0, children: _jsx(Text, { color: providerDetailSection === 'options' || hoveredControl === 'section:options'
|
|
1990
|
+
? accent
|
|
1991
|
+
: palette.muted, bold: providerDetailSection === 'options', children: "Options" }) })] })) : (_jsx(Text, { dimColor: true, children: "Models" })), children: !showModelOptionsPanel &&
|
|
1992
|
+
providerDetailSection === 'options' &&
|
|
1993
|
+
modelOptionRows.length > 0 ? (renderModelOptions(quickstartDetailContentWidth)) : (_jsxs(Box, { ref: modelListElement, paddingX: 1, flexGrow: 1, flexDirection: "column", overflow: "hidden", children: [_jsx(Box, { ref: modelSearchElement, height: quickstartSearchHeight, paddingX: 1, flexShrink: 0, borderStyle: quickstartSearchHeight >= 3 ? 'single' : undefined, borderColor: modelSearchFocused || hoveredControl === 'search' ? accent : undefined, borderDimColor: !modelSearchFocused && hoveredControl !== 'search', children: _jsx(Text, { wrap: "truncate-end", children: modelSearchFocused ? (_jsxs(_Fragment, { children: [modelQuery, _jsx(Cursor, {})] })) : (_jsxs(Text, { dimColor: true, children: ["/ ", modelQuery || 'Search models'] })) }) }), showModelPagination ? (_jsx(Box, { ref: modelPreviousElement, width: "100%", height: 1, paddingX: 1, flexShrink: 0, children: _jsxs(Text, { ...(previousModelCount > 0
|
|
1994
|
+
? {
|
|
1995
|
+
color: hoveredControl === 'models-previous' ? accent : palette.muted,
|
|
1996
|
+
bold: hoveredControl === 'models-previous',
|
|
1997
|
+
}
|
|
1998
|
+
: { dimColor: true }), children: ["\u2191 Previous", previousModelCount > 0 ? ` · ${previousModelCount}` : ''] }) })) : null, _jsx(Box, { flexShrink: 0, flexDirection: "column", overflow: "hidden", children: providerModels.provider !== quickstartProvider || providerModels.loading ? (_jsx(Text, { dimColor: true, children: "Loading model catalog..." })) : !providerModels.available ? (_jsxs(Text, { color: palette.warning, children: ["Model catalog unavailable", providerModels.error ? ` · ${providerModels.error}` : ''] })) : visibleProviderModels.length === 0 ? (_jsx(Text, { dimColor: true, children: modelQuery.trim() ? 'No matching models' : 'No models reported' })) : (_jsx(_Fragment, { children: visibleProviderModels.map((model, visibleIndex) => {
|
|
1999
|
+
const modelIndex = quickstartModelViewportStart + visibleIndex;
|
|
2000
|
+
const index = quickstartModelOffset + modelIndex;
|
|
2001
|
+
const active = `${quickstartProvider}/${model.id}` === draft.profile.model &&
|
|
2002
|
+
deselectedModel !== draft.profile.model;
|
|
2003
|
+
const focused = focusedAction === undefined && !modelSearchFocused && index === selection;
|
|
2004
|
+
const hovered = hoveredControl === index;
|
|
2005
|
+
const highlighted = focused || hovered;
|
|
2006
|
+
const harnessDefault = model.id === quickstartDefaultModel;
|
|
2007
|
+
const modelSpecifier = `${quickstartProvider}/${model.id}`;
|
|
2008
|
+
return (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), width: "100%", height: quickstartModelRowHeight, paddingX: 1, flexShrink: 0, overflow: "hidden", backgroundColor: active || highlighted ? palette.selection : undefined, children: [_jsx(Box, { width: 2, flexShrink: 0, children: _jsx(Text, { ...(active || highlighted ? { color: accent, bold: true } : {}), children: active ? '✓ ' : highlighted ? '› ' : ' ' }) }), _jsx(Box, { ...(showModelIds
|
|
2009
|
+
? { width: quickstartModelNameWidth, flexShrink: 0 }
|
|
2010
|
+
: { flexGrow: 1 }), overflow: "hidden", children: _jsxs(Text, { ...(active || highlighted ? { color: accent, bold: true } : {}), wrap: "truncate-end", children: [model.name, harnessDefault ? _jsx(Text, { color: accent, children: " \u2605" }) : null] }) }), showModelIds ? (_jsxs(_Fragment, { children: [_jsx(Box, { width: 1, flexShrink: 0 }), _jsx(Box, { width: quickstartModelIdWidth, flexShrink: 0, overflow: "hidden", children: _jsx(Text, { dimColor: true, wrap: "truncate-end", children: modelSpecifier }) })] })) : null] }, model.id));
|
|
2011
|
+
}) })) }), showModelPagination ? (_jsx(Box, { ref: modelNextElement, width: "100%", height: 1, paddingX: 1, flexShrink: 0, children: _jsxs(Text, { ...(nextModelCount > 0
|
|
2012
|
+
? {
|
|
2013
|
+
color: hoveredControl === 'models-next' ? accent : palette.muted,
|
|
2014
|
+
bold: hoveredControl === 'models-next',
|
|
2015
|
+
}
|
|
2016
|
+
: { dimColor: true }), children: ["\u2193 Next", nextModelCount > 0 ? ` · ${nextModelCount} more` : ''] }) })) : null] })) }), showModelOptionsPanel ? (_jsx(PanelSection, { width: quickstartOptionsColumnWidth, focused: focusedProviderSection === 'options', header: _jsx(Text, { dimColor: true, children: "Model options" }), meta: visibleModelOptionRows.length < modelOptionRows.length ? '↕' : '', children: renderModelOptions(quickstartOptionsColumnWidth - 4) })) : null] })) })] })) : isSettings ? (_jsx(SetupSettingsPanel, { rows: visibleRows, allRows: rows, focus: settingsFocus, focusActive: focusedAction !== 'back' && focusedAction !== 'next', category: settingsCategory, start: viewportStart, selected: selection, width: bubbleWidth, height: bubbleHeight, ...(typeof hoveredControl === 'string' ? { hoveredControl } : {}), ...(typeof hoveredControl === 'number' ? { hoveredRow: hoveredControl } : {}), onRowElement: (index, element) => registerElement(rowElements.current, index, element), onChoiceElement: (target, element) => registerElement(choiceElements.current, target, element), onCategoriesElement: (element) => {
|
|
2017
|
+
settingsCategoriesElement.current = element;
|
|
2018
|
+
} })) : isPermissions ? (_jsxs(Box, { flexGrow: 1, paddingX: 1, flexDirection: "column", overflow: "hidden", children: [_jsx(Box, { height: permissionModeHeight, flexShrink: 0, children: rows.slice(0, 3).map((row, index) => (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), flexGrow: 1, flexBasis: 0, height: permissionModeHeight, marginRight: index < 2 ? 1 : 0, paddingX: bubbleWidth >= 72 ? 1 : 0, borderStyle: "single", borderColor: rowHighlighted(index) || row.active ? accent : undefined, borderDimColor: !rowHighlighted(index) && !row.active, flexDirection: "column", justifyContent: "center", overflow: "hidden", children: [_jsxs(Text, { bold: true, color: row.active || rowHighlighted(index) ? accent : palette.foreground, wrap: "truncate-end", children: [row.active ? '✓ ' : '', bubbleWidth < 72 ? ['Ask', 'Allow all', 'Custom'][index] : row.label] }), permissionModeHeight >= 5 ? (_jsx(Text, { dimColor: true, wrap: permissionModeHeight >= 7 ? 'wrap' : 'truncate-end', children: row.description })) : null] }, row.id))) }), draft.customPermissions ? (_jsxs(Box, { marginTop: 1, flexGrow: 1, flexDirection: "column", overflow: "hidden", children: [_jsxs(Box, { justifyContent: "space-between", flexShrink: 0, children: [_jsx(Text, { bold: true, children: "Per-tool behavior" }), _jsxs(Text, { dimColor: true, children: [permissionViewportStart > 3 ? `↑ ${permissionViewportStart - 3} ` : '', permissionViewportStart + visiblePermissionTools.length < rows.length
|
|
2019
|
+
? `↓ ${rows.length - permissionViewportStart - visiblePermissionTools.length}`
|
|
2020
|
+
: ''] })] }), visiblePermissionTools.map((row, visibleIndex) => {
|
|
2021
|
+
const index = permissionViewportStart + visibleIndex;
|
|
2022
|
+
return (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), height: rowHeight, paddingX: 1, flexShrink: 0, flexDirection: "column", children: [_jsxs(Text, { bold: rowHighlighted(index), color: row.active || rowHighlighted(index) ? accent : palette.foreground, wrap: "truncate-end", children: [rowHighlighted(index) ? '› ' : ' ', row.active ? '☑ ' : '☐ ', row.label] }), _jsx(Text, { dimColor: true, wrap: "truncate-end", children: row.description })] }, row.id));
|
|
2023
|
+
})] })) : (_jsx(Box, { marginTop: 1, paddingX: 1, children: _jsx(Text, { dimColor: true, children: rows.find((row) => row.active)?.description }) }))] })) : selecting ? (renderProviderSelect(selecting)) : (_jsx(Box, { flexGrow: 1, paddingX: isProviderSetup ? 0 : 1, flexDirection: "column", overflow: "hidden", children: visibleRows.map((row, visibleIndex) => {
|
|
2024
|
+
const index = viewportStart + visibleIndex;
|
|
2025
|
+
if (isReview)
|
|
2026
|
+
return renderReviewRow(row, index);
|
|
2027
|
+
if (isData)
|
|
2028
|
+
return renderDataRow(row, index);
|
|
2029
|
+
if (!isProviderSetup)
|
|
2030
|
+
return renderSetupRow(row, index);
|
|
2031
|
+
if (row.id === 'refresh-provider') {
|
|
2032
|
+
return renderRefreshButton(row, bubbleWidth - 2);
|
|
2033
|
+
}
|
|
2034
|
+
if (row.status) {
|
|
2035
|
+
return (_jsx(ProviderList, { items: [
|
|
2036
|
+
{
|
|
2037
|
+
id: row.id,
|
|
2038
|
+
label: row.label,
|
|
2039
|
+
description: row.description,
|
|
2040
|
+
status: row.status,
|
|
2041
|
+
},
|
|
2042
|
+
], selected: quickstartProvider, width: Math.max(1, bubbleWidth - 2), rowHeight: rowHeight, focused: focusedProviderSection === 'providers', selectedBackground: true, ...(hoveredControl === index ? { hovered: row.id } : {}), onElement: (_, element) => registerElement(rowElements.current, index, element) }, row.id));
|
|
2043
|
+
}
|
|
2044
|
+
const activeEditing = editing?.field === row.field ? editing : undefined;
|
|
2045
|
+
return (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), paddingX: row.field ? 0 : 1, height: rowHeight, flexShrink: 0, flexDirection: "column", backgroundColor: !row.disabled && rowHighlighted(index) ? palette.selection : undefined, children: [_jsxs(Box, { paddingX: row.field ? 1 : 0, justifyContent: "space-between", flexShrink: 0, children: [_jsxs(Text, { bold: row.field !== undefined, ...(!row.disabled && index === selection ? { color: accent } : {}), dimColor: row.disabled === true, wrap: "truncate-end", children: [row.field || row.active === undefined ? '' : row.active ? '☑ ' : '☐ ', row.label] }), directoryRows.has(index) ? (_jsx(Box, { ref: (element) => registerElement(directoryElements.current, index, element), paddingX: 1, flexShrink: 0, children: _jsx(Text, { bold: true, children: choosingDirectory && focusedAction === `browse:${index}` ? 'Opening...' : 'Browse' }) })) : null] }), row.choices?.length ? (renderChoices(row.choices, index)) : row.field ? (_jsx(Box, { flexGrow: 1, paddingX: 1, flexDirection: "column", justifyContent: row.field === 'instructions' ? 'flex-start' : 'center', children: _jsx(EditableText, { value: activeEditing?.value ?? row.description, cursor: activeEditing
|
|
2046
|
+
? (activeEditing.cursor ?? graphemes(activeEditing.value).length)
|
|
2047
|
+
: graphemes(row.description).length, width: Math.max(1, bubbleWidth - 4), maxRows: row.field === 'instructions' ? rowHeight - 2 : 1, active: Boolean(activeEditing), masked: PROVIDER_CREDENTIAL_KEYS.includes(row.field) }) })) : (_jsx(Text, { ...(row.descriptionColor ? { color: row.descriptionColor } : { dimColor: true }), wrap: "truncate-end", children: row.description }))] }, row.id));
|
|
2048
|
+
}) })), warningHeight > 0 ? (_jsx(Box, { paddingX: 1, marginTop: warningGap, height: warningHeight, flexShrink: 0, children: _jsx(Text, { color: palette[providerWarningStatus], children: warningLines.join('\n') }) })) : null, error ? (_jsx(Box, { paddingX: 1, height: 1, children: _jsx(Text, { color: "red", wrap: "truncate-end", children: error }) })) : null] }), hasExternalActions ? (_jsx(Box, { width: bubbleWidth, height: actionHeight, marginTop: actionGap, columnGap: actionColumnGap, justifyContent: "space-between", children: [
|
|
2049
|
+
['back', 'Back', backElement],
|
|
2050
|
+
['next', primaryLabel, nextElement],
|
|
2051
|
+
].map(([action, label, elementRef]) => {
|
|
2052
|
+
const primary = action === 'next';
|
|
2053
|
+
const enabled = canContinue && !saving;
|
|
2054
|
+
const active = focusedAction === action;
|
|
2055
|
+
const hovered = hoveredControl === action;
|
|
2056
|
+
const interactiveHover = hovered && (!primary || enabled);
|
|
2057
|
+
return (_jsx(Box, { ref: (element) => {
|
|
2058
|
+
elementRef.current = element ?? undefined;
|
|
2059
|
+
}, width: actionWidth, height: actionHeight, alignItems: "center", justifyContent: "center", ...(actionHeight >= 3
|
|
2060
|
+
? {
|
|
2061
|
+
borderStyle: 'single',
|
|
2062
|
+
borderColor: (active || interactiveHover) && (!primary || enabled) ? accent : undefined,
|
|
2063
|
+
borderDimColor: !(active || interactiveHover) || (primary && !enabled),
|
|
2064
|
+
}
|
|
2065
|
+
: {}), children: _jsx(Text, { bold: true, ...(active || interactiveHover ? { color: accent } : {}), dimColor: primary ? !enabled : saving, children: label }) }, action));
|
|
2066
|
+
}) })) : null] }) })), width < 32 ? (_jsxs(Box, { height: navigationHeight, flexShrink: 0, flexDirection: "column", paddingX: 1, children: [_jsx(Box, { justifyContent: "center", children: _jsx(Text, { dimColor: true, wrap: "truncate-end", children: navigationHints[0] }) }), _jsxs(Box, { height: 1, alignItems: "center", children: [_jsx(Box, { flexGrow: 1, justifyContent: "center", overflow: "hidden", children: _jsx(Text, { dimColor: true, wrap: "truncate-end", children: navigationHints[1] }) }), settingsButton] })] })) : (_jsxs(Box, { height: navigationHeight, flexShrink: 0, alignItems: "flex-end", paddingX: 1, children: [_jsx(Box, { flexGrow: 1, flexDirection: "column", alignItems: "center", overflow: "hidden", children: navigationHints.map((hint) => (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: hint }, hint))) }), settingsButton] }))] }));
|
|
2067
|
+
}
|
|
2068
|
+
function isProviderEnvironmentKey(value) {
|
|
2069
|
+
return PROVIDER_ENVIRONMENT_KEYS.includes(value);
|
|
2070
|
+
}
|
|
2071
|
+
function SetupToggle({ checked, focused }) {
|
|
2072
|
+
const { accent, foreground } = useTheme();
|
|
2073
|
+
return (_jsx(Box, { width: 9, flexShrink: 0, children: _jsx(Text, { color: checked || focused ? accent : foreground, bold: checked || focused, wrap: "truncate-end", children: checked ? ' ━━● On ' : ' ●━━ Off ' }) }));
|
|
2074
|
+
}
|
|
2075
|
+
//# sourceMappingURL=wizard.js.map
|