@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,34 +0,0 @@
|
|
|
1
|
-
async function sleep(ms) {
|
|
2
|
-
await new Promise((resolve) => setTimeout(resolve, Math.max(ms, 0)));
|
|
3
|
-
}
|
|
4
|
-
export async function* createPollingSubscription(loadOnce, options = { pollIntervalMs: 1_000 }) {
|
|
5
|
-
const seenVersions = new Map();
|
|
6
|
-
let afterCreatedAt = options.initialAfterCreatedAt ?? 0;
|
|
7
|
-
while (true) {
|
|
8
|
-
const snapshot = await loadOnce();
|
|
9
|
-
let emitted = false;
|
|
10
|
-
for (const item of snapshot) {
|
|
11
|
-
const createdAt = options.getCursor?.(item);
|
|
12
|
-
if (typeof createdAt === "number" && createdAt < afterCreatedAt) {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
const identity = options.getIdentityKey?.(item);
|
|
16
|
-
if (typeof identity === "string") {
|
|
17
|
-
const versionKey = options.getVersionKey?.(item) ?? JSON.stringify(item);
|
|
18
|
-
if (seenVersions.get(identity) === versionKey) {
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
seenVersions.set(identity, versionKey);
|
|
22
|
-
}
|
|
23
|
-
if (typeof createdAt === "number") {
|
|
24
|
-
afterCreatedAt = Math.max(afterCreatedAt, createdAt);
|
|
25
|
-
}
|
|
26
|
-
emitted = true;
|
|
27
|
-
yield item;
|
|
28
|
-
}
|
|
29
|
-
if (!emitted) {
|
|
30
|
-
await sleep(options.pollIntervalMs);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=polling-subscription.js.map
|
package/dist/relaunch.js
DELETED
|
@@ -1,588 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @aria/cli - Relaunch / self-restart infrastructure
|
|
3
|
-
*
|
|
4
|
-
* Implements the parent-child supervisor pattern (inspired by gemini-cli):
|
|
5
|
-
*
|
|
6
|
-
* Parent process (supervisor)
|
|
7
|
-
* └─ spawns child with ARIA_NO_RELAUNCH=true, stdio: inherit
|
|
8
|
-
* └─ loops: if child exits with RELAUNCH_EXIT_CODE → respawn
|
|
9
|
-
* └─ otherwise: propagate exit code and exit
|
|
10
|
-
*
|
|
11
|
-
* Child process (actual ARIA)
|
|
12
|
-
* └─ runs the Ink REPL normally
|
|
13
|
-
* └─ on restart: requestRelaunch() → process.exit(RELAUNCH_EXIT_CODE)
|
|
14
|
-
* └─ supervisor catches it and respawns
|
|
15
|
-
*
|
|
16
|
-
* This replaces the fragile "detached spawn + kill self" approach
|
|
17
|
-
* with a reliable supervisor loop that inherits the terminal properly.
|
|
18
|
-
*/
|
|
19
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, readdirSync, } from "node:fs";
|
|
20
|
-
import { dirname, join, resolve } from "node:path";
|
|
21
|
-
import { NO_RELAUNCH_ENV, RELAUNCH_EXIT_CODE, RESUME_ARION_ENV, RESUME_SESSION_ENV, RESTART_KIND_ENV, clearRelaunchMarker as clearSharedRelaunchMarker, readRelaunchMarker as readSharedRelaunchMarker, writeRelaunchMarker as writeSharedRelaunchMarker, } from "@aria-cli/types";
|
|
22
|
-
import { getAriaDir } from "./config.js";
|
|
23
|
-
import { resolveAriaLaunchSpec } from "./runtime/launch-spec.js";
|
|
24
|
-
import { spawnAria } from "./runtime/spawn-aria.js";
|
|
25
|
-
export { NO_RELAUNCH_ENV, RELAUNCH_EXIT_CODE, RESUME_ARION_ENV, RESUME_SESSION_ENV, RESTART_KIND_ENV, } from "@aria-cli/types";
|
|
26
|
-
export function writeRelaunchMarker(marker) {
|
|
27
|
-
writeSharedRelaunchMarker(marker);
|
|
28
|
-
}
|
|
29
|
-
export function readRelaunchMarker(pid) {
|
|
30
|
-
return readSharedRelaunchMarker(pid);
|
|
31
|
-
}
|
|
32
|
-
export function clearRelaunchMarker(pid) {
|
|
33
|
-
clearSharedRelaunchMarker(pid);
|
|
34
|
-
}
|
|
35
|
-
function isIgnorableTerminalWriteError(error) {
|
|
36
|
-
if (!error || typeof error !== "object")
|
|
37
|
-
return false;
|
|
38
|
-
const maybe = error;
|
|
39
|
-
return maybe.code === "EPIPE" || maybe.code === "EIO" || maybe.code === "ERR_STREAM_DESTROYED";
|
|
40
|
-
}
|
|
41
|
-
function writeSupervisorStderr(message) {
|
|
42
|
-
try {
|
|
43
|
-
process.stderr.write(message);
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
if (isIgnorableTerminalWriteError(error)) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
throw error;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function isProcessExitSentinel(error) {
|
|
53
|
-
if (!error || typeof error !== "object") {
|
|
54
|
-
return error instanceof Error && /^exit:\d+$/.test(error.message);
|
|
55
|
-
}
|
|
56
|
-
if (error.__ariaProcessExit === true) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
return error instanceof Error && /^exit:\d+$/.test(error.message);
|
|
60
|
-
}
|
|
61
|
-
/** Maximum age (ms) for a relaunch marker to be considered valid. */
|
|
62
|
-
const RELAUNCH_MARKER_TTL_MS = 30_000;
|
|
63
|
-
let pendingResumeSessionId = process.env[RESUME_SESSION_ENV] ?? null;
|
|
64
|
-
let pendingArionName = process.env[RESUME_ARION_ENV] || "ARIA";
|
|
65
|
-
export function setPendingResumeSessionId(sessionId) {
|
|
66
|
-
const normalized = sessionId?.trim() || null;
|
|
67
|
-
pendingResumeSessionId = normalized;
|
|
68
|
-
if (normalized) {
|
|
69
|
-
process.env[RESUME_SESSION_ENV] = normalized;
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
delete process.env[RESUME_SESSION_ENV];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
export function getPendingResumeSessionId() {
|
|
76
|
-
return pendingResumeSessionId;
|
|
77
|
-
}
|
|
78
|
-
export function setPendingArionName(name) {
|
|
79
|
-
pendingArionName = name || "ARIA";
|
|
80
|
-
process.env[RESUME_ARION_ENV] = pendingArionName;
|
|
81
|
-
}
|
|
82
|
-
export function getPendingArionName() {
|
|
83
|
-
return pendingArionName;
|
|
84
|
-
}
|
|
85
|
-
function findBunWorkspaceRoot(startDir) {
|
|
86
|
-
let dir = resolve(startDir);
|
|
87
|
-
while (true) {
|
|
88
|
-
if (existsSync(join(dir, "bunfig.toml")) || existsSync(join(dir, "bun.lock")))
|
|
89
|
-
return dir;
|
|
90
|
-
const parent = dirname(dir);
|
|
91
|
-
if (parent === dir)
|
|
92
|
-
return null;
|
|
93
|
-
dir = parent;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
function getBunCommand() {
|
|
97
|
-
return process.platform === "win32" ? "bun.exe" : "bun";
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Rebuild workspace before relaunch (dev workflow).
|
|
101
|
-
*
|
|
102
|
-
* This is best-effort and only runs when a bun workspace root is detected.
|
|
103
|
-
*/
|
|
104
|
-
export async function rebuildWorkspaceIfPresent(startDir = process.cwd()) {
|
|
105
|
-
const root = findBunWorkspaceRoot(startDir);
|
|
106
|
-
if (!root)
|
|
107
|
-
return { attempted: false };
|
|
108
|
-
const started = Date.now();
|
|
109
|
-
const command = getBunCommand();
|
|
110
|
-
const proc = Bun.spawn([command, "run", "build"], {
|
|
111
|
-
cwd: root,
|
|
112
|
-
env: process.env,
|
|
113
|
-
stdin: "inherit",
|
|
114
|
-
stdout: "inherit",
|
|
115
|
-
stderr: "inherit",
|
|
116
|
-
});
|
|
117
|
-
const code = await proc.exited;
|
|
118
|
-
if (code !== 0) {
|
|
119
|
-
throw new Error(`bun run build failed with exit code ${code}`);
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
attempted: true,
|
|
123
|
-
root,
|
|
124
|
-
durationMs: Date.now() - started,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Returns true if we are already running inside a supervised child process.
|
|
129
|
-
*/
|
|
130
|
-
export function isChildProcess() {
|
|
131
|
-
return process.env[NO_RELAUNCH_ENV] === "true";
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Trigger a relaunch from the child process.
|
|
135
|
-
* Simply exits with the magic code — the parent supervisor handles the rest.
|
|
136
|
-
*/
|
|
137
|
-
export async function requestRelaunch(reason, resumeSessionId) {
|
|
138
|
-
if (!isChildProcess()) {
|
|
139
|
-
throw new Error("Restart requires RelaunchSupervisor; detached self-spawn has been removed.");
|
|
140
|
-
}
|
|
141
|
-
const logReason = reason || "Restart requested";
|
|
142
|
-
if (resumeSessionId !== undefined) {
|
|
143
|
-
setPendingResumeSessionId(resumeSessionId);
|
|
144
|
-
}
|
|
145
|
-
const sessionId = getPendingResumeSessionId();
|
|
146
|
-
const arionName = getPendingArionName();
|
|
147
|
-
writeSupervisorStderr(`[aria] Relaunch requested: ${logReason} (session=${sessionId?.slice(0, 8) ?? "none"}, arion=${arionName})\n`);
|
|
148
|
-
// Write disk-backed marker as durable fallback in case IPC is lost.
|
|
149
|
-
const markerPid = process.ppid || process.pid;
|
|
150
|
-
writeRelaunchMarker({
|
|
151
|
-
sessionId,
|
|
152
|
-
arionName,
|
|
153
|
-
pid: markerPid,
|
|
154
|
-
timestamp: new Date().toISOString(),
|
|
155
|
-
});
|
|
156
|
-
// If running as a supervised child with IPC enabled, inform the parent
|
|
157
|
-
// which session to auto-resume after respawn. Wait briefly for ack.
|
|
158
|
-
try {
|
|
159
|
-
const send = process.send;
|
|
160
|
-
if (typeof send === "function") {
|
|
161
|
-
const nonce = `${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
162
|
-
const acked = await new Promise((resolve) => {
|
|
163
|
-
let settled = false;
|
|
164
|
-
const timeout = setTimeout(() => {
|
|
165
|
-
if (settled)
|
|
166
|
-
return;
|
|
167
|
-
settled = true;
|
|
168
|
-
process.off("message", onMessage);
|
|
169
|
-
resolve(false);
|
|
170
|
-
}, 120);
|
|
171
|
-
const onMessage = (msg) => {
|
|
172
|
-
if (!msg || typeof msg !== "object")
|
|
173
|
-
return;
|
|
174
|
-
const payload = msg;
|
|
175
|
-
if (payload.type !== "aria-relaunch-ack")
|
|
176
|
-
return;
|
|
177
|
-
if (payload.nonce !== nonce)
|
|
178
|
-
return;
|
|
179
|
-
if (settled)
|
|
180
|
-
return;
|
|
181
|
-
settled = true;
|
|
182
|
-
clearTimeout(timeout);
|
|
183
|
-
process.off("message", onMessage);
|
|
184
|
-
resolve(true);
|
|
185
|
-
};
|
|
186
|
-
process.on("message", onMessage);
|
|
187
|
-
send({ type: "aria-relaunch", nonce, resumeSessionId: sessionId, arionName }, (err) => {
|
|
188
|
-
if (err && !settled) {
|
|
189
|
-
settled = true;
|
|
190
|
-
clearTimeout(timeout);
|
|
191
|
-
process.off("message", onMessage);
|
|
192
|
-
resolve(false);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
if (acked) {
|
|
197
|
-
writeSupervisorStderr(`[aria] IPC handoff acknowledged by supervisor\n`);
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
writeSupervisorStderr(`[aria] IPC ack timeout — disk marker will be used as fallback\n`);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
catch {
|
|
205
|
-
// Non-fatal: disk marker is the fallback.
|
|
206
|
-
}
|
|
207
|
-
process.exit(RELAUNCH_EXIT_CODE);
|
|
208
|
-
// Unreachable — satisfies TypeScript
|
|
209
|
-
throw new Error("Unreachable");
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Supervisor loop: spawns ARIA as a child process and respawns on RELAUNCH_EXIT_CODE.
|
|
213
|
-
*
|
|
214
|
-
* The child inherits the terminal (stdio: inherit) so the user experience
|
|
215
|
-
* is seamless. The parent just watches and re-executes when needed.
|
|
216
|
-
*
|
|
217
|
-
* @param scriptPath - Legacy compatibility label retained for tests/callers
|
|
218
|
-
* @param scriptArgs - Arguments to forward to the internal REPL mode
|
|
219
|
-
* @param nodeArgs - Legacy compatibility placeholder (ignored)
|
|
220
|
-
*/
|
|
221
|
-
/** Maximum consecutive crash restarts before giving up. */
|
|
222
|
-
const MAX_CRASH_RESTARTS = 3;
|
|
223
|
-
function getCrashStatePath(...parts) {
|
|
224
|
-
return join(getAriaDir(), ...parts);
|
|
225
|
-
}
|
|
226
|
-
function getCrashMarkerDir() {
|
|
227
|
-
return getCrashStatePath("crash-markers");
|
|
228
|
-
}
|
|
229
|
-
function getCrashMarkerPath(sessionId) {
|
|
230
|
-
return join(getCrashMarkerDir(), `${sessionId}.json`);
|
|
231
|
-
}
|
|
232
|
-
function readCrashMarker(sessionId) {
|
|
233
|
-
const markerPath = getCrashMarkerPath(sessionId);
|
|
234
|
-
if (!existsSync(markerPath))
|
|
235
|
-
return null;
|
|
236
|
-
try {
|
|
237
|
-
return JSON.parse(readFileSync(markerPath, "utf-8"));
|
|
238
|
-
}
|
|
239
|
-
catch {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
function writeCrashMarker(marker) {
|
|
244
|
-
try {
|
|
245
|
-
const dir = getCrashMarkerDir();
|
|
246
|
-
mkdirSync(dir, { recursive: true });
|
|
247
|
-
writeFileSync(getCrashMarkerPath(marker.sessionId), JSON.stringify(marker), "utf-8");
|
|
248
|
-
}
|
|
249
|
-
catch {
|
|
250
|
-
// Best-effort — don't crash the supervisor over crash tracking
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
function clearCrashMarker(sessionId) {
|
|
254
|
-
try {
|
|
255
|
-
const markerPath = getCrashMarkerPath(sessionId);
|
|
256
|
-
if (existsSync(markerPath))
|
|
257
|
-
unlinkSync(markerPath);
|
|
258
|
-
}
|
|
259
|
-
catch {
|
|
260
|
-
// Best-effort
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
function getCrashReportPath() {
|
|
264
|
-
return getCrashStatePath("crash-reports", "latest.json");
|
|
265
|
-
}
|
|
266
|
-
function abandonPoisonedResumeSession(sessionId, crashCount) {
|
|
267
|
-
writeSupervisorStderr(`[aria] Session ${sessionId} exceeded crash limit (${crashCount}/${MAX_CRASH_RESTARTS}). ` +
|
|
268
|
-
`Starting fresh instead of resuming.\n`);
|
|
269
|
-
clearCrashMarker(sessionId);
|
|
270
|
-
pendingResumeSessionId = null;
|
|
271
|
-
setPendingResumeSessionId(null);
|
|
272
|
-
}
|
|
273
|
-
function readAndClearCrashReport() {
|
|
274
|
-
const reportPath = getCrashReportPath();
|
|
275
|
-
if (!existsSync(reportPath))
|
|
276
|
-
return null;
|
|
277
|
-
try {
|
|
278
|
-
const raw = JSON.parse(readFileSync(reportPath, "utf-8"));
|
|
279
|
-
try {
|
|
280
|
-
unlinkSync(reportPath);
|
|
281
|
-
}
|
|
282
|
-
catch {
|
|
283
|
-
/* best effort */
|
|
284
|
-
}
|
|
285
|
-
return {
|
|
286
|
-
message: raw?.error?.message ?? "unknown",
|
|
287
|
-
stack: raw?.error?.stack ?? undefined,
|
|
288
|
-
heapMb: raw?.process?.heapUsedMb,
|
|
289
|
-
rssMb: raw?.process?.rssMb,
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
catch {
|
|
293
|
-
try {
|
|
294
|
-
unlinkSync(reportPath);
|
|
295
|
-
}
|
|
296
|
-
catch {
|
|
297
|
-
/* best effort */
|
|
298
|
-
}
|
|
299
|
-
return null;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Unified fallback resolver for recovering session context when IPC handoff
|
|
304
|
-
* is lost (child exited before parent received the message).
|
|
305
|
-
*
|
|
306
|
-
* Priority order:
|
|
307
|
-
* 1. Disk-backed relaunch marker (written by child before exit)
|
|
308
|
-
* 2. SessionHistory lookup (most recent incomplete session for the active arion)
|
|
309
|
-
*
|
|
310
|
-
* Used for both crash recovery AND explicit restart recovery.
|
|
311
|
-
*/
|
|
312
|
-
async function recoverResumeContext(currentArionName) {
|
|
313
|
-
// 1. Try disk-backed relaunch marker (namespaced by current child PID)
|
|
314
|
-
const marker = readRelaunchMarker(process.pid);
|
|
315
|
-
if (marker) {
|
|
316
|
-
const age = Date.now() - new Date(marker.timestamp).getTime();
|
|
317
|
-
if (age < RELAUNCH_MARKER_TTL_MS) {
|
|
318
|
-
clearRelaunchMarker(process.pid);
|
|
319
|
-
return {
|
|
320
|
-
sessionId: marker.sessionId,
|
|
321
|
-
arionName: marker.arionName || currentArionName,
|
|
322
|
-
source: "marker",
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
// Stale marker — clean up
|
|
326
|
-
clearRelaunchMarker(process.pid);
|
|
327
|
-
}
|
|
328
|
-
// 2. Query SessionHistory for most recent incomplete session
|
|
329
|
-
// First preferred arion, then scan other arions and choose most recently updated.
|
|
330
|
-
try {
|
|
331
|
-
const { SessionHistory } = await import("./history/index.js");
|
|
332
|
-
const { getAriaDir } = await import("./config.js");
|
|
333
|
-
const ariaDir = getAriaDir();
|
|
334
|
-
const candidateArions = new Set([currentArionName]);
|
|
335
|
-
const arionsDir = join(ariaDir, "arions");
|
|
336
|
-
if (existsSync(arionsDir)) {
|
|
337
|
-
for (const entry of readdirSync(arionsDir, { withFileTypes: true })) {
|
|
338
|
-
if (entry.isDirectory() && entry.name.trim()) {
|
|
339
|
-
candidateArions.add(entry.name.trim());
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
let best = null;
|
|
344
|
-
for (const arionName of candidateArions) {
|
|
345
|
-
const dbPath = SessionHistory.resolvePerArionPath(ariaDir, arionName);
|
|
346
|
-
if (!existsSync(dbPath))
|
|
347
|
-
continue;
|
|
348
|
-
const tmpHistory = new SessionHistory(dbPath);
|
|
349
|
-
try {
|
|
350
|
-
const incomplete = tmpHistory.getIncompleteSessions(1);
|
|
351
|
-
if (incomplete.length === 0)
|
|
352
|
-
continue;
|
|
353
|
-
const top = incomplete[0];
|
|
354
|
-
const updatedAtMs = top.updatedAt.getTime();
|
|
355
|
-
// Prefer current arion first when timestamps tie.
|
|
356
|
-
if (!best ||
|
|
357
|
-
updatedAtMs > best.updatedAtMs ||
|
|
358
|
-
(updatedAtMs === best.updatedAtMs && arionName === currentArionName)) {
|
|
359
|
-
best = {
|
|
360
|
-
sessionId: top.id,
|
|
361
|
-
arionName,
|
|
362
|
-
updatedAtMs,
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
finally {
|
|
367
|
-
tmpHistory.close();
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
if (best) {
|
|
371
|
-
return {
|
|
372
|
-
sessionId: best.sessionId,
|
|
373
|
-
arionName: best.arionName,
|
|
374
|
-
source: best.arionName === currentArionName ? "history" : "history-scan",
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
catch (err) {
|
|
379
|
-
writeSupervisorStderr(`[aria] SessionHistory fallback failed: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
380
|
-
}
|
|
381
|
-
return { sessionId: null, arionName: currentArionName, source: "none" };
|
|
382
|
-
}
|
|
383
|
-
export async function supervise(scriptPath, scriptArgs, nodeArgs = [], options = {}) {
|
|
384
|
-
// Restore crash count from persistent marker if resuming a session
|
|
385
|
-
let consecutiveCrashes = 0;
|
|
386
|
-
if (pendingResumeSessionId) {
|
|
387
|
-
const marker = readCrashMarker(pendingResumeSessionId);
|
|
388
|
-
if (marker) {
|
|
389
|
-
consecutiveCrashes = marker.count;
|
|
390
|
-
if (consecutiveCrashes >= MAX_CRASH_RESTARTS) {
|
|
391
|
-
abandonPoisonedResumeSession(pendingResumeSessionId, consecutiveCrashes);
|
|
392
|
-
consecutiveCrashes = 0;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
// Tracks the kind of restart so the child can distinguish explicit /restart
|
|
397
|
-
// from crash recovery (affects whether auto-continue message is injected).
|
|
398
|
-
let nextRestartKind;
|
|
399
|
-
while (true) {
|
|
400
|
-
try {
|
|
401
|
-
await options.beforeSpawn?.();
|
|
402
|
-
const result = await spawnChild(scriptPath, scriptArgs, nodeArgs, pendingResumeSessionId, pendingArionName, nextRestartKind);
|
|
403
|
-
nextRestartKind = undefined; // Reset for next iteration
|
|
404
|
-
const exitCode = result.code;
|
|
405
|
-
pendingResumeSessionId = result.resumeSessionId;
|
|
406
|
-
setPendingResumeSessionId(pendingResumeSessionId);
|
|
407
|
-
pendingArionName = result.arionName;
|
|
408
|
-
setPendingArionName(pendingArionName);
|
|
409
|
-
if (exitCode === 0) {
|
|
410
|
-
// Clean exit — clear any crash markers and relaunch marker
|
|
411
|
-
if (pendingResumeSessionId)
|
|
412
|
-
clearCrashMarker(pendingResumeSessionId);
|
|
413
|
-
clearRelaunchMarker(process.pid);
|
|
414
|
-
process.exit(0);
|
|
415
|
-
}
|
|
416
|
-
if (exitCode === RELAUNCH_EXIT_CODE) {
|
|
417
|
-
// Explicit restart request — reset crash counter and clear crash marker
|
|
418
|
-
consecutiveCrashes = 0;
|
|
419
|
-
if (pendingResumeSessionId)
|
|
420
|
-
clearCrashMarker(pendingResumeSessionId);
|
|
421
|
-
// If IPC didn't deliver the session ID, use the unified fallback resolver.
|
|
422
|
-
// This is the key fix: explicit restarts now have the same recovery
|
|
423
|
-
// guarantees as crash restarts.
|
|
424
|
-
if (!pendingResumeSessionId) {
|
|
425
|
-
const recovered = await recoverResumeContext(pendingArionName);
|
|
426
|
-
if (recovered.sessionId) {
|
|
427
|
-
pendingResumeSessionId = recovered.sessionId;
|
|
428
|
-
setPendingResumeSessionId(pendingResumeSessionId);
|
|
429
|
-
pendingArionName = recovered.arionName;
|
|
430
|
-
setPendingArionName(pendingArionName);
|
|
431
|
-
writeSupervisorStderr(`[aria] IPC session ID lost — recovered via ${recovered.source}: ${pendingResumeSessionId.slice(0, 8)}...\n`);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
else {
|
|
435
|
-
// IPC succeeded — consume disk marker if present
|
|
436
|
-
clearRelaunchMarker(process.pid);
|
|
437
|
-
}
|
|
438
|
-
nextRestartKind = "explicit";
|
|
439
|
-
writeSupervisorStderr(`[aria] Respawning after relaunch request...\n`);
|
|
440
|
-
continue;
|
|
441
|
-
}
|
|
442
|
-
// Unexpected exit (crash, segfault, OOM, unhandled exception)
|
|
443
|
-
nextRestartKind = "crash";
|
|
444
|
-
consecutiveCrashes++;
|
|
445
|
-
const crashAttempt = consecutiveCrashes;
|
|
446
|
-
const crashedSessionId = pendingResumeSessionId;
|
|
447
|
-
let abandonedResumeSession = false;
|
|
448
|
-
// Read crash report written by the child's uncaughtException/unhandledRejection handler
|
|
449
|
-
const crashReport = readAndClearCrashReport();
|
|
450
|
-
// Persist crash marker so the count survives supervisor restarts
|
|
451
|
-
if (crashedSessionId) {
|
|
452
|
-
writeCrashMarker({
|
|
453
|
-
sessionId: crashedSessionId,
|
|
454
|
-
count: crashAttempt,
|
|
455
|
-
lastExitCode: exitCode,
|
|
456
|
-
lastCrash: new Date().toISOString(),
|
|
457
|
-
lastError: crashReport?.message,
|
|
458
|
-
lastStack: crashReport?.stack?.slice(0, 2000),
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
// Log crash details to stderr for diagnostics
|
|
462
|
-
if (crashReport) {
|
|
463
|
-
writeSupervisorStderr(`[aria] Crash error: ${crashReport.message}\n`);
|
|
464
|
-
if (crashReport.stack) {
|
|
465
|
-
writeSupervisorStderr(`[aria] Stack: ${crashReport.stack.slice(0, 2000)}\n`);
|
|
466
|
-
}
|
|
467
|
-
if (crashReport.heapMb != null || crashReport.rssMb != null) {
|
|
468
|
-
writeSupervisorStderr(`[aria] Memory at crash: heap=${crashReport.heapMb ?? "?"}MB, rss=${crashReport.rssMb ?? "?"}MB\n`);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
if (crashedSessionId && crashAttempt >= MAX_CRASH_RESTARTS) {
|
|
472
|
-
abandonPoisonedResumeSession(crashedSessionId, crashAttempt);
|
|
473
|
-
consecutiveCrashes = 0;
|
|
474
|
-
abandonedResumeSession = true;
|
|
475
|
-
}
|
|
476
|
-
else if (crashAttempt > MAX_CRASH_RESTARTS) {
|
|
477
|
-
writeSupervisorStderr(`[aria] Too many consecutive crashes (${crashAttempt}), giving up (exit ${exitCode})\n`);
|
|
478
|
-
process.exit(exitCode);
|
|
479
|
-
}
|
|
480
|
-
const backoffMs = Math.min(1000 * Math.pow(2, Math.max(crashAttempt - 1, 0)), 30000);
|
|
481
|
-
writeSupervisorStderr(`[aria] Crash detected (exit ${exitCode}, attempt ${crashAttempt}/${MAX_CRASH_RESTARTS}). ` +
|
|
482
|
-
`Restarting in ${backoffMs}ms...\n`);
|
|
483
|
-
// Fallback: if IPC didn't deliver the session ID, use the unified resolver.
|
|
484
|
-
if (!pendingResumeSessionId && !abandonedResumeSession) {
|
|
485
|
-
const recovered = await recoverResumeContext(pendingArionName);
|
|
486
|
-
if (recovered.sessionId) {
|
|
487
|
-
pendingResumeSessionId = recovered.sessionId;
|
|
488
|
-
setPendingResumeSessionId(pendingResumeSessionId);
|
|
489
|
-
pendingArionName = recovered.arionName;
|
|
490
|
-
setPendingArionName(pendingArionName);
|
|
491
|
-
writeSupervisorStderr(`[aria] IPC session ID lost — recovered via ${recovered.source}: ${pendingResumeSessionId.slice(0, 8)}...\n`);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
await new Promise((r) => setTimeout(r, backoffMs));
|
|
495
|
-
// Respawn with the same resume session ID so the child auto-continues
|
|
496
|
-
}
|
|
497
|
-
catch (error) {
|
|
498
|
-
if (isProcessExitSentinel(error)) {
|
|
499
|
-
throw error;
|
|
500
|
-
}
|
|
501
|
-
process.stdin.resume();
|
|
502
|
-
const message = error instanceof Error ? (error.stack ?? error.message) : String(error);
|
|
503
|
-
writeSupervisorStderr(`[aria] Fatal: failed to spawn child process.\n${message}\n`);
|
|
504
|
-
process.exit(1);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
export async function superviseInteractiveSession(invocation, options = {}) {
|
|
509
|
-
const forwardedArgs = [...invocation.rawArgs];
|
|
510
|
-
return supervise("__internal-repl", forwardedArgs, [], options);
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* Spawn a single child process and wait for it to exit.
|
|
514
|
-
*/
|
|
515
|
-
function spawnChild(scriptPath, scriptArgs, nodeArgs, resumeSessionId, arionName, restartKind) {
|
|
516
|
-
// Pause parent stdin while child owns the terminal
|
|
517
|
-
process.stdin.pause();
|
|
518
|
-
void scriptPath;
|
|
519
|
-
void nodeArgs;
|
|
520
|
-
const childEnv = {
|
|
521
|
-
...process.env,
|
|
522
|
-
[NO_RELAUNCH_ENV]: "true",
|
|
523
|
-
};
|
|
524
|
-
if (resumeSessionId) {
|
|
525
|
-
childEnv[RESUME_SESSION_ENV] = resumeSessionId;
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
delete childEnv[RESUME_SESSION_ENV];
|
|
529
|
-
}
|
|
530
|
-
childEnv[RESUME_ARION_ENV] = arionName;
|
|
531
|
-
if (restartKind) {
|
|
532
|
-
childEnv[RESTART_KIND_ENV] = restartKind;
|
|
533
|
-
}
|
|
534
|
-
else {
|
|
535
|
-
delete childEnv[RESTART_KIND_ENV];
|
|
536
|
-
}
|
|
537
|
-
const childArgs = scriptArgs;
|
|
538
|
-
const spec = resolveAriaLaunchSpec({
|
|
539
|
-
mode: "repl",
|
|
540
|
-
args: childArgs,
|
|
541
|
-
env: childEnv,
|
|
542
|
-
cwd: process.cwd(),
|
|
543
|
-
});
|
|
544
|
-
const child = spawnAria(spec, { ipc: true });
|
|
545
|
-
return new Promise((resolve, reject) => {
|
|
546
|
-
let resumeFromChild = resumeSessionId;
|
|
547
|
-
let arionFromChild = arionName;
|
|
548
|
-
child.on("message", (message) => {
|
|
549
|
-
if (!message || typeof message !== "object")
|
|
550
|
-
return;
|
|
551
|
-
const payload = message;
|
|
552
|
-
if (payload.type !== "aria-relaunch")
|
|
553
|
-
return;
|
|
554
|
-
if (typeof payload.resumeSessionId === "string" && payload.resumeSessionId.trim()) {
|
|
555
|
-
resumeFromChild = payload.resumeSessionId.trim();
|
|
556
|
-
}
|
|
557
|
-
else if (payload.resumeSessionId === null) {
|
|
558
|
-
resumeFromChild = null;
|
|
559
|
-
}
|
|
560
|
-
if (typeof payload.arionName === "string" && payload.arionName.trim()) {
|
|
561
|
-
arionFromChild = payload.arionName.trim();
|
|
562
|
-
}
|
|
563
|
-
// Acknowledge receipt so child can exit with confidence.
|
|
564
|
-
try {
|
|
565
|
-
child.send({
|
|
566
|
-
type: "aria-relaunch-ack",
|
|
567
|
-
nonce: typeof payload.nonce === "string" ? payload.nonce : undefined,
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
catch {
|
|
571
|
-
// Child may have already exited — non-fatal.
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
child.on("error", (err) => {
|
|
575
|
-
process.stdin.resume();
|
|
576
|
-
reject(err);
|
|
577
|
-
});
|
|
578
|
-
child.on("close", (code) => {
|
|
579
|
-
process.stdin.resume();
|
|
580
|
-
resolve({
|
|
581
|
-
code: (typeof code === "number" ? code : null) ?? 1,
|
|
582
|
-
resumeSessionId: resumeFromChild,
|
|
583
|
-
arionName: arionFromChild,
|
|
584
|
-
});
|
|
585
|
-
});
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
//# sourceMappingURL=relaunch.js.map
|
package/dist/release-notes.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Release notes shown in the TUI startup banner.
|
|
3
|
-
* Update this file each release to keep "What's New" accurate.
|
|
4
|
-
*
|
|
5
|
-
* Guidelines:
|
|
6
|
-
* - Only user-facing features — no bug fixes, refactors, or internals
|
|
7
|
-
* - Lead with the verb / action the user can take
|
|
8
|
-
* - Keep it to 4-5 items max
|
|
9
|
-
*/
|
|
10
|
-
function resolveVersion() {
|
|
11
|
-
// In bundled/compiled builds, __ARIA_VERSION__ is replaced at build time
|
|
12
|
-
// by --define. In dev, it's undefined → read from package.json.
|
|
13
|
-
if (typeof __ARIA_VERSION__ !== "undefined")
|
|
14
|
-
return __ARIA_VERSION__;
|
|
15
|
-
// Dev-mode fallback: read from the package.json next to this source file.
|
|
16
|
-
// This only runs when bun executes TS directly (not bundled).
|
|
17
|
-
try {
|
|
18
|
-
const { readFileSync } = require("node:fs");
|
|
19
|
-
const { resolve, dirname } = require("node:path");
|
|
20
|
-
const pkgPath = resolve(dirname(__filename), "..", "package.json");
|
|
21
|
-
return JSON.parse(readFileSync(pkgPath, "utf8")).version;
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
return "0.0.0-dev";
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export const CLI_VERSION = resolveVersion();
|
|
28
|
-
export const WHATS_NEW = [
|
|
29
|
-
"⚡ Search millions of lines instantly with native Rust-powered code search",
|
|
30
|
-
"🧠 Jump to definitions & find references with real LSP intelligence",
|
|
31
|
-
"✏️ Press Esc×2 to edit and fork any previous message in-place",
|
|
32
|
-
"🔊 Get audio cues when tasks finish — try /sound to configure",
|
|
33
|
-
"🎨 All 87 tools now render rich, beautiful output in the terminal",
|
|
34
|
-
];
|
|
35
|
-
//# sourceMappingURL=release-notes.js.map
|