@cotal-ai/cli 0.116.2 → 0.116.4
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/native-session.js +3 -2
- package/dist/chat/native-session.js.map +1 -1
- package/dist/chat/static-session.js +1 -1
- package/dist/chat/static-session.js.map +1 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +19 -19
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/backup-maintenance.js +8 -8
- package/dist/commands/backup-maintenance.js.map +1 -1
- package/dist/commands/backup-restore.js +1 -1
- package/dist/commands/backup-restore.js.map +1 -1
- package/dist/commands/backup.js +11 -11
- package/dist/commands/backup.js.map +1 -1
- package/dist/commands/channels.js +4 -4
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/chat.js +5 -5
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +12 -12
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +5 -5
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/describe.js +2 -2
- package/dist/commands/describe.js.map +1 -1
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/down-live-lease.js +1 -1
- package/dist/commands/down-live-lease.js.map +1 -1
- package/dist/commands/down-manifest.js +1 -1
- package/dist/commands/down-manifest.js.map +1 -1
- package/dist/commands/down-services.js +8 -8
- package/dist/commands/down-services.js.map +1 -1
- package/dist/commands/down.js +8 -8
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/endpoint.js +1 -1
- package/dist/commands/endpoint.js.map +1 -1
- package/dist/commands/history-clear.js +1 -1
- package/dist/commands/history-clear.js.map +1 -1
- package/dist/commands/history.js +1 -1
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/join.js +1 -1
- package/dist/commands/join.js.map +1 -1
- package/dist/commands/mint.js +3 -3
- package/dist/commands/mint.js.map +1 -1
- package/dist/commands/persona-remote.js +1 -1
- package/dist/commands/persona-remote.js.map +1 -1
- package/dist/commands/persona.js +4 -4
- package/dist/commands/persona.js.map +1 -1
- package/dist/commands/personas.js +2 -2
- package/dist/commands/personas.js.map +1 -1
- package/dist/commands/reset-space-apply.js +5 -5
- package/dist/commands/reset-space-apply.js.map +1 -1
- package/dist/commands/reset-store-apply.js +21 -21
- package/dist/commands/reset-store-apply.js.map +1 -1
- package/dist/commands/revoke-credential.js +5 -5
- package/dist/commands/revoke-credential.js.map +1 -1
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +7 -7
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/service-actions.js +9 -9
- package/dist/commands/service-actions.js.map +1 -1
- package/dist/commands/service-log-follow.js +1 -1
- package/dist/commands/service-log-follow.js.map +1 -1
- package/dist/commands/service-registry.js +19 -19
- package/dist/commands/service-registry.js.map +1 -1
- package/dist/commands/service-set-stop.js +3 -3
- package/dist/commands/service-set-stop.js.map +1 -1
- package/dist/commands/space-delete.js +10 -10
- package/dist/commands/space-delete.js.map +1 -1
- package/dist/commands/spawn-preview.js +1 -1
- package/dist/commands/spawn-preview.js.map +1 -1
- package/dist/commands/spawn.d.ts +1 -1
- package/dist/commands/spawn.js +19 -19
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/stack-down.js +12 -12
- package/dist/commands/stack-down.js.map +1 -1
- package/dist/commands/stack-gone.js +7 -7
- package/dist/commands/stack-gone.js.map +1 -1
- package/dist/commands/stack-up.d.ts.map +1 -1
- package/dist/commands/stack-up.js +44 -44
- package/dist/commands/stack-up.js.map +1 -1
- package/dist/commands/stack-user-auth.d.ts.map +1 -1
- package/dist/commands/stack-user-auth.js +2 -2
- package/dist/commands/stack-user-auth.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +14 -14
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/team-agent-remove.js +2 -2
- package/dist/commands/team-agent-remove.js.map +1 -1
- package/dist/commands/team-boot-controller.js +5 -5
- package/dist/commands/team-boot-controller.js.map +1 -1
- package/dist/commands/team-channel-remove.js +4 -4
- package/dist/commands/team-channel-remove.js.map +1 -1
- package/dist/commands/team-deploy-apply.js +1 -1
- package/dist/commands/team-deploy-apply.js.map +1 -1
- package/dist/commands/team-mixed-remove.js +2 -2
- package/dist/commands/team-mixed-remove.js.map +1 -1
- package/dist/commands/team.js +7 -7
- package/dist/commands/team.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +51 -51
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/update.js +2 -2
- package/dist/commands/update.js.map +1 -1
- package/dist/console/launch.js +1 -1
- package/dist/console/launch.js.map +1 -1
- package/dist/exec-endpoint/service-adapter.js +1 -1
- package/dist/exec-endpoint/service-adapter.js.map +1 -1
- package/dist/ext-loader.js +2 -2
- package/dist/ext-loader.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-skills.js +3 -3
- package/dist/lib/agent-skills.js.map +1 -1
- package/dist/lib/backup-artifact.js +1 -1
- package/dist/lib/backup-artifact.js.map +1 -1
- package/dist/lib/broker-service.js +1 -1
- package/dist/lib/broker-service.js.map +1 -1
- package/dist/lib/broker-store-health.js +1 -1
- package/dist/lib/broker-store-health.js.map +1 -1
- package/dist/lib/completion-install.js +7 -7
- package/dist/lib/completion-install.js.map +1 -1
- package/dist/lib/control.js +3 -3
- package/dist/lib/control.js.map +1 -1
- package/dist/lib/controller-preserve.js +5 -5
- package/dist/lib/controller-preserve.js.map +1 -1
- package/dist/lib/controller-resume.js +3 -3
- package/dist/lib/controller-resume.js.map +1 -1
- package/dist/lib/delivery-responder.js +1 -1
- package/dist/lib/delivery-responder.js.map +1 -1
- package/dist/lib/endpoint-capability-gates.js +1 -1
- package/dist/lib/endpoint-capability-gates.js.map +1 -1
- package/dist/lib/endpoint-errors.d.ts.map +1 -1
- package/dist/lib/endpoint-errors.js +3 -3
- package/dist/lib/endpoint-errors.js.map +1 -1
- package/dist/lib/held-name.js +3 -3
- package/dist/lib/held-name.js.map +1 -1
- package/dist/lib/interrupt-notice.js +1 -1
- package/dist/lib/interrupt-notice.js.map +1 -1
- package/dist/lib/manager-choice.js +2 -2
- package/dist/lib/manager-choice.js.map +1 -1
- package/dist/lib/manifest/render.js +1 -1
- package/dist/lib/manifest/render.js.map +1 -1
- package/dist/lib/paths.js +5 -5
- package/dist/lib/paths.js.map +1 -1
- package/dist/lib/persona-files.js +3 -3
- package/dist/lib/persona-files.js.map +1 -1
- package/dist/lib/personas.js +1 -1
- package/dist/lib/personas.js.map +1 -1
- package/dist/lib/reset-space-plan.js +1 -1
- package/dist/lib/reset-space-plan.js.map +1 -1
- package/dist/lib/restore.d.ts.map +1 -1
- package/dist/lib/restore.js +20 -20
- package/dist/lib/restore.js.map +1 -1
- package/dist/lib/service-adapters.js +1 -1
- package/dist/lib/service-adapters.js.map +1 -1
- package/dist/lib/service-definitions.js +4 -4
- package/dist/lib/service-definitions.js.map +1 -1
- package/dist/lib/service-preset-target.js +7 -7
- package/dist/lib/service-preset-target.js.map +1 -1
- package/dist/lib/service-presets.js +2 -2
- package/dist/lib/service-presets.js.map +1 -1
- package/dist/lib/service-process.d.ts.map +1 -1
- package/dist/lib/service-process.js +18 -16
- package/dist/lib/service-process.js.map +1 -1
- package/dist/lib/stack-journal.d.ts.map +1 -1
- package/dist/lib/stack-journal.js +16 -16
- package/dist/lib/stack-journal.js.map +1 -1
- package/dist/lib/stack-resume.js +5 -5
- package/dist/lib/stack-resume.js.map +1 -1
- package/dist/lib/steps.js +1 -1
- package/dist/lib/steps.js.map +1 -1
- package/dist/lib/store-dir.d.ts +2 -1
- package/dist/lib/store-dir.d.ts.map +1 -1
- package/dist/lib/store-dir.js +5 -4
- package/dist/lib/store-dir.js.map +1 -1
- package/dist/lib/systemd-supervision.js +1 -1
- package/dist/lib/systemd-supervision.js.map +1 -1
- package/dist/lib/teardown-spare.js +1 -1
- package/dist/lib/teardown-spare.js.map +1 -1
- package/dist/lib/transient.js +2 -2
- package/dist/lib/transient.js.map +1 -1
- package/dist/lib/up-report.js +2 -2
- package/dist/lib/up-report.js.map +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +1 -1
- package/dist/ui.js +2 -2
- package/dist/ui.js.map +1 -1
- package/dist/watch-data.js +1 -1
- package/dist/watch-data.js.map +1 -1
- package/package.json +4 -4
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, removeIssuedStoresBeforeRetention, IssuedStoreBeforeRetentionError, IssuedStoreRecreateRefusal, reconcileSpaceTtls, ttlBuckets, standaloneConnectOpts, requireBrokerFloor, parseServerVersion, presenceBucket, MEMBERSHIP_MAX_BYTES, spaceDeletionStreams, isJetStreamMissing, seedChannelRegistry, ensureDefaultDeliveryClass, UndecodableRegistryEntry, 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, brokerPolicyPath, 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, recordsElsewhereError, recordOperationWarning, retainSystemSigningSeed, restoreLeftOut, SPACE_NAME_MAX, spaceNameTooLong, MIN_FILE_STORE, NATS_PIDFILE, exitCode, } from "@cotal-ai/workspace";
|
|
11
|
+
import { assertManagerName, readManagerName, readManagerSeatCap, recordManagerName, recordManagerSeatCap, parseSeatCapFlag, seatCapText, assertRecordIdentity, formatRecord, identityRecord, parseRecord, CommandFailure, codeSpan, commandFailureReport, isCommandFailure, protectedLocalDirectory, jsonFlag, plainFlag, renderReport, terminalWidth, assertSingleSpaceBroker, assertUserAuthInfo, authDir, brokerAddressForDisplay, brokerPolicyPath, 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, recordsElsewhereError, recordOperationWarning, retainSystemSigningSeed, restoreLeftOut, SPACE_NAME_MAX, spaceNameTooLong, MIN_FILE_STORE, NATS_PIDFILE, 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";
|
|
@@ -73,7 +73,7 @@ export async function startRestore(values) {
|
|
|
73
73
|
await up({ values: { ...values }, positionals: [], raw: [] }, undefined, false, (result) => { returned = result; });
|
|
74
74
|
if (!returned) {
|
|
75
75
|
const root = cotalRoot(), held = heldRestoreAttempt(root);
|
|
76
|
-
throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the guarded restore returned without its activation result; the journal records its state and no step was repeated", { target: { root, ...(held ? { attemptId: held.attemptId, journalState: held.journalState } : {}) }, remedy: held?.remedy ?? "this root's maintenance journal names no restore attempt; check it with cotal status" });
|
|
76
|
+
throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the guarded restore returned without its activation result; the journal records its state and no step was repeated", { target: { root, ...(held ? { attemptId: held.attemptId, journalState: held.journalState } : {}) }, remedy: held?.remedy ?? "this root's maintenance journal names no restore attempt; check it with `cotal status`" });
|
|
77
77
|
}
|
|
78
78
|
return returned;
|
|
79
79
|
}
|
|
@@ -105,7 +105,7 @@ export const upFlags = [
|
|
|
105
105
|
{ name: "agent-provisioning-url", type: "string", value: "<https://…>", description: "with --exchange-public-port: the deployment's remote agent-provisioning endpoint the public bundle advertises" },
|
|
106
106
|
{ name: "rotate-sys", type: "boolean", description: "renew the expired/expiring $SYS creds by rotating the system account (agents, data and creds survive; needs a stopped mesh)" },
|
|
107
107
|
{ name: "recreate-issued-stores", type: "string", value: "<backup-dir>", description: "back up this space's issued-authority stores created before 0.111.0 into a new <backup-dir>, delete them and create them again (needs a stopped stack and every other issuer of the space stopped)" },
|
|
108
|
-
{ name: "detach", type: "boolean", short: "d", description: "run in the background (the default; stop with cotal down)" },
|
|
108
|
+
{ name: "detach", type: "boolean", short: "d", description: "run in the background (the default; stop with `cotal down`)" },
|
|
109
109
|
{ name: "foreground", type: "boolean", description: "keep a non-manifest native stack in this terminal; -f currently refuses" },
|
|
110
110
|
{ 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" },
|
|
111
111
|
{ 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" },
|
|
@@ -163,7 +163,7 @@ export function validateUpArguments(args) {
|
|
|
163
163
|
throw new CommandFailure("refused", "USAGE_INVALID", "choose --foreground or --detach, not both");
|
|
164
164
|
// Only a manifest launch has a plan to print; without -f every route would start the stack.
|
|
165
165
|
if (args.values["dry-run"] === true && !args.values.file)
|
|
166
|
-
throw new CommandFailure("refused", "USAGE_INVALID", "--dry-run previews a manifest launch and needs -f <cotal.yaml>; nothing was started or written", { remedy: "pass -f <cotal.yaml> to print that manifest's plan; cotal status shows what this folder records" });
|
|
166
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--dry-run previews a manifest launch and needs -f <cotal.yaml>; nothing was started or written", { remedy: "pass -f <cotal.yaml> to print that manifest's plan; `cotal status` shows what this folder records" });
|
|
167
167
|
// The stack passes its space to its own children as `--space <name>`, which a leading - breaks.
|
|
168
168
|
const named = typeof args.values.space === "string" ? checkSpaceFlagValue(args.values.space) : undefined;
|
|
169
169
|
if (named && !named.ok)
|
|
@@ -216,10 +216,10 @@ export function validateUpArguments(args) {
|
|
|
216
216
|
if (args.values.restore && (args.values.file !== undefined || args.values.channels !== undefined))
|
|
217
217
|
throw new CommandFailure("refused", "USAGE_INVALID", "--restore cannot be combined with --file/-f or --channels");
|
|
218
218
|
if (args.values.restore && args.values["rotate-sys"] === true)
|
|
219
|
-
throw new CommandFailure("refused", "USAGE_INVALID", "--restore cannot be combined with --rotate-sys", { remedy: "restore the space and verify it first, then rotate: cotal down
|
|
219
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--restore cannot be combined with --rotate-sys", { remedy: "restore the space and verify it first, then rotate: `cotal down`, then `cotal up --rotate-sys`" });
|
|
220
220
|
if (args.values["recreate-issued-stores"] !== undefined) {
|
|
221
221
|
if (args.values.file !== undefined || args.values.restore !== undefined)
|
|
222
|
-
throw new CommandFailure("refused", "USAGE_INVALID", `--recreate-issued-stores cannot be combined with ${args.values.file !== undefined ? "--file/-f" : "--restore"}; nothing was started`, { remedy: "run cotal up --space <space> --recreate-issued-stores <backup-dir
|
|
222
|
+
throw new CommandFailure("refused", "USAGE_INVALID", `--recreate-issued-stores cannot be combined with ${args.values.file !== undefined ? "--file/-f" : "--restore"}; nothing was started`, { remedy: "run `cotal up --space <space> --recreate-issued-stores <backup-dir>` on its own first" });
|
|
223
223
|
assertIssuedBackupDirArgument(String(args.values["recreate-issued-stores"]));
|
|
224
224
|
}
|
|
225
225
|
if (args.values.root !== undefined)
|
|
@@ -228,12 +228,12 @@ export function validateUpArguments(args) {
|
|
|
228
228
|
const inheritedRoot = inheritedMachineHomeRoot();
|
|
229
229
|
if (inheritedRoot) {
|
|
230
230
|
if (!freshFolderRoot(args.values))
|
|
231
|
-
throw new CommandFailure("refused", "CONFLICT", "this folder inherits the machine's home .cotal; up did not start a stack in that home root", { target: { root: process.cwd(), inheritedRoot }, remedy: "prepare this folder with cotal space create <space> --root
|
|
231
|
+
throw new CommandFailure("refused", "CONFLICT", "this folder inherits the machine's home .cotal; up did not start a stack in that home root", { target: { root: process.cwd(), inheritedRoot }, remedy: "prepare this folder with `cotal space create <space> --root .`, then run `cotal up` again from this folder" });
|
|
232
232
|
}
|
|
233
233
|
else {
|
|
234
234
|
const home = machineHomeRoot();
|
|
235
235
|
if (home && !homeHoldsStack(home))
|
|
236
|
-
throw new CommandFailure("refused", "CONFLICT", `${home} is your home folder, whose .cotal holds this machine's own records, so up started no stack there`, { target: { root: home }, remedy: "prepare a project folder with cotal space create <space> --root <dir
|
|
236
|
+
throw new CommandFailure("refused", "CONFLICT", `${home} is your home folder, whose .cotal holds this machine's own records, so up started no stack there`, { target: { root: home }, remedy: "prepare a project folder with `cotal space create <space> --root <dir>`, then run `cotal up` there, or pass --root <dir> from here" });
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
if (args.values.restore !== undefined)
|
|
@@ -243,12 +243,12 @@ export function validateUpArguments(args) {
|
|
|
243
243
|
// A path with a control character or a bidirectional formatting mark is refused before any write.
|
|
244
244
|
const pathProblem = rootPathProblem(root) ?? rootPathProblem(canonicalRoot(root));
|
|
245
245
|
if (pathProblem)
|
|
246
|
-
throw new CommandFailure("refused", "USAGE_INVALID", `${pathProblem}; nothing was started or written`, { target: { root }, remedy: "rename the folder without those characters, then run cotal up there" });
|
|
246
|
+
throw new CommandFailure("refused", "USAGE_INVALID", `${pathProblem}; nothing was started or written`, { target: { root }, remedy: "rename the folder without those characters, then run `cotal up` there" });
|
|
247
247
|
const control = rootControlProblem(root);
|
|
248
248
|
if (control)
|
|
249
249
|
throw new CommandFailure("refused", "CONFLICT", `${control.message}; nothing was started or written`, { target: { root, controlDirectory: control.controlDirectory }, remedy: control.project === undefined
|
|
250
|
-
? "prepare a project folder with cotal space create <space> --root <dir
|
|
251
|
-
: `run cotal up from the project folder ${shellWord(control.project)}` });
|
|
250
|
+
? "prepare a project folder with `cotal space create <space> --root <dir>`, then run `cotal up` there"
|
|
251
|
+
: `run \`cotal up\` from the project folder ${shellWord(control.project)}` });
|
|
252
252
|
assertUpRootWritable(root);
|
|
253
253
|
// A restore and a manifest name their own store.
|
|
254
254
|
if (args.values.restore === undefined && args.values.file === undefined)
|
|
@@ -388,11 +388,11 @@ function folderNamedSpace(values) {
|
|
|
388
388
|
const checked = checkSpaceName(space);
|
|
389
389
|
const invalid = spaceNameTooLong(space) ?? (checked.ok ? undefined : checked.message.replace(/^✗ /, ""));
|
|
390
390
|
if (invalid)
|
|
391
|
-
throw new CommandFailure("refused", "USAGE_INVALID", `${named} the folder name ${JSON.stringify(space)} cannot be one: ${invalid}; nothing was started or written`, { target: { root }, remedy: "name the space with cotal up --space <name
|
|
391
|
+
throw new CommandFailure("refused", "USAGE_INVALID", `${named} the folder name ${JSON.stringify(space)} cannot be one: ${invalid}; nothing was started or written`, { target: { root }, remedy: "name the space with `cotal up --space <name>`", selfContained: true });
|
|
392
392
|
assertSelectionNotMoved(root, space);
|
|
393
393
|
const held = findMesh(space) ?? findPreparedSpace(space);
|
|
394
394
|
if (held)
|
|
395
|
-
throw new CommandFailure("refused", "CONFLICT", `${named} "${space}" is already ${"server" in held ? `registered at ${held.server}` : "prepared"} for ${held.root}; nothing was started or written`, { target: { root, space, heldBy: held.root }, remedy: "name this folder's space with cotal up --space <name
|
|
395
|
+
throw new CommandFailure("refused", "CONFLICT", `${named} "${space}" is already ${"server" in held ? `registered at ${held.server}` : "prepared"} for ${held.root}; nothing was started or written`, { target: { root, space, heldBy: held.root }, remedy: "name this folder's space with `cotal up --space <name>`, naming one this machine does not use; `cotal space` lists the names in use" });
|
|
396
396
|
checkLocalSpace(space, root, "--root", false);
|
|
397
397
|
return space;
|
|
398
398
|
}
|
|
@@ -443,10 +443,10 @@ export function preparedUpRoot(value) {
|
|
|
443
443
|
throw new Error("not a private project directory");
|
|
444
444
|
}
|
|
445
445
|
catch {
|
|
446
|
-
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "--root must name an existing prepared local project with its own .cotal directory; no ancestor or other space was selected", { target: { root: resolve(value) }, remedy: "prepare it with cotal space create <space> --root <dir
|
|
446
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "--root must name an existing prepared local project with its own .cotal directory; no ancestor or other space was selected", { target: { root: resolve(value) }, remedy: "prepare it with `cotal space create <space> --root <dir>`, then retry with that root" });
|
|
447
447
|
}
|
|
448
448
|
if (canonicalRoot(root) === canonicalRoot(homedir()) || canonicalRoot(join(root, ".cotal")) === canonicalRoot(homeCotalDir()))
|
|
449
|
-
throw new CommandFailure("refused", "CONFLICT", "--root names the machine's home store, not a prepared project; no stack was started there", { target: { root }, remedy: "prepare the space in a project folder with cotal space create <space> --root <dir
|
|
449
|
+
throw new CommandFailure("refused", "CONFLICT", "--root names the machine's home store, not a prepared project; no stack was started there", { target: { root }, remedy: "prepare the space in a project folder with `cotal space create <space> --root <dir>`" });
|
|
450
450
|
return root;
|
|
451
451
|
}
|
|
452
452
|
/** The fresh team entry refuses retained custody before `up -f` can write a launch spec,
|
|
@@ -778,9 +778,9 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
778
778
|
if (freshTeamBoot && (!values.file || values.restore || values.__restoreAttempt || values.__ordinaryResumeAttempt || values["rotate-sys"] || values["no-manager"]))
|
|
779
779
|
throw new CommandFailure("refused", "USAGE_INVALID", "fresh team boot accepts one manifest and its selected lifetime, not a restore, rotation or manager-free override");
|
|
780
780
|
if (values["manager-name"] !== undefined && (values.restore || values.file || values["no-manager"]))
|
|
781
|
-
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");
|
|
781
|
+
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");
|
|
782
782
|
if (values["seat-cap"] !== undefined && (values.restore || values.file || values["no-manager"]))
|
|
783
|
-
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");
|
|
783
|
+
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");
|
|
784
784
|
// `space create` and `down` refuse a root other local accounts can write, so `up` refuses it too,
|
|
785
785
|
// before anything is written: a stack started there could not be stopped from it.
|
|
786
786
|
protectedLocalDirectory(canonicalRoot(cotalRoot()), "the project root");
|
|
@@ -880,7 +880,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
880
880
|
if (values["rotate-sys"] && readMaintenanceJournal(root))
|
|
881
881
|
throw new Error("--rotate-sys is refused while this root has a maintenance attempt to recover - finish or roll back that attempt (`cotal up` alone recovers it), then `cotal down` and `cotal up --rotate-sys`");
|
|
882
882
|
if (values["recreate-issued-stores"] !== undefined && readMaintenanceJournal(root))
|
|
883
|
-
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "--recreate-issued-stores needs a fresh broker start, and this root has a maintenance attempt to recover; nothing was started", { target: { root }, remedy: "finish or roll back that attempt first (cotal up alone recovers it)" });
|
|
883
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "--recreate-issued-stores needs a fresh broker start, and this root has a maintenance attempt to recover; nothing was started", { target: { root }, remedy: "finish or roll back that attempt first (`cotal up` alone recovers it)" });
|
|
884
884
|
// Raised here for the stronger reason the journal itself carries: a pending maintenance attempt
|
|
885
885
|
// means the store is mid-recovery, and a broker-only boot over it is wrong with or without the
|
|
886
886
|
// manager half. The manager half is why the FLAG specifically cannot apply. A settled active
|
|
@@ -933,7 +933,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
933
933
|
const assessment = assessRestoreClaim(journal, { unrecordedOwnersDead: attemptProcessesGone(root) });
|
|
934
934
|
if (assessment !== "stale")
|
|
935
935
|
throw heldClaim(root, attempt, journal.claim, "cotal up", assessment);
|
|
936
|
-
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", `cotal up is refused: restore attempt ${attempt} stopped before it committed and still holds the store; nothing was changed`, { target: { root, attemptId: attempt }, remedy: `roll it back with cotal backup recover ${attempt} --yes
|
|
936
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", `cotal up is refused: restore attempt ${attempt} stopped before it committed and still holds the store; nothing was changed`, { target: { root, attemptId: attempt }, remedy: `roll it back with \`cotal backup recover ${attempt} --yes\`, then run \`cotal up\`; or run the restore again` });
|
|
937
937
|
}
|
|
938
938
|
const controllerCut = journal ? cutController(journal.cut) : undefined;
|
|
939
939
|
if (journal && controllerCut && journal.state !== "cut-intent" && journal.state !== "cut-committed" && journal.state !== "resume-retired") {
|
|
@@ -972,9 +972,9 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
972
972
|
else if (journal?.state === "ready") {
|
|
973
973
|
const source = preservedSourceState(root, journal.source);
|
|
974
974
|
if (source.state === "moved")
|
|
975
|
-
throw movedFolderRefusal(root, journal.space, journal.source.path, source, "run cotal up");
|
|
975
|
+
throw movedFolderRefusal(root, journal.space, journal.source.path, source, "run `cotal up`");
|
|
976
976
|
if (source.state === "missing")
|
|
977
|
-
throw new CommandFailure("refused", "TARGET_NOT_FOUND", `the preserved store recorded at ${journal.source.path} is missing, so up cannot resume it; nothing was started`, { target: { root, space: journal.space, recordedStore: journal.source.path }, remedy: "if this folder was moved, move it back so that path exists again; if the store is lost, restore a backup here with cotal backup restore <dir> --accept-missing-source" });
|
|
977
|
+
throw new CommandFailure("refused", "TARGET_NOT_FOUND", `the preserved store recorded at ${journal.source.path} is missing, so up cannot resume it; nothing was started`, { target: { root, space: journal.space, recordedStore: journal.source.path }, remedy: "if this folder was moved, move it back so that path exists again; if the store is lost, restore a backup here with `cotal backup restore <dir> --accept-missing-source`" });
|
|
978
978
|
const resume = readMaintenanceResumeDocument(root, journal.resume);
|
|
979
979
|
const attemptId = `resume-${randomUUID()}`;
|
|
980
980
|
const launch = resume.launch;
|
|
@@ -987,7 +987,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
987
987
|
// follows a normal `down` of the resumed mesh.
|
|
988
988
|
const preservedOnly = (flag, given, what, preserved) => new CommandFailure("refused", "CONFLICT", `${flag} ${given} is not the ${what} that down --preserve-state recorded here (${preserved}), and a resume starts what it recorded; nothing was started`, {
|
|
989
989
|
target: { root, space: journal.space, flag, given: String(given), preserved },
|
|
990
|
-
remedy: `resume with cotal up without ${flag}; to use ${given}, stop the resumed mesh with cotal down
|
|
990
|
+
remedy: `resume with \`cotal up\` without ${flag}; to use ${given}, stop the resumed mesh with \`cotal down\`, then run \`cotal up ${flag} ${given}\``,
|
|
991
991
|
});
|
|
992
992
|
if (values.server !== undefined && values.server !== resumeServer)
|
|
993
993
|
throw preservedOnly("--server", values.server, "broker address", resumeServer);
|
|
@@ -1028,7 +1028,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1028
1028
|
// The resumed broker binds this address, so another listener there would leave the resume
|
|
1029
1029
|
// degraded. It is refused here, before anything is journalled or started, as backup create does.
|
|
1030
1030
|
await assertEndpointUnreachable(resumeServer).catch((error) => {
|
|
1031
|
-
throw new CommandFailure("refused", "CONFLICT", `${error.message}; the resumed broker needs that address, so nothing was started`, { target: { root, space: journal.space, server: resumeServer }, remedy: `stop the process that listens on ${resumeServer}, then run cotal up again` });
|
|
1031
|
+
throw new CommandFailure("refused", "CONFLICT", `${error.message}; the resumed broker needs that address, so nothing was started`, { target: { root, space: journal.space, server: resumeServer }, remedy: `stop the process that listens on ${resumeServer}, then run \`cotal up\` again` });
|
|
1032
1032
|
});
|
|
1033
1033
|
// Admit every seat checkpoint the cut wrote and take custody, BEFORE the resume attempt is
|
|
1034
1034
|
// journalled and long before a manager starts. A refusal here costs nothing because
|
|
@@ -1147,7 +1147,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1147
1147
|
const assessment = assessMaintenanceClaim(journal.claim, { unrecordedOwnersDead: attemptProcessesGone(root) });
|
|
1148
1148
|
if (assessment !== "stale")
|
|
1149
1149
|
throw heldClaim(root, attempt, journal.claim, "cotal up", assessment);
|
|
1150
|
-
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", `cotal up is refused: backup attempt ${attempt} stopped before it finished and still holds this root; nothing was changed`, { target: { root, attemptId: attempt }, remedy: `release it with cotal backup recover ${attempt} --yes
|
|
1150
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", `cotal up is refused: backup attempt ${attempt} stopped before it finished and still holds this root; nothing was changed`, { target: { root, attemptId: attempt }, remedy: `release it with \`cotal backup recover ${attempt} --yes\`, then run \`cotal up\`` });
|
|
1151
1151
|
}
|
|
1152
1152
|
else if (journal) {
|
|
1153
1153
|
throw new Error(`cotal up is refused while maintenance state is ${journal.state}; follow the recorded recovery`);
|
|
@@ -1274,7 +1274,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1274
1274
|
const named = { root: cotalRoot(), space: values.space ?? folderSpace() };
|
|
1275
1275
|
if (readManagerName(named) !== name) {
|
|
1276
1276
|
if (managerRecordState(named.space, named.root).state === "alive")
|
|
1277
|
-
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", `a manager already runs for space ${named.space}, and it keeps the name it started with`, { target: { root: named.root, space: named.space }, remedy: `stop it with cotal down
|
|
1277
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", `a manager already runs for space ${named.space}, and it keeps the name it started with`, { target: { root: named.root, space: named.space }, remedy: `stop it with \`cotal down\`, then run ${codeSpan(`cotal up --manager-name ${shellWord(name)}`)}` });
|
|
1278
1278
|
if (!values["dry-run"])
|
|
1279
1279
|
recordManagerName(named, name);
|
|
1280
1280
|
}
|
|
@@ -1287,7 +1287,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1287
1287
|
const capped = { root: cotalRoot(), space: values.space ?? folderSpace() };
|
|
1288
1288
|
if (readManagerSeatCap(capped) !== cap) {
|
|
1289
1289
|
if (managerRecordState(capped.space, capped.root).state === "alive")
|
|
1290
|
-
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
|
|
1290
|
+
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)}\`` });
|
|
1291
1291
|
if (!values["dry-run"])
|
|
1292
1292
|
recordManagerSeatCap(capped, cap);
|
|
1293
1293
|
}
|
|
@@ -1359,7 +1359,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1359
1359
|
// one, it takes that stack's lifetime over and says so before it blocks.
|
|
1360
1360
|
const holder = values.foreground ? foregroundHolder(meshRoot) : undefined;
|
|
1361
1361
|
if (holder !== undefined)
|
|
1362
|
-
throw new CommandFailure("refused", "CONFLICT", `a foreground cotal up in process ${holder} already holds this stack's lifetime; this terminal did not take it over and nothing was started`, { target: { root: meshRoot, space: stackSpace, holderPid: holder }, remedy: `use the terminal that runs process ${holder}, where Ctrl-C stops the stack, or stop it with cotal down --yes from ${meshRoot} and run cotal up --foreground again` });
|
|
1362
|
+
throw new CommandFailure("refused", "CONFLICT", `a foreground \`cotal up\` in process ${holder} already holds this stack's lifetime; this terminal did not take it over and nothing was started`, { target: { root: meshRoot, space: stackSpace, holderPid: holder }, remedy: `use the terminal that runs process ${holder}, where Ctrl-C stops the stack, or stop it with \`cotal down --yes\` from ${meshRoot} and run \`cotal up --foreground\` again` });
|
|
1363
1363
|
const takeover = values.foreground === true && STACK_ROLES.some((role) => serviceInstances(stackSpace, STACK_DEFINITION[role]).some((row) => observeServiceProcess(row.record.value) === "running"));
|
|
1364
1364
|
// A signal ends a detached start where it is, after it records a launch it had not yet pinned to
|
|
1365
1365
|
// its child, and the notice names what it left running. It is installed before the lock, so no
|
|
@@ -1428,7 +1428,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1428
1428
|
if (controller)
|
|
1429
1429
|
throw new CommandFailure("refused", "CONFLICT", `this root holds the controller stack of space ${controller.journal.space}, and up -f does not start a manifest beside it; nothing was started`, {
|
|
1430
1430
|
target: { root: meshRoot, space: controller.journal.space },
|
|
1431
|
-
remedy: `add the manifest's channels and agents to the running stack with cotal team deploy ${values.file}
|
|
1431
|
+
remedy: `add the manifest's channels and agents to the running stack with \`cotal team deploy ${values.file}\`, or stop it with \`cotal down --yes\` and start the manifest through the controller with \`cotal team boot ${values.file}\``,
|
|
1432
1432
|
});
|
|
1433
1433
|
if (values["dry-run"]) {
|
|
1434
1434
|
await upManifest(values.file, {
|
|
@@ -1562,7 +1562,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1562
1562
|
else if (implicit) {
|
|
1563
1563
|
const cleaned = cleanedManifestStart(cotalRoot(), recordedSpace, values.open === true);
|
|
1564
1564
|
if (cleaned)
|
|
1565
|
-
throw new CommandFailure("refused", "CONFLICT", `this folder was deployed from a manifest as "${cleaned.space}" at ${cleaned.server} in ${cleaned.mode === "open" ? "open" : "static auth"} mode, and its identity and broker configuration were removed, so a bare up would not start it as it was deployed; nothing was started`, { target: { root: cotalRoot(), space: cleaned.space, server: cleaned.server }, remedy: `deploy it again with ${cleaned.command}` });
|
|
1565
|
+
throw new CommandFailure("refused", "CONFLICT", `this folder was deployed from a manifest as "${cleaned.space}" at ${cleaned.server} in ${cleaned.mode === "open" ? "open" : "static auth"} mode, and its identity and broker configuration were removed, so a bare up would not start it as it was deployed; nothing was started`, { target: { root: cotalRoot(), space: cleaned.space, server: cleaned.server }, remedy: `deploy it again with ${codeSpan(cleaned.command)}` });
|
|
1566
1566
|
}
|
|
1567
1567
|
// A registered address stays as recorded, so a running stack is still found by it.
|
|
1568
1568
|
const implicitServer = registeredServer ?? serving(retained?.server ?? DEFAULT_SERVER);
|
|
@@ -1681,7 +1681,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1681
1681
|
process.exit(1);
|
|
1682
1682
|
}
|
|
1683
1683
|
if (values["recreate-issued-stores"] !== undefined)
|
|
1684
|
-
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", `mesh "${held.space}" is already running at ${server}, and its issued-authority stores are recreated only on a fresh broker start, before any issuer runs; nothing was changed`, { target: { space: held.space }, remedy: "stop the stack first, then run cotal up --recreate-issued-stores <backup-dir
|
|
1684
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", `mesh "${held.space}" is already running at ${server}, and its issued-authority stores are recreated only on a fresh broker start, before any issuer runs; nothing was changed`, { target: { space: held.space }, remedy: "stop the stack first, then run `cotal up --recreate-issued-stores <backup-dir>` again" });
|
|
1685
1685
|
// `--foreground` asks this terminal to hold the stack's lifetime, but this branch starts
|
|
1686
1686
|
// nothing here: it used to print `✓ already running`, restart a missing manager detached and
|
|
1687
1687
|
// exit 0. A service unit relying on `--foreground` read that exit as the stack ending, stopped
|
|
@@ -2105,7 +2105,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
2105
2105
|
}
|
|
2106
2106
|
catch (e) {
|
|
2107
2107
|
console.error(c.red(`! teardown: ${e.message}`));
|
|
2108
|
-
console.error(c.red(`the stack is still running; to take managed agents with it, run: cotal down --with-agents
|
|
2108
|
+
console.error(c.red(`the stack is still running; to take managed agents with it, run: \`cotal down --with-agents\``));
|
|
2109
2109
|
stopping = false;
|
|
2110
2110
|
return;
|
|
2111
2111
|
}
|
|
@@ -2264,7 +2264,7 @@ async function unrecordedStackServer(root, space, host) {
|
|
|
2264
2264
|
return host ? reconcileHostAndServer(host, undefined, "--host", "--server", saved) : saved;
|
|
2265
2265
|
}
|
|
2266
2266
|
if (listSpaceAccounts(authDir(root)).includes(space) || existsSync(join(root, ".cotal", "nats")))
|
|
2267
|
-
throw new MissingFlags(`no stack journal, registration or saved broker definition records the address "${space}" ran at in ${root}, which holds its earlier trust or store; nothing was started`, "run cotal up --server <url
|
|
2267
|
+
throw new MissingFlags(`no stack journal, registration or saved broker definition records the address "${space}" ran at in ${root}, which holds its earlier trust or store; nothing was started`, "run `cotal up --server <url>` with the address it ran at", { root, space });
|
|
2268
2268
|
return freshStackServer(host ? reconcileHostAndServer(host, undefined) : DEFAULT_SERVER, host);
|
|
2269
2269
|
}
|
|
2270
2270
|
/** A start over the broker a committed restore left running here. `up -f` boots a fresh mesh, so its
|
|
@@ -2272,7 +2272,7 @@ async function unrecordedStackServer(root, space, host) {
|
|
|
2272
2272
|
function restoredBrokerRuns(root, attempt, pid, manifest, retire) {
|
|
2273
2273
|
return new CommandFailure("refused", "CONFLICT", `the broker that restore attempt ${attempt} started still runs here (pid ${pid}), and a new start does not run beside it; nothing was started`, {
|
|
2274
2274
|
target: { root, attempt, pid },
|
|
2275
|
-
remedy: manifest !== undefined ? `stop the restored stack with cotal down
|
|
2275
|
+
remedy: manifest !== undefined ? `stop the restored stack with \`cotal down\`, retire the restore with ${retire}, then run \`cotal up -f ${manifest}\` again` : "stop the restored stack with `cotal down`, then run `cotal up` again",
|
|
2276
2276
|
});
|
|
2277
2277
|
}
|
|
2278
2278
|
/** The cleanup that retires an active restore. One that left something out keeps its only copy in the
|
|
@@ -2298,9 +2298,9 @@ function assertOrdinaryUpAllowed(root, storeDir, manifest) {
|
|
|
2298
2298
|
throw new Error(`restore attempt ${attempt} active listener ownership is ${status}; refusing ordinary startup`);
|
|
2299
2299
|
// `up -f` boots a fresh mesh, so the restore it would start over is retired first.
|
|
2300
2300
|
if (manifest !== undefined)
|
|
2301
|
-
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", `restore attempt ${attempt} is still active here, and cotal up -f boots a fresh mesh, which does not start over a restore that is not retired; nothing was started`, {
|
|
2301
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", `restore attempt ${attempt} is still active here, and \`cotal up -f\` boots a fresh mesh, which does not start over a restore that is not retired; nothing was started`, {
|
|
2302
2302
|
target: { root, attempt },
|
|
2303
|
-
remedy: `retire the restore with ${retire}, then run cotal up -f ${manifest} again; bare cotal up starts the restored stack instead`,
|
|
2303
|
+
remedy: `retire the restore with ${retire}, then run \`cotal up -f ${manifest}\` again; bare \`cotal up\` starts the restored stack instead`,
|
|
2304
2304
|
});
|
|
2305
2305
|
// Relaunching after restore must serve the exact recorded active target, not whatever store the
|
|
2306
2306
|
// caller happens to name — the journal's provenance would otherwise describe a different mesh.
|
|
@@ -2575,7 +2575,7 @@ async function resumeControllerStack(lock, root, values, restoreSink) {
|
|
|
2575
2575
|
if (values["store-dir"] !== undefined || values["max-file-store"] !== undefined)
|
|
2576
2576
|
throw new CommandFailure("refused", "USAGE_INVALID", "a controller resume takes its store and cap from the cut; --store-dir and --max-file-store are refused", { target: { root, space } });
|
|
2577
2577
|
if (values["auth-timeout"] !== undefined)
|
|
2578
|
-
throw new CommandFailure("refused", "USAGE_INVALID", "a controller resume renders this root's recorded auth callout timeout; --auth-timeout is refused", { target: { root, space }, remedy: "run cotal up without --auth-timeout" });
|
|
2578
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "a controller resume renders this root's recorded auth callout timeout; --auth-timeout is refused", { target: { root, space }, remedy: "run `cotal up` without --auth-timeout" });
|
|
2579
2579
|
const runtimes = [...new Set(agents.map((agent) => agent.launch?.runtime).filter((value) => typeof value === "string"))];
|
|
2580
2580
|
if (runtimes.length > 1 || (values.runtime !== undefined && runtimes[0] !== undefined && values.runtime !== runtimes[0]))
|
|
2581
2581
|
throw new CommandFailure("refused", "USAGE_INVALID", "--runtime must equal the preserved inventory's runtime; a controller resume does not change it", { target: { root, space } });
|
|
@@ -3082,7 +3082,7 @@ async function startUserAuthService(space, server, setup, publicExchange, quietB
|
|
|
3082
3082
|
const endpoints = { url: base, ...(typeof raw.publicUrl === "string" ? { managerAuthorityUrl: `${base.replace(/\/$/, "")}/manager-service-authority` } : {}) };
|
|
3083
3083
|
const info = assertUserAuthInfo({ ...setup.prepared.publicAuth, endpoints });
|
|
3084
3084
|
if (!quietBoot)
|
|
3085
|
-
console.log(c.green("✓ user-auth service up") + c.dim(` - sign in with: cotal login --idp ${info.idp.url}
|
|
3085
|
+
console.log(c.green("✓ user-auth service up") + c.dim(` - sign in with: \`cotal login --idp ${info.idp.url}\``));
|
|
3086
3086
|
return { userAuth: info, ok: true };
|
|
3087
3087
|
}
|
|
3088
3088
|
catch (e) {
|
|
@@ -3518,7 +3518,7 @@ async function upManifest(file, opts) {
|
|
|
3518
3518
|
console.log(c.green(`✓ mesh "${m.space}" up at ${server}`) + c.dim(` (broker pid ${pid})`));
|
|
3519
3519
|
console.log(c.dim(` seeded ${m.channels.length} channel(s): ${m.channels.map((ch) => "#" + ch.name).join(", ")}`));
|
|
3520
3520
|
if (summaryRecorded)
|
|
3521
|
-
console.log(c.dim(` fresh deployment ${deploymentId} recorded; cotal team show ${deploymentId} reads its launch summary, not live ownership`));
|
|
3521
|
+
console.log(c.dim(` fresh deployment ${deploymentId} recorded; \`cotal team show ${deploymentId}\` reads its launch summary, not live ownership`));
|
|
3522
3522
|
// Never claim a launch the control plane can't deliver: the manager carries the launch spec, so a
|
|
3523
3523
|
// degraded control plane (announced above) means the agents are NOT coming up.
|
|
3524
3524
|
if (effectiveNoManager) {
|
|
@@ -3531,7 +3531,7 @@ async function upManifest(file, opts) {
|
|
|
3531
3531
|
// The manager launches them after this command returns, so nothing here knows whether one joined:
|
|
3532
3532
|
// no success mark, and name where the outcome shows.
|
|
3533
3533
|
console.log(` launch pending: the manager (${runtime}) starts ${eff.agents.length} agent(s)${owner ? ` as you (owner ${owner})` : ""} after this returns; up -f does not wait for them to join`);
|
|
3534
|
-
console.log(c.dim(` who joined: cotal ps --space ${m.space} · a failed launch and its reason: ${managerLogDisplayPath(m.space)}`));
|
|
3534
|
+
console.log(c.dim(` who joined: \`cotal ps --space ${m.space}\` · a failed launch and its reason: ${managerLogDisplayPath(m.space)}`));
|
|
3535
3535
|
}
|
|
3536
3536
|
else {
|
|
3537
3537
|
stderrLine("✗ ", `${eff.agents.length} agent(s) NOT launched - the control plane did not come up (see above)`, c.red);
|
|
@@ -3694,7 +3694,7 @@ function exitedBeforeReady(l) {
|
|
|
3694
3694
|
const { path, source } = l.executable;
|
|
3695
3695
|
return new CommandFailure("failed", "OPERATION_FAILED", `${natsServerLabel(l.executable)} ${exit} before it answered at ${l.server}; see ${l.log}`, {
|
|
3696
3696
|
target: { executable: path, ...(exitCode !== null ? { exitCode } : { signal: signalCode }), server: l.server, log: l.log },
|
|
3697
|
-
remedy: source === "path" ? `read ${l.log}, then fix ${path} or take it off PATH so cotal uses its bundled nats-server, and run cotal up again` : `read ${l.log}, then run cotal up again`,
|
|
3697
|
+
remedy: source === "path" ? `read ${l.log}, then fix ${path} or take it off PATH so cotal uses its bundled nats-server, and run \`cotal up\` again` : `read ${l.log}, then run \`cotal up\` again`,
|
|
3698
3698
|
});
|
|
3699
3699
|
}
|
|
3700
3700
|
/**
|
|
@@ -3836,7 +3836,7 @@ export function openBrokerLog(path) {
|
|
|
3836
3836
|
catch (error) {
|
|
3837
3837
|
if (error.code !== "EPERM")
|
|
3838
3838
|
throw error;
|
|
3839
|
-
throw new CommandFailure("refused", "PERMISSION_DENIED", `no broker was started: ${error.message}`, { target: { path }, remedy: `remove ${path} or replace it with a regular file you own, then run cotal up again` });
|
|
3839
|
+
throw new CommandFailure("refused", "PERMISSION_DENIED", `no broker was started: ${error.message}`, { target: { path }, remedy: `remove ${path} or replace it with a regular file you own, then run \`cotal up\` again` });
|
|
3840
3840
|
}
|
|
3841
3841
|
}
|
|
3842
3842
|
/**
|
|
@@ -3894,7 +3894,7 @@ async function assertBrokerAddressFree(server, command) {
|
|
|
3894
3894
|
const { says, frees } = addressHolder("the broker address", host, port);
|
|
3895
3895
|
throw new CommandFailure("refused", "CONFLICT", `${says} (bind failed: address already in use); no broker was launched`, {
|
|
3896
3896
|
target: { root: cotalRoot(), server, bindError: bindError.code },
|
|
3897
|
-
remedy: `start it at another address with ${command} --server ${address.protocol}//${address.hostname}:<port
|
|
3897
|
+
remedy: `start it at another address with ${codeSpan(`${command} --server ${address.protocol}//${address.hostname}:<port>`)}, or ${frees} and run ${codeSpan(command)} again`,
|
|
3898
3898
|
});
|
|
3899
3899
|
}
|
|
3900
3900
|
/** THE FLIP: a start without `--user-auth` must never boot a broker over a root whose space has
|
|
@@ -4112,9 +4112,9 @@ export async function claimSpace(space, server, root) {
|
|
|
4112
4112
|
if (canonicalRoot(existing.root) === canonicalRoot(root) && existing.server !== server)
|
|
4113
4113
|
throw new CommandFailure("refused", "CONFLICT", `space "${space}" already runs from this project at ${existing.server}, and this start names ${server}; nothing was started`, {
|
|
4114
4114
|
target,
|
|
4115
|
-
remedy: `run cotal up here with no --server or --host to reach the mesh at ${existing.server}, or stop it first with cotal down${controller ? " --yes" : ""} in ${shellWord(existing.root)}`,
|
|
4115
|
+
remedy: `run \`cotal up\` here with no --server or --host to reach the mesh at ${existing.server}, or stop it first with \`cotal down${controller ? " --yes" : ""}\` in ${shellWord(existing.root)}`,
|
|
4116
4116
|
});
|
|
4117
|
-
throw new CommandFailure("refused", "CONFLICT", `space "${space}" is already in use by a mesh at ${existing.server} (${existing.root})`, { target, remedy: `start a separate space in this folder with cotal up --space <name
|
|
4117
|
+
throw new CommandFailure("refused", "CONFLICT", `space "${space}" is already in use by a mesh at ${existing.server} (${existing.root})`, { target, remedy: `start a separate space in this folder with \`cotal up --space <name>\`, naming one no other folder uses, or stop "${space}" first with \`cotal down${controller ? " --yes" : ""}\` in ${shellWord(existing.root)}` });
|
|
4118
4118
|
}
|
|
4119
4119
|
// The recorded root is this root only where it physically resolves, so it is resolved before any
|
|
4120
4120
|
// comparison, and one that cannot be resolved refuses. A dead holder at another root keeps its name
|
|
@@ -4297,8 +4297,8 @@ async function refuseUntrustedListener(server, creds) {
|
|
|
4297
4297
|
throw new CommandFailure("failed", "OPERATION_FAILED", `nats-server answered at ${server}, but this client refused its TLS certificate in the handshake (${reason}); up stopped it and recorded nothing`, {
|
|
4298
4298
|
native: { code: String(code) },
|
|
4299
4299
|
remedy: untrusted
|
|
4300
|
-
? "trust the certificate's CA, or a self-signed certificate itself, by setting NODE_EXTRA_CA_CERTS to that PEM file for cotal up and every cotal command of this space, then run cotal up again"
|
|
4301
|
-
: /^tls:/i.test(server) ? `serve a certificate that names ${hostname}, then run cotal up again` : `pass --server tls://${hostname}:${port}, so every dial checks the certificate against ${hostname}`,
|
|
4300
|
+
? "trust the certificate's CA, or a self-signed certificate itself, by setting NODE_EXTRA_CA_CERTS to that PEM file for `cotal up` and every cotal command of this space, then run `cotal up` again"
|
|
4301
|
+
: /^tls:/i.test(server) ? `serve a certificate that names ${hostname}, then run \`cotal up\` again` : `pass --server tls://${hostname}:${port}, so every dial checks the certificate against ${hostname}`,
|
|
4302
4302
|
});
|
|
4303
4303
|
}
|
|
4304
4304
|
/** The broker's version, and whether `space`'s presence stream exists file-backed. Cotal creates
|
|
@@ -4526,7 +4526,7 @@ async function postStart(server, space, setup, seedFile, recreateIssuedStores) {
|
|
|
4526
4526
|
catch (error) {
|
|
4527
4527
|
// Nothing of the stack runs yet, and the caller stops this broker again, so this is a refusal.
|
|
4528
4528
|
if (error instanceof IssuedStoreBeforeRetentionError)
|
|
4529
|
-
throw new CommandFailure("refused", "CONFLICT", error.message, { target: { space, store: error.bucket }, remedy: `stop every other issuer and resolver of space ${space}, then add --recreate-issued-stores <backup-dir> to the cotal up that starts it` });
|
|
4529
|
+
throw new CommandFailure("refused", "CONFLICT", error.message, { target: { space, store: error.bucket }, remedy: `stop every other issuer and resolver of space ${space}, then add --recreate-issued-stores <backup-dir> to the \`cotal up\` that starts it` });
|
|
4530
4530
|
throw error;
|
|
4531
4531
|
}
|
|
4532
4532
|
try {
|
|
@@ -4693,7 +4693,7 @@ async function refuseRunningElsewhere(space, root) {
|
|
|
4693
4693
|
controller = readStackJournal(owner.root)?.journal.space === space;
|
|
4694
4694
|
}
|
|
4695
4695
|
catch { /* named with the legacy stop */ }
|
|
4696
|
-
throw new CommandFailure("refused", "CONFLICT", `space "${space}" runs at ${owner.server}, started in ${owner.root}, so up did not start it again`, { target: { space, root: owner.root, server: owner.server }, remedy: `use it from here with --space ${space}, or stop it with cotal down${controller ? " --yes" : ""} in ${owner.root}` });
|
|
4696
|
+
throw new CommandFailure("refused", "CONFLICT", `space "${space}" runs at ${owner.server}, started in ${owner.root}, so up did not start it again`, { target: { space, root: owner.root, server: owner.server }, remedy: `use it from here with --space ${space}, or stop it with \`cotal down${controller ? " --yes" : ""}\` in ${owner.root}` });
|
|
4697
4697
|
}
|
|
4698
4698
|
/** Refuses a bare `up` in a folder holding the records of a space this machine registers for another
|
|
4699
4699
|
* folder, as a copy, a moved folder and one whose name a later `up` took over keep them. The retained
|
|
@@ -4708,7 +4708,7 @@ async function refuseRecordsElsewhere(root) {
|
|
|
4708
4708
|
const takeover = !existsSync(records.recordedRoot) && !(await isReachable(findMesh(space)?.server ?? records.server ?? DEFAULT_SERVER));
|
|
4709
4709
|
throw new CommandFailure("refused", "CONFLICT", `this folder holds the records of "${space}", which is registered for ${records.recordedRoot}, not for this folder, so up did not start it here`, {
|
|
4710
4710
|
target: { root, space, recordedRoot: records.recordedRoot },
|
|
4711
|
-
remedy: takeover ? `${records.stackRemedy}; or, to run it from this folder, take the name over with cotal up --space ${space}
|
|
4711
|
+
remedy: takeover ? `${records.stackRemedy}; or, to run it from this folder, take the name over with \`cotal up --space ${space}\`` : records.stackRemedy,
|
|
4712
4712
|
});
|
|
4713
4713
|
}
|
|
4714
4714
|
/** The channels files one `up` has read, by path. It reads its seed when it checks the flags, when it
|
|
@@ -5073,7 +5073,7 @@ function writeBrokerConfig(path, text) {
|
|
|
5073
5073
|
const entry = lstatSync(path, { throwIfNoEntry: false });
|
|
5074
5074
|
const what = entry?.isSymbolicLink() ? "is a symlink" : entry?.isDirectory() ? "is a folder" : code === "EACCES" ? "cannot be written by this account" : "is not a regular file this account owns";
|
|
5075
5075
|
throw new CommandFailure("refused", "PERMISSION_DENIED", `the broker configuration ${path} ${what}, so up cannot write it; it was left as it is and nothing was started`, {
|
|
5076
|
-
target: { path }, remedy: `move it aside, as mv ${shellWord(path)} ${shellWord(`${path}.old`)} does, then run cotal up again, which writes it from the space's trust`,
|
|
5076
|
+
target: { path }, remedy: `move it aside, as mv ${shellWord(path)} ${shellWord(`${path}.old`)} does, then run \`cotal up\` again, which writes it from the space's trust`,
|
|
5077
5077
|
});
|
|
5078
5078
|
}
|
|
5079
5079
|
}
|
|
@@ -5084,7 +5084,7 @@ function unreadableTrust(error) {
|
|
|
5084
5084
|
if (code !== "EACCES" && code !== "EPERM" || typeof path !== "string")
|
|
5085
5085
|
return error;
|
|
5086
5086
|
return new CommandFailure("refused", "PERMISSION_DENIED", `the space's trust record ${path} cannot be read by this account (${code}); nothing was started`, {
|
|
5087
|
-
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`,
|
|
5087
|
+
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`,
|
|
5088
5088
|
});
|
|
5089
5089
|
}
|
|
5090
5090
|
/** Ensure the space's trust material exists, render a server config, and mint a privileged
|