@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,21 @@
1
+ export type ParsedArguments = {
2
+ readonly json: boolean;
3
+ readonly jsonFlagCount: number;
4
+ readonly tokens: readonly string[];
5
+ };
6
+ export type ParsedOptions = {
7
+ readonly flags: ReadonlySet<string>;
8
+ readonly options: ReadonlyMap<string, string>;
9
+ readonly positionals: readonly string[];
10
+ };
11
+ export declare class CliArgumentError extends Error {
12
+ }
13
+ export declare const argumentsAreBounded: (arguments_: readonly string[]) => boolean;
14
+ export declare const parseArguments: (arguments_: readonly string[]) => ParsedArguments;
15
+ export declare const parseOptions: (tokens: readonly string[], allowed: ReadonlySet<string>, allowedFlags?: ReadonlySet<string>) => ParsedOptions;
16
+ export declare const requirePositionals: (positionals: readonly string[], count: number, usage: string) => void;
17
+ export declare const requireNoArguments: (tokens: readonly string[], command: string) => void;
18
+ export declare const readPageSize: (value: string | undefined) => number;
19
+ export declare const readCursor: (value?: string) => string;
20
+ export declare const readExpectedRevision: (value: string | undefined) => string;
21
+ //# sourceMappingURL=arguments.d.ts.map
@@ -0,0 +1,99 @@
1
+ import { Buffer } from "node:buffer";
2
+ const MAX_ARGUMENT_BYTES = 16 * 1024;
3
+ const MAX_ARGUMENT_COUNT = 32;
4
+ const MAX_TOKEN_BYTES = 4096;
5
+ const MAX_SIGNED_INT_64 = 9223372036854775807n;
6
+ const DEFAULT_PAGE_SIZE = 2;
7
+ export class CliArgumentError extends Error {
8
+ }
9
+ export const argumentsAreBounded = (arguments_) => arguments_.length <= MAX_ARGUMENT_COUNT &&
10
+ arguments_.every((argument) => Buffer.byteLength(argument, "utf8") <= MAX_TOKEN_BYTES) &&
11
+ arguments_.reduce((total, argument) => total + Buffer.byteLength(argument, "utf8"), 0) <= MAX_ARGUMENT_BYTES;
12
+ export const parseArguments = (arguments_) => {
13
+ const jsonFlagCount = arguments_.filter((argument) => argument === "--json").length;
14
+ return {
15
+ json: jsonFlagCount > 0,
16
+ jsonFlagCount,
17
+ tokens: arguments_.filter((argument) => argument !== "--json"),
18
+ };
19
+ };
20
+ const parseOptionToken = (state, token) => {
21
+ if (state.pendingOption !== undefined) {
22
+ if (token.startsWith("--")) {
23
+ throw new CliArgumentError(`Option '${state.pendingOption}' requires a value.`);
24
+ }
25
+ state.options.set(state.pendingOption, token);
26
+ delete state.pendingOption;
27
+ return;
28
+ }
29
+ if (!token.startsWith("--")) {
30
+ state.positionals.push(token);
31
+ return;
32
+ }
33
+ if (state.allowedFlags.has(token)) {
34
+ if (state.flags.has(token)) {
35
+ throw new CliArgumentError(`Option '${token}' may be used only once.`);
36
+ }
37
+ state.flags.add(token);
38
+ return;
39
+ }
40
+ if (!state.allowed.has(token)) {
41
+ throw new CliArgumentError("The command contains an unknown option.");
42
+ }
43
+ if (state.options.has(token)) {
44
+ throw new CliArgumentError(`Option '${token}' may be used only once.`);
45
+ }
46
+ state.pendingOption = token;
47
+ };
48
+ export const parseOptions = (tokens, allowed, allowedFlags = new Set()) => {
49
+ const state = {
50
+ allowed,
51
+ allowedFlags,
52
+ flags: new Set(),
53
+ options: new Map(),
54
+ positionals: [],
55
+ };
56
+ tokens.forEach((token) => {
57
+ parseOptionToken(state, token);
58
+ });
59
+ if (state.pendingOption !== undefined) {
60
+ throw new CliArgumentError(`Option '${state.pendingOption}' requires a value.`);
61
+ }
62
+ return {
63
+ flags: state.flags,
64
+ options: state.options,
65
+ positionals: state.positionals,
66
+ };
67
+ };
68
+ export const requirePositionals = (positionals, count, usage) => {
69
+ if (positionals.length !== count) {
70
+ throw new CliArgumentError(`Usage: ${usage}`);
71
+ }
72
+ };
73
+ export const requireNoArguments = (tokens, command) => {
74
+ if (tokens.length > 0) {
75
+ throw new CliArgumentError(`${command} does not accept additional arguments.`);
76
+ }
77
+ };
78
+ export const readPageSize = (value) => {
79
+ if (value === undefined)
80
+ return DEFAULT_PAGE_SIZE;
81
+ if (!/^(?:[1-9]|[1-9]\d|100)$/u.test(value)) {
82
+ throw new CliArgumentError("Option '--limit' must be an integer from 1 to 100.");
83
+ }
84
+ return Number(value);
85
+ };
86
+ const readInt64 = (value, errorMessage) => {
87
+ if (!/^(?:0|[1-9]\d*)$/u.test(value) || BigInt(value) > MAX_SIGNED_INT_64) {
88
+ throw new CliArgumentError(errorMessage);
89
+ }
90
+ return value;
91
+ };
92
+ export const readCursor = (value = "0") => readInt64(value, "Option '--after' must be a non-negative signed 64-bit integer cursor.");
93
+ export const readExpectedRevision = (value) => {
94
+ if (value === undefined) {
95
+ throw new CliArgumentError("Option '--expected-revision' is required.");
96
+ }
97
+ return readInt64(value, "Option '--expected-revision' must be a non-negative signed 64-bit integer.");
98
+ };
99
+ //# sourceMappingURL=arguments.js.map
@@ -0,0 +1,112 @@
1
+ import type { ExecutionCatalogGetResult, InstalledHarnessListResult, IntegrationApplyCodexResult, IntegrationApplyPiRpcResult, IntegrationPlanCodexResult, IntegrationPlanPiRpcResult, IntegrationRemoveCodexResult, IntegrationRemovePiRpcResult, IntegrationStatusCodexResult, IntegrationStatusPiRpcResult, InvocationContextShowResult, LiveTerminalCloseResult, LiveTerminalControllerAcquireResult, LiveTerminalControllerReleaseResult, LiveTerminalControllerRequestResult, LiveTerminalControllerRequestShowResult, LiveTerminalResizeResult, LiveTerminalSignalResult, LiveTerminalWriteResult, LocalNodeStatusResult, MonitorBootstrapCreateResult, OrchestrationDispatchSettleTerminalResult, OrchestrationDispatchShowResult, OrchestrationInboxAckResult, OrchestrationInboxCheckResult, OrchestrationQuestionCancelResult, OrchestrationQuestionOpenResult, OrchestrationQuestionReplyResult, OrchestrationRunCreateResult, OrchestrationRunListResult, OrchestrationRunShowResult, OrchestrationTaskListResult, OrchestrationTaskShowResult, ProjectListResult, ProjectRegisterResult, ProjectShowResult, ReceiptGetResult, ReceiptListParameters, ReceiptListResult, RuntimeProbeResult, SessionCreateResult, SessionEventsListResult, SessionListResult, SessionShowResult, SessionStartResult, TerminalCreateResult, TerminalEventsListResult, TerminalListResult, TerminalReadResult, TerminalShowResult, TurnInterruptResult, TurnSendResult, TurnShowResult, WorkspaceExecutionConfigureResult, WorkspaceExecutionShowResult, WorkspaceListResult, WorkspaceRepositoryAttachResult, WorkspaceShowResult } from "@maiaos/sdk";
2
+ import type { acknowledgeRunDelivery, cancelRunQuestion, checkRunInbox, createRun, openRunQuestion, replyRunQuestion, settleRunDispatchTerminal } from "../orchestration/client.js";
3
+ import type { AttachRepositoryInput, CliNodeResult, ConfigureWorkspaceExecutionInput, RegisterProjectInput } from "../project-workspace/client.js";
4
+ import type { CreateSessionInput, StartSessionInput } from "../session/client.js";
5
+ import type { acquireTerminalController, closeTerminal, CreateTerminalInput, releaseTerminalController, requestTerminalController, resizeTerminal, showTerminalControllerRequest, signalTerminal, writeTerminalInput } from "../terminal/client.js";
6
+ import type { InterruptTurnInput, SendTurnInput } from "../turn/client.js";
7
+ import type { CliIo } from "./output.js";
8
+ export type CliDependencies = {
9
+ readonly acknowledgeRunDelivery: (input: Parameters<typeof acknowledgeRunDelivery>[0]) => Promise<CliNodeResult<OrchestrationInboxAckResult>>;
10
+ readonly acquireTerminalController: (input: Parameters<typeof acquireTerminalController>[0]) => Promise<CliNodeResult<LiveTerminalControllerAcquireResult>>;
11
+ readonly applyIntegration?: (integration: "codex" | "pi-rpc", input: {
12
+ readonly commandId?: string;
13
+ readonly planId: string;
14
+ }) => Promise<CliNodeResult<IntegrationApplyCodexResult | IntegrationApplyPiRpcResult>>;
15
+ readonly attachWorkspaceRepository: (input: AttachRepositoryInput) => Promise<CliNodeResult<WorkspaceRepositoryAttachResult>>;
16
+ readonly cancelRunQuestion: (input: Parameters<typeof cancelRunQuestion>[0]) => Promise<CliNodeResult<OrchestrationQuestionCancelResult>>;
17
+ readonly checkRunInbox: (input: Parameters<typeof checkRunInbox>[0]) => Promise<CliNodeResult<OrchestrationInboxCheckResult>>;
18
+ readonly closeTerminal: (input: Parameters<typeof closeTerminal>[0]) => Promise<CliNodeResult<LiveTerminalCloseResult>>;
19
+ readonly configureWorkspaceExecution?: (input: ConfigureWorkspaceExecutionInput) => Promise<CliNodeResult<WorkspaceExecutionConfigureResult>>;
20
+ readonly createMonitorBootstrap?: () => Promise<CliNodeResult<MonitorBootstrapCreateResult>>;
21
+ readonly createRun: (input: Parameters<typeof createRun>[0]) => Promise<CliNodeResult<OrchestrationRunCreateResult>>;
22
+ readonly createSession: (input: CreateSessionInput) => Promise<CliNodeResult<SessionCreateResult>>;
23
+ readonly createTerminal: (input: CreateTerminalInput) => Promise<CliNodeResult<TerminalCreateResult>>;
24
+ readonly getReceipt: (commandId: string) => Promise<CliNodeResult<ReceiptGetResult>>;
25
+ readonly interruptTurn: (input: InterruptTurnInput) => Promise<CliNodeResult<TurnInterruptResult>>;
26
+ readonly listInstalledHarnesses: () => Promise<CliNodeResult<InstalledHarnessListResult>>;
27
+ readonly listProjects: (input: {
28
+ readonly afterCursor: string;
29
+ readonly limit: number;
30
+ }) => Promise<CliNodeResult<ProjectListResult>>;
31
+ readonly listReceipts: (parameters: ReceiptListParameters) => Promise<CliNodeResult<ReceiptListResult>>;
32
+ readonly listRuns: (input: {
33
+ readonly afterCursor: string;
34
+ readonly limit: number;
35
+ readonly workspaceId: string;
36
+ }) => Promise<CliNodeResult<OrchestrationRunListResult>>;
37
+ readonly listSessionEvents: (input: {
38
+ readonly afterSessionCursor: string;
39
+ readonly limit: number;
40
+ readonly sessionId: string;
41
+ }) => Promise<CliNodeResult<SessionEventsListResult>>;
42
+ readonly listSessions: (input: {
43
+ readonly afterCursor: string;
44
+ readonly limit: number;
45
+ readonly projectId: string;
46
+ }) => Promise<CliNodeResult<SessionListResult>>;
47
+ readonly listTasks: (input: {
48
+ readonly afterCursor: string;
49
+ readonly limit: number;
50
+ readonly runId: string;
51
+ }) => Promise<CliNodeResult<OrchestrationTaskListResult>>;
52
+ readonly listTerminalEvents: (input: {
53
+ readonly afterTerminalCursor: string;
54
+ readonly limit: number;
55
+ readonly terminalId: string;
56
+ }) => Promise<CliNodeResult<TerminalEventsListResult>>;
57
+ readonly listTerminals: (input: {
58
+ readonly afterCursor: string;
59
+ readonly limit: number;
60
+ readonly workspaceId: string;
61
+ }) => Promise<CliNodeResult<TerminalListResult>>;
62
+ readonly listWorkspaces: (input: {
63
+ readonly afterCursor: string;
64
+ readonly limit: number;
65
+ readonly projectId: string;
66
+ }) => Promise<CliNodeResult<WorkspaceListResult>>;
67
+ readonly openRunQuestion: (input: Parameters<typeof openRunQuestion>[0]) => Promise<CliNodeResult<OrchestrationQuestionOpenResult>>;
68
+ readonly planIntegration?: (integration: "codex" | "pi-rpc") => Promise<CliNodeResult<IntegrationPlanCodexResult | IntegrationPlanPiRpcResult>>;
69
+ readonly probeRuntime: (runtime?: "codex" | "pi-rpc") => Promise<CliNodeResult<RuntimeProbeResult>>;
70
+ readonly readExecutionCatalog?: () => Promise<CliNodeResult<ExecutionCatalogGetResult>>;
71
+ readonly readStatus: () => Promise<LocalNodeStatusResult>;
72
+ readonly readTerminal: (input: {
73
+ readonly afterChunkCursor: string;
74
+ readonly limit: number;
75
+ readonly terminalId: string;
76
+ }) => Promise<CliNodeResult<TerminalReadResult>>;
77
+ readonly registerProject: (input: RegisterProjectInput) => Promise<CliNodeResult<ProjectRegisterResult>>;
78
+ readonly releaseTerminalController: (input: Parameters<typeof releaseTerminalController>[0]) => Promise<CliNodeResult<LiveTerminalControllerReleaseResult>>;
79
+ readonly removeIntegration?: (integration: "codex" | "pi-rpc", input: {
80
+ readonly commandId?: string;
81
+ }) => Promise<CliNodeResult<IntegrationRemoveCodexResult | IntegrationRemovePiRpcResult>>;
82
+ readonly replyRunQuestion: (input: Parameters<typeof replyRunQuestion>[0]) => Promise<CliNodeResult<OrchestrationQuestionReplyResult>>;
83
+ readonly requestTerminalController: (input: Parameters<typeof requestTerminalController>[0]) => Promise<CliNodeResult<LiveTerminalControllerRequestResult>>;
84
+ readonly resizeTerminal: (input: Parameters<typeof resizeTerminal>[0]) => Promise<CliNodeResult<LiveTerminalResizeResult>>;
85
+ readonly sendTurn: (input: SendTurnInput) => Promise<CliNodeResult<TurnSendResult>>;
86
+ readonly settleRunDispatchTerminal: (input: Parameters<typeof settleRunDispatchTerminal>[0]) => Promise<CliNodeResult<OrchestrationDispatchSettleTerminalResult>>;
87
+ readonly showCurrentContext: () => Promise<CliNodeResult<InvocationContextShowResult>>;
88
+ readonly showDispatch: (runId: string) => Promise<CliNodeResult<OrchestrationDispatchShowResult>>;
89
+ readonly showProject: (projectId: string) => Promise<CliNodeResult<ProjectShowResult>>;
90
+ readonly showRun: (runId: string) => Promise<CliNodeResult<OrchestrationRunShowResult>>;
91
+ readonly showSession: (sessionId: string) => Promise<CliNodeResult<SessionShowResult>>;
92
+ readonly showTask: (input: {
93
+ readonly runId: string;
94
+ readonly taskId: string;
95
+ }) => Promise<CliNodeResult<OrchestrationTaskShowResult>>;
96
+ readonly showTerminal: (terminalId: string) => Promise<CliNodeResult<TerminalShowResult>>;
97
+ readonly showTerminalControllerRequest: (input: Parameters<typeof showTerminalControllerRequest>[0]) => Promise<CliNodeResult<LiveTerminalControllerRequestShowResult>>;
98
+ readonly showTurn: (turnId: string) => Promise<CliNodeResult<TurnShowResult>>;
99
+ readonly showWorkspace: (workspaceId: string) => Promise<CliNodeResult<WorkspaceShowResult>>;
100
+ readonly showWorkspaceExecution?: (workspaceId: string) => Promise<CliNodeResult<WorkspaceExecutionShowResult>>;
101
+ readonly signalTerminal: (input: Parameters<typeof signalTerminal>[0]) => Promise<CliNodeResult<LiveTerminalSignalResult>>;
102
+ readonly startSession: (input: StartSessionInput) => Promise<CliNodeResult<SessionStartResult>>;
103
+ readonly statusIntegration?: (integration: "codex" | "pi-rpc") => Promise<CliNodeResult<IntegrationStatusCodexResult | IntegrationStatusPiRpcResult>>;
104
+ readonly writeTerminalInput: (input: Parameters<typeof writeTerminalInput>[0]) => Promise<CliNodeResult<LiveTerminalWriteResult>>;
105
+ };
106
+ export type CommandContext = {
107
+ readonly dependencies: CliDependencies;
108
+ readonly io: CliIo;
109
+ readonly json: boolean;
110
+ readonly version: string;
111
+ };
112
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1,36 @@
1
+ export declare const HELP_FAMILY_NAMES: readonly ["context", "execution", "help", "integration", "project", "receipt", "runtime", "run", "session", "status", "terminal", "version", "workspace", "monitor", "turn"];
2
+ export type CliHelpFamilyName = (typeof HELP_FAMILY_NAMES)[number];
3
+ export type CliHelpAvailability = "implemented" | "source_implemented_candidate";
4
+ export type CliHelpIndexCommand = {
5
+ readonly candidateUsageCount: number;
6
+ readonly implementedUsageCount: number;
7
+ readonly name: CliHelpFamilyName;
8
+ readonly summary: string;
9
+ };
10
+ export type CliHelpIndexResult = {
11
+ readonly command: "help";
12
+ readonly commands: readonly CliHelpIndexCommand[];
13
+ readonly name: "maia";
14
+ readonly registryDigest: string;
15
+ readonly version: string;
16
+ };
17
+ export type CliHelpFamilyUsage = {
18
+ readonly availability: CliHelpAvailability;
19
+ readonly usage: string;
20
+ };
21
+ export type CliHelpFamilyResult = {
22
+ readonly command: "help";
23
+ readonly family: CliHelpFamilyName;
24
+ readonly name: "maia";
25
+ readonly usage: readonly CliHelpFamilyUsage[];
26
+ readonly version: string;
27
+ };
28
+ export type CliHelpResult = CliHelpFamilyResult | CliHelpIndexResult;
29
+ export declare const HELP_USAGE: string[];
30
+ export declare const createHelpRegistryDigest: (usages?: readonly string[]) => string;
31
+ export declare const createHelpIndex: (version: string) => CliHelpIndexResult;
32
+ export declare const createHelpFamily: (version: string, family: CliHelpFamilyName) => CliHelpFamilyResult;
33
+ export declare const parseHelpFamily: (tokens: readonly string[]) => CliHelpFamilyName | undefined;
34
+ export declare const createHelpResult: (version: string, tokens: readonly string[]) => CliHelpResult;
35
+ export declare const helpUsageAvailability: (usage: string) => CliHelpAvailability | undefined;
36
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1,267 @@
1
+ import { createHash } from "node:crypto";
2
+ import { CliArgumentError } from "./arguments.js";
3
+ export const HELP_FAMILY_NAMES = [
4
+ "context",
5
+ "execution",
6
+ "help",
7
+ "integration",
8
+ "project",
9
+ "receipt",
10
+ "runtime",
11
+ "run",
12
+ "session",
13
+ "status",
14
+ "terminal",
15
+ "version",
16
+ "workspace",
17
+ "monitor",
18
+ "turn",
19
+ ];
20
+ const implemented = "implemented";
21
+ const candidate = "source_implemented_candidate";
22
+ const usagePrefix = "maia [--json] ";
23
+ const commandIdOption = " [--command-id <id>]";
24
+ const expectedRevisionOption = " --expected-revision <revision>";
25
+ const pageOptions = " [--limit <1..100>] [--after <cursor>]";
26
+ const coordinatorOption = " --coordinator-epoch 1";
27
+ const orchestrationRevisionOptions = " --expected-run-revision <revision> --expected-dispatch-revision <revision>";
28
+ const terminalGenerationOption = " --terminal-generation <1..65535>";
29
+ const terminalFencedUsage = (prefix) => `${prefix} --controller-id <id> --controller-epoch <epoch> --controller-revision <revision> --controller-expires-at <timestamp>${terminalGenerationOption}${expectedRevisionOption}${commandIdOption}`;
30
+ const HELP_USAGE_ROWS = [
31
+ [implemented, 9, "status"],
32
+ [implemented, 13, "monitor"],
33
+ [candidate, 0, "context show"],
34
+ [candidate, 1, "execution catalog"],
35
+ [
36
+ implemented,
37
+ 4,
38
+ `project add <repository> [--name <name>]${commandIdOption}`,
39
+ ],
40
+ [implemented, 4, `project list${pageOptions}`],
41
+ [implemented, 4, "project show <project-id>"],
42
+ [
43
+ implemented,
44
+ 5,
45
+ "receipt list [--limit <1..32>] [--after <cursor>] [--actor <actor-id>] [--method <method>] [--since <recorded-at>] [--until <recorded-at>]",
46
+ ],
47
+ [implemented, 5, "receipt show <command-id>"],
48
+ [
49
+ candidate,
50
+ 7,
51
+ `run create <workspace-id> <terminal-id> --graph-stdin${commandIdOption}`,
52
+ ],
53
+ [
54
+ candidate,
55
+ 7,
56
+ "run list --workspace <workspace-id> [--limit <1..100>] [--after <cursor>]",
57
+ ],
58
+ [candidate, 7, "run show <run-id>"],
59
+ [candidate, 7, "run task list <run-id> [--limit <1..32>] [--after <cursor>]"],
60
+ [candidate, 7, "run task show <run-id> <task-id>"],
61
+ [
62
+ candidate,
63
+ 7,
64
+ "run inbox check <run-id> --owner <run|dispatch> --owner-id <id> --coordinator-epoch 1 [--limit <1..16>]",
65
+ ],
66
+ [
67
+ candidate,
68
+ 7,
69
+ `run inbox ack <run-id> --owner <run|dispatch> --owner-id <id> --delivery-id <id> --expected-mailbox-revision <revision> --coordinator-epoch 1${commandIdOption}`,
70
+ ],
71
+ [
72
+ candidate,
73
+ 7,
74
+ `run question open <run-id> <dispatch-id> --subject <text> --body-stdin${orchestrationRevisionOptions}${coordinatorOption}${commandIdOption}`,
75
+ ],
76
+ [
77
+ candidate,
78
+ 7,
79
+ `run question reply <run-id> <dispatch-id> <question-id> --answer-stdin${orchestrationRevisionOptions} --expected-question-revision <revision>${coordinatorOption}${commandIdOption}`,
80
+ ],
81
+ [
82
+ candidate,
83
+ 7,
84
+ `run question cancel <run-id> <dispatch-id> <question-id>${orchestrationRevisionOptions} --expected-question-revision <revision>${coordinatorOption}${commandIdOption}`,
85
+ ],
86
+ [candidate, 7, "run dispatch show <run-id>"],
87
+ [
88
+ candidate,
89
+ 7,
90
+ `run dispatch settle-terminal <run-id> <dispatch-id>${orchestrationRevisionOptions}${coordinatorOption}${commandIdOption}`,
91
+ ],
92
+ [candidate, 3, "integration plan codex"],
93
+ [candidate, 3, `integration apply <plan-id>${commandIdOption}`],
94
+ [candidate, 3, "integration status codex"],
95
+ [candidate, 3, `integration remove codex${commandIdOption}`],
96
+ [candidate, 3, "integration plan pi-rpc"],
97
+ [
98
+ candidate,
99
+ 3,
100
+ `integration apply <plan-id> --integration pi-rpc${commandIdOption}`,
101
+ ],
102
+ [candidate, 3, "integration status pi-rpc"],
103
+ [candidate, 3, `integration remove pi-rpc${commandIdOption}`],
104
+ [candidate, 6, "runtime list"],
105
+ [implemented, 6, "runtime probe codex"],
106
+ [candidate, 6, "runtime probe pi-rpc"],
107
+ [
108
+ implemented,
109
+ 8,
110
+ `session create <workspace-id> --runtime <codex|pi> [--profile <codex|pi-rpc>]${commandIdOption}`,
111
+ ],
112
+ [
113
+ implemented,
114
+ 8,
115
+ "session events <session-id> [--limit <1..32>] [--after <session-cursor>]",
116
+ ],
117
+ [implemented, 8, `session list --project <project-id>${pageOptions}`],
118
+ [implemented, 8, "session show <session-id>"],
119
+ [
120
+ candidate,
121
+ 8,
122
+ `session start <session-id>${expectedRevisionOption}${commandIdOption}`,
123
+ ],
124
+ [
125
+ candidate,
126
+ 10,
127
+ `terminal create <workspace-id> [--interactive --columns <2..500> --rows <2..300>]${commandIdOption}`,
128
+ ],
129
+ [
130
+ candidate,
131
+ 10,
132
+ `terminal controller request <terminal-id>${terminalGenerationOption} --lease-ms <1000..30000>${commandIdOption}`,
133
+ ],
134
+ [
135
+ candidate,
136
+ 10,
137
+ `terminal controller request show <terminal-id> <controller-request-id>${terminalGenerationOption}`,
138
+ ],
139
+ [
140
+ candidate,
141
+ 10,
142
+ `terminal controller acquire <terminal-id> <controller-request-id>${terminalGenerationOption}${expectedRevisionOption}${commandIdOption}`,
143
+ ],
144
+ [
145
+ candidate,
146
+ 10,
147
+ terminalFencedUsage("terminal controller release <terminal-id>"),
148
+ ],
149
+ [
150
+ candidate,
151
+ 10,
152
+ "terminal events <terminal-id> [--limit <1..32>] [--after <terminal-cursor>]",
153
+ ],
154
+ [
155
+ candidate,
156
+ 10,
157
+ terminalFencedUsage("terminal input write <terminal-id> --input-stdin --input-id <id> --input-sequence <1..2147483647>"),
158
+ ],
159
+ [candidate, 10, `terminal list --workspace <workspace-id>${pageOptions}`],
160
+ [
161
+ candidate,
162
+ 10,
163
+ "terminal read <terminal-id> [--limit <1..8>] [--after <chunk-cursor>]",
164
+ ],
165
+ [
166
+ candidate,
167
+ 10,
168
+ terminalFencedUsage("terminal resize <terminal-id> --columns <2..500> --rows <2..300>"),
169
+ ],
170
+ [candidate, 10, "terminal show <terminal-id>"],
171
+ [
172
+ candidate,
173
+ 10,
174
+ terminalFencedUsage("terminal signal <terminal-id> --signal <hangup|interrupt|terminate>"),
175
+ ],
176
+ [candidate, 10, terminalFencedUsage("terminal close <terminal-id>")],
177
+ [
178
+ candidate,
179
+ 14,
180
+ `turn interrupt <turn-id>${expectedRevisionOption}${commandIdOption}`,
181
+ ],
182
+ [
183
+ candidate,
184
+ 14,
185
+ `turn send <session-id> --prompt-stdin${expectedRevisionOption}${commandIdOption}`,
186
+ ],
187
+ [candidate, 14, "turn show <turn-id> [--include-content]"],
188
+ [implemented, 12, `workspace list --project <project-id>${pageOptions}`],
189
+ [candidate, 12, "workspace execution show <workspace-id>"],
190
+ [
191
+ candidate,
192
+ 12,
193
+ `workspace execution set <workspace-id> (--profile <profile-id> | --policy <policy-id>)${expectedRevisionOption}${commandIdOption}`,
194
+ ],
195
+ [
196
+ candidate,
197
+ 12,
198
+ `workspace execution clear <workspace-id>${expectedRevisionOption}${commandIdOption}`,
199
+ ],
200
+ [implemented, 12, "workspace show <workspace-id>"],
201
+ [
202
+ implemented,
203
+ 12,
204
+ `workspace repo add <workspace-id> <repository>${expectedRevisionOption} [--name <name>]${commandIdOption}`,
205
+ ],
206
+ [implemented, 11, "version"],
207
+ ];
208
+ const fullUsage = (tail) => `${usagePrefix}${tail}`;
209
+ export const HELP_USAGE = HELP_USAGE_ROWS.map((row) => fullUsage(row[2]));
210
+ const HELP_SUMMARIES = [
211
+ "Show context.",
212
+ "Inspect execution.",
213
+ "Show command index.",
214
+ "Manage integrations.",
215
+ "Inspect projects.",
216
+ "Inspect results.",
217
+ "Inspect runtime.",
218
+ "Coordinate Runs.",
219
+ "Inspect sessions.",
220
+ "Inspect Maia node.",
221
+ "Use Terminal.",
222
+ "Show CLI version.",
223
+ "Inspect workspaces.",
224
+ "Open monitor.",
225
+ "Use turns.",
226
+ ];
227
+ export const createHelpRegistryDigest = (usages = HELP_USAGE) => `sha256:${createHash("sha256").update(usages.join("\n")).digest("hex")}`;
228
+ const countAvailability = (family, availability) => HELP_USAGE_ROWS.filter((row) => row[1] === family && row[0] === availability)
229
+ .length;
230
+ export const createHelpIndex = (version) => ({
231
+ command: "help",
232
+ commands: HELP_FAMILY_NAMES.map((name, index) => ({
233
+ candidateUsageCount: countAvailability(index, candidate),
234
+ implementedUsageCount: countAvailability(index, implemented),
235
+ name,
236
+ summary: HELP_SUMMARIES[index],
237
+ })),
238
+ name: "maia",
239
+ registryDigest: createHelpRegistryDigest(),
240
+ version,
241
+ });
242
+ export const createHelpFamily = (version, family) => ({
243
+ command: "help",
244
+ family,
245
+ name: "maia",
246
+ usage: HELP_USAGE_ROWS.filter((row) => HELP_FAMILY_NAMES[row[1]] === family).map((row) => ({ availability: row[0], usage: fullUsage(row[2]) })),
247
+ version,
248
+ });
249
+ export const parseHelpFamily = (tokens) => {
250
+ if (tokens.length > 1) {
251
+ throw new CliArgumentError("Help accepts at most one command family.");
252
+ }
253
+ const family = tokens[0];
254
+ if (tokens.length === 1 &&
255
+ (family === undefined || !HELP_FAMILY_NAMES.includes(family))) {
256
+ throw new CliArgumentError("Help does not include that command family.");
257
+ }
258
+ return family;
259
+ };
260
+ export const createHelpResult = (version, tokens) => {
261
+ const family = parseHelpFamily(tokens);
262
+ return family === undefined
263
+ ? createHelpIndex(version)
264
+ : createHelpFamily(version, family);
265
+ };
266
+ export const helpUsageAvailability = (usage) => HELP_USAGE_ROWS[HELP_USAGE.indexOf(usage)]?.[0];
267
+ //# sourceMappingURL=help.js.map