/** * Sandbox Chat Utility Module * Handles chat session management, message sending, and polling for responses */ import type { AxiosInstance } from 'axios'; import type { SandboxChatSession, Connector, ConversationAct, ChatDebugInfo } from '../types.js'; /** * Options for selecting which connector to chat through */ export interface ConnectorSelectionOptions { /** Integration IDN to search connectors in (default: 'sandbox') */ integrationIdn?: string; /** Exact connector_idn to use; when omitted, the first running connector is used */ connectorIdn?: string; } /** * List running connectors of an integration (default: sandbox). * Used by `newo sandbox --list-connectors` and connector selection. */ export declare function listRunningSandboxConnectors(client: AxiosInstance, integrationIdn?: string): Promise; /** * Find a sandbox connector from the customer's connectors list. * * Without options, preserves legacy behavior: first running connector of the * 'sandbox' integration. With options.connectorIdn, selects that exact * connector and throws a descriptive error (listing available connectors) * when it is not found or not running. */ export declare function findSandboxConnector(client: AxiosInstance, verbose?: boolean, options?: ConnectorSelectionOptions): Promise; /** * Create a new sandbox chat session */ export declare function createChatSession(client: AxiosInstance, connector: Connector, verbose?: boolean): Promise; /** * Send a message in the chat session * Returns the timestamp when message was sent (for filtering responses) */ export declare function sendMessage(client: AxiosInstance, session: SandboxChatSession, text: string, verbose?: boolean): Promise; /** * Poll for new conversation acts (messages and debug info) * Continues polling until we get an agent response, not just any new message * * @param settleMs - Optional multi-bubble settle window in ms (default `0`, which * preserves the original single-bubble behavior byte-for-byte - `newo sandbox`'s * call sites never pass this and must not change). When `settleMs > 0`, once the * first agent act is observed the poll keeps going, accumulating every distinct * agent act seen (deduped by a stable settle key), until either no NEW agent act has appeared * for `settleMs` or the overall `timeoutMs` budget is exhausted - whichever * comes first. The returned `acts` then include every agent act observed, not * just the newest one. Settle ordering is deterministic: `datetime` * ascending, then first-seen order for equal datetimes. */ export declare function pollForResponse(client: AxiosInstance, session: SandboxChatSession, messageSentAt?: Date | null, verbose?: boolean, timeoutMs?: number, settleMs?: number): Promise<{ acts: ConversationAct[]; agentPersonaId: string | null; userAct: ConversationAct | null; }>; /** * Normalize an act's external_event_id: the chat-history converter falls back * to the placeholder 'chat_history' when the API omits the field. Callers * (sandbox.ts, test.ts) must go through this rather than reading * act.external_event_id raw, or they'll silently correlate against the * placeholder instead of a real `newo logs --event-id` key. */ export declare function normalizeActEventId(act: ConversationAct | null | undefined): string | null; /** * Extract agent messages from acts */ export declare function extractAgentMessages(acts: ConversationAct[]): ConversationAct[]; /** * Extract debug information from acts */ export declare function extractDebugInfo(acts: ConversationAct[]): ChatDebugInfo[]; /** * Format debug info for display */ export declare function formatDebugInfo(acts: ConversationAct[]): string; //# sourceMappingURL=chat.d.ts.map