/** * Platform-neutral session realtime: the controller hook, admission rules and * the workspace voice-model catalog. Free of DOM components, so web and native * hosts (which inject their own WebRTC through `controllerFactory`) share it. */ import { type EffectiveSessionControl, type SessionEvent, type SessionStatus } from "@opengeni/sdk"; import { type CreateSessionRealtimeControllerOptions, type SessionRealtimeClientLike, type SessionRealtimeController, type SessionRealtimeLifecycleProjection, type RealtimeVoiceSettings, type SessionRealtimeModel, type WorkspaceRealtimeModelCatalogItem } from "@opengeni/sdk/realtime"; import type { EmbeddedRealtimeSessionClientLike } from "../client.js"; import { type OpenGeniText } from "../messages/runtime.js"; export type RealtimeModelOption = { id: SessionRealtimeModel; label: string; provider: WorkspaceRealtimeModelCatalogItem["provider"]; description: string; available: boolean; unavailableReason: string | null; /** Machine-readable reason, e.g. `insufficient_credits` (same codes as voice input). */ unavailableCode?: string | null | undefined; recommended: boolean; /** * Languages a conversation with this model can be set to. Absent when the * model detects the spoken language itself. */ languages?: readonly string[] | undefined; /** Voices this model can speak with. Absent when the voice cannot be chosen. */ voices?: WorkspaceRealtimeModelCatalogItem["voices"]; /** Whether any provider voice id is accepted beyond the listed `voices`. */ customVoice?: boolean | undefined; /** Turn eagerness values this model accepts. */ turnEagerness?: WorkspaceRealtimeModelCatalogItem["turnEagerness"]; /** The provider's defaults for the settings it offers, other than language. */ voiceDefaults?: RealtimeVoiceSettings | undefined; /** The workspace's saved voice settings for this model. */ workspaceVoiceSettings?: RealtimeVoiceSettings | undefined; /** True on the model the workspace chose to start voice conversations with. */ workspaceDefault?: boolean | undefined; /** True on the model the organization chose; the workspace's own choice wins. */ organizationDefault?: boolean | undefined; }; export declare const CODEX_LIVE_MODEL: (t: OpenGeniText) => RealtimeModelOption; export type RealtimeControllerClient = EmbeddedRealtimeSessionClientLike & SessionRealtimeClientLike; /** * The person's chosen voice-conversation language (a catalog language code), or * `null` to follow their app language. Kept on this device for every workspace. */ export declare function useRealtimeLanguagePreference(): { language: string | null; setLanguage(language: string | null): void; }; /** The person's app language: the host locale, else the browser's language. */ export declare function realtimeAppLanguage(locale: string | undefined): string | undefined; /** * The language a voice conversation with `model` is held in: the person's * choice, else their app language. Undefined for models that detect the spoken * language themselves, so nothing is sent for them. */ export declare function realtimeConversationLanguage(model: Pick | undefined, preference: string | null, locale: string | undefined): string | undefined; /** Shared by the lazy conversation offer and the stock voice control. */ export declare function loadRealtimeModelCatalog(client: RealtimeControllerClient, workspaceId: string, signal?: AbortSignal): Promise | null; export type SessionRealtimeControllerFactory = (options: CreateSessionRealtimeControllerOptions) => SessionRealtimeController; /** * Start voice for a session the host has just created, before its session view * mounts. The connection comes up while the host navigates, and the view's * `useSessionRealtime` (with the same workspace, session and model) adopts the * running call instead of starting another. Call it from the action that * created the session, so the microphone prompt follows the user's gesture. * * Returns `abandon`, which ends the call if no view adopted it yet (for * example when navigation to the session failed). */ export declare function prestartSessionRealtime(input: { client: RealtimeControllerClient; workspaceId: string; sessionId: string; model: SessionRealtimeModel; /** * BCP 47 language the conversation is held in, for models that need one * (see `realtimeConversationLanguage`). */ language?: string | undefined; /** * Voice settings for this call (voice, language, turn eagerness), over the * workspace's saved settings for the model. */ voiceSettings?: RealtimeVoiceSettings | undefined; controllerFactory?: SessionRealtimeControllerFactory | undefined; }): () => void; type AdmissionInput = { sessionStatus: SessionStatus; controlState: "active" | "paused"; settlement: { state: string; } | null; codexConnected: boolean; lifecycleActive: boolean; }; export declare function codexRealtimeAdmissionAllowed(t: OpenGeniText, input: AdmissionInput): boolean; export declare function codexRealtimeAdmissionBlocker(t: OpenGeniText, input: AdmissionInput): string | null; export declare function useSessionRealtime(options: { client?: RealtimeControllerClient | undefined; workspaceId?: string | undefined; sessionId: string; sessionStatus: SessionStatus; effectiveControl: EffectiveSessionControl; events: SessionEvent[]; eventsReady: boolean; codexConnected: boolean; model?: SessionRealtimeModel | undefined; modelAvailable?: boolean | undefined; modelUnavailableReason?: string | null | undefined; /** Model-visible application context captured with each durable realtime message. */ getModelContext?: (() => string | undefined) | undefined; /** * BCP 47 language the conversation is held in, for models that need one * (see `realtimeConversationLanguage`). Applies from the next connection. */ language?: string | undefined; /** * Voice settings (voice, language, turn eagerness) over the workspace's saved * settings for the model. Applies from the next connection. */ voiceSettings?: RealtimeVoiceSettings | undefined; /** Deterministic browser-test/demo seam. Production hosts should use the SDK default. */ controllerFactory?: SessionRealtimeControllerFactory | undefined; }): { snapshot: import("@opengeni/sdk").CodexRealtimeControllerSnapshot; lifecycleActive: boolean; /** The current call was started before this view mounted and adopted here. */ prestarted: boolean; canStart: boolean; admissionBlocker: string | null; codexConnected: boolean; audioRef: import("react").RefObject; start: () => Promise; stop: () => Promise; retry: () => Promise; retryAudibleOutput: () => Promise; setInputMuted: (muted: boolean) => void; setOutputMuted: (muted: boolean) => void; }; export declare function sessionRealtimeLifecycleIsActive(lifecycle: SessionRealtimeLifecycleProjection | null): boolean; export declare function useRealtimeModelSelection(options: { client?: RealtimeControllerClient | undefined; workspaceId?: string | undefined; codexConnected: boolean; activeModel?: SessionRealtimeModel | null | undefined; }): { models: RealtimeModelOption[]; selectedModel: RealtimeModelOption; selectModel: (value: string) => void; catalogReady: boolean; languageFor: (modelId: SessionRealtimeModel) => string | undefined; voiceSettingsFor: (modelId: SessionRealtimeModel, base?: RealtimeVoiceSettings | undefined) => RealtimeVoiceSettings | undefined; }; export {};