import type { HumanDecisionChannelRequest, HumanDecisionResponse } from "../workflows/types.js"; export declare const CHANNEL_ADAPTER_PROTOCOL_SCHEMA: "pi-workflows.channel-adapter.v1"; export type TelegramMessageReference = { chatId: string; messageId: string; recipientIndex: number; partIndex: number; contentDigest: string; }; type ChannelAdapterMessageBase = { schema: typeof CHANNEL_ADAPTER_PROTOCOL_SCHEMA; adapterEpoch: string; profile: string; sequence: number; expectedRevision: number; stableMessageId: string; }; export type ChannelAdapterMessage = (ChannelAdapterMessageBase & { kind: "channel.ready"; cursor: number; }) | (ChannelAdapterMessageBase & { kind: "channel.present"; decisionId: string; requestDigest: string; attemptId: string; state: "confirmed" | "failed" | "unknown"; messages: TelegramMessageReference[]; errorCode?: string; }) | (ChannelAdapterMessageBase & { kind: "channel.answer"; decisionId: string; requestDigest: string; response: HumanDecisionResponse; actorId: string; chatId: string; eventId: string; idempotencyKey: string; cursor: number; }) | (ChannelAdapterMessageBase & { kind: "channel.settle"; decisionId: string; requestDigest: string; attemptId: string; state: "confirmed" | "failed" | "unknown"; errorCode?: string; }) | (ChannelAdapterMessageBase & { kind: "channel.exiting"; cursor: number; }); export type ChannelAdapterCommand = { kind: "channel.present"; stableMessageId: string; attemptId: string; request: HumanDecisionChannelRequest; } | { kind: "channel.settle"; stableMessageId: string; attemptId: string; request: HumanDecisionChannelRequest; outcome: "accepted" | "cancelled" | "expired"; response?: HumanDecisionResponse; messages: TelegramMessageReference[]; } | { kind: "channel.poll"; cursor: number; requests: HumanDecisionChannelRequest[]; } | { kind: "channel.stop"; }; export type ChannelAdapterResponse = { schema: typeof CHANNEL_ADAPTER_PROTOCOL_SCHEMA; type: "response"; sequence: number; outcome: "accepted" | "rejected"; revision: number; command: ChannelAdapterCommand | null; error?: string; }; export type ChannelAdapterLaunch = { schema: "pi-workflows.channel-adapter-launch.v1"; adapterEpoch: string; profile: string; token: string; allowedUserIds: string[]; allowedChatIds: string[]; apiBase?: string; }; export declare function encodeChannelLine(value: ChannelAdapterMessage | ChannelAdapterResponse): Buffer; export declare function parseChannelAdapterMessage(frame: Buffer): ChannelAdapterMessage; export declare function parseChannelAdapterResponse(frame: Buffer): ChannelAdapterResponse; export declare function parseChannelAdapterLaunch(value: unknown): ChannelAdapterLaunch; export declare function channelResponse(message: ChannelAdapterMessage, outcome: ChannelAdapterResponse["outcome"], revision: number, command: ChannelAdapterCommand | null, error?: string): ChannelAdapterResponse; export declare function channelStableMessageId(parts: readonly string[]): string; export {};