dispach 0.1.0

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 (346) hide show
  1. package/README.md +596 -0
  2. package/dist/App-dxqm39zx.js +11 -0
  3. package/dist/App-dxqm39zx.js.map +25 -0
  4. package/dist/ConfigEditor-7v5nebvy.js +6 -0
  5. package/dist/ConfigEditor-7v5nebvy.js.map +11 -0
  6. package/dist/KeyProbe-vjhmdpx6.js +5 -0
  7. package/dist/KeyProbe-vjhmdpx6.js.map +11 -0
  8. package/dist/Picker-jxaesaxy.js +5 -0
  9. package/dist/Picker-jxaesaxy.js.map +10 -0
  10. package/dist/SessionPicker-z2t0p4b5.js +5 -0
  11. package/dist/SessionPicker-z2t0p4b5.js.map +11 -0
  12. package/dist/SkillBrowser-yyf2gy0q.js +5 -0
  13. package/dist/SkillBrowser-yyf2gy0q.js.map +11 -0
  14. package/dist/WizardApp-12ndxgqv.js +5 -0
  15. package/dist/WizardApp-12ndxgqv.js.map +13 -0
  16. package/dist/agents.d.ts +9 -0
  17. package/dist/agents.d.ts.map +1 -0
  18. package/dist/browse.d.ts +63 -0
  19. package/dist/browse.d.ts.map +1 -0
  20. package/dist/client.d.ts +25 -0
  21. package/dist/client.d.ts.map +1 -0
  22. package/dist/client.js +34 -0
  23. package/dist/client.js.map +11 -0
  24. package/dist/components/App.d.ts +28 -0
  25. package/dist/components/App.d.ts.map +1 -0
  26. package/dist/components/Banner.d.ts +16 -0
  27. package/dist/components/Banner.d.ts.map +1 -0
  28. package/dist/components/Brandmark.d.ts +31 -0
  29. package/dist/components/Brandmark.d.ts.map +1 -0
  30. package/dist/components/CheckList.d.ts +38 -0
  31. package/dist/components/CheckList.d.ts.map +1 -0
  32. package/dist/components/CommandOutput.d.ts +29 -0
  33. package/dist/components/CommandOutput.d.ts.map +1 -0
  34. package/dist/components/ConfigEditor.d.ts +64 -0
  35. package/dist/components/ConfigEditor.d.ts.map +1 -0
  36. package/dist/components/HistorySearch.d.ts +23 -0
  37. package/dist/components/HistorySearch.d.ts.map +1 -0
  38. package/dist/components/KeyProbe.d.ts +36 -0
  39. package/dist/components/KeyProbe.d.ts.map +1 -0
  40. package/dist/components/LineCursor.d.ts +55 -0
  41. package/dist/components/LineCursor.d.ts.map +1 -0
  42. package/dist/components/Live.d.ts +17 -0
  43. package/dist/components/Live.d.ts.map +1 -0
  44. package/dist/components/Palette.d.ts +21 -0
  45. package/dist/components/Palette.d.ts.map +1 -0
  46. package/dist/components/Picker.d.ts +23 -0
  47. package/dist/components/Picker.d.ts.map +1 -0
  48. package/dist/components/Prompt.d.ts +20 -0
  49. package/dist/components/Prompt.d.ts.map +1 -0
  50. package/dist/components/Screen.d.ts +39 -0
  51. package/dist/components/Screen.d.ts.map +1 -0
  52. package/dist/components/SelectList.d.ts +34 -0
  53. package/dist/components/SelectList.d.ts.map +1 -0
  54. package/dist/components/SessionPicker.d.ts +26 -0
  55. package/dist/components/SessionPicker.d.ts.map +1 -0
  56. package/dist/components/SkillBrowser.d.ts +39 -0
  57. package/dist/components/SkillBrowser.d.ts.map +1 -0
  58. package/dist/components/Spinner.d.ts +13 -0
  59. package/dist/components/Spinner.d.ts.map +1 -0
  60. package/dist/components/StatusBar.d.ts +11 -0
  61. package/dist/components/StatusBar.d.ts.map +1 -0
  62. package/dist/components/SummaryCard.d.ts +11 -0
  63. package/dist/components/SummaryCard.d.ts.map +1 -0
  64. package/dist/components/TextField.d.ts +39 -0
  65. package/dist/components/TextField.d.ts.map +1 -0
  66. package/dist/components/Transcript.d.ts +23 -0
  67. package/dist/components/Transcript.d.ts.map +1 -0
  68. package/dist/components/WizardApp.d.ts +18 -0
  69. package/dist/components/WizardApp.d.ts.map +1 -0
  70. package/dist/components/WizardFrame.d.ts +19 -0
  71. package/dist/components/WizardFrame.d.ts.map +1 -0
  72. package/dist/config-yz0nz51b.js +24 -0
  73. package/dist/config-yz0nz51b.js.map +10 -0
  74. package/dist/config.d.ts +71 -0
  75. package/dist/config.d.ts.map +1 -0
  76. package/dist/credential-wgt4gvcz.js +19 -0
  77. package/dist/credential-wgt4gvcz.js.map +10 -0
  78. package/dist/credential.d.ts +68 -0
  79. package/dist/credential.d.ts.map +1 -0
  80. package/dist/daemon.d.ts +47 -0
  81. package/dist/daemon.d.ts.map +1 -0
  82. package/dist/editor.d.ts +81 -0
  83. package/dist/editor.d.ts.map +1 -0
  84. package/dist/hooks/useElapsed.d.ts +10 -0
  85. package/dist/hooks/useElapsed.d.ts.map +1 -0
  86. package/dist/hooks/useTerminalSize.d.ts +14 -0
  87. package/dist/hooks/useTerminalSize.d.ts.map +1 -0
  88. package/dist/hooks/useTurn.d.ts +41 -0
  89. package/dist/hooks/useTurn.d.ts.map +1 -0
  90. package/dist/index-2cvtz0fy.js +903 -0
  91. package/dist/index-2cvtz0fy.js.map +194 -0
  92. package/dist/index-3nwfz9jq.js +12 -0
  93. package/dist/index-3nwfz9jq.js.map +11 -0
  94. package/dist/index-6b7qvh1x.js +6 -0
  95. package/dist/index-6b7qvh1x.js.map +10 -0
  96. package/dist/index-6z0yr17z.js +12 -0
  97. package/dist/index-6z0yr17z.js.map +11 -0
  98. package/dist/index-7da4fqcr.js +7 -0
  99. package/dist/index-7da4fqcr.js.map +11 -0
  100. package/dist/index-8bmhd2hj.js +6 -0
  101. package/dist/index-8bmhd2hj.js.map +10 -0
  102. package/dist/index-9d011p3q.js +6 -0
  103. package/dist/index-9d011p3q.js.map +10 -0
  104. package/dist/index-9f9pp2ef.js +6 -0
  105. package/dist/index-9f9pp2ef.js.map +10 -0
  106. package/dist/index-9nsfs0vy.js +6 -0
  107. package/dist/index-9nsfs0vy.js.map +10 -0
  108. package/dist/index-9pj1ws0p.js +77 -0
  109. package/dist/index-9pj1ws0p.js.map +12 -0
  110. package/dist/index-b5wwtxzk.js +66 -0
  111. package/dist/index-b5wwtxzk.js.map +12 -0
  112. package/dist/index-b8zwg8a3.js +6 -0
  113. package/dist/index-b8zwg8a3.js.map +10 -0
  114. package/dist/index-bry9bzt3.js +427 -0
  115. package/dist/index-bry9bzt3.js.map +11 -0
  116. package/dist/index-bwckzbf8.js +6 -0
  117. package/dist/index-bwckzbf8.js.map +10 -0
  118. package/dist/index-cx3vz7sf.js +6 -0
  119. package/dist/index-cx3vz7sf.js.map +11 -0
  120. package/dist/index-e8n70sgj.js +6 -0
  121. package/dist/index-e8n70sgj.js.map +11 -0
  122. package/dist/index-fvhg0xyd.js +167 -0
  123. package/dist/index-fvhg0xyd.js.map +19 -0
  124. package/dist/index-gbnc99j8.js +14 -0
  125. package/dist/index-gbnc99j8.js.map +13 -0
  126. package/dist/index-h2yds678.js +7 -0
  127. package/dist/index-h2yds678.js.map +11 -0
  128. package/dist/index-j97vttdt.js +10 -0
  129. package/dist/index-j97vttdt.js.map +10 -0
  130. package/dist/index-jk0def33.js +6 -0
  131. package/dist/index-jk0def33.js.map +12 -0
  132. package/dist/index-jym27m75.js +6 -0
  133. package/dist/index-jym27m75.js.map +10 -0
  134. package/dist/index-mgdgx22q.js +10 -0
  135. package/dist/index-mgdgx22q.js.map +10 -0
  136. package/dist/index-mrtb5y08.js +6 -0
  137. package/dist/index-mrtb5y08.js.map +11 -0
  138. package/dist/index-my5cjx00.js +6 -0
  139. package/dist/index-my5cjx00.js.map +10 -0
  140. package/dist/index-qc2vrq9z.js +7 -0
  141. package/dist/index-qc2vrq9z.js.map +11 -0
  142. package/dist/index-rqbtm761.js +6 -0
  143. package/dist/index-rqbtm761.js.map +10 -0
  144. package/dist/index-rqzg861g.js +6 -0
  145. package/dist/index-rqzg861g.js.map +10 -0
  146. package/dist/index-t1xvacym.js +6 -0
  147. package/dist/index-t1xvacym.js.map +11 -0
  148. package/dist/index-xgqzk5cq.js +9 -0
  149. package/dist/index-xgqzk5cq.js.map +12 -0
  150. package/dist/index-xqyms08r.js +6 -0
  151. package/dist/index-xqyms08r.js.map +10 -0
  152. package/dist/index-yr25dnf5.js +6 -0
  153. package/dist/index-yr25dnf5.js.map +10 -0
  154. package/dist/index.d.ts +23 -0
  155. package/dist/index.d.ts.map +1 -0
  156. package/dist/index.js +527 -0
  157. package/dist/index.js.map +48 -0
  158. package/dist/init.d.ts +34 -0
  159. package/dist/init.d.ts.map +1 -0
  160. package/dist/keymap.d.ts +126 -0
  161. package/dist/keymap.d.ts.map +1 -0
  162. package/dist/keys.d.ts +17 -0
  163. package/dist/keys.d.ts.map +1 -0
  164. package/dist/lib/ambient.d.ts +69 -0
  165. package/dist/lib/ambient.d.ts.map +1 -0
  166. package/dist/lib/args.d.ts +33 -0
  167. package/dist/lib/args.d.ts.map +1 -0
  168. package/dist/lib/bootstrap.d.ts +84 -0
  169. package/dist/lib/bootstrap.d.ts.map +1 -0
  170. package/dist/lib/browse.d.ts +89 -0
  171. package/dist/lib/browse.d.ts.map +1 -0
  172. package/dist/lib/browser.d.ts +55 -0
  173. package/dist/lib/browser.d.ts.map +1 -0
  174. package/dist/lib/chat-frame.d.ts +156 -0
  175. package/dist/lib/chat-frame.d.ts.map +1 -0
  176. package/dist/lib/clipboard.d.ts +32 -0
  177. package/dist/lib/clipboard.d.ts.map +1 -0
  178. package/dist/lib/commands.d.ts +26 -0
  179. package/dist/lib/commands.d.ts.map +1 -0
  180. package/dist/lib/composer.d.ts +85 -0
  181. package/dist/lib/composer.d.ts.map +1 -0
  182. package/dist/lib/config-apply.d.ts +51 -0
  183. package/dist/lib/config-apply.d.ts.map +1 -0
  184. package/dist/lib/config-editor.d.ts +113 -0
  185. package/dist/lib/config-editor.d.ts.map +1 -0
  186. package/dist/lib/config-env.d.ts +110 -0
  187. package/dist/lib/config-env.d.ts.map +1 -0
  188. package/dist/lib/config-rows.d.ts +37 -0
  189. package/dist/lib/config-rows.d.ts.map +1 -0
  190. package/dist/lib/config-view.d.ts +133 -0
  191. package/dist/lib/config-view.d.ts.map +1 -0
  192. package/dist/lib/confirm.d.ts +86 -0
  193. package/dist/lib/confirm.d.ts.map +1 -0
  194. package/dist/lib/const.d.ts +213 -0
  195. package/dist/lib/const.d.ts.map +1 -0
  196. package/dist/lib/csi.d.ts +70 -0
  197. package/dist/lib/csi.d.ts.map +1 -0
  198. package/dist/lib/curated.d.ts +44 -0
  199. package/dist/lib/curated.d.ts.map +1 -0
  200. package/dist/lib/daemon-plan.d.ts +151 -0
  201. package/dist/lib/daemon-plan.d.ts.map +1 -0
  202. package/dist/lib/dotenv-edit.d.ts +30 -0
  203. package/dist/lib/dotenv-edit.d.ts.map +1 -0
  204. package/dist/lib/env.d.ts +10 -0
  205. package/dist/lib/env.d.ts.map +1 -0
  206. package/dist/lib/exit.d.ts +170 -0
  207. package/dist/lib/exit.d.ts.map +1 -0
  208. package/dist/lib/help.d.ts +10 -0
  209. package/dist/lib/help.d.ts.map +1 -0
  210. package/dist/lib/init-flow.d.ts +539 -0
  211. package/dist/lib/init-flow.d.ts.map +1 -0
  212. package/dist/lib/init-skills.d.ts +46 -0
  213. package/dist/lib/init-skills.d.ts.map +1 -0
  214. package/dist/lib/keyboard.d.ts +76 -0
  215. package/dist/lib/keyboard.d.ts.map +1 -0
  216. package/dist/lib/keys-view.d.ts +57 -0
  217. package/dist/lib/keys-view.d.ts.map +1 -0
  218. package/dist/lib/launchd.d.ts +151 -0
  219. package/dist/lib/launchd.d.ts.map +1 -0
  220. package/dist/lib/lifecycle.d.ts +126 -0
  221. package/dist/lib/lifecycle.d.ts.map +1 -0
  222. package/dist/lib/log-follow.d.ts +71 -0
  223. package/dist/lib/log-follow.d.ts.map +1 -0
  224. package/dist/lib/mouse.d.ts +84 -0
  225. package/dist/lib/mouse.d.ts.map +1 -0
  226. package/dist/lib/multiselect.d.ts +37 -0
  227. package/dist/lib/multiselect.d.ts.map +1 -0
  228. package/dist/lib/origins.d.ts +40 -0
  229. package/dist/lib/origins.d.ts.map +1 -0
  230. package/dist/lib/output.d.ts +29 -0
  231. package/dist/lib/output.d.ts.map +1 -0
  232. package/dist/lib/palette.d.ts +69 -0
  233. package/dist/lib/palette.d.ts.map +1 -0
  234. package/dist/lib/probe.d.ts +158 -0
  235. package/dist/lib/probe.d.ts.map +1 -0
  236. package/dist/lib/providers.d.ts +63 -0
  237. package/dist/lib/providers.d.ts.map +1 -0
  238. package/dist/lib/provision.d.ts +163 -0
  239. package/dist/lib/provision.d.ts.map +1 -0
  240. package/dist/lib/remove-plan.d.ts +120 -0
  241. package/dist/lib/remove-plan.d.ts.map +1 -0
  242. package/dist/lib/render.d.ts +78 -0
  243. package/dist/lib/render.d.ts.map +1 -0
  244. package/dist/lib/resume.d.ts +69 -0
  245. package/dist/lib/resume.d.ts.map +1 -0
  246. package/dist/lib/rows.d.ts +69 -0
  247. package/dist/lib/rows.d.ts.map +1 -0
  248. package/dist/lib/sandbox.d.ts +101 -0
  249. package/dist/lib/sandbox.d.ts.map +1 -0
  250. package/dist/lib/schema.d.ts +491 -0
  251. package/dist/lib/schema.d.ts.map +1 -0
  252. package/dist/lib/screen.d.ts +102 -0
  253. package/dist/lib/screen.d.ts.map +1 -0
  254. package/dist/lib/scroll.d.ts +64 -0
  255. package/dist/lib/scroll.d.ts.map +1 -0
  256. package/dist/lib/select.d.ts +23 -0
  257. package/dist/lib/select.d.ts.map +1 -0
  258. package/dist/lib/service-env.d.ts +38 -0
  259. package/dist/lib/service-env.d.ts.map +1 -0
  260. package/dist/lib/service.d.ts +102 -0
  261. package/dist/lib/service.d.ts.map +1 -0
  262. package/dist/lib/session-commands.d.ts +229 -0
  263. package/dist/lib/session-commands.d.ts.map +1 -0
  264. package/dist/lib/session-key.d.ts +55 -0
  265. package/dist/lib/session-key.d.ts.map +1 -0
  266. package/dist/lib/sessions-view.d.ts +31 -0
  267. package/dist/lib/sessions-view.d.ts.map +1 -0
  268. package/dist/lib/source-cache.d.ts +105 -0
  269. package/dist/lib/source-cache.d.ts.map +1 -0
  270. package/dist/lib/source.d.ts +281 -0
  271. package/dist/lib/source.d.ts.map +1 -0
  272. package/dist/lib/sources.d.ts +107 -0
  273. package/dist/lib/sources.d.ts.map +1 -0
  274. package/dist/lib/spawn.d.ts +56 -0
  275. package/dist/lib/spawn.d.ts.map +1 -0
  276. package/dist/lib/stdin-tap.d.ts +41 -0
  277. package/dist/lib/stdin-tap.d.ts.map +1 -0
  278. package/dist/lib/subcommand.d.ts +57 -0
  279. package/dist/lib/subcommand.d.ts.map +1 -0
  280. package/dist/lib/systemd.d.ts +60 -0
  281. package/dist/lib/systemd.d.ts.map +1 -0
  282. package/dist/lib/templates.d.ts +35 -0
  283. package/dist/lib/templates.d.ts.map +1 -0
  284. package/dist/lib/terminal.d.ts +98 -0
  285. package/dist/lib/terminal.d.ts.map +1 -0
  286. package/dist/lib/text-selection.d.ts +75 -0
  287. package/dist/lib/text-selection.d.ts.map +1 -0
  288. package/dist/lib/theme.d.ts +90 -0
  289. package/dist/lib/theme.d.ts.map +1 -0
  290. package/dist/lib/types.d.ts +467 -0
  291. package/dist/lib/types.d.ts.map +1 -0
  292. package/dist/lib/warnings.d.ts +79 -0
  293. package/dist/lib/warnings.d.ts.map +1 -0
  294. package/dist/lib/width.d.ts +39 -0
  295. package/dist/lib/width.d.ts.map +1 -0
  296. package/dist/lib/wizard.d.ts +95 -0
  297. package/dist/lib/wizard.d.ts.map +1 -0
  298. package/dist/lib/wordmark.d.ts +60 -0
  299. package/dist/lib/wordmark.d.ts.map +1 -0
  300. package/dist/lib/wrap.d.ts +74 -0
  301. package/dist/lib/wrap.d.ts.map +1 -0
  302. package/dist/memory.d.ts +25 -0
  303. package/dist/memory.d.ts.map +1 -0
  304. package/dist/model.d.ts +47 -0
  305. package/dist/model.d.ts.map +1 -0
  306. package/dist/plugins.d.ts +15 -0
  307. package/dist/plugins.d.ts.map +1 -0
  308. package/dist/remove.d.ts +52 -0
  309. package/dist/remove.d.ts.map +1 -0
  310. package/dist/run.d.ts +42 -0
  311. package/dist/run.d.ts.map +1 -0
  312. package/dist/schedules.d.ts +41 -0
  313. package/dist/schedules.d.ts.map +1 -0
  314. package/dist/serve.d.ts +41 -0
  315. package/dist/serve.d.ts.map +1 -0
  316. package/dist/sessions.d.ts +13 -0
  317. package/dist/sessions.d.ts.map +1 -0
  318. package/dist/skills.d.ts +80 -0
  319. package/dist/skills.d.ts.map +1 -0
  320. package/dist/soul.d.ts +19 -0
  321. package/dist/soul.d.ts.map +1 -0
  322. package/dist/sources.d.ts +32 -0
  323. package/dist/sources.d.ts.map +1 -0
  324. package/dist/start.d.ts +26 -0
  325. package/dist/start.d.ts.map +1 -0
  326. package/dist/stop.d.ts +58 -0
  327. package/dist/stop.d.ts.map +1 -0
  328. package/dist/terminal-setup.d.ts +31 -0
  329. package/dist/terminal-setup.d.ts.map +1 -0
  330. package/dist/tools.d.ts +22 -0
  331. package/dist/tools.d.ts.map +1 -0
  332. package/dist/transcript.d.ts +124 -0
  333. package/dist/transcript.d.ts.map +1 -0
  334. package/dist/validate.d.ts +36 -0
  335. package/dist/validate.d.ts.map +1 -0
  336. package/dist/web-w7r68df1.js +14 -0
  337. package/dist/web-w7r68df1.js.map +11 -0
  338. package/dist/web.d.ts +36 -0
  339. package/dist/web.d.ts.map +1 -0
  340. package/dist/wire.d.ts +10 -0
  341. package/dist/wire.d.ts.map +1 -0
  342. package/dist/wire.js +33 -0
  343. package/dist/wire.js.map +10 -0
  344. package/dist/workspace.d.ts +19 -0
  345. package/dist/workspace.d.ts.map +1 -0
  346. package/package.json +78 -0
@@ -0,0 +1,120 @@
1
+ /**
2
+ * What removing an agent would actually take, and what should stop it.
3
+ *
4
+ * Facts in, a listing and an ordered plan out. Gathering the facts needs the filesystem, the store and
5
+ * `launchctl`; deciding what to do with them needs none of that — and the interesting cases here are
6
+ * exactly the ones that are painful to produce on a real machine: a manifest id shared by two
7
+ * directories, a live lease, an installed service, rows nobody claims. A table beats breaking a
8
+ * sandbox nine different ways.
9
+ *
10
+ * ## Why the listing and the deletion come from one place
11
+ *
12
+ * The confirmation is a listing plus the agent's name typed back, and the listing *is* `--dry-run` —
13
+ * one code path, so what a dry run shows is what a real run does. Deriving the two separately is how a
14
+ * confirmation comes to describe something other than what happens, which for an irreversible command
15
+ * is the worst available failure: the person read it, agreed to it, and got something else.
16
+ *
17
+ * No `node:*`, no `process`. This module is on the boundaries test's `PURE` list.
18
+ */
19
+ import type { AgentFootprint } from "@dispach/core";
20
+ export interface Finding {
21
+ readonly code: string;
22
+ readonly message: string;
23
+ /** Never optional. Hard rule 7, and a test asserts it over every finding this can produce. */
24
+ readonly hint: string;
25
+ }
26
+ /** A file the removal would delete, and what it costs to keep. */
27
+ export interface FileFacts {
28
+ readonly path: string;
29
+ readonly bytes: number;
30
+ }
31
+ export interface RemovalFacts {
32
+ /** The directory name — what was typed, and what the confirmation asks to be typed back. */
33
+ readonly ref: string;
34
+ /** The manifest id. Keys the store, the logs and the service label; may differ from `ref`. */
35
+ readonly agentId: string;
36
+ readonly dir: string;
37
+ /** Files under `dir`, counted and summed. Empty when the directory could not be read. */
38
+ readonly files: {
39
+ readonly count: number;
40
+ readonly bytes: number;
41
+ };
42
+ /** What the store holds for `agentId`. */
43
+ readonly footprint: AgentFootprint;
44
+ /** Log files that exist. Absent entries are simply not listed. */
45
+ readonly logs: readonly FileFacts[];
46
+ /**
47
+ * Other sandbox directories whose manifest id is also `agentId`.
48
+ *
49
+ * The refusal case. Store rows, logs and the service label are all keyed by id, so removing this
50
+ * agent's *data* would remove theirs.
51
+ */
52
+ readonly sharesIdWith: readonly string[];
53
+ /** A live process holding the lease, if any. */
54
+ readonly running?: {
55
+ readonly pid: number;
56
+ readonly mode: string;
57
+ };
58
+ /** The launchd label, when a service is installed under it. */
59
+ readonly service?: string;
60
+ /** Only the directory goes; the store, the logs and the service are left alone. */
61
+ readonly filesOnly: boolean;
62
+ }
63
+ /**
64
+ * What must not be removed, and why.
65
+ *
66
+ * **A shared manifest id blocks, rather than degrading to a partial removal.** Deleting store rows by
67
+ * `agent_id` when two directories answer to that id destroys the other agent's conversations and
68
+ * memory, and reports success — the silent-loss shape hard rule 8 exists to prevent. Falling back to
69
+ * files-only automatically was the alternative and is worse in a quieter way: it leaves rows that
70
+ * `agentIds` will list forever as belonging to nobody, having told the person their agent was gone.
71
+ *
72
+ * `--files-only` clears it, because then the id is not being acted on at all.
73
+ */
74
+ export declare function removalFindings(facts: RemovalFacts): readonly Finding[];
75
+ export type StepKind = "stop" | "service" | "store" | "logs" | "directory";
76
+ export interface Step {
77
+ readonly kind: StepKind;
78
+ /** What this step will do, in the imperative. Shown before it happens. */
79
+ readonly detail: string;
80
+ }
81
+ /**
82
+ * The steps, in the order they must run.
83
+ *
84
+ * The order is not cosmetic:
85
+ *
86
+ * 1. **Stop first.** A process holding the lease is still writing sessions, and a graceful stop is the
87
+ * only path that runs `provider.stop()` — the sole reaper for backgrounded `exec` children. Deleting
88
+ * a running agent's directory would leave a live process serving from a manifest that no longer
89
+ * exists, with orphaned shells behind it.
90
+ * 2. **Service next.** `disable` persists across boots and `bootout` does not, so both are needed: a
91
+ * label left enabled comes back at the next login and fails forever against a deleted manifest.
92
+ * 3. **Store, then logs, then the directory last.** Every earlier step is recoverable — an agent whose
93
+ * rows are gone still loads and still runs. The directory is the only irreplaceable part, so it goes
94
+ * when nothing else can fail; the reverse order leaves a manifest-less agent whose data is
95
+ * unreachable and whose name nothing can name.
96
+ */
97
+ export declare function removalSteps(facts: RemovalFacts): readonly Step[];
98
+ /**
99
+ * The listing shown before anything happens, and printed on its own by `--dry-run`.
100
+ *
101
+ * Every row is a number somebody might want to stop over. A zero row is still shown where its absence
102
+ * would be ambiguous — `service not installed` is information, and omitting it invites the reading
103
+ * that a service was quietly left behind.
104
+ */
105
+ export declare function renderRemoval(facts: RemovalFacts): string;
106
+ /** An agent id with rows or logs in the sandbox that no directory claims. */
107
+ export interface Orphan {
108
+ readonly agentId: string;
109
+ readonly footprint: AgentFootprint;
110
+ readonly logs: readonly FileFacts[];
111
+ }
112
+ /**
113
+ * The listing for `--prune`.
114
+ *
115
+ * Separate from `renderRemoval` because it answers a different question — not "what does this agent
116
+ * own" but "what is left over" — and because an orphan has no directory, no ref and no manifest, so
117
+ * most of the other rows would be empty or a lie.
118
+ */
119
+ export declare function renderOrphans(orphans: readonly Orphan[]): string;
120
+ //# sourceMappingURL=remove-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-plan.d.ts","sourceRoot":"","sources":["../../src/lib/remove-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAGnD,MAAM,WAAW,OAAO;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,8FAA8F;IAC9F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACxB;AAED,kEAAkE;AAClE,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,YAAY;IACzB,4FAA4F;IAC5F,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,8FAA8F;IAC9F,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,yFAAyF;IACzF,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAClE,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAA;IAClC,kEAAkE;IAClE,QAAQ,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,CAAA;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;IACxC,gDAAgD;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAClE,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,mFAAmF;IACnF,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAC9B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,OAAO,EAAE,CAUvE;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,WAAW,CAAA;AAE1E,MAAM,WAAW,IAAI;IACjB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,IAAI,EAAE,CA0BjE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAmEzD;AAED,6EAA6E;AAC7E,MAAM,WAAW,MAAM;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAA;IAClC,QAAQ,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,CAAA;CACtC;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAyBhE"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The plain path's shared vocabulary — the half of the house style that never had one.
3
+ *
4
+ * `theme.ts` serves the Ink path. The plain path is most of the binary, and until this file every
5
+ * command that printed a labelled block invented its own: eight hand-rolled `padEnd` widths across
6
+ * seven files (9, 14, `FLAG_COLUMN`, `ENV_COLUMN`, `COMMAND_COLUMN`, and three computed maxima),
7
+ * with `agents.ts` emitting tab-separated columns while everything beside it emitted padded ones.
8
+ * `agents` and `validate` genuinely looked like output from two different products.
9
+ *
10
+ * So this is not a new style — it is the existing one, written down once. A new surface that wants
11
+ * a labelled block, a status word or a byte count reaches here rather than adding a ninth variant.
12
+ *
13
+ * **Pure.** No `node:*`, no `process`, no colour decision. Every function is text in, text out, so
14
+ * it belongs on the boundaries test's `PURE` list and every rendering rule is unit-testable without
15
+ * capturing stdout. Colour is deliberately *not* applied here: the plain path is read as often from
16
+ * a log file as from a terminal, and a module that emitted escape codes would have to know which,
17
+ * which is `resolveMode`'s job and nowhere near a formatter's.
18
+ */
19
+ export interface Row {
20
+ readonly label: string;
21
+ readonly value: string;
22
+ /**
23
+ * Trailing text, aligned past the value.
24
+ *
25
+ * Its own field rather than something the caller concatenates, because the interesting rows
26
+ * are the ones carrying a fact *and* its consequence — "2463 · launchd has restarted this
27
+ * 2463 times" — and a caller building that by hand loses the alignment on the next row.
28
+ */
29
+ readonly note?: string;
30
+ }
31
+ /**
32
+ * A labelled block: two-space indent, labels padded to the widest, values aligned.
33
+ *
34
+ * Rows with an empty value are dropped rather than printed blank. A field that does not apply is
35
+ * not the same as a field that is empty, and printing `logs` with nothing after it invites the
36
+ * reader to wonder which one they are looking at.
37
+ */
38
+ export declare function keyValue(rows: readonly Row[]): string;
39
+ /** A heading with its own blank line above, unless it opens the output. */
40
+ export declare function section(title: string, first?: boolean): string;
41
+ export declare function bullet(text: string): string;
42
+ /** Indent a block that was rendered elsewhere — a log tail, a nested report. */
43
+ export declare function indent(text: string, depth?: number): string;
44
+ /**
45
+ * Bytes as a person reads them.
46
+ *
47
+ * Binary units, and the decimal place only below 10 in each unit — `1.2 MB` is worth a digit,
48
+ * `847 MB` is not, and the extra precision only makes a size harder to compare at a glance.
49
+ */
50
+ export declare function bytes(count: number): string;
51
+ /**
52
+ * A span, in the largest two units that carry information.
53
+ *
54
+ * "3h 12m" rather than "3.2 hours" or "11520 seconds": an uptime is read to answer "since roughly
55
+ * when", and two units is where that question stops getting better answers.
56
+ */
57
+ export declare function duration(ms: number): string;
58
+ /**
59
+ * `~/…` for a path under home, so a block of paths stays readable at a glance.
60
+ *
61
+ * Takes `home` rather than reading it, because this module is pure — and because the daemon's
62
+ * output has to be able to render a path under a *different* home than the current process's when
63
+ * it is describing a service definition it did not write.
64
+ */
65
+ export declare function tildify(path: string, home: string): string;
66
+ /**
67
+ * How long ago, in the shortest honest form.
68
+ *
69
+ * `now` is a parameter rather than a `Date.now()` call, which is what lets this live in a pure module and
70
+ * be shared. It was previously private to `sessions.ts` and read the clock itself, so the session picker
71
+ * would have had to reimplement it — and two renderings of "how old is this conversation" that disagree
72
+ * is the drift this module exists to end.
73
+ *
74
+ * An unparseable timestamp is returned as itself. A store row with a bad date is a real thing to see, and
75
+ * "NaNm ago" says nothing about it.
76
+ */
77
+ export declare function ago(iso: string, now: number): string;
78
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/lib/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAQH,MAAM,WAAW,GAAG;IAChB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,GAAG,MAAM,CAUrD;AAED,2EAA2E;AAC3E,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,MAAM,CAE5D;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,gFAAgF;AAChF,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,MAAM,CAMtD;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAW3C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAS3C;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI1D;AAKD;;;;;;;;;;GAUG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CASpD"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The conversation a resumed session paints, out of the messages the store kept.
3
+ *
4
+ * Pure, and extracted from `run` for one reason: it was four chained lambdas inside a function that
5
+ * needs a live runtime to call, so the only way to check it was to resume a real session and look. The
6
+ * shape it decides has already been wrong twice — first painting nothing at all under a banner that
7
+ * said `17 message(s)`, then painting every turn except the ones that called a tool — and both times
8
+ * the layers around it were individually correct.
9
+ *
10
+ * What counts as part of the conversation:
11
+ *
12
+ * - No `origin` — a person's message, or a reply the model wrote as its final answer.
13
+ * - `origin: "call"` — a tool-calling step. Its prose is narration the live session *did* show as it
14
+ * streamed, so excluding the row made a resumed transcript differ from the one that had been on
15
+ * screen. Under NLT the row also holds the ACTION block, which `proseOf` removes.
16
+ *
17
+ * What does not, and why each is deliberate rather than unhandled:
18
+ *
19
+ * - `origin: "observation"` — text a stranger wrote. It reaches the model inside a fence; painting it
20
+ * as part of the conversation would present it as something the agent or the person said.
21
+ * - `origin: "repair"` and `origin: "digest"` — the runtime talking to itself about a malformed call
22
+ * or a compacted history. True of the prompt, not of anything anybody said.
23
+ * - `role: "system"` and `role: "tool"` — the assembled prefix and native tool results, neither of
24
+ * which was ever on screen.
25
+ */
26
+ import type { ChatMessage, DialectId } from "@dispach/core";
27
+ import type { PriorMessage } from "#transcript";
28
+ /**
29
+ * `history` in order, reduced to what a reader saw. Empty prose is dropped, not painted blank.
30
+ *
31
+ * A step that called a tool without narrating it produces no text at all, and a blank message row in a
32
+ * resumed transcript reads as content that failed to load.
33
+ */
34
+ export declare function priorMessages(history: readonly ChatMessage[], dialect: DialectId): readonly PriorMessage[];
35
+ /**
36
+ * The note a clean exit leaves on the shell's own screen.
37
+ *
38
+ * Nothing else survives. That was the decision and the alternate screen enforces it whether we agree or
39
+ * not — so the one thing worth printing is not the conversation, which is in the store, but the command
40
+ * that reaches it again.
41
+ *
42
+ * Two lines and faint, which is a change from the one bright line this used to be. The old form led with
43
+ * `session <key> ·` and buried the command behind `resume with:`, so the half a person needs to *copy*
44
+ * sat at the end of a sentence they had to read first. The key is not lost by dropping the prefix — it is
45
+ * inside the command, which is the only place it is any use. And faint because this is the epilogue: the
46
+ * work is over, and a line as loud as the output above it reads as one more result.
47
+ *
48
+ * The agent is named by the ref `resolveAgentRef` accepts rather than by a path, because a line you
49
+ * cannot paste is a line that reads as help and is not.
50
+ */
51
+ export declare function resumeNotice(input: {
52
+ readonly ref: string | undefined;
53
+ readonly sessionKey: string;
54
+ }): string;
55
+ /**
56
+ * Why a banner is being printed, as the one sentence a person reads.
57
+ *
58
+ * Four answers, and they are genuinely different things to say: a `/restart` is about *configuration*
59
+ * and would be a lie about a switch; a `/new` opened a conversation that did not exist a moment ago,
60
+ * and the only thing worth saying about it is what happened to the one being left.
61
+ *
62
+ * Extracted from `bannerLines` because that function needs a live agent and a store to call, so the
63
+ * sentence selection — the only part a person actually reads — could not be checked without resuming a
64
+ * real session and looking. Exactly the reason `priorMessages` above lives here.
65
+ *
66
+ * The return is `undefined` for a first run: nothing has happened yet that needs explaining.
67
+ */
68
+ export declare function reopenNote(reopened: "first" | "restart" | "switch" | "new", previousKey?: string): string | undefined;
69
+ //# sourceMappingURL=resume.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resume.d.ts","sourceRoot":"","sources":["../../src/lib/resume.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;;GAKG;AACH,wBAAgB,aAAa,CACzB,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,OAAO,EAAE,SAAS,GACnB,SAAS,YAAY,EAAE,CAUzB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC9B,GAAG,MAAM,CAQT;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CACtB,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,EAChD,WAAW,CAAC,EAAE,MAAM,GACrB,MAAM,GAAG,SAAS,CAmBpB"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Laying a catalogue row out in a fixed number of columns. Pure, so the layout is testable as strings.
3
+ *
4
+ * ## Why this is not a component's problem
5
+ *
6
+ * The first version put the name, the size and the whole description in one `<Text>` and let Ink wrap.
7
+ * Every row longer than the terminal became two or three lines, the checkbox column stopped lining up,
8
+ * and a list of forty skills was unreadable. Wrapping is not a styling detail in a list — it destroys the
9
+ * one property a list has, which is that a row is a row.
10
+ *
11
+ * So the width arithmetic lives here, in one place, as functions over numbers and strings: pad the name to
12
+ * a column, pad the meta to a column, give the description whatever is left, and **truncate every field
13
+ * before it can wrap**. `Text` also carries `wrap="truncate"` as a backstop, but a backstop is not a
14
+ * layout — the columns have to add up, or the description gets cut at a width nobody chose.
15
+ */
16
+ /** `2284` → `2.3k`. A row is scanned, not audited, and five digits of precision cost a column. */
17
+ export declare function compactTokens(tokens: number): string;
18
+ export declare function metaOf(tokens: number, scripts: number, installed: boolean): string;
19
+ /** Cut to `width`, with an ellipsis when anything was lost. Never returns more than `width`. */
20
+ export declare function clip(text: string, width: number): string;
21
+ export interface RowColumns {
22
+ readonly name: number;
23
+ readonly meta: number;
24
+ readonly description: number;
25
+ }
26
+ /**
27
+ * How wide each column is at a given terminal width.
28
+ *
29
+ * The name column flexes with the longest name actually present rather than being fixed: a catalogue of
30
+ * short names should not leave a third of the row empty, and one long name should not push the
31
+ * description off the screen. Clamped at both ends for both reasons.
32
+ */
33
+ export declare function columnsFor(width: number, longestName: number, options?: {
34
+ readonly nameMax?: number;
35
+ }): RowColumns;
36
+ /**
37
+ * One row, exactly `width` characters wide or less, in three aligned columns.
38
+ *
39
+ * Returned as one string rather than as fields, because alignment is the whole point and a caller that
40
+ * assembled the parts could get the padding wrong. Colour is applied by the component *around* this — the
41
+ * arithmetic must not know about escape codes, which do not occupy columns and would break every count.
42
+ */
43
+ export declare function layoutRow(input: {
44
+ readonly name: string;
45
+ readonly meta: string;
46
+ readonly description: string;
47
+ }, columns: RowColumns): {
48
+ readonly name: string;
49
+ readonly meta: string;
50
+ readonly description: string;
51
+ };
52
+ /** A heading, drawn as a rule so groups separate without costing a blank line each. */
53
+ export declare function headingRule(label: string, width: number): string;
54
+ /**
55
+ * Which slice of a longer list to show.
56
+ *
57
+ * Shared by the catalogue list and the input box, which want the same rule for the same reason: both
58
+ * are taller than their allowance and both have a position that must stay visible. It lives here rather
59
+ * than in either component because the second caller is what proved it was layout arithmetic and not a
60
+ * detail of one screen.
61
+ *
62
+ * Originally: Keeps the cursor inside the window rather than paging, because a cursor that jumps a
63
+ * whole viewport loses the reader's place.
64
+ */
65
+ export declare function viewport(total: number, index: number, window: number): {
66
+ readonly from: number;
67
+ readonly to: number;
68
+ };
69
+ //# sourceMappingURL=rows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../src/lib/rows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAaH,kGAAkG;AAClG,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,CAIlF;AAED,gGAAgG;AAChG,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMxD;AAED,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC/B;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACtB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5C,UAAU,CAmBZ;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACrB,KAAK,EAAE;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC/B,EACD,OAAO,EAAE,UAAU,GACpB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAMhF;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIhE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CACpB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACf;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAKhD"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * The home sandbox: where agents live when nobody says otherwise.
3
+ *
4
+ * `~/<stateDir>/` (brand-derived, so a rename moves it) holds `agents/<ref>/` for init-created
5
+ * agents and `store.db` for their sessions. One root, one store: the store schema is already
6
+ * keyed by agent id, and a cwd-relative default meant the same agent got a different session
7
+ * history in every directory you happened to be in.
8
+ *
9
+ * Discovery reads manifest *headers*, never `loadManifest`: loading expands env references and
10
+ * checks that key variables are set, so a picker built on it would fail exactly when it is
11
+ * needed most — on a machine where the key is not exported yet. A broken manifest becomes a
12
+ * listed entry with a `problem`, never a broken listing.
13
+ *
14
+ * Tests override the root with `<ENVPREFIX>HOME` pointed at a tmpdir; nothing here touches the
15
+ * real home directory when that is set.
16
+ */
17
+ export declare function sandboxRoot(env?: Readonly<Record<string, string | undefined>>): string;
18
+ export declare function agentsDir(env?: Readonly<Record<string, string | undefined>>): string;
19
+ export declare function storePath(env?: Readonly<Record<string, string | undefined>>): string;
20
+ /**
21
+ * Where a service writes its output, keyed by the agent's **manifest id**.
22
+ *
23
+ * Not by the directory name, which is what `run <ref>` takes — the same split as the store's
24
+ * `agent_id` and the launchd label. Two directories with one manifest id therefore share these files,
25
+ * which `listAgents` already warns about.
26
+ *
27
+ * Here rather than in `daemon.ts`, where it was private, because it is a fact about the sandbox layout
28
+ * and `remove` needs it too. Moved rather than duplicated: a second copy of a path derivation is how
29
+ * one command deletes a file another command is still writing to.
30
+ */
31
+ /**
32
+ * Where the one server unit writes, in a **subdirectory** rather than beside the agent logs.
33
+ *
34
+ * `logs/<id>.err.log` is the per-agent shape, so a flat `logs/server.err.log` would collide with an
35
+ * agent whose id happened to be `server` — and the collision would appear as a service and an agent
36
+ * appending to one file, which is the kind of thing nobody diagnoses from a log.
37
+ */
38
+ export declare function serverLogPaths(env?: Readonly<Record<string, string | undefined>>): {
39
+ readonly out: string;
40
+ readonly err: string;
41
+ };
42
+ export declare function logPaths(agentId: string, env?: Readonly<Record<string, string | undefined>>): {
43
+ readonly out: string;
44
+ readonly err: string;
45
+ };
46
+ /**
47
+ * Is this path inside the sandbox's agents directory?
48
+ *
49
+ * Both sides are resolved first, for the reason `root.ts` already records: an unresolved
50
+ * `<base>/../../elsewhere` passes a prefix test while landing nowhere near the base. The `sep`
51
+ * suffix is what stops `~/.brand/agents-backup` reading as inside `~/.brand/agents`.
52
+ */
53
+ export declare function insideSandbox(targetDir: string, env?: Readonly<Record<string, string | undefined>>): boolean;
54
+ /**
55
+ * The one-line note an out-of-sandbox target earns, or `undefined` when it is inside.
56
+ *
57
+ * A note rather than a refusal: `init --dir ./examples/scout` is a legitimate thing to want, and a
58
+ * command that refuses it would be one people work around with `mv`. What is *not* legitimate is
59
+ * doing it silently — an agent outside the sandbox has no bare name, so every later `run`, `config`,
60
+ * `daemon` and `schedules` call needs a path, and the reason for that is only obvious at the moment
61
+ * the directory is chosen.
62
+ *
63
+ * Pure and separate from the write so the sentence can be asserted without a filesystem.
64
+ */
65
+ export declare function outsideSandboxNote(targetDir: string, env?: Readonly<Record<string, string | undefined>>): string | undefined;
66
+ export interface SandboxAgent {
67
+ /** The directory name — what `run <ref>` takes. Filesystem-unique by construction. */
68
+ readonly ref: string;
69
+ /** Absolute agent directory. */
70
+ readonly dir: string;
71
+ /** Absolute path to its agent.yaml. */
72
+ readonly manifestPath: string;
73
+ /** From the manifest header; may differ from `ref` for hand-copied directories. */
74
+ readonly id?: string;
75
+ readonly name?: string;
76
+ /** Raw — may literally be an unexpanded `${MODEL_ID}` reference. */
77
+ readonly modelId?: string;
78
+ /** Modification time of the manifest, for "recently used" ordering hints. */
79
+ readonly mtimeMs: number;
80
+ /** Present when the manifest could not be read; the entry lists anyway, honestly. */
81
+ readonly problem?: string;
82
+ }
83
+ /**
84
+ * Every agent directory in the sandbox, alphabetical by ref with broken entries last.
85
+ *
86
+ * Broken means the header could not be read — the entry still appears, carrying the problem,
87
+ * because a listing that silently hides a corrupted agent turns "why is my agent gone" into a
88
+ * filesystem investigation. Duplicate manifest ids are marked the same way: both run, but their
89
+ * sessions share a store keyed by that id, which is worth a warning rather than a pretence.
90
+ */
91
+ export declare function listAgents(env?: Readonly<Record<string, string | undefined>>): readonly SandboxAgent[];
92
+ /**
93
+ * Turn what the user typed into a manifest path.
94
+ *
95
+ * The filesystem wins: anything that looks like a path (a separator, a .yaml suffix, or a thing
96
+ * that exists here) is a path, so `./milo` always forces the file even when a sandbox agent
97
+ * `milo` exists — the same rule git applies to pathspec-versus-branch, with the same free escape
98
+ * hatch. Only then is the ref tried as a sandbox agent name.
99
+ */
100
+ export declare function resolveAgentRef(ref: string, env?: Readonly<Record<string, string | undefined>>, cwd?: string): string;
101
+ //# sourceMappingURL=sandbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/lib/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH,wBAAgB,WAAW,CACvB,GAAG,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAe,GAChE,MAAM,CAGR;AAED,wBAAgB,SAAS,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,MAAM,CAEpF;AAED,wBAAgB,SAAS,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,MAAM,CAEpF;AAED;;;;;;;;;;GAUG;AACH;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG;IAChF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACvB,CAGA;AAED,wBAAgB,QAAQ,CACpB,OAAO,EAAE,MAAM,EACf,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GACnD;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAGhD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CACzB,SAAS,EAAE,MAAM,EACjB,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GACnD,OAAO,CAIT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAC9B,SAAS,EAAE,MAAM,EACjB,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GACnD,MAAM,GAAG,SAAS,CAGpB;AAED,MAAM,WAAW,YAAY;IACzB,sFAAsF;IACtF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,gCAAgC;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,uCAAuC;IACvC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,mFAAmF;IACnF,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,oEAAoE;IACpE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,qFAAqF;IACrF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACtB,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GACnD,SAAS,YAAY,EAAE,CAoEzB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC3B,GAAG,EAAE,MAAM,EACX,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EAClD,GAAG,GAAE,MAAsB,GAC5B,MAAM,CA8CR"}