@maiaos/cli 0.1.0-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +287 -0
- package/dist/bin/maia.NOTICES.txt +59 -0
- package/dist/bin/maia.cdx.json +145 -0
- package/dist/bin/maia.mjs +2 -0
- package/dist/bootstrap/index.d.ts +3 -0
- package/dist/bootstrap/index.js +3 -0
- package/dist/bootstrap/process.d.ts +5 -0
- package/dist/bootstrap/process.js +45 -0
- package/dist/bootstrap/run.d.ts +25 -0
- package/dist/bootstrap/run.js +95 -0
- package/dist/bootstrap/stdio.d.ts +4 -0
- package/dist/bootstrap/stdio.js +9 -0
- package/dist/cli/cli.d.ts +17 -0
- package/dist/cli/cli.js +481 -0
- package/dist/cli/environment.d.ts +8 -0
- package/dist/cli/environment.js +12 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/services.d.ts +4 -0
- package/dist/cli/services.js +4 -0
- package/dist/command-line/context.d.ts +178 -0
- package/dist/command-line/context.js +2 -0
- package/dist/command-line/index.d.ts +7 -0
- package/dist/command-line/index.js +6 -0
- package/dist/command-line/input/arguments.d.ts +55 -0
- package/dist/command-line/input/arguments.js +220 -0
- package/dist/command-line/input/index.d.ts +4 -0
- package/dist/command-line/input/index.js +4 -0
- package/dist/command-line/input/prompt.d.ts +8 -0
- package/dist/command-line/input/prompt.js +44 -0
- package/dist/command-line/input/stdin-stream.d.ts +4 -0
- package/dist/command-line/input/stdin-stream.js +3 -0
- package/dist/command-line/input/stdin.d.ts +11 -0
- package/dist/command-line/input/stdin.js +23 -0
- package/dist/command-line/json-decoder.d.ts +3 -0
- package/dist/command-line/json-decoder.js +3 -0
- package/dist/command-line/json.d.ts +3 -0
- package/dist/command-line/json.js +4 -0
- package/dist/command-line/output.d.ts +57 -0
- package/dist/command-line/output.js +94 -0
- package/dist/command-line/rows.d.ts +10 -0
- package/dist/command-line/rows.js +32 -0
- package/dist/command-line/two-phase.d.ts +57 -0
- package/dist/command-line/two-phase.js +148 -0
- package/dist/command-receipt/command.d.ts +4 -0
- package/dist/command-receipt/command.js +59 -0
- package/dist/command-receipt/compact-list.d.ts +20 -0
- package/dist/command-receipt/compact-list.js +29 -0
- package/dist/command-receipt/index.d.ts +3 -0
- package/dist/command-receipt/index.js +3 -0
- package/dist/command-tree/commands.d.ts +17 -0
- package/dist/command-tree/commands.js +41 -0
- package/dist/command-tree/completion.d.ts +6 -0
- package/dist/command-tree/completion.js +36 -0
- package/dist/command-tree/grammar.d.ts +18 -0
- package/dist/command-tree/grammar.js +160 -0
- package/dist/command-tree/help.d.ts +62 -0
- package/dist/command-tree/help.js +219 -0
- package/dist/command-tree/index.d.ts +8 -0
- package/dist/command-tree/index.js +6 -0
- package/dist/command-tree/local.d.ts +3 -0
- package/dist/command-tree/local.js +126 -0
- package/dist/command-tree/placeholder.d.ts +3 -0
- package/dist/command-tree/placeholder.js +4 -0
- package/dist/command-tree/row.d.ts +29 -0
- package/dist/command-tree/row.js +2 -0
- package/dist/command-tree/suggest.d.ts +3 -0
- package/dist/command-tree/suggest.js +81 -0
- package/dist/command-tree/tree.d.ts +34 -0
- package/dist/command-tree/tree.js +124 -0
- package/dist/connection/client.d.ts +692 -0
- package/dist/connection/client.js +28 -0
- package/dist/connection/commands.d.ts +15 -0
- package/dist/connection/commands.js +118 -0
- package/dist/connection/index.d.ts +7 -0
- package/dist/connection/index.js +7 -0
- package/dist/connection/input.d.ts +50 -0
- package/dist/connection/input.js +90 -0
- package/dist/connection/login.d.ts +13 -0
- package/dist/connection/login.js +69 -0
- package/dist/connection/output/format.d.ts +32 -0
- package/dist/connection/output/format.js +94 -0
- package/dist/connection/output/index.d.ts +2 -0
- package/dist/connection/output/index.js +2 -0
- package/dist/connection/resolve.d.ts +60 -0
- package/dist/connection/resolve.js +30 -0
- package/dist/connection/signin.d.ts +4 -0
- package/dist/connection/signin.js +32 -0
- package/dist/connection/system.d.ts +4 -0
- package/dist/connection/system.js +190 -0
- package/dist/connection/tree/index.d.ts +2 -0
- package/dist/connection/tree/index.js +2 -0
- package/dist/connection/tree/tree.d.ts +3 -0
- package/dist/connection/tree/tree.js +209 -0
- package/dist/container/client.d.ts +142 -0
- package/dist/container/client.js +11 -0
- package/dist/container/commands.d.ts +7 -0
- package/dist/container/commands.js +100 -0
- package/dist/container/index.d.ts +3 -0
- package/dist/container/index.js +3 -0
- package/dist/container/output/format.d.ts +11 -0
- package/dist/container/output/format.js +28 -0
- package/dist/container/output/index.d.ts +2 -0
- package/dist/container/output/index.js +2 -0
- package/dist/context/client.d.ts +7 -0
- package/dist/context/client.js +21 -0
- package/dist/context/commands.d.ts +3 -0
- package/dist/context/commands.js +27 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/index.js +3 -0
- package/dist/development/cli.d.ts +3 -0
- package/dist/development/cli.js +44 -0
- package/dist/execution/client.d.ts +25 -0
- package/dist/execution/client.js +24 -0
- package/dist/execution/index.d.ts +3 -0
- package/dist/execution/index.js +3 -0
- package/dist/execution/relocation.d.ts +6 -0
- package/dist/execution/relocation.js +123 -0
- package/dist/execution/tree/index.d.ts +2 -0
- package/dist/execution/tree/index.js +2 -0
- package/dist/execution/tree/tree.d.ts +3 -0
- package/dist/execution/tree/tree.js +137 -0
- package/dist/hold/client.d.ts +137 -0
- package/dist/hold/client.js +12 -0
- package/dist/hold/commands.d.ts +5 -0
- package/dist/hold/commands.js +91 -0
- package/dist/hold/index.d.ts +3 -0
- package/dist/hold/index.js +3 -0
- package/dist/hold/output/format.d.ts +11 -0
- package/dist/hold/output/format.js +29 -0
- package/dist/hold/output/index.d.ts +2 -0
- package/dist/hold/output/index.js +2 -0
- package/dist/hold/tree/index.d.ts +2 -0
- package/dist/hold/tree/index.js +2 -0
- package/dist/hold/tree/tree.d.ts +3 -0
- package/dist/hold/tree/tree.js +96 -0
- package/dist/import/client.d.ts +14 -0
- package/dist/import/client.js +16 -0
- package/dist/import/commands.d.ts +5 -0
- package/dist/import/commands.js +76 -0
- package/dist/import/index.d.ts +3 -0
- package/dist/import/index.js +3 -0
- package/dist/import/input.d.ts +16 -0
- package/dist/import/input.js +92 -0
- package/dist/import/output.d.ts +6 -0
- package/dist/import/output.js +40 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/integration/client.d.ts +1284 -0
- package/dist/integration/client.js +24 -0
- package/dist/integration/commands.d.ts +10 -0
- package/dist/integration/commands.js +104 -0
- package/dist/integration/index.d.ts +3 -0
- package/dist/integration/index.js +3 -0
- package/dist/integration/output.d.ts +22 -0
- package/dist/integration/output.js +20 -0
- package/dist/local-node/call.d.ts +7 -0
- package/dist/local-node/call.js +13 -0
- package/dist/local-node/client.d.ts +67 -0
- package/dist/local-node/client.js +241 -0
- package/dist/local-node/index.d.ts +3 -0
- package/dist/local-node/index.js +3 -0
- package/dist/login/agent-provider.d.ts +20 -0
- package/dist/login/agent-provider.js +109 -0
- package/dist/login/commands.d.ts +4 -0
- package/dist/login/commands.js +93 -0
- package/dist/login/failure.d.ts +3 -0
- package/dist/login/failure.js +14 -0
- package/dist/login/gateway.d.ts +12 -0
- package/dist/login/gateway.js +71 -0
- package/dist/login/index.d.ts +3 -0
- package/dist/login/index.js +2 -0
- package/dist/login/menu.d.ts +4 -0
- package/dist/login/menu.js +105 -0
- package/dist/login/output/format.d.ts +16 -0
- package/dist/login/output/format.js +31 -0
- package/dist/login/output/index.d.ts +2 -0
- package/dist/login/output/index.js +2 -0
- package/dist/login/vendor-account.d.ts +95 -0
- package/dist/login/vendor-account.js +75 -0
- package/dist/login/vendor-input.d.ts +14 -0
- package/dist/login/vendor-input.js +36 -0
- package/dist/mcp/calls.d.ts +7 -0
- package/dist/mcp/calls.js +202 -0
- package/dist/mcp/commands.d.ts +9 -0
- package/dist/mcp/commands.js +21 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +2 -0
- package/dist/mcp/server.d.ts +11 -0
- package/dist/mcp/server.js +57 -0
- package/dist/orchestration/client.d.ts +78 -0
- package/dist/orchestration/client.js +89 -0
- package/dist/orchestration/commands.d.ts +14 -0
- package/dist/orchestration/commands.js +312 -0
- package/dist/orchestration/index.d.ts +3 -0
- package/dist/orchestration/index.js +3 -0
- package/dist/orchestration/output/compact-aggregate.d.ts +121 -0
- package/dist/orchestration/output/compact-aggregate.js +110 -0
- package/dist/orchestration/output/compact-run-list.d.ts +20 -0
- package/dist/orchestration/output/compact-run-list.js +16 -0
- package/dist/orchestration/output/human.d.ts +80 -0
- package/dist/orchestration/output/human.js +252 -0
- package/dist/orchestration/output/index.d.ts +4 -0
- package/dist/orchestration/output/index.js +4 -0
- package/dist/orchestration/tree/index.d.ts +2 -0
- package/dist/orchestration/tree/index.js +2 -0
- package/dist/orchestration/tree/tree.d.ts +3 -0
- package/dist/orchestration/tree/tree.js +142 -0
- package/dist/port-lease/client.d.ts +160 -0
- package/dist/port-lease/client.js +11 -0
- package/dist/port-lease/commands.d.ts +6 -0
- package/dist/port-lease/commands.js +17 -0
- package/dist/port-lease/index.d.ts +3 -0
- package/dist/port-lease/index.js +3 -0
- package/dist/port-lease/input.d.ts +65 -0
- package/dist/port-lease/input.js +67 -0
- package/dist/port-lease/output/format.d.ts +11 -0
- package/dist/port-lease/output/format.js +24 -0
- package/dist/port-lease/output/index.d.ts +2 -0
- package/dist/port-lease/output/index.js +2 -0
- package/dist/presentation/client.d.ts +10 -0
- package/dist/presentation/client.js +9 -0
- package/dist/presentation/commands.d.ts +6 -0
- package/dist/presentation/commands.js +78 -0
- package/dist/presentation/index.d.ts +4 -0
- package/dist/presentation/index.js +3 -0
- package/dist/presentation/output/format.d.ts +11 -0
- package/dist/presentation/output/format.js +32 -0
- package/dist/presentation/output/index.d.ts +3 -0
- package/dist/presentation/output/index.js +2 -0
- package/dist/project-guard/client.d.ts +88 -0
- package/dist/project-guard/client.js +7 -0
- package/dist/project-guard/commands.d.ts +4 -0
- package/dist/project-guard/commands.js +39 -0
- package/dist/project-guard/index.d.ts +3 -0
- package/dist/project-guard/index.js +3 -0
- package/dist/project-guard/input.d.ts +18 -0
- package/dist/project-guard/input.js +47 -0
- package/dist/project-guard/output/format.d.ts +11 -0
- package/dist/project-guard/output/format.js +35 -0
- package/dist/project-guard/output/index.d.ts +2 -0
- package/dist/project-guard/output/index.js +2 -0
- package/dist/project-workspace/client.d.ts +86 -0
- package/dist/project-workspace/client.js +159 -0
- package/dist/project-workspace/commands.d.ts +30 -0
- package/dist/project-workspace/commands.js +700 -0
- package/dist/project-workspace/index.d.ts +5 -0
- package/dist/project-workspace/index.js +5 -0
- package/dist/project-workspace/metadata-client.d.ts +99 -0
- package/dist/project-workspace/metadata-client.js +8 -0
- package/dist/project-workspace/metadata-commands.d.ts +4 -0
- package/dist/project-workspace/metadata-commands.js +56 -0
- package/dist/project-workspace/output/human.d.ts +126 -0
- package/dist/project-workspace/output/human.js +103 -0
- package/dist/project-workspace/output/index.d.ts +3 -0
- package/dist/project-workspace/output/index.js +3 -0
- package/dist/project-workspace/output/metadata.d.ts +11 -0
- package/dist/project-workspace/output/metadata.js +17 -0
- package/dist/project-workspace/tree/index.d.ts +2 -0
- package/dist/project-workspace/tree/index.js +2 -0
- package/dist/project-workspace/tree/tree.d.ts +3 -0
- package/dist/project-workspace/tree/tree.js +197 -0
- package/dist/provider/client.d.ts +6 -0
- package/dist/provider/client.js +5 -0
- package/dist/provider/commands.d.ts +3 -0
- package/dist/provider/commands.js +38 -0
- package/dist/provider/index.d.ts +3 -0
- package/dist/provider/index.js +3 -0
- package/dist/reference/commands.d.ts +3 -0
- package/dist/reference/commands.js +39 -0
- package/dist/reference/index.d.ts +3 -0
- package/dist/reference/index.js +3 -0
- package/dist/reference/resolve.d.ts +29 -0
- package/dist/reference/resolve.js +294 -0
- package/dist/reference/tree/index.d.ts +2 -0
- package/dist/reference/tree/index.js +2 -0
- package/dist/reference/tree/tree.d.ts +3 -0
- package/dist/reference/tree/tree.js +17 -0
- package/dist/remote-node/client.d.ts +258 -0
- package/dist/remote-node/client.js +12 -0
- package/dist/remote-node/commands.d.ts +6 -0
- package/dist/remote-node/commands.js +264 -0
- package/dist/remote-node/connector.d.ts +59 -0
- package/dist/remote-node/connector.js +122 -0
- package/dist/remote-node/index.d.ts +4 -0
- package/dist/remote-node/index.js +4 -0
- package/dist/remote-node/reachability.d.ts +22 -0
- package/dist/remote-node/reachability.js +34 -0
- package/dist/remote-node/text.d.ts +9 -0
- package/dist/remote-node/text.js +64 -0
- package/dist/remote-node/tree/index.d.ts +2 -0
- package/dist/remote-node/tree/index.js +2 -0
- package/dist/remote-node/tree/tree.d.ts +3 -0
- package/dist/remote-node/tree/tree.js +51 -0
- package/dist/run-ledger/client.d.ts +358 -0
- package/dist/run-ledger/client.js +13 -0
- package/dist/run-ledger/commands.d.ts +8 -0
- package/dist/run-ledger/commands.js +19 -0
- package/dist/run-ledger/index.d.ts +3 -0
- package/dist/run-ledger/index.js +3 -0
- package/dist/run-ledger/input.d.ts +42 -0
- package/dist/run-ledger/input.js +107 -0
- package/dist/run-ledger/output/format.d.ts +11 -0
- package/dist/run-ledger/output/format.js +49 -0
- package/dist/run-ledger/output/index.d.ts +2 -0
- package/dist/run-ledger/output/index.js +2 -0
- package/dist/session/agent-permission.d.ts +63 -0
- package/dist/session/agent-permission.js +20 -0
- package/dist/session/approval/client.d.ts +117 -0
- package/dist/session/approval/client.js +7 -0
- package/dist/session/approval/commands.d.ts +7 -0
- package/dist/session/approval/commands.js +123 -0
- package/dist/session/approval/index.d.ts +3 -0
- package/dist/session/approval/index.js +3 -0
- package/dist/session/approval/output/format.d.ts +12 -0
- package/dist/session/approval/output/format.js +25 -0
- package/dist/session/approval/output/index.d.ts +2 -0
- package/dist/session/approval/output/index.js +2 -0
- package/dist/session/attach-client.d.ts +16 -0
- package/dist/session/attach-client.js +8 -0
- package/dist/session/attach-render.d.ts +16 -0
- package/dist/session/attach-render.js +154 -0
- package/dist/session/attach.d.ts +5 -0
- package/dist/session/attach.js +106 -0
- package/dist/session/client.d.ts +132 -0
- package/dist/session/client.js +128 -0
- package/dist/session/coding-client.d.ts +16 -0
- package/dist/session/coding-client.js +15 -0
- package/dist/session/coding-commands.d.ts +4 -0
- package/dist/session/coding-commands.js +50 -0
- package/dist/session/commands.d.ts +13 -0
- package/dist/session/commands.js +488 -0
- package/dist/session/create-tasks.d.ts +20 -0
- package/dist/session/create-tasks.js +110 -0
- package/dist/session/index.d.ts +9 -0
- package/dist/session/index.js +7 -0
- package/dist/session/interaction/client.d.ts +347 -0
- package/dist/session/interaction/client.js +15 -0
- package/dist/session/interaction/commands.d.ts +7 -0
- package/dist/session/interaction/commands.js +101 -0
- package/dist/session/interaction/index.d.ts +3 -0
- package/dist/session/interaction/index.js +3 -0
- package/dist/session/interaction/input.d.ts +15 -0
- package/dist/session/interaction/input.js +46 -0
- package/dist/session/interaction/output/format.d.ts +11 -0
- package/dist/session/interaction/output/format.js +3 -0
- package/dist/session/interaction/output/index.d.ts +2 -0
- package/dist/session/interaction/output/index.js +2 -0
- package/dist/session/output/diff.d.ts +3 -0
- package/dist/session/output/diff.js +30 -0
- package/dist/session/output/failure.d.ts +11 -0
- package/dist/session/output/failure.js +24 -0
- package/dist/session/output/human.d.ts +112 -0
- package/dist/session/output/human.js +71 -0
- package/dist/session/output/index.d.ts +6 -0
- package/dist/session/output/index.js +6 -0
- package/dist/session/output/observe.d.ts +4 -0
- package/dist/session/output/observe.js +46 -0
- package/dist/session/output/tasks.d.ts +19 -0
- package/dist/session/output/tasks.js +34 -0
- package/dist/session/rename.d.ts +3 -0
- package/dist/session/rename.js +37 -0
- package/dist/session/task-file.d.ts +5 -0
- package/dist/session/task-file.js +23 -0
- package/dist/session/tree/index.d.ts +2 -0
- package/dist/session/tree/index.js +2 -0
- package/dist/session/tree/tree.d.ts +3 -0
- package/dist/session/tree/tree.js +309 -0
- package/dist/session/turn/client.d.ts +25 -0
- package/dist/session/turn/client.js +40 -0
- package/dist/session/turn/commands.d.ts +6 -0
- package/dist/session/turn/commands.js +157 -0
- package/dist/session/turn/index.d.ts +4 -0
- package/dist/session/turn/index.js +3 -0
- package/dist/session/turn/output.d.ts +42 -0
- package/dist/session/turn/output.js +38 -0
- package/dist/status/client.d.ts +119 -0
- package/dist/status/client.js +5 -0
- package/dist/status/command.d.ts +4 -0
- package/dist/status/command.js +40 -0
- package/dist/status/doctor.d.ts +15 -0
- package/dist/status/doctor.js +111 -0
- package/dist/status/index.d.ts +5 -0
- package/dist/status/index.js +4 -0
- package/dist/status/output/compact.d.ts +31 -0
- package/dist/status/output/compact.js +46 -0
- package/dist/status/output/human.d.ts +7 -0
- package/dist/status/output/human.js +30 -0
- package/dist/status/output/index.d.ts +3 -0
- package/dist/status/output/index.js +3 -0
- package/dist/terminal/arguments.d.ts +13 -0
- package/dist/terminal/arguments.js +79 -0
- package/dist/terminal/client.d.ts +79 -0
- package/dist/terminal/client.js +68 -0
- package/dist/terminal/commands.d.ts +7 -0
- package/dist/terminal/commands.js +131 -0
- package/dist/terminal/control-commands.d.ts +10 -0
- package/dist/terminal/control-commands.js +212 -0
- package/dist/terminal/index.d.ts +4 -0
- package/dist/terminal/index.js +4 -0
- package/dist/terminal/output/compact-list.d.ts +147 -0
- package/dist/terminal/output/compact-list.js +152 -0
- package/dist/terminal/output/human.d.ts +59 -0
- package/dist/terminal/output/human.js +55 -0
- package/dist/terminal/output/index.d.ts +3 -0
- package/dist/terminal/output/index.js +3 -0
- package/dist/terminal/tree/index.d.ts +2 -0
- package/dist/terminal/tree/index.js +2 -0
- package/dist/terminal/tree/tree.d.ts +3 -0
- package/dist/terminal/tree/tree.js +104 -0
- package/guidance/maia-cli/SKILL.md +58 -0
- package/guidance/maia-orchestration/SKILL.md +54 -0
- package/package.json +76 -0
|
@@ -0,0 +1,122 @@
|
|
|
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, openNodeBridge, shellQuote, sshCommandArguments, } from "@maiaos/sdk/node/effect";
|
|
7
|
+
import * as Duration from "effect/Duration";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Layer from "effect/Layer";
|
|
10
|
+
import * as ChildProcess from "effect/process/ChildProcess";
|
|
11
|
+
import * as Scope from "effect/Scope";
|
|
12
|
+
import * as Stream from "effect/Stream";
|
|
13
|
+
import { connectLocalNode, discoveryOptionsFor, newCliIdentifier, } from "../local-node/index.js";
|
|
14
|
+
const spawner = NodeChildProcessSpawner.layer.pipe(Layer.provide(Layer.merge(NodeFileSystem.layer, NodePath.layer)));
|
|
15
|
+
const BRIDGE_DEADLINE = Duration.seconds(30);
|
|
16
|
+
const unreachable = (name, reason) => new MaiaClientError("transport_failure", reason, {
|
|
17
|
+
remoteError: {
|
|
18
|
+
code: "node_unavailable",
|
|
19
|
+
message: `Remote Node ${name}: ${reason}`,
|
|
20
|
+
retryable: true,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
export const readRemoteNode = (connector, options, name) => Effect.gen(function* () {
|
|
24
|
+
const local = yield* connector(options);
|
|
25
|
+
const messageId = yield* newCliIdentifier("request");
|
|
26
|
+
const listed = yield* local.client.listRemoteNodes({}, { messageId });
|
|
27
|
+
const node = listed.nodes.find((candidate) => candidate.name === name);
|
|
28
|
+
if (node === undefined)
|
|
29
|
+
return yield* Effect.fail(unreachable(name, "no Node has this name; see maia node list."));
|
|
30
|
+
return node;
|
|
31
|
+
});
|
|
32
|
+
const STDERR_TAIL_BYTES = 512;
|
|
33
|
+
const spawnBridge = (node) => ChildProcess.make("ssh", sshCommandArguments({
|
|
34
|
+
host: node.host,
|
|
35
|
+
script: bridgeScript(node.launcherPath),
|
|
36
|
+
}), { stderr: "pipe", stdin: "pipe", stdout: "pipe" });
|
|
37
|
+
const keepStderrTail = (stderr, tail) => stderr.pipe(Stream.decodeText(), Stream.runForEach((chunk) => Effect.sync(() => {
|
|
38
|
+
tail.text = `${tail.text}${chunk}`.slice(-STDERR_TAIL_BYTES);
|
|
39
|
+
})), Effect.ignore, Effect.forkScoped);
|
|
40
|
+
const reasonOf = (error, tail) => {
|
|
41
|
+
const said = tail.trim().split("\n").at(-1) ?? "";
|
|
42
|
+
return said === "" ? `${error.message}.` : `${error.message}: ${said}`;
|
|
43
|
+
};
|
|
44
|
+
const asRecorded = (node, bridge) => {
|
|
45
|
+
const { client, closed, hello } = bridge;
|
|
46
|
+
return hello.status.profile === node.profile
|
|
47
|
+
? Effect.succeed({
|
|
48
|
+
client,
|
|
49
|
+
closed,
|
|
50
|
+
status: hello.status,
|
|
51
|
+
version: hello.version,
|
|
52
|
+
})
|
|
53
|
+
: Effect.fail(unreachable(node.name, "the bridge answers for another profile."));
|
|
54
|
+
};
|
|
55
|
+
export const openRemoteBridge = (node, scope) => {
|
|
56
|
+
if (node.state !== "ready")
|
|
57
|
+
return Effect.fail(unreachable(node.name, `it is ${node.state}, not ready.`));
|
|
58
|
+
const tail = { text: "" };
|
|
59
|
+
return Effect.gen(function* () {
|
|
60
|
+
const handle = yield* spawnBridge(node);
|
|
61
|
+
yield* keepStderrTail(handle.stderr, tail);
|
|
62
|
+
const bridge = yield* openNodeBridge(handle, {
|
|
63
|
+
helloDeadline: BRIDGE_DEADLINE,
|
|
64
|
+
});
|
|
65
|
+
return yield* asRecorded(node, bridge);
|
|
66
|
+
}).pipe(Effect.provide(spawner), Effect.provideService(Scope.Scope, scope), Effect.mapError((error) => error instanceof MaiaClientError
|
|
67
|
+
? error
|
|
68
|
+
: unreachable(node.name, reasonOf(error, tail.text))));
|
|
69
|
+
};
|
|
70
|
+
export const makeRemoteNodeConnector = (input) => {
|
|
71
|
+
const local = input.local ?? connectLocalNode;
|
|
72
|
+
const cache = {};
|
|
73
|
+
const open = (options) => Effect.gen(function* () {
|
|
74
|
+
const cached = cache.bridge;
|
|
75
|
+
if (cached !== undefined && !(yield* cached.closed))
|
|
76
|
+
return cached;
|
|
77
|
+
const node = yield* readRemoteNode(local, options, input.name);
|
|
78
|
+
const bridge = yield* openRemoteBridge(node, input.scope);
|
|
79
|
+
cache.bridge = bridge;
|
|
80
|
+
return bridge;
|
|
81
|
+
});
|
|
82
|
+
return (options) => open(options).pipe(Effect.map((bridge) => ({
|
|
83
|
+
client: bridge.client,
|
|
84
|
+
status: bridge.status,
|
|
85
|
+
})));
|
|
86
|
+
};
|
|
87
|
+
const vendorCommand = (executor) => executor === "codex-cli"
|
|
88
|
+
? { arguments_: "login --device-auth", variable: "CODEX_HOME" }
|
|
89
|
+
: { arguments_: "auth login", variable: "CLAUDE_CONFIG_DIR" };
|
|
90
|
+
const directoryOf = (path) => path.slice(0, Math.max(1, path.lastIndexOf("/")));
|
|
91
|
+
export const remoteSignInScript = (node, connection) => {
|
|
92
|
+
const pinned = node.executors.find((executor) => executor.executor === connection.executor);
|
|
93
|
+
if (pinned?.state !== "available" || pinned.path === undefined)
|
|
94
|
+
return undefined;
|
|
95
|
+
const vendor = vendorCommand(connection.executor);
|
|
96
|
+
const path = [
|
|
97
|
+
directoryOf(pinned.path),
|
|
98
|
+
...(pinned.interpreter === undefined
|
|
99
|
+
? []
|
|
100
|
+
: [directoryOf(pinned.interpreter.path)]),
|
|
101
|
+
"/usr/local/bin",
|
|
102
|
+
"/usr/bin",
|
|
103
|
+
"/bin",
|
|
104
|
+
].join(":");
|
|
105
|
+
const account = connection.configRoot.kind === "maia-managed"
|
|
106
|
+
? `${vendor.variable}=${shellQuote(connection.configRoot.path)} `
|
|
107
|
+
: "";
|
|
108
|
+
return `exec env PATH=${shellQuote(path)} ${account}${shellQuote(pinned.path)} ${vendor.arguments_}`;
|
|
109
|
+
};
|
|
110
|
+
const signInOver = (node, connection) => Effect.gen(function* () {
|
|
111
|
+
const script = remoteSignInScript(node, connection);
|
|
112
|
+
if (script === undefined)
|
|
113
|
+
return yield* Effect.fail(unreachable(node.name, `no pinned ${connection.executor} binary is available there.`));
|
|
114
|
+
const handle = yield* ChildProcess.make("ssh", sshCommandArguments({ host: node.host, script, terminal: true }), { stderr: "inherit", stdin: "inherit", stdout: "inherit" });
|
|
115
|
+
return yield* handle.exitCode.pipe(Effect.map(Number), Effect.orElseSucceed(() => 1));
|
|
116
|
+
});
|
|
117
|
+
export const remoteVendorLogin = (input) => (connection) => Effect.gen(function* () {
|
|
118
|
+
const options = yield* discoveryOptionsFor(input.profile);
|
|
119
|
+
const node = yield* readRemoteNode(input.connector ?? connectLocalNode, options, input.name);
|
|
120
|
+
return yield* signInOver(node, connection);
|
|
121
|
+
}).pipe(Effect.scoped, Effect.provide(Layer.merge(spawner, NodeCrypto.layer)));
|
|
122
|
+
//# sourceMappingURL=connector.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { makeRemoteNodeClient, type RemoteNodeCliDependencies, } from "./client.js";
|
|
2
|
+
export { runNodeInstall, runNodeList, runNodeRemove } from "./commands.js";
|
|
3
|
+
export { makeRemoteNodeConnector, remoteVendorLogin } from "./connector.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { RemoteNodeRecord } from "@maiaos/sdk";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
export type Reachability = {
|
|
4
|
+
readonly latencyMs: number;
|
|
5
|
+
readonly pid: number;
|
|
6
|
+
readonly state: "reachable";
|
|
7
|
+
readonly version: string;
|
|
8
|
+
} | {
|
|
9
|
+
readonly reason: string;
|
|
10
|
+
readonly state: "not_checked";
|
|
11
|
+
} | {
|
|
12
|
+
readonly reason: string;
|
|
13
|
+
readonly state: "stale";
|
|
14
|
+
} | {
|
|
15
|
+
readonly reason: string;
|
|
16
|
+
readonly state: "unknown";
|
|
17
|
+
} | {
|
|
18
|
+
readonly reason: string;
|
|
19
|
+
readonly state: "unreachable";
|
|
20
|
+
};
|
|
21
|
+
export declare const checkReachability: (node: RemoteNodeRecord) => Effect.Effect<Reachability>;
|
|
22
|
+
//# sourceMappingURL=reachability.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
pid: bridge.status.pid,
|
|
10
|
+
state: "reachable",
|
|
11
|
+
version: bridge.version,
|
|
12
|
+
}
|
|
13
|
+
: {
|
|
14
|
+
reason: `it answers as maia-node ${bridge.version}, recorded ${node.maiaVersion}`,
|
|
15
|
+
state: "stale",
|
|
16
|
+
};
|
|
17
|
+
export const checkReachability = (node) => node.state === "ready"
|
|
18
|
+
? Effect.gen(function* () {
|
|
19
|
+
const started = yield* Clock.currentTimeMillis;
|
|
20
|
+
const bridge = yield* Effect.flatMap(Effect.scope, (scope) => openRemoteBridge(node, scope));
|
|
21
|
+
const finished = yield* Clock.currentTimeMillis;
|
|
22
|
+
return greeted(node, bridge, finished - started);
|
|
23
|
+
}).pipe(Effect.scoped, Effect.timeoutOrElse({
|
|
24
|
+
duration: CHECK_DEADLINE,
|
|
25
|
+
orElse: () => Effect.succeed({
|
|
26
|
+
reason: `no answer within ${Duration.format(CHECK_DEADLINE)}`,
|
|
27
|
+
state: "unknown",
|
|
28
|
+
}),
|
|
29
|
+
}), Effect.catch((error) => Effect.succeed({
|
|
30
|
+
reason: error.message,
|
|
31
|
+
state: "unreachable",
|
|
32
|
+
})))
|
|
33
|
+
: Effect.succeed({ reason: `it is ${node.state}`, state: "not_checked" });
|
|
34
|
+
//# sourceMappingURL=reachability.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RemoteNodeInstallPreviewResult, RemoteNodeRecord } from "@maiaos/sdk";
|
|
2
|
+
import type { Reachability } from "./reachability.js";
|
|
3
|
+
export declare const planText: (preview: RemoteNodeInstallPreviewResult) => string;
|
|
4
|
+
export declare const installedText: (node: RemoteNodeRecord) => string;
|
|
5
|
+
export declare const removedText: (node: RemoteNodeRecord) => string;
|
|
6
|
+
export declare const listText: (nodes: readonly (RemoteNodeRecord & {
|
|
7
|
+
readonly reachability: Reachability;
|
|
8
|
+
})[]) => string;
|
|
9
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { formatRows } from "../command-line/index.js";
|
|
2
|
+
const CONTROL = /[^\P{Cc}\t\n]|[--]/gu;
|
|
3
|
+
const printable = (text) => text.replaceAll(CONTROL, "?");
|
|
4
|
+
const mebibytes = (bytes) => `${(bytes / 1_048_576).toFixed(1)} MiB`;
|
|
5
|
+
const executorLine = (executor) => {
|
|
6
|
+
const name = executor.executor === "codex-cli" ? "codex " : "claude";
|
|
7
|
+
if (executor.state === "unavailable")
|
|
8
|
+
return ` ${name} unavailable: ${executor.reason ?? "unknown"}`;
|
|
9
|
+
const interpreter = executor.interpreter === undefined
|
|
10
|
+
? ""
|
|
11
|
+
: ` (node ${executor.interpreter.path})`;
|
|
12
|
+
return ` ${name} ${executor.path ?? ""} sha256:${(executor.sha256 ?? "").slice(0, 12)}${interpreter}`;
|
|
13
|
+
};
|
|
14
|
+
const changeLines = (plan) => plan.executorChanges.map((change) => ` changed ${change.executor}: ${change.from?.path ?? "none"} -> ${change.to?.path ?? "none"}`);
|
|
15
|
+
const readyPlan = (preview) => {
|
|
16
|
+
const { name, plan } = preview;
|
|
17
|
+
return [
|
|
18
|
+
`Plan (${plan.mode}) for ${name}: maia-node ${plan.maiaVersion}, release ${plan.releaseId}, upload ${mebibytes(plan.uploadBytes)}`,
|
|
19
|
+
` root ${plan.root} profile ${plan.profile} unit ${plan.unitName}`,
|
|
20
|
+
` bridge ${plan.launcherPath}`,
|
|
21
|
+
` PATH ${plan.path}`,
|
|
22
|
+
` maia ${plan.cli.path} (worker MCP; maia.mjs sha256:${plan.cli.sha256.slice(0, 12)})`,
|
|
23
|
+
...plan.executors.map(executorLine),
|
|
24
|
+
...changeLines(plan),
|
|
25
|
+
...(plan.prune.releases.length === 0
|
|
26
|
+
? []
|
|
27
|
+
: [` prune ${plan.prune.releases.join(", ")}`]),
|
|
28
|
+
"",
|
|
29
|
+
].join("\n");
|
|
30
|
+
};
|
|
31
|
+
export const planText = (preview) => {
|
|
32
|
+
if (preview.state === "ready")
|
|
33
|
+
return printable(readyPlan(preview));
|
|
34
|
+
if (preview.state === "probing")
|
|
35
|
+
return "Still probing.\n";
|
|
36
|
+
return printable([
|
|
37
|
+
`The host cannot run a contained Maia Node (${preview.facts.distro || preview.facts.os}, Linux ${preview.facts.kernel}):`,
|
|
38
|
+
...preview.blockers.map((blocker) => ` - ${blocker.code}: ${blocker.message}${blocker.remedy === undefined ? "" : `\n ${blocker.remedy}`}`),
|
|
39
|
+
"",
|
|
40
|
+
].join("\n"));
|
|
41
|
+
};
|
|
42
|
+
const errorLine = (node) => node.error === undefined
|
|
43
|
+
? ""
|
|
44
|
+
: `\n ${node.error.code}: ${node.error.message}`;
|
|
45
|
+
export const installedText = (node) => printable(node.state === "ready"
|
|
46
|
+
? `${node.name} is ready: maia-node ${node.maiaVersion ?? "?"} on ${node.host}.\nNext: maia --node ${node.name} status\n`
|
|
47
|
+
: `${node.name} is ${node.state}.${errorLine(node)}\n`);
|
|
48
|
+
export const removedText = (node) => printable(node.state === "removed"
|
|
49
|
+
? `${node.name} is removed from ${node.host}.${node.remaining === undefined || node.remaining.length === 0 ? "" : `\n Kept on the host: ${node.remaining.join(", ")}`}\n`
|
|
50
|
+
: `${node.name} is ${node.state}.${errorLine(node)}\n`);
|
|
51
|
+
const reachabilityText = (reachability) => reachability.state === "reachable"
|
|
52
|
+
? `reachable pid ${String(reachability.pid)} ${String(reachability.latencyMs)} ms`
|
|
53
|
+
: `${reachability.state}: ${reachability.reason}`;
|
|
54
|
+
export const listText = (nodes) => printable(formatRows(nodes, (node) => [
|
|
55
|
+
node.name,
|
|
56
|
+
node.host,
|
|
57
|
+
node.state,
|
|
58
|
+
node.maiaVersion ?? "-",
|
|
59
|
+
reachabilityText(node.reachability),
|
|
60
|
+
].join("\t"), {
|
|
61
|
+
empty: "No remote Nodes. Add one with: maia node install <host> --release <file> --node-runtime <file>",
|
|
62
|
+
headers: ["NODE", "HOST", "STATE", "VERSION", "REACHABLE"],
|
|
63
|
+
}));
|
|
64
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const remote = () => import("../index.js");
|
|
2
|
+
const status = () => import("../../status/index.js");
|
|
3
|
+
const nodeStatus = [status, "runNodeStatus"];
|
|
4
|
+
export const NODE_TREE = {
|
|
5
|
+
groups: [["node", "This Node, and remote Nodes over SSH (--node <name>)."]],
|
|
6
|
+
leaves: [
|
|
7
|
+
[
|
|
8
|
+
"status",
|
|
9
|
+
0,
|
|
10
|
+
"node.status",
|
|
11
|
+
"Show whether the Node is ready (maia node status).",
|
|
12
|
+
{ example: "maia status", kind: "shortcut", run: nodeStatus },
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
"node status",
|
|
16
|
+
0,
|
|
17
|
+
"node.status",
|
|
18
|
+
"Show whether the Node is ready.",
|
|
19
|
+
{ example: "maia --json node status", run: nodeStatus },
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
"node monitor",
|
|
23
|
+
0,
|
|
24
|
+
"monitor.bootstrap.create",
|
|
25
|
+
"Print a one-time loopback URL for the admin monitor.",
|
|
26
|
+
{ run: [status, "runNodeMonitor"] },
|
|
27
|
+
],
|
|
28
|
+
[
|
|
29
|
+
"node install <host> --release <maia-node.release.json> --node-runtime <node> [--name <name>] [--root <dir>] [--remote-profile <name>] [--keep <2..8>] [--codex-bin <path>] [--claude-bin <path>] [--command-id <id>] [--dry-run | --confirm-stdin | --yes]",
|
|
30
|
+
1,
|
|
31
|
+
["node.remote.install.preview", "node.remote.install.confirm"],
|
|
32
|
+
"Install Maia Node on a remote host over SSH.",
|
|
33
|
+
{ kind: "two-phase", remote: false, run: [remote, "runNodeInstall"] },
|
|
34
|
+
],
|
|
35
|
+
[
|
|
36
|
+
"node list [--all]",
|
|
37
|
+
1,
|
|
38
|
+
"node.remote.list",
|
|
39
|
+
"List registered remote Nodes.",
|
|
40
|
+
{ remote: false, run: [remote, "runNodeList"] },
|
|
41
|
+
],
|
|
42
|
+
[
|
|
43
|
+
"node remove <node> [--purge] [--command-id <id>] [--dry-run | --confirm-stdin | --yes]",
|
|
44
|
+
1,
|
|
45
|
+
["node.remote.remove.preview", "node.remote.remove.confirm"],
|
|
46
|
+
"Remove a registered remote Node.",
|
|
47
|
+
{ kind: "two-phase", remote: false, run: [remote, "runNodeRemove"] },
|
|
48
|
+
],
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=tree.js.map
|