@wahooks/channel 0.7.0 → 0.7.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/index.js +22 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -431,9 +431,30 @@ function connectWebSocket() {
|
|
|
431
431
|
}
|
|
432
432
|
// Build message content for Claude
|
|
433
433
|
let content = text;
|
|
434
|
+
let localMediaPath = "";
|
|
434
435
|
if (hasMedia && media?.url) {
|
|
435
436
|
const mime = media.mimetype ?? "unknown";
|
|
436
|
-
|
|
437
|
+
// Download media locally so Claude can access it directly
|
|
438
|
+
try {
|
|
439
|
+
const mediaRes = await fetch(media.url, {
|
|
440
|
+
headers: { Authorization: `Bearer ${API_KEY}` },
|
|
441
|
+
});
|
|
442
|
+
if (mediaRes.ok) {
|
|
443
|
+
const buf = Buffer.from(await mediaRes.arrayBuffer());
|
|
444
|
+
const ext = mime.split("/")[1]?.split(";")[0] ?? "bin";
|
|
445
|
+
localMediaPath = path.join(os.tmpdir(), `wahooks-media-${Date.now()}.${ext}`);
|
|
446
|
+
fs.writeFileSync(localMediaPath, buf);
|
|
447
|
+
content = `${text ? text + "\n\n" : ""}[Attached: ${mime}] Saved to: ${localMediaPath}`;
|
|
448
|
+
console.error(`[wahooks-channel] Media saved: ${localMediaPath} (${buf.length} bytes)`);
|
|
449
|
+
}
|
|
450
|
+
else {
|
|
451
|
+
content = `${text ? text + "\n\n" : ""}[Attached: ${mime}] (could not download)`;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
catch (err) {
|
|
455
|
+
content = `${text ? text + "\n\n" : ""}[Attached: ${mime}] (download failed)`;
|
|
456
|
+
console.error(`[wahooks-channel] Media download failed: ${err}`);
|
|
457
|
+
}
|
|
437
458
|
}
|
|
438
459
|
// Forward to Claude Code
|
|
439
460
|
await mcp.notification({
|