@cotal-ai/core 0.115.0 → 0.115.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/endpoint.js CHANGED
@@ -2159,7 +2159,7 @@ export class CotalEndpoint extends EventEmitter {
2159
2159
  * other requests. */
2160
2160
  serveControl(service, handler, opts = {}) {
2161
2161
  if (!this.nc)
2162
- throw new Error("endpoint not started");
2162
+ throw new Error(this.notLiveMsg());
2163
2163
  const sub = this.nc.subscribe(controlServiceSubject(this.space, service, "*", "*"), {
2164
2164
  queue: service,
2165
2165
  });
@@ -3001,7 +3001,7 @@ export class CotalEndpoint extends EventEmitter {
3001
3001
  * two names look alike, so this one is explicitly "feed". Read-only here; agents hold no grant. */
3002
3002
  async membershipFeedRegistry() {
3003
3003
  if (!this.nc)
3004
- throw new Error("endpoint not started");
3004
+ throw new Error(this.notLiveMsg());
3005
3005
  this.membershipFeedKv ??= await new Kvm(this.nc).open(membershipBucket(this.space));
3006
3006
  return this.membershipFeedKv;
3007
3007
  }
@@ -3277,7 +3277,7 @@ export class CotalEndpoint extends EventEmitter {
3277
3277
  if (!Number.isSafeInteger(limit) || limit < 1 || limit > 1000)
3278
3278
  throw new Error("channelHistoryPage limit must be a whole number from 1 to 1000");
3279
3279
  if (!this.nc || !this.js)
3280
- throw new Error("endpoint not started");
3280
+ throw new Error(this.notLiveMsg());
3281
3281
  const jsm = this.jsm ??= await jetstreamManager(this.nc);
3282
3282
  const signal = AbortSignal.any([AbortSignal.timeout(10_000), ...(opts?.signal ? [opts.signal] : [])]);
3283
3283
  signal.throwIfAborted();
@@ -3518,7 +3518,7 @@ export class CotalEndpoint extends EventEmitter {
3518
3518
  */
3519
3519
  async streamHistory(stream, subjects, limit, before, signal) {
3520
3520
  if (!this.nc)
3521
- throw new Error("endpoint not started");
3521
+ throw new Error(this.notLiveMsg());
3522
3522
  signal?.throwIfAborted();
3523
3523
  // A LIMIT THAT IS NOT A FINITE NUMBER HAS NO ANSWER, AND THE SEARCH BELOW CANNOT REFUSE IT.
3524
3524
  // Every comparison against NaN is false, so `limit <= 0` does not fire for one, and neither of
@@ -4060,7 +4060,7 @@ export class CotalEndpoint extends EventEmitter {
4060
4060
  * the same definitions are used by `cotal up` at privileged setup. */
4061
4061
  async ensureStreams() {
4062
4062
  if (!this.jsm)
4063
- throw new Error("endpoint not started");
4063
+ throw new Error(this.notLiveMsg());
4064
4064
  await createSpaceStreams(this.jsm, this.space);
4065
4065
  }
4066
4066
  // (v3) The old `provisionMembership` — manager/provisioner-written boot membership at spawn — is GONE.
@@ -4159,7 +4159,7 @@ export class CotalEndpoint extends EventEmitter {
4159
4159
  /** Lazily open the privileged members registry KV (delivery daemon / open-mode self). */
4160
4160
  async membersRegistry() {
4161
4161
  if (!this.nc)
4162
- throw new Error("endpoint not started");
4162
+ throw new Error(this.notLiveMsg());
4163
4163
  this.membersKv ??= await openMembersRegistry(this.nc, this.space);
4164
4164
  return this.membersKv;
4165
4165
  }
@@ -4167,7 +4167,7 @@ export class CotalEndpoint extends EventEmitter {
4167
4167
  * ACL at mint); the delivery daemon reads it fresh per durable entry to re-authorize. */
4168
4168
  async aclRegistry() {
4169
4169
  if (!this.nc)
4170
- throw new Error("endpoint not started");
4170
+ throw new Error(this.notLiveMsg());
4171
4171
  this.aclKv ??= await openAclRegistry(this.nc, this.space);
4172
4172
  return this.aclKv;
4173
4173
  }
@@ -4211,7 +4211,7 @@ export class CotalEndpoint extends EventEmitter {
4211
4211
  /** Lazily open the delivery lease/readiness KV (pre-created at `cotal up`; bind, never create). */
4212
4212
  async deliveryRegistry() {
4213
4213
  if (!this.nc)
4214
- throw new Error("endpoint not started");
4214
+ throw new Error(this.notLiveMsg());
4215
4215
  this.deliveryKv ??= await openDeliveryRegistry(this.nc, this.space);
4216
4216
  return this.deliveryKv;
4217
4217
  }
@@ -4456,7 +4456,7 @@ export class CotalEndpoint extends EventEmitter {
4456
4456
  * as "lease held". */
4457
4457
  async managerLeaseRegistry() {
4458
4458
  if (!this.nc)
4459
- throw new Error("endpoint not started");
4459
+ throw new Error(this.notLiveMsg());
4460
4460
  if (this.managerLeaseKv)
4461
4461
  return this.managerLeaseKv;
4462
4462
  // A JetStream client of its own, so every operation on this bucket carries the lease budget's
@@ -4741,7 +4741,7 @@ export class CotalEndpoint extends EventEmitter {
4741
4741
  */
4742
4742
  async durableJoinFor(owner, channel, lifecycleUid, opts = {}) {
4743
4743
  if (!this.js)
4744
- throw new Error("endpoint not started");
4744
+ throw new Error(this.notLiveMsg());
4745
4745
  await this.manager(); // ensure jsm — a non-consuming provisioner inits it lazily; catch-up + fence need it
4746
4746
  const kv = await this.membersRegistry();
4747
4747
  const existing = await readMember(kv, channel, owner, lifecycleUid);
@@ -4915,7 +4915,7 @@ export class CotalEndpoint extends EventEmitter {
4915
4915
  * is required, not optional (the responder would otherwise be lost on a broker blip). */
4916
4916
  async startPlane3(aclFor, opts = {}) {
4917
4917
  if (!this.js)
4918
- throw new Error("endpoint not started");
4918
+ throw new Error(this.notLiveMsg());
4919
4919
  this.plane3 = { aclFor, reloadMembershipCreds: opts.reloadMembershipCreds, evictPrincipal: opts.evictPrincipal, evictPrincipals: opts.evictPrincipals, planeConnLiveness: opts.planeConnLiveness, principalLiveness: opts.principalLiveness, reloadStoreIdentity: opts.reloadStoreIdentity, onDeliveryCredsAdopted: opts.onDeliveryCredsAdopted, startupComplete: opts.startupComplete };
4920
4920
  await this.armPlane3();
4921
4921
  }
@@ -5350,7 +5350,7 @@ export class CotalEndpoint extends EventEmitter {
5350
5350
  * call for the same plane replaces the first. */
5351
5351
  serveLiveness(plane, readState) {
5352
5352
  if (!this.nc)
5353
- throw new Error("endpoint not started");
5353
+ throw new Error(this.notLiveMsg());
5354
5354
  const held = this.livenessResponders.get(plane);
5355
5355
  if (held)
5356
5356
  held.readState = readState;
@@ -6216,14 +6216,14 @@ export class CotalEndpoint extends EventEmitter {
6216
6216
  * consume:false) can still pre-create others' durables. */
6217
6217
  async manager() {
6218
6218
  if (!this.nc)
6219
- throw new Error("endpoint not started");
6219
+ throw new Error(this.notLiveMsg());
6220
6220
  this.jsm ??= await jetstreamManager(this.nc);
6221
6221
  return this.jsm;
6222
6222
  }
6223
6223
  /** Bind this endpoint's durable consumers: DM inbox, chat, and (if a role) the task queue. */
6224
6224
  async startConsumers() {
6225
6225
  if (!this.jsm)
6226
- throw new Error("endpoint not started");
6226
+ throw new Error(this.notLiveMsg());
6227
6227
  // Unicast: this instance's private DM inbox, keyed on this endpoint's owner+actor principal. Open
6228
6228
  // mode self-creates; auth mode BINDS a durable the provisioner pre-created (agents are denied
6229
6229
  // CONSUMER.CREATE on DM_<space>, since the create-time filter_subject is the attack surface).
@@ -6283,7 +6283,7 @@ export class CotalEndpoint extends EventEmitter {
6283
6283
  * and acking one unseen on the work queue would delete the only copy of the request. */
6284
6284
  async pump(stream, durable, opts = {}) {
6285
6285
  if (!this.js)
6286
- throw new Error("endpoint not started");
6286
+ throw new Error(this.notLiveMsg());
6287
6287
  const consumer = await this.js.consumers.get(stream, durable);
6288
6288
  const ackWaitMs = await ackWaitOf(consumer);
6289
6289
  const msgs = await consumer.consume();
@@ -6393,7 +6393,7 @@ export class CotalEndpoint extends EventEmitter {
6393
6393
  * of one, and the next copy reaches the handler only after the previous handler settles. */
6394
6394
  async bindDmOnly(mode) {
6395
6395
  if (!this.js)
6396
- throw new Error("endpoint not started");
6396
+ throw new Error(this.notLiveMsg());
6397
6397
  const stream = dmStream(this.space);
6398
6398
  const durable = dmDurable(this.owner, this.actor, this.requireLifecycleUid("consuming the DM inbox"));
6399
6399
  let consumer;
@@ -6560,7 +6560,7 @@ export class CotalEndpoint extends EventEmitter {
6560
6560
  * and exposes the current `filter_subjects` for restart reconciliation. */
6561
6561
  async consumerInfo(stream, durable) {
6562
6562
  if (!this.jsm)
6563
- throw new Error("endpoint not started");
6563
+ throw new Error(this.notLiveMsg());
6564
6564
  try {
6565
6565
  return await this.jsm.consumers.info(stream, durable);
6566
6566
  }
@@ -6573,7 +6573,7 @@ export class CotalEndpoint extends EventEmitter {
6573
6573
  /** Delete one named consumer, swallowing ONLY structured consumer/stream absence. */
6574
6574
  async deleteConsumerIfPresent(stream, durable) {
6575
6575
  if (!this.jsm)
6576
- throw new Error("endpoint not started");
6576
+ throw new Error(this.notLiveMsg());
6577
6577
  try {
6578
6578
  await this.jsm.consumers.delete(stream, durable);
6579
6579
  }
@@ -6662,7 +6662,7 @@ export class CotalEndpoint extends EventEmitter {
6662
6662
  }
6663
6663
  async collectHistoryInner(subject, start, opts = {}) {
6664
6664
  if (!this.jsm || !this.js)
6665
- throw new Error("endpoint not started");
6665
+ throw new Error(this.notLiveMsg());
6666
6666
  const stream = chatStream(this.space);
6667
6667
  const name = chatHistDurable(this.owner, this.actor, this.requireLifecycleUid("chat history reads"));
6668
6668
  const out = [];