import type { UserContent } from "ai"; import type { ChannelAdapter } from "#channel/adapter.js"; import { type ChannelDeliverySource } from "#channel/delivery-metadata.js"; import type { SendPayload } from "#channel/routes.js"; import { type Session } from "#channel/session.js"; import type { CancelTurnResult, ClearSessionResult, CompactSessionResult, ResetSessionResult, Runtime, SessionAuthContext, SessionCallback, TurnPolicy } from "#channel/types.js"; interface BaseChannelAddressDeliveryOptions { readonly auth: SessionAuthContext | null; readonly callback?: SessionCallback; readonly initiatorAuth?: SessionAuthContext | null; readonly title?: string; readonly turnPolicy?: TurnPolicy; } /** Delivery options for a channel address whose continuation token is already bound. */ export type ChannelAddressDeliveryOptions = [TState] extends [undefined] ? BaseChannelAddressDeliveryOptions : BaseChannelAddressDeliveryOptions & { readonly state?: Partial; }; /** * Dynamic handle for whichever durable session currently owns one channel-local address. * Only {@link send} may create a session: when the address is unowned, or in * place of a stranded session that another eve version built. Sends to a session whose * owner is only unavailable throw `SessionStrandedError` and deliver nothing. */ 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}. */ 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?: ChannelDeliverySource; readonly runtime: Runtime; readonly turnPolicy?: TurnPolicy; }): 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?: ChannelDeliverySource; readonly runtime: Runtime; readonly turnPolicy?: TurnPolicy; }): ChannelAddressFn; export {};