@friendlyrobot/discord-pi-agent 0.1.2 → 0.1.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.
- package/dist/index.js +15 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -470,7 +470,7 @@ async function onMessage(message, config, agentService, promptQueue) {
|
|
|
470
470
|
console.log("[discord] channel is not sendable", { messageId: message.id });
|
|
471
471
|
return;
|
|
472
472
|
}
|
|
473
|
-
await message.channel
|
|
473
|
+
const typingInterval = await startTypingInterval(message.channel);
|
|
474
474
|
const queuePosition = promptQueue.getSnapshot().pending;
|
|
475
475
|
console.log("[queue] enqueue request", {
|
|
476
476
|
messageId: message.id,
|
|
@@ -483,6 +483,7 @@ async function onMessage(message, config, agentService, promptQueue) {
|
|
|
483
483
|
console.log(`[queue] processing message ${message.id}`);
|
|
484
484
|
return agentService.prompt(content);
|
|
485
485
|
});
|
|
486
|
+
stopTypingInterval(typingInterval);
|
|
486
487
|
console.log("[discord] response ready", {
|
|
487
488
|
messageId: message.id,
|
|
488
489
|
responseLength: response.length,
|
|
@@ -510,6 +511,16 @@ async function sendReply(message, text) {
|
|
|
510
511
|
await message.channel.send(chunk);
|
|
511
512
|
}
|
|
512
513
|
}
|
|
514
|
+
var TYPING_INTERVAL_MS = 8000;
|
|
515
|
+
function startTypingInterval(channel) {
|
|
516
|
+
channel.sendTyping();
|
|
517
|
+
return setInterval(() => {
|
|
518
|
+
channel.sendTyping();
|
|
519
|
+
}, TYPING_INTERVAL_MS);
|
|
520
|
+
}
|
|
521
|
+
function stopTypingInterval(interval) {
|
|
522
|
+
clearInterval(interval);
|
|
523
|
+
}
|
|
513
524
|
|
|
514
525
|
// src/prompt-queue.ts
|
|
515
526
|
class PromptQueue {
|
|
@@ -607,8 +618,10 @@ function createStopHandler(client, agentService, config) {
|
|
|
607
618
|
}
|
|
608
619
|
function registerSignalHandlers(stop) {
|
|
609
620
|
const handleSignal = (signal) => {
|
|
621
|
+
console.log(`[shutdown] received ${signal}`);
|
|
610
622
|
stop().finally(() => {
|
|
611
|
-
console.log(
|
|
623
|
+
console.log("[shutdown] done");
|
|
624
|
+
process.exit(0);
|
|
612
625
|
});
|
|
613
626
|
};
|
|
614
627
|
process.on("SIGINT", () => {
|