@maiaos/cli 0.1.0-canary.63 → 0.1.0-canary.65

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 (334) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -9
  3. package/dist/address-space/address-space.js +21 -2
  4. package/dist/address-space/index.js +1 -1
  5. package/dist/agents/client.d.ts +1 -0
  6. package/dist/agents/tree/tree.js +3 -3
  7. package/dist/bin/maia.NOTICES.txt +1 -1
  8. package/dist/bin/maia.cdx.json +70 -19
  9. package/dist/bin/maia.mjs +1 -1
  10. package/dist/board/client.d.ts +27 -0
  11. package/dist/board/client.js +40 -0
  12. package/dist/board/commands.d.ts +28 -0
  13. package/dist/board/commands.js +52 -0
  14. package/dist/board/index.d.ts +3 -0
  15. package/dist/board/index.js +3 -0
  16. package/dist/board/input.js +339 -0
  17. package/dist/board/output/format.js +175 -0
  18. package/dist/board/output/index.js +2 -0
  19. package/dist/board/plan.js +47 -0
  20. package/dist/board/tree/index.js +2 -0
  21. package/dist/board/tree/tree.js +161 -0
  22. package/dist/cli/cli.d.ts +3 -1
  23. package/dist/cli/cli.js +175 -6
  24. package/dist/cli/log-level.d.ts +11 -0
  25. package/dist/cli/log-level.js +14 -0
  26. package/dist/command-line/context.d.ts +18 -5
  27. package/dist/command-line/emit/output.d.ts +5 -1
  28. package/dist/command-line/emit/output.js +13 -5
  29. package/dist/command-line/index.d.ts +2 -2
  30. package/dist/command-line/index.js +1 -2
  31. package/dist/command-line/input/arguments.d.ts +3 -0
  32. package/dist/command-line/input/arguments.js +12 -0
  33. package/dist/command-line/input/index.d.ts +2 -2
  34. package/dist/command-line/input/index.js +2 -2
  35. package/dist/command-line/input/prompt.d.ts +1 -0
  36. package/dist/command-line/input/prompt.js +1 -0
  37. package/dist/command-line/two-phase/two-phase.d.ts +4 -4
  38. package/dist/command-line/two-phase/two-phase.js +9 -9
  39. package/dist/command-tree/commands.js +0 -4
  40. package/dist/command-tree/deprecated.d.ts +2 -0
  41. package/dist/command-tree/deprecated.js +29 -0
  42. package/dist/command-tree/grammar.js +2 -0
  43. package/dist/command-tree/help.d.ts +2 -2
  44. package/dist/command-tree/help.js +13 -15
  45. package/dist/command-tree/index.d.ts +1 -0
  46. package/dist/command-tree/index.js +1 -0
  47. package/dist/command-tree/local.js +10 -5
  48. package/dist/command-tree/placeholder.js +1 -1
  49. package/dist/command-tree/row.d.ts +1 -0
  50. package/dist/command-tree/tree.d.ts +2 -1
  51. package/dist/command-tree/tree.js +30 -4
  52. package/dist/connection/client.d.ts +36 -18
  53. package/dist/connection/client.js +1 -0
  54. package/dist/connection/executors/executors.d.ts +18 -0
  55. package/dist/connection/executors/executors.js +95 -0
  56. package/dist/connection/executors/index.d.ts +2 -0
  57. package/dist/connection/executors/index.js +2 -0
  58. package/dist/connection/executors/reading.js +22 -0
  59. package/dist/connection/index.d.ts +1 -0
  60. package/dist/connection/index.js +1 -0
  61. package/dist/connection/input.js +2 -2
  62. package/dist/connection/login.d.ts +1 -1
  63. package/dist/connection/login.js +4 -3
  64. package/dist/connection/output/format.js +2 -2
  65. package/dist/connection/output/index.d.ts +1 -1
  66. package/dist/connection/output/index.js +1 -1
  67. package/dist/connection/resolve.d.ts +1 -0
  68. package/dist/connection/setup-file.js +161 -0
  69. package/dist/connection/system.js +90 -45
  70. package/dist/connection/tree/tree.js +120 -7
  71. package/dist/container/client.d.ts +2 -0
  72. package/dist/fleet/fleet.d.ts +7 -8
  73. package/dist/fleet/fleet.js +18 -6
  74. package/dist/fleet/index.d.ts +1 -1
  75. package/dist/fleet/index.js +1 -1
  76. package/dist/github/client.d.ts +189 -0
  77. package/dist/github/client.js +16 -0
  78. package/dist/github/commands.d.ts +17 -0
  79. package/dist/github/commands.js +81 -0
  80. package/dist/github/index.d.ts +3 -0
  81. package/dist/github/index.js +3 -0
  82. package/dist/github/input.js +114 -0
  83. package/dist/github/output/format.js +78 -0
  84. package/dist/github/output/index.js +2 -0
  85. package/dist/github/tree/index.js +2 -0
  86. package/dist/github/tree/tree.js +28 -0
  87. package/dist/goal/client.d.ts +246 -0
  88. package/dist/goal/client.js +13 -0
  89. package/dist/goal/commands.d.ts +22 -0
  90. package/dist/goal/commands.js +110 -0
  91. package/dist/goal/index.d.ts +4 -0
  92. package/dist/goal/index.js +4 -0
  93. package/dist/goal/input.js +118 -0
  94. package/dist/goal/output/format.js +29 -0
  95. package/dist/goal/output/index.js +2 -0
  96. package/dist/goal/pause.d.ts +16 -0
  97. package/dist/goal/pause.js +91 -0
  98. package/dist/goal/tree/index.js +2 -0
  99. package/dist/goal/tree/tree.js +49 -0
  100. package/dist/hold/client.d.ts +2 -0
  101. package/dist/hold/tree/tree.js +2 -2
  102. package/dist/import/{batch.js → batch/batch.js} +5 -5
  103. package/dist/import/batch/index.js +3 -0
  104. package/dist/import/{manifest.js → batch/manifest.js} +7 -6
  105. package/dist/import/commands.d.ts +1 -0
  106. package/dist/import/commands.js +27 -15
  107. package/dist/import/detach.d.ts +12 -0
  108. package/dist/import/detach.js +70 -0
  109. package/dist/import/index.d.ts +2 -1
  110. package/dist/import/index.js +2 -1
  111. package/dist/import/input.js +32 -10
  112. package/dist/import/output.js +13 -8
  113. package/dist/inbox/client.d.ts +310 -0
  114. package/dist/inbox/client.js +15 -0
  115. package/dist/inbox/index.d.ts +2 -0
  116. package/dist/inbox/index.js +2 -0
  117. package/dist/integration/client.d.ts +307 -1
  118. package/dist/integration/client.js +21 -1
  119. package/dist/integration/commands.d.ts +8 -0
  120. package/dist/integration/commands.js +53 -10
  121. package/dist/integration/index.d.ts +1 -1
  122. package/dist/integration/index.js +1 -1
  123. package/dist/local-node/client.d.ts +11 -1
  124. package/dist/local-node/client.js +185 -235
  125. package/dist/local-node/index.d.ts +1 -1
  126. package/dist/local-node/index.js +1 -1
  127. package/dist/login/commands.js +7 -1
  128. package/dist/login/gateway.js +34 -11
  129. package/dist/login/menu.js +2 -1
  130. package/dist/login/vendor-account.js +3 -2
  131. package/dist/login/vendor-input.js +3 -2
  132. package/dist/mcp/calls.js +47 -226
  133. package/dist/mcp/routing.d.ts +3 -2
  134. package/dist/mcp/routing.js +37 -8
  135. package/dist/mcp/server.d.ts +10 -1
  136. package/dist/mcp/server.js +16 -6
  137. package/dist/migrate/classes.js +158 -0
  138. package/dist/migrate/commands.js +46 -0
  139. package/dist/migrate/format.js +199 -0
  140. package/dist/migrate/index.js +2 -0
  141. package/dist/migrate/item.js +59 -0
  142. package/dist/migrate/plan.js +79 -0
  143. package/dist/migrate/tree/index.js +2 -0
  144. package/dist/migrate/tree/tree.js +23 -0
  145. package/dist/node-update/client.d.ts +17 -0
  146. package/dist/node-update/client.js +27 -0
  147. package/dist/node-update/commands.d.ts +20 -0
  148. package/dist/node-update/commands.js +150 -0
  149. package/dist/node-update/index.d.ts +4 -0
  150. package/dist/node-update/index.js +4 -0
  151. package/dist/node-update/output.d.ts +12 -0
  152. package/dist/node-update/output.js +165 -0
  153. package/dist/node-update/tree/index.js +2 -0
  154. package/dist/node-update/tree/tree.js +73 -0
  155. package/dist/pairing/client.d.ts +13 -0
  156. package/dist/pairing/client.js +36 -0
  157. package/dist/pairing/commands.d.ts +15 -0
  158. package/dist/pairing/commands.js +131 -0
  159. package/dist/pairing/index.d.ts +4 -0
  160. package/dist/pairing/index.js +4 -0
  161. package/dist/pairing/output.d.ts +12 -0
  162. package/dist/pairing/output.js +53 -0
  163. package/dist/pairing/tree/index.js +2 -0
  164. package/dist/pairing/tree/tree.js +35 -0
  165. package/dist/panel/client.d.ts +9 -0
  166. package/dist/panel/client.js +24 -0
  167. package/dist/panel/commands.d.ts +19 -0
  168. package/dist/panel/commands.js +112 -0
  169. package/dist/panel/index.d.ts +3 -0
  170. package/dist/panel/index.js +3 -0
  171. package/dist/panel/tree/index.js +2 -0
  172. package/dist/panel/tree/tree.js +14 -0
  173. package/dist/port-lease/client.d.ts +3 -0
  174. package/dist/principal/client.d.ts +9 -0
  175. package/dist/principal/client.js +7 -0
  176. package/dist/principal/commands.d.ts +14 -0
  177. package/dist/principal/commands.js +84 -0
  178. package/dist/principal/index.d.ts +4 -0
  179. package/dist/principal/index.js +4 -0
  180. package/dist/principal/output.d.ts +8 -0
  181. package/dist/principal/output.js +43 -0
  182. package/dist/principal/tree/index.js +2 -0
  183. package/dist/principal/tree/tree.js +31 -0
  184. package/dist/project-guard/client.d.ts +1 -0
  185. package/dist/project-instructions/client.d.ts +56 -0
  186. package/dist/project-instructions/client.js +7 -0
  187. package/dist/project-instructions/commands.d.ts +13 -0
  188. package/dist/project-instructions/commands.js +89 -0
  189. package/dist/project-instructions/index.d.ts +3 -0
  190. package/dist/project-instructions/index.js +3 -0
  191. package/dist/project-instructions/input.js +33 -0
  192. package/dist/project-instructions/output/format.js +22 -0
  193. package/dist/project-instructions/output/index.js +2 -0
  194. package/dist/project-knowledge/change.js +22 -0
  195. package/dist/project-knowledge/client.d.ts +127 -0
  196. package/dist/project-knowledge/client.js +17 -0
  197. package/dist/project-knowledge/commands.d.ts +14 -0
  198. package/dist/project-knowledge/commands.js +100 -0
  199. package/dist/project-knowledge/index.d.ts +3 -0
  200. package/dist/project-knowledge/index.js +3 -0
  201. package/dist/project-knowledge/input.js +32 -0
  202. package/dist/project-knowledge/output/format.js +64 -0
  203. package/dist/project-knowledge/output/index.js +2 -0
  204. package/dist/project-knowledge/sources.js +108 -0
  205. package/dist/project-knowledge/upload.js +27 -0
  206. package/dist/project-workspace/git-reads.d.ts +12 -0
  207. package/dist/project-workspace/git-reads.js +71 -0
  208. package/dist/project-workspace/index.d.ts +1 -0
  209. package/dist/project-workspace/index.js +1 -0
  210. package/dist/project-workspace/metadata-client.d.ts +2 -0
  211. package/dist/project-workspace/output/human.js +1 -1
  212. package/dist/project-workspace/tree/tree.js +95 -5
  213. package/dist/reach/client.d.ts +9 -0
  214. package/dist/reach/client.js +7 -0
  215. package/dist/reach/commands.d.ts +14 -0
  216. package/dist/reach/commands.js +72 -0
  217. package/dist/reach/index.d.ts +3 -0
  218. package/dist/reach/index.js +3 -0
  219. package/dist/reach/output.js +41 -0
  220. package/dist/reach/tree/index.js +2 -0
  221. package/dist/reach/tree/tree.js +28 -0
  222. package/dist/remote-node/client.d.ts +85 -0
  223. package/dist/remote-node/commands.js +32 -17
  224. package/dist/remote-node/connector.d.ts +16 -0
  225. package/dist/remote-node/connector.js +2 -2
  226. package/dist/remote-node/reachability.js +31 -18
  227. package/dist/remote-node/reading.js +31 -0
  228. package/dist/remote-node/text.js +68 -5
  229. package/dist/remote-node/tree/tree.js +14 -3
  230. package/dist/routine/client.d.ts +547 -13
  231. package/dist/routine/client.js +19 -1
  232. package/dist/routine/commands.d.ts +5 -0
  233. package/dist/routine/commands.js +73 -15
  234. package/dist/routine/index.d.ts +2 -1
  235. package/dist/routine/index.js +2 -1
  236. package/dist/routine/input.js +66 -3
  237. package/dist/routine/output/format.js +80 -19
  238. package/dist/routine/output/index.js +1 -1
  239. package/dist/routine/portable/import-files.js +74 -0
  240. package/dist/routine/portable/import-output.js +21 -0
  241. package/dist/routine/portable/import.js +274 -0
  242. package/dist/routine/portable/index.js +3 -0
  243. package/dist/routine/portable/portable.js +185 -0
  244. package/dist/routine/tree/tree.js +80 -8
  245. package/dist/routine/trigger/commands.d.ts +20 -0
  246. package/dist/routine/trigger/commands.js +74 -0
  247. package/dist/routine/trigger/format.js +42 -0
  248. package/dist/routine/trigger/index.d.ts +2 -0
  249. package/dist/routine/trigger/index.js +2 -0
  250. package/dist/routine/trigger/input.js +81 -0
  251. package/dist/run-ledger/client.d.ts +45 -0
  252. package/dist/secret/client.d.ts +39 -0
  253. package/dist/secret/client.js +6 -0
  254. package/dist/secret/commands.d.ts +12 -0
  255. package/dist/secret/commands.js +91 -0
  256. package/dist/secret/index.d.ts +3 -0
  257. package/dist/secret/index.js +3 -0
  258. package/dist/secret/input.js +22 -0
  259. package/dist/secret/output/format.js +10 -0
  260. package/dist/secret/output/index.js +2 -0
  261. package/dist/secret/tree/index.js +2 -0
  262. package/dist/secret/tree/tree.js +16 -0
  263. package/dist/session/agent-permission.d.ts +3 -2
  264. package/dist/session/approval/client.d.ts +4 -3
  265. package/dist/session/approval/commands.d.ts +7 -0
  266. package/dist/session/approval/commands.js +176 -6
  267. package/dist/session/approval/index.d.ts +1 -1
  268. package/dist/session/approval/index.js +1 -1
  269. package/dist/session/approval/output/format.js +53 -1
  270. package/dist/session/approval/output/index.js +1 -1
  271. package/dist/session/attach.d.ts +1 -1
  272. package/dist/session/attach.js +7 -2
  273. package/dist/session/client.d.ts +12 -12
  274. package/dist/session/client.js +8 -17
  275. package/dist/session/command/commands.js +109 -0
  276. package/dist/session/command/index.js +2 -0
  277. package/dist/session/commands.d.ts +5 -1
  278. package/dist/session/commands.js +260 -55
  279. package/dist/session/create-tasks.js +3 -48
  280. package/dist/session/creation/creation.js +51 -0
  281. package/dist/session/creation/index.js +2 -0
  282. package/dist/session/fork/fork.js +135 -0
  283. package/dist/session/fork/index.js +2 -0
  284. package/dist/session/git-status.d.ts +11 -0
  285. package/dist/session/git-status.js +30 -0
  286. package/dist/session/index.d.ts +4 -3
  287. package/dist/session/index.js +3 -2
  288. package/dist/session/interaction/client.d.ts +3 -0
  289. package/dist/session/move/index.js +2 -0
  290. package/dist/session/move/move.js +439 -0
  291. package/dist/session/output/held.js +28 -0
  292. package/dist/session/output/human.js +34 -7
  293. package/dist/session/output/tasks.js +23 -6
  294. package/dist/session/setup/index.js +2 -0
  295. package/dist/session/setup/setup.js +69 -0
  296. package/dist/session/spawn/caps.js +128 -0
  297. package/dist/session/spawn/index.js +5 -0
  298. package/dist/session/spawn/spawn.js +203 -0
  299. package/dist/session/spawn/standing.js +62 -0
  300. package/dist/session/spawn/supervision.js +62 -0
  301. package/dist/session/switch/index.js +2 -0
  302. package/dist/session/switch/switch.js +103 -0
  303. package/dist/session/tree/tree.js +280 -18
  304. package/dist/session/turn/attachments.js +54 -0
  305. package/dist/session/turn/client.d.ts +3 -1
  306. package/dist/session/turn/client.js +6 -1
  307. package/dist/session/turn/commands.d.ts +5 -1
  308. package/dist/session/turn/commands.js +148 -27
  309. package/dist/session/turn/index.d.ts +2 -2
  310. package/dist/session/turn/index.js +1 -1
  311. package/dist/session/turn/output.d.ts +25 -1
  312. package/dist/session/turn/output.js +33 -0
  313. package/dist/skills-sync/client.d.ts +9 -0
  314. package/dist/skills-sync/client.js +7 -0
  315. package/dist/skills-sync/commands.d.ts +15 -0
  316. package/dist/skills-sync/commands.js +241 -0
  317. package/dist/skills-sync/index.d.ts +3 -0
  318. package/dist/skills-sync/index.js +3 -0
  319. package/dist/skills-sync/output.js +168 -0
  320. package/dist/skills-sync/set-file.js +23 -0
  321. package/dist/skills-sync/tree/index.js +2 -0
  322. package/dist/skills-sync/tree/tree.js +38 -0
  323. package/dist/status/client.d.ts +7 -0
  324. package/dist/status/command.js +3 -2
  325. package/dist/status/doctor.js +4 -3
  326. package/dist/team-workspace/client.d.ts +1 -0
  327. package/dist/text-input/index.js +2 -0
  328. package/dist/text-input/text-input.js +35 -0
  329. package/dist/webhooks/client.d.ts +10 -9
  330. package/dist/webhooks/input.js +2 -2
  331. package/dist/webhooks/tree/tree.js +4 -4
  332. package/guidance/maia-sessions/SKILL.md +37 -3
  333. package/package.json +6 -5
  334. package/dist/command-line/context.js +0 -2
@@ -0,0 +1,112 @@
1
+ import { normalizePanelOrigin } from "@maiaos/agent/config";
2
+ import { NODE_API_PANEL_PATH, pairingConfirmParametersSchema, } from "@maiaos/sdk";
3
+ import * as Effect from "effect/Effect";
4
+ import { fields, writeNodeResult, } from "../command-line/emit/index.js";
5
+ import { CliArgumentError, parseOptionsWith, requirePositionals, } from "../command-line/input/index.js";
6
+ import { confirmParameters, readTwoPhaseMode, runTwoPhase, TWO_PHASE_FLAGS, } from "../command-line/two-phase/index.js";
7
+ import { commandIdentifier } from "../local-node/index.js";
8
+ import { formatPairingResult, } from "../pairing/index.js";
9
+ const OPEN_OPTIONS = {
10
+ allowed: new Set(["--command-id", "--origin"]),
11
+ allowedFlags: new Set(TWO_PHASE_FLAGS),
12
+ repeatable: new Set(),
13
+ };
14
+ const NO_CODE = "This pairing's code was shown once already; run 'maia panel open' again for a new one.";
15
+ const BAD_ORIGIN = "--origin takes one https origin, as https://host:port.";
16
+ const readOrigin = (value) => {
17
+ const origin = value === undefined ? undefined : normalizePanelOrigin(value);
18
+ return value !== undefined && origin === undefined
19
+ ? Effect.fail(new CliArgumentError(BAD_ORIGIN))
20
+ : Effect.succeed(origin);
21
+ };
22
+ const operatorPairing = (preview) => Effect.flatMap(confirmParameters(pairingConfirmParametersSchema, preview), (parameters) => parameters.change.kind === "create" &&
23
+ parameters.change.role === "operator"
24
+ ? Effect.succeed(parameters)
25
+ : Effect.fail(new CliArgumentError("The piped preview does not pair an operator; confirm it with 'maia node pair --confirm-stdin'.")));
26
+ const pageOf = (confirmed, address) => confirmed.code === undefined
27
+ ? {
28
+ error: { code: "conflict", message: NO_CODE, retryable: false },
29
+ ok: false,
30
+ }
31
+ : { ok: true, value: `${address}#code=${confirmed.code}` };
32
+ const panelAddress = (needs, origin) => origin === undefined
33
+ ? needs.panelAddress()
34
+ : Effect.succeed({ ok: true, value: `${origin}${NODE_API_PANEL_PATH}` });
35
+ const confirmAndOpen = (needs, json, origin) => (preview) => Effect.gen(function* () {
36
+ const parameters = yield* operatorPairing(preview);
37
+ const address = yield* panelAddress(needs, origin);
38
+ if (!address.ok)
39
+ return address;
40
+ const confirmed = yield* needs.confirmPairing(parameters);
41
+ if (!confirmed.ok)
42
+ return confirmed;
43
+ const page = pageOf(confirmed.value, address.value);
44
+ if (!page.ok)
45
+ return page;
46
+ const local = !json && origin === undefined;
47
+ const opened = local && (yield* needs.openBrowser(address.value));
48
+ const { expiresAt, pairingId } = confirmed.value;
49
+ return {
50
+ ok: true,
51
+ value: {
52
+ ...(expiresAt === undefined ? {} : { expiresAt }),
53
+ opened,
54
+ pairingId,
55
+ url: page.value,
56
+ },
57
+ };
58
+ });
59
+ const openedText = ({ expiresAt, opened, pairingId, url }) => fields([
60
+ ["Panel", opened ? "opened in your browser" : "not opened"],
61
+ ["Sign in", url],
62
+ ["Pairing", pairingId],
63
+ ["Expires", expiresAt],
64
+ ]);
65
+ const requireNeeds = (dependencies) => {
66
+ const { confirmPairing, openBrowser, panelAddress, previewPairing } = dependencies;
67
+ return confirmPairing === undefined ||
68
+ openBrowser === undefined ||
69
+ panelAddress === undefined ||
70
+ previewPairing === undefined
71
+ ? Effect.fail(new CliArgumentError("The panel is unavailable: the CLI has no Node client."))
72
+ : Effect.succeed({
73
+ confirmPairing,
74
+ openBrowser,
75
+ panelAddress,
76
+ previewPairing,
77
+ });
78
+ };
79
+ const previewOperator = (needs, commandId) => Effect.flatMap(commandIdentifier(commandId), (identifier) => needs.previewPairing({
80
+ change: { kind: "create", role: "operator" },
81
+ commandId: identifier,
82
+ }));
83
+ const describePreview = (preview) => formatPairingResult({ command: preview.method, result: preview });
84
+ const openPrompt = (origin) => ({
85
+ describe: describePreview,
86
+ question: origin === undefined
87
+ ? "Pair the panel as an operator and open it in your browser?"
88
+ : `Pair the panel as an operator for ${origin}?`,
89
+ });
90
+ export const runPanelOpen = (tokens, context) => Effect.gen(function* () {
91
+ const parsed = parseOptionsWith(tokens, OPEN_OPTIONS);
92
+ requirePositionals(parsed.positionals, 0);
93
+ const mode = readTwoPhaseMode(parsed.flags, context);
94
+ const origin = yield* readOrigin(parsed.options.get("--origin"));
95
+ const needs = yield* requireNeeds(context.dependencies);
96
+ return yield* runTwoPhase({
97
+ confirm: confirmAndOpen(needs, context.json, origin),
98
+ context,
99
+ mode,
100
+ preview: () => previewOperator(needs, parsed.options.get("--command-id")),
101
+ prompt: openPrompt(origin),
102
+ writeConfirm: (result) => writeNodeResult(result, context, {
103
+ toResult: (value) => ({ command: "panel.open", result: value }),
104
+ toText: ({ result: value }) => openedText(value),
105
+ }),
106
+ writePreview: (result) => writeNodeResult(result, context, {
107
+ toResult: (value) => ({ command: value.method, result: value }),
108
+ toText: ({ result: value }) => describePreview(value),
109
+ }),
110
+ });
111
+ });
112
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1,3 @@
1
+ export { makePanelClient, type PanelCliDependencies } from "./client.js";
2
+ export { type PanelOpened, runPanelOpen } from "./commands.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { makePanelClient } from "./client.js";
2
+ export { runPanelOpen } from "./commands.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export { PANEL_TREE } from "./tree.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,14 @@
1
+ const panel = () => import("../index.js");
2
+ export const PANEL_TREE = {
3
+ groups: [["panel", "Open this Node's local web panel."]],
4
+ leaves: [
5
+ [
6
+ "panel open ([--command-id <id>] [--origin <url>] [--dry-run | --yes] | --confirm-stdin)",
7
+ 1,
8
+ ["node.pairing.preview", "node.pairing.confirm"],
9
+ "Pair the panel as an operator; open it, or print its --origin link.",
10
+ { kind: "two-phase", remote: false, run: [panel, "runPanelOpen"] },
11
+ ],
12
+ ],
13
+ };
14
+ //# sourceMappingURL=tree.js.map
@@ -30,6 +30,7 @@ export declare const makePortLeaseClient: (node: CliNodeOperations) => {
30
30
  readonly createdAt: string;
31
31
  readonly eventCursor: string;
32
32
  readonly method: string;
33
+ readonly proposedBy?: string | undefined;
33
34
  readonly receiptId: string;
34
35
  readonly schemaVersion: 1;
35
36
  readonly state: "succeeded";
@@ -70,6 +71,7 @@ export declare const makePortLeaseClient: (node: CliNodeOperations) => {
70
71
  readonly createdAt: string;
71
72
  readonly eventCursor: string;
72
73
  readonly method: string;
74
+ readonly proposedBy?: string | undefined;
73
75
  readonly receiptId: string;
74
76
  readonly schemaVersion: 1;
75
77
  readonly state: "succeeded";
@@ -110,6 +112,7 @@ export declare const makePortLeaseClient: (node: CliNodeOperations) => {
110
112
  readonly createdAt: string;
111
113
  readonly eventCursor: string;
112
114
  readonly method: string;
115
+ readonly proposedBy?: string | undefined;
113
116
  readonly receiptId: string;
114
117
  readonly schemaVersion: 1;
115
118
  readonly state: "succeeded";
@@ -0,0 +1,9 @@
1
+ import { type PrincipalConfirmParameters, type PrincipalConfirmResult, type PrincipalPreviewParameters, type PrincipalPreviewResult, type PrincipalShowResult } from "@maiaos/sdk";
2
+ import type { CliNodeEffect, CliNodeOperations } from "../local-node/index.js";
3
+ export declare const makePrincipalClient: (node: CliNodeOperations) => {
4
+ confirmPrincipal: (input: PrincipalConfirmParameters) => CliNodeEffect<PrincipalConfirmResult>;
5
+ previewPrincipal: (input: PrincipalPreviewParameters) => CliNodeEffect<PrincipalPreviewResult>;
6
+ showPrincipals: () => CliNodeEffect<PrincipalShowResult>;
7
+ };
8
+ export type PrincipalCliDependencies = ReturnType<typeof makePrincipalClient>;
9
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { principalConfirmParametersSchema, principalPreviewParametersSchema, } from "@maiaos/sdk";
2
+ export const makePrincipalClient = (node) => ({
3
+ confirmPrincipal: (input) => node.runValidatedNodeOperation(input, principalConfirmParametersSchema, (client, parameters, options) => client.confirmPrincipal(parameters, options), { commandId: input.commandId }),
4
+ previewPrincipal: (input) => node.runValidatedNodeOperation(input, principalPreviewParametersSchema, (client, parameters, options) => client.previewPrincipal(parameters, options)),
5
+ showPrincipals: () => node.runNodeClientOperation((client, options) => client.showPrincipals(options)),
6
+ });
7
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,14 @@
1
+ import type * as Crypto from "effect/Crypto";
2
+ import * as Effect from "effect/Effect";
3
+ import { type OutputContext } from "../command-line/emit/index.js";
4
+ import { CliArgumentError } from "../command-line/input/index.js";
5
+ import type { PrincipalCliDependencies } from "./client.js";
6
+ type CommandContext = OutputContext & {
7
+ readonly dependencies: PrincipalCliDependencies;
8
+ };
9
+ type CommandEffect = Effect.Effect<number, CliArgumentError, Crypto.Crypto>;
10
+ export declare const runPrincipalList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
11
+ export declare const runPrincipalAdd: (tokens: readonly string[], context: CommandContext) => CommandEffect;
12
+ export declare const runPrincipalRevoke: (tokens: readonly string[], context: CommandContext) => CommandEffect;
13
+ export {};
14
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1,84 @@
1
+ import { principalConfirmParametersSchema, } from "@maiaos/sdk";
2
+ import * as Effect from "effect/Effect";
3
+ import { writeNodeResult, } from "../command-line/emit/index.js";
4
+ import { CliArgumentError, parseOptions, parseOptionsWith, requirePositionals, } from "../command-line/input/index.js";
5
+ import { confirmParameters, readTwoPhaseMode, runTwoPhase, TWO_PHASE_FLAGS, } from "../command-line/two-phase/index.js";
6
+ import { commandIdentifier } from "../local-node/index.js";
7
+ import { formatPrincipalResult, } from "./output.js";
8
+ const write = (context) => (result) => writeNodeResult(result, context, {
9
+ toResult: (value) => ({
10
+ command: value.method,
11
+ result: value,
12
+ }),
13
+ toText: formatPrincipalResult,
14
+ });
15
+ const missingClient = () => new CliArgumentError("Principals are unavailable: the CLI has no Node client.");
16
+ export const runPrincipalList = (tokens, context) => Effect.gen(function* () {
17
+ requirePositionals(parseOptions(tokens, new Set()).positionals, 0);
18
+ const { showPrincipals } = context.dependencies;
19
+ if (showPrincipals === undefined)
20
+ return yield* missingClient();
21
+ return write(context)(yield* showPrincipals());
22
+ });
23
+ const ADD_OPTIONS = {
24
+ allowed: new Set(["--command-id", "--role"]),
25
+ allowedFlags: new Set(TWO_PHASE_FLAGS),
26
+ repeatable: new Set(),
27
+ };
28
+ const REVOKE_OPTIONS = {
29
+ allowed: new Set(["--command-id"]),
30
+ allowedFlags: new Set(TWO_PHASE_FLAGS),
31
+ repeatable: new Set(),
32
+ };
33
+ const ROLES = ["operator", "reader"];
34
+ const readRole = (value) => {
35
+ const role = ROLES.find((candidate) => candidate === value);
36
+ if (role === undefined)
37
+ throw new CliArgumentError("A bot takes --role operator or --role reader.");
38
+ return role;
39
+ };
40
+ const readChange = (parsed, kind) => {
41
+ requirePositionals(parsed.positionals, 1);
42
+ const [subject = ""] = parsed.positionals;
43
+ return kind === "create"
44
+ ? { kind, name: subject, role: readRole(parsed.options.get("--role")) }
45
+ : { kind, principalId: subject };
46
+ };
47
+ const requirePipedPreviewAlone = (parsed) => {
48
+ requirePositionals(parsed.positionals, 0);
49
+ if (parsed.options.has("--role"))
50
+ throw new CliArgumentError("The piped preview carries the role: drop '--role'.");
51
+ };
52
+ const confirmOwnChange = (kind, confirmPrincipal) => (preview) => Effect.flatMap(confirmParameters(principalConfirmParametersSchema, preview), (parameters) => parameters.change.kind === kind
53
+ ? confirmPrincipal(parameters)
54
+ : Effect.fail(new CliArgumentError(`The piped preview is ${kind === "create" ? "a revocation" : "a new bot"}; confirm it with 'maia principal ${kind === "create" ? "revoke" : "add bot"} --confirm-stdin'.`)));
55
+ const previewChange = (parsed, kind, previewPrincipal) => Effect.flatMap(commandIdentifier(parsed.options.get("--command-id")), (commandId) => previewPrincipal({ change: readChange(parsed, kind), commandId }));
56
+ const promptFor = (kind) => ({
57
+ describe: (preview) => formatPrincipalResult({ command: preview.method, result: preview }),
58
+ question: kind === "create"
59
+ ? "Add this bot, and show its token here once?"
60
+ : "Revoke this principal, so its token stops working?",
61
+ });
62
+ const runChange = (tokens, context, kind) => Effect.gen(function* () {
63
+ const parsed = parseOptionsWith(tokens, kind === "create" ? ADD_OPTIONS : REVOKE_OPTIONS);
64
+ const mode = readTwoPhaseMode(parsed.flags, context);
65
+ if (mode === "confirm-stdin")
66
+ requirePipedPreviewAlone(parsed);
67
+ else
68
+ readChange(parsed, kind);
69
+ const { confirmPrincipal, previewPrincipal } = context.dependencies;
70
+ if (confirmPrincipal === undefined || previewPrincipal === undefined)
71
+ return yield* missingClient();
72
+ return yield* runTwoPhase({
73
+ confirm: confirmOwnChange(kind, confirmPrincipal),
74
+ context,
75
+ mode,
76
+ preview: () => previewChange(parsed, kind, previewPrincipal),
77
+ prompt: promptFor(kind),
78
+ writeConfirm: write(context),
79
+ writePreview: write(context),
80
+ });
81
+ });
82
+ export const runPrincipalAdd = (tokens, context) => runChange(tokens, context, "create");
83
+ export const runPrincipalRevoke = (tokens, context) => runChange(tokens, context, "revoke");
84
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1,4 @@
1
+ export { makePrincipalClient, type PrincipalCliDependencies, } from "./client.js";
2
+ export { runPrincipalAdd, runPrincipalList, runPrincipalRevoke, } from "./commands.js";
3
+ export { formatPrincipalResult } from "./output.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ export { makePrincipalClient, } from "./client.js";
2
+ export { runPrincipalAdd, runPrincipalList, runPrincipalRevoke, } from "./commands.js";
3
+ export { formatPrincipalResult } from "./output.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ import type { PrincipalConfirmResult, PrincipalPreviewResult, PrincipalShowResult } from "@maiaos/sdk";
2
+ export type PrincipalResult = PrincipalConfirmResult | PrincipalPreviewResult | PrincipalShowResult;
3
+ export type CliPrincipalResult = {
4
+ readonly command: PrincipalResult["method"];
5
+ readonly result: PrincipalResult;
6
+ };
7
+ export declare const formatPrincipalResult: ({ result, }: CliPrincipalResult) => string;
8
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1,43 @@
1
+ import { fields, formatRows, tab } from "../command-line/emit/index.js";
2
+ const changeText = (change) => change.kind === "create"
3
+ ? `add the bot ${change.name} with the role ${change.role}`
4
+ : `revoke principal ${change.principalId}`;
5
+ const previewText = (preview) => {
6
+ const { change, commandId, revision, validUntil } = preview;
7
+ return fields([
8
+ ["Change", changeText(change)],
9
+ ["Command", commandId],
10
+ ["Revision", revision],
11
+ ["Valid until", validUntil],
12
+ ]);
13
+ };
14
+ const confirmText = (confirmed) => fields([
15
+ ["Principal", confirmed.principalId],
16
+ ["Name", confirmed.name],
17
+ ["Role", confirmed.role],
18
+ ["State", confirmed.state],
19
+ ["Token", confirmed.token],
20
+ [
21
+ "Note",
22
+ confirmed.token === undefined
23
+ ? undefined
24
+ : "Shown once. The Node keeps a digest, so a lost token needs a new bot.",
25
+ ],
26
+ ["Receipt", confirmed.receiptId],
27
+ ["Revision", confirmed.revision],
28
+ ]);
29
+ const showText = ({ principals }) => formatRows(principals, ({ createdAt, name, principalId, role, state }) => tab([principalId, name, role, state, createdAt]), {
30
+ empty: "No principals.",
31
+ headers: ["PRINCIPAL", "NAME", "ROLE", "STATE", "CREATED"],
32
+ });
33
+ export const formatPrincipalResult = ({ result, }) => {
34
+ switch (result.method) {
35
+ case "node.principal.show":
36
+ return showText(result);
37
+ case "node.principal.preview":
38
+ return previewText(result);
39
+ case "node.principal.confirm":
40
+ return confirmText(result);
41
+ }
42
+ };
43
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1,2 @@
1
+ export { PRINCIPAL_TREE } from "./tree.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,31 @@
1
+ const principal = () => import("../index.js");
2
+ export const PRINCIPAL_TREE = {
3
+ groups: [
4
+ ["principal", "Manage the bot principals of a Node."],
5
+ ["principal add", "Add a principal to a Node."],
6
+ ],
7
+ leaves: [
8
+ [
9
+ "principal add bot (<name> --role <operator|reader> [--command-id <id>] [--dry-run | --yes] | --confirm-stdin)",
10
+ 1,
11
+ ["node.principal.preview", "node.principal.confirm"],
12
+ "Add a bot with one role and show its token once, after a preview.",
13
+ { kind: "two-phase", run: [principal, "runPrincipalAdd"] },
14
+ ],
15
+ [
16
+ "principal list",
17
+ 1,
18
+ "node.principal.show",
19
+ "List the principals, never a token.",
20
+ { run: [principal, "runPrincipalList"] },
21
+ ],
22
+ [
23
+ "principal revoke (<principal-id> [--command-id <id>] [--dry-run | --yes] | --confirm-stdin)",
24
+ 1,
25
+ ["node.principal.preview", "node.principal.confirm"],
26
+ "Revoke one principal by its ID after a preview.",
27
+ { kind: "two-phase", run: [principal, "runPrincipalRevoke"] },
28
+ ],
29
+ ],
30
+ };
31
+ //# sourceMappingURL=tree.js.map
@@ -30,6 +30,7 @@ export declare const makeProjectGuardClient: (node: CliNodeOperations) => {
30
30
  readonly createdAt: string;
31
31
  readonly eventCursor: string;
32
32
  readonly method: string;
33
+ readonly proposedBy?: string | undefined;
33
34
  readonly receiptId: string;
34
35
  readonly schemaVersion: 1;
35
36
  readonly state: "succeeded";
@@ -0,0 +1,56 @@
1
+ import { type ProjectInstructionsChangeConfirmParameters, type ProjectInstructionsChangePreviewParameters, type ProjectInstructionsShowParameters } from "@maiaos/sdk";
2
+ import type { CliNodeOperations } from "../local-node/index.js";
3
+ export declare const makeProjectInstructionsClient: (node: CliNodeOperations) => {
4
+ confirmProjectInstructionsChange: (input: ProjectInstructionsChangeConfirmParameters) => import("../local-node/client.js").CliNodeEffect<{
5
+ readonly actorId: string;
6
+ readonly commandId: string;
7
+ readonly delivery: "duplicate" | "new";
8
+ readonly digest: string;
9
+ readonly expectedRevision: string;
10
+ readonly inputDigest: string;
11
+ readonly method: "project.instructions.change.confirm";
12
+ readonly projectId: string;
13
+ readonly receipt: {
14
+ readonly actorId: string;
15
+ readonly aggregateRevision: string;
16
+ readonly commandId: string;
17
+ readonly createdAt: string;
18
+ readonly eventCursor: string;
19
+ readonly method: string;
20
+ readonly proposedBy?: string | undefined;
21
+ readonly receiptId: string;
22
+ readonly schemaVersion: 1;
23
+ readonly state: "succeeded";
24
+ readonly target: {
25
+ readonly id: string;
26
+ readonly type: string;
27
+ };
28
+ readonly updatedAt: string;
29
+ };
30
+ readonly revision: string;
31
+ }>;
32
+ previewProjectInstructionsChange: (input: ProjectInstructionsChangePreviewParameters) => import("../local-node/client.js").CliNodeEffect<{
33
+ readonly commandId: string;
34
+ readonly expectedRevision: string;
35
+ readonly projectId: string;
36
+ readonly text: string;
37
+ readonly inputDigest: string;
38
+ readonly proof: string;
39
+ readonly validUntil: string;
40
+ readonly actorId: string;
41
+ readonly method: "project.instructions.change.preview";
42
+ }>;
43
+ showProjectInstructions: (input: ProjectInstructionsShowParameters) => import("../local-node/client.js").CliNodeEffect<{
44
+ readonly instructions: {
45
+ readonly digest: string;
46
+ readonly projectId: string;
47
+ readonly revision: string;
48
+ readonly text: string;
49
+ readonly updatedAt: string;
50
+ } | null;
51
+ readonly method: "project.instructions.show";
52
+ readonly projectId: string;
53
+ }>;
54
+ };
55
+ export type ProjectInstructionsCliDependencies = ReturnType<typeof makeProjectInstructionsClient>;
56
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { projectInstructionsChangeConfirmParametersSchema, projectInstructionsChangePreviewParametersSchema, projectInstructionsShowParametersSchema, } from "@maiaos/sdk";
2
+ export const makeProjectInstructionsClient = (node) => ({
3
+ confirmProjectInstructionsChange: (input) => node.runValidatedNodeOperation(input, projectInstructionsChangeConfirmParametersSchema, (client, parameters, options) => client.confirmProjectInstructionsChange(parameters, options), { commandId: input.commandId }),
4
+ previewProjectInstructionsChange: (input) => node.runValidatedNodeOperation(input, projectInstructionsChangePreviewParametersSchema, (client, parameters, options) => client.previewProjectInstructionsChange(parameters, options)),
5
+ showProjectInstructions: (input) => node.runValidatedNodeOperation(input, projectInstructionsShowParametersSchema, (client, parameters, options) => client.showProjectInstructions(parameters, options)),
6
+ });
7
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,13 @@
1
+ import type * as Crypto from "effect/Crypto";
2
+ import * as Effect from "effect/Effect";
3
+ import { type OutputContext } from "../command-line/emit/index.js";
4
+ import { CliArgumentError } from "../command-line/input/index.js";
5
+ import type { ProjectInstructionsCliDependencies } from "./client.js";
6
+ type CommandContext = OutputContext & {
7
+ readonly dependencies: ProjectInstructionsCliDependencies;
8
+ };
9
+ type CommandEffect = Effect.Effect<number, CliArgumentError, Crypto.Crypto>;
10
+ export declare const runProjectInstructionsShow: (tokens: readonly string[], context: CommandContext) => CommandEffect;
11
+ export declare const runProjectInstructionsSet: (tokens: readonly string[], context: CommandContext) => CommandEffect;
12
+ export {};
13
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1,89 @@
1
+ import { projectInstructionsChangeConfirmParametersSchema, } from "@maiaos/sdk";
2
+ import * as Effect from "effect/Effect";
3
+ import { writeNodeResult, } from "../command-line/emit/index.js";
4
+ import { CliArgumentError, parseOptions, requirePositionals, } from "../command-line/input/index.js";
5
+ import { confirmParameters, readPipedPreview, readTwoPhaseMode, runTwoPhase, TWO_PHASE_FLAGS, } from "../command-line/two-phase/index.js";
6
+ import { commandIdentifier, } from "../local-node/index.js";
7
+ import { readTextInput } from "../text-input/index.js";
8
+ import { readInstructionsSet, readInstructionsShow, SET_OPTIONS, } from "./input.js";
9
+ import { formatProjectInstructionsResult, } from "./output/index.js";
10
+ const withStaleHint = (result, projectId) => !result.ok && result.error.code === "storage_conflict"
11
+ ? {
12
+ ...result,
13
+ error: {
14
+ ...result.error,
15
+ message: `${result.error.message} Run 'maia project instructions show --project ${projectId}' for the current revision, then retry.`,
16
+ },
17
+ }
18
+ : result;
19
+ const write = (context, projectId) => (result) => writeNodeResult(withStaleHint(result, projectId), context, {
20
+ toResult: (value) => ({ command: value.method, result: value }),
21
+ toText: formatProjectInstructionsResult,
22
+ });
23
+ const unavailable = () => Effect.die(new Error("Missing Project instructions client."));
24
+ export const runProjectInstructionsShow = (tokens, context) => Effect.gen(function* () {
25
+ const show = context.dependencies.showProjectInstructions;
26
+ if (show === undefined)
27
+ return yield* unavailable();
28
+ const input = readInstructionsShow(tokens);
29
+ return write(context, input.projectId)(yield* show(input));
30
+ });
31
+ const revisionToReplace = (show, projectId, named) => named === undefined
32
+ ? Effect.map(show({ projectId }), (shown) => shown.ok
33
+ ? { ok: true, value: shown.value.instructions?.revision ?? "0" }
34
+ : shown)
35
+ : Effect.succeed({ ok: true, value: named });
36
+ const previewChange = (context, input, node) => Effect.gen(function* () {
37
+ const text = yield* readTextInput(input.file, context.io, "instructions");
38
+ const expected = yield* revisionToReplace(node.show, input.projectId, input.revision);
39
+ if (!expected.ok)
40
+ return expected;
41
+ const commandId = yield* commandIdentifier(input.commandId);
42
+ return yield* node.preview({
43
+ commandId,
44
+ expectedRevision: expected.value,
45
+ projectId: input.projectId,
46
+ text,
47
+ });
48
+ });
49
+ const confirmInstructionsParameters = (preview) => confirmParameters(projectInstructionsChangeConfirmParametersSchema, preview);
50
+ const PROMPT = {
51
+ describe: (preview) => formatProjectInstructionsResult({
52
+ command: preview.method,
53
+ result: preview,
54
+ }),
55
+ question: "Set these instructions?",
56
+ };
57
+ const confirmPiped = (context) => Effect.flatMap(Effect.flatMap(readPipedPreview(context), confirmInstructionsParameters), (confirmation) => {
58
+ const confirm = context.dependencies.confirmProjectInstructionsChange;
59
+ if (confirm === undefined)
60
+ return unavailable();
61
+ return Effect.map(confirm(confirmation), write(context, confirmation.projectId));
62
+ });
63
+ const confirmFromStdin = (parsed, context) => Effect.gen(function* () {
64
+ requirePositionals(parsed.positionals, 0);
65
+ if (parsed.options.size > 0)
66
+ return yield* new CliArgumentError("'--confirm-stdin' takes the text, revision and command from the piped preview, and no other option.");
67
+ return yield* confirmPiped(context);
68
+ });
69
+ export const runProjectInstructionsSet = (tokens, context) => Effect.gen(function* () {
70
+ const parsed = parseOptions(tokens, SET_OPTIONS, new Set(TWO_PHASE_FLAGS));
71
+ const mode = readTwoPhaseMode(parsed.flags, context);
72
+ if (mode === "confirm-stdin")
73
+ return yield* confirmFromStdin(parsed, context);
74
+ const { confirmProjectInstructionsChange: confirm, previewProjectInstructionsChange: preview, showProjectInstructions: show, } = context.dependencies;
75
+ if (confirm === undefined || preview === undefined || show === undefined)
76
+ return yield* unavailable();
77
+ const input = readInstructionsSet(parsed);
78
+ const writeResult = write(context, input.projectId);
79
+ return yield* runTwoPhase({
80
+ confirm: (previewed) => Effect.flatMap(confirmInstructionsParameters(previewed), confirm),
81
+ context,
82
+ mode,
83
+ preview: () => previewChange(context, input, { preview, show }),
84
+ prompt: PROMPT,
85
+ writeConfirm: writeResult,
86
+ writePreview: writeResult,
87
+ });
88
+ });
89
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1,3 @@
1
+ export { makeProjectInstructionsClient, type ProjectInstructionsCliDependencies, } from "./client.js";
2
+ export { runProjectInstructionsSet, runProjectInstructionsShow, } from "./commands.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { makeProjectInstructionsClient, } from "./client.js";
2
+ export { runProjectInstructionsSet, runProjectInstructionsShow, } from "./commands.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,33 @@
1
+ import { CliArgumentError, parseOptions, readExpectedRevision, requirePositionals, } from "../command-line/input/index.js";
2
+ const PROJECT = "--project";
3
+ export const SET_OPTIONS = new Set([
4
+ "--command-id",
5
+ "--expected-revision",
6
+ "--file",
7
+ PROJECT,
8
+ ]);
9
+ const projectOf = (options) => {
10
+ const projectId = options.get(PROJECT);
11
+ if (projectId === undefined)
12
+ throw new CliArgumentError(`Option '${PROJECT}' is required.`);
13
+ return projectId;
14
+ };
15
+ export const readInstructionsShow = (tokens) => {
16
+ const { options, positionals } = parseOptions(tokens, new Set([PROJECT]));
17
+ requirePositionals(positionals, 0);
18
+ return { projectId: projectOf(options) };
19
+ };
20
+ export const readInstructionsSet = (parsed) => {
21
+ requirePositionals(parsed.positionals, 0);
22
+ const { options } = parsed;
23
+ const revision = options.get("--expected-revision");
24
+ if (revision === undefined && options.has("--command-id"))
25
+ throw new CliArgumentError("Option '--command-id' needs '--expected-revision' with the revision of the first attempt.");
26
+ return {
27
+ commandId: options.get("--command-id"),
28
+ file: options.get("--file"),
29
+ projectId: projectOf(options),
30
+ revision: revision === undefined ? undefined : readExpectedRevision(revision),
31
+ };
32
+ };
33
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1,22 @@
1
+ import { block, fields, tab } from "../../command-line/emit/index.js";
2
+ const CLEARED = "The instructions are cleared.\n";
3
+ const withEndingLine = (text) => text.endsWith("\n") ? text : `${text}\n`;
4
+ const formatInstructions = ({ digest, revision, text, updatedAt, }) => `${fields([
5
+ ["Revision", revision],
6
+ ["Digest", digest],
7
+ ["Updated", updatedAt],
8
+ ])}\n${text === "" ? CLEARED : withEndingLine(block(text))}`;
9
+ const formatPreview = ({ commandId, expectedRevision, projectId, text, validUntil, }) => `${tab([projectId, `expected revision ${expectedRevision}`, `command=${commandId}`, `valid until ${validUntil}`])}\n${text === "" ? "Clears the instructions.\n" : withEndingLine(block(text))}`;
10
+ export const formatProjectInstructionsResult = ({ result, }) => {
11
+ switch (result.method) {
12
+ case "project.instructions.show":
13
+ return result.instructions === null
14
+ ? "No instructions.\n"
15
+ : formatInstructions(result.instructions);
16
+ case "project.instructions.change.preview":
17
+ return formatPreview(result);
18
+ case "project.instructions.change.confirm":
19
+ return `${tab([result.projectId, `revision ${result.revision}`, result.digest, result.receipt.receiptId, result.delivery])}\n`;
20
+ }
21
+ };
22
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1,2 @@
1
+ export { formatProjectInstructionsResult, } from "./format.js";
2
+ //# sourceMappingURL=index.js.map