instar 0.28.94 → 0.28.95

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 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkQH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAw4CD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAs9JtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkQH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAw4CD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAqhKtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
@@ -4549,6 +4549,79 @@ export async function startServer(options) {
4549
4549
  });
4550
4550
  promiseBeacon.start();
4551
4551
  globalThis.__instarPromiseBeacon = promiseBeacon;
4552
+ // ── "keep watching" resume detector ─────────────────────────────
4553
+ // When a user replies on a topic that has any auto-paused beacons,
4554
+ // a literal "keep watching" match resumes them. Brittle detector
4555
+ // (regex) with no blocking authority — it only triggers the
4556
+ // structurally-symmetric /resume endpoint. False-positive cost:
4557
+ // one extra heartbeat that re-pauses on next idle cycle.
4558
+ const KEEP_WATCHING_RE = /\bkeep[\s-]?watching\b/i;
4559
+ const previousTelegramHook = telegram.onMessageLogged;
4560
+ telegram.onMessageLogged = (entry) => {
4561
+ if (previousTelegramHook)
4562
+ previousTelegramHook(entry);
4563
+ if (!entry.fromUser)
4564
+ return;
4565
+ if (!entry.topicId)
4566
+ return;
4567
+ if (!entry.text || !KEEP_WATCHING_RE.test(entry.text))
4568
+ return;
4569
+ const topicId = entry.topicId;
4570
+ const paused = commitmentTracker
4571
+ .getActive()
4572
+ .filter(c => c.topicId === topicId && c.beaconPaused);
4573
+ if (paused.length === 0)
4574
+ return;
4575
+ (async () => {
4576
+ let resumed = 0;
4577
+ for (const c of paused) {
4578
+ try {
4579
+ const url = `http://localhost:${config.port}/commitments/${c.id}/resume`;
4580
+ const resp = await fetch(url, {
4581
+ method: 'POST',
4582
+ headers: {
4583
+ 'Content-Type': 'application/json',
4584
+ 'Authorization': `Bearer ${config.authToken}`,
4585
+ },
4586
+ });
4587
+ if (resp.ok)
4588
+ resumed += 1;
4589
+ else
4590
+ console.warn(`[PromiseBeacon] resume call returned ${resp.status} for ${c.id}`);
4591
+ }
4592
+ catch (err) {
4593
+ console.warn(`[PromiseBeacon] resume call failed for ${c.id}:`, err.message);
4594
+ }
4595
+ }
4596
+ let ackText;
4597
+ if (resumed === paused.length && resumed > 0) {
4598
+ ackText = `⏳ resumed ${resumed === 1 ? 'watcher' : `${resumed} watchers`} on this topic.`;
4599
+ }
4600
+ else if (resumed > 0) {
4601
+ ackText = `⏳ resumed ${resumed} of ${paused.length} watchers — ${paused.length - resumed} didn't resume. Try again or open the dashboard.`;
4602
+ }
4603
+ else {
4604
+ ackText = `⚠️ couldn't resume the watcher${paused.length === 1 ? '' : 's'} on this topic — try again or open the dashboard.`;
4605
+ }
4606
+ try {
4607
+ const ackUrl = `http://localhost:${config.port}/telegram/reply/${topicId}`;
4608
+ await fetch(ackUrl, {
4609
+ method: 'POST',
4610
+ headers: {
4611
+ 'Content-Type': 'application/json',
4612
+ 'Authorization': `Bearer ${config.authToken}`,
4613
+ },
4614
+ body: JSON.stringify({
4615
+ text: ackText,
4616
+ metadata: { source: 'promise-beacon', isProxy: true, tier: 1 },
4617
+ }),
4618
+ });
4619
+ }
4620
+ catch (err) {
4621
+ console.warn('[PromiseBeacon] resume ack send failed:', err.message);
4622
+ }
4623
+ })();
4624
+ };
4552
4625
  }
4553
4626
  catch (err) {
4554
4627
  console.warn('[PromiseBeacon] init failed:', err.message);