@cotal-ai/core 0.4.0 → 0.5.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,5 +1,5 @@
1
1
  import { EventEmitter } from "node:events";
2
- import type { AgentCard, ChannelConfig, ControlReply, ControlRequest, ControlRequestInit, EndpointRef, Part, Presence, PresenceStatus, CotalMessage } from "./types.js";
2
+ import type { AgentCard, ChannelConfig, ControlReply, ControlRequest, ControlRequestInit, EndpointRef, Part, Presence, PresenceStatus, AttentionMode, ChannelMode, CotalMessage } from "./types.js";
3
3
  export declare const DEFAULT_SERVER = "nats://127.0.0.1:4222";
4
4
  /** Space joined when none is given on the CLI (the `cotal-<space>` cmux tab, etc.). */
5
5
  export declare const DEFAULT_SPACE = "main";
@@ -33,6 +33,9 @@ export interface EndpointOptions {
33
33
  watchPresence?: boolean;
34
34
  /** Create inbound stream consumers (DM / chat / anycast). Default true; a pure observer sets false. */
35
35
  consume?: boolean;
36
+ /** Initial per-channel attention overrides to publish in presence from the first heartbeat (the
37
+ * connector's file-default seed). Mirror only — never read back into delivery. */
38
+ channelModes?: Record<string, ChannelMode>;
36
39
  /** How long an unacked (un-surfaced) message waits before redelivery (ms). */
37
40
  ackWaitMs?: number;
38
41
  /** Retire this instance's durable consumers after it's been gone this long (ms). */
@@ -47,18 +50,6 @@ export interface ChannelMember {
47
50
  role?: string;
48
51
  live: boolean;
49
52
  }
50
- /**
51
- * Events: "message" (CotalMessage), "presence" (PresenceEvent), "roster" (Presence[]), "error" (Error),
52
- * "connection" ({ connected: boolean }) — true on every successful (re)bind (initial start, manual
53
- * reconnect, AND background self-heal), false the moment the connection drops (rebuild null window /
54
- * terminal close). Lets an in-process agent track connectedness off the endpoint's own (re)binds
55
- * instead of an imperative flag the self-heal path can't reach.
56
- *
57
- * Callers MUST attach an "error" listener before `start()`: async faults (incl. NATS
58
- * permission denials, surfaced via `watchStatus`) are emitted as "error", and Node throws
59
- * synchronously on an unhandled "error" — a missing listener turns any such fault into a
60
- * process crash instead of a logged denial.
61
- */
62
53
  export declare class CotalEndpoint extends EventEmitter {
63
54
  readonly card: AgentCard;
64
55
  readonly space: string;
@@ -81,6 +72,11 @@ export declare class CotalEndpoint extends EventEmitter {
81
72
  private jsm?;
82
73
  private kv?;
83
74
  private channelKv?;
75
+ /** Plane-3 durable-membership registry KV — lazily opened by the privileged (manager) endpoint. */
76
+ private membersKv?;
77
+ /** When set, this endpoint hosts the Plane-3 fan-out writer + trusted reader (the manager). `aclFor`
78
+ * maps an owner id to its current read ACL (`allowSubscribe`) for the reader's re-authorization. */
79
+ private plane3?;
84
80
  /** Live local cache of the channel registry (key = channel token), kept by a KV watch. */
85
81
  private readonly channelConfigs;
86
82
  private channelDefaults;
@@ -94,11 +90,45 @@ export declare class CotalEndpoint extends EventEmitter {
94
90
  private histLock;
95
91
  private readonly subs;
96
92
  private readonly streamMsgs;
93
+ /** Per-channel native core subscriptions (SPEC v0.3) — the manager-free live read path for boot +
94
+ * runtime channels (there is no per-instance chat durable). Keyed by channel so leave unsubscribes
95
+ * just one. */
96
+ private readonly chatSubs;
97
+ /** Channels whose core-sub the broker refused (async sub.allow violation) — read by the
98
+ * broker-confirmed join: a denied subscribe is NOT a successful join (SPEC conformance #13). */
99
+ private readonly chatSubDenied;
100
+ /** Channels this session has a Plane-3 durable backstop for (per-channel join GENERATION, from
101
+ * durableJoin, so leave passes it back for the stale-leave guard). A durable channel's core-sub is
102
+ * NOT coverage-dropped — it stays a live wake-hint, dedup-coalesced with the Plane-3 durable copy by
103
+ * id-dedup. Drives the durable-state surface + routes leave to `durableLeave`. PERSISTS across
104
+ * reconnect (like `this.channels`): the membership record + the `dlv_<id>` durable are persistent so
105
+ * the backstop survives a reconnect on its own; the agent can't re-read the privileged members KV,
106
+ * so this in-memory mirror is kept, not rebuilt. Cleared only on full stop. */
107
+ private readonly plane3Channels;
108
+ /** Channels whose live sub was REFUSED while they held a Plane-3 durable membership, whose §7
109
+ * tombstone has not yet confirmed (channel → join generation). {@link closeRefusedMembership} retries
110
+ * the tombstone until it lands; until then this is a `durable-unclosed` state surfaced via
111
+ * {@link pendingDurableLeaves} (the connector shows it in `cotal_channels`, never as ordinary
112
+ * absence). Persists across reconnect; cleared on tombstone success or full stop. */
113
+ private readonly pendingDurableLeave;
114
+ /** Chat-join subjects currently being broker-confirmed. An out-of-ACL subscribe among these trips an
115
+ * EXPECTED async permission violation that joinChannel turns into a clean throw, so watchStatus
116
+ * suppresses it rather than surfacing a spurious connection error. */
117
+ private readonly confirmingChatSubs;
118
+ /** True until the first successful connect completes its boot backfill — distinguishes first-connect
119
+ * (backfill the boot channels' history) from a reconnect (reopen the core-subs, no re-backfill).
120
+ * Persists across reconnect (NOT connection-scoped). Replaces the legacy chat-durable consumed-cursor
121
+ * signal now that there is no per-instance chat durable. */
122
+ private firstConnect;
97
123
  private heartbeatTimer?;
98
124
  private sweepTimer?;
99
125
  private readonly roster;
100
126
  private status;
101
127
  private activity?;
128
+ /** Mirror of the connector's authoritative attention state, published in presence (advisory). The
129
+ * endpoint never reads these back into delivery — they exist only to broadcast. */
130
+ private attentionMode?;
131
+ private channelModes?;
102
132
  private stopped;
103
133
  /** In-flight rebuild (drain+rebind) — serializes manual reconnect, the supervisor's
104
134
  * closed(), and reestablishLoop so only ONE rebuild runs at a time (a second trigger
@@ -198,6 +228,18 @@ export declare class CotalEndpoint extends EventEmitter {
198
228
  getRoster(): Presence[];
199
229
  setActivity(activity: string): Promise<void>;
200
230
  setStatus(status: PresenceStatus): Promise<void>;
231
+ /** Publish the agent's global attention mode into presence (advisory observability). Mirror only —
232
+ * delivery decisions stay in the connector's authoritative state. */
233
+ setAttention(attention: AttentionMode): Promise<void>;
234
+ /** Publish the agent's per-channel attention overrides into presence (advisory). An empty map drops
235
+ * the field. Mirror only — never read back into delivery. */
236
+ setChannelModes(modes: Record<string, ChannelMode>): Promise<void>;
237
+ /** Overlay the host's live model onto the card's display-only `meta.model` and republish presence.
238
+ * For connectors that learn the actual model only *after* launch (e.g. Claude Code's `SessionStart`
239
+ * hook payload) rather than from an operator pin. Display-only discovery metadata; a no-op when the
240
+ * value is empty or already current (no redundant publish). The mutated card is read live by every
241
+ * later publish, so even a pre-connect call surfaces on the first presence write. */
242
+ setCardModel(model: string): Promise<void>;
201
243
  /** This channel's registry config from the live local cache (undefined if unset). */
202
244
  getChannelConfig(channel: string): ChannelConfig | undefined;
203
245
  /** Effective replay-on-join policy for a channel: per-channel override ?? space default ??
@@ -206,29 +248,27 @@ export declare class CotalEndpoint extends EventEmitter {
206
248
  /** The channels this endpoint is currently subscribed to (live — reflects join/leave). */
207
249
  joinedChannels(): string[];
208
250
  /**
209
- * Join a channel mid-session: add it to our chat durable's `filter_subjects` (same durable,
210
- * same ack-floor, no teardown `update` rides the self-scoped create grant), capture the
211
- * stream frontier as this channel's join watermark, and backfill its history if replay is on.
212
- * Idempotent: re-joining a channel already in our filter is a no-op (no re-backfill). Returns
213
- * the number of historical messages backfilled (emitted as `historical` "message" events).
251
+ * Join a channel mid-session: open a native core subscription (manager-free live read, broker-
252
+ * confirmed against `sub.allow`), capture the stream frontier as the join watermark, backfill its
253
+ * history if replay is on, and for a `durable`-class channel under a manager — request a Plane-3
254
+ * durable backstop. Idempotent: re-joining is a no-op (no re-backfill). Returns the backfill count +
255
+ * whether the durable backstop is active (+ a `reason` when a durable channel couldn't get one).
214
256
  */
215
257
  joinChannel(channel: string): Promise<{
216
258
  joined: boolean;
217
259
  backfilled: number;
260
+ durable: boolean;
261
+ reason?: string;
218
262
  }>;
219
- /** Leave a channel mid-session: drop it from the durable's `filter_subjects`. Refuses to leave
220
- * the *last* channel (an empty filter would match every chat subject the opposite of
221
- * leaving). Returns whether anything changed. */
263
+ /** Leave a channel mid-session MANAGER-FREE for the live read: close the core subscription. For a
264
+ * Plane-3 durable channel, the membership is tombstoned FIRST at the leave cursor (SPEC §7: leave is
265
+ * a hard read boundary for the backstop — a pre-leave entry stays deliverable, `seq > leaveCursor` is
266
+ * denied). FAIL-CLOSED: if the tombstone can't be confirmed the call throws and the leave is NOT
267
+ * applied (live sub stays up, local mirror intact) so the caller can retry — never close the live
268
+ * read while the backstop keeps delivering. */
222
269
  leaveChannel(channel: string): Promise<{
223
270
  left: boolean;
224
271
  }>;
225
- /** Move the chat live-tail durable to a new channel set. OPEN mode self-serves the
226
- * `consumers.update` (the agent owns its durable). AUTH mode is bind-only — the agent has no
227
- * UPDATE grant — so it sends a mediated control request to the manager, which validates the set
228
- * ⊆ its `allowSubscribe` before moving the filter. Throws clearly when no privileged responder is
229
- * present: a manager-less standalone auth session is fixed to its boot subscribe set — a
230
- * documented limitation, not a silent degrade. */
231
- private setChatFilter;
232
272
  /** One coherent channel model for dashboards: every channel that has messages OR a registry
233
273
  * entry (configured-but-empty), each tagged with its {@link ChannelConfig}. Works even on
234
274
  * observer endpoints (no consumers needed). */
@@ -238,20 +278,15 @@ export declare class CotalEndpoint extends EventEmitter {
238
278
  config?: ChannelConfig;
239
279
  }[]>;
240
280
  /**
241
- * Who is subscribed to a channel — **broker truth, not self-report**. In Cotal a peer
242
- * joins a channel by creating a chat-stream durable consumer (`chat_<id>`,
243
- * `filter_subjects` = its channels), so `consumers.list(CHAT)` already records the real
244
- * membership; we join it with presence so a lingering durable for a gone peer shows as a
245
- * stale ghost (`live: false`) rather than a phantom listener.
246
- *
247
- * `channelMembers("review")` that channel's members; `channelMembers()` every channel
248
- * mapped to its members. A member on a wildcard (`team.>`) counts for every concrete
249
- * channel it subsumes (`team.backend`) membership is the *effective subscription*.
250
- *
251
- * Privileged read: `consumers.list` needs `$JS.API.CONSUMER.LIST.<chat stream>`, which only
252
- * the allow-all manager profile holds today (agents, observer, and admin are all denied), so
253
- * this is not an agent-facing capability — serving it from a dashboard profile is a one-line
254
- * ACL grant away.
281
+ * Who is a durable member of a channel — read from the privileged members registry (Plane-3),
282
+ * joined with presence for liveness (a member whose peer is gone but lingering shows `live:false`,
283
+ * not a phantom). Only CURRENT, ACTIVATED members (non-tombstoned, and past activation catch-up — a
284
+ * join still completing or that failed catch-up reported durable:false and stays hidden here until
285
+ * confirmed, so this surface never overstates membership). A wildcard registry channel would count for
286
+ * the concrete channels it subsumes, but durable membership is per-concrete-channel, so records are
287
+ * concrete. `live`-class channels carry no durable record membership there is the live core-sub,
288
+ * not tracked here. Privileged read (the members KV is manager-write/read; agents hold no grant), so
289
+ * it is served by the manager, not an agent capability.
255
290
  */
256
291
  channelMembers(channel: string): Promise<ChannelMember[]>;
257
292
  channelMembers(): Promise<Map<string, ChannelMember[]>>;
@@ -288,20 +323,19 @@ export declare class CotalEndpoint extends EventEmitter {
288
323
  * the same definitions are used by `cotal up` at privileged setup. */
289
324
  private ensureStreams;
290
325
  /**
291
- * Privileged: pre-create an agent's bind-only chat live-tail durable (auth mode), filtered to its
292
- * `subscribe` set, so the agent can BIND it without holding CONSUMER.CREATE/UPDATE on CHAT — its
293
- * live read can't be self-widened past `allowSubscribe`. The creator sets the filter; the agent
294
- * never does (mirrors {@link provisionDmInbox}). Idempotent. The caller must be permissive on CHAT.
295
- */
296
- provisionChatDurable(targetId: string, subscribe: string[]): Promise<void>;
297
- /**
298
- * Privileged: move an agent's bind-only chat durable to a new channel set — the write half of the
299
- * mediated join/leave. The manager calls this AFTER validating the set the agent's
300
- * `allowSubscribe`; the agent itself has no UPDATE grant, so this trusted path is the only way its
301
- * live filter moves. The filter is rebuilt from channel names here (not from agent-supplied
302
- * subjects) so a caller can't smuggle a hand-built filter.
326
+ * Privileged: write an agent's BOOT durable membership each `durable`-class channel in its boot
327
+ * subscribe set gets a Plane-3 durable-active record (via {@link durableJoinFor}: cursor capture +
328
+ * activation catch-up), so it receives durable backstop copies from boot exactly like a runtime
329
+ * `durableJoin`. `live`-class (and non-concrete) channels are skipped. Idempotent.
330
+ *
331
+ * Writes the durable RECORDS with the caller's privileged creds — it does NOT require this endpoint
332
+ * to host the runtime fan-out/reader loops (a space-level manager service), so EVERY auth launcher
333
+ * provisions identically: the manager AND the short-lived `cotal spawn` provisioner both write boot
334
+ * records, which the space's manager then delivers (no silent no-op that would hide a boot
335
+ * membership; AGENTS.md "no fallbacks"). A space running no manager is live-only for everyone (the
336
+ * records exist; nothing delivers them until a manager hosts the loops).
303
337
  */
304
- setChatFilterFor(targetId: string, channels: string[]): Promise<void>;
338
+ provisionMembership(targetId: string, channels: string[]): Promise<void>;
305
339
  /**
306
340
  * Privileged: pre-create an agent's DM inbox durable (auth mode), so the agent can BIND
307
341
  * it without holding CONSUMER.CREATE on DM_<space>. The creator sets the filter to
@@ -310,6 +344,14 @@ export declare class CotalEndpoint extends EventEmitter {
310
344
  * safe to call again on manager restart. The caller must be permissive on DM_<space>.
311
345
  */
312
346
  provisionDmInbox(targetId: string): Promise<void>;
347
+ /**
348
+ * Privileged: pre-create an agent's bind-only Plane-3 DELIVER durable (`dlv_<id>`, filtered to
349
+ * `dlv.<id>`), so the agent can BIND its per-member durable handoff without holding CONSUMER.CREATE
350
+ * on the DLV stream. Same bind-only model as {@link provisionDmInbox}: the creator sets the filter,
351
+ * the agent never does. The trusted reader transfers re-authorized copies onto `dlv.<id>`; the agent
352
+ * acks them via native JetStream (SPEC §8). Idempotent. The caller must be permissive on DLV.
353
+ */
354
+ provisionDlvInbox(targetId: string): Promise<void>;
313
355
  /**
314
356
  * Privileged: pre-create a role's shared TASK work-queue durable (auth mode), so agents
315
357
  * of that role can BIND it without holding CONSUMER.CREATE on TASK_<space>. The creator
@@ -317,6 +359,124 @@ export declare class CotalEndpoint extends EventEmitter {
317
359
  * Idempotent per role. The caller must be permissive on TASK_<space>.
318
360
  */
319
361
  provisionTaskQueue(role: string): Promise<void>;
362
+ /** Lazily open the privileged members registry KV (manager / open-mode self). */
363
+ private membersRegistry;
364
+ /** Privileged: one owner's NON-TOMBSTONED durable memberships as `{channel, generation, activated}` —
365
+ * the manager serves this to a connecting agent (via the `listMemberships` self-service op). The agent
366
+ * hydrates its leave mirror from the ACTIVATED ones (the confirmed backstops), but the non-activated
367
+ * ones are returned too so `leaveChannel` can discover + close a record that still routes under the
368
+ * pure-interval predicate (a crash-stuck pending activation) — without reading the privileged KV. */
369
+ ownerMemberships(owner: string): Promise<{
370
+ channel: string;
371
+ generation: number;
372
+ activated: boolean;
373
+ }[]>;
374
+ /** Effective delivery class read AUTHORITATIVELY from the registry KV (not the watch cache) — so a
375
+ * `live`→`durable` flip is seen by fan-out without a cache-propagation gap (red-team MED-3). */
376
+ private deliveryClassFresh;
377
+ /** Collision-safe `@mention` → owner-id resolution: a name that resolves to exactly one present
378
+ * peer wins; 0 or >1 matches drop (never fan a directed durable copy to an unrelated same-named
379
+ * bystander — red-team LOW; SPEC §4 unique instance id). */
380
+ private resolveOwnerByName;
381
+ /** Publish one fan-out entry into an owner's mixed inbox, idempotent via `Nats-Msg-Id`
382
+ * (`<msgId>:<owner>:<generation>`) so a catch-up copy and a racing fan-out copy collapse. */
383
+ private publishDinbox;
384
+ /** The fan-out consumer's delivered stream-seq — the activation-fence upper bound (red-team
385
+ * BLOCKER-1: the shared fan-out cursor advances independently of the stream frontier). */
386
+ private fanoutDeliveredSeq;
387
+ /**
388
+ * Privileged durable-JOIN write (the manager calls this after validating channel ⊆ allowSubscribe;
389
+ * {@link provisionMembership} calls it at provision time for boot channels): capture `joinCursor`,
390
+ * commit a `durable-active` record (CAS + generation bump), then ACTIVATION CATCH-UP idempotently
391
+ * copies `(joinCursor, fence]` into the owner inbox where `fence = max(frontier, fanoutDelivered)` —
392
+ * fan-out owns `seq > fence`. Idempotent against a timeout-retry (an already-activated membership
393
+ * no-ops). Returns `{durable:false}` (honest degrade) only if the catch-up window was evicted.
394
+ *
395
+ * This writes durable KV + dinbox state with the caller's privileged creds; it does NOT require THIS
396
+ * endpoint to host the fan-out/reader loops (those are a space-level manager service). So a
397
+ * short-lived provisioner can write a boot membership a separate long-lived manager then delivers.
398
+ */
399
+ durableJoinFor(owner: string, channel: string): Promise<{
400
+ durable: boolean;
401
+ reason?: string;
402
+ generation?: number;
403
+ }>;
404
+ /** Privileged durable-LEAVE write: tombstone the membership at `leaveCursor = frontier` so the
405
+ * backstop denies `seq > leaveCursor` while a pre-leave entry stays deliverable (SPEC §7 interval). */
406
+ durableLeaveFor(owner: string, channel: string, expectedGeneration?: number): Promise<void>;
407
+ /** Idempotently copy the eligible chat messages in `(fromSeqExcl, toSeqIncl]` for `channel` into the
408
+ * owner inbox, via a DEDICATED per-(owner,join) ephemeral consumer (NOT the agent-scoped
409
+ * `chathist_<id>`/`histLock` — red-team HIGH-8). `evicted` ⇒ the oldest eligible seq aged out under
410
+ * `discard=Old` (the start seq could not be served), a durable shortfall the caller surfaces. */
411
+ private catchupCopy;
412
+ /** Start the Plane-3 fan-out writer + trusted reader on THIS (privileged) endpoint. `aclFor` maps an
413
+ * owner id to its current read ACL for the reader's re-authorization (the manager passes its managed
414
+ * set). Call once after connect; idempotent durable creation lets it resume on a manager restart. */
415
+ startPlane3(aclFor: (owner: string) => string[] | undefined): Promise<void>;
416
+ /** (Re)bind the Plane-3 fan-out writer + trusted reader. Idempotent — the durables resume from their
417
+ * cursor. Called by {@link startPlane3} once AND by {@link connectAndBind} on every (re)connect, so
418
+ * a manager-endpoint reconnect RE-ARMS the backstop. Without this, a broker blip would silently kill
419
+ * the loops while `durableJoinFor` kept reporting `durable:true` (the impl-review's BLOCKER-1). No-op
420
+ * unless this endpoint hosts Plane-3 (`this.plane3` set). */
421
+ private armPlane3;
422
+ /** Fan-out loop: bind the privileged `fanout` durable on CHAT and route each message (routing only —
423
+ * the trusted reader is the auth gate). */
424
+ private runFanout;
425
+ /** Route ONE chat message to eligible owners' mixed inboxes. `durable` channel → its `durable-active`
426
+ * members within interval; `live` channel → `@mention` targets authorized to read it (ACL only).
427
+ * Members KV is scanned FRESH per message (no cache — red-team BLOCKER-1 catch-up correctness). */
428
+ private fanOutMessage;
429
+ /** Trusted-reader loop: bind the single privileged `reader` durable over `dinbox.>` and re-authorize
430
+ * + transfer each entry. */
431
+ private runReader;
432
+ /** Re-authorize ONE mixed-inbox entry and transfer it to the owner's DELIVER store. Deny (drop) on a
433
+ * revoked/narrowed ACL or out-of-interval seq; on transfer success, ack the mixed entry (durability
434
+ * has moved to DLV — an §8 equivalent per-member at-least-once mechanism). The agent acks DLV. */
435
+ private readerHandle;
436
+ /** Agent-side: bind + pump our pre-created Plane-3 DELIVER durable (`dlv_<id>`). Every message here is
437
+ * manager-written (DLV is manager-write-only, broker-enforced) and is a CHANNEL message by contract
438
+ * (the backstop never carries DMs), so `kind=channel` is path-derived (SPEC §4) and the body is
439
+ * trusted (no spoof-guard). `durable:true` — real JetStream ack, coalesced with the core-sub live
440
+ * copy by `MeshAgent.ingest`. No-op when the durable isn't present (open mode / not provisioned). */
441
+ private pumpDlv;
442
+ /** Agent-side: request a Plane-3 durable backstop for a channel via the manager (ctl.self). Throws
443
+ * when no privileged writer is present (open / manager-less). 30s timeout — activation catch-up may
444
+ * run before the reply (the window is small, but a busy channel can take more than the 5s default). */
445
+ durableJoinChannel(channel: string): Promise<{
446
+ durable: boolean;
447
+ reason?: string;
448
+ generation?: number;
449
+ }>;
450
+ /** Agent-side: release a Plane-3 durable backstop (tombstone membership at the leave cursor). Passes
451
+ * the join generation so a stale leave can't tombstone a newer rejoin (the manager validates it). */
452
+ durableLeaveChannel(channel: string, generation?: number): Promise<void>;
453
+ /** Fail-closed async cleanup for a channel forced out by a LATE sub.allow refusal (the broker revoked
454
+ * the live read). The sync sub callback can't await, so this RETRIES the Plane-3 tombstone with capped
455
+ * backoff UNTIL IT SUCCEEDS (or the endpoint stops) — the §7 boundary always closes once the manager
456
+ * is reachable, never a silent give-up. While pending, the channel is tracked in
457
+ * {@link pendingDurableLeave} and surfaced via {@link pendingDurableLeaves} (the connector shows it in
458
+ * `cotal_channels` as `durable-unclosed`, never ordinary absence). The generation is kept the whole
459
+ * time. Authoritative closure of a revoked membership is also the manager's job (revocation). */
460
+ private closeRefusedMembership;
461
+ /** Channels with a Plane-3 durable membership whose §7 tombstone is still pending after a refused live
462
+ * sub (see {@link closeRefusedMembership}) — surfaced by the connector as a `durable-unclosed` state so
463
+ * it is never presented as ordinary "not subscribed". */
464
+ pendingDurableLeaves(): string[];
465
+ /** A control request that found NO responder — open / manager-less (no privileged control plane),
466
+ * distinct from a responder that errored. nats.js surfaces it as NoRespondersError, or a RequestError
467
+ * whose `isNoResponders()` is true. */
468
+ private isNoResponders;
469
+ /** Agent-side: this session's CURRENT durable memberships (channel + join generation) from the
470
+ * manager — the agent holds no read on the privileged members KV. `undefined` ⇒ NO control responder
471
+ * (open / manager-less, so there is no Plane-3 and no memberships). THROWS on a responder-present RPC
472
+ * failure, so a caller can FAIL-CLOSED rather than mistaking a transient error for "no membership". */
473
+ private fetchMemberships;
474
+ /** Agent-side: seed `plane3Channels` with this session's boot durable memberships + generations on
475
+ * first connect (the agent holds no read on the privileged members KV). A best-effort OPTIMIZATION: it
476
+ * pre-fills the leave-generation mirror + the durable-state surface. If it can't (a transient manager
477
+ * error), {@link leaveChannel} re-resolves the generation on demand and fails closed there — so a
478
+ * missed hydration never silently leaves a boot durable channel untombstonable. */
479
+ private hydrateMemberships;
320
480
  /** Lazily obtain a JetStream manager — so a non-consuming endpoint (e.g. the supervisor,
321
481
  * consume:false) can still pre-create others' durables. */
322
482
  private manager;
@@ -324,6 +484,18 @@ export declare class CotalEndpoint extends EventEmitter {
324
484
  private startConsumers;
325
485
  /** Drive one consumer: decode, drop our own echo, and hand each message to listeners with ack control. */
326
486
  private pump;
487
+ /** Open a native core subscription to a channel's live feed (the manager-free live read path,
488
+ * broker-enforced by `sub.allow`). At-most-once — no replay, no ack; it is the live delivery for
489
+ * every channel (boot + runtime). For a `durable` channel it is also the low-latency wake-hint
490
+ * alongside the Plane-3 durable copy, coalesced by the receiver's id-dedup. Drops our own echo +
491
+ * spoofed senders. */
492
+ private subscribeChat;
493
+ /** Close a channel's core subscription (manager-free leave). */
494
+ private unsubscribeChat;
495
+ /** Confirm a just-opened core subscription was accepted by the broker. A `sub.allow` violation is
496
+ * async in NATS, so flush (round-trips the SUB) then settle briefly to let the refusal land — a
497
+ * denied subscribe must not read as a successful join (SPEC conformance #13). */
498
+ private confirmChatSub;
327
499
  /** The highest join watermark among the joined subscriptions that cover `concreteChannel`
328
500
  * (a wildcard sub like `team.>` covers `team.backend`), or undefined if none — the tail
329
501
  * drops a chat message with `seq <= ` this. */
@@ -335,8 +507,8 @@ export declare class CotalEndpoint extends EventEmitter {
335
507
  * focus-watermark a connector captures on entering `focus` (recall reads ambient after it). */
336
508
  chatFrontier(): Promise<number>;
337
509
  /** Phase 1 of a join — arm each channel's tail-drop watermark at the current frontier. MUST run
338
- * BEFORE the filter flip (consumers.update, or pump on a fresh create) so the tail can never
339
- * carry a just-joined message un-watermarked — which would double-emit it (live + backfill).
510
+ * BEFORE opening the core subscription so the live tail can never carry a just-joined message
511
+ * un-watermarked — which would double-emit it (live + backfill).
340
512
  * Returns the per-channel frontiers for {@link backfillArmed}. */
341
513
  private armJoin;
342
514
  /** Phase 2 of a join — backfill each armed channel's history up to its frontier (replay-gated),
@@ -401,6 +573,10 @@ export declare class CotalEndpoint extends EventEmitter {
401
573
  private handleChannelEntry;
402
574
  private handleKvEntry;
403
575
  private applyPresence;
576
+ /** Materialize an OFFLINE presence record: drop the advisory attention fields. An offline peer must
577
+ * not show a stale `[focus]` or "locally muted #x" hint — SPEC: attention removed on offline sweep,
578
+ * channel modes reset on restart. card/activity/ts are kept. */
579
+ private toOffline;
404
580
  /** Mark a known peer offline (on KV delete/purge), keeping it in the roster. */
405
581
  private markOffline;
406
582
  private sweep;
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../src/endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA4B3C,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EAEb,YAAY,EACZ,cAAc,EACd,kBAAkB,EAElB,WAAW,EAEX,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,YAAY,EAC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