@cotal-ai/cli 0.2.0 → 0.3.0-next-20260614011207

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 (87) hide show
  1. package/dist/commands/channels.d.ts.map +1 -1
  2. package/dist/commands/channels.js +4 -2
  3. package/dist/commands/channels.js.map +1 -1
  4. package/dist/commands/console.d.ts.map +1 -1
  5. package/dist/commands/console.js +11 -8
  6. package/dist/commands/console.js.map +1 -1
  7. package/dist/commands/demo.js +3 -2
  8. package/dist/commands/demo.js.map +1 -1
  9. package/dist/commands/down.d.ts +4 -0
  10. package/dist/commands/down.d.ts.map +1 -0
  11. package/dist/commands/down.js +36 -0
  12. package/dist/commands/down.js.map +1 -0
  13. package/dist/commands/history.d.ts.map +1 -1
  14. package/dist/commands/history.js +5 -3
  15. package/dist/commands/history.js.map +1 -1
  16. package/dist/commands/join.js +3 -2
  17. package/dist/commands/join.js.map +1 -1
  18. package/dist/commands/mint.d.ts.map +1 -1
  19. package/dist/commands/mint.js +3 -2
  20. package/dist/commands/mint.js.map +1 -1
  21. package/dist/commands/setup.d.ts +8 -6
  22. package/dist/commands/setup.d.ts.map +1 -1
  23. package/dist/commands/setup.js +496 -56
  24. package/dist/commands/setup.js.map +1 -1
  25. package/dist/commands/spawn.d.ts.map +1 -1
  26. package/dist/commands/spawn.js +9 -5
  27. package/dist/commands/spawn.js.map +1 -1
  28. package/dist/commands/up.d.ts +21 -0
  29. package/dist/commands/up.d.ts.map +1 -1
  30. package/dist/commands/up.js +106 -38
  31. package/dist/commands/up.js.map +1 -1
  32. package/dist/commands/web.d.ts +27 -0
  33. package/dist/commands/web.d.ts.map +1 -1
  34. package/dist/commands/web.js +64 -7
  35. package/dist/commands/web.js.map +1 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +23 -8
  38. package/dist/index.js.map +1 -1
  39. package/dist/lib/assist.d.ts +16 -0
  40. package/dist/lib/assist.d.ts.map +1 -0
  41. package/dist/lib/assist.js +52 -0
  42. package/dist/lib/assist.js.map +1 -0
  43. package/dist/lib/cancel.d.ts +5 -0
  44. package/dist/lib/cancel.d.ts.map +1 -0
  45. package/dist/lib/cancel.js +12 -0
  46. package/dist/lib/cancel.js.map +1 -0
  47. package/dist/lib/live-window.d.ts +22 -0
  48. package/dist/lib/live-window.d.ts.map +1 -0
  49. package/dist/lib/live-window.js +71 -0
  50. package/dist/lib/live-window.js.map +1 -0
  51. package/dist/lib/manager-proc.d.ts +32 -0
  52. package/dist/lib/manager-proc.d.ts.map +1 -0
  53. package/dist/lib/manager-proc.js +84 -0
  54. package/dist/lib/manager-proc.js.map +1 -0
  55. package/dist/lib/nats-bin.d.ts +7 -0
  56. package/dist/lib/nats-bin.d.ts.map +1 -0
  57. package/dist/lib/nats-bin.js +21 -0
  58. package/dist/lib/nats-bin.js.map +1 -0
  59. package/dist/lib/onboard.d.ts +3 -0
  60. package/dist/lib/onboard.d.ts.map +1 -0
  61. package/dist/lib/onboard.js +15 -0
  62. package/dist/lib/onboard.js.map +1 -0
  63. package/dist/lib/paths.d.ts +7 -0
  64. package/dist/lib/paths.d.ts.map +1 -0
  65. package/dist/lib/paths.js +13 -0
  66. package/dist/lib/paths.js.map +1 -0
  67. package/dist/lib/self-exec.d.ts +10 -0
  68. package/dist/lib/self-exec.d.ts.map +1 -0
  69. package/dist/lib/self-exec.js +16 -0
  70. package/dist/lib/self-exec.js.map +1 -0
  71. package/dist/lib/setup-log.d.ts +8 -0
  72. package/dist/lib/setup-log.d.ts.map +1 -0
  73. package/dist/lib/setup-log.js +17 -0
  74. package/dist/lib/setup-log.js.map +1 -0
  75. package/dist/lib/status.d.ts +28 -0
  76. package/dist/lib/status.d.ts.map +1 -0
  77. package/dist/lib/status.js +58 -0
  78. package/dist/lib/status.js.map +1 -0
  79. package/dist/lib/steps.d.ts +31 -0
  80. package/dist/lib/steps.d.ts.map +1 -0
  81. package/dist/lib/steps.js +91 -0
  82. package/dist/lib/steps.js.map +1 -0
  83. package/dist/lib/theme.d.ts +18 -0
  84. package/dist/lib/theme.d.ts.map +1 -0
  85. package/dist/lib/theme.js +61 -0
  86. package/dist/lib/theme.js.map +1 -0
  87. package/package.json +12 -2
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,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,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD;;;kCAGkC;AAClC,MAAM,YAAY,GAAc;IAC9B;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,oGAAoG;QAC7G,GAAG,EAAE,EAAE;KACR;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,kEAAkE;QAC3E,GAAG,EAAE,IAAI;KACV;IACD;QACE,IAAI,EAAE,SAAS;QACf,I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ACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,MAAM;QACb,OAAO,EACL,qJAAqJ;QACvJ,GAAG,EAAE,QAAQ;KACd;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,8EAA8E;QACvF,GAAG,EAAE,OAAO;KACb;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,MAAM;QACb,OAAO,EACL,sJAAsJ;QACxJ,GAAG,EAAE,QAAQ;KACd;CACF,CAAC;AAEF,QAAQ,CAAC,QAAQ,CAAC,GAAG,YAAY,CAAC,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface AssistContext {
2
+ /** Failed step slug (as shown to the user and written to the log). */
3
+ step: string;
4
+ error: Error;
5
+ /** Local paths and doc URLs Claude should read for context: referenced in the
6
+ * prompt, never inlined, so it works without a repo clone. */
7
+ context: string[];
8
+ logPath: string;
9
+ }
10
+ /** Interactive Claude is offered only when it can actually run: a TTY, the
11
+ * `claude` binary on PATH, and not opted out via COTAL_SKIP_ASSIST=1 (CI). */
12
+ export declare function assistAvailable(): boolean;
13
+ /** Hand the terminal to an interactive Claude session primed with the failure
14
+ * context. Resolves when the user exits Claude (/exit) and setup resumes. */
15
+ export declare function runHandoff(ctx: AssistContext): Promise<void>;
16
+ //# sourceMappingURL=assist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assist.d.ts","sourceRoot":"","sources":["../../src/lib/assist.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb;mEAC+D;IAC/D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;+EAC+E;AAC/E,wBAAgB,eAAe,IAAI,OAAO,CAKzC;AAQD;8EAC8E;AAC9E,wBAAsB,UAAU,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBlE"}
@@ -0,0 +1,52 @@
1
+ import { spawn, spawnSync } from "node:child_process";
2
+ import { randomUUID } from "node:crypto";
3
+ import * as p from "@clack/prompts";
4
+ import { dim } from "./theme.js";
5
+ /** Interactive Claude is offered only when it can actually run: a TTY, the
6
+ * `claude` binary on PATH, and not opted out via COTAL_SKIP_ASSIST=1 (CI). */
7
+ export function assistAvailable() {
8
+ if (process.env.COTAL_SKIP_ASSIST === "1")
9
+ return false;
10
+ if (!process.stdin.isTTY || !process.stdout.isTTY)
11
+ return false;
12
+ const probe = spawnSync("claude", ["--version"], { stdio: "ignore" });
13
+ return !probe.error && probe.status === 0;
14
+ }
15
+ // All handoffs in one setup run share a single Claude session: the first spawn pins
16
+ // a generated UUID (--session-id), later spawns --resume it, so Claude keeps the
17
+ // context of earlier failures. stdio is inherited, so pinning our own id is the only
18
+ // way to find the session again.
19
+ let sessionId;
20
+ /** Hand the terminal to an interactive Claude session primed with the failure
21
+ * context. Resolves when the user exits Claude (/exit) and setup resumes. */
22
+ export async function runHandoff(ctx) {
23
+ const sessionArgs = sessionId ? ["--resume", sessionId] : ["--session-id", (sessionId = randomUUID())];
24
+ p.note(`Failed step: ${ctx.step}\n${ctx.error.message}\n\nType ${dim("/exit")} when you're done; setup resumes here.`, "Handing off to Claude");
25
+ const child = spawn("claude", [buildPrompt(ctx), "--permission-mode", "auto", ...sessionArgs], {
26
+ stdio: "inherit",
27
+ });
28
+ await new Promise((resolve) => {
29
+ child.on("exit", () => resolve());
30
+ child.on("error", () => {
31
+ p.log.error("Couldn't launch Claude; continuing without it.");
32
+ resolve();
33
+ });
34
+ });
35
+ p.log.info("Back from Claude.");
36
+ }
37
+ function buildPrompt(ctx) {
38
+ return [
39
+ "I'm running `cotal setup` (Cotal: a mesh where AI agents coordinate as lateral",
40
+ "peers over NATS/JetStream) and a setup step failed. Help me diagnose and fix it.",
41
+ "",
42
+ `Failed step: ${ctx.step}`,
43
+ `Error: ${ctx.error.message}`,
44
+ "",
45
+ "Read these for context as needed (don't assume their contents):",
46
+ ...[ctx.logPath, ...ctx.context].map((f) => ` - ${f}`),
47
+ "",
48
+ "Be concise. When the issue is fixed, remind me to type /exit, and I'll land back",
49
+ "in the setup flow, which will offer to retry the failed step.",
50
+ ].join("\n");
51
+ }
52
+ //# sourceMappingURL=assist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assist.js","sourceRoot":"","sources":["../../src/lib/assist.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAYjC;+EAC+E;AAC/E,MAAM,UAAU,eAAe;IAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,GAAG;QAAE,OAAO,KAAK,CAAC;IACxD,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAChE,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IACtE,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;AAC5C,CAAC;AAED,oFAAoF;AACpF,iFAAiF;AACjF,qFAAqF;AACrF,iCAAiC;AACjC,IAAI,SAA6B,CAAC;AAElC;8EAC8E;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C,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;QACvD,EAAE;QACF,kFAAkF;QAClF,+DAA+D;KAChE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** Treat a clack cancel (Ctrl-C / Esc) as quitting setup, cleanly. clack traps SIGINT
2
+ * inside a prompt and returns its cancel symbol instead of exiting; route those here so
3
+ * Ctrl-C aborts setup rather than falling through to a default. */
4
+ export declare function abortIfCancel<T>(value: T): Exclude<T, symbol>;
5
+ //# sourceMappingURL=cancel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel.d.ts","sourceRoot":"","sources":["../../src/lib/cancel.ts"],"names":[],"mappings":"AAEA;;oEAEoE;AACpE,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAM7D"}
@@ -0,0 +1,12 @@
1
+ import * as p from "@clack/prompts";
2
+ /** Treat a clack cancel (Ctrl-C / Esc) as quitting setup, cleanly. clack traps SIGINT
3
+ * inside a prompt and returns its cancel symbol instead of exiting; route those here so
4
+ * Ctrl-C aborts setup rather than falling through to a default. */
5
+ export function abortIfCancel(value) {
6
+ if (p.isCancel(value)) {
7
+ p.cancel("Setup cancelled.");
8
+ process.exit(130);
9
+ }
10
+ return value;
11
+ }
12
+ //# sourceMappingURL=cancel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../src/lib/cancel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC;;oEAEoE;AACpE,MAAM,UAAU,aAAa,CAAI,KAAQ;IACvC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAC7B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,KAA2B,CAAC;AACrC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * A fixed-height rolling tail under a spinner header, so a slow step shows live
3
+ * progress instead of a frozen spinner. Modeled on nanoclaw's windowed-runner.
4
+ *
5
+ * Purely transient: `start` opens the pane, `push` feeds it lines, `clear` wipes it
6
+ * and restores the cursor. The caller (the step runner) emits the permanent ✓/✗ line,
7
+ * so the pane never competes with clack's log output. On a non-TTY (CI/piped) every
8
+ * method is a no-op and lines are dropped; the runner's plain status line is enough.
9
+ */
10
+ export declare class LivePane {
11
+ private readonly tty;
12
+ private readonly lines;
13
+ private label;
14
+ private start0;
15
+ private frame;
16
+ private ticker?;
17
+ start(label: string): void;
18
+ push(chunk: string): void;
19
+ clear(): void;
20
+ private redraw;
21
+ }
22
+ //# sourceMappingURL=live-window.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-window.d.ts","sourceRoot":"","sources":["../../src/lib/live-window.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAiC;IACrD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,MAAM,CAAC,CAAiC;IAEhD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAe1B,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAUzB,KAAK,IAAI,IAAI;IASb,OAAO,CAAC,MAAM;CAUf"}
@@ -0,0 +1,71 @@
1
+ import { brand, dim, fit, fmtDuration } from "./theme.js";
2
+ const WINDOW = 3; // lines of rolling tail under the spinner header
3
+ const FRAMES = ["◒", "◐", "◓", "◑"];
4
+ const HIDE = "\x1b[?25l";
5
+ const SHOW = "\x1b[?25h";
6
+ /**
7
+ * A fixed-height rolling tail under a spinner header, so a slow step shows live
8
+ * progress instead of a frozen spinner. Modeled on nanoclaw's windowed-runner.
9
+ *
10
+ * Purely transient: `start` opens the pane, `push` feeds it lines, `clear` wipes it
11
+ * and restores the cursor. The caller (the step runner) emits the permanent ✓/✗ line,
12
+ * so the pane never competes with clack's log output. On a non-TTY (CI/piped) every
13
+ * method is a no-op and lines are dropped; the runner's plain status line is enough.
14
+ */
15
+ export class LivePane {
16
+ tty = Boolean(process.stdout.isTTY);
17
+ lines = [];
18
+ label = "";
19
+ start0 = 0;
20
+ frame = 0;
21
+ ticker;
22
+ start(label) {
23
+ if (!this.tty)
24
+ return;
25
+ this.label = label;
26
+ this.start0 = Date.now();
27
+ const out = process.stdout;
28
+ out.write(HIDE);
29
+ for (let i = 0; i < WINDOW + 1; i++)
30
+ out.write("\n");
31
+ this.redraw();
32
+ process.once("exit", () => out.write(SHOW));
33
+ this.ticker = setInterval(() => {
34
+ this.frame++;
35
+ this.redraw();
36
+ }, 200);
37
+ }
38
+ push(chunk) {
39
+ if (!this.tty)
40
+ return;
41
+ for (const raw of chunk.split("\n")) {
42
+ // eslint-disable-next-line no-control-regex
43
+ const clean = raw.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "").trim();
44
+ if (clean)
45
+ this.lines.push(clean);
46
+ }
47
+ this.redraw();
48
+ }
49
+ clear() {
50
+ if (!this.tty)
51
+ return;
52
+ if (this.ticker)
53
+ clearInterval(this.ticker);
54
+ const out = process.stdout;
55
+ out.write(`\x1b[${WINDOW + 1}A`);
56
+ for (let i = 0; i < WINDOW + 1; i++)
57
+ out.write("\x1b[2K\n");
58
+ out.write(`\x1b[${WINDOW + 1}A${SHOW}`);
59
+ }
60
+ redraw() {
61
+ const out = process.stdout;
62
+ out.write(`\x1b[${WINDOW + 1}A`);
63
+ const suffix = ` (${fmtDuration(Date.now() - this.start0)})`;
64
+ out.write(`\x1b[2K${brand(FRAMES[this.frame % FRAMES.length])} ${this.label}${dim(suffix)}\n`);
65
+ for (let i = 0; i < WINDOW; i++) {
66
+ const line = this.lines[this.lines.length - WINDOW + i] ?? "";
67
+ out.write(`\x1b[2K${line ? `${dim("│")} ${dim(fit(line))}` : dim("│")}\n`);
68
+ }
69
+ }
70
+ }
71
+ //# sourceMappingURL=live-window.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-window.js","sourceRoot":"","sources":["../../src/lib/live-window.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,iDAAiD;AACnE,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACpC,MAAM,IAAI,GAAG,WAAW,CAAC;AACzB,MAAM,IAAI,GAAG,WAAW,CAAC;AAEzB;;;;;;;;GAQG;AACH,MAAM,OAAO,QAAQ;IACF,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,KAAK,GAAa,EAAE,CAAC;IAC9B,KAAK,GAAG,EAAE,CAAC;IACX,MAAM,GAAG,CAAC,CAAC;IACX,KAAK,GAAG,CAAC,CAAC;IACV,MAAM,CAAkC;IAEhD,KAAK,CAAC,KAAa;QACjB,IAAI,CAAC,IAAI,CAAC,GAAG;YAAE,OAAO;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;QAC3B,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE;YAAE,GAAG,CAAC,KAAK,C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C,CAAC;IAEO,MAAM;QACZ,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;QAC3B,GAAG,CAAC,KAAK,CAAC,QAAQ,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,MAAM,GAAG,KAAK,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;QAC7D,GAAG,CAAC,KAAK,CAAC,UAAU,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAChG,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;YAC9D,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,32 @@
1
+ /** True if the manager we started for this folder is still running (pid file + liveness). */
2
+ export declare function managerUp(): boolean;
3
+ /** True if any process's full command line matches `pattern` (`pgrep -f`). Detects processes that
4
+ * have no pid file — the cmux-tab manager and the driving session — which live in cmux tabs. */
5
+ export declare function pgrepMatches(pattern: string): boolean;
6
+ /** 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>`). */
9
+ export declare function cmuxManagerRunning(space: string): boolean;
10
+ /** Start the control-plane manager detached (pid in `.cotal/manager.pid`, output to
11
+ * `.cotal/manager.log`), stopped by `cotal down`. Re-execs this same CLI's `supervise` — the
12
+ * composed `cotal` binary registers it; `process.execArgv` carries the tsx loader in dev and is
13
+ * empty in prod. `supervise`'s auto runtime resolves to pty when detached, which answers the
14
+ * control plane (`cotal_spawn`/`despawn`/`purge`/`persona`) with no tmux/cmux needed. */
15
+ export declare function startManagerDetached(o?: {
16
+ space?: string;
17
+ server?: string;
18
+ spawn?: string[];
19
+ }): number;
20
+ /** Make the control plane available: reuse a manager already running for this folder, else start
21
+ * one detached. Best-effort — callers treat it as non-fatal. */
22
+ export declare function ensureManager(o?: {
23
+ space?: string;
24
+ server?: string;
25
+ spawn?: string[];
26
+ }): {
27
+ running: boolean;
28
+ };
29
+ /** Stop the detached (pty) manager if we started one. Used when switching to the cmux-tab manager
30
+ * so the two don't both answer the control plane (queue-grouped requests would split between them). */
31
+ export declare function stopManager(): void;
32
+ //# sourceMappingURL=manager-proc.d.ts.map
@@ -0,0 +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,OAAO,EAAE,OAAO,CAAA;CAAE,CAIjH;AAED;wGACwG;AACxG,wBAAgB,WAAW,IAAI,IAAI,CAYlC"}
@@ -0,0 +1,84 @@
1
+ import { spawn, spawnSync } from "node:child_process";
2
+ import { existsSync, openSync, closeSync, writeFileSync, readFileSync, rmSync } from "node:fs";
3
+ import { DEFAULT_SERVER } from "@cotal-ai/core";
4
+ import { selfArgv } from "./self-exec.js";
5
+ import { resolveSpace } from "./status.js";
6
+ import { cotalPath } from "./paths.js";
7
+ const PID_PATH = () => cotalPath("manager.pid");
8
+ function alive(pid) {
9
+ try {
10
+ process.kill(pid, 0); // signal 0: liveness probe, doesn't actually signal
11
+ return true;
12
+ }
13
+ catch {
14
+ return false;
15
+ }
16
+ }
17
+ /** True if the manager we started for this folder is still running (pid file + liveness). */
18
+ export function managerUp() {
19
+ const p = PID_PATH();
20
+ if (!existsSync(p))
21
+ return false;
22
+ const pid = Number(readFileSync(p, "utf8").trim());
23
+ return Number.isFinite(pid) && alive(pid);
24
+ }
25
+ /** True if any process's full command line matches `pattern` (`pgrep -f`). Detects processes that
26
+ * have no pid file — the cmux-tab manager and the driving session — which live in cmux tabs. */
27
+ export function pgrepMatches(pattern) {
28
+ return spawnSync("pgrep", ["-f", pattern], { stdio: "ignore" }).status === 0;
29
+ }
30
+ /** True if a cmux-runtime manager is live for this space. Its cmux tab persists after the process
31
+ * exits, so a workspace listing isn't proof — the process is. Matches prod `cotal.js` and dev
32
+ * `cotal.ts` (both carry `cmux --space <space>`). */
33
+ export function cmuxManagerRunning(space) {
34
+ return pgrepMatches(`cmux --space ${space}`);
35
+ }
36
+ /** Start the control-plane manager detached (pid in `.cotal/manager.pid`, output to
37
+ * `.cotal/manager.log`), stopped by `cotal down`. Re-execs this same CLI's `supervise` — the
38
+ * composed `cotal` binary registers it; `process.execArgv` carries the tsx loader in dev and is
39
+ * empty in prod. `supervise`'s auto runtime resolves to pty when detached, which answers the
40
+ * control plane (`cotal_spawn`/`despawn`/`purge`/`persona`) with no tmux/cmux needed. */
41
+ export function startManagerDetached(o = {}) {
42
+ const fd = openSync(cotalPath("manager.log"), "a");
43
+ const [node, ...self] = selfArgv();
44
+ const args = [
45
+ ...self,
46
+ "supervise",
47
+ "--space",
48
+ o.space ?? resolveSpace(process.cwd()),
49
+ "--server",
50
+ o.server ?? DEFAULT_SERVER,
51
+ ...(o.spawn?.length ? ["--spawn", o.spawn.join(",")] : []),
52
+ ];
53
+ const child = spawn(node, args, { detached: true, stdio: ["ignore", fd, fd] });
54
+ closeSync(fd);
55
+ child.unref();
56
+ writeFileSync(PID_PATH(), String(child.pid));
57
+ return child.pid ?? 0;
58
+ }
59
+ /** Make the control plane available: reuse a manager already running for this folder, else start
60
+ * one detached. Best-effort — callers treat it as non-fatal. */
61
+ export function ensureManager(o = {}) {
62
+ if (managerUp())
63
+ return { running: true };
64
+ startManagerDetached(o);
65
+ return { running: true };
66
+ }
67
+ /** Stop the detached (pty) manager if we started one. Used when switching to the cmux-tab manager
68
+ * so the two don't both answer the control plane (queue-grouped requests would split between them). */
69
+ export function stopManager() {
70
+ const p = PID_PATH();
71
+ if (!existsSync(p))
72
+ return;
73
+ const pid = Number(readFileSync(p, "utf8").trim());
74
+ if (Number.isFinite(pid)) {
75
+ try {
76
+ process.kill(pid, "SIGTERM");
77
+ }
78
+ catch {
79
+ /* already gone */
80
+ }
81
+ }
82
+ rmSync(p);
83
+ }
84
+ //# sourceMappingURL=manager-proc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager-proc.js","sourceRoot":"","sources":["../../src/lib/manager-proc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,a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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"}
@@ -0,0 +1,7 @@
1
+ /** Resolve the nats-server binary: PATH first (an operator-installed server always
2
+ * wins), then the bundled platform package. Throws when neither is available. */
3
+ export declare function resolveNatsServer(): Promise<{
4
+ bin: string;
5
+ source: "path" | "bundled";
6
+ }>;
7
+ //# sourceMappingURL=nats-bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nats-bin.d.ts","sourceRoot":"","sources":["../../src/lib/nats-bin.ts"],"names":[],"mappings":"AAMA;kFACkF;AAClF,wBAAsB,iBAAiB,IAAI,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC,CAc9F"}
@@ -0,0 +1,21 @@
1
+ import { spawnSync } from "node:child_process";
2
+ /** Platform-package prefix the bundled binary ships under. Swapping providers
3
+ * (e.g. to our own @cotal-ai/nats-server-*) is a one-line change here. */
4
+ const BUNDLED_PKG_PREFIX = "@eplightning/nats-server";
5
+ /** Resolve the nats-server binary: PATH first (an operator-installed server always
6
+ * wins), then the bundled platform package. Throws when neither is available. */
7
+ export async function resolveNatsServer() {
8
+ const onPath = spawnSync("nats-server", ["--version"], { stdio: "ignore" });
9
+ if (!onPath.error && onPath.status === 0)
10
+ return { bin: "nats-server", source: "path" };
11
+ const pkg = `${BUNDLED_PKG_PREFIX}-${process.platform}-${process.arch}`;
12
+ try {
13
+ const mod = (await import(pkg));
14
+ return { bin: mod.getBinaryPath(), source: "bundled" };
15
+ }
16
+ catch {
17
+ throw new Error(`nats-server not found on PATH and no bundled binary for ${process.platform}/${process.arch} (${pkg}). ` +
18
+ "Install nats-server (https://github.com/nats-io/nats-server/releases) and put it on PATH.");
19
+ }
20
+ }
21
+ //# sourceMappingURL=nats-bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nats-bin.js","sourceRoot":"","sources":["../../src/lib/nats-bin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;2EAC2E;AAC3E,MAAM,kBAAkB,GAAG,0BAA0B,CAAC;AAEtD;kFACkF;AAClF,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,MAAM,MAAM,GAAG,SAAS,CAAC,aAAa,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC5E,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAExF,MAAM,GAAG,GAAG,GAAG,kBAAkB,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IACxE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,CAAgC,CAAC;QAC/D,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,2DAA2D,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,KAAK,GAAG,KAAK;YACtG,2FAA2F,CAC9F,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function isOnboarded(): boolean;
2
+ export declare function markOnboarded(version: string): void;
3
+ //# sourceMappingURL=onboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onboard.d.ts","sourceRoot":"","sources":["../../src/lib/onboard.ts"],"names":[],"mappings":"AASA,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAGnD"}
@@ -0,0 +1,15 @@
1
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+ /** Machine-level "I've onboarded before" marker. Its presence flips `cotal` from the
5
+ * full first-run flow to the compact ensure+status run. Lives next to the materialized
6
+ * plugin marketplace under ~/.cotal. */
7
+ const MARKER = join(homedir(), ".cotal", "onboarded.json");
8
+ export function isOnboarded() {
9
+ return existsSync(MARKER);
10
+ }
11
+ export function markOnboarded(version) {
12
+ mkdirSync(join(homedir(), ".cotal"), { recursive: true });
13
+ writeFileSync(MARKER, JSON.stringify({ version, ts: new Date().toISOString() }, null, 2));
14
+ }
15
+ //# sourceMappingURL=onboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onboard.js","sourceRoot":"","sources":["../../src/lib/onboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;yCAEyC;AACzC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;AAE3D,MAAM,UAAU,WAAW;IACzB,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC5F,CAAC"}
@@ -0,0 +1,7 @@
1
+ /** The project's `.cotal/` root, found by walking up from cwd (like git finds `.git`), so every
2
+ * command resolves the same `.cotal/` whether you're at the project root or a subdirectory. */
3
+ export declare function cotalRoot(): string;
4
+ /** A path inside the project's `.cotal/` directory. Use instead of `resolve(".cotal/…")` so paths
5
+ * don't break when `cotal` runs from a subdirectory. */
6
+ export declare function cotalPath(...segments: string[]): string;
7
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/lib/paths.ts"],"names":[],"mappings":"AAGA;gGACgG;AAChG,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;yDACyD;AACzD,wBAAgB,SAAS,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAEvD"}
@@ -0,0 +1,13 @@
1
+ import { join } from "node:path";
2
+ import { findCotalRoot } from "@cotal-ai/core";
3
+ /** The project's `.cotal/` root, found by walking up from cwd (like git finds `.git`), so every
4
+ * command resolves the same `.cotal/` whether you're at the project root or a subdirectory. */
5
+ export function cotalRoot() {
6
+ return findCotalRoot();
7
+ }
8
+ /** A path inside the project's `.cotal/` directory. Use instead of `resolve(".cotal/…")` so paths
9
+ * don't break when `cotal` runs from a subdirectory. */
10
+ export function cotalPath(...segments) {
11
+ return join(cotalRoot(), ".cotal", ...segments);
12
+ }
13
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/lib/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;gGACgG;AAChG,MAAM,UAAU,SAAS;IACvB,OAAO,aAAa,EAAE,CAAC;AACzB,CAAC;AAED;yDACyD;AACzD,MAAM,UAAU,SAAS,CAAC,GAAG,QAAkB;IAC7C,OAAO,IAAI,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC;AAClD,CAAC"}
@@ -0,0 +1,10 @@
1
+ /** This CLI's own invocation as argv: `[node, ...loaderFlags, entryScript]`. The loader flags carry
2
+ * tsx in dev (so a re-exec can run the `.ts` entry) and are empty in prod (entry = compiled JS).
3
+ * Re-execed children (web, manager) and cmux pane commands use this so they never depend on
4
+ * `cotal` being on PATH — works the same via `npx`, `npm i -g`, and a dev clone. */
5
+ export declare function selfArgv(): string[];
6
+ /** The self-invocation as a shell-ready, double-quoted command prefix (for cmux pane commands).
7
+ * Tokens are absolute paths with no single quotes, so the surrounding `bash -lc '…'` single-quote
8
+ * wrapping stays intact through a login shell (e.g. nushell) before bash. */
9
+ export declare function selfCotal(): string;
10
+ //# sourceMappingURL=self-exec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self-exec.d.ts","sourceRoot":"","sources":["../../src/lib/self-exec.ts"],"names":[],"mappings":"AAAA;;;qFAGqF;AACrF,wBAAgB,QAAQ,IAAI,MAAM,EAAE,CAEnC;AAED;;8EAE8E;AAC9E,wBAAgB,SAAS,IAAI,MAAM,CAIlC"}
@@ -0,0 +1,16 @@
1
+ /** This CLI's own invocation as argv: `[node, ...loaderFlags, entryScript]`. The loader flags carry
2
+ * tsx in dev (so a re-exec can run the `.ts` entry) and are empty in prod (entry = compiled JS).
3
+ * Re-execed children (web, manager) and cmux pane commands use this so they never depend on
4
+ * `cotal` being on PATH — works the same via `npx`, `npm i -g`, and a dev clone. */
5
+ export function selfArgv() {
6
+ return [process.execPath, ...process.execArgv, process.argv[1]];
7
+ }
8
+ /** The self-invocation as a shell-ready, double-quoted command prefix (for cmux pane commands).
9
+ * Tokens are absolute paths with no single quotes, so the surrounding `bash -lc '…'` single-quote
10
+ * wrapping stays intact through a login shell (e.g. nushell) before bash. */
11
+ export function selfCotal() {
12
+ return selfArgv()
13
+ .map((a) => `"${a}"`)
14
+ .join(" ");
15
+ }
16
+ //# sourceMappingURL=self-exec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self-exec.js","sourceRoot":"","sources":["../../src/lib/self-exec.ts"],"names":[],"mappings":"AAAA;;;qFAGqF;AACrF,MAAM,UAAU,QAAQ;IACtB,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAED;;8EAE8E;AAC9E,MAAM,UAAU,SAAS;IACvB,OAAO,QAAQ,EAAE;SACd,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;SACpB,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,8 @@
1
+ export interface SetupLog {
2
+ path: string;
3
+ line(s: string): void;
4
+ }
5
+ /** Timestamped append log for `cotal setup` — one file, also the first thing a
6
+ * Claude handoff is pointed at. Resolves the project's `.cotal/` (walks up from cwd). */
7
+ export declare function openSetupLog(_cwd: string): SetupLog;
8
+ //# sourceMappingURL=setup-log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-log.d.ts","sourceRoot":"","sources":["../../src/lib/setup-log.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;0FAC0F;AAC1F,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAUnD"}
@@ -0,0 +1,17 @@
1
+ import { appendFileSync, mkdirSync } from "node:fs";
2
+ import { dirname } from "node:path";
3
+ import { cotalPath } from "./paths.js";
4
+ /** Timestamped append log for `cotal setup` — one file, also the first thing a
5
+ * Claude handoff is pointed at. Resolves the project's `.cotal/` (walks up from cwd). */
6
+ export function openSetupLog(_cwd) {
7
+ const path = cotalPath("setup.log");
8
+ mkdirSync(dirname(path), { recursive: true });
9
+ appendFileSync(path, `\n=== cotal setup — ${new Date().toISOString()} ===\n`);
10
+ return {
11
+ path,
12
+ line(s) {
13
+ appendFileSync(path, `${new Date().toISOString()} ${s}\n`);
14
+ },
15
+ };
16
+ }
17
+ //# sourceMappingURL=setup-log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-log.js","sourceRoot":"","sources":["../../src/lib/setup-log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAOvC;0FAC0F;AAC1F,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,IAAI,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IACpC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,cAAc,CAAC,IAAI,EAAE,uBAAuB,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC9E,OAAO;QACL,IAAI;QACJ,IAAI,CAAC,CAAS;YACZ,cAAc,CAAC,IAAI,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7D,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,28 @@
1
+ export interface MeshStatus {
2
+ reachable: boolean;
3
+ server: string;
4
+ space: string;
5
+ auth: boolean;
6
+ }
7
+ /** The space this folder operates on: its `.cotal/auth` space if set up, else the default.
8
+ * A folder has exactly one space (its auth) — commands resolve it through here so they always
9
+ * match the folder's mesh instead of assuming the global default. */
10
+ export declare function resolveSpace(cwd: string): string;
11
+ /** Cheap, connectionless-ish snapshot of the mesh for this folder: is a server up,
12
+ * and what space/auth does the local `.cotal/` describe (found by walking up from `cwd`). */
13
+ export declare function meshStatus(cwd: string): Promise<MeshStatus>;
14
+ export interface MachineStatus {
15
+ nats: "path" | "bundled" | "missing";
16
+ claudePlugin: boolean;
17
+ agents: {
18
+ claude: boolean;
19
+ codex: boolean;
20
+ opencode: boolean;
21
+ };
22
+ }
23
+ /** Machine-level readiness: the once-per-machine setup pieces. */
24
+ export declare function machineStatus(): Promise<MachineStatus>;
25
+ export declare function onPath(bin: string): boolean;
26
+ /** True once the machine-level setup has completed at least once. */
27
+ export declare function hasLocalMesh(cwd: string): boolean;
28
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/lib/status.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;sEAEsE;AACtE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;8FAC8F;AAC9F,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CASjE;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;IACrC,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;CAChE;AAED,kEAAkE;AAClE,wBAAsB,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,CAgB5D;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAG3C;AAQD,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGjD"}