/** * Interface-driven gateways & scheduling (adaptive-agent design R8). * * pi does NOT bake transports (Slack/Discord/email/webhooks) or a cron tick loop into the core — that * would bloat the agent and couple it to deployment concerns. Instead it exposes two provider contracts * that a deployment wrapper (server, headless runner) implements and registers; the core only manages * their lifecycle. This keeps the CLI/agent transport- and schedule-agnostic while still offering a * first-class, uniform extension point. */ /** A message arriving from / sent to an external channel (gateway). */ export interface ChannelMessage { /** Stable conversation/session key for this channel (e.g. `slack_C123`). */ conversationKey: string; /** Message text. */ text: string; /** Optional opaque metadata the provider round-trips. */ meta?: Record; } /** Handler the core supplies to a channel for inbound messages. */ export type ChannelInboundHandler = (message: ChannelMessage) => void | Promise; /** * A transport channel (Telegram/Slack/email/webhook/...). Implemented by a deployment wrapper and * registered via {@link GatewayRegistry}. The core starts it (handing it an inbound handler) and stops * it on shutdown; it never imports any transport SDK itself. */ export interface ChannelProvider { readonly name: string; /** Begin listening; deliver inbound messages to `onInbound`. */ start(onInbound: ChannelInboundHandler): void | Promise; /** Send an outbound message on this channel. */ send(message: ChannelMessage): void | Promise; /** Stop listening and release resources. */ stop(): void | Promise; } /** A scheduled job definition. */ export interface ScheduledJob { id: string; /** Cron expression or interval spec the provider understands. */ schedule: string; /** Invoked when the job fires. */ run: () => void | Promise; } /** * A scheduler (cron-like). Implemented by a deployment wrapper and registered via * {@link GatewayRegistry}. The core registers jobs + starts/stops it; it owns no tick loop itself. */ export interface JobSchedulerProvider { readonly name: string; schedule(job: ScheduledJob): void; start(): void | Promise; stop(): void | Promise; } /** * Holds registered channel + scheduler providers and drives their lifecycle. A session starts all * registered providers when it binds and stops them on dispose. Registration is additive and idempotent * by provider name (last registration wins). */ export declare class GatewayRegistry { private readonly channels; private readonly schedulers; private started; private inboundHandler; private readonly pendingLifecycle; private trackLifecycle; private drainLifecycle; registerChannel(provider: ChannelProvider): void; registerScheduler(provider: JobSchedulerProvider): void; getChannel(name: string): ChannelProvider | undefined; get channelCount(): number; get schedulerCount(): number; /** Start every registered provider; inbound channel messages are routed to `onInbound`. */ start(onInbound: ChannelInboundHandler): Promise; /** Stop every registered provider. Best-effort; always leaves the registry stopped. */ stop(): Promise; } //# sourceMappingURL=channel-provider.d.ts.map