@convai/web-sdk 1.8.0-beta.7 → 1.8.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/README.md +44 -194
- package/dist/core/ConvaiClient.d.ts +1 -190
- package/dist/core/ConvaiClient.d.ts.map +1 -1
- package/dist/core/ConvaiClient.js +286 -1306
- package/dist/core/ConvaiClient.js.map +1 -1
- package/dist/core/MessageHandler.d.ts +1 -19
- package/dist/core/MessageHandler.d.ts.map +1 -1
- package/dist/core/MessageHandler.js +27 -378
- package/dist/core/MessageHandler.js.map +1 -1
- package/dist/core/connectRequest.d.ts +4 -17
- package/dist/core/connectRequest.d.ts.map +1 -1
- package/dist/core/connectRequest.js +17 -28
- package/dist/core/connectRequest.js.map +1 -1
- package/dist/core/index.d.ts +1 -6
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -7
- package/dist/core/index.js.map +1 -1
- package/dist/core/logicalTurn.d.ts +6 -4
- package/dist/core/logicalTurn.d.ts.map +1 -1
- package/dist/core/logicalTurn.js +4 -29
- package/dist/core/logicalTurn.js.map +1 -1
- package/dist/core/modelOutput.d.ts.map +1 -1
- package/dist/core/modelOutput.js +2 -2
- package/dist/core/modelOutput.js.map +1 -1
- package/dist/core/types.d.ts +22 -860
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/embed/chat-embed-v1.js +9 -10
- package/dist/embed/chat-embed-v1.js.map +4 -4
- package/dist/react/components/ConvaiWidget.d.ts.map +1 -1
- package/dist/react/components/ConvaiWidget.js +1 -6
- package/dist/react/components/ConvaiWidget.js.map +1 -1
- package/dist/react/components/rtc-widget/components/AudioVisualizer.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/AudioVisualizer.js +1 -28
- package/dist/react/components/rtc-widget/components/AudioVisualizer.js.map +1 -1
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +44 -39
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.js.map +1 -1
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js +49 -93
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js.map +1 -1
- package/dist/react/hooks/useConvaiClient.d.ts.map +1 -1
- package/dist/react/hooks/useConvaiClient.js +2 -17
- package/dist/react/hooks/useConvaiClient.js.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/vanilla/AudioRenderer.d.ts +1 -3
- package/dist/vanilla/AudioRenderer.d.ts.map +1 -1
- package/dist/vanilla/AudioRenderer.js +2 -8
- package/dist/vanilla/AudioRenderer.js.map +1 -1
- package/dist/vanilla/ConvaiWidget.d.ts.map +1 -1
- package/dist/vanilla/ConvaiWidget.js +300 -994
- package/dist/vanilla/ConvaiWidget.js.map +1 -1
- package/dist/vanilla/WidgetEventSubscriptions.d.ts +1 -1
- package/dist/vanilla/WidgetEventSubscriptions.d.ts.map +1 -1
- package/dist/vanilla/WidgetEventSubscriptions.js +0 -5
- package/dist/vanilla/WidgetEventSubscriptions.js.map +1 -1
- package/dist/vanilla/icons.d.ts.map +1 -1
- package/dist/vanilla/icons.js +15 -62
- package/dist/vanilla/icons.js.map +1 -1
- package/dist/vanilla/index.d.ts +2 -4
- package/dist/vanilla/index.d.ts.map +1 -1
- package/dist/vanilla/index.js +1 -3
- package/dist/vanilla/index.js.map +1 -1
- package/dist/vanilla/styles.d.ts +1 -18
- package/dist/vanilla/styles.d.ts.map +1 -1
- package/dist/vanilla/styles.js +29 -129
- package/dist/vanilla/styles.js.map +1 -1
- package/dist/vanilla/types.d.ts +0 -74
- package/dist/vanilla/types.d.ts.map +1 -1
- package/dist/vanilla/types.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +8 -13
- package/dist/core/CharacterRoster.d.ts +0 -84
- package/dist/core/CharacterRoster.d.ts.map +0 -1
- package/dist/core/CharacterRoster.js +0 -348
- package/dist/core/CharacterRoster.js.map +0 -1
- package/dist/core/CharacterVersionManager.d.ts +0 -100
- package/dist/core/CharacterVersionManager.d.ts.map +0 -1
- package/dist/core/CharacterVersionManager.js +0 -227
- package/dist/core/CharacterVersionManager.js.map +0 -1
- package/dist/core/ConvaiRoomError.d.ts +0 -48
- package/dist/core/ConvaiRoomError.d.ts.map +0 -1
- package/dist/core/ConvaiRoomError.js +0 -111
- package/dist/core/ConvaiRoomError.js.map +0 -1
- package/dist/core/SSESession.d.ts +0 -59
- package/dist/core/SSESession.d.ts.map +0 -1
- package/dist/core/SSESession.js +0 -289
- package/dist/core/SSESession.js.map +0 -1
- package/dist/core/characterReference.d.ts +0 -40
- package/dist/core/characterReference.d.ts.map +0 -1
- package/dist/core/characterReference.js +0 -72
- package/dist/core/characterReference.js.map +0 -1
- package/dist/core/rosterRequest.d.ts +0 -57
- package/dist/core/rosterRequest.d.ts.map +0 -1
- package/dist/core/rosterRequest.js +0 -210
- package/dist/core/rosterRequest.js.map +0 -1
- package/dist/utils/inlineMarkdown.d.ts +0 -38
- package/dist/utils/inlineMarkdown.d.ts.map +0 -1
- package/dist/utils/inlineMarkdown.js +0 -106
- package/dist/utils/inlineMarkdown.js.map +0 -1
package/dist/core/types.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Room, DisconnectReason as LiveKitDisconnectReason } from 'livekit-client';
|
|
2
|
-
import type { CharacterVersionSelector } from "./characterReference.js";
|
|
3
|
-
export type { CharacterVersionSelector, CharacterReference } from "./characterReference.js";
|
|
4
2
|
import { BlendshapeQueue } from './BlendshapeQueue.js';
|
|
5
3
|
/**
|
|
6
4
|
* LiveKit disconnect reasons.
|
|
@@ -124,17 +122,6 @@ export interface ServerResponseExtras {
|
|
|
124
122
|
has_speak_tag?: boolean;
|
|
125
123
|
text?: string;
|
|
126
124
|
room_name?: string;
|
|
127
|
-
command_id?: string;
|
|
128
|
-
room_session_id?: string;
|
|
129
|
-
previous_membership_id?: string | null;
|
|
130
|
-
active_membership_id?: string | null;
|
|
131
|
-
previous_active_membership_id?: string | null;
|
|
132
|
-
route_epoch?: number;
|
|
133
|
-
roster_epoch?: number;
|
|
134
|
-
changed?: boolean;
|
|
135
|
-
added?: unknown[];
|
|
136
|
-
removed_membership_ids?: string[];
|
|
137
|
-
code?: string;
|
|
138
125
|
supported_types?: string[];
|
|
139
126
|
vision_buffer?: VisionBufferStatus;
|
|
140
127
|
requested_respond_mode?: RespondMode;
|
|
@@ -234,16 +221,15 @@ export interface ProtocolCapabilitiesConfig {
|
|
|
234
221
|
actionProtocolVersion?: 1 | 2;
|
|
235
222
|
/** Opt in to canonical typed model output. Omitted connections remain v1. */
|
|
236
223
|
modelOutputVersion?: 1 | 2;
|
|
237
|
-
}
|
|
238
|
-
/** One raw provider-output chunk emitted only by negotiated model output v2. */
|
|
239
|
-
export interface BotLlmTextRawEvent {
|
|
240
|
-
text: string;
|
|
241
|
-
logical_turn_id: string;
|
|
242
224
|
/**
|
|
243
|
-
* Core
|
|
244
|
-
*
|
|
225
|
+
* Select what Core streams through the existing `bot-llm-text` event.
|
|
226
|
+
*
|
|
227
|
+
* `"raw"` is an explicit opt-in to the complete user-visible provider output
|
|
228
|
+
* before action/display parsing. Omit this field for the legacy filtered text
|
|
229
|
+
* stream. `"legacy"` is available when an application needs to state that
|
|
230
|
+
* choice explicitly.
|
|
245
231
|
*/
|
|
246
|
-
|
|
232
|
+
botLlmTextMode?: "legacy" | "raw";
|
|
247
233
|
}
|
|
248
234
|
export interface ModelOutputMessageItem {
|
|
249
235
|
type: "message";
|
|
@@ -280,10 +266,6 @@ export type ModelOutputItem = ModelOutputMessageItem | ModelOutputEmotionItem |
|
|
|
280
266
|
export interface ModelOutputMessage {
|
|
281
267
|
type: "model-output";
|
|
282
268
|
version: 2;
|
|
283
|
-
/**
|
|
284
|
-
* Core-owned provider invocation id. Distinct projections from the same
|
|
285
|
-
* invocation can share this value and are emitted in arrival order.
|
|
286
|
-
*/
|
|
287
269
|
output_id: string;
|
|
288
270
|
/**
|
|
289
271
|
* Stable identifier shared by every output envelope for one logical turn.
|
|
@@ -308,29 +290,6 @@ export interface ActionResult {
|
|
|
308
290
|
error?: JsonValue;
|
|
309
291
|
characterSessionId?: string;
|
|
310
292
|
}
|
|
311
|
-
/** Successful server acknowledgement for one correlated action result. */
|
|
312
|
-
export interface ActionResultAck {
|
|
313
|
-
toolCallId: string;
|
|
314
|
-
status: "success";
|
|
315
|
-
message: string | null;
|
|
316
|
-
/** True when Core had already accepted the same terminal result. */
|
|
317
|
-
idempotent: boolean;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Controls acknowledgement waiting for
|
|
321
|
-
* {@link IConvaiClient.sendActionResultAndWait}.
|
|
322
|
-
*/
|
|
323
|
-
export interface ActionResultAckOptions {
|
|
324
|
-
/** Maximum wait for Core's acknowledgement. Defaults to 10 seconds. */
|
|
325
|
-
timeoutMs?: number;
|
|
326
|
-
/**
|
|
327
|
-
* Cancels acknowledgement waiting. An already-aborted signal prevents
|
|
328
|
-
* publication.
|
|
329
|
-
*/
|
|
330
|
-
signal?: AbortSignal;
|
|
331
|
-
}
|
|
332
|
-
/** Machine-readable reason exposed by `ActionResultAckError`. */
|
|
333
|
-
export type ActionResultAckFailureReason = "server_error" | "publication_error" | "timeout" | "aborted" | "duplicate_in_flight";
|
|
334
293
|
/**
|
|
335
294
|
* Payload of the `actionResponse` event. Actions execute sequentially; an
|
|
336
295
|
* empty array is a valid "no action" turn.
|
|
@@ -535,101 +494,8 @@ export interface ConvaiConfig {
|
|
|
535
494
|
/** Your Convai API key or Auth Token (at least one is required) */
|
|
536
495
|
apiKey?: string;
|
|
537
496
|
authToken?: string;
|
|
538
|
-
/**
|
|
539
|
-
|
|
540
|
-
*
|
|
541
|
-
* May also carry a version selector suffix (`<uuid>-draft`, `<uuid>-latest`,
|
|
542
|
-
* `<uuid>-1.2`); `characterVersion` is the clearer way to say the same thing.
|
|
543
|
-
*
|
|
544
|
-
* Optional only because a multi-character room supplies `characters`
|
|
545
|
-
* instead. Exactly one of the two is required, and a version selector is not
|
|
546
|
-
* accepted inside a roster entry.
|
|
547
|
-
*/
|
|
548
|
-
characterId?: string;
|
|
549
|
-
/**
|
|
550
|
-
* Which version of the character to run (optional).
|
|
551
|
-
*
|
|
552
|
-
* - `"draft"` — the editable draft, so you can test unreleased changes
|
|
553
|
-
* - `"latest"` — the promoted latest release
|
|
554
|
-
* - `"1.2"` / `"1.2.3"` — an immutable tagged version
|
|
555
|
-
*
|
|
556
|
-
* Omit it to let the runtime pick the effective latest revision, which is
|
|
557
|
-
* also how characters that predate versioning behave. The selector is joined
|
|
558
|
-
* to `characterId` on the wire as `<uuid>-<selector>`; `client.characterId`
|
|
559
|
-
* keeps returning the bare UUID.
|
|
560
|
-
*
|
|
561
|
-
* @example
|
|
562
|
-
* ```ts
|
|
563
|
-
* const client = new ConvaiClient({
|
|
564
|
-
* apiKey: 'YOUR_API_KEY',
|
|
565
|
-
* characterId: 'YOUR_CHARACTER_ID',
|
|
566
|
-
* characterVersion: 'draft',
|
|
567
|
-
* });
|
|
568
|
-
* ```
|
|
569
|
-
*/
|
|
570
|
-
characterVersion?: CharacterVersionSelector | null;
|
|
571
|
-
/**
|
|
572
|
-
* Base URL of the Character REST platform used by `client.characterVersions`
|
|
573
|
-
* (optional, defaults to `https://api2.convai.com`). Point it at
|
|
574
|
-
* `https://api2-stg.convai.com` to author against staging.
|
|
575
|
-
*/
|
|
576
|
-
characterApiUrl?: string;
|
|
577
|
-
/**
|
|
578
|
-
* Ordered roster of character instances for a multi-character room. Pass this
|
|
579
|
-
* *instead of* `characterId` -- exactly one of the two is valid.
|
|
580
|
-
*
|
|
581
|
-
* Every entry becomes a distinct membership with its own actor, LiveKit
|
|
582
|
-
* participant, voice, history and lifecycle. The same `characterId` may
|
|
583
|
-
* appear more than once; each copy is an independent clone addressed by its
|
|
584
|
-
* own `membershipId`. `characters[0]` is the initial active member.
|
|
585
|
-
*
|
|
586
|
-
* Roster rooms require the LiveKit transport, a nonblank `endUserId`, and the
|
|
587
|
-
* `MULTI_CHARACTER_V0` entitlement on the publisher.
|
|
588
|
-
*
|
|
589
|
-
* @example
|
|
590
|
-
* ```ts
|
|
591
|
-
* const client = new ConvaiClient({
|
|
592
|
-
* apiKey: 'YOUR_API_KEY',
|
|
593
|
-
* endUserId: 'player-42',
|
|
594
|
-
* characters: [
|
|
595
|
-
* { characterId: GUIDE }, // initial active member
|
|
596
|
-
* { characterId: ASSESSOR },
|
|
597
|
-
* { characterId: GUIDE }, // a second, independent copy of GUIDE
|
|
598
|
-
* ],
|
|
599
|
-
* });
|
|
600
|
-
* ```
|
|
601
|
-
*/
|
|
602
|
-
characters?: ConvaiCharacterSpec[];
|
|
603
|
-
/**
|
|
604
|
-
* Publisher-scoped room grouping and topology key (1-128 chars of letters,
|
|
605
|
-
* digits, hyphen or underscore). A matching create request reuses the
|
|
606
|
-
* existing room; reusing the key with a different ordered roster, creator or
|
|
607
|
-
* capacity is rejected with `ROSTER_FINGERPRINT_MISMATCH`. Reordering the
|
|
608
|
-
* same characters counts as different, because it changes the initial member.
|
|
609
|
-
*
|
|
610
|
-
* This does not raise human capacity on its own -- see `maxNumParticipants`.
|
|
611
|
-
*/
|
|
612
|
-
sharedSessionKey?: string;
|
|
613
|
-
/**
|
|
614
|
-
* Idempotency key for one logical connect (1-128 chars, same charset as
|
|
615
|
-
* `sharedSessionKey`). Reuse it only when retrying with an identical payload:
|
|
616
|
-
* within the replay window a completed attempt returns its original response
|
|
617
|
-
* and token, while a changed payload or a still-running original is rejected.
|
|
618
|
-
*/
|
|
619
|
-
connectAttemptId?: string;
|
|
620
|
-
/**
|
|
621
|
-
* Maximum number of distinct human speakers in a roster room. Characters do
|
|
622
|
-
* not count toward it. Defaults to the server's value of 1, which admits no
|
|
623
|
-
* second human -- raise it before expecting `joinRoom()` to succeed.
|
|
624
|
-
*/
|
|
625
|
-
maxNumParticipants?: number;
|
|
626
|
-
/**
|
|
627
|
-
* Bounded retry when a roster room is still provisioning (409
|
|
628
|
-
* `ROSTER_PROVISIONING_IN_PROGRESS`). Defaults to four attempts starting at
|
|
629
|
-
* 500ms and doubling with jitter. Pass `false` to surface the error instead
|
|
630
|
-
* and retry in application code.
|
|
631
|
-
*/
|
|
632
|
-
rosterProvisioningRetry?: RosterProvisioningRetry | false;
|
|
497
|
+
/** The Character ID to connect to (required) */
|
|
498
|
+
characterId: string;
|
|
633
499
|
/** Temporary character state of mind sent as `state_of_mind` on connect. */
|
|
634
500
|
stateOfMind?: string | null;
|
|
635
501
|
/**
|
|
@@ -655,10 +521,8 @@ export interface ConvaiConfig {
|
|
|
655
521
|
endUserMetadata?: Record<string, unknown>;
|
|
656
522
|
/** Custom Convai API URL (optional, defaults to production endpoint) */
|
|
657
523
|
url?: string;
|
|
658
|
-
/** Transport layer to use. Default: "livekit". */
|
|
659
|
-
transport?: "livekit" | "websocket"
|
|
660
|
-
/** SSE interaction endpoint. Supplying this also selects the SSE transport when transport is omitted. */
|
|
661
|
-
interactionApiUrl?: string;
|
|
524
|
+
/** Transport layer to use. Default: "livekit". Use "websocket" for Pipecat WebSocket transport. */
|
|
525
|
+
transport?: "livekit" | "websocket";
|
|
662
526
|
/** Explicit protocol opt-ins. Omit to preserve the legacy v1 wire contract. */
|
|
663
527
|
capabilities?: ProtocolCapabilitiesConfig;
|
|
664
528
|
/**
|
|
@@ -689,27 +553,8 @@ export interface ConvaiConfig {
|
|
|
689
553
|
* visionInputConfig.enabled=false to opt out while keeping the video channel.
|
|
690
554
|
*/
|
|
691
555
|
visionInputConfig?: VisionInputConfig;
|
|
692
|
-
/**
|
|
693
|
-
* Controls whether Core injects its vision-state instructions into the model prompt.
|
|
694
|
-
* Omit this option (or use `"auto"`) to preserve the existing runtime behavior.
|
|
695
|
-
* Use `"disabled"` for metadata-only sessions that must not advertise or deny
|
|
696
|
-
* visual perception.
|
|
697
|
-
*/
|
|
698
|
-
visionPromptMode?: "auto" | "disabled";
|
|
699
556
|
/** Connect-time respond-mode defaults by modality. */
|
|
700
557
|
respondModes?: RespondModesConfig;
|
|
701
|
-
/** Descriptive objects visible in the scene at connection time. */
|
|
702
|
-
sceneDescription?: Array<{
|
|
703
|
-
name: string;
|
|
704
|
-
description: string;
|
|
705
|
-
}>;
|
|
706
|
-
/**
|
|
707
|
-
* WebRTC ICE transport policy for the LiveKit connection (default: "relay").
|
|
708
|
-
* "relay" forces TURN-only (reliable against Convai's hosted LiveKit which
|
|
709
|
-
* provides TURN). Set "all" to also allow host/srflx candidates when the
|
|
710
|
-
* LiveKit has no TURN server (e.g. local dev).
|
|
711
|
-
*/
|
|
712
|
-
iceTransportPolicy?: RTCIceTransportPolicy;
|
|
713
558
|
/** Enable text-to-speech audio generation (default: true) */
|
|
714
559
|
ttsEnabled?: boolean;
|
|
715
560
|
/**
|
|
@@ -723,15 +568,7 @@ export interface ConvaiConfig {
|
|
|
723
568
|
/** Blendshape configuration for facial animation format */
|
|
724
569
|
blendshapeConfig?: {
|
|
725
570
|
/** Format of blendshapes: "arkit" or "mha" (Meta Human Animation, default: "mha") */
|
|
726
|
-
|
|
727
|
-
* Blendshape stream format (default: "mha"). Server-verified set:
|
|
728
|
-
* - "mha" — 251 channels (Unreal MetaHuman Animation, CTRL_expressions_*)
|
|
729
|
-
* - "arkit" — 61 channels (Apple ARKit names)
|
|
730
|
-
* - "cc4_extended" — 170 channels (Reallusion CC4 ExpressionPlus)
|
|
731
|
-
* - "cc5_hd" — accepted by the server but currently delivers no frames
|
|
732
|
-
* - "visemes" — 15 channels (OVR viseme set)
|
|
733
|
-
*/
|
|
734
|
-
format?: "arkit" | "mha" | "cc4_extended" | "cc5_hd" | "visemes";
|
|
571
|
+
format?: "arkit" | "mha";
|
|
735
572
|
/**
|
|
736
573
|
* Custom mapper function to transform incoming blendshapes.
|
|
737
574
|
* Use this to map Convai blendshapes to your character's morph targets.
|
|
@@ -761,7 +598,7 @@ export interface ConvaiConfig {
|
|
|
761
598
|
*/
|
|
762
599
|
frames_buffer_duration?: number;
|
|
763
600
|
/**
|
|
764
|
-
* Enable server ahead-delivery for NeuroSync chunks
|
|
601
|
+
* Enable server ahead-delivery for NeuroSync chunks.
|
|
765
602
|
*
|
|
766
603
|
* Defaults to `true` when `enableLipsync` is on. The server may send
|
|
767
604
|
* indexed blendshape chunks before audio playback, so use the SDK
|
|
@@ -867,37 +704,6 @@ export interface ConvaiConfig {
|
|
|
867
704
|
* Enable debug mode for additional logging and diagnostics (default: false).
|
|
868
705
|
*/
|
|
869
706
|
debug?: boolean;
|
|
870
|
-
/** Optional per-session response lifecycle contract override. */
|
|
871
|
-
useResponseLifecycleContract?: boolean;
|
|
872
|
-
/**
|
|
873
|
-
* Keep links in the character's text output (default: server-side, currently off).
|
|
874
|
-
*
|
|
875
|
-
* Core-service flattens the LLM's markdown before streaming `bot-llm-text`,
|
|
876
|
-
* which also drops link targets: `[Doc](https://…/a.pdf)` reaches the client
|
|
877
|
-
* as `Doc`. With this on, the session preserves `[text](url)`, ``
|
|
878
|
-
* and bare `http(s)://` URLs verbatim (trailing sentence punctuation stays
|
|
879
|
-
* outside the URL, non-http(s) schemes are still stripped) while bold,
|
|
880
|
-
* headings, tables and code are flattened as before. Speech is unaffected —
|
|
881
|
-
* URLs are never read aloud.
|
|
882
|
-
*
|
|
883
|
-
* Both widgets render the preserved form as clickable links, with inline
|
|
884
|
-
* previews for image and video URLs. If you render `chatMessages` yourself,
|
|
885
|
-
* expect markdown links in `content` once this is on.
|
|
886
|
-
*
|
|
887
|
-
* Sent as `preserve_links_in_output` on `/connect`; omitted when undefined so
|
|
888
|
-
* the server's own default applies. If you build the `/connect` request
|
|
889
|
-
* server-side for `connectWithConnectionData()`, add the field there.
|
|
890
|
-
*
|
|
891
|
-
* @example
|
|
892
|
-
* ```typescript
|
|
893
|
-
* const client = new ConvaiClient({
|
|
894
|
-
* apiKey: 'your-api-key',
|
|
895
|
-
* characterId: 'your-character-id',
|
|
896
|
-
* preserveLinksInOutput: true,
|
|
897
|
-
* });
|
|
898
|
-
* ```
|
|
899
|
-
*/
|
|
900
|
-
preserveLinksInOutput?: boolean;
|
|
901
707
|
/**
|
|
902
708
|
* Log decoded RTVI data messages to the browser console (default: true).
|
|
903
709
|
* Set to false to silence incoming and outgoing RTVI message logs.
|
|
@@ -916,294 +722,10 @@ export interface ConvaiConfig {
|
|
|
916
722
|
extraMetadata?: Record<string, unknown>;
|
|
917
723
|
};
|
|
918
724
|
}
|
|
919
|
-
/** Optional metadata for a text interaction. */
|
|
920
|
-
export interface SendUserTextMessageOptions {
|
|
921
|
-
/** Stable logical-turn identity used by clients that correlate responses. */
|
|
922
|
-
logicalTurnId?: string;
|
|
923
|
-
/** User-selected temporary emotion to apply before processing the text. */
|
|
924
|
-
stateOfMind?: string | null;
|
|
925
|
-
/** Latest request-scoped dynamic context to include in this same interaction. */
|
|
926
|
-
dynamicInfo?: DynamicInfo;
|
|
927
|
-
}
|
|
928
|
-
/**
|
|
929
|
-
* The body returned by POST /connect. The embed receives this from a
|
|
930
|
-
* customer-hosted proxy route rather than fetching it directly.
|
|
931
|
-
*/
|
|
932
|
-
/**
|
|
933
|
-
* One ordered character instance requested for a multi-character room.
|
|
934
|
-
*
|
|
935
|
-
* Repeating a `characterId` is legal and intentional: each entry becomes an
|
|
936
|
-
* independent clone with its own membership, session, participant and voice.
|
|
937
|
-
*/
|
|
938
|
-
export interface ConvaiCharacterSpec {
|
|
939
|
-
/**
|
|
940
|
-
* Bare character UUID. Version selectors (`<uuid>-draft`, `<uuid>-1.2`) are
|
|
941
|
-
* accepted by single-character `characterId` but rejected inside a roster --
|
|
942
|
-
* the runtime types roster entries as plain UUIDs.
|
|
943
|
-
*/
|
|
944
|
-
characterId: string;
|
|
945
|
-
/**
|
|
946
|
-
* Resume this instance's prior conversation history. Must be unique across
|
|
947
|
-
* the roster, and must belong to the same publisher, speaker and character.
|
|
948
|
-
*/
|
|
949
|
-
characterSessionId?: string;
|
|
950
|
-
}
|
|
951
|
-
/**
|
|
952
|
-
* Dispatch state of one roster member, as reported by `/connect`.
|
|
953
|
-
*
|
|
954
|
-
* These describe provisioning only and never readiness. A member becomes
|
|
955
|
-
* usable when its own `bot-ready` arrives -- `dispatch_accepted` is not
|
|
956
|
-
* `bot-ready`. The union deliberately has no member that could be mistaken for
|
|
957
|
-
* a ready state; the separate `character-status` event carries those.
|
|
958
|
-
*/
|
|
959
|
-
export type CharacterProvisioningStatus = "dispatch_queued" | "dispatch_accepted" | "dispatch_failed";
|
|
960
|
-
/** One concrete character instance in a roster room. */
|
|
961
|
-
export interface ConvaiCharacterInstance {
|
|
962
|
-
/** Primary key for this instance. Address members by this, never by `characterId`. */
|
|
963
|
-
membershipId: string;
|
|
964
|
-
/** The authored character this instance runs. Not unique across a roster. */
|
|
965
|
-
characterId: string;
|
|
966
|
-
/** Backend session for support correlation. */
|
|
967
|
-
sessionId: string | null;
|
|
968
|
-
/** This instance's conversation/history session. */
|
|
969
|
-
characterSessionId: string | null;
|
|
970
|
-
/** Stable LiveKit identity, always `character:{membershipId}`. */
|
|
971
|
-
participantIdentity: string;
|
|
972
|
-
/** True for `characters[0]`, the initially active member. */
|
|
973
|
-
isInitial: boolean;
|
|
974
|
-
provisioningStatus: CharacterProvisioningStatus;
|
|
975
|
-
/**
|
|
976
|
-
* The character's display name, when the runtime sends one. Saves a separate
|
|
977
|
-
* `character/get` call just to label a member in the UI. Undocumented in the
|
|
978
|
-
* published contract but returned by the live API, so treat it as optional.
|
|
979
|
-
*/
|
|
980
|
-
displayName: string | null;
|
|
981
|
-
/** Character description, when the runtime sends one. */
|
|
982
|
-
description: string | null;
|
|
983
|
-
/** Populated when `provisioningStatus` is `dispatch_failed`. */
|
|
984
|
-
failureCode: string | null;
|
|
985
|
-
/** True once this member's own `bot-ready` has arrived. */
|
|
986
|
-
isReady: boolean;
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
* Server-owned snapshot of a multi-character room. Null for single-character
|
|
990
|
-
* sessions.
|
|
991
|
-
*/
|
|
992
|
-
export interface ConvaiRoomSession {
|
|
993
|
-
/** Durable room identity. Use it to join, and to correlate with support. */
|
|
994
|
-
roomSessionId: string;
|
|
995
|
-
roomName: string | null;
|
|
996
|
-
/** Trace id of the `/connect` that produced this room. Quote it in bug reports. */
|
|
997
|
-
requestTraceId: string | null;
|
|
998
|
-
/** Membership currently authorised to consume user turns. */
|
|
999
|
-
activeMembershipId: string | null;
|
|
1000
|
-
/** Monotonic version of the active target; fences target switches. */
|
|
1001
|
-
routeEpoch: number;
|
|
1002
|
-
/** Monotonic version of roster composition; fences add/remove. */
|
|
1003
|
-
rosterEpoch: number;
|
|
1004
|
-
/** True when at least one member already failed dispatch. */
|
|
1005
|
-
partialDispatch: boolean;
|
|
1006
|
-
characters: ConvaiCharacterInstance[];
|
|
1007
|
-
}
|
|
1008
|
-
/** Result of a successful target switch. */
|
|
1009
|
-
export interface ActiveCharacterChange {
|
|
1010
|
-
/** Membership that was active before, or null. */
|
|
1011
|
-
previous: string | null;
|
|
1012
|
-
/** Membership now authorised to consume user turns, or null when all gates are closed. */
|
|
1013
|
-
active: string | null;
|
|
1014
|
-
routeEpoch: number;
|
|
1015
|
-
}
|
|
1016
|
-
/** Result of a successful roster mutation. */
|
|
1017
|
-
export interface CharacterRosterChange {
|
|
1018
|
-
added: ConvaiCharacterInstance[];
|
|
1019
|
-
removed: ConvaiCharacterInstance[];
|
|
1020
|
-
/** The roster after the change. */
|
|
1021
|
-
characters: ConvaiCharacterInstance[];
|
|
1022
|
-
rosterEpoch: number;
|
|
1023
|
-
routeEpoch: number;
|
|
1024
|
-
activeMembershipId: string | null;
|
|
1025
|
-
}
|
|
1026
|
-
/** Options for adding and removing roster members on a live room. */
|
|
1027
|
-
export interface UpdateCharacterRosterOptions {
|
|
1028
|
-
/** Members to add. Repeating an existing characterId creates another clone. */
|
|
1029
|
-
add?: ConvaiCharacterSpec[];
|
|
1030
|
-
/** Membership ids to remove. Never characterIds -- clones make those ambiguous. */
|
|
1031
|
-
remove?: string[];
|
|
1032
|
-
/**
|
|
1033
|
-
* Member to take over routing when the active one is removed. Must be a ready
|
|
1034
|
-
* member that survives the change. Chosen automatically when omitted.
|
|
1035
|
-
*/
|
|
1036
|
-
replacementTarget?: string;
|
|
1037
|
-
}
|
|
1038
|
-
/** Options for joining an existing multi-character room. */
|
|
1039
|
-
export interface JoinRoomOptions {
|
|
1040
|
-
/** Preferred locator. Exactly one of this or `sharedSessionKey`. */
|
|
1041
|
-
roomSessionId?: string;
|
|
1042
|
-
/** Publisher-scoped alternative locator. */
|
|
1043
|
-
sharedSessionKey?: string;
|
|
1044
|
-
/** Required and nonblank; identifies the joining human. */
|
|
1045
|
-
endUserId: string;
|
|
1046
|
-
endUserMetadata?: Record<string, unknown>;
|
|
1047
|
-
/** Idempotency key for retrying this join. */
|
|
1048
|
-
connectAttemptId?: string;
|
|
1049
|
-
}
|
|
1050
|
-
/**
|
|
1051
|
-
* Lifecycle transition of one roster member, after `/connect` has returned.
|
|
1052
|
-
*
|
|
1053
|
-
* `bot-ready` remains the readiness authority: do not enable interaction from a
|
|
1054
|
-
* `ready` status alone. This event's real job is reporting a member that was
|
|
1055
|
-
* added at runtime, or one whose dispatch failed in the background.
|
|
1056
|
-
*/
|
|
1057
|
-
export interface CharacterStatusEvent {
|
|
1058
|
-
status: "starting" | "ready" | "failed";
|
|
1059
|
-
membershipId: string;
|
|
1060
|
-
characterId: string;
|
|
1061
|
-
characterSessionId: string | null;
|
|
1062
|
-
participantIdentity: string;
|
|
1063
|
-
roomSessionId: string | null;
|
|
1064
|
-
rosterEpoch: number | null;
|
|
1065
|
-
/** Set when `status` is `failed`, e.g. `ACTOR_ASSIGNMENT_FAILED`. */
|
|
1066
|
-
failureCode: string | null;
|
|
1067
|
-
}
|
|
1068
|
-
/**
|
|
1069
|
-
* An audio track bound to the character instance that publishes it.
|
|
1070
|
-
*
|
|
1071
|
-
* In a multi-character room `membershipId` is always set -- a track that
|
|
1072
|
-
* cannot be attributed to a roster member is dropped, never surfaced against
|
|
1073
|
-
* the active character. In a single-character room it is null.
|
|
1074
|
-
*/
|
|
1075
|
-
export interface CharacterAudioTrackEvent {
|
|
1076
|
-
membershipId: string | null;
|
|
1077
|
-
characterId: string | null;
|
|
1078
|
-
/** LiveKit participant identity; `character:{membershipId}` in a roster. */
|
|
1079
|
-
participantIdentity: string;
|
|
1080
|
-
track: MediaStreamTrack;
|
|
1081
|
-
}
|
|
1082
|
-
/**
|
|
1083
|
-
* A finalized turn's usage/cost breakdown, streamed by the server after
|
|
1084
|
-
* {@link IConvaiClient.toggleUsageUpdates} enables it. The shape is
|
|
1085
|
-
* server-defined and informational; treat unknown fields as opaque.
|
|
1086
|
-
*/
|
|
1087
|
-
export type UsageUpdate = Record<string, unknown>;
|
|
1088
|
-
/**
|
|
1089
|
-
* Every event the client emits, with its payload.
|
|
1090
|
-
*
|
|
1091
|
-
* `on()` is typed against this map, so a listener for a known event gets its
|
|
1092
|
-
* payload inferred instead of `any`. The plain-string signature is kept so
|
|
1093
|
-
* existing callers and dynamic event names keep compiling, which also means a
|
|
1094
|
-
* misspelt literal is not a compile error. Payloads the server defines as
|
|
1095
|
-
* opaque blobs (blendshape frames, metrics, usage) are left as records rather
|
|
1096
|
-
* than guessed at.
|
|
1097
|
-
*/
|
|
1098
|
-
export interface ConvaiEventMap {
|
|
1099
|
-
connect: [];
|
|
1100
|
-
connected: [];
|
|
1101
|
-
disconnect: [reason: DisconnectReason | null];
|
|
1102
|
-
disconnected: [];
|
|
1103
|
-
error: [error: unknown];
|
|
1104
|
-
stateChange: [state: ConvaiClientState];
|
|
1105
|
-
botReady: [];
|
|
1106
|
-
characterSessionId: [characterSessionId: string];
|
|
1107
|
-
interactionCreated: [data: InteractionCreated];
|
|
1108
|
-
message: [message: ChatMessage];
|
|
1109
|
-
messagesChange: [messages: ChatMessage[]];
|
|
1110
|
-
userTranscriptionChange: [transcription: string];
|
|
1111
|
-
speakingChange: [isSpeaking: boolean];
|
|
1112
|
-
listeningChange: [isListening: boolean];
|
|
1113
|
-
botRespondingChange: [isResponding: boolean];
|
|
1114
|
-
turnEnd: [turn: {
|
|
1115
|
-
sessionId: number;
|
|
1116
|
-
duration: number;
|
|
1117
|
-
timestamp: number;
|
|
1118
|
-
}];
|
|
1119
|
-
conversationStart: [
|
|
1120
|
-
start: {
|
|
1121
|
-
sessionId: number;
|
|
1122
|
-
userMessage: string;
|
|
1123
|
-
timestamp: number;
|
|
1124
|
-
}
|
|
1125
|
-
];
|
|
1126
|
-
emotionChange: [emotion: {
|
|
1127
|
-
emotion: string;
|
|
1128
|
-
scale?: number;
|
|
1129
|
-
} | null];
|
|
1130
|
-
actionResponse: [data: ActionResponseEvent];
|
|
1131
|
-
serverResponse: [response: ServerResponse];
|
|
1132
|
-
botOutput: [data: {
|
|
1133
|
-
text: string;
|
|
1134
|
-
spoken: boolean;
|
|
1135
|
-
aggregatedBy: string;
|
|
1136
|
-
}];
|
|
1137
|
-
botTtsText: [data: {
|
|
1138
|
-
text: string;
|
|
1139
|
-
}];
|
|
1140
|
-
botTtsStarted: [];
|
|
1141
|
-
botTtsStopped: [];
|
|
1142
|
-
botTurnCompleted: [data: unknown];
|
|
1143
|
-
userMuteStarted: [];
|
|
1144
|
-
userMuteStopped: [];
|
|
1145
|
-
idleWarning: [data: {
|
|
1146
|
-
remainingSeconds: number | null;
|
|
1147
|
-
}];
|
|
1148
|
-
llmNoResponse: [];
|
|
1149
|
-
metrics: [data: Record<string, unknown>];
|
|
1150
|
-
usageUpdate: [data: UsageUpdate];
|
|
1151
|
-
blendshapes: [data: Record<string, unknown>];
|
|
1152
|
-
blendshapeCancel: [data: Record<string, unknown>];
|
|
1153
|
-
blendshapeStatsReceived: [stats: Record<string, unknown>];
|
|
1154
|
-
botAudioTrack: [track: MediaStreamTrack];
|
|
1155
|
-
audioStateChange: [enabled: boolean];
|
|
1156
|
-
videoStateChange: [enabled: boolean];
|
|
1157
|
-
screenShareStateChange: [active: boolean];
|
|
1158
|
-
characterReady: [instance: ConvaiCharacterInstance | undefined];
|
|
1159
|
-
characterStatus: [status: CharacterStatusEvent];
|
|
1160
|
-
activeCharacterChange: [change: ActiveCharacterChange];
|
|
1161
|
-
rosterChange: [change: CharacterRosterChange];
|
|
1162
|
-
characterAudioTrack: [event: CharacterAudioTrackEvent];
|
|
1163
|
-
actionResultAck: [ack: ActionResultAck];
|
|
1164
|
-
modelOutputProtocolError: [data: ModelOutputProtocolError];
|
|
1165
|
-
modelOutput: [data: ModelOutputMessage];
|
|
1166
|
-
botLlmTextRaw: [data: BotLlmTextRawEvent];
|
|
1167
|
-
}
|
|
1168
|
-
/**
|
|
1169
|
-
* Preserve typed callbacks for known events while permitting callers that
|
|
1170
|
-
* intentionally enumerate runtime event names. A string literal outside the
|
|
1171
|
-
* map resolves to `never`, so misspellings still fail at compile time.
|
|
1172
|
-
*/
|
|
1173
|
-
export type ConvaiEventCallback<E extends string> = E extends keyof ConvaiEventMap ? (...args: ConvaiEventMap[E]) => void : string extends E ? (...args: any[]) => void : never;
|
|
1174
|
-
/** A transcript line inserted locally by {@link IConvaiClient.appendMessage}. */
|
|
1175
|
-
export interface AppendMessageOptions {
|
|
1176
|
-
sender: "user" | "bot";
|
|
1177
|
-
content: string;
|
|
1178
|
-
/** Attribute the line to a roster member, in a multi-character room. */
|
|
1179
|
-
membershipId?: string;
|
|
1180
|
-
characterId?: string;
|
|
1181
|
-
}
|
|
1182
|
-
/** Bounded retry for a roster room that is still provisioning. */
|
|
1183
|
-
export interface RosterProvisioningRetry {
|
|
1184
|
-
/** Total attempts including the first. Default 4. */
|
|
1185
|
-
attempts?: number;
|
|
1186
|
-
/** Delay before the second attempt; doubles with jitter. Default 500. */
|
|
1187
|
-
initialDelayMs?: number;
|
|
1188
|
-
}
|
|
1189
|
-
export interface ConnectionData {
|
|
1190
|
-
/** LiveKit room URL, or the WebSocket URL when the transport is websocket. */
|
|
1191
|
-
room_url: string;
|
|
1192
|
-
/** LiveKit access token. Absent on the WebSocket transport. */
|
|
1193
|
-
token?: string;
|
|
1194
|
-
character_session_id?: string;
|
|
1195
|
-
end_user_id?: string;
|
|
1196
|
-
end_user_metadata?: Record<string, unknown>;
|
|
1197
|
-
}
|
|
1198
725
|
/** Options for connecting to a published text-chat session. */
|
|
1199
726
|
export interface PublishedChatConnectOptions {
|
|
1200
727
|
/** Core API origin (defaults to the production realtime API). */
|
|
1201
728
|
url?: string;
|
|
1202
|
-
/**
|
|
1203
|
-
* WebRTC ICE transport policy (defaults to "relay" for Convai-hosted
|
|
1204
|
-
* LiveKit). Set "all" for a deployment that has no TURN server.
|
|
1205
|
-
*/
|
|
1206
|
-
iceTransportPolicy?: RTCIceTransportPolicy;
|
|
1207
729
|
/** Cancels the grant exchange and tears down an in-progress connection. */
|
|
1208
730
|
signal?: AbortSignal;
|
|
1209
731
|
/**
|
|
@@ -1220,12 +742,7 @@ export interface ChatMessage {
|
|
|
1220
742
|
/** Unique identifier for the message */
|
|
1221
743
|
id: string;
|
|
1222
744
|
/**
|
|
1223
|
-
*
|
|
1224
|
-
* this bot row. Absent for legacy sessions and older v2 Core versions.
|
|
1225
|
-
*/
|
|
1226
|
-
outputId?: string;
|
|
1227
|
-
/**
|
|
1228
|
-
* Immutable logical turn id for correlated v2 user speech and bot text.
|
|
745
|
+
* Client-owned logical turn id for a correlated v2 voice transcription.
|
|
1229
746
|
* Absent for legacy sessions and uncorrelated messages.
|
|
1230
747
|
*/
|
|
1231
748
|
logicalTurnId?: string;
|
|
@@ -1246,14 +763,6 @@ export interface ChatMessage {
|
|
|
1246
763
|
* - `llm-no-response`: LLM deliberately did not respond (abstain); `content` is always `""`
|
|
1247
764
|
*/
|
|
1248
765
|
type: 'user' | 'convai' | 'emotion' | 'behavior-tree' | 'action' | 'user-transcription' | 'bot-llm-text' | 'bot-output' | 'bot-emotion' | 'user-llm-text' | 'interrupt-bot' | 'idle-warning' | 'llm-no-response';
|
|
1249
|
-
/**
|
|
1250
|
-
* Which character instance produced this message, in a multi-character room.
|
|
1251
|
-
* Undefined in single-character sessions. Attribute UI to this, never to
|
|
1252
|
-
* `characterId` -- two clones of one character share a `characterId`.
|
|
1253
|
-
*/
|
|
1254
|
-
membershipId?: string;
|
|
1255
|
-
/** The authored character behind {@link membershipId}. Not unique across a roster. */
|
|
1256
|
-
characterId?: string;
|
|
1257
766
|
/** The text content of the message */
|
|
1258
767
|
content: string;
|
|
1259
768
|
/** ISO timestamp string of when the message was created */
|
|
@@ -1359,16 +868,6 @@ export interface ConvaiClientState {
|
|
|
1359
868
|
* @see DisconnectReason
|
|
1360
869
|
*/
|
|
1361
870
|
disconnectReason: DisconnectReason | null;
|
|
1362
|
-
/**
|
|
1363
|
-
* Character instances in a multi-character room, in roster order. Empty for
|
|
1364
|
-
* single-character sessions, so a check on `length` distinguishes the two.
|
|
1365
|
-
*/
|
|
1366
|
-
characters: ConvaiCharacterInstance[];
|
|
1367
|
-
/**
|
|
1368
|
-
* Membership currently receiving user turns, or null. Only this member
|
|
1369
|
-
* consumes interaction input.
|
|
1370
|
-
*/
|
|
1371
|
-
activeMembershipId: string | null;
|
|
1372
871
|
}
|
|
1373
872
|
/**
|
|
1374
873
|
* Audio control interface for managing microphone
|
|
@@ -1386,10 +885,7 @@ export interface AudioControls {
|
|
|
1386
885
|
getAudioDevices: () => Promise<MediaDeviceInfo[]>;
|
|
1387
886
|
startAudioLevelMonitoring: () => void;
|
|
1388
887
|
stopAudioLevelMonitoring: () => void;
|
|
1389
|
-
on:
|
|
1390
|
-
<E extends keyof ConvaiEventMap>(event: E, callback: (...args: ConvaiEventMap[E]) => void): () => void;
|
|
1391
|
-
(event: string, callback: (...args: any[]) => void): () => void;
|
|
1392
|
-
};
|
|
888
|
+
on: (event: string, callback: (...args: any[]) => void) => () => void;
|
|
1393
889
|
off: (event: string, callback: (...args: any[]) => void) => void;
|
|
1394
890
|
}
|
|
1395
891
|
/**
|
|
@@ -1412,10 +908,7 @@ export interface VideoControls {
|
|
|
1412
908
|
publishCanvas: (canvas: HTMLCanvasElement, options?: PublishCanvasOptions) => Promise<VisionSourceHandle>;
|
|
1413
909
|
publishVideoTrack: (track: MediaStreamTrack, options?: PublishVideoTrackOptions) => Promise<VisionSourceHandle>;
|
|
1414
910
|
unpublishVisionSource: (source?: VisionSourceHandle | MediaStreamTrack) => Promise<void>;
|
|
1415
|
-
on:
|
|
1416
|
-
<E extends keyof ConvaiEventMap>(event: E, callback: (...args: ConvaiEventMap[E]) => void): () => void;
|
|
1417
|
-
(event: string, callback: (...args: any[]) => void): () => void;
|
|
1418
|
-
};
|
|
911
|
+
on: (event: string, callback: (...args: any[]) => void) => () => void;
|
|
1419
912
|
off: (event: string, callback: (...args: any[]) => void) => void;
|
|
1420
913
|
}
|
|
1421
914
|
/**
|
|
@@ -1429,10 +922,7 @@ export interface ScreenShareControls {
|
|
|
1429
922
|
toggleScreenShare: () => Promise<void>;
|
|
1430
923
|
enableScreenShareWithAudio: () => Promise<void>;
|
|
1431
924
|
getScreenShareTracks: () => Promise<any[]>;
|
|
1432
|
-
on:
|
|
1433
|
-
<E extends keyof ConvaiEventMap>(event: E, callback: (...args: ConvaiEventMap[E]) => void): () => void;
|
|
1434
|
-
(event: string, callback: (...args: any[]) => void): () => void;
|
|
1435
|
-
};
|
|
925
|
+
on: (event: string, callback: (...args: any[]) => void) => () => void;
|
|
1436
926
|
off: (event: string, callback: (...args: any[]) => void) => void;
|
|
1437
927
|
}
|
|
1438
928
|
/**
|
|
@@ -1466,202 +956,6 @@ export interface ScreenShareControls {
|
|
|
1466
956
|
* });
|
|
1467
957
|
* ```
|
|
1468
958
|
*/
|
|
1469
|
-
/**
|
|
1470
|
-
* Character Versioning API Types
|
|
1471
|
-
*
|
|
1472
|
-
* Shapes returned by the Character REST platform's `/character/versions/*`
|
|
1473
|
-
* routes. Field names are kept as the API sends them.
|
|
1474
|
-
*/
|
|
1475
|
-
/** One immutable, tagged character version. */
|
|
1476
|
-
export interface CharacterVersionInfo {
|
|
1477
|
-
/** Semantic tag, e.g. `"1.2"` or `"1.2.3"` */
|
|
1478
|
-
version: string;
|
|
1479
|
-
/** Immutable revision backing this tag */
|
|
1480
|
-
revision_id: string;
|
|
1481
|
-
/** Whether `latest` currently points at this tag */
|
|
1482
|
-
is_latest: boolean;
|
|
1483
|
-
created_by: string;
|
|
1484
|
-
/** ISO-8601 timestamp */
|
|
1485
|
-
created_at: string;
|
|
1486
|
-
is_deprecated: boolean;
|
|
1487
|
-
/** ISO-8601 timestamp, or null when not deprecated */
|
|
1488
|
-
deprecated_at: string | null;
|
|
1489
|
-
}
|
|
1490
|
-
/** Response from `CharacterVersionManager.list()`. */
|
|
1491
|
-
export interface CharacterVersionList {
|
|
1492
|
-
/** Released versions, newest first as returned by the API */
|
|
1493
|
-
items: CharacterVersionInfo[];
|
|
1494
|
-
/** Revision `latest` resolves to, or null before any release */
|
|
1495
|
-
latest_revision_id: string | null;
|
|
1496
|
-
/** Tag `latest` points at, or null when latest is an unpromoted revision */
|
|
1497
|
-
latest_version: string | null;
|
|
1498
|
-
/** Editable draft revision, or null for a legacy character that has not been bootstrapped */
|
|
1499
|
-
draft_revision_id: string | null;
|
|
1500
|
-
/** Released revision the draft was branched from */
|
|
1501
|
-
draft_parent_revision_id: string | null;
|
|
1502
|
-
draft_parent_version: string | null;
|
|
1503
|
-
/** True when the draft differs from its released parent */
|
|
1504
|
-
has_unpublished_changes: boolean;
|
|
1505
|
-
/** True when `latest` points at a tagged version rather than a loose revision */
|
|
1506
|
-
latest_is_promoted: boolean;
|
|
1507
|
-
}
|
|
1508
|
-
/** Voice details attached to a resolved version when `includeRuntimeSettings` is set. */
|
|
1509
|
-
export interface CharacterRuntimeVoice {
|
|
1510
|
-
voice_value: string;
|
|
1511
|
-
voice_name: string;
|
|
1512
|
-
provider: string;
|
|
1513
|
-
lang_codes: string[] | null;
|
|
1514
|
-
accessibility: string | null;
|
|
1515
|
-
gender: string | null;
|
|
1516
|
-
voice_data: Record<string, unknown> | null;
|
|
1517
|
-
}
|
|
1518
|
-
/** Live (unversioned) runtime settings returned alongside a resolved version. */
|
|
1519
|
-
export interface CharacterRuntimeSettings {
|
|
1520
|
-
schema_version: 1;
|
|
1521
|
-
stt_provider: string | null;
|
|
1522
|
-
voice: CharacterRuntimeVoice | null;
|
|
1523
|
-
}
|
|
1524
|
-
/** Response from `CharacterVersionManager.resolve()`. */
|
|
1525
|
-
export interface ResolvedCharacterVersion {
|
|
1526
|
-
character_id: string;
|
|
1527
|
-
/** The reference that was resolved, e.g. `<uuid>-draft` */
|
|
1528
|
-
requested_reference: string;
|
|
1529
|
-
/** Immutable revision, or null for a legacy character with no revision yet */
|
|
1530
|
-
revision_id: string | null;
|
|
1531
|
-
/** Tag when the reference resolved to a tagged version */
|
|
1532
|
-
version: string | null;
|
|
1533
|
-
is_latest: boolean;
|
|
1534
|
-
/** The full character configuration snapshot */
|
|
1535
|
-
payload: Record<string, unknown>;
|
|
1536
|
-
runtime_settings?: CharacterRuntimeSettings | null;
|
|
1537
|
-
}
|
|
1538
|
-
/** Options for `CharacterVersionManager.resolve()`. */
|
|
1539
|
-
export interface ResolveCharacterVersionOptions {
|
|
1540
|
-
/**
|
|
1541
|
-
* Also return the live voice and STT settings (default: false).
|
|
1542
|
-
* Only a trusted service identity may ask for these; an API key is
|
|
1543
|
-
* answered with `403 Runtime settings require a trusted service identity`.
|
|
1544
|
-
*/
|
|
1545
|
-
includeRuntimeSettings?: boolean;
|
|
1546
|
-
}
|
|
1547
|
-
/** Response from `CharacterVersionManager.bootstrap()`. */
|
|
1548
|
-
export interface CharacterDraftBootstrapResult {
|
|
1549
|
-
character_id: string;
|
|
1550
|
-
draft_revision_id: string;
|
|
1551
|
-
/** False when the character already had a draft */
|
|
1552
|
-
created: boolean;
|
|
1553
|
-
}
|
|
1554
|
-
/** One side of a version comparison. */
|
|
1555
|
-
export interface CharacterVersionDiffSide {
|
|
1556
|
-
/** The selector that was compared: `draft`, `latest`, or a tag */
|
|
1557
|
-
selector: string;
|
|
1558
|
-
revision_id: string | null;
|
|
1559
|
-
version: string | null;
|
|
1560
|
-
is_latest: boolean;
|
|
1561
|
-
}
|
|
1562
|
-
/** One field-level change in a raw diff. */
|
|
1563
|
-
export interface CharacterVersionRawChange {
|
|
1564
|
-
/** JSON path into the character payload */
|
|
1565
|
-
path: string;
|
|
1566
|
-
change_type: "added" | "removed" | "modified";
|
|
1567
|
-
before?: unknown;
|
|
1568
|
-
after?: unknown;
|
|
1569
|
-
}
|
|
1570
|
-
/** One human-labelled change in a semantic diff; revertable one at a time. */
|
|
1571
|
-
export interface CharacterVersionSemanticChange {
|
|
1572
|
-
change_id: string;
|
|
1573
|
-
semantic_key: string;
|
|
1574
|
-
label: string;
|
|
1575
|
-
category: string;
|
|
1576
|
-
change_type: "added" | "removed" | "modified";
|
|
1577
|
-
before?: unknown;
|
|
1578
|
-
after?: unknown;
|
|
1579
|
-
source_paths: string[];
|
|
1580
|
-
can_revert: boolean;
|
|
1581
|
-
revert_disabled_reason?: string | null;
|
|
1582
|
-
integrity_warning?: string | null;
|
|
1583
|
-
}
|
|
1584
|
-
/** Response from `CharacterVersionManager.diff()` with `view: "raw"` (the default). */
|
|
1585
|
-
export interface CharacterVersionRawDiff {
|
|
1586
|
-
view?: "raw";
|
|
1587
|
-
character_id: string;
|
|
1588
|
-
from: CharacterVersionDiffSide;
|
|
1589
|
-
to: CharacterVersionDiffSide;
|
|
1590
|
-
change_count: number;
|
|
1591
|
-
changes: CharacterVersionRawChange[];
|
|
1592
|
-
}
|
|
1593
|
-
/** Response from `CharacterVersionManager.diff()` with `view: "semantic"`. */
|
|
1594
|
-
export interface CharacterVersionSemanticDiff {
|
|
1595
|
-
view: "semantic";
|
|
1596
|
-
semantic_schema_version: number;
|
|
1597
|
-
character_id: string;
|
|
1598
|
-
from: CharacterVersionDiffSide;
|
|
1599
|
-
to: CharacterVersionDiffSide;
|
|
1600
|
-
draft_revision_id: string | null;
|
|
1601
|
-
change_count: number;
|
|
1602
|
-
changes: CharacterVersionSemanticChange[];
|
|
1603
|
-
}
|
|
1604
|
-
export type CharacterVersionDiff = CharacterVersionRawDiff | CharacterVersionSemanticDiff;
|
|
1605
|
-
/** Options for `CharacterVersionManager.diff()`. */
|
|
1606
|
-
export interface CharacterVersionDiffOptions {
|
|
1607
|
-
/** `"raw"` lists JSON paths; `"semantic"` groups them into labelled, revertable changes. Default `"raw"`. */
|
|
1608
|
-
view?: "raw" | "semantic";
|
|
1609
|
-
}
|
|
1610
|
-
/** Options for `CharacterVersionManager.create()`. */
|
|
1611
|
-
export interface CreateCharacterVersionOptions {
|
|
1612
|
-
/** Point `latest` at the new version immediately (default: false) */
|
|
1613
|
-
makeLatest?: boolean;
|
|
1614
|
-
}
|
|
1615
|
-
/** Options for `CharacterVersionManager.revert()`. */
|
|
1616
|
-
export interface RevertCharacterChangeOptions {
|
|
1617
|
-
/** Version the draft is being compared against — the change is reverted to this side */
|
|
1618
|
-
from: string;
|
|
1619
|
-
/** `change_id` from a semantic diff */
|
|
1620
|
-
changeId: string;
|
|
1621
|
-
/** Draft revision the caller last saw; the request fails if the draft moved */
|
|
1622
|
-
expectedDraftRevisionId: string;
|
|
1623
|
-
}
|
|
1624
|
-
/** Response from `CharacterVersionManager.revert()`. */
|
|
1625
|
-
export interface RevertCharacterChangeResult {
|
|
1626
|
-
character_id: string;
|
|
1627
|
-
reverted_change_id: string;
|
|
1628
|
-
previous_draft_revision_id: string;
|
|
1629
|
-
/** The new draft revision after the revert */
|
|
1630
|
-
draft_revision_id: string;
|
|
1631
|
-
/** Semantic diff between `from` and the new draft */
|
|
1632
|
-
diff: CharacterVersionSemanticDiff;
|
|
1633
|
-
}
|
|
1634
|
-
/** Response from `CharacterVersionManager.discardDraft()`. */
|
|
1635
|
-
export interface DiscardCharacterDraftResult {
|
|
1636
|
-
character_id: string;
|
|
1637
|
-
previous_draft_revision_id: string;
|
|
1638
|
-
/** The fresh draft, restored from its released parent */
|
|
1639
|
-
draft_revision_id: string;
|
|
1640
|
-
draft_parent_revision_id: string;
|
|
1641
|
-
draft_parent_version: string;
|
|
1642
|
-
}
|
|
1643
|
-
/** Response from `CharacterVersionManager.fork()`. */
|
|
1644
|
-
export interface ForkCharacterVersionResult {
|
|
1645
|
-
character_id: string;
|
|
1646
|
-
/** Tag the draft was replaced with */
|
|
1647
|
-
source_version: string;
|
|
1648
|
-
draft_revision_id: string;
|
|
1649
|
-
latest_revision_id: string | null;
|
|
1650
|
-
has_unpublished_changes: boolean;
|
|
1651
|
-
}
|
|
1652
|
-
/** Options for constructing a `CharacterVersionManager` directly. */
|
|
1653
|
-
export interface CharacterVersionManagerOptions {
|
|
1654
|
-
/** Bare character UUID (a suffixed reference is accepted and stripped) */
|
|
1655
|
-
characterId: string;
|
|
1656
|
-
/** Convai API key, sent as `CONVAI-API-KEY` */
|
|
1657
|
-
apiKey?: string;
|
|
1658
|
-
/** Convai personal access token, sent as `Authorization: Bearer` (alternative to `apiKey`) */
|
|
1659
|
-
personalAccessToken?: string;
|
|
1660
|
-
/** Character REST platform origin (default: `https://api2.convai.com`) */
|
|
1661
|
-
baseUrl?: string;
|
|
1662
|
-
/** Workspace scope, forwarded as `workspace_id` on every call */
|
|
1663
|
-
workspaceId?: string;
|
|
1664
|
-
}
|
|
1665
959
|
/**
|
|
1666
960
|
* Memory API Types
|
|
1667
961
|
* Types for Convai's long-term memory management APIs
|
|
@@ -1816,12 +1110,8 @@ export interface IConvaiClient {
|
|
|
1816
1110
|
readonly apiKey?: string | null;
|
|
1817
1111
|
/** Auth token used for the current connection, if authToken was used (null otherwise) */
|
|
1818
1112
|
readonly authToken?: string | null;
|
|
1819
|
-
/**
|
|
1113
|
+
/** Character ID used for the current connection (null if not connected) */
|
|
1820
1114
|
readonly characterId: string | null;
|
|
1821
|
-
/** Version selector in effect for the current connection (`draft`, `latest`, or a tag); null when unversioned or not connected */
|
|
1822
|
-
readonly characterVersion: CharacterVersionSelector | null;
|
|
1823
|
-
/** The reference sent to the runtime: `characterId` joined with `characterVersion` (null if not connected) */
|
|
1824
|
-
readonly characterReference: string | null;
|
|
1825
1115
|
/** Internal LiveKit Room instance (for advanced usage) */
|
|
1826
1116
|
readonly room: Room;
|
|
1827
1117
|
/** Array of all chat messages in the current conversation */
|
|
@@ -1857,150 +1147,22 @@ export interface IConvaiClient {
|
|
|
1857
1147
|
* ```
|
|
1858
1148
|
*/
|
|
1859
1149
|
readonly memoryManager: import('./MemoryManager.js').MemoryManager | null;
|
|
1860
|
-
/**
|
|
1861
|
-
* Character version manager for the configured character.
|
|
1862
|
-
*
|
|
1863
|
-
* Lists, compares, releases, promotes and discards character versions
|
|
1864
|
-
* through the Character REST platform. Available as soon as the client has
|
|
1865
|
-
* an `apiKey` and `characterId` — before connecting, so an app can pick a
|
|
1866
|
-
* version and then connect to it. Null without an API key.
|
|
1867
|
-
*
|
|
1868
|
-
* @example
|
|
1869
|
-
* ```typescript
|
|
1870
|
-
* const versions = client.characterVersions;
|
|
1871
|
-
* if (versions) {
|
|
1872
|
-
* const { items, draft_revision_id } = await versions.list();
|
|
1873
|
-
* await versions.create('1.0', { makeLatest: true });
|
|
1874
|
-
* }
|
|
1875
|
-
* ```
|
|
1876
|
-
*/
|
|
1877
|
-
readonly characterVersions: import('./CharacterVersionManager.js').CharacterVersionManager | null;
|
|
1878
1150
|
/**
|
|
1879
1151
|
* Connect to a Convai character.
|
|
1880
1152
|
*/
|
|
1881
1153
|
connect: (config?: ConvaiConfig) => Promise<void>;
|
|
1882
|
-
/**
|
|
1883
|
-
* Connect to a published text chat with a short-lived, single-use grant.
|
|
1884
|
-
*
|
|
1885
|
-
* Obtain the grant from the public publication endpoint immediately before
|
|
1886
|
-
* connecting. This path needs no API key or character ID in the browser and
|
|
1887
|
-
* creates a data-only, text-chat session. Request a fresh grant for every
|
|
1888
|
-
* later session or reconnect attempt.
|
|
1889
|
-
*
|
|
1890
|
-
* @example
|
|
1891
|
-
* ```ts
|
|
1892
|
-
* import { ConvaiClient } from '@convai/web-sdk/core'
|
|
1893
|
-
* import { requestPublishedChatGrant } from '@convai/web-sdk/embed'
|
|
1894
|
-
*
|
|
1895
|
-
* const client = new ConvaiClient()
|
|
1896
|
-
* const launchToken = await requestPublishedChatGrant(
|
|
1897
|
-
* 'https://character-api.example.com/chat-publications/PUBLICATION_ID/launch-grants',
|
|
1898
|
-
* )
|
|
1899
|
-
* await client.connectWithPublicationGrant(launchToken, {
|
|
1900
|
-
* url: 'https://realtime.example.com',
|
|
1901
|
-
* })
|
|
1902
|
-
* ```
|
|
1903
|
-
*/
|
|
1154
|
+
/** Connect to a published text chat with a short-lived, single-use grant. */
|
|
1904
1155
|
connectWithPublicationGrant?: (launchToken: string, options?: PublishedChatConnectOptions) => Promise<void>;
|
|
1905
|
-
/**
|
|
1906
|
-
* Complete a connection from an already-fetched /connect response body.
|
|
1907
|
-
*
|
|
1908
|
-
* `connect()` fetches /connect and then calls this internally. Call it
|
|
1909
|
-
* directly when the response was obtained elsewhere — a server-side session
|
|
1910
|
-
* manager, or the embed's connect-proxy flow, where the API key must never
|
|
1911
|
-
* reach the browser.
|
|
1912
|
-
*
|
|
1913
|
-
* @example
|
|
1914
|
-
* // Server (customer's backend): holds the API key, calls Convai's
|
|
1915
|
-
* // /connect, and relays the response body verbatim.
|
|
1916
|
-
* // Browser: never sees the API key, only the relayed response.
|
|
1917
|
-
* const data = await fetch('/api/convai-connect', {
|
|
1918
|
-
* method: 'POST',
|
|
1919
|
-
* headers: { 'Content-Type': 'application/json' },
|
|
1920
|
-
* body: JSON.stringify({ characterId: 'your-character-id' }),
|
|
1921
|
-
* }).then(r => r.json())
|
|
1922
|
-
* await client.connectWithConnectionData(data)
|
|
1923
|
-
*/
|
|
1924
|
-
connectWithConnectionData: (data: ConnectionData, config?: ConvaiConfig) => Promise<void>;
|
|
1925
|
-
/**
|
|
1926
|
-
* Join an existing multi-character room by `roomSessionId` or
|
|
1927
|
-
* `sharedSessionKey`. The roster is server-owned, so no character topology is
|
|
1928
|
-
* sent; joining never spawns, removes or repairs a character.
|
|
1929
|
-
*
|
|
1930
|
-
* @example
|
|
1931
|
-
* ```ts
|
|
1932
|
-
* await client.joinRoom({ roomSessionId: 'the-room-id', endUserId: 'player-99' })
|
|
1933
|
-
* ```
|
|
1934
|
-
*/
|
|
1935
|
-
joinRoom: (options: JoinRoomOptions) => Promise<void>;
|
|
1936
|
-
/** Server-owned snapshot of a multi-character room (null when single-character) */
|
|
1937
|
-
readonly roomSession: ConvaiRoomSession | null;
|
|
1938
|
-
/** Character instances in roster order; empty for a single-character session */
|
|
1939
|
-
readonly characters: ConvaiCharacterInstance[];
|
|
1940
|
-
/** Membership currently receiving user turns, or null */
|
|
1941
|
-
readonly activeMembershipId: string | null;
|
|
1942
|
-
/**
|
|
1943
|
-
* Insert a message into the transcript locally, without sending it to the
|
|
1944
|
-
* character. Use it for client-side lines -- a greeting, a system notice,
|
|
1945
|
-
* replayed history -- that must appear in the chat but must never reach
|
|
1946
|
-
* the LLM or be billed as a turn. Not `sendUserTextMessage`: nothing is
|
|
1947
|
-
* transmitted. Returns the message that was added.
|
|
1948
|
-
*
|
|
1949
|
-
* @example
|
|
1950
|
-
* ```ts
|
|
1951
|
-
* client.appendMessage({ sender: 'bot', content: 'Welcome back!' })
|
|
1952
|
-
* ```
|
|
1953
|
-
*/
|
|
1954
|
-
appendMessage: (message: AppendMessageOptions) => ChatMessage;
|
|
1955
|
-
/**
|
|
1956
|
-
* Opt in or out of `usageUpdate` events -- the server's per-turn usage and
|
|
1957
|
-
* cost breakdown. Informational only; billing is unaffected.
|
|
1958
|
-
*
|
|
1959
|
-
* @example
|
|
1960
|
-
* ```ts
|
|
1961
|
-
* client.toggleUsageUpdates(true)
|
|
1962
|
-
* client.on('usageUpdate', (u) => console.log(u))
|
|
1963
|
-
* ```
|
|
1964
|
-
*/
|
|
1965
|
-
toggleUsageUpdates: (enabled: boolean) => void;
|
|
1966
|
-
/**
|
|
1967
|
-
* Route subsequent user turns to a different character instance. Pass null to
|
|
1968
|
-
* close every input gate so no member hears the user.
|
|
1969
|
-
*
|
|
1970
|
-
* Resolves on the server's acknowledgement. Retries once against the
|
|
1971
|
-
* server's authoritative epoch when another participant switched first.
|
|
1972
|
-
*
|
|
1973
|
-
* @example
|
|
1974
|
-
* ```ts
|
|
1975
|
-
* await client.setInteractionTarget(assessor.membershipId)
|
|
1976
|
-
* client.sendUserTextMessage('Now grade me.')
|
|
1977
|
-
* ```
|
|
1978
|
-
*/
|
|
1979
|
-
setInteractionTarget: (membershipId: string | null) => Promise<ActiveCharacterChange>;
|
|
1980
|
-
/**
|
|
1981
|
-
* Add or remove character instances on a live room, without reconnecting.
|
|
1982
|
-
*
|
|
1983
|
-
* @example
|
|
1984
|
-
* ```ts
|
|
1985
|
-
* await client.updateCharacterRoster({ add: [{ characterId: NARRATOR }] })
|
|
1986
|
-
* ```
|
|
1987
|
-
*/
|
|
1988
|
-
updateCharacterRoster: (options: UpdateCharacterRosterOptions) => Promise<CharacterRosterChange>;
|
|
1989
1156
|
/** Disconnect from the current character session */
|
|
1990
1157
|
disconnect: () => Promise<void>;
|
|
1991
1158
|
/** Reconnect - disconnect and connect again using stored config */
|
|
1992
1159
|
reconnect: () => Promise<void>;
|
|
1993
1160
|
/** Reset the session ID to start a new conversation (clears history) */
|
|
1994
1161
|
resetSession: () => void;
|
|
1995
|
-
/** Send a text message to the character */
|
|
1162
|
+
/** Send a text message to the character, optionally with a v2 turn id. */
|
|
1996
1163
|
sendUserTextMessage: (text: string, options?: SendUserTextMessageOptions) => void;
|
|
1997
1164
|
/** Return a correlated terminal result for a v2 client tool call. */
|
|
1998
1165
|
sendActionResult: (result: ActionResult) => void;
|
|
1999
|
-
/**
|
|
2000
|
-
* Publish one correlated terminal result and wait for Core's matching
|
|
2001
|
-
* `server-response` acknowledgement.
|
|
2002
|
-
*/
|
|
2003
|
-
sendActionResultAndWait: (result: ActionResult, options?: ActionResultAckOptions) => Promise<ActionResultAck>;
|
|
2004
1166
|
/**
|
|
2005
1167
|
* Send a trigger message to invoke specific character actions or responses.
|
|
2006
1168
|
* @param triggerName - Name of the trigger to invoke
|
|
@@ -2129,12 +1291,12 @@ export interface IConvaiClient {
|
|
|
2129
1291
|
* @param callback Callback function
|
|
2130
1292
|
* @returns Unsubscribe function
|
|
2131
1293
|
*/
|
|
2132
|
-
on:
|
|
1294
|
+
on: (event: string, callback: (...args: any[]) => void) => () => void;
|
|
2133
1295
|
/**
|
|
2134
1296
|
* Unsubscribe from an event
|
|
2135
1297
|
* @param event Event name
|
|
2136
1298
|
* @param callback Callback function to remove
|
|
2137
1299
|
*/
|
|
2138
|
-
off:
|
|
1300
|
+
off: (event: string, callback: (...args: any[]) => void) => void;
|
|
2139
1301
|
}
|
|
2140
1302
|
//# sourceMappingURL=types.d.ts.map
|