@maiaos/cli 0.1.0-canary.2
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 +287 -0
- package/dist/bin/maia.NOTICES.txt +59 -0
- package/dist/bin/maia.cdx.json +145 -0
- package/dist/bin/maia.mjs +2 -0
- package/dist/bootstrap/index.d.ts +3 -0
- package/dist/bootstrap/index.js +3 -0
- package/dist/bootstrap/process.d.ts +5 -0
- package/dist/bootstrap/process.js +45 -0
- package/dist/bootstrap/run.d.ts +25 -0
- package/dist/bootstrap/run.js +95 -0
- package/dist/bootstrap/stdio.d.ts +4 -0
- package/dist/bootstrap/stdio.js +9 -0
- package/dist/cli/cli.d.ts +17 -0
- package/dist/cli/cli.js +481 -0
- package/dist/cli/environment.d.ts +8 -0
- package/dist/cli/environment.js +12 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/services.d.ts +4 -0
- package/dist/cli/services.js +4 -0
- package/dist/command-line/context.d.ts +178 -0
- package/dist/command-line/context.js +2 -0
- package/dist/command-line/index.d.ts +7 -0
- package/dist/command-line/index.js +6 -0
- package/dist/command-line/input/arguments.d.ts +55 -0
- package/dist/command-line/input/arguments.js +220 -0
- package/dist/command-line/input/index.d.ts +4 -0
- package/dist/command-line/input/index.js +4 -0
- package/dist/command-line/input/prompt.d.ts +8 -0
- package/dist/command-line/input/prompt.js +44 -0
- package/dist/command-line/input/stdin-stream.d.ts +4 -0
- package/dist/command-line/input/stdin-stream.js +3 -0
- package/dist/command-line/input/stdin.d.ts +11 -0
- package/dist/command-line/input/stdin.js +23 -0
- package/dist/command-line/json-decoder.d.ts +3 -0
- package/dist/command-line/json-decoder.js +3 -0
- package/dist/command-line/json.d.ts +3 -0
- package/dist/command-line/json.js +4 -0
- package/dist/command-line/output.d.ts +57 -0
- package/dist/command-line/output.js +94 -0
- package/dist/command-line/rows.d.ts +10 -0
- package/dist/command-line/rows.js +32 -0
- package/dist/command-line/two-phase.d.ts +57 -0
- package/dist/command-line/two-phase.js +148 -0
- package/dist/command-receipt/command.d.ts +4 -0
- package/dist/command-receipt/command.js +59 -0
- package/dist/command-receipt/compact-list.d.ts +20 -0
- package/dist/command-receipt/compact-list.js +29 -0
- package/dist/command-receipt/index.d.ts +3 -0
- package/dist/command-receipt/index.js +3 -0
- package/dist/command-tree/commands.d.ts +17 -0
- package/dist/command-tree/commands.js +41 -0
- package/dist/command-tree/completion.d.ts +6 -0
- package/dist/command-tree/completion.js +36 -0
- package/dist/command-tree/grammar.d.ts +18 -0
- package/dist/command-tree/grammar.js +160 -0
- package/dist/command-tree/help.d.ts +62 -0
- package/dist/command-tree/help.js +219 -0
- package/dist/command-tree/index.d.ts +8 -0
- package/dist/command-tree/index.js +6 -0
- package/dist/command-tree/local.d.ts +3 -0
- package/dist/command-tree/local.js +126 -0
- package/dist/command-tree/placeholder.d.ts +3 -0
- package/dist/command-tree/placeholder.js +4 -0
- package/dist/command-tree/row.d.ts +29 -0
- package/dist/command-tree/row.js +2 -0
- package/dist/command-tree/suggest.d.ts +3 -0
- package/dist/command-tree/suggest.js +81 -0
- package/dist/command-tree/tree.d.ts +34 -0
- package/dist/command-tree/tree.js +124 -0
- package/dist/connection/client.d.ts +692 -0
- package/dist/connection/client.js +28 -0
- package/dist/connection/commands.d.ts +15 -0
- package/dist/connection/commands.js +118 -0
- package/dist/connection/index.d.ts +7 -0
- package/dist/connection/index.js +7 -0
- package/dist/connection/input.d.ts +50 -0
- package/dist/connection/input.js +90 -0
- package/dist/connection/login.d.ts +13 -0
- package/dist/connection/login.js +69 -0
- package/dist/connection/output/format.d.ts +32 -0
- package/dist/connection/output/format.js +94 -0
- package/dist/connection/output/index.d.ts +2 -0
- package/dist/connection/output/index.js +2 -0
- package/dist/connection/resolve.d.ts +60 -0
- package/dist/connection/resolve.js +30 -0
- package/dist/connection/signin.d.ts +4 -0
- package/dist/connection/signin.js +32 -0
- package/dist/connection/system.d.ts +4 -0
- package/dist/connection/system.js +190 -0
- package/dist/connection/tree/index.d.ts +2 -0
- package/dist/connection/tree/index.js +2 -0
- package/dist/connection/tree/tree.d.ts +3 -0
- package/dist/connection/tree/tree.js +209 -0
- package/dist/container/client.d.ts +142 -0
- package/dist/container/client.js +11 -0
- package/dist/container/commands.d.ts +7 -0
- package/dist/container/commands.js +100 -0
- package/dist/container/index.d.ts +3 -0
- package/dist/container/index.js +3 -0
- package/dist/container/output/format.d.ts +11 -0
- package/dist/container/output/format.js +28 -0
- package/dist/container/output/index.d.ts +2 -0
- package/dist/container/output/index.js +2 -0
- package/dist/context/client.d.ts +7 -0
- package/dist/context/client.js +21 -0
- package/dist/context/commands.d.ts +3 -0
- package/dist/context/commands.js +27 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/index.js +3 -0
- package/dist/development/cli.d.ts +3 -0
- package/dist/development/cli.js +44 -0
- package/dist/execution/client.d.ts +25 -0
- package/dist/execution/client.js +24 -0
- package/dist/execution/index.d.ts +3 -0
- package/dist/execution/index.js +3 -0
- package/dist/execution/relocation.d.ts +6 -0
- package/dist/execution/relocation.js +123 -0
- package/dist/execution/tree/index.d.ts +2 -0
- package/dist/execution/tree/index.js +2 -0
- package/dist/execution/tree/tree.d.ts +3 -0
- package/dist/execution/tree/tree.js +137 -0
- package/dist/hold/client.d.ts +137 -0
- package/dist/hold/client.js +12 -0
- package/dist/hold/commands.d.ts +5 -0
- package/dist/hold/commands.js +91 -0
- package/dist/hold/index.d.ts +3 -0
- package/dist/hold/index.js +3 -0
- package/dist/hold/output/format.d.ts +11 -0
- package/dist/hold/output/format.js +29 -0
- package/dist/hold/output/index.d.ts +2 -0
- package/dist/hold/output/index.js +2 -0
- package/dist/hold/tree/index.d.ts +2 -0
- package/dist/hold/tree/index.js +2 -0
- package/dist/hold/tree/tree.d.ts +3 -0
- package/dist/hold/tree/tree.js +96 -0
- package/dist/import/client.d.ts +14 -0
- package/dist/import/client.js +16 -0
- package/dist/import/commands.d.ts +5 -0
- package/dist/import/commands.js +76 -0
- package/dist/import/index.d.ts +3 -0
- package/dist/import/index.js +3 -0
- package/dist/import/input.d.ts +16 -0
- package/dist/import/input.js +92 -0
- package/dist/import/output.d.ts +6 -0
- package/dist/import/output.js +40 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/integration/client.d.ts +1284 -0
- package/dist/integration/client.js +24 -0
- package/dist/integration/commands.d.ts +10 -0
- package/dist/integration/commands.js +104 -0
- package/dist/integration/index.d.ts +3 -0
- package/dist/integration/index.js +3 -0
- package/dist/integration/output.d.ts +22 -0
- package/dist/integration/output.js +20 -0
- package/dist/local-node/call.d.ts +7 -0
- package/dist/local-node/call.js +13 -0
- package/dist/local-node/client.d.ts +67 -0
- package/dist/local-node/client.js +241 -0
- package/dist/local-node/index.d.ts +3 -0
- package/dist/local-node/index.js +3 -0
- package/dist/login/agent-provider.d.ts +20 -0
- package/dist/login/agent-provider.js +109 -0
- package/dist/login/commands.d.ts +4 -0
- package/dist/login/commands.js +93 -0
- package/dist/login/failure.d.ts +3 -0
- package/dist/login/failure.js +14 -0
- package/dist/login/gateway.d.ts +12 -0
- package/dist/login/gateway.js +71 -0
- package/dist/login/index.d.ts +3 -0
- package/dist/login/index.js +2 -0
- package/dist/login/menu.d.ts +4 -0
- package/dist/login/menu.js +105 -0
- package/dist/login/output/format.d.ts +16 -0
- package/dist/login/output/format.js +31 -0
- package/dist/login/output/index.d.ts +2 -0
- package/dist/login/output/index.js +2 -0
- package/dist/login/vendor-account.d.ts +95 -0
- package/dist/login/vendor-account.js +75 -0
- package/dist/login/vendor-input.d.ts +14 -0
- package/dist/login/vendor-input.js +36 -0
- package/dist/mcp/calls.d.ts +7 -0
- package/dist/mcp/calls.js +202 -0
- package/dist/mcp/commands.d.ts +9 -0
- package/dist/mcp/commands.js +21 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +2 -0
- package/dist/mcp/server.d.ts +11 -0
- package/dist/mcp/server.js +57 -0
- package/dist/orchestration/client.d.ts +78 -0
- package/dist/orchestration/client.js +89 -0
- package/dist/orchestration/commands.d.ts +14 -0
- package/dist/orchestration/commands.js +312 -0
- package/dist/orchestration/index.d.ts +3 -0
- package/dist/orchestration/index.js +3 -0
- package/dist/orchestration/output/compact-aggregate.d.ts +121 -0
- package/dist/orchestration/output/compact-aggregate.js +110 -0
- package/dist/orchestration/output/compact-run-list.d.ts +20 -0
- package/dist/orchestration/output/compact-run-list.js +16 -0
- package/dist/orchestration/output/human.d.ts +80 -0
- package/dist/orchestration/output/human.js +252 -0
- package/dist/orchestration/output/index.d.ts +4 -0
- package/dist/orchestration/output/index.js +4 -0
- package/dist/orchestration/tree/index.d.ts +2 -0
- package/dist/orchestration/tree/index.js +2 -0
- package/dist/orchestration/tree/tree.d.ts +3 -0
- package/dist/orchestration/tree/tree.js +142 -0
- package/dist/port-lease/client.d.ts +160 -0
- package/dist/port-lease/client.js +11 -0
- package/dist/port-lease/commands.d.ts +6 -0
- package/dist/port-lease/commands.js +17 -0
- package/dist/port-lease/index.d.ts +3 -0
- package/dist/port-lease/index.js +3 -0
- package/dist/port-lease/input.d.ts +65 -0
- package/dist/port-lease/input.js +67 -0
- package/dist/port-lease/output/format.d.ts +11 -0
- package/dist/port-lease/output/format.js +24 -0
- package/dist/port-lease/output/index.d.ts +2 -0
- package/dist/port-lease/output/index.js +2 -0
- package/dist/presentation/client.d.ts +10 -0
- package/dist/presentation/client.js +9 -0
- package/dist/presentation/commands.d.ts +6 -0
- package/dist/presentation/commands.js +78 -0
- package/dist/presentation/index.d.ts +4 -0
- package/dist/presentation/index.js +3 -0
- package/dist/presentation/output/format.d.ts +11 -0
- package/dist/presentation/output/format.js +32 -0
- package/dist/presentation/output/index.d.ts +3 -0
- package/dist/presentation/output/index.js +2 -0
- package/dist/project-guard/client.d.ts +88 -0
- package/dist/project-guard/client.js +7 -0
- package/dist/project-guard/commands.d.ts +4 -0
- package/dist/project-guard/commands.js +39 -0
- package/dist/project-guard/index.d.ts +3 -0
- package/dist/project-guard/index.js +3 -0
- package/dist/project-guard/input.d.ts +18 -0
- package/dist/project-guard/input.js +47 -0
- package/dist/project-guard/output/format.d.ts +11 -0
- package/dist/project-guard/output/format.js +35 -0
- package/dist/project-guard/output/index.d.ts +2 -0
- package/dist/project-guard/output/index.js +2 -0
- package/dist/project-workspace/client.d.ts +86 -0
- package/dist/project-workspace/client.js +159 -0
- package/dist/project-workspace/commands.d.ts +30 -0
- package/dist/project-workspace/commands.js +700 -0
- package/dist/project-workspace/index.d.ts +5 -0
- package/dist/project-workspace/index.js +5 -0
- package/dist/project-workspace/metadata-client.d.ts +99 -0
- package/dist/project-workspace/metadata-client.js +8 -0
- package/dist/project-workspace/metadata-commands.d.ts +4 -0
- package/dist/project-workspace/metadata-commands.js +56 -0
- package/dist/project-workspace/output/human.d.ts +126 -0
- package/dist/project-workspace/output/human.js +103 -0
- package/dist/project-workspace/output/index.d.ts +3 -0
- package/dist/project-workspace/output/index.js +3 -0
- package/dist/project-workspace/output/metadata.d.ts +11 -0
- package/dist/project-workspace/output/metadata.js +17 -0
- package/dist/project-workspace/tree/index.d.ts +2 -0
- package/dist/project-workspace/tree/index.js +2 -0
- package/dist/project-workspace/tree/tree.d.ts +3 -0
- package/dist/project-workspace/tree/tree.js +197 -0
- package/dist/provider/client.d.ts +6 -0
- package/dist/provider/client.js +5 -0
- package/dist/provider/commands.d.ts +3 -0
- package/dist/provider/commands.js +38 -0
- package/dist/provider/index.d.ts +3 -0
- package/dist/provider/index.js +3 -0
- package/dist/reference/commands.d.ts +3 -0
- package/dist/reference/commands.js +39 -0
- package/dist/reference/index.d.ts +3 -0
- package/dist/reference/index.js +3 -0
- package/dist/reference/resolve.d.ts +29 -0
- package/dist/reference/resolve.js +294 -0
- package/dist/reference/tree/index.d.ts +2 -0
- package/dist/reference/tree/index.js +2 -0
- package/dist/reference/tree/tree.d.ts +3 -0
- package/dist/reference/tree/tree.js +17 -0
- package/dist/remote-node/client.d.ts +258 -0
- package/dist/remote-node/client.js +12 -0
- package/dist/remote-node/commands.d.ts +6 -0
- package/dist/remote-node/commands.js +264 -0
- package/dist/remote-node/connector.d.ts +59 -0
- package/dist/remote-node/connector.js +122 -0
- package/dist/remote-node/index.d.ts +4 -0
- package/dist/remote-node/index.js +4 -0
- package/dist/remote-node/reachability.d.ts +22 -0
- package/dist/remote-node/reachability.js +34 -0
- package/dist/remote-node/text.d.ts +9 -0
- package/dist/remote-node/text.js +64 -0
- package/dist/remote-node/tree/index.d.ts +2 -0
- package/dist/remote-node/tree/index.js +2 -0
- package/dist/remote-node/tree/tree.d.ts +3 -0
- package/dist/remote-node/tree/tree.js +51 -0
- package/dist/run-ledger/client.d.ts +358 -0
- package/dist/run-ledger/client.js +13 -0
- package/dist/run-ledger/commands.d.ts +8 -0
- package/dist/run-ledger/commands.js +19 -0
- package/dist/run-ledger/index.d.ts +3 -0
- package/dist/run-ledger/index.js +3 -0
- package/dist/run-ledger/input.d.ts +42 -0
- package/dist/run-ledger/input.js +107 -0
- package/dist/run-ledger/output/format.d.ts +11 -0
- package/dist/run-ledger/output/format.js +49 -0
- package/dist/run-ledger/output/index.d.ts +2 -0
- package/dist/run-ledger/output/index.js +2 -0
- package/dist/session/agent-permission.d.ts +63 -0
- package/dist/session/agent-permission.js +20 -0
- package/dist/session/approval/client.d.ts +117 -0
- package/dist/session/approval/client.js +7 -0
- package/dist/session/approval/commands.d.ts +7 -0
- package/dist/session/approval/commands.js +123 -0
- package/dist/session/approval/index.d.ts +3 -0
- package/dist/session/approval/index.js +3 -0
- package/dist/session/approval/output/format.d.ts +12 -0
- package/dist/session/approval/output/format.js +25 -0
- package/dist/session/approval/output/index.d.ts +2 -0
- package/dist/session/approval/output/index.js +2 -0
- package/dist/session/attach-client.d.ts +16 -0
- package/dist/session/attach-client.js +8 -0
- package/dist/session/attach-render.d.ts +16 -0
- package/dist/session/attach-render.js +154 -0
- package/dist/session/attach.d.ts +5 -0
- package/dist/session/attach.js +106 -0
- package/dist/session/client.d.ts +132 -0
- package/dist/session/client.js +128 -0
- package/dist/session/coding-client.d.ts +16 -0
- package/dist/session/coding-client.js +15 -0
- package/dist/session/coding-commands.d.ts +4 -0
- package/dist/session/coding-commands.js +50 -0
- package/dist/session/commands.d.ts +13 -0
- package/dist/session/commands.js +488 -0
- package/dist/session/create-tasks.d.ts +20 -0
- package/dist/session/create-tasks.js +110 -0
- package/dist/session/index.d.ts +9 -0
- package/dist/session/index.js +7 -0
- package/dist/session/interaction/client.d.ts +347 -0
- package/dist/session/interaction/client.js +15 -0
- package/dist/session/interaction/commands.d.ts +7 -0
- package/dist/session/interaction/commands.js +101 -0
- package/dist/session/interaction/index.d.ts +3 -0
- package/dist/session/interaction/index.js +3 -0
- package/dist/session/interaction/input.d.ts +15 -0
- package/dist/session/interaction/input.js +46 -0
- package/dist/session/interaction/output/format.d.ts +11 -0
- package/dist/session/interaction/output/format.js +3 -0
- package/dist/session/interaction/output/index.d.ts +2 -0
- package/dist/session/interaction/output/index.js +2 -0
- package/dist/session/output/diff.d.ts +3 -0
- package/dist/session/output/diff.js +30 -0
- package/dist/session/output/failure.d.ts +11 -0
- package/dist/session/output/failure.js +24 -0
- package/dist/session/output/human.d.ts +112 -0
- package/dist/session/output/human.js +71 -0
- package/dist/session/output/index.d.ts +6 -0
- package/dist/session/output/index.js +6 -0
- package/dist/session/output/observe.d.ts +4 -0
- package/dist/session/output/observe.js +46 -0
- package/dist/session/output/tasks.d.ts +19 -0
- package/dist/session/output/tasks.js +34 -0
- package/dist/session/rename.d.ts +3 -0
- package/dist/session/rename.js +37 -0
- package/dist/session/task-file.d.ts +5 -0
- package/dist/session/task-file.js +23 -0
- package/dist/session/tree/index.d.ts +2 -0
- package/dist/session/tree/index.js +2 -0
- package/dist/session/tree/tree.d.ts +3 -0
- package/dist/session/tree/tree.js +309 -0
- package/dist/session/turn/client.d.ts +25 -0
- package/dist/session/turn/client.js +40 -0
- package/dist/session/turn/commands.d.ts +6 -0
- package/dist/session/turn/commands.js +157 -0
- package/dist/session/turn/index.d.ts +4 -0
- package/dist/session/turn/index.js +3 -0
- package/dist/session/turn/output.d.ts +42 -0
- package/dist/session/turn/output.js +38 -0
- package/dist/status/client.d.ts +119 -0
- package/dist/status/client.js +5 -0
- package/dist/status/command.d.ts +4 -0
- package/dist/status/command.js +40 -0
- package/dist/status/doctor.d.ts +15 -0
- package/dist/status/doctor.js +111 -0
- package/dist/status/index.d.ts +5 -0
- package/dist/status/index.js +4 -0
- package/dist/status/output/compact.d.ts +31 -0
- package/dist/status/output/compact.js +46 -0
- package/dist/status/output/human.d.ts +7 -0
- package/dist/status/output/human.js +30 -0
- package/dist/status/output/index.d.ts +3 -0
- package/dist/status/output/index.js +3 -0
- package/dist/terminal/arguments.d.ts +13 -0
- package/dist/terminal/arguments.js +79 -0
- package/dist/terminal/client.d.ts +79 -0
- package/dist/terminal/client.js +68 -0
- package/dist/terminal/commands.d.ts +7 -0
- package/dist/terminal/commands.js +131 -0
- package/dist/terminal/control-commands.d.ts +10 -0
- package/dist/terminal/control-commands.js +212 -0
- package/dist/terminal/index.d.ts +4 -0
- package/dist/terminal/index.js +4 -0
- package/dist/terminal/output/compact-list.d.ts +147 -0
- package/dist/terminal/output/compact-list.js +152 -0
- package/dist/terminal/output/human.d.ts +59 -0
- package/dist/terminal/output/human.js +55 -0
- package/dist/terminal/output/index.d.ts +3 -0
- package/dist/terminal/output/index.js +3 -0
- package/dist/terminal/tree/index.d.ts +2 -0
- package/dist/terminal/tree/index.js +2 -0
- package/dist/terminal/tree/tree.d.ts +3 -0
- package/dist/terminal/tree/tree.js +104 -0
- package/guidance/maia-cli/SKILL.md +58 -0
- package/guidance/maia-orchestration/SKILL.md +54 -0
- package/package.json +76 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { DEFAULT_ORCHESTRATION_TASK_LIST_PAGE_SIZE, orchestrationQuestionOpenParametersSchema, orchestrationQuestionReplyParametersSchema, orchestrationTaskGraphSchema, } from "@maiaos/sdk";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { CliArgumentError, decodeJsonText, parseOptions, readCursor, readExpectedRevision, readPageSize, requirePositionals, } from "../command-line/index.js";
|
|
4
|
+
import { writeDispatchSettleResult, writeDispatchShowResult, writeInboxAckResult, writeInboxCheckResult, writeQuestionCancelResult, writeQuestionOpenResult, writeQuestionReplyResult, writeRunCreateResult, writeRunListResult, writeRunShowResult, writeTaskListResult, writeTaskShowResult, } from "./output/index.js";
|
|
5
|
+
const requireOption = (parsed, name) => {
|
|
6
|
+
const value = parsed.options.get(name);
|
|
7
|
+
if (value === undefined) {
|
|
8
|
+
throw new CliArgumentError(`Option '${name}' is required.`);
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
12
|
+
const coordinatorEpoch = (parsed) => {
|
|
13
|
+
if (requireOption(parsed, "--coordinator-epoch") !== "1") {
|
|
14
|
+
throw new CliArgumentError("Option '--coordinator-epoch' must be exactly 1 for local v1.");
|
|
15
|
+
}
|
|
16
|
+
return 1;
|
|
17
|
+
};
|
|
18
|
+
const revision = (parsed, name) => readExpectedRevision(requireOption(parsed, name));
|
|
19
|
+
const mutationCommandId = (parsed) => {
|
|
20
|
+
const commandId = parsed.options.get("--command-id");
|
|
21
|
+
return commandId === undefined ? {} : { commandId };
|
|
22
|
+
};
|
|
23
|
+
const questionScope = (parsed, runId, dispatchId) => ({
|
|
24
|
+
coordinatorEpoch: coordinatorEpoch(parsed),
|
|
25
|
+
dispatchId,
|
|
26
|
+
expectedDispatchRevision: revision(parsed, "--expected-dispatch-revision"),
|
|
27
|
+
expectedRunRevision: revision(parsed, "--expected-run-revision"),
|
|
28
|
+
runId,
|
|
29
|
+
...mutationCommandId(parsed),
|
|
30
|
+
});
|
|
31
|
+
const parseRunCreateScope = (tokens) => {
|
|
32
|
+
const parsed = parseOptions(tokens, new Set(["--command-id", "--terminal", "--workspace"]), new Set(["--graph-stdin"]));
|
|
33
|
+
requirePositionals(parsed.positionals, 0);
|
|
34
|
+
if (!parsed.flags.has("--graph-stdin")) {
|
|
35
|
+
throw new CliArgumentError("Option '--graph-stdin' is required.");
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
parsed,
|
|
39
|
+
terminalId: requireOption(parsed, "--terminal"),
|
|
40
|
+
workspaceId: requireOption(parsed, "--workspace"),
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const readTaskGraph = (context) => {
|
|
44
|
+
const stdin = context.io.stdin;
|
|
45
|
+
if (stdin === undefined) {
|
|
46
|
+
throw new CliArgumentError("Standard input is unavailable.");
|
|
47
|
+
}
|
|
48
|
+
return stdin({
|
|
49
|
+
label: "orchestration graph",
|
|
50
|
+
maxBytes: 64 * 1024,
|
|
51
|
+
maxChunks: 1024,
|
|
52
|
+
}).pipe(Effect.flatMap((graphText) => decodeJsonText(graphText, () => new CliArgumentError("Standard input must be one valid JSON graph."))), Effect.flatMap((rawGraph) => {
|
|
53
|
+
const graph = orchestrationTaskGraphSchema.safeParse(rawGraph);
|
|
54
|
+
return graph.success
|
|
55
|
+
? Effect.succeed(graph.data)
|
|
56
|
+
: Effect.fail(new CliArgumentError("Standard input is not a valid Task graph."));
|
|
57
|
+
}));
|
|
58
|
+
};
|
|
59
|
+
export const runCreate = (tokens, context) => Effect.gen(function* () {
|
|
60
|
+
const { parsed, terminalId, workspaceId } = parseRunCreateScope(tokens);
|
|
61
|
+
const graph = yield* readTaskGraph(context);
|
|
62
|
+
const result = yield* context.dependencies.createRun({
|
|
63
|
+
graph,
|
|
64
|
+
terminalId,
|
|
65
|
+
workspaceId,
|
|
66
|
+
...mutationCommandId(parsed),
|
|
67
|
+
});
|
|
68
|
+
return writeRunCreateResult(result, context);
|
|
69
|
+
});
|
|
70
|
+
export const runShow = (tokens, context) => Effect.gen(function* () {
|
|
71
|
+
const parsed = parseOptions(tokens, new Set());
|
|
72
|
+
requirePositionals(parsed.positionals, 1);
|
|
73
|
+
const runId = parsed.positionals[0];
|
|
74
|
+
if (runId === undefined)
|
|
75
|
+
throw new CliArgumentError("The Run ID is missing.");
|
|
76
|
+
const result = yield* context.dependencies.showRun(runId);
|
|
77
|
+
return writeRunShowResult(result, context);
|
|
78
|
+
});
|
|
79
|
+
export const runList = (tokens, context) => Effect.gen(function* () {
|
|
80
|
+
const parsed = parseOptions(tokens, new Set(["--after", "--limit", "--workspace"]));
|
|
81
|
+
requirePositionals(parsed.positionals, 0);
|
|
82
|
+
const workspaceId = parsed.options.get("--workspace");
|
|
83
|
+
if (workspaceId === undefined) {
|
|
84
|
+
throw new CliArgumentError("Option '--workspace' is required.");
|
|
85
|
+
}
|
|
86
|
+
const result = yield* context.dependencies.listRuns({
|
|
87
|
+
afterCursor: readCursor(parsed.options.get("--after")),
|
|
88
|
+
limit: readPageSize(parsed.options.get("--limit")),
|
|
89
|
+
workspaceId,
|
|
90
|
+
});
|
|
91
|
+
return writeRunListResult(result, context, workspaceId);
|
|
92
|
+
});
|
|
93
|
+
const readTaskListPageSize = (value) => {
|
|
94
|
+
if (value === undefined)
|
|
95
|
+
return DEFAULT_ORCHESTRATION_TASK_LIST_PAGE_SIZE;
|
|
96
|
+
if (!/^(?:[1-9]|[12]\d|3[0-2])$/u.test(value)) {
|
|
97
|
+
throw new CliArgumentError("Option '--limit' must be an integer from 1 to 32.");
|
|
98
|
+
}
|
|
99
|
+
return Number(value);
|
|
100
|
+
};
|
|
101
|
+
export const runTaskList = (tokens, context) => Effect.gen(function* () {
|
|
102
|
+
const parsed = parseOptions(tokens, new Set(["--after", "--limit", "--run"]));
|
|
103
|
+
requirePositionals(parsed.positionals, 0);
|
|
104
|
+
const runId = requireOption(parsed, "--run");
|
|
105
|
+
const result = yield* context.dependencies.listTasks({
|
|
106
|
+
afterCursor: readCursor(parsed.options.get("--after")),
|
|
107
|
+
limit: readTaskListPageSize(parsed.options.get("--limit")),
|
|
108
|
+
runId,
|
|
109
|
+
});
|
|
110
|
+
return writeTaskListResult(result, context);
|
|
111
|
+
});
|
|
112
|
+
export const runTaskShow = (tokens, context) => Effect.gen(function* () {
|
|
113
|
+
const parsed = parseOptions(tokens, new Set(["--run"]));
|
|
114
|
+
requirePositionals(parsed.positionals, 1);
|
|
115
|
+
const runId = requireOption(parsed, "--run");
|
|
116
|
+
const taskId = parsed.positionals[0];
|
|
117
|
+
if (taskId === undefined) {
|
|
118
|
+
throw new CliArgumentError("The Task ID is missing.");
|
|
119
|
+
}
|
|
120
|
+
const result = yield* context.dependencies.showTask({ runId, taskId });
|
|
121
|
+
return writeTaskShowResult(result, context);
|
|
122
|
+
});
|
|
123
|
+
const inboxOwner = (parsed, runId) => {
|
|
124
|
+
const kind = requireOption(parsed, "--owner");
|
|
125
|
+
if (kind !== "run" && kind !== "dispatch") {
|
|
126
|
+
throw new CliArgumentError("Option '--owner' must be run or dispatch.");
|
|
127
|
+
}
|
|
128
|
+
const id = requireOption(parsed, "--owner-id");
|
|
129
|
+
if (kind === "run" && id !== runId) {
|
|
130
|
+
throw new CliArgumentError("A Run inbox owner ID must equal the Run ID.");
|
|
131
|
+
}
|
|
132
|
+
return { id, kind };
|
|
133
|
+
};
|
|
134
|
+
export const runInboxCheck = (tokens, context) => Effect.gen(function* () {
|
|
135
|
+
const parsed = parseOptions(tokens, new Set([
|
|
136
|
+
"--coordinator-epoch",
|
|
137
|
+
"--limit",
|
|
138
|
+
"--owner",
|
|
139
|
+
"--owner-id",
|
|
140
|
+
"--run",
|
|
141
|
+
]));
|
|
142
|
+
requirePositionals(parsed.positionals, 0);
|
|
143
|
+
const runId = requireOption(parsed, "--run");
|
|
144
|
+
const limitValue = parsed.options.get("--limit") ?? "8";
|
|
145
|
+
if (!/^(?:[1-9]|1[0-6])$/u.test(limitValue)) {
|
|
146
|
+
throw new CliArgumentError("Option '--limit' must be from 1 to 16.");
|
|
147
|
+
}
|
|
148
|
+
const result = yield* context.dependencies.checkRunInbox({
|
|
149
|
+
coordinatorEpoch: coordinatorEpoch(parsed),
|
|
150
|
+
limit: Number(limitValue),
|
|
151
|
+
owner: inboxOwner(parsed, runId),
|
|
152
|
+
runId,
|
|
153
|
+
});
|
|
154
|
+
return writeInboxCheckResult(result, context);
|
|
155
|
+
});
|
|
156
|
+
const inboxAckOptions = new Set([
|
|
157
|
+
"--command-id",
|
|
158
|
+
"--coordinator-epoch",
|
|
159
|
+
"--expected-mailbox-revision",
|
|
160
|
+
"--owner",
|
|
161
|
+
"--owner-id",
|
|
162
|
+
"--run",
|
|
163
|
+
]);
|
|
164
|
+
export const runInboxAck = (tokens, context) => Effect.gen(function* () {
|
|
165
|
+
const parsed = parseOptions(tokens, inboxAckOptions);
|
|
166
|
+
requirePositionals(parsed.positionals, 1);
|
|
167
|
+
const runId = requireOption(parsed, "--run");
|
|
168
|
+
const deliveryId = parsed.positionals[0];
|
|
169
|
+
if (deliveryId === undefined)
|
|
170
|
+
throw new CliArgumentError("The delivery ID is missing.");
|
|
171
|
+
const result = yield* context.dependencies.acknowledgeRunDelivery({
|
|
172
|
+
coordinatorEpoch: coordinatorEpoch(parsed),
|
|
173
|
+
deliveryId,
|
|
174
|
+
expectedMailboxRevision: revision(parsed, "--expected-mailbox-revision"),
|
|
175
|
+
owner: inboxOwner(parsed, runId),
|
|
176
|
+
runId,
|
|
177
|
+
...mutationCommandId(parsed),
|
|
178
|
+
});
|
|
179
|
+
return writeInboxAckResult(result, context);
|
|
180
|
+
});
|
|
181
|
+
const questionScopeOptions = [
|
|
182
|
+
"--command-id",
|
|
183
|
+
"--coordinator-epoch",
|
|
184
|
+
"--expected-dispatch-revision",
|
|
185
|
+
"--expected-run-revision",
|
|
186
|
+
"--run",
|
|
187
|
+
];
|
|
188
|
+
const runDispatchIdentifiers = (parsed) => {
|
|
189
|
+
requirePositionals(parsed.positionals, 0);
|
|
190
|
+
return {
|
|
191
|
+
dispatchId: requireOption(parsed, "--dispatch"),
|
|
192
|
+
runId: requireOption(parsed, "--run"),
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
const questionIdentifiers = (parsed) => {
|
|
196
|
+
requirePositionals(parsed.positionals, 1);
|
|
197
|
+
const questionId = parsed.positionals[0];
|
|
198
|
+
if (questionId === undefined)
|
|
199
|
+
throw new CliArgumentError("The Question ID is missing.");
|
|
200
|
+
return {
|
|
201
|
+
dispatchId: requireOption(parsed, "--dispatch"),
|
|
202
|
+
questionId,
|
|
203
|
+
runId: requireOption(parsed, "--run"),
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
const parseQuestionOpen = (tokens) => {
|
|
207
|
+
const parsed = parseOptions(tokens, new Set([...questionScopeOptions, "--dispatch", "--subject"]), new Set(["--body-stdin"]));
|
|
208
|
+
const identifiers = runDispatchIdentifiers(parsed);
|
|
209
|
+
if (!parsed.flags.has("--body-stdin")) {
|
|
210
|
+
throw new CliArgumentError("Option '--body-stdin' is required.");
|
|
211
|
+
}
|
|
212
|
+
const input = {
|
|
213
|
+
...questionScope(parsed, identifiers.runId, identifiers.dispatchId),
|
|
214
|
+
subject: requireOption(parsed, "--subject"),
|
|
215
|
+
};
|
|
216
|
+
if (!orchestrationQuestionOpenParametersSchema.safeParse({
|
|
217
|
+
...input,
|
|
218
|
+
body: "validated-after-metadata",
|
|
219
|
+
commandId: input.commandId ?? "command_metadata_validation",
|
|
220
|
+
}).success) {
|
|
221
|
+
throw new CliArgumentError("The Question-open metadata is invalid.");
|
|
222
|
+
}
|
|
223
|
+
return input;
|
|
224
|
+
};
|
|
225
|
+
export const runQuestionOpen = (tokens, context) => Effect.gen(function* () {
|
|
226
|
+
const input = parseQuestionOpen(tokens);
|
|
227
|
+
if (context.io.stdin === undefined) {
|
|
228
|
+
throw new CliArgumentError("Standard input is unavailable.");
|
|
229
|
+
}
|
|
230
|
+
const body = yield* context.io.stdin({
|
|
231
|
+
label: "Question body",
|
|
232
|
+
maxBytes: 4 * 1024,
|
|
233
|
+
maxChunks: 256,
|
|
234
|
+
});
|
|
235
|
+
const result = yield* context.dependencies.openRunQuestion({
|
|
236
|
+
...input,
|
|
237
|
+
body,
|
|
238
|
+
});
|
|
239
|
+
return writeQuestionOpenResult(result, context);
|
|
240
|
+
});
|
|
241
|
+
const parseQuestionReply = (tokens) => {
|
|
242
|
+
const parsed = parseOptions(tokens, new Set([
|
|
243
|
+
...questionScopeOptions,
|
|
244
|
+
"--dispatch",
|
|
245
|
+
"--expected-question-revision",
|
|
246
|
+
]), new Set(["--answer-stdin"]));
|
|
247
|
+
const identifiers = questionIdentifiers(parsed);
|
|
248
|
+
if (!parsed.flags.has("--answer-stdin")) {
|
|
249
|
+
throw new CliArgumentError("Option '--answer-stdin' is required.");
|
|
250
|
+
}
|
|
251
|
+
const input = {
|
|
252
|
+
...questionScope(parsed, identifiers.runId, identifiers.dispatchId),
|
|
253
|
+
expectedQuestionRevision: revision(parsed, "--expected-question-revision"),
|
|
254
|
+
questionId: identifiers.questionId,
|
|
255
|
+
};
|
|
256
|
+
if (!orchestrationQuestionReplyParametersSchema.safeParse({
|
|
257
|
+
...input,
|
|
258
|
+
answer: "validated-after-metadata",
|
|
259
|
+
commandId: input.commandId ?? "command_metadata_validation",
|
|
260
|
+
}).success) {
|
|
261
|
+
throw new CliArgumentError("The Question-reply metadata is invalid.");
|
|
262
|
+
}
|
|
263
|
+
return input;
|
|
264
|
+
};
|
|
265
|
+
export const runQuestionReply = (tokens, context) => Effect.gen(function* () {
|
|
266
|
+
const input = parseQuestionReply(tokens);
|
|
267
|
+
if (context.io.stdin === undefined) {
|
|
268
|
+
throw new CliArgumentError("Standard input is unavailable.");
|
|
269
|
+
}
|
|
270
|
+
const answer = yield* context.io.stdin({
|
|
271
|
+
label: "Question answer",
|
|
272
|
+
maxBytes: 4 * 1024,
|
|
273
|
+
maxChunks: 256,
|
|
274
|
+
});
|
|
275
|
+
const result = yield* context.dependencies.replyRunQuestion({
|
|
276
|
+
...input,
|
|
277
|
+
answer,
|
|
278
|
+
});
|
|
279
|
+
return writeQuestionReplyResult(result, context);
|
|
280
|
+
});
|
|
281
|
+
export const runQuestionCancel = (tokens, context) => Effect.gen(function* () {
|
|
282
|
+
const parsed = parseOptions(tokens, new Set([
|
|
283
|
+
...questionScopeOptions,
|
|
284
|
+
"--dispatch",
|
|
285
|
+
"--expected-question-revision",
|
|
286
|
+
]));
|
|
287
|
+
const { dispatchId, questionId, runId } = questionIdentifiers(parsed);
|
|
288
|
+
const result = yield* context.dependencies.cancelRunQuestion({
|
|
289
|
+
...questionScope(parsed, runId, dispatchId),
|
|
290
|
+
expectedQuestionRevision: revision(parsed, "--expected-question-revision"),
|
|
291
|
+
questionId,
|
|
292
|
+
});
|
|
293
|
+
return writeQuestionCancelResult(result, context);
|
|
294
|
+
});
|
|
295
|
+
export const runDispatchShow = (tokens, context) => Effect.gen(function* () {
|
|
296
|
+
const parsed = parseOptions(tokens, new Set(["--run"]));
|
|
297
|
+
requirePositionals(parsed.positionals, 0);
|
|
298
|
+
const runId = requireOption(parsed, "--run");
|
|
299
|
+
const result = yield* context.dependencies.showDispatch(runId);
|
|
300
|
+
return writeDispatchShowResult(result, context);
|
|
301
|
+
});
|
|
302
|
+
export const runDispatchSettleTerminal = (tokens, context) => Effect.gen(function* () {
|
|
303
|
+
const parsed = parseOptions(tokens, new Set(questionScopeOptions));
|
|
304
|
+
requirePositionals(parsed.positionals, 1);
|
|
305
|
+
const runId = requireOption(parsed, "--run");
|
|
306
|
+
const dispatchId = parsed.positionals[0];
|
|
307
|
+
if (dispatchId === undefined)
|
|
308
|
+
throw new CliArgumentError("The Dispatch ID is missing.");
|
|
309
|
+
const result = yield* context.dependencies.settleRunDispatchTerminal(questionScope(parsed, runId, dispatchId));
|
|
310
|
+
return writeDispatchSettleResult(result, context);
|
|
311
|
+
});
|
|
312
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { makeOrchestrationClient } from "./client.js";
|
|
2
|
+
export { runCreate, runDispatchSettleTerminal, runDispatchShow, runInboxAck, runInboxCheck, runList, runQuestionCancel, runQuestionOpen, runQuestionReply, runShow, runTaskList, runTaskShow, } from "./commands.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { makeOrchestrationClient } from "./client.js";
|
|
2
|
+
export { runCreate, runDispatchSettleTerminal, runDispatchShow, runInboxAck, runInboxCheck, runList, runQuestionCancel, runQuestionOpen, runQuestionReply, runShow, runTaskList, runTaskShow, } from "./commands.js";
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { OrchestrationAggregate, OrchestrationDelivery, OrchestrationDispatchSettleTerminalResult, OrchestrationDispatchShowResult, OrchestrationInboxAckResult, OrchestrationQuestion, OrchestrationQuestionCancelResult, OrchestrationQuestionOpenResult, OrchestrationQuestionReplyResult, OrchestrationRunCreateResult, OrchestrationRunShowResult } from "@maiaos/sdk";
|
|
2
|
+
type ProtocolDispatch = OrchestrationDispatchShowResult["dispatch"];
|
|
3
|
+
type ProtocolReceipt = OrchestrationRunCreateResult["receipt"];
|
|
4
|
+
export type CliDispatchShowDispatch = {
|
|
5
|
+
readonly attemptId: ProtocolDispatch["attemptId"];
|
|
6
|
+
readonly failure?: Extract<ProtocolDispatch, {
|
|
7
|
+
readonly state: "failed";
|
|
8
|
+
}>["failure"];
|
|
9
|
+
readonly id: ProtocolDispatch["id"];
|
|
10
|
+
readonly revision: ProtocolDispatch["revision"];
|
|
11
|
+
readonly runId: ProtocolDispatch["runId"];
|
|
12
|
+
readonly state: ProtocolDispatch["state"];
|
|
13
|
+
readonly taskId: ProtocolDispatch["taskId"];
|
|
14
|
+
readonly terminalId: ProtocolDispatch["terminalId"];
|
|
15
|
+
};
|
|
16
|
+
type CliCompactMailbox = {
|
|
17
|
+
readonly id: OrchestrationAggregate["mailboxes"][number]["id"];
|
|
18
|
+
readonly owner: OrchestrationAggregate["mailboxes"][number]["owner"];
|
|
19
|
+
readonly revision: OrchestrationAggregate["mailboxes"][number]["revision"];
|
|
20
|
+
};
|
|
21
|
+
export type CliCompactQuestion = {
|
|
22
|
+
readonly answer?: Extract<OrchestrationQuestion, {
|
|
23
|
+
readonly state: "answered";
|
|
24
|
+
}>["answer"];
|
|
25
|
+
readonly body: OrchestrationQuestion["body"];
|
|
26
|
+
readonly id: OrchestrationQuestion["id"];
|
|
27
|
+
readonly revision: OrchestrationQuestion["revision"];
|
|
28
|
+
readonly state: OrchestrationQuestion["state"];
|
|
29
|
+
readonly subject: OrchestrationQuestion["subject"];
|
|
30
|
+
readonly taskId: OrchestrationQuestion["taskId"];
|
|
31
|
+
};
|
|
32
|
+
type CliCompactAggregate = {
|
|
33
|
+
readonly attempt: {
|
|
34
|
+
readonly id: OrchestrationAggregate["attempt"]["id"];
|
|
35
|
+
readonly revision: OrchestrationAggregate["attempt"]["revision"];
|
|
36
|
+
readonly state: OrchestrationAggregate["attempt"]["state"];
|
|
37
|
+
readonly taskId: OrchestrationAggregate["attempt"]["taskId"];
|
|
38
|
+
};
|
|
39
|
+
readonly dispatch: CliDispatchShowDispatch;
|
|
40
|
+
readonly mailboxes: readonly CliCompactMailbox[];
|
|
41
|
+
readonly question?: CliCompactQuestion;
|
|
42
|
+
readonly run: {
|
|
43
|
+
readonly dispatchTaskId: OrchestrationAggregate["run"]["dispatchTaskId"];
|
|
44
|
+
readonly id: OrchestrationAggregate["run"]["id"];
|
|
45
|
+
readonly revision: OrchestrationAggregate["run"]["revision"];
|
|
46
|
+
readonly rootTaskId: OrchestrationAggregate["run"]["rootTaskId"];
|
|
47
|
+
readonly state: OrchestrationAggregate["run"]["state"];
|
|
48
|
+
readonly terminalId: OrchestrationAggregate["run"]["terminalId"];
|
|
49
|
+
readonly workspaceId: OrchestrationAggregate["run"]["workspaceId"];
|
|
50
|
+
};
|
|
51
|
+
readonly taskCount: number;
|
|
52
|
+
};
|
|
53
|
+
export type CliCompactDelivery = {
|
|
54
|
+
readonly deliveryId: OrchestrationDelivery["id"];
|
|
55
|
+
readonly mailboxId: OrchestrationDelivery["mailboxId"];
|
|
56
|
+
readonly questionId?: string;
|
|
57
|
+
readonly sequence: OrchestrationDelivery["sequence"];
|
|
58
|
+
readonly subject: OrchestrationDelivery["message"]["subject"];
|
|
59
|
+
readonly type: OrchestrationDelivery["message"]["type"];
|
|
60
|
+
};
|
|
61
|
+
type CliCompactReceipt = {
|
|
62
|
+
readonly aggregateRevision: ProtocolReceipt["aggregateRevision"];
|
|
63
|
+
readonly commandId: ProtocolReceipt["commandId"];
|
|
64
|
+
readonly receiptId: ProtocolReceipt["receiptId"];
|
|
65
|
+
readonly state: ProtocolReceipt["state"];
|
|
66
|
+
readonly target: ProtocolReceipt["target"];
|
|
67
|
+
};
|
|
68
|
+
export type CliRunShowResult = {
|
|
69
|
+
readonly aggregate: CliCompactAggregate;
|
|
70
|
+
readonly command: "run.show";
|
|
71
|
+
};
|
|
72
|
+
export type CliRunCreateResult = {
|
|
73
|
+
readonly aggregate: CliCompactAggregate;
|
|
74
|
+
readonly command: "run.create";
|
|
75
|
+
readonly delivery: OrchestrationRunCreateResult["delivery"];
|
|
76
|
+
readonly initialDelivery: CliCompactDelivery;
|
|
77
|
+
readonly receipt: CliCompactReceipt;
|
|
78
|
+
};
|
|
79
|
+
export type CliQuestionOpenResult = {
|
|
80
|
+
readonly aggregate: CliCompactAggregate;
|
|
81
|
+
readonly command: "run.question.open";
|
|
82
|
+
readonly delivery: CliCompactDelivery;
|
|
83
|
+
readonly receipt: CliCompactReceipt;
|
|
84
|
+
};
|
|
85
|
+
export type CliQuestionReplyResult = {
|
|
86
|
+
readonly aggregate: CliCompactAggregate;
|
|
87
|
+
readonly command: "run.question.reply";
|
|
88
|
+
readonly delivery: CliCompactDelivery;
|
|
89
|
+
readonly receipt: CliCompactReceipt;
|
|
90
|
+
};
|
|
91
|
+
export type CliQuestionCancelResult = {
|
|
92
|
+
readonly aggregate: CliCompactAggregate;
|
|
93
|
+
readonly command: "run.question.cancel";
|
|
94
|
+
readonly receipt: CliCompactReceipt;
|
|
95
|
+
};
|
|
96
|
+
export type CliDispatchSettleResult = {
|
|
97
|
+
readonly aggregate: CliCompactAggregate;
|
|
98
|
+
readonly command: "run.dispatch.settle-terminal";
|
|
99
|
+
readonly delivery: CliCompactDelivery;
|
|
100
|
+
readonly receipt: CliCompactReceipt;
|
|
101
|
+
};
|
|
102
|
+
export type CliInboxAckResult = {
|
|
103
|
+
readonly command: "run.inbox.ack";
|
|
104
|
+
readonly delivery: CliCompactDelivery;
|
|
105
|
+
readonly mailboxId: OrchestrationInboxAckResult["mailbox"]["id"];
|
|
106
|
+
readonly mailboxRevision: OrchestrationInboxAckResult["mailbox"]["revision"];
|
|
107
|
+
readonly owner: OrchestrationInboxAckResult["mailbox"]["owner"];
|
|
108
|
+
readonly receipt: CliCompactReceipt;
|
|
109
|
+
readonly runId: OrchestrationInboxAckResult["mailbox"]["runId"];
|
|
110
|
+
};
|
|
111
|
+
export declare const projectDispatchShowDispatch: (dispatch: ProtocolDispatch) => CliDispatchShowDispatch;
|
|
112
|
+
export declare const projectOrchestrationAggregate: (aggregate: OrchestrationAggregate) => CliCompactAggregate;
|
|
113
|
+
export declare const projectRunShowResult: (value: OrchestrationRunShowResult) => CliRunShowResult;
|
|
114
|
+
export declare const projectRunCreateResult: (value: OrchestrationRunCreateResult) => CliRunCreateResult;
|
|
115
|
+
export declare const projectQuestionOpenResult: (value: OrchestrationQuestionOpenResult) => CliQuestionOpenResult;
|
|
116
|
+
export declare const projectQuestionReplyResult: (value: OrchestrationQuestionReplyResult) => CliQuestionReplyResult;
|
|
117
|
+
export declare const projectQuestionCancelResult: (value: OrchestrationQuestionCancelResult) => CliQuestionCancelResult;
|
|
118
|
+
export declare const projectDispatchSettleResult: (value: OrchestrationDispatchSettleTerminalResult) => CliDispatchSettleResult;
|
|
119
|
+
export declare const projectInboxAckResult: (value: OrchestrationInboxAckResult) => CliInboxAckResult;
|
|
120
|
+
export {};
|
|
121
|
+
//# sourceMappingURL=compact-aggregate.d.ts.map
|
|
@@ -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
|
+
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
|
+
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,20 @@
|
|
|
1
|
+
import type { OrchestrationRun, OrchestrationRunListResult } from "@maiaos/sdk";
|
|
2
|
+
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
|
+
export {};
|
|
20
|
+
//# 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,80 @@
|
|
|
1
|
+
import type { OrchestrationDispatchShowResult, OrchestrationInboxCheckResult, OrchestrationRunListResult, OrchestrationTaskListResult, OrchestrationTaskShowResult } from "@maiaos/sdk";
|
|
2
|
+
import { type CliIo } from "../../command-line/index.js";
|
|
3
|
+
import type { CliNodeResult } from "../../local-node/index.js";
|
|
4
|
+
import { type CliDispatchSettleResult, type CliDispatchShowDispatch, type CliInboxAckResult, type CliQuestionCancelResult, type CliQuestionOpenResult, type CliQuestionReplyResult, type CliRunCreateResult, type CliRunShowResult, projectDispatchSettleResult, projectInboxAckResult, projectQuestionCancelResult, projectQuestionOpenResult, projectQuestionReplyResult, projectRunCreateResult, projectRunShowResult } from "./compact-aggregate.js";
|
|
5
|
+
import { type CliRunListResult } from "./compact-run-list.js";
|
|
6
|
+
type OutputContext = {
|
|
7
|
+
readonly io: CliIo;
|
|
8
|
+
readonly json: boolean;
|
|
9
|
+
};
|
|
10
|
+
type CliInboxCheckItem = {
|
|
11
|
+
readonly body: OrchestrationInboxCheckResult["items"][number]["message"]["body"];
|
|
12
|
+
readonly deliveryId: OrchestrationInboxCheckResult["items"][number]["id"];
|
|
13
|
+
readonly mailboxId: OrchestrationInboxCheckResult["items"][number]["mailboxId"];
|
|
14
|
+
readonly sequence: OrchestrationInboxCheckResult["items"][number]["sequence"];
|
|
15
|
+
readonly subject: OrchestrationInboxCheckResult["items"][number]["message"]["subject"];
|
|
16
|
+
readonly type: OrchestrationInboxCheckResult["items"][number]["message"]["type"];
|
|
17
|
+
};
|
|
18
|
+
type CliInboxCheckResult = {
|
|
19
|
+
readonly command: "run.inbox.check";
|
|
20
|
+
readonly count: number;
|
|
21
|
+
readonly items: readonly CliInboxCheckItem[];
|
|
22
|
+
readonly mailboxId: OrchestrationInboxCheckResult["mailbox"]["id"];
|
|
23
|
+
readonly mailboxRevision: OrchestrationInboxCheckResult["mailbox"]["revision"];
|
|
24
|
+
readonly owner: OrchestrationInboxCheckResult["mailbox"]["owner"];
|
|
25
|
+
readonly runId: OrchestrationInboxCheckResult["mailbox"]["runId"];
|
|
26
|
+
};
|
|
27
|
+
type CliTaskListItem = {
|
|
28
|
+
readonly clientKey: OrchestrationTaskListResult["items"][number]["clientKey"];
|
|
29
|
+
readonly dependencyTaskIds: OrchestrationTaskListResult["items"][number]["dependencyTaskIds"];
|
|
30
|
+
readonly id: OrchestrationTaskListResult["items"][number]["id"];
|
|
31
|
+
readonly revision: OrchestrationTaskListResult["items"][number]["revision"];
|
|
32
|
+
readonly state: OrchestrationTaskListResult["items"][number]["state"];
|
|
33
|
+
};
|
|
34
|
+
type CliTaskListResult = {
|
|
35
|
+
readonly command: "run.task.list";
|
|
36
|
+
readonly count: number;
|
|
37
|
+
readonly items: readonly CliTaskListItem[];
|
|
38
|
+
readonly nextCursor?: OrchestrationTaskListResult["nextCursor"];
|
|
39
|
+
readonly runId: OrchestrationTaskListResult["runId"];
|
|
40
|
+
};
|
|
41
|
+
type CliTaskShowTask = {
|
|
42
|
+
readonly clientKey: OrchestrationTaskShowResult["task"]["clientKey"];
|
|
43
|
+
readonly dependencyTaskIds: OrchestrationTaskShowResult["task"]["dependencyTaskIds"];
|
|
44
|
+
readonly id: OrchestrationTaskShowResult["task"]["id"];
|
|
45
|
+
readonly objective: OrchestrationTaskShowResult["task"]["objective"];
|
|
46
|
+
readonly revision: OrchestrationTaskShowResult["task"]["revision"];
|
|
47
|
+
readonly runId: OrchestrationTaskShowResult["task"]["runId"];
|
|
48
|
+
readonly state: OrchestrationTaskShowResult["task"]["state"];
|
|
49
|
+
};
|
|
50
|
+
type CliTaskShowResult = {
|
|
51
|
+
readonly command: "run.task.show";
|
|
52
|
+
readonly task: CliTaskShowTask;
|
|
53
|
+
};
|
|
54
|
+
type CliDispatchShowResult = {
|
|
55
|
+
readonly command: "run.dispatch.show";
|
|
56
|
+
readonly dispatch: CliDispatchShowDispatch;
|
|
57
|
+
};
|
|
58
|
+
export type CliOrchestrationResult = CliDispatchSettleResult | CliDispatchShowResult | CliInboxAckResult | CliInboxCheckResult | CliQuestionCancelResult | CliQuestionOpenResult | CliQuestionReplyResult | CliRunCreateResult | CliRunListResult | CliRunShowResult | CliTaskListResult | CliTaskShowResult;
|
|
59
|
+
export declare const formatInboxAck: (result: CliInboxAckResult) => string;
|
|
60
|
+
export declare const formatRunList: (result: CliRunListResult) => string;
|
|
61
|
+
export declare const formatRunShow: (result: CliRunShowResult) => string;
|
|
62
|
+
export declare const formatRunCreate: (result: CliRunCreateResult) => string;
|
|
63
|
+
export declare const formatQuestionOpen: (result: CliQuestionOpenResult) => string;
|
|
64
|
+
export declare const formatQuestionCancel: (result: CliQuestionCancelResult) => string;
|
|
65
|
+
export declare const formatCompactOrchestration: (result: CliOrchestrationResult) => string;
|
|
66
|
+
type ProjectedWriter<TValue> = (result: CliNodeResult<TValue>, context: OutputContext) => number;
|
|
67
|
+
export declare const writeInboxAckResult: ProjectedWriter<Parameters<typeof projectInboxAckResult>[0]>;
|
|
68
|
+
export declare const writeInboxCheckResult: (result: CliNodeResult<OrchestrationInboxCheckResult>, context: OutputContext) => number;
|
|
69
|
+
export declare const writeRunListResult: (result: CliNodeResult<OrchestrationRunListResult>, context: OutputContext, workspaceId: string) => number;
|
|
70
|
+
export declare const writeTaskListResult: (result: CliNodeResult<OrchestrationTaskListResult>, context: OutputContext) => number;
|
|
71
|
+
export declare const writeTaskShowResult: (result: CliNodeResult<OrchestrationTaskShowResult>, context: OutputContext) => number;
|
|
72
|
+
export declare const writeDispatchShowResult: (result: CliNodeResult<OrchestrationDispatchShowResult>, context: OutputContext) => number;
|
|
73
|
+
export declare const writeRunShowResult: ProjectedWriter<Parameters<typeof projectRunShowResult>[0]>;
|
|
74
|
+
export declare const writeRunCreateResult: ProjectedWriter<Parameters<typeof projectRunCreateResult>[0]>;
|
|
75
|
+
export declare const writeQuestionOpenResult: ProjectedWriter<Parameters<typeof projectQuestionOpenResult>[0]>;
|
|
76
|
+
export declare const writeQuestionReplyResult: ProjectedWriter<Parameters<typeof projectQuestionReplyResult>[0]>;
|
|
77
|
+
export declare const writeQuestionCancelResult: ProjectedWriter<Parameters<typeof projectQuestionCancelResult>[0]>;
|
|
78
|
+
export declare const writeDispatchSettleResult: ProjectedWriter<Parameters<typeof projectDispatchSettleResult>[0]>;
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=human.d.ts.map
|