@cotal-ai/connector-claude-code 0.85.0 → 0.86.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 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAcA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AA+EjD,MAAM,WAAW,gBAAgB;IAC/B,mGAAmG;IACnG,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,+FAA+F;IAC/F,MAAM,CAAC,EAAE,MAAM,iBAAiB,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACnE,iFAAiF;IACjF,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,KAAK,IAAI,CAAC;CAClD;AAOD;;+DAE+D;AAC/D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,UAAU,CAAC;IACnB,iDAAiD;IACjD,OAAO,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,GAAE,gBAAqB,GAAG,WAAW,CAoU3E;AAED,wEAAwE;AACxE,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5H,MAAM,WAAW,UAAU;IACzB,+EAA+E;IAC/E,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC;+FAC2F;IAC3F,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI,CAAC;IAC5C,sCAAsC;IACtC,IAAI,IAAI,IAAI,CAAC;CACd;AAKD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAe,GAAG,UAAU,CAsH3H"}
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAcA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AA+EjD,MAAM,WAAW,gBAAgB;IAC/B,mGAAmG;IACnG,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,+FAA+F;IAC/F,MAAM,CAAC,EAAE,MAAM,iBAAiB,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACnE,iFAAiF;IACjF,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,KAAK,IAAI,CAAC;CAClD;AAOD;;+DAE+D;AAC/D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,UAAU,CAAC;IACnB,iDAAiD;IACjD,OAAO,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,GAAE,gBAAqB,GAAG,WAAW,CAyU3E;AAED,wEAAwE;AACxE,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5H,MAAM,WAAW,UAAU;IACzB,+EAA+E;IAC/E,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC;+FAC2F;IAC3F,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI,CAAC;IAC5C,sCAAsC;IACtC,IAAI,IAAI,IAAI,CAAC;CACd;AAKD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAe,GAAG,UAAU,CAsH3H"}
package/dist/index.js CHANGED
@@ -3643,49 +3643,49 @@ var require_fast_uri = __commonJS({
3643
3643
  schemelessOptions.skipEscape = true;
3644
3644
  return serialize(resolved, schemelessOptions);
3645
3645
  }
3646
- function resolveComponent(base, relative, options, skipNormalization) {
3646
+ function resolveComponent(base, relative2, options, skipNormalization) {
3647
3647
  const target = {};
3648
3648
  if (!skipNormalization) {
3649
3649
  base = parse3(serialize(base, options), options);
3650
- relative = parse3(serialize(relative, options), options);
3650
+ relative2 = parse3(serialize(relative2, options), options);
3651
3651
  }
3652
3652
  options = options || {};
3653
- if (!options.tolerant && relative.scheme) {
3654
- target.scheme = relative.scheme;
3655
- target.userinfo = relative.userinfo;
3656
- target.host = relative.host;
3657
- target.port = relative.port;
3658
- target.path = removeDotSegments(relative.path || "");
3659
- target.query = relative.query;
3653
+ if (!options.tolerant && relative2.scheme) {
3654
+ target.scheme = relative2.scheme;
3655
+ target.userinfo = relative2.userinfo;
3656
+ target.host = relative2.host;
3657
+ target.port = relative2.port;
3658
+ target.path = removeDotSegments(relative2.path || "");
3659
+ target.query = relative2.query;
3660
3660
  } else {
3661
- if (relative.userinfo !== void 0 || relative.host !== void 0 || relative.port !== void 0) {
3662
- target.userinfo = relative.userinfo;
3663
- target.host = relative.host;
3664
- target.port = relative.port;
3665
- target.path = removeDotSegments(relative.path || "");
3666
- target.query = relative.query;
3661
+ if (relative2.userinfo !== void 0 || relative2.host !== void 0 || relative2.port !== void 0) {
3662
+ target.userinfo = relative2.userinfo;
3663
+ target.host = relative2.host;
3664
+ target.port = relative2.port;
3665
+ target.path = removeDotSegments(relative2.path || "");
3666
+ target.query = relative2.query;
3667
3667
  } else {
3668
- if (!relative.path) {
3668
+ if (!relative2.path) {
3669
3669
  target.path = base.path;
3670
- if (relative.query !== void 0) {
3671
- target.query = relative.query;
3670
+ if (relative2.query !== void 0) {
3671
+ target.query = relative2.query;
3672
3672
  } else {
3673
3673
  target.query = base.query;
3674
3674
  }
3675
3675
  } else {
3676
- if (relative.path[0] === "/") {
3677
- target.path = removeDotSegments(relative.path);
3676
+ if (relative2.path[0] === "/") {
3677
+ target.path = removeDotSegments(relative2.path);
3678
3678
  } else {
3679
3679
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
3680
- target.path = "/" + relative.path;
3680
+ target.path = "/" + relative2.path;
3681
3681
  } else if (!base.path) {
3682
- target.path = relative.path;
3682
+ target.path = relative2.path;
3683
3683
  } else {
3684
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
3684
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
3685
3685
  }
3686
3686
  target.path = removeDotSegments(target.path);
3687
3687
  }
3688
- target.query = relative.query;
3688
+ target.query = relative2.query;
3689
3689
  }
3690
3690
  target.userinfo = base.userinfo;
3691
3691
  target.host = base.host;
@@ -3693,7 +3693,7 @@ var require_fast_uri = __commonJS({
3693
3693
  }
3694
3694
  target.scheme = base.scheme;
3695
3695
  }
3696
- target.fragment = relative.fragment;
3696
+ target.fragment = relative2.fragment;
3697
3697
  return target;
3698
3698
  }
3699
3699
  function equal(uriA, uriB, options) {
@@ -6886,10 +6886,10 @@ var require_dist = __commonJS({
6886
6886
 
6887
6887
  // src/setup.ts
6888
6888
  import { spawn, spawnSync } from "node:child_process";
6889
- import { randomUUID } from "node:crypto";
6890
- import { cpSync, existsSync as existsSync2, mkdirSync, readdirSync, readFileSync as readFileSync2, renameSync, rmSync, writeFileSync } from "node:fs";
6891
- import { homedir as homedir2 } from "node:os";
6892
- import { dirname, join as join3 } from "node:path";
6889
+ import { createHash as createHash2, randomUUID } from "node:crypto";
6890
+ import { cpSync, existsSync as existsSync3, mkdirSync, readdirSync, readFileSync as readFileSync3, renameSync as renameSync2, rmSync, statSync as statSync2, writeFileSync as writeFileSync2 } from "node:fs";
6891
+ import { homedir as homedir3 } from "node:os";
6892
+ import { dirname, join as join4, relative } from "node:path";
6893
6893
  import { fileURLToPath } from "node:url";
6894
6894
  import {
6895
6895
  globalConfigPath,
@@ -6907,7 +6907,7 @@ import { LAUNCH_MATERIAL_ENV, readLaunchMaterial } from "@cotal-ai/core/launch-m
6907
6907
  import { normalizeMentions, RUN_LAUNCH_DEADLINE_MS, subjectMatches, isConcreteChannel as isConcreteChannel2, assertValidChannel as assertValidChannel2, channelInAllow as channelInAllow2, resolvePeer as resolvePeerInRoster, peerLabel as peerLabel2, CotalEndpoint, acquireLocalConsumer, BASELINE_LIFECYCLE_ENDPOINT as BASELINE_LIFECYCLE_ENDPOINT2, BIND_SPLIT_REISSUES, assertLifecycleToken as assertLifecycleToken2, EpEnvelopeError as EpEnvelopeError2, isPublishPermissionDenied, unansweredRequest, controlReplyFrom, controlReplyFromThrown, runAgentBearer, partsToText, assertValidRole } from "@cotal-ai/core";
6908
6908
 
6909
6909
  // ../connector-core/dist/framing.js
6910
- import { peerLabel } from "@cotal-ai/core";
6910
+ import { peerLabel } from "@cotal-ai/core/peer-label";
6911
6911
 
6912
6912
  // ../connector-core/dist/manager-call.js
6913
6913
  import { BASELINE_LIFECYCLE_ENDPOINT, EpEnvelopeError, dialerFor, goalFollowRefusal, invokeCommand, isPermissionDenied, issuedUserCaller, managerCallerBinding, replyRefusedBeforeEffect, resolveService, standaloneConnectOpts } from "@cotal-ai/core";
@@ -21774,7 +21774,7 @@ function date4(params) {
21774
21774
  config(en_default());
21775
21775
 
21776
21776
  // ../connector-core/dist/tool-specs.js
21777
- 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 } from "@cotal-ai/core";
21777
+ 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";
21778
21778
 
21779
21779
  // ../connector-core/dist/orientation.js
21780
21780
  import { peerLabel as peerLabel3 } from "@cotal-ai/core";
@@ -21784,6 +21784,14 @@ var STOP = new Set("a an and are as at be by do for from has how in is it of on
21784
21784
 
21785
21785
  // ../connector-core/dist/tool-specs.js
21786
21786
  var NO_TOOL_ARGS = external_exports.strictObject({});
21787
+ var managerInstanceArg = external_exports.string().refine((value) => {
21788
+ try {
21789
+ assertLifecycleToken3(value, "instance");
21790
+ return true;
21791
+ } catch {
21792
+ return false;
21793
+ }
21794
+ }, "instance must be a lifecycle token ([a-z0-9]{26,32})").optional().describe("Optional manager instance id for a multi-manager space. When omitted, a seat a manager launched uses that manager and any other caller lets the mesh select one; on a user-auth mesh with several of your managers live, that selection refuses and lists their ids. A pin that cannot be resolved is refused without falling back to another manager.");
21787
21795
 
21788
21796
  // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
21789
21797
  var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
@@ -23513,21 +23521,66 @@ var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
23513
23521
  // ../connector-core/dist/gateway.js
23514
23522
  import { assertValidName } from "@cotal-ai/core";
23515
23523
  var CONNECTION_ID = external_exports.string().min(1).describe("The connection_id cotal_connect returned in THIS conversation. Never reuse another conversation's.");
23524
+ var GATEWAY_LISTENING = "Messages reach you only when you call a tool: to listen, call cotal_wait, which returns as soon as a message arrives. When the person asks you to stay on Cotal or keep listening, call cotal_wait again each time it returns and handle each message as it arrives, until they ask you to stop.";
23525
+ var GATEWAY_CONNECTING = "Cotal connects this conversation to the person's Cotal space. Call cotal_connect once with a short name for this conversation, then pass the returned connection_id on every other cotal tool call. Each conversation needs its own connection. Never reuse another conversation's connection_id.";
23526
+ var GATEWAY_INSTRUCTIONS = `${GATEWAY_CONNECTING} ${GATEWAY_LISTENING}`;
23516
23527
 
23517
23528
  // ../connector-core/dist/control.js
23518
23529
  var MAX_FRAME_BYTES = 1 << 20;
23519
23530
 
23520
- // src/user-mcp.ts
23521
- import { existsSync, readFileSync } from "node:fs";
23531
+ // src/cli-record.ts
23532
+ var CLI_RECORD = "cli.json";
23533
+
23534
+ // src/desktop-config.ts
23535
+ import { existsSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
23522
23536
  import { homedir } from "node:os";
23523
23537
  import { join as join2 } from "node:path";
23538
+ var DESKTOP_SERVER = "cotal";
23539
+ function desktopConfigPath(platform = process.platform, env = process.env, home = homedir()) {
23540
+ if (platform === "darwin") return join2(home, "Library", "Application Support", "Claude", "claude_desktop_config.json");
23541
+ if (platform === "win32" && env.APPDATA) return join2(env.APPDATA, "Claude", "claude_desktop_config.json");
23542
+ return void 0;
23543
+ }
23544
+ function readConfig(path) {
23545
+ if (!existsSync(path)) return {};
23546
+ const text = readFileSync(path, "utf8");
23547
+ let parsed;
23548
+ try {
23549
+ parsed = text.trim() ? JSON.parse(text) : {};
23550
+ } catch {
23551
+ throw new Error(`${path} is not valid JSON, so Cotal left it alone. Fix it, then run \`cotal setup\` again.`);
23552
+ }
23553
+ const servers = parsed?.mcpServers;
23554
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || servers !== void 0 && (!servers || typeof servers !== "object" || Array.isArray(servers)))
23555
+ throw new Error(`${path} is not a Claude Desktop config (an object whose mcpServers is an object), so Cotal left it alone.`);
23556
+ return parsed;
23557
+ }
23558
+ function readDesktopEntry(path) {
23559
+ return readConfig(path).mcpServers?.[DESKTOP_SERVER];
23560
+ }
23561
+ function writeDesktopEntry(path, entry) {
23562
+ const config2 = readConfig(path);
23563
+ const before = config2.mcpServers?.[DESKTOP_SERVER];
23564
+ if (JSON.stringify(before) === JSON.stringify(entry)) return "current";
23565
+ config2.mcpServers = { ...config2.mcpServers, [DESKTOP_SERVER]: entry };
23566
+ const tmp = `${path}.cotal-${process.pid}`;
23567
+ writeFileSync(tmp, `${JSON.stringify(config2, null, 2)}
23568
+ `, { mode: existsSync(path) ? statSync(path).mode & 511 : 384 });
23569
+ renameSync(tmp, path);
23570
+ return before === void 0 ? "added" : "updated";
23571
+ }
23572
+
23573
+ // src/user-mcp.ts
23574
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
23575
+ import { homedir as homedir2 } from "node:os";
23576
+ import { join as join3 } from "node:path";
23524
23577
  import { mcpServerProblem } from "@cotal-ai/core";
23525
23578
  function claudeUserMcpServers() {
23526
- const path = join2(process.env.CLAUDE_CONFIG_DIR?.trim() || homedir(), ".claude.json");
23527
- if (!existsSync(path)) return {};
23579
+ const path = join3(process.env.CLAUDE_CONFIG_DIR?.trim() || homedir2(), ".claude.json");
23580
+ if (!existsSync2(path)) return {};
23528
23581
  let config2;
23529
23582
  try {
23530
- config2 = JSON.parse(readFileSync(path, "utf8"));
23583
+ config2 = JSON.parse(readFileSync2(path, "utf8"));
23531
23584
  } catch (e) {
23532
23585
  throw new Error(`${path}: invalid JSON - ${e.message}`);
23533
23586
  }
@@ -23540,91 +23593,130 @@ function claudeUserMcpEnvKeys() {
23540
23593
 
23541
23594
  // src/setup.ts
23542
23595
  var PACKAGE_ROOT = fileURLToPath(new URL("..", import.meta.url));
23596
+ var COTAL_ASSETS = [".claude-plugin", ".mcp.json", "hooks", "monitors", "dist/mcp.cjs", "dist/hook.cjs", "dist/monitor.cjs"];
23597
+ function pluginVersion(root, assets, files) {
23598
+ const hash2 = createHash2("sha256");
23599
+ const add = (path, bytes) => hash2.update(`${path}\0${bytes.length}\0`).update(bytes);
23600
+ const walk = (path) => {
23601
+ if (statSync2(path).isDirectory()) for (const entry of readdirSync(path).sort()) walk(join4(path, entry));
23602
+ else add(relative(root, path), readFileSync3(path));
23603
+ };
23604
+ for (const asset of [...assets].sort()) walk(join4(root, asset));
23605
+ for (const [path, text] of Object.entries(files).sort(([a], [b]) => a.localeCompare(b))) add(path, text);
23606
+ const release = JSON.parse(readFileSync3(join4(PACKAGE_ROOT, "package.json"), "utf8")).version;
23607
+ return `${release}+${hash2.digest("hex").slice(0, 12)}`;
23608
+ }
23609
+ function materializeCotal(cotal) {
23610
+ for (const asset of COTAL_ASSETS) if (!existsSync3(join4(PACKAGE_ROOT, asset))) throw new Error(`plugin asset missing: ${join4(PACKAGE_ROOT, asset)}`);
23611
+ const files = { [`dist/${CLI_RECORD}`]: `${JSON.stringify({ argv: cotal })}
23612
+ ` };
23613
+ const version2 = pluginVersion(PACKAGE_ROOT, COTAL_ASSETS, files);
23614
+ materialize("cotal", PACKAGE_ROOT, COTAL_ASSETS, version2, files);
23615
+ return version2;
23616
+ }
23617
+ function desktopEntry(cotal) {
23618
+ return {
23619
+ command: cotal[0],
23620
+ args: [join4(marketplaceDir(), "cotal", "dist", "mcp.cjs"), "--desktop"],
23621
+ ...process.env.COTAL_HOME ? { env: { COTAL_HOME: process.env.COTAL_HOME } } : {}
23622
+ };
23623
+ }
23624
+ function desktop(cotal, add) {
23625
+ const path = desktopConfigPath();
23626
+ if (!path || !existsSync3(dirname(path))) return void 0;
23627
+ if (!add && readDesktopEntry(path) === void 0) return void 0;
23628
+ const state = writeDesktopEntry(path, desktopEntry(cotal));
23629
+ return `Claude Desktop ${state}${state === "current" ? "" : "; quit and reopen Claude Desktop to load it"}`;
23630
+ }
23543
23631
  var DOCS_URL = "https://github.com/Cotal-AI/Cotal/blob/main/docs/connect-claude.md";
23544
23632
  var MARKETPLACE = "cotal-mesh";
23545
23633
  function cotalHome() {
23546
23634
  if (process.env.COTAL_HOME) return process.env.COTAL_HOME;
23547
- if (process.platform === "win32" && process.env.LOCALAPPDATA) return join3(process.env.LOCALAPPDATA, "Cotal");
23548
- return join3(homedir2(), ".cotal");
23635
+ if (process.platform === "win32" && process.env.LOCALAPPDATA) return join4(process.env.LOCALAPPDATA, "Cotal");
23636
+ return join4(homedir3(), ".cotal");
23549
23637
  }
23550
23638
  function marketplaceDir() {
23551
- return join3(cotalHome(), "claude-plugin");
23639
+ return join4(cotalHome(), "claude-plugin");
23552
23640
  }
23553
- function materialize(name, root, assets, version2) {
23641
+ function materialize(name, root, assets, version2, files = {}) {
23554
23642
  const market = marketplaceDir();
23555
23643
  mkdirSync(market, { recursive: true });
23556
- const dest = join3(market, name);
23644
+ const dest = join4(market, name);
23557
23645
  const staging = `${dest}.staging.${process.pid}`;
23558
23646
  const old = `${dest}.old.${process.pid}`;
23559
23647
  const orphans = readdirSync(market, { withFileTypes: true }).filter((entry) => entry.isDirectory() && (entry.name.startsWith(`${name}.old.`) || entry.name.startsWith(`${name}.staging.`))).map((entry) => entry.name);
23560
- if (!existsSync2(dest)) {
23648
+ if (!existsSync3(dest)) {
23561
23649
  const recoverable = orphans.find((entry) => entry.startsWith(`${name}.old.`));
23562
- if (recoverable) renameSync(join3(market, recoverable), dest);
23650
+ if (recoverable) renameSync2(join4(market, recoverable), dest);
23563
23651
  }
23564
- for (const entry of orphans) rmSync(join3(market, entry), { recursive: true, force: true });
23652
+ for (const entry of orphans) rmSync(join4(market, entry), { recursive: true, force: true });
23565
23653
  let movedAside = false;
23566
23654
  let swapped = false;
23567
23655
  try {
23568
23656
  mkdirSync(staging, { recursive: true });
23569
23657
  for (const asset of assets) {
23570
- const destination = join3(staging, asset);
23571
- mkdirSync(join3(destination, ".."), { recursive: true });
23572
- cpSync(join3(root, asset), destination, { recursive: true, dereference: true });
23658
+ const destination = join4(staging, asset);
23659
+ mkdirSync(join4(destination, ".."), { recursive: true });
23660
+ cpSync(join4(root, asset), destination, { recursive: true, dereference: true });
23573
23661
  }
23662
+ for (const [path, text] of Object.entries(files)) writeFileSync2(join4(staging, path), text);
23574
23663
  if (version2) {
23575
- const manifestPath = join3(staging, ".claude-plugin", "plugin.json");
23576
- const manifest = JSON.parse(readFileSync2(manifestPath, "utf8"));
23664
+ const manifestPath = join4(staging, ".claude-plugin", "plugin.json");
23665
+ const manifest = JSON.parse(readFileSync3(manifestPath, "utf8"));
23577
23666
  manifest.version = version2;
23578
- writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
23667
+ writeFileSync2(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
23579
23668
  }
23580
- if (existsSync2(dest)) {
23581
- renameSync(dest, old);
23669
+ if (existsSync3(dest)) {
23670
+ renameSync2(dest, old);
23582
23671
  movedAside = true;
23583
23672
  }
23584
- renameSync(staging, dest);
23673
+ renameSync2(staging, dest);
23585
23674
  swapped = true;
23586
23675
  if (movedAside) rmSync(old, { recursive: true, force: true });
23587
23676
  } catch (error51) {
23588
- if (movedAside && !swapped && !existsSync2(dest) && existsSync2(old)) renameSync(old, dest);
23677
+ if (movedAside && !swapped && !existsSync3(dest) && existsSync3(old)) renameSync2(old, dest);
23589
23678
  throw error51;
23590
23679
  } finally {
23591
23680
  rmSync(staging, { recursive: true, force: true });
23592
23681
  if (swapped) rmSync(old, { recursive: true, force: true });
23593
23682
  }
23594
23683
  }
23684
+ var CLAUDE_OUTPUT_LIMIT = 64 * 1024 * 1024;
23595
23685
  function command(...args) {
23596
- const result = spawnSync("claude", args, { encoding: "utf8" });
23686
+ return commandIn(process.cwd(), ...args);
23687
+ }
23688
+ function commandIn(cwd, ...args) {
23689
+ const result = spawnSync("claude", args, { cwd, encoding: "utf8", maxBuffer: CLAUDE_OUTPUT_LIMIT });
23690
+ if (result.error) return { status: null, output: result.error.message };
23597
23691
  return { status: result.status, output: `${result.stdout ?? ""}${result.stderr ?? ""}`.trim() };
23598
23692
  }
23599
23693
  function marketplaceEntry(market, name) {
23600
- const manifest = JSON.parse(readFileSync2(join3(market, name, ".claude-plugin", "plugin.json"), "utf8"));
23694
+ const manifest = JSON.parse(readFileSync3(join4(market, name, ".claude-plugin", "plugin.json"), "utf8"));
23601
23695
  const description = typeof manifest.description === "string" ? manifest.description : void 0;
23602
23696
  return { name, source: `./${name}`, ...description ? { description } : {} };
23603
23697
  }
23604
23698
  function marketplaceManifest(market) {
23605
- const plugins = ["cotal", "cotal-skills"].filter((name) => existsSync2(join3(market, name, ".claude-plugin", "plugin.json"))).map((name) => marketplaceEntry(market, name));
23699
+ const plugins = ["cotal", "cotal-skills"].filter((name) => existsSync3(join4(market, name, ".claude-plugin", "plugin.json"))).map((name) => marketplaceEntry(market, name));
23606
23700
  return { name: MARKETPLACE, description: "Cotal for Claude Code", owner: { name: "Cotal" }, plugins };
23607
23701
  }
23608
23702
  function writeMarketplaceManifest(market) {
23609
- const path = join3(market, ".claude-plugin", "marketplace.json");
23703
+ const path = join4(market, ".claude-plugin", "marketplace.json");
23610
23704
  mkdirSync(dirname(path), { recursive: true });
23611
- writeFileSync(path, JSON.stringify(marketplaceManifest(market), null, 2) + "\n");
23705
+ writeFileSync2(path, JSON.stringify(marketplaceManifest(market), null, 2) + "\n");
23612
23706
  return path;
23613
23707
  }
23614
23708
  function writeMarketplace() {
23615
23709
  const market = marketplaceDir();
23616
23710
  writeMarketplaceManifest(market);
23617
23711
  const add = command("plugin", "marketplace", "add", market);
23618
- if (add.status !== 0 && !/already (?:exists|added)/i.test(add.output)) throw new Error(`plugin marketplace add failed:
23712
+ if (add.status !== 0 && !/already (?:exists|added|on disk)/i.test(add.output)) throw new Error(`plugin marketplace add failed:
23619
23713
  ${add.output}`);
23620
- if (/already (?:exists|added)/i.test(add.output)) {
23621
- const update = command("plugin", "marketplace", "update", MARKETPLACE);
23622
- if (update.status !== 0) throw new Error(`plugin marketplace update failed:
23714
+ const update = command("plugin", "marketplace", "update", MARKETPLACE);
23715
+ if (update.status !== 0) throw new Error(`plugin marketplace update failed:
23623
23716
  ${update.output}`);
23624
- }
23625
23717
  }
23626
- function verify(name, scope, expectedVersion) {
23627
- const result = command("plugin", "list", "--json");
23718
+ function listPlugins(cwd = process.cwd()) {
23719
+ const result = commandIn(cwd, "plugin", "list", "--json");
23628
23720
  if (result.status !== 0) throw new Error(`plugin list failed:
23629
23721
  ${result.output}`);
23630
23722
  let entries;
@@ -23634,9 +23726,16 @@ ${result.output}`);
23634
23726
  throw new Error(`could not parse plugin list:
23635
23727
  ${result.output}`);
23636
23728
  }
23637
- const match = Array.isArray(entries) ? entries.find((entry) => entry && typeof entry === "object" && entry.id === `${name}@${MARKETPLACE}` && entry.scope === scope) : void 0;
23638
- if (!match || match.enabled !== true || match.errors?.length)
23639
- throw new Error(`plugin ${name}@${MARKETPLACE} (${scope} scope) did not load`);
23729
+ if (!Array.isArray(entries)) throw new Error(`could not parse plugin list:
23730
+ ${result.output}`);
23731
+ return entries;
23732
+ }
23733
+ function verify(name, scope, expectedVersion) {
23734
+ const match = listPlugins(cotalHome()).find((entry) => entry.id === `${name}@${MARKETPLACE}` && entry.scope === scope);
23735
+ const where = `${scope} scope`;
23736
+ if (!match) throw new Error(`plugin ${name}@${MARKETPLACE} (${where}) is not installed`);
23737
+ if (match.enabled !== true || match.errors?.length)
23738
+ throw new Error(`plugin ${name}@${MARKETPLACE} (${where}) did not load: ${JSON.stringify({ enabled: match.enabled, errors: match.errors })}`);
23640
23739
  if (expectedVersion && match.version !== expectedVersion)
23641
23740
  throw new Error(`plugin ${name}@${MARKETPLACE} loaded version ${String(match.version)}; expected ${expectedVersion}`);
23642
23741
  }
@@ -23652,9 +23751,26 @@ ${update.output}`);
23652
23751
  }
23653
23752
  verify(name, scope, expectedVersion);
23654
23753
  }
23754
+ function retireProjectInstalls() {
23755
+ let removed = 0;
23756
+ const failed = [];
23757
+ for (const entry of listPlugins()) {
23758
+ if (entry.id !== `cotal@${MARKETPLACE}` || entry.scope !== "local" || typeof entry.projectPath !== "string") continue;
23759
+ if (!statSync2(entry.projectPath, { throwIfNoEntry: false })?.isDirectory()) continue;
23760
+ const result = commandIn(entry.projectPath, "plugin", "uninstall", `cotal@${MARKETPLACE}`, "--scope", "local");
23761
+ if (result.status === 0) removed += 1;
23762
+ else failed.push(`${entry.projectPath}: ${result.output}`);
23763
+ }
23764
+ if (failed.length)
23765
+ throw new Error(
23766
+ `cotal@${MARKETPLACE} is installed at user scope, but ${failed.length} earlier per-project install${failed.length === 1 ? "" : "s"} could not be removed. In each directory, run \`claude plugin uninstall cotal@${MARKETPLACE} --scope local\`:
23767
+ ${failed.join("\n")}`
23768
+ );
23769
+ return removed;
23770
+ }
23655
23771
  function pluginList() {
23656
- const result = spawnSync("claude", ["plugin", "list", "--json"], { encoding: "utf8" });
23657
- if (result.status !== 0) return void 0;
23772
+ const result = spawnSync("claude", ["plugin", "list", "--json"], { encoding: "utf8", maxBuffer: CLAUDE_OUTPUT_LIMIT });
23773
+ if (result.error || result.status !== 0) return void 0;
23658
23774
  try {
23659
23775
  const parsed = JSON.parse(result.stdout || "[]");
23660
23776
  return Array.isArray(parsed) ? parsed : void 0;
@@ -23672,6 +23788,39 @@ function skillsRow(entries, { version: version2, skillsRemedy }) {
23672
23788
  if (match.version === version2) return row("ok", "current");
23673
23789
  return row("warn", `${typeof match.version === "string" ? `v${match.version} \u2260 v${version2} \xB7 ` : ""}stale \xB7 ${skillsRemedy}`);
23674
23790
  }
23791
+ function pluginRow(entries, { version: version2 }) {
23792
+ const row = (state, text) => ({ label: "Claude plugin", state, text });
23793
+ if (entries === void 0) return row("off", "unknown");
23794
+ const installs = entries.filter((entry) => entry.id === `cotal@${MARKETPLACE}`);
23795
+ if (!installs.length) return row("off", "not installed");
23796
+ if (installs.some((entry) => Array.isArray(entry.errors) ? entry.errors.length > 0 : Boolean(entry.errors ?? entry.error)))
23797
+ return row("error", "load error \xB7 run `cotal setup`");
23798
+ let materialized;
23799
+ try {
23800
+ materialized = JSON.parse(readFileSync3(join4(marketplaceDir(), "cotal", ".claude-plugin", "plugin.json"), "utf8")).version;
23801
+ } catch {
23802
+ materialized = void 0;
23803
+ }
23804
+ if (typeof materialized !== "string" || !materialized.startsWith(`${version2}+`)) return row("warn", "stale \xB7 run `cotal setup`");
23805
+ if (installs.some((entry) => entry.scope === "user")) return row("ok", "current (user scope)");
23806
+ return row("ok", `current (${installs.length} install${installs.length === 1 ? "" : "s"})`);
23807
+ }
23808
+ function desktopRow() {
23809
+ const path = desktopConfigPath();
23810
+ if (!path || !existsSync3(dirname(path))) return void 0;
23811
+ const row = (state, text) => ({ label: "Claude Desktop", state, text });
23812
+ let entry;
23813
+ try {
23814
+ entry = readDesktopEntry(path);
23815
+ } catch (e) {
23816
+ return row("error", e.message);
23817
+ }
23818
+ if (entry === void 0) return row("off", "not added \xB7 run `cotal setup`");
23819
+ const server = entry.args;
23820
+ const expected = join4(marketplaceDir(), "cotal", "dist", "mcp.cjs");
23821
+ if (!Array.isArray(server) || server[0] !== expected || !existsSync3(expected)) return row("warn", "stale \xB7 run `cotal setup`");
23822
+ return row("ok", "added");
23823
+ }
23675
23824
  function copyable(name, spec) {
23676
23825
  if (mcpServerProblem2(name, spec) !== void 0) return false;
23677
23826
  const { env, headers } = spec;
@@ -23685,14 +23834,36 @@ var claudeSetupProvider = {
23685
23834
  connector: {
23686
23835
  name: "claude-plugin",
23687
23836
  title: "Install the Claude Code plugin",
23688
- explain: "Lets a Claude Code session join the web and wake on peer messages.",
23837
+ explain: "Lets every Claude Code session on this machine join the web and wake on peer messages.",
23689
23838
  context: [DOCS_URL],
23690
- run() {
23691
- for (const asset of ["dist/mcp.cjs", "dist/hook.cjs", ".claude-plugin/plugin.json", ".mcp.json", "hooks/hooks.json"])
23692
- if (!existsSync2(join3(PACKAGE_ROOT, asset))) throw new Error(`plugin asset missing: ${join3(PACKAGE_ROOT, asset)}`);
23693
- materialize("cotal", PACKAGE_ROOT, [".claude-plugin", ".mcp.json", "hooks", "dist/mcp.cjs", "dist/hook.cjs"]);
23694
- install("cotal", "local");
23695
- return `cotal@${MARKETPLACE} (local scope)`;
23839
+ run({ cotal }) {
23840
+ materializeCotal(cotal);
23841
+ install("cotal", "user");
23842
+ const app = desktop(cotal, true);
23843
+ const removed = retireProjectInstalls();
23844
+ const replaced = removed ? `, replacing ${removed} project install${removed === 1 ? "" : "s"}` : "";
23845
+ return `cotal@${MARKETPLACE} (user scope${replaced})${app ? `; ${app}` : ""}`;
23846
+ }
23847
+ },
23848
+ refresh: {
23849
+ name: "claude-plugin-refresh",
23850
+ title: "Refresh the Claude Code plugin",
23851
+ explain: "Rewrites the copy of the Cotal plugin that Claude Code sessions load, and Cotal's entry in Claude Desktop, for this release.",
23852
+ context: [DOCS_URL],
23853
+ run({ cotal }) {
23854
+ const code = listPlugins().some((entry) => entry.id === `cotal@${MARKETPLACE}`);
23855
+ const path = desktopConfigPath();
23856
+ const app = path !== void 0 && readDesktopEntry(path) !== void 0;
23857
+ if (!code && !app) return "not installed";
23858
+ const version2 = materializeCotal(cotal);
23859
+ const parts = [];
23860
+ if (code) {
23861
+ writeMarketplace();
23862
+ parts.push(`cotal@${MARKETPLACE} ${version2}; each Claude Code session loads it when it starts`);
23863
+ }
23864
+ const desktopText = app ? desktop(cotal, false) : void 0;
23865
+ if (desktopText) parts.push(desktopText);
23866
+ return parts.join("; ");
23696
23867
  }
23697
23868
  },
23698
23869
  skills: {
@@ -23701,14 +23872,14 @@ var claudeSetupProvider = {
23701
23872
  explain: "Installs Cotal's authored skills as a Claude Code plugin.",
23702
23873
  context: [DOCS_URL],
23703
23874
  run({ skillsDir, version: version2, stateDir }) {
23704
- const manifestRoot = join3(PACKAGE_ROOT, "skills-plugin");
23705
- if (!existsSync2(join3(manifestRoot, ".claude-plugin", "plugin.json"))) throw new Error("Claude skills plugin manifest is missing");
23706
- const payload = join3(stateDir, `.claude-skills-payload.${process.pid}`);
23875
+ const manifestRoot = join4(PACKAGE_ROOT, "skills-plugin");
23876
+ if (!existsSync3(join4(manifestRoot, ".claude-plugin", "plugin.json"))) throw new Error("Claude skills plugin manifest is missing");
23877
+ const payload = join4(stateDir, `.claude-skills-payload.${process.pid}`);
23707
23878
  rmSync(payload, { recursive: true, force: true });
23708
23879
  try {
23709
23880
  mkdirSync(payload, { recursive: true });
23710
- cpSync(join3(manifestRoot, ".claude-plugin"), join3(payload, ".claude-plugin"), { recursive: true, dereference: true });
23711
- cpSync(skillsDir, join3(payload, "skills"), { recursive: true, dereference: true });
23881
+ cpSync(join4(manifestRoot, ".claude-plugin"), join4(payload, ".claude-plugin"), { recursive: true, dereference: true });
23882
+ cpSync(skillsDir, join4(payload, "skills"), { recursive: true, dereference: true });
23712
23883
  materialize("cotal-skills", payload, [".claude-plugin", "skills"], version2);
23713
23884
  install("cotal-skills", "user", version2);
23714
23885
  return `cotal-skills@${MARKETPLACE} (user scope)`;
@@ -23747,11 +23918,8 @@ var claudeSetupProvider = {
23747
23918
  },
23748
23919
  status(input) {
23749
23920
  const plugins = pluginList();
23750
- const plugin = plugins?.some((entry) => entry.id === `cotal@${MARKETPLACE}`) ?? false;
23751
- return [
23752
- { label: "Claude plugin", state: plugin ? "ok" : "off", text: plugin ? "installed" : "not installed" },
23753
- skillsRow(plugins, input)
23754
- ];
23921
+ const app = desktopRow();
23922
+ return [pluginRow(plugins, input), ...app ? [app] : [], skillsRow(plugins, input)];
23755
23923
  }
23756
23924
  };
23757
23925
  registry3.register(claudeSetupProvider);
@@ -23762,32 +23930,32 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
23762
23930
  import { loadAgentFile as loadAgentFile2, registry as registry4, writeLaunchArtifact } from "@cotal-ai/core";
23763
23931
 
23764
23932
  // src/carried.ts
23765
- import { createHash as createHash2 } from "node:crypto";
23933
+ import { createHash as createHash3 } from "node:crypto";
23766
23934
  import { execFileSync } from "node:child_process";
23767
- import { copyFileSync, lstatSync, mkdirSync as mkdirSync2, readdirSync as readdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
23768
- import { homedir as homedir3, hostname as hostname3 } from "node:os";
23769
- import { join as join4 } from "node:path";
23935
+ import { copyFileSync, lstatSync, mkdirSync as mkdirSync2, readdirSync as readdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
23936
+ import { homedir as homedir4, hostname as hostname3 } from "node:os";
23937
+ import { join as join5 } from "node:path";
23770
23938
  var SEAT_PROJECT = "seat";
23771
23939
  var FORK_RECORD = "cotal-fork.json";
23772
23940
  var MIN_VERSION = [2, 1, 234];
23773
23941
  var MAX_TITLE = 1024;
23774
23942
  function configDir(env) {
23775
- return env.CLAUDE_CONFIG_DIR || join4(env.HOME || homedir3(), ".claude");
23943
+ return env.CLAUDE_CONFIG_DIR || join5(env.HOME || homedir4(), ".claude");
23776
23944
  }
23777
23945
  function transcripts(env) {
23778
- const projects = join4(configDir(env), "projects");
23946
+ const projects = join5(configDir(env), "projects");
23779
23947
  let dirs;
23780
23948
  try {
23781
- dirs = readdirSync2(projects, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join4(projects, d.name));
23949
+ dirs = readdirSync2(projects, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join5(projects, d.name));
23782
23950
  } catch (e) {
23783
23951
  if (e.code === "ENOENT") return [];
23784
23952
  throw e;
23785
23953
  }
23786
- return dirs.flatMap((dir) => readdirSync2(dir, { withFileTypes: true }).filter((f) => f.isFile() && f.name.endsWith(".jsonl")).map((f) => join4(dir, f.name)));
23954
+ return dirs.flatMap((dir) => readdirSync2(dir, { withFileTypes: true }).filter((f) => f.isFile() && f.name.endsWith(".jsonl")).map((f) => join5(dir, f.name)));
23787
23955
  }
23788
23956
  function titleOf(path) {
23789
23957
  let title;
23790
- for (const line of readFileSync3(path, "utf8").split("\n")) {
23958
+ for (const line of readFileSync4(path, "utf8").split("\n")) {
23791
23959
  try {
23792
23960
  const entry = JSON.parse(line);
23793
23961
  if (entry.type === "custom-title" && typeof entry.customTitle === "string") title = entry.customTitle;
@@ -23797,7 +23965,7 @@ function titleOf(path) {
23797
23965
  return title;
23798
23966
  }
23799
23967
  function sha256(path) {
23800
- return createHash2("sha256").update(readFileSync3(path)).digest("hex");
23968
+ return createHash3("sha256").update(readFileSync4(path)).digest("hex");
23801
23969
  }
23802
23970
  var claudeResumeTranscript = {
23803
23971
  find(id, env) {
@@ -23840,14 +24008,14 @@ function refuseCarriedLaunch(binary, seatEnv) {
23840
24008
  );
23841
24009
  }
23842
24010
  function carriedForkRecord(home) {
23843
- return join4(home, FORK_RECORD);
24011
+ return join5(home, FORK_RECORD);
23844
24012
  }
23845
24013
  function placeCarried(home, transcript, resume, cwd) {
23846
- writeFileSync2(join4(home, ".claude.json"), JSON.stringify({ hasCompletedOnboarding: true, projects: { [cwd]: { hasTrustDialogAccepted: true } } }), { mode: 384 });
24014
+ writeFileSync3(join5(home, ".claude.json"), JSON.stringify({ hasCompletedOnboarding: true, projects: { [cwd]: { hasTrustDialogAccepted: true } } }), { mode: 384 });
23847
24015
  if (resume !== void 0) {
23848
- const dir = join4(home, "projects", SEAT_PROJECT);
24016
+ const dir = join5(home, "projects", SEAT_PROJECT);
23849
24017
  mkdirSync2(dir, { recursive: true, mode: 448 });
23850
- copyFileSync(transcript, join4(dir, `${resume}.jsonl`));
24018
+ copyFileSync(transcript, join5(dir, `${resume}.jsonl`));
23851
24019
  }
23852
24020
  return { CLAUDE_CONFIG_DIR: home, CLAUDE_CODE_PROJECT_DIR_NAME: SEAT_PROJECT, ...resume !== void 0 ? { COTAL_CLAUDE_CARRIED: resume } : {} };
23853
24021
  }