export type AdapterCapability = 'send' | 'receive' | 'threads' | 'attachments' | 'interactive' | 'markdown' | 'edit' | 'delete' | 'reaction' | 'mention' | 'rich_cards' | 'sync_reply' | 'typing' | 'ephemeral' | 'proactive' | 'commands' | 'presence'; export interface AdapterManifest { readonly id: string; readonly name: string; readonly version: string; readonly capabilities: readonly AdapterCapability[]; readonly description?: string; readonly configSchema?: object | string; readonly envVars?: readonly string[]; readonly homepage?: string; readonly sdkVersion?: string; readonly platform?: string; } export interface IChannelAdapter { readonly manifest: AdapterManifest; start(ctx: AdapterContext): Promise; stop(ctx: AdapterContext): Promise; send(ctx: AdapterContext, msg: OutboundMessage): Promise; healthcheck?(ctx: AdapterContext): Promise; validateConfig?(raw: unknown): TConfig; describe?(): AdapterManifest; handleUninstall?(ctx: AdapterContext): Promise; getInstallUrl?(state: InstallState): Promise; completeInstall?(callback: InstallCallback): Promise; } export interface InstallState { readonly instanceId: string; readonly nonce: string; readonly redirectUri: string; readonly scopes?: readonly string[]; } export interface InstallCallback { readonly query: Readonly>; readonly nonce: string; } export interface AdapterContext { readonly instanceId: string; readonly installationId?: string; readonly config: TConfig; readonly capabilities: ReadonlySet; readonly log: Logger; readonly agentRunner: AgentRunner; readonly db: AdapterStore; readonly storage: BlobStorage; readonly audit: AuditSink; readonly abortSignal: AbortSignal; readonly httpRouter: HttpRouter; inbound(msg: InboundMessage): Promise; emitEvent(event: InboundEvent): Promise; updateMessage(messageId: string, patch: Partial): Promise; resolveUser(userId: string): Promise; respondSync(payload: OutboundMessage | { text: string; raw?: unknown; }): Promise; proactive?(threadId: string, msg: OutboundMessage): Promise; } export interface ResolvedUser { readonly userId: string; readonly displayName: string; readonly email?: string; readonly raw?: unknown; } export interface RouteResolution { readonly accepted: boolean; readonly reason?: string; readonly output?: string; } export interface EventResolution { readonly accepted: boolean; readonly reason?: string; } export interface HttpRouter { registerRoute(path: string, handler: (req: RawRequest, res: RawResponse) => Promise, opts?: RouteOptions): void; } export interface RouteOptions { readonly requireSignature?: { readonly headerName: string; readonly verify: (rawBody: Buffer, signature: string) => boolean; }; readonly rateLimit?: { readonly requestsPerMin: number; }; readonly timeoutMs?: number; } export interface RawRequest { readonly method: string; readonly url: string; readonly headers: Readonly>; readonly body: Buffer; readonly params: Readonly>; readonly query: Readonly>; } export interface RawResponse { status(code: number): RawResponse; set(field: string, value: string): RawResponse; send(body: Buffer | string): RawResponse; json(body: unknown): RawResponse; end(): RawResponse; } export interface InboundMessage { readonly id: string; readonly threadId: string; readonly userId: string; readonly text: string; readonly receivedAt: number; readonly attachments?: readonly { readonly url: string; readonly mimeType?: string; readonly name?: string; }[]; readonly mentions?: readonly { readonly userId: string; readonly displayName: string; }[]; readonly routingHints?: { readonly agentId?: string; readonly policyTags?: readonly string[]; }; readonly raw?: unknown; } export interface OutboundMessage { readonly threadId: string; readonly text: string; readonly markdown?: boolean; readonly actions?: readonly { readonly id: string; readonly label: string; readonly value?: string; readonly blockId?: string; }[]; readonly attachments?: readonly { readonly url: string; readonly mimeType?: string; readonly name?: string; }[]; readonly cards?: readonly RichCard[]; readonly ephemeralFor?: string; readonly replyToId?: string; readonly editOf?: string; readonly raw?: unknown; } export interface RichCard { readonly id: string; readonly title?: string; readonly body?: string; readonly elements?: readonly RichCardElement[]; readonly raw?: unknown; } export type RichCardElement = { readonly type: 'text'; readonly text: string; } | { readonly type: 'button'; readonly id: string; readonly label: string; readonly value?: string; readonly blockId?: string; } | { readonly type: 'image'; readonly url: string; readonly alt?: string; }; export type InboundEvent = { readonly type: 'action'; readonly actionId: string; readonly blockId?: string; readonly threadId: string; readonly userId: string; readonly value?: string; readonly raw?: unknown; } | { readonly type: 'edit'; readonly messageId: string; readonly threadId: string; readonly text: string; } | { readonly type: 'delete'; readonly messageId: string; readonly threadId: string; } | { readonly type: 'reaction'; readonly messageId: string; readonly threadId: string; readonly userId: string; readonly emoji: string; readonly added: boolean; } | { readonly type: 'space_joined' | 'space_left'; readonly threadId: string; readonly userId?: string; readonly raw?: unknown; } | { readonly type: 'member_joined' | 'member_left'; readonly threadId: string; readonly userId: string; readonly raw?: unknown; } | { readonly type: 'command'; readonly commandId: string; readonly threadId: string; readonly userId: string; readonly text: string; readonly raw?: unknown; }; export interface SendResult { readonly messageId: string; readonly sentAt: number; } export interface HealthStatus { readonly ok: boolean; readonly details?: Record; } export declare class AdapterError extends Error { readonly code: string; readonly kind: 'transient' | 'permanent' | 'config'; readonly retryAfterMs?: number; constructor(code: string, kind: 'transient' | 'permanent' | 'config', retryAfterMs?: number); } export interface Logger { debug(msg: string, meta?: Record): void; info(msg: string, meta?: Record): void; warn(msg: string, meta?: Record): void; error(msg: string, meta?: Record): void; } export interface AgentRunner { run(agentId: string, message: string, opts?: { readonly threadId?: string; }): Promise<{ readonly output: string; }>; } export interface AdapterStore { get(key: string): Promise; set(key: string, value: T): Promise; delete(key: string): Promise; list(prefix?: string): Promise; } export interface BlobStorage { put(key: string, data: Buffer, contentType?: string): Promise; get(key: string): Promise; delete(key: string): Promise; } export interface AuditSink { log(event: string, payload: Record): Promise; } export interface ChannelAdapterRegistration { readonly adapter: IChannelAdapter; readonly instanceId: string; readonly config: TConfig; readonly installationId?: string; readonly store?: AdapterStore; readonly agentRunner?: AgentRunner; readonly defaultMode?: 'query' | 'execute'; readonly defaultAgent?: string; readonly onInbound?: (msg: InboundMessage) => Promise; }