@maiaos/cli 0.1.0-canary.5 → 0.1.0-canary.51

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 (114) hide show
  1. package/README.md +2 -2
  2. package/dist/agents/client.d.ts +47 -27
  3. package/dist/agents/client.js +10 -3
  4. package/dist/agents/commands.d.ts +1 -0
  5. package/dist/agents/commands.js +24 -2
  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 +11 -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 +19 -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 +2 -1
  21. package/dist/command-line/emit/index.d.ts +4 -0
  22. package/dist/command-line/emit/index.js +4 -0
  23. package/dist/command-line/{output.d.ts → emit/output.d.ts} +2 -2
  24. package/dist/command-line/{rows.d.ts → emit/rows.d.ts} +1 -0
  25. package/dist/command-line/{rows.js → emit/rows.js} +3 -0
  26. package/dist/command-line/index.d.ts +4 -4
  27. package/dist/command-line/index.js +4 -4
  28. package/dist/command-line/input/arguments.d.ts +10 -0
  29. package/dist/command-line/input/arguments.js +30 -10
  30. package/dist/command-line/input/index.d.ts +1 -1
  31. package/dist/command-line/input/index.js +1 -1
  32. package/dist/command-line/two-phase.js +1 -1
  33. package/dist/command-receipt/command.js +1 -1
  34. package/dist/command-tree/tree.d.ts +1 -1
  35. package/dist/command-tree/tree.js +3 -1
  36. package/dist/connection/input.js +2 -2
  37. package/dist/connection/system.js +3 -2
  38. package/dist/connection/tree/tree.js +5 -5
  39. package/dist/events/commands.d.ts +11 -0
  40. package/dist/events/commands.js +64 -0
  41. package/dist/events/index.d.ts +2 -0
  42. package/dist/events/index.js +2 -0
  43. package/dist/events/tree/index.d.ts +2 -0
  44. package/dist/events/tree/index.js +2 -0
  45. package/dist/events/tree/tree.d.ts +10 -0
  46. package/dist/events/tree/tree.js +17 -0
  47. package/dist/import/commands.js +1 -1
  48. package/dist/import/input.d.ts +4 -1
  49. package/dist/import/input.js +23 -2
  50. package/dist/import/output.js +3 -1
  51. package/dist/local-node/client.d.ts +1 -0
  52. package/dist/local-node/client.js +1 -0
  53. package/dist/local-node/index.d.ts +2 -1
  54. package/dist/local-node/index.js +2 -1
  55. package/dist/local-node/wait.d.ts +10 -0
  56. package/dist/local-node/wait.js +17 -0
  57. package/dist/login/gateway.js +2 -2
  58. package/dist/login/vendor-input.js +2 -2
  59. package/dist/mcp/calls.js +6 -1
  60. package/dist/mcp/routing.js +1 -0
  61. package/dist/project-guard/client.d.ts +12 -0
  62. package/dist/project-guard/input.d.ts +3 -0
  63. package/dist/project-guard/input.js +15 -1
  64. package/dist/project-guard/output/format.js +5 -0
  65. package/dist/project-workspace/tree/tree.js +1 -1
  66. package/dist/reference/resolve.js +9 -2
  67. package/dist/remote-node/connector.js +8 -1
  68. package/dist/run-ledger/client.d.ts +2 -0
  69. package/dist/session/agent-permission.d.ts +2 -2
  70. package/dist/session/approval/client.d.ts +5 -2
  71. package/dist/session/approval/client.js +2 -2
  72. package/dist/session/approval/commands.js +29 -15
  73. package/dist/session/client.d.ts +14 -3
  74. package/dist/session/client.js +17 -2
  75. package/dist/session/commands.d.ts +1 -0
  76. package/dist/session/commands.js +125 -9
  77. package/dist/session/create-tasks.js +10 -2
  78. package/dist/session/index.d.ts +1 -1
  79. package/dist/session/index.js +1 -1
  80. package/dist/session/output/human.d.ts +3 -0
  81. package/dist/session/output/human.js +20 -4
  82. package/dist/session/output/index.d.ts +1 -1
  83. package/dist/session/output/index.js +1 -1
  84. package/dist/session/output/tasks.d.ts +2 -0
  85. package/dist/session/output/tasks.js +34 -4
  86. package/dist/session/tree/tree.js +23 -12
  87. package/dist/session/turn/client.js +7 -9
  88. package/dist/session/turn/commands.js +67 -20
  89. package/dist/session/turn/output.d.ts +6 -0
  90. package/dist/session/turn/output.js +12 -2
  91. package/dist/status/client.d.ts +14 -3
  92. package/dist/status/command.js +3 -1
  93. package/dist/status/doctor.d.ts +5 -1
  94. package/dist/status/doctor.js +10 -4
  95. package/dist/status/output/compact.d.ts +3 -0
  96. package/dist/status/output/compact.js +17 -7
  97. package/dist/status/output/human.js +15 -0
  98. package/dist/terminal/control-commands.js +26 -9
  99. package/dist/terminal/keys.d.ts +12 -0
  100. package/dist/terminal/keys.js +62 -0
  101. package/dist/terminal/output/compact-list.d.ts +1 -0
  102. package/dist/terminal/output/compact-list.js +3 -0
  103. package/dist/terminal/output/human.js +2 -2
  104. package/dist/terminal/tree/tree.js +1 -1
  105. package/guidance/maia-cli/SKILL.md +1 -1
  106. package/guidance/maia-node/SKILL.md +54 -0
  107. package/guidance/maia-orchestration/SKILL.md +1 -2
  108. package/guidance/maia-sessions/SKILL.md +69 -0
  109. package/package.json +4 -4
  110. /package/dist/command-line/{json-decoder.d.ts → emit/json-decoder.d.ts} +0 -0
  111. /package/dist/command-line/{json-decoder.js → emit/json-decoder.js} +0 -0
  112. /package/dist/command-line/{json.d.ts → emit/json.d.ts} +0 -0
  113. /package/dist/command-line/{json.js → emit/json.js} +0 -0
  114. /package/dist/command-line/{output.js → emit/output.js} +0 -0
@@ -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 &&
@@ -419,6 +429,7 @@ const makeDefaultCliDependencies = (binding) => ({
419
429
  "sendAttachedSessionMessage",
420
430
  "showExecutionRelocation",
421
431
  "showSession",
432
+ "waitSession",
422
433
  "startSession",
423
434
  "stopSession",
424
435
  ],
@@ -485,6 +496,7 @@ const makeDefaultCliDependencies = (binding) => ({
485
496
  ...binding,
486
497
  names: [
487
498
  "confirmAgentChange",
499
+ "detectAgents",
488
500
  "listAgents",
489
501
  "previewAgentChange",
490
502
  "showAgent",
@@ -512,19 +524,20 @@ const makeDefaultCliDependencies = (binding) => ({
512
524
  }),
513
525
  ...lazyDependencies(loadStatus, (module, node) => module.makeStatusClient(node), { ...binding, names: ["createMonitorBootstrap", "readStatus"] }),
514
526
  });
515
- const remoteConnector = (remote, local) => {
527
+ const remoteConnector = (remote, local, ssh) => {
516
528
  const cache = {};
517
529
  return (options) => Effect.promise(loadRemoteNode).pipe(Effect.flatMap((module) => {
518
530
  cache.connector ??= module.makeRemoteNodeConnector({
519
531
  ...(local === undefined ? {} : { local }),
520
532
  name: remote.name,
521
533
  scope: remote.scope,
534
+ ...(ssh === undefined ? {} : { ssh }),
522
535
  });
523
536
  return cache.connector(options);
524
537
  }));
525
538
  };
526
539
  const remoteSignIn = (remote, binding) => (connection) => Effect.promise(loadRemoteNode).pipe(Effect.flatMap((module) => module.remoteVendorLogin({ ...binding, name: remote.name })(connection)));
527
- export const makeCliDependencies = (connector) => (profile, remote) => {
540
+ export const makeCliDependencies = (connector, ssh) => (profile, remote) => {
528
541
  const binding = {
529
542
  ...(connector === undefined ? {} : { connector }),
530
543
  ...(profile === undefined ? {} : { profile }),
@@ -534,7 +547,7 @@ export const makeCliDependencies = (connector) => (profile, remote) => {
534
547
  : {
535
548
  ...makeDefaultCliDependencies({
536
549
  ...binding,
537
- connector: remoteConnector(remote, connector),
550
+ connector: remoteConnector(remote, connector, ssh),
538
551
  remote: true,
539
552
  }),
540
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
@@ -25,8 +25,8 @@ import type { InteractionCliDependencies } from "../session/interaction/index.js
25
25
  import type { CancelTurnInput, InterruptTurnInput, SendTurnInput, WaitTurnsInput } from "../session/turn/index.js";
26
26
  import type { BootstrapCliDependencies } from "../team-workspace/index.js";
27
27
  import type { CreateTerminalInput, makeTerminalClient } from "../terminal/index.js";
28
+ import type { CliIo, CliResolution } from "./emit/index.js";
28
29
  import type { CliArgumentError } from "./input/index.js";
29
- import type { CliIo, CliResolution } from "./output.js";
30
30
  type OrchestrationClient = ReturnType<typeof makeOrchestrationClient>;
31
31
  type SessionClient = ReturnType<typeof makeSessionClient>;
32
32
  type TerminalClient = ReturnType<typeof makeTerminalClient>;
@@ -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
  };
@@ -0,0 +1,4 @@
1
+ export { decodeJsonText, jsonLine } from "./json.js";
2
+ export { type CliCommandOutput, type CliErrorOutput, type CliIo, type CliResolution, type CliSuccessOutput, type CliSuccessResult, exitCodeOf, type NodeResultPresenter, type OutputContext, reportError, writeNodeResult, writeSuccess, } from "./output.js";
3
+ export { block, cell, type CliTable, fields, formatRows, tab, withNextPage, withPrunedHistory, } from "./rows.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ export { decodeJsonText, jsonLine } from "./json.js";
2
+ export { exitCodeOf, reportError, writeNodeResult, writeSuccess, } from "./output.js";
3
+ export { block, cell, fields, formatRows, tab, withNextPage, withPrunedHistory, } from "./rows.js";
4
+ //# sourceMappingURL=index.js.map
@@ -1,8 +1,8 @@
1
1
  import type { NodeHolding } from "@maiaos/client-core/cockpit";
2
2
  import type { ProtocolError } from "@maiaos/sdk";
3
3
  import type * as Effect from "effect/Effect";
4
- import type { CliMutationRecovery, CliNodeResult } from "../local-node/index.js";
5
- import type { BoundedStdinRequest, CliArgumentError, PromptOptions } from "./input/index.js";
4
+ import type { CliMutationRecovery, CliNodeResult } from "../../local-node/index.js";
5
+ import type { BoundedStdinRequest, CliArgumentError, PromptOptions } from "../input/index.js";
6
6
  export type CliIo = {
7
7
  readonly cwd?: string;
8
8
  readonly interactive?: boolean;
@@ -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
@@ -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";
3
- export { decodeJsonText, jsonLine } from "./json.js";
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";
2
+ export { decodeJsonText, jsonLine } from "./emit/index.js";
3
+ export { type CliCommandOutput, type CliErrorOutput, type CliIo, type CliResolution, type CliSuccessOutput, type CliSuccessResult, exitCodeOf, type NodeResultPresenter, reportError, writeNodeResult, writeSuccess, } from "./emit/index.js";
4
+ export { block, cell, type CliTable, fields, formatRows, tab, withNextPage, withPrunedHistory, } from "./emit/index.js";
5
+ export { argumentsAreBounded, type ArgumentToken, CliArgumentError, missingArgument, parseArguments, type ParsedArguments, type ParsedOptions, parseOptions, parseOptionsWith, readBoundedStdin, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readPermission, readRevisionOption, readWaitTimeoutSeconds, recoverStdin, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./input/index.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";
3
- export { decodeJsonText, jsonLine } from "./json.js";
4
- export { exitCodeOf, reportError, writeNodeResult, writeSuccess, } from "./output.js";
5
- export { block, cell, fields, formatRows, tab, withNextPage, } from "./rows.js";
2
+ export { decodeJsonText, jsonLine } from "./emit/index.js";
3
+ export { exitCodeOf, reportError, writeNodeResult, writeSuccess, } from "./emit/index.js";
4
+ export { block, cell, fields, formatRows, tab, withNextPage, withPrunedHistory, } from "./emit/index.js";
5
+ export { argumentsAreBounded, CliArgumentError, missingArgument, parseArguments, parseOptions, parseOptionsWith, readBoundedStdin, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readPermission, readRevisionOption, readWaitTimeoutSeconds, recoverStdin, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./input/index.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;
@@ -32,11 +38,15 @@ export declare const requireNoArguments: (tokens: readonly string[], command: st
32
38
  export declare const readPageSize: (value: string | undefined, maximum?: number) => number;
33
39
  export declare const readCursor: (value?: string) => string;
34
40
  export declare const readRevisionOption: (value: string | undefined, option: `--${string}`) => string;
41
+ export declare const readPermission: <TPermission extends string>(permission: string | undefined, validate: (permission: string) => TPermission | undefined) => {
42
+ readonly permission?: TPermission;
43
+ };
35
44
  export declare const readExpectedRevision: (value: string | undefined) => string;
36
45
  export declare const readDuration: (value: string, option: `--${string}`, range: {
37
46
  readonly max: number;
38
47
  readonly min: number;
39
48
  }) => number;
49
+ export declare const readWaitTimeoutSeconds: (value: string | undefined) => number;
40
50
  export type ArgumentToken = {
41
51
  readonly index: number;
42
52
  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;
@@ -170,6 +177,14 @@ export const readRevisionOption = (value, option) => {
170
177
  }
171
178
  return readInt64(value, `Option '${option}' must be a non-negative signed 64-bit integer.`);
172
179
  };
180
+ export const readPermission = (permission, validate) => {
181
+ if (permission === undefined)
182
+ return {};
183
+ const valid = validate(permission);
184
+ if (valid === undefined)
185
+ throw new CliArgumentError("Option '--permission' must be a permission mode Claude Code or Codex defines.");
186
+ return { permission: valid };
187
+ };
173
188
  export const readExpectedRevision = (value) => readRevisionOption(value, "--expected-revision");
174
189
  const DURATION = /^([1-9]\d{0,5})(s|m|h)$/u;
175
190
  const unitSeconds = (unit) => {
@@ -191,6 +206,11 @@ export const readDuration = (value, option, range) => {
191
206
  throw new CliArgumentError(`Option '${option}' must be a duration from ${describeSeconds(range.min)} to ${describeSeconds(range.max)}, such as 30s, 10m or 1h.`);
192
207
  return seconds;
193
208
  };
209
+ const DEFAULT_WAIT_SECONDS = 600;
210
+ const MAX_WAIT_SECONDS = 86_400;
211
+ export const readWaitTimeoutSeconds = (value) => value === undefined
212
+ ? DEFAULT_WAIT_SECONDS
213
+ : readDuration(value, "--timeout", { max: MAX_WAIT_SECONDS, min: 1 });
194
214
  const tokenRole = (token, index, valueOptions) => {
195
215
  if (!token.startsWith("--"))
196
216
  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, readPermission, 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, readPermission, 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
@@ -1,8 +1,8 @@
1
1
  import * as Cause from "effect/Cause";
2
2
  import * as Effect from "effect/Effect";
3
3
  import * as Exit from "effect/Exit";
4
+ import { decodeJsonText } from "./emit/index.js";
4
5
  import { CliArgumentError, parseOptions, recoverStdin, replayStdin, requirePositionals, } from "./input/index.js";
5
- import { decodeJsonText } from "./json.js";
6
6
  export const TWO_PHASE_FLAGS = [
7
7
  "--confirm-stdin",
8
8
  "--dry-run",
@@ -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
@@ -20,7 +20,7 @@ export type TreeNode = {
20
20
  readonly summary: string;
21
21
  };
22
22
  export declare const TREE_FRAGMENTS: readonly TreeFragment[];
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
+ 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", "events", "context"]], readonly ["Clients and local", readonly ["presentation", "mcp", "dashboard", "agent", "help", "version", "doctor", "completion"]]];
24
24
  export declare const usagePath: (usage: string) => readonly string[];
25
25
  export declare const COMMAND_TREE: TreeNode;
26
26
  export declare const commandTree: () => TreeNode;
@@ -1,6 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { AGENTS_TREE } from "../agents/tree/index.js";
3
3
  import { CONNECTION_TREE } from "../connection/tree/index.js";
4
+ import { EVENTS_TREE } from "../events/tree/index.js";
4
5
  import { EXECUTION_TREE } from "../execution/tree/index.js";
5
6
  import { SAFETY_TREE } from "../hold/tree/index.js";
6
7
  import { RUN_TREE } from "../orchestration/tree/index.js";
@@ -19,6 +20,7 @@ export const TREE_FRAGMENTS = [
19
20
  ROUTINE_TREE,
20
21
  PROJECT_TREE,
21
22
  REFERENCE_TREE,
23
+ EVENTS_TREE,
22
24
  TERMINAL_TREE,
23
25
  EXECUTION_TREE,
24
26
  SAFETY_TREE,
@@ -42,7 +44,7 @@ export const TREE_SECTIONS = [
42
44
  ],
43
45
  ],
44
46
  ["Accounts and Nodes", ["connection", "integration", "provider", "node"]],
45
- ["Safety and audit", ["hold", "receipt", "context"]],
47
+ ["Safety and audit", ["hold", "receipt", "events", "context"]],
46
48
  [
47
49
  "Clients and local",
48
50
  [
@@ -2,8 +2,8 @@ import { CliArgumentError, parseOptions, readExpectedRevision, readPageSize, req
2
2
  const readSessionLimit = (value) => {
3
3
  if (value === undefined)
4
4
  return {};
5
- if (!/^(?:[1-9]|1[0-6])$/u.test(value))
6
- throw new CliArgumentError("Option '--max-sessions' must be an integer from 1 to 16.");
5
+ if (!/^(?:[1-9]|[1-5][0-9]|6[0-4])$/u.test(value))
6
+ throw new CliArgumentError("Option '--max-sessions' must be an integer from 1 to 64.");
7
7
  return { maxConcurrentSessions: Number(value) };
8
8
  };
9
9
  const requireOption = (options, name) => {
@@ -146,8 +146,9 @@ const confirmedText = (result) => result.items
146
146
  const readSetup = (parsed) => {
147
147
  requirePositionals(parsed.positionals, 0);
148
148
  const sessions = parsed.options.get("--max-sessions");
149
- if (sessions !== undefined && !/^(?:[1-9]|1[0-6])$/u.test(sessions))
150
- throw new CliArgumentError("--max-sessions must be 1 to 16.");
149
+ if (sessions !== undefined &&
150
+ !/^(?:[1-9]|[1-5][0-9]|6[0-4])$/u.test(sessions))
151
+ throw new CliArgumentError("--max-sessions must be 1 to 64.");
151
152
  return {
152
153
  commandId: parsed.options.get("--command-id"),
153
154
  ...(sessions === undefined
@@ -23,7 +23,7 @@ export const CONNECTION_TREE = {
23
23
  ],
24
24
  leaves: [
25
25
  [
26
- "setup [--max-sessions <1..16>] [--command-id <id>] [--dry-run | --confirm-stdin | --yes]",
26
+ "setup [--max-sessions <1..64>] [--command-id <id>] [--dry-run | --confirm-stdin | --yes]",
27
27
  1,
28
28
  ["connection.system.preview", "connection.system.confirm"],
29
29
  "Use installed vendor CLIs as system-default accounts.",
@@ -41,7 +41,7 @@ export const CONNECTION_TREE = {
41
41
  { kind: "composite", run: loginRunner },
42
42
  ],
43
43
  [
44
- "login <claude|codex> [--name <name>] [--device-code] [--max-sessions <1..16>]",
44
+ "login <claude|codex> [--name <name>] [--device-code] [--max-sessions <1..64>]",
45
45
  1,
46
46
  "",
47
47
  "Add or re-sign a Claude Code or Codex account.",
@@ -59,14 +59,14 @@ export const CONNECTION_TREE = {
59
59
  { kind: "composite", run: loginRunner },
60
60
  ],
61
61
  [
62
- "login gateway --name <name> --base-url <url> --api-key-stdin [--max-sessions <1..16>] [--command-id <id>]",
62
+ "login gateway --name <name> --base-url <url> --api-key-stdin [--max-sessions <1..64>] [--command-id <id>]",
63
63
  1,
64
64
  "connection.gateway.create",
65
65
  "Add a gateway Connection with its API key.",
66
66
  { run: [login, "runLoginGateway"] },
67
67
  ],
68
68
  [
69
- "connection create --name <name> --executor <codex-cli|claude-code> --root <maia-managed|system-default> [--max-sessions <1..16>] [--command-id <id>]",
69
+ "connection create --name <name> --executor <codex-cli|claude-code> --root <maia-managed|system-default> [--max-sessions <1..64>] [--command-id <id>]",
70
70
  1,
71
71
  "connection.create",
72
72
  "Create a worker account Connection.",
@@ -133,7 +133,7 @@ export const CONNECTION_TREE = {
133
133
  { run: [connection, "runConnectionModelsList"] },
134
134
  ],
135
135
  [
136
- "connection capacity set <connection> --max-sessions <1..16> --expected-revision <revision> [--command-id <id>]",
136
+ "connection capacity set <connection> --max-sessions <1..64> --expected-revision <revision> [--command-id <id>]",
137
137
  1,
138
138
  "connection.capacity.set",
139
139
  "Set a Connection's Session limit.",
@@ -0,0 +1,11 @@
1
+ import * as Effect from "effect/Effect";
2
+ import { type OutputContext } from "../command-line/emit/index.js";
3
+ import type { CliNodeCall } from "../local-node/index.js";
4
+ type EventsContext = OutputContext & {
5
+ readonly dependencies: {
6
+ readonly call?: CliNodeCall;
7
+ };
8
+ };
9
+ export declare const runEventsRead: (tokens: readonly string[], context: EventsContext) => Effect.Effect<number, never, import("effect/Crypto").Crypto>;
10
+ export {};
11
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1,64 @@
1
+ import { findEventKind, localNodeRequestPayloadSchema, SESSION_ACTIVITY_SUBJECT_TYPE, } from "@maiaos/sdk";
2
+ import * as Effect from "effect/Effect";
3
+ import { cell, writeNodeResult, } from "../command-line/emit/index.js";
4
+ import { CliArgumentError, parseOptionsWith, readPageSize, requirePositionals, } from "../command-line/input/index.js";
5
+ const MAX_LIMIT = 100;
6
+ const readSubject = (value) => {
7
+ const split = value.indexOf(":");
8
+ if (split < 1 || split === value.length - 1)
9
+ throw new CliArgumentError("Option '--subject' must be <type>:<id>.");
10
+ const type = value.slice(0, split);
11
+ if (type !== SESSION_ACTIVITY_SUBJECT_TYPE)
12
+ throw new CliArgumentError(`Option '--subject' type must be ${SESSION_ACTIVITY_SUBJECT_TYPE}.`);
13
+ return { id: value.slice(split + 1), type };
14
+ };
15
+ const readKinds = (value) => {
16
+ const kinds = value.split(",");
17
+ const unknown = kinds.find((kind) => findEventKind(kind) === undefined);
18
+ if (unknown !== undefined)
19
+ throw new CliArgumentError(`Unknown event kind '${unknown}'.`);
20
+ return kinds;
21
+ };
22
+ const readParameters = (tokens) => {
23
+ const parsed = parseOptionsWith(tokens, {
24
+ allowed: new Set(["--kind", "--limit", "--since", "--subject"]),
25
+ allowedFlags: new Set(),
26
+ repeatable: new Set(["--kind"]),
27
+ });
28
+ requirePositionals(parsed.positionals, 0);
29
+ const kind = parsed.options.get("--kind");
30
+ const limit = parsed.options.get("--limit");
31
+ const since = parsed.options.get("--since");
32
+ const subject = parsed.options.get("--subject");
33
+ const parameters = {
34
+ ...(kind === undefined ? {} : { kinds: readKinds(kind) }),
35
+ ...(limit === undefined ? {} : { limit: readPageSize(limit, MAX_LIMIT) }),
36
+ ...(since === undefined ? {} : { since }),
37
+ ...(subject === undefined ? {} : { subject: readSubject(subject) }),
38
+ };
39
+ if (!localNodeRequestPayloadSchema.safeParse({
40
+ method: "events.read",
41
+ parameters,
42
+ }).success)
43
+ throw new CliArgumentError("Options '--kind', '--since' and '--subject' must be valid event filters.");
44
+ return parameters;
45
+ };
46
+ const formatResult = (value) => {
47
+ if (value.status === "invalid_cursor")
48
+ return "invalid cursor; read again without --since\n";
49
+ if (value.status === "cursor_reset_required")
50
+ return `cursor reset (${value.reason}); resume with --since ${value.next}\n`;
51
+ const lines = value.events.map((event) => `${event.seq}\t${event.kind}\t${cell(event.subject.id)}\t${event.ts}\n`);
52
+ return `${lines.join("")}next ${value.next}\n`;
53
+ };
54
+ export const runEventsRead = (tokens, context) => {
55
+ const parameters = readParameters(tokens);
56
+ const { call } = context.dependencies;
57
+ if (call === undefined)
58
+ return Effect.die(new Error("Missing the typed Node call."));
59
+ return Effect.map(call("events.read", parameters), (result) => writeNodeResult(result, context, {
60
+ toResult: (value) => ({ command: "events.read", result: value }),
61
+ toText: ({ result: value }) => formatResult(value),
62
+ }));
63
+ };
64
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1,2 @@
1
+ export { runEventsRead } from "./commands.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { runEventsRead } from "./commands.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export { EVENTS_TREE } from "./tree.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { EVENTS_TREE } from "./tree.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ declare const events: () => Promise<typeof import("../index.js")>;
2
+ export declare const EVENTS_TREE: {
3
+ readonly groups: readonly [readonly ["events", "The Node's public events, read by cursor."]];
4
+ readonly leaves: readonly [readonly ["events read [--kind <kind>]... [--since <cursor>] [--subject <type>:<id>] [--limit <1..100>]", 1, "events.read", "Read one page of public events after a cursor.", {
5
+ readonly example: "maia --json events read --since <cursor> --limit 50";
6
+ readonly run: readonly [typeof events, "runEventsRead"];
7
+ }]];
8
+ };
9
+ export {};
10
+ //# sourceMappingURL=tree.d.ts.map