export interface RoomRecord { subdomain: string; /** Session token: lets this machine post as the agent. Never shown. */ token: string; /** The link people open. Its last part is the key. */ url: string; title: string; agent: string; openedAt: string; expiresAt: string | null; /** Id of the newest message this machine has handed to the agent. */ cursor: number; closedAt?: string; } export interface RoomMessage { id: number; ts: number; from: 'agent' | 'human'; name: string; text: string; options?: string[]; answer?: { text: string; name: string; at: number; }; answers?: number; } export interface Reply { id: number; name: string; text: string; at: string; } export declare class RoomError extends Error { readonly code: string; constructor(code: string, message: string); } export declare function listRooms(): RoomRecord[]; /** The room a command means: the named one, else the newest that is still open. */ export declare function resolveRoom(name?: string): RoomRecord; /** A name for the agent on the page: the tool it runs in when that is known. */ export declare function defaultAgentName(): string; export declare function openRoom(opts: { title: string; agent?: string; ttl?: string; }): Promise; export declare function say(record: RoomRecord, text: string): Promise; export interface AskResult { answered: boolean; /** The reply that settled it: the tapped option, else the first thing typed. */ answer?: string; /** True when the answer is one of the offered options. */ option?: boolean; by?: string; /** Everything people wrote after the question, in order. */ replies: Reply[]; closed: boolean; } export declare function ask(record: RoomRecord, question: string, opts: { options?: string[]; timeoutMs: number; }): Promise; /** Replies that arrived since the agent last looked, waiting for one if there are none. */ export declare function waitForReplies(record: RoomRecord, timeoutMs: number): Promise<{ replies: Reply[]; closed: boolean; }>; export declare function transcript(record: RoomRecord): Promise; /** Close the room and stop the endpoint behind it, so billing stops too. */ export declare function closeRoom(record: RoomRecord): Promise; /** "90s", "30m", "2h" to milliseconds. */ export declare function parseWait(value: string | undefined, fallbackMs: number): number; /** Print a failure the way the caller asked for it, and exit. */ export declare function failRoom(err: unknown, json?: boolean): never; export declare function openCmd(title: string, options: { agent?: string; ttl?: string; json?: boolean; }): Promise; export declare function askCmd(parts: string[], options: { options?: string; timeout?: string; json?: boolean; }): Promise; export declare function sayCmd(parts: string[], options: { json?: boolean; }): Promise; export declare function waitCmd(name: string | undefined, options: { timeout?: string; json?: boolean; }): Promise; export declare function readCmd(name: string | undefined, options: { json?: boolean; }): Promise; export declare function closeCmd(name: string | undefined, options: { json?: boolean; }): Promise; /** * `room listen`: stay in the room and run a command for every message a * person writes. This is how an agent that is not in the middle of a turn * gets told a message arrived: the command starts it (or resumes it) with the * message, and the agent answers with `otterkit room say`. * * The message reaches the command through the environment and stdin only. It * is never placed into the command line, so what a person types cannot change * the command that runs. */ export declare function listenCmd(name: string | undefined, options: { exec?: string; json?: boolean; }): Promise; export declare function listCmd(options: { json?: boolean; }): void;