@maiaos/cli 0.1.0-canary.9 → 0.1.0-canary.90
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 +21 -15
- package/dist/address-space/address-space.js +21 -2
- package/dist/address-space/index.js +1 -1
- package/dist/agents/client.d.ts +48 -27
- package/dist/agents/client.js +10 -3
- package/dist/agents/commands.d.ts +1 -0
- package/dist/agents/commands.js +24 -2
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.js +1 -1
- package/dist/agents/input.js +6 -0
- package/dist/agents/output/format.js +11 -0
- package/dist/agents/tree/tree.js +16 -4
- 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 +11 -3
- package/dist/cli/cli.js +215 -12
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/log-level.d.ts +11 -0
- package/dist/cli/log-level.js +14 -0
- package/dist/command-line/context.d.ts +25 -7
- package/dist/command-line/emit/index.d.ts +4 -0
- package/dist/command-line/emit/index.js +4 -0
- package/dist/command-line/{output.d.ts → emit/output.d.ts} +7 -3
- package/dist/command-line/{output.js → emit/output.js} +13 -5
- package/dist/command-line/{rows.d.ts → emit/rows.d.ts} +2 -0
- package/dist/command-line/{rows.js → emit/rows.js} +6 -0
- package/dist/command-line/index.d.ts +6 -6
- package/dist/command-line/index.js +5 -6
- package/dist/command-line/input/arguments.d.ts +6 -0
- package/dist/command-line/input/arguments.js +20 -0
- package/dist/command-line/input/index.d.ts +3 -2
- package/dist/command-line/input/index.js +3 -2
- package/dist/command-line/input/manager-options.d.ts +10 -0
- package/dist/command-line/input/manager-options.js +38 -0
- 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/index.d.ts +2 -0
- package/dist/command-line/two-phase/index.js +2 -0
- package/dist/command-line/{two-phase.d.ts → two-phase/two-phase.d.ts} +14 -14
- package/dist/command-line/{two-phase.js → two-phase/two-phase.js} +11 -11
- package/dist/command-receipt/command.js +1 -1
- package/dist/command-tree/commands.d.ts +1 -1
- package/dist/command-tree/commands.js +1 -5
- 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 +27 -7
- 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 +35 -4
- package/dist/connection/client.d.ts +72 -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 +4 -4
- package/dist/connection/login.d.ts +1 -1
- package/dist/connection/login.js +4 -3
- package/dist/connection/output/format.js +6 -3
- package/dist/connection/output/index.d.ts +1 -1
- package/dist/connection/output/index.js +1 -1
- package/dist/connection/resolve.d.ts +5 -0
- package/dist/connection/setup-file.js +227 -0
- package/dist/connection/setup-project.js +138 -0
- package/dist/connection/system.js +126 -61
- package/dist/connection/tree/tree.js +179 -10
- package/dist/container/client.d.ts +2 -0
- package/dist/events/commands.js +65 -0
- package/dist/events/index.js +2 -0
- package/dist/events/tree/index.js +2 -0
- package/dist/events/tree/tree.js +17 -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/batch.js +196 -0
- package/dist/import/batch/index.js +3 -0
- package/dist/import/batch/manifest.js +108 -0
- package/dist/import/client.d.ts +3 -3
- package/dist/import/client.js +1 -1
- package/dist/import/commands.d.ts +2 -0
- package/dist/import/commands.js +104 -18
- 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 +68 -11
- package/dist/import/output.js +57 -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 +607 -1
- package/dist/integration/client.js +41 -1
- package/dist/integration/commands.d.ts +16 -0
- package/dist/integration/commands.js +93 -10
- package/dist/integration/index.d.ts +1 -1
- package/dist/integration/index.js +1 -1
- package/dist/local-node/client.d.ts +13 -1
- package/dist/local-node/client.js +191 -235
- package/dist/local-node/index.d.ts +1 -1
- package/dist/local-node/index.js +1 -1
- package/dist/local-node/launch/index.d.ts +2 -0
- package/dist/local-node/launch/index.js +2 -0
- package/dist/local-node/launch/launch.d.ts +19 -0
- package/dist/local-node/launch/launch.js +49 -0
- package/dist/login/commands.js +7 -1
- package/dist/login/gateway.js +36 -13
- package/dist/login/menu.js +2 -1
- package/dist/login/vendor-account.js +3 -2
- package/dist/login/vendor-input.js +5 -4
- package/dist/mcp/calls.js +47 -222
- package/dist/mcp/routing.d.ts +3 -2
- package/dist/mcp/routing.js +39 -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 +13 -0
- package/dist/project-guard/input.js +15 -1
- package/dist/project-guard/output/format.js +5 -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/reference/resolve.js +2 -1
- package/dist/remote-node/client.d.ts +85 -0
- package/dist/remote-node/commands.d.ts +1 -0
- package/dist/remote-node/commands.js +60 -18
- package/dist/remote-node/connector.d.ts +16 -0
- package/dist/remote-node/connector.js +10 -3
- package/dist/remote-node/index.d.ts +1 -1
- package/dist/remote-node/index.js +1 -1
- package/dist/remote-node/lifecycle.js +66 -0
- 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 +26 -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 +47 -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 +9 -5
- package/dist/session/approval/client.js +2 -2
- package/dist/session/approval/commands.d.ts +8 -0
- package/dist/session/approval/commands.js +267 -21
- 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-render.js +6 -0
- package/dist/session/attach.d.ts +1 -1
- package/dist/session/attach.js +7 -2
- package/dist/session/client.d.ts +19 -13
- package/dist/session/client.js +39 -19
- package/dist/session/coding-client.d.ts +2 -0
- package/dist/session/coding-client.js +1 -2
- package/dist/session/coding-commands.js +24 -7
- package/dist/session/command/commands.js +109 -0
- package/dist/session/command/index.js +2 -0
- package/dist/session/commands.d.ts +6 -1
- package/dist/session/commands.js +417 -73
- package/dist/session/create-tasks.js +24 -51
- 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 +64 -10
- package/dist/session/output/tasks.js +68 -7
- 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 +372 -32
- package/dist/session/turn/attachments.js +54 -0
- package/dist/session/turn/client.d.ts +9 -1
- package/dist/session/turn/client.js +20 -1
- package/dist/session/turn/commands.d.ts +8 -1
- package/dist/session/turn/commands.js +253 -36
- package/dist/session/turn/index.d.ts +3 -3
- package/dist/session/turn/index.js +1 -1
- package/dist/session/turn/output.d.ts +34 -2
- package/dist/session/turn/output.js +52 -2
- 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 +21 -3
- package/dist/status/command.js +6 -3
- package/dist/status/doctor.d.ts +5 -1
- package/dist/status/doctor.js +14 -7
- package/dist/status/output/compact.d.ts +3 -0
- package/dist/status/output/compact.js +17 -7
- package/dist/status/output/human.js +25 -0
- package/dist/team-workspace/client.d.ts +1 -0
- package/dist/terminal/control-commands.js +26 -9
- package/dist/terminal/keys.js +62 -0
- package/dist/terminal/output/compact-list.js +3 -0
- package/dist/terminal/output/human.js +2 -2
- package/dist/terminal/tree/tree.js +1 -1
- package/dist/text-input/index.js +2 -0
- package/dist/text-input/text-input.js +35 -0
- package/dist/webhooks/client.d.ts +157 -0
- package/dist/webhooks/client.js +8 -0
- package/dist/webhooks/commands.d.ts +17 -0
- package/dist/webhooks/commands.js +76 -0
- package/dist/webhooks/index.d.ts +3 -0
- package/dist/webhooks/index.js +3 -0
- package/dist/webhooks/input.js +125 -0
- package/dist/webhooks/output/format.js +75 -0
- package/dist/webhooks/output/index.js +2 -0
- package/dist/webhooks/tree/index.js +2 -0
- package/dist/webhooks/tree/tree.js +49 -0
- package/guidance/maia-cli/SKILL.md +1 -1
- package/guidance/maia-node/SKILL.md +54 -0
- package/guidance/maia-orchestration/SKILL.md +1 -2
- package/guidance/maia-sessions/SKILL.md +110 -0
- package/package.json +7 -6
- package/dist/address-space/address-space.d.ts +0 -38
- package/dist/address-space/index.d.ts +0 -2
- package/dist/agents/input.d.ts +0 -130
- package/dist/agents/output/format.d.ts +0 -8
- package/dist/agents/output/index.d.ts +0 -2
- package/dist/agents/tree/index.d.ts +0 -2
- package/dist/agents/tree/tree.d.ts +0 -3
- package/dist/bootstrap/exit.d.ts +0 -14
- package/dist/bootstrap/exit.js +0 -42
- package/dist/bootstrap/index.d.ts +0 -3
- package/dist/bootstrap/index.js +0 -3
- package/dist/bootstrap/process.d.ts +0 -5
- package/dist/bootstrap/process.js +0 -23
- package/dist/bootstrap/run.d.ts +0 -25
- package/dist/bootstrap/run.js +0 -95
- package/dist/bootstrap/stdio.d.ts +0 -4
- package/dist/bootstrap/stdio.js +0 -9
- package/dist/cli/environment.d.ts +0 -8
- package/dist/cli/services.d.ts +0 -4
- package/dist/command-line/context.js +0 -2
- package/dist/command-line/input/stdin-stream.d.ts +0 -4
- package/dist/command-line/json-decoder.d.ts +0 -3
- package/dist/command-receipt/command.d.ts +0 -4
- package/dist/command-receipt/compact-list.d.ts +0 -20
- package/dist/command-receipt/index.d.ts +0 -3
- package/dist/command-tree/completion.d.ts +0 -6
- package/dist/command-tree/local.d.ts +0 -3
- package/dist/command-tree/row.js +0 -2
- package/dist/connection/access/format.d.ts +0 -8
- package/dist/connection/access/input.d.ts +0 -53
- package/dist/connection/input.d.ts +0 -50
- package/dist/connection/signin.d.ts +0 -4
- package/dist/connection/tree/index.d.ts +0 -2
- package/dist/connection/tree/tree.d.ts +0 -3
- package/dist/container/output/format.d.ts +0 -11
- package/dist/container/output/index.d.ts +0 -2
- package/dist/context/client.d.ts +0 -7
- package/dist/context/commands.d.ts +0 -3
- package/dist/context/index.d.ts +0 -3
- package/dist/dashboard/cockpit-client.d.ts +0 -6
- package/dist/dashboard/cockpit-client.js +0 -27
- package/dist/dashboard/cockpits.d.ts +0 -29
- package/dist/dashboard/cockpits.js +0 -65
- package/dist/dashboard/dashboard.d.ts +0 -7
- package/dist/dashboard/draw.d.ts +0 -15
- package/dist/dashboard/frame.d.ts +0 -4
- package/dist/dashboard/index.d.ts +0 -2
- package/dist/dashboard/modes.d.ts +0 -5
- package/dist/dashboard/node-connection.d.ts +0 -15
- package/dist/dashboard/node-connection.js +0 -51
- package/dist/dashboard/pi-tui.d.ts +0 -6
- package/dist/dashboard/status-bar.d.ts +0 -4
- package/dist/dashboard/terminal.d.ts +0 -53
- package/dist/dashboard/tree-model.d.ts +0 -28
- package/dist/dashboard/tree.d.ts +0 -10
- package/dist/development/cli.d.ts +0 -3
- package/dist/development/cli.js +0 -44
- package/dist/execution/tree/index.d.ts +0 -2
- package/dist/execution/tree/tree.d.ts +0 -3
- package/dist/hold/output/format.d.ts +0 -11
- package/dist/hold/output/index.d.ts +0 -2
- package/dist/hold/tree/index.d.ts +0 -2
- package/dist/hold/tree/tree.d.ts +0 -3
- package/dist/import/input.d.ts +0 -16
- package/dist/import/output.d.ts +0 -6
- package/dist/integration/output.d.ts +0 -22
- package/dist/login/failure.d.ts +0 -3
- package/dist/login/gateway.d.ts +0 -12
- package/dist/login/menu.d.ts +0 -4
- package/dist/login/output/format.d.ts +0 -16
- package/dist/login/output/index.d.ts +0 -2
- package/dist/login/vendor-account.d.ts +0 -95
- package/dist/login/vendor-input.d.ts +0 -14
- package/dist/mcp/calls.d.ts +0 -8
- package/dist/orchestration/output/compact-aggregate.d.ts +0 -121
- package/dist/orchestration/output/compact-run-list.d.ts +0 -20
- package/dist/orchestration/output/human.d.ts +0 -80
- package/dist/orchestration/output/index.d.ts +0 -4
- package/dist/orchestration/tree/index.d.ts +0 -2
- package/dist/orchestration/tree/tree.d.ts +0 -3
- package/dist/port-lease/input.d.ts +0 -65
- package/dist/port-lease/output/format.d.ts +0 -11
- package/dist/port-lease/output/index.d.ts +0 -2
- package/dist/presentation/output/format.d.ts +0 -11
- package/dist/presentation/output/index.d.ts +0 -3
- package/dist/project-guard/input.d.ts +0 -18
- package/dist/project-guard/output/format.d.ts +0 -11
- package/dist/project-guard/output/index.d.ts +0 -2
- package/dist/project-workspace/output/human.d.ts +0 -139
- package/dist/project-workspace/output/index.d.ts +0 -3
- package/dist/project-workspace/output/metadata.d.ts +0 -11
- package/dist/project-workspace/tree/index.d.ts +0 -2
- package/dist/project-workspace/tree/tree.d.ts +0 -3
- package/dist/provider/client.d.ts +0 -6
- package/dist/provider/commands.d.ts +0 -3
- package/dist/provider/index.d.ts +0 -3
- package/dist/reference/commands.d.ts +0 -3
- package/dist/reference/index.d.ts +0 -3
- package/dist/reference/resolve.d.ts +0 -31
- package/dist/reference/tree/index.d.ts +0 -2
- package/dist/reference/tree/tree.d.ts +0 -3
- package/dist/remote-node/reachability.d.ts +0 -64
- package/dist/remote-node/text.d.ts +0 -10
- package/dist/remote-node/tree/index.d.ts +0 -2
- package/dist/remote-node/tree/tree.d.ts +0 -3
- package/dist/routine/input.d.ts +0 -28
- package/dist/routine/output/format.d.ts +0 -23
- package/dist/routine/output/index.d.ts +0 -2
- package/dist/routine/tree/index.d.ts +0 -2
- package/dist/routine/tree/tree.d.ts +0 -3
- package/dist/run-ledger/input.d.ts +0 -42
- package/dist/run-ledger/output/format.d.ts +0 -11
- package/dist/run-ledger/output/index.d.ts +0 -2
- package/dist/session/approval/output/format.d.ts +0 -23
- package/dist/session/approval/output/index.d.ts +0 -2
- package/dist/session/attach-render.d.ts +0 -16
- package/dist/session/create-tasks.d.ts +0 -20
- package/dist/session/interaction/input.d.ts +0 -15
- package/dist/session/interaction/output/format.d.ts +0 -11
- package/dist/session/interaction/output/index.d.ts +0 -2
- package/dist/session/output/diff.d.ts +0 -3
- package/dist/session/output/failure.d.ts +0 -11
- package/dist/session/output/human.d.ts +0 -113
- package/dist/session/output/index.d.ts +0 -6
- package/dist/session/output/observe.d.ts +0 -4
- package/dist/session/output/tasks.d.ts +0 -34
- package/dist/session/task-file.d.ts +0 -5
- package/dist/session/tree/index.d.ts +0 -2
- package/dist/session/tree/tree.d.ts +0 -3
- package/dist/team-workspace/ceremony.d.ts +0 -19
- package/dist/team-workspace/confirmation.d.ts +0 -4
- package/dist/team-workspace/dependencies.js +0 -2
- package/dist/team-workspace/output.d.ts +0 -15
- package/dist/terminal/arguments.d.ts +0 -13
- package/dist/terminal/output/compact-list.d.ts +0 -148
- package/dist/terminal/output/human.d.ts +0 -42
- package/dist/terminal/output/index.d.ts +0 -3
- package/dist/terminal/tree/index.d.ts +0 -2
- package/dist/terminal/tree/tree.d.ts +0 -3
- /package/dist/command-line/{json-decoder.js → emit/json-decoder.js} +0 -0
- /package/dist/command-line/{json.d.ts → emit/json.d.ts} +0 -0
- /package/dist/command-line/{json.js → emit/json.js} +0 -0
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
|
+
import { MAX_PROJECT_CONTEXT_NOTE_BODY_BYTES, MAX_TURN_INPUT_BYTES, } from "@maiaos/sdk";
|
|
3
|
+
import { Crypto, Data, Effect } from "effect";
|
|
4
|
+
import { decodeJsonText, exitCodeOf, fields, labelCells, reportError, writeSuccess, } from "../../command-line/emit/index.js";
|
|
5
|
+
import { CliArgumentError, LOCAL_NODE, parseOptions, requirePositionals, } from "../../command-line/input/index.js";
|
|
6
|
+
import { readTwoPhaseMode, runTwoPhase, TWO_PHASE_FLAGS, } from "../../command-line/two-phase/index.js";
|
|
7
|
+
import { batchError, reportItem, withCommandId } from "../creation/index.js";
|
|
8
|
+
class Stopped extends Data.TaggedError("MoveStopped") {
|
|
9
|
+
}
|
|
10
|
+
const utf8 = new TextEncoder();
|
|
11
|
+
const MAX_COMMAND_ID_LENGTH = 120;
|
|
12
|
+
const MOVABLE_STATES = new Set([
|
|
13
|
+
"failed",
|
|
14
|
+
"idle",
|
|
15
|
+
"interrupted",
|
|
16
|
+
"running",
|
|
17
|
+
"stopped",
|
|
18
|
+
]);
|
|
19
|
+
const IN_FLIGHT_TURNS = new Set([
|
|
20
|
+
"dispatching",
|
|
21
|
+
"queued",
|
|
22
|
+
"running",
|
|
23
|
+
]);
|
|
24
|
+
const NO_SUMMARY = "The Session has no final text to carry over; pass '--summary' or '--summary-stdin'.";
|
|
25
|
+
const ok = (value) => ({ ok: true, value });
|
|
26
|
+
const refuse = (message) => new Stopped({
|
|
27
|
+
error: { code: "session_move_refused", message, retryable: false },
|
|
28
|
+
});
|
|
29
|
+
const need = (effect) => Effect.flatMap(effect, (result) => result.ok ? Effect.succeed(result.value) : Effect.fail(new Stopped(result)));
|
|
30
|
+
const stopped = (done) => ({ error, recovery }) => Effect.succeed({ ...done, error, recovery });
|
|
31
|
+
const readTarget = (options) => {
|
|
32
|
+
const projectId = options.get("--project");
|
|
33
|
+
const workspaceId = options.get("--workspace");
|
|
34
|
+
const toNode = options.get("--to-node");
|
|
35
|
+
if (toNode === undefined)
|
|
36
|
+
throw new CliArgumentError("Option '--to-node' names the target Node.");
|
|
37
|
+
if (projectId !== undefined && workspaceId === undefined)
|
|
38
|
+
return { scope: { projectId }, toNode };
|
|
39
|
+
if (workspaceId !== undefined && projectId === undefined)
|
|
40
|
+
return { scope: { workspaceId }, toNode };
|
|
41
|
+
throw new CliArgumentError("Name the target with one of '--project' or '--workspace', an ID on the target Node.");
|
|
42
|
+
};
|
|
43
|
+
const readSummary = (options, flags) => {
|
|
44
|
+
const summary = options.get("--summary");
|
|
45
|
+
const stdin = flags.has("--summary-stdin");
|
|
46
|
+
if (summary !== undefined && stdin)
|
|
47
|
+
throw new CliArgumentError("Use one of '--summary' or '--summary-stdin'.");
|
|
48
|
+
if (summary !== undefined)
|
|
49
|
+
return { from: "option", summary };
|
|
50
|
+
return { from: stdin ? "stdin" : "turn" };
|
|
51
|
+
};
|
|
52
|
+
const OPTIONS = new Set([
|
|
53
|
+
"--command-id",
|
|
54
|
+
"--expected-revision",
|
|
55
|
+
"--project",
|
|
56
|
+
"--summary",
|
|
57
|
+
"--to-node",
|
|
58
|
+
"--workspace",
|
|
59
|
+
]);
|
|
60
|
+
const FLAGS = new Set([...TWO_PHASE_FLAGS, "--no-start", "--summary-stdin"]);
|
|
61
|
+
const readRequest = (tokens, context) => {
|
|
62
|
+
const { flags, options, positionals } = parseOptions(tokens, OPTIONS, FLAGS);
|
|
63
|
+
requirePositionals(positionals, 1);
|
|
64
|
+
const commandId = options.get("--command-id");
|
|
65
|
+
if ((commandId?.length ?? 0) > MAX_COMMAND_ID_LENGTH)
|
|
66
|
+
throw new CliArgumentError(`Option '--command-id' takes at most ${String(MAX_COMMAND_ID_LENGTH)} characters; each step adds a suffix.`);
|
|
67
|
+
const mode = readTwoPhaseMode(flags, context);
|
|
68
|
+
if (mode === "confirm-stdin" && flags.has("--summary-stdin"))
|
|
69
|
+
throw new CliArgumentError("Use one of '--summary-stdin' or '--confirm-stdin'; each reads standard input.");
|
|
70
|
+
return {
|
|
71
|
+
...readSummary(options, flags),
|
|
72
|
+
...readTarget(options),
|
|
73
|
+
commandId,
|
|
74
|
+
expectedRevision: options.get("--expected-revision"),
|
|
75
|
+
mode,
|
|
76
|
+
noStart: flags.has("--no-start"),
|
|
77
|
+
sessionId: positionals[0] ?? "",
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
const labelsOf = (sourceNode, sessionId, noteId) => Object.fromEntries([
|
|
81
|
+
["moved-from-node", sourceNode],
|
|
82
|
+
["moved-from-session", sessionId],
|
|
83
|
+
...(noteId === undefined ? [] : [["moved-seed-note", noteId]]),
|
|
84
|
+
]);
|
|
85
|
+
const seedOf = (sourceNode, { session, summary }) => `Moved from Maia Node ${sourceNode}, Session ${session.id}.\n\n${summary}`;
|
|
86
|
+
const readSummaryStdin = ({ io }) => {
|
|
87
|
+
if (io.stdin === undefined)
|
|
88
|
+
return Effect.fail(new CliArgumentError("Standard input is unavailable."));
|
|
89
|
+
return io.stdin({
|
|
90
|
+
label: "Session summary",
|
|
91
|
+
maxBytes: MAX_TURN_INPUT_BYTES,
|
|
92
|
+
maxChunks: 1024,
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
const summaryOf = (request, session, route) => {
|
|
96
|
+
const { context } = route;
|
|
97
|
+
const { latestTurnId } = session;
|
|
98
|
+
if (request.summary !== undefined)
|
|
99
|
+
return Effect.succeed(request.summary);
|
|
100
|
+
if (request.from === "stdin")
|
|
101
|
+
return readSummaryStdin(context);
|
|
102
|
+
if (latestTurnId === undefined)
|
|
103
|
+
return Effect.fail(refuse(NO_SUMMARY));
|
|
104
|
+
return Effect.flatMap(need(context.dependencies.showTurn(latestTurnId)), ({ turn }) => turn.state === "completed"
|
|
105
|
+
? Effect.succeed(turn.responseText)
|
|
106
|
+
: Effect.fail(refuse(NO_SUMMARY)));
|
|
107
|
+
};
|
|
108
|
+
const unsettled = ({ id, latestTurnState, state, worktree }) => {
|
|
109
|
+
if (!MOVABLE_STATES.has(state))
|
|
110
|
+
return `Session ${id} is ${state}; move it once it settles.`;
|
|
111
|
+
if (worktree !== undefined && worktree.state !== "active")
|
|
112
|
+
return `Session ${id} is archived; it has already moved or ended.`;
|
|
113
|
+
return IN_FLIGHT_TURNS.has(latestTurnState)
|
|
114
|
+
? `Session ${id} has a turn in flight or queued; wait for it or interrupt it first.`
|
|
115
|
+
: undefined;
|
|
116
|
+
};
|
|
117
|
+
const staleRevision = ({ id, revision }, expected) => expected === undefined || expected === revision
|
|
118
|
+
? undefined
|
|
119
|
+
: new Stopped({
|
|
120
|
+
error: {
|
|
121
|
+
code: "storage_conflict",
|
|
122
|
+
message: `Session ${id} is at revision ${revision}, not ${expected}; preview the move again.`,
|
|
123
|
+
retryable: true,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
const archivedBefore = (commandId, route, sessionId) => Effect.flatMap(route.context.dependencies.getReceipt(commandId), (found) => {
|
|
127
|
+
if (found.ok) {
|
|
128
|
+
const { method, target } = found.value.receipt;
|
|
129
|
+
return Effect.succeed(method === "session.archive" && target.id === sessionId);
|
|
130
|
+
}
|
|
131
|
+
return found.error.code === "resource_not_found"
|
|
132
|
+
? Effect.succeed(false)
|
|
133
|
+
: Effect.fail(new Stopped(found));
|
|
134
|
+
});
|
|
135
|
+
const archiveCommandId = (commandId) => `${commandId}.archive`;
|
|
136
|
+
const finishing = (route, sessionId) => archivedBefore(archiveCommandId(route.commandId), route, sessionId);
|
|
137
|
+
const hex = (bytes) => Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
138
|
+
const moveCommandId = ({ request, sourceNode }) => {
|
|
139
|
+
if (request.commandId !== undefined)
|
|
140
|
+
return Effect.succeed(request.commandId);
|
|
141
|
+
const { noStart, scope, sessionId, toNode } = request;
|
|
142
|
+
const identity = JSON.stringify([
|
|
143
|
+
sourceNode,
|
|
144
|
+
sessionId,
|
|
145
|
+
toNode,
|
|
146
|
+
scope,
|
|
147
|
+
noStart,
|
|
148
|
+
]);
|
|
149
|
+
return Effect.flatMap(Crypto.Crypto, (crypto) => Effect.map(Effect.orDie(crypto.digest("SHA-256", utf8.encode(identity))), (digest) => `move-${hex(digest).slice(0, 32)}`));
|
|
150
|
+
};
|
|
151
|
+
const readSource = (route) => Effect.gen(function* () {
|
|
152
|
+
const { context, request, sourceNode } = route;
|
|
153
|
+
const { session } = yield* need(context.dependencies.showSession(request.sessionId));
|
|
154
|
+
const blocked = unsettled(session);
|
|
155
|
+
const refusal = blocked === undefined
|
|
156
|
+
? staleRevision(session, request.expectedRevision)
|
|
157
|
+
: refuse(blocked);
|
|
158
|
+
if (refusal !== undefined && !(yield* finishing(route, session.id)))
|
|
159
|
+
return yield* refusal;
|
|
160
|
+
const summary = (yield* summaryOf(request, session, route)).trim();
|
|
161
|
+
if (summary === "")
|
|
162
|
+
return yield* refuse(NO_SUMMARY);
|
|
163
|
+
const { byteLength } = utf8.encode(seedOf(sourceNode, { session, summary }));
|
|
164
|
+
if (request.noStart && byteLength > MAX_PROJECT_CONTEXT_NOTE_BODY_BYTES)
|
|
165
|
+
return yield* refuse(`The seed is ${String(byteLength)} bytes; a Project context note holds ${String(MAX_PROJECT_CONTEXT_NOTE_BODY_BYTES)}. Pass a shorter '--summary'.`);
|
|
166
|
+
return { session, summary };
|
|
167
|
+
});
|
|
168
|
+
const projectOf = ({ request: { scope }, target }) => "projectId" in scope
|
|
169
|
+
? Effect.succeed(scope.projectId)
|
|
170
|
+
: Effect.map(need(target.showWorkspace(scope.workspaceId)), ({ workspace }) => workspace.projectId);
|
|
171
|
+
const planOf = (route, source) => Effect.gen(function* () {
|
|
172
|
+
const { request, sourceNode, target } = route;
|
|
173
|
+
const { executor, id } = source.session;
|
|
174
|
+
if (target.planSessions === undefined)
|
|
175
|
+
return yield* new CliArgumentError("Session creation is unavailable.");
|
|
176
|
+
const plan = yield* need(target.planSessions({
|
|
177
|
+
...request.scope,
|
|
178
|
+
session: {
|
|
179
|
+
...(executor === undefined ? {} : { executor: executor.kind }),
|
|
180
|
+
labels: labelsOf(sourceNode, id),
|
|
181
|
+
},
|
|
182
|
+
split: "whole",
|
|
183
|
+
text: seedOf(sourceNode, source),
|
|
184
|
+
}));
|
|
185
|
+
if (plan.refusals.length > 0 || plan.items.length !== 1)
|
|
186
|
+
return yield* refuse("The summary does not fit one first message; pass a shorter '--summary'.");
|
|
187
|
+
return plan;
|
|
188
|
+
});
|
|
189
|
+
const readMove = (route) => Effect.gen(function* () {
|
|
190
|
+
const source = yield* readSource(route);
|
|
191
|
+
const projectId = yield* projectOf(route);
|
|
192
|
+
const plan = yield* planOf(route, source);
|
|
193
|
+
return { ...route, ...source, plan, projectId };
|
|
194
|
+
});
|
|
195
|
+
const outcomeFailure = (plan, outcome) => {
|
|
196
|
+
const item = outcome === undefined ? undefined : reportItem(plan, outcome);
|
|
197
|
+
return {
|
|
198
|
+
error: (item === undefined ? undefined : batchError([item])) ?? {
|
|
199
|
+
code: "incomplete",
|
|
200
|
+
message: `The new Session stopped at ${outcome?.stage ?? "an unknown step"}.`,
|
|
201
|
+
retryable: true,
|
|
202
|
+
},
|
|
203
|
+
recovery: item?.recovery,
|
|
204
|
+
sessionId: item?.sessionId,
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
const createUnstarted = ({ commandId, plan, target }) => Effect.gen(function* () {
|
|
208
|
+
if (target.runSessions === undefined)
|
|
209
|
+
return yield* new CliArgumentError("Session creation is unavailable.");
|
|
210
|
+
const [outcome] = yield* need(target.runSessions(withCommandId(plan, commandId), { until: "created" }));
|
|
211
|
+
const first = { archived: false };
|
|
212
|
+
if (outcome?.stage === "created" && outcome.sessionId !== undefined)
|
|
213
|
+
return { ...first, sessionId: outcome.sessionId };
|
|
214
|
+
return { ...first, ...outcomeFailure(plan, outcome) };
|
|
215
|
+
});
|
|
216
|
+
const startSeeded = ({ commandId, plan, target }, done) => Effect.gen(function* () {
|
|
217
|
+
if (target.runSessions === undefined)
|
|
218
|
+
return yield* new CliArgumentError("Session creation is unavailable.");
|
|
219
|
+
const [outcome] = yield* need(target.runSessions(withCommandId(plan, commandId)));
|
|
220
|
+
if (outcome?.stage === "sent")
|
|
221
|
+
return done;
|
|
222
|
+
const { sessionId = done.sessionId, ...failure } = outcomeFailure(plan, outcome);
|
|
223
|
+
return { ...done, ...failure, sessionId };
|
|
224
|
+
});
|
|
225
|
+
const createSeeded = (move) => {
|
|
226
|
+
const { commandId, plan, projectId, session, sourceNode, target } = move;
|
|
227
|
+
return Effect.gen(function* () {
|
|
228
|
+
const { note } = yield* need(target.recordProjectContext({
|
|
229
|
+
body: seedOf(sourceNode, move),
|
|
230
|
+
commandId: `${commandId}.seed`,
|
|
231
|
+
projectId,
|
|
232
|
+
}));
|
|
233
|
+
const seeded = { archived: false, seedNoteId: note.id };
|
|
234
|
+
return yield* need(target.createSession({
|
|
235
|
+
commandId,
|
|
236
|
+
executor: session.executor?.kind,
|
|
237
|
+
labels: labelsOf(sourceNode, session.id, note.id),
|
|
238
|
+
workspaceId: plan.workspaceId,
|
|
239
|
+
})).pipe(Effect.map(({ session: created }) => ({
|
|
240
|
+
...seeded,
|
|
241
|
+
revision: created.revision,
|
|
242
|
+
sessionId: created.id,
|
|
243
|
+
})), Effect.catchTag("MoveStopped", stopped(seeded)));
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
const archiveSource = (move, done, movedId) => {
|
|
247
|
+
const { context, request, session } = move;
|
|
248
|
+
const { archiveSession } = context.dependencies;
|
|
249
|
+
const commandId = archiveCommandId(move.commandId);
|
|
250
|
+
return Effect.gen(function* () {
|
|
251
|
+
if (yield* archivedBefore(commandId, move, session.id))
|
|
252
|
+
return { ...done, archived: true };
|
|
253
|
+
if (archiveSession === undefined)
|
|
254
|
+
return yield* refuse("Archiving a Session is unavailable.");
|
|
255
|
+
const { archive } = yield* need(archiveSession({
|
|
256
|
+
commandId,
|
|
257
|
+
expectedRevision: session.revision,
|
|
258
|
+
sessionId: session.id,
|
|
259
|
+
summary: `Moved to ${request.toNode}:${movedId}`,
|
|
260
|
+
}));
|
|
261
|
+
return { ...done, archived: true, kept: archive };
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
const applyMove = (move) => Effect.gen(function* () {
|
|
265
|
+
const create = move.request.noStart
|
|
266
|
+
? createSeeded
|
|
267
|
+
: createUnstarted;
|
|
268
|
+
const created = yield* create(move).pipe(Effect.catchTag("MoveStopped", stopped({ archived: false })));
|
|
269
|
+
const { error, sessionId } = created;
|
|
270
|
+
if (error !== undefined || sessionId === undefined)
|
|
271
|
+
return created;
|
|
272
|
+
const archived = yield* archiveSource(move, created, sessionId).pipe(Effect.catchTag("MoveStopped", stopped(created)));
|
|
273
|
+
if (archived.error !== undefined || move.request.noStart)
|
|
274
|
+
return archived;
|
|
275
|
+
return yield* startSeeded(move, archived).pipe(Effect.catchTag("MoveStopped", stopped(archived)));
|
|
276
|
+
});
|
|
277
|
+
const CARRIES = "summary";
|
|
278
|
+
const CARRIES_TEXT = "the summary only; no native history and no code moves with it";
|
|
279
|
+
const worktreeOf = ({ worktree }, node) => worktree === undefined ? undefined : { branch: worktree.branch, node };
|
|
280
|
+
const stepsOf = (move, worktree) => {
|
|
281
|
+
const { projectId, request, session, sourceNode } = move;
|
|
282
|
+
const { noStart, toNode } = request;
|
|
283
|
+
return [
|
|
284
|
+
noStart
|
|
285
|
+
? `Record the seed as a context note on Project ${projectId} and create a Session on ${toNode} that starts nothing.`
|
|
286
|
+
: `Create a Session on ${toNode}; it does not start yet.`,
|
|
287
|
+
`Stop and archive ${session.id} on ${sourceNode} with the summary "Moved to ${toNode}:<new Session>".`,
|
|
288
|
+
...(worktree === undefined
|
|
289
|
+
? []
|
|
290
|
+
: [
|
|
291
|
+
`The archive commits any uncommitted work to branch ${worktree.branch} on ${sourceNode}. The branch stays there, is not copied to ${toNode} and is never deleted; the checkout folder is removed later, only once clean.`,
|
|
292
|
+
]),
|
|
293
|
+
...(noStart
|
|
294
|
+
? []
|
|
295
|
+
: [`Start the new Session on ${toNode} and send it the summary.`]),
|
|
296
|
+
];
|
|
297
|
+
};
|
|
298
|
+
const previewOf = (move) => {
|
|
299
|
+
const { plan, projectId, request, session, sourceNode, summary } = move;
|
|
300
|
+
const worktree = worktreeOf(session, sourceNode);
|
|
301
|
+
return {
|
|
302
|
+
carries: CARRIES,
|
|
303
|
+
labels: labelsOf(sourceNode, session.id),
|
|
304
|
+
source: {
|
|
305
|
+
node: sourceNode,
|
|
306
|
+
revision: session.revision,
|
|
307
|
+
sessionId: session.id,
|
|
308
|
+
},
|
|
309
|
+
started: !request.noStart,
|
|
310
|
+
steps: stepsOf(move, worktree),
|
|
311
|
+
summary: { bytes: utf8.encode(summary).byteLength, from: request.from },
|
|
312
|
+
target: { node: request.toNode, projectId, workspaceId: plan.workspaceId },
|
|
313
|
+
...(worktree === undefined ? {} : { worktree }),
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
const laterCommands = (node, done) => {
|
|
317
|
+
const { archived, revision, seedNoteId, sessionId } = done;
|
|
318
|
+
if (!archived || revision === undefined || seedNoteId === undefined)
|
|
319
|
+
return undefined;
|
|
320
|
+
const maia = node === LOCAL_NODE ? "maia" : `maia --node ${node}`;
|
|
321
|
+
return [
|
|
322
|
+
`${maia} session start ${String(sessionId)} --expected-revision ${revision} --wait`,
|
|
323
|
+
`${maia} --json project context show ${seedNoteId} | jq -r .result.result.note.body | ${maia} session turn send --session ${String(sessionId)} --prompt-stdin --wait`,
|
|
324
|
+
];
|
|
325
|
+
};
|
|
326
|
+
const resultOf = (move, done) => {
|
|
327
|
+
const { request, session, sourceNode } = move;
|
|
328
|
+
const { archived, kept, recovery, revision, seedNoteId, sessionId } = done;
|
|
329
|
+
const worktree = worktreeOf(session, sourceNode);
|
|
330
|
+
return {
|
|
331
|
+
archived,
|
|
332
|
+
carries: CARRIES,
|
|
333
|
+
next: laterCommands(request.toNode, done),
|
|
334
|
+
recovery,
|
|
335
|
+
seedNoteId,
|
|
336
|
+
source: { node: sourceNode, sessionId: session.id },
|
|
337
|
+
started: !request.noStart,
|
|
338
|
+
target: { node: request.toNode, revision, sessionId },
|
|
339
|
+
worktree: worktree && {
|
|
340
|
+
...worktree,
|
|
341
|
+
branchRevision: kept?.branchRevision,
|
|
342
|
+
snapshot: kept?.snapshot,
|
|
343
|
+
},
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
const formatPreview = ({ labels, source, steps, summary, target, worktree, }) => `${fields([
|
|
347
|
+
["move", `${source.sessionId} on ${source.node} to ${target.node}`],
|
|
348
|
+
["carries", CARRIES_TEXT],
|
|
349
|
+
["revision", source.revision],
|
|
350
|
+
["project", target.projectId],
|
|
351
|
+
["workspace", target.workspaceId],
|
|
352
|
+
["summary", `${String(summary.bytes)} bytes (${summary.from})`],
|
|
353
|
+
["labels", labelCells(labels)],
|
|
354
|
+
[
|
|
355
|
+
"branch",
|
|
356
|
+
worktree && `${worktree.branch} stays on ${worktree.node}, not copied`,
|
|
357
|
+
],
|
|
358
|
+
])}${steps.map((step, index) => `${String(index + 1)}. ${step}`).join("\n")}\n`;
|
|
359
|
+
const stoppedAt = ({ archived, source, target, }) => {
|
|
360
|
+
const { node, sessionId } = target;
|
|
361
|
+
if (sessionId === undefined)
|
|
362
|
+
return `No Session was created on ${node}; the source is unchanged`;
|
|
363
|
+
return archived
|
|
364
|
+
? `Created ${sessionId} on ${node} and archived the source ${source.sessionId}, but the new Session did not start`
|
|
365
|
+
: `Created ${sessionId} on ${node}, but the source ${source.sessionId} is not archived`;
|
|
366
|
+
};
|
|
367
|
+
const formatResult = (output, error) => {
|
|
368
|
+
const { next, seedNoteId, source, started, target, worktree } = output;
|
|
369
|
+
if (error !== undefined)
|
|
370
|
+
return `${stoppedAt(output)}: ${error.message}\n`;
|
|
371
|
+
const { node, sessionId } = target;
|
|
372
|
+
const moved = `Moved ${source.sessionId} on ${source.node} to ${String(sessionId)} on ${node}${started ? "" : " without a first turn"}; the source is archived.\n${fields([
|
|
373
|
+
["carries", CARRIES_TEXT],
|
|
374
|
+
[
|
|
375
|
+
"branch",
|
|
376
|
+
worktree &&
|
|
377
|
+
`${worktree.branch} stays on ${worktree.node}${worktree.snapshot === "committed" ? ", uncommitted work committed to it" : ""}`,
|
|
378
|
+
],
|
|
379
|
+
])}`;
|
|
380
|
+
if (next === undefined)
|
|
381
|
+
return moved;
|
|
382
|
+
return `${moved}${fields([["seed note", seedNoteId]])}To send it as the first turn, run:\n${next.map((command) => ` ${command}\n`).join("")}The second takes the revision the first prints.\n`;
|
|
383
|
+
};
|
|
384
|
+
const writeOutcome = (move) => (response) => {
|
|
385
|
+
const { context } = move;
|
|
386
|
+
if (!response.ok)
|
|
387
|
+
return reportError(response.error, context);
|
|
388
|
+
const { error } = response.value;
|
|
389
|
+
const failure = error && {
|
|
390
|
+
...error,
|
|
391
|
+
message: `${error.message} Run the same command again to finish.`,
|
|
392
|
+
};
|
|
393
|
+
writeSuccess({ command: "session.move", result: resultOf(move, response.value) }, failure === undefined
|
|
394
|
+
? context
|
|
395
|
+
: { ...context, error: failure, ok: false }, (output) => formatResult(output.result, failure));
|
|
396
|
+
return failure === undefined ? 0 : exitCodeOf(failure);
|
|
397
|
+
};
|
|
398
|
+
const writePreview = (context) => (response) => {
|
|
399
|
+
if (!response.ok)
|
|
400
|
+
return reportError(response.error, context);
|
|
401
|
+
writeSuccess({ command: "session.move.preview", result: response.value }, context, (output) => formatPreview(output.result));
|
|
402
|
+
return 0;
|
|
403
|
+
};
|
|
404
|
+
const STALE_PREVIEW = "The piped preview is not this move's preview now; pipe the output of the same command with '--json --dry-run'.";
|
|
405
|
+
const asPiped = (preview) => decodeJsonText(JSON.stringify(preview), () => new CliArgumentError(STALE_PREVIEW));
|
|
406
|
+
const moveSession = (intent) => {
|
|
407
|
+
const { context, request } = intent;
|
|
408
|
+
return Effect.gen(function* () {
|
|
409
|
+
const route = { ...intent, commandId: yield* moveCommandId(intent) };
|
|
410
|
+
const move = yield* readMove(route);
|
|
411
|
+
const preview = previewOf(move);
|
|
412
|
+
return yield* runTwoPhase({
|
|
413
|
+
confirm: (confirming) => Effect.flatMap(asPiped(preview), (current) => isDeepStrictEqual(confirming, current)
|
|
414
|
+
? Effect.map(applyMove(move), ok)
|
|
415
|
+
: Effect.fail(new CliArgumentError(STALE_PREVIEW))),
|
|
416
|
+
context,
|
|
417
|
+
mode: request.mode,
|
|
418
|
+
preview: () => Effect.succeed(ok(preview)),
|
|
419
|
+
prompt: { describe: formatPreview, question: "Move this Session?" },
|
|
420
|
+
writeConfirm: writeOutcome(move),
|
|
421
|
+
writePreview: writePreview(context),
|
|
422
|
+
});
|
|
423
|
+
}).pipe(Effect.catchTag("MoveStopped", ({ error }) => Effect.sync(() => reportError(error, context))));
|
|
424
|
+
};
|
|
425
|
+
export const runSessionMove = (tokens, context) => {
|
|
426
|
+
const request = readRequest(tokens, context);
|
|
427
|
+
const sourceNode = context.node ?? LOCAL_NODE;
|
|
428
|
+
if (request.toNode === sourceNode)
|
|
429
|
+
throw new CliArgumentError("The target is the Session's own Node; name another Node with '--to-node'.");
|
|
430
|
+
if (context.bindNode === undefined)
|
|
431
|
+
throw new CliArgumentError("Moving a Session to another Node is unavailable here.");
|
|
432
|
+
return moveSession({
|
|
433
|
+
context,
|
|
434
|
+
request,
|
|
435
|
+
sourceNode,
|
|
436
|
+
target: context.bindNode(request.toNode),
|
|
437
|
+
});
|
|
438
|
+
};
|
|
439
|
+
//# sourceMappingURL=move.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { cell, formatRows, tab } from "../../command-line/emit/index.js";
|
|
2
|
+
const HELD_HEADERS = [
|
|
3
|
+
"SESSION",
|
|
4
|
+
"HELD TASK",
|
|
5
|
+
"STATE",
|
|
6
|
+
"CLAIMED",
|
|
7
|
+
"LEASE UNTIL",
|
|
8
|
+
"TITLE",
|
|
9
|
+
];
|
|
10
|
+
const moreLines = (sessions) => sessions
|
|
11
|
+
.filter((session) => (session.heldTaskCount ?? 0) > (session.heldTasks?.length ?? 0))
|
|
12
|
+
.map((session) => `more held by ${session.id}: maia board tasks list --session ${session.id}\n`)
|
|
13
|
+
.join("");
|
|
14
|
+
export const formatHeldTasks = (sessions) => {
|
|
15
|
+
const rows = sessions.flatMap((session) => (session.heldTasks ?? []).map((task) => ({ session: session.id, task })));
|
|
16
|
+
const table = rows.length === 0
|
|
17
|
+
? ""
|
|
18
|
+
: formatRows(rows, ({ session, task }) => tab([
|
|
19
|
+
session,
|
|
20
|
+
task.id,
|
|
21
|
+
task.state,
|
|
22
|
+
task.claimedAt,
|
|
23
|
+
task.leaseExpiresAt,
|
|
24
|
+
cell(task.title),
|
|
25
|
+
]), { empty: "", headers: HELD_HEADERS });
|
|
26
|
+
return `${table}${moreLines(sessions)}`;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=held.js.map
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { cell, fields, formatRows, tab, writeNodeResult, } from "../../command-line/index.js";
|
|
1
|
+
import { cell, fields, formatRows, labelCells, tab, withPrunedHistory, writeNodeResult, } from "../../command-line/index.js";
|
|
2
2
|
import { formatSessionDiff } from "./diff.js";
|
|
3
3
|
import { formatFailure, formatSessionEvents } from "./failure.js";
|
|
4
|
+
import { formatHeldTasks } from "./held.js";
|
|
4
5
|
import { formatSessionObservation } from "./observe.js";
|
|
5
|
-
import { formatSessionList, formatSessionTasks, } from "./tasks.js";
|
|
6
|
+
import { activityLabel, formatSessionList, formatSessionTasks, } from "./tasks.js";
|
|
6
7
|
const formatSessionInbox = (deliveries) => formatRows(deliveries, (delivery) => `${delivery.deliveryId}\t${delivery.sequence}\t${cell(delivery.message.senderSessionId)}\t${cell(delivery.message.subject)}\t${cell(delivery.message.body)}`);
|
|
7
8
|
const formatSessionCreation = (result) => `${fields([
|
|
8
9
|
["session", result.sessionId],
|
|
9
10
|
["account", result.executor?.connectionId],
|
|
11
|
+
["containment", result.containment],
|
|
12
|
+
["permission", result.permission],
|
|
10
13
|
[
|
|
11
14
|
"workspace",
|
|
12
15
|
result.worktree === undefined ? undefined : result.workspaceId,
|
|
@@ -31,20 +34,71 @@ const formatCodingSession = (result) => {
|
|
|
31
34
|
const formatAgentPermission = (result) => result.command === "session.agent-permission.preview"
|
|
32
35
|
? `${result.result.sessionId}\t${result.result.expiresAt}\n`
|
|
33
36
|
: `${result.result.receipt.receiptId}\t${result.result.delivery}\n`;
|
|
34
|
-
|
|
37
|
+
const formatPrompt = (prompt) => prompt === undefined
|
|
38
|
+
? ""
|
|
39
|
+
: `prompt: ${prompt.approvalId}\t${prompt.kind}\texpires=${prompt.expiresAt}\n${(prompt.summary ?? "")
|
|
40
|
+
.split("\n")
|
|
41
|
+
.map((line) => ` ${line}`)
|
|
42
|
+
.join("\n")}\n${(prompt.options ?? [])
|
|
43
|
+
.map((option) => ` ${option.optionId}\t${option.label}\n`)
|
|
44
|
+
.join("")}`;
|
|
45
|
+
const formatRemoteChild = ({ node, observedState, orphanedAt, sessionId, state, }) => `${tab([
|
|
46
|
+
"child",
|
|
47
|
+
node,
|
|
48
|
+
sessionId,
|
|
49
|
+
state === "orphaned"
|
|
50
|
+
? `orphaned since ${orphanedAt ?? "-"}`
|
|
51
|
+
: (observedState ?? state),
|
|
52
|
+
])}\n`;
|
|
53
|
+
export const formatSessionShow = ({ remoteChildren = [], session, }) => `${fields([
|
|
35
54
|
["session", session.id],
|
|
36
55
|
["state", session.state],
|
|
56
|
+
...(session.status === undefined
|
|
57
|
+
? []
|
|
58
|
+
: [["status", session.status]]),
|
|
59
|
+
...(session.activity === undefined
|
|
60
|
+
? []
|
|
61
|
+
: [["activity", activityLabel(session)]]),
|
|
62
|
+
...(session.latestTurnState === undefined
|
|
63
|
+
? []
|
|
64
|
+
: [["latest-turn", session.latestTurnState]]),
|
|
37
65
|
["revision", session.revision],
|
|
38
66
|
["workspace", session.workspaceId],
|
|
39
|
-
|
|
40
|
-
|
|
67
|
+
["containment", session.containment],
|
|
68
|
+
["permission", session.permission],
|
|
69
|
+
[
|
|
70
|
+
"labels",
|
|
71
|
+
session.labels === undefined ? undefined : labelCells(session.labels),
|
|
72
|
+
],
|
|
73
|
+
["updated", session.updatedAt],
|
|
74
|
+
["held-tasks", session.heldTaskCount?.toString()],
|
|
75
|
+
])}${formatHeldTasks([session])}${formatPrompt(session.prompt)}${formatFailure(session.failure)}${formatFailure(session.recovery, "recovering")}${remoteChildren.map(formatRemoteChild).join("")}`;
|
|
76
|
+
const formatChildStop = ({ error, node, orphanedAt, sessionId, state, }) => `${tab([
|
|
77
|
+
"child",
|
|
78
|
+
node,
|
|
79
|
+
sessionId ?? "-",
|
|
80
|
+
error === undefined
|
|
81
|
+
? (state ?? "-")
|
|
82
|
+
: `${orphanedAt === undefined ? "not stopped" : `orphaned since ${orphanedAt}`}: ${cell(error.message)}`,
|
|
83
|
+
])}\n`;
|
|
84
|
+
const formatLifecycle = ({ children = [], revision, sessionId, state, }) => `${fields([
|
|
41
85
|
["session", sessionId],
|
|
42
86
|
["state", state],
|
|
43
87
|
["revision", revision],
|
|
44
|
-
])}${state === "starting" ? `next: maia session start ${sessionId} --expected-revision ${revision} --wait returns once it runs; maia session show ${sessionId} shows it now\n` : ""}`;
|
|
88
|
+
])}${children.map(formatChildStop).join("")}${state === "starting" ? `next: maia session start ${sessionId} --expected-revision ${revision} --wait returns once it runs; maia session show ${sessionId} shows it now\n` : ""}`;
|
|
45
89
|
const formatSessions = (result) => result.items.length === 0 ? "No Sessions.\n" : formatSessionList(result);
|
|
46
90
|
const formatInboxAck = ({ delivery, deliveryRecord, mailboxRevision, }) => `${tab([deliveryRecord.deliveryId, delivery, mailboxRevision])}\n`;
|
|
47
91
|
const formatMessageSend = ({ delivery, deliveryId, sequence, }) => `${tab([deliveryId, delivery, sequence])}\n`;
|
|
92
|
+
const formatEventsPage = ({ items, oldestRetainedCursor, }) => withPrunedHistory(formatSessionEvents(items), oldestRetainedCursor !== undefined);
|
|
93
|
+
const formatParent = (result) => result.command === "session.show"
|
|
94
|
+
? formatSessionShow(result.result)
|
|
95
|
+
: formatReconcile(result.result);
|
|
96
|
+
const formatInbox = (result) => result.command === "session.inbox.ack"
|
|
97
|
+
? formatInboxAck(result.result)
|
|
98
|
+
: formatSessionInbox(result.result.deliveries);
|
|
99
|
+
const formatReconcile = ({ children, sessionId, }) => children.length === 0
|
|
100
|
+
? `Nothing to reconcile below ${sessionId}.\n`
|
|
101
|
+
: children.map(formatChildStop).join("");
|
|
48
102
|
export const formatSessionResult = (result) => {
|
|
49
103
|
switch (result.command) {
|
|
50
104
|
case "session.agent-permission.confirm":
|
|
@@ -56,19 +110,19 @@ export const formatSessionResult = (result) => {
|
|
|
56
110
|
case "session.diff":
|
|
57
111
|
return formatCodingSession(result);
|
|
58
112
|
case "session.events.list":
|
|
59
|
-
return
|
|
113
|
+
return formatEventsPage(result.result);
|
|
60
114
|
case "session.inbox.ack":
|
|
61
|
-
return formatInboxAck(result.result);
|
|
62
115
|
case "session.inbox.check":
|
|
63
|
-
return
|
|
116
|
+
return formatInbox(result);
|
|
64
117
|
case "session.list":
|
|
65
118
|
return formatSessions(result.result);
|
|
66
119
|
case "session.message.send":
|
|
67
120
|
return formatMessageSend(result.result);
|
|
68
121
|
case "session.observe":
|
|
69
122
|
return formatSessionObservation(result.result);
|
|
123
|
+
case "session.reconcile":
|
|
70
124
|
case "session.show":
|
|
71
|
-
return
|
|
125
|
+
return formatParent(result);
|
|
72
126
|
case "session.resume":
|
|
73
127
|
case "session.start":
|
|
74
128
|
case "session.stop":
|