@cotal-ai/connector-claude-code 0.90.0 → 0.91.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cotal",
3
3
  "version": "0.0.0",
4
- "description": "Join the Cotal mesh: coordinate with other AI agents as lateral peers (presence, messaging, role requests) over NATS. Adds one MCP server, 7 hooks and a monitor. A session the cotal CLI did not launch joins only when it calls cotal_connect, and the monitor then starts a turn when a message arrives.",
4
+ "description": "Connect Claude Code to a Cotal mesh for presence, messaging and role requests. Includes MCP tools, lifecycle hooks and native incoming-message delivery in supported Code sessions. Each conversation joins only when it calls cotal_connect.",
5
5
  "author": { "name": "Cotal", "url": "https://cotal.ai" },
6
6
  "homepage": "https://cotal.ai",
7
7
  "repository": "https://github.com/Cotal-AI/Cotal",
package/dist/carried.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ResumeTranscriptLocator } from "@cotal-ai/core";
1
+ import { type ResumeTranscriptLocator } from "@cotal-ai/core";
2
2
  export declare const claudeResumeTranscript: ResumeTranscriptLocator;
3
3
  /**
4
4
  * Refuse a carried launch this host cannot run, before anything is written: a Claude that ignores
@@ -8,7 +8,9 @@ export declare function refuseCarriedLaunch(binary: string, seatEnv: Record<stri
8
8
  /** Where a carried seat writes its fork record: the manager's {@link LaunchSpec.resumeRecordPath}. */
9
9
  export declare function carriedForkRecord(home: string): string;
10
10
  /** Fill the seat's home: the carried transcript where `--resume` finds it, and the first-run state a
11
- * fresh home would otherwise prompt for, trusting the authorized launch directory. */
11
+ * fresh home would otherwise prompt for, trusting the authorized launch directory. Neither file is
12
+ * written through a symlink: the state takes the private open, and the transcript copy refuses a
13
+ * name that already exists. */
12
14
  export declare function placeCarried(home: string, transcript: string, resume: string | undefined, cwd: string): Record<string, string>;
13
15
  /**
14
16
  * Write a carried seat's fork record once Claude has forked: the digest of the transcript its
@@ -1 +1 @@
1
- {"version":3,"file":"carried.d.ts","sourceRoot":"","sources":["../src/carried.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAiD9D,eAAO,MAAM,sBAAsB,EAAE,uBAqBpC,CAAC;AAUF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAWzF;AAED,sGAAsG;AACtG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;uFACuF;AACvF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ9H;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAY3F"}
1
+ {"version":3,"file":"carried.d.ts","sourceRoot":"","sources":["../src/carried.ts"],"names":[],"mappings":"AAUA,OAAO,EAAsB,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAiDlF,eAAO,MAAM,sBAAsB,EAAE,uBAqBpC,CAAC;AAUF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAWzF;AAED,sGAAsG;AACtG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;gCAGgC;AAChC,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ9H;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAY3F"}
package/dist/index.js CHANGED
@@ -405,11 +405,11 @@ var require_codegen = __commonJS({
405
405
  const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
406
406
  return `${varKind} ${this.name}${rhs};` + _n;
407
407
  }
408
- optimizeNames(names, constants) {
408
+ optimizeNames(names, constants2) {
409
409
  if (!names[this.name.str])
410
410
  return;
411
411
  if (this.rhs)
412
- this.rhs = optimizeExpr(this.rhs, names, constants);
412
+ this.rhs = optimizeExpr(this.rhs, names, constants2);
413
413
  return this;
414
414
  }
415
415
  get names() {
@@ -426,10 +426,10 @@ var require_codegen = __commonJS({
426
426
  render({ _n }) {
427
427
  return `${this.lhs} = ${this.rhs};` + _n;
428
428
  }
429
- optimizeNames(names, constants) {
429
+ optimizeNames(names, constants2) {
430
430
  if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
431
431
  return;
432
- this.rhs = optimizeExpr(this.rhs, names, constants);
432
+ this.rhs = optimizeExpr(this.rhs, names, constants2);
433
433
  return this;
434
434
  }
435
435
  get names() {
@@ -490,8 +490,8 @@ var require_codegen = __commonJS({
490
490
  optimizeNodes() {
491
491
  return `${this.code}` ? this : void 0;
492
492
  }
493
- optimizeNames(names, constants) {
494
- this.code = optimizeExpr(this.code, names, constants);
493
+ optimizeNames(names, constants2) {
494
+ this.code = optimizeExpr(this.code, names, constants2);
495
495
  return this;
496
496
  }
497
497
  get names() {
@@ -520,12 +520,12 @@ var require_codegen = __commonJS({
520
520
  }
521
521
  return nodes.length > 0 ? this : void 0;
522
522
  }
523
- optimizeNames(names, constants) {
523
+ optimizeNames(names, constants2) {
524
524
  const { nodes } = this;
525
525
  let i = nodes.length;
526
526
  while (i--) {
527
527
  const n = nodes[i];
528
- if (n.optimizeNames(names, constants))
528
+ if (n.optimizeNames(names, constants2))
529
529
  continue;
530
530
  subtractNames(names, n.names);
531
531
  nodes.splice(i, 1);
@@ -578,12 +578,12 @@ var require_codegen = __commonJS({
578
578
  return void 0;
579
579
  return this;
580
580
  }
581
- optimizeNames(names, constants) {
581
+ optimizeNames(names, constants2) {
582
582
  var _a3;
583
- this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants);
584
- if (!(super.optimizeNames(names, constants) || this.else))
583
+ this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants2);
584
+ if (!(super.optimizeNames(names, constants2) || this.else))
585
585
  return;
586
- this.condition = optimizeExpr(this.condition, names, constants);
586
+ this.condition = optimizeExpr(this.condition, names, constants2);
587
587
  return this;
588
588
  }
589
589
  get names() {
@@ -606,10 +606,10 @@ var require_codegen = __commonJS({
606
606
  render(opts) {
607
607
  return `for(${this.iteration})` + super.render(opts);
608
608
  }
609
- optimizeNames(names, constants) {
610
- if (!super.optimizeNames(names, constants))
609
+ optimizeNames(names, constants2) {
610
+ if (!super.optimizeNames(names, constants2))
611
611
  return;
612
- this.iteration = optimizeExpr(this.iteration, names, constants);
612
+ this.iteration = optimizeExpr(this.iteration, names, constants2);
613
613
  return this;
614
614
  }
615
615
  get names() {
@@ -645,10 +645,10 @@ var require_codegen = __commonJS({
645
645
  render(opts) {
646
646
  return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
647
647
  }
648
- optimizeNames(names, constants) {
649
- if (!super.optimizeNames(names, constants))
648
+ optimizeNames(names, constants2) {
649
+ if (!super.optimizeNames(names, constants2))
650
650
  return;
651
- this.iterable = optimizeExpr(this.iterable, names, constants);
651
+ this.iterable = optimizeExpr(this.iterable, names, constants2);
652
652
  return this;
653
653
  }
654
654
  get names() {
@@ -690,11 +690,11 @@ var require_codegen = __commonJS({
690
690
  (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
691
691
  return this;
692
692
  }
693
- optimizeNames(names, constants) {
693
+ optimizeNames(names, constants2) {
694
694
  var _a3, _b;
695
- super.optimizeNames(names, constants);
696
- (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants);
697
- (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants);
695
+ super.optimizeNames(names, constants2);
696
+ (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants2);
697
+ (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants2);
698
698
  return this;
699
699
  }
700
700
  get names() {
@@ -995,7 +995,7 @@ var require_codegen = __commonJS({
995
995
  function addExprNames(names, from) {
996
996
  return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
997
997
  }
998
- function optimizeExpr(expr, names, constants) {
998
+ function optimizeExpr(expr, names, constants2) {
999
999
  if (expr instanceof code_1.Name)
1000
1000
  return replaceName(expr);
1001
1001
  if (!canOptimize(expr))
@@ -1010,14 +1010,14 @@ var require_codegen = __commonJS({
1010
1010
  return items;
1011
1011
  }, []));
1012
1012
  function replaceName(n) {
1013
- const c = constants[n.str];
1013
+ const c = constants2[n.str];
1014
1014
  if (c === void 0 || names[n.str] !== 1)
1015
1015
  return n;
1016
1016
  delete names[n.str];
1017
1017
  return c;
1018
1018
  }
1019
1019
  function canOptimize(e) {
1020
- return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants[c.str] !== void 0);
1020
+ return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants2[c.str] !== void 0);
1021
1021
  }
1022
1022
  }
1023
1023
  function subtractNames(names, from) {
@@ -6894,7 +6894,8 @@ import { fileURLToPath } from "node:url";
6894
6894
  import {
6895
6895
  globalConfigPath,
6896
6896
  mcpServerProblem as mcpServerProblem2,
6897
- registry as registry3
6897
+ registry as registry3,
6898
+ writePrivateRecord
6898
6899
  } from "@cotal-ai/core";
6899
6900
 
6900
6901
  // ../connector-core/dist/config.js
@@ -23611,12 +23612,33 @@ function pluginVersion(root, assets, files) {
23611
23612
  }
23612
23613
  function materializeCotal(cotal) {
23613
23614
  for (const asset of COTAL_ASSETS) if (!existsSync3(join4(PACKAGE_ROOT, asset))) throw new Error(`plugin asset missing: ${join4(PACKAGE_ROOT, asset)}`);
23614
- const files = { [`dist/${CLI_RECORD}`]: `${JSON.stringify({ argv: cotal })}
23615
- ` };
23615
+ const files = pluginFiles(cotal);
23616
23616
  const version2 = pluginVersion(PACKAGE_ROOT, COTAL_ASSETS, files);
23617
23617
  materialize("cotal", PACKAGE_ROOT, COTAL_ASSETS, version2, files);
23618
23618
  return version2;
23619
23619
  }
23620
+ function pluginFiles(cotal) {
23621
+ const node = cotal[0];
23622
+ if (!node) throw new Error("the Cotal CLI record has no Node executable");
23623
+ if (process.platform === "win32" && /[\"%!\r\n]/.test(node))
23624
+ throw new Error("the Node executable path contains characters Claude's Windows command hooks cannot safely run");
23625
+ const quoted = process.platform === "win32" ? `"${node}"` : `'${node.replace(/'/g, "'\\''")}'`;
23626
+ const mcp = JSON.parse(readFileSync3(join4(PACKAGE_ROOT, ".mcp.json"), "utf8"));
23627
+ mcp.mcpServers.cotal.command = node;
23628
+ const hooks = JSON.parse(readFileSync3(join4(PACKAGE_ROOT, "hooks", "hooks.json"), "utf8"));
23629
+ for (const groups of Object.values(hooks.hooks)) for (const group of groups) for (const hook of group.hooks) {
23630
+ if (hook.command === 'node "${CLAUDE_PLUGIN_ROOT}/dist/hook.cjs"')
23631
+ hook.command = quoted + ' "${CLAUDE_PLUGIN_ROOT}/dist/hook.cjs"';
23632
+ }
23633
+ return {
23634
+ [`dist/${CLI_RECORD}`]: `${JSON.stringify({ argv: cotal })}
23635
+ `,
23636
+ ".mcp.json": `${JSON.stringify(mcp, null, 2)}
23637
+ `,
23638
+ "hooks/hooks.json": `${JSON.stringify(hooks, null, 2)}
23639
+ `
23640
+ };
23641
+ }
23620
23642
  function desktopEntry(cotal) {
23621
23643
  return {
23622
23644
  command: cotal[0],
@@ -23633,6 +23655,40 @@ function desktop(cotal, add) {
23633
23655
  }
23634
23656
  var DOCS_URL = "https://github.com/Cotal-AI/Cotal/blob/main/docs/connect-claude.md";
23635
23657
  var MARKETPLACE = "cotal-mesh";
23658
+ function claudeCommand() {
23659
+ const terminal = spawnSync("claude", ["--version"], { stdio: "ignore", timeout: 5e3, killSignal: "SIGKILL" });
23660
+ if (terminal.status === 0) return "claude";
23661
+ if (terminal.error?.code !== "ENOENT")
23662
+ throw new Error("The installed Claude Code command could not run. Repair it before running cotal setup.");
23663
+ const config2 = desktopConfigPath();
23664
+ const app = config2 ? dirname2(config2) : process.platform === "linux" ? join4(process.env.XDG_CONFIG_HOME || join4(homedir3(), ".config"), "Claude") : void 0;
23665
+ if (!app || !existsSync3(join4(app, "claude-code"))) throw new Error("Claude Code is unavailable. Install it or open Desktop's Code tab, then retry setup.");
23666
+ const cache = join4(app, "claude-code");
23667
+ const versions = readdirSync(cache, { withFileTypes: true }).filter((entry) => entry.isDirectory() && /^\d+\.\d+\.\d+$/.test(entry.name)).sort((a, b) => b.name.localeCompare(a.name, void 0, { numeric: true }));
23668
+ const executable = process.platform === "win32" ? "claude.exe" : "claude";
23669
+ for (const version2 of versions) {
23670
+ const root = join4(cache, version2.name);
23671
+ for (const entry of readdirSync(root, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
23672
+ if (!entry.isDirectory()) continue;
23673
+ const candidates = process.platform === "darwin" ? [join4(root, entry.name, "claude.app", "Contents", "MacOS", "claude"), join4(root, entry.name, executable)] : [join4(root, entry.name, executable)];
23674
+ for (const candidate of candidates) {
23675
+ if (!existsSync3(candidate)) continue;
23676
+ if (spawnSync(candidate, ["--version"], { stdio: "ignore", timeout: 5e3, killSignal: "SIGKILL" }).status !== 0)
23677
+ throw new Error("Claude Desktop's bundled Code executable could not run. Update or reinstall Claude Desktop.");
23678
+ return candidate;
23679
+ }
23680
+ }
23681
+ }
23682
+ throw new Error("Claude Code is unavailable. Install it or open Desktop's Code tab, then retry setup.");
23683
+ }
23684
+ function claudeAvailable() {
23685
+ try {
23686
+ claudeCommand();
23687
+ return true;
23688
+ } catch {
23689
+ return false;
23690
+ }
23691
+ }
23636
23692
  function cotalHome() {
23637
23693
  if (process.env.COTAL_HOME) return process.env.COTAL_HOME;
23638
23694
  if (process.platform === "win32" && process.env.LOCALAPPDATA) return join4(process.env.LOCALAPPDATA, "Cotal");
@@ -23656,7 +23712,7 @@ function materialize(name, root, assets, version2, files = {}) {
23656
23712
  let movedAside = false;
23657
23713
  let swapped = false;
23658
23714
  try {
23659
- mkdirSync(staging, { recursive: true });
23715
+ mkdirSync(staging);
23660
23716
  for (const asset of assets) {
23661
23717
  const destination = join4(staging, asset);
23662
23718
  mkdirSync(join4(destination, ".."), { recursive: true });
@@ -23689,7 +23745,7 @@ function command(...args) {
23689
23745
  return commandIn(process.cwd(), ...args);
23690
23746
  }
23691
23747
  function commandIn(cwd, ...args) {
23692
- const result = spawnSync("claude", args, { cwd, encoding: "utf8", maxBuffer: CLAUDE_OUTPUT_LIMIT });
23748
+ const result = spawnSync(claudeCommand(), args, { cwd, encoding: "utf8", maxBuffer: CLAUDE_OUTPUT_LIMIT, timeout: 12e4, killSignal: "SIGKILL" });
23693
23749
  if (result.error) return { status: null, output: result.error.message };
23694
23750
  return { status: result.status, output: `${result.stdout ?? ""}${result.stderr ?? ""}`.trim() };
23695
23751
  }
@@ -23705,7 +23761,7 @@ function marketplaceManifest(market) {
23705
23761
  function writeMarketplaceManifest(market) {
23706
23762
  const path = join4(market, ".claude-plugin", "marketplace.json");
23707
23763
  mkdirSync(dirname2(path), { recursive: true });
23708
- writeFileSync2(path, JSON.stringify(marketplaceManifest(market), null, 2) + "\n");
23764
+ writePrivateRecord(path, JSON.stringify(marketplaceManifest(market), null, 2) + "\n");
23709
23765
  return path;
23710
23766
  }
23711
23767
  function writeMarketplace() {
@@ -23718,6 +23774,28 @@ ${add.output}`);
23718
23774
  if (update.status !== 0) throw new Error(`plugin marketplace update failed:
23719
23775
  ${update.output}`);
23720
23776
  }
23777
+ function installedForRefresh() {
23778
+ const config2 = process.env.CLAUDE_CONFIG_DIR?.trim() || join4(homedir3(), ".claude");
23779
+ const cache = process.env.CLAUDE_CODE_PLUGIN_CACHE_DIR?.trim() || join4(config2, "plugins");
23780
+ const path = join4(cache, "installed_plugins.json");
23781
+ if (!existsSync3(path)) return [];
23782
+ let records;
23783
+ try {
23784
+ records = JSON.parse(readFileSync3(path, "utf8")).plugins;
23785
+ } catch {
23786
+ throw new Error("Claude's plugin records could not be read, so Cotal cannot verify their upgrade");
23787
+ }
23788
+ if (!records || typeof records !== "object" || Array.isArray(records))
23789
+ throw new Error("Claude's plugin records have an unsupported shape, so Cotal cannot verify their upgrade");
23790
+ for (const name of ["cotal", "cotal-skills"]) {
23791
+ const entries = records[`${name}@${MARKETPLACE}`];
23792
+ if (entries !== void 0 && (!Array.isArray(entries) || entries.length > 0)) {
23793
+ if (!claudeAvailable()) throw new Error(`${name}@${MARKETPLACE} is installed, but Claude Code is unavailable. Restore Claude Code or open Desktop's Code tab, then retry the Cotal update.`);
23794
+ return listPlugins();
23795
+ }
23796
+ }
23797
+ return [];
23798
+ }
23721
23799
  function listPlugins(cwd = process.cwd()) {
23722
23800
  const result = commandIn(cwd, "plugin", "list", "--json");
23723
23801
  if (result.status !== 0) throw new Error(`plugin list failed:
@@ -23754,6 +23832,50 @@ ${update.output}`);
23754
23832
  }
23755
23833
  verify(name, scope, expectedVersion);
23756
23834
  }
23835
+ function refreshInstalls(name, entries, version2) {
23836
+ for (const entry of entries) {
23837
+ const scope = entry.scope;
23838
+ if (scope !== "user" && scope !== "local" && scope !== "project")
23839
+ throw new Error(`cannot refresh ${name}@${MARKETPLACE} at ${String(scope)} scope; its administrator must update it`);
23840
+ const cwd = scope === "user" ? cotalHome() : entry.projectPath;
23841
+ if (typeof cwd !== "string") throw new Error(`${name}@${MARKETPLACE} (${scope} scope) has no project path`);
23842
+ if (!statSync2(cwd, { throwIfNoEntry: false })?.isDirectory()) continue;
23843
+ if (entry.version === version2 && resolvedPluginCurrent(entry, version2, name)) continue;
23844
+ const update = commandIn(cwd, "plugin", "update", `${name}@${MARKETPLACE}`, "--scope", scope);
23845
+ if (update.status !== 0) throw new Error(`plugin update failed (${name}, ${scope} scope):
23846
+ ${update.output}`);
23847
+ const current = listPlugins(cwd).find((candidate) => candidate.id === entry.id && candidate.scope === scope && (scope === "user" || candidate.projectPath === entry.projectPath));
23848
+ if (!current || current.version !== version2 || !resolvedPluginCurrent(current, version2, name))
23849
+ throw new Error(`${name}@${MARKETPLACE} (${scope} scope) did not load the updated plugin ${version2}`);
23850
+ }
23851
+ }
23852
+ function resolvedPluginCurrent(entry, version2, name = "cotal") {
23853
+ const sourceRoot = name === "cotal" ? PACKAGE_ROOT : join4(marketplaceDir(), name);
23854
+ const assets = name === "cotal" ? COTAL_ASSETS : [".claude-plugin", "skills"];
23855
+ const root = entry.readFromFolder ?? entry.installPath;
23856
+ if (typeof root !== "string") return false;
23857
+ try {
23858
+ const manifest = JSON.parse(readFileSync3(join4(root, ".claude-plugin", "plugin.json"), "utf8"));
23859
+ if (manifest.version !== version2) return false;
23860
+ const record2 = name === "cotal" ? JSON.parse(readFileSync3(join4(marketplaceDir(), "cotal", "dist", CLI_RECORD), "utf8")) : void 0;
23861
+ const generated = record2 ? pluginFiles(record2.argv) : {};
23862
+ const same = (asset) => {
23863
+ const source = join4(sourceRoot, asset);
23864
+ const target = join4(root, asset);
23865
+ const generatedText = generated[asset.replaceAll("\\", "/")];
23866
+ if (generatedText !== void 0) return readFileSync3(target).equals(Buffer.from(generatedText));
23867
+ if (statSync2(source).isDirectory()) return readdirSync(source).every((name2) => same(join4(asset, name2)));
23868
+ if (asset === join4(".claude-plugin", "plugin.json")) {
23869
+ const expected = JSON.parse(readFileSync3(source, "utf8"));
23870
+ return JSON.stringify({ ...expected, version: version2 }) === JSON.stringify(manifest);
23871
+ }
23872
+ return readFileSync3(source).equals(readFileSync3(target));
23873
+ };
23874
+ return assets.every(same) && (name !== "cotal" || readFileSync3(join4(root, "dist", CLI_RECORD)).equals(readFileSync3(join4(marketplaceDir(), "cotal", "dist", CLI_RECORD))));
23875
+ } catch {
23876
+ return false;
23877
+ }
23878
+ }
23757
23879
  function retireProjectInstalls() {
23758
23880
  let removed = 0;
23759
23881
  const failed = [];
@@ -23772,10 +23894,10 @@ ${failed.join("\n")}`
23772
23894
  return removed;
23773
23895
  }
23774
23896
  function pluginList() {
23775
- const result = spawnSync("claude", ["plugin", "list", "--json"], { encoding: "utf8", maxBuffer: CLAUDE_OUTPUT_LIMIT });
23776
- if (result.error || result.status !== 0) return void 0;
23777
23897
  try {
23778
- const parsed = JSON.parse(result.stdout || "[]");
23898
+ const result = command("plugin", "list", "--json");
23899
+ if (result.status !== 0) return void 0;
23900
+ const parsed = JSON.parse(result.output || "[]");
23779
23901
  return Array.isArray(parsed) ? parsed : void 0;
23780
23902
  } catch {
23781
23903
  return void 0;
@@ -23805,6 +23927,9 @@ function pluginRow(entries, { version: version2 }) {
23805
23927
  materialized = void 0;
23806
23928
  }
23807
23929
  if (typeof materialized !== "string" || !materialized.startsWith(`${version2}+`)) return row("warn", "stale \xB7 run `cotal setup`");
23930
+ const active = installs.filter((entry) => entry.scope === "user" || typeof entry.projectPath !== "string" || statSync2(entry.projectPath, { throwIfNoEntry: false })?.isDirectory());
23931
+ if (active.some((entry) => entry.version !== materialized || !resolvedPluginCurrent(entry, materialized)))
23932
+ return row("warn", "stale \xB7 run `cotal setup`");
23808
23933
  if (installs.some((entry) => entry.scope === "user")) return row("ok", "current (user scope)");
23809
23934
  return row("ok", `current (${installs.length} install${installs.length === 1 ? "" : "s"})`);
23810
23935
  }
@@ -23830,18 +23955,34 @@ function copyable(name, spec) {
23830
23955
  return [env, headers].every((values) => values === void 0 || Object.values(values).every((v) => v.replace(ENV_REFERENCE, "") === ""));
23831
23956
  }
23832
23957
  var assistSession;
23958
+ function materializeSkills({ skillsDir, version: version2, stateDir }) {
23959
+ const manifestRoot = join4(PACKAGE_ROOT, "skills-plugin");
23960
+ if (!existsSync3(join4(manifestRoot, ".claude-plugin", "plugin.json"))) throw new Error("Claude skills plugin manifest is missing");
23961
+ const payload = join4(stateDir, `.claude-skills-payload.${process.pid}`);
23962
+ rmSync(payload, { recursive: true, force: true });
23963
+ try {
23964
+ mkdirSync(stateDir, { recursive: true });
23965
+ mkdirSync(payload);
23966
+ cpSync(join4(manifestRoot, ".claude-plugin"), join4(payload, ".claude-plugin"), { recursive: true, dereference: true });
23967
+ cpSync(skillsDir, join4(payload, "skills"), { recursive: true, dereference: true });
23968
+ materialize("cotal-skills", payload, [".claude-plugin", "skills"], version2);
23969
+ } finally {
23970
+ rmSync(payload, { recursive: true, force: true });
23971
+ }
23972
+ }
23833
23973
  var claudeSetupProvider = {
23834
23974
  kind: "connector-setup",
23835
23975
  name: "claude",
23836
23976
  requires: ["claude"],
23977
+ available: claudeAvailable,
23837
23978
  connector: {
23838
23979
  name: "claude-plugin",
23839
23980
  title: "Install the Claude Code plugin",
23840
- explain: "Lets every Claude Code session on this machine join the web and wake on peer messages.",
23981
+ explain: "Installs Cotal messaging for Claude Code, including supported local sessions in Desktop's Code tab. Reopen Claude after setup.",
23841
23982
  context: [DOCS_URL],
23842
23983
  run({ cotal }) {
23843
- materializeCotal(cotal);
23844
- install("cotal", "user");
23984
+ const version2 = materializeCotal(cotal);
23985
+ install("cotal", "user", version2);
23845
23986
  const app = desktop(cotal, true);
23846
23987
  const removed = retireProjectInstalls();
23847
23988
  const replaced = removed ? `, replacing ${removed} project install${removed === 1 ? "" : "s"}` : "";
@@ -23853,16 +23994,25 @@ var claudeSetupProvider = {
23853
23994
  title: "Refresh the Claude Code plugin",
23854
23995
  explain: "Rewrites the copy of the Cotal plugin that Claude Code sessions load, and Cotal's entry in Claude Desktop, for this release.",
23855
23996
  context: [DOCS_URL],
23856
- run({ cotal }) {
23857
- const code = listPlugins().some((entry) => entry.id === `cotal@${MARKETPLACE}`);
23997
+ run({ cotal, skills }) {
23998
+ const entries = installedForRefresh();
23999
+ const installs = entries.filter((entry) => entry.id === `cotal@${MARKETPLACE}`);
24000
+ const skillInstalls = entries.filter((entry) => entry.id === `cotal-skills@${MARKETPLACE}`);
23858
24001
  const path = desktopConfigPath();
23859
24002
  const app = path !== void 0 && readDesktopEntry(path) !== void 0;
23860
- if (!code && !app) return "not installed";
23861
- const version2 = materializeCotal(cotal);
24003
+ if (!installs.length && !skillInstalls.length && !app) return "not installed";
24004
+ if (skillInstalls.length && !skills) throw new Error("current skills are required to refresh the installed Claude skills plugin");
24005
+ const version2 = installs.length || app ? materializeCotal(cotal) : void 0;
24006
+ if (skillInstalls.length) materializeSkills(skills);
24007
+ if (installs.length || skillInstalls.length) writeMarketplace();
23862
24008
  const parts = [];
23863
- if (code) {
23864
- writeMarketplace();
23865
- parts.push(`cotal@${MARKETPLACE} ${version2}; each Claude Code session loads it when it starts`);
24009
+ if (installs.length) {
24010
+ refreshInstalls("cotal", installs, version2);
24011
+ parts.push(`cotal@${MARKETPLACE} ${version2}; reload plugins or reopen Claude to load it in running sessions`);
24012
+ }
24013
+ if (skillInstalls.length) {
24014
+ refreshInstalls("cotal-skills", skillInstalls, skills.version);
24015
+ parts.push(`cotal-skills@${MARKETPLACE} ${skills.version}`);
23866
24016
  }
23867
24017
  const desktopText = app ? desktop(cotal, false) : void 0;
23868
24018
  if (desktopText) parts.push(desktopText);
@@ -23874,21 +24024,10 @@ var claudeSetupProvider = {
23874
24024
  title: "Add Cotal's skills to Claude Code",
23875
24025
  explain: "Installs Cotal's authored skills as a Claude Code plugin.",
23876
24026
  context: [DOCS_URL],
23877
- run({ skillsDir, version: version2, stateDir }) {
23878
- const manifestRoot = join4(PACKAGE_ROOT, "skills-plugin");
23879
- if (!existsSync3(join4(manifestRoot, ".claude-plugin", "plugin.json"))) throw new Error("Claude skills plugin manifest is missing");
23880
- const payload = join4(stateDir, `.claude-skills-payload.${process.pid}`);
23881
- rmSync(payload, { recursive: true, force: true });
23882
- try {
23883
- mkdirSync(payload, { recursive: true });
23884
- cpSync(join4(manifestRoot, ".claude-plugin"), join4(payload, ".claude-plugin"), { recursive: true, dereference: true });
23885
- cpSync(skillsDir, join4(payload, "skills"), { recursive: true, dereference: true });
23886
- materialize("cotal-skills", payload, [".claude-plugin", "skills"], version2);
23887
- install("cotal-skills", "user", version2);
23888
- return `cotal-skills@${MARKETPLACE} (user scope)`;
23889
- } finally {
23890
- rmSync(payload, { recursive: true, force: true });
23891
- }
24027
+ run(input) {
24028
+ materializeSkills(input);
24029
+ install("cotal-skills", "user", input.version);
24030
+ return `cotal-skills@${MARKETPLACE} (user scope)`;
23892
24031
  }
23893
24032
  },
23894
24033
  mcpServers: {
@@ -23912,7 +24051,7 @@ var claudeSetupProvider = {
23912
24051
  title: "Claude",
23913
24052
  run(prompt) {
23914
24053
  const sessionArgs = assistSession ? ["--resume", assistSession] : ["--session-id", assistSession = randomUUID()];
23915
- const child = spawn("claude", [prompt, "--permission-mode", "auto", ...sessionArgs], { stdio: "inherit" });
24054
+ const child = spawn(claudeCommand(), [prompt, "--permission-mode", "auto", ...sessionArgs], { stdio: "inherit" });
23916
24055
  return new Promise((resolve2, reject) => {
23917
24056
  child.on("exit", () => resolve2());
23918
24057
  child.on("error", reject);
@@ -23935,9 +24074,10 @@ import { loadAgentFile as loadAgentFile2, registry as registry4, writeLaunchArti
23935
24074
  // src/carried.ts
23936
24075
  import { createHash as createHash3 } from "node:crypto";
23937
24076
  import { execFileSync } from "node:child_process";
23938
- import { copyFileSync, lstatSync, mkdirSync as mkdirSync2, readdirSync as readdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
24077
+ import { constants, copyFileSync, lstatSync, mkdirSync as mkdirSync2, readdirSync as readdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
23939
24078
  import { homedir as homedir4, hostname as hostname3 } from "node:os";
23940
24079
  import { join as join5 } from "node:path";
24080
+ import { writePrivateRecord as writePrivateRecord2 } from "@cotal-ai/core";
23941
24081
  var SEAT_PROJECT = "seat";
23942
24082
  var FORK_RECORD = "cotal-fork.json";
23943
24083
  var MIN_VERSION = [2, 1, 234];
@@ -24014,11 +24154,11 @@ function carriedForkRecord(home) {
24014
24154
  return join5(home, FORK_RECORD);
24015
24155
  }
24016
24156
  function placeCarried(home, transcript, resume, cwd) {
24017
- writeFileSync3(join5(home, ".claude.json"), JSON.stringify({ hasCompletedOnboarding: true, projects: { [cwd]: { hasTrustDialogAccepted: true } } }), { mode: 384 });
24157
+ writePrivateRecord2(join5(home, ".claude.json"), JSON.stringify({ hasCompletedOnboarding: true, projects: { [cwd]: { hasTrustDialogAccepted: true } } }));
24018
24158
  if (resume !== void 0) {
24019
24159
  const dir = join5(home, "projects", SEAT_PROJECT);
24020
24160
  mkdirSync2(dir, { recursive: true, mode: 448 });
24021
- copyFileSync(transcript, join5(dir, `${resume}.jsonl`));
24161
+ copyFileSync(transcript, join5(dir, `${resume}.jsonl`), constants.COPYFILE_EXCL);
24022
24162
  }
24023
24163
  return { CLAUDE_CONFIG_DIR: home, CLAUDE_CODE_PROJECT_DIR_NAME: SEAT_PROJECT, ...resume !== void 0 ? { COTAL_CLAUDE_CARRIED: resume } : {} };
24024
24164
  }
@@ -24231,5 +24371,6 @@ export {
24231
24371
  claudeConnector,
24232
24372
  claudeSetupProvider,
24233
24373
  marketplaceManifest,
24374
+ materialize,
24234
24375
  writeMarketplaceManifest
24235
24376
  };