@cotal-ai/connector-claude-code 0.28.0 → 0.28.2

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.
package/dist/hook.cjs CHANGED
@@ -13605,11 +13605,11 @@ var require_connect = __commonJS({
13605
13605
  "../../node_modules/.pnpm/@nats-io+transport-node@3.4.0/node_modules/@nats-io/transport-node/lib/connect.js"(exports2) {
13606
13606
  "use strict";
13607
13607
  Object.defineProperty(exports2, "__esModule", { value: true });
13608
- exports2.connect = connect9;
13608
+ exports2.connect = connect8;
13609
13609
  var node_transport_1 = require_node_transport();
13610
13610
  var nats_base_client_1 = require_nats_base_client();
13611
13611
  var nats_base_client_2 = require_nats_base_client();
13612
- function connect9(opts = {}) {
13612
+ function connect8(opts = {}) {
13613
13613
  if ((0, nats_base_client_2.hasWsProtocol)(opts)) {
13614
13614
  return Promise.reject(nats_base_client_2.errors.InvalidArgumentError.format(`servers`, `node client doesn't support websockets, use the 'wsconnect' function instead`));
13615
13615
  }
@@ -26260,22 +26260,30 @@ var SYS_LIMITS = { ...BASE_LIMITS, mem_storage: 0, disk_storage: 0 };
26260
26260
  var import_nkeys4 = __toESM(require_mod2(), 1);
26261
26261
 
26262
26262
  // ../../packages/core/dist/channels.js
26263
- var import_kv4 = __toESM(require_mod6(), 1);
26264
- var import_transport_node13 = __toESM(require_transport_node(), 1);
26265
-
26266
- // ../../packages/core/dist/members.js
26267
- var import_kv5 = __toESM(require_mod6(), 1);
26263
+ var import_kv7 = __toESM(require_mod6(), 1);
26264
+ var import_transport_node15 = __toESM(require_transport_node(), 1);
26268
26265
 
26269
- // ../../packages/core/dist/membership-feed.js
26266
+ // ../../packages/core/dist/endpoint.js
26270
26267
  var import_transport_node14 = __toESM(require_transport_node(), 1);
26268
+ var import_nats_core = __toESM(require_mod3(), 1);
26269
+ var import_jetstream13 = __toESM(require_mod4(), 1);
26270
+ var import_jetstream14 = __toESM(require_mod4(), 1);
26271
26271
  var import_kv6 = __toESM(require_mod6(), 1);
26272
+ var import_internal2 = __toESM(require_internal_mod3(), 1);
26272
26273
 
26273
- // ../../packages/core/dist/evict.js
26274
- var import_transport_node15 = __toESM(require_transport_node(), 1);
26274
+ // ../../packages/core/dist/members.js
26275
+ var import_kv4 = __toESM(require_mod6(), 1);
26275
26276
 
26276
26277
  // ../../packages/core/dist/lease.js
26277
- var import_kv7 = __toESM(require_mod6(), 1);
26278
+ var import_kv5 = __toESM(require_mod6(), 1);
26279
+ var import_transport_node13 = __toESM(require_transport_node(), 1);
26280
+
26281
+ // ../../packages/core/dist/membership-feed.js
26278
26282
  var import_transport_node16 = __toESM(require_transport_node(), 1);
26283
+ var import_kv8 = __toESM(require_mod6(), 1);
26284
+
26285
+ // ../../packages/core/dist/evict.js
26286
+ var import_transport_node17 = __toESM(require_transport_node(), 1);
26279
26287
 
26280
26288
  // ../../packages/core/dist/agent-file.js
26281
26289
  var import_yaml = __toESM(require_dist(), 1);
@@ -26345,14 +26353,6 @@ function validate(raw, path) {
26345
26353
  return material;
26346
26354
  }
26347
26355
 
26348
- // ../../packages/core/dist/endpoint.js
26349
- var import_transport_node17 = __toESM(require_transport_node(), 1);
26350
- var import_nats_core = __toESM(require_mod3(), 1);
26351
- var import_jetstream13 = __toESM(require_mod4(), 1);
26352
- var import_jetstream14 = __toESM(require_mod4(), 1);
26353
- var import_kv8 = __toESM(require_mod6(), 1);
26354
- var import_internal2 = __toESM(require_internal_mod3(), 1);
26355
-
26356
26356
  // ../../packages/core/dist/spaces.js
26357
26357
  var import_transport_node18 = __toESM(require_transport_node(), 1);
26358
26358
  var import_jetstream15 = __toESM(require_mod4(), 1);
@@ -41153,7 +41153,7 @@ config(en_default());
41153
41153
 
41154
41154
  // ../connector-core/dist/docs-bundle.generated.js
41155
41155
  var DOCS_BUNDLE = {
41156
- "version": "0.28.0",
41156
+ "version": "0.28.2",
41157
41157
  "generatedFrom": "docs/*.md + SPEC.md + spec/cotal-lang.md + spec/cotal.schema.json",
41158
41158
  "pages": [
41159
41159
  {
package/dist/index.js CHANGED
@@ -14853,7 +14853,7 @@ import { isConcreteChannel as isConcreteChannel3, channelInAllow as channelInAll
14853
14853
 
14854
14854
  // ../connector-core/dist/docs-bundle.generated.js
14855
14855
  var DOCS_BUNDLE = {
14856
- "version": "0.28.0",
14856
+ "version": "0.28.2",
14857
14857
  "generatedFrom": "docs/*.md + SPEC.md + spec/cotal-lang.md + spec/cotal.schema.json",
14858
14858
  "pages": [
14859
14859
  {
package/dist/mcp.cjs CHANGED
@@ -20461,11 +20461,11 @@ var require_connect = __commonJS({
20461
20461
  "../../node_modules/.pnpm/@nats-io+transport-node@3.4.0/node_modules/@nats-io/transport-node/lib/connect.js"(exports2) {
20462
20462
  "use strict";
20463
20463
  Object.defineProperty(exports2, "__esModule", { value: true });
20464
- exports2.connect = connect8;
20464
+ exports2.connect = connect7;
20465
20465
  var node_transport_1 = require_node_transport();
20466
20466
  var nats_base_client_1 = require_nats_base_client();
20467
20467
  var nats_base_client_2 = require_nats_base_client();
20468
- function connect8(opts = {}) {
20468
+ function connect7(opts = {}) {
20469
20469
  if ((0, nats_base_client_2.hasWsProtocol)(opts)) {
20470
20470
  return Promise.reject(nats_base_client_2.errors.InvalidArgumentError.format(`servers`, `node client doesn't support websockets, use the 'wsconnect' function instead`));
20471
20471
  }
@@ -60478,49 +60478,33 @@ var SYS_LIMITS = { ...BASE_LIMITS, mem_storage: 0, disk_storage: 0 };
60478
60478
  var import_nkeys4 = __toESM(require_mod2(), 1);
60479
60479
 
60480
60480
  // ../../packages/core/dist/channels.js
60481
- var import_kv4 = __toESM(require_mod6(), 1);
60482
- var import_transport_node13 = __toESM(require_transport_node(), 1);
60483
- function parseDuration(s) {
60484
- const m = /^(\d+)(s|m|h|d)$/.exec(s.trim());
60485
- if (!m)
60486
- throw new Error(`invalid duration "${s}" - expected <number><s|m|h|d>, e.g. "24h"`);
60487
- const n = Number(m[1]);
60488
- const unit = { s: 1e3, m: 6e4, h: 36e5, d: 864e5 }[m[2]];
60489
- return n * unit;
60490
- }
60491
- function effectiveReplay(cfg, defaults) {
60492
- return cfg?.replay ?? defaults?.replay ?? true;
60493
- }
60494
- function effectiveReplayWindowMs(cfg, defaults) {
60495
- const w = cfg?.replayWindow ?? defaults?.replayWindow;
60496
- return w === void 0 ? void 0 : parseDuration(w);
60497
- }
60498
- function effectiveDeliveryClass(cfg, defaults) {
60499
- return cfg?.deliveryClass ?? defaults?.deliveryClass ?? "durable";
60500
- }
60501
- async function openChannelRegistry(nc, space, opts = {}) {
60502
- const kvm = new import_kv4.Kvm(nc);
60503
- return opts.create ? kvm.create(channelBucket(space)) : kvm.open(channelBucket(space));
60504
- }
60505
- async function readChannelConfig(kv, channel) {
60506
- return decode4(kv, channel);
60507
- }
60508
- async function readChannelDefaults(kv) {
60509
- return decode4(kv, CHANNEL_DEFAULTS_KEY);
60510
- }
60511
- async function decode4(kv, key) {
60512
- const e = await kv.get(key);
60513
- if (!e || e.operation === "DEL" || e.operation === "PURGE")
60514
- return void 0;
60515
- try {
60516
- return e.json();
60517
- } catch {
60518
- return void 0;
60519
- }
60481
+ var import_kv7 = __toESM(require_mod6(), 1);
60482
+ var import_transport_node15 = __toESM(require_transport_node(), 1);
60483
+
60484
+ // ../../packages/core/dist/endpoint.js
60485
+ var import_node_events = require("node:events");
60486
+ var import_node_crypto7 = require("node:crypto");
60487
+ var import_node_net = require("node:net");
60488
+ var import_transport_node14 = __toESM(require_transport_node(), 1);
60489
+ var import_nats_core = __toESM(require_mod3(), 1);
60490
+
60491
+ // ../../packages/core/dist/artifact.js
60492
+ var ARTIFACT_PART_KIND = "artifact";
60493
+ function isArtifactPart(value) {
60494
+ if (!value || typeof value !== "object")
60495
+ return false;
60496
+ const p = value;
60497
+ return p.kind === ARTIFACT_PART_KIND && typeof p.name === "string" && p.name.length > 0 && typeof p.mediaType === "string" && p.mediaType.length > 0 && typeof p.digest === "string" && isContractDigest(p.digest) && typeof p.size === "number" && Number.isSafeInteger(p.size) && p.size >= 0;
60520
60498
  }
60521
60499
 
60500
+ // ../../packages/core/dist/endpoint.js
60501
+ var import_jetstream13 = __toESM(require_mod4(), 1);
60502
+ var import_jetstream14 = __toESM(require_mod4(), 1);
60503
+ var import_kv6 = __toESM(require_mod6(), 1);
60504
+ var import_internal2 = __toESM(require_internal_mod3(), 1);
60505
+
60522
60506
  // ../../packages/core/dist/members.js
60523
- var import_kv5 = __toESM(require_mod6(), 1);
60507
+ var import_kv4 = __toESM(require_mod6(), 1);
60524
60508
  var StaleMembershipWrite = class extends Error {
60525
60509
  constructor(channel, owner, attempted, current) {
60526
60510
  super(`stale membership write for ${channel}/${owner}: generation ${attempted} < current ${current}`);
@@ -60528,7 +60512,7 @@ var StaleMembershipWrite = class extends Error {
60528
60512
  }
60529
60513
  };
60530
60514
  async function openMembersRegistry(nc, space, opts = {}) {
60531
- const kvm = new import_kv5.Kvm(nc);
60515
+ const kvm = new import_kv4.Kvm(nc);
60532
60516
  return opts.create ? kvm.create(membersBucket(space)) : kvm.open(membersBucket(space));
60533
60517
  }
60534
60518
  async function readMember(kv, channel, owner, lifecycleUid) {
@@ -60628,246 +60612,14 @@ function durableEligible(rec, seq) {
60628
60612
  return true;
60629
60613
  }
60630
60614
 
60631
- // ../../packages/core/dist/membership-feed.js
60632
- var import_transport_node14 = __toESM(require_transport_node(), 1);
60633
- var import_kv6 = __toESM(require_mod6(), 1);
60634
-
60635
- // ../../packages/core/dist/evict.js
60636
- var import_transport_node15 = __toESM(require_transport_node(), 1);
60637
-
60638
60615
  // ../../packages/core/dist/lease.js
60639
- var import_kv7 = __toESM(require_mod6(), 1);
60640
- var import_transport_node16 = __toESM(require_transport_node(), 1);
60616
+ var import_kv5 = __toESM(require_mod6(), 1);
60617
+ var import_transport_node13 = __toESM(require_transport_node(), 1);
60641
60618
  async function openDeliveryRegistry(nc, space) {
60642
- return new import_kv7.Kvm(nc).open(deliveryBucket(space));
60643
- }
60644
-
60645
- // ../../packages/core/dist/agent-file.js
60646
- var import_node_fs = require("node:fs");
60647
- var import_yaml = __toESM(require_dist2(), 1);
60648
- function parseFrontmatter(src, path) {
60649
- let doc;
60650
- try {
60651
- doc = (0, import_yaml.parse)(src);
60652
- } catch (e) {
60653
- throw new Error(`agent file ${path}: invalid YAML frontmatter; ${e.message}`);
60654
- }
60655
- if (doc === null || doc === void 0)
60656
- return {};
60657
- if (typeof doc !== "object" || Array.isArray(doc))
60658
- throw new Error(`agent file ${path}: frontmatter must be a YAML mapping (key: value pairs)`);
60659
- return doc;
60660
- }
60661
- function loadAgentFile(path) {
60662
- const src = (0, import_node_fs.readFileSync)(path, "utf8");
60663
- const m = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(src);
60664
- if (!m)
60665
- throw new Error(`agent file ${path}: missing "---" frontmatter block`);
60666
- const fm = parseFrontmatter(m[1], path);
60667
- const persona = m[2].trim();
60668
- const str2 = (k) => {
60669
- const v = fm[k];
60670
- if (v === void 0 || v === null)
60671
- return void 0;
60672
- if (typeof v === "object")
60673
- throw new Error(`agent file ${path}: "${k}" must be a scalar`);
60674
- return String(v);
60675
- };
60676
- const list = (k) => {
60677
- const v = fm[k];
60678
- if (v === void 0 || v === null)
60679
- return void 0;
60680
- return (Array.isArray(v) ? v : [v]).map((x) => {
60681
- if (x === null || typeof x === "object")
60682
- throw new Error(`agent file ${path}: "${k}" list items must be scalars`);
60683
- return String(x);
60684
- });
60685
- };
60686
- const name = str2("name");
60687
- if (!name)
60688
- throw new Error(`agent file ${path}: "name" is required`);
60689
- assertValidName(name);
60690
- const kind = str2("kind");
60691
- if (kind && kind !== "agent" && kind !== "endpoint")
60692
- throw new Error(`agent file ${path}: "kind" must be "agent" or "endpoint"`);
60693
- for (const old of ["channels", "publish"])
60694
- if (old in fm)
60695
- throw new Error(`agent file ${path}: "${old}" was renamed - use "subscribe"/"allowSubscribe" (read) and "allowPublish" (post)`);
60696
- const subscribe = list("subscribe");
60697
- const allowSubscribe = list("allowSubscribe");
60698
- const allowPublish = list("allowPublish");
60699
- const quiet = list("quiet");
60700
- const muted = list("muted");
60701
- for (const ch of [...subscribe ?? [], ...allowSubscribe ?? [], ...allowPublish ?? []])
60702
- try {
60703
- assertValidChannel(ch);
60704
- } catch (e) {
60705
- throw new Error(`agent file ${path}: ${e.message}`);
60706
- }
60707
- const effSubscribe = subscribe ?? [];
60708
- const effAllow = allowSubscribe?.length ? allowSubscribe : effSubscribe;
60709
- for (const ch of effSubscribe)
60710
- if (!channelInAllow(effAllow, ch))
60711
- throw new Error(`agent file ${path}: subscribe channel "${ch}" is not within allowSubscribe [${effAllow.join(", ")}]`);
60712
- const both = (quiet ?? []).filter((c) => (muted ?? []).includes(c));
60713
- if (both.length)
60714
- throw new Error(`agent file ${path}: channel(s) [${both.join(", ")}] are in both quiet and muted - pick one`);
60715
- for (const [field, chans] of [["quiet", quiet], ["muted", muted]])
60716
- for (const ch of chans ?? []) {
60717
- try {
60718
- assertValidChannel(ch);
60719
- } catch (e) {
60720
- throw new Error(`agent file ${path}: ${e.message}`);
60721
- }
60722
- if (!isConcreteChannel(ch))
60723
- throw new Error(`agent file ${path}: ${field} channel "${ch}" must be a concrete channel (no wildcard)`);
60724
- if (!channelInAllow(effAllow, ch))
60725
- throw new Error(`agent file ${path}: ${field} channel "${ch}" is not within your read ACL / allowSubscribe [${effAllow.join(", ")}]`);
60726
- }
60727
- const launchOptionsRaw = fm["launchOptions"];
60728
- let launchOptions;
60729
- if (launchOptionsRaw !== void 0 && launchOptionsRaw !== null) {
60730
- if (typeof launchOptionsRaw !== "object" || Array.isArray(launchOptionsRaw))
60731
- throw new Error(`agent file ${path}: "launchOptions" must be a mapping of key: value pairs`);
60732
- launchOptions = launchOptionsRaw;
60733
- }
60734
- const known = /* @__PURE__ */ new Set(["name", "role", "kind", "description", "tags", "subscribe", "allowSubscribe", "allowPublish", "quiet", "muted", "model", "variant", "launchOptions", "capabilities", "owner"]);
60735
- const meta3 = {};
60736
- for (const [k, v] of Object.entries(fm))
60737
- if (!known.has(k) && v !== null && typeof v !== "object")
60738
- meta3[k] = String(v);
60739
- return {
60740
- name,
60741
- role: str2("role"),
60742
- kind,
60743
- description: str2("description"),
60744
- tags: list("tags"),
60745
- subscribe,
60746
- allowSubscribe,
60747
- allowPublish,
60748
- quiet,
60749
- muted,
60750
- model: str2("model"),
60751
- variant: str2("variant"),
60752
- launchOptions,
60753
- capabilities: list("capabilities"),
60754
- owner: str2("owner"),
60755
- meta: Object.keys(meta3).length ? meta3 : void 0,
60756
- persona: persona || void 0
60757
- };
60758
- }
60759
-
60760
- // ../../packages/core/dist/fs-safe.js
60761
- var import_node_fs2 = require("node:fs");
60762
- var import_node_path = require("node:path");
60763
- function ensureDirNoSymlink(parent, ...segments) {
60764
- let dir = parent;
60765
- for (const seg of segments) {
60766
- dir = (0, import_node_path.join)(dir, seg);
60767
- let st;
60768
- try {
60769
- st = (0, import_node_fs2.lstatSync)(dir);
60770
- } catch (e) {
60771
- if (e.code === "ENOENT") {
60772
- (0, import_node_fs2.mkdirSync)(dir, { mode: 448 });
60773
- continue;
60774
- }
60775
- throw e;
60776
- }
60777
- if (st.isSymbolicLink())
60778
- throw new Error(`refusing to write under "${dir}": it is a symlink`);
60779
- if (!st.isDirectory())
60780
- throw new Error(`refusing to write under "${dir}": not a directory`);
60781
- }
60782
- return dir;
60783
- }
60784
-
60785
- // ../../packages/core/dist/secret-fs.js
60786
- var isWin = process.platform === "win32";
60787
-
60788
- // ../../packages/core/dist/launch-material.js
60789
- var import_node_fs3 = require("node:fs");
60790
- var LAUNCH_MATERIAL_ENV = "COTAL_LAUNCH_MATERIAL";
60791
- function readLaunchMaterial(path) {
60792
- let raw;
60793
- try {
60794
- if (process.platform !== "win32") {
60795
- const mode = (0, import_node_fs3.statSync)(path).mode & 511;
60796
- if (mode & 63)
60797
- throw new Error(`is readable beyond its owner (mode ${mode.toString(8)}) - refusing to read connection material out of a file other local users can open`);
60798
- }
60799
- raw = (0, import_node_fs3.readFileSync)(path, "utf8");
60800
- } catch (e) {
60801
- throw new Error(`launch material: cannot read ${path} (${e instanceof Error ? e.message : String(e)})`);
60802
- }
60803
- let parsed;
60804
- try {
60805
- parsed = JSON.parse(raw);
60806
- } catch {
60807
- throw new Error(`launch material: ${path} is not valid JSON`);
60808
- }
60809
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
60810
- throw new Error(`launch material: ${path} must contain a JSON object`);
60811
- return validate(parsed, path);
60812
- }
60813
- function validate(raw, path) {
60814
- const material = {};
60815
- const str2 = (key) => {
60816
- const v = raw[key];
60817
- if (v === void 0)
60818
- return;
60819
- if (typeof v !== "string" || !v.trim())
60820
- throw new Error(`launch material: ${path} has a ${key} that is not a non-empty string`);
60821
- material[key] = v;
60822
- };
60823
- str2("servers");
60824
- str2("creds");
60825
- str2("token");
60826
- str2("controlToken");
60827
- if (raw.userAuth !== void 0) {
60828
- const u = raw.userAuth;
60829
- if (typeof u !== "object" || u === null || Array.isArray(u))
60830
- throw new Error(`launch material: ${path} has a userAuth that is not an object`);
60831
- const { owner, actor, sentinelCredsPath, bearerCmd } = u;
60832
- const named = { owner, actor, sentinelCredsPath };
60833
- for (const [k, v] of Object.entries(named))
60834
- if (typeof v !== "string" || !v.trim())
60835
- throw new Error(`launch material: ${path} has a userAuth.${k} that is not a non-empty string`);
60836
- if (!Array.isArray(bearerCmd) || bearerCmd.length === 0 || !bearerCmd.every((a) => typeof a === "string" && a))
60837
- throw new Error(`launch material: ${path} has a userAuth.bearerCmd that is not a non-empty array of strings`);
60838
- material.userAuth = {
60839
- owner,
60840
- actor,
60841
- sentinelCredsPath,
60842
- bearerCmd
60843
- };
60844
- }
60845
- if (Object.keys(material).length === 0)
60846
- throw new Error(`launch material: ${path} carries nothing this reader recognises. A launch that references material and supplies none is a broken launcher, not an open-mode launch, so it is refused rather than defaulted.`);
60847
- return material;
60619
+ return new import_kv5.Kvm(nc).open(deliveryBucket(space));
60848
60620
  }
60849
60621
 
60850
60622
  // ../../packages/core/dist/endpoint.js
60851
- var import_node_events = require("node:events");
60852
- var import_node_crypto7 = require("node:crypto");
60853
- var import_node_net = require("node:net");
60854
- var import_transport_node17 = __toESM(require_transport_node(), 1);
60855
- var import_nats_core = __toESM(require_mod3(), 1);
60856
-
60857
- // ../../packages/core/dist/artifact.js
60858
- var ARTIFACT_PART_KIND = "artifact";
60859
- function isArtifactPart(value) {
60860
- if (!value || typeof value !== "object")
60861
- return false;
60862
- const p = value;
60863
- return p.kind === ARTIFACT_PART_KIND && typeof p.name === "string" && p.name.length > 0 && typeof p.mediaType === "string" && p.mediaType.length > 0 && typeof p.digest === "string" && isContractDigest(p.digest) && typeof p.size === "number" && Number.isSafeInteger(p.size) && p.size >= 0;
60864
- }
60865
-
60866
- // ../../packages/core/dist/endpoint.js
60867
- var import_jetstream13 = __toESM(require_mod4(), 1);
60868
- var import_jetstream14 = __toESM(require_mod4(), 1);
60869
- var import_kv8 = __toESM(require_mod6(), 1);
60870
- var import_internal2 = __toESM(require_internal_mod3(), 1);
60871
60623
  var DEFAULT_SERVER = "nats://127.0.0.1:4222";
60872
60624
  var PLANE3_FRAME_HEADER = "Cotal-Delivery-Frame";
60873
60625
  var READER_MAX_REDELIVERIES = 10;
@@ -61381,7 +61133,7 @@ var CotalEndpoint = class _CotalEndpoint extends import_node_events.EventEmitter
61381
61133
  this.watchStatus();
61382
61134
  this.js = (0, import_jetstream13.jetstream)(this.nc);
61383
61135
  if (this.doWatch || this.doRegister) {
61384
- const kvm = new import_kv8.Kvm(this.nc);
61136
+ const kvm = new import_kv6.Kvm(this.nc);
61385
61137
  this.kv = this.authed ? await kvm.open(presenceBucket(this.space)) : await kvm.create(presenceBucket(this.space), { ttl: this.ttlMs });
61386
61138
  }
61387
61139
  if (this.doWatch) {
@@ -61763,7 +61515,7 @@ var CotalEndpoint = class _CotalEndpoint extends import_node_events.EventEmitter
61763
61515
  throw new Error(`expectedLastSubjectSeq must be a non-negative safe integer, got ${JSON.stringify(opts.expectedLastSubjectSeq)}`);
61764
61516
  if (!Array.isArray(opts.parts) || opts.parts.length === 0)
61765
61517
  throw new Error("encodedSize requires at least one part");
61766
- const mh = (0, import_transport_node17.headers)();
61518
+ const mh = (0, import_transport_node14.headers)();
61767
61519
  mh.set("Nats-Msg-Id", opts.id);
61768
61520
  mh.set("Nats-Expected-Last-Subject-Sequence", `${opts.expectedLastSubjectSeq}`);
61769
61521
  const headerBytes = mh.encode().length;
@@ -62269,7 +62021,7 @@ var CotalEndpoint = class _CotalEndpoint extends import_node_events.EventEmitter
62269
62021
  async membershipFeedRegistry() {
62270
62022
  if (!this.nc)
62271
62023
  throw new Error("endpoint not started");
62272
- this.membershipFeedKv ??= await new import_kv8.Kvm(this.nc).open(membershipBucket(this.space));
62024
+ this.membershipFeedKv ??= await new import_kv6.Kvm(this.nc).open(membershipBucket(this.space));
62273
62025
  return this.membershipFeedKv;
62274
62026
  }
62275
62027
  /**
@@ -62635,7 +62387,7 @@ var CotalEndpoint = class _CotalEndpoint extends import_node_events.EventEmitter
62635
62387
  for await (const s of this.nc.status()) {
62636
62388
  if (s.type !== "error")
62637
62389
  continue;
62638
- if (s.error instanceof import_transport_node17.PermissionViolationError && this.confirmingChatSubs.has(s.error.subject))
62390
+ if (s.error instanceof import_transport_node14.PermissionViolationError && this.confirmingChatSubs.has(s.error.subject))
62639
62391
  continue;
62640
62392
  this.emit("error", describeStatusError(s.error));
62641
62393
  }
@@ -62858,7 +62610,7 @@ var CotalEndpoint = class _CotalEndpoint extends import_node_events.EventEmitter
62858
62610
  throw new Error("endpoint not started");
62859
62611
  if (this.managerLeaseKv)
62860
62612
  return this.managerLeaseKv;
62861
- const kvm = new import_kv8.Kvm((0, import_jetstream13.jetstream)(this.nc, { timeout: MANAGER_LEASE_ATTEMPT_MS }));
62613
+ const kvm = new import_kv6.Kvm((0, import_jetstream13.jetstream)(this.nc, { timeout: MANAGER_LEASE_ATTEMPT_MS }));
62862
62614
  if (this.authed) {
62863
62615
  this.managerLeaseKv = await kvm.open(managerBucket(this.space));
62864
62616
  } else {
@@ -63088,7 +62840,7 @@ var CotalEndpoint = class _CotalEndpoint extends import_node_events.EventEmitter
63088
62840
  filter_subject: subject,
63089
62841
  ack_policy: import_jetstream13.AckPolicy.None,
63090
62842
  mem_storage: true,
63091
- inactive_threshold: (0, import_transport_node17.nanos)(3e4),
62843
+ inactive_threshold: (0, import_transport_node14.nanos)(3e4),
63092
62844
  deliver_policy: import_jetstream13.DeliverPolicy.StartSequence,
63093
62845
  opt_start_seq: fromSeqExcl + 1
63094
62846
  });
@@ -63550,7 +63302,7 @@ var CotalEndpoint = class _CotalEndpoint extends import_node_events.EventEmitter
63550
63302
  channel: entry.channel,
63551
63303
  msg: authenticatedChannelMessage(entry.msg, entry.channel)
63552
63304
  };
63553
- const frameHeaders = (0, import_transport_node17.headers)();
63305
+ const frameHeaders = (0, import_transport_node14.headers)();
63554
63306
  frameHeaders.set(PLANE3_FRAME_HEADER, "1");
63555
63307
  await this.js.publish(dlvSubject(this.space, pr.owner, pr.actor, pr.lifecycleUid), JSON.stringify(frame), {
63556
63308
  msgID: `${entry.msg.id}:${owner}:${pr.lifecycleUid}:${entry.generation}`,
@@ -63680,7 +63432,7 @@ var CotalEndpoint = class _CotalEndpoint extends import_node_events.EventEmitter
63680
63432
  * distinct from a responder that errored. nats.js surfaces it as NoRespondersError, or a RequestError
63681
63433
  * whose `isNoResponders()` is true. */
63682
63434
  isNoResponders(e) {
63683
- return e instanceof import_transport_node17.NoRespondersError || e instanceof import_transport_node17.RequestError && e.isNoResponders();
63435
+ return e instanceof import_transport_node14.NoRespondersError || e instanceof import_transport_node14.RequestError && e.isNoResponders();
63684
63436
  }
63685
63437
  /** Agent-side: this session's CURRENT durable memberships (channel + join generation) from the
63686
63438
  * manager — the agent holds no read on the privileged members KV. `undefined` ⇒ NO control responder
@@ -64023,7 +63775,7 @@ var CotalEndpoint = class _CotalEndpoint extends import_node_events.EventEmitter
64023
63775
  filter_subject: subject,
64024
63776
  ack_policy: import_jetstream13.AckPolicy.None,
64025
63777
  mem_storage: true,
64026
- inactive_threshold: (0, import_transport_node17.nanos)(3e4),
63778
+ inactive_threshold: (0, import_transport_node14.nanos)(3e4),
64027
63779
  ..."time" in start ? { deliver_policy: import_jetstream13.DeliverPolicy.StartTime, opt_start_time: start.time.toISOString() } : { deliver_policy: import_jetstream13.DeliverPolicy.StartSequence, opt_start_seq: start.seq }
64028
63780
  });
64029
63781
  try {
@@ -64384,7 +64136,7 @@ function authOpts(a) {
64384
64136
  if (!a.sentinelCreds)
64385
64137
  throw new Error("user-mode bearer requires sentinelCreds");
64386
64138
  return {
64387
- authenticator: [(0, import_transport_node17.credsAuthenticator)(new TextEncoder().encode(a.sentinelCreds)), (0, import_transport_node17.tokenAuthenticator)(a.bearer)],
64139
+ authenticator: [(0, import_transport_node14.credsAuthenticator)(new TextEncoder().encode(a.sentinelCreds)), (0, import_transport_node14.tokenAuthenticator)(a.bearer)],
64388
64140
  tls
64389
64141
  };
64390
64142
  }
@@ -64392,7 +64144,7 @@ function authOpts(a) {
64392
64144
  if (a.token || a.user || a.pass)
64393
64145
  throw new Error("creds are mutually exclusive with token/user/pass auth");
64394
64146
  const creds = a.creds;
64395
- const authenticator = typeof creds === "function" ? (nonce3) => (0, import_transport_node17.credsAuthenticator)(new TextEncoder().encode(creds()))(nonce3) : (0, import_transport_node17.credsAuthenticator)(new TextEncoder().encode(creds));
64147
+ const authenticator = typeof creds === "function" ? (nonce3) => (0, import_transport_node14.credsAuthenticator)(new TextEncoder().encode(creds()))(nonce3) : (0, import_transport_node14.credsAuthenticator)(new TextEncoder().encode(creds));
64396
64148
  return { authenticator, tls };
64397
64149
  }
64398
64150
  return { token: a.token, user: a.user, pass: a.pass, tls };
@@ -64427,25 +64179,32 @@ function decodeBearerPrincipal(bearer) {
64427
64179
  return { owner, actor };
64428
64180
  }
64429
64181
  function describeStatusError(err2) {
64430
- if (err2 instanceof import_transport_node17.PermissionViolationError) {
64182
+ if (err2 instanceof import_transport_node14.PermissionViolationError) {
64431
64183
  return new Error(`NATS permission denied: cannot ${err2.operation} "${err2.subject}" - check this endpoint's ACLs (a denied peer looks "absent" rather than blocked)`, { cause: err2 });
64432
64184
  }
64433
64185
  return err2;
64434
64186
  }
64435
64187
  function isPermissionDenied(e) {
64436
- if (e instanceof import_transport_node17.PermissionViolationError)
64188
+ if (e instanceof import_transport_node14.PermissionViolationError)
64437
64189
  return true;
64438
- if (e?.cause instanceof import_transport_node17.PermissionViolationError)
64190
+ if (e?.cause instanceof import_transport_node14.PermissionViolationError)
64439
64191
  return true;
64440
64192
  return /permissions?\s+violation/i.test(String(e?.message ?? ""));
64441
64193
  }
64442
64194
  function isPublishPermissionDenied(e) {
64443
- const typed = e instanceof import_transport_node17.PermissionViolationError ? e : e?.cause instanceof import_transport_node17.PermissionViolationError ? e.cause : void 0;
64195
+ const typed = e instanceof import_transport_node14.PermissionViolationError ? e : e?.cause instanceof import_transport_node14.PermissionViolationError ? e.cause : void 0;
64444
64196
  return typed?.operation === "publish";
64445
64197
  }
64198
+ function wsServers(servers) {
64199
+ return /^wss?:\/\//i.test((servers.split(",")[0] ?? "").trim());
64200
+ }
64446
64201
  function dialerFor(servers) {
64447
- const first = (servers.split(",")[0] ?? "").trim();
64448
- return /^wss?:\/\//i.test(first) ? import_nats_core.wsconnect : import_transport_node17.connect;
64202
+ if (!wsServers(servers))
64203
+ return import_transport_node14.connect;
64204
+ return ((opts) => {
64205
+ const { tls: _tls, ...rest } = opts ?? {};
64206
+ return (0, import_nats_core.wsconnect)(rest);
64207
+ });
64449
64208
  }
64450
64209
  function hostPort(server) {
64451
64210
  const raw = (server.split(",")[0] ?? "").trim();
@@ -64510,13 +64269,265 @@ function classifyProbeFailure(e, opts) {
64510
64269
  } catch {
64511
64270
  }
64512
64271
  }
64513
- if (e instanceof import_transport_node17.UserAuthenticationExpiredError)
64272
+ if (e instanceof import_transport_node14.UserAuthenticationExpiredError)
64514
64273
  return { ok: false, reason: "stale-auth" };
64515
- if (e instanceof import_transport_node17.AuthorizationError)
64274
+ if (e instanceof import_transport_node14.AuthorizationError)
64516
64275
  return { ok: false, reason: "auth-required" };
64517
64276
  return { ok: false, reason: "unreachable" };
64518
64277
  }
64519
64278
 
64279
+ // ../../packages/core/dist/channels.js
64280
+ function parseDuration(s) {
64281
+ const m = /^(\d+)(s|m|h|d)$/.exec(s.trim());
64282
+ if (!m)
64283
+ throw new Error(`invalid duration "${s}" - expected <number><s|m|h|d>, e.g. "24h"`);
64284
+ const n = Number(m[1]);
64285
+ const unit = { s: 1e3, m: 6e4, h: 36e5, d: 864e5 }[m[2]];
64286
+ return n * unit;
64287
+ }
64288
+ function effectiveReplay(cfg, defaults) {
64289
+ return cfg?.replay ?? defaults?.replay ?? true;
64290
+ }
64291
+ function effectiveReplayWindowMs(cfg, defaults) {
64292
+ const w = cfg?.replayWindow ?? defaults?.replayWindow;
64293
+ return w === void 0 ? void 0 : parseDuration(w);
64294
+ }
64295
+ function effectiveDeliveryClass(cfg, defaults) {
64296
+ return cfg?.deliveryClass ?? defaults?.deliveryClass ?? "durable";
64297
+ }
64298
+ async function openChannelRegistry(nc, space, opts = {}) {
64299
+ const kvm = new import_kv7.Kvm(nc);
64300
+ return opts.create ? kvm.create(channelBucket(space)) : kvm.open(channelBucket(space));
64301
+ }
64302
+ async function readChannelConfig(kv, channel) {
64303
+ return decode4(kv, channel);
64304
+ }
64305
+ async function readChannelDefaults(kv) {
64306
+ return decode4(kv, CHANNEL_DEFAULTS_KEY);
64307
+ }
64308
+ async function decode4(kv, key) {
64309
+ const e = await kv.get(key);
64310
+ if (!e || e.operation === "DEL" || e.operation === "PURGE")
64311
+ return void 0;
64312
+ try {
64313
+ return e.json();
64314
+ } catch {
64315
+ return void 0;
64316
+ }
64317
+ }
64318
+
64319
+ // ../../packages/core/dist/membership-feed.js
64320
+ var import_transport_node16 = __toESM(require_transport_node(), 1);
64321
+ var import_kv8 = __toESM(require_mod6(), 1);
64322
+
64323
+ // ../../packages/core/dist/evict.js
64324
+ var import_transport_node17 = __toESM(require_transport_node(), 1);
64325
+
64326
+ // ../../packages/core/dist/agent-file.js
64327
+ var import_node_fs = require("node:fs");
64328
+ var import_yaml = __toESM(require_dist2(), 1);
64329
+ function parseFrontmatter(src, path) {
64330
+ let doc;
64331
+ try {
64332
+ doc = (0, import_yaml.parse)(src);
64333
+ } catch (e) {
64334
+ throw new Error(`agent file ${path}: invalid YAML frontmatter; ${e.message}`);
64335
+ }
64336
+ if (doc === null || doc === void 0)
64337
+ return {};
64338
+ if (typeof doc !== "object" || Array.isArray(doc))
64339
+ throw new Error(`agent file ${path}: frontmatter must be a YAML mapping (key: value pairs)`);
64340
+ return doc;
64341
+ }
64342
+ function loadAgentFile(path) {
64343
+ const src = (0, import_node_fs.readFileSync)(path, "utf8");
64344
+ const m = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(src);
64345
+ if (!m)
64346
+ throw new Error(`agent file ${path}: missing "---" frontmatter block`);
64347
+ const fm = parseFrontmatter(m[1], path);
64348
+ const persona = m[2].trim();
64349
+ const str2 = (k) => {
64350
+ const v = fm[k];
64351
+ if (v === void 0 || v === null)
64352
+ return void 0;
64353
+ if (typeof v === "object")
64354
+ throw new Error(`agent file ${path}: "${k}" must be a scalar`);
64355
+ return String(v);
64356
+ };
64357
+ const list = (k) => {
64358
+ const v = fm[k];
64359
+ if (v === void 0 || v === null)
64360
+ return void 0;
64361
+ return (Array.isArray(v) ? v : [v]).map((x) => {
64362
+ if (x === null || typeof x === "object")
64363
+ throw new Error(`agent file ${path}: "${k}" list items must be scalars`);
64364
+ return String(x);
64365
+ });
64366
+ };
64367
+ const name = str2("name");
64368
+ if (!name)
64369
+ throw new Error(`agent file ${path}: "name" is required`);
64370
+ assertValidName(name);
64371
+ const kind = str2("kind");
64372
+ if (kind && kind !== "agent" && kind !== "endpoint")
64373
+ throw new Error(`agent file ${path}: "kind" must be "agent" or "endpoint"`);
64374
+ for (const old of ["channels", "publish"])
64375
+ if (old in fm)
64376
+ throw new Error(`agent file ${path}: "${old}" was renamed - use "subscribe"/"allowSubscribe" (read) and "allowPublish" (post)`);
64377
+ const subscribe = list("subscribe");
64378
+ const allowSubscribe = list("allowSubscribe");
64379
+ const allowPublish = list("allowPublish");
64380
+ const quiet = list("quiet");
64381
+ const muted = list("muted");
64382
+ for (const ch of [...subscribe ?? [], ...allowSubscribe ?? [], ...allowPublish ?? []])
64383
+ try {
64384
+ assertValidChannel(ch);
64385
+ } catch (e) {
64386
+ throw new Error(`agent file ${path}: ${e.message}`);
64387
+ }
64388
+ const effSubscribe = subscribe ?? [];
64389
+ const effAllow = allowSubscribe?.length ? allowSubscribe : effSubscribe;
64390
+ for (const ch of effSubscribe)
64391
+ if (!channelInAllow(effAllow, ch))
64392
+ throw new Error(`agent file ${path}: subscribe channel "${ch}" is not within allowSubscribe [${effAllow.join(", ")}]`);
64393
+ const both = (quiet ?? []).filter((c) => (muted ?? []).includes(c));
64394
+ if (both.length)
64395
+ throw new Error(`agent file ${path}: channel(s) [${both.join(", ")}] are in both quiet and muted - pick one`);
64396
+ for (const [field, chans] of [["quiet", quiet], ["muted", muted]])
64397
+ for (const ch of chans ?? []) {
64398
+ try {
64399
+ assertValidChannel(ch);
64400
+ } catch (e) {
64401
+ throw new Error(`agent file ${path}: ${e.message}`);
64402
+ }
64403
+ if (!isConcreteChannel(ch))
64404
+ throw new Error(`agent file ${path}: ${field} channel "${ch}" must be a concrete channel (no wildcard)`);
64405
+ if (!channelInAllow(effAllow, ch))
64406
+ throw new Error(`agent file ${path}: ${field} channel "${ch}" is not within your read ACL / allowSubscribe [${effAllow.join(", ")}]`);
64407
+ }
64408
+ const launchOptionsRaw = fm["launchOptions"];
64409
+ let launchOptions;
64410
+ if (launchOptionsRaw !== void 0 && launchOptionsRaw !== null) {
64411
+ if (typeof launchOptionsRaw !== "object" || Array.isArray(launchOptionsRaw))
64412
+ throw new Error(`agent file ${path}: "launchOptions" must be a mapping of key: value pairs`);
64413
+ launchOptions = launchOptionsRaw;
64414
+ }
64415
+ const known = /* @__PURE__ */ new Set(["name", "role", "kind", "description", "tags", "subscribe", "allowSubscribe", "allowPublish", "quiet", "muted", "model", "variant", "launchOptions", "capabilities", "owner"]);
64416
+ const meta3 = {};
64417
+ for (const [k, v] of Object.entries(fm))
64418
+ if (!known.has(k) && v !== null && typeof v !== "object")
64419
+ meta3[k] = String(v);
64420
+ return {
64421
+ name,
64422
+ role: str2("role"),
64423
+ kind,
64424
+ description: str2("description"),
64425
+ tags: list("tags"),
64426
+ subscribe,
64427
+ allowSubscribe,
64428
+ allowPublish,
64429
+ quiet,
64430
+ muted,
64431
+ model: str2("model"),
64432
+ variant: str2("variant"),
64433
+ launchOptions,
64434
+ capabilities: list("capabilities"),
64435
+ owner: str2("owner"),
64436
+ meta: Object.keys(meta3).length ? meta3 : void 0,
64437
+ persona: persona || void 0
64438
+ };
64439
+ }
64440
+
64441
+ // ../../packages/core/dist/fs-safe.js
64442
+ var import_node_fs2 = require("node:fs");
64443
+ var import_node_path = require("node:path");
64444
+ function ensureDirNoSymlink(parent, ...segments) {
64445
+ let dir = parent;
64446
+ for (const seg of segments) {
64447
+ dir = (0, import_node_path.join)(dir, seg);
64448
+ let st;
64449
+ try {
64450
+ st = (0, import_node_fs2.lstatSync)(dir);
64451
+ } catch (e) {
64452
+ if (e.code === "ENOENT") {
64453
+ (0, import_node_fs2.mkdirSync)(dir, { mode: 448 });
64454
+ continue;
64455
+ }
64456
+ throw e;
64457
+ }
64458
+ if (st.isSymbolicLink())
64459
+ throw new Error(`refusing to write under "${dir}": it is a symlink`);
64460
+ if (!st.isDirectory())
64461
+ throw new Error(`refusing to write under "${dir}": not a directory`);
64462
+ }
64463
+ return dir;
64464
+ }
64465
+
64466
+ // ../../packages/core/dist/secret-fs.js
64467
+ var isWin = process.platform === "win32";
64468
+
64469
+ // ../../packages/core/dist/launch-material.js
64470
+ var import_node_fs3 = require("node:fs");
64471
+ var LAUNCH_MATERIAL_ENV = "COTAL_LAUNCH_MATERIAL";
64472
+ function readLaunchMaterial(path) {
64473
+ let raw;
64474
+ try {
64475
+ if (process.platform !== "win32") {
64476
+ const mode = (0, import_node_fs3.statSync)(path).mode & 511;
64477
+ if (mode & 63)
64478
+ throw new Error(`is readable beyond its owner (mode ${mode.toString(8)}) - refusing to read connection material out of a file other local users can open`);
64479
+ }
64480
+ raw = (0, import_node_fs3.readFileSync)(path, "utf8");
64481
+ } catch (e) {
64482
+ throw new Error(`launch material: cannot read ${path} (${e instanceof Error ? e.message : String(e)})`);
64483
+ }
64484
+ let parsed;
64485
+ try {
64486
+ parsed = JSON.parse(raw);
64487
+ } catch {
64488
+ throw new Error(`launch material: ${path} is not valid JSON`);
64489
+ }
64490
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
64491
+ throw new Error(`launch material: ${path} must contain a JSON object`);
64492
+ return validate(parsed, path);
64493
+ }
64494
+ function validate(raw, path) {
64495
+ const material = {};
64496
+ const str2 = (key) => {
64497
+ const v = raw[key];
64498
+ if (v === void 0)
64499
+ return;
64500
+ if (typeof v !== "string" || !v.trim())
64501
+ throw new Error(`launch material: ${path} has a ${key} that is not a non-empty string`);
64502
+ material[key] = v;
64503
+ };
64504
+ str2("servers");
64505
+ str2("creds");
64506
+ str2("token");
64507
+ str2("controlToken");
64508
+ if (raw.userAuth !== void 0) {
64509
+ const u = raw.userAuth;
64510
+ if (typeof u !== "object" || u === null || Array.isArray(u))
64511
+ throw new Error(`launch material: ${path} has a userAuth that is not an object`);
64512
+ const { owner, actor, sentinelCredsPath, bearerCmd } = u;
64513
+ const named = { owner, actor, sentinelCredsPath };
64514
+ for (const [k, v] of Object.entries(named))
64515
+ if (typeof v !== "string" || !v.trim())
64516
+ throw new Error(`launch material: ${path} has a userAuth.${k} that is not a non-empty string`);
64517
+ if (!Array.isArray(bearerCmd) || bearerCmd.length === 0 || !bearerCmd.every((a) => typeof a === "string" && a))
64518
+ throw new Error(`launch material: ${path} has a userAuth.bearerCmd that is not a non-empty array of strings`);
64519
+ material.userAuth = {
64520
+ owner,
64521
+ actor,
64522
+ sentinelCredsPath,
64523
+ bearerCmd
64524
+ };
64525
+ }
64526
+ if (Object.keys(material).length === 0)
64527
+ throw new Error(`launch material: ${path} carries nothing this reader recognises. A launch that references material and supplies none is a broken launcher, not an open-mode launch, so it is refused rather than defaulted.`);
64528
+ return material;
64529
+ }
64530
+
64520
64531
  // ../../packages/core/dist/spaces.js
64521
64532
  var import_transport_node18 = __toESM(require_transport_node(), 1);
64522
64533
  var import_jetstream15 = __toESM(require_mod4(), 1);
@@ -67837,7 +67848,7 @@ var import_node_child_process2 = require("node:child_process");
67837
67848
 
67838
67849
  // ../connector-core/dist/docs-bundle.generated.js
67839
67850
  var DOCS_BUNDLE = {
67840
- "version": "0.28.0",
67851
+ "version": "0.28.2",
67841
67852
  "generatedFrom": "docs/*.md + SPEC.md + spec/cotal-lang.md + spec/cotal.schema.json",
67842
67853
  "pages": [
67843
67854
  {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cotal-ai/connector-claude-code",
3
3
  "description": "Cotal connector for Claude Code: an installed plugin that joins a session to the mesh.",
4
- "version": "0.28.0",
4
+ "version": "0.28.2",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -24,9 +24,9 @@
24
24
  "@modelcontextprotocol/sdk": "^1.29.0",
25
25
  "esbuild": "^0.28.0",
26
26
  "tsx": "^4.22.4",
27
- "@cotal-ai/connector-core": "0.28.0",
28
- "@cotal-ai/core": "0.28.0",
29
- "@cotal-ai/smoke-kit": "0.0.0"
27
+ "@cotal-ai/connector-core": "0.28.2",
28
+ "@cotal-ai/smoke-kit": "0.0.0",
29
+ "@cotal-ai/core": "0.28.2"
30
30
  },
31
31
  "files": [
32
32
  "dist",