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