instar 0.26.2 → 0.26.4

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.
Files changed (98) hide show
  1. package/dashboard/index.html +55 -0
  2. package/dist/commands/init.d.ts.map +1 -1
  3. package/dist/commands/init.js +2 -1
  4. package/dist/commands/init.js.map +1 -1
  5. package/dist/commands/server.d.ts.map +1 -1
  6. package/dist/commands/server.js +65 -4
  7. package/dist/commands/server.js.map +1 -1
  8. package/dist/commands/slack-cli.d.ts.map +1 -1
  9. package/dist/commands/slack-cli.js +6 -0
  10. package/dist/commands/slack-cli.js.map +1 -1
  11. package/dist/core/CapabilityMapper.d.ts.map +1 -1
  12. package/dist/core/CapabilityMapper.js +2 -0
  13. package/dist/core/CapabilityMapper.js.map +1 -1
  14. package/dist/core/EvolutionManager.d.ts +17 -0
  15. package/dist/core/EvolutionManager.d.ts.map +1 -1
  16. package/dist/core/EvolutionManager.js +64 -0
  17. package/dist/core/EvolutionManager.js.map +1 -1
  18. package/dist/core/GitSync.d.ts.map +1 -1
  19. package/dist/core/GitSync.js +10 -2
  20. package/dist/core/GitSync.js.map +1 -1
  21. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  22. package/dist/core/PostUpdateMigrator.js +37 -0
  23. package/dist/core/PostUpdateMigrator.js.map +1 -1
  24. package/dist/core/SessionManager.d.ts.map +1 -1
  25. package/dist/core/SessionManager.js +9 -0
  26. package/dist/core/SessionManager.js.map +1 -1
  27. package/dist/core/types.d.ts +4 -0
  28. package/dist/core/types.d.ts.map +1 -1
  29. package/dist/core/types.js.map +1 -1
  30. package/dist/index.d.ts +1 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +1 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/lifeline/ServerSupervisor.d.ts.map +1 -1
  35. package/dist/lifeline/ServerSupervisor.js +37 -1
  36. package/dist/lifeline/ServerSupervisor.js.map +1 -1
  37. package/dist/messaging/imessage/IMessageAdapter.d.ts +112 -0
  38. package/dist/messaging/imessage/IMessageAdapter.d.ts.map +1 -0
  39. package/dist/messaging/imessage/IMessageAdapter.js +483 -0
  40. package/dist/messaging/imessage/IMessageAdapter.js.map +1 -0
  41. package/dist/messaging/imessage/NativeBackend.d.ts +82 -0
  42. package/dist/messaging/imessage/NativeBackend.d.ts.map +1 -0
  43. package/dist/messaging/imessage/NativeBackend.js +353 -0
  44. package/dist/messaging/imessage/NativeBackend.js.map +1 -0
  45. package/dist/messaging/imessage/OutboundAuditLog.d.ts +49 -0
  46. package/dist/messaging/imessage/OutboundAuditLog.d.ts.map +1 -0
  47. package/dist/messaging/imessage/OutboundAuditLog.js +58 -0
  48. package/dist/messaging/imessage/OutboundAuditLog.js.map +1 -0
  49. package/dist/messaging/imessage/OutboundRateLimiter.d.ts +54 -0
  50. package/dist/messaging/imessage/OutboundRateLimiter.d.ts.map +1 -0
  51. package/dist/messaging/imessage/OutboundRateLimiter.js +111 -0
  52. package/dist/messaging/imessage/OutboundRateLimiter.js.map +1 -0
  53. package/dist/messaging/imessage/index.d.ts +10 -0
  54. package/dist/messaging/imessage/index.d.ts.map +1 -0
  55. package/dist/messaging/imessage/index.js +13 -0
  56. package/dist/messaging/imessage/index.js.map +1 -0
  57. package/dist/messaging/imessage/normalize-phone.d.ts +26 -0
  58. package/dist/messaging/imessage/normalize-phone.d.ts.map +1 -0
  59. package/dist/messaging/imessage/normalize-phone.js +55 -0
  60. package/dist/messaging/imessage/normalize-phone.js.map +1 -0
  61. package/dist/messaging/imessage/types.d.ts +84 -0
  62. package/dist/messaging/imessage/types.d.ts.map +1 -0
  63. package/dist/messaging/imessage/types.js +5 -0
  64. package/dist/messaging/imessage/types.js.map +1 -0
  65. package/dist/messaging/shared/MessagingEventBus.d.ts +5 -0
  66. package/dist/messaging/shared/MessagingEventBus.d.ts.map +1 -1
  67. package/dist/messaging/shared/MessagingEventBus.js.map +1 -1
  68. package/dist/messaging/slack/SlackAdapter.d.ts.map +1 -1
  69. package/dist/messaging/slack/SlackAdapter.js +31 -1
  70. package/dist/messaging/slack/SlackAdapter.js.map +1 -1
  71. package/dist/messaging/slack/SocketModeClient.d.ts.map +1 -1
  72. package/dist/messaging/slack/SocketModeClient.js +6 -0
  73. package/dist/messaging/slack/SocketModeClient.js.map +1 -1
  74. package/dist/monitoring/PresenceProxy.d.ts +10 -4
  75. package/dist/monitoring/PresenceProxy.d.ts.map +1 -1
  76. package/dist/monitoring/PresenceProxy.js +87 -15
  77. package/dist/monitoring/PresenceProxy.js.map +1 -1
  78. package/dist/monitoring/QuotaExhaustionDetector.d.ts +15 -0
  79. package/dist/monitoring/QuotaExhaustionDetector.d.ts.map +1 -1
  80. package/dist/monitoring/QuotaExhaustionDetector.js +26 -3
  81. package/dist/monitoring/QuotaExhaustionDetector.js.map +1 -1
  82. package/dist/monitoring/SessionMonitor.d.ts.map +1 -1
  83. package/dist/monitoring/SessionMonitor.js +5 -2
  84. package/dist/monitoring/SessionMonitor.js.map +1 -1
  85. package/dist/monitoring/SessionRecovery.d.ts +16 -1
  86. package/dist/monitoring/SessionRecovery.d.ts.map +1 -1
  87. package/dist/monitoring/SessionRecovery.js +71 -8
  88. package/dist/monitoring/SessionRecovery.js.map +1 -1
  89. package/dist/scheduler/JobScheduler.js +1 -1
  90. package/dist/scheduler/JobScheduler.js.map +1 -1
  91. package/dist/server/routes.d.ts.map +1 -1
  92. package/dist/server/routes.js +14 -0
  93. package/dist/server/routes.js.map +1 -1
  94. package/package.json +1 -1
  95. package/src/data/builtin-manifest.json +65 -65
  96. package/src/templates/hooks/settings-template.json +11 -0
  97. package/upgrades/0.26.3.md +26 -0
  98. package/upgrades/0.26.4.md +17 -0
@@ -865,8 +865,9 @@ function wireTelegramRouting(telegram, sessionManager, quotaTracker, topicMemory
865
865
  telegram.trackMessageInjection(topicId, targetSession, text);
866
866
  }
867
867
  else {
868
- // Session died — check if it's a quota death before respawning
868
+ // Session died — classify death cause before deciding how to respawn
869
869
  let isQuotaDeath = false;
870
+ let isContextExhausted = false;
870
871
  try {
871
872
  const output = sessionManager.captureOutput(targetSession, 100);
872
873
  if (output) {
@@ -877,10 +878,36 @@ function wireTelegramRouting(telegram, sessionManager, quotaTracker, topicMemory
877
878
  telegram.sendToTopic(topicId, `🔴 Session died — quota limit reached.\n${classification.detail}\n\n` +
878
879
  `Use /switch-account to switch, /login to add an account, or reply again to force restart.`).catch(() => { });
879
880
  }
881
+ else if (classification.cause === 'context_exhausted') {
882
+ isContextExhausted = true;
883
+ telegram.sendToTopic(topicId, `🔄 Conversation got too long — starting a fresh session with your recent history.`).catch(() => { });
884
+ }
880
885
  }
881
886
  }
882
887
  catch { /* classification failed — fall through to respawn */ }
883
- if (!isQuotaDeath) {
888
+ if (isContextExhausted) {
889
+ // Context exhaustion: respawn FRESH (no --resume) — the old conversation
890
+ // is too large to continue. The respawn path will load telegram thread
891
+ // history as context, giving the new session continuity.
892
+ if (spawningTopics.has(topicId)) {
893
+ console.log(`[telegram→session] Spawn already in progress for topic ${topicId} — skipping duplicate respawn`);
894
+ return;
895
+ }
896
+ spawningTopics.add(topicId);
897
+ // Remove the resume UUID so respawnSessionForTopic doesn't try --resume
898
+ if (_topicResumeMap) {
899
+ _topicResumeMap.remove(topicId);
900
+ }
901
+ respawnSessionForTopic(sessionManager, telegram, targetSession, topicId, text, topicMemory, resolvedUser ?? undefined)
902
+ .catch(err => {
903
+ console.error(`[telegram→session] Context exhaustion respawn failed:`, err);
904
+ telegram.sendToTopic(topicId, `❌ Fresh session restart failed. Try sending your message again.`).catch(() => { });
905
+ })
906
+ .finally(() => {
907
+ spawningTopics.delete(topicId);
908
+ });
909
+ }
910
+ else if (!isQuotaDeath) {
884
911
  // Guard: skip respawn if one is already in progress for this topic.
885
912
  // Prevents the infinite respawn loop: dead session + rapid messages → each
886
913
  // message triggers a new respawn → multiple concurrent spawns → chaos.
@@ -3122,6 +3149,22 @@ export async function startServer(options) {
3122
3149
  if (telegram)
3123
3150
  await telegram.sendToTopic(topicId, message);
3124
3151
  },
3152
+ captureSessionOutput: (name, lines) => {
3153
+ return sessionManager.captureOutput(name, lines);
3154
+ },
3155
+ respawnSessionFresh: async (topicId, _sessionName, recoveryPrompt) => {
3156
+ // Fresh respawn for context exhaustion — explicitly clear resume UUID
3157
+ // so the new session starts clean with telegram history, not --resume.
3158
+ if (_topicResumeMap) {
3159
+ _topicResumeMap.remove(topicId);
3160
+ }
3161
+ if (telegram) {
3162
+ const targetSession = telegram.getSessionForTopic(topicId);
3163
+ if (!targetSession)
3164
+ return;
3165
+ await respawnSessionForTopic(sessionManager, telegram, targetSession, topicId, undefined, topicMemory, undefined, recoveryPrompt, { silent: true });
3166
+ }
3167
+ },
3125
3168
  });
3126
3169
  console.log(pc.green(' Session Recovery enabled (mechanical fast-path)'));
3127
3170
  }
@@ -4341,11 +4384,29 @@ export async function startServer(options) {
4341
4384
  const featureRegistry = new FeatureRegistry(config.stateDir, {
4342
4385
  hmacKey: config.authToken || undefined,
4343
4386
  });
4344
- await featureRegistry.open();
4387
+ let featureRegistryReady = false;
4388
+ try {
4389
+ await featureRegistry.open();
4390
+ featureRegistryReady = true;
4391
+ }
4392
+ catch (frErr) {
4393
+ const msg = frErr instanceof Error ? frErr.message : String(frErr);
4394
+ console.warn(pc.yellow(` FeatureRegistry: failed to open (${msg.slice(0, 120)})`));
4395
+ const { DegradationReporter } = await import('../monitoring/DegradationReporter.js');
4396
+ DegradationReporter.getInstance().report({
4397
+ feature: 'FeatureRegistry',
4398
+ primary: 'SQLite-backed feature registry with discovery state tracking',
4399
+ fallback: 'Feature definitions available in-memory only (no persistent state)',
4400
+ reason: `FeatureRegistry open failed: ${msg.slice(0, 200)}`,
4401
+ impact: 'Feature discovery state not persisted. Features default to definitions only.',
4402
+ });
4403
+ }
4345
4404
  for (const def of BUILTIN_FEATURES) {
4346
4405
  featureRegistry.register(def);
4347
4406
  }
4348
- featureRegistry.bootstrap(config);
4407
+ if (featureRegistryReady) {
4408
+ featureRegistry.bootstrap(config);
4409
+ }
4349
4410
  {
4350
4411
  const summaries = featureRegistry.getSummaries();
4351
4412
  const enabledCount = summaries.filter((f) => f.enabled).length;