@charivo/core 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -50,6 +50,7 @@ type RealtimeTransportKind = "webrtc" | "websocket";
50
50
  type RealtimeToolChoice = "auto" | "none" | "required";
51
51
  declare const OPENAI_REALTIME_ADAPTER = "openai-webrtc";
52
52
  declare const OPENAI_REALTIME_AGENTS_ADAPTER = "openai-agents-webrtc";
53
+ declare const GEMINI_LIVE_ADAPTER = "gemini-live-websocket";
53
54
  interface ToolDefinition {
54
55
  type: "function";
55
56
  name: string;
@@ -96,6 +97,12 @@ interface RealtimeSessionConfig {
96
97
  maxTokens?: number;
97
98
  tools?: ToolDefinition[];
98
99
  toolChoice?: RealtimeToolChoice;
100
+ /**
101
+ * Off unless asked, on every provider. `{ enabled: true }` turns it on with
102
+ * the provider's default transcription model; a `model` implies on where the
103
+ * provider offers a choice (OpenAI) and is rejected where it does not
104
+ * (Gemini); `{ enabled: false }` turns it off.
105
+ */
99
106
  inputAudioTranscription?: {
100
107
  model?: string;
101
108
  enabled?: boolean;
@@ -778,6 +785,22 @@ interface FetchWithTimeoutOptions {
778
785
  declare function fetchWithTimeout<T = Response>(input: RequestInfo | URL, init: Omit<RequestInit, "signal"> & {
779
786
  signal?: never;
780
787
  }, options: FetchWithTimeoutOptions, consumeBody?: (response: Response) => Promise<T>): Promise<T>;
788
+ /**
789
+ * Reads the most specific failure message a non-ok response carries.
790
+ *
791
+ * Remote clients talk to a caller-supplied route, and a route that took the
792
+ * trouble to explain itself is the only place the real cause lives -- a
793
+ * provider rate limit or an upstream outage reaches the browser as a bare
794
+ * status line otherwise. Routes in this repo answer with `{ error, details? }`,
795
+ * where `details` carries the vendor's own text; both are read here, most
796
+ * specific first, falling back to the status line.
797
+ *
798
+ * A body that is not JSON is not an error in itself, so it falls back. Any
799
+ * other read failure -- an abort or timeout part-way through the body --
800
+ * propagates, so `fetchWithTimeout` can classify it instead of it being masked
801
+ * as a provider error.
802
+ */
803
+ declare function readResponseErrorMessage(response: Response): Promise<string>;
781
804
 
782
805
  declare class Charivo {
783
806
  private eventBus;
@@ -1000,4 +1023,4 @@ interface CharivoOptions {
1000
1023
  */
1001
1024
  declare function createCharivo(options?: CharivoOptions): Charivo;
1002
1025
 
1003
- export { type AvatarControlCatalog, type BrowserLifecycleCallbacks, type BuiltInRealtimeManager, type BuiltInSTTManager, type BuiltInTTSManager, type Character, Charivo, CharivoDisposeError, CharivoError, type CharivoErrorCode, type CharivoErrorKind, type CharivoErrorOptions, type CharivoEventBus, type CharivoEventEmitter, type CharivoOptions, CharivoProviderError, CharivoStateError, CharivoTimeoutError, CharivoTransportError, DEFAULT_FETCH_TIMEOUT_MS, type EventMap, type FetchWithTimeoutOptions, type GazeCoordinates, type GenerateResponseOptions, type HistoryRollback, type LLMAdapter, type LLMCallOptions, type LLMClient, type LLMManager, type LLMManagerWithTools, type LLMMessage, type LLMProvider, type LLMToolCall, type LLMToolResponse, type LipSyncAnalyzer, type LipSyncAnalyzerOptions, type Message, type MotionSelection, OPENAI_REALTIME_ADAPTER, OPENAI_REALTIME_AGENTS_ADAPTER, type RealtimeConnectionState, type RealtimeManager, type RealtimeProvider, type RealtimeReconnectCause, type RealtimeResponseStatus, type RealtimeSessionBootstrap, type RealtimeSessionConfig, type RealtimeSessionRequest, type RealtimeSessionStatus, type RealtimeSessionTransitionReason, type RealtimeState, type RealtimeToolChoice, type RealtimeTransportKind, type RealtimeUsageEvent, type RenderManager, type Renderer, type STTManager, type STTOptions, type STTProvider, type STTTranscriber, type TTSManager, type TTSOptions, type TTSPlaybackMode, type TTSPlayer, type TTSProvider, type ToolContext, type ToolDefinition, type ToolHandler, type ToolRegistration, type ToolRegistry, type ToolResultProjector, type ToolResultProjectorContext, type ToolResultSnapshot, assertToolResultObject, createCharivo, createLipSyncAnalyzer, createToolFailureOutput, createToolRegistry, fetchWithTimeout, getErrorMessage, isCharivoError, snapshotToolResult, subscribeBrowserLifecycle, toCharivoError, validateToolArguments, withToolTimeout };
1026
+ export { type AvatarControlCatalog, type BrowserLifecycleCallbacks, type BuiltInRealtimeManager, type BuiltInSTTManager, type BuiltInTTSManager, type Character, Charivo, CharivoDisposeError, CharivoError, type CharivoErrorCode, type CharivoErrorKind, type CharivoErrorOptions, type CharivoEventBus, type CharivoEventEmitter, type CharivoOptions, CharivoProviderError, CharivoStateError, CharivoTimeoutError, CharivoTransportError, DEFAULT_FETCH_TIMEOUT_MS, type EventMap, type FetchWithTimeoutOptions, GEMINI_LIVE_ADAPTER, type GazeCoordinates, type GenerateResponseOptions, type HistoryRollback, type LLMAdapter, type LLMCallOptions, type LLMClient, type LLMManager, type LLMManagerWithTools, type LLMMessage, type LLMProvider, type LLMToolCall, type LLMToolResponse, type LipSyncAnalyzer, type LipSyncAnalyzerOptions, type Message, type MotionSelection, OPENAI_REALTIME_ADAPTER, OPENAI_REALTIME_AGENTS_ADAPTER, type RealtimeConnectionState, type RealtimeManager, type RealtimeProvider, type RealtimeReconnectCause, type RealtimeResponseStatus, type RealtimeSessionBootstrap, type RealtimeSessionConfig, type RealtimeSessionRequest, type RealtimeSessionStatus, type RealtimeSessionTransitionReason, type RealtimeState, type RealtimeToolChoice, type RealtimeTransportKind, type RealtimeUsageEvent, type RenderManager, type Renderer, type STTManager, type STTOptions, type STTProvider, type STTTranscriber, type TTSManager, type TTSOptions, type TTSPlaybackMode, type TTSPlayer, type TTSProvider, type ToolContext, type ToolDefinition, type ToolHandler, type ToolRegistration, type ToolRegistry, type ToolResultProjector, type ToolResultProjectorContext, type ToolResultSnapshot, assertToolResultObject, createCharivo, createLipSyncAnalyzer, createToolFailureOutput, createToolRegistry, fetchWithTimeout, getErrorMessage, isCharivoError, readResponseErrorMessage, snapshotToolResult, subscribeBrowserLifecycle, toCharivoError, validateToolArguments, withToolTimeout };
package/dist/index.d.ts CHANGED
@@ -50,6 +50,7 @@ type RealtimeTransportKind = "webrtc" | "websocket";
50
50
  type RealtimeToolChoice = "auto" | "none" | "required";
51
51
  declare const OPENAI_REALTIME_ADAPTER = "openai-webrtc";
52
52
  declare const OPENAI_REALTIME_AGENTS_ADAPTER = "openai-agents-webrtc";
53
+ declare const GEMINI_LIVE_ADAPTER = "gemini-live-websocket";
53
54
  interface ToolDefinition {
54
55
  type: "function";
55
56
  name: string;
@@ -96,6 +97,12 @@ interface RealtimeSessionConfig {
96
97
  maxTokens?: number;
97
98
  tools?: ToolDefinition[];
98
99
  toolChoice?: RealtimeToolChoice;
100
+ /**
101
+ * Off unless asked, on every provider. `{ enabled: true }` turns it on with
102
+ * the provider's default transcription model; a `model` implies on where the
103
+ * provider offers a choice (OpenAI) and is rejected where it does not
104
+ * (Gemini); `{ enabled: false }` turns it off.
105
+ */
99
106
  inputAudioTranscription?: {
100
107
  model?: string;
101
108
  enabled?: boolean;
@@ -778,6 +785,22 @@ interface FetchWithTimeoutOptions {
778
785
  declare function fetchWithTimeout<T = Response>(input: RequestInfo | URL, init: Omit<RequestInit, "signal"> & {
779
786
  signal?: never;
780
787
  }, options: FetchWithTimeoutOptions, consumeBody?: (response: Response) => Promise<T>): Promise<T>;
788
+ /**
789
+ * Reads the most specific failure message a non-ok response carries.
790
+ *
791
+ * Remote clients talk to a caller-supplied route, and a route that took the
792
+ * trouble to explain itself is the only place the real cause lives -- a
793
+ * provider rate limit or an upstream outage reaches the browser as a bare
794
+ * status line otherwise. Routes in this repo answer with `{ error, details? }`,
795
+ * where `details` carries the vendor's own text; both are read here, most
796
+ * specific first, falling back to the status line.
797
+ *
798
+ * A body that is not JSON is not an error in itself, so it falls back. Any
799
+ * other read failure -- an abort or timeout part-way through the body --
800
+ * propagates, so `fetchWithTimeout` can classify it instead of it being masked
801
+ * as a provider error.
802
+ */
803
+ declare function readResponseErrorMessage(response: Response): Promise<string>;
781
804
 
782
805
  declare class Charivo {
783
806
  private eventBus;
@@ -1000,4 +1023,4 @@ interface CharivoOptions {
1000
1023
  */
1001
1024
  declare function createCharivo(options?: CharivoOptions): Charivo;
1002
1025
 
1003
- export { type AvatarControlCatalog, type BrowserLifecycleCallbacks, type BuiltInRealtimeManager, type BuiltInSTTManager, type BuiltInTTSManager, type Character, Charivo, CharivoDisposeError, CharivoError, type CharivoErrorCode, type CharivoErrorKind, type CharivoErrorOptions, type CharivoEventBus, type CharivoEventEmitter, type CharivoOptions, CharivoProviderError, CharivoStateError, CharivoTimeoutError, CharivoTransportError, DEFAULT_FETCH_TIMEOUT_MS, type EventMap, type FetchWithTimeoutOptions, type GazeCoordinates, type GenerateResponseOptions, type HistoryRollback, type LLMAdapter, type LLMCallOptions, type LLMClient, type LLMManager, type LLMManagerWithTools, type LLMMessage, type LLMProvider, type LLMToolCall, type LLMToolResponse, type LipSyncAnalyzer, type LipSyncAnalyzerOptions, type Message, type MotionSelection, OPENAI_REALTIME_ADAPTER, OPENAI_REALTIME_AGENTS_ADAPTER, type RealtimeConnectionState, type RealtimeManager, type RealtimeProvider, type RealtimeReconnectCause, type RealtimeResponseStatus, type RealtimeSessionBootstrap, type RealtimeSessionConfig, type RealtimeSessionRequest, type RealtimeSessionStatus, type RealtimeSessionTransitionReason, type RealtimeState, type RealtimeToolChoice, type RealtimeTransportKind, type RealtimeUsageEvent, type RenderManager, type Renderer, type STTManager, type STTOptions, type STTProvider, type STTTranscriber, type TTSManager, type TTSOptions, type TTSPlaybackMode, type TTSPlayer, type TTSProvider, type ToolContext, type ToolDefinition, type ToolHandler, type ToolRegistration, type ToolRegistry, type ToolResultProjector, type ToolResultProjectorContext, type ToolResultSnapshot, assertToolResultObject, createCharivo, createLipSyncAnalyzer, createToolFailureOutput, createToolRegistry, fetchWithTimeout, getErrorMessage, isCharivoError, snapshotToolResult, subscribeBrowserLifecycle, toCharivoError, validateToolArguments, withToolTimeout };
1026
+ export { type AvatarControlCatalog, type BrowserLifecycleCallbacks, type BuiltInRealtimeManager, type BuiltInSTTManager, type BuiltInTTSManager, type Character, Charivo, CharivoDisposeError, CharivoError, type CharivoErrorCode, type CharivoErrorKind, type CharivoErrorOptions, type CharivoEventBus, type CharivoEventEmitter, type CharivoOptions, CharivoProviderError, CharivoStateError, CharivoTimeoutError, CharivoTransportError, DEFAULT_FETCH_TIMEOUT_MS, type EventMap, type FetchWithTimeoutOptions, GEMINI_LIVE_ADAPTER, type GazeCoordinates, type GenerateResponseOptions, type HistoryRollback, type LLMAdapter, type LLMCallOptions, type LLMClient, type LLMManager, type LLMManagerWithTools, type LLMMessage, type LLMProvider, type LLMToolCall, type LLMToolResponse, type LipSyncAnalyzer, type LipSyncAnalyzerOptions, type Message, type MotionSelection, OPENAI_REALTIME_ADAPTER, OPENAI_REALTIME_AGENTS_ADAPTER, type RealtimeConnectionState, type RealtimeManager, type RealtimeProvider, type RealtimeReconnectCause, type RealtimeResponseStatus, type RealtimeSessionBootstrap, type RealtimeSessionConfig, type RealtimeSessionRequest, type RealtimeSessionStatus, type RealtimeSessionTransitionReason, type RealtimeState, type RealtimeToolChoice, type RealtimeTransportKind, type RealtimeUsageEvent, type RenderManager, type Renderer, type STTManager, type STTOptions, type STTProvider, type STTTranscriber, type TTSManager, type TTSOptions, type TTSPlaybackMode, type TTSPlayer, type TTSProvider, type ToolContext, type ToolDefinition, type ToolHandler, type ToolRegistration, type ToolRegistry, type ToolResultProjector, type ToolResultProjectorContext, type ToolResultSnapshot, assertToolResultObject, createCharivo, createLipSyncAnalyzer, createToolFailureOutput, createToolRegistry, fetchWithTimeout, getErrorMessage, isCharivoError, readResponseErrorMessage, snapshotToolResult, subscribeBrowserLifecycle, toCharivoError, validateToolArguments, withToolTimeout };
package/dist/index.js CHANGED
@@ -151,6 +151,7 @@ function toCharivoError(kind, error, fallbackMessage) {
151
151
  // src/types.ts
152
152
  var OPENAI_REALTIME_ADAPTER = "openai-webrtc";
153
153
  var OPENAI_REALTIME_AGENTS_ADAPTER = "openai-agents-webrtc";
154
+ var GEMINI_LIVE_ADAPTER = "gemini-live-websocket";
154
155
 
155
156
  // src/browser-lifecycle.ts
156
157
  var subscribers = /* @__PURE__ */ new Set();
@@ -606,6 +607,20 @@ function fetchWithTimeout(input, init, options, consumeBody) {
606
607
  }
607
608
  );
608
609
  }
610
+ async function readResponseErrorMessage(response) {
611
+ let body;
612
+ try {
613
+ body = await response.json();
614
+ } catch (error) {
615
+ if (!(error instanceof SyntaxError)) {
616
+ throw error;
617
+ }
618
+ }
619
+ const fields = typeof body === "object" && body !== null ? body : {};
620
+ const detail = typeof fields.details === "string" ? fields.details : void 0;
621
+ const summary = typeof fields.error === "string" ? fields.error : void 0;
622
+ return detail ?? summary ?? response.statusText;
623
+ }
609
624
 
610
625
  // src/index.ts
611
626
  var Charivo = class {
@@ -1226,6 +1241,6 @@ function createCharivo(options = {}) {
1226
1241
  return charivo;
1227
1242
  }
1228
1243
 
1229
- export { Charivo, CharivoDisposeError, CharivoError, CharivoProviderError, CharivoStateError, CharivoTimeoutError, CharivoTransportError, DEFAULT_FETCH_TIMEOUT_MS, OPENAI_REALTIME_ADAPTER, OPENAI_REALTIME_AGENTS_ADAPTER, assertToolResultObject, createCharivo, createLipSyncAnalyzer, createToolFailureOutput, createToolRegistry, fetchWithTimeout, getErrorMessage, isCharivoError, snapshotToolResult, subscribeBrowserLifecycle, toCharivoError, validateToolArguments, withToolTimeout };
1244
+ export { Charivo, CharivoDisposeError, CharivoError, CharivoProviderError, CharivoStateError, CharivoTimeoutError, CharivoTransportError, DEFAULT_FETCH_TIMEOUT_MS, GEMINI_LIVE_ADAPTER, OPENAI_REALTIME_ADAPTER, OPENAI_REALTIME_AGENTS_ADAPTER, assertToolResultObject, createCharivo, createLipSyncAnalyzer, createToolFailureOutput, createToolRegistry, fetchWithTimeout, getErrorMessage, isCharivoError, readResponseErrorMessage, snapshotToolResult, subscribeBrowserLifecycle, toCharivoError, validateToolArguments, withToolTimeout };
1230
1245
  //# sourceMappingURL=index.js.map
1231
1246
  //# sourceMappingURL=index.js.map