@inworld/web-core
Version:
61 lines (60 loc) • 2.5 kB
TypeScript
import { ConversationState, User } from '../common/data_structures/index.js';
import { ConvesationInterface, Extension } from '../common/data_structures/extension.js';
import { HistoryItem } from '../common/data_structures/history.js';
import { Character } from '../entities/character.entity.js';
import { InworldPacket } from '../entities/packets/inworld_packet.entity.js';
import { GrpcAudioPlayback } from './sound/grpc_audio.playback.js';
interface InworldHistoryAddProps<InworldPacketT> {
characters: Character[];
grpcAudioPlayer: GrpcAudioPlayback;
packet: InworldPacketT;
outgoing?: boolean;
fromHistory?: boolean;
fromHistoryCharacter?: Character;
}
interface InworldHistoryProps<InworldPacketT extends InworldPacket = InworldPacket, HistoryItemT extends HistoryItem = HistoryItem> {
audioEnabled?: boolean;
extension?: Extension<InworldPacketT, HistoryItemT>;
user?: User;
scene: string;
conversations: Map<string, {
service: ConvesationInterface<InworldPacketT>;
state: ConversationState;
}>;
}
export declare class InworldHistory<InworldPacketT extends InworldPacket = InworldPacket, HistoryItemT extends HistoryItem = HistoryItem> {
private audioEnabled;
private audioEnabledPerConversation;
private scene;
private user?;
private history;
private queue;
private emotions;
private extension;
private conversationItems;
private conversations;
constructor(props: InworldHistoryProps<InworldPacketT, HistoryItemT>);
setAudioEnabled(conversationId: string, enabled: boolean): void;
addOrUpdate({ characters, grpcAudioPlayer, packet, outgoing, fromHistory, fromHistoryCharacter, }: InworldHistoryAddProps<InworldPacketT>): HistoryItem[];
update(packet: InworldPacketT): HistoryItem[];
display(packet: InworldPacketT): HistoryItem[];
get(conversationId?: string): HistoryItem[];
filter(props: {
history?: (item: HistoryItem) => boolean;
queue?: (item: HistoryItem) => boolean;
}): HistoryItem[];
clear(): void;
getTranscript(conversationId?: string): string;
private getUserName;
private combineTextItem;
private combineSceneChangeItem;
private combineConversationUpdateItem;
private combineNarratedActionItem;
private combineCustomItem;
private combineInteractionEndItem;
private combineLogItem;
private convertToExtendedType;
private markAsApplied;
private findCharacters;
}
export {};