@cotal-ai/cli 0.103.1 → 0.103.3
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 +2 -2
- 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 +28 -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/manager-choice.d.ts.map +1 -1
- package/dist/lib/manager-choice.js +4 -4
- package/dist/lib/manager-choice.js.map +1 -1
- package/dist/lib/prompts.d.ts +5 -0
- package/dist/lib/prompts.d.ts.map +1 -1
- package/dist/lib/prompts.js +9 -1
- package/dist/lib/prompts.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,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,
|
|
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,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mBAAa,YAAY;mBAAa,MAAM;sBAAgB,MAAM;;;;;;;GAxnC7H;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQlD;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAGrC,IAAI,EAAE,UAAU,GACf,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,OAAO,CAAC;IAAC,sBAAsB,EAAE,OAAO,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAmCxL;AAuLD;;;;;;oGAMoG;AACpG,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyC3F;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAElF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEnF;AAWD;;;;;;;;;;GAUG;AACH,KAAK,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAExC;;mCAEmC;AACnC,eAAO,MAAM,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, 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, 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";
|
|
@@ -1864,7 +1864,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1864
1864
|
}
|
|
1865
1865
|
}
|
|
1866
1866
|
if (!resumeAttempt)
|
|
1867
|
-
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>\``);
|
|
1868
1868
|
await assertBrokerAddressFree(server, "cotal up");
|
|
1869
1869
|
// A repair keeps its own store rules above, and a resume or restore names its store.
|
|
1870
1870
|
if (!resumeAttempt && !repairing) {
|
|
@@ -3238,6 +3238,13 @@ async function upManifest(file, opts) {
|
|
|
3238
3238
|
const runtime = m.runtime ?? "pty";
|
|
3239
3239
|
if (open && (m.defaults?.deliveryClass === "durable" || m.channels.some((channel) => channel.deliveryClass === "durable")))
|
|
3240
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`);
|
|
3241
3248
|
if (opts.freshTeamBoot) {
|
|
3242
3249
|
const other = loadMeshes().filter((row) => row.space !== m.space && row.server === server);
|
|
3243
3250
|
if (other.length)
|
|
@@ -4307,23 +4314,23 @@ async function assertFreshTeamBindAvailable(server, host, space) {
|
|
|
4307
4314
|
}
|
|
4308
4315
|
});
|
|
4309
4316
|
}
|
|
4310
|
-
/** The host and port a registration's broker address reserves, whatever its scheme. */
|
|
4311
|
-
function reservedAddress(server) {
|
|
4312
|
-
const address = new URL(server);
|
|
4313
|
-
return `${address.hostname}:${address.port || "4222"}`;
|
|
4314
|
-
}
|
|
4315
4317
|
/** Refuse an address that a space registered for another folder keeps while its broker is stopped,
|
|
4316
4318
|
* as an occupied one is refused. Starting there would leave two registrations naming one broker:
|
|
4317
|
-
* whichever stack runs answers for both, and the other one's `down` and reads reach it.
|
|
4318
|
-
*
|
|
4319
|
-
|
|
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;
|
|
4320
4327
|
const root = canonicalRoot(cotalRoot());
|
|
4321
|
-
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);
|
|
4322
4329
|
if (!held)
|
|
4323
4330
|
return;
|
|
4324
4331
|
throw new CommandFailure("refused", "CONFLICT", `${server} is the broker address of "${held.space}", registered for ${held.root} and stopped; nothing was started`, {
|
|
4325
4332
|
target: { root: cotalRoot(), server, space, heldSpace: held.space, heldBy: held.root },
|
|
4326
|
-
remedy:
|
|
4333
|
+
remedy: `${elsewhere}, or free that one with \`cotal space forget ${held.space}\``,
|
|
4327
4334
|
});
|
|
4328
4335
|
}
|
|
4329
4336
|
/** Choose only a first implicit address. A saved or explicitly requested address is never moved.
|
|
@@ -4331,11 +4338,18 @@ function refuseRegisteredAddress(server, space, host) {
|
|
|
4331
4338
|
async function freshStackServer(server, bindHost) {
|
|
4332
4339
|
const url = new URL(server);
|
|
4333
4340
|
const host = (bindHost ?? url.hostname).replace(/^\[|\]$/g, "");
|
|
4334
|
-
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
|
+
}
|
|
4335
4348
|
let candidate = server;
|
|
4336
4349
|
for (let attempt = 0; attempt < 16; attempt++) {
|
|
4337
4350
|
const address = new URL(candidate);
|
|
4338
|
-
|
|
4351
|
+
const key = brokerAddressKey(candidate);
|
|
4352
|
+
if (key === undefined || !reserved.has(key)) {
|
|
4339
4353
|
try {
|
|
4340
4354
|
await freePort(host, Number(address.port) || 4222);
|
|
4341
4355
|
return candidate;
|