UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

75 lines (74 loc) 3.41 kB
/** * Minimal Twilio REST API wrapper used by the Twilio channel. * * Requests use Twilio's normal `application/x-www-form-urlencoded` * body encoding and HTTP Basic auth. No Twilio SDK dependency is * required or exposed through eve public APIs. */ import { type TwilioAuthToken } from "#public/channels/twilio/verify.js"; /** * Builds the Twilio channel-local continuation token * (`<from>:<to>`). Route `send()` namespaces this with the channel * name before passing it to the runtime (`twilio:<from>:<to>`), so * Twilio routes should pass the raw channel-local form returned * here. `to` may be empty for proactive sessions that don't yet know * the Twilio sender number. */ export declare function twilioContinuationToken(from: string, to: string | undefined): string; /** Twilio Account SID, materialized directly or from an async secret provider. */ export type TwilioAccountSid = string | (() => string | Promise<string>); /** Fetch implementation override matching the global `fetch` signature. Defaults to the runtime global; supply a custom one for tests or non-standard runtimes. */ export type TwilioFetch = typeof fetch; /** Credentials required for Twilio REST API calls and webhook verification. */ export interface TwilioCredentials { readonly accountSid?: TwilioAccountSid; readonly authToken?: TwilioAuthToken; } /** Shared Twilio REST API options. */ export interface TwilioApiOptions { readonly credentials?: TwilioCredentials; readonly apiBaseUrl?: string; readonly fetch?: TwilioFetch; } /** * Result of a Twilio REST call: HTTP `status`, an `ok` flag, and `body`. * `body` holds parsed JSON for a JSON response, the raw text string * otherwise, or `null` when empty. */ export interface TwilioApiResponse { readonly status: number; readonly ok: boolean; readonly body: unknown; } /** Parameters for creating an outbound Twilio message. */ export interface TwilioSendMessageInput extends TwilioApiOptions { readonly to: string; readonly body: string; readonly from?: string; readonly messagingServiceSid?: string; readonly statusCallbackUrl?: string; } /** Parameters for updating a live Twilio call with new TwiML. */ export interface TwilioUpdateCallInput extends TwilioApiOptions { readonly callSid: string; readonly twiml: string; } /** Resolves a Twilio Account SID, falling back to `TWILIO_ACCOUNT_SID`. */ export declare function resolveTwilioAccountSid(accountSid?: TwilioAccountSid): Promise<string>; /** * Calls Twilio's REST API with Basic auth and form-encoded body fields. * * `path` is relative to `https://api.twilio.com` by default and may be * pointed elsewhere through `apiBaseUrl` for tests or proxies. */ export declare function callTwilioApi(input: { readonly credentials?: TwilioCredentials; readonly apiBaseUrl?: string; readonly fetch?: TwilioFetch; readonly path: string; readonly body: Readonly<Record<string, string | number | boolean | undefined | null>>; }): Promise<TwilioApiResponse>; /** Sends an outbound SMS/MMS-style message via Twilio's Messages resource. */ export declare function sendTwilioMessage(input: TwilioSendMessageInput): Promise<TwilioApiResponse>; /** Updates a live Twilio call by posting replacement TwiML to the Calls resource. */ export declare function updateTwilioCall(input: TwilioUpdateCallInput): Promise<TwilioApiResponse>;