@friendlyrobot/discord-pi-agent 0.19.13 → 0.19.14

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.
@@ -1,4 +1,6 @@
1
1
  import type { Message } from "discord.js";
2
2
  export declare function addWorkingReaction(message: Message): Promise<void>;
3
3
  export declare function removeWorkingReaction(message: Message): Promise<void>;
4
- export declare function sendReply(message: Message, text: string): Promise<void>;
4
+ export declare function sendReply(message: Message, text: string, opts?: {
5
+ codeFence?: boolean;
6
+ }): Promise<void>;
package/dist/index.js CHANGED
@@ -1140,7 +1140,7 @@ async function removeWorkingReaction(message) {
1140
1140
  logger7.debug({ messageId: message.id, error }, "failed to remove working reaction");
1141
1141
  }
1142
1142
  }
1143
- async function sendReply(message, text) {
1143
+ async function sendReply(message, text, opts) {
1144
1144
  const channel = message.channel;
1145
1145
  if (!channel.isSendable()) {
1146
1146
  logger7.debug({
@@ -1148,7 +1148,10 @@ async function sendReply(message, text) {
1148
1148
  }, "reply skipped, channel not sendable");
1149
1149
  return;
1150
1150
  }
1151
- const chunks = chunkMessage(text);
1151
+ const wrap = opts?.codeFence ? (c) => `\`\`\`
1152
+ ${c}
1153
+ \`\`\`` : (c) => c;
1154
+ const chunks = chunkMessage(text).map(wrap);
1152
1155
  const [firstChunk, ...remainingChunks] = chunks;
1153
1156
  if (!firstChunk) {
1154
1157
  return;
@@ -1449,11 +1452,6 @@ function normalizeContextValue(value) {
1449
1452
 
1450
1453
  // src/discord-message-handler.ts
1451
1454
  var logger11 = createModuleLogger("discord-message-handler");
1452
- function codeFence(text) {
1453
- return `\`\`\`
1454
- ${text}
1455
- \`\`\``;
1456
- }
1457
1455
  function buildDiscordPromptContent(message, scope, content, config) {
1458
1456
  const isThread = scope.startsWith("thread:") && message.channel.isThread();
1459
1457
  return buildDiscordMessageContextPrompt(content, {
@@ -1543,7 +1541,9 @@ ${attachment.content}`;
1543
1541
  logger11.info({ scope }, "archiving thread");
1544
1542
  const archiveChannel = message.channel;
1545
1543
  if (archiveChannel.isSendable()) {
1546
- await archiveChannel.send(codeFence(commandResult.response ?? "Archiving..."));
1544
+ await archiveChannel.send(`\`\`\`
1545
+ ${commandResult.response ?? "Archiving..."}
1546
+ \`\`\``);
1547
1547
  }
1548
1548
  try {
1549
1549
  if (archiveChannel.isThread()) {
@@ -1561,7 +1561,7 @@ ${attachment.content}`;
1561
1561
  hasResponse: Boolean(commandResult.response)
1562
1562
  }, `command handled: ${content}`);
1563
1563
  if (commandResult.response) {
1564
- await sendReply(message, codeFence(commandResult.response));
1564
+ await sendReply(message, commandResult.response, { codeFence: true });
1565
1565
  }
1566
1566
  return;
1567
1567
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@friendlyrobot/discord-pi-agent",
3
- "version": "0.19.13",
3
+ "version": "0.19.14",
4
4
  "description": "Reusable Discord gateway for persistent pi agent sessions",
5
5
  "license": "MIT",
6
6
  "type": "module",