import type { UserContent } from "ai"; import type { ChannelAdapter } from "#channel/adapter.js"; import { type ChannelAddressDeliveryOptions } from "#channel/channel-address.js"; import type { SendPayload } from "#channel/routes.js"; import type { Session } from "#channel/session.js"; import type { CancelTurnResult, ClearSessionResult, CompactSessionResult, ResetSessionResult, Runtime, SessionAuthContext, SessionCallback } from "#channel/types.js"; import type { InputResponse } from "#runtime/input/types.js"; import type { JsonObject } from "#shared/json.js"; import type { RunMode } from "#shared/run-mode.js"; interface BaseChannelSendOptions { readonly auth: SessionAuthContext | null; readonly callback?: SessionCallback; readonly context?: readonly string[]; readonly initiatorAuth?: SessionAuthContext | null; readonly mode?: RunMode; readonly outputSchema?: JsonObject; readonly title?: string; } /** 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 outputSchema?: JsonObject; } /** 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: readonly InputResponse[], 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; } export declare const INTERNAL_CHANNEL_DELIVER: unique symbol; /** @internal Permissive transport delivery retained below public authoring surfaces. */ export interface InternalChannelSource extends ChannelSource { [INTERNAL_CHANNEL_DELIVER](payload: SendPayload, options: ChannelAddressDeliveryOptions): Promise; } /** Creates request-scoped channel operations backed by continuation dispatch. */ export declare function createChannelOperations(input: { readonly adapter: ChannelAdapter; readonly channelName: string; readonly metadata?: { readonly requestId?: string; }; readonly runtime: Runtime; }): ChannelReceiveContext; export {};