@maiaos/cli 0.1.0-canary.2

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 (413) hide show
  1. package/README.md +287 -0
  2. package/dist/bin/maia.NOTICES.txt +59 -0
  3. package/dist/bin/maia.cdx.json +145 -0
  4. package/dist/bin/maia.mjs +2 -0
  5. package/dist/bootstrap/index.d.ts +3 -0
  6. package/dist/bootstrap/index.js +3 -0
  7. package/dist/bootstrap/process.d.ts +5 -0
  8. package/dist/bootstrap/process.js +45 -0
  9. package/dist/bootstrap/run.d.ts +25 -0
  10. package/dist/bootstrap/run.js +95 -0
  11. package/dist/bootstrap/stdio.d.ts +4 -0
  12. package/dist/bootstrap/stdio.js +9 -0
  13. package/dist/cli/cli.d.ts +17 -0
  14. package/dist/cli/cli.js +481 -0
  15. package/dist/cli/environment.d.ts +8 -0
  16. package/dist/cli/environment.js +12 -0
  17. package/dist/cli/index.d.ts +2 -0
  18. package/dist/cli/index.js +2 -0
  19. package/dist/cli/services.d.ts +4 -0
  20. package/dist/cli/services.js +4 -0
  21. package/dist/command-line/context.d.ts +178 -0
  22. package/dist/command-line/context.js +2 -0
  23. package/dist/command-line/index.d.ts +7 -0
  24. package/dist/command-line/index.js +6 -0
  25. package/dist/command-line/input/arguments.d.ts +55 -0
  26. package/dist/command-line/input/arguments.js +220 -0
  27. package/dist/command-line/input/index.d.ts +4 -0
  28. package/dist/command-line/input/index.js +4 -0
  29. package/dist/command-line/input/prompt.d.ts +8 -0
  30. package/dist/command-line/input/prompt.js +44 -0
  31. package/dist/command-line/input/stdin-stream.d.ts +4 -0
  32. package/dist/command-line/input/stdin-stream.js +3 -0
  33. package/dist/command-line/input/stdin.d.ts +11 -0
  34. package/dist/command-line/input/stdin.js +23 -0
  35. package/dist/command-line/json-decoder.d.ts +3 -0
  36. package/dist/command-line/json-decoder.js +3 -0
  37. package/dist/command-line/json.d.ts +3 -0
  38. package/dist/command-line/json.js +4 -0
  39. package/dist/command-line/output.d.ts +57 -0
  40. package/dist/command-line/output.js +94 -0
  41. package/dist/command-line/rows.d.ts +10 -0
  42. package/dist/command-line/rows.js +32 -0
  43. package/dist/command-line/two-phase.d.ts +57 -0
  44. package/dist/command-line/two-phase.js +148 -0
  45. package/dist/command-receipt/command.d.ts +4 -0
  46. package/dist/command-receipt/command.js +59 -0
  47. package/dist/command-receipt/compact-list.d.ts +20 -0
  48. package/dist/command-receipt/compact-list.js +29 -0
  49. package/dist/command-receipt/index.d.ts +3 -0
  50. package/dist/command-receipt/index.js +3 -0
  51. package/dist/command-tree/commands.d.ts +17 -0
  52. package/dist/command-tree/commands.js +41 -0
  53. package/dist/command-tree/completion.d.ts +6 -0
  54. package/dist/command-tree/completion.js +36 -0
  55. package/dist/command-tree/grammar.d.ts +18 -0
  56. package/dist/command-tree/grammar.js +160 -0
  57. package/dist/command-tree/help.d.ts +62 -0
  58. package/dist/command-tree/help.js +219 -0
  59. package/dist/command-tree/index.d.ts +8 -0
  60. package/dist/command-tree/index.js +6 -0
  61. package/dist/command-tree/local.d.ts +3 -0
  62. package/dist/command-tree/local.js +126 -0
  63. package/dist/command-tree/placeholder.d.ts +3 -0
  64. package/dist/command-tree/placeholder.js +4 -0
  65. package/dist/command-tree/row.d.ts +29 -0
  66. package/dist/command-tree/row.js +2 -0
  67. package/dist/command-tree/suggest.d.ts +3 -0
  68. package/dist/command-tree/suggest.js +81 -0
  69. package/dist/command-tree/tree.d.ts +34 -0
  70. package/dist/command-tree/tree.js +124 -0
  71. package/dist/connection/client.d.ts +692 -0
  72. package/dist/connection/client.js +28 -0
  73. package/dist/connection/commands.d.ts +15 -0
  74. package/dist/connection/commands.js +118 -0
  75. package/dist/connection/index.d.ts +7 -0
  76. package/dist/connection/index.js +7 -0
  77. package/dist/connection/input.d.ts +50 -0
  78. package/dist/connection/input.js +90 -0
  79. package/dist/connection/login.d.ts +13 -0
  80. package/dist/connection/login.js +69 -0
  81. package/dist/connection/output/format.d.ts +32 -0
  82. package/dist/connection/output/format.js +94 -0
  83. package/dist/connection/output/index.d.ts +2 -0
  84. package/dist/connection/output/index.js +2 -0
  85. package/dist/connection/resolve.d.ts +60 -0
  86. package/dist/connection/resolve.js +30 -0
  87. package/dist/connection/signin.d.ts +4 -0
  88. package/dist/connection/signin.js +32 -0
  89. package/dist/connection/system.d.ts +4 -0
  90. package/dist/connection/system.js +190 -0
  91. package/dist/connection/tree/index.d.ts +2 -0
  92. package/dist/connection/tree/index.js +2 -0
  93. package/dist/connection/tree/tree.d.ts +3 -0
  94. package/dist/connection/tree/tree.js +209 -0
  95. package/dist/container/client.d.ts +142 -0
  96. package/dist/container/client.js +11 -0
  97. package/dist/container/commands.d.ts +7 -0
  98. package/dist/container/commands.js +100 -0
  99. package/dist/container/index.d.ts +3 -0
  100. package/dist/container/index.js +3 -0
  101. package/dist/container/output/format.d.ts +11 -0
  102. package/dist/container/output/format.js +28 -0
  103. package/dist/container/output/index.d.ts +2 -0
  104. package/dist/container/output/index.js +2 -0
  105. package/dist/context/client.d.ts +7 -0
  106. package/dist/context/client.js +21 -0
  107. package/dist/context/commands.d.ts +3 -0
  108. package/dist/context/commands.js +27 -0
  109. package/dist/context/index.d.ts +3 -0
  110. package/dist/context/index.js +3 -0
  111. package/dist/development/cli.d.ts +3 -0
  112. package/dist/development/cli.js +44 -0
  113. package/dist/execution/client.d.ts +25 -0
  114. package/dist/execution/client.js +24 -0
  115. package/dist/execution/index.d.ts +3 -0
  116. package/dist/execution/index.js +3 -0
  117. package/dist/execution/relocation.d.ts +6 -0
  118. package/dist/execution/relocation.js +123 -0
  119. package/dist/execution/tree/index.d.ts +2 -0
  120. package/dist/execution/tree/index.js +2 -0
  121. package/dist/execution/tree/tree.d.ts +3 -0
  122. package/dist/execution/tree/tree.js +137 -0
  123. package/dist/hold/client.d.ts +137 -0
  124. package/dist/hold/client.js +12 -0
  125. package/dist/hold/commands.d.ts +5 -0
  126. package/dist/hold/commands.js +91 -0
  127. package/dist/hold/index.d.ts +3 -0
  128. package/dist/hold/index.js +3 -0
  129. package/dist/hold/output/format.d.ts +11 -0
  130. package/dist/hold/output/format.js +29 -0
  131. package/dist/hold/output/index.d.ts +2 -0
  132. package/dist/hold/output/index.js +2 -0
  133. package/dist/hold/tree/index.d.ts +2 -0
  134. package/dist/hold/tree/index.js +2 -0
  135. package/dist/hold/tree/tree.d.ts +3 -0
  136. package/dist/hold/tree/tree.js +96 -0
  137. package/dist/import/client.d.ts +14 -0
  138. package/dist/import/client.js +16 -0
  139. package/dist/import/commands.d.ts +5 -0
  140. package/dist/import/commands.js +76 -0
  141. package/dist/import/index.d.ts +3 -0
  142. package/dist/import/index.js +3 -0
  143. package/dist/import/input.d.ts +16 -0
  144. package/dist/import/input.js +92 -0
  145. package/dist/import/output.d.ts +6 -0
  146. package/dist/import/output.js +40 -0
  147. package/dist/index.d.ts +2 -0
  148. package/dist/index.js +2 -0
  149. package/dist/integration/client.d.ts +1284 -0
  150. package/dist/integration/client.js +24 -0
  151. package/dist/integration/commands.d.ts +10 -0
  152. package/dist/integration/commands.js +104 -0
  153. package/dist/integration/index.d.ts +3 -0
  154. package/dist/integration/index.js +3 -0
  155. package/dist/integration/output.d.ts +22 -0
  156. package/dist/integration/output.js +20 -0
  157. package/dist/local-node/call.d.ts +7 -0
  158. package/dist/local-node/call.js +13 -0
  159. package/dist/local-node/client.d.ts +67 -0
  160. package/dist/local-node/client.js +241 -0
  161. package/dist/local-node/index.d.ts +3 -0
  162. package/dist/local-node/index.js +3 -0
  163. package/dist/login/agent-provider.d.ts +20 -0
  164. package/dist/login/agent-provider.js +109 -0
  165. package/dist/login/commands.d.ts +4 -0
  166. package/dist/login/commands.js +93 -0
  167. package/dist/login/failure.d.ts +3 -0
  168. package/dist/login/failure.js +14 -0
  169. package/dist/login/gateway.d.ts +12 -0
  170. package/dist/login/gateway.js +71 -0
  171. package/dist/login/index.d.ts +3 -0
  172. package/dist/login/index.js +2 -0
  173. package/dist/login/menu.d.ts +4 -0
  174. package/dist/login/menu.js +105 -0
  175. package/dist/login/output/format.d.ts +16 -0
  176. package/dist/login/output/format.js +31 -0
  177. package/dist/login/output/index.d.ts +2 -0
  178. package/dist/login/output/index.js +2 -0
  179. package/dist/login/vendor-account.d.ts +95 -0
  180. package/dist/login/vendor-account.js +75 -0
  181. package/dist/login/vendor-input.d.ts +14 -0
  182. package/dist/login/vendor-input.js +36 -0
  183. package/dist/mcp/calls.d.ts +7 -0
  184. package/dist/mcp/calls.js +202 -0
  185. package/dist/mcp/commands.d.ts +9 -0
  186. package/dist/mcp/commands.js +21 -0
  187. package/dist/mcp/index.d.ts +2 -0
  188. package/dist/mcp/index.js +2 -0
  189. package/dist/mcp/server.d.ts +11 -0
  190. package/dist/mcp/server.js +57 -0
  191. package/dist/orchestration/client.d.ts +78 -0
  192. package/dist/orchestration/client.js +89 -0
  193. package/dist/orchestration/commands.d.ts +14 -0
  194. package/dist/orchestration/commands.js +312 -0
  195. package/dist/orchestration/index.d.ts +3 -0
  196. package/dist/orchestration/index.js +3 -0
  197. package/dist/orchestration/output/compact-aggregate.d.ts +121 -0
  198. package/dist/orchestration/output/compact-aggregate.js +110 -0
  199. package/dist/orchestration/output/compact-run-list.d.ts +20 -0
  200. package/dist/orchestration/output/compact-run-list.js +16 -0
  201. package/dist/orchestration/output/human.d.ts +80 -0
  202. package/dist/orchestration/output/human.js +252 -0
  203. package/dist/orchestration/output/index.d.ts +4 -0
  204. package/dist/orchestration/output/index.js +4 -0
  205. package/dist/orchestration/tree/index.d.ts +2 -0
  206. package/dist/orchestration/tree/index.js +2 -0
  207. package/dist/orchestration/tree/tree.d.ts +3 -0
  208. package/dist/orchestration/tree/tree.js +142 -0
  209. package/dist/port-lease/client.d.ts +160 -0
  210. package/dist/port-lease/client.js +11 -0
  211. package/dist/port-lease/commands.d.ts +6 -0
  212. package/dist/port-lease/commands.js +17 -0
  213. package/dist/port-lease/index.d.ts +3 -0
  214. package/dist/port-lease/index.js +3 -0
  215. package/dist/port-lease/input.d.ts +65 -0
  216. package/dist/port-lease/input.js +67 -0
  217. package/dist/port-lease/output/format.d.ts +11 -0
  218. package/dist/port-lease/output/format.js +24 -0
  219. package/dist/port-lease/output/index.d.ts +2 -0
  220. package/dist/port-lease/output/index.js +2 -0
  221. package/dist/presentation/client.d.ts +10 -0
  222. package/dist/presentation/client.js +9 -0
  223. package/dist/presentation/commands.d.ts +6 -0
  224. package/dist/presentation/commands.js +78 -0
  225. package/dist/presentation/index.d.ts +4 -0
  226. package/dist/presentation/index.js +3 -0
  227. package/dist/presentation/output/format.d.ts +11 -0
  228. package/dist/presentation/output/format.js +32 -0
  229. package/dist/presentation/output/index.d.ts +3 -0
  230. package/dist/presentation/output/index.js +2 -0
  231. package/dist/project-guard/client.d.ts +88 -0
  232. package/dist/project-guard/client.js +7 -0
  233. package/dist/project-guard/commands.d.ts +4 -0
  234. package/dist/project-guard/commands.js +39 -0
  235. package/dist/project-guard/index.d.ts +3 -0
  236. package/dist/project-guard/index.js +3 -0
  237. package/dist/project-guard/input.d.ts +18 -0
  238. package/dist/project-guard/input.js +47 -0
  239. package/dist/project-guard/output/format.d.ts +11 -0
  240. package/dist/project-guard/output/format.js +35 -0
  241. package/dist/project-guard/output/index.d.ts +2 -0
  242. package/dist/project-guard/output/index.js +2 -0
  243. package/dist/project-workspace/client.d.ts +86 -0
  244. package/dist/project-workspace/client.js +159 -0
  245. package/dist/project-workspace/commands.d.ts +30 -0
  246. package/dist/project-workspace/commands.js +700 -0
  247. package/dist/project-workspace/index.d.ts +5 -0
  248. package/dist/project-workspace/index.js +5 -0
  249. package/dist/project-workspace/metadata-client.d.ts +99 -0
  250. package/dist/project-workspace/metadata-client.js +8 -0
  251. package/dist/project-workspace/metadata-commands.d.ts +4 -0
  252. package/dist/project-workspace/metadata-commands.js +56 -0
  253. package/dist/project-workspace/output/human.d.ts +126 -0
  254. package/dist/project-workspace/output/human.js +103 -0
  255. package/dist/project-workspace/output/index.d.ts +3 -0
  256. package/dist/project-workspace/output/index.js +3 -0
  257. package/dist/project-workspace/output/metadata.d.ts +11 -0
  258. package/dist/project-workspace/output/metadata.js +17 -0
  259. package/dist/project-workspace/tree/index.d.ts +2 -0
  260. package/dist/project-workspace/tree/index.js +2 -0
  261. package/dist/project-workspace/tree/tree.d.ts +3 -0
  262. package/dist/project-workspace/tree/tree.js +197 -0
  263. package/dist/provider/client.d.ts +6 -0
  264. package/dist/provider/client.js +5 -0
  265. package/dist/provider/commands.d.ts +3 -0
  266. package/dist/provider/commands.js +38 -0
  267. package/dist/provider/index.d.ts +3 -0
  268. package/dist/provider/index.js +3 -0
  269. package/dist/reference/commands.d.ts +3 -0
  270. package/dist/reference/commands.js +39 -0
  271. package/dist/reference/index.d.ts +3 -0
  272. package/dist/reference/index.js +3 -0
  273. package/dist/reference/resolve.d.ts +29 -0
  274. package/dist/reference/resolve.js +294 -0
  275. package/dist/reference/tree/index.d.ts +2 -0
  276. package/dist/reference/tree/index.js +2 -0
  277. package/dist/reference/tree/tree.d.ts +3 -0
  278. package/dist/reference/tree/tree.js +17 -0
  279. package/dist/remote-node/client.d.ts +258 -0
  280. package/dist/remote-node/client.js +12 -0
  281. package/dist/remote-node/commands.d.ts +6 -0
  282. package/dist/remote-node/commands.js +264 -0
  283. package/dist/remote-node/connector.d.ts +59 -0
  284. package/dist/remote-node/connector.js +122 -0
  285. package/dist/remote-node/index.d.ts +4 -0
  286. package/dist/remote-node/index.js +4 -0
  287. package/dist/remote-node/reachability.d.ts +22 -0
  288. package/dist/remote-node/reachability.js +34 -0
  289. package/dist/remote-node/text.d.ts +9 -0
  290. package/dist/remote-node/text.js +64 -0
  291. package/dist/remote-node/tree/index.d.ts +2 -0
  292. package/dist/remote-node/tree/index.js +2 -0
  293. package/dist/remote-node/tree/tree.d.ts +3 -0
  294. package/dist/remote-node/tree/tree.js +51 -0
  295. package/dist/run-ledger/client.d.ts +358 -0
  296. package/dist/run-ledger/client.js +13 -0
  297. package/dist/run-ledger/commands.d.ts +8 -0
  298. package/dist/run-ledger/commands.js +19 -0
  299. package/dist/run-ledger/index.d.ts +3 -0
  300. package/dist/run-ledger/index.js +3 -0
  301. package/dist/run-ledger/input.d.ts +42 -0
  302. package/dist/run-ledger/input.js +107 -0
  303. package/dist/run-ledger/output/format.d.ts +11 -0
  304. package/dist/run-ledger/output/format.js +49 -0
  305. package/dist/run-ledger/output/index.d.ts +2 -0
  306. package/dist/run-ledger/output/index.js +2 -0
  307. package/dist/session/agent-permission.d.ts +63 -0
  308. package/dist/session/agent-permission.js +20 -0
  309. package/dist/session/approval/client.d.ts +117 -0
  310. package/dist/session/approval/client.js +7 -0
  311. package/dist/session/approval/commands.d.ts +7 -0
  312. package/dist/session/approval/commands.js +123 -0
  313. package/dist/session/approval/index.d.ts +3 -0
  314. package/dist/session/approval/index.js +3 -0
  315. package/dist/session/approval/output/format.d.ts +12 -0
  316. package/dist/session/approval/output/format.js +25 -0
  317. package/dist/session/approval/output/index.d.ts +2 -0
  318. package/dist/session/approval/output/index.js +2 -0
  319. package/dist/session/attach-client.d.ts +16 -0
  320. package/dist/session/attach-client.js +8 -0
  321. package/dist/session/attach-render.d.ts +16 -0
  322. package/dist/session/attach-render.js +154 -0
  323. package/dist/session/attach.d.ts +5 -0
  324. package/dist/session/attach.js +106 -0
  325. package/dist/session/client.d.ts +132 -0
  326. package/dist/session/client.js +128 -0
  327. package/dist/session/coding-client.d.ts +16 -0
  328. package/dist/session/coding-client.js +15 -0
  329. package/dist/session/coding-commands.d.ts +4 -0
  330. package/dist/session/coding-commands.js +50 -0
  331. package/dist/session/commands.d.ts +13 -0
  332. package/dist/session/commands.js +488 -0
  333. package/dist/session/create-tasks.d.ts +20 -0
  334. package/dist/session/create-tasks.js +110 -0
  335. package/dist/session/index.d.ts +9 -0
  336. package/dist/session/index.js +7 -0
  337. package/dist/session/interaction/client.d.ts +347 -0
  338. package/dist/session/interaction/client.js +15 -0
  339. package/dist/session/interaction/commands.d.ts +7 -0
  340. package/dist/session/interaction/commands.js +101 -0
  341. package/dist/session/interaction/index.d.ts +3 -0
  342. package/dist/session/interaction/index.js +3 -0
  343. package/dist/session/interaction/input.d.ts +15 -0
  344. package/dist/session/interaction/input.js +46 -0
  345. package/dist/session/interaction/output/format.d.ts +11 -0
  346. package/dist/session/interaction/output/format.js +3 -0
  347. package/dist/session/interaction/output/index.d.ts +2 -0
  348. package/dist/session/interaction/output/index.js +2 -0
  349. package/dist/session/output/diff.d.ts +3 -0
  350. package/dist/session/output/diff.js +30 -0
  351. package/dist/session/output/failure.d.ts +11 -0
  352. package/dist/session/output/failure.js +24 -0
  353. package/dist/session/output/human.d.ts +112 -0
  354. package/dist/session/output/human.js +71 -0
  355. package/dist/session/output/index.d.ts +6 -0
  356. package/dist/session/output/index.js +6 -0
  357. package/dist/session/output/observe.d.ts +4 -0
  358. package/dist/session/output/observe.js +46 -0
  359. package/dist/session/output/tasks.d.ts +19 -0
  360. package/dist/session/output/tasks.js +34 -0
  361. package/dist/session/rename.d.ts +3 -0
  362. package/dist/session/rename.js +37 -0
  363. package/dist/session/task-file.d.ts +5 -0
  364. package/dist/session/task-file.js +23 -0
  365. package/dist/session/tree/index.d.ts +2 -0
  366. package/dist/session/tree/index.js +2 -0
  367. package/dist/session/tree/tree.d.ts +3 -0
  368. package/dist/session/tree/tree.js +309 -0
  369. package/dist/session/turn/client.d.ts +25 -0
  370. package/dist/session/turn/client.js +40 -0
  371. package/dist/session/turn/commands.d.ts +6 -0
  372. package/dist/session/turn/commands.js +157 -0
  373. package/dist/session/turn/index.d.ts +4 -0
  374. package/dist/session/turn/index.js +3 -0
  375. package/dist/session/turn/output.d.ts +42 -0
  376. package/dist/session/turn/output.js +38 -0
  377. package/dist/status/client.d.ts +119 -0
  378. package/dist/status/client.js +5 -0
  379. package/dist/status/command.d.ts +4 -0
  380. package/dist/status/command.js +40 -0
  381. package/dist/status/doctor.d.ts +15 -0
  382. package/dist/status/doctor.js +111 -0
  383. package/dist/status/index.d.ts +5 -0
  384. package/dist/status/index.js +4 -0
  385. package/dist/status/output/compact.d.ts +31 -0
  386. package/dist/status/output/compact.js +46 -0
  387. package/dist/status/output/human.d.ts +7 -0
  388. package/dist/status/output/human.js +30 -0
  389. package/dist/status/output/index.d.ts +3 -0
  390. package/dist/status/output/index.js +3 -0
  391. package/dist/terminal/arguments.d.ts +13 -0
  392. package/dist/terminal/arguments.js +79 -0
  393. package/dist/terminal/client.d.ts +79 -0
  394. package/dist/terminal/client.js +68 -0
  395. package/dist/terminal/commands.d.ts +7 -0
  396. package/dist/terminal/commands.js +131 -0
  397. package/dist/terminal/control-commands.d.ts +10 -0
  398. package/dist/terminal/control-commands.js +212 -0
  399. package/dist/terminal/index.d.ts +4 -0
  400. package/dist/terminal/index.js +4 -0
  401. package/dist/terminal/output/compact-list.d.ts +147 -0
  402. package/dist/terminal/output/compact-list.js +152 -0
  403. package/dist/terminal/output/human.d.ts +59 -0
  404. package/dist/terminal/output/human.js +55 -0
  405. package/dist/terminal/output/index.d.ts +3 -0
  406. package/dist/terminal/output/index.js +3 -0
  407. package/dist/terminal/tree/index.d.ts +2 -0
  408. package/dist/terminal/tree/index.js +2 -0
  409. package/dist/terminal/tree/tree.d.ts +3 -0
  410. package/dist/terminal/tree/tree.js +104 -0
  411. package/guidance/maia-cli/SKILL.md +58 -0
  412. package/guidance/maia-orchestration/SKILL.md +54 -0
  413. package/package.json +76 -0
@@ -0,0 +1,57 @@
1
+ import type { ProtocolError } from "@maiaos/sdk";
2
+ import type * as Effect from "effect/Effect";
3
+ import type { CliMutationRecovery, CliNodeResult } from "../local-node/index.js";
4
+ import type { BoundedStdinRequest, CliArgumentError, PromptOptions } from "./input/index.js";
5
+ export type CliIo = {
6
+ readonly cwd?: string;
7
+ readonly interactive?: boolean;
8
+ readonly prompt?: (question: string, options?: PromptOptions) => Effect.Effect<string | undefined>;
9
+ readonly stderr: (text: string) => void;
10
+ readonly stdin?: (request: BoundedStdinRequest) => Effect.Effect<string, CliArgumentError>;
11
+ readonly stdout: (text: string) => void;
12
+ };
13
+ export type CliSuccessResult = {
14
+ readonly command: string;
15
+ };
16
+ export type CliResolution = {
17
+ readonly argument: string;
18
+ readonly id: string;
19
+ readonly kind: string;
20
+ readonly label?: string;
21
+ readonly match: "id" | "name" | "path" | "prefix" | "selection";
22
+ readonly reference?: string;
23
+ };
24
+ export type CliSuccessOutput = {
25
+ readonly ok: boolean;
26
+ readonly resolved?: readonly CliResolution[];
27
+ readonly result: CliSuccessResult;
28
+ };
29
+ export type CliUsageHint = {
30
+ readonly hint: string;
31
+ readonly usage: readonly string[];
32
+ };
33
+ export type CliErrorOutput = Partial<CliUsageHint> & {
34
+ readonly error: ProtocolError;
35
+ readonly ok: false;
36
+ readonly recovery?: CliMutationRecovery;
37
+ };
38
+ export type OutputContext = {
39
+ readonly io: CliIo;
40
+ readonly json: boolean;
41
+ readonly ok?: boolean;
42
+ readonly resolved?: readonly CliResolution[];
43
+ };
44
+ type ErrorContext = OutputContext & {
45
+ readonly recovery?: CliMutationRecovery;
46
+ readonly usage?: CliUsageHint;
47
+ };
48
+ export type CliCommandOutput = CliSuccessResult;
49
+ export declare const writeSuccess: <TResult extends CliCommandOutput>(result: TResult, { io, json, ok, resolved }: OutputContext, human: (result: TResult) => string) => void;
50
+ export declare const reportError: (error: ProtocolError, context: ErrorContext) => number;
51
+ export type NodeResultPresenter<TValue, TResult extends CliCommandOutput> = {
52
+ readonly toResult: (value: TValue) => TResult;
53
+ readonly toText: (result: TResult) => string;
54
+ };
55
+ export declare const writeNodeResult: <TValue, TResult extends CliCommandOutput>(result: CliNodeResult<TValue>, context: OutputContext, { toResult, toText }: NodeResultPresenter<TValue, TResult>) => number;
56
+ export {};
57
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1,94 @@
1
+ const EXIT_DATA_NOT_FOUND = 66;
2
+ const EXIT_USAGE = 64;
3
+ const EXIT_UNAVAILABLE = 69;
4
+ const EXIT_SOFTWARE = 70;
5
+ const EXIT_DEADLINE = 74;
6
+ const EXIT_TEMPORARY = 75;
7
+ const EXIT_OUTCOME_UNKNOWN = 76;
8
+ const EXIT_PERMISSION = 77;
9
+ export const writeSuccess = (result, { io, json, ok = true, resolved = [] }, human) => {
10
+ if (json) {
11
+ const output = {
12
+ ok,
13
+ ...(resolved.length === 0 ? {} : { resolved }),
14
+ result,
15
+ };
16
+ io.stdout(`${JSON.stringify(output)}\n`);
17
+ return;
18
+ }
19
+ io.stdout(human(result));
20
+ };
21
+ const formatUsageHint = (error, hint) => {
22
+ if (hint !== undefined)
23
+ return `Usage:\n ${hint.usage.join("\n ")}\n${hint.hint}\n`;
24
+ return error.code === "invalid_argument" ||
25
+ error.code === "command_not_implemented"
26
+ ? "Run 'maia --help' for usage.\n"
27
+ : "";
28
+ };
29
+ const writeError = (error, context) => {
30
+ const { io, json, recovery, usage: hint } = context;
31
+ if (json) {
32
+ const output = {
33
+ error,
34
+ ok: false,
35
+ ...(recovery === undefined ? {} : { recovery }),
36
+ ...hint,
37
+ };
38
+ io.stderr(`${JSON.stringify(output)}\n`);
39
+ return;
40
+ }
41
+ const usage = formatUsageHint(error, hint);
42
+ const recoveryHint = recovery === undefined
43
+ ? ""
44
+ : `Outcome unknown. Recover with:\n maia receipt show ${recovery.commandId}\n`;
45
+ io.stderr(`maia: ${error.message}\n${recoveryHint}${usage}`);
46
+ };
47
+ const TEMPORARY_ERROR_CODES = new Set([
48
+ "guard_leases_per_session_exceeded",
49
+ "guard_live_children_exceeded",
50
+ "guard_messages_per_minute_exceeded",
51
+ "held",
52
+ "saturated",
53
+ ]);
54
+ const PERMISSION_ERROR_CODES = new Set([
55
+ "authentication_failed",
56
+ "context_override_forbidden",
57
+ "role_denied",
58
+ ]);
59
+ export const reportError = (error, context) => {
60
+ writeError(error, context);
61
+ if (error.code === "invalid_argument" ||
62
+ error.code === "command_not_implemented") {
63
+ return EXIT_USAGE;
64
+ }
65
+ if (error.code === "resource_not_found" ||
66
+ error.code === "port_lease_not_found")
67
+ return EXIT_DATA_NOT_FOUND;
68
+ if (PERMISSION_ERROR_CODES.has(error.code))
69
+ return EXIT_PERMISSION;
70
+ if (error.code === "node_unavailable" ||
71
+ error.code === "node_context_unavailable") {
72
+ return EXIT_UNAVAILABLE;
73
+ }
74
+ if (error.code === "deadline_exceeded")
75
+ return EXIT_DEADLINE;
76
+ if (error.code === "outcome_unknown")
77
+ return EXIT_OUTCOME_UNKNOWN;
78
+ if (TEMPORARY_ERROR_CODES.has(error.code))
79
+ return EXIT_TEMPORARY;
80
+ if (error.retryable)
81
+ return EXIT_TEMPORARY;
82
+ return EXIT_SOFTWARE;
83
+ };
84
+ export const writeNodeResult = (result, context, { toResult, toText }) => {
85
+ if (!result.ok) {
86
+ return reportError(result.error, {
87
+ ...context,
88
+ ...(result.recovery === undefined ? {} : { recovery: result.recovery }),
89
+ });
90
+ }
91
+ writeSuccess(toResult(result.value), context, toText);
92
+ return 0;
93
+ };
94
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1,10 @@
1
+ export declare const isTerminalControl: (character: string) => boolean;
2
+ export declare const cell: (value: string) => string;
3
+ export declare const tab: (values: readonly unknown[]) => string;
4
+ export type CliTable = {
5
+ readonly empty: string;
6
+ readonly headers: readonly string[];
7
+ };
8
+ export declare const formatRows: <TValue>(items: readonly TValue[], format: (value: TValue) => string, text?: CliTable | string) => string;
9
+ export declare const withNextPage: (text: string, nextCursor?: string) => string;
10
+ //# sourceMappingURL=rows.d.ts.map
@@ -0,0 +1,32 @@
1
+ const FORMAT_CHARACTER = /^\p{Cf}$/u;
2
+ const JOINERS = new Set([8204, 8205]);
3
+ export const isTerminalControl = (character) => {
4
+ const point = character.codePointAt(0) ?? 0;
5
+ return (point <= 31 ||
6
+ (point >= 127 && point <= 159) ||
7
+ point === 8232 ||
8
+ point === 8233 ||
9
+ (FORMAT_CHARACTER.test(character) && !JOINERS.has(point)));
10
+ };
11
+ export const cell = (value) => Array.from(value, (character) => isTerminalControl(character) ? "�" : character).join("");
12
+ export const tab = (values) => values.join("\t");
13
+ const align = (rows) => {
14
+ const widths = rows.reduce((sizes, row) => row.map((value, index) => Math.max(sizes[index] ?? 0, value.length)), []);
15
+ return `${rows
16
+ .map((row) => row
17
+ .map((value, index) => index === row.length - 1 ? value : value.padEnd(widths[index] ?? 0))
18
+ .join(" ")
19
+ .trimEnd())
20
+ .join("\n")}\n`;
21
+ };
22
+ export const formatRows = (items, format, text) => {
23
+ const empty = typeof text === "object" ? text.empty : text;
24
+ if (items.length === 0)
25
+ return empty === undefined ? "" : `${empty}\n`;
26
+ const lines = items.map(format);
27
+ return typeof text === "object"
28
+ ? align([text.headers, ...lines.map((line) => line.split("\t"))])
29
+ : `${lines.join("\n")}\n`;
30
+ };
31
+ export const withNextPage = (text, nextCursor) => nextCursor === undefined ? text : `${text}next: --after ${nextCursor}\n`;
32
+ //# sourceMappingURL=rows.js.map
@@ -0,0 +1,57 @@
1
+ import * as Effect from "effect/Effect";
2
+ import type { CliNodeResult } from "../local-node/index.js";
3
+ import type { CommandContext } from "./context.js";
4
+ import { CliArgumentError } from "./input/index.js";
5
+ export type TwoPhaseMode = "confirm-stdin" | "dry-run" | "prompt" | "yes";
6
+ export declare const TWO_PHASE_FLAGS: readonly string[];
7
+ export declare const canPrompt: (context: CommandContext) => boolean;
8
+ export declare const requestedTwoPhaseMode: (flags: ReadonlySet<string>, offersYes?: boolean) => Exclude<TwoPhaseMode, "prompt"> | undefined;
9
+ export declare const promptOrRefuse: (context: CommandContext, offersYes?: boolean) => "prompt";
10
+ export declare const readTwoPhaseMode: (flags: ReadonlySet<string>, context: CommandContext, offersYes?: boolean) => TwoPhaseMode;
11
+ export declare const readPipedPreview: (context: CommandContext) => Effect.Effect<object, CliArgumentError>;
12
+ export declare const confirmParameters: <TParameters>(schema: {
13
+ readonly safeParse: (input: unknown) => {
14
+ readonly data: TParameters;
15
+ readonly success: true;
16
+ } | {
17
+ readonly success: false;
18
+ };
19
+ }, preview: object, previewOnly?: readonly string[]) => Effect.Effect<TParameters, CliArgumentError>;
20
+ export declare const confirmationOf: (preview: object, previewOnly?: readonly string[]) => Record<string, unknown>;
21
+ export declare const askToConfirm: (context: CommandContext, question: string) => Effect.Effect<boolean>;
22
+ export declare const EXIT_CANCELLED = 1;
23
+ export type TwoPhaseSpec<TPreview extends object, TConfirm, TRequirements> = {
24
+ readonly confirm: (preview: object) => Effect.Effect<CliNodeResult<TConfirm>, CliArgumentError, TRequirements>;
25
+ readonly context: CommandContext;
26
+ readonly mode: TwoPhaseMode;
27
+ readonly preview: () => Effect.Effect<CliNodeResult<TPreview>, CliArgumentError, TRequirements>;
28
+ readonly prompt?: {
29
+ readonly describe: (preview: TPreview) => string;
30
+ readonly question: string;
31
+ };
32
+ readonly writeConfirm: (result: CliNodeResult<TConfirm>) => number;
33
+ readonly writePreview: (result: CliNodeResult<TPreview>) => number;
34
+ };
35
+ export declare const runTwoPhase: <TPreview extends object, TConfirm, TRequirements>(spec: TwoPhaseSpec<TPreview, TConfirm, TRequirements>) => Effect.Effect<number, CliArgumentError, TRequirements>;
36
+ type SafeParser<TValue> = {
37
+ readonly safeParse: (input: unknown) => {
38
+ readonly data: TValue;
39
+ readonly success: true;
40
+ } | {
41
+ readonly success: false;
42
+ };
43
+ };
44
+ export type InputTwoPhaseSpec<TPreviewParameters, TPreview extends object, TConfirmParameters, TConfirm, TRequirements> = {
45
+ readonly confirm?: (parameters: TConfirmParameters) => Effect.Effect<CliNodeResult<TConfirm>, never, TRequirements>;
46
+ readonly confirmSchema: SafeParser<TConfirmParameters>;
47
+ readonly context: CommandContext;
48
+ readonly label: string;
49
+ readonly preview?: (parameters: TPreviewParameters) => Effect.Effect<CliNodeResult<TPreview>, never, TRequirements>;
50
+ readonly previewOnly?: readonly string[];
51
+ readonly previewSchema: SafeParser<TPreviewParameters>;
52
+ readonly tokens: readonly string[];
53
+ readonly write: (result: CliNodeResult<TConfirm | TPreview>) => number;
54
+ };
55
+ export declare const runInputTwoPhase: <TPreviewParameters, TPreview extends object, TConfirmParameters, TConfirm, TRequirements>(spec: InputTwoPhaseSpec<TPreviewParameters, TPreview, TConfirmParameters, TConfirm, TRequirements>) => Effect.Effect<number, CliArgumentError, TRequirements>;
56
+ export {};
57
+ //# sourceMappingURL=two-phase.d.ts.map
@@ -0,0 +1,148 @@
1
+ import * as Effect from "effect/Effect";
2
+ import { CliArgumentError, parseOptions, recoverStdin, requirePositionals, } from "./input/index.js";
3
+ import { decodeJsonText } from "./json.js";
4
+ export const TWO_PHASE_FLAGS = [
5
+ "--confirm-stdin",
6
+ "--dry-run",
7
+ ];
8
+ export const canPrompt = (context) => context.io.interactive === true &&
9
+ context.io.prompt !== undefined &&
10
+ !context.json;
11
+ export const requestedTwoPhaseMode = (flags, offersYes = false) => {
12
+ const offered = [...TWO_PHASE_FLAGS, ...(offersYes ? ["--yes"] : [])];
13
+ const chosen = offered.filter((flag) => flags.has(flag));
14
+ if (chosen.length > 1)
15
+ throw new CliArgumentError(`Use one of ${offered.map((flag) => `'${flag}'`).join(", ")}.`);
16
+ const [flag] = chosen;
17
+ if (flag === "--dry-run")
18
+ return "dry-run";
19
+ if (flag === "--confirm-stdin")
20
+ return "confirm-stdin";
21
+ return flag === "--yes" ? "yes" : undefined;
22
+ };
23
+ export const promptOrRefuse = (context, offersYes = false) => {
24
+ if (canPrompt(context))
25
+ return "prompt";
26
+ throw new CliArgumentError(`No person can confirm here: preview with '--dry-run', then pipe that preview to '--confirm-stdin'${offersYes ? ", or confirm at once with '--yes'" : ""}.`);
27
+ };
28
+ export const readTwoPhaseMode = (flags, context, offersYes = false) => requestedTwoPhaseMode(flags, offersYes) ?? promptOrRefuse(context, offersYes);
29
+ const MAX_PREVIEW_BYTES = 64 * 1024;
30
+ const invalidPreview = () => new CliArgumentError("The piped preview is invalid; pipe the output of the same command with '--json --dry-run'.");
31
+ const unwrapPreview = (value) => {
32
+ const envelope = typeof value === "object" && value !== null && "ok" in value
33
+ ? Reflect.get(value, "result")
34
+ : value;
35
+ return typeof envelope === "object" &&
36
+ envelope !== null &&
37
+ "command" in envelope &&
38
+ "result" in envelope
39
+ ? Reflect.get(envelope, "result")
40
+ : envelope;
41
+ };
42
+ export const readPipedPreview = (context) => Effect.gen(function* () {
43
+ const stdin = context.io.stdin;
44
+ if (stdin === undefined)
45
+ return yield* new CliArgumentError("Standard input is unavailable.");
46
+ const text = yield* stdin({
47
+ label: "preview",
48
+ maxBytes: MAX_PREVIEW_BYTES,
49
+ maxChunks: 256,
50
+ });
51
+ const preview = unwrapPreview(yield* decodeJsonText(text, invalidPreview));
52
+ return typeof preview === "object" && preview !== null
53
+ ? preview
54
+ : yield* invalidPreview();
55
+ });
56
+ export const confirmParameters = (schema, preview, previewOnly = []) => {
57
+ const parsed = schema.safeParse(confirmationOf(preview, previewOnly));
58
+ return parsed.success
59
+ ? Effect.succeed(parsed.data)
60
+ : Effect.fail(invalidPreview());
61
+ };
62
+ export const confirmationOf = (preview, previewOnly = []) => Object.fromEntries(Object.entries(preview).filter(([key]) => ![
63
+ "actorId",
64
+ "expiresAt",
65
+ "issuedAt",
66
+ "method",
67
+ ...previewOnly,
68
+ ].includes(key)));
69
+ export const askToConfirm = (context, question) => {
70
+ const prompt = context.io.prompt;
71
+ if (prompt === undefined)
72
+ return Effect.succeed(false);
73
+ return Effect.map(prompt(`${question} [y/N] `), (answer) => ["y", "yes"].includes((answer ?? "").toLowerCase()));
74
+ };
75
+ export const EXIT_CANCELLED = 1;
76
+ const personConfirms = (context, description, question) => Effect.gen(function* () {
77
+ context.io.stderr(description);
78
+ if (yield* askToConfirm(context, question))
79
+ return true;
80
+ context.io.stderr("Cancelled; nothing changed.\n");
81
+ return false;
82
+ });
83
+ export const runTwoPhase = (spec) => Effect.gen(function* () {
84
+ const { context, mode } = spec;
85
+ if (mode === "confirm-stdin") {
86
+ const piped = yield* readPipedPreview(context);
87
+ return spec.writeConfirm(yield* spec.confirm(piped));
88
+ }
89
+ const { confirm, prompt, writeConfirm, writePreview } = spec;
90
+ const previewed = yield* spec.preview();
91
+ if (mode === "dry-run" || !previewed.ok)
92
+ return writePreview(previewed);
93
+ if (mode === "prompt" &&
94
+ (prompt === undefined ||
95
+ !(yield* personConfirms(context, prompt.describe(previewed.value), prompt.question))))
96
+ return EXIT_CANCELLED;
97
+ return writeConfirm(yield* confirm(previewed.value));
98
+ });
99
+ const withRecovery = (result, parameters) => {
100
+ if (result.ok || result.error.code !== "outcome_unknown")
101
+ return result;
102
+ const commandId = typeof parameters === "object" && parameters !== null
103
+ ? Reflect.get(parameters, "commandId")
104
+ : undefined;
105
+ const { recovery: _claimed, ...failure } = result;
106
+ return typeof commandId === "string"
107
+ ? { ...failure, recovery: { commandId } }
108
+ : failure;
109
+ };
110
+ const unavailableOperation = (label) => new CliArgumentError(`This CLI cannot send the ${label}.`);
111
+ const previewFromStdin = (context, spec) => Effect.gen(function* () {
112
+ const invalid = () => new CliArgumentError(`The ${spec.label} is invalid.`);
113
+ const stdin = context.io.stdin;
114
+ if (stdin === undefined)
115
+ return yield* invalid();
116
+ const text = yield* recoverStdin(stdin({ label: spec.label, maxBytes: 8192, maxChunks: 32 }), invalid);
117
+ const input = spec.previewSchema.safeParse(yield* decodeJsonText(text, invalid));
118
+ if (!input.success)
119
+ return yield* invalid();
120
+ return spec.preview === undefined
121
+ ? yield* unavailableOperation(spec.label)
122
+ : yield* spec.preview(input.data);
123
+ });
124
+ const confirmPreview = (spec, previewed) => Effect.flatMap(confirmParameters(spec.confirmSchema, previewed, spec.previewOnly), (parameters) => spec.confirm === undefined
125
+ ? Effect.fail(unavailableOperation(spec.label))
126
+ : Effect.map(spec.confirm(parameters), (result) => withRecovery(result, parameters)));
127
+ const readInputMode = (tokens) => {
128
+ const parsed = parseOptions(tokens, new Set(), new Set(["--input-stdin", ...TWO_PHASE_FLAGS]));
129
+ requirePositionals(parsed.positionals, 0);
130
+ const mode = requestedTwoPhaseMode(parsed.flags);
131
+ const input = parsed.flags.has("--input-stdin");
132
+ if (mode === "confirm-stdin" && !input)
133
+ return mode;
134
+ if (mode === "dry-run" && input)
135
+ return mode;
136
+ throw new CliArgumentError(mode === "confirm-stdin"
137
+ ? "Use one of '--input-stdin' or '--confirm-stdin'."
138
+ : "Preview with '--input-stdin --dry-run', then pipe that preview to '--confirm-stdin'.");
139
+ };
140
+ export const runInputTwoPhase = (spec) => Effect.suspend(() => runTwoPhase({
141
+ confirm: (previewed) => confirmPreview(spec, previewed),
142
+ context: spec.context,
143
+ mode: readInputMode(spec.tokens),
144
+ preview: () => previewFromStdin(spec.context, spec),
145
+ writeConfirm: spec.write,
146
+ writePreview: spec.write,
147
+ }));
148
+ //# sourceMappingURL=two-phase.js.map
@@ -0,0 +1,4 @@
1
+ import { type CommandContext, type CommandEffect } from "../command-line/index.js";
2
+ export declare const runReceiptList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
3
+ export declare const runReceiptShow: (tokens: readonly string[], context: CommandContext) => CommandEffect;
4
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1,59 @@
1
+ import { DEFAULT_RECEIPT_LIST_PAGE_SIZE, } from "@maiaos/sdk";
2
+ import * as Effect from "effect/Effect";
3
+ import { CliArgumentError, parseOptions, requirePositionals, writeNodeResult, } from "../command-line/index.js";
4
+ import { formatReceiptList, projectReceiptListResult } from "./compact-list.js";
5
+ const readReceiptListPageSize = (value) => {
6
+ if (value === undefined)
7
+ return DEFAULT_RECEIPT_LIST_PAGE_SIZE;
8
+ if (!/^(?:[1-9]|[12]\d|3[0-2])$/u.test(value)) {
9
+ throw new CliArgumentError("Option '--limit' must be an integer from 1 to 32.");
10
+ }
11
+ return Number(value);
12
+ };
13
+ const optionalListFilter = (options, flag, key) => {
14
+ const value = options.get(flag);
15
+ return value === undefined ? {} : { [key]: value };
16
+ };
17
+ const readReceiptListParameters = (tokens) => {
18
+ const parsed = parseOptions(tokens, new Set([
19
+ "--actor",
20
+ "--after",
21
+ "--limit",
22
+ "--method",
23
+ "--since",
24
+ "--until",
25
+ ]));
26
+ requirePositionals(parsed.positionals, 0);
27
+ return {
28
+ limit: readReceiptListPageSize(parsed.options.get("--limit")),
29
+ ...optionalListFilter(parsed.options, "--actor", "actor"),
30
+ ...optionalListFilter(parsed.options, "--after", "afterCursor"),
31
+ ...optionalListFilter(parsed.options, "--method", "method"),
32
+ ...optionalListFilter(parsed.options, "--since", "since"),
33
+ ...optionalListFilter(parsed.options, "--until", "until"),
34
+ };
35
+ };
36
+ export const runReceiptList = (tokens, context) => Effect.gen(function* () {
37
+ const result = yield* context.dependencies.listReceipts(readReceiptListParameters(tokens));
38
+ return writeNodeResult(result, context, {
39
+ toResult: projectReceiptListResult,
40
+ toText: formatReceiptList,
41
+ });
42
+ });
43
+ export const runReceiptShow = (tokens, context) => Effect.gen(function* () {
44
+ const parsed = parseOptions(tokens, new Set());
45
+ requirePositionals(parsed.positionals, 1);
46
+ const commandId = parsed.positionals[0];
47
+ if (commandId === undefined) {
48
+ throw new CliArgumentError("The command identifier is missing.");
49
+ }
50
+ const result = yield* context.dependencies.getReceipt(commandId);
51
+ return writeNodeResult(result, context, {
52
+ toResult: (value) => ({
53
+ command: "receipt.show",
54
+ result: value,
55
+ }),
56
+ toText: ({ result: { receipt } }) => `${receipt.receiptId}\t${receipt.state}\t${receipt.target.type}:${receipt.target.id}\n`,
57
+ });
58
+ });
59
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1,20 @@
1
+ import type { ReceiptListResult } from "@maiaos/sdk";
2
+ type CliReceiptListItem = {
3
+ readonly commandId: ReceiptListResult["items"][number]["commandId"];
4
+ readonly createdAt: ReceiptListResult["items"][number]["createdAt"];
5
+ readonly method: ReceiptListResult["items"][number]["method"];
6
+ readonly receiptId: ReceiptListResult["items"][number]["receiptId"];
7
+ readonly state: ReceiptListResult["items"][number]["state"];
8
+ readonly target: ReceiptListResult["items"][number]["target"];
9
+ };
10
+ export type CliReceiptListResult = {
11
+ readonly command: "receipt.list";
12
+ readonly count: number;
13
+ readonly items: readonly CliReceiptListItem[];
14
+ readonly nextCursor?: ReceiptListResult["nextCursor"];
15
+ };
16
+ export declare const projectReceiptListItem: (item: ReceiptListResult["items"][number]) => CliReceiptListItem;
17
+ export declare const projectReceiptListResult: (value: ReceiptListResult) => CliReceiptListResult;
18
+ export declare const formatReceiptList: (result: CliReceiptListResult) => string;
19
+ export {};
20
+ //# sourceMappingURL=compact-list.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { formatRows, tab, withNextPage } from "../command-line/index.js";
2
+ export const projectReceiptListItem = (item) => ({
3
+ commandId: item.commandId,
4
+ createdAt: item.createdAt,
5
+ method: item.method,
6
+ receiptId: item.receiptId,
7
+ state: item.state,
8
+ target: {
9
+ id: item.target.id,
10
+ type: item.target.type,
11
+ },
12
+ });
13
+ export const projectReceiptListResult = (value) => ({
14
+ command: "receipt.list",
15
+ count: value.items.length,
16
+ items: value.items.map(projectReceiptListItem),
17
+ ...(value.nextCursor === undefined ? {} : { nextCursor: value.nextCursor }),
18
+ });
19
+ export const formatReceiptList = (result) => withNextPage(formatRows(result.items, (item) => tab([
20
+ item.commandId,
21
+ item.method,
22
+ item.state,
23
+ item.target.type,
24
+ item.target.id,
25
+ ]), {
26
+ empty: "No receipts.",
27
+ headers: ["COMMAND", "METHOD", "STATE", "TARGET", "TARGET ID"],
28
+ }), result.nextCursor);
29
+ //# sourceMappingURL=compact-list.js.map
@@ -0,0 +1,3 @@
1
+ export { runReceiptList, runReceiptShow } from "./command.js";
2
+ export { type CliReceiptListResult, formatReceiptList, } from "./compact-list.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { runReceiptList, runReceiptShow } from "./command.js";
2
+ export { formatReceiptList, } from "./compact-list.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,17 @@
1
+ import { type CommandContext, type CommandEffect } from "../command-line/index.js";
2
+ export declare const CLI_PROTOCOL_VERSION = "maia.protocol/v1alpha1";
3
+ export type CliVersionResult = {
4
+ readonly command: "version";
5
+ readonly commit?: string;
6
+ readonly name: "maia";
7
+ readonly protocol: string;
8
+ readonly version: string;
9
+ };
10
+ export declare const runVersion: (tokens: readonly string[], context: CommandContext) => CommandEffect;
11
+ export declare const runHelp: () => CommandEffect;
12
+ export declare const runCompletion: (tokens: readonly string[], context: CommandContext) => CommandEffect;
13
+ declare const agentArguments: (tokens: readonly string[], context: CommandContext) => CommandEffect;
14
+ export declare const runAgent: typeof agentArguments;
15
+ export declare const runAgentExtensionDigest: (tokens: readonly string[], context: CommandContext) => CommandEffect;
16
+ export {};
17
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1,41 @@
1
+ import * as Effect from "effect/Effect";
2
+ import { CliArgumentError, requireNoArguments, writeSuccess, } from "../command-line/index.js";
3
+ import { completionScript, isCompletionShell } from "./completion.js";
4
+ export const CLI_PROTOCOL_VERSION = "maia.protocol/v1alpha1";
5
+ const buildCommit = () => typeof MAIA_CLI_COMMIT === "string" && /^[0-9a-f]{40}$/u.test(MAIA_CLI_COMMIT)
6
+ ? MAIA_CLI_COMMIT
7
+ : undefined;
8
+ export const runVersion = (tokens, context) => Effect.sync(() => {
9
+ requireNoArguments(tokens, "Version");
10
+ const commit = buildCommit();
11
+ const result = {
12
+ command: "version",
13
+ ...(commit === undefined ? {} : { commit }),
14
+ name: "maia",
15
+ protocol: CLI_PROTOCOL_VERSION,
16
+ version: context.version,
17
+ };
18
+ writeSuccess(result, context, () => `${context.version}\n`);
19
+ return 0;
20
+ });
21
+ export const runHelp = () => Effect.die(new Error("Help runs before dispatch."));
22
+ export const runCompletion = (tokens, context) => Effect.sync(() => {
23
+ const [shell, ...rest] = tokens;
24
+ if (rest.length > 0 || !isCompletionShell(shell))
25
+ throw new CliArgumentError("Name one shell: bash, zsh or fish.");
26
+ if (context.json)
27
+ throw new CliArgumentError("Completion prints a shell script; omit '--json'.");
28
+ context.io.stdout(completionScript(shell));
29
+ return 0;
30
+ });
31
+ const agentArguments = (tokens, context) => {
32
+ if (context.json)
33
+ return Effect.fail(new CliArgumentError("Global '--json' is not supported by maia agent; use '--json-events' with print mode."));
34
+ const operation = context.dependencies.runAgent;
35
+ if (operation === undefined)
36
+ return Effect.fail(new CliArgumentError("The Maia agent harness is unavailable."));
37
+ return Effect.orDie(operation(tokens, context.io));
38
+ };
39
+ export const runAgent = agentArguments;
40
+ export const runAgentExtensionDigest = (tokens, context) => agentArguments(["extension", "digest", ...tokens], context);
41
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1,6 @@
1
+ declare const SHELLS: readonly ["bash", "zsh", "fish"];
2
+ export type CompletionShell = (typeof SHELLS)[number];
3
+ export declare const isCompletionShell: (value: string | undefined) => value is CompletionShell;
4
+ export declare const completionScript: (shell: CompletionShell) => string;
5
+ export {};
6
+ //# sourceMappingURL=completion.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { commandTree, treeNodes } from "./tree.js";
2
+ const SHELLS = ["bash", "zsh", "fish"];
3
+ const SHELL_NAMES = new Set(SHELLS);
4
+ export const isCompletionShell = (value) => value !== undefined && SHELL_NAMES.has(value);
5
+ const groups = () => [commandTree(), ...treeNodes()]
6
+ .filter((node) => node.children.length > 0)
7
+ .map((node) => [
8
+ node.path.join(" "),
9
+ node.children.map((child) => child.name).join(" "),
10
+ ]);
11
+ const bash = () => [
12
+ "_maia() {",
13
+ ' local path="${COMP_WORDS[*]:1:COMP_CWORD-1}" words=""',
14
+ ' case "$path" in',
15
+ ...groups().map(([path, words]) => ` "${path}") words="${words}" ;;`),
16
+ " esac",
17
+ ' COMPREPLY=($(compgen -W "$words" -- "${COMP_WORDS[COMP_CWORD]}"))',
18
+ "}",
19
+ "complete -F _maia maia",
20
+ "",
21
+ ].join("\n");
22
+ const fish = () => [
23
+ "function __maia_path",
24
+ " string join ' ' (commandline -opc)[2..-1]",
25
+ "end",
26
+ ...groups().map(([path, words]) => `complete -c maia -f -n 'test "(__maia_path)" = "${path}"' -a '${words}'`),
27
+ "",
28
+ ].join("\n");
29
+ export const completionScript = (shell) => {
30
+ if (shell === "fish")
31
+ return fish();
32
+ return shell === "zsh"
33
+ ? `autoload -U +X bashcompinit && bashcompinit\n${bash()}`
34
+ : bash();
35
+ };
36
+ //# sourceMappingURL=completion.js.map
@@ -0,0 +1,18 @@
1
+ export type TreeArgument = {
2
+ readonly choices?: readonly string[];
3
+ readonly max?: number;
4
+ readonly min?: number;
5
+ readonly name: string;
6
+ readonly oneOf?: number;
7
+ readonly repeated?: true;
8
+ readonly required?: true;
9
+ readonly type?: string;
10
+ readonly value?: string;
11
+ };
12
+ export type TreeForm = {
13
+ readonly args: readonly TreeArgument[];
14
+ readonly path: readonly string[];
15
+ };
16
+ export declare const parseUsage: (usage: string) => TreeForm;
17
+ export declare const exampleFor: (form: TreeForm) => string;
18
+ //# sourceMappingURL=grammar.d.ts.map