clawgram 2.5.1 → 2.6.1

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/channel.js CHANGED
@@ -1120,8 +1120,16 @@ const createChannelPlugin = (runtimes, pluginRuntime) => {
1120
1120
  return null;
1121
1121
  }
1122
1122
  return {
1123
- actions: ["send", "read", "participants", "joins", "react", "chatInfo"],
1123
+ // `upload-file` is what core dispatches when an agent has an
1124
+ // attachment to deliver — a generated image is the common case.
1125
+ // Leaving it out does not degrade to a text send: the agent simply
1126
+ // never sees a way to send the file, announces it in words, and the
1127
+ // file stays on disk. That is exactly what happened on 2026-08-07.
1128
+ actions: ["send", "read", "participants", "joins", "react", "chatInfo", "upload-file"],
1124
1129
  capabilities: [],
1130
+ mediaSourceParams: {
1131
+ "upload-file": ["filePath", "path", "media"],
1132
+ },
1125
1133
  };
1126
1134
  },
1127
1135
  extractToolSend: ({ args }) => (0, tool_send_1.extractToolSend)(args, "sendMessage"),
@@ -1308,6 +1316,75 @@ const createChannelPlugin = (runtimes, pluginRuntime) => {
1308
1316
  removed: reactionParams.remove,
1309
1317
  });
1310
1318
  }
1319
+ // Core normalizes whichever of these it filled in to a local path (see
1320
+ // `mediaSourceParams` above); `mediaUrl` stays a URL, which GramJS
1321
+ // accepts as well.
1322
+ const attachedFile = (0, param_readers_1.readStringParam)(params, "filePath")
1323
+ ?? (0, param_readers_1.readStringParam)(params, "path")
1324
+ ?? (0, param_readers_1.readStringParam)(params, "media")
1325
+ ?? (0, param_readers_1.readStringParam)(params, "mediaUrl");
1326
+ // Core dispatches `upload-file`; `sendAttachment` is its legacy alias
1327
+ // and arrives from older callers. A plain `send` carrying a file lands
1328
+ // here too — `openclaw message send --media` does exactly that, and
1329
+ // routing it to the text path dropped the file without a word.
1330
+ if (action === "upload-file" || action === "sendAttachment" || (action === "send" && attachedFile)) {
1331
+ const rawUploadTo = (0, helpers_1.resolveActionTarget)(params, toolContext);
1332
+ const uploadTo = (0, helpers_1.normalizeOutboundTarget)(rawUploadTo);
1333
+ const uploadAccountId = resolveRuntimeAccountId(cfg, accountId);
1334
+ if (!uploadAccountId) {
1335
+ throw new Error("clawgram: no configured account found");
1336
+ }
1337
+ const file = attachedFile;
1338
+ if (!file) {
1339
+ throw new Error("clawgram: upload-file requires filePath, path, media, or mediaUrl");
1340
+ }
1341
+ const captionText = (0, helpers_1.readMessageText)(params) || ((0, param_readers_1.readStringParam)(params, "caption") ?? "");
1342
+ // A caption is optional, but the silent-reply sentinel must never
1343
+ // reach Telegram as one — same reasoning as the `send` path below.
1344
+ const caption = captionText.trim() && (0, helpers_1.isSilentReplyText)(captionText)
1345
+ ? ""
1346
+ : captionText.replaceAll("\\n", "\n");
1347
+ const uploadReplyToId = (0, param_readers_1.readStringOrNumberParam)(params, "replyToId") ?? (0, param_readers_1.readStringOrNumberParam)(params, "replyTo");
1348
+ const uploadThreadId = (0, param_readers_1.readStringOrNumberParam)(params, "threadId");
1349
+ actionLog.info("clawgram handleAction upload-file", {
1350
+ accountId: uploadAccountId,
1351
+ dryRun: dryRun === true,
1352
+ to: uploadTo,
1353
+ hasCaption: Boolean(caption),
1354
+ replyToId: uploadReplyToId ?? null,
1355
+ threadId: uploadThreadId ?? null,
1356
+ });
1357
+ if (dryRun === true) {
1358
+ return (0, core_1.jsonResult)({
1359
+ ok: true,
1360
+ dryRun: true,
1361
+ to: uploadTo,
1362
+ accountId: uploadAccountId,
1363
+ });
1364
+ }
1365
+ const uploadGram = runtimes.get(uploadAccountId);
1366
+ if (!uploadGram) {
1367
+ throw new Error(`clawgram: runtime not found for account ${uploadAccountId}`);
1368
+ }
1369
+ const uploaded = await uploadGram.sendMedia({
1370
+ target: uploadTo,
1371
+ file,
1372
+ caption: caption || undefined,
1373
+ replyToMessageId: (0, helpers_1.resolveReplyToMessageIdForTarget)(rawUploadTo, uploadReplyToId),
1374
+ messageThreadId: parseOptionalThreadId(uploadThreadId),
1375
+ });
1376
+ actionLog.info("clawgram handleAction upload-file completed", {
1377
+ accountId: uploadAccountId,
1378
+ to: uploadTo,
1379
+ sentMessageId: String(uploaded?.id ?? ""),
1380
+ });
1381
+ return (0, core_1.jsonResult)({
1382
+ ok: true,
1383
+ to: uploadTo,
1384
+ accountId: uploadAccountId,
1385
+ messageId: String(uploaded?.id ?? ""),
1386
+ });
1387
+ }
1311
1388
  if (action !== "send") {
1312
1389
  throw new Error(`clawgram: unsupported message action ${action}`);
1313
1390
  }
@@ -2,7 +2,7 @@
2
2
  "id": "clawgram",
3
3
  "name": "Clawgram",
4
4
  "description": "Clawgram — personal Telegram (MTProto userbot) channel for OpenClaw. Your AI assistant reads and responds as you.",
5
- "version": "2.5.1",
5
+ "version": "2.6.1",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawgram",
3
- "version": "2.5.1",
3
+ "version": "2.6.1",
4
4
  "description": "Clawgram — personal Telegram (MTProto userbot) channel for OpenClaw. Your AI assistant reads and responds as you.",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {