@vivix-ai/ivi-frontend-sdk 0.3.8 → 0.3.9
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 +194 -1
- package/dist/index.cjs +667 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +152 -2
- package/dist/index.d.ts +152 -2
- package/dist/index.js +661 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReceiveSessionSourceReadyPayload, IviStream, IviConversationItem, IviRealtimeSessionConfig, IviStageComposition, IviTrack, IviSourceAsset, ReceiveSessionSourceFailedPayload, IviConversationItemContent, ReceiveSessionEndedEvent, ParsedIviEvent, IviRealtimeResponseCreateParams, ReceiveConversationItemAddedEvent, ReceiveConversationItemDoneEvent, ReceiveResponseCreatedEvent, IviClient, IviClientConfig } from '@vivix-ai/ivi-sdk-ts';
|
|
2
2
|
import { LiveKitBrowserTransportConfig } from '@vivix-ai/ivi-sdk-ts/transports/livekit-browser';
|
|
3
|
+
import { WebSocketTransportConfig } from '@vivix-ai/ivi-sdk-ts/transports/websocket';
|
|
3
4
|
import { ReactNode, CSSProperties, ReactElement, VideoHTMLAttributes, ImgHTMLAttributes } from 'react';
|
|
4
5
|
import { IviClientLogEntry } from '@vivix-ai/ivi-sdk-ts/client';
|
|
5
6
|
|
|
@@ -18,6 +19,7 @@ interface IviRuntimeState {
|
|
|
18
19
|
streams: Map<string, IviRuntimeStream>;
|
|
19
20
|
conversationItems: Map<string, IviRuntimeConversationItem>;
|
|
20
21
|
conversations: IviRuntimeConversationItem[];
|
|
22
|
+
bootstrap?: IviRuntimeBootstrapViewState | null;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Runtime 层归一化后的 stream 视图。
|
|
@@ -37,6 +39,7 @@ interface IviRuntimeSourcePreloadState {
|
|
|
37
39
|
*/
|
|
38
40
|
autoclearAfterPlay: boolean;
|
|
39
41
|
}
|
|
42
|
+
type IviRuntimeSourceOrigin = "prebuilt-session-response";
|
|
40
43
|
interface IviRuntimeSource {
|
|
41
44
|
source: IviSourceAsset;
|
|
42
45
|
status: "created" | "ready" | "failed";
|
|
@@ -52,6 +55,27 @@ interface IviRuntimeSource {
|
|
|
52
55
|
* - 不存在:不进行预加载(active source 由上层独立决定是否渲染)。
|
|
53
56
|
*/
|
|
54
57
|
preload?: IviRuntimeSourcePreloadState;
|
|
58
|
+
origin?: IviRuntimeSourceOrigin;
|
|
59
|
+
provisional?: boolean;
|
|
60
|
+
}
|
|
61
|
+
interface IviRuntimeBootstrapSource {
|
|
62
|
+
sourceId: string;
|
|
63
|
+
streamId?: string;
|
|
64
|
+
slot: string;
|
|
65
|
+
trackId: string;
|
|
66
|
+
playback: IviSourcePlayback;
|
|
67
|
+
width?: number;
|
|
68
|
+
height?: number;
|
|
69
|
+
durationMs?: number;
|
|
70
|
+
hasAudio?: boolean;
|
|
71
|
+
source?: Partial<IviSourceAsset>;
|
|
72
|
+
}
|
|
73
|
+
interface IviRuntimeBootstrapViewState {
|
|
74
|
+
active: boolean;
|
|
75
|
+
slot: string;
|
|
76
|
+
trackId: string;
|
|
77
|
+
sourceId: string;
|
|
78
|
+
streamId?: string;
|
|
55
79
|
}
|
|
56
80
|
type IviRuntimeLogLevel = "info" | "warn" | "error";
|
|
57
81
|
interface IviRuntimeLogEntry {
|
|
@@ -239,6 +263,7 @@ declare class TrtcSourceManager {
|
|
|
239
263
|
attachView(sourceId: string, viewId: string, container: HTMLElement, muted: boolean): Promise<void>;
|
|
240
264
|
detachView(sourceId: string, viewId: string): void;
|
|
241
265
|
updateViewMuted(sourceId: string, viewId: string, muted: boolean): void;
|
|
266
|
+
reassignView(fromSourceId: string, toSourceId: string, viewId: string): boolean;
|
|
242
267
|
private unlinkSourceFromSession;
|
|
243
268
|
private getSession;
|
|
244
269
|
private snapshotFromSession;
|
|
@@ -315,9 +340,10 @@ type LivekitSourceListener = (snapshot: LivekitSourceSnapshot) => void;
|
|
|
315
340
|
*/
|
|
316
341
|
declare class LivekitSourceManager {
|
|
317
342
|
private readonly onLog?;
|
|
343
|
+
private readonly onRemoteVideoAvailable?;
|
|
318
344
|
private readonly sessions;
|
|
319
345
|
private readonly listeners;
|
|
320
|
-
constructor(onLog?: IviRuntimeLogCallback | undefined);
|
|
346
|
+
constructor(onLog?: IviRuntimeLogCallback | undefined, onRemoteVideoAvailable?: ((sourceId: string) => void) | undefined);
|
|
321
347
|
/**
|
|
322
348
|
* 与 runtime 当前 sources 对齐:
|
|
323
349
|
* - 对 ready + livekit 的 source 进行 upsert(必要时建立连接);
|
|
@@ -428,6 +454,7 @@ declare class IviRuntimeCoordinator {
|
|
|
428
454
|
private userTextFlowCounter;
|
|
429
455
|
private waitingTracksListValidation;
|
|
430
456
|
private waitingSourcesListValidation;
|
|
457
|
+
private bootstrapSource;
|
|
431
458
|
private state;
|
|
432
459
|
/**
|
|
433
460
|
* @param client 底层实时客户端,负责实际事件收发。
|
|
@@ -448,6 +475,7 @@ declare class IviRuntimeCoordinator {
|
|
|
448
475
|
onEvent(listener: IviRuntimeEventListener): () => void;
|
|
449
476
|
onTrtcEvent(listener: IviRuntimeTrtcEventListener): () => void;
|
|
450
477
|
emitLog(entry: IviRuntimeLogEntry): void;
|
|
478
|
+
setBootstrapSource(source: IviRuntimeBootstrapSource | null): void;
|
|
451
479
|
/**
|
|
452
480
|
* 编排一次"用户文本输入 -> 触发模型回复"链路。
|
|
453
481
|
*
|
|
@@ -484,8 +512,15 @@ declare class IviRuntimeCoordinator {
|
|
|
484
512
|
private onStreamsChanged;
|
|
485
513
|
private onConversationsChanged;
|
|
486
514
|
private setState;
|
|
515
|
+
private composeBootstrapState;
|
|
516
|
+
private shouldExposeBootstrap;
|
|
517
|
+
private isReadyForBootstrapHandoff;
|
|
518
|
+
private recomposeBootstrapState;
|
|
519
|
+
private ensureBootstrapSourceRegistered;
|
|
520
|
+
private syncPlaybackManagers;
|
|
487
521
|
private emitEvent;
|
|
488
522
|
private emitTrtcEvent;
|
|
523
|
+
private onTrtcManagerEvent;
|
|
489
524
|
private resetStoppedState;
|
|
490
525
|
private ensureSourcesSyncedForTracks;
|
|
491
526
|
private validateSourcesListRefreshed;
|
|
@@ -523,10 +558,107 @@ declare class IviRuntimeDispatcher {
|
|
|
523
558
|
private dispatchEvent;
|
|
524
559
|
}
|
|
525
560
|
|
|
561
|
+
type IviCreateSessionStreamType = "TRTC" | "LIVEKIT" | string;
|
|
562
|
+
interface IviCreateIVISessionPrebuiltCharacter {
|
|
563
|
+
characterId: string;
|
|
564
|
+
characterPayload: unknown;
|
|
565
|
+
}
|
|
566
|
+
interface IviCreateIVISessionPrebuiltStream {
|
|
567
|
+
streamId?: string;
|
|
568
|
+
sourceId?: string;
|
|
569
|
+
mode: "character" | string;
|
|
570
|
+
streamConfig: unknown;
|
|
571
|
+
}
|
|
572
|
+
interface IviCreateIVISessionRequest {
|
|
573
|
+
idempotencyKey?: string;
|
|
574
|
+
streamType?: IviCreateSessionStreamType;
|
|
575
|
+
iviVersion?: string;
|
|
576
|
+
sessionParameters?: Record<string, string>;
|
|
577
|
+
enableDecoderPublish?: boolean;
|
|
578
|
+
sessionRecording?: {
|
|
579
|
+
enabled: boolean;
|
|
580
|
+
aspectRatio?: string;
|
|
581
|
+
};
|
|
582
|
+
prebuiltCharacters?: IviCreateIVISessionPrebuiltCharacter[];
|
|
583
|
+
prebuiltStream?: IviCreateIVISessionPrebuiltStream;
|
|
584
|
+
[key: string]: unknown;
|
|
585
|
+
}
|
|
586
|
+
interface IviCreateIVISessionHttpOptions {
|
|
587
|
+
baseUrl?: string;
|
|
588
|
+
path?: string;
|
|
589
|
+
url?: string;
|
|
590
|
+
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
591
|
+
fetch?: typeof fetch;
|
|
592
|
+
credentials?: RequestCredentials;
|
|
593
|
+
signal?: AbortSignal;
|
|
594
|
+
}
|
|
595
|
+
interface IviPrebuiltPlayback {
|
|
596
|
+
sourceId: string;
|
|
597
|
+
streamId?: string;
|
|
598
|
+
kind: "trtc" | "livekit";
|
|
599
|
+
playback: IviSourcePlayback;
|
|
600
|
+
provisional: true;
|
|
601
|
+
}
|
|
602
|
+
interface IviCreateIVISessionResult {
|
|
603
|
+
iviSessionId: string;
|
|
604
|
+
endpoint: string;
|
|
605
|
+
tokenInfo?: unknown;
|
|
606
|
+
trtcInfo?: IviSourcePlaybackTrtc;
|
|
607
|
+
livekitInfo?: IviSourcePlaybackLivekit;
|
|
608
|
+
prebuildTrtcInfo?: {
|
|
609
|
+
trtcInfo?: IviSourcePlaybackTrtc;
|
|
610
|
+
livekitInfo?: IviSourcePlaybackLivekit;
|
|
611
|
+
};
|
|
612
|
+
prebuiltPlayback?: IviPrebuiltPlayback;
|
|
613
|
+
raw: unknown;
|
|
614
|
+
requestBody: Record<string, unknown>;
|
|
615
|
+
}
|
|
616
|
+
interface IviRuntimeWebSocketOptions {
|
|
617
|
+
url?: string;
|
|
618
|
+
protocols?: WebSocketTransportConfig["protocols"];
|
|
619
|
+
query?: Record<string, string | undefined | null>;
|
|
620
|
+
socketFactory?: WebSocketTransportConfig["socketFactory"];
|
|
621
|
+
}
|
|
622
|
+
interface IviRuntimeFromSessionOptions {
|
|
623
|
+
fastStart?: boolean;
|
|
624
|
+
bootstrapSlot?: string;
|
|
625
|
+
bootstrapTrackId?: string;
|
|
626
|
+
clientConfig?: Omit<IviClientConfig, "transport">;
|
|
627
|
+
runtimeConfig?: IviRuntimeCoordinatorConfig;
|
|
628
|
+
websocket?: IviRuntimeWebSocketOptions;
|
|
629
|
+
}
|
|
630
|
+
interface IviSessionRuntime {
|
|
631
|
+
session: IviCreateIVISessionResult;
|
|
632
|
+
client: IviClient;
|
|
633
|
+
runtime: IviRuntimeCoordinator;
|
|
634
|
+
}
|
|
635
|
+
interface IviCreateIVISessionRuntimeOptions extends IviRuntimeFromSessionOptions {
|
|
636
|
+
http: IviCreateIVISessionHttpOptions;
|
|
637
|
+
}
|
|
638
|
+
declare class IviCreateIVISessionError extends Error {
|
|
639
|
+
readonly status: number;
|
|
640
|
+
readonly statusText: string;
|
|
641
|
+
readonly body: unknown;
|
|
642
|
+
constructor(response: Response, body: unknown);
|
|
643
|
+
}
|
|
644
|
+
declare function createIVISession(request: IviCreateIVISessionRequest, options: IviCreateIVISessionHttpOptions): Promise<IviCreateIVISessionResult>;
|
|
645
|
+
declare function createRuntimeFromSession(session: IviCreateIVISessionResult, options?: IviRuntimeFromSessionOptions): IviSessionRuntime;
|
|
646
|
+
declare function createIVISessionRuntime(request: IviCreateIVISessionRequest, options: IviCreateIVISessionRuntimeOptions): Promise<IviSessionRuntime>;
|
|
647
|
+
declare function toCpCreateIVISessionRequestBody(request: IviCreateIVISessionRequest): Record<string, unknown>;
|
|
648
|
+
declare function normalizeCreateIVISessionResponse(responseBody: unknown, request?: IviCreateIVISessionRequest, requestBody?: Record<string, unknown>): IviCreateIVISessionResult;
|
|
649
|
+
|
|
526
650
|
type IviFrontendClientConfig = IviClientConfig;
|
|
651
|
+
interface IviFrontendSdkConfig {
|
|
652
|
+
http?: IviCreateIVISessionHttpOptions;
|
|
653
|
+
}
|
|
527
654
|
declare class IviFrontendSdk {
|
|
655
|
+
private readonly config;
|
|
656
|
+
constructor(config?: IviFrontendSdkConfig);
|
|
528
657
|
createClient(config: IviFrontendClientConfig): IviClient;
|
|
529
658
|
createRuntimeCoordinator(clientConfig: IviFrontendClientConfig, runtimeConfig?: IviRuntimeCoordinatorConfig): IviRuntimeCoordinator;
|
|
659
|
+
createIVISession(request: IviCreateIVISessionRequest, options?: IviCreateIVISessionHttpOptions): Promise<IviCreateIVISessionResult>;
|
|
660
|
+
createRuntimeFromSession(session: IviCreateIVISessionResult, options?: IviRuntimeFromSessionOptions): IviSessionRuntime;
|
|
661
|
+
createIVISessionRuntime(request: IviCreateIVISessionRequest, options?: Partial<IviCreateIVISessionRuntimeOptions>): Promise<IviSessionRuntime>;
|
|
530
662
|
}
|
|
531
663
|
|
|
532
664
|
interface IviStageSlotBinding {
|
|
@@ -800,6 +932,24 @@ interface IviManagedRuntimeConfig {
|
|
|
800
932
|
}
|
|
801
933
|
declare function useManagedIviRuntime(config: IviManagedRuntimeConfig): IviRuntimeCoordinator | null;
|
|
802
934
|
|
|
935
|
+
type IviSessionRuntimeHookStatus = "idle" | "creating" | "connecting" | "running" | "error" | "stopped";
|
|
936
|
+
interface UseIviSessionRuntimeConfig extends IviCreateIVISessionRuntimeOptions {
|
|
937
|
+
request: IviCreateIVISessionRequest | null | undefined;
|
|
938
|
+
enabled?: boolean;
|
|
939
|
+
autoStart?: boolean;
|
|
940
|
+
onCreated?: (session: IviCreateIVISessionResult) => void;
|
|
941
|
+
onRuntimeReady?: (runtime: IviRuntimeCoordinator, client: IviClient) => void;
|
|
942
|
+
onError?: (error: unknown) => void;
|
|
943
|
+
}
|
|
944
|
+
interface UseIviSessionRuntimeResult {
|
|
945
|
+
status: IviSessionRuntimeHookStatus;
|
|
946
|
+
session: IviCreateIVISessionResult | null;
|
|
947
|
+
runtime: IviRuntimeCoordinator | null;
|
|
948
|
+
client: IviClient | null;
|
|
949
|
+
error: Error | null;
|
|
950
|
+
}
|
|
951
|
+
declare function useIviSessionRuntime(config: UseIviSessionRuntimeConfig): UseIviSessionRuntimeResult;
|
|
952
|
+
|
|
803
953
|
declare function useIviStageView(): IviStageViewContextValue;
|
|
804
954
|
|
|
805
|
-
export { DEFAULT_HIDE_COMPLETED_SUBTITLE_AFTER_MS, EMPTY_RUNTIME_STATE, IVILivekitPlayer, type IVILivekitPlayerProps, IVIStageView, type IVIStageViewProps, IVISubtitleOverlay, type IVISubtitleOverlayProps, type IVISubtitleOverlayStyle, IVITrackSlot, type IVITrackSlotProps, IVITrtcPlayer, type IVITrtcPlayerProps, type IviCompletedSubtitleDecision, type IviCompletedSubtitleDecisionResult, type IviFrontendClientConfig, IviFrontendSdk, type IviManagedRuntimeConfig, type IviManagedRuntimeLogCallback, type IviManagedRuntimeLogEntry, type IviManagedRuntimeLogLevel, type IviManagedRuntimeLogSource, type IviRuntimeConversationItem, type IviRuntimeConversationLifecycle, type IviRuntimeConversationStatus, IviRuntimeCoordinator, type IviRuntimeCoordinatorConfig, IviRuntimeDispatcher, type IviRuntimeDispatcherConfig, type IviRuntimeEventListener, type IviRuntimeLogCallback, type IviRuntimeLogEntry, type IviRuntimeLogLevel, type IviRuntimeSource, type IviRuntimeSourcePreloadState, type IviRuntimeState, type IviRuntimeStatus, type IviRuntimeStream, type IviRuntimeTrtcAIDenoiserMode, type IviRuntimeTrtcAIDenoiserOptions, type IviRuntimeTrtcEvent, type IviRuntimeTrtcEventListener, type IviRuntimeTrtcEventType, type IviRuntimeUserTextToResponseCallbacks, type IviRuntimeUserTextToResponseOptions, type IviRuntimeUserTextToResponseResult, type IviSourcePlaybackLivekit, type IviSourcePlaybackLivekitDescriptor, type IviStageSlotBinding, type IviStageViewContextValue, type IviSubtitleCompletedContext, type IviSubtitleCompletedHandler, type IviSubtitleCompletedReason, type IviSubtitleItem, type IviSubtitleRole, type IviSubtitleSource, type IviUseSubtitlesOptions, LivekitSourceManager, TrtcSourceManager, isLivekitSourcePlayback, isReadyLivekitRuntimeSource, isSameLivekitConfig, useIviStageView, useIviSubtitles, useManagedIviRuntime, useRuntimeState };
|
|
955
|
+
export { DEFAULT_HIDE_COMPLETED_SUBTITLE_AFTER_MS, EMPTY_RUNTIME_STATE, IVILivekitPlayer, type IVILivekitPlayerProps, IVIStageView, type IVIStageViewProps, IVISubtitleOverlay, type IVISubtitleOverlayProps, type IVISubtitleOverlayStyle, IVITrackSlot, type IVITrackSlotProps, IVITrtcPlayer, type IVITrtcPlayerProps, type IviCompletedSubtitleDecision, type IviCompletedSubtitleDecisionResult, IviCreateIVISessionError, type IviCreateIVISessionHttpOptions, type IviCreateIVISessionPrebuiltCharacter, type IviCreateIVISessionPrebuiltStream, type IviCreateIVISessionRequest, type IviCreateIVISessionResult, type IviCreateIVISessionRuntimeOptions, type IviCreateSessionStreamType, type IviFrontendClientConfig, IviFrontendSdk, type IviFrontendSdkConfig, type IviManagedRuntimeConfig, type IviManagedRuntimeLogCallback, type IviManagedRuntimeLogEntry, type IviManagedRuntimeLogLevel, type IviManagedRuntimeLogSource, type IviPrebuiltPlayback, type IviRuntimeBootstrapSource, type IviRuntimeBootstrapViewState, type IviRuntimeConversationItem, type IviRuntimeConversationLifecycle, type IviRuntimeConversationStatus, IviRuntimeCoordinator, type IviRuntimeCoordinatorConfig, IviRuntimeDispatcher, type IviRuntimeDispatcherConfig, type IviRuntimeEventListener, type IviRuntimeFromSessionOptions, type IviRuntimeLogCallback, type IviRuntimeLogEntry, type IviRuntimeLogLevel, type IviRuntimeSource, type IviRuntimeSourceOrigin, type IviRuntimeSourcePreloadState, type IviRuntimeState, type IviRuntimeStatus, type IviRuntimeStream, type IviRuntimeTrtcAIDenoiserMode, type IviRuntimeTrtcAIDenoiserOptions, type IviRuntimeTrtcEvent, type IviRuntimeTrtcEventListener, type IviRuntimeTrtcEventType, type IviRuntimeUserTextToResponseCallbacks, type IviRuntimeUserTextToResponseOptions, type IviRuntimeUserTextToResponseResult, type IviRuntimeWebSocketOptions, type IviSessionRuntime, type IviSessionRuntimeHookStatus, type IviSourcePlaybackLivekit, type IviSourcePlaybackLivekitDescriptor, type IviStageSlotBinding, type IviStageViewContextValue, type IviSubtitleCompletedContext, type IviSubtitleCompletedHandler, type IviSubtitleCompletedReason, type IviSubtitleItem, type IviSubtitleRole, type IviSubtitleSource, type IviUseSubtitlesOptions, LivekitSourceManager, TrtcSourceManager, type UseIviSessionRuntimeConfig, type UseIviSessionRuntimeResult, createIVISession, createIVISessionRuntime, createRuntimeFromSession, isLivekitSourcePlayback, isReadyLivekitRuntimeSource, isSameLivekitConfig, normalizeCreateIVISessionResponse, toCpCreateIVISessionRequestBody, useIviSessionRuntime, useIviStageView, useIviSubtitles, useManagedIviRuntime, useRuntimeState };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReceiveSessionSourceReadyPayload, IviStream, IviConversationItem, IviRealtimeSessionConfig, IviStageComposition, IviTrack, IviSourceAsset, ReceiveSessionSourceFailedPayload, IviConversationItemContent, ReceiveSessionEndedEvent, ParsedIviEvent, IviRealtimeResponseCreateParams, ReceiveConversationItemAddedEvent, ReceiveConversationItemDoneEvent, ReceiveResponseCreatedEvent, IviClient, IviClientConfig } from '@vivix-ai/ivi-sdk-ts';
|
|
2
2
|
import { LiveKitBrowserTransportConfig } from '@vivix-ai/ivi-sdk-ts/transports/livekit-browser';
|
|
3
|
+
import { WebSocketTransportConfig } from '@vivix-ai/ivi-sdk-ts/transports/websocket';
|
|
3
4
|
import { ReactNode, CSSProperties, ReactElement, VideoHTMLAttributes, ImgHTMLAttributes } from 'react';
|
|
4
5
|
import { IviClientLogEntry } from '@vivix-ai/ivi-sdk-ts/client';
|
|
5
6
|
|
|
@@ -18,6 +19,7 @@ interface IviRuntimeState {
|
|
|
18
19
|
streams: Map<string, IviRuntimeStream>;
|
|
19
20
|
conversationItems: Map<string, IviRuntimeConversationItem>;
|
|
20
21
|
conversations: IviRuntimeConversationItem[];
|
|
22
|
+
bootstrap?: IviRuntimeBootstrapViewState | null;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Runtime 层归一化后的 stream 视图。
|
|
@@ -37,6 +39,7 @@ interface IviRuntimeSourcePreloadState {
|
|
|
37
39
|
*/
|
|
38
40
|
autoclearAfterPlay: boolean;
|
|
39
41
|
}
|
|
42
|
+
type IviRuntimeSourceOrigin = "prebuilt-session-response";
|
|
40
43
|
interface IviRuntimeSource {
|
|
41
44
|
source: IviSourceAsset;
|
|
42
45
|
status: "created" | "ready" | "failed";
|
|
@@ -52,6 +55,27 @@ interface IviRuntimeSource {
|
|
|
52
55
|
* - 不存在:不进行预加载(active source 由上层独立决定是否渲染)。
|
|
53
56
|
*/
|
|
54
57
|
preload?: IviRuntimeSourcePreloadState;
|
|
58
|
+
origin?: IviRuntimeSourceOrigin;
|
|
59
|
+
provisional?: boolean;
|
|
60
|
+
}
|
|
61
|
+
interface IviRuntimeBootstrapSource {
|
|
62
|
+
sourceId: string;
|
|
63
|
+
streamId?: string;
|
|
64
|
+
slot: string;
|
|
65
|
+
trackId: string;
|
|
66
|
+
playback: IviSourcePlayback;
|
|
67
|
+
width?: number;
|
|
68
|
+
height?: number;
|
|
69
|
+
durationMs?: number;
|
|
70
|
+
hasAudio?: boolean;
|
|
71
|
+
source?: Partial<IviSourceAsset>;
|
|
72
|
+
}
|
|
73
|
+
interface IviRuntimeBootstrapViewState {
|
|
74
|
+
active: boolean;
|
|
75
|
+
slot: string;
|
|
76
|
+
trackId: string;
|
|
77
|
+
sourceId: string;
|
|
78
|
+
streamId?: string;
|
|
55
79
|
}
|
|
56
80
|
type IviRuntimeLogLevel = "info" | "warn" | "error";
|
|
57
81
|
interface IviRuntimeLogEntry {
|
|
@@ -239,6 +263,7 @@ declare class TrtcSourceManager {
|
|
|
239
263
|
attachView(sourceId: string, viewId: string, container: HTMLElement, muted: boolean): Promise<void>;
|
|
240
264
|
detachView(sourceId: string, viewId: string): void;
|
|
241
265
|
updateViewMuted(sourceId: string, viewId: string, muted: boolean): void;
|
|
266
|
+
reassignView(fromSourceId: string, toSourceId: string, viewId: string): boolean;
|
|
242
267
|
private unlinkSourceFromSession;
|
|
243
268
|
private getSession;
|
|
244
269
|
private snapshotFromSession;
|
|
@@ -315,9 +340,10 @@ type LivekitSourceListener = (snapshot: LivekitSourceSnapshot) => void;
|
|
|
315
340
|
*/
|
|
316
341
|
declare class LivekitSourceManager {
|
|
317
342
|
private readonly onLog?;
|
|
343
|
+
private readonly onRemoteVideoAvailable?;
|
|
318
344
|
private readonly sessions;
|
|
319
345
|
private readonly listeners;
|
|
320
|
-
constructor(onLog?: IviRuntimeLogCallback | undefined);
|
|
346
|
+
constructor(onLog?: IviRuntimeLogCallback | undefined, onRemoteVideoAvailable?: ((sourceId: string) => void) | undefined);
|
|
321
347
|
/**
|
|
322
348
|
* 与 runtime 当前 sources 对齐:
|
|
323
349
|
* - 对 ready + livekit 的 source 进行 upsert(必要时建立连接);
|
|
@@ -428,6 +454,7 @@ declare class IviRuntimeCoordinator {
|
|
|
428
454
|
private userTextFlowCounter;
|
|
429
455
|
private waitingTracksListValidation;
|
|
430
456
|
private waitingSourcesListValidation;
|
|
457
|
+
private bootstrapSource;
|
|
431
458
|
private state;
|
|
432
459
|
/**
|
|
433
460
|
* @param client 底层实时客户端,负责实际事件收发。
|
|
@@ -448,6 +475,7 @@ declare class IviRuntimeCoordinator {
|
|
|
448
475
|
onEvent(listener: IviRuntimeEventListener): () => void;
|
|
449
476
|
onTrtcEvent(listener: IviRuntimeTrtcEventListener): () => void;
|
|
450
477
|
emitLog(entry: IviRuntimeLogEntry): void;
|
|
478
|
+
setBootstrapSource(source: IviRuntimeBootstrapSource | null): void;
|
|
451
479
|
/**
|
|
452
480
|
* 编排一次"用户文本输入 -> 触发模型回复"链路。
|
|
453
481
|
*
|
|
@@ -484,8 +512,15 @@ declare class IviRuntimeCoordinator {
|
|
|
484
512
|
private onStreamsChanged;
|
|
485
513
|
private onConversationsChanged;
|
|
486
514
|
private setState;
|
|
515
|
+
private composeBootstrapState;
|
|
516
|
+
private shouldExposeBootstrap;
|
|
517
|
+
private isReadyForBootstrapHandoff;
|
|
518
|
+
private recomposeBootstrapState;
|
|
519
|
+
private ensureBootstrapSourceRegistered;
|
|
520
|
+
private syncPlaybackManagers;
|
|
487
521
|
private emitEvent;
|
|
488
522
|
private emitTrtcEvent;
|
|
523
|
+
private onTrtcManagerEvent;
|
|
489
524
|
private resetStoppedState;
|
|
490
525
|
private ensureSourcesSyncedForTracks;
|
|
491
526
|
private validateSourcesListRefreshed;
|
|
@@ -523,10 +558,107 @@ declare class IviRuntimeDispatcher {
|
|
|
523
558
|
private dispatchEvent;
|
|
524
559
|
}
|
|
525
560
|
|
|
561
|
+
type IviCreateSessionStreamType = "TRTC" | "LIVEKIT" | string;
|
|
562
|
+
interface IviCreateIVISessionPrebuiltCharacter {
|
|
563
|
+
characterId: string;
|
|
564
|
+
characterPayload: unknown;
|
|
565
|
+
}
|
|
566
|
+
interface IviCreateIVISessionPrebuiltStream {
|
|
567
|
+
streamId?: string;
|
|
568
|
+
sourceId?: string;
|
|
569
|
+
mode: "character" | string;
|
|
570
|
+
streamConfig: unknown;
|
|
571
|
+
}
|
|
572
|
+
interface IviCreateIVISessionRequest {
|
|
573
|
+
idempotencyKey?: string;
|
|
574
|
+
streamType?: IviCreateSessionStreamType;
|
|
575
|
+
iviVersion?: string;
|
|
576
|
+
sessionParameters?: Record<string, string>;
|
|
577
|
+
enableDecoderPublish?: boolean;
|
|
578
|
+
sessionRecording?: {
|
|
579
|
+
enabled: boolean;
|
|
580
|
+
aspectRatio?: string;
|
|
581
|
+
};
|
|
582
|
+
prebuiltCharacters?: IviCreateIVISessionPrebuiltCharacter[];
|
|
583
|
+
prebuiltStream?: IviCreateIVISessionPrebuiltStream;
|
|
584
|
+
[key: string]: unknown;
|
|
585
|
+
}
|
|
586
|
+
interface IviCreateIVISessionHttpOptions {
|
|
587
|
+
baseUrl?: string;
|
|
588
|
+
path?: string;
|
|
589
|
+
url?: string;
|
|
590
|
+
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
591
|
+
fetch?: typeof fetch;
|
|
592
|
+
credentials?: RequestCredentials;
|
|
593
|
+
signal?: AbortSignal;
|
|
594
|
+
}
|
|
595
|
+
interface IviPrebuiltPlayback {
|
|
596
|
+
sourceId: string;
|
|
597
|
+
streamId?: string;
|
|
598
|
+
kind: "trtc" | "livekit";
|
|
599
|
+
playback: IviSourcePlayback;
|
|
600
|
+
provisional: true;
|
|
601
|
+
}
|
|
602
|
+
interface IviCreateIVISessionResult {
|
|
603
|
+
iviSessionId: string;
|
|
604
|
+
endpoint: string;
|
|
605
|
+
tokenInfo?: unknown;
|
|
606
|
+
trtcInfo?: IviSourcePlaybackTrtc;
|
|
607
|
+
livekitInfo?: IviSourcePlaybackLivekit;
|
|
608
|
+
prebuildTrtcInfo?: {
|
|
609
|
+
trtcInfo?: IviSourcePlaybackTrtc;
|
|
610
|
+
livekitInfo?: IviSourcePlaybackLivekit;
|
|
611
|
+
};
|
|
612
|
+
prebuiltPlayback?: IviPrebuiltPlayback;
|
|
613
|
+
raw: unknown;
|
|
614
|
+
requestBody: Record<string, unknown>;
|
|
615
|
+
}
|
|
616
|
+
interface IviRuntimeWebSocketOptions {
|
|
617
|
+
url?: string;
|
|
618
|
+
protocols?: WebSocketTransportConfig["protocols"];
|
|
619
|
+
query?: Record<string, string | undefined | null>;
|
|
620
|
+
socketFactory?: WebSocketTransportConfig["socketFactory"];
|
|
621
|
+
}
|
|
622
|
+
interface IviRuntimeFromSessionOptions {
|
|
623
|
+
fastStart?: boolean;
|
|
624
|
+
bootstrapSlot?: string;
|
|
625
|
+
bootstrapTrackId?: string;
|
|
626
|
+
clientConfig?: Omit<IviClientConfig, "transport">;
|
|
627
|
+
runtimeConfig?: IviRuntimeCoordinatorConfig;
|
|
628
|
+
websocket?: IviRuntimeWebSocketOptions;
|
|
629
|
+
}
|
|
630
|
+
interface IviSessionRuntime {
|
|
631
|
+
session: IviCreateIVISessionResult;
|
|
632
|
+
client: IviClient;
|
|
633
|
+
runtime: IviRuntimeCoordinator;
|
|
634
|
+
}
|
|
635
|
+
interface IviCreateIVISessionRuntimeOptions extends IviRuntimeFromSessionOptions {
|
|
636
|
+
http: IviCreateIVISessionHttpOptions;
|
|
637
|
+
}
|
|
638
|
+
declare class IviCreateIVISessionError extends Error {
|
|
639
|
+
readonly status: number;
|
|
640
|
+
readonly statusText: string;
|
|
641
|
+
readonly body: unknown;
|
|
642
|
+
constructor(response: Response, body: unknown);
|
|
643
|
+
}
|
|
644
|
+
declare function createIVISession(request: IviCreateIVISessionRequest, options: IviCreateIVISessionHttpOptions): Promise<IviCreateIVISessionResult>;
|
|
645
|
+
declare function createRuntimeFromSession(session: IviCreateIVISessionResult, options?: IviRuntimeFromSessionOptions): IviSessionRuntime;
|
|
646
|
+
declare function createIVISessionRuntime(request: IviCreateIVISessionRequest, options: IviCreateIVISessionRuntimeOptions): Promise<IviSessionRuntime>;
|
|
647
|
+
declare function toCpCreateIVISessionRequestBody(request: IviCreateIVISessionRequest): Record<string, unknown>;
|
|
648
|
+
declare function normalizeCreateIVISessionResponse(responseBody: unknown, request?: IviCreateIVISessionRequest, requestBody?: Record<string, unknown>): IviCreateIVISessionResult;
|
|
649
|
+
|
|
526
650
|
type IviFrontendClientConfig = IviClientConfig;
|
|
651
|
+
interface IviFrontendSdkConfig {
|
|
652
|
+
http?: IviCreateIVISessionHttpOptions;
|
|
653
|
+
}
|
|
527
654
|
declare class IviFrontendSdk {
|
|
655
|
+
private readonly config;
|
|
656
|
+
constructor(config?: IviFrontendSdkConfig);
|
|
528
657
|
createClient(config: IviFrontendClientConfig): IviClient;
|
|
529
658
|
createRuntimeCoordinator(clientConfig: IviFrontendClientConfig, runtimeConfig?: IviRuntimeCoordinatorConfig): IviRuntimeCoordinator;
|
|
659
|
+
createIVISession(request: IviCreateIVISessionRequest, options?: IviCreateIVISessionHttpOptions): Promise<IviCreateIVISessionResult>;
|
|
660
|
+
createRuntimeFromSession(session: IviCreateIVISessionResult, options?: IviRuntimeFromSessionOptions): IviSessionRuntime;
|
|
661
|
+
createIVISessionRuntime(request: IviCreateIVISessionRequest, options?: Partial<IviCreateIVISessionRuntimeOptions>): Promise<IviSessionRuntime>;
|
|
530
662
|
}
|
|
531
663
|
|
|
532
664
|
interface IviStageSlotBinding {
|
|
@@ -800,6 +932,24 @@ interface IviManagedRuntimeConfig {
|
|
|
800
932
|
}
|
|
801
933
|
declare function useManagedIviRuntime(config: IviManagedRuntimeConfig): IviRuntimeCoordinator | null;
|
|
802
934
|
|
|
935
|
+
type IviSessionRuntimeHookStatus = "idle" | "creating" | "connecting" | "running" | "error" | "stopped";
|
|
936
|
+
interface UseIviSessionRuntimeConfig extends IviCreateIVISessionRuntimeOptions {
|
|
937
|
+
request: IviCreateIVISessionRequest | null | undefined;
|
|
938
|
+
enabled?: boolean;
|
|
939
|
+
autoStart?: boolean;
|
|
940
|
+
onCreated?: (session: IviCreateIVISessionResult) => void;
|
|
941
|
+
onRuntimeReady?: (runtime: IviRuntimeCoordinator, client: IviClient) => void;
|
|
942
|
+
onError?: (error: unknown) => void;
|
|
943
|
+
}
|
|
944
|
+
interface UseIviSessionRuntimeResult {
|
|
945
|
+
status: IviSessionRuntimeHookStatus;
|
|
946
|
+
session: IviCreateIVISessionResult | null;
|
|
947
|
+
runtime: IviRuntimeCoordinator | null;
|
|
948
|
+
client: IviClient | null;
|
|
949
|
+
error: Error | null;
|
|
950
|
+
}
|
|
951
|
+
declare function useIviSessionRuntime(config: UseIviSessionRuntimeConfig): UseIviSessionRuntimeResult;
|
|
952
|
+
|
|
803
953
|
declare function useIviStageView(): IviStageViewContextValue;
|
|
804
954
|
|
|
805
|
-
export { DEFAULT_HIDE_COMPLETED_SUBTITLE_AFTER_MS, EMPTY_RUNTIME_STATE, IVILivekitPlayer, type IVILivekitPlayerProps, IVIStageView, type IVIStageViewProps, IVISubtitleOverlay, type IVISubtitleOverlayProps, type IVISubtitleOverlayStyle, IVITrackSlot, type IVITrackSlotProps, IVITrtcPlayer, type IVITrtcPlayerProps, type IviCompletedSubtitleDecision, type IviCompletedSubtitleDecisionResult, type IviFrontendClientConfig, IviFrontendSdk, type IviManagedRuntimeConfig, type IviManagedRuntimeLogCallback, type IviManagedRuntimeLogEntry, type IviManagedRuntimeLogLevel, type IviManagedRuntimeLogSource, type IviRuntimeConversationItem, type IviRuntimeConversationLifecycle, type IviRuntimeConversationStatus, IviRuntimeCoordinator, type IviRuntimeCoordinatorConfig, IviRuntimeDispatcher, type IviRuntimeDispatcherConfig, type IviRuntimeEventListener, type IviRuntimeLogCallback, type IviRuntimeLogEntry, type IviRuntimeLogLevel, type IviRuntimeSource, type IviRuntimeSourcePreloadState, type IviRuntimeState, type IviRuntimeStatus, type IviRuntimeStream, type IviRuntimeTrtcAIDenoiserMode, type IviRuntimeTrtcAIDenoiserOptions, type IviRuntimeTrtcEvent, type IviRuntimeTrtcEventListener, type IviRuntimeTrtcEventType, type IviRuntimeUserTextToResponseCallbacks, type IviRuntimeUserTextToResponseOptions, type IviRuntimeUserTextToResponseResult, type IviSourcePlaybackLivekit, type IviSourcePlaybackLivekitDescriptor, type IviStageSlotBinding, type IviStageViewContextValue, type IviSubtitleCompletedContext, type IviSubtitleCompletedHandler, type IviSubtitleCompletedReason, type IviSubtitleItem, type IviSubtitleRole, type IviSubtitleSource, type IviUseSubtitlesOptions, LivekitSourceManager, TrtcSourceManager, isLivekitSourcePlayback, isReadyLivekitRuntimeSource, isSameLivekitConfig, useIviStageView, useIviSubtitles, useManagedIviRuntime, useRuntimeState };
|
|
955
|
+
export { DEFAULT_HIDE_COMPLETED_SUBTITLE_AFTER_MS, EMPTY_RUNTIME_STATE, IVILivekitPlayer, type IVILivekitPlayerProps, IVIStageView, type IVIStageViewProps, IVISubtitleOverlay, type IVISubtitleOverlayProps, type IVISubtitleOverlayStyle, IVITrackSlot, type IVITrackSlotProps, IVITrtcPlayer, type IVITrtcPlayerProps, type IviCompletedSubtitleDecision, type IviCompletedSubtitleDecisionResult, IviCreateIVISessionError, type IviCreateIVISessionHttpOptions, type IviCreateIVISessionPrebuiltCharacter, type IviCreateIVISessionPrebuiltStream, type IviCreateIVISessionRequest, type IviCreateIVISessionResult, type IviCreateIVISessionRuntimeOptions, type IviCreateSessionStreamType, type IviFrontendClientConfig, IviFrontendSdk, type IviFrontendSdkConfig, type IviManagedRuntimeConfig, type IviManagedRuntimeLogCallback, type IviManagedRuntimeLogEntry, type IviManagedRuntimeLogLevel, type IviManagedRuntimeLogSource, type IviPrebuiltPlayback, type IviRuntimeBootstrapSource, type IviRuntimeBootstrapViewState, type IviRuntimeConversationItem, type IviRuntimeConversationLifecycle, type IviRuntimeConversationStatus, IviRuntimeCoordinator, type IviRuntimeCoordinatorConfig, IviRuntimeDispatcher, type IviRuntimeDispatcherConfig, type IviRuntimeEventListener, type IviRuntimeFromSessionOptions, type IviRuntimeLogCallback, type IviRuntimeLogEntry, type IviRuntimeLogLevel, type IviRuntimeSource, type IviRuntimeSourceOrigin, type IviRuntimeSourcePreloadState, type IviRuntimeState, type IviRuntimeStatus, type IviRuntimeStream, type IviRuntimeTrtcAIDenoiserMode, type IviRuntimeTrtcAIDenoiserOptions, type IviRuntimeTrtcEvent, type IviRuntimeTrtcEventListener, type IviRuntimeTrtcEventType, type IviRuntimeUserTextToResponseCallbacks, type IviRuntimeUserTextToResponseOptions, type IviRuntimeUserTextToResponseResult, type IviRuntimeWebSocketOptions, type IviSessionRuntime, type IviSessionRuntimeHookStatus, type IviSourcePlaybackLivekit, type IviSourcePlaybackLivekitDescriptor, type IviStageSlotBinding, type IviStageViewContextValue, type IviSubtitleCompletedContext, type IviSubtitleCompletedHandler, type IviSubtitleCompletedReason, type IviSubtitleItem, type IviSubtitleRole, type IviSubtitleSource, type IviUseSubtitlesOptions, LivekitSourceManager, TrtcSourceManager, type UseIviSessionRuntimeConfig, type UseIviSessionRuntimeResult, createIVISession, createIVISessionRuntime, createRuntimeFromSession, isLivekitSourcePlayback, isReadyLivekitRuntimeSource, isSameLivekitConfig, normalizeCreateIVISessionResponse, toCpCreateIVISessionRequestBody, useIviSessionRuntime, useIviStageView, useIviSubtitles, useManagedIviRuntime, useRuntimeState };
|