@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,363 +0,0 @@
|
|
|
1
|
-
import { appendFileSync, mkdirSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
export function isStaleLeaseError(error) {
|
|
4
|
-
if (!(error instanceof Error))
|
|
5
|
-
return false;
|
|
6
|
-
const msg = error.message;
|
|
7
|
-
if (msg.includes("attached-local-client-only"))
|
|
8
|
-
return true;
|
|
9
|
-
if (msg.includes("ECONNRESET"))
|
|
10
|
-
return true;
|
|
11
|
-
if (msg.includes("ECONNREFUSED"))
|
|
12
|
-
return true;
|
|
13
|
-
if (msg.includes("EPIPE"))
|
|
14
|
-
return true;
|
|
15
|
-
if (msg.includes("connect ENOENT"))
|
|
16
|
-
return true;
|
|
17
|
-
if (msg.includes("socket hang up"))
|
|
18
|
-
return true;
|
|
19
|
-
if (msg.includes("closed before"))
|
|
20
|
-
return true;
|
|
21
|
-
if (msg.includes("has been released"))
|
|
22
|
-
return true;
|
|
23
|
-
if (msg.includes("no daemon found"))
|
|
24
|
-
return true;
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
export function enrichStaleLeaseError(error) {
|
|
28
|
-
if (!isStaleLeaseError(error))
|
|
29
|
-
return error instanceof Error ? error : new Error(String(error));
|
|
30
|
-
const original = error;
|
|
31
|
-
const msg = original.message;
|
|
32
|
-
const reason = original.reason ?? "";
|
|
33
|
-
const isSocketError = msg.includes("ECONNRESET") ||
|
|
34
|
-
msg.includes("ECONNREFUSED") ||
|
|
35
|
-
msg.includes("EPIPE") ||
|
|
36
|
-
msg.includes("connect ENOENT") ||
|
|
37
|
-
msg.includes("socket hang up") ||
|
|
38
|
-
msg.includes("closed before");
|
|
39
|
-
const hint = isSocketError
|
|
40
|
-
? "Lost connection to the ARIA daemon. It may have restarted. Run `aria` again to reconnect."
|
|
41
|
-
: reason === "invalid_or_expired_lease" || reason === ""
|
|
42
|
-
? "The ARIA daemon restarted and your session could not be restored. Run `aria` again to start a new session."
|
|
43
|
-
: reason === "missing_client_id" || reason === "missing_proof"
|
|
44
|
-
? "Client credentials were not sent. This is likely a bug — please report it."
|
|
45
|
-
: reason === "no_authority"
|
|
46
|
-
? "The daemon has no attached-client authority configured. It may still be starting up."
|
|
47
|
-
: `Session authentication failed (${reason}). Run \`aria\` again to start a new session.`;
|
|
48
|
-
return Object.assign(new Error(`Session expired: ${hint} (${original.message})`), {
|
|
49
|
-
code: "ARIA_SESSION_EXPIRED",
|
|
50
|
-
reason: isSocketError ? "connection_lost" : reason,
|
|
51
|
-
cause: original,
|
|
52
|
-
}, original.diagnostic !== undefined ? { diagnostic: original.diagnostic } : {});
|
|
53
|
-
}
|
|
54
|
-
export const REATTACH_BACKOFF_DELAYS = [0, 250, 500, 1000, 2000, 3000];
|
|
55
|
-
const _reattachLogDirs = new Map();
|
|
56
|
-
export function logReattach(ariaDir, event) {
|
|
57
|
-
try {
|
|
58
|
-
let logDir = _reattachLogDirs.get(ariaDir);
|
|
59
|
-
if (!logDir) {
|
|
60
|
-
logDir = join(ariaDir, "logs");
|
|
61
|
-
mkdirSync(logDir, { recursive: true });
|
|
62
|
-
_reattachLogDirs.set(ariaDir, logDir);
|
|
63
|
-
}
|
|
64
|
-
const entry = JSON.stringify({ ts: new Date().toISOString(), pid: process.pid, ...event });
|
|
65
|
-
appendFileSync(join(logDir, "reattach.jsonl"), entry + "\n");
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
// Never let logging break reattach flow
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
export function reattachSleep(ms) {
|
|
72
|
-
if (ms <= 0)
|
|
73
|
-
return Promise.resolve();
|
|
74
|
-
return new Promise((resolve) => {
|
|
75
|
-
const timer = setTimeout(resolve, ms);
|
|
76
|
-
timer.unref?.();
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
export function createLazyAttachedLocalControlApi(loader, onStaleLeaseDetected, ariaDir) {
|
|
80
|
-
let cached = null;
|
|
81
|
-
let currentState = "connected";
|
|
82
|
-
let currentClientId;
|
|
83
|
-
let currentClientAuthToken;
|
|
84
|
-
const stateListeners = new Set();
|
|
85
|
-
let innerStateUnsub = null;
|
|
86
|
-
function emitState(next) {
|
|
87
|
-
if (next === currentState)
|
|
88
|
-
return;
|
|
89
|
-
currentState = next;
|
|
90
|
-
for (const fn of stateListeners) {
|
|
91
|
-
try {
|
|
92
|
-
fn(next);
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
// Never let listener failures break wrapper state.
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
async function syncStateSubscription(control) {
|
|
100
|
-
innerStateUnsub?.();
|
|
101
|
-
innerStateUnsub = null;
|
|
102
|
-
const stateAware = control;
|
|
103
|
-
if (typeof stateAware.getConnectionState === "function")
|
|
104
|
-
emitState(stateAware.getConnectionState());
|
|
105
|
-
currentClientId = stateAware.getClientId?.();
|
|
106
|
-
currentClientAuthToken = stateAware.getClientAuthToken?.();
|
|
107
|
-
if (typeof stateAware.onConnectionStateChange === "function") {
|
|
108
|
-
innerStateUnsub = stateAware.onConnectionStateChange((next) => {
|
|
109
|
-
emitState(next);
|
|
110
|
-
currentClientId = stateAware.getClientId?.();
|
|
111
|
-
currentClientAuthToken = stateAware.getClientAuthToken?.();
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
const ensure = () => {
|
|
116
|
-
if (!cached) {
|
|
117
|
-
cached = loader().then(async (control) => {
|
|
118
|
-
await syncStateSubscription(control);
|
|
119
|
-
return control;
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
return cached;
|
|
123
|
-
};
|
|
124
|
-
function invalidate() {
|
|
125
|
-
cached = null;
|
|
126
|
-
onStaleLeaseDetected?.();
|
|
127
|
-
}
|
|
128
|
-
async function withReattach(fn) {
|
|
129
|
-
try {
|
|
130
|
-
const control = await ensure();
|
|
131
|
-
return await fn(control);
|
|
132
|
-
}
|
|
133
|
-
catch (error) {
|
|
134
|
-
if (!isStaleLeaseError(error))
|
|
135
|
-
throw error;
|
|
136
|
-
const trigger = error instanceof Error ? error.message : String(error);
|
|
137
|
-
if (ariaDir)
|
|
138
|
-
logReattach(ariaDir, {
|
|
139
|
-
event: "reattach_start",
|
|
140
|
-
trigger,
|
|
141
|
-
maxAttempts: REATTACH_BACKOFF_DELAYS.length,
|
|
142
|
-
});
|
|
143
|
-
for (let attempt = 0; attempt < REATTACH_BACKOFF_DELAYS.length; attempt++) {
|
|
144
|
-
await reattachSleep(REATTACH_BACKOFF_DELAYS[attempt] ?? 0);
|
|
145
|
-
invalidate();
|
|
146
|
-
try {
|
|
147
|
-
const control = await ensure();
|
|
148
|
-
if (ariaDir)
|
|
149
|
-
logReattach(ariaDir, { event: "reattach_success", attempt, trigger });
|
|
150
|
-
return await fn(control);
|
|
151
|
-
}
|
|
152
|
-
catch (retryError) {
|
|
153
|
-
const retryMsg = retryError instanceof Error ? retryError.message : String(retryError);
|
|
154
|
-
if (ariaDir) {
|
|
155
|
-
logReattach(ariaDir, {
|
|
156
|
-
event: "reattach_retry_failed",
|
|
157
|
-
attempt,
|
|
158
|
-
error: retryMsg,
|
|
159
|
-
willRetry: isStaleLeaseError(retryError) && attempt < REATTACH_BACKOFF_DELAYS.length - 1,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
if (!isStaleLeaseError(retryError) || attempt === REATTACH_BACKOFF_DELAYS.length - 1) {
|
|
163
|
-
throw enrichStaleLeaseError(retryError);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
throw enrichStaleLeaseError(error);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
async function* withReattachStream(fn) {
|
|
171
|
-
try {
|
|
172
|
-
const control = await ensure();
|
|
173
|
-
yield* fn(control);
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
catch (error) {
|
|
177
|
-
if (!isStaleLeaseError(error))
|
|
178
|
-
throw error;
|
|
179
|
-
const trigger = error instanceof Error ? error.message : String(error);
|
|
180
|
-
if (ariaDir)
|
|
181
|
-
logReattach(ariaDir, {
|
|
182
|
-
event: "reattach_stream_start",
|
|
183
|
-
trigger,
|
|
184
|
-
maxAttempts: REATTACH_BACKOFF_DELAYS.length,
|
|
185
|
-
});
|
|
186
|
-
for (let attempt = 0; attempt < REATTACH_BACKOFF_DELAYS.length; attempt++) {
|
|
187
|
-
await reattachSleep(REATTACH_BACKOFF_DELAYS[attempt] ?? 0);
|
|
188
|
-
invalidate();
|
|
189
|
-
try {
|
|
190
|
-
const control = await ensure();
|
|
191
|
-
if (ariaDir)
|
|
192
|
-
logReattach(ariaDir, { event: "reattach_stream_success", attempt, trigger });
|
|
193
|
-
yield* fn(control);
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
catch (retryError) {
|
|
197
|
-
if (!isStaleLeaseError(retryError) || attempt === REATTACH_BACKOFF_DELAYS.length - 1) {
|
|
198
|
-
throw enrichStaleLeaseError(retryError);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return {
|
|
205
|
-
submitRun(request) {
|
|
206
|
-
return withReattach((c) => c.submitRun(request));
|
|
207
|
-
},
|
|
208
|
-
resumeRun(request) {
|
|
209
|
-
return withReattach((c) => c.resumeRun(request));
|
|
210
|
-
},
|
|
211
|
-
async *streamRun(request, signal) {
|
|
212
|
-
yield* withReattachStream((c) => c.streamRun(request, signal));
|
|
213
|
-
},
|
|
214
|
-
async *subscribeRuntimeEvents(cursor) {
|
|
215
|
-
yield* withReattachStream((c) => c.subscribeRuntimeEvents(cursor));
|
|
216
|
-
},
|
|
217
|
-
sendBestEffort(message) {
|
|
218
|
-
return withReattach((c) => c.sendBestEffort(message));
|
|
219
|
-
},
|
|
220
|
-
sendDurable(message) {
|
|
221
|
-
return withReattach((c) => c.sendDurable(message));
|
|
222
|
-
},
|
|
223
|
-
listInbox(request) {
|
|
224
|
-
return withReattach((c) => c.listInbox(request));
|
|
225
|
-
},
|
|
226
|
-
async *subscribeInbox(cursor) {
|
|
227
|
-
yield* withReattachStream((c) => c.subscribeInbox(cursor));
|
|
228
|
-
},
|
|
229
|
-
listPeers() {
|
|
230
|
-
return withReattach((c) => c.listPeers());
|
|
231
|
-
},
|
|
232
|
-
listNearbyPeers() {
|
|
233
|
-
return withReattach((c) => c.listNearbyPeers());
|
|
234
|
-
},
|
|
235
|
-
async *subscribePeers() {
|
|
236
|
-
yield* withReattachStream((c) => c.subscribePeers());
|
|
237
|
-
},
|
|
238
|
-
getRuntimeStatus() {
|
|
239
|
-
return withReattach((c) => c.getRuntimeStatus());
|
|
240
|
-
},
|
|
241
|
-
getModelSnapshot() {
|
|
242
|
-
return withReattach((c) => {
|
|
243
|
-
if (!c.getModelSnapshot)
|
|
244
|
-
throw new Error("getModelSnapshot not available");
|
|
245
|
-
return c.getModelSnapshot();
|
|
246
|
-
});
|
|
247
|
-
},
|
|
248
|
-
refreshModelSnapshot(input) {
|
|
249
|
-
return withReattach((c) => {
|
|
250
|
-
if (!c.refreshModelSnapshot)
|
|
251
|
-
throw new Error("refreshModelSnapshot not available");
|
|
252
|
-
return c.refreshModelSnapshot(input);
|
|
253
|
-
});
|
|
254
|
-
},
|
|
255
|
-
setCurrentModel(model) {
|
|
256
|
-
return withReattach((c) => {
|
|
257
|
-
if (!c.setCurrentModel)
|
|
258
|
-
throw new Error("setCurrentModel not available");
|
|
259
|
-
return c.setCurrentModel(model);
|
|
260
|
-
});
|
|
261
|
-
},
|
|
262
|
-
getSessionCredentialOverlayState() {
|
|
263
|
-
return withReattach((c) => {
|
|
264
|
-
if (!c.getSessionCredentialOverlayState) {
|
|
265
|
-
return Promise.resolve({ providers: [] });
|
|
266
|
-
}
|
|
267
|
-
return c.getSessionCredentialOverlayState();
|
|
268
|
-
});
|
|
269
|
-
},
|
|
270
|
-
setSessionCredentialOverlay(input) {
|
|
271
|
-
return withReattach((c) => {
|
|
272
|
-
if (!c.setSessionCredentialOverlay)
|
|
273
|
-
throw new Error("setSessionCredentialOverlay not available");
|
|
274
|
-
return c.setSessionCredentialOverlay(input);
|
|
275
|
-
});
|
|
276
|
-
},
|
|
277
|
-
clearSessionCredentialOverlay() {
|
|
278
|
-
return withReattach((c) => {
|
|
279
|
-
if (!c.clearSessionCredentialOverlay)
|
|
280
|
-
throw new Error("clearSessionCredentialOverlay not available");
|
|
281
|
-
return c.clearSessionCredentialOverlay();
|
|
282
|
-
});
|
|
283
|
-
},
|
|
284
|
-
getRuntimeBootstrap() {
|
|
285
|
-
return withReattach((c) => c.getRuntimeBootstrap());
|
|
286
|
-
},
|
|
287
|
-
listPendingPairRequests() {
|
|
288
|
-
return withReattach((c) => c.listPendingPairRequests());
|
|
289
|
-
},
|
|
290
|
-
respondToPairRequest(input) {
|
|
291
|
-
return withReattach((c) => c.respondToPairRequest(input));
|
|
292
|
-
},
|
|
293
|
-
createInvite(input) {
|
|
294
|
-
return withReattach((c) => c.createInvite(input));
|
|
295
|
-
},
|
|
296
|
-
listPendingInvites() {
|
|
297
|
-
return withReattach((c) => c.listPendingInvites());
|
|
298
|
-
},
|
|
299
|
-
acceptInviteToken(input) {
|
|
300
|
-
return withReattach((c) => c.acceptInviteToken(input));
|
|
301
|
-
},
|
|
302
|
-
cancelInvite(input) {
|
|
303
|
-
return withReattach((c) => c.cancelInvite(input));
|
|
304
|
-
},
|
|
305
|
-
invitePeer(input) {
|
|
306
|
-
return withReattach((c) => c.invitePeer(input));
|
|
307
|
-
},
|
|
308
|
-
acceptInvite(input) {
|
|
309
|
-
return withReattach((c) => c.acceptInvite(input));
|
|
310
|
-
},
|
|
311
|
-
directPair(input) {
|
|
312
|
-
return withReattach((c) => c.directPair(input));
|
|
313
|
-
},
|
|
314
|
-
revokePeer(input) {
|
|
315
|
-
return withReattach((c) => c.revokePeer(input));
|
|
316
|
-
},
|
|
317
|
-
repairPeer(input) {
|
|
318
|
-
return withReattach((c) => c.repairPeer(input));
|
|
319
|
-
},
|
|
320
|
-
listAttachedClients() {
|
|
321
|
-
return withReattach((c) => c.listAttachedClients());
|
|
322
|
-
},
|
|
323
|
-
listDirectClientInbox(request) {
|
|
324
|
-
return withReattach((c) => c.listDirectClientInbox(request));
|
|
325
|
-
},
|
|
326
|
-
async *subscribeDirectClientInbox(cursor) {
|
|
327
|
-
yield* withReattachStream((c) => c.subscribeDirectClientInbox(cursor));
|
|
328
|
-
},
|
|
329
|
-
appendSessionMessages(sessionId, messages) {
|
|
330
|
-
return withReattach((c) => c.appendSessionMessages(sessionId, messages));
|
|
331
|
-
},
|
|
332
|
-
markSessionCompleted(sessionId) {
|
|
333
|
-
return withReattach((c) => c.markSessionCompleted(sessionId));
|
|
334
|
-
},
|
|
335
|
-
replaceSessionMessages(sessionId, messages) {
|
|
336
|
-
return withReattach((c) => c.replaceSessionMessages(sessionId, messages));
|
|
337
|
-
},
|
|
338
|
-
startAutonomousLoop(input) {
|
|
339
|
-
return withReattach((c) => c.startAutonomousLoop?.(input) ??
|
|
340
|
-
Promise.reject(new Error("startAutonomousLoop not available")));
|
|
341
|
-
},
|
|
342
|
-
stopAutonomousLoop() {
|
|
343
|
-
return withReattach((c) => c.stopAutonomousLoop?.() ?? Promise.reject(new Error("stopAutonomousLoop not available")));
|
|
344
|
-
},
|
|
345
|
-
getConnectionState() {
|
|
346
|
-
return currentState;
|
|
347
|
-
},
|
|
348
|
-
getClientId() {
|
|
349
|
-
return currentClientId;
|
|
350
|
-
},
|
|
351
|
-
getClientAuthToken() {
|
|
352
|
-
return currentClientAuthToken;
|
|
353
|
-
},
|
|
354
|
-
__ariaLazyControl: true,
|
|
355
|
-
onConnectionStateChange(listener) {
|
|
356
|
-
stateListeners.add(listener);
|
|
357
|
-
return () => {
|
|
358
|
-
stateListeners.delete(listener);
|
|
359
|
-
};
|
|
360
|
-
},
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
//# sourceMappingURL=local-control-lazy-wrapper.js.map
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { createResilientAttachedClient } from "./attached-local-control-client.js";
|
|
3
|
-
import { createLazyAttachedLocalControlApi } from "./local-control-lazy-wrapper.js";
|
|
4
|
-
import { log } from "@aria-cli/types";
|
|
5
|
-
/**
|
|
6
|
-
* Process-wide local-control manager for the CLI process.
|
|
7
|
-
*
|
|
8
|
-
* Responsibilities:
|
|
9
|
-
* - owns the single active AttachedLocalControlClient/control used by the REPL process
|
|
10
|
-
* - exposes one authoritative control object for all consumers (REPL UI,
|
|
11
|
-
* direct subscriptions, HeadlessKernel, SessionHistory IPC)
|
|
12
|
-
* - forwards connection-state events from the active control
|
|
13
|
-
* - allows future client replacement without consumers chasing instances
|
|
14
|
-
*/
|
|
15
|
-
let singletonInstance = null;
|
|
16
|
-
export class LocalControlManager {
|
|
17
|
-
attached;
|
|
18
|
-
listeners = new Set();
|
|
19
|
-
innerUnsub = null;
|
|
20
|
-
state = "connected";
|
|
21
|
-
stale = false;
|
|
22
|
-
released = false;
|
|
23
|
-
runtimeSocket = null;
|
|
24
|
-
managedControl;
|
|
25
|
-
/**
|
|
26
|
-
* Creates the process-wide LocalControlManager singleton.
|
|
27
|
-
* Throws if one already exists — use release() first.
|
|
28
|
-
*/
|
|
29
|
-
constructor(attached) {
|
|
30
|
-
if (singletonInstance) {
|
|
31
|
-
throw new Error("LocalControlManager: another instance already exists. " +
|
|
32
|
-
"Call release() on the existing instance before creating a new one.");
|
|
33
|
-
}
|
|
34
|
-
singletonInstance = this;
|
|
35
|
-
this.attached = attached;
|
|
36
|
-
this.stale = false;
|
|
37
|
-
this.managedControl = createLazyAttachedLocalControlApi(async () => {
|
|
38
|
-
if (!this.stale) {
|
|
39
|
-
return this.attached?.control ?? attached.control;
|
|
40
|
-
}
|
|
41
|
-
const server = await import("@aria-cli/server");
|
|
42
|
-
const ariaDir = process.env.ARIA_HOME ?? `${process.env.HOME}/.aria`;
|
|
43
|
-
const runtimeRoot = server.resolveRuntimeRootDirectory();
|
|
44
|
-
const owner = server.findRuntimeOwnerRecordByAriaHome(runtimeRoot, ariaDir);
|
|
45
|
-
if (!owner?.runtimeSocket) {
|
|
46
|
-
throw new Error("Cannot reconnect: no daemon found after restart");
|
|
47
|
-
}
|
|
48
|
-
const resilient = await createResilientAttachedClient({
|
|
49
|
-
runtimeSocket: owner.runtimeSocket,
|
|
50
|
-
clientKind: "local-api",
|
|
51
|
-
logDir: join(ariaDir, "logs"),
|
|
52
|
-
});
|
|
53
|
-
return resilient.api;
|
|
54
|
-
}, () => {
|
|
55
|
-
this.stale = true;
|
|
56
|
-
}, process.env.ARIA_HOME ?? `${process.env.HOME}/.aria`);
|
|
57
|
-
this.bind(attached);
|
|
58
|
-
}
|
|
59
|
-
emit(next) {
|
|
60
|
-
if (next === this.state)
|
|
61
|
-
return;
|
|
62
|
-
this.state = next;
|
|
63
|
-
for (const fn of this.listeners) {
|
|
64
|
-
try {
|
|
65
|
-
fn(next);
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
// Never let listeners break the manager.
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
bind(attached) {
|
|
73
|
-
this.innerUnsub?.();
|
|
74
|
-
this.innerUnsub = null;
|
|
75
|
-
this.attached = attached;
|
|
76
|
-
const control = this.managedControl;
|
|
77
|
-
const current = control.getConnectionState?.() ?? attached.getConnectionState?.() ?? "connected";
|
|
78
|
-
this.emit(current);
|
|
79
|
-
const subscribe = control.onConnectionStateChange;
|
|
80
|
-
if (subscribe) {
|
|
81
|
-
this.innerUnsub = subscribe((next) => this.emit(next));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
/** Replace the active attached client while keeping all consumers on one stable manager. */
|
|
85
|
-
replaceAttached(attached) {
|
|
86
|
-
if (this.released) {
|
|
87
|
-
throw new Error("LocalControlManager: cannot replace attached client after release(). " +
|
|
88
|
-
"Create a new manager instead.");
|
|
89
|
-
}
|
|
90
|
-
log.debug(`[LocalControlManager] Replacing attached client runtime=${attached.runtimeId} node=${attached.nodeId}`);
|
|
91
|
-
this.stale = false;
|
|
92
|
-
this.bind(attached);
|
|
93
|
-
}
|
|
94
|
-
getControl() {
|
|
95
|
-
return this.managedControl;
|
|
96
|
-
}
|
|
97
|
-
getAttached() {
|
|
98
|
-
return this.attached;
|
|
99
|
-
}
|
|
100
|
-
getCredentials() {
|
|
101
|
-
const control = this.managedControl;
|
|
102
|
-
const clientId = control.getClientId?.() ?? this.attached?.attachedClientId;
|
|
103
|
-
const clientAuthToken = control.getClientAuthToken?.() ?? this.attached?.attachedClientAuthToken;
|
|
104
|
-
if (!clientId || !clientAuthToken)
|
|
105
|
-
return null;
|
|
106
|
-
return { clientId, clientAuthToken };
|
|
107
|
-
}
|
|
108
|
-
async resolveRuntimeSocket() {
|
|
109
|
-
if (this.runtimeSocket)
|
|
110
|
-
return this.runtimeSocket;
|
|
111
|
-
try {
|
|
112
|
-
const server = await import("@aria-cli/server");
|
|
113
|
-
const ariaDir = process.env.ARIA_HOME ?? `${process.env.HOME}/.aria`;
|
|
114
|
-
const root = server.resolveRuntimeRootDirectory();
|
|
115
|
-
this.runtimeSocket =
|
|
116
|
-
server.findRuntimeOwnerRecordByAriaHome(root, ariaDir)?.runtimeSocket ?? null;
|
|
117
|
-
return this.runtimeSocket;
|
|
118
|
-
}
|
|
119
|
-
catch {
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
getState() {
|
|
124
|
-
return this.state;
|
|
125
|
-
}
|
|
126
|
-
onStateChange(listener) {
|
|
127
|
-
this.listeners.add(listener);
|
|
128
|
-
return () => {
|
|
129
|
-
this.listeners.delete(listener);
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
async release() {
|
|
133
|
-
if (this.released)
|
|
134
|
-
return;
|
|
135
|
-
this.released = true;
|
|
136
|
-
this.innerUnsub?.();
|
|
137
|
-
this.innerUnsub = null;
|
|
138
|
-
const attached = this.attached;
|
|
139
|
-
this.attached = null;
|
|
140
|
-
if (singletonInstance === this) {
|
|
141
|
-
singletonInstance = null;
|
|
142
|
-
}
|
|
143
|
-
await attached?.release().catch(() => { });
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
//# sourceMappingURL=local-control-manager.js.map
|
package/dist/main.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import "./runtime/configure-bun-sqlite.js";
|
|
2
|
-
import { installProcessCrashHandlers } from "./runtime/crash-handlers.js";
|
|
3
|
-
import { installOwnerLeaseIfNeeded } from "./runtime/owner-lease.js";
|
|
4
|
-
import { parseInternalInvocation } from "./runtime/internal-mode.js";
|
|
5
|
-
import { isPublicCommandInvocation } from "./runtime/public-mode.js";
|
|
6
|
-
import { runInternalMode } from "./runtime/run-internal-mode.js";
|
|
7
|
-
import { runCommandMode } from "./entrypoints/command-mode.js";
|
|
8
|
-
import { runInteractiveEntrypoint } from "./entrypoints/interactive.js";
|
|
9
|
-
import { parseInteractiveInvocation } from "./runtime/interactive-invocation.js";
|
|
10
|
-
import { isChildProcess, superviseInteractiveSession } from "./relaunch.js";
|
|
11
|
-
export async function main(argv = process.argv) {
|
|
12
|
-
installProcessCrashHandlers();
|
|
13
|
-
installOwnerLeaseIfNeeded();
|
|
14
|
-
const userArgs = argv.slice(2);
|
|
15
|
-
const internal = parseInternalInvocation(userArgs);
|
|
16
|
-
if (internal) {
|
|
17
|
-
await runInternalMode(internal);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (isPublicCommandInvocation(userArgs)) {
|
|
21
|
-
await runCommandMode(argv);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const interactive = parseInteractiveInvocation(userArgs);
|
|
25
|
-
if (isChildProcess()) {
|
|
26
|
-
await runInteractiveEntrypoint(interactive);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
await superviseInteractiveSession(interactive);
|
|
30
|
-
}
|
|
31
|
-
if (import.meta.main) {
|
|
32
|
-
main(process.argv).catch((error) => {
|
|
33
|
-
const message = error instanceof Error ? (error.stack ?? error.message) : String(error);
|
|
34
|
-
process.stderr.write(`${message}\n`);
|
|
35
|
-
process.exit(1);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=main.js.map
|
package/dist/network-security.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import * as nodePath from "node:path";
|
|
3
|
-
import { PrincipalFingerprintSchema, SigningPublicKeySchema, TlsCaFingerprintSchema, } from "@aria-cli/tools/network-runtime";
|
|
4
|
-
const LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "::1"]);
|
|
5
|
-
export function isLocalCoordinationHost(hostname) {
|
|
6
|
-
if (LOCAL_HOSTS.has(hostname))
|
|
7
|
-
return true;
|
|
8
|
-
return hostname.toLowerCase().endsWith(".localhost");
|
|
9
|
-
}
|
|
10
|
-
export function parseAndValidateCoordinationUrl(rawUrl) {
|
|
11
|
-
let parsed;
|
|
12
|
-
try {
|
|
13
|
-
parsed = new URL(rawUrl);
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
throw new Error(`Invalid coordination URL: ${rawUrl}`);
|
|
17
|
-
}
|
|
18
|
-
const hostname = parsed.hostname.toLowerCase();
|
|
19
|
-
if (parsed.protocol === "https:")
|
|
20
|
-
return parsed;
|
|
21
|
-
if (parsed.protocol === "http:" && isLocalCoordinationHost(hostname))
|
|
22
|
-
return parsed;
|
|
23
|
-
throw new Error(`Insecure coordination URL "${rawUrl}". Use https:// (http:// allowed only for localhost).`);
|
|
24
|
-
}
|
|
25
|
-
export function normalizeTlsCaFingerprintId(fingerprint) {
|
|
26
|
-
const normalized = TlsCaFingerprintSchema.parse(fingerprint).trim().toLowerCase();
|
|
27
|
-
if (!/^[a-f0-9]{16,128}$/.test(normalized)) {
|
|
28
|
-
throw new Error("Invalid fingerprint format for trusted CA path");
|
|
29
|
-
}
|
|
30
|
-
return normalized;
|
|
31
|
-
}
|
|
32
|
-
function normalizePrincipalFingerprintId(fingerprint) {
|
|
33
|
-
const normalized = PrincipalFingerprintSchema.parse(fingerprint).trim().toLowerCase();
|
|
34
|
-
if (!/^[a-f0-9]{16,128}$/.test(normalized)) {
|
|
35
|
-
throw new Error("Invalid fingerprint format for responder identity");
|
|
36
|
-
}
|
|
37
|
-
return normalized;
|
|
38
|
-
}
|
|
39
|
-
export function trustedCaPathForFingerprint(ariaDir, fingerprint) {
|
|
40
|
-
const id = normalizeTlsCaFingerprintId(fingerprint);
|
|
41
|
-
const trustedDir = nodePath.resolve(nodePath.join(ariaDir, "network", "trusted-cas"));
|
|
42
|
-
const targetPath = nodePath.resolve(nodePath.join(trustedDir, `${id}.pem`));
|
|
43
|
-
if (!targetPath.startsWith(`${trustedDir}${nodePath.sep}`)) {
|
|
44
|
-
throw new Error("Trusted CA path escapes trusted-cas directory");
|
|
45
|
-
}
|
|
46
|
-
return targetPath;
|
|
47
|
-
}
|
|
48
|
-
export function signingKeyFingerprintHex(signingPublicKeyB64) {
|
|
49
|
-
return PrincipalFingerprintSchema.parse(createHash("sha256")
|
|
50
|
-
.update(Buffer.from(SigningPublicKeySchema.parse(signingPublicKeyB64), "base64"))
|
|
51
|
-
.digest("hex"));
|
|
52
|
-
}
|
|
53
|
-
export function assertResponderIdentityMatchesExpectedFingerprint(expectedFingerprint, responderSigningPublicKeyB64) {
|
|
54
|
-
if (!expectedFingerprint)
|
|
55
|
-
return;
|
|
56
|
-
const expected = normalizePrincipalFingerprintId(expectedFingerprint);
|
|
57
|
-
const actual = signingKeyFingerprintHex(responderSigningPublicKeyB64);
|
|
58
|
-
if (!(actual === expected || actual.startsWith(expected))) {
|
|
59
|
-
throw new Error("Responder signing key fingerprint mismatch");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=network-security.js.map
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI adapter over the real server-owned NodeRuntime.
|
|
3
|
-
*
|
|
4
|
-
* Machine-local attach/start semantics now route through the server-owned
|
|
5
|
-
* HostSupervisor. This file is only the CLI adapter layer.
|
|
6
|
-
*/
|
|
7
|
-
import { HostSupervisorSplitBrainError, getHostSupervisor, } from "@aria-cli/server";
|
|
8
|
-
/**
|
|
9
|
-
* Start the ARIA networking server — shared between interactive and daemon modes.
|
|
10
|
-
* Returns null if this arion is already running (caller should use client mode).
|
|
11
|
-
*/
|
|
12
|
-
export async function ensureNetworkingServer(opts) {
|
|
13
|
-
const supervisor = getHostSupervisor();
|
|
14
|
-
let attachment;
|
|
15
|
-
try {
|
|
16
|
-
attachment = await supervisor.attach({
|
|
17
|
-
...opts,
|
|
18
|
-
clientKind: "daemon-launcher",
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
if (error instanceof HostSupervisorSplitBrainError) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
const cleanup = async () => {
|
|
28
|
-
attachment.release();
|
|
29
|
-
if (attachment.ownership === "started") {
|
|
30
|
-
await supervisor.shutdownRuntime(attachment.nodeId);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
return {
|
|
34
|
-
...attachment.runtime,
|
|
35
|
-
cleanup,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=networking-server.js.map
|
package/dist/peer-identity.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export function discoveredPeerIdentityKey(peer) {
|
|
2
|
-
const nodeId = typeof peer.nodeId === "string" ? peer.nodeId.trim() : "";
|
|
3
|
-
const transport = typeof peer.transport === "string" ? peer.transport : "unknown";
|
|
4
|
-
if (nodeId) {
|
|
5
|
-
return `node:${nodeId}`;
|
|
6
|
-
}
|
|
7
|
-
const principalFingerprint = typeof peer.principalFingerprint === "string" ? peer.principalFingerprint.trim() : "";
|
|
8
|
-
if (principalFingerprint) {
|
|
9
|
-
return `principal:${principalFingerprint}`;
|
|
10
|
-
}
|
|
11
|
-
return `endpoint:${transport}:${peer.host}:${peer.port}:${peer.displayNameSnapshot}`;
|
|
12
|
-
}
|
|
13
|
-
export function mergeDiscoveredPeersByIdentity(preferredPeers, additionalPeers) {
|
|
14
|
-
const merged = new Map();
|
|
15
|
-
for (const peer of [...preferredPeers, ...additionalPeers]) {
|
|
16
|
-
const key = discoveredPeerIdentityKey(peer);
|
|
17
|
-
if (!merged.has(key)) {
|
|
18
|
-
merged.set(key, peer);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return [...merged.values()];
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=peer-identity.js.map
|