@friendlyrobot/discord-pi-agent 0.19.10 → 0.19.13
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 +16 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -375,15 +375,17 @@ function truncateForLog(value, maxLength = 400) {
|
|
|
375
375
|
return `${value.slice(0, maxLength)}...`;
|
|
376
376
|
}
|
|
377
377
|
function extractToolOutput(output) {
|
|
378
|
-
if (
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
378
|
+
if (typeof output === "object" && output !== null) {
|
|
379
|
+
const obj = output;
|
|
380
|
+
if (Array.isArray(obj.content)) {
|
|
381
|
+
return obj.content.map((item) => {
|
|
382
|
+
if (item.type === "text" && typeof item.text === "string") {
|
|
383
|
+
return item.text;
|
|
384
|
+
}
|
|
383
385
|
return JSON.stringify(item);
|
|
384
|
-
}
|
|
385
|
-
}).join(`
|
|
386
|
+
}).join(`
|
|
386
387
|
`);
|
|
388
|
+
}
|
|
387
389
|
}
|
|
388
390
|
return String(output);
|
|
389
391
|
}
|
|
@@ -1447,6 +1449,11 @@ function normalizeContextValue(value) {
|
|
|
1447
1449
|
|
|
1448
1450
|
// src/discord-message-handler.ts
|
|
1449
1451
|
var logger11 = createModuleLogger("discord-message-handler");
|
|
1452
|
+
function codeFence(text) {
|
|
1453
|
+
return `\`\`\`
|
|
1454
|
+
${text}
|
|
1455
|
+
\`\`\``;
|
|
1456
|
+
}
|
|
1450
1457
|
function buildDiscordPromptContent(message, scope, content, config) {
|
|
1451
1458
|
const isThread = scope.startsWith("thread:") && message.channel.isThread();
|
|
1452
1459
|
return buildDiscordMessageContextPrompt(content, {
|
|
@@ -1536,7 +1543,7 @@ ${attachment.content}`;
|
|
|
1536
1543
|
logger11.info({ scope }, "archiving thread");
|
|
1537
1544
|
const archiveChannel = message.channel;
|
|
1538
1545
|
if (archiveChannel.isSendable()) {
|
|
1539
|
-
await archiveChannel.send(commandResult.response ?? "Archiving...");
|
|
1546
|
+
await archiveChannel.send(codeFence(commandResult.response ?? "Archiving..."));
|
|
1540
1547
|
}
|
|
1541
1548
|
try {
|
|
1542
1549
|
if (archiveChannel.isThread()) {
|
|
@@ -1554,7 +1561,7 @@ ${attachment.content}`;
|
|
|
1554
1561
|
hasResponse: Boolean(commandResult.response)
|
|
1555
1562
|
}, `command handled: ${content}`);
|
|
1556
1563
|
if (commandResult.response) {
|
|
1557
|
-
await sendReply(message, commandResult.response);
|
|
1564
|
+
await sendReply(message, codeFence(commandResult.response));
|
|
1558
1565
|
}
|
|
1559
1566
|
return;
|
|
1560
1567
|
}
|