eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
61 lines (60 loc) • 2.47 kB
TypeScript
/**
* Twilio inbound webhook parsing and prompt shaping.
*
* The channel owns these small data shapes instead of exposing raw
* Twilio webhook payloads as the public API surface.
*/
/** Channel-owned representation of one inbound Twilio text message. */
export interface TwilioTextMessage {
readonly from: string;
readonly to: string | undefined;
readonly body: string;
readonly messageSid: string | undefined;
readonly accountSid: string | undefined;
readonly raw: URLSearchParams;
}
/** Channel-owned representation of one inbound Twilio voice call. */
export interface TwilioVoiceCall {
readonly from: string;
readonly to: string | undefined;
readonly callSid: string | undefined;
readonly accountSid: string | undefined;
readonly raw: URLSearchParams;
}
/** Channel-owned representation of one inbound Twilio voice transcription. */
export interface TwilioVoiceTranscription {
readonly from: string;
readonly to: string | undefined;
readonly callSid: string | undefined;
readonly text: string;
readonly confidence: number | undefined;
readonly transcriptionSid: string | undefined;
readonly raw: URLSearchParams;
}
/**
* Inbound identity fields for the model-visible `<twilio_context>` block.
* Stores the caller and receiver numbers, the originating SID, and the turn
* medium (text or voice).
*/
export interface TwilioInboundContext {
readonly from: string;
readonly to?: string;
readonly messageSid?: string;
readonly callSid?: string;
readonly channel: "text" | "voice";
}
/** Parses Twilio's incoming-message webhook fields. */
export declare function parseTwilioTextMessage(params: URLSearchParams): TwilioTextMessage | null;
/** Parses Twilio's incoming-call webhook fields. */
export declare function parseTwilioVoiceCall(params: URLSearchParams): TwilioVoiceCall | null;
/**
* Parses Twilio voice transcription fields.
*
* Supports `<Gather input="speech">` (`SpeechResult`), recording
* transcription callbacks (`TranscriptionText`), and real-time
* transcription callbacks (`TranscriptionData` JSON). Real-time partial
* results are ignored until Twilio marks them final.
*/
export declare function parseTwilioVoiceTranscription(params: URLSearchParams): TwilioVoiceTranscription | null;
/** Renders a deterministic `<twilio_context>` block for the model. */
export declare function formatTwilioContextBlock(context: TwilioInboundContext): string;