@cotal-ai/cli 0.133.12 → 0.133.13
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/dist/chat/static-session.d.ts +1 -1
- package/dist/chat/static-session.d.ts.map +1 -1
- package/dist/chat/static-session.js +3 -2
- package/dist/chat/static-session.js.map +1 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +2 -2
- package/dist/command.js.map +1 -1
- package/dist/commands/agents.d.ts +1 -117
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +13 -178
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/console.js +5 -4
- package/dist/commands/console.js.map +1 -1
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +8 -7
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/models.d.ts.map +1 -1
- package/dist/commands/models.js +4 -3
- package/dist/commands/models.js.map +1 -1
- package/dist/commands/persona-remote.js +1 -2
- package/dist/commands/persona-remote.js.map +1 -1
- package/dist/commands/spawn.d.ts +1 -37
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +24 -43
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +4 -3
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/team-agent-apply.d.ts.map +1 -1
- package/dist/commands/team-agent-apply.js +6 -5
- package/dist/commands/team-agent-apply.js.map +1 -1
- package/dist/commands/team-agent-remove.d.ts.map +1 -1
- package/dist/commands/team-agent-remove.js +6 -5
- package/dist/commands/team-agent-remove.js.map +1 -1
- package/dist/commands/team-deploy-apply.d.ts.map +1 -1
- package/dist/commands/team-deploy-apply.js +1 -2
- package/dist/commands/team-deploy-apply.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +7 -6
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +5 -4
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +5 -17
- package/dist/commands/watch.js.map +1 -1
- package/dist/commands/who.d.ts.map +1 -1
- package/dist/commands/who.js +1 -1
- package/dist/commands/who.js.map +1 -1
- package/dist/console/app.d.ts +1 -1
- package/dist/console/app.d.ts.map +1 -1
- package/dist/console/app.js +6 -5
- package/dist/console/app.js.map +1 -1
- package/dist/console/commands.d.ts +2 -3
- package/dist/console/commands.d.ts.map +1 -1
- package/dist/console/commands.js.map +1 -1
- package/dist/console/launch.d.ts +1 -1
- package/dist/console/launch.d.ts.map +1 -1
- package/dist/console/mesh.d.ts +2 -2
- package/dist/console/mesh.d.ts.map +1 -1
- package/dist/console/mesh.js +2 -2
- package/dist/console/mesh.js.map +1 -1
- package/dist/console/root.d.ts +2 -16
- package/dist/console/root.d.ts.map +1 -1
- package/dist/console/root.js +6 -30
- package/dist/console/root.js.map +1 -1
- package/dist/console/ui/CommandPalette.d.ts +2 -2
- package/dist/console/ui/CommandPalette.d.ts.map +1 -1
- package/dist/console/ui/CommandPalette.js.map +1 -1
- package/dist/console/ui/Dm.d.ts +1 -1
- package/dist/console/ui/Dm.d.ts.map +1 -1
- package/dist/console/ui/Tiles.d.ts +1 -1
- package/dist/console/ui/Tiles.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/control.d.ts +5 -280
- package/dist/lib/control.d.ts.map +1 -1
- package/dist/lib/control.js +24 -782
- package/dist/lib/control.js.map +1 -1
- package/dist/lib/controller-preserve.d.ts.map +1 -1
- package/dist/lib/controller-preserve.js +5 -4
- package/dist/lib/controller-preserve.js.map +1 -1
- package/dist/lib/endpoint-errors.d.ts +1 -3
- package/dist/lib/endpoint-errors.d.ts.map +1 -1
- package/dist/lib/endpoint-errors.js +1 -6
- package/dist/lib/endpoint-errors.js.map +1 -1
- package/dist/lib/endpoint-scatter.d.ts.map +1 -1
- package/dist/lib/endpoint-scatter.js +1 -2
- package/dist/lib/endpoint-scatter.js.map +1 -1
- package/dist/lib/manager-choice.d.ts +2 -31
- package/dist/lib/manager-choice.d.ts.map +1 -1
- package/dist/lib/manager-choice.js +10 -61
- package/dist/lib/manager-choice.js.map +1 -1
- package/dist/lib/manifest/live.js +1 -1
- package/dist/lib/manifest/live.js.map +1 -1
- package/dist/lib/service-census.d.ts +10 -10
- package/dist/lib/service-install-intent.d.ts +2 -2
- package/dist/lib/service-instances.d.ts +1 -1
- package/dist/lib/service-supervision.d.ts +1 -1
- package/dist/lib/service-systemd-attempt-read.d.ts +3 -3
- package/dist/lib/service-uninstall-intent.d.ts +3 -3
- package/dist/lib/space-schema-report.d.ts +5 -5
- package/dist/lib/stack-runs.d.ts.map +1 -1
- package/dist/lib/stack-runs.js +4 -3
- package/dist/lib/stack-runs.js.map +1 -1
- package/dist/lib/team-retained.d.ts.map +1 -1
- package/dist/lib/team-retained.js +4 -3
- package/dist/lib/team-retained.js.map +1 -1
- package/dist/lib/teardown-spare.d.ts.map +1 -1
- package/dist/lib/teardown-spare.js +4 -3
- package/dist/lib/teardown-spare.js.map +1 -1
- package/dist/lib/transient.js +1 -1
- package/dist/lib/transient.js.map +1 -1
- package/dist/render.js +1 -1
- package/dist/render.js.map +1 -1
- package/dist/ui.d.ts +0 -7
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +1 -24
- package/dist/ui.js.map +1 -1
- package/dist/watch-data.d.ts +1 -1
- package/dist/watch-data.d.ts.map +1 -1
- package/dist/watch-json.js +1 -1
- package/dist/watch-json.js.map +1 -1
- package/dist/watch-view.d.ts +1 -1
- package/dist/watch-view.d.ts.map +1 -1
- package/dist/watch-view.js +1 -1
- package/dist/watch-view.js.map +1 -1
- package/package.json +5 -6
- package/dist/console/control.d.ts +0 -141
- package/dist/console/control.d.ts.map +0 -1
- package/dist/console/control.js +0 -191
- package/dist/console/control.js.map +0 -1
- package/dist/lib/dial-retry.d.ts +0 -33
- package/dist/lib/dial-retry.d.ts.map +0 -1
- package/dist/lib/dial-retry.js +0 -70
- package/dist/lib/dial-retry.js.map +0 -1
- package/dist/view/mesh-view.d.ts +0 -213
- package/dist/view/mesh-view.d.ts.map +0 -1
- package/dist/view/mesh-view.js +0 -527
- package/dist/view/mesh-view.js.map +0 -1
package/dist/commands/agents.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DEV_OWNER, assertLifecycleToken, dialerFor, mintCreds, newIdentity, openSessionRail, peerLabel, standaloneConnectOpts } from "@cotal-ai/core";
|
|
2
|
-
import { codeSpan, CommandFailure, ConnectRefusal, divergentCwdAnchor, findMesh, isCommandFailure, isConnectRefusal, isWorkspaceTargetError, jsonFlag, localStackRoot, oneLine, renderReport, plainFlag, presentationOf, resolveSeatControlTarget, renderWorkspaceError, targetFlags, userSessionAuth, writeResult, recordOperationSpace, } from "@cotal-ai/workspace";
|
|
2
|
+
import { codeSpan, CommandFailure, ConnectRefusal, divergentCwdAnchor, findMesh, isCommandFailure, isConnectRefusal, isWorkspaceTargetError, jsonFlag, localStackRoot, oneLine, renderReport, plainFlag, presentationOf, resolveSeatControlTarget, renderWorkspaceError, targetFlags, userSessionAuth, writeResult, recordOperationSpace, resolveControlTarget, } from "@cotal-ai/workspace";
|
|
3
3
|
import * as prompts from "../lib/prompts.js";
|
|
4
4
|
import { canPrompt } from "./meshes-wizard.js";
|
|
5
5
|
import {} from "@nats-io/transport-node";
|
|
6
6
|
import { c, presenceFacts } from "../ui.js";
|
|
7
|
-
import {
|
|
8
|
-
import { AgentManagerUnsettled, managerPin,
|
|
7
|
+
import { cliControl, onInstance, onFlag } from "../lib/control.js";
|
|
8
|
+
import { AgentManagerUnsettled, managerPin, noLiveManager } from "../lib/manager-choice.js";
|
|
9
9
|
import { openTransient } from "../lib/transient.js";
|
|
10
10
|
import { attachClient, detachKey, holdTerminal, isDetachPress, isTransportEnd, meshSessionTransport } from "../lib/attach-client.js";
|
|
11
11
|
import { completingFlagValue } from "../lib/completion.js";
|
|
@@ -13,6 +13,7 @@ import { displayCmd } from "../lib/self-exec.js";
|
|
|
13
13
|
import { shellWord } from "../lib/endpoint-errors.js";
|
|
14
14
|
import { runningStackManagerPid, stackManagerAbsent, stackManagerStarting } from "../lib/stack-journal.js";
|
|
15
15
|
import { connectorHarnesses } from "../lib/status.js";
|
|
16
|
+
import { askManager, scatterManager, managerFailure, readFailure, refuseUnregisteredManager, unansweredDescribeRefusal, managersByInstance, askYourManagers, locateSeat, managerReadFailure, refusedManagers, seatMissRefusal, seatNotFoundMessage } from "@cotal-ai/workspace/control";
|
|
16
17
|
/**
|
|
17
18
|
* The manager's operator clients — thin control-plane request/reply commands (`stop`/`ps`/
|
|
18
19
|
* `attach`) that drive a RUNNING manager. Moved from `@cotal-ai/manager` in stage 2a of the CLI
|
|
@@ -125,7 +126,7 @@ export async function stop(args) {
|
|
|
125
126
|
t = await resolveControlTarget(v, "control-caller-admin", on);
|
|
126
127
|
}
|
|
127
128
|
recordOperationSpace(t.space);
|
|
128
|
-
const reply = await askManager(t.space, t.server, v.self ? "stopSelf" : "stop", { ...(name ? { name } : {}), graceful: v.force !== true }, t.auth, t.auth.bearer ? "owner" : "any", undefined, { instanceId: on });
|
|
129
|
+
const reply = await askManager(cliControl, t.space, t.server, v.self ? "stopSelf" : "stop", { ...(name ? { name } : {}), graceful: v.force !== true }, t.auth, t.auth.bearer ? "owner" : "any", undefined, { instanceId: on });
|
|
129
130
|
const target = { space: t.space, managerInstanceId: reply.managerInstanceId ?? on ?? null, selection: v.self ? "verified-self" : "named", ...(name ? { agent: name } : {}) };
|
|
130
131
|
if (!reply.ok)
|
|
131
132
|
throw unansweredDescribeRefusal(reply, "agent stop", target) ?? managerFailure(reply, "agent stop", target);
|
|
@@ -199,85 +200,13 @@ function fmtUptime(ms) {
|
|
|
199
200
|
const d = Math.floor(h / 24);
|
|
200
201
|
return `${d}d ${Math.floor(h - d * 24)}h`;
|
|
201
202
|
}
|
|
202
|
-
/** Exported for the console, which drives the same targeted verbs (`stop`/`attach`) from
|
|
203
|
-
* inside a TUI and so needs the THROWING resolve: an unreachable mesh there is a notice on the
|
|
204
|
-
* status line, never a `process.exit` that blanks the screen. The CLI commands keep the default. */
|
|
205
|
-
export async function locateSeat(v, name, opts = {}) {
|
|
206
|
-
// User control authority selects one manager; it does not grant the registry reads needed
|
|
207
|
-
// to scatter. Carry that selection into the targeted command's fresh credential.
|
|
208
|
-
let probe;
|
|
209
|
-
try {
|
|
210
|
-
probe = await resolveControlTarget(v, "control-caller-privileged", undefined, opts);
|
|
211
|
-
}
|
|
212
|
-
catch (e) {
|
|
213
|
-
// The exchange would not pick one of your several live managers and named them, so each is asked
|
|
214
|
-
// which seats it runs, as `ps` reads them. A manager whose read fails has not answered for itself.
|
|
215
|
-
const managers = await refusedManagers(e, v);
|
|
216
|
-
if (!managers)
|
|
217
|
-
throw e;
|
|
218
|
-
let space;
|
|
219
|
-
const instances = [];
|
|
220
|
-
for (const manager of managers) {
|
|
221
|
-
try {
|
|
222
|
-
const asked = await askYourManagers(v, "ps", [manager]);
|
|
223
|
-
space ??= asked.space;
|
|
224
|
-
instances.push(...asked.instances);
|
|
225
|
-
}
|
|
226
|
-
catch (error) {
|
|
227
|
-
instances.push({ instanceId: manager.instanceId, reachable: true, error: error instanceof Error ? error.message : String(error) });
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
const loc = locateSeatIn(instances, name);
|
|
231
|
-
return loc.kind === "several" || loc.kind === "absent" || loc.kind === "unknown" ? { ...loc, ...(space !== undefined ? { space } : {}), managers } : loc;
|
|
232
|
-
}
|
|
233
|
-
if (probe.auth.managerInstanceId !== undefined)
|
|
234
|
-
return { kind: "pin", instanceId: probe.auth.managerInstanceId };
|
|
235
|
-
if (probe.auth.bearer)
|
|
236
|
-
return { kind: "unpinned" };
|
|
237
|
-
const scatter = await scatterManager(probe.space, probe.server, "ps", probe.auth, probe.spaceAuth);
|
|
238
|
-
if (!scatter.ok && scatter.noLiveManager)
|
|
239
|
-
return { kind: "no-manager", space: probe.space, native: { code: scatter.code, detail: scatter.error } };
|
|
240
|
-
if (!scatter.ok)
|
|
241
|
-
return { kind: "unpinned" }; // cannot locate ⇒ behave exactly as before, never worse
|
|
242
|
-
const loc = locateSeatIn(scatter.instances, name);
|
|
243
|
-
return loc.kind === "several" || loc.kind === "absent" || loc.kind === "unknown" ? { ...loc, space: probe.space } : loc;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* WHAT THE SCATTER ESTABLISHED about one seat name — the whole decision, as a function of the rows
|
|
247
|
-
* alone, so it is gradable without a broker.
|
|
248
|
-
*
|
|
249
|
-
* ANSWERED FOR ITSELF means an instance returned its own roster. A slot that never answered and one
|
|
250
|
-
* that answered with a REFUSAL are the same fact for this search: neither stated which seats it
|
|
251
|
-
* hosts, so neither licenses a conclusion about a seat that might be sitting on it (#1638 item 3).
|
|
252
|
-
* The refusal half is the reachable-but-errored row `scatterManager` reports, which the older
|
|
253
|
-
* filter counted as a manager that had looked and found nothing.
|
|
254
|
-
*
|
|
255
|
-
* Absence is a claim about the WHOLE space, so it is concluded only when the whole space answered.
|
|
256
|
-
* A name that more than one answering instance runs picks none of them.
|
|
257
|
-
*/
|
|
258
|
-
export function locateSeatIn(instances, name) {
|
|
259
|
-
const reachable = instances.filter((i) => i.reachable);
|
|
260
|
-
const silent = instances.filter((i) => !i.reachable).map((i) => i.instanceId);
|
|
261
|
-
if (reachable.length <= 1 && !silent.length)
|
|
262
|
-
return { kind: "unpinned" };
|
|
263
|
-
const answered = reachable.filter((i) => i.error === undefined);
|
|
264
|
-
const refused = reachable.filter((i) => i.error !== undefined).map((i) => ({ instanceId: i.instanceId, error: i.error }));
|
|
265
|
-
const hosts = answered.filter((i) => (i.data ?? []).some((r) => r.name === name));
|
|
266
|
-
if (hosts.length === 1)
|
|
267
|
-
return { kind: "pin", instanceId: hosts[0].instanceId };
|
|
268
|
-
if (hosts.length > 1)
|
|
269
|
-
return { kind: "several", instances: hosts.map((i) => i.instanceId).sort() };
|
|
270
|
-
if (silent.length || refused.length)
|
|
271
|
-
return { kind: "unknown", answered: answered.length, silent, refused };
|
|
272
|
-
return { kind: "absent", checked: answered.length, instances: answered.map((i) => i.instanceId).sort() };
|
|
273
|
-
}
|
|
274
203
|
/** Resolve `--on` for a targeted verb: an explicit pin wins; otherwise locate the seat. Returns the
|
|
275
204
|
* instance to address, or exits with an error that says WHICH case the miss was. */
|
|
276
205
|
async function pinForTarget(v, verb) {
|
|
277
206
|
const on = await managerPin(v, verb);
|
|
278
207
|
if (on !== undefined)
|
|
279
208
|
return on;
|
|
280
|
-
const loc = await locateSeat(v, String(v.name));
|
|
209
|
+
const loc = await locateSeat(cliControl, v, String(v.name));
|
|
281
210
|
if (loc.kind === "pin")
|
|
282
211
|
return loc.instanceId;
|
|
283
212
|
if (loc.kind === "unpinned")
|
|
@@ -302,47 +231,6 @@ async function pinForTarget(v, verb) {
|
|
|
302
231
|
const question = loc.answered ? `"${shown}" was not found on the ${loc.answered === 1 ? "manager" : `${loc.answered} managers`} that answered. Which manager that did not answer should run this?` : `None of your managers answered for "${shown}". Which one should run this?`;
|
|
303
232
|
throw new AgentManagerUnsettled(question, managersByInstance(unanswered, loc.managers), "TARGET_UNAVAILABLE", message, { space: loc.space ?? null, agent, answered: loc.answered, silent: loc.silent, refused: loc.refused });
|
|
304
233
|
}
|
|
305
|
-
/** The console's wording for a seat the whole space proved absent. Main's richer `seatMissRefusal`
|
|
306
|
-
* needs the `unknown` variant too; the console (and `attachSeat`'s returned verdict) only ever
|
|
307
|
-
* hold a proved `absent`, so this stays the narrow shape their call sites guarantee. */
|
|
308
|
-
export function seatNotFoundMessage(loc, name, verb) {
|
|
309
|
-
const remedy = verb ? ` To address it directly: \`${verb} --on <instance>\` (the whole id, as printed).` : "";
|
|
310
|
-
return `no managed agent "${name}" on any of the ${loc.checked} reachable manager instance(s) in this space.${remedy}`;
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* What a `stop`/`attach`/`input` that did not find its seat TELLS the operator — and the difference
|
|
314
|
-
* between the two things it can mean (#1638 item 3).
|
|
315
|
-
*
|
|
316
|
-
* ABSENT is a claim about the whole space and is only made when the whole space answered for
|
|
317
|
-
* itself. A registration that gave no answer within the deadline is NOT told to "retry": a manager
|
|
318
|
-
* whose host died never deregisters, so its row stays in the registry indefinitely and answers
|
|
319
|
-
* nothing, and a retry against it loops forever. Say what is known (registered, silent), what it
|
|
320
|
-
* may mean (a live slow host OR a dead registration), and the two real actions.
|
|
321
|
-
*
|
|
322
|
-
* UNKNOWN is the other case and it used to print as the first one. The seat may be sitting on the
|
|
323
|
-
* instance that did not answer, so "no managed agent <name>" was a definite negative drawn from an
|
|
324
|
-
* incomplete search — and it names the instance COUNT, which is the shape a reader believes.
|
|
325
|
-
* Measured on a live mesh: a seat that `ps` listed as running the whole time was reported absent,
|
|
326
|
-
* and the same command with `--on` succeeded first time. A retry loop that reads the old sentence
|
|
327
|
-
* as "already gone" stops looking for a seat that is still running.
|
|
328
|
-
*
|
|
329
|
-
* SEVERAL names each instance that runs a seat of that name, since picking one would act on a seat
|
|
330
|
-
* the operator may not mean.
|
|
331
|
-
*/
|
|
332
|
-
export function seatMissRefusal(name, verb, loc) {
|
|
333
|
-
const address = `To address one directly: \`${verb} --on <instance>\` (the whole id, as printed).`;
|
|
334
|
-
if (loc.kind === "several")
|
|
335
|
-
return `"${name}" is held on each of ${loc.instances.length} manager instances (${loc.instances.join(", ")}), so this command does not pick one. ${address}`;
|
|
336
|
-
if (loc.kind === "absent")
|
|
337
|
-
return `no managed agent "${name}" on any of the ${loc.checked} reachable manager instance(s) in this space (${loc.instances.join(", ")}).`;
|
|
338
|
-
const silent = loc.silent.length
|
|
339
|
-
? ` ${loc.silent.length} registered manager instance(s) gave no answer within the deadline (${loc.silent.join(", ")}). Either that host is alive but slow, or it died and its registration was never removed; if it is dead, deregister it.`
|
|
340
|
-
: "";
|
|
341
|
-
const refused = loc.refused.length
|
|
342
|
-
? ` ${loc.refused.length} refused the read rather than answering (${loc.refused.map((r) => `${r.instanceId}: ${r.error}`).join("; ")}).`
|
|
343
|
-
: "";
|
|
344
|
-
return `could not establish where "${name}" is: ${loc.answered} manager instance(s) answered and none hosts it, but ${loc.silent.length + loc.refused.length} did not answer for themselves, so this is NOT a report that it is gone — it may be running on one of those.${silent}${refused} ${address}`;
|
|
345
|
-
}
|
|
346
234
|
/**
|
|
347
235
|
* What one SILENT manager instance's row says. The wording lives here, in the CLI, and not in the
|
|
348
236
|
* scatter that produced the fact: core reports a frozen slot that did not answer, and turning that
|
|
@@ -726,7 +614,7 @@ export async function readSeats(v, command, on) {
|
|
|
726
614
|
catch (e) {
|
|
727
615
|
// The exchange refused to pick one of your several live managers and named them, so each is
|
|
728
616
|
// read. That is the whole set it counts, not a fallback after a failed read.
|
|
729
|
-
const managers = on === undefined ? await refusedManagers(e, v) : undefined;
|
|
617
|
+
const managers = on === undefined ? await refusedManagers(cliControl, e, v) : undefined;
|
|
730
618
|
if (!managers)
|
|
731
619
|
throw e;
|
|
732
620
|
return readYourManagers(v, command, managers);
|
|
@@ -747,7 +635,7 @@ export async function readSeats(v, command, on) {
|
|
|
747
635
|
if (on !== undefined || t.auth.bearer) {
|
|
748
636
|
const instanceId = on ?? t.auth.managerInstanceId;
|
|
749
637
|
const target = { space: t.space, scope: "manager", managerInstanceId: instanceId ?? null };
|
|
750
|
-
const reply = await askManager(t.space, t.server, command, undefined, t.auth, "owner", undefined, on !== undefined ? { instanceId: on } : {});
|
|
638
|
+
const reply = await askManager(cliControl, t.space, t.server, command, undefined, t.auth, "owner", undefined, on !== undefined ? { instanceId: on } : {});
|
|
751
639
|
if (!reply.ok) {
|
|
752
640
|
// The one manager the exchange picked for you did not answer, so none of yours did.
|
|
753
641
|
if (t.auth.bearer && on === undefined && reply.unanswered)
|
|
@@ -761,7 +649,7 @@ export async function readSeats(v, command, on) {
|
|
|
761
649
|
// freeze rows; every registered instance is attributed, and a non-answering one is labeled with
|
|
762
650
|
// what this command established about it (pin 3).
|
|
763
651
|
const target = { space: t.space, scope: "all-managers" };
|
|
764
|
-
const scatter = await scatterManager(t.space, t.server, command, t.auth, t.spaceAuth, undefined, { reportHosts: true });
|
|
652
|
+
const scatter = await scatterManager(cliControl, t.space, t.server, command, t.auth, t.spaceAuth, undefined, { reportHosts: true });
|
|
765
653
|
// An empty manager registry on this root's own controller stack, whose manager does not run, is
|
|
766
654
|
// a known boundary with a remedy; the registry's own failure stays the cause. So is a registry
|
|
767
655
|
// that still lists that manager after its process died: no manager answered the read. While an
|
|
@@ -856,21 +744,6 @@ function silentManagersNext(instanceIds) {
|
|
|
856
744
|
const one = instanceIds.length === 1;
|
|
857
745
|
return `${one ? "manager" : "managers"} ${instanceIds.join(", ")} did not answer. If ${one ? "it is" : "one is"} still running, retry; a manager that ended without a clean stop stays registered under its instance id`;
|
|
858
746
|
}
|
|
859
|
-
/** A manager read that failed, as the classified failure. For a user-mode manager view that the
|
|
860
|
-
* broker refused before any responder saw the call, the broker does not say which row was missing,
|
|
861
|
-
* so this names the documented requirement for these reads instead of asserting a cause, and keeps
|
|
862
|
-
* the native refusal as it was. A refusal the manager answered, such as a retiring caller's, already
|
|
863
|
-
* states its own reason. */
|
|
864
|
-
function managerReadFailure(reply, target, command, userAuth) {
|
|
865
|
-
const failure = readFailure(reply, target);
|
|
866
|
-
if (!userAuth || failure.code !== "PERMISSION_DENIED" || reply.nativeOutcome !== "not-executed" || reply.answered)
|
|
867
|
-
return failure;
|
|
868
|
-
return new CommandFailure(failure.outcome, failure.code, failure.message, {
|
|
869
|
-
target,
|
|
870
|
-
remedy: `on a user-auth mesh, the manager's \`${command}\` read is documented to need the \`admin\` scope on your actor grant; \`spawn\` alone does not carry it. Check what your row holds with \`cotal auth grants\``,
|
|
871
|
-
...(failure.native ? { native: failure.native } : {}),
|
|
872
|
-
});
|
|
873
|
-
}
|
|
874
747
|
/** None of your managers answered a read on a user-auth mesh: the one the exchange picked, or each of
|
|
875
748
|
* the several it counts live. `ps` then lists your agents as presence shows them. */
|
|
876
749
|
export class NoManagerAnswered extends CommandFailure {
|
|
@@ -883,47 +756,9 @@ export class NoManagerAnswered extends CommandFailure {
|
|
|
883
756
|
});
|
|
884
757
|
}
|
|
885
758
|
}
|
|
886
|
-
/** The managers an unpinned manager selection refused to choose between, when `e` is that refusal. */
|
|
887
|
-
async function refusedManagers(e, v) {
|
|
888
|
-
const failure = isCommandFailure(e) ? e : isConnectRefusal(e) ? e.failure() : undefined;
|
|
889
|
-
return failure ? (await severalLive(failure, () => rosterOf(v)))?.managers : undefined;
|
|
890
|
-
}
|
|
891
|
-
/** Each of `managers` asked `command` through its own one-instance view, one after another, as the
|
|
892
|
-
* slots of a class scatter: the rows of one that answered, the refusal of one that answered with an
|
|
893
|
-
* error, and as silent one that did not answer or whose view was refused. The host its presence
|
|
894
|
-
* reports is kept for display. A read the broker refused before any manager saw it is thrown,
|
|
895
|
-
* because every view of the same grant is refused the same way. */
|
|
896
|
-
async function askYourManagers(v, command, managers) {
|
|
897
|
-
let space, mode;
|
|
898
|
-
const instances = [];
|
|
899
|
-
for (const { instanceId, host } of managers) {
|
|
900
|
-
let t;
|
|
901
|
-
try {
|
|
902
|
-
t = await resolveControlTarget(v, "control-caller-privileged", instanceId, { onRefusal: "throw" });
|
|
903
|
-
}
|
|
904
|
-
catch (e) {
|
|
905
|
-
if (!isCommandFailure(e) && !isConnectRefusal(e))
|
|
906
|
-
throw e;
|
|
907
|
-
instances.push({ instanceId, reachable: false });
|
|
908
|
-
continue;
|
|
909
|
-
}
|
|
910
|
-
space ??= t.space;
|
|
911
|
-
mode ??= t.mode;
|
|
912
|
-
const reply = await askManager(t.space, t.server, command, undefined, t.auth, "owner", undefined, { instanceId });
|
|
913
|
-
if (reply.ok)
|
|
914
|
-
instances.push({ instanceId, reachable: true, data: reply.data, ...(host ? { reportedHost: host } : {}) });
|
|
915
|
-
else if (reply.answered)
|
|
916
|
-
instances.push({ instanceId, reachable: true, error: reply.error ?? "the manager refused the read", ...(reply.code ? { code: reply.code } : {}) });
|
|
917
|
-
else if (reply.unanswered)
|
|
918
|
-
instances.push({ instanceId, reachable: false });
|
|
919
|
-
else
|
|
920
|
-
throw managerReadFailure(reply, { space: t.space, scope: "manager", managerInstanceId: instanceId }, command, true);
|
|
921
|
-
}
|
|
922
|
-
return { ...(space !== undefined ? { space } : {}), ...(mode !== undefined ? { mode } : {}), instances };
|
|
923
|
-
}
|
|
924
759
|
/** {@link readSeats} on a user-auth mesh with several of your managers live and none named. */
|
|
925
760
|
async function readYourManagers(v, command, managers) {
|
|
926
|
-
const { space, mode, instances } = await askYourManagers(v, command, managers);
|
|
761
|
+
const { space, mode, instances } = await askYourManagers(cliControl, v, command, managers);
|
|
927
762
|
if (space !== undefined)
|
|
928
763
|
recordOperationSpace(space);
|
|
929
764
|
if (space === undefined || !instances.some((i) => i.reachable))
|
|
@@ -1099,7 +934,7 @@ async function establishAttachSession(v, on, reconnect, firstAttempt) {
|
|
|
1099
934
|
// A refusal's report names the mesh in its heading, so this block names it once, in a field.
|
|
1100
935
|
if (first)
|
|
1101
936
|
console.error(renderReport({ sections: [{ title: "Attach", blocks: [{ kind: "fields", rows: [["Space", t.space], ["Agent", v.name], ["Manager", on ?? t.auth.managerInstanceId ?? "native selection"]] }] }] }, "rich", process.stderr));
|
|
1102
|
-
const reply = await askManager(t.space, t.server, "attach", { name: v.name }, t.auth, reach, undefined, { instanceId: on, expectedTarget: v.expectedTarget });
|
|
937
|
+
const reply = await askManager(cliControl, t.space, t.server, "attach", { name: v.name }, t.auth, reach, undefined, { instanceId: on, expectedTarget: v.expectedTarget });
|
|
1103
938
|
if (!reply.ok) {
|
|
1104
939
|
// The one refusal no attach can work around: this seat's runtime streams no terminal. It is
|
|
1105
940
|
// said once, with the runtime's own guidance for watching the agent where it really runs, and
|
|
@@ -1627,7 +1462,7 @@ export async function attachSeat(v, opts) {
|
|
|
1627
1462
|
if (opts.onRefusal === "exit")
|
|
1628
1463
|
on = await pinForTarget(v, "cotal attach");
|
|
1629
1464
|
else {
|
|
1630
|
-
const loc = await locateSeat(v, v.name, { onRefusal: "throw" });
|
|
1465
|
+
const loc = await locateSeat(cliControl, v, v.name, { onRefusal: "throw" });
|
|
1631
1466
|
if (loc.kind === "absent")
|
|
1632
1467
|
return { kind: "failed", message: seatNotFoundMessage(loc, v.name) };
|
|
1633
1468
|
if (loc.kind === "several")
|
|
@@ -1742,7 +1577,7 @@ export async function input(args) {
|
|
|
1742
1577
|
const t = await resolveControlTarget(v, "control-caller-admin", on);
|
|
1743
1578
|
recordOperationSpace(t.space);
|
|
1744
1579
|
const reach = t.auth.bearer ? "owner" : "any";
|
|
1745
|
-
const reply = await askManager(t.space, t.server, "input", { name: v.name, text: v.text, enter: v["no-enter"] !== true }, t.auth, reach, undefined, { instanceId: on });
|
|
1580
|
+
const reply = await askManager(cliControl, t.space, t.server, "input", { name: v.name, text: v.text, enter: v["no-enter"] !== true }, t.auth, reach, undefined, { instanceId: on });
|
|
1746
1581
|
const target = { space: t.space, managerInstanceId: reply.managerInstanceId ?? on ?? null, agent: v.name };
|
|
1747
1582
|
if (!reply.ok)
|
|
1748
1583
|
throw unansweredDescribeRefusal(reply, "terminal input", target) ?? managerFailure(reply, "terminal input", target);
|