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

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 (81) 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 +1 -1
  22. package/dist/command-line/index.js +1 -1
  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/connection/access/client.d.ts +13 -0
  28. package/dist/connection/access/client.js +19 -0
  29. package/dist/connection/access/commands.d.ts +6 -0
  30. package/dist/connection/access/commands.js +60 -0
  31. package/dist/connection/access/format.d.ts +8 -0
  32. package/dist/connection/access/format.js +61 -0
  33. package/dist/connection/access/index.d.ts +3 -0
  34. package/dist/connection/access/index.js +3 -0
  35. package/dist/connection/access/input.d.ts +53 -0
  36. package/dist/connection/access/input.js +83 -0
  37. package/dist/connection/client.d.ts +6 -0
  38. package/dist/connection/client.js +2 -0
  39. package/dist/connection/index.d.ts +1 -0
  40. package/dist/connection/index.js +1 -0
  41. package/dist/connection/tree/tree.js +45 -7
  42. package/dist/local-node/client.d.ts +1 -0
  43. package/dist/local-node/client.js +1 -0
  44. package/dist/local-node/index.d.ts +2 -1
  45. package/dist/local-node/index.js +2 -1
  46. package/dist/local-node/wait.d.ts +10 -0
  47. package/dist/local-node/wait.js +17 -0
  48. package/dist/mcp/calls.js +2 -1
  49. package/dist/reference/resolve.js +9 -2
  50. package/dist/remote-node/connector.js +8 -1
  51. package/dist/session/agent-permission.d.ts +2 -2
  52. package/dist/session/approval/commands.js +7 -3
  53. package/dist/session/client.d.ts +10 -3
  54. package/dist/session/client.js +14 -2
  55. package/dist/session/commands.d.ts +1 -0
  56. package/dist/session/commands.js +45 -5
  57. package/dist/session/index.d.ts +1 -1
  58. package/dist/session/index.js +1 -1
  59. package/dist/session/output/human.d.ts +1 -0
  60. package/dist/session/output/human.js +1 -1
  61. package/dist/session/output/index.d.ts +1 -1
  62. package/dist/session/output/index.js +1 -1
  63. package/dist/session/tree/tree.js +12 -1
  64. package/dist/session/turn/client.js +7 -9
  65. package/dist/session/turn/commands.js +1 -6
  66. package/dist/status/client.d.ts +6 -1
  67. package/dist/status/command.js +3 -1
  68. package/dist/status/doctor.d.ts +5 -1
  69. package/dist/status/doctor.js +10 -4
  70. package/dist/status/output/compact.d.ts +1 -0
  71. package/dist/status/output/compact.js +3 -0
  72. package/dist/status/output/human.js +10 -0
  73. package/dist/terminal/control-commands.js +26 -9
  74. package/dist/terminal/keys.d.ts +12 -0
  75. package/dist/terminal/keys.js +62 -0
  76. package/dist/terminal/tree/tree.js +1 -1
  77. package/guidance/maia-cli/SKILL.md +1 -1
  78. package/guidance/maia-node/SKILL.md +54 -0
  79. package/guidance/maia-orchestration/SKILL.md +1 -2
  80. package/guidance/maia-sessions/SKILL.md +69 -0
  81. package/package.json +6 -6
@@ -1,18 +1,21 @@
1
1
  import { MAX_SESSION_INBOX_CHECK_LIMIT, MAX_SESSION_MESSAGE_BODY_BYTES, MAX_SESSION_OBSERVE_IDS, MAX_SESSION_STALL_AFTER_SECONDS, MIN_SESSION_STALL_AFTER_SECONDS, SESSION_EFFORT_LEVELS, sessionBaseRefSchema, sessionCreateParametersSchema, } from "@maiaos/sdk";
2
2
  import { Effect } from "effect";
3
3
  import { listEach, writeMerged } from "../address-space/index.js";
4
- import { CliArgumentError, parseOptions, readCursor, readDuration, readExpectedRevision, readPageSize, requirePositionals, } from "../command-line/index.js";
4
+ import { CliArgumentError, parseOptions, parseOptionsWith, readCursor, readDuration, readExpectedRevision, readPageSize, readWaitTimeoutSeconds, requirePositionals, writeNodeResult, } from "../command-line/index.js";
5
5
  import { mergeLists } from "../fleet/index.js";
6
6
  import { runSessionTasks, } from "./create-tasks.js";
7
- import { formatMergedSessions, writeSessionResult } from "./output/index.js";
7
+ import { formatMergedSessions, formatSessionShow, writeSessionResult, } from "./output/index.js";
8
+ const EXIT_DEADLINE = 74;
8
9
  const SESSION_CREATE_OPTIONS = new Set([
9
10
  "--agent",
10
11
  "--base",
11
12
  "--command-id",
12
13
  "--connection",
14
+ "--cwd",
13
15
  "--effort",
14
16
  "--executor",
15
17
  "--model",
18
+ "--name",
16
19
  "--agent-definition",
17
20
  "--agent-definition-version",
18
21
  "--agent-definition-digest",
@@ -117,18 +120,25 @@ const readAgentId = (options) => {
117
120
  throw new CliArgumentError(`Option '--agent' fixes the harness, Connection, model and effort; drop '${clash}'.`);
118
121
  return { agentId };
119
122
  };
123
+ const readSessionTitle = (options) => {
124
+ if (options.has("--name") && options.has("--title"))
125
+ throw new CliArgumentError("Use one of '--name' or '--title'.");
126
+ return options.get("--title") ?? options.get("--name");
127
+ };
120
128
  const readSessionSelection = (options, workspaceId) => {
121
129
  const agent = readAgentId(options);
122
130
  const commandId = options.get("--command-id");
123
131
  const connectionId = options.get("--connection");
124
132
  const executor = readExecutorKind(options.get("--executor"));
125
133
  const effort = readEffort(options.get("--effort"));
134
+ const cwd = options.get("--cwd");
126
135
  const model = options.get("--model");
127
- const title = options.get("--title");
136
+ const title = readSessionTitle(options);
128
137
  const selection = {
129
138
  ...agent,
130
139
  ...(commandId === undefined ? {} : { commandId }),
131
140
  ...(connectionId === undefined ? {} : { connectionId }),
141
+ ...(cwd === undefined ? {} : { cwd }),
132
142
  ...(effort === undefined ? {} : { effort }),
133
143
  ...(executor === undefined ? {} : { executor }),
134
144
  ...(model === undefined ? {} : { model }),
@@ -188,8 +198,9 @@ const taskSource = (parsed) => {
188
198
  const stdin = parsed.flags.has("--prompt-stdin");
189
199
  if ([file, message, stdin ? "" : undefined].filter((value) => value !== undefined).length > 1)
190
200
  throw new CliArgumentError("Use one of '--message', '--prompt-stdin' or '--from-file'.");
191
- if (file !== undefined && parsed.options.has("--title"))
192
- throw new CliArgumentError("Option '--title' names one Session; with '--from-file' each Session takes its task's first line.");
201
+ if (file !== undefined &&
202
+ (parsed.options.has("--title") || parsed.options.has("--name")))
203
+ throw new CliArgumentError("Option '--title' or '--name' names one Session; with '--from-file' each Session takes its task's first line.");
193
204
  if (file !== undefined)
194
205
  return { kind: "file", path: file };
195
206
  if (message !== undefined)
@@ -287,6 +298,35 @@ export const runSessionShow = (tokens, context) => Effect.gen(function* () {
287
298
  result: value,
288
299
  }));
289
300
  });
301
+ const readWaitInput = (tokens) => {
302
+ const parsed = parseOptionsWith(tokens, {
303
+ allowed: new Set(["--timeout", "--until"]),
304
+ allowedFlags: new Set(),
305
+ repeatable: new Set(["--until"]),
306
+ });
307
+ requirePositionals(parsed.positionals, 1);
308
+ const [sessionId] = parsed.positionals;
309
+ const states = parsed.options.get("--until")?.split(",");
310
+ if (sessionId === undefined || states === undefined)
311
+ throw new CliArgumentError("Name the Session and the state or states to wait for with '--until'.");
312
+ return {
313
+ sessionId,
314
+ states,
315
+ timeoutMilliseconds: readWaitTimeoutSeconds(parsed.options.get("--timeout")) * 1000,
316
+ };
317
+ };
318
+ export const runSessionWait = (tokens, context) => Effect.gen(function* () {
319
+ const input = readWaitInput(tokens);
320
+ const { waitSession } = context.dependencies;
321
+ if (waitSession === undefined)
322
+ throw new CliArgumentError("Session wait is unavailable.");
323
+ const result = yield* waitSession(input);
324
+ const code = writeNodeResult(result, context, {
325
+ toResult: (value) => ({ command: "session.wait", result: value }),
326
+ toText: ({ result: waited }) => formatSessionShow(waited),
327
+ });
328
+ return result.ok && !result.value.satisfied ? EXIT_DEADLINE : code;
329
+ });
290
330
  const readLifecycleInput = (parsed) => {
291
331
  const sessionId = parsed.positionals[0];
292
332
  if (sessionId === undefined) {
@@ -4,6 +4,6 @@ export { type AttachSessionInput, makeAttachClient, type SessionAttachStream, }
4
4
  export { type CreateSessionInput, type ListSessionsInput, makeSessionClient, type StartSessionInput, } from "./client.js";
5
5
  export { type ArchiveSessionInput, type DiffSessionInput, } from "./coding-client.js";
6
6
  export { runSessionArchive, runSessionDiff } from "./coding-commands.js";
7
- export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, } from "./commands.js";
7
+ export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, runSessionWait, } from "./commands.js";
8
8
  export { runSessionRename } from "./rename.js";
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -3,6 +3,6 @@ export { runSessionAttach } from "./attach.js";
3
3
  export { makeAttachClient, } from "./attach-client.js";
4
4
  export { makeSessionClient, } from "./client.js";
5
5
  export { runSessionArchive, runSessionDiff } from "./coding-commands.js";
6
- export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, } from "./commands.js";
6
+ export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, runSessionWait, } from "./commands.js";
7
7
  export { runSessionRename } from "./rename.js";
8
8
  //# sourceMappingURL=index.js.map
@@ -103,6 +103,7 @@ export type CliSessionResult = {
103
103
  readonly command: "session.show";
104
104
  readonly result: SessionShowResult;
105
105
  };
106
+ export declare const formatSessionShow: ({ session, }: Pick<SessionShowResult, "session">) => string;
106
107
  export declare const formatSessionResult: (result: CliSessionResult) => string;
107
108
  export declare const writeSessionResult: <TValue>(result: CliNodeResult<TValue>, context: {
108
109
  readonly io: CliIo;
@@ -31,7 +31,7 @@ const formatCodingSession = (result) => {
31
31
  const formatAgentPermission = (result) => result.command === "session.agent-permission.preview"
32
32
  ? `${result.result.sessionId}\t${result.result.expiresAt}\n`
33
33
  : `${result.result.receipt.receiptId}\t${result.result.delivery}\n`;
34
- const formatSessionShow = ({ session, }) => `${fields([
34
+ export const formatSessionShow = ({ session, }) => `${fields([
35
35
  ["session", session.id],
36
36
  ["state", session.state],
37
37
  ["revision", session.revision],
@@ -1,6 +1,6 @@
1
1
  export { formatSessionDiff } from "./diff.js";
2
2
  export { formatFailure, formatFailureCell, formatSessionEvents, } from "./failure.js";
3
- export { type CliSessionResult, formatSessionResult, writeSessionResult, } from "./human.js";
3
+ export { type CliSessionResult, formatSessionResult, formatSessionShow, writeSessionResult, } from "./human.js";
4
4
  export { formatSessionObservation } from "./observe.js";
5
5
  export { type CliSessionList, type CliSessionTaskItem, type CliSessionTasksResult, formatMergedSessions, formatSessionList, formatSessionTasks, } from "./tasks.js";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
1
  export { formatSessionDiff } from "./diff.js";
2
2
  export { formatFailure, formatFailureCell, formatSessionEvents, } from "./failure.js";
3
- export { formatSessionResult, writeSessionResult, } from "./human.js";
3
+ export { formatSessionResult, formatSessionShow, writeSessionResult, } from "./human.js";
4
4
  export { formatSessionObservation } from "./observe.js";
5
5
  export { formatMergedSessions, formatSessionList, formatSessionTasks, } from "./tasks.js";
6
6
  //# sourceMappingURL=index.js.map
@@ -18,7 +18,7 @@ export const SESSION_TREE = {
18
18
  ],
19
19
  leaves: [
20
20
  [
21
- "session create (--workspace <workspace-id> | --project <project-id>) [--command-id <id>] [--role <worker|orchestrator>] [--connection <connection-id> [--executor <codex-cli|claude-code>] [--model <id>] | --executor <codex-cli|claude-code> | --agent <agent-id> | --agent-definition <key> --agent-definition-version <version> --agent-definition-digest <sha256>] [--effort <low|medium|high|xhigh|max|ultra>] [--base <branch-tag-or-commit>] [--title <text>] [--message <text> | --prompt-stdin | --from-file <path>]",
21
+ "session create (--workspace <workspace-id> | --project <project-id>) [--command-id <id>] [--role <worker|orchestrator>] [--connection <connection-id> [--executor <codex-cli|claude-code>] [--model <id>] | --executor <codex-cli|claude-code> | --agent <agent-id> | --agent-definition <key> --agent-definition-version <version> --agent-definition-digest <sha256>] [--effort <low|medium|high|xhigh|max|ultra>] [--base <branch-tag-or-commit>] [--cwd <path>] [--title <text> | --name <text>] [--message <text> | --prompt-stdin | --from-file <path>]",
22
22
  0,
23
23
  "session.create",
24
24
  "Create a Session, optionally starting it with a first message.",
@@ -50,6 +50,17 @@ export const SESSION_TREE = {
50
50
  run: [session, "runSessionShow"],
51
51
  },
52
52
  ],
53
+ [
54
+ "session wait <session-id> --until <state>[,<state>...] [--timeout <duration>]",
55
+ 1,
56
+ "session.wait",
57
+ "Wait until a Session reaches one of the states; exits 74 on timeout.",
58
+ {
59
+ example: "maia --json session wait session_1 --until idle --until failed --timeout 10m",
60
+ route: "<session-id>",
61
+ run: [session, "runSessionWait"],
62
+ },
63
+ ],
53
64
  [
54
65
  "session rename <session-id> --title <text> --expected-revision <revision> [--command-id <id>]",
55
66
  1,
@@ -1,6 +1,6 @@
1
1
  import { MAX_TURN_WAIT_MILLISECONDS, turnCancelParametersSchema, turnInterruptParametersSchema, turnQueueListParametersSchema, turnSendParametersSchema, turnShowParametersSchema, turnWaitParametersSchema, } from "@maiaos/sdk";
2
2
  import { Effect } from "effect";
3
- import { commandIdentifier, } from "../../local-node/index.js";
3
+ import { commandIdentifier, repeatBoundedWait, } from "../../local-node/index.js";
4
4
  export const makeTurnClient = (node) => {
5
5
  const interruptTurn = (input) => {
6
6
  return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
@@ -29,17 +29,15 @@ export const makeTurnClient = (node) => {
29
29
  };
30
30
  const showTurn = (turnId) => node.runValidatedNodeOperation({ turnId }, turnShowParametersSchema, (client, parameters, options) => client.showTurn(parameters, options));
31
31
  const waitTurnsOnce = (parameters) => node.runValidatedNodeOperation(parameters, turnWaitParametersSchema, (client, validated, options) => client.waitTurns(validated, options));
32
- const waitWithin = (input) => Effect.gen(function* () {
33
- const waitMilliseconds = Math.min(MAX_TURN_WAIT_MILLISECONDS, input.timeoutMilliseconds);
34
- const result = yield* waitTurnsOnce({
32
+ const waitWithin = (input) => repeatBoundedWait({
33
+ maxRequestMilliseconds: MAX_TURN_WAIT_MILLISECONDS,
34
+ once: (waitMilliseconds) => waitTurnsOnce({
35
35
  mode: input.mode,
36
36
  turnIds: input.turnIds,
37
37
  waitMilliseconds,
38
- });
39
- const remaining = input.timeoutMilliseconds - waitMilliseconds;
40
- if (!result.ok || result.value.satisfied || remaining <= 0)
41
- return result;
42
- return yield* waitWithin({ ...input, timeoutMilliseconds: remaining });
38
+ }),
39
+ satisfied: (value) => value.satisfied,
40
+ timeoutMilliseconds: input.timeoutMilliseconds,
43
41
  });
44
42
  return {
45
43
  cancelTurn,
@@ -1,6 +1,6 @@
1
1
  import { MAX_TURN_INPUT_BYTES, MAX_TURN_WAIT_IDS, } from "@maiaos/sdk";
2
2
  import * as Effect from "effect/Effect";
3
- import { CliArgumentError, parseOptions, readDuration, readExpectedRevision, readRevisionOption, requirePositionals, writeNodeResult, } from "../../command-line/index.js";
3
+ import { CliArgumentError, parseOptions, readExpectedRevision, readRevisionOption, readWaitTimeoutSeconds, requirePositionals, writeNodeResult, } from "../../command-line/index.js";
4
4
  import { formatTurnMutation, formatTurnQueue, formatTurnShow, formatTurnWait, turnWaitExitCode, } from "./output.js";
5
5
  const utf8 = new TextEncoder();
6
6
  const summarizeTurnMutation = (result) => ({
@@ -156,11 +156,6 @@ export const runTurnShow = (tokens, context) => Effect.gen(function* () {
156
156
  toText: formatTurnShow,
157
157
  });
158
158
  });
159
- const DEFAULT_TURN_WAIT_SECONDS = 600;
160
- const MAX_TURN_WAIT_SECONDS = 86_400;
161
- const readWaitTimeoutSeconds = (value) => value === undefined
162
- ? DEFAULT_TURN_WAIT_SECONDS
163
- : readDuration(value, "--timeout", { max: MAX_TURN_WAIT_SECONDS, min: 1 });
164
159
  const parseTurnWaitArguments = (tokens) => {
165
160
  const parsed = parseOptions(tokens, new Set(["--timeout"]), new Set(["--any"]));
166
161
  if (parsed.positionals.length === 0 ||
@@ -114,7 +114,12 @@ export declare const makeStatusClient: (node: CliNodeOperations) => {
114
114
  };
115
115
  };
116
116
  readonly storage: {
117
- readonly integrity: "ok";
117
+ readonly events?: {
118
+ readonly checkpointBlocked?: boolean | undefined;
119
+ readonly excessBytes: number;
120
+ readonly oldestAgeMs?: number | undefined;
121
+ } | undefined;
122
+ readonly integrity: "ok" | "unavailable";
118
123
  readonly journalMode: "wal";
119
124
  readonly schemaTag: string;
120
125
  readonly schemaVersion: number;
@@ -14,7 +14,9 @@ const unavailableError = (cause) => {
14
14
  const remote = Predicate.hasProperty(error, "remoteError")
15
15
  ? protocolErrorSchema.safeParse(error.remoteError)
16
16
  : undefined;
17
- return remote?.success === true && remote.data.code === "node_unavailable"
17
+ return remote?.success === true &&
18
+ (remote.data.code === "node_unavailable" ||
19
+ remote.data.code === "invalid_argument")
18
20
  ? remote.data
19
21
  : createUnavailableError();
20
22
  };
@@ -5,9 +5,13 @@ export type DoctorCheck = {
5
5
  readonly next?: string;
6
6
  readonly ok: boolean;
7
7
  };
8
+ export type DoctorScope = "machine" | "node";
8
9
  export type CliDoctorResult = {
9
- readonly checks: readonly DoctorCheck[];
10
+ readonly checks: readonly (DoctorCheck & {
11
+ readonly scope: DoctorScope;
12
+ })[];
10
13
  readonly command: "doctor";
14
+ readonly node?: string;
11
15
  readonly ok: boolean;
12
16
  readonly version: string;
13
17
  };
@@ -1,6 +1,6 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import * as Option from "effect/Option";
3
- import { requireNoArguments, writeSuccess, } from "../command-line/index.js";
3
+ import { LOCAL_NODE, requireNoArguments, writeSuccess, } from "../command-line/index.js";
4
4
  const EXIT_FAILED = 70;
5
5
  const vendorWords = (executor) => executor === "codex-cli"
6
6
  ? { integration: "codex", login: "codex" }
@@ -71,8 +71,8 @@ const nodeChecks = (detected, connections) => {
71
71
  ]),
72
72
  ];
73
73
  };
74
- const formatDoctor = (result) => `Maia doctor ${result.ok ? "ok" : "failed"}\n${result.checks
75
- .map((check) => ` ${check.code}: ${check.ok ? "ok" : "failed"}${check.detail === undefined ? "" : ` (${check.detail})`}${check.ok || check.next === undefined ? "" : `; next: ${check.next}`}\n`)
74
+ const formatDoctor = (result) => `Maia doctor ${result.ok ? "ok" : "failed"}${result.node === undefined ? "" : ` (Node ${result.node})`}\n${result.checks
75
+ .map((check) => ` ${check.code}${check.scope === "machine" ? " (this machine)" : ""}: ${check.ok ? "ok" : "failed"}${check.detail === undefined ? "" : ` (${check.detail})`}${check.ok || check.next === undefined ? "" : `; next: ${check.next}`}\n`)
76
76
  .join("")}`;
77
77
  const readLifecycle = (dependencies) => Effect.map(Effect.option(Effect.map(Effect.suspend(() => dependencies.readStatus()), (node) => node.lifecycle)), Option.getOrUndefined);
78
78
  const nodeCheck = (lifecycle) => lifecycle === undefined
@@ -100,8 +100,14 @@ export const runDoctor = (tokens, context) => Effect.gen(function* () {
100
100
  const checks = yield* readChecks(context);
101
101
  const ok = checks.every((check) => check.ok);
102
102
  const result = {
103
- checks,
103
+ checks: checks.map((check) => ({
104
+ ...check,
105
+ scope: check.code === "cli" ? "machine" : "node",
106
+ })),
104
107
  command: "doctor",
108
+ ...(context.node === undefined || context.node === LOCAL_NODE
109
+ ? {}
110
+ : { node: context.node }),
105
111
  ok,
106
112
  version: context.version,
107
113
  };
@@ -23,6 +23,7 @@ export type CliCompactStatusResult = {
23
23
  };
24
24
  readonly profile: LocalNodeStatusResult["profile"];
25
25
  readonly storage: {
26
+ readonly events?: LocalNodeStatusResult["storage"]["events"];
26
27
  readonly integrity: LocalNodeStatusResult["storage"]["integrity"];
27
28
  readonly journalMode: LocalNodeStatusResult["storage"]["journalMode"];
28
29
  readonly schemaVersion: LocalNodeStatusResult["storage"]["schemaVersion"];
@@ -41,6 +41,9 @@ export const projectStatusResult = (node) => ({
41
41
  },
42
42
  profile: node.profile,
43
43
  storage: {
44
+ ...(node.storage.events === undefined
45
+ ? {}
46
+ : { events: node.storage.events }),
44
47
  integrity: node.storage.integrity,
45
48
  journalMode: node.storage.journalMode,
46
49
  schemaVersion: node.storage.schemaVersion,
@@ -73,12 +73,22 @@ const executorHostLines = (host) => {
73
73
  userNamespaces[host.userNamespaces],
74
74
  ];
75
75
  };
76
+ const eventLines = (events) => events === undefined
77
+ ? []
78
+ : [
79
+ `events: ${String(events.excessBytes)} bytes over limit` +
80
+ (events.oldestAgeMs === undefined
81
+ ? ""
82
+ : `, oldest ${String(Math.floor(events.oldestAgeMs / 3_600_000))} h`) +
83
+ (events.checkpointBlocked === true ? ", checkpoint blocked" : ""),
84
+ ];
76
85
  export const formatHumanStatus = ({ node }) => {
77
86
  const lines = [
78
87
  `profile: ${node.profile}`,
79
88
  `pid: ${String(node.pid)}`,
80
89
  `instance: ${node.instanceId}`,
81
90
  `storage: ${node.storage.integrity} (${node.storage.journalMode})`,
91
+ ...eventLines(node.storage.events),
82
92
  ...processResourceLines(node.processResources),
83
93
  ...executorHostLines(node.executorHost),
84
94
  ];
@@ -3,8 +3,19 @@ import { liveTerminalWriteParametersSchema, MAX_TERMINAL_INPUT_CHUNK_BYTES, } fr
3
3
  import * as Effect from "effect/Effect";
4
4
  import { CliArgumentError, parseOptions, requirePositionals, } from "../command-line/index.js";
5
5
  import { readTerminalColumns, readTerminalControllerFence, readTerminalExpectedRevision, readTerminalGeneration, readTerminalInputSequence, readTerminalLeaseDuration, readTerminalRows, terminalControllerFenceOptionNames, } from "./arguments.js";
6
+ import { terminalInputBytes, UnknownKeyError } from "./keys.js";
6
7
  import { writeTerminalResult } from "./output/index.js";
7
8
  const optionNames = (...additional) => new Set([...terminalControllerFenceOptionNames, ...additional]);
9
+ const typedInputBytes = (options) => {
10
+ try {
11
+ return terminalInputBytes([...options].filter(([name]) => name === "--text" || name === "--keys"));
12
+ }
13
+ catch (error) {
14
+ throw error instanceof UnknownKeyError
15
+ ? new CliArgumentError(error.message)
16
+ : error;
17
+ }
18
+ };
8
19
  const commandId = (options) => {
9
20
  const value = options.get("--command-id");
10
21
  return value === undefined ? {} : { commandId: value };
@@ -99,15 +110,15 @@ export const runControllerAcquire = (tokens, context) => Effect.gen(function* ()
99
110
  }));
100
111
  });
101
112
  const parseTerminalWriteOptions = (tokens) => {
102
- const parsed = parseOptions(tokens, optionNames("--input-id", "--input-sequence"), new Set(["--input-stdin"]));
113
+ const parsed = parseOptions(tokens, optionNames("--input-id", "--input-sequence", "--keys", "--text"), new Set(["--input-stdin"]));
103
114
  requirePositionals(parsed.positionals, 1);
104
- if (!parsed.flags.has("--input-stdin")) {
105
- throw new CliArgumentError("Option '--input-stdin' is required.");
115
+ const typed = parsed.options.has("--text") || parsed.options.has("--keys");
116
+ if (parsed.flags.has("--input-stdin") === typed) {
117
+ throw new CliArgumentError("Give the input as '--input-stdin' or as '--text' and '--keys', not both.");
106
118
  }
107
119
  return parsed;
108
120
  };
109
- const readTerminalWriteScope = (tokens) => {
110
- const parsed = parseTerminalWriteOptions(tokens);
121
+ const readTerminalWriteScope = (parsed) => {
111
122
  const terminalId = requiredTerminalId(parsed.positionals);
112
123
  const inputId = parsed.options.get("--input-id");
113
124
  if (inputId === undefined) {
@@ -146,14 +157,20 @@ const readTerminalInput = (context) => {
146
157
  });
147
158
  };
148
159
  export const runTerminalInputWrite = (tokens, context) => Effect.gen(function* () {
149
- const scope = readTerminalWriteScope(tokens);
150
- const input = yield* readTerminalInput(context);
151
- if (input.length === 0) {
160
+ const parsed = parseTerminalWriteOptions(tokens);
161
+ const scope = readTerminalWriteScope(parsed);
162
+ const bytes = parsed.flags.has("--input-stdin")
163
+ ? Buffer.from(yield* readTerminalInput(context), "utf8")
164
+ : typedInputBytes(parsed.options);
165
+ if (bytes.length === 0) {
152
166
  throw new CliArgumentError("Terminal input must not be empty.");
153
167
  }
168
+ if (bytes.length > MAX_TERMINAL_INPUT_CHUNK_BYTES) {
169
+ throw new CliArgumentError(`Terminal input must be at most ${String(MAX_TERMINAL_INPUT_CHUNK_BYTES)} bytes.`);
170
+ }
154
171
  const result = yield* context.dependencies.writeTerminalInput({
155
172
  ...scope,
156
- bytesBase64: Buffer.from(input, "utf8").toString("base64"),
173
+ bytesBase64: bytes.toString("base64"),
157
174
  });
158
175
  return writeTerminalResult(result, context, (value) => ({
159
176
  command: "terminal.input.write",
@@ -0,0 +1,12 @@
1
+ import { Buffer } from "node:buffer";
2
+ declare const UnknownKeyError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
3
+ readonly _tag: "UnknownKeyError";
4
+ } & Readonly<A>;
5
+ export declare class UnknownKeyError extends UnknownKeyError_base<{
6
+ readonly message: string;
7
+ }> {
8
+ }
9
+ export declare const TERMINAL_KEY_NAMES: readonly string[];
10
+ export declare const terminalInputBytes: (parts: Iterable<readonly [option: string, value: string]>) => Buffer;
11
+ export {};
12
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1,62 @@
1
+ import { Buffer } from "node:buffer";
2
+ import { Data } from "effect";
3
+ const NAMED_KEYS = new Map([
4
+ ["Backspace", "\u007F"],
5
+ ["Delete", "\u001B[3~"],
6
+ ["Down", "\u001B[B"],
7
+ ["End", "\u001B[F"],
8
+ ["Enter", "\r"],
9
+ ["Escape", "\u001B"],
10
+ ["F1", "\u001BOP"],
11
+ ["F2", "\u001BOQ"],
12
+ ["F3", "\u001BOR"],
13
+ ["F4", "\u001BOS"],
14
+ ["F5", "\u001B[15~"],
15
+ ["F6", "\u001B[17~"],
16
+ ["F7", "\u001B[18~"],
17
+ ["F8", "\u001B[19~"],
18
+ ["F9", "\u001B[20~"],
19
+ ["F10", "\u001B[21~"],
20
+ ["F11", "\u001B[23~"],
21
+ ["F12", "\u001B[24~"],
22
+ ["Home", "\u001B[H"],
23
+ ["Insert", "\u001B[2~"],
24
+ ["Left", "\u001B[D"],
25
+ ["PageDown", "\u001B[6~"],
26
+ ["PageUp", "\u001B[5~"],
27
+ ["Right", "\u001B[C"],
28
+ ["Space", " "],
29
+ ["Tab", "\t"],
30
+ ["Up", "\u001B[A"],
31
+ ]);
32
+ export class UnknownKeyError extends Data.TaggedError("UnknownKeyError") {
33
+ }
34
+ export const TERMINAL_KEY_NAMES = [
35
+ ...NAMED_KEYS.keys(),
36
+ "C-<a..z>",
37
+ "M-<char>",
38
+ ];
39
+ const bytesOfKey = (name) => {
40
+ const named = NAMED_KEYS.get(name);
41
+ if (named !== undefined)
42
+ return named;
43
+ if (/^C-[a-z]$/u.test(name)) {
44
+ return String.fromCodePoint((name.codePointAt(2) ?? 0) - 0x60);
45
+ }
46
+ const alt = /^M-(\P{Cc})$/u.exec(name);
47
+ if (alt?.[1] !== undefined)
48
+ return `\u001B${alt[1]}`;
49
+ throw new UnknownKeyError({
50
+ message: `Unknown key '${name}'. Keys: ${TERMINAL_KEY_NAMES.join(", ")}.`,
51
+ });
52
+ };
53
+ export const terminalInputBytes = (parts) => Buffer.from([...parts]
54
+ .map(([option, value]) => option === "--text"
55
+ ? value
56
+ : value
57
+ .split(/\s+/u)
58
+ .filter((name) => name !== "")
59
+ .map(bytesOfKey)
60
+ .join(""))
61
+ .join(""), "utf8");
62
+ //# sourceMappingURL=keys.js.map
@@ -72,7 +72,7 @@ export const TERMINAL_TREE = {
72
72
  { route: "<terminal-id>", run: [terminal, "runControllerRelease"] },
73
73
  ],
74
74
  [
75
- "terminal input write <terminal-id> --input-stdin --input-id <id> --input-sequence <1..2147483647> --controller-id <id> --controller-epoch <epoch> --controller-revision <revision> --controller-expires-at <timestamp> --terminal-generation <1..65535> --expected-revision <revision> [--command-id <id>]",
75
+ "terminal input write <terminal-id> (--input-stdin | [--text <text>] [--keys <names>]) --input-id <id> --input-sequence <1..2147483647> --controller-id <id> --controller-epoch <epoch> --controller-revision <revision> --controller-expires-at <timestamp> --terminal-generation <1..65535> --expected-revision <revision> [--command-id <id>]",
76
76
  1,
77
77
  "terminal.input.write",
78
78
  "Write input to a terminal you control.",
@@ -11,7 +11,7 @@ description: >
11
11
  ## Goal
12
12
 
13
13
  Use the installed `maia` binary as the public client. Treat `maia help --json`
14
- and `maia help <family> --json` as the command allowlist.
14
+ and `maia help session --json` (or any other family) as the command allowlist.
15
15
 
16
16
  ## Main rules
17
17
 
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: maia-node
3
+ description: >
4
+ Check a Maia Node's health and reach local or remote Nodes with --node and
5
+ --profile through the public CLI. Use when an agent must find which Node a
6
+ command ran on, see whether a Node is ready, or register another Node.
7
+ ---
8
+
9
+ # Maia Node
10
+
11
+ A Node is the one place Maia keeps state and runs work. The CLI is a client of
12
+ it. Confirm each command on `maia help node --json` before use.
13
+
14
+ ## Rules
15
+
16
+ 1. Pass `--json` and read results from stdout and errors from stderr.
17
+ 2. `--node <name>` sends a Node-backed command to a registered remote Node.
18
+ `--node local` names this machine. `--profile <name>` picks a local profile.
19
+ A flag beats `MAIA_NODE` and `MAIA_PROFILE`, which beat the default.
20
+ 3. A command that manages this machine's Nodes, such as `maia node list`,
21
+ refuses `--node`.
22
+ 4. An id belongs to one Node. A missing id (`resource_not_found`, exit 66) on
23
+ the selected Node does not prove it is absent everywhere; check the Node
24
+ selection and retry with the `--node` that holds it.
25
+ 5. Exit code 69 means the Node is unavailable. Report it; do not start a Node
26
+ unless the caller asked for it.
27
+
28
+ ## Implemented
29
+
30
+ ```sh
31
+ maia --json status
32
+ maia --json node status
33
+ maia --json --node local node status
34
+ ```
35
+
36
+ `node monitor` prints a one-time loopback URL for the admin monitor.
37
+
38
+ ## Source candidates (release-disabled)
39
+
40
+ ```sh
41
+ maia --json node list
42
+ maia --json node register <host> --name <name> --dry-run
43
+ maia --json node remove <node> --dry-run
44
+ ```
45
+
46
+ `node register`, `node install` and `node remove` preview with `--dry-run`.
47
+ Confirm the preview only on the caller's request, from stdin with
48
+ `--confirm-stdin`.
49
+
50
+ ## Do not
51
+
52
+ - Do not copy a Node's credentials or tokens into a prompt, a file or a log.
53
+ - Do not expose a Node beyond loopback or its tailnet.
54
+ - Do not remove a Node with `--purge` unless the caller named that.
@@ -5,7 +5,7 @@ description: >
5
5
  public CLI: create, list, show, task list and show, inbox check and ack,
6
6
  questions, and dispatch show or settle-terminal. Use when an external agent
7
7
  is the explicit Run coordinator. Do not treat these commands as
8
- release-enabled, worker assignment, or Orca equivalence.
8
+ release-enabled or worker assignment.
9
9
  ---
10
10
 
11
11
  # Maia orchestration
@@ -51,4 +51,3 @@ caller-selected outcome. `settle-terminal` only records the Terminal's exact
51
51
  unavailable failure. Do not teach Skill install/sync or extra runtime probes.
52
52
 
53
53
  A compact CLI projection is not a protocol change. The SDK remains lossless.
54
- No Orca command is equivalent.