import type { UserContent } from "ai"; import type { ChannelAdapter } from "#channel/adapter.js"; import { 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 accepted by {@link CrossChannelReceiveFn}. Mirrors the input * argument of a channel's authored `receive(input, { send })` hook — * the runtime constructs `send` internally so route-handler callers * only supply the platform target, payload, and auth. */ export interface CrossChannelReceiveOptions> { readonly message: string | UserContent; readonly target: TTarget; readonly auth: SessionAuthContext | null; } /** * Starts a session on a different channel from inside a route handler. * The target channel's authored `receive` hook owns continuation-token * format and initial state; `auth` is forwarded verbatim and becomes * `session.initiatorAuth`. */ export type CrossChannelReceiveFn = (channel: TChannel, options: CrossChannelReceiveOptions>) => Promise; /** * 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 `args.receive` closure used by every route handler. The * closure resolves the target channel by reference identity against * the request-scoped channel bundle, then delegates to the target's * authored `receive` hook with a per-target `send` factory. */ export declare function createCrossChannelReceiveFn(runtime: Runtime, channels: readonly CrossChannelTarget[]): CrossChannelReceiveFn; interface InvokeChannelReceiveInput { readonly runtime: Runtime; readonly target: Pick; readonly input: { readonly message: string; readonly target: Readonly>; readonly auth: SessionAuthContext | null; }; readonly describeMissingReceive: () => string; readonly describeMissingAdapter: () => string; } /** * Shared `receive(input, { send })` invocation used by both the route- * handler cross-channel surface and the schedule dispatcher. Owns the * receive/adapter precondition checks and the per-target `send` * factory so both call sites stay byte-identical. */ export declare function invokeChannelReceive(args: InvokeChannelReceiveInput): Promise; export {};