@maiaos/cli 0.1.0-canary.63 → 0.1.0-canary.65
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/LICENSE +21 -0
- package/README.md +15 -9
- package/dist/address-space/address-space.js +21 -2
- package/dist/address-space/index.js +1 -1
- package/dist/agents/client.d.ts +1 -0
- package/dist/agents/tree/tree.js +3 -3
- package/dist/bin/maia.NOTICES.txt +1 -1
- package/dist/bin/maia.cdx.json +70 -19
- package/dist/bin/maia.mjs +1 -1
- package/dist/board/client.d.ts +27 -0
- package/dist/board/client.js +40 -0
- package/dist/board/commands.d.ts +28 -0
- package/dist/board/commands.js +52 -0
- package/dist/board/index.d.ts +3 -0
- package/dist/board/index.js +3 -0
- package/dist/board/input.js +339 -0
- package/dist/board/output/format.js +175 -0
- package/dist/board/output/index.js +2 -0
- package/dist/board/plan.js +47 -0
- package/dist/board/tree/index.js +2 -0
- package/dist/board/tree/tree.js +161 -0
- package/dist/cli/cli.d.ts +3 -1
- package/dist/cli/cli.js +175 -6
- package/dist/cli/log-level.d.ts +11 -0
- package/dist/cli/log-level.js +14 -0
- package/dist/command-line/context.d.ts +18 -5
- package/dist/command-line/emit/output.d.ts +5 -1
- package/dist/command-line/emit/output.js +13 -5
- package/dist/command-line/index.d.ts +2 -2
- package/dist/command-line/index.js +1 -2
- package/dist/command-line/input/arguments.d.ts +3 -0
- package/dist/command-line/input/arguments.js +12 -0
- package/dist/command-line/input/index.d.ts +2 -2
- package/dist/command-line/input/index.js +2 -2
- package/dist/command-line/input/prompt.d.ts +1 -0
- package/dist/command-line/input/prompt.js +1 -0
- package/dist/command-line/two-phase/two-phase.d.ts +4 -4
- package/dist/command-line/two-phase/two-phase.js +9 -9
- package/dist/command-tree/commands.js +0 -4
- package/dist/command-tree/deprecated.d.ts +2 -0
- package/dist/command-tree/deprecated.js +29 -0
- package/dist/command-tree/grammar.js +2 -0
- package/dist/command-tree/help.d.ts +2 -2
- package/dist/command-tree/help.js +13 -15
- package/dist/command-tree/index.d.ts +1 -0
- package/dist/command-tree/index.js +1 -0
- package/dist/command-tree/local.js +10 -5
- package/dist/command-tree/placeholder.js +1 -1
- package/dist/command-tree/row.d.ts +1 -0
- package/dist/command-tree/tree.d.ts +2 -1
- package/dist/command-tree/tree.js +30 -4
- package/dist/connection/client.d.ts +36 -18
- package/dist/connection/client.js +1 -0
- package/dist/connection/executors/executors.d.ts +18 -0
- package/dist/connection/executors/executors.js +95 -0
- package/dist/connection/executors/index.d.ts +2 -0
- package/dist/connection/executors/index.js +2 -0
- package/dist/connection/executors/reading.js +22 -0
- package/dist/connection/index.d.ts +1 -0
- package/dist/connection/index.js +1 -0
- package/dist/connection/input.js +2 -2
- package/dist/connection/login.d.ts +1 -1
- package/dist/connection/login.js +4 -3
- package/dist/connection/output/format.js +2 -2
- package/dist/connection/output/index.d.ts +1 -1
- package/dist/connection/output/index.js +1 -1
- package/dist/connection/resolve.d.ts +1 -0
- package/dist/connection/setup-file.js +161 -0
- package/dist/connection/system.js +90 -45
- package/dist/connection/tree/tree.js +120 -7
- package/dist/container/client.d.ts +2 -0
- package/dist/fleet/fleet.d.ts +7 -8
- package/dist/fleet/fleet.js +18 -6
- package/dist/fleet/index.d.ts +1 -1
- package/dist/fleet/index.js +1 -1
- package/dist/github/client.d.ts +189 -0
- package/dist/github/client.js +16 -0
- package/dist/github/commands.d.ts +17 -0
- package/dist/github/commands.js +81 -0
- package/dist/github/index.d.ts +3 -0
- package/dist/github/index.js +3 -0
- package/dist/github/input.js +114 -0
- package/dist/github/output/format.js +78 -0
- package/dist/github/output/index.js +2 -0
- package/dist/github/tree/index.js +2 -0
- package/dist/github/tree/tree.js +28 -0
- package/dist/goal/client.d.ts +246 -0
- package/dist/goal/client.js +13 -0
- package/dist/goal/commands.d.ts +22 -0
- package/dist/goal/commands.js +110 -0
- package/dist/goal/index.d.ts +4 -0
- package/dist/goal/index.js +4 -0
- package/dist/goal/input.js +118 -0
- package/dist/goal/output/format.js +29 -0
- package/dist/goal/output/index.js +2 -0
- package/dist/goal/pause.d.ts +16 -0
- package/dist/goal/pause.js +91 -0
- package/dist/goal/tree/index.js +2 -0
- package/dist/goal/tree/tree.js +49 -0
- package/dist/hold/client.d.ts +2 -0
- package/dist/hold/tree/tree.js +2 -2
- package/dist/import/{batch.js → batch/batch.js} +5 -5
- package/dist/import/batch/index.js +3 -0
- package/dist/import/{manifest.js → batch/manifest.js} +7 -6
- package/dist/import/commands.d.ts +1 -0
- package/dist/import/commands.js +27 -15
- package/dist/import/detach.d.ts +12 -0
- package/dist/import/detach.js +70 -0
- package/dist/import/index.d.ts +2 -1
- package/dist/import/index.js +2 -1
- package/dist/import/input.js +32 -10
- package/dist/import/output.js +13 -8
- package/dist/inbox/client.d.ts +310 -0
- package/dist/inbox/client.js +15 -0
- package/dist/inbox/index.d.ts +2 -0
- package/dist/inbox/index.js +2 -0
- package/dist/integration/client.d.ts +307 -1
- package/dist/integration/client.js +21 -1
- package/dist/integration/commands.d.ts +8 -0
- package/dist/integration/commands.js +53 -10
- package/dist/integration/index.d.ts +1 -1
- package/dist/integration/index.js +1 -1
- package/dist/local-node/client.d.ts +11 -1
- package/dist/local-node/client.js +185 -235
- package/dist/local-node/index.d.ts +1 -1
- package/dist/local-node/index.js +1 -1
- package/dist/login/commands.js +7 -1
- package/dist/login/gateway.js +34 -11
- package/dist/login/menu.js +2 -1
- package/dist/login/vendor-account.js +3 -2
- package/dist/login/vendor-input.js +3 -2
- package/dist/mcp/calls.js +47 -226
- package/dist/mcp/routing.d.ts +3 -2
- package/dist/mcp/routing.js +37 -8
- package/dist/mcp/server.d.ts +10 -1
- package/dist/mcp/server.js +16 -6
- package/dist/migrate/classes.js +158 -0
- package/dist/migrate/commands.js +46 -0
- package/dist/migrate/format.js +199 -0
- package/dist/migrate/index.js +2 -0
- package/dist/migrate/item.js +59 -0
- package/dist/migrate/plan.js +79 -0
- package/dist/migrate/tree/index.js +2 -0
- package/dist/migrate/tree/tree.js +23 -0
- package/dist/node-update/client.d.ts +17 -0
- package/dist/node-update/client.js +27 -0
- package/dist/node-update/commands.d.ts +20 -0
- package/dist/node-update/commands.js +150 -0
- package/dist/node-update/index.d.ts +4 -0
- package/dist/node-update/index.js +4 -0
- package/dist/node-update/output.d.ts +12 -0
- package/dist/node-update/output.js +165 -0
- package/dist/node-update/tree/index.js +2 -0
- package/dist/node-update/tree/tree.js +73 -0
- package/dist/pairing/client.d.ts +13 -0
- package/dist/pairing/client.js +36 -0
- package/dist/pairing/commands.d.ts +15 -0
- package/dist/pairing/commands.js +131 -0
- package/dist/pairing/index.d.ts +4 -0
- package/dist/pairing/index.js +4 -0
- package/dist/pairing/output.d.ts +12 -0
- package/dist/pairing/output.js +53 -0
- package/dist/pairing/tree/index.js +2 -0
- package/dist/pairing/tree/tree.js +35 -0
- package/dist/panel/client.d.ts +9 -0
- package/dist/panel/client.js +24 -0
- package/dist/panel/commands.d.ts +19 -0
- package/dist/panel/commands.js +112 -0
- package/dist/panel/index.d.ts +3 -0
- package/dist/panel/index.js +3 -0
- package/dist/panel/tree/index.js +2 -0
- package/dist/panel/tree/tree.js +14 -0
- package/dist/port-lease/client.d.ts +3 -0
- package/dist/principal/client.d.ts +9 -0
- package/dist/principal/client.js +7 -0
- package/dist/principal/commands.d.ts +14 -0
- package/dist/principal/commands.js +84 -0
- package/dist/principal/index.d.ts +4 -0
- package/dist/principal/index.js +4 -0
- package/dist/principal/output.d.ts +8 -0
- package/dist/principal/output.js +43 -0
- package/dist/principal/tree/index.js +2 -0
- package/dist/principal/tree/tree.js +31 -0
- package/dist/project-guard/client.d.ts +1 -0
- package/dist/project-instructions/client.d.ts +56 -0
- package/dist/project-instructions/client.js +7 -0
- package/dist/project-instructions/commands.d.ts +13 -0
- package/dist/project-instructions/commands.js +89 -0
- package/dist/project-instructions/index.d.ts +3 -0
- package/dist/project-instructions/index.js +3 -0
- package/dist/project-instructions/input.js +33 -0
- package/dist/project-instructions/output/format.js +22 -0
- package/dist/project-instructions/output/index.js +2 -0
- package/dist/project-knowledge/change.js +22 -0
- package/dist/project-knowledge/client.d.ts +127 -0
- package/dist/project-knowledge/client.js +17 -0
- package/dist/project-knowledge/commands.d.ts +14 -0
- package/dist/project-knowledge/commands.js +100 -0
- package/dist/project-knowledge/index.d.ts +3 -0
- package/dist/project-knowledge/index.js +3 -0
- package/dist/project-knowledge/input.js +32 -0
- package/dist/project-knowledge/output/format.js +64 -0
- package/dist/project-knowledge/output/index.js +2 -0
- package/dist/project-knowledge/sources.js +108 -0
- package/dist/project-knowledge/upload.js +27 -0
- package/dist/project-workspace/git-reads.d.ts +12 -0
- package/dist/project-workspace/git-reads.js +71 -0
- package/dist/project-workspace/index.d.ts +1 -0
- package/dist/project-workspace/index.js +1 -0
- package/dist/project-workspace/metadata-client.d.ts +2 -0
- package/dist/project-workspace/output/human.js +1 -1
- package/dist/project-workspace/tree/tree.js +95 -5
- package/dist/reach/client.d.ts +9 -0
- package/dist/reach/client.js +7 -0
- package/dist/reach/commands.d.ts +14 -0
- package/dist/reach/commands.js +72 -0
- package/dist/reach/index.d.ts +3 -0
- package/dist/reach/index.js +3 -0
- package/dist/reach/output.js +41 -0
- package/dist/reach/tree/index.js +2 -0
- package/dist/reach/tree/tree.js +28 -0
- package/dist/remote-node/client.d.ts +85 -0
- package/dist/remote-node/commands.js +32 -17
- package/dist/remote-node/connector.d.ts +16 -0
- package/dist/remote-node/connector.js +2 -2
- package/dist/remote-node/reachability.js +31 -18
- package/dist/remote-node/reading.js +31 -0
- package/dist/remote-node/text.js +68 -5
- package/dist/remote-node/tree/tree.js +14 -3
- package/dist/routine/client.d.ts +547 -13
- package/dist/routine/client.js +19 -1
- package/dist/routine/commands.d.ts +5 -0
- package/dist/routine/commands.js +73 -15
- package/dist/routine/index.d.ts +2 -1
- package/dist/routine/index.js +2 -1
- package/dist/routine/input.js +66 -3
- package/dist/routine/output/format.js +80 -19
- package/dist/routine/output/index.js +1 -1
- package/dist/routine/portable/import-files.js +74 -0
- package/dist/routine/portable/import-output.js +21 -0
- package/dist/routine/portable/import.js +274 -0
- package/dist/routine/portable/index.js +3 -0
- package/dist/routine/portable/portable.js +185 -0
- package/dist/routine/tree/tree.js +80 -8
- package/dist/routine/trigger/commands.d.ts +20 -0
- package/dist/routine/trigger/commands.js +74 -0
- package/dist/routine/trigger/format.js +42 -0
- package/dist/routine/trigger/index.d.ts +2 -0
- package/dist/routine/trigger/index.js +2 -0
- package/dist/routine/trigger/input.js +81 -0
- package/dist/run-ledger/client.d.ts +45 -0
- package/dist/secret/client.d.ts +39 -0
- package/dist/secret/client.js +6 -0
- package/dist/secret/commands.d.ts +12 -0
- package/dist/secret/commands.js +91 -0
- package/dist/secret/index.d.ts +3 -0
- package/dist/secret/index.js +3 -0
- package/dist/secret/input.js +22 -0
- package/dist/secret/output/format.js +10 -0
- package/dist/secret/output/index.js +2 -0
- package/dist/secret/tree/index.js +2 -0
- package/dist/secret/tree/tree.js +16 -0
- package/dist/session/agent-permission.d.ts +3 -2
- package/dist/session/approval/client.d.ts +4 -3
- package/dist/session/approval/commands.d.ts +7 -0
- package/dist/session/approval/commands.js +176 -6
- package/dist/session/approval/index.d.ts +1 -1
- package/dist/session/approval/index.js +1 -1
- package/dist/session/approval/output/format.js +53 -1
- package/dist/session/approval/output/index.js +1 -1
- package/dist/session/attach.d.ts +1 -1
- package/dist/session/attach.js +7 -2
- package/dist/session/client.d.ts +12 -12
- package/dist/session/client.js +8 -17
- package/dist/session/command/commands.js +109 -0
- package/dist/session/command/index.js +2 -0
- package/dist/session/commands.d.ts +5 -1
- package/dist/session/commands.js +260 -55
- package/dist/session/create-tasks.js +3 -48
- package/dist/session/creation/creation.js +51 -0
- package/dist/session/creation/index.js +2 -0
- package/dist/session/fork/fork.js +135 -0
- package/dist/session/fork/index.js +2 -0
- package/dist/session/git-status.d.ts +11 -0
- package/dist/session/git-status.js +30 -0
- package/dist/session/index.d.ts +4 -3
- package/dist/session/index.js +3 -2
- package/dist/session/interaction/client.d.ts +3 -0
- package/dist/session/move/index.js +2 -0
- package/dist/session/move/move.js +439 -0
- package/dist/session/output/held.js +28 -0
- package/dist/session/output/human.js +34 -7
- package/dist/session/output/tasks.js +23 -6
- package/dist/session/setup/index.js +2 -0
- package/dist/session/setup/setup.js +69 -0
- package/dist/session/spawn/caps.js +128 -0
- package/dist/session/spawn/index.js +5 -0
- package/dist/session/spawn/spawn.js +203 -0
- package/dist/session/spawn/standing.js +62 -0
- package/dist/session/spawn/supervision.js +62 -0
- package/dist/session/switch/index.js +2 -0
- package/dist/session/switch/switch.js +103 -0
- package/dist/session/tree/tree.js +280 -18
- package/dist/session/turn/attachments.js +54 -0
- package/dist/session/turn/client.d.ts +3 -1
- package/dist/session/turn/client.js +6 -1
- package/dist/session/turn/commands.d.ts +5 -1
- package/dist/session/turn/commands.js +148 -27
- package/dist/session/turn/index.d.ts +2 -2
- package/dist/session/turn/index.js +1 -1
- package/dist/session/turn/output.d.ts +25 -1
- package/dist/session/turn/output.js +33 -0
- package/dist/skills-sync/client.d.ts +9 -0
- package/dist/skills-sync/client.js +7 -0
- package/dist/skills-sync/commands.d.ts +15 -0
- package/dist/skills-sync/commands.js +241 -0
- package/dist/skills-sync/index.d.ts +3 -0
- package/dist/skills-sync/index.js +3 -0
- package/dist/skills-sync/output.js +168 -0
- package/dist/skills-sync/set-file.js +23 -0
- package/dist/skills-sync/tree/index.js +2 -0
- package/dist/skills-sync/tree/tree.js +38 -0
- package/dist/status/client.d.ts +7 -0
- package/dist/status/command.js +3 -2
- package/dist/status/doctor.js +4 -3
- package/dist/team-workspace/client.d.ts +1 -0
- package/dist/text-input/index.js +2 -0
- package/dist/text-input/text-input.js +35 -0
- package/dist/webhooks/client.d.ts +10 -9
- package/dist/webhooks/input.js +2 -2
- package/dist/webhooks/tree/tree.js +4 -4
- package/guidance/maia-sessions/SKILL.md +37 -3
- package/package.json +6 -5
- package/dist/command-line/context.js +0 -2
package/dist/session/commands.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { MAX_SESSION_INBOX_CHECK_LIMIT, MAX_SESSION_MESSAGE_BODY_BYTES, MAX_SESSION_OBSERVE_IDS, MAX_SESSION_SETTLED_IDLE_SECONDS, MAX_SESSION_STALL_AFTER_SECONDS, MIN_SESSION_STALL_AFTER_SECONDS, SESSION_EFFORT_LEVELS, sessionBaseRefSchema, sessionCreateParametersSchema, } from "@maiaos/sdk";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { listEach, writeMerged } from "../address-space/index.js";
|
|
4
|
-
import { CliArgumentError, LABEL_OPTION, parseOptions, parseOptionsWith, readCursor, readDuration, readExpectedRevision, readLabels, readPageSize, readPermission, readSessionRole, readSessionTitle, readWaitTimeoutSeconds, requireOneLabelPerOption, requirePositionals, writeNodeResult, } from "../command-line/index.js";
|
|
5
|
-
import { mergeLists } from "../fleet/index.js";
|
|
1
|
+
import { EXECUTOR_IDS, MAX_SESSION_INBOX_CHECK_LIMIT, MAX_SESSION_MESSAGE_BODY_BYTES, MAX_SESSION_OBSERVE_IDS, MAX_SESSION_SETTLED_IDLE_SECONDS, MAX_SESSION_STALL_AFTER_SECONDS, MIN_SESSION_STALL_AFTER_SECONDS, SESSION_EFFORT_LEVELS, sessionBaseRefSchema, sessionBranchNameSchema, sessionCreateParametersSchema, sessionEffortLevels, sessionExecutorKindSchema, } from "@maiaos/sdk";
|
|
2
|
+
import { Clock, Effect } from "effect";
|
|
3
|
+
import { everyNode, everyNodeName, formatMerged, listEach, writeMerged, } from "../address-space/index.js";
|
|
4
|
+
import { cell, CliArgumentError, exitCodeOf, formatRows, LABEL_OPTION, LOCAL_NODE, parseOptions, parseOptionsWith, readCursor, readDuration, readExpectedRevision, readLabels, readOptionalRevision, readPageSize, readPermission, readSessionRole, readSessionTitle, readWaitTimeoutSeconds, requireOneLabelPerOption, requirePositionals, writeNodeResult, writeSuccess, } from "../command-line/index.js";
|
|
5
|
+
import { freshnessOf, mergeLists } from "../fleet/index.js";
|
|
6
|
+
import { changeAtRevision, } from "../local-node/index.js";
|
|
6
7
|
import { runSessionTasks, } from "./create-tasks.js";
|
|
7
|
-
import { formatMergedSessions, formatSessionShow, writeSessionResult, } from "./output/index.js";
|
|
8
|
+
import { formatMergedSessions, formatSessionResult, formatSessionShow, writeSessionResult, } from "./output/index.js";
|
|
9
|
+
import { cancelChildren, readResumeParent, reconcileChildren, resumeSupervised, runSessionSpawn as runSpawn, } from "./spawn/index.js";
|
|
8
10
|
const EXIT_DEADLINE = 74;
|
|
9
11
|
const SESSION_CREATE_OPTIONS = new Set([
|
|
10
12
|
"--agent",
|
|
11
13
|
"--base",
|
|
14
|
+
"--branch",
|
|
12
15
|
"--command-id",
|
|
13
16
|
"--connection",
|
|
14
17
|
"--cwd",
|
|
15
18
|
"--effort",
|
|
16
|
-
"--
|
|
19
|
+
"--harness",
|
|
17
20
|
"--label",
|
|
18
21
|
"--model",
|
|
19
22
|
"--name",
|
|
@@ -74,7 +77,7 @@ const readSessionCreateOptions = (parsed) => {
|
|
|
74
77
|
const workspaceId = parsed.options.get("--workspace");
|
|
75
78
|
if (workspaceId === undefined)
|
|
76
79
|
throw new CliArgumentError(parsed.options.has("--project")
|
|
77
|
-
? "Option '--project' needs '--
|
|
80
|
+
? "Option '--project' needs '--text', '--prompt-stdin' or '--from-file'; name a Workspace with '--workspace' otherwise."
|
|
78
81
|
: "Option '--workspace' is required.");
|
|
79
82
|
const input = readSessionSelection(parsed, workspaceId);
|
|
80
83
|
const definition = readDefinitionSelection(parsed.options, input);
|
|
@@ -84,7 +87,7 @@ const readSessionCreateOptions = (parsed) => {
|
|
|
84
87
|
const requireOneSelection = (input) => {
|
|
85
88
|
if (input.definitionRef !== undefined &&
|
|
86
89
|
(input.connectionId !== undefined || input.executor !== undefined))
|
|
87
|
-
throw new CliArgumentError("Use one of '--connection', '--
|
|
90
|
+
throw new CliArgumentError("Use one of '--connection', '--harness' or '--agent-definition'.");
|
|
88
91
|
if (input.model !== undefined && input.connectionId === undefined)
|
|
89
92
|
throw new CliArgumentError("Option '--model' needs '--connection' with a gateway connection.");
|
|
90
93
|
requireSupportedEffort(input);
|
|
@@ -93,18 +96,20 @@ const requireSupportedEffort = ({ connectionId, effort, executor, }) => {
|
|
|
93
96
|
if (effort === undefined)
|
|
94
97
|
return;
|
|
95
98
|
if (connectionId === undefined && executor === undefined)
|
|
96
|
-
throw new CliArgumentError("Option '--effort' needs '--connection' or '--
|
|
97
|
-
const levels = executor === undefined ? [] :
|
|
99
|
+
throw new CliArgumentError("Option '--effort' needs '--connection' or '--harness'.");
|
|
100
|
+
const levels = executor === undefined ? [] : sessionEffortLevels(executor);
|
|
98
101
|
if (executor !== undefined && !levels.includes(effort))
|
|
99
|
-
throw new CliArgumentError(
|
|
102
|
+
throw new CliArgumentError(levels.length === 0
|
|
103
|
+
? `The ${executor} executor declares no effort levels.`
|
|
104
|
+
: `Executor ${executor} supports effort ${levels.join(", ")}.`);
|
|
100
105
|
};
|
|
101
106
|
const readEffort = (value) => {
|
|
102
107
|
if (value === undefined)
|
|
103
108
|
return;
|
|
104
|
-
const level = SESSION_EFFORT_LEVELS[
|
|
109
|
+
const level = SESSION_EFFORT_LEVELS[EXECUTOR_IDS.codex].find((candidate) => candidate === value);
|
|
105
110
|
if (level !== undefined)
|
|
106
111
|
return level;
|
|
107
|
-
throw new CliArgumentError(`Option '--effort' must be ${SESSION_EFFORT_LEVELS[
|
|
112
|
+
throw new CliArgumentError(`Option '--effort' must be ${SESSION_EFFORT_LEVELS[EXECUTOR_IDS.codex].slice(0, -1).join(", ")} or ${SESSION_EFFORT_LEVELS[EXECUTOR_IDS.codex].at(-1) ?? "ultra"}.`);
|
|
108
113
|
};
|
|
109
114
|
const AGENT_FIXED_OPTIONS = [
|
|
110
115
|
"--agent-definition",
|
|
@@ -112,7 +117,7 @@ const AGENT_FIXED_OPTIONS = [
|
|
|
112
117
|
"--agent-definition-version",
|
|
113
118
|
"--connection",
|
|
114
119
|
"--effort",
|
|
115
|
-
"--
|
|
120
|
+
"--harness",
|
|
116
121
|
"--model",
|
|
117
122
|
];
|
|
118
123
|
const readAgentId = (options) => {
|
|
@@ -128,7 +133,7 @@ const readSessionSelection = ({ flags, options }, workspaceId) => {
|
|
|
128
133
|
const agent = readAgentId(options);
|
|
129
134
|
const commandId = options.get("--command-id");
|
|
130
135
|
const connectionId = options.get("--connection");
|
|
131
|
-
const executor = readExecutorKind(options.get("--
|
|
136
|
+
const executor = readExecutorKind(options.get("--harness"));
|
|
132
137
|
const effort = readEffort(options.get("--effort"));
|
|
133
138
|
const cwd = options.get("--cwd");
|
|
134
139
|
const model = options.get("--model");
|
|
@@ -147,8 +152,7 @@ const readSessionSelection = ({ flags, options }, workspaceId) => {
|
|
|
147
152
|
...readHostAuthority({ flags, options }),
|
|
148
153
|
workspaceId,
|
|
149
154
|
};
|
|
150
|
-
|
|
151
|
-
return { ...selection, ...(baseRef === undefined ? {} : { baseRef }) };
|
|
155
|
+
return { ...selection, ...readWorktreeOptions(options, selection) };
|
|
152
156
|
};
|
|
153
157
|
const validPermission = (permission, executor) => {
|
|
154
158
|
const valid = sessionCreateParametersSchema.safeParse({
|
|
@@ -172,11 +176,19 @@ const readHostAuthority = ({ flags, options, }) => {
|
|
|
172
176
|
}
|
|
173
177
|
if (options.has("--base"))
|
|
174
178
|
throw new CliArgumentError("Option '--host-authority' runs in an existing '--cwd', not a Maia worktree; drop '--base'.");
|
|
175
|
-
if (!options.has("--connection") && !options.has("--
|
|
176
|
-
throw new CliArgumentError("Option '--host-authority' needs '--connection' or '--
|
|
179
|
+
if (!options.has("--connection") && !options.has("--harness"))
|
|
180
|
+
throw new CliArgumentError("Option '--host-authority' needs '--connection' or '--harness'.");
|
|
177
181
|
return {
|
|
178
182
|
hostAuthority: true,
|
|
179
|
-
...readPermission(permission, (value) => validPermission(value, readExecutorKind(options.get("--
|
|
183
|
+
...readPermission(permission, (value) => validPermission(value, readExecutorKind(options.get("--harness")))),
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
const readWorktreeOptions = (options, selection) => {
|
|
187
|
+
const baseRef = readBaseRef(options.get("--base"), selection);
|
|
188
|
+
const branch = readBranch(options.get("--branch"), baseRef);
|
|
189
|
+
return {
|
|
190
|
+
...(baseRef === undefined ? {} : { baseRef }),
|
|
191
|
+
...(branch === undefined ? {} : { branch }),
|
|
180
192
|
};
|
|
181
193
|
};
|
|
182
194
|
const readBaseRef = (value, selection) => {
|
|
@@ -185,15 +197,27 @@ const readBaseRef = (value, selection) => {
|
|
|
185
197
|
if (selection.agentId === undefined &&
|
|
186
198
|
selection.connectionId === undefined &&
|
|
187
199
|
selection.executor === undefined)
|
|
188
|
-
throw new CliArgumentError("Option '--base' needs '--agent', '--connection' or '--
|
|
200
|
+
throw new CliArgumentError("Option '--base' needs '--agent', '--connection' or '--harness'.");
|
|
189
201
|
if (sessionBaseRefSchema.safeParse(value).success)
|
|
190
202
|
return value;
|
|
191
203
|
throw new CliArgumentError("Option '--base' must name a branch, tag or commit without ranges, revision suffixes or a leading dash.");
|
|
192
204
|
};
|
|
205
|
+
const readBranch = (value, baseRef) => {
|
|
206
|
+
if (value === undefined)
|
|
207
|
+
return;
|
|
208
|
+
if (baseRef === undefined)
|
|
209
|
+
throw new CliArgumentError("Option '--branch' needs '--base'.");
|
|
210
|
+
if (sessionBranchNameSchema.safeParse(value).success)
|
|
211
|
+
return value;
|
|
212
|
+
throw new CliArgumentError("Option '--branch' must be 'maia/<name>' of up to 160 characters: letters, digits, '_', '-' and single inner dots, not ending in '.lock'.");
|
|
213
|
+
};
|
|
193
214
|
const readExecutorKind = (value) => {
|
|
194
|
-
if (value === undefined
|
|
215
|
+
if (value === undefined)
|
|
195
216
|
return value;
|
|
196
|
-
|
|
217
|
+
const valid = sessionExecutorKindSchema.safeParse(value);
|
|
218
|
+
if (valid.success)
|
|
219
|
+
return valid.data;
|
|
220
|
+
throw new CliArgumentError("Option '--harness' must be an executor id: lowercase letters, digits and dashes, starting with a letter, such as codex-cli or claude-code.");
|
|
197
221
|
};
|
|
198
222
|
const readDefinitionSelection = (options, input) => {
|
|
199
223
|
const key = options.get("--agent-definition");
|
|
@@ -218,23 +242,28 @@ const readDefinitionSelection = (options, input) => {
|
|
|
218
242
|
const TASK_OPTIONS = new Set([
|
|
219
243
|
...SESSION_CREATE_OPTIONS,
|
|
220
244
|
"--from-file",
|
|
221
|
-
"--
|
|
245
|
+
"--text",
|
|
222
246
|
"--project",
|
|
223
247
|
"--workspace",
|
|
224
248
|
]);
|
|
249
|
+
const requireOneSessionOptions = (options) => {
|
|
250
|
+
if (options.has("--title") || options.has("--name"))
|
|
251
|
+
throw new CliArgumentError("Option '--title' or '--name' names one Session; with '--from-file' each Session takes its task's first line.");
|
|
252
|
+
if (options.has("--label"))
|
|
253
|
+
throw new CliArgumentError("Option '--label' labels one Session; it cannot be used with '--from-file'.");
|
|
254
|
+
if (options.has("--branch"))
|
|
255
|
+
throw new CliArgumentError("Option '--branch' names one Session's branch; it cannot be used with '--from-file'.");
|
|
256
|
+
};
|
|
225
257
|
const taskSource = (parsed) => {
|
|
226
258
|
const file = parsed.options.get("--from-file");
|
|
227
|
-
const message = parsed.options.get("--
|
|
259
|
+
const message = parsed.options.get("--text");
|
|
228
260
|
const stdin = parsed.flags.has("--prompt-stdin");
|
|
229
261
|
if ([file, message, stdin ? "" : undefined].filter((value) => value !== undefined).length > 1)
|
|
230
|
-
throw new CliArgumentError("Use one of '--
|
|
231
|
-
if (file !== undefined
|
|
232
|
-
(parsed.options
|
|
233
|
-
throw new CliArgumentError("Option '--title' or '--name' names one Session; with '--from-file' each Session takes its task's first line.");
|
|
234
|
-
if (file !== undefined && parsed.options.has("--label"))
|
|
235
|
-
throw new CliArgumentError("Option '--label' labels one Session; it cannot be used with '--from-file'.");
|
|
236
|
-
if (file !== undefined)
|
|
262
|
+
throw new CliArgumentError("Use one of '--text', '--prompt-stdin' or '--from-file'.");
|
|
263
|
+
if (file !== undefined) {
|
|
264
|
+
requireOneSessionOptions(parsed.options);
|
|
237
265
|
return { kind: "file", path: file };
|
|
266
|
+
}
|
|
238
267
|
if (message !== undefined)
|
|
239
268
|
return { kind: "message", text: message };
|
|
240
269
|
return stdin ? { kind: "stdin" } : undefined;
|
|
@@ -247,7 +276,7 @@ const readTaskWorkspace = (parsed, source) => {
|
|
|
247
276
|
if (parsed.options.has("--agent-definition"))
|
|
248
277
|
throw new CliArgumentError("Option '--agent-definition' does not apply to Session tasks.");
|
|
249
278
|
if (parsed.options.has("--command-id") && source.kind === "file")
|
|
250
|
-
throw new CliArgumentError("Option '--command-id' names one Session; use it with '--
|
|
279
|
+
throw new CliArgumentError("Option '--command-id' names one Session; use it with '--text' or '--prompt-stdin'.");
|
|
251
280
|
return named;
|
|
252
281
|
};
|
|
253
282
|
const readSessionTasks = (parsed, source) => {
|
|
@@ -298,6 +327,15 @@ const readSettled = ({ flags, options, }) => {
|
|
|
298
327
|
settled: true,
|
|
299
328
|
};
|
|
300
329
|
};
|
|
330
|
+
const requireOneScope = (projectId, flags) => {
|
|
331
|
+
const everyProject = flags.has("--all") || flags.has("--all-nodes");
|
|
332
|
+
if ((projectId === undefined) === !everyProject)
|
|
333
|
+
throw new CliArgumentError("Use one of '--project', '--all' or '--all-nodes'.");
|
|
334
|
+
};
|
|
335
|
+
const readParent = (options) => {
|
|
336
|
+
const parentSessionId = options.get("--parent");
|
|
337
|
+
return parentSessionId === undefined ? {} : { parentSessionId };
|
|
338
|
+
};
|
|
301
339
|
const readSessionList = (tokens) => {
|
|
302
340
|
requireOneLabelPerOption(tokens);
|
|
303
341
|
const parsed = parseOptionsWith(tokens, {
|
|
@@ -306,22 +344,23 @@ const readSessionList = (tokens) => {
|
|
|
306
344
|
"--idle-for",
|
|
307
345
|
"--label",
|
|
308
346
|
"--limit",
|
|
347
|
+
"--parent",
|
|
309
348
|
"--project",
|
|
310
349
|
"--state",
|
|
311
350
|
]),
|
|
312
|
-
allowedFlags: new Set(["--all", "--attention", "--settled"]),
|
|
351
|
+
allowedFlags: new Set(["--all", "--all-nodes", "--attention", "--settled"]),
|
|
313
352
|
repeatable: LABEL_OPTION,
|
|
314
353
|
});
|
|
315
354
|
requirePositionals(parsed.positionals, 0);
|
|
316
355
|
const projectId = parsed.options.get("--project");
|
|
317
|
-
|
|
318
|
-
throw new CliArgumentError("Use one of '--project' or '--all'.");
|
|
356
|
+
requireOneScope(projectId, parsed.flags);
|
|
319
357
|
const states = parsed.options.get("--state")?.split(",");
|
|
320
358
|
return {
|
|
321
359
|
afterCursor: readCursor(parsed.options.get("--after")),
|
|
322
360
|
...readSettled(parsed),
|
|
323
361
|
limit: readPageSize(parsed.options.get("--limit")),
|
|
324
362
|
...readLabels(parsed.options.get("--label")),
|
|
363
|
+
...readParent(parsed.options),
|
|
325
364
|
...(projectId === undefined ? {} : { projectId }),
|
|
326
365
|
...(parsed.flags.has("--attention") ? { attention: true } : {}),
|
|
327
366
|
...(states === undefined ? {} : { states }),
|
|
@@ -355,6 +394,98 @@ const writeMergedSessions = (context, answers) => {
|
|
|
355
394
|
};
|
|
356
395
|
return writeMerged(context, { command: "session.list", result }, formatMergedSessions);
|
|
357
396
|
};
|
|
397
|
+
const PLACEMENT_TABLE = {
|
|
398
|
+
empty: "No Nodes answered.",
|
|
399
|
+
headers: [
|
|
400
|
+
"EXECUTOR",
|
|
401
|
+
"READY",
|
|
402
|
+
"LOGIN",
|
|
403
|
+
"ACCOUNTS",
|
|
404
|
+
"ACTIVE",
|
|
405
|
+
"LOAD/CPU",
|
|
406
|
+
"MEM FREE",
|
|
407
|
+
"DISK FREE",
|
|
408
|
+
"READING",
|
|
409
|
+
"LIMIT",
|
|
410
|
+
"REASON",
|
|
411
|
+
],
|
|
412
|
+
};
|
|
413
|
+
const percentCell = (value) => value === undefined ? "-" : `${value.toFixed(0)}%`;
|
|
414
|
+
const figure = (value) => String(Math.round(value * 100) / 100);
|
|
415
|
+
const limitCell = (refusal) => {
|
|
416
|
+
if (refusal === undefined)
|
|
417
|
+
return "-";
|
|
418
|
+
const { code, measured, required, resource, saturation } = refusal;
|
|
419
|
+
if (measured === undefined || required === undefined)
|
|
420
|
+
return resource === undefined
|
|
421
|
+
? (saturation ?? code)
|
|
422
|
+
: `${resource} unreadable`;
|
|
423
|
+
if (resource === undefined)
|
|
424
|
+
return `sessions ${figure(measured)}/${figure(required)}`;
|
|
425
|
+
return resource === "cpu"
|
|
426
|
+
? `cpu ${figure(measured)} load/CPU, max ${figure(required)}`
|
|
427
|
+
: `${resource} ${figure(measured)}% free, min ${figure(required)}%`;
|
|
428
|
+
};
|
|
429
|
+
const placementRow = ({ capacity, executor, login, reading, ready, reason, refusal, }) => [
|
|
430
|
+
executor.id,
|
|
431
|
+
ready ? "yes" : "no",
|
|
432
|
+
login,
|
|
433
|
+
String(executor.accounts),
|
|
434
|
+
`${String(capacity.activeSessions)}/${String(capacity.maximumActiveSessions)}`,
|
|
435
|
+
capacity.host?.loadPerCpu.toFixed(2) ?? "-",
|
|
436
|
+
percentCell(capacity.host?.memoryAvailablePercent),
|
|
437
|
+
percentCell(capacity.host?.diskFreePercent),
|
|
438
|
+
reading,
|
|
439
|
+
limitCell(refusal),
|
|
440
|
+
cell(reason ?? "-"),
|
|
441
|
+
].join("\t");
|
|
442
|
+
const readPlacement = ({ call }, executor) => call === undefined
|
|
443
|
+
? Effect.die(new Error("Missing the typed Node call."))
|
|
444
|
+
: Effect.gen(function* () {
|
|
445
|
+
const result = yield* call("session.placement.show", { executor });
|
|
446
|
+
if (!result.ok)
|
|
447
|
+
return result;
|
|
448
|
+
const now = yield* Clock.currentTimeMillis;
|
|
449
|
+
const { host } = result.value.capacity;
|
|
450
|
+
return {
|
|
451
|
+
ok: true,
|
|
452
|
+
value: {
|
|
453
|
+
...result.value,
|
|
454
|
+
reading: host === undefined ? "live" : freshnessOf(host.observedAt, now),
|
|
455
|
+
},
|
|
456
|
+
};
|
|
457
|
+
});
|
|
458
|
+
const writeMergedPlacements = (context, answers) => {
|
|
459
|
+
const { items, nodes } = mergeLists(answers.map(({ node, result }) => ({
|
|
460
|
+
node,
|
|
461
|
+
result: result.ok
|
|
462
|
+
? { ok: true, value: { items: [result.value] } }
|
|
463
|
+
: result,
|
|
464
|
+
})));
|
|
465
|
+
return writeMerged(context, {
|
|
466
|
+
command: "session.placement.show",
|
|
467
|
+
result: { items, method: "session.placement.show", nodes },
|
|
468
|
+
}, ({ result }) => formatMerged(result, placementRow, PLACEMENT_TABLE));
|
|
469
|
+
};
|
|
470
|
+
export const runSessionPlacementShow = (tokens, context) => {
|
|
471
|
+
const parsed = parseOptions(tokens, new Set(["--harness"]));
|
|
472
|
+
requirePositionals(parsed.positionals, 0);
|
|
473
|
+
const executor = readExecutorKind(parsed.options.get("--harness"));
|
|
474
|
+
if (executor === undefined)
|
|
475
|
+
throw new CliArgumentError("Option '--harness' is required.");
|
|
476
|
+
return listEach(context, {
|
|
477
|
+
merged: (answers) => writeMergedPlacements(context, answers),
|
|
478
|
+
paged: false,
|
|
479
|
+
read: (dependencies) => readPlacement(dependencies, executor),
|
|
480
|
+
sole: (result) => writeNodeResult(result, context, {
|
|
481
|
+
toResult: (value) => ({
|
|
482
|
+
command: "session.placement.show",
|
|
483
|
+
result: value,
|
|
484
|
+
}),
|
|
485
|
+
toText: ({ result }) => formatRows([result], placementRow, PLACEMENT_TABLE),
|
|
486
|
+
}),
|
|
487
|
+
});
|
|
488
|
+
};
|
|
358
489
|
export const runSessionShow = (tokens, context) => Effect.gen(function* () {
|
|
359
490
|
const parsed = parseOptions(tokens, new Set());
|
|
360
491
|
requirePositionals(parsed.positionals, 1);
|
|
@@ -400,27 +531,29 @@ export const runSessionWait = (tokens, context) => Effect.gen(function* () {
|
|
|
400
531
|
});
|
|
401
532
|
return result.ok && !result.value.satisfied ? EXIT_DEADLINE : code;
|
|
402
533
|
});
|
|
403
|
-
const
|
|
534
|
+
const readLifecycleTarget = (parsed) => {
|
|
404
535
|
const sessionId = parsed.positionals[0];
|
|
405
536
|
if (sessionId === undefined) {
|
|
406
537
|
throw new CliArgumentError("The session identifier is missing.");
|
|
407
538
|
}
|
|
408
539
|
const commandId = parsed.options.get("--command-id");
|
|
409
|
-
return {
|
|
410
|
-
expectedRevision: readExpectedRevision(parsed.options.get("--expected-revision")),
|
|
411
|
-
sessionId,
|
|
412
|
-
...(commandId === undefined ? {} : { commandId }),
|
|
413
|
-
};
|
|
540
|
+
return { sessionId, ...(commandId === undefined ? {} : { commandId }) };
|
|
414
541
|
};
|
|
542
|
+
const readLifecycleInput = (parsed) => ({
|
|
543
|
+
...readLifecycleTarget(parsed),
|
|
544
|
+
expectedRevision: readExpectedRevision(parsed.options.get("--expected-revision")),
|
|
545
|
+
});
|
|
415
546
|
const parseSessionLifecycle = (verb, tokens, flags = new Set()) => {
|
|
416
547
|
const parsed = parseOptions(tokens, new Set(["--command-id", "--expected-revision"]), flags);
|
|
417
548
|
requirePositionals(parsed.positionals, 1);
|
|
418
549
|
return { flags: parsed.flags, input: readLifecycleInput(parsed) };
|
|
419
550
|
};
|
|
420
|
-
|
|
551
|
+
const RUNNING_DEADLINE_MILLISECONDS = 120_000;
|
|
552
|
+
const readStartInput = (tokens) => {
|
|
421
553
|
const parsed = parseOptions(tokens, new Set(["--command-id", "--expected-revision", "--timeout"]), new Set(["--wait"]));
|
|
422
554
|
requirePositionals(parsed.positionals, 1);
|
|
423
|
-
const
|
|
555
|
+
const target = readLifecycleTarget(parsed);
|
|
556
|
+
const named = readOptionalRevision(parsed.options);
|
|
424
557
|
const wait = parsed.flags.has("--wait");
|
|
425
558
|
const timeout = parsed.options.get("--timeout");
|
|
426
559
|
if (timeout !== undefined && !wait)
|
|
@@ -428,7 +561,17 @@ export const runSessionStart = (tokens, context) => Effect.gen(function* () {
|
|
|
428
561
|
const deadlineMilliseconds = timeout === undefined
|
|
429
562
|
? RUNNING_DEADLINE_MILLISECONDS
|
|
430
563
|
: readDuration(timeout, "--timeout", { max: 3600, min: 1 }) * 1000;
|
|
431
|
-
|
|
564
|
+
return { deadlineMilliseconds, named, target, wait };
|
|
565
|
+
};
|
|
566
|
+
export const runSessionStart = (tokens, context) => Effect.gen(function* () {
|
|
567
|
+
const { deadlineMilliseconds, named, target, wait } = readStartInput(tokens);
|
|
568
|
+
const { showSession, startSession } = context.dependencies;
|
|
569
|
+
const result = yield* changeAtRevision(named, {
|
|
570
|
+
change: (expectedRevision) => startSession({ ...target, expectedRevision }),
|
|
571
|
+
read: () => showSession(target.sessionId),
|
|
572
|
+
retry: `session start ${target.sessionId}`,
|
|
573
|
+
revisionOf: ({ session }) => ({ ok: true, value: session.revision }),
|
|
574
|
+
});
|
|
432
575
|
if (!wait || !result.ok)
|
|
433
576
|
return writeSessionResult(result, context, (value) => ({
|
|
434
577
|
command: "session.start",
|
|
@@ -436,7 +579,6 @@ export const runSessionStart = (tokens, context) => Effect.gen(function* () {
|
|
|
436
579
|
}));
|
|
437
580
|
return yield* waitUntilRunning(result.value, context, deadlineMilliseconds);
|
|
438
581
|
});
|
|
439
|
-
const RUNNING_DEADLINE_MILLISECONDS = 120_000;
|
|
440
582
|
const EXIT_NOT_RUNNING = 70;
|
|
441
583
|
const EXIT_STILL_STARTING = 74;
|
|
442
584
|
const waitUntilRunning = (started, context, deadlineMilliseconds) => Effect.gen(function* () {
|
|
@@ -462,28 +604,90 @@ const waitUntilRunning = (started, context, deadlineMilliseconds) => Effect.gen(
|
|
|
462
604
|
? EXIT_NOT_RUNNING
|
|
463
605
|
: EXIT_STILL_STARTING;
|
|
464
606
|
});
|
|
607
|
+
const summarizeSessionStop = (result, children) => ({
|
|
608
|
+
command: "session.stop",
|
|
609
|
+
result: {
|
|
610
|
+
...summarizeSessionLifecycle(result),
|
|
611
|
+
...(children === undefined ? {} : { children }),
|
|
612
|
+
},
|
|
613
|
+
});
|
|
614
|
+
const writeChildOutcomes = (output, children, context) => {
|
|
615
|
+
const failed = children.find(({ error }) => error !== undefined)?.error;
|
|
616
|
+
writeSuccess(output, {
|
|
617
|
+
...context,
|
|
618
|
+
...(failed === undefined ? {} : { error: failed, ok: false }),
|
|
619
|
+
}, formatSessionResult);
|
|
620
|
+
return failed === undefined ? 0 : exitCodeOf(failed);
|
|
621
|
+
};
|
|
622
|
+
const supervisionRoute = (context, names = []) => ({
|
|
623
|
+
bindNode: (name) => name === (context.node ?? LOCAL_NODE)
|
|
624
|
+
? context.dependencies
|
|
625
|
+
: (context.bindNode?.(name) ??
|
|
626
|
+
(name === LOCAL_NODE ? context.dependencies : undefined)),
|
|
627
|
+
names,
|
|
628
|
+
node: context.node ?? LOCAL_NODE,
|
|
629
|
+
});
|
|
630
|
+
const subtreeRoute = (context) => Effect.map(everyNodeName(context), (names) => ({
|
|
631
|
+
route: supervisionRoute(context, names.ok ? names.value : []),
|
|
632
|
+
unread: names.ok ? [] : [{ error: names.error, node: LOCAL_NODE }],
|
|
633
|
+
}));
|
|
634
|
+
const withReconcileHint = (result, { flags, input }) => flags.has("--children") &&
|
|
635
|
+
!result.ok &&
|
|
636
|
+
result.error.code === "storage_conflict"
|
|
637
|
+
? {
|
|
638
|
+
...result,
|
|
639
|
+
error: {
|
|
640
|
+
...result.error,
|
|
641
|
+
message: `${result.error.message} Nothing below it was asked. If it has stopped, run 'maia session reconcile ${input.sessionId}' to stop what runs below it.`,
|
|
642
|
+
},
|
|
643
|
+
}
|
|
644
|
+
: result;
|
|
465
645
|
export const runSessionStop = (tokens, context) => Effect.gen(function* () {
|
|
466
|
-
const
|
|
646
|
+
const stop = parseSessionLifecycle("stop", tokens, new Set(["--children"]));
|
|
647
|
+
const { flags, input } = stop;
|
|
467
648
|
const { stopSession } = context.dependencies;
|
|
468
649
|
if (stopSession === undefined)
|
|
469
650
|
throw new CliArgumentError("Session stop is unavailable.");
|
|
470
|
-
const result = yield* stopSession(input);
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
651
|
+
const result = withReconcileHint(yield* stopSession(input), stop);
|
|
652
|
+
if (!flags.has("--children") || !result.ok)
|
|
653
|
+
return writeSessionResult(result, context, (value) => summarizeSessionStop(value));
|
|
654
|
+
const { route, unread } = yield* subtreeRoute(context);
|
|
655
|
+
const children = [
|
|
656
|
+
...unread,
|
|
657
|
+
...(yield* cancelChildren(route, input.sessionId)),
|
|
658
|
+
];
|
|
659
|
+
return writeChildOutcomes(summarizeSessionStop(result.value, children), children, context);
|
|
475
660
|
});
|
|
476
661
|
export const runSessionResume = (tokens, context) => Effect.gen(function* () {
|
|
477
662
|
const { input } = parseSessionLifecycle("resume", tokens);
|
|
478
|
-
const { resumeSession } = context.dependencies;
|
|
663
|
+
const { resumeSession, showSession } = context.dependencies;
|
|
479
664
|
if (resumeSession === undefined)
|
|
480
665
|
throw new CliArgumentError("Session resume is unavailable.");
|
|
481
|
-
const result = yield*
|
|
666
|
+
const result = yield* resumeSupervised(everyNode(context), {
|
|
667
|
+
claim: (child) => readResumeParent(everyNode(context), context.node ?? LOCAL_NODE, child),
|
|
668
|
+
resumeSession,
|
|
669
|
+
showSession,
|
|
670
|
+
}, input);
|
|
482
671
|
return writeSessionResult(result, context, (value) => ({
|
|
483
672
|
command: "session.resume",
|
|
484
673
|
result: summarizeSessionLifecycle(value),
|
|
485
674
|
}));
|
|
486
675
|
});
|
|
676
|
+
export const runSessionReconcile = (tokens, context) => Effect.gen(function* () {
|
|
677
|
+
const { positionals } = parseOptions(tokens, new Set());
|
|
678
|
+
requirePositionals(positionals, 1);
|
|
679
|
+
const sessionId = positionals[0] ?? "";
|
|
680
|
+
const { route, unread } = yield* subtreeRoute(context);
|
|
681
|
+
const result = yield* reconcileChildren(route, sessionId);
|
|
682
|
+
const output = (children) => ({
|
|
683
|
+
command: "session.reconcile",
|
|
684
|
+
result: { children, sessionId },
|
|
685
|
+
});
|
|
686
|
+
if (!result.ok)
|
|
687
|
+
return writeSessionResult(result, context, output);
|
|
688
|
+
const children = [...unread, ...result.value];
|
|
689
|
+
return writeChildOutcomes(output(children), children, context);
|
|
690
|
+
});
|
|
487
691
|
export const runSessionEventsList = (tokens, context) => Effect.gen(function* () {
|
|
488
692
|
const parsed = parseOptions(tokens, new Set(["--after", "--limit", "--session"]));
|
|
489
693
|
requirePositionals(parsed.positionals, 0);
|
|
@@ -665,4 +869,5 @@ export const runSessionInboxAck = (tokens, context) => Effect.gen(function* () {
|
|
|
665
869
|
result: summarizeInboxAck(value),
|
|
666
870
|
}));
|
|
667
871
|
});
|
|
872
|
+
export const runSessionSpawn = (tokens, context) => runSpawn(tokens, { ...context, everyNode: everyNode(context) });
|
|
668
873
|
//# sourceMappingURL=commands.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MAX_SESSION_CREATION_TASKS, MAX_TURN_INPUT_BYTES, } from "@maiaos/sdk";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
import { CliArgumentError, reportError, writeSuccess, } from "../command-line/index.js";
|
|
4
|
+
import { batchError, reportItem, toWorktreeRequest, withCommandId, } from "./creation/index.js";
|
|
4
5
|
import { formatSessionTasks } from "./output/index.js";
|
|
5
6
|
import { readTaskFile } from "./task-file.js";
|
|
6
7
|
const EXIT_OUTCOME_UNKNOWN = 76;
|
|
@@ -27,7 +28,7 @@ const toStartFields = ({ cwd, hostAuthority, permission, }) => ({
|
|
|
27
28
|
...(permission === undefined ? {} : { permission }),
|
|
28
29
|
});
|
|
29
30
|
const toTemplate = (selection) => {
|
|
30
|
-
const { agentId,
|
|
31
|
+
const { agentId, connectionId, effort, executor, labels, model, role, title, } = selection;
|
|
31
32
|
return {
|
|
32
33
|
...(agentId === undefined ? {} : { agentId }),
|
|
33
34
|
...(connectionId === undefined ? {} : { connectionId }),
|
|
@@ -38,7 +39,7 @@ const toTemplate = (selection) => {
|
|
|
38
39
|
...(model === undefined ? {} : { model }),
|
|
39
40
|
...(role === undefined ? {} : { role }),
|
|
40
41
|
...(title === undefined ? {} : { title }),
|
|
41
|
-
...(
|
|
42
|
+
...toWorktreeRequest(selection),
|
|
42
43
|
};
|
|
43
44
|
};
|
|
44
45
|
const toInput = (request, text) => {
|
|
@@ -51,39 +52,6 @@ const toInput = (request, text) => {
|
|
|
51
52
|
...(workspaceId === undefined ? {} : { workspaceId }),
|
|
52
53
|
};
|
|
53
54
|
};
|
|
54
|
-
const reportItem = (plan, outcome) => {
|
|
55
|
-
const commandId = outcome.stage === "unknown" ? outcome.error?.commandId : undefined;
|
|
56
|
-
const { error, index, receipts, sessionId, stage, turnId } = outcome;
|
|
57
|
-
return {
|
|
58
|
-
...(error === undefined ? {} : { error }),
|
|
59
|
-
line: plan.items[index]?.line ?? 0,
|
|
60
|
-
receipts,
|
|
61
|
-
...(commandId === undefined ? {} : { recovery: { commandId } }),
|
|
62
|
-
...(sessionId === undefined ? {} : { sessionId }),
|
|
63
|
-
stage,
|
|
64
|
-
...(turnId === undefined ? {} : { turnId }),
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
const MAX_TASK_COMMAND_ID_LENGTH = 122;
|
|
68
|
-
const withCommandId = (plan, commandId) => {
|
|
69
|
-
if (commandId === undefined)
|
|
70
|
-
return plan;
|
|
71
|
-
if (plan.items.length !== 1)
|
|
72
|
-
throw new CliArgumentError("Option '--command-id' names one Session; the input holds several tasks.");
|
|
73
|
-
if (commandId.length > MAX_TASK_COMMAND_ID_LENGTH)
|
|
74
|
-
throw new CliArgumentError(`Option '--command-id' takes at most ${String(MAX_TASK_COMMAND_ID_LENGTH)} characters with a first message.`);
|
|
75
|
-
return {
|
|
76
|
-
...plan,
|
|
77
|
-
items: plan.items.map((item) => ({
|
|
78
|
-
...item,
|
|
79
|
-
commands: {
|
|
80
|
-
create: commandId,
|
|
81
|
-
send: `${commandId}.send`,
|
|
82
|
-
start: `${commandId}.start`,
|
|
83
|
-
},
|
|
84
|
-
})),
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
55
|
const exitCode = (items) => {
|
|
88
56
|
if (items.some((item) => item.stage === "unknown"))
|
|
89
57
|
return EXIT_OUTCOME_UNKNOWN;
|
|
@@ -91,19 +59,6 @@ const exitCode = (items) => {
|
|
|
91
59
|
? 0
|
|
92
60
|
: EXIT_REFUSED;
|
|
93
61
|
};
|
|
94
|
-
const batchError = (items) => {
|
|
95
|
-
const failed = items.find((item) => item.error !== undefined);
|
|
96
|
-
if (failed?.error === undefined)
|
|
97
|
-
return undefined;
|
|
98
|
-
const { code, failure, kind, message, operationId, retryable } = failed.error;
|
|
99
|
-
return {
|
|
100
|
-
code: failure?.code ?? code ?? kind,
|
|
101
|
-
message: failure?.message ??
|
|
102
|
-
message ??
|
|
103
|
-
`Line ${String(failed.line)} stopped at ${operationId}: ${code ?? kind}.`,
|
|
104
|
-
retryable,
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
62
|
const writeBatch = (plan, outcomes, context) => {
|
|
108
63
|
const items = outcomes.map((outcome) => reportItem(plan, outcome));
|
|
109
64
|
const code = exitCode(items);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CliArgumentError } from "../../command-line/input/index.js";
|
|
2
|
+
export const toWorktreeRequest = ({ baseRef, branch, }) => baseRef === undefined
|
|
3
|
+
? {}
|
|
4
|
+
: { worktree: { baseRef, ...(branch === undefined ? {} : { branch }) } };
|
|
5
|
+
export const reportItem = (plan, outcome) => {
|
|
6
|
+
const commandId = outcome.stage === "unknown" ? outcome.error?.commandId : undefined;
|
|
7
|
+
const { error, index, receipts, sessionId, stage, turnId } = outcome;
|
|
8
|
+
return {
|
|
9
|
+
...(error === undefined ? {} : { error }),
|
|
10
|
+
line: plan.items[index]?.line ?? 0,
|
|
11
|
+
receipts,
|
|
12
|
+
...(commandId === undefined ? {} : { recovery: { commandId } }),
|
|
13
|
+
...(sessionId === undefined ? {} : { sessionId }),
|
|
14
|
+
stage,
|
|
15
|
+
...(turnId === undefined ? {} : { turnId }),
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
const MAX_TASK_COMMAND_ID_LENGTH = 122;
|
|
19
|
+
export const withCommandId = (plan, commandId) => {
|
|
20
|
+
if (commandId === undefined)
|
|
21
|
+
return plan;
|
|
22
|
+
if (plan.items.length !== 1)
|
|
23
|
+
throw new CliArgumentError("Option '--command-id' names one Session; the input holds several tasks.");
|
|
24
|
+
if (commandId.length > MAX_TASK_COMMAND_ID_LENGTH)
|
|
25
|
+
throw new CliArgumentError(`Option '--command-id' takes at most ${String(MAX_TASK_COMMAND_ID_LENGTH)} characters with a first message.`);
|
|
26
|
+
return {
|
|
27
|
+
...plan,
|
|
28
|
+
items: plan.items.map((item) => ({
|
|
29
|
+
...item,
|
|
30
|
+
commands: {
|
|
31
|
+
create: commandId,
|
|
32
|
+
send: `${commandId}.send`,
|
|
33
|
+
start: `${commandId}.start`,
|
|
34
|
+
},
|
|
35
|
+
})),
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export const batchError = (items) => {
|
|
39
|
+
const failed = items.find((item) => item.error !== undefined);
|
|
40
|
+
if (failed?.error === undefined)
|
|
41
|
+
return undefined;
|
|
42
|
+
const { code, failure, kind, message, operationId, retryable } = failed.error;
|
|
43
|
+
return {
|
|
44
|
+
code: failure?.code ?? code ?? kind,
|
|
45
|
+
message: failure?.message ??
|
|
46
|
+
message ??
|
|
47
|
+
`Line ${String(failed.line)} stopped at ${operationId}: ${code ?? kind}.`,
|
|
48
|
+
retryable,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=creation.js.map
|