@cotal-ai/cli 0.99.3 → 0.100.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.
Files changed (241) hide show
  1. package/dist/chat/chat-view.d.ts.map +1 -1
  2. package/dist/chat/chat-view.js +9 -1
  3. package/dist/chat/chat-view.js.map +1 -1
  4. package/dist/chat/controller.d.ts.map +1 -1
  5. package/dist/chat/controller.js +6 -2
  6. package/dist/chat/controller.js.map +1 -1
  7. package/dist/chat/native-session.d.ts +8 -0
  8. package/dist/chat/native-session.d.ts.map +1 -1
  9. package/dist/chat/native-session.js +31 -6
  10. package/dist/chat/native-session.js.map +1 -1
  11. package/dist/chat/plain.d.ts.map +1 -1
  12. package/dist/chat/plain.js +33 -7
  13. package/dist/chat/plain.js.map +1 -1
  14. package/dist/chat/session.d.ts +3 -0
  15. package/dist/chat/session.d.ts.map +1 -1
  16. package/dist/chat/static-session.d.ts.map +1 -1
  17. package/dist/chat/static-session.js +2 -1
  18. package/dist/chat/static-session.js.map +1 -1
  19. package/dist/chat/stdio-io.js +2 -2
  20. package/dist/chat/stdio-io.js.map +1 -1
  21. package/dist/chat/stdio.d.ts +9 -2
  22. package/dist/chat/stdio.d.ts.map +1 -1
  23. package/dist/chat/stdio.js +33 -13
  24. package/dist/chat/stdio.js.map +1 -1
  25. package/dist/chat/view.d.ts +16 -4
  26. package/dist/chat/view.d.ts.map +1 -1
  27. package/dist/chat/view.js +21 -8
  28. package/dist/chat/view.js.map +1 -1
  29. package/dist/command.d.ts.map +1 -1
  30. package/dist/command.js +51 -8
  31. package/dist/command.js.map +1 -1
  32. package/dist/commands/agents.d.ts.map +1 -1
  33. package/dist/commands/agents.js +3 -2
  34. package/dist/commands/agents.js.map +1 -1
  35. package/dist/commands/backup-maintenance.d.ts.map +1 -1
  36. package/dist/commands/backup-maintenance.js +75 -16
  37. package/dist/commands/backup-maintenance.js.map +1 -1
  38. package/dist/commands/backup-read.d.ts.map +1 -1
  39. package/dist/commands/backup-read.js +14 -1
  40. package/dist/commands/backup-read.js.map +1 -1
  41. package/dist/commands/backup-restore.d.ts.map +1 -1
  42. package/dist/commands/backup-restore.js +4 -1
  43. package/dist/commands/backup-restore.js.map +1 -1
  44. package/dist/commands/backup.d.ts.map +1 -1
  45. package/dist/commands/backup.js +51 -11
  46. package/dist/commands/backup.js.map +1 -1
  47. package/dist/commands/channel-members.d.ts.map +1 -1
  48. package/dist/commands/channel-members.js +6 -3
  49. package/dist/commands/channel-members.js.map +1 -1
  50. package/dist/commands/channels.d.ts.map +1 -1
  51. package/dist/commands/channels.js +12 -9
  52. package/dist/commands/channels.js.map +1 -1
  53. package/dist/commands/chat.d.ts +4 -3
  54. package/dist/commands/chat.d.ts.map +1 -1
  55. package/dist/commands/chat.js +6 -3
  56. package/dist/commands/chat.js.map +1 -1
  57. package/dist/commands/clean.d.ts +4 -3
  58. package/dist/commands/clean.d.ts.map +1 -1
  59. package/dist/commands/clean.js +24 -14
  60. package/dist/commands/clean.js.map +1 -1
  61. package/dist/commands/completion.d.ts.map +1 -1
  62. package/dist/commands/completion.js +3 -1
  63. package/dist/commands/completion.js.map +1 -1
  64. package/dist/commands/config.d.ts +7 -0
  65. package/dist/commands/config.d.ts.map +1 -1
  66. package/dist/commands/config.js +42 -7
  67. package/dist/commands/config.js.map +1 -1
  68. package/dist/commands/console.js +1 -1
  69. package/dist/commands/console.js.map +1 -1
  70. package/dist/commands/doctor.d.ts.map +1 -1
  71. package/dist/commands/doctor.js +27 -7
  72. package/dist/commands/doctor.js.map +1 -1
  73. package/dist/commands/down.d.ts +3 -2
  74. package/dist/commands/down.d.ts.map +1 -1
  75. package/dist/commands/down.js +97 -19
  76. package/dist/commands/down.js.map +1 -1
  77. package/dist/commands/endpoints.js +4 -2
  78. package/dist/commands/endpoints.js.map +1 -1
  79. package/dist/commands/ext.js +1 -1
  80. package/dist/commands/ext.js.map +1 -1
  81. package/dist/commands/join.d.ts.map +1 -1
  82. package/dist/commands/join.js +17 -7
  83. package/dist/commands/join.js.map +1 -1
  84. package/dist/commands/meshes-add.d.ts.map +1 -1
  85. package/dist/commands/meshes-add.js +12 -6
  86. package/dist/commands/meshes-add.js.map +1 -1
  87. package/dist/commands/models.d.ts.map +1 -1
  88. package/dist/commands/models.js +3 -1
  89. package/dist/commands/models.js.map +1 -1
  90. package/dist/commands/persona.d.ts.map +1 -1
  91. package/dist/commands/persona.js +8 -1
  92. package/dist/commands/persona.js.map +1 -1
  93. package/dist/commands/personas.d.ts.map +1 -1
  94. package/dist/commands/personas.js +20 -9
  95. package/dist/commands/personas.js.map +1 -1
  96. package/dist/commands/reset-store-apply.d.ts.map +1 -1
  97. package/dist/commands/reset-store-apply.js +22 -7
  98. package/dist/commands/reset-store-apply.js.map +1 -1
  99. package/dist/commands/reset.js +1 -1
  100. package/dist/commands/reset.js.map +1 -1
  101. package/dist/commands/send.d.ts +1 -1
  102. package/dist/commands/send.d.ts.map +1 -1
  103. package/dist/commands/send.js +28 -11
  104. package/dist/commands/send.js.map +1 -1
  105. package/dist/commands/setup.js +3 -3
  106. package/dist/commands/setup.js.map +1 -1
  107. package/dist/commands/space-delete.d.ts.map +1 -1
  108. package/dist/commands/space-delete.js +31 -6
  109. package/dist/commands/space-delete.js.map +1 -1
  110. package/dist/commands/space-registration.d.ts +3 -1
  111. package/dist/commands/space-registration.d.ts.map +1 -1
  112. package/dist/commands/space-registration.js +85 -16
  113. package/dist/commands/space-registration.js.map +1 -1
  114. package/dist/commands/space.d.ts +1 -1
  115. package/dist/commands/space.js +1 -1
  116. package/dist/commands/space.js.map +1 -1
  117. package/dist/commands/stack-down.d.ts +3 -2
  118. package/dist/commands/stack-down.d.ts.map +1 -1
  119. package/dist/commands/stack-down.js +19 -10
  120. package/dist/commands/stack-down.js.map +1 -1
  121. package/dist/commands/stack-up.d.ts.map +1 -1
  122. package/dist/commands/stack-up.js +68 -20
  123. package/dist/commands/stack-up.js.map +1 -1
  124. package/dist/commands/status.d.ts +5 -1
  125. package/dist/commands/status.d.ts.map +1 -1
  126. package/dist/commands/status.js +134 -46
  127. package/dist/commands/status.js.map +1 -1
  128. package/dist/commands/team-boot-controller.d.ts.map +1 -1
  129. package/dist/commands/team-boot-controller.js +3 -1
  130. package/dist/commands/team-boot-controller.js.map +1 -1
  131. package/dist/commands/team.d.ts.map +1 -1
  132. package/dist/commands/team.js +28 -6
  133. package/dist/commands/team.js.map +1 -1
  134. package/dist/commands/telemetry.d.ts +3 -1
  135. package/dist/commands/telemetry.d.ts.map +1 -1
  136. package/dist/commands/telemetry.js +9 -3
  137. package/dist/commands/telemetry.js.map +1 -1
  138. package/dist/commands/up.d.ts +6 -3
  139. package/dist/commands/up.d.ts.map +1 -1
  140. package/dist/commands/up.js +230 -40
  141. package/dist/commands/up.js.map +1 -1
  142. package/dist/commands/use.d.ts.map +1 -1
  143. package/dist/commands/use.js +4 -1
  144. package/dist/commands/use.js.map +1 -1
  145. package/dist/commands/watch.d.ts.map +1 -1
  146. package/dist/commands/watch.js +11 -5
  147. package/dist/commands/watch.js.map +1 -1
  148. package/dist/console/mesh.d.ts +6 -1
  149. package/dist/console/mesh.d.ts.map +1 -1
  150. package/dist/console/mesh.js +18 -2
  151. package/dist/console/mesh.js.map +1 -1
  152. package/dist/help.d.ts.map +1 -1
  153. package/dist/help.js +14 -6
  154. package/dist/help.js.map +1 -1
  155. package/dist/index.d.ts.map +1 -1
  156. package/dist/index.js +9 -2
  157. package/dist/index.js.map +1 -1
  158. package/dist/lib/completion-install.d.ts.map +1 -1
  159. package/dist/lib/completion-install.js +78 -11
  160. package/dist/lib/completion-install.js.map +1 -1
  161. package/dist/lib/control.d.ts +6 -0
  162. package/dist/lib/control.d.ts.map +1 -1
  163. package/dist/lib/control.js +16 -1
  164. package/dist/lib/control.js.map +1 -1
  165. package/dist/lib/default-persona.js +1 -1
  166. package/dist/lib/default-persona.js.map +1 -1
  167. package/dist/lib/endpoint-errors.d.ts +2 -0
  168. package/dist/lib/endpoint-errors.d.ts.map +1 -1
  169. package/dist/lib/endpoint-errors.js +13 -7
  170. package/dist/lib/endpoint-errors.js.map +1 -1
  171. package/dist/lib/interrupt-notice.d.ts +5 -0
  172. package/dist/lib/interrupt-notice.d.ts.map +1 -0
  173. package/dist/lib/interrupt-notice.js +23 -0
  174. package/dist/lib/interrupt-notice.js.map +1 -0
  175. package/dist/lib/isolated-broker.d.ts +5 -0
  176. package/dist/lib/isolated-broker.d.ts.map +1 -1
  177. package/dist/lib/isolated-broker.js +36 -0
  178. package/dist/lib/isolated-broker.js.map +1 -1
  179. package/dist/lib/legacy-start.d.ts +17 -0
  180. package/dist/lib/legacy-start.d.ts.map +1 -0
  181. package/dist/lib/legacy-start.js +66 -0
  182. package/dist/lib/legacy-start.js.map +1 -0
  183. package/dist/lib/manager-choice.d.ts +21 -0
  184. package/dist/lib/manager-choice.d.ts.map +1 -0
  185. package/dist/lib/manager-choice.js +57 -0
  186. package/dist/lib/manager-choice.js.map +1 -0
  187. package/dist/lib/manifest/resolve.d.ts.map +1 -1
  188. package/dist/lib/manifest/resolve.js +9 -1
  189. package/dist/lib/manifest/resolve.js.map +1 -1
  190. package/dist/lib/missing-flags.d.ts +1 -1
  191. package/dist/lib/missing-flags.d.ts.map +1 -1
  192. package/dist/lib/missing-flags.js +2 -2
  193. package/dist/lib/missing-flags.js.map +1 -1
  194. package/dist/lib/persona-files.d.ts +2 -0
  195. package/dist/lib/persona-files.d.ts.map +1 -1
  196. package/dist/lib/persona-files.js +81 -23
  197. package/dist/lib/persona-files.js.map +1 -1
  198. package/dist/lib/restore.d.ts +27 -1
  199. package/dist/lib/restore.d.ts.map +1 -1
  200. package/dist/lib/restore.js +106 -14
  201. package/dist/lib/restore.js.map +1 -1
  202. package/dist/lib/service-process.d.ts +12 -2
  203. package/dist/lib/service-process.d.ts.map +1 -1
  204. package/dist/lib/service-process.js +25 -2
  205. package/dist/lib/service-process.js.map +1 -1
  206. package/dist/lib/setup-log.js +1 -1
  207. package/dist/lib/setup-log.js.map +1 -1
  208. package/dist/lib/stack-journal.d.ts +22 -1
  209. package/dist/lib/stack-journal.d.ts.map +1 -1
  210. package/dist/lib/stack-journal.js +104 -23
  211. package/dist/lib/stack-journal.js.map +1 -1
  212. package/dist/lib/stdout-owner.d.ts +7 -3
  213. package/dist/lib/stdout-owner.d.ts.map +1 -1
  214. package/dist/lib/stdout-owner.js +17 -4
  215. package/dist/lib/stdout-owner.js.map +1 -1
  216. package/dist/lib/store-dir.d.ts +8 -0
  217. package/dist/lib/store-dir.d.ts.map +1 -0
  218. package/dist/lib/store-dir.js +50 -0
  219. package/dist/lib/store-dir.js.map +1 -0
  220. package/dist/lib/team-additive-attempt.d.ts +1 -1
  221. package/dist/lib/team-fresh.d.ts +11 -1
  222. package/dist/lib/team-fresh.d.ts.map +1 -1
  223. package/dist/lib/team-fresh.js +24 -9
  224. package/dist/lib/team-fresh.js.map +1 -1
  225. package/dist/lib/transient.d.ts +2 -1
  226. package/dist/lib/transient.d.ts.map +1 -1
  227. package/dist/lib/transient.js +9 -3
  228. package/dist/lib/transient.js.map +1 -1
  229. package/dist/render.d.ts +4 -2
  230. package/dist/render.d.ts.map +1 -1
  231. package/dist/render.js +23 -16
  232. package/dist/render.js.map +1 -1
  233. package/dist/ui.d.ts +4 -2
  234. package/dist/ui.d.ts.map +1 -1
  235. package/dist/ui.js +13 -8
  236. package/dist/ui.js.map +1 -1
  237. package/dist/view/mesh-view.d.ts +3 -0
  238. package/dist/view/mesh-view.d.ts.map +1 -1
  239. package/dist/view/mesh-view.js +10 -0
  240. package/dist/view/mesh-view.js.map +1 -1
  241. package/package.json +4 -4
@@ -2,7 +2,7 @@ import { existsSync, readFileSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
4
  import { CotalEndpoint, dialerFor, EpEnvelopeError, formatAge, isReachable, mintCreds, mintLifecycleUid, resolveService, realDirNoSymlink, invokeRepairingSplit, standaloneConnectOpts, newIdentity, idFromCreds, principalKey, DEV_OWNER, unansweredRequest, resolveAuthProvider, personaDir, presenceText, } from "@cotal-ai/core";
5
- import { accountInventory, authDir, isCommandFailure, readMaintenanceJournal, brokerAddressForDisplay, canonicalRoot, CLI_USER_ACTOR, CommandFailure, deliveryCredsKey, DELIVERY_PIDFILE, extensionsDir, findCotalRoot, findPreparedSpace, hasUserAuthState, homeCotalDir, cachedPreferences, resolvePreference, isMeshRegistryError, isWorkspaceTargetError, jsonFlag, loadSoleSpaceAuth, localProcessPath, localProcessVisible, MANAGER_PIDFILE, oneLine, parsePid, plainFlag, preflightTarget, presentationOf, probeLiveness, probeWebReadiness, readCurrent, readMeshRegistry, readRenewalRecord, renderWorkspaceError, resolveMeshTarget, serverFlag, spaceFlag, userAuthStateDir, WEB_PIDFILE, WEB_READINESS_HEADER, workspaceSecretStore, writeResult } from "@cotal-ai/workspace";
5
+ import { accountInventory, assessMaintenanceClaim, authDir, isCommandFailure, readMaintenanceJournal, brokerAddressForDisplay, canonicalRoot, CLI_USER_ACTOR, CommandFailure, deliveryCredsKey, DELIVERY_PIDFILE, extensionsDir, findCotalRoot, findPreparedSpace, hasUserAuthState, homeCotalDir, cachedPreferences, resolvePreference, isMeshRegistryError, isWorkspaceTargetError, jsonFlag, loadSoleSpaceAuth, localProcessPath, localProcessVisible, MANAGER_PIDFILE, oneLine, PREFERENCE_KEYS, parsePid, plainFlag, preflightTarget, presentationOf, probeLiveness, probeWebReadiness, readCurrent, readMeshRegistry, readRenewalRecord, renderWorkspaceError, resolveMeshTarget, serverFlag, spaceFlag, userAuthStateDir, WEB_PIDFILE, WEB_READINESS_HEADER, workspaceSecretStore, writeResult } from "@cotal-ai/workspace";
6
6
  import { localProcessSurface } from "../ext-loader.js";
7
7
  import { cliVersion, cliProvenance, readExtensionVersions } from "../lib/version.js";
8
8
  import { agentSkillsSkew } from "../lib/agent-skills.js";
@@ -17,12 +17,14 @@ import { defaultPersonaFix } from "../lib/default-persona.js";
17
17
  import { c } from "../ui.js";
18
18
  import { preparedCatalogDiagnostics } from "./sync.js";
19
19
  import { agentStatus } from "./agents.js";
20
+ import { invalidEnvironmentValues } from "./config.js";
20
21
  import { onInstance } from "../lib/control.js";
21
22
  import { serviceDefinitionProjection, serviceDefinitionStore } from "../lib/service-definitions.js";
22
23
  import { instanceProjection, serviceInstances } from "../lib/service-instances.js";
23
24
  import { freshTeamAttemptSettled, listFreshTeamAttempts, listFreshTeamSummaries } from "../lib/team-fresh.js";
24
25
  import { additiveTeamRecordedState, listAdditiveTeamAttempts } from "../lib/team-additive-attempt.js";
25
- import { restoreNextStep } from "../lib/restore.js";
26
+ import { preservedSourceState, restoreNextStep } from "../lib/restore.js";
27
+ import { attemptProcessesGone } from "../lib/isolated-broker.js";
26
28
  import { readStackJournal } from "../lib/stack-journal.js";
27
29
  /** `--components` is the fail-loud health pass with a machine-readable EXIT DISPOSITION. Bare
28
30
  * `status` is a broad, recovery-oriented report: it exits 0, or 4 when it could not read part of what
@@ -43,7 +45,7 @@ export const statusFlags = [
43
45
  { name: "creds", type: "string", value: "<file>", description: "named agent: use an explicit connection credential" },
44
46
  { name: "all", type: "boolean", description: "check every recorded mesh, not only the selected one" },
45
47
  { name: "verbose", short: "v", type: "boolean", description: "include installation paths, local records and detailed diagnostics" },
46
- { name: "components", type: "boolean", description: "probe manager, delivery, web, and registered broker component health (exit: 0 serving; 1 absent; 2 present but not serving; 3 probe refused)" },
48
+ { name: "components", type: "boolean", description: "probe manager, delivery, web, and registered broker component health (exit: 0 serving, or the optional dashboard not installed; 1 absent; 2 present but not serving; 3 probe refused)" },
47
49
  jsonFlag,
48
50
  plainFlag,
49
51
  ];
@@ -52,14 +54,16 @@ export const statusFlags = [
52
54
  * status selects no space for it and dials nothing. */
53
55
  class UnregisteredRoot {
54
56
  root;
55
- constructor(root) {
57
+ namesNoSpace;
58
+ constructor(root, namesNoSpace) {
56
59
  this.root = root;
60
+ this.namesNoSpace = namesNoSpace;
57
61
  }
58
62
  }
59
63
  function resolveSelected(cwd, values) {
60
64
  try {
61
65
  const target = resolveMeshTarget(cwd, { server: values.server, space: values.space });
62
- return target.source === "local-space" ? { ok: false, error: new UnregisteredRoot(target.root) } : { ok: true, target };
66
+ return target.source === "local-space" ? { ok: false, error: new UnregisteredRoot(target.root, target.namesNoSpace === true) } : { ok: true, target };
63
67
  }
64
68
  catch (e) {
65
69
  return { ok: false, error: e };
@@ -118,7 +122,7 @@ export async function status(args) {
118
122
  // health they never checked. It is read before the folder section because that section renders
119
123
  // the delivery process row, and a live pid means nothing without it.
120
124
  const responder = await readResponderAxis(selected);
121
- const folder = await readFolder(root, selected, values, responder, gaps, hints);
125
+ const folder = await readFolder(root, selected, values, responder.state, gaps, hints);
122
126
  const meshes = await readMeshes(selected, Boolean(values.all), gaps);
123
127
  const target = await readSelected(selected, responder, gaps, hints);
124
128
  const services = readOwnedServices(selected, gaps);
@@ -126,26 +130,40 @@ export async function status(args) {
126
130
  const maintenance = readMaintenance(root, gaps);
127
131
  const result = { kind: "infrastructure", machine, extensions, folder, meshes, selected: target, services, bootAttempts, maintenance, hints };
128
132
  const parts = gaps.warnings.length;
133
+ // A preference variable `config set` would refuse is named, but it was read, so the run stays complete.
134
+ const context = { preferences: cachedPreferences(), space: selected.ok ? selected.target.space : undefined };
135
+ const invalidValues = invalidEnvironmentValues(PREFERENCE_KEYS.map((key) => resolvePreference(key, context)));
129
136
  writeResult(presentation, {
130
137
  command: "status",
131
138
  target: { space: selected.ok ? selected.target.space : null, scope: values.all ? "all" : "selected" },
132
139
  result,
133
140
  completeness: parts ? "partial" : "complete",
134
- warnings: gaps.warnings,
141
+ warnings: [...gaps.warnings, ...invalidValues],
135
142
  ...(parts ? { partial: { message: `status could not read ${parts === 1 ? "one part" : `${parts} parts`} of what it reports; the warnings name ${parts === 1 ? "it" : "each"}` } } : {}),
136
143
  }, (result) => statusView(result, Boolean(values.verbose)));
137
144
  if (values.components)
138
145
  await printComponentHealth(cwd, values);
139
146
  }
147
+ /** A ready journal's next step. Resume and backup use the store at its recorded path, so a folder
148
+ * moved after the cut is told to move back, and a missing store is named. */
149
+ function readyNextStep(root, source) {
150
+ const where = preservedSourceState(root, source);
151
+ if (where.state === "moved")
152
+ return `this folder was moved from ${where.recordedRoot} after its state was preserved: move it back there, then create a backup or resume with bare ${displayCmd()} up`;
153
+ if (where.state === "missing")
154
+ return `the preserved store recorded at ${source.path} is missing: if this folder was moved, move it back; if the store is lost, restore a backup with ${displayCmd()} backup restore <dir> --accept-missing-source`;
155
+ return `create a backup with ${displayCmd()} backup create <dir>, or resume with bare ${displayCmd()} up`;
156
+ }
140
157
  /** The folder's maintenance journal, read only. An unreadable one is reported, never taken for none. */
141
158
  function readMaintenance(root, gaps) {
142
159
  try {
143
160
  const journal = readMaintenanceJournal(root);
144
161
  if (!journal)
145
162
  return null;
146
- const attemptId = "restore" in journal ? journal.restore.attemptId : journal.cut.attemptId;
163
+ const attemptId = "restore" in journal ? journal.restore.attemptId : journal.state === "claimed" ? journal.claim.attemptId : journal.cut.attemptId;
147
164
  const next = "restore" in journal ? restoreNextStep(journal.state, attemptId)
148
- : journal.state === "ready" ? `create a backup with ${displayCmd()} backup create <dir>, or resume with bare ${displayCmd()} up` : null;
165
+ : journal.state === "ready" ? readyNextStep(root, journal.source)
166
+ : journal.state === "claimed" ? claimedNextStep(root, journal.claim) : null;
149
167
  return { root, space: journal.space, state: journal.state, attemptId, next };
150
168
  }
151
169
  catch {
@@ -153,9 +171,19 @@ function readMaintenance(root, gaps) {
153
171
  return { root, space: null, state: "unreadable", attemptId: null, next: null };
154
172
  }
155
173
  }
174
+ /** The next step for a cut a backup create still claims: wait while it runs, or release it once it
175
+ * stopped before it finished. */
176
+ function claimedNextStep(root, claim) {
177
+ const recover = `${displayCmd()} backup recover ${claim.attemptId} --yes`;
178
+ if (assessMaintenanceClaim(claim, { unrecordedOwnersDead: attemptProcessesGone(root) }) === "stale")
179
+ return `backup attempt ${claim.attemptId} stopped before it finished: release it with ${recover}`;
180
+ return `backup attempt ${claim.attemptId} holds this root until ${claim.deadline} (process ${claim.coordinator.pid}); if it was stopped, run ${recover} once it has exited`;
181
+ }
156
182
  /** Local boot and additive intents are recovery coordinates, not evidence of native state. */
157
183
  function readBootAttempts(root, gaps) {
158
- const result = { root, state: "not-checked", observedAt: new Date().toISOString(), unsettled: [], additive: [], unreadable: [] };
184
+ // A refusal with its own cause, such as a root other local accounts can write, is named.
185
+ const because = (error) => isCommandFailure(error) ? ` (${error.message})` : "";
186
+ const result = { root, state: "not-checked", observedAt: new Date().toISOString(), unsettled: [], additive: [], unreadable: [], elsewhere: [] };
159
187
  try {
160
188
  if (!realDirNoSymlink(root, ".cotal"))
161
189
  return result;
@@ -163,14 +191,15 @@ function readBootAttempts(root, gaps) {
163
191
  const byId = new Map(summaries.valid.map((summary) => [summary.deploymentId, summary]));
164
192
  result.unsettled = attempts.valid.filter((attempt) => !freshTeamAttemptSettled(attempt, byId.get(attempt.deploymentId)))
165
193
  .map(({ deploymentId, space, server, createdAt }) => ({ deploymentId, space, server: brokerAddressForDisplay(server) ?? "not displayable", createdAt }));
194
+ result.elsewhere = summaries.elsewhere.map(({ deploymentId, root: recordedRoot }) => ({ deploymentId, root: recordedRoot }));
166
195
  const unreadable = [...attempts.refused, ...summaries.refused].map(({ path }) => path);
167
196
  result.unreadable.push(...unreadable);
168
197
  if (unreadable.length)
169
198
  gaps.add("FRESH_BOOT_RECORD_UNREADABLE", "one or more fresh boot attempts or returned summaries are unreadable; their outcomes were not treated as absent", { root, paths: unreadable });
170
199
  }
171
- catch {
200
+ catch (error) {
172
201
  result.state = "partial";
173
- gaps.add("FRESH_BOOT_RECORD_UNAVAILABLE", "this folder's fresh boot attempt inventory could not be read; no empty inventory was inferred", { root });
202
+ gaps.add("FRESH_BOOT_RECORD_UNAVAILABLE", `this folder's fresh boot attempt inventory could not be read${because(error)}; no empty inventory was inferred`, { root });
174
203
  }
175
204
  try {
176
205
  const additive = listAdditiveTeamAttempts(root);
@@ -180,9 +209,9 @@ function readBootAttempts(root, gaps) {
180
209
  if (unreadable.length)
181
210
  gaps.add("ADDITIVE_ATTEMPT_UNREADABLE", "one or more additive attempts are unreadable; their effects were not treated as absent", { root, paths: unreadable });
182
211
  }
183
- catch {
212
+ catch (error) {
184
213
  result.state = "partial";
185
- gaps.add("ADDITIVE_ATTEMPT_UNAVAILABLE", "this folder's additive attempt inventory could not be read; no empty inventory was inferred", { root });
214
+ gaps.add("ADDITIVE_ATTEMPT_UNAVAILABLE", `this folder's additive attempt inventory could not be read${because(error)}; no empty inventory was inferred`, { root });
186
215
  }
187
216
  if (result.state !== "partial")
188
217
  result.state = result.unreadable.length ? "partial" : "read";
@@ -344,17 +373,21 @@ async function expectedDeliveryHolder(target) {
344
373
  * USER MODE IS DELIBERATELY `unknown` RATHER THAN CONNECTED. The flip forbids status from
345
374
  * static-minting on a user-auth mesh, and borrowing the operator's bearer for a health probe is a
346
375
  * bigger decision than this fix should make silently. Those operators get the axis from
347
- * `--components`, and the row says so instead of guessing. */
376
+ * `--components`, and the row says so instead of guessing.
377
+ *
378
+ * `leased` says whether the read found a delivery lease record. An open mesh runs no delivery
379
+ * daemon, so there a missing lease is the normal state rather than an unbound responder. */
348
380
  async function readResponderAxis(selected) {
381
+ let leased = false;
349
382
  if (!selected.ok)
350
- return "unknown";
383
+ return { state: "unknown", leased };
351
384
  const target = selected.target;
352
385
  if (target.mode === "user")
353
- return "unknown";
386
+ return { state: "unknown", leased };
354
387
  try {
355
388
  const preflight = await preflightTarget(target);
356
389
  if (!preflight.ok)
357
- return "unknown";
390
+ return { state: "unknown", leased };
358
391
  const id = newIdentity();
359
392
  const creds = target.auth ? await mintCreds(target.auth, id, "observer") : undefined;
360
393
  const ep = new CotalEndpoint({
@@ -388,14 +421,19 @@ async function readResponderAxis(selected) {
388
421
  // `--components` surface deliberately does NOT use it: that surface must tell a missing lease
389
422
  // stream apart from a refused read, and flattening both to `unknown` would erase a
390
423
  // distinction it reports.
391
- return await deliveryResponderState(() => ep.readDeliveryLease(0), await expectedDeliveryHolder(target));
424
+ const holder = await expectedDeliveryHolder(target);
425
+ const state = await deliveryResponderState(async () => { const lease = await ep.readDeliveryLease(0); leased = lease !== undefined; return lease; }, holder);
426
+ // A daemon killed before it could release shard 0 leaves its ready row, which names this
427
+ // folder's credential, until the bucket TTL removes it. When this folder's delivery pidfile
428
+ // names a process that is gone, that row is the dead daemon's, the same rule `up` waits on.
429
+ return { state: state === "bound" && holder !== undefined && processRecord(DELIVERY_PIDFILE, { root: target.root, space: target.space }).kind === "dead" ? "stale" : state, leased };
392
430
  }
393
431
  finally {
394
432
  await ep.stop().catch(() => { });
395
433
  }
396
434
  }
397
435
  catch {
398
- return "unknown";
436
+ return { state: "unknown", leased };
399
437
  }
400
438
  }
401
439
  async function readFolder(root, selected, values, responder, gaps, hints) {
@@ -504,7 +542,15 @@ async function readFolder(root, selected, values, responder, gaps, hints) {
504
542
  controllerStack = false;
505
543
  }
506
544
  const storedState = !controllerStack && nats?.liveness !== "alive" && existsSync(join(root, ".cotal", "nats"));
507
- if (storedState)
545
+ // While a maintenance journal holds the store, clean store refuses, so it is not offered.
546
+ let maintained = false;
547
+ try {
548
+ maintained = readMaintenanceJournal(root) !== undefined;
549
+ }
550
+ catch {
551
+ maintained = true;
552
+ }
553
+ if (storedState && !maintained)
508
554
  hints.push(`if the stored JetStream state is stale: ${cmd} clean store --force, then \`up\` with your usual flags (\`clean all\` also resets identity)`);
509
555
  return folder({ state: auth ? "space" : "none", spaces: auth ? [auth.space] : [], userAuth: userDisk, error: null }, processes, storedState, space, controllerStack);
510
556
  }
@@ -694,7 +740,11 @@ async function readSelected(selected, responder, gaps, hints) {
694
740
  }
695
741
  if (e instanceof UnregisteredRoot) {
696
742
  const message = `no space is registered or prepared here for ${e.root}`;
697
- hints.push(`${message} - run \`${cmd} up\` there to start one, or select a space with \`${cmd} use <name>\``);
743
+ // A bare `up` in a folder whose records name no space starts the default space there, which
744
+ // then holds the folder, so the step that brings a forgotten space back is to prepare it again.
745
+ hints.push(e.namesNoSpace
746
+ ? `${message} - prepare one there with \`${cmd} space create <name> --root ${e.root}\`, or select a space with \`${cmd} use <name>\``
747
+ : `${message} - run \`${cmd} up\` there to start one, or select a space with \`${cmd} use <name>\``);
698
748
  return { resolved: false, code: "unregistered-root", message };
699
749
  }
700
750
  if (!isWorkspaceTargetError(e))
@@ -763,7 +813,7 @@ async function readSelected(selected, responder, gaps, hints) {
763
813
  // delivery PROCESS is doing; this says whether the SPACE currently has a bound responder, which is
764
814
  // the question "can I spawn into this mesh right now" actually reduces to. An operator reading a
765
815
  // reachable broker and a running daemon had, before this, no row that said otherwise.
766
- return { ...base, connection: "ok", deliveryResponder: responder, ...(await readSnapshot(() => snapshotEndpoint(target), target.space, gaps)) };
816
+ return { ...base, connection: "ok", deliveryResponder: target.mode === "open" && !responder.leased ? null : responder.state, ...(await readSnapshot(() => snapshotEndpoint(target), target.space, gaps)) };
767
817
  }
768
818
  async function snapshotEndpoint(target) {
769
819
  const id = newIdentity();
@@ -993,10 +1043,14 @@ function meshesSections(m) {
993
1043
  return sections;
994
1044
  }
995
1045
  /** The selected space's delivery responder (#1576). Bare status and the verbose mesh section both
996
- * state it, so an operator on a manager host away from the broker's folder still sees it. */
997
- function responderText(state) {
1046
+ * state it, so an operator on a manager host away from the broker's folder still sees it. An open
1047
+ * mesh runs no delivery daemon, so with no lease recorded its row says the responder is not used
1048
+ * rather than unbound. */
1049
+ function responderText(state, mode) {
1050
+ if (state === null && mode === "open")
1051
+ return { text: "not used - an open mesh runs no delivery daemon", tone: "hint" };
998
1052
  if (state === "unbound")
999
- return { text: `NOT BOUND - ${RESPONDER_UNBOUND_CONSEQUENCE} · start it with \`${displayCmd()} up\` (or \`${displayCmd()} deliver --space <space>\`)`, tone: "failed" };
1053
+ return { text: `NOT BOUND - ${RESPONDER_UNBOUND_CONSEQUENCE} · start it with \`${displayCmd()} up\``, tone: "failed" };
1000
1054
  // A stale record is NOT BOUND with a different next move: the slot is occupied by a corpse, so
1001
1055
  // starting a daemon now loses the single-flight CAS. Say that, rather than sending the operator
1002
1056
  // into a refusal they will read as a second failure.
@@ -1043,7 +1097,7 @@ function selectedSection(s) {
1043
1097
  }
1044
1098
  else {
1045
1099
  rows.push(["connection", s.connection === "ok" ? cell("ok", "ok") : cell(`${s.connection}${s.staleRecord ? " (stale registry entry)" : ""}`, "failed")]);
1046
- const responder = responderText(s.deliveryResponder);
1100
+ const responder = responderText(s.deliveryResponder, s.mode);
1047
1101
  if (responder)
1048
1102
  rows.push(["delivery responder", cell(responder.text, responder.tone)]);
1049
1103
  }
@@ -1148,7 +1202,7 @@ function selectedOverview(r) {
1148
1202
  // A broker named with `--server` is reported even when nothing on this machine is registered.
1149
1203
  if (s.source !== "flag-server" && !r.meshes.items.length && !r.meshes.currentPrepared && r.folder.auth.state === "none" && !r.folder.processes?.some((item) => item.pid !== null))
1150
1204
  return undefined;
1151
- const responder = responderText(s.deliveryResponder);
1205
+ const responder = responderText(s.deliveryResponder, s.mode);
1152
1206
  const rows = [
1153
1207
  ["Broker", s.server ?? stateCell("address unavailable", "failed")],
1154
1208
  ["Connection", connectionCell(s)],
@@ -1198,28 +1252,34 @@ function selectedOverview(r) {
1198
1252
  function nextActions(r) {
1199
1253
  const cmd = displayCmd();
1200
1254
  const items = [];
1201
- if (!r.machine.connectors?.length)
1202
- items.push({ command: `${cmd} setup`, description: "Set up an agent application and a space" });
1203
- else {
1204
- if (r.selected.resolved) {
1205
- const s = r.selected;
1206
- // Name what fixes the default persona alone; setup does far more than that.
1207
- if (s.personas.default === "missing") {
1208
- const fix = defaultPersonaFix({ space: s.space, root: s.root, origin: r.meshes.items.find((m) => m.space === s.space)?.origin }, cmd);
1209
- items.push({ command: fix.command, description: fix.cwd ? `Write the default persona; run it in ${fix.cwd}` : "Create the default persona" });
1210
- }
1211
- else if (s.personas.default !== "valid")
1212
- items.push({ command: `${cmd} persona show default --space ${s.space}`, description: "See what is wrong with the default persona" });
1213
- else
1214
- items.push({ command: `${cmd} spawn`, description: "Open your default agent" });
1215
- items.push({ command: `${cmd} ps`, description: "See the agent roster" });
1255
+ const noApplication = !r.machine.connectors?.length;
1256
+ if (r.selected.resolved) {
1257
+ const s = r.selected;
1258
+ // A space that already resolves needs only the application to spawn into it.
1259
+ if (noApplication)
1260
+ items.push({ command: `${cmd} setup`, description: "Set up an agent application" });
1261
+ // Name what fixes the default persona alone; setup does far more than that.
1262
+ else if (s.personas.default === "missing") {
1263
+ const fix = defaultPersonaFix({ space: s.space, root: s.root, origin: r.meshes.items.find((m) => m.space === s.space)?.origin }, cmd);
1264
+ items.push({ command: fix.command, description: fix.cwd ? `Write the default persona; run it in ${fix.cwd}` : "Create the default persona" });
1216
1265
  }
1266
+ else if (s.personas.default !== "valid")
1267
+ items.push({ command: `${cmd} persona show default --space ${s.space}`, description: "See what is wrong with the default persona" });
1268
+ else
1269
+ items.push({ command: `${cmd} spawn`, description: "Open your default agent" });
1270
+ items.push({ command: `${cmd} ps`, description: "See the agent roster" });
1271
+ }
1272
+ else if (noApplication)
1273
+ items.push({ command: `${cmd} setup`, description: r.selected.code === "not-started" ? "Set up an agent application" : "Set up an agent application and a space" });
1274
+ if (r.selected.resolved || !noApplication) {
1217
1275
  items.push({ command: `${cmd} use`, description: "Choose another space" });
1218
1276
  if (r.meshes.items.length > 1)
1219
1277
  items.push({ command: `${cmd} status --all`, description: "Check every registered space" });
1220
1278
  }
1221
- // A local controller stack that does not answer restarts its stopped members from its own records.
1222
- if (r.selected.resolved && r.selected.connection !== "ok" && r.selected.connection !== "reachable" && r.folder.controllerStack && r.folder.root === r.selected.root && r.folder.processSpace === r.selected.space)
1279
+ // A local controller stack that does not answer, or one with a member whose process is gone,
1280
+ // restarts its stopped members from its own records.
1281
+ const memberGone = r.services?.instances?.some((row) => row.definition.startsWith("stack-") && row.observedProcess === "gone") === true;
1282
+ if (r.selected.resolved && (memberGone || r.selected.connection !== "ok" && r.selected.connection !== "reachable") && r.folder.controllerStack && r.folder.root === r.selected.root && r.folder.processSpace === r.selected.space)
1223
1283
  items.unshift({ command: `${cmd} up --root ${r.selected.root}`, description: "Restart this stack's stopped members from its recorded inputs" });
1224
1284
  if (r.selected.resolved && r.selected.mode === "user" && r.selected.login && !r.selected.login.subject)
1225
1285
  items.unshift({ command: `${cmd} login --idp ${r.selected.login.idp}`, description: "Sign in to the selected space" });
@@ -1259,12 +1319,16 @@ function ownedServicesOverview(services) {
1259
1319
  return { title: `Owned services → ${services.space}`, blocks };
1260
1320
  }
1261
1321
  function bootAttemptOverview(snapshot) {
1262
- if (!snapshot || !snapshot.unsettled.length && !snapshot.additive.length && !snapshot.unreadable.length)
1322
+ if (!snapshot)
1263
1323
  return undefined;
1324
+ const elsewhere = [...snapshot.elsewhere.slice(0, 100).map((row) => `Launch summary ${row.deploymentId} was recorded at ${row.root}. This folder was moved or copied since, so it reports only that earlier boot and blocks nothing here.`), ...(snapshot.elsewhere.length > 100 ? ["Additional summaries are in JSON."] : [])];
1325
+ if (!snapshot.unsettled.length && !snapshot.additive.length && !snapshot.unreadable.length)
1326
+ return elsewhere.length ? { title: "Deployment attempts", blocks: [{ kind: "fields", rows: [["Folder root", snapshot.root]] }, { kind: "lines", lines: elsewhere }] } : undefined;
1264
1327
  return { title: "Deployment attempts", blocks: [
1265
1328
  { kind: "fields", rows: [["Folder root", snapshot.root], ["Local read", snapshot.state], ["Unsettled fresh", String(snapshot.unsettled.length)], ["Additive attempts", String(snapshot.additive.length)], ["Unreadable records", String(snapshot.unreadable.length)]] },
1266
1329
  snapshot.unsettled.length ? { kind: "table", columns: [{ key: "id", label: "Fresh boot" }, { key: "space", label: "Space" }, { key: "broker", label: "Recorded broker" }], rows: snapshot.unsettled.slice(0, 100).map((row) => ({ id: row.deploymentId, space: row.space, broker: row.server })) } : { kind: "lines", lines: ["No readable unsettled fresh attempt in this folder."] },
1267
1330
  snapshot.additive.length ? { kind: "table", columns: [{ key: "id", label: "Additive intent" }, { key: "space", label: "Space" }, { key: "state", label: "Recorded state" }], rows: snapshot.additive.slice(0, 100).map((row) => ({ id: row.deploymentId, space: row.space, state: row.recordedState })) } : { kind: "lines", lines: ["No readable additive attempt in this folder."] },
1331
+ ...(elsewhere.length ? [{ kind: "lines", lines: elsewhere }] : []),
1268
1332
  { kind: "lines", lines: [...snapshot.unreadable.slice(0, 100).map((path) => `Unreadable record: ${path}`), ...(snapshot.unsettled.length > 100 || snapshot.additive.length > 100 || snapshot.unreadable.length > 100 ? ["Additional records are in JSON."] : []), "A fresh intent may have started a broker; an additive intent may have changed its resources. No retry or stop authority follows from this read."] },
1269
1333
  { kind: "commands", items: [{ command: `${displayCmd()} team show <deployment-id>`, description: "Inspect the original attempt from its recorded root" }] },
1270
1334
  ] };
@@ -1294,6 +1358,8 @@ function section(name) {
1294
1358
  }
1295
1359
  const COMPONENT_EXIT = {
1296
1360
  serving: 0,
1361
+ // An optional component that was never installed is not a failed one.
1362
+ "not-installed": 0,
1297
1363
  absent: 1,
1298
1364
  "not-serving": 2,
1299
1365
  refused: 3,
@@ -1382,6 +1448,7 @@ async function componentCredential(target) {
1382
1448
  }
1383
1449
  }
1384
1450
  async function componentEp(target, credential) {
1451
+ await requireGreeting(target);
1385
1452
  const id = newIdentity();
1386
1453
  const user = credential.kind === "user";
1387
1454
  // Static/open: ONE lifecycleUid minted and used both in the credential and as the endpoint's own
@@ -1416,6 +1483,14 @@ async function componentEp(target, credential) {
1416
1483
  await ep.start();
1417
1484
  return { ep, close: () => ep.stop().catch(() => { }) };
1418
1485
  }
1486
+ /** Refuse before a probe dials a broker that does not greet on a socket this check owns. A broker
1487
+ * that takes the connection and never greets, as a stopped one does, leaves the dial's socket open
1488
+ * after its timeout, because the client library does not release a connection it never finished,
1489
+ * and status could then never exit. */
1490
+ async function requireGreeting(target) {
1491
+ if (!(await isReachable(target.server, { ...(target.tlsRequired ? { tls: true } : {}), timeoutMs: 3_000 })))
1492
+ throw new Error(`the broker at ${brokerAddressForDisplay(target.server) ?? "an invalid broker address"} is not answering`);
1493
+ }
1419
1494
  /** The static arm's one-shot service instrument, unchanged from before the user-mode fix: a fresh
1420
1495
  * identity, its minted deployer credential, and the caller triple on the SAME identity — a
1421
1496
  * mismatched random actor would turn an authorized manager into a false no-answer. */
@@ -1464,6 +1539,7 @@ function managerStopImpactFacts(input) {
1464
1539
  * generic endpoint does not work on this base because a passive status endpoint has no v0.4 caller
1465
1540
  * rail; a one-shot standalone caller does. */
1466
1541
  async function managerServiceHealth(target, auth) {
1542
+ await requireGreeting(target);
1467
1543
  const nc = await dialerFor(target.server)({
1468
1544
  servers: target.server,
1469
1545
  ...standaloneConnectOpts("bearer" in auth
@@ -1668,6 +1744,18 @@ async function webHealth(context) {
1668
1744
  const record = processRecord(WEB_PIDFILE, context);
1669
1745
  const facts = pidFacts(record);
1670
1746
  const stopped = processVerdict(record);
1747
+ if (record.kind === "absent") {
1748
+ // An installation that cannot be read keeps the absent verdict rather than a clean zero.
1749
+ let installed;
1750
+ try {
1751
+ installed = webInstalled();
1752
+ }
1753
+ catch {
1754
+ installed = undefined;
1755
+ }
1756
+ if (installed === false)
1757
+ return { name: "web", verdict: "not-installed", facts: ["optional"] };
1758
+ }
1671
1759
  if (stopped) {
1672
1760
  if (record.kind === "dead")
1673
1761
  facts.push("stale pidfile");