feat: add image support across web and twilio
This commit is contained in:
@@ -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;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user