@maiaos/cli 0.1.0-canary.44938d4.manual.1

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 (75) hide show
  1. package/README.md +382 -0
  2. package/dist/bin/maia.NOTICES.txt +31 -0
  3. package/dist/bin/maia.cdx.json +138 -0
  4. package/dist/bin/maia.mjs +115 -0
  5. package/dist/command-line/arguments.d.ts +21 -0
  6. package/dist/command-line/arguments.js +99 -0
  7. package/dist/command-line/context.d.ts +112 -0
  8. package/dist/command-line/context.js +2 -0
  9. package/dist/command-line/help.d.ts +36 -0
  10. package/dist/command-line/help.js +267 -0
  11. package/dist/command-line/output.d.ts +2111 -0
  12. package/dist/command-line/output.js +643 -0
  13. package/dist/command-line/stdin.d.ts +7 -0
  14. package/dist/command-line/stdin.js +34 -0
  15. package/dist/command-receipt/command.d.ts +3 -0
  16. package/dist/command-receipt/command.js +63 -0
  17. package/dist/command-receipt/compact-list.d.ts +18 -0
  18. package/dist/command-receipt/compact-list.js +18 -0
  19. package/dist/context/client.d.ts +4 -0
  20. package/dist/context/client.js +19 -0
  21. package/dist/context/commands.d.ts +3 -0
  22. package/dist/context/commands.js +13 -0
  23. package/dist/index.d.ts +7 -0
  24. package/dist/index.js +202 -0
  25. package/dist/integration-authorization/client.d.ts +16 -0
  26. package/dist/integration-authorization/client.js +30 -0
  27. package/dist/integration-authorization/commands.d.ts +3 -0
  28. package/dist/integration-authorization/commands.js +92 -0
  29. package/dist/local-node/client.d.ts +31 -0
  30. package/dist/local-node/client.js +99 -0
  31. package/dist/orchestration/client.d.ts +59 -0
  32. package/dist/orchestration/client.js +66 -0
  33. package/dist/orchestration/commands.d.ts +3 -0
  34. package/dist/orchestration/commands.js +336 -0
  35. package/dist/orchestration/compact-aggregate.d.ts +123 -0
  36. package/dist/orchestration/compact-aggregate.js +110 -0
  37. package/dist/orchestration/compact-run-list.d.ts +19 -0
  38. package/dist/orchestration/compact-run-list.js +16 -0
  39. package/dist/project-workspace/client.d.ts +43 -0
  40. package/dist/project-workspace/client.js +54 -0
  41. package/dist/project-workspace/commands.d.ts +5 -0
  42. package/dist/project-workspace/commands.js +239 -0
  43. package/dist/runtime/client.d.ts +6 -0
  44. package/dist/runtime/client.js +10 -0
  45. package/dist/runtime/command.d.ts +3 -0
  46. package/dist/runtime/command.js +20 -0
  47. package/dist/session/client.d.ts +32 -0
  48. package/dist/session/client.js +30 -0
  49. package/dist/session/commands.d.ts +3 -0
  50. package/dist/session/commands.js +160 -0
  51. package/dist/status/client.d.ts +5 -0
  52. package/dist/status/client.js +15 -0
  53. package/dist/status/command.d.ts +3 -0
  54. package/dist/status/command.js +17 -0
  55. package/dist/status/compact.d.ts +31 -0
  56. package/dist/status/compact.js +46 -0
  57. package/dist/terminal/arguments.d.ts +12 -0
  58. package/dist/terminal/arguments.js +79 -0
  59. package/dist/terminal/client.d.ts +45 -0
  60. package/dist/terminal/client.js +48 -0
  61. package/dist/terminal/commands.d.ts +3 -0
  62. package/dist/terminal/commands.js +151 -0
  63. package/dist/terminal/compact-list.d.ts +148 -0
  64. package/dist/terminal/compact-list.js +152 -0
  65. package/dist/terminal/control-commands.d.ts +7 -0
  66. package/dist/terminal/control-commands.js +211 -0
  67. package/dist/turn/client.d.ts +17 -0
  68. package/dist/turn/client.js +23 -0
  69. package/dist/turn/commands.d.ts +3 -0
  70. package/dist/turn/commands.js +126 -0
  71. package/dist/turn/prompt.d.ts +2 -0
  72. package/dist/turn/prompt.js +9 -0
  73. package/guidance/maia-cli/SKILL.md +75 -0
  74. package/guidance/maia-orchestration/SKILL.md +54 -0
  75. package/package.json +50 -0
@@ -0,0 +1,126 @@
1
+ import { MAX_TURN_INPUT_BYTES, } from "@maiaos/sdk";
2
+ import { CliArgumentError, parseOptions, readExpectedRevision, requirePositionals, } from "../command-line/arguments.js";
3
+ import { writeNodeResult } from "../command-line/output.js";
4
+ const utf8 = new TextEncoder();
5
+ const summarizeTurnMutation = (result) => ({
6
+ delivery: result.delivery,
7
+ receipt: result.receipt,
8
+ revision: result.turn.revision,
9
+ sessionId: result.turn.sessionId,
10
+ state: result.turn.state,
11
+ turnId: result.turn.id,
12
+ });
13
+ const parseTurnSendArguments = (tokens) => {
14
+ const parsed = parseOptions(tokens, new Set(["--command-id", "--expected-revision"]), new Set(["--prompt-stdin"]));
15
+ requirePositionals(parsed.positionals, 1, "maia turn send <session-id> --prompt-stdin --expected-revision <revision>");
16
+ const sessionId = parsed.positionals[0];
17
+ if (sessionId === undefined) {
18
+ throw new CliArgumentError("The session identifier is missing.");
19
+ }
20
+ if (!parsed.flags.has("--prompt-stdin")) {
21
+ throw new CliArgumentError("Option '--prompt-stdin' is required.");
22
+ }
23
+ const commandId = parsed.options.get("--command-id");
24
+ return {
25
+ expectedRevision: readExpectedRevision(parsed.options.get("--expected-revision")),
26
+ sessionId,
27
+ ...(commandId === undefined ? {} : { commandId }),
28
+ };
29
+ };
30
+ const runTurnSend = async (tokens, context) => {
31
+ const input = parseTurnSendArguments(tokens);
32
+ if (context.io.stdin === undefined) {
33
+ throw new CliArgumentError("Standard input is unavailable.");
34
+ }
35
+ const prompt = await context.io.stdin({
36
+ label: "turn prompt",
37
+ maxBytes: MAX_TURN_INPUT_BYTES,
38
+ maxChunks: 1024,
39
+ });
40
+ const result = await context.dependencies.sendTurn({ ...input, prompt });
41
+ return writeNodeResult(result, context, (value) => ({
42
+ command: "turn.send",
43
+ result: summarizeTurnMutation(value),
44
+ }));
45
+ };
46
+ const parseTurnInterruptArguments = (tokens) => {
47
+ const parsed = parseOptions(tokens, new Set(["--command-id", "--expected-revision"]));
48
+ requirePositionals(parsed.positionals, 1, "maia turn interrupt <turn-id> --expected-revision <revision>");
49
+ const turnId = parsed.positionals[0];
50
+ if (turnId === undefined) {
51
+ throw new CliArgumentError("The turn identifier is missing.");
52
+ }
53
+ const commandId = parsed.options.get("--command-id");
54
+ return {
55
+ expectedRevision: readExpectedRevision(parsed.options.get("--expected-revision")),
56
+ turnId,
57
+ ...(commandId === undefined ? {} : { commandId }),
58
+ };
59
+ };
60
+ const runTurnInterrupt = async (tokens, context) => {
61
+ const input = parseTurnInterruptArguments(tokens);
62
+ const result = await context.dependencies.interruptTurn(input);
63
+ return writeNodeResult(result, context, (value) => ({
64
+ command: "turn.interrupt",
65
+ result: summarizeTurnMutation(value),
66
+ }));
67
+ };
68
+ const parseTurnShowArguments = (tokens, json) => {
69
+ const parsed = parseOptions(tokens, new Set(), new Set(["--include-content"]));
70
+ requirePositionals(parsed.positionals, 1, "maia turn show <turn-id>");
71
+ const includeContent = parsed.flags.has("--include-content");
72
+ if (includeContent && !json) {
73
+ throw new CliArgumentError("Option '--include-content' requires machine-readable '--json' output.");
74
+ }
75
+ const turnId = parsed.positionals[0];
76
+ if (turnId === undefined) {
77
+ throw new CliArgumentError("The turn identifier is missing.");
78
+ }
79
+ return { includeContent, turnId };
80
+ };
81
+ const turnTerminalProjection = (turn) => {
82
+ if (turn.state === "completed") {
83
+ return {
84
+ responseBytes: utf8.encode(turn.responseText).byteLength,
85
+ ...(turn.tokenUsage === undefined ? {} : { tokenUsage: turn.tokenUsage }),
86
+ };
87
+ }
88
+ return turn.state === "failed" || turn.state === "outcome-unknown"
89
+ ? { failureReason: turn.failureReason }
90
+ : {};
91
+ };
92
+ const projectTurnWithoutContent = (value) => ({
93
+ contentIncluded: false,
94
+ method: value.method,
95
+ turn: {
96
+ id: value.turn.id,
97
+ inputBytes: utf8.encode(value.turn.input.text).byteLength,
98
+ revision: value.turn.revision,
99
+ sessionId: value.turn.sessionId,
100
+ sessionRevision: value.turn.sessionRevision,
101
+ state: value.turn.state,
102
+ ...turnTerminalProjection(value.turn),
103
+ },
104
+ });
105
+ const summarizeTurnShow = (value, includeContent) => includeContent
106
+ ? { ...value, contentIncluded: true }
107
+ : projectTurnWithoutContent(value);
108
+ const runTurnShow = async (tokens, context) => {
109
+ const input = parseTurnShowArguments(tokens, context.json);
110
+ const result = await context.dependencies.showTurn(input.turnId);
111
+ return writeNodeResult(result, context, (value) => ({
112
+ command: "turn.show",
113
+ result: summarizeTurnShow(value, input.includeContent),
114
+ }));
115
+ };
116
+ export const runTurnCommand = (tokens, context) => {
117
+ const [subcommand, ...rest] = tokens;
118
+ if (subcommand === "interrupt")
119
+ return runTurnInterrupt(rest, context);
120
+ if (subcommand === "send")
121
+ return runTurnSend(rest, context);
122
+ if (subcommand === "show")
123
+ return runTurnShow(rest, context);
124
+ throw new CliArgumentError("Usage: maia turn <interrupt|send|show>");
125
+ };
126
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1,2 @@
1
+ export declare const readTurnPrompt: (input: AsyncIterable<string | Uint8Array>) => Promise<string>;
2
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { MAX_TURN_INPUT_BYTES } from "@maiaos/sdk";
2
+ import { readBoundedStdin } from "../command-line/stdin.js";
3
+ const MAX_TURN_INPUT_CHUNKS = 1024;
4
+ export const readTurnPrompt = async (input) => readBoundedStdin(input, {
5
+ label: "turn prompt",
6
+ maxBytes: MAX_TURN_INPUT_BYTES,
7
+ maxChunks: MAX_TURN_INPUT_CHUNKS,
8
+ });
9
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: maia-cli
3
+ description: >
4
+ Operate the public Maia CLI through JSON-first commands. Discover the
5
+ classified index with maia help --json, then maia help <family> --json for
6
+ usage rows. Inspect node status, register projects and workspaces, recover
7
+ receipts, probe Codex compatibility, and create or inspect sessions. Use
8
+ when an external agent must call maia rather than inventing a node API,
9
+ Skill install, or harness adapter.
10
+ ---
11
+
12
+ # Maia CLI
13
+
14
+ Call the installed `maia` binary. Treat the classified index from
15
+ `maia help --json` plus the matching `maia help <family> --json` page as the
16
+ only command list. Do not invent verbs. Do not write `~/.codex`, `~/.claude`,
17
+ `~/.cursor`, `~/.grok`, or another native Skill root.
18
+
19
+ ## Discover, then invoke
20
+
21
+ 1. Run `maia help --json`. Use only `commands[].name` as the family allowlist.
22
+ The default index has no usage array.
23
+ 2. Run `maia help <family> --json` for that family's usage rows and
24
+ `availability` (`implemented` or `source_implemented_candidate`).
25
+ 3. Prefer `--json` on every node-facing command.
26
+ 4. Put secrets, graph JSON, and prompt bodies on stdin. Do not pass them as
27
+ argv.
28
+ 5. On failure, read stderr JSON. Recover a mutation with
29
+ `maia receipt show <command-id>` when a command id exists. If the
30
+ command id was lost, use `maia --json receipt list` as bounded
31
+ no-payload discovery, then show the known id.
32
+
33
+ ## Implemented foundation
34
+
35
+ These are classified-help `implemented` commands. That help availability is
36
+ not the AGENTS release-gated Implemented label and is not product
37
+ enablement. Use them as source-callable current evidence.
38
+
39
+ - `maia --json status`
40
+ - `maia --json project add <repository>`
41
+ - `maia --json project list`
42
+ - `maia --json project show <project-id>`
43
+ - `maia --json workspace list --project <project-id>`
44
+ - `maia --json workspace show <workspace-id>`
45
+ - `maia --json workspace repo add <workspace-id> <repository> --expected-revision <revision>`
46
+ - `maia --json receipt list`
47
+ - `maia --json receipt show <command-id>`
48
+ - `maia --json runtime probe codex`
49
+ - `maia --json session create <workspace-id> --runtime codex`
50
+ - `maia --json session list --project <project-id>`
51
+ - `maia --json session show <session-id>`
52
+ - `maia --json session events <session-id>`
53
+
54
+ `runtime probe codex` is a compatibility handshake. It does not log in, start a
55
+ model turn, or authorize a harness.
56
+
57
+ ## Source candidates (do not treat as product)
58
+
59
+ Mention these only when the caller already accepted a release-disabled
60
+ candidate. They are not implemented product behavior.
61
+
62
+ - `maia --json context show` — Client principal only; no mailbox.
63
+ - `maia --json runtime list` — detection catalog; nothing is selected or
64
+ authorized.
65
+ - `maia --json session start <session-id> --expected-revision <revision>` —
66
+ blocked activation candidate. Do not start Codex from this Skill.
67
+
68
+ ## Do not run
69
+
70
+ Do not run Skill install/sync, Agent, Room, Routine, extension, integration, or
71
+ any `runtime probe` other than `codex`. Those verbs are planned. Absence from
72
+ the index `commands[]` and from the matching family `usage[]` is a deny.
73
+
74
+ Do not infer Run, Session, or node identity from cwd, Git, or environment.
75
+ Do not launch a harness process.
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: maia-orchestration
3
+ description: >
4
+ Coordinate source-candidate, release-disabled local-v1 Maia Runs through the
5
+ public CLI: create, list, show, task list and show, inbox check and ack,
6
+ questions, and dispatch show or settle-terminal. Use when an external agent
7
+ is the explicit Run coordinator. Do not treat these commands as
8
+ release-enabled, worker assignment, or Orca equivalence.
9
+ ---
10
+
11
+ # Maia orchestration
12
+
13
+ Every command in this Skill is a **source-implemented candidate,
14
+ release-disabled**. Confirm the usage exists on `maia help run --json` and is
15
+ tagged `source_implemented_candidate` before running it. Do not start a
16
+ worker, waiter, harness, or model turn.
17
+
18
+ ## Identity
19
+
20
+ Supply explicit ids. Do not infer a Run from the terminal, cwd, Git, or
21
+ environment. Do not use `--scope current`, `--run`, `--from`, or `--preamble`.
22
+
23
+ After `run create`, keep `run.id`, `run.revision`, `dispatch.id`,
24
+ `dispatch.revision`, both mailbox ids and revisions, and `receipt.commandId`
25
+ from the compact CLI projection. Recover a Task objective with
26
+ `run task show`. Recover Dispatch identity with `run dispatch show`.
27
+
28
+ ## Candidate commands
29
+
30
+ Label every invocation as release-disabled when you describe it.
31
+
32
+ - `maia --json run create <workspace-id> <terminal-id> --graph-stdin`
33
+ - `maia --json run list --workspace <workspace-id>`
34
+ - `maia --json run show <run-id>`
35
+ - `maia --json run task list <run-id>`
36
+ - `maia --json run task show <run-id> <task-id>`
37
+ - `maia --json run inbox check <run-id> --owner <run|dispatch> --owner-id <id> --coordinator-epoch 1`
38
+ - `maia --json run inbox ack <run-id> --owner <run|dispatch> --owner-id <id> --delivery-id <id> --expected-mailbox-revision <revision> --coordinator-epoch 1`
39
+ - `maia --json run question open <run-id> <dispatch-id> --subject <text> --body-stdin --expected-run-revision <revision> --expected-dispatch-revision <revision> --coordinator-epoch 1`
40
+ - `maia --json run question reply <run-id> <dispatch-id> <question-id> --answer-stdin --expected-run-revision <revision> --expected-dispatch-revision <revision> --expected-question-revision <revision> --coordinator-epoch 1`
41
+ - `maia --json run question cancel <run-id> <dispatch-id> <question-id> --expected-run-revision <revision> --expected-dispatch-revision <revision> --expected-question-revision <revision> --coordinator-epoch 1`
42
+ - `maia --json run dispatch show <run-id>`
43
+ - `maia --json run dispatch settle-terminal <run-id> <dispatch-id> --expected-run-revision <revision> --expected-dispatch-revision <revision> --coordinator-epoch 1`
44
+
45
+ Put the Task graph, Question body, and reply answer on stdin.
46
+
47
+ ## Do not run
48
+
49
+ Do not wait, watch, or poll an inbox. Do not assign a worker. Do not settle a
50
+ caller-selected outcome. `settle-terminal` only records the Terminal's exact
51
+ unavailable failure. Do not teach Skill install/sync or extra runtime probes.
52
+
53
+ A compact CLI projection is not a protocol change. The SDK remains lossless.
54
+ No Orca command is equivalent.
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@maiaos/cli",
3
+ "version": "0.1.0-canary.44938d4.manual.1",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "types": "./dist/index.d.ts",
7
+ "bin": {
8
+ "maia": "./dist/bin/maia.mjs"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "!dist/bin/*.meta.json",
20
+ "!dist/**/*.d.ts.map",
21
+ "!dist/**/*.js.map",
22
+ "!dist/**/*.mjs.map",
23
+ "!dist/bin/maia.d.ts",
24
+ "!dist/bin/maia.d.ts.map",
25
+ "guidance",
26
+ "README.md"
27
+ ],
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "engines": {
32
+ "node": "24.19.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "24.13.3",
36
+ "@vllnt/typescript": "1.0.0",
37
+ "eslint": "9.39.5",
38
+ "typescript": "5.9.3"
39
+ },
40
+ "dependencies": {
41
+ "@maiaos/sdk": "0.1.0-canary.44938d4.manual.1",
42
+ "effect": "4.0.0-beta.106"
43
+ },
44
+ "scripts": {
45
+ "build": "node -e \"require('node:fs').rmSync('dist',{force:true,recursive:true})\" && tsc --project tsconfig.build.json && node scripts/build-executable.mjs",
46
+ "lint": "eslint src scripts --max-warnings 0",
47
+ "test": "node -e \"require('node:fs').rmSync('.test-dist',{force:true,recursive:true})\" && tsc --project tsconfig.test.json && node --test --test-concurrency=2 --enable-source-maps .test-dist/command-line/cli.test.js .test-dist/command-line/help.test.js .test-dist/command-line/stdin.test.js .test-dist/command-receipt/command.test.js .test-dist/command-receipt/compact-list.test.js .test-dist/context/commands.test.js .test-dist/execution/client.test.js .test-dist/execution/commands.test.js .test-dist/guidance/pack-contents.test.js .test-dist/integration-authorization/client.test.js .test-dist/integration-authorization/commands.test.js .test-dist/orchestration/compact-aggregate.test.js .test-dist/orchestration/compact-run-list.test.js .test-dist/orchestration/commands.test.js .test-dist/project-workspace/client.test.js .test-dist/project-workspace/commands.test.js .test-dist/runtime/command.test.js .test-dist/session/client.test.js .test-dist/session/commands.test.js .test-dist/status/command.test.js .test-dist/terminal/client.test.js .test-dist/terminal/compact-list.test.js .test-dist/terminal/commands.test.js .test-dist/turn/client.test.js .test-dist/turn/commands.test.js .test-dist/turn/prompt.test.js",
48
+ "typecheck": "tsc --project tsconfig.json --noEmit && tsc --project scripts/tsconfig.json --noEmit"
49
+ }
50
+ }