@cotal-ai/cli 0.5.0 → 0.7.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 (90) hide show
  1. package/dist/command.d.ts.map +1 -1
  2. package/dist/command.js +3 -2
  3. package/dist/command.js.map +1 -1
  4. package/dist/commands/channels.d.ts +4 -2
  5. package/dist/commands/channels.d.ts.map +1 -1
  6. package/dist/commands/channels.js +17 -18
  7. package/dist/commands/channels.js.map +1 -1
  8. package/dist/commands/completion.d.ts.map +1 -1
  9. package/dist/commands/completion.js +5 -1
  10. package/dist/commands/completion.js.map +1 -1
  11. package/dist/commands/console.d.ts.map +1 -1
  12. package/dist/commands/console.js +13 -29
  13. package/dist/commands/console.js.map +1 -1
  14. package/dist/commands/down.d.ts +1 -1
  15. package/dist/commands/down.d.ts.map +1 -1
  16. package/dist/commands/down.js +13 -1
  17. package/dist/commands/down.js.map +1 -1
  18. package/dist/commands/history.d.ts.map +1 -1
  19. package/dist/commands/history.js +6 -13
  20. package/dist/commands/history.js.map +1 -1
  21. package/dist/commands/join.d.ts.map +1 -1
  22. package/dist/commands/join.js +20 -7
  23. package/dist/commands/join.js.map +1 -1
  24. package/dist/commands/meshes.d.ts +5 -0
  25. package/dist/commands/meshes.d.ts.map +1 -0
  26. package/dist/commands/meshes.js +25 -0
  27. package/dist/commands/meshes.js.map +1 -0
  28. package/dist/commands/mint.d.ts +4 -1
  29. package/dist/commands/mint.d.ts.map +1 -1
  30. package/dist/commands/mint.js +26 -3
  31. package/dist/commands/mint.js.map +1 -1
  32. package/dist/commands/send.d.ts +8 -15
  33. package/dist/commands/send.d.ts.map +1 -1
  34. package/dist/commands/send.js +41 -24
  35. package/dist/commands/send.js.map +1 -1
  36. package/dist/commands/setup.d.ts.map +1 -1
  37. package/dist/commands/setup.js +23 -18
  38. package/dist/commands/setup.js.map +1 -1
  39. package/dist/commands/spawn.d.ts +4 -2
  40. package/dist/commands/spawn.d.ts.map +1 -1
  41. package/dist/commands/spawn.js +54 -22
  42. package/dist/commands/spawn.js.map +1 -1
  43. package/dist/commands/up.d.ts.map +1 -1
  44. package/dist/commands/up.js +133 -6
  45. package/dist/commands/up.js.map +1 -1
  46. package/dist/commands/use.d.ts +7 -0
  47. package/dist/commands/use.d.ts.map +1 -0
  48. package/dist/commands/use.js +27 -0
  49. package/dist/commands/use.js.map +1 -0
  50. package/dist/commands/web.d.ts.map +1 -1
  51. package/dist/commands/web.js +57 -27
  52. package/dist/commands/web.js.map +1 -1
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +24 -37
  55. package/dist/index.js.map +1 -1
  56. package/dist/lib/connect.d.ts +72 -0
  57. package/dist/lib/connect.d.ts.map +1 -0
  58. package/dist/lib/connect.js +115 -0
  59. package/dist/lib/connect.js.map +1 -0
  60. package/dist/lib/delivery-proc.d.ts +35 -0
  61. package/dist/lib/delivery-proc.d.ts.map +1 -0
  62. package/dist/lib/delivery-proc.js +128 -0
  63. package/dist/lib/delivery-proc.js.map +1 -0
  64. package/dist/lib/manager-proc.d.ts +11 -2
  65. package/dist/lib/manager-proc.d.ts.map +1 -1
  66. package/dist/lib/manager-proc.js +43 -3
  67. package/dist/lib/manager-proc.js.map +1 -1
  68. package/dist/lib/meshes.d.ts +8 -0
  69. package/dist/lib/meshes.d.ts.map +1 -0
  70. package/dist/lib/meshes.js +15 -0
  71. package/dist/lib/meshes.js.map +1 -0
  72. package/dist/lib/onboard.js +6 -6
  73. package/dist/lib/onboard.js.map +1 -1
  74. package/dist/lib/transient.d.ts +7 -6
  75. package/dist/lib/transient.d.ts.map +1 -1
  76. package/dist/lib/transient.js +6 -25
  77. package/dist/lib/transient.js.map +1 -1
  78. package/dist/render.js +1 -1
  79. package/dist/web/graph.html +204 -0
  80. package/dist/web/graph.js +453 -0
  81. package/dist/web/index.html +6 -0
  82. package/package.json +2 -2
  83. package/dist/commands/signer.d.ts +0 -6
  84. package/dist/commands/signer.d.ts.map +0 -1
  85. package/dist/commands/signer.js +0 -30
  86. package/dist/commands/signer.js.map +0 -1
  87. package/dist/commands/watch.d.ts +0 -4
  88. package/dist/commands/watch.d.ts.map +0 -1
  89. package/dist/commands/watch.js +0 -7
  90. package/dist/commands/watch.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { registry } from "@cotal-ai/core";
2
2
  import { up } from "./commands/up.js";
3
3
  import { down } from "./commands/down.js";
4
+ import { use, useComplete } from "./commands/use.js";
5
+ import { meshes } from "./commands/meshes.js";
4
6
  import { setup, go } from "./commands/setup.js";
5
7
  import { join } from "./commands/join.js";
6
- import { watch } from "./commands/watch.js";
7
8
  import { console_ } from "./commands/console.js";
8
9
  import { demo } from "./commands/demo.js";
9
10
  import { web } from "./commands/web.js";
@@ -11,12 +12,11 @@ import { spawn, spawnComplete } from "./commands/spawn.js";
11
12
  import { personas, personasComplete } from "./commands/personas.js";
12
13
  import { completion, completionComplete, complete } from "./commands/completion.js";
13
14
  import { mint } from "./commands/mint.js";
14
- import { signer } from "./commands/signer.js";
15
15
  import { channels } from "./commands/channels.js";
16
16
  import { history } from "./commands/history.js";
17
17
  import { feedback } from "./commands/feedback.js";
18
- import { dm, msg, ask, msgComplete, askComplete } from "./commands/send.js";
19
- /** The minimal mesh CLI: thin NATS clients (up/join/watch), plus `spawn` — a
18
+ import { send, sendComplete } from "./commands/send.js";
19
+ /** The minimal mesh CLI: thin NATS clients (up/join/console), plus `spawn` — a
20
20
  * foreground agent launch that reuses the connector's launch recipe. Self-registers
21
21
  * on import; heavier surfaces (the manager's control plane) register the same way
22
22
  * and are composed at a root. */
@@ -46,48 +46,39 @@ const baseCommands = [
46
46
  kind: "command",
47
47
  name: "down",
48
48
  group: "Mesh",
49
- summary: "stop a background mesh started with `up --detach`",
49
+ summary: "stop a background mesh started with `up --detach` (run from its project — local only)",
50
50
  run: down,
51
51
  },
52
52
  {
53
53
  kind: "command",
54
- name: "join",
55
- group: "Mesh",
56
- summary: "join a space (interactive) — --space <s> --name <n> [--role <r>]",
57
- run: join,
58
- },
59
- {
60
- kind: "command",
61
- name: "watch",
54
+ name: "meshes",
62
55
  group: "Mesh",
63
- summary: "observe all activity in a space --space <s>",
64
- run: watch,
56
+ summary: "list the running meshes (a `*` marks the `current` default a bare spawn joins)",
57
+ run: meshes,
65
58
  },
66
59
  {
67
60
  kind: "command",
68
- name: "dm",
61
+ name: "use",
69
62
  group: "Mesh",
70
- summary: "direct-message a peer by name",
71
- usage: 'dm <agent> "<text>" [--space <s>] [--server <url>] [--creds <path>]',
72
- run: dm,
63
+ summary: "set the default mesh for a bare `cotal spawn` when several are running — use <space>",
64
+ run: use,
65
+ complete: useComplete,
73
66
  },
74
67
  {
75
68
  kind: "command",
76
- name: "msg",
69
+ name: "join",
77
70
  group: "Mesh",
78
- summary: "broadcast a message to a channel",
79
- usage: 'msg <channel> "<text>" [--space <s>] [--server <url>] [--creds <path>]',
80
- run: msg,
81
- complete: msgComplete,
71
+ summary: "join a space (interactive) --space <s> --name <n> [--role <r>]",
72
+ run: join,
82
73
  },
83
74
  {
84
75
  kind: "command",
85
- name: "ask",
76
+ name: "send",
86
77
  group: "Mesh",
87
- summary: "anycast a message to a role (one instance answers)",
88
- usage: 'ask <role> "<text>" [--space <s>] [--server <url>] [--creds <path>]',
89
- run: ask,
90
- complete: askComplete,
78
+ summary: "send one message, then exit send <dm <agent> | msg <channel> | ask <role>> \"<text>\"",
79
+ usage: 'send <dm <agent> | msg <channel> | ask <role>> "<text>" [--space <s>] [--server <url>] [--creds <path>]',
80
+ run: send,
81
+ complete: sendComplete,
91
82
  },
92
83
  {
93
84
  kind: "command",
@@ -100,6 +91,9 @@ const baseCommands = [
100
91
  kind: "command",
101
92
  name: "demo",
102
93
  group: "Mesh",
94
+ // A dev/test traffic generator (see docs/protocol-view.md) — runnable, but kept off the
95
+ // top-level help so it doesn't clutter the user-facing surface.
96
+ hidden: true,
103
97
  summary: "replay a scripted multi-agent trace (all message types) to exercise the console/web — --space <s> [--interval <ms>] [--once]",
104
98
  run: demo,
105
99
  },
@@ -145,16 +139,9 @@ const baseCommands = [
145
139
  kind: "command",
146
140
  name: "mint",
147
141
  group: "Mesh",
148
- summary: "mint a creds file for a space (auth mode) — mint <name> --profile <agent|observer> [--out <path>]",
142
+ summary: "mint a creds file for a space (auth mode) — mint <name> --profile <agent|observer> [--out <path>]; --signer emits a stripped account-signing file (no operator key) for a containerized manager",
149
143
  run: mint,
150
144
  },
151
- {
152
- kind: "command",
153
- name: "signer",
154
- group: "Mesh",
155
- summary: "emit a stripped signer file (account signing material only, no operator key) for a containerized manager — [--out <path>] [--force]",
156
- run: signer,
157
- },
158
145
  {
159
146
  kind: "command",
160
147
  name: "channels",
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAAE,I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C,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,72 @@
1
+ import { type MeshTarget, type Profile, type SpaceAuth } from "@cotal-ai/core";
2
+ /**
3
+ * The one way every command that touches a running mesh figures out WHICH mesh + with what creds,
4
+ * and confirms it's actually up — so `spawn`, `send`/`dm`/`msg`/`ask`, `console`, `join`, `web`,
5
+ * `channels`, `history`, and `personas --running` all behave identically from any directory instead
6
+ * of each re-deriving it from a cwd walk-up (which mistook `$HOME/.cotal` for a space and crashed
7
+ * with a raw NATS auth violation). Two escape hatches take a RAW off-registry connection (no
8
+ * registry lookup, no stale-prune): explicit `--creds`, and `--server` + an unregistered `--space`
9
+ * (an open remote mesh that has no creds to pass).
10
+ */
11
+ export interface ConnectFlags {
12
+ server?: string;
13
+ space?: string;
14
+ /** Explicit creds file — triggers a raw off-registry connection (see {@link connectOrExit}). */
15
+ creds?: string;
16
+ }
17
+ /** Raw NATS auth for an off-registry connection — a join link / --token / --user+--pass / --creds.
18
+ * Structurally matches what `probeConnect` accepts. */
19
+ export interface RawAuth {
20
+ token?: string;
21
+ user?: string;
22
+ pass?: string;
23
+ creds?: string;
24
+ tls?: boolean;
25
+ }
26
+ export interface Connection {
27
+ server: string;
28
+ space: string;
29
+ creds?: string;
30
+ /** The mesh's trust material when resolved from the registry on an auth mesh — undefined for an
31
+ * open mesh or a raw off-registry connection (`--creds` or `--server`+unregistered `--space`).
32
+ * (web keeps it for its per-delete manager mint.) */
33
+ auth?: SpaceAuth;
34
+ }
35
+ /**
36
+ * Resolve where a mesh-touching command connects + with what creds.
37
+ * • Explicit `--creds` → a RAW off-registry connection: straight to `--server` (default loopback)
38
+ * as `--space`, with those creds. No registry lookup, no stale-prune, plain reachability message
39
+ * (the user is deliberately off-registry — e.g. a remote mesh that isn't locally recorded).
40
+ * • Otherwise → resolve the running mesh from the registry (works from any dir), mint `role` creds
41
+ * on an auth mesh, and preflight with the registry's stale-prune.
42
+ */
43
+ export declare function connectOrExit(flags: ConnectFlags, role: Profile): Promise<Connection>;
44
+ /** Reachability check for a RAW (off-registry) connection — one plain sentence, never a registry/
45
+ * stale-entry message and never a prune. Used by the `--creds` escape hatch and `join`'s explicit
46
+ * (link/token/creds) path, both of which connect to a broker the user named, not the registry. */
47
+ export declare function reachableOrExit(server: string, auth?: RawAuth): Promise<void>;
48
+ /** Resolve the mesh a command targets, exiting with one human sentence on an unresolved/ambiguous
49
+ * registry rather than a stack trace. Prunes dead registry entries first so a crashed mesh doesn't
50
+ * block a bare command or get offered by `--space`. */
51
+ export declare function resolveTargetOrExit(flags: {
52
+ server?: string;
53
+ space?: string;
54
+ }): Promise<MeshTarget>;
55
+ /** The five distinct ways a preflight fails. Each also says whether the target OWNS its registry
56
+ * entry (→ prune): `fromRegistry` means the server+mode came from a registry record (incl. a
57
+ * `local-recorded` project matched by root), so a definitive failure is a stale-entry signal. */
58
+ export type PreflightFailure = "unreachable" | "registry-creds-rejected" | "registry-open-now-auth" | "creds-rejected" | "open-wants-auth";
59
+ /** Pure decision for {@link preflightOrExit} — separated from I/O so the whole branch tree is
60
+ * unit-testable (it's the riskiest new logic: a wrong branch prunes a LIVE registry entry). A
61
+ * non-registry source (`flag-server`/`local-space`, or a raw `--creds` connection) is NEVER pruned;
62
+ * the user owns that diagnosis. */
63
+ export declare function classifyPreflightFailure(source: MeshTarget["source"], reason: "auth-required" | "unreachable", hasAuth: boolean): {
64
+ prune: boolean;
65
+ kind: PreflightFailure;
66
+ };
67
+ /** Confirm the resolved mesh is up and accepts these creds — replaces the raw NATS "Authorization
68
+ * Violation" trace with one sentence, and prunes the entry if the broker is gone / mismatched.
69
+ * Probes with `probeCreds` when given (the caller's `--creds`/minted creds); otherwise mints a
70
+ * throwaway identity from the target's own trust material. */
71
+ export declare function preflightOrExit(target: MeshTarget, probeCreds?: string): Promise<void>;
72
+ //# sourceMappingURL=connect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect.d.ts","sourceRoot":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;oCAGoC;AACpC,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC5B,MAAM,EAAE,eAAe,GAAG,aAAa,EACvC,OAAO,EAAE,OAAO,GACf;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAW5C;AAiBD;;;+DAG+D;AAC/D,wBAAsB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAS5F"}
@@ -0,0 +1,115 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { DEFAULT_SERVER, DEFAULT_SPACE, findMesh, getCurrent, mintCreds, newIdentity, probeConnect, removeMesh, resolveMeshTarget, } from "@cotal-ai/core";
3
+ import { c } from "../ui.js";
4
+ import { pruneStaleMeshes } from "./meshes.js";
5
+ /**
6
+ * Resolve where a mesh-touching command connects + with what creds.
7
+ * • Explicit `--creds` → a RAW off-registry connection: straight to `--server` (default loopback)
8
+ * as `--space`, with those creds. No registry lookup, no stale-prune, plain reachability message
9
+ * (the user is deliberately off-registry — e.g. a remote mesh that isn't locally recorded).
10
+ * • Otherwise → resolve the running mesh from the registry (works from any dir), mint `role` creds
11
+ * on an auth mesh, and preflight with the registry's stale-prune.
12
+ */
13
+ export async function connectOrExit(flags, role) {
14
+ if (flags.creds) {
15
+ const server = flags.server ?? DEFAULT_SERVER;
16
+ const space = flags.space ?? DEFAULT_SPACE;
17
+ const creds = readFileSync(flags.creds, "utf8");
18
+ await reachableOrExit(server, { creds });
19
+ return { server, space, creds };
20
+ }
21
+ // A raw OPEN remote mesh: explicit `--server` + a `--space` that isn't locally registered. Naming
22
+ // both is as deliberate as `--creds`, but an open broker has no creds to pass — connect bare,
23
+ // off-registry (no registry lookup, no prune). A registered `--space` still goes through the
24
+ // resolver below (which honors `--server` as an override); `--server` alone resolves there too.
25
+ if (flags.server && flags.space && !findMesh(flags.space)) {
26
+ await reachableOrExit(flags.server, {});
27
+ return { server: flags.server, space: flags.space };
28
+ }
29
+ const target = await resolveTargetOrExit({ server: flags.server, space: flags.space });
30
+ const creds = target.auth ? await mintCreds(target.auth, newIdentity(), role) : undefined;
31
+ await preflightOrExit(target, creds);
32
+ return { server: target.server, space: target.space, creds, auth: target.auth };
33
+ }
34
+ /** Reachability check for a RAW (off-registry) connection — one plain sentence, never a registry/
35
+ * stale-entry message and never a prune. Used by the `--creds` escape hatch and `join`'s explicit
36
+ * (link/token/creds) path, both of which connect to a broker the user named, not the registry. */
37
+ export async function reachableOrExit(server, auth = {}) {
38
+ const probe = await probeConnect(server, auth);
39
+ if (probe.ok)
40
+ return;
41
+ console.error(c.red(probe.reason === "auth-required"
42
+ ? `✗ credentials rejected at ${server} — check your creds, or the broker wants different auth`
43
+ : `✗ can't reach a broker at ${server} — is it running? (\`cotal up\`)`));
44
+ process.exit(1);
45
+ }
46
+ /** Resolve the mesh a command targets, exiting with one human sentence on an unresolved/ambiguous
47
+ * registry rather than a stack trace. Prunes dead registry entries first so a crashed mesh doesn't
48
+ * block a bare command or get offered by `--space`. */
49
+ export async function resolveTargetOrExit(flags) {
50
+ await pruneStaleMeshes();
51
+ let target;
52
+ try {
53
+ target = resolveMeshTarget(process.cwd(), flags);
54
+ }
55
+ catch (e) {
56
+ console.error(c.red(`✗ ${e.message}`));
57
+ process.exit(1);
58
+ }
59
+ // If a dangling `current` was silently bypassed — it named a mesh that's since gone and we fell
60
+ // back to the only live one — say so. The N>1 case errors loudly; this is the one spot that would
61
+ // otherwise quietly redirect a stale default.
62
+ const cur = getCurrent();
63
+ if (cur && !findMesh(cur) && target.source === "registry")
64
+ console.error(c.dim(`note: default mesh "${cur}" is down — using "${target.space}"`));
65
+ return target;
66
+ }
67
+ /** Pure decision for {@link preflightOrExit} — separated from I/O so the whole branch tree is
68
+ * unit-testable (it's the riskiest new logic: a wrong branch prunes a LIVE registry entry). A
69
+ * non-registry source (`flag-server`/`local-space`, or a raw `--creds` connection) is NEVER pruned;
70
+ * the user owns that diagnosis. */
71
+ export function classifyPreflightFailure(source, reason, hasAuth) {
72
+ const fromRegistry = source === "registry" ||
73
+ source === "current" ||
74
+ source === "flag-space" ||
75
+ source === "local-recorded";
76
+ if (reason === "unreachable")
77
+ return { prune: fromRegistry, kind: "unreachable" };
78
+ if (fromRegistry && hasAuth)
79
+ return { prune: true, kind: "registry-creds-rejected" };
80
+ if (fromRegistry)
81
+ return { prune: true, kind: "registry-open-now-auth" };
82
+ if (hasAuth)
83
+ return { prune: false, kind: "creds-rejected" };
84
+ return { prune: false, kind: "open-wants-auth" };
85
+ }
86
+ function preflightMessage(kind, t, pruned) {
87
+ switch (kind) {
88
+ case "unreachable":
89
+ return `✗ no mesh running at ${t.server}${pruned ? " (stale registry entry — removed)" : ""} — run \`cotal up\``;
90
+ case "registry-creds-rejected":
91
+ return `✗ mesh "${t.space}" at ${t.server} no longer matches its registry entry (credentials rejected — port reused?) — re-run \`cotal up\` from ${t.root}, or \`cotal meshes\` to see what's live`;
92
+ case "registry-open-now-auth":
93
+ return `✗ open mesh "${t.space}" at ${t.server} no longer matches its registry entry (broker now requires auth — port reused?) — re-run \`cotal up\` from ${t.root}, or \`cotal meshes\` to see what's live`;
94
+ case "creds-rejected":
95
+ return `✗ credentials for "${t.space}" were rejected at ${t.server} — a different mesh may be running there. Run \`cotal meshes\` to check, or \`cotal up\` here to start yours`;
96
+ case "open-wants-auth":
97
+ return `✗ broker at ${t.server} requires auth, but this mesh is open (no trust material) — use \`--space <name>\` for an auth mesh, or run \`cotal up\` here without \`--open\``;
98
+ }
99
+ }
100
+ /** Confirm the resolved mesh is up and accepts these creds — replaces the raw NATS "Authorization
101
+ * Violation" trace with one sentence, and prunes the entry if the broker is gone / mismatched.
102
+ * Probes with `probeCreds` when given (the caller's `--creds`/minted creds); otherwise mints a
103
+ * throwaway identity from the target's own trust material. */
104
+ export async function preflightOrExit(target, probeCreds) {
105
+ const creds = probeCreds ?? (target.auth ? await mintCreds(target.auth, newIdentity(), "manager") : undefined);
106
+ const probe = await probeConnect(target.server, creds ? { creds } : {});
107
+ if (probe.ok)
108
+ return;
109
+ const { prune, kind } = classifyPreflightFailure(target.source, probe.reason, Boolean(target.auth));
110
+ if (prune)
111
+ removeMesh(target.space);
112
+ console.error(c.red(preflightMessage(kind, target, prune)));
113
+ process.exit(1);
114
+ }
115
+ //# sourceMappingURL=connect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/lib/connect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EACL,cAAc,EACd,aAAa,EACb,QAAQ,EACR,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,iBAAiB,GAIlB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAuC/C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAAmB,EAAE,IAAa;IACpE,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,cAAc,CAAC;QAC9C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,aAAa,CAAC;QAC3C,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChD,MAAM,eAAe,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACzC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAClC,CAAC;IACD,kGAAkG;IAClG,8FAA8F;IAC9F,6FAA6F;IAC7F,gGAAgG;IAChG,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC,QAAQ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IAAI,KAAK,CAAC,EAAE;QAAE,OAAO;IACrB,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,wBAAwB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACpG,IAAI,KAAK;QAAE,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
@@ -0,0 +1,35 @@
1
+ type Opts = {
2
+ space?: string;
3
+ server?: string;
4
+ spawn?: string[];
5
+ };
6
+ /** True if the delivery daemon we started for this folder is still running (pid file + liveness). */
7
+ export declare function deliveryUp(): boolean;
8
+ /** Cutover preflight — the FIRST action, BEFORE the daemon can bind: stop any old Plane-3-hosting
9
+ * manager (live `manager.pid` without the delivery-aware marker) so it never double-binds the
10
+ * daemon's durables. A delivery-aware (this-build) manager is left running. No-op on a fresh install. */
11
+ export declare function stopOldHostingManagerIfPresent(): void;
12
+ /** Start the delivery daemon detached (pid in `.cotal/delivery.pid`, output to `.cotal/delivery.log`),
13
+ * stopped by `cotal down`. Re-execs this CLI's `deliver` command; the daemon loads the pre-minted
14
+ * scoped `delivery.creds` (written by {@link ensureDelivery}) — it never sees the signer. */
15
+ export declare function startDeliveryDetached(o?: Opts): number;
16
+ /** Make the server-side delivery daemon available (auth mode only). FAILS CLOSED: refuses to launch
17
+ * while an old Plane-3-hosting manager is live (the preflight should have stopped it) so the daemon
18
+ * never double-binds. Mints a SCOPED `delivery` cred from the local signer ONCE, writes it to
19
+ * `.cotal/delivery.creds` (0600), and launches the daemon WITHOUT signer access. Best-effort — callers
20
+ * treat it as non-fatal (a missing daemon degrades durable delivery, never live). */
21
+ export declare function ensureDelivery(o?: Opts): Promise<{
22
+ running: boolean;
23
+ }>;
24
+ /** Stop the detached delivery daemon if we started one, and drop its creds file. */
25
+ export declare function stopDelivery(): void;
26
+ /** Bring up the control plane in the correct cutover order: OLD-manager preflight → delivery daemon
27
+ * (auth only, fails closed on a live old manager) → manager (lifecycle, writes the delivery-aware
28
+ * marker). The manager no longer depends on the daemon (it hosts no Plane-3), so the daemon is started
29
+ * first only to close the old-manager double-bind window and so freshly-spawned agents find the
30
+ * `ctl.delivery` responder for their boot self-join (a miss honest-degrades to live-only). */
31
+ export declare function ensureControlPlane(o?: Opts): Promise<{
32
+ running: boolean;
33
+ }>;
34
+ export {};
35
+ //# sourceMappingURL=delivery-proc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-proc.d.ts","sourceRoot":"","sources":["../../src/lib/delivery-proc.ts"],"names":[],"mappings":"AAmBA,KAAK,IAAI,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAWlE,qGAAqG;AACrG,wBAAgB,UAAU,IAAI,OAAO,CAKpC;AAeD;;0GAE0G;AAC1G,wBAAgB,8BAA8B,IAAI,IAAI,CAKrD;AAED;;8FAE8F;AAC9F,wBAAgB,qBAAqB,CAAC,CAAC,GAAE,IAAS,GAAG,MAAM,CAgB1D;AAED;;;;sFAIsF;AACtF,wBAAsB,cAAc,CAAC,CAAC,GAAE,IAAS,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA6BhF;AAED,oFAAoF;AACpF,wBAAgB,YAAY,IAAI,IAAI,CAanC;AAED;;;;+FAI+F;AAC/F,wBAAsB,kBAAkB,CAAC,CAAC,GAAE,IAAS,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAIpF"}
@@ -0,0 +1,128 @@
1
+ import { spawn } from "node:child_process";
2
+ import { existsSync, openSync, closeSync, writeFileSync, readFileSync, rmSync } from "node:fs";
3
+ import { DEFAULT_SERVER, authDir, findCotalRoot, loadSpaceAuth, mintCreds, newIdentity, waitForDeliveryLease, } from "@cotal-ai/core";
4
+ import { selfArgv } from "./self-exec.js";
5
+ import { resolveSpace } from "./status.js";
6
+ import { cotalPath } from "./paths.js";
7
+ import { ensureManager, managerHasDeliveryMarker, managerUp, stopManager } from "./manager-proc.js";
8
+ const PID_PATH = () => cotalPath("delivery.pid");
9
+ const CREDS_PATH = () => cotalPath("delivery.creds");
10
+ function alive(pid) {
11
+ try {
12
+ process.kill(pid, 0);
13
+ return true;
14
+ }
15
+ catch {
16
+ return false;
17
+ }
18
+ }
19
+ /** True if the delivery daemon we started for this folder is still running (pid file + liveness). */
20
+ export function deliveryUp() {
21
+ const p = PID_PATH();
22
+ if (!existsSync(p))
23
+ return false;
24
+ const pid = Number(readFileSync(p, "utf8").trim());
25
+ return Number.isFinite(pid) && alive(pid);
26
+ }
27
+ /** True when this folder runs an authed mesh — the only mode with a delivery daemon (Plane-3 needs the
28
+ * trusted reader; open dev mode is live-only). */
29
+ function hasAuth() {
30
+ return Boolean(loadSpaceAuth(authDir(findCotalRoot())));
31
+ }
32
+ /** True if an OLD (pre-delivery-daemon) Plane-3-hosting manager is live: a `manager.pid` that is alive
33
+ * but carries no delivery-aware marker. Such a manager still calls `startPlane3` and would double-bind
34
+ * `fanout`/`reader` against the new daemon. */
35
+ function oldHostingManagerLive() {
36
+ return managerUp() && !managerHasDeliveryMarker();
37
+ }
38
+ /** Cutover preflight — the FIRST action, BEFORE the daemon can bind: stop any old Plane-3-hosting
39
+ * manager (live `manager.pid` without the delivery-aware marker) so it never double-binds the
40
+ * daemon's durables. A delivery-aware (this-build) manager is left running. No-op on a fresh install. */
41
+ export function stopOldHostingManagerIfPresent() {
42
+ if (oldHostingManagerLive()) {
43
+ console.error("• stopping an old Plane-3-hosting manager before starting the delivery daemon (cutover preflight)");
44
+ stopManager();
45
+ }
46
+ }
47
+ /** Start the delivery daemon detached (pid in `.cotal/delivery.pid`, output to `.cotal/delivery.log`),
48
+ * stopped by `cotal down`. Re-execs this CLI's `deliver` command; the daemon loads the pre-minted
49
+ * scoped `delivery.creds` (written by {@link ensureDelivery}) — it never sees the signer. */
50
+ export function startDeliveryDetached(o = {}) {
51
+ const fd = openSync(cotalPath("delivery.log"), "a");
52
+ const [node, ...self] = selfArgv();
53
+ const args = [
54
+ ...self,
55
+ "deliver",
56
+ "--space",
57
+ o.space ?? resolveSpace(process.cwd()),
58
+ "--server",
59
+ o.server ?? DEFAULT_SERVER,
60
+ ];
61
+ const child = spawn(node, args, { detached: true, stdio: ["ignore", fd, fd] });
62
+ closeSync(fd);
63
+ child.unref();
64
+ writeFileSync(PID_PATH(), String(child.pid));
65
+ return child.pid ?? 0;
66
+ }
67
+ /** Make the server-side delivery daemon available (auth mode only). FAILS CLOSED: refuses to launch
68
+ * while an old Plane-3-hosting manager is live (the preflight should have stopped it) so the daemon
69
+ * never double-binds. Mints a SCOPED `delivery` cred from the local signer ONCE, writes it to
70
+ * `.cotal/delivery.creds` (0600), and launches the daemon WITHOUT signer access. Best-effort — callers
71
+ * treat it as non-fatal (a missing daemon degrades durable delivery, never live). */
72
+ export async function ensureDelivery(o = {}) {
73
+ if (!hasAuth())
74
+ return { running: false }; // open dev mode — no daemon, agents are live-only
75
+ if (oldHostingManagerLive()) {
76
+ console.error("✗ delivery: an old Plane-3-hosting manager is still live (no delivery-aware marker). Refusing to start the daemon — run `cotal down` first, then retry.");
77
+ return { running: false };
78
+ }
79
+ // Mint a scoped delivery cred (used to probe readiness; for a NEW launch it is ALSO the daemon's cred,
80
+ // written to disk). The daemon process reads the file and never holds the signer (a container mounts it
81
+ // read-only). A reuse (daemon already up) mints a throwaway probe cred — the running daemon keeps its
82
+ // own creds file.
83
+ const auth = loadSpaceAuth(authDir(findCotalRoot()));
84
+ const id = newIdentity();
85
+ const creds = await mintCreds(auth, id, "delivery");
86
+ const space = o.space ?? resolveSpace(process.cwd());
87
+ const server = o.server ?? DEFAULT_SERVER;
88
+ if (!deliveryUp()) {
89
+ writeFileSync(CREDS_PATH(), creds, { mode: 0o600 });
90
+ startDeliveryDetached({ ...o, space, server });
91
+ }
92
+ // ALWAYS wait for the daemon to be READY (lease flipped ready AFTER it bound ctl.delivery) before
93
+ // returning — for a fresh launch AND a reused live daemon — so agents the manager spawns next find the
94
+ // responder for their boot self-join. Non-fatal on timeout: the boot self-join reconciles with backoff,
95
+ // which is the real safety net for a slow start or a later outage.
96
+ const ready = await waitForDeliveryLease({ servers: server, space, creds, id: id.id });
97
+ if (!ready)
98
+ console.error("• delivery daemon not yet ready (responder not bound) — boot durable joins will reconcile when it is");
99
+ return { running: true };
100
+ }
101
+ /** Stop the detached delivery daemon if we started one, and drop its creds file. */
102
+ export function stopDelivery() {
103
+ rmSync(CREDS_PATH(), { force: true });
104
+ const p = PID_PATH();
105
+ if (!existsSync(p))
106
+ return;
107
+ const pid = Number(readFileSync(p, "utf8").trim());
108
+ if (Number.isFinite(pid)) {
109
+ try {
110
+ process.kill(pid, "SIGTERM");
111
+ }
112
+ catch {
113
+ /* already gone */
114
+ }
115
+ }
116
+ rmSync(p);
117
+ }
118
+ /** Bring up the control plane in the correct cutover order: OLD-manager preflight → delivery daemon
119
+ * (auth only, fails closed on a live old manager) → manager (lifecycle, writes the delivery-aware
120
+ * marker). The manager no longer depends on the daemon (it hosts no Plane-3), so the daemon is started
121
+ * first only to close the old-manager double-bind window and so freshly-spawned agents find the
122
+ * `ctl.delivery` responder for their boot self-join (a miss honest-degrades to live-only). */
123
+ export async function ensureControlPlane(o = {}) {
124
+ stopOldHostingManagerIfPresent();
125
+ await ensureDelivery(o);
126
+ return ensureManager(o);
127
+ }
128
+ //# sourceMappingURL=delivery-proc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-proc.js","sourceRoot":"","sources":["../../src/lib/delivery-proc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EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,YAAY;IAC1B,MAAM,CAAC,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACtC,MAAM,CAAC,GAAG,QAAQ,EAAE,CAAC;IACrB,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO;IAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACnD,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,IAAI,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,kBAAkB;QACpB,CAAC;IACH,CAAC;IACD,MAAM,CAAC,CAAC,CAAC,CAAC;AACZ,CAAC;AAED;;;;+FAI+F;AAC/F,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAU,EAAE;IACnD,8BAA8B,EAAE,CAAC;IACjC,MAAM,cAAc,CAAC,CAAC,CAAC,CAAC;IACxB,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC"}
@@ -1,11 +1,20 @@
1
1
  /** True if the manager we started for this folder is still running (pid file + liveness). */
2
2
  export declare function managerUp(): boolean;
3
+ /** True if the live manager carries a delivery-aware marker BOUND to its current pid (i.e. it's THIS
4
+ * build, non-hosting). Fail-closed: the marker stores the pid it was written for, and this requires it
5
+ * to equal the live `manager.pid` — a stale marker left by a crash, a mismatch, or an unparseable file
6
+ * all read as NOT delivery-aware, so a live old hosting `manager.pid` can't be mistaken for non-hosting
7
+ * and the delivery preflight stops it. */
8
+ export declare function managerHasDeliveryMarker(): boolean;
3
9
  /** True if any process's full command line matches `pattern` (`pgrep -f`). Detects processes that
4
10
  * have no pid file — the cmux-tab manager and the driving session — which live in cmux tabs. */
5
11
  export declare function pgrepMatches(pattern: string): boolean;
6
12
  /** True if a cmux-runtime manager is live for this space. Its cmux tab persists after the process
7
- * exits, so a workspace listing isn't proof — the process is. Matches prod `cotal.js` and dev
8
- * `cotal.ts` (both carry `cmux --space <space>`). */
13
+ * exits, so a workspace listing isn't proof — the process is. A cmux manager runs `… supervise
14
+ * --runtime cmux --space <space> …`; match order-independently (the session launcher emits the
15
+ * two flags adjacent, but a hand-typed launch may reorder them) by narrowing to `--runtime cmux`
16
+ * processes, then confirming the exact `--space <space>` token in each one's argv. Works for prod
17
+ * `cotal.js` and dev `cotal.ts` alike. */
9
18
  export declare function cmuxManagerRunning(space: string): boolean;
10
19
  /** Start the control-plane manager detached (pid in `.cotal/manager.pid`, output to
11
20
  * `.cotal/manager.log`), stopped by `cotal down`. Re-execs this same CLI's `supervise` — the
@@ -1 +1 @@
1
- {"version":3,"file":"manager-proc.d.ts","sourceRoot":"","sources":["../../src/lib/manager-proc.ts"],"names":[],"mappings":"AAkBA,6FAA6F;AAC7F,wBAAgB,SAAS,IAAI,OAAO,CAKnC;AAED;iGACiG;AACjG,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;sDAEsD;AACtD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;;0FAI0F;AAC1F,wBAAgB,oBAAoB,CAAC,CAAC,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GAAG,MAAM,CAiB1G;AAED;iEACiE;AACjE,wBAAgB,aAAa,CAAC,CAAC,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GAAG;IAAE,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