@maiaos/cli 0.1.0-canary.55 → 0.1.0-canary.57
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 +4 -3
- package/dist/bin/maia.cdx.json +19 -19
- package/dist/bin/maia.mjs +1 -1
- package/dist/cli/cli.js +10 -0
- package/dist/command-line/context.d.ts +2 -1
- package/dist/command-line/emit/index.d.ts +1 -1
- package/dist/command-line/emit/index.js +1 -1
- package/dist/command-line/emit/rows.d.ts +1 -0
- package/dist/command-line/emit/rows.js +5 -0
- package/dist/command-line/index.d.ts +3 -3
- package/dist/command-line/index.js +3 -3
- package/dist/command-line/input/index.d.ts +2 -1
- package/dist/command-line/input/index.js +1 -0
- package/dist/command-line/input/manager-options.d.ts +10 -0
- package/dist/command-line/input/manager-options.js +38 -0
- package/dist/command-line/two-phase/index.d.ts +2 -0
- package/dist/command-line/two-phase/index.js +2 -0
- package/dist/command-line/{two-phase.d.ts → two-phase/two-phase.d.ts} +12 -12
- package/dist/command-line/{two-phase.js → two-phase/two-phase.js} +2 -2
- package/dist/command-tree/tree.d.ts +1 -1
- package/dist/command-tree/tree.js +3 -0
- package/dist/events/commands.js +4 -3
- package/dist/import/batch.js +196 -0
- package/dist/import/client.d.ts +3 -3
- package/dist/import/client.js +1 -1
- package/dist/import/commands.d.ts +1 -0
- package/dist/import/commands.js +82 -8
- package/dist/import/index.d.ts +1 -1
- package/dist/import/index.js +1 -1
- package/dist/import/input.js +16 -2
- package/dist/import/manifest.js +107 -0
- package/dist/import/output.js +44 -2
- package/dist/session/agent-permission.d.ts +2 -2
- package/dist/session/approval/commands.d.ts +1 -0
- package/dist/session/approval/commands.js +75 -9
- package/dist/session/approval/index.d.ts +1 -1
- package/dist/session/approval/index.js +1 -1
- package/dist/session/client.d.ts +2 -2
- package/dist/session/coding-client.d.ts +2 -0
- package/dist/session/coding-client.js +1 -2
- package/dist/session/coding-commands.js +24 -7
- package/dist/session/commands.js +36 -39
- package/dist/session/output/human.js +14 -3
- package/dist/session/output/tasks.js +25 -11
- package/dist/session/tree/tree.js +31 -9
- package/dist/webhooks/client.d.ts +156 -0
- package/dist/webhooks/client.js +8 -0
- package/dist/webhooks/commands.d.ts +17 -0
- package/dist/webhooks/commands.js +76 -0
- package/dist/webhooks/index.d.ts +3 -0
- package/dist/webhooks/index.js +3 -0
- package/dist/webhooks/input.js +125 -0
- package/dist/webhooks/output/format.js +75 -0
- package/dist/webhooks/output/index.js +2 -0
- package/dist/webhooks/tree/index.js +2 -0
- package/dist/webhooks/tree/tree.js +49 -0
- package/package.json +5 -5
- package/dist/address-space/address-space.d.ts +0 -38
- package/dist/address-space/index.d.ts +0 -2
- package/dist/agents/input.d.ts +0 -132
- package/dist/agents/output/format.d.ts +0 -8
- package/dist/agents/output/index.d.ts +0 -2
- package/dist/agents/tree/index.d.ts +0 -2
- package/dist/agents/tree/tree.d.ts +0 -3
- package/dist/bootstrap/exit.d.ts +0 -14
- package/dist/bootstrap/exit.js +0 -42
- package/dist/bootstrap/index.d.ts +0 -3
- package/dist/bootstrap/index.js +0 -3
- package/dist/bootstrap/process.d.ts +0 -5
- package/dist/bootstrap/process.js +0 -23
- package/dist/bootstrap/run.d.ts +0 -25
- package/dist/bootstrap/run.js +0 -98
- package/dist/bootstrap/stdio.d.ts +0 -4
- package/dist/bootstrap/stdio.js +0 -9
- package/dist/cli/environment.d.ts +0 -8
- package/dist/cli/services.d.ts +0 -4
- package/dist/command-line/emit/json-decoder.d.ts +0 -3
- package/dist/command-line/input/stdin-stream.d.ts +0 -4
- package/dist/command-receipt/command.d.ts +0 -4
- package/dist/command-receipt/compact-list.d.ts +0 -20
- package/dist/command-receipt/index.d.ts +0 -3
- package/dist/command-tree/completion.d.ts +0 -6
- package/dist/command-tree/local.d.ts +0 -3
- package/dist/command-tree/row.js +0 -2
- package/dist/connection/access/format.d.ts +0 -8
- package/dist/connection/access/input.d.ts +0 -53
- package/dist/connection/input.d.ts +0 -50
- package/dist/connection/signin.d.ts +0 -4
- package/dist/connection/tree/index.d.ts +0 -2
- package/dist/connection/tree/tree.d.ts +0 -3
- package/dist/container/output/format.d.ts +0 -11
- package/dist/container/output/index.d.ts +0 -2
- package/dist/context/client.d.ts +0 -7
- package/dist/context/commands.d.ts +0 -3
- package/dist/context/index.d.ts +0 -3
- package/dist/dashboard/cockpit-client.d.ts +0 -6
- package/dist/dashboard/cockpit-client.js +0 -27
- package/dist/dashboard/cockpits.d.ts +0 -29
- package/dist/dashboard/cockpits.js +0 -65
- package/dist/dashboard/dashboard.d.ts +0 -7
- package/dist/dashboard/draw.d.ts +0 -15
- package/dist/dashboard/frame.d.ts +0 -4
- package/dist/dashboard/index.d.ts +0 -2
- package/dist/dashboard/modes.d.ts +0 -5
- package/dist/dashboard/node-connection.d.ts +0 -15
- package/dist/dashboard/node-connection.js +0 -51
- package/dist/dashboard/pi-tui.d.ts +0 -6
- package/dist/dashboard/status-bar.d.ts +0 -4
- package/dist/dashboard/terminal.d.ts +0 -53
- package/dist/dashboard/tree-model.d.ts +0 -28
- package/dist/dashboard/tree.d.ts +0 -10
- package/dist/development/cli.d.ts +0 -3
- package/dist/development/cli.js +0 -44
- package/dist/events/commands.d.ts +0 -11
- package/dist/events/index.d.ts +0 -2
- package/dist/events/tree/index.d.ts +0 -2
- package/dist/events/tree/tree.d.ts +0 -10
- package/dist/execution/tree/index.d.ts +0 -2
- package/dist/execution/tree/tree.d.ts +0 -3
- package/dist/hold/output/format.d.ts +0 -11
- package/dist/hold/output/index.d.ts +0 -2
- package/dist/hold/tree/index.d.ts +0 -2
- package/dist/hold/tree/tree.d.ts +0 -3
- package/dist/import/input.d.ts +0 -19
- package/dist/import/output.d.ts +0 -6
- package/dist/integration/output.d.ts +0 -22
- package/dist/login/failure.d.ts +0 -3
- package/dist/login/gateway.d.ts +0 -12
- package/dist/login/menu.d.ts +0 -4
- package/dist/login/output/format.d.ts +0 -16
- package/dist/login/output/index.d.ts +0 -2
- package/dist/login/vendor-account.d.ts +0 -95
- package/dist/login/vendor-input.d.ts +0 -14
- package/dist/mcp/calls.d.ts +0 -8
- package/dist/orchestration/output/compact-aggregate.d.ts +0 -121
- package/dist/orchestration/output/compact-run-list.d.ts +0 -20
- package/dist/orchestration/output/human.d.ts +0 -80
- package/dist/orchestration/output/index.d.ts +0 -4
- package/dist/orchestration/tree/index.d.ts +0 -2
- package/dist/orchestration/tree/tree.d.ts +0 -3
- package/dist/port-lease/input.d.ts +0 -65
- package/dist/port-lease/output/format.d.ts +0 -11
- package/dist/port-lease/output/index.d.ts +0 -2
- package/dist/presentation/output/format.d.ts +0 -11
- package/dist/presentation/output/index.d.ts +0 -3
- package/dist/project-guard/input.d.ts +0 -21
- package/dist/project-guard/output/format.d.ts +0 -11
- package/dist/project-guard/output/index.d.ts +0 -2
- package/dist/project-workspace/output/human.d.ts +0 -139
- package/dist/project-workspace/output/index.d.ts +0 -3
- package/dist/project-workspace/output/metadata.d.ts +0 -11
- package/dist/project-workspace/tree/index.d.ts +0 -2
- package/dist/project-workspace/tree/tree.d.ts +0 -3
- package/dist/provider/client.d.ts +0 -6
- package/dist/provider/commands.d.ts +0 -3
- package/dist/provider/index.d.ts +0 -3
- package/dist/reference/commands.d.ts +0 -3
- package/dist/reference/index.d.ts +0 -3
- package/dist/reference/resolve.d.ts +0 -31
- package/dist/reference/tree/index.d.ts +0 -2
- package/dist/reference/tree/tree.d.ts +0 -3
- package/dist/remote-node/reachability.d.ts +0 -64
- package/dist/remote-node/text.d.ts +0 -10
- package/dist/remote-node/tree/index.d.ts +0 -2
- package/dist/remote-node/tree/tree.d.ts +0 -3
- package/dist/routine/input.d.ts +0 -28
- package/dist/routine/output/format.d.ts +0 -23
- package/dist/routine/output/index.d.ts +0 -2
- package/dist/routine/tree/index.d.ts +0 -2
- package/dist/routine/tree/tree.d.ts +0 -3
- package/dist/run-ledger/input.d.ts +0 -42
- package/dist/run-ledger/output/format.d.ts +0 -11
- package/dist/run-ledger/output/index.d.ts +0 -2
- package/dist/session/approval/output/format.d.ts +0 -23
- package/dist/session/approval/output/index.d.ts +0 -2
- package/dist/session/attach-render.d.ts +0 -16
- package/dist/session/create-tasks.d.ts +0 -20
- package/dist/session/interaction/input.d.ts +0 -15
- package/dist/session/interaction/output/format.d.ts +0 -11
- package/dist/session/interaction/output/index.d.ts +0 -2
- package/dist/session/output/diff.d.ts +0 -3
- package/dist/session/output/failure.d.ts +0 -11
- package/dist/session/output/human.d.ts +0 -115
- package/dist/session/output/index.d.ts +0 -6
- package/dist/session/output/observe.d.ts +0 -4
- package/dist/session/output/tasks.d.ts +0 -36
- package/dist/session/task-file.d.ts +0 -5
- package/dist/session/tree/index.d.ts +0 -2
- package/dist/session/tree/tree.d.ts +0 -3
- package/dist/team-workspace/ceremony.d.ts +0 -19
- package/dist/team-workspace/confirmation.d.ts +0 -4
- package/dist/team-workspace/dependencies.js +0 -2
- package/dist/team-workspace/output.d.ts +0 -15
- package/dist/terminal/arguments.d.ts +0 -13
- package/dist/terminal/keys.d.ts +0 -12
- package/dist/terminal/output/compact-list.d.ts +0 -149
- package/dist/terminal/output/human.d.ts +0 -42
- package/dist/terminal/output/index.d.ts +0 -3
- package/dist/terminal/tree/index.d.ts +0 -2
- package/dist/terminal/tree/tree.d.ts +0 -3
package/dist/cli/cli.js
CHANGED
|
@@ -223,6 +223,7 @@ const loadRemoteNode = () => import("../remote-node/index.js");
|
|
|
223
223
|
const loadRunLedger = () => import("../run-ledger/index.js");
|
|
224
224
|
const loadProjectGuard = () => import("../project-guard/index.js");
|
|
225
225
|
const loadAgents = () => import("../agents/index.js");
|
|
226
|
+
const loadWebhooks = () => import("../webhooks/index.js");
|
|
226
227
|
const loadLocalNode = () => import("../local-node/index.js");
|
|
227
228
|
const loadBootstrap = () => import("../team-workspace/index.js");
|
|
228
229
|
const lazyDependencies = (load, makeClient, binding) => Object.fromEntries(binding.names.map((name) => [
|
|
@@ -502,6 +503,15 @@ const makeDefaultCliDependencies = (binding) => ({
|
|
|
502
503
|
"showAgent",
|
|
503
504
|
],
|
|
504
505
|
}),
|
|
506
|
+
...lazyDependencies(loadWebhooks, (module, node) => module.makeWebhooksClient(node), {
|
|
507
|
+
...binding,
|
|
508
|
+
names: [
|
|
509
|
+
"confirmWebhookChange",
|
|
510
|
+
"listWebhookDeliveries",
|
|
511
|
+
"listWebhooks",
|
|
512
|
+
"previewWebhookChange",
|
|
513
|
+
],
|
|
514
|
+
}),
|
|
505
515
|
...lazyDependencies(loadRemoteNode, (module, node) => module.makeRemoteNodeClient(node), {
|
|
506
516
|
...binding,
|
|
507
517
|
names: [
|
|
@@ -25,12 +25,13 @@ import type { InteractionCliDependencies } from "../session/interaction/index.js
|
|
|
25
25
|
import type { CancelTurnInput, InterruptTurnInput, SendTurnInput, WaitTurnsInput } from "../session/turn/index.js";
|
|
26
26
|
import type { BootstrapCliDependencies } from "../team-workspace/index.js";
|
|
27
27
|
import type { CreateTerminalInput, makeTerminalClient } from "../terminal/index.js";
|
|
28
|
+
import type { WebhooksCliDependencies } from "../webhooks/index.js";
|
|
28
29
|
import type { CliIo, CliResolution } from "./emit/index.js";
|
|
29
30
|
import type { CliArgumentError } from "./input/index.js";
|
|
30
31
|
type OrchestrationClient = ReturnType<typeof makeOrchestrationClient>;
|
|
31
32
|
type SessionClient = ReturnType<typeof makeSessionClient>;
|
|
32
33
|
type TerminalClient = ReturnType<typeof makeTerminalClient>;
|
|
33
|
-
export type CliDependencies = Partial<AgentsCliDependencies & ApprovalCliDependencies & BootstrapCliDependencies & ConnectionCliDependencies & ContainerCliDependencies & HoldCliDependencies & DiscoveryCliDependencies & IntegrationCliDependencies & PresentationCliDependencies & McpCliDependencies & InteractionCliDependencies & PortLeaseCliDependencies & ProjectGuardCliDependencies & ProjectMetadataCliDependencies & RemoteNodeCliDependencies & RoutineCliDependencies & RunLedgerCliDependencies> & {
|
|
34
|
+
export type CliDependencies = Partial<AgentsCliDependencies & ApprovalCliDependencies & BootstrapCliDependencies & ConnectionCliDependencies & ContainerCliDependencies & HoldCliDependencies & DiscoveryCliDependencies & IntegrationCliDependencies & PresentationCliDependencies & McpCliDependencies & InteractionCliDependencies & PortLeaseCliDependencies & ProjectGuardCliDependencies & ProjectMetadataCliDependencies & RemoteNodeCliDependencies & RoutineCliDependencies & RunLedgerCliDependencies & WebhooksCliDependencies> & {
|
|
34
35
|
readonly acknowledgeAttachedSessionDelivery?: (input: Parameters<SessionClient["acknowledgeAttachedSessionDelivery"]>[0]) => CliNodeEffect<SessionInboxAckResult>;
|
|
35
36
|
readonly acknowledgeRunDelivery: (input: Parameters<OrchestrationClient["acknowledgeRunDelivery"]>[0]) => CliNodeEffect<OrchestrationInboxAckResult>;
|
|
36
37
|
readonly acquireTerminalController: (input: Parameters<TerminalClient["acquireTerminalController"]>[0]) => CliNodeEffect<LiveTerminalControllerAcquireResult>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { decodeJsonText, jsonLine } from "./json.js";
|
|
2
2
|
export { type CliCommandOutput, type CliErrorOutput, type CliIo, type CliResolution, type CliSuccessOutput, type CliSuccessResult, exitCodeOf, type NodeResultPresenter, type OutputContext, reportError, writeNodeResult, writeSuccess, } from "./output.js";
|
|
3
|
-
export { block, cell, type CliTable, fields, formatRows, tab, withNextPage, withPrunedHistory, } from "./rows.js";
|
|
3
|
+
export { block, cell, type CliTable, fields, formatRows, labelCells, tab, withNextPage, withPrunedHistory, } from "./rows.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { decodeJsonText, jsonLine } from "./json.js";
|
|
2
2
|
export { exitCodeOf, reportError, writeNodeResult, writeSuccess, } from "./output.js";
|
|
3
|
-
export { block, cell, fields, formatRows, tab, withNextPage, withPrunedHistory, } from "./rows.js";
|
|
3
|
+
export { block, cell, fields, formatRows, labelCells, tab, withNextPage, withPrunedHistory, } from "./rows.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const isTerminalControl: (character: string) => boolean;
|
|
2
2
|
export declare const cell: (value: string) => string;
|
|
3
3
|
export declare const block: (value: string) => string;
|
|
4
|
+
export declare const labelCells: (labels: Readonly<Record<string, string>> | undefined) => string;
|
|
4
5
|
export declare const tab: (values: readonly unknown[]) => string;
|
|
5
6
|
export declare const fields: (entries: readonly (readonly [label: string, value: string | undefined])[]) => string;
|
|
6
7
|
export type CliTable = {
|
|
@@ -11,6 +11,11 @@ export const isTerminalControl = (character) => {
|
|
|
11
11
|
const replaceControls = (value, kept) => Array.from(value, (character) => !kept.includes(character) && isTerminalControl(character) ? "�" : character).join("");
|
|
12
12
|
export const cell = (value) => replaceControls(value, "");
|
|
13
13
|
export const block = (value) => replaceControls(value, "\t\n");
|
|
14
|
+
export const labelCells = (labels) => labels === undefined
|
|
15
|
+
? "-"
|
|
16
|
+
: Object.entries(labels)
|
|
17
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
18
|
+
.join(",");
|
|
14
19
|
export const tab = (values) => values.join("\t");
|
|
15
20
|
const align = (rows) => {
|
|
16
21
|
const widths = rows.reduce((sizes, row) => row.map((value, index) => Math.max(sizes[index] ?? 0, value.length)), []);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { type CliDependencies, type CliServices, type CommandContext, type CommandEffect, LOCAL_NODE, } from "./context.js";
|
|
2
2
|
export { decodeJsonText, jsonLine } from "./emit/index.js";
|
|
3
3
|
export { type CliCommandOutput, type CliErrorOutput, type CliIo, type CliResolution, type CliSuccessOutput, type CliSuccessResult, exitCodeOf, type NodeResultPresenter, reportError, writeNodeResult, writeSuccess, } from "./emit/index.js";
|
|
4
|
-
export { block, cell, type CliTable, fields, formatRows, tab, withNextPage, withPrunedHistory, } from "./emit/index.js";
|
|
5
|
-
export { argumentsAreBounded, type ArgumentToken, CliArgumentError, missingArgument, parseArguments, type ParsedArguments, type ParsedOptions, parseOptions, parseOptionsWith, readBoundedStdin, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readPermission, readRevisionOption, readWaitTimeoutSeconds, recoverStdin, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./input/index.js";
|
|
6
|
-
export { askToConfirm, canPrompt, confirmationOf, confirmParameters, EXIT_CANCELLED, peekStdin, promptOrRefuse, readInputMode, readPipedPreview, readTwoPhaseMode, requestedTwoPhaseMode, runInputTwoPhase, runTwoPhase, TWO_PHASE_FLAGS, type TwoPhaseMode, } from "./two-phase.js";
|
|
4
|
+
export { block, cell, type CliTable, fields, formatRows, labelCells, tab, withNextPage, withPrunedHistory, } from "./emit/index.js";
|
|
5
|
+
export { argumentsAreBounded, type ArgumentToken, CliArgumentError, LABEL_OPTION, missingArgument, type OptionSpec, parseArguments, type ParsedArguments, type ParsedOptions, parseOptions, parseOptionsWith, readBoundedStdin, readCursor, readDuration, readExpectedRevision, readGlobalValue, readLabels, readPageSize, readPermission, readRevisionOption, readSessionRole, readSessionTitle, readWaitTimeoutSeconds, recoverStdin, requireNoArguments, requireOneLabelPerOption, requirePositionals, tokenizeArguments, unknownCommand, } from "./input/index.js";
|
|
6
|
+
export { askToConfirm, canPrompt, confirmationOf, confirmParameters, EXIT_CANCELLED, peekStdin, promptOrRefuse, readInputMode, readPipedPreview, readTwoPhaseMode, requestedTwoPhaseMode, runInputTwoPhase, runTwoPhase, TWO_PHASE_FLAGS, type TwoPhaseMode, } from "./two-phase/index.js";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { LOCAL_NODE, } from "./context.js";
|
|
2
2
|
export { decodeJsonText, jsonLine } from "./emit/index.js";
|
|
3
3
|
export { exitCodeOf, reportError, writeNodeResult, writeSuccess, } from "./emit/index.js";
|
|
4
|
-
export { block, cell, fields, formatRows, tab, withNextPage, withPrunedHistory, } from "./emit/index.js";
|
|
5
|
-
export { argumentsAreBounded, CliArgumentError, missingArgument, parseArguments, parseOptions, parseOptionsWith, readBoundedStdin, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readPermission, readRevisionOption, readWaitTimeoutSeconds, recoverStdin, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./input/index.js";
|
|
6
|
-
export { askToConfirm, canPrompt, confirmationOf, confirmParameters, EXIT_CANCELLED, peekStdin, promptOrRefuse, readInputMode, readPipedPreview, readTwoPhaseMode, requestedTwoPhaseMode, runInputTwoPhase, runTwoPhase, TWO_PHASE_FLAGS, } from "./two-phase.js";
|
|
4
|
+
export { block, cell, fields, formatRows, labelCells, tab, withNextPage, withPrunedHistory, } from "./emit/index.js";
|
|
5
|
+
export { argumentsAreBounded, CliArgumentError, LABEL_OPTION, missingArgument, parseArguments, parseOptions, parseOptionsWith, readBoundedStdin, readCursor, readDuration, readExpectedRevision, readGlobalValue, readLabels, readPageSize, readPermission, readRevisionOption, readSessionRole, readSessionTitle, readWaitTimeoutSeconds, recoverStdin, requireNoArguments, requireOneLabelPerOption, requirePositionals, tokenizeArguments, unknownCommand, } from "./input/index.js";
|
|
6
|
+
export { askToConfirm, canPrompt, confirmationOf, confirmParameters, EXIT_CANCELLED, peekStdin, promptOrRefuse, readInputMode, readPipedPreview, readTwoPhaseMode, requestedTwoPhaseMode, runInputTwoPhase, runTwoPhase, TWO_PHASE_FLAGS, } from "./two-phase/index.js";
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { argumentsAreBounded, type ArgumentToken, CliArgumentError, missingArgument, parseArguments, type ParsedArguments, type ParsedOptions, parseOptions, parseOptionsWith, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readPermission, readRevisionOption, readWaitTimeoutSeconds, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./arguments.js";
|
|
1
|
+
export { argumentsAreBounded, type ArgumentToken, CliArgumentError, missingArgument, type OptionSpec, parseArguments, type ParsedArguments, type ParsedOptions, parseOptions, parseOptionsWith, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readPermission, readRevisionOption, readWaitTimeoutSeconds, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./arguments.js";
|
|
2
|
+
export { LABEL_OPTION, readLabels, readSessionRole, readSessionTitle, requireOneLabelPerOption, } from "./manager-options.js";
|
|
2
3
|
export { promptLine, type PromptOptions, terminalIsInteractive, } from "./prompt.js";
|
|
3
4
|
export { type BoundedStdinRequest, readBoundedStdin, recoverStdin, replayStdin, } from "./stdin.js";
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { argumentsAreBounded, CliArgumentError, missingArgument, parseArguments, parseOptions, parseOptionsWith, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readPermission, readRevisionOption, readWaitTimeoutSeconds, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./arguments.js";
|
|
2
|
+
export { LABEL_OPTION, readLabels, readSessionRole, readSessionTitle, requireOneLabelPerOption, } from "./manager-options.js";
|
|
2
3
|
export { promptLine, terminalIsInteractive, } from "./prompt.js";
|
|
3
4
|
export { readBoundedStdin, recoverStdin, replayStdin, } from "./stdin.js";
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const LABEL_OPTION: ReadonlySet<string>;
|
|
2
|
+
export declare const requireOneLabelPerOption: (tokens: readonly string[]) => void;
|
|
3
|
+
export declare const readLabels: (value: string | undefined) => {
|
|
4
|
+
readonly labels?: Readonly<Record<string, string>>;
|
|
5
|
+
};
|
|
6
|
+
export declare const readSessionRole: (value: string | undefined) => {
|
|
7
|
+
readonly role?: "orchestrator" | "worker";
|
|
8
|
+
};
|
|
9
|
+
export declare const readSessionTitle: (options: ReadonlyMap<string, string>) => string | undefined;
|
|
10
|
+
//# sourceMappingURL=manager-options.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CliArgumentError } from "./arguments.js";
|
|
2
|
+
export const LABEL_OPTION = new Set(["--label"]);
|
|
3
|
+
export const requireOneLabelPerOption = (tokens) => {
|
|
4
|
+
const given = tokens.flatMap((token, index) => {
|
|
5
|
+
if (tokens[index - 1] === "--label")
|
|
6
|
+
return [token];
|
|
7
|
+
return token.startsWith("--label=") ? [token.slice("--label=".length)] : [];
|
|
8
|
+
});
|
|
9
|
+
if (given.some((value) => value.includes(",")))
|
|
10
|
+
throw new CliArgumentError("Option '--label' takes one key=value; repeat the option for more.");
|
|
11
|
+
};
|
|
12
|
+
export const readLabels = (value) => {
|
|
13
|
+
if (value === undefined)
|
|
14
|
+
return {};
|
|
15
|
+
const pairs = value.split(",").map((pair) => {
|
|
16
|
+
const separator = pair.indexOf("=");
|
|
17
|
+
if (separator < 1)
|
|
18
|
+
throw new CliArgumentError("Option '--label' takes key=value.");
|
|
19
|
+
return [pair.slice(0, separator), pair.slice(separator + 1)];
|
|
20
|
+
});
|
|
21
|
+
const duplicate = pairs.find(([key], index) => pairs.findIndex(([other]) => other === key) !== index);
|
|
22
|
+
if (duplicate !== undefined)
|
|
23
|
+
throw new CliArgumentError(`Label '${duplicate[0]}' is given twice.`);
|
|
24
|
+
return { labels: Object.fromEntries(pairs) };
|
|
25
|
+
};
|
|
26
|
+
export const readSessionRole = (value) => {
|
|
27
|
+
if (value === undefined)
|
|
28
|
+
return {};
|
|
29
|
+
if (value === "worker" || value === "orchestrator")
|
|
30
|
+
return { role: value };
|
|
31
|
+
throw new CliArgumentError("Option '--role' must be worker or orchestrator.");
|
|
32
|
+
};
|
|
33
|
+
export const readSessionTitle = (options) => {
|
|
34
|
+
if (options.has("--name") && options.has("--title"))
|
|
35
|
+
throw new CliArgumentError("Use one of '--name' or '--title'.");
|
|
36
|
+
return options.get("--title") ?? options.get("--name");
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=manager-options.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { askToConfirm, canPrompt, confirmationOf, confirmParameters, EXIT_CANCELLED, peekStdin, promptOrRefuse, readInputMode, readPipedPreview, readTwoPhaseMode, requestedTwoPhaseMode, runInputTwoPhase, runTwoPhase, TWO_PHASE_FLAGS, type TwoPhaseMode, } from "./two-phase.js";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { askToConfirm, canPrompt, confirmationOf, confirmParameters, EXIT_CANCELLED, peekStdin, promptOrRefuse, readInputMode, readPipedPreview, readTwoPhaseMode, requestedTwoPhaseMode, runInputTwoPhase, runTwoPhase, TWO_PHASE_FLAGS, } from "./two-phase.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
|
-
import type { CliNodeResult } from "
|
|
3
|
-
import type
|
|
4
|
-
import { CliArgumentError } from "
|
|
2
|
+
import type { CliNodeResult } from "../../local-node/index.js";
|
|
3
|
+
import { type OutputContext } from "../emit/index.js";
|
|
4
|
+
import { CliArgumentError } from "../input/index.js";
|
|
5
5
|
export type TwoPhaseMode = "confirm-stdin" | "dry-run" | "prompt" | "yes";
|
|
6
6
|
export declare const TWO_PHASE_FLAGS: readonly string[];
|
|
7
|
-
export declare const canPrompt: (context:
|
|
7
|
+
export declare const canPrompt: (context: OutputContext) => boolean;
|
|
8
8
|
export declare const requestedTwoPhaseMode: (flags: ReadonlySet<string>, offersYes?: boolean) => Exclude<TwoPhaseMode, "prompt"> | undefined;
|
|
9
|
-
export declare const promptOrRefuse: (context:
|
|
10
|
-
export declare const readTwoPhaseMode: (flags: ReadonlySet<string>, context:
|
|
11
|
-
export declare const readPipedPreview: (context:
|
|
12
|
-
export declare const peekStdin: (context:
|
|
13
|
-
readonly context:
|
|
9
|
+
export declare const promptOrRefuse: (context: OutputContext, offersYes?: boolean) => "prompt";
|
|
10
|
+
export declare const readTwoPhaseMode: (flags: ReadonlySet<string>, context: OutputContext, offersYes?: boolean) => TwoPhaseMode;
|
|
11
|
+
export declare const readPipedPreview: (context: OutputContext) => Effect.Effect<object, CliArgumentError>;
|
|
12
|
+
export declare const peekStdin: <TContext extends OutputContext>(context: TContext) => Effect.Effect<{
|
|
13
|
+
readonly context: TContext;
|
|
14
14
|
readonly input: unknown;
|
|
15
15
|
}>;
|
|
16
16
|
export declare const confirmParameters: <TParameters>(schema: {
|
|
@@ -22,11 +22,11 @@ export declare const confirmParameters: <TParameters>(schema: {
|
|
|
22
22
|
};
|
|
23
23
|
}, preview: object, previewOnly?: readonly string[]) => Effect.Effect<TParameters, CliArgumentError>;
|
|
24
24
|
export declare const confirmationOf: (preview: object, previewOnly?: readonly string[]) => Record<string, unknown>;
|
|
25
|
-
export declare const askToConfirm: (context:
|
|
25
|
+
export declare const askToConfirm: (context: OutputContext, question: string) => Effect.Effect<boolean>;
|
|
26
26
|
export declare const EXIT_CANCELLED = 1;
|
|
27
27
|
export type TwoPhaseSpec<TPreview extends object, TConfirm, TRequirements> = {
|
|
28
28
|
readonly confirm: (preview: object) => Effect.Effect<CliNodeResult<TConfirm>, CliArgumentError, TRequirements>;
|
|
29
|
-
readonly context:
|
|
29
|
+
readonly context: OutputContext;
|
|
30
30
|
readonly mode: TwoPhaseMode;
|
|
31
31
|
readonly preview: () => Effect.Effect<CliNodeResult<TPreview>, CliArgumentError, TRequirements>;
|
|
32
32
|
readonly prompt?: {
|
|
@@ -48,7 +48,7 @@ type SafeParser<TValue> = {
|
|
|
48
48
|
export type InputTwoPhaseSpec<TPreviewParameters, TPreview extends object, TConfirmParameters, TConfirm, TRequirements> = {
|
|
49
49
|
readonly confirm?: (parameters: TConfirmParameters) => Effect.Effect<CliNodeResult<TConfirm>, never, TRequirements>;
|
|
50
50
|
readonly confirmSchema: SafeParser<TConfirmParameters>;
|
|
51
|
-
readonly context:
|
|
51
|
+
readonly context: OutputContext;
|
|
52
52
|
readonly label: string;
|
|
53
53
|
readonly preview?: (parameters: TPreviewParameters) => Effect.Effect<CliNodeResult<TPreview>, never, TRequirements>;
|
|
54
54
|
readonly previewOnly?: readonly string[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as Cause from "effect/Cause";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Exit from "effect/Exit";
|
|
4
|
-
import { decodeJsonText } from "
|
|
5
|
-
import { CliArgumentError, parseOptions, recoverStdin, replayStdin, requirePositionals, } from "
|
|
4
|
+
import { decodeJsonText } from "../emit/index.js";
|
|
5
|
+
import { CliArgumentError, parseOptions, recoverStdin, replayStdin, requirePositionals, } from "../input/index.js";
|
|
6
6
|
export const TWO_PHASE_FLAGS = [
|
|
7
7
|
"--confirm-stdin",
|
|
8
8
|
"--dry-run",
|
|
@@ -20,7 +20,7 @@ export type TreeNode = {
|
|
|
20
20
|
readonly summary: string;
|
|
21
21
|
};
|
|
22
22
|
export declare const TREE_FRAGMENTS: readonly TreeFragment[];
|
|
23
|
-
export declare const TREE_SECTIONS: readonly [readonly ["Start and sign in", readonly ["setup", "login", "status"]], readonly ["Work", readonly ["session", "run", "routine", "import"]], readonly ["Resources", readonly ["project", "workspace", "container", "terminal", "execution", "port", "reference", "agents"]], readonly ["Accounts and Nodes", readonly ["connection", "integration", "provider", "node"]], readonly ["Safety and audit", readonly ["hold", "receipt", "events", "context"]], readonly ["Clients and local", readonly ["presentation", "mcp", "dashboard", "agent", "help", "version", "doctor", "completion"]]];
|
|
23
|
+
export declare const TREE_SECTIONS: readonly [readonly ["Start and sign in", readonly ["setup", "login", "status"]], readonly ["Work", readonly ["session", "run", "routine", "import"]], readonly ["Resources", readonly ["project", "workspace", "container", "terminal", "execution", "port", "reference", "agents", "webhooks"]], readonly ["Accounts and Nodes", readonly ["connection", "integration", "provider", "node"]], readonly ["Safety and audit", readonly ["hold", "receipt", "events", "context"]], readonly ["Clients and local", readonly ["presentation", "mcp", "dashboard", "agent", "help", "version", "doctor", "completion"]]];
|
|
24
24
|
export declare const usagePath: (usage: string) => readonly string[];
|
|
25
25
|
export declare const COMMAND_TREE: TreeNode;
|
|
26
26
|
export declare const commandTree: () => TreeNode;
|
|
@@ -11,6 +11,7 @@ import { NODE_TREE } from "../remote-node/tree/index.js";
|
|
|
11
11
|
import { ROUTINE_TREE } from "../routine/tree/index.js";
|
|
12
12
|
import { SESSION_TREE } from "../session/tree/index.js";
|
|
13
13
|
import { TERMINAL_TREE } from "../terminal/tree/index.js";
|
|
14
|
+
import { WEBHOOKS_TREE } from "../webhooks/tree/index.js";
|
|
14
15
|
import { LOCAL_TREE } from "./local.js";
|
|
15
16
|
export const TREE_FRAGMENTS = [
|
|
16
17
|
NODE_TREE,
|
|
@@ -25,6 +26,7 @@ export const TREE_FRAGMENTS = [
|
|
|
25
26
|
EXECUTION_TREE,
|
|
26
27
|
SAFETY_TREE,
|
|
27
28
|
AGENTS_TREE,
|
|
29
|
+
WEBHOOKS_TREE,
|
|
28
30
|
LOCAL_TREE,
|
|
29
31
|
];
|
|
30
32
|
export const TREE_SECTIONS = [
|
|
@@ -41,6 +43,7 @@ export const TREE_SECTIONS = [
|
|
|
41
43
|
"port",
|
|
42
44
|
"reference",
|
|
43
45
|
"agents",
|
|
46
|
+
"webhooks",
|
|
44
47
|
],
|
|
45
48
|
],
|
|
46
49
|
["Accounts and Nodes", ["connection", "integration", "provider", "node"]],
|
package/dist/events/commands.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { findEventKind, localNodeRequestPayloadSchema, SESSION_ACTIVITY_SUBJECT_TYPE, } from "@maiaos/sdk";
|
|
1
|
+
import { findEventKind, localNodeRequestPayloadSchema, SESSION_ACTIVITY_SUBJECT_TYPE, SESSION_STATUS_SUBJECT_TYPE, } from "@maiaos/sdk";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import { cell, writeNodeResult, } from "../command-line/emit/index.js";
|
|
4
4
|
import { CliArgumentError, parseOptionsWith, readPageSize, requirePositionals, } from "../command-line/input/index.js";
|
|
@@ -8,8 +8,9 @@ const readSubject = (value) => {
|
|
|
8
8
|
if (split < 1 || split === value.length - 1)
|
|
9
9
|
throw new CliArgumentError("Option '--subject' must be <type>:<id>.");
|
|
10
10
|
const type = value.slice(0, split);
|
|
11
|
-
if (type !== SESSION_ACTIVITY_SUBJECT_TYPE
|
|
12
|
-
|
|
11
|
+
if (type !== SESSION_ACTIVITY_SUBJECT_TYPE &&
|
|
12
|
+
type !== SESSION_STATUS_SUBJECT_TYPE)
|
|
13
|
+
throw new CliArgumentError(`Option '--subject' type must be ${SESSION_ACTIVITY_SUBJECT_TYPE} or ${SESSION_STATUS_SUBJECT_TYPE}.`);
|
|
13
14
|
return { id: value.slice(split + 1), type };
|
|
14
15
|
};
|
|
15
16
|
const readKinds = (value) => {
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { ADOPTION_REFUSED_ERROR_CODE, } from "@maiaos/sdk";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import { jsonLine } from "../command-line/emit/index.js";
|
|
5
|
+
import { CliArgumentError } from "../command-line/input/index.js";
|
|
6
|
+
import { newCliIdentifier, } from "../local-node/index.js";
|
|
7
|
+
import { MAX_IMPORT_BYTES, MAX_IMPORT_ENTRIES, } from "./manifest.js";
|
|
8
|
+
const MAX_REASON_CHARACTERS = 300;
|
|
9
|
+
const harness = Schema.Literals(["claude-code", "codex-cli"]);
|
|
10
|
+
const nativeId = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_.:-]{1,200}$/u));
|
|
11
|
+
const base = { harness, index: Schema.Int, nativeId };
|
|
12
|
+
const reason = Schema.String.check(Schema.isMaxLength(MAX_REASON_CHARACTERS));
|
|
13
|
+
const sessionId = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_.:-]{1,200}$/u));
|
|
14
|
+
const plannedEntry = Schema.Union([
|
|
15
|
+
Schema.Struct({
|
|
16
|
+
...base,
|
|
17
|
+
commandId: sessionId,
|
|
18
|
+
connectionId: sessionId,
|
|
19
|
+
expiresAt: Schema.String,
|
|
20
|
+
hostAuthority: Schema.optional(Schema.Literal(true)),
|
|
21
|
+
inputDigest: Schema.String,
|
|
22
|
+
labels: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
23
|
+
outcome: Schema.Literal("adopt"),
|
|
24
|
+
permission: Schema.optional(Schema.String.check(Schema.isMaxLength(64))),
|
|
25
|
+
previewId: Schema.String.check(Schema.isPattern(/^adopt_[A-Za-z0-9_-]{43}$/u)),
|
|
26
|
+
role: Schema.optional(Schema.Literals(["orchestrator", "worker"])),
|
|
27
|
+
title: Schema.optional(Schema.String.check(Schema.isMaxLength(80))),
|
|
28
|
+
workingDirectory: Schema.String.check(Schema.isMaxLength(4096)),
|
|
29
|
+
workspaceId: sessionId,
|
|
30
|
+
}),
|
|
31
|
+
Schema.Struct({ ...base, outcome: Schema.Literal("skipped"), sessionId }),
|
|
32
|
+
Schema.Struct({ ...base, outcome: Schema.Literal("refused"), reason }),
|
|
33
|
+
]);
|
|
34
|
+
const importPlan = Schema.Struct({
|
|
35
|
+
entries: Schema.Array(plannedEntry).check(Schema.isMinLength(1), Schema.isMaxLength(MAX_IMPORT_ENTRIES)),
|
|
36
|
+
method: Schema.Literal("session.import.preview"),
|
|
37
|
+
});
|
|
38
|
+
const cut = (text) => text.length > MAX_REASON_CHARACTERS
|
|
39
|
+
? `${text.slice(0, MAX_REASON_CHARACTERS - 1)}…`
|
|
40
|
+
: text;
|
|
41
|
+
const identityOf = ({ harness, index, nativeId }) => ({
|
|
42
|
+
harness,
|
|
43
|
+
index,
|
|
44
|
+
nativeId,
|
|
45
|
+
});
|
|
46
|
+
const refusedBy = (identity, error) => ({
|
|
47
|
+
...identity,
|
|
48
|
+
outcome: "refused",
|
|
49
|
+
reason: cut(`${error.code}: ${error.message}`),
|
|
50
|
+
});
|
|
51
|
+
const managerFields = ({ labels, role, title }) => ({
|
|
52
|
+
...(labels === undefined ? {} : { labels }),
|
|
53
|
+
...(role === undefined ? {} : { role }),
|
|
54
|
+
...(title === undefined ? {} : { title }),
|
|
55
|
+
});
|
|
56
|
+
const plannedFrom = (identity, commandId, value) => "alreadyAdopted" in value
|
|
57
|
+
? {
|
|
58
|
+
...identity,
|
|
59
|
+
outcome: "skipped",
|
|
60
|
+
sessionId: value.alreadyAdopted.sessionId,
|
|
61
|
+
}
|
|
62
|
+
: {
|
|
63
|
+
...identity,
|
|
64
|
+
commandId,
|
|
65
|
+
connectionId: value.connectionId,
|
|
66
|
+
expiresAt: value.expiresAt,
|
|
67
|
+
...(value.hostAuthority === true
|
|
68
|
+
? { hostAuthority: true }
|
|
69
|
+
: {}),
|
|
70
|
+
inputDigest: value.inputDigest,
|
|
71
|
+
outcome: "adopt",
|
|
72
|
+
...(value.permission === undefined
|
|
73
|
+
? {}
|
|
74
|
+
: { permission: value.permission }),
|
|
75
|
+
...managerFields(value),
|
|
76
|
+
previewId: value.previewId,
|
|
77
|
+
workingDirectory: value.workingDirectory,
|
|
78
|
+
workspaceId: value.workspaceId,
|
|
79
|
+
};
|
|
80
|
+
const previewEntry = (entry, previewAdopt) => {
|
|
81
|
+
const identity = identityOf(entry);
|
|
82
|
+
return Effect.gen(function* () {
|
|
83
|
+
const commandId = yield* newCliIdentifier("command");
|
|
84
|
+
const answer = yield* previewAdopt({ ...entry.request, commandId });
|
|
85
|
+
return answer.ok
|
|
86
|
+
? plannedFrom(identity, commandId, answer.value)
|
|
87
|
+
: refusedBy(identity, answer.error);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
export const previewOutputBytes = (plan) => new TextEncoder().encode(jsonLine({ ok: true, result: { command: "session.import", result: plan } })).length;
|
|
91
|
+
export const previewImport = (entries, previewAdopt) => Effect.forEach(entries, (entry) => previewEntry(entry, previewAdopt)).pipe(Effect.map((planned) => ({
|
|
92
|
+
entries: planned,
|
|
93
|
+
method: "session.import.preview",
|
|
94
|
+
})), Effect.filterOrFail((plan) => previewOutputBytes(plan) <= MAX_IMPORT_BYTES, () => new CliArgumentError(`The preview artifact exceeds ${String(MAX_IMPORT_BYTES)} bytes, the most '--confirm-stdin' reads; split the import file.`)));
|
|
95
|
+
export const readImportPlan = (value) => {
|
|
96
|
+
try {
|
|
97
|
+
return Schema.decodeUnknownSync(importPlan, { onExcessProperty: "error" })(value);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
throw new CliArgumentError("The piped preview is invalid; pipe the output of 'maia --json session import --from <file> --dry-run'.");
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const AMBIGUOUS_CODES = new Set([
|
|
104
|
+
"deadline_exceeded",
|
|
105
|
+
"outcome_unknown",
|
|
106
|
+
"transport_failed",
|
|
107
|
+
]);
|
|
108
|
+
const failedConfirm = (entry, error) => {
|
|
109
|
+
const identity = identityOf(entry);
|
|
110
|
+
if (error.code === "already_adopted")
|
|
111
|
+
return { ...identity, outcome: "skipped" };
|
|
112
|
+
return AMBIGUOUS_CODES.has(error.code)
|
|
113
|
+
? {
|
|
114
|
+
...identity,
|
|
115
|
+
commandId: entry.commandId,
|
|
116
|
+
outcome: "unknown",
|
|
117
|
+
reason: cut(`${error.message} Check 'maia receipt show ${entry.commandId}' before importing again.`),
|
|
118
|
+
}
|
|
119
|
+
: refusedBy(identity, error);
|
|
120
|
+
};
|
|
121
|
+
const mismatch = (entry, value) => {
|
|
122
|
+
const differs = [
|
|
123
|
+
["command ID", value.commandId, entry.commandId],
|
|
124
|
+
["input digest", value.inputDigest, entry.inputDigest],
|
|
125
|
+
["executor", value.adoption.executor, entry.harness],
|
|
126
|
+
["native ID", value.adoption.nativeId, entry.nativeId],
|
|
127
|
+
["connection", value.adoption.connectionId, entry.connectionId],
|
|
128
|
+
].filter(([, got, wanted]) => got !== wanted);
|
|
129
|
+
return differs.length === 0
|
|
130
|
+
? undefined
|
|
131
|
+
: differs.map(([name]) => name).join(", ");
|
|
132
|
+
};
|
|
133
|
+
const confirmed = (entry, value) => {
|
|
134
|
+
const differs = mismatch(entry, value);
|
|
135
|
+
return differs === undefined
|
|
136
|
+
? {
|
|
137
|
+
...identityOf(entry),
|
|
138
|
+
commandId: entry.commandId,
|
|
139
|
+
delivery: value.delivery,
|
|
140
|
+
outcome: "adopted",
|
|
141
|
+
receiptId: value.receipt.receiptId,
|
|
142
|
+
sessionId: value.session.id,
|
|
143
|
+
}
|
|
144
|
+
: {
|
|
145
|
+
...identityOf(entry),
|
|
146
|
+
commandId: entry.commandId,
|
|
147
|
+
outcome: "unknown",
|
|
148
|
+
reason: cut(`The Node confirmed a different adoption than the preview (${differs}). Check 'maia receipt show ${entry.commandId}' before importing again.`),
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
const settled = (entry, answer) => answer.ok
|
|
152
|
+
? confirmed(entry, answer.value)
|
|
153
|
+
: failedConfirm(entry, answer.error);
|
|
154
|
+
const carried = (entry) => entry.outcome === "skipped"
|
|
155
|
+
? { ...identityOf(entry), outcome: "skipped", sessionId: entry.sessionId }
|
|
156
|
+
: { ...identityOf(entry), outcome: "refused", reason: entry.reason };
|
|
157
|
+
const confirmEntry = (entry, stopped, confirmAdopt) => {
|
|
158
|
+
if (entry.outcome !== "adopt")
|
|
159
|
+
return Effect.succeed(carried(entry));
|
|
160
|
+
if (stopped)
|
|
161
|
+
return Effect.succeed({
|
|
162
|
+
...identityOf(entry),
|
|
163
|
+
commandId: entry.commandId,
|
|
164
|
+
outcome: "not-attempted",
|
|
165
|
+
});
|
|
166
|
+
return confirmAdopt({
|
|
167
|
+
inputDigest: entry.inputDigest,
|
|
168
|
+
previewId: entry.previewId,
|
|
169
|
+
}).pipe(Effect.map((answer) => settled(entry, answer)));
|
|
170
|
+
};
|
|
171
|
+
export const confirmImport = (plan, confirmAdopt) => Effect.reduce(plan.entries, () => ({ entries: [], stopped: false }), (state, entry) => confirmEntry(entry, state.stopped, confirmAdopt).pipe(Effect.map((result) => ({
|
|
172
|
+
entries: [...state.entries, result],
|
|
173
|
+
stopped: state.stopped || result.outcome === "unknown",
|
|
174
|
+
})))).pipe(Effect.map(({ entries }) => ({
|
|
175
|
+
entries,
|
|
176
|
+
method: "session.import.confirm",
|
|
177
|
+
})));
|
|
178
|
+
export const firstFailure = (result) => {
|
|
179
|
+
const failed = result.entries.find((entry) => entry.outcome !== "adopted" && entry.outcome !== "skipped");
|
|
180
|
+
if (failed === undefined)
|
|
181
|
+
return undefined;
|
|
182
|
+
if (failed.outcome === "refused")
|
|
183
|
+
return {
|
|
184
|
+
code: ADOPTION_REFUSED_ERROR_CODE,
|
|
185
|
+
message: failed.reason,
|
|
186
|
+
retryable: false,
|
|
187
|
+
};
|
|
188
|
+
return {
|
|
189
|
+
code: "outcome_unknown",
|
|
190
|
+
message: failed.outcome === "unknown"
|
|
191
|
+
? failed.reason
|
|
192
|
+
: `Entry ${String(failed.index)} was not attempted.`,
|
|
193
|
+
retryable: false,
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
//# sourceMappingURL=batch.js.map
|
package/dist/import/client.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type DiscoverySessionsListParameters, type DiscoverySessionsListResult, type SessionAdoptConfirmResult, type
|
|
1
|
+
import { type DiscoverySessionsListParameters, type DiscoverySessionsListResult, type SessionAdoptConfirmParameters, type SessionAdoptConfirmResult, type SessionAdoptPreviewOutcome, type SessionAdoptPreviewParameters, type SessionHistoryReadParameters, type SessionHistoryReadResult } from "@maiaos/sdk";
|
|
2
2
|
import { type CliNodeEffect, type CliNodeOperations } from "../local-node/index.js";
|
|
3
3
|
type AdoptInput = Omit<SessionAdoptPreviewParameters, "commandId"> & {
|
|
4
4
|
readonly commandId?: string;
|
|
5
5
|
};
|
|
6
6
|
export declare const makeDiscoveryClient: (node: CliNodeOperations) => {
|
|
7
|
-
previewSessionAdopt: (input: AdoptInput) => CliNodeEffect<
|
|
8
|
-
confirmSessionAdopt: (
|
|
7
|
+
previewSessionAdopt: (input: AdoptInput) => CliNodeEffect<SessionAdoptPreviewOutcome>;
|
|
8
|
+
confirmSessionAdopt: (input: SessionAdoptConfirmParameters) => CliNodeEffect<SessionAdoptConfirmResult>;
|
|
9
9
|
listDiscoveredSessions: (input: DiscoverySessionsListParameters) => CliNodeEffect<DiscoverySessionsListResult>;
|
|
10
10
|
readSessionHistory: (input: SessionHistoryReadParameters) => CliNodeEffect<SessionHistoryReadResult>;
|
|
11
11
|
};
|
package/dist/import/client.js
CHANGED
|
@@ -5,7 +5,7 @@ const makePreviewClient = (node) => ({
|
|
|
5
5
|
previewSessionAdopt: (input) => Effect.flatMap(commandIdentifier(input.commandId), (commandId) => node.runValidatedNodeOperation({ ...input, commandId }, sessionAdoptPreviewParametersSchema, (client, parameters, options) => client.previewSessionAdopt(parameters, options))),
|
|
6
6
|
});
|
|
7
7
|
const makeConfirmClient = (node) => ({
|
|
8
|
-
confirmSessionAdopt: (
|
|
8
|
+
confirmSessionAdopt: (input) => node.runValidatedNodeOperation(input, sessionAdoptConfirmParametersSchema, (client, parameters, options) => client.confirmSessionAdopt(parameters, options)),
|
|
9
9
|
});
|
|
10
10
|
export const makeDiscoveryClient = (node) => ({
|
|
11
11
|
...makePreviewClient(node),
|
|
@@ -2,4 +2,5 @@ import { type CommandContext, type CommandEffect } from "../command-line/index.j
|
|
|
2
2
|
export declare const runScan: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
3
3
|
export declare const runHistoryRead: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
4
4
|
export declare const runAdopt: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
5
|
+
export declare const runImport: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
5
6
|
//# sourceMappingURL=commands.d.ts.map
|