@charisma-ai/sdk
Version:
Charisma.ai SDK for Javascript (browser)
149 lines (148 loc) • 4.15 kB
TypeScript
export declare type MediaType = "image" | "video" | "audio" | "youtube" | "vimeo" | "unknown";
export declare type ActiveFeelingEffect = {
feeling: string;
intensity: number;
duration: number;
durationRemaining: number;
};
export declare type Emotion = {
id: number;
name: string;
avatar: string | null;
moodPositivity: number;
moodEnergy: number;
playerRelationship: number;
activeEffects: ActiveFeelingEffect[];
};
export declare type Memory = {
id: number;
recallValue: string;
saveValue: string | null;
};
export declare type MessagePathItem = {
id: number;
type: "node" | "edge";
};
export declare type MessagePath = MessagePathItem[];
export declare type Impact = {
id: number;
impact: string;
isImpactShareable: boolean;
impactImageUrl: string | null;
};
export declare type Metadata = {
[key: string]: string | undefined;
};
export declare type Character = {
id: number;
name: string;
avatar: string | null;
};
export declare type Speech = {
audio: ArrayBuffer | string;
duration: number;
};
export declare type BubblePoints = [number, number, number];
export declare type BubbleTailPosition = string;
export declare type BubbleStyle = string;
export declare type ImageLayerPoints = [[number, number], [number, number]];
export declare enum ImageLayerResizeMode {
Contain = "contain",
Cover = "cover"
}
export declare type ImageLayer = {
url: string | null;
points: ImageLayerPoints;
resizeMode: ImageLayerResizeMode;
};
export declare enum AudioTrackBehaviour {
Continue = "continue",
Restart = "restart"
}
export declare type AudioTrack = {
url: string | null;
behaviour: AudioTrackBehaviour;
loop: boolean;
volume: number;
stopPlaying: boolean;
};
export declare type Media = {
animationIn: string | null;
animationOut: string | null;
bubblePoints: BubblePoints | null;
bubbleTailPosition: BubbleTailPosition | null;
bubbleStyle: BubbleStyle | null;
imageLayers: ImageLayer[];
audioTracks: AudioTrack[];
stopAllAudio: boolean;
};
export declare type MessageCharacter = {
text: string;
character: Character | null;
metadata: Metadata;
speech: Speech | null;
media: Media;
impact: Impact | null;
};
export declare type MessagePanel = {
metadata: Metadata;
media: Media;
impact: Impact | null;
};
export declare type MessageMedia = {
url: string;
mediaType: MediaType;
};
declare type GenericMessage<T extends string, S> = {
type: T;
message: S;
eventId: string;
timestamp: number;
endStory: boolean;
tapToContinue: boolean;
path: MessagePath;
emotions: Emotion[];
memories: Memory[];
};
export declare type Message = GenericMessage<"character", MessageCharacter> | GenericMessage<"panel", MessagePanel> | GenericMessage<"media", MessageMedia>;
export declare type SpeechEncoding = "mp3" | "ogg" | "pcm";
export declare type SpeechOutput = "url" | "buffer";
export interface SpeechConfig {
encoding?: SpeechEncoding;
output?: SpeechOutput;
}
export interface StartEvent {
sceneIndex?: number;
startGraphId?: number;
startGraphReferenceId?: string;
startNodeId?: number;
}
export interface ReplyEvent {
text: string;
}
export interface ActionEvent {
action: string;
}
export interface StartTypingEvent {
conversationId: number;
}
export interface StopTypingEvent {
conversationId: number;
}
export declare type MessageEvent = {
conversationId: number;
} & Message;
export declare type CharacterMoodChange = {
characterId: number;
characterName: string | null;
characterAvatar: string | null;
};
export declare type CharacterMoodChanges = CharacterMoodChange[];
export interface EpisodeCompleteEvent {
conversationId: number;
impacts: Impact[];
completedEpisodeId: number;
nextEpisodeId: number | null;
characterMoodChanges: CharacterMoodChanges;
}
export {};