@prometheusavatar/core 0.3.0 → 0.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/dist/index.d.ts +113 -1
- package/dist/index.js +155 -0
- package/package.json +9 -5
package/dist/index.d.ts
CHANGED
|
@@ -84,6 +84,22 @@ interface AvatarEventMap {
|
|
|
84
84
|
};
|
|
85
85
|
'destroy': void;
|
|
86
86
|
}
|
|
87
|
+
/** Standard chat message format (OpenAI-compatible) */
|
|
88
|
+
interface ILLMMessage {
|
|
89
|
+
role: 'system' | 'user' | 'assistant';
|
|
90
|
+
content: string;
|
|
91
|
+
}
|
|
92
|
+
/** LLM Provider interface — implement this to plug in any LLM */
|
|
93
|
+
interface ILLMProvider {
|
|
94
|
+
/** Provider name (e.g. "gemini", "groq", "deepseek") */
|
|
95
|
+
readonly name: string;
|
|
96
|
+
/** Whether this provider is available (has API key etc.) */
|
|
97
|
+
available(): boolean;
|
|
98
|
+
/** Generate a streaming response. Returns an async iterator of text tokens. */
|
|
99
|
+
stream(messages: ILLMMessage[]): AsyncIterable<string>;
|
|
100
|
+
/** Generate a non-streaming response. */
|
|
101
|
+
generate?(messages: ILLMMessage[]): Promise<string>;
|
|
102
|
+
}
|
|
87
103
|
|
|
88
104
|
/**
|
|
89
105
|
* PrometheusAvatar — Main orchestrator class
|
|
@@ -346,4 +362,100 @@ declare class EmotionAnalyzer {
|
|
|
346
362
|
analyze(text: string): EmotionResult;
|
|
347
363
|
}
|
|
348
364
|
|
|
349
|
-
|
|
365
|
+
/**
|
|
366
|
+
* Prometheus AssetManager
|
|
367
|
+
*
|
|
368
|
+
* Handles loading, applying, and managing ALL marketplace asset categories:
|
|
369
|
+
* - Skins: Live2D .model3.json + textures
|
|
370
|
+
* - Voices: TTS voice config or audio samples
|
|
371
|
+
* - Motions: Live2D .motion3.json animations
|
|
372
|
+
* - Expressions: Live2D .exp3.json facial expressions
|
|
373
|
+
* - Effects: Particle/shader overlays (JSON config)
|
|
374
|
+
* - Scenes: Background images/videos
|
|
375
|
+
* - Personas: Personality prompt/behavior JSON
|
|
376
|
+
* - Accessories: Additional Live2D attachments
|
|
377
|
+
* - Bundles: Multi-asset packages
|
|
378
|
+
*/
|
|
379
|
+
type AssetCategory = "skins" | "voices" | "motions" | "expressions" | "effects" | "scenes" | "personas" | "accessories" | "bundles";
|
|
380
|
+
interface AssetManifest {
|
|
381
|
+
id: string;
|
|
382
|
+
name: string;
|
|
383
|
+
category: AssetCategory;
|
|
384
|
+
fileUrl: string;
|
|
385
|
+
/** For bundles: list of sub-asset URLs */
|
|
386
|
+
files?: {
|
|
387
|
+
category: AssetCategory;
|
|
388
|
+
url: string;
|
|
389
|
+
name: string;
|
|
390
|
+
}[];
|
|
391
|
+
/** For voices: voice config */
|
|
392
|
+
voiceConfig?: {
|
|
393
|
+
lang?: string;
|
|
394
|
+
rate?: number;
|
|
395
|
+
pitch?: number;
|
|
396
|
+
voiceId?: string;
|
|
397
|
+
};
|
|
398
|
+
/** For personas: system prompt */
|
|
399
|
+
persona?: {
|
|
400
|
+
systemPrompt: string;
|
|
401
|
+
traits?: string[];
|
|
402
|
+
greeting?: string;
|
|
403
|
+
};
|
|
404
|
+
/** For effects: particle config */
|
|
405
|
+
effectConfig?: {
|
|
406
|
+
type: string;
|
|
407
|
+
color?: string;
|
|
408
|
+
density?: number;
|
|
409
|
+
speed?: number;
|
|
410
|
+
};
|
|
411
|
+
/** For scenes: scene config */
|
|
412
|
+
sceneConfig?: {
|
|
413
|
+
type: "image" | "video" | "gradient";
|
|
414
|
+
loop?: boolean;
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
interface AssetManagerCallbacks {
|
|
418
|
+
onSkinLoaded?: (modelUrl: string) => void;
|
|
419
|
+
onVoiceChanged?: (config: AssetManifest["voiceConfig"]) => void;
|
|
420
|
+
onMotionPlay?: (motionUrl: string) => void;
|
|
421
|
+
onExpressionLoaded?: (expressionUrl: string) => void;
|
|
422
|
+
onEffectApplied?: (config: AssetManifest["effectConfig"]) => void;
|
|
423
|
+
onSceneChanged?: (sceneUrl: string, config: AssetManifest["sceneConfig"]) => void;
|
|
424
|
+
onPersonaLoaded?: (persona: AssetManifest["persona"]) => void;
|
|
425
|
+
onAccessoryAdded?: (accessoryUrl: string) => void;
|
|
426
|
+
onError?: (error: Error, category: AssetCategory) => void;
|
|
427
|
+
}
|
|
428
|
+
declare class AssetManager {
|
|
429
|
+
private appliedAssets;
|
|
430
|
+
private callbacks;
|
|
431
|
+
private sceneElement;
|
|
432
|
+
private effectCanvas;
|
|
433
|
+
constructor(callbacks?: AssetManagerCallbacks);
|
|
434
|
+
/**
|
|
435
|
+
* Apply an asset from the marketplace.
|
|
436
|
+
* Fetches the file, determines category, and applies it.
|
|
437
|
+
*/
|
|
438
|
+
applyAsset(manifest: AssetManifest): Promise<void>;
|
|
439
|
+
private applySkin;
|
|
440
|
+
private applyVoice;
|
|
441
|
+
private applyMotion;
|
|
442
|
+
private applyExpression;
|
|
443
|
+
private applyEffect;
|
|
444
|
+
private applyScene;
|
|
445
|
+
private applyPersona;
|
|
446
|
+
private applyAccessory;
|
|
447
|
+
private applyBundle;
|
|
448
|
+
private parseVoiceFromUrl;
|
|
449
|
+
/** Get all currently applied assets */
|
|
450
|
+
getApplied(): Map<AssetCategory, AssetManifest>;
|
|
451
|
+
/** Remove an applied asset */
|
|
452
|
+
removeAsset(category: AssetCategory): void;
|
|
453
|
+
/** Get file format requirements for each category */
|
|
454
|
+
static getFormatRequirements(): Record<AssetCategory, {
|
|
455
|
+
formats: string[];
|
|
456
|
+
maxSize: string;
|
|
457
|
+
description: string;
|
|
458
|
+
}>;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export { type AssetCategory, AssetManager, type AssetManagerCallbacks, type AssetManifest, type AvatarEventMap, type AvatarOptions, type Emotion, EmotionAnalyzer, type EmotionResult, type ILLMMessage, type ILLMProvider, type ITTSEngine, LipSyncEngine, type LipSyncFrame, Live2DRenderer, PrometheusAvatar, type PrometheusConfig, type TTSOptions, WebSpeechTTS, createAvatar };
|
package/dist/index.js
CHANGED
|
@@ -815,7 +815,162 @@ async function createAvatar(options) {
|
|
|
815
815
|
await avatar.init();
|
|
816
816
|
return avatar;
|
|
817
817
|
}
|
|
818
|
+
|
|
819
|
+
// src/asset-manager.ts
|
|
820
|
+
var AssetManager = class {
|
|
821
|
+
constructor(callbacks = {}) {
|
|
822
|
+
this.appliedAssets = /* @__PURE__ */ new Map();
|
|
823
|
+
this.sceneElement = null;
|
|
824
|
+
this.effectCanvas = null;
|
|
825
|
+
this.callbacks = callbacks;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Apply an asset from the marketplace.
|
|
829
|
+
* Fetches the file, determines category, and applies it.
|
|
830
|
+
*/
|
|
831
|
+
async applyAsset(manifest) {
|
|
832
|
+
try {
|
|
833
|
+
switch (manifest.category) {
|
|
834
|
+
case "skins":
|
|
835
|
+
await this.applySkin(manifest);
|
|
836
|
+
break;
|
|
837
|
+
case "voices":
|
|
838
|
+
this.applyVoice(manifest);
|
|
839
|
+
break;
|
|
840
|
+
case "motions":
|
|
841
|
+
await this.applyMotion(manifest);
|
|
842
|
+
break;
|
|
843
|
+
case "expressions":
|
|
844
|
+
await this.applyExpression(manifest);
|
|
845
|
+
break;
|
|
846
|
+
case "effects":
|
|
847
|
+
this.applyEffect(manifest);
|
|
848
|
+
break;
|
|
849
|
+
case "scenes":
|
|
850
|
+
this.applyScene(manifest);
|
|
851
|
+
break;
|
|
852
|
+
case "personas":
|
|
853
|
+
this.applyPersona(manifest);
|
|
854
|
+
break;
|
|
855
|
+
case "accessories":
|
|
856
|
+
await this.applyAccessory(manifest);
|
|
857
|
+
break;
|
|
858
|
+
case "bundles":
|
|
859
|
+
await this.applyBundle(manifest);
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
this.appliedAssets.set(manifest.category, manifest);
|
|
863
|
+
} catch (error) {
|
|
864
|
+
this.callbacks.onError?.(error, manifest.category);
|
|
865
|
+
throw error;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
// ═══ Category-specific apply methods ═══
|
|
869
|
+
async applySkin(manifest) {
|
|
870
|
+
this.callbacks.onSkinLoaded?.(manifest.fileUrl);
|
|
871
|
+
}
|
|
872
|
+
applyVoice(manifest) {
|
|
873
|
+
const config = manifest.voiceConfig || this.parseVoiceFromUrl(manifest.fileUrl);
|
|
874
|
+
this.callbacks.onVoiceChanged?.(config);
|
|
875
|
+
}
|
|
876
|
+
async applyMotion(manifest) {
|
|
877
|
+
this.callbacks.onMotionPlay?.(manifest.fileUrl);
|
|
878
|
+
}
|
|
879
|
+
async applyExpression(manifest) {
|
|
880
|
+
this.callbacks.onExpressionLoaded?.(manifest.fileUrl);
|
|
881
|
+
}
|
|
882
|
+
applyEffect(manifest) {
|
|
883
|
+
const config = manifest.effectConfig || { type: "particles", color: "#00d4aa", density: 50, speed: 1 };
|
|
884
|
+
this.callbacks.onEffectApplied?.(config);
|
|
885
|
+
}
|
|
886
|
+
applyScene(manifest) {
|
|
887
|
+
const config = manifest.sceneConfig || { type: "image" };
|
|
888
|
+
this.callbacks.onSceneChanged?.(manifest.fileUrl, config);
|
|
889
|
+
}
|
|
890
|
+
applyPersona(manifest) {
|
|
891
|
+
const persona = manifest.persona || { systemPrompt: "", traits: [] };
|
|
892
|
+
this.callbacks.onPersonaLoaded?.(persona);
|
|
893
|
+
}
|
|
894
|
+
async applyAccessory(manifest) {
|
|
895
|
+
this.callbacks.onAccessoryAdded?.(manifest.fileUrl);
|
|
896
|
+
}
|
|
897
|
+
async applyBundle(manifest) {
|
|
898
|
+
if (manifest.files) {
|
|
899
|
+
for (const file of manifest.files) {
|
|
900
|
+
await this.applyAsset({
|
|
901
|
+
id: `${manifest.id}_${file.category}`,
|
|
902
|
+
name: file.name,
|
|
903
|
+
category: file.category,
|
|
904
|
+
fileUrl: file.url
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
// ═══ Helpers ═══
|
|
910
|
+
parseVoiceFromUrl(url) {
|
|
911
|
+
return { lang: "en-US", rate: 1, pitch: 1 };
|
|
912
|
+
}
|
|
913
|
+
/** Get all currently applied assets */
|
|
914
|
+
getApplied() {
|
|
915
|
+
return new Map(this.appliedAssets);
|
|
916
|
+
}
|
|
917
|
+
/** Remove an applied asset */
|
|
918
|
+
removeAsset(category) {
|
|
919
|
+
this.appliedAssets.delete(category);
|
|
920
|
+
}
|
|
921
|
+
/** Get file format requirements for each category */
|
|
922
|
+
static getFormatRequirements() {
|
|
923
|
+
return {
|
|
924
|
+
skins: {
|
|
925
|
+
formats: [".model3.json", ".zip (with textures)"],
|
|
926
|
+
maxSize: "50MB",
|
|
927
|
+
description: "Live2D model package \u2014 includes .model3.json, textures (.png), and physics config"
|
|
928
|
+
},
|
|
929
|
+
voices: {
|
|
930
|
+
formats: [".json (voice config)", ".mp3", ".wav"],
|
|
931
|
+
maxSize: "20MB",
|
|
932
|
+
description: "Voice pack \u2014 TTS config JSON with lang/rate/pitch or audio sample files"
|
|
933
|
+
},
|
|
934
|
+
motions: {
|
|
935
|
+
formats: [".motion3.json", ".zip"],
|
|
936
|
+
maxSize: "10MB",
|
|
937
|
+
description: "Motion animations \u2014 Live2D motion3.json files for dance, idle, wave, etc."
|
|
938
|
+
},
|
|
939
|
+
expressions: {
|
|
940
|
+
formats: [".exp3.json", ".json"],
|
|
941
|
+
maxSize: "5MB",
|
|
942
|
+
description: "Expression presets \u2014 Live2D exp3.json or parameter preset JSON"
|
|
943
|
+
},
|
|
944
|
+
effects: {
|
|
945
|
+
formats: [".json (config)", ".zip"],
|
|
946
|
+
maxSize: "10MB",
|
|
947
|
+
description: "Visual effects \u2014 particle/shader config JSON with optional texture assets"
|
|
948
|
+
},
|
|
949
|
+
scenes: {
|
|
950
|
+
formats: [".png", ".jpg", ".webp", ".mp4", ".webm"],
|
|
951
|
+
maxSize: "30MB",
|
|
952
|
+
description: "Background scene \u2014 static image or looping video behind the avatar"
|
|
953
|
+
},
|
|
954
|
+
personas: {
|
|
955
|
+
formats: [".json"],
|
|
956
|
+
maxSize: "1MB",
|
|
957
|
+
description: "Persona config \u2014 JSON with systemPrompt, personalityTraits, and optional greeting"
|
|
958
|
+
},
|
|
959
|
+
accessories: {
|
|
960
|
+
formats: [".model3.json", ".png", ".zip"],
|
|
961
|
+
maxSize: "20MB",
|
|
962
|
+
description: "Accessories \u2014 Live2D overlay model or sprite images (ears, hats, glasses, etc.)"
|
|
963
|
+
},
|
|
964
|
+
bundles: {
|
|
965
|
+
formats: [".zip"],
|
|
966
|
+
maxSize: "100MB",
|
|
967
|
+
description: "Bundle \u2014 ZIP containing multiple assets with a manifest.json listing each item"
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
};
|
|
818
972
|
export {
|
|
973
|
+
AssetManager,
|
|
819
974
|
EmotionAnalyzer,
|
|
820
975
|
LipSyncEngine,
|
|
821
976
|
Live2DRenderer,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prometheusavatar/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Give your AI agent an embodied avatar — Live2D rendering, TTS, lip-sync, and emotion analysis in one SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,16 +19,20 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
21
21
|
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest",
|
|
22
24
|
"clean": "rm -rf dist",
|
|
23
25
|
"lint": "tsc --noEmit"
|
|
24
26
|
},
|
|
25
27
|
"dependencies": {
|
|
26
|
-
"pixi
|
|
27
|
-
"pixi
|
|
28
|
+
"pixi-live2d-display": "^0.4.0",
|
|
29
|
+
"pixi.js": "^6.5.10"
|
|
28
30
|
},
|
|
29
31
|
"devDependencies": {
|
|
30
32
|
"tsup": "^8.0.0",
|
|
31
|
-
"
|
|
33
|
+
"typedoc": "^0.28.17",
|
|
34
|
+
"typescript": "^5.4.0",
|
|
35
|
+
"vitest": "^4.0.18"
|
|
32
36
|
},
|
|
33
37
|
"keywords": [
|
|
34
38
|
"live2d",
|
|
@@ -45,6 +49,6 @@
|
|
|
45
49
|
"author": "Myths Labs (JC)",
|
|
46
50
|
"repository": {
|
|
47
51
|
"type": "git",
|
|
48
|
-
"url": "https://github.com/myths-labs/prometheus"
|
|
52
|
+
"url": "https://github.com/myths-labs/prometheus-avatar"
|
|
49
53
|
}
|
|
50
54
|
}
|