@aria-cli/cli 1.0.57 → 1.0.58
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/package.json +17 -76
- 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 -367
- package/dist/commands/definitions.js +0 -176
- package/dist/commands/index.js +0 -80
- 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 -62
- 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 -617
- 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 -72
- 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,238 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ARIA Display & Persistence Configuration
|
|
3
|
-
*
|
|
4
|
-
* Loads user preferences from ~/.aria/config.yaml and merges them with
|
|
5
|
-
* MODE_PRESETS to produce the final display configuration. This implements
|
|
6
|
-
* the 4-layer merge strategy:
|
|
7
|
-
*
|
|
8
|
-
* MODE_PRESETS[mode] -> config file -> CLI flags -> hotkey toggles
|
|
9
|
-
*
|
|
10
|
-
* All config options control UI presentation density, NOT feature availability.
|
|
11
|
-
* ObservabilityContext always captures everything regardless of display settings.
|
|
12
|
-
*/
|
|
13
|
-
import { readFileSync } from "fs";
|
|
14
|
-
import { join } from "path";
|
|
15
|
-
import { homedir } from "os";
|
|
16
|
-
import { parse as parseYaml } from "yaml";
|
|
17
|
-
import { MODE_PRESETS, } from "../ui/display-mode.js";
|
|
18
|
-
import { log } from "@aria-cli/types";
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
// Defaults
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
const DEFAULT_PERSISTENCE = {
|
|
23
|
-
jsonlEnabled: true,
|
|
24
|
-
// SQLite SessionHistory is the authoritative session ledger.
|
|
25
|
-
// JSONL event logs remain observability and recovery aids only.
|
|
26
|
-
// Never auto-delete JSONL files — they are still the durable event journal.
|
|
27
|
-
jsonlRetentionDays: Infinity,
|
|
28
|
-
jsonlMaxSizeMb: Infinity,
|
|
29
|
-
otelEndpoint: null,
|
|
30
|
-
};
|
|
31
|
-
const DEFAULT_DISPLAY_EXTRAS = {
|
|
32
|
-
mode: "standard",
|
|
33
|
-
syntaxHighlighting: true,
|
|
34
|
-
maxToolOutputLines: 5,
|
|
35
|
-
maxThinkingPreview: 80,
|
|
36
|
-
};
|
|
37
|
-
function buildDefaultConfig() {
|
|
38
|
-
return {
|
|
39
|
-
display: {
|
|
40
|
-
...MODE_PRESETS.standard,
|
|
41
|
-
...DEFAULT_DISPLAY_EXTRAS,
|
|
42
|
-
},
|
|
43
|
-
persistence: { ...DEFAULT_PERSISTENCE },
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
// ---------------------------------------------------------------------------
|
|
47
|
-
// Validation helpers (lightweight — no Zod)
|
|
48
|
-
// ---------------------------------------------------------------------------
|
|
49
|
-
const VALID_DISPLAY_MODES = new Set(["minimal", "standard", "debug"]);
|
|
50
|
-
const VALID_TOOL_OUTPUT_MODES = new Set(["hidden", "collapsed", "standard", "expanded"]);
|
|
51
|
-
const VALID_THEME_NAMES = new Set([
|
|
52
|
-
"dark",
|
|
53
|
-
"light",
|
|
54
|
-
"dark-accessible",
|
|
55
|
-
"light-accessible",
|
|
56
|
-
"claude-dark",
|
|
57
|
-
"claude-light",
|
|
58
|
-
"claude-dark-daltonized",
|
|
59
|
-
"claude-light-daltonized",
|
|
60
|
-
]);
|
|
61
|
-
function isDisplayMode(value) {
|
|
62
|
-
return typeof value === "string" && VALID_DISPLAY_MODES.has(value);
|
|
63
|
-
}
|
|
64
|
-
function isToolOutputMode(value) {
|
|
65
|
-
return typeof value === "string" && VALID_TOOL_OUTPUT_MODES.has(value);
|
|
66
|
-
}
|
|
67
|
-
function isThemeName(value) {
|
|
68
|
-
return typeof value === "string" && VALID_THEME_NAMES.has(value);
|
|
69
|
-
}
|
|
70
|
-
function isBool(value) {
|
|
71
|
-
return typeof value === "boolean";
|
|
72
|
-
}
|
|
73
|
-
function isPositiveInt(value) {
|
|
74
|
-
return typeof value === "number" && Number.isInteger(value) && value > 0;
|
|
75
|
-
}
|
|
76
|
-
function isNonNegativeInt(value) {
|
|
77
|
-
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
78
|
-
}
|
|
79
|
-
// ---------------------------------------------------------------------------
|
|
80
|
-
// YAML Config File Parsing
|
|
81
|
-
// ---------------------------------------------------------------------------
|
|
82
|
-
/**
|
|
83
|
-
* Attempt to read and parse the YAML config file.
|
|
84
|
-
* Returns null if the file doesn't exist. Throws on I/O errors.
|
|
85
|
-
* Returns the raw parsed object on success (even if malformed YAML structure).
|
|
86
|
-
*/
|
|
87
|
-
function readYamlConfig(configPath) {
|
|
88
|
-
try {
|
|
89
|
-
const content = readFileSync(configPath, "utf-8");
|
|
90
|
-
const parsed = parseYaml(content);
|
|
91
|
-
if (parsed === null || parsed === undefined || typeof parsed !== "object") {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
return parsed;
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
if (error.code === "ENOENT") {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
throw error;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Extract validated display overrides from raw YAML.
|
|
105
|
-
* Unknown fields are silently ignored (forward-compatible).
|
|
106
|
-
*/
|
|
107
|
-
function parseDisplaySection(raw) {
|
|
108
|
-
const result = {};
|
|
109
|
-
if (isDisplayMode(raw.mode))
|
|
110
|
-
result.mode = raw.mode;
|
|
111
|
-
if (isThemeName(raw.theme))
|
|
112
|
-
result.theme = raw.theme;
|
|
113
|
-
if (isBool(raw.thinking))
|
|
114
|
-
result.showThinking = raw.thinking;
|
|
115
|
-
if (isBool(raw.costs))
|
|
116
|
-
result.showCosts = raw.costs;
|
|
117
|
-
if (isBool(raw.toolArgs))
|
|
118
|
-
result.showToolArgs = raw.toolArgs;
|
|
119
|
-
if (isToolOutputMode(raw.toolOutput))
|
|
120
|
-
result.toolOutput = raw.toolOutput;
|
|
121
|
-
if (isBool(raw.traces))
|
|
122
|
-
result.showTraces = raw.traces;
|
|
123
|
-
if (isBool(raw.pipelineTiming))
|
|
124
|
-
result.showPipelineTiming = raw.pipelineTiming;
|
|
125
|
-
if (isBool(raw.statusBar))
|
|
126
|
-
result.showStatusBar = raw.statusBar;
|
|
127
|
-
if (isBool(raw.syntaxHighlighting))
|
|
128
|
-
result.syntaxHighlighting = raw.syntaxHighlighting;
|
|
129
|
-
if (isPositiveInt(raw.maxToolOutputLines))
|
|
130
|
-
result.maxToolOutputLines = raw.maxToolOutputLines;
|
|
131
|
-
if (isNonNegativeInt(raw.maxThinkingPreview))
|
|
132
|
-
result.maxThinkingPreview = raw.maxThinkingPreview;
|
|
133
|
-
return result;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Extract validated persistence overrides from raw YAML.
|
|
137
|
-
*/
|
|
138
|
-
function parsePersistenceSection(raw) {
|
|
139
|
-
const result = {};
|
|
140
|
-
if (isBool(raw.jsonlEnabled))
|
|
141
|
-
result.jsonlEnabled = raw.jsonlEnabled;
|
|
142
|
-
if (isPositiveInt(raw.jsonlRetentionDays) || raw.jsonlRetentionDays === Infinity)
|
|
143
|
-
result.jsonlRetentionDays = raw.jsonlRetentionDays;
|
|
144
|
-
if (isPositiveInt(raw.jsonlMaxSizeMb) || raw.jsonlMaxSizeMb === Infinity)
|
|
145
|
-
result.jsonlMaxSizeMb = raw.jsonlMaxSizeMb;
|
|
146
|
-
if (raw.otelEndpoint === null) {
|
|
147
|
-
result.otelEndpoint = null;
|
|
148
|
-
}
|
|
149
|
-
else if (typeof raw.otelEndpoint === "string" && raw.otelEndpoint.length > 0) {
|
|
150
|
-
result.otelEndpoint = raw.otelEndpoint;
|
|
151
|
-
}
|
|
152
|
-
return result;
|
|
153
|
-
}
|
|
154
|
-
// ---------------------------------------------------------------------------
|
|
155
|
-
// Public API
|
|
156
|
-
// ---------------------------------------------------------------------------
|
|
157
|
-
/**
|
|
158
|
-
* Merge display config layers: preset -> file -> overrides.
|
|
159
|
-
*
|
|
160
|
-
* Each layer is a partial DisplayConfig. Values from later layers
|
|
161
|
-
* override earlier ones. Missing values fall through to the preset.
|
|
162
|
-
*/
|
|
163
|
-
export function mergeDisplayConfig(preset, fileOverrides, cliOverrides) {
|
|
164
|
-
return {
|
|
165
|
-
...preset,
|
|
166
|
-
...(fileOverrides ? stripUndefined(fileOverrides) : {}),
|
|
167
|
-
...(cliOverrides ? stripUndefined(cliOverrides) : {}),
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Load the full ARIA display/persistence config.
|
|
172
|
-
*
|
|
173
|
-
* Resolution order:
|
|
174
|
-
* 1. Start with MODE_PRESETS[mode] (default: "standard")
|
|
175
|
-
* 2. Overlay values from ~/.aria/config.yaml (if exists)
|
|
176
|
-
* 3. Return merged AriaDisplayConfig
|
|
177
|
-
*
|
|
178
|
-
* If the file doesn't exist, returns defaults silently.
|
|
179
|
-
* If the file is malformed YAML, logs a warning and returns defaults.
|
|
180
|
-
*/
|
|
181
|
-
export function loadAriaDisplayConfig(configPath) {
|
|
182
|
-
const defaults = buildDefaultConfig();
|
|
183
|
-
const resolvedPath = configPath ?? join(homedir(), ".aria", "config.yaml");
|
|
184
|
-
let raw;
|
|
185
|
-
try {
|
|
186
|
-
raw = readYamlConfig(resolvedPath);
|
|
187
|
-
}
|
|
188
|
-
catch (error) {
|
|
189
|
-
log.warn(`[AriaConfig] Failed to parse ${resolvedPath}: ${error.message}. Using defaults.`);
|
|
190
|
-
return defaults;
|
|
191
|
-
}
|
|
192
|
-
if (raw === null) {
|
|
193
|
-
return defaults;
|
|
194
|
-
}
|
|
195
|
-
// Parse display section
|
|
196
|
-
const rawDisplay = typeof raw.display === "object" && raw.display !== null
|
|
197
|
-
? raw.display
|
|
198
|
-
: {};
|
|
199
|
-
const displayOverrides = parseDisplaySection(rawDisplay);
|
|
200
|
-
// Determine the base mode — file may specify a different mode
|
|
201
|
-
const mode = displayOverrides.mode ?? defaults.display.mode;
|
|
202
|
-
const modePreset = MODE_PRESETS[mode];
|
|
203
|
-
// Build display config: preset -> file overrides
|
|
204
|
-
const mergedDisplay = mergeDisplayConfig(modePreset, displayOverrides);
|
|
205
|
-
// Parse persistence section
|
|
206
|
-
const rawPersistence = typeof raw.persistence === "object" && raw.persistence !== null
|
|
207
|
-
? raw.persistence
|
|
208
|
-
: {};
|
|
209
|
-
const persistenceOverrides = parsePersistenceSection(rawPersistence);
|
|
210
|
-
return {
|
|
211
|
-
display: {
|
|
212
|
-
...mergedDisplay,
|
|
213
|
-
mode,
|
|
214
|
-
theme: displayOverrides.theme,
|
|
215
|
-
syntaxHighlighting: displayOverrides.syntaxHighlighting ?? defaults.display.syntaxHighlighting,
|
|
216
|
-
maxToolOutputLines: displayOverrides.maxToolOutputLines ?? defaults.display.maxToolOutputLines,
|
|
217
|
-
maxThinkingPreview: displayOverrides.maxThinkingPreview ?? defaults.display.maxThinkingPreview,
|
|
218
|
-
},
|
|
219
|
-
persistence: {
|
|
220
|
-
...defaults.persistence,
|
|
221
|
-
...stripUndefined(persistenceOverrides),
|
|
222
|
-
},
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
// ---------------------------------------------------------------------------
|
|
226
|
-
// Utility
|
|
227
|
-
// ---------------------------------------------------------------------------
|
|
228
|
-
/** Remove undefined values from an object so spread doesn't override with undefined */
|
|
229
|
-
function stripUndefined(obj) {
|
|
230
|
-
const result = {};
|
|
231
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
232
|
-
if (value !== undefined) {
|
|
233
|
-
result[key] = value;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return result;
|
|
237
|
-
}
|
|
238
|
-
//# sourceMappingURL=aria-config.js.map
|
package/dist/config/index.js
DELETED
package/dist/config/loader.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ARIA CLI Configuration Loader
|
|
3
|
-
*
|
|
4
|
-
* Loads configuration from project and global locations.
|
|
5
|
-
*/
|
|
6
|
-
import { readFile } from "fs/promises";
|
|
7
|
-
import { join } from "path";
|
|
8
|
-
import { homedir } from "os";
|
|
9
|
-
const DEFAULT_CONFIG = {
|
|
10
|
-
mcp: { servers: [] },
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Load config from a file path
|
|
14
|
-
*/
|
|
15
|
-
async function loadConfigFile(path) {
|
|
16
|
-
try {
|
|
17
|
-
const content = await readFile(path, "utf-8");
|
|
18
|
-
const config = JSON.parse(content);
|
|
19
|
-
// Expand environment variables in config
|
|
20
|
-
if (config.mcp?.servers) {
|
|
21
|
-
for (const server of config.mcp.servers) {
|
|
22
|
-
if (server.env) {
|
|
23
|
-
for (const [key, value] of Object.entries(server.env)) {
|
|
24
|
-
if (typeof value === "string" && value.startsWith("${") && value.endsWith("}")) {
|
|
25
|
-
const envVar = value.slice(2, -1);
|
|
26
|
-
server.env[key] = process.env[envVar] || "";
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
// Validate server configs
|
|
33
|
-
if (config.mcp?.servers) {
|
|
34
|
-
for (const server of config.mcp.servers) {
|
|
35
|
-
if (!server.name || typeof server.name !== "string") {
|
|
36
|
-
throw new Error('Invalid MCP server config: missing "name" field');
|
|
37
|
-
}
|
|
38
|
-
if (!server.transport) {
|
|
39
|
-
throw new Error(`MCP server "${server.name}": missing "transport" field`);
|
|
40
|
-
}
|
|
41
|
-
if (server.transport && !["stdio", "sse"].includes(server.transport)) {
|
|
42
|
-
throw new Error(`MCP server "${server.name}": unknown transport "${server.transport}"`);
|
|
43
|
-
}
|
|
44
|
-
if (server.transport === "stdio" && !server.command) {
|
|
45
|
-
throw new Error(`MCP server "${server.name}": stdio transport requires "command" field`);
|
|
46
|
-
}
|
|
47
|
-
if (server.transport === "sse" && !server.url) {
|
|
48
|
-
throw new Error(`MCP server "${server.name}": sse transport requires "url" field`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return config;
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
if (error.code === "ENOENT") {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
throw error;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Merge two configs (later takes precedence)
|
|
63
|
-
*/
|
|
64
|
-
function mergeConfigs(base, override) {
|
|
65
|
-
const baseServers = base.mcp?.servers || [];
|
|
66
|
-
const overrideServers = override.mcp?.servers || [];
|
|
67
|
-
const overrideNames = new Set(overrideServers.map((s) => s.name));
|
|
68
|
-
return {
|
|
69
|
-
mcp: {
|
|
70
|
-
servers: [...baseServers.filter((s) => !overrideNames.has(s.name)), ...overrideServers],
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Load configuration from all sources
|
|
76
|
-
*
|
|
77
|
-
* Precedence: project > global > defaults
|
|
78
|
-
*/
|
|
79
|
-
export async function loadAriaProjectConfig(projectDir) {
|
|
80
|
-
let config = { ...DEFAULT_CONFIG };
|
|
81
|
-
// Load global config
|
|
82
|
-
const globalPath = join(homedir(), ".aria", "config.json");
|
|
83
|
-
const globalConfig = await loadConfigFile(globalPath);
|
|
84
|
-
if (globalConfig) {
|
|
85
|
-
config = mergeConfigs(config, globalConfig);
|
|
86
|
-
}
|
|
87
|
-
// Load project config
|
|
88
|
-
if (projectDir) {
|
|
89
|
-
const projectPath = join(projectDir, "aria.config.json");
|
|
90
|
-
const projectConfig = await loadConfigFile(projectPath);
|
|
91
|
-
if (projectConfig) {
|
|
92
|
-
config = mergeConfigs(config, projectConfig);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return config;
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=loader.js.map
|
package/dist/config.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared configuration utilities for ARIA CLI
|
|
3
|
-
*/
|
|
4
|
-
import * as fs from "fs";
|
|
5
|
-
import * as os from "os";
|
|
6
|
-
import { resolveModelReference, isValidTier } from "@aria-cli/models";
|
|
7
|
-
import { log } from "@aria-cli/types";
|
|
8
|
-
import { clearStallPhase, setStallPhase } from "./event-loop-watchdog.js";
|
|
9
|
-
/**
|
|
10
|
-
* Get the ARIA home directory.
|
|
11
|
-
* Respects ARIA_HOME env var for testing and custom deployments.
|
|
12
|
-
*/
|
|
13
|
-
export function getAriaDir() {
|
|
14
|
-
if (process.env.ARIA_HOME) {
|
|
15
|
-
return process.env.ARIA_HOME;
|
|
16
|
-
}
|
|
17
|
-
const home = process.env.HOME || os.homedir();
|
|
18
|
-
return `${home}/.aria`;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Get the config file path
|
|
22
|
-
*/
|
|
23
|
-
export function getConfigPath() {
|
|
24
|
-
return `${getAriaDir()}/config.json`;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Load configuration from ~/.aria/config.json
|
|
28
|
-
* Automatically migrates legacy defaultModel to preferredTier.
|
|
29
|
-
*
|
|
30
|
-
* This is the canonical config loader — use this instead of inline
|
|
31
|
-
* JSON.parse to ensure migration logic runs consistently.
|
|
32
|
-
*/
|
|
33
|
-
export function loadAndMigrateConfig() {
|
|
34
|
-
setStallPhase("config:load");
|
|
35
|
-
try {
|
|
36
|
-
const configPath = getConfigPath();
|
|
37
|
-
if (!fs.existsSync(configPath)) {
|
|
38
|
-
const config = {};
|
|
39
|
-
if (persistAwsSelectorHintsFromEnv(config)) {
|
|
40
|
-
saveConfig(config);
|
|
41
|
-
}
|
|
42
|
-
return config;
|
|
43
|
-
}
|
|
44
|
-
if (fs.existsSync(configPath)) {
|
|
45
|
-
const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
46
|
-
// Migrate old defaultModel to preferredTier
|
|
47
|
-
try {
|
|
48
|
-
if (config.defaultModel && !config.preferredTier) {
|
|
49
|
-
const model = resolveModelReference(config.defaultModel);
|
|
50
|
-
if (!model) {
|
|
51
|
-
log.warn(`Unknown model "${config.defaultModel}" migrated to balanced tier (Sonnet 4.5)`);
|
|
52
|
-
}
|
|
53
|
-
const tier = model?.tier || "balanced";
|
|
54
|
-
config.preferredTier = isValidTier(tier) ? tier : "balanced";
|
|
55
|
-
delete config.defaultModel;
|
|
56
|
-
saveConfig(config);
|
|
57
|
-
}
|
|
58
|
-
// Validate existing preferredTier
|
|
59
|
-
if (config.preferredTier !== undefined && !isValidTier(config.preferredTier)) {
|
|
60
|
-
log.warn(`Invalid tier "${config.preferredTier}" corrected to balanced tier`);
|
|
61
|
-
config.preferredTier = "balanced";
|
|
62
|
-
saveConfig(config);
|
|
63
|
-
}
|
|
64
|
-
// Persist non-secret AWS Bedrock selector config from env vars into config.json.
|
|
65
|
-
// These vars often exist only in one launch context (editor, login shell, etc.).
|
|
66
|
-
// Persisting them lets the daemon own Bedrock execution while still using
|
|
67
|
-
// AWS-native shared config / SSO cache as the real credential authority.
|
|
68
|
-
if (persistAwsSelectorHintsFromEnv(config)) {
|
|
69
|
-
saveConfig(config);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (migrationError) {
|
|
73
|
-
log.warn("Config migration failed, using config as-is:", migrationError instanceof Error ? migrationError.message : migrationError);
|
|
74
|
-
}
|
|
75
|
-
return config;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
catch (err) {
|
|
79
|
-
log.warn("[Config] Failed to load config file:", err);
|
|
80
|
-
}
|
|
81
|
-
finally {
|
|
82
|
-
clearStallPhase();
|
|
83
|
-
}
|
|
84
|
-
return {};
|
|
85
|
-
}
|
|
86
|
-
/** @deprecated Use loadAndMigrateConfig() */
|
|
87
|
-
export const loadConfig = loadAndMigrateConfig;
|
|
88
|
-
function readNonEmptyEnv(name) {
|
|
89
|
-
const value = process.env[name]?.trim();
|
|
90
|
-
return value ? value : undefined;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Persist non-secret Bedrock selector hints from the current environment into config.
|
|
94
|
-
*
|
|
95
|
-
* This is intentionally limited to selectors and file locations, not credential material:
|
|
96
|
-
* - AWS profile / region
|
|
97
|
-
* - shared config / credentials file overrides
|
|
98
|
-
*
|
|
99
|
-
* The daemon remains the authority for execution; this only captures enough configuration
|
|
100
|
-
* for the daemon to find the machine-local AWS auth state later.
|
|
101
|
-
*/
|
|
102
|
-
export function persistAwsSelectorHintsFromEnv(config) {
|
|
103
|
-
let changed = false;
|
|
104
|
-
const envAwsRegion = readNonEmptyEnv("AWS_REGION") ?? readNonEmptyEnv("AWS_DEFAULT_REGION");
|
|
105
|
-
const envAwsProfile = readNonEmptyEnv("AWS_PROFILE");
|
|
106
|
-
const envAwsConfigFile = readNonEmptyEnv("AWS_CONFIG_FILE");
|
|
107
|
-
const envAwsSharedCredentialsFile = readNonEmptyEnv("AWS_SHARED_CREDENTIALS_FILE");
|
|
108
|
-
if (!config.awsRegion && envAwsRegion) {
|
|
109
|
-
config.awsRegion = envAwsRegion;
|
|
110
|
-
changed = true;
|
|
111
|
-
}
|
|
112
|
-
if (!config.awsProfile && envAwsProfile) {
|
|
113
|
-
config.awsProfile = envAwsProfile;
|
|
114
|
-
changed = true;
|
|
115
|
-
}
|
|
116
|
-
if (!config.awsConfigFile && envAwsConfigFile) {
|
|
117
|
-
config.awsConfigFile = envAwsConfigFile;
|
|
118
|
-
changed = true;
|
|
119
|
-
}
|
|
120
|
-
if (!config.awsSharedCredentialsFile && envAwsSharedCredentialsFile) {
|
|
121
|
-
config.awsSharedCredentialsFile = envAwsSharedCredentialsFile;
|
|
122
|
-
changed = true;
|
|
123
|
-
}
|
|
124
|
-
return changed;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Save configuration to ~/.aria/config.json
|
|
128
|
-
*/
|
|
129
|
-
export function saveConfig(config) {
|
|
130
|
-
setStallPhase("config:save");
|
|
131
|
-
const ariaDir = getAriaDir();
|
|
132
|
-
try {
|
|
133
|
-
if (!fs.existsSync(ariaDir)) {
|
|
134
|
-
fs.mkdirSync(ariaDir, { recursive: true });
|
|
135
|
-
}
|
|
136
|
-
fs.writeFileSync(getConfigPath(), JSON.stringify(config, null, 2), "utf-8");
|
|
137
|
-
}
|
|
138
|
-
finally {
|
|
139
|
-
clearStallPhase();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
//# sourceMappingURL=config.js.map
|
package/dist/daemon-info.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Legacy daemon-info / presence helpers.
|
|
3
|
-
*
|
|
4
|
-
* The runtime-owner architecture no longer allows attach/discovery through
|
|
5
|
-
* daemon-info files or per-process presence files. Keep this module only to
|
|
6
|
-
* document that these APIs were removed in favor of HostSupervisor and
|
|
7
|
-
* local-control attach.
|
|
8
|
-
*/
|
|
9
|
-
export const LEGACY_RUNTIME_DISCOVERY_REMOVED = "[daemon-info] Legacy daemon-info/presence attach is removed. Use HostSupervisor/runtime-owner records and local-control attach instead.";
|
|
10
|
-
//# sourceMappingURL=daemon-info.js.map
|
package/dist/ensure-daemon.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Universal daemon connection for all CLI subcommands.
|
|
3
|
-
*
|
|
4
|
-
* One function, one pattern:
|
|
5
|
-
* 1. Find running daemon → verify PID alive → connect to socket
|
|
6
|
-
* 2. Dead/missing daemon → clean stale records → spawn → connect
|
|
7
|
-
*
|
|
8
|
-
* Every CLI path (pairing, call, headless) uses this. No scoped runtimes,
|
|
9
|
-
* no split-brain, no WG port conflicts. The daemon owns the runtime.
|
|
10
|
-
*/
|
|
11
|
-
import path from "node:path";
|
|
12
|
-
function isPidAlive(pid) {
|
|
13
|
-
try {
|
|
14
|
-
process.kill(pid, 0);
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
const ATTACHABLE_PHASES = new Set(["control_ready", "network_ready", "mesh_ready"]);
|
|
22
|
-
function tryConnectToSocket(ariaHome) {
|
|
23
|
-
return (async () => {
|
|
24
|
-
try {
|
|
25
|
-
const { resolveRuntimeRootDirectory, findRuntimeOwnerRecordByAriaHome, removeRuntimeOwnerRecord, } = await import("@aria-cli/server");
|
|
26
|
-
const runtimeRoot = resolveRuntimeRootDirectory();
|
|
27
|
-
const owner = findRuntimeOwnerRecordByAriaHome(runtimeRoot, ariaHome);
|
|
28
|
-
if (!owner?.runtimeSocket) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
// Verify the daemon process is actually alive.
|
|
32
|
-
// If not, clean the stale record so we spawn a fresh daemon.
|
|
33
|
-
if (!isPidAlive(owner.runtimePid)) {
|
|
34
|
-
removeRuntimeOwnerRecord(runtimeRoot, owner.nodeId);
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
// Use the resilient client — it owns lease, auth, reattach, backoff, and logging.
|
|
38
|
-
const { createResilientAttachedClient } = await import("./attached-local-control-client.js");
|
|
39
|
-
const resilient = await createResilientAttachedClient({
|
|
40
|
-
runtimeSocket: owner.runtimeSocket,
|
|
41
|
-
clientKind: "local-api",
|
|
42
|
-
logDir: path.join(ariaHome, "logs"),
|
|
43
|
-
});
|
|
44
|
-
// Verify the daemon is in an attachable phase (not shutting down).
|
|
45
|
-
// Without this check, ensureDaemon can return a connection to a daemon
|
|
46
|
-
// in "stopped" phase — the socket and PID are alive during shutdown,
|
|
47
|
-
// but the child TUI will fail to attach because it requires an
|
|
48
|
-
// attachable phase (control_ready/network_ready/mesh_ready).
|
|
49
|
-
try {
|
|
50
|
-
const bootstrap = await resilient.api.getRuntimeBootstrap();
|
|
51
|
-
if (!ATTACHABLE_PHASES.has(bootstrap.phase)) {
|
|
52
|
-
await resilient.release();
|
|
53
|
-
removeRuntimeOwnerRecord(runtimeRoot, owner.nodeId);
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
await resilient.release();
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
control: resilient.api,
|
|
63
|
-
release: () => resilient.release(),
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
})();
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Connect to a running daemon, or spawn one if none exists.
|
|
73
|
-
* This is the ONLY way CLI subcommands should obtain a control client.
|
|
74
|
-
*/
|
|
75
|
-
export async function ensureDaemon(ctx) {
|
|
76
|
-
// 1. Try existing daemon (verifies PID alive, cleans stale records)
|
|
77
|
-
const existing = await tryConnectToSocket(ctx.ariaDir);
|
|
78
|
-
if (existing) {
|
|
79
|
-
return existing;
|
|
80
|
-
}
|
|
81
|
-
// 2. No daemon (or dead daemon cleaned up) — spawn one
|
|
82
|
-
const { createDaemonService } = await import("./headless/daemon-service.js");
|
|
83
|
-
const arionName = ctx.config.activeArion ?? "ARIA";
|
|
84
|
-
const daemon = createDaemonService({
|
|
85
|
-
cli: ctx,
|
|
86
|
-
cwd: process.cwd(),
|
|
87
|
-
arionName,
|
|
88
|
-
});
|
|
89
|
-
await daemon.start({});
|
|
90
|
-
// 3. Wait for socket with adaptive polling — fast at first (50ms),
|
|
91
|
-
// then backs off to 200ms. Uses fs.watch on the owner-records
|
|
92
|
-
// directory so we react in <50ms when the daemon writes its record.
|
|
93
|
-
const { resolveRuntimeRootDirectory } = await import("@aria-cli/server");
|
|
94
|
-
const runtimeRoot = resolveRuntimeRootDirectory();
|
|
95
|
-
const ownersDir = path.join(runtimeRoot, "owners");
|
|
96
|
-
const deadline = Date.now() + 15_000;
|
|
97
|
-
let watcher = null;
|
|
98
|
-
let notifyResolve = null;
|
|
99
|
-
try {
|
|
100
|
-
const { watch, mkdirSync, existsSync } = await import("node:fs");
|
|
101
|
-
if (!existsSync(ownersDir))
|
|
102
|
-
mkdirSync(ownersDir, { recursive: true, mode: 0o700 });
|
|
103
|
-
try {
|
|
104
|
-
watcher = watch(ownersDir, () => notifyResolve?.());
|
|
105
|
-
watcher.on("error", () => { });
|
|
106
|
-
}
|
|
107
|
-
catch {
|
|
108
|
-
// fs.watch may fail on some platforms; polling still works
|
|
109
|
-
}
|
|
110
|
-
let pollMs = 50;
|
|
111
|
-
while (Date.now() < deadline) {
|
|
112
|
-
const conn = await tryConnectToSocket(ctx.ariaDir);
|
|
113
|
-
if (conn)
|
|
114
|
-
return conn;
|
|
115
|
-
await new Promise((resolve) => {
|
|
116
|
-
notifyResolve = resolve;
|
|
117
|
-
setTimeout(resolve, pollMs);
|
|
118
|
-
});
|
|
119
|
-
notifyResolve = null;
|
|
120
|
-
pollMs = Math.min(Math.round(pollMs * 1.5), 200);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
finally {
|
|
124
|
-
watcher?.close();
|
|
125
|
-
}
|
|
126
|
-
throw new Error("Daemon started but socket not reachable. Check ARIA_HOME.");
|
|
127
|
-
}
|
|
128
|
-
//# sourceMappingURL=ensure-daemon.js.map
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { runServerDaemonLauncherFromCli } from "@aria-cli/server/daemon-launcher";
|
|
2
|
-
function requireValue(argv, index, flag) {
|
|
3
|
-
const value = argv[index + 1];
|
|
4
|
-
if (!value)
|
|
5
|
-
throw new Error(`${flag} requires a value`);
|
|
6
|
-
return value;
|
|
7
|
-
}
|
|
8
|
-
function parseDaemonArgs(argv) {
|
|
9
|
-
const options = {};
|
|
10
|
-
for (let i = 0; i < argv.length; i += 1) {
|
|
11
|
-
const arg = argv[i];
|
|
12
|
-
switch (arg) {
|
|
13
|
-
case "--arion":
|
|
14
|
-
options.arion = requireValue(argv, i, arg);
|
|
15
|
-
i += 1;
|
|
16
|
-
break;
|
|
17
|
-
case "--port":
|
|
18
|
-
options.port = requireValue(argv, i, arg);
|
|
19
|
-
i += 1;
|
|
20
|
-
break;
|
|
21
|
-
case "--interval-ms":
|
|
22
|
-
options.intervalMs = requireValue(argv, i, arg);
|
|
23
|
-
i += 1;
|
|
24
|
-
break;
|
|
25
|
-
case "--allowed-tool-categories":
|
|
26
|
-
options.allowedToolCategories = requireValue(argv, i, arg);
|
|
27
|
-
i += 1;
|
|
28
|
-
break;
|
|
29
|
-
case "--allowed-shell-commands":
|
|
30
|
-
options.allowedShellCommands = requireValue(argv, i, arg);
|
|
31
|
-
i += 1;
|
|
32
|
-
break;
|
|
33
|
-
case "--max-write-ops-per-minute":
|
|
34
|
-
options.maxWriteOpsPerMinute = requireValue(argv, i, arg);
|
|
35
|
-
i += 1;
|
|
36
|
-
break;
|
|
37
|
-
case "--max-git-pushes-per-hour":
|
|
38
|
-
options.maxGitPushesPerHour = requireValue(argv, i, arg);
|
|
39
|
-
i += 1;
|
|
40
|
-
break;
|
|
41
|
-
default:
|
|
42
|
-
throw new Error(`[aria] Unknown internal daemon arg: ${arg}`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return options;
|
|
46
|
-
}
|
|
47
|
-
export async function runDaemonEntrypoint(argv) {
|
|
48
|
-
await runServerDaemonLauncherFromCli(parseDaemonArgs(argv));
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=daemon.js.map
|