feat: add image support across web and twilio

This commit is contained in:
Peter Steinberger
2025-11-25 04:58:31 +01:00
parent ac2bdcbea6
commit 948ff7f035
13 changed files with 510 additions and 82 deletions

View File

@@ -15,6 +15,7 @@ import { startWebhook } from "../webhook/server.js";
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
import { info } from "../globals.js";
import { autoReplyIfConfigured } from "../auto-reply/reply.js";
import { ensureMediaHosted } from "../media/host.js";
export type CliDeps = {
sendMessage: typeof sendMessage;
@@ -35,6 +36,10 @@ export type CliDeps = {
updateWebhook: typeof updateWebhook;
handlePortError: typeof handlePortError;
monitorWebProvider: typeof monitorWebProvider;
resolveTwilioMediaUrl: (
source: string,
opts: { serveMedia: boolean; runtime: RuntimeEnv },
) => Promise<string>;
};
export async function monitorTwilio(
@@ -79,6 +84,14 @@ export function createDefaultDeps(): CliDeps {
updateWebhook,
handlePortError,
monitorWebProvider,
resolveTwilioMediaUrl: async (source, { serveMedia, runtime }) => {
if (/^https?:\/\//i.test(source)) return source;
const hosted = await ensureMediaHosted(source, {
startServer: serveMedia,
runtime,
});
return hosted.url;
},
};
}

View File

@@ -56,6 +56,8 @@ export function buildProgram() {
"Recipient number in E.164 (e.g. +15551234567)",
)
.requiredOption("-m, --message <text>", "Message body")
.option("--media <path-or-url>", "Attach image (<=5MB). Web: path or URL. Twilio: https URL or local path hosted via webhook/funnel.")
.option("--serve-media", "For Twilio: start a temporary media server if webhook is not running", false)
.option("-w, --wait <seconds>", "Wait for delivery status (0 to skip)", "20")
.option("-p, --poll <seconds>", "Polling interval while waiting", "2")
.option("--provider <provider>", "Provider: twilio | web", "twilio")