@maiaos/cli 0.1.0-canary.3 → 0.1.0-canary.31

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 (87) hide show
  1. package/README.md +2 -2
  2. package/dist/agents/client.d.ts +35 -27
  3. package/dist/agents/client.js +10 -3
  4. package/dist/agents/commands.d.ts +1 -0
  5. package/dist/agents/commands.js +7 -1
  6. package/dist/agents/index.d.ts +1 -1
  7. package/dist/agents/index.js +1 -1
  8. package/dist/agents/input.d.ts +3 -1
  9. package/dist/agents/input.js +6 -0
  10. package/dist/agents/output/format.d.ts +2 -2
  11. package/dist/agents/output/format.js +8 -0
  12. package/dist/agents/tree/tree.js +13 -1
  13. package/dist/bin/maia.cdx.json +19 -19
  14. package/dist/bin/maia.mjs +1 -1
  15. package/dist/bootstrap/run.js +5 -2
  16. package/dist/cli/cli.d.ts +8 -2
  17. package/dist/cli/cli.js +25 -6
  18. package/dist/cli/index.d.ts +1 -1
  19. package/dist/cli/index.js +1 -1
  20. package/dist/command-line/context.d.ts +1 -0
  21. package/dist/command-line/index.d.ts +2 -2
  22. package/dist/command-line/index.js +2 -2
  23. package/dist/command-line/input/arguments.d.ts +7 -0
  24. package/dist/command-line/input/arguments.js +22 -10
  25. package/dist/command-line/input/index.d.ts +1 -1
  26. package/dist/command-line/input/index.js +1 -1
  27. package/dist/command-line/rows.d.ts +1 -0
  28. package/dist/command-line/rows.js +3 -0
  29. package/dist/command-receipt/command.js +1 -1
  30. package/dist/connection/access/client.d.ts +13 -0
  31. package/dist/connection/access/client.js +19 -0
  32. package/dist/connection/access/commands.d.ts +6 -0
  33. package/dist/connection/access/commands.js +60 -0
  34. package/dist/connection/access/format.d.ts +8 -0
  35. package/dist/connection/access/format.js +61 -0
  36. package/dist/connection/access/index.d.ts +3 -0
  37. package/dist/connection/access/index.js +3 -0
  38. package/dist/connection/access/input.d.ts +53 -0
  39. package/dist/connection/access/input.js +83 -0
  40. package/dist/connection/client.d.ts +6 -0
  41. package/dist/connection/client.js +2 -0
  42. package/dist/connection/index.d.ts +1 -0
  43. package/dist/connection/index.js +1 -0
  44. package/dist/connection/tree/tree.js +45 -7
  45. package/dist/local-node/client.d.ts +1 -0
  46. package/dist/local-node/client.js +1 -0
  47. package/dist/local-node/index.d.ts +2 -1
  48. package/dist/local-node/index.js +2 -1
  49. package/dist/local-node/wait.d.ts +10 -0
  50. package/dist/local-node/wait.js +17 -0
  51. package/dist/mcp/calls.js +2 -1
  52. package/dist/reference/resolve.js +9 -2
  53. package/dist/remote-node/connector.js +8 -1
  54. package/dist/session/agent-permission.d.ts +2 -2
  55. package/dist/session/approval/commands.js +7 -3
  56. package/dist/session/client.d.ts +10 -3
  57. package/dist/session/client.js +14 -2
  58. package/dist/session/commands.d.ts +1 -0
  59. package/dist/session/commands.js +45 -5
  60. package/dist/session/index.d.ts +1 -1
  61. package/dist/session/index.js +1 -1
  62. package/dist/session/output/human.d.ts +1 -0
  63. package/dist/session/output/human.js +4 -3
  64. package/dist/session/output/index.d.ts +1 -1
  65. package/dist/session/output/index.js +1 -1
  66. package/dist/session/tree/tree.js +12 -1
  67. package/dist/session/turn/client.js +7 -9
  68. package/dist/session/turn/commands.js +1 -6
  69. package/dist/status/client.d.ts +6 -1
  70. package/dist/status/command.js +3 -1
  71. package/dist/status/doctor.d.ts +5 -1
  72. package/dist/status/doctor.js +10 -4
  73. package/dist/status/output/compact.d.ts +1 -0
  74. package/dist/status/output/compact.js +3 -0
  75. package/dist/status/output/human.js +10 -0
  76. package/dist/terminal/control-commands.js +26 -9
  77. package/dist/terminal/keys.d.ts +12 -0
  78. package/dist/terminal/keys.js +62 -0
  79. package/dist/terminal/output/compact-list.d.ts +1 -0
  80. package/dist/terminal/output/compact-list.js +3 -0
  81. package/dist/terminal/output/human.js +2 -2
  82. package/dist/terminal/tree/tree.js +1 -1
  83. package/guidance/maia-cli/SKILL.md +1 -1
  84. package/guidance/maia-node/SKILL.md +54 -0
  85. package/guidance/maia-orchestration/SKILL.md +1 -2
  86. package/guidance/maia-sessions/SKILL.md +69 -0
  87. package/package.json +6 -6
@@ -17,12 +17,15 @@ const probePayloads = (dependencies) => Effect.all([
17
17
  probe(dependencies.loadAgent, (module) => typeof module.runMaiaAgent === "function"),
18
18
  ]).pipe(Effect.map(([cliPayload, agent]) => ({ agent, cliPayload })));
19
19
  const formatInstallation = (checks) => `Maia doctor failed\n${checks
20
- .map((check) => ` ${check.code}: ${check.ok ? "ok" : "failed; next: reinstall Maia"}`)
20
+ .map((check) => ` ${check.code} (this machine): ${check.ok ? "ok" : "failed; next: reinstall Maia"}`)
21
21
  .join("\n")}\n`;
22
22
  const writeInstallationFailure = (output) => {
23
23
  const { arguments_, checks, input } = output;
24
24
  const result = {
25
- checks: checks.map((check) => check.ok ? check : { ...check, next: "reinstall Maia" }),
25
+ checks: checks.map((check) => ({
26
+ ...(check.ok ? check : { ...check, next: "reinstall Maia" }),
27
+ scope: "machine",
28
+ })),
26
29
  command: "doctor",
27
30
  ok: false,
28
31
  version: input.version,
package/dist/cli/cli.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import type * as Scope from "effect/Scope";
3
- import { type CliDependencies, type CliIo } from "../command-line/index.js";
3
+ import { type CliDependencies, type CliIo, type ParsedArguments } from "../command-line/index.js";
4
+ import { type TreeNode } from "../command-tree/index.js";
4
5
  import type { CliNodeConnector } from "../local-node/index.js";
6
+ import type { SshLayer } from "../remote-node/index.js";
5
7
  export type { CliDependencies, CliErrorOutput, CliIo, CliSuccessOutput, CliSuccessResult, } from "../command-line/index.js";
6
8
  export type { CliHelpResult, CliVersionResult } from "../command-tree/index.js";
7
9
  export type { CliStatusResult } from "../status/index.js";
@@ -11,7 +13,11 @@ export type CliRemoteNode = {
11
13
  };
12
14
  export type CliDependencyResolver = (profile: string | undefined, remote?: CliRemoteNode) => CliDependencies;
13
15
  type CliDependencySource = CliDependencies | CliDependencyResolver;
16
+ export declare const resolveCommand: (parsed: ParsedArguments) => {
17
+ readonly node: TreeNode;
18
+ readonly rest: readonly string[];
19
+ };
14
20
  export declare const makeCli: (dependencies: CliDependencySource) => (arguments_: readonly string[], version: string, io: CliIo) => Effect.Effect<number>;
15
- export declare const makeCliDependencies: (connector?: CliNodeConnector) => CliDependencyResolver;
21
+ export declare const makeCliDependencies: (connector?: CliNodeConnector, ssh?: SshLayer) => CliDependencyResolver;
16
22
  export declare const runCli: (arguments_: readonly string[], version: string, io: CliIo) => Effect.Effect<number>;
17
23
  //# sourceMappingURL=cli.d.ts.map
package/dist/cli/cli.js CHANGED
@@ -49,7 +49,6 @@ const noInputFrom = (value) => value !== undefined && value !== "" && value !==
49
49
  const resolveOptions = (parsed, leaf, environment) => {
50
50
  const nodeBacked = isNodeBacked(leaf);
51
51
  const remote = nodeBacked && leaf.remote !== false;
52
- checkGlobalOptions(parsed, leaf, remote);
53
52
  const node = parsed.node ??
54
53
  (remote ? fromEnvironment("--node", environment.node) : undefined);
55
54
  const profile = parsed.profile ??
@@ -104,7 +103,7 @@ const reportFailures = (effect, context, tokens) => effect.pipe(Effect.catchDefe
104
103
  ? Effect.interrupt
105
104
  : Effect.sync(() => reportFailure(Cause.squash(cause), context, tokens))));
106
105
  const isHelpInvocation = (parsed) => parsed.help || parsed.tokens[0] === undefined || parsed.tokens[0] === "help";
107
- const runHelp = (input, parsed) => Effect.sync(() => {
106
+ const helpNode = (parsed) => {
108
107
  const strict = parsed.tokens[0] === "help";
109
108
  const end = parsed.tokens.indexOf("--");
110
109
  const tokens = end === -1 ? parsed.tokens : parsed.tokens.slice(0, end);
@@ -112,6 +111,10 @@ const runHelp = (input, parsed) => Effect.sync(() => {
112
111
  const { consumed, node } = findNode(path);
113
112
  if (consumed < path.length && (strict || node.forms.length === 0))
114
113
  throw new CliArgumentError(unknownPathMessage(path));
114
+ return node;
115
+ };
116
+ const runHelp = (input, parsed) => Effect.sync(() => {
117
+ const node = helpNode(parsed);
115
118
  const root = node.path.length === 0;
116
119
  writeSuccess(root
117
120
  ? createHelpTree(input.version)
@@ -125,6 +128,13 @@ const findLeaf = (typed) => {
125
128
  throw new CliArgumentError(unknownPathMessage(tokens));
126
129
  return { leaf: node, rest: tokens.slice(consumed) };
127
130
  };
131
+ export const resolveCommand = (parsed) => {
132
+ if (isHelpInvocation(parsed))
133
+ return { node: helpNode(parsed), rest: [] };
134
+ const { leaf, rest } = findLeaf(parsed.tokens);
135
+ checkGlobalOptions(parsed, leaf, isNodeBacked(leaf) && leaf.remote !== false);
136
+ return { node: leaf, rest };
137
+ };
128
138
  const leafProgram = (leaf, rest, context) => {
129
139
  const reference = leaf.run;
130
140
  if (reference === undefined)
@@ -167,7 +177,7 @@ const runParsed = (input, parsed) => {
167
177
  if (isHelpInvocation(parsed))
168
178
  return runHelp(input, parsed);
169
179
  return Effect.gen(function* () {
170
- const { leaf, rest } = findLeaf(parsed.tokens);
180
+ const { node: leaf, rest } = resolveCommand(parsed);
171
181
  const resolved = resolveOptions(parsed, leaf, yield* readEnvironment(leaf));
172
182
  if (parsed.node === undefined &&
173
183
  resolved.node !== undefined &&
@@ -255,9 +265,15 @@ const makeDefaultCliDependencies = (binding) => ({
255
265
  ...lazyDependencies(loadConnection, (module, node) => module.makeConnectionClient(node), {
256
266
  ...binding,
257
267
  names: [
268
+ "confirmConnectionGrant",
269
+ "confirmConnectionPool",
258
270
  "createConnection",
259
271
  "createGatewayConnection",
272
+ "listConnectionGrants",
273
+ "listConnectionPools",
260
274
  "listConnections",
275
+ "previewConnectionGrant",
276
+ "previewConnectionPool",
261
277
  "listConnectionModels",
262
278
  "showConnection",
263
279
  "showConnectionUsage",
@@ -413,6 +429,7 @@ const makeDefaultCliDependencies = (binding) => ({
413
429
  "sendAttachedSessionMessage",
414
430
  "showExecutionRelocation",
415
431
  "showSession",
432
+ "waitSession",
416
433
  "startSession",
417
434
  "stopSession",
418
435
  ],
@@ -479,6 +496,7 @@ const makeDefaultCliDependencies = (binding) => ({
479
496
  ...binding,
480
497
  names: [
481
498
  "confirmAgentChange",
499
+ "detectAgents",
482
500
  "listAgents",
483
501
  "previewAgentChange",
484
502
  "showAgent",
@@ -506,19 +524,20 @@ const makeDefaultCliDependencies = (binding) => ({
506
524
  }),
507
525
  ...lazyDependencies(loadStatus, (module, node) => module.makeStatusClient(node), { ...binding, names: ["createMonitorBootstrap", "readStatus"] }),
508
526
  });
509
- const remoteConnector = (remote, local) => {
527
+ const remoteConnector = (remote, local, ssh) => {
510
528
  const cache = {};
511
529
  return (options) => Effect.promise(loadRemoteNode).pipe(Effect.flatMap((module) => {
512
530
  cache.connector ??= module.makeRemoteNodeConnector({
513
531
  ...(local === undefined ? {} : { local }),
514
532
  name: remote.name,
515
533
  scope: remote.scope,
534
+ ...(ssh === undefined ? {} : { ssh }),
516
535
  });
517
536
  return cache.connector(options);
518
537
  }));
519
538
  };
520
539
  const remoteSignIn = (remote, binding) => (connection) => Effect.promise(loadRemoteNode).pipe(Effect.flatMap((module) => module.remoteVendorLogin({ ...binding, name: remote.name })(connection)));
521
- export const makeCliDependencies = (connector) => (profile, remote) => {
540
+ export const makeCliDependencies = (connector, ssh) => (profile, remote) => {
522
541
  const binding = {
523
542
  ...(connector === undefined ? {} : { connector }),
524
543
  ...(profile === undefined ? {} : { profile }),
@@ -528,7 +547,7 @@ export const makeCliDependencies = (connector) => (profile, remote) => {
528
547
  : {
529
548
  ...makeDefaultCliDependencies({
530
549
  ...binding,
531
- connector: remoteConnector(remote, connector),
550
+ connector: remoteConnector(remote, connector, ssh),
532
551
  remote: true,
533
552
  }),
534
553
  runVendorLogin: remoteSignIn(remote, binding),
@@ -1,2 +1,2 @@
1
- export { type CliDependencies, type CliDependencyResolver, type CliErrorOutput, type CliHelpResult, type CliIo, type CliStatusResult, type CliSuccessOutput, type CliSuccessResult, type CliVersionResult, makeCli, makeCliDependencies, runCli, } from "./cli.js";
1
+ export { type CliDependencies, type CliDependencyResolver, type CliErrorOutput, type CliHelpResult, type CliIo, type CliStatusResult, type CliSuccessOutput, type CliSuccessResult, type CliVersionResult, makeCli, makeCliDependencies, resolveCommand, runCli, } from "./cli.js";
2
2
  //# sourceMappingURL=index.d.ts.map
package/dist/cli/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { makeCli, makeCliDependencies, runCli, } from "./cli.js";
1
+ export { makeCli, makeCliDependencies, resolveCommand, runCli, } from "./cli.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -166,6 +166,7 @@ export type CliDependencies = Partial<AgentsCliDependencies & ApprovalCliDepende
166
166
  readonly sshLayer?: SshLayer;
167
167
  readonly startSession: (input: StartSessionInput) => CliNodeEffect<SessionStartResult>;
168
168
  readonly stopSession?: (input: StartSessionInput) => CliNodeEffect<SessionStopResult>;
169
+ readonly waitSession?: SessionClient["waitSession"];
169
170
  readonly waitTurns?: (input: WaitTurnsInput) => CliNodeEffect<TurnWaitResult>;
170
171
  readonly writeTerminalInput: (input: Parameters<TerminalClient["writeTerminalInput"]>[0]) => CliNodeEffect<LiveTerminalWriteResult>;
171
172
  };
@@ -1,7 +1,7 @@
1
1
  export { type CliDependencies, type CliServices, type CommandContext, type CommandEffect, LOCAL_NODE, } from "./context.js";
2
- export { argumentsAreBounded, type ArgumentToken, CliArgumentError, missingArgument, parseArguments, type ParsedArguments, type ParsedOptions, parseOptions, readBoundedStdin, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, recoverStdin, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./input/index.js";
2
+ export { argumentsAreBounded, type ArgumentToken, CliArgumentError, missingArgument, parseArguments, type ParsedArguments, type ParsedOptions, parseOptions, parseOptionsWith, readBoundedStdin, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, readWaitTimeoutSeconds, recoverStdin, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./input/index.js";
3
3
  export { decodeJsonText, jsonLine } from "./json.js";
4
4
  export { type CliCommandOutput, type CliErrorOutput, type CliIo, type CliResolution, type CliSuccessOutput, type CliSuccessResult, exitCodeOf, type NodeResultPresenter, reportError, writeNodeResult, writeSuccess, } from "./output.js";
5
- export { block, cell, type CliTable, fields, formatRows, tab, withNextPage, } from "./rows.js";
5
+ export { block, cell, type CliTable, fields, formatRows, tab, withNextPage, withPrunedHistory, } from "./rows.js";
6
6
  export { askToConfirm, canPrompt, confirmationOf, confirmParameters, EXIT_CANCELLED, peekStdin, promptOrRefuse, readInputMode, readPipedPreview, readTwoPhaseMode, requestedTwoPhaseMode, runInputTwoPhase, runTwoPhase, TWO_PHASE_FLAGS, type TwoPhaseMode, } from "./two-phase.js";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,7 +1,7 @@
1
1
  export { LOCAL_NODE, } from "./context.js";
2
- export { argumentsAreBounded, CliArgumentError, missingArgument, parseArguments, parseOptions, readBoundedStdin, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, recoverStdin, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./input/index.js";
2
+ export { argumentsAreBounded, CliArgumentError, missingArgument, parseArguments, parseOptions, parseOptionsWith, readBoundedStdin, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, readWaitTimeoutSeconds, recoverStdin, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./input/index.js";
3
3
  export { decodeJsonText, jsonLine } from "./json.js";
4
4
  export { exitCodeOf, reportError, writeNodeResult, writeSuccess, } from "./output.js";
5
- export { block, cell, fields, formatRows, tab, withNextPage, } from "./rows.js";
5
+ export { block, cell, fields, formatRows, tab, withNextPage, withPrunedHistory, } from "./rows.js";
6
6
  export { askToConfirm, canPrompt, confirmationOf, confirmParameters, EXIT_CANCELLED, peekStdin, promptOrRefuse, readInputMode, readPipedPreview, readTwoPhaseMode, requestedTwoPhaseMode, runInputTwoPhase, runTwoPhase, TWO_PHASE_FLAGS, } from "./two-phase.js";
7
7
  //# sourceMappingURL=index.js.map
@@ -24,6 +24,12 @@ export declare const argumentsAreBounded: (arguments_: readonly string[]) => boo
24
24
  type ValueOption = "--node" | "--profile";
25
25
  export declare const readGlobalValue: (option: ValueOption, value: string | undefined) => string;
26
26
  export declare const parseArguments: (arguments_: readonly string[]) => ParsedArguments;
27
+ export type OptionSpec = {
28
+ readonly allowed: ReadonlySet<string>;
29
+ readonly allowedFlags: ReadonlySet<string>;
30
+ readonly repeatable: ReadonlySet<string>;
31
+ };
32
+ export declare const parseOptionsWith: (tokens: readonly string[], spec: OptionSpec) => ParsedOptions;
27
33
  export declare const parseOptions: (tokens: readonly string[], allowed: ReadonlySet<string>, allowedFlags?: ReadonlySet<string>) => ParsedOptions;
28
34
  export declare const requirePositionals: (positionals: readonly string[], count: number) => void;
29
35
  export declare const missingArgument: () => CliArgumentError;
@@ -37,6 +43,7 @@ export declare const readDuration: (value: string, option: `--${string}`, range:
37
43
  readonly max: number;
38
44
  readonly min: number;
39
45
  }) => number;
46
+ export declare const readWaitTimeoutSeconds: (value: string | undefined) => number;
40
47
  export type ArgumentToken = {
41
48
  readonly index: number;
42
49
  readonly inline: boolean;
@@ -77,13 +77,20 @@ export const parseArguments = (arguments_) => {
77
77
  tokens: [...scan.tokens, ...(end === -1 ? [] : arguments_.slice(end))],
78
78
  };
79
79
  };
80
+ const takeOptionValue = (state, token) => {
81
+ const { options, pendingOption } = state;
82
+ if (pendingOption === undefined)
83
+ return;
84
+ if (token.startsWith("--")) {
85
+ throw new CliArgumentError(`Option '${pendingOption}' requires a value.`);
86
+ }
87
+ const earlier = options.get(pendingOption);
88
+ options.set(pendingOption, earlier === undefined ? token : `${earlier},${token}`);
89
+ delete state.pendingOption;
90
+ };
80
91
  const parseOptionToken = (state, token) => {
81
92
  if (state.pendingOption !== undefined) {
82
- if (token.startsWith("--")) {
83
- throw new CliArgumentError(`Option '${state.pendingOption}' requires a value.`);
84
- }
85
- state.options.set(state.pendingOption, token);
86
- delete state.pendingOption;
93
+ takeOptionValue(state, token);
87
94
  return;
88
95
  }
89
96
  if (!token.startsWith("--")) {
@@ -100,7 +107,7 @@ const parseOptionToken = (state, token) => {
100
107
  if (!state.allowed.has(token)) {
101
108
  throw new CliArgumentError("The command contains an unknown option.");
102
109
  }
103
- if (state.options.has(token)) {
110
+ if (state.options.has(token) && !state.repeatable.has(token)) {
104
111
  throw new CliArgumentError(`Option '${token}' may be used only once.`);
105
112
  }
106
113
  state.pendingOption = token;
@@ -112,16 +119,15 @@ const splitInlineValue = (token, allowed) => {
112
119
  const name = token.slice(0, separator);
113
120
  return allowed.has(name) ? [name, token.slice(separator + 1)] : [token];
114
121
  };
115
- export const parseOptions = (tokens, allowed, allowedFlags = new Set()) => {
122
+ export const parseOptionsWith = (tokens, spec) => {
116
123
  const state = {
117
- allowed,
118
- allowedFlags,
124
+ ...spec,
119
125
  flags: new Set(),
120
126
  options: new Map(),
121
127
  positionals: [],
122
128
  };
123
129
  tokens
124
- .flatMap((token) => splitInlineValue(token, allowed))
130
+ .flatMap((token) => splitInlineValue(token, spec.allowed))
125
131
  .forEach((token) => {
126
132
  parseOptionToken(state, token);
127
133
  });
@@ -134,6 +140,7 @@ export const parseOptions = (tokens, allowed, allowedFlags = new Set()) => {
134
140
  positionals: state.positionals,
135
141
  };
136
142
  };
143
+ export const parseOptions = (tokens, allowed, allowedFlags = new Set()) => parseOptionsWith(tokens, { allowed, allowedFlags, repeatable: new Set() });
137
144
  export const requirePositionals = (positionals, count) => {
138
145
  if (positionals.length === count)
139
146
  return;
@@ -191,6 +198,11 @@ export const readDuration = (value, option, range) => {
191
198
  throw new CliArgumentError(`Option '${option}' must be a duration from ${describeSeconds(range.min)} to ${describeSeconds(range.max)}, such as 30s, 10m or 1h.`);
192
199
  return seconds;
193
200
  };
201
+ const DEFAULT_WAIT_SECONDS = 600;
202
+ const MAX_WAIT_SECONDS = 86_400;
203
+ export const readWaitTimeoutSeconds = (value) => value === undefined
204
+ ? DEFAULT_WAIT_SECONDS
205
+ : readDuration(value, "--timeout", { max: MAX_WAIT_SECONDS, min: 1 });
194
206
  const tokenRole = (token, index, valueOptions) => {
195
207
  if (!token.startsWith("--"))
196
208
  return { index, kind: "positional" };
@@ -1,4 +1,4 @@
1
- export { argumentsAreBounded, type ArgumentToken, CliArgumentError, missingArgument, parseArguments, type ParsedArguments, type ParsedOptions, parseOptions, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./arguments.js";
1
+ export { argumentsAreBounded, type ArgumentToken, CliArgumentError, missingArgument, parseArguments, type ParsedArguments, type ParsedOptions, parseOptions, parseOptionsWith, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, readWaitTimeoutSeconds, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./arguments.js";
2
2
  export { promptLine, type PromptOptions, terminalIsInteractive, } from "./prompt.js";
3
3
  export { type BoundedStdinRequest, readBoundedStdin, recoverStdin, replayStdin, } from "./stdin.js";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- export { argumentsAreBounded, CliArgumentError, missingArgument, parseArguments, parseOptions, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./arguments.js";
1
+ export { argumentsAreBounded, CliArgumentError, missingArgument, parseArguments, parseOptions, parseOptionsWith, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, readWaitTimeoutSeconds, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./arguments.js";
2
2
  export { promptLine, terminalIsInteractive, } from "./prompt.js";
3
3
  export { readBoundedStdin, recoverStdin, replayStdin, } from "./stdin.js";
4
4
  //# sourceMappingURL=index.js.map
@@ -8,5 +8,6 @@ export type CliTable = {
8
8
  readonly headers: readonly string[];
9
9
  };
10
10
  export declare const formatRows: <TValue>(items: readonly TValue[], format: (value: TValue) => string, text?: CliTable | string) => string;
11
+ export declare const withPrunedHistory: (text: string, oldest?: string) => string;
11
12
  export declare const withNextPage: (text: string, nextCursor?: string) => string;
12
13
  //# sourceMappingURL=rows.d.ts.map
@@ -37,5 +37,8 @@ export const formatRows = (items, format, text) => {
37
37
  ? align([text.headers, ...lines.map((line) => line.split("\t"))])
38
38
  : `${lines.join("\n")}\n`;
39
39
  };
40
+ export const withPrunedHistory = (text, oldest) => oldest === undefined
41
+ ? text
42
+ : `earlier history pruned; oldest retained cursor ${oldest}\n${text}`;
40
43
  export const withNextPage = (text, nextCursor) => nextCursor === undefined ? text : `${text}next: --after ${nextCursor}\n`;
41
44
  //# sourceMappingURL=rows.js.map
@@ -53,7 +53,7 @@ export const runReceiptShow = (tokens, context) => Effect.gen(function* () {
53
53
  command: "receipt.show",
54
54
  result: value,
55
55
  }),
56
- toText: ({ result: { receipt } }) => `${receipt.receiptId}\t${receipt.state}\t${receipt.target.type}:${receipt.target.id}\n`,
56
+ toText: ({ result: { eventsPruned, receipt } }) => `${receipt.receiptId}\t${receipt.state}\t${receipt.target.type}:${receipt.target.id}${eventsPruned === true ? "\tevents-pruned" : ""}\n`,
57
57
  });
58
58
  });
59
59
  //# sourceMappingURL=command.js.map
@@ -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