import type { UserContent } from "ai"; import type { ChannelAdapter } from "#channel/adapter.js"; import { type ChannelReference, type CompiledChannel } from "#channel/compiled-channel.js"; import type { InferReceiveTarget } from "#channel/receive-target.js"; import type { Session } from "#channel/session.js"; import type { Runtime, SessionAuthContext } from "#channel/types.js"; import type { ResolvedChannelDefinition } from "#runtime/types.js"; /** * Options for sending a message to a channel selected with `ctx.to(...)`. */ export interface CrossChannelSendOptions { readonly auth: SessionAuthContext | null; } /** Message delivery bound to one channel-specific proactive target. */ export interface CrossChannelTargetHandle { send(message: string | UserContent, options: CrossChannelSendOptions): Promise; } /** Selects another authored channel and one of its proactive targets. */ export type CrossChannelToFn = >(channel: TChannel, target: InferReceiveTarget) => CrossChannelTargetHandle; /** * Channel record consumed by the receiver — keeps the public-facing * `definition` reference so callers can identify a target by value * (the same module-default they imported in their route file). */ export interface CrossChannelTarget { readonly name: string; readonly definition: CompiledChannel; readonly receive?: CompiledChannel["receive"]; readonly adapter?: ChannelAdapter; } /** * Projects an agent's resolved channels into the receiver-input shape. * * Framework-internal fetch-only channels carry no `definition` reference * and are filtered out at this boundary — only authored channels backed * by a `defineChannel` value can be receive targets. */ export declare function toCrossChannelTargets(channels: readonly ResolvedChannelDefinition[]): readonly CrossChannelTarget[]; /** * Builds the `ctx.to(channel, target)` closure used by route and schedule handlers. */ export declare function createCrossChannelToFn(runtime: Runtime, channels: readonly CrossChannelTarget[]): CrossChannelToFn; interface InvokeChannelReceiveInput { readonly runtime: Runtime; readonly target: Pick; readonly input: { readonly message: string | UserContent; readonly target: Readonly>; readonly auth: SessionAuthContext | null; }; readonly describeMissingReceive: () => string; readonly describeMissingAdapter: () => string; } /** * Shared authored `receive(input, ctx)` invocation used by route and schedule delivery. */ export declare function invokeChannelReceive(args: InvokeChannelReceiveInput): Promise; export {};