@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.
- package/bin/aria.mjs +799 -668
- 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,279 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { OutboundMessageSchema } from "@aria-cli/tools";
|
|
3
|
-
import { failureResult, successResult } from "./utils.js";
|
|
4
|
-
function parseSendArgs(input) {
|
|
5
|
-
const trimmed = input.trim();
|
|
6
|
-
if (!trimmed) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
const separatorIndex = trimmed.indexOf(" ");
|
|
10
|
-
if (separatorIndex <= 0) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
const recipient = trimmed.slice(0, separatorIndex).trim();
|
|
14
|
-
const content = trimmed.slice(separatorIndex + 1).trim();
|
|
15
|
-
if (!recipient || !content) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return { recipient, content };
|
|
19
|
-
}
|
|
20
|
-
function normalizePeerLabel(peer) {
|
|
21
|
-
return peer.displayNameSnapshot?.trim() || peer.nodeId;
|
|
22
|
-
}
|
|
23
|
-
function normalizeAttachedClientLabel(client) {
|
|
24
|
-
return client.displayLabel.trim() || client.clientId;
|
|
25
|
-
}
|
|
26
|
-
function formatAttachedClientLabel(client) {
|
|
27
|
-
const displayLabel = normalizeAttachedClientLabel(client);
|
|
28
|
-
return displayLabel === client.clientId
|
|
29
|
-
? client.clientId
|
|
30
|
-
: `${displayLabel} (${client.clientId})`;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Parse @peer/arion or @peer#client syntax.
|
|
34
|
-
*
|
|
35
|
-
* Examples:
|
|
36
|
-
* "@vm1" → { peer: "vm1" }
|
|
37
|
-
* "@vm1/CodeReviewer" → { peer: "vm1", arion: "CodeReviewer" }
|
|
38
|
-
* "@vm1#my-tui" → { peer: "vm1", client: "my-tui" }
|
|
39
|
-
* "vm1/ARIA" → { peer: "vm1", arion: "ARIA" }
|
|
40
|
-
*/
|
|
41
|
-
function parseMention(ref) {
|
|
42
|
-
const cleaned = ref.trim().replace(/^@/, "");
|
|
43
|
-
// Check for client addressing: peer#client
|
|
44
|
-
const hashIdx = cleaned.indexOf("#");
|
|
45
|
-
if (hashIdx > 0) {
|
|
46
|
-
return {
|
|
47
|
-
peer: cleaned.slice(0, hashIdx),
|
|
48
|
-
client: cleaned.slice(hashIdx + 1) || undefined,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
// Check for arion addressing: peer/arion
|
|
52
|
-
const slashIdx = cleaned.indexOf("/");
|
|
53
|
-
if (slashIdx > 0) {
|
|
54
|
-
return {
|
|
55
|
-
peer: cleaned.slice(0, slashIdx),
|
|
56
|
-
arion: cleaned.slice(slashIdx + 1) || undefined,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
return { peer: cleaned };
|
|
60
|
-
}
|
|
61
|
-
function resolveRecipient(peers, peerRef) {
|
|
62
|
-
// Strip @prefix for @mention support
|
|
63
|
-
const { peer: normalizedRef } = parseMention(peerRef);
|
|
64
|
-
const exactNodeId = peers.find((peer) => peer.nodeId.toLowerCase() === normalizedRef);
|
|
65
|
-
if (exactNodeId) {
|
|
66
|
-
return exactNodeId;
|
|
67
|
-
}
|
|
68
|
-
const displayMatches = peers.filter((peer) => normalizePeerLabel(peer).toLowerCase() === normalizedRef);
|
|
69
|
-
if (displayMatches.length === 1) {
|
|
70
|
-
return displayMatches[0];
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
function hasAmbiguousRecipient(peers, peerRef) {
|
|
75
|
-
const normalizedRef = peerRef.trim().toLowerCase().replace(/^@/, "");
|
|
76
|
-
return (peers.filter((peer) => normalizePeerLabel(peer).toLowerCase() === normalizedRef).length > 1);
|
|
77
|
-
}
|
|
78
|
-
function resolveAttachedClient(clients, clientRef) {
|
|
79
|
-
const normalizedRef = clientRef.trim().toLowerCase().replace(/^@/, "");
|
|
80
|
-
return clients.find((client) => client.clientId.toLowerCase() === normalizedRef) ?? null;
|
|
81
|
-
}
|
|
82
|
-
function resolveAttachedClientDisplayLabel(clients, clientRef) {
|
|
83
|
-
const normalizedRef = clientRef.trim().toLowerCase();
|
|
84
|
-
return (clients.find((client) => normalizeAttachedClientLabel(client).toLowerCase() === normalizedRef) ?? null);
|
|
85
|
-
}
|
|
86
|
-
function buildPeerOutboundMessage(input) {
|
|
87
|
-
const metadata = {};
|
|
88
|
-
if (input.targetArion)
|
|
89
|
-
metadata.targetArion = input.targetArion;
|
|
90
|
-
if (input.targetClient)
|
|
91
|
-
metadata.targetClient = input.targetClient;
|
|
92
|
-
const hasMetadata = Object.keys(metadata).length > 0;
|
|
93
|
-
return {
|
|
94
|
-
rawMessage: {
|
|
95
|
-
version: 1,
|
|
96
|
-
id: `headless-send-${randomUUID()}`,
|
|
97
|
-
sender: {
|
|
98
|
-
id: input.senderNodeId,
|
|
99
|
-
name: input.senderName,
|
|
100
|
-
type: "arion",
|
|
101
|
-
},
|
|
102
|
-
recipient: {
|
|
103
|
-
id: input.recipient.nodeId,
|
|
104
|
-
name: normalizePeerLabel(input.recipient),
|
|
105
|
-
type: "peer",
|
|
106
|
-
},
|
|
107
|
-
type: "message",
|
|
108
|
-
content: input.content,
|
|
109
|
-
timestamp: Date.now(),
|
|
110
|
-
priority: 2,
|
|
111
|
-
...(hasMetadata ? { metadata } : {}),
|
|
112
|
-
},
|
|
113
|
-
to: input.recipient.nodeId,
|
|
114
|
-
type: "message",
|
|
115
|
-
content: input.content,
|
|
116
|
-
priority: 2,
|
|
117
|
-
...(hasMetadata ? { metadata } : {}),
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
function buildClientOutboundMessage(input) {
|
|
121
|
-
return {
|
|
122
|
-
rawMessage: {
|
|
123
|
-
version: 1,
|
|
124
|
-
id: `headless-send-${randomUUID()}`,
|
|
125
|
-
sender: {
|
|
126
|
-
id: input.senderNodeId,
|
|
127
|
-
name: input.senderName,
|
|
128
|
-
type: "arion",
|
|
129
|
-
},
|
|
130
|
-
recipient: {
|
|
131
|
-
id: input.recipient.clientId,
|
|
132
|
-
name: normalizeAttachedClientLabel(input.recipient),
|
|
133
|
-
type: "client",
|
|
134
|
-
},
|
|
135
|
-
type: "message",
|
|
136
|
-
content: input.content,
|
|
137
|
-
timestamp: Date.now(),
|
|
138
|
-
priority: 2,
|
|
139
|
-
},
|
|
140
|
-
recipientInbox: {
|
|
141
|
-
kind: "client",
|
|
142
|
-
clientId: input.recipient.clientId,
|
|
143
|
-
},
|
|
144
|
-
type: "message",
|
|
145
|
-
content: input.content,
|
|
146
|
-
priority: 2,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
async function resolveStructuredMessage(ctx, input) {
|
|
150
|
-
const parsed = typeof input.args === "string" && input.args.trim().length > 0
|
|
151
|
-
? parseSendArgs(input.args)
|
|
152
|
-
: input.recipient && input.content
|
|
153
|
-
? { recipient: input.recipient, content: input.content }
|
|
154
|
-
: null;
|
|
155
|
-
if (!parsed) {
|
|
156
|
-
return {
|
|
157
|
-
ok: false,
|
|
158
|
-
code: "MESSAGE_SEND_FAILED",
|
|
159
|
-
message: "Usage: /send <peer-name|node-id|client-id> <message>",
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
const [peers, attachedClients, runtimeStatus] = await Promise.all([
|
|
163
|
-
ctx.localControl.listPeers(),
|
|
164
|
-
ctx.localControl.listAttachedClients(),
|
|
165
|
-
ctx.localControl.getRuntimeStatus(),
|
|
166
|
-
]);
|
|
167
|
-
const senderName = input.senderName?.trim() || "ARIA";
|
|
168
|
-
const attachedClient = resolveAttachedClient(attachedClients, parsed.recipient);
|
|
169
|
-
if (attachedClient) {
|
|
170
|
-
if (attachedClient.self) {
|
|
171
|
-
return {
|
|
172
|
-
ok: false,
|
|
173
|
-
code: "MESSAGE_SEND_FAILED",
|
|
174
|
-
message: "Cannot send a same-home message to yourself.",
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
return {
|
|
178
|
-
ok: true,
|
|
179
|
-
outbound: buildClientOutboundMessage({
|
|
180
|
-
senderNodeId: runtimeStatus.nodeId,
|
|
181
|
-
senderName,
|
|
182
|
-
recipient: attachedClient,
|
|
183
|
-
content: parsed.content,
|
|
184
|
-
}),
|
|
185
|
-
message: `Sent message to ${formatAttachedClientLabel(attachedClient)}.`,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
if (hasAmbiguousRecipient(peers, parsed.recipient)) {
|
|
189
|
-
return {
|
|
190
|
-
ok: false,
|
|
191
|
-
code: "MESSAGE_SEND_FAILED",
|
|
192
|
-
message: `Multiple peers match "${parsed.recipient}". Use the nodeId instead.`,
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
const recipient = resolveRecipient(peers, parsed.recipient);
|
|
196
|
-
if (!recipient) {
|
|
197
|
-
const matchedClientByLabel = resolveAttachedClientDisplayLabel(attachedClients, parsed.recipient);
|
|
198
|
-
if (matchedClientByLabel) {
|
|
199
|
-
return {
|
|
200
|
-
ok: false,
|
|
201
|
-
code: "MESSAGE_SEND_FAILED",
|
|
202
|
-
message: `Same-home clients require the exact clientId. Use /clients to choose ${formatAttachedClientLabel(matchedClientByLabel)}.`,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
return {
|
|
206
|
-
ok: false,
|
|
207
|
-
code: "MESSAGE_SEND_FAILED",
|
|
208
|
-
message: `Recipient "${parsed.recipient}" not found.`,
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
const mention = parseMention(parsed.recipient);
|
|
212
|
-
const targetLabel = mention.arion
|
|
213
|
-
? `${normalizePeerLabel(recipient)}/${mention.arion}`
|
|
214
|
-
: mention.client
|
|
215
|
-
? `${normalizePeerLabel(recipient)}#${mention.client}`
|
|
216
|
-
: normalizePeerLabel(recipient);
|
|
217
|
-
return {
|
|
218
|
-
ok: true,
|
|
219
|
-
outbound: buildPeerOutboundMessage({
|
|
220
|
-
senderNodeId: runtimeStatus.nodeId,
|
|
221
|
-
senderName,
|
|
222
|
-
recipient,
|
|
223
|
-
content: parsed.content,
|
|
224
|
-
targetArion: mention.arion,
|
|
225
|
-
targetClient: mention.client,
|
|
226
|
-
}),
|
|
227
|
-
message: `Sent message to ${targetLabel}.`,
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
function toDeliveryMessage(receipt, fallback) {
|
|
231
|
-
if (receipt.deliveryState === "queued_for_route") {
|
|
232
|
-
return fallback.replace(/^Sent/, "Queued");
|
|
233
|
-
}
|
|
234
|
-
if (receipt.deliveryState === "dispatching") {
|
|
235
|
-
return `${fallback.slice(0, -1)}; awaiting acknowledgement.`;
|
|
236
|
-
}
|
|
237
|
-
if (receipt.delivered) {
|
|
238
|
-
return fallback.replace(/^Sent/, "Delivered");
|
|
239
|
-
}
|
|
240
|
-
return fallback;
|
|
241
|
-
}
|
|
242
|
-
export function createMessageOperationHandlers(ctx) {
|
|
243
|
-
return {
|
|
244
|
-
"message.send": async function* (requestId, input) {
|
|
245
|
-
const outbound = OutboundMessageSchema.safeParse(input);
|
|
246
|
-
if (outbound.success) {
|
|
247
|
-
yield successResult(requestId, "message.send", {
|
|
248
|
-
receipt: await ctx.localControl.sendDurable(outbound.data),
|
|
249
|
-
});
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
const hasStructuredProjectionInput = input &&
|
|
253
|
-
typeof input === "object" &&
|
|
254
|
-
(typeof input.args === "string" ||
|
|
255
|
-
typeof input.recipient === "string" ||
|
|
256
|
-
typeof input.content === "string");
|
|
257
|
-
if (!hasStructuredProjectionInput) {
|
|
258
|
-
yield failureResult(requestId, "message.send", "INVALID_INPUT", "Invalid input for message.send");
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
const resolved = await resolveStructuredMessage(ctx, input);
|
|
262
|
-
if (!resolved.ok) {
|
|
263
|
-
yield failureResult(requestId, "message.send", resolved.code, resolved.message);
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
const receipt = await ctx.localControl.sendDurable(resolved.outbound);
|
|
267
|
-
yield successResult(requestId, "message.send", {
|
|
268
|
-
receipt,
|
|
269
|
-
message: toDeliveryMessage(receipt, resolved.message),
|
|
270
|
-
});
|
|
271
|
-
},
|
|
272
|
-
"message.inbox.list": async function* (requestId, input) {
|
|
273
|
-
yield successResult(requestId, "message.inbox.list", {
|
|
274
|
-
events: await ctx.localControl.listInbox(input),
|
|
275
|
-
});
|
|
276
|
-
},
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
//# sourceMappingURL=message.js.map
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { failureResult, successResult, unsupportedWhenMissing } from "./utils.js";
|
|
2
|
-
export function createModelOperationHandlers(ctx) {
|
|
3
|
-
const localControl = ctx.localControl;
|
|
4
|
-
if (localControl) {
|
|
5
|
-
return {
|
|
6
|
-
"model.list": async function* (requestId, input) {
|
|
7
|
-
const lc = localControl;
|
|
8
|
-
const providers = Array.isArray(input.providers)
|
|
9
|
-
? (input.providers ?? [])
|
|
10
|
-
.filter((value) => typeof value === "string" && value.trim().length > 0)
|
|
11
|
-
.map((value) => value.trim())
|
|
12
|
-
: undefined;
|
|
13
|
-
const snapshot = await lc.getModelSnapshot();
|
|
14
|
-
yield successResult(requestId, "model.list", {
|
|
15
|
-
models: snapshot.models,
|
|
16
|
-
currentModel: snapshot.currentModel,
|
|
17
|
-
lastRefreshAt: snapshot.lastRefreshAt,
|
|
18
|
-
stale: snapshot.stale,
|
|
19
|
-
refreshInFlight: snapshot.refreshInFlight,
|
|
20
|
-
providerStatuses: snapshot.providerStatuses,
|
|
21
|
-
});
|
|
22
|
-
},
|
|
23
|
-
"model.set": async function* (requestId, input) {
|
|
24
|
-
const lc = localControl;
|
|
25
|
-
const model = input.model?.trim();
|
|
26
|
-
if (!model) {
|
|
27
|
-
yield failureResult(requestId, "model.set", "MODEL_SET_FAILED", "model.set requires a model");
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const snapshot = await lc.setCurrentModel(model);
|
|
31
|
-
const selected = snapshot.models.find((entry) => typeof entry.shortName === "string" &&
|
|
32
|
-
typeof entry.id === "string" &&
|
|
33
|
-
(entry.shortName.toLowerCase() === (snapshot.currentModel ?? model).toLowerCase() ||
|
|
34
|
-
entry.id.toLowerCase() === (snapshot.currentModel ?? model).toLowerCase()));
|
|
35
|
-
yield successResult(requestId, "model.set", {
|
|
36
|
-
currentModel: snapshot.currentModel ?? model,
|
|
37
|
-
tier: selected?.tier,
|
|
38
|
-
lastRefreshAt: snapshot.lastRefreshAt,
|
|
39
|
-
stale: snapshot.stale,
|
|
40
|
-
refreshInFlight: snapshot.refreshInFlight,
|
|
41
|
-
providerStatuses: snapshot.providerStatuses,
|
|
42
|
-
});
|
|
43
|
-
},
|
|
44
|
-
"model.refresh": async function* (requestId, input) {
|
|
45
|
-
const lc = localControl;
|
|
46
|
-
const providers = Array.isArray(input.providers)
|
|
47
|
-
? (input.providers ?? [])
|
|
48
|
-
.filter((value) => typeof value === "string" && value.trim().length > 0)
|
|
49
|
-
.map((value) => value.trim())
|
|
50
|
-
: undefined;
|
|
51
|
-
const snapshot = await lc.refreshModelSnapshot(providers?.length ? { providers } : undefined);
|
|
52
|
-
yield successResult(requestId, "model.refresh", {
|
|
53
|
-
models: snapshot.models,
|
|
54
|
-
currentModel: snapshot.currentModel,
|
|
55
|
-
lastRefreshAt: snapshot.lastRefreshAt,
|
|
56
|
-
stale: snapshot.stale,
|
|
57
|
-
refreshInFlight: snapshot.refreshInFlight,
|
|
58
|
-
providerStatuses: snapshot.providerStatuses,
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
const discovery = ctx.modelDiscovery;
|
|
64
|
-
if (!discovery?.listAvailable || !discovery.refresh || !discovery.setCurrentModel) {
|
|
65
|
-
return {
|
|
66
|
-
"model.list": unsupportedWhenMissing("modelDiscovery", "model.list"),
|
|
67
|
-
"model.set": unsupportedWhenMissing("modelDiscovery", "model.set"),
|
|
68
|
-
"model.refresh": unsupportedWhenMissing("modelDiscovery", "model.refresh"),
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
"model.list": async function* (requestId) {
|
|
73
|
-
const listAvailable = discovery.listAvailable;
|
|
74
|
-
yield successResult(requestId, "model.list", {
|
|
75
|
-
models: await listAvailable(),
|
|
76
|
-
currentModel: await discovery.getCurrentModel?.(),
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
"model.set": async function* (requestId, input) {
|
|
80
|
-
const setCurrentModel = discovery.setCurrentModel;
|
|
81
|
-
const model = input.model?.trim();
|
|
82
|
-
if (!model) {
|
|
83
|
-
yield failureResult(requestId, "model.set", "MODEL_SET_FAILED", "model.set requires a model");
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const result = await setCurrentModel(model);
|
|
87
|
-
yield successResult(requestId, "model.set", {
|
|
88
|
-
currentModel: model,
|
|
89
|
-
...(result && typeof result === "object" ? result : {}),
|
|
90
|
-
});
|
|
91
|
-
},
|
|
92
|
-
"model.refresh": async function* (requestId) {
|
|
93
|
-
const refresh = discovery.refresh;
|
|
94
|
-
yield successResult(requestId, "model.refresh", {
|
|
95
|
-
models: await refresh(true),
|
|
96
|
-
});
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=model.js.map
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { successResult } from "./utils.js";
|
|
2
|
-
export function createPeerOperationHandlers(ctx) {
|
|
3
|
-
return {
|
|
4
|
-
"peer.list": async function* (requestId) {
|
|
5
|
-
yield successResult(requestId, "peer.list", {
|
|
6
|
-
peers: await ctx.localControl.listPeers(),
|
|
7
|
-
});
|
|
8
|
-
},
|
|
9
|
-
"peer.list_nearby": async function* (requestId) {
|
|
10
|
-
yield successResult(requestId, "peer.list_nearby", {
|
|
11
|
-
peers: await ctx.localControl.listNearbyPeers(),
|
|
12
|
-
});
|
|
13
|
-
},
|
|
14
|
-
"peer.pending.list": async function* (requestId) {
|
|
15
|
-
yield successResult(requestId, "peer.pending.list", {
|
|
16
|
-
requests: await ctx.localControl.listPendingPairRequests(),
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
"peer.pending.respond": async function* (requestId, input) {
|
|
20
|
-
yield successResult(requestId, "peer.pending.respond", {
|
|
21
|
-
response: await ctx.localControl.respondToPairRequest(input),
|
|
22
|
-
});
|
|
23
|
-
},
|
|
24
|
-
"peer.invite": async function* (requestId, input) {
|
|
25
|
-
yield successResult(requestId, "peer.invite", {
|
|
26
|
-
invite: await ctx.localControl.createInvite(input),
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
"peer.connect": async function* (requestId, input) {
|
|
30
|
-
yield successResult(requestId, "peer.connect", {
|
|
31
|
-
invite: await ctx.localControl.invitePeer(input),
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
"peer.accept_invite": async function* (requestId, input) {
|
|
35
|
-
yield successResult(requestId, "peer.accept_invite", {
|
|
36
|
-
accepted: await ctx.localControl.acceptInviteToken(input),
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
"peer.direct_pair": async function* (requestId, input) {
|
|
40
|
-
yield successResult(requestId, "peer.direct_pair", {
|
|
41
|
-
pair: await ctx.localControl.directPair(input),
|
|
42
|
-
});
|
|
43
|
-
},
|
|
44
|
-
"peer.repair": async function* (requestId, input) {
|
|
45
|
-
yield successResult(requestId, "peer.repair", {
|
|
46
|
-
repair: await ctx.localControl.repairPeer(input),
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
"peer.revoke": async function* (requestId, input) {
|
|
50
|
-
yield successResult(requestId, "peer.revoke", {
|
|
51
|
-
revoke: await ctx.localControl.revokePeer(input),
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=peer.js.map
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export function createRunOperationHandlers(orchestrator) {
|
|
2
|
-
return {
|
|
3
|
-
"run.start": async function* (requestId, input, context) {
|
|
4
|
-
yield* orchestrator.start(requestId, input, context?.signal);
|
|
5
|
-
},
|
|
6
|
-
"run.resume": async function* (requestId, input, context) {
|
|
7
|
-
yield* orchestrator.resume(requestId, input, context?.signal);
|
|
8
|
-
},
|
|
9
|
-
"run.abort": async function* (requestId, input, context) {
|
|
10
|
-
yield* orchestrator.abort(requestId, input, context?.activeRunController);
|
|
11
|
-
},
|
|
12
|
-
"interaction.respond": async function* (requestId, input, context) {
|
|
13
|
-
const response = input && typeof input === "object" && "kind" in input
|
|
14
|
-
? input
|
|
15
|
-
: {
|
|
16
|
-
kind: "interaction.respond",
|
|
17
|
-
requestId,
|
|
18
|
-
...input,
|
|
19
|
-
};
|
|
20
|
-
yield* orchestrator.respond(response, context?.signal);
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=run.js.map
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { failureResult, successResult } from "./utils.js";
|
|
2
|
-
function toHeadlessSessionSummary(summary) {
|
|
3
|
-
return {
|
|
4
|
-
...summary,
|
|
5
|
-
createdAt: summary.createdAt.toISOString(),
|
|
6
|
-
updatedAt: summary.updatedAt.toISOString(),
|
|
7
|
-
...(summary.completedAt ? { completedAt: summary.completedAt.toISOString() } : {}),
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
function normalizeSessionId(input) {
|
|
11
|
-
const raw = input.sessionId;
|
|
12
|
-
return typeof raw === "string" ? raw.trim() : "";
|
|
13
|
-
}
|
|
14
|
-
export function buildSessionListResult(requestId, sessionLedger, input) {
|
|
15
|
-
const args = input;
|
|
16
|
-
const sessions = typeof args.query === "string" && args.query.trim().length > 0
|
|
17
|
-
? sessionLedger.searchSessionSummaries(args.query, args.limit ?? 20, args.offset ?? 0)
|
|
18
|
-
: sessionLedger.listSessions(args.limit ?? 20, args.offset ?? 0);
|
|
19
|
-
return successResult(requestId, "session.list", {
|
|
20
|
-
sessions: sessions.map(toHeadlessSessionSummary),
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
export function buildSessionReadResult(requestId, sessionLedger, input) {
|
|
24
|
-
const sessionId = normalizeSessionId(input);
|
|
25
|
-
if (!sessionId) {
|
|
26
|
-
return failureResult(requestId, "session.read", "SESSION_READ_FAILED", "session.read requires a sessionId");
|
|
27
|
-
}
|
|
28
|
-
const resolvedId = sessionLedger.findSessionByPrefix(sessionId) ?? sessionId;
|
|
29
|
-
const session = sessionLedger.loadSessionMessages(resolvedId);
|
|
30
|
-
if (!session) {
|
|
31
|
-
return failureResult(requestId, "session.read", "SESSION_NOT_FOUND", `Session ${sessionId} not found`);
|
|
32
|
-
}
|
|
33
|
-
return successResult(requestId, "session.read", { session });
|
|
34
|
-
}
|
|
35
|
-
export function buildSessionLoadResult(requestId, sessionLedger, input) {
|
|
36
|
-
const sessionId = normalizeSessionId(input);
|
|
37
|
-
if (!sessionId) {
|
|
38
|
-
return failureResult(requestId, "session.load", "SESSION_LOAD_FAILED", "session.load requires a sessionId");
|
|
39
|
-
}
|
|
40
|
-
const resolvedId = sessionLedger.findSessionByPrefix(sessionId) ?? sessionId;
|
|
41
|
-
const loaded = sessionLedger.loadSession(resolvedId);
|
|
42
|
-
if (!loaded) {
|
|
43
|
-
return failureResult(requestId, "session.load", "SESSION_NOT_FOUND", `Session ${sessionId} not found`);
|
|
44
|
-
}
|
|
45
|
-
return successResult(requestId, "session.load", {
|
|
46
|
-
session: loaded.session,
|
|
47
|
-
loaded: true,
|
|
48
|
-
...(loaded.runtimeState ? { runtimeState: loaded.runtimeState } : {}),
|
|
49
|
-
...(loaded.pendingInteraction ? { pendingInteraction: loaded.pendingInteraction } : {}),
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
export function buildSessionForkResult(requestId, sessionLedger, input) {
|
|
53
|
-
const args = input;
|
|
54
|
-
const sessionId = typeof args.sessionId === "string" ? args.sessionId.trim() : "";
|
|
55
|
-
if (!sessionId) {
|
|
56
|
-
return failureResult(requestId, "session.fork", "SESSION_FORK_FAILED", "session.fork requires a sessionId");
|
|
57
|
-
}
|
|
58
|
-
const resolvedId = sessionLedger.findSessionByPrefix(sessionId) ?? sessionId;
|
|
59
|
-
try {
|
|
60
|
-
const result = sessionLedger.forkSession(resolvedId, {
|
|
61
|
-
messageLimit: args.messageLimit,
|
|
62
|
-
});
|
|
63
|
-
return successResult(requestId, "session.fork", {
|
|
64
|
-
newSessionId: result.newSessionId,
|
|
65
|
-
sourceSessionId: result.sourceSessionId,
|
|
66
|
-
messagesCopied: result.messagesCopied,
|
|
67
|
-
title: result.title,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
return failureResult(requestId, "session.fork", "SESSION_NOT_FOUND", error.message);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
export function createSessionOperationHandlers(ctx) {
|
|
75
|
-
return {
|
|
76
|
-
"session.list": async function* (requestId, input) {
|
|
77
|
-
yield buildSessionListResult(requestId, ctx.sessionLedger, input);
|
|
78
|
-
},
|
|
79
|
-
"session.read": async function* (requestId, input) {
|
|
80
|
-
yield buildSessionReadResult(requestId, ctx.sessionLedger, input);
|
|
81
|
-
},
|
|
82
|
-
"session.load": async function* (requestId, input) {
|
|
83
|
-
yield buildSessionLoadResult(requestId, ctx.sessionLedger, input);
|
|
84
|
-
},
|
|
85
|
-
"session.fork": async function* (requestId, input) {
|
|
86
|
-
yield buildSessionForkResult(requestId, ctx.sessionLedger, input);
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=session.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { successResult, unsupportedWhenMissing } from "./utils.js";
|
|
2
|
-
export function createSystemOperationHandlers(ctx) {
|
|
3
|
-
const system = ctx.system;
|
|
4
|
-
if (!system?.restart || !system.terminalSetup) {
|
|
5
|
-
return {
|
|
6
|
-
"system.restart": unsupportedWhenMissing("system", "system.restart"),
|
|
7
|
-
"system.terminal_setup": unsupportedWhenMissing("system", "system.terminal_setup"),
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
return {
|
|
11
|
-
"system.restart": async function* (requestId, input) {
|
|
12
|
-
yield successResult(requestId, "system.restart", await system.restart(input));
|
|
13
|
-
},
|
|
14
|
-
"system.terminal_setup": async function* (requestId) {
|
|
15
|
-
yield successResult(requestId, "system.terminal_setup", await system.terminalSetup());
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=system.js.map
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { HEADLESS_OPERATION_SCHEMAS } from "@aria-cli/tools";
|
|
2
|
-
export function successResult(requestId, op, result) {
|
|
3
|
-
const parsed = HEADLESS_OPERATION_SCHEMAS[op].result.safeParse(result);
|
|
4
|
-
if (!parsed.success) {
|
|
5
|
-
throw new Error(`Invalid headless result for ${op}: ${parsed.error.issues
|
|
6
|
-
.map((issue) => `${issue.path.join(".") || "<root>"} ${issue.message}`)
|
|
7
|
-
.join("; ")}`);
|
|
8
|
-
}
|
|
9
|
-
return {
|
|
10
|
-
kind: "result",
|
|
11
|
-
requestId,
|
|
12
|
-
op,
|
|
13
|
-
ok: true,
|
|
14
|
-
result: parsed.data,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export function failureResult(requestId, op, code, message, details) {
|
|
18
|
-
return {
|
|
19
|
-
kind: "result",
|
|
20
|
-
requestId,
|
|
21
|
-
op,
|
|
22
|
-
ok: false,
|
|
23
|
-
error: {
|
|
24
|
-
code,
|
|
25
|
-
message,
|
|
26
|
-
...(details ? { details } : {}),
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
export function unsupportedWhenMissing(serviceName, op) {
|
|
31
|
-
return async function* (requestId) {
|
|
32
|
-
yield failureResult(requestId, op, "MISSING_SERVICE", `Kernel service ${serviceName} is not configured for ${op}.`);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=utils.js.map
|