@strands-agents/cli 0.1.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/LICENSE +175 -0
- package/NOTICE +1 -0
- package/README.md +576 -0
- package/bin/strands.js +256 -0
- package/dist/src/cli/arguments.js +198 -0
- package/dist/src/cli/arguments.js.map +1 -0
- package/dist/src/cli/invocation.js +124 -0
- package/dist/src/cli/invocation.js.map +1 -0
- package/dist/src/cli/run.js +252 -0
- package/dist/src/cli/run.js.map +1 -0
- package/dist/src/console.js +235 -0
- package/dist/src/console.js.map +1 -0
- package/dist/src/logging.js +103 -0
- package/dist/src/logging.js.map +1 -0
- package/dist/src/main.js +7 -0
- package/dist/src/main.js.map +1 -0
- package/dist/src/tui/acp/projection.js +276 -0
- package/dist/src/tui/acp/projection.js.map +1 -0
- package/dist/src/tui/acp/server.js +263 -0
- package/dist/src/tui/acp/server.js.map +1 -0
- package/dist/src/tui/agent-configuration.js +335 -0
- package/dist/src/tui/agent-configuration.js.map +1 -0
- package/dist/src/tui/agent-setup.js +80 -0
- package/dist/src/tui/agent-setup.js.map +1 -0
- package/dist/src/tui/background/activity.js +273 -0
- package/dist/src/tui/background/activity.js.map +1 -0
- package/dist/src/tui/background/inbox.js +120 -0
- package/dist/src/tui/background/inbox.js.map +1 -0
- package/dist/src/tui/background/tasks.js +98 -0
- package/dist/src/tui/background/tasks.js.map +1 -0
- package/dist/src/tui/builtin-tools.js +65 -0
- package/dist/src/tui/builtin-tools.js.map +1 -0
- package/dist/src/tui/chat/commands.js +98 -0
- package/dist/src/tui/chat/commands.js.map +1 -0
- package/dist/src/tui/chat/controller-helpers.js +62 -0
- package/dist/src/tui/chat/controller-helpers.js.map +1 -0
- package/dist/src/tui/chat/controller.js +1913 -0
- package/dist/src/tui/chat/controller.js.map +1 -0
- package/dist/src/tui/chat/help.js +94 -0
- package/dist/src/tui/chat/help.js.map +1 -0
- package/dist/src/tui/chat/panels.js +418 -0
- package/dist/src/tui/chat/panels.js.map +1 -0
- package/dist/src/tui/chat/projector.js +443 -0
- package/dist/src/tui/chat/projector.js.map +1 -0
- package/dist/src/tui/chat/sdk-projector.js +194 -0
- package/dist/src/tui/chat/sdk-projector.js.map +1 -0
- package/dist/src/tui/chat/shell.js +263 -0
- package/dist/src/tui/chat/shell.js.map +1 -0
- package/dist/src/tui/chat/types.js +2 -0
- package/dist/src/tui/chat/types.js.map +1 -0
- package/dist/src/tui/config.js +497 -0
- package/dist/src/tui/config.js.map +1 -0
- package/dist/src/tui/configuration-instructions.js +14 -0
- package/dist/src/tui/configuration-instructions.js.map +1 -0
- package/dist/src/tui/mcp/config.js +370 -0
- package/dist/src/tui/mcp/config.js.map +1 -0
- package/dist/src/tui/mcp.js +98 -0
- package/dist/src/tui/mcp.js.map +1 -0
- package/dist/src/tui/memory-options.js +10 -0
- package/dist/src/tui/memory-options.js.map +1 -0
- package/dist/src/tui/messaging.js +193 -0
- package/dist/src/tui/messaging.js.map +1 -0
- package/dist/src/tui/model/context.js +13 -0
- package/dist/src/tui/model/context.js.map +1 -0
- package/dist/src/tui/model/display.js +59 -0
- package/dist/src/tui/model/display.js.map +1 -0
- package/dist/src/tui/model/runtime.js +365 -0
- package/dist/src/tui/model/runtime.js.map +1 -0
- package/dist/src/tui/model/selection.js +160 -0
- package/dist/src/tui/model/selection.js.map +1 -0
- package/dist/src/tui/package-version.js +47 -0
- package/dist/src/tui/package-version.js.map +1 -0
- package/dist/src/tui/permissions/file-change-preview.js +182 -0
- package/dist/src/tui/permissions/file-change-preview.js.map +1 -0
- package/dist/src/tui/permissions/policy.js +223 -0
- package/dist/src/tui/permissions/policy.js.map +1 -0
- package/dist/src/tui/permissions/settings.js +21 -0
- package/dist/src/tui/permissions/settings.js.map +1 -0
- package/dist/src/tui/project/acp.js +93 -0
- package/dist/src/tui/project/acp.js.map +1 -0
- package/dist/src/tui/project/archive.js +239 -0
- package/dist/src/tui/project/archive.js.map +1 -0
- package/dist/src/tui/project/configuration-secrets.js +107 -0
- package/dist/src/tui/project/configuration-secrets.js.map +1 -0
- package/dist/src/tui/project/configuration.js +201 -0
- package/dist/src/tui/project/configuration.js.map +1 -0
- package/dist/src/tui/project/export.js +560 -0
- package/dist/src/tui/project/export.js.map +1 -0
- package/dist/src/tui/project/import.js +75 -0
- package/dist/src/tui/project/import.js.map +1 -0
- package/dist/src/tui/project/module-loader.js +157 -0
- package/dist/src/tui/project/module-loader.js.map +1 -0
- package/dist/src/tui/project/packaging.js +53 -0
- package/dist/src/tui/project/packaging.js.map +1 -0
- package/dist/src/tui/project/portable-dependencies.js +34 -0
- package/dist/src/tui/project/portable-dependencies.js.map +1 -0
- package/dist/src/tui/project/portable-mcp.js +118 -0
- package/dist/src/tui/project/portable-mcp.js.map +1 -0
- package/dist/src/tui/project/python.js +414 -0
- package/dist/src/tui/project/python.js.map +1 -0
- package/dist/src/tui/project/run.js +118 -0
- package/dist/src/tui/project/run.js.map +1 -0
- package/dist/src/tui/project/source.js +307 -0
- package/dist/src/tui/project/source.js.map +1 -0
- package/dist/src/tui/project/typescript.js +135 -0
- package/dist/src/tui/project/typescript.js.map +1 -0
- package/dist/src/tui/project/worker.py +731 -0
- package/dist/src/tui/provider/aws-client.js +67 -0
- package/dist/src/tui/provider/aws-client.js.map +1 -0
- package/dist/src/tui/provider/aws-config.js +66 -0
- package/dist/src/tui/provider/aws-config.js.map +1 -0
- package/dist/src/tui/provider/bedrock-catalog.js +87 -0
- package/dist/src/tui/provider/bedrock-catalog.js.map +1 -0
- package/dist/src/tui/provider/discovery.js +323 -0
- package/dist/src/tui/provider/discovery.js.map +1 -0
- package/dist/src/tui/provider/environment.js +138 -0
- package/dist/src/tui/provider/environment.js.map +1 -0
- package/dist/src/tui/provider/packages.js +42 -0
- package/dist/src/tui/provider/packages.js.map +1 -0
- package/dist/src/tui/run.js +257 -0
- package/dist/src/tui/run.js.map +1 -0
- package/dist/src/tui/runtime.js +520 -0
- package/dist/src/tui/runtime.js.map +1 -0
- package/dist/src/tui/session/agent-definition.js +100 -0
- package/dist/src/tui/session/agent-definition.js.map +1 -0
- package/dist/src/tui/session/catalog.js +159 -0
- package/dist/src/tui/session/catalog.js.map +1 -0
- package/dist/src/tui/session/context.js +118 -0
- package/dist/src/tui/session/context.js.map +1 -0
- package/dist/src/tui/session/conversation-helpers.js +46 -0
- package/dist/src/tui/session/conversation-helpers.js.map +1 -0
- package/dist/src/tui/session/conversations.js +456 -0
- package/dist/src/tui/session/conversations.js.map +1 -0
- package/dist/src/tui/session/desktop-profile.js +80 -0
- package/dist/src/tui/session/desktop-profile.js.map +1 -0
- package/dist/src/tui/session/options.js +44 -0
- package/dist/src/tui/session/options.js.map +1 -0
- package/dist/src/tui/session/sessions.js +251 -0
- package/dist/src/tui/session/sessions.js.map +1 -0
- package/dist/src/tui/session/voice.js +353 -0
- package/dist/src/tui/session/voice.js.map +1 -0
- package/dist/src/tui/settings.js +362 -0
- package/dist/src/tui/settings.js.map +1 -0
- package/dist/src/tui/setup/questions.js +277 -0
- package/dist/src/tui/setup/questions.js.map +1 -0
- package/dist/src/tui/skills.js +135 -0
- package/dist/src/tui/skills.js.map +1 -0
- package/dist/src/tui/steering.js +67 -0
- package/dist/src/tui/steering.js.map +1 -0
- package/dist/src/tui/strands-backend.js +368 -0
- package/dist/src/tui/strands-backend.js.map +1 -0
- package/dist/src/tui/stream-presentation.js +138 -0
- package/dist/src/tui/stream-presentation.js.map +1 -0
- package/dist/src/tui/telemetry.js +46 -0
- package/dist/src/tui/telemetry.js.map +1 -0
- package/dist/src/tui/terminal/composer.js +237 -0
- package/dist/src/tui/terminal/composer.js.map +1 -0
- package/dist/src/tui/terminal/directory-picker.js +76 -0
- package/dist/src/tui/terminal/directory-picker.js.map +1 -0
- package/dist/src/tui/terminal/ink.js +94 -0
- package/dist/src/tui/terminal/ink.js.map +1 -0
- package/dist/src/tui/terminal/mouse-input.js +83 -0
- package/dist/src/tui/terminal/mouse-input.js.map +1 -0
- package/dist/src/tui/terminal/open-url.js +21 -0
- package/dist/src/tui/terminal/open-url.js.map +1 -0
- package/dist/src/tui/terminal/process-tree.js +132 -0
- package/dist/src/tui/terminal/process-tree.js.map +1 -0
- package/dist/src/tui/terminal/sanitize.js +71 -0
- package/dist/src/tui/terminal/sanitize.js.map +1 -0
- package/dist/src/tui/terminal/shell-output.js +43 -0
- package/dist/src/tui/terminal/shell-output.js.map +1 -0
- package/dist/src/tui/terminal/terminal.js +39 -0
- package/dist/src/tui/terminal/terminal.js.map +1 -0
- package/dist/src/tui/view/agents-panel.js +21 -0
- package/dist/src/tui/view/agents-panel.js.map +1 -0
- package/dist/src/tui/view/app.js +1068 -0
- package/dist/src/tui/view/app.js.map +1 -0
- package/dist/src/tui/view/chat-root.js +88 -0
- package/dist/src/tui/view/chat-root.js.map +1 -0
- package/dist/src/tui/view/chat-view.js +185 -0
- package/dist/src/tui/view/chat-view.js.map +1 -0
- package/dist/src/tui/view/command-palette.js +18 -0
- package/dist/src/tui/view/command-palette.js.map +1 -0
- package/dist/src/tui/view/custom-theme-editor.js +301 -0
- package/dist/src/tui/view/custom-theme-editor.js.map +1 -0
- package/dist/src/tui/view/export-panel.js +14 -0
- package/dist/src/tui/view/export-panel.js.map +1 -0
- package/dist/src/tui/view/fade-in.js +106 -0
- package/dist/src/tui/view/fade-in.js.map +1 -0
- package/dist/src/tui/view/frog-canvas.js +375 -0
- package/dist/src/tui/view/frog-canvas.js.map +1 -0
- package/dist/src/tui/view/frog-drawing.js +415 -0
- package/dist/src/tui/view/frog-drawing.js.map +1 -0
- package/dist/src/tui/view/frog-easter-egg.js +53 -0
- package/dist/src/tui/view/frog-easter-egg.js.map +1 -0
- package/dist/src/tui/view/frog-intro-renderer.js +634 -0
- package/dist/src/tui/view/frog-intro-renderer.js.map +1 -0
- package/dist/src/tui/view/help-footer.js +36 -0
- package/dist/src/tui/view/help-footer.js.map +1 -0
- package/dist/src/tui/view/interaction.js +349 -0
- package/dist/src/tui/view/interaction.js.map +1 -0
- package/dist/src/tui/view/intro.js +35 -0
- package/dist/src/tui/view/intro.js.map +1 -0
- package/dist/src/tui/view/markdown.js +99 -0
- package/dist/src/tui/view/markdown.js.map +1 -0
- package/dist/src/tui/view/media.js +70 -0
- package/dist/src/tui/view/media.js.map +1 -0
- package/dist/src/tui/view/model-panel.js +65 -0
- package/dist/src/tui/view/model-panel.js.map +1 -0
- package/dist/src/tui/view/panel-components.js +17 -0
- package/dist/src/tui/view/panel-components.js.map +1 -0
- package/dist/src/tui/view/panels.js +129 -0
- package/dist/src/tui/view/panels.js.map +1 -0
- package/dist/src/tui/view/presentation.js +382 -0
- package/dist/src/tui/view/presentation.js.map +1 -0
- package/dist/src/tui/view/prompt-editor.js +74 -0
- package/dist/src/tui/view/prompt-editor.js.map +1 -0
- package/dist/src/tui/view/provider-list.js +14 -0
- package/dist/src/tui/view/provider-list.js.map +1 -0
- package/dist/src/tui/view/sessions-panel.js +15 -0
- package/dist/src/tui/view/sessions-panel.js.map +1 -0
- package/dist/src/tui/view/settings-panel.js +146 -0
- package/dist/src/tui/view/settings-panel.js.map +1 -0
- package/dist/src/tui/view/setup-question.js +90 -0
- package/dist/src/tui/view/setup-question.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/brand.js +18 -0
- package/dist/src/tui/view/setup-wizard/brand.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/index.js +1557 -0
- package/dist/src/tui/view/setup-wizard/index.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/opening-menu.js +88 -0
- package/dist/src/tui/view/setup-wizard/opening-menu.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/path-completion.js +53 -0
- package/dist/src/tui/view/setup-wizard/path-completion.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/profile-fields.js +29 -0
- package/dist/src/tui/view/setup-wizard/profile-fields.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/progress.js +42 -0
- package/dist/src/tui/view/setup-wizard/progress.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/providers.js +344 -0
- package/dist/src/tui/view/setup-wizard/providers.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/settings-panel.js +74 -0
- package/dist/src/tui/view/setup-wizard/settings-panel.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/steps.js +544 -0
- package/dist/src/tui/view/setup-wizard/steps.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/types.js +2 -0
- package/dist/src/tui/view/setup-wizard/types.js.map +1 -0
- package/dist/src/tui/view/setup-wizard/use-provider-discovery.js +145 -0
- package/dist/src/tui/view/setup-wizard/use-provider-discovery.js.map +1 -0
- package/dist/src/tui/view/startup-view.js +42 -0
- package/dist/src/tui/view/startup-view.js.map +1 -0
- package/dist/src/tui/view/text-input.js +33 -0
- package/dist/src/tui/view/text-input.js.map +1 -0
- package/dist/src/tui/view/theme-detection.js +45 -0
- package/dist/src/tui/view/theme-detection.js.map +1 -0
- package/dist/src/tui/view/theme.js +127 -0
- package/dist/src/tui/view/theme.js.map +1 -0
- package/dist/src/tui/view/transcript-layout.js +60 -0
- package/dist/src/tui/view/transcript-layout.js.map +1 -0
- package/dist/src/tui/view/transcript-turn.js +135 -0
- package/dist/src/tui/view/transcript-turn.js.map +1 -0
- package/dist/src/tui/view/transcript.js +138 -0
- package/dist/src/tui/view/transcript.js.map +1 -0
- package/dist/src/tui/view/use-party-frame.js +15 -0
- package/dist/src/tui/view/use-party-frame.js.map +1 -0
- package/dist/src/tui/view/use-spinner.js +14 -0
- package/dist/src/tui/view/use-spinner.js.map +1 -0
- package/dist/src/tui/voice/session.js +515 -0
- package/dist/src/tui/voice/session.js.map +1 -0
- package/dist/src/tui/workspace/sandbox.js +156 -0
- package/dist/src/tui/workspace/sandbox.js.map +1 -0
- package/dist/src/tui/workspace/trust.js +147 -0
- package/dist/src/tui/workspace/trust.js.map +1 -0
- package/dist/src/usage.js +187 -0
- package/dist/src/usage.js.map +1 -0
- package/package.json +97 -0
- package/src/tui/voice/sidecar.py +606 -0
|
@@ -0,0 +1,1557 @@
|
|
|
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, useWindowSize } from 'ink';
|
|
4
|
+
import { PROVIDER_CREDENTIAL_KEYS, PROVIDER_ENVIRONMENT_KEYS, PROVIDER_LABELS, PROVIDER_IDS, } from '../../config.js';
|
|
5
|
+
import { importAgentProject } from '../../project/import.js';
|
|
6
|
+
import { configurationFromStore } from '../../agent-configuration.js';
|
|
7
|
+
import { DEFAULT_SETTINGS_CATEGORY, SETTINGS_CATEGORIES } from '../../settings.js';
|
|
8
|
+
import { parseMouseInput } from '../../terminal/mouse-input.js';
|
|
9
|
+
import { emptyEditor, graphemes, reduceInputSequence } from '../../terminal/composer.js';
|
|
10
|
+
import { errorMessage, sanitizeTerminalText } from '../../terminal/sanitize.js';
|
|
11
|
+
import { canChooseDirectory, chooseAgentProject, chooseDirectory } from '../../terminal/directory-picker.js';
|
|
12
|
+
import { setTerminalMouseMotion } from '../../terminal/terminal.js';
|
|
13
|
+
import { frogStartupHeight, renderSetupGuideTransitionFrame, SETUP_GUIDE_TRANSITION_DURATION_MS, setupGuideLayout, } from '../frog-intro-renderer.js';
|
|
14
|
+
import { elementAtMouse, elementContainsMouse, registerElement, mouseScrollDirection, scrollPanelViewport, revealPanelSelection, sliderOptionAtMouse, } from '../interaction.js';
|
|
15
|
+
import { wrapLines } from '../presentation.js';
|
|
16
|
+
import { Text, ThemeProvider, useTheme } from '../theme.js';
|
|
17
|
+
import { BlinkingCursor, EditableText } from '../text-input.js';
|
|
18
|
+
import { CustomThemeEditor } from '../custom-theme-editor.js';
|
|
19
|
+
import { Fade, mixHexColors, useFadeTransition } from '../fade-in.js';
|
|
20
|
+
import { PROVIDERS, compatibleProfile, exaWebSearchActive, providerAssessment, providerFromModel, quickstartDraft, } from './providers.js';
|
|
21
|
+
import { EXA_WEB_SEARCH_WARNING } from '../../builtin-tools.js';
|
|
22
|
+
import { memoryForDir } from './profile-fields.js';
|
|
23
|
+
import { APPEARANCE_STEP, appearanceSettings, MANUAL_STEPS, OPENING_CHOICES, rowsForStep, setupStepProgress, wizardSettingsRows, } from './steps.js';
|
|
24
|
+
import { useBrandAnimation } from '../startup-view.js';
|
|
25
|
+
import { SetupBrand } from './brand.js';
|
|
26
|
+
import { OpeningMenu } from './opening-menu.js';
|
|
27
|
+
import { SetupSettingsPanel } from './settings-panel.js';
|
|
28
|
+
import { EffortSlider } from '../model-panel.js';
|
|
29
|
+
import { ProviderList } from '../provider-list.js';
|
|
30
|
+
import { useProviderDiscovery, useProviderDiscoveryEffects } from './use-provider-discovery.js';
|
|
31
|
+
import { importPathCompletions } from './path-completion.js';
|
|
32
|
+
import { SetupProgress } from './progress.js';
|
|
33
|
+
export function SetupWizard(props) {
|
|
34
|
+
const [appearance, setAppearance] = useState(() => appearanceSettings({ ...props.config.snapshot().settings, ...props.initialSettings }));
|
|
35
|
+
return (_jsx(ThemeProvider, { settings: appearance, children: _jsx(SetupWizardContent, { ...props, appearance: appearance, setAppearance: setAppearance }) }));
|
|
36
|
+
}
|
|
37
|
+
function SetupWizardContent({ appearance, setAppearance, config, deferred = false, appearanceOnly = false, onComplete, onCancel, onAgentSetup, initialSettings, }) {
|
|
38
|
+
const { stdout } = useStdout();
|
|
39
|
+
const { columns, rows: terminalRows } = useWindowSize();
|
|
40
|
+
const [flow, setFlow] = useState();
|
|
41
|
+
const [step, setStep] = useState(appearanceOnly ? APPEARANCE_STEP : 0);
|
|
42
|
+
const [settingsReturn, setSettingsReturn] = useState();
|
|
43
|
+
const [settingsCategory, setSettingsCategory] = useState(DEFAULT_SETTINGS_CATEGORY);
|
|
44
|
+
const [panelSettings, setPanelSettings] = useState(() => globalThis.structuredClone({ ...config.snapshot().settings, ...initialSettings }));
|
|
45
|
+
const [appearanceOpen, setAppearanceOpen] = useState(false);
|
|
46
|
+
const priorAppearance = useRef(appearance);
|
|
47
|
+
const openAppearance = useCallback(() => {
|
|
48
|
+
priorAppearance.current = appearance;
|
|
49
|
+
setAppearanceOpen(true);
|
|
50
|
+
}, [appearance]);
|
|
51
|
+
const previewAppearance = useCallback((next) => {
|
|
52
|
+
setAppearance((current) => ({ ...current, ...next }));
|
|
53
|
+
}, [setAppearance]);
|
|
54
|
+
function closeAppearance() {
|
|
55
|
+
setAppearance(priorAppearance.current);
|
|
56
|
+
setAppearanceOpen(false);
|
|
57
|
+
}
|
|
58
|
+
const palette = useTheme();
|
|
59
|
+
const { surface: COMMAND_DECK_BACKGROUND, panel: PANEL_BACKGROUND, selection: PANEL_SELECTION } = palette;
|
|
60
|
+
const panelTransition = useFadeTransition(appearance.animations);
|
|
61
|
+
const [selection, setSelection] = useState(0);
|
|
62
|
+
const [openingSelectionVisible, setOpeningSelectionVisible] = useState(false);
|
|
63
|
+
const [hoveredControl, setHoveredControl] = useState();
|
|
64
|
+
const [focusedAction, setFocusedAction] = useState();
|
|
65
|
+
const [draft, setDraft] = useState(() => {
|
|
66
|
+
const snapshot = config.snapshot();
|
|
67
|
+
const settings = { ...snapshot.settings, ...initialSettings };
|
|
68
|
+
return {
|
|
69
|
+
providers: [...snapshot.providers.enabled],
|
|
70
|
+
profile: snapshot.profile,
|
|
71
|
+
permissionMode: snapshot.permissions.mode,
|
|
72
|
+
allowedTools: [...snapshot.permissions.allow],
|
|
73
|
+
customPermissions: snapshot.permissions.mode === 'default' && snapshot.permissions.allow.length > 0,
|
|
74
|
+
settings: {
|
|
75
|
+
mcpDiscovery: settings.mcpDiscovery,
|
|
76
|
+
skillDiscovery: settings.skillDiscovery,
|
|
77
|
+
agentMessaging: settings.agentMessaging,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
const [setupTarget, setSetupTarget] = useState();
|
|
82
|
+
const [profileBaseDir] = useState(() => config.snapshot().profileBaseDir);
|
|
83
|
+
const [importPath, setImportPath] = useState('');
|
|
84
|
+
const [importedEntrypoint, setImportedEntrypoint] = useState();
|
|
85
|
+
const [editing, setEditing] = useState();
|
|
86
|
+
const [pathCompletionIndex, setPathCompletionIndex] = useState(-1);
|
|
87
|
+
const [error, setError] = useState();
|
|
88
|
+
const [saving, setSaving] = useState(false);
|
|
89
|
+
const [choosingDirectory, setChoosingDirectory] = useState(false);
|
|
90
|
+
const choosingDirectoryRef = useRef(false);
|
|
91
|
+
const discovery = useProviderDiscovery(config);
|
|
92
|
+
const { detectedEnvironment, providerEnvironment, setProviderEnvironment, awsDiscovery, ollamaDiscovery, liteLlmDiscovery, providerModels, effectiveEnvironment, readyProviders, recheck, } = discovery;
|
|
93
|
+
const [modelViewportStart, setModelViewportStart] = useState(0);
|
|
94
|
+
const [modelQuery, setModelQuery] = useState('');
|
|
95
|
+
const [modelSearchFocused, setModelSearchFocused] = useState(false);
|
|
96
|
+
const modelListElement = useRef(null);
|
|
97
|
+
const modelSearchElement = useRef(null);
|
|
98
|
+
const setupEffortSliderElement = useRef(null);
|
|
99
|
+
const [quickstartProvider, setQuickstartProvider] = useState('bedrock');
|
|
100
|
+
const [selecting, setSelecting] = useState();
|
|
101
|
+
const [frogAnimationId, setFrogAnimationId] = useState();
|
|
102
|
+
const [agentHandoff, setAgentHandoff] = useState();
|
|
103
|
+
const [agentHandoffElapsedMs, setAgentHandoffElapsedMs] = useState(0);
|
|
104
|
+
const agentHandoffDelivered = useRef(false);
|
|
105
|
+
const rowElements = useRef(new Map());
|
|
106
|
+
const directoryElements = useRef(new Map());
|
|
107
|
+
const pathCompletionElements = useRef(new Map());
|
|
108
|
+
const selectOptionElements = useRef(new Map());
|
|
109
|
+
const choiceElements = useRef(new Map());
|
|
110
|
+
const backElement = useRef(undefined);
|
|
111
|
+
const nextElement = useRef(undefined);
|
|
112
|
+
const settingsElement = useRef(undefined);
|
|
113
|
+
const frogElement = useRef(undefined);
|
|
114
|
+
const frogPress = useRef(undefined);
|
|
115
|
+
const pressedElement = useRef(undefined);
|
|
116
|
+
const width = Math.max(1, columns);
|
|
117
|
+
const height = Math.max(1, terminalRows);
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (!agentHandoff || !onAgentSetup) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const duration = appearance.animations ? SETUP_GUIDE_TRANSITION_DURATION_MS : 0;
|
|
123
|
+
const startedAt = Date.now();
|
|
124
|
+
const finish = () => {
|
|
125
|
+
if (!agentHandoffDelivered.current) {
|
|
126
|
+
agentHandoffDelivered.current = true;
|
|
127
|
+
onAgentSetup(agentHandoff);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
setAgentHandoffElapsedMs(duration === 0 ? SETUP_GUIDE_TRANSITION_DURATION_MS : 0);
|
|
131
|
+
if (duration === 0) {
|
|
132
|
+
finish();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const timer = setInterval(() => {
|
|
136
|
+
const elapsed = Math.min(duration, Date.now() - startedAt);
|
|
137
|
+
setAgentHandoffElapsedMs(elapsed);
|
|
138
|
+
if (elapsed >= duration) {
|
|
139
|
+
clearInterval(timer);
|
|
140
|
+
finish();
|
|
141
|
+
}
|
|
142
|
+
}, 32);
|
|
143
|
+
return () => clearInterval(timer);
|
|
144
|
+
}, [agentHandoff, appearance.animations, onAgentSetup]);
|
|
145
|
+
const navigationHeight = width < 32 ? 2 : 3;
|
|
146
|
+
const accent = palette.accent;
|
|
147
|
+
const pathEditing = editing?.field === 'importPath' ? editing : undefined;
|
|
148
|
+
const pathCompletions = useMemo(() => {
|
|
149
|
+
if (!pathEditing ||
|
|
150
|
+
(pathEditing.cursor ?? graphemes(pathEditing.value).length) !== graphemes(pathEditing.value).length) {
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
return importPathCompletions(pathEditing.value);
|
|
154
|
+
}, [pathEditing]);
|
|
155
|
+
const importCompletionCapacity = Math.min(pathCompletions.length, 4);
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
setPathCompletionIndex(-1);
|
|
158
|
+
}, [pathEditing?.value]);
|
|
159
|
+
const isAppearance = step === APPEARANCE_STEP;
|
|
160
|
+
const isSettings = isAppearance && settingsReturn !== undefined;
|
|
161
|
+
const progress = appearanceOnly || isSettings ? undefined : setupStepProgress(flow, step);
|
|
162
|
+
const progressHeight = progress ? 3 : 0;
|
|
163
|
+
const updateAppearance = useCallback((next) => {
|
|
164
|
+
setAppearance(next);
|
|
165
|
+
setPanelSettings((current) => ({ ...current, ...next }));
|
|
166
|
+
if (isSettings) {
|
|
167
|
+
setError(undefined);
|
|
168
|
+
void config
|
|
169
|
+
.setSettings(next)
|
|
170
|
+
.catch((cause) => setError(cause instanceof Error ? cause.message : String(cause)));
|
|
171
|
+
}
|
|
172
|
+
}, [config, isSettings, setAppearance]);
|
|
173
|
+
const updateSettings = useCallback((next) => {
|
|
174
|
+
setPanelSettings(next);
|
|
175
|
+
setAppearance(appearanceSettings(next));
|
|
176
|
+
setDraft((current) => ({
|
|
177
|
+
...current,
|
|
178
|
+
settings: {
|
|
179
|
+
...current.settings,
|
|
180
|
+
mcpDiscovery: next.mcpDiscovery,
|
|
181
|
+
skillDiscovery: next.skillDiscovery,
|
|
182
|
+
agentMessaging: next.agentMessaging,
|
|
183
|
+
},
|
|
184
|
+
}));
|
|
185
|
+
setError(undefined);
|
|
186
|
+
void config
|
|
187
|
+
.setSettings(next)
|
|
188
|
+
.catch((cause) => setError(cause instanceof Error ? cause.message : String(cause)));
|
|
189
|
+
}, [config, setAppearance]);
|
|
190
|
+
const updateSetupSettings = useCallback((next) => {
|
|
191
|
+
setPanelSettings(next);
|
|
192
|
+
setAppearance(appearanceSettings(next));
|
|
193
|
+
setDraft((current) => ({
|
|
194
|
+
...current,
|
|
195
|
+
settings: {
|
|
196
|
+
...current.settings,
|
|
197
|
+
mcpDiscovery: next.mcpDiscovery,
|
|
198
|
+
skillDiscovery: next.skillDiscovery,
|
|
199
|
+
agentMessaging: next.agentMessaging,
|
|
200
|
+
},
|
|
201
|
+
}));
|
|
202
|
+
}, [setAppearance]);
|
|
203
|
+
const isProviderSetup = (flow === 'quickstart' || flow === 'manual' || flow === 'agent') && step === 1;
|
|
204
|
+
const isTools = (flow === 'quickstart' && step === 2) || (flow === 'manual' && step === 3);
|
|
205
|
+
const isPlugins = (flow === 'quickstart' && step === 3) || (flow === 'manual' && step === 4);
|
|
206
|
+
const isCapabilities = isTools || isPlugins;
|
|
207
|
+
const isPermissions = flow === 'manual' && step === 6;
|
|
208
|
+
const isImport = flow === 'import' && step === 1;
|
|
209
|
+
const hasExternalActions = !isSettings && (isProviderSetup || isImport || isCapabilities || isAppearance || flow === 'manual');
|
|
210
|
+
const bubbleWidth = Math.max(1, Math.min(isProviderSetup ? 118 : 112, width - 2));
|
|
211
|
+
const lockupWidth = Math.max(1, width - 2);
|
|
212
|
+
const minimumContentHeight = step === 0 ? 20 : isProviderSetup ? 24 : 22;
|
|
213
|
+
const brandAvailableHeight = Math.max(1, height - minimumContentHeight);
|
|
214
|
+
const fullLockupHeight = frogStartupHeight(lockupWidth, Number.POSITIVE_INFINITY);
|
|
215
|
+
const lockupHeight = lockupWidth >= 74 && brandAvailableHeight >= fullLockupHeight + 2
|
|
216
|
+
? fullLockupHeight
|
|
217
|
+
: frogStartupHeight(lockupWidth, brandAvailableHeight);
|
|
218
|
+
const showBrand = lockupHeight > 1;
|
|
219
|
+
const brandHeight = showBrand ? lockupHeight + 2 : 0;
|
|
220
|
+
const openingColumns = lockupWidth >= 64 ? 2 : 1;
|
|
221
|
+
const openingRows = Math.ceil(OPENING_CHOICES.length / openingColumns);
|
|
222
|
+
const openingRowGap = openingColumns === 2 ? 2 : 1;
|
|
223
|
+
const openingContentHeight = height - brandHeight - navigationHeight - Number(error !== undefined);
|
|
224
|
+
const openingTopGap = openingContentHeight >= openingRows * (openingColumns === 2 ? 9 : 5) + (openingRows - 1) * openingRowGap + 3
|
|
225
|
+
? 3
|
|
226
|
+
: openingContentHeight >= openingRows * (openingColumns === 2 ? 8 : 5) + (openingRows - 1) * openingRowGap + 2
|
|
227
|
+
? 2
|
|
228
|
+
: openingContentHeight >= openingRows * 3 + (openingRows - 1) * openingRowGap + 1
|
|
229
|
+
? 1
|
|
230
|
+
: 0;
|
|
231
|
+
const openingButtonHeight = Math.max(1, Math.min(openingColumns === 2 ? 9 : 5, Math.floor((openingContentHeight - openingTopGap - (openingRows - 1) * openingRowGap) / openingRows)));
|
|
232
|
+
const actionHeight = height >= 20 ? 3 : 1;
|
|
233
|
+
const actionGap = height >= 24 ? 1 : 0;
|
|
234
|
+
const actionColumnGap = bubbleWidth >= 3 ? 1 : 0;
|
|
235
|
+
const actionWidth = Math.max(1, Math.floor((bubbleWidth - actionColumnGap) / 2));
|
|
236
|
+
const splitQuickstart = isProviderSetup && bubbleWidth >= 38;
|
|
237
|
+
const quickstartProviderColumnWidth = Math.max(16, Math.min(31, Math.floor(bubbleWidth * 0.34)));
|
|
238
|
+
const quickstartDetailColumnWidth = bubbleWidth - quickstartProviderColumnWidth - 2;
|
|
239
|
+
const rowHeight = isAppearance
|
|
240
|
+
? 2
|
|
241
|
+
: isProviderSetup
|
|
242
|
+
? 4
|
|
243
|
+
: isCapabilities
|
|
244
|
+
? 2
|
|
245
|
+
: isPermissions
|
|
246
|
+
? 2
|
|
247
|
+
: flow === 'manual'
|
|
248
|
+
? step === 2
|
|
249
|
+
? 5
|
|
250
|
+
: 3
|
|
251
|
+
: 2;
|
|
252
|
+
const updateProfile = useCallback((update) => {
|
|
253
|
+
setDraft((current) => ({ ...current, profile: { ...current.profile, ...update } }));
|
|
254
|
+
}, []);
|
|
255
|
+
const rows = useMemo(() => {
|
|
256
|
+
const stepRows = isAppearance
|
|
257
|
+
? wizardSettingsRows({ ...panelSettings, ...draft.settings, ...appearance }, isSettings ? updateSettings : updateSetupSettings, openAppearance, 'all').filter(({ section }) => section === settingsCategory)
|
|
258
|
+
: rowsForStep(step, flow, draft, importPath, providerEnvironment, detectedEnvironment, quickstartProvider, readyProviders, awsDiscovery, ollamaDiscovery, setDraft, updateProfile, setEditing, liteLlmDiscovery);
|
|
259
|
+
return isProviderSetup
|
|
260
|
+
? [
|
|
261
|
+
...stepRows,
|
|
262
|
+
{
|
|
263
|
+
id: 'refresh-provider',
|
|
264
|
+
label: '↻ Refresh',
|
|
265
|
+
description: '',
|
|
266
|
+
activate: () => {
|
|
267
|
+
try {
|
|
268
|
+
recheck();
|
|
269
|
+
setError(undefined);
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
setError(errorMessage(error));
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
]
|
|
277
|
+
: stepRows;
|
|
278
|
+
}, [
|
|
279
|
+
appearance,
|
|
280
|
+
panelSettings,
|
|
281
|
+
openAppearance,
|
|
282
|
+
updateSetupSettings,
|
|
283
|
+
updateSettings,
|
|
284
|
+
isAppearance,
|
|
285
|
+
isSettings,
|
|
286
|
+
settingsCategory,
|
|
287
|
+
isProviderSetup,
|
|
288
|
+
awsDiscovery,
|
|
289
|
+
detectedEnvironment,
|
|
290
|
+
draft,
|
|
291
|
+
flow,
|
|
292
|
+
importPath,
|
|
293
|
+
ollamaDiscovery,
|
|
294
|
+
liteLlmDiscovery,
|
|
295
|
+
providerEnvironment,
|
|
296
|
+
quickstartProvider,
|
|
297
|
+
readyProviders,
|
|
298
|
+
recheck,
|
|
299
|
+
step,
|
|
300
|
+
updateProfile,
|
|
301
|
+
]);
|
|
302
|
+
const selectedModelProvider = providerFromModel(draft.profile.model);
|
|
303
|
+
const canContinue = step !== 1 ||
|
|
304
|
+
(flow === 'import'
|
|
305
|
+
? importPath.trim().length > 0
|
|
306
|
+
: isProviderSetup
|
|
307
|
+
? selectedModelProvider === quickstartProvider && readyProviders.includes(quickstartProvider)
|
|
308
|
+
: draft.providers.some((provider) => readyProviders.includes(provider)));
|
|
309
|
+
const inspectedProvider = isProviderSetup ? quickstartProvider : undefined;
|
|
310
|
+
const inspectedAssessment = inspectedProvider
|
|
311
|
+
? providerAssessment(inspectedProvider, effectiveEnvironment, awsDiscovery, ollamaDiscovery, liteLlmDiscovery)
|
|
312
|
+
: undefined;
|
|
313
|
+
const warning = inspectedAssessment?.warning;
|
|
314
|
+
const assessmentFacts = inspectedAssessment?.facts ?? [];
|
|
315
|
+
const bannerWarning = warning
|
|
316
|
+
? assessmentFacts.length > 0
|
|
317
|
+
? [
|
|
318
|
+
PROVIDER_LABELS[inspectedProvider],
|
|
319
|
+
...assessmentFacts.map((fact) => `${fact.label}: ${fact.value}`),
|
|
320
|
+
'',
|
|
321
|
+
warning,
|
|
322
|
+
].join('\n')
|
|
323
|
+
: `${PROVIDER_LABELS[inspectedProvider]}: ${warning}`
|
|
324
|
+
: isTools && exaWebSearchActive(draft.profile)
|
|
325
|
+
? EXA_WEB_SEARCH_WARNING
|
|
326
|
+
: undefined;
|
|
327
|
+
const bannerWarningStatus = warning ? inspectedAssessment.status : 'warning';
|
|
328
|
+
const providerReady = isProviderSetup && readyProviders.includes(quickstartProvider);
|
|
329
|
+
const showProviderConfiguration = isProviderSetup && !providerReady;
|
|
330
|
+
const modelPanelVisible = splitQuickstart && providerReady;
|
|
331
|
+
const availableBubbleHeight = Math.max(1, height - brandHeight - progressHeight - (hasExternalActions ? actionHeight + actionGap : 0) - navigationHeight);
|
|
332
|
+
const warningLines = bannerWarning && !splitQuickstart
|
|
333
|
+
? wrapLines(`⚠ ${bannerWarning}`, Math.max(1, bubbleWidth - 4)).slice(0, Math.max(0, availableBubbleHeight - rowHeight - 1 - Number(error !== undefined)))
|
|
334
|
+
: [];
|
|
335
|
+
const extraRows = Number(error !== undefined) + warningLines.length;
|
|
336
|
+
const capabilityContentHeight = Math.max(0, rows.length - 1) * rowHeight + 2;
|
|
337
|
+
const bubbleHeight = isImport
|
|
338
|
+
? Math.min(9 + extraRows + importCompletionCapacity, availableBubbleHeight)
|
|
339
|
+
: isCapabilities
|
|
340
|
+
? Math.min(capabilityContentHeight + extraRows, availableBubbleHeight)
|
|
341
|
+
: isPermissions
|
|
342
|
+
? Math.min(9 + Math.max(0, rows.length - 3) * rowHeight + extraRows, availableBubbleHeight)
|
|
343
|
+
: isAppearance
|
|
344
|
+
? availableBubbleHeight
|
|
345
|
+
: flow === 'manual' && !isProviderSetup
|
|
346
|
+
? Math.min(rows.length * rowHeight + 3 + extraRows, availableBubbleHeight)
|
|
347
|
+
: availableBubbleHeight;
|
|
348
|
+
const panelChromeHeight = isProviderSetup || isCapabilities ? 0 : isAppearance || flow === 'manual' ? 2 : 4;
|
|
349
|
+
const rowCapacity = isAppearance
|
|
350
|
+
? settingsCategory === 'Appearance' && bubbleHeight < 18
|
|
351
|
+
? 1
|
|
352
|
+
: rows.length
|
|
353
|
+
: Math.max(1, Math.floor((bubbleHeight - panelChromeHeight - extraRows) / rowHeight));
|
|
354
|
+
const firstListRow = isCapabilities ? 1 : 0;
|
|
355
|
+
const viewportStart = Math.max(firstListRow, Math.min(selection - rowCapacity + 1, rows.length - rowCapacity));
|
|
356
|
+
const visibleRows = rows.slice(viewportStart, viewportStart + rowCapacity);
|
|
357
|
+
const visibleCapabilityRows = isCapabilities ? visibleRows.filter((row) => row.id !== 'select-all') : [];
|
|
358
|
+
const permissionToolCapacity = Math.max(1, Math.floor((bubbleHeight - 9 - extraRows) / rowHeight));
|
|
359
|
+
const permissionViewportStart = Math.max(3, Math.min(selection - permissionToolCapacity + 1, rows.length - permissionToolCapacity));
|
|
360
|
+
const visiblePermissionTools = rows.slice(permissionViewportStart, permissionViewportStart + permissionToolCapacity);
|
|
361
|
+
const providerRows = isProviderSetup ? rows.slice(0, PROVIDER_IDS.length) : [];
|
|
362
|
+
const providerFieldRows = isProviderSetup ? rows.slice(PROVIDER_IDS.length) : [];
|
|
363
|
+
const refreshRow = providerFieldRows.find((row) => row.id === 'refresh-provider');
|
|
364
|
+
const providerConfigurationRows = providerFieldRows.filter((row) => row.id !== 'refresh-provider');
|
|
365
|
+
const providerWarningStatus = providerConfigurationRows.some((row) => row.input === true && PROVIDER_CREDENTIAL_KEYS.includes(row.field))
|
|
366
|
+
? 'error'
|
|
367
|
+
: bannerWarningStatus;
|
|
368
|
+
const availableReasoningRow = providerConfigurationRows.find((row) => row.id === 'thinking');
|
|
369
|
+
const selectedModelAvailable = providerModels.provider === quickstartProvider &&
|
|
370
|
+
providerModels.available &&
|
|
371
|
+
!providerModels.loading &&
|
|
372
|
+
providerModels.models.some((model) => `${quickstartProvider}/${model.id}` === draft.profile.model);
|
|
373
|
+
const reasoningRow = selectedModelAvailable ? availableReasoningRow : undefined;
|
|
374
|
+
const reasoningRowIndex = reasoningRow ? rows.indexOf(reasoningRow) : -1;
|
|
375
|
+
const hiddenReasoningRowIndex = availableReasoningRow && !reasoningRow ? rows.indexOf(availableReasoningRow) : -1;
|
|
376
|
+
const reasoningSlider = reasoningRow?.choices && reasoningRow.choices.length > 0
|
|
377
|
+
? {
|
|
378
|
+
label: 'Effort',
|
|
379
|
+
options: reasoningRow.choices.map((choice, index) => ({
|
|
380
|
+
id: String(index),
|
|
381
|
+
label: choice.label,
|
|
382
|
+
...(choice.active ? { active: true } : {}),
|
|
383
|
+
})),
|
|
384
|
+
...(reasoningRow.disabled ? { disabled: true } : {}),
|
|
385
|
+
}
|
|
386
|
+
: undefined;
|
|
387
|
+
const showReasoningPanel = modelPanelVisible && reasoningSlider !== undefined && quickstartDetailColumnWidth >= 62;
|
|
388
|
+
const readyProviderControlRows = providerConfigurationRows.filter((row) => row.id !== 'thinking' || (reasoningRow !== undefined && !showReasoningPanel));
|
|
389
|
+
const directoryRows = new Map(rows.flatMap((row, index) => canChooseDirectory() && !row.disabled && (row.field === 'memoryDir' || row.field === 'skills')
|
|
390
|
+
? [[index, row.field]]
|
|
391
|
+
: []));
|
|
392
|
+
const quickstartBodyHeight = bubbleHeight - panelChromeHeight - extraRows;
|
|
393
|
+
const providerFooterHeight = refreshRow ? 4 : 0;
|
|
394
|
+
const quickstartProviderListCapacity = Math.max(1, quickstartBodyHeight - 2 - providerFooterHeight);
|
|
395
|
+
const quickstartProviderRowHeight = quickstartProviderListCapacity >= PROVIDER_IDS.length * 3 - 1
|
|
396
|
+
? 3
|
|
397
|
+
: quickstartProviderListCapacity >= PROVIDER_IDS.length * 2
|
|
398
|
+
? 2
|
|
399
|
+
: 1;
|
|
400
|
+
const quickstartProviderListHeight = Math.min(quickstartProviderListCapacity, PROVIDER_IDS.length * quickstartProviderRowHeight);
|
|
401
|
+
const quickstartFieldRowHeight = 5;
|
|
402
|
+
const middleFacts = splitQuickstart && showProviderConfiguration ? assessmentFacts : [];
|
|
403
|
+
const middleFactsHeight = middleFacts.length;
|
|
404
|
+
const middleDetailGap = middleFacts.length > 0 && warning ? 1 : 0;
|
|
405
|
+
const middleFieldGap = warning && providerConfigurationRows.length > 0 ? 1 : 0;
|
|
406
|
+
const quickstartFieldReserve = providerConfigurationRows.length > 0 ? quickstartFieldRowHeight : 0;
|
|
407
|
+
const middleWarningLines = splitQuickstart && showProviderConfiguration && warning
|
|
408
|
+
? wrapLines(warning, quickstartDetailColumnWidth - 3).slice(0, Math.max(0, quickstartBodyHeight - quickstartFieldReserve - middleFactsHeight - middleDetailGap - middleFieldGap))
|
|
409
|
+
: [];
|
|
410
|
+
const middleDetailHeight = middleFactsHeight + middleDetailGap + middleWarningLines.length + middleFieldGap;
|
|
411
|
+
const quickstartFieldCapacity = Math.max(1, Math.floor((quickstartBodyHeight - middleDetailHeight) / quickstartFieldRowHeight));
|
|
412
|
+
const selectedField = providerConfigurationRows.findIndex((row) => row === rows[selection]);
|
|
413
|
+
const quickstartFieldViewportStart = Math.max(0, Math.min(selectedField - quickstartFieldCapacity + 1, providerConfigurationRows.length - quickstartFieldCapacity));
|
|
414
|
+
const visibleProviderFieldRows = providerConfigurationRows.slice(quickstartFieldViewportStart, quickstartFieldViewportStart + quickstartFieldCapacity);
|
|
415
|
+
const filteredProviderModels = useMemo(() => {
|
|
416
|
+
const query = modelQuery.trim().toLowerCase();
|
|
417
|
+
return providerModels.models.filter((model) => `${model.name} ${model.id}`.toLowerCase().includes(query));
|
|
418
|
+
}, [modelQuery, providerModels.models]);
|
|
419
|
+
const quickstartModelOffset = rows.length;
|
|
420
|
+
const defaultModel = quickstartProvider === 'ollama' ? undefined : PROVIDERS[quickstartProvider].model(effectiveEnvironment);
|
|
421
|
+
const quickstartDefaultModel = defaultModel?.slice(defaultModel.indexOf('/') + 1);
|
|
422
|
+
const readyProviderControlsHeight = readyProviderControlRows.length * quickstartFieldRowHeight;
|
|
423
|
+
const quickstartModelRowHeight = 2;
|
|
424
|
+
const quickstartModelCapacity = Math.max(1, Math.floor((quickstartBodyHeight - 5 - readyProviderControlsHeight) / quickstartModelRowHeight));
|
|
425
|
+
const quickstartModelViewportStart = Math.max(0, Math.min(modelViewportStart, filteredProviderModels.length - quickstartModelCapacity));
|
|
426
|
+
const visibleProviderModels = filteredProviderModels.slice(quickstartModelViewportStart, quickstartModelViewportStart + quickstartModelCapacity);
|
|
427
|
+
const quickstartSelectableRows = rows.length + (modelPanelVisible && providerModels.available ? filteredProviderModels.length : 0);
|
|
428
|
+
const controlBackground = (control, focused, disabled = false) => {
|
|
429
|
+
if (disabled || saving) {
|
|
430
|
+
return undefined;
|
|
431
|
+
}
|
|
432
|
+
return hoveredControl === control || focused ? PANEL_SELECTION : undefined;
|
|
433
|
+
};
|
|
434
|
+
const rowBackground = (index) => {
|
|
435
|
+
return controlBackground(index, focusedAction === undefined && !modelSearchFocused && index === selection, rows[index]?.disabled);
|
|
436
|
+
};
|
|
437
|
+
const backHoverBackground = mixHexColors(COMMAND_DECK_BACKGROUND, palette.error, palette.mode === 'dark' ? 0.22 : 0.16);
|
|
438
|
+
const nextHoverBackground = mixHexColors(COMMAND_DECK_BACKGROUND, palette.accent, palette.mode === 'dark' ? 0.22 : 0.16);
|
|
439
|
+
const renderCapabilityRows = (capabilityRows) => (_jsx(Box, { flexGrow: 1, paddingX: 1, flexDirection: "column", overflow: "hidden", children: capabilityRows.map((row) => {
|
|
440
|
+
const index = rows.indexOf(row);
|
|
441
|
+
return (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), height: 2, paddingX: 1, flexShrink: 0, flexDirection: "column", backgroundColor: rowBackground(index), children: [_jsxs(Text, { color: row.active ? accent : palette.foreground, bold: index === selection, children: [row.active ? '☑' : '☐', " ", row.label] }), _jsxs(Text, { ...(row.descriptionColor ? { color: row.descriptionColor } : { dimColor: true }), wrap: "truncate-end", children: [' ', row.description] })] }, row.id));
|
|
442
|
+
}) }));
|
|
443
|
+
const renderChoices = (choices, index) => (_jsx(Box, { flexWrap: "wrap", children: choices.map((choice, choiceIndex) => {
|
|
444
|
+
const target = `choice:${index}:${choiceIndex}`;
|
|
445
|
+
return (_jsx(Box, { ref: (element) => registerElement(choiceElements.current, target, element), paddingX: 1, marginRight: 1, backgroundColor: controlBackground(target, choice.active), children: _jsx(Text, { bold: choice.active, ...(choice.active ? { color: accent } : {}), children: choice.label }) }, choice.label));
|
|
446
|
+
}) }));
|
|
447
|
+
const renderRefreshButton = (row, fieldWidth, compact = false) => {
|
|
448
|
+
const index = rows.indexOf(row);
|
|
449
|
+
const buttonWidth = Math.max(10, Math.floor(fieldWidth / 2));
|
|
450
|
+
return (_jsx(Box, { height: compact ? 4 : 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: 3, backgroundColor: rowBackground(index) ?? COMMAND_DECK_BACKGROUND, flexDirection: "column", justifyContent: "center", alignItems: "center", children: _jsx(Text, { bold: true, color: index === selection ? accent : palette.foreground, children: row.label }) }) }, row.id));
|
|
451
|
+
};
|
|
452
|
+
const renderProviderField = (row, fieldWidth) => {
|
|
453
|
+
const index = rows.indexOf(row);
|
|
454
|
+
const activeEditing = editing?.field === row.field ? editing : undefined;
|
|
455
|
+
const credential = PROVIDER_CREDENTIAL_KEYS.includes(row.field);
|
|
456
|
+
const editable = row.input === true;
|
|
457
|
+
return (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), height: quickstartFieldRowHeight, flexShrink: 0, flexDirection: "column", backgroundColor: credential && editable ? undefined : rowBackground(index), children: [_jsx(Text, { bold: true, ...(index === selection ? { color: accent } : {}), wrap: "truncate-end", children: row.label }), editable ? (_jsxs(_Fragment, { children: [_jsx(Box, { width: fieldWidth, height: 3, paddingX: 1, alignItems: "center", backgroundColor: rowBackground(index) ?? COMMAND_DECK_BACKGROUND, children: _jsx(EditableText, { value: activeEditing?.value ?? '', cursor: activeEditing?.cursor ?? graphemes(activeEditing?.value ?? '').length, width: Math.max(1, fieldWidth - 4), active: Boolean(activeEditing), animate: appearance.animations, 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, animate: appearance.animations })) : (_jsx(Text, { dimColor: true, children: row.description || ' ' }))] }, row.id));
|
|
458
|
+
};
|
|
459
|
+
const renderProviderSelect = (state) => {
|
|
460
|
+
const capacity = Math.max(1, quickstartBodyHeight - middleDetailHeight - 3);
|
|
461
|
+
const start = Math.max(0, Math.min(state.selection - capacity + 1, state.options.length - capacity));
|
|
462
|
+
return (_jsxs(Box, { backgroundColor: PANEL_BACKGROUND, paddingX: 1, flexDirection: "column", overflow: "hidden", children: [_jsx(Text, { bold: true, wrap: "truncate-end", children: providerFieldRows.find((row) => row.field === state.field)?.label ?? 'Choose' }), state.options.slice(start, start + capacity).map((option, index) => {
|
|
463
|
+
const optionIndex = start + index;
|
|
464
|
+
return (_jsx(Box, { ref: (element) => registerElement(selectOptionElements.current, optionIndex, element), flexShrink: 0, backgroundColor: controlBackground(`option:${optionIndex}`, optionIndex === state.selection), children: _jsxs(Text, { ...(optionIndex === state.selection ? { color: accent } : {}), wrap: "truncate-end", children: [optionIndex === state.selection ? '› ' : ' ', option.label] }) }, `${option.label}:${option.value ?? 'custom'}`));
|
|
465
|
+
})] }));
|
|
466
|
+
};
|
|
467
|
+
function setProviderValue(field, value) {
|
|
468
|
+
setProviderEnvironment((current) => {
|
|
469
|
+
const next = { ...current };
|
|
470
|
+
const normalized = value.trim();
|
|
471
|
+
if (normalized) {
|
|
472
|
+
next[field] = normalized;
|
|
473
|
+
}
|
|
474
|
+
else {
|
|
475
|
+
delete next[field];
|
|
476
|
+
}
|
|
477
|
+
return next;
|
|
478
|
+
});
|
|
479
|
+
setError(undefined);
|
|
480
|
+
}
|
|
481
|
+
function chooseSelectOption(option) {
|
|
482
|
+
if (!selecting) {
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
if (option.custom) {
|
|
486
|
+
const current = providerEnvironment[selecting.field] ?? effectiveEnvironment[selecting.field]?.value ?? '';
|
|
487
|
+
setEditing({ field: selecting.field, value: current });
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
setProviderValue(selecting.field, option.value ?? '');
|
|
491
|
+
}
|
|
492
|
+
setSelecting(undefined);
|
|
493
|
+
}
|
|
494
|
+
const selectWizardRow = useCallback((index) => {
|
|
495
|
+
setFocusedAction(undefined);
|
|
496
|
+
setModelSearchFocused(false);
|
|
497
|
+
setSelection(index);
|
|
498
|
+
if (isProviderSetup && index >= quickstartModelOffset) {
|
|
499
|
+
setModelViewportStart((start) => revealPanelSelection(index - quickstartModelOffset, start, quickstartModelCapacity, filteredProviderModels.length));
|
|
500
|
+
}
|
|
501
|
+
if (isProviderSetup && index >= 0 && index < PROVIDER_IDS.length) {
|
|
502
|
+
if (PROVIDER_IDS[index] !== quickstartProvider) {
|
|
503
|
+
setModelQuery('');
|
|
504
|
+
setModelViewportStart(0);
|
|
505
|
+
}
|
|
506
|
+
setQuickstartProvider(PROVIDER_IDS[index]);
|
|
507
|
+
setSelecting(undefined);
|
|
508
|
+
setEditing(undefined);
|
|
509
|
+
}
|
|
510
|
+
}, [isProviderSetup, quickstartModelOffset, quickstartModelCapacity, filteredProviderModels.length, quickstartProvider]);
|
|
511
|
+
const updateModelQuery = (query) => {
|
|
512
|
+
setModelQuery(query);
|
|
513
|
+
setModelSearchFocused(true);
|
|
514
|
+
setFocusedAction(undefined);
|
|
515
|
+
setModelViewportStart(0);
|
|
516
|
+
setSelection(quickstartModelOffset);
|
|
517
|
+
setHoveredControl(undefined);
|
|
518
|
+
};
|
|
519
|
+
function browseForDirectory(field) {
|
|
520
|
+
if (choosingDirectoryRef.current) {
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
choosingDirectoryRef.current = true;
|
|
524
|
+
setChoosingDirectory(true);
|
|
525
|
+
setEditing(undefined);
|
|
526
|
+
setError(undefined);
|
|
527
|
+
const selection = field === 'importPath'
|
|
528
|
+
? chooseAgentProject()
|
|
529
|
+
: chooseDirectory(field === 'memoryDir' ? 'Choose a directory for agent memory' : 'Choose a directory containing agent skills');
|
|
530
|
+
void selection
|
|
531
|
+
.then((path) => {
|
|
532
|
+
if (!path)
|
|
533
|
+
return;
|
|
534
|
+
if (field === 'importPath') {
|
|
535
|
+
setImportPath(path);
|
|
536
|
+
setSelection(0);
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
updateProfile(field === 'skills' ? { skills: [path] } : { memory: memoryForDir(path) });
|
|
540
|
+
}
|
|
541
|
+
})
|
|
542
|
+
.catch((cause) => {
|
|
543
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
544
|
+
})
|
|
545
|
+
.finally(() => {
|
|
546
|
+
choosingDirectoryRef.current = false;
|
|
547
|
+
setChoosingDirectory(false);
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
function chooseFlow(nextFlow) {
|
|
551
|
+
panelTransition.transition(() => {
|
|
552
|
+
setHoveredControl(undefined);
|
|
553
|
+
setFocusedAction(undefined);
|
|
554
|
+
setModelQuery('');
|
|
555
|
+
setModelSearchFocused(false);
|
|
556
|
+
setFlow(nextFlow);
|
|
557
|
+
setStep(1);
|
|
558
|
+
setError(undefined);
|
|
559
|
+
if (nextFlow !== 'import') {
|
|
560
|
+
if (nextFlow === 'agent')
|
|
561
|
+
setSetupTarget(draft);
|
|
562
|
+
const provider = providerFromModel(draft.profile.model) ?? 'bedrock';
|
|
563
|
+
setQuickstartProvider(provider);
|
|
564
|
+
setSelection(PROVIDER_IDS.indexOf(provider));
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
setSelection(0);
|
|
568
|
+
setImportPath('');
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
function continueFlow() {
|
|
573
|
+
if (editing || selecting || saving) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
if (step === 0) {
|
|
577
|
+
chooseFlow(OPENING_CHOICES[selection].id);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
if (isAppearance) {
|
|
581
|
+
let saved;
|
|
582
|
+
setSaving(true);
|
|
583
|
+
if (appearanceOnly || (flow === 'import' && importedEntrypoint)) {
|
|
584
|
+
if (deferred) {
|
|
585
|
+
onComplete({
|
|
586
|
+
configuration: {
|
|
587
|
+
...configurationFromStore(config),
|
|
588
|
+
settings: { ...panelSettings, ...draft.settings, ...appearance },
|
|
589
|
+
},
|
|
590
|
+
...(!appearanceOnly ? { agentProject: importedEntrypoint } : {}),
|
|
591
|
+
});
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
saved = appearanceOnly
|
|
595
|
+
? config.setSettings({ ...panelSettings, ...appearance })
|
|
596
|
+
: config.useAgentProject(importedEntrypoint, { ...panelSettings, ...draft.settings, ...appearance });
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
setError(undefined);
|
|
600
|
+
const configuration = {
|
|
601
|
+
providers: draft.providers,
|
|
602
|
+
profile: compatibleProfile(draft.profile),
|
|
603
|
+
...(profileBaseDir !== undefined ? { profileBaseDir } : {}),
|
|
604
|
+
permissionMode: draft.permissionMode,
|
|
605
|
+
allowedTools: draft.customPermissions || draft.permissionMode === 'bypassPermissions' ? draft.allowedTools : [],
|
|
606
|
+
providerEnvironment,
|
|
607
|
+
settings: { ...panelSettings, ...draft.settings, ...appearance },
|
|
608
|
+
};
|
|
609
|
+
if (deferred) {
|
|
610
|
+
onComplete({ configuration });
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
saved = config.saveSetup(configuration);
|
|
614
|
+
}
|
|
615
|
+
void saved
|
|
616
|
+
.then(() => onComplete())
|
|
617
|
+
.catch((cause) => {
|
|
618
|
+
setSaving(false);
|
|
619
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
620
|
+
});
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
if (flow === 'import') {
|
|
624
|
+
try {
|
|
625
|
+
const imported = importAgentProject(importPath);
|
|
626
|
+
panelTransition.transition(() => {
|
|
627
|
+
setImportedEntrypoint(imported.entrypoint);
|
|
628
|
+
setSettingsCategory(DEFAULT_SETTINGS_CATEGORY);
|
|
629
|
+
setStep(APPEARANCE_STEP);
|
|
630
|
+
setSelection(0);
|
|
631
|
+
setFocusedAction(undefined);
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
catch (cause) {
|
|
635
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
636
|
+
}
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
if (!canContinue) {
|
|
640
|
+
setError('Select a provider with detected credentials; follow the provider setup instructions.');
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
if (flow === 'agent') {
|
|
644
|
+
if (!onAgentSetup || !setupTarget) {
|
|
645
|
+
setError('Agent Q&A is not available in this setup session.');
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
agentHandoffDelivered.current = false;
|
|
649
|
+
setAgentHandoffElapsedMs(0);
|
|
650
|
+
setAgentHandoff({
|
|
651
|
+
model: draft.profile.model,
|
|
652
|
+
effort: draft.profile.effort,
|
|
653
|
+
configuration: {
|
|
654
|
+
profile: setupTarget.profile,
|
|
655
|
+
permissionMode: setupTarget.permissionMode,
|
|
656
|
+
allowedTools: setupTarget.customPermissions || setupTarget.permissionMode === 'bypassPermissions'
|
|
657
|
+
? setupTarget.allowedTools
|
|
658
|
+
: [],
|
|
659
|
+
providers: [...new Set([...setupTarget.providers, ...readyProviders])],
|
|
660
|
+
providerEnvironment,
|
|
661
|
+
settings: setupTarget.settings,
|
|
662
|
+
...(profileBaseDir !== undefined ? { profileBaseDir } : {}),
|
|
663
|
+
},
|
|
664
|
+
});
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
if (flow === 'quickstart') {
|
|
668
|
+
const provider = providerFromModel(draft.profile.model);
|
|
669
|
+
if (!provider || !readyProviders.includes(provider)) {
|
|
670
|
+
setError('The selected model provider needs setup.');
|
|
671
|
+
panelTransition.transition(() => setStep(1));
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
setDraft({
|
|
675
|
+
...draft,
|
|
676
|
+
providers: [provider, ...draft.providers.filter((candidate) => candidate !== provider)],
|
|
677
|
+
});
|
|
678
|
+
panelTransition.transition(() => {
|
|
679
|
+
if (step >= 3) {
|
|
680
|
+
setSettingsCategory(DEFAULT_SETTINGS_CATEGORY);
|
|
681
|
+
}
|
|
682
|
+
setStep(step < 3 ? step + 1 : APPEARANCE_STEP);
|
|
683
|
+
setSelection(0);
|
|
684
|
+
setFocusedAction(undefined);
|
|
685
|
+
if (step === 1) {
|
|
686
|
+
setModelSearchFocused(false);
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
if (step < MANUAL_STEPS.length) {
|
|
692
|
+
panelTransition.transition(() => {
|
|
693
|
+
setStep((current) => current + 1);
|
|
694
|
+
setFocusedAction(undefined);
|
|
695
|
+
setSelection(0);
|
|
696
|
+
setError(undefined);
|
|
697
|
+
setModelSearchFocused(false);
|
|
698
|
+
});
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
const selectedProvider = providerFromModel(draft.profile.model);
|
|
702
|
+
if (selectedProvider && !readyProviders.includes(selectedProvider)) {
|
|
703
|
+
setError('The selected model provider needs setup.');
|
|
704
|
+
panelTransition.transition(() => {
|
|
705
|
+
setStep(1);
|
|
706
|
+
setSelection(PROVIDER_IDS.indexOf(selectedProvider));
|
|
707
|
+
});
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
panelTransition.transition(() => {
|
|
711
|
+
setSettingsCategory(DEFAULT_SETTINGS_CATEGORY);
|
|
712
|
+
setStep(APPEARANCE_STEP);
|
|
713
|
+
setSelection(0);
|
|
714
|
+
setFocusedAction(undefined);
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
function moveBack() {
|
|
718
|
+
if (editing || selecting || saving) {
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
setFocusedAction(undefined);
|
|
722
|
+
if (isAppearance) {
|
|
723
|
+
if (isSettings) {
|
|
724
|
+
const destination = settingsReturn;
|
|
725
|
+
panelTransition.transition(() => {
|
|
726
|
+
setFlow(destination.flow);
|
|
727
|
+
setStep(destination.step);
|
|
728
|
+
setSelection(destination.selection);
|
|
729
|
+
setSettingsReturn(undefined);
|
|
730
|
+
setError(undefined);
|
|
731
|
+
});
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
if (appearanceOnly) {
|
|
735
|
+
onCancel?.(0);
|
|
736
|
+
}
|
|
737
|
+
else {
|
|
738
|
+
panelTransition.transition(() => {
|
|
739
|
+
setStep(flow === 'manual' ? MANUAL_STEPS.length : flow === 'quickstart' ? 3 : 1);
|
|
740
|
+
setSelection(0);
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
if (step <= 1) {
|
|
746
|
+
if (step === 0) {
|
|
747
|
+
onCancel?.(0);
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
panelTransition.transition(() => {
|
|
751
|
+
if (flow === 'agent' && setupTarget)
|
|
752
|
+
setDraft(setupTarget);
|
|
753
|
+
setFlow(undefined);
|
|
754
|
+
setStep(0);
|
|
755
|
+
setSelection(0);
|
|
756
|
+
setOpeningSelectionVisible(false);
|
|
757
|
+
setError(undefined);
|
|
758
|
+
});
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
panelTransition.transition(() => {
|
|
762
|
+
setStep((current) => current - 1);
|
|
763
|
+
setSelection(step === 2 ? PROVIDER_IDS.indexOf(quickstartProvider) : 0);
|
|
764
|
+
setError(undefined);
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
function openSettings() {
|
|
768
|
+
if (isAppearance) {
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
panelTransition.transition(() => {
|
|
772
|
+
setSettingsReturn({ flow, step, selection });
|
|
773
|
+
setSettingsCategory(DEFAULT_SETTINGS_CATEGORY);
|
|
774
|
+
setStep(APPEARANCE_STEP);
|
|
775
|
+
setSelection(0);
|
|
776
|
+
setFocusedAction(undefined);
|
|
777
|
+
setError(undefined);
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
function commitEdit() {
|
|
781
|
+
if (!editing) {
|
|
782
|
+
return true;
|
|
783
|
+
}
|
|
784
|
+
const value = editing.value.trim();
|
|
785
|
+
if (isProviderEnvironmentKey(editing.field)) {
|
|
786
|
+
if (PROVIDER_CREDENTIAL_KEYS.includes(editing.field)) {
|
|
787
|
+
if (!value) {
|
|
788
|
+
setError('API key cannot be empty.');
|
|
789
|
+
return false;
|
|
790
|
+
}
|
|
791
|
+
try {
|
|
792
|
+
config.setSessionProviderCredential(editing.field, value);
|
|
793
|
+
recheck();
|
|
794
|
+
}
|
|
795
|
+
catch (cause) {
|
|
796
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
797
|
+
return false;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
else {
|
|
801
|
+
setProviderValue(editing.field, value);
|
|
802
|
+
}
|
|
803
|
+
setEditing(undefined);
|
|
804
|
+
setError(undefined);
|
|
805
|
+
return true;
|
|
806
|
+
}
|
|
807
|
+
if (!value && editing.field !== 'instructions') {
|
|
808
|
+
setError('This field cannot be empty.');
|
|
809
|
+
return false;
|
|
810
|
+
}
|
|
811
|
+
if (editing.field === 'importPath') {
|
|
812
|
+
setImportPath(value);
|
|
813
|
+
}
|
|
814
|
+
else if (editing.field === 'skills') {
|
|
815
|
+
const paths = value
|
|
816
|
+
.split(',')
|
|
817
|
+
.map((path) => path.trim())
|
|
818
|
+
.filter(Boolean);
|
|
819
|
+
// No directories keeps the library default (`true`) rather than turning skills off.
|
|
820
|
+
updateProfile({ skills: paths.length === 0 ? true : paths });
|
|
821
|
+
}
|
|
822
|
+
else {
|
|
823
|
+
updateProfile({ [editing.field]: value });
|
|
824
|
+
}
|
|
825
|
+
setEditing(undefined);
|
|
826
|
+
setError(undefined);
|
|
827
|
+
return true;
|
|
828
|
+
}
|
|
829
|
+
function leaveEdit() {
|
|
830
|
+
setEditing(undefined);
|
|
831
|
+
setError(undefined);
|
|
832
|
+
}
|
|
833
|
+
function applyPathCompletion(index = pathCompletionIndex < 0 ? 0 : pathCompletionIndex) {
|
|
834
|
+
const completion = pathCompletions[index];
|
|
835
|
+
if (!completion || !pathEditing) {
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
setEditing({
|
|
839
|
+
...pathEditing,
|
|
840
|
+
value: completion.value,
|
|
841
|
+
cursor: graphemes(completion.value).length,
|
|
842
|
+
});
|
|
843
|
+
setError(undefined);
|
|
844
|
+
}
|
|
845
|
+
function activateRow(index) {
|
|
846
|
+
if (step === 0) {
|
|
847
|
+
chooseFlow(OPENING_CHOICES[index].id);
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
if (isImport && index === 1) {
|
|
851
|
+
browseForDirectory('importPath');
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
if (isProviderSetup && index >= quickstartModelOffset) {
|
|
855
|
+
const model = filteredProviderModels[index - quickstartModelOffset];
|
|
856
|
+
if (!model) {
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
const profile = quickstartDraft(quickstartProvider, effectiveEnvironment).profile;
|
|
860
|
+
const modelSpecifier = `${quickstartProvider}/${model.id}`;
|
|
861
|
+
setDraft((current) => ({
|
|
862
|
+
...current,
|
|
863
|
+
providers: [quickstartProvider, ...current.providers.filter((provider) => provider !== quickstartProvider)],
|
|
864
|
+
profile: compatibleProfile({
|
|
865
|
+
...current.profile,
|
|
866
|
+
effort: profile.effort,
|
|
867
|
+
caching: profile.caching,
|
|
868
|
+
model: modelSpecifier,
|
|
869
|
+
}),
|
|
870
|
+
}));
|
|
871
|
+
setError(undefined);
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
if (isProviderSetup && index < PROVIDER_IDS.length && !readyProviders.includes(PROVIDER_IDS[index])) {
|
|
875
|
+
const fieldIndex = rows.findIndex((row) => row.field !== undefined && row.input === true);
|
|
876
|
+
const field = rows[fieldIndex];
|
|
877
|
+
if (fieldIndex >= PROVIDER_IDS.length && field) {
|
|
878
|
+
setSelection(fieldIndex);
|
|
879
|
+
field.activate();
|
|
880
|
+
}
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
const row = rows[index];
|
|
884
|
+
if (!row || row.disabled) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
if (editing && editing.field === row.field) {
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
if (flow === 'manual' && step === MANUAL_STEPS.length) {
|
|
891
|
+
const destination = [1, 2, 1, 3, 4, 5, 6][index];
|
|
892
|
+
panelTransition.transition(() => {
|
|
893
|
+
setStep(destination);
|
|
894
|
+
setSelection(destination === 1 ? PROVIDER_IDS.indexOf(quickstartProvider) : 0);
|
|
895
|
+
setFocusedAction(undefined);
|
|
896
|
+
});
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
if (row.choices?.length) {
|
|
900
|
+
const selected = row.choices.findIndex((choice) => choice.active);
|
|
901
|
+
row.choices[(selected + 1) % row.choices.length].activate();
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
if (row.selectOptions && row.field && isProviderEnvironmentKey(row.field)) {
|
|
905
|
+
const current = providerEnvironment[row.field] ?? effectiveEnvironment[row.field]?.value;
|
|
906
|
+
const selected = Math.max(0, row.selectOptions.findIndex((option) => !option.custom && option.value === current));
|
|
907
|
+
setSelecting({ field: row.field, options: row.selectOptions, selection: selected });
|
|
908
|
+
setEditing(undefined);
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
row.activate();
|
|
912
|
+
}
|
|
913
|
+
useEffect(() => {
|
|
914
|
+
setTerminalMouseMotion(true, stdout);
|
|
915
|
+
return () => setTerminalMouseMotion(false, stdout);
|
|
916
|
+
}, [stdout]);
|
|
917
|
+
useEffect(() => {
|
|
918
|
+
setHoveredControl(undefined);
|
|
919
|
+
pressedElement.current = undefined;
|
|
920
|
+
}, [step, flow, quickstartProvider, selecting?.field, modelViewportStart, width, height]);
|
|
921
|
+
useEffect(() => {
|
|
922
|
+
if (isProviderSetup && !modelPanelVisible && (modelSearchFocused || selection >= quickstartModelOffset)) {
|
|
923
|
+
selectWizardRow(PROVIDER_IDS.indexOf(quickstartProvider));
|
|
924
|
+
}
|
|
925
|
+
}, [
|
|
926
|
+
isProviderSetup,
|
|
927
|
+
modelPanelVisible,
|
|
928
|
+
modelSearchFocused,
|
|
929
|
+
selection,
|
|
930
|
+
quickstartModelOffset,
|
|
931
|
+
quickstartProvider,
|
|
932
|
+
selectWizardRow,
|
|
933
|
+
]);
|
|
934
|
+
useProviderDiscoveryEffects(discovery, isProviderSetup, quickstartProvider, setModelViewportStart);
|
|
935
|
+
useEffect(() => {
|
|
936
|
+
if (!isProviderSetup || awsDiscovery.credentialStatus === undefined || !ollamaDiscovery) {
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
setDraft((current) => {
|
|
940
|
+
const providers = [
|
|
941
|
+
...current.providers.filter((provider) => !config.needsSetup() || readyProviders.includes(provider)),
|
|
942
|
+
...readyProviders.filter((provider) => !current.providers.includes(provider)),
|
|
943
|
+
];
|
|
944
|
+
const sameProviders = providers.length === current.providers.length &&
|
|
945
|
+
providers.every((provider, index) => provider === current.providers[index]);
|
|
946
|
+
const modelProvider = providerFromModel(current.profile.model);
|
|
947
|
+
const defaultProvider = providers[0];
|
|
948
|
+
let profile = current.profile;
|
|
949
|
+
if (config.needsSetup() && defaultProvider && (!modelProvider || !providers.includes(modelProvider))) {
|
|
950
|
+
const defaults = quickstartDraft(defaultProvider, effectiveEnvironment).profile;
|
|
951
|
+
profile = compatibleProfile({
|
|
952
|
+
...profile,
|
|
953
|
+
model: defaults.model,
|
|
954
|
+
effort: defaults.effort,
|
|
955
|
+
caching: defaults.caching,
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
if (sameProviders && profile === current.profile) {
|
|
959
|
+
return current;
|
|
960
|
+
}
|
|
961
|
+
return { ...current, providers, profile };
|
|
962
|
+
});
|
|
963
|
+
}, [awsDiscovery.credentialStatus, config, effectiveEnvironment, isProviderSetup, ollamaDiscovery, readyProviders]);
|
|
964
|
+
const frogElapsedMs = useBrandAnimation(frogAnimationId);
|
|
965
|
+
useInput((input, key) => {
|
|
966
|
+
if (agentHandoff || appearanceOpen || panelTransition.transitioning)
|
|
967
|
+
return;
|
|
968
|
+
const mouse = parseMouseInput(input);
|
|
969
|
+
if (mouse) {
|
|
970
|
+
const scroll = mouseScrollDirection(mouse);
|
|
971
|
+
if (scroll !== undefined) {
|
|
972
|
+
setHoveredControl(undefined);
|
|
973
|
+
if (isProviderSetup && modelListElement.current && elementContainsMouse(modelListElement.current, mouse)) {
|
|
974
|
+
setModelViewportStart((start) => scrollPanelViewport(start, scroll, filteredProviderModels.length, quickstartModelCapacity));
|
|
975
|
+
}
|
|
976
|
+
else if (isCapabilities || isAppearance || flow === 'manual') {
|
|
977
|
+
setFocusedAction(undefined);
|
|
978
|
+
setSelection((current) => scrollPanelViewport(current, scroll, rows.length, 1));
|
|
979
|
+
}
|
|
980
|
+
return;
|
|
981
|
+
}
|
|
982
|
+
const selectOption = elementAtMouse(selectOptionElements.current, mouse);
|
|
983
|
+
const choice = elementAtMouse(choiceElements.current, mouse);
|
|
984
|
+
const pathCompletion = elementAtMouse(pathCompletionElements.current, mouse);
|
|
985
|
+
const directory = elementAtMouse(directoryElements.current, mouse);
|
|
986
|
+
const row = elementAtMouse(rowElements.current, mouse);
|
|
987
|
+
const back = backElement.current ? elementContainsMouse(backElement.current, mouse) : false;
|
|
988
|
+
const next = nextElement.current ? elementContainsMouse(nextElement.current, mouse) : false;
|
|
989
|
+
const settings = settingsElement.current ? elementContainsMouse(settingsElement.current, mouse) : false;
|
|
990
|
+
const frog = frogElement.current ? elementContainsMouse(frogElement.current, mouse) : false;
|
|
991
|
+
const search = modelSearchElement.current ? elementContainsMouse(modelSearchElement.current, mouse) : false;
|
|
992
|
+
const effortSliderHit = setupEffortSliderElement.current
|
|
993
|
+
? elementContainsMouse(setupEffortSliderElement.current, mouse)
|
|
994
|
+
: false;
|
|
995
|
+
const target = (pathCompletion !== undefined ? `completion:${pathCompletion}` : undefined) ??
|
|
996
|
+
(directory !== undefined ? `browse:${directory}` : undefined) ??
|
|
997
|
+
choice ??
|
|
998
|
+
(selectOption !== undefined
|
|
999
|
+
? `option:${selectOption}`
|
|
1000
|
+
: row !== undefined && !rows[row]?.disabled && !(isImport && row === 1 && choosingDirectory)
|
|
1001
|
+
? row
|
|
1002
|
+
: back
|
|
1003
|
+
? 'back'
|
|
1004
|
+
: next && canContinue
|
|
1005
|
+
? 'next'
|
|
1006
|
+
: settings
|
|
1007
|
+
? 'settings'
|
|
1008
|
+
: search
|
|
1009
|
+
? 'search'
|
|
1010
|
+
: undefined);
|
|
1011
|
+
if (saving || choosingDirectory) {
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
if (mouse.action === 'press' && (mouse.button & 3) === 0) {
|
|
1015
|
+
if (editing &&
|
|
1016
|
+
!(typeof target === 'string' && target.startsWith('completion:')) &&
|
|
1017
|
+
(target === undefined || typeof target !== 'number' || rows[target]?.field !== editing.field)) {
|
|
1018
|
+
leaveEdit();
|
|
1019
|
+
}
|
|
1020
|
+
if (selecting && selectOption === undefined) {
|
|
1021
|
+
setSelecting(undefined);
|
|
1022
|
+
}
|
|
1023
|
+
if (effortSliderHit && reasoningSlider && reasoningRow?.choices) {
|
|
1024
|
+
pressedElement.current = undefined;
|
|
1025
|
+
const option = sliderOptionAtMouse(reasoningSlider, setupEffortSliderElement.current, mouse);
|
|
1026
|
+
const choice = option ? reasoningRow.choices[Number(option.id)] : undefined;
|
|
1027
|
+
if (choice) {
|
|
1028
|
+
choice.activate();
|
|
1029
|
+
setSelection(reasoningRowIndex);
|
|
1030
|
+
setFocusedAction(undefined);
|
|
1031
|
+
}
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
frogPress.current = frog ? { column: mouse.column, row: mouse.row } : undefined;
|
|
1035
|
+
pressedElement.current = target;
|
|
1036
|
+
if (selectOption !== undefined && selecting) {
|
|
1037
|
+
setSelecting({ ...selecting, selection: selectOption });
|
|
1038
|
+
}
|
|
1039
|
+
else if (pathCompletion !== undefined) {
|
|
1040
|
+
setPathCompletionIndex(pathCompletion);
|
|
1041
|
+
}
|
|
1042
|
+
else if (typeof target === 'number') {
|
|
1043
|
+
selectWizardRow(target);
|
|
1044
|
+
}
|
|
1045
|
+
else if (typeof target === 'string' && target.startsWith('browse:')) {
|
|
1046
|
+
selectWizardRow(directory);
|
|
1047
|
+
setFocusedAction(`browse:${directory}`);
|
|
1048
|
+
}
|
|
1049
|
+
else if (target === 'back' || target === 'next' || target === 'settings') {
|
|
1050
|
+
setFocusedAction(target);
|
|
1051
|
+
setModelSearchFocused(false);
|
|
1052
|
+
}
|
|
1053
|
+
else if (target === 'search') {
|
|
1054
|
+
setModelSearchFocused(true);
|
|
1055
|
+
setFocusedAction(undefined);
|
|
1056
|
+
setEditing(undefined);
|
|
1057
|
+
}
|
|
1058
|
+
else if (choice?.startsWith('choice:')) {
|
|
1059
|
+
selectWizardRow(Number(choice.split(':')[1]));
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
else if (mouse.action === 'release') {
|
|
1063
|
+
const frogClicked = frog && frogPress.current?.column === mouse.column && frogPress.current?.row === mouse.row;
|
|
1064
|
+
frogPress.current = undefined;
|
|
1065
|
+
const pressed = pressedElement.current;
|
|
1066
|
+
pressedElement.current = undefined;
|
|
1067
|
+
if (frogClicked && appearance.animations) {
|
|
1068
|
+
setFrogAnimationId((current) => (current ?? 0) + 1);
|
|
1069
|
+
}
|
|
1070
|
+
else if (directory !== undefined && pressed === `browse:${directory}` && directoryRows.has(directory)) {
|
|
1071
|
+
browseForDirectory(directoryRows.get(directory));
|
|
1072
|
+
}
|
|
1073
|
+
else if (typeof pressed === 'string' && pressed.startsWith('choice:') && pressed === choice) {
|
|
1074
|
+
const [, rowIndex, choiceIndex] = pressed.split(':');
|
|
1075
|
+
rows[Number(rowIndex)]?.choices?.[Number(choiceIndex)]?.activate();
|
|
1076
|
+
}
|
|
1077
|
+
else if (typeof pressed === 'string' && pressed.startsWith('category:') && pressed === choice) {
|
|
1078
|
+
setSettingsCategory(pressed.slice('category:'.length));
|
|
1079
|
+
setSelection(0);
|
|
1080
|
+
setFocusedAction(undefined);
|
|
1081
|
+
}
|
|
1082
|
+
else if (typeof pressed === 'string' && pressed.startsWith('option:')) {
|
|
1083
|
+
const optionIndex = Number(pressed.slice('option:'.length));
|
|
1084
|
+
const option = selecting?.options[optionIndex];
|
|
1085
|
+
if (selectOption === optionIndex && option) {
|
|
1086
|
+
chooseSelectOption(option);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
else if (typeof pressed === 'string' && pressed.startsWith('completion:')) {
|
|
1090
|
+
const completionIndex = Number(pressed.slice('completion:'.length));
|
|
1091
|
+
if (pathCompletion === completionIndex) {
|
|
1092
|
+
applyPathCompletion(completionIndex);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
else if (typeof pressed === 'number' &&
|
|
1096
|
+
pressed === row &&
|
|
1097
|
+
(!isAppearance || !rows[pressed]?.choices?.length)) {
|
|
1098
|
+
activateRow(pressed);
|
|
1099
|
+
}
|
|
1100
|
+
else if (pressed === 'back' && back) {
|
|
1101
|
+
moveBack();
|
|
1102
|
+
}
|
|
1103
|
+
else if (pressed === 'next' && next) {
|
|
1104
|
+
continueFlow();
|
|
1105
|
+
}
|
|
1106
|
+
else if (pressed === 'settings' && settings) {
|
|
1107
|
+
if (isSettings)
|
|
1108
|
+
moveBack();
|
|
1109
|
+
else
|
|
1110
|
+
openSettings();
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
else if (mouse.action === 'move') {
|
|
1114
|
+
setHoveredControl(isCapabilities && row !== undefined ? row : target);
|
|
1115
|
+
}
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
if (key.ctrl && input === 'c') {
|
|
1119
|
+
onCancel?.(130);
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
if (key.ctrl && input === 's' && !appearanceOnly) {
|
|
1123
|
+
if (isSettings)
|
|
1124
|
+
moveBack();
|
|
1125
|
+
else
|
|
1126
|
+
openSettings();
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
setHoveredControl(undefined);
|
|
1130
|
+
if (saving || choosingDirectory) {
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
if (selecting) {
|
|
1134
|
+
if (key.escape) {
|
|
1135
|
+
setSelecting(undefined);
|
|
1136
|
+
}
|
|
1137
|
+
else if (key.tab && selecting.options.length > 0) {
|
|
1138
|
+
setSelecting({
|
|
1139
|
+
...selecting,
|
|
1140
|
+
selection: (selecting.selection + (key.shift ? -1 : 1) + selecting.options.length) % selecting.options.length,
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
else if (key.upArrow || key.leftArrow) {
|
|
1144
|
+
setSelecting({
|
|
1145
|
+
...selecting,
|
|
1146
|
+
selection: Math.max(0, selecting.selection - 1),
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
else if (key.downArrow || key.rightArrow) {
|
|
1150
|
+
setSelecting({
|
|
1151
|
+
...selecting,
|
|
1152
|
+
selection: Math.min(selecting.options.length - 1, selecting.selection + 1),
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1155
|
+
else if (key.return) {
|
|
1156
|
+
const option = selecting.options[selecting.selection];
|
|
1157
|
+
if (option) {
|
|
1158
|
+
chooseSelectOption(option);
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
if (editing) {
|
|
1164
|
+
if (key.escape) {
|
|
1165
|
+
setEditing(undefined);
|
|
1166
|
+
setError(undefined);
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
if (editing.field === 'importPath' && importCompletionCapacity > 0) {
|
|
1170
|
+
if (key.upArrow) {
|
|
1171
|
+
setPathCompletionIndex((current) => current < 0
|
|
1172
|
+
? importCompletionCapacity - 1
|
|
1173
|
+
: (current - 1 + importCompletionCapacity) % importCompletionCapacity);
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
if (key.downArrow) {
|
|
1177
|
+
setPathCompletionIndex((current) => (current + 1) % importCompletionCapacity);
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
if (key.tab || (key.return && pathCompletionIndex >= 0)) {
|
|
1181
|
+
applyPathCompletion();
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
if (key.tab) {
|
|
1186
|
+
leaveEdit();
|
|
1187
|
+
}
|
|
1188
|
+
else if (key.return && !(editing.field === 'instructions' && (key.meta || key.shift))) {
|
|
1189
|
+
commitEdit();
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
else {
|
|
1193
|
+
const multiline = editing.field === 'instructions';
|
|
1194
|
+
const result = reduceInputSequence({ ...emptyEditor(), input: editing.value, cursor: editing.cursor ?? graphemes(editing.value).length }, multiline ? input : input.replace(/[\r\n]/g, ''), multiline && key.return && key.meta ? { ...key, shift: true } : key, 'idle');
|
|
1195
|
+
setEditing({ ...editing, value: result.state.input, cursor: result.state.cursor });
|
|
1196
|
+
setError(undefined);
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
if (modelPanelVisible) {
|
|
1201
|
+
if (key.escape && (modelQuery || modelSearchFocused)) {
|
|
1202
|
+
if (modelQuery) {
|
|
1203
|
+
updateModelQuery('');
|
|
1204
|
+
}
|
|
1205
|
+
else {
|
|
1206
|
+
selectWizardRow(PROVIDER_IDS.indexOf(quickstartProvider));
|
|
1207
|
+
}
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
if (modelSearchFocused && (key.downArrow || key.return)) {
|
|
1211
|
+
if (filteredProviderModels.length > 0) {
|
|
1212
|
+
selectWizardRow(quickstartModelOffset);
|
|
1213
|
+
}
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1216
|
+
if (modelSearchFocused && (key.leftArrow || key.rightArrow || key.upArrow)) {
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
if (!focusedAction && key.upArrow && selection === quickstartModelOffset) {
|
|
1220
|
+
setModelSearchFocused(true);
|
|
1221
|
+
return;
|
|
1222
|
+
}
|
|
1223
|
+
if (key.backspace || key.delete) {
|
|
1224
|
+
updateModelQuery([...modelQuery].slice(0, -1).join(''));
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
if (key.ctrl && input === 'u') {
|
|
1228
|
+
updateModelQuery('');
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
if (!key.ctrl &&
|
|
1232
|
+
!key.meta &&
|
|
1233
|
+
input &&
|
|
1234
|
+
!input.startsWith('\u001b') &&
|
|
1235
|
+
[...input].every((character) => (character.codePointAt(0) ?? 0) >= 0x20) &&
|
|
1236
|
+
(input !== ' ' || modelSearchFocused)) {
|
|
1237
|
+
updateModelQuery(input === '/' && !modelSearchFocused
|
|
1238
|
+
? modelQuery
|
|
1239
|
+
: modelQuery + sanitizeTerminalText(input).replaceAll('\n', ''));
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
const rowCount = isProviderSetup ? quickstartSelectableRows : rows.length;
|
|
1244
|
+
const focusableRows = Array.from({ length: rowCount }, (_, index) => index).filter((index) => !rows[index]?.disabled && index !== hiddenReasoningRowIndex);
|
|
1245
|
+
const moveRow = (direction, start = 0, end = rowCount - 1) => {
|
|
1246
|
+
const candidates = focusableRows.filter((index) => index >= start && index <= end);
|
|
1247
|
+
const target = direction === 1
|
|
1248
|
+
? candidates.find((index) => index > selection)
|
|
1249
|
+
: candidates.reverse().find((index) => index < selection);
|
|
1250
|
+
if (target !== undefined) {
|
|
1251
|
+
selectWizardRow(target);
|
|
1252
|
+
}
|
|
1253
|
+
};
|
|
1254
|
+
if (key.escape) {
|
|
1255
|
+
moveBack();
|
|
1256
|
+
}
|
|
1257
|
+
else if (key.tab) {
|
|
1258
|
+
if (isSettings) {
|
|
1259
|
+
const categoryIndex = SETTINGS_CATEGORIES.findIndex(({ id }) => id === settingsCategory);
|
|
1260
|
+
const nextCategory = SETTINGS_CATEGORIES[(categoryIndex + (key.shift ? -1 : 1) + SETTINGS_CATEGORIES.length) % SETTINGS_CATEGORIES.length];
|
|
1261
|
+
setSettingsCategory(nextCategory.id);
|
|
1262
|
+
setSelection(0);
|
|
1263
|
+
setFocusedAction(undefined);
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
if (step === 0) {
|
|
1267
|
+
if (focusedAction === 'settings') {
|
|
1268
|
+
setOpeningSelectionVisible(true);
|
|
1269
|
+
}
|
|
1270
|
+
setFocusedAction(focusedAction === 'settings' ? undefined : 'settings');
|
|
1271
|
+
setModelSearchFocused(false);
|
|
1272
|
+
return;
|
|
1273
|
+
}
|
|
1274
|
+
const controls = [
|
|
1275
|
+
...focusableRows
|
|
1276
|
+
.filter((index) => !modelPanelVisible || index < quickstartModelOffset)
|
|
1277
|
+
.flatMap((index) => (directoryRows.has(index) ? [index, `browse:${index}`] : [index])),
|
|
1278
|
+
...(modelPanelVisible
|
|
1279
|
+
? ['search', ...focusableRows.filter((index) => index >= quickstartModelOffset)]
|
|
1280
|
+
: []),
|
|
1281
|
+
...(step > 0 && hasExternalActions ? ['back', ...(canContinue ? ['next'] : [])] : []),
|
|
1282
|
+
];
|
|
1283
|
+
const index = controls.indexOf(modelSearchFocused ? 'search' : (focusedAction ?? selection));
|
|
1284
|
+
const target = controls[(index + (key.shift ? -1 : 1) + controls.length) % controls.length];
|
|
1285
|
+
if (typeof target === 'number') {
|
|
1286
|
+
selectWizardRow(target);
|
|
1287
|
+
if (rows[target]?.field && rows[target]?.input !== false && !rows[target]?.selectOptions) {
|
|
1288
|
+
rows[target].activate();
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
else if (target === 'search') {
|
|
1292
|
+
setModelSearchFocused(true);
|
|
1293
|
+
setFocusedAction(undefined);
|
|
1294
|
+
}
|
|
1295
|
+
else {
|
|
1296
|
+
setFocusedAction(target);
|
|
1297
|
+
setModelSearchFocused(false);
|
|
1298
|
+
if (target?.startsWith('browse:')) {
|
|
1299
|
+
setSelection(Number(target.slice('browse:'.length)));
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
else if (focusedAction) {
|
|
1304
|
+
if (focusedAction === 'settings') {
|
|
1305
|
+
if (key.return || input === ' ') {
|
|
1306
|
+
if (isSettings)
|
|
1307
|
+
moveBack();
|
|
1308
|
+
else
|
|
1309
|
+
openSettings();
|
|
1310
|
+
}
|
|
1311
|
+
else if (key.upArrow && step !== 0) {
|
|
1312
|
+
setFocusedAction(undefined);
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
else if (focusedAction.startsWith('browse:')) {
|
|
1316
|
+
const index = Number(focusedAction.slice('browse:'.length));
|
|
1317
|
+
if (key.return || input === ' ') {
|
|
1318
|
+
browseForDirectory(directoryRows.get(index));
|
|
1319
|
+
}
|
|
1320
|
+
else if (key.leftArrow || key.upArrow) {
|
|
1321
|
+
selectWizardRow(index);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
else if (key.leftArrow) {
|
|
1325
|
+
setFocusedAction('back');
|
|
1326
|
+
}
|
|
1327
|
+
else if (key.rightArrow) {
|
|
1328
|
+
if (canContinue)
|
|
1329
|
+
setFocusedAction('next');
|
|
1330
|
+
}
|
|
1331
|
+
else if (key.upArrow) {
|
|
1332
|
+
setFocusedAction(undefined);
|
|
1333
|
+
}
|
|
1334
|
+
else if (key.return || input === ' ') {
|
|
1335
|
+
if (focusedAction === 'back')
|
|
1336
|
+
moveBack();
|
|
1337
|
+
else
|
|
1338
|
+
continueFlow();
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
else if ((key.leftArrow || key.rightArrow) && rows[selection]?.choices?.length) {
|
|
1342
|
+
const choices = rows[selection].choices;
|
|
1343
|
+
const selected = choices.findIndex((choice) => choice.active);
|
|
1344
|
+
const next = selected < 0
|
|
1345
|
+
? key.leftArrow
|
|
1346
|
+
? 0
|
|
1347
|
+
: choices.length - 1
|
|
1348
|
+
: (selected + (key.leftArrow ? -1 : 1) + choices.length) % choices.length;
|
|
1349
|
+
choices[next].activate();
|
|
1350
|
+
}
|
|
1351
|
+
else if (splitQuickstart && (key.upArrow || key.leftArrow)) {
|
|
1352
|
+
const columnStart = selection < PROVIDER_IDS.length
|
|
1353
|
+
? 0
|
|
1354
|
+
: selection < quickstartModelOffset
|
|
1355
|
+
? PROVIDER_IDS.length
|
|
1356
|
+
: quickstartModelOffset;
|
|
1357
|
+
moveRow(-1, columnStart);
|
|
1358
|
+
}
|
|
1359
|
+
else if (splitQuickstart && (key.downArrow || key.rightArrow)) {
|
|
1360
|
+
const columnEnd = selection < PROVIDER_IDS.length
|
|
1361
|
+
? PROVIDER_IDS.length - 1
|
|
1362
|
+
: selection < quickstartModelOffset
|
|
1363
|
+
? quickstartModelOffset - 1
|
|
1364
|
+
: quickstartSelectableRows - 1;
|
|
1365
|
+
moveRow(1, 0, columnEnd);
|
|
1366
|
+
}
|
|
1367
|
+
else if (step === 0 &&
|
|
1368
|
+
openingColumns === 2 &&
|
|
1369
|
+
(key.leftArrow || key.rightArrow || key.upArrow || key.downArrow)) {
|
|
1370
|
+
setOpeningSelectionVisible(true);
|
|
1371
|
+
const column = selection % openingColumns;
|
|
1372
|
+
const next = key.leftArrow
|
|
1373
|
+
? column > 0
|
|
1374
|
+
? selection - 1
|
|
1375
|
+
: selection
|
|
1376
|
+
: key.rightArrow
|
|
1377
|
+
? column < openingColumns - 1
|
|
1378
|
+
? selection + 1
|
|
1379
|
+
: selection
|
|
1380
|
+
: key.upArrow
|
|
1381
|
+
? Math.max(0, selection - openingColumns)
|
|
1382
|
+
: Math.min(OPENING_CHOICES.length - 1, selection + openingColumns);
|
|
1383
|
+
selectWizardRow(next);
|
|
1384
|
+
}
|
|
1385
|
+
else if (key.upArrow || key.leftArrow) {
|
|
1386
|
+
if (step === 0)
|
|
1387
|
+
setOpeningSelectionVisible(true);
|
|
1388
|
+
moveRow(-1);
|
|
1389
|
+
}
|
|
1390
|
+
else if (key.downArrow || key.rightArrow) {
|
|
1391
|
+
if (step === 0)
|
|
1392
|
+
setOpeningSelectionVisible(true);
|
|
1393
|
+
moveRow(1);
|
|
1394
|
+
}
|
|
1395
|
+
else if (key.return || input === ' ') {
|
|
1396
|
+
activateRow(selection);
|
|
1397
|
+
}
|
|
1398
|
+
else if (rows[selection]?.field &&
|
|
1399
|
+
rows[selection]?.input !== false &&
|
|
1400
|
+
!rows[selection]?.disabled &&
|
|
1401
|
+
!rows[selection]?.selectOptions &&
|
|
1402
|
+
input &&
|
|
1403
|
+
!key.ctrl &&
|
|
1404
|
+
!key.meta) {
|
|
1405
|
+
rows[selection].activate();
|
|
1406
|
+
setEditing((current) => {
|
|
1407
|
+
if (!current)
|
|
1408
|
+
return current;
|
|
1409
|
+
const result = reduceInputSequence({ ...emptyEditor(), input: current.value, cursor: graphemes(current.value).length }, input, key, 'idle');
|
|
1410
|
+
return { ...current, value: result.state.input, cursor: result.state.cursor };
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1413
|
+
});
|
|
1414
|
+
const primaryLabel = saving
|
|
1415
|
+
? 'Saving...'
|
|
1416
|
+
: isAppearance
|
|
1417
|
+
? deferred || !config.needsSetup()
|
|
1418
|
+
? 'Save and Launch'
|
|
1419
|
+
: 'Launch Strands harness'
|
|
1420
|
+
: flow === 'agent'
|
|
1421
|
+
? 'Start Q&A'
|
|
1422
|
+
: 'Continue';
|
|
1423
|
+
const escapeAction = editing || selecting ? 'cancel' : step === 0 ? 'exit' : 'back';
|
|
1424
|
+
const navigationHints = editing
|
|
1425
|
+
? [
|
|
1426
|
+
width < 32 ? 'Enter save · Tab move' : 'Enter save · Tab/Shift+Tab move',
|
|
1427
|
+
editing.field === 'instructions'
|
|
1428
|
+
? 'Shift+Enter newline · Esc cancel'
|
|
1429
|
+
: width < 60
|
|
1430
|
+
? 'Click focus · Esc cancel'
|
|
1431
|
+
: 'Mouse click: switch controls · Ctrl+U: clear · Esc: cancel',
|
|
1432
|
+
]
|
|
1433
|
+
: [
|
|
1434
|
+
width < 32
|
|
1435
|
+
? 'Click/Enter · ↑↓'
|
|
1436
|
+
: width < 60
|
|
1437
|
+
? 'Click/Enter choose · ↑↓ move'
|
|
1438
|
+
: 'Click or Enter to choose · Arrow keys (↑↓) to move',
|
|
1439
|
+
width < 32
|
|
1440
|
+
? 'Shift+Tab'
|
|
1441
|
+
: width < 60
|
|
1442
|
+
? `Tab/Shift+Tab focus · Esc ${escapeAction}`
|
|
1443
|
+
: step === 0
|
|
1444
|
+
? 'Tab / Shift+Tab: grid ↔ Settings · Esc to exit'
|
|
1445
|
+
: `Tab / Shift+Tab to move focus · Esc to ${escapeAction}`,
|
|
1446
|
+
];
|
|
1447
|
+
const settingsHovered = hoveredControl === 'settings';
|
|
1448
|
+
const settingsBackHovered = isSettings && settingsHovered;
|
|
1449
|
+
const settingsButton = !appearanceOnly ? (_jsx(Box, { ref: (element) => {
|
|
1450
|
+
settingsElement.current = element ?? undefined;
|
|
1451
|
+
}, width: 11, height: 1, paddingX: 1, flexShrink: 0, alignItems: "center", justifyContent: "center", backgroundColor: settingsBackHovered
|
|
1452
|
+
? backHoverBackground
|
|
1453
|
+
: (controlBackground('settings', focusedAction === 'settings') ?? COMMAND_DECK_BACKGROUND), children: _jsx(Text, { color: settingsBackHovered ? palette.muted : focusedAction === 'settings' ? accent : palette.muted, children: isSettings ? 'Back' : 'Settings' }) })) : null;
|
|
1454
|
+
if (agentHandoff) {
|
|
1455
|
+
const canvasHeight = Math.max(12, height - 2);
|
|
1456
|
+
const guideHeight = Math.max(4, height - 4);
|
|
1457
|
+
const { wide, frogWidth, frogHeight, contentWidth } = setupGuideLayout(lockupWidth, guideHeight);
|
|
1458
|
+
const landingX = wide
|
|
1459
|
+
? Math.max(frogWidth / 2, Math.floor((lockupWidth - contentWidth) / 2) + frogWidth / 2)
|
|
1460
|
+
: lockupWidth / 2;
|
|
1461
|
+
const landingY = Math.max(7, guideHeight + frogHeight - 16);
|
|
1462
|
+
return (_jsx(Box, { width: width, height: height, paddingX: 1, paddingTop: 2, overflow: "hidden", backgroundColor: palette.background, children: _jsx(Text, { children: renderSetupGuideTransitionFrame(lockupWidth, canvasHeight, agentHandoffElapsedMs / SETUP_GUIDE_TRANSITION_DURATION_MS, agentHandoffElapsedMs, landingX, true, appearance.frogTheme, {
|
|
1463
|
+
colorMode: palette.mode,
|
|
1464
|
+
customBase: appearance.customTheme.base,
|
|
1465
|
+
...(appearance.frogTheme === 'custom' ? { frogColor: palette.frog } : {}),
|
|
1466
|
+
}, landingY) }) }));
|
|
1467
|
+
}
|
|
1468
|
+
return (_jsxs(Box, { width: width, height: height, paddingX: 1, flexDirection: "column", overflow: "hidden", backgroundColor: palette.background, children: [showBrand ? (_jsx(SetupBrand, { width: lockupWidth, height: lockupHeight, appearance: appearance, animationId: frogAnimationId, elapsedMs: frogElapsedMs, onFrogElement: (element) => {
|
|
1469
|
+
frogElement.current = element ?? undefined;
|
|
1470
|
+
} })) : null, step === 0 ? (_jsx(Fade, { background: palette.background, progress: panelTransition.progress, children: _jsx(OpeningMenu, { width: lockupWidth, buttonHeight: openingButtonHeight, selection: selection, showSelection: openingSelectionVisible, ...(typeof hoveredControl === 'number' ? { hovered: hoveredControl } : {}), topGap: openingTopGap, animate: appearance.animations, ...(error ? { error } : {}), 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, width: Math.min(bubbleWidth, 48), animate: appearance.animations })] })) : null, _jsxs(Box, { width: bubbleWidth, height: bubbleHeight, flexDirection: "column", overflow: "hidden", backgroundColor: PANEL_BACKGROUND, children: [!isAppearance && flow === 'manual' && !isProviderSetup && !isCapabilities ? (_jsx(Box, { paddingX: 1, marginBottom: 1, flexShrink: 0, children: _jsx(Text, { bold: true, color: accent, children: isSettings ? 'Settings' : isAppearance ? 'Appearance' : MANUAL_STEPS[step - 1] }) })) : null, isCapabilities ? (_jsxs(_Fragment, { children: [_jsxs(Box, { paddingX: 1, marginBottom: 1, justifyContent: "space-between", flexShrink: 0, children: [_jsx(Text, { bold: true, color: accent, children: isTools ? 'Tools' : 'Plugins & features' }), _jsx(Box, { ref: (element) => registerElement(rowElements.current, 0, element), paddingX: 1, backgroundColor: rowBackground(0) ?? COMMAND_DECK_BACKGROUND, children: _jsx(Text, { bold: true, children: rows[0].label }) })] }), renderCapabilityRows(visibleCapabilityRows)] })) : isImport ? (_jsxs(Box, { flexGrow: 1, paddingX: 2, 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, flexDirection: "row", children: [_jsx(Box, { ref: (element) => registerElement(rowElements.current, 0, element), flexGrow: 1, paddingX: 1, flexDirection: "column", justifyContent: "center", backgroundColor: rowBackground(0) ?? COMMAND_DECK_BACKGROUND, children: _jsx(EditableText, { value: editing?.field === 'importPath' ? editing.value : importPath, cursor: editing?.field === 'importPath'
|
|
1471
|
+
? (editing.cursor ?? graphemes(editing.value).length)
|
|
1472
|
+
: graphemes(importPath).length, width: Math.max(1, bubbleWidth - (canChooseDirectory() ? 17 : 6)), active: editing?.field === 'importPath', animate: appearance.animations }) }), canChooseDirectory() ? (_jsx(Box, { ref: (element) => registerElement(rowElements.current, 1, element), width: 12, marginLeft: 1, alignItems: "center", justifyContent: "center", backgroundColor: controlBackground(1, focusedAction === undefined && selection === 1, choosingDirectory) ??
|
|
1473
|
+
COMMAND_DECK_BACKGROUND, 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, backgroundColor: pathCompletionIndex === index || hoveredControl === `completion:${index}`
|
|
1474
|
+
? PANEL_SELECTION
|
|
1475
|
+
: undefined, children: _jsxs(Text, { color: pathCompletionIndex === index ? accent : palette.foreground, 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: [_jsxs(Box, { width: quickstartProviderColumnWidth, flexShrink: 0, paddingX: 1, flexDirection: "column", overflow: "hidden", children: [_jsx(Box, { marginBottom: 1, flexShrink: 0, children: _jsx(Text, { bold: true, color: accent, children: "Providers" }) }), _jsx(Box, { height: quickstartProviderListHeight, flexShrink: 0, flexDirection: "column", overflow: "hidden", children: _jsx(ProviderList, { items: providerRows.map((row) => ({
|
|
1476
|
+
id: row.id,
|
|
1477
|
+
label: row.label,
|
|
1478
|
+
description: row.description,
|
|
1479
|
+
...(row.status ? { status: row.status } : {}),
|
|
1480
|
+
})), selected: quickstartProvider, width: quickstartProviderColumnWidth - 2, rowHeight: quickstartProviderRowHeight, selectedBackground: true, ...(typeof hoveredControl === 'number' &&
|
|
1481
|
+
hoveredControl >= 0 &&
|
|
1482
|
+
hoveredControl < PROVIDER_IDS.length
|
|
1483
|
+
? { hovered: PROVIDER_IDS[hoveredControl] }
|
|
1484
|
+
: {}), onElement: (id, element) => registerElement(rowElements.current, PROVIDER_IDS.indexOf(id), element) }) }), _jsx(Box, { flexGrow: 1 }), refreshRow ? renderRefreshButton(refreshRow, quickstartProviderColumnWidth - 2, true) : null] }), _jsx(Box, { width: quickstartDetailColumnWidth, flexGrow: 1, flexShrink: 0, paddingX: 1, flexDirection: "column", overflow: "hidden", children: showProviderConfiguration ? (_jsxs(_Fragment, { children: [middleFacts.length > 0 || middleWarningLines.length > 0 ? (_jsxs(Box, { paddingX: 1, 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
|
|
1485
|
+
? renderProviderSelect(selecting)
|
|
1486
|
+
: visibleProviderFieldRows.map((row) => renderProviderField(row, quickstartDetailColumnWidth - 3))] })) : (_jsxs(Box, { flexGrow: 1, flexDirection: showReasoningPanel ? 'row' : 'column', overflow: "hidden", children: [_jsxs(Box, { ref: modelListElement, flexGrow: 1, flexDirection: "column", overflow: "hidden", children: [_jsx(Box, { flexShrink: 0, children: _jsx(Text, { bold: true, color: accent, children: "Models" }) }), _jsx(Box, { ref: modelSearchElement, marginBottom: 1, flexShrink: 0, backgroundColor: controlBackground('search', modelSearchFocused), children: _jsx(Text, { wrap: "truncate-end", children: modelSearchFocused ? (_jsxs(_Fragment, { children: [modelQuery, _jsx(BlinkingCursor, { animate: appearance.animations })] })) : (_jsxs(Text, { dimColor: true, children: ["/ ", modelQuery || 'Search models'] })) }) }), _jsxs(Box, { flexGrow: 1, flexDirection: "column", overflow: "hidden", children: [providerModels.provider !== quickstartProvider || providerModels.loading ? (_jsx(Text, { dimColor: true, children: "Loading model catalog..." })) : !providerModels.available ? (_jsx(Text, { color: palette.warning, children: "Model catalog unavailable" })) : visibleProviderModels.length === 0 ? (_jsx(Text, { dimColor: true, children: modelQuery.trim() ? 'No matching models' : 'No models reported' })) : (_jsxs(_Fragment, { children: [quickstartModelViewportStart > 0 ? (_jsxs(Text, { dimColor: true, children: ["\u2191 ", quickstartModelViewportStart, " more"] })) : null, visibleProviderModels.map((model, visibleIndex) => {
|
|
1487
|
+
const modelIndex = quickstartModelViewportStart + visibleIndex;
|
|
1488
|
+
const index = quickstartModelOffset + modelIndex;
|
|
1489
|
+
const active = `${quickstartProvider}/${model.id}` === draft.profile.model;
|
|
1490
|
+
const focused = focusedAction === undefined && !modelSearchFocused && index === selection;
|
|
1491
|
+
const hovered = hoveredControl === index;
|
|
1492
|
+
const highlighted = focused || hovered;
|
|
1493
|
+
const harnessDefault = model.id === quickstartDefaultModel;
|
|
1494
|
+
return (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), height: quickstartModelRowHeight, paddingX: 1, flexShrink: 0, flexDirection: "column", backgroundColor: rowBackground(index) ?? (active ? COMMAND_DECK_BACKGROUND : undefined), children: [_jsxs(Text, { ...(active || highlighted ? { color: accent, bold: true } : {}), wrap: "truncate-end", children: [active ? '✓ ' : highlighted ? '› ' : ' ', model.name, harnessDefault ? _jsx(Text, { color: accent, children: " \u2605" }) : null] }), active || highlighted ? (_jsxs(Text, { dimColor: true, wrap: "truncate-end", children: [' ', model.id] })) : null] }, model.id));
|
|
1495
|
+
})] })), providerModels.provider === quickstartProvider &&
|
|
1496
|
+
quickstartModelViewportStart + visibleProviderModels.length <
|
|
1497
|
+
filteredProviderModels.length ? (_jsxs(Text, { dimColor: true, children: ["\u2193", ' ', filteredProviderModels.length -
|
|
1498
|
+
quickstartModelViewportStart -
|
|
1499
|
+
visibleProviderModels.length, ' ', "more"] })) : null] }), readyProviderControlRows.length > 0 ? (_jsx(Box, { flexShrink: 0, flexDirection: "column", children: readyProviderControlRows.map((row) => renderProviderField(row, quickstartDetailColumnWidth - (showReasoningPanel ? 36 : 3))) })) : null] }), showReasoningPanel ? (_jsxs(Box, { width: 32, marginLeft: 1, paddingLeft: 1, flexDirection: "column", flexShrink: 0, children: [_jsx(Text, { bold: true, color: accent, children: "Reasoning" }), _jsx(EffortSlider, { slider: reasoningSlider, width: 26, compact: false, pressed: false, focused: reasoningRowIndex === selection, onElement: (element) => {
|
|
1500
|
+
setupEffortSliderElement.current = element;
|
|
1501
|
+
registerElement(rowElements.current, reasoningRowIndex, element);
|
|
1502
|
+
} })] })) : null] })) })] })) : isAppearance ? (_jsx(SetupSettingsPanel, { rows: visibleRows, category: settingsCategory, settings: { ...panelSettings, ...draft.settings, ...appearance }, start: viewportStart, selected: selection, width: bubbleWidth, height: bubbleHeight, ...(typeof hoveredControl === 'string' ? { hoveredControl } : {}), onRowElement: (index, element) => registerElement(rowElements.current, index, element), onChoiceElement: (target, element) => registerElement(choiceElements.current, target, element) })) : isPermissions ? (_jsxs(Box, { flexGrow: 1, paddingX: 1, flexDirection: "column", overflow: "hidden", children: [_jsx(Box, { height: 7, flexShrink: 0, children: rows.slice(0, 3).map((row, index) => (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), flexGrow: 1, flexBasis: 0, height: 7, marginRight: index < 2 ? 1 : 0, paddingX: 1, borderStyle: "single", borderColor: index === selection ? accent : row.active ? palette.success : palette.muted, flexDirection: "column", justifyContent: "center", backgroundColor: rowBackground(index), children: [_jsxs(Text, { bold: true, color: row.active || index === selection ? accent : palette.foreground, children: [row.active ? '◆ ' : '', row.label] }), _jsx(Text, { dimColor: true, wrap: "wrap", children: row.description })] }, 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
|
|
1503
|
+
? `↓ ${rows.length - permissionViewportStart - visiblePermissionTools.length}`
|
|
1504
|
+
: ''] })] }), visiblePermissionTools.map((row, visibleIndex) => {
|
|
1505
|
+
const index = permissionViewportStart + visibleIndex;
|
|
1506
|
+
return (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), height: rowHeight, paddingX: 1, flexShrink: 0, flexDirection: "column", backgroundColor: rowBackground(index), children: [_jsxs(Text, { bold: row.active === true, color: row.active || index === selection ? accent : palette.foreground, children: [row.active ? '☑ ' : '☐ ', row.label] }), _jsx(Text, { dimColor: true, wrap: "truncate-end", children: row.description })] }, row.id));
|
|
1507
|
+
})] })) : (_jsx(Box, { marginTop: 1, paddingX: 1, children: _jsx(Text, { dimColor: true, children: "Choose Custom to set per-tool overrides. Unselected tools continue to use the default policy." }) }))] })) : selecting ? (renderProviderSelect(selecting)) : (_jsx(Box, { flexGrow: 1, flexDirection: "column", overflow: "hidden", children: visibleRows.map((row, visibleIndex) => {
|
|
1508
|
+
const index = viewportStart + visibleIndex;
|
|
1509
|
+
if (row.id === 'refresh-provider') {
|
|
1510
|
+
return renderRefreshButton(row, bubbleWidth - 2);
|
|
1511
|
+
}
|
|
1512
|
+
if (isProviderSetup && row.status) {
|
|
1513
|
+
return (_jsx(ProviderList, { items: [
|
|
1514
|
+
{
|
|
1515
|
+
id: row.id,
|
|
1516
|
+
label: row.label,
|
|
1517
|
+
description: row.description,
|
|
1518
|
+
status: row.status,
|
|
1519
|
+
},
|
|
1520
|
+
], selected: quickstartProvider, width: bubbleWidth, rowHeight: rowHeight, selectedBackground: true, ...(hoveredControl === index ? { hovered: row.id } : {}), onElement: (_, element) => registerElement(rowElements.current, index, element) }, row.id));
|
|
1521
|
+
}
|
|
1522
|
+
const activeEditing = editing?.field === row.field ? editing : undefined;
|
|
1523
|
+
return (_jsxs(Box, { ref: (element) => registerElement(rowElements.current, index, element), paddingX: row.field ? 0 : 1, height: rowHeight, flexShrink: 0, flexDirection: "column", backgroundColor: row.field ? undefined : rowBackground(index), 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.status ? (_jsx(Text, { color: palette[row.status], children: "\u25CF " })) : row.field ? ('') : row.active === undefined ? ('') : row.active ? ('☑ ') : ('☐ '), row.label, flow === 'manual' && step === MANUAL_STEPS.length ? ' →' : ''] }), directoryRows.has(index) ? (_jsx(Box, { ref: (element) => registerElement(directoryElements.current, index, element), paddingX: 1, flexShrink: 0, backgroundColor: controlBackground(`browse:${index}`, focusedAction === `browse:${index}`) ??
|
|
1524
|
+
COMMAND_DECK_BACKGROUND, 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', backgroundColor: rowBackground(index) ?? COMMAND_DECK_BACKGROUND, children: _jsx(EditableText, { value: activeEditing?.value ?? row.description, cursor: activeEditing
|
|
1525
|
+
? (activeEditing.cursor ?? graphemes(activeEditing.value).length)
|
|
1526
|
+
: graphemes(row.description).length, width: Math.max(1, bubbleWidth - 4), maxRows: row.field === 'instructions' ? rowHeight - 2 : 1, active: Boolean(activeEditing), animate: appearance.animations }) })) : (_jsx(Text, { ...(row.descriptionColor
|
|
1527
|
+
? { color: row.descriptionColor }
|
|
1528
|
+
: row.status
|
|
1529
|
+
? { color: palette[row.status] }
|
|
1530
|
+
: { dimColor: true }), wrap: "truncate-end", children: row.description }))] }, row.id));
|
|
1531
|
+
}) })), warningLines.length > 0 ? (_jsx(Box, { paddingX: 1, 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: [
|
|
1532
|
+
['back', 'Back', backElement],
|
|
1533
|
+
['next', primaryLabel, nextElement],
|
|
1534
|
+
].map(([action, label, elementRef]) => {
|
|
1535
|
+
const primary = action === 'next';
|
|
1536
|
+
const enabled = canContinue && !saving;
|
|
1537
|
+
const active = focusedAction === action;
|
|
1538
|
+
const hovered = hoveredControl === action;
|
|
1539
|
+
const interactiveHover = hovered && (!primary || enabled);
|
|
1540
|
+
return (_jsx(Box, { ref: (element) => {
|
|
1541
|
+
elementRef.current = element ?? undefined;
|
|
1542
|
+
}, width: actionWidth, height: actionHeight, alignItems: "center", justifyContent: "center", backgroundColor: interactiveHover
|
|
1543
|
+
? action === 'back'
|
|
1544
|
+
? backHoverBackground
|
|
1545
|
+
: nextHoverBackground
|
|
1546
|
+
: active
|
|
1547
|
+
? PANEL_SELECTION
|
|
1548
|
+
: (controlBackground(action, active, primary && !canContinue) ?? COMMAND_DECK_BACKGROUND), children: _jsx(Text, { bold: true, ...(interactiveHover ? { color: palette.foreground } : active ? { color: accent } : {}), dimColor: primary ? !enabled : saving, children: label }) }, action));
|
|
1549
|
+
}) })) : null] }) })), width < 32 ? (_jsxs(Box, { height: navigationHeight, flexShrink: 0, flexDirection: "column", children: [_jsx(Box, { justifyContent: "center", children: _jsx(Text, { dimColor: true, wrap: "truncate-end", children: navigationHints[0] }) }), _jsxs(Box, { height: 1, alignItems: "center", children: [settingsButton, _jsx(Box, { flexGrow: 1, justifyContent: "center", overflow: "hidden", children: _jsx(Text, { dimColor: true, wrap: "truncate-end", children: navigationHints[1] }) })] })] })) : (_jsxs(Box, { height: navigationHeight, flexShrink: 0, alignItems: "center", children: [settingsButton, _jsx(Box, { flexGrow: 1, flexDirection: "column", alignItems: "center", overflow: "hidden", children: navigationHints.map((hint) => (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: hint }, hint))) })] })), appearanceOpen ? (_jsx(CustomThemeEditor, { settings: priorAppearance.current, animate: appearance.animations, width: width, height: height, onPreview: previewAppearance, onClose: closeAppearance, onApply: (next) => {
|
|
1550
|
+
priorAppearance.current = { ...appearance, ...next };
|
|
1551
|
+
updateAppearance(priorAppearance.current);
|
|
1552
|
+
} })) : null] }));
|
|
1553
|
+
}
|
|
1554
|
+
function isProviderEnvironmentKey(value) {
|
|
1555
|
+
return PROVIDER_ENVIRONMENT_KEYS.includes(value);
|
|
1556
|
+
}
|
|
1557
|
+
//# sourceMappingURL=index.js.map
|