@cotal-ai/cli 0.170.0 → 0.171.1
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/command.d.ts.map +1 -1
- package/dist/command.js +9 -2
- package/dist/command.js.map +1 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +18 -17
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/channels.d.ts.map +1 -1
- package/dist/commands/channels.js +3 -2
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +9 -4
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +4 -3
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +5 -2
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/ext.d.ts.map +1 -1
- package/dist/commands/ext.js +17 -8
- package/dist/commands/ext.js.map +1 -1
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +5 -4
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/join.js +9 -4
- package/dist/commands/join.js.map +1 -1
- package/dist/commands/manager-service.js +1 -1
- package/dist/commands/manager-service.js.map +1 -1
- package/dist/commands/meshes.d.ts.map +1 -1
- package/dist/commands/meshes.js +2 -7
- package/dist/commands/meshes.js.map +1 -1
- package/dist/commands/mint.d.ts.map +1 -1
- package/dist/commands/mint.js +5 -0
- package/dist/commands/mint.js.map +1 -1
- package/dist/commands/persona.d.ts.map +1 -1
- package/dist/commands/persona.js +4 -2
- package/dist/commands/persona.js.map +1 -1
- package/dist/commands/service-actions.d.ts.map +1 -1
- package/dist/commands/service-actions.js +13 -4
- package/dist/commands/service-actions.js.map +1 -1
- package/dist/commands/service-registry.d.ts.map +1 -1
- package/dist/commands/service-registry.js +5 -1
- package/dist/commands/service-registry.js.map +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +22 -16
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/space.d.ts.map +1 -1
- package/dist/commands/space.js +36 -16
- package/dist/commands/space.js.map +1 -1
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +4 -8
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/stack-up.d.ts +2 -2
- package/dist/commands/stack-up.d.ts.map +1 -1
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +47 -30
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/up.d.ts +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +19 -113
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/use.d.ts.map +1 -1
- package/dist/commands/use.js +7 -5
- package/dist/commands/use.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/channel-seed.d.ts +15 -0
- package/dist/lib/channel-seed.d.ts.map +1 -0
- package/dist/lib/channel-seed.js +121 -0
- package/dist/lib/channel-seed.js.map +1 -0
- package/dist/lib/history-command.d.ts +3 -0
- package/dist/lib/history-command.d.ts.map +1 -0
- package/dist/lib/history-command.js +6 -0
- package/dist/lib/history-command.js.map +1 -0
- package/dist/lib/persona-files.d.ts.map +1 -1
- package/dist/lib/persona-files.js +4 -2
- package/dist/lib/persona-files.js.map +1 -1
- package/dist/lib/reset-space-plan.d.ts +3 -2
- package/dist/lib/reset-space-plan.d.ts.map +1 -1
- package/dist/lib/reset-space-plan.js +9 -7
- package/dist/lib/reset-space-plan.js.map +1 -1
- package/dist/lib/service-systemd-files.js +2 -2
- package/dist/lib/service-systemd-files.js.map +1 -1
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +15 -5
- package/dist/render.js.map +1 -1
- package/dist/watch-data.d.ts.map +1 -1
- package/dist/watch-data.js +2 -1
- package/dist/watch-data.js.map +1 -1
- package/package.json +4 -4
package/dist/commands/up.d.ts
CHANGED
|
@@ -211,7 +211,7 @@ export declare function prepareBrokerStart(opts: DetachOpts): Promise<{
|
|
|
211
211
|
setup: {
|
|
212
212
|
brokerBinary: NatsServer;
|
|
213
213
|
confPath: string;
|
|
214
|
-
|
|
214
|
+
mintProvisioner: () => Promise<string>;
|
|
215
215
|
wsPort: number;
|
|
216
216
|
moveWebsocketPort: () => Promise<number>;
|
|
217
217
|
prepared?: AuthPrepared;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../src/commands/up.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../src/commands/up.ts"],"names":[],"mappings":"AAsBA,OAAO,EAaL,KAAK,eAAe,EA+BpB,KAAK,YAAY,EAEjB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAsEL,KAAK,SAAS,EAyBd,KAAK,eAAe,EAwCrB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAqD,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAcxG,OAAO,EAA4C,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAa3G,OAAO,EAYL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAEnB,MAAM,eAAe,CAAC;AAuBvB,OAAO,EAsBL,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAC;AAS3B;;8FAE8F;AAC9F,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAC9B,SAAS,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;IACxC,eAAe,EAAE,SAAS,MAA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AED;;;;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,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA6C/M;AAuLD;;;;;;oGAMoG;AACpG,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsD3F;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;AAED;;;;;;;;;;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
|
@@ -2,13 +2,12 @@ import { noManagerCredentialWarning } from "../lib/daemon-credential-warning.js"
|
|
|
2
2
|
import { drainAndClose } from "@cotal-ai/core";
|
|
3
3
|
import {} from "node:child_process";
|
|
4
4
|
import { spawnBroker } from "../lib/broker-spawn.js";
|
|
5
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
6
5
|
import { randomUUID } from "node:crypto";
|
|
7
6
|
import { createConnection, createServer, isIP } from "node:net";
|
|
8
7
|
import { homedir, hostname } from "node:os";
|
|
9
8
|
import { accessSync, constants, mkdirSync, readFileSync, existsSync, statSync, closeSync, lstatSync, realpathSync, readdirSync, rmdirSync, } from "node:fs";
|
|
10
9
|
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
11
|
-
import { isReachable, dialerFor, DEFAULT_SERVER, DEFAULT_SPACE, SERVICE_AUTHORITY_MAX_BYTES, SERVICE_CALLER_PAYLOAD_FLOOR, CONTRACT_ARTIFACT_MAX_BYTES, MANAGER_START_PAYLOAD_FLOOR, createSpaceAuth, serverConfig, openServerConfig, validateTlsMaterial, credsProblem, mintCreds, mintLifecycleUid, DEV_OWNER, mintConnectionEvictorCreds, mintMembershipObserverCreds, newIdentity, setupSpaceStreams, removeIssuedStoresBeforeRetention, IssuedStoreBeforeRetentionError, IssuedStoreRecreateRefusal, reconcileSpaceMemoryBuckets, membershipStoreDefinition, LEGACY_MEMBERSHIP_MAX_BYTES, MEMBERSHIP_MAX_VALUE_SIZE, ttlBuckets, standaloneConnectOpts, requireBrokerFloor, parseServerVersion, presenceBucket, spaceDeletionStreams, isJetStreamMissing, seedChannelRegistry, ensureDefaultDeliveryClass, UndecodableRegistryEntry,
|
|
10
|
+
import { isReachable, dialerFor, DEFAULT_SERVER, DEFAULT_SPACE, SERVICE_AUTHORITY_MAX_BYTES, SERVICE_CALLER_PAYLOAD_FLOOR, CONTRACT_ARTIFACT_MAX_BYTES, MANAGER_START_PAYLOAD_FLOOR, createSpaceAuth, serverConfig, openServerConfig, validateTlsMaterial, credsProblem, mintCreds, mintLifecycleUid, DEV_OWNER, mintConnectionEvictorCreds, mintMembershipObserverCreds, newIdentity, setupSpaceStreams, removeIssuedStoresBeforeRetention, IssuedStoreBeforeRetentionError, IssuedStoreRecreateRefusal, reconcileSpaceMemoryBuckets, membershipStoreDefinition, LEGACY_MEMBERSHIP_MAX_BYTES, MEMBERSHIP_MAX_VALUE_SIZE, ttlBuckets, standaloneConnectOpts, requireBrokerFloor, parseServerVersion, presenceBucket, spaceDeletionStreams, isJetStreamMissing, seedChannelRegistry, ensureDefaultDeliveryClass, UndecodableRegistryEntry, LEASE_TTL_MS, EpEnvelopeError, mkSecretDir, openPrivateAppend, writeSecretFile, } from "@cotal-ai/core";
|
|
12
11
|
import { JetStreamApiCodes, jetstreamManager, StorageType } from "@nats-io/jetstream";
|
|
13
12
|
import { Kvm } from "@nats-io/kv";
|
|
14
13
|
import { assertManagerName, readManagerName, readManagerSeatCap, recordManagerName, recordManagerSeatCap, parseSeatCapFlag, seatCapText, CommandFailure, codeSpan, commandFailureReport, failureEnvelope, writeEnvelope, isCommandFailure, protectedLocalDirectory, jsonFlag, plainFlag, renderReport, assertSingleSpaceBroker, assertUserAuthInfo, authDir, brokerAddressForDisplay, brokerPolicyPath, getSoleSpaceAuth, soleSpaceOf, getSpaceAuth, hasUserAuthState, listSpaceAccounts, preloadSpaceAccounts, putSpaceAuth, brokerAddressKey, canonicalRoot, rootPathProblem, rootControlProblem, clearCurrent, findMesh, findPreparedSpace, homeCotalDir, legacyStackOtherHome, stackHomeRemedy, getCurrent, loadMeshes, preparedSpaceAt, removePreparedSpace, localMeshesForRoot, keepsRegistration, oneLine, presentationOf, writeResult, connectionEvictorCredsKey, membershipConfigPath, membershipObserverCredsKey, membershipRwCredsKey, MEMBERSHIP_CONFIG_KIND, MEMBERSHIP_RW_CREDS_KIND, WEB_CREDS_KIND, webCredsKey, parsePositiveIntegerFlag, recordMesh, retainedLegacyBroker, meshesForRoot, removeMesh, rotateSystemCreds, setAdoptedCurrent, staleSystemCreds, SYSTEM_CREDS_FILES, userAuthStateDir, userAuthSpacesOnDisk, workspaceSecretStore, acquireMaintenanceLock, assertStoreIdentity, assessMaintenanceClaim, assessRestoreClaim, beginOrdinaryResume, bindOrdinaryResumeListener, consumeRetiredMaintenance, markOrdinaryResumeActive, markOrdinaryResumeDegraded, replaceDeadOrdinaryResumeListener, localProcessOwnerStatus, readMaintenanceJournal, rootNamesNoSpace, readMaintenanceResumeDocument, readStoreIdentity, recordOrdinaryResumeManagerCommit, releaseMaintenanceLock, retireOrdinaryResume, settleTokenHandoff, sweepTokenHandoff, writeTokenHandoff, sameStoreIdentity, cutController, readBrokerPolicy, writeBrokerPolicy, brokerAccountResolver, removePidPair, writePidPair, verifyIdentityPin, processesNaming, isLoopbackHost, connectUserControlOrThrow, userViewAuth, recordOperationSpace, recordsElsewhereError, recordOperationWarning, retainSystemSigningSeed, restoreLeftOut, SPACE_NAME_MAX, spaceNameTooLong, NATS_PIDFILE, MANAGER_PIDFILE, DELIVERY_PIDFILE, AUTH_PIDFILE, localProcessPath, UNTRUSTED_CERTIFICATE, exitCode, canonicalLocalProcessPath, DELIVERY_LOGFILE, terminalWidth, } from "@cotal-ai/workspace";
|
|
@@ -19,6 +18,7 @@ import { c, hang, stderrLine } from "../ui.js";
|
|
|
19
18
|
import { admitAndRestoreSeatCheckpoints } from "../lib/seat-resume.js";
|
|
20
19
|
import { natsServerLabel, resolveNatsServer, unreadVersion } from "../lib/nats-bin.js";
|
|
21
20
|
import { cotalPath, cotalRoot, homeHoldsStack, linkedCotalRefusal } from "../lib/paths.js";
|
|
21
|
+
import { channelsReads, readChannelsFile, readDefaultChannelsFile } from "../lib/channel-seed.js";
|
|
22
22
|
import { detachedNext, renderDetachedSummary } from "../lib/up-report.js";
|
|
23
23
|
import { seedDefaultPersona } from "../lib/default-persona.js";
|
|
24
24
|
import { seedBeforeLaunch, seedMoveNote } from "../seed/launch.js";
|
|
@@ -2235,17 +2235,17 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
2235
2235
|
// Decided above the branch; the dial host is only settled here (a port collision may have moved
|
|
2236
2236
|
// the server, and the hostname is what the certificate has to match).
|
|
2237
2237
|
assertServesDialHost(transport, new URL(server).hostname);
|
|
2238
|
-
const
|
|
2239
|
-
const brokerMaxPayload =
|
|
2238
|
+
const brokerSetup = useAuth ? await authSetup(storeDir, server, space, host, wantUser ? { idpUrl: values.idp } : undefined, transport, values["rotate-sys"], maxFileStore, false, { authTimeout, maxPayload, accountResolver, manager: values["no-manager"] !== true }) : undefined;
|
|
2239
|
+
const brokerMaxPayload = brokerSetup?.maxPayload ?? maxPayload ?? readBrokerPolicy(cotalRoot())?.maxPayload;
|
|
2240
2240
|
const port = Number(new URL(server).port) || 4222;
|
|
2241
2241
|
// Both modes go through a RENDERER, never bare CLI flags. Open mode used to start from
|
|
2242
2242
|
// `-js -sd … -p … -a …`, which never called a renderer at all — so the required transport union
|
|
2243
2243
|
// protected the auth path and was silent on the open one, and a cert/key pair passed to an
|
|
2244
2244
|
// open-mode `up` would have been accepted while the listener came up in cleartext.
|
|
2245
|
-
const renderingBinary =
|
|
2245
|
+
const renderingBinary = brokerSetup?.brokerBinary ?? await resolveNatsServer();
|
|
2246
2246
|
if (!renderingBinary.version)
|
|
2247
2247
|
throw unreadVersion(renderingBinary);
|
|
2248
|
-
const confPath =
|
|
2248
|
+
const confPath = brokerSetup ? brokerSetup.confPath : writeOpenBrokerConf(storeDir, space, { brokerVersion: renderingBinary.version, port, host, transport, maxFileStore, maxPayload: brokerMaxPayload });
|
|
2249
2249
|
const natsArgs = [
|
|
2250
2250
|
"-c", confPath,
|
|
2251
2251
|
...(boundListener ? ["--name", boundListener.serverName] : []),
|
|
@@ -2253,6 +2253,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
2253
2253
|
const natsServer = renderingBinary;
|
|
2254
2254
|
const bin = natsServer.path;
|
|
2255
2255
|
await seedBeforeLaunch();
|
|
2256
|
+
const setup = brokerSetup && { ...brokerSetup, creds: await brokerSetup.mintProvisioner() };
|
|
2256
2257
|
const starting = `Starting ${natsServerLabel(natsServer)} (JetStream, ${useAuth ? "JWT auth" : "OPEN/no-auth"}) - store: ${storeDir}, bind: ${host}`;
|
|
2257
2258
|
for (const line of hang("", starting, terminalWidth(process.stdout), c.dim))
|
|
2258
2259
|
console.log(line);
|
|
@@ -3417,9 +3418,9 @@ export function controllerStackNative() {
|
|
|
3417
3418
|
return {
|
|
3418
3419
|
prepareBroker: async (opts) => {
|
|
3419
3420
|
const prepared = await prepareBrokerStart({ transport: opts.transport, server: opts.server, space: opts.space, ...(opts.open ? { open: true } : {}), ...(opts.userAuth ? { userAuth: opts.userAuth } : {}), ...(opts.host ? { host: opts.host } : {}), ...(opts.storeDir ? { storeDir: opts.storeDir } : {}), ...(opts.existingStore ? { existingStore: opts.existingStore } : {}), ...(opts.maxFileStore !== undefined ? { maxFileStore: opts.maxFileStore } : {}), ...(opts.logFile !== undefined ? { logFile: opts.logFile } : {}), ...(opts.logfileSizeLimit !== undefined ? { logfileSizeLimit: opts.logfileSizeLimit } : {}), ...(opts.logfileMaxNum !== undefined ? { logfileMaxNum: opts.logfileMaxNum } : {}), ...(opts.authTimeout !== undefined ? { authTimeout: opts.authTimeout } : {}), ...(opts.maxPayload !== undefined ? { maxPayload: opts.maxPayload } : {}), ...(opts.accountResolver !== undefined ? { accountResolver: opts.accountResolver } : {}), ...(opts.noManager ? { noManager: true } : {}), ...(opts.seed !== undefined ? { seed: opts.seed } : opts.channels ? { channels: opts.channels } : {}), quietBoot: true });
|
|
3420
|
-
return { root: prepared.root, server: prepared.server, space: prepared.space, storeDir: prepared.storeDir, transport: prepared.transport, ...(prepared.setup ? { setup: {
|
|
3421
|
+
return { root: prepared.root, server: prepared.server, space: prepared.space, storeDir: prepared.storeDir, transport: prepared.transport, ...(prepared.setup ? { setup: { mintProvisioner: prepared.setup.mintProvisioner, wsPort: prepared.setup.wsPort, moveWebsocketPort: prepared.setup.moveWebsocketPort } } : {}), ...(prepared.setup?.prepared && prepared.setup.stateDir ? { user: { prepared: prepared.setup.prepared, stateDir: prepared.setup.stateDir } } : {}), confPath: prepared.confPath, bin: prepared.bin, source: prepared.source, version: prepared.version, seedFile: prepared.seedFile, ...(prepared.setup?.authTimeout !== undefined ? { authTimeout: prepared.setup.authTimeout } : {}), ...(prepared.maxPayload !== undefined ? { maxPayload: prepared.maxPayload } : {}), ...(prepared.setup?.accountResolver !== undefined ? { accountResolver: prepared.setup.accountResolver } : {}) };
|
|
3421
3422
|
},
|
|
3422
|
-
initializeStreams: (server, space, setup, seedFile, recreateIssuedStores, recreateMembershipStore) => postStart(server, space, setup, seedFile, recreateIssuedStores, recreateMembershipStore, true),
|
|
3423
|
+
initializeStreams: async (server, space, setup, seedFile, recreateIssuedStores, recreateMembershipStore) => postStart(server, space, setup && { creds: await setup.mintProvisioner() }, seedFile, recreateIssuedStores, recreateMembershipStore, true),
|
|
3423
3424
|
recreateDeletedStreams: ({ seed, ...opts }) => recreateDeletedStreams({ ...opts, ...(seed !== undefined ? { seed: seed } : {}) }),
|
|
3424
3425
|
recordMesh: (entry) => recordOurMesh({ ...entry, ts: new Date().toISOString() }, "started", true),
|
|
3425
3426
|
commitTransport: (root, chosen, limits) => commitTransportPolicy(root, chosen, true, undefined, limits),
|
|
@@ -4116,8 +4117,9 @@ export async function startMeshDetached(
|
|
|
4116
4117
|
// The `= {}` default is gone with the optional transport: an options object that can be omitted
|
|
4117
4118
|
// entirely cannot carry a mandatory decision.
|
|
4118
4119
|
opts) {
|
|
4119
|
-
const { server, space, useAuth, storeDir, seedFile, transport, setup, maxPayload, args, bin, source, version } = await prepareBrokerStart(opts);
|
|
4120
|
+
const { server, space, useAuth, storeDir, seedFile, transport, setup: brokerSetup, maxPayload, args, bin, source, version } = await prepareBrokerStart(opts);
|
|
4120
4121
|
await seedBeforeLaunch();
|
|
4122
|
+
const setup = brokerSetup && { ...brokerSetup, creds: await brokerSetup.mintProvisioner() };
|
|
4121
4123
|
const logPath = cotalPath("nats.log");
|
|
4122
4124
|
const fd = openBrokerLog(logPath);
|
|
4123
4125
|
const listenerStartedAt = new Date().toISOString();
|
|
@@ -4477,7 +4479,7 @@ function recordOurMesh(m, provenance, quietBoot = false) {
|
|
|
4477
4479
|
}
|
|
4478
4480
|
const nativeHost = nativeMembers.length ? knownStackRecoveryHost() : undefined;
|
|
4479
4481
|
const recorded = { ...m, origin, ...(nativeHost !== undefined ? { nativeMembers, nativeHost } : {}) };
|
|
4480
|
-
recordMesh(provenance === "refresh" ? { ...prior, ...recorded } : recorded);
|
|
4482
|
+
recordMesh(provenance === "refresh" ? { ...prior, ...recorded, stoppedByDown: undefined } : recorded);
|
|
4481
4483
|
removePreparedSpace(m.space); // started: the registration is its record now
|
|
4482
4484
|
if (!usableCurrent) {
|
|
4483
4485
|
setAdoptedCurrent(m.space);
|
|
@@ -5016,10 +5018,7 @@ function authTimeoutArgs(seconds) {
|
|
|
5016
5018
|
function loadChannelsFile(explicit) {
|
|
5017
5019
|
if (explicit)
|
|
5018
5020
|
return readChannelsFile(resolve(explicit));
|
|
5019
|
-
|
|
5020
|
-
if (!existsSync(path))
|
|
5021
|
-
return undefined;
|
|
5022
|
-
return readChannelsFile(path, false);
|
|
5021
|
+
return readDefaultChannelsFile(cotalRoot());
|
|
5023
5022
|
}
|
|
5024
5023
|
/** Refuse `up --space` of a space this machine started from another folder while its broker answers,
|
|
5025
5024
|
* naming that folder: the stack there is the one to use or stop. */
|
|
@@ -5050,98 +5049,6 @@ async function refuseRecordsElsewhere(root) {
|
|
|
5050
5049
|
remedy: takeover ? `${records.stackRemedy}; or, to run it from this folder, take the name over with \`cotal up --space ${space}\`` : records.stackRemedy,
|
|
5051
5050
|
});
|
|
5052
5051
|
}
|
|
5053
|
-
/** The channels files one `up` has read, by path. It reads its seed when it checks the flags, when it
|
|
5054
|
-
* prepares the broker and when it seeds the registry, and `--channels` may name a pipe or a FIFO,
|
|
5055
|
-
* which a second open finds empty or waits on for a writer that is gone. */
|
|
5056
|
-
const channelsReads = new AsyncLocalStorage();
|
|
5057
|
-
/** Read, parse and check a channels file: `explicit` is a `--channels` path, else the root's default
|
|
5058
|
-
* `.cotal/channels.json`. A `--channels` path that is missing, unreadable or not JSON is a usage
|
|
5059
|
-
* refusal. A default file that is not JSON, and either file whose content the registry would not
|
|
5060
|
-
* take, is a schema refusal. Each names the file. */
|
|
5061
|
-
function readChannelsFile(path, explicit = true) {
|
|
5062
|
-
const read = channelsReads.getStore()?.get(path);
|
|
5063
|
-
if (read)
|
|
5064
|
-
return read;
|
|
5065
|
-
const remedy = explicit ? "fix the file, or omit --channels" : `fix or remove ${path}`;
|
|
5066
|
-
let text;
|
|
5067
|
-
// A default file that is a FIFO or a device would block the read with no writer, so only a regular
|
|
5068
|
-
// default file is opened. An explicit path may name a pipe such as `<(…)`, read once (see `channelsReads`).
|
|
5069
|
-
if (!explicit && statSync(path, { throwIfNoEntry: false })?.isFile() === false)
|
|
5070
|
-
throw new CommandFailure("refused", "USAGE_INVALID", `the channels file ${path} is not a regular file, such as a FIFO; it was not read`, { remedy });
|
|
5071
|
-
try {
|
|
5072
|
-
text = readFileSync(path, "utf8");
|
|
5073
|
-
}
|
|
5074
|
-
catch {
|
|
5075
|
-
throw new CommandFailure("refused", "USAGE_INVALID", `the channels file ${path} is missing or unreadable`, { remedy: explicit ? "name an existing channels file with --channels <path>, or omit --channels" : remedy });
|
|
5076
|
-
}
|
|
5077
|
-
const encoding = utf16Problem(text);
|
|
5078
|
-
if (encoding)
|
|
5079
|
-
throw new CommandFailure("refused", "USAGE_INVALID", `the channels file ${path} cannot be read: ${encoding}`, { remedy: `save ${path} as UTF-8` });
|
|
5080
|
-
let value;
|
|
5081
|
-
// An editor on Windows can begin the file with a UTF-8 byte-order mark, which RFC 8259 lets a
|
|
5082
|
-
// reader ignore.
|
|
5083
|
-
try {
|
|
5084
|
-
value = JSON.parse(text.replace(/^\uFEFF/, ""));
|
|
5085
|
-
}
|
|
5086
|
-
catch (error) {
|
|
5087
|
-
throw new CommandFailure("refused", "USAGE_INVALID", `the channels file ${path} is not valid JSON (${error.message})`, { remedy });
|
|
5088
|
-
}
|
|
5089
|
-
const problem = channelsFileProblem(value);
|
|
5090
|
-
if (problem)
|
|
5091
|
-
throw new CommandFailure("refused", "SCHEMA_INVALID", `the channels file ${path} is invalid: ${problem}`, { remedy });
|
|
5092
|
-
channelsReads.getStore()?.set(path, value);
|
|
5093
|
-
return value;
|
|
5094
|
-
}
|
|
5095
|
-
const CHANNEL_DEFAULT_FIELDS = { replay: true, replayWindow: true, deliveryClass: true };
|
|
5096
|
-
const CHANNEL_FIELDS = { ...CHANNEL_DEFAULT_FIELDS, description: true, instructions: true };
|
|
5097
|
-
/** Why the registry would not take this seed: the shape, an unknown key, a channel name `channel set`
|
|
5098
|
-
* refuses, or a field value the registry's write checks refuse. Undefined when every entry passes. */
|
|
5099
|
-
function channelsFileProblem(value) {
|
|
5100
|
-
const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
5101
|
-
const fieldsProblem = (where, entry, fields, check) => {
|
|
5102
|
-
if (!isObject(entry))
|
|
5103
|
-
return `${where} must be an object`;
|
|
5104
|
-
for (const [field, fieldValue] of Object.entries(entry)) {
|
|
5105
|
-
if (!Object.hasOwn(fields, field))
|
|
5106
|
-
return `${where} has an unknown key ${JSON.stringify(field)}; it takes ${Object.keys(fields).join(", ")}`;
|
|
5107
|
-
try {
|
|
5108
|
-
check({ [field]: fieldValue });
|
|
5109
|
-
}
|
|
5110
|
-
catch (error) {
|
|
5111
|
-
return `${where} ${field}: ${error.message}`;
|
|
5112
|
-
}
|
|
5113
|
-
}
|
|
5114
|
-
return undefined;
|
|
5115
|
-
};
|
|
5116
|
-
if (!isObject(value))
|
|
5117
|
-
return 'it must be a JSON object with "defaults" and "channels"';
|
|
5118
|
-
for (const key of Object.keys(value))
|
|
5119
|
-
if (key !== "defaults" && key !== "channels")
|
|
5120
|
-
return `unknown key ${JSON.stringify(key)}; the file takes "defaults" and "channels"`;
|
|
5121
|
-
if (value.defaults !== undefined) {
|
|
5122
|
-
const problem = fieldsProblem('"defaults"', value.defaults, CHANNEL_DEFAULT_FIELDS, validateChannelDefaults);
|
|
5123
|
-
if (problem)
|
|
5124
|
-
return problem;
|
|
5125
|
-
}
|
|
5126
|
-
if (value.channels === undefined)
|
|
5127
|
-
return undefined;
|
|
5128
|
-
if (!isObject(value.channels))
|
|
5129
|
-
return '"channels" must be an object of channel names';
|
|
5130
|
-
for (const [name, config] of Object.entries(value.channels)) {
|
|
5131
|
-
try {
|
|
5132
|
-
assertValidChannel(name);
|
|
5133
|
-
}
|
|
5134
|
-
catch (error) {
|
|
5135
|
-
return error.message;
|
|
5136
|
-
}
|
|
5137
|
-
if (!isConcreteChannel(name))
|
|
5138
|
-
return `channel ${JSON.stringify(name)} is a wildcard; name one concrete channel`;
|
|
5139
|
-
const problem = fieldsProblem(`channel ${JSON.stringify(name)}`, config, CHANNEL_FIELDS, validateChannelConfig);
|
|
5140
|
-
if (problem)
|
|
5141
|
-
return problem;
|
|
5142
|
-
}
|
|
5143
|
-
return undefined;
|
|
5144
|
-
}
|
|
5145
5052
|
/**
|
|
5146
5053
|
* Turn the `--tls-cert`/`--tls-key` pair into a validated {@link BrokerTransport}, or `plaintext`
|
|
5147
5054
|
* when neither was given.
|
|
@@ -5452,8 +5359,8 @@ function unreadableTrust(error) {
|
|
|
5452
5359
|
target: { path }, remedy: `make it readable by you again, as chmod 600 ${shellWord(path)} does, then run \`cotal up\` again; it holds the space's keys, so keep it`,
|
|
5453
5360
|
});
|
|
5454
5361
|
}
|
|
5455
|
-
/** Ensure the space's trust material exists
|
|
5456
|
-
* setup
|
|
5362
|
+
/** Ensure the space's trust material exists and render a server config. The caller can mint
|
|
5363
|
+
* the setup credential after connector reconciliation. The account signing key
|
|
5457
5364
|
* in `.cotal/auth` is what `cotal mint` and the manager later use to issue per-agent creds.
|
|
5458
5365
|
*
|
|
5459
5366
|
* USER MODE (`user` set): additionally run the registered auth provider's `prepareServer` over the
|
|
@@ -5617,11 +5524,10 @@ requested = {}) {
|
|
|
5617
5524
|
// takes it first, the broker exits before readiness, and a controller stack start renders this
|
|
5618
5525
|
// configuration again on a newly chosen port.
|
|
5619
5526
|
const moveWebsocketPort = async () => { const moved = await freePort(host); render(moved); return moved; };
|
|
5620
|
-
//
|
|
5621
|
-
//
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
return { brokerBinary, confPath, creds, wsPort, moveWebsocketPort, ...(prepared ? { prepared, stateDir } : {}), ...(authTimeout !== undefined ? { authTimeout } : {}), ...(maxPayload !== undefined ? { maxPayload } : {}), accountResolver: resolverChoice };
|
|
5527
|
+
// Connector reconciliation can outlast the provisioner's lifetime. Mint only when boot needs it
|
|
5528
|
+
// to probe the listener, create streams and buckets, or seed the channel registry.
|
|
5529
|
+
const mintProvisioner = () => mintCreds(auth, newIdentity(), "provisioner");
|
|
5530
|
+
return { brokerBinary, confPath, mintProvisioner, wsPort, moveWebsocketPort, ...(prepared ? { prepared, stateDir } : {}), ...(authTimeout !== undefined ? { authTimeout } : {}), ...(maxPayload !== undefined ? { maxPayload } : {}), accountResolver: resolverChoice };
|
|
5625
5531
|
}
|
|
5626
5532
|
/**
|
|
5627
5533
|
* Refuse the rotation if this root's own bookkeeping still shows a broker running. This is a
|