import type { UserContent } from "ai"; import type { ChannelAdapter } from "#channel/adapter.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 { RunMode } from "#shared/run-mode.js"; interface BaseChannelAddressDeliveryOptions { readonly auth: SessionAuthContext | null; readonly callback?: SessionCallback; readonly initiatorAuth?: SessionAuthContext | null; readonly mode?: RunMode; readonly title?: string; } /** Delivery options for a channel address whose continuation token is already bound. */ export type ChannelAddressDeliveryOptions = [TState] extends [undefined] ? BaseChannelAddressDeliveryOptions : BaseChannelAddressDeliveryOptions & { readonly state?: TState; }; /** * Dynamic handle for whichever durable session currently owns one channel-local address. * Only {@link send} may create a session when the address is unowned. */ export interface ChannelAddress { readonly continuationToken: string; deliver(input: SendPayload, options: ChannelAddressDeliveryOptions): Promise; send(message: string | UserContent, options: ChannelAddressDeliveryOptions): Promise; respond(inputResponses: SendPayload["inputResponses"], options: ChannelAddressDeliveryOptions): Promise; cancel(options?: { readonly turnId?: string; }): Promise; compact(): Promise; clear(): Promise; reset(options?: { readonly reason?: string; }): Promise; resolveSession(): Promise; } /** Factory for binding a route-local continuation token to a {@link ChannelAddress}. */ export type ChannelAddressFn = (continuationToken: string) => ChannelAddress; /** Creates one channel address backed by the runtime's continuation dispatch primitive. */ export declare function createChannelAddress(input: { readonly adapter: ChannelAdapter; readonly channelName: string; readonly continuationToken: string; readonly metadata?: { readonly requestId?: string; }; readonly runtime: Runtime; }): ChannelAddress; /** Builds a request-scoped factory for channel addresses on one authored channel. */ export declare function createChannelAddressFn(input: { readonly adapter: ChannelAdapter; readonly channelName: string; readonly metadata?: { readonly requestId?: string; }; readonly runtime: Runtime; }): ChannelAddressFn; export {};