# Dictum SDK public API report v1 This file is generated deterministically from every declaration shipped by the npm package. ## core/browser-compatibility.d.ts import type { DictumCompatibilityDetails, DictumSttCompatibilityError } from '../shared/index.js'; import type { DictumAudioCaptureAdapter, STTInsertMode } from './types.js'; /** Checks capabilities used by the selected SDK path. It never sniffs a UA or browser version. */ export declare function inspectBrowserCompatibility(options?: Readonly<{ audioCapture?: DictumAudioCaptureAdapter | undefined; targetType?: string | null; insertMode?: STTInsertMode | undefined; domEvents?: boolean; }>): DictumCompatibilityDetails; export declare function createBrowserCompatibilityError(details: DictumCompatibilityDetails): DictumSttCompatibilityError; ## core/config-error.d.ts export declare class DictumConfigError extends Error { code: string | undefined; status: number | undefined; rid: string | undefined; exact_message: string | undefined; details: unknown; raw: unknown; constructor(message: string, options?: { code?: string; status?: number; rid?: string; exact_message?: string; details?: unknown; raw?: unknown; }); } ## core/config-preload.d.ts import { loadConfig } from './config.js'; export type LoadedConfig = Awaited>; export type ConfigLoadOutcome = { ok: true; config: LoadedConfig; } | { ok: false; error: unknown; }; export type SharedConfigLease = Readonly<{ promise: Promise; settled: Promise; release: () => void; }>; export declare function acquireSharedConfig(apiBaseUrl: string, projectKey: string): SharedConfigLease; ## core/config.d.ts import { type SdkConfigResponse } from '../shared/index.js'; export declare function validateSdkConfigResponse(value: unknown): SdkConfigResponse; export declare function validateSdkConfigSuccessEnvelope(value: unknown, expectedRid: string): SdkConfigResponse; export declare function loadConfig(apiBaseUrl: string, projectKey: string, signal?: AbortSignal): Promise; ## core/diagnostic-sanitizer.d.ts export type SanitizedDiagnosticValue = null | boolean | number | string | SanitizedDiagnosticValue[] | { [key: string]: SanitizedDiagnosticValue; }; export declare function safeClone(value: unknown): SanitizedDiagnosticValue; ## core/diagnostics.d.ts import type { DictumDiagnosticCode, DictumDiagnosticError, DictumDiagnosticEvent, DictumSessionPhase, DictumSdkDiagnostics, DictumSdkState, SdkRuntime } from './types.js'; export { safeClone } from './diagnostic-sanitizer.js'; export declare function createInitialDiagnostics(projectKey: string): DictumSdkDiagnostics; export declare function normalizeDiagnosticError(code: DictumDiagnosticCode, error: unknown, sessionId?: string): DictumDiagnosticError; export declare function recordDiagnosticError(runtime: SdkRuntime, code: DictumDiagnosticCode, error: unknown, sessionId?: string): DictumDiagnosticError; export declare function appendDiagnostic(runtime: SdkRuntime, event: Omit): void; export declare function updateSessionDiagnostics(runtime: SdkRuntime, session: { id: string; state: DictumSdkState; phase: DictumSessionPhase; fieldType: string; createdAt?: number; recordingStartedAt?: number; stoppedAt?: number; completedAt?: number; } | null): void; export declare function syncActiveSessionSnapshot(runtime: SdkRuntime): void; export declare function markDiagnosticTiming(runtime: SdkRuntime, mark: keyof DictumSdkDiagnostics['marks'], at?: number): void; export declare function updateRecorderDiagnostics(runtime: SdkRuntime, patch: Partial): void; export declare function updateTransportDiagnostics(runtime: SdkRuntime, patch: Partial): void; export declare function updateDebugDiagnostics(runtime: SdkRuntime, patch: Partial): void; export declare function syncPermissionDiagnostics(runtime: SdkRuntime): void; export declare function snapshotDiagnostics(runtime: SdkRuntime): DictumSdkDiagnostics; ## core/editable-target-policy.d.ts export declare function looksLikeUnsupportedRichTextEditor(field: HTMLElement): boolean; ## core/error-policy.d.ts import type { DictumCompatibilityDetails, DictumSttError, DictumSttErrorCode } from '../shared/index.js'; export type DictumErrorPhase = 'config' | 'transcribe' | 'microphone' | 'runtime'; export type DictumDedicatedErrorEvent = 'mic_denied' | 'no_transcript' | 'network_error' | 'audio_invalid' | 'compat_failed' | 'quota_exceeded' | 'auth_required' | 'identity_expired' | 'auth_invalid'; type DictumErrorAction = NonNullable; export type DictumPublicErrorPolicyEntry = Readonly<{ retryable: boolean; action: DictumErrorAction | null; userActionRequired: boolean; dedicatedEvent: DictumDedicatedErrorEvent | null; message: string; }>; export declare const PUBLIC_ERROR_POLICY: Readonly>; /** * Keeps the backend operation that produced an error without adding a field to * the error object. This context is deliberately private: it is used only when * projecting an internal failure to the stable public error contract. */ export declare function markSdkErrorPhase(error: T, phase: DictumErrorPhase): T; export declare function registerInspectedCompatibilityDetails(missing: DictumCompatibilityDetails['missing'], capture: DictumCompatibilityDetails['capture']): DictumCompatibilityDetails; export declare function resolvePublicErrorCode(params: { code?: unknown; status?: unknown; phase: DictumErrorPhase; fallbackCode?: DictumSttErrorCode; }): DictumSttErrorCode; export declare function createPublicError(code: DictumSttErrorCode, details?: unknown): DictumSttError; export declare function createInspectedCompatibilityError(details: DictumCompatibilityDetails): DictumSttError; export declare function normalizeSdkError(error: unknown, options?: { phase?: DictumErrorPhase; fallbackCode?: DictumSttErrorCode; }): DictumSttError; export declare function dedicatedErrorEventFor(code: DictumSttErrorCode): DictumDedicatedErrorEvent | null; export {}; ## core/insertion-target-metadata.d.ts import type { DictumInsertionTargetSnapshot, DictumSessionTargetType } from './types.js'; export declare function readInsertionTargetId(target: DictumInsertionTargetSnapshot): string | null; export declare function readInsertionTargetType(target: DictumInsertionTargetSnapshot): DictumSessionTargetType; ## core/microphone-permission.d.ts import type { SdkRuntime } from './types.js'; export type DictumMicrophoneErrorCode = 'microphone_permission_denied' | 'microphone_not_found' | 'microphone_busy' | 'microphone_unsupported' | 'microphone_security_blocked' | 'microphone_capture_failed'; export declare class DictumMicrophonePermissionError extends Error { code: DictumMicrophoneErrorCode; details: unknown; raw: unknown; constructor(message: string, options: { code: DictumMicrophoneErrorCode; details?: unknown; raw?: unknown; }); } export declare function requestMicrophoneStream(runtime: SdkRuntime): Promise; ## core/network.d.ts export declare class DictumNetworkTimeoutError extends Error { code: string; details: unknown; raw?: unknown; constructor(message: string, details: unknown); } export declare class DictumNetworkError extends Error { code: string; details: unknown; raw?: unknown; constructor(message: string, details: unknown, raw?: unknown); } export declare class DictumNetworkStreamError extends Error { code: string; details: unknown; raw?: unknown; constructor(message: string, details: unknown, raw?: unknown); } export declare class DictumResponseLimitError extends Error { code: string; details: unknown; constructor(message: string, details: unknown); } export declare class DictumResponseEncodingError extends Error { code: string; details: unknown; constructor(message: string, details: unknown); } export declare const CONTROL_RESPONSE_MAX_BYTES: number; export declare const SSE_EVENT_BUFFER_MAX_CHARS: number; export declare const TRANSCRIPT_MAX_CHARS = 4000000; export declare const WEBSOCKET_FRAME_MAX_CHARS: number; export declare function readNetworkCancellationFailure(error: unknown): Readonly<{ label: string; cleanupError: unknown; }> | undefined; export declare function cancelReaderWithoutBlocking(reader: ReadableStreamDefaultReader, error: unknown, label: string): void; export declare function fetchWithInactivityTimeout(url: string, options: RequestInit & { credentials: 'omit'; }, params: { timeoutMs?: number; label: string; streamResponse?: boolean; maxResponseBytes?: number; }): Promise; type StreamInterruptionCode = 'NETWORK_ERROR' | 'stream_lost'; export declare function readResponseTextWithLimit(response: Response, maxBytes: number, label: string, options?: { timeoutMs?: number; signal?: AbortSignal; interruptionCode?: StreamInterruptionCode; }): Promise; export declare function readSseStreamChunkWithInactivityTimeout(reader: ReadableStreamDefaultReader, timeoutMs: number, rid: string, signal?: AbortSignal): Promise>; export {}; ## core/page-session-coordinator.d.ts export type DictumPageSessionOwner = Readonly<{ destroy(): Promise; }>; export declare class DictumPageSessionCleanupError extends Error { constructor(); } export declare function reservePageSession(params: { owner: DictumPageSessionOwner; assertAvailable(): void; }): Promise; export declare function releasePageSession(owner: DictumPageSessionOwner): void; ## core/platform-events.d.ts import type { DictumPlatformDiagnosticsEvent, DictumPlatformPublicEventOf, SdkRuntime, STTEventType } from './types.js'; export declare function assertDomPlatformEventSupport(runtime: SdkRuntime): void; export declare function emitPlatformEvent(runtime: SdkRuntime, event: DictumPlatformPublicEventOf, domTarget?: Element | null): void; export declare function emitPlatformEvent(runtime: SdkRuntime, event: DictumPlatformDiagnosticsEvent, domTarget?: Element | null): void; ## core/public-config-error.d.ts /** Stable reason explaining why public SDK configuration is invalid. */ export type DictumSdkConfigErrorReason = 'invalid_type' | 'invalid_value' | 'missing_value' | 'out_of_range' | 'unknown_key'; /** Synchronous strict-validation error thrown by public SDK entrypoints. */ export declare class DictumSdkConfigError extends Error { /** Exact public configuration path that failed validation. */ readonly path: string; /** Stable machine-readable validation reason. */ readonly reason: DictumSdkConfigErrorReason; /** Stable configuration error code. */ readonly code = "invalid_config"; constructor( /** Exact public configuration path that failed validation. */ path: string, /** Stable machine-readable validation reason. */ reason: DictumSdkConfigErrorReason, message: string); /** Returns a frozen, serialization-safe public representation. */ toJSON(): Readonly<{ name: 'DictumSdkConfigError'; code: 'invalid_config'; path: string; reason: DictumSdkConfigErrorReason; message: string; }>; } ## core/public-config.d.ts import type { DictumAudioCaptureAdapter, DictumCustomInsertionAdapter, DictumPlatformEventAdapter, STTInsertMode } from './types.js'; export declare const DEFAULT_DICTUM_API_BASE_URL = "https://dictumflow-api.agentcore.workers.dev"; export type NormalizedSdkTarget = HTMLElement | DictumCustomInsertionAdapter; export type NormalizedSdkSessionConfig = Readonly<{ projectKey: string; identityToken: string | null; identityProvider: ((context: Readonly<{ signal: AbortSignal; }>) => PromiseLike | string) | undefined; target: NormalizedSdkTarget; apiBaseUrl: string; debug: boolean; domEvents: boolean; insertMode: STTInsertMode | undefined; volumeMeter: boolean | Readonly<{ intervalMs?: number; }>; audioCapture: DictumAudioCaptureAdapter | undefined; platformEvents: DictumPlatformEventAdapter | undefined; }>; export declare function normalizeVolumeMeterIntervalMs(intervalMs: unknown): number; /** Validates and snapshots the complete public configuration before any preload or session work. */ export declare function normalizeSdkSessionConfig(value: unknown): NormalizedSdkSessionConfig; export declare function normalizeSdkCompatibilityOptions(value: unknown): Readonly<{ audioCapture: DictumAudioCaptureAdapter | undefined; target: NormalizedSdkTarget | undefined; insertMode: STTInsertMode | undefined; domEvents: boolean; }>; ## core/public-events.d.ts import type { DictumSessionTargetContext, STTError, STTEventDataMap, STTEventOf, STTEventType, STTState, SdkRuntime } from './types.js'; /** * Emits the public STT event contract. * * This is the single bridge from internal sdk/transport activity to the * stable public API: session listeners and platform event adapters all receive * the same normalized payload. The default web adapter also mirrors public * events as DOM CustomEvents. */ export declare function emitSttEvent(runtime: SdkRuntime, target: DictumSessionTargetContext, params: { type: T; sessionId: string; state: STTEventOf['state']; data: STTEventDataMap[T]; }): STTEventOf; export declare function emitSdkErrorEvents(runtime: SdkRuntime, target: DictumSessionTargetContext, params: { sessionId: string; state: STTState; error: STTError; }): void; ## core/resource-acquisition-error.d.ts export declare class DictumResourceAcquisitionCleanupError extends Error { readonly raw: unknown; constructor(raw: unknown); } ## core/transcription-timing.d.ts import type { DictumServerTiming, DictumTranscriptionTiming } from '../shared/index.js'; export type DictumClientTimingTracker = { readonly originMs: number; recordingStartedOffsetMs: number | null; transportReadyOffsetMs: number | null; stopRequestedOffsetMs: number | null; firstTranscriptReceivedOffsetMs: number | null; lastTranscriptReceivedOffsetMs: number | null; resultResolvedOffsetMs: number | null; }; export declare function createClientTimingTracker(originMs: number): DictumClientTimingTracker; export declare function markClientTiming(tracker: DictumClientTimingTracker, field: 'recordingStartedOffsetMs' | 'transportReadyOffsetMs' | 'stopRequestedOffsetMs' | 'resultResolvedOffsetMs'): void; export declare function markClientTranscriptReceived(tracker: DictumClientTimingTracker): void; export declare function buildTranscriptionTiming(tracker: DictumClientTimingTracker, server: DictumServerTiming): DictumTranscriptionTiming; ## core/types.d.ts import type { DictumSttError, DictumSttEvent, DictumSttEventDataMap, DictumSttEventOf, DictumSttEventType, DictumSttInsertMode, DictumSttResult, DictumSttState, DictumSttTransport, DictumSttVolume, SdkConfigResponse } from '../shared/index.js'; export type DictumSdkState = DictumSttState; export type DictumSessionPhase = 'starting' | 'recording' | 'stopping' | 'uploading' | 'waiting' | 'complete'; export type DictumMicrophonePermissionState = 'unknown' | 'prompt' | 'granted' | 'denied' | 'unsupported'; export type DictumDiagnosticLevel = 'info' | 'warn' | 'error'; export type DictumDiagnosticCode = 'SDK_BOOTED' | 'CONFIG_LOAD_FAILED' | 'FIELD_CONFIG_INVALID' | 'SESSION_CREATED' | 'SESSION_STALE' | 'RECORDER_STARTING' | 'RECORDER_RECORDING' | 'RECORDER_STOPPING' | 'RECORDER_ABORTED' | 'AUDIO_TOO_LARGE' | 'AUDIO_TOO_LONG' | 'AUDIO_BUFFER_TOO_LARGE' | 'VOLUME_METER_FAILED' | 'MIC_PERMISSION_CHECK' | 'MIC_PERMISSION_GRANTED' | 'MIC_PERMISSION_DENIED' | 'MIC_SECURITY_BLOCKED' | 'MIC_NOT_FOUND' | 'MIC_BUSY' | 'MIC_UNSUPPORTED' | 'MIC_CAPTURE_FAILED' | 'WS_OPENING' | 'WS_READY' | 'WS_UNAVAILABLE' | 'WS_ABANDONED_FOR_PAUSE' | 'WS_FAILED_BEFORE_FINALIZE' | 'WS_CHUNK_SEND_FAILED' | 'WS_FINALIZE_SENT' | 'WS_TRANSCRIPT_DONE' | 'WS_FINALIZE_FAILED' | 'TRANSPORT_PENDING' | 'TRANSPORT_READY' | 'TRANSPORT_SETUP_FAILED' | 'WS_RUNTIME_FAILED' | 'SSE_UPLOADING' | 'SSE_COMPLETE' | 'SSE_FAILED' | 'IDENTITY_TOKEN_MISSING' | 'TARGET_UNSUPPORTED' | 'TARGET_UNAVAILABLE' | 'TRANSCRIPT_EMPTY' | 'TRANSCRIPT_INSERTED' | 'TRANSCRIPT_INSERT_FAILED' | 'UNKNOWN_ERROR'; export type DictumDiagnosticError = { code: DictumDiagnosticCode; message: string; at: number; sessionId?: string; status?: number; rid?: string; exact_message?: string; details?: unknown; raw?: unknown; }; export type DictumRecorderController = { pause: () => Promise; resume: () => Promise; retry: () => Promise; stop: () => Promise; abort: () => Promise; }; export type DictumRecorderResult = Readonly<{ text: string; providerModel: import('../shared/index.js').DictumProviderModel; audioDurationMs: number; serverTiming: import('../shared/index.js').DictumServerTiming; }>; /** Runtime context supplied to a host-owned audio capture adapter. */ export type DictumAudioCaptureAdapterContext = { /** Private operation identifier for correlating adapter callbacks only. */ readonly sessionId: string; /** Required output media type. */ readonly contentType: 'audio/wav'; /** Required PCM sample rate. */ readonly sampleRateHz: 16000; /** Requested nominal duration of each emitted WAV chunk. */ readonly chunkMs: 100; /** Aborts when capture must stop and all adapter resources must be released. */ readonly signal: AbortSignal; /** Emits one bounded, valid 16 kHz mono PCM WAV chunk. */ readonly onChunk: (chunk: Blob) => void; }; /** Capture handle returned after a custom audio adapter starts successfully. */ export type DictumAudioCaptureHandle = { /** The handle's sole own member; idempotently stops and releases capture. */ readonly stop: () => void | Promise; }; /** Host-owned replacement for the SDK's built-in browser microphone capture. */ export type DictumAudioCaptureAdapter = { /** Discriminator for the custom capture boundary. */ readonly kind: 'audio-capture'; /** Exact audio format emitted through `context.onChunk`. */ readonly contentType: 'audio/wav'; /** Starts capture and returns the handle whose cleanup the SDK will await. */ readonly start: (context: DictumAudioCaptureAdapterContext) => DictumAudioCaptureHandle | Promise; }; /** Typed public event projected onto the platform event adapter boundary. */ export type DictumPlatformPublicEventOf = Readonly<{ /** Discriminator for public product events. */ kind: 'public'; /** Namespaced form of the SDK event name. */ name: `dictum:${T}`; /** Stable host target identifier, when one was configured. */ targetId: string | null; /** Immutable public SDK event with its internal operation identifier removed. */ detail: Omit, 'sessionId'>; }>; /** Closed union of every public platform-adapter event. */ export type DictumPlatformPublicEvent = { [T in DictumSttEventType]: DictumPlatformPublicEventOf; }[DictumSttEventType]; /** Debug-only sanitized diagnostics projected onto the platform event adapter. */ export type DictumPlatformDiagnosticsEvent = Readonly<{ /** Discriminator for diagnostic events. */ kind: 'diagnostics'; /** Stable diagnostics event name. */ name: 'dictum:diagnostics'; /** Sanitized diagnostic payload; present only when debug mode is enabled. */ detail: unknown; }>; /** Closed event union accepted by `DictumSdkPlatformEventAdapter.emit`. */ export type DictumPlatformEventPayload = DictumPlatformPublicEvent | DictumPlatformDiagnosticsEvent; /** Host bridge for SDK events when DOM events are unsuitable or insufficient. */ export type DictumPlatformEventAdapter = { /** Discriminator for the platform event integration boundary. */ readonly kind: 'platform-events'; /** Receives immutable public events and optional sanitized diagnostics. */ readonly emit: (event: DictumPlatformEventPayload) => void | Promise; }; export type STTState = DictumSttState; export type STTTransport = DictumSttTransport; export type STTInsertMode = DictumSttInsertMode; export type STTEventType = DictumSttEventType; export type STTEvent = DictumSttEvent; export type STTEventDataMap = DictumSttEventDataMap; export type STTEventOf = DictumSttEventOf; export type STTResult = DictumSttResult; export type STTError = DictumSttError; export type STTVolume = DictumSttVolume; export type STTStartOptions = { insertMode?: STTInsertMode; }; export type DictumSessionSink = { readonly id: string; readonly state: STTState; setState(state: STTState): void; emit(event: STTEvent): void; complete(createResultAfterCleanup: () => STTResult): void; fail(error: STTError): void; retainForRetry(): void; }; export type DictumNativeInsertionTarget = { kind: 'native'; element: HTMLInputElement | HTMLTextAreaElement; }; export type DictumContentEditableInsertionTarget = { kind: 'contenteditable'; element: HTMLElement; }; /** Context supplied whenever transcript text is sent to a custom insertion adapter. */ export type DictumCustomInsertionAdapterContext = { /** Private operation identifier for adapter-side correlation only. */ readonly sessionId: string; /** Insertion behavior requested by the client configuration. */ readonly mode: STTInsertMode; }; /** Host-owned insertion boundary for controlled fields and rich-text editors. */ export type DictumCustomInsertionAdapter = { /** Discriminator for a custom insertion target. */ readonly kind: 'custom'; /** Optional stable identifier copied into public event and result metadata. */ readonly targetId?: string | null; /** Optional host-defined target category copied into diagnostics. */ readonly targetType?: string; /** Inserts one immutable transcript delta or final suffix. Calls are serialized and awaited. */ readonly insertText: (text: string, context: DictumCustomInsertionAdapterContext) => void | Promise; }; export type DictumCustomInsertionTarget = { kind: 'custom'; adapter: DictumCustomInsertionAdapter; }; export type DictumInsertionTargetSnapshot = DictumNativeInsertionTarget | DictumContentEditableInsertionTarget | DictumCustomInsertionTarget; export type DictumSessionTargetType = 'input' | 'textarea' | 'contenteditable' | 'custom'; /** Stable target metadata used by the session engine without requiring a DOM element. */ export type DictumSessionTargetContext = { readonly element: Element | null; readonly targetId: string | null; readonly targetType: string; }; export type DictumDiagnosticEvent = { at: number; scope: 'sdk' | 'session' | 'recorder' | 'transport' | 'permission' | 'debug'; level?: DictumDiagnosticLevel; code?: DictumDiagnosticCode; message: string; sessionId?: string; details?: unknown; }; export type DictumSdkDiagnostics = { bootedAt: number; projectKeyHash: string; session: { id: string; state: DictumSdkState; phase: DictumSessionPhase; fieldType: string; createdAt?: number; recordingStartedAt?: number; stoppedAt?: number; completedAt?: number; } | null; activeSessionSnapshot: { id: string; state: DictumSdkState; phase: DictumSessionPhase; transport: STTTransport; insertMode: STTInsertMode; targetAttached: boolean; recorderAttached: boolean; finishRequested: boolean; startedAt: string; } | null; recorder: { state: 'ready' | 'starting' | 'recording' | 'paused' | 'stopping' | 'stopped' | 'aborted' | 'error'; mimeType?: string; chunkCount: number; byteCount: number; retainedByteCount: number; }; transport: { mode: 'none' | 'websocket' | 'post'; websocketReady: boolean; lastProgressEvent: string | null; lastError: unknown; }; lastError: DictumDiagnosticError | null; marks: { sessionStartedAt?: number; microphoneRequestStartedAt?: number; microphoneStreamReadyAt?: number; audioWorkletReadyAt?: number; configReadyAt?: number; permissionGrantedAt?: number; websocketReadyAt?: number; recordingStartedAt?: number; stopRequestedAt?: number; transcriptDoneAt?: number; completedAt?: number; }; timings: { microphoneAcquireMs?: number; audioWorkletSetupMs?: number; captureSetupMs?: number; clickToPermissionMs?: number; clickToConfigReadyMs?: number; clickToWebSocketReadyMs?: number; recordingDurationMs?: number; stopToTranscriptMs?: number; totalSessionMs?: number; }; permission: { state: DictumMicrophonePermissionState; checkedAt: number; }; debug: { eventCount: number; lastImportant: string | null; }; events: DictumDiagnosticEvent[]; }; export type DictumActiveSession = { id: string; readonly state: DictumSdkState; phase: DictumSessionPhase; target: DictumSessionTargetContext; insertionTarget: DictumInsertionTargetSnapshot; recorder: DictumRecorderController | null; finishRequested: boolean; startedAt: string; transport: STTTransport; insertMode: STTInsertMode; lastError: STTError | null; }; export type SdkRuntime = { projectKey: string; identityToken: string; apiBaseUrl: string; requestSignal: AbortSignal | null; globalDebug: boolean; domEventsEnabled: boolean; config: SdkConfigResponse | null; audioCaptureAdapter: DictumAudioCaptureAdapter | null; audioCapturePrewarm: { acquire: () => Promise; replenish: () => void; destroy: () => Promise; } | null; platformEventAdapter: DictumPlatformEventAdapter | null; session: DictumSessionSink; publicEventSeq: number; activeSession: DictumActiveSession | null; cleanupRecorder: DictumRecorderController | null; pendingRecorderStart: Promise | null; clientTiming: import('./transcription-timing.js').DictumClientTimingTracker; microphonePermission: { state: DictumMicrophonePermissionState; checkedAt: number; }; diagnostics: DictumSdkDiagnostics; destroyed: boolean; }; ## index.d.ts /** Reports whether the selected browser integration is supported without creating a client or causing side effects. */ export { checkCompatibility } from './sdk.js'; /** Creates one reusable, target-bound Dictum client. See `AGENTS.md` for lifecycle and Promise semantics. */ export { createClient } from './sdk.js'; /** Indicates that terminal SDK resources could not be completely released. */ export { DictumSdkCleanupError } from './sdk.js'; /** Indicates that a client command is invalid for the current lifecycle state. */ export { DictumSdkCommandError } from './sdk.js'; /** Indicates that public SDK configuration failed synchronous validation. */ export { DictumSdkConfigError } from './sdk.js'; /** Names the state-changing commands accepted by a Dictum client. */ export type { DictumSdkCommand } from './sdk.js'; /** Stable reason attached to a rejected client command. */ export type { DictumSdkCommandErrorReason } from './sdk.js'; /** Stable reason attached to an invalid public configuration value. */ export type { DictumSdkConfigErrorReason } from './sdk.js'; /** Selects the browser capabilities that `checkCompatibility()` must evaluate. */ export type { DictumSdkCompatibilityOptions } from './sdk.js'; /** Immutable compatibility result for the selected capture and target path. */ export type { DictumSdkCompatibilityReport } from './sdk.js'; /** Callback invoked for one typed SDK event or for the `'*'` event stream. */ export type { DictumSdkEventHandler } from './sdk.js'; /** Immutable public event envelope with internal operation identifiers removed. */ export type { DictumSdkEvent } from './sdk.js'; /** Closed public event-name union plus the `'*'` subscription wildcard. */ export type { DictumSdkEventName } from './sdk.js'; /** Host action associated with a public SDK error when user intervention is required. */ export type { DictumSdkErrorAction } from './sdk.js'; /** Host-owned PCM16 WAV capture adapter used instead of the built-in microphone pipeline. */ export type { DictumSdkAudioCaptureAdapter } from './sdk.js'; /** Host-owned insertion adapter for controlled fields and rich-text editors. */ export type { DictumSdkInsertionAdapter } from './sdk.js'; /** Resolves the signed end-user identity for an accepted dictation. */ export type { DictumSdkIdentityProvider } from './sdk.js'; /** Cancellation context supplied to a configured identity provider. */ export type { DictumSdkIdentityProviderContext } from './sdk.js'; /** Host integration boundary for public events and optional diagnostics. */ export type { DictumSdkPlatformEventAdapter } from './sdk.js'; /** Closed platform-adapter event union emitted by the SDK. */ export type { DictumSdkPlatformEvent } from './sdk.js'; /** Reusable client bound to one target and one validated configuration. */ export type { DictumSdkClient } from './sdk.js'; /** Strict configuration accepted by `createClient()`. Unknown keys fail synchronously. */ export type { DictumSdkClientConfig } from './sdk.js'; /** Immutable successful transcription result with no internal operation identifier. */ export type { DictumSdkResult } from './sdk.js'; /** Supported DOM target or explicit host insertion adapter. */ export type { DictumSdkTarget } from './sdk.js'; /** Transport that produced a successful public result. */ export type { DictumSdkTransport } from './sdk.js'; /** Browser capability names reported when an integration path is unsupported. */ export type { DictumBrowserCapability } from './shared/index.js'; /** Detailed capability report carried by compatibility failures. */ export type { DictumCompatibilityDetails } from './shared/index.js'; /** Closed immutable union of errors observable through commands, results, and `sdk_error`. */ export type { DictumSttError as DictumSdkError } from './shared/index.js'; /** Stable public SDK error-code union. */ export type { DictumSttErrorCode as DictumSdkErrorCode } from './shared/index.js'; /** Maps every public event name to its immutable `data` payload. */ export type { DictumSttEventDataMap as DictumSdkEventDataMap } from './shared/index.js'; /** Controls whether transcript text replaces, appends to, or bypasses automatic insertion. */ export type { DictumSttInsertMode as DictumSdkInsertMode } from './shared/index.js'; /** Closed lifecycle-state union exposed by `client.state` and public events. */ export type { DictumSttState as DictumSdkState } from './shared/index.js'; /** Non-retryable browser capability error returned by an incompatible selected path. */ export type { DictumSttCompatibilityError as DictumSdkCompatibilityError } from './shared/index.js'; /** Client-observed timing offsets measured from the accepted `start()` call. */ export type { DictumClientTiming as DictumSdkClientTiming } from './shared/index.js'; /** Server-observed timing offsets measured from session acceptance. */ export type { DictumServerTiming as DictumSdkServerTiming } from './shared/index.js'; /** Combined immutable client and server timing report for a successful transcription. */ export type { DictumTranscriptionTiming as DictumSdkTiming } from './shared/index.js'; ## recorder/pcm16-resampler.d.ts /** * Stateful, band-limited browser-audio resampler used by the AudioWorklet. * * The implementation keeps absolute input/output positions so render-quantum * boundaries cannot reset phase. A compact polyphase Blackman-windowed sinc * table avoids trigonometry in the real-time sampling loop. */ export type Pcm16StreamingResampler = Readonly<{ push(samples: Float32Array): Float32Array; flush(): Float32Array; bufferedInputSamples(): number; }>; export declare function createPcm16StreamingResampler(sourceRateHz: number, targetRateHz?: number): Pcm16StreamingResampler; /** Builds the self-contained Blob module loaded by AudioWorklet. */ export declare function createPcm16CaptureWorkletSource(processorName: string): string; ## recorder/post.d.ts import type { DictumProviderModel, DictumServerTiming, DictumSttLimitData } from '../shared/index.js'; export declare const SSE_INACTIVITY_TIMEOUT_MS = 15000; export declare class DictumSseError extends Error { code: string | undefined; status: number | undefined; rid: string | undefined; exact_message: string | undefined; details: unknown; raw: unknown; constructor(message: string, options?: { code?: string; status?: number; rid?: string; exact_message?: string; details?: unknown; raw?: unknown; }); } export declare function readSseChunkWithInactivityTimeout(reader: ReadableStreamDefaultReader, timeoutMs: number, rid: string, signal?: AbortSignal): Promise>; export declare function transcribeWithSse(params: { apiBaseUrl: string; identityToken: string; projectKey: string; audio: Blob; onDelta?: (text: string) => void; onLimit?: (limit: DictumSttLimitData) => void; signal?: AbortSignal; }): Promise>; ## recorder/published-transcript.d.ts export declare class PublishedTranscriptTracker { private value; get text(): string; get hasPublished(): boolean; beginAttempt(): PublishedTranscriptAttempt; publishObserved(observed: string): string; } export declare class PublishedTranscriptAttempt { private readonly tracker; private observed; constructor(tracker: PublishedTranscriptTracker); observeDelta(delta: string): string; finalize(finalTranscript: string): string; } ## recorder/recorder-capture.d.ts import type { SdkRuntime } from '../core/types.js'; export { CUSTOM_CAPTURE_MAX_PENDING_VALIDATION_BYTES, CUSTOM_CAPTURE_MAX_PENDING_VALIDATION_CHUNKS, } from './recorder-limits.js'; export type RecorderAudioCapture = { stream: MediaStream | null; stop: () => Promise; abort: () => Promise; }; export declare function startRecorderAudioCapture(params: { runtime: SdkRuntime; sessionId: string; contentType: string; onChunk: (chunk: Blob) => void; onFailure: (error: unknown) => void; }): Promise; ## recorder/recorder-config.d.ts export declare const WEBSOCKET_INACTIVITY_TIMEOUT_MS = 15000; export declare const WEBSOCKET_READY_TIMEOUT_MS = 15000; export declare const WEBSOCKET_AUDIO_ACK_TIMEOUT_MS = 15000; export declare const PRE_WEBSOCKET_READY_QUEUE_TIMEOUT_MS = 15000; export declare const PRE_WEBSOCKET_READY_QUEUE_MAX_BYTES: number; export declare const WEBSOCKET_WAITING_AUDIO_MAX_BYTES: number; export declare const WEBSOCKET_WAITING_AUDIO_MAX_CHUNKS = 32; export declare const PROCESSING_PROGRESS: { readonly starting: 3; readonly recording: 8; readonly stopping: 12; readonly uploading: 80; readonly waiting: 92; readonly complete: 100; }; ## recorder/recorder-errors.d.ts import type { DictumDiagnosticCode } from '../core/types.js'; export declare function debugError(error: unknown, code?: DictumDiagnosticCode): { code: DictumDiagnosticCode; status?: number; rid?: string; exact_message: string; details?: unknown; raw?: unknown; }; ## recorder/recorder-events.d.ts import type { DictumDiagnosticCode, DictumSessionPhase, DictumSessionTargetContext, STTVolume, SdkRuntime } from '../core/types.js'; export type DictumRecorderDebugDetail = { message: string; transient?: boolean; status?: number; rid?: string; exact_message?: string; details?: unknown; raw?: unknown; sessionId?: string; important?: boolean; code?: DictumDiagnosticCode; }; export type DictumRecorderInternalEvent = { type: 'debug'; detail: DictumRecorderDebugDetail; } | { type: 'phase'; sessionId: string; phase: DictumSessionPhase; progress: number; label: string; }; /** * Typed recorder-only signal channel. * * These signals update internal diagnostics and, in debug mode only, the * browser console. They deliberately never create DOM events or public SDK * events. Public output continues to flow exclusively through emitSttEvent(). */ export declare function recordRecorderInternalEvent(runtime: SdkRuntime, event: DictumRecorderInternalEvent): void; export declare function recordRecorderDebug(runtime: SdkRuntime, detail: DictumRecorderDebugDetail): void; export declare function emitVolumeChange(runtime: SdkRuntime, target: DictumSessionTargetContext, sessionId: string, volume: number | Partial): void; export declare function recordRecorderPhase(runtime: SdkRuntime, sessionId: string, phase: DictumSessionPhase, progress: number, label: string): void; export declare function startAudioLevelMeter(runtime: SdkRuntime, target: DictumSessionTargetContext, stream: MediaStream, sessionId: string, intervalMs?: number, onSamplingFailure?: () => void): Promise<(() => Promise) | null>; ## recorder/recorder-limits.d.ts import type { DictumDiagnosticCode, SdkRuntime } from '../core/types.js'; export declare const CUSTOM_CAPTURE_MAX_PENDING_VALIDATION_CHUNKS = 32; export declare const CUSTOM_CAPTURE_MAX_PENDING_VALIDATION_BYTES: number; export declare const MAX_RETAINED_AUDIO_BYTES: number; export declare const MAX_RETAINED_AUDIO_CHUNKS = 8192; export declare function failAudioBufferLimit(params: { runtime: SdkRuntime; sessionId: string; code: DictumDiagnosticCode; message: string; exactMessage: string; details: Record; byteCount: number; clearAudio: () => void; stopRecorder: () => Promise; }): Error; ## recorder/recorder-policy.d.ts import type { DictumSessionTargetContext, SdkRuntime } from '../core/types.js'; import type { DictumSttLimitData } from '../shared/index.js'; export type RecorderFallbackReason = 'setup_failed' | 'stream_lost' | 'finalize_failed' | 'paused'; export declare function isTerminalWebSocketFailure(code: string): boolean; export declare function transportFailureFallbackReason(stage: 'setup' | 'runtime', publishedTranscript: string): RecorderFallbackReason | null; export declare function emitRecorderFallbackStarted(params: Readonly<{ runtime: SdkRuntime; target: DictumSessionTargetContext; sessionId: string; reason: RecorderFallbackReason | null; }>): boolean; export declare function handleRecorderWorkerLimit(params: Readonly<{ runtime: SdkRuntime; target: DictumSessionTargetContext; sessionId: string; details: DictumSttLimitData; finish: () => void; }>): boolean; ## recorder/recorder-post.d.ts import type { DictumRecorderResult, DictumSessionTargetContext, SdkRuntime } from '../core/types.js'; import type { DictumSttLimitData } from '../shared/index.js'; import { PublishedTranscriptTracker } from './published-transcript.js'; export declare function transcribeSseUpload(params: { runtime: SdkRuntime; target: DictumSessionTargetContext; sessionId: string; audio: Blob; transcriptTracker: PublishedTranscriptTracker; onPublishedDelta: (text: string) => void; onLimit: (limit: DictumSttLimitData) => void; }): Promise; ## recorder/recorder-wav-capture.d.ts export type RecorderWavCaptureMode = 'pcm16'; export declare const RECORDER_WAV_CONTENT_TYPE = "audio/wav"; export declare const RECORDER_WAV_SAMPLE_RATE = 16000; export declare const RECORDER_WAV_CHUNK_MS = 100; export type RecorderWavCapture = { stop: () => Promise; abort: () => Promise; }; export type RecorderWavCaptureOptions = { /** Packaged Worklet URL for hosts whose CSP forbids Blob-backed modules. */ workletModuleUrl?: string; }; export type RecorderWavCapturePrewarm = { acquire: () => Promise; replenish: () => void; destroy: () => Promise; }; export declare function supportsRecorderWavCapture(options?: RecorderWavCaptureOptions): boolean; export declare function createRecorderWavCapturePrewarm(options?: RecorderWavCaptureOptions): RecorderWavCapturePrewarm; export declare function startRecorderWavCapture(stream: MediaStream, onChunk: (chunk: Blob) => void, prewarm?: RecorderWavCapturePrewarm | null, signal?: AbortSignal | null, options?: RecorderWavCaptureOptions): Promise; ## recorder/recorder-websocket.d.ts import type { DictumSessionTargetContext, SdkRuntime } from '../core/types.js'; import type { DictumRecorderResult } from '../core/types.js'; import type { DictumSttLimitData } from '../shared/index.js'; import { PublishedTranscriptTracker } from './published-transcript.js'; export declare class WebSocketRecorderTransport { private readonly runtime; private readonly target; private readonly sessionId; private readonly config; private streaming; private streamingStartFailed; private streamingSendFailed; private streamingReady; private preReadyQueuedBytes; private preReadyStartedAt; private flushTail; private flushing; private waitingBytes; private waitingChunks; private chunks; private finalizing; private finalized; private finalizePromise; private closePromise; private closeFailureObserved; private abandoned; private serverLimitReached; private readonly transcriptAttempt; constructor(runtime: SdkRuntime, target: DictumSessionTargetContext, sessionId: string, config: { contentType: string; fieldType: string; transcriptTracker: PublishedTranscriptTracker; onPublishedDelta: (text: string) => void; onLimit: (limit: DictumSttLimitData) => void; onFailure: (error: unknown, stage: 'setup' | 'runtime') => void; onCapacityFailure: (error: unknown) => void; identityToken: Promise; }); get failedBeforeFinalize(): boolean; get canFinalize(): boolean; start(): Promise; enqueue(chunk: Blob): void; finalize(): Promise; close(): Promise; private shutdownTransport; private beginShutdownTransport; private observeCloseFailure; private observeTransportMessage; private onState; private onDelta; private publishTranscriptSuffix; private onFinal; private onLimit; private markReady; private markStartFailed; private trackPreReadyQueue; private flush; } ## recorder/recorder.d.ts import type { DictumDiagnosticCode, DictumRecorderController, DictumSessionTargetContext, SdkRuntime } from '../core/types.js'; import { type RecorderWavCapturePrewarm } from './recorder-wav-capture.js'; export type RecorderCapturePrewarm = RecorderWavCapturePrewarm; export declare function createRecorderCapturePrewarm(): RecorderCapturePrewarm; type DictumRecorderStartupController = DictumRecorderController & { activateTransport: () => void; }; type DictumRecorderSessionPort = Readonly<{ fail: (params: { error: unknown; code: DictumDiagnosticCode; diagnosticError?: unknown; allowRetry?: boolean; }) => void; finish: () => Promise; publishTranscriptDelta: (text: string) => void; }>; export declare function createRecorder(_runtime: SdkRuntime, _target: DictumSessionTargetContext, _sessionId: string, options: { enableAudioLevelMeter?: boolean; audioLevelMeterIntervalMs?: number; sessionPort: DictumRecorderSessionPort; transportAuthorization: Promise; transportIdentity: Promise; }): { start: () => Promise; }; export {}; ## recorder/streaming-error.d.ts export declare class DictumTransportError extends Error { code: string | undefined; status: number | undefined; rid: string | undefined; exact_message: string | undefined; details: unknown; raw: unknown; constructor(message: string, options?: { code?: string; status?: number; rid?: string; exact_message?: string; details?: unknown; raw?: unknown; }); } ## recorder/streaming-frame.d.ts import { type DictumSdkWebSocketTranscriptFrame } from '../shared/index.js'; import { DictumTransportError } from './streaming-error.js'; export declare const WEBSOCKET_CLOSE_PROTOCOL_ERROR = 4002; export declare const WEBSOCKET_CLOSE_MESSAGE_TOO_BIG = 4009; export type StreamingFrameDecodeResult = Readonly<{ ok: true; frame: DictumSdkWebSocketTranscriptFrame; }> | Readonly<{ ok: false; error: DictumTransportError; closeCode: number; closeReason: string; }>; export declare function decodeStreamingFrame(data: unknown, rid: string): StreamingFrameDecodeResult; ## recorder/streaming.d.ts import { type DictumSttLimitData, type DictumServerTiming, type DictumProviderModel } from '../shared/index.js'; import { DictumTransportError } from './streaming-error.js'; export { DictumTransportError } from './streaming-error.js'; export type DictumStreamingProductState = 'buffering' | 'recording' | 'transcribing'; export type DictumStreamingSession = { ready: Promise; sendChunk: (chunk: Blob) => Promise; finalize: () => Promise>; close: () => Promise; }; export declare function openStreamingSession(params: { apiBaseUrl: string; identityToken: string | Promise; projectKey: string; contentType: string; fieldType: string; inactivityTimeoutMs: number; audioAckTimeoutMs: number; onState?: (state: DictumStreamingProductState) => void; onDelta?: (text: string) => void; onFinal?: (text: string, providerModel: DictumProviderModel, audioDurationMs: number, serverTiming: DictumServerTiming) => void; onLimit?: (limit: DictumSttLimitData) => void; onFailure?: (error: DictumTransportError) => void; }): DictumStreamingSession; ## recorder/transport-adapters.d.ts import type { DictumProviderModel, DictumServerTiming, DictumSttLimitData } from '../shared/index.js'; import { type DictumStreamingProductState } from './streaming.js'; export type RawTransportMessage = { transport: 'sse'; kind: 'started'; payload: { sessionId: string; }; } | { transport: 'sse'; kind: 'delta'; payload: { text: string; }; } | { transport: 'sse'; kind: 'limit'; payload: DictumSttLimitData; } | { transport: 'sse'; kind: 'transcript.final'; payload: { text: string; providerModel: DictumProviderModel; audioDurationMs: number; serverTiming: DictumServerTiming; }; } | { transport: 'websocket'; kind: 'started'; payload: { sessionId: string; }; } | { transport: 'websocket'; kind: 'state'; payload: { state: DictumStreamingProductState; }; } | { transport: 'websocket'; kind: 'limit'; payload: DictumSttLimitData; } | { transport: 'websocket'; kind: 'transcript.delta'; payload: { text: string; }; } | { transport: 'websocket'; kind: 'transcript.final'; payload: { text: string; providerModel: DictumProviderModel; audioDurationMs: number; serverTiming: DictumServerTiming; }; } | { transport: 'websocket'; kind: 'done'; payload: { text: string; providerModel: DictumProviderModel; audioDurationMs: number; serverTiming: DictumServerTiming; }; }; export type DictumTransportTranscriptResult = Readonly<{ text: string; providerModel: DictumProviderModel; audioDurationMs: number; serverTiming: DictumServerTiming; }>; export type SseTransportContext = { sessionId: string; apiBaseUrl: string; identityToken: string; projectKey: string; audio: Blob; signal?: AbortSignal; onLimit?: (limit: DictumSttLimitData) => void; }; export type WebSocketTransportContext = { sessionId: string; apiBaseUrl: string; identityToken: string | Promise; projectKey: string; contentType: string; fieldType: string; inactivityTimeoutMs: number; audioAckTimeoutMs: number; onState?: (state: DictumStreamingProductState) => void; onDelta?: (text: string) => void; onFinal?: (text: string) => void; onLimit?: (limit: DictumSttLimitData) => void; }; export declare class SseTransportAdapter { private readonly messageCallbacks; private readonly errorCallbacks; onMessage(callback: (message: RawTransportMessage) => void): () => void; onError(callback: (error: unknown) => void): () => void; transcribe(context: SseTransportContext): Promise; private emitMessage; private emitError; } export declare class WebSocketTransportAdapter { private readonly messageCallbacks; private readonly errorCallbacks; private streaming; private closePromise; ready: Promise; onMessage(callback: (message: RawTransportMessage) => void): () => void; onError(callback: (error: unknown) => void): () => void; start(context: WebSocketTransportContext): void; sendChunk(chunk: Blob): Promise; finalize(): Promise; close(): Promise; private emitMessage; private emitError; } ## recorder/wav.d.ts export declare const WAV_CONTENT_TYPE = "audio/wav"; export declare const WAV_SAMPLE_RATE = 16000; export declare const WAV_CHANNELS = 1; export declare const WAV_BITS_PER_SAMPLE = 16; export declare function createWavBlobFromPcm16(pcm: ArrayBuffer): Blob; export declare function createSessionWavBlobFromChunks(chunks: Blob[]): Promise; export declare function validatePcm16MonoWavBlob(chunk: unknown): Promise; export declare function measureWavPcm16Volume(buffer: ArrayBuffer): { level: number; rms: number; peak: number; }; /** Maps linear PCM RMS to a perceptual speech meter without changing captured audio. */ export declare function mapRmsToVoiceLevel(rms: number): number; export declare function extractPcm16MonoFromWav(buffer: ArrayBuffer): ArrayBuffer; ## sdk.d.ts import type { DictumAudioCaptureAdapter, DictumCustomInsertionAdapter, DictumPlatformEventAdapter, DictumPlatformEventPayload, STTEvent, STTEventOf, STTEventType, STTInsertMode, STTResult, STTState, STTTransport } from './core/types.js'; import type { DictumBrowserCapability, DictumSttErrorAction } from './shared/index.js'; /** A supported editable DOM element or an explicit host-owned insertion adapter. */ export type DictumSdkTarget = HTMLElement | DictumCustomInsertionAdapter; /** Inserts immutable transcript text through host application state or editor APIs. */ export type DictumSdkInsertionAdapter = DictumCustomInsertionAdapter; /** Supplies bounded 16 kHz mono PCM WAV chunks instead of using built-in browser capture. */ export type DictumSdkAudioCaptureAdapter = DictumAudioCaptureAdapter; /** Receives typed public events and optional sanitized diagnostics outside the DOM event boundary. */ export type DictumSdkPlatformEventAdapter = DictumPlatformEventAdapter; /** Event union delivered to a configured platform event adapter. */ export type DictumSdkPlatformEvent = DictumPlatformEventPayload; /** Transport that produced the successful final transcript. */ export type DictumSdkTransport = STTTransport; /** Host action attached to an SDK error that requires user intervention. */ export type DictumSdkErrorAction = DictumSttErrorAction; /** Options inspected without side effects by `checkCompatibility()`. */ export type DictumSdkCompatibilityOptions = { /** Custom capture path to inspect instead of the built-in microphone path. */ readonly audioCapture?: DictumSdkAudioCaptureAdapter; /** Optional target whose insertion capabilities should be inspected. */ readonly target?: DictumSdkTarget; /** Intended insertion behavior for the selected target. */ readonly insertMode?: STTInsertMode; /** Whether the selected path requires DOM `CustomEvent` mirroring. */ readonly domEvents?: boolean; }; /** Immutable compatibility result for one selected browser integration path. */ export type DictumSdkCompatibilityReport = Readonly<{ /** `true` when no required browser capability is missing. */ supported: boolean; /** Capture path that was evaluated. */ capture: 'sdk' | 'custom'; /** Exact missing capabilities; empty when `supported` is `true`. */ missing: readonly DictumBrowserCapability[]; }>; /** Context passed to `DictumSdkIdentityProvider` for one accepted dictation. */ export type DictumSdkIdentityProviderContext = Readonly<{ /** Aborts when the dictation terminates; SDK cleanup does not wait for a provider that ignores it. */ signal: AbortSignal; }>; /** * Returns the signed customer-owned identity for one accepted dictation. * * The provider is invoked once after `start()` is accepted and may resolve * synchronously or asynchronously. Late settlement after the operation aborts * is observed but ignored. See `AGENTS.md` for identity and cancellation * invariants. */ export type DictumSdkIdentityProvider = (context: DictumSdkIdentityProviderContext) => PromiseLike | string; export { DictumSdkCommandError } from './session/session-command-error.js'; export { DictumSdkCleanupError } from './session/session-cleanup-error.js'; export { DictumSdkConfigError } from './core/public-config-error.js'; export type { DictumSdkCommand, DictumSdkCommandErrorReason } from './session/session-command-error.js'; export type { DictumSdkConfigErrorReason } from './core/public-config-error.js'; /** Strict configuration for one reusable, target-bound Dictum client. */ export type DictumSdkClientConfig = { /** Public Dictum project key used to select project configuration. */ readonly projectKey: string; /** Static signed end-user identity. Mutually exclusive with `identityProvider`. */ readonly identityToken?: string | null; /** Lazy signed-identity resolver. Mutually exclusive with `identityToken`. */ readonly identityProvider?: DictumSdkIdentityProvider; /** Sticky DOM or custom insertion target used by every dictation on this client. */ readonly target: DictumSdkTarget; /** Optional compatibility origin; only the canonical API or current HTTPS page origin is accepted. */ readonly apiBaseUrl?: string; /** Enables sanitized technical diagnostics and console output. */ readonly debug?: boolean; /** Mirrors public events through DOM `CustomEvent`s when enabled. Defaults to `true`. */ readonly domEvents?: boolean; /** Automatic transcript insertion behavior. Defaults to `append`. */ readonly insertMode?: STTInsertMode; /** Enables volume events, optionally with a clamped 100–2000 ms interval. */ readonly volumeMeter?: boolean | { /** Requested volume sampling interval in milliseconds. Defaults to 500. */ readonly intervalMs?: number; }; /** Host-owned capture adapter used instead of built-in browser microphone capture. */ readonly audioCapture?: DictumSdkAudioCaptureAdapter; /** Optional host bridge for typed public events and debug-only diagnostics. */ readonly platformEvents?: DictumSdkPlatformEventAdapter; }; /** Public SDK event name or the `'*'` wildcard accepted by `client.on()`. */ export type DictumSdkEventName = STTEvent['type'] | '*'; /** Immutable public event envelope for one event type, without an internal operation identifier. */ export type DictumSdkEvent = T extends STTEventType ? Omit, 'sessionId'> : never; /** Listener for one typed event name or for the complete wildcard event union. */ export type DictumSdkEventHandler = (event: T extends STTEventType ? DictumSdkEvent : DictumSdkEvent) => void | Promise; /** Immutable successful transcription result with internal operation identity removed. */ export type DictumSdkResult = Omit; /** * Reports support for the selected capture, target, insertion, and DOM-event path. * * This function validates its input synchronously and causes no network, * microphone, DOM mutation, or client lifecycle side effect. */ export declare function checkCompatibility(options?: DictumSdkCompatibilityOptions): DictumSdkCompatibilityReport; /** One reusable Dictum client bound to the target supplied at creation. */ export type DictumSdkClient = { /** Sticky target used for every dictation created by this client. */ readonly target: DictumSdkTarget; /** Current public lifecycle state. */ readonly state: STTState; /** Starts a fresh dictation and resolves once the client is listening. */ start(): Promise; /** Pauses microphone capture while retaining the active dictation. */ pause(): Promise; /** Resumes a paused active dictation. */ resume(): Promise; /** Finalizes the active dictation and resolves with its successful result. */ stop(): Promise; /** Explicitly retries an eligible retained-audio transport failure. */ retry(): Promise; /** Observes the current dictation result without issuing a state-changing command. */ waitForResult(): Promise; /** Permanently destroys the client and releases all owned resources. */ destroy(): Promise; /** Registers a typed listener and returns an idempotent unsubscribe function. */ on(eventName: T, handler: DictumSdkEventHandler): () => void; /** Removes a previously registered typed listener. */ off(eventName: T, handler: DictumSdkEventHandler): void; }; /** * Creates one reusable Dictum client after synchronous, strict validation. * * Client creation binds the target and may preload public project * configuration, but it never requests microphone access or resolves a lazy * identity provider. */ export declare function createClient(config: DictumSdkClientConfig): DictumSdkClient; ## session/insert-text.d.ts import type { DictumCustomInsertionAdapter, DictumInsertionTargetSnapshot, DictumSessionTargetContext, STTInsertMode } from '../core/types.js'; export type DictumInsertionTargetInput = Element | DictumCustomInsertionAdapter; export declare function isCustomInsertionAdapter(target: unknown): target is DictumCustomInsertionAdapter; export declare function createSessionTargetContext(target: DictumInsertionTargetInput): DictumSessionTargetContext; export declare function captureInsertionTarget(field: DictumInsertionTargetInput): DictumInsertionTargetSnapshot; export declare function insertText(target: DictumInsertionTargetSnapshot, text: string, mode: STTInsertMode | undefined, sessionId: string): Promise; ## session/live-insertion.d.ts import type { DictumInsertionTargetSnapshot, DictumSessionTargetContext, STTInsertMode, SdkRuntime } from '../core/types.js'; export type LiveInsertionSnapshot = Readonly<{ insertedText: string; failed: boolean; }>; export declare function beginLiveInsertion(params: { runtime: SdkRuntime; sessionId: string; target: DictumSessionTargetContext; insertionTarget: DictumInsertionTargetSnapshot; insertMode: STTInsertMode; }): Readonly<{ publish: (text: string) => void; }>; export declare function flushLiveInsertion(runtime: SdkRuntime, sessionId: string): Promise; export declare function clearLiveInsertion(runtime: SdkRuntime, sessionId: string): void; ## session/public-session.d.ts import { type DictumErrorPhase } from '../core/error-policy.js'; import type { STTError, STTInsertMode, STTStartOptions } from '../core/types.js'; export declare function normalizeError(error: unknown, phase?: DictumErrorPhase): STTError; export declare function resolveInsertMode(options: STTStartOptions | undefined): STTInsertMode; ## session/sdk-session-cleanup.d.ts import type { SharedConfigLease } from '../core/config-preload.js'; import { type DictumPageSessionOwner } from '../core/page-session-coordinator.js'; import type { DictumRecorderController, SdkRuntime, STTState } from '../core/types.js'; export declare function cleanupSdkSessionResources(params: Readonly<{ runtime: SdkRuntime | null; recorder: DictumRecorderController | null; pendingRecorderStart: Promise | null; pendingIdentityLoad: Promise | null; controller: AbortController | null; configLease: SharedConfigLease | null; pageSessionOwner: DictumPageSessionOwner; sessionId: string; terminalState: STTState; debug: boolean; beforeRelease?: () => Promise; }>): Promise; ## session/session-cleanup-error.d.ts /** Error thrown when terminal SDK resources cannot be completely released. */ export declare class DictumSdkCleanupError extends Error { /** Stable cleanup failure code. */ readonly code = "cleanup_failed"; constructor(); } ## session/session-command-error.d.ts import type { STTState } from '../core/types.js'; /** State-changing commands accepted by the public Dictum client. */ export type DictumSdkCommand = 'start' | 'pause' | 'resume' | 'stop' | 'retry'; /** Stable reason explaining why a public client command was rejected. */ export type DictumSdkCommandErrorReason = 'already_started' | 'command_in_progress' | 'destroyed' | 'invalid_state' | 'not_retryable' | 'dictation_settled'; /** Error thrown when a public client command is invalid for the current lifecycle. */ export declare class DictumSdkCommandError extends Error { /** Command that was rejected. */ readonly command: DictumSdkCommand; /** Public client state observed at rejection time. */ readonly state: STTState; /** Stable machine-readable rejection reason. */ readonly reason: DictumSdkCommandErrorReason; /** Stable error code for all invalid command uses. */ readonly code = "invalid_command"; constructor( /** Command that was rejected. */ command: DictumSdkCommand, /** Public client state observed at rejection time. */ state: STTState, /** Stable machine-readable rejection reason. */ reason: DictumSdkCommandErrorReason); } ## session/session-controller.d.ts import { createRecorderCapturePrewarm, type RecorderCapturePrewarm } from '../recorder/recorder.js'; import type { DictumInsertionTargetSnapshot, DictumSessionTargetContext, STTStartOptions, SdkRuntime } from '../core/types.js'; export type DictumSessionPresentation = { enableAudioLevelMeter: boolean; audioLevelMeterIntervalMs?: number; }; export { createRecorderCapturePrewarm }; export type { RecorderCapturePrewarm }; export declare function startSession(params: { runtime: SdkRuntime; target: DictumSessionTargetContext; presentation: DictumSessionPresentation; insertionTarget: DictumInsertionTargetSnapshot; options: STTStartOptions; transportAuthorization: Promise; transportIdentity: Promise; }): Promise; ## session/session-lifecycle.d.ts import { type DictumErrorPhase } from '../core/error-policy.js'; import type { DictumDiagnosticCode, DictumSessionTargetContext, STTError, SdkRuntime } from '../core/types.js'; export declare function readTransport(): 'websocket'; export declare function readDiagnosticFieldType(target: DictumSessionTargetContext): string; export declare function syncActiveSessionDiagnostics(runtime: SdkRuntime): void; export declare function clearSessionIfCurrent(runtime: SdkRuntime, sessionId: string): boolean; export declare function failActiveSession(runtime: SdkRuntime, sessionId: string, params: { error: unknown; code?: DictumDiagnosticCode; phase?: DictumErrorPhase; diagnosticError?: unknown; allowRetry?: boolean; }): STTError | false; export declare function finishSession(runtime: SdkRuntime, sessionId: string): Promise; export declare function retryActiveSession(runtime: SdkRuntime, sessionId: string): Promise; ## session/state-machine.d.ts import type { DictumSessionTargetContext, STTState, SdkRuntime } from '../core/types.js'; export type DictumSessionCommand = 'start' | 'pause' | 'resume' | 'stop' | 'transcribe' | 'retry' | 'success' | 'fail'; export declare const SESSION_TRANSITION_TABLE: { readonly idle: { readonly start: "requesting_mic"; readonly fail: "failed"; }; readonly requesting_mic: { readonly start: "listening"; readonly fail: "failed"; }; readonly listening: { readonly pause: "paused"; readonly stop: "transcribing"; readonly transcribe: "transcribing"; readonly fail: "failed"; }; readonly paused: { readonly resume: "listening"; readonly stop: "transcribing"; readonly transcribe: "transcribing"; readonly fail: "failed"; }; readonly retrying: { readonly success: "idle"; readonly fail: "failed"; }; readonly transcribing: { readonly success: "idle"; readonly fail: "failed"; }; readonly failed: { readonly retry: "retrying"; }; }; export declare class InvalidSessionTransitionError extends Error { readonly previousState: STTState; readonly command: DictumSessionCommand; constructor(previousState: STTState, command: DictumSessionCommand); } export declare function nextSessionState(previousState: STTState, command: DictumSessionCommand): STTState; export declare function dispatchSessionCommand(params: { runtime: SdkRuntime; sessionId: string; command: DictumSessionCommand; target?: DictumSessionTargetContext; }): boolean; ## session/stt-result.d.ts import type { DictumActiveSession, STTInsertMode, STTResult } from '../core/types.js'; import { type DictumProviderModel, type DictumTranscriptionTiming } from '../shared/index.js'; /** * Builds the single public STTResult shape for every transport. */ export declare function buildSttResult(params: { session: DictumActiveSession; text: string; endedAt?: string; inserted: boolean; insertMode: STTInsertMode; providerModel: DictumProviderModel; audioDurationMs: number; timing: DictumTranscriptionTiming; }): STTResult; ## shared/api-types.d.ts export type SdkConfigResponse = { enabled: boolean; }; export type SdkConfigApiResponse = { ok: true; rid: string; sdk: SdkConfigResponse; } | { ok: false; rid: string; error: import('./errors.js').ApiError; }; ## shared/contracts/dictumflow-sdk.d.ts import { type ApiError } from '../errors.js'; export declare const DICTUM_SDK_CONTRACT: { readonly timingVersion: 2; readonly contract: { readonly route: "/api/sdk/contract"; readonly method: "GET"; }; readonly config: { readonly route: "/api/sdk/config"; readonly method: "GET"; readonly projectKeyParam: "p"; readonly purpose: "project_runtime_activation"; }; readonly transcribe: { readonly route: "/api/sdk/transcribe"; readonly method: "POST"; }; readonly websocket: { readonly route: "/api/sdk/ws"; readonly protocol: "dictum.v1"; readonly pendingProtocol: "dictum.pending.v1"; readonly ridProtocolPrefix: "dictum.rid."; readonly authProtocolPrefix: "dictum.auth."; readonly initType: "init"; readonly authorizeType: "authorize"; readonly finalizeType: "finalize"; readonly stateType: "state"; readonly ackType: "ack"; readonly limitType: "limit"; readonly deltaType: "delta"; readonly finalType: "final"; readonly doneType: "done"; readonly events: readonly ["state", "ack", "limit", "delta", "final", "done", "error"]; }; readonly headers: { readonly authorization: "authorization"; readonly contentType: "content-type"; readonly requestId: "x-request-id"; readonly projectKey: "x-dictum-project-key"; readonly timingVersion: "x-dictum-timing-version"; }; }; export type DictumSdkWebSocketInitFrame = { type: typeof DICTUM_SDK_CONTRACT.websocket.initType; rid: string; authorization?: string; projectKey: string; contentType: string; fieldType: string; timingVersion: typeof DICTUM_SDK_CONTRACT.timingVersion; }; export type DictumSdkWebSocketAuthorizeFrame = { type: typeof DICTUM_SDK_CONTRACT.websocket.authorizeType; authorization: string; }; /** Server-observed offsets, in milliseconds, measured from accepted session start. */ export type DictumServerTiming = Readonly<{ /** Offset at which the server accepted the session. */ sessionAcceptedOffsetMs: number; /** Offset at which quota reservation began. */ quotaReservationStartedOffsetMs: number; /** Offset at which quota reservation completed. */ quotaReservationCompletedOffsetMs: number; /** Offset at which the first audio bytes were accepted. */ firstAudioAcceptedOffsetMs: number; /** Offset at which the final audio bytes were accepted. */ lastAudioAcceptedOffsetMs: number; /** Offset at which the first transcript text was observed. */ firstTranscriptOffsetMs: number; /** Offset at which the final transcript text was observed. */ lastTranscriptOffsetMs: number; /** Offset at which the successful terminal response completed. */ doneOffsetMs: number; }>; /** Client-observed offsets, in milliseconds, measured from the accepted `start()` call. */ export type DictumClientTiming = Readonly<{ /** Timeline origin for the accepted start command. */ startRequestedOffsetMs: 0; /** Offset at which microphone recording became active. */ recordingStartedOffsetMs: number; /** Offset at which the selected transport became ready, when observable. */ transportReadyOffsetMs: number | null; /** Offset at which `stop()` was accepted, or `null` before an explicit stop. */ stopRequestedOffsetMs: number | null; /** Offset at which the first transcript text reached the client. */ firstTranscriptReceivedOffsetMs: number; /** Offset at which the final transcript text reached the client. */ lastTranscriptReceivedOffsetMs: number; /** Offset sampled after terminal cleanup and immediately before result resolution. */ resultResolvedOffsetMs: number; }>; /** Combined client and server timing report attached to a successful result. */ export type DictumTranscriptionTiming = Readonly<{ /** Browser-side lifecycle offsets. */ client: DictumClientTiming; /** Server-side processing offsets. */ server: DictumServerTiming; }>; export type DictumProviderModel = `STT_${string}`; export type DictumSdkWebSocketFinalizeFrame = { type: typeof DICTUM_SDK_CONTRACT.websocket.finalizeType; }; export type DictumSdkWebSocketTranscriptFrame = { ok: false; rid: string; error: ApiError; } | { ok: true; type: typeof DICTUM_SDK_CONTRACT.websocket.stateType; value: 'buffering' | 'recording' | 'transcribing'; } | { ok: true; type: typeof DICTUM_SDK_CONTRACT.websocket.ackType; stage: 'audio'; chunkCount: number; totalBytes: number; audioDurationMs?: number; audioDurationSeconds?: number; audioDataBytes?: number; audioBytes?: number; maxAudioDurationMs?: number; maxAudioDurationSeconds?: number; maxAudioBytes?: number; audioLimitReached?: boolean; } | ({ ok: true; type: typeof DICTUM_SDK_CONTRACT.websocket.limitType; } & DictumSttLimitData) | { ok: true; type: typeof DICTUM_SDK_CONTRACT.websocket.deltaType; text: string; } | { ok: true; type: typeof DICTUM_SDK_CONTRACT.websocket.finalType; rid: string; text: string; providerModel: DictumProviderModel; audioDurationMs: number; timing: DictumServerTiming; } | { ok: true; type: typeof DICTUM_SDK_CONTRACT.websocket.doneType; rid: string; }; export declare const DICTUM_STT_EVENT_CONTRACT: { readonly publicEvents: readonly ["state_changed", "volume_changed", "transcript_delta", "text_inserted", "mic_denied", "no_transcript", "network_error", "audio_invalid", "compat_failed", "limit_reached", "fallback_started", "quota_exceeded", "auth_required", "identity_expired", "auth_invalid", "retry_started", "sdk_error"]; readonly publicStates: readonly ["idle", "requesting_mic", "listening", "paused", "retrying", "transcribing", "failed"]; readonly publicErrors: readonly ["microphone_permission_denied", "microphone_not_found", "browser_unsupported", "sdk_disabled", "network_error", "stream_lost", "transcription_failed", "transport_response_invalid", "empty_audio", "no_speech_detected", "quota_exceeded", "unsupported_audio_type", "audio_too_large", "rate_limited", "timeout", "aborted_by_user", "client_not_authenticated", "identity_expired", "config_response_invalid", "auth_config_error"]; readonly transports: readonly ["post", "websocket"]; readonly sse: { readonly events: readonly ["start", "limit", "delta", "done", "error"]; }; readonly websocket: { readonly events: readonly ["state", "ack", "limit", "delta", "final", "done", "error"]; }; }; /** Closed union of public SDK event names. */ export type DictumSttEventType = typeof DICTUM_STT_EVENT_CONTRACT.publicEvents[number]; /** Closed public lifecycle-state union. */ export type DictumSttState = typeof DICTUM_STT_EVENT_CONTRACT.publicStates[number]; /** Closed stable public error-code union. */ export type DictumSttErrorCode = typeof DICTUM_STT_EVENT_CONTRACT.publicErrors[number]; /** Transport that may produce a successful public transcription result. */ export type DictumSttTransport = typeof DICTUM_STT_EVENT_CONTRACT.transports[number]; /** Automatic transcript insertion behavior. */ export type DictumSttInsertMode = 'replace' | 'append' | 'manual'; /** Payload emitted after an accepted lifecycle transition. */ export type DictumSttStateChangedData = { /** State active before the transition. */ readonly previousState: DictumSttState; /** State active before listeners receive the event. */ readonly nextState: DictumSttState; }; /** Immutable transcript suffix published by the active transport. */ export type DictumSttTranscriptDeltaData = { /** Newly published append-only transcript text. */ readonly text: string; /** Transport that published the text. */ readonly transport: DictumSttTransport; }; /** Confirms successful automatic insertion of transcript text. */ export type DictumSttTextInsertedData = { /** Text inserted during this operation. */ readonly text: string; /** Automatic insertion mode that was applied. */ readonly insertMode: Exclude; }; /** Describes the bounded audio limit that forced transcription to begin. */ export type DictumSttLimitData = { /** Resource limit that was reached. */ readonly reason: 'duration' | 'size'; /** Accepted audio duration at the limit. */ readonly durationMs: number; /** Configured maximum audio duration. */ readonly maxSeconds: number; /** Accepted PCM audio bytes at the limit. */ readonly bytes: number; /** Configured maximum PCM audio bytes. */ readonly maxBytes: number; /** Stable action taken after reaching the limit. */ readonly action: 'transcribing'; }; /** Confirms that an explicit retained-audio retry began. */ export type DictumSttRetryData = { /** Retry transport; retained-audio retries use POST only. */ readonly transport: 'post'; }; /** Describes an observable WebSocket-to-POST recovery. */ export type DictumSttFallbackData = { /** Transport that could not complete before text publication. */ readonly from: 'websocket'; /** Recovery transport that actually began. */ readonly to: 'post'; /** Stable machine-readable fallback reason. */ readonly reason: 'setup_failed' | 'stream_lost' | 'finalize_failed' | 'paused'; }; /** Browser capabilities evaluated for the selected SDK integration path. */ export type DictumBrowserCapability = 'AbortController' | 'ArrayBuffer' | 'AudioContext' | 'AudioContext.audioWorklet' | 'AudioWorkletNode' | 'Blob' | 'Blob.arrayBuffer' | 'browser_page' | 'DataView' | 'Headers' | 'InputEvent' | 'ReadableStream' | 'ReadableStream.getReader' | 'Response' | 'TextDecoder' | 'CustomEvent' | 'URL.createObjectURL' | 'URL.revokeObjectURL' | 'crypto.getRandomValues' | 'fetch' | 'secure_context' | 'navigator.mediaDevices.getUserMedia'; /** Detailed capability report attached to compatibility checks and failures. */ export type DictumCompatibilityDetails = { /** Exact capabilities missing from the selected path. */ readonly missing: readonly DictumBrowserCapability[]; /** Capture path that was evaluated. */ readonly capture: 'sdk' | 'custom'; }; /** Host action attached to a public error requiring user intervention. */ export type DictumSttErrorAction = 'grant_microphone' | 'sign_in' | 'reload_page' | 'provide_identity_token' | 'retry_network' | 'update_browser'; type DictumSttErrorShape = { /** Stable machine-readable error code. */ readonly code: C; /** Stable SDK-owned user-facing message. */ readonly message: string; /** Whether the failure class is transient; command retry eligibility is stricter. */ readonly retryable: R; /** Whether the host should present a user action. */ readonly userActionRequired: A extends null ? false : true; /** Reserved from general errors; compatibility errors expose typed details separately. */ readonly details?: never; } & (A extends DictumSttErrorAction ? { /** Stable host action required for this error. */ readonly action: A; } : { /** Absent when no host action is required. */ readonly action?: never; }); /** Non-retryable public error for an unsupported selected browser path. */ export type DictumSttCompatibilityError = { /** Stable compatibility error code. */ readonly code: 'browser_unsupported'; /** Stable SDK-owned user-facing message. */ readonly message: string; /** Compatibility cannot be retried without changing the environment. */ readonly retryable: false; /** Indicates that the host must guide the user. */ readonly userActionRequired: true; /** Stable host action for this error. */ readonly action: 'update_browser'; /** Exact capability details for the selected path. */ readonly details: DictumCompatibilityDetails; }; export type DictumSttErrorOf = Extract; /** Explains why a dictation produced no transcript text. */ export type DictumSttNoTranscriptData = Readonly<{ /** Local audio contained no complete PCM sample frames. */ reason: 'empty_audio'; /** Stable empty-audio error details. */ error: DictumSttErrorOf<'empty_audio'>; }> | Readonly<{ /** A valid completed transcription contained no speech text. */ reason: 'no_speech'; /** Stable no-speech error details. */ error: DictumSttErrorOf<'no_speech_detected'>; }>; /** Maps every public SDK event name to its immutable `data` payload. */ export type DictumSttEventDataMap = { /** Accepted lifecycle transition. */ readonly state_changed: DictumSttStateChangedData; /** Bounded microphone level sample. */ readonly volume_changed: DictumSttVolume; /** Append-only transcript suffix. */ readonly transcript_delta: DictumSttTranscriptDeltaData; /** Successful automatic transcript insertion. */ readonly text_inserted: DictumSttTextInsertedData; /** Microphone permission denial. */ readonly mic_denied: DictumSttErrorOf<'microphone_permission_denied'>; /** Empty audio or no-speech outcome. */ readonly no_transcript: DictumSttNoTranscriptData; /** Retryable network or transport interruption. */ readonly network_error: DictumSttErrorOf<'network_error' | 'stream_lost' | 'timeout'>; /** Invalid or oversized audio input. */ readonly audio_invalid: DictumSttErrorOf<'unsupported_audio_type' | 'audio_too_large'>; /** Unsupported selected browser integration. */ readonly compat_failed: DictumSttCompatibilityError; /** Audio duration or size limit reached before automatic finalization. */ readonly limit_reached: DictumSttLimitData; /** WebSocket-to-POST recovery that actually began. */ readonly fallback_started: DictumSttFallbackData; /** Exhausted project or user quota. */ readonly quota_exceeded: DictumSttErrorOf<'quota_exceeded'>; /** Missing signed end-user identity. */ readonly auth_required: DictumSttErrorOf<'client_not_authenticated'>; /** Expired signed identity requiring a page reload. */ readonly identity_expired: DictumSttErrorOf<'identity_expired'>; /** Invalid identity provider output or rejected identity configuration. */ readonly auth_invalid: DictumSttErrorOf<'auth_config_error'>; /** Explicit retained-audio retry started. */ readonly retry_started: DictumSttRetryData; /** General event emitted for every public SDK error. */ readonly sdk_error: DictumSttError; }; type DictumSttEventBase = { /** Stable public event name. */ readonly type: T; /** Private operation identifier removed from package-level public events. */ readonly sessionId: string; /** Stable host target identifier, when configured. */ readonly targetId?: string | null; /** Lifecycle state already active when listeners receive the event. */ readonly state: DictumSttState; /** ISO timestamp at which the event was created. */ readonly timestamp: string; /** Monotonic sequence number within the private dictation operation. */ readonly seq: number; /** Immutable payload selected by the event name. */ readonly data: DictumSttEventDataMap[T]; }; /** Immutable public SDK event envelope for one event name. */ export type DictumSttEventOf = T extends DictumSttEventType ? DictumSttEventBase : never; /** Closed immutable union of all public SDK events. */ export type DictumSttEvent = DictumSttEventOf; /** Immutable successful transcription result before private operation identity is removed. */ export type DictumSttResult = { /** Private operation identifier removed from the package-level `DictumSdkResult`. */ readonly sessionId: string; /** Complete final transcript, including an allowed successful empty result. */ readonly text: string; /** ISO timestamp at which the dictation operation began. */ readonly startedAt: string; /** ISO timestamp at which transcription completed. */ readonly endedAt: string; /** Whether automatic insertion completed successfully. */ readonly inserted: boolean; /** Insertion behavior requested for the operation. */ readonly insertMode: DictumSttInsertMode; /** Immutable metadata describing the bound insertion target. */ readonly target: { /** Stable host target identifier, when configured. */ readonly targetId: string | null; /** Normalized target category. */ readonly type: 'input' | 'textarea' | 'contenteditable' | 'custom'; }; /** Transport that produced the successful final transcript. */ readonly transport: DictumSttTransport; /** Exact provider model reported by the verified backend response. */ readonly providerModel: DictumProviderModel; /** Authoritative accepted PCM audio duration. */ readonly audioDurationMs: number; /** Combined immutable browser and server timing offsets. */ readonly timing: DictumTranscriptionTiming; }; /** Closed immutable public error union shared by events, command failures, and results. */ export type DictumSttError = DictumSttErrorShape<'microphone_permission_denied', false, 'grant_microphone'> | DictumSttErrorShape<'microphone_not_found', false, null> | DictumSttCompatibilityError | DictumSttErrorShape<'sdk_disabled', false, null> | DictumSttErrorShape<'network_error', true, 'retry_network'> | DictumSttErrorShape<'stream_lost', true, 'retry_network'> | DictumSttErrorShape<'transcription_failed', false, null> | DictumSttErrorShape<'transport_response_invalid', false, null> | DictumSttErrorShape<'empty_audio', false, null> | DictumSttErrorShape<'no_speech_detected', false, null> | DictumSttErrorShape<'quota_exceeded', false, null> | DictumSttErrorShape<'unsupported_audio_type', false, null> | DictumSttErrorShape<'audio_too_large', false, null> | DictumSttErrorShape<'rate_limited', false, null> | DictumSttErrorShape<'timeout', true, 'retry_network'> | DictumSttErrorShape<'aborted_by_user', false, null> | DictumSttErrorShape<'client_not_authenticated', false, 'sign_in'> | DictumSttErrorShape<'identity_expired', false, 'reload_page'> | DictumSttErrorShape<'config_response_invalid', false, null> | DictumSttErrorShape<'auth_config_error', false, 'provide_identity_token'>; /** Bounded microphone level sample emitted when volume metering is enabled. */ export type DictumSttVolume = { /** Normalized perceptual speech level from 0 through 1. */ readonly level: number; /** Optional linear root-mean-square sample. */ readonly rms?: number; /** Optional absolute peak sample. */ readonly peak?: number; }; export type DictumSseEvent = { eventName: string; payload: unknown; }; export declare class DictumSdkProtocolError extends Error { exact_message: string; details: unknown; raw: unknown; constructor(message: string, options?: { details?: unknown; raw?: unknown; }); } export declare function createDictumRequestId(): string; export declare function buildDictumUrl(apiBaseUrl: string, route: string): string; export declare function buildDictumWebSocketUrl(apiBaseUrl: string): string; export declare function toDictumBase64Url(value: string): string; export declare function buildDictumWebSocketProtocols(params: { rid: string; authorization?: string; }): string[]; export declare function buildDictumWebSocketInitFrame(params: Omit): DictumSdkWebSocketInitFrame; export declare function buildDictumWebSocketFinalizeFrame(): DictumSdkWebSocketFinalizeFrame; export declare function buildDictumWebSocketAuthorizeFrame(authorization: string): DictumSdkWebSocketAuthorizeFrame; export declare function parseDictumServerTiming(value: unknown, raw?: unknown): DictumServerTiming; export declare function parseDictumProviderModel(value: unknown, raw?: unknown): DictumProviderModel; export declare function buildDictumPublicEvent(params: { type: T; sessionId: string; targetId?: string | null; state: DictumSttState; timestamp?: string; seq: number; data: DictumSttEventDataMap[T]; }): DictumSttEventOf; export declare function parseDictumSseEventBlock(block: string): DictumSseEvent | null; export declare function parseDictumTranscriptFrame(raw: unknown): DictumSdkWebSocketTranscriptFrame; export {}; ## shared/errors.d.ts export type ApiErrorCategory = 'validation' | 'authentication' | 'authorization' | 'configuration' | 'quota' | 'conflict' | 'not_found' | 'dependency' | 'internal' | 'security' | 'cancelled'; export type CatalogApiError = { code: string; message: string; category: ApiErrorCategory; retryable: boolean; }; export type ApiError = CatalogApiError; export declare function isCatalogApiError(value: unknown): value is CatalogApiError; export declare function apiErrorCode(error: ApiError | null): string | undefined; /** * Projects a validated Worker catalog error onto the SDK's stable internal * classification vocabulary when no HTTP status exists (SSE/WS frames). * Human-readable messages are deliberately excluded from this decision. */ export declare function apiErrorSdkCode(error: ApiError | null): string | undefined; export declare function apiErrorMessage(error: ApiError | null, fallback: string): string; /** The HTTP response status is authoritative; catalog envelopes contain no status field. */ export declare function apiErrorStatus(_error: ApiError | null, httpStatus: number): number; export type ApiSuccess = { ok: true; data: T; }; export type ApiFailure = { ok: false; rid: string; error: ApiError; }; export declare function isApiFailure(value: unknown): value is ApiFailure; export type ApiResponse = ApiSuccess | ApiFailure; ## shared/ids.d.ts export declare function createCryptographicId(prefix: string): string; ## shared/index.d.ts export * from './api-types.js'; export * from './contracts/dictumflow-sdk.js'; export * from './errors.js'; export * from './ids.js'; export * from './public-immutability.js'; ## shared/public-immutability.d.ts /** * Deeply freezes the bounded JSON-like canonical values exposed by the SDK. * Freezing in place preserves the contractually stable identity of errors. */ export declare function deepFreezePublicValue(value: T): T;