@maiaos/cli 0.1.0-canary.2 → 0.1.0-canary.4

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 (226) hide show
  1. package/README.md +38 -265
  2. package/dist/address-space/address-space.d.ts +38 -0
  3. package/dist/address-space/address-space.js +130 -0
  4. package/dist/address-space/index.d.ts +2 -0
  5. package/dist/address-space/index.js +2 -0
  6. package/dist/agents/client.d.ts +171 -0
  7. package/dist/agents/client.js +8 -0
  8. package/dist/agents/commands.d.ts +7 -0
  9. package/dist/agents/commands.js +65 -0
  10. package/dist/agents/index.d.ts +3 -0
  11. package/dist/agents/index.js +3 -0
  12. package/dist/agents/input.d.ts +130 -0
  13. package/dist/agents/input.js +99 -0
  14. package/dist/agents/output/format.d.ts +8 -0
  15. package/dist/agents/output/format.js +47 -0
  16. package/dist/agents/output/index.d.ts +2 -0
  17. package/dist/agents/output/index.js +2 -0
  18. package/dist/agents/tree/index.d.ts +2 -0
  19. package/dist/agents/tree/index.js +2 -0
  20. package/dist/agents/tree/tree.d.ts +3 -0
  21. package/dist/agents/tree/tree.js +43 -0
  22. package/dist/bin/maia.cdx.json +37 -14
  23. package/dist/bin/maia.mjs +1 -1
  24. package/dist/bootstrap/exit.d.ts +14 -0
  25. package/dist/bootstrap/exit.js +42 -0
  26. package/dist/bootstrap/process.js +4 -26
  27. package/dist/cli/cli.js +76 -13
  28. package/dist/command-line/context.d.ts +13 -4
  29. package/dist/command-line/context.js +1 -1
  30. package/dist/command-line/index.d.ts +5 -5
  31. package/dist/command-line/index.js +5 -4
  32. package/dist/command-line/input/index.d.ts +1 -1
  33. package/dist/command-line/input/index.js +1 -1
  34. package/dist/command-line/input/stdin.d.ts +1 -0
  35. package/dist/command-line/input/stdin.js +1 -0
  36. package/dist/command-line/json.d.ts +1 -0
  37. package/dist/command-line/json.js +23 -0
  38. package/dist/command-line/output.d.ts +8 -1
  39. package/dist/command-line/output.js +33 -14
  40. package/dist/command-line/rows.d.ts +2 -0
  41. package/dist/command-line/rows.js +10 -1
  42. package/dist/command-line/two-phase.d.ts +5 -0
  43. package/dist/command-line/two-phase.js +33 -8
  44. package/dist/command-tree/help.d.ts +1 -1
  45. package/dist/command-tree/help.js +1 -0
  46. package/dist/command-tree/index.d.ts +2 -2
  47. package/dist/command-tree/index.js +1 -1
  48. package/dist/command-tree/local.js +12 -0
  49. package/dist/command-tree/placeholder.d.ts +1 -0
  50. package/dist/command-tree/placeholder.js +1 -0
  51. package/dist/command-tree/row.d.ts +2 -0
  52. package/dist/command-tree/tree.d.ts +3 -2
  53. package/dist/command-tree/tree.js +18 -2
  54. package/dist/connection/access/client.d.ts +13 -0
  55. package/dist/connection/access/client.js +19 -0
  56. package/dist/connection/access/commands.d.ts +6 -0
  57. package/dist/connection/access/commands.js +60 -0
  58. package/dist/connection/access/format.d.ts +8 -0
  59. package/dist/connection/access/format.js +61 -0
  60. package/dist/connection/access/index.d.ts +3 -0
  61. package/dist/connection/access/index.js +3 -0
  62. package/dist/connection/access/input.d.ts +53 -0
  63. package/dist/connection/access/input.js +83 -0
  64. package/dist/connection/client.d.ts +99 -1
  65. package/dist/connection/client.js +9 -1
  66. package/dist/connection/index.d.ts +2 -1
  67. package/dist/connection/index.js +2 -1
  68. package/dist/connection/system.d.ts +1 -0
  69. package/dist/connection/system.js +109 -5
  70. package/dist/connection/tree/tree.js +59 -8
  71. package/dist/container/output/format.js +1 -2
  72. package/dist/dashboard/cockpit-client.d.ts +6 -0
  73. package/dist/dashboard/cockpit-client.js +27 -0
  74. package/dist/dashboard/cockpits.d.ts +29 -0
  75. package/dist/dashboard/cockpits.js +65 -0
  76. package/dist/dashboard/dashboard.d.ts +7 -0
  77. package/dist/dashboard/dashboard.js +47 -0
  78. package/dist/dashboard/draw.d.ts +15 -0
  79. package/dist/dashboard/draw.js +30 -0
  80. package/dist/dashboard/frame.d.ts +4 -0
  81. package/dist/dashboard/frame.js +15 -0
  82. package/dist/dashboard/index.d.ts +2 -0
  83. package/dist/dashboard/index.js +2 -0
  84. package/dist/dashboard/modes.d.ts +5 -0
  85. package/dist/dashboard/modes.js +16 -0
  86. package/dist/dashboard/node-connection.d.ts +15 -0
  87. package/dist/dashboard/node-connection.js +51 -0
  88. package/dist/dashboard/pi-tui.d.ts +6 -0
  89. package/dist/dashboard/pi-tui.js +35 -0
  90. package/dist/dashboard/status-bar.d.ts +4 -0
  91. package/dist/dashboard/status-bar.js +60 -0
  92. package/dist/dashboard/terminal.d.ts +53 -0
  93. package/dist/dashboard/terminal.js +165 -0
  94. package/dist/dashboard/tree-model.d.ts +28 -0
  95. package/dist/dashboard/tree-model.js +97 -0
  96. package/dist/dashboard/tree.d.ts +10 -0
  97. package/dist/dashboard/tree.js +76 -0
  98. package/dist/fleet/fleet.d.ts +70 -0
  99. package/dist/fleet/fleet.js +91 -0
  100. package/dist/fleet/index.d.ts +2 -0
  101. package/dist/fleet/index.js +2 -0
  102. package/dist/hold/output/format.js +1 -5
  103. package/dist/hold/tree/tree.js +1 -0
  104. package/dist/import/commands.js +3 -4
  105. package/dist/import/output.js +1 -4
  106. package/dist/local-node/client.d.ts +8 -4
  107. package/dist/local-node/client.js +20 -9
  108. package/dist/local-node/index.d.ts +1 -1
  109. package/dist/local-node/index.js +1 -1
  110. package/dist/login/commands.js +2 -1
  111. package/dist/mcp/calls.d.ts +1 -0
  112. package/dist/mcp/calls.js +36 -3
  113. package/dist/mcp/commands.d.ts +5 -2
  114. package/dist/mcp/commands.js +30 -4
  115. package/dist/mcp/routing.d.ts +24 -0
  116. package/dist/mcp/routing.js +188 -0
  117. package/dist/mcp/server.d.ts +13 -4
  118. package/dist/mcp/server.js +35 -12
  119. package/dist/presentation/output/format.js +4 -3
  120. package/dist/project-guard/commands.js +11 -2
  121. package/dist/project-workspace/commands.js +16 -6
  122. package/dist/project-workspace/output/human.d.ts +13 -0
  123. package/dist/project-workspace/output/human.js +17 -5
  124. package/dist/project-workspace/output/index.d.ts +1 -1
  125. package/dist/project-workspace/output/index.js +1 -1
  126. package/dist/project-workspace/output/metadata.js +1 -1
  127. package/dist/project-workspace/tree/tree.js +27 -12
  128. package/dist/reference/commands.js +4 -2
  129. package/dist/reference/index.d.ts +1 -1
  130. package/dist/reference/index.js +1 -1
  131. package/dist/reference/resolve.d.ts +2 -0
  132. package/dist/reference/resolve.js +20 -17
  133. package/dist/remote-node/client.d.ts +89 -9
  134. package/dist/remote-node/client.js +6 -1
  135. package/dist/remote-node/commands.d.ts +9 -0
  136. package/dist/remote-node/commands.js +96 -18
  137. package/dist/remote-node/connector.d.ts +12 -4
  138. package/dist/remote-node/connector.js +46 -25
  139. package/dist/remote-node/index.d.ts +2 -2
  140. package/dist/remote-node/index.js +2 -2
  141. package/dist/remote-node/reachability.d.ts +43 -1
  142. package/dist/remote-node/reachability.js +13 -3
  143. package/dist/remote-node/text.d.ts +2 -1
  144. package/dist/remote-node/text.js +74 -27
  145. package/dist/remote-node/tree/tree.js +21 -1
  146. package/dist/routine/client.d.ts +398 -0
  147. package/dist/routine/client.js +28 -0
  148. package/dist/routine/commands.d.ts +9 -0
  149. package/dist/routine/commands.js +109 -0
  150. package/dist/routine/index.d.ts +3 -0
  151. package/dist/routine/index.js +3 -0
  152. package/dist/routine/input.d.ts +28 -0
  153. package/dist/routine/input.js +44 -0
  154. package/dist/routine/output/format.d.ts +23 -0
  155. package/dist/routine/output/format.js +83 -0
  156. package/dist/routine/output/index.d.ts +2 -0
  157. package/dist/routine/output/index.js +2 -0
  158. package/dist/routine/tree/index.d.ts +2 -0
  159. package/dist/routine/tree/index.js +2 -0
  160. package/dist/routine/tree/tree.d.ts +3 -0
  161. package/dist/routine/tree/tree.js +70 -0
  162. package/dist/session/agent-permission.d.ts +2 -2
  163. package/dist/session/approval/commands.js +24 -6
  164. package/dist/session/approval/output/format.d.ts +11 -0
  165. package/dist/session/approval/output/format.js +8 -0
  166. package/dist/session/approval/output/index.d.ts +1 -1
  167. package/dist/session/approval/output/index.js +1 -1
  168. package/dist/session/attach-client.d.ts +1 -1
  169. package/dist/session/attach-client.js +12 -3
  170. package/dist/session/attach-render.js +15 -7
  171. package/dist/session/attach.js +17 -3
  172. package/dist/session/client.d.ts +4 -2
  173. package/dist/session/client.js +4 -15
  174. package/dist/session/commands.js +76 -9
  175. package/dist/session/create-tasks.js +29 -11
  176. package/dist/session/index.d.ts +1 -1
  177. package/dist/session/index.js +1 -0
  178. package/dist/session/interaction/output/format.js +2 -1
  179. package/dist/session/output/diff.js +3 -10
  180. package/dist/session/output/failure.js +3 -10
  181. package/dist/session/output/human.js +21 -10
  182. package/dist/session/output/index.d.ts +1 -1
  183. package/dist/session/output/index.js +1 -1
  184. package/dist/session/output/tasks.d.ts +16 -1
  185. package/dist/session/output/tasks.js +41 -27
  186. package/dist/session/tree/tree.js +56 -8
  187. package/dist/session/turn/client.d.ts +4 -1
  188. package/dist/session/turn/client.js +15 -2
  189. package/dist/session/turn/commands.d.ts +2 -0
  190. package/dist/session/turn/commands.js +38 -5
  191. package/dist/session/turn/index.d.ts +3 -3
  192. package/dist/session/turn/index.js +1 -1
  193. package/dist/session/turn/output.d.ts +7 -2
  194. package/dist/session/turn/output.js +36 -13
  195. package/dist/status/client.d.ts +7 -2
  196. package/dist/status/output/compact.d.ts +1 -0
  197. package/dist/status/output/compact.js +3 -0
  198. package/dist/status/output/human.d.ts +1 -1
  199. package/dist/status/output/human.js +71 -14
  200. package/dist/team-workspace/ceremony.d.ts +19 -0
  201. package/dist/team-workspace/ceremony.js +141 -0
  202. package/dist/team-workspace/client.d.ts +58 -0
  203. package/dist/team-workspace/client.js +6 -0
  204. package/dist/team-workspace/commands.d.ts +3 -0
  205. package/dist/team-workspace/commands.js +85 -0
  206. package/dist/team-workspace/confirmation.d.ts +4 -0
  207. package/dist/team-workspace/confirmation.js +8 -0
  208. package/dist/team-workspace/dependencies.d.ts +8 -0
  209. package/dist/team-workspace/dependencies.js +2 -0
  210. package/dist/team-workspace/index.d.ts +6 -0
  211. package/dist/team-workspace/index.js +5 -0
  212. package/dist/team-workspace/launcher.d.ts +17 -0
  213. package/dist/team-workspace/launcher.js +30 -0
  214. package/dist/team-workspace/output.d.ts +15 -0
  215. package/dist/team-workspace/output.js +28 -0
  216. package/dist/team-workspace/terminal.d.ts +9 -0
  217. package/dist/team-workspace/terminal.js +46 -0
  218. package/dist/terminal/client.d.ts +4 -0
  219. package/dist/terminal/client.js +3 -0
  220. package/dist/terminal/commands.js +37 -25
  221. package/dist/terminal/output/compact-list.d.ts +1 -0
  222. package/dist/terminal/output/compact-list.js +1 -0
  223. package/dist/terminal/output/human.d.ts +2 -19
  224. package/dist/terminal/output/human.js +6 -6
  225. package/dist/terminal/tree/tree.js +15 -15
  226. package/package.json +10 -8
@@ -8,7 +8,9 @@ export const isTerminalControl = (character) => {
8
8
  point === 8233 ||
9
9
  (FORMAT_CHARACTER.test(character) && !JOINERS.has(point)));
10
10
  };
11
- export const cell = (value) => Array.from(value, (character) => isTerminalControl(character) ? "�" : character).join("");
11
+ const replaceControls = (value, kept) => Array.from(value, (character) => !kept.includes(character) && isTerminalControl(character) ? "�" : character).join("");
12
+ export const cell = (value) => replaceControls(value, "");
13
+ export const block = (value) => replaceControls(value, "\t\n");
12
14
  export const tab = (values) => values.join("\t");
13
15
  const align = (rows) => {
14
16
  const widths = rows.reduce((sizes, row) => row.map((value, index) => Math.max(sizes[index] ?? 0, value.length)), []);
@@ -19,6 +21,13 @@ const align = (rows) => {
19
21
  .trimEnd())
20
22
  .join("\n")}\n`;
21
23
  };
24
+ export const fields = (entries) => {
25
+ const shown = entries.flatMap(([label, value]) => value === undefined ? [] : [[`${label}:`, cell(value)]]);
26
+ const width = Math.max(...shown.map(([label]) => label.length)) + 1;
27
+ return shown
28
+ .map(([label, value]) => `${label.padEnd(width)}${value}\n`)
29
+ .join("");
30
+ };
22
31
  export const formatRows = (items, format, text) => {
23
32
  const empty = typeof text === "object" ? text.empty : text;
24
33
  if (items.length === 0)
@@ -9,6 +9,10 @@ export declare const requestedTwoPhaseMode: (flags: ReadonlySet<string>, offersY
9
9
  export declare const promptOrRefuse: (context: CommandContext, offersYes?: boolean) => "prompt";
10
10
  export declare const readTwoPhaseMode: (flags: ReadonlySet<string>, context: CommandContext, offersYes?: boolean) => TwoPhaseMode;
11
11
  export declare const readPipedPreview: (context: CommandContext) => Effect.Effect<object, CliArgumentError>;
12
+ export declare const peekStdin: (context: CommandContext) => Effect.Effect<{
13
+ readonly context: CommandContext;
14
+ readonly input: unknown;
15
+ }>;
12
16
  export declare const confirmParameters: <TParameters>(schema: {
13
17
  readonly safeParse: (input: unknown) => {
14
18
  readonly data: TParameters;
@@ -52,6 +56,7 @@ export type InputTwoPhaseSpec<TPreviewParameters, TPreview extends object, TConf
52
56
  readonly tokens: readonly string[];
53
57
  readonly write: (result: CliNodeResult<TConfirm | TPreview>) => number;
54
58
  };
59
+ export declare const readInputMode: (tokens: readonly string[]) => "confirm-stdin" | "dry-run";
55
60
  export declare const runInputTwoPhase: <TPreviewParameters, TPreview extends object, TConfirmParameters, TConfirm, TRequirements>(spec: InputTwoPhaseSpec<TPreviewParameters, TPreview, TConfirmParameters, TConfirm, TRequirements>) => Effect.Effect<number, CliArgumentError, TRequirements>;
56
61
  export {};
57
62
  //# sourceMappingURL=two-phase.d.ts.map
@@ -1,5 +1,7 @@
1
+ import * as Cause from "effect/Cause";
1
2
  import * as Effect from "effect/Effect";
2
- import { CliArgumentError, parseOptions, recoverStdin, requirePositionals, } from "./input/index.js";
3
+ import * as Exit from "effect/Exit";
4
+ import { CliArgumentError, parseOptions, recoverStdin, replayStdin, requirePositionals, } from "./input/index.js";
3
5
  import { decodeJsonText } from "./json.js";
4
6
  export const TWO_PHASE_FLAGS = [
5
7
  "--confirm-stdin",
@@ -26,7 +28,11 @@ export const promptOrRefuse = (context, offersYes = false) => {
26
28
  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
29
  };
28
30
  export const readTwoPhaseMode = (flags, context, offersYes = false) => requestedTwoPhaseMode(flags, offersYes) ?? promptOrRefuse(context, offersYes);
29
- const MAX_PREVIEW_BYTES = 64 * 1024;
31
+ const PIPED_PREVIEW = {
32
+ label: "preview",
33
+ maxBytes: 64 * 1024,
34
+ maxChunks: 256,
35
+ };
30
36
  const invalidPreview = () => new CliArgumentError("The piped preview is invalid; pipe the output of the same command with '--json --dry-run'.");
31
37
  const unwrapPreview = (value) => {
32
38
  const envelope = typeof value === "object" && value !== null && "ok" in value
@@ -43,16 +49,35 @@ export const readPipedPreview = (context) => Effect.gen(function* () {
43
49
  const stdin = context.io.stdin;
44
50
  if (stdin === undefined)
45
51
  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
- });
52
+ const text = yield* stdin(PIPED_PREVIEW);
51
53
  const preview = unwrapPreview(yield* decodeJsonText(text, invalidPreview));
52
54
  return typeof preview === "object" && preview !== null
53
55
  ? preview
54
56
  : yield* invalidPreview();
55
57
  });
58
+ export const peekStdin = (context) => Effect.gen(function* () {
59
+ const { io } = context;
60
+ if (io.stdin === undefined)
61
+ return { context, input: undefined };
62
+ const read = yield* Effect.exit(io.stdin(PIPED_PREVIEW));
63
+ if (Exit.isFailure(read)) {
64
+ if (Cause.hasInterruptsOnly(read.cause))
65
+ return yield* Effect.interrupt;
66
+ const { cause } = read;
67
+ return {
68
+ context: {
69
+ ...context,
70
+ io: { ...io, stdin: () => Effect.failCause(cause) },
71
+ },
72
+ input: undefined,
73
+ };
74
+ }
75
+ const input = yield* Effect.orElseSucceed(decodeJsonText(read.value, invalidPreview), () => ({}));
76
+ return {
77
+ context: { ...context, io: { ...io, stdin: replayStdin(read.value) } },
78
+ input: unwrapPreview(input),
79
+ };
80
+ });
56
81
  export const confirmParameters = (schema, preview, previewOnly = []) => {
57
82
  const parsed = schema.safeParse(confirmationOf(preview, previewOnly));
58
83
  return parsed.success
@@ -124,7 +149,7 @@ const previewFromStdin = (context, spec) => Effect.gen(function* () {
124
149
  const confirmPreview = (spec, previewed) => Effect.flatMap(confirmParameters(spec.confirmSchema, previewed, spec.previewOnly), (parameters) => spec.confirm === undefined
125
150
  ? Effect.fail(unavailableOperation(spec.label))
126
151
  : Effect.map(spec.confirm(parameters), (result) => withRecovery(result, parameters)));
127
- const readInputMode = (tokens) => {
152
+ export const readInputMode = (tokens) => {
128
153
  const parsed = parseOptions(tokens, new Set(), new Set(["--input-stdin", ...TWO_PHASE_FLAGS]));
129
154
  requirePositionals(parsed.positionals, 0);
130
155
  const mode = requestedTwoPhaseMode(parsed.flags);
@@ -6,7 +6,7 @@ export declare const CLI_CONTRACT: {
6
6
  readonly failure: '{"ok":false,"error":{"code","message","retryable"},"usage"?,"hint"?,"recovery"?} on stderr';
7
7
  readonly success: '{"ok":true,"resolved"?,"result":{"command","result"}} on stdout';
8
8
  };
9
- readonly exitCodes: readonly [readonly [0, "done"], readonly [64, "invalid usage"], readonly [66, "unknown ID"], readonly [69, "Node unavailable"], readonly [70, "other failure: read the message"], readonly [74, "deadline reached"], readonly [75, "retry later: revision changed, full, limited or held"], readonly [76, "outcome unknown: run maia receipt show <command-id>"], readonly [77, "not permitted"]];
9
+ readonly exitCodes: readonly [readonly [0, "done"], readonly [64, "invalid usage"], readonly [66, "unknown ID"], readonly [69, "Node unavailable"], readonly [70, "other failure: read the message"], readonly [74, "deadline reached"], readonly [75, "retry later: revision changed, full, limited or held"], readonly [76, "outcome unknown: run maia receipt show <command-id>"], readonly [77, "not permitted"], readonly [130, "interrupted by a signal"]];
10
10
  readonly grammar: "<x> is a value, [x] optional, (a | b) one of, <a|b> a choice, <1..100> an integer range, <duration> 30s, 10m or 1h, x... repeats; 'maia <command> --help --json' lists typed arguments.";
11
11
  readonly idempotency: "A mutation that guards a revision takes the current --expected-revision (or a named --expected-*-revision); --command-id <id> names the mutation, and a retry with the same command ID replays the first result.";
12
12
  readonly input: "Prompts appear only when stdin and stderr are terminals and --json and --no-input (MAIA_NO_INPUT=1) are absent; otherwise a command that confirms fails (exit 64) and names its flags. A two-phase command previews with --dry-run and confirms that preview from stdin with --confirm-stdin.";
@@ -15,6 +15,7 @@ export const CLI_CONTRACT = {
15
15
  [75, "retry later: revision changed, full, limited or held"],
16
16
  [76, "outcome unknown: run maia receipt show <command-id>"],
17
17
  [77, "not permitted"],
18
+ [130, "interrupted by a signal"],
18
19
  ],
19
20
  grammar: "<x> is a value, [x] optional, (a | b) one of, <a|b> a choice, <1..100> an integer range, <duration> 30s, 10m or 1h, x... repeats; 'maia <command> --help --json' lists typed arguments.",
20
21
  idempotency: "A mutation that guards a revision takes the current --expected-revision (or a named --expected-*-revision); --command-id <id> names the mutation, and a retry with the same command ID replays the first result.",
@@ -1,8 +1,8 @@
1
1
  export type { CliVersionResult } from "./commands.js";
2
2
  export { exampleFor, parseUsage, type TreeArgument, type TreeForm, } from "./grammar.js";
3
3
  export { CLI_CONTRACT, type CliHelpNode, type CliHelpNodeResult, type CliHelpResult, type CliHelpTreeResult, createHelpTree, createNodeHelp, formatNodeHelp, formatRootHelp, leafExample, usageHint, } from "./help.js";
4
- export { REFERENCE_PLACEHOLDER, REFERENCE_USAGE } from "./placeholder.js";
5
- export type { GroupRow, LeafRow, LeafRunner, RunnerReference, TreeFragment, TreeLeafKind, TreeOperation, } from "./row.js";
4
+ export { REFERENCE_PLACEHOLDER, REFERENCE_USAGE, ROUTE_ARGUMENT, } from "./placeholder.js";
5
+ export type { GroupRow, LeafRoute, LeafRow, LeafRunner, RunnerReference, TreeFragment, TreeLeafKind, TreeOperation, } from "./row.js";
6
6
  export { suggestPaths, unknownPathMessage } from "./suggest.js";
7
7
  export { commandTree, createTreeDigest, findNode, isNodeBacked, TREE_FRAGMENTS, TREE_SECTIONS, type TreeAvailability, type TreeLeafForm, type TreeNode, treeNodes, treeUsages, usagePath, } from "./tree.js";
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
1
  export { exampleFor, parseUsage, } from "./grammar.js";
2
2
  export { CLI_CONTRACT, createHelpTree, createNodeHelp, formatNodeHelp, formatRootHelp, leafExample, usageHint, } from "./help.js";
3
- export { REFERENCE_PLACEHOLDER, REFERENCE_USAGE } from "./placeholder.js";
3
+ export { REFERENCE_PLACEHOLDER, REFERENCE_USAGE, ROUTE_ARGUMENT, } from "./placeholder.js";
4
4
  export { suggestPaths, unknownPathMessage } from "./suggest.js";
5
5
  export { commandTree, createTreeDigest, findNode, isNodeBacked, TREE_FRAGMENTS, TREE_SECTIONS, treeNodes, treeUsages, usagePath, } from "./tree.js";
6
6
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,7 @@ const local = () => import("./commands.js");
2
2
  const doctor = () => import("../status/index.js");
3
3
  const mcp = () => import("../mcp/index.js");
4
4
  const presentation = () => import("../presentation/index.js");
5
+ const dashboard = () => import("../dashboard/index.js");
5
6
  const agent = [local, "runAgent"];
6
7
  export const LOCAL_TREE = {
7
8
  groups: [
@@ -121,6 +122,17 @@ export const LOCAL_TREE = {
121
122
  "Serve coordinator or worker tools over MCP stdio.",
122
123
  { kind: "local", node: true, run: [mcp, "runMcpCommand"] },
123
124
  ],
125
+ [
126
+ "dashboard [--plain]",
127
+ 1,
128
+ "",
129
+ "Open the terminal dashboard; --plain prints its text once.",
130
+ {
131
+ example: "maia dashboard --plain",
132
+ kind: "composite",
133
+ run: [dashboard, "runDashboard"],
134
+ },
135
+ ],
124
136
  ],
125
137
  };
126
138
  //# sourceMappingURL=local.js.map
@@ -1,3 +1,4 @@
1
1
  export declare const REFERENCE_PLACEHOLDER: RegExp;
2
2
  export declare const REFERENCE_USAGE: RegExp;
3
+ export declare const ROUTE_ARGUMENT: RegExp;
3
4
  //# sourceMappingURL=placeholder.d.ts.map
@@ -1,4 +1,5 @@
1
1
  const KINDS = "connection|container|project|session|workspace";
2
2
  export const REFERENCE_PLACEHOLDER = new RegExp(`^<(?:[a-z]+-)*?(${KINDS})(?:-id)?>$`, "u");
3
3
  export const REFERENCE_USAGE = new RegExp(`<(?:[a-z]+-)*?(?:${KINDS})(?:-id)?>`, "u");
4
+ export const ROUTE_ARGUMENT = /^(?:--|<(?:[a-z]+-)*?)(approval|command|project|routine|session|terminal|turn|workspace)(?:-id(?:\|.+)?>)?$/u;
4
5
  //# sourceMappingURL=placeholder.js.map
@@ -2,6 +2,7 @@ import type { localNodeRequestPayloadSchema, SessionAttachFrame } from "@maiaos/
2
2
  import type { CommandContext, CommandEffect } from "../command-line/index.js";
3
3
  export type TreeOperation = ReturnType<typeof localNodeRequestPayloadSchema.parse>["method"] | SessionAttachFrame["operationId"];
4
4
  export type TreeLeafKind = "composite" | "discriminant" | "local" | "operation" | "shortcut" | "two-phase";
5
+ export type LeafRoute = readonly [string, string] | string;
5
6
  export type LeafRunner = (tokens: readonly string[], context: CommandContext) => CommandEffect;
6
7
  export type RunnerReference = readonly [
7
8
  load: () => Promise<object>,
@@ -12,6 +13,7 @@ export type LeafExtra = {
12
13
  readonly kind?: Exclude<TreeLeafKind, "operation">;
13
14
  readonly node?: true;
14
15
  readonly remote?: false;
16
+ readonly route?: LeafRoute;
15
17
  readonly run: RunnerReference;
16
18
  };
17
19
  export type LeafRow = readonly [
@@ -1,4 +1,4 @@
1
- import type { RunnerReference, TreeFragment, TreeLeafKind, TreeOperation } from "./row.js";
1
+ import type { LeafRoute, RunnerReference, TreeFragment, TreeLeafKind, TreeOperation } from "./row.js";
2
2
  export type TreeAvailability = "implemented" | "source_implemented_candidate";
3
3
  export type TreeLeafForm = {
4
4
  readonly availability: TreeAvailability;
@@ -15,11 +15,12 @@ export type TreeNode = {
15
15
  readonly operations: readonly TreeOperation[];
16
16
  readonly path: readonly string[];
17
17
  readonly remote?: false;
18
+ readonly route?: LeafRoute;
18
19
  readonly run?: RunnerReference;
19
20
  readonly summary: string;
20
21
  };
21
22
  export declare const TREE_FRAGMENTS: readonly TreeFragment[];
22
- export declare const TREE_SECTIONS: readonly [readonly ["Start and sign in", readonly ["setup", "login", "status"]], readonly ["Work", readonly ["session", "run", "import"]], readonly ["Resources", readonly ["project", "workspace", "container", "terminal", "execution", "port", "reference"]], readonly ["Accounts and Nodes", readonly ["connection", "integration", "provider", "node"]], readonly ["Safety and audit", readonly ["hold", "receipt", "context"]], readonly ["Clients and local", readonly ["presentation", "mcp", "agent", "help", "version", "doctor", "completion"]]];
23
+ export declare const TREE_SECTIONS: readonly [readonly ["Start and sign in", readonly ["setup", "login", "status"]], readonly ["Work", readonly ["session", "run", "routine", "import"]], readonly ["Resources", readonly ["project", "workspace", "container", "terminal", "execution", "port", "reference", "agents"]], readonly ["Accounts and Nodes", readonly ["connection", "integration", "provider", "node"]], readonly ["Safety and audit", readonly ["hold", "receipt", "context"]], readonly ["Clients and local", readonly ["presentation", "mcp", "dashboard", "agent", "help", "version", "doctor", "completion"]]];
23
24
  export declare const usagePath: (usage: string) => readonly string[];
24
25
  export declare const COMMAND_TREE: TreeNode;
25
26
  export declare const commandTree: () => TreeNode;
@@ -1,4 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
+ import { AGENTS_TREE } from "../agents/tree/index.js";
2
3
  import { CONNECTION_TREE } from "../connection/tree/index.js";
3
4
  import { EXECUTION_TREE } from "../execution/tree/index.js";
4
5
  import { SAFETY_TREE } from "../hold/tree/index.js";
@@ -6,6 +7,7 @@ import { RUN_TREE } from "../orchestration/tree/index.js";
6
7
  import { PROJECT_TREE } from "../project-workspace/tree/index.js";
7
8
  import { REFERENCE_TREE } from "../reference/tree/index.js";
8
9
  import { NODE_TREE } from "../remote-node/tree/index.js";
10
+ import { ROUTINE_TREE } from "../routine/tree/index.js";
9
11
  import { SESSION_TREE } from "../session/tree/index.js";
10
12
  import { TERMINAL_TREE } from "../terminal/tree/index.js";
11
13
  import { LOCAL_TREE } from "./local.js";
@@ -14,16 +16,18 @@ export const TREE_FRAGMENTS = [
14
16
  CONNECTION_TREE,
15
17
  SESSION_TREE,
16
18
  RUN_TREE,
19
+ ROUTINE_TREE,
17
20
  PROJECT_TREE,
18
21
  REFERENCE_TREE,
19
22
  TERMINAL_TREE,
20
23
  EXECUTION_TREE,
21
24
  SAFETY_TREE,
25
+ AGENTS_TREE,
22
26
  LOCAL_TREE,
23
27
  ];
24
28
  export const TREE_SECTIONS = [
25
29
  ["Start and sign in", ["setup", "login", "status"]],
26
- ["Work", ["session", "run", "import"]],
30
+ ["Work", ["session", "run", "routine", "import"]],
27
31
  [
28
32
  "Resources",
29
33
  [
@@ -34,13 +38,23 @@ export const TREE_SECTIONS = [
34
38
  "execution",
35
39
  "port",
36
40
  "reference",
41
+ "agents",
37
42
  ],
38
43
  ],
39
44
  ["Accounts and Nodes", ["connection", "integration", "provider", "node"]],
40
45
  ["Safety and audit", ["hold", "receipt", "context"]],
41
46
  [
42
47
  "Clients and local",
43
- ["presentation", "mcp", "agent", "help", "version", "doctor", "completion"],
48
+ [
49
+ "presentation",
50
+ "mcp",
51
+ "dashboard",
52
+ "agent",
53
+ "help",
54
+ "version",
55
+ "doctor",
56
+ "completion",
57
+ ],
44
58
  ],
45
59
  ];
46
60
  const PATH_WORD = /^[a-z][a-z0-9-]*$/u;
@@ -82,6 +96,8 @@ const addLeaf = (root, row) => {
82
96
  node.node = extra.node;
83
97
  if (extra.remote !== undefined)
84
98
  node.remote = extra.remote;
99
+ if (extra.route !== undefined)
100
+ node.route = extra.route;
85
101
  if (extra.example !== undefined)
86
102
  node.example = extra.example;
87
103
  };
@@ -0,0 +1,13 @@
1
+ import { type ConnectionGrantListParameters, type ConnectionGrantListResult, type ConnectionGrantSetConfirmParameters, type ConnectionGrantSetConfirmResult, type ConnectionGrantSetPreviewParameters, type ConnectionGrantSetPreviewResult, type ConnectionPoolListParameters, type ConnectionPoolListResult, type ConnectionPoolSetConfirmParameters, type ConnectionPoolSetConfirmResult, type ConnectionPoolSetPreviewParameters, type ConnectionPoolSetPreviewResult } from "@maiaos/sdk";
2
+ import type { CliNodeEffect, CliNodeOperations } from "../../local-node/index.js";
3
+ export type Operation<TInput, TResult> = (input: TInput) => CliNodeEffect<TResult>;
4
+ export type ConnectionAccessClient = {
5
+ readonly confirmConnectionGrant: Operation<ConnectionGrantSetConfirmParameters, ConnectionGrantSetConfirmResult>;
6
+ readonly confirmConnectionPool: Operation<ConnectionPoolSetConfirmParameters, ConnectionPoolSetConfirmResult>;
7
+ readonly listConnectionGrants: Operation<ConnectionGrantListParameters, ConnectionGrantListResult>;
8
+ readonly listConnectionPools: Operation<ConnectionPoolListParameters, ConnectionPoolListResult>;
9
+ readonly previewConnectionGrant: Operation<ConnectionGrantSetPreviewParameters, ConnectionGrantSetPreviewResult>;
10
+ readonly previewConnectionPool: Operation<ConnectionPoolSetPreviewParameters, ConnectionPoolSetPreviewResult>;
11
+ };
12
+ export declare const makeConnectionAccessClient: (node: CliNodeOperations) => ConnectionAccessClient;
13
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1,19 @@
1
+ import { connectionGrantListParametersSchema, connectionGrantSetConfirmParametersSchema, connectionGrantSetPreviewParametersSchema, connectionPoolListParametersSchema, connectionPoolSetConfirmParametersSchema, connectionPoolSetPreviewParametersSchema, } from "@maiaos/sdk";
2
+ const reads = (node) => ({
3
+ listConnectionGrants: (input) => node.runValidatedNodeOperation(input, connectionGrantListParametersSchema, (client, parameters, options) => client.listConnectionGrants(parameters, options)),
4
+ listConnectionPools: (input) => node.runValidatedNodeOperation(input, connectionPoolListParametersSchema, (client, parameters, options) => client.listConnectionPools(parameters, options)),
5
+ });
6
+ const previews = (node) => ({
7
+ previewConnectionGrant: (input) => node.runValidatedNodeOperation(input, connectionGrantSetPreviewParametersSchema, (client, parameters, options) => client.previewConnectionGrant(parameters, options)),
8
+ previewConnectionPool: (input) => node.runValidatedNodeOperation(input, connectionPoolSetPreviewParametersSchema, (client, parameters, options) => client.previewConnectionPool(parameters, options)),
9
+ });
10
+ const confirmations = (node) => ({
11
+ confirmConnectionGrant: (input) => node.runValidatedNodeOperation(input, connectionGrantSetConfirmParametersSchema, (client, parameters, options) => client.confirmConnectionGrant(parameters, options), { commandId: input.commandId }),
12
+ confirmConnectionPool: (input) => node.runValidatedNodeOperation(input, connectionPoolSetConfirmParametersSchema, (client, parameters, options) => client.confirmConnectionPool(parameters, options), { commandId: input.commandId }),
13
+ });
14
+ export const makeConnectionAccessClient = (node) => ({
15
+ ...confirmations(node),
16
+ ...previews(node),
17
+ ...reads(node),
18
+ });
19
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,6 @@
1
+ import { type CommandContext, type CommandEffect } from "../../command-line/index.js";
2
+ export declare const runConnectionGrantList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
3
+ export declare const runConnectionPoolList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
4
+ export declare const runConnectionGrantSet: (tokens: readonly string[], context: CommandContext) => CommandEffect;
5
+ export declare const runConnectionPoolSet: (tokens: readonly string[], context: CommandContext) => CommandEffect;
6
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1,60 @@
1
+ import { connectionGrantSetConfirmParametersSchema, connectionPoolSetConfirmParametersSchema, } from "@maiaos/sdk";
2
+ import * as Effect from "effect/Effect";
3
+ import { CliArgumentError, confirmParameters, parseOptions, readTwoPhaseMode, runTwoPhase, TWO_PHASE_FLAGS, writeNodeResult, } from "../../command-line/index.js";
4
+ import { formatConnectionAccessResult, } from "./format.js";
5
+ import { GRANT_SET_OPTIONS, POOL_SET_OPTIONS, readGrantList, readGrantPreview, readPoolList, readPoolPreview, } from "./input.js";
6
+ const write = (context) => (result) => writeNodeResult(result, context, {
7
+ toResult: (value) => ({
8
+ command: value.method,
9
+ result: value,
10
+ }),
11
+ toText: formatConnectionAccessResult,
12
+ });
13
+ const unavailable = () => new CliArgumentError("Connection grants and pools are unavailable.");
14
+ const list = (step, read) => (tokens, context) => Effect.gen(function* () {
15
+ const operation = step(context.dependencies);
16
+ if (operation === undefined)
17
+ return yield* unavailable();
18
+ return write(context)(yield* operation(read(tokens)));
19
+ });
20
+ export const runConnectionGrantList = list((dependencies) => dependencies.listConnectionGrants, readGrantList);
21
+ export const runConnectionPoolList = list((dependencies) => dependencies.listConnectionPools, readPoolList);
22
+ const PROMPT = {
23
+ describe: (preview) => formatConnectionAccessResult({ command: preview.method, result: preview }),
24
+ question: "Apply this change?",
25
+ };
26
+ const runSet = (spec, tokens, context) => Effect.gen(function* () {
27
+ const parsed = parseOptions(tokens, spec.options, new Set(spec.flags));
28
+ const mode = readTwoPhaseMode(parsed.flags, context);
29
+ const send = spec.confirm(context.dependencies);
30
+ const preview = spec.preview(context.dependencies);
31
+ if (send === undefined || preview === undefined)
32
+ return yield* unavailable();
33
+ return yield* runTwoPhase({
34
+ confirm: (previewed) => Effect.flatMap(confirmParameters(spec.confirmSchema, previewed, ["current"]), send),
35
+ context,
36
+ mode,
37
+ preview: () => Effect.flatMap(spec.read(parsed), preview),
38
+ prompt: PROMPT,
39
+ writeConfirm: write(context),
40
+ writePreview: write(context),
41
+ });
42
+ });
43
+ const set = (spec) => (tokens, context) => runSet(spec, tokens, context);
44
+ export const runConnectionGrantSet = set({
45
+ confirm: (dependencies) => dependencies.confirmConnectionGrant,
46
+ confirmSchema: connectionGrantSetConfirmParametersSchema,
47
+ flags: ["--revoke", ...TWO_PHASE_FLAGS],
48
+ options: GRANT_SET_OPTIONS,
49
+ preview: (dependencies) => dependencies.previewConnectionGrant,
50
+ read: readGrantPreview,
51
+ });
52
+ export const runConnectionPoolSet = set({
53
+ confirm: (dependencies) => dependencies.confirmConnectionPool,
54
+ confirmSchema: connectionPoolSetConfirmParametersSchema,
55
+ flags: TWO_PHASE_FLAGS,
56
+ options: POOL_SET_OPTIONS,
57
+ preview: (dependencies) => dependencies.previewConnectionPool,
58
+ read: readPoolPreview,
59
+ });
60
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1,8 @@
1
+ import type { ConnectionGrantListResult, ConnectionGrantSetConfirmResult, ConnectionGrantSetPreviewResult, ConnectionPoolListResult, ConnectionPoolSetConfirmResult, ConnectionPoolSetPreviewResult } from "@maiaos/sdk";
2
+ export type ConnectionAccessResult = ConnectionGrantListResult | ConnectionGrantSetConfirmResult | ConnectionGrantSetPreviewResult | ConnectionPoolListResult | ConnectionPoolSetConfirmResult | ConnectionPoolSetPreviewResult;
3
+ export type CliConnectionAccessResult = {
4
+ readonly command: ConnectionAccessResult["method"];
5
+ readonly result: ConnectionAccessResult;
6
+ };
7
+ export declare const formatConnectionAccessResult: ({ result, }: CliConnectionAccessResult) => string;
8
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1,61 @@
1
+ import { formatRows, tab, withNextPage } from "../../command-line/index.js";
2
+ const scopeCell = (scope) => `${scope.kind === "project" ? "project" : "container"}:${scope.id}`;
3
+ const grantLine = (grant) => tab([
4
+ grant.grantId,
5
+ grant.connectionId,
6
+ scopeCell(grant.scope),
7
+ grant.state,
8
+ `revision=${grant.revision}`,
9
+ ]);
10
+ const poolLine = (pool) => tab([
11
+ pool.poolId,
12
+ scopeCell(pool.scope),
13
+ pool.mode,
14
+ pool.members.length === 0 ? "-" : pool.members.join(","),
15
+ `revision=${pool.revision}`,
16
+ ]);
17
+ const grantPreviewLines = (result) => [
18
+ result.current === undefined
19
+ ? tab([result.connectionId, scopeCell(result.scope), "none", "current"])
20
+ : `${grantLine(result.current)}\tcurrent`,
21
+ tab([
22
+ result.connectionId,
23
+ scopeCell(result.scope),
24
+ result.granted ? "grant" : "revoke",
25
+ "proposed",
26
+ `command=${result.commandId}`,
27
+ `expires=${result.expiresAt}`,
28
+ ]),
29
+ ].join("\n");
30
+ const poolPreviewLines = (result) => [
31
+ result.current === undefined
32
+ ? tab([scopeCell(result.scope), "none", "current"])
33
+ : `${poolLine(result.current)}\tcurrent`,
34
+ tab([
35
+ scopeCell(result.scope),
36
+ result.mode,
37
+ result.members.length === 0 ? "-" : result.members.join(","),
38
+ "proposed",
39
+ `command=${result.commandId}`,
40
+ `expires=${result.expiresAt}`,
41
+ ]),
42
+ ].join("\n");
43
+ const confirmed = (line, result) => tab([line, result.receipt.receiptId, result.delivery]);
44
+ const formatLines = (result) => {
45
+ switch (result.method) {
46
+ case "connection.grant.list":
47
+ return withNextPage(formatRows(result.items, grantLine, "No grants."), result.nextCursor).trimEnd();
48
+ case "connection.pool.list":
49
+ return withNextPage(formatRows(result.items, poolLine, "No pools."), result.nextCursor).trimEnd();
50
+ case "connection.grant.set.preview":
51
+ return grantPreviewLines(result);
52
+ case "connection.pool.set.preview":
53
+ return poolPreviewLines(result);
54
+ case "connection.grant.set.confirm":
55
+ return confirmed(grantLine(result.grant), result);
56
+ case "connection.pool.set.confirm":
57
+ return confirmed(poolLine(result.pool), result);
58
+ }
59
+ };
60
+ export const formatConnectionAccessResult = ({ result, }) => `${formatLines(result)}\n`;
61
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1,3 @@
1
+ export { makeConnectionAccessClient } from "./client.js";
2
+ export { runConnectionGrantList, runConnectionGrantSet, runConnectionPoolList, runConnectionPoolSet, } from "./commands.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { makeConnectionAccessClient } from "./client.js";
2
+ export { runConnectionGrantList, runConnectionGrantSet, runConnectionPoolList, runConnectionPoolSet, } from "./commands.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,53 @@
1
+ import * as Effect from "effect/Effect";
2
+ import { type ParsedOptions } from "../../command-line/index.js";
3
+ type PoolMode = "off" | "rotate" | "single";
4
+ export declare const readGrantList: (tokens: readonly string[]) => {
5
+ afterCursor?: string | undefined;
6
+ limit: number;
7
+ scope?: undefined;
8
+ connectionId?: string | undefined;
9
+ state?: "active" | "revoked" | undefined;
10
+ } | {
11
+ afterCursor?: string | undefined;
12
+ limit: number;
13
+ scope: {
14
+ readonly id: string;
15
+ readonly kind: "project" | "workspace";
16
+ };
17
+ connectionId?: string | undefined;
18
+ state?: "active" | "revoked" | undefined;
19
+ };
20
+ export declare const readPoolList: (tokens: readonly string[]) => {
21
+ afterCursor?: string | undefined;
22
+ limit: number;
23
+ scope?: undefined;
24
+ } | {
25
+ afterCursor?: string | undefined;
26
+ limit: number;
27
+ scope: {
28
+ readonly id: string;
29
+ readonly kind: "project" | "workspace";
30
+ };
31
+ };
32
+ export declare const GRANT_SET_OPTIONS: ReadonlySet<string>;
33
+ export declare const readGrantPreview: (parsed: ParsedOptions) => Effect.Effect<{
34
+ commandId: string;
35
+ connectionId: string;
36
+ granted: boolean;
37
+ scope: {
38
+ readonly id: string;
39
+ readonly kind: "project" | "workspace";
40
+ };
41
+ }, never, import("effect/Crypto").Crypto>;
42
+ export declare const POOL_SET_OPTIONS: ReadonlySet<string>;
43
+ export declare const readPoolPreview: (parsed: ParsedOptions) => Effect.Effect<{
44
+ commandId: string;
45
+ members: readonly string[];
46
+ mode: PoolMode;
47
+ scope: {
48
+ readonly id: string;
49
+ readonly kind: "project" | "workspace";
50
+ };
51
+ }, never, import("effect/Crypto").Crypto>;
52
+ export {};
53
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1,83 @@
1
+ import * as Effect from "effect/Effect";
2
+ import { CliArgumentError, parseOptions, readPageSize, requirePositionals, } from "../../command-line/index.js";
3
+ import { commandIdentifier } from "../../local-node/index.js";
4
+ const SCOPE_OPTIONS = ["--container", "--project"];
5
+ const isMode = (value) => value === "off" || value === "rotate" || value === "single";
6
+ const isState = (value) => value === "active" || value === "revoked";
7
+ const readScope = (options) => {
8
+ const project = options.get("--project");
9
+ const container = options.get("--container");
10
+ if (project !== undefined && container !== undefined)
11
+ throw new CliArgumentError("Use one of '--project' or '--container'.");
12
+ if (project !== undefined)
13
+ return { id: project, kind: "project" };
14
+ return container === undefined
15
+ ? undefined
16
+ : { id: container, kind: "workspace" };
17
+ };
18
+ const requireScope = (options) => {
19
+ const scope = readScope(options);
20
+ if (scope === undefined)
21
+ throw new CliArgumentError("Use one of '--project' or '--container'.");
22
+ return scope;
23
+ };
24
+ const readPage = (options) => {
25
+ const afterCursor = options.get("--after");
26
+ return {
27
+ ...(afterCursor === undefined ? {} : { afterCursor }),
28
+ limit: readPageSize(options.get("--limit")),
29
+ };
30
+ };
31
+ const withScope = (scope) => scope === undefined ? {} : { scope };
32
+ export const readGrantList = (tokens) => {
33
+ const parsed = parseOptions(tokens, new Set([
34
+ ...SCOPE_OPTIONS,
35
+ "--after",
36
+ "--connection",
37
+ "--limit",
38
+ "--state",
39
+ ]));
40
+ requirePositionals(parsed.positionals, 0);
41
+ const connectionId = parsed.options.get("--connection");
42
+ const state = parsed.options.get("--state");
43
+ if (state !== undefined && !isState(state))
44
+ throw new CliArgumentError("Option '--state' must be 'active' or 'revoked'.");
45
+ return {
46
+ ...readPage(parsed.options),
47
+ ...(connectionId === undefined ? {} : { connectionId }),
48
+ ...withScope(readScope(parsed.options)),
49
+ ...(state === undefined ? {} : { state }),
50
+ };
51
+ };
52
+ export const readPoolList = (tokens) => {
53
+ const parsed = parseOptions(tokens, new Set([...SCOPE_OPTIONS, "--after", "--limit"]));
54
+ requirePositionals(parsed.positionals, 0);
55
+ return {
56
+ ...readPage(parsed.options),
57
+ ...withScope(readScope(parsed.options)),
58
+ };
59
+ };
60
+ export const GRANT_SET_OPTIONS = new Set([
61
+ ...SCOPE_OPTIONS,
62
+ "--command-id",
63
+ ]);
64
+ export const readGrantPreview = (parsed) => {
65
+ requirePositionals(parsed.positionals, 1);
66
+ const scope = requireScope(parsed.options);
67
+ const connectionId = parsed.positionals[0] ?? "";
68
+ const granted = !parsed.flags.has("--revoke");
69
+ return Effect.map(commandIdentifier(parsed.options.get("--command-id")), (commandId) => ({ commandId, connectionId, granted, scope }));
70
+ };
71
+ export const POOL_SET_OPTIONS = new Set([
72
+ ...SCOPE_OPTIONS,
73
+ "--command-id",
74
+ "--mode",
75
+ ]);
76
+ export const readPoolPreview = (parsed) => {
77
+ const scope = requireScope(parsed.options);
78
+ const mode = parsed.options.get("--mode") ?? "";
79
+ if (!isMode(mode))
80
+ throw new CliArgumentError("Option '--mode' must be 'off', 'rotate' or 'single'.");
81
+ return Effect.map(commandIdentifier(parsed.options.get("--command-id")), (commandId) => ({ commandId, members: parsed.positionals, mode, scope }));
82
+ };
83
+ //# sourceMappingURL=input.js.map