@maiaos/cli 0.1.0-canary.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -0
- package/dist/address-space/address-space.d.ts +38 -0
- package/dist/address-space/address-space.js +130 -0
- package/dist/address-space/index.d.ts +2 -0
- package/dist/address-space/index.js +2 -0
- package/dist/agents/client.d.ts +171 -0
- package/dist/agents/client.js +8 -0
- package/dist/agents/commands.d.ts +7 -0
- package/dist/agents/commands.js +65 -0
- package/dist/agents/index.d.ts +3 -0
- package/dist/agents/index.js +3 -0
- package/dist/agents/input.d.ts +130 -0
- package/dist/agents/input.js +99 -0
- package/dist/agents/output/format.d.ts +8 -0
- package/dist/agents/output/format.js +47 -0
- package/dist/agents/output/index.d.ts +2 -0
- package/dist/agents/output/index.js +2 -0
- package/dist/agents/tree/index.d.ts +2 -0
- package/dist/agents/tree/index.js +2 -0
- package/dist/agents/tree/tree.d.ts +3 -0
- package/dist/agents/tree/tree.js +43 -0
- package/dist/bin/maia.NOTICES.txt +59 -0
- package/dist/bin/maia.cdx.json +168 -0
- package/dist/bin/maia.mjs +2 -0
- package/dist/bootstrap/exit.d.ts +14 -0
- package/dist/bootstrap/exit.js +42 -0
- package/dist/bootstrap/index.d.ts +3 -0
- package/dist/bootstrap/index.js +3 -0
- package/dist/bootstrap/process.d.ts +5 -0
- package/dist/bootstrap/process.js +23 -0
- package/dist/bootstrap/run.d.ts +25 -0
- package/dist/bootstrap/run.js +95 -0
- package/dist/bootstrap/stdio.d.ts +4 -0
- package/dist/bootstrap/stdio.js +9 -0
- package/dist/cli/cli.d.ts +17 -0
- package/dist/cli/cli.js +545 -0
- package/dist/cli/environment.d.ts +8 -0
- package/dist/cli/environment.js +12 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/services.d.ts +4 -0
- package/dist/cli/services.js +4 -0
- package/dist/command-line/context.d.ts +188 -0
- package/dist/command-line/context.js +2 -0
- package/dist/command-line/index.d.ts +7 -0
- package/dist/command-line/index.js +7 -0
- package/dist/command-line/input/arguments.d.ts +62 -0
- package/dist/command-line/input/arguments.js +232 -0
- package/dist/command-line/input/index.d.ts +4 -0
- package/dist/command-line/input/index.js +4 -0
- package/dist/command-line/input/prompt.d.ts +8 -0
- package/dist/command-line/input/prompt.js +44 -0
- package/dist/command-line/input/stdin-stream.d.ts +4 -0
- package/dist/command-line/input/stdin-stream.js +3 -0
- package/dist/command-line/input/stdin.d.ts +12 -0
- package/dist/command-line/input/stdin.js +24 -0
- package/dist/command-line/json-decoder.d.ts +3 -0
- package/dist/command-line/json-decoder.js +3 -0
- package/dist/command-line/json.d.ts +4 -0
- package/dist/command-line/json.js +27 -0
- package/dist/command-line/output.d.ts +64 -0
- package/dist/command-line/output.js +113 -0
- package/dist/command-line/rows.d.ts +12 -0
- package/dist/command-line/rows.js +41 -0
- package/dist/command-line/two-phase.d.ts +62 -0
- package/dist/command-line/two-phase.js +173 -0
- package/dist/command-receipt/command.d.ts +4 -0
- package/dist/command-receipt/command.js +59 -0
- package/dist/command-receipt/compact-list.d.ts +20 -0
- package/dist/command-receipt/compact-list.js +29 -0
- package/dist/command-receipt/index.d.ts +3 -0
- package/dist/command-receipt/index.js +3 -0
- package/dist/command-tree/commands.d.ts +17 -0
- package/dist/command-tree/commands.js +41 -0
- package/dist/command-tree/completion.d.ts +6 -0
- package/dist/command-tree/completion.js +36 -0
- package/dist/command-tree/grammar.d.ts +18 -0
- package/dist/command-tree/grammar.js +160 -0
- package/dist/command-tree/help.d.ts +62 -0
- package/dist/command-tree/help.js +220 -0
- package/dist/command-tree/index.d.ts +8 -0
- package/dist/command-tree/index.js +6 -0
- package/dist/command-tree/local.d.ts +3 -0
- package/dist/command-tree/local.js +138 -0
- package/dist/command-tree/placeholder.d.ts +4 -0
- package/dist/command-tree/placeholder.js +5 -0
- package/dist/command-tree/row.d.ts +31 -0
- package/dist/command-tree/row.js +2 -0
- package/dist/command-tree/suggest.d.ts +3 -0
- package/dist/command-tree/suggest.js +81 -0
- package/dist/command-tree/tree.d.ts +35 -0
- package/dist/command-tree/tree.js +140 -0
- package/dist/connection/access/client.d.ts +13 -0
- package/dist/connection/access/client.js +19 -0
- package/dist/connection/access/commands.d.ts +6 -0
- package/dist/connection/access/commands.js +60 -0
- package/dist/connection/access/format.d.ts +8 -0
- package/dist/connection/access/format.js +61 -0
- package/dist/connection/access/index.d.ts +3 -0
- package/dist/connection/access/index.js +3 -0
- package/dist/connection/access/input.d.ts +53 -0
- package/dist/connection/access/input.js +83 -0
- package/dist/connection/client.d.ts +790 -0
- package/dist/connection/client.js +36 -0
- package/dist/connection/commands.d.ts +15 -0
- package/dist/connection/commands.js +118 -0
- package/dist/connection/index.d.ts +8 -0
- package/dist/connection/index.js +8 -0
- package/dist/connection/input.d.ts +50 -0
- package/dist/connection/input.js +90 -0
- package/dist/connection/login.d.ts +13 -0
- package/dist/connection/login.js +69 -0
- package/dist/connection/output/format.d.ts +32 -0
- package/dist/connection/output/format.js +94 -0
- package/dist/connection/output/index.d.ts +2 -0
- package/dist/connection/output/index.js +2 -0
- package/dist/connection/resolve.d.ts +60 -0
- package/dist/connection/resolve.js +30 -0
- package/dist/connection/signin.d.ts +4 -0
- package/dist/connection/signin.js +32 -0
- package/dist/connection/system.d.ts +5 -0
- package/dist/connection/system.js +294 -0
- package/dist/connection/tree/index.d.ts +2 -0
- package/dist/connection/tree/index.js +2 -0
- package/dist/connection/tree/tree.d.ts +3 -0
- package/dist/connection/tree/tree.js +260 -0
- package/dist/container/client.d.ts +142 -0
- package/dist/container/client.js +11 -0
- package/dist/container/commands.d.ts +7 -0
- package/dist/container/commands.js +100 -0
- package/dist/container/index.d.ts +3 -0
- package/dist/container/index.js +3 -0
- package/dist/container/output/format.d.ts +11 -0
- package/dist/container/output/format.js +27 -0
- package/dist/container/output/index.d.ts +2 -0
- package/dist/container/output/index.js +2 -0
- package/dist/context/client.d.ts +7 -0
- package/dist/context/client.js +21 -0
- package/dist/context/commands.d.ts +3 -0
- package/dist/context/commands.js +27 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/index.js +3 -0
- package/dist/dashboard/cockpit-client.d.ts +6 -0
- package/dist/dashboard/cockpit-client.js +27 -0
- package/dist/dashboard/cockpits.d.ts +29 -0
- package/dist/dashboard/cockpits.js +65 -0
- package/dist/dashboard/dashboard.d.ts +7 -0
- package/dist/dashboard/dashboard.js +47 -0
- package/dist/dashboard/draw.d.ts +15 -0
- package/dist/dashboard/draw.js +30 -0
- package/dist/dashboard/frame.d.ts +4 -0
- package/dist/dashboard/frame.js +15 -0
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.js +2 -0
- package/dist/dashboard/modes.d.ts +5 -0
- package/dist/dashboard/modes.js +16 -0
- package/dist/dashboard/node-connection.d.ts +15 -0
- package/dist/dashboard/node-connection.js +51 -0
- package/dist/dashboard/pi-tui.d.ts +6 -0
- package/dist/dashboard/pi-tui.js +35 -0
- package/dist/dashboard/status-bar.d.ts +4 -0
- package/dist/dashboard/status-bar.js +60 -0
- package/dist/dashboard/terminal.d.ts +53 -0
- package/dist/dashboard/terminal.js +165 -0
- package/dist/dashboard/tree-model.d.ts +28 -0
- package/dist/dashboard/tree-model.js +97 -0
- package/dist/dashboard/tree.d.ts +10 -0
- package/dist/dashboard/tree.js +76 -0
- package/dist/development/cli.d.ts +3 -0
- package/dist/development/cli.js +44 -0
- package/dist/execution/client.d.ts +25 -0
- package/dist/execution/client.js +24 -0
- package/dist/execution/index.d.ts +3 -0
- package/dist/execution/index.js +3 -0
- package/dist/execution/relocation.d.ts +6 -0
- package/dist/execution/relocation.js +123 -0
- package/dist/execution/tree/index.d.ts +2 -0
- package/dist/execution/tree/index.js +2 -0
- package/dist/execution/tree/tree.d.ts +3 -0
- package/dist/execution/tree/tree.js +137 -0
- package/dist/fleet/fleet.d.ts +70 -0
- package/dist/fleet/fleet.js +91 -0
- package/dist/fleet/index.d.ts +2 -0
- package/dist/fleet/index.js +2 -0
- package/dist/hold/client.d.ts +137 -0
- package/dist/hold/client.js +12 -0
- package/dist/hold/commands.d.ts +5 -0
- package/dist/hold/commands.js +91 -0
- package/dist/hold/index.d.ts +3 -0
- package/dist/hold/index.js +3 -0
- package/dist/hold/output/format.d.ts +11 -0
- package/dist/hold/output/format.js +25 -0
- package/dist/hold/output/index.d.ts +2 -0
- package/dist/hold/output/index.js +2 -0
- package/dist/hold/tree/index.d.ts +2 -0
- package/dist/hold/tree/index.js +2 -0
- package/dist/hold/tree/tree.d.ts +3 -0
- package/dist/hold/tree/tree.js +97 -0
- package/dist/import/client.d.ts +14 -0
- package/dist/import/client.js +16 -0
- package/dist/import/commands.d.ts +5 -0
- package/dist/import/commands.js +75 -0
- package/dist/import/index.d.ts +3 -0
- package/dist/import/index.js +3 -0
- package/dist/import/input.d.ts +16 -0
- package/dist/import/input.js +92 -0
- package/dist/import/output.d.ts +6 -0
- package/dist/import/output.js +37 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/integration/client.d.ts +1284 -0
- package/dist/integration/client.js +24 -0
- package/dist/integration/commands.d.ts +10 -0
- package/dist/integration/commands.js +104 -0
- package/dist/integration/index.d.ts +3 -0
- package/dist/integration/index.js +3 -0
- package/dist/integration/output.d.ts +22 -0
- package/dist/integration/output.js +20 -0
- package/dist/local-node/call.d.ts +7 -0
- package/dist/local-node/call.js +13 -0
- package/dist/local-node/client.d.ts +72 -0
- package/dist/local-node/client.js +253 -0
- package/dist/local-node/index.d.ts +4 -0
- package/dist/local-node/index.js +4 -0
- package/dist/local-node/wait.d.ts +10 -0
- package/dist/local-node/wait.js +17 -0
- package/dist/login/agent-provider.d.ts +20 -0
- package/dist/login/agent-provider.js +109 -0
- package/dist/login/commands.d.ts +4 -0
- package/dist/login/commands.js +94 -0
- package/dist/login/failure.d.ts +3 -0
- package/dist/login/failure.js +14 -0
- package/dist/login/gateway.d.ts +12 -0
- package/dist/login/gateway.js +71 -0
- package/dist/login/index.d.ts +3 -0
- package/dist/login/index.js +2 -0
- package/dist/login/menu.d.ts +4 -0
- package/dist/login/menu.js +105 -0
- package/dist/login/output/format.d.ts +16 -0
- package/dist/login/output/format.js +31 -0
- package/dist/login/output/index.d.ts +2 -0
- package/dist/login/output/index.js +2 -0
- package/dist/login/vendor-account.d.ts +95 -0
- package/dist/login/vendor-account.js +75 -0
- package/dist/login/vendor-input.d.ts +14 -0
- package/dist/login/vendor-input.js +36 -0
- package/dist/mcp/calls.d.ts +8 -0
- package/dist/mcp/calls.js +236 -0
- package/dist/mcp/commands.d.ts +12 -0
- package/dist/mcp/commands.js +47 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +2 -0
- package/dist/mcp/routing.d.ts +24 -0
- package/dist/mcp/routing.js +188 -0
- package/dist/mcp/server.d.ts +20 -0
- package/dist/mcp/server.js +80 -0
- package/dist/orchestration/client.d.ts +78 -0
- package/dist/orchestration/client.js +89 -0
- package/dist/orchestration/commands.d.ts +14 -0
- package/dist/orchestration/commands.js +312 -0
- package/dist/orchestration/index.d.ts +3 -0
- package/dist/orchestration/index.js +3 -0
- package/dist/orchestration/output/compact-aggregate.d.ts +121 -0
- package/dist/orchestration/output/compact-aggregate.js +110 -0
- package/dist/orchestration/output/compact-run-list.d.ts +20 -0
- package/dist/orchestration/output/compact-run-list.js +16 -0
- package/dist/orchestration/output/human.d.ts +80 -0
- package/dist/orchestration/output/human.js +252 -0
- package/dist/orchestration/output/index.d.ts +4 -0
- package/dist/orchestration/output/index.js +4 -0
- package/dist/orchestration/tree/index.d.ts +2 -0
- package/dist/orchestration/tree/index.js +2 -0
- package/dist/orchestration/tree/tree.d.ts +3 -0
- package/dist/orchestration/tree/tree.js +142 -0
- package/dist/port-lease/client.d.ts +160 -0
- package/dist/port-lease/client.js +11 -0
- package/dist/port-lease/commands.d.ts +6 -0
- package/dist/port-lease/commands.js +17 -0
- package/dist/port-lease/index.d.ts +3 -0
- package/dist/port-lease/index.js +3 -0
- package/dist/port-lease/input.d.ts +65 -0
- package/dist/port-lease/input.js +67 -0
- package/dist/port-lease/output/format.d.ts +11 -0
- package/dist/port-lease/output/format.js +24 -0
- package/dist/port-lease/output/index.d.ts +2 -0
- package/dist/port-lease/output/index.js +2 -0
- package/dist/presentation/client.d.ts +10 -0
- package/dist/presentation/client.js +9 -0
- package/dist/presentation/commands.d.ts +6 -0
- package/dist/presentation/commands.js +78 -0
- package/dist/presentation/index.d.ts +4 -0
- package/dist/presentation/index.js +3 -0
- package/dist/presentation/output/format.d.ts +11 -0
- package/dist/presentation/output/format.js +33 -0
- package/dist/presentation/output/index.d.ts +3 -0
- package/dist/presentation/output/index.js +2 -0
- package/dist/project-guard/client.d.ts +88 -0
- package/dist/project-guard/client.js +7 -0
- package/dist/project-guard/commands.d.ts +4 -0
- package/dist/project-guard/commands.js +48 -0
- package/dist/project-guard/index.d.ts +3 -0
- package/dist/project-guard/index.js +3 -0
- package/dist/project-guard/input.d.ts +18 -0
- package/dist/project-guard/input.js +47 -0
- package/dist/project-guard/output/format.d.ts +11 -0
- package/dist/project-guard/output/format.js +35 -0
- package/dist/project-guard/output/index.d.ts +2 -0
- package/dist/project-guard/output/index.js +2 -0
- package/dist/project-workspace/client.d.ts +86 -0
- package/dist/project-workspace/client.js +159 -0
- package/dist/project-workspace/commands.d.ts +30 -0
- package/dist/project-workspace/commands.js +710 -0
- package/dist/project-workspace/index.d.ts +5 -0
- package/dist/project-workspace/index.js +5 -0
- package/dist/project-workspace/metadata-client.d.ts +99 -0
- package/dist/project-workspace/metadata-client.js +8 -0
- package/dist/project-workspace/metadata-commands.d.ts +4 -0
- package/dist/project-workspace/metadata-commands.js +56 -0
- package/dist/project-workspace/output/human.d.ts +139 -0
- package/dist/project-workspace/output/human.js +115 -0
- package/dist/project-workspace/output/index.d.ts +3 -0
- package/dist/project-workspace/output/index.js +3 -0
- package/dist/project-workspace/output/metadata.d.ts +11 -0
- package/dist/project-workspace/output/metadata.js +17 -0
- package/dist/project-workspace/tree/index.d.ts +2 -0
- package/dist/project-workspace/tree/index.js +2 -0
- package/dist/project-workspace/tree/tree.d.ts +3 -0
- package/dist/project-workspace/tree/tree.js +212 -0
- package/dist/provider/client.d.ts +6 -0
- package/dist/provider/client.js +5 -0
- package/dist/provider/commands.d.ts +3 -0
- package/dist/provider/commands.js +38 -0
- package/dist/provider/index.d.ts +3 -0
- package/dist/provider/index.js +3 -0
- package/dist/reference/commands.d.ts +3 -0
- package/dist/reference/commands.js +41 -0
- package/dist/reference/index.d.ts +3 -0
- package/dist/reference/index.js +3 -0
- package/dist/reference/resolve.d.ts +31 -0
- package/dist/reference/resolve.js +304 -0
- package/dist/reference/tree/index.d.ts +2 -0
- package/dist/reference/tree/index.js +2 -0
- package/dist/reference/tree/tree.d.ts +3 -0
- package/dist/reference/tree/tree.js +17 -0
- package/dist/remote-node/client.d.ts +338 -0
- package/dist/remote-node/client.js +17 -0
- package/dist/remote-node/commands.d.ts +15 -0
- package/dist/remote-node/commands.js +342 -0
- package/dist/remote-node/connector.d.ts +67 -0
- package/dist/remote-node/connector.js +143 -0
- package/dist/remote-node/index.d.ts +4 -0
- package/dist/remote-node/index.js +4 -0
- package/dist/remote-node/reachability.d.ts +64 -0
- package/dist/remote-node/reachability.js +44 -0
- package/dist/remote-node/text.d.ts +10 -0
- package/dist/remote-node/text.js +111 -0
- package/dist/remote-node/tree/index.d.ts +2 -0
- package/dist/remote-node/tree/index.js +2 -0
- package/dist/remote-node/tree/tree.d.ts +3 -0
- package/dist/remote-node/tree/tree.js +71 -0
- package/dist/routine/client.d.ts +398 -0
- package/dist/routine/client.js +28 -0
- package/dist/routine/commands.d.ts +9 -0
- package/dist/routine/commands.js +109 -0
- package/dist/routine/index.d.ts +3 -0
- package/dist/routine/index.js +3 -0
- package/dist/routine/input.d.ts +28 -0
- package/dist/routine/input.js +44 -0
- package/dist/routine/output/format.d.ts +23 -0
- package/dist/routine/output/format.js +83 -0
- package/dist/routine/output/index.d.ts +2 -0
- package/dist/routine/output/index.js +2 -0
- package/dist/routine/tree/index.d.ts +2 -0
- package/dist/routine/tree/index.js +2 -0
- package/dist/routine/tree/tree.d.ts +3 -0
- package/dist/routine/tree/tree.js +70 -0
- package/dist/run-ledger/client.d.ts +358 -0
- package/dist/run-ledger/client.js +13 -0
- package/dist/run-ledger/commands.d.ts +8 -0
- package/dist/run-ledger/commands.js +19 -0
- package/dist/run-ledger/index.d.ts +3 -0
- package/dist/run-ledger/index.js +3 -0
- package/dist/run-ledger/input.d.ts +42 -0
- package/dist/run-ledger/input.js +107 -0
- package/dist/run-ledger/output/format.d.ts +11 -0
- package/dist/run-ledger/output/format.js +49 -0
- package/dist/run-ledger/output/index.d.ts +2 -0
- package/dist/run-ledger/output/index.js +2 -0
- package/dist/session/agent-permission.d.ts +63 -0
- package/dist/session/agent-permission.js +20 -0
- package/dist/session/approval/client.d.ts +117 -0
- package/dist/session/approval/client.js +7 -0
- package/dist/session/approval/commands.d.ts +7 -0
- package/dist/session/approval/commands.js +145 -0
- package/dist/session/approval/index.d.ts +3 -0
- package/dist/session/approval/index.js +3 -0
- package/dist/session/approval/output/format.d.ts +23 -0
- package/dist/session/approval/output/format.js +33 -0
- package/dist/session/approval/output/index.d.ts +2 -0
- package/dist/session/approval/output/index.js +2 -0
- package/dist/session/attach-client.d.ts +16 -0
- package/dist/session/attach-client.js +17 -0
- package/dist/session/attach-render.d.ts +16 -0
- package/dist/session/attach-render.js +162 -0
- package/dist/session/attach.d.ts +5 -0
- package/dist/session/attach.js +120 -0
- package/dist/session/client.d.ts +140 -0
- package/dist/session/client.js +129 -0
- package/dist/session/coding-client.d.ts +16 -0
- package/dist/session/coding-client.js +15 -0
- package/dist/session/coding-commands.d.ts +4 -0
- package/dist/session/coding-commands.js +50 -0
- package/dist/session/commands.d.ts +14 -0
- package/dist/session/commands.js +585 -0
- package/dist/session/create-tasks.d.ts +20 -0
- package/dist/session/create-tasks.js +128 -0
- package/dist/session/index.d.ts +9 -0
- package/dist/session/index.js +8 -0
- package/dist/session/interaction/client.d.ts +347 -0
- package/dist/session/interaction/client.js +15 -0
- package/dist/session/interaction/commands.d.ts +7 -0
- package/dist/session/interaction/commands.js +101 -0
- package/dist/session/interaction/index.d.ts +3 -0
- package/dist/session/interaction/index.js +3 -0
- package/dist/session/interaction/input.d.ts +15 -0
- package/dist/session/interaction/input.js +46 -0
- package/dist/session/interaction/output/format.d.ts +11 -0
- package/dist/session/interaction/output/format.js +4 -0
- package/dist/session/interaction/output/index.d.ts +2 -0
- package/dist/session/interaction/output/index.js +2 -0
- package/dist/session/output/diff.d.ts +3 -0
- package/dist/session/output/diff.js +23 -0
- package/dist/session/output/failure.d.ts +11 -0
- package/dist/session/output/failure.js +17 -0
- package/dist/session/output/human.d.ts +113 -0
- package/dist/session/output/human.js +82 -0
- package/dist/session/output/index.d.ts +6 -0
- package/dist/session/output/index.js +6 -0
- package/dist/session/output/observe.d.ts +4 -0
- package/dist/session/output/observe.js +46 -0
- package/dist/session/output/tasks.d.ts +34 -0
- package/dist/session/output/tasks.js +48 -0
- package/dist/session/rename.d.ts +3 -0
- package/dist/session/rename.js +37 -0
- package/dist/session/task-file.d.ts +5 -0
- package/dist/session/task-file.js +23 -0
- package/dist/session/tree/index.d.ts +2 -0
- package/dist/session/tree/index.js +2 -0
- package/dist/session/tree/tree.d.ts +3 -0
- package/dist/session/tree/tree.js +368 -0
- package/dist/session/turn/client.d.ts +28 -0
- package/dist/session/turn/client.js +51 -0
- package/dist/session/turn/commands.d.ts +8 -0
- package/dist/session/turn/commands.js +185 -0
- package/dist/session/turn/index.d.ts +4 -0
- package/dist/session/turn/index.js +3 -0
- package/dist/session/turn/output.d.ts +47 -0
- package/dist/session/turn/output.js +61 -0
- package/dist/status/client.d.ts +124 -0
- package/dist/status/client.js +5 -0
- package/dist/status/command.d.ts +4 -0
- package/dist/status/command.js +40 -0
- package/dist/status/doctor.d.ts +15 -0
- package/dist/status/doctor.js +111 -0
- package/dist/status/index.d.ts +5 -0
- package/dist/status/index.js +4 -0
- package/dist/status/output/compact.d.ts +32 -0
- package/dist/status/output/compact.js +49 -0
- package/dist/status/output/human.d.ts +7 -0
- package/dist/status/output/human.js +87 -0
- package/dist/status/output/index.d.ts +3 -0
- package/dist/status/output/index.js +3 -0
- package/dist/team-workspace/ceremony.d.ts +19 -0
- package/dist/team-workspace/ceremony.js +141 -0
- package/dist/team-workspace/client.d.ts +58 -0
- package/dist/team-workspace/client.js +6 -0
- package/dist/team-workspace/commands.d.ts +3 -0
- package/dist/team-workspace/commands.js +85 -0
- package/dist/team-workspace/confirmation.d.ts +4 -0
- package/dist/team-workspace/confirmation.js +8 -0
- package/dist/team-workspace/dependencies.d.ts +8 -0
- package/dist/team-workspace/dependencies.js +2 -0
- package/dist/team-workspace/index.d.ts +6 -0
- package/dist/team-workspace/index.js +5 -0
- package/dist/team-workspace/launcher.d.ts +17 -0
- package/dist/team-workspace/launcher.js +30 -0
- package/dist/team-workspace/output.d.ts +15 -0
- package/dist/team-workspace/output.js +28 -0
- package/dist/team-workspace/terminal.d.ts +9 -0
- package/dist/team-workspace/terminal.js +46 -0
- package/dist/terminal/arguments.d.ts +13 -0
- package/dist/terminal/arguments.js +79 -0
- package/dist/terminal/client.d.ts +83 -0
- package/dist/terminal/client.js +71 -0
- package/dist/terminal/commands.d.ts +7 -0
- package/dist/terminal/commands.js +143 -0
- package/dist/terminal/control-commands.d.ts +10 -0
- package/dist/terminal/control-commands.js +212 -0
- package/dist/terminal/index.d.ts +4 -0
- package/dist/terminal/index.js +4 -0
- package/dist/terminal/output/compact-list.d.ts +148 -0
- package/dist/terminal/output/compact-list.js +153 -0
- package/dist/terminal/output/human.d.ts +42 -0
- package/dist/terminal/output/human.js +55 -0
- package/dist/terminal/output/index.d.ts +3 -0
- package/dist/terminal/output/index.js +3 -0
- package/dist/terminal/tree/index.d.ts +2 -0
- package/dist/terminal/tree/index.js +2 -0
- package/dist/terminal/tree/tree.d.ts +3 -0
- package/dist/terminal/tree/tree.js +104 -0
- package/guidance/maia-cli/SKILL.md +58 -0
- package/guidance/maia-orchestration/SKILL.md +54 -0
- package/package.json +78 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { remoteNodeInstallConfirmParametersSchema, remoteNodeRegisterConfirmParametersSchema, remoteNodeRemoveConfirmParametersSchema, } from "@maiaos/sdk";
|
|
4
|
+
import * as Data from "effect/Data";
|
|
5
|
+
import * as Duration from "effect/Duration";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Schedule from "effect/Schedule";
|
|
8
|
+
import { askToConfirm, CliArgumentError, confirmParameters, jsonLine, LOCAL_NODE, missingArgument, parseOptions, promptOrRefuse, readPipedPreview, reportError, requestedTwoPhaseMode, requirePositionals, TWO_PHASE_FLAGS, } from "../command-line/index.js";
|
|
9
|
+
import { commandIdentifier, } from "../local-node/index.js";
|
|
10
|
+
import { withReachability } from "./reachability.js";
|
|
11
|
+
import { installedText, listText, planText, registerPlanText, removedText, } from "./text.js";
|
|
12
|
+
const WAIT_MS = 3500;
|
|
13
|
+
const PROBE_DEADLINE = Duration.minutes(3);
|
|
14
|
+
const JOB_DEADLINE = Duration.minutes(20);
|
|
15
|
+
const EXIT_UNAVAILABLE = 69;
|
|
16
|
+
const EXIT_TEMPORARY = 75;
|
|
17
|
+
const cancelled = (context) => {
|
|
18
|
+
context.io.stderr("Cancelled; nothing changed on the host.\n");
|
|
19
|
+
return 1;
|
|
20
|
+
};
|
|
21
|
+
class NodeCommandError extends Data.TaggedError("NodeCommandError") {
|
|
22
|
+
}
|
|
23
|
+
const required = (effect) => Effect.flatMap(effect, (result) => result.ok
|
|
24
|
+
? Effect.succeed(result.value)
|
|
25
|
+
: Effect.fail(new NodeCommandError({ error: result.error })));
|
|
26
|
+
const operation = (value) => {
|
|
27
|
+
if (value === undefined)
|
|
28
|
+
throw new CliArgumentError("Remote Nodes are unavailable in this CLI.");
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
export const nameFromHost = (host) => {
|
|
32
|
+
const name = (host.split("@").at(-1) ?? "")
|
|
33
|
+
.toLowerCase()
|
|
34
|
+
.replaceAll(/[^a-z0-9-]+/gu, "-")
|
|
35
|
+
.replace(/^-+/u, "")
|
|
36
|
+
.slice(0, 63)
|
|
37
|
+
.replace(/-+$/u, "");
|
|
38
|
+
if (name === "")
|
|
39
|
+
throw new CliArgumentError("Name the Node with --name <name>.");
|
|
40
|
+
return name;
|
|
41
|
+
};
|
|
42
|
+
const readKeep = (value = "3") => {
|
|
43
|
+
if (!/^[2-8]$/u.test(value))
|
|
44
|
+
throw new CliArgumentError("--keep must be 2 to 8.");
|
|
45
|
+
return Number(value);
|
|
46
|
+
};
|
|
47
|
+
const ADD_OPTIONS = new Set([
|
|
48
|
+
"--claude-bin",
|
|
49
|
+
"--codex-bin",
|
|
50
|
+
"--command-id",
|
|
51
|
+
"--keep",
|
|
52
|
+
"--name",
|
|
53
|
+
"--node-runtime",
|
|
54
|
+
"--release",
|
|
55
|
+
"--remote-profile",
|
|
56
|
+
"--root",
|
|
57
|
+
]);
|
|
58
|
+
const optionalBinaries = (options) => {
|
|
59
|
+
const codexBin = options.get("--codex-bin");
|
|
60
|
+
const claudeBin = options.get("--claude-bin");
|
|
61
|
+
return {
|
|
62
|
+
...(claudeBin === undefined ? {} : { claudeBin }),
|
|
63
|
+
...(codexBin === undefined ? {} : { codexBin }),
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const CONFIRM_FLAGS = new Set(["--yes", ...TWO_PHASE_FLAGS]);
|
|
67
|
+
const readName = (name) => {
|
|
68
|
+
if (name === LOCAL_NODE)
|
|
69
|
+
throw new CliArgumentError("The name 'local' is this machine's Node: name the Node with --name <name>.");
|
|
70
|
+
return name;
|
|
71
|
+
};
|
|
72
|
+
const PINNED_NODE_VERSION = "24.22.1";
|
|
73
|
+
const thisNode = {
|
|
74
|
+
arch: process.arch,
|
|
75
|
+
execPath: process.execPath,
|
|
76
|
+
platform: process.platform,
|
|
77
|
+
version: process.versions.node,
|
|
78
|
+
};
|
|
79
|
+
export const nodeRuntimeOf = (flag, interpreter) => {
|
|
80
|
+
if (flag !== undefined)
|
|
81
|
+
return flag;
|
|
82
|
+
if (interpreter.platform === "linux" &&
|
|
83
|
+
interpreter.arch === "x64" &&
|
|
84
|
+
interpreter.version === PINNED_NODE_VERSION)
|
|
85
|
+
return interpreter.execPath;
|
|
86
|
+
throw new CliArgumentError(`--node-runtime is required: this Node.js is ${interpreter.platform}-${interpreter.arch} ${interpreter.version}, and a remote host needs a linux-x64 ${PINNED_NODE_VERSION} build.`);
|
|
87
|
+
};
|
|
88
|
+
const readAdd = ({ options, positionals }) => {
|
|
89
|
+
requirePositionals(positionals, 1);
|
|
90
|
+
const host = positionals[0] ?? "";
|
|
91
|
+
const release = options.get("--release");
|
|
92
|
+
if (release === undefined)
|
|
93
|
+
throw missingArgument();
|
|
94
|
+
const runtime = nodeRuntimeOf(options.get("--node-runtime"), thisNode);
|
|
95
|
+
return {
|
|
96
|
+
commandId: options.get("--command-id"),
|
|
97
|
+
parameters: {
|
|
98
|
+
...optionalBinaries(options),
|
|
99
|
+
host,
|
|
100
|
+
keep: readKeep(options.get("--keep")),
|
|
101
|
+
name: readName(options.get("--name") ?? nameFromHost(host)),
|
|
102
|
+
nodeRuntime: resolve(process.cwd(), runtime),
|
|
103
|
+
profile: options.get("--remote-profile") ?? "default",
|
|
104
|
+
release: resolve(process.cwd(), release),
|
|
105
|
+
root: options.get("--root") ?? "~/.maia",
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
const confirmed = (context, question, mode) => mode === "prompt" ? askToConfirm(context, question) : Effect.succeed(true);
|
|
110
|
+
const pipedPlan = (piped, longPolled = true) => {
|
|
111
|
+
const parameters = Reflect.get(piped, "parameters");
|
|
112
|
+
const preview = Reflect.get(piped, "preview");
|
|
113
|
+
if (typeof parameters !== "object" ||
|
|
114
|
+
parameters === null ||
|
|
115
|
+
typeof preview !== "object" ||
|
|
116
|
+
preview === null)
|
|
117
|
+
return {};
|
|
118
|
+
const planDigest = Reflect.get(preview, "planDigest");
|
|
119
|
+
return {
|
|
120
|
+
...parameters,
|
|
121
|
+
inputDigest: Reflect.get(preview, "inputDigest"),
|
|
122
|
+
...(planDigest === undefined ? {} : { planDigest }),
|
|
123
|
+
proof: Reflect.get(preview, "proof"),
|
|
124
|
+
...(longPolled ? { waitMs: WAIT_MS } : {}),
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
const notSettled = () => new NodeCommandError({
|
|
128
|
+
error: {
|
|
129
|
+
code: "deadline_exceeded",
|
|
130
|
+
message: "The remote Node did not settle in time; maia node list shows where it stands.",
|
|
131
|
+
retryable: true,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
const repeatUntil = (effect, settled, deadline) => effect.pipe(Effect.repeat({
|
|
135
|
+
schedule: Schedule.spaced(Duration.millis(250)),
|
|
136
|
+
until: settled,
|
|
137
|
+
}), Effect.timeoutOrElse({
|
|
138
|
+
duration: deadline,
|
|
139
|
+
orElse: () => Effect.fail(notSettled()),
|
|
140
|
+
}));
|
|
141
|
+
const write = (context, output, text) => {
|
|
142
|
+
context.io.stdout(context.json ? jsonLine({ ok: true, result: output }) : text);
|
|
143
|
+
};
|
|
144
|
+
const exitFor = (node) => {
|
|
145
|
+
if (node.state === "ready" || node.state === "removed")
|
|
146
|
+
return 0;
|
|
147
|
+
return node.error?.code === "blocked" ? EXIT_UNAVAILABLE : EXIT_TEMPORARY;
|
|
148
|
+
};
|
|
149
|
+
const previewUntilSettled = (context, parameters) => {
|
|
150
|
+
const preview = operation(context.dependencies.previewRemoteNodeInstall);
|
|
151
|
+
if (!context.json)
|
|
152
|
+
context.io.stderr(`Probing ${parameters.host}…\n`);
|
|
153
|
+
return repeatUntil(required(preview({ ...parameters, waitMs: WAIT_MS })), (result) => result.state !== "probing", PROBE_DEADLINE);
|
|
154
|
+
};
|
|
155
|
+
const install = (context, confirmation) => {
|
|
156
|
+
const confirm = operation(context.dependencies.confirmRemoteNodeInstall);
|
|
157
|
+
if (!context.json)
|
|
158
|
+
context.io.stderr(`Installing on ${confirmation.host}; a first install takes about a minute…\n`);
|
|
159
|
+
return repeatUntil(required(confirm(confirmation)), (result) => result.node.state !== "installing", JOB_DEADLINE);
|
|
160
|
+
};
|
|
161
|
+
const finishInstall = (context, confirmation) => Effect.gen(function* () {
|
|
162
|
+
const result = yield* install(context, confirmation);
|
|
163
|
+
write(context, { command: "node.remote.install.confirm", result }, installedText(result.node));
|
|
164
|
+
return exitFor(result.node);
|
|
165
|
+
});
|
|
166
|
+
const runConfirmedInstall = (context) => Effect.flatMap(readPipedPreview(context), (piped) => Effect.flatMap(confirmParameters(remoteNodeInstallConfirmParametersSchema, pipedPlan(piped)), (confirmation) => finishInstall(context, confirmation)));
|
|
167
|
+
const planInstall = (context, parsed, requested) => Effect.gen(function* () {
|
|
168
|
+
const input = readAdd(parsed);
|
|
169
|
+
const commandId = yield* commandIdentifier(input.commandId);
|
|
170
|
+
const parameters = { ...input.parameters, commandId };
|
|
171
|
+
const preview = yield* previewUntilSettled(context, parameters);
|
|
172
|
+
const planned = {
|
|
173
|
+
parameters,
|
|
174
|
+
preview,
|
|
175
|
+
};
|
|
176
|
+
if (preview.state !== "ready" || !context.json || requested === "dry-run")
|
|
177
|
+
write(context, { command: "node.remote.install.preview", result: planned }, planText(preview));
|
|
178
|
+
return planned;
|
|
179
|
+
});
|
|
180
|
+
export const runNodeInstall = (tokens, context) => guarded(Effect.gen(function* () {
|
|
181
|
+
const parsed = parseOptions(tokens, ADD_OPTIONS, CONFIRM_FLAGS);
|
|
182
|
+
const requested = requestedTwoPhaseMode(parsed.flags, true);
|
|
183
|
+
if (requested === "confirm-stdin")
|
|
184
|
+
return yield* runConfirmedInstall(context);
|
|
185
|
+
const planned = yield* planInstall(context, parsed, requested);
|
|
186
|
+
const { parameters, preview } = planned;
|
|
187
|
+
if (preview.state !== "ready")
|
|
188
|
+
return EXIT_UNAVAILABLE;
|
|
189
|
+
if (requested === "dry-run")
|
|
190
|
+
return 0;
|
|
191
|
+
const mode = requested ?? promptOrRefuse(context, true);
|
|
192
|
+
const question = `Install this plan on ${parameters.host} as ${parameters.name}?`;
|
|
193
|
+
if (!(yield* confirmed(context, question, mode)))
|
|
194
|
+
return cancelled(context);
|
|
195
|
+
const { inputDigest, planDigest, proof } = preview;
|
|
196
|
+
const proven = { inputDigest, planDigest, proof, waitMs: WAIT_MS };
|
|
197
|
+
return yield* finishInstall(context, { ...parameters, ...proven });
|
|
198
|
+
}), context);
|
|
199
|
+
const REGISTER_OPTIONS = new Set([
|
|
200
|
+
"--command-id",
|
|
201
|
+
"--launcher",
|
|
202
|
+
"--name",
|
|
203
|
+
"--remote-profile",
|
|
204
|
+
]);
|
|
205
|
+
const readRegister = ({ options, positionals }) => {
|
|
206
|
+
requirePositionals(positionals, 1);
|
|
207
|
+
const host = positionals[0] ?? "";
|
|
208
|
+
const launcherPath = options.get("--launcher");
|
|
209
|
+
const profile = options.get("--remote-profile");
|
|
210
|
+
return {
|
|
211
|
+
commandId: options.get("--command-id"),
|
|
212
|
+
parameters: {
|
|
213
|
+
host,
|
|
214
|
+
...(launcherPath === undefined ? {} : { launcherPath }),
|
|
215
|
+
name: readName(options.get("--name") ?? nameFromHost(host)),
|
|
216
|
+
...(profile === undefined ? {} : { profile }),
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
const finishRegister = (context, confirmation) => Effect.gen(function* () {
|
|
221
|
+
const result = yield* required(operation(context.dependencies.confirmRemoteNodeRegister)(confirmation));
|
|
222
|
+
write(context, { command: "node.remote.register.confirm", result }, installedText(result.node));
|
|
223
|
+
return exitFor(result.node);
|
|
224
|
+
});
|
|
225
|
+
const confirmPipedRegister = (context) => Effect.gen(function* () {
|
|
226
|
+
const piped = yield* readPipedPreview(context);
|
|
227
|
+
return yield* finishRegister(context, yield* confirmParameters(remoteNodeRegisterConfirmParametersSchema, pipedPlan(piped, false)));
|
|
228
|
+
});
|
|
229
|
+
const planRegister = (context, parsed) => Effect.gen(function* () {
|
|
230
|
+
const input = readRegister(parsed);
|
|
231
|
+
const commandId = yield* commandIdentifier(input.commandId);
|
|
232
|
+
const parameters = { ...input.parameters, commandId };
|
|
233
|
+
const preview = yield* required(operation(context.dependencies.previewRemoteNodeRegister)(parameters));
|
|
234
|
+
write(context, {
|
|
235
|
+
command: "node.remote.register.preview",
|
|
236
|
+
result: { parameters, preview },
|
|
237
|
+
}, registerPlanText(preview));
|
|
238
|
+
return { parameters, preview };
|
|
239
|
+
});
|
|
240
|
+
export const runNodeRegister = (tokens, context) => guarded(Effect.gen(function* () {
|
|
241
|
+
const parsed = parseOptions(tokens, REGISTER_OPTIONS, new Set(TWO_PHASE_FLAGS));
|
|
242
|
+
const requested = requestedTwoPhaseMode(parsed.flags);
|
|
243
|
+
if (requested === "confirm-stdin")
|
|
244
|
+
return yield* confirmPipedRegister(context);
|
|
245
|
+
const mode = requested ?? promptOrRefuse(context);
|
|
246
|
+
const { parameters, preview } = yield* planRegister(context, parsed);
|
|
247
|
+
if (mode === "dry-run")
|
|
248
|
+
return 0;
|
|
249
|
+
const question = `Register the Node on ${parameters.host} as ${parameters.name}?`;
|
|
250
|
+
if (!(yield* confirmed(context, question, mode)))
|
|
251
|
+
return cancelled(context);
|
|
252
|
+
const { inputDigest, planDigest, proof } = preview;
|
|
253
|
+
const proven = { inputDigest, planDigest, proof };
|
|
254
|
+
return yield* finishRegister(context, { ...parameters, ...proven });
|
|
255
|
+
}), context);
|
|
256
|
+
export const runNodeList = (tokens, context) => guarded(Effect.gen(function* () {
|
|
257
|
+
const { flags, positionals } = parseOptions(tokens, new Set(), new Set(["--all"]));
|
|
258
|
+
requirePositionals(positionals, 0);
|
|
259
|
+
const listed = yield* required(operation(context.dependencies.listRemoteNodes)({
|
|
260
|
+
includeRemoved: flags.has("--all"),
|
|
261
|
+
}));
|
|
262
|
+
const nodes = yield* withReachability(listed.nodes, context.dependencies.sshLayer);
|
|
263
|
+
write(context, { command: "node.remote.list", result: { nodes } }, listText(nodes));
|
|
264
|
+
return 0;
|
|
265
|
+
}), context);
|
|
266
|
+
const readRemove = ({ flags, options, positionals }) => {
|
|
267
|
+
requirePositionals(positionals, 1);
|
|
268
|
+
return {
|
|
269
|
+
commandId: options.get("--command-id"),
|
|
270
|
+
name: positionals[0] ?? "",
|
|
271
|
+
purge: flags.has("--purge"),
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
const removeQuestion = (node, purge) => {
|
|
275
|
+
if (node.root === undefined)
|
|
276
|
+
return `Forget ${node.name}? The Node on ${node.host} keeps running.`;
|
|
277
|
+
return purge
|
|
278
|
+
? `Uninstall ${node.name} from ${node.host}:${node.root} and DELETE profile ${node.profile}'s state (its database)? Sign-ins there stay.`
|
|
279
|
+
: `Uninstall ${node.name} from ${node.host}:${node.root}? Profile ${node.profile}'s state stays for a later add.`;
|
|
280
|
+
};
|
|
281
|
+
const registered = (context, name) => Effect.flatMap(required(operation(context.dependencies.listRemoteNodes)({})), (listed) => {
|
|
282
|
+
const node = listed.nodes.find((candidate) => candidate.name === name);
|
|
283
|
+
return node === undefined
|
|
284
|
+
? Effect.fail(new CliArgumentError(`No remote Node is registered as ${name}.`))
|
|
285
|
+
: Effect.succeed(node);
|
|
286
|
+
});
|
|
287
|
+
const uninstall = (context, confirmation) => repeatUntil(required(operation(context.dependencies.confirmRemoteNodeRemove)(confirmation)), (value) => value.node.state !== "removing", JOB_DEADLINE);
|
|
288
|
+
const finishRemove = (context, confirmation) => Effect.gen(function* () {
|
|
289
|
+
const result = yield* uninstall(context, confirmation);
|
|
290
|
+
write(context, { command: "node.remote.remove.confirm", result }, removedText(result.node));
|
|
291
|
+
return exitFor(result.node);
|
|
292
|
+
});
|
|
293
|
+
const confirmPipedRemove = (context) => Effect.gen(function* () {
|
|
294
|
+
const piped = yield* readPipedPreview(context);
|
|
295
|
+
return yield* finishRemove(context, yield* confirmParameters(remoteNodeRemoveConfirmParametersSchema, pipedPlan(piped)));
|
|
296
|
+
});
|
|
297
|
+
const planRemove = (context, parsed) => Effect.gen(function* () {
|
|
298
|
+
const input = readRemove(parsed);
|
|
299
|
+
const node = yield* registered(context, input.name);
|
|
300
|
+
const removal = {
|
|
301
|
+
commandId: yield* commandIdentifier(input.commandId),
|
|
302
|
+
expectedRevision: node.revision,
|
|
303
|
+
name: node.name,
|
|
304
|
+
purge: input.purge,
|
|
305
|
+
};
|
|
306
|
+
const preview = yield* required(operation(context.dependencies.previewRemoteNodeRemove)(removal));
|
|
307
|
+
return { preview, question: removeQuestion(node, input.purge), removal };
|
|
308
|
+
});
|
|
309
|
+
const writeRemovePreview = (context, { preview, question, removal }) => {
|
|
310
|
+
write(context, {
|
|
311
|
+
command: "node.remote.remove.preview",
|
|
312
|
+
result: { parameters: removal, preview },
|
|
313
|
+
}, `${question}\n`);
|
|
314
|
+
return 0;
|
|
315
|
+
};
|
|
316
|
+
export const runNodeRemove = (tokens, context) => guarded(Effect.gen(function* () {
|
|
317
|
+
const parsed = parseOptions(tokens, new Set(["--command-id"]), new Set(["--purge", ...CONFIRM_FLAGS]));
|
|
318
|
+
const requested = requestedTwoPhaseMode(parsed.flags, true);
|
|
319
|
+
if (requested === "confirm-stdin")
|
|
320
|
+
return yield* confirmPipedRemove(context);
|
|
321
|
+
const { preview, question, removal } = yield* planRemove(context, parsed);
|
|
322
|
+
if (requested === "dry-run")
|
|
323
|
+
return writeRemovePreview(context, { preview, question, removal });
|
|
324
|
+
const mode = requested ?? promptOrRefuse(context, true);
|
|
325
|
+
if (!(yield* confirmed(context, question, mode)))
|
|
326
|
+
return cancelled(context);
|
|
327
|
+
const { inputDigest, proof } = preview;
|
|
328
|
+
const proven = { inputDigest, proof, waitMs: WAIT_MS };
|
|
329
|
+
return yield* finishRemove(context, { ...removal, ...proven });
|
|
330
|
+
}), context);
|
|
331
|
+
const failure = (error) => {
|
|
332
|
+
if (error instanceof NodeCommandError)
|
|
333
|
+
return error.error;
|
|
334
|
+
const usage = error instanceof CliArgumentError;
|
|
335
|
+
return {
|
|
336
|
+
code: usage ? "invalid_argument" : "internal_error",
|
|
337
|
+
message: usage ? error.message : "The node command failed.",
|
|
338
|
+
retryable: false,
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
const guarded = (program, context) => Effect.suspend(() => program).pipe(Effect.catch((error) => Effect.sync(() => reportError(failure(error), context))));
|
|
342
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type Connection, type LocalNodeStatusResult, MaiaClientError, type RemoteNodeRecord } from "@maiaos/sdk";
|
|
2
|
+
import { type LocalNodeEffectClient, type NodeApiEffectDiscoveryOptions, type NodeBridge } from "@maiaos/sdk/node/effect";
|
|
3
|
+
import type * as Crypto from "effect/Crypto";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import type { ChildProcessSpawner } from "effect/process/ChildProcessSpawner";
|
|
7
|
+
import * as Scope from "effect/Scope";
|
|
8
|
+
import { type CliNodeConnector } from "../local-node/index.js";
|
|
9
|
+
export type SshLayer = Layer.Layer<ChildProcessSpawner>;
|
|
10
|
+
export declare const readRemoteNode: (connector: CliNodeConnector, options: NodeApiEffectDiscoveryOptions, name: string) => Effect.Effect<{
|
|
11
|
+
readonly createdAt: string;
|
|
12
|
+
readonly error?: {
|
|
13
|
+
readonly code: string;
|
|
14
|
+
readonly message: string;
|
|
15
|
+
} | undefined;
|
|
16
|
+
readonly executors: readonly {
|
|
17
|
+
readonly executor: "claude-code" | "codex-cli";
|
|
18
|
+
readonly interpreter?: {
|
|
19
|
+
readonly path: string;
|
|
20
|
+
readonly sha256: string;
|
|
21
|
+
} | undefined;
|
|
22
|
+
readonly path?: string | undefined;
|
|
23
|
+
readonly realPath?: string | undefined;
|
|
24
|
+
readonly reason?: string | undefined;
|
|
25
|
+
readonly sha256?: string | undefined;
|
|
26
|
+
readonly source: "discovered" | "override";
|
|
27
|
+
readonly state: "available" | "unavailable";
|
|
28
|
+
}[];
|
|
29
|
+
readonly host: string;
|
|
30
|
+
readonly installedAt?: string | undefined;
|
|
31
|
+
readonly launcherPath: string;
|
|
32
|
+
readonly maiaVersion?: string | undefined;
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly origin?: "registered" | undefined;
|
|
35
|
+
readonly profile: string;
|
|
36
|
+
readonly releaseId?: string | undefined;
|
|
37
|
+
readonly remaining?: readonly string[] | undefined;
|
|
38
|
+
readonly revision: string;
|
|
39
|
+
readonly root?: string | undefined;
|
|
40
|
+
readonly schemaVersion: "maia.remote-node/v1";
|
|
41
|
+
readonly state: "install_failed" | "installing" | "ready" | "remove_failed" | "removed" | "removing";
|
|
42
|
+
readonly unitName?: string | undefined;
|
|
43
|
+
readonly updatedAt: string;
|
|
44
|
+
}, unknown, Crypto.Crypto>;
|
|
45
|
+
export type RemoteBridge = {
|
|
46
|
+
readonly attachSession: NodeBridge["attachSession"];
|
|
47
|
+
readonly client: LocalNodeEffectClient;
|
|
48
|
+
readonly closed: Effect.Effect<boolean>;
|
|
49
|
+
readonly coordinator: LocalNodeEffectClient;
|
|
50
|
+
readonly coordinatorAttachSession: NodeBridge["attachSession"];
|
|
51
|
+
readonly status: LocalNodeStatusResult;
|
|
52
|
+
readonly version: string;
|
|
53
|
+
};
|
|
54
|
+
export declare const openRemoteBridge: (node: RemoteNodeRecord, scope: Scope.Scope, ssh?: SshLayer) => Effect.Effect<RemoteBridge, MaiaClientError>;
|
|
55
|
+
export declare const makeRemoteNodeConnector: (input: {
|
|
56
|
+
readonly local?: CliNodeConnector;
|
|
57
|
+
readonly name: string;
|
|
58
|
+
readonly scope: Scope.Scope;
|
|
59
|
+
readonly ssh?: SshLayer;
|
|
60
|
+
}) => CliNodeConnector;
|
|
61
|
+
export declare const remoteSignInScript: (node: RemoteNodeRecord, connection: Connection) => string | undefined;
|
|
62
|
+
export declare const remoteVendorLogin: (input: {
|
|
63
|
+
readonly connector?: CliNodeConnector;
|
|
64
|
+
readonly name: string;
|
|
65
|
+
readonly profile?: string;
|
|
66
|
+
}) => (connection: Connection) => Effect.Effect<number, unknown>;
|
|
67
|
+
//# sourceMappingURL=connector.d.ts.map
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as NodeChildProcessSpawner from "@effect/platform-node-shared/NodeChildProcessSpawner";
|
|
2
|
+
import * as NodeCrypto from "@effect/platform-node-shared/NodeCrypto";
|
|
3
|
+
import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem";
|
|
4
|
+
import * as NodePath from "@effect/platform-node-shared/NodePath";
|
|
5
|
+
import { MaiaClientError, } from "@maiaos/sdk";
|
|
6
|
+
import { bridgeScript, NO_SSH_STDERR, openNodeBridge, readSshStderr, shellQuote, sshCommandArguments, } from "@maiaos/sdk/node/effect";
|
|
7
|
+
import * as Duration from "effect/Duration";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Exit from "effect/Exit";
|
|
10
|
+
import * as Layer from "effect/Layer";
|
|
11
|
+
import { isPlatformError } from "effect/PlatformError";
|
|
12
|
+
import * as ChildProcess from "effect/process/ChildProcess";
|
|
13
|
+
import * as Scope from "effect/Scope";
|
|
14
|
+
import * as Semaphore from "effect/Semaphore";
|
|
15
|
+
import * as Stream from "effect/Stream";
|
|
16
|
+
import { connectLocalNode, discoveryOptionsFor, newCliIdentifier, } from "../local-node/index.js";
|
|
17
|
+
const spawner = NodeChildProcessSpawner.layer.pipe(Layer.provide(Layer.merge(NodeFileSystem.layer, NodePath.layer)));
|
|
18
|
+
const BRIDGE_DEADLINE = Duration.seconds(30);
|
|
19
|
+
const unreachable = (name, reason) => new MaiaClientError("transport_failure", reason, {
|
|
20
|
+
remoteError: {
|
|
21
|
+
code: "node_unavailable",
|
|
22
|
+
message: `Remote Node ${name}: ${reason}`,
|
|
23
|
+
retryable: true,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
export const readRemoteNode = (connector, options, name) => Effect.gen(function* () {
|
|
27
|
+
const local = yield* connector(options);
|
|
28
|
+
const messageId = yield* newCliIdentifier("request");
|
|
29
|
+
const listed = yield* local.client.listRemoteNodes({}, { messageId });
|
|
30
|
+
const node = listed.nodes.find((candidate) => candidate.name === name);
|
|
31
|
+
if (node === undefined)
|
|
32
|
+
return yield* Effect.fail(unreachable(name, "no Node has this name; see maia node list."));
|
|
33
|
+
return node;
|
|
34
|
+
});
|
|
35
|
+
const spawnBridge = (node) => ChildProcess.make("ssh", sshCommandArguments({
|
|
36
|
+
host: node.host,
|
|
37
|
+
script: bridgeScript(node.launcherPath),
|
|
38
|
+
}), { stderr: "pipe", stdin: "pipe", stdout: "pipe" });
|
|
39
|
+
const readStderr = (stderr, read) => stderr.pipe(Stream.decodeText(), Stream.runForEach((chunk) => Effect.sync(() => {
|
|
40
|
+
read.reader = readSshStderr(read.reader, chunk);
|
|
41
|
+
})), Effect.ignore, Effect.forkScoped);
|
|
42
|
+
const SSH_NOT_STARTED = "ssh could not be started.";
|
|
43
|
+
const reasonOf = (error, failure) => {
|
|
44
|
+
const own = isPlatformError(error) ? SSH_NOT_STARTED : error.message;
|
|
45
|
+
const failed = own.endsWith(".") ? own : `${own}.`;
|
|
46
|
+
return failure === undefined ? failed : `${failed} ${failure.message}`;
|
|
47
|
+
};
|
|
48
|
+
const asRecorded = (node, bridge) => {
|
|
49
|
+
const { attachSession, client, closed, coordinator, coordinatorAttachSession, hello, } = bridge;
|
|
50
|
+
return hello.status.profile === node.profile
|
|
51
|
+
? Effect.succeed({
|
|
52
|
+
attachSession,
|
|
53
|
+
client,
|
|
54
|
+
closed,
|
|
55
|
+
coordinator,
|
|
56
|
+
coordinatorAttachSession,
|
|
57
|
+
status: hello.status,
|
|
58
|
+
version: hello.version,
|
|
59
|
+
})
|
|
60
|
+
: Effect.fail(unreachable(node.name, "the bridge answers for another profile."));
|
|
61
|
+
};
|
|
62
|
+
const notReady = ({ name, state }) => state === "install_failed" || state === "remove_failed"
|
|
63
|
+
? `it is ${state}, not ready: remove it with 'maia node remove ${name}'.`
|
|
64
|
+
: `it is ${state}, not ready.`;
|
|
65
|
+
export const openRemoteBridge = (node, scope, ssh = spawner) => {
|
|
66
|
+
if (node.state !== "ready")
|
|
67
|
+
return Effect.fail(unreachable(node.name, notReady(node)));
|
|
68
|
+
const read = { reader: NO_SSH_STDERR };
|
|
69
|
+
return Effect.gen(function* () {
|
|
70
|
+
const handle = yield* spawnBridge(node);
|
|
71
|
+
yield* readStderr(handle.stderr, read);
|
|
72
|
+
const bridge = yield* openNodeBridge(handle, {
|
|
73
|
+
helloDeadline: BRIDGE_DEADLINE,
|
|
74
|
+
});
|
|
75
|
+
return yield* asRecorded(node, bridge);
|
|
76
|
+
}).pipe(Effect.provide(ssh), Effect.provideService(Scope.Scope, scope), Effect.mapError((error) => error instanceof MaiaClientError
|
|
77
|
+
? error
|
|
78
|
+
: unreachable(node.name, reasonOf(error, read.reader.failure))));
|
|
79
|
+
};
|
|
80
|
+
const connectionOf = (bridge, principal) => ({
|
|
81
|
+
attachSession: principal === undefined
|
|
82
|
+
? bridge.attachSession
|
|
83
|
+
: bridge.coordinatorAttachSession,
|
|
84
|
+
client: principal === undefined ? bridge.client : bridge.coordinator,
|
|
85
|
+
status: bridge.status,
|
|
86
|
+
});
|
|
87
|
+
const openIntoCache = (node, { scope, ssh }, cache) => Effect.uninterruptibleMask((restore) => Effect.flatMap(Scope.fork(scope), (attempt) => restore(openRemoteBridge(node, attempt, ssh)).pipe(Effect.onExit((exit) => {
|
|
88
|
+
const closed = cache.entry?.scope;
|
|
89
|
+
if (Exit.isSuccess(exit))
|
|
90
|
+
cache.entry = { bridge: exit.value, scope: attempt };
|
|
91
|
+
else
|
|
92
|
+
delete cache.entry;
|
|
93
|
+
return Effect.andThen(closed === undefined ? Effect.void : Scope.close(closed, Exit.void), Exit.isSuccess(exit) ? Effect.void : Scope.close(attempt, exit));
|
|
94
|
+
}))));
|
|
95
|
+
export const makeRemoteNodeConnector = (input) => {
|
|
96
|
+
const local = input.local ?? connectLocalNode;
|
|
97
|
+
const cache = {};
|
|
98
|
+
const opening = Semaphore.makeUnsafe(1);
|
|
99
|
+
const open = ({ principal: _mark, ...operator }) => Effect.gen(function* () {
|
|
100
|
+
const cached = cache.entry?.bridge;
|
|
101
|
+
if (cached !== undefined && !(yield* cached.closed))
|
|
102
|
+
return cached;
|
|
103
|
+
const node = yield* readRemoteNode(local, operator, input.name);
|
|
104
|
+
return yield* openIntoCache(node, input, cache);
|
|
105
|
+
}).pipe(Semaphore.withPermit(opening));
|
|
106
|
+
return (options) => open(options).pipe(Effect.map((bridge) => connectionOf(bridge, options.principal)));
|
|
107
|
+
};
|
|
108
|
+
const vendorCommand = (executor) => executor === "codex-cli"
|
|
109
|
+
? { arguments_: "login --device-auth", variable: "CODEX_HOME" }
|
|
110
|
+
: { arguments_: "auth login", variable: "CLAUDE_CONFIG_DIR" };
|
|
111
|
+
const directoryOf = (path) => path.slice(0, Math.max(1, path.lastIndexOf("/")));
|
|
112
|
+
export const remoteSignInScript = (node, connection) => {
|
|
113
|
+
const pinned = node.executors.find((executor) => executor.executor === connection.executor);
|
|
114
|
+
if (pinned?.state !== "available" || pinned.path === undefined)
|
|
115
|
+
return undefined;
|
|
116
|
+
const vendor = vendorCommand(connection.executor);
|
|
117
|
+
const path = [
|
|
118
|
+
directoryOf(pinned.path),
|
|
119
|
+
...(pinned.interpreter === undefined
|
|
120
|
+
? []
|
|
121
|
+
: [directoryOf(pinned.interpreter.path)]),
|
|
122
|
+
"/usr/local/bin",
|
|
123
|
+
"/usr/bin",
|
|
124
|
+
"/bin",
|
|
125
|
+
].join(":");
|
|
126
|
+
const account = connection.configRoot.kind === "maia-managed"
|
|
127
|
+
? `${vendor.variable}=${shellQuote(connection.configRoot.path)} `
|
|
128
|
+
: "";
|
|
129
|
+
return `exec env PATH=${shellQuote(path)} ${account}${shellQuote(pinned.path)} ${vendor.arguments_}`;
|
|
130
|
+
};
|
|
131
|
+
const signInOver = (node, connection) => Effect.gen(function* () {
|
|
132
|
+
const script = remoteSignInScript(node, connection);
|
|
133
|
+
if (script === undefined)
|
|
134
|
+
return yield* Effect.fail(unreachable(node.name, `no pinned ${connection.executor} binary is available there.`));
|
|
135
|
+
const handle = yield* ChildProcess.make("ssh", sshCommandArguments({ host: node.host, script, terminal: true }), { stderr: "inherit", stdin: "inherit", stdout: "inherit" });
|
|
136
|
+
return yield* handle.exitCode.pipe(Effect.map(Number), Effect.orElseSucceed(() => 1));
|
|
137
|
+
});
|
|
138
|
+
export const remoteVendorLogin = (input) => (connection) => Effect.gen(function* () {
|
|
139
|
+
const options = yield* discoveryOptionsFor(input.profile);
|
|
140
|
+
const node = yield* readRemoteNode(input.connector ?? connectLocalNode, options, input.name);
|
|
141
|
+
return yield* signInOver(node, connection);
|
|
142
|
+
}).pipe(Effect.scoped, Effect.provide(Layer.merge(spawner, NodeCrypto.layer)));
|
|
143
|
+
//# sourceMappingURL=connector.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { makeRemoteNodeClient, type RemoteNodeCliDependencies, } from "./client.js";
|
|
2
|
+
export { runNodeInstall, runNodeList, runNodeRegister, runNodeRemove, } from "./commands.js";
|
|
3
|
+
export { makeRemoteNodeConnector, remoteVendorLogin, type SshLayer, } from "./connector.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { RemoteNodeRecord } from "@maiaos/sdk";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { type SshLayer } from "./connector.js";
|
|
4
|
+
export type Reachability = {
|
|
5
|
+
readonly latencyMs: number;
|
|
6
|
+
readonly lifecycle: string;
|
|
7
|
+
readonly pid: number;
|
|
8
|
+
readonly pressure: string;
|
|
9
|
+
readonly state: "reachable";
|
|
10
|
+
readonly trees: {
|
|
11
|
+
readonly capacity: number;
|
|
12
|
+
readonly used: number;
|
|
13
|
+
};
|
|
14
|
+
readonly version: string;
|
|
15
|
+
} | {
|
|
16
|
+
readonly reason: string;
|
|
17
|
+
readonly state: "not_checked";
|
|
18
|
+
} | {
|
|
19
|
+
readonly reason: string;
|
|
20
|
+
readonly state: "stale";
|
|
21
|
+
} | {
|
|
22
|
+
readonly reason: string;
|
|
23
|
+
readonly state: "unknown";
|
|
24
|
+
} | {
|
|
25
|
+
readonly reason: string;
|
|
26
|
+
readonly state: "unreachable";
|
|
27
|
+
};
|
|
28
|
+
export declare const withReachability: (nodes: readonly RemoteNodeRecord[], ssh?: SshLayer) => Effect.Effect<{
|
|
29
|
+
createdAt: string;
|
|
30
|
+
error?: {
|
|
31
|
+
readonly code: string;
|
|
32
|
+
readonly message: string;
|
|
33
|
+
} | undefined;
|
|
34
|
+
executors: readonly {
|
|
35
|
+
readonly executor: "claude-code" | "codex-cli";
|
|
36
|
+
readonly interpreter?: {
|
|
37
|
+
readonly path: string;
|
|
38
|
+
readonly sha256: string;
|
|
39
|
+
} | undefined;
|
|
40
|
+
readonly path?: string | undefined;
|
|
41
|
+
readonly realPath?: string | undefined;
|
|
42
|
+
readonly reason?: string | undefined;
|
|
43
|
+
readonly sha256?: string | undefined;
|
|
44
|
+
readonly source: "discovered" | "override";
|
|
45
|
+
readonly state: "available" | "unavailable";
|
|
46
|
+
}[];
|
|
47
|
+
host: string;
|
|
48
|
+
installedAt?: string | undefined;
|
|
49
|
+
launcherPath: string;
|
|
50
|
+
maiaVersion?: string | undefined;
|
|
51
|
+
name: string;
|
|
52
|
+
origin?: "registered" | undefined;
|
|
53
|
+
profile: string;
|
|
54
|
+
releaseId?: string | undefined;
|
|
55
|
+
remaining?: readonly string[] | undefined;
|
|
56
|
+
revision: string;
|
|
57
|
+
root?: string | undefined;
|
|
58
|
+
schemaVersion: "maia.remote-node/v1";
|
|
59
|
+
state: "install_failed" | "installing" | "ready" | "remove_failed" | "removed" | "removing";
|
|
60
|
+
unitName?: string | undefined;
|
|
61
|
+
updatedAt: string;
|
|
62
|
+
reachability: Reachability;
|
|
63
|
+
}[], never, never>;
|
|
64
|
+
//# sourceMappingURL=reachability.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as Clock from "effect/Clock";
|
|
2
|
+
import * as Duration from "effect/Duration";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import { openRemoteBridge, } from "./connector.js";
|
|
5
|
+
const CHECK_DEADLINE = Duration.seconds(12);
|
|
6
|
+
const greeted = (node, bridge, latencyMs) => node.maiaVersion === undefined || bridge.version === node.maiaVersion
|
|
7
|
+
? {
|
|
8
|
+
latencyMs,
|
|
9
|
+
lifecycle: bridge.status.lifecycle,
|
|
10
|
+
pid: bridge.status.pid,
|
|
11
|
+
pressure: bridge.status.processResources.pressure,
|
|
12
|
+
state: "reachable",
|
|
13
|
+
trees: {
|
|
14
|
+
capacity: bridge.status.processResources.admission.capacity,
|
|
15
|
+
used: bridge.status.processResources.admission.usedTrees,
|
|
16
|
+
},
|
|
17
|
+
version: bridge.version,
|
|
18
|
+
}
|
|
19
|
+
: {
|
|
20
|
+
reason: `it answers as maia-node ${bridge.version}, recorded ${node.maiaVersion}`,
|
|
21
|
+
state: "stale",
|
|
22
|
+
};
|
|
23
|
+
const checkReachability = (node, ssh) => node.state === "ready"
|
|
24
|
+
? Effect.gen(function* () {
|
|
25
|
+
const started = yield* Clock.currentTimeMillis;
|
|
26
|
+
const bridge = yield* Effect.flatMap(Effect.scope, (scope) => openRemoteBridge(node, scope, ssh));
|
|
27
|
+
const finished = yield* Clock.currentTimeMillis;
|
|
28
|
+
return greeted(node, bridge, finished - started);
|
|
29
|
+
}).pipe(Effect.scoped, Effect.timeoutOrElse({
|
|
30
|
+
duration: CHECK_DEADLINE,
|
|
31
|
+
orElse: () => Effect.succeed({
|
|
32
|
+
reason: `no answer within ${Duration.format(CHECK_DEADLINE)}`,
|
|
33
|
+
state: "unknown",
|
|
34
|
+
}),
|
|
35
|
+
}), Effect.catch((error) => Effect.succeed({
|
|
36
|
+
reason: error.message,
|
|
37
|
+
state: "unreachable",
|
|
38
|
+
})))
|
|
39
|
+
: Effect.succeed({ reason: `it is ${node.state}`, state: "not_checked" });
|
|
40
|
+
export const withReachability = (nodes, ssh) => Effect.forEach(nodes, (node) => Effect.map(checkReachability(node, ssh), (reachability) => ({
|
|
41
|
+
...node,
|
|
42
|
+
reachability,
|
|
43
|
+
})), { concurrency: 4 });
|
|
44
|
+
//# sourceMappingURL=reachability.js.map
|