@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,28 @@
|
|
|
1
|
+
import { connectionCapacitySetParametersSchema, connectionCreateParametersSchema, connectionDetectParametersSchema, connectionGatewayCreateParametersSchema, connectionListParametersSchema, connectionLoginStartParametersSchema, connectionModelsListParametersSchema, connectionShowParametersSchema, connectionStateSetParametersSchema, connectionSystemConfirmParametersSchema, connectionSystemPreviewParametersSchema, connectionUsageShowParametersSchema, } from "@maiaos/sdk";
|
|
2
|
+
const readClient = (node) => ({
|
|
3
|
+
listConnectionModels: (input) => node.runValidatedNodeOperation(input, connectionModelsListParametersSchema, (client, parameters, options) => client.listConnectionModels(parameters, options)),
|
|
4
|
+
listConnections: (input) => node.runValidatedNodeOperation(input, connectionListParametersSchema, (client, parameters, options) => client.listConnections(parameters, options)),
|
|
5
|
+
showConnection: (input) => node.runValidatedNodeOperation(input, connectionShowParametersSchema, (client, parameters, options) => client.showConnection(parameters, options)),
|
|
6
|
+
showConnectionUsage: (input) => node.runValidatedNodeOperation(input, connectionUsageShowParametersSchema, (client, parameters, options) => client.showConnectionUsage(parameters, options)),
|
|
7
|
+
});
|
|
8
|
+
const mutationClient = (node) => ({
|
|
9
|
+
createConnection: (input) => node.runValidatedNodeOperation(input, connectionCreateParametersSchema, (client, parameters, options) => client.createConnection(parameters, options), { commandId: input.commandId }),
|
|
10
|
+
setConnectionCapacity: (input) => node.runValidatedNodeOperation(input, connectionCapacitySetParametersSchema, (client, parameters, options) => client.setConnectionCapacity(parameters, options), { commandId: input.commandId }),
|
|
11
|
+
setConnectionState: (input) => node.runValidatedNodeOperation(input, connectionStateSetParametersSchema, (client, parameters, options) => client.setConnectionState(parameters, options), { commandId: input.commandId }),
|
|
12
|
+
});
|
|
13
|
+
const signInClient = (node) => ({
|
|
14
|
+
createGatewayConnection: (input) => node.runValidatedNodeOperation(input, connectionGatewayCreateParametersSchema, (client, parameters, options) => client.createGatewayConnection(parameters, options), { commandId: input.commandId }),
|
|
15
|
+
startConnectionLogin: (input) => node.runValidatedNodeOperation(input, connectionLoginStartParametersSchema, (client, parameters, options) => client.startConnectionLogin(parameters, options), { commandId: input.commandId }),
|
|
16
|
+
});
|
|
17
|
+
const systemClient = (node) => ({
|
|
18
|
+
confirmSystemConnections: (input) => node.runValidatedNodeOperation(input, connectionSystemConfirmParametersSchema, (client, parameters, options) => client.confirmSystemConnections(parameters, options), { commandId: input.commandId }),
|
|
19
|
+
detectConnections: (input) => node.runValidatedNodeOperation(input, connectionDetectParametersSchema, (client, parameters, options) => client.detectConnections(parameters, options)),
|
|
20
|
+
previewSystemConnections: (input) => node.runValidatedNodeOperation(input, connectionSystemPreviewParametersSchema, (client, parameters, options) => client.previewSystemConnections(parameters, options)),
|
|
21
|
+
});
|
|
22
|
+
export const makeConnectionClient = (node) => ({
|
|
23
|
+
...readClient(node),
|
|
24
|
+
...mutationClient(node),
|
|
25
|
+
...signInClient(node),
|
|
26
|
+
...systemClient(node),
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Connection } from "@maiaos/sdk";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { type CommandContext, type CommandEffect } from "../command-line/index.js";
|
|
4
|
+
import type { VendorLoginOptions } from "./login.js";
|
|
5
|
+
export declare const runConnectionCreate: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
6
|
+
export declare const runConnectionList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
7
|
+
export declare const runConnectionShow: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
8
|
+
export declare const runConnectionModelsList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
9
|
+
export declare const runConnectionUsageShow: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
10
|
+
export declare const runConnectionLoginStart: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
11
|
+
export declare const runConnectionCapacitySet: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
12
|
+
export declare const runConnectionEnable: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
13
|
+
export declare const runConnectionDisable: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
14
|
+
export type VendorLogin = (connection: Connection, options: VendorLoginOptions) => Effect.Effect<number, unknown>;
|
|
15
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { connectionCapacitySetParametersSchema, connectionCreateParametersSchema, connectionListParametersSchema, connectionModelsListParametersSchema, connectionShowParametersSchema, connectionStateSetParametersSchema, connectionUsageShowParametersSchema, protocolErrorSchema, } from "@maiaos/sdk";
|
|
2
|
+
import { Cause, Effect } from "effect";
|
|
3
|
+
import { CliArgumentError, reportError, writeSuccess, } from "../command-line/index.js";
|
|
4
|
+
import { fillCommandIdentifier, } from "../local-node/index.js";
|
|
5
|
+
import { readConnectionCapacity, readConnectionCreate, readConnectionList, readConnectionModels, readConnectionState, readConnectionTarget, readConnectionUsage, } from "./input.js";
|
|
6
|
+
import { formatConnectionResult, redactConnectionResult, } from "./output/index.js";
|
|
7
|
+
import { ConnectionNodeError } from "./resolve.js";
|
|
8
|
+
import { signInThroughNode } from "./signin.js";
|
|
9
|
+
const invalidInput = (error) => error instanceof CliArgumentError
|
|
10
|
+
? error
|
|
11
|
+
: new CliArgumentError("Invalid connection input. Use 'maia help connection' for usage.");
|
|
12
|
+
const recoveryFor = (parameters) => typeof parameters === "object" &&
|
|
13
|
+
parameters !== null &&
|
|
14
|
+
"commandId" in parameters &&
|
|
15
|
+
typeof parameters.commandId === "string"
|
|
16
|
+
? { recovery: { commandId: parameters.commandId } }
|
|
17
|
+
: {};
|
|
18
|
+
const boundaryFailure = (parameters) => ({
|
|
19
|
+
error: {
|
|
20
|
+
code: "recovery" in recoveryFor(parameters)
|
|
21
|
+
? "outcome_unknown"
|
|
22
|
+
: "node_unavailable",
|
|
23
|
+
message: "Connection response unavailable. Reconcile the original command before retrying a mutation.",
|
|
24
|
+
retryable: false,
|
|
25
|
+
},
|
|
26
|
+
ok: false,
|
|
27
|
+
...recoveryFor(parameters),
|
|
28
|
+
});
|
|
29
|
+
const request = (spec) => Effect.gen(function* () {
|
|
30
|
+
const parsed = yield* Effect.try({ catch: invalidInput, try: spec.input });
|
|
31
|
+
const filled = yield* fillCommandIdentifier(parsed);
|
|
32
|
+
const parameters = yield* Effect.try({
|
|
33
|
+
catch: invalidInput,
|
|
34
|
+
try: () => spec.parameters.parse(filled),
|
|
35
|
+
});
|
|
36
|
+
const operation = spec.operation;
|
|
37
|
+
if (operation === undefined)
|
|
38
|
+
return yield* Effect.fail(new Error("Missing connection client."));
|
|
39
|
+
const response = yield* operation(parameters).pipe(Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause)
|
|
40
|
+
? Effect.interrupt
|
|
41
|
+
: Effect.succeed(boundaryFailure(parameters))));
|
|
42
|
+
return { parameters, response };
|
|
43
|
+
});
|
|
44
|
+
const writeResponse = (response, parameters, context) => {
|
|
45
|
+
if (!response.ok) {
|
|
46
|
+
const error = protocolErrorSchema.parse(response.error);
|
|
47
|
+
return reportError(error, {
|
|
48
|
+
...context,
|
|
49
|
+
...(error.code === "outcome_unknown" ? recoveryFor(parameters) : {}),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
writeSuccess({
|
|
53
|
+
command: response.value.method,
|
|
54
|
+
result: redactConnectionResult(response.value),
|
|
55
|
+
}, context, formatConnectionResult);
|
|
56
|
+
return 0;
|
|
57
|
+
};
|
|
58
|
+
const invoke = (spec, context) => request(spec).pipe(Effect.map(({ parameters, response }) => writeResponse(response, parameters, context)));
|
|
59
|
+
const usage = (tokens, context) => invoke({
|
|
60
|
+
input: () => {
|
|
61
|
+
const parsed = readConnectionUsage(tokens);
|
|
62
|
+
return {
|
|
63
|
+
connectionId: parsed.connection,
|
|
64
|
+
...(parsed.refresh ? { refresh: true } : {}),
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
operation: context.dependencies.showConnectionUsage,
|
|
68
|
+
parameters: connectionUsageShowParametersSchema,
|
|
69
|
+
}, context);
|
|
70
|
+
const reportFailure = (error, context) => {
|
|
71
|
+
if (error instanceof ConnectionNodeError)
|
|
72
|
+
return reportError(error.error, context);
|
|
73
|
+
return reportError({
|
|
74
|
+
code: error instanceof CliArgumentError
|
|
75
|
+
? "invalid_argument"
|
|
76
|
+
: "internal_error",
|
|
77
|
+
message: error instanceof CliArgumentError
|
|
78
|
+
? error.message
|
|
79
|
+
: "Connection command failed.",
|
|
80
|
+
retryable: false,
|
|
81
|
+
}, context);
|
|
82
|
+
};
|
|
83
|
+
const leaf = (program) => (tokens, context) => Effect.suspend(() => program(tokens, context)).pipe(Effect.catch((error) => Effect.sync(() => reportFailure(error, context))));
|
|
84
|
+
export const runConnectionCreate = leaf((tokens, context) => invoke({
|
|
85
|
+
input: () => readConnectionCreate(tokens),
|
|
86
|
+
operation: context.dependencies.createConnection,
|
|
87
|
+
parameters: connectionCreateParametersSchema,
|
|
88
|
+
}, context));
|
|
89
|
+
export const runConnectionList = leaf((tokens, context) => invoke({
|
|
90
|
+
input: () => readConnectionList(tokens),
|
|
91
|
+
operation: context.dependencies.listConnections,
|
|
92
|
+
parameters: connectionListParametersSchema,
|
|
93
|
+
}, context));
|
|
94
|
+
export const runConnectionShow = leaf((tokens, context) => invoke({
|
|
95
|
+
input: () => readConnectionTarget(tokens),
|
|
96
|
+
operation: context.dependencies.showConnection,
|
|
97
|
+
parameters: connectionShowParametersSchema,
|
|
98
|
+
}, context));
|
|
99
|
+
export const runConnectionModelsList = leaf((tokens, context) => invoke({
|
|
100
|
+
input: () => readConnectionModels(tokens),
|
|
101
|
+
operation: context.dependencies.listConnectionModels,
|
|
102
|
+
parameters: connectionModelsListParametersSchema,
|
|
103
|
+
}, context));
|
|
104
|
+
export const runConnectionUsageShow = leaf(usage);
|
|
105
|
+
export const runConnectionLoginStart = leaf(signInThroughNode);
|
|
106
|
+
export const runConnectionCapacitySet = leaf((tokens, context) => invoke({
|
|
107
|
+
input: () => readConnectionCapacity(tokens),
|
|
108
|
+
operation: context.dependencies.setConnectionCapacity,
|
|
109
|
+
parameters: connectionCapacitySetParametersSchema,
|
|
110
|
+
}, context));
|
|
111
|
+
const stateLeaf = (state) => leaf((tokens, context) => invoke({
|
|
112
|
+
input: () => readConnectionState(tokens, state),
|
|
113
|
+
operation: context.dependencies.setConnectionState,
|
|
114
|
+
parameters: connectionStateSetParametersSchema,
|
|
115
|
+
}, context));
|
|
116
|
+
export const runConnectionEnable = stateLeaf("enabled");
|
|
117
|
+
export const runConnectionDisable = stateLeaf("disabled");
|
|
118
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { type ConnectionCliDependencies, makeConnectionClient, } from "./client.js";
|
|
2
|
+
export { runConnectionCapacitySet, runConnectionCreate, runConnectionDisable, runConnectionEnable, runConnectionList, runConnectionLoginStart, runConnectionModelsList, runConnectionShow, runConnectionUsageShow, type VendorLogin, } from "./commands.js";
|
|
3
|
+
export { runVendorLogin } from "./login.js";
|
|
4
|
+
export { describeConnection, formatConnectionResult, redactConnection, redactConnectionResult, } from "./output/index.js";
|
|
5
|
+
export { callNode, ConnectionNodeError, findConnectionByName, } from "./resolve.js";
|
|
6
|
+
export { runConnectionDetect, runSetup } from "./system.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { makeConnectionClient, } from "./client.js";
|
|
2
|
+
export { runConnectionCapacitySet, runConnectionCreate, runConnectionDisable, runConnectionEnable, runConnectionList, runConnectionLoginStart, runConnectionModelsList, runConnectionShow, runConnectionUsageShow, } from "./commands.js";
|
|
3
|
+
export { runVendorLogin } from "./login.js";
|
|
4
|
+
export { describeConnection, formatConnectionResult, redactConnection, redactConnectionResult, } from "./output/index.js";
|
|
5
|
+
export { callNode, ConnectionNodeError, findConnectionByName, } from "./resolve.js";
|
|
6
|
+
export { runConnectionDetect, runSetup } from "./system.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare const readConnectionCreate: (tokens: readonly string[]) => {
|
|
2
|
+
maxConcurrentSessions?: undefined;
|
|
3
|
+
commandId: string | undefined;
|
|
4
|
+
configRootKind: string;
|
|
5
|
+
executor: string;
|
|
6
|
+
name: string;
|
|
7
|
+
} | {
|
|
8
|
+
maxConcurrentSessions: number;
|
|
9
|
+
commandId: string | undefined;
|
|
10
|
+
configRootKind: string;
|
|
11
|
+
executor: string;
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const readConnectionList: (tokens: readonly string[]) => {
|
|
15
|
+
limit: number;
|
|
16
|
+
afterCursor?: string | undefined;
|
|
17
|
+
};
|
|
18
|
+
export declare const readConnectionTarget: (tokens: readonly string[]) => {
|
|
19
|
+
connectionId: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
export declare const readConnectionCapacity: (tokens: readonly string[]) => {
|
|
22
|
+
maxConcurrentSessions?: undefined;
|
|
23
|
+
commandId: string | undefined;
|
|
24
|
+
connectionId: string | undefined;
|
|
25
|
+
expectedRevision: string;
|
|
26
|
+
} | {
|
|
27
|
+
maxConcurrentSessions: number;
|
|
28
|
+
commandId: string | undefined;
|
|
29
|
+
connectionId: string | undefined;
|
|
30
|
+
expectedRevision: string;
|
|
31
|
+
};
|
|
32
|
+
export declare const readConnectionUsage: (tokens: readonly string[]) => {
|
|
33
|
+
connection: string;
|
|
34
|
+
refresh: boolean;
|
|
35
|
+
};
|
|
36
|
+
export declare const readConnectionSignin: (tokens: readonly string[]) => {
|
|
37
|
+
commandId: string | undefined;
|
|
38
|
+
connection: string;
|
|
39
|
+
flow: "browser" | "device-code";
|
|
40
|
+
};
|
|
41
|
+
export declare const readConnectionState: (tokens: readonly string[], state: "disabled" | "enabled") => {
|
|
42
|
+
commandId: string | undefined;
|
|
43
|
+
connectionId: string | undefined;
|
|
44
|
+
expectedRevision: string;
|
|
45
|
+
state: "disabled" | "enabled";
|
|
46
|
+
};
|
|
47
|
+
export declare const readConnectionModels: (tokens: readonly string[]) => {
|
|
48
|
+
connectionId: string;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { CliArgumentError, parseOptions, readExpectedRevision, readPageSize, requirePositionals, } from "../command-line/index.js";
|
|
2
|
+
const readSessionLimit = (value) => {
|
|
3
|
+
if (value === undefined)
|
|
4
|
+
return {};
|
|
5
|
+
if (!/^(?:[1-9]|1[0-6])$/u.test(value))
|
|
6
|
+
throw new CliArgumentError("Option '--max-sessions' must be an integer from 1 to 16.");
|
|
7
|
+
return { maxConcurrentSessions: Number(value) };
|
|
8
|
+
};
|
|
9
|
+
const requireOption = (options, name) => {
|
|
10
|
+
const value = options.get(name);
|
|
11
|
+
if (value === undefined)
|
|
12
|
+
throw new CliArgumentError(`Option '${name}' is required.`);
|
|
13
|
+
return value;
|
|
14
|
+
};
|
|
15
|
+
export const readConnectionCreate = (tokens) => {
|
|
16
|
+
const parsed = parseOptions(tokens, new Set([
|
|
17
|
+
"--command-id",
|
|
18
|
+
"--executor",
|
|
19
|
+
"--max-sessions",
|
|
20
|
+
"--name",
|
|
21
|
+
"--root",
|
|
22
|
+
]));
|
|
23
|
+
requirePositionals(parsed.positionals, 0);
|
|
24
|
+
return {
|
|
25
|
+
commandId: parsed.options.get("--command-id"),
|
|
26
|
+
configRootKind: requireOption(parsed.options, "--root"),
|
|
27
|
+
executor: requireOption(parsed.options, "--executor"),
|
|
28
|
+
name: requireOption(parsed.options, "--name"),
|
|
29
|
+
...readSessionLimit(parsed.options.get("--max-sessions")),
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export const readConnectionList = (tokens) => {
|
|
33
|
+
const parsed = parseOptions(tokens, new Set(["--after", "--limit"]));
|
|
34
|
+
requirePositionals(parsed.positionals, 0);
|
|
35
|
+
const afterCursor = parsed.options.get("--after");
|
|
36
|
+
return {
|
|
37
|
+
limit: readPageSize(parsed.options.get("--limit")),
|
|
38
|
+
...(afterCursor === undefined ? {} : { afterCursor }),
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export const readConnectionTarget = (tokens) => {
|
|
42
|
+
const parsed = parseOptions(tokens, new Set());
|
|
43
|
+
requirePositionals(parsed.positionals, 1);
|
|
44
|
+
return { connectionId: parsed.positionals[0] };
|
|
45
|
+
};
|
|
46
|
+
export const readConnectionCapacity = (tokens) => {
|
|
47
|
+
const parsed = parseOptions(tokens, new Set(["--command-id", "--expected-revision", "--max-sessions"]));
|
|
48
|
+
requirePositionals(parsed.positionals, 1);
|
|
49
|
+
return {
|
|
50
|
+
commandId: parsed.options.get("--command-id"),
|
|
51
|
+
connectionId: parsed.positionals[0],
|
|
52
|
+
expectedRevision: readExpectedRevision(parsed.options.get("--expected-revision")),
|
|
53
|
+
...readSessionLimit(requireOption(parsed.options, "--max-sessions")),
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export const readConnectionUsage = (tokens) => {
|
|
57
|
+
const parsed = parseOptions(tokens, new Set(), new Set(["--refresh"]));
|
|
58
|
+
requirePositionals(parsed.positionals, 1);
|
|
59
|
+
return {
|
|
60
|
+
connection: parsed.positionals[0] ?? "",
|
|
61
|
+
refresh: parsed.flags.has("--refresh"),
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export const readConnectionSignin = (tokens) => {
|
|
65
|
+
const parsed = parseOptions(tokens, new Set(["--command-id"]), new Set(["--device-code"]));
|
|
66
|
+
requirePositionals(parsed.positionals, 1);
|
|
67
|
+
return {
|
|
68
|
+
commandId: parsed.options.get("--command-id"),
|
|
69
|
+
connection: parsed.positionals[0] ?? "",
|
|
70
|
+
flow: parsed.flags.has("--device-code")
|
|
71
|
+
? "device-code"
|
|
72
|
+
: "browser",
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export const readConnectionState = (tokens, state) => {
|
|
76
|
+
const parsed = parseOptions(tokens, new Set(["--command-id", "--expected-revision"]));
|
|
77
|
+
requirePositionals(parsed.positionals, 1);
|
|
78
|
+
return {
|
|
79
|
+
commandId: parsed.options.get("--command-id"),
|
|
80
|
+
connectionId: parsed.positionals[0],
|
|
81
|
+
expectedRevision: readExpectedRevision(parsed.options.get("--expected-revision")),
|
|
82
|
+
state,
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export const readConnectionModels = (tokens) => {
|
|
86
|
+
const parsed = parseOptions(tokens, new Set(["--connection"]));
|
|
87
|
+
requirePositionals(parsed.positionals, 0);
|
|
88
|
+
return { connectionId: requireOption(parsed.options, "--connection") };
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Connection } from "@maiaos/sdk";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
export declare const vendorEnvironmentChanges: (connection: Connection) => Readonly<Record<string, string | undefined>>;
|
|
4
|
+
export type VendorLoginOptions = {
|
|
5
|
+
readonly deviceCode: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const vendorLoginArguments: (connection: Connection, options: VendorLoginOptions) => readonly string[];
|
|
8
|
+
export declare const hasLocalBrowser: (environment: Readonly<NodeJS.ProcessEnv>, platform: NodeJS.Platform) => boolean;
|
|
9
|
+
export declare const localBrowserAvailable: Effect.Effect<boolean>;
|
|
10
|
+
export declare const effectiveLoginOptions: (options: VendorLoginOptions, localBrowser: boolean) => VendorLoginOptions;
|
|
11
|
+
export declare const headlessLoginHint: (executor: Connection["executor"]) => string;
|
|
12
|
+
export declare const runVendorLogin: (connection: Connection, options: VendorLoginOptions) => Effect.Effect<number, unknown>;
|
|
13
|
+
//# sourceMappingURL=login.d.ts.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import * as NodeChildProcessSpawner from "@effect/platform-node-shared/NodeChildProcessSpawner";
|
|
3
|
+
import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem";
|
|
4
|
+
import * as NodePath from "@effect/platform-node-shared/NodePath";
|
|
5
|
+
import * as Config from "effect/Config";
|
|
6
|
+
import * as ConfigProvider from "effect/ConfigProvider";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Layer from "effect/Layer";
|
|
9
|
+
import * as Option from "effect/Option";
|
|
10
|
+
import * as ChildProcess from "effect/process/ChildProcess";
|
|
11
|
+
const vendorFor = (executor) => executor === "codex-cli"
|
|
12
|
+
? { command: "codex", loginArguments: ["login"], variable: "CODEX_HOME" }
|
|
13
|
+
: {
|
|
14
|
+
command: "claude",
|
|
15
|
+
loginArguments: ["auth", "login"],
|
|
16
|
+
variable: "CLAUDE_CONFIG_DIR",
|
|
17
|
+
};
|
|
18
|
+
export const vendorEnvironmentChanges = (connection) => ({
|
|
19
|
+
[vendorFor(connection.executor).variable]: connection.configRoot.kind === "maia-managed"
|
|
20
|
+
? connection.configRoot.path
|
|
21
|
+
: undefined,
|
|
22
|
+
});
|
|
23
|
+
export const vendorLoginArguments = (connection, options) => {
|
|
24
|
+
const vendor = vendorFor(connection.executor);
|
|
25
|
+
return connection.executor === "codex-cli" && options.deviceCode
|
|
26
|
+
? [...vendor.loginArguments, "--device-auth"]
|
|
27
|
+
: vendor.loginArguments;
|
|
28
|
+
};
|
|
29
|
+
export const hasLocalBrowser = (environment, platform) => {
|
|
30
|
+
if (environment.SSH_CONNECTION !== undefined ||
|
|
31
|
+
environment.SSH_CLIENT !== undefined ||
|
|
32
|
+
environment.SSH_TTY !== undefined)
|
|
33
|
+
return false;
|
|
34
|
+
if (platform === "darwin" || platform === "win32")
|
|
35
|
+
return true;
|
|
36
|
+
return (environment.DISPLAY !== undefined ||
|
|
37
|
+
environment.WAYLAND_DISPLAY !== undefined);
|
|
38
|
+
};
|
|
39
|
+
const BROWSER_VARIABLES = [
|
|
40
|
+
"DISPLAY",
|
|
41
|
+
"SSH_CLIENT",
|
|
42
|
+
"SSH_CONNECTION",
|
|
43
|
+
"SSH_TTY",
|
|
44
|
+
"WAYLAND_DISPLAY",
|
|
45
|
+
];
|
|
46
|
+
export const localBrowserAvailable = Effect.forEach(BROWSER_VARIABLES, (name) => Config.option(Config.String(name)).pipe(Effect.map((value) => [name, Option.getOrUndefined(value)]))).pipe(Effect.map((entries) => hasLocalBrowser(Object.fromEntries(entries.filter(([, value]) => value !== undefined)), process.platform)), Effect.orElseSucceed(() => hasLocalBrowser({}, process.platform)), Effect.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromEnv({ preserveEmptyStrings: true })));
|
|
47
|
+
export const effectiveLoginOptions = (options, localBrowser) => ({
|
|
48
|
+
deviceCode: options.deviceCode || !localBrowser,
|
|
49
|
+
});
|
|
50
|
+
export const headlessLoginHint = (executor) => executor === "codex-cli"
|
|
51
|
+
? "No browser on this machine: open the link below on any device and enter the code."
|
|
52
|
+
: "No browser on this machine: open the link Claude prints on any device, sign in, then paste the code here.";
|
|
53
|
+
const spawner = NodeChildProcessSpawner.layer.pipe(Layer.provide(Layer.merge(NodeFileSystem.layer, NodePath.layer)));
|
|
54
|
+
export const runVendorLogin = (connection, options) => Effect.gen(function* () {
|
|
55
|
+
const localBrowser = yield* localBrowserAvailable;
|
|
56
|
+
if (!localBrowser)
|
|
57
|
+
process.stderr.write(`${headlessLoginHint(connection.executor)}\n`);
|
|
58
|
+
const handle = yield* ChildProcess.make(vendorFor(connection.executor).command, vendorLoginArguments(connection, effectiveLoginOptions(options, localBrowser)), {
|
|
59
|
+
detached: false,
|
|
60
|
+
env: vendorEnvironmentChanges(connection),
|
|
61
|
+
extendEnv: true,
|
|
62
|
+
stderr: "inherit",
|
|
63
|
+
stdin: "inherit",
|
|
64
|
+
stdout: "inherit",
|
|
65
|
+
windowsHide: false,
|
|
66
|
+
});
|
|
67
|
+
return yield* handle.exitCode.pipe(Effect.map(Number), Effect.orElseSucceed(() => 1));
|
|
68
|
+
}).pipe(Effect.scoped, Effect.provide(spawner));
|
|
69
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Connection, ConnectionCapacitySetResult, ConnectionCreateResult, ConnectionGatewayCreateResult, ConnectionListResult, ConnectionLoginStartResult, ConnectionModelsListResult, ConnectionShowResult, ConnectionStateSetResult, ConnectionUsage, ConnectionUsageShowResult } from "@maiaos/sdk";
|
|
2
|
+
export type ConnectionResult = ConnectionCapacitySetResult | ConnectionCreateResult | ConnectionGatewayCreateResult | ConnectionListResult | ConnectionLoginStartResult | ConnectionModelsListResult | ConnectionShowResult | ConnectionStateSetResult | ConnectionUsageShowResult;
|
|
3
|
+
export type RedactedConnection = Omit<Connection, "configRoot"> & {
|
|
4
|
+
readonly configRoot: {
|
|
5
|
+
readonly kind: Connection["configRoot"]["kind"];
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
type RedactedSingle<TResult extends {
|
|
9
|
+
readonly connection: Connection;
|
|
10
|
+
}> = Omit<TResult, "connection"> & {
|
|
11
|
+
readonly connection: RedactedConnection;
|
|
12
|
+
};
|
|
13
|
+
type RedactedConnectionResult = ConnectionModelsListResult | (Omit<ConnectionListResult, "items"> & {
|
|
14
|
+
readonly items: readonly RedactedConnection[];
|
|
15
|
+
}) | RedactedSingle<ConnectionCapacitySetResult> | RedactedSingle<ConnectionCreateResult> | RedactedSingle<ConnectionGatewayCreateResult> | RedactedSingle<ConnectionLoginStartResult> | RedactedSingle<ConnectionShowResult> | RedactedSingle<ConnectionStateSetResult> | RedactedSingle<ConnectionUsageShowResult> | {
|
|
16
|
+
readonly connection: RedactedConnection;
|
|
17
|
+
readonly method: "connection.login";
|
|
18
|
+
};
|
|
19
|
+
export type CliConnectionResult = {
|
|
20
|
+
readonly command: RedactedConnectionResult["method"];
|
|
21
|
+
readonly result: RedactedConnectionResult;
|
|
22
|
+
};
|
|
23
|
+
export declare const redactConnection: (connection: Connection) => RedactedConnection;
|
|
24
|
+
export declare const redactConnectionResult: (result: ConnectionResult) => RedactedConnectionResult;
|
|
25
|
+
export declare const isConnectionResult: (result: {
|
|
26
|
+
readonly command: string;
|
|
27
|
+
}) => result is CliConnectionResult;
|
|
28
|
+
export declare const describeUsage: (usage: ConnectionUsage) => string;
|
|
29
|
+
export declare const describeConnection: (connection: RedactedConnection) => string;
|
|
30
|
+
export declare const formatConnectionResult: ({ result, }: CliConnectionResult) => string;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { formatRows, withNextPage } from "../../command-line/index.js";
|
|
2
|
+
export const redactConnection = (connection) => ({
|
|
3
|
+
...connection,
|
|
4
|
+
configRoot: { kind: connection.configRoot.kind },
|
|
5
|
+
});
|
|
6
|
+
export const redactConnectionResult = (result) => {
|
|
7
|
+
if (result.method === "connection.models.list")
|
|
8
|
+
return result;
|
|
9
|
+
return result.method === "connection.list"
|
|
10
|
+
? { ...result, items: result.items.map(redactConnection) }
|
|
11
|
+
: { ...result, connection: redactConnection(result.connection) };
|
|
12
|
+
};
|
|
13
|
+
export const isConnectionResult = (result) => result.command.startsWith("connection.");
|
|
14
|
+
const windowLabel = (window) => {
|
|
15
|
+
if (window.kind === "session")
|
|
16
|
+
return "5h";
|
|
17
|
+
if (window.kind !== "weekly")
|
|
18
|
+
return window.id.replaceAll("_", "-");
|
|
19
|
+
const model = window.id.replace(/^seven_day_?/u, "").replaceAll("_", " ");
|
|
20
|
+
return model === "" || window.id === "primary" || window.id === "secondary"
|
|
21
|
+
? "week"
|
|
22
|
+
: `week ${model}`;
|
|
23
|
+
};
|
|
24
|
+
const resetText = (resetsAt) => resetsAt === undefined ? "" : ` resets ${resetsAt.slice(0, 16)}Z`;
|
|
25
|
+
export const describeUsage = (usage) => {
|
|
26
|
+
if (usage.unavailable !== undefined)
|
|
27
|
+
return `usage unavailable: ${usage.unavailable.message ?? usage.unavailable.reason}`;
|
|
28
|
+
const windows = usage.windows.map((window) => `${windowLabel(window)} ${String(Math.round(window.usedPercent))}%${resetText(window.resetsAt)}`);
|
|
29
|
+
const credits = usage.resetCredits?.availableCount ?? 0;
|
|
30
|
+
const parts = [
|
|
31
|
+
...(usage.account?.plan === undefined ? [] : [usage.account.plan]),
|
|
32
|
+
...windows,
|
|
33
|
+
...(credits > 0
|
|
34
|
+
? [`${String(credits)} reset credit${credits === 1 ? "" : "s"}`]
|
|
35
|
+
: []),
|
|
36
|
+
];
|
|
37
|
+
return parts.length === 0 ? "no usage windows" : parts.join(", ");
|
|
38
|
+
};
|
|
39
|
+
export const describeConnection = (connection) => {
|
|
40
|
+
const limited = connection.limitedUntil === null
|
|
41
|
+
? ""
|
|
42
|
+
: ` limited-until=${connection.limitedUntil}`;
|
|
43
|
+
const usage = connection.usage === undefined
|
|
44
|
+
? ""
|
|
45
|
+
: `\n ${describeUsage(connection.usage)}`;
|
|
46
|
+
const gateway = connection.gateway === undefined
|
|
47
|
+
? ""
|
|
48
|
+
: ` gateway=${connection.gateway.baseUrl}`;
|
|
49
|
+
return `${connection.connectionId} ${connection.name} ${connection.executor} ${connection.state} sessions<=${String(connection.maxConcurrentSessions)} revision=${connection.revision} root=${connection.configRoot.kind}${gateway}${limited}${usage}`;
|
|
50
|
+
};
|
|
51
|
+
const describeLogin = (login) => login.authUrl === undefined
|
|
52
|
+
? `Open ${login.verificationUrl ?? ""} and enter ${login.userCode ?? ""} before ${login.expiresAt}.`
|
|
53
|
+
: `Open ${login.authUrl} before ${login.expiresAt}.`;
|
|
54
|
+
const describeModels = (result) => {
|
|
55
|
+
const lines = result.models.map((model) => model.displayName === undefined
|
|
56
|
+
? model.id
|
|
57
|
+
: `${model.id} ${model.displayName}`);
|
|
58
|
+
const notes = [
|
|
59
|
+
...(result.truncated ? ["the gateway listed more models"] : []),
|
|
60
|
+
...(result.omitted > 0
|
|
61
|
+
? [`${String(result.omitted)} entries without a usable id`]
|
|
62
|
+
: []),
|
|
63
|
+
];
|
|
64
|
+
return `${[
|
|
65
|
+
...(lines.length === 0 ? ["No models."] : lines),
|
|
66
|
+
...(notes.length === 0 ? [] : [`(${notes.join("; ")})`]),
|
|
67
|
+
].join("\n")}\n`;
|
|
68
|
+
};
|
|
69
|
+
const prefixFor = (method) => {
|
|
70
|
+
return method === "connection.login" ? "Signed in: " : "";
|
|
71
|
+
};
|
|
72
|
+
const formatConnectionList = (result) => withNextPage(formatRows(result.items, (connection) => `${connection.connectionId}\t${connection.name}\t${connection.executor}\t${connection.state}\t${String(connection.maxConcurrentSessions)}\t${connection.limitedUntil ?? "-"}`, {
|
|
73
|
+
empty: "No connections.",
|
|
74
|
+
headers: [
|
|
75
|
+
"CONNECTION",
|
|
76
|
+
"NAME",
|
|
77
|
+
"EXECUTOR",
|
|
78
|
+
"STATE",
|
|
79
|
+
"SESSIONS",
|
|
80
|
+
"LIMITED UNTIL",
|
|
81
|
+
],
|
|
82
|
+
}), result.nextCursor);
|
|
83
|
+
export const formatConnectionResult = ({ result, }) => {
|
|
84
|
+
if (result.method === "connection.models.list")
|
|
85
|
+
return describeModels(result);
|
|
86
|
+
if (result.method === "connection.list")
|
|
87
|
+
return formatConnectionList(result);
|
|
88
|
+
const prefix = prefixFor(result.method);
|
|
89
|
+
const login = result.method === "connection.login.start"
|
|
90
|
+
? `\n${describeLogin(result.login)}`
|
|
91
|
+
: "";
|
|
92
|
+
return `${prefix}${describeConnection(result.connection)}${login}\n`;
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ProtocolError } from "@maiaos/sdk";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import type { CliServices, CommandContext } from "../command-line/index.js";
|
|
4
|
+
import type { CliNodeEffect } from "../local-node/index.js";
|
|
5
|
+
declare const ConnectionNodeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
6
|
+
readonly _tag: "ConnectionNodeError";
|
|
7
|
+
} & Readonly<A>;
|
|
8
|
+
export declare class ConnectionNodeError extends ConnectionNodeError_base<{
|
|
9
|
+
readonly error: ProtocolError;
|
|
10
|
+
readonly message: string;
|
|
11
|
+
}> {
|
|
12
|
+
constructor(error: ProtocolError);
|
|
13
|
+
}
|
|
14
|
+
export declare const callNode: <TOperation, TValue>(operation: TOperation | undefined, run: (operation: TOperation) => CliNodeEffect<TValue>) => Effect.Effect<TValue, ConnectionNodeError | Error, CliServices>;
|
|
15
|
+
export declare const findConnectionByName: (context: CommandContext, name: string) => Effect.Effect<{
|
|
16
|
+
readonly configRoot: {
|
|
17
|
+
readonly kind: "maia-managed";
|
|
18
|
+
readonly path: string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: "system-default";
|
|
21
|
+
};
|
|
22
|
+
readonly connectionId: string;
|
|
23
|
+
readonly createdAt: string;
|
|
24
|
+
readonly executor: "claude-code" | "codex-cli" | "gateway";
|
|
25
|
+
readonly gateway?: {
|
|
26
|
+
readonly baseUrl: string;
|
|
27
|
+
} | undefined;
|
|
28
|
+
readonly limitedUntil: string | null;
|
|
29
|
+
readonly maxConcurrentSessions: number;
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly revision: string;
|
|
32
|
+
readonly schemaVersion: "maia.connection/v1";
|
|
33
|
+
readonly state: "disabled" | "enabled";
|
|
34
|
+
readonly updatedAt: string;
|
|
35
|
+
readonly usage?: {
|
|
36
|
+
readonly account?: {
|
|
37
|
+
readonly email?: string | undefined;
|
|
38
|
+
readonly plan?: string | undefined;
|
|
39
|
+
} | undefined;
|
|
40
|
+
readonly checkedAt: string;
|
|
41
|
+
readonly resetCredits?: {
|
|
42
|
+
readonly availableCount: number;
|
|
43
|
+
readonly nextCreditId?: string | undefined;
|
|
44
|
+
readonly nextExpiresAt?: string | undefined;
|
|
45
|
+
} | undefined;
|
|
46
|
+
readonly unavailable?: {
|
|
47
|
+
readonly message?: string | undefined;
|
|
48
|
+
readonly reason: "probe_failed" | "signed_out" | "unsupported";
|
|
49
|
+
} | undefined;
|
|
50
|
+
readonly windows: readonly {
|
|
51
|
+
readonly id: string;
|
|
52
|
+
readonly kind: "other" | "session" | "weekly";
|
|
53
|
+
readonly resetsAt?: string | undefined;
|
|
54
|
+
readonly usedPercent: number;
|
|
55
|
+
readonly windowMinutes?: number | undefined;
|
|
56
|
+
}[];
|
|
57
|
+
} | undefined;
|
|
58
|
+
} | undefined, ConnectionNodeError | Error, import("effect/Crypto").Crypto>;
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Data, Effect } from "effect";
|
|
2
|
+
const PAGE_SIZE = 100;
|
|
3
|
+
const MAXIMUM_PAGES = 10;
|
|
4
|
+
export class ConnectionNodeError extends Data.TaggedError("ConnectionNodeError") {
|
|
5
|
+
constructor(error) {
|
|
6
|
+
super({ error, message: error.message });
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export const callNode = (operation, run) => operation === undefined
|
|
10
|
+
? Effect.fail(new Error("Missing connection client."))
|
|
11
|
+
: run(operation).pipe(Effect.flatMap((result) => result.ok
|
|
12
|
+
? Effect.succeed(result.value)
|
|
13
|
+
: Effect.fail(new ConnectionNodeError(result.error))));
|
|
14
|
+
const searchPage = (context, { afterCursor, name, page }) => callNode(context.dependencies.listConnections, (list) => list({
|
|
15
|
+
limit: PAGE_SIZE,
|
|
16
|
+
...(afterCursor === undefined ? {} : { afterCursor }),
|
|
17
|
+
})).pipe(Effect.flatMap((result) => {
|
|
18
|
+
const found = result.items.find((item) => item.name === name);
|
|
19
|
+
if (found !== undefined || result.nextCursor === undefined)
|
|
20
|
+
return Effect.succeed(found);
|
|
21
|
+
return page + 1 >= MAXIMUM_PAGES
|
|
22
|
+
? Effect.succeed(found)
|
|
23
|
+
: searchPage(context, {
|
|
24
|
+
afterCursor: result.nextCursor,
|
|
25
|
+
name,
|
|
26
|
+
page: page + 1,
|
|
27
|
+
});
|
|
28
|
+
}));
|
|
29
|
+
export const findConnectionByName = (context, name) => searchPage(context, { name, page: 0 });
|
|
30
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { CliArgumentError, type CommandContext } from "../command-line/index.js";
|
|
3
|
+
export declare const signInThroughNode: (tokens: readonly string[], context: CommandContext) => Effect.Effect<number, CliArgumentError | Error, import("effect/Crypto").Crypto>;
|
|
4
|
+
//# sourceMappingURL=signin.d.ts.map
|