@aituber-onair/core 0.1.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/README.md +723 -0
- package/dist/constants/api.d.ts +4 -0
- package/dist/constants/api.js +13 -0
- package/dist/constants/api.js.map +1 -0
- package/dist/constants/index.d.ts +23 -0
- package/dist/constants/index.js +25 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/openaiApi.d.ts +15 -0
- package/dist/constants/openaiApi.js +15 -0
- package/dist/constants/openaiApi.js.map +1 -0
- package/dist/constants/prompts.d.ts +2 -0
- package/dist/constants/prompts.js +13 -0
- package/dist/constants/prompts.js.map +1 -0
- package/dist/core/AITuberOnAirCore.d.ts +142 -0
- package/dist/core/AITuberOnAirCore.js +316 -0
- package/dist/core/AITuberOnAirCore.js.map +1 -0
- package/dist/core/ChatProcessor.d.ts +86 -0
- package/dist/core/ChatProcessor.js +246 -0
- package/dist/core/ChatProcessor.js.map +1 -0
- package/dist/core/EventEmitter.d.ts +35 -0
- package/dist/core/EventEmitter.js +72 -0
- package/dist/core/EventEmitter.js.map +1 -0
- package/dist/core/MemoryManager.d.ts +98 -0
- package/dist/core/MemoryManager.js +208 -0
- package/dist/core/MemoryManager.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/services/chat/ChatService.d.ts +21 -0
- package/dist/services/chat/ChatService.js +2 -0
- package/dist/services/chat/ChatService.js.map +1 -0
- package/dist/services/chat/ChatServiceFactory.d.ts +38 -0
- package/dist/services/chat/ChatServiceFactory.js +55 -0
- package/dist/services/chat/ChatServiceFactory.js.map +1 -0
- package/dist/services/chat/OpenAIChatService.d.ts +38 -0
- package/dist/services/chat/OpenAIChatService.js +166 -0
- package/dist/services/chat/OpenAIChatService.js.map +1 -0
- package/dist/services/chat/OpenAISummarizer.d.ts +25 -0
- package/dist/services/chat/OpenAISummarizer.js +70 -0
- package/dist/services/chat/OpenAISummarizer.js.map +1 -0
- package/dist/services/chat/providers/ChatServiceProvider.d.ts +44 -0
- package/dist/services/chat/providers/ChatServiceProvider.js +2 -0
- package/dist/services/chat/providers/ChatServiceProvider.js.map +1 -0
- package/dist/services/chat/providers/OpenAIChatServiceProvider.d.ts +33 -0
- package/dist/services/chat/providers/OpenAIChatServiceProvider.js +44 -0
- package/dist/services/chat/providers/OpenAIChatServiceProvider.js.map +1 -0
- package/dist/services/voice/VoiceEngineAdapter.d.ts +46 -0
- package/dist/services/voice/VoiceEngineAdapter.js +173 -0
- package/dist/services/voice/VoiceEngineAdapter.js.map +1 -0
- package/dist/services/voice/VoiceService.d.ts +55 -0
- package/dist/services/voice/VoiceService.js +2 -0
- package/dist/services/voice/VoiceService.js.map +1 -0
- package/dist/services/voice/engines/AivisSpeechEngine.d.ts +10 -0
- package/dist/services/voice/engines/AivisSpeechEngine.js +70 -0
- package/dist/services/voice/engines/AivisSpeechEngine.js.map +1 -0
- package/dist/services/voice/engines/NijiVoiceEngine.d.ts +12 -0
- package/dist/services/voice/engines/NijiVoiceEngine.js +105 -0
- package/dist/services/voice/engines/NijiVoiceEngine.js.map +1 -0
- package/dist/services/voice/engines/OpenAiEngine.d.ts +9 -0
- package/dist/services/voice/engines/OpenAiEngine.js +34 -0
- package/dist/services/voice/engines/OpenAiEngine.js.map +1 -0
- package/dist/services/voice/engines/VoiceEngine.d.ts +21 -0
- package/dist/services/voice/engines/VoiceEngine.js +2 -0
- package/dist/services/voice/engines/VoiceEngine.js.map +1 -0
- package/dist/services/voice/engines/VoiceEngineFactory.d.ts +14 -0
- package/dist/services/voice/engines/VoiceEngineFactory.js +34 -0
- package/dist/services/voice/engines/VoiceEngineFactory.js.map +1 -0
- package/dist/services/voice/engines/VoicePeakEngine.d.ts +13 -0
- package/dist/services/voice/engines/VoicePeakEngine.js +46 -0
- package/dist/services/voice/engines/VoicePeakEngine.js.map +1 -0
- package/dist/services/voice/engines/VoiceVoxEngine.d.ts +13 -0
- package/dist/services/voice/engines/VoiceVoxEngine.js +67 -0
- package/dist/services/voice/engines/VoiceVoxEngine.js.map +1 -0
- package/dist/services/voice/engines/index.d.ts +7 -0
- package/dist/services/voice/engines/index.js +7 -0
- package/dist/services/voice/engines/index.js.map +1 -0
- package/dist/services/voice/messages.d.ts +38 -0
- package/dist/services/voice/messages.js +49 -0
- package/dist/services/voice/messages.js.map +1 -0
- package/dist/services/youtube/YouTubeDataApiService.d.ts +69 -0
- package/dist/services/youtube/YouTubeDataApiService.js +255 -0
- package/dist/services/youtube/YouTubeDataApiService.js.map +1 -0
- package/dist/services/youtube/YouTubeService.d.ts +63 -0
- package/dist/services/youtube/YouTubeService.js +2 -0
- package/dist/services/youtube/YouTubeService.js.map +1 -0
- package/dist/types/index.d.ts +82 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/nijiVoice.d.ts +27 -0
- package/dist/types/nijiVoice.js +2 -0
- package/dist/types/nijiVoice.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/screenplay.d.ts +19 -0
- package/dist/utils/screenplay.js +42 -0
- package/dist/utils/screenplay.js.map +1 -0
- package/dist/utils/screenshot.d.ts +19 -0
- package/dist/utils/screenshot.js +44 -0
- package/dist/utils/screenshot.js.map +1 -0
- package/dist/utils/storage.d.ts +44 -0
- package/dist/utils/storage.js +103 -0
- package/dist/utils/storage.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LocalStorage implementation of MemoryStorage
|
|
3
|
+
*/
|
|
4
|
+
export class LocalStorageMemoryStorage {
|
|
5
|
+
/**
|
|
6
|
+
* Constructor
|
|
7
|
+
* @param storageKey Key to use in localStorage
|
|
8
|
+
*/
|
|
9
|
+
constructor(storageKey) {
|
|
10
|
+
this.storageKey = storageKey;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Load memory records from localStorage
|
|
14
|
+
* @returns Promise resolving to array of memory records
|
|
15
|
+
*/
|
|
16
|
+
async load() {
|
|
17
|
+
try {
|
|
18
|
+
const rawData = localStorage.getItem(this.storageKey);
|
|
19
|
+
if (!rawData) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
const parsed = JSON.parse(rawData);
|
|
23
|
+
if (!Array.isArray(parsed)) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
// Validate records and filter out invalid ones
|
|
27
|
+
return parsed.filter((item) => typeof item === 'object' &&
|
|
28
|
+
item !== null &&
|
|
29
|
+
typeof item.type === 'string' &&
|
|
30
|
+
['short', 'mid', 'long'].includes(item.type) &&
|
|
31
|
+
typeof item.summary === 'string' &&
|
|
32
|
+
typeof item.timestamp === 'number');
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.error('Error loading memory records from localStorage:', error);
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Save memory records to localStorage
|
|
41
|
+
* @param records Memory records to save
|
|
42
|
+
* @returns Promise resolving when save is complete
|
|
43
|
+
*/
|
|
44
|
+
async save(records) {
|
|
45
|
+
try {
|
|
46
|
+
localStorage.setItem(this.storageKey, JSON.stringify(records));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error('Error saving memory records to localStorage:', error);
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Clear all stored memory records
|
|
55
|
+
* @returns Promise resolving when clear is complete
|
|
56
|
+
*/
|
|
57
|
+
async clear() {
|
|
58
|
+
try {
|
|
59
|
+
localStorage.removeItem(this.storageKey);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.error('Error clearing memory records from localStorage:', error);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* IndexedDB implementation of MemoryStorage (example skeleton)
|
|
69
|
+
* This is just a placeholder - would need to be implemented properly
|
|
70
|
+
*/
|
|
71
|
+
export class IndexedDBMemoryStorage {
|
|
72
|
+
// Implementation would go here
|
|
73
|
+
async load() {
|
|
74
|
+
// Would use IndexedDB APIs to load data
|
|
75
|
+
throw new Error('IndexedDBMemoryStorage not implemented');
|
|
76
|
+
}
|
|
77
|
+
async save(records) {
|
|
78
|
+
// Would use IndexedDB APIs to save data
|
|
79
|
+
throw new Error('IndexedDBMemoryStorage not implemented');
|
|
80
|
+
}
|
|
81
|
+
async clear() {
|
|
82
|
+
// Would use IndexedDB APIs to clear data
|
|
83
|
+
throw new Error('IndexedDBMemoryStorage not implemented');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Factory function to create appropriate storage based on environment
|
|
88
|
+
* @param storageKey Key to use for storage
|
|
89
|
+
* @param storageType Type of storage to use
|
|
90
|
+
* @returns MemoryStorage implementation
|
|
91
|
+
*/
|
|
92
|
+
export function createMemoryStorage(storageKey, storageType = 'localStorage') {
|
|
93
|
+
switch (storageType) {
|
|
94
|
+
case 'localStorage':
|
|
95
|
+
return new LocalStorageMemoryStorage(storageKey);
|
|
96
|
+
case 'indexedDB':
|
|
97
|
+
// Example - not implemented yet
|
|
98
|
+
return new IndexedDBMemoryStorage();
|
|
99
|
+
default:
|
|
100
|
+
return new LocalStorageMemoryStorage(storageKey);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/utils/storage.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,yBAAyB;IAGpC;;;OAGG;IACH,YAAY,UAAkB;QAC5B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;OAGG;IAC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ACT,IAAI,CAAC;YACH,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,kDAAkD,EAAE,KAAK,CAAC,CAAC;YACzE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,sBAAsB;IACjC,+BAA+B;IAC/B,KAAK,CAAC,IAAI;QACR,wCAAwC;QACxC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAuB;QAChC,wCAAwC;QACxC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,KAAK;QACT,yCAAyC;QACzC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,UAAkB,EAClB,cAA4C,cAAc;IAE1D,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,cAAc;YACjB,OAAO,IAAI,yBAAyB,CAAC,UAAU,CAAC,CAAC;QACnD,KAAK,WAAW;YACd,gCAAgC;YAChC,OAAO,IAAI,sBAAsB,EAAE,CAAC;QACtC;YACE,OAAO,IAAI,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aituber-onair/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Core library for AITuber OnAir providing voice synthesis and chat processing",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": ["dist"],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc --project tsconfig.json",
|
|
11
|
+
"typecheck": "tsc --project tsconfig.dev.json",
|
|
12
|
+
"test": "npm run typecheck && vitest run",
|
|
13
|
+
"test:watch": "vitest",
|
|
14
|
+
"test:coverage": "vitest run --coverage"
|
|
15
|
+
},
|
|
16
|
+
"keywords": ["aituber", "vtuber", "ai", "voice", "streaming"],
|
|
17
|
+
"author": "shinshin86 (https://github.com/shinshin86)",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"openai": "^3.2.1",
|
|
22
|
+
"@pixiv/three-vrm": "^1.0.9"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^18.15.0",
|
|
26
|
+
"@vitest/coverage-v8": "^1.3.1",
|
|
27
|
+
"typescript": "^5.0.0",
|
|
28
|
+
"vitest": "^1.3.1"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
}
|
|
33
|
+
}
|