@friendlyrobot/discord-pi-agent 0.8.3 → 0.9.1
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 +24 -3
- package/package.json +1 -1
- package/dist/discord-client.d.ts +0 -5
package/dist/index.js
CHANGED
|
@@ -972,27 +972,42 @@ async function removeWorkingReaction(message) {
|
|
|
972
972
|
}
|
|
973
973
|
var TYPING_INTERVAL_MS = 9000;
|
|
974
974
|
var typingIntervals = new Map;
|
|
975
|
+
async function sendTypingSafe(channel, channelKey) {
|
|
976
|
+
logger5.info({ channelKey }, "[TYPING] calling sendTyping()");
|
|
977
|
+
try {
|
|
978
|
+
await channel.sendTyping();
|
|
979
|
+
logger5.info({ channelKey }, "[TYPING] sendTyping() OK");
|
|
980
|
+
} catch (error) {
|
|
981
|
+
logger5.warn({ channelKey, error }, "[TYPING] sendTyping() FAILED");
|
|
982
|
+
}
|
|
983
|
+
}
|
|
975
984
|
function startTypingForChannel(channel, channelKey) {
|
|
976
985
|
const existing = typingIntervals.get(channelKey);
|
|
977
986
|
if (existing) {
|
|
978
987
|
existing.refs += 1;
|
|
988
|
+
logger5.info({ channelKey, refs: existing.refs }, "[TYPING] ref++ (reusing existing interval)");
|
|
979
989
|
return;
|
|
980
990
|
}
|
|
981
|
-
|
|
991
|
+
logger5.info({ channelKey }, "[TYPING] started new interval");
|
|
992
|
+
sendTypingSafe(channel, channelKey);
|
|
982
993
|
const interval = setInterval(() => {
|
|
983
|
-
channel
|
|
994
|
+
sendTypingSafe(channel, channelKey);
|
|
984
995
|
}, TYPING_INTERVAL_MS);
|
|
985
996
|
typingIntervals.set(channelKey, { interval, refs: 1 });
|
|
986
997
|
}
|
|
987
998
|
function stopTypingForChannel(channelKey) {
|
|
988
999
|
const entry = typingIntervals.get(channelKey);
|
|
989
1000
|
if (!entry) {
|
|
1001
|
+
logger5.info({ channelKey }, "[TYPING] stop called but no entry found");
|
|
990
1002
|
return;
|
|
991
1003
|
}
|
|
992
1004
|
entry.refs -= 1;
|
|
993
1005
|
if (entry.refs <= 0) {
|
|
994
1006
|
clearInterval(entry.interval);
|
|
995
1007
|
typingIntervals.delete(channelKey);
|
|
1008
|
+
logger5.info({ channelKey }, "[TYPING] interval cleared (refs hit 0)");
|
|
1009
|
+
} else {
|
|
1010
|
+
logger5.info({ channelKey, refs: entry.refs }, "[TYPING] ref-- (interval still active)");
|
|
996
1011
|
}
|
|
997
1012
|
}
|
|
998
1013
|
async function sendReply(message, text) {
|
|
@@ -1115,8 +1130,11 @@ async function onMessage(message, config, agentService, sessionRegistry, authCon
|
|
|
1115
1130
|
}, "new thread session");
|
|
1116
1131
|
}
|
|
1117
1132
|
const channelKey = message.channel.id;
|
|
1118
|
-
|
|
1133
|
+
const canSend = message.channel.isSendable();
|
|
1134
|
+
logger5.info({ channelKey, scope, canSend, channelType: message.channel.type }, "[TYPING] checking sendable");
|
|
1135
|
+
if (canSend) {
|
|
1119
1136
|
startTypingForChannel(message.channel, channelKey);
|
|
1137
|
+
logger5.info({ channelKey, scope }, "[TYPING] interval requested");
|
|
1120
1138
|
}
|
|
1121
1139
|
const commandResult = await handleCommand(content, {
|
|
1122
1140
|
agentService,
|
|
@@ -1173,14 +1191,17 @@ async function onMessage(message, config, agentService, sessionRegistry, authCon
|
|
|
1173
1191
|
messageId: message.id,
|
|
1174
1192
|
scope
|
|
1175
1193
|
}, "processing message");
|
|
1194
|
+
logger5.info({ messageId: message.id, scope, channelKey }, "[TYPING] prompt enqueued, starting processing");
|
|
1176
1195
|
const promptContent = buildDiscordPromptContent(message, scope, content, config);
|
|
1177
1196
|
const transformedPrompt = await config.promptTransform(promptContent);
|
|
1197
|
+
logger5.info({ messageId: message.id, scope, channelKey }, "[TYPING] about to call collectReply/session.prompt");
|
|
1178
1198
|
return collectReply(session, transformedPrompt, {
|
|
1179
1199
|
logPrefix: `[agent:${session.sessionId}]`
|
|
1180
1200
|
});
|
|
1181
1201
|
});
|
|
1182
1202
|
} finally {
|
|
1183
1203
|
stopTypingForChannel(channelKey);
|
|
1204
|
+
logger5.info({ channelKey, scope }, "[TYPING] interval released");
|
|
1184
1205
|
await removeWorkingReaction(message);
|
|
1185
1206
|
}
|
|
1186
1207
|
logger5.info({
|
package/package.json
CHANGED
package/dist/discord-client.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Client } from "discord.js";
|
|
2
|
-
import type { AgentService } from "./agent-service";
|
|
3
|
-
import type { PromptQueue } from "./prompt-queue";
|
|
4
|
-
import type { ResolvedDiscordPiBridgeConfig } from "./types";
|
|
5
|
-
export declare function startDiscordClient(config: ResolvedDiscordPiBridgeConfig, agentService: AgentService, promptQueue: PromptQueue): Promise<Client>;
|