@cotal-ai/core 0.166.3 → 0.168.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.
- package/dist/agent-endpoint.d.ts +242 -0
- package/dist/agent-endpoint.d.ts.map +1 -0
- package/dist/agent-endpoint.js +183 -0
- package/dist/agent-endpoint.js.map +1 -0
- package/dist/backup-config.d.ts +2 -2
- package/dist/endpoint-call.d.ts +36 -1
- package/dist/endpoint-call.d.ts.map +1 -1
- package/dist/endpoint-call.js +218 -116
- package/dist/endpoint-call.js.map +1 -1
- package/dist/endpoint-cluster.d.ts +6 -1
- package/dist/endpoint-cluster.d.ts.map +1 -1
- package/dist/endpoint-cluster.js +25 -1
- package/dist/endpoint-cluster.js.map +1 -1
- package/dist/endpoint-delivery-lease.d.ts +184 -0
- package/dist/endpoint-delivery-lease.d.ts.map +1 -0
- package/dist/endpoint-delivery-lease.js +270 -0
- package/dist/endpoint-delivery-lease.js.map +1 -0
- package/dist/endpoint-envelope.d.ts +4 -3
- package/dist/endpoint-envelope.d.ts.map +1 -1
- package/dist/endpoint-envelope.js +19 -2
- package/dist/endpoint-envelope.js.map +1 -1
- package/dist/endpoint-grants.d.ts +31 -1
- package/dist/endpoint-grants.d.ts.map +1 -1
- package/dist/endpoint-grants.js +62 -1
- package/dist/endpoint-grants.js.map +1 -1
- package/dist/endpoint-presence.d.ts +296 -0
- package/dist/endpoint-presence.d.ts.map +1 -0
- package/dist/endpoint-presence.js +784 -0
- package/dist/endpoint-presence.js.map +1 -0
- package/dist/endpoint-provenance.d.ts +11 -0
- package/dist/endpoint-provenance.d.ts.map +1 -0
- package/dist/endpoint-provenance.js +20 -0
- package/dist/endpoint-provenance.js.map +1 -0
- package/dist/endpoint-serve.d.ts +76 -2
- package/dist/endpoint-serve.d.ts.map +1 -1
- package/dist/endpoint-serve.js +332 -147
- package/dist/endpoint-serve.js.map +1 -1
- package/dist/endpoint-service.d.ts +5 -1
- package/dist/endpoint-service.d.ts.map +1 -1
- package/dist/endpoint-service.js +2 -1
- package/dist/endpoint-service.js.map +1 -1
- package/dist/endpoint-subjects.d.ts +76 -2
- package/dist/endpoint-subjects.d.ts.map +1 -1
- package/dist/endpoint-subjects.js +113 -2
- package/dist/endpoint-subjects.js.map +1 -1
- package/dist/endpoint-verbs.d.ts +1 -1
- package/dist/endpoint-verbs.d.ts.map +1 -1
- package/dist/endpoint-verbs.js +1 -1
- package/dist/endpoint-verbs.js.map +1 -1
- package/dist/endpoint.d.ts +132 -188
- package/dist/endpoint.d.ts.map +1 -1
- package/dist/endpoint.js +380 -790
- package/dist/endpoint.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/peer-label.d.ts +6 -5
- package/dist/peer-label.d.ts.map +1 -1
- package/dist/peer-label.js +7 -6
- package/dist/peer-label.js.map +1 -1
- package/dist/provision-jwt.d.ts +518 -0
- package/dist/provision-jwt.d.ts.map +1 -0
- package/dist/provision-jwt.js +641 -0
- package/dist/provision-jwt.js.map +1 -0
- package/dist/provision-permissions.d.ts +72 -0
- package/dist/provision-permissions.d.ts.map +1 -0
- package/dist/provision-permissions.js +2009 -0
- package/dist/provision-permissions.js.map +1 -0
- package/dist/provision-resources.d.ts +66 -0
- package/dist/provision-resources.d.ts.map +1 -0
- package/dist/provision-resources.js +61 -0
- package/dist/provision-resources.js.map +1 -0
- package/dist/provision-server-config.d.ts +115 -0
- package/dist/provision-server-config.d.ts.map +1 -0
- package/dist/provision-server-config.js +169 -0
- package/dist/provision-server-config.js.map +1 -0
- package/dist/provision.d.ts +19 -701
- package/dist/provision.d.ts.map +1 -1
- package/dist/provision.js +4 -2835
- package/dist/provision.js.map +1 -1
- package/dist/subjects.d.ts +3 -2
- package/dist/subjects.d.ts.map +1 -1
- package/dist/subjects.js +10 -2
- package/dist/subjects.js.map +1 -1
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import type { ConsumerInfo } from "@nats-io/jetstream";
|
|
2
|
+
import type { KV } from "@nats-io/kv";
|
|
3
|
+
import { type NatsConnection } from "@nats-io/transport-node";
|
|
4
|
+
import type { AgentCard, Presence, PresenceStatus, PresenceCondition, PresencePrompts, AttentionMode, ChannelMode } from "./types.js";
|
|
5
|
+
type PresenceWatch = Awaited<ReturnType<KV["watch"]>>;
|
|
6
|
+
/** Live connection dependencies shared with the endpoint's other broker readers. */
|
|
7
|
+
export interface EndpointPresenceDeps {
|
|
8
|
+
card: () => AgentCard;
|
|
9
|
+
space: () => string;
|
|
10
|
+
bucket: () => KV | undefined;
|
|
11
|
+
connection: () => NatsConnection | undefined;
|
|
12
|
+
lifecycleUid: () => string | undefined;
|
|
13
|
+
/** The `prompts` field this process's presence carries now, or none (SPEC §6). */
|
|
14
|
+
prompts: () => PresencePrompts | undefined;
|
|
15
|
+
ttlMs: () => number;
|
|
16
|
+
registers: () => boolean;
|
|
17
|
+
watches: () => boolean;
|
|
18
|
+
readsOnce: () => boolean;
|
|
19
|
+
stopped: () => boolean;
|
|
20
|
+
reconnecting: () => boolean;
|
|
21
|
+
epoch: () => number;
|
|
22
|
+
notLiveMsg: () => string;
|
|
23
|
+
bindWatch: (kv: KV) => Promise<{
|
|
24
|
+
iter: PresenceWatch;
|
|
25
|
+
info: ConsumerInfo;
|
|
26
|
+
} | undefined>;
|
|
27
|
+
retireWatch: (iter: PresenceWatch) => void;
|
|
28
|
+
emit: (event: string, value: unknown) => boolean;
|
|
29
|
+
recoverable: (error: Error) => void;
|
|
30
|
+
isPublishPermissionDenied: (error: unknown) => boolean;
|
|
31
|
+
}
|
|
32
|
+
/** Trust state of this endpoint's local presence roster. `fresh` remains for older consumers:
|
|
33
|
+
* unpopulated is deliberately false so they fail toward unknown rather than treating a partial
|
|
34
|
+
* reconnect snapshot as an authoritative absence verdict. */
|
|
35
|
+
export type PresenceView = {
|
|
36
|
+
state: "current";
|
|
37
|
+
fresh: true;
|
|
38
|
+
} | {
|
|
39
|
+
state: "unpopulated";
|
|
40
|
+
fresh: false;
|
|
41
|
+
} | {
|
|
42
|
+
state: "stale";
|
|
43
|
+
fresh: false;
|
|
44
|
+
staleSince: number;
|
|
45
|
+
};
|
|
46
|
+
/** A presence bucket that has refused consecutive writes for at least one full presence TTL.
|
|
47
|
+
* The condition is non-transient: ordinary heartbeat retry has already failed for the whole
|
|
48
|
+
* liveness window, so callers should report the roster as last-known until a write succeeds. */
|
|
49
|
+
export declare class PresenceWriteStuckError extends Error {
|
|
50
|
+
readonly bucket: string;
|
|
51
|
+
readonly since: number;
|
|
52
|
+
readonly consecutiveFailures: number;
|
|
53
|
+
readonly ttlMs: number;
|
|
54
|
+
readonly lastError?: string | undefined;
|
|
55
|
+
readonly code: "presence-write-stuck";
|
|
56
|
+
readonly transient: false;
|
|
57
|
+
constructor(bucket: string, since: number, consecutiveFailures: number, ttlMs: number, lastError?: string | undefined);
|
|
58
|
+
}
|
|
59
|
+
/** Presence publication, local roster materialization and observer freshness for one endpoint. */
|
|
60
|
+
export declare class EndpointPresence {
|
|
61
|
+
private readonly deps;
|
|
62
|
+
/** #1356: when the presence bucket started refusing writes; undefined once one succeeds. */
|
|
63
|
+
private presenceWriteFailingSince?;
|
|
64
|
+
/** #1356: the broker's last refusal message, kept alongside the start time for diagnosis. */
|
|
65
|
+
private lastPresenceWriteError?;
|
|
66
|
+
/** Consecutive latest-evidence refusals on the current connection epoch. A success resets it. */
|
|
67
|
+
private presenceWriteFailures;
|
|
68
|
+
/** One named non-transient warning per failed run. A success re-arms it. */
|
|
69
|
+
private presenceWriteEscalated;
|
|
70
|
+
/** #1461: monotonic per-put generation on the presence path, so a settle can tell whether it is
|
|
71
|
+
* the latest evidence on its epoch. {@link publishPresence} snapshots it at put start and every
|
|
72
|
+
* settle records its generation here: a settle is the latest evidence only while no put that
|
|
73
|
+
* started after it has already settled. */
|
|
74
|
+
private presencePutGeneration;
|
|
75
|
+
/** #1461: the generation of the newest presence put that has SETTLED (succeeded or rejected),
|
|
76
|
+
* or `undefined` when none ever has. A put that is merely in flight is not evidence yet. */
|
|
77
|
+
private presencePutSettled?;
|
|
78
|
+
private readonly roster;
|
|
79
|
+
/** The {@link readPresence} in flight; calls made before it settles share it. */
|
|
80
|
+
private presenceRead?;
|
|
81
|
+
/** Orders {@link readPresence} merges: a read that settles after a newer one was applied is dropped. */
|
|
82
|
+
private presenceReadGeneration;
|
|
83
|
+
private presenceReadApplied;
|
|
84
|
+
/** Resolves when the current presence watch has consumed its complete initial KV snapshot. */
|
|
85
|
+
private presenceSnapshot;
|
|
86
|
+
/** False from connection reset until the watch marks the last entry in its initial replay. */
|
|
87
|
+
private presenceSnapshotPopulated;
|
|
88
|
+
/**
|
|
89
|
+
* Observer-local age of the last presence-KV delivery (any key, including DEL/PURGE). Distinct
|
|
90
|
+
* from each peer's `ts`: that is the publisher's heartbeat. Whole-bucket silence past TTL is
|
|
91
|
+
* the observer going deaf, not N simultaneous deaths, and sweep must not treat it as the
|
|
92
|
+
* latter (#1045).
|
|
93
|
+
*/
|
|
94
|
+
private lastPresenceWatchAt;
|
|
95
|
+
/** Last emitted presence-view state. Suppresses duplicate `presence-view` events. */
|
|
96
|
+
private presenceViewState;
|
|
97
|
+
/** A presence-watch rebind in flight (see {@link rebindStalePresenceWatch}); one at a time. */
|
|
98
|
+
private presenceRebind?;
|
|
99
|
+
/** The current watch was bound onto a bucket with NO keys (see {@link markPresenceBucketEmpty}).
|
|
100
|
+
* Such a watch cannot deliver until someone writes, so its silence is not staleness. */
|
|
101
|
+
private presenceWatchEmpty;
|
|
102
|
+
/** Wall-clock of the last rebind attempt, so a bucket that is silent because it is EMPTY (or a
|
|
103
|
+
* broker that keeps refusing the consumer create) is retried once per TTL, not per sweep tick. */
|
|
104
|
+
private presenceRebindAt;
|
|
105
|
+
private status;
|
|
106
|
+
private activity?;
|
|
107
|
+
/** When {@link status} or {@link activity} last changed. Heartbeats republish it unchanged. */
|
|
108
|
+
private statusSince;
|
|
109
|
+
/** When {@link activity} last changed. A status change leaves it alone. */
|
|
110
|
+
private activitySince?;
|
|
111
|
+
/** Last harness-reported work progress. Carried by the next heartbeat, never published per event. */
|
|
112
|
+
private activeAt?;
|
|
113
|
+
private condition?;
|
|
114
|
+
/** Advances on every condition change so an older in-flight put cannot be the final KV state. */
|
|
115
|
+
private conditionRevision;
|
|
116
|
+
/** Read once at construction. Core publishes this opaque provider reference and never parses it. */
|
|
117
|
+
private environment?;
|
|
118
|
+
/** Mirror of the connector's authoritative attention state, published in presence (advisory). The
|
|
119
|
+
* endpoint never reads these back into delivery - they exist only to broadcast. */
|
|
120
|
+
private attentionMode?;
|
|
121
|
+
private channelModes?;
|
|
122
|
+
/** Presence rows rejected because their embedded id did not match the ACL-scoped KV key, or because
|
|
123
|
+
* a field the observer computes with was malformed. */
|
|
124
|
+
private presenceBindingDrops;
|
|
125
|
+
/** The presence/channel-registry watches' own handles. Each is an ORDERED push consumer: its idle
|
|
126
|
+
* heartbeat monitor lives on a JS timer independent of the connection, so a drain that doesn't
|
|
127
|
+
* `.stop()` it first leaves the monitor to fire into a closing connection every 30s, throwing
|
|
128
|
+
* `DrainingConnectionError` out of `reset()` on a timer nothing awaits. */
|
|
129
|
+
private presenceWatchIter?;
|
|
130
|
+
constructor(deps: EndpointPresenceDeps);
|
|
131
|
+
private get card();
|
|
132
|
+
private get space();
|
|
133
|
+
private get kv();
|
|
134
|
+
private get nc();
|
|
135
|
+
private get ownLifecycleUid();
|
|
136
|
+
private get ttlMs();
|
|
137
|
+
private get doRegister();
|
|
138
|
+
private get doWatch();
|
|
139
|
+
private get readOnce();
|
|
140
|
+
private get stopped();
|
|
141
|
+
private get reconnecting();
|
|
142
|
+
private get presenceEpoch();
|
|
143
|
+
private notLiveMsg;
|
|
144
|
+
private bindKvWatch;
|
|
145
|
+
private retireKvWatch;
|
|
146
|
+
private emit;
|
|
147
|
+
private emitRecoverable;
|
|
148
|
+
configureEnvironment(environment: string | undefined): void;
|
|
149
|
+
seedChannelModes(modes: Record<string, ChannelMode> | undefined): void;
|
|
150
|
+
get bindingDropCount(): number;
|
|
151
|
+
values(): IterableIterator<Presence>;
|
|
152
|
+
cancelRebind(): void;
|
|
153
|
+
retireWatch(): void;
|
|
154
|
+
publishOffline(): Promise<void>;
|
|
155
|
+
resetConnection(): void;
|
|
156
|
+
getRoster(): Presence[];
|
|
157
|
+
/**
|
|
158
|
+
* Read the roster from the broker now, for an endpoint that does not watch presence (SPEC §6). One
|
|
159
|
+
* batched Direct Get of the bucket that binds no consumer, decoded and dropped as the watch decodes.
|
|
160
|
+
* A record that says `offline` or whose `ts` is past the liveness window reads offline. A peer an
|
|
161
|
+
* earlier read saw that is gone from the bucket stays in the roster as offline, as a watch keeps
|
|
162
|
+
* it. The result is also what {@link getRoster} returns until the next read.
|
|
163
|
+
*
|
|
164
|
+
* Calls made while a read is in flight share it, and every other call reads anew, so a verdict
|
|
165
|
+
* never rests on a read that settled before it was asked. A failed read throws and changes
|
|
166
|
+
* nothing. A credential that may not make the read is refused with the grant it lacks.
|
|
167
|
+
*/
|
|
168
|
+
readPresence(): Promise<Presence[]>;
|
|
169
|
+
/**
|
|
170
|
+
* Trust state of THIS observer's presence watch, not of any peer. `unpopulated` means the
|
|
171
|
+
* current watch has not completed its initial snapshot, so {@link getRoster} may be partial and
|
|
172
|
+
* cannot support an absence verdict. `stale` means the whole bucket has been silent past the
|
|
173
|
+
* liveness window, so the roster is last-known as of `staleSince`. `fresh` is false for both
|
|
174
|
+
* unsafe states so consumers written before `state` was added degrade in the safe direction.
|
|
175
|
+
*/
|
|
176
|
+
presenceView(): PresenceView;
|
|
177
|
+
/** Wait until the current presence watch has consumed its initial KV snapshot. An observer that
|
|
178
|
+
* does not register completes on an empty bucket at once. A registering one completes when its
|
|
179
|
+
* own record arrives, and the timeout bounds that wait. */
|
|
180
|
+
waitForPresenceSnapshot(timeoutMs?: number): Promise<"snapshot" | "timeout">;
|
|
181
|
+
private assertPresenceUpdate;
|
|
182
|
+
setActivity(activity: string): Promise<void>;
|
|
183
|
+
/** Set the status, and with `activity` the activity line too, in one presence write, so no peer sees
|
|
184
|
+
* the new activity beside the old status. */
|
|
185
|
+
setStatus(status: PresenceStatus, activity?: string): Promise<void>;
|
|
186
|
+
/** Record harness-reported work progress as `activeAt`. It writes nothing itself: the next heartbeat
|
|
187
|
+
* carries it, so a stream of events costs no presence writes. */
|
|
188
|
+
noteActivity(at?: number): void;
|
|
189
|
+
/** Publish a harness-reported condition, or clear it. Core stores the relay without interpretation. */
|
|
190
|
+
setCondition(condition: PresenceCondition | null): Promise<void>;
|
|
191
|
+
/** Publish the agent's global attention mode into presence (advisory observability). Mirror only -
|
|
192
|
+
* delivery decisions stay in the connector's authoritative state. */
|
|
193
|
+
setAttention(attention: AttentionMode): Promise<void>;
|
|
194
|
+
/** Publish the agent's per-channel attention overrides into presence (advisory). An empty map drops
|
|
195
|
+
* the field. Mirror only - never read back into delivery. */
|
|
196
|
+
setChannelModes(modes: Record<string, ChannelMode>): Promise<void>;
|
|
197
|
+
publishPresence(): Promise<void>;
|
|
198
|
+
/** #1356: drop the presence-refusal record when the connection that OBSERVED those refusals goes
|
|
199
|
+
* away. "This bucket is refusing writes" is a claim about a specific broker connection; once that
|
|
200
|
+
* connection is torn down or rebuilt the claim has no remaining basis, and a later failure on a
|
|
201
|
+
* fresh connection must establish it again from its own evidence.
|
|
202
|
+
*
|
|
203
|
+
* Cleared at the SOURCE rather than guarded at each reader, because a guard protects one consumer
|
|
204
|
+
* and clearing protects every consumer, including ones not yet written. Measured: without this, a
|
|
205
|
+
* failed bind against an unreachable server still reported the presence-refusal sentence while the
|
|
206
|
+
* endpoint's own `connectionIssue` already said "connection refused". */
|
|
207
|
+
clearPresenceWriteFailure(): void;
|
|
208
|
+
/** A heartbeat retry remains recoverable inside one TTL. Once two or more consecutive writes have
|
|
209
|
+
* failed across the full window, ordinary retry has exhausted the roster's liveness budget: raise
|
|
210
|
+
* one named, non-transient warning. Later failures keep the duration/count current without flooding
|
|
211
|
+
* the operator log; the next successful write clears and re-arms the condition. */
|
|
212
|
+
private escalatePresenceWriteFailureIfStuck;
|
|
213
|
+
/** #1356: the presence bucket has been refusing writes since this time, or `undefined` when the
|
|
214
|
+
* last publish succeeded. Cleared by a successful write that is the latest evidence on its
|
|
215
|
+
* epoch (#1461), so a survived blip reads as healthy and only a SUSTAINED failure carries a
|
|
216
|
+
* duration.
|
|
217
|
+
*
|
|
218
|
+
* Presence writes are the CANARY, not the scope: the broker can disable JetStream account-wide
|
|
219
|
+
* while the NATS connection stays up, so a caller must not read this as "only presence is
|
|
220
|
+
* affected". It reports what was observed, not how far the fault extends. */
|
|
221
|
+
presenceWriteFailure(): {
|
|
222
|
+
since: number;
|
|
223
|
+
forMs: number;
|
|
224
|
+
error?: string;
|
|
225
|
+
bucket: string;
|
|
226
|
+
consecutiveFailures: number;
|
|
227
|
+
stuck: boolean;
|
|
228
|
+
} | undefined;
|
|
229
|
+
/** Bind a presence watch on the current connection. Resolves the bound consumer's info when
|
|
230
|
+
* the watch was installed, undefined when the endpoint stopped or rebuilt while the bind was
|
|
231
|
+
* in flight: that bind's watch is retired by {@link bindKvWatch} and nothing is installed,
|
|
232
|
+
* because the epoch that asked for it is gone and the epoch that replaced it binds its own
|
|
233
|
+
* watch through the endpoint connection bind. Without this fence a bind that completes after
|
|
234
|
+
* endpoint shutdown would resurrect a watch on a stopped endpoint, and one that completes after a
|
|
235
|
+
* rebuild would overwrite the fresh epoch's watch with a dead-connection iterator. */
|
|
236
|
+
startPresenceWatch(): Promise<ConsumerInfo | undefined>;
|
|
237
|
+
/** `readOnce`: fill the roster from one read of the presence bucket. Stale
|
|
238
|
+
* and offline records resolve as they do in a watch's initial replay. */
|
|
239
|
+
readPresenceOnce(): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* Replace a presence watch that has gone silent past TTL while the connection is up. The new
|
|
242
|
+
* ordered consumer starts from the bucket's current last-per-subject state, so a peer that is
|
|
243
|
+
* heartbeating is re-observed within one replay and a peer that is gone is aged out by the
|
|
244
|
+
* next sweep exactly as if the watch had never stalled. Rate-limited to one attempt per TTL
|
|
245
|
+
* per observer, never overlapping, never on a stopped or rebuilding endpoint (those own their
|
|
246
|
+
* watch through the endpoint connection bind). A stop or rebuild that lands while the bind is in
|
|
247
|
+
* flight retires it: {@link startPresenceWatch} retires the late watch and reports
|
|
248
|
+
* nothing, since the epoch that was silent no longer exists. A failed bind is reported and
|
|
249
|
+
* the view stays stale.
|
|
250
|
+
*/
|
|
251
|
+
private rebindStalePresenceWatch;
|
|
252
|
+
/** The watch was just bound onto a bucket with no keys.
|
|
253
|
+
*
|
|
254
|
+
* A NON-REGISTERING observer (a `cotal status` probe, a lease checker) has real knowledge:
|
|
255
|
+
* nobody is present. Every peer still in its roster is known gone (its key is not there to
|
|
256
|
+
* replay), so it is marked offline now rather than aged out against a delivery that cannot
|
|
257
|
+
* come; the silence gate is disarmed and the view reads current until the first write lands.
|
|
258
|
+
* Without that the empty-bucket view relapsed to stale one window later and rebound again on
|
|
259
|
+
* every window, one consumer create and one warning per TTL for as long as the mesh was empty.
|
|
260
|
+
*
|
|
261
|
+
* A REGISTERING observer (the manager) is itself one of the keys that should be there. An
|
|
262
|
+
* empty bucket under it means the bucket was wiped since its last heartbeat (the stream
|
|
263
|
+
* recreation), and the same wipe took every peer's record: their absence says the bucket is
|
|
264
|
+
* new, not that they left. a reviewer reproduced the previous behaviour at default timing:
|
|
265
|
+
* the rebind landed ~0.9s after the recreation, the observer marked every peer AND ITSELF
|
|
266
|
+
* offline, and held the view current for up to one heartbeat, a false verdict `cotal ps`
|
|
267
|
+
* would print as `mesh offline`. So a registering observer re-publishes its own record NOW,
|
|
268
|
+
* which the new watch delivers, and lets the ordinary per-peer age-out run from that delivery:
|
|
269
|
+
* a peer that is still heartbeating rewrites its key within its own heartbeat interval and is
|
|
270
|
+
* re-observed live; one that is gone ages out exactly as after a plain rebind. The roster is
|
|
271
|
+
* not touched here and the view is not held; the delivery is what makes it current.
|
|
272
|
+
*
|
|
273
|
+
* What neither branch covers: a consumer that dies again while the bucket is still empty is
|
|
274
|
+
* not detectable by silence, so the first write after that is missed until the observer
|
|
275
|
+
* restarts. */
|
|
276
|
+
private onPresenceBucketEmpty;
|
|
277
|
+
/** See {@link onPresenceBucketEmpty}: the non-registering branch. */
|
|
278
|
+
private markPresenceBucketEmpty;
|
|
279
|
+
private handleKvEntry;
|
|
280
|
+
/** The record a presence PUT carries, or undefined when a reader must drop it (SPEC §6). The watch
|
|
281
|
+
* and {@link readPresence} decode through this one gate, so they drop the same records. */
|
|
282
|
+
private decodePresence;
|
|
283
|
+
private applyPresence;
|
|
284
|
+
/** Materialize an OFFLINE presence record: drop the advisory attention fields. An offline peer must
|
|
285
|
+
* not show a stale `[focus]` or "locally muted #x" hint - SPEC: attention removed on offline sweep,
|
|
286
|
+
* channel modes reset on restart. `statusSince` goes too: it dated the live status, and an observer
|
|
287
|
+
* that derives offline from a stale heartbeat does not know when the peer left. `prompts` goes as
|
|
288
|
+
* well: an offline process serves nothing. card/activity/ts are kept. */
|
|
289
|
+
private toOffline;
|
|
290
|
+
/** Mark a known peer offline (on KV delete/purge), keeping it in the roster. */
|
|
291
|
+
private markOffline;
|
|
292
|
+
private emitPresenceViewIfChanged;
|
|
293
|
+
sweep(): void;
|
|
294
|
+
}
|
|
295
|
+
export {};
|
|
296
|
+
//# sourceMappingURL=endpoint-presence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-presence.d.ts","sourceRoot":"","sources":["../src/endpoint-presence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,EAAE,EAAW,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,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