@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,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenAIChatServiceProvider = void 0;
|
|
4
|
+
const constants_1 = require("../../../constants");
|
|
5
|
+
const OpenAIChatService_1 = require("./OpenAIChatService");
|
|
6
|
+
/**
|
|
7
|
+
* OpenAI API provider implementation
|
|
8
|
+
*/
|
|
9
|
+
class OpenAIChatServiceProvider {
|
|
10
|
+
/**
|
|
11
|
+
* Create a chat service instance
|
|
12
|
+
* @param options Service options
|
|
13
|
+
* @returns OpenAIChatService instance
|
|
14
|
+
*/
|
|
15
|
+
createChatService(options) {
|
|
16
|
+
// Use the visionModel if provided, otherwise use the model that supports vision
|
|
17
|
+
const visionModel = options.visionModel ||
|
|
18
|
+
(this.supportsVisionForModel(options.model || this.getDefaultModel())
|
|
19
|
+
? options.model
|
|
20
|
+
: this.getDefaultModel());
|
|
21
|
+
// tools definition
|
|
22
|
+
const tools = options.tools;
|
|
23
|
+
// if MCP servers are set, automatically use Responses API
|
|
24
|
+
const mcpServers = options.mcpServers ?? [];
|
|
25
|
+
const shouldUseResponsesAPI = mcpServers.length > 0;
|
|
26
|
+
const endpoint = options.endpoint ||
|
|
27
|
+
(shouldUseResponsesAPI
|
|
28
|
+
? constants_1.ENDPOINT_OPENAI_RESPONSES_API
|
|
29
|
+
: constants_1.ENDPOINT_OPENAI_CHAT_COMPLETIONS_API);
|
|
30
|
+
return new OpenAIChatService_1.OpenAIChatService(options.apiKey, options.model || this.getDefaultModel(), visionModel, tools, endpoint, mcpServers, options.responseLength);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get the provider name
|
|
34
|
+
* @returns Provider name ('openai')
|
|
35
|
+
*/
|
|
36
|
+
getProviderName() {
|
|
37
|
+
return 'openai';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get the list of supported models
|
|
41
|
+
* @returns Array of supported model names
|
|
42
|
+
*/
|
|
43
|
+
getSupportedModels() {
|
|
44
|
+
return [
|
|
45
|
+
constants_1.MODEL_GPT_4_1,
|
|
46
|
+
constants_1.MODEL_GPT_4_1_MINI,
|
|
47
|
+
constants_1.MODEL_GPT_4_1_NANO,
|
|
48
|
+
constants_1.MODEL_GPT_4O_MINI,
|
|
49
|
+
constants_1.MODEL_GPT_4O,
|
|
50
|
+
constants_1.MODEL_O3_MINI,
|
|
51
|
+
constants_1.MODEL_O1_MINI,
|
|
52
|
+
constants_1.MODEL_O1,
|
|
53
|
+
constants_1.MODEL_GPT_4_5_PREVIEW,
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get the default model
|
|
58
|
+
* @returns Default model name
|
|
59
|
+
*/
|
|
60
|
+
getDefaultModel() {
|
|
61
|
+
return constants_1.MODEL_GPT_4O_MINI;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Check if this provider supports vision (image processing)
|
|
65
|
+
* @returns Vision support status (true)
|
|
66
|
+
*/
|
|
67
|
+
supportsVision() {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Check if a specific model supports vision capabilities
|
|
72
|
+
* @param model The model name to check
|
|
73
|
+
* @returns True if the model supports vision, false otherwise
|
|
74
|
+
*/
|
|
75
|
+
supportsVisionForModel(model) {
|
|
76
|
+
return constants_1.VISION_SUPPORTED_MODELS.includes(model);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.OpenAIChatServiceProvider = OpenAIChatServiceProvider;
|
|
80
|
+
//# sourceMappingURL=OpenAIChatServiceProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenAIChatServiceProvider.js","sourceRoot":"","sources":["../../../../../src/services/providers/openai/OpenAIChatServiceProvider.ts"],"names":[],"mappings":";;;AAAA,kDAa4B;AAE5B,2DAAwD;AAOxD;;GAEG;AACH,MAAa,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,yCAA6B;gBAC/B,CAAC,CAAC,gDAAoC,CAAC,CAAC;QAE5C,OAAO,IAAI,qCAAiB,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,yBAAa;YACb,8BAAkB;YAClB,8BAAkB;YAClB,6BAAiB;YACjB,wBAAY;YACZ,yBAAa;YACb,yBAAa;YACb,oBAAQ;YACR,iCAAqB;SACtB,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,eAAe;QACb,OAAO,6BAAiB,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,sBAAsB,CAAC,KAAa;QAClC,OAAO,mCAAuB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;CACF;AAvFD,8DAuFC"}
|
|
@@ -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,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AITuber OnAir Chat type definitions
|
|
4
|
+
* Index file: Export all type definitions from here
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
// Tool related type definitions
|
|
22
|
+
__exportStar(require("./toolChat"), exports);
|
|
23
|
+
// MCP related type definitions
|
|
24
|
+
__exportStar(require("./mcp"), exports);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAWH,gCAAgC;AAChC,6CAA2B;AAE3B,+BAA+B;AAC/B,wCAAsB"}
|
|
@@ -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,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,GAAG;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,CAAC,CAAC;CACV;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,YAAY,GAAG,eAAe,CAAC;AAE3E,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,iBAAiB;IACvD,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,WAAW,EAAE,UAAU,GAAG,KAAK,CAAC;CACjC;AACD,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CACjB,MAAM,EACN;YACE,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;YACb,KAAK,CAAC,EAAE,GAAG,CAAC;YACZ,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;YACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;SACpB,CACF,CAAC;QACF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,MAAM,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACjC,CAAC"}
|
|
@@ -0,0 +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,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChatServiceHttpClient = exports.HttpError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* HTTP error response
|
|
6
|
+
*/
|
|
7
|
+
class HttpError extends Error {
|
|
8
|
+
constructor(status, statusText, body) {
|
|
9
|
+
super(`HTTP ${status}: ${statusText}`);
|
|
10
|
+
this.status = status;
|
|
11
|
+
this.statusText = statusText;
|
|
12
|
+
this.body = body;
|
|
13
|
+
this.name = 'HttpError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.HttpError = HttpError;
|
|
17
|
+
/**
|
|
18
|
+
* Unified HTTP client for chat services
|
|
19
|
+
*/
|
|
20
|
+
class ChatServiceHttpClient {
|
|
21
|
+
/**
|
|
22
|
+
* Make a POST request with common error handling
|
|
23
|
+
* @param url Request URL
|
|
24
|
+
* @param body Request body
|
|
25
|
+
* @param headers Request headers
|
|
26
|
+
* @param options Additional options
|
|
27
|
+
* @returns Response object
|
|
28
|
+
*/
|
|
29
|
+
static async post(url, body, headers = {}, options = {}) {
|
|
30
|
+
const { timeout = 30000, retries = 0, retryDelay = 1000 } = options;
|
|
31
|
+
// Default headers
|
|
32
|
+
const defaultHeaders = {
|
|
33
|
+
'Content-Type': 'application/json',
|
|
34
|
+
};
|
|
35
|
+
const finalHeaders = { ...defaultHeaders, ...headers };
|
|
36
|
+
let lastError = null;
|
|
37
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
38
|
+
try {
|
|
39
|
+
const controller = new AbortController();
|
|
40
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
41
|
+
const response = await fetch(url, {
|
|
42
|
+
method: 'POST',
|
|
43
|
+
headers: finalHeaders,
|
|
44
|
+
body: typeof body === 'string' ? body : JSON.stringify(body),
|
|
45
|
+
signal: controller.signal,
|
|
46
|
+
});
|
|
47
|
+
clearTimeout(timeoutId);
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
const errorBody = await response.text();
|
|
50
|
+
throw new HttpError(response.status, response.statusText, errorBody);
|
|
51
|
+
}
|
|
52
|
+
return response;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
lastError = error;
|
|
56
|
+
// Don't retry on client errors (4xx)
|
|
57
|
+
if (error instanceof HttpError &&
|
|
58
|
+
error.status >= 400 &&
|
|
59
|
+
error.status < 500) {
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
// Don't retry if aborted
|
|
63
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
64
|
+
throw new Error(`Request timeout after ${timeout}ms`);
|
|
65
|
+
}
|
|
66
|
+
// Wait before retrying
|
|
67
|
+
if (attempt < retries) {
|
|
68
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelay * (attempt + 1)));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
throw lastError || new Error('Request failed');
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Handle error response and throw appropriate error
|
|
76
|
+
* @param res Response object
|
|
77
|
+
* @returns Never (always throws)
|
|
78
|
+
*/
|
|
79
|
+
static async handleErrorResponse(res) {
|
|
80
|
+
const errorBody = await res.text();
|
|
81
|
+
throw new HttpError(res.status, res.statusText, errorBody);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Make a GET request (for fetching images, etc.)
|
|
85
|
+
* @param url Request URL
|
|
86
|
+
* @param headers Request headers
|
|
87
|
+
* @param options Additional options
|
|
88
|
+
* @returns Response object
|
|
89
|
+
*/
|
|
90
|
+
static async get(url, headers = {}, options = {}) {
|
|
91
|
+
const { timeout = 30000, retries = 0, retryDelay = 1000 } = options;
|
|
92
|
+
let lastError = null;
|
|
93
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
94
|
+
try {
|
|
95
|
+
const controller = new AbortController();
|
|
96
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
97
|
+
const response = await fetch(url, {
|
|
98
|
+
method: 'GET',
|
|
99
|
+
headers,
|
|
100
|
+
signal: controller.signal,
|
|
101
|
+
});
|
|
102
|
+
clearTimeout(timeoutId);
|
|
103
|
+
if (!response.ok) {
|
|
104
|
+
const errorBody = await response.text();
|
|
105
|
+
throw new HttpError(response.status, response.statusText, errorBody);
|
|
106
|
+
}
|
|
107
|
+
return response;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
lastError = error;
|
|
111
|
+
// Don't retry on client errors (4xx)
|
|
112
|
+
if (error instanceof HttpError &&
|
|
113
|
+
error.status >= 400 &&
|
|
114
|
+
error.status < 500) {
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
// Don't retry if aborted
|
|
118
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
119
|
+
throw new Error(`Request timeout after ${timeout}ms`);
|
|
120
|
+
}
|
|
121
|
+
// Wait before retrying
|
|
122
|
+
if (attempt < retries) {
|
|
123
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelay * (attempt + 1)));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
throw lastError || new Error('Request failed');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.ChatServiceHttpClient = ChatServiceHttpClient;
|
|
131
|
+
//# sourceMappingURL=chatServiceHttpClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatServiceHttpClient.js","sourceRoot":"","sources":["../../../src/utils/chatServiceHttpClient.ts"],"names":[],"mappings":";;;AAUA;;GAEG;AACH,MAAa,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;AATD,8BASC;AAED;;GAEG;AACH,MAAa,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,MAAM,cAAc,GAA2B;YAC7C,cAAc,EAAE,kBAAkB;SACnC,CAAC;QAEF,MAAM,YAAY,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,EAAE,CAAC;QAEvD,IAAI,SAAS,GAAiB,IAAI,CAAC;QAEnC,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC;YACpD,IAAI,CAAC;gBACH,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;gBACzC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;gBAEhE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;oBAChC,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE,YAAY;oBACrB,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;oBAC5D,MAAM,EAAE,UAAU,CAAC,MAAM;iBAC1B,CAAC,CAAC;gBAEH,YAAY,CAAC,SAAS,CAAC,CAAC;gBAExB,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;oBACxC,MAAM,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;gBACvE,CAAC;gBAED,OAAO,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,SAAS,GAAG,KAAc,CAAC;gBAE3B,qCAAqC;gBACrC,IACE,KAAK,YAAY,SAAS;oBAC1B,KAAK,CAAC,MAAM,IAAI,GAAG;oBACnB,KAAK,CAAC,MAAM,GAAG,GAAG,EAClB,CAAC;oBACD,MAAM,KAAK,CAAC;gBACd,CAAC;gBAED,yBAAyB;gBACzB,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBAC1D,MAAM,IAAI,KAAK,CAAC,yBAAyB,OAAO,IAAI,CAAC,CAAC;gBACxD,CAAC;gBAED,uBAAuB;gBACvB,IAAI,OAAO,GAAG,OAAO,EAAE,CAAC;oBACtB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAC5B,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAChD,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,SAAS,IAAI,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACjD,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAa;QAC5C,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,IAAI,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,CACd,GAAW,EACX,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,IAAI,SAAS,GAAiB,IAAI,CAAC;QAEnC,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC;YACpD,IAAI,CAAC;gBACH,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;gBACzC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;gBAEhE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;oBAChC,MAAM,EAAE,KAAK;oBACb,OAAO;oBACP,MAAM,EAAE,UAAU,CAAC,MAAM;iBAC1B,CAAC,CAAC;gBAEH,YAAY,CAAC,SAAS,CAAC,CAAC;gBAExB,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;oBACxC,MAAM,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;gBACvE,CAAC;gBAED,OAAO,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,SAAS,GAAG,KAAc,CAAC;gBAE3B,qCAAqC;gBACrC,IACE,KAAK,YAAY,SAAS;oBAC1B,KAAK,CAAC,MAAM,IAAI,GAAG;oBACnB,KAAK,CAAC,MAAM,GAAG,GAAG,EAClB,CAAC;oBACD,MAAM,KAAK,CAAC;gBACd,CAAC;gBAED,yBAAyB;gBACzB,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBAC1D,MAAM,IAAI,KAAK,CAAC,yBAAyB,OAAO,IAAI,CAAC,CAAC;gBACxD,CAAC;gBAED,uBAAuB;gBACvB,IAAI,OAAO,GAAG,OAAO,EAAE,CAAC;oBACtB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAC5B,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAChD,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,SAAS,IAAI,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACjD,CAAC;CACF;AApJD,sDAoJC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
declare 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,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmotionParser = exports.EMOTION_TAG_CLEANUP_REGEX = exports.EMOTION_TAG_REGEX = void 0;
|
|
4
|
+
// Define emotion types and list locally to avoid dependency on voice package
|
|
5
|
+
const emotions = ['happy', 'sad', 'angry', 'surprised', 'neutral'];
|
|
6
|
+
/**
|
|
7
|
+
* Regular expressions for emotion tag parsing
|
|
8
|
+
*/
|
|
9
|
+
exports.EMOTION_TAG_REGEX = /\[([a-z]+)\]/i;
|
|
10
|
+
exports.EMOTION_TAG_CLEANUP_REGEX = /\[[a-z]+\]\s*/gi;
|
|
11
|
+
/**
|
|
12
|
+
* Utility class for parsing and handling emotion tags in text
|
|
13
|
+
*/
|
|
14
|
+
class EmotionParser {
|
|
15
|
+
/**
|
|
16
|
+
* Extract emotion from text and return clean text
|
|
17
|
+
* @param text Text that may contain emotion tags like [happy]
|
|
18
|
+
* @returns Object containing extracted emotion and clean text
|
|
19
|
+
*/
|
|
20
|
+
static extractEmotion(text) {
|
|
21
|
+
const match = text.match(exports.EMOTION_TAG_REGEX);
|
|
22
|
+
if (match) {
|
|
23
|
+
const emotion = match[1].toLowerCase();
|
|
24
|
+
const cleanText = text.replace(exports.EMOTION_TAG_CLEANUP_REGEX, '').trim();
|
|
25
|
+
return {
|
|
26
|
+
emotion,
|
|
27
|
+
cleanText,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return { cleanText: text };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Check if an emotion is valid
|
|
34
|
+
* @param emotion Emotion string to validate
|
|
35
|
+
* @returns True if the emotion is valid
|
|
36
|
+
*/
|
|
37
|
+
static isValidEmotion(emotion) {
|
|
38
|
+
return emotions.includes(emotion);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Remove all emotion tags from text
|
|
42
|
+
* @param text Text containing emotion tags
|
|
43
|
+
* @returns Clean text without emotion tags
|
|
44
|
+
*/
|
|
45
|
+
static cleanEmotionTags(text) {
|
|
46
|
+
return text.replace(exports.EMOTION_TAG_CLEANUP_REGEX, '').trim();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Add emotion tag to text
|
|
50
|
+
* @param emotion Emotion to add
|
|
51
|
+
* @param text Text content
|
|
52
|
+
* @returns Text with emotion tag prepended
|
|
53
|
+
*/
|
|
54
|
+
static addEmotionTag(emotion, text) {
|
|
55
|
+
return `[${emotion}] ${text}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.EmotionParser = EmotionParser;
|
|
59
|
+
//# 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,EAAE,WAAW,EAAE,SAAS,CAAU,CAAC;AAG5E;;GAEG;AACU,QAAA,iBAAiB,GAAG,eAAe,CAAC;AACpC,QAAA,yBAAyB,GAAG,iBAAiB,CAAC;AAU3D;;GAEG;AACH,MAAa,aAAa;IACxB;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,IAAY;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,yBAAiB,CAAC,CAAC;QAE5C,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,iCAAyB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YACrE,OAAO;gBACL,OAAO;gBACP,SAAS;aACV,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,OAAe;QACnC,OAAO,QAAQ,CAAC,QAAQ,CAAC,OAAc,CAAC,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAY;QAClC,OAAO,IAAI,CAAC,OAAO,CAAC,iCAAyB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5D,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,OAAe,EAAE,IAAY;QAChD,OAAO,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;IAChC,CAAC;CACF;AAhDD,sCAgDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","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,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* Utilities for AITuber OnAir Chat
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("./chatServiceHttpClient"), exports);
|
|
21
|
+
__exportStar(require("./streamTextAccumulator"), exports);
|
|
22
|
+
__exportStar(require("./screenplay"), exports);
|
|
23
|
+
__exportStar(require("./emotionParser"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,0DAAwC;AACxC,0DAAwC;AACxC,+CAA6B;AAC7B,kDAAgC"}
|