@inworld/web-core
Version:
96 lines (95 loc) • 4.89 kB
TypeScript
import { InworldPacket as ProtoPacket } from '../../proto/ai/inworld/packets/packets.pb.js';
import { AudioSessionStartPacketParams, CancelResponsesProps, ChangeSceneProps, PerceivedLatencyReportProps, TriggerParameter } from '../common/data_structures/index.js';
import { GrpcAudioPlayback } from '../components/sound/grpc_audio.playback.js';
import { GrpcAudioRecorder } from '../components/sound/grpc_audio.recorder.js';
import { GrpcWebRtcLoopbackBiDiSession } from '../components/sound/grpc_web_rtc_loopback_bidi.session.js';
import { InworldPlayer } from '../components/sound/inworld_player.js';
import { InworldRecorder } from '../components/sound/inworld_recorder.js';
import { Character } from '../entities/character.entity.js';
import { InworldPacket } from '../entities/packets/inworld_packet.entity.js';
import { ConnectionService } from './connection.service.js';
import { ConversationService } from './conversation.service.js';
import { EntityService } from './entity.service.js';
import { SessionStateService } from './session_state.service.js';
import { FeedbackService } from './wrappers/feedback.service.js';
import { StateSerializationService } from './wrappers/state_serialization.service.js';
interface InworldConnectionServiceProps<InworldPacketT extends InworldPacket = InworldPacket> {
connection: ConnectionService<InworldPacketT>;
grpcAudioPlayer: GrpcAudioPlayback<InworldPacketT>;
grpcAudioRecorder: GrpcAudioRecorder;
webRtcLoopbackBiDiSession: GrpcWebRtcLoopbackBiDiSession;
}
export declare class InworldConnectionService<InworldPacketT extends InworldPacket = InworldPacket> {
private connection;
private grpcAudioPlayer;
private oneToOneConversation;
private oneToOneConversationIntializeState;
readonly feedback: FeedbackService<InworldPacketT>;
readonly entity: EntityService<InworldPacketT>;
readonly stateSerialization: StateSerializationService<InworldPacketT>;
readonly sessionState: SessionStateService;
readonly player: InworldPlayer<InworldPacketT>;
readonly recorder: InworldRecorder;
constructor(props: InworldConnectionServiceProps<InworldPacketT>);
getSessionState(): Promise<import("../common/data_structures/index.js").SessionState>;
open(): Promise<void>;
close(): Promise<void>;
isActive(): boolean;
getCapabilities(): import("../common/data_structures/index.js").Capabilities;
getCharacters(): Promise<Character[]>;
getCurrentCharacter(): Promise<Character>;
getCharacterById(id: string): Character;
getCharacterByResourceName(name: string): Character;
setCurrentCharacter(character: Character): Promise<void>;
clearState(): void;
getHistory(): import("../index.js").HistoryItem[];
getFullHistory(): import("../index.js").HistoryItem[];
clearHistory(): void;
getTranscript(): string;
getFullTranscript(): string;
getCurrentConversation(): Promise<ConversationService<InworldPacketT>>;
getConversations(): {
conversationId: string;
characters: Character[];
}[];
sendText(text: string): Promise<InworldPacketT>;
sendAudio(chunk: string): Promise<InworldPacketT>;
sendTrigger(name: string, parameters?: TriggerParameter[] | {
parameters: TriggerParameter[];
}): Promise<InworldPacketT>;
sendAudioSessionStart(params?: AudioSessionStartPacketParams): Promise<InworldPacketT>;
sendAudioSessionEnd(): Promise<InworldPacketT>;
sendTTSPlaybackMute(isMuted: boolean): Promise<InworldPacketT>;
sendCancelResponse(cancelResponses?: CancelResponsesProps): Promise<InworldPacketT>;
sendNarratedAction(text: string): Promise<InworldPacketT>;
sendPerceivedLatenctReport(props: PerceivedLatencyReportProps): Promise<InworldPacketT>;
reloadScene(): Promise<void>;
changeScene(name: string, props?: ChangeSceneProps): Promise<void>;
addCharacters(names: string[]): Promise<InworldPacketT>;
removeCharacters(names: string[]): Promise<InworldPacketT>;
sendCustomPacket(getPacket: () => ProtoPacket): Promise<InworldPacketT>;
interrupt(): Promise<void>;
startConversation(participants: string[]): ConversationService<InworldPacketT>;
baseProtoPacket(props?: {
utteranceId?: boolean;
interactionId?: boolean;
conversationId?: string;
characters?: Character[];
}): {
packetId: {
conversationId: string;
correlationId: string;
interactionId: string;
utteranceId: string;
packetId: string;
};
timestamp: string;
routing: import("../../proto/ai/inworld/packets/packets.pb.js").Routing;
};
markPacketAsHandled(packet: InworldPacketT): void;
private ensureOneToOneConversation;
private resolveInterval;
private addConversationToConnection;
private recorderListener;
}
export {};