@aria-cli/cli 1.0.49 → 1.0.51
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/bin/aria.mjs +2 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/attached-local-control-client.js +826 -0
- package/dist/bootstrap-local-control-client.js +2 -0
- package/dist/capability-aware-method-proxy.js +42 -0
- package/dist/cli-context.js +160 -0
- package/dist/commands/arions.js +174 -0
- package/dist/commands/auth.js +123 -0
- package/dist/commands/daemon.js +245 -0
- package/dist/commands/definitions.js +176 -0
- package/dist/commands/index.js +74 -0
- package/dist/commands/login-handler.js +1108 -0
- package/dist/commands/logout-handler.js +92 -0
- package/dist/commands/memory-handlers.js +89 -0
- package/dist/commands/pairing.js +60 -0
- package/dist/commands/runtime-cutover-reset-command.js +12 -0
- package/dist/commands/runtime-cutover-reset.js +265 -0
- package/dist/commands/terminal-setup.js +84 -0
- package/dist/config/aria-config.js +238 -0
- package/dist/config/index.js +3 -0
- package/dist/config/loader.js +97 -0
- package/dist/config.js +142 -0
- package/dist/daemon-info.js +10 -0
- package/dist/ensure-daemon.js +128 -0
- package/dist/entrypoints/command-mode.js +5 -0
- package/dist/entrypoints/daemon.js +50 -0
- package/dist/entrypoints/headless-stdio.js +25 -0
- package/dist/entrypoints/interactive.js +80 -0
- package/dist/event-loop-watchdog.js +73 -0
- package/dist/headless/auth-orchestrator.js +508 -0
- package/dist/headless/auth-service.js +43 -0
- package/dist/headless/bootstrap-fast-path.js +112 -0
- package/dist/headless/call-command.js +143 -0
- package/dist/headless/daemon-service.js +318 -0
- package/dist/headless/hook-actions.js +235 -0
- package/dist/headless/hook-service.js +42 -0
- package/dist/headless/kernel-services.js +216 -0
- package/dist/headless/kernel.js +785 -0
- package/dist/headless/operations/arion.js +119 -0
- package/dist/headless/operations/auth.js +45 -0
- package/dist/headless/operations/client.js +31 -0
- package/dist/headless/operations/config.js +69 -0
- package/dist/headless/operations/daemon.js +47 -0
- package/dist/headless/operations/hook.js +56 -0
- package/dist/headless/operations/index.js +11 -0
- package/dist/headless/operations/memory.js +102 -0
- package/dist/headless/operations/message.js +279 -0
- package/dist/headless/operations/model.js +100 -0
- package/dist/headless/operations/peer.js +56 -0
- package/dist/headless/operations/run.js +24 -0
- package/dist/headless/operations/session.js +90 -0
- package/dist/headless/operations/system.js +19 -0
- package/dist/headless/operations/utils.js +35 -0
- package/dist/headless/run-orchestrator.js +703 -0
- package/dist/headless/stdio-server.js +439 -0
- package/dist/history/SessionHistory.js +8 -0
- package/dist/history/SessionHistoryClient.js +186 -0
- package/dist/history/conversation-message.js +112 -0
- package/dist/history/index.js +8 -0
- package/dist/history/jsonl-replay.js +154 -0
- package/dist/history/repair-tool-pairing.js +84 -0
- package/dist/history/stall-phase-bridge.js +11 -0
- package/dist/history/turn-accumulator.js +427 -0
- package/dist/index.js +7 -0
- package/dist/ink-repl.js +4183 -0
- package/dist/local-control-bootstrap.js +26 -0
- package/dist/local-control-client.js +2 -0
- package/dist/local-control-error-reporting.js +34 -0
- package/dist/local-control-http-client.js +362 -0
- package/dist/local-control-lazy-wrapper.js +363 -0
- package/dist/local-control-manager.js +146 -0
- package/dist/main.js +38 -0
- package/dist/network-security.js +62 -0
- package/dist/networking-server.js +38 -0
- package/dist/peer-identity.js +23 -0
- package/dist/polling-subscription.js +34 -0
- package/dist/relaunch.js +588 -0
- package/dist/release-notes.js +35 -0
- package/dist/repl-cleanup.js +47 -0
- package/dist/runtime/configure-bun-sqlite.js +3 -0
- package/dist/runtime/crash-handlers.js +111 -0
- package/dist/runtime/interactive-invocation.js +39 -0
- package/dist/runtime/internal-mode.js +14 -0
- package/dist/runtime/launch-spec.js +64 -0
- package/dist/runtime/owner-lease.js +44 -0
- package/dist/runtime/public-mode.js +20 -0
- package/dist/runtime/run-internal-mode.js +18 -0
- package/dist/runtime/runtime-kind.js +32 -0
- package/dist/runtime/spawn-aria.js +38 -0
- package/dist/selectable-client.js +2 -0
- package/dist/selectable-peer.js +2 -0
- package/dist/session.js +203 -0
- package/dist/slash-commands.js +80 -0
- package/dist/sounds.js +210 -0
- package/dist/ui/App.js +526 -0
- package/dist/ui/components/AnthropicMethodPicker.js +6 -0
- package/dist/ui/components/ArionPrompt.js +15 -0
- package/dist/ui/components/AutocompleteDropdown.js +23 -0
- package/dist/ui/components/AutonomySelector.js +55 -0
- package/dist/ui/components/Banner.js +98 -0
- package/dist/ui/components/ConversationHistory.js +175 -0
- package/dist/ui/components/CopilotDeviceLoginFlow.js +88 -0
- package/dist/ui/components/CopilotSourcePicker.js +50 -0
- package/dist/ui/components/Cost.js +10 -0
- package/dist/ui/components/CustomSelect/option-map.js +30 -0
- package/dist/ui/components/CustomSelect/select-option.js +13 -0
- package/dist/ui/components/CustomSelect/select.js +42 -0
- package/dist/ui/components/CustomSelect/use-select-state.js +179 -0
- package/dist/ui/components/CustomSelect/use-select.js +15 -0
- package/dist/ui/components/ErrorDisplay.js +35 -0
- package/dist/ui/components/FallbackToolUseRejectedMessage.js +7 -0
- package/dist/ui/components/FileEditToolUpdatedMessage.js +57 -0
- package/dist/ui/components/HandoffMarker.js +18 -0
- package/dist/ui/components/HighlightedCode.js +21 -0
- package/dist/ui/components/InputArea.js +187 -0
- package/dist/ui/components/Message.js +25 -0
- package/dist/ui/components/OAuthLoginFlow.js +113 -0
- package/dist/ui/components/OutputTruncation.js +35 -0
- package/dist/ui/components/PermissionPrompt.js +79 -0
- package/dist/ui/components/PipelineTimingPanel.js +15 -0
- package/dist/ui/components/ProviderMethodPicker.js +61 -0
- package/dist/ui/components/ProviderPicker.js +63 -0
- package/dist/ui/components/RenderItemView.js +71 -0
- package/dist/ui/components/Spinner.js +46 -0
- package/dist/ui/components/StatusBar.js +95 -0
- package/dist/ui/components/StreamingIndicator.js +55 -0
- package/dist/ui/components/StructuredDiff.js +168 -0
- package/dist/ui/components/TextInputOverlay.js +43 -0
- package/dist/ui/components/ThinkingBlock.js +82 -0
- package/dist/ui/components/ToolCost.js +17 -0
- package/dist/ui/components/ToolExecution.js +61 -0
- package/dist/ui/components/ToolHeader.js +51 -0
- package/dist/ui/components/ToolRenderLayoutContext.js +14 -0
- package/dist/ui/components/ToolResultWrapper.js +6 -0
- package/dist/ui/components/ToolUseLoader.js +35 -0
- package/dist/ui/components/TraceWaterfall.js +91 -0
- package/dist/ui/components/index.js +33 -0
- package/dist/ui/components/messages/AssistantTextMessage.js +25 -0
- package/dist/ui/components/messages/UserImageMessage.js +12 -0
- package/dist/ui/components/messages/UserTextMessage.js +12 -0
- package/dist/ui/components/overlays/ArionSelector.js +68 -0
- package/dist/ui/components/overlays/ClientSelector.js +62 -0
- package/dist/ui/components/overlays/CommandPalette.js +67 -0
- package/dist/ui/components/overlays/DaemonControl.js +87 -0
- package/dist/ui/components/overlays/InviteShareOverlay.js +15 -0
- package/dist/ui/components/overlays/JoinInviteOverlay.js +32 -0
- package/dist/ui/components/overlays/MemoryBrowser.js +100 -0
- package/dist/ui/components/overlays/MessageSelector.js +123 -0
- package/dist/ui/components/overlays/ModelSelector.js +211 -0
- package/dist/ui/components/overlays/PairRequestOverlay.js +42 -0
- package/dist/ui/components/overlays/PeerSelector.js +84 -0
- package/dist/ui/components/overlays/SessionSelector.js +102 -0
- package/dist/ui/components/overlays/SoundSelector.js +86 -0
- package/dist/ui/components/overlays/ThemeSelector.js +139 -0
- package/dist/ui/components/overlays/index.js +15 -0
- package/dist/ui/components/permissions/BashPermissionRequest/BashPermissionRequest.js +53 -0
- package/dist/ui/components/permissions/FallbackPermissionRequest.js +56 -0
- package/dist/ui/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.js +76 -0
- package/dist/ui/components/permissions/FileEditPermissionRequest/FileEditToolDiff.js +18 -0
- package/dist/ui/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.js +64 -0
- package/dist/ui/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.js +26 -0
- package/dist/ui/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js +141 -0
- package/dist/ui/components/permissions/PermissionRequest.js +70 -0
- package/dist/ui/components/permissions/PermissionRequestTitle.js +41 -0
- package/dist/ui/components/permissions/hooks.js +10 -0
- package/dist/ui/components/permissions/toolUseOptions.js +68 -0
- package/dist/ui/components/permissions/utils.js +10 -0
- package/dist/ui/components/text-input/Cursor.js +326 -0
- package/dist/ui/components/text-input/TextInput.js +231 -0
- package/dist/ui/components/text-input/imagePaste.js +28 -0
- package/dist/ui/components/text-input/index.js +6 -0
- package/dist/ui/components/text-input/useDoublePress.js +30 -0
- package/dist/ui/components/text-input/useTextInput.js +245 -0
- package/dist/ui/components/tool-types.js +9 -0
- package/dist/ui/constants/figures.js +4 -0
- package/dist/ui/constants/index.js +3 -0
- package/dist/ui/display-mode.js +93 -0
- package/dist/ui/display-policy.js +19 -0
- package/dist/ui/hooks/index.js +6 -0
- package/dist/ui/hooks/useCommandAutocomplete.js +93 -0
- package/dist/ui/hooks/useDoublePress.js +37 -0
- package/dist/ui/hooks/useIndicatorState.js +55 -0
- package/dist/ui/hooks/useInterval.js +23 -0
- package/dist/ui/hooks/useKeyboardShortcuts.js +127 -0
- package/dist/ui/hooks/useTerminalSize.js +55 -0
- package/dist/ui/hooks/useUnifiedMessages.js +117 -0
- package/dist/ui/indicator-state.js +44 -0
- package/dist/ui/markdown/highlight.js +44 -0
- package/dist/ui/markdown/index.js +1460 -0
- package/dist/ui/markdown/tokenizer.js +24 -0
- package/dist/ui/render-item.js +5 -0
- package/dist/ui/screens/REPL.js +119 -0
- package/dist/ui/screens/approval-lifecycle.js +38 -0
- package/dist/ui/status-line.js +72 -0
- package/dist/ui/theme/index.js +51 -0
- package/dist/ui/theme/themes/claude-dark-daltonized.js +51 -0
- package/dist/ui/theme/themes/claude-dark.js +50 -0
- package/dist/ui/theme/themes/claude-light-daltonized.js +51 -0
- package/dist/ui/theme/themes/claude-light.js +50 -0
- package/dist/ui/theme/themes/dark-accessible.js +18 -0
- package/dist/ui/theme/themes/dark.js +49 -0
- package/dist/ui/theme/themes/light-accessible.js +18 -0
- package/dist/ui/theme/themes/light.js +49 -0
- package/dist/ui/theme/types.js +3 -0
- package/dist/ui/theme.js +142 -0
- package/dist/ui/to-render-items.js +145 -0
- package/dist/ui/tools/AgentTool/index.js +30 -0
- package/dist/ui/tools/ArchitectTool/index.js +31 -0
- package/dist/ui/tools/AskUserTool/index.js +46 -0
- package/dist/ui/tools/BashTool/BashToolResultMessage.js +11 -0
- package/dist/ui/tools/BashTool/OutputLine.js +21 -0
- package/dist/ui/tools/BashTool/index.js +91 -0
- package/dist/ui/tools/BrowseTool/index.js +43 -0
- package/dist/ui/tools/BrowserTool/index.js +47 -0
- package/dist/ui/tools/CbmTool/index.js +188 -0
- package/dist/ui/tools/CheckDelegationTool/index.js +46 -0
- package/dist/ui/tools/CheckMessagesTool/index.js +85 -0
- package/dist/ui/tools/CreateQuipTool/index.js +30 -0
- package/dist/ui/tools/CreateSkillTool/index.js +22 -0
- package/dist/ui/tools/CreateToolTool/index.js +31 -0
- package/dist/ui/tools/DelegateRemoteTool/index.js +42 -0
- package/dist/ui/tools/DeployTool/index.js +47 -0
- package/dist/ui/tools/FffTool/index.js +103 -0
- package/dist/ui/tools/FileEditTool/index.js +67 -0
- package/dist/ui/tools/FileReadTool/index.js +68 -0
- package/dist/ui/tools/FileWriteTool/index.js +61 -0
- package/dist/ui/tools/ForkTool/index.js +47 -0
- package/dist/ui/tools/FrgTool/index.js +96 -0
- package/dist/ui/tools/GetThreadTool/index.js +39 -0
- package/dist/ui/tools/GlobTool/index.js +50 -0
- package/dist/ui/tools/GrepTool/index.js +84 -0
- package/dist/ui/tools/HatchArionTool/index.js +36 -0
- package/dist/ui/tools/LearnSkillTool/index.js +22 -0
- package/dist/ui/tools/LearnTool/index.js +43 -0
- package/dist/ui/tools/LearnToolTool/index.js +22 -0
- package/dist/ui/tools/ListClientsTool/index.js +39 -0
- package/dist/ui/tools/LspTool/index.js +261 -0
- package/dist/ui/tools/MCPTool/index.js +33 -0
- package/dist/ui/tools/ManageNetworkTool/index.js +53 -0
- package/dist/ui/tools/MemoryReadTool/index.js +64 -0
- package/dist/ui/tools/MemoryWriteTool/index.js +20 -0
- package/dist/ui/tools/NotebookEditTool/index.js +33 -0
- package/dist/ui/tools/NotebookReadTool/index.js +25 -0
- package/dist/ui/tools/OutlookReadTool/index.js +66 -0
- package/dist/ui/tools/OutlookReplyTool/index.js +49 -0
- package/dist/ui/tools/OutlookSendTool/index.js +49 -0
- package/dist/ui/tools/PauseDelegationTool/index.js +35 -0
- package/dist/ui/tools/ProbeTool/index.js +121 -0
- package/dist/ui/tools/ProcessTool/index.js +66 -0
- package/dist/ui/tools/QuestListTool/index.js +46 -0
- package/dist/ui/tools/QuestReportTool/index.js +49 -0
- package/dist/ui/tools/QuestUpdateTool/index.js +87 -0
- package/dist/ui/tools/QuipCommentTool/index.js +69 -0
- package/dist/ui/tools/QuipReadTool/index.js +71 -0
- package/dist/ui/tools/RestArionTool/index.js +32 -0
- package/dist/ui/tools/RestartTool/index.js +35 -0
- package/dist/ui/tools/ResumeDelegationTool/index.js +35 -0
- package/dist/ui/tools/RetireArionTool/index.js +32 -0
- package/dist/ui/tools/RgTool/index.js +73 -0
- package/dist/ui/tools/SearchKnowledgeTool/index.js +43 -0
- package/dist/ui/tools/SearchMessagesTool/index.js +43 -0
- package/dist/ui/tools/SelfDiagnoseTool/index.js +61 -0
- package/dist/ui/tools/SendMessageTool/index.js +45 -0
- package/dist/ui/tools/SerenaTool/index.js +124 -0
- package/dist/ui/tools/SessionHistoryTool/index.js +52 -0
- package/dist/ui/tools/SgTool/index.js +80 -0
- package/dist/ui/tools/SlackReactTool/index.js +41 -0
- package/dist/ui/tools/SlackReadTool/index.js +48 -0
- package/dist/ui/tools/SlackSendTool/index.js +45 -0
- package/dist/ui/tools/SpawnWorkerTool/index.js +33 -0
- package/dist/ui/tools/StickerRequestTool/index.js +19 -0
- package/dist/ui/tools/ThinkTool/index.js +17 -0
- package/dist/ui/tools/UgTool/index.js +108 -0
- package/dist/ui/tools/UseSkillTool/index.js +22 -0
- package/dist/ui/tools/WakeArionTool/index.js +32 -0
- package/dist/ui/tools/WebFetchTool/index.js +56 -0
- package/dist/ui/tools/WebSearchTool/index.js +44 -0
- package/dist/ui/tools/lsTool/index.js +58 -0
- package/dist/ui/tools/registry.js +197 -0
- package/dist/ui/tools/tool-renderer.js +11 -0
- package/dist/ui/tools/truncation.js +35 -0
- package/dist/ui/types/anthropic.js +4 -0
- package/dist/ui/types/index.js +2 -0
- package/dist/ui/types/message.js +3 -0
- package/dist/ui/types/tool.js +4 -0
- package/dist/ui/utils/array.js +4 -0
- package/dist/ui/utils/cursor.js +131 -0
- package/dist/ui/utils/diff.js +120 -0
- package/dist/ui/utils/format.js +42 -0
- package/dist/ui/utils/fuzzy.js +59 -0
- package/dist/ui/utils/index.js +11 -0
- package/dist/ui/utils/keys.js +8 -0
- package/dist/ui/utils/patch.js +17 -0
- package/dist/ui/utils/risk.js +114 -0
- package/dist/ui/utils/terminal-image.js +70 -0
- package/dist/ui/utils/validation.js +48 -0
- package/dist/ui/verb-pairs.js +248 -0
- package/dist/ui.js +131 -0
- package/package.json +73 -14
- package/src/entrypoints/command-mode.ts +5 -0
- package/src/entrypoints/daemon.ts +54 -0
- package/src/entrypoints/headless-stdio.ts +27 -0
- package/src/entrypoints/interactive.ts +112 -0
- package/src/main.ts +44 -0
- package/src/runtime/configure-bun-sqlite.ts +3 -0
- package/src/runtime/crash-handlers.ts +128 -0
- package/src/runtime/interactive-invocation.test.ts +42 -0
- package/src/runtime/interactive-invocation.ts +51 -0
- package/src/runtime/internal-mode.test.ts +19 -0
- package/src/runtime/internal-mode.ts +24 -0
- package/src/runtime/launch-spec.test.ts +26 -0
- package/src/runtime/launch-spec.ts +84 -0
- package/src/runtime/owner-lease.ts +52 -0
- package/src/runtime/public-mode.test.ts +18 -0
- package/src/runtime/public-mode.ts +19 -0
- package/src/runtime/run-internal-mode.ts +19 -0
- package/src/runtime/runtime-kind.test.ts +23 -0
- package/src/runtime/runtime-kind.ts +41 -0
- package/src/runtime/spawn-aria.ts +62 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useMemo } from "react";
|
|
3
|
+
import { Box, Text, useInput } from "ink";
|
|
4
|
+
import { isEscapeInput } from "../../utils/keys.js";
|
|
5
|
+
import { getModelColor, getProviderStyle } from "../../theme.js";
|
|
6
|
+
const PROVIDER_LABELS = {
|
|
7
|
+
anthropic: "Anthropic",
|
|
8
|
+
"openai-codex": "OpenAI Codex",
|
|
9
|
+
google: "Google",
|
|
10
|
+
bedrock: "AWS Bedrock",
|
|
11
|
+
"bedrock-converse": "AWS Bedrock (Converse)",
|
|
12
|
+
"github-copilot": "GitHub Copilot",
|
|
13
|
+
openai: "OpenAI",
|
|
14
|
+
local: "Local",
|
|
15
|
+
};
|
|
16
|
+
/** Display order for provider groups in the model selector. */
|
|
17
|
+
const PROVIDER_ORDER = [
|
|
18
|
+
"anthropic",
|
|
19
|
+
"openai-codex",
|
|
20
|
+
"google",
|
|
21
|
+
"bedrock",
|
|
22
|
+
"bedrock-converse",
|
|
23
|
+
"github-copilot",
|
|
24
|
+
"openai",
|
|
25
|
+
"local",
|
|
26
|
+
];
|
|
27
|
+
function getProviderLabel(provider) {
|
|
28
|
+
return PROVIDER_LABELS[provider] || provider;
|
|
29
|
+
}
|
|
30
|
+
function getProviderSortKey(provider) {
|
|
31
|
+
const idx = PROVIDER_ORDER.indexOf(provider);
|
|
32
|
+
return idx >= 0 ? idx : PROVIDER_ORDER.length;
|
|
33
|
+
}
|
|
34
|
+
function buildProviderGroups(models, items, selectableIndices) {
|
|
35
|
+
const groups = new Map();
|
|
36
|
+
for (const model of models) {
|
|
37
|
+
const key = model.provider || "other";
|
|
38
|
+
const group = groups.get(key) ?? [];
|
|
39
|
+
group.push(model);
|
|
40
|
+
groups.set(key, group);
|
|
41
|
+
}
|
|
42
|
+
// Sort groups by PROVIDER_ORDER, models by tier (powerful first)
|
|
43
|
+
const TIER_PRIORITY = {
|
|
44
|
+
powerful: 0,
|
|
45
|
+
balanced: 1,
|
|
46
|
+
fast: 2,
|
|
47
|
+
ensemble: 3,
|
|
48
|
+
};
|
|
49
|
+
const sortedEntries = [...groups.entries()].sort(([a], [b]) => getProviderSortKey(a) - getProviderSortKey(b));
|
|
50
|
+
for (const [provider, groupModels] of sortedEntries) {
|
|
51
|
+
items.push({ type: "header", label: getProviderLabel(provider), provider });
|
|
52
|
+
const tierFromDesc = (desc) => {
|
|
53
|
+
if (!desc)
|
|
54
|
+
return "balanced";
|
|
55
|
+
const d = desc.toLowerCase();
|
|
56
|
+
if (d.includes("deep"))
|
|
57
|
+
return "powerful";
|
|
58
|
+
if (d.includes("quick"))
|
|
59
|
+
return "fast";
|
|
60
|
+
return "balanced";
|
|
61
|
+
};
|
|
62
|
+
// Model family order: Claude first, then OpenAI/GPT, then Gemini, then others
|
|
63
|
+
// Within Claude: opus > sonnet > haiku (via bedrock-opus > bedrock-sonnet > bedrock-haiku)
|
|
64
|
+
const MODEL_FAMILY_ORDER = [
|
|
65
|
+
/^claude-opus-|^opus-|^bedrock-opus-/,
|
|
66
|
+
/^claude-sonnet-|^sonnet-|^bedrock-sonnet-/,
|
|
67
|
+
/^claude-haiku-|^haiku-|^bedrock-haiku-/,
|
|
68
|
+
/^claude-/,
|
|
69
|
+
/^gpt-/,
|
|
70
|
+
/^o[0-9]/,
|
|
71
|
+
/^gemini-/,
|
|
72
|
+
];
|
|
73
|
+
const familyRank = (name) => {
|
|
74
|
+
const lower = name.toLowerCase();
|
|
75
|
+
for (let i = 0; i < MODEL_FAMILY_ORDER.length; i++) {
|
|
76
|
+
if (MODEL_FAMILY_ORDER[i].test(lower))
|
|
77
|
+
return i;
|
|
78
|
+
}
|
|
79
|
+
return MODEL_FAMILY_ORDER.length;
|
|
80
|
+
};
|
|
81
|
+
const sorted = [...groupModels].sort((a, b) => {
|
|
82
|
+
// Primary: family group (Claude > GPT > Gemini)
|
|
83
|
+
const fa = familyRank(a.name);
|
|
84
|
+
const fb = familyRank(b.name);
|
|
85
|
+
if (fa !== fb)
|
|
86
|
+
return fa - fb;
|
|
87
|
+
// Secondary: higher version first (4.6 > 4.5, 5.3 > 5.2)
|
|
88
|
+
// Then tier within same version
|
|
89
|
+
return b.name.localeCompare(a.name);
|
|
90
|
+
});
|
|
91
|
+
for (const model of sorted) {
|
|
92
|
+
selectableIndices.push(items.length);
|
|
93
|
+
items.push({ type: "model", model });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const EFFORT_LEVELS = ["low", "medium", "high", "max"];
|
|
98
|
+
const EFFORT_BARS = {
|
|
99
|
+
low: "▌",
|
|
100
|
+
medium: "▌▌",
|
|
101
|
+
high: "▌▌▌",
|
|
102
|
+
max: "▌▌▌▌",
|
|
103
|
+
};
|
|
104
|
+
const EFFORT_LABELS = {
|
|
105
|
+
low: "Low",
|
|
106
|
+
medium: "Medium",
|
|
107
|
+
high: "High",
|
|
108
|
+
max: "Max",
|
|
109
|
+
};
|
|
110
|
+
const EFFORT_COLORS = {
|
|
111
|
+
low: "blue",
|
|
112
|
+
medium: "cyan",
|
|
113
|
+
high: "yellow",
|
|
114
|
+
max: "magenta",
|
|
115
|
+
};
|
|
116
|
+
export function ModelSelector({ models, initialFilter = "", effortLevel, onSelect, onCancel, }) {
|
|
117
|
+
const [filter, setFilter] = useState(initialFilter);
|
|
118
|
+
const [effort, setEffort] = useState(effortLevel ?? "high");
|
|
119
|
+
const allFiltered = models.filter((m) => m.name.toLowerCase().includes(filter.toLowerCase()));
|
|
120
|
+
const visibleModels = allFiltered;
|
|
121
|
+
const { items, selectableIndices } = useMemo(() => {
|
|
122
|
+
const hasProviders = visibleModels.some((m) => m.provider);
|
|
123
|
+
if (!hasProviders) {
|
|
124
|
+
return {
|
|
125
|
+
items: visibleModels.map((m) => ({ type: "model", model: m })),
|
|
126
|
+
selectableIndices: visibleModels.map((_, i) => i),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
const items = [];
|
|
130
|
+
const selectableIndices = [];
|
|
131
|
+
buildProviderGroups(visibleModels, items, selectableIndices);
|
|
132
|
+
return { items, selectableIndices };
|
|
133
|
+
}, [visibleModels]);
|
|
134
|
+
const currentSelectableIdx = selectableIndices.findIndex((itemIdx) => {
|
|
135
|
+
const item = items[itemIdx];
|
|
136
|
+
return item?.type === "model" && item.model.isCurrent;
|
|
137
|
+
});
|
|
138
|
+
const [selectedIndex, setSelectedIndex] = useState(currentSelectableIdx >= 0 ? currentSelectableIdx : 0);
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
setSelectedIndex((i) => Math.min(i, Math.max(0, selectableIndices.length - 1)));
|
|
141
|
+
}, [selectableIndices.length]);
|
|
142
|
+
const safeIndex = selectableIndices.length > 0 ? Math.min(selectedIndex, selectableIndices.length - 1) : 0;
|
|
143
|
+
const isRawModeSupported = process.stdin.isTTY ?? false;
|
|
144
|
+
useInput((input, key) => {
|
|
145
|
+
if (isEscapeInput(input, key)) {
|
|
146
|
+
onCancel();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (key.return && selectableIndices.length > 0) {
|
|
150
|
+
const itemIdx = selectableIndices[safeIndex];
|
|
151
|
+
const item = items[itemIdx];
|
|
152
|
+
if (item.type === "model") {
|
|
153
|
+
onSelect(item.model, effort);
|
|
154
|
+
}
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (key.leftArrow) {
|
|
158
|
+
setEffort((prev) => {
|
|
159
|
+
const idx = EFFORT_LEVELS.indexOf(prev);
|
|
160
|
+
return EFFORT_LEVELS[Math.max(0, idx - 1)];
|
|
161
|
+
});
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (key.rightArrow) {
|
|
165
|
+
setEffort((prev) => {
|
|
166
|
+
const idx = EFFORT_LEVELS.indexOf(prev);
|
|
167
|
+
return EFFORT_LEVELS[Math.min(EFFORT_LEVELS.length - 1, idx + 1)];
|
|
168
|
+
});
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (key.upArrow) {
|
|
172
|
+
setSelectedIndex((i) => Math.max(0, i - 1));
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (key.downArrow) {
|
|
176
|
+
setSelectedIndex((i) => Math.min(selectableIndices.length - 1, i + 1));
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (key.backspace || key.delete) {
|
|
180
|
+
setFilter((f) => f.slice(0, -1));
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (input && !key.ctrl && !key.meta) {
|
|
184
|
+
setFilter((f) => f + input);
|
|
185
|
+
}
|
|
186
|
+
}, { isActive: isRawModeSupported });
|
|
187
|
+
const positionIndicator = selectableIndices.length > 0 ? ` [${safeIndex + 1}/${selectableIndices.length}]` : "";
|
|
188
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "gray", paddingX: 1, children: [_jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { bold: true, children: "Model" }), _jsx(Text, { dimColor: true, children: positionIndicator }), _jsx(Text, { children: " " }), filter ? _jsx(Text, { color: "cyan", children: filter }) : _jsx(Text, { dimColor: true, children: "Type to search..." })] }), visibleModels.length === 0 && _jsx(Text, { dimColor: true, children: "No matching models" }), (() => {
|
|
189
|
+
// Compute max model name width for aligned descriptions
|
|
190
|
+
const maxNameLen = items.reduce((max, item) => {
|
|
191
|
+
if (item.type !== "model")
|
|
192
|
+
return max;
|
|
193
|
+
return Math.max(max, item.model.name.length);
|
|
194
|
+
}, 0);
|
|
195
|
+
return items.map((item, i) => {
|
|
196
|
+
if (item.type === "header") {
|
|
197
|
+
const style = getProviderStyle(item.provider);
|
|
198
|
+
return (_jsxs(Box, { marginTop: i > 0 ? 1 : 0, children: [_jsxs(Text, { color: style.color, children: [style.icon, " "] }), _jsx(Text, { bold: true, color: style.color, children: item.label })] }, `header-${item.label}-${i}`));
|
|
199
|
+
}
|
|
200
|
+
if (item.type === "hint") {
|
|
201
|
+
return (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, italic: true, children: item.label }) }, "hint"));
|
|
202
|
+
}
|
|
203
|
+
const isSelected = selectableIndices[safeIndex] === i;
|
|
204
|
+
const showDescription = item.model.description;
|
|
205
|
+
const padded = item.model.name.padEnd(maxNameLen);
|
|
206
|
+
const modelColor = getModelColor(item.model.name);
|
|
207
|
+
return (_jsxs(Box, { children: [_jsxs(Text, { inverse: isSelected, color: isSelected ? undefined : modelColor, dimColor: isSelected ? false : !modelColor, children: [item.model.isCurrent ? "●" : "○", " ", padded] }), showDescription && _jsxs(Text, { dimColor: true, children: [" ", item.model.description] })] }, item.model.value ?? `${item.model.provider}-${item.model.name}`));
|
|
208
|
+
});
|
|
209
|
+
})(), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Box, { children: [_jsxs(Text, { color: EFFORT_COLORS[effort], children: [EFFORT_BARS[effort], " "] }), _jsxs(Text, { color: EFFORT_COLORS[effort], bold: true, children: [EFFORT_LABELS[effort], " effort"] }), effort === "high" && _jsx(Text, { dimColor: true, children: " (default)" }), _jsx(Text, { dimColor: true, children: " \u2190 \u2192 to adjust" })] }), _jsx(Box, { marginTop: 0, children: _jsx(Text, { dimColor: true, children: "\u2191\u2193 navigate \u2190 \u2192 effort \u23CE select esc cancel" }) })] })] }));
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=ModelSelector.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Pair request overlay — shown when another ARIA instance requests connection.
|
|
4
|
+
*
|
|
5
|
+
* Displays the requester's name and signing key fingerprint for visual
|
|
6
|
+
* verification, with Accept/Reject buttons.
|
|
7
|
+
*/
|
|
8
|
+
import { useState, useRef } from "react";
|
|
9
|
+
import { Box, Text, useInput } from "ink";
|
|
10
|
+
import { getTheme } from "../../theme/index.js";
|
|
11
|
+
import { isEscapeInput } from "../../utils/keys.js";
|
|
12
|
+
export function PairRequestOverlay({ request, onAccept, onReject }) {
|
|
13
|
+
const [selected, setSelected] = useState("accept");
|
|
14
|
+
const submittedRef = useRef(false);
|
|
15
|
+
const theme = getTheme();
|
|
16
|
+
const isRawModeSupported = process.stdin.isTTY ?? false;
|
|
17
|
+
const formatFp = (fp) => `${fp.slice(0, 4)} ${fp.slice(4, 8)} ${fp.slice(8, 12)} ${fp.slice(12, 16)}`;
|
|
18
|
+
useInput((input, key) => {
|
|
19
|
+
if (submittedRef.current)
|
|
20
|
+
return;
|
|
21
|
+
if (key.return) {
|
|
22
|
+
submittedRef.current = true;
|
|
23
|
+
if (selected === "accept") {
|
|
24
|
+
onAccept();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
onReject();
|
|
28
|
+
}
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (isEscapeInput(input, key)) {
|
|
32
|
+
submittedRef.current = true;
|
|
33
|
+
onReject();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (key.leftArrow || key.rightArrow || key.tab) {
|
|
37
|
+
setSelected((s) => (s === "accept" ? "reject" : "accept"));
|
|
38
|
+
}
|
|
39
|
+
}, { isActive: isRawModeSupported });
|
|
40
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.colors.warning, paddingX: 2, paddingY: 1, children: [_jsxs(Text, { bold: true, color: theme.colors.warning, children: [" ", "Connection Request", " "] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { bold: true, children: request.displayNameSnapshot ?? request.nodeId }), " wants to connect"] }) }), _jsx(Box, { children: _jsxs(Text, { dimColor: true, children: ["Fingerprint: ", formatFp(request.principalFingerprint)] }) }), _jsxs(Box, { marginTop: 1, gap: 2, children: [_jsxs(Text, { inverse: selected === "accept", color: selected === "accept" ? theme.colors.success : undefined, children: [" ", "Accept", " "] }), _jsxs(Text, { inverse: selected === "reject", color: selected === "reject" ? theme.colors.error : undefined, children: [" ", "Reject", " "] })] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "\u2190\u2192 select \u23CE confirm esc reject" }) })] }));
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=PairRequestOverlay.js.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* AirDrop-style peer selection overlay.
|
|
4
|
+
*
|
|
5
|
+
* Shows nearby ARIA instances discovered via mDNS/Bonjour.
|
|
6
|
+
* User navigates with arrow keys, presses Enter to initiate pairing.
|
|
7
|
+
*/
|
|
8
|
+
import { useState, useEffect, useMemo } from "react";
|
|
9
|
+
import { Box, Text, useInput } from "ink";
|
|
10
|
+
import { getTheme } from "../../theme/index.js";
|
|
11
|
+
import { isEscapeInput } from "../../utils/keys.js";
|
|
12
|
+
function peerMatchesFilter(peer, filter) {
|
|
13
|
+
const normalizedFilter = filter.trim().toLowerCase();
|
|
14
|
+
if (!normalizedFilter) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
const searchFields = [
|
|
18
|
+
peer.displayNameSnapshot,
|
|
19
|
+
peer.nodeId,
|
|
20
|
+
peer.host,
|
|
21
|
+
peer.port?.toString(),
|
|
22
|
+
peer.principalFingerprint,
|
|
23
|
+
peer.transport,
|
|
24
|
+
peer.status,
|
|
25
|
+
]
|
|
26
|
+
.filter((value) => typeof value === "string" && value.length > 0)
|
|
27
|
+
.map((value) => value.toLowerCase());
|
|
28
|
+
return searchFields.some((field) => field.includes(normalizedFilter));
|
|
29
|
+
}
|
|
30
|
+
function clampSelectedIndex(index, length) {
|
|
31
|
+
if (length <= 0) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
return Math.min(index, length - 1);
|
|
35
|
+
}
|
|
36
|
+
export function PeerSelector({ peers, sameHomeClientsAvailable = false, onSelect, onCancel, }) {
|
|
37
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
38
|
+
const [filter, setFilter] = useState("");
|
|
39
|
+
const theme = getTheme();
|
|
40
|
+
const filteredPeers = useMemo(() => peers.filter((peer) => peerMatchesFilter(peer, filter)), [peers, filter]);
|
|
41
|
+
// Clamp index when peer list changes
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
setSelectedIndex((i) => clampSelectedIndex(i, filteredPeers.length));
|
|
44
|
+
}, [filteredPeers.length]);
|
|
45
|
+
const safeIndex = clampSelectedIndex(selectedIndex, filteredPeers.length);
|
|
46
|
+
const isRawModeSupported = process.stdin.isTTY ?? false;
|
|
47
|
+
useInput((input, key) => {
|
|
48
|
+
if (isEscapeInput(input, key)) {
|
|
49
|
+
onCancel();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (key.return) {
|
|
53
|
+
if (filteredPeers.length > 0) {
|
|
54
|
+
onSelect(filteredPeers[safeIndex]);
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (key.upArrow) {
|
|
59
|
+
setSelectedIndex((i) => Math.max(0, i - 1));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (key.downArrow) {
|
|
63
|
+
setSelectedIndex((i) => clampSelectedIndex(i + 1, filteredPeers.length));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (key.backspace || key.delete) {
|
|
67
|
+
setFilter((current) => current.slice(0, -1));
|
|
68
|
+
setSelectedIndex(0);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (input && !key.ctrl && !key.meta) {
|
|
72
|
+
setFilter((current) => current + input);
|
|
73
|
+
setSelectedIndex(0);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}, { isActive: isRawModeSupported });
|
|
77
|
+
const formatFp = (fp) => `${fp.slice(0, 4)} ${fp.slice(4, 8)} ${fp.slice(8, 12)} ${fp.slice(12, 16)}`;
|
|
78
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.colors.secondary, paddingX: 1, children: [_jsxs(Text, { bold: true, color: theme.colors.primary, children: [" ", "Nearby Peers", " "] }), filter ? _jsxs(Text, { dimColor: true, children: [" (filter: \"", filter, "\")"] }) : null, filteredPeers.length === 0 && (_jsx(Text, { dimColor: true, children: filter
|
|
79
|
+
? "No peers match your filter."
|
|
80
|
+
: sameHomeClientsAvailable
|
|
81
|
+
? "No peer nodes. Use /clients for same-home terminals."
|
|
82
|
+
: "Scanning... no peers found yet" })), filteredPeers.map((peer, i) => (_jsxs(Box, { children: [_jsxs(Text, { inverse: i === safeIndex, color: i === safeIndex ? theme.colors.primary : undefined, children: [i === safeIndex ? " ▸ " : " ", peer.displayNameSnapshot] }), peer.status === "connected" ? (_jsx(Text, { color: "green", children: " \u2713 connected" })) : (_jsxs(Text, { dimColor: true, children: [" ", peer.host, ":", peer.port] })), peer.principalFingerprint ? (_jsxs(Text, { color: theme.colors.secondary, children: [" ", formatFp(peer.principalFingerprint)] })) : null] }, `${peer.displayNameSnapshot}-${peer.nodeId}-${i}`))), _jsx(Box, { marginTop: filteredPeers.length > 0 ? 1 : 0, children: _jsx(Text, { dimColor: true, children: "type to search \u2191\u2193 navigate \u23CE connect esc cancel" }) })] }));
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=PeerSelector.js.map
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// packages/cli/src/ui/components/overlays/SessionSelector.tsx
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
|
+
import { Box, Text, useInput } from "ink";
|
|
5
|
+
import { isEscapeInput } from "../../utils/keys.js";
|
|
6
|
+
import { useTerminalSize } from "../../hooks/useTerminalSize.js";
|
|
7
|
+
function formatRelativeTime(date) {
|
|
8
|
+
const now = Date.now();
|
|
9
|
+
const diff = now - date.getTime();
|
|
10
|
+
const minutes = Math.floor(diff / 60000);
|
|
11
|
+
const hours = Math.floor(diff / 3600000);
|
|
12
|
+
const days = Math.floor(diff / 86400000);
|
|
13
|
+
if (minutes < 1)
|
|
14
|
+
return "just now";
|
|
15
|
+
if (minutes < 60)
|
|
16
|
+
return `${minutes}m ago`;
|
|
17
|
+
if (hours < 24)
|
|
18
|
+
return `${hours}h ago`;
|
|
19
|
+
if (days < 7)
|
|
20
|
+
return `${days}d ago`;
|
|
21
|
+
return date.toLocaleDateString();
|
|
22
|
+
}
|
|
23
|
+
export function SessionSelector({ sessions, onSelect, onCancel, onSearch, onPageChange, }) {
|
|
24
|
+
const { columns } = useTerminalSize();
|
|
25
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
26
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
27
|
+
const [page, setPage] = useState(0);
|
|
28
|
+
const pageSize = 8;
|
|
29
|
+
const totalPages = Math.max(1, Math.ceil(sessions.length / pageSize));
|
|
30
|
+
const pageItems = sessions.slice(page * pageSize, (page + 1) * pageSize);
|
|
31
|
+
// Clamp selection when sessions change
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
setSelectedIndex((i) => Math.min(i, Math.max(0, pageItems.length - 1)));
|
|
34
|
+
}, [pageItems.length]);
|
|
35
|
+
// Clamp page when session list size changes
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setPage((p) => Math.min(p, Math.max(0, totalPages - 1)));
|
|
38
|
+
}, [totalPages]);
|
|
39
|
+
// Safe index that's always in bounds (sync guard against async useEffect lag)
|
|
40
|
+
const safeIndex = pageItems.length > 0 ? Math.min(selectedIndex, pageItems.length - 1) : 0;
|
|
41
|
+
// Only use input handling when stdin supports raw mode
|
|
42
|
+
const isRawModeSupported = process.stdin.isTTY ?? false;
|
|
43
|
+
useInput((input, key) => {
|
|
44
|
+
if (isEscapeInput(input, key)) {
|
|
45
|
+
onCancel();
|
|
46
|
+
}
|
|
47
|
+
else if (key.return && pageItems.length > 0) {
|
|
48
|
+
onSelect(pageItems[safeIndex].id);
|
|
49
|
+
}
|
|
50
|
+
else if (key.upArrow) {
|
|
51
|
+
setSelectedIndex((i) => Math.max(0, i - 1));
|
|
52
|
+
}
|
|
53
|
+
else if (key.downArrow) {
|
|
54
|
+
setSelectedIndex((i) => Math.min(pageItems.length - 1, i + 1));
|
|
55
|
+
}
|
|
56
|
+
else if (key.leftArrow && page > 0) {
|
|
57
|
+
setPage((p) => p - 1);
|
|
58
|
+
setSelectedIndex(0);
|
|
59
|
+
}
|
|
60
|
+
else if (key.leftArrow && page === 0) {
|
|
61
|
+
onPageChange?.("prev");
|
|
62
|
+
setSelectedIndex(0);
|
|
63
|
+
}
|
|
64
|
+
else if (key.rightArrow && page < totalPages - 1) {
|
|
65
|
+
setPage((p) => p + 1);
|
|
66
|
+
setSelectedIndex(0);
|
|
67
|
+
}
|
|
68
|
+
else if (key.rightArrow && page === totalPages - 1) {
|
|
69
|
+
onPageChange?.("next");
|
|
70
|
+
setSelectedIndex(0);
|
|
71
|
+
}
|
|
72
|
+
else if (key.backspace || key.delete) {
|
|
73
|
+
const next = searchQuery.slice(0, -1);
|
|
74
|
+
setSearchQuery(next);
|
|
75
|
+
setPage(0);
|
|
76
|
+
setSelectedIndex(0);
|
|
77
|
+
onSearch(next);
|
|
78
|
+
}
|
|
79
|
+
else if (input && !key.ctrl && !key.meta) {
|
|
80
|
+
const next = searchQuery + input;
|
|
81
|
+
setSearchQuery(next);
|
|
82
|
+
setPage(0);
|
|
83
|
+
setSelectedIndex(0);
|
|
84
|
+
onSearch(next);
|
|
85
|
+
}
|
|
86
|
+
}, { isActive: isRawModeSupported });
|
|
87
|
+
function truncate(str, len) {
|
|
88
|
+
if (str.length <= len)
|
|
89
|
+
return str;
|
|
90
|
+
return str.slice(0, len - 3) + "...";
|
|
91
|
+
}
|
|
92
|
+
// Use available terminal width so session titles don't feel artificially clipped.
|
|
93
|
+
const titleMaxLen = Math.max(30, Math.min(120, columns - 28));
|
|
94
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { bold: true, color: "cyan", children: "Sessions" }), searchQuery && _jsxs(Text, { dimColor: true, children: [" (filter: \"", searchQuery, "\")"] }), _jsxs(Text, { dimColor: true, children: [" - ", sessions.length, " sessions"] })] }), sessions.length === 0 ? (_jsx(Text, { dimColor: true, children: searchQuery ? "No sessions match your filter." : "No sessions yet." })) : (pageItems.map((session, index) => {
|
|
95
|
+
const isSelected = index === safeIndex;
|
|
96
|
+
const timeStr = formatRelativeTime(session.updatedAt);
|
|
97
|
+
const title = session.title ?? session.preview ?? "Untitled session";
|
|
98
|
+
const globalIndex = page * pageSize + index;
|
|
99
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: index < pageItems.length - 1 ? 1 : 0, children: [_jsxs(Box, { flexDirection: "row", children: [_jsxs(Text, { inverse: isSelected, children: [isSelected ? ">" : " ", " ", globalIndex + 1, ". ", truncate(title, titleMaxLen)] }), _jsxs(Text, { dimColor: true, children: [" [", timeStr, "]"] })] }), _jsxs(Text, { dimColor: true, children: [" ", session.arion, " | ", session.model, " | ", session.messageCount, " messages"] })] }, session.id));
|
|
100
|
+
})), sessions.length > 0 && totalPages > 1 && (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { dimColor: true, children: ["Page ", page + 1, "/", totalPages] }) })), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "type to search arrows navigate enter resume esc cancel" }) })] }));
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=SessionSelector.js.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback } from "react";
|
|
3
|
+
import { Box, Text, useInput } from "ink";
|
|
4
|
+
import { isEscapeInput } from "../../utils/keys.js";
|
|
5
|
+
import { getTheme } from "../../theme/index.js";
|
|
6
|
+
import * as sounds from "../../../sounds.js";
|
|
7
|
+
import { loadConfig, saveConfig } from "../../../config.js";
|
|
8
|
+
const SOUND_OPTIONS = [
|
|
9
|
+
{
|
|
10
|
+
id: "toggle",
|
|
11
|
+
label: "Toggle sounds",
|
|
12
|
+
description: "Turn sound notifications on or off",
|
|
13
|
+
icon: "🔊",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "preview",
|
|
17
|
+
label: "Preview sound",
|
|
18
|
+
description: "Play a sample notification sound",
|
|
19
|
+
icon: "▶",
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
export function SoundSelector({ onClose }) {
|
|
23
|
+
const theme = getTheme();
|
|
24
|
+
const c = theme.colors;
|
|
25
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
26
|
+
const [enabled, setEnabled] = useState(sounds.isEnabled());
|
|
27
|
+
const [previewState, setPreviewState] = useState("idle");
|
|
28
|
+
const handleToggle = useCallback(() => {
|
|
29
|
+
const next = !enabled;
|
|
30
|
+
sounds.setEnabled(next);
|
|
31
|
+
const cfg = loadConfig();
|
|
32
|
+
cfg.soundEnabled = next;
|
|
33
|
+
saveConfig(cfg);
|
|
34
|
+
setEnabled(next);
|
|
35
|
+
if (next) {
|
|
36
|
+
// Play a sound to confirm
|
|
37
|
+
sounds.onSessionStart();
|
|
38
|
+
}
|
|
39
|
+
}, [enabled]);
|
|
40
|
+
const handlePreview = useCallback(() => {
|
|
41
|
+
const previous = enabled;
|
|
42
|
+
if (!previous) {
|
|
43
|
+
sounds.setEnabled(true);
|
|
44
|
+
}
|
|
45
|
+
const played = sounds.previewSound();
|
|
46
|
+
if (!previous) {
|
|
47
|
+
sounds.setEnabled(false);
|
|
48
|
+
}
|
|
49
|
+
setPreviewState(played ? "playing" : "unavailable");
|
|
50
|
+
setTimeout(() => setPreviewState("idle"), 1500);
|
|
51
|
+
}, [enabled]);
|
|
52
|
+
const isRawModeSupported = process.stdin.isTTY ?? false;
|
|
53
|
+
useInput((input, key) => {
|
|
54
|
+
if (isEscapeInput(input, key)) {
|
|
55
|
+
onClose();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (key.upArrow) {
|
|
59
|
+
setSelectedIndex((i) => Math.max(0, i - 1));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (key.downArrow) {
|
|
63
|
+
setSelectedIndex((i) => Math.min(SOUND_OPTIONS.length - 1, i + 1));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (key.return) {
|
|
67
|
+
const option = SOUND_OPTIONS[selectedIndex];
|
|
68
|
+
if (option?.id === "toggle") {
|
|
69
|
+
handleToggle();
|
|
70
|
+
}
|
|
71
|
+
else if (option?.id === "preview") {
|
|
72
|
+
handlePreview();
|
|
73
|
+
}
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}, { isActive: isRawModeSupported });
|
|
77
|
+
const available = sounds.isSoundAvailable();
|
|
78
|
+
const hasAssets = sounds.hasSoundAssets();
|
|
79
|
+
const engineLabel = sounds.getPlaybackEngineLabel();
|
|
80
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: c.primary, paddingX: 1, children: [_jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { bold: true, color: c.primary, children: "🔔 Sound" }), _jsxs(Text, { color: c.textMuted, children: [" ", theme.symbols.arrow, " notification preferences"] })] }), _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsx(Text, { color: c.textMuted, children: "Status " }), hasAssets ? (_jsx(Text, { bold: true, color: enabled ? c.success : c.textMuted, children: enabled ? "● ON" : "○ OFF" })) : (_jsx(Text, { color: c.warning, children: "\u26A0 Sound files not found" }))] }), _jsxs(Box, { children: [_jsx(Text, { color: c.textMuted, children: "Engine " }), _jsx(Text, { color: available ? c.text : c.warning, children: engineLabel })] }), _jsxs(Box, { children: [_jsx(Text, { color: c.textMuted, children: "Assets " }), _jsx(Text, { color: hasAssets ? c.text : c.warning, children: hasAssets ? "Warcraft II pack found" : "missing" })] })] }), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: c.border, children: "─".repeat(40) }) }), _jsx(Box, { flexDirection: "column", children: SOUND_OPTIONS.map((option, i) => {
|
|
81
|
+
const isHighlighted = i === selectedIndex;
|
|
82
|
+
const isToggle = option.id === "toggle";
|
|
83
|
+
return (_jsxs(Box, { paddingX: 1, children: [_jsxs(Text, { inverse: isHighlighted, color: isHighlighted ? c.primary : c.text, children: [option.icon, " ", isToggle ? (enabled ? "Turn off" : "Turn on") : option.label] }), isToggle && isHighlighted && (_jsxs(Text, { color: c.textMuted, children: [" ", enabled ? "→ disable notifications" : "→ enable notifications"] })), option.id === "preview" && previewState === "playing" && (_jsx(Text, { color: c.success, children: " \u266A playing..." })), option.id === "preview" && previewState === "unavailable" && (_jsx(Text, { color: c.warning, children: " \u26A0 preview unavailable" }))] }, option.id));
|
|
84
|
+
}) }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: c.textMuted, children: ["↑↓", " navigate ", "⏎", " select ", "esc", " close"] }) })] }));
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=SoundSelector.js.map
|