@friendlyrobot/discord-pi-agent 0.10.5 → 0.11.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.
Files changed (2) hide show
  1. package/dist/index.js +44 -3
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1002,7 +1002,7 @@ async function sendTypingSafe(channel, channelKey) {
1002
1002
  headers: { Authorization: `Bot ${token}` }
1003
1003
  });
1004
1004
  if (res.ok) {
1005
- logger5.debug(`[TYPING] STATUS UPDATED OK: ${await res.text()}`);
1005
+ logger5.debug(`[TYPING] STATUS UPDATED OK`);
1006
1006
  return;
1007
1007
  }
1008
1008
  if (res.status === 429) {
@@ -1082,6 +1082,39 @@ async function sendReply(message, text) {
1082
1082
  }, "send reply failed");
1083
1083
  }
1084
1084
  }
1085
+ var TEXT_ATTACHMENT_EXTENSIONS = [".txt", ".md", ".json", ".csv", ".log", ".yml", ".yaml", ".xml", ".toml", ".ini", ".cfg"];
1086
+ var MAX_ATTACHMENT_SIZE_BYTES = 25 * 1024 * 1024;
1087
+ async function readTextAttachments(message) {
1088
+ const attachments = message.attachments;
1089
+ if (attachments.size === 0) {
1090
+ return [];
1091
+ }
1092
+ const results = [];
1093
+ for (const [, attachment] of attachments) {
1094
+ const ext = attachment.name?.slice(attachment.name.lastIndexOf(".")).toLowerCase();
1095
+ if (!ext || !TEXT_ATTACHMENT_EXTENSIONS.includes(ext)) {
1096
+ logger5.debug({ messageId: message.id, filename: attachment.name, ext }, "skipping non-text attachment");
1097
+ continue;
1098
+ }
1099
+ if (attachment.size > MAX_ATTACHMENT_SIZE_BYTES) {
1100
+ logger5.warn({ messageId: message.id, filename: attachment.name, size: attachment.size }, "attachment too large, skipping");
1101
+ continue;
1102
+ }
1103
+ try {
1104
+ logger5.info({ messageId: message.id, filename: attachment.name, size: attachment.size }, "fetching attachment");
1105
+ const response = await fetch(attachment.url);
1106
+ if (!response.ok) {
1107
+ logger5.warn({ messageId: message.id, filename: attachment.name, status: response.status }, "failed to fetch attachment");
1108
+ continue;
1109
+ }
1110
+ const content = await response.text();
1111
+ results.push({ filename: attachment.name, content });
1112
+ } catch (error) {
1113
+ logger5.error({ messageId: message.id, filename: attachment.name, error }, "error fetching attachment");
1114
+ }
1115
+ }
1116
+ return results;
1117
+ }
1085
1118
  async function startGatewayClient(config, agentService, sessionRegistry, authConfig) {
1086
1119
  const client = new Client({
1087
1120
  intents: [
@@ -1149,7 +1182,15 @@ async function onMessage(message, config, agentService, sessionRegistry, authCon
1149
1182
  }, "unauthorized");
1150
1183
  return;
1151
1184
  }
1152
- const content = message.content.trim();
1185
+ let content = message.content.trim();
1186
+ const attachmentContents = await readTextAttachments(message);
1187
+ if (attachmentContents.length > 0) {
1188
+ const suffix = attachmentContents.map((a) => `
1189
+
1190
+ --- Attachment: ${a.filename} ---
1191
+ ${a.content}`).join("");
1192
+ content = content ? content + suffix : attachmentContents[0].content;
1193
+ }
1153
1194
  if (!content) {
1154
1195
  logger5.debug({ messageId: message.id }, "ignored empty message");
1155
1196
  return;
@@ -1202,7 +1243,7 @@ async function onMessage(message, config, agentService, sessionRegistry, authCon
1202
1243
  messageId: message.id,
1203
1244
  command: content,
1204
1245
  hasResponse: Boolean(commandResult.response)
1205
- }, "command handled");
1246
+ }, `command handled: ${content}`);
1206
1247
  if (commandResult.response) {
1207
1248
  await sendReply(message, commandResult.response);
1208
1249
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@friendlyrobot/discord-pi-agent",
3
- "version": "0.10.5",
3
+ "version": "0.11.0",
4
4
  "description": "Reusable Discord gateway bridge for persistent pi agent sessions",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/node": "^25.6.2",
49
- "@typescript/native-preview": "^7.0.0-dev.20260508.1",
49
+ "@typescript/native-preview": "^7.0.0-dev.20260510.1",
50
50
  "@vitest/ui": "^4.1.5",
51
51
  "vitest": "^4.1.5"
52
52
  }