@aria-cli/cli 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/bin/aria-dev.js +15 -0
  2. package/bin/aria.js +366 -0
  3. package/bin/install-owner-lease.d.ts +8 -0
  4. package/bin/install-owner-lease.js +53 -0
  5. package/dist/.aria-build-stamp.json +4 -0
  6. package/dist/attached-local-control-client.d.ts +90 -0
  7. package/dist/bootstrap-local-control-client.d.ts +1 -0
  8. package/dist/capability-aware-method-proxy.d.ts +1 -0
  9. package/dist/cli-context.d.ts +31 -0
  10. package/dist/commands/arions.d.ts +14 -0
  11. package/dist/commands/auth.d.ts +27 -0
  12. package/dist/commands/daemon.d.ts +31 -0
  13. package/dist/commands/definitions.d.ts +19 -0
  14. package/dist/commands/index.d.ts +13 -0
  15. package/dist/commands/login-handler.d.ts +108 -0
  16. package/dist/commands/logout-handler.d.ts +24 -0
  17. package/dist/commands/memory-handlers.d.ts +15 -0
  18. package/dist/commands/pairing.d.ts +2 -0
  19. package/dist/commands/peer-message-handler.d.ts +7 -0
  20. package/dist/commands/runtime-cutover-reset-command.d.ts +2 -0
  21. package/dist/commands/runtime-cutover-reset.d.ts +26 -0
  22. package/dist/commands/terminal-setup.d.ts +3 -0
  23. package/dist/config/aria-config.d.ts +50 -0
  24. package/dist/config/index.d.ts +4 -0
  25. package/dist/config/loader.d.ts +17 -0
  26. package/dist/config.d.ts +53 -0
  27. package/dist/daemon-info.d.ts +17 -0
  28. package/dist/ensure-daemon.d.ts +21 -0
  29. package/dist/event-loop-watchdog.d.ts +31 -0
  30. package/dist/headless/auth-orchestrator.d.ts +19 -0
  31. package/dist/headless/auth-service.d.ts +15 -0
  32. package/dist/headless/bootstrap-fast-path.d.ts +12 -0
  33. package/dist/headless/call-command.d.ts +8 -0
  34. package/dist/headless/daemon-service.d.ts +14 -0
  35. package/dist/headless/hook-actions.d.ts +40 -0
  36. package/dist/headless/hook-service.d.ts +8 -0
  37. package/dist/headless/kernel-services.d.ts +8 -0
  38. package/dist/headless/kernel.d.ts +118 -0
  39. package/dist/headless/operations/arion.d.ts +3 -0
  40. package/dist/headless/operations/auth.d.ts +4 -0
  41. package/dist/headless/operations/client.d.ts +2 -0
  42. package/dist/headless/operations/config.d.ts +3 -0
  43. package/dist/headless/operations/daemon.d.ts +3 -0
  44. package/dist/headless/operations/hook.d.ts +3 -0
  45. package/dist/headless/operations/index.d.ts +10 -0
  46. package/dist/headless/operations/memory.d.ts +3 -0
  47. package/dist/headless/operations/message.d.ts +2 -0
  48. package/dist/headless/operations/model.d.ts +3 -0
  49. package/dist/headless/operations/peer.d.ts +2 -0
  50. package/dist/headless/operations/run.d.ts +3 -0
  51. package/dist/headless/operations/session.d.ts +74 -0
  52. package/dist/headless/operations/subscription.d.ts +2 -0
  53. package/dist/headless/operations/system.d.ts +3 -0
  54. package/dist/headless/operations/utils.d.ts +5 -0
  55. package/dist/headless/run-orchestrator.d.ts +38 -0
  56. package/dist/headless/stdio-server.d.ts +4 -0
  57. package/dist/history/SessionHistory.d.ts +200 -0
  58. package/dist/history/conversation-message.d.ts +181 -0
  59. package/dist/history/index.d.ts +8 -0
  60. package/dist/history/jsonl-replay.d.ts +38 -0
  61. package/dist/history/repair-tool-pairing.d.ts +14 -0
  62. package/dist/history/turn-accumulator.d.ts +85 -0
  63. package/dist/index.d.ts +6 -0
  64. package/dist/index.js +505 -0
  65. package/dist/ink-repl.d.ts +32 -0
  66. package/dist/local-control-bootstrap.d.ts +5 -0
  67. package/dist/local-control-client.d.ts +1 -0
  68. package/dist/local-control-error-reporting.d.ts +6 -0
  69. package/dist/local-control-http-client.d.ts +9 -0
  70. package/dist/network-security.d.ts +7 -0
  71. package/dist/networking-server.d.ts +28 -0
  72. package/dist/peer-identity.d.ts +3 -0
  73. package/dist/polling-subscription.d.ts +7 -0
  74. package/dist/relaunch.d.ts +55 -0
  75. package/dist/release-notes.d.ts +11 -0
  76. package/dist/repl-cleanup.d.ts +20 -0
  77. package/dist/selectable-client.d.ts +7 -0
  78. package/dist/selectable-peer.d.ts +12 -0
  79. package/dist/session.d.ts +103 -0
  80. package/dist/slash-commands.d.ts +34 -0
  81. package/dist/sounds.d.ts +31 -0
  82. package/dist/ui/App.d.ts +288 -0
  83. package/dist/ui/components/AnthropicMethodPicker.d.ts +9 -0
  84. package/dist/ui/components/ArionPrompt.d.ts +8 -0
  85. package/dist/ui/components/AutocompleteDropdown.d.ts +9 -0
  86. package/dist/ui/components/AutonomySelector.d.ts +12 -0
  87. package/dist/ui/components/Banner.d.ts +9 -0
  88. package/dist/ui/components/ConversationHistory.d.ts +59 -0
  89. package/dist/ui/components/CopilotDeviceLoginFlow.d.ts +15 -0
  90. package/dist/ui/components/CopilotSourcePicker.d.ts +13 -0
  91. package/dist/ui/components/Cost.d.ts +8 -0
  92. package/dist/ui/components/CustomSelect/option-map.d.ts +15 -0
  93. package/dist/ui/components/CustomSelect/select-option.d.ts +20 -0
  94. package/dist/ui/components/CustomSelect/select.d.ts +55 -0
  95. package/dist/ui/components/CustomSelect/use-select-state.d.ts +99 -0
  96. package/dist/ui/components/CustomSelect/use-select.d.ts +14 -0
  97. package/dist/ui/components/ErrorDisplay.d.ts +26 -0
  98. package/dist/ui/components/FallbackToolUseRejectedMessage.d.ts +2 -0
  99. package/dist/ui/components/FileEditToolUpdatedMessage.d.ts +9 -0
  100. package/dist/ui/components/HandoffMarker.d.ts +17 -0
  101. package/dist/ui/components/HighlightedCode.d.ts +7 -0
  102. package/dist/ui/components/InputArea.d.ts +17 -0
  103. package/dist/ui/components/Message.d.ts +16 -0
  104. package/dist/ui/components/OAuthLoginFlow.d.ts +25 -0
  105. package/dist/ui/components/OutputTruncation.d.ts +16 -0
  106. package/dist/ui/components/PermissionPrompt.d.ts +22 -0
  107. package/dist/ui/components/PipelineTimingPanel.d.ts +13 -0
  108. package/dist/ui/components/ProviderMethodPicker.d.ts +16 -0
  109. package/dist/ui/components/ProviderPicker.d.ts +15 -0
  110. package/dist/ui/components/RenderItemView.d.ts +18 -0
  111. package/dist/ui/components/Spinner.d.ts +3 -0
  112. package/dist/ui/components/StatusBar.d.ts +78 -0
  113. package/dist/ui/components/StreamingIndicator.d.ts +11 -0
  114. package/dist/ui/components/StructuredDiff.d.ts +20 -0
  115. package/dist/ui/components/TextInputOverlay.d.ts +9 -0
  116. package/dist/ui/components/ThinkingBlock.d.ts +53 -0
  117. package/dist/ui/components/ToolCost.d.ts +8 -0
  118. package/dist/ui/components/ToolExecution.d.ts +13 -0
  119. package/dist/ui/components/ToolHeader.d.ts +10 -0
  120. package/dist/ui/components/ToolRenderLayoutContext.d.ts +10 -0
  121. package/dist/ui/components/ToolResultWrapper.d.ts +6 -0
  122. package/dist/ui/components/ToolUseLoader.d.ts +10 -0
  123. package/dist/ui/components/TraceWaterfall.d.ts +56 -0
  124. package/dist/ui/components/index.d.ts +29 -0
  125. package/dist/ui/components/messages/AssistantTextMessage.d.ts +13 -0
  126. package/dist/ui/components/messages/UserImageMessage.d.ts +8 -0
  127. package/dist/ui/components/messages/UserTextMessage.d.ts +13 -0
  128. package/dist/ui/components/overlays/ArionSelector.d.ts +18 -0
  129. package/dist/ui/components/overlays/ClientSelector.d.ts +7 -0
  130. package/dist/ui/components/overlays/CommandPalette.d.ts +14 -0
  131. package/dist/ui/components/overlays/InviteShareOverlay.d.ts +7 -0
  132. package/dist/ui/components/overlays/JoinInviteOverlay.d.ts +6 -0
  133. package/dist/ui/components/overlays/MemoryBrowser.d.ts +17 -0
  134. package/dist/ui/components/overlays/MessageSelector.d.ts +20 -0
  135. package/dist/ui/components/overlays/ModelSelector.d.ts +17 -0
  136. package/dist/ui/components/overlays/PairRequestOverlay.d.ts +19 -0
  137. package/dist/ui/components/overlays/PeerSelector.d.ts +14 -0
  138. package/dist/ui/components/overlays/SessionSelector.d.ts +11 -0
  139. package/dist/ui/components/overlays/ThemeSelector.d.ts +22 -0
  140. package/dist/ui/components/overlays/index.d.ts +13 -0
  141. package/dist/ui/components/permissions/BashPermissionRequest/BashPermissionRequest.d.ts +9 -0
  142. package/dist/ui/components/permissions/FallbackPermissionRequest.d.ts +9 -0
  143. package/dist/ui/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.d.ts +9 -0
  144. package/dist/ui/components/permissions/FileEditPermissionRequest/FileEditToolDiff.d.ts +11 -0
  145. package/dist/ui/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.d.ts +9 -0
  146. package/dist/ui/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.d.ts +9 -0
  147. package/dist/ui/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.d.ts +5 -0
  148. package/dist/ui/components/permissions/PermissionRequest.d.ts +52 -0
  149. package/dist/ui/components/permissions/PermissionRequestTitle.d.ts +13 -0
  150. package/dist/ui/components/permissions/hooks.d.ts +10 -0
  151. package/dist/ui/components/permissions/toolUseOptions.d.ts +10 -0
  152. package/dist/ui/components/permissions/utils.d.ts +6 -0
  153. package/dist/ui/components/text-input/Cursor.d.ts +58 -0
  154. package/dist/ui/components/text-input/TextInput.d.ts +98 -0
  155. package/dist/ui/components/text-input/imagePaste.d.ts +2 -0
  156. package/dist/ui/components/text-input/index.d.ts +6 -0
  157. package/dist/ui/components/text-input/useDoublePress.d.ts +2 -0
  158. package/dist/ui/components/text-input/useTextInput.d.ts +34 -0
  159. package/dist/ui/components/tool-types.d.ts +28 -0
  160. package/dist/ui/constants/figures.d.ts +1 -0
  161. package/dist/ui/constants/index.d.ts +1 -0
  162. package/dist/ui/display-mode.d.ts +62 -0
  163. package/dist/ui/display-policy.d.ts +3 -0
  164. package/dist/ui/hooks/index.d.ts +4 -0
  165. package/dist/ui/hooks/useCommandAutocomplete.d.ts +28 -0
  166. package/dist/ui/hooks/useDoublePress.d.ts +13 -0
  167. package/dist/ui/hooks/useIndicatorState.d.ts +3 -0
  168. package/dist/ui/hooks/useInterval.d.ts +6 -0
  169. package/dist/ui/hooks/useKeyboardShortcuts.d.ts +17 -0
  170. package/dist/ui/hooks/usePeerMessages.d.ts +26 -0
  171. package/dist/ui/hooks/useTerminalSize.d.ts +6 -0
  172. package/dist/ui/hooks/useUnifiedMessages.d.ts +83 -0
  173. package/dist/ui/indicator-state.d.ts +46 -0
  174. package/dist/ui/markdown/highlight.d.ts +8 -0
  175. package/dist/ui/markdown/index.d.ts +16 -0
  176. package/dist/ui/markdown/tokenizer.d.ts +17 -0
  177. package/dist/ui/render-item.d.ts +70 -0
  178. package/dist/ui/screens/REPL.d.ts +288 -0
  179. package/dist/ui/status-line.d.ts +32 -0
  180. package/dist/ui/theme/index.d.ts +8 -0
  181. package/dist/ui/theme/themes/claude-dark-daltonized.d.ts +2 -0
  182. package/dist/ui/theme/themes/claude-dark.d.ts +2 -0
  183. package/dist/ui/theme/themes/claude-light-daltonized.d.ts +2 -0
  184. package/dist/ui/theme/themes/claude-light.d.ts +2 -0
  185. package/dist/ui/theme/themes/dark-accessible.d.ts +2 -0
  186. package/dist/ui/theme/themes/dark.d.ts +2 -0
  187. package/dist/ui/theme/themes/light-accessible.d.ts +2 -0
  188. package/dist/ui/theme/themes/light.d.ts +2 -0
  189. package/dist/ui/theme/types.d.ts +51 -0
  190. package/dist/ui/theme.d.ts +51 -0
  191. package/dist/ui/to-render-items.d.ts +7 -0
  192. package/dist/ui/tools/AgentTool/index.d.ts +8 -0
  193. package/dist/ui/tools/ArchitectTool/index.d.ts +10 -0
  194. package/dist/ui/tools/AskUserTool/index.d.ts +19 -0
  195. package/dist/ui/tools/BashTool/BashToolResultMessage.d.ts +13 -0
  196. package/dist/ui/tools/BashTool/OutputLine.d.ts +6 -0
  197. package/dist/ui/tools/BashTool/index.d.ts +8 -0
  198. package/dist/ui/tools/BrowseTool/index.d.ts +20 -0
  199. package/dist/ui/tools/BrowserTool/index.d.ts +25 -0
  200. package/dist/ui/tools/CbmTool/index.d.ts +81 -0
  201. package/dist/ui/tools/CheckDelegationTool/index.d.ts +23 -0
  202. package/dist/ui/tools/CheckMessagesTool/index.d.ts +8 -0
  203. package/dist/ui/tools/CreateQuipTool/index.d.ts +10 -0
  204. package/dist/ui/tools/CreateSkillTool/index.d.ts +13 -0
  205. package/dist/ui/tools/CreateToolTool/index.d.ts +10 -0
  206. package/dist/ui/tools/DelegateRemoteTool/index.d.ts +22 -0
  207. package/dist/ui/tools/DeployTool/index.d.ts +24 -0
  208. package/dist/ui/tools/FffTool/index.d.ts +17 -0
  209. package/dist/ui/tools/FileEditTool/index.d.ts +10 -0
  210. package/dist/ui/tools/FileReadTool/index.d.ts +10 -0
  211. package/dist/ui/tools/FileWriteTool/index.d.ts +10 -0
  212. package/dist/ui/tools/FrgTool/index.d.ts +17 -0
  213. package/dist/ui/tools/GetThreadTool/index.d.ts +10 -0
  214. package/dist/ui/tools/GlobTool/index.d.ts +11 -0
  215. package/dist/ui/tools/GrepTool/index.d.ts +12 -0
  216. package/dist/ui/tools/HatchArionTool/index.d.ts +20 -0
  217. package/dist/ui/tools/LearnSkillTool/index.d.ts +13 -0
  218. package/dist/ui/tools/LearnTool/index.d.ts +15 -0
  219. package/dist/ui/tools/LearnToolTool/index.d.ts +14 -0
  220. package/dist/ui/tools/ListClientsTool/index.d.ts +10 -0
  221. package/dist/ui/tools/LspTool/index.d.ts +11 -0
  222. package/dist/ui/tools/MCPTool/index.d.ts +11 -0
  223. package/dist/ui/tools/ManageNetworkTool/index.d.ts +28 -0
  224. package/dist/ui/tools/MemoryReadTool/index.d.ts +8 -0
  225. package/dist/ui/tools/MemoryWriteTool/index.d.ts +6 -0
  226. package/dist/ui/tools/NotebookEditTool/index.d.ts +19 -0
  227. package/dist/ui/tools/NotebookReadTool/index.d.ts +12 -0
  228. package/dist/ui/tools/OutlookReadTool/index.d.ts +10 -0
  229. package/dist/ui/tools/OutlookReplyTool/index.d.ts +10 -0
  230. package/dist/ui/tools/OutlookSendTool/index.d.ts +10 -0
  231. package/dist/ui/tools/PauseDelegationTool/index.d.ts +20 -0
  232. package/dist/ui/tools/ProbeTool/index.d.ts +26 -0
  233. package/dist/ui/tools/ProcessTool/index.d.ts +29 -0
  234. package/dist/ui/tools/QuestListTool/index.d.ts +24 -0
  235. package/dist/ui/tools/QuestReportTool/index.d.ts +27 -0
  236. package/dist/ui/tools/QuestUpdateTool/index.d.ts +24 -0
  237. package/dist/ui/tools/QuipCommentTool/index.d.ts +23 -0
  238. package/dist/ui/tools/QuipReadTool/index.d.ts +26 -0
  239. package/dist/ui/tools/RestArionTool/index.d.ts +19 -0
  240. package/dist/ui/tools/RestartTool/index.d.ts +20 -0
  241. package/dist/ui/tools/ResumeDelegationTool/index.d.ts +21 -0
  242. package/dist/ui/tools/RetireArionTool/index.d.ts +19 -0
  243. package/dist/ui/tools/RgTool/index.d.ts +44 -0
  244. package/dist/ui/tools/SearchKnowledgeTool/index.d.ts +31 -0
  245. package/dist/ui/tools/SearchMessagesTool/index.d.ts +10 -0
  246. package/dist/ui/tools/SelfDiagnoseTool/index.d.ts +11 -0
  247. package/dist/ui/tools/SendMessageTool/index.d.ts +8 -0
  248. package/dist/ui/tools/SerenaTool/index.d.ts +18 -0
  249. package/dist/ui/tools/SessionHistoryTool/index.d.ts +32 -0
  250. package/dist/ui/tools/SgTool/index.d.ts +8 -0
  251. package/dist/ui/tools/SlackReactTool/index.d.ts +10 -0
  252. package/dist/ui/tools/SlackReadTool/index.d.ts +10 -0
  253. package/dist/ui/tools/SlackSendTool/index.d.ts +10 -0
  254. package/dist/ui/tools/SpawnWorkerTool/index.d.ts +18 -0
  255. package/dist/ui/tools/StickerRequestTool/index.d.ts +6 -0
  256. package/dist/ui/tools/ThinkTool/index.d.ts +8 -0
  257. package/dist/ui/tools/UgTool/index.d.ts +47 -0
  258. package/dist/ui/tools/UseSkillTool/index.d.ts +17 -0
  259. package/dist/ui/tools/WakeArionTool/index.d.ts +19 -0
  260. package/dist/ui/tools/WebFetchTool/index.d.ts +20 -0
  261. package/dist/ui/tools/WebSearchTool/index.d.ts +21 -0
  262. package/dist/ui/tools/lsTool/index.d.ts +12 -0
  263. package/dist/ui/tools/registry.d.ts +15 -0
  264. package/dist/ui/tools/tool-renderer.d.ts +24 -0
  265. package/dist/ui/tools/truncation.d.ts +6 -0
  266. package/dist/ui/types/anthropic.d.ts +19 -0
  267. package/dist/ui/types/index.d.ts +3 -0
  268. package/dist/ui/types/message.d.ts +19 -0
  269. package/dist/ui/types/tool.d.ts +17 -0
  270. package/dist/ui/utils/array.d.ts +1 -0
  271. package/dist/ui/utils/cursor.d.ts +28 -0
  272. package/dist/ui/utils/diff.d.ts +24 -0
  273. package/dist/ui/utils/format.d.ts +3 -0
  274. package/dist/ui/utils/fuzzy.d.ts +11 -0
  275. package/dist/ui/utils/index.d.ts +9 -0
  276. package/dist/ui/utils/keys.d.ts +6 -0
  277. package/dist/ui/utils/patch.d.ts +8 -0
  278. package/dist/ui/utils/risk.d.ts +14 -0
  279. package/dist/ui/utils/terminal-image.d.ts +18 -0
  280. package/dist/ui/utils/validation.d.ts +8 -0
  281. package/dist/ui/verb-pairs.d.ts +20 -0
  282. package/dist/ui.d.ts +70 -0
  283. package/package.json +76 -0
@@ -0,0 +1,181 @@
1
+ /**
2
+ * ConversationMessage — the single message type for all rendering and resume pipelines.
3
+ *
4
+ * Provides:
5
+ * - Zod schemas + inferred types (ContentBlock, ConversationMessage, ArionRef)
6
+ * - Factory helpers (createUserMessage, createSystemMessage)
7
+ * - Bidirectional conversion: toModelMessages / fromModelMessages
8
+ * - v1 DB migration: fromV1Columns
9
+ * - Bridge to existing UI: conversationMessageToHistoryMessages
10
+ * - Extract helpers for backward-compat INSERT
11
+ */
12
+ import { z } from "zod";
13
+ import type { Message } from "@aria-cli/types";
14
+ import type { HistoryMessage } from "../ui/components/ConversationHistory.js";
15
+ export declare const ContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
16
+ type: z.ZodLiteral<"text">;
17
+ text: z.ZodString;
18
+ }, z.core.$strip>, z.ZodObject<{
19
+ type: z.ZodLiteral<"thinking">;
20
+ content: z.ZodString;
21
+ wordCount: z.ZodNumber;
22
+ durationMs: z.ZodOptional<z.ZodNumber>;
23
+ verb: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strip>, z.ZodObject<{
25
+ type: z.ZodLiteral<"tool_use">;
26
+ id: z.ZodString;
27
+ name: z.ZodString;
28
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
29
+ thoughtSignature: z.ZodOptional<z.ZodString>;
30
+ }, z.core.$strip>, z.ZodObject<{
31
+ type: z.ZodLiteral<"tool_result">;
32
+ toolUseId: z.ZodString;
33
+ content: z.ZodString;
34
+ status: z.ZodEnum<{
35
+ success: "success";
36
+ error: "error";
37
+ }>;
38
+ durationMs: z.ZodOptional<z.ZodNumber>;
39
+ resultData: z.ZodOptional<z.ZodUnknown>;
40
+ usage: z.ZodOptional<z.ZodObject<{
41
+ inputTokens: z.ZodNumber;
42
+ outputTokens: z.ZodNumber;
43
+ totalTokens: z.ZodNumber;
44
+ estimatedCost: z.ZodNumber;
45
+ }, z.core.$strip>>;
46
+ }, z.core.$strip>, z.ZodObject<{
47
+ type: z.ZodLiteral<"handoff">;
48
+ target: z.ZodString;
49
+ direction: z.ZodEnum<{
50
+ to: "to";
51
+ from: "from";
52
+ }>;
53
+ }, z.core.$strip>, z.ZodObject<{
54
+ type: z.ZodLiteral<"error">;
55
+ content: z.ZodString;
56
+ suggestion: z.ZodOptional<z.ZodString>;
57
+ }, z.core.$strip>], "type">;
58
+ export declare const ArionRefSchema: z.ZodObject<{
59
+ name: z.ZodString;
60
+ emoji: z.ZodString;
61
+ color: z.ZodOptional<z.ZodEnum<{
62
+ cyan: "cyan";
63
+ magenta: "magenta";
64
+ yellow: "yellow";
65
+ green: "green";
66
+ blue: "blue";
67
+ red: "red";
68
+ white: "white";
69
+ }>>;
70
+ }, z.core.$strip>;
71
+ export declare const ConversationMessageSchema: z.ZodObject<{
72
+ id: z.ZodString;
73
+ role: z.ZodEnum<{
74
+ user: "user";
75
+ assistant: "assistant";
76
+ system: "system";
77
+ tool: "tool";
78
+ }>;
79
+ content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
80
+ type: z.ZodLiteral<"text">;
81
+ text: z.ZodString;
82
+ }, z.core.$strip>, z.ZodObject<{
83
+ type: z.ZodLiteral<"thinking">;
84
+ content: z.ZodString;
85
+ wordCount: z.ZodNumber;
86
+ durationMs: z.ZodOptional<z.ZodNumber>;
87
+ verb: z.ZodOptional<z.ZodString>;
88
+ }, z.core.$strip>, z.ZodObject<{
89
+ type: z.ZodLiteral<"tool_use">;
90
+ id: z.ZodString;
91
+ name: z.ZodString;
92
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
93
+ thoughtSignature: z.ZodOptional<z.ZodString>;
94
+ }, z.core.$strip>, z.ZodObject<{
95
+ type: z.ZodLiteral<"tool_result">;
96
+ toolUseId: z.ZodString;
97
+ content: z.ZodString;
98
+ status: z.ZodEnum<{
99
+ success: "success";
100
+ error: "error";
101
+ }>;
102
+ durationMs: z.ZodOptional<z.ZodNumber>;
103
+ resultData: z.ZodOptional<z.ZodUnknown>;
104
+ usage: z.ZodOptional<z.ZodObject<{
105
+ inputTokens: z.ZodNumber;
106
+ outputTokens: z.ZodNumber;
107
+ totalTokens: z.ZodNumber;
108
+ estimatedCost: z.ZodNumber;
109
+ }, z.core.$strip>>;
110
+ }, z.core.$strip>, z.ZodObject<{
111
+ type: z.ZodLiteral<"handoff">;
112
+ target: z.ZodString;
113
+ direction: z.ZodEnum<{
114
+ to: "to";
115
+ from: "from";
116
+ }>;
117
+ }, z.core.$strip>, z.ZodObject<{
118
+ type: z.ZodLiteral<"error">;
119
+ content: z.ZodString;
120
+ suggestion: z.ZodOptional<z.ZodString>;
121
+ }, z.core.$strip>], "type">>;
122
+ arion: z.ZodOptional<z.ZodObject<{
123
+ name: z.ZodString;
124
+ emoji: z.ZodString;
125
+ color: z.ZodOptional<z.ZodEnum<{
126
+ cyan: "cyan";
127
+ magenta: "magenta";
128
+ yellow: "yellow";
129
+ green: "green";
130
+ blue: "blue";
131
+ red: "red";
132
+ white: "white";
133
+ }>>;
134
+ }, z.core.$strip>>;
135
+ costUSD: z.ZodOptional<z.ZodNumber>;
136
+ durationMs: z.ZodOptional<z.ZodNumber>;
137
+ tokenUsage: z.ZodOptional<z.ZodObject<{
138
+ input: z.ZodNumber;
139
+ output: z.ZodNumber;
140
+ }, z.core.$strip>>;
141
+ createdAt: z.ZodString;
142
+ }, z.core.$strip>;
143
+ export type ContentBlock = z.infer<typeof ContentBlockSchema>;
144
+ export type ConversationMessage = z.infer<typeof ConversationMessageSchema>;
145
+ export type ArionRef = z.infer<typeof ArionRefSchema>;
146
+ export declare function createUserMessage(text: string): ConversationMessage;
147
+ export declare function createSystemMessage(text: string): ConversationMessage;
148
+ /**
149
+ * Synthesize an assistant tool_use + tool result pair that looks like
150
+ * `check_messages` returned an incoming message. This lets the LLM see the
151
+ * message as a tool result — the most natural prompt to reply via send_message.
152
+ */
153
+ export declare function createIncomingMessagePair(senderName: string, senderAddress: string, content: string, messageId?: string): [ConversationMessage, ConversationMessage];
154
+ export declare function createErrorMessage(text: string, suggestion?: string): ConversationMessage;
155
+ export declare function toModelMessages(msgs: ConversationMessage[]): Message[];
156
+ export declare function fromModelMessages(msgs: Message[], metadata?: {
157
+ arion?: ArionRef;
158
+ }): ConversationMessage[];
159
+ /** Row shape from the messages table (v1 columns) */
160
+ interface MessageRow {
161
+ id: number;
162
+ session_id: string;
163
+ role: "user" | "assistant" | "system" | "tool";
164
+ content: string;
165
+ arion: string | null;
166
+ tool_call_id: string | null;
167
+ tool_calls: string | null;
168
+ thinking: string | null;
169
+ created_at: string;
170
+ }
171
+ export declare function fromV1Columns(row: MessageRow): ConversationMessage;
172
+ export declare function conversationMessageToHistoryMessages(msgs: ConversationMessage[]): HistoryMessage[];
173
+ /** Join all text blocks into a single string */
174
+ export declare function extractTextContent(msg: ConversationMessage): string;
175
+ /** JSON of tool_use blocks in v1 format, or null if none */
176
+ export declare function extractToolCalls(msg: ConversationMessage): string | null;
177
+ /** JSON of thinking blocks in v1 format [{ id, content, wordCount }], or null if none */
178
+ export declare function extractThinking(msg: ConversationMessage): string | null;
179
+ /** First tool_result's toolUseId, or null if none */
180
+ export declare function extractToolCallId(msg: ConversationMessage): string | null;
181
+ export {};
@@ -0,0 +1,8 @@
1
+ export { SessionHistory } from "./SessionHistory.js";
2
+ export { repairToolCallPairing } from "./repair-tool-pairing.js";
3
+ export type { SessionSummary, SessionMessage, SessionContext, LoadedSession, SessionRuntimeStateStatus, SessionInteractionStatus, SessionRuntimeState, SessionInteractionRecord, LoadedSessionState, } from "./SessionHistory.js";
4
+ export { ContentBlockSchema, ArionRefSchema, ConversationMessageSchema, createUserMessage, createSystemMessage, createErrorMessage, createIncomingMessagePair, toModelMessages, fromModelMessages, fromV1Columns, conversationMessageToHistoryMessages, extractTextContent, extractToolCalls, extractThinking, extractToolCallId, } from "./conversation-message.js";
5
+ export type { ContentBlock, ConversationMessage, ArionRef } from "./conversation-message.js";
6
+ export { TurnAccumulator } from "./turn-accumulator.js";
7
+ export type { AccumulatorSignal } from "./turn-accumulator.js";
8
+ export { replaySessionFromJsonl, findJsonlForSession, mergeWithJsonlRecovery, } from "./jsonl-replay.js";
@@ -0,0 +1,38 @@
1
+ /**
2
+ * JSONL Replay — reconstructs ConversationMessage[] from a JSONL event log.
3
+ *
4
+ * The JsonlEventLogger writes every RunEvent to disk as newline-delimited JSON.
5
+ * This module reads those logs back and feeds them through a TurnAccumulator
6
+ * to reconstruct the conversation messages for crash recovery and session resume.
7
+ *
8
+ * Each JSONL line has the shape: { ts: string, event: RunEvent }
9
+ */
10
+ import type { ConversationMessage } from "./conversation-message.js";
11
+ /**
12
+ * Replay a JSONL event log file and reconstruct ConversationMessage[].
13
+ *
14
+ * Feeds each RunEvent through a fresh TurnAccumulator. On turn boundaries
15
+ * (turn_complete events), the accumulator flushes and messages are collected.
16
+ * Any remaining pending content is flushed at the end (handles mid-turn crashes).
17
+ *
18
+ * Returns user + assistant + tool messages. User messages are captured via
19
+ * synthetic `user_message` events logged before each LLM call.
20
+ */
21
+ export declare function replaySessionFromJsonl(jsonlPath: string): ConversationMessage[];
22
+ /**
23
+ * Merge SQLite messages with JSONL-replayed messages for crash recovery.
24
+ *
25
+ * Strategy: SQLite is the primary store; JSONL fills gaps from crash recovery.
26
+ * Uses content-based identity (tool_use IDs, tool_result references) to detect
27
+ * which JSONL messages are truly missing from SQLite, avoiding the position-based
28
+ * counting that breaks when JSONL accumulates events across multiple session runs
29
+ * with different message coalescing boundaries.
30
+ *
31
+ * Returns { messages, backfillMessages } where backfillMessages are the
32
+ * messages JSONL had that SQLite was missing (for SQLite index backfill).
33
+ */
34
+ export declare function mergeWithJsonlRecovery(sqliteMessages: ConversationMessage[], jsonlPath: string | null): {
35
+ messages: ConversationMessage[];
36
+ backfillMessages: ConversationMessage[];
37
+ };
38
+ export declare function findJsonlForSession(ariaDir: string, arionName: string, sessionId: string): string | null;
@@ -0,0 +1,14 @@
1
+ import type { Message } from "@aria-cli/types";
2
+ /**
3
+ * Repair tool call/result pairing in a message sequence.
4
+ *
5
+ * Ensures:
6
+ * 1. Every tool result has a matching tool call (removes orphans)
7
+ * 2. Every tool call has a matching result (adds synthetic "interrupted" result)
8
+ * 3. Synthetic results are placed AFTER real results for the same assistant (R2-C3)
9
+ * 4. Tool messages without toolCallId are removed (R2 F-10)
10
+ * 5. thoughtSignature is preserved on tool calls (Gemini requirement)
11
+ *
12
+ * Inspired by Codex's normalize_history() and OpenClaw's repairToolUseResultPairing().
13
+ */
14
+ export declare function repairToolCallPairing(messages: Message[]): Message[];
@@ -0,0 +1,85 @@
1
+ /**
2
+ * TurnAccumulator — ingests RunEvent stream events and accumulates them into
3
+ * ConversationMessage[] for batch persistence and rendering.
4
+ *
5
+ * Key behaviors:
6
+ * - text_delta → single text block on assistant message
7
+ * - thinking_start/delta/end → thinking block with durationMs, verb, content
8
+ * - tool_start → tool_use block (deduped via seenToolIds Set)
9
+ * - tool_args_delta → progressive JSON accumulation on tool_use arguments
10
+ * - tool_result → SEPARATE ConversationMessage with role="tool"
11
+ * - handoff_start/result → handoff blocks
12
+ * - messages_snapshot → stored for getSnapshotMessages()
13
+ * - turn_complete → returns "flush" signal
14
+ * - Unknown event types → returns "continue" (default case)
15
+ * - No error case — event loop throws before accumulator sees errors
16
+ */
17
+ import type { RunEvent } from "@aria-cli/aria";
18
+ import type { RuntimeRunEvent } from "@aria-cli/tools";
19
+ import type { Message } from "@aria-cli/types";
20
+ import type { ConversationMessage, ArionRef } from "./conversation-message.js";
21
+ /**
22
+ * "continue" = data ingested, accumulator state updated (caller need not act).
23
+ * "flush" = turn boundary — caller must call flush() and commit messages.
24
+ *
25
+ * Render scheduling is NOT the accumulator's concern. The consumer (ink-repl)
26
+ * polls via a fixed-interval render scheduler, making per-event-type throttle
27
+ * logic unnecessary and eliminating the bug class of "new event type without
28
+ * throttle causes excessive re-renders."
29
+ */
30
+ export type AccumulatorSignal = "continue" | "flush";
31
+ export declare class TurnAccumulator {
32
+ private textParts;
33
+ private thinkingBlocks;
34
+ private toolUseBlocks;
35
+ private handoffBlocks;
36
+ private toolResultMessages;
37
+ private seenToolIds;
38
+ private toolArgsAccumulator;
39
+ private thinkingInProgress;
40
+ private pendingThinkingContent;
41
+ private arion;
42
+ private verb;
43
+ private tokenUsage;
44
+ private snapshotMessages;
45
+ private previewAssistantId;
46
+ ingest(event: RunEvent | RuntimeRunEvent): AccumulatorSignal;
47
+ /**
48
+ * Flush all accumulated content into ConversationMessage[].
49
+ * Works anytime (including mid-accumulation for abort scenarios).
50
+ * Resets all state after flush.
51
+ */
52
+ flush(): ConversationMessage[];
53
+ /**
54
+ * Returns a read-only view of current accumulated state as ConversationMessage[].
55
+ * Does NOT reset state (unlike flush). Used for intermediate rendering.
56
+ * Includes in-progress thinking content and progressive text content.
57
+ */
58
+ snapshot(): ConversationMessage[];
59
+ /** Get snapshot messages from the most recent messages_snapshot event */
60
+ getSnapshotMessages(): Message[] | undefined;
61
+ /** Whether there is any pending content that would produce messages on flush */
62
+ hasPendingContent(): boolean;
63
+ /** Set the arion reference — propagated to all flushed messages */
64
+ setArion(arion: ArionRef): void;
65
+ /** Set the composing verb — used in thinking blocks */
66
+ setVerb(verb: string): void;
67
+ /** Accumulate token usage — attached to assistant message on flush */
68
+ setTokenUsage(usage: {
69
+ input: number;
70
+ output: number;
71
+ }): void;
72
+ /**
73
+ * Parse a partial JSON object string by trying progressive closings.
74
+ * Used in snapshot() to extract displayable args from in-progress tool arg streaming.
75
+ *
76
+ * Strategy (ordered by information preserved):
77
+ * 1. Complete parse (fast path — JSON already valid)
78
+ * 2. Close object with '}' (last value complete, just needs brace)
79
+ * 3. Close string + object with '"}' (last string value incomplete)
80
+ * 4. Scan backward for commas — truncate to last complete pair + close
81
+ *
82
+ * Returns undefined when no useful partial extraction is possible.
83
+ */
84
+ static tryParsePartialArgs(raw: string): Record<string, unknown> | undefined;
85
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @aria/cli - Simple chat interface for ARIA
3
+ */
4
+ export { SessionHistory } from "./history/SessionHistory.js";
5
+ export { startInkRepl, startInkRepl as startRepl } from "./ink-repl.js";
6
+ export { program, createArionsCommand, createAuthCommand } from "./commands/index.js";