@cotal-ai/manager 0.191.0 → 0.193.0
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 +14 -5
- package/dist/boot.d.ts +1 -0
- package/dist/boot.d.ts.map +1 -1
- package/dist/boot.js +3 -0
- package/dist/boot.js.map +1 -1
- package/dist/command-dispatch.d.ts +6 -1
- package/dist/command-dispatch.d.ts.map +1 -1
- package/dist/command-dispatch.js +26 -9
- package/dist/command-dispatch.js.map +1 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +101 -83
- package/dist/commands.js.map +1 -1
- package/dist/connector-inventory.d.ts +1 -0
- package/dist/connector-inventory.d.ts.map +1 -1
- package/dist/connector-inventory.js +1 -0
- package/dist/connector-inventory.js.map +1 -1
- package/dist/control-fork-source.d.ts +14 -0
- package/dist/control-fork-source.d.ts.map +1 -0
- package/dist/control-fork-source.js +28 -0
- package/dist/control-fork-source.js.map +1 -0
- package/dist/harness-sessions-contract.d.ts +132 -0
- package/dist/harness-sessions-contract.d.ts.map +1 -0
- package/dist/harness-sessions-contract.js +59 -0
- package/dist/harness-sessions-contract.js.map +1 -0
- package/dist/harness-sessions.d.ts +120 -0
- package/dist/harness-sessions.d.ts.map +1 -0
- package/dist/harness-sessions.js +370 -0
- package/dist/harness-sessions.js.map +1 -0
- package/dist/launch.d.ts.map +1 -1
- package/dist/launch.js +5 -20
- package/dist/launch.js.map +1 -1
- package/dist/maintenance-contract.d.ts +57 -0
- package/dist/maintenance-contract.d.ts.map +1 -0
- package/dist/maintenance-contract.js +19 -0
- package/dist/maintenance-contract.js.map +1 -0
- package/dist/manager-config.d.ts +8 -3
- package/dist/manager-config.d.ts.map +1 -1
- package/dist/manager-config.js +6 -1
- package/dist/manager-config.js.map +1 -1
- package/dist/manager-limits.d.ts +10 -0
- package/dist/manager-limits.d.ts.map +1 -0
- package/dist/manager-limits.js +46 -0
- package/dist/manager-limits.js.map +1 -0
- package/dist/manager-service-contract.d.ts +20 -1
- package/dist/manager-service-contract.d.ts.map +1 -1
- package/dist/manager-service-contract.js +32 -19
- package/dist/manager-service-contract.js.map +1 -1
- package/dist/manager-set-command.d.ts +3 -0
- package/dist/manager-set-command.d.ts.map +1 -0
- package/dist/manager-set-command.js +73 -0
- package/dist/manager-set-command.js.map +1 -0
- package/dist/manager.d.ts +18 -14
- package/dist/manager.d.ts.map +1 -1
- package/dist/manager.js +24 -4
- package/dist/manager.js.map +1 -1
- package/dist/names-capacity.d.ts +1 -0
- package/dist/names-capacity.d.ts.map +1 -1
- package/dist/names-capacity.js +5 -3
- package/dist/names-capacity.js.map +1 -1
- package/dist/parent-generation.d.ts +8 -0
- package/dist/parent-generation.d.ts.map +1 -0
- package/dist/parent-generation.js +71 -0
- package/dist/parent-generation.js.map +1 -0
- package/dist/preservation.d.ts +2 -2
- package/dist/preservation.d.ts.map +1 -1
- package/dist/preservation.js +16 -5
- package/dist/preservation.js.map +1 -1
- package/dist/preserved-resume.d.ts +6 -5
- package/dist/preserved-resume.d.ts.map +1 -1
- package/dist/preserved-resume.js +54 -31
- package/dist/preserved-resume.js.map +1 -1
- package/dist/readiness-wait.d.ts.map +1 -1
- package/dist/readiness-wait.js +5 -1
- package/dist/readiness-wait.js.map +1 -1
- package/dist/remote-authority.d.ts.map +1 -1
- package/dist/remote-authority.js +8 -3
- package/dist/remote-authority.js.map +1 -1
- package/dist/remote-register.d.ts +1 -0
- package/dist/remote-register.d.ts.map +1 -1
- package/dist/remote-register.js +13 -1
- package/dist/remote-register.js.map +1 -1
- package/dist/resume.d.ts +3 -8
- package/dist/resume.d.ts.map +1 -1
- package/dist/resume.js +17 -15
- package/dist/resume.js.map +1 -1
- package/dist/run-hosting.d.ts +5 -10
- package/dist/run-hosting.d.ts.map +1 -1
- package/dist/run-hosting.js +24 -15
- package/dist/run-hosting.js.map +1 -1
- package/dist/runtime/custodial-pty.d.ts.map +1 -1
- package/dist/runtime/custodial-pty.js +2 -0
- package/dist/runtime/custodial-pty.js.map +1 -1
- package/dist/runtime/headless.d.ts +4 -0
- package/dist/runtime/headless.d.ts.map +1 -0
- package/dist/runtime/headless.js +62 -0
- package/dist/runtime/headless.js.map +1 -0
- package/dist/runtime/pty.d.ts.map +1 -1
- package/dist/runtime/pty.js +3 -0
- package/dist/runtime/pty.js.map +1 -1
- package/dist/seat-launch.d.ts +12 -2
- package/dist/seat-launch.d.ts.map +1 -1
- package/dist/seat-launch.js +45 -0
- package/dist/seat-launch.js.map +1 -1
- package/dist/seat-start.d.ts +2 -0
- package/dist/seat-start.d.ts.map +1 -1
- package/dist/seat-start.js +47 -24
- package/dist/seat-start.js.map +1 -1
- package/dist/seat-stop.d.ts.map +1 -1
- package/dist/seat-stop.js +5 -2
- package/dist/seat-stop.js.map +1 -1
- package/dist/serve-plane.d.ts +4 -10
- package/dist/serve-plane.d.ts.map +1 -1
- package/dist/serve-plane.js +17 -12
- package/dist/serve-plane.js.map +1 -1
- package/dist/service-adapter.d.ts.map +1 -1
- package/dist/service-adapter.js +2 -0
- package/dist/service-adapter.js.map +1 -1
- package/dist/session/plane.d.ts +2 -2
- package/dist/session/plane.d.ts.map +1 -1
- package/dist/session/plane.js +8 -4
- package/dist/session/plane.js.map +1 -1
- package/dist/session-recovery.d.ts +5 -1
- package/dist/session-recovery.d.ts.map +1 -1
- package/dist/session-recovery.js +20 -1
- package/dist/session-recovery.js.map +1 -1
- package/dist/status-and-models.d.ts.map +1 -1
- package/dist/status-and-models.js +5 -2
- package/dist/status-and-models.js.map +1 -1
- package/dist/terminal-input.d.ts.map +1 -1
- package/dist/terminal-input.js +8 -0
- package/dist/terminal-input.js.map +1 -1
- package/dist/vitals.d.ts +1 -1
- package/dist/vitals.d.ts.map +1 -1
- package/dist/vitals.js +2 -2
- package/dist/vitals.js.map +1 -1
- package/package.json +12 -12
package/dist/commands.js
CHANGED
|
@@ -5,8 +5,10 @@ import { join } from "node:path";
|
|
|
5
5
|
import { Kvm } from "@nats-io/kv";
|
|
6
6
|
import * as prompts from "@clack/prompts";
|
|
7
7
|
import { dialerFor, isReachable, epAuthBucket, recordsBucket, mintCreds, newIdentity, remoteManagerActors, remoteManagerRegistrationProof, resolveAuthProvider, standaloneConnectOpts, DEFAULT_SERVER, DEFAULT_SPACE, isAuthRejection, registry, parseCommandArgs, token, writePrivateRecord, rejectionText, } from "@cotal-ai/core";
|
|
8
|
-
import { assertManagerName, authDir, canonicalLocalProcessPath, canonicalRoot, claimServicePid, consumeManagerShutdownIntent, findCotalRoot, getSpaceAuth, hasUserAuthState, isWorkspaceTargetError, listenForLocalStop, loadManagerInstanceIdentity, loadSpaceAccountAuth, parsePositiveIntegerFlag, parseSeatCapFlag, publishManagerSpareCapability, readManagerName, readManagerSeatCap, reclaimDeadPreUpgradeRecord, recordManagerName, recordManagerSeatCap, removePidPair, resolveMeshTarget,
|
|
8
|
+
import { accountInventory, assertManagerName, authDir, canonicalLocalProcessPath, canonicalRoot, claimServicePid, consumeManagerShutdownIntent, findCotalRoot, getSpaceAuth, hasUserAuthState, isWorkspaceTargetError, listenForLocalStop, loadManagerInstanceIdentity, loadSpaceAccountAuth, parsePositiveIntegerFlag, parseSeatCapFlag, publishManagerSpareCapability, readManagerName, readManagerSeatCap, reclaimDeadPreUpgradeRecord, recordManagerName, recordManagerSeatCap, removePidPair, resolveMeshTarget, userAuthStateDir, workspaceSecretStore, writePidPair, c, MANAGER_DELIVERY_AWARE_MARKER, MANAGER_PIDFILE, stderrLines, UNTRUSTED_CERTIFICATE, untilInputEnds, brokerAddressForDisplay, brokerUrlCredentialRefusal, brokerUrlHasUserinfo, CommandFailure, exitCode, inputDisabledByFlag, isCommandFailure, jsonFlag, plainFlag, presentationOf, renderReport, resolveNativeServiceTarget, writeResult, refreshRegistrationPolicy, publishServiceIdleExit, publishServiceStartup, serviceStartupPath, publishServiceStopReceipt, publishServedContract, protectedCredentialReference, readLocalRecordSource, ConfirmationRequired, findMesh, folderSpace, folderSpaceHeld, getCurrent, targetErrorCode, targetErrorSpace, workspaceErrorParts, deprecatedDaemonEntry, DEPRECATED_MANAGER_ENTRY, loadRoster, migrateProjectTrust, managerMaxAgentsFlag, parseManagerMaxAgentsFlag, inspectManagerMaxAgents, recordManagerMaxAgents, } from "@cotal-ai/workspace";
|
|
9
9
|
import { Manager } from "./manager.js";
|
|
10
|
+
import { parentGenerationHandler } from "./parent-generation.js";
|
|
11
|
+
import { managerSetCommand } from "./manager-set-command.js";
|
|
10
12
|
import { answerConnectorQuestion } from "./hosted-connector-observation.js";
|
|
11
13
|
import { acceptManagerServiceStop, armManagerServiceObserver, bindManagerServiceIdentity, managerServiceChild, managerServiceStopRequested } from "./service-child.js";
|
|
12
14
|
import { MANAGER_ENDPOINT } from "./manager-service-contract.js";
|
|
@@ -107,7 +109,19 @@ export function recordManagerPid(root, space) {
|
|
|
107
109
|
/** The space to operate on: explicit `--space`, else this folder's `.cotal/auth` space, else the
|
|
108
110
|
* default — so a manually-run manager matches the folder's mesh instead of assuming the default. */
|
|
109
111
|
function spaceFor(v, root = findCotalRoot()) {
|
|
110
|
-
|
|
112
|
+
if (v.space !== undefined)
|
|
113
|
+
return v.space;
|
|
114
|
+
const dir = authDir(root);
|
|
115
|
+
const { spaces, corrupt } = accountInventory(dir);
|
|
116
|
+
if (corrupt.length)
|
|
117
|
+
throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", `the account records under ${dir} cannot all be read`, {
|
|
118
|
+
target: { root }, remedy: "restore the unreadable account records from backup, or name a space with `--space <name>`",
|
|
119
|
+
});
|
|
120
|
+
if (spaces.length > 1)
|
|
121
|
+
throw new CommandFailure("refused", "TARGET_AMBIGUOUS", `the broker in ${root} holds multiple space accounts`, {
|
|
122
|
+
target: { root, spaces }, remedy: "name one of this folder's spaces with `--space <name>`",
|
|
123
|
+
});
|
|
124
|
+
return spaces[0] ?? DEFAULT_SPACE;
|
|
111
125
|
}
|
|
112
126
|
/** The space and root a `supervise` runs for. `--space` or `COTAL_SPACE` names the space, and the
|
|
113
127
|
* manager then runs in this folder's root. Otherwise the space is the one every other command
|
|
@@ -317,10 +331,76 @@ function answerConnectionQuestion(frame, mgr) {
|
|
|
317
331
|
process.send?.({ kind: "machine-connection-result", attemptId: frame.attemptId, ok: true, bound: mgr.serveBound() });
|
|
318
332
|
return true;
|
|
319
333
|
}
|
|
334
|
+
/** Answer only on the owning daemon's private parent channel. */
|
|
335
|
+
function serveParentGeneration(mgr) {
|
|
336
|
+
const generation = parentGenerationHandler(mgr, frame => { process.send?.(frame); });
|
|
337
|
+
process.on("message", (raw) => {
|
|
338
|
+
if (!raw || typeof raw !== "object")
|
|
339
|
+
return;
|
|
340
|
+
const frame = raw;
|
|
341
|
+
if (frame.kind === "machine-agents" && typeof frame.attemptId === "string" && /^[A-Za-z0-9-]{1,64}$/.test(frame.attemptId)) {
|
|
342
|
+
try {
|
|
343
|
+
process.send?.({ kind: "machine-agents-result", attemptId: frame.attemptId, ok: true, agents: mgr.hostedAgents() });
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
process.send?.({ kind: "machine-agents-result", attemptId: frame.attemptId, ok: false });
|
|
347
|
+
}
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (answerConnectionQuestion(frame, mgr) || answerConnectorQuestion(frame, mgr))
|
|
351
|
+
return;
|
|
352
|
+
void generation(frame);
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
async function reportManagerBrokerUnavailable() {
|
|
356
|
+
if (!process.connected || !process.send)
|
|
357
|
+
return;
|
|
358
|
+
await new Promise(resolve => process.send({ kind: "manager-start-failure", code: "space-unavailable" }, () => resolve()));
|
|
359
|
+
}
|
|
320
360
|
/** The machine daemon's private composition path can supply its same-user PATH reader. */
|
|
321
361
|
export function runMachineManager(args, readApplicationPath) {
|
|
322
362
|
return runManager(args, "auto", undefined, readApplicationPath);
|
|
323
363
|
}
|
|
364
|
+
function recordManagerStartSettings(context, flags, name, seatCap) {
|
|
365
|
+
if (flags.name !== undefined && name !== undefined) {
|
|
366
|
+
try {
|
|
367
|
+
if (readManagerName(context) !== name)
|
|
368
|
+
recordManagerName(context, name);
|
|
369
|
+
}
|
|
370
|
+
catch (e) {
|
|
371
|
+
console.error(c.yellow(`! the manager name was not recorded, so the next start does not keep it: ${e.message}`));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
if (flags["seat-cap"] !== undefined && seatCap !== undefined) {
|
|
375
|
+
try {
|
|
376
|
+
if (readManagerSeatCap(context) !== seatCap)
|
|
377
|
+
recordManagerSeatCap(context, seatCap);
|
|
378
|
+
}
|
|
379
|
+
catch (e) {
|
|
380
|
+
console.error(c.yellow(`! the manager seat cap was not recorded, so the next start does not keep it: ${e.message}`));
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function managerStartLimit(context, raw) {
|
|
385
|
+
const record = inspectManagerMaxAgents(context);
|
|
386
|
+
const requested = parseManagerMaxAgentsFlag(raw);
|
|
387
|
+
const maxAgentsWarning = requested === undefined ? record.warning : undefined;
|
|
388
|
+
if (maxAgentsWarning)
|
|
389
|
+
console.error(c.yellow(`! ${maxAgentsWarning}`));
|
|
390
|
+
return { requested, record, maxAgents: requested ?? record.recorded, maxAgentsWarning };
|
|
391
|
+
}
|
|
392
|
+
function saveManagerStartLimit(mgr, context, limit) {
|
|
393
|
+
if (limit.requested === undefined || limit.requested === limit.record.recorded)
|
|
394
|
+
return;
|
|
395
|
+
try {
|
|
396
|
+
recordManagerMaxAgents(context, limit.requested);
|
|
397
|
+
}
|
|
398
|
+
catch (error) {
|
|
399
|
+
const warning = `The Manager could not save the slot limit at ${limit.record.path}: ${rejectionText(error)}. Start with \`cotal up --max-agents <n>\` to retry the write.`;
|
|
400
|
+
mgr.reportMaxAgentsWriteWarning(warning);
|
|
401
|
+
console.error(c.yellow(`! ${warning}`));
|
|
402
|
+
}
|
|
403
|
+
}
|
|
324
404
|
async function runManager(args, defaultRuntime, service, readApplicationPath) {
|
|
325
405
|
stampConsole();
|
|
326
406
|
const { values: v, root: managerRoot } = service ? { values: args.values, root: service.root } : superviseSelection(args.values);
|
|
@@ -408,7 +488,7 @@ async function runManager(args, defaultRuntime, service, readApplicationPath) {
|
|
|
408
488
|
material = refreshed;
|
|
409
489
|
return creds;
|
|
410
490
|
},
|
|
411
|
-
tlsRequired: target.tlsRequired,
|
|
491
|
+
tlsRequired: target.tlsRequired, onBrokerUnavailable: args.values["machine-parent"] === true ? reportManagerBrokerUnavailable : undefined,
|
|
412
492
|
evict: async (principals) => (await maintain("evict-family-principal", state.instanceId, [...principals])).evictions.map((e) => e.verifiedGone),
|
|
413
493
|
reconcileForeignRegistration: async (instanceId) => { await maintain("reconcile-registration", instanceId); },
|
|
414
494
|
});
|
|
@@ -665,6 +745,8 @@ async function runManager(args, defaultRuntime, service, readApplicationPath) {
|
|
|
665
745
|
// pty runtime under Bun. Render that as one actionable line, not a raw stack (this also lands in
|
|
666
746
|
// `.cotal/manager.log` for a detached `cotal up` daemon).
|
|
667
747
|
let mgr;
|
|
748
|
+
const managerLimit = managerStartLimit({ root: managerRoot, space }, v["max-agents"]);
|
|
749
|
+
let maxAgentsReady = false;
|
|
668
750
|
try {
|
|
669
751
|
// The published-binary supervisor resolves connectors from the operator manifest (seeded +
|
|
670
752
|
// `ext add`ed), NOT from static imports — `bin/cotal.ts` no longer registers any. A direct
|
|
@@ -681,6 +763,7 @@ async function runManager(args, defaultRuntime, service, readApplicationPath) {
|
|
|
681
763
|
attachHost,
|
|
682
764
|
maxSessions,
|
|
683
765
|
...(seatCap !== undefined ? { seatCap } : {}),
|
|
766
|
+
maxAgents: managerLimit.maxAgents, maxAgentsWarning: managerLimit.maxAgentsWarning, maxAgentsReady: () => maxAgentsReady,
|
|
684
767
|
...(name !== undefined ? { name } : {}),
|
|
685
768
|
...(service?.idleExitSeconds !== undefined ? { idleExit: { afterMs: service.idleExitSeconds * 1000, onStop: () => shutdown("idle") } } : {}),
|
|
686
769
|
installedExtensions: true,
|
|
@@ -702,62 +785,8 @@ async function runManager(args, defaultRuntime, service, readApplicationPath) {
|
|
|
702
785
|
console.error(c.red(`✗ ${rejectionText(e)}`));
|
|
703
786
|
process.exit(1);
|
|
704
787
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
let pending = Promise.resolve();
|
|
708
|
-
let heldAttempt;
|
|
709
|
-
process.on("message", (raw) => {
|
|
710
|
-
if (!raw || typeof raw !== "object")
|
|
711
|
-
return;
|
|
712
|
-
const frame = raw;
|
|
713
|
-
if (frame.kind === "machine-agents" && typeof frame.attemptId === "string" && /^[A-Za-z0-9-]{1,64}$/.test(frame.attemptId)) {
|
|
714
|
-
try {
|
|
715
|
-
process.send?.({ kind: "machine-agents-result", attemptId: frame.attemptId, ok: true, agents: mgr.hostedAgents() });
|
|
716
|
-
}
|
|
717
|
-
catch {
|
|
718
|
-
process.send?.({ kind: "machine-agents-result", attemptId: frame.attemptId, ok: false });
|
|
719
|
-
}
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
if (answerConnectionQuestion(frame, mgr))
|
|
723
|
-
return;
|
|
724
|
-
if (answerConnectorQuestion(frame, mgr))
|
|
725
|
-
return;
|
|
726
|
-
if (frame.kind !== "machine-generation" || typeof frame.attemptId !== "string" || !["inspect", "prepare", "abort"].includes(String(frame.op)))
|
|
727
|
-
return;
|
|
728
|
-
const attemptId = frame.attemptId;
|
|
729
|
-
pending = pending.then(async () => {
|
|
730
|
-
try {
|
|
731
|
-
if (frame.op === "inspect") {
|
|
732
|
-
process.send?.({ kind: "machine-generation-result", attemptId, op: frame.op, ok: true, seats: mgr.hostedSeatCount() });
|
|
733
|
-
return;
|
|
734
|
-
}
|
|
735
|
-
else if (frame.op === "abort") {
|
|
736
|
-
if (heldAttempt === attemptId) {
|
|
737
|
-
mgr.abortPreservation(attemptId);
|
|
738
|
-
heldAttempt = undefined;
|
|
739
|
-
}
|
|
740
|
-
else if (heldAttempt)
|
|
741
|
-
throw new Error("another parent attempt holds the manager");
|
|
742
|
-
}
|
|
743
|
-
else {
|
|
744
|
-
heldAttempt = attemptId;
|
|
745
|
-
const plan = await mgr.preparePreservation(attemptId);
|
|
746
|
-
if (!plan.ok || plan.inventory.agents.length !== 0) {
|
|
747
|
-
mgr.abortPreservation(attemptId);
|
|
748
|
-
heldAttempt = undefined;
|
|
749
|
-
process.send?.({ kind: "machine-generation-result", attemptId, op: frame.op, ok: false });
|
|
750
|
-
return;
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
process.send?.({ kind: "machine-generation-result", attemptId, op: frame.op, ok: true });
|
|
754
|
-
}
|
|
755
|
-
catch {
|
|
756
|
-
process.send?.({ kind: "machine-generation-result", attemptId, op: frame.op, ok: false });
|
|
757
|
-
}
|
|
758
|
-
});
|
|
759
|
-
});
|
|
760
|
-
}
|
|
788
|
+
if (args.values["machine-parent"] === true && process.connected)
|
|
789
|
+
serveParentGeneration(mgr);
|
|
761
790
|
const managerContext = { root: managerRoot, space };
|
|
762
791
|
// Until the settled record exists, a release only drops a managed child's exact starting slot.
|
|
763
792
|
// A failed start or a stop that wins the start leaves no settled legacy record behind.
|
|
@@ -869,6 +898,8 @@ async function runManager(args, defaultRuntime, service, readApplicationPath) {
|
|
|
869
898
|
// A stop that arrived during start owns the exit; this process never announces itself ready.
|
|
870
899
|
if (shuttingDown)
|
|
871
900
|
return;
|
|
901
|
+
saveManagerStartLimit(mgr, managerContext, managerLimit);
|
|
902
|
+
maxAgentsReady = true;
|
|
872
903
|
// The control capability precedes the pid record, so a stop cannot observe a ready manager
|
|
873
904
|
// before its cooperative endpoint exists. A failed start still publishes no pid record. A
|
|
874
905
|
// managed child already owns its exact starting PID slot; it settles that same process here.
|
|
@@ -876,24 +907,7 @@ async function runManager(args, defaultRuntime, service, readApplicationPath) {
|
|
|
876
907
|
publishManagerSpareCapability(managerContext, mgr.spareSeats);
|
|
877
908
|
if (args.values["machine-parent"] === true && remoteAuthority && process.connected)
|
|
878
909
|
process.send?.({ kind: "manager-ready", instanceId: remoteAuthority.instanceId }, () => { });
|
|
879
|
-
|
|
880
|
-
try {
|
|
881
|
-
if (readManagerName(managerContext) !== name)
|
|
882
|
-
recordManagerName(managerContext, name);
|
|
883
|
-
}
|
|
884
|
-
catch (e) {
|
|
885
|
-
console.error(c.yellow(`! the manager name was not recorded, so the next start does not keep it: ${e.message}`));
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
if (v["seat-cap"] !== undefined && seatCap !== undefined) {
|
|
889
|
-
try {
|
|
890
|
-
if (readManagerSeatCap(managerContext) !== seatCap)
|
|
891
|
-
recordManagerSeatCap(managerContext, seatCap);
|
|
892
|
-
}
|
|
893
|
-
catch (e) {
|
|
894
|
-
console.error(c.yellow(`! the manager seat cap was not recorded, so the next start does not keep it: ${e.message}`));
|
|
895
|
-
}
|
|
896
|
-
}
|
|
910
|
+
recordManagerStartSettings(managerContext, v, name, seatCap);
|
|
897
911
|
if (!service)
|
|
898
912
|
console.log(c.green("✓ manager up") +
|
|
899
913
|
c.dim(` (space ${space} · ${name !== undefined ? `${name} · ` : ""}${mgr.runtimeKind})`) +
|
|
@@ -1153,6 +1167,7 @@ const managerCommands = [
|
|
|
1153
1167
|
{ name: "ws-port", type: "string", description: "the prepared broker websocket port" },
|
|
1154
1168
|
{ name: "max-sessions", type: "string", description: "explicit positive native session ceiling" },
|
|
1155
1169
|
{ name: "seat-cap", type: "string", description: "explicit native per-owner seat ceiling, or unlimited" },
|
|
1170
|
+
managerMaxAgentsFlag,
|
|
1156
1171
|
{ name: "idle-exit", type: "string", description: "stop once the manager has held no agents for this many seconds" },
|
|
1157
1172
|
{ name: "launch", type: "string", description: "private native launch spec for this selected space" },
|
|
1158
1173
|
{ name: "launch-sha256", type: "string", description: "full digest pinned by the saved service definition" },
|
|
@@ -1199,6 +1214,7 @@ const managerCommands = [
|
|
|
1199
1214
|
{ name: "ws-port", type: "string", value: "<n>", description: "broker ws listener port for the console session client" },
|
|
1200
1215
|
{ name: "max-sessions", type: "string", value: "<n>", description: "live-session ceiling (default 64; one session per console pane, so size for agents × panes)" },
|
|
1201
1216
|
{ name: "seat-cap", type: "string", value: "<n|unlimited>", description: "live seats this manager admits per owner (default unlimited); kept for later starts in this root" },
|
|
1217
|
+
managerMaxAgentsFlag,
|
|
1202
1218
|
{ name: "name", type: "string", value: "<name>", description: "the name who --all, the manager choice and --on use for this manager; kept for later starts in this root" },
|
|
1203
1219
|
{ name: "roster", type: "string", value: "<file>", description: "declarative roster to boot at startup" },
|
|
1204
1220
|
{ name: "launch", type: "string", value: "<spec>", description: "resolved mesh-manifest launch spec (`cotal up -f` / `spawn -f`)" },
|
|
@@ -1210,6 +1226,7 @@ const managerCommands = [
|
|
|
1210
1226
|
],
|
|
1211
1227
|
validate: (args) => {
|
|
1212
1228
|
superviseExecution(args.values);
|
|
1229
|
+
parseManagerMaxAgentsFlag(args.values["max-agents"]);
|
|
1213
1230
|
// COTAL_SERVER stands in for --server (see superviseTarget), so it is refused as the flag is.
|
|
1214
1231
|
const server = process.env.COTAL_SERVER;
|
|
1215
1232
|
if (args.values.server === undefined && server !== undefined && brokerUrlHasUserinfo(server))
|
|
@@ -1269,16 +1286,17 @@ const managerCommands = [
|
|
|
1269
1286
|
run: runSeats,
|
|
1270
1287
|
},
|
|
1271
1288
|
];
|
|
1272
|
-
const
|
|
1289
|
+
const localMaintenance = [
|
|
1273
1290
|
{ name: "reconcile", source: "reconcile-gate", summary: "repair an owned manager issuance gate from its mesh root", examples: [{ command: "cotal manager reconcile --dry-run", note: "show whether its issuance gate needs repair" }, { command: "cotal manager reconcile --yes", note: "repair it" }] },
|
|
1274
1291
|
{ name: "seats", source: "seats", summary: "inspect retained local seats; --drain removes only childless records", examples: [{ command: "cotal manager seats", note: "list the seats an earlier manager left" }, { command: "cotal manager seats --drain --dry-run", note: "preview draining the finished seats" }] },
|
|
1275
|
-
]
|
|
1292
|
+
];
|
|
1293
|
+
const maintenance = localMaintenance.map((mode) => {
|
|
1276
1294
|
const source = managerCommands.find((command) => command.name === mode.source);
|
|
1277
1295
|
if (!source)
|
|
1278
1296
|
throw new Error(`manager command ${mode.source} is not registered`);
|
|
1279
1297
|
const command = { ...source, flags: source.flags?.map((flag) => flag.name === "space" ? { ...flag, short: "s" } : flag) };
|
|
1280
1298
|
return { ...mode, command };
|
|
1281
|
-
});
|
|
1299
|
+
}).concat({ name: "set", source: managerSetCommand.name, summary: managerSetCommand.summary, examples: managerSetCommand.examples ?? [], command: managerSetCommand });
|
|
1282
1300
|
const maintenanceFlags = new Map();
|
|
1283
1301
|
for (const mode of maintenance)
|
|
1284
1302
|
for (const flag of mode.command.flags ?? []) {
|
|
@@ -1320,14 +1338,14 @@ const managerGroup = {
|
|
|
1320
1338
|
aliases: ["mgr"],
|
|
1321
1339
|
group: "Services",
|
|
1322
1340
|
summary: "start, stop and check the manager that runs your agents",
|
|
1323
|
-
usage: "cotal manager [start | stop | restart | status | logs | install | uninstall | reconcile | seats] [options]",
|
|
1341
|
+
usage: "cotal manager [start | stop | restart | status | logs | install | uninstall | reconcile | seats | set] [options]",
|
|
1324
1342
|
examples: [{ command: "cotal manager start", note: "start the manager that runs your agents" }, { command: "cotal manager status", note: "check whether it runs" }, { command: "cotal manager logs --follow", note: "follow what it logs" }],
|
|
1325
|
-
positionals: "[start | stop | restart | status | logs | install | uninstall | reconcile | seats]",
|
|
1343
|
+
positionals: "[start | stop | restart | status | logs | install | uninstall | reconcile | seats | set]",
|
|
1326
1344
|
outputs: ["json", "plain"],
|
|
1327
1345
|
flags: [...maintenanceFlags.values()],
|
|
1328
1346
|
subcommands: [
|
|
1329
1347
|
...lifecycle.map((mode) => ({ name: mode.name, summary: mode.summary, usage: mode.usage, examples: mode.examples, flagNames: ["json", "plain"], outputs: mode.name === "logs" ? ["json", "ndjson", "plain"] : ["json", "plain"] })),
|
|
1330
|
-
...maintenance.map((mode) => ({ name: mode.name, summary: mode.summary, examples: mode.examples, flagNames: mode.command.flags?.map((flag) => flag.name), outputs: mode.command.outputs, usage: mode.name === "seats" ? "cotal manager seats [--drain [--yes|--dry-run]] [--json|--plain]" : "cotal manager reconcile [--space <space>] [--server <url>] [--instance <id>] [--yes|--dry-run] [--json|--plain]" })),
|
|
1348
|
+
...maintenance.map((mode) => ({ name: mode.name, summary: mode.summary, examples: mode.examples, flagNames: mode.command.flags?.map((flag) => flag.name), outputs: mode.command.outputs, usage: mode.name === "set" ? managerSetCommand.usage : mode.name === "seats" ? "cotal manager seats [--drain [--yes|--dry-run]] [--json|--plain]" : "cotal manager reconcile [--space <space>] [--server <url>] [--instance <id>] [--yes|--dry-run] [--json|--plain]" })),
|
|
1331
1349
|
],
|
|
1332
1350
|
reads: true,
|
|
1333
1351
|
prepareMeshTarget: false,
|