@cotal-ai/core 0.171.4 → 0.171.5

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.
Files changed (35) hide show
  1. package/dist/control-exchange.d.ts.map +1 -1
  2. package/dist/control-exchange.js +3 -4
  3. package/dist/control-exchange.js.map +1 -1
  4. package/dist/endpoint-anycast.d.ts +110 -0
  5. package/dist/endpoint-anycast.d.ts.map +1 -0
  6. package/dist/endpoint-anycast.js +316 -0
  7. package/dist/endpoint-anycast.js.map +1 -0
  8. package/dist/endpoint-consumers.d.ts +147 -0
  9. package/dist/endpoint-consumers.d.ts.map +1 -0
  10. package/dist/endpoint-consumers.js +459 -0
  11. package/dist/endpoint-consumers.js.map +1 -0
  12. package/dist/endpoint-dial.d.ts +3 -1
  13. package/dist/endpoint-dial.d.ts.map +1 -1
  14. package/dist/endpoint-dial.js +5 -2
  15. package/dist/endpoint-dial.js.map +1 -1
  16. package/dist/endpoint-durable.d.ts +82 -0
  17. package/dist/endpoint-durable.d.ts.map +1 -0
  18. package/dist/endpoint-durable.js +164 -0
  19. package/dist/endpoint-durable.js.map +1 -0
  20. package/dist/endpoint-principal-serve.d.ts +110 -0
  21. package/dist/endpoint-principal-serve.d.ts.map +1 -0
  22. package/dist/endpoint-principal-serve.js +233 -0
  23. package/dist/endpoint-principal-serve.js.map +1 -0
  24. package/dist/endpoint.d.ts +30 -189
  25. package/dist/endpoint.d.ts.map +1 -1
  26. package/dist/endpoint.js +201 -1089
  27. package/dist/endpoint.js.map +1 -1
  28. package/dist/launch-artifacts.d.ts.map +1 -1
  29. package/dist/launch-artifacts.js +17 -9
  30. package/dist/launch-artifacts.js.map +1 -1
  31. package/dist/websocket-dial.d.ts +9 -0
  32. package/dist/websocket-dial.d.ts.map +1 -0
  33. package/dist/websocket-dial.js +121 -0
  34. package/dist/websocket-dial.js.map +1 -0
  35. package/package.json +1 -1
@@ -0,0 +1,147 @@
1
+ import { type DmOnlyOptions } from "./endpoint-options.js";
2
+ import type { AgentCard, AnycastTakeOutcome } from "./types.js";
3
+ import { type JetStreamManager, type JetStreamClient, type ConsumerMessages, type ConsumerInfo } from "@nats-io/jetstream";
4
+ import { type NatsConnection, type Subscription, PermissionViolationError } from "@nats-io/transport-node";
5
+ /** What the consumers component reads from its endpoint. State is read when it is used, never copied, a
6
+ * field it reassigns is written back through its setter, and every method is looked up on the endpoint
7
+ * at call time, so a member a caller replaced on the endpoint is the one that runs. */
8
+ export interface EndpointConsumersDeps {
9
+ nc: () => NatsConnection | undefined;
10
+ jsm: () => JetStreamManager | undefined;
11
+ setJsm: (value: JetStreamManager | undefined) => void;
12
+ js: () => JetStreamClient | undefined;
13
+ space: () => string;
14
+ owner: () => string;
15
+ actor: () => string;
16
+ card: () => AgentCard;
17
+ authed: () => boolean;
18
+ channels: () => string[];
19
+ ackWaitMs: () => number;
20
+ inactiveThresholdMs: () => number;
21
+ firstConnect: () => boolean;
22
+ setFirstConnect: (value: boolean) => void;
23
+ backfillFloor: () => number | undefined;
24
+ streamMsgs: () => ConsumerMessages[];
25
+ taskEpoch: () => string | undefined;
26
+ setTaskEpoch: (value: string | undefined) => void;
27
+ stopped: () => boolean;
28
+ dmOnlyInFlight: () => Promise<void> | undefined;
29
+ setDmOnlyInFlight: (value: Promise<void> | undefined) => void;
30
+ chatSubs: () => Map<string, Subscription>;
31
+ chatSubDenied: () => Set<string>;
32
+ chatSubRefusals: () => WeakSet<PermissionViolationError>;
33
+ plane3Channels: () => Map<string, number>;
34
+ notLiveMsg: () => string;
35
+ requireLifecycleUid: (what: string) => string;
36
+ ensureDmDurable: (owner: string, actor: string, lifecycleUid: string, opts: {
37
+ ackWaitMs?: number;
38
+ inactiveThresholdMs?: number;
39
+ }) => Promise<void>;
40
+ pumpDlv: () => Promise<void>;
41
+ armJoin: (channels: string[]) => Promise<Map<string, number>>;
42
+ backfillArmed: (frontiers: Map<string, number>, floorSeq?: number) => Promise<number>;
43
+ armBootDurableMemberships: () => Promise<void>;
44
+ takeAnycast: (role: string, seq: number, id: string, count: number, epoch: string, nak: () => void) => Promise<AnycastTakeOutcome>;
45
+ emitRecoverable: (err: Error) => void;
46
+ closeRefusedMembership: (channel: string, generation: number) => Promise<void>;
47
+ emit: (event: string, ...args: unknown[]) => boolean;
48
+ }
49
+ /** One endpoint's durable consumers. Internal: `CotalEndpoint` keeps the fields and forwards to it. */
50
+ export declare class EndpointConsumers {
51
+ private readonly deps;
52
+ constructor(deps: EndpointConsumersDeps);
53
+ private get nc();
54
+ private get jsm();
55
+ private set jsm(value);
56
+ private get js();
57
+ private get space();
58
+ private get owner();
59
+ private get actor();
60
+ private get card();
61
+ private get authed();
62
+ private get channels();
63
+ private get ackWaitMs();
64
+ private get inactiveThresholdMs();
65
+ private get firstConnect();
66
+ private set firstConnect(value);
67
+ private get backfillFloor();
68
+ private get streamMsgs();
69
+ private get taskEpoch();
70
+ private set taskEpoch(value);
71
+ private get stopped();
72
+ private get dmOnlyInFlight();
73
+ private set dmOnlyInFlight(value);
74
+ private get chatSubs();
75
+ private get chatSubDenied();
76
+ private get chatSubRefusals();
77
+ private get plane3Channels();
78
+ private notLiveMsg;
79
+ private requireLifecycleUid;
80
+ private ensureDmDurable;
81
+ private pumpDlv;
82
+ private armJoin;
83
+ private backfillArmed;
84
+ private armBootDurableMemberships;
85
+ private takeAnycast;
86
+ private emitRecoverable;
87
+ private closeRefusedMembership;
88
+ private emit;
89
+ /** Lazily obtain a JetStream manager — so a non-consuming endpoint (e.g. the supervisor,
90
+ * consume:false) can still pre-create others' durables. */
91
+ manager(): Promise<JetStreamManager>;
92
+ /** Bind this endpoint's durable consumers: DM inbox, chat, and (if a role) the task queue. */
93
+ startConsumers(): Promise<void>;
94
+ /** Drive one consumer: decode and hand each message to listeners with ack control. Our own sends are
95
+ * delivered too: on the DM inbox and the role queue they were addressed to us, so none is an echo,
96
+ * and acking one unseen on the work queue would delete the only copy of the request. */
97
+ private pump;
98
+ /** Bind the role consumer and read the TASK stream's creation time on both sides of the bind, so
99
+ * the time belongs to the stream the consumer was bound on (SPEC §8.1). */
100
+ private bindTaskConsumer;
101
+ /** Read the TASK stream's creation time into {@link taskEpoch}. */
102
+ readTaskEpoch(): Promise<string>;
103
+ /** Warn once when the broker reports this endpoint's own DM inbox missing while the connection is
104
+ * up, as after a store reset that the client's reconnect rode through, or after a manager restart
105
+ * deletes the inbox. nats.js keeps checking and resumes pulling if the inbox comes back, so this
106
+ * only reports. A `consumer_deleted` status is the consumer going away, so it warns at once. A
107
+ * not-found can be a passing state, so that warning waits for a second report; the several 409s a
108
+ * delete answers pending pulls with count once. A pull means the consumer was found again, which
109
+ * re-arms the warning. The loop ends when the consumer is stopped, by `stop()` or by a rebuild
110
+ * replacing this connection. */
111
+ private watchInbox;
112
+ /** Decode one stream copy and apply the authenticity guard (fail closed): the sender is encoded in
113
+ * the subject, which the server policed who could publish. The payload `from` is advisory — it
114
+ * must match, and a missing `from` or an unparseable subject on a delivery is itself an anomaly.
115
+ * A rejected copy is `term()`ed (permanently invalid, never redelivered) and reported, and
116
+ * `undefined` returns, so no handler ever sees it. */
117
+ private authenticateStreamMsg;
118
+ /** Bind this endpoint's own existing DM durable and drive it serially (EndpointOptions.dmOnly).
119
+ * The bind is one CONSUMER.INFO on `dm_<owner>-<actor>-<uid>`; reading is MSG.NEXT with a batch
120
+ * of one, and the next copy reaches the handler only after the previous handler settles. */
121
+ bindDmOnly(mode: DmOnlyOptions): Promise<void>;
122
+ /** Open a native core subscription to a channel's live feed (the manager-free live read path,
123
+ * broker-enforced by `sub.allow`). At-most-once — no replay, no ack; it is the live delivery for
124
+ * every channel (boot + runtime). For a `durable` channel it is also the low-latency wake-hint
125
+ * alongside the Plane-3 durable copy, coalesced by the receiver's id-dedup. Drops our own echo +
126
+ * spoofed senders. */
127
+ subscribeChat(channel: string): void;
128
+ /** Close a channel's core subscription (manager-free leave). */
129
+ unsubscribeChat(channel: string): void;
130
+ /** Confirm a just-opened core subscription was accepted by the broker. A `sub.allow` violation is
131
+ * async in NATS, so flush (round-trips the SUB) then settle briefly to let the refusal land — a
132
+ * denied subscribe must not read as a successful join (SPEC conformance #13). */
133
+ confirmChatSub(): Promise<void>;
134
+ /** The durable's info (rebind) or null (fresh — 404). Gates create/backfill to the join event
135
+ * and exposes the current `filter_subjects` for restart reconciliation. */
136
+ consumerInfo(stream: string, durable: string): Promise<ConsumerInfo | null>;
137
+ /** Delete one named consumer, swallowing ONLY structured consumer/stream absence. */
138
+ deleteConsumerIfPresent(stream: string, durable: string): Promise<void>;
139
+ /** Whether this connection's account has a JetStream stream of this name. A missing stream is
140
+ * false. Any other failure is thrown, so a caller does not treat an unread broker as absence. */
141
+ streamRecorded(name: string): Promise<boolean>;
142
+ /** The bytes this connection's account holds in JetStream file storage, as `$JS.API.INFO`
143
+ * reports them. A broker's `max_file_store` cap counts every account it serves, so this is a
144
+ * lower bound on what that cap measures. */
145
+ storedBytes(): Promise<number>;
146
+ }
147
+ //# sourceMappingURL=endpoint-consumers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-consumers.d.ts","sourceRoot":"","sources":["../src/endpoint-consumers.ts"],"names":[],"mappings":"AAOA,OAAO,EAAyB,KAAK,aAAa,EAAsB,MAAM,uBAAuB,CAAC;AAItG,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAuC,MAAM,YAAY,CAAC;AACrG,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAkE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3L,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAE3G;;wFAEwF;AACxF,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,cAAc,GAAG,SAAS,CAAC;IACrC,GAAG,EAAE,MAAM,gBAAgB,GAAG,SAAS,CAAC;IACxC,MAAM,EAAE,CAAC,KAAK,EAAE,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AO,CAAC,MAAM,CAAC;IAMtC;;;;;;;qCAOiC;IACjC,OAAO,CAAC,UAAU;IA6BlB;;;;2DAIuD;IACvD,OAAO,CAAC,qBAAqB;IA6B7B;;iGAE6F;IACvF,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAwDpD;;;;2BAIuB;IACvB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAuDpC,gEAAgE;IAChE,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAatC;;sFAEkF;IAC5E,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAUrC;gFAC4E;IACtE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAWjF,qFAAqF;IAC/E,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7E;sGACkG;IAC5F,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAUpD;;iDAE6C;IACvC,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;CAGrC"}
@@ -0,0 +1,459 @@
1
+ // The durable consumers of CotalEndpoint, as an internal component: the JetStream manager, binding the DM
2
+ // inbox, chat and task consumers and pumping them, the DM-only bind, the per-channel chat subscriptions, and
3
+ // the consumer and stream reads. Moved verbatim from endpoint.ts; the endpoint keeps the fields and
4
+ // chatFrontier and forwards to these. Not re-exported by the index.
5
+ import { withDeadline } from "./deadline.js";
6
+ import { ackWaitOf, durableDelivery, isRecord } from "./endpoint-inbound.js";
7
+ import { authenticatedMessage, kindFromParsed, isUsableMessageId, isFromSubjectSender, dmOnlyDelivery } from "./endpoint-messages.js";
8
+ import { DmDurableMissingError, DmBindRefusedError } from "./endpoint-options.js";
9
+ import { isConsumerNotFound, isJetStreamMissing, isStreamNotFound } from "./jetstream-missing.js";
10
+ import { taskDurableConfig } from "./streams.js";
11
+ import { dmDurable, dmStream, taskStream, taskDurable, parseSubject, chatSubject } from "./subjects.js";
12
+ import { jetstreamManager, JetStreamApiCodes } from "@nats-io/jetstream";
13
+ import { PermissionViolationError } from "@nats-io/transport-node";
14
+ /** One endpoint's durable consumers. Internal: `CotalEndpoint` keeps the fields and forwards to it. */
15
+ export class EndpointConsumers {
16
+ deps;
17
+ constructor(deps) {
18
+ this.deps = deps;
19
+ }
20
+ get nc() { return this.deps.nc(); }
21
+ get jsm() { return this.deps.jsm(); }
22
+ set jsm(value) { this.deps.setJsm(value); }
23
+ get js() { return this.deps.js(); }
24
+ get space() { return this.deps.space(); }
25
+ get owner() { return this.deps.owner(); }
26
+ get actor() { return this.deps.actor(); }
27
+ get card() { return this.deps.card(); }
28
+ get authed() { return this.deps.authed(); }
29
+ get channels() { return this.deps.channels(); }
30
+ get ackWaitMs() { return this.deps.ackWaitMs(); }
31
+ get inactiveThresholdMs() { return this.deps.inactiveThresholdMs(); }
32
+ get firstConnect() { return this.deps.firstConnect(); }
33
+ set firstConnect(value) { this.deps.setFirstConnect(value); }
34
+ get backfillFloor() { return this.deps.backfillFloor(); }
35
+ get streamMsgs() { return this.deps.streamMsgs(); }
36
+ get taskEpoch() { return this.deps.taskEpoch(); }
37
+ set taskEpoch(value) { this.deps.setTaskEpoch(value); }
38
+ get stopped() { return this.deps.stopped(); }
39
+ get dmOnlyInFlight() { return this.deps.dmOnlyInFlight(); }
40
+ set dmOnlyInFlight(value) { this.deps.setDmOnlyInFlight(value); }
41
+ get chatSubs() { return this.deps.chatSubs(); }
42
+ get chatSubDenied() { return this.deps.chatSubDenied(); }
43
+ get chatSubRefusals() { return this.deps.chatSubRefusals(); }
44
+ get plane3Channels() { return this.deps.plane3Channels(); }
45
+ notLiveMsg() { return this.deps.notLiveMsg(); }
46
+ requireLifecycleUid(what) { return this.deps.requireLifecycleUid(what); }
47
+ ensureDmDurable(owner, actor, lifecycleUid, opts) { return this.deps.ensureDmDurable(owner, actor, lifecycleUid, opts); }
48
+ pumpDlv() { return this.deps.pumpDlv(); }
49
+ armJoin(channels) { return this.deps.armJoin(channels); }
50
+ backfillArmed(frontiers, floorSeq) { return this.deps.backfillArmed(frontiers, floorSeq); }
51
+ armBootDurableMemberships() { return this.deps.armBootDurableMemberships(); }
52
+ takeAnycast(role, seq, id, count, epoch, nak) { return this.deps.takeAnycast(role, seq, id, count, epoch, nak); }
53
+ emitRecoverable(err) { return this.deps.emitRecoverable(err); }
54
+ closeRefusedMembership(channel, generation) { return this.deps.closeRefusedMembership(channel, generation); }
55
+ emit(event, ...args) { return this.deps.emit(event, ...args); }
56
+ /** Lazily obtain a JetStream manager — so a non-consuming endpoint (e.g. the supervisor,
57
+ * consume:false) can still pre-create others' durables. */
58
+ async manager() {
59
+ if (!this.nc)
60
+ throw new Error(this.notLiveMsg());
61
+ this.jsm ??= await jetstreamManager(this.nc);
62
+ return this.jsm;
63
+ }
64
+ /** Bind this endpoint's durable consumers: DM inbox, chat, and (if a role) the task queue. */
65
+ async startConsumers() {
66
+ if (!this.jsm)
67
+ throw new Error(this.notLiveMsg());
68
+ // Unicast: this instance's private DM inbox, keyed on this endpoint's owner+actor principal. Open
69
+ // mode self-creates; auth mode BINDS a durable the provisioner pre-created (agents are denied
70
+ // CONSUMER.CREATE on DM_<space>, since the create-time filter_subject is the attack surface).
71
+ const ownUid = this.requireLifecycleUid("consuming the DM inbox");
72
+ if (!this.authed) {
73
+ // Open-mode self-create rides the SAME per-lifecycle ensure as the privileged pre-create: an
74
+ // existing `dm_…-<uid>` durable (this lifecycle's own restart) is kept with its ORIGINAL
75
+ // activation frontier; a fresh lifecycle captures its frontier at creation.
76
+ await this.ensureDmDurable(this.owner, this.actor, ownUid, {
77
+ ackWaitMs: this.ackWaitMs,
78
+ inactiveThresholdMs: this.inactiveThresholdMs,
79
+ });
80
+ }
81
+ const dm = dmDurable(this.owner, this.actor, ownUid);
82
+ try {
83
+ await this.pump(dmStream(this.space), dm, { inbox: true });
84
+ }
85
+ catch (e) {
86
+ // Auth mode cannot create the durable, so every rebind fails the same way until the session is
87
+ // replaced. The typed error lets a caller name that route instead of a bare "consumer not found".
88
+ if (this.authed && isConsumerNotFound(e))
89
+ throw new DmDurableMissingError(dmStream(this.space), dm);
90
+ throw e;
91
+ }
92
+ // Plane-3 (SPEC §8): bind + pump our per-member DELIVER durable (`dlv_<id>`) — the re-authorized
93
+ // durable-backstop channel copies the trusted reader transfers to us. No-op when it isn't present
94
+ // (open mode / un-provisioned). Auth-only feature; the pump self-guards on the durable's existence.
95
+ await this.pumpDlv();
96
+ // Multicast: open a native CORE subscription for each channel (live, manager-free, broker-enforced
97
+ // by sub.allow) — boot + runtime joins use the SAME path; there is no per-instance chat durable.
98
+ // The durable backstop (a busy/offline turn) is Plane-3 (auth: membership established by the agent's
99
+ // self-join, the delivery daemon's fan-out writer + trusted reader deliver via the `dlv_<id>` pump
100
+ // above; open dev mode is live-only — the durable plane needs the daemon's trusted reader, the
101
+ // security boundary). Per-
102
+ // channel history is the explicit replay-gated backfill, on FIRST connect only; a reconnect reopens
103
+ // the subs without re-backfilling (the durable backstop redelivers any missed window via dlv).
104
+ if (this.channels.length) {
105
+ // Arm the per-channel join watermarks BEFORE opening the subs: the backfill reads <= frontier and
106
+ // the core-sub delivers > frontier, so they never overlap (first connect). On reconnect we reopen
107
+ // without arming/backfilling.
108
+ const armed = this.firstConnect ? await this.armJoin(this.channels) : undefined;
109
+ for (const ch of this.channels)
110
+ this.subscribeChat(ch);
111
+ await this.confirmChatSub();
112
+ if (armed)
113
+ await this.backfillArmed(armed, this.backfillFloor);
114
+ }
115
+ // First connect, auth mode: self-join BOOT durable channels via the server-side delivery daemon
116
+ // (it owns membership now — there is no manager-written boot membership). Seeds plane3Channels so a
117
+ // later leave can tombstone the §7 boundary; idempotent on relaunch. Open mode has no Plane-3.
118
+ if (this.firstConnect && this.authed && this.channels.length)
119
+ await this.armBootDurableMemberships();
120
+ this.firstConnect = false;
121
+ // Anycast: a shared work-queue consumer for our role — one instance grabs each task.
122
+ // Open mode self-creates; auth mode BINDS the provisioner-pre-created svc_<role>
123
+ // durable (agents are denied CONSUMER.CREATE on TASK_<space>, since the create-time
124
+ // filter is the cross-role-drain attack surface — see provisionTaskQueue).
125
+ if (this.card.role) {
126
+ if (!this.authed) {
127
+ await this.jsm.consumers.add(taskStream(this.space), taskDurableConfig(this.space, this.card.role, { ackWaitMs: this.ackWaitMs }));
128
+ }
129
+ await this.pump(taskStream(this.space), taskDurable(this.card.role), this.authed ? { takeRole: this.card.role } : {});
130
+ }
131
+ }
132
+ /** Drive one consumer: decode and hand each message to listeners with ack control. Our own sends are
133
+ * delivered too: on the DM inbox and the role queue they were addressed to us, so none is an echo,
134
+ * and acking one unseen on the work queue would delete the only copy of the request. */
135
+ async pump(stream, durable, opts = {}) {
136
+ if (!this.js)
137
+ throw new Error(this.notLiveMsg());
138
+ const consumer = opts.takeRole === undefined
139
+ ? await this.js.consumers.get(stream, durable)
140
+ : await this.bindTaskConsumer(stream, durable);
141
+ const ackWaitMs = await ackWaitOf(consumer);
142
+ const msgs = await consumer.consume();
143
+ this.streamMsgs.push(msgs);
144
+ if (opts.inbox)
145
+ this.watchInbox(msgs, stream, durable);
146
+ void (async () => {
147
+ for await (const m of msgs) {
148
+ const authed = this.authenticateStreamMsg(m);
149
+ if (!authed)
150
+ continue;
151
+ const { msg, parsed } = authed;
152
+ const delivery = durableDelivery(m, ackWaitMs);
153
+ // On an auth mesh a role request carries its take: the holder records it with the delivery
154
+ // daemon before showing the request, so its sender can cancel it until then (SPEC §8.1).
155
+ // The copy carries the creation time of the stream it came from, read at bind.
156
+ const role = opts.takeRole;
157
+ if (role !== undefined) {
158
+ const epoch = this.taskEpoch;
159
+ delivery.take = () => this.takeAnycast(role, m.seq, msg.id, m.info.deliveryCount, epoch, () => m.nak());
160
+ }
161
+ this.emit("message", authenticatedMessage(msg, parsed), delivery, {
162
+ historical: false,
163
+ kind: kindFromParsed(parsed.kind),
164
+ });
165
+ }
166
+ })().catch((e) => {
167
+ if (!this.stopped)
168
+ this.emit("error", e);
169
+ });
170
+ }
171
+ /** Bind the role consumer and read the TASK stream's creation time on both sides of the bind, so
172
+ * the time belongs to the stream the consumer was bound on (SPEC §8.1). */
173
+ async bindTaskConsumer(stream, durable) {
174
+ for (let attempt = 0; attempt < 3; attempt++) {
175
+ const before = await this.readTaskEpoch();
176
+ const consumer = await this.js.consumers.get(stream, durable);
177
+ if (before === (await this.readTaskEpoch()))
178
+ return consumer;
179
+ }
180
+ throw new Error(`the ${stream} stream was recreated while its role consumer was binding; reconnect to bind it again`);
181
+ }
182
+ /** Read the TASK stream's creation time into {@link taskEpoch}. */
183
+ async readTaskEpoch() {
184
+ const epoch = (await (await this.manager()).streams.info(taskStream(this.space))).created;
185
+ this.taskEpoch = epoch;
186
+ return epoch;
187
+ }
188
+ /** Warn once when the broker reports this endpoint's own DM inbox missing while the connection is
189
+ * up, as after a store reset that the client's reconnect rode through, or after a manager restart
190
+ * deletes the inbox. nats.js keeps checking and resumes pulling if the inbox comes back, so this
191
+ * only reports. A `consumer_deleted` status is the consumer going away, so it warns at once. A
192
+ * not-found can be a passing state, so that warning waits for a second report; the several 409s a
193
+ * delete answers pending pulls with count once. A pull means the consumer was found again, which
194
+ * re-arms the warning. The loop ends when the consumer is stopped, by `stop()` or by a rebuild
195
+ * replacing this connection. */
196
+ watchInbox(msgs, stream, durable) {
197
+ const boundNc = this.nc;
198
+ void (async () => {
199
+ let absences = 0;
200
+ let deleted = false;
201
+ for await (const s of msgs.status()) {
202
+ if (this.stopped || this.nc !== boundNc)
203
+ break;
204
+ if (s.type === "next") {
205
+ absences = 0;
206
+ deleted = false;
207
+ continue;
208
+ }
209
+ if (s.type === "consumer_deleted") {
210
+ if (deleted)
211
+ continue;
212
+ deleted = true;
213
+ absences = 1; // the deletion itself is the second report: warn on this one
214
+ }
215
+ else if (s.type !== "consumer_not_found" && s.type !== "stream_not_found")
216
+ continue;
217
+ if (++absences === 2)
218
+ this.emitRecoverable(new Error(`DM inbox missing: the broker reports consumer "${durable}" on stream "${stream}" missing, so direct ` +
219
+ "messages to this endpoint are not delivered. The endpoint keeps checking; if the inbox does not " +
220
+ "come back, end this session and start a new one"));
221
+ }
222
+ })().catch((e) => {
223
+ if (!this.stopped)
224
+ this.emit("error", e);
225
+ });
226
+ }
227
+ /** Decode one stream copy and apply the authenticity guard (fail closed): the sender is encoded in
228
+ * the subject, which the server policed who could publish. The payload `from` is advisory — it
229
+ * must match, and a missing `from` or an unparseable subject on a delivery is itself an anomaly.
230
+ * A rejected copy is `term()`ed (permanently invalid, never redelivered) and reported, and
231
+ * `undefined` returns, so no handler ever sees it. */
232
+ authenticateStreamMsg(m) {
233
+ let msg;
234
+ try {
235
+ msg = m.json();
236
+ }
237
+ catch (e) {
238
+ m.term(); // undecodable — never redeliver
239
+ this.emit("error", e);
240
+ return undefined;
241
+ }
242
+ if (!isRecord(msg) || !isUsableMessageId(msg.id)) {
243
+ m.term(); // malformed envelope (SPEC sec 5): absent/non-string id — permanently invalid
244
+ this.emit("error", new Error(`dropped message on ${m.subject}: absent or non-string id`));
245
+ return undefined;
246
+ }
247
+ const parsed = parseSubject(m.subject);
248
+ if (!parsed || !isFromSubjectSender(msg, parsed)) {
249
+ m.term();
250
+ this.emit("error", new Error(`dropped message on ${m.subject}: payload from ${msg.from?.id ?? "(none)"} ` +
251
+ `does not match subject sender ${parsed?.sender ?? "(unparseable)"}`));
252
+ return undefined;
253
+ }
254
+ return { msg, parsed };
255
+ }
256
+ /** Bind this endpoint's own existing DM durable and drive it serially (EndpointOptions.dmOnly).
257
+ * The bind is one CONSUMER.INFO on `dm_<owner>-<actor>-<uid>`; reading is MSG.NEXT with a batch
258
+ * of one, and the next copy reaches the handler only after the previous handler settles. */
259
+ async bindDmOnly(mode) {
260
+ if (!this.js)
261
+ throw new Error(this.notLiveMsg());
262
+ const stream = dmStream(this.space);
263
+ const durable = dmDurable(this.owner, this.actor, this.requireLifecycleUid("consuming the DM inbox"));
264
+ let consumer;
265
+ try {
266
+ consumer = await this.js.consumers.get(stream, durable);
267
+ }
268
+ catch (e) {
269
+ if (isJetStreamMissing(e, JetStreamApiCodes.ConsumerNotFound))
270
+ throw new DmDurableMissingError(stream, durable);
271
+ throw new DmBindRefusedError(stream, durable, e);
272
+ }
273
+ const ackWaitMs = await ackWaitOf(consumer); // cached by the bind's own CONSUMER.INFO, no request
274
+ // A rebind after reconnect must not overlap the previous epoch's running handler. A handler that
275
+ // does not settle within the stop bound fails this bind; the retry loop tries again.
276
+ if (this.dmOnlyInFlight) {
277
+ const settleMs = mode.settleTimeoutMs ?? 30_000;
278
+ await withDeadline(this.dmOnlyInFlight, settleMs, () => new Error(`DM-only rebind waited ${settleMs}ms for the previous handler to settle; not reading the next DM yet`));
279
+ }
280
+ const msgs = await consumer.consume({ max_messages: 1 });
281
+ this.streamMsgs.push(msgs);
282
+ // The epoch this loop belongs to. nats.js can yield copies it already received after stop() began
283
+ // or after a rebuild replaced the connection (a stacked pull after a missed-heartbeat reset hands
284
+ // over several at once). Such a copy never reaches the handler and is neither acked nor nak'd:
285
+ // the connection is closing or closed, so any reply could be lost, and the broker redelivers an
286
+ // unacked copy after the durable's ack_wait to whichever epoch binds next.
287
+ const boundNc = this.nc;
288
+ const retired = () => this.stopped || this.nc !== boundNc || !boundNc || boundNc.isClosed();
289
+ void (async () => {
290
+ for await (const m of msgs) {
291
+ if (retired())
292
+ break;
293
+ const authed = this.authenticateStreamMsg(m);
294
+ if (!authed)
295
+ continue;
296
+ if (authed.parsed.kind !== "inst") {
297
+ m.term(); // the DM stream filter admits only inst.* subjects; anything else is not a DM
298
+ continue;
299
+ }
300
+ const run = Promise.resolve().then(() => mode.handler(authenticatedMessage(authed.msg, authed.parsed), dmOnlyDelivery(m, ackWaitMs, boundNc), {
301
+ historical: false,
302
+ kind: "dm",
303
+ }));
304
+ const flight = run.then(() => { }, () => { });
305
+ this.dmOnlyInFlight = flight;
306
+ try {
307
+ await run;
308
+ }
309
+ catch (e) {
310
+ this.emit("error", e instanceof Error ? e : new Error(String(e)));
311
+ }
312
+ finally {
313
+ if (this.dmOnlyInFlight === flight)
314
+ this.dmOnlyInFlight = undefined;
315
+ }
316
+ }
317
+ })().catch((e) => {
318
+ if (!this.stopped)
319
+ this.emit("error", e);
320
+ });
321
+ }
322
+ /** Open a native core subscription to a channel's live feed (the manager-free live read path,
323
+ * broker-enforced by `sub.allow`). At-most-once — no replay, no ack; it is the live delivery for
324
+ * every channel (boot + runtime). For a `durable` channel it is also the low-latency wake-hint
325
+ * alongside the Plane-3 durable copy, coalesced by the receiver's id-dedup. Drops our own echo +
326
+ * spoofed senders. */
327
+ subscribeChat(channel) {
328
+ if (!this.nc || this.chatSubs.has(channel))
329
+ return;
330
+ this.chatSubDenied.delete(channel);
331
+ const subject = chatSubject(this.space, "*", "*", channel);
332
+ const sub = this.nc.subscribe(subject, {
333
+ callback: (err, m) => {
334
+ if (err) {
335
+ // async sub.allow refusal (or sub error): the live feed for this channel is dead — never a
336
+ // leak (the broker refused it). Drop the channel from local joined state even if it was
337
+ // already treated as joined — a LATE refusal beyond the confirm window: conformance #13
338
+ // "drop on late refusal". (During the join's own confirm the channel isn't pushed yet, so
339
+ // this fires nothing then; joinChannel reads `chatSubDenied` and throws cleanly.) Either way
340
+ // the refusal is reported from here, by that throw or the leave below, so watchStatus skips it.
341
+ if (err instanceof PermissionViolationError)
342
+ this.chatSubRefusals.add(err);
343
+ this.chatSubDenied.add(channel);
344
+ this.chatSubs.delete(channel);
345
+ const i = this.channels.indexOf(channel);
346
+ if (i >= 0) {
347
+ this.channels.splice(i, 1);
348
+ // A late sub.allow refusal forces this agent out of the channel (the broker revoked its live
349
+ // read). If it held a Plane-3 durable membership, the §7 boundary must close too. This sub
350
+ // callback can't await, so a fail-closed async helper RETRIES the tombstone (backoff) UNTIL it
351
+ // succeeds, clearing the mirror only then; while pending it is surfaced via cotal_channels —
352
+ // never a silent drop, never lost retry state.
353
+ const gen = this.plane3Channels.get(channel);
354
+ if (gen !== undefined)
355
+ void this.closeRefusedMembership(channel, gen);
356
+ this.emit("error", new Error(`left channel "${channel}": its live subscription was refused by the broker`, { cause: err }));
357
+ }
358
+ return;
359
+ }
360
+ const parsed = parseSubject(m.subject);
361
+ if (!parsed || parsed.kind !== "chat")
362
+ return;
363
+ let msg;
364
+ try {
365
+ msg = m.json();
366
+ }
367
+ catch (e) {
368
+ this.emit("error", e);
369
+ return;
370
+ }
371
+ if (!isRecord(msg) || !isUsableMessageId(msg.id))
372
+ return; // malformed envelope (SPEC sec 5) — live is at-most-once: drop
373
+ if (!isFromSubjectSender(msg, parsed))
374
+ return; // spoof/malformed/old-shape-alias — drop (at-most-once)
375
+ if (msg.from.id === this.card.id)
376
+ return; // our own echo
377
+ const delivery = { ack: () => { }, nak: () => { }, durable: false }; // live = at-most-once, not acked
378
+ this.emit("message", authenticatedMessage(msg, parsed), delivery, {
379
+ historical: false,
380
+ kind: kindFromParsed(parsed.kind),
381
+ });
382
+ },
383
+ });
384
+ this.chatSubs.set(channel, sub);
385
+ }
386
+ /** Close a channel's core subscription (manager-free leave). */
387
+ unsubscribeChat(channel) {
388
+ const sub = this.chatSubs.get(channel);
389
+ if (sub) {
390
+ try {
391
+ sub.unsubscribe();
392
+ }
393
+ catch {
394
+ /* closing with the connection */
395
+ }
396
+ this.chatSubs.delete(channel);
397
+ }
398
+ this.chatSubDenied.delete(channel);
399
+ }
400
+ /** Confirm a just-opened core subscription was accepted by the broker. A `sub.allow` violation is
401
+ * async in NATS, so flush (round-trips the SUB) then settle briefly to let the refusal land — a
402
+ * denied subscribe must not read as a successful join (SPEC conformance #13). */
403
+ async confirmChatSub() {
404
+ if (!this.nc)
405
+ throw new Error("connection not established");
406
+ // flush() is the deterministic boundary: the broker's -ERR for an out-of-ACL SUB arrives BEFORE the
407
+ // PONG, so once flush resolves the subscribe callback has already recorded any denial. A flush
408
+ // FAILURE means the connection drained/closed mid-join — we have no confirmation, so let it throw
409
+ // (joinChannel fails closed) instead of swallowing it and continuing as if confirmed.
410
+ await this.nc.flush();
411
+ await new Promise((r) => setTimeout(r, 50));
412
+ }
413
+ /** The durable's info (rebind) or null (fresh — 404). Gates create/backfill to the join event
414
+ * and exposes the current `filter_subjects` for restart reconciliation. */
415
+ async consumerInfo(stream, durable) {
416
+ if (!this.jsm)
417
+ throw new Error(this.notLiveMsg());
418
+ try {
419
+ return await this.jsm.consumers.info(stream, durable);
420
+ }
421
+ catch (e) {
422
+ if (isJetStreamMissing(e, JetStreamApiCodes.ConsumerNotFound))
423
+ return null; // structured absence — fresh durable
424
+ throw e;
425
+ }
426
+ }
427
+ /** Delete one named consumer, swallowing ONLY structured consumer/stream absence. */
428
+ async deleteConsumerIfPresent(stream, durable) {
429
+ if (!this.jsm)
430
+ throw new Error(this.notLiveMsg());
431
+ try {
432
+ await this.jsm.consumers.delete(stream, durable);
433
+ }
434
+ catch (e) {
435
+ if (!isJetStreamMissing(e, JetStreamApiCodes.ConsumerNotFound, JetStreamApiCodes.StreamNotFound))
436
+ throw e;
437
+ }
438
+ }
439
+ /** Whether this connection's account has a JetStream stream of this name. A missing stream is
440
+ * false. Any other failure is thrown, so a caller does not treat an unread broker as absence. */
441
+ async streamRecorded(name) {
442
+ try {
443
+ await (await this.manager()).streams.info(name);
444
+ return true;
445
+ }
446
+ catch (e) {
447
+ if (isStreamNotFound(e))
448
+ return false;
449
+ throw e;
450
+ }
451
+ }
452
+ /** The bytes this connection's account holds in JetStream file storage, as `$JS.API.INFO`
453
+ * reports them. A broker's `max_file_store` cap counts every account it serves, so this is a
454
+ * lower bound on what that cap measures. */
455
+ async storedBytes() {
456
+ return (await (await this.manager()).getAccountInfo()).storage;
457
+ }
458
+ }
459
+ //# sourceMappingURL=endpoint-consumers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-consumers.js","sourceRoot":"","sources":["../src/endpoint-consumers.ts"],"names":[],"mappings":"AAAA,0GAA0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