/** * Channel-neutral authoring and runtime contracts. * * Provider-specific fields belong in a validated `native` payload or the * managed adapter — never on these core types. */ export type JsonValue = null | boolean | number | string | readonly JsonValue[] | { readonly [key: string]: JsonValue; }; /** Opaque conversation address in a provider/installation. */ export interface ChannelAddress { /** Opaque conversation identifier in this provider/installation. */ conversationId: string; /** Opaque provider thread/root identifier, when the provider has threads. */ threadId?: string; } export interface ChannelAttachmentRef { /** Opaque MDA reference, not a provider ID or bearer URL. */ id: string; kind: "file" | "image" | "audio" | "video" | "link" | "unknown"; name?: string; contentType?: string; size?: number; } export interface ChannelInboundMessage { id: string; text: string; attachments: readonly ChannelAttachmentRef[]; } export interface ChannelEvent { /** MDA delivery/audit id. */ deliveryId: string; /** Provider logical-event id, if one exists. */ eventId?: string; type: string; occurredAt?: string; address: ChannelAddress; message?: ChannelInboundMessage; interaction?: { action: string; value?: JsonValue; }; /** Provider-native payload for tools/connectors (sanitized subset). */ native?: ChannelNativePayload; } export interface ChannelNativePayload { provider: string; payload: { readonly [key: string]: JsonValue; }; } /** * Destination for channel delivery. * * Schedules cannot use `current_thread` (no originating thread). */ export type ChannelDestination = { type: "current_thread"; } | { type: "provider_thread"; conversationId: string; threadId: string; } | { type: "provider_conversation"; conversationId: string; }; export interface ChannelMessage { /** Required plain-text representation and fallback. */ text: string; to?: ChannelDestination; native?: ChannelNativePayload; } export interface PostedChannelMessage { /** Stable MDA-owned id used by update and delivery records. */ id: string; providerMessageId?: string; url?: string; } export interface ChannelMessageUpdate { text?: string; native?: ChannelNativePayload; } export interface ChannelCapabilities { update: boolean; } /** * Provider-neutral reply surface injected on channel-originated runs only. * * Absent for ordinary HTTP and schedule runs. */ export interface RuntimeChannel { /** File-derived configured channel name. */ name: string; provider: string; event: ChannelEvent; address: ChannelAddress; capabilities: ChannelCapabilities; post(message: ChannelMessage, options?: { final?: boolean; }): Promise; update?(id: string, message: ChannelMessageUpdate): Promise; } /** Stable machine-readable channel error codes (npm / PyPI / traces). */ export type ChannelErrorCode = "channel_invalid_signature" | "channel_replay_rejected" | "channel_installation_not_found" | "channel_event_filtered" | "channel_identity_unresolvable" | "channel_destination_forbidden" | "channel_invocation_rate_limited" | "channel_run_failed" | "channel_provider_rate_limited" | "channel_provider_rejected"; /** Narrow a destination to its discriminant + required address fields. */ export declare function normalizeChannelDestination(destination: ChannelDestination): { type: "current_thread"; } | { type: "provider_thread"; conversationId: string; threadId: string; } | { type: "provider_conversation"; conversationId: string; }; //# sourceMappingURL=types.d.ts.map