@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.
- package/README.md +382 -0
- package/dist/bin/maia.NOTICES.txt +31 -0
- package/dist/bin/maia.cdx.json +138 -0
- package/dist/bin/maia.mjs +115 -0
- package/dist/command-line/arguments.d.ts +21 -0
- package/dist/command-line/arguments.js +99 -0
- package/dist/command-line/context.d.ts +112 -0
- package/dist/command-line/context.js +2 -0
- package/dist/command-line/help.d.ts +36 -0
- package/dist/command-line/help.js +267 -0
- package/dist/command-line/output.d.ts +2111 -0
- package/dist/command-line/output.js +643 -0
- package/dist/command-line/stdin.d.ts +7 -0
- package/dist/command-line/stdin.js +34 -0
- package/dist/command-receipt/command.d.ts +3 -0
- package/dist/command-receipt/command.js +63 -0
- package/dist/command-receipt/compact-list.d.ts +18 -0
- package/dist/command-receipt/compact-list.js +18 -0
- package/dist/context/client.d.ts +4 -0
- package/dist/context/client.js +19 -0
- package/dist/context/commands.d.ts +3 -0
- package/dist/context/commands.js +13 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +202 -0
- package/dist/integration-authorization/client.d.ts +16 -0
- package/dist/integration-authorization/client.js +30 -0
- package/dist/integration-authorization/commands.d.ts +3 -0
- package/dist/integration-authorization/commands.js +92 -0
- package/dist/local-node/client.d.ts +31 -0
- package/dist/local-node/client.js +99 -0
- package/dist/orchestration/client.d.ts +59 -0
- package/dist/orchestration/client.js +66 -0
- package/dist/orchestration/commands.d.ts +3 -0
- package/dist/orchestration/commands.js +336 -0
- package/dist/orchestration/compact-aggregate.d.ts +123 -0
- package/dist/orchestration/compact-aggregate.js +110 -0
- package/dist/orchestration/compact-run-list.d.ts +19 -0
- package/dist/orchestration/compact-run-list.js +16 -0
- package/dist/project-workspace/client.d.ts +43 -0
- package/dist/project-workspace/client.js +54 -0
- package/dist/project-workspace/commands.d.ts +5 -0
- package/dist/project-workspace/commands.js +239 -0
- package/dist/runtime/client.d.ts +6 -0
- package/dist/runtime/client.js +10 -0
- package/dist/runtime/command.d.ts +3 -0
- package/dist/runtime/command.js +20 -0
- package/dist/session/client.d.ts +32 -0
- package/dist/session/client.js +30 -0
- package/dist/session/commands.d.ts +3 -0
- package/dist/session/commands.js +160 -0
- package/dist/status/client.d.ts +5 -0
- package/dist/status/client.js +15 -0
- package/dist/status/command.d.ts +3 -0
- package/dist/status/command.js +17 -0
- package/dist/status/compact.d.ts +31 -0
- package/dist/status/compact.js +46 -0
- package/dist/terminal/arguments.d.ts +12 -0
- package/dist/terminal/arguments.js +79 -0
- package/dist/terminal/client.d.ts +45 -0
- package/dist/terminal/client.js +48 -0
- package/dist/terminal/commands.d.ts +3 -0
- package/dist/terminal/commands.js +151 -0
- package/dist/terminal/compact-list.d.ts +148 -0
- package/dist/terminal/compact-list.js +152 -0
- package/dist/terminal/control-commands.d.ts +7 -0
- package/dist/terminal/control-commands.js +211 -0
- package/dist/turn/client.d.ts +17 -0
- package/dist/turn/client.js +23 -0
- package/dist/turn/commands.d.ts +3 -0
- package/dist/turn/commands.js +126 -0
- package/dist/turn/prompt.d.ts +2 -0
- package/dist/turn/prompt.js +9 -0
- package/guidance/maia-cli/SKILL.md +75 -0
- package/guidance/maia-orchestration/SKILL.md +54 -0
- package/package.json +50 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export const projectDispatchShowDispatch = (dispatch) => ({
|
|
2
|
+
attemptId: dispatch.attemptId,
|
|
3
|
+
...(dispatch.state === "failed" ? { failure: dispatch.failure } : {}),
|
|
4
|
+
id: dispatch.id,
|
|
5
|
+
revision: dispatch.revision,
|
|
6
|
+
runId: dispatch.runId,
|
|
7
|
+
state: dispatch.state,
|
|
8
|
+
taskId: dispatch.taskId,
|
|
9
|
+
terminalId: dispatch.terminalId,
|
|
10
|
+
});
|
|
11
|
+
const projectMailbox = (mailbox) => ({
|
|
12
|
+
id: mailbox.id,
|
|
13
|
+
owner: { id: mailbox.owner.id, kind: mailbox.owner.kind },
|
|
14
|
+
revision: mailbox.revision,
|
|
15
|
+
});
|
|
16
|
+
const projectQuestion = (question) => ({
|
|
17
|
+
...(question.state === "answered" ? { answer: question.answer } : {}),
|
|
18
|
+
body: question.body,
|
|
19
|
+
id: question.id,
|
|
20
|
+
revision: question.revision,
|
|
21
|
+
state: question.state,
|
|
22
|
+
subject: question.subject,
|
|
23
|
+
taskId: question.taskId,
|
|
24
|
+
});
|
|
25
|
+
export const projectOrchestrationAggregate = (aggregate) => ({
|
|
26
|
+
attempt: {
|
|
27
|
+
id: aggregate.attempt.id,
|
|
28
|
+
revision: aggregate.attempt.revision,
|
|
29
|
+
state: aggregate.attempt.state,
|
|
30
|
+
taskId: aggregate.attempt.taskId,
|
|
31
|
+
},
|
|
32
|
+
dispatch: projectDispatchShowDispatch(aggregate.dispatch),
|
|
33
|
+
mailboxes: [...aggregate.mailboxes]
|
|
34
|
+
.map(projectMailbox)
|
|
35
|
+
.sort((left, right) => left.owner.kind.localeCompare(right.owner.kind)),
|
|
36
|
+
...(aggregate.question === undefined
|
|
37
|
+
? {}
|
|
38
|
+
: { question: projectQuestion(aggregate.question) }),
|
|
39
|
+
run: {
|
|
40
|
+
dispatchTaskId: aggregate.run.dispatchTaskId,
|
|
41
|
+
id: aggregate.run.id,
|
|
42
|
+
revision: aggregate.run.revision,
|
|
43
|
+
rootTaskId: aggregate.run.rootTaskId,
|
|
44
|
+
state: aggregate.run.state,
|
|
45
|
+
terminalId: aggregate.run.terminalId,
|
|
46
|
+
workspaceId: aggregate.run.workspaceId,
|
|
47
|
+
},
|
|
48
|
+
taskCount: aggregate.tasks.length,
|
|
49
|
+
});
|
|
50
|
+
export const projectOrchestrationDelivery = (delivery) => ({
|
|
51
|
+
deliveryId: delivery.id,
|
|
52
|
+
mailboxId: delivery.mailboxId,
|
|
53
|
+
...("questionId" in delivery.message
|
|
54
|
+
? { questionId: delivery.message.questionId }
|
|
55
|
+
: {}),
|
|
56
|
+
sequence: delivery.sequence,
|
|
57
|
+
subject: delivery.message.subject,
|
|
58
|
+
type: delivery.message.type,
|
|
59
|
+
});
|
|
60
|
+
export const projectOrchestrationReceipt = (receipt) => ({
|
|
61
|
+
aggregateRevision: receipt.aggregateRevision,
|
|
62
|
+
commandId: receipt.commandId,
|
|
63
|
+
receiptId: receipt.receiptId,
|
|
64
|
+
state: receipt.state,
|
|
65
|
+
target: receipt.target,
|
|
66
|
+
});
|
|
67
|
+
export const projectRunShowResult = (value) => ({
|
|
68
|
+
aggregate: projectOrchestrationAggregate(value.aggregate),
|
|
69
|
+
command: "run.show",
|
|
70
|
+
});
|
|
71
|
+
export const projectRunCreateResult = (value) => ({
|
|
72
|
+
aggregate: projectOrchestrationAggregate(value.aggregate),
|
|
73
|
+
command: "run.create",
|
|
74
|
+
delivery: value.delivery,
|
|
75
|
+
initialDelivery: projectOrchestrationDelivery(value.initialDelivery),
|
|
76
|
+
receipt: projectOrchestrationReceipt(value.receipt),
|
|
77
|
+
});
|
|
78
|
+
export const projectQuestionOpenResult = (value) => ({
|
|
79
|
+
aggregate: projectOrchestrationAggregate(value.aggregate),
|
|
80
|
+
command: "run.question.open",
|
|
81
|
+
delivery: projectOrchestrationDelivery(value.delivery),
|
|
82
|
+
receipt: projectOrchestrationReceipt(value.receipt),
|
|
83
|
+
});
|
|
84
|
+
export const projectQuestionReplyResult = (value) => ({
|
|
85
|
+
aggregate: projectOrchestrationAggregate(value.aggregate),
|
|
86
|
+
command: "run.question.reply",
|
|
87
|
+
delivery: projectOrchestrationDelivery(value.delivery),
|
|
88
|
+
receipt: projectOrchestrationReceipt(value.receipt),
|
|
89
|
+
});
|
|
90
|
+
export const projectQuestionCancelResult = (value) => ({
|
|
91
|
+
aggregate: projectOrchestrationAggregate(value.aggregate),
|
|
92
|
+
command: "run.question.cancel",
|
|
93
|
+
receipt: projectOrchestrationReceipt(value.receipt),
|
|
94
|
+
});
|
|
95
|
+
export const projectDispatchSettleResult = (value) => ({
|
|
96
|
+
aggregate: projectOrchestrationAggregate(value.aggregate),
|
|
97
|
+
command: "run.dispatch.settle-terminal",
|
|
98
|
+
delivery: projectOrchestrationDelivery(value.delivery),
|
|
99
|
+
receipt: projectOrchestrationReceipt(value.receipt),
|
|
100
|
+
});
|
|
101
|
+
export const projectInboxAckResult = (value) => ({
|
|
102
|
+
command: "run.inbox.ack",
|
|
103
|
+
delivery: projectOrchestrationDelivery(value.delivery),
|
|
104
|
+
mailboxId: value.mailbox.id,
|
|
105
|
+
mailboxRevision: value.mailbox.revision,
|
|
106
|
+
owner: { id: value.mailbox.owner.id, kind: value.mailbox.owner.kind },
|
|
107
|
+
receipt: projectOrchestrationReceipt(value.receipt),
|
|
108
|
+
runId: value.mailbox.runId,
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=compact-aggregate.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { OrchestrationRun, OrchestrationRunListResult } from "@maiaos/sdk";
|
|
2
|
+
export type CliRunListItem = {
|
|
3
|
+
readonly dispatchTaskId: OrchestrationRun["dispatchTaskId"];
|
|
4
|
+
readonly id: OrchestrationRun["id"];
|
|
5
|
+
readonly revision: OrchestrationRun["revision"];
|
|
6
|
+
readonly rootTaskId: OrchestrationRun["rootTaskId"];
|
|
7
|
+
readonly state: OrchestrationRun["state"];
|
|
8
|
+
readonly terminalId: OrchestrationRun["terminalId"];
|
|
9
|
+
};
|
|
10
|
+
export type CliRunListResult = {
|
|
11
|
+
readonly command: "run.list";
|
|
12
|
+
readonly count: number;
|
|
13
|
+
readonly items: readonly CliRunListItem[];
|
|
14
|
+
readonly nextCursor?: OrchestrationRunListResult["nextCursor"];
|
|
15
|
+
readonly workspaceId: OrchestrationRun["workspaceId"];
|
|
16
|
+
};
|
|
17
|
+
export declare const projectRunListItem: (run: OrchestrationRun) => CliRunListItem;
|
|
18
|
+
export declare const projectRunListResult: (value: OrchestrationRunListResult, workspaceId: OrchestrationRun["workspaceId"]) => CliRunListResult;
|
|
19
|
+
//# sourceMappingURL=compact-run-list.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const projectRunListItem = (run) => ({
|
|
2
|
+
dispatchTaskId: run.dispatchTaskId,
|
|
3
|
+
id: run.id,
|
|
4
|
+
revision: run.revision,
|
|
5
|
+
rootTaskId: run.rootTaskId,
|
|
6
|
+
state: run.state,
|
|
7
|
+
terminalId: run.terminalId,
|
|
8
|
+
});
|
|
9
|
+
export const projectRunListResult = (value, workspaceId) => ({
|
|
10
|
+
command: "run.list",
|
|
11
|
+
count: value.items.length,
|
|
12
|
+
items: value.items.map(projectRunListItem),
|
|
13
|
+
...(value.nextCursor === undefined ? {} : { nextCursor: value.nextCursor }),
|
|
14
|
+
workspaceId: value.items[0]?.workspaceId ?? workspaceId,
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=compact-run-list.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ExecutionCatalogGetResult, ProjectListResult, ProjectRegisterResult, ProjectShowResult, ReceiptGetResult, ReceiptListParameters, ReceiptListResult, WorkspaceExecutionConfigureParameters, WorkspaceExecutionConfigureResult, WorkspaceExecutionShowResult, WorkspaceListResult, WorkspaceRepositoryAttachResult, WorkspaceShowResult } from "@maiaos/sdk";
|
|
2
|
+
import { type CliNodeResult } from "../local-node/client.js";
|
|
3
|
+
export type { CliMutationRecovery, CliNodeResult, } from "../local-node/client.js";
|
|
4
|
+
export type RegisterProjectInput = {
|
|
5
|
+
readonly commandId?: string;
|
|
6
|
+
readonly name?: string;
|
|
7
|
+
readonly path: string;
|
|
8
|
+
};
|
|
9
|
+
export type AttachRepositoryInput = RegisterProjectInput & {
|
|
10
|
+
readonly expectedRevision: string;
|
|
11
|
+
readonly workspaceId: string;
|
|
12
|
+
};
|
|
13
|
+
export type ConfigureWorkspaceExecutionInput = (Omit<Extract<WorkspaceExecutionConfigureParameters, {
|
|
14
|
+
operation: "clear";
|
|
15
|
+
}>, "commandId"> & {
|
|
16
|
+
readonly commandId?: string;
|
|
17
|
+
}) | (Omit<Extract<WorkspaceExecutionConfigureParameters, {
|
|
18
|
+
operation: "set";
|
|
19
|
+
}>, "commandId"> & {
|
|
20
|
+
readonly commandId?: string;
|
|
21
|
+
});
|
|
22
|
+
export declare const registerProject: (input: RegisterProjectInput) => Promise<CliNodeResult<ProjectRegisterResult>>;
|
|
23
|
+
export declare const projectWorkspaceClientInternals: {
|
|
24
|
+
readonly outcomeCanBeAmbiguous: (error: unknown) => boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare const listProjects: (input: {
|
|
27
|
+
readonly afterCursor: string;
|
|
28
|
+
readonly limit: number;
|
|
29
|
+
}) => Promise<CliNodeResult<ProjectListResult>>;
|
|
30
|
+
export declare const showProject: (projectId: string) => Promise<CliNodeResult<ProjectShowResult>>;
|
|
31
|
+
export declare const listWorkspaces: (input: {
|
|
32
|
+
readonly afterCursor: string;
|
|
33
|
+
readonly limit: number;
|
|
34
|
+
readonly projectId: string;
|
|
35
|
+
}) => Promise<CliNodeResult<WorkspaceListResult>>;
|
|
36
|
+
export declare const showWorkspace: (workspaceId: string) => Promise<CliNodeResult<WorkspaceShowResult>>;
|
|
37
|
+
export declare const readExecutionCatalog: () => Promise<CliNodeResult<ExecutionCatalogGetResult>>;
|
|
38
|
+
export declare const showWorkspaceExecution: (workspaceId: string) => Promise<CliNodeResult<WorkspaceExecutionShowResult>>;
|
|
39
|
+
export declare const configureWorkspaceExecution: (input: ConfigureWorkspaceExecutionInput) => Promise<CliNodeResult<WorkspaceExecutionConfigureResult>>;
|
|
40
|
+
export declare const attachWorkspaceRepository: (input: AttachRepositoryInput) => Promise<CliNodeResult<WorkspaceRepositoryAttachResult>>;
|
|
41
|
+
export declare const getReceipt: (commandId: string) => Promise<CliNodeResult<ReceiptGetResult>>;
|
|
42
|
+
export declare const listReceipts: (input: ReceiptListParameters) => Promise<CliNodeResult<ReceiptListResult>>;
|
|
43
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { basename, resolve } from "node:path";
|
|
2
|
+
import { projectListParametersSchema, projectRegisterParametersSchema, projectShowParametersSchema, receiptGetParametersSchema, receiptListParametersSchema, workspaceExecutionConfigureParametersSchema, workspaceExecutionShowParametersSchema, workspaceListParametersSchema, workspaceRepositoryAttachParametersSchema, workspaceShowParametersSchema, } from "@maiaos/sdk";
|
|
3
|
+
import { newCliIdentifier, outcomeCanBeAmbiguous, runNodeClientOperation, runValidatedNodeOperation, } from "../local-node/client.js";
|
|
4
|
+
export const registerProject = (input) => {
|
|
5
|
+
const rootPath = resolve(input.path);
|
|
6
|
+
const commandId = input.commandId ?? newCliIdentifier("command");
|
|
7
|
+
return runValidatedNodeOperation({
|
|
8
|
+
commandId,
|
|
9
|
+
expectedRevision: "0",
|
|
10
|
+
name: input.name ?? basename(rootPath),
|
|
11
|
+
rootPath,
|
|
12
|
+
}, projectRegisterParametersSchema, (client, parameters, options) => client.registerProject(parameters, options), { commandId });
|
|
13
|
+
};
|
|
14
|
+
export const projectWorkspaceClientInternals = {
|
|
15
|
+
outcomeCanBeAmbiguous,
|
|
16
|
+
};
|
|
17
|
+
export const listProjects = (input) => {
|
|
18
|
+
return runValidatedNodeOperation(input, projectListParametersSchema, (client, parameters, options) => client.listProjects(parameters, options));
|
|
19
|
+
};
|
|
20
|
+
export const showProject = (projectId) => {
|
|
21
|
+
return runValidatedNodeOperation({ projectId }, projectShowParametersSchema, (client, parameters, options) => client.showProject(parameters, options));
|
|
22
|
+
};
|
|
23
|
+
export const listWorkspaces = (input) => {
|
|
24
|
+
return runValidatedNodeOperation(input, workspaceListParametersSchema, (client, parameters, options) => client.listWorkspaces(parameters, options));
|
|
25
|
+
};
|
|
26
|
+
export const showWorkspace = (workspaceId) => {
|
|
27
|
+
return runValidatedNodeOperation({ workspaceId }, workspaceShowParametersSchema, (client, parameters, options) => client.showWorkspace(parameters, options));
|
|
28
|
+
};
|
|
29
|
+
export const readExecutionCatalog = () => runNodeClientOperation((client, options) => client.readExecutionCatalog({}, options));
|
|
30
|
+
export const showWorkspaceExecution = (workspaceId) => {
|
|
31
|
+
return runValidatedNodeOperation({ workspaceId }, workspaceExecutionShowParametersSchema, (client, parameters, options) => client.showWorkspaceExecution(parameters, options));
|
|
32
|
+
};
|
|
33
|
+
export const configureWorkspaceExecution = (input) => {
|
|
34
|
+
const commandId = input.commandId ?? newCliIdentifier("command");
|
|
35
|
+
return runValidatedNodeOperation({ ...input, commandId }, workspaceExecutionConfigureParametersSchema, (client, parameters, options) => client.configureWorkspaceExecution(parameters, options), { commandId });
|
|
36
|
+
};
|
|
37
|
+
export const attachWorkspaceRepository = (input) => {
|
|
38
|
+
const rootPath = resolve(input.path);
|
|
39
|
+
const commandId = input.commandId ?? newCliIdentifier("command");
|
|
40
|
+
return runValidatedNodeOperation({
|
|
41
|
+
commandId,
|
|
42
|
+
expectedRevision: input.expectedRevision,
|
|
43
|
+
name: input.name ?? basename(rootPath),
|
|
44
|
+
rootPath,
|
|
45
|
+
workspaceId: input.workspaceId,
|
|
46
|
+
}, workspaceRepositoryAttachParametersSchema, (client, parameters, options) => client.attachWorkspaceRepository(parameters, options), { commandId });
|
|
47
|
+
};
|
|
48
|
+
export const getReceipt = (commandId) => {
|
|
49
|
+
return runValidatedNodeOperation({ commandId }, receiptGetParametersSchema, (client, parameters, options) => client.getReceipt(parameters, options));
|
|
50
|
+
};
|
|
51
|
+
export const listReceipts = (input) => {
|
|
52
|
+
return runValidatedNodeOperation(input, receiptListParametersSchema, (client, parameters, options) => client.listReceipts(parameters, options));
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CommandContext } from "../command-line/context.js";
|
|
2
|
+
export declare const runProjectCommand: (tokens: readonly string[], context: CommandContext) => Promise<number>;
|
|
3
|
+
export declare const runExecutionCommand: (tokens: readonly string[], context: CommandContext) => Promise<number>;
|
|
4
|
+
export declare const runWorkspaceCommand: (tokens: readonly string[], context: CommandContext) => Promise<number>;
|
|
5
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { CliArgumentError, parseOptions, readCursor, readExpectedRevision, readPageSize, requirePositionals, } from "../command-line/arguments.js";
|
|
2
|
+
import { writeNodeResult } from "../command-line/output.js";
|
|
3
|
+
const WORKSPACE_REPOSITORY_ADD_USAGE = "maia [--json] workspace repo add <workspace-id> <repository> --expected-revision <revision> [--name <name>] [--command-id <id>]";
|
|
4
|
+
const summarizeProjectRegistration = (result) => ({
|
|
5
|
+
checkoutId: result.checkout.id,
|
|
6
|
+
delivery: result.delivery,
|
|
7
|
+
projectId: result.project.id,
|
|
8
|
+
receipt: result.receipt,
|
|
9
|
+
repositoryId: result.repository.id,
|
|
10
|
+
workspaceId: result.workspace.id,
|
|
11
|
+
});
|
|
12
|
+
const summarizeRepositoryAttachment = (result) => ({
|
|
13
|
+
checkoutId: result.checkout.id,
|
|
14
|
+
delivery: result.delivery,
|
|
15
|
+
receipt: result.receipt,
|
|
16
|
+
repositoryId: result.repository.id,
|
|
17
|
+
workspaceId: result.workspace.id,
|
|
18
|
+
workspaceRevision: result.workspace.revision,
|
|
19
|
+
});
|
|
20
|
+
const runProjectAdd = async (tokens, context) => {
|
|
21
|
+
const parsed = parseOptions(tokens, new Set(["--command-id", "--name"]));
|
|
22
|
+
requirePositionals(parsed.positionals, 1, "maia project add <repository>");
|
|
23
|
+
const path = parsed.positionals[0];
|
|
24
|
+
if (path === undefined) {
|
|
25
|
+
throw new CliArgumentError("The repository path is missing.");
|
|
26
|
+
}
|
|
27
|
+
const commandId = parsed.options.get("--command-id");
|
|
28
|
+
const name = parsed.options.get("--name");
|
|
29
|
+
const result = await context.dependencies.registerProject({
|
|
30
|
+
path,
|
|
31
|
+
...(commandId === undefined ? {} : { commandId }),
|
|
32
|
+
...(name === undefined ? {} : { name }),
|
|
33
|
+
});
|
|
34
|
+
return writeNodeResult(result, context, (value) => ({
|
|
35
|
+
command: "project.add",
|
|
36
|
+
result: summarizeProjectRegistration(value),
|
|
37
|
+
}));
|
|
38
|
+
};
|
|
39
|
+
const runProjectList = async (tokens, context) => {
|
|
40
|
+
const parsed = parseOptions(tokens, new Set(["--after", "--limit"]));
|
|
41
|
+
requirePositionals(parsed.positionals, 0, "maia project list");
|
|
42
|
+
const result = await context.dependencies.listProjects({
|
|
43
|
+
afterCursor: readCursor(parsed.options.get("--after")),
|
|
44
|
+
limit: readPageSize(parsed.options.get("--limit")),
|
|
45
|
+
});
|
|
46
|
+
return writeNodeResult(result, context, (value) => ({
|
|
47
|
+
command: "project.list",
|
|
48
|
+
result: value,
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
const runProjectShow = async (tokens, context) => {
|
|
52
|
+
const parsed = parseOptions(tokens, new Set());
|
|
53
|
+
requirePositionals(parsed.positionals, 1, "maia project show <project-id>");
|
|
54
|
+
const projectId = parsed.positionals[0];
|
|
55
|
+
if (projectId === undefined) {
|
|
56
|
+
throw new CliArgumentError("The project identifier is missing.");
|
|
57
|
+
}
|
|
58
|
+
const result = await context.dependencies.showProject(projectId);
|
|
59
|
+
return writeNodeResult(result, context, (value) => ({
|
|
60
|
+
command: "project.show",
|
|
61
|
+
result: value,
|
|
62
|
+
}));
|
|
63
|
+
};
|
|
64
|
+
export const runProjectCommand = (tokens, context) => {
|
|
65
|
+
const [subcommand, ...rest] = tokens;
|
|
66
|
+
if (subcommand === "add")
|
|
67
|
+
return runProjectAdd(rest, context);
|
|
68
|
+
if (subcommand === "list")
|
|
69
|
+
return runProjectList(rest, context);
|
|
70
|
+
if (subcommand === "show")
|
|
71
|
+
return runProjectShow(rest, context);
|
|
72
|
+
throw new CliArgumentError("Usage: maia project <add|list|show>");
|
|
73
|
+
};
|
|
74
|
+
const runExecutionCatalog = async (tokens, context) => {
|
|
75
|
+
const parsed = parseOptions(tokens, new Set());
|
|
76
|
+
requirePositionals(parsed.positionals, 0, "maia execution catalog");
|
|
77
|
+
const operation = context.dependencies.readExecutionCatalog;
|
|
78
|
+
if (operation === undefined)
|
|
79
|
+
throw new Error("Missing execution client.");
|
|
80
|
+
const result = await operation();
|
|
81
|
+
return writeNodeResult(result, context, (value) => ({
|
|
82
|
+
command: "execution.catalog",
|
|
83
|
+
result: value,
|
|
84
|
+
}));
|
|
85
|
+
};
|
|
86
|
+
export const runExecutionCommand = (tokens, context) => {
|
|
87
|
+
const [subcommand, ...rest] = tokens;
|
|
88
|
+
if (subcommand === "catalog")
|
|
89
|
+
return runExecutionCatalog(rest, context);
|
|
90
|
+
throw new CliArgumentError("Usage: maia execution catalog");
|
|
91
|
+
};
|
|
92
|
+
const runWorkspaceList = async (tokens, context) => {
|
|
93
|
+
const parsed = parseOptions(tokens, new Set(["--after", "--limit", "--project"]));
|
|
94
|
+
requirePositionals(parsed.positionals, 0, "maia workspace list --project <project-id>");
|
|
95
|
+
const projectId = parsed.options.get("--project");
|
|
96
|
+
if (projectId === undefined) {
|
|
97
|
+
throw new CliArgumentError("Option '--project' is required.");
|
|
98
|
+
}
|
|
99
|
+
const result = await context.dependencies.listWorkspaces({
|
|
100
|
+
afterCursor: readCursor(parsed.options.get("--after")),
|
|
101
|
+
limit: readPageSize(parsed.options.get("--limit")),
|
|
102
|
+
projectId,
|
|
103
|
+
});
|
|
104
|
+
return writeNodeResult(result, context, (value) => ({
|
|
105
|
+
command: "workspace.list",
|
|
106
|
+
result: value,
|
|
107
|
+
}));
|
|
108
|
+
};
|
|
109
|
+
const runWorkspaceShow = async (tokens, context) => {
|
|
110
|
+
const parsed = parseOptions(tokens, new Set());
|
|
111
|
+
requirePositionals(parsed.positionals, 1, "maia workspace show <workspace-id>");
|
|
112
|
+
const workspaceId = parsed.positionals[0];
|
|
113
|
+
if (workspaceId === undefined) {
|
|
114
|
+
throw new CliArgumentError("The workspace identifier is missing.");
|
|
115
|
+
}
|
|
116
|
+
const result = await context.dependencies.showWorkspace(workspaceId);
|
|
117
|
+
return writeNodeResult(result, context, (value) => ({
|
|
118
|
+
command: "workspace.show",
|
|
119
|
+
result: value,
|
|
120
|
+
}));
|
|
121
|
+
};
|
|
122
|
+
const parseWorkspaceRepositoryAdd = (tokens) => {
|
|
123
|
+
const parsed = parseOptions(tokens, new Set(["--command-id", "--expected-revision", "--name"]));
|
|
124
|
+
requirePositionals(parsed.positionals, 2, WORKSPACE_REPOSITORY_ADD_USAGE);
|
|
125
|
+
const [workspaceId, path] = parsed.positionals;
|
|
126
|
+
const expectedRevision = readExpectedRevision(parsed.options.get("--expected-revision"));
|
|
127
|
+
if (workspaceId === undefined || path === undefined) {
|
|
128
|
+
throw new CliArgumentError("Workspace and repository are required.");
|
|
129
|
+
}
|
|
130
|
+
const commandId = parsed.options.get("--command-id");
|
|
131
|
+
const name = parsed.options.get("--name");
|
|
132
|
+
return {
|
|
133
|
+
expectedRevision,
|
|
134
|
+
path,
|
|
135
|
+
workspaceId,
|
|
136
|
+
...(commandId === undefined ? {} : { commandId }),
|
|
137
|
+
...(name === undefined ? {} : { name }),
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
const runWorkspaceRepositoryAdd = async (tokens, context) => {
|
|
141
|
+
const input = parseWorkspaceRepositoryAdd(tokens);
|
|
142
|
+
const result = await context.dependencies.attachWorkspaceRepository(input);
|
|
143
|
+
return writeNodeResult(result, context, (value) => ({
|
|
144
|
+
command: "workspace.repo.add",
|
|
145
|
+
result: summarizeRepositoryAttachment(value),
|
|
146
|
+
}));
|
|
147
|
+
};
|
|
148
|
+
const summarizeExecutionConfiguration = (result) => ({
|
|
149
|
+
...(result.binding === undefined ? {} : { binding: result.binding }),
|
|
150
|
+
delivery: result.delivery,
|
|
151
|
+
receipt: result.receipt,
|
|
152
|
+
resolution: result.resolution,
|
|
153
|
+
workspaceId: result.workspace.id,
|
|
154
|
+
workspaceRevision: result.workspace.revision,
|
|
155
|
+
});
|
|
156
|
+
const readExecutionSelection = (profileId, policyId) => {
|
|
157
|
+
if ((profileId === undefined) === (policyId === undefined)) {
|
|
158
|
+
throw new CliArgumentError("Exactly one of '--profile' or '--policy' is required.");
|
|
159
|
+
}
|
|
160
|
+
return profileId === undefined
|
|
161
|
+
? { id: policyId ?? "", kind: "policy" }
|
|
162
|
+
: { id: profileId, kind: "profile" };
|
|
163
|
+
};
|
|
164
|
+
const readExecutionMutation = (parsed, usage) => {
|
|
165
|
+
requirePositionals(parsed.positionals, 1, usage);
|
|
166
|
+
const workspaceId = parsed.positionals[0];
|
|
167
|
+
if (workspaceId === undefined) {
|
|
168
|
+
throw new CliArgumentError("The workspace identifier is missing.");
|
|
169
|
+
}
|
|
170
|
+
const commandId = parsed.options.get("--command-id");
|
|
171
|
+
return {
|
|
172
|
+
expectedRevision: readExpectedRevision(parsed.options.get("--expected-revision")),
|
|
173
|
+
workspaceId,
|
|
174
|
+
...(commandId === undefined ? {} : { commandId }),
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
const readExecutionInput = (operation, tokens) => {
|
|
178
|
+
const parsed = parseOptions(tokens, new Set([
|
|
179
|
+
"--command-id",
|
|
180
|
+
"--expected-revision",
|
|
181
|
+
...(operation === "set" ? ["--policy", "--profile"] : []),
|
|
182
|
+
]));
|
|
183
|
+
const common = readExecutionMutation(parsed, operation === "set"
|
|
184
|
+
? "maia workspace execution set <workspace-id> (--profile <profile-id> | --policy <policy-id>) --expected-revision <revision> [--command-id <id>]"
|
|
185
|
+
: "maia workspace execution clear <workspace-id> --expected-revision <revision> [--command-id <id>]");
|
|
186
|
+
return operation === "clear"
|
|
187
|
+
? { ...common, operation }
|
|
188
|
+
: {
|
|
189
|
+
...common,
|
|
190
|
+
operation,
|
|
191
|
+
selection: readExecutionSelection(parsed.options.get("--profile"), parsed.options.get("--policy")),
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
const runWorkspaceExecutionShow = async (tokens, context) => {
|
|
195
|
+
const parsed = parseOptions(tokens, new Set());
|
|
196
|
+
requirePositionals(parsed.positionals, 1, "maia workspace execution show <workspace-id>");
|
|
197
|
+
const workspaceId = parsed.positionals[0];
|
|
198
|
+
if (workspaceId === undefined) {
|
|
199
|
+
throw new CliArgumentError("The workspace identifier is missing.");
|
|
200
|
+
}
|
|
201
|
+
const operation = context.dependencies.showWorkspaceExecution;
|
|
202
|
+
if (operation === undefined)
|
|
203
|
+
throw new Error("Missing execution client.");
|
|
204
|
+
const result = await operation(workspaceId);
|
|
205
|
+
return writeNodeResult(result, context, (value) => ({
|
|
206
|
+
command: "workspace.execution.show",
|
|
207
|
+
result: value,
|
|
208
|
+
}));
|
|
209
|
+
};
|
|
210
|
+
const runWorkspaceExecutionCommand = (tokens, context) => {
|
|
211
|
+
const [subcommand, ...rest] = tokens;
|
|
212
|
+
if (subcommand === "show")
|
|
213
|
+
return runWorkspaceExecutionShow(rest, context);
|
|
214
|
+
if (subcommand === "set" || subcommand === "clear") {
|
|
215
|
+
const operation = context.dependencies.configureWorkspaceExecution;
|
|
216
|
+
if (operation === undefined)
|
|
217
|
+
throw new Error("Missing execution client.");
|
|
218
|
+
return operation(readExecutionInput(subcommand, rest)).then((result) => writeNodeResult(result, context, (value) => ({
|
|
219
|
+
command: "workspace.execution.configure",
|
|
220
|
+
result: summarizeExecutionConfiguration(value),
|
|
221
|
+
})));
|
|
222
|
+
}
|
|
223
|
+
throw new CliArgumentError("Usage: maia workspace execution <show|set|clear>");
|
|
224
|
+
};
|
|
225
|
+
export const runWorkspaceCommand = (tokens, context) => {
|
|
226
|
+
const [subcommand, ...rest] = tokens;
|
|
227
|
+
if (subcommand === "list")
|
|
228
|
+
return runWorkspaceList(rest, context);
|
|
229
|
+
if (subcommand === "execution") {
|
|
230
|
+
return runWorkspaceExecutionCommand(rest, context);
|
|
231
|
+
}
|
|
232
|
+
if (subcommand === "show")
|
|
233
|
+
return runWorkspaceShow(rest, context);
|
|
234
|
+
if (subcommand === "repo" && rest[0] === "add") {
|
|
235
|
+
return runWorkspaceRepositoryAdd(rest.slice(1), context);
|
|
236
|
+
}
|
|
237
|
+
throw new CliArgumentError("Usage: maia workspace <list|show|repo add>");
|
|
238
|
+
};
|
|
239
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { InstalledHarnessListResult, RuntimeProbeResult } from "@maiaos/sdk";
|
|
2
|
+
import { type CliNodeResult } from "../local-node/client.js";
|
|
3
|
+
export declare const listInstalledHarnesses: () => Promise<CliNodeResult<InstalledHarnessListResult>>;
|
|
4
|
+
export declare const probeRuntime: (runtime: "codex" | "pi-rpc") => Promise<CliNodeResult<RuntimeProbeResult>>;
|
|
5
|
+
export declare const probeCodexRuntime: () => Promise<CliNodeResult<RuntimeProbeResult>>;
|
|
6
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { installedHarnessListParametersSchema, runtimeProbeParametersSchema, } from "@maiaos/sdk";
|
|
2
|
+
import { runValidatedNodeOperation, } from "../local-node/client.js";
|
|
3
|
+
export const listInstalledHarnesses = () => {
|
|
4
|
+
return runValidatedNodeOperation({}, installedHarnessListParametersSchema, (client, parameters, options) => client.listInstalledHarnesses(parameters, options));
|
|
5
|
+
};
|
|
6
|
+
export const probeRuntime = (runtime) => {
|
|
7
|
+
return runValidatedNodeOperation({ runtime }, runtimeProbeParametersSchema, (client, parameters, options) => client.probeRuntime(parameters, options));
|
|
8
|
+
};
|
|
9
|
+
export const probeCodexRuntime = () => probeRuntime("codex");
|
|
10
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CliArgumentError, requireNoArguments, } from "../command-line/arguments.js";
|
|
2
|
+
import { writeRuntimeListResult, writeRuntimeProbeResult, } from "../command-line/output.js";
|
|
3
|
+
export const runRuntimeCommand = (tokens, context) => {
|
|
4
|
+
const [subcommand, ...rest] = tokens;
|
|
5
|
+
if (subcommand === "list") {
|
|
6
|
+
requireNoArguments(rest, "Runtime list");
|
|
7
|
+
return context.dependencies
|
|
8
|
+
.listInstalledHarnesses()
|
|
9
|
+
.then((result) => writeRuntimeListResult(result, context));
|
|
10
|
+
}
|
|
11
|
+
const [runtime, ...probeRest] = rest;
|
|
12
|
+
if (subcommand !== "probe" || (runtime !== "codex" && runtime !== "pi-rpc")) {
|
|
13
|
+
throw new CliArgumentError("Usage: maia runtime list | maia runtime probe <codex|pi-rpc>");
|
|
14
|
+
}
|
|
15
|
+
requireNoArguments(probeRest, "Runtime probe");
|
|
16
|
+
return context.dependencies
|
|
17
|
+
.probeRuntime(runtime)
|
|
18
|
+
.then((result) => writeRuntimeProbeResult(result, context));
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SessionCreateResult, SessionEventsListResult, SessionListResult, SessionShowResult, SessionStartResult } from "@maiaos/sdk";
|
|
2
|
+
import { type CliNodeResult } from "../local-node/client.js";
|
|
3
|
+
export type CreateSessionInput = {
|
|
4
|
+
readonly commandId?: string;
|
|
5
|
+
readonly profile: "pi-rpc";
|
|
6
|
+
readonly runtime: "pi";
|
|
7
|
+
readonly workspaceId: string;
|
|
8
|
+
} | {
|
|
9
|
+
readonly commandId?: string;
|
|
10
|
+
readonly profile?: "codex";
|
|
11
|
+
readonly runtime: "codex";
|
|
12
|
+
readonly workspaceId: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const createSession: (input: CreateSessionInput) => Promise<CliNodeResult<SessionCreateResult>>;
|
|
15
|
+
export declare const listSessions: (input: {
|
|
16
|
+
readonly afterCursor: string;
|
|
17
|
+
readonly limit: number;
|
|
18
|
+
readonly projectId: string;
|
|
19
|
+
}) => Promise<CliNodeResult<SessionListResult>>;
|
|
20
|
+
export declare const showSession: (sessionId: string) => Promise<CliNodeResult<SessionShowResult>>;
|
|
21
|
+
export declare const listSessionEvents: (input: {
|
|
22
|
+
readonly afterSessionCursor: string;
|
|
23
|
+
readonly limit: number;
|
|
24
|
+
readonly sessionId: string;
|
|
25
|
+
}) => Promise<CliNodeResult<SessionEventsListResult>>;
|
|
26
|
+
export type StartSessionInput = {
|
|
27
|
+
readonly commandId?: string;
|
|
28
|
+
readonly expectedRevision: string;
|
|
29
|
+
readonly sessionId: string;
|
|
30
|
+
};
|
|
31
|
+
export declare const startSession: (input: StartSessionInput) => Promise<CliNodeResult<SessionStartResult>>;
|
|
32
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { sessionCreateParametersSchema, sessionEventsListParametersSchema, sessionListParametersSchema, sessionShowParametersSchema, sessionStartParametersSchema, } from "@maiaos/sdk";
|
|
2
|
+
import { newCliIdentifier, runValidatedNodeOperation, } from "../local-node/client.js";
|
|
3
|
+
export const createSession = (input) => {
|
|
4
|
+
const commandId = input.commandId ?? newCliIdentifier("command");
|
|
5
|
+
return runValidatedNodeOperation({
|
|
6
|
+
commandId,
|
|
7
|
+
expectedRevision: "0",
|
|
8
|
+
...(input.profile === undefined ? {} : { profile: input.profile }),
|
|
9
|
+
runtime: input.runtime,
|
|
10
|
+
workspaceId: input.workspaceId,
|
|
11
|
+
}, sessionCreateParametersSchema, (client, parameters, options) => client.createSession(parameters, options), { commandId });
|
|
12
|
+
};
|
|
13
|
+
export const listSessions = (input) => {
|
|
14
|
+
return runValidatedNodeOperation(input, sessionListParametersSchema, (client, parameters, options) => client.listSessions(parameters, options));
|
|
15
|
+
};
|
|
16
|
+
export const showSession = (sessionId) => {
|
|
17
|
+
return runValidatedNodeOperation({ sessionId }, sessionShowParametersSchema, (client, parameters, options) => client.showSession(parameters, options));
|
|
18
|
+
};
|
|
19
|
+
export const listSessionEvents = (input) => {
|
|
20
|
+
return runValidatedNodeOperation(input, sessionEventsListParametersSchema, (client, parameters, options) => client.listSessionEvents(parameters, options));
|
|
21
|
+
};
|
|
22
|
+
export const startSession = (input) => {
|
|
23
|
+
const commandId = input.commandId ?? newCliIdentifier("command");
|
|
24
|
+
return runValidatedNodeOperation({
|
|
25
|
+
commandId,
|
|
26
|
+
expectedRevision: input.expectedRevision,
|
|
27
|
+
sessionId: input.sessionId,
|
|
28
|
+
}, sessionStartParametersSchema, (client, parameters, options) => client.startSession(parameters, options), { commandId });
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=client.js.map
|