madeonsol-x402 4.2.0 → 4.4.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.
@@ -0,0 +1,548 @@
1
+ /* Mirrored from src/lib/terminal-realtime/watch.ts; see SDK parity tests. */
2
+ /**
3
+ * Framework-agnostic terminal snapshot/stream bridge (#534).
4
+ *
5
+ * A shared SDK socket supplies push frames. Snapshot reads happen once after
6
+ * the named subscription is ACKED, then only on coalesced, named invalidations.
7
+ * This deliberately NEVER patches REST module data from unrelated clocks.
8
+ *
9
+ * Instantiate once per selected token, reusing one existing stream connection.
10
+ * The controller never closes that shared stream on dispose().
11
+ */
12
+ import { planTerminalWatch, rulesForEvent, TERMINAL_MODULE_COSTS, } from "./terminal-policy.js";
13
+ const ACK_SUBSCRIBE = "subscribed";
14
+ const MAX_DEDUPE_IDS = 512;
15
+ /** Bounded by nine modules and one frame per live overlay; never a trade queue. */
16
+ export class TerminalTokenView {
17
+ plan;
18
+ opts;
19
+ listeners = new Map();
20
+ dirty = new Set();
21
+ stale = new Set();
22
+ seen = new Map();
23
+ live = {};
24
+ gen = new Map();
25
+ lastRead = new Map();
26
+ now;
27
+ timer = null;
28
+ timerAt = 0;
29
+ busy = false;
30
+ /** If the socket ACK arrives while a prior REST read is still unresolved,
31
+ * the latest post-ACK snapshot must run after that read settles. */
32
+ pendingBootstrap = false;
33
+ subscribed = false;
34
+ epoch = 0;
35
+ phase = "idle";
36
+ incomplete = false;
37
+ /** An observed historical gap survives a new REST snapshot and reconnect. */
38
+ gapUnresolved = false;
39
+ /** A named subscription ACK never proves that its resume finished. */
40
+ replayPending = false;
41
+ replayUnverified = false;
42
+ replayComplete = false;
43
+ continuityStatus = "initial";
44
+ lastDisconnectedAt = null;
45
+ lastReplayAt = null;
46
+ lastError = null;
47
+ snapshot = null;
48
+ /**
49
+ * Modules not yet successfully re-read since the latest ACK/disconnect. A
50
+ * replay_end or a targeted refresh of ONE module must not report "live"
51
+ * while another module still shows its pre-disconnect REST value.
52
+ */
53
+ baselineMissing = new Set();
54
+ constructor(options) {
55
+ if (typeof options.subId !== "string" || !/^[A-Za-z0-9_.-]{1,64}$/.test(options.subId) || options.subId === "default") {
56
+ throw new Error("named_sub_id_required");
57
+ }
58
+ const n = options.minModuleRefreshMs ?? 15_000;
59
+ const d = options.debounceMs ?? 750;
60
+ if (!Number.isFinite(n) || n < 1_000 || n > 600_000 ||
61
+ !Number.isFinite(d) || d < 0 || d > 30_000)
62
+ throw new Error("invalid_refresh_budget");
63
+ this.plan = planTerminalWatch(options);
64
+ this.opts = options;
65
+ this.now = options.now ?? Date.now;
66
+ for (const m of this.plan.include) {
67
+ this.gen.set(m, 0);
68
+ this.baselineMissing.add(m);
69
+ }
70
+ }
71
+ getView() {
72
+ return {
73
+ phase: this.phase, address: this.plan.address, chain: this.plan.chain,
74
+ snapshot: this.snapshot,
75
+ live: { ...this.live },
76
+ stale: [...this.stale],
77
+ no_push: [...this.plan.modules_without_push],
78
+ incomplete: this.incomplete,
79
+ last_error: this.lastError,
80
+ continuity: {
81
+ status: this.continuityStatus,
82
+ last_disconnected_at_ms: this.lastDisconnectedAt,
83
+ last_replay_at_ms: this.lastReplayAt,
84
+ this_subscription_replay_complete: this.replayComplete,
85
+ },
86
+ };
87
+ }
88
+ /** Registers handlers BEFORE opening the stream; first REST read waits for ACK. */
89
+ start() {
90
+ if (this.phase !== "idle")
91
+ throw new Error("already_started");
92
+ this.phase = this.plan.channels.length ? "awaiting_subscribe" : "bootstrapping";
93
+ this.emit();
94
+ if (!this.plan.channels.length) {
95
+ this.continuityStatus = "snapshot_only";
96
+ void this.fetchModules(this.plan.include, true);
97
+ return;
98
+ }
99
+ this.listen("*", (data, frame) => this.onFrame(frame));
100
+ this.listen(ACK_SUBSCRIBE, (_channels, ack) => this.onSubscribed(ack));
101
+ // The shared managed stream emits one aggregate "replay" when ALL named
102
+ // subscriptions have ended. Inspect ends[sub_id], NOT the aggregate complete
103
+ // flag: another terminal panel's successful replay cannot certify ours.
104
+ this.listen("replay", result => this.onReplay(result));
105
+ this.listen("close", () => {
106
+ if (this.phase === "stopped")
107
+ return;
108
+ // A fetch launched on the old socket can no longer be trusted. In
109
+ // particular, neither a new ACK nor REST first paint proves that lost
110
+ // historical events were replayed across the disconnection.
111
+ this.epoch++;
112
+ this.pendingBootstrap = false;
113
+ this.subscribed = false;
114
+ this.replayPending = true;
115
+ this.replayUnverified = true;
116
+ this.replayComplete = false;
117
+ this.lastDisconnectedAt = this.now();
118
+ this.continuityStatus = this.gapUnresolved ? "historical_gap" : "replay_pending";
119
+ this.lastError = this.gapUnresolved ? "stream_gap" : "stream_disconnected";
120
+ this.clearLive(); // old price ticks must not masquerade as live prices
121
+ this.requireBaseline();
122
+ this.incomplete = true;
123
+ this.phase = "awaiting_subscribe";
124
+ this.markStale(this.plan.include);
125
+ this.clearTimer();
126
+ this.emit();
127
+ });
128
+ this.listen("warning", (warn) => this.onWarning(warn));
129
+ this.listen("gap", (gap) => this.onGap(gap));
130
+ this.listen("fatal", () => {
131
+ this.epoch++;
132
+ this.pendingBootstrap = false;
133
+ this.subscribed = false;
134
+ this.replayPending = false;
135
+ this.replayUnverified = true;
136
+ this.replayComplete = false;
137
+ this.continuityStatus = this.gapUnresolved ? "historical_gap" : "replay_unverified";
138
+ this.lastError = this.gapUnresolved ? "stream_gap" : "stream_fatal";
139
+ this.clearLive();
140
+ this.incomplete = true;
141
+ this.phase = "degraded";
142
+ this.markStale(this.plan.include);
143
+ this.clearTimer();
144
+ this.emit();
145
+ });
146
+ this.opts.stream.subscribe({
147
+ subId: this.opts.subId,
148
+ channels: [...this.plan.channels],
149
+ filters: this.plan.filters,
150
+ });
151
+ }
152
+ /** Consumer-initiated refresh, useful after a known unrecoverable gap. */
153
+ refresh() {
154
+ if (this.phase === "idle" || this.phase === "stopped")
155
+ throw new Error("watch_not_active");
156
+ this.markStale(this.plan.include);
157
+ for (const m of this.plan.include)
158
+ this.dirty.add(m);
159
+ this.schedule(0);
160
+ }
161
+ /**
162
+ * The caller must independently reconcile an unrecoverable event interval
163
+ * BEFORE clearing the visible gap. A fresh snapshot is not that evidence.
164
+ */
165
+ acknowledgeHistoricalRecovery() {
166
+ if ((!this.gapUnresolved && !this.replayUnverified && !this.replayPending) ||
167
+ this.phase === "stopped" || this.phase === "idle")
168
+ return;
169
+ // The integrator is claiming it independently verified the lost window.
170
+ // Do NOT call the SDK's acceptGap() here or move an SDK cursor.
171
+ this.gapUnresolved = false;
172
+ this.replayPending = false;
173
+ this.replayUnverified = false;
174
+ this.continuityStatus = this.subscribed ? "externally_reconciled" : "replay_unverified";
175
+ this.incomplete = !this.subscribed;
176
+ this.lastError = this.incomplete ? "stream_disconnected" : null;
177
+ if (!this.incomplete && this.snapshot && this.baselineMissing.size === 0)
178
+ this.phase = "live";
179
+ this.emit();
180
+ }
181
+ dispose() {
182
+ if (this.phase === "stopped")
183
+ return;
184
+ this.epoch++;
185
+ this.pendingBootstrap = false;
186
+ this.phase = "stopped";
187
+ this.subscribed = false;
188
+ this.clearTimer();
189
+ for (const [event, fn] of this.listeners)
190
+ this.opts.stream.off(event, fn);
191
+ this.listeners.clear();
192
+ if (this.plan.channels.length)
193
+ this.opts.stream.unsubscribe(this.opts.subId);
194
+ this.emit();
195
+ }
196
+ isStopped() { return this.phase === "stopped"; }
197
+ requireBaseline() {
198
+ for (const m of this.plan.include)
199
+ this.baselineMissing.add(m);
200
+ }
201
+ /** Phase after a continuity change; never "live" on a partial baseline. */
202
+ settledPhase() {
203
+ if (this.busy && this.phase === "bootstrapping")
204
+ return "bootstrapping";
205
+ if (this.incomplete)
206
+ return "degraded";
207
+ if (!this.snapshot || this.baselineMissing.size > 0)
208
+ return this.busy ? "bootstrapping" : "degraded";
209
+ return "live";
210
+ }
211
+ clearLive() {
212
+ for (const m of Object.keys(this.live))
213
+ delete this.live[m];
214
+ }
215
+ // A throwing UI callback must never leave the controller half-updated.
216
+ emit() { try {
217
+ this.opts.onChange?.(this.getView());
218
+ }
219
+ catch { /* consumer */ } }
220
+ listen(event, cb) {
221
+ this.listeners.set(event, cb);
222
+ this.opts.stream.on(event, cb);
223
+ }
224
+ onSubscribed(ack) {
225
+ if (this.phase === "stopped" || !ack || ack.sub_id !== this.opts.subId)
226
+ return;
227
+ const channels = Array.isArray(ack.channels) ? ack.channels : [];
228
+ // A partial or silently rejected subscription cannot be treated as live.
229
+ if (!this.plan.channels.every(ch => channels.includes(ch))) {
230
+ this.incomplete = true;
231
+ this.subscribed = false;
232
+ this.lastError = "subscription_incomplete";
233
+ this.phase = "degraded";
234
+ this.markStale(this.plan.include);
235
+ this.emit();
236
+ return;
237
+ }
238
+ // Invalidate any in-flight REST read from before this ACK/reconnect.
239
+ this.epoch++;
240
+ this.subscribed = true;
241
+ // Re-ACK proves a live subscription again, not that old trade events
242
+ // reported missing by the SDK have been reconstructed.
243
+ this.incomplete = this.gapUnresolved || this.replayPending || this.replayUnverified;
244
+ this.continuityStatus = this.gapUnresolved ? "historical_gap"
245
+ : this.replayPending ? "replay_pending"
246
+ : this.replayUnverified ? "replay_unverified" : this.continuityStatus;
247
+ this.lastError = this.gapUnresolved ? "stream_gap"
248
+ : this.replayPending ? "replay_pending"
249
+ : this.replayUnverified ? "replay_unverified" : null;
250
+ this.clearTimer();
251
+ // A re-subscribe after reconnect ALWAYS re-reads a bounded snapshot. We
252
+ // cannot compare clocks from REST and WS as one total-order watermark.
253
+ this.phase = "bootstrapping";
254
+ this.requireBaseline();
255
+ this.pendingBootstrap = true;
256
+ for (const m of this.plan.include)
257
+ this.dirty.add(m);
258
+ this.emit();
259
+ if (!this.busy) {
260
+ this.pendingBootstrap = false;
261
+ void this.fetchModules(this.plan.include, true);
262
+ }
263
+ }
264
+ /**
265
+ * A successful SDK aggregate replay is relevant only when its per-subscribe
266
+ * replay_end for OUR named subscription says complete=true. REST freshness
267
+ * alone cannot certify recovered KOL/trade/risk events.
268
+ */
269
+ onReplay(value) {
270
+ if (!this.subscribed || this.isStopped() || !value || typeof value !== "object")
271
+ return;
272
+ const r = value;
273
+ const ends = r.ends;
274
+ if (!ends || typeof ends !== "object" || Array.isArray(ends) ||
275
+ !Object.prototype.hasOwnProperty.call(ends, this.opts.subId))
276
+ return;
277
+ const own = ends[this.opts.subId];
278
+ if (!own || typeof own !== "object" || Array.isArray(own))
279
+ return;
280
+ const complete = own.complete === true;
281
+ this.replayPending = false;
282
+ this.replayUnverified = !complete;
283
+ this.replayComplete = complete;
284
+ if (complete)
285
+ this.lastReplayAt = this.now();
286
+ this.incomplete = this.gapUnresolved || !complete;
287
+ this.continuityStatus = this.gapUnresolved ? "historical_gap"
288
+ : complete ? "replay_complete" : "replay_unverified";
289
+ this.lastError = this.gapUnresolved ? "stream_gap" : complete ? null : "replay_unverified";
290
+ // A replay proof does not replace a post-ACK HTTP read; remain bootstrapping
291
+ // until the read has actually landed, and degraded if that read failed.
292
+ this.phase = this.settledPhase();
293
+ this.emit();
294
+ }
295
+ onWarning(value) {
296
+ if (!value || typeof value !== "object" || this.phase === "stopped")
297
+ return;
298
+ const w = value;
299
+ // Named-subscription warnings always carry sub_id; one without it belongs
300
+ // to the connection default subscription, not this terminal view.
301
+ if (w.sub_id !== this.opts.subId)
302
+ return;
303
+ if (["channels_rejected", "channels_revoked", "named_subscriptions_unsupported", "invalid_filters",
304
+ // The server refuses the whole subscribe with these and sends NO ack.
305
+ "too_many_subscriptions", "invalid_sub_id", "unknown_sub_id"].includes(String(w.code))) {
306
+ // An already-started read cannot certify a revoked/invalid connection.
307
+ this.epoch++;
308
+ this.pendingBootstrap = false;
309
+ this.subscribed = false;
310
+ this.replayPending = false;
311
+ this.replayUnverified = true;
312
+ this.replayComplete = false;
313
+ this.continuityStatus = this.gapUnresolved ? "historical_gap" : "replay_unverified";
314
+ this.clearLive();
315
+ this.incomplete = true;
316
+ this.lastError = String(w.code);
317
+ this.phase = "degraded";
318
+ this.clearTimer();
319
+ this.markStale(this.plan.include);
320
+ this.emit();
321
+ }
322
+ }
323
+ onGap(value) {
324
+ if (this.phase === "stopped" || !value || typeof value !== "object")
325
+ return;
326
+ const gap = value;
327
+ const entries = gap.channels && typeof gap.channels === "object" ? Object.keys(gap.channels) : [];
328
+ // The managed SDK emits aggregate gaps. A gap with no channel detail may
329
+ // belong ONLY to another named subscription. If our own replay_end
330
+ // explicitly says complete:true, do not poison this panel with a sibling's
331
+ // error. With missing own proof, fail conservatively and keep it visible.
332
+ const ends = (gap.replay && typeof gap.replay === "object" &&
333
+ gap.replay.ends);
334
+ const own = ends && Object.prototype.hasOwnProperty.call(ends, this.opts.subId)
335
+ ? ends[this.opts.subId] : null;
336
+ const ownComplete = !!own && typeof own === "object" &&
337
+ own.complete === true;
338
+ const ownIncomplete = !!own && typeof own === "object" &&
339
+ own.complete === false;
340
+ const channelBelongs = entries.some(ch => ch.startsWith(this.opts.subId + "/") || ch === this.opts.subId);
341
+ const belongs = channelBelongs || ownIncomplete || (entries.length === 0 && !ownComplete);
342
+ if (!belongs)
343
+ return;
344
+ this.gapUnresolved = true;
345
+ this.clearLive();
346
+ this.continuityStatus = "historical_gap";
347
+ this.incomplete = true;
348
+ this.lastError = "stream_gap";
349
+ this.phase = "degraded";
350
+ this.markStale(this.plan.include);
351
+ // If the gap arrives during a REST fetch it must not let that fetch clear
352
+ // stale just because a frame did not increment the generation.
353
+ for (const m of this.plan.include)
354
+ this.gen.set(m, (this.gen.get(m) ?? 0) + 1);
355
+ // Snapshot resync is bounded, but not proof that missing historical events
356
+ // (KOL, executed trades) can be reconstructed. Keep incomplete=true.
357
+ if (this.subscribed) {
358
+ for (const m of this.plan.include)
359
+ this.dirty.add(m);
360
+ this.schedule(0);
361
+ }
362
+ this.emit();
363
+ }
364
+ onFrame(frame) {
365
+ if (!frame || !this.subscribed || this.phase === "stopped" ||
366
+ frame.sub_id !== this.opts.subId)
367
+ return;
368
+ const matches = rulesForEvent(frame, this.plan);
369
+ if (!matches.length)
370
+ return;
371
+ if (frame.id) {
372
+ const key = this.opts.subId + ":" + frame.channel + ":" + frame.id;
373
+ if (this.seen.has(key))
374
+ return;
375
+ this.seen.set(key, this.now());
376
+ if (this.seen.size > MAX_DEDUPE_IDS)
377
+ this.seen.delete(this.seen.keys().next().value);
378
+ }
379
+ for (const rule of matches) {
380
+ if (rule.delivery === "overlay") {
381
+ // State ticks carry no cursor; never let a late/replayed tick replace
382
+ // a newer overlay that is already on screen.
383
+ const prev = this.live[rule.module];
384
+ if (prev && typeof prev.ts === "number" && typeof frame.ts === "number" && frame.ts < prev.ts)
385
+ continue;
386
+ this.live[rule.module] = frame;
387
+ try {
388
+ this.opts.onLive?.(frame, rule.module);
389
+ }
390
+ catch { /* consumer */ }
391
+ }
392
+ else {
393
+ this.markStale([rule.module]);
394
+ this.dirty.add(rule.module);
395
+ // A failed post-ACK read is never retried on its own; the next
396
+ // invalidation carries the missing baseline modules with it.
397
+ if (!this.busy)
398
+ for (const m of this.baselineMissing)
399
+ this.dirty.add(m);
400
+ // Only an INVALIDATION may make an in-flight read stale. An overlay tick
401
+ // supersedes the REST price on screen; counting it would re-read the
402
+ // snapshot module after every read on any actively traded token.
403
+ this.gen.set(rule.module, (this.gen.get(rule.module) ?? 0) + 1);
404
+ }
405
+ }
406
+ this.emit();
407
+ // A degraded view (visible gap, failed read) must keep refreshing its
408
+ // invalidated modules on a subscribed socket; schedule() refuses otherwise.
409
+ if ((this.phase === "live" || this.phase === "degraded") && this.dirty.size > 0)
410
+ this.schedule();
411
+ }
412
+ markStale(modules) {
413
+ for (const m of modules)
414
+ this.stale.add(m);
415
+ }
416
+ clearTimer() {
417
+ if (this.timer !== null)
418
+ clearTimeout(this.timer);
419
+ this.timer = null;
420
+ }
421
+ schedule(delay) {
422
+ if (this.phase === "stopped" || this.phase === "idle" || this.busy ||
423
+ (this.plan.channels.length > 0 && !this.subscribed))
424
+ return;
425
+ const now = this.now();
426
+ const minGap = this.opts.minModuleRefreshMs ?? 15_000;
427
+ // Wake when the FIRST dirty module is eligible; flush() skips the others
428
+ // until their own budget allows, then reschedules.
429
+ let earliest = Infinity;
430
+ for (const m of this.dirty)
431
+ earliest = Math.min(earliest, (this.lastRead.get(m) ?? -Infinity) + minGap - now);
432
+ if (!Number.isFinite(earliest))
433
+ earliest = 0;
434
+ const wait = Math.max(delay ?? (this.opts.debounceMs ?? 750), earliest, 0);
435
+ // A pending flush may only be moved EARLIER, never later. A trailing-edge
436
+ // debounce reset on every event can starve a hot mint forever when trades
437
+ // arrive faster than debounceMs, leaving token intelligence permanently stale.
438
+ if (this.timer !== null) {
439
+ if (now + wait >= this.timerAt)
440
+ return;
441
+ clearTimeout(this.timer);
442
+ }
443
+ this.timerAt = now + wait;
444
+ this.timer = setTimeout(() => { this.timer = null; void this.flush(); }, wait);
445
+ }
446
+ async flush() {
447
+ if (this.busy || this.phase === "stopped" || this.dirty.size === 0)
448
+ return;
449
+ if (this.plan.channels.length > 0 && !this.subscribed)
450
+ return;
451
+ const modules = [];
452
+ const now = this.now();
453
+ const minGap = this.opts.minModuleRefreshMs ?? 15_000;
454
+ let cost = 0;
455
+ for (const m of this.dirty) {
456
+ // Newer invalidations may join a timer that was scheduled for an older
457
+ // module. They must still honour their OWN per-module refresh budget.
458
+ if (now < (this.lastRead.get(m) ?? -Infinity) + minGap)
459
+ continue;
460
+ const next = TERMINAL_MODULE_COSTS[m];
461
+ if (modules.length >= 5 || cost + next > 8)
462
+ break;
463
+ modules.push(m);
464
+ cost += next;
465
+ }
466
+ if (!modules.length) {
467
+ this.schedule();
468
+ return;
469
+ }
470
+ for (const m of modules)
471
+ this.dirty.delete(m);
472
+ await this.fetchModules(modules, false);
473
+ }
474
+ async fetchModules(modules, initial) {
475
+ if (this.busy || this.phase === "stopped")
476
+ return;
477
+ this.busy = true;
478
+ // The initial ACK already put all modules in dirty. Consume that batch
479
+ // before the read; a new frame during I/O can add a fresh invalidation.
480
+ for (const m of modules)
481
+ this.dirty.delete(m);
482
+ const epoch = this.epoch;
483
+ const seen = new Map(modules.map(m => [m, this.gen.get(m) ?? 0]));
484
+ const now = this.now();
485
+ for (const m of modules)
486
+ this.lastRead.set(m, now);
487
+ try {
488
+ const incoming = await this.opts.read(modules);
489
+ if (this.isStopped() || epoch !== this.epoch)
490
+ return;
491
+ if (incoming.chain !== this.plan.chain ||
492
+ (this.plan.chain === "solana" ? incoming.address !== this.plan.address :
493
+ incoming.address.toLowerCase() !== this.plan.address))
494
+ throw new Error("snapshot_identity_mismatch");
495
+ if (!incoming.modules || typeof incoming.modules !== "object")
496
+ throw new Error("invalid_snapshot_modules");
497
+ for (const m of modules)
498
+ if (!incoming.modules[m])
499
+ throw new Error("missing_snapshot_module:" + m);
500
+ this.snapshot = this.snapshot && !initial
501
+ ? { ...incoming, modules: { ...this.snapshot.modules, ...incoming.modules } }
502
+ : incoming;
503
+ for (const m of modules) {
504
+ this.baselineMissing.delete(m);
505
+ if ((this.gen.get(m) ?? 0) === seen.get(m))
506
+ this.stale.delete(m);
507
+ else
508
+ this.dirty.add(m);
509
+ }
510
+ // HTTP first paint is never a proof of socket replay or missing history.
511
+ this.lastError = this.gapUnresolved ? "stream_gap"
512
+ : this.replayPending ? "replay_pending"
513
+ : this.replayUnverified ? "replay_unverified"
514
+ : this.baselineMissing.size ? "snapshot_refresh_pending" : null;
515
+ this.phase = this.incomplete || this.baselineMissing.size ? "degraded" : "live";
516
+ }
517
+ catch (error) {
518
+ if (this.isStopped() || epoch !== this.epoch)
519
+ return;
520
+ this.lastError = error instanceof Error ? error.message : "snapshot_failed";
521
+ this.markStale(modules);
522
+ this.phase = "degraded";
523
+ // Do not automatically retry a failed DB/RPC call: the next event or an
524
+ // explicit refresh can trigger another, still rate-limited, request.
525
+ }
526
+ finally {
527
+ this.busy = false;
528
+ if (!this.isStopped()) {
529
+ this.emit();
530
+ if (this.pendingBootstrap && this.subscribed) {
531
+ // A reconnect occurred while the old read was busy. Only the NEW
532
+ // post-ACK full snapshot can establish a fresh baseline; a targeted
533
+ // merge onto the old one is not sufficient.
534
+ this.pendingBootstrap = false;
535
+ void this.fetchModules(this.plan.include, true);
536
+ }
537
+ else if (this.dirty.size > 0 && this.subscribed) {
538
+ this.schedule();
539
+ }
540
+ }
541
+ }
542
+ }
543
+ }
544
+ /** A named subscription prevents overwriting an integrator's other filters. */
545
+ export function createTerminalTokenView(options) {
546
+ return new TerminalTokenView(options);
547
+ }
548
+ //# sourceMappingURL=terminal-watch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal-watch.js","sourceRoot":"","sources":["../src/terminal-watch.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E;;;;;;;;;GASG;AACH,OAAO,EACL,iBAAiB,EAAE,aAAa,EAAE,qBAAqB,GAExD,MAAM,sBAAsB,CAAC;AA2F9B,MAAM,aAAa,GAAG,YAAY,CAAC;AACnC,MAAM,cAAc,GAAG,GAAG,CAAC;AAG3B,mFAAmF;AACnF,MAAM,OAAO,iBAAiB;IACnB,IAAI,CAAoB;IAChB,IAAI,CAAsB;IAC1B,SAAS,GAAG,IAAI,GAAG,EAAmB,CAAC;IACvC,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IAClC,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IAClC,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;IACjC,IAAI,GAAyD,EAAE,CAAC;IAChE,GAAG,GAAG,IAAI,GAAG,EAA0B,CAAC;IACxC,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC7C,GAAG,CAAe;IAC3B,KAAK,GAAyC,IAAI,CAAC;IACnD,OAAO,GAAG,CAAC,CAAC;IACZ,IAAI,GAAG,KAAK,CAAC;IACrB;wEACoE;IAC5D,gBAAgB,GAAG,KAAK,CAAC;IACzB,UAAU,GAAG,KAAK,CAAC;IACnB,KAAK,GAAG,CAAC,CAAC;IACV,KAAK,GAAkB,MAAM,CAAC;IAC9B,UAAU,GAAG,KAAK,CAAC;IAC3B,6EAA6E;IACrE,aAAa,GAAG,KAAK,CAAC;IAC9B,sEAAsE;IAC9D,a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CAAC,CAAC;YACxB,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC;YACxB,wEAAwE;YACxE,qEAAqE;QACvE,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;YAClB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;gBACtB,IAAI,CAAC,IAAI,EAAE,CAAC;gBACZ,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBAC7C,iEAAiE;oBACjE,oEAAoE;oBACpE,4CAA4C;oBAC5C,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;oBAC9B,KAAK,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAClD,CAAC;qBAAM,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,+EAA+E;AAC/E,MAAM,UAAU,uBAAuB,CAAC,OAA4B;IAClE,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Solana terminal integration over existing REST + managed WebSocket (#534).
3
+ *
4
+ * A shared SDK socket is REQUIRED. We do not open a socket per token widget,
5
+ * and no REST module is refetched on every price tick. Each terminal must use
6
+ * its own explicit named subscription, and each disconnect/replay gap is visible.
7
+ *
8
+ * This adapter does NOT make the selected token's historical capture complete.
9
+ */
10
+ import type { MadeOnSolREST } from "./index.js";
11
+ import type { MadeOnSolStream } from "./stream.js";
12
+ import type { TokenIntelligenceModuleId } from "./types.js";
13
+ import { type TerminalStreamPort, type TerminalTokenView, type TerminalView, type TerminalStreamFrame } from "./terminal-watch.js";
14
+ import type { TerminalTier, TerminalModule } from "./terminal-policy.js";
15
+ export interface SolanaTerminalWatchOptions {
16
+ /** Caller-selected modules, obeying existing API budget (at most 5, cost <=8). */
17
+ include: readonly TokenIntelligenceModuleId[];
18
+ /** Account's current tier. Server still enforces its authoritative entitlement. */
19
+ tier: TerminalTier;
20
+ /** Reuse ONE existing client.stream() across terminal widgets. */
21
+ stream: MadeOnSolStream;
22
+ /** Unique per shared connection, 1..64 chars, A-Z a-z 0-9 _ . - */
23
+ subId: string;
24
+ /** Subscribe to global, unscoped KOL broadcasts (may be high bandwidth). */
25
+ includeKolBroadcast?: boolean;
26
+ /** Min interval between REST refreshes for any invalidated module. Default 15s. */
27
+ minModuleRefreshMs?: number;
28
+ debounceMs?: number;
29
+ /** Snapshot, stale module names, live overlays and historical gap status. */
30
+ onChange?: (view: TerminalView) => void;
31
+ onLive?: (frame: TerminalStreamFrame, module: TerminalModule) => void;
32
+ }
33
+ /**
34
+ * The existing stream's public `on` overloads use specific event signatures.
35
+ * Narrowly adapt those overloads to the small event-port used by the shared
36
+ * controller, without changing stream/client behavior.
37
+ *
38
+ * Exported for BROWSER terminals that must not hold an API key: pair it with
39
+ * `createTerminalTokenView({ stream: terminalStreamPort(stream), read })`, where
40
+ * `stream` gets its short-lived token from your backend (`getToken`) and `read`
41
+ * calls your backend, which calls the keyed intelligence endpoint.
42
+ */
43
+ export declare function terminalStreamPort(stream: MadeOnSolStream): TerminalStreamPort;
44
+ /** Creates an active, terminal-scoped view; returns a handle with dispose(). */
45
+ export declare function createSolanaTerminalWatch(client: MadeOnSolREST, mint: string, options: SolanaTerminalWatchOptions): TerminalTokenView;
46
+ //# sourceMappingURL=terminal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,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