@aria-cli/cli 1.0.51 → 1.0.54
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 +569 -569
- package/package.json +14 -73
- package/dist/.tsbuildinfo +0 -1
- package/dist/attached-local-control-client.js +0 -826
- package/dist/bootstrap-local-control-client.js +0 -2
- package/dist/capability-aware-method-proxy.js +0 -42
- package/dist/cli-context.js +0 -160
- package/dist/commands/arions.js +0 -174
- package/dist/commands/auth.js +0 -123
- package/dist/commands/daemon.js +0 -245
- package/dist/commands/definitions.js +0 -176
- package/dist/commands/index.js +0 -74
- package/dist/commands/login-handler.js +0 -1108
- package/dist/commands/logout-handler.js +0 -92
- package/dist/commands/memory-handlers.js +0 -89
- package/dist/commands/pairing.js +0 -60
- package/dist/commands/runtime-cutover-reset-command.js +0 -12
- package/dist/commands/runtime-cutover-reset.js +0 -265
- package/dist/commands/terminal-setup.js +0 -84
- package/dist/config/aria-config.js +0 -238
- package/dist/config/index.js +0 -3
- package/dist/config/loader.js +0 -97
- package/dist/config.js +0 -142
- package/dist/daemon-info.js +0 -10
- package/dist/ensure-daemon.js +0 -128
- package/dist/entrypoints/command-mode.js +0 -5
- package/dist/entrypoints/daemon.js +0 -50
- package/dist/entrypoints/headless-stdio.js +0 -25
- package/dist/entrypoints/interactive.js +0 -80
- package/dist/event-loop-watchdog.js +0 -73
- package/dist/headless/auth-orchestrator.js +0 -508
- package/dist/headless/auth-service.js +0 -43
- package/dist/headless/bootstrap-fast-path.js +0 -112
- package/dist/headless/call-command.js +0 -143
- package/dist/headless/daemon-service.js +0 -318
- package/dist/headless/hook-actions.js +0 -235
- package/dist/headless/hook-service.js +0 -42
- package/dist/headless/kernel-services.js +0 -216
- package/dist/headless/kernel.js +0 -785
- package/dist/headless/operations/arion.js +0 -119
- package/dist/headless/operations/auth.js +0 -45
- package/dist/headless/operations/client.js +0 -31
- package/dist/headless/operations/config.js +0 -69
- package/dist/headless/operations/daemon.js +0 -47
- package/dist/headless/operations/hook.js +0 -56
- package/dist/headless/operations/index.js +0 -11
- package/dist/headless/operations/memory.js +0 -102
- package/dist/headless/operations/message.js +0 -279
- package/dist/headless/operations/model.js +0 -100
- package/dist/headless/operations/peer.js +0 -56
- package/dist/headless/operations/run.js +0 -24
- package/dist/headless/operations/session.js +0 -90
- package/dist/headless/operations/system.js +0 -19
- package/dist/headless/operations/utils.js +0 -35
- package/dist/headless/run-orchestrator.js +0 -703
- package/dist/headless/stdio-server.js +0 -439
- package/dist/history/SessionHistory.js +0 -8
- package/dist/history/SessionHistoryClient.js +0 -186
- package/dist/history/conversation-message.js +0 -112
- package/dist/history/index.js +0 -8
- package/dist/history/jsonl-replay.js +0 -154
- package/dist/history/repair-tool-pairing.js +0 -84
- package/dist/history/stall-phase-bridge.js +0 -11
- package/dist/history/turn-accumulator.js +0 -427
- package/dist/index.js +0 -7
- package/dist/ink-repl.js +0 -4183
- package/dist/local-control-bootstrap.js +0 -26
- package/dist/local-control-client.js +0 -2
- package/dist/local-control-error-reporting.js +0 -34
- package/dist/local-control-http-client.js +0 -362
- package/dist/local-control-lazy-wrapper.js +0 -363
- package/dist/local-control-manager.js +0 -146
- package/dist/main.js +0 -38
- package/dist/network-security.js +0 -62
- package/dist/networking-server.js +0 -38
- package/dist/peer-identity.js +0 -23
- package/dist/polling-subscription.js +0 -34
- package/dist/relaunch.js +0 -588
- package/dist/release-notes.js +0 -35
- package/dist/repl-cleanup.js +0 -47
- package/dist/runtime/configure-bun-sqlite.js +0 -3
- package/dist/runtime/crash-handlers.js +0 -111
- package/dist/runtime/interactive-invocation.js +0 -39
- package/dist/runtime/internal-mode.js +0 -14
- package/dist/runtime/launch-spec.js +0 -64
- package/dist/runtime/owner-lease.js +0 -44
- package/dist/runtime/public-mode.js +0 -20
- package/dist/runtime/run-internal-mode.js +0 -18
- package/dist/runtime/runtime-kind.js +0 -32
- package/dist/runtime/spawn-aria.js +0 -38
- package/dist/selectable-client.js +0 -2
- package/dist/selectable-peer.js +0 -2
- package/dist/session.js +0 -203
- package/dist/slash-commands.js +0 -80
- package/dist/sounds.js +0 -210
- package/dist/ui/App.js +0 -526
- package/dist/ui/components/AnthropicMethodPicker.js +0 -6
- package/dist/ui/components/ArionPrompt.js +0 -15
- package/dist/ui/components/AutocompleteDropdown.js +0 -23
- package/dist/ui/components/AutonomySelector.js +0 -55
- package/dist/ui/components/Banner.js +0 -98
- package/dist/ui/components/ConversationHistory.js +0 -175
- package/dist/ui/components/CopilotDeviceLoginFlow.js +0 -88
- package/dist/ui/components/CopilotSourcePicker.js +0 -50
- package/dist/ui/components/Cost.js +0 -10
- package/dist/ui/components/CustomSelect/option-map.js +0 -30
- package/dist/ui/components/CustomSelect/select-option.js +0 -13
- package/dist/ui/components/CustomSelect/select.js +0 -42
- package/dist/ui/components/CustomSelect/use-select-state.js +0 -179
- package/dist/ui/components/CustomSelect/use-select.js +0 -15
- package/dist/ui/components/ErrorDisplay.js +0 -35
- package/dist/ui/components/FallbackToolUseRejectedMessage.js +0 -7
- package/dist/ui/components/FileEditToolUpdatedMessage.js +0 -57
- package/dist/ui/components/HandoffMarker.js +0 -18
- package/dist/ui/components/HighlightedCode.js +0 -21
- package/dist/ui/components/InputArea.js +0 -187
- package/dist/ui/components/Message.js +0 -25
- package/dist/ui/components/OAuthLoginFlow.js +0 -113
- package/dist/ui/components/OutputTruncation.js +0 -35
- package/dist/ui/components/PermissionPrompt.js +0 -79
- package/dist/ui/components/PipelineTimingPanel.js +0 -15
- package/dist/ui/components/ProviderMethodPicker.js +0 -61
- package/dist/ui/components/ProviderPicker.js +0 -63
- package/dist/ui/components/RenderItemView.js +0 -71
- package/dist/ui/components/Spinner.js +0 -46
- package/dist/ui/components/StatusBar.js +0 -95
- package/dist/ui/components/StreamingIndicator.js +0 -55
- package/dist/ui/components/StructuredDiff.js +0 -168
- package/dist/ui/components/TextInputOverlay.js +0 -43
- package/dist/ui/components/ThinkingBlock.js +0 -82
- package/dist/ui/components/ToolCost.js +0 -17
- package/dist/ui/components/ToolExecution.js +0 -61
- package/dist/ui/components/ToolHeader.js +0 -51
- package/dist/ui/components/ToolRenderLayoutContext.js +0 -14
- package/dist/ui/components/ToolResultWrapper.js +0 -6
- package/dist/ui/components/ToolUseLoader.js +0 -35
- package/dist/ui/components/TraceWaterfall.js +0 -91
- package/dist/ui/components/index.js +0 -33
- package/dist/ui/components/messages/AssistantTextMessage.js +0 -25
- package/dist/ui/components/messages/UserImageMessage.js +0 -12
- package/dist/ui/components/messages/UserTextMessage.js +0 -12
- package/dist/ui/components/overlays/ArionSelector.js +0 -68
- package/dist/ui/components/overlays/ClientSelector.js +0 -62
- package/dist/ui/components/overlays/CommandPalette.js +0 -67
- package/dist/ui/components/overlays/DaemonControl.js +0 -87
- package/dist/ui/components/overlays/InviteShareOverlay.js +0 -15
- package/dist/ui/components/overlays/JoinInviteOverlay.js +0 -32
- package/dist/ui/components/overlays/MemoryBrowser.js +0 -100
- package/dist/ui/components/overlays/MessageSelector.js +0 -123
- package/dist/ui/components/overlays/ModelSelector.js +0 -211
- package/dist/ui/components/overlays/PairRequestOverlay.js +0 -42
- package/dist/ui/components/overlays/PeerSelector.js +0 -84
- package/dist/ui/components/overlays/SessionSelector.js +0 -102
- package/dist/ui/components/overlays/SoundSelector.js +0 -86
- package/dist/ui/components/overlays/ThemeSelector.js +0 -139
- package/dist/ui/components/overlays/index.js +0 -15
- package/dist/ui/components/permissions/BashPermissionRequest/BashPermissionRequest.js +0 -53
- package/dist/ui/components/permissions/FallbackPermissionRequest.js +0 -56
- package/dist/ui/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.js +0 -76
- package/dist/ui/components/permissions/FileEditPermissionRequest/FileEditToolDiff.js +0 -18
- package/dist/ui/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.js +0 -64
- package/dist/ui/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.js +0 -26
- package/dist/ui/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js +0 -141
- package/dist/ui/components/permissions/PermissionRequest.js +0 -70
- package/dist/ui/components/permissions/PermissionRequestTitle.js +0 -41
- package/dist/ui/components/permissions/hooks.js +0 -10
- package/dist/ui/components/permissions/toolUseOptions.js +0 -68
- package/dist/ui/components/permissions/utils.js +0 -10
- package/dist/ui/components/text-input/Cursor.js +0 -326
- package/dist/ui/components/text-input/TextInput.js +0 -231
- package/dist/ui/components/text-input/imagePaste.js +0 -28
- package/dist/ui/components/text-input/index.js +0 -6
- package/dist/ui/components/text-input/useDoublePress.js +0 -30
- package/dist/ui/components/text-input/useTextInput.js +0 -245
- package/dist/ui/components/tool-types.js +0 -9
- package/dist/ui/constants/figures.js +0 -4
- package/dist/ui/constants/index.js +0 -3
- package/dist/ui/display-mode.js +0 -93
- package/dist/ui/display-policy.js +0 -19
- package/dist/ui/hooks/index.js +0 -6
- package/dist/ui/hooks/useCommandAutocomplete.js +0 -93
- package/dist/ui/hooks/useDoublePress.js +0 -37
- package/dist/ui/hooks/useIndicatorState.js +0 -55
- package/dist/ui/hooks/useInterval.js +0 -23
- package/dist/ui/hooks/useKeyboardShortcuts.js +0 -127
- package/dist/ui/hooks/useTerminalSize.js +0 -55
- package/dist/ui/hooks/useUnifiedMessages.js +0 -117
- package/dist/ui/indicator-state.js +0 -44
- package/dist/ui/markdown/highlight.js +0 -44
- package/dist/ui/markdown/index.js +0 -1460
- package/dist/ui/markdown/tokenizer.js +0 -24
- package/dist/ui/render-item.js +0 -5
- package/dist/ui/screens/REPL.js +0 -119
- package/dist/ui/screens/approval-lifecycle.js +0 -38
- package/dist/ui/status-line.js +0 -72
- package/dist/ui/theme/index.js +0 -51
- package/dist/ui/theme/themes/claude-dark-daltonized.js +0 -51
- package/dist/ui/theme/themes/claude-dark.js +0 -50
- package/dist/ui/theme/themes/claude-light-daltonized.js +0 -51
- package/dist/ui/theme/themes/claude-light.js +0 -50
- package/dist/ui/theme/themes/dark-accessible.js +0 -18
- package/dist/ui/theme/themes/dark.js +0 -49
- package/dist/ui/theme/themes/light-accessible.js +0 -18
- package/dist/ui/theme/themes/light.js +0 -49
- package/dist/ui/theme/types.js +0 -3
- package/dist/ui/theme.js +0 -142
- package/dist/ui/to-render-items.js +0 -145
- package/dist/ui/tools/AgentTool/index.js +0 -30
- package/dist/ui/tools/ArchitectTool/index.js +0 -31
- package/dist/ui/tools/AskUserTool/index.js +0 -46
- package/dist/ui/tools/BashTool/BashToolResultMessage.js +0 -11
- package/dist/ui/tools/BashTool/OutputLine.js +0 -21
- package/dist/ui/tools/BashTool/index.js +0 -91
- package/dist/ui/tools/BrowseTool/index.js +0 -43
- package/dist/ui/tools/BrowserTool/index.js +0 -47
- package/dist/ui/tools/CbmTool/index.js +0 -188
- package/dist/ui/tools/CheckDelegationTool/index.js +0 -46
- package/dist/ui/tools/CheckMessagesTool/index.js +0 -85
- package/dist/ui/tools/CreateQuipTool/index.js +0 -30
- package/dist/ui/tools/CreateSkillTool/index.js +0 -22
- package/dist/ui/tools/CreateToolTool/index.js +0 -31
- package/dist/ui/tools/DelegateRemoteTool/index.js +0 -42
- package/dist/ui/tools/DeployTool/index.js +0 -47
- package/dist/ui/tools/FffTool/index.js +0 -103
- package/dist/ui/tools/FileEditTool/index.js +0 -67
- package/dist/ui/tools/FileReadTool/index.js +0 -68
- package/dist/ui/tools/FileWriteTool/index.js +0 -61
- package/dist/ui/tools/ForkTool/index.js +0 -47
- package/dist/ui/tools/FrgTool/index.js +0 -96
- package/dist/ui/tools/GetThreadTool/index.js +0 -39
- package/dist/ui/tools/GlobTool/index.js +0 -50
- package/dist/ui/tools/GrepTool/index.js +0 -84
- package/dist/ui/tools/HatchArionTool/index.js +0 -36
- package/dist/ui/tools/LearnSkillTool/index.js +0 -22
- package/dist/ui/tools/LearnTool/index.js +0 -43
- package/dist/ui/tools/LearnToolTool/index.js +0 -22
- package/dist/ui/tools/ListClientsTool/index.js +0 -39
- package/dist/ui/tools/LspTool/index.js +0 -261
- package/dist/ui/tools/MCPTool/index.js +0 -33
- package/dist/ui/tools/ManageNetworkTool/index.js +0 -53
- package/dist/ui/tools/MemoryReadTool/index.js +0 -64
- package/dist/ui/tools/MemoryWriteTool/index.js +0 -20
- package/dist/ui/tools/NotebookEditTool/index.js +0 -33
- package/dist/ui/tools/NotebookReadTool/index.js +0 -25
- package/dist/ui/tools/OutlookReadTool/index.js +0 -66
- package/dist/ui/tools/OutlookReplyTool/index.js +0 -49
- package/dist/ui/tools/OutlookSendTool/index.js +0 -49
- package/dist/ui/tools/PauseDelegationTool/index.js +0 -35
- package/dist/ui/tools/ProbeTool/index.js +0 -121
- package/dist/ui/tools/ProcessTool/index.js +0 -66
- package/dist/ui/tools/QuestListTool/index.js +0 -46
- package/dist/ui/tools/QuestReportTool/index.js +0 -49
- package/dist/ui/tools/QuestUpdateTool/index.js +0 -87
- package/dist/ui/tools/QuipCommentTool/index.js +0 -69
- package/dist/ui/tools/QuipReadTool/index.js +0 -71
- package/dist/ui/tools/RestArionTool/index.js +0 -32
- package/dist/ui/tools/RestartTool/index.js +0 -35
- package/dist/ui/tools/ResumeDelegationTool/index.js +0 -35
- package/dist/ui/tools/RetireArionTool/index.js +0 -32
- package/dist/ui/tools/RgTool/index.js +0 -73
- package/dist/ui/tools/SearchKnowledgeTool/index.js +0 -43
- package/dist/ui/tools/SearchMessagesTool/index.js +0 -43
- package/dist/ui/tools/SelfDiagnoseTool/index.js +0 -61
- package/dist/ui/tools/SendMessageTool/index.js +0 -45
- package/dist/ui/tools/SerenaTool/index.js +0 -124
- package/dist/ui/tools/SessionHistoryTool/index.js +0 -52
- package/dist/ui/tools/SgTool/index.js +0 -80
- package/dist/ui/tools/SlackReactTool/index.js +0 -41
- package/dist/ui/tools/SlackReadTool/index.js +0 -48
- package/dist/ui/tools/SlackSendTool/index.js +0 -45
- package/dist/ui/tools/SpawnWorkerTool/index.js +0 -33
- package/dist/ui/tools/StickerRequestTool/index.js +0 -19
- package/dist/ui/tools/ThinkTool/index.js +0 -17
- package/dist/ui/tools/UgTool/index.js +0 -108
- package/dist/ui/tools/UseSkillTool/index.js +0 -22
- package/dist/ui/tools/WakeArionTool/index.js +0 -32
- package/dist/ui/tools/WebFetchTool/index.js +0 -56
- package/dist/ui/tools/WebSearchTool/index.js +0 -44
- package/dist/ui/tools/lsTool/index.js +0 -58
- package/dist/ui/tools/registry.js +0 -197
- package/dist/ui/tools/tool-renderer.js +0 -11
- package/dist/ui/tools/truncation.js +0 -35
- package/dist/ui/types/anthropic.js +0 -4
- package/dist/ui/types/index.js +0 -2
- package/dist/ui/types/message.js +0 -3
- package/dist/ui/types/tool.js +0 -4
- package/dist/ui/utils/array.js +0 -4
- package/dist/ui/utils/cursor.js +0 -131
- package/dist/ui/utils/diff.js +0 -120
- package/dist/ui/utils/format.js +0 -42
- package/dist/ui/utils/fuzzy.js +0 -59
- package/dist/ui/utils/index.js +0 -11
- package/dist/ui/utils/keys.js +0 -8
- package/dist/ui/utils/patch.js +0 -17
- package/dist/ui/utils/risk.js +0 -114
- package/dist/ui/utils/terminal-image.js +0 -70
- package/dist/ui/utils/validation.js +0 -48
- package/dist/ui/verb-pairs.js +0 -248
- package/dist/ui.js +0 -131
- package/src/entrypoints/command-mode.ts +0 -5
- package/src/entrypoints/daemon.ts +0 -54
- package/src/entrypoints/headless-stdio.ts +0 -27
- package/src/entrypoints/interactive.ts +0 -112
- package/src/main.ts +0 -44
- package/src/runtime/configure-bun-sqlite.ts +0 -3
- package/src/runtime/crash-handlers.ts +0 -128
- package/src/runtime/interactive-invocation.test.ts +0 -42
- package/src/runtime/interactive-invocation.ts +0 -51
- package/src/runtime/internal-mode.test.ts +0 -19
- package/src/runtime/internal-mode.ts +0 -24
- package/src/runtime/launch-spec.test.ts +0 -26
- package/src/runtime/launch-spec.ts +0 -84
- package/src/runtime/owner-lease.ts +0 -52
- package/src/runtime/public-mode.test.ts +0 -18
- package/src/runtime/public-mode.ts +0 -19
- package/src/runtime/run-internal-mode.ts +0 -19
- package/src/runtime/runtime-kind.test.ts +0 -23
- package/src/runtime/runtime-kind.ts +0 -41
- package/src/runtime/spawn-aria.ts +0 -62
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
// Change: Option type from @inkjs/ui → imported from ./option-map.js
|
|
2
|
-
import { isDeepStrictEqual } from "node:util";
|
|
3
|
-
import { useReducer, useCallback, useMemo, useState, useEffect } from "react";
|
|
4
|
-
import OptionMap from "./option-map.js";
|
|
5
|
-
const reducer = (state, action) => {
|
|
6
|
-
switch (action.type) {
|
|
7
|
-
case "focus-next-option": {
|
|
8
|
-
if (!state.focusedValue) {
|
|
9
|
-
return state;
|
|
10
|
-
}
|
|
11
|
-
const item = state.optionMap.get(state.focusedValue);
|
|
12
|
-
if (!item) {
|
|
13
|
-
return state;
|
|
14
|
-
}
|
|
15
|
-
let next = item.next;
|
|
16
|
-
while (next && !("value" in next)) {
|
|
17
|
-
// Skip headers
|
|
18
|
-
next = next.next;
|
|
19
|
-
}
|
|
20
|
-
if (!next) {
|
|
21
|
-
return state;
|
|
22
|
-
}
|
|
23
|
-
const needsToScroll = next.index >= state.visibleToIndex;
|
|
24
|
-
if (!needsToScroll) {
|
|
25
|
-
return {
|
|
26
|
-
...state,
|
|
27
|
-
focusedValue: next.value,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
const nextVisibleToIndex = Math.min(state.optionMap.size, state.visibleToIndex + 1);
|
|
31
|
-
const nextVisibleFromIndex = nextVisibleToIndex - state.visibleOptionCount;
|
|
32
|
-
return {
|
|
33
|
-
...state,
|
|
34
|
-
focusedValue: next.value,
|
|
35
|
-
visibleFromIndex: nextVisibleFromIndex,
|
|
36
|
-
visibleToIndex: nextVisibleToIndex,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
case "focus-previous-option": {
|
|
40
|
-
if (!state.focusedValue) {
|
|
41
|
-
return state;
|
|
42
|
-
}
|
|
43
|
-
const item = state.optionMap.get(state.focusedValue);
|
|
44
|
-
if (!item) {
|
|
45
|
-
return state;
|
|
46
|
-
}
|
|
47
|
-
let previous = item.previous;
|
|
48
|
-
while (previous && !("value" in previous)) {
|
|
49
|
-
// Skip headers
|
|
50
|
-
previous = previous.previous;
|
|
51
|
-
}
|
|
52
|
-
if (!previous) {
|
|
53
|
-
return state;
|
|
54
|
-
}
|
|
55
|
-
const needsToScroll = previous.index <= state.visibleFromIndex;
|
|
56
|
-
if (!needsToScroll) {
|
|
57
|
-
return {
|
|
58
|
-
...state,
|
|
59
|
-
focusedValue: previous.value,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
const nextVisibleFromIndex = Math.max(0, state.visibleFromIndex - 1);
|
|
63
|
-
const nextVisibleToIndex = nextVisibleFromIndex + state.visibleOptionCount;
|
|
64
|
-
return {
|
|
65
|
-
...state,
|
|
66
|
-
focusedValue: previous.value,
|
|
67
|
-
visibleFromIndex: nextVisibleFromIndex,
|
|
68
|
-
visibleToIndex: nextVisibleToIndex,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
case "select-focused-option": {
|
|
72
|
-
return {
|
|
73
|
-
...state,
|
|
74
|
-
previousValue: state.value,
|
|
75
|
-
value: state.focusedValue,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
case "reset": {
|
|
79
|
-
return action.state;
|
|
80
|
-
}
|
|
81
|
-
case "set-focus": {
|
|
82
|
-
return {
|
|
83
|
-
...state,
|
|
84
|
-
focusedValue: action.value,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
const flattenOptions = (options) => options.flatMap((option) => {
|
|
90
|
-
if ("options" in option) {
|
|
91
|
-
const flatSubtree = flattenOptions(option.options);
|
|
92
|
-
const optionValues = flatSubtree.flatMap((o) => ("value" in o ? o.value : []));
|
|
93
|
-
const header = option.header !== undefined ? [{ header: option.header, optionValues }] : [];
|
|
94
|
-
return [...header, ...flatSubtree];
|
|
95
|
-
}
|
|
96
|
-
return option;
|
|
97
|
-
});
|
|
98
|
-
const createDefaultState = ({ visibleOptionCount: customVisibleOptionCount, defaultValue, options, }) => {
|
|
99
|
-
const flatOptions = flattenOptions(options);
|
|
100
|
-
const visibleOptionCount = typeof customVisibleOptionCount === "number"
|
|
101
|
-
? Math.min(customVisibleOptionCount, flatOptions.length)
|
|
102
|
-
: flatOptions.length;
|
|
103
|
-
const optionMap = new OptionMap(flatOptions);
|
|
104
|
-
const firstOption = optionMap.first;
|
|
105
|
-
const focusedValue = firstOption && "value" in firstOption ? firstOption.value : undefined;
|
|
106
|
-
return {
|
|
107
|
-
optionMap,
|
|
108
|
-
visibleOptionCount,
|
|
109
|
-
focusedValue,
|
|
110
|
-
visibleFromIndex: 0,
|
|
111
|
-
visibleToIndex: visibleOptionCount,
|
|
112
|
-
previousValue: defaultValue,
|
|
113
|
-
value: defaultValue,
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
export const useSelectState = ({ visibleOptionCount = 5, options, defaultValue, onChange, onFocus, focusValue, }) => {
|
|
117
|
-
const flatOptions = flattenOptions(options);
|
|
118
|
-
const [state, dispatch] = useReducer(reducer, { visibleOptionCount, defaultValue, options }, createDefaultState);
|
|
119
|
-
const [lastOptions, setLastOptions] = useState(flatOptions);
|
|
120
|
-
if (flatOptions !== lastOptions && !isDeepStrictEqual(flatOptions, lastOptions)) {
|
|
121
|
-
dispatch({
|
|
122
|
-
type: "reset",
|
|
123
|
-
state: createDefaultState({ visibleOptionCount, defaultValue, options }),
|
|
124
|
-
});
|
|
125
|
-
setLastOptions(flatOptions);
|
|
126
|
-
}
|
|
127
|
-
const focusNextOption = useCallback(() => {
|
|
128
|
-
dispatch({
|
|
129
|
-
type: "focus-next-option",
|
|
130
|
-
});
|
|
131
|
-
}, []);
|
|
132
|
-
const focusPreviousOption = useCallback(() => {
|
|
133
|
-
dispatch({
|
|
134
|
-
type: "focus-previous-option",
|
|
135
|
-
});
|
|
136
|
-
}, []);
|
|
137
|
-
const selectFocusedOption = useCallback(() => {
|
|
138
|
-
dispatch({
|
|
139
|
-
type: "select-focused-option",
|
|
140
|
-
});
|
|
141
|
-
}, []);
|
|
142
|
-
const visibleOptions = useMemo(() => {
|
|
143
|
-
return flatOptions
|
|
144
|
-
.map((option, index) => ({
|
|
145
|
-
...option,
|
|
146
|
-
index,
|
|
147
|
-
}))
|
|
148
|
-
.slice(state.visibleFromIndex, state.visibleToIndex);
|
|
149
|
-
}, [flatOptions, state.visibleFromIndex, state.visibleToIndex]);
|
|
150
|
-
useEffect(() => {
|
|
151
|
-
if (state.value && state.previousValue !== state.value) {
|
|
152
|
-
onChange?.(state.value);
|
|
153
|
-
}
|
|
154
|
-
}, [state.previousValue, state.value, options, onChange]);
|
|
155
|
-
useEffect(() => {
|
|
156
|
-
if (state.focusedValue) {
|
|
157
|
-
onFocus?.(state.focusedValue);
|
|
158
|
-
}
|
|
159
|
-
}, [state.focusedValue, onFocus]);
|
|
160
|
-
useEffect(() => {
|
|
161
|
-
if (focusValue) {
|
|
162
|
-
dispatch({
|
|
163
|
-
type: "set-focus",
|
|
164
|
-
value: focusValue,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}, [focusValue]);
|
|
168
|
-
return {
|
|
169
|
-
focusedValue: state.focusedValue,
|
|
170
|
-
visibleFromIndex: state.visibleFromIndex,
|
|
171
|
-
visibleToIndex: state.visibleToIndex,
|
|
172
|
-
value: state.value,
|
|
173
|
-
visibleOptions,
|
|
174
|
-
focusNextOption,
|
|
175
|
-
focusPreviousOption,
|
|
176
|
-
selectFocusedOption,
|
|
177
|
-
};
|
|
178
|
-
};
|
|
179
|
-
//# sourceMappingURL=use-select-state.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useInput } from "ink";
|
|
2
|
-
export const useSelect = ({ isDisabled = false, state }) => {
|
|
3
|
-
useInput((_input, key) => {
|
|
4
|
-
if (key.downArrow) {
|
|
5
|
-
state.focusNextOption();
|
|
6
|
-
}
|
|
7
|
-
if (key.upArrow) {
|
|
8
|
-
state.focusPreviousOption();
|
|
9
|
-
}
|
|
10
|
-
if (key.return) {
|
|
11
|
-
state.selectFocusedOption();
|
|
12
|
-
}
|
|
13
|
-
}, { isActive: !isDisabled });
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=use-select.js.map
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Text, useStdout } from "ink";
|
|
3
|
-
import { getTheme } from "../theme/index.js";
|
|
4
|
-
export function ErrorDisplay({ level, message, suggestion, title = "Error", }) {
|
|
5
|
-
const theme = getTheme();
|
|
6
|
-
const symbols = theme.symbols;
|
|
7
|
-
const colors = theme.colors;
|
|
8
|
-
const { stdout } = useStdout();
|
|
9
|
-
const width = stdout?.columns ?? 80;
|
|
10
|
-
switch (level) {
|
|
11
|
-
case "inline":
|
|
12
|
-
return (_jsxs(Text, { color: colors.error, children: [symbols.error, " ", message] }));
|
|
13
|
-
case "suggestion":
|
|
14
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: colors.error, children: [symbols.error, " ", message] }), suggestion && (_jsxs(Text, { color: colors.textMuted, children: [" ", symbols.arrow, " Did you mean \"", suggestion, "\"?"] }))] }));
|
|
15
|
-
case "boxed":
|
|
16
|
-
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: colors.error, paddingX: 1, width: width, children: [_jsxs(Text, { color: colors.error, bold: true, wrap: "wrap", children: [symbols.warning, " ", title] }), _jsx(Text, { wrap: "wrap", children: message }), suggestion && (_jsxs(Text, { color: colors.textMuted, wrap: "wrap", children: [symbols.arrow, " ", suggestion] }))] }));
|
|
17
|
-
case "fatal": {
|
|
18
|
-
const lineWidth = Math.max(1, width);
|
|
19
|
-
return (_jsxs(Box, { flexDirection: "column", width: width, children: [_jsx(Text, { color: colors.error, children: "═".repeat(lineWidth) }), _jsxs(Text, { color: colors.error, bold: true, wrap: "wrap", children: [" ", "\u26D4 FATAL: ", message] }), suggestion && (_jsxs(Text, { color: colors.textMuted, wrap: "wrap", children: [" ", suggestion] })), _jsx(Text, { color: colors.error, children: "═".repeat(lineWidth) })] }));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export function InlineError({ message }) {
|
|
24
|
-
return _jsx(ErrorDisplay, { level: "inline", message: message });
|
|
25
|
-
}
|
|
26
|
-
export function SuggestionError({ message, suggestion, }) {
|
|
27
|
-
return _jsx(ErrorDisplay, { level: "suggestion", message: message, suggestion: suggestion });
|
|
28
|
-
}
|
|
29
|
-
export function BoxedError({ message, title, suggestion, }) {
|
|
30
|
-
return _jsx(ErrorDisplay, { level: "boxed", message: message, title: title, suggestion: suggestion });
|
|
31
|
-
}
|
|
32
|
-
export function FatalError({ message, suggestion, }) {
|
|
33
|
-
return _jsx(ErrorDisplay, { level: "fatal", message: message, suggestion: suggestion });
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=ErrorDisplay.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getTheme } from "../theme/index.js";
|
|
3
|
-
import { Text } from "ink";
|
|
4
|
-
export function FallbackToolUseRejectedMessage() {
|
|
5
|
-
return (_jsxs(Text, { children: ["\u00A0\u00A0", "\u23BF", " \u00A0", _jsx(Text, { color: getTheme().colors.error, children: "No (tell ARIA what to do differently)" })] }));
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=FallbackToolUseRejectedMessage.js.map
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Text } from "ink";
|
|
3
|
-
import { StructuredDiff } from "./StructuredDiff.js";
|
|
4
|
-
import { getTheme } from "../theme/index.js";
|
|
5
|
-
import { useTerminalSize } from "../hooks/useTerminalSize.js";
|
|
6
|
-
function intersperse(as, separator) {
|
|
7
|
-
return as.flatMap((a, i) => (i ? [separator(i), a] : [a]));
|
|
8
|
-
}
|
|
9
|
-
const getCwd = () => process.cwd();
|
|
10
|
-
/** Convert a Hunk (from `diff` package) to ARIA's FileDiff format */
|
|
11
|
-
function hunkToFileDiff(hunk, filePath) {
|
|
12
|
-
const lines = [];
|
|
13
|
-
let oldLineNo = hunk.oldStart;
|
|
14
|
-
let newLineNo = hunk.newStart;
|
|
15
|
-
let additions = 0;
|
|
16
|
-
let deletions = 0;
|
|
17
|
-
for (const line of hunk.lines) {
|
|
18
|
-
const content = line.slice(1); // Remove +/- prefix
|
|
19
|
-
if (line.startsWith("+")) {
|
|
20
|
-
lines.push({ type: "added", content, newLineNo: newLineNo++ });
|
|
21
|
-
additions++;
|
|
22
|
-
}
|
|
23
|
-
else if (line.startsWith("-")) {
|
|
24
|
-
lines.push({ type: "removed", content, oldLineNo: oldLineNo++ });
|
|
25
|
-
deletions++;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
lines.push({ type: "unchanged", content, oldLineNo: oldLineNo++, newLineNo: newLineNo++ });
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
filePath,
|
|
33
|
-
hunks: [
|
|
34
|
-
{
|
|
35
|
-
oldStart: hunk.oldStart,
|
|
36
|
-
oldLines: hunk.oldLines,
|
|
37
|
-
newStart: hunk.newStart,
|
|
38
|
-
newLines: hunk.newLines,
|
|
39
|
-
lines,
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
additions,
|
|
43
|
-
deletions,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export function FileEditToolUpdatedMessage({ filePath, structuredPatch, verbose, }) {
|
|
47
|
-
const { columns } = useTerminalSize();
|
|
48
|
-
const numAdditions = structuredPatch.reduce((count, hunk) => count + hunk.lines.filter((_) => _.startsWith("+")).length, 0);
|
|
49
|
-
const numRemovals = structuredPatch.reduce((count, hunk) => count + hunk.lines.filter((_) => _.startsWith("-")).length, 0);
|
|
50
|
-
// Collect all diff lines across hunks to enforce a 3-line collapsed view
|
|
51
|
-
const allDiffLines = structuredPatch.flatMap((hunk) => hunk.lines.filter((l) => l.startsWith("+") || l.startsWith("-")));
|
|
52
|
-
const MAX_DIFF_LINES = 2; // 1 summary + 2 diff lines = 3 lines total
|
|
53
|
-
const showDiff = verbose || allDiffLines.length <= MAX_DIFF_LINES;
|
|
54
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [numAdditions > 0 ? (_jsxs(_Fragment, { children: ["Added ", _jsx(Text, { bold: true, children: numAdditions }), " ", numAdditions > 1 ? "lines" : "line"] })) : null, numAdditions > 0 && numRemovals > 0 ? ", " : null, numRemovals > 0 ? (_jsxs(_Fragment, { children: ["removed ", _jsx(Text, { bold: true, children: numRemovals }), " ", numRemovals > 1 ? "lines" : "line"] })) : null, !showDiff ? (_jsxs(Text, { color: getTheme().colors.textMuted, children: [" (", allDiffLines.length, " diff lines)"] })) : null] }), showDiff &&
|
|
55
|
-
intersperse(structuredPatch.map((_) => (_jsx(Box, { flexDirection: "column", paddingLeft: 5, children: _jsx(StructuredDiff, { diff: hunkToFileDiff(_, filePath), showHeader: false, dim: false, width: columns - 12 }) }, _.newStart))), (i) => (_jsx(Box, { paddingLeft: 5, children: _jsx(Text, { color: getTheme().colors.textMuted, children: "..." }) }, `ellipsis-${i}`)))] }));
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=FileEditToolUpdatedMessage.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Text } from "ink";
|
|
3
|
-
import { getTheme } from "../theme/index.js";
|
|
4
|
-
/**
|
|
5
|
-
* HandoffMarker displays a visual separator for arion handoff transitions.
|
|
6
|
-
*
|
|
7
|
-
* Outgoing:
|
|
8
|
-
* \u2192 Researcher
|
|
9
|
-
*
|
|
10
|
-
* Returning:
|
|
11
|
-
* \u2190 Researcher
|
|
12
|
-
*/
|
|
13
|
-
export function HandoffMarker({ target, direction }) {
|
|
14
|
-
const theme = getTheme();
|
|
15
|
-
const arrow = direction === "to" ? "\u2192" : "\u2190";
|
|
16
|
-
return (_jsx(Box, { children: _jsxs(Text, { color: theme.colors.warning, children: [arrow, " ", target] }) }));
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=HandoffMarker.js.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
// Substitution: logError → console.error
|
|
3
|
-
import { highlight, supportsLanguage } from "cli-highlight";
|
|
4
|
-
import { Text } from "ink";
|
|
5
|
-
import { useMemo } from "react";
|
|
6
|
-
export function HighlightedCode({ code, language }) {
|
|
7
|
-
const highlightedCode = useMemo(() => {
|
|
8
|
-
try {
|
|
9
|
-
if (language && supportsLanguage(language)) {
|
|
10
|
-
return highlight(code, { language });
|
|
11
|
-
}
|
|
12
|
-
// Silent fallback — no console.error (was leaking into terminal output)
|
|
13
|
-
return highlight(code, { language: "markdown" });
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
return code;
|
|
17
|
-
}
|
|
18
|
-
}, [code, language]);
|
|
19
|
-
return _jsx(Text, { children: highlightedCode });
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=HighlightedCode.js.map
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
-
import { Box, Text } from "ink";
|
|
4
|
-
import { TextInput } from "./text-input/index.js";
|
|
5
|
-
import { ArionPrompt } from "./ArionPrompt.js";
|
|
6
|
-
import { useTerminalSize } from "../hooks/useTerminalSize.js";
|
|
7
|
-
import { isShiftEnterKeyBindingInstalled, isTerminalSetupSupported, } from "../../commands/terminal-setup.js";
|
|
8
|
-
const PASTED_IMAGE_MIME_TYPE = "image/png";
|
|
9
|
-
const IMAGE_PLACEHOLDER = "[Image pasted]";
|
|
10
|
-
function toImageDataUri(base64Image) {
|
|
11
|
-
return `data:${PASTED_IMAGE_MIME_TYPE};base64,${base64Image}`;
|
|
12
|
-
}
|
|
13
|
-
export function InputArea({ userName, value, onChange, onSubmit, onTrigger, onExit, isStreaming = false, isDisabled = false, focus, history = [], onSaveInput, onDoubleEscape, }) {
|
|
14
|
-
const { columns } = useTerminalSize();
|
|
15
|
-
const textInputColumns = columns - 6; // 3 (prompt) + 2 (border) + 1 (padding)
|
|
16
|
-
const showShiftEnterHint = isTerminalSetupSupported() && isShiftEnterKeyBindingInstalled();
|
|
17
|
-
// History navigation state
|
|
18
|
-
const [historyIndex, setHistoryIndex] = useState(-1);
|
|
19
|
-
const [savedInput, setSavedInput] = useState("");
|
|
20
|
-
// Local history (session-scoped, most recent first)
|
|
21
|
-
const [localHistory, setLocalHistory] = useState(history);
|
|
22
|
-
// Cursor and paste state (matching PromptInput pattern)
|
|
23
|
-
const [cursorOffset, setCursorOffset] = useState(value.length);
|
|
24
|
-
const [pastedText, setPastedText] = useState(null);
|
|
25
|
-
const [pastedImage, setPastedImage] = useState(null);
|
|
26
|
-
const [exitMessage, setExitMessage] = useState({ show: false });
|
|
27
|
-
const [message, setMessage] = useState({ show: false });
|
|
28
|
-
// Refs for value/cursorOffset so that handleTextPaste (called asynchronously
|
|
29
|
-
// from a setTimeout+microtask) always reads the CURRENT state, not stale
|
|
30
|
-
// closure values from the render when the paste timer was scheduled.
|
|
31
|
-
const valueRef = useRef(value);
|
|
32
|
-
const cursorOffsetRef = useRef(cursorOffset);
|
|
33
|
-
const pastedTextRef = useRef(pastedText);
|
|
34
|
-
const pastedImageRef = useRef(pastedImage);
|
|
35
|
-
valueRef.current = value;
|
|
36
|
-
cursorOffsetRef.current = cursorOffset;
|
|
37
|
-
pastedTextRef.current = pastedText;
|
|
38
|
-
pastedImageRef.current = pastedImage;
|
|
39
|
-
// NOTE: Do not auto-sync cursorOffset with value.length!
|
|
40
|
-
// The TextInput component manages cursor position via onChangeCursorOffset.
|
|
41
|
-
// Auto-syncing here causes the cursor to jump to the end on every keystroke.
|
|
42
|
-
// Sync localHistory with incoming persistent history
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (history.length > 0) {
|
|
45
|
-
setLocalHistory((prev) => {
|
|
46
|
-
// Merge: persistent history items not already in local
|
|
47
|
-
const merged = [...prev];
|
|
48
|
-
for (const item of history) {
|
|
49
|
-
if (!merged.includes(item)) {
|
|
50
|
-
merged.push(item);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return merged.slice(0, 100);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}, [history]);
|
|
57
|
-
// Reset historyIndex when history becomes empty
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (localHistory.length === 0 && historyIndex >= 0) {
|
|
60
|
-
setHistoryIndex(-1);
|
|
61
|
-
}
|
|
62
|
-
}, [localHistory.length]);
|
|
63
|
-
// --- History navigation handlers (for TextInput callbacks) ---
|
|
64
|
-
const handleHistoryUp = useCallback(() => {
|
|
65
|
-
if (localHistory.length === 0)
|
|
66
|
-
return;
|
|
67
|
-
if (historyIndex === -1) {
|
|
68
|
-
setSavedInput(value);
|
|
69
|
-
}
|
|
70
|
-
const newIndex = Math.min(historyIndex + 1, localHistory.length - 1);
|
|
71
|
-
setHistoryIndex(newIndex);
|
|
72
|
-
if (newIndex >= 0 && newIndex < localHistory.length) {
|
|
73
|
-
const entry = localHistory[newIndex];
|
|
74
|
-
onChange(entry);
|
|
75
|
-
setCursorOffset(entry.length);
|
|
76
|
-
}
|
|
77
|
-
}, [localHistory, historyIndex, value, onChange]);
|
|
78
|
-
const handleHistoryDown = useCallback(() => {
|
|
79
|
-
if (historyIndex < 0)
|
|
80
|
-
return;
|
|
81
|
-
const newIndex = historyIndex - 1;
|
|
82
|
-
setHistoryIndex(newIndex);
|
|
83
|
-
if (newIndex === -1) {
|
|
84
|
-
onChange(savedInput);
|
|
85
|
-
setCursorOffset(savedInput.length);
|
|
86
|
-
}
|
|
87
|
-
else if (newIndex >= 0 && newIndex < localHistory.length) {
|
|
88
|
-
const entry = localHistory[newIndex];
|
|
89
|
-
onChange(entry);
|
|
90
|
-
setCursorOffset(entry.length);
|
|
91
|
-
}
|
|
92
|
-
else if (newIndex >= localHistory.length) {
|
|
93
|
-
// History shrank, reset to saved input
|
|
94
|
-
setHistoryIndex(-1);
|
|
95
|
-
onChange(savedInput);
|
|
96
|
-
setCursorOffset(savedInput.length);
|
|
97
|
-
}
|
|
98
|
-
}, [historyIndex, savedInput, localHistory, onChange]);
|
|
99
|
-
// --- Change handler with trigger detection ---
|
|
100
|
-
const handleChange = useCallback((newValue) => {
|
|
101
|
-
// Reset history navigation when user types
|
|
102
|
-
setHistoryIndex(-1);
|
|
103
|
-
// Detect triggers - always update value, then fire trigger
|
|
104
|
-
const isNewCommand = newValue === "/" || (newValue.startsWith("/") && !value.startsWith("/"));
|
|
105
|
-
// Detect @mention using the same Unicode/hyphen-safe name class as arion mention parsing.
|
|
106
|
-
const mentionMatch = newValue.match(/@([\p{L}\p{N}_-]*)$/u);
|
|
107
|
-
const wasAlreadyMention = value.match(/@[\p{L}\p{N}_-]*$/u);
|
|
108
|
-
const isNewMention = mentionMatch && !wasAlreadyMention;
|
|
109
|
-
// Always update the value first
|
|
110
|
-
onChange(newValue);
|
|
111
|
-
// Then fire triggers
|
|
112
|
-
if (isNewCommand) {
|
|
113
|
-
onTrigger("command", newValue.slice(1));
|
|
114
|
-
}
|
|
115
|
-
else if (isNewMention) {
|
|
116
|
-
// Extract filter text after the @
|
|
117
|
-
onTrigger("mention", mentionMatch[1]);
|
|
118
|
-
}
|
|
119
|
-
}, [value, onChange, onTrigger]);
|
|
120
|
-
// --- Submit handler (moved from App.tsx) ---
|
|
121
|
-
const handleInternalSubmit = useCallback((submittedValue) => {
|
|
122
|
-
const latestValue = valueRef.current;
|
|
123
|
-
const latestPastedText = pastedTextRef.current;
|
|
124
|
-
const latestPastedImage = pastedImageRef.current;
|
|
125
|
-
let finalInput = submittedValue !== latestValue && (latestPastedText !== null || latestPastedImage !== null)
|
|
126
|
-
? latestValue
|
|
127
|
-
: submittedValue;
|
|
128
|
-
// If there's pasted text, expand the placeholder back to the real pasted content
|
|
129
|
-
if (latestPastedText) {
|
|
130
|
-
const newlineCount = (latestPastedText.match(/\r\n|\r|\n/g) || []).length;
|
|
131
|
-
const pastedPrompt = `[Pasted text +${newlineCount} lines] `;
|
|
132
|
-
if (finalInput.includes(pastedPrompt)) {
|
|
133
|
-
finalInput = finalInput.replaceAll(pastedPrompt, latestPastedText);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (latestPastedImage && finalInput.includes(IMAGE_PLACEHOLDER)) {
|
|
137
|
-
finalInput = finalInput.replaceAll(IMAGE_PLACEHOLDER, "");
|
|
138
|
-
}
|
|
139
|
-
const hasImageAttachment = latestPastedImage !== null;
|
|
140
|
-
const trimmedForHistory = finalInput.trim();
|
|
141
|
-
if (!trimmedForHistory && !hasImageAttachment)
|
|
142
|
-
return;
|
|
143
|
-
if (hasImageAttachment) {
|
|
144
|
-
const imageDataUri = toImageDataUri(latestPastedImage);
|
|
145
|
-
finalInput = trimmedForHistory ? `${finalInput}\n\n${imageDataUri}` : imageDataUri;
|
|
146
|
-
}
|
|
147
|
-
if (trimmedForHistory) {
|
|
148
|
-
onSaveInput?.(trimmedForHistory); // Save text prompt history without large data URIs
|
|
149
|
-
// Update local history (most recent first, no duplicates)
|
|
150
|
-
setLocalHistory((prev) => [trimmedForHistory, ...prev.filter((h) => h !== trimmedForHistory)].slice(0, 100));
|
|
151
|
-
}
|
|
152
|
-
valueRef.current = "";
|
|
153
|
-
cursorOffsetRef.current = 0;
|
|
154
|
-
pastedTextRef.current = null;
|
|
155
|
-
pastedImageRef.current = null;
|
|
156
|
-
onChange(""); // Clear input
|
|
157
|
-
setPastedText(null);
|
|
158
|
-
setPastedImage(null);
|
|
159
|
-
setMessage({ show: false });
|
|
160
|
-
onSubmit(finalInput);
|
|
161
|
-
}, [onSubmit, onSaveInput, onChange]);
|
|
162
|
-
// --- Paste handlers (matching PromptInput pattern) ---
|
|
163
|
-
function handleImagePaste(image) {
|
|
164
|
-
pastedImageRef.current = image;
|
|
165
|
-
setPastedImage(image);
|
|
166
|
-
setMessage({ show: true, text: "Image attached. Press Enter to send." });
|
|
167
|
-
}
|
|
168
|
-
function handleTextPaste(rawText) {
|
|
169
|
-
// Read current state from refs — this function is called asynchronously
|
|
170
|
-
// (setTimeout + microtask) so closure values may be stale.
|
|
171
|
-
const currentValue = valueRef.current;
|
|
172
|
-
const currentOffset = cursorOffsetRef.current;
|
|
173
|
-
const text = rawText.replace(/\r/g, "\n");
|
|
174
|
-
const newlineCount = (text.match(/\r\n|\r|\n/g) || []).length;
|
|
175
|
-
const pastedPrompt = `[Pasted text +${newlineCount} lines] `;
|
|
176
|
-
const newInput = currentValue.slice(0, currentOffset) + pastedPrompt + currentValue.slice(currentOffset);
|
|
177
|
-
valueRef.current = newInput;
|
|
178
|
-
onChange(newInput);
|
|
179
|
-
const nextCursorOffset = currentOffset + pastedPrompt.length;
|
|
180
|
-
cursorOffsetRef.current = nextCursorOffset;
|
|
181
|
-
setCursorOffset(currentOffset + pastedPrompt.length);
|
|
182
|
-
pastedTextRef.current = text;
|
|
183
|
-
setPastedText(text);
|
|
184
|
-
}
|
|
185
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { borderStyle: "single", borderLeft: false, borderRight: false, borderDimColor: true, width: "100%", children: _jsxs(Box, { children: [_jsx(ArionPrompt, { userName: userName }), _jsx(TextInput, { multiline: true, value: value, onChange: handleChange, onSubmit: handleInternalSubmit, onHistoryUp: handleHistoryUp, onHistoryDown: handleHistoryDown, onHistoryReset: () => setHistoryIndex(-1), onDoubleEscape: onDoubleEscape, onExit: onExit, onExitMessage: (show, key) => setExitMessage({ show, key }), onMessage: (show, text) => setMessage({ show, text }), onImagePaste: handleImagePaste, onPaste: handleTextPaste, columns: textInputColumns, isDimmed: isDisabled, focus: focus !== false, showCursor: true, cursorOffset: cursorOffset, onChangeCursorOffset: setCursorOffset })] }) }), _jsx(Box, { flexDirection: "row", justifyContent: "space-between", paddingX: 2, children: _jsx(Box, { justifyContent: "flex-start", gap: 1, children: exitMessage.show ? (_jsxs(Text, { dimColor: true, children: ["Press ", exitMessage.key, " again to exit"] })) : message.show ? (_jsx(Text, { dimColor: true, children: message.text })) : (_jsxs(_Fragment, { children: [_jsx(Text, { dimColor: true, children: "/ for commands \u00B7 @ to mention \u00B7 esc to undo" }), _jsx(Text, { dimColor: true, children: showShiftEnterHint ? "shift + ⏎ for newline" : "\\⏎ for newline" })] })) }) })] }));
|
|
186
|
-
}
|
|
187
|
-
//# sourceMappingURL=InputArea.js.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Text } from "ink";
|
|
3
|
-
import { getArionColor, theme } from "../theme.js";
|
|
4
|
-
import { getTheme } from "../theme/index.js";
|
|
5
|
-
import { applyMarkdown } from "../markdown/index.js";
|
|
6
|
-
export function Message({ role, content, arion, userName, toolStatus, showPrefix = true, }) {
|
|
7
|
-
if (role === "tool") {
|
|
8
|
-
const t = getTheme();
|
|
9
|
-
const color = toolStatus === "error" ? t.colors.error : t.colors.success;
|
|
10
|
-
return (_jsx(Text, { color: color, dimColor: true, children: content }));
|
|
11
|
-
}
|
|
12
|
-
if (role === "system") {
|
|
13
|
-
return (_jsx(Box, { paddingY: 1, children: _jsx(Text, { dimColor: true, wrap: "wrap", children: applyMarkdown(content) }) }));
|
|
14
|
-
}
|
|
15
|
-
if (role === "user") {
|
|
16
|
-
const name = userName || "You";
|
|
17
|
-
return (_jsx(Box, { children: _jsxs(Text, { wrap: "wrap", children: [showPrefix && (_jsxs(Text, { color: theme.colors.cyan, bold: true, children: [name, " "] })), content] }) }));
|
|
18
|
-
}
|
|
19
|
-
// Assistant message - emoji + name in arion color, no colon
|
|
20
|
-
const colorHex = arion ? getArionColor(arion.color) : "#FFFFFF";
|
|
21
|
-
const prefix = arion ? `${arion.emoji} ${arion.name}` : "Assistant";
|
|
22
|
-
const renderedContent = applyMarkdown(content.trimEnd());
|
|
23
|
-
return (_jsx(Box, { children: _jsxs(Text, { wrap: "wrap", children: [showPrefix && (_jsxs(Text, { color: colorHex, bold: true, children: [prefix, " "] })), renderedContent] }) }));
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=Message.js.map
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* OAuthLoginFlow — interactive OAuth login component with browser + manual fallback.
|
|
4
|
-
*
|
|
5
|
-
* State machine: starting -> waiting -> manual -> exchanging -> success | error
|
|
6
|
-
*
|
|
7
|
-
* On mount, calls loginWithOAuth() which opens the browser. After 3s (or
|
|
8
|
-
* immediately if browser fails), the onManualFallback callback fires and
|
|
9
|
-
* we show the authorize URL + a text input for pasting the auth code.
|
|
10
|
-
* When the code arrives (via browser callback or manual paste), we show
|
|
11
|
-
* an exchanging spinner, then success or error.
|
|
12
|
-
*/
|
|
13
|
-
import { useEffect, useRef, useState } from "react";
|
|
14
|
-
import { Box, Text, useInput } from "ink";
|
|
15
|
-
import { collectOAuthAuthorizationCode, loginWithOAuth } from "@aria-cli/auth";
|
|
16
|
-
import { getTheme } from "../theme/index.js";
|
|
17
|
-
import { isEscapeInput } from "../utils/keys.js";
|
|
18
|
-
import { SimpleSpinner } from "./Spinner.js";
|
|
19
|
-
import TextInput from "./text-input/TextInput.js";
|
|
20
|
-
export function OAuthLoginFlow({ provider, onCancel, isActive = true, onComplete, authorizeUrl: initialAuthorizeUrl, expectedState, onCodeSubmit, }) {
|
|
21
|
-
const theme = getTheme();
|
|
22
|
-
const [step, setStep] = useState("starting");
|
|
23
|
-
const [authorizeUrl, setAuthorizeUrl] = useState("");
|
|
24
|
-
const [errorMessage, setErrorMessage] = useState("");
|
|
25
|
-
const [codeInput, setCodeInput] = useState("");
|
|
26
|
-
// Ref to hold the resolve function for manualCodePromise
|
|
27
|
-
const manualCodeResolveRef = useRef(null);
|
|
28
|
-
// Track whether the flow has already been started (prevent double-mount in strict mode)
|
|
29
|
-
const startedRef = useRef(false);
|
|
30
|
-
// Track whether onComplete has been called (prevent double-fire)
|
|
31
|
-
const completedRef = useRef(false);
|
|
32
|
-
const isRawModeSupported = process.stdin.isTTY ?? false;
|
|
33
|
-
// Handle Escape key
|
|
34
|
-
useInput((input, key) => {
|
|
35
|
-
if (isEscapeInput(input, key)) {
|
|
36
|
-
onCancel();
|
|
37
|
-
}
|
|
38
|
-
}, { isActive: isActive && isRawModeSupported });
|
|
39
|
-
// Start the OAuth flow on mount
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (startedRef.current)
|
|
42
|
-
return;
|
|
43
|
-
startedRef.current = true;
|
|
44
|
-
setStep("waiting");
|
|
45
|
-
// Create the manual code promise — resolve is stored in the ref
|
|
46
|
-
const manualCodePromise = new Promise((resolve) => {
|
|
47
|
-
manualCodeResolveRef.current = resolve;
|
|
48
|
-
});
|
|
49
|
-
const handleManualFallback = (url) => {
|
|
50
|
-
setAuthorizeUrl(url);
|
|
51
|
-
setStep("manual");
|
|
52
|
-
};
|
|
53
|
-
if (initialAuthorizeUrl && onCodeSubmit) {
|
|
54
|
-
setAuthorizeUrl(initialAuthorizeUrl);
|
|
55
|
-
collectOAuthAuthorizationCode(provider, {
|
|
56
|
-
authorizeUrl: initialAuthorizeUrl,
|
|
57
|
-
expectedState,
|
|
58
|
-
onManualFallback: handleManualFallback,
|
|
59
|
-
manualCodePromise,
|
|
60
|
-
}).then(async (code) => {
|
|
61
|
-
if (completedRef.current)
|
|
62
|
-
return;
|
|
63
|
-
setStep("exchanging");
|
|
64
|
-
await onCodeSubmit(code);
|
|
65
|
-
completedRef.current = true;
|
|
66
|
-
setStep("success");
|
|
67
|
-
}, (err) => {
|
|
68
|
-
if (completedRef.current)
|
|
69
|
-
return;
|
|
70
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
71
|
-
setErrorMessage(msg);
|
|
72
|
-
setStep("error");
|
|
73
|
-
});
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
loginWithOAuth(provider, {
|
|
77
|
-
onManualFallback: handleManualFallback,
|
|
78
|
-
manualCodePromise,
|
|
79
|
-
}).then((result) => {
|
|
80
|
-
if (completedRef.current)
|
|
81
|
-
return;
|
|
82
|
-
if (result.success) {
|
|
83
|
-
setStep("success");
|
|
84
|
-
completedRef.current = true;
|
|
85
|
-
setTimeout(() => {
|
|
86
|
-
onComplete?.({ success: true, message: result.message });
|
|
87
|
-
}, 1000);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
setErrorMessage(result.message);
|
|
91
|
-
setStep("error");
|
|
92
|
-
}
|
|
93
|
-
}, (err) => {
|
|
94
|
-
if (completedRef.current)
|
|
95
|
-
return;
|
|
96
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
97
|
-
setErrorMessage(msg);
|
|
98
|
-
setStep("error");
|
|
99
|
-
});
|
|
100
|
-
}, [expectedState, initialAuthorizeUrl, onCodeSubmit, onComplete, provider]);
|
|
101
|
-
const handleCodeSubmit = (value) => {
|
|
102
|
-
const trimmed = value.trim();
|
|
103
|
-
if (!trimmed)
|
|
104
|
-
return;
|
|
105
|
-
setStep("exchanging");
|
|
106
|
-
if (manualCodeResolveRef.current) {
|
|
107
|
-
manualCodeResolveRef.current(trimmed);
|
|
108
|
-
manualCodeResolveRef.current = null;
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.colors.secondary, paddingX: 1, paddingY: 1, width: 64, children: [_jsx(Box, { marginBottom: 1, children: _jsxs(Text, { bold: true, children: ["Sign in to ", provider] }) }), (step === "starting" || step === "waiting") && (_jsxs(Box, { gap: 1, children: [_jsx(SimpleSpinner, {}), _jsx(Text, { children: "Opening browser to sign in..." })] })), step === "manual" && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: "Open this URL in your browser:" }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.colors.primary, wrap: "wrap", children: authorizeUrl }) }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { children: "Paste the authorization code below:" }) }), _jsxs(Box, { marginTop: 1, children: [_jsx(Text, { color: theme.colors.textMuted, children: "> " }), _jsx(TextInput, { value: codeInput, onChange: setCodeInput, onSubmit: handleCodeSubmit, placeholder: "paste code here", focus: isActive, showCursor: true })] })] })), step === "exchanging" && (_jsxs(Box, { gap: 1, children: [_jsx(SimpleSpinner, {}), _jsx(Text, { children: "Exchanging code for tokens..." })] })), step === "success" && (_jsxs(Text, { color: theme.colors.success, children: ["\u2713", " Logged in to ", provider] })), step === "error" && (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: theme.colors.error, children: ["\u2717", " ", errorMessage] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.colors.textMuted, children: "Press Esc to dismiss" }) })] })), step !== "success" && step !== "error" && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.colors.textMuted, children: "Esc Cancel" }) }))] }));
|
|
112
|
-
}
|
|
113
|
-
//# sourceMappingURL=OAuthLoginFlow.js.map
|