/** * Widget-side ergonomics over the typed SessionsClient. * * This is NOT a second session API — every call below delegates to * `client.sessions.*`. What it adds is one uniform result shape for the UI: * the typed client reports failures two ways (a TorukErrorResponse envelope * for HTTP errors, a thrown TorukSdkError for network/config failures) and the * widget needs to render both as the same "session list unavailable" state. * * It also classifies failures as permanent or transient. That distinction is * what stops retry storms: a permanent failure disables the trigger for the * rest of the widget's lifetime, and a transient one is retried a bounded * number of times. Neither ever falls back to a local session store — Core * remains the only source of truth, so an outage shows an error, not a * silently divergent second history. */ import { type WidgetClientParams } from './toruk-client'; import type { TranscriptionResult } from '@/employees/employees.client'; import type { TorukSession, TorukSessionList, TorukSessionMessageList, TorukSessionDeleted, TorukSessionBranches, TorukSessionBranchSwitched, TorukSessionMessagesTruncated, ListSessionsInput, GetSessionMessagesInput } from '@/sessions/sessions.types'; export type SessionFailure = { ok: false; code: string; message: string; /** True when retrying cannot succeed (auth, missing deployment, bad config). */ permanent: boolean; }; export type SessionResult = { ok: true; data: T; } | SessionFailure; export declare function isPermanentSessionFailure(code: string): boolean; export type WidgetSessionParams = WidgetClientParams; export declare const widgetSessions: { create(params: WidgetSessionParams, input?: { chatId?: string; title?: string; }): Promise>; list(params: WidgetSessionParams, input?: Omit): Promise>; get(params: WidgetSessionParams, sessionId: string): Promise>; getMessages(params: WidgetSessionParams, input: Omit): Promise>; rename(params: WidgetSessionParams, sessionId: string, title: string): Promise>; delete(params: WidgetSessionParams, sessionId: string): Promise>; /** The conversation's message versions, one group per edited turn. */ listBranches(params: WidgetSessionParams, sessionId: string): Promise>; /** Make one version of an edited turn live. */ switchBranch(params: WidgetSessionParams, sessionId: string, input: { branchIndex: number; forkAfterMessageId?: string | null; }): Promise>; /** Fork the conversation at a message — the server half of editing a turn. */ truncateMessages(params: WidgetSessionParams, sessionId: string, messageId: string): Promise>; }; /** * Transcribe a recorded clip, flattened into the same result shape the widget * renders everywhere else. * * Lives beside the session helpers rather than in a module of its own because it * shares the one thing that matters: `run()`, which collapses the typed client's * envelope-vs-throw failure channels into a single value the UI can branch on. */ export declare function widgetTranscribe(params: WidgetSessionParams, input: { audio: string; mime?: string; chatId?: string; }): Promise>;