instar 1.3.567 → 1.3.569

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;AAkCH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAS3D,OAAO,EAAE,eAAe,EAAiC,MAAM,iCAAiC,CAAC;AAuBjG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAkH7D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAsBtD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC1C,OAAO,CAUT;AAyID,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAg4CD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EACzB,cAAc,EAAE,cAAc,EAC9B,YAAY,CAAC,EAAE,YAAY,EAC3B,WAAW,CAAC,EAAE,WAAW,EACzB,WAAW,CAAC,EAAE,WAAW,EACzB,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EAGvE,UAAU,CAAC,EAAE,MAAM,OAAO,8BAA8B,EAAE,WAAW,GAAG,IAAI,EAK5E,qBAAqB,CAAC,EAAE,MAAM,OAAO,gCAAgC,EAAE,kBAAkB,GAAG,IAAI,EAKhG,mBAAmB,CAAC,EAAE,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,WAAW,EACzB,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EAGvE,UAAU,CAAC,EAAE,MAAM,OAAO,8BAA8B,EAAE,WAAW,GAAG,IAAI,EAK5E,qBAAqB,CAAC,EAAE,MAAM,OAAO,gCAAgC,EAAE,kBAAkB,GAAG,IAAI,EAKhG,mBAAmB,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,GACpD,IAAI,CA8eN;AA2lBD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAihctE;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"}
@@ -15,7 +15,7 @@ import { fileURLToPath } from 'node:url';
15
15
  import pc from 'picocolors';
16
16
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
17
17
  import { loadConfig, ensureStateDir, detectTmuxPath, detectGeminiPath } from '../core/Config.js';
18
- import { isNonFatalUncaught, shouldLogStackForUncaught } from '../core/uncaughtExceptionPolicy.js';
18
+ import { handleProcessLevelError } from '../core/uncaughtExceptionPolicy.js';
19
19
  import { resolveDevAgentGate, resolveStateSyncStores } from '../core/devAgentGate.js';
20
20
  import { parseProfileTrigger, platformMessageIdFrom } from '../core/topicProfileIngress.js';
21
21
  import { slugifyChannelName } from '../messaging/slack/sanitize.js';
@@ -16553,31 +16553,25 @@ export async function startServer(options) {
16553
16553
  // (e.g., cloudflared crash cascade during sleep/wake), close databases to prevent
16554
16554
  // the "mutex lock failed" error on next start. This doesn't prevent the crash,
16555
16555
  // but ensures the next boot is clean.
16556
+ // Route BOTH process-level error events through one shared decision
16557
+ // (uncaughtExceptionPolicy.handleProcessLevelError) so they cannot drift to
16558
+ // divergent policies: one narrow allowlist (HTTP double-response races, the
16559
+ // Slack Socket Mode reconnect race, standby read-only writes), one
16560
+ // fail-toward-crash default, one dedup'd log path. Isolated/recoverable
16561
+ // errors log-and-continue; anything unknown closes ALL registered SQLite
16562
+ // handles (so the crash exit doesn't compound into a "mutex lock failed"
16563
+ // SIGABRT) and exits — net #2 respawns a clean process in ~10s.
16564
+ //
16565
+ // The unhandledRejection handler is essential, not optional: the Slack
16566
+ // 'message' listener calls the async _handleRawMessage, so an escaping throw
16567
+ // there surfaces as a REJECTION, not a sync exception (net #1). Cleanup is
16568
+ // injected so the policy module stays pure decision-logic.
16569
+ const onFatalCleanup = () => { closeAllSqlite(); };
16556
16570
  process.on('uncaughtException', (err) => {
16557
- // Isolated, recoverable uncaught exceptions — log and continue, don't
16558
- // crash the server (which would close its databases + drop in-flight
16559
- // work). See isNonFatalUncaught for the allowlist + rationale (HTTP
16560
- // double-response races, Slack Socket Mode reconnect races).
16561
- if (isNonFatalUncaught(err)) {
16562
- // Attach the stack the first time a given origin is seen so the offending
16563
- // call site (e.g. a route that double-responds → "Cannot set headers")
16564
- // is diagnosable; repeats log message-only to avoid flooding the log
16565
- // (these isolated races recur ~10-20x/hour).
16566
- const stackSuffix = shouldLogStackForUncaught(err) && err.stack
16567
- ? `\n first-seen stack (for diagnosis):\n${err.stack}`
16568
- : '';
16569
- console.warn(`[WARN] Non-fatal uncaught exception (suppressed): ${err.message}${stackSuffix}`);
16570
- return; // Don't crash — the server is fine
16571
- }
16572
- console.error('[FATAL] Uncaught exception — closing databases before crash:', err.message);
16573
- // Close ALL registered SQLite handles (not just topic/semantic memory) so
16574
- // the crash exit doesn't compound into a "mutex lock failed" SIGABRT on top
16575
- // of the original error. closeAllSqlite() is best-effort + idempotent.
16576
- try {
16577
- closeAllSqlite();
16578
- }
16579
- catch { /* best effort */ }
16580
- process.exit(1);
16571
+ handleProcessLevelError(err, 'uncaughtException', { onFatalCleanup });
16572
+ });
16573
+ process.on('unhandledRejection', (reason) => {
16574
+ handleProcessLevelError(reason, 'unhandledRejection', { onFatalCleanup });
16581
16575
  });
16582
16576
  // Wire the ForegroundRestartWatcher to the graceful shutdown function.
16583
16577
  // This ensures auto-update restarts close all resources (especially SQLite