@aria-cli/cli 1.0.57 → 1.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/aria.mjs +2 -2
- package/package.json +17 -76
- package/dist/.tsbuildinfo +0 -1
- package/dist/attached-local-control-client.js +0 -826
- package/dist/bootstrap-local-control-client.js +0 -2
- package/dist/capability-aware-method-proxy.js +0 -42
- package/dist/cli-context.js +0 -160
- package/dist/commands/arions.js +0 -174
- package/dist/commands/auth.js +0 -123
- package/dist/commands/daemon.js +0 -367
- package/dist/commands/definitions.js +0 -176
- package/dist/commands/index.js +0 -80
- package/dist/commands/login-handler.js +0 -1108
- package/dist/commands/logout-handler.js +0 -92
- package/dist/commands/memory-handlers.js +0 -89
- package/dist/commands/pairing.js +0 -60
- package/dist/commands/runtime-cutover-reset-command.js +0 -12
- package/dist/commands/runtime-cutover-reset.js +0 -265
- package/dist/commands/terminal-setup.js +0 -84
- package/dist/config/aria-config.js +0 -238
- package/dist/config/index.js +0 -3
- package/dist/config/loader.js +0 -97
- package/dist/config.js +0 -142
- package/dist/daemon-info.js +0 -10
- package/dist/ensure-daemon.js +0 -128
- package/dist/entrypoints/command-mode.js +0 -5
- package/dist/entrypoints/daemon.js +0 -50
- package/dist/entrypoints/headless-stdio.js +0 -25
- package/dist/entrypoints/interactive.js +0 -80
- package/dist/event-loop-watchdog.js +0 -73
- package/dist/headless/auth-orchestrator.js +0 -508
- package/dist/headless/auth-service.js +0 -43
- package/dist/headless/bootstrap-fast-path.js +0 -112
- package/dist/headless/call-command.js +0 -143
- package/dist/headless/daemon-service.js +0 -318
- package/dist/headless/hook-actions.js +0 -235
- package/dist/headless/hook-service.js +0 -42
- package/dist/headless/kernel-services.js +0 -216
- package/dist/headless/kernel.js +0 -785
- package/dist/headless/operations/arion.js +0 -119
- package/dist/headless/operations/auth.js +0 -45
- package/dist/headless/operations/client.js +0 -31
- package/dist/headless/operations/config.js +0 -69
- package/dist/headless/operations/daemon.js +0 -47
- package/dist/headless/operations/hook.js +0 -56
- package/dist/headless/operations/index.js +0 -11
- package/dist/headless/operations/memory.js +0 -102
- package/dist/headless/operations/message.js +0 -279
- package/dist/headless/operations/model.js +0 -100
- package/dist/headless/operations/peer.js +0 -56
- package/dist/headless/operations/run.js +0 -24
- package/dist/headless/operations/session.js +0 -90
- package/dist/headless/operations/system.js +0 -19
- package/dist/headless/operations/utils.js +0 -35
- package/dist/headless/run-orchestrator.js +0 -703
- package/dist/headless/stdio-server.js +0 -439
- package/dist/history/SessionHistory.js +0 -8
- package/dist/history/SessionHistoryClient.js +0 -186
- package/dist/history/conversation-message.js +0 -112
- package/dist/history/index.js +0 -8
- package/dist/history/jsonl-replay.js +0 -154
- package/dist/history/repair-tool-pairing.js +0 -84
- package/dist/history/stall-phase-bridge.js +0 -11
- package/dist/history/turn-accumulator.js +0 -427
- package/dist/index.js +0 -7
- package/dist/ink-repl.js +0 -4183
- package/dist/local-control-bootstrap.js +0 -26
- package/dist/local-control-client.js +0 -2
- package/dist/local-control-error-reporting.js +0 -34
- package/dist/local-control-http-client.js +0 -362
- package/dist/local-control-lazy-wrapper.js +0 -363
- package/dist/local-control-manager.js +0 -146
- package/dist/main.js +0 -62
- package/dist/network-security.js +0 -62
- package/dist/networking-server.js +0 -38
- package/dist/peer-identity.js +0 -23
- package/dist/polling-subscription.js +0 -34
- package/dist/relaunch.js +0 -617
- package/dist/release-notes.js +0 -35
- package/dist/repl-cleanup.js +0 -47
- package/dist/runtime/configure-bun-sqlite.js +0 -3
- package/dist/runtime/crash-handlers.js +0 -111
- package/dist/runtime/interactive-invocation.js +0 -39
- package/dist/runtime/internal-mode.js +0 -14
- package/dist/runtime/launch-spec.js +0 -64
- package/dist/runtime/owner-lease.js +0 -44
- package/dist/runtime/public-mode.js +0 -20
- package/dist/runtime/run-internal-mode.js +0 -18
- package/dist/runtime/runtime-kind.js +0 -32
- package/dist/runtime/spawn-aria.js +0 -38
- package/dist/selectable-client.js +0 -2
- package/dist/selectable-peer.js +0 -2
- package/dist/session.js +0 -203
- package/dist/slash-commands.js +0 -80
- package/dist/sounds.js +0 -210
- package/dist/ui/App.js +0 -526
- package/dist/ui/components/AnthropicMethodPicker.js +0 -6
- package/dist/ui/components/ArionPrompt.js +0 -15
- package/dist/ui/components/AutocompleteDropdown.js +0 -23
- package/dist/ui/components/AutonomySelector.js +0 -55
- package/dist/ui/components/Banner.js +0 -98
- package/dist/ui/components/ConversationHistory.js +0 -175
- package/dist/ui/components/CopilotDeviceLoginFlow.js +0 -88
- package/dist/ui/components/CopilotSourcePicker.js +0 -50
- package/dist/ui/components/Cost.js +0 -10
- package/dist/ui/components/CustomSelect/option-map.js +0 -30
- package/dist/ui/components/CustomSelect/select-option.js +0 -13
- package/dist/ui/components/CustomSelect/select.js +0 -42
- package/dist/ui/components/CustomSelect/use-select-state.js +0 -179
- package/dist/ui/components/CustomSelect/use-select.js +0 -15
- package/dist/ui/components/ErrorDisplay.js +0 -35
- package/dist/ui/components/FallbackToolUseRejectedMessage.js +0 -7
- package/dist/ui/components/FileEditToolUpdatedMessage.js +0 -57
- package/dist/ui/components/HandoffMarker.js +0 -18
- package/dist/ui/components/HighlightedCode.js +0 -21
- package/dist/ui/components/InputArea.js +0 -187
- package/dist/ui/components/Message.js +0 -25
- package/dist/ui/components/OAuthLoginFlow.js +0 -113
- package/dist/ui/components/OutputTruncation.js +0 -35
- package/dist/ui/components/PermissionPrompt.js +0 -79
- package/dist/ui/components/PipelineTimingPanel.js +0 -15
- package/dist/ui/components/ProviderMethodPicker.js +0 -61
- package/dist/ui/components/ProviderPicker.js +0 -63
- package/dist/ui/components/RenderItemView.js +0 -71
- package/dist/ui/components/Spinner.js +0 -46
- package/dist/ui/components/StatusBar.js +0 -95
- package/dist/ui/components/StreamingIndicator.js +0 -55
- package/dist/ui/components/StructuredDiff.js +0 -168
- package/dist/ui/components/TextInputOverlay.js +0 -43
- package/dist/ui/components/ThinkingBlock.js +0 -82
- package/dist/ui/components/ToolCost.js +0 -17
- package/dist/ui/components/ToolExecution.js +0 -61
- package/dist/ui/components/ToolHeader.js +0 -51
- package/dist/ui/components/ToolRenderLayoutContext.js +0 -14
- package/dist/ui/components/ToolResultWrapper.js +0 -6
- package/dist/ui/components/ToolUseLoader.js +0 -35
- package/dist/ui/components/TraceWaterfall.js +0 -91
- package/dist/ui/components/index.js +0 -33
- package/dist/ui/components/messages/AssistantTextMessage.js +0 -25
- package/dist/ui/components/messages/UserImageMessage.js +0 -12
- package/dist/ui/components/messages/UserTextMessage.js +0 -12
- package/dist/ui/components/overlays/ArionSelector.js +0 -68
- package/dist/ui/components/overlays/ClientSelector.js +0 -62
- package/dist/ui/components/overlays/CommandPalette.js +0 -67
- package/dist/ui/components/overlays/DaemonControl.js +0 -87
- package/dist/ui/components/overlays/InviteShareOverlay.js +0 -15
- package/dist/ui/components/overlays/JoinInviteOverlay.js +0 -32
- package/dist/ui/components/overlays/MemoryBrowser.js +0 -100
- package/dist/ui/components/overlays/MessageSelector.js +0 -123
- package/dist/ui/components/overlays/ModelSelector.js +0 -211
- package/dist/ui/components/overlays/PairRequestOverlay.js +0 -42
- package/dist/ui/components/overlays/PeerSelector.js +0 -84
- package/dist/ui/components/overlays/SessionSelector.js +0 -102
- package/dist/ui/components/overlays/SoundSelector.js +0 -86
- package/dist/ui/components/overlays/ThemeSelector.js +0 -139
- package/dist/ui/components/overlays/index.js +0 -15
- package/dist/ui/components/permissions/BashPermissionRequest/BashPermissionRequest.js +0 -53
- package/dist/ui/components/permissions/FallbackPermissionRequest.js +0 -56
- package/dist/ui/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.js +0 -76
- package/dist/ui/components/permissions/FileEditPermissionRequest/FileEditToolDiff.js +0 -18
- package/dist/ui/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.js +0 -64
- package/dist/ui/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.js +0 -26
- package/dist/ui/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js +0 -141
- package/dist/ui/components/permissions/PermissionRequest.js +0 -70
- package/dist/ui/components/permissions/PermissionRequestTitle.js +0 -41
- package/dist/ui/components/permissions/hooks.js +0 -10
- package/dist/ui/components/permissions/toolUseOptions.js +0 -68
- package/dist/ui/components/permissions/utils.js +0 -10
- package/dist/ui/components/text-input/Cursor.js +0 -326
- package/dist/ui/components/text-input/TextInput.js +0 -231
- package/dist/ui/components/text-input/imagePaste.js +0 -28
- package/dist/ui/components/text-input/index.js +0 -6
- package/dist/ui/components/text-input/useDoublePress.js +0 -30
- package/dist/ui/components/text-input/useTextInput.js +0 -245
- package/dist/ui/components/tool-types.js +0 -9
- package/dist/ui/constants/figures.js +0 -4
- package/dist/ui/constants/index.js +0 -3
- package/dist/ui/display-mode.js +0 -93
- package/dist/ui/display-policy.js +0 -19
- package/dist/ui/hooks/index.js +0 -6
- package/dist/ui/hooks/useCommandAutocomplete.js +0 -93
- package/dist/ui/hooks/useDoublePress.js +0 -37
- package/dist/ui/hooks/useIndicatorState.js +0 -55
- package/dist/ui/hooks/useInterval.js +0 -23
- package/dist/ui/hooks/useKeyboardShortcuts.js +0 -127
- package/dist/ui/hooks/useTerminalSize.js +0 -55
- package/dist/ui/hooks/useUnifiedMessages.js +0 -117
- package/dist/ui/indicator-state.js +0 -44
- package/dist/ui/markdown/highlight.js +0 -44
- package/dist/ui/markdown/index.js +0 -1460
- package/dist/ui/markdown/tokenizer.js +0 -24
- package/dist/ui/render-item.js +0 -5
- package/dist/ui/screens/REPL.js +0 -119
- package/dist/ui/screens/approval-lifecycle.js +0 -38
- package/dist/ui/status-line.js +0 -72
- package/dist/ui/theme/index.js +0 -51
- package/dist/ui/theme/themes/claude-dark-daltonized.js +0 -51
- package/dist/ui/theme/themes/claude-dark.js +0 -50
- package/dist/ui/theme/themes/claude-light-daltonized.js +0 -51
- package/dist/ui/theme/themes/claude-light.js +0 -50
- package/dist/ui/theme/themes/dark-accessible.js +0 -18
- package/dist/ui/theme/themes/dark.js +0 -49
- package/dist/ui/theme/themes/light-accessible.js +0 -18
- package/dist/ui/theme/themes/light.js +0 -49
- package/dist/ui/theme/types.js +0 -3
- package/dist/ui/theme.js +0 -142
- package/dist/ui/to-render-items.js +0 -145
- package/dist/ui/tools/AgentTool/index.js +0 -30
- package/dist/ui/tools/ArchitectTool/index.js +0 -31
- package/dist/ui/tools/AskUserTool/index.js +0 -46
- package/dist/ui/tools/BashTool/BashToolResultMessage.js +0 -11
- package/dist/ui/tools/BashTool/OutputLine.js +0 -21
- package/dist/ui/tools/BashTool/index.js +0 -91
- package/dist/ui/tools/BrowseTool/index.js +0 -43
- package/dist/ui/tools/BrowserTool/index.js +0 -47
- package/dist/ui/tools/CbmTool/index.js +0 -188
- package/dist/ui/tools/CheckDelegationTool/index.js +0 -46
- package/dist/ui/tools/CheckMessagesTool/index.js +0 -85
- package/dist/ui/tools/CreateQuipTool/index.js +0 -30
- package/dist/ui/tools/CreateSkillTool/index.js +0 -22
- package/dist/ui/tools/CreateToolTool/index.js +0 -31
- package/dist/ui/tools/DelegateRemoteTool/index.js +0 -42
- package/dist/ui/tools/DeployTool/index.js +0 -47
- package/dist/ui/tools/FffTool/index.js +0 -103
- package/dist/ui/tools/FileEditTool/index.js +0 -67
- package/dist/ui/tools/FileReadTool/index.js +0 -68
- package/dist/ui/tools/FileWriteTool/index.js +0 -61
- package/dist/ui/tools/ForkTool/index.js +0 -47
- package/dist/ui/tools/FrgTool/index.js +0 -96
- package/dist/ui/tools/GetThreadTool/index.js +0 -39
- package/dist/ui/tools/GlobTool/index.js +0 -50
- package/dist/ui/tools/GrepTool/index.js +0 -84
- package/dist/ui/tools/HatchArionTool/index.js +0 -36
- package/dist/ui/tools/LearnSkillTool/index.js +0 -22
- package/dist/ui/tools/LearnTool/index.js +0 -43
- package/dist/ui/tools/LearnToolTool/index.js +0 -22
- package/dist/ui/tools/ListClientsTool/index.js +0 -39
- package/dist/ui/tools/LspTool/index.js +0 -261
- package/dist/ui/tools/MCPTool/index.js +0 -33
- package/dist/ui/tools/ManageNetworkTool/index.js +0 -53
- package/dist/ui/tools/MemoryReadTool/index.js +0 -64
- package/dist/ui/tools/MemoryWriteTool/index.js +0 -20
- package/dist/ui/tools/NotebookEditTool/index.js +0 -33
- package/dist/ui/tools/NotebookReadTool/index.js +0 -25
- package/dist/ui/tools/OutlookReadTool/index.js +0 -66
- package/dist/ui/tools/OutlookReplyTool/index.js +0 -49
- package/dist/ui/tools/OutlookSendTool/index.js +0 -49
- package/dist/ui/tools/PauseDelegationTool/index.js +0 -35
- package/dist/ui/tools/ProbeTool/index.js +0 -121
- package/dist/ui/tools/ProcessTool/index.js +0 -66
- package/dist/ui/tools/QuestListTool/index.js +0 -46
- package/dist/ui/tools/QuestReportTool/index.js +0 -49
- package/dist/ui/tools/QuestUpdateTool/index.js +0 -87
- package/dist/ui/tools/QuipCommentTool/index.js +0 -69
- package/dist/ui/tools/QuipReadTool/index.js +0 -71
- package/dist/ui/tools/RestArionTool/index.js +0 -32
- package/dist/ui/tools/RestartTool/index.js +0 -35
- package/dist/ui/tools/ResumeDelegationTool/index.js +0 -35
- package/dist/ui/tools/RetireArionTool/index.js +0 -32
- package/dist/ui/tools/RgTool/index.js +0 -73
- package/dist/ui/tools/SearchKnowledgeTool/index.js +0 -43
- package/dist/ui/tools/SearchMessagesTool/index.js +0 -43
- package/dist/ui/tools/SelfDiagnoseTool/index.js +0 -61
- package/dist/ui/tools/SendMessageTool/index.js +0 -45
- package/dist/ui/tools/SerenaTool/index.js +0 -124
- package/dist/ui/tools/SessionHistoryTool/index.js +0 -52
- package/dist/ui/tools/SgTool/index.js +0 -80
- package/dist/ui/tools/SlackReactTool/index.js +0 -41
- package/dist/ui/tools/SlackReadTool/index.js +0 -48
- package/dist/ui/tools/SlackSendTool/index.js +0 -45
- package/dist/ui/tools/SpawnWorkerTool/index.js +0 -33
- package/dist/ui/tools/StickerRequestTool/index.js +0 -19
- package/dist/ui/tools/ThinkTool/index.js +0 -17
- package/dist/ui/tools/UgTool/index.js +0 -108
- package/dist/ui/tools/UseSkillTool/index.js +0 -22
- package/dist/ui/tools/WakeArionTool/index.js +0 -32
- package/dist/ui/tools/WebFetchTool/index.js +0 -56
- package/dist/ui/tools/WebSearchTool/index.js +0 -44
- package/dist/ui/tools/lsTool/index.js +0 -58
- package/dist/ui/tools/registry.js +0 -197
- package/dist/ui/tools/tool-renderer.js +0 -11
- package/dist/ui/tools/truncation.js +0 -35
- package/dist/ui/types/anthropic.js +0 -4
- package/dist/ui/types/index.js +0 -2
- package/dist/ui/types/message.js +0 -3
- package/dist/ui/types/tool.js +0 -4
- package/dist/ui/utils/array.js +0 -4
- package/dist/ui/utils/cursor.js +0 -131
- package/dist/ui/utils/diff.js +0 -120
- package/dist/ui/utils/format.js +0 -42
- package/dist/ui/utils/fuzzy.js +0 -59
- package/dist/ui/utils/index.js +0 -11
- package/dist/ui/utils/keys.js +0 -8
- package/dist/ui/utils/patch.js +0 -17
- package/dist/ui/utils/risk.js +0 -114
- package/dist/ui/utils/terminal-image.js +0 -70
- package/dist/ui/utils/validation.js +0 -48
- package/dist/ui/verb-pairs.js +0 -248
- package/dist/ui.js +0 -131
- package/src/entrypoints/command-mode.ts +0 -5
- package/src/entrypoints/daemon.ts +0 -54
- package/src/entrypoints/headless-stdio.ts +0 -27
- package/src/entrypoints/interactive.ts +0 -112
- package/src/main.ts +0 -72
- package/src/runtime/configure-bun-sqlite.ts +0 -3
- package/src/runtime/crash-handlers.ts +0 -128
- package/src/runtime/interactive-invocation.test.ts +0 -42
- package/src/runtime/interactive-invocation.ts +0 -51
- package/src/runtime/internal-mode.test.ts +0 -19
- package/src/runtime/internal-mode.ts +0 -24
- package/src/runtime/launch-spec.test.ts +0 -26
- package/src/runtime/launch-spec.ts +0 -84
- package/src/runtime/owner-lease.ts +0 -52
- package/src/runtime/public-mode.test.ts +0 -18
- package/src/runtime/public-mode.ts +0 -19
- package/src/runtime/run-internal-mode.ts +0 -19
- package/src/runtime/runtime-kind.test.ts +0 -23
- package/src/runtime/runtime-kind.ts +0 -41
- package/src/runtime/spawn-aria.ts +0 -62
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
function readInputJson(pathOrDash) {
|
|
6
|
-
if (!pathOrDash || pathOrDash === "-") {
|
|
7
|
-
const raw = readFileSync(0, "utf8").trim();
|
|
8
|
-
return raw ? JSON.parse(raw) : {};
|
|
9
|
-
}
|
|
10
|
-
return JSON.parse(readFileSync(pathOrDash, "utf8"));
|
|
11
|
-
}
|
|
12
|
-
function makeClientFrame(operation, input) {
|
|
13
|
-
if (operation === "interaction.respond") {
|
|
14
|
-
return {
|
|
15
|
-
kind: "interaction.respond",
|
|
16
|
-
requestId: "call-1",
|
|
17
|
-
...input,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
kind: "request",
|
|
22
|
-
requestId: "call-1",
|
|
23
|
-
op: operation,
|
|
24
|
-
input,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function resolveAriaHome() {
|
|
28
|
-
if (process.env.ARIA_HOME) {
|
|
29
|
-
return process.env.ARIA_HOME;
|
|
30
|
-
}
|
|
31
|
-
return path.join(process.env.HOME || homedir(), ".aria");
|
|
32
|
-
}
|
|
33
|
-
function resolveCallArionName(options) {
|
|
34
|
-
if (typeof options.arion === "string" && options.arion.trim().length > 0) {
|
|
35
|
-
return options.arion.trim();
|
|
36
|
-
}
|
|
37
|
-
const configPath = path.join(resolveAriaHome(), "config.json");
|
|
38
|
-
if (!existsSync(configPath)) {
|
|
39
|
-
return "ARIA";
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
const raw = JSON.parse(readFileSync(configPath, "utf8"));
|
|
43
|
-
if (typeof raw.activeArion === "string" && raw.activeArion.trim().length > 0) {
|
|
44
|
-
return raw.activeArion.trim();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
// Fall through to the default Arion name when config is unreadable.
|
|
49
|
-
}
|
|
50
|
-
return "ARIA";
|
|
51
|
-
}
|
|
52
|
-
function missingResult(operation) {
|
|
53
|
-
return {
|
|
54
|
-
kind: "result",
|
|
55
|
-
requestId: "call-1",
|
|
56
|
-
op: operation,
|
|
57
|
-
ok: false,
|
|
58
|
-
error: {
|
|
59
|
-
code: "NO_RESULT",
|
|
60
|
-
message: `Operation ${operation} produced no result frame`,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
async function runFastSessionCall(operation, input, options) {
|
|
65
|
-
const [{ SessionHistory }, { createSessionOperationHandlers }, { cliStallPhase }] = await Promise.all([
|
|
66
|
-
import("../history/index.js"),
|
|
67
|
-
import("./operations/session.js"),
|
|
68
|
-
import("../history/stall-phase-bridge.js"),
|
|
69
|
-
]);
|
|
70
|
-
const sessionLedger = new SessionHistory(SessionHistory.resolvePerArionPath(resolveAriaHome(), resolveCallArionName(options)), { stallPhase: cliStallPhase });
|
|
71
|
-
try {
|
|
72
|
-
const handlers = createSessionOperationHandlers({
|
|
73
|
-
sessionLedger,
|
|
74
|
-
});
|
|
75
|
-
let lastResult = null;
|
|
76
|
-
for await (const frame of handlers[operation]("call-1", input)) {
|
|
77
|
-
if (frame.kind === "result") {
|
|
78
|
-
lastResult = frame;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return lastResult ?? missingResult(operation);
|
|
82
|
-
}
|
|
83
|
-
finally {
|
|
84
|
-
sessionLedger.close();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
async function tryRunFastPath(operation, input, options) {
|
|
88
|
-
switch (operation) {
|
|
89
|
-
case "session.list":
|
|
90
|
-
case "session.read":
|
|
91
|
-
case "session.load":
|
|
92
|
-
return runFastSessionCall(operation, input, options);
|
|
93
|
-
default:
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
export async function runHeadlessCall(operation, options) {
|
|
98
|
-
try {
|
|
99
|
-
const input = readInputJson(options.inputJson);
|
|
100
|
-
const fastPathResult = await tryRunFastPath(operation, input, options);
|
|
101
|
-
if (fastPathResult) {
|
|
102
|
-
process.stdout.write(`${JSON.stringify(fastPathResult)}\n`);
|
|
103
|
-
return fastPathResult.ok ? 0 : 1;
|
|
104
|
-
}
|
|
105
|
-
const { createHeadlessKernelRuntime } = await import("./kernel.js");
|
|
106
|
-
const runtime = await createHeadlessKernelRuntime({
|
|
107
|
-
cwd: process.cwd(),
|
|
108
|
-
arionName: options.arion,
|
|
109
|
-
});
|
|
110
|
-
try {
|
|
111
|
-
let lastResult = null;
|
|
112
|
-
for await (const frame of runtime.kernel.dispatch(makeClientFrame(operation, input))) {
|
|
113
|
-
if (frame.kind === "result") {
|
|
114
|
-
lastResult = frame;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (!lastResult) {
|
|
118
|
-
process.stdout.write(`${JSON.stringify(missingResult(operation))}\n`);
|
|
119
|
-
return 1;
|
|
120
|
-
}
|
|
121
|
-
process.stdout.write(`${JSON.stringify(lastResult)}\n`);
|
|
122
|
-
return lastResult.ok ? 0 : 1;
|
|
123
|
-
}
|
|
124
|
-
finally {
|
|
125
|
-
await runtime.release();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
130
|
-
return 2;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
export function createHeadlessCallCommand() {
|
|
134
|
-
return new Command("call")
|
|
135
|
-
.description("Execute one headless operation and print exactly one JSON result")
|
|
136
|
-
.argument("<operation>", "Headless operation name")
|
|
137
|
-
.option("--input-json <path|->", "Read JSON input from a file path or stdin", "-")
|
|
138
|
-
.option("--arion <name>", "Arion name for per-Arion session context")
|
|
139
|
-
.action(async (operation, options) => {
|
|
140
|
-
process.exitCode = await runHeadlessCall(operation, options);
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=call-command.js.map
|
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, openSync, closeSync, writeFileSync } from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import process from "node:process";
|
|
4
|
-
import { resolveLocalControlClient } from "../local-control-client.js";
|
|
5
|
-
import { resolveAriaLaunchSpec } from "../runtime/launch-spec.js";
|
|
6
|
-
import { spawnAria } from "../runtime/spawn-aria.js";
|
|
7
|
-
const DAEMON_READY_TIMEOUT_MS = 15_000;
|
|
8
|
-
const DAEMON_READY_POLL_MS = 250;
|
|
9
|
-
function sleep(ms) {
|
|
10
|
-
return new Promise((resolve) => setTimeout(resolve, Math.max(ms, 0)));
|
|
11
|
-
}
|
|
12
|
-
function resolveArionName(cli, fallback, raw) {
|
|
13
|
-
const fromInput = typeof raw.arion === "string" ? raw.arion.trim() : "";
|
|
14
|
-
return fromInput || fallback || cli.config.activeArion?.trim() || "ARIA";
|
|
15
|
-
}
|
|
16
|
-
function toAutonomousLoopCommand(input) {
|
|
17
|
-
return {
|
|
18
|
-
...(typeof input.intervalMs === "number" ? { intervalMs: input.intervalMs } : {}),
|
|
19
|
-
...(input.allowedToolCategories ||
|
|
20
|
-
input.allowedShellCommands ||
|
|
21
|
-
typeof input.maxWriteOpsPerMinute === "number" ||
|
|
22
|
-
typeof input.maxGitPushesPerHour === "number"
|
|
23
|
-
? {
|
|
24
|
-
safetyPolicy: {
|
|
25
|
-
...(Array.isArray(input.allowedToolCategories)
|
|
26
|
-
? { allowedToolCategories: input.allowedToolCategories }
|
|
27
|
-
: {}),
|
|
28
|
-
...(Array.isArray(input.allowedShellCommands)
|
|
29
|
-
? { allowedShellCommands: input.allowedShellCommands }
|
|
30
|
-
: {}),
|
|
31
|
-
...(typeof input.maxWriteOpsPerMinute === "number"
|
|
32
|
-
? { maxWriteOpsPerMinute: input.maxWriteOpsPerMinute }
|
|
33
|
-
: {}),
|
|
34
|
-
...(typeof input.maxGitPushesPerHour === "number"
|
|
35
|
-
? { maxGitPushesPerHour: input.maxGitPushesPerHour }
|
|
36
|
-
: {}),
|
|
37
|
-
},
|
|
38
|
-
}
|
|
39
|
-
: {}),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
async function waitForDaemonStatus(options) {
|
|
43
|
-
const deadline = Date.now() + DAEMON_READY_TIMEOUT_MS;
|
|
44
|
-
let lastError = null;
|
|
45
|
-
while (Date.now() < deadline) {
|
|
46
|
-
try {
|
|
47
|
-
const control = await resolveLocalControlClient({ ariaHome: options.ariaHome });
|
|
48
|
-
if (control) {
|
|
49
|
-
const status = await control.getRuntimeStatus();
|
|
50
|
-
if (!options.requireRunning || status.autonomousLoop.status === "running") {
|
|
51
|
-
return status;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
lastError = error instanceof Error ? error : new Error(String(error));
|
|
57
|
-
}
|
|
58
|
-
await sleep(DAEMON_READY_POLL_MS);
|
|
59
|
-
}
|
|
60
|
-
throw new Error(lastError?.message ?? "Timed out waiting for the daemon runtime to become reachable");
|
|
61
|
-
}
|
|
62
|
-
async function findLocalRuntimeOwner(options) {
|
|
63
|
-
const { resolveRuntimeRootDirectory, findRuntimeOwnerRecordByAriaHome, readRuntimeOwnerRecord, removeRuntimeOwnerRecord, } = await import("@aria-cli/server");
|
|
64
|
-
const runtimeRoot = resolveRuntimeRootDirectory();
|
|
65
|
-
if (options.liveControl) {
|
|
66
|
-
try {
|
|
67
|
-
const status = await options.liveControl.getRuntimeStatus();
|
|
68
|
-
const byNodeId = readRuntimeOwnerRecord(runtimeRoot, status.nodeId);
|
|
69
|
-
if (byNodeId) {
|
|
70
|
-
return { runtimeRoot, owner: byNodeId, removeRuntimeOwnerRecord };
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
// Fall back to ARIA_HOME-scoped owner lookup below.
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const owner = findRuntimeOwnerRecordByAriaHome(runtimeRoot, options.ariaHome);
|
|
78
|
-
return { runtimeRoot, owner, removeRuntimeOwnerRecord };
|
|
79
|
-
}
|
|
80
|
-
function isPidAlive(pid) {
|
|
81
|
-
try {
|
|
82
|
-
process.kill(pid, 0);
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async function killOwnedDaemonProcess(options) {
|
|
90
|
-
const { runtimeRoot, owner, removeRuntimeOwnerRecord } = await findLocalRuntimeOwner(options);
|
|
91
|
-
if (!owner) {
|
|
92
|
-
return { stopped: false };
|
|
93
|
-
}
|
|
94
|
-
const pid = owner.runtimePid;
|
|
95
|
-
if (!isPidAlive(pid)) {
|
|
96
|
-
removeRuntimeOwnerRecord(runtimeRoot, owner.nodeId);
|
|
97
|
-
return { stopped: false, pid };
|
|
98
|
-
}
|
|
99
|
-
try {
|
|
100
|
-
process.kill(pid, "SIGINT");
|
|
101
|
-
}
|
|
102
|
-
catch {
|
|
103
|
-
removeRuntimeOwnerRecord(runtimeRoot, owner.nodeId);
|
|
104
|
-
return { stopped: false, pid };
|
|
105
|
-
}
|
|
106
|
-
const deadline = Date.now() + 5_000;
|
|
107
|
-
while (Date.now() < deadline) {
|
|
108
|
-
if (!isPidAlive(pid)) {
|
|
109
|
-
try {
|
|
110
|
-
removeRuntimeOwnerRecord(runtimeRoot, owner.nodeId);
|
|
111
|
-
}
|
|
112
|
-
catch { }
|
|
113
|
-
return { stopped: true, pid };
|
|
114
|
-
}
|
|
115
|
-
await sleep(200);
|
|
116
|
-
}
|
|
117
|
-
try {
|
|
118
|
-
process.kill(pid, "SIGKILL");
|
|
119
|
-
}
|
|
120
|
-
catch { }
|
|
121
|
-
try {
|
|
122
|
-
removeRuntimeOwnerRecord(runtimeRoot, owner.nodeId);
|
|
123
|
-
}
|
|
124
|
-
catch { }
|
|
125
|
-
return { stopped: true, pid };
|
|
126
|
-
}
|
|
127
|
-
function sanitizeDaemonEnv(env, overrides) {
|
|
128
|
-
const passthrough = [
|
|
129
|
-
"HOME",
|
|
130
|
-
"PATH",
|
|
131
|
-
"USER",
|
|
132
|
-
"LOGNAME",
|
|
133
|
-
"SHELL",
|
|
134
|
-
"TERM",
|
|
135
|
-
"COLORTERM",
|
|
136
|
-
"LANG",
|
|
137
|
-
"LC_ALL",
|
|
138
|
-
"LC_CTYPE",
|
|
139
|
-
"LC_MESSAGES",
|
|
140
|
-
"TMPDIR",
|
|
141
|
-
"TMP",
|
|
142
|
-
"TEMP",
|
|
143
|
-
"SSH_AUTH_SOCK",
|
|
144
|
-
"DISPLAY",
|
|
145
|
-
"WAYLAND_DISPLAY",
|
|
146
|
-
"XDG_RUNTIME_DIR",
|
|
147
|
-
"XDG_CONFIG_HOME",
|
|
148
|
-
"XDG_CACHE_HOME",
|
|
149
|
-
"XDG_DATA_HOME",
|
|
150
|
-
// Preserve machine-local AWS shared config path overrides. These are configuration
|
|
151
|
-
// selectors/locations, not credentials, and are required for daemon-owned Bedrock auth
|
|
152
|
-
// on systems that don't use the default ~/.aws paths.
|
|
153
|
-
"AWS_CONFIG_FILE",
|
|
154
|
-
"AWS_SHARED_CREDENTIALS_FILE",
|
|
155
|
-
"NO_COLOR",
|
|
156
|
-
"CI",
|
|
157
|
-
];
|
|
158
|
-
const sanitized = {};
|
|
159
|
-
for (const key of passthrough) {
|
|
160
|
-
const value = env[key];
|
|
161
|
-
if (typeof value === "string" && value.length > 0) {
|
|
162
|
-
sanitized[key] = value;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return { ...sanitized, ...overrides };
|
|
166
|
-
}
|
|
167
|
-
function ensureFreshDaemonBootstrapNetworkConfig(ariaHome) {
|
|
168
|
-
const networkDir = path.join(ariaHome, "network");
|
|
169
|
-
const networkConfigPath = path.join(networkDir, "config.json");
|
|
170
|
-
if (existsSync(networkConfigPath)) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
mkdirSync(networkDir, { recursive: true });
|
|
174
|
-
writeFileSync(networkConfigPath, `${JSON.stringify({ listenPort: 0 }, null, 2)}\n`, {
|
|
175
|
-
encoding: "utf8",
|
|
176
|
-
flag: "wx",
|
|
177
|
-
mode: 0o600,
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
function spawnDetachedDaemonLauncher(options) {
|
|
181
|
-
const args = ["--arion", options.arionName];
|
|
182
|
-
if (typeof options.input.port === "number") {
|
|
183
|
-
args.push("--port", String(options.input.port));
|
|
184
|
-
}
|
|
185
|
-
if (typeof options.input.intervalMs === "number") {
|
|
186
|
-
args.push("--interval-ms", String(options.input.intervalMs));
|
|
187
|
-
}
|
|
188
|
-
if (Array.isArray(options.input.allowedToolCategories) &&
|
|
189
|
-
options.input.allowedToolCategories.length > 0) {
|
|
190
|
-
args.push("--allowed-tool-categories", options.input.allowedToolCategories.join(","));
|
|
191
|
-
}
|
|
192
|
-
if (Array.isArray(options.input.allowedShellCommands) &&
|
|
193
|
-
options.input.allowedShellCommands.length > 0) {
|
|
194
|
-
args.push("--allowed-shell-commands", options.input.allowedShellCommands.join(","));
|
|
195
|
-
}
|
|
196
|
-
if (typeof options.input.maxWriteOpsPerMinute === "number") {
|
|
197
|
-
args.push("--max-write-ops-per-minute", String(options.input.maxWriteOpsPerMinute));
|
|
198
|
-
}
|
|
199
|
-
if (typeof options.input.maxGitPushesPerHour === "number") {
|
|
200
|
-
args.push("--max-git-pushes-per-hour", String(options.input.maxGitPushesPerHour));
|
|
201
|
-
}
|
|
202
|
-
// Defense-in-depth: redirect stderr to a file so uncaught exceptions
|
|
203
|
-
// and native Node warnings are captured even if the log module's file
|
|
204
|
-
// sink hasn't initialized yet. The daemon-launcher configures a proper
|
|
205
|
-
// JSONL file sink inside the child process for structured log output;
|
|
206
|
-
// this stderr redirect catches only what bypasses the log module.
|
|
207
|
-
const logsDir = path.join(options.ariaHome, "logs");
|
|
208
|
-
mkdirSync(logsDir, { recursive: true });
|
|
209
|
-
ensureFreshDaemonBootstrapNetworkConfig(options.ariaHome);
|
|
210
|
-
const stderrFd = openSync(path.join(logsDir, "daemon-stderr.log"), "a");
|
|
211
|
-
const spec = resolveAriaLaunchSpec({
|
|
212
|
-
mode: "daemon",
|
|
213
|
-
args,
|
|
214
|
-
cwd: options.cwd,
|
|
215
|
-
env: sanitizeDaemonEnv(process.env, {
|
|
216
|
-
ARIA_HOME: options.ariaHome,
|
|
217
|
-
}),
|
|
218
|
-
});
|
|
219
|
-
const child = spawnAria(spec, {
|
|
220
|
-
detached: true,
|
|
221
|
-
stdio: ["ignore", "ignore", stderrFd],
|
|
222
|
-
});
|
|
223
|
-
child.unref();
|
|
224
|
-
closeSync(stderrFd); // Parent closes its copy; child inherits the fd
|
|
225
|
-
}
|
|
226
|
-
export function createDaemonService(options) {
|
|
227
|
-
const ariaHome = options.cli.ariaDir;
|
|
228
|
-
let stopOnShutdown = false;
|
|
229
|
-
const resolveScopedArionName = () => options.getArionName?.() ?? options.arionName ?? "ARIA";
|
|
230
|
-
const assertScopedTargetArion = (raw) => {
|
|
231
|
-
const requestedArion = typeof raw.arion === "string" ? raw.arion.trim() : "";
|
|
232
|
-
const scopedArion = resolveScopedArionName();
|
|
233
|
-
if (requestedArion && requestedArion !== scopedArion) {
|
|
234
|
-
throw new Error(`daemon operations are scoped to ${scopedArion}; switch scope with arion.become before targeting ${requestedArion}`);
|
|
235
|
-
}
|
|
236
|
-
return requestedArion || scopedArion;
|
|
237
|
-
};
|
|
238
|
-
const resolveScopedLiveControl = async () => {
|
|
239
|
-
if (!options.localControl) {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
try {
|
|
243
|
-
await options.localControl.getRuntimeStatus();
|
|
244
|
-
return options.localControl;
|
|
245
|
-
}
|
|
246
|
-
catch {
|
|
247
|
-
return null;
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
return {
|
|
251
|
-
async start(input) {
|
|
252
|
-
const arionName = resolveArionName(options.cli, assertScopedTargetArion(input), input);
|
|
253
|
-
const liveControl = await resolveScopedLiveControl();
|
|
254
|
-
if (!liveControl) {
|
|
255
|
-
stopOnShutdown = true;
|
|
256
|
-
spawnDetachedDaemonLauncher({
|
|
257
|
-
ariaHome,
|
|
258
|
-
cwd: options.cwd,
|
|
259
|
-
arionName,
|
|
260
|
-
input,
|
|
261
|
-
});
|
|
262
|
-
return waitForDaemonStatus({ ariaHome, requireRunning: true });
|
|
263
|
-
}
|
|
264
|
-
const before = await liveControl.getRuntimeStatus();
|
|
265
|
-
if (before.autonomousLoop.status === "running") {
|
|
266
|
-
stopOnShutdown = false;
|
|
267
|
-
return before;
|
|
268
|
-
}
|
|
269
|
-
if (!liveControl.startAutonomousLoop) {
|
|
270
|
-
throw new Error("Live runtime does not expose autonomous-loop start control");
|
|
271
|
-
}
|
|
272
|
-
stopOnShutdown = true;
|
|
273
|
-
return liveControl.startAutonomousLoop(toAutonomousLoopCommand(input));
|
|
274
|
-
},
|
|
275
|
-
async status(input = {}) {
|
|
276
|
-
assertScopedTargetArion(input);
|
|
277
|
-
const liveControl = await resolveScopedLiveControl();
|
|
278
|
-
if (!liveControl) {
|
|
279
|
-
throw new Error("No live runtime is available for daemon.status");
|
|
280
|
-
}
|
|
281
|
-
return liveControl.getRuntimeStatus();
|
|
282
|
-
},
|
|
283
|
-
async stop(input = {}) {
|
|
284
|
-
assertScopedTargetArion(input);
|
|
285
|
-
const stopped = await killOwnedDaemonProcess({
|
|
286
|
-
ariaHome,
|
|
287
|
-
liveControl: await resolveScopedLiveControl(),
|
|
288
|
-
});
|
|
289
|
-
stopOnShutdown = false;
|
|
290
|
-
return {
|
|
291
|
-
running: false,
|
|
292
|
-
stopped: true,
|
|
293
|
-
pid: stopped.pid,
|
|
294
|
-
};
|
|
295
|
-
},
|
|
296
|
-
async restart(input = {}) {
|
|
297
|
-
const arionName = resolveArionName(options.cli, assertScopedTargetArion(input), input);
|
|
298
|
-
await killOwnedDaemonProcess({
|
|
299
|
-
ariaHome,
|
|
300
|
-
liveControl: await resolveScopedLiveControl(),
|
|
301
|
-
});
|
|
302
|
-
stopOnShutdown = true;
|
|
303
|
-
spawnDetachedDaemonLauncher({
|
|
304
|
-
ariaHome,
|
|
305
|
-
cwd: options.cwd,
|
|
306
|
-
arionName,
|
|
307
|
-
input,
|
|
308
|
-
});
|
|
309
|
-
const status = await waitForDaemonStatus({ ariaHome, requireRunning: false });
|
|
310
|
-
return status;
|
|
311
|
-
},
|
|
312
|
-
shouldStopOnShutdown() {
|
|
313
|
-
return stopOnShutdown;
|
|
314
|
-
},
|
|
315
|
-
async releaseAll() { },
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
//# sourceMappingURL=daemon-service.js.map
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared hook action implementations used by the `hook.*` headless operations.
|
|
3
|
-
*
|
|
4
|
-
* These functions provide the Memoria/router-backed extraction, reflection,
|
|
5
|
-
* consolidation, ingestion, and harvesting behavior without a dedicated legacy
|
|
6
|
-
* hook CLI mode.
|
|
7
|
-
*/
|
|
8
|
-
import { lightReflection } from "@aria-cli/aria";
|
|
9
|
-
import { ingestClaudeCodeHistory } from "@aria-cli/memoria-bridge";
|
|
10
|
-
const EXTRACT_MAX_PAIRS = 50;
|
|
11
|
-
const EXTRACT_CONCURRENCY = 5;
|
|
12
|
-
function throwIfAborted(signal) {
|
|
13
|
-
if (!signal?.aborted) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const message = signal.reason instanceof Error && signal.reason.message
|
|
17
|
-
? signal.reason.message
|
|
18
|
-
: "The operation was aborted";
|
|
19
|
-
const error = new Error(message);
|
|
20
|
-
error.name = "AbortError";
|
|
21
|
-
throw error;
|
|
22
|
-
}
|
|
23
|
-
function normalizeHarvestInput(input = {}) {
|
|
24
|
-
const normalized = {
|
|
25
|
-
feedback: input.feedback === true,
|
|
26
|
-
extract: input.extract === true,
|
|
27
|
-
stats: input.stats === true,
|
|
28
|
-
cleanup: input.cleanup === true,
|
|
29
|
-
all: input.all === true,
|
|
30
|
-
limit: typeof input.limit === "number" && Number.isInteger(input.limit) && input.limit > 0
|
|
31
|
-
? input.limit
|
|
32
|
-
: 50,
|
|
33
|
-
};
|
|
34
|
-
if (normalized.all) {
|
|
35
|
-
normalized.extract = true;
|
|
36
|
-
normalized.stats = true;
|
|
37
|
-
}
|
|
38
|
-
return normalized;
|
|
39
|
-
}
|
|
40
|
-
export function parseHarvestArgs(args) {
|
|
41
|
-
const limitIdx = args.indexOf("--limit");
|
|
42
|
-
return normalizeHarvestInput({
|
|
43
|
-
feedback: args.includes("--feedback"),
|
|
44
|
-
extract: args.includes("--extract"),
|
|
45
|
-
stats: args.includes("--stats"),
|
|
46
|
-
cleanup: args.includes("--cleanup"),
|
|
47
|
-
all: args.includes("--all"),
|
|
48
|
-
...(limitIdx >= 0 && args[limitIdx + 1]
|
|
49
|
-
? { limit: Number.parseInt(args[limitIdx + 1] ?? "50", 10) || 50 }
|
|
50
|
-
: {}),
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
export async function actionExtract(memoria, stdin, options = {}) {
|
|
54
|
-
throwIfAborted(options.signal);
|
|
55
|
-
if (!stdin) {
|
|
56
|
-
return { output: { error: "no input on stdin" }, exitCode: 1 };
|
|
57
|
-
}
|
|
58
|
-
let pairs;
|
|
59
|
-
try {
|
|
60
|
-
pairs = JSON.parse(stdin);
|
|
61
|
-
if (!Array.isArray(pairs))
|
|
62
|
-
throw new Error("expected array");
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
return {
|
|
66
|
-
output: { error: "stdin must be JSON array of {user, assistant} pairs" },
|
|
67
|
-
exitCode: 1,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
if (pairs.length > EXTRACT_MAX_PAIRS) {
|
|
71
|
-
return {
|
|
72
|
-
output: { error: `hook.extract accepts at most ${EXTRACT_MAX_PAIRS} pairs per request` },
|
|
73
|
-
exitCode: 1,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const results = [];
|
|
77
|
-
let nextIndex = 0;
|
|
78
|
-
const workers = Array.from({ length: Math.min(EXTRACT_CONCURRENCY, pairs.length) }, async () => {
|
|
79
|
-
while (true) {
|
|
80
|
-
throwIfAborted(options.signal);
|
|
81
|
-
const index = nextIndex;
|
|
82
|
-
nextIndex += 1;
|
|
83
|
-
if (index >= pairs.length) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const pair = pairs[index];
|
|
87
|
-
if (!pair.user || !pair.assistant) {
|
|
88
|
-
results[index] = {
|
|
89
|
-
user: pair.user ?? "",
|
|
90
|
-
extracted: 0,
|
|
91
|
-
error: "missing user or assistant",
|
|
92
|
-
};
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
try {
|
|
96
|
-
const result = await memoria.extractFromConversation(pair.user, pair.assistant);
|
|
97
|
-
throwIfAborted(options.signal);
|
|
98
|
-
const learned = result?.learned;
|
|
99
|
-
results[index] = {
|
|
100
|
-
user: pair.user.slice(0, 80),
|
|
101
|
-
extracted: Array.isArray(learned) ? learned.length : 0,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
catch (err) {
|
|
105
|
-
throwIfAborted(options.signal);
|
|
106
|
-
results[index] = {
|
|
107
|
-
user: pair.user.slice(0, 80),
|
|
108
|
-
extracted: 0,
|
|
109
|
-
error: err instanceof Error ? err.message : String(err),
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
await Promise.all(workers);
|
|
115
|
-
return { output: { extracted: results } };
|
|
116
|
-
}
|
|
117
|
-
export async function actionReflect(memoria, router, stdin, options = {}) {
|
|
118
|
-
throwIfAborted(options.signal);
|
|
119
|
-
const messages = [];
|
|
120
|
-
if (stdin) {
|
|
121
|
-
try {
|
|
122
|
-
const parsed = JSON.parse(stdin);
|
|
123
|
-
if (Array.isArray(parsed)) {
|
|
124
|
-
for (const msg of parsed) {
|
|
125
|
-
if (msg.role && msg.content) {
|
|
126
|
-
messages.push({
|
|
127
|
-
role: msg.role,
|
|
128
|
-
content: typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content),
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
catch {
|
|
135
|
-
messages.push({ role: "user", content: "Session review" });
|
|
136
|
-
messages.push({ role: "assistant", content: stdin });
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if (messages.length < 2) {
|
|
140
|
-
return { output: { findings: null, reason: "insufficient conversation" } };
|
|
141
|
-
}
|
|
142
|
-
try {
|
|
143
|
-
const result = await lightReflection(router, memoria, messages);
|
|
144
|
-
throwIfAborted(options.signal);
|
|
145
|
-
return { output: { findings: result } };
|
|
146
|
-
}
|
|
147
|
-
catch (err) {
|
|
148
|
-
throwIfAborted(options.signal);
|
|
149
|
-
return {
|
|
150
|
-
output: {
|
|
151
|
-
findings: null,
|
|
152
|
-
error: err instanceof Error ? err.message : String(err),
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
export async function actionConsolidate(memoria, options = {}) {
|
|
158
|
-
throwIfAborted(options.signal);
|
|
159
|
-
try {
|
|
160
|
-
const stats = await memoria.reflect({ full: false });
|
|
161
|
-
throwIfAborted(options.signal);
|
|
162
|
-
return { output: stats };
|
|
163
|
-
}
|
|
164
|
-
catch (err) {
|
|
165
|
-
throwIfAborted(options.signal);
|
|
166
|
-
return {
|
|
167
|
-
output: {
|
|
168
|
-
error: err instanceof Error ? err.message : String(err),
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
export async function actionIngest(memoria, options = {}) {
|
|
174
|
-
throwIfAborted(options.signal);
|
|
175
|
-
try {
|
|
176
|
-
const result = await ingestClaudeCodeHistory(memoria);
|
|
177
|
-
throwIfAborted(options.signal);
|
|
178
|
-
return { output: result };
|
|
179
|
-
}
|
|
180
|
-
catch (err) {
|
|
181
|
-
throwIfAborted(options.signal);
|
|
182
|
-
return {
|
|
183
|
-
output: {
|
|
184
|
-
error: err instanceof Error ? err.message : String(err),
|
|
185
|
-
},
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
export async function actionHarvest(memoria, router, input = {}, options = {}) {
|
|
190
|
-
throwIfAborted(options.signal);
|
|
191
|
-
const flags = normalizeHarvestInput(input);
|
|
192
|
-
if (!flags.feedback && !flags.extract && !flags.stats && !flags.cleanup) {
|
|
193
|
-
return {
|
|
194
|
-
output: {
|
|
195
|
-
help: "Use hook.harvest via `aria call` or the persistent headless server.",
|
|
196
|
-
actions: [
|
|
197
|
-
"--extract: session extraction WITH LLM",
|
|
198
|
-
"--stats: health dashboard (includes learning velocity + dupe rate)",
|
|
199
|
-
"--cleanup: garbage removal",
|
|
200
|
-
"--all: extract + stats",
|
|
201
|
-
"--feedback: (deprecated, no-op)",
|
|
202
|
-
],
|
|
203
|
-
},
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
const results = {};
|
|
207
|
-
if (flags.extract) {
|
|
208
|
-
process.stderr.write("[harvest] Running extraction...\n");
|
|
209
|
-
throwIfAborted(options.signal);
|
|
210
|
-
results.extract = toHarvestExtractResult(await actionReflect(memoria, router, "", options));
|
|
211
|
-
}
|
|
212
|
-
if (flags.stats) {
|
|
213
|
-
try {
|
|
214
|
-
throwIfAborted(options.signal);
|
|
215
|
-
results.stats = await memoria.reflect({ full: false });
|
|
216
|
-
throwIfAborted(options.signal);
|
|
217
|
-
}
|
|
218
|
-
catch (err) {
|
|
219
|
-
throwIfAborted(options.signal);
|
|
220
|
-
results.stats = { error: err instanceof Error ? err.message : String(err) };
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
if (flags.cleanup) {
|
|
224
|
-
results.cleanup = { skipped: true, message: "cleanup remains a no-op in headless cutover" };
|
|
225
|
-
}
|
|
226
|
-
if (flags.feedback) {
|
|
227
|
-
process.stderr.write("[harvest] --feedback is deprecated and has no effect.\n");
|
|
228
|
-
results.feedback = { deprecated: true };
|
|
229
|
-
}
|
|
230
|
-
return { output: results };
|
|
231
|
-
}
|
|
232
|
-
function toHarvestExtractResult(result) {
|
|
233
|
-
return result.output;
|
|
234
|
-
}
|
|
235
|
-
//# sourceMappingURL=hook-actions.js.map
|