import type { UserContent } from "ai"; import type { ChannelAdapter } from "#channel/adapter.js"; import type { ChannelDeliverySource } from "#channel/delivery-metadata.js"; import type { Session } from "#channel/session.js"; import type { CancelTurnResult, ClearSessionResult, CompactSessionResult, ResetSessionResult, Runtime, SessionAuthContext, SessionCallback, TurnPolicy } from "#channel/types.js"; import { type InputResponse, type StrictInputResponses } from "#shared/input.js"; import type { JsonObject } from "#shared/json.js"; interface BaseChannelSendOptions { readonly auth: SessionAuthContext | null; readonly callback?: SessionCallback; readonly context?: readonly string[]; readonly initiatorAuth?: SessionAuthContext | null; /** JSON Schema for a structured final answer, as on `Session.send()`. */ readonly outputSchema?: JsonObject; readonly title?: string; readonly turnPolicy?: TurnPolicy; } /** Options for sending a message from a channel-local continuation address. */ export type ChannelSendOptions = [TState] extends [undefined] ? BaseChannelSendOptions : BaseChannelSendOptions & { readonly state: TState; }; interface BaseChannelRespondOptions { readonly auth: SessionAuthContext | null; readonly context?: readonly string[]; readonly state?: Partial; } /** Options for answering pending input requests at an existing continuation address. */ export type ChannelRespondOptions = BaseChannelRespondOptions; /** Dynamic handle for whichever session currently owns one channel-local address. */ export interface ChannelSource { /** Starts or resumes a turn with a user message. May create a session. */ send(message: string | UserContent, options: ChannelSendOptions): Promise; /** Answers pending input requests. Never creates a session. */ respond(inputResponses: StrictInputResponses, options: ChannelRespondOptions): Promise; /** Cooperatively cancels the active turn without creating a session. */ cancel(options?: { readonly turnId?: string; }): Promise; /** Queues context compaction without creating a session. */ compact(): Promise; /** Clears model-message history without creating a session. */ clear(): Promise; /** Retires the current owner without creating a replacement. */ reset(options?: { readonly reason?: string; }): Promise; } /** Binds a raw channel-local continuation address to its current-owner operations. */ export type ChannelFrom = (address: string) => ChannelSource; /** Snapshots the session currently owning a channel-local continuation address. */ export type ChannelResolveSession = (address: string) => Promise; /** Continuation operations passed to an authored channel's proactive `receive` hook. */ export interface ChannelReceiveContext { readonly from: ChannelFrom; readonly resolveSession: ChannelResolveSession; } /** Creates request-scoped channel operations backed by continuation dispatch. */ export declare function createChannelOperations(input: { readonly adapter: ChannelAdapter; readonly channelName: string; readonly metadata?: ChannelDeliverySource; readonly runtime: Runtime; readonly turnPolicy?: TurnPolicy; }): ChannelReceiveContext; export {};