@wabot-dev/framework 0.1.0-beta.29 → 0.1.0-beta.30

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.
Files changed (153) hide show
  1. package/dist/src/addon/async/pg/PgJobRepository.js +26 -0
  2. package/dist/src/addon/chat-bot/claude/ClaudeChatBotAdapter.js +107 -0
  3. package/dist/src/addon/chat-bot/deepseek/DeepSeekChatBotAdapter.js +103 -0
  4. package/dist/src/{ai → addon/chat-bot}/openia/OpenaiChatAdapter.js +3 -3
  5. package/dist/src/{pre-made/repository/chat → addon/chat-bot}/pg/PgChatMemory.js +5 -4
  6. package/dist/src/{pre-made/repository/chat → addon/chat-bot}/pg/PgChatRepository.js +5 -5
  7. package/dist/src/{pre-made/repository/chat → addon/chat-bot}/ram/RamChatRepository.js +1 -1
  8. package/dist/src/addon/chat-controller/cmd/@cmd.js +22 -0
  9. package/dist/src/{channels → addon/chat-controller}/cmd/CmdChannel.js +5 -27
  10. package/dist/src/{channels → addon/chat-controller}/socket/@socket.js +8 -4
  11. package/dist/src/{channels → addon/chat-controller}/socket/SocketChannel.js +6 -24
  12. package/dist/src/{channels → addon/chat-controller}/socket/SocketChannelConfig.js +1 -1
  13. package/dist/src/{channels → addon/chat-controller}/telegram/@telegram.js +8 -4
  14. package/dist/src/{channels → addon/chat-controller}/telegram/TelegramChannel.js +5 -23
  15. package/dist/src/{channels → addon/chat-controller}/whatsapp/@whatsapp.js +8 -4
  16. package/dist/src/{channels → addon/chat-controller}/whatsapp/EnvWhatsAppRepository.js +2 -2
  17. package/dist/src/{channels → addon/chat-controller}/whatsapp/PgWhatsAppRepository.js +1 -1
  18. package/dist/src/{channels/wabot → addon/chat-controller/whatsapp}/WabotDevConnection.js +2 -2
  19. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsApp.js +1 -3
  20. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppChannel.js +6 -18
  21. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppReceiver.js +13 -10
  22. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppReceiverByDevConnection.js +3 -9
  23. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppReceiverByWebHook.js +2 -9
  24. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSender.js +12 -7
  25. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSenderByCloudApi.js +10 -7
  26. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSenderByDevConnection.js +12 -9
  27. package/dist/src/{pre-made/module → addon/mindset}/html/HtmlModule.js +6 -6
  28. package/dist/src/{repository → addon/repository}/pg/PgCrudRepository.js +1 -1
  29. package/dist/src/addon/rest-controller/jwt/@jwtGuard.js +17 -0
  30. package/dist/src/{jwt → addon/rest-controller/jwt}/Jwt.js +7 -2
  31. package/dist/src/{jwt → addon/rest-controller/jwt}/JwtAccessAndRefreshTokenDto.js +3 -3
  32. package/dist/src/{jwt → addon/rest-controller/jwt}/JwtConfig.js +2 -2
  33. package/dist/src/{jwt → addon/rest-controller/jwt}/JwtGuardMiddleware.js +8 -3
  34. package/dist/src/addon/rest-controller/jwt/JwtRefreshToken.js +9 -0
  35. package/dist/src/{jwt → addon/rest-controller/jwt}/JwtRefreshTokenRepository.js +2 -2
  36. package/dist/src/{jwt → addon/rest-controller/jwt}/JwtSigner.js +2 -2
  37. package/dist/src/{jwt → addon/rest-controller/jwt}/JwtTokenDto.js +5 -5
  38. package/dist/src/{validation/metadata → addon/validation/is-boolean}/@isBoolean.js +3 -3
  39. package/dist/src/{validation/metadata → addon/validation/is-date}/@isDate.js +3 -3
  40. package/dist/src/{validation/metadata → addon/validation/is-not-empty}/@isNotEmpty.js +3 -3
  41. package/dist/src/{validation/metadata → addon/validation/is-number}/@isNumber.js +3 -3
  42. package/dist/src/{validation/metadata → addon/validation/is-present}/@isPresent.js +3 -3
  43. package/dist/src/{validation/metadata → addon/validation/is-string}/@isString.js +3 -3
  44. package/dist/src/{validation/metadata → addon/validation/max}/@max.js +3 -3
  45. package/dist/src/{validation/metadata → addon/validation/min}/@min.js +3 -3
  46. package/dist/src/core/{Entity.js → entity/Entity.js} +1 -1
  47. package/dist/src/{mapper → core/mapper}/Mapper.js +1 -3
  48. package/dist/src/{async → feature/async}/@command.js +1 -1
  49. package/dist/src/{async → feature/async}/@commandHandler.js +1 -1
  50. package/dist/src/{async → feature/async}/Async.js +1 -1
  51. package/dist/src/feature/async/Command.js +9 -0
  52. package/dist/src/{async → feature/async}/CommandMetadataStore.js +1 -1
  53. package/dist/src/{async → feature/async}/Job.js +2 -4
  54. package/dist/src/feature/async/JobRepository.js +31 -0
  55. package/dist/src/{async → feature/async}/JobRunner.js +1 -1
  56. package/dist/src/{async → feature/async}/JobsEventsHub.js +1 -1
  57. package/dist/src/{async → feature/async}/runCommandHandlers.js +1 -1
  58. package/dist/src/{core/chat → feature/chat-bot}/Chat.js +1 -1
  59. package/dist/src/feature/chat-bot/ChatAdapter.js +7 -0
  60. package/dist/src/feature/chat-bot/ChatBot.js +50 -0
  61. package/dist/src/feature/chat-bot/ChatItem.js +24 -0
  62. package/dist/src/feature/chat-bot/ChatMemory.js +10 -0
  63. package/dist/src/{core/chat/repository/IChatRepository.js → feature/chat-bot/ChatRepository.js} +2 -8
  64. package/dist/src/feature/chat-bot/IChatItem.js +3 -0
  65. package/dist/src/{chatbot → feature/chat-bot}/metadata/@chatBot.js +1 -1
  66. package/dist/src/{chatbot → feature/chat-bot}/metadata/ChatBotMetadataStore.js +1 -1
  67. package/dist/src/{controller/channel → feature/chat-controller}/ChatResolver.js +5 -4
  68. package/dist/src/{controller → feature/chat-controller}/metadata/ControllerMetadataStore.js +1 -1
  69. package/dist/src/{controller → feature/chat-controller}/metadata/controller/@chatController.js +1 -1
  70. package/dist/src/feature/chat-controller/runChatControllers.js +69 -0
  71. package/dist/src/{channels → feature}/express/ExpressProvider.js +1 -1
  72. package/dist/src/{channels → feature}/http/HttpServerProvider.js +1 -1
  73. package/dist/src/{mindset → feature/mindset}/MindsetOperator.js +2 -61
  74. package/dist/src/{mindset → feature/mindset}/metadata/MindsetMetadataStore.js +1 -1
  75. package/dist/src/{mindset → feature/mindset}/metadata/functions/@mindsetFunction.js +1 -1
  76. package/dist/src/{mindset → feature/mindset}/metadata/mindsets/@mindset.js +1 -1
  77. package/dist/src/{mindset → feature/mindset}/metadata/modules/@mindsetModule.js +1 -2
  78. package/dist/src/{mindset → feature/mindset}/metadata/params/@param.js +1 -1
  79. package/dist/src/{auth → feature/rest-controller/auth}/Auth.js +2 -2
  80. package/dist/src/{rest-controller → feature/rest-controller}/metadata/@get.js +1 -1
  81. package/dist/src/{rest-controller → feature/rest-controller}/metadata/@middleware.js +1 -1
  82. package/dist/src/{rest-controller → feature/rest-controller}/metadata/@post.js +1 -1
  83. package/dist/src/{rest-controller → feature/rest-controller}/metadata/@restController.js +1 -1
  84. package/dist/src/{rest-controller → feature/rest-controller}/metadata/RestControllerMetadataStore.js +1 -1
  85. package/dist/src/{rest-controller → feature/rest-controller}/runRestControllers.js +6 -24
  86. package/dist/src/{channels → feature}/socket/SocketServerProvider.js +1 -1
  87. package/dist/src/index.d.ts +550 -724
  88. package/dist/src/index.js +118 -133
  89. package/package.json +1 -1
  90. package/dist/src/ai/claude/ClaudeChatBotAdapter.js +0 -112
  91. package/dist/src/ai/deepseek/DeepSeekChatBotAdapter.js +0 -107
  92. package/dist/src/ai/openia/OpenaiChatBotAdapter.js +0 -88
  93. package/dist/src/async/Command.js +0 -11
  94. package/dist/src/async/JobRepository.js +0 -21
  95. package/dist/src/channels/cmd/@cmd.js +0 -18
  96. package/dist/src/chatbot/ChatBot.js +0 -50
  97. package/dist/src/chatbot/ChatBotAdapter.js +0 -70
  98. package/dist/src/controller/channel/UserResolver.js +0 -21
  99. package/dist/src/core/IMessageContext.js +0 -12
  100. package/dist/src/core/chat/ChatItem.js +0 -15
  101. package/dist/src/core/chat/IChatAdapter.js +0 -3
  102. package/dist/src/core/chat/repository/IChatMemory.js +0 -10
  103. package/dist/src/core/user/IUserRepository.js +0 -19
  104. package/dist/src/core/user/User.js +0 -26
  105. package/dist/src/jwt/@jwtGuard.js +0 -34
  106. package/dist/src/jwt/JwtRefreshToken.js +0 -11
  107. package/dist/src/pre-made/module/authentication/AuthenticationModule.js +0 -97
  108. package/dist/src/pre-made/module/authentication/requests/SendOneTimePasswordRequest.js +0 -25
  109. package/dist/src/pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js +0 -25
  110. package/dist/src/pre-made/module/register-user/RegisterUserModule.js +0 -56
  111. package/dist/src/pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js +0 -25
  112. package/dist/src/pre-made/repository/user/pg/PgUserRepository.js +0 -33
  113. package/dist/src/pre-made/repository/user/ram/RamUserRepository.js +0 -27
  114. package/dist/src/pre-made/service/EmailService.js +0 -13
  115. package/dist/src/pre-made/service/OtpService.js +0 -14
  116. package/dist/src/server/prepareChatContainer.js +0 -43
  117. package/dist/src/server/runChannel.js +0 -27
  118. package/dist/src/server/runServer.js +0 -40
  119. /package/dist/src/{pre-made/repository/chat → addon/chat-bot}/ram/RamChatMemory.js +0 -0
  120. /package/dist/src/{channels → addon/chat-controller}/telegram/TelegramChannelConfig.js +0 -0
  121. /package/dist/src/{channels/wabot → addon/chat-controller/whatsapp}/WabotDevSocketContracts.js +0 -0
  122. /package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppChannelConfig.js +0 -0
  123. /package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppRepository.js +0 -0
  124. /package/dist/src/{repository → addon/repository}/pg/PgRepositoryBase.js +0 -0
  125. /package/dist/src/{validation/validators → addon/validation/is-boolean}/validateIsBoolean.js +0 -0
  126. /package/dist/src/{validation/validators → addon/validation/is-date}/validateIsDate.js +0 -0
  127. /package/dist/src/{validation/validators → addon/validation/is-not-empty}/validateIsNotEmpty.js +0 -0
  128. /package/dist/src/{validation/validators → addon/validation/is-number}/validateIsNumber.js +0 -0
  129. /package/dist/src/{validation/validators → addon/validation/is-present}/validateIsPresent.js +0 -0
  130. /package/dist/src/{validation/validators → addon/validation/is-string}/validateIsString.js +0 -0
  131. /package/dist/src/{validation/validators → addon/validation/max}/validateMax.js +0 -0
  132. /package/dist/src/{validation/validators → addon/validation/min}/validateMin.js +0 -0
  133. /package/dist/src/{env → core/env}/Env.js +0 -0
  134. /package/dist/src/{error → core/error}/CustomError.js +0 -0
  135. /package/dist/src/{injection → core/injection}/Container.js +0 -0
  136. /package/dist/src/{injection → core/injection}/index.js +0 -0
  137. /package/dist/src/{logger → core/logger}/Logger.js +0 -0
  138. /package/dist/src/{random → core/random}/Random.js +0 -0
  139. /package/dist/src/core/{Storable.js → storable/Storable.js} +0 -0
  140. /package/dist/src/{validation → core/validation}/metadata/@isArray.js +0 -0
  141. /package/dist/src/{validation → core/validation}/metadata/@isModel.js +0 -0
  142. /package/dist/src/{validation → core/validation}/metadata/@isOptional.js +0 -0
  143. /package/dist/src/{validation → core/validation}/metadata/ValidationMetadataStore.js +0 -0
  144. /package/dist/src/{validation → core/validation}/modelInfo.js +0 -0
  145. /package/dist/src/{validation → core/validation}/validate.js +0 -0
  146. /package/dist/src/{validation → core/validation}/validators/validateArray.js +0 -0
  147. /package/dist/src/{validation → core/validation}/validators/validateIsOptional.js +0 -0
  148. /package/dist/src/{validation → core/validation}/validators/validateModel.js +0 -0
  149. /package/dist/src/{mindset → feature/mindset}/IMindset.js +0 -0
  150. /package/dist/src/{mindset → feature/mindset}/metadata/functions/decoratorNames.js +0 -0
  151. /package/dist/src/{mindset → feature/mindset}/metadata/mindsets/decoratorNames.js +0 -0
  152. /package/dist/src/{mindset → feature/mindset}/metadata/modules/decoratorNames.js +0 -0
  153. /package/dist/src/{mindset → feature/mindset}/metadata/params/decoratorNames.js +0 -0
@@ -0,0 +1,26 @@
1
+ import { __decorate, __metadata } from 'tslib';
2
+ import { Pool } from 'pg';
3
+ import { singleton } from '../../../core/injection/index.js';
4
+ import { PgCrudRepository } from '../../repository/pg/PgCrudRepository.js';
5
+ import '../../../feature/async/CommandMetadataStore.js';
6
+ import '../../../feature/async/Async.js';
7
+ import { Job } from '../../../feature/async/Job.js';
8
+ import '../../../feature/async/JobRepository.js';
9
+ import '../../../feature/async/JobRunner.js';
10
+ import '../../../feature/async/JobsEventsHub.js';
11
+
12
+ let PgJobRepository = class PgJobRepository extends PgCrudRepository {
13
+ constructor(pool) {
14
+ super(pool, {
15
+ schema: 'wabot',
16
+ table: 'job',
17
+ constructor: Job,
18
+ });
19
+ }
20
+ };
21
+ PgJobRepository = __decorate([
22
+ singleton(),
23
+ __metadata("design:paramtypes", [Pool])
24
+ ], PgJobRepository);
25
+
26
+ export { PgJobRepository };
@@ -0,0 +1,107 @@
1
+ // import { injectable } from '@/injection'
2
+ // import { Anthropic } from '@anthropic-ai/sdk'
3
+ // import { ChatBotAdapter } from '@/chatbot'
4
+ // import type { ChatItem } from '@/core'
5
+ // import { MindsetOperator } from '@/mindset'
6
+ // import { Logger } from '@/logger'
7
+ class DummyClaudeChatBotAdapter {
8
+ }
9
+ // @injectable()
10
+ // export class ClaudeChatBotAdapter extends ChatBotAdapter {
11
+ // private anthropic: Anthropic
12
+ // private model: string
13
+ // private logger = new Logger('wabot:claude-chat-bot-adapter')
14
+ // constructor(mindset: MindsetOperator) {
15
+ // super(mindset)
16
+ // const apiKey = process.env.CLAUDE_API_KEY
17
+ // if (!apiKey) {
18
+ // throw new Error(`CLAUDE_API_KEY env variable is required`)
19
+ // }
20
+ // const model = process.env.CLAUDE_CHAT_MODEL
21
+ // if (!model) {
22
+ // throw new Error(`CLAUDE_CHAT_MODEL env variable is required`)
23
+ // }
24
+ // this.anthropic = new Anthropic({ apiKey })
25
+ // this.model = model
26
+ // }
27
+ // override async generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem> {
28
+ // const systemPrompt = await this.systemPrompt()
29
+ // const tools = (await this.mindset.allFunctionsDescriptors()).map((fn) => {
30
+ // return {
31
+ // name: fn.name,
32
+ // description: fn.description,
33
+ // input_schema: {
34
+ // ...fn.parameters,
35
+ // type: 'object' as const
36
+ // }
37
+ // }
38
+ // })
39
+ // const messages = this.mapChatItems(chatItems)
40
+ // const request = {
41
+ // model: this.model,
42
+ // max_tokens: 4096,
43
+ // system: systemPrompt,
44
+ // messages,
45
+ // tools: tools.length > 0 ? tools : undefined,
46
+ // }
47
+ // this.logger.debug(`Call Claude API with Request: ${JSON.stringify(request)}`)
48
+ // const response = await this.anthropic.messages.create(request)
49
+ // let newChatItem: ChatItem
50
+ // const content = response.content[0]
51
+ // if (content.type === 'text') {
52
+ // newChatItem = await this.buildBotMessageItem(content.text)
53
+ // } else if (content.type === 'tool_use') {
54
+ // newChatItem = await this.buildFunctionCallItem(
55
+ // content.id,
56
+ // content.name,
57
+ // JSON.stringify(content.input),
58
+ // )
59
+ // } else {
60
+ // throw new Error('Not supported Claude Response')
61
+ // }
62
+ // return newChatItem
63
+ // }
64
+ // private mapChatItems(chatItems: ChatItem[]): Anthropic.Messages.MessageParam[] {
65
+ // // const messages: Anthropic.Messages.MessageParam[] = []
66
+ // // for (const item of chatItems) {
67
+ // // const itemData = item.getData()
68
+ // // if (itemData.type === 'CONNECTION_MESSAGE') {
69
+ // // if (!itemData.content.text) {
70
+ // // throw new Error('User message content is empty')
71
+ // // }
72
+ // // messages.push({ role: 'user', content: itemData.content.text })
73
+ // // } else if (itemData.type === 'BOT_MESSAGE') {
74
+ // // if (!itemData.content.text) {
75
+ // // throw new Error('Assistant message content is empty')
76
+ // // }
77
+ // // messages.push({ role: 'assistant', content: itemData.content.text })
78
+ // // } else if (itemData.type === 'FUNCTION_CALL') {
79
+ // // messages.push({
80
+ // // role: 'assistant',
81
+ // // content: [
82
+ // // {
83
+ // // type: 'tool_use',
84
+ // // id: itemData.content.id,
85
+ // // name: itemData.content.name,
86
+ // // input: JSON.parse(itemData.content.arguments || '{}')
87
+ // // }
88
+ // // ]
89
+ // // })
90
+ // // messages.push({
91
+ // // role: 'user',
92
+ // // content: [
93
+ // // {
94
+ // // type: 'tool_result',
95
+ // // tool_use_id: itemData.content.id,
96
+ // // content: itemData.content.result || 'No result'
97
+ // // }
98
+ // // ]
99
+ // // })
100
+ // // }
101
+ // // }
102
+ // // return messages
103
+ // return []
104
+ // }
105
+ // }
106
+
107
+ export { DummyClaudeChatBotAdapter };
@@ -0,0 +1,103 @@
1
+ // import { injectable } from '@/injection'
2
+ // import { OpenAI } from 'openai'
3
+ // import { ChatBotAdapter } from '@/chatbot'
4
+ // import type { ChatItem } from '@/core'
5
+ // import { MindsetOperator } from '@/mindset'
6
+ class DummyDeepSeekChatBotAdapter {
7
+ }
8
+ // @injectable()
9
+ // export class DeepSeekChatBotAdapter extends ChatBotAdapter {
10
+ // private deepSeek: OpenAI
11
+ // private model: string
12
+ // constructor(mindset: MindsetOperator) {
13
+ // super(mindset)
14
+ // const model = process.env.DEEPSEEK_CHAT_MODEL
15
+ // const apiKey = process.env.DEEPSEEK_API_KEY
16
+ // const baseURL = process.env.DEEPSEEK_BASE_URL
17
+ // this.validateEnvVariables([model, apiKey, baseURL])
18
+ // this.model = model || 'deepseek-chat'
19
+ // this.deepSeek = new OpenAI({
20
+ // apiKey: apiKey,
21
+ // baseURL: baseURL,
22
+ // })
23
+ // }
24
+ // validateEnvVariables(envVariables: (string | undefined)[]): void {
25
+ // envVariables.forEach((envVariable) => {
26
+ // if (!envVariable) {
27
+ // throw new Error('Missing environment variable')
28
+ // }
29
+ // })
30
+ // }
31
+ // override async generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem> {
32
+ // const systemPrompt = await this.systemPrompt()
33
+ // const tools = (await this.mindset.allFunctionsDescriptors()).map((fn) => {
34
+ // const parameters = { ...fn.parameters, additionalProperties: false, type: 'object' }
35
+ // return {
36
+ // type: 'function',
37
+ // function: { name: fn.name, description: fn.description, parameters, strict: true },
38
+ // } as const
39
+ // })
40
+ // const response = await this.deepSeek.chat.completions.create({
41
+ // model: this.model,
42
+ // messages: [{ role: 'system', content: systemPrompt }, ...this.mapChatItems(chatItems)],
43
+ // tools: tools,
44
+ // tool_choice: 'auto',
45
+ // })
46
+ // let newChatItem: ChatItem
47
+ // const { tool_calls: responseFunctionCall, content: responseText } =
48
+ // response.choices?.[0]?.message ?? {}
49
+ // if (responseText) {
50
+ // newChatItem = await this.buildBotMessageItem(responseText)
51
+ // } else if (responseFunctionCall && responseFunctionCall[0]?.type == 'function') {
52
+ // newChatItem = await this.buildFunctionCallItem(
53
+ // responseFunctionCall[0].id,
54
+ // responseFunctionCall[0].function.name,
55
+ // responseFunctionCall[0].function.arguments,
56
+ // )
57
+ // } else {
58
+ // throw new Error('Not supported DeepSeek Response')
59
+ // }
60
+ // return newChatItem
61
+ // }
62
+ // private mapChatItems(chatItems: ChatItem[]): OpenAI.Chat.ChatCompletionMessageParam[] {
63
+ // // const deepSeekInput: OpenAI.Chat.ChatCompletionMessageParam[] = []
64
+ // // for (const item of chatItems) {
65
+ // // const itemData = item.getData()
66
+ // // if (itemData.type === 'CONNECTION_MESSAGE') {
67
+ // // if (!itemData.content.text) {
68
+ // // throw new Error('System message content is empty')
69
+ // // }
70
+ // // deepSeekInput.push({ role: 'user', content: itemData.content.text })
71
+ // // } else if (itemData.type === 'BOT_MESSAGE') {
72
+ // // if (!itemData.content.text) {
73
+ // // throw new Error('System message content is empty')
74
+ // // }
75
+ // // deepSeekInput.push({ role: 'assistant', content: itemData.content.text })
76
+ // // }
77
+ // // if (itemData.type === 'FUNCTION_CALL') {
78
+ // // deepSeekInput.push({
79
+ // // role: 'assistant',
80
+ // // tool_calls: [
81
+ // // {
82
+ // // id: itemData.content.id,
83
+ // // type: 'function',
84
+ // // function: {
85
+ // // name: itemData.content.name,
86
+ // // arguments: JSON.stringify(itemData.content.arguments),
87
+ // // },
88
+ // // },
89
+ // // ],
90
+ // // })
91
+ // // deepSeekInput.push({
92
+ // // role: 'tool',
93
+ // // tool_call_id: itemData.content.id,
94
+ // // content: itemData.content.result ?? 'No result',
95
+ // // })
96
+ // // }
97
+ // // }
98
+ // // return deepSeekInput
99
+ // return []
100
+ // }
101
+ // }
102
+
103
+ export { DummyDeepSeekChatBotAdapter };
@@ -1,4 +1,4 @@
1
- import { Logger } from '../../logger/Logger.js';
1
+ import { Logger } from '../../../core/logger/Logger.js';
2
2
  import { OpenAI } from 'openai';
3
3
 
4
4
  class OpenaiChatAdapter {
@@ -20,8 +20,8 @@ class OpenaiChatAdapter {
20
20
  const openIaInput = [];
21
21
  for (const chatItem of chatItems) {
22
22
  switch (chatItem.type) {
23
- case 'connectionMessage':
24
- openIaInput.push(this.mapConectionMessage(chatItem.connectionMessage));
23
+ case 'humanMessage':
24
+ openIaInput.push(this.mapConectionMessage(chatItem.humanMessage));
25
25
  break;
26
26
  case 'botMessage':
27
27
  openIaInput.push(this.mapBotMessage(chatItem.botMessage));
@@ -1,7 +1,8 @@
1
- import '../../../../core/chat/repository/IChatRepository.js';
2
- import { ChatItem } from '../../../../core/chat/ChatItem.js';
3
- import '../../../../core/user/IUserRepository.js';
4
- import { PgCrudRepository } from '../../../../repository/pg/PgCrudRepository.js';
1
+ import { PgCrudRepository } from '../../repository/pg/PgCrudRepository.js';
2
+ import { ChatItem } from '../../../feature/chat-bot/ChatItem.js';
3
+ import '../../../core/injection/index.js';
4
+ import 'uuid';
5
+ import '../../../feature/chat-bot/metadata/ChatBotMetadataStore.js';
5
6
 
6
7
  class PgChatMemory extends PgCrudRepository {
7
8
  chatId;
@@ -1,11 +1,11 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
- import '../../../../core/chat/repository/IChatRepository.js';
3
- import { Chat } from '../../../../core/chat/Chat.js';
4
- import '../../../../core/user/IUserRepository.js';
5
- import { singleton } from '../../../../injection/index.js';
6
2
  import { Pool } from 'pg';
7
3
  import { PgChatMemory } from './PgChatMemory.js';
8
- import { PgCrudRepository } from '../../../../repository/pg/PgCrudRepository.js';
4
+ import { singleton } from '../../../core/injection/index.js';
5
+ import { PgCrudRepository } from '../../repository/pg/PgCrudRepository.js';
6
+ import { Chat } from '../../../feature/chat-bot/Chat.js';
7
+ import 'uuid';
8
+ import '../../../feature/chat-bot/metadata/ChatBotMetadataStore.js';
9
9
 
10
10
  let PgChatRepository = class PgChatRepository extends PgCrudRepository {
11
11
  constructor(pool) {
@@ -1,7 +1,7 @@
1
1
  import { __decorate } from 'tslib';
2
2
  import { v4 } from 'uuid';
3
3
  import { RamChatMemory } from './RamChatMemory.js';
4
- import { singleton } from '../../../../injection/index.js';
4
+ import { singleton } from '../../../core/injection/index.js';
5
5
 
6
6
  let RamChatRepository = class RamChatRepository {
7
7
  items = [];
@@ -0,0 +1,22 @@
1
+ import { container } from '../../../core/injection/index.js';
2
+ import { ControllerMetadataStore } from '../../../feature/chat-controller/metadata/ControllerMetadataStore.js';
3
+ import '../../../feature/chat-controller/ChatResolver.js';
4
+ import 'uuid';
5
+ import '../../../feature/chat-bot/metadata/ChatBotMetadataStore.js';
6
+ import 'reflect-metadata';
7
+ import '../../../feature/mindset/metadata/MindsetMetadataStore.js';
8
+ import '../../../feature/mindset/MindsetOperator.js';
9
+ import { CmdChannel } from './CmdChannel.js';
10
+
11
+ function cmd() {
12
+ return function (target, propertyKey) {
13
+ const store = container.resolve(ControllerMetadataStore);
14
+ store.saveChannelMetadata({
15
+ channelConstructor: CmdChannel,
16
+ functionName: propertyKey.toString(),
17
+ controllerConstructor: target.constructor,
18
+ });
19
+ };
20
+ }
21
+
22
+ export { cmd };
@@ -1,25 +1,15 @@
1
- import { __decorate, __metadata } from 'tslib';
2
- import { ChatResolver } from '../../controller/channel/ChatResolver.js';
3
- import { UserResolver } from '../../controller/channel/UserResolver.js';
4
- import { injectable } from '../../injection/index.js';
5
- import '../../controller/metadata/ControllerMetadataStore.js';
1
+ import { __decorate } from 'tslib';
2
+ import { injectable } from '../../../core/injection/index.js';
6
3
  import * as readline from 'readline';
7
4
 
8
5
  var CmdChannel_1;
9
6
  const chatId = 'cmd';
10
- const userId = 'cmd';
11
7
  let CmdChannel = CmdChannel_1 = class CmdChannel {
12
- chatResolver;
13
- userResolver;
14
8
  rl = readline.createInterface({
15
9
  input: process.stdin,
16
10
  output: process.stdout,
17
11
  });
18
12
  callBack = null;
19
- constructor(chatResolver, userResolver) {
20
- this.chatResolver = chatResolver;
21
- this.userResolver = userResolver;
22
- }
23
13
  listen(callback) {
24
14
  this.callBack = callback;
25
15
  }
@@ -39,25 +29,15 @@ let CmdChannel = CmdChannel_1 = class CmdChannel {
39
29
  chatType: 'PRIVATE',
40
30
  channelName: CmdChannel_1.name,
41
31
  };
42
- const chat = await this.chatResolver.resolve(chatConnection);
43
- const userConnection = {
44
- id: userId,
45
- channelName: CmdChannel_1.name,
46
- };
47
- const user = await this.userResolver.resolve(userConnection);
48
32
  if (!this.callBack)
49
33
  return;
50
34
  this.callBack({
51
- chat,
52
- user,
35
+ chatConnection,
53
36
  message: {
54
- chatConnection,
55
- userConnection,
56
37
  text: trimmedInput,
57
- // senderName: 'cmd',
58
38
  },
59
39
  reply: (message) => {
60
- // console.log(`\n[${message.senderName}]: ${message.text}\n`)
40
+ console.log(`\n[${message.senderName}]: ${message.text}\n`);
61
41
  this.rl.prompt();
62
42
  },
63
43
  });
@@ -65,9 +45,7 @@ let CmdChannel = CmdChannel_1 = class CmdChannel {
65
45
  }
66
46
  };
67
47
  CmdChannel = CmdChannel_1 = __decorate([
68
- injectable(),
69
- __metadata("design:paramtypes", [ChatResolver,
70
- UserResolver])
48
+ injectable()
71
49
  ], CmdChannel);
72
50
 
73
51
  export { CmdChannel };
@@ -1,7 +1,11 @@
1
- import '../../controller/channel/ChatResolver.js';
2
- import '../../controller/channel/UserResolver.js';
3
- import { container } from '../../injection/index.js';
4
- import { ControllerMetadataStore } from '../../controller/metadata/ControllerMetadataStore.js';
1
+ import { container } from '../../../core/injection/index.js';
2
+ import { ControllerMetadataStore } from '../../../feature/chat-controller/metadata/ControllerMetadataStore.js';
3
+ import '../../../feature/chat-controller/ChatResolver.js';
4
+ import 'uuid';
5
+ import '../../../feature/chat-bot/metadata/ChatBotMetadataStore.js';
6
+ import 'reflect-metadata';
7
+ import '../../../feature/mindset/metadata/MindsetMetadataStore.js';
8
+ import '../../../feature/mindset/MindsetOperator.js';
5
9
  import { SocketChannel } from './SocketChannel.js';
6
10
  import { SocketChannelConfig } from './SocketChannelConfig.js';
7
11
 
@@ -1,24 +1,17 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
+ import { injectable } from '../../../core/injection/index.js';
3
+ import { SocketServerProvider } from '../../../feature/socket/SocketServerProvider.js';
2
4
  import { SocketChannelConfig } from './SocketChannelConfig.js';
3
- import { injectable } from '../../injection/index.js';
4
- import { ChatResolver } from '../../controller/channel/ChatResolver.js';
5
- import { UserResolver } from '../../controller/channel/UserResolver.js';
6
- import '../../controller/metadata/ControllerMetadataStore.js';
7
- import { SocketServerProvider } from './SocketServerProvider.js';
8
5
 
9
6
  var SocketChannel_1;
10
7
  let SocketChannel = SocketChannel_1 = class SocketChannel {
11
8
  config;
12
9
  socketServerProvider;
13
- chatResolver;
14
- userResolver;
15
10
  callBack = null;
16
11
  server;
17
- constructor(config, socketServerProvider, chatResolver, userResolver) {
12
+ constructor(config, socketServerProvider) {
18
13
  this.config = config;
19
14
  this.socketServerProvider = socketServerProvider;
20
- this.chatResolver = chatResolver;
21
- this.userResolver = userResolver;
22
15
  this.server = this.socketServerProvider.getSocketServer();
23
16
  }
24
17
  listen(callback) {
@@ -42,22 +35,13 @@ let SocketChannel = SocketChannel_1 = class SocketChannel {
42
35
  chatType: 'PRIVATE',
43
36
  channelName: SocketChannel_1.name,
44
37
  };
45
- const chat = await this.chatResolver.resolve(chatConnection);
46
- const userConnection = {
47
- id: message.userId,
48
- channelName: SocketChannel_1.name,
49
- };
50
- const user = await this.userResolver.resolve(userConnection);
51
38
  if (!this.callBack)
52
39
  return;
53
40
  this.callBack({
54
- chat,
55
- user,
41
+ chatConnection,
56
42
  message: {
57
- chatConnection,
58
- userConnection,
59
43
  text: trimmedInput,
60
- // senderName: message.senderName,
44
+ senderName: message.senderName,
61
45
  },
62
46
  reply: (message) => {
63
47
  socket.emit(this.config.channel, message);
@@ -71,9 +55,7 @@ let SocketChannel = SocketChannel_1 = class SocketChannel {
71
55
  SocketChannel = SocketChannel_1 = __decorate([
72
56
  injectable(),
73
57
  __metadata("design:paramtypes", [SocketChannelConfig,
74
- SocketServerProvider,
75
- ChatResolver,
76
- UserResolver])
58
+ SocketServerProvider])
77
59
  ], SocketChannel);
78
60
 
79
61
  export { SocketChannel };
@@ -1,5 +1,5 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
- import { injectable } from '../../injection/index.js';
2
+ import { injectable } from '../../../core/injection/index.js';
3
3
 
4
4
  let SocketChannelConfig = class SocketChannelConfig {
5
5
  channel;
@@ -1,7 +1,11 @@
1
- import { container } from '../../injection/index.js';
2
- import '../../controller/channel/ChatResolver.js';
3
- import '../../controller/channel/UserResolver.js';
4
- import { ControllerMetadataStore } from '../../controller/metadata/ControllerMetadataStore.js';
1
+ import { container } from '../../../core/injection/index.js';
2
+ import { ControllerMetadataStore } from '../../../feature/chat-controller/metadata/ControllerMetadataStore.js';
3
+ import '../../../feature/chat-controller/ChatResolver.js';
4
+ import 'uuid';
5
+ import '../../../feature/chat-bot/metadata/ChatBotMetadataStore.js';
6
+ import 'reflect-metadata';
7
+ import '../../../feature/mindset/metadata/MindsetMetadataStore.js';
8
+ import '../../../feature/mindset/MindsetOperator.js';
5
9
  import { TelegramChannel } from './TelegramChannel.js';
6
10
  import { TelegramChannelConfig } from './TelegramChannelConfig.js';
7
11
 
@@ -1,21 +1,14 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
- import { ChatResolver } from '../../controller/channel/ChatResolver.js';
3
- import { UserResolver } from '../../controller/channel/UserResolver.js';
4
- import { injectable } from '../../injection/index.js';
5
- import '../../controller/metadata/ControllerMetadataStore.js';
6
2
  import { Bot } from 'grammy';
7
3
  import { TelegramChannelConfig } from './TelegramChannelConfig.js';
4
+ import { injectable } from '../../../core/injection/index.js';
8
5
 
9
6
  var TelegramChannel_1;
10
7
  let TelegramChannel = TelegramChannel_1 = class TelegramChannel {
11
8
  config;
12
- chatResolver;
13
- userResolver;
14
9
  bot;
15
- constructor(config, chatResolver, userResolver) {
10
+ constructor(config) {
16
11
  this.config = config;
17
- this.chatResolver = chatResolver;
18
- this.userResolver = userResolver;
19
12
  this.bot = new Bot(this.config.botToken);
20
13
  }
21
14
  listen(callback) {
@@ -28,19 +21,10 @@ let TelegramChannel = TelegramChannel_1 = class TelegramChannel {
28
21
  chatType: ctx.message.chat.type === 'private' ? 'PRIVATE' : 'GROUP',
29
22
  channelName: TelegramChannel_1.name,
30
23
  };
31
- const chat = await this.chatResolver.resolve(chatConnection);
32
- const userConnection = {
33
- id: ctx.from.id.toString(),
34
- channelName: TelegramChannel_1.name,
35
- };
36
- const user = await this.userResolver.resolve(userConnection);
37
24
  callback({
38
- chat,
39
- user,
25
+ chatConnection,
40
26
  message: {
41
- chatConnection,
42
- userConnection,
43
- // senderName: ctx.from.first_name,
27
+ senderName: ctx.from.first_name,
44
28
  text: ctx.message.text,
45
29
  },
46
30
  reply: (replyMessage) => {
@@ -55,9 +39,7 @@ let TelegramChannel = TelegramChannel_1 = class TelegramChannel {
55
39
  };
56
40
  TelegramChannel = TelegramChannel_1 = __decorate([
57
41
  injectable(),
58
- __metadata("design:paramtypes", [TelegramChannelConfig,
59
- ChatResolver,
60
- UserResolver])
42
+ __metadata("design:paramtypes", [TelegramChannelConfig])
61
43
  ], TelegramChannel);
62
44
 
63
45
  export { TelegramChannel };
@@ -1,8 +1,12 @@
1
- import { container } from '../../injection/index.js';
1
+ import { container } from '../../../core/injection/index.js';
2
2
  import { WhatsappChannelConfig } from './WhatsAppChannelConfig.js';
3
- import '../../controller/channel/ChatResolver.js';
4
- import '../../controller/channel/UserResolver.js';
5
- import { ControllerMetadataStore } from '../../controller/metadata/ControllerMetadataStore.js';
3
+ import { ControllerMetadataStore } from '../../../feature/chat-controller/metadata/ControllerMetadataStore.js';
4
+ import '../../../feature/chat-controller/ChatResolver.js';
5
+ import 'uuid';
6
+ import '../../../feature/chat-bot/metadata/ChatBotMetadataStore.js';
7
+ import 'reflect-metadata';
8
+ import '../../../feature/mindset/metadata/MindsetMetadataStore.js';
9
+ import '../../../feature/mindset/MindsetOperator.js';
6
10
  import { WhatsAppChannel } from './WhatsAppChannel.js';
7
11
 
8
12
  function whatsapp(config) {
@@ -1,7 +1,7 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
- import { singleton } from '../../injection/index.js';
2
+ import { singleton } from '../../../core/injection/index.js';
3
3
  import { WhatsApp } from './WhatsApp.js';
4
- import { Env } from '../../env/Env.js';
4
+ import { Env } from '../../../core/env/Env.js';
5
5
 
6
6
  let EnvWhatsAppRepository = class EnvWhatsAppRepository {
7
7
  env;
@@ -1,7 +1,7 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
2
  import { Pool } from 'pg';
3
3
  import { WhatsApp } from './WhatsApp.js';
4
- import { singleton } from '../../injection/index.js';
4
+ import { singleton } from '../../../core/injection/index.js';
5
5
  import { PgCrudRepository } from '../../repository/pg/PgCrudRepository.js';
6
6
 
7
7
  let PgWhatsAppRepository = class PgWhatsAppRepository extends PgCrudRepository {
@@ -1,6 +1,6 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
- import { singleton } from '../../injection/index.js';
3
- import { Logger } from '../../logger/Logger.js';
2
+ import { singleton } from '../../../core/injection/index.js';
3
+ import { Logger } from '../../../core/logger/Logger.js';
4
4
  import { io } from 'socket.io-client';
5
5
  import { devEmitEvent } from './WabotDevSocketContracts.js';
6
6
 
@@ -1,6 +1,4 @@
1
- import '../../core/chat/repository/IChatRepository.js';
2
- import { Entity } from '../../core/Entity.js';
3
- import '../../core/user/IUserRepository.js';
1
+ import { Entity } from '../../../core/entity/Entity.js';
4
2
 
5
3
  class WhatsApp extends Entity {
6
4
  getVerifyToken() {