@maiaos/cli 0.1.0-canary.55 → 0.1.0-canary.57

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 (200) hide show
  1. package/README.md +4 -3
  2. package/dist/bin/maia.cdx.json +19 -19
  3. package/dist/bin/maia.mjs +1 -1
  4. package/dist/cli/cli.js +10 -0
  5. package/dist/command-line/context.d.ts +2 -1
  6. package/dist/command-line/emit/index.d.ts +1 -1
  7. package/dist/command-line/emit/index.js +1 -1
  8. package/dist/command-line/emit/rows.d.ts +1 -0
  9. package/dist/command-line/emit/rows.js +5 -0
  10. package/dist/command-line/index.d.ts +3 -3
  11. package/dist/command-line/index.js +3 -3
  12. package/dist/command-line/input/index.d.ts +2 -1
  13. package/dist/command-line/input/index.js +1 -0
  14. package/dist/command-line/input/manager-options.d.ts +10 -0
  15. package/dist/command-line/input/manager-options.js +38 -0
  16. package/dist/command-line/two-phase/index.d.ts +2 -0
  17. package/dist/command-line/two-phase/index.js +2 -0
  18. package/dist/command-line/{two-phase.d.ts → two-phase/two-phase.d.ts} +12 -12
  19. package/dist/command-line/{two-phase.js → two-phase/two-phase.js} +2 -2
  20. package/dist/command-tree/tree.d.ts +1 -1
  21. package/dist/command-tree/tree.js +3 -0
  22. package/dist/events/commands.js +4 -3
  23. package/dist/import/batch.js +196 -0
  24. package/dist/import/client.d.ts +3 -3
  25. package/dist/import/client.js +1 -1
  26. package/dist/import/commands.d.ts +1 -0
  27. package/dist/import/commands.js +82 -8
  28. package/dist/import/index.d.ts +1 -1
  29. package/dist/import/index.js +1 -1
  30. package/dist/import/input.js +16 -2
  31. package/dist/import/manifest.js +107 -0
  32. package/dist/import/output.js +44 -2
  33. package/dist/session/agent-permission.d.ts +2 -2
  34. package/dist/session/approval/commands.d.ts +1 -0
  35. package/dist/session/approval/commands.js +75 -9
  36. package/dist/session/approval/index.d.ts +1 -1
  37. package/dist/session/approval/index.js +1 -1
  38. package/dist/session/client.d.ts +2 -2
  39. package/dist/session/coding-client.d.ts +2 -0
  40. package/dist/session/coding-client.js +1 -2
  41. package/dist/session/coding-commands.js +24 -7
  42. package/dist/session/commands.js +36 -39
  43. package/dist/session/output/human.js +14 -3
  44. package/dist/session/output/tasks.js +25 -11
  45. package/dist/session/tree/tree.js +31 -9
  46. package/dist/webhooks/client.d.ts +156 -0
  47. package/dist/webhooks/client.js +8 -0
  48. package/dist/webhooks/commands.d.ts +17 -0
  49. package/dist/webhooks/commands.js +76 -0
  50. package/dist/webhooks/index.d.ts +3 -0
  51. package/dist/webhooks/index.js +3 -0
  52. package/dist/webhooks/input.js +125 -0
  53. package/dist/webhooks/output/format.js +75 -0
  54. package/dist/webhooks/output/index.js +2 -0
  55. package/dist/webhooks/tree/index.js +2 -0
  56. package/dist/webhooks/tree/tree.js +49 -0
  57. package/package.json +5 -5
  58. package/dist/address-space/address-space.d.ts +0 -38
  59. package/dist/address-space/index.d.ts +0 -2
  60. package/dist/agents/input.d.ts +0 -132
  61. package/dist/agents/output/format.d.ts +0 -8
  62. package/dist/agents/output/index.d.ts +0 -2
  63. package/dist/agents/tree/index.d.ts +0 -2
  64. package/dist/agents/tree/tree.d.ts +0 -3
  65. package/dist/bootstrap/exit.d.ts +0 -14
  66. package/dist/bootstrap/exit.js +0 -42
  67. package/dist/bootstrap/index.d.ts +0 -3
  68. package/dist/bootstrap/index.js +0 -3
  69. package/dist/bootstrap/process.d.ts +0 -5
  70. package/dist/bootstrap/process.js +0 -23
  71. package/dist/bootstrap/run.d.ts +0 -25
  72. package/dist/bootstrap/run.js +0 -98
  73. package/dist/bootstrap/stdio.d.ts +0 -4
  74. package/dist/bootstrap/stdio.js +0 -9
  75. package/dist/cli/environment.d.ts +0 -8
  76. package/dist/cli/services.d.ts +0 -4
  77. package/dist/command-line/emit/json-decoder.d.ts +0 -3
  78. package/dist/command-line/input/stdin-stream.d.ts +0 -4
  79. package/dist/command-receipt/command.d.ts +0 -4
  80. package/dist/command-receipt/compact-list.d.ts +0 -20
  81. package/dist/command-receipt/index.d.ts +0 -3
  82. package/dist/command-tree/completion.d.ts +0 -6
  83. package/dist/command-tree/local.d.ts +0 -3
  84. package/dist/command-tree/row.js +0 -2
  85. package/dist/connection/access/format.d.ts +0 -8
  86. package/dist/connection/access/input.d.ts +0 -53
  87. package/dist/connection/input.d.ts +0 -50
  88. package/dist/connection/signin.d.ts +0 -4
  89. package/dist/connection/tree/index.d.ts +0 -2
  90. package/dist/connection/tree/tree.d.ts +0 -3
  91. package/dist/container/output/format.d.ts +0 -11
  92. package/dist/container/output/index.d.ts +0 -2
  93. package/dist/context/client.d.ts +0 -7
  94. package/dist/context/commands.d.ts +0 -3
  95. package/dist/context/index.d.ts +0 -3
  96. package/dist/dashboard/cockpit-client.d.ts +0 -6
  97. package/dist/dashboard/cockpit-client.js +0 -27
  98. package/dist/dashboard/cockpits.d.ts +0 -29
  99. package/dist/dashboard/cockpits.js +0 -65
  100. package/dist/dashboard/dashboard.d.ts +0 -7
  101. package/dist/dashboard/draw.d.ts +0 -15
  102. package/dist/dashboard/frame.d.ts +0 -4
  103. package/dist/dashboard/index.d.ts +0 -2
  104. package/dist/dashboard/modes.d.ts +0 -5
  105. package/dist/dashboard/node-connection.d.ts +0 -15
  106. package/dist/dashboard/node-connection.js +0 -51
  107. package/dist/dashboard/pi-tui.d.ts +0 -6
  108. package/dist/dashboard/status-bar.d.ts +0 -4
  109. package/dist/dashboard/terminal.d.ts +0 -53
  110. package/dist/dashboard/tree-model.d.ts +0 -28
  111. package/dist/dashboard/tree.d.ts +0 -10
  112. package/dist/development/cli.d.ts +0 -3
  113. package/dist/development/cli.js +0 -44
  114. package/dist/events/commands.d.ts +0 -11
  115. package/dist/events/index.d.ts +0 -2
  116. package/dist/events/tree/index.d.ts +0 -2
  117. package/dist/events/tree/tree.d.ts +0 -10
  118. package/dist/execution/tree/index.d.ts +0 -2
  119. package/dist/execution/tree/tree.d.ts +0 -3
  120. package/dist/hold/output/format.d.ts +0 -11
  121. package/dist/hold/output/index.d.ts +0 -2
  122. package/dist/hold/tree/index.d.ts +0 -2
  123. package/dist/hold/tree/tree.d.ts +0 -3
  124. package/dist/import/input.d.ts +0 -19
  125. package/dist/import/output.d.ts +0 -6
  126. package/dist/integration/output.d.ts +0 -22
  127. package/dist/login/failure.d.ts +0 -3
  128. package/dist/login/gateway.d.ts +0 -12
  129. package/dist/login/menu.d.ts +0 -4
  130. package/dist/login/output/format.d.ts +0 -16
  131. package/dist/login/output/index.d.ts +0 -2
  132. package/dist/login/vendor-account.d.ts +0 -95
  133. package/dist/login/vendor-input.d.ts +0 -14
  134. package/dist/mcp/calls.d.ts +0 -8
  135. package/dist/orchestration/output/compact-aggregate.d.ts +0 -121
  136. package/dist/orchestration/output/compact-run-list.d.ts +0 -20
  137. package/dist/orchestration/output/human.d.ts +0 -80
  138. package/dist/orchestration/output/index.d.ts +0 -4
  139. package/dist/orchestration/tree/index.d.ts +0 -2
  140. package/dist/orchestration/tree/tree.d.ts +0 -3
  141. package/dist/port-lease/input.d.ts +0 -65
  142. package/dist/port-lease/output/format.d.ts +0 -11
  143. package/dist/port-lease/output/index.d.ts +0 -2
  144. package/dist/presentation/output/format.d.ts +0 -11
  145. package/dist/presentation/output/index.d.ts +0 -3
  146. package/dist/project-guard/input.d.ts +0 -21
  147. package/dist/project-guard/output/format.d.ts +0 -11
  148. package/dist/project-guard/output/index.d.ts +0 -2
  149. package/dist/project-workspace/output/human.d.ts +0 -139
  150. package/dist/project-workspace/output/index.d.ts +0 -3
  151. package/dist/project-workspace/output/metadata.d.ts +0 -11
  152. package/dist/project-workspace/tree/index.d.ts +0 -2
  153. package/dist/project-workspace/tree/tree.d.ts +0 -3
  154. package/dist/provider/client.d.ts +0 -6
  155. package/dist/provider/commands.d.ts +0 -3
  156. package/dist/provider/index.d.ts +0 -3
  157. package/dist/reference/commands.d.ts +0 -3
  158. package/dist/reference/index.d.ts +0 -3
  159. package/dist/reference/resolve.d.ts +0 -31
  160. package/dist/reference/tree/index.d.ts +0 -2
  161. package/dist/reference/tree/tree.d.ts +0 -3
  162. package/dist/remote-node/reachability.d.ts +0 -64
  163. package/dist/remote-node/text.d.ts +0 -10
  164. package/dist/remote-node/tree/index.d.ts +0 -2
  165. package/dist/remote-node/tree/tree.d.ts +0 -3
  166. package/dist/routine/input.d.ts +0 -28
  167. package/dist/routine/output/format.d.ts +0 -23
  168. package/dist/routine/output/index.d.ts +0 -2
  169. package/dist/routine/tree/index.d.ts +0 -2
  170. package/dist/routine/tree/tree.d.ts +0 -3
  171. package/dist/run-ledger/input.d.ts +0 -42
  172. package/dist/run-ledger/output/format.d.ts +0 -11
  173. package/dist/run-ledger/output/index.d.ts +0 -2
  174. package/dist/session/approval/output/format.d.ts +0 -23
  175. package/dist/session/approval/output/index.d.ts +0 -2
  176. package/dist/session/attach-render.d.ts +0 -16
  177. package/dist/session/create-tasks.d.ts +0 -20
  178. package/dist/session/interaction/input.d.ts +0 -15
  179. package/dist/session/interaction/output/format.d.ts +0 -11
  180. package/dist/session/interaction/output/index.d.ts +0 -2
  181. package/dist/session/output/diff.d.ts +0 -3
  182. package/dist/session/output/failure.d.ts +0 -11
  183. package/dist/session/output/human.d.ts +0 -115
  184. package/dist/session/output/index.d.ts +0 -6
  185. package/dist/session/output/observe.d.ts +0 -4
  186. package/dist/session/output/tasks.d.ts +0 -36
  187. package/dist/session/task-file.d.ts +0 -5
  188. package/dist/session/tree/index.d.ts +0 -2
  189. package/dist/session/tree/tree.d.ts +0 -3
  190. package/dist/team-workspace/ceremony.d.ts +0 -19
  191. package/dist/team-workspace/confirmation.d.ts +0 -4
  192. package/dist/team-workspace/dependencies.js +0 -2
  193. package/dist/team-workspace/output.d.ts +0 -15
  194. package/dist/terminal/arguments.d.ts +0 -13
  195. package/dist/terminal/keys.d.ts +0 -12
  196. package/dist/terminal/output/compact-list.d.ts +0 -149
  197. package/dist/terminal/output/human.d.ts +0 -42
  198. package/dist/terminal/output/index.d.ts +0 -3
  199. package/dist/terminal/tree/index.d.ts +0 -2
  200. package/dist/terminal/tree/tree.d.ts +0 -3
@@ -0,0 +1,8 @@
1
+ import { webhooksChangeConfirmParametersSchema, webhooksChangePreviewParametersSchema, webhooksDeliveriesParametersSchema, webhooksListParametersSchema, } from "@maiaos/sdk";
2
+ export const makeWebhooksClient = (node) => ({
3
+ confirmWebhookChange: (input) => node.runValidatedNodeOperation(input, webhooksChangeConfirmParametersSchema, (client, parameters, options) => client.confirmWebhookChange(parameters, options), { commandId: input.commandId }),
4
+ listWebhookDeliveries: (input) => node.runValidatedNodeOperation(input, webhooksDeliveriesParametersSchema, (client, parameters, options) => client.listWebhookDeliveries(parameters, options)),
5
+ listWebhooks: (input) => node.runValidatedNodeOperation(input, webhooksListParametersSchema, (client, parameters, options) => client.listWebhooks(parameters, options)),
6
+ previewWebhookChange: (input) => node.runValidatedNodeOperation(input, webhooksChangePreviewParametersSchema, (client, parameters, options) => client.previewWebhookChange(parameters, options)),
7
+ });
8
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,17 @@
1
+ import type * as Crypto from "effect/Crypto";
2
+ import * as Effect from "effect/Effect";
3
+ import { type OutputContext } from "../command-line/emit/index.js";
4
+ import { CliArgumentError } from "../command-line/input/index.js";
5
+ import type { WebhooksCliDependencies } from "./client.js";
6
+ type CommandContext = OutputContext & {
7
+ readonly dependencies: WebhooksCliDependencies;
8
+ };
9
+ type CommandEffect = Effect.Effect<number, CliArgumentError, Crypto.Crypto>;
10
+ export declare const runWebhooksList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
11
+ export declare const runWebhooksDeliveries: (tokens: readonly string[], context: CommandContext) => CommandEffect;
12
+ export declare const runWebhooksAdd: (tokens: readonly string[], context: CommandContext) => CommandEffect;
13
+ export declare const runWebhooksRemove: (tokens: readonly string[], context: CommandContext) => CommandEffect;
14
+ export declare const runWebhooksTest: (tokens: readonly string[], context: CommandContext) => CommandEffect;
15
+ export declare const runWebhooksRedeliver: (tokens: readonly string[], context: CommandContext) => CommandEffect;
16
+ export {};
17
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1,76 @@
1
+ import { webhooksChangeConfirmParametersSchema, } from "@maiaos/sdk";
2
+ import * as Effect from "effect/Effect";
3
+ import { writeNodeResult, } from "../command-line/emit/index.js";
4
+ import { CliArgumentError, parseOptionsWith, requirePositionals, } from "../command-line/input/index.js";
5
+ import { confirmParameters, readTwoPhaseMode, runTwoPhase, } from "../command-line/two-phase/index.js";
6
+ import { readAddChange, readRedeliverChange, readRemoveChange, readTestChange, readWebhooksDeliveries, readWebhooksList, WEBHOOK_OPTIONS, } from "./input.js";
7
+ import { formatWebhooksResult } from "./output/index.js";
8
+ const write = (context) => (result) => writeNodeResult(result, context, {
9
+ toResult: (value) => ({ command: value.method, result: value }),
10
+ toText: formatWebhooksResult,
11
+ });
12
+ const unavailable = () => Effect.die(new Error("Missing webhooks client."));
13
+ export const runWebhooksList = (tokens, context) => Effect.gen(function* () {
14
+ const list = context.dependencies.listWebhooks;
15
+ if (list === undefined)
16
+ return yield* unavailable();
17
+ return write(context)(yield* list(readWebhooksList(tokens)));
18
+ });
19
+ export const runWebhooksDeliveries = (tokens, context) => Effect.gen(function* () {
20
+ const list = context.dependencies.listWebhookDeliveries;
21
+ if (list === undefined)
22
+ return yield* unavailable();
23
+ return write(context)(yield* list(readWebhooksDeliveries(tokens)));
24
+ });
25
+ const describe = (preview) => formatWebhooksResult({ command: preview.method, result: preview });
26
+ const confirmOwnKind = (kind, confirm) => (preview) => Effect.flatMap(confirmParameters(webhooksChangeConfirmParametersSchema, preview, [
27
+ "current",
28
+ "deletesDeliveries",
29
+ "webhookId",
30
+ ]), (parameters) => parameters.change.kind === kind
31
+ ? confirm(parameters)
32
+ : Effect.fail(new CliArgumentError(`The piped preview is a ${parameters.change.kind} change; confirm it with 'maia webhooks ${parameters.change.kind} --confirm-stdin'.`)));
33
+ const runChange = (tokens, context, spec) => Effect.gen(function* () {
34
+ const parsed = parseOptionsWith(tokens, spec.options);
35
+ const mode = readTwoPhaseMode(parsed.flags, context);
36
+ if (mode === "confirm-stdin")
37
+ requirePositionals(parsed.positionals, 0);
38
+ const { confirmWebhookChange, previewWebhookChange } = context.dependencies;
39
+ if (confirmWebhookChange === undefined ||
40
+ previewWebhookChange === undefined)
41
+ return yield* new CliArgumentError("Webhook changes are unavailable.");
42
+ return yield* runTwoPhase({
43
+ confirm: confirmOwnKind(spec.kind, confirmWebhookChange),
44
+ context,
45
+ mode,
46
+ preview: () => Effect.flatMap(spec.read(parsed), previewWebhookChange),
47
+ prompt: { describe, question: spec.question },
48
+ writeConfirm: write(context),
49
+ writePreview: write(context),
50
+ });
51
+ });
52
+ export const runWebhooksAdd = (tokens, context) => runChange(tokens, context, {
53
+ kind: "add",
54
+ options: WEBHOOK_OPTIONS.add,
55
+ question: "Add this webhook?",
56
+ read: readAddChange,
57
+ });
58
+ export const runWebhooksRemove = (tokens, context) => runChange(tokens, context, {
59
+ kind: "remove",
60
+ options: WEBHOOK_OPTIONS.remove,
61
+ question: "Remove this webhook and its deliveries?",
62
+ read: readRemoveChange,
63
+ });
64
+ export const runWebhooksTest = (tokens, context) => runChange(tokens, context, {
65
+ kind: "test",
66
+ options: WEBHOOK_OPTIONS.test,
67
+ question: "Send a test event to this webhook?",
68
+ read: readTestChange,
69
+ });
70
+ export const runWebhooksRedeliver = (tokens, context) => runChange(tokens, context, {
71
+ kind: "redeliver",
72
+ options: WEBHOOK_OPTIONS.redeliver,
73
+ question: "Send this delivery again?",
74
+ read: readRedeliverChange,
75
+ });
76
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1,3 @@
1
+ export { makeWebhooksClient, type WebhooksCliDependencies } from "./client.js";
2
+ export { runWebhooksAdd, runWebhooksDeliveries, runWebhooksList, runWebhooksRedeliver, runWebhooksRemove, runWebhooksTest, } from "./commands.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { makeWebhooksClient } from "./client.js";
2
+ export { runWebhooksAdd, runWebhooksDeliveries, runWebhooksList, runWebhooksRedeliver, runWebhooksRemove, runWebhooksTest, } from "./commands.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,125 @@
1
+ import { webhookSpecSchema, } from "@maiaos/sdk";
2
+ import * as Effect from "effect/Effect";
3
+ import { CliArgumentError, parseOptionsWith, readExpectedRevision, readPageSize, requirePositionals, } from "../command-line/input/index.js";
4
+ import { TWO_PHASE_FLAGS } from "../command-line/two-phase/index.js";
5
+ import { commandIdentifier } from "../local-node/index.js";
6
+ const targetOptions = ["--command-id", "--expected-revision"];
7
+ export const WEBHOOK_OPTIONS = {
8
+ add: {
9
+ allowed: new Set([
10
+ "--command-id",
11
+ "--event",
12
+ "--label",
13
+ "--node-id",
14
+ "--project",
15
+ "--secret-env",
16
+ "--url",
17
+ ]),
18
+ allowedFlags: new Set([...TWO_PHASE_FLAGS, "--allow-private"]),
19
+ repeatable: new Set(["--event", "--label"]),
20
+ },
21
+ deliveries: {
22
+ allowed: new Set(["--after", "--limit", "--webhook"]),
23
+ allowedFlags: new Set(["--failed"]),
24
+ repeatable: new Set(),
25
+ },
26
+ list: {
27
+ allowed: new Set(["--after", "--limit"]),
28
+ allowedFlags: new Set(),
29
+ repeatable: new Set(),
30
+ },
31
+ redeliver: {
32
+ allowed: new Set(targetOptions),
33
+ allowedFlags: new Set(TWO_PHASE_FLAGS),
34
+ repeatable: new Set(),
35
+ },
36
+ remove: {
37
+ allowed: new Set(targetOptions),
38
+ allowedFlags: new Set(TWO_PHASE_FLAGS),
39
+ repeatable: new Set(),
40
+ },
41
+ test: {
42
+ allowed: new Set(targetOptions),
43
+ allowedFlags: new Set(TWO_PHASE_FLAGS),
44
+ repeatable: new Set(),
45
+ },
46
+ };
47
+ const required = (options, name) => {
48
+ const value = options.get(name);
49
+ if (value === undefined)
50
+ throw new CliArgumentError(`Option '${name}' is required.`);
51
+ return value;
52
+ };
53
+ const INVALID_SPEC = "The webhook is invalid: check '--url' (http or https, no credentials), '--secret-env' (an upper-case variable name), '--event' (a hook event) and '--label' (key=value, no comma).";
54
+ const labelFilter = (label) => {
55
+ const [key, ...rest] = label.split("=");
56
+ if (key === undefined || key === "" || rest.length === 0)
57
+ throw new CliArgumentError("Option '--label' takes key=value.");
58
+ return { key: `label.${key}`, value: rest.join("=") };
59
+ };
60
+ const filtersOf = (options) => {
61
+ const project = options.get("--project");
62
+ const node = options.get("--node-id");
63
+ return [
64
+ ...(project === undefined ? [] : [{ key: "project", value: project }]),
65
+ ...(node === undefined ? [] : [{ key: "node", value: node }]),
66
+ ...(options.get("--label")?.split(",").map(labelFilter) ?? []),
67
+ ];
68
+ };
69
+ const readSpec = (parsed) => {
70
+ const { flags, options } = parsed;
71
+ const spec = webhookSpecSchema.safeParse({
72
+ allowPrivate: flags.has("--allow-private"),
73
+ events: required(options, "--event").split(","),
74
+ filters: filtersOf(options),
75
+ secretEnv: required(options, "--secret-env"),
76
+ url: required(options, "--url"),
77
+ });
78
+ if (!spec.success)
79
+ throw new CliArgumentError(INVALID_SPEC);
80
+ return spec.data;
81
+ };
82
+ export const readWebhooksList = (tokens) => {
83
+ const { options, positionals } = parseOptionsWith(tokens, WEBHOOK_OPTIONS.list);
84
+ requirePositionals(positionals, 0);
85
+ const afterCursor = options.get("--after");
86
+ return {
87
+ ...(afterCursor === undefined ? {} : { afterCursor }),
88
+ limit: readPageSize(options.get("--limit")),
89
+ };
90
+ };
91
+ export const readWebhooksDeliveries = (tokens) => {
92
+ const { flags, options, positionals } = parseOptionsWith(tokens, WEBHOOK_OPTIONS.deliveries);
93
+ requirePositionals(positionals, 0);
94
+ const afterCursor = options.get("--after");
95
+ const webhookId = options.get("--webhook");
96
+ return {
97
+ ...(afterCursor === undefined ? {} : { afterCursor }),
98
+ ...(flags.has("--failed") ? { failedOnly: true } : {}),
99
+ limit: readPageSize(options.get("--limit")),
100
+ ...(webhookId === undefined ? {} : { webhookId }),
101
+ };
102
+ };
103
+ const withCommandId = (parsed, change) => Effect.map(commandIdentifier(parsed.options.get("--command-id")), (commandId) => ({ change, commandId }));
104
+ export const readAddChange = (parsed) => {
105
+ requirePositionals(parsed.positionals, 0);
106
+ return withCommandId(parsed, { kind: "add", spec: readSpec(parsed) });
107
+ };
108
+ const targetOf = (parsed, positionals) => {
109
+ requirePositionals(parsed.positionals, positionals);
110
+ return {
111
+ expectedRevision: readExpectedRevision(parsed.options.get("--expected-revision")),
112
+ webhookId: parsed.positionals[0] ?? "",
113
+ };
114
+ };
115
+ export const readRemoveChange = (parsed) => withCommandId(parsed, { ...targetOf(parsed, 1), kind: "remove" });
116
+ export const readTestChange = (parsed) => withCommandId(parsed, { ...targetOf(parsed, 1), kind: "test" });
117
+ export const readRedeliverChange = (parsed) => {
118
+ requirePositionals(parsed.positionals, 1);
119
+ return withCommandId(parsed, {
120
+ deliveryId: parsed.positionals[0] ?? "",
121
+ expectedRevision: readExpectedRevision(parsed.options.get("--expected-revision")),
122
+ kind: "redeliver",
123
+ });
124
+ };
125
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1,75 @@
1
+ import { cell, formatRows, tab, withNextPage, } from "../../command-line/emit/index.js";
2
+ const hookLine = (hook) => tab([
3
+ hook.id,
4
+ hook.state,
5
+ hook.revision,
6
+ cell(hook.spec.url),
7
+ hook.spec.events.join(","),
8
+ ]);
9
+ const deliveryLine = (delivery) => tab([
10
+ delivery.id,
11
+ delivery.webhookId,
12
+ delivery.state,
13
+ delivery.kind,
14
+ `attempts=${String(delivery.attempts)}`,
15
+ delivery.errorClass ?? "",
16
+ ]);
17
+ const specOf = ({ change, current }) => change.kind === "add" ? change.spec : current?.spec;
18
+ const specLines = (spec) => [
19
+ spec.allowPrivate
20
+ ? "allowPrivate=true (sends may reach private and loopback addresses)"
21
+ : "allowPrivate=false",
22
+ `url=${cell(spec.url)}`,
23
+ `events=${spec.events.join(",")}`,
24
+ `filters=${spec.filters.map(({ key, value }) => `${key}=${cell(value)}`).join(",") || "none"}`,
25
+ `secretEnv=${spec.secretEnv}`,
26
+ ];
27
+ const targetLines = (result) => {
28
+ const { change, deletesDeliveries } = result;
29
+ return [
30
+ ...(change.kind === "add" ? [] : [`revision=${change.expectedRevision}`]),
31
+ ...(change.kind === "redeliver" ? [`delivery=${change.deliveryId}`] : []),
32
+ ...(deletesDeliveries === undefined
33
+ ? []
34
+ : [`deletes=${String(deletesDeliveries)} deliveries`]),
35
+ ];
36
+ };
37
+ const previewLines = (result) => {
38
+ const { change, commandId, expiresAt, webhookId } = result;
39
+ const spec = specOf(result);
40
+ const header = tab([
41
+ change.kind,
42
+ webhookId,
43
+ `command=${commandId}`,
44
+ `expires=${expiresAt}`,
45
+ ]);
46
+ return `${[header, ...(spec === undefined ? [] : specLines(spec)), ...targetLines(result)].join("\n")}\n`;
47
+ };
48
+ const confirmLine = ({ delivery, receipt, webhook, }) => `${tab([webhook.id, webhook.state, webhook.revision, receipt.receiptId, delivery])}\n`;
49
+ const DELIVERY_HEADERS = [
50
+ "DELIVERY",
51
+ "WEBHOOK",
52
+ "STATE",
53
+ "KIND",
54
+ "ATTEMPTS",
55
+ "ERROR",
56
+ ];
57
+ export const formatWebhooksResult = ({ result }) => {
58
+ switch (result.method) {
59
+ case "webhooks.list":
60
+ return withNextPage(formatRows(result.items, hookLine, {
61
+ empty: "No webhooks.",
62
+ headers: ["WEBHOOK", "STATE", "REVISION", "URL", "EVENTS"],
63
+ }), result.nextCursor);
64
+ case "webhooks.deliveries":
65
+ return withNextPage(formatRows(result.items, deliveryLine, {
66
+ empty: "No deliveries.",
67
+ headers: DELIVERY_HEADERS,
68
+ }), result.nextCursor);
69
+ case "webhooks.change.preview":
70
+ return previewLines(result);
71
+ case "webhooks.change.confirm":
72
+ return confirmLine(result);
73
+ }
74
+ };
75
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1,2 @@
1
+ export { formatWebhooksResult, } from "./format.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export { WEBHOOKS_TREE } from "./tree.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,49 @@
1
+ const webhooks = () => import("../index.js");
2
+ export const WEBHOOKS_TREE = {
3
+ groups: [["webhooks", "Signed outbound webhooks for Node events."]],
4
+ leaves: [
5
+ [
6
+ "webhooks list [--limit <1..100>] [--after <cursor>]",
7
+ 1,
8
+ "webhooks.list",
9
+ "List webhooks.",
10
+ { run: [webhooks, "runWebhooksList"] },
11
+ ],
12
+ [
13
+ "webhooks deliveries [--webhook <webhook-id>] [--failed] [--limit <1..100>] [--after <cursor>]",
14
+ 1,
15
+ "webhooks.deliveries",
16
+ "List webhook deliveries; --failed lists parked and denied ones.",
17
+ { run: [webhooks, "runWebhooksDeliveries"] },
18
+ ],
19
+ [
20
+ "webhooks add (--url <http-url> --secret-env <VARIABLE> --event <kind>... [--label <key=value>...] [--project <project-id>] [--node-id <node-id>] [--allow-private] [--command-id <id>] [--dry-run] | --confirm-stdin)",
21
+ 1,
22
+ ["webhooks.change.preview", "webhooks.change.confirm"],
23
+ "Add a webhook after a preview.",
24
+ { kind: "two-phase", run: [webhooks, "runWebhooksAdd"] },
25
+ ],
26
+ [
27
+ "webhooks test (<webhook-id> --expected-revision <revision> [--command-id <id>] [--dry-run] | --confirm-stdin)",
28
+ 1,
29
+ ["webhooks.change.preview", "webhooks.change.confirm"],
30
+ "Send a test event to a webhook after a preview.",
31
+ { kind: "two-phase", run: [webhooks, "runWebhooksTest"] },
32
+ ],
33
+ [
34
+ "webhooks remove (<webhook-id> --expected-revision <revision> [--command-id <id>] [--dry-run] | --confirm-stdin)",
35
+ 1,
36
+ ["webhooks.change.preview", "webhooks.change.confirm"],
37
+ "Remove a webhook and its deliveries after a preview.",
38
+ { kind: "two-phase", run: [webhooks, "runWebhooksRemove"] },
39
+ ],
40
+ [
41
+ "webhooks redeliver (<delivery-id> --expected-revision <revision> [--command-id <id>] [--dry-run] | --confirm-stdin)",
42
+ 1,
43
+ ["webhooks.change.preview", "webhooks.change.confirm"],
44
+ "Send a delivery again after a preview.",
45
+ { kind: "two-phase", run: [webhooks, "runWebhooksRedeliver"] },
46
+ ],
47
+ ],
48
+ };
49
+ //# sourceMappingURL=tree.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiaos/cli",
3
- "version": "0.1.0-canary.55",
3
+ "version": "0.1.0-canary.57",
4
4
  "description": "The maia CLI and MCP server: start, drive, observe and stop swarms of Claude Code and Codex agents from a terminal, a script or another agent.",
5
5
  "keywords": [
6
6
  "maia",
@@ -64,13 +64,13 @@
64
64
  "dependencies": {
65
65
  "@earendil-works/pi-tui": "1.0.0",
66
66
  "@effect/platform-node-shared": "4.0.0",
67
- "@maiaos/agent": "0.1.0-canary.55",
68
- "@maiaos/client-core": "0.1.0-canary.55",
69
- "@maiaos/sdk": "0.1.0-canary.55",
67
+ "@maiaos/agent": "0.1.0-canary.57",
68
+ "@maiaos/client-core": "0.1.0-canary.57",
69
+ "@maiaos/sdk": "0.1.0-canary.57",
70
70
  "effect": "4.0.0"
71
71
  },
72
72
  "scripts": {
73
- "build": "node -e \"require('node:fs').rmSync('dist',{force:true,recursive:true})\" && tsc --project tsconfig.build.json && node scripts/build-executable.mjs",
73
+ "build": "node -e \"require('node:fs').rmSync('dist',{force:true,recursive:true})\" && tsc --project tsconfig.build.json && node scripts/build-executable.mjs && node scripts/prune-library.mjs",
74
74
  "lint": "eslint src scripts --max-warnings 0 --cache --cache-location node_modules/.cache/eslint/ --cache-strategy content",
75
75
  "test": "node -e \"require('node:fs').rmSync('.test-dist',{force:true,recursive:true})\" && tsc --project tsconfig.test.json && node --import ../../scripts/lib/test-environment.mjs --test --test-concurrency=2 --enable-source-maps \".test-dist/**/*.test.js\"",
76
76
  "typecheck": "tsc --project tsconfig.json --noEmit --incremental --tsBuildInfoFile node_modules/.cache/tsc/typecheck.tsbuildinfo && tsc --project scripts/tsconfig.json --noEmit --incremental --tsBuildInfoFile node_modules/.cache/tsc/scripts.tsbuildinfo"
@@ -1,38 +0,0 @@
1
- import type { RouteKind } from "@maiaos/client-core/cockpit";
2
- import { type CliCommandOutput, type CliDependencies, type CliTable, type CommandContext, type CommandEffect } from "../command-line/index.js";
3
- import { type LeafRoute } from "../command-tree/index.js";
4
- import { type HeldId, type ListedNode, type NodeAnswer } from "../fleet/index.js";
5
- import type { CliNodeEffect, CliNodeResult } from "../local-node/index.js";
6
- export declare const onHolder: (context: CommandContext, held: HeldId, run: (bound: CommandContext) => CommandEffect) => CommandEffect;
7
- type InputRoute = {
8
- readonly idOf: (input: object) => unknown;
9
- readonly kind: RouteKind;
10
- };
11
- export declare const onInputHolder: (context: CommandContext, { idOf, kind }: InputRoute, run: (bound: CommandContext) => CommandEffect) => CommandEffect;
12
- export type RoutedLeaf = {
13
- readonly argument: LeafRoute;
14
- readonly tokens: readonly string[];
15
- readonly usage: string;
16
- };
17
- export declare const routeLeaf: (context: CommandContext, { argument, tokens, usage }: RoutedLeaf, run: (bound: CommandContext) => CommandEffect) => CommandEffect;
18
- export declare const nodeLines: (nodes: readonly ListedNode[]) => string;
19
- export declare const formatMerged: <TItem extends {
20
- readonly node: string;
21
- }>({ items, nodes, }: {
22
- readonly items: readonly TItem[];
23
- readonly nodes: readonly ListedNode[];
24
- }, row: (item: TItem) => string, { empty, headers }: CliTable) => string;
25
- export declare const writeMerged: <TResult extends CliCommandOutput & {
26
- readonly result: {
27
- readonly nodes: readonly ListedNode[];
28
- };
29
- }>(context: CommandContext, output: TResult, text: (output: TResult) => string) => number;
30
- type ListSpec<TList> = {
31
- readonly merged: (answers: readonly NodeAnswer<TList>[]) => number;
32
- readonly paged: boolean;
33
- readonly read: (dependencies: CliDependencies) => CliNodeEffect<TList>;
34
- readonly sole: (result: CliNodeResult<TList>) => number;
35
- };
36
- export declare const listEach: <TList>(context: CommandContext, { merged, paged, read, sole }: ListSpec<TList>) => CommandEffect;
37
- export {};
38
- //# sourceMappingURL=address-space.d.ts.map
@@ -1,2 +0,0 @@
1
- export { formatMerged, listEach, nodeLines, onHolder, onInputHolder, type RoutedLeaf, routeLeaf, writeMerged, } from "./address-space.js";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,132 +0,0 @@
1
- import { type AgentsDetectParameters, type AgentsListParameters, type AgentsShowParameters } from "@maiaos/sdk";
2
- import * as Effect from "effect/Effect";
3
- import { type ParsedOptions } from "../command-line/index.js";
4
- export declare const AGENT_OPTIONS: {
5
- readonly create: Set<string>;
6
- readonly detect: Set<string>;
7
- readonly disable: Set<string>;
8
- readonly list: Set<string>;
9
- readonly revise: Set<string>;
10
- readonly show: Set<string>;
11
- };
12
- export declare const readAgentsList: (tokens: readonly string[]) => AgentsListParameters;
13
- export declare const readAgentsDetect: (tokens: readonly string[]) => AgentsDetectParameters;
14
- export declare const readAgentsShow: (tokens: readonly string[]) => AgentsShowParameters;
15
- export declare const readCreateChange: (parsed: ParsedOptions) => Effect.Effect<{
16
- change: {
17
- readonly kind: "create";
18
- readonly projectId: string;
19
- readonly spec: {
20
- readonly accountableActorId: string;
21
- readonly connectionId?: string | undefined;
22
- readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
23
- readonly harness: "claude-code" | "codex-cli" | "maia-agent" | "pi";
24
- readonly homeSessionId?: string | undefined;
25
- readonly instruction: string;
26
- readonly managerAgentId?: string | undefined;
27
- readonly model?: string | undefined;
28
- readonly name: string;
29
- readonly placement: "local";
30
- };
31
- } | {
32
- readonly agentId: string;
33
- readonly expectedRevision: string;
34
- readonly kind: "revise";
35
- readonly spec: {
36
- readonly accountableActorId: string;
37
- readonly connectionId?: string | undefined;
38
- readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
39
- readonly harness: "claude-code" | "codex-cli" | "maia-agent" | "pi";
40
- readonly homeSessionId?: string | undefined;
41
- readonly instruction: string;
42
- readonly managerAgentId?: string | undefined;
43
- readonly model?: string | undefined;
44
- readonly name: string;
45
- readonly placement: "local";
46
- };
47
- } | {
48
- readonly agentId: string;
49
- readonly expectedRevision: string;
50
- readonly kind: "disable";
51
- };
52
- commandId: string;
53
- }, never, import("effect/Crypto").Crypto>;
54
- export declare const readReviseChange: (parsed: ParsedOptions) => Effect.Effect<{
55
- change: {
56
- readonly kind: "create";
57
- readonly projectId: string;
58
- readonly spec: {
59
- readonly accountableActorId: string;
60
- readonly connectionId?: string | undefined;
61
- readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
62
- readonly harness: "claude-code" | "codex-cli" | "maia-agent" | "pi";
63
- readonly homeSessionId?: string | undefined;
64
- readonly instruction: string;
65
- readonly managerAgentId?: string | undefined;
66
- readonly model?: string | undefined;
67
- readonly name: string;
68
- readonly placement: "local";
69
- };
70
- } | {
71
- readonly agentId: string;
72
- readonly expectedRevision: string;
73
- readonly kind: "revise";
74
- readonly spec: {
75
- readonly accountableActorId: string;
76
- readonly connectionId?: string | undefined;
77
- readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
78
- readonly harness: "claude-code" | "codex-cli" | "maia-agent" | "pi";
79
- readonly homeSessionId?: string | undefined;
80
- readonly instruction: string;
81
- readonly managerAgentId?: string | undefined;
82
- readonly model?: string | undefined;
83
- readonly name: string;
84
- readonly placement: "local";
85
- };
86
- } | {
87
- readonly agentId: string;
88
- readonly expectedRevision: string;
89
- readonly kind: "disable";
90
- };
91
- commandId: string;
92
- }, never, import("effect/Crypto").Crypto>;
93
- export declare const readDisableChange: (parsed: ParsedOptions) => Effect.Effect<{
94
- change: {
95
- readonly kind: "create";
96
- readonly projectId: string;
97
- readonly spec: {
98
- readonly accountableActorId: string;
99
- readonly connectionId?: string | undefined;
100
- readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
101
- readonly harness: "claude-code" | "codex-cli" | "maia-agent" | "pi";
102
- readonly homeSessionId?: string | undefined;
103
- readonly instruction: string;
104
- readonly managerAgentId?: string | undefined;
105
- readonly model?: string | undefined;
106
- readonly name: string;
107
- readonly placement: "local";
108
- };
109
- } | {
110
- readonly agentId: string;
111
- readonly expectedRevision: string;
112
- readonly kind: "revise";
113
- readonly spec: {
114
- readonly accountableActorId: string;
115
- readonly connectionId?: string | undefined;
116
- readonly effort?: "high" | "low" | "max" | "medium" | "ultra" | "xhigh" | undefined;
117
- readonly harness: "claude-code" | "codex-cli" | "maia-agent" | "pi";
118
- readonly homeSessionId?: string | undefined;
119
- readonly instruction: string;
120
- readonly managerAgentId?: string | undefined;
121
- readonly model?: string | undefined;
122
- readonly name: string;
123
- readonly placement: "local";
124
- };
125
- } | {
126
- readonly agentId: string;
127
- readonly expectedRevision: string;
128
- readonly kind: "disable";
129
- };
130
- commandId: string;
131
- }, never, import("effect/Crypto").Crypto>;
132
- //# sourceMappingURL=input.d.ts.map
@@ -1,8 +0,0 @@
1
- import type { AgentsChangeConfirmResult, AgentsChangePreviewResult, AgentsDetectResult, AgentsListResult, AgentsShowResult } from "@maiaos/sdk";
2
- export type AgentsResult = AgentsChangeConfirmResult | AgentsChangePreviewResult | AgentsDetectResult | AgentsListResult | AgentsShowResult;
3
- export type CliAgentsResult = {
4
- readonly command: AgentsResult["method"];
5
- readonly result: AgentsResult;
6
- };
7
- export declare const formatAgentsResult: ({ result }: CliAgentsResult) => string;
8
- //# sourceMappingURL=format.d.ts.map
@@ -1,2 +0,0 @@
1
- export { type AgentsResult, type CliAgentsResult, formatAgentsResult, } from "./format.js";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +0,0 @@
1
- export { AGENTS_TREE } from "./tree.js";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,3 +0,0 @@
1
- import type { TreeFragment } from "../../command-tree/index.js";
2
- export declare const AGENTS_TREE: TreeFragment;
3
- //# sourceMappingURL=tree.d.ts.map
@@ -1,14 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- type Output = {
3
- readonly on: (event: "close" | "error", listener: () => void) => unknown;
4
- readonly writableLength: number;
5
- readonly write: (chunk: string, callback?: () => void) => unknown;
6
- };
7
- type ExitingProcess = {
8
- readonly exit: (code: number) => void;
9
- readonly stderr: Output;
10
- readonly stdout: Output;
11
- };
12
- export declare const exitAfterOutput: (program: Effect.Effect<number>, host: ExitingProcess) => Effect.Effect<void>;
13
- export {};
14
- //# sourceMappingURL=exit.d.ts.map
@@ -1,42 +0,0 @@
1
- import * as Cause from "effect/Cause";
2
- import * as Deferred from "effect/Deferred";
3
- import * as Effect from "effect/Effect";
4
- import * as Exit from "effect/Exit";
5
- import * as Fiber from "effect/Fiber";
6
- const EXIT_INTERRUPTED = 130;
7
- const watch = (output) => Effect.gen(function* () {
8
- const ended = yield* Deferred.make();
9
- const end = () => {
10
- Deferred.doneUnsafe(ended, Effect.succeed(true));
11
- };
12
- output.on("error", end);
13
- output.on("close", end);
14
- const flushed = Effect.callback((resume) => {
15
- if (output.writableLength === 0) {
16
- resume(Effect.succeed(true));
17
- return;
18
- }
19
- output.write("", () => {
20
- resume(Effect.succeed(true));
21
- });
22
- });
23
- return Effect.raceFirst(Deferred.await(ended), flushed);
24
- });
25
- const exitCode = (exit, stderr) => {
26
- if (Exit.isSuccess(exit))
27
- return exit.value;
28
- if (Cause.hasInterruptsOnly(exit.cause))
29
- return EXIT_INTERRUPTED;
30
- stderr.write(`${Cause.pretty(exit.cause)}\n`);
31
- return 1;
32
- };
33
- export const exitAfterOutput = (program, host) => Effect.gen(function* () {
34
- const drains = [yield* watch(host.stdout), yield* watch(host.stderr)];
35
- const running = yield* Effect.forkChild(program, {
36
- startImmediately: true,
37
- });
38
- const code = exitCode(yield* Fiber.await(running), host.stderr);
39
- yield* Effect.all(drains, { concurrency: "unbounded", discard: true });
40
- host.exit(code);
41
- });
42
- //# sourceMappingURL=exit.js.map