@aituber-onair/chat 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.ja.md +318 -0
- package/README.md +318 -0
- package/dist/cjs/constants/chat.d.ts +26 -0
- package/dist/cjs/constants/chat.d.ts.map +1 -0
- package/dist/cjs/constants/chat.js +34 -0
- package/dist/cjs/constants/chat.js.map +1 -0
- package/dist/cjs/constants/claude.d.ts +9 -0
- package/dist/cjs/constants/claude.d.ts.map +1 -0
- package/dist/cjs/constants/claude.js +20 -0
- package/dist/cjs/constants/claude.js.map +1 -0
- package/dist/cjs/constants/gemini.d.ts +11 -0
- package/dist/cjs/constants/gemini.d.ts.map +1 -0
- package/dist/cjs/constants/gemini.js +26 -0
- package/dist/cjs/constants/gemini.js.map +1 -0
- package/dist/cjs/constants/index.d.ts +9 -0
- package/dist/cjs/constants/index.d.ts.map +1 -0
- package/dist/cjs/constants/index.js +25 -0
- package/dist/cjs/constants/index.js.map +1 -0
- package/dist/cjs/constants/openai.d.ts +13 -0
- package/dist/cjs/constants/openai.d.ts.map +1 -0
- package/dist/cjs/constants/openai.js +28 -0
- package/dist/cjs/constants/openai.js.map +1 -0
- package/dist/cjs/constants/prompts.d.ts +3 -0
- package/dist/cjs/constants/prompts.d.ts.map +1 -0
- package/dist/cjs/constants/prompts.js +16 -0
- package/dist/cjs/constants/prompts.js.map +1 -0
- package/dist/cjs/index.d.ts +17 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +45 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/services/ChatService.d.ts +51 -0
- package/dist/cjs/services/ChatService.d.ts.map +1 -0
- package/dist/cjs/services/ChatService.js +3 -0
- package/dist/cjs/services/ChatService.js.map +1 -0
- package/dist/cjs/services/ChatServiceFactory.d.ts +39 -0
- package/dist/cjs/services/ChatServiceFactory.d.ts.map +1 -0
- package/dist/cjs/services/ChatServiceFactory.js +65 -0
- package/dist/cjs/services/ChatServiceFactory.js.map +1 -0
- package/dist/cjs/services/providers/ChatServiceProvider.d.ts +52 -0
- package/dist/cjs/services/providers/ChatServiceProvider.d.ts.map +1 -0
- package/dist/cjs/services/providers/ChatServiceProvider.js +3 -0
- package/dist/cjs/services/providers/ChatServiceProvider.js.map +1 -0
- package/dist/cjs/services/providers/claude/ClaudeChatService.d.ts +142 -0
- package/dist/cjs/services/providers/claude/ClaudeChatService.d.ts.map +1 -0
- package/dist/cjs/services/providers/claude/ClaudeChatService.js +501 -0
- package/dist/cjs/services/providers/claude/ClaudeChatService.js.map +1 -0
- package/dist/cjs/services/providers/claude/ClaudeChatServiceProvider.d.ts +40 -0
- package/dist/cjs/services/providers/claude/ClaudeChatServiceProvider.d.ts.map +1 -0
- package/dist/cjs/services/providers/claude/ClaudeChatServiceProvider.js +68 -0
- package/dist/cjs/services/providers/claude/ClaudeChatServiceProvider.js.map +1 -0
- package/dist/cjs/services/providers/gemini/GeminiChatService.d.ts +104 -0
- package/dist/cjs/services/providers/gemini/GeminiChatService.d.ts.map +1 -0
- package/dist/cjs/services/providers/gemini/GeminiChatService.js +653 -0
- package/dist/cjs/services/providers/gemini/GeminiChatService.js.map +1 -0
- package/dist/cjs/services/providers/gemini/GeminiChatServiceProvider.d.ts +40 -0
- package/dist/cjs/services/providers/gemini/GeminiChatServiceProvider.d.ts.map +1 -0
- package/dist/cjs/services/providers/gemini/GeminiChatServiceProvider.js +70 -0
- package/dist/cjs/services/providers/gemini/GeminiChatServiceProvider.js.map +1 -0
- package/dist/cjs/services/providers/openai/OpenAIChatService.d.ts +110 -0
- package/dist/cjs/services/providers/openai/OpenAIChatService.d.ts.map +1 -0
- package/dist/cjs/services/providers/openai/OpenAIChatService.js +544 -0
- package/dist/cjs/services/providers/openai/OpenAIChatService.js.map +1 -0
- package/dist/cjs/services/providers/openai/OpenAIChatServiceProvider.d.ts +40 -0
- package/dist/cjs/services/providers/openai/OpenAIChatServiceProvider.d.ts.map +1 -0
- package/dist/cjs/services/providers/openai/OpenAIChatServiceProvider.js +80 -0
- package/dist/cjs/services/providers/openai/OpenAIChatServiceProvider.js.map +1 -0
- package/dist/cjs/types/chat.d.ts +46 -0
- package/dist/cjs/types/chat.d.ts.map +1 -0
- package/dist/cjs/types/chat.js +6 -0
- package/dist/cjs/types/chat.js.map +1 -0
- package/dist/cjs/types/index.d.ts +8 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/index.js +25 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/mcp.d.ts +37 -0
- package/dist/cjs/types/mcp.d.ts.map +1 -0
- package/dist/cjs/types/mcp.js +6 -0
- package/dist/cjs/types/mcp.js.map +1 -0
- package/dist/cjs/types/toolChat.d.ts +42 -0
- package/dist/cjs/types/toolChat.d.ts.map +1 -0
- package/dist/cjs/types/toolChat.js +3 -0
- package/dist/cjs/types/toolChat.js.map +1 -0
- package/dist/cjs/utils/chatServiceHttpClient.d.ts +47 -0
- package/dist/cjs/utils/chatServiceHttpClient.d.ts.map +1 -0
- package/dist/cjs/utils/chatServiceHttpClient.js +131 -0
- package/dist/cjs/utils/chatServiceHttpClient.js.map +1 -0
- package/dist/cjs/utils/emotionParser.d.ts +46 -0
- package/dist/cjs/utils/emotionParser.d.ts.map +1 -0
- package/dist/cjs/utils/emotionParser.js +59 -0
- package/dist/cjs/utils/emotionParser.js.map +1 -0
- package/dist/cjs/utils/index.d.ts +8 -0
- package/dist/cjs/utils/index.d.ts.map +1 -0
- package/dist/cjs/utils/index.js +24 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/mcpSchemaFetcher.d.ts +19 -0
- package/dist/cjs/utils/mcpSchemaFetcher.d.ts.map +1 -0
- package/dist/cjs/utils/mcpSchemaFetcher.js +98 -0
- package/dist/cjs/utils/mcpSchemaFetcher.js.map +1 -0
- package/dist/cjs/utils/screenplay.d.ts +20 -0
- package/dist/cjs/utils/screenplay.d.ts.map +1 -0
- package/dist/cjs/utils/screenplay.js +41 -0
- package/dist/cjs/utils/screenplay.js.map +1 -0
- package/dist/cjs/utils/streamTextAccumulator.d.ts +25 -0
- package/dist/cjs/utils/streamTextAccumulator.d.ts.map +1 -0
- package/dist/cjs/utils/streamTextAccumulator.js +47 -0
- package/dist/cjs/utils/streamTextAccumulator.js.map +1 -0
- package/dist/esm/constants/chat.d.ts +26 -0
- package/dist/esm/constants/chat.d.ts.map +1 -0
- package/dist/esm/constants/chat.js +30 -0
- package/dist/esm/constants/chat.js.map +1 -0
- package/dist/esm/constants/claude.d.ts +9 -0
- package/dist/esm/constants/claude.d.ts.map +1 -0
- package/dist/esm/constants/claude.js +17 -0
- package/dist/esm/constants/claude.js.map +1 -0
- package/dist/esm/constants/gemini.d.ts +11 -0
- package/dist/esm/constants/gemini.d.ts.map +1 -0
- package/dist/esm/constants/gemini.js +23 -0
- package/dist/esm/constants/gemini.js.map +1 -0
- package/dist/esm/constants/index.d.ts +9 -0
- package/dist/esm/constants/index.d.ts.map +1 -0
- package/dist/esm/constants/index.js +9 -0
- package/dist/esm/constants/index.js.map +1 -0
- package/dist/esm/constants/openai.d.ts +13 -0
- package/dist/esm/constants/openai.d.ts.map +1 -0
- package/dist/esm/constants/openai.js +25 -0
- package/dist/esm/constants/openai.js.map +1 -0
- package/dist/esm/constants/prompts.d.ts +3 -0
- package/dist/esm/constants/prompts.d.ts.map +1 -0
- package/dist/esm/constants/prompts.js +13 -0
- package/dist/esm/constants/prompts.js.map +1 -0
- package/dist/esm/index.d.ts +17 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +21 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/services/ChatService.d.ts +51 -0
- package/dist/esm/services/ChatService.d.ts.map +1 -0
- package/dist/esm/services/ChatService.js +2 -0
- package/dist/esm/services/ChatService.js.map +1 -0
- package/dist/esm/services/ChatServiceFactory.d.ts +39 -0
- package/dist/esm/services/ChatServiceFactory.d.ts.map +1 -0
- package/dist/esm/services/ChatServiceFactory.js +61 -0
- package/dist/esm/services/ChatServiceFactory.js.map +1 -0
- package/dist/esm/services/providers/ChatServiceProvider.d.ts +52 -0
- package/dist/esm/services/providers/ChatServiceProvider.d.ts.map +1 -0
- package/dist/esm/services/providers/ChatServiceProvider.js +2 -0
- package/dist/esm/services/providers/ChatServiceProvider.js.map +1 -0
- package/dist/esm/services/providers/claude/ClaudeChatService.d.ts +142 -0
- package/dist/esm/services/providers/claude/ClaudeChatService.d.ts.map +1 -0
- package/dist/esm/services/providers/claude/ClaudeChatService.js +497 -0
- package/dist/esm/services/providers/claude/ClaudeChatService.js.map +1 -0
- package/dist/esm/services/providers/claude/ClaudeChatServiceProvider.d.ts +40 -0
- package/dist/esm/services/providers/claude/ClaudeChatServiceProvider.d.ts.map +1 -0
- package/dist/esm/services/providers/claude/ClaudeChatServiceProvider.js +64 -0
- package/dist/esm/services/providers/claude/ClaudeChatServiceProvider.js.map +1 -0
- package/dist/esm/services/providers/gemini/GeminiChatService.d.ts +104 -0
- package/dist/esm/services/providers/gemini/GeminiChatService.d.ts.map +1 -0
- package/dist/esm/services/providers/gemini/GeminiChatService.js +649 -0
- package/dist/esm/services/providers/gemini/GeminiChatService.js.map +1 -0
- package/dist/esm/services/providers/gemini/GeminiChatServiceProvider.d.ts +40 -0
- package/dist/esm/services/providers/gemini/GeminiChatServiceProvider.d.ts.map +1 -0
- package/dist/esm/services/providers/gemini/GeminiChatServiceProvider.js +66 -0
- package/dist/esm/services/providers/gemini/GeminiChatServiceProvider.js.map +1 -0
- package/dist/esm/services/providers/openai/OpenAIChatService.d.ts +110 -0
- package/dist/esm/services/providers/openai/OpenAIChatService.d.ts.map +1 -0
- package/dist/esm/services/providers/openai/OpenAIChatService.js +540 -0
- package/dist/esm/services/providers/openai/OpenAIChatService.js.map +1 -0
- package/dist/esm/services/providers/openai/OpenAIChatServiceProvider.d.ts +40 -0
- package/dist/esm/services/providers/openai/OpenAIChatServiceProvider.d.ts.map +1 -0
- package/dist/esm/services/providers/openai/OpenAIChatServiceProvider.js +76 -0
- package/dist/esm/services/providers/openai/OpenAIChatServiceProvider.js.map +1 -0
- package/dist/esm/types/chat.d.ts +46 -0
- package/dist/esm/types/chat.d.ts.map +1 -0
- package/dist/esm/types/chat.js +5 -0
- package/dist/esm/types/chat.js.map +1 -0
- package/dist/esm/types/index.d.ts +8 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js +9 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/mcp.d.ts +37 -0
- package/dist/esm/types/mcp.d.ts.map +1 -0
- package/dist/esm/types/mcp.js +5 -0
- package/dist/esm/types/mcp.js.map +1 -0
- package/dist/esm/types/toolChat.d.ts +42 -0
- package/dist/esm/types/toolChat.d.ts.map +1 -0
- package/dist/esm/types/toolChat.js +2 -0
- package/dist/esm/types/toolChat.js.map +1 -0
- package/dist/esm/utils/chatServiceHttpClient.d.ts +47 -0
- package/dist/esm/utils/chatServiceHttpClient.d.ts.map +1 -0
- package/dist/esm/utils/chatServiceHttpClient.js +126 -0
- package/dist/esm/utils/chatServiceHttpClient.js.map +1 -0
- package/dist/esm/utils/emotionParser.d.ts +46 -0
- package/dist/esm/utils/emotionParser.d.ts.map +1 -0
- package/dist/esm/utils/emotionParser.js +55 -0
- package/dist/esm/utils/emotionParser.js.map +1 -0
- package/dist/esm/utils/index.d.ts +8 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/index.js +8 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/mcpSchemaFetcher.d.ts +19 -0
- package/dist/esm/utils/mcpSchemaFetcher.d.ts.map +1 -0
- package/dist/esm/utils/mcpSchemaFetcher.js +94 -0
- package/dist/esm/utils/mcpSchemaFetcher.js.map +1 -0
- package/dist/esm/utils/screenplay.d.ts +20 -0
- package/dist/esm/utils/screenplay.d.ts.map +1 -0
- package/dist/esm/utils/screenplay.js +36 -0
- package/dist/esm/utils/screenplay.js.map +1 -0
- package/dist/esm/utils/streamTextAccumulator.d.ts +25 -0
- package/dist/esm/utils/streamTextAccumulator.d.ts.map +1 -0
- package/dist/esm/utils/streamTextAccumulator.js +43 -0
- package/dist/esm/utils/streamTextAccumulator.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ENDPOINT_OPENAI_CHAT_COMPLETIONS_API, ENDPOINT_OPENAI_RESPONSES_API, MODEL_GPT_4_1, MODEL_GPT_4_1_MINI, MODEL_GPT_4_1_NANO, MODEL_GPT_4O_MINI, MODEL_GPT_4O, MODEL_O3_MINI, MODEL_O1_MINI, MODEL_O1, MODEL_GPT_4_5_PREVIEW, VISION_SUPPORTED_MODELS, } from '../../../constants';
|
|
2
|
+
import { OpenAIChatService } from './OpenAIChatService';
|
|
3
|
+
/**
|
|
4
|
+
* OpenAI API provider implementation
|
|
5
|
+
*/
|
|
6
|
+
export class OpenAIChatServiceProvider {
|
|
7
|
+
/**
|
|
8
|
+
* Create a chat service instance
|
|
9
|
+
* @param options Service options
|
|
10
|
+
* @returns OpenAIChatService instance
|
|
11
|
+
*/
|
|
12
|
+
createChatService(options) {
|
|
13
|
+
// Use the visionModel if provided, otherwise use the model that supports vision
|
|
14
|
+
const visionModel = options.visionModel ||
|
|
15
|
+
(this.supportsVisionForModel(options.model || this.getDefaultModel())
|
|
16
|
+
? options.model
|
|
17
|
+
: this.getDefaultModel());
|
|
18
|
+
// tools definition
|
|
19
|
+
const tools = options.tools;
|
|
20
|
+
// if MCP servers are set, automatically use Responses API
|
|
21
|
+
const mcpServers = options.mcpServers ?? [];
|
|
22
|
+
const shouldUseResponsesAPI = mcpServers.length > 0;
|
|
23
|
+
const endpoint = options.endpoint ||
|
|
24
|
+
(shouldUseResponsesAPI
|
|
25
|
+
? ENDPOINT_OPENAI_RESPONSES_API
|
|
26
|
+
: ENDPOINT_OPENAI_CHAT_COMPLETIONS_API);
|
|
27
|
+
return new OpenAIChatService(options.apiKey, options.model || this.getDefaultModel(), visionModel, tools, endpoint, mcpServers, options.responseLength);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the provider name
|
|
31
|
+
* @returns Provider name ('openai')
|
|
32
|
+
*/
|
|
33
|
+
getProviderName() {
|
|
34
|
+
return 'openai';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get the list of supported models
|
|
38
|
+
* @returns Array of supported model names
|
|
39
|
+
*/
|
|
40
|
+
getSupportedModels() {
|
|
41
|
+
return [
|
|
42
|
+
MODEL_GPT_4_1,
|
|
43
|
+
MODEL_GPT_4_1_MINI,
|
|
44
|
+
MODEL_GPT_4_1_NANO,
|
|
45
|
+
MODEL_GPT_4O_MINI,
|
|
46
|
+
MODEL_GPT_4O,
|
|
47
|
+
MODEL_O3_MINI,
|
|
48
|
+
MODEL_O1_MINI,
|
|
49
|
+
MODEL_O1,
|
|
50
|
+
MODEL_GPT_4_5_PREVIEW,
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get the default model
|
|
55
|
+
* @returns Default model name
|
|
56
|
+
*/
|
|
57
|
+
getDefaultModel() {
|
|
58
|
+
return MODEL_GPT_4O_MINI;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Check if this provider supports vision (image processing)
|
|
62
|
+
* @returns Vision support status (true)
|
|
63
|
+
*/
|
|
64
|
+
supportsVision() {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Check if a specific model supports vision capabilities
|
|
69
|
+
* @param model The model name to check
|
|
70
|
+
* @returns True if the model supports vision, false otherwise
|
|
71
|
+
*/
|
|
72
|
+
supportsVisionForModel(model) {
|
|
73
|
+
return VISION_SUPPORTED_MODELS.includes(model);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=OpenAIChatServiceProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenAIChatServiceProvider.js","sourceRoot":"","sources":["../../../../../src/services/providers/openai/OpenAIChatServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EACpC,6BAA6B,EAC7B,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,QAAQ,EACR,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAOxD;;GAEG;AACH,MAAM,OAAO,yBAAyB;IACpC;;;;OAIG;IACH,iBAAiB,CAAC,OAA2B;QAC3C,gFAAgF;QAChF,MAAM,WAAW,GACf,OAAO,CAAC,WAAW;YACnB,CAAC,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;gBACnE,CAAC,CAAC,OAAO,CAAC,KAAK;gBACf,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;QAE9B,mBAAmB;QACnB,MAAM,KAAK,GAAiC,OAAO,CAAC,KAAK,CAAC;QAE1D,0DAA0D;QAC1D,MAAM,UAAU,GAAI,OAAe,CAAC,UAAU,IAAI,EAAE,CAAC;QACrD,MAAM,qBAAqB,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QACpD,MAAM,QAAQ,GACZ,OAAO,CAAC,QAAQ;YAChB,CAAC,qBAAqB;gBACpB,CAAC,CAAC,6BAA6B;gBAC/B,CAAC,CAAC,oCAAoC,CAAC,CAAC;QAE5C,OAAO,IAAI,iBAAiB,CAC1B,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,eAAe,EAAE,EACvC,WAAW,EACX,KAAK,EACL,QAAQ,EACR,UAAU,EACV,OAAO,CAAC,cAAc,CACvB,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,eAAe;QACb,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACH,kBAAkB;QAChB,OAAO;YACL,aAAa;YACb,kBAAkB;YAClB,kBAAkB;YAClB,iBAAiB;YACjB,YAAY;YACZ,aAAa;YACb,aAAa;YACb,QAAQ;YACR,qBAAqB;SACtB,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,eAAe;QACb,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,sBAAsB,CAAC,KAAa;QAClC,OAAO,uBAAuB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AITuber OnAir Core type definitions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Chat message basic type
|
|
6
|
+
*/
|
|
7
|
+
export interface Message {
|
|
8
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
9
|
+
content: string;
|
|
10
|
+
timestamp?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Vision block type for image content
|
|
14
|
+
*/
|
|
15
|
+
export type VisionBlock = {
|
|
16
|
+
type: 'text';
|
|
17
|
+
text: string;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'image_url';
|
|
20
|
+
image_url: {
|
|
21
|
+
url: string;
|
|
22
|
+
detail?: 'low' | 'high' | 'auto';
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Message type corresponding to vision (image)
|
|
27
|
+
*/
|
|
28
|
+
export interface MessageWithVision {
|
|
29
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
30
|
+
content: string | VisionBlock[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Chat type
|
|
34
|
+
* - chatForm: Chat from text input
|
|
35
|
+
* - youtube: Chat from YouTube comments
|
|
36
|
+
* - vision: Chat from vision (image)
|
|
37
|
+
*/
|
|
38
|
+
export type ChatType = 'chatForm' | 'youtube' | 'vision';
|
|
39
|
+
/**
|
|
40
|
+
* screenplay (text with emotion)
|
|
41
|
+
*/
|
|
42
|
+
export interface Screenplay {
|
|
43
|
+
text: string;
|
|
44
|
+
emotion?: string;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../src/types/chat.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE;QACT,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;KAClC,CAAC;CACH,CAAC;AAEN;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,CAAC;CACjC;AAED;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../../src/types/chat.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AITuber OnAir Chat type definitions
|
|
3
|
+
* Index file: Export all type definitions from here
|
|
4
|
+
*/
|
|
5
|
+
export { Message, MessageWithVision, VisionBlock, ChatType, Screenplay, } from './chat';
|
|
6
|
+
export * from './toolChat';
|
|
7
|
+
export * from './mcp';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,UAAU,GACX,MAAM,QAAQ,CAAC;AAGhB,cAAc,YAAY,CAAC;AAG3B,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,gCAAgC;AAChC,cAAc,YAAY,CAAC;AAE3B,+BAA+B;AAC/B,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Context Protocol (MCP) related types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* MCP server configuration for MCP connector
|
|
6
|
+
* This is a standard configuration format that may be used by multiple providers
|
|
7
|
+
*/
|
|
8
|
+
export interface MCPServerConfig {
|
|
9
|
+
type: 'url';
|
|
10
|
+
url: string;
|
|
11
|
+
name: string;
|
|
12
|
+
tool_configuration?: {
|
|
13
|
+
enabled?: boolean;
|
|
14
|
+
allowed_tools?: string[];
|
|
15
|
+
};
|
|
16
|
+
authorization_token?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Claude-specific MCP tool use block (internal type for Claude)
|
|
20
|
+
*/
|
|
21
|
+
export interface ClaudeMCPToolUseBlock {
|
|
22
|
+
type: 'mcp_tool_use';
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
server_name: string;
|
|
26
|
+
input: any;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Claude-specific MCP tool result block (internal type for Claude)
|
|
30
|
+
*/
|
|
31
|
+
export interface ClaudeMCPToolResultBlock {
|
|
32
|
+
type: 'mcp_tool_result';
|
|
33
|
+
tool_use_id: string;
|
|
34
|
+
is_error: boolean;
|
|
35
|
+
content: any[];
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/types/mcp.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,KAAK,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE;QACnB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1B,CAAC;IACF,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,cAAc,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,iBAAiB,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,GAAG,EAAE,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../../src/types/mcp.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface TextBlock {
|
|
2
|
+
type: 'text';
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ToolUseBlock<P = any> {
|
|
6
|
+
type: 'tool_use';
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
input: P;
|
|
10
|
+
}
|
|
11
|
+
export interface ToolResultBlock {
|
|
12
|
+
type: 'tool_result';
|
|
13
|
+
tool_use_id: string;
|
|
14
|
+
content: string;
|
|
15
|
+
}
|
|
16
|
+
export type CoreToolChatBlock = TextBlock | ToolUseBlock | ToolResultBlock;
|
|
17
|
+
export interface ToolChatCompletion<B = CoreToolChatBlock> {
|
|
18
|
+
blocks: B[];
|
|
19
|
+
stop_reason: 'tool_use' | 'end';
|
|
20
|
+
}
|
|
21
|
+
export type ToolChatBlock = CoreToolChatBlock;
|
|
22
|
+
export type ToolDefinition = {
|
|
23
|
+
name: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
parameters: {
|
|
26
|
+
type: 'object';
|
|
27
|
+
properties?: Record<string, {
|
|
28
|
+
type?: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
enum?: any[];
|
|
31
|
+
items?: any;
|
|
32
|
+
required?: string[];
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}>;
|
|
35
|
+
required?: string[];
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
};
|
|
38
|
+
config?: {
|
|
39
|
+
timeoutMs?: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=toolChat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolChat.d.ts","sourceRoot":"","sources":["../../../src/types/toolChat.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,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 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolChat.js","sourceRoot":"","sources":["../../../src/types/toolChat.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client options
|
|
3
|
+
*/
|
|
4
|
+
export interface HttpClientOptions {
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
timeout?: number;
|
|
7
|
+
retries?: number;
|
|
8
|
+
retryDelay?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* HTTP error response
|
|
12
|
+
*/
|
|
13
|
+
export declare class HttpError extends Error {
|
|
14
|
+
status: number;
|
|
15
|
+
statusText: string;
|
|
16
|
+
body: string;
|
|
17
|
+
constructor(status: number, statusText: string, body: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Unified HTTP client for chat services
|
|
21
|
+
*/
|
|
22
|
+
export declare class ChatServiceHttpClient {
|
|
23
|
+
/**
|
|
24
|
+
* Make a POST request with common error handling
|
|
25
|
+
* @param url Request URL
|
|
26
|
+
* @param body Request body
|
|
27
|
+
* @param headers Request headers
|
|
28
|
+
* @param options Additional options
|
|
29
|
+
* @returns Response object
|
|
30
|
+
*/
|
|
31
|
+
static post(url: string, body: any, headers?: Record<string, string>, options?: HttpClientOptions): Promise<Response>;
|
|
32
|
+
/**
|
|
33
|
+
* Handle error response and throw appropriate error
|
|
34
|
+
* @param res Response object
|
|
35
|
+
* @returns Never (always throws)
|
|
36
|
+
*/
|
|
37
|
+
static handleErrorResponse(res: Response): Promise<never>;
|
|
38
|
+
/**
|
|
39
|
+
* Make a GET request (for fetching images, etc.)
|
|
40
|
+
* @param url Request URL
|
|
41
|
+
* @param headers Request headers
|
|
42
|
+
* @param options Additional options
|
|
43
|
+
* @returns Response object
|
|
44
|
+
*/
|
|
45
|
+
static get(url: string, headers?: Record<string, string>, options?: HttpClientOptions): Promise<Response>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=chatServiceHttpClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatServiceHttpClient.d.ts","sourceRoot":"","sources":["../../../src/utils/chatServiceHttpClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAEzB,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,MAAM;IAClB,IAAI,EAAE,MAAM;gBAFZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM;CAKtB;AAED;;GAEG;AACH,qBAAa,qBAAqB;IAChC;;;;;;;OAOG;WACU,IAAI,CACf,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,GAAG,EACT,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACpC,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,QAAQ,CAAC;IA6DpB;;;;OAIG;WACU,mBAAmB,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;IAK/D;;;;;;OAMG;WACU,GAAG,CACd,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACpC,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,QAAQ,CAAC;CAoDrB"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP error response
|
|
3
|
+
*/
|
|
4
|
+
export class HttpError extends Error {
|
|
5
|
+
constructor(status, statusText, body) {
|
|
6
|
+
super(`HTTP ${status}: ${statusText}`);
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.statusText = statusText;
|
|
9
|
+
this.body = body;
|
|
10
|
+
this.name = 'HttpError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Unified HTTP client for chat services
|
|
15
|
+
*/
|
|
16
|
+
export class ChatServiceHttpClient {
|
|
17
|
+
/**
|
|
18
|
+
* Make a POST request with common error handling
|
|
19
|
+
* @param url Request URL
|
|
20
|
+
* @param body Request body
|
|
21
|
+
* @param headers Request headers
|
|
22
|
+
* @param options Additional options
|
|
23
|
+
* @returns Response object
|
|
24
|
+
*/
|
|
25
|
+
static async post(url, body, headers = {}, options = {}) {
|
|
26
|
+
const { timeout = 30000, retries = 0, retryDelay = 1000 } = options;
|
|
27
|
+
// Default headers
|
|
28
|
+
const defaultHeaders = {
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
};
|
|
31
|
+
const finalHeaders = { ...defaultHeaders, ...headers };
|
|
32
|
+
let lastError = null;
|
|
33
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
34
|
+
try {
|
|
35
|
+
const controller = new AbortController();
|
|
36
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
37
|
+
const response = await fetch(url, {
|
|
38
|
+
method: 'POST',
|
|
39
|
+
headers: finalHeaders,
|
|
40
|
+
body: typeof body === 'string' ? body : JSON.stringify(body),
|
|
41
|
+
signal: controller.signal,
|
|
42
|
+
});
|
|
43
|
+
clearTimeout(timeoutId);
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
const errorBody = await response.text();
|
|
46
|
+
throw new HttpError(response.status, response.statusText, errorBody);
|
|
47
|
+
}
|
|
48
|
+
return response;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
lastError = error;
|
|
52
|
+
// Don't retry on client errors (4xx)
|
|
53
|
+
if (error instanceof HttpError &&
|
|
54
|
+
error.status >= 400 &&
|
|
55
|
+
error.status < 500) {
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
// Don't retry if aborted
|
|
59
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
60
|
+
throw new Error(`Request timeout after ${timeout}ms`);
|
|
61
|
+
}
|
|
62
|
+
// Wait before retrying
|
|
63
|
+
if (attempt < retries) {
|
|
64
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelay * (attempt + 1)));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
throw lastError || new Error('Request failed');
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Handle error response and throw appropriate error
|
|
72
|
+
* @param res Response object
|
|
73
|
+
* @returns Never (always throws)
|
|
74
|
+
*/
|
|
75
|
+
static async handleErrorResponse(res) {
|
|
76
|
+
const errorBody = await res.text();
|
|
77
|
+
throw new HttpError(res.status, res.statusText, errorBody);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Make a GET request (for fetching images, etc.)
|
|
81
|
+
* @param url Request URL
|
|
82
|
+
* @param headers Request headers
|
|
83
|
+
* @param options Additional options
|
|
84
|
+
* @returns Response object
|
|
85
|
+
*/
|
|
86
|
+
static async get(url, headers = {}, options = {}) {
|
|
87
|
+
const { timeout = 30000, retries = 0, retryDelay = 1000 } = options;
|
|
88
|
+
let lastError = null;
|
|
89
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
90
|
+
try {
|
|
91
|
+
const controller = new AbortController();
|
|
92
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
93
|
+
const response = await fetch(url, {
|
|
94
|
+
method: 'GET',
|
|
95
|
+
headers,
|
|
96
|
+
signal: controller.signal,
|
|
97
|
+
});
|
|
98
|
+
clearTimeout(timeoutId);
|
|
99
|
+
if (!response.ok) {
|
|
100
|
+
const errorBody = await response.text();
|
|
101
|
+
throw new HttpError(response.status, response.statusText, errorBody);
|
|
102
|
+
}
|
|
103
|
+
return response;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
lastError = error;
|
|
107
|
+
// Don't retry on client errors (4xx)
|
|
108
|
+
if (error instanceof HttpError &&
|
|
109
|
+
error.status >= 400 &&
|
|
110
|
+
error.status < 500) {
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
// Don't retry if aborted
|
|
114
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
115
|
+
throw new Error(`Request timeout after ${timeout}ms`);
|
|
116
|
+
}
|
|
117
|
+
// Wait before retrying
|
|
118
|
+
if (attempt < retries) {
|
|
119
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelay * (attempt + 1)));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
throw lastError || new Error('Request failed');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=chatServiceHttpClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatServiceHttpClient.js","sourceRoot":"","sources":["../../../src/utils/chatServiceHttpClient.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClC,YACS,MAAc,EACd,UAAkB,EAClB,IAAY;QAEnB,KAAK,CAAC,QAAQ,MAAM,KAAK,UAAU,EAAE,CAAC,CAAC;QAJhC,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAQ;QAClB,SAAI,GAAJ,IAAI,CAAQ;QAGnB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAChC;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,CACf,GAAW,EACX,IAAS,EACT,UAAkC,EAAE,EACpC,UAA6B,EAAE;QAE/B,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,OAAO,GAAG,CAAC,EAAE,UAAU,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;QAEpE,kBAAkB;QAClB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are const emotions: readonly ["happy", "sad", "angry", "surprised", "neutral"];
|
|
2
|
+
type EmotionType = (typeof emotions)[number];
|
|
3
|
+
/**
|
|
4
|
+
* Regular expressions for emotion tag parsing
|
|
5
|
+
*/
|
|
6
|
+
export declare const EMOTION_TAG_REGEX: RegExp;
|
|
7
|
+
export declare const EMOTION_TAG_CLEANUP_REGEX: RegExp;
|
|
8
|
+
/**
|
|
9
|
+
* Result of emotion extraction
|
|
10
|
+
*/
|
|
11
|
+
export interface EmotionExtractionResult {
|
|
12
|
+
emotion?: string;
|
|
13
|
+
cleanText: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Utility class for parsing and handling emotion tags in text
|
|
17
|
+
*/
|
|
18
|
+
export declare class EmotionParser {
|
|
19
|
+
/**
|
|
20
|
+
* Extract emotion from text and return clean text
|
|
21
|
+
* @param text Text that may contain emotion tags like [happy]
|
|
22
|
+
* @returns Object containing extracted emotion and clean text
|
|
23
|
+
*/
|
|
24
|
+
static extractEmotion(text: string): EmotionExtractionResult;
|
|
25
|
+
/**
|
|
26
|
+
* Check if an emotion is valid
|
|
27
|
+
* @param emotion Emotion string to validate
|
|
28
|
+
* @returns True if the emotion is valid
|
|
29
|
+
*/
|
|
30
|
+
static isValidEmotion(emotion: string): emotion is EmotionType;
|
|
31
|
+
/**
|
|
32
|
+
* Remove all emotion tags from text
|
|
33
|
+
* @param text Text containing emotion tags
|
|
34
|
+
* @returns Clean text without emotion tags
|
|
35
|
+
*/
|
|
36
|
+
static cleanEmotionTags(text: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Add emotion tag to text
|
|
39
|
+
* @param emotion Emotion to add
|
|
40
|
+
* @param text Text content
|
|
41
|
+
* @returns Text with emotion tag prepended
|
|
42
|
+
*/
|
|
43
|
+
static addEmotionTag(emotion: string, text: string): string;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=emotionParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emotionParser.d.ts","sourceRoot":"","sources":["../../../src/utils/emotionParser.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,QAAQ,4DAA6D,CAAC;AAC5E,KAAK,WAAW,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAkB,CAAC;AACjD,eAAO,MAAM,yBAAyB,QAAoB,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB;IAe5D;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,WAAW;IAI9D;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI7C;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;CAG5D"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Define emotion types and list locally to avoid dependency on voice package
|
|
2
|
+
const emotions = ['happy', 'sad', 'angry', 'surprised', 'neutral'];
|
|
3
|
+
/**
|
|
4
|
+
* Regular expressions for emotion tag parsing
|
|
5
|
+
*/
|
|
6
|
+
export const EMOTION_TAG_REGEX = /\[([a-z]+)\]/i;
|
|
7
|
+
export const EMOTION_TAG_CLEANUP_REGEX = /\[[a-z]+\]\s*/gi;
|
|
8
|
+
/**
|
|
9
|
+
* Utility class for parsing and handling emotion tags in text
|
|
10
|
+
*/
|
|
11
|
+
export class EmotionParser {
|
|
12
|
+
/**
|
|
13
|
+
* Extract emotion from text and return clean text
|
|
14
|
+
* @param text Text that may contain emotion tags like [happy]
|
|
15
|
+
* @returns Object containing extracted emotion and clean text
|
|
16
|
+
*/
|
|
17
|
+
static extractEmotion(text) {
|
|
18
|
+
const match = text.match(EMOTION_TAG_REGEX);
|
|
19
|
+
if (match) {
|
|
20
|
+
const emotion = match[1].toLowerCase();
|
|
21
|
+
const cleanText = text.replace(EMOTION_TAG_CLEANUP_REGEX, '').trim();
|
|
22
|
+
return {
|
|
23
|
+
emotion,
|
|
24
|
+
cleanText,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return { cleanText: text };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Check if an emotion is valid
|
|
31
|
+
* @param emotion Emotion string to validate
|
|
32
|
+
* @returns True if the emotion is valid
|
|
33
|
+
*/
|
|
34
|
+
static isValidEmotion(emotion) {
|
|
35
|
+
return emotions.includes(emotion);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Remove all emotion tags from text
|
|
39
|
+
* @param text Text containing emotion tags
|
|
40
|
+
* @returns Clean text without emotion tags
|
|
41
|
+
*/
|
|
42
|
+
static cleanEmotionTags(text) {
|
|
43
|
+
return text.replace(EMOTION_TAG_CLEANUP_REGEX, '').trim();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Add emotion tag to text
|
|
47
|
+
* @param emotion Emotion to add
|
|
48
|
+
* @param text Text content
|
|
49
|
+
* @returns Text with emotion tag prepended
|
|
50
|
+
*/
|
|
51
|
+
static addEmotionTag(emotion, text) {
|
|
52
|
+
return `[${emotion}] ${text}`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=emotionParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emotionParser.js","sourceRoot":"","sources":["../../../src/utils/emotionParser.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,E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,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ToolDefinition, MCPServerConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* MCP server schema fetcher for SDK-less implementation
|
|
4
|
+
*/
|
|
5
|
+
export declare class MCPSchemaFetcher {
|
|
6
|
+
/**
|
|
7
|
+
* Fetch tool schemas from MCP server
|
|
8
|
+
* @param serverConfig MCP server configuration
|
|
9
|
+
* @returns Array of tool definitions
|
|
10
|
+
*/
|
|
11
|
+
static fetchToolSchemas(serverConfig: MCPServerConfig): Promise<ToolDefinition[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Fetch all tool schemas from multiple MCP servers
|
|
14
|
+
* @param mcpServers Array of MCP server configurations
|
|
15
|
+
* @returns Array of all tool definitions
|
|
16
|
+
*/
|
|
17
|
+
static fetchAllToolSchemas(mcpServers: MCPServerConfig[]): Promise<ToolDefinition[]>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=mcpSchemaFetcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpSchemaFetcher.d.ts","sourceRoot":"","sources":["../../../src/utils/mcpSchemaFetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3D;;GAEG;AACH,qBAAa,gBAAgB;IAC3B;;;;OAIG;WACU,gBAAgB,CAC3B,YAAY,EAAE,eAAe,GAC5B,OAAO,CAAC,cAAc,EAAE,CAAC;IA8E5B;;;;OAIG;WACU,mBAAmB,CAC9B,UAAU,EAAE,eAAe,EAAE,GAC5B,OAAO,CAAC,cAAc,EAAE,CAAC;CAc7B"}
|