@cotal-ai/cli 0.150.0 → 0.151.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 -0
- package/dist/command.js.map +1 -1
- package/dist/commands/agents.d.ts +5 -2
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +4 -1
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/chat.js +1 -1
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +14 -6
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/doctor.js +11 -5
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/ext.d.ts.map +1 -1
- package/dist/commands/ext.js +10 -1
- package/dist/commands/ext.js.map +1 -1
- package/dist/commands/revoke-credential.d.ts.map +1 -1
- package/dist/commands/revoke-credential.js +12 -6
- package/dist/commands/revoke-credential.js.map +1 -1
- package/dist/commands/service-registry.d.ts.map +1 -1
- package/dist/commands/service-registry.js +9 -2
- package/dist/commands/service-registry.js.map +1 -1
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +22 -6
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/stack-down.d.ts.map +1 -1
- package/dist/commands/stack-down.js +8 -0
- package/dist/commands/stack-down.js.map +1 -1
- package/dist/commands/stack-up.js +1 -1
- package/dist/commands/stack-up.js.map +1 -1
- package/dist/commands/up.d.ts +6 -7
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +36 -45
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +5 -4
- package/dist/commands/update.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/foreground-hold.d.ts +12 -0
- package/dist/lib/foreground-hold.d.ts.map +1 -0
- package/dist/lib/foreground-hold.js +63 -0
- package/dist/lib/foreground-hold.js.map +1 -0
- package/dist/lib/manager-proc.d.ts +12 -8
- package/dist/lib/manager-proc.d.ts.map +1 -1
- package/dist/lib/manager-proc.js +92 -17
- package/dist/lib/manager-proc.js.map +1 -1
- package/dist/lib/private-log.d.ts +14 -0
- package/dist/lib/private-log.d.ts.map +1 -0
- package/dist/lib/private-log.js +56 -0
- package/dist/lib/private-log.js.map +1 -0
- package/dist/lib/service-process.d.ts.map +1 -1
- package/dist/lib/service-process.js +2 -48
- package/dist/lib/service-process.js.map +1 -1
- package/dist/lib/spawn-defaults.d.ts +3 -2
- package/dist/lib/spawn-defaults.d.ts.map +1 -1
- package/dist/lib/spawn-defaults.js +9 -5
- package/dist/lib/spawn-defaults.js.map +1 -1
- package/dist/lib/stack-journal.d.ts +3 -0
- package/dist/lib/stack-journal.d.ts.map +1 -1
- package/dist/lib/stack-journal.js +12 -0
- package/dist/lib/stack-journal.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":"
|
|
1
|
+
{"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../src/commands/up.ts"],"names":[],"mappings":"AAqBA,OAAO,EAWL,KAAK,eAAe,EAkCpB,KAAK,YAAY,EAIjB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAkEL,KAAK,SAAS,EA0Bd,KAAK,eAAe,EAiCrB,MAAM,qBAAqB,CAAC;AAmB7B,OAAO,EAA4C,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAa3G,OAAO,EAYL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAEnB,MAAM,eAAe,CAAC;AAuBvB,OAAO,EAqBL,KAAK,eAAe,EAErB,MAAM,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AED;;;;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,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA0C/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
|
@@ -4,12 +4,12 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
5
|
import { createConnection, createServer, isIP } from "node:net";
|
|
6
6
|
import { homedir, hostname } from "node:os";
|
|
7
|
-
import { accessSync, constants, mkdirSync, readFileSync, existsSync, statSync, closeSync, lstatSync, realpathSync, readdirSync, rmdirSync,
|
|
7
|
+
import { accessSync, constants, mkdirSync, readFileSync, existsSync, statSync, closeSync, lstatSync, realpathSync, readdirSync, rmdirSync, } from "node:fs";
|
|
8
8
|
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
9
|
-
import { isReachable, dialerFor, DEFAULT_SERVER, DEFAULT_SPACE, SERVICE_AUTHORITY_MAX_BYTES, SERVICE_CALLER_PAYLOAD_FLOOR, createSpaceAuth, serverConfig, openServerConfig, validateTlsMaterial, credsProblem, mintCreds, mintLifecycleUid, DEV_OWNER, mintConnectionEvictorCreds, mintMembershipObserverCreds, newIdentity, setupSpaceStreams, removeIssuedStoresBeforeRetention, IssuedStoreBeforeRetentionError, IssuedStoreRecreateRefusal, reconcileSpaceTtls, ttlBuckets, standaloneConnectOpts, requireBrokerFloor, parseServerVersion, presenceBucket, spaceDeletionStreams, isJetStreamMissing, seedChannelRegistry, ensureDefaultDeliveryClass, UndecodableRegistryEntry, assertValidChannel, isConcreteChannel, validateChannelConfig, validateChannelDefaults, LEASE_TTL_MS, EpEnvelopeError, mkSecretDir, openPrivateAppend, realDirNoSymlink, writeSecretFile,
|
|
9
|
+
import { isReachable, dialerFor, DEFAULT_SERVER, DEFAULT_SPACE, SERVICE_AUTHORITY_MAX_BYTES, SERVICE_CALLER_PAYLOAD_FLOOR, createSpaceAuth, serverConfig, openServerConfig, validateTlsMaterial, credsProblem, mintCreds, mintLifecycleUid, DEV_OWNER, mintConnectionEvictorCreds, mintMembershipObserverCreds, newIdentity, setupSpaceStreams, removeIssuedStoresBeforeRetention, IssuedStoreBeforeRetentionError, IssuedStoreRecreateRefusal, reconcileSpaceTtls, ttlBuckets, standaloneConnectOpts, requireBrokerFloor, parseServerVersion, presenceBucket, spaceDeletionStreams, isJetStreamMissing, seedChannelRegistry, ensureDefaultDeliveryClass, UndecodableRegistryEntry, assertValidChannel, isConcreteChannel, validateChannelConfig, validateChannelDefaults, LEASE_TTL_MS, EpEnvelopeError, mkSecretDir, openPrivateAppend, realDirNoSymlink, writeSecretFile, utf16Problem, } from "@cotal-ai/core";
|
|
10
10
|
import { JetStreamApiCodes, jetstreamManager, StorageType } from "@nats-io/jetstream";
|
|
11
11
|
import { Kvm } from "@nats-io/kv";
|
|
12
|
-
import { assertManagerName, readManagerName, readManagerSeatCap, recordManagerName, recordManagerSeatCap, parseSeatCapFlag, seatCapText,
|
|
12
|
+
import { assertManagerName, readManagerName, readManagerSeatCap, recordManagerName, recordManagerSeatCap, parseSeatCapFlag, seatCapText, CommandFailure, codeSpan, commandFailureReport, 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, 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, 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, NATS_PIDFILE, UNTRUSTED_CERTIFICATE, exitCode, canonicalLocalProcessPath, DELIVERY_LOGFILE, terminalWidth, } from "@cotal-ai/workspace";
|
|
13
13
|
import { FlagValueRefusal } from "../lib/flag-value-refusal.js";
|
|
14
14
|
import { ensureAuthService, resolveAuthProvider, stopAuthService } from "../lib/auth-proc.js";
|
|
15
15
|
import { resolveSpace } from "../lib/status.js";
|
|
@@ -43,6 +43,7 @@ import { checkLocalSpace } from "./space-registration.js";
|
|
|
43
43
|
import { cleanedManifestStart, namedOpenConfig, retainedOpenSpace } from "../lib/legacy-start.js";
|
|
44
44
|
import { bindReaches, canonicalServer, controllerStackApplies, recheckExistingStore, requestedStackMode, requestsTls, stackUp, stackUpForegroundNotice, stackUpInterruptNotice, keptOnUp, selectedOnUp, unparsableDaemonCredsNotice, } from "./stack-up.js";
|
|
45
45
|
import { handOverStartupNotice, noticeOnInterrupt, releaseStartupNotice } from "../lib/interrupt-notice.js";
|
|
46
|
+
import { claimForegroundHold, foregroundHolder, releaseForegroundHold } from "../lib/foreground-hold.js";
|
|
46
47
|
import { settleInterruptedLaunches } from "../lib/service-process.js";
|
|
47
48
|
import { assertUserStackTransport, preflightUserStack } from "./stack-user-auth.js";
|
|
48
49
|
import { stackDown } from "./stack-down.js";
|
|
@@ -571,12 +572,22 @@ function stopForegroundStack(root, signal) {
|
|
|
571
572
|
process.stderr.write(`${renderReport(commandFailureReport(isCommandFailure(error) ? error : new CommandFailure("unknown", "OPERATION_UNKNOWN", "the foreground stack stop did not confirm its outcome; its members were retained")), "rich", process.stderr)}\n`);
|
|
572
573
|
}).finally(() => { process.exitCode = signal === "SIGINT" ? 130 : 143; });
|
|
573
574
|
}
|
|
575
|
+
/** A hangup, such as a closed terminal, is not a stop. The stack keeps running and the notice names
|
|
576
|
+
* the command that stops it. Release this process's hold before the immediate exit, which does not
|
|
577
|
+
* unwind the surrounding finally, so a later foreground `up` can take the running stack over. */
|
|
578
|
+
function hangupForegroundStack(root) {
|
|
579
|
+
process.stderr.write(`The terminal closed. This stack in ${root} is still running; \`cotal down\` stops it.\n`);
|
|
580
|
+
process.exitCode = 129;
|
|
581
|
+
releaseForegroundHold(root);
|
|
582
|
+
process.exit(129);
|
|
583
|
+
}
|
|
574
584
|
/** Foreground controller stack: the terminal holds the stack's lifetime until SIGINT or SIGTERM,
|
|
575
|
-
* which runs the same guarded whole-stack stop as bare `down`.
|
|
576
|
-
*
|
|
577
|
-
*
|
|
578
|
-
*
|
|
579
|
-
*
|
|
585
|
+
* which runs the same guarded whole-stack stop as bare `down`. A hangup leaves the stack running and
|
|
586
|
+
* exits 129, naming `cotal down`. `start`, when given, is the startup this terminal already holds: a
|
|
587
|
+
* signal during it lets the start settle, then a stop signal runs that stop and a hangup leaves what
|
|
588
|
+
* the start left. A failed start still runs the stop, and its failure is thrown once the stop returns.
|
|
589
|
+
* The hold's end sets the exit code: 0 when another command completed the stop or preserve, 129 after
|
|
590
|
+
* a hangup, 130 or 143 after a stop signal, whatever the start receipt set. */
|
|
580
591
|
export async function holdForegroundStack(root, start) {
|
|
581
592
|
claimForegroundHold(root);
|
|
582
593
|
try {
|
|
@@ -597,11 +608,14 @@ async function holdStack(root, start) {
|
|
|
597
608
|
if (requested)
|
|
598
609
|
return;
|
|
599
610
|
requested = signal;
|
|
600
|
-
process.stderr.write(
|
|
611
|
+
process.stderr.write(signal === "SIGHUP"
|
|
612
|
+
? "The terminal closed; the start settles, then the stack is left running\n"
|
|
613
|
+
: "Stop requested; the whole-stack stop runs once the start settles\n");
|
|
601
614
|
};
|
|
602
|
-
const interrupt = () => request("SIGINT"), terminate = () => request("SIGTERM");
|
|
615
|
+
const interrupt = () => request("SIGINT"), terminate = () => request("SIGTERM"), hangup = () => request("SIGHUP");
|
|
603
616
|
process.on("SIGINT", interrupt);
|
|
604
617
|
process.on("SIGTERM", terminate);
|
|
618
|
+
process.on("SIGHUP", hangup);
|
|
605
619
|
handOverStartupNotice();
|
|
606
620
|
let failure;
|
|
607
621
|
try {
|
|
@@ -610,9 +624,11 @@ async function holdStack(root, start) {
|
|
|
610
624
|
catch (error) {
|
|
611
625
|
failure = { error };
|
|
612
626
|
}
|
|
613
|
-
releaseStart = () => { process.off("SIGINT", interrupt); process.off("SIGTERM", terminate); };
|
|
627
|
+
releaseStart = () => { process.off("SIGINT", interrupt); process.off("SIGTERM", terminate); process.off("SIGHUP", hangup); };
|
|
614
628
|
if (requested || failure)
|
|
615
629
|
releaseStart();
|
|
630
|
+
if (requested === "SIGHUP")
|
|
631
|
+
hangupForegroundStack(root);
|
|
616
632
|
if (requested)
|
|
617
633
|
await stopForegroundStack(root, requested);
|
|
618
634
|
if (failure)
|
|
@@ -640,6 +656,7 @@ async function holdStack(root, start) {
|
|
|
640
656
|
stopping = true;
|
|
641
657
|
process.off("SIGINT", interrupt);
|
|
642
658
|
process.off("SIGTERM", terminate);
|
|
659
|
+
process.off("SIGHUP", hangup);
|
|
643
660
|
clearInterval(lifetime);
|
|
644
661
|
process.stderr.write(`${renderReport({ sections: [{ title: "Foreground stack released", blocks: [{ kind: "lines", lines: [`Another command completed a ${operation.kind === "down" ? "stop" : "preserve"} of this stack (operation ${operation.id}). This terminal no longer holds it.`] }] }] }, "rich", process.stderr)}\n`);
|
|
645
662
|
process.exitCode = 0;
|
|
@@ -651,49 +668,21 @@ async function holdStack(root, start) {
|
|
|
651
668
|
stopping = true;
|
|
652
669
|
process.off("SIGINT", interrupt);
|
|
653
670
|
process.off("SIGTERM", terminate);
|
|
671
|
+
process.off("SIGHUP", hangup);
|
|
654
672
|
clearInterval(lifetime);
|
|
655
673
|
void stopForegroundStack(root, signal).finally(resolveHold);
|
|
656
674
|
};
|
|
657
675
|
const interrupt = () => stop("SIGINT");
|
|
658
676
|
const terminate = () => stop("SIGTERM");
|
|
677
|
+
const hangup = () => { if (!stopping)
|
|
678
|
+
hangupForegroundStack(root); };
|
|
659
679
|
process.on("SIGINT", interrupt);
|
|
660
680
|
process.on("SIGTERM", terminate);
|
|
681
|
+
process.on("SIGHUP", hangup);
|
|
661
682
|
releaseStart();
|
|
662
683
|
handOverStartupNotice();
|
|
663
684
|
});
|
|
664
685
|
}
|
|
665
|
-
/** Where a foreground `up` records the process that holds its stack's lifetime. */
|
|
666
|
-
const foregroundHoldPath = (root) => join(root, ".cotal", "stack-foreground.hold");
|
|
667
|
-
/** The process of another foreground `up` that holds `root`'s stack, while that exact process runs. */
|
|
668
|
-
export function foregroundHolder(root) {
|
|
669
|
-
let raw;
|
|
670
|
-
try {
|
|
671
|
-
raw = readFileSync(foregroundHoldPath(root), "utf8");
|
|
672
|
-
}
|
|
673
|
-
catch {
|
|
674
|
-
return undefined;
|
|
675
|
-
}
|
|
676
|
-
const read = parseRecord(raw);
|
|
677
|
-
if (read.kind !== "record" || read.record.pid === process.pid)
|
|
678
|
-
return undefined;
|
|
679
|
-
return assertRecordIdentity(read.record).kind === "match" ? read.record.pid : undefined;
|
|
680
|
-
}
|
|
681
|
-
/** Record this process as the foreground holder of `root`'s stack. A host that cannot pin a process
|
|
682
|
-
* start records nothing, so no later `up` refuses on a pid that may have been reused. */
|
|
683
|
-
function claimForegroundHold(root) {
|
|
684
|
-
const record = identityRecord(process.pid);
|
|
685
|
-
if ("token" in record)
|
|
686
|
-
writeSecretFileAtomic(foregroundHoldPath(root), `${formatRecord(record)}\n`);
|
|
687
|
-
}
|
|
688
|
-
/** Remove this process's foreground hold record, and leave one another process wrote. */
|
|
689
|
-
function releaseForegroundHold(root) {
|
|
690
|
-
try {
|
|
691
|
-
const read = parseRecord(readFileSync(foregroundHoldPath(root), "utf8"));
|
|
692
|
-
if (read.kind === "record" && read.record.pid === process.pid)
|
|
693
|
-
unlinkSync(foregroundHoldPath(root));
|
|
694
|
-
}
|
|
695
|
-
catch { /* nothing recorded */ }
|
|
696
|
-
}
|
|
697
686
|
/** The registered `up` command. When a background run is the main process of a systemd unit, it
|
|
698
687
|
* names that unit and the `--foreground` remedy once startup returns: controller stack, retained
|
|
699
688
|
* launcher, refresh and restore alike. It never changes the run's mode. Internal callers of
|
|
@@ -5461,8 +5450,10 @@ async function assertRootBrokerStopped(root) {
|
|
|
5461
5450
|
*
|
|
5462
5451
|
* WHY THIS IS SEPARATE FROM {@link provisionMembershipCreds}. That function mints the whole bundle
|
|
5463
5452
|
* in the fresh-space branch because the `$SYS` signing seed exists only there and is never
|
|
5464
|
-
* persisted — true of `membership-observer.creds` and `connection-evictor.creds
|
|
5465
|
-
*
|
|
5453
|
+
* persisted — true of `membership-observer.creds` and `connection-evictor.creds`. The delivery daemon
|
|
5454
|
+
* mints a missing evictor itself on a single-space root that retained its system-account signing
|
|
5455
|
+
* seed, so that one no longer needs a rotation; a root without the seed still needs one. It is NOT
|
|
5456
|
+
* true of the other two.
|
|
5466
5457
|
* `membership-rw.creds` is signed by the DATA account, whose signing seed IS persisted, and
|
|
5467
5458
|
* `membership.json` is just that account's public id. Neither needs the `$SYS` window, so binding
|
|
5468
5459
|
* them to it left every space provisioned before the feature permanently without the feed.
|