@aria-cli/cli 1.0.57 → 1.0.59

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.
Files changed (319) hide show
  1. package/bin/aria.mjs +799 -668
  2. package/package.json +17 -76
  3. package/dist/.tsbuildinfo +0 -1
  4. package/dist/attached-local-control-client.js +0 -826
  5. package/dist/bootstrap-local-control-client.js +0 -2
  6. package/dist/capability-aware-method-proxy.js +0 -42
  7. package/dist/cli-context.js +0 -160
  8. package/dist/commands/arions.js +0 -174
  9. package/dist/commands/auth.js +0 -123
  10. package/dist/commands/daemon.js +0 -367
  11. package/dist/commands/definitions.js +0 -176
  12. package/dist/commands/index.js +0 -80
  13. package/dist/commands/login-handler.js +0 -1108
  14. package/dist/commands/logout-handler.js +0 -92
  15. package/dist/commands/memory-handlers.js +0 -89
  16. package/dist/commands/pairing.js +0 -60
  17. package/dist/commands/runtime-cutover-reset-command.js +0 -12
  18. package/dist/commands/runtime-cutover-reset.js +0 -265
  19. package/dist/commands/terminal-setup.js +0 -84
  20. package/dist/config/aria-config.js +0 -238
  21. package/dist/config/index.js +0 -3
  22. package/dist/config/loader.js +0 -97
  23. package/dist/config.js +0 -142
  24. package/dist/daemon-info.js +0 -10
  25. package/dist/ensure-daemon.js +0 -128
  26. package/dist/entrypoints/command-mode.js +0 -5
  27. package/dist/entrypoints/daemon.js +0 -50
  28. package/dist/entrypoints/headless-stdio.js +0 -25
  29. package/dist/entrypoints/interactive.js +0 -80
  30. package/dist/event-loop-watchdog.js +0 -73
  31. package/dist/headless/auth-orchestrator.js +0 -508
  32. package/dist/headless/auth-service.js +0 -43
  33. package/dist/headless/bootstrap-fast-path.js +0 -112
  34. package/dist/headless/call-command.js +0 -143
  35. package/dist/headless/daemon-service.js +0 -318
  36. package/dist/headless/hook-actions.js +0 -235
  37. package/dist/headless/hook-service.js +0 -42
  38. package/dist/headless/kernel-services.js +0 -216
  39. package/dist/headless/kernel.js +0 -785
  40. package/dist/headless/operations/arion.js +0 -119
  41. package/dist/headless/operations/auth.js +0 -45
  42. package/dist/headless/operations/client.js +0 -31
  43. package/dist/headless/operations/config.js +0 -69
  44. package/dist/headless/operations/daemon.js +0 -47
  45. package/dist/headless/operations/hook.js +0 -56
  46. package/dist/headless/operations/index.js +0 -11
  47. package/dist/headless/operations/memory.js +0 -102
  48. package/dist/headless/operations/message.js +0 -279
  49. package/dist/headless/operations/model.js +0 -100
  50. package/dist/headless/operations/peer.js +0 -56
  51. package/dist/headless/operations/run.js +0 -24
  52. package/dist/headless/operations/session.js +0 -90
  53. package/dist/headless/operations/system.js +0 -19
  54. package/dist/headless/operations/utils.js +0 -35
  55. package/dist/headless/run-orchestrator.js +0 -703
  56. package/dist/headless/stdio-server.js +0 -439
  57. package/dist/history/SessionHistory.js +0 -8
  58. package/dist/history/SessionHistoryClient.js +0 -186
  59. package/dist/history/conversation-message.js +0 -112
  60. package/dist/history/index.js +0 -8
  61. package/dist/history/jsonl-replay.js +0 -154
  62. package/dist/history/repair-tool-pairing.js +0 -84
  63. package/dist/history/stall-phase-bridge.js +0 -11
  64. package/dist/history/turn-accumulator.js +0 -427
  65. package/dist/index.js +0 -7
  66. package/dist/ink-repl.js +0 -4183
  67. package/dist/local-control-bootstrap.js +0 -26
  68. package/dist/local-control-client.js +0 -2
  69. package/dist/local-control-error-reporting.js +0 -34
  70. package/dist/local-control-http-client.js +0 -362
  71. package/dist/local-control-lazy-wrapper.js +0 -363
  72. package/dist/local-control-manager.js +0 -146
  73. package/dist/main.js +0 -62
  74. package/dist/network-security.js +0 -62
  75. package/dist/networking-server.js +0 -38
  76. package/dist/peer-identity.js +0 -23
  77. package/dist/polling-subscription.js +0 -34
  78. package/dist/relaunch.js +0 -617
  79. package/dist/release-notes.js +0 -35
  80. package/dist/repl-cleanup.js +0 -47
  81. package/dist/runtime/configure-bun-sqlite.js +0 -3
  82. package/dist/runtime/crash-handlers.js +0 -111
  83. package/dist/runtime/interactive-invocation.js +0 -39
  84. package/dist/runtime/internal-mode.js +0 -14
  85. package/dist/runtime/launch-spec.js +0 -64
  86. package/dist/runtime/owner-lease.js +0 -44
  87. package/dist/runtime/public-mode.js +0 -20
  88. package/dist/runtime/run-internal-mode.js +0 -18
  89. package/dist/runtime/runtime-kind.js +0 -32
  90. package/dist/runtime/spawn-aria.js +0 -38
  91. package/dist/selectable-client.js +0 -2
  92. package/dist/selectable-peer.js +0 -2
  93. package/dist/session.js +0 -203
  94. package/dist/slash-commands.js +0 -80
  95. package/dist/sounds.js +0 -210
  96. package/dist/ui/App.js +0 -526
  97. package/dist/ui/components/AnthropicMethodPicker.js +0 -6
  98. package/dist/ui/components/ArionPrompt.js +0 -15
  99. package/dist/ui/components/AutocompleteDropdown.js +0 -23
  100. package/dist/ui/components/AutonomySelector.js +0 -55
  101. package/dist/ui/components/Banner.js +0 -98
  102. package/dist/ui/components/ConversationHistory.js +0 -175
  103. package/dist/ui/components/CopilotDeviceLoginFlow.js +0 -88
  104. package/dist/ui/components/CopilotSourcePicker.js +0 -50
  105. package/dist/ui/components/Cost.js +0 -10
  106. package/dist/ui/components/CustomSelect/option-map.js +0 -30
  107. package/dist/ui/components/CustomSelect/select-option.js +0 -13
  108. package/dist/ui/components/CustomSelect/select.js +0 -42
  109. package/dist/ui/components/CustomSelect/use-select-state.js +0 -179
  110. package/dist/ui/components/CustomSelect/use-select.js +0 -15
  111. package/dist/ui/components/ErrorDisplay.js +0 -35
  112. package/dist/ui/components/FallbackToolUseRejectedMessage.js +0 -7
  113. package/dist/ui/components/FileEditToolUpdatedMessage.js +0 -57
  114. package/dist/ui/components/HandoffMarker.js +0 -18
  115. package/dist/ui/components/HighlightedCode.js +0 -21
  116. package/dist/ui/components/InputArea.js +0 -187
  117. package/dist/ui/components/Message.js +0 -25
  118. package/dist/ui/components/OAuthLoginFlow.js +0 -113
  119. package/dist/ui/components/OutputTruncation.js +0 -35
  120. package/dist/ui/components/PermissionPrompt.js +0 -79
  121. package/dist/ui/components/PipelineTimingPanel.js +0 -15
  122. package/dist/ui/components/ProviderMethodPicker.js +0 -61
  123. package/dist/ui/components/ProviderPicker.js +0 -63
  124. package/dist/ui/components/RenderItemView.js +0 -71
  125. package/dist/ui/components/Spinner.js +0 -46
  126. package/dist/ui/components/StatusBar.js +0 -95
  127. package/dist/ui/components/StreamingIndicator.js +0 -55
  128. package/dist/ui/components/StructuredDiff.js +0 -168
  129. package/dist/ui/components/TextInputOverlay.js +0 -43
  130. package/dist/ui/components/ThinkingBlock.js +0 -82
  131. package/dist/ui/components/ToolCost.js +0 -17
  132. package/dist/ui/components/ToolExecution.js +0 -61
  133. package/dist/ui/components/ToolHeader.js +0 -51
  134. package/dist/ui/components/ToolRenderLayoutContext.js +0 -14
  135. package/dist/ui/components/ToolResultWrapper.js +0 -6
  136. package/dist/ui/components/ToolUseLoader.js +0 -35
  137. package/dist/ui/components/TraceWaterfall.js +0 -91
  138. package/dist/ui/components/index.js +0 -33
  139. package/dist/ui/components/messages/AssistantTextMessage.js +0 -25
  140. package/dist/ui/components/messages/UserImageMessage.js +0 -12
  141. package/dist/ui/components/messages/UserTextMessage.js +0 -12
  142. package/dist/ui/components/overlays/ArionSelector.js +0 -68
  143. package/dist/ui/components/overlays/ClientSelector.js +0 -62
  144. package/dist/ui/components/overlays/CommandPalette.js +0 -67
  145. package/dist/ui/components/overlays/DaemonControl.js +0 -87
  146. package/dist/ui/components/overlays/InviteShareOverlay.js +0 -15
  147. package/dist/ui/components/overlays/JoinInviteOverlay.js +0 -32
  148. package/dist/ui/components/overlays/MemoryBrowser.js +0 -100
  149. package/dist/ui/components/overlays/MessageSelector.js +0 -123
  150. package/dist/ui/components/overlays/ModelSelector.js +0 -211
  151. package/dist/ui/components/overlays/PairRequestOverlay.js +0 -42
  152. package/dist/ui/components/overlays/PeerSelector.js +0 -84
  153. package/dist/ui/components/overlays/SessionSelector.js +0 -102
  154. package/dist/ui/components/overlays/SoundSelector.js +0 -86
  155. package/dist/ui/components/overlays/ThemeSelector.js +0 -139
  156. package/dist/ui/components/overlays/index.js +0 -15
  157. package/dist/ui/components/permissions/BashPermissionRequest/BashPermissionRequest.js +0 -53
  158. package/dist/ui/components/permissions/FallbackPermissionRequest.js +0 -56
  159. package/dist/ui/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.js +0 -76
  160. package/dist/ui/components/permissions/FileEditPermissionRequest/FileEditToolDiff.js +0 -18
  161. package/dist/ui/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.js +0 -64
  162. package/dist/ui/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.js +0 -26
  163. package/dist/ui/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js +0 -141
  164. package/dist/ui/components/permissions/PermissionRequest.js +0 -70
  165. package/dist/ui/components/permissions/PermissionRequestTitle.js +0 -41
  166. package/dist/ui/components/permissions/hooks.js +0 -10
  167. package/dist/ui/components/permissions/toolUseOptions.js +0 -68
  168. package/dist/ui/components/permissions/utils.js +0 -10
  169. package/dist/ui/components/text-input/Cursor.js +0 -326
  170. package/dist/ui/components/text-input/TextInput.js +0 -231
  171. package/dist/ui/components/text-input/imagePaste.js +0 -28
  172. package/dist/ui/components/text-input/index.js +0 -6
  173. package/dist/ui/components/text-input/useDoublePress.js +0 -30
  174. package/dist/ui/components/text-input/useTextInput.js +0 -245
  175. package/dist/ui/components/tool-types.js +0 -9
  176. package/dist/ui/constants/figures.js +0 -4
  177. package/dist/ui/constants/index.js +0 -3
  178. package/dist/ui/display-mode.js +0 -93
  179. package/dist/ui/display-policy.js +0 -19
  180. package/dist/ui/hooks/index.js +0 -6
  181. package/dist/ui/hooks/useCommandAutocomplete.js +0 -93
  182. package/dist/ui/hooks/useDoublePress.js +0 -37
  183. package/dist/ui/hooks/useIndicatorState.js +0 -55
  184. package/dist/ui/hooks/useInterval.js +0 -23
  185. package/dist/ui/hooks/useKeyboardShortcuts.js +0 -127
  186. package/dist/ui/hooks/useTerminalSize.js +0 -55
  187. package/dist/ui/hooks/useUnifiedMessages.js +0 -117
  188. package/dist/ui/indicator-state.js +0 -44
  189. package/dist/ui/markdown/highlight.js +0 -44
  190. package/dist/ui/markdown/index.js +0 -1460
  191. package/dist/ui/markdown/tokenizer.js +0 -24
  192. package/dist/ui/render-item.js +0 -5
  193. package/dist/ui/screens/REPL.js +0 -119
  194. package/dist/ui/screens/approval-lifecycle.js +0 -38
  195. package/dist/ui/status-line.js +0 -72
  196. package/dist/ui/theme/index.js +0 -51
  197. package/dist/ui/theme/themes/claude-dark-daltonized.js +0 -51
  198. package/dist/ui/theme/themes/claude-dark.js +0 -50
  199. package/dist/ui/theme/themes/claude-light-daltonized.js +0 -51
  200. package/dist/ui/theme/themes/claude-light.js +0 -50
  201. package/dist/ui/theme/themes/dark-accessible.js +0 -18
  202. package/dist/ui/theme/themes/dark.js +0 -49
  203. package/dist/ui/theme/themes/light-accessible.js +0 -18
  204. package/dist/ui/theme/themes/light.js +0 -49
  205. package/dist/ui/theme/types.js +0 -3
  206. package/dist/ui/theme.js +0 -142
  207. package/dist/ui/to-render-items.js +0 -145
  208. package/dist/ui/tools/AgentTool/index.js +0 -30
  209. package/dist/ui/tools/ArchitectTool/index.js +0 -31
  210. package/dist/ui/tools/AskUserTool/index.js +0 -46
  211. package/dist/ui/tools/BashTool/BashToolResultMessage.js +0 -11
  212. package/dist/ui/tools/BashTool/OutputLine.js +0 -21
  213. package/dist/ui/tools/BashTool/index.js +0 -91
  214. package/dist/ui/tools/BrowseTool/index.js +0 -43
  215. package/dist/ui/tools/BrowserTool/index.js +0 -47
  216. package/dist/ui/tools/CbmTool/index.js +0 -188
  217. package/dist/ui/tools/CheckDelegationTool/index.js +0 -46
  218. package/dist/ui/tools/CheckMessagesTool/index.js +0 -85
  219. package/dist/ui/tools/CreateQuipTool/index.js +0 -30
  220. package/dist/ui/tools/CreateSkillTool/index.js +0 -22
  221. package/dist/ui/tools/CreateToolTool/index.js +0 -31
  222. package/dist/ui/tools/DelegateRemoteTool/index.js +0 -42
  223. package/dist/ui/tools/DeployTool/index.js +0 -47
  224. package/dist/ui/tools/FffTool/index.js +0 -103
  225. package/dist/ui/tools/FileEditTool/index.js +0 -67
  226. package/dist/ui/tools/FileReadTool/index.js +0 -68
  227. package/dist/ui/tools/FileWriteTool/index.js +0 -61
  228. package/dist/ui/tools/ForkTool/index.js +0 -47
  229. package/dist/ui/tools/FrgTool/index.js +0 -96
  230. package/dist/ui/tools/GetThreadTool/index.js +0 -39
  231. package/dist/ui/tools/GlobTool/index.js +0 -50
  232. package/dist/ui/tools/GrepTool/index.js +0 -84
  233. package/dist/ui/tools/HatchArionTool/index.js +0 -36
  234. package/dist/ui/tools/LearnSkillTool/index.js +0 -22
  235. package/dist/ui/tools/LearnTool/index.js +0 -43
  236. package/dist/ui/tools/LearnToolTool/index.js +0 -22
  237. package/dist/ui/tools/ListClientsTool/index.js +0 -39
  238. package/dist/ui/tools/LspTool/index.js +0 -261
  239. package/dist/ui/tools/MCPTool/index.js +0 -33
  240. package/dist/ui/tools/ManageNetworkTool/index.js +0 -53
  241. package/dist/ui/tools/MemoryReadTool/index.js +0 -64
  242. package/dist/ui/tools/MemoryWriteTool/index.js +0 -20
  243. package/dist/ui/tools/NotebookEditTool/index.js +0 -33
  244. package/dist/ui/tools/NotebookReadTool/index.js +0 -25
  245. package/dist/ui/tools/OutlookReadTool/index.js +0 -66
  246. package/dist/ui/tools/OutlookReplyTool/index.js +0 -49
  247. package/dist/ui/tools/OutlookSendTool/index.js +0 -49
  248. package/dist/ui/tools/PauseDelegationTool/index.js +0 -35
  249. package/dist/ui/tools/ProbeTool/index.js +0 -121
  250. package/dist/ui/tools/ProcessTool/index.js +0 -66
  251. package/dist/ui/tools/QuestListTool/index.js +0 -46
  252. package/dist/ui/tools/QuestReportTool/index.js +0 -49
  253. package/dist/ui/tools/QuestUpdateTool/index.js +0 -87
  254. package/dist/ui/tools/QuipCommentTool/index.js +0 -69
  255. package/dist/ui/tools/QuipReadTool/index.js +0 -71
  256. package/dist/ui/tools/RestArionTool/index.js +0 -32
  257. package/dist/ui/tools/RestartTool/index.js +0 -35
  258. package/dist/ui/tools/ResumeDelegationTool/index.js +0 -35
  259. package/dist/ui/tools/RetireArionTool/index.js +0 -32
  260. package/dist/ui/tools/RgTool/index.js +0 -73
  261. package/dist/ui/tools/SearchKnowledgeTool/index.js +0 -43
  262. package/dist/ui/tools/SearchMessagesTool/index.js +0 -43
  263. package/dist/ui/tools/SelfDiagnoseTool/index.js +0 -61
  264. package/dist/ui/tools/SendMessageTool/index.js +0 -45
  265. package/dist/ui/tools/SerenaTool/index.js +0 -124
  266. package/dist/ui/tools/SessionHistoryTool/index.js +0 -52
  267. package/dist/ui/tools/SgTool/index.js +0 -80
  268. package/dist/ui/tools/SlackReactTool/index.js +0 -41
  269. package/dist/ui/tools/SlackReadTool/index.js +0 -48
  270. package/dist/ui/tools/SlackSendTool/index.js +0 -45
  271. package/dist/ui/tools/SpawnWorkerTool/index.js +0 -33
  272. package/dist/ui/tools/StickerRequestTool/index.js +0 -19
  273. package/dist/ui/tools/ThinkTool/index.js +0 -17
  274. package/dist/ui/tools/UgTool/index.js +0 -108
  275. package/dist/ui/tools/UseSkillTool/index.js +0 -22
  276. package/dist/ui/tools/WakeArionTool/index.js +0 -32
  277. package/dist/ui/tools/WebFetchTool/index.js +0 -56
  278. package/dist/ui/tools/WebSearchTool/index.js +0 -44
  279. package/dist/ui/tools/lsTool/index.js +0 -58
  280. package/dist/ui/tools/registry.js +0 -197
  281. package/dist/ui/tools/tool-renderer.js +0 -11
  282. package/dist/ui/tools/truncation.js +0 -35
  283. package/dist/ui/types/anthropic.js +0 -4
  284. package/dist/ui/types/index.js +0 -2
  285. package/dist/ui/types/message.js +0 -3
  286. package/dist/ui/types/tool.js +0 -4
  287. package/dist/ui/utils/array.js +0 -4
  288. package/dist/ui/utils/cursor.js +0 -131
  289. package/dist/ui/utils/diff.js +0 -120
  290. package/dist/ui/utils/format.js +0 -42
  291. package/dist/ui/utils/fuzzy.js +0 -59
  292. package/dist/ui/utils/index.js +0 -11
  293. package/dist/ui/utils/keys.js +0 -8
  294. package/dist/ui/utils/patch.js +0 -17
  295. package/dist/ui/utils/risk.js +0 -114
  296. package/dist/ui/utils/terminal-image.js +0 -70
  297. package/dist/ui/utils/validation.js +0 -48
  298. package/dist/ui/verb-pairs.js +0 -248
  299. package/dist/ui.js +0 -131
  300. package/src/entrypoints/command-mode.ts +0 -5
  301. package/src/entrypoints/daemon.ts +0 -54
  302. package/src/entrypoints/headless-stdio.ts +0 -27
  303. package/src/entrypoints/interactive.ts +0 -112
  304. package/src/main.ts +0 -72
  305. package/src/runtime/configure-bun-sqlite.ts +0 -3
  306. package/src/runtime/crash-handlers.ts +0 -128
  307. package/src/runtime/interactive-invocation.test.ts +0 -42
  308. package/src/runtime/interactive-invocation.ts +0 -51
  309. package/src/runtime/internal-mode.test.ts +0 -19
  310. package/src/runtime/internal-mode.ts +0 -24
  311. package/src/runtime/launch-spec.test.ts +0 -26
  312. package/src/runtime/launch-spec.ts +0 -84
  313. package/src/runtime/owner-lease.ts +0 -52
  314. package/src/runtime/public-mode.test.ts +0 -18
  315. package/src/runtime/public-mode.ts +0 -19
  316. package/src/runtime/run-internal-mode.ts +0 -19
  317. package/src/runtime/runtime-kind.test.ts +0 -23
  318. package/src/runtime/runtime-kind.ts +0 -41
  319. 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,62 +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 { parseInteractiveInvocation } from "./runtime/interactive-invocation.js";
7
- import { isChildProcess, superviseInteractiveSession } from "./relaunch.js";
8
- import { isCompiledRuntime } from "./runtime/runtime-kind.js";
9
- export async function main(argv = process.argv) {
10
- installProcessCrashHandlers();
11
- installOwnerLeaseIfNeeded();
12
- const userArgs = argv.slice(2);
13
- const internal = parseInternalInvocation(userArgs);
14
- if (internal) {
15
- const { runInternalMode } = await import("./runtime/run-internal-mode.js");
16
- await runInternalMode(internal);
17
- return;
18
- }
19
- if (isPublicCommandInvocation(userArgs)) {
20
- const { runCommandMode } = await import("./entrypoints/command-mode.js");
21
- await runCommandMode(argv);
22
- return;
23
- }
24
- const interactive = parseInteractiveInvocation(userArgs);
25
- if (isChildProcess()) {
26
- const { runInteractiveEntrypoint } = await import("./entrypoints/interactive.js");
27
- await runInteractiveEntrypoint(interactive);
28
- return;
29
- }
30
- // Compiled binary: run REPL directly in this process instead of spawning
31
- // a supervisor + child (which loads the 82MB binary twice). Saves ~3-13s
32
- // on cold start. Relaunch (rare) spawns a new process in supervisor mode.
33
- // ARIA_USE_SUPERVISOR is set by requestRelaunch() to force the supervisor
34
- // path on respawned processes, preventing waiter process accumulation.
35
- if (isCompiledRuntime() && !process.env.ARIA_USE_SUPERVISOR) {
36
- await runCompiledDirect(interactive);
37
- return;
38
- }
39
- await superviseInteractiveSession(interactive);
40
- }
41
- /**
42
- * Compiled-binary direct mode: run the REPL in-process (single binary load).
43
- *
44
- * The normal supervisor pattern loads the 82MB binary twice (parent + child).
45
- * In compiled mode, we skip the supervisor and run the REPL directly. If the
46
- * user requests a relaunch (rare), requestRelaunch() spawns a new process
47
- * with resume env vars — the current process waits and propagates exit code.
48
- */
49
- async function runCompiledDirect(interactive) {
50
- const { NO_RELAUNCH_ENV } = await import("@aria-cli/types");
51
- process.env[NO_RELAUNCH_ENV] = "true";
52
- const { runInteractiveEntrypoint } = await import("./entrypoints/interactive.js");
53
- await runInteractiveEntrypoint(interactive);
54
- }
55
- if (import.meta.main) {
56
- main(process.argv).catch((error) => {
57
- const message = error instanceof Error ? (error.stack ?? error.message) : String(error);
58
- process.stderr.write(`${message}\n`);
59
- process.exit(1);
60
- });
61
- }
62
- //# sourceMappingURL=main.js.map
@@ -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