@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,106 @@
|
|
|
1
|
+
import { initialSessionAttachView, sessionAttachCursor, } from "@maiaos/sdk";
|
|
2
|
+
import * as Duration from "effect/Duration";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Ref from "effect/Ref";
|
|
5
|
+
import * as Stream from "effect/Stream";
|
|
6
|
+
import { CliArgumentError, parseOptions, reportError, requirePositionals, } from "../command-line/index.js";
|
|
7
|
+
import { finishSessionAttachRender, initialAttachRenderState, renderSessionAttachFrame, } from "./attach-render.js";
|
|
8
|
+
const MAX_IDLE_REATTACHES = 5;
|
|
9
|
+
const REATTACH_BACKOFF = Duration.millis(100);
|
|
10
|
+
const NODE_UNAVAILABLE = {
|
|
11
|
+
code: "node_unavailable",
|
|
12
|
+
message: "The Session stream is unavailable.",
|
|
13
|
+
retryable: true,
|
|
14
|
+
};
|
|
15
|
+
export const readAttachCursor = (value) => {
|
|
16
|
+
if (value === undefined)
|
|
17
|
+
return undefined;
|
|
18
|
+
const separator = value.lastIndexOf(":");
|
|
19
|
+
const epoch = value.slice(0, separator);
|
|
20
|
+
const sequence = value.slice(separator + 1);
|
|
21
|
+
if (separator <= 0 ||
|
|
22
|
+
!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u.test(epoch) ||
|
|
23
|
+
!/^(?:0|[1-9]\d{0,15})$/u.test(sequence) ||
|
|
24
|
+
!Number.isSafeInteger(Number(sequence)))
|
|
25
|
+
throw new CliArgumentError("Option '--after' must be '<epoch>:<sequence>' from a previous attach.");
|
|
26
|
+
return { epoch, sequence: Number(sequence) };
|
|
27
|
+
};
|
|
28
|
+
const writeFrame = (attachment, frame) => Ref.modify(attachment.state, (state) => {
|
|
29
|
+
const rendered = renderSessionAttachFrame(state, frame);
|
|
30
|
+
return [rendered.text, rendered.state];
|
|
31
|
+
}).pipe(Effect.map((text) => {
|
|
32
|
+
const { io, json } = attachment.context;
|
|
33
|
+
if (json)
|
|
34
|
+
io.stdout(`${JSON.stringify(frame)}\n`);
|
|
35
|
+
else if (text.length > 0)
|
|
36
|
+
io.stdout(text);
|
|
37
|
+
}));
|
|
38
|
+
const framesOf = (attachment, stream) => attachment.follow
|
|
39
|
+
? stream
|
|
40
|
+
: stream.pipe(Stream.takeUntil((frame) => frame.kind === "synchronized"));
|
|
41
|
+
const outcomeOf = (attachment, completed) => Ref.get(attachment.state).pipe(Effect.map(({ view }) => {
|
|
42
|
+
if (view.end?.kind === "error")
|
|
43
|
+
return {
|
|
44
|
+
error: {
|
|
45
|
+
code: view.end.code,
|
|
46
|
+
message: view.end.message,
|
|
47
|
+
retryable: false,
|
|
48
|
+
},
|
|
49
|
+
kind: "failed",
|
|
50
|
+
};
|
|
51
|
+
return completed && !attachment.follow
|
|
52
|
+
? { kind: "ended" }
|
|
53
|
+
: { kind: "reattach" };
|
|
54
|
+
}));
|
|
55
|
+
const attachOnce = (attachment) => Effect.gen(function* () {
|
|
56
|
+
const { attachSession } = attachment.context.dependencies;
|
|
57
|
+
if (attachSession === undefined)
|
|
58
|
+
throw new CliArgumentError("Session attach is unavailable.");
|
|
59
|
+
const after = sessionAttachCursor((yield* Ref.get(attachment.state)).view);
|
|
60
|
+
const opened = yield* attachSession({
|
|
61
|
+
...(after === undefined ? {} : { after }),
|
|
62
|
+
sessionId: attachment.sessionId,
|
|
63
|
+
});
|
|
64
|
+
if (!opened.ok)
|
|
65
|
+
return { error: opened.error, kind: "failed" };
|
|
66
|
+
const ran = yield* Effect.result(Stream.runForEach(framesOf(attachment, opened.value), (frame) => writeFrame(attachment, frame)));
|
|
67
|
+
return yield* outcomeOf(attachment, ran._tag === "Success");
|
|
68
|
+
});
|
|
69
|
+
const finish = (attachment, outcome) => Ref.get(attachment.state).pipe(Effect.map((state) => {
|
|
70
|
+
if (!attachment.context.json)
|
|
71
|
+
attachment.context.io.stdout(finishSessionAttachRender(state));
|
|
72
|
+
return outcome.kind === "failed"
|
|
73
|
+
? reportError(outcome.error, attachment.context)
|
|
74
|
+
: 0;
|
|
75
|
+
}));
|
|
76
|
+
const follow = (attachment, idle) => Effect.gen(function* () {
|
|
77
|
+
const before = (yield* Ref.get(attachment.state)).view.sequence;
|
|
78
|
+
const outcome = yield* attachOnce(attachment);
|
|
79
|
+
if (outcome.kind !== "reattach")
|
|
80
|
+
return yield* finish(attachment, outcome);
|
|
81
|
+
const progressed = (yield* Ref.get(attachment.state)).view.sequence > before;
|
|
82
|
+
const nextIdle = progressed ? 0 : idle + 1;
|
|
83
|
+
if (nextIdle > MAX_IDLE_REATTACHES)
|
|
84
|
+
return yield* finish(attachment, {
|
|
85
|
+
error: NODE_UNAVAILABLE,
|
|
86
|
+
kind: "failed",
|
|
87
|
+
});
|
|
88
|
+
yield* Effect.sleep(Duration.times(REATTACH_BACKOFF, nextIdle));
|
|
89
|
+
return yield* follow(attachment, nextIdle);
|
|
90
|
+
});
|
|
91
|
+
export const runSessionAttach = (tokens, context) => Effect.gen(function* () {
|
|
92
|
+
const parsed = parseOptions(tokens, new Set(["--after"]), new Set(["--no-follow"]));
|
|
93
|
+
requirePositionals(parsed.positionals, 1);
|
|
94
|
+
const [sessionId = ""] = parsed.positionals;
|
|
95
|
+
const after = readAttachCursor(parsed.options.get("--after"));
|
|
96
|
+
const view = after === undefined
|
|
97
|
+
? initialSessionAttachView
|
|
98
|
+
: { ...initialSessionAttachView, ...after };
|
|
99
|
+
return yield* follow({
|
|
100
|
+
context,
|
|
101
|
+
follow: !parsed.flags.has("--no-follow"),
|
|
102
|
+
sessionId,
|
|
103
|
+
state: yield* Ref.make(initialAttachRenderState(view)),
|
|
104
|
+
}, 0);
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=attach.js.map
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { Session, SessionCreateParameters, SessionCreateResult, SessionCreationInput, SessionCreationOutcome, SessionCreationPlan, SessionEventsListResult, SessionInboxAckResult, SessionInboxCheckResult, SessionListParameters, SessionListResult, SessionMessageSendResult, SessionObserveResult, SessionResumeResult, SessionShowResult, SessionSpawnResult, SessionStartResult, SessionStopResult } from "@maiaos/sdk";
|
|
2
|
+
import { type CliNodeEffect, type CliNodeOperations } from "../local-node/index.js";
|
|
3
|
+
export type CreateSessionInput = {
|
|
4
|
+
readonly baseRef?: string;
|
|
5
|
+
readonly commandId?: string;
|
|
6
|
+
readonly connectionId?: string;
|
|
7
|
+
readonly definitionRef?: SessionCreateParameters["definitionRef"];
|
|
8
|
+
readonly executor?: SessionCreateParameters["executor"];
|
|
9
|
+
readonly model?: string;
|
|
10
|
+
readonly role?: SessionCreateParameters["role"];
|
|
11
|
+
readonly title?: string;
|
|
12
|
+
readonly workspaceId: string;
|
|
13
|
+
};
|
|
14
|
+
type SpawnSessionInput = {
|
|
15
|
+
readonly commandId?: string;
|
|
16
|
+
readonly harness: "maia-agent" | "pi";
|
|
17
|
+
readonly parentSessionId: string;
|
|
18
|
+
readonly workspaceId: string;
|
|
19
|
+
};
|
|
20
|
+
export type ListSessionsInput = Omit<SessionListParameters, "states"> & {
|
|
21
|
+
readonly states?: readonly string[];
|
|
22
|
+
};
|
|
23
|
+
export type StartSessionInput = {
|
|
24
|
+
readonly commandId?: string;
|
|
25
|
+
readonly expectedRevision: string;
|
|
26
|
+
readonly sessionId: string;
|
|
27
|
+
};
|
|
28
|
+
type SendAttachedSessionMessageInput = {
|
|
29
|
+
readonly body: string;
|
|
30
|
+
readonly commandId?: string;
|
|
31
|
+
readonly recipientSessionId: string;
|
|
32
|
+
readonly subject: string;
|
|
33
|
+
};
|
|
34
|
+
type AcknowledgeAttachedSessionDeliveryInput = {
|
|
35
|
+
readonly commandId?: string;
|
|
36
|
+
readonly deliveryId: string;
|
|
37
|
+
readonly expectedMailboxRevision: string;
|
|
38
|
+
};
|
|
39
|
+
export declare const makeSessionClient: (node: CliNodeOperations) => {
|
|
40
|
+
applyExecutionRelocation: (input: import("../execution/client.js").ApplyExecutionRelocationInput) => CliNodeEffect<import("@maiaos/sdk").ExecutionRelocationApplyResult>;
|
|
41
|
+
planExecutionRelocation: (input: import("../execution/client.js").PlanExecutionRelocationInput) => CliNodeEffect<import("@maiaos/sdk").ExecutionRelocationPlanResult>;
|
|
42
|
+
reconcileExecutionRelocation: (input: import("../execution/client.js").ReconcileExecutionRelocationInput) => CliNodeEffect<import("@maiaos/sdk").ExecutionRelocationReconcileResult>;
|
|
43
|
+
showExecutionRelocation: (relocationId: string) => CliNodeEffect<import("@maiaos/sdk").ExecutionRelocationShowResult>;
|
|
44
|
+
confirmAgentPermission: (input: import("@maiaos/sdk").AgentPermissionConfirmParameters) => CliNodeEffect<{
|
|
45
|
+
readonly delivery: "duplicate" | "new";
|
|
46
|
+
readonly grant: {
|
|
47
|
+
readonly definitionRef: {
|
|
48
|
+
readonly contentDigest: string;
|
|
49
|
+
readonly key: string;
|
|
50
|
+
readonly version: string;
|
|
51
|
+
};
|
|
52
|
+
readonly expectedSessionRevision: string;
|
|
53
|
+
readonly expectedWorkspaceRevision: string;
|
|
54
|
+
readonly sessionId: string;
|
|
55
|
+
readonly workspaceId: string;
|
|
56
|
+
readonly actorId: string;
|
|
57
|
+
readonly commandId: string;
|
|
58
|
+
readonly grantedAt: string;
|
|
59
|
+
readonly inputDigest: string;
|
|
60
|
+
readonly operationIds: readonly ("approval.list" | "approval.respond" | "approval.show" | "connection.capacity.set" | "connection.create" | "connection.detect" | "connection.gateway.create" | "connection.list" | "connection.login.start" | "connection.models.list" | "connection.show" | "connection.state.set" | "connection.system.confirm" | "connection.system.preview" | "connection.usage.show" | "container.create.confirm" | "container.create.preview" | "container.index.list" | "container.list" | "container.rename.confirm" | "container.rename.preview" | "container.show" | "context.show" | "discovery.sessions.list" | "execution.catalog.get" | "execution.checkpoint.create" | "execution.checkpoint.show" | "execution.command.run" | "execution.file.read" | "execution.placement.create" | "execution.placement.show" | "execution.relocation.apply" | "execution.relocation.plan" | "execution.relocation.reconcile" | "execution.relocation.show" | "execution.worktree.create" | "execution.worktree.import" | "execution.worktree.reconcile" | "execution.worktree.remove.apply" | "execution.worktree.remove.plan" | "execution.worktree.status" | "harness.installed.list" | "hold.list" | "hold.place.confirm" | "hold.place.preview" | "hold.release.confirm" | "hold.release.preview" | "integration.apply.claude-code" | "integration.apply.codex" | "integration.apply.pi-rpc" | "integration.plan.claude-code" | "integration.plan.codex" | "integration.plan.pi-rpc" | "integration.remove.claude-code" | "integration.remove.codex" | "integration.remove.pi-rpc" | "integration.status.claude-code" | "integration.status.codex" | "integration.status.pi-rpc" | "interaction.cancel" | "interaction.create" | "interaction.list" | "interaction.respond" | "interaction.show" | "monitor.bootstrap.create" | "node.remote.install.confirm" | "node.remote.install.preview" | "node.remote.list" | "node.remote.remove.confirm" | "node.remote.remove.preview" | "node.shutdown" | "node.status" | "port.lease.acquire" | "port.lease.list" | "port.lease.release" | "port.lease.renew" | "presentation.catalog.show" | "presentation.project-list.show" | "presentation.session-list.show" | "presentation.workspace-directory.show" | "project.context.list" | "project.context.record" | "project.context.show" | "project.create.confirm" | "project.create.preview" | "project.guard.confirm" | "project.guard.preview" | "project.guard.show" | "project.list" | "project.register" | "project.rename.confirm" | "project.rename.preview" | "project.show" | "provider.pool.list" | "receipt.get" | "receipt.list" | "reference.resolve" | "run.create" | "run.dispatch.settle-terminal" | "run.dispatch.show" | "run.inbox.ack" | "run.inbox.check" | "run.ledger.create" | "run.ledger.list" | "run.ledger.task.dispatch" | "run.ledger.task.list" | "run.ledger.task.settle" | "run.ledger.task.show" | "run.list" | "run.question.cancel" | "run.question.open" | "run.question.reply" | "run.show" | "run.task.list" | "run.task.show" | "runtime.probe" | "session.adopt.confirm" | "session.adopt.preview" | "session.agent-permission.confirm" | "session.agent-permission.preview" | "session.archive" | "session.create" | "session.diff" | "session.events.list" | "session.history.read" | "session.inbox.ack" | "session.inbox.check" | "session.list" | "session.message.send" | "session.observe" | "session.rename" | "session.resume" | "session.show" | "session.spawn" | "session.start" | "session.stop" | "terminal.controller.acquire" | "terminal.controller.release" | "terminal.controller.renew" | "terminal.controller.request" | "terminal.controller.request.show" | "terminal.create" | "terminal.events.list" | "terminal.input.write" | "terminal.list" | "terminal.mutation.reconcile" | "terminal.observer.attach" | "terminal.observer.check" | "terminal.observer.detach" | "terminal.observer.resync" | "terminal.read" | "terminal.session.close" | "terminal.session.delete" | "terminal.session.resize" | "terminal.session.restart" | "terminal.session.signal" | "terminal.show" | "turn.interrupt" | "turn.send" | "turn.show" | "turn.wait" | "voice.managed-turn.confirm" | "voice.managed-turn.preview" | "voice.orchestrator.context.show" | "voice.orchestrator.tool.call" | "voice.pi.relay" | "voice.pi.relay.preview" | "voice.pi.relay.reconcile" | "workspace.context.show" | "workspace.execution.configure" | "workspace.execution.show" | "workspace.list" | "workspace.membership.attach" | "workspace.repository.attach" | "workspace.select" | "workspace.show")[];
|
|
61
|
+
readonly revision: "1";
|
|
62
|
+
};
|
|
63
|
+
readonly method: "session.agent-permission.confirm";
|
|
64
|
+
readonly receipt: {
|
|
65
|
+
readonly actorId: string;
|
|
66
|
+
readonly aggregateRevision: string;
|
|
67
|
+
readonly commandId: string;
|
|
68
|
+
readonly createdAt: string;
|
|
69
|
+
readonly eventCursor: string;
|
|
70
|
+
readonly method: string;
|
|
71
|
+
readonly receiptId: string;
|
|
72
|
+
readonly schemaVersion: 1;
|
|
73
|
+
readonly state: "succeeded";
|
|
74
|
+
readonly target: {
|
|
75
|
+
readonly id: string;
|
|
76
|
+
readonly type: string;
|
|
77
|
+
};
|
|
78
|
+
readonly updatedAt: string;
|
|
79
|
+
};
|
|
80
|
+
}>;
|
|
81
|
+
previewAgentPermission: (input: import("@maiaos/sdk").AgentPermissionPreviewParameters) => CliNodeEffect<{
|
|
82
|
+
readonly definitionRef: {
|
|
83
|
+
readonly contentDigest: string;
|
|
84
|
+
readonly key: string;
|
|
85
|
+
readonly version: string;
|
|
86
|
+
};
|
|
87
|
+
readonly expectedSessionRevision: string;
|
|
88
|
+
readonly expectedWorkspaceRevision: string;
|
|
89
|
+
readonly sessionId: string;
|
|
90
|
+
readonly workspaceId: string;
|
|
91
|
+
readonly actorId: string;
|
|
92
|
+
readonly commandId: string;
|
|
93
|
+
readonly expiresAt: string;
|
|
94
|
+
readonly inputDigest: string;
|
|
95
|
+
readonly issuedAt: string;
|
|
96
|
+
readonly method: "session.agent-permission.preview";
|
|
97
|
+
readonly operationIds: readonly ("approval.list" | "approval.respond" | "approval.show" | "connection.capacity.set" | "connection.create" | "connection.detect" | "connection.gateway.create" | "connection.list" | "connection.login.start" | "connection.models.list" | "connection.show" | "connection.state.set" | "connection.system.confirm" | "connection.system.preview" | "connection.usage.show" | "container.create.confirm" | "container.create.preview" | "container.index.list" | "container.list" | "container.rename.confirm" | "container.rename.preview" | "container.show" | "context.show" | "discovery.sessions.list" | "execution.catalog.get" | "execution.checkpoint.create" | "execution.checkpoint.show" | "execution.command.run" | "execution.file.read" | "execution.placement.create" | "execution.placement.show" | "execution.relocation.apply" | "execution.relocation.plan" | "execution.relocation.reconcile" | "execution.relocation.show" | "execution.worktree.create" | "execution.worktree.import" | "execution.worktree.reconcile" | "execution.worktree.remove.apply" | "execution.worktree.remove.plan" | "execution.worktree.status" | "harness.installed.list" | "hold.list" | "hold.place.confirm" | "hold.place.preview" | "hold.release.confirm" | "hold.release.preview" | "integration.apply.claude-code" | "integration.apply.codex" | "integration.apply.pi-rpc" | "integration.plan.claude-code" | "integration.plan.codex" | "integration.plan.pi-rpc" | "integration.remove.claude-code" | "integration.remove.codex" | "integration.remove.pi-rpc" | "integration.status.claude-code" | "integration.status.codex" | "integration.status.pi-rpc" | "interaction.cancel" | "interaction.create" | "interaction.list" | "interaction.respond" | "interaction.show" | "monitor.bootstrap.create" | "node.remote.install.confirm" | "node.remote.install.preview" | "node.remote.list" | "node.remote.remove.confirm" | "node.remote.remove.preview" | "node.shutdown" | "node.status" | "port.lease.acquire" | "port.lease.list" | "port.lease.release" | "port.lease.renew" | "presentation.catalog.show" | "presentation.project-list.show" | "presentation.session-list.show" | "presentation.workspace-directory.show" | "project.context.list" | "project.context.record" | "project.context.show" | "project.create.confirm" | "project.create.preview" | "project.guard.confirm" | "project.guard.preview" | "project.guard.show" | "project.list" | "project.register" | "project.rename.confirm" | "project.rename.preview" | "project.show" | "provider.pool.list" | "receipt.get" | "receipt.list" | "reference.resolve" | "run.create" | "run.dispatch.settle-terminal" | "run.dispatch.show" | "run.inbox.ack" | "run.inbox.check" | "run.ledger.create" | "run.ledger.list" | "run.ledger.task.dispatch" | "run.ledger.task.list" | "run.ledger.task.settle" | "run.ledger.task.show" | "run.list" | "run.question.cancel" | "run.question.open" | "run.question.reply" | "run.show" | "run.task.list" | "run.task.show" | "runtime.probe" | "session.adopt.confirm" | "session.adopt.preview" | "session.agent-permission.confirm" | "session.agent-permission.preview" | "session.archive" | "session.create" | "session.diff" | "session.events.list" | "session.history.read" | "session.inbox.ack" | "session.inbox.check" | "session.list" | "session.message.send" | "session.observe" | "session.rename" | "session.resume" | "session.show" | "session.spawn" | "session.start" | "session.stop" | "terminal.controller.acquire" | "terminal.controller.release" | "terminal.controller.renew" | "terminal.controller.request" | "terminal.controller.request.show" | "terminal.create" | "terminal.events.list" | "terminal.input.write" | "terminal.list" | "terminal.mutation.reconcile" | "terminal.observer.attach" | "terminal.observer.check" | "terminal.observer.detach" | "terminal.observer.resync" | "terminal.read" | "terminal.session.close" | "terminal.session.delete" | "terminal.session.resize" | "terminal.session.restart" | "terminal.session.signal" | "terminal.show" | "turn.interrupt" | "turn.send" | "turn.show" | "turn.wait" | "voice.managed-turn.confirm" | "voice.managed-turn.preview" | "voice.orchestrator.context.show" | "voice.orchestrator.tool.call" | "voice.pi.relay" | "voice.pi.relay.preview" | "voice.pi.relay.reconcile" | "workspace.context.show" | "workspace.execution.configure" | "workspace.execution.show" | "workspace.list" | "workspace.membership.attach" | "workspace.repository.attach" | "workspace.select" | "workspace.show")[];
|
|
98
|
+
readonly proof: string;
|
|
99
|
+
}>;
|
|
100
|
+
attachSession: (input: import("./attach-client.js").AttachSessionInput) => CliNodeEffect<import("./attach-client.js").SessionAttachStream>;
|
|
101
|
+
archiveSession: (input: import("./coding-client.js").ArchiveSessionInput) => CliNodeEffect<import("@maiaos/sdk").SessionArchiveResult>;
|
|
102
|
+
diffSession: (input: import("./coding-client.js").DiffSessionInput) => CliNodeEffect<import("@maiaos/sdk").SessionDiffResult>;
|
|
103
|
+
acknowledgeAttachedSessionDelivery: (input: AcknowledgeAttachedSessionDeliveryInput) => CliNodeEffect<SessionInboxAckResult>;
|
|
104
|
+
awaitSessionRunning: (input: {
|
|
105
|
+
readonly deadlineMilliseconds: number;
|
|
106
|
+
readonly sessionId: string;
|
|
107
|
+
}) => CliNodeEffect<Session>;
|
|
108
|
+
checkAttachedSessionInbox: (input: {
|
|
109
|
+
readonly limit?: number;
|
|
110
|
+
}) => CliNodeEffect<SessionInboxCheckResult>;
|
|
111
|
+
createSession: (input: CreateSessionInput) => CliNodeEffect<SessionCreateResult>;
|
|
112
|
+
listSessionEvents: (input: {
|
|
113
|
+
readonly afterSessionCursor: string;
|
|
114
|
+
readonly limit: number;
|
|
115
|
+
readonly sessionId: string;
|
|
116
|
+
}) => CliNodeEffect<SessionEventsListResult>;
|
|
117
|
+
listSessions: (input: ListSessionsInput) => CliNodeEffect<SessionListResult>;
|
|
118
|
+
observeSessions: (input: {
|
|
119
|
+
readonly sessionIds?: readonly string[];
|
|
120
|
+
readonly stallAfterSeconds?: number;
|
|
121
|
+
}) => CliNodeEffect<SessionObserveResult>;
|
|
122
|
+
planSessions: (input: SessionCreationInput) => CliNodeEffect<SessionCreationPlan>;
|
|
123
|
+
resumeSession: (input: StartSessionInput) => CliNodeEffect<SessionResumeResult>;
|
|
124
|
+
runSessions: (plan: SessionCreationPlan) => CliNodeEffect<readonly SessionCreationOutcome[]>;
|
|
125
|
+
sendAttachedSessionMessage: (input: SendAttachedSessionMessageInput) => CliNodeEffect<SessionMessageSendResult>;
|
|
126
|
+
showSession: (sessionId: string) => CliNodeEffect<SessionShowResult>;
|
|
127
|
+
spawnSession: (input: SpawnSessionInput) => CliNodeEffect<SessionSpawnResult>;
|
|
128
|
+
startSession: (input: StartSessionInput) => CliNodeEffect<SessionStartResult>;
|
|
129
|
+
stopSession: (input: StartSessionInput) => CliNodeEffect<SessionStopResult>;
|
|
130
|
+
};
|
|
131
|
+
export {};
|
|
132
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { sessionCreateParametersSchema, sessionEventsListParametersSchema, sessionInboxAckParametersSchema, sessionInboxCheckParametersSchema, sessionListParametersSchema, sessionMessageSendParametersSchema, sessionObserveParametersSchema, sessionResumeParametersSchema, sessionShowParametersSchema, sessionSpawnParametersSchema, sessionStartParametersSchema, sessionStopParametersSchema, } from "@maiaos/sdk";
|
|
2
|
+
import * as Crypto from "effect/Crypto";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import { makeRelocateClient } from "../execution/index.js";
|
|
5
|
+
import { commandIdentifier, } from "../local-node/index.js";
|
|
6
|
+
import { makeAgentPermissionCliClient } from "./agent-permission.js";
|
|
7
|
+
import { makeAttachClient } from "./attach-client.js";
|
|
8
|
+
import { makeCodingSessionClient } from "./coding-client.js";
|
|
9
|
+
export const makeSessionClient = (node) => {
|
|
10
|
+
const createSession = (input) => {
|
|
11
|
+
return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
|
|
12
|
+
return node.runValidatedNodeOperation({
|
|
13
|
+
commandId,
|
|
14
|
+
...(input.connectionId === undefined
|
|
15
|
+
? {}
|
|
16
|
+
: { connectionId: input.connectionId }),
|
|
17
|
+
expectedRevision: "0",
|
|
18
|
+
...(input.definitionRef === undefined
|
|
19
|
+
? {}
|
|
20
|
+
: { definitionRef: input.definitionRef }),
|
|
21
|
+
...(input.executor === undefined ? {} : { executor: input.executor }),
|
|
22
|
+
...(input.model === undefined ? {} : { model: input.model }),
|
|
23
|
+
...(input.role === undefined ? {} : { role: input.role }),
|
|
24
|
+
...(input.title === undefined ? {} : { title: input.title }),
|
|
25
|
+
workspaceId: input.workspaceId,
|
|
26
|
+
...(input.baseRef === undefined
|
|
27
|
+
? {}
|
|
28
|
+
: { worktree: { baseRef: input.baseRef } }),
|
|
29
|
+
}, sessionCreateParametersSchema, (client, parameters, options) => client.createSession(parameters, options), { commandId });
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
const listSessions = (input) => {
|
|
33
|
+
return node.runValidatedNodeOperation(input, sessionListParametersSchema, (client, parameters, options) => client.listSessions(parameters, options));
|
|
34
|
+
};
|
|
35
|
+
const showSession = (sessionId) => {
|
|
36
|
+
return node.runValidatedNodeOperation({ sessionId }, sessionShowParametersSchema, (client, parameters, options) => client.showSession(parameters, options));
|
|
37
|
+
};
|
|
38
|
+
const observeSessions = (input) => node.runValidatedNodeOperation(input, sessionObserveParametersSchema, (client, parameters, options) => client.observeSessions(parameters, options));
|
|
39
|
+
const listSessionEvents = (input) => {
|
|
40
|
+
return node.runValidatedNodeOperation(input, sessionEventsListParametersSchema, (client, parameters, options) => client.listSessionEvents(parameters, options));
|
|
41
|
+
};
|
|
42
|
+
const sendAttachedSessionMessage = (input) => {
|
|
43
|
+
return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
|
|
44
|
+
const parameters = sessionMessageSendParametersSchema.parse({
|
|
45
|
+
...input,
|
|
46
|
+
commandId,
|
|
47
|
+
});
|
|
48
|
+
return node.runDiscoveryOperation((options) => Effect.promise(() => import("@maiaos/sdk/node/effect")).pipe(Effect.flatMap((sdk) => sdk.sendAttachedSessionMessageEffect(parameters, options))));
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const checkAttachedSessionInbox = (input) => {
|
|
52
|
+
const parameters = sessionInboxCheckParametersSchema.parse(input);
|
|
53
|
+
return node.runDiscoveryOperation((options) => Effect.promise(() => import("@maiaos/sdk/node/effect")).pipe(Effect.flatMap((sdk) => sdk.checkAttachedSessionInboxEffect(parameters, options))));
|
|
54
|
+
};
|
|
55
|
+
const acknowledgeAttachedSessionDelivery = (input) => {
|
|
56
|
+
return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
|
|
57
|
+
const parameters = sessionInboxAckParametersSchema.parse({
|
|
58
|
+
...input,
|
|
59
|
+
commandId,
|
|
60
|
+
});
|
|
61
|
+
return node.runDiscoveryOperation((options) => Effect.promise(() => import("@maiaos/sdk/node/effect")).pipe(Effect.flatMap((sdk) => sdk.acknowledgeAttachedSessionDeliveryEffect(parameters, options))));
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const spawnSession = (input) => {
|
|
65
|
+
return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
|
|
66
|
+
return node.runValidatedNodeOperation({
|
|
67
|
+
commandId,
|
|
68
|
+
expectedRevision: "0",
|
|
69
|
+
harness: input.harness,
|
|
70
|
+
parentSessionId: input.parentSessionId,
|
|
71
|
+
workspaceId: input.workspaceId,
|
|
72
|
+
}, sessionSpawnParametersSchema, (client, parameters, options) => client.spawnSession(parameters, options), { commandId });
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const startSession = (input) => {
|
|
76
|
+
return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
|
|
77
|
+
return node.runValidatedNodeOperation({
|
|
78
|
+
commandId,
|
|
79
|
+
expectedRevision: input.expectedRevision,
|
|
80
|
+
sessionId: input.sessionId,
|
|
81
|
+
}, sessionStartParametersSchema, (client, parameters, options) => client.startSession(parameters, options), { commandId });
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const stopSession = (input) => {
|
|
85
|
+
return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
|
|
86
|
+
return node.runValidatedNodeOperation({
|
|
87
|
+
commandId,
|
|
88
|
+
expectedRevision: input.expectedRevision,
|
|
89
|
+
sessionId: input.sessionId,
|
|
90
|
+
}, sessionStopParametersSchema, (client, parameters, options) => client.stopSession(parameters, options), { commandId });
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
const resumeSession = (input) => {
|
|
94
|
+
return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
|
|
95
|
+
return node.runValidatedNodeOperation({
|
|
96
|
+
commandId,
|
|
97
|
+
expectedRevision: input.expectedRevision,
|
|
98
|
+
sessionId: input.sessionId,
|
|
99
|
+
}, sessionResumeParametersSchema, (client, parameters, options) => client.resumeSession(parameters, options), { commandId });
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
const withSdk = (operation) => Effect.flatMap(Crypto.Crypto, (crypto) => node.runNodeClientOperation((client) => Effect.promise(() => import("@maiaos/sdk/node/effect")).pipe(Effect.flatMap((sdk) => operation(sdk, client)), Effect.provideService(Crypto.Crypto, crypto))));
|
|
103
|
+
const planSessions = (input) => withSdk((sdk, client) => sdk.planSessionCreationEffect(client, input));
|
|
104
|
+
const runSessions = (plan) => withSdk((sdk, client) => sdk.createSessionsEffect(client, plan));
|
|
105
|
+
const awaitSessionRunning = (input) => withSdk((sdk, client) => sdk.awaitSessionRunningEffect(client, input.sessionId, input.deadlineMilliseconds));
|
|
106
|
+
return {
|
|
107
|
+
acknowledgeAttachedSessionDelivery,
|
|
108
|
+
awaitSessionRunning,
|
|
109
|
+
checkAttachedSessionInbox,
|
|
110
|
+
createSession,
|
|
111
|
+
listSessionEvents,
|
|
112
|
+
listSessions,
|
|
113
|
+
observeSessions,
|
|
114
|
+
planSessions,
|
|
115
|
+
resumeSession,
|
|
116
|
+
runSessions,
|
|
117
|
+
sendAttachedSessionMessage,
|
|
118
|
+
showSession,
|
|
119
|
+
spawnSession,
|
|
120
|
+
startSession,
|
|
121
|
+
stopSession,
|
|
122
|
+
...makeRelocateClient(node),
|
|
123
|
+
...makeAgentPermissionCliClient(node),
|
|
124
|
+
...makeCodingSessionClient(node),
|
|
125
|
+
...makeAttachClient(node),
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SessionArchiveResult, SessionDiffResult } from "@maiaos/sdk";
|
|
2
|
+
import { type CliNodeEffect, type CliNodeOperations } from "../local-node/index.js";
|
|
3
|
+
export type DiffSessionInput = {
|
|
4
|
+
readonly sessionId: string;
|
|
5
|
+
readonly stat: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type ArchiveSessionInput = {
|
|
8
|
+
readonly commandId?: string;
|
|
9
|
+
readonly expectedRevision: string;
|
|
10
|
+
readonly sessionId: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const makeCodingSessionClient: (node: CliNodeOperations) => {
|
|
13
|
+
archiveSession: (input: ArchiveSessionInput) => CliNodeEffect<SessionArchiveResult>;
|
|
14
|
+
diffSession: (input: DiffSessionInput) => CliNodeEffect<SessionDiffResult>;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=coding-client.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { sessionArchiveParametersSchema, sessionDiffParametersSchema, } from "@maiaos/sdk";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { commandIdentifier, } from "../local-node/index.js";
|
|
4
|
+
export const makeCodingSessionClient = (node) => ({
|
|
5
|
+
archiveSession: (input) => Effect.flatMap(commandIdentifier(input.commandId), (commandId) => node.runValidatedNodeOperation({
|
|
6
|
+
commandId,
|
|
7
|
+
expectedRevision: input.expectedRevision,
|
|
8
|
+
sessionId: input.sessionId,
|
|
9
|
+
}, sessionArchiveParametersSchema, (client, parameters, options) => client.archiveSession(parameters, options), { commandId })),
|
|
10
|
+
diffSession: (input) => node.runValidatedNodeOperation({
|
|
11
|
+
sessionId: input.sessionId,
|
|
12
|
+
...(input.stat ? { stat: true } : {}),
|
|
13
|
+
}, sessionDiffParametersSchema, (client, parameters, options) => client.diffSession(parameters, options)),
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=coding-client.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type CommandContext, type CommandEffect } from "../command-line/index.js";
|
|
2
|
+
export declare const runSessionDiff: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
3
|
+
export declare const runSessionArchive: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
4
|
+
//# sourceMappingURL=coding-commands.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { CliArgumentError, parseOptions, readExpectedRevision, requirePositionals, } from "../command-line/index.js";
|
|
3
|
+
import { writeSessionResult } from "./output/index.js";
|
|
4
|
+
const requireSessionId = (positionals) => {
|
|
5
|
+
const sessionId = positionals[0];
|
|
6
|
+
if (sessionId === undefined)
|
|
7
|
+
throw new CliArgumentError("The session identifier is missing.");
|
|
8
|
+
return sessionId;
|
|
9
|
+
};
|
|
10
|
+
export const runSessionDiff = (tokens, context) => Effect.gen(function* () {
|
|
11
|
+
const parsed = parseOptions(tokens, new Set(), new Set(["--stat"]));
|
|
12
|
+
requirePositionals(parsed.positionals, 1);
|
|
13
|
+
const { diffSession } = context.dependencies;
|
|
14
|
+
if (diffSession === undefined)
|
|
15
|
+
throw new CliArgumentError("Session diff is unavailable.");
|
|
16
|
+
const result = yield* diffSession({
|
|
17
|
+
sessionId: requireSessionId(parsed.positionals),
|
|
18
|
+
stat: parsed.flags.has("--stat"),
|
|
19
|
+
});
|
|
20
|
+
return writeSessionResult(result, context, (value) => ({
|
|
21
|
+
command: "session.diff",
|
|
22
|
+
result: value,
|
|
23
|
+
}));
|
|
24
|
+
});
|
|
25
|
+
const summarizeArchive = (result) => ({
|
|
26
|
+
...(result.archive === undefined ? {} : { archive: result.archive }),
|
|
27
|
+
delivery: result.delivery,
|
|
28
|
+
receipt: result.receipt,
|
|
29
|
+
revision: result.session.revision,
|
|
30
|
+
sessionId: result.session.id,
|
|
31
|
+
state: result.session.state,
|
|
32
|
+
});
|
|
33
|
+
export const runSessionArchive = (tokens, context) => Effect.gen(function* () {
|
|
34
|
+
const parsed = parseOptions(tokens, new Set(["--command-id", "--expected-revision"]));
|
|
35
|
+
requirePositionals(parsed.positionals, 1);
|
|
36
|
+
const { archiveSession } = context.dependencies;
|
|
37
|
+
if (archiveSession === undefined)
|
|
38
|
+
throw new CliArgumentError("Session archive is unavailable.");
|
|
39
|
+
const commandId = parsed.options.get("--command-id");
|
|
40
|
+
const result = yield* archiveSession({
|
|
41
|
+
...(commandId === undefined ? {} : { commandId }),
|
|
42
|
+
expectedRevision: readExpectedRevision(parsed.options.get("--expected-revision")),
|
|
43
|
+
sessionId: requireSessionId(parsed.positionals),
|
|
44
|
+
});
|
|
45
|
+
return writeSessionResult(result, context, (value) => ({
|
|
46
|
+
command: "session.archive",
|
|
47
|
+
result: summarizeArchive(value),
|
|
48
|
+
}));
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=coding-commands.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CommandContext, type CommandEffect } from "../command-line/index.js";
|
|
2
|
+
export declare const runSessionCreate: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
3
|
+
export declare const runSessionList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
4
|
+
export declare const runSessionShow: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
5
|
+
export declare const runSessionStart: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
6
|
+
export declare const runSessionStop: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
7
|
+
export declare const runSessionResume: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
8
|
+
export declare const runSessionEventsList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
9
|
+
export declare const runSessionObserve: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
10
|
+
export declare const runSessionMessageSend: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
11
|
+
export declare const runSessionInboxCheck: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
12
|
+
export declare const runSessionInboxAck: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
13
|
+
//# sourceMappingURL=commands.d.ts.map
|