@maiaos/cli 0.1.0-canary.5 → 0.1.0-canary.50
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 +2 -2
- package/dist/agents/client.d.ts +47 -27
- package/dist/agents/client.js +10 -3
- package/dist/agents/commands.d.ts +1 -0
- package/dist/agents/commands.js +24 -2
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.js +1 -1
- package/dist/agents/input.d.ts +3 -1
- package/dist/agents/input.js +6 -0
- package/dist/agents/output/format.d.ts +2 -2
- package/dist/agents/output/format.js +11 -0
- package/dist/agents/tree/tree.js +13 -1
- package/dist/bin/maia.cdx.json +19 -19
- package/dist/bin/maia.mjs +1 -1
- package/dist/bootstrap/run.js +5 -2
- package/dist/cli/cli.d.ts +8 -2
- package/dist/cli/cli.js +19 -6
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/command-line/context.d.ts +2 -1
- package/dist/command-line/emit/index.d.ts +4 -0
- package/dist/command-line/emit/index.js +4 -0
- package/dist/command-line/{output.d.ts → emit/output.d.ts} +2 -2
- package/dist/command-line/{rows.d.ts → emit/rows.d.ts} +1 -0
- package/dist/command-line/{rows.js → emit/rows.js} +3 -0
- package/dist/command-line/index.d.ts +4 -4
- package/dist/command-line/index.js +4 -4
- package/dist/command-line/input/arguments.d.ts +10 -0
- package/dist/command-line/input/arguments.js +30 -10
- package/dist/command-line/input/index.d.ts +1 -1
- package/dist/command-line/input/index.js +1 -1
- package/dist/command-line/two-phase.js +1 -1
- package/dist/command-receipt/command.js +1 -1
- package/dist/command-tree/tree.d.ts +1 -1
- package/dist/command-tree/tree.js +3 -1
- package/dist/connection/input.js +2 -2
- package/dist/connection/system.js +3 -2
- package/dist/connection/tree/tree.js +5 -5
- package/dist/events/commands.d.ts +11 -0
- package/dist/events/commands.js +64 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.js +2 -0
- package/dist/events/tree/index.d.ts +2 -0
- package/dist/events/tree/index.js +2 -0
- package/dist/events/tree/tree.d.ts +10 -0
- package/dist/events/tree/tree.js +17 -0
- package/dist/import/commands.js +1 -1
- package/dist/import/input.d.ts +4 -1
- package/dist/import/input.js +23 -2
- package/dist/import/output.js +3 -1
- package/dist/local-node/client.d.ts +1 -0
- package/dist/local-node/client.js +1 -0
- package/dist/local-node/index.d.ts +2 -1
- package/dist/local-node/index.js +2 -1
- package/dist/local-node/wait.d.ts +10 -0
- package/dist/local-node/wait.js +17 -0
- package/dist/login/gateway.js +2 -2
- package/dist/login/vendor-input.js +2 -2
- package/dist/mcp/calls.js +6 -1
- package/dist/mcp/routing.js +1 -0
- package/dist/project-guard/client.d.ts +12 -0
- package/dist/project-guard/input.d.ts +3 -0
- package/dist/project-guard/input.js +15 -1
- package/dist/project-guard/output/format.js +5 -0
- package/dist/project-workspace/tree/tree.js +1 -1
- package/dist/reference/resolve.js +9 -2
- package/dist/remote-node/connector.js +8 -1
- package/dist/run-ledger/client.d.ts +2 -0
- package/dist/session/agent-permission.d.ts +2 -2
- package/dist/session/approval/client.d.ts +5 -2
- package/dist/session/approval/client.js +2 -2
- package/dist/session/approval/commands.js +29 -15
- package/dist/session/client.d.ts +14 -3
- package/dist/session/client.js +17 -2
- package/dist/session/commands.d.ts +1 -0
- package/dist/session/commands.js +125 -9
- package/dist/session/create-tasks.js +10 -2
- package/dist/session/index.d.ts +1 -1
- package/dist/session/index.js +1 -1
- package/dist/session/output/human.d.ts +3 -0
- package/dist/session/output/human.js +20 -4
- package/dist/session/output/index.d.ts +1 -1
- package/dist/session/output/index.js +1 -1
- package/dist/session/output/tasks.d.ts +2 -0
- package/dist/session/output/tasks.js +34 -4
- package/dist/session/tree/tree.js +23 -12
- package/dist/session/turn/client.js +7 -9
- package/dist/session/turn/commands.js +67 -20
- package/dist/session/turn/output.d.ts +6 -0
- package/dist/session/turn/output.js +12 -2
- package/dist/status/client.d.ts +14 -3
- package/dist/status/command.js +3 -1
- package/dist/status/doctor.d.ts +5 -1
- package/dist/status/doctor.js +10 -4
- package/dist/status/output/compact.d.ts +3 -0
- package/dist/status/output/compact.js +17 -7
- package/dist/status/output/human.js +15 -0
- package/dist/terminal/control-commands.js +26 -9
- package/dist/terminal/keys.d.ts +12 -0
- package/dist/terminal/keys.js +62 -0
- package/dist/terminal/output/compact-list.d.ts +1 -0
- package/dist/terminal/output/compact-list.js +3 -0
- package/dist/terminal/output/human.js +2 -2
- package/dist/terminal/tree/tree.js +1 -1
- package/guidance/maia-cli/SKILL.md +1 -1
- package/guidance/maia-node/SKILL.md +54 -0
- package/guidance/maia-orchestration/SKILL.md +1 -2
- package/guidance/maia-sessions/SKILL.md +69 -0
- package/package.json +4 -4
- /package/dist/command-line/{json-decoder.d.ts → emit/json-decoder.d.ts} +0 -0
- /package/dist/command-line/{json-decoder.js → emit/json-decoder.js} +0 -0
- /package/dist/command-line/{json.d.ts → emit/json.d.ts} +0 -0
- /package/dist/command-line/{json.js → emit/json.js} +0 -0
- /package/dist/command-line/{output.js → emit/output.js} +0 -0
|
@@ -2,7 +2,7 @@ import * as Effect from "effect/Effect";
|
|
|
2
2
|
import { listEach, writeMerged } from "../../address-space/index.js";
|
|
3
3
|
import { CliArgumentError, parseOptions, reportError, requirePositionals, writeNodeResult, } from "../../command-line/index.js";
|
|
4
4
|
import { mergeLists } from "../../fleet/index.js";
|
|
5
|
-
import { commandIdentifier, } from "../../local-node/index.js";
|
|
5
|
+
import { commandIdentifier, holdsSessionCredential, } from "../../local-node/index.js";
|
|
6
6
|
import { describeApproval, formatApprovalResult, formatMergedApprovals, } from "./output/index.js";
|
|
7
7
|
const missing = (name) => Effect.die(new Error(`Missing approval client: ${name}.`));
|
|
8
8
|
const write = (context) => (result) => writeNodeResult(result, context, {
|
|
@@ -85,10 +85,16 @@ const OPTIONS = {
|
|
|
85
85
|
approve: new Set(["--command-id"]),
|
|
86
86
|
deny: new Set(["--command-id", "--reason"]),
|
|
87
87
|
};
|
|
88
|
-
const
|
|
88
|
+
const FLAGS = {
|
|
89
|
+
answer: new Set(["--as-coordinator"]),
|
|
90
|
+
approve: new Set(["--as-coordinator", "--for-session"]),
|
|
91
|
+
deny: new Set(["--as-coordinator"]),
|
|
92
|
+
};
|
|
93
|
+
const confirmed = (context, { approval, asCoordinator, decision }) => {
|
|
89
94
|
context.io.stderr(`${describeApproval(approval)}\n`);
|
|
90
|
-
if (
|
|
91
|
-
decision.decision !== "
|
|
95
|
+
if (asCoordinator ||
|
|
96
|
+
(decision.decision !== "approve" &&
|
|
97
|
+
decision.decision !== "approve_for_session"))
|
|
92
98
|
return Effect.succeed(true);
|
|
93
99
|
const scope = decision.decision === "approve_for_session"
|
|
94
100
|
? "for this Session until its worker restarts"
|
|
@@ -103,34 +109,42 @@ const notConfirmed = (context) => reportError({
|
|
|
103
109
|
message: "Nothing approved; the worker still waits until the request expires.",
|
|
104
110
|
retryable: false,
|
|
105
111
|
}, context);
|
|
106
|
-
const decide = (context,
|
|
112
|
+
const decide = (context, { approvalId, asCoordinator, commandId, requested }) => {
|
|
107
113
|
const { respondToApproval, showApproval } = context.dependencies;
|
|
108
114
|
if (respondToApproval === undefined || showApproval === undefined)
|
|
109
115
|
return missing("decision");
|
|
110
116
|
return Effect.gen(function* () {
|
|
111
|
-
const shown = yield* showApproval({ approvalId
|
|
117
|
+
const shown = yield* showApproval({ approvalId }, asCoordinator);
|
|
112
118
|
if (!shown.ok)
|
|
113
119
|
return write(context)(shown);
|
|
114
120
|
const { approval } = shown.value;
|
|
115
|
-
const decision = resolveAnswer(approval,
|
|
116
|
-
|
|
121
|
+
const decision = resolveAnswer(approval, requested);
|
|
122
|
+
const reading = { approval, asCoordinator, decision };
|
|
123
|
+
if (!(yield* confirmed(context, reading)))
|
|
117
124
|
return notConfirmed(context);
|
|
118
|
-
const
|
|
125
|
+
const id = yield* commandIdentifier(commandId);
|
|
119
126
|
return write(context)(yield* respondToApproval({
|
|
120
127
|
...decision,
|
|
121
|
-
approvalId
|
|
122
|
-
commandId,
|
|
128
|
+
approvalId,
|
|
129
|
+
commandId: id,
|
|
123
130
|
requestDigest: approval.requestDigest,
|
|
124
|
-
}));
|
|
131
|
+
}, asCoordinator));
|
|
125
132
|
});
|
|
126
133
|
};
|
|
127
|
-
const runDecision = (verb, tokens, context) => {
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
const runDecision = (verb, tokens, context) => Effect.gen(function* () {
|
|
135
|
+
const asCoordinator = tokens.includes("--as-coordinator");
|
|
136
|
+
if (!asCoordinator &&
|
|
137
|
+
(verb !== "answer" || !(yield* holdsSessionCredential)))
|
|
138
|
+
requirePerson(context, verb);
|
|
139
|
+
return yield* parseDecision(verb, tokens, context);
|
|
140
|
+
});
|
|
141
|
+
const parseDecision = (verb, tokens, context) => {
|
|
142
|
+
const parsed = parseOptions(tokens, OPTIONS[verb], FLAGS[verb]);
|
|
130
143
|
requirePositionals(parsed.positionals, 1);
|
|
131
144
|
const commandId = parsed.options.get("--command-id");
|
|
132
145
|
return decide(context, {
|
|
133
146
|
approvalId: parsed.positionals[0] ?? "",
|
|
147
|
+
asCoordinator: parsed.flags.has("--as-coordinator"),
|
|
134
148
|
...(commandId === undefined ? {} : { commandId }),
|
|
135
149
|
requested: readDecision(verb, parsed.options, parsed.flags),
|
|
136
150
|
});
|
package/dist/session/client.d.ts
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import type { Session, SessionCreateParameters, SessionCreateResult, SessionCreationInput, SessionCreationOutcome, SessionCreationPlan, SessionEventsListResult, SessionInboxAckResult, SessionInboxCheckResult, SessionListParameters, SessionListResult, SessionMessageSendResult, SessionObserveResult, SessionResumeResult, SessionShowResult, SessionSpawnResult, SessionStartResult, SessionStopResult } from "@maiaos/sdk";
|
|
1
|
+
import type { Session, SessionCreateParameters, SessionCreateResult, SessionCreationInput, SessionCreationOutcome, SessionCreationPlan, SessionEventsListResult, SessionInboxAckResult, SessionInboxCheckResult, SessionListParameters, SessionListResult, SessionMessageSendResult, SessionObserveResult, SessionResumeResult, SessionShowResult, SessionSpawnResult, SessionStartResult, SessionStopResult, SessionWaitResult } from "@maiaos/sdk";
|
|
2
2
|
import { type CliNodeEffect, type CliNodeOperations } from "../local-node/index.js";
|
|
3
|
+
export type WaitSessionInput = {
|
|
4
|
+
readonly activities?: readonly string[];
|
|
5
|
+
readonly sessionId: string;
|
|
6
|
+
readonly states?: readonly string[];
|
|
7
|
+
readonly timeoutMilliseconds: number;
|
|
8
|
+
};
|
|
3
9
|
export type CreateSessionInput = {
|
|
4
10
|
readonly agentId?: SessionCreateParameters["agentId"];
|
|
5
11
|
readonly baseRef?: string;
|
|
6
12
|
readonly commandId?: string;
|
|
7
13
|
readonly connectionId?: string;
|
|
14
|
+
readonly cwd?: string;
|
|
8
15
|
readonly definitionRef?: SessionCreateParameters["definitionRef"];
|
|
9
16
|
readonly effort?: SessionCreateParameters["effort"];
|
|
10
17
|
readonly executor?: SessionCreateParameters["executor"];
|
|
18
|
+
readonly hostAuthority?: SessionCreateParameters["hostAuthority"];
|
|
19
|
+
readonly labels?: SessionCreateParameters["labels"];
|
|
11
20
|
readonly model?: string;
|
|
21
|
+
readonly permission?: SessionCreateParameters["permission"];
|
|
12
22
|
readonly role?: SessionCreateParameters["role"];
|
|
13
23
|
readonly title?: string;
|
|
14
24
|
readonly workspaceId: string;
|
|
@@ -59,7 +69,7 @@ export declare const makeSessionClient: (node: CliNodeOperations) => {
|
|
|
59
69
|
readonly commandId: string;
|
|
60
70
|
readonly grantedAt: string;
|
|
61
71
|
readonly inputDigest: string;
|
|
62
|
-
readonly operationIds: readonly ("agents.change.confirm" | "agents.change.preview" | "agents.list" | "agents.show" | "approval.list" | "approval.respond" | "approval.show" | "connection.capacity.set" | "connection.create" | "connection.detect" | "connection.gateway.create" | "connection.grant.list" | "connection.grant.set.confirm" | "connection.grant.set.preview" | "connection.list" | "connection.login.start" | "connection.models.list" | "connection.pool.list" | "connection.pool.set.confirm" | "connection.pool.set.preview" | "connection.show" | "connection.state.set" | "connection.system.confirm" | "connection.system.preview" | "connection.upkeep.confirm" | "connection.upkeep.preview" | "connection.upkeep.refresh" | "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.register.confirm" | "node.remote.register.preview" | "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" | "routine.create.confirm" | "routine.create.preview" | "routine.disable.confirm" | "routine.disable.preview" | "routine.list" | "routine.pause" | "routine.resume" | "routine.run.confirm" | "routine.run.preview" | "routine.show" | "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" | "team-workspace.bootstrap.apply" | "team-workspace.bootstrap.preview" | "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.cancel" | "turn.interrupt" | "turn.queue.list" | "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")[];
|
|
72
|
+
readonly operationIds: readonly ("agents.change.confirm" | "agents.change.preview" | "agents.detect" | "agents.list" | "agents.show" | "approval.list" | "approval.respond" | "approval.show" | "connection.capacity.set" | "connection.create" | "connection.detect" | "connection.gateway.create" | "connection.grant.list" | "connection.grant.set.confirm" | "connection.grant.set.preview" | "connection.list" | "connection.login.start" | "connection.models.list" | "connection.pool.list" | "connection.pool.set.confirm" | "connection.pool.set.preview" | "connection.show" | "connection.state.set" | "connection.system.confirm" | "connection.system.preview" | "connection.upkeep.confirm" | "connection.upkeep.preview" | "connection.upkeep.refresh" | "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" | "events.read" | "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.register.confirm" | "node.remote.register.preview" | "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" | "routine.create.confirm" | "routine.create.preview" | "routine.disable.confirm" | "routine.disable.preview" | "routine.list" | "routine.pause" | "routine.resume" | "routine.run.confirm" | "routine.run.preview" | "routine.show" | "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" | "session.wait" | "team-workspace.bootstrap.apply" | "team-workspace.bootstrap.preview" | "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.cancel" | "turn.interrupt" | "turn.queue.list" | "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")[];
|
|
63
73
|
readonly revision: "1";
|
|
64
74
|
};
|
|
65
75
|
readonly method: "session.agent-permission.confirm";
|
|
@@ -96,7 +106,7 @@ export declare const makeSessionClient: (node: CliNodeOperations) => {
|
|
|
96
106
|
readonly inputDigest: string;
|
|
97
107
|
readonly issuedAt: string;
|
|
98
108
|
readonly method: "session.agent-permission.preview";
|
|
99
|
-
readonly operationIds: readonly ("agents.change.confirm" | "agents.change.preview" | "agents.list" | "agents.show" | "approval.list" | "approval.respond" | "approval.show" | "connection.capacity.set" | "connection.create" | "connection.detect" | "connection.gateway.create" | "connection.grant.list" | "connection.grant.set.confirm" | "connection.grant.set.preview" | "connection.list" | "connection.login.start" | "connection.models.list" | "connection.pool.list" | "connection.pool.set.confirm" | "connection.pool.set.preview" | "connection.show" | "connection.state.set" | "connection.system.confirm" | "connection.system.preview" | "connection.upkeep.confirm" | "connection.upkeep.preview" | "connection.upkeep.refresh" | "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.register.confirm" | "node.remote.register.preview" | "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" | "routine.create.confirm" | "routine.create.preview" | "routine.disable.confirm" | "routine.disable.preview" | "routine.list" | "routine.pause" | "routine.resume" | "routine.run.confirm" | "routine.run.preview" | "routine.show" | "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" | "team-workspace.bootstrap.apply" | "team-workspace.bootstrap.preview" | "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.cancel" | "turn.interrupt" | "turn.queue.list" | "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")[];
|
|
109
|
+
readonly operationIds: readonly ("agents.change.confirm" | "agents.change.preview" | "agents.detect" | "agents.list" | "agents.show" | "approval.list" | "approval.respond" | "approval.show" | "connection.capacity.set" | "connection.create" | "connection.detect" | "connection.gateway.create" | "connection.grant.list" | "connection.grant.set.confirm" | "connection.grant.set.preview" | "connection.list" | "connection.login.start" | "connection.models.list" | "connection.pool.list" | "connection.pool.set.confirm" | "connection.pool.set.preview" | "connection.show" | "connection.state.set" | "connection.system.confirm" | "connection.system.preview" | "connection.upkeep.confirm" | "connection.upkeep.preview" | "connection.upkeep.refresh" | "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" | "events.read" | "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.register.confirm" | "node.remote.register.preview" | "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" | "routine.create.confirm" | "routine.create.preview" | "routine.disable.confirm" | "routine.disable.preview" | "routine.list" | "routine.pause" | "routine.resume" | "routine.run.confirm" | "routine.run.preview" | "routine.show" | "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" | "session.wait" | "team-workspace.bootstrap.apply" | "team-workspace.bootstrap.preview" | "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.cancel" | "turn.interrupt" | "turn.queue.list" | "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")[];
|
|
100
110
|
readonly proof: string;
|
|
101
111
|
}>;
|
|
102
112
|
attachSession: (input: import("./attach-client.js").AttachSessionInput) => CliNodeEffect<import("./attach-client.js").SessionAttachStream>;
|
|
@@ -129,6 +139,7 @@ export declare const makeSessionClient: (node: CliNodeOperations) => {
|
|
|
129
139
|
spawnSession: (input: SpawnSessionInput) => CliNodeEffect<SessionSpawnResult>;
|
|
130
140
|
startSession: (input: StartSessionInput) => CliNodeEffect<SessionStartResult>;
|
|
131
141
|
stopSession: (input: StartSessionInput) => CliNodeEffect<SessionStopResult>;
|
|
142
|
+
waitSession: (input: WaitSessionInput) => CliNodeEffect<SessionWaitResult>;
|
|
132
143
|
};
|
|
133
144
|
export {};
|
|
134
145
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/session/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { sessionCreateParametersSchema, sessionEventsListParametersSchema, sessionInboxAckParametersSchema, sessionInboxCheckParametersSchema, sessionListParametersSchema, sessionMessageSendParametersSchema, sessionObserveParametersSchema, sessionResumeParametersSchema, sessionShowParametersSchema, sessionSpawnParametersSchema, sessionStartParametersSchema, sessionStopParametersSchema, } from "@maiaos/sdk";
|
|
1
|
+
import { MAX_SESSION_WAIT_MILLISECONDS, sessionCreateParametersSchema, sessionEventsListParametersSchema, sessionInboxAckParametersSchema, sessionInboxCheckParametersSchema, sessionListParametersSchema, sessionMessageSendParametersSchema, sessionObserveParametersSchema, sessionResumeParametersSchema, sessionShowParametersSchema, sessionSpawnParametersSchema, sessionStartParametersSchema, sessionStopParametersSchema, sessionWaitParametersSchema, } from "@maiaos/sdk";
|
|
2
2
|
import * as Crypto from "effect/Crypto";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import { makeRelocateClient } from "../execution/index.js";
|
|
5
|
-
import { commandIdentifier, } from "../local-node/index.js";
|
|
5
|
+
import { commandIdentifier, repeatBoundedWait, } from "../local-node/index.js";
|
|
6
6
|
import { makeAgentPermissionCliClient } from "./agent-permission.js";
|
|
7
7
|
import { makeAttachClient } from "./attach-client.js";
|
|
8
8
|
import { makeCodingSessionClient } from "./coding-client.js";
|
|
@@ -24,6 +24,20 @@ export const makeSessionClient = (node) => {
|
|
|
24
24
|
const showSession = (sessionId) => {
|
|
25
25
|
return node.runValidatedNodeOperation({ sessionId }, sessionShowParametersSchema, (client, parameters, options) => client.showSession(parameters, options));
|
|
26
26
|
};
|
|
27
|
+
const waitSessionOnce = (parameters) => node.runValidatedNodeOperation(parameters, sessionWaitParametersSchema, (client, validated, options) => client.waitSession(validated, options));
|
|
28
|
+
const waitSession = (input) => repeatBoundedWait({
|
|
29
|
+
maxRequestMilliseconds: MAX_SESSION_WAIT_MILLISECONDS,
|
|
30
|
+
once: (waitMilliseconds) => waitSessionOnce({
|
|
31
|
+
...(input.activities === undefined
|
|
32
|
+
? {}
|
|
33
|
+
: { activities: input.activities }),
|
|
34
|
+
sessionId: input.sessionId,
|
|
35
|
+
...(input.states === undefined ? {} : { states: input.states }),
|
|
36
|
+
waitMilliseconds,
|
|
37
|
+
}),
|
|
38
|
+
satisfied: (value) => value.satisfied,
|
|
39
|
+
timeoutMilliseconds: input.timeoutMilliseconds,
|
|
40
|
+
});
|
|
27
41
|
const observeSessions = (input) => node.runValidatedNodeOperation(input, sessionObserveParametersSchema, (client, parameters, options) => client.observeSessions(parameters, options));
|
|
28
42
|
const listSessionEvents = (input) => {
|
|
29
43
|
return node.runValidatedNodeOperation(input, sessionEventsListParametersSchema, (client, parameters, options) => client.listSessionEvents(parameters, options));
|
|
@@ -108,6 +122,7 @@ export const makeSessionClient = (node) => {
|
|
|
108
122
|
spawnSession,
|
|
109
123
|
startSession,
|
|
110
124
|
stopSession,
|
|
125
|
+
waitSession,
|
|
111
126
|
...makeRelocateClient(node),
|
|
112
127
|
...makeAgentPermissionCliClient(node),
|
|
113
128
|
...makeCodingSessionClient(node),
|
|
@@ -2,6 +2,7 @@ import { type CommandContext, type CommandEffect } from "../command-line/index.j
|
|
|
2
2
|
export declare const runSessionCreate: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
3
3
|
export declare const runSessionList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
4
4
|
export declare const runSessionShow: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
5
|
+
export declare const runSessionWait: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
5
6
|
export declare const runSessionStart: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
6
7
|
export declare const runSessionStop: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
7
8
|
export declare const runSessionResume: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
package/dist/session/commands.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { MAX_SESSION_INBOX_CHECK_LIMIT, MAX_SESSION_MESSAGE_BODY_BYTES, MAX_SESSION_OBSERVE_IDS, MAX_SESSION_STALL_AFTER_SECONDS, MIN_SESSION_STALL_AFTER_SECONDS, SESSION_EFFORT_LEVELS, sessionBaseRefSchema, sessionCreateParametersSchema, } from "@maiaos/sdk";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
import { listEach, writeMerged } from "../address-space/index.js";
|
|
4
|
-
import { CliArgumentError, parseOptions, readCursor, readDuration, readExpectedRevision, readPageSize, requirePositionals, } from "../command-line/index.js";
|
|
4
|
+
import { CliArgumentError, parseOptions, parseOptionsWith, readCursor, readDuration, readExpectedRevision, readPageSize, readPermission, readWaitTimeoutSeconds, requirePositionals, writeNodeResult, } from "../command-line/index.js";
|
|
5
5
|
import { mergeLists } from "../fleet/index.js";
|
|
6
6
|
import { runSessionTasks, } from "./create-tasks.js";
|
|
7
|
-
import { formatMergedSessions, writeSessionResult } from "./output/index.js";
|
|
7
|
+
import { formatMergedSessions, formatSessionShow, writeSessionResult, } from "./output/index.js";
|
|
8
|
+
const EXIT_DEADLINE = 74;
|
|
8
9
|
const SESSION_CREATE_OPTIONS = new Set([
|
|
9
10
|
"--agent",
|
|
10
11
|
"--base",
|
|
11
12
|
"--command-id",
|
|
12
13
|
"--connection",
|
|
14
|
+
"--cwd",
|
|
13
15
|
"--effort",
|
|
14
16
|
"--executor",
|
|
17
|
+
"--label",
|
|
15
18
|
"--model",
|
|
19
|
+
"--name",
|
|
20
|
+
"--permission",
|
|
16
21
|
"--agent-definition",
|
|
17
22
|
"--agent-definition-version",
|
|
18
23
|
"--agent-definition-digest",
|
|
@@ -20,6 +25,12 @@ const SESSION_CREATE_OPTIONS = new Set([
|
|
|
20
25
|
"--title",
|
|
21
26
|
]);
|
|
22
27
|
const summarizeSessionCreation = (result) => ({
|
|
28
|
+
...(result.session.containment === undefined
|
|
29
|
+
? {}
|
|
30
|
+
: { containment: result.session.containment }),
|
|
31
|
+
...(result.session.permission === undefined
|
|
32
|
+
? {}
|
|
33
|
+
: { permission: result.session.permission }),
|
|
23
34
|
...(result.session.agentDefinitionRef === undefined
|
|
24
35
|
? {}
|
|
25
36
|
: { agentDefinitionRef: result.session.agentDefinitionRef }),
|
|
@@ -31,6 +42,9 @@ const summarizeSessionCreation = (result) => ({
|
|
|
31
42
|
revision: result.session.revision,
|
|
32
43
|
sessionId: result.session.id,
|
|
33
44
|
state: result.session.state,
|
|
45
|
+
...(result.session.labels === undefined
|
|
46
|
+
? {}
|
|
47
|
+
: { labels: result.session.labels }),
|
|
34
48
|
...(result.session.title === undefined
|
|
35
49
|
? {}
|
|
36
50
|
: { title: result.session.title }),
|
|
@@ -62,7 +76,7 @@ const readSessionCreateOptions = (parsed) => {
|
|
|
62
76
|
throw new CliArgumentError(parsed.options.has("--project")
|
|
63
77
|
? "Option '--project' needs '--message', '--prompt-stdin' or '--from-file'; name a Workspace with '--workspace' otherwise."
|
|
64
78
|
: "Option '--workspace' is required.");
|
|
65
|
-
const input = readSessionSelection(parsed
|
|
79
|
+
const input = readSessionSelection(parsed, workspaceId);
|
|
66
80
|
const definition = readDefinitionSelection(parsed.options, input);
|
|
67
81
|
requireOneSelection({ ...input, ...definition });
|
|
68
82
|
return { ...input, ...definition };
|
|
@@ -117,28 +131,90 @@ const readAgentId = (options) => {
|
|
|
117
131
|
throw new CliArgumentError(`Option '--agent' fixes the harness, Connection, model and effort; drop '${clash}'.`);
|
|
118
132
|
return { agentId };
|
|
119
133
|
};
|
|
120
|
-
const
|
|
134
|
+
const LABEL_OPTION = new Set(["--label"]);
|
|
135
|
+
const requireOneLabelPerOption = (tokens) => {
|
|
136
|
+
const given = tokens.flatMap((token, index) => {
|
|
137
|
+
if (tokens[index - 1] === "--label")
|
|
138
|
+
return [token];
|
|
139
|
+
return token.startsWith("--label=") ? [token.slice("--label=".length)] : [];
|
|
140
|
+
});
|
|
141
|
+
if (given.some((value) => value.includes(",")))
|
|
142
|
+
throw new CliArgumentError("Option '--label' takes one key=value; repeat the option for more.");
|
|
143
|
+
};
|
|
144
|
+
const readLabels = (value) => {
|
|
145
|
+
if (value === undefined)
|
|
146
|
+
return {};
|
|
147
|
+
const pairs = value.split(",").map((pair) => {
|
|
148
|
+
const separator = pair.indexOf("=");
|
|
149
|
+
if (separator < 1)
|
|
150
|
+
throw new CliArgumentError("Option '--label' takes key=value.");
|
|
151
|
+
return [pair.slice(0, separator), pair.slice(separator + 1)];
|
|
152
|
+
});
|
|
153
|
+
const duplicate = pairs.find(([key], index) => pairs.findIndex(([other]) => other === key) !== index);
|
|
154
|
+
if (duplicate !== undefined)
|
|
155
|
+
throw new CliArgumentError(`Label '${duplicate[0]}' is given twice.`);
|
|
156
|
+
return { labels: Object.fromEntries(pairs) };
|
|
157
|
+
};
|
|
158
|
+
const readSessionTitle = (options) => {
|
|
159
|
+
if (options.has("--name") && options.has("--title"))
|
|
160
|
+
throw new CliArgumentError("Use one of '--name' or '--title'.");
|
|
161
|
+
return options.get("--title") ?? options.get("--name");
|
|
162
|
+
};
|
|
163
|
+
const readSessionSelection = ({ flags, options }, workspaceId) => {
|
|
121
164
|
const agent = readAgentId(options);
|
|
122
165
|
const commandId = options.get("--command-id");
|
|
123
166
|
const connectionId = options.get("--connection");
|
|
124
167
|
const executor = readExecutorKind(options.get("--executor"));
|
|
125
168
|
const effort = readEffort(options.get("--effort"));
|
|
169
|
+
const cwd = options.get("--cwd");
|
|
126
170
|
const model = options.get("--model");
|
|
127
|
-
const title = options
|
|
171
|
+
const title = readSessionTitle(options);
|
|
128
172
|
const selection = {
|
|
129
173
|
...agent,
|
|
130
174
|
...(commandId === undefined ? {} : { commandId }),
|
|
131
175
|
...(connectionId === undefined ? {} : { connectionId }),
|
|
176
|
+
...(cwd === undefined ? {} : { cwd }),
|
|
132
177
|
...(effort === undefined ? {} : { effort }),
|
|
133
178
|
...(executor === undefined ? {} : { executor }),
|
|
134
179
|
...(model === undefined ? {} : { model }),
|
|
180
|
+
...readLabels(options.get("--label")),
|
|
135
181
|
...readSessionRole(options.get("--role")),
|
|
136
182
|
...(title === undefined ? {} : { title }),
|
|
183
|
+
...readHostAuthority({ flags, options }),
|
|
137
184
|
workspaceId,
|
|
138
185
|
};
|
|
139
186
|
const baseRef = readBaseRef(options.get("--base"), selection);
|
|
140
187
|
return { ...selection, ...(baseRef === undefined ? {} : { baseRef }) };
|
|
141
188
|
};
|
|
189
|
+
const validPermission = (permission, executor) => {
|
|
190
|
+
const valid = sessionCreateParametersSchema.safeParse({
|
|
191
|
+
commandId: "command_validate",
|
|
192
|
+
...(executor === undefined
|
|
193
|
+
? { connectionId: "connection_validate" }
|
|
194
|
+
: { executor }),
|
|
195
|
+
expectedRevision: "0",
|
|
196
|
+
hostAuthority: true,
|
|
197
|
+
permission,
|
|
198
|
+
workspaceId: "workspace_validate",
|
|
199
|
+
});
|
|
200
|
+
return valid.success ? valid.data.permission : undefined;
|
|
201
|
+
};
|
|
202
|
+
const readHostAuthority = ({ flags, options, }) => {
|
|
203
|
+
const permission = options.get("--permission");
|
|
204
|
+
if (!flags.has("--host-authority")) {
|
|
205
|
+
if (permission !== undefined)
|
|
206
|
+
throw new CliArgumentError("Option '--permission' needs '--host-authority'.");
|
|
207
|
+
return {};
|
|
208
|
+
}
|
|
209
|
+
if (options.has("--base"))
|
|
210
|
+
throw new CliArgumentError("Option '--host-authority' runs in an existing '--cwd', not a Maia worktree; drop '--base'.");
|
|
211
|
+
if (!options.has("--connection") && !options.has("--executor"))
|
|
212
|
+
throw new CliArgumentError("Option '--host-authority' needs '--connection' or '--executor'.");
|
|
213
|
+
return {
|
|
214
|
+
hostAuthority: true,
|
|
215
|
+
...readPermission(permission, (value) => validPermission(value, readExecutorKind(options.get("--executor")))),
|
|
216
|
+
};
|
|
217
|
+
};
|
|
142
218
|
const readBaseRef = (value, selection) => {
|
|
143
219
|
if (value === undefined)
|
|
144
220
|
return;
|
|
@@ -188,8 +264,11 @@ const taskSource = (parsed) => {
|
|
|
188
264
|
const stdin = parsed.flags.has("--prompt-stdin");
|
|
189
265
|
if ([file, message, stdin ? "" : undefined].filter((value) => value !== undefined).length > 1)
|
|
190
266
|
throw new CliArgumentError("Use one of '--message', '--prompt-stdin' or '--from-file'.");
|
|
191
|
-
if (file !== undefined &&
|
|
192
|
-
|
|
267
|
+
if (file !== undefined &&
|
|
268
|
+
(parsed.options.has("--title") || parsed.options.has("--name")))
|
|
269
|
+
throw new CliArgumentError("Option '--title' or '--name' names one Session; with '--from-file' each Session takes its task's first line.");
|
|
270
|
+
if (file !== undefined && parsed.options.has("--label"))
|
|
271
|
+
throw new CliArgumentError("Option '--label' labels one Session; it cannot be used with '--from-file'.");
|
|
193
272
|
if (file !== undefined)
|
|
194
273
|
return { kind: "file", path: file };
|
|
195
274
|
if (message !== undefined)
|
|
@@ -211,7 +290,7 @@ const readSessionTasks = (parsed, source) => {
|
|
|
211
290
|
const workspaceId = readTaskWorkspace(parsed, source);
|
|
212
291
|
const projectId = parsed.options.get("--project");
|
|
213
292
|
const commandId = parsed.options.get("--command-id");
|
|
214
|
-
const { workspaceId: _placeholder, ...selection } = readSessionSelection(parsed
|
|
293
|
+
const { workspaceId: _placeholder, ...selection } = readSessionSelection(parsed, workspaceId ?? "workspace_default");
|
|
215
294
|
requireOneSelection({ ...selection, workspaceId: _placeholder });
|
|
216
295
|
return {
|
|
217
296
|
...(commandId === undefined ? {} : { commandId }),
|
|
@@ -222,7 +301,12 @@ const readSessionTasks = (parsed, source) => {
|
|
|
222
301
|
};
|
|
223
302
|
};
|
|
224
303
|
export const runSessionCreate = (tokens, context) => {
|
|
225
|
-
|
|
304
|
+
requireOneLabelPerOption(tokens);
|
|
305
|
+
const parsed = parseOptionsWith(tokens, {
|
|
306
|
+
allowed: TASK_OPTIONS,
|
|
307
|
+
allowedFlags: new Set(["--host-authority", "--prompt-stdin"]),
|
|
308
|
+
repeatable: LABEL_OPTION,
|
|
309
|
+
});
|
|
226
310
|
const source = taskSource(parsed);
|
|
227
311
|
if (source !== undefined)
|
|
228
312
|
return runSessionTasks(readSessionTasks(parsed, source), context);
|
|
@@ -287,6 +371,38 @@ export const runSessionShow = (tokens, context) => Effect.gen(function* () {
|
|
|
287
371
|
result: value,
|
|
288
372
|
}));
|
|
289
373
|
});
|
|
374
|
+
const readWaitInput = (tokens) => {
|
|
375
|
+
const parsed = parseOptionsWith(tokens, {
|
|
376
|
+
allowed: new Set(["--activity", "--timeout", "--until"]),
|
|
377
|
+
allowedFlags: new Set(),
|
|
378
|
+
repeatable: new Set(["--activity", "--until"]),
|
|
379
|
+
});
|
|
380
|
+
requirePositionals(parsed.positionals, 1);
|
|
381
|
+
const [sessionId] = parsed.positionals;
|
|
382
|
+
const states = parsed.options.get("--until")?.split(",");
|
|
383
|
+
const activities = parsed.options.get("--activity")?.split(",");
|
|
384
|
+
if (sessionId === undefined ||
|
|
385
|
+
(states === undefined && activities === undefined))
|
|
386
|
+
throw new CliArgumentError("Name the Session and the states ('--until') or activities ('--activity') to wait for.");
|
|
387
|
+
return {
|
|
388
|
+
...(activities === undefined ? {} : { activities }),
|
|
389
|
+
sessionId,
|
|
390
|
+
...(states === undefined ? {} : { states }),
|
|
391
|
+
timeoutMilliseconds: readWaitTimeoutSeconds(parsed.options.get("--timeout")) * 1000,
|
|
392
|
+
};
|
|
393
|
+
};
|
|
394
|
+
export const runSessionWait = (tokens, context) => Effect.gen(function* () {
|
|
395
|
+
const input = readWaitInput(tokens);
|
|
396
|
+
const { waitSession } = context.dependencies;
|
|
397
|
+
if (waitSession === undefined)
|
|
398
|
+
throw new CliArgumentError("Session wait is unavailable.");
|
|
399
|
+
const result = yield* waitSession(input);
|
|
400
|
+
const code = writeNodeResult(result, context, {
|
|
401
|
+
toResult: (value) => ({ command: "session.wait", result: value }),
|
|
402
|
+
toText: ({ result: waited }) => formatSessionShow(waited),
|
|
403
|
+
});
|
|
404
|
+
return result.ok && !result.value.satisfied ? EXIT_DEADLINE : code;
|
|
405
|
+
});
|
|
290
406
|
const readLifecycleInput = (parsed) => {
|
|
291
407
|
const sessionId = parsed.positionals[0];
|
|
292
408
|
if (sessionId === undefined) {
|
|
@@ -21,13 +21,20 @@ const readText = (source, context) => {
|
|
|
21
21
|
const refusalMessage = (refusal) => refusal.reason === "too_long"
|
|
22
22
|
? `Task line ${String(refusal.line)} exceeds ${String(MAX_TURN_INPUT_BYTES)} bytes.`
|
|
23
23
|
: `A batch holds at most ${String(MAX_SESSION_CREATION_TASKS)} tasks; line ${String(refusal.line)} is beyond it.`;
|
|
24
|
+
const toStartFields = ({ cwd, hostAuthority, permission, }) => ({
|
|
25
|
+
...(cwd === undefined ? {} : { cwd }),
|
|
26
|
+
...(hostAuthority === undefined ? {} : { hostAuthority }),
|
|
27
|
+
...(permission === undefined ? {} : { permission }),
|
|
28
|
+
});
|
|
24
29
|
const toTemplate = (selection) => {
|
|
25
|
-
const { agentId, baseRef, connectionId, effort, executor, model, role, title, } = selection;
|
|
30
|
+
const { agentId, baseRef, connectionId, effort, executor, labels, model, role, title, } = selection;
|
|
26
31
|
return {
|
|
27
32
|
...(agentId === undefined ? {} : { agentId }),
|
|
28
33
|
...(connectionId === undefined ? {} : { connectionId }),
|
|
34
|
+
...toStartFields(selection),
|
|
29
35
|
...(effort === undefined ? {} : { effort }),
|
|
30
36
|
...(executor === undefined ? {} : { executor }),
|
|
37
|
+
...(labels === undefined ? {} : { labels }),
|
|
31
38
|
...(model === undefined ? {} : { model }),
|
|
32
39
|
...(role === undefined ? {} : { role }),
|
|
33
40
|
...(title === undefined ? {} : { title }),
|
|
@@ -88,10 +95,11 @@ const batchError = (items) => {
|
|
|
88
95
|
const failed = items.find((item) => item.error !== undefined);
|
|
89
96
|
if (failed?.error === undefined)
|
|
90
97
|
return undefined;
|
|
91
|
-
const { code, failure, kind, operationId, retryable } = failed.error;
|
|
98
|
+
const { code, failure, kind, message, operationId, retryable } = failed.error;
|
|
92
99
|
return {
|
|
93
100
|
code: failure?.code ?? code ?? kind,
|
|
94
101
|
message: failure?.message ??
|
|
102
|
+
message ??
|
|
95
103
|
`Line ${String(failed.line)} stopped at ${operationId}: ${code ?? kind}.`,
|
|
96
104
|
retryable,
|
|
97
105
|
};
|
package/dist/session/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export { type AttachSessionInput, makeAttachClient, type SessionAttachStream, }
|
|
|
4
4
|
export { type CreateSessionInput, type ListSessionsInput, makeSessionClient, type StartSessionInput, } from "./client.js";
|
|
5
5
|
export { type ArchiveSessionInput, type DiffSessionInput, } from "./coding-client.js";
|
|
6
6
|
export { runSessionArchive, runSessionDiff } from "./coding-commands.js";
|
|
7
|
-
export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, } from "./commands.js";
|
|
7
|
+
export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, runSessionWait, } from "./commands.js";
|
|
8
8
|
export { runSessionRename } from "./rename.js";
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/session/index.js
CHANGED
|
@@ -3,6 +3,6 @@ export { runSessionAttach } from "./attach.js";
|
|
|
3
3
|
export { makeAttachClient, } from "./attach-client.js";
|
|
4
4
|
export { makeSessionClient, } from "./client.js";
|
|
5
5
|
export { runSessionArchive, runSessionDiff } from "./coding-commands.js";
|
|
6
|
-
export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, } from "./commands.js";
|
|
6
|
+
export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, runSessionWait, } from "./commands.js";
|
|
7
7
|
export { runSessionRename } from "./rename.js";
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -30,8 +30,10 @@ export type CliSessionResult = {
|
|
|
30
30
|
} | {
|
|
31
31
|
readonly command: "session.create";
|
|
32
32
|
readonly result: {
|
|
33
|
+
readonly containment?: SessionCreateResult["session"]["containment"];
|
|
33
34
|
readonly delivery: SessionCreateResult["delivery"];
|
|
34
35
|
readonly executor?: SessionCreateResult["session"]["executor"];
|
|
36
|
+
readonly permission?: SessionCreateResult["session"]["permission"];
|
|
35
37
|
readonly receipt: SessionCreateResult["receipt"];
|
|
36
38
|
readonly revision: string;
|
|
37
39
|
readonly sessionId: string;
|
|
@@ -103,6 +105,7 @@ export type CliSessionResult = {
|
|
|
103
105
|
readonly command: "session.show";
|
|
104
106
|
readonly result: SessionShowResult;
|
|
105
107
|
};
|
|
108
|
+
export declare const formatSessionShow: ({ session, }: Pick<SessionShowResult, "session">) => string;
|
|
106
109
|
export declare const formatSessionResult: (result: CliSessionResult) => string;
|
|
107
110
|
export declare const writeSessionResult: <TValue>(result: CliNodeResult<TValue>, context: {
|
|
108
111
|
readonly io: CliIo;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { cell, fields, formatRows, tab, writeNodeResult, } from "../../command-line/index.js";
|
|
1
|
+
import { cell, fields, formatRows, tab, withPrunedHistory, writeNodeResult, } from "../../command-line/index.js";
|
|
2
2
|
import { formatSessionDiff } from "./diff.js";
|
|
3
3
|
import { formatFailure, formatSessionEvents } from "./failure.js";
|
|
4
4
|
import { formatSessionObservation } from "./observe.js";
|
|
5
|
-
import { formatSessionList, formatSessionTasks, } from "./tasks.js";
|
|
5
|
+
import { activityLabel, formatSessionList, formatSessionTasks, labelCells, } from "./tasks.js";
|
|
6
6
|
const formatSessionInbox = (deliveries) => formatRows(deliveries, (delivery) => `${delivery.deliveryId}\t${delivery.sequence}\t${cell(delivery.message.senderSessionId)}\t${cell(delivery.message.subject)}\t${cell(delivery.message.body)}`);
|
|
7
7
|
const formatSessionCreation = (result) => `${fields([
|
|
8
8
|
["session", result.sessionId],
|
|
9
9
|
["account", result.executor?.connectionId],
|
|
10
|
+
["containment", result.containment],
|
|
11
|
+
["permission", result.permission],
|
|
10
12
|
[
|
|
11
13
|
"workspace",
|
|
12
14
|
result.worktree === undefined ? undefined : result.workspaceId,
|
|
@@ -31,11 +33,24 @@ const formatCodingSession = (result) => {
|
|
|
31
33
|
const formatAgentPermission = (result) => result.command === "session.agent-permission.preview"
|
|
32
34
|
? `${result.result.sessionId}\t${result.result.expiresAt}\n`
|
|
33
35
|
: `${result.result.receipt.receiptId}\t${result.result.delivery}\n`;
|
|
34
|
-
const formatSessionShow = ({ session, }) => `${fields([
|
|
36
|
+
export const formatSessionShow = ({ session, }) => `${fields([
|
|
35
37
|
["session", session.id],
|
|
36
38
|
["state", session.state],
|
|
39
|
+
...(session.activity === undefined
|
|
40
|
+
? []
|
|
41
|
+
: [["activity", activityLabel(session)]]),
|
|
42
|
+
...(session.latestTurnState === undefined
|
|
43
|
+
? []
|
|
44
|
+
: [["latest-turn", session.latestTurnState]]),
|
|
37
45
|
["revision", session.revision],
|
|
38
46
|
["workspace", session.workspaceId],
|
|
47
|
+
["containment", session.containment],
|
|
48
|
+
["permission", session.permission],
|
|
49
|
+
[
|
|
50
|
+
"labels",
|
|
51
|
+
session.labels === undefined ? undefined : labelCells(session.labels),
|
|
52
|
+
],
|
|
53
|
+
["updated", session.updatedAt],
|
|
39
54
|
])}${formatFailure(session.failure)}`;
|
|
40
55
|
const formatLifecycle = ({ revision, sessionId, state, }) => `${fields([
|
|
41
56
|
["session", sessionId],
|
|
@@ -45,6 +60,7 @@ const formatLifecycle = ({ revision, sessionId, state, }) => `${fields([
|
|
|
45
60
|
const formatSessions = (result) => result.items.length === 0 ? "No Sessions.\n" : formatSessionList(result);
|
|
46
61
|
const formatInboxAck = ({ delivery, deliveryRecord, mailboxRevision, }) => `${tab([deliveryRecord.deliveryId, delivery, mailboxRevision])}\n`;
|
|
47
62
|
const formatMessageSend = ({ delivery, deliveryId, sequence, }) => `${tab([deliveryId, delivery, sequence])}\n`;
|
|
63
|
+
const formatEventsPage = ({ items, oldestRetainedCursor, }) => withPrunedHistory(formatSessionEvents(items), oldestRetainedCursor);
|
|
48
64
|
export const formatSessionResult = (result) => {
|
|
49
65
|
switch (result.command) {
|
|
50
66
|
case "session.agent-permission.confirm":
|
|
@@ -56,7 +72,7 @@ export const formatSessionResult = (result) => {
|
|
|
56
72
|
case "session.diff":
|
|
57
73
|
return formatCodingSession(result);
|
|
58
74
|
case "session.events.list":
|
|
59
|
-
return
|
|
75
|
+
return formatEventsPage(result.result);
|
|
60
76
|
case "session.inbox.ack":
|
|
61
77
|
return formatInboxAck(result.result);
|
|
62
78
|
case "session.inbox.check":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { formatSessionDiff } from "./diff.js";
|
|
2
2
|
export { formatFailure, formatFailureCell, formatSessionEvents, } from "./failure.js";
|
|
3
|
-
export { type CliSessionResult, formatSessionResult, writeSessionResult, } from "./human.js";
|
|
3
|
+
export { type CliSessionResult, formatSessionResult, formatSessionShow, writeSessionResult, } from "./human.js";
|
|
4
4
|
export { formatSessionObservation } from "./observe.js";
|
|
5
5
|
export { type CliSessionList, type CliSessionTaskItem, type CliSessionTasksResult, formatMergedSessions, formatSessionList, formatSessionTasks, } from "./tasks.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { formatSessionDiff } from "./diff.js";
|
|
2
2
|
export { formatFailure, formatFailureCell, formatSessionEvents, } from "./failure.js";
|
|
3
|
-
export { formatSessionResult, writeSessionResult, } from "./human.js";
|
|
3
|
+
export { formatSessionResult, formatSessionShow, writeSessionResult, } from "./human.js";
|
|
4
4
|
export { formatSessionObservation } from "./observe.js";
|
|
5
5
|
export { formatMergedSessions, formatSessionList, formatSessionTasks, } from "./tasks.js";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -17,6 +17,8 @@ export type CliSessionTasksResult = {
|
|
|
17
17
|
};
|
|
18
18
|
export declare const formatSessionTasks: ({ items }: CliSessionTasksResult) => string;
|
|
19
19
|
type ListedSession = SessionListResult["items"][number];
|
|
20
|
+
export declare const activityLabel: (session: Pick<ListedSession, "activity" | "latestTurnState">) => string;
|
|
21
|
+
export declare const labelCells: (labels: Readonly<Record<string, string>> | undefined) => string;
|
|
20
22
|
export declare const formatSessionList: (result: SessionListResult) => string;
|
|
21
23
|
type Labeled<TValue> = TValue & {
|
|
22
24
|
readonly node: string;
|