instar 1.2.50 → 1.2.51

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;AAiqDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA6oLtE;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;AAiqDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAksLtE;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"}
@@ -4700,13 +4700,17 @@ export async function startServer(options) {
4700
4700
  }
4701
4701
  console.log(pc.green(' CompactionSentinel enabled (verified recovery lifecycle)'));
4702
4702
  // ── Silently-stopped trio: SocketDisconnectSentinel + ActiveWorkSilenceSentinel ──
4703
- // Both detectors merged in PR #334 but were never instantiated; this is the
4704
- // missing wire-up. Escalations route through the tone-gated /attention path.
4703
+ // Wire-up post-2026-05-22 incident. Every transition (detect/nudge/recover)
4704
+ // lands in the audit log (server logs + JSONL) — the user never sees it.
4705
+ // A genuine recovery-failed escalation goes through SentinelNotifier, which
4706
+ // is OFF for Telegram by default and, when enabled, coalesces into ONE
4707
+ // consolidated message to the existing system topic. No new-topic-per-event.
4705
4708
  // Spec: docs/specs/silently-stopped-trio.md.
4706
4709
  {
4707
4710
  const { SocketDisconnectSentinel } = await import('../monitoring/SocketDisconnectSentinel.js');
4708
4711
  const { ActiveWorkSilenceSentinel } = await import('../monitoring/ActiveWorkSilenceSentinel.js');
4709
- const { makeAttentionPoster, buildSocketDisconnectDeps, buildActiveWorkSilenceDeps, OutputActivityTracker, } = await import('../monitoring/sentinelWiring.js');
4712
+ const { buildSocketDisconnectDeps, buildActiveWorkSilenceDeps, OutputActivityTracker, } = await import('../monitoring/sentinelWiring.js');
4713
+ const { SentinelNotifier } = await import('../monitoring/SentinelNotifier.js');
4710
4714
  const sessionSurface = {
4711
4715
  captureOutput: (s, lines) => sessionManager.captureOutput(s, lines),
4712
4716
  isSessionAlive: (s) => sessionManager.isSessionAlive(s),
@@ -4716,19 +4720,60 @@ export async function startServer(options) {
4716
4720
  framework: sessionManager.frameworkForSession(sess.tmuxSession),
4717
4721
  })),
4718
4722
  };
4719
- const attentionPoster = makeAttentionPoster({ port: config.port, authToken: config.authToken ?? '' });
4723
+ // Audit log: console + JSONL. setupServerLog already created the logs dir.
4724
+ const sentinelLogPath = path.join(config.stateDir, '..', 'logs', 'sentinel-events.jsonl');
4725
+ const logSink = (entry) => {
4726
+ const detail = entry.detail ? ` — ${entry.detail}` : '';
4727
+ console.log(`[sentinel:${entry.kind}] ${entry.sentinel}/${entry.sessionName}${detail}`);
4728
+ try {
4729
+ fs.appendFileSync(sentinelLogPath, JSON.stringify(entry) + '\n');
4730
+ }
4731
+ catch { /* logs are best-effort; never crash the monitoring path */ }
4732
+ };
4733
+ // Consolidated Telegram delivery — reuses the existing system (lifeline)
4734
+ // topic. When telegramEscalation is off, this callback is never invoked.
4735
+ const localTelegram = telegram;
4736
+ const sendConsolidated = localTelegram
4737
+ ? async (text) => {
4738
+ const topicId = localTelegram.getLifelineTopicId();
4739
+ if (!topicId)
4740
+ return false;
4741
+ try {
4742
+ await localTelegram.sendToTopic(topicId, text);
4743
+ return true;
4744
+ }
4745
+ catch {
4746
+ return false;
4747
+ }
4748
+ }
4749
+ : undefined;
4750
+ const telegramEscalation = config.monitoring?.sentinelTelegramEscalation === true;
4751
+ const notifier = new SentinelNotifier({ log: logSink, sendConsolidated }, { telegramEscalation });
4720
4752
  const socketCfg = config.monitoring?.socketDisconnectSentinel ?? { enabled: true };
4721
4753
  if (socketCfg.enabled !== false) {
4722
- const socketSentinel = new SocketDisconnectSentinel(buildSocketDisconnectDeps({ sessions: sessionSurface, notify: attentionPoster }), socketCfg);
4754
+ const socketSentinel = new SocketDisconnectSentinel(buildSocketDisconnectDeps({
4755
+ sessions: sessionSurface,
4756
+ escalate: (name, text) => notifier.escalate('socket-disconnect', name, text),
4757
+ }), socketCfg);
4758
+ socketSentinel.on('recovered', (n) => notifier.record('recovered', 'socket-disconnect', n));
4759
+ socketSentinel.on('recovery-error', (e) => notifier.record('recovery-error', 'socket-disconnect', e.sessionName, e.err instanceof Error ? e.err.message : String(e.err)));
4723
4760
  socketSentinel.start();
4724
4761
  console.log(pc.green(' SocketDisconnectSentinel enabled (connection-drop recovery)'));
4725
4762
  }
4726
4763
  const silenceCfg = config.monitoring?.activeWorkSilenceSentinel ?? { enabled: true };
4727
4764
  if (silenceCfg.enabled !== false) {
4728
4765
  const tracker = new OutputActivityTracker(sessionSurface);
4729
- const silenceSentinel = new ActiveWorkSilenceSentinel(buildActiveWorkSilenceDeps({ tracker, sessions: sessionSurface, notify: attentionPoster }), silenceCfg);
4766
+ const silenceSentinel = new ActiveWorkSilenceSentinel(buildActiveWorkSilenceDeps({
4767
+ tracker, sessions: sessionSurface,
4768
+ escalate: (name, text) => notifier.escalate('active-silence', name, text),
4769
+ }), silenceCfg);
4770
+ silenceSentinel.on('silence', (e) => notifier.record('detected', 'active-silence', e.sessionName, `idleMs=${e.idleMs}`));
4771
+ silenceSentinel.on('recovered', (n) => notifier.record('recovered', 'active-silence', n));
4772
+ silenceSentinel.on('nudge-error', (e) => notifier.record('nudge-error', 'active-silence', e.sessionName, e.err instanceof Error ? e.err.message : String(e.err)));
4730
4773
  silenceSentinel.start();
4731
- console.log(pc.green(' ActiveWorkSilenceSentinel enabled (silent-freeze watchdog)'));
4774
+ console.log(pc.green(telegramEscalation
4775
+ ? ' ActiveWorkSilenceSentinel enabled (silent-freeze watchdog — Telegram escalation ON, consolidated)'
4776
+ : ' ActiveWorkSilenceSentinel enabled (silent-freeze watchdog — logs only, Telegram escalation OFF)'));
4732
4777
  }
4733
4778
  }
4734
4779
  // Trigger 1: PreCompact hook event — report to sentinel.