@cotal-ai/cli 0.172.1 → 0.173.0
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 +34 -20
- package/dist/command.js.map +1 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +8 -6
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +15 -10
- package/dist/commands/backup.js.map +1 -1
- package/dist/commands/channel-members.d.ts.map +1 -1
- package/dist/commands/channel-members.js +2 -1
- package/dist/commands/channel-members.js.map +1 -1
- package/dist/commands/channels.d.ts.map +1 -1
- package/dist/commands/channels.js +19 -9
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +2 -3
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/doctor.js +5 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/down-preserve.d.ts +74 -0
- package/dist/commands/down-preserve.d.ts.map +1 -0
- package/dist/commands/down-preserve.js +626 -0
- package/dist/commands/down-preserve.js.map +1 -0
- package/dist/commands/down.d.ts +2 -61
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +26 -617
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/endpoint-authoring.d.ts.map +1 -1
- package/dist/commands/endpoint-authoring.js +16 -4
- package/dist/commands/endpoint-authoring.js.map +1 -1
- package/dist/commands/history-clear.d.ts.map +1 -1
- package/dist/commands/history-clear.js +10 -3
- package/dist/commands/history-clear.js.map +1 -1
- package/dist/commands/history-limit.js +2 -2
- package/dist/commands/history-limit.js.map +1 -1
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +49 -19
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/join.d.ts.map +1 -1
- package/dist/commands/join.js +30 -7
- package/dist/commands/join.js.map +1 -1
- package/dist/commands/manager-service.d.ts.map +1 -1
- package/dist/commands/manager-service.js +5 -1
- package/dist/commands/manager-service.js.map +1 -1
- package/dist/commands/meshes-add.d.ts +4 -1
- package/dist/commands/meshes-add.d.ts.map +1 -1
- package/dist/commands/meshes-add.js +19 -1
- package/dist/commands/meshes-add.js.map +1 -1
- package/dist/commands/meshes-wizard.d.ts.map +1 -1
- package/dist/commands/meshes-wizard.js +5 -5
- package/dist/commands/meshes-wizard.js.map +1 -1
- package/dist/commands/meshes.d.ts.map +1 -1
- package/dist/commands/meshes.js +4 -3
- package/dist/commands/meshes.js.map +1 -1
- package/dist/commands/persona-remote.js +2 -2
- package/dist/commands/persona-remote.js.map +1 -1
- package/dist/commands/persona.d.ts.map +1 -1
- package/dist/commands/persona.js +13 -5
- package/dist/commands/persona.js.map +1 -1
- package/dist/commands/personas.d.ts.map +1 -1
- package/dist/commands/personas.js +4 -1
- package/dist/commands/personas.js.map +1 -1
- package/dist/commands/reset-space-apply.js +2 -2
- package/dist/commands/reset-space-apply.js.map +1 -1
- package/dist/commands/reset-store-apply.d.ts +2 -2
- package/dist/commands/reset-store-apply.d.ts.map +1 -1
- package/dist/commands/reset-store-apply.js +10 -7
- package/dist/commands/reset-store-apply.js.map +1 -1
- package/dist/commands/reset.js +2 -2
- package/dist/commands/reset.js.map +1 -1
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +21 -9
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/service-actions.d.ts.map +1 -1
- package/dist/commands/service-actions.js +15 -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 +16 -5
- package/dist/commands/service-registry.js.map +1 -1
- package/dist/commands/space-delete.d.ts.map +1 -1
- package/dist/commands/space-delete.js +46 -31
- package/dist/commands/space-delete.js.map +1 -1
- package/dist/commands/space-registration.d.ts +4 -3
- package/dist/commands/space-registration.d.ts.map +1 -1
- package/dist/commands/space-registration.js +65 -45
- package/dist/commands/space-registration.js.map +1 -1
- package/dist/commands/space.d.ts.map +1 -1
- package/dist/commands/space.js +18 -6
- package/dist/commands/space.js.map +1 -1
- package/dist/commands/spawn-flags.d.ts +205 -0
- package/dist/commands/spawn-flags.d.ts.map +1 -0
- package/dist/commands/spawn-flags.js +34 -0
- package/dist/commands/spawn-flags.js.map +1 -0
- package/dist/commands/spawn-foreground.d.ts +74 -0
- package/dist/commands/spawn-foreground.d.ts.map +1 -0
- package/dist/commands/spawn-foreground.js +355 -0
- package/dist/commands/spawn-foreground.js.map +1 -0
- package/dist/commands/spawn-managed-launch.d.ts +43 -0
- package/dist/commands/spawn-managed-launch.d.ts.map +1 -0
- package/dist/commands/spawn-managed-launch.js +631 -0
- package/dist/commands/spawn-managed-launch.js.map +1 -0
- package/dist/commands/spawn-preview.d.ts.map +1 -1
- package/dist/commands/spawn-preview.js +10 -7
- package/dist/commands/spawn-preview.js.map +1 -1
- package/dist/commands/spawn.d.ts +6 -220
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +21 -1009
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/stack-down.d.ts.map +1 -1
- package/dist/commands/stack-down.js +7 -4
- package/dist/commands/stack-down.js.map +1 -1
- package/dist/commands/stack-up.d.ts +5 -1
- package/dist/commands/stack-up.d.ts.map +1 -1
- package/dist/commands/stack-up.js +46 -15
- package/dist/commands/stack-up.js.map +1 -1
- package/dist/commands/status-delivery.d.ts +9 -0
- package/dist/commands/status-delivery.d.ts.map +1 -0
- package/dist/commands/status-delivery.js +19 -0
- package/dist/commands/status-delivery.js.map +1 -0
- package/dist/commands/status-legacy.d.ts +7 -0
- package/dist/commands/status-legacy.d.ts.map +1 -0
- package/dist/commands/status-legacy.js +35 -0
- package/dist/commands/status-legacy.js.map +1 -0
- package/dist/commands/status-stop-impact.d.ts +3 -0
- package/dist/commands/status-stop-impact.d.ts.map +1 -0
- package/dist/commands/status-stop-impact.js +34 -0
- package/dist/commands/status-stop-impact.js.map +1 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +48 -105
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/team-agent-apply.js +11 -11
- package/dist/commands/team-agent-apply.js.map +1 -1
- package/dist/commands/team-boot-controller.d.ts.map +1 -1
- package/dist/commands/team-boot-controller.js +21 -4
- package/dist/commands/team-boot-controller.js.map +1 -1
- package/dist/commands/team-deploy-apply.js +2 -2
- package/dist/commands/team-deploy-apply.js.map +1 -1
- package/dist/commands/team.d.ts.map +1 -1
- package/dist/commands/team.js +37 -42
- package/dist/commands/team.js.map +1 -1
- package/dist/commands/telemetry.d.ts +1 -1
- package/dist/commands/telemetry.d.ts.map +1 -1
- package/dist/commands/telemetry.js +17 -7
- package/dist/commands/telemetry.js.map +1 -1
- package/dist/commands/up-target.d.ts +7 -0
- package/dist/commands/up-target.d.ts.map +1 -0
- package/dist/commands/up-target.js +42 -0
- package/dist/commands/up-target.js.map +1 -0
- package/dist/commands/up.d.ts +5 -10
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +55 -156
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/update-caches.d.ts +4 -0
- package/dist/commands/update-caches.d.ts.map +1 -0
- package/dist/commands/update-caches.js +82 -0
- package/dist/commands/update-caches.js.map +1 -0
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +35 -121
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +5 -2
- package/dist/commands/watch.js.map +1 -1
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +3 -2
- package/dist/commands/whoami.js.map +1 -1
- package/dist/help.d.ts +1 -1
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +5 -2
- package/dist/help.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/broker-log.d.ts +8 -0
- package/dist/lib/broker-log.d.ts.map +1 -0
- package/dist/lib/broker-log.js +27 -0
- package/dist/lib/broker-log.js.map +1 -0
- package/dist/lib/choose-target.d.ts.map +1 -1
- package/dist/lib/choose-target.js +12 -9
- package/dist/lib/choose-target.js.map +1 -1
- package/dist/lib/credential-authority.d.ts.map +1 -1
- package/dist/lib/credential-authority.js +22 -5
- package/dist/lib/credential-authority.js.map +1 -1
- package/dist/lib/endpoint-errors.d.ts.map +1 -1
- package/dist/lib/endpoint-errors.js +9 -2
- package/dist/lib/endpoint-errors.js.map +1 -1
- package/dist/lib/persona-files.d.ts.map +1 -1
- package/dist/lib/persona-files.js +2 -3
- package/dist/lib/persona-files.js.map +1 -1
- package/dist/lib/restore.d.ts +2 -1
- package/dist/lib/restore.d.ts.map +1 -1
- package/dist/lib/restore.js +4 -3
- package/dist/lib/restore.js.map +1 -1
- package/dist/lib/service-preset-target.d.ts.map +1 -1
- package/dist/lib/service-preset-target.js +6 -2
- package/dist/lib/service-preset-target.js.map +1 -1
- package/dist/lib/service-presets.d.ts +2 -0
- package/dist/lib/service-presets.d.ts.map +1 -1
- package/dist/lib/service-presets.js +19 -2
- package/dist/lib/service-presets.js.map +1 -1
- package/dist/lib/spawn-defaults.d.ts +7 -0
- package/dist/lib/spawn-defaults.d.ts.map +1 -1
- package/dist/lib/spawn-defaults.js +16 -0
- package/dist/lib/spawn-defaults.js.map +1 -1
- package/dist/lib/stack-journal.d.ts +4 -4
- package/dist/lib/stack-journal.d.ts.map +1 -1
- package/dist/lib/stack-journal.js +16 -6
- package/dist/lib/stack-journal.js.map +1 -1
- package/dist/lib/store-dir.d.ts +3 -1
- package/dist/lib/store-dir.d.ts.map +1 -1
- package/dist/lib/store-dir.js +20 -4
- package/dist/lib/store-dir.js.map +1 -1
- package/dist/lib/team-deploy-inspection.d.ts +2 -1
- package/dist/lib/team-deploy-inspection.d.ts.map +1 -1
- package/dist/lib/team-deploy-inspection.js +6 -1
- package/dist/lib/team-deploy-inspection.js.map +1 -1
- package/dist/lib/up-broker-address.d.ts +7 -0
- package/dist/lib/up-broker-address.d.ts.map +1 -0
- package/dist/lib/up-broker-address.js +76 -0
- package/dist/lib/up-broker-address.js.map +1 -0
- package/dist/lib/up-report.d.ts +2 -0
- package/dist/lib/up-report.d.ts.map +1 -1
- package/dist/lib/up-report.js +8 -1
- package/dist/lib/up-report.js.map +1 -1
- package/dist/lib/update-connector-config.d.ts +6 -0
- package/dist/lib/update-connector-config.d.ts.map +1 -0
- package/dist/lib/update-connector-config.js +44 -0
- package/dist/lib/update-connector-config.js.map +1 -0
- package/dist/seed/launch.d.ts +1 -1
- package/dist/seed/launch.d.ts.map +1 -1
- package/dist/seed/launch.js +3 -3
- package/dist/seed/launch.js.map +1 -1
- package/dist/seed/reconcile.d.ts +1 -1
- package/dist/seed/reconcile.d.ts.map +1 -1
- package/dist/seed/reconcile.js +28 -11
- package/dist/seed/reconcile.js.map +1 -1
- package/package.json +4 -4
package/dist/commands/status.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { accessSync, constants, existsSync, lstatSync
|
|
1
|
+
import { accessSync, constants, existsSync, lstatSync } from "node:fs";
|
|
2
2
|
import { drainAndClose } from "@cotal-ai/core";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { CotalEndpoint, agentFilePath, dialerFor, EpEnvelopeError, formatAge, globalConfigDir, isReachable, isStreamNotFound, mintCreds, mintLifecycleUid, resolveService, realDirNoSymlink, invokeRepairingSplit, standaloneConnectOpts, newIdentity, idFromCreds, principalKey, DEV_OWNER, unansweredRequest, resolveAuthProvider, personaDir, } from "@cotal-ai/core";
|
|
6
|
-
import { stoppedLoopbackListener, UnreadableConnectorSelection, stackRunsUnderOtherHome, accountInventory, authDir, isCommandFailure, readMaintenanceJournal, recordsElsewhereError, recordsElsewhereText, restoreRolledBackRuns, targetErrorSpace, brokerAddressForDisplay, brokerCheck, brokerUrlKey, canonicalRoot, CLI_USER_ACTOR, codeSpan, credentialFileExposure, CommandFailure, deliveryCredsKey, DELIVERY_PIDFILE, extensionsDir, findCotalRoot, folderSpaceOverSelection, isGenuineSpace, meshesForRoot, resolveReadsLiveness, stoppedStack, unsettledStackOperation, withdrawOperationNote, hasUserAuthState, homeCotalDir, installationWriter, cachedPreferences, loadLaunchPersonaFile, resolvePreference, isMeshRegistryError, isWorkspaceTargetError, jsonFlag, loadManagerInstanceIdentity, loadSoleSpaceAuth, localProcessPath, localProcessVisible, MANAGER_PIDFILE, NATS_PIDFILE, OFFICIAL_CONNECTORS, oneLine,
|
|
6
|
+
import { stoppedLoopbackListener, UnreadableConnectorSelection, stackRunsUnderOtherHome, accountInventory, authDir, isCommandFailure, readMaintenanceJournal, recordsElsewhereError, recordsElsewhereText, restoreRolledBackRuns, targetErrorSpace, brokerAddressForDisplay, brokerCheck, brokerUrlKey, canonicalRoot, CLI_USER_ACTOR, codeSpan, credentialFileExposure, CommandFailure, deliveryCredsKey, DELIVERY_PIDFILE, extensionsDir, findCotalRoot, folderSpaceOverSelection, isGenuineSpace, meshesForRoot, resolveReadsLiveness, stoppedStack, unsettledStackOperation, withdrawOperationNote, hasUserAuthState, homeCotalDir, installationWriter, cachedPreferences, loadLaunchPersonaFile, resolvePreference, isMeshRegistryError, isWorkspaceTargetError, jsonFlag, loadManagerInstanceIdentity, loadSoleSpaceAuth, localProcessPath, localProcessVisible, MANAGER_PIDFILE, NATS_PIDFILE, OFFICIAL_CONNECTORS, oneLine, PREFERENCE_KEYS, plainFlag, preflightTarget, preparedNeverStarted, presentationOf, principalFromBearer, verifyIdentityPin, probeWebReadiness, readCurrent, readMeshRegistry, readPidfile, preparedRecordSkipped, readPreparedSpaces, stackJournalPath, readRenewalRecord, recordOperationSpace, resolveMeshTarget, serverFlag, spaceFlag, userAuthStateDir, WEB_PIDFILE, workspaceSecretStore, displayWidth, terminalWidth, wrapWords, writeResult, workspaceErrorParts, preferencesPath, preferencesFolderWarning, cotalDirLink, movedProject, spaceStreamsAbsent, spaceStreamsExpected, resolveControlTarget, } from "@cotal-ai/workspace";
|
|
7
7
|
import { localProcessSurface } from "../ext-loader.js";
|
|
8
8
|
import { cliVersion, cliProvenance, readExtensionVersions } from "../lib/version.js";
|
|
9
9
|
import { agentSkillsSkew } from "../lib/agent-skills.js";
|
|
10
|
-
import { managerHasDeliveryMarker
|
|
10
|
+
import { managerHasDeliveryMarker } from "../lib/manager-proc.js";
|
|
11
11
|
import { MANAGER_OMITTED } from "../lib/delivery-proc.js";
|
|
12
12
|
import { signedInSpace } from "../lib/conversation-identity.js";
|
|
13
|
-
import { connectorHarnesses, connectorStatusRows, machineStatus, recordedWebUrl,
|
|
14
|
-
import {
|
|
13
|
+
import { connectorHarnesses, connectorStatusRows, machineStatus, recordedWebUrl, webBoundAddress, webInstalled, webSessionSource } from "../lib/status.js";
|
|
14
|
+
import { legacyManagerStopped, statusRuntimeSpace } from "./status-legacy.js";
|
|
15
|
+
import { deliveryResponderFromLease, deliveryResponderState, deliveryRowSuffix, RESPONDER_UNBOUND_CONSEQUENCE } from "../lib/delivery-responder.js";
|
|
15
16
|
import { brokerStoreWrite, storeFull, storeWriteRepair } from "../lib/broker-store-health.js";
|
|
16
17
|
import { chatStreamGone, stackState } from "../lib/space-streams.js";
|
|
17
18
|
import { pidfileState } from "./down.js";
|
|
@@ -41,6 +42,8 @@ import { natsServerLabel } from "../lib/nats-bin.js";
|
|
|
41
42
|
import { askManager } from "@cotal-ai/workspace/control";
|
|
42
43
|
import { readCursor } from "../seed/lock.js";
|
|
43
44
|
import { reconcileCursorPath } from "../seed/paths.js";
|
|
45
|
+
import { managerStopImpactFacts } from "./status-stop-impact.js";
|
|
46
|
+
import { responderText } from "./status-delivery.js";
|
|
44
47
|
/** `--components` is the fail-loud health pass with a machine-readable EXIT DISPOSITION. Bare
|
|
45
48
|
* `status` is a broad, recovery-oriented report: it exits 0, or 4 when it could not read part of what
|
|
46
49
|
* it reports; this explicit mode is for an operator or monitor that needs a component state per
|
|
@@ -244,7 +247,7 @@ export async function status(args) {
|
|
|
244
247
|
const target = await readSelected(selected, responder, folder, gaps, selectedHints, preflight, Boolean(values.all));
|
|
245
248
|
// Do not offer the conditional store reset when this folder needs a channel seed repair first,
|
|
246
249
|
// while a maintenance journal holds the store, or if the store is unwritable.
|
|
247
|
-
if (folder.storedState && folder.processSpace !== null && maintenance === null && !(target.channelSeedBlocksRestart && target.root === root) && !rootStoreProblem(root)) {
|
|
250
|
+
if ((target.resolved || target.code !== "SCHEMA_INVALID") && folder.storedState && folder.processSpace !== null && maintenance === null && !(target.channelSeedBlocksRestart && target.root === root) && !rootStoreProblem(root)) {
|
|
248
251
|
const reset = storeResetTarget(root, folder.processSpace);
|
|
249
252
|
// An explicit address is not evidence about a different broker's store.
|
|
250
253
|
if (values.server === undefined || (reset && selected.ok && selected.target.space === reset.space
|
|
@@ -323,7 +326,7 @@ export async function status(args) {
|
|
|
323
326
|
recovery,
|
|
324
327
|
}));
|
|
325
328
|
if (values.components)
|
|
326
|
-
await printComponentHealth(selected, store);
|
|
329
|
+
await printComponentHealth(selected, store, target.resolved && target.connection === "unreachable");
|
|
327
330
|
}
|
|
328
331
|
/** Why this account cannot list or search `root`, or undefined when it can. */
|
|
329
332
|
function folderReadProblem(root) {
|
|
@@ -749,7 +752,7 @@ async function readFolder(root, selected, values, responder, gaps, hints) {
|
|
|
749
752
|
// report that state and stop rather than crashing in the recovery command that names it.
|
|
750
753
|
let space;
|
|
751
754
|
try {
|
|
752
|
-
space = auth?.space ??
|
|
755
|
+
space = auth?.space ?? statusRuntimeSpace(root, selected.ok ? selected.target : undefined);
|
|
753
756
|
}
|
|
754
757
|
catch (e) {
|
|
755
758
|
hints.push(e.message);
|
|
@@ -822,7 +825,7 @@ async function readFolder(root, selected, values, responder, gaps, hints) {
|
|
|
822
825
|
const managerIndex = !unusable && !controllerStack && (nats?.liveness === "alive" || nats?.liveness === "dead")
|
|
823
826
|
? processes.findIndex((row) => row.name === "manager" && row.state === "stopped" && row.pid === null)
|
|
824
827
|
: -1;
|
|
825
|
-
if (managerIndex !== -1 && legacyManagerStopped(root, space))
|
|
828
|
+
if (managerIndex !== -1 && legacyManagerStopped(root, space, localManagerInstanceId(root, space)))
|
|
826
829
|
processes[managerIndex] = { ...processes[managerIndex], detail: "stopped" };
|
|
827
830
|
const noManager = journal !== undefined && controllerStack && stackStartedWithoutManager(journal);
|
|
828
831
|
// An operation cut off with no recorded outcome can keep up and down from settling it; status names
|
|
@@ -1067,28 +1070,6 @@ function localManagerInstanceId(root, space) {
|
|
|
1067
1070
|
return undefined;
|
|
1068
1071
|
}
|
|
1069
1072
|
}
|
|
1070
|
-
/** Whether the legacy stack whose broker pidfile is in `root` started a manager that has since
|
|
1071
|
-
* exited and removed its pidfile (as SIGTERM does), rather than running with `--no-manager`. */
|
|
1072
|
-
function legacyManagerStopped(root, space) {
|
|
1073
|
-
const id = localManagerInstanceId(root, space);
|
|
1074
|
-
if (id === undefined)
|
|
1075
|
-
return false;
|
|
1076
|
-
let brokerMtime;
|
|
1077
|
-
try {
|
|
1078
|
-
brokerMtime = statSync(join(root, ".cotal", NATS_PIDFILE), { bigint: true }).mtimeNs;
|
|
1079
|
-
}
|
|
1080
|
-
catch {
|
|
1081
|
-
return false;
|
|
1082
|
-
}
|
|
1083
|
-
for (const path of [managerLogPath(space, root), join(root, ".cotal", `manager-execution.${spaceKey(space)}.${id}.json`)]) {
|
|
1084
|
-
try {
|
|
1085
|
-
if (statSync(path, { bigint: true }).mtimeNs >= brokerMtime)
|
|
1086
|
-
return true;
|
|
1087
|
-
}
|
|
1088
|
-
catch { /* absent or unreadable candidate */ }
|
|
1089
|
-
}
|
|
1090
|
-
return false;
|
|
1091
|
-
}
|
|
1092
1073
|
/** User-mode manager status goes through the same control call `cotal spawn` uses. `instanceId`
|
|
1093
1074
|
* pins that call to this machine's manager. Without it, the exchange may select another live
|
|
1094
1075
|
* manager of the same owner. */
|
|
@@ -1310,6 +1291,12 @@ async function readSelected(selected, responder, folder, gaps, hints, preflight,
|
|
|
1310
1291
|
const cmd = displayCmd();
|
|
1311
1292
|
if (!selected.ok) {
|
|
1312
1293
|
const e = selected.error;
|
|
1294
|
+
if (isCommandFailure(e) && e.code === "SCHEMA_INVALID") {
|
|
1295
|
+
gaps.add(e.code, e.message, e.target);
|
|
1296
|
+
if (e.remedy)
|
|
1297
|
+
hints.push(e.remedy);
|
|
1298
|
+
return { resolved: false, code: e.code, message: e.message };
|
|
1299
|
+
}
|
|
1313
1300
|
// Resolution reads the whole registry and refuses a directory or record it cannot use. The meshes
|
|
1314
1301
|
// reader has already named it, so this is the same gap, and the selection is unresolved.
|
|
1315
1302
|
if (isMeshRegistryError(e)) {
|
|
@@ -1463,7 +1450,7 @@ async function readSelected(selected, responder, folder, gaps, hints, preflight,
|
|
|
1463
1450
|
const store = offline ? rootStoreProblem(target.root) : undefined;
|
|
1464
1451
|
let seedBlock;
|
|
1465
1452
|
// A blocked stack refuses that `up`, and Next names the step that clears the block instead.
|
|
1466
|
-
if (preflight.kind === "unreachable" && (overridden || offline) && !(servedStack(folder, base) && folder.stackBlock)) {
|
|
1453
|
+
if (preflight.kind === "unreachable" && (overridden || offline || target.origin === "manual") && !(servedStack(folder, base) && folder.stackBlock)) {
|
|
1467
1454
|
const { message, remedy, restartRoot } = workspaceErrorParts({ kind: "preflight", failure: "unreachable", target, pruned: !offline && preflight.prune });
|
|
1468
1455
|
seedBlock = store || restartRoot === undefined ? undefined : channelSeedRestartBlock(restartRoot);
|
|
1469
1456
|
if (store)
|
|
@@ -1730,30 +1717,6 @@ function meshesSections(m) {
|
|
|
1730
1717
|
sections.push({ title: "Space Catalog Accounts", blocks: [{ kind: "lines", lines: m.catalogs.map((r) => `${r.idp} ${r.state}${r.error ? `: ${r.error}` : ""}`) }] });
|
|
1731
1718
|
return sections;
|
|
1732
1719
|
}
|
|
1733
|
-
/** The selected space's delivery responder (#1576). Bare status and the verbose mesh section both
|
|
1734
|
-
* state it, so an operator on a manager host away from the broker's folder still sees it. An open
|
|
1735
|
-
* mesh runs no delivery daemon, so with no lease recorded its row says the responder is not used
|
|
1736
|
-
* rather than unbound. */
|
|
1737
|
-
function responderText(state, mode, stackBlocked = false, deliveryPid, storeFull = false) {
|
|
1738
|
-
if (state === null && mode === "open")
|
|
1739
|
-
return { text: "not used - an open mesh runs no delivery daemon", tone: "hint" };
|
|
1740
|
-
// A running delivery member with no lease is starting or not responding. Status cannot ask it which,
|
|
1741
|
-
// and `up` starts no second daemon beside it.
|
|
1742
|
-
if (state === "unbound" && deliveryPid !== undefined)
|
|
1743
|
-
return { text: `no lease · stack-delivery pid ${deliveryPid} is alive but holds no lease, so it is starting or not responding`, tone: "failed" };
|
|
1744
|
-
// While this folder's stack is blocked, `up` refuses, so the row names the block Next clears. A full
|
|
1745
|
-
// store refuses the daemon's lease as every other write, so `up` starts it only once there is room.
|
|
1746
|
-
if (state === "unbound")
|
|
1747
|
-
return { text: `NOT BOUND - ${RESPONDER_UNBOUND_CONSEQUENCE} · ${stackBlocked ? `\`${displayCmd()} up\` refuses until the stack block is cleared, as Next shows` : storeFull ? `the full store refuses its lease, so \`${displayCmd()} up\` starts it only once there is room, as Next shows` : `start it with \`${displayCmd()} up\``}`, tone: "failed" };
|
|
1748
|
-
// A stale record is NOT BOUND with a different next move: the slot is occupied by a corpse, so
|
|
1749
|
-
// starting a daemon now loses the single-flight CAS. Say that, rather than sending the operator
|
|
1750
|
-
// into a refusal they will read as a second failure.
|
|
1751
|
-
if (state === "stale")
|
|
1752
|
-
return { text: `NOT BOUND - ${RESPONDER_STALE_TEXT} · \`${displayCmd()} up\` restarts it, after waiting out the lease`, tone: "failed" };
|
|
1753
|
-
if (state === "bound")
|
|
1754
|
-
return { text: "bound", tone: "ok" };
|
|
1755
|
-
return undefined;
|
|
1756
|
-
}
|
|
1757
1720
|
/** The pid of the selected space's running stack delivery member, from its owned service record. */
|
|
1758
1721
|
function stackDeliveryPid(r) {
|
|
1759
1722
|
return r.services?.instances?.find((item) => item.definition === STACK_DEFINITION.delivery && item.observedProcess === "running")?.pid ?? undefined;
|
|
@@ -2151,16 +2114,16 @@ function nextActions(r, seedFailed, interactive, recovery, preparedHarness) {
|
|
|
2151
2114
|
}
|
|
2152
2115
|
if (r.selected.resolved) {
|
|
2153
2116
|
const s = r.selected;
|
|
2117
|
+
const reachable = s.connection === "ok" || s.connection === "reachable";
|
|
2154
2118
|
// Name what fixes the default persona alone; setup does far more than that.
|
|
2155
2119
|
if (!noApplication) {
|
|
2156
|
-
if (s.personas.default
|
|
2157
|
-
items.push({ command: `${cmd} spawn`, description: "Open your default agent; creates the shipped default persona" });
|
|
2158
|
-
else if (s.personas.default !== "valid")
|
|
2120
|
+
if (s.personas.default !== "missing" && s.personas.default !== "valid")
|
|
2159
2121
|
items.push({ command: `${cmd} persona show default --space ${shellWord(s.space)}`, description: "See what is wrong with the default persona" });
|
|
2160
|
-
else
|
|
2161
|
-
items.push({ command: `${cmd} spawn`, description: "Open your default agent" });
|
|
2122
|
+
else if (reachable && s.deliveryResponder !== "unbound" && s.deliveryResponder !== "stale")
|
|
2123
|
+
items.push({ command: `${cmd} spawn`, description: s.personas.default === "missing" ? "Open your default agent; creates the shipped default persona" : "Open your default agent" });
|
|
2162
2124
|
}
|
|
2163
|
-
|
|
2125
|
+
if (reachable)
|
|
2126
|
+
items.push({ command: `${cmd} who`, description: "See the live roster" });
|
|
2164
2127
|
if (r.stackManager?.endpoint === "answered" || r.outsideStackManager?.endpoint === "answered")
|
|
2165
2128
|
items.push({ command: `${cmd} ps`, description: "List managed agents" });
|
|
2166
2129
|
}
|
|
@@ -2189,12 +2152,10 @@ function nextActions(r, seedFailed, interactive, recovery, preparedHarness) {
|
|
|
2189
2152
|
// This folder's own stack is blocked the same way under another selection, and its block leads too.
|
|
2190
2153
|
const blocked = stack ?? folderStack(r.folder, r.selected);
|
|
2191
2154
|
const block = blocked ? r.folder.stackBlock : undefined;
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
const
|
|
2196
|
-
&& !["manual", "catalog"].includes(r.meshes.items.find((m) => m.space === r.selected.space)?.origin ?? "up");
|
|
2197
|
-
const exited = local ? (r.folder.processes ?? []).filter((row) => (row.name === "nats" || row.name === "manager") && row.state === "stopped" && (row.pid !== null || row.detail === "stopped")).map((row) => row.name) : [];
|
|
2155
|
+
const origin = r.meshes.items.find((m) => m.space === dialed?.space)?.origin;
|
|
2156
|
+
const legacy = dialed && !r.folder.controllerStack && r.folder.root === dialed.root && r.folder.processSpace === dialed.space;
|
|
2157
|
+
const local = legacy && dialed.mode === "auth" && !["manual", "catalog"].includes(origin ?? "up");
|
|
2158
|
+
const exited = legacy ? (r.folder.processes ?? []).filter((row) => (row.name === "nats" || row.name === "manager") && row.state === "stopped" && (row.pid !== null || row.detail === "stopped")).map((row) => row.name) : [];
|
|
2198
2159
|
const storeBlocked = !elsewhere && r.selected.resolved && r.selected.connection === "unreachable" && rootStoreProblem(r.selected.root) !== undefined;
|
|
2199
2160
|
if (r.selected.resolved && r.selected.connection === "broker-stopped")
|
|
2200
2161
|
items.unshift({ command: `kill -CONT ${r.selected.brokerPid}`, description: "Resume the stopped broker process so it answers again" });
|
|
@@ -2232,7 +2193,10 @@ function nextActions(r, seedFailed, interactive, recovery, preparedHarness) {
|
|
|
2232
2193
|
const held = r.folder.heldServices ?? [], space = r.selected.space;
|
|
2233
2194
|
items.unshift(...held.map((row) => ({ command: `${cmd} svc stop ${row.definition} --instance ${row.instanceId} --space ${shellWord(space)} --yes`, description: `Stop the ${row.definition} service, which runs this root's ${row.record} (pid ${row.pid}) outside the stack` })), { command: `${cmd} up --root ${shellWord(r.selected.root)}${r.folder.noManager ? " --no-manager" : ""}`, description: held.length ? "Then restart this stack's stopped members from its recorded inputs" : "Restart this stack's stopped members from its recorded inputs" });
|
|
2234
2195
|
}
|
|
2235
|
-
else if (!
|
|
2196
|
+
else if (!elsewhere && legacy && dialed.mode === "open" && origin === "up" && exited.includes("manager") && r.folder.processes?.some((row) => row.name === "nats" && row.state === "running")) {
|
|
2197
|
+
items.unshift({ command: `${cmd} down --yes`, description: "Stop this folder's broker so the exited manager can be restarted" }, { command: `${cmd} up --foreground`, description: "Then start the stack with its manager" });
|
|
2198
|
+
}
|
|
2199
|
+
else if (!storeBlocked && !seedBlocksRestart && local && exited.length) {
|
|
2236
2200
|
const broker = exited.includes("nats"), manager = exited.includes("manager");
|
|
2237
2201
|
const notes = [...(broker ? ["up reopens the recorded store"] : []), ...(manager ? ["pass --runtime again if the manager ran on one"] : [])];
|
|
2238
2202
|
items.unshift({ command: `${cmd} up`, description: `Restart this folder's ${broker && manager ? "broker and manager" : broker ? "broker" : "manager"}, which exited; ${notes.join("; ")}` });
|
|
@@ -2242,6 +2206,11 @@ function nextActions(r, seedFailed, interactive, recovery, preparedHarness) {
|
|
|
2242
2206
|
// bare `up` that starts it again on its recorded address and store comes first.
|
|
2243
2207
|
items.unshift({ command: `${cmd} up`, description: "Start this folder's stopped stack again; pass --runtime again if the manager ran on one" });
|
|
2244
2208
|
}
|
|
2209
|
+
else if (!seedBlocksRestart && !elsewhere && local && r.selected.resolved && r.selected.connection === "ok" && r.store?.state !== "full" && r.store?.state !== "write-failed"
|
|
2210
|
+
&& (r.selected.deliveryResponder === "unbound" || r.selected.deliveryResponder === "stale")
|
|
2211
|
+
&& r.folder.processes?.some((row) => row.name === "delivery" && row.state === "stopped")) {
|
|
2212
|
+
items.unshift({ command: `${cmd} up`, description: "Restore the delivery responder" });
|
|
2213
|
+
}
|
|
2245
2214
|
// A stack whose folder was deleted stops only from this machine's records.
|
|
2246
2215
|
if (r.selected.resolved && r.selected.rootGone)
|
|
2247
2216
|
items.unshift({ command: `${cmd} down --space ${shellWord(r.selected.space)} --yes`, description: "Stop the stack whose folder is gone and free its name" });
|
|
@@ -2496,39 +2465,6 @@ async function staticServiceAuth(auth) {
|
|
|
2496
2465
|
caller: { owner: "local", actor: serviceIdentity.id, uid: serviceUid },
|
|
2497
2466
|
};
|
|
2498
2467
|
}
|
|
2499
|
-
/** Display only. A status observation never authorizes process control or proves cleanup. */
|
|
2500
|
-
function managerStopImpactFacts(input) {
|
|
2501
|
-
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
2502
|
-
return ["stop impact not reported by this manager build"];
|
|
2503
|
-
const impact = input;
|
|
2504
|
-
if (!["manager", "owner-filtered"].includes(String(impact.agentScope)) || typeof impact.observedAt !== "string" || impact.observedAt.length > 100 || !Number.isFinite(Date.parse(impact.observedAt)) || !Array.isArray(impact.agents))
|
|
2505
|
-
return ["stop impact could not be interpreted; no safe stop inferred"];
|
|
2506
|
-
const facts = [`stop impact ${impact.agentScope === "manager" ? "manager-owned rows" : "owner-filtered; full scope unknown"} as of ${new Date(impact.observedAt).toISOString()}`];
|
|
2507
|
-
const actions = { stop: 0, release: 0, retained: 0, unknown: 0 };
|
|
2508
|
-
for (const row of impact.agents) {
|
|
2509
|
-
const action = row && typeof row === "object" && !Array.isArray(row) ? row.defaultAction : undefined;
|
|
2510
|
-
if (action === "stop")
|
|
2511
|
-
actions.stop++;
|
|
2512
|
-
else if (action === "release-custody")
|
|
2513
|
-
actions.release++;
|
|
2514
|
-
else if (action === "stop-retaining-state")
|
|
2515
|
-
actions.retained++;
|
|
2516
|
-
else
|
|
2517
|
-
actions.unknown++;
|
|
2518
|
-
}
|
|
2519
|
-
facts.push(`default stop policy: stop ${actions.stop}, release custody ${actions.release}, stop retaining state ${actions.retained}, unknown ${actions.unknown} visible seats`);
|
|
2520
|
-
for (const [key, label] of [["lifecycleInFlight", "lifecycle work"], ["reservedLaunches", "reserved launches"], ["retirementsPending", "pending retirements"], ["deprovisioningInFlight", "cleanup in flight"], ["staticReconciliationInFlight", "reconciliation in flight"]]) {
|
|
2521
|
-
const count = impact[key];
|
|
2522
|
-
if (!Number.isSafeInteger(count) || Number(count) < 0)
|
|
2523
|
-
facts.push(`${label} unknown`);
|
|
2524
|
-
else if (Number(count) > 0)
|
|
2525
|
-
facts.push(`${label} ${count}`);
|
|
2526
|
-
}
|
|
2527
|
-
if (impact.stopping === true)
|
|
2528
|
-
facts.push("native manager stop already in progress");
|
|
2529
|
-
facts.push("stop not reserved; seat exit and cleanup not checked");
|
|
2530
|
-
return facts;
|
|
2531
|
-
}
|
|
2532
2468
|
/** A service registration is the health target itself. Calling its `status` command through a
|
|
2533
2469
|
* generic endpoint does not work on this base because a passive status endpoint has no v0.4 caller
|
|
2534
2470
|
* rail; a one-shot standalone caller does. */
|
|
@@ -2683,7 +2619,7 @@ export function deliveryLeaseAbsent(e) {
|
|
|
2683
2619
|
/** Delivery owns two answers: its ready lease is its liveness/control surface; its latest explicit
|
|
2684
2620
|
* adoption report is the renewal record it writes through the manager-owned renewal pass. The
|
|
2685
2621
|
* latter is intentionally not inferred from credential mtime or process output. */
|
|
2686
|
-
async function deliveryHealth(target, context, credential) {
|
|
2622
|
+
async function deliveryHealth(target, context, credential, brokerOffline) {
|
|
2687
2623
|
const record = processRecord(DELIVERY_PIDFILE, context);
|
|
2688
2624
|
const facts = pidFacts(record);
|
|
2689
2625
|
const stopped = processVerdict(record);
|
|
@@ -2704,6 +2640,8 @@ async function deliveryHealth(target, context, credential) {
|
|
|
2704
2640
|
facts.push(renewal.adoption.ok ? "renewal adoption accepted" : `renewal adoption refused${renewal.adoption.error ? `: ${renewal.adoption.error}` : ""}`);
|
|
2705
2641
|
const renewalRefused = renewal?.adoption?.ok === false;
|
|
2706
2642
|
if (target.mode === "open" && record.kind === "absent" && !renewalRefused) {
|
|
2643
|
+
if (brokerOffline)
|
|
2644
|
+
return { name: "delivery", verdict: "not-started", facts: ["not used on an open mesh"] };
|
|
2707
2645
|
if (credential.kind === "unavailable")
|
|
2708
2646
|
return { name: "delivery", verdict: "refused", facts: [credential.reason] };
|
|
2709
2647
|
try {
|
|
@@ -2901,10 +2839,15 @@ async function brokerHealth(target, store) {
|
|
|
2901
2839
|
return { name: "broker", verdict: "refused", facts: [`registered ${address}`, `probe refused: ${e.message}`] };
|
|
2902
2840
|
}
|
|
2903
2841
|
}
|
|
2904
|
-
async function printComponentHealth(selected, store) {
|
|
2842
|
+
async function printComponentHealth(selected, store, brokerUnreachable) {
|
|
2905
2843
|
section("Component Health");
|
|
2906
2844
|
if (!selected.ok) {
|
|
2907
2845
|
const e = selected.error;
|
|
2846
|
+
if (isCommandFailure(e) && e.code === "SCHEMA_INVALID") {
|
|
2847
|
+
printComponent({ name: "target", verdict: "refused", facts: [e.code, e.message, ...(e.remedy ? [e.remedy] : [])] });
|
|
2848
|
+
process.exitCode = COMPONENT_EXIT.refused;
|
|
2849
|
+
return;
|
|
2850
|
+
}
|
|
2908
2851
|
if (isMeshRegistryError(e)) {
|
|
2909
2852
|
printComponent({ name: "target", verdict: "refused", facts: ["SCHEMA_INVALID", e.message] });
|
|
2910
2853
|
process.exitCode = COMPONENT_EXIT.refused;
|
|
@@ -2933,7 +2876,7 @@ async function printComponentHealth(selected, store) {
|
|
|
2933
2876
|
const broker = await brokerHealth(target, store);
|
|
2934
2877
|
const components = await Promise.all([
|
|
2935
2878
|
managerHealth(target, context, credential, broker),
|
|
2936
|
-
deliveryHealth(target, context, credential),
|
|
2879
|
+
deliveryHealth(target, context, credential, brokerUnreachable && broker.verdict === "absent"),
|
|
2937
2880
|
webHealth(context),
|
|
2938
2881
|
broker,
|
|
2939
2882
|
]);
|