@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.
Files changed (237) hide show
  1. package/dist/command.d.ts.map +1 -1
  2. package/dist/command.js +34 -20
  3. package/dist/command.js.map +1 -1
  4. package/dist/commands/agents.d.ts.map +1 -1
  5. package/dist/commands/agents.js +8 -6
  6. package/dist/commands/agents.js.map +1 -1
  7. package/dist/commands/backup.d.ts.map +1 -1
  8. package/dist/commands/backup.js +15 -10
  9. package/dist/commands/backup.js.map +1 -1
  10. package/dist/commands/channel-members.d.ts.map +1 -1
  11. package/dist/commands/channel-members.js +2 -1
  12. package/dist/commands/channel-members.js.map +1 -1
  13. package/dist/commands/channels.d.ts.map +1 -1
  14. package/dist/commands/channels.js +19 -9
  15. package/dist/commands/channels.js.map +1 -1
  16. package/dist/commands/clean.d.ts.map +1 -1
  17. package/dist/commands/clean.js +2 -3
  18. package/dist/commands/clean.js.map +1 -1
  19. package/dist/commands/doctor.js +5 -2
  20. package/dist/commands/doctor.js.map +1 -1
  21. package/dist/commands/down-preserve.d.ts +74 -0
  22. package/dist/commands/down-preserve.d.ts.map +1 -0
  23. package/dist/commands/down-preserve.js +626 -0
  24. package/dist/commands/down-preserve.js.map +1 -0
  25. package/dist/commands/down.d.ts +2 -61
  26. package/dist/commands/down.d.ts.map +1 -1
  27. package/dist/commands/down.js +26 -617
  28. package/dist/commands/down.js.map +1 -1
  29. package/dist/commands/endpoint-authoring.d.ts.map +1 -1
  30. package/dist/commands/endpoint-authoring.js +16 -4
  31. package/dist/commands/endpoint-authoring.js.map +1 -1
  32. package/dist/commands/history-clear.d.ts.map +1 -1
  33. package/dist/commands/history-clear.js +10 -3
  34. package/dist/commands/history-clear.js.map +1 -1
  35. package/dist/commands/history-limit.js +2 -2
  36. package/dist/commands/history-limit.js.map +1 -1
  37. package/dist/commands/history.d.ts.map +1 -1
  38. package/dist/commands/history.js +49 -19
  39. package/dist/commands/history.js.map +1 -1
  40. package/dist/commands/join.d.ts.map +1 -1
  41. package/dist/commands/join.js +30 -7
  42. package/dist/commands/join.js.map +1 -1
  43. package/dist/commands/manager-service.d.ts.map +1 -1
  44. package/dist/commands/manager-service.js +5 -1
  45. package/dist/commands/manager-service.js.map +1 -1
  46. package/dist/commands/meshes-add.d.ts +4 -1
  47. package/dist/commands/meshes-add.d.ts.map +1 -1
  48. package/dist/commands/meshes-add.js +19 -1
  49. package/dist/commands/meshes-add.js.map +1 -1
  50. package/dist/commands/meshes-wizard.d.ts.map +1 -1
  51. package/dist/commands/meshes-wizard.js +5 -5
  52. package/dist/commands/meshes-wizard.js.map +1 -1
  53. package/dist/commands/meshes.d.ts.map +1 -1
  54. package/dist/commands/meshes.js +4 -3
  55. package/dist/commands/meshes.js.map +1 -1
  56. package/dist/commands/persona-remote.js +2 -2
  57. package/dist/commands/persona-remote.js.map +1 -1
  58. package/dist/commands/persona.d.ts.map +1 -1
  59. package/dist/commands/persona.js +13 -5
  60. package/dist/commands/persona.js.map +1 -1
  61. package/dist/commands/personas.d.ts.map +1 -1
  62. package/dist/commands/personas.js +4 -1
  63. package/dist/commands/personas.js.map +1 -1
  64. package/dist/commands/reset-space-apply.js +2 -2
  65. package/dist/commands/reset-space-apply.js.map +1 -1
  66. package/dist/commands/reset-store-apply.d.ts +2 -2
  67. package/dist/commands/reset-store-apply.d.ts.map +1 -1
  68. package/dist/commands/reset-store-apply.js +10 -7
  69. package/dist/commands/reset-store-apply.js.map +1 -1
  70. package/dist/commands/reset.js +2 -2
  71. package/dist/commands/reset.js.map +1 -1
  72. package/dist/commands/send.d.ts.map +1 -1
  73. package/dist/commands/send.js +21 -9
  74. package/dist/commands/send.js.map +1 -1
  75. package/dist/commands/service-actions.d.ts.map +1 -1
  76. package/dist/commands/service-actions.js +15 -4
  77. package/dist/commands/service-actions.js.map +1 -1
  78. package/dist/commands/service-registry.d.ts.map +1 -1
  79. package/dist/commands/service-registry.js +16 -5
  80. package/dist/commands/service-registry.js.map +1 -1
  81. package/dist/commands/space-delete.d.ts.map +1 -1
  82. package/dist/commands/space-delete.js +46 -31
  83. package/dist/commands/space-delete.js.map +1 -1
  84. package/dist/commands/space-registration.d.ts +4 -3
  85. package/dist/commands/space-registration.d.ts.map +1 -1
  86. package/dist/commands/space-registration.js +65 -45
  87. package/dist/commands/space-registration.js.map +1 -1
  88. package/dist/commands/space.d.ts.map +1 -1
  89. package/dist/commands/space.js +18 -6
  90. package/dist/commands/space.js.map +1 -1
  91. package/dist/commands/spawn-flags.d.ts +205 -0
  92. package/dist/commands/spawn-flags.d.ts.map +1 -0
  93. package/dist/commands/spawn-flags.js +34 -0
  94. package/dist/commands/spawn-flags.js.map +1 -0
  95. package/dist/commands/spawn-foreground.d.ts +74 -0
  96. package/dist/commands/spawn-foreground.d.ts.map +1 -0
  97. package/dist/commands/spawn-foreground.js +355 -0
  98. package/dist/commands/spawn-foreground.js.map +1 -0
  99. package/dist/commands/spawn-managed-launch.d.ts +43 -0
  100. package/dist/commands/spawn-managed-launch.d.ts.map +1 -0
  101. package/dist/commands/spawn-managed-launch.js +631 -0
  102. package/dist/commands/spawn-managed-launch.js.map +1 -0
  103. package/dist/commands/spawn-preview.d.ts.map +1 -1
  104. package/dist/commands/spawn-preview.js +10 -7
  105. package/dist/commands/spawn-preview.js.map +1 -1
  106. package/dist/commands/spawn.d.ts +6 -220
  107. package/dist/commands/spawn.d.ts.map +1 -1
  108. package/dist/commands/spawn.js +21 -1009
  109. package/dist/commands/spawn.js.map +1 -1
  110. package/dist/commands/stack-down.d.ts.map +1 -1
  111. package/dist/commands/stack-down.js +7 -4
  112. package/dist/commands/stack-down.js.map +1 -1
  113. package/dist/commands/stack-up.d.ts +5 -1
  114. package/dist/commands/stack-up.d.ts.map +1 -1
  115. package/dist/commands/stack-up.js +46 -15
  116. package/dist/commands/stack-up.js.map +1 -1
  117. package/dist/commands/status-delivery.d.ts +9 -0
  118. package/dist/commands/status-delivery.d.ts.map +1 -0
  119. package/dist/commands/status-delivery.js +19 -0
  120. package/dist/commands/status-delivery.js.map +1 -0
  121. package/dist/commands/status-legacy.d.ts +7 -0
  122. package/dist/commands/status-legacy.d.ts.map +1 -0
  123. package/dist/commands/status-legacy.js +35 -0
  124. package/dist/commands/status-legacy.js.map +1 -0
  125. package/dist/commands/status-stop-impact.d.ts +3 -0
  126. package/dist/commands/status-stop-impact.d.ts.map +1 -0
  127. package/dist/commands/status-stop-impact.js +34 -0
  128. package/dist/commands/status-stop-impact.js.map +1 -0
  129. package/dist/commands/status.d.ts.map +1 -1
  130. package/dist/commands/status.js +48 -105
  131. package/dist/commands/status.js.map +1 -1
  132. package/dist/commands/team-agent-apply.js +11 -11
  133. package/dist/commands/team-agent-apply.js.map +1 -1
  134. package/dist/commands/team-boot-controller.d.ts.map +1 -1
  135. package/dist/commands/team-boot-controller.js +21 -4
  136. package/dist/commands/team-boot-controller.js.map +1 -1
  137. package/dist/commands/team-deploy-apply.js +2 -2
  138. package/dist/commands/team-deploy-apply.js.map +1 -1
  139. package/dist/commands/team.d.ts.map +1 -1
  140. package/dist/commands/team.js +37 -42
  141. package/dist/commands/team.js.map +1 -1
  142. package/dist/commands/telemetry.d.ts +1 -1
  143. package/dist/commands/telemetry.d.ts.map +1 -1
  144. package/dist/commands/telemetry.js +17 -7
  145. package/dist/commands/telemetry.js.map +1 -1
  146. package/dist/commands/up-target.d.ts +7 -0
  147. package/dist/commands/up-target.d.ts.map +1 -0
  148. package/dist/commands/up-target.js +42 -0
  149. package/dist/commands/up-target.js.map +1 -0
  150. package/dist/commands/up.d.ts +5 -10
  151. package/dist/commands/up.d.ts.map +1 -1
  152. package/dist/commands/up.js +55 -156
  153. package/dist/commands/up.js.map +1 -1
  154. package/dist/commands/update-caches.d.ts +4 -0
  155. package/dist/commands/update-caches.d.ts.map +1 -0
  156. package/dist/commands/update-caches.js +82 -0
  157. package/dist/commands/update-caches.js.map +1 -0
  158. package/dist/commands/update.d.ts.map +1 -1
  159. package/dist/commands/update.js +35 -121
  160. package/dist/commands/update.js.map +1 -1
  161. package/dist/commands/watch.d.ts.map +1 -1
  162. package/dist/commands/watch.js +5 -2
  163. package/dist/commands/watch.js.map +1 -1
  164. package/dist/commands/whoami.d.ts.map +1 -1
  165. package/dist/commands/whoami.js +3 -2
  166. package/dist/commands/whoami.js.map +1 -1
  167. package/dist/help.d.ts +1 -1
  168. package/dist/help.d.ts.map +1 -1
  169. package/dist/help.js +5 -2
  170. package/dist/help.js.map +1 -1
  171. package/dist/index.d.ts.map +1 -1
  172. package/dist/index.js +4 -2
  173. package/dist/index.js.map +1 -1
  174. package/dist/lib/broker-log.d.ts +8 -0
  175. package/dist/lib/broker-log.d.ts.map +1 -0
  176. package/dist/lib/broker-log.js +27 -0
  177. package/dist/lib/broker-log.js.map +1 -0
  178. package/dist/lib/choose-target.d.ts.map +1 -1
  179. package/dist/lib/choose-target.js +12 -9
  180. package/dist/lib/choose-target.js.map +1 -1
  181. package/dist/lib/credential-authority.d.ts.map +1 -1
  182. package/dist/lib/credential-authority.js +22 -5
  183. package/dist/lib/credential-authority.js.map +1 -1
  184. package/dist/lib/endpoint-errors.d.ts.map +1 -1
  185. package/dist/lib/endpoint-errors.js +9 -2
  186. package/dist/lib/endpoint-errors.js.map +1 -1
  187. package/dist/lib/persona-files.d.ts.map +1 -1
  188. package/dist/lib/persona-files.js +2 -3
  189. package/dist/lib/persona-files.js.map +1 -1
  190. package/dist/lib/restore.d.ts +2 -1
  191. package/dist/lib/restore.d.ts.map +1 -1
  192. package/dist/lib/restore.js +4 -3
  193. package/dist/lib/restore.js.map +1 -1
  194. package/dist/lib/service-preset-target.d.ts.map +1 -1
  195. package/dist/lib/service-preset-target.js +6 -2
  196. package/dist/lib/service-preset-target.js.map +1 -1
  197. package/dist/lib/service-presets.d.ts +2 -0
  198. package/dist/lib/service-presets.d.ts.map +1 -1
  199. package/dist/lib/service-presets.js +19 -2
  200. package/dist/lib/service-presets.js.map +1 -1
  201. package/dist/lib/spawn-defaults.d.ts +7 -0
  202. package/dist/lib/spawn-defaults.d.ts.map +1 -1
  203. package/dist/lib/spawn-defaults.js +16 -0
  204. package/dist/lib/spawn-defaults.js.map +1 -1
  205. package/dist/lib/stack-journal.d.ts +4 -4
  206. package/dist/lib/stack-journal.d.ts.map +1 -1
  207. package/dist/lib/stack-journal.js +16 -6
  208. package/dist/lib/stack-journal.js.map +1 -1
  209. package/dist/lib/store-dir.d.ts +3 -1
  210. package/dist/lib/store-dir.d.ts.map +1 -1
  211. package/dist/lib/store-dir.js +20 -4
  212. package/dist/lib/store-dir.js.map +1 -1
  213. package/dist/lib/team-deploy-inspection.d.ts +2 -1
  214. package/dist/lib/team-deploy-inspection.d.ts.map +1 -1
  215. package/dist/lib/team-deploy-inspection.js +6 -1
  216. package/dist/lib/team-deploy-inspection.js.map +1 -1
  217. package/dist/lib/up-broker-address.d.ts +7 -0
  218. package/dist/lib/up-broker-address.d.ts.map +1 -0
  219. package/dist/lib/up-broker-address.js +76 -0
  220. package/dist/lib/up-broker-address.js.map +1 -0
  221. package/dist/lib/up-report.d.ts +2 -0
  222. package/dist/lib/up-report.d.ts.map +1 -1
  223. package/dist/lib/up-report.js +8 -1
  224. package/dist/lib/up-report.js.map +1 -1
  225. package/dist/lib/update-connector-config.d.ts +6 -0
  226. package/dist/lib/update-connector-config.d.ts.map +1 -0
  227. package/dist/lib/update-connector-config.js +44 -0
  228. package/dist/lib/update-connector-config.js.map +1 -0
  229. package/dist/seed/launch.d.ts +1 -1
  230. package/dist/seed/launch.d.ts.map +1 -1
  231. package/dist/seed/launch.js +3 -3
  232. package/dist/seed/launch.js.map +1 -1
  233. package/dist/seed/reconcile.d.ts +1 -1
  234. package/dist/seed/reconcile.d.ts.map +1 -1
  235. package/dist/seed/reconcile.js +28 -11
  236. package/dist/seed/reconcile.js.map +1 -1
  237. package/package.json +4 -4
@@ -1,6 +1,7 @@
1
1
  import { basename, join, resolve } from "node:path";
2
2
  import { CotalEndpoint, DEFAULT_SERVER, isReachable, realDirNoSymlink, subjectMatches, durableCovers } from "@cotal-ai/core";
3
- import { assertSingleSpaceBroker, recordOperationSpace, authDir, CommandFailure, oneLine, credentialRefusalMessage, brokerAddressForDisplay, canonicalRoot, connectOrThrow, findMesh, findPreparedSpace, preparedSpaceAt, jsonFlag, loadMeshes, localMeshesForRoot, nearbyMeshManifest, plainFlag, presentationOf, readMaintenanceJournal, shellPath, spaceFlag, userViewAuth, writeResult } from "@cotal-ai/workspace";
3
+ import { assertSingleSpaceBroker, recordOperationSpace, authDir, CommandFailure, oneLine, credentialRefusalMessage, brokerAddressForDisplay, canonicalRoot, codeSpan, connectOrThrow, findCotalRoot, findMesh, findPreparedSpace, preparedSpaceAt, jsonFlag, loadMeshes, localMeshesForRoot, nearbyMeshManifest, plainFlag, presentationOf, readMaintenanceJournal, shellPath, spaceFlag, userViewAuth, writeResult } from "@cotal-ai/workspace";
4
+ import { shellWord } from "../lib/endpoint-errors.js";
4
5
  import { personaCatalog } from "../lib/persona-files.js";
5
6
  import { formatIssue, loadManifest, ManifestError } from "../lib/manifest/index.js";
6
7
  import { UnusableFile } from "../lib/unusable-file.js";
@@ -8,7 +9,7 @@ import { findLedgerByRun, listLedgerFiles } from "../lib/manifest/ledger.js";
8
9
  import { findFreshTeamAttempt, findFreshTeamSummary, freshTeamAttemptSettled, freshTeamSummaryRecordedElsewhere, listFreshTeamAttempts, listFreshTeamSummaries } from "../lib/team-fresh.js";
9
10
  import { additiveTeamRecordedState, findAdditiveTeamAttempt, listAdditiveTeamAttempts, removedAdditiveDeploymentIds, stoppedAttemptEffects } from "../lib/team-additive-attempt.js";
10
11
  import { completedFlagValue, positionalsForCompletion } from "../lib/completion.js";
11
- import { cardsWithoutLiveDelivery, inspectTeamDeployment, LIVE_DELIVERY_REMEDY, readOwnedChannelRevisions } from "../lib/team-deploy-inspection.js";
12
+ import { cardsWithoutLiveDelivery, inspectTeamDeployment, liveDeliveryRemedy, readOwnedChannelRevisions } from "../lib/team-deploy-inspection.js";
12
13
  import { managerRecordState } from "../lib/manager-proc.js";
13
14
  import { authModeText, teamText } from "../lib/team-text.js";
14
15
  import { readLocalServiceCensus } from "../lib/service-census.js";
@@ -389,23 +390,16 @@ export async function team(args) {
389
390
  ] }));
390
391
  }
391
392
  async function previewDeploy(file, values) {
392
- if (values["dry-run"] !== true) {
393
- let resolved;
394
- try {
395
- resolved = loadManifest(resolve(file));
396
- }
397
- catch (e) {
398
- if (e instanceof ManifestError)
399
- throw manifestRefusal(e, resolve(file));
400
- throw new CommandFailure("refused", "SCHEMA_INVALID", "the additive manifest could not be resolved; no native effect was submitted");
401
- }
402
- if (resolved.agents.length) {
393
+ const dryRun = values["dry-run"] === true;
394
+ // Apply handlers perform their own exact target checks and report the selected space.
395
+ const { path, prepared } = readTeamFile(file, dryRun ? values.space : undefined);
396
+ if (!dryRun) {
397
+ if (prepared.agents.length) {
403
398
  const { applyAgentTeam } = await import("./team-agent-apply.js");
404
399
  return applyAgentTeam(file, values);
405
400
  }
406
401
  return applyChannelOnlyTeam(file, values);
407
402
  }
408
- const { path, prepared } = readTeamFile(file, values);
409
403
  const space = prepared.manifest.space;
410
404
  let local, waiting;
411
405
  try {
@@ -440,7 +434,7 @@ async function previewDeploy(file, values) {
440
434
  targetReachability: "native-reads-established", brokerPolicy: "not-checked", authorization: "read-established-not-deploy-authority", ownershipClassification: "native-roster-and-registry-snapshot", connectorAvailability: "not-checked", effectAttempted: false, persisted: false };
441
435
  writeResult(presentationOf(values), { command: "team deploy", target: { space, root: local.root, path }, result,
442
436
  completeness: "partial",
443
- warnings: [...prepared.warnings.map((warning) => ({ code: "MANIFEST_WARNING", target: { agent: warning.agent }, message: warning.message })), ...(openDurable ? [{ code: "OPEN_DURABLE_UNSUPPORTED", target: { space }, message: "The selected running mesh is open and has no delivery daemon; this manifest's durable declaration cannot acquire a per-member backstop." }] : []), ...(notLive ? [{ code: "LIVE_DELIVERY_REQUIRED", target: { space, cards: notLive.names }, message: `Apply refuses: ${notLive.cards} ${notLive.verb} not set deliveryClass: live. To deploy, ${LIVE_DELIVERY_REMEDY}.` }] : []), ...(!native.unmanaged.feedAvailable ? [{ code: "MEMBERSHIP_FEED_UNAVAILABLE", target: { space }, message: "Other readers are a lower bound because the derived membership feed has no observed heartbeat." }] : []), ...(attempts.valid.length || attempts.refused.length ? [{ code: "ADDITIVE_ATTEMPT_REMAINS", target: { root: local.root, space, deploymentIds: attempts.valid.map((attempt) => attempt.deploymentId), unreadable: attempts.refused.map(({ path }) => path) }, message: "An additive deployment intent is retained at this root; the preview does not settle or retry it." }] : [])] }, (data) => ({ sections: [
437
+ warnings: [...prepared.warnings.map((warning) => ({ code: "MANIFEST_WARNING", target: { agent: warning.agent }, message: warning.message })), ...(openDurable ? [{ code: "OPEN_DURABLE_UNSUPPORTED", target: { space }, message: "The selected running mesh is open and has no delivery daemon; this manifest's durable declaration cannot acquire a per-member backstop." }] : []), ...(notLive ? [{ code: "LIVE_DELIVERY_REQUIRED", target: { space, cards: notLive.names }, message: `Apply refuses: ${notLive.cards} ${notLive.verb} not set deliveryClass: live. To deploy, ${liveDeliveryRemedy(local.mode)}.` }] : []), ...(!native.unmanaged.feedAvailable ? [{ code: "MEMBERSHIP_FEED_UNAVAILABLE", target: { space }, message: "Other readers are a lower bound because the derived membership feed has no observed heartbeat." }] : []), ...(attempts.valid.length || attempts.refused.length ? [{ code: "ADDITIVE_ATTEMPT_REMAINS", target: { root: local.root, space, deploymentIds: attempts.valid.map((attempt) => attempt.deploymentId), unreadable: attempts.refused.map(({ path }) => path) }, message: "An additive deployment intent is retained at this root; the preview does not settle or retry it." }] : [])] }, (data) => ({ sections: [
444
438
  { title: "Additive team inspection", blocks: [{ kind: "fields", rows: [["Space", data.space], ["Registered root", data.root], ["Registration", data.registrationOrigin], ["Recorded broker", data.recordedBroker ?? "not displayable"], ["Recorded mode", authModeText(data.recordedMode)], ["TLS", data.recordedTlsRequired ? "required" : "not required"], ["Manifest", data.path], ["Runtime request", data.runtimeRequest], ["Prior additive run", data.native.priorDeploymentId ?? "none recorded"], ["Retained additive attempts", String(data.retainedAdditiveAttempts.length)], ["Unreadable additive attempts", String(data.unreadableAdditiveAttempts.length)], ["Native roster", data.native.roster], ["Channel registry", data.native.registry], ["Membership feed", data.native.unmanaged.feedAvailable ? "display-only lower bound" : "unavailable"], ...(data.recordedMode === "open" ? [["Durable delivery on open", data.openDurableUnsupported ? "unsupported" : "not a contradiction"]] : [])] }, { kind: "lines", lines: [{ text: "The observed registry and roster do not reserve names or authorize creation. Manager readiness, runtime/provider availability and write grants remain unchecked; nothing was added.", tone: "waiting" }] }] },
445
439
  { title: "Requested agents", blocks: [data.agents.length ? { kind: "table", columns: [{ key: "name", label: "Name" }, { key: "application", label: "Application" }, { key: "role", label: "Role" }, { key: "model", label: "Model request" }], rows: data.agents.slice(0, 100).map((agent) => ({ name: agent.name, application: agent.application, role: agent.role ?? "none", model: agent.requestedModel ?? "application default" })) } : { kind: "lines", lines: ["No agents requested."] }, ...(data.agents.length > 100 ? [{ kind: "lines", lines: ["Additional requested agents are in JSON."] }] : [])] },
446
440
  { title: "Declared channels", blocks: [data.channels.length ? { kind: "table", columns: [{ key: "name", label: "Channel" }, { key: "delivery", label: "Delivery class" }, { key: "replay", label: "Replay" }, { key: "window", label: "Replay window" }], rows: data.channels.slice(0, 100).map((channel) => ({ name: `#${channel.name}`, delivery: channel.deliveryClass ?? "not declared", replay: channel.replay === null ? "not declared" : channel.replay ? "on" : "off", window: channel.replayWindow ?? "not declared" })) } : { kind: "lines", lines: ["No channels declared."] }, { kind: "lines", lines: [...(data.channels.length > 100 ? ["Additional channels are in JSON."] : []), "Declared policy is not a live registry value or permission to overwrite existing metadata. Apply accepts all-new live channels and bounded static/open agent or mixed teams. Reapplying an identical settled deployment changes nothing; other existing cards refuse."] }] },
@@ -536,10 +530,32 @@ function removalShape(root, attempt) {
536
530
  throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", `this additive ID retains an unsettled attempt whose effects are not all recorded (${why}); team remove cannot infer which resources it created`, { target, remedy: `inspect \`cotal team show ${deploymentId}\` and the original native target; no effect was retried or removed` });
537
531
  }
538
532
  async function previewRemove(deploymentId, values) {
533
+ const catalog = personaCatalog(values);
534
+ recordOperationSpace(catalog.space);
535
+ let summary;
536
+ try {
537
+ summary = findFreshTeamSummary(catalog.root, deploymentId);
538
+ }
539
+ catch {
540
+ assertSummaryNotElsewhere(catalog.root, deploymentId);
541
+ throw new CommandFailure("refused", "SCHEMA_INVALID", "the fresh launch summary for this ID is unreadable; it cannot be treated as absent or as an additive removal target", { target: { space: catalog.space, deploymentId } });
542
+ }
543
+ if (summary) {
544
+ const atRoot = canonicalRoot(findCotalRoot()) === catalog.root ? "" : `cd ${shellPath(catalog.root)} && `;
545
+ throw new CommandFailure("refused", "CONFLICT", "this ID belongs to a fresh boot summary, not an additive ownership ledger; team remove did not infer whole-stack stop authority", { target: { recordedSpace: summary.space, recordedRoot: summary.root, selectedSpace: catalog.space, deploymentId }, remedy: `stop the booted stack with ${codeSpan(`${atRoot}cotal down`)}; preview that stop with ${codeSpan(`${atRoot}cotal down --space ${shellWord(summary.space)} --dry-run`)}` });
546
+ }
547
+ let freshAttempt;
548
+ try {
549
+ freshAttempt = findFreshTeamAttempt(catalog.root, deploymentId);
550
+ }
551
+ catch {
552
+ throw new CommandFailure("refused", "SCHEMA_INVALID", "the fresh boot attempt for this ID is unreadable; it was not treated as an additive target", { target: { root: catalog.root, deploymentId } });
553
+ }
554
+ if (freshAttempt)
555
+ throw new CommandFailure("refused", "CONFLICT", "this ID belongs to a fresh boot attempt, not an additive removal target", { target: { root: catalog.root, deploymentId } });
539
556
  if (values["dry-run"] !== true) {
540
557
  // The original intent picks the route; each route revalidates its own returned or stopped receipt.
541
558
  let routed;
542
- const catalog = personaCatalog(values);
543
559
  try {
544
560
  routed = findAdditiveTeamAttempt(catalog.root, deploymentId);
545
561
  }
@@ -563,27 +579,6 @@ async function previewRemove(deploymentId, values) {
563
579
  const { removeAgentTeam } = await import("./team-agent-remove.js");
564
580
  return removeAgentTeam(deploymentId, values);
565
581
  }
566
- const catalog = personaCatalog(values);
567
- recordOperationSpace(catalog.space);
568
- let summary;
569
- try {
570
- summary = findFreshTeamSummary(catalog.root, deploymentId);
571
- }
572
- catch {
573
- assertSummaryNotElsewhere(catalog.root, deploymentId);
574
- throw new CommandFailure("refused", "SCHEMA_INVALID", "the fresh launch summary for this ID is unreadable; it cannot be treated as absent or as an additive removal target", { target: { space: catalog.space, deploymentId } });
575
- }
576
- if (summary)
577
- throw new CommandFailure("refused", "CONFLICT", "this ID belongs to a fresh boot summary, not an additive ownership ledger; team remove did not infer whole-stack stop authority", { target: { recordedSpace: summary.space, recordedRoot: summary.root, selectedSpace: catalog.space, deploymentId }, remedy: `stop the booted stack with \`cotal down\`; preview that stop with \`cotal down --space ${summary.space} --dry-run\`` });
578
- let freshAttempt;
579
- try {
580
- freshAttempt = findFreshTeamAttempt(catalog.root, deploymentId);
581
- }
582
- catch {
583
- throw new CommandFailure("refused", "SCHEMA_INVALID", "the fresh boot attempt for this ID is unreadable; it was not treated as an additive target", { target: { root: catalog.root, deploymentId } });
584
- }
585
- if (freshAttempt)
586
- throw new CommandFailure("refused", "CONFLICT", "this ID belongs to a fresh boot attempt, not an additive removal target", { target: { root: catalog.root, deploymentId } });
587
582
  let attempt;
588
583
  try {
589
584
  attempt = findAdditiveTeamAttempt(catalog.root, deploymentId);
@@ -666,7 +661,7 @@ function accessGraph(prepared) {
666
661
  allowPublish: prepared.agents.filter((agent) => agent.policy.allowPublish.includes(name)).map((agent) => agent.name),
667
662
  }));
668
663
  }
669
- function readTeamFile(file, values) {
664
+ function readTeamFile(file, space) {
670
665
  const path = resolve(file);
671
666
  let prepared;
672
667
  try {
@@ -682,7 +677,7 @@ function readTeamFile(file, values) {
682
677
  throw new CommandFailure("refused", "TARGET_NOT_FOUND", `the team manifest ${path} was not found; no broker was contacted`, { target: { path }, remedy: "check the file path and run the command again" });
683
678
  throw new CommandFailure("refused", "SCHEMA_INVALID", "the team manifest or referenced persona could not be read and resolved; no broker was contacted", { target: { path }, remedy: "check the manifest schema, persona paths and permission declarations" });
684
679
  }
685
- if (values.space !== undefined && values.space !== prepared.manifest.space)
680
+ if (space !== undefined && space !== prepared.manifest.space)
686
681
  throw new CommandFailure("refused", "CONFLICT", "--space must agree with the manifest's recorded target; the file was not rebound");
687
682
  return { path, prepared };
688
683
  }
@@ -696,7 +691,7 @@ function manifestRefusal(e, path) {
696
691
  return new CommandFailure("refused", "SCHEMA_INVALID", `${issues.length === 1 ? "the team manifest has a problem" : `the team manifest has ${issues.length} problems`}, so no broker was contacted: ${shown.join("; ")}`, { target: { path, issues }, remedy: "fix each named problem and run team check again" });
697
692
  }
698
693
  async function bootTeam(file, values) {
699
- const { path, prepared } = readTeamFile(file, values), space = prepared.manifest.space;
694
+ const { path, prepared } = readTeamFile(file, values.space), space = prepared.manifest.space;
700
695
  let local, waiting;
701
696
  try {
702
697
  local = findMesh(space);
@@ -726,7 +721,7 @@ async function bootTeam(file, values) {
726
721
  async function previewBoot(file, values) {
727
722
  if (values["dry-run"] !== true)
728
723
  return bootTeam(file, values);
729
- const { path, prepared } = readTeamFile(file, values);
724
+ const { path, prepared } = readTeamFile(file, values.space);
730
725
  const space = prepared.manifest.space;
731
726
  let local, waiting;
732
727
  try {
@@ -827,7 +822,7 @@ async function previewBoot(file, values) {
827
822
  ] }));
828
823
  }
829
824
  async function checkTeam(file, values) {
830
- const { path, prepared } = readTeamFile(file, values);
825
+ const { path, prepared } = readTeamFile(file, values.space);
831
826
  const openDurable = prepared.manifest.broker?.auth === false && (prepared.manifest.defaults?.deliveryClass === "durable" || prepared.manifest.channels.some((channel) => channel.deliveryClass === "durable"));
832
827
  const result = { kind: "team-check", file: path, space: prepared.manifest.space, runtime: prepared.manifest.runtime ?? "pty",
833
828
  agents: prepared.agents.map((agent) => ({ name: agent.name, harness: agent.agentType, role: agent.role ?? null, model: agent.model ?? null, policy: agent.policy, inherited: agent.inherited, capabilities: agent.capabilities, capabilitySource: agent.capabilitySource })),