@friendlyrobot/discord-pi-agent 0.10.2 → 0.10.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/debug-print.test.d.ts +1 -0
- package/dist/index.js +16 -14
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -41,11 +41,18 @@ function createModuleLogger(moduleName) {
|
|
|
41
41
|
|
|
42
42
|
// src/debug-print.ts
|
|
43
43
|
function debugPrint(body, title) {
|
|
44
|
+
const WIDTH = 80;
|
|
44
45
|
const label = title ?? "DEBUG";
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
function centeredFence(text) {
|
|
47
|
+
const inner = ` ${text} `;
|
|
48
|
+
const padLen = Math.floor((WIDTH - inner.length) / 2);
|
|
49
|
+
const pad = "=".repeat(padLen);
|
|
50
|
+
const result = pad + inner + pad;
|
|
51
|
+
return result.length < WIDTH ? result + "=" : result;
|
|
52
|
+
}
|
|
53
|
+
console.info(centeredFence(label));
|
|
47
54
|
console.info(body);
|
|
48
|
-
console.info(
|
|
55
|
+
console.info(centeredFence("END"));
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
// src/markdown-table-transformer.ts
|
|
@@ -132,12 +139,7 @@ async function collectReply(session, prompt, options = {}) {
|
|
|
132
139
|
}, `tool end: [${event.toolName}]`);
|
|
133
140
|
}
|
|
134
141
|
if (event.type === "agent_end") {
|
|
135
|
-
logger3.debug(
|
|
136
|
-
messageCount: event.messages.length,
|
|
137
|
-
model,
|
|
138
|
-
toolCount,
|
|
139
|
-
eventCount
|
|
140
|
-
}, "agent end");
|
|
142
|
+
logger3.debug("agent end");
|
|
141
143
|
}
|
|
142
144
|
});
|
|
143
145
|
try {
|
|
@@ -1000,7 +1002,7 @@ async function sendTypingSafe(channel, channelKey) {
|
|
|
1000
1002
|
headers: { Authorization: `Bot ${token}` }
|
|
1001
1003
|
});
|
|
1002
1004
|
if (res.ok) {
|
|
1003
|
-
logger5.debug(
|
|
1005
|
+
logger5.debug(`[TYPING] STATUS UPDATED OK: ${await res.text()}`);
|
|
1004
1006
|
return;
|
|
1005
1007
|
}
|
|
1006
1008
|
if (res.status === 429) {
|
|
@@ -1033,7 +1035,7 @@ function startTypingForChannel(channel, channelKey) {
|
|
|
1033
1035
|
logger5.debug({ channelKey, refs: existing.refs }, "[TYPING] ref++ (reusing existing interval)");
|
|
1034
1036
|
return;
|
|
1035
1037
|
}
|
|
1036
|
-
logger5.debug(
|
|
1038
|
+
logger5.debug("[TYPING] started new interval");
|
|
1037
1039
|
sendTypingSafe(channel, channelKey);
|
|
1038
1040
|
const interval = setInterval(() => {
|
|
1039
1041
|
sendTypingSafe(channel, channelKey);
|
|
@@ -1050,9 +1052,9 @@ function stopTypingForChannel(channelKey) {
|
|
|
1050
1052
|
if (entry.refs <= 0) {
|
|
1051
1053
|
clearInterval(entry.interval);
|
|
1052
1054
|
typingIntervals.delete(channelKey);
|
|
1053
|
-
logger5.debug(
|
|
1055
|
+
logger5.debug("[TYPING] interval cleared (refs hit 0)");
|
|
1054
1056
|
} else {
|
|
1055
|
-
logger5.debug(
|
|
1057
|
+
logger5.debug("[TYPING] ref-- (interval still active)");
|
|
1056
1058
|
}
|
|
1057
1059
|
}
|
|
1058
1060
|
async function sendReply(message, text) {
|
|
@@ -1124,7 +1126,7 @@ async function startGatewayClient(config, agentService, sessionRegistry, authCon
|
|
|
1124
1126
|
}
|
|
1125
1127
|
async function onMessage(message, config, agentService, sessionRegistry, authConfig) {
|
|
1126
1128
|
if (message.author.bot) {
|
|
1127
|
-
logger5.debug(
|
|
1129
|
+
logger5.debug("ignored bot message");
|
|
1128
1130
|
return;
|
|
1129
1131
|
}
|
|
1130
1132
|
if (message.system) {
|