instar 0.23.0 → 0.23.2
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.
- package/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +36 -3
- package/dist/commands/server.js.map +1 -1
- package/dist/messaging/WhatsAppAdapter.d.ts +8 -1
- package/dist/messaging/WhatsAppAdapter.d.ts.map +1 -1
- package/dist/messaging/WhatsAppAdapter.js +14 -1
- package/dist/messaging/WhatsAppAdapter.js.map +1 -1
- package/dist/messaging/backends/BaileysBackend.d.ts +16 -0
- package/dist/messaging/backends/BaileysBackend.d.ts.map +1 -1
- package/dist/messaging/backends/BaileysBackend.js +150 -5
- package/dist/messaging/backends/BaileysBackend.js.map +1 -1
- package/dist/messaging/shared/AuthGate.d.ts +7 -2
- package/dist/messaging/shared/AuthGate.d.ts.map +1 -1
- package/dist/messaging/shared/AuthGate.js +8 -3
- package/dist/messaging/shared/AuthGate.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +2 -2
- package/upgrades/0.23.1.md +28 -0
- package/upgrades/0.23.2.md +32 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAwPH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAwPH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA6gCD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA0yEtE;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"}
|
package/dist/commands/server.js
CHANGED
|
@@ -723,6 +723,10 @@ function messageToPipeline(msg, topicName) {
|
|
|
723
723
|
};
|
|
724
724
|
}
|
|
725
725
|
function wireTelegramRouting(telegram, sessionManager, quotaTracker, topicMemory, userManager, fixCommandHandler) {
|
|
726
|
+
// Guard: tracks which topic IDs have a spawn in progress.
|
|
727
|
+
// Prevents duplicate concurrent spawns for the same topic when messages
|
|
728
|
+
// arrive faster than the async spawn completes.
|
|
729
|
+
const spawningTopics = new Set();
|
|
726
730
|
telegram.onTopicMessage = (msg) => {
|
|
727
731
|
const topicId = msg.metadata?.messageThreadId ?? null;
|
|
728
732
|
if (!topicId)
|
|
@@ -830,9 +834,26 @@ function wireTelegramRouting(telegram, sessionManager, quotaTracker, topicMemory
|
|
|
830
834
|
}
|
|
831
835
|
catch { /* classification failed — fall through to respawn */ }
|
|
832
836
|
if (!isQuotaDeath) {
|
|
837
|
+
// Guard: skip respawn if one is already in progress for this topic.
|
|
838
|
+
// Prevents the infinite respawn loop: dead session + rapid messages → each
|
|
839
|
+
// message triggers a new respawn → multiple concurrent spawns → chaos.
|
|
840
|
+
if (spawningTopics.has(topicId)) {
|
|
841
|
+
console.log(`[telegram→session] Spawn already in progress for topic ${topicId} — skipping duplicate respawn`);
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
844
|
+
spawningTopics.add(topicId);
|
|
833
845
|
telegram.sendToTopic(topicId, `🔄 Session restarting — message queued.`).catch(() => { });
|
|
834
|
-
respawnSessionForTopic(sessionManager, telegram, targetSession, topicId, text, topicMemory, resolvedUser ?? undefined)
|
|
846
|
+
respawnSessionForTopic(sessionManager, telegram, targetSession, topicId, text, topicMemory, resolvedUser ?? undefined)
|
|
847
|
+
.catch(err => {
|
|
835
848
|
console.error(`[telegram→session] Respawn failed:`, err);
|
|
849
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
850
|
+
const userMsg = errMsg.includes('session limit') || errMsg.includes('limit')
|
|
851
|
+
? `❌ Session restart failed — session limit reached. Close an existing session or increase maxSessions in your config, then try again.`
|
|
852
|
+
: `❌ Session restart failed. Try sending your message again in a moment.`;
|
|
853
|
+
telegram.sendToTopic(topicId, userMsg).catch(() => { });
|
|
854
|
+
})
|
|
855
|
+
.finally(() => {
|
|
856
|
+
spawningTopics.delete(topicId);
|
|
836
857
|
});
|
|
837
858
|
}
|
|
838
859
|
}
|
|
@@ -841,7 +862,14 @@ function wireTelegramRouting(telegram, sessionManager, quotaTracker, topicMemory
|
|
|
841
862
|
// No session mapped — auto-spawn with topic history (same as respawn path).
|
|
842
863
|
// Without history, the agent has no conversational context and gives blind answers.
|
|
843
864
|
console.log(`[telegram→session] No session for topic ${topicId}, auto-spawning with history...`);
|
|
865
|
+
// Guard: skip spawn if one is already in progress for this topic.
|
|
866
|
+
if (spawningTopics.has(topicId)) {
|
|
867
|
+
telegram.sendToTopic(topicId, `Session is still starting up — please wait a moment.`).catch(() => { });
|
|
868
|
+
console.log(`[telegram→session] Spawn already in progress for topic ${topicId} — skipping duplicate`);
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
844
871
|
const spawnName = storedTopicName || `topic-${topicId}`;
|
|
872
|
+
spawningTopics.add(topicId);
|
|
845
873
|
// Use the shared spawn helper that includes topic history + user context
|
|
846
874
|
spawnSessionForTopic(sessionManager, telegram, spawnName, topicId, text, topicMemory, resolvedUser ?? undefined).then((newSessionName) => {
|
|
847
875
|
telegram.registerTopicSession(topicId, newSessionName, spawnName);
|
|
@@ -849,8 +877,13 @@ function wireTelegramRouting(telegram, sessionManager, quotaTracker, topicMemory
|
|
|
849
877
|
console.log(`[telegram→session] Auto-spawned "${newSessionName}" for topic ${topicId}`);
|
|
850
878
|
}).catch((err) => {
|
|
851
879
|
console.error(`[telegram→session] Auto-spawn failed:`, err);
|
|
852
|
-
|
|
853
|
-
|
|
880
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
881
|
+
const userMsg = errMsg.includes('session limit') || errMsg.includes('limit')
|
|
882
|
+
? `❌ Unable to start session — session limit reached. Close an existing session or increase maxSessions in your config, then try again.`
|
|
883
|
+
: 'Having trouble starting a session right now. Try sending your message again in a moment.';
|
|
884
|
+
telegram.sendToTopic(topicId, userMsg).catch(() => { });
|
|
885
|
+
}).finally(() => {
|
|
886
|
+
spawningTopics.delete(topicId);
|
|
854
887
|
});
|
|
855
888
|
}
|
|
856
889
|
};
|