@cotal-ai/cli 0.102.0 → 0.103.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +8 -1
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/meshes-add.d.ts.map +1 -1
- package/dist/commands/meshes-add.js +2 -0
- package/dist/commands/meshes-add.js.map +1 -1
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +54 -30
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +1 -0
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +45 -14
- package/dist/commands/up.js.map +1 -1
- package/dist/console/ui/Detail.d.ts.map +1 -1
- package/dist/console/ui/Detail.js +1 -1
- package/dist/console/ui/Detail.js.map +1 -1
- package/dist/lib/control.d.ts +11 -0
- package/dist/lib/control.d.ts.map +1 -1
- package/dist/lib/control.js +21 -0
- package/dist/lib/control.js.map +1 -1
- package/dist/lib/delivery-proc.d.ts.map +1 -1
- package/dist/lib/delivery-proc.js +6 -5
- package/dist/lib/delivery-proc.js.map +1 -1
- package/dist/lib/local-process-stop.d.ts +2 -2
- package/dist/lib/local-process-stop.d.ts.map +1 -1
- package/dist/lib/local-process-stop.js +4 -0
- package/dist/lib/local-process-stop.js.map +1 -1
- package/dist/lib/manager-choice.d.ts +12 -2
- package/dist/lib/manager-choice.d.ts.map +1 -1
- package/dist/lib/manager-choice.js +15 -6
- package/dist/lib/manager-choice.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../src/commands/up.ts"],"names":[],"mappings":"AAqBA,OAAO,EASL,KAAK,eAAe,EA+BpB,KAAK,YAAY,EAIjB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,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AM,oBAAoB,GAAI,GAAG,SAAS,EAAE,YAAY,UAAU,KAAG,IAAoC,CAAC"}
|
package/dist/commands/up.js
CHANGED
|
@@ -8,7 +8,7 @@ import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
|
8
8
|
import { isReachable, dialerFor, DEFAULT_SERVER, DEFAULT_SPACE, createSpaceAuth, serverConfig, openServerConfig, validateTlsMaterial, credsProblem, mintCreds, mintLifecycleUid, DEV_OWNER, mintConnectionEvictorCreds, mintMembershipObserverCreds, newIdentity, setupSpaceStreams, reconcileSpaceTtls, ttlBuckets, standaloneConnectOpts, requireBrokerFloor, parseServerVersion, presenceBucket, MEMBERSHIP_MAX_BYTES, spaceDeletionStreams, isJetStreamMissing, seedChannelRegistry, ensureDefaultDeliveryClass, assertValidChannel, isConcreteChannel, validateChannelConfig, validateChannelDefaults, LEASE_TTL_MS, mkSecretDir, openPrivateAppend, realDirNoSymlink, writeSecretFile, writeSecretFileAtomic, utf16Problem, } from "@cotal-ai/core";
|
|
9
9
|
import { JetStreamApiCodes, jetstreamManager, StorageType } from "@nats-io/jetstream";
|
|
10
10
|
import { Kvm } from "@nats-io/kv";
|
|
11
|
-
import { assertManagerName, readManagerName, recordManagerName, assertRecordIdentity, formatRecord, identityRecord, parseRecord, CommandFailure, commandFailureReport, isCommandFailure, protectedLocalDirectory, jsonFlag, plainFlag, renderReport, terminalWidth, assertSingleSpaceBroker, assertUserAuthInfo, authDir, brokerAddressForDisplay, getSoleSpaceAuth, soleSpaceOf, getSpaceAuth, hasUserAuthState, listSpaceAccounts, preloadSpaceAccounts, putSpaceAuth, canonicalRoot, rootPathProblem, rootControlProblem, clearCurrent, findMesh, findPreparedSpace, homeCotalDir, getCurrent, loadMeshes, preparedSpaceAt, removePreparedSpace, localMeshesForRoot, keepsRegistration, oneLine, presentationOf, writeResult, connectionEvictorCredsKey, membershipConfigPath, membershipObserverCredsKey, membershipRwCredsKey, MEMBERSHIP_CONFIG_KIND, MEMBERSHIP_RW_CREDS_KIND, parsePositiveIntegerFlag, recordMesh, retainedLegacyBroker, meshesForRoot, removeMesh, rotateSystemCreds, setCurrent, staleSystemCreds, SYSTEM_CREDS_FILES, userAuthStateDir, userAuthSpacesOnDisk, workspaceSecretStore, acquireMaintenanceLock, assertStoreIdentity, assessMaintenanceClaim, assessRestoreClaim, beginOrdinaryResume, bindOrdinaryResumeListener, consumeRetiredMaintenance, markOrdinaryResumeActive, markOrdinaryResumeDegraded, replaceDeadOrdinaryResumeListener, localProcessOwnerStatus, readMaintenanceJournal, rootNamesNoSpace, readMaintenanceResumeDocument, seatCheckpointDir, readStoreIdentity, recordOrdinaryResumeManagerCommit, releaseMaintenanceLock, retireOrdinaryResume, settleTokenHandoff, sweepTokenHandoff, writeTokenHandoff, sameStoreIdentity, cutController, readBrokerPolicy, writeBrokerPolicy, removePidPair, writePidPair, isLoopbackHost, connectUserControlOrThrow, userViewAuth, recordOperationSpace, recordOperationWarning, retainSystemSigningSeed, restoreLeftOut, SPACE_NAME_MAX, spaceNameTooLong, MIN_FILE_STORE, exitCode, } from "@cotal-ai/workspace";
|
|
11
|
+
import { assertManagerName, readManagerName, readManagerSeatCap, recordManagerName, recordManagerSeatCap, parseSeatCapFlag, seatCapText, assertRecordIdentity, formatRecord, identityRecord, parseRecord, CommandFailure, commandFailureReport, isCommandFailure, protectedLocalDirectory, jsonFlag, plainFlag, renderReport, terminalWidth, assertSingleSpaceBroker, assertUserAuthInfo, authDir, brokerAddressForDisplay, getSoleSpaceAuth, soleSpaceOf, getSpaceAuth, hasUserAuthState, listSpaceAccounts, preloadSpaceAccounts, putSpaceAuth, brokerAddressKey, canonicalRoot, rootPathProblem, rootControlProblem, clearCurrent, findMesh, findPreparedSpace, homeCotalDir, getCurrent, loadMeshes, preparedSpaceAt, removePreparedSpace, localMeshesForRoot, keepsRegistration, oneLine, presentationOf, writeResult, connectionEvictorCredsKey, membershipConfigPath, membershipObserverCredsKey, membershipRwCredsKey, MEMBERSHIP_CONFIG_KIND, MEMBERSHIP_RW_CREDS_KIND, parsePositiveIntegerFlag, recordMesh, retainedLegacyBroker, meshesForRoot, removeMesh, rotateSystemCreds, setCurrent, staleSystemCreds, SYSTEM_CREDS_FILES, userAuthStateDir, userAuthSpacesOnDisk, workspaceSecretStore, acquireMaintenanceLock, assertStoreIdentity, assessMaintenanceClaim, assessRestoreClaim, beginOrdinaryResume, bindOrdinaryResumeListener, consumeRetiredMaintenance, markOrdinaryResumeActive, markOrdinaryResumeDegraded, replaceDeadOrdinaryResumeListener, localProcessOwnerStatus, readMaintenanceJournal, rootNamesNoSpace, readMaintenanceResumeDocument, seatCheckpointDir, readStoreIdentity, recordOrdinaryResumeManagerCommit, releaseMaintenanceLock, retireOrdinaryResume, settleTokenHandoff, sweepTokenHandoff, writeTokenHandoff, sameStoreIdentity, cutController, readBrokerPolicy, writeBrokerPolicy, removePidPair, writePidPair, isLoopbackHost, connectUserControlOrThrow, userViewAuth, recordOperationSpace, recordOperationWarning, retainSystemSigningSeed, restoreLeftOut, SPACE_NAME_MAX, spaceNameTooLong, MIN_FILE_STORE, exitCode, } from "@cotal-ai/workspace";
|
|
12
12
|
import { FlagValueRefusal } from "../lib/flag-value-refusal.js";
|
|
13
13
|
import { ensureAuthService, resolveAuthProvider, stopAuthService } from "../lib/auth-proc.js";
|
|
14
14
|
import { resolveSpace } from "../lib/status.js";
|
|
@@ -109,6 +109,7 @@ export const upFlags = [
|
|
|
109
109
|
{ name: "runtime", type: "string", value: "<name>", description: "agent runtime for the mesh manager (default pty; extension runtimes are explicit-only, see `cotal runtimes`); with -f overrides the manifest's runtime" },
|
|
110
110
|
{ name: "max-sessions", type: "string", value: "<n>", description: "live-session ceiling for the mesh manager (default 64; one session per console pane, so size for agents × panes). Recorded and reused by later manager launches" },
|
|
111
111
|
{ name: "manager-name", type: "string", value: "<name>", description: "name this root's manager for who --all, the manager choice and --on; kept for later starts" },
|
|
112
|
+
{ name: "seat-cap", type: "string", value: "<n|unlimited>", description: "live seats this root's manager admits per owner (default unlimited); kept for later starts" },
|
|
112
113
|
{ name: "no-manager", type: "boolean", description: "broker-only boot: start the broker and, in auth mode, the delivery daemon, and no local manager (refuses on a mesh whose manager is live)" },
|
|
113
114
|
{ name: "file", type: "string", short: "f", value: "<cotal.yaml>", description: "launch a whole mesh from a manifest" },
|
|
114
115
|
{ name: "dry-run", type: "boolean", description: "with -f: print the plan, mutate nothing" },
|
|
@@ -186,6 +187,7 @@ export function validateUpArguments(args) {
|
|
|
186
187
|
// Flag values and combinations are usage, so they refuse here, before any effect. The run keeps
|
|
187
188
|
// its own checks for maintenance re-entries, which do not pass through this validation.
|
|
188
189
|
parsePositiveIntegerFlag("--max-sessions", args.values["max-sessions"]);
|
|
190
|
+
parseSeatCapFlag("--seat-cap", args.values["seat-cap"]);
|
|
189
191
|
parseMaxFileStore(args.values["max-file-store"]);
|
|
190
192
|
// The timeout belongs to the auth callout, which only a user-auth space has. A manifest or a
|
|
191
193
|
// restore starts the broker its own record describes, so neither takes it.
|
|
@@ -763,6 +765,8 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
763
765
|
throw new CommandFailure("refused", "USAGE_INVALID", "fresh team boot accepts one manifest and its selected lifetime, not a restore, rotation or manager-free override");
|
|
764
766
|
if (values["manager-name"] !== undefined && (values.restore || values.file || values["no-manager"]))
|
|
765
767
|
throw new CommandFailure("refused", "USAGE_INVALID", "--manager-name names the manager a plain cotal up starts; it cannot be combined with --restore, --file or --no-manager");
|
|
768
|
+
if (values["seat-cap"] !== undefined && (values.restore || values.file || values["no-manager"]))
|
|
769
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--seat-cap caps the manager a plain cotal up starts; it cannot be combined with --restore, --file or --no-manager");
|
|
766
770
|
// `space create` and `down` refuse a root other local accounts can write, so `up` refuses it too,
|
|
767
771
|
// before anything is written: a stack started there could not be stopped from it.
|
|
768
772
|
protectedLocalDirectory(canonicalRoot(cotalRoot()), "the project root");
|
|
@@ -1255,6 +1259,19 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1255
1259
|
recordManagerName(named, name);
|
|
1256
1260
|
}
|
|
1257
1261
|
}
|
|
1262
|
+
// `--seat-cap` is recorded the same way, and read by the manager at each start, so a repair, a
|
|
1263
|
+
// resume or a bare `up` after `down` keeps a ceiling the operator set instead of reopening the
|
|
1264
|
+
// host to one owner. A running manager keeps the cap it started with.
|
|
1265
|
+
if (values["seat-cap"] !== undefined) {
|
|
1266
|
+
const cap = parseSeatCapFlag("--seat-cap", values["seat-cap"]);
|
|
1267
|
+
const capped = { root: cotalRoot(), space: values.space ?? folderSpace() };
|
|
1268
|
+
if (readManagerSeatCap(capped) !== cap) {
|
|
1269
|
+
if (managerRecordState(undefined, undefined, capped.space, capped.root).state === "alive")
|
|
1270
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", `a manager already runs for space ${capped.space}, and it keeps the seat cap it started with`, { target: { root: capped.root, space: capped.space }, remedy: `stop it with cotal down, then run cotal up --seat-cap ${seatCapText(cap)}` });
|
|
1271
|
+
if (!values["dry-run"])
|
|
1272
|
+
recordManagerSeatCap(capped, cap);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1258
1275
|
// THE TRANSPORT IS DECIDED HERE, ABOVE EVERY BRANCH, AND THIS POSITION IS THE FIX.
|
|
1259
1276
|
//
|
|
1260
1277
|
// It used to be resolved inside the foreground path only, which meant three routes to a listener
|
|
@@ -1847,7 +1864,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1847
1864
|
}
|
|
1848
1865
|
}
|
|
1849
1866
|
if (!resumeAttempt)
|
|
1850
|
-
refuseRegisteredAddress(server, values.space ?? folderSpace(), host);
|
|
1867
|
+
refuseRegisteredAddress(server, values.space ?? folderSpace(), `start this one at another address with \`cotal up --server nats://${host}:<port>\``);
|
|
1851
1868
|
await assertBrokerAddressFree(server, "cotal up");
|
|
1852
1869
|
// A repair keeps its own store rules above, and a resume or restore names its store.
|
|
1853
1870
|
if (!resumeAttempt && !repairing) {
|
|
@@ -3221,6 +3238,13 @@ async function upManifest(file, opts) {
|
|
|
3221
3238
|
const runtime = m.runtime ?? "pty";
|
|
3222
3239
|
if (open && (m.defaults?.deliveryClass === "durable" || m.channels.some((channel) => channel.deliveryClass === "durable")))
|
|
3223
3240
|
throw new CommandFailure("refused", "UNSUPPORTED", "this open manifest explicitly requests durable channel delivery, but the open broker has no delivery daemon; no channel metadata or broker was written", { target: { space: m.space, defaultDurable: m.defaults?.deliveryClass === "durable", channels: m.channels.filter((channel) => channel.deliveryClass === "durable").map((channel) => channel.name) }, remedy: "use static/user authentication for durable delivery, or declare live delivery for an open mesh" });
|
|
3241
|
+
// The address this manifest names is held by the same rule as a `--server` on the flag path: a
|
|
3242
|
+
// stopped space keeps its registered address, and a second stack started there answers for both
|
|
3243
|
+
// registrations. A fresh team boot has its own refusal below, so this is the ordinary `up -f`.
|
|
3244
|
+
if (!opts.freshTeamBoot)
|
|
3245
|
+
refuseRegisteredAddress(server, m.space, opts.server !== undefined
|
|
3246
|
+
? `start this one at another address with \`cotal up -f ${file} --server nats://${host}:<port>\``
|
|
3247
|
+
: `point broker.servers in ${file} at another address`);
|
|
3224
3248
|
if (opts.freshTeamBoot) {
|
|
3225
3249
|
const other = loadMeshes().filter((row) => row.space !== m.space && row.server === server);
|
|
3226
3250
|
if (other.length)
|
|
@@ -4290,23 +4314,23 @@ async function assertFreshTeamBindAvailable(server, host, space) {
|
|
|
4290
4314
|
}
|
|
4291
4315
|
});
|
|
4292
4316
|
}
|
|
4293
|
-
/** The host and port a registration's broker address reserves, whatever its scheme. */
|
|
4294
|
-
function reservedAddress(server) {
|
|
4295
|
-
const address = new URL(server);
|
|
4296
|
-
return `${address.hostname}:${address.port || "4222"}`;
|
|
4297
|
-
}
|
|
4298
4317
|
/** Refuse an address that a space registered for another folder keeps while its broker is stopped,
|
|
4299
4318
|
* as an occupied one is refused. Starting there would leave two registrations naming one broker:
|
|
4300
|
-
* whichever stack runs answers for both, and the other one's `down` and reads reach it.
|
|
4301
|
-
*
|
|
4302
|
-
|
|
4319
|
+
* whichever stack runs answers for both, and the other one's `down` and reads reach it. Every
|
|
4320
|
+
* start that names its own address asks this, a manifest's `broker.servers` included, and
|
|
4321
|
+
* `elsewhere` names the way to move the one being started. A space this start takes the name of is
|
|
4322
|
+
* left to the name rules. */
|
|
4323
|
+
function refuseRegisteredAddress(server, space, elsewhere) {
|
|
4324
|
+
const key = brokerAddressKey(server);
|
|
4325
|
+
if (key === undefined)
|
|
4326
|
+
return;
|
|
4303
4327
|
const root = canonicalRoot(cotalRoot());
|
|
4304
|
-
const held = loadMeshes().find((m) => m.space !== space && canonicalRoot(m.root) !== root &&
|
|
4328
|
+
const held = loadMeshes().find((m) => m.space !== space && canonicalRoot(m.root) !== root && brokerAddressKey(m.server) === key);
|
|
4305
4329
|
if (!held)
|
|
4306
4330
|
return;
|
|
4307
4331
|
throw new CommandFailure("refused", "CONFLICT", `${server} is the broker address of "${held.space}", registered for ${held.root} and stopped; nothing was started`, {
|
|
4308
4332
|
target: { root: cotalRoot(), server, space, heldSpace: held.space, heldBy: held.root },
|
|
4309
|
-
remedy:
|
|
4333
|
+
remedy: `${elsewhere}, or free that one with \`cotal space forget ${held.space}\``,
|
|
4310
4334
|
});
|
|
4311
4335
|
}
|
|
4312
4336
|
/** Choose only a first implicit address. A saved or explicitly requested address is never moved.
|
|
@@ -4314,11 +4338,18 @@ function refuseRegisteredAddress(server, space, host) {
|
|
|
4314
4338
|
async function freshStackServer(server, bindHost) {
|
|
4315
4339
|
const url = new URL(server);
|
|
4316
4340
|
const host = (bindHost ?? url.hostname).replace(/^\[|\]$/g, "");
|
|
4317
|
-
const reserved = new Set(
|
|
4341
|
+
const reserved = new Set();
|
|
4342
|
+
// A recorded address this cannot take apart reserves nothing: it names no host and port to avoid.
|
|
4343
|
+
for (const mesh of loadMeshes()) {
|
|
4344
|
+
const key = brokerAddressKey(mesh.server);
|
|
4345
|
+
if (key !== undefined)
|
|
4346
|
+
reserved.add(key);
|
|
4347
|
+
}
|
|
4318
4348
|
let candidate = server;
|
|
4319
4349
|
for (let attempt = 0; attempt < 16; attempt++) {
|
|
4320
4350
|
const address = new URL(candidate);
|
|
4321
|
-
|
|
4351
|
+
const key = brokerAddressKey(candidate);
|
|
4352
|
+
if (key === undefined || !reserved.has(key)) {
|
|
4322
4353
|
try {
|
|
4323
4354
|
await freePort(host, Number(address.port) || 4222);
|
|
4324
4355
|
return candidate;
|