@cotal-ai/connector-claude-code 0.90.1 → 0.92.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) {
@@ -6892,9 +6892,11 @@ import { homedir as homedir3 } from "node:os";
6892
6892
  import { dirname as dirname2, join as join4, relative } from "node:path";
6893
6893
  import { fileURLToPath } from "node:url";
6894
6894
  import {
6895
+ acquireLock,
6895
6896
  globalConfigPath,
6896
6897
  mcpServerProblem as mcpServerProblem2,
6897
- registry as registry3
6898
+ registry as registry3,
6899
+ writePrivateRecord
6898
6900
  } from "@cotal-ai/core";
6899
6901
 
6900
6902
  // ../connector-core/dist/config.js
@@ -21780,7 +21782,7 @@ config(en_default());
21780
21782
  import { isConcreteChannel as isConcreteChannel3, channelInAllow as channelInAllow3, AmbiguousPeerError, peerLabel as peerLabel4, assertLifecycleToken as assertLifecycleToken3, isPermissionDenied as isPermissionDenied2, renderLifecycleBlocked, EpEnvelopeError as EpEnvelopeError3, LANG_PROBLEM_DETAIL_KIND, formatAge, presenceAges, presenceText } from "@cotal-ai/core";
21781
21783
 
21782
21784
  // ../connector-core/dist/orientation.js
21783
- import { peerLabel as peerLabel3 } from "@cotal-ai/core";
21785
+ import { parsePrincipalKey as parsePrincipalKey2, peerLabel as peerLabel3 } from "@cotal-ai/core";
21784
21786
 
21785
21787
  // ../connector-core/dist/docs.js
21786
21788
  var STOP = new Set("a an and are as at be by do for from has how in is it of on or that the this to use using was what when where which who with you your".split(" "));
@@ -23611,12 +23613,33 @@ function pluginVersion(root, assets, files) {
23611
23613
  }
23612
23614
  function materializeCotal(cotal) {
23613
23615
  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
- ` };
23616
+ const files = pluginFiles(cotal);
23616
23617
  const version2 = pluginVersion(PACKAGE_ROOT, COTAL_ASSETS, files);
23617
23618
  materialize("cotal", PACKAGE_ROOT, COTAL_ASSETS, version2, files);
23618
23619
  return version2;
23619
23620
  }
23621
+ function pluginFiles(cotal) {
23622
+ const node = cotal[0];
23623
+ if (!node) throw new Error("the Cotal CLI record has no Node executable");
23624
+ if (process.platform === "win32" && /[\"%!\r\n]/.test(node))
23625
+ throw new Error("the Node executable path contains characters Claude's Windows command hooks cannot safely run");
23626
+ const quoted = process.platform === "win32" ? `"${node}"` : `'${node.replace(/'/g, "'\\''")}'`;
23627
+ const mcp = JSON.parse(readFileSync3(join4(PACKAGE_ROOT, ".mcp.json"), "utf8"));
23628
+ mcp.mcpServers.cotal.command = node;
23629
+ const hooks = JSON.parse(readFileSync3(join4(PACKAGE_ROOT, "hooks", "hooks.json"), "utf8"));
23630
+ for (const groups of Object.values(hooks.hooks)) for (const group of groups) for (const hook of group.hooks) {
23631
+ if (hook.command === 'node "${CLAUDE_PLUGIN_ROOT}/dist/hook.cjs"')
23632
+ hook.command = quoted + ' "${CLAUDE_PLUGIN_ROOT}/dist/hook.cjs"';
23633
+ }
23634
+ return {
23635
+ [`dist/${CLI_RECORD}`]: `${JSON.stringify({ argv: cotal })}
23636
+ `,
23637
+ ".mcp.json": `${JSON.stringify(mcp, null, 2)}
23638
+ `,
23639
+ "hooks/hooks.json": `${JSON.stringify(hooks, null, 2)}
23640
+ `
23641
+ };
23642
+ }
23620
23643
  function desktopEntry(cotal) {
23621
23644
  return {
23622
23645
  command: cotal[0],
@@ -23633,6 +23656,40 @@ function desktop(cotal, add) {
23633
23656
  }
23634
23657
  var DOCS_URL = "https://github.com/Cotal-AI/Cotal/blob/main/docs/connect-claude.md";
23635
23658
  var MARKETPLACE = "cotal-mesh";
23659
+ function claudeCommand() {
23660
+ const terminal = spawnSync("claude", ["--version"], { stdio: "ignore", timeout: 5e3, killSignal: "SIGKILL" });
23661
+ if (terminal.status === 0) return "claude";
23662
+ if (terminal.error?.code !== "ENOENT")
23663
+ throw new Error("The installed Claude Code command could not run. Repair it before running cotal setup.");
23664
+ const config2 = desktopConfigPath();
23665
+ const app = config2 ? dirname2(config2) : process.platform === "linux" ? join4(process.env.XDG_CONFIG_HOME || join4(homedir3(), ".config"), "Claude") : void 0;
23666
+ 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.");
23667
+ const cache = join4(app, "claude-code");
23668
+ 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 }));
23669
+ const executable = process.platform === "win32" ? "claude.exe" : "claude";
23670
+ for (const version2 of versions) {
23671
+ const root = join4(cache, version2.name);
23672
+ for (const entry of readdirSync(root, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
23673
+ if (!entry.isDirectory()) continue;
23674
+ const candidates = process.platform === "darwin" ? [join4(root, entry.name, "claude.app", "Contents", "MacOS", "claude"), join4(root, entry.name, executable)] : [join4(root, entry.name, executable)];
23675
+ for (const candidate of candidates) {
23676
+ if (!existsSync3(candidate)) continue;
23677
+ if (spawnSync(candidate, ["--version"], { stdio: "ignore", timeout: 5e3, killSignal: "SIGKILL" }).status !== 0)
23678
+ throw new Error("Claude Desktop's bundled Code executable could not run. Update or reinstall Claude Desktop.");
23679
+ return candidate;
23680
+ }
23681
+ }
23682
+ }
23683
+ throw new Error("Claude Code is unavailable. Install it or open Desktop's Code tab, then retry setup.");
23684
+ }
23685
+ function claudeAvailable() {
23686
+ try {
23687
+ claudeCommand();
23688
+ return true;
23689
+ } catch {
23690
+ return false;
23691
+ }
23692
+ }
23636
23693
  function cotalHome() {
23637
23694
  if (process.env.COTAL_HOME) return process.env.COTAL_HOME;
23638
23695
  if (process.platform === "win32" && process.env.LOCALAPPDATA) return join4(process.env.LOCALAPPDATA, "Cotal");
@@ -23641,6 +23698,14 @@ function cotalHome() {
23641
23698
  function marketplaceDir() {
23642
23699
  return join4(cotalHome(), "claude-plugin");
23643
23700
  }
23701
+ function withPluginLock(run) {
23702
+ const lock = acquireLock(join4(marketplaceDir(), ".setup.lock"), { label: "Claude plugin setup" });
23703
+ try {
23704
+ return run();
23705
+ } finally {
23706
+ lock.release();
23707
+ }
23708
+ }
23644
23709
  function materialize(name, root, assets, version2, files = {}) {
23645
23710
  const market = marketplaceDir();
23646
23711
  mkdirSync(market, { recursive: true });
@@ -23656,7 +23721,7 @@ function materialize(name, root, assets, version2, files = {}) {
23656
23721
  let movedAside = false;
23657
23722
  let swapped = false;
23658
23723
  try {
23659
- mkdirSync(staging, { recursive: true });
23724
+ mkdirSync(staging);
23660
23725
  for (const asset of assets) {
23661
23726
  const destination = join4(staging, asset);
23662
23727
  mkdirSync(join4(destination, ".."), { recursive: true });
@@ -23689,7 +23754,7 @@ function command(...args) {
23689
23754
  return commandIn(process.cwd(), ...args);
23690
23755
  }
23691
23756
  function commandIn(cwd, ...args) {
23692
- const result = spawnSync("claude", args, { cwd, encoding: "utf8", maxBuffer: CLAUDE_OUTPUT_LIMIT });
23757
+ const result = spawnSync(claudeCommand(), args, { cwd, encoding: "utf8", maxBuffer: CLAUDE_OUTPUT_LIMIT, timeout: 12e4, killSignal: "SIGKILL" });
23693
23758
  if (result.error) return { status: null, output: result.error.message };
23694
23759
  return { status: result.status, output: `${result.stdout ?? ""}${result.stderr ?? ""}`.trim() };
23695
23760
  }
@@ -23705,7 +23770,7 @@ function marketplaceManifest(market) {
23705
23770
  function writeMarketplaceManifest(market) {
23706
23771
  const path = join4(market, ".claude-plugin", "marketplace.json");
23707
23772
  mkdirSync(dirname2(path), { recursive: true });
23708
- writeFileSync2(path, JSON.stringify(marketplaceManifest(market), null, 2) + "\n");
23773
+ writePrivateRecord(path, JSON.stringify(marketplaceManifest(market), null, 2) + "\n");
23709
23774
  return path;
23710
23775
  }
23711
23776
  function writeMarketplace() {
@@ -23718,6 +23783,28 @@ ${add.output}`);
23718
23783
  if (update.status !== 0) throw new Error(`plugin marketplace update failed:
23719
23784
  ${update.output}`);
23720
23785
  }
23786
+ function installedForRefresh() {
23787
+ const config2 = process.env.CLAUDE_CONFIG_DIR?.trim() || join4(homedir3(), ".claude");
23788
+ const cache = process.env.CLAUDE_CODE_PLUGIN_CACHE_DIR?.trim() || join4(config2, "plugins");
23789
+ const path = join4(cache, "installed_plugins.json");
23790
+ if (!existsSync3(path)) return [];
23791
+ let records;
23792
+ try {
23793
+ records = JSON.parse(readFileSync3(path, "utf8")).plugins;
23794
+ } catch {
23795
+ throw new Error("Claude's plugin records could not be read, so Cotal cannot verify their upgrade");
23796
+ }
23797
+ if (!records || typeof records !== "object" || Array.isArray(records))
23798
+ throw new Error("Claude's plugin records have an unsupported shape, so Cotal cannot verify their upgrade");
23799
+ for (const name of ["cotal", "cotal-skills"]) {
23800
+ const entries = records[`${name}@${MARKETPLACE}`];
23801
+ if (entries !== void 0 && (!Array.isArray(entries) || entries.length > 0)) {
23802
+ 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.`);
23803
+ return listPlugins();
23804
+ }
23805
+ }
23806
+ return [];
23807
+ }
23721
23808
  function listPlugins(cwd = process.cwd()) {
23722
23809
  const result = commandIn(cwd, "plugin", "list", "--json");
23723
23810
  if (result.status !== 0) throw new Error(`plugin list failed:
@@ -23754,6 +23841,50 @@ ${update.output}`);
23754
23841
  }
23755
23842
  verify(name, scope, expectedVersion);
23756
23843
  }
23844
+ function refreshInstalls(name, entries, version2) {
23845
+ for (const entry of entries) {
23846
+ const scope = entry.scope;
23847
+ if (scope !== "user" && scope !== "local" && scope !== "project")
23848
+ throw new Error(`cannot refresh ${name}@${MARKETPLACE} at ${String(scope)} scope; its administrator must update it`);
23849
+ const cwd = scope === "user" ? cotalHome() : entry.projectPath;
23850
+ if (typeof cwd !== "string") throw new Error(`${name}@${MARKETPLACE} (${scope} scope) has no project path`);
23851
+ if (!statSync2(cwd, { throwIfNoEntry: false })?.isDirectory()) continue;
23852
+ if (entry.version === version2 && resolvedPluginCurrent(entry, version2, name)) continue;
23853
+ const update = commandIn(cwd, "plugin", "update", `${name}@${MARKETPLACE}`, "--scope", scope);
23854
+ if (update.status !== 0) throw new Error(`plugin update failed (${name}, ${scope} scope):
23855
+ ${update.output}`);
23856
+ const current = listPlugins(cwd).find((candidate) => candidate.id === entry.id && candidate.scope === scope && (scope === "user" || candidate.projectPath === entry.projectPath));
23857
+ if (!current || current.version !== version2 || !resolvedPluginCurrent(current, version2, name))
23858
+ throw new Error(`${name}@${MARKETPLACE} (${scope} scope) did not load the updated plugin ${version2}`);
23859
+ }
23860
+ }
23861
+ function resolvedPluginCurrent(entry, version2, name = "cotal") {
23862
+ const sourceRoot = name === "cotal" ? PACKAGE_ROOT : join4(marketplaceDir(), name);
23863
+ const assets = name === "cotal" ? COTAL_ASSETS : [".claude-plugin", "skills"];
23864
+ const root = entry.readFromFolder ?? entry.installPath;
23865
+ if (typeof root !== "string") return false;
23866
+ try {
23867
+ const manifest = JSON.parse(readFileSync3(join4(root, ".claude-plugin", "plugin.json"), "utf8"));
23868
+ if (manifest.version !== version2) return false;
23869
+ const record2 = name === "cotal" ? JSON.parse(readFileSync3(join4(marketplaceDir(), "cotal", "dist", CLI_RECORD), "utf8")) : void 0;
23870
+ const generated = record2 ? pluginFiles(record2.argv) : {};
23871
+ const same = (asset) => {
23872
+ const source = join4(sourceRoot, asset);
23873
+ const target = join4(root, asset);
23874
+ const generatedText = generated[asset.replaceAll("\\", "/")];
23875
+ if (generatedText !== void 0) return readFileSync3(target).equals(Buffer.from(generatedText));
23876
+ if (statSync2(source).isDirectory()) return readdirSync(source).every((name2) => same(join4(asset, name2)));
23877
+ if (asset === join4(".claude-plugin", "plugin.json")) {
23878
+ const expected = JSON.parse(readFileSync3(source, "utf8"));
23879
+ return JSON.stringify({ ...expected, version: version2 }) === JSON.stringify(manifest);
23880
+ }
23881
+ return readFileSync3(source).equals(readFileSync3(target));
23882
+ };
23883
+ return assets.every(same) && (name !== "cotal" || readFileSync3(join4(root, "dist", CLI_RECORD)).equals(readFileSync3(join4(marketplaceDir(), "cotal", "dist", CLI_RECORD))));
23884
+ } catch {
23885
+ return false;
23886
+ }
23887
+ }
23757
23888
  function retireProjectInstalls() {
23758
23889
  let removed = 0;
23759
23890
  const failed = [];
@@ -23772,10 +23903,10 @@ ${failed.join("\n")}`
23772
23903
  return removed;
23773
23904
  }
23774
23905
  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
23906
  try {
23778
- const parsed = JSON.parse(result.stdout || "[]");
23907
+ const result = command("plugin", "list", "--json");
23908
+ if (result.status !== 0) return void 0;
23909
+ const parsed = JSON.parse(result.output || "[]");
23779
23910
  return Array.isArray(parsed) ? parsed : void 0;
23780
23911
  } catch {
23781
23912
  return void 0;
@@ -23805,6 +23936,9 @@ function pluginRow(entries, { version: version2 }) {
23805
23936
  materialized = void 0;
23806
23937
  }
23807
23938
  if (typeof materialized !== "string" || !materialized.startsWith(`${version2}+`)) return row("warn", "stale \xB7 run `cotal setup`");
23939
+ const active = installs.filter((entry) => entry.scope === "user" || typeof entry.projectPath !== "string" || statSync2(entry.projectPath, { throwIfNoEntry: false })?.isDirectory());
23940
+ if (active.some((entry) => entry.version !== materialized || !resolvedPluginCurrent(entry, materialized)))
23941
+ return row("warn", "stale \xB7 run `cotal setup`");
23808
23942
  if (installs.some((entry) => entry.scope === "user")) return row("ok", "current (user scope)");
23809
23943
  return row("ok", `current (${installs.length} install${installs.length === 1 ? "" : "s"})`);
23810
23944
  }
@@ -23830,22 +23964,40 @@ function copyable(name, spec) {
23830
23964
  return [env, headers].every((values) => values === void 0 || Object.values(values).every((v) => v.replace(ENV_REFERENCE, "") === ""));
23831
23965
  }
23832
23966
  var assistSession;
23967
+ function materializeSkills({ skillsDir, version: version2, stateDir }) {
23968
+ const manifestRoot = join4(PACKAGE_ROOT, "skills-plugin");
23969
+ if (!existsSync3(join4(manifestRoot, ".claude-plugin", "plugin.json"))) throw new Error("Claude skills plugin manifest is missing");
23970
+ const payload = join4(stateDir, `.claude-skills-payload.${process.pid}`);
23971
+ rmSync(payload, { recursive: true, force: true });
23972
+ try {
23973
+ mkdirSync(stateDir, { recursive: true });
23974
+ mkdirSync(payload);
23975
+ cpSync(join4(manifestRoot, ".claude-plugin"), join4(payload, ".claude-plugin"), { recursive: true, dereference: true });
23976
+ cpSync(skillsDir, join4(payload, "skills"), { recursive: true, dereference: true });
23977
+ materialize("cotal-skills", payload, [".claude-plugin", "skills"], version2);
23978
+ } finally {
23979
+ rmSync(payload, { recursive: true, force: true });
23980
+ }
23981
+ }
23833
23982
  var claudeSetupProvider = {
23834
23983
  kind: "connector-setup",
23835
23984
  name: "claude",
23836
23985
  requires: ["claude"],
23986
+ available: claudeAvailable,
23837
23987
  connector: {
23838
23988
  name: "claude-plugin",
23839
23989
  title: "Install the Claude Code plugin",
23840
- explain: "Lets every Claude Code session on this machine join the web and wake on peer messages.",
23990
+ explain: "Installs Cotal messaging for Claude Code, including supported local sessions in Desktop's Code tab. Reopen Claude after setup.",
23841
23991
  context: [DOCS_URL],
23842
23992
  run({ cotal }) {
23843
- materializeCotal(cotal);
23844
- install("cotal", "user");
23845
- const app = desktop(cotal, true);
23846
- const removed = retireProjectInstalls();
23847
- const replaced = removed ? `, replacing ${removed} project install${removed === 1 ? "" : "s"}` : "";
23848
- return `cotal@${MARKETPLACE} (user scope${replaced})${app ? `; ${app}` : ""}`;
23993
+ return withPluginLock(() => {
23994
+ const version2 = materializeCotal(cotal);
23995
+ install("cotal", "user", version2);
23996
+ const app = desktop(cotal, true);
23997
+ const removed = retireProjectInstalls();
23998
+ const replaced = removed ? `, replacing ${removed} project install${removed === 1 ? "" : "s"}` : "";
23999
+ return `cotal@${MARKETPLACE} (user scope${replaced})${app ? `; ${app}` : ""}`;
24000
+ });
23849
24001
  }
23850
24002
  },
23851
24003
  refresh: {
@@ -23853,20 +24005,31 @@ var claudeSetupProvider = {
23853
24005
  title: "Refresh the Claude Code plugin",
23854
24006
  explain: "Rewrites the copy of the Cotal plugin that Claude Code sessions load, and Cotal's entry in Claude Desktop, for this release.",
23855
24007
  context: [DOCS_URL],
23856
- run({ cotal }) {
23857
- const code = listPlugins().some((entry) => entry.id === `cotal@${MARKETPLACE}`);
23858
- const path = desktopConfigPath();
23859
- const app = path !== void 0 && readDesktopEntry(path) !== void 0;
23860
- if (!code && !app) return "not installed";
23861
- const version2 = materializeCotal(cotal);
23862
- const parts = [];
23863
- if (code) {
23864
- writeMarketplace();
23865
- parts.push(`cotal@${MARKETPLACE} ${version2}; each Claude Code session loads it when it starts`);
23866
- }
23867
- const desktopText = app ? desktop(cotal, false) : void 0;
23868
- if (desktopText) parts.push(desktopText);
23869
- return parts.join("; ");
24008
+ run({ cotal, skills }) {
24009
+ return withPluginLock(() => {
24010
+ const entries = installedForRefresh();
24011
+ const installs = entries.filter((entry) => entry.id === `cotal@${MARKETPLACE}`);
24012
+ const skillInstalls = entries.filter((entry) => entry.id === `cotal-skills@${MARKETPLACE}`);
24013
+ const path = desktopConfigPath();
24014
+ const app = path !== void 0 && readDesktopEntry(path) !== void 0;
24015
+ if (!installs.length && !skillInstalls.length && !app) return "not installed";
24016
+ if (skillInstalls.length && !skills) throw new Error("current skills are required to refresh the installed Claude skills plugin");
24017
+ const version2 = installs.length || app ? materializeCotal(cotal) : void 0;
24018
+ if (skillInstalls.length) materializeSkills(skills);
24019
+ if (installs.length || skillInstalls.length) writeMarketplace();
24020
+ const parts = [];
24021
+ if (installs.length) {
24022
+ refreshInstalls("cotal", installs, version2);
24023
+ parts.push(`cotal@${MARKETPLACE} ${version2}; reload plugins or reopen Claude to load it in running sessions`);
24024
+ }
24025
+ if (skillInstalls.length) {
24026
+ refreshInstalls("cotal-skills", skillInstalls, skills.version);
24027
+ parts.push(`cotal-skills@${MARKETPLACE} ${skills.version}`);
24028
+ }
24029
+ const desktopText = app ? desktop(cotal, false) : void 0;
24030
+ if (desktopText) parts.push(desktopText);
24031
+ return parts.join("; ");
24032
+ });
23870
24033
  }
23871
24034
  },
23872
24035
  skills: {
@@ -23874,21 +24037,12 @@ var claudeSetupProvider = {
23874
24037
  title: "Add Cotal's skills to Claude Code",
23875
24038
  explain: "Installs Cotal's authored skills as a Claude Code plugin.",
23876
24039
  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);
24040
+ run(input) {
24041
+ return withPluginLock(() => {
24042
+ materializeSkills(input);
24043
+ install("cotal-skills", "user", input.version);
23888
24044
  return `cotal-skills@${MARKETPLACE} (user scope)`;
23889
- } finally {
23890
- rmSync(payload, { recursive: true, force: true });
23891
- }
24045
+ });
23892
24046
  }
23893
24047
  },
23894
24048
  mcpServers: {
@@ -23912,7 +24066,7 @@ var claudeSetupProvider = {
23912
24066
  title: "Claude",
23913
24067
  run(prompt) {
23914
24068
  const sessionArgs = assistSession ? ["--resume", assistSession] : ["--session-id", assistSession = randomUUID()];
23915
- const child = spawn("claude", [prompt, "--permission-mode", "auto", ...sessionArgs], { stdio: "inherit" });
24069
+ const child = spawn(claudeCommand(), [prompt, "--permission-mode", "auto", ...sessionArgs], { stdio: "inherit" });
23916
24070
  return new Promise((resolve2, reject) => {
23917
24071
  child.on("exit", () => resolve2());
23918
24072
  child.on("error", reject);
@@ -23935,9 +24089,10 @@ import { loadAgentFile as loadAgentFile2, registry as registry4, writeLaunchArti
23935
24089
  // src/carried.ts
23936
24090
  import { createHash as createHash3 } from "node:crypto";
23937
24091
  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";
24092
+ import { constants, copyFileSync, lstatSync, mkdirSync as mkdirSync2, readdirSync as readdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
23939
24093
  import { homedir as homedir4, hostname as hostname3 } from "node:os";
23940
24094
  import { join as join5 } from "node:path";
24095
+ import { writePrivateRecord as writePrivateRecord2 } from "@cotal-ai/core";
23941
24096
  var SEAT_PROJECT = "seat";
23942
24097
  var FORK_RECORD = "cotal-fork.json";
23943
24098
  var MIN_VERSION = [2, 1, 234];
@@ -24014,11 +24169,11 @@ function carriedForkRecord(home) {
24014
24169
  return join5(home, FORK_RECORD);
24015
24170
  }
24016
24171
  function placeCarried(home, transcript, resume, cwd) {
24017
- writeFileSync3(join5(home, ".claude.json"), JSON.stringify({ hasCompletedOnboarding: true, projects: { [cwd]: { hasTrustDialogAccepted: true } } }), { mode: 384 });
24172
+ writePrivateRecord2(join5(home, ".claude.json"), JSON.stringify({ hasCompletedOnboarding: true, projects: { [cwd]: { hasTrustDialogAccepted: true } } }));
24018
24173
  if (resume !== void 0) {
24019
24174
  const dir = join5(home, "projects", SEAT_PROJECT);
24020
24175
  mkdirSync2(dir, { recursive: true, mode: 448 });
24021
- copyFileSync(transcript, join5(dir, `${resume}.jsonl`));
24176
+ copyFileSync(transcript, join5(dir, `${resume}.jsonl`), constants.COPYFILE_EXCL);
24022
24177
  }
24023
24178
  return { CLAUDE_CONFIG_DIR: home, CLAUDE_CODE_PROJECT_DIR_NAME: SEAT_PROJECT, ...resume !== void 0 ? { COTAL_CLAUDE_CARRIED: resume } : {} };
24024
24179
  }
@@ -24231,5 +24386,6 @@ export {
24231
24386
  claudeConnector,
24232
24387
  claudeSetupProvider,
24233
24388
  marketplaceManifest,
24389
+ materialize,
24234
24390
  writeMarketplaceManifest
24235
24391
  };