@wabot-dev/framework 0.1.0-beta.27 → 0.1.0-beta.28

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.
@@ -63,46 +63,45 @@ let ClaudeChatBotAdapter = class ClaudeChatBotAdapter extends ChatBotAdapter {
63
63
  return newChatItem;
64
64
  }
65
65
  mapChatItems(chatItems) {
66
- const messages = [];
67
- for (const item of chatItems) {
68
- const itemData = item.getData();
69
- if (itemData.type === 'CONNECTION_MESSAGE') {
70
- if (!itemData.content.text) {
71
- throw new Error('User message content is empty');
72
- }
73
- messages.push({ role: 'user', content: itemData.content.text });
74
- }
75
- else if (itemData.type === 'BOT_MESSAGE') {
76
- if (!itemData.content.text) {
77
- throw new Error('Assistant message content is empty');
78
- }
79
- messages.push({ role: 'assistant', content: itemData.content.text });
80
- }
81
- else if (itemData.type === 'FUNCTION_CALL') {
82
- messages.push({
83
- role: 'assistant',
84
- content: [
85
- {
86
- type: 'tool_use',
87
- id: itemData.content.id,
88
- name: itemData.content.name,
89
- input: JSON.parse(itemData.content.arguments || '{}')
90
- }
91
- ]
92
- });
93
- messages.push({
94
- role: 'user',
95
- content: [
96
- {
97
- type: 'tool_result',
98
- tool_use_id: itemData.content.id,
99
- content: itemData.content.result || 'No result'
100
- }
101
- ]
102
- });
103
- }
104
- }
105
- return messages;
66
+ // const messages: Anthropic.Messages.MessageParam[] = []
67
+ // for (const item of chatItems) {
68
+ // const itemData = item.getData()
69
+ // if (itemData.type === 'CONNECTION_MESSAGE') {
70
+ // if (!itemData.content.text) {
71
+ // throw new Error('User message content is empty')
72
+ // }
73
+ // messages.push({ role: 'user', content: itemData.content.text })
74
+ // } else if (itemData.type === 'BOT_MESSAGE') {
75
+ // if (!itemData.content.text) {
76
+ // throw new Error('Assistant message content is empty')
77
+ // }
78
+ // messages.push({ role: 'assistant', content: itemData.content.text })
79
+ // } else if (itemData.type === 'FUNCTION_CALL') {
80
+ // messages.push({
81
+ // role: 'assistant',
82
+ // content: [
83
+ // {
84
+ // type: 'tool_use',
85
+ // id: itemData.content.id,
86
+ // name: itemData.content.name,
87
+ // input: JSON.parse(itemData.content.arguments || '{}')
88
+ // }
89
+ // ]
90
+ // })
91
+ // messages.push({
92
+ // role: 'user',
93
+ // content: [
94
+ // {
95
+ // type: 'tool_result',
96
+ // tool_use_id: itemData.content.id,
97
+ // content: itemData.content.result || 'No result'
98
+ // }
99
+ // ]
100
+ // })
101
+ // }
102
+ // }
103
+ // return messages
104
+ return [];
106
105
  }
107
106
  };
108
107
  ClaudeChatBotAdapter = __decorate([
@@ -60,43 +60,43 @@ let DeepSeekChatBotAdapter = class DeepSeekChatBotAdapter extends ChatBotAdapter
60
60
  return newChatItem;
61
61
  }
62
62
  mapChatItems(chatItems) {
63
- const deepSeekInput = [];
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
- }
72
- else if (itemData.type === 'BOT_MESSAGE') {
73
- if (!itemData.content.text) {
74
- throw new Error('System message content is empty');
75
- }
76
- deepSeekInput.push({ role: 'assistant', content: itemData.content.text });
77
- }
78
- if (itemData.type === 'FUNCTION_CALL') {
79
- deepSeekInput.push({
80
- role: 'assistant',
81
- tool_calls: [
82
- {
83
- id: itemData.content.id,
84
- type: 'function',
85
- function: {
86
- name: itemData.content.name,
87
- arguments: JSON.stringify(itemData.content.arguments),
88
- },
89
- },
90
- ],
91
- });
92
- deepSeekInput.push({
93
- role: 'tool',
94
- tool_call_id: itemData.content.id,
95
- content: itemData.content.result ?? 'No result',
96
- });
97
- }
98
- }
99
- return deepSeekInput;
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
100
  }
101
101
  };
102
102
  DeepSeekChatBotAdapter = __decorate([
@@ -18,16 +18,16 @@ class OpenaiChatAdapter {
18
18
  }
19
19
  mapChatItems(chatItems) {
20
20
  const openIaInput = [];
21
- for (const { type, content } of chatItems) {
22
- switch (type) {
23
- case 'CONNECTION_MESSAGE':
24
- openIaInput.push(this.mapConectionMessage(content));
21
+ for (const chatItem of chatItems) {
22
+ switch (chatItem.type) {
23
+ case 'connectionMessage':
24
+ openIaInput.push(this.mapConectionMessage(chatItem.connectionMessage));
25
25
  break;
26
- case 'BOT_MESSAGE':
27
- openIaInput.push(this.mapBotMessage(content));
26
+ case 'botMessage':
27
+ openIaInput.push(this.mapBotMessage(chatItem.botMessage));
28
28
  break;
29
- case 'FUNCTION_CALL':
30
- openIaInput.push(...this.mapFunctionCall(content));
29
+ case 'functionCall':
30
+ openIaInput.push(...this.mapFunctionCall(chatItem.functionCall));
31
31
  break;
32
32
  }
33
33
  }
@@ -79,12 +79,12 @@ class OpenaiChatAdapter {
79
79
  mapResponse(response) {
80
80
  let newItem;
81
81
  if (response.output_text) {
82
- newItem = { type: 'BOT_MESSAGE', content: { text: response.output_text } };
82
+ newItem = { type: 'botMessage', botMessage: { text: response.output_text } };
83
83
  }
84
84
  else if (response.output && response.output[0]?.type == 'function_call') {
85
85
  newItem = {
86
- type: 'FUNCTION_CALL',
87
- content: {
86
+ type: 'functionCall',
87
+ functionCall: {
88
88
  id: response.output[0].call_id,
89
89
  name: response.output[0].name,
90
90
  arguments: response.output[0].arguments,
@@ -48,36 +48,36 @@ let OpenaiChatBotAdapter = class OpenaiChatBotAdapter extends ChatBotAdapter {
48
48
  return newChatItem;
49
49
  }
50
50
  mapChatItems(chatItems) {
51
- const openIaInput = [];
52
- for (const item of chatItems) {
53
- const itemData = item.getData();
54
- if (itemData.type === 'CONNECTION_MESSAGE') {
55
- if (!itemData.content.text) {
56
- throw new Error('System message content is empty');
57
- }
58
- openIaInput.push({ role: 'user', content: itemData.content.text });
59
- }
60
- else if (itemData.type === 'BOT_MESSAGE') {
61
- if (!itemData.content.text) {
62
- throw new Error('System message content is empty');
63
- }
64
- openIaInput.push({ role: 'assistant', content: itemData.content.text });
65
- }
66
- if (itemData.type === 'FUNCTION_CALL') {
67
- openIaInput.push({
68
- type: 'function_call',
69
- call_id: itemData.content.id,
70
- name: itemData.content.name,
71
- arguments: JSON.stringify(itemData.content.arguments),
72
- });
73
- openIaInput.push({
74
- type: 'function_call_output',
75
- call_id: itemData.content.id,
76
- output: itemData.content.result ?? 'Not result',
77
- });
78
- }
79
- }
80
- return openIaInput;
51
+ // const openIaInput: OpenAI.Responses.ResponseInput = []
52
+ // for (const item of chatItems) {
53
+ // const itemData = item.getData()
54
+ // if (itemData.type === 'CONNECTION_MESSAGE') {
55
+ // if (!itemData.content.text) {
56
+ // throw new Error('System message content is empty')
57
+ // }
58
+ // openIaInput.push({ role: 'user', content: itemData.content.text })
59
+ // } else if (itemData.type === 'BOT_MESSAGE') {
60
+ // if (!itemData.content.text) {
61
+ // throw new Error('System message content is empty')
62
+ // }
63
+ // openIaInput.push({ role: 'assistant', content: itemData.content.text })
64
+ // }
65
+ // if (itemData.type === 'FUNCTION_CALL') {
66
+ // openIaInput.push({
67
+ // type: 'function_call',
68
+ // call_id: itemData.content.id,
69
+ // name: itemData.content.name,
70
+ // arguments: JSON.stringify(itemData.content.arguments),
71
+ // })
72
+ // openIaInput.push({
73
+ // type: 'function_call_output',
74
+ // call_id: itemData.content.id,
75
+ // output: itemData.content.result ?? 'Not result',
76
+ // })
77
+ // }
78
+ // }
79
+ // return openIaInput
80
+ return [];
81
81
  }
82
82
  };
83
83
  OpenaiChatBotAdapter = __decorate([
@@ -54,10 +54,10 @@ let CmdChannel = CmdChannel_1 = class CmdChannel {
54
54
  chatConnection,
55
55
  userConnection,
56
56
  text: trimmedInput,
57
- senderName: 'cmd',
57
+ // senderName: 'cmd',
58
58
  },
59
59
  reply: (message) => {
60
- console.log(`\n[${message.senderName}]: ${message.text}\n`);
60
+ // console.log(`\n[${message.senderName}]: ${message.text}\n`)
61
61
  this.rl.prompt();
62
62
  },
63
63
  });
@@ -57,7 +57,7 @@ let SocketChannel = SocketChannel_1 = class SocketChannel {
57
57
  chatConnection,
58
58
  userConnection,
59
59
  text: trimmedInput,
60
- senderName: message.senderName,
60
+ // senderName: message.senderName,
61
61
  },
62
62
  reply: (message) => {
63
63
  socket.emit(this.config.channel, message);
@@ -40,7 +40,7 @@ let TelegramChannel = TelegramChannel_1 = class TelegramChannel {
40
40
  message: {
41
41
  chatConnection,
42
42
  userConnection,
43
- senderName: ctx.from.first_name,
43
+ // senderName: ctx.from.first_name,
44
44
  text: ctx.message.text,
45
45
  },
46
46
  reply: (replyMessage) => {
@@ -37,22 +37,16 @@ class WhatsAppReceiver {
37
37
  this.logger.error(`message type ${message.type} is not supported yet`);
38
38
  return;
39
39
  }
40
- const channelName = 'WhatsAppChannel';
41
- const chatConnection = {
42
- id: contact.wa_id,
43
- chatType: 'PRIVATE',
44
- channelName,
45
- };
46
- const userConnection = {
47
- id: contact.wa_id,
48
- channelName,
49
- };
50
- await listener({
51
- chatConnection,
52
- userConnection,
53
- senderName: contact.profile.name,
54
- text: message.text.body,
55
- });
40
+ ({
41
+ id: contact.wa_id});
42
+ ({
43
+ id: contact.wa_id});
44
+ // await listener({
45
+ // chatConnection,
46
+ // userConnection,
47
+ // senderName: contact.profile.name,
48
+ // text: message.text.body,
49
+ // })
56
50
  }
57
51
  }
58
52
 
@@ -1,7 +1,3 @@
1
- import '../../core/chat/repository/IChatRepository.js';
2
- import { ChatItem } from '../../core/chat/ChatItem.js';
3
- import '../../core/user/IUserRepository.js';
4
-
5
1
  class WhatsAppSender {
6
2
  logger;
7
3
  chatRepository;
@@ -72,7 +68,7 @@ class WhatsAppSender {
72
68
  .join('\n');
73
69
  return {
74
70
  text: this.replaceTemplateParameters(components, request.templateMessage.parameters),
75
- senderName: request.senderName,
71
+ // senderName: request.senderName,
76
72
  };
77
73
  }
78
74
  async writePrivateChatMemory(message, to) {
@@ -82,12 +78,12 @@ class WhatsAppSender {
82
78
  channelName: 'WhatsAppChannel',
83
79
  };
84
80
  const chat = await this.chatResolver.resolve(chatConnection);
85
- const chatMemory = await this.chatRepository.findMemory(chat.id);
86
- const chatItem = new ChatItem({
87
- type: 'BOT_MESSAGE',
88
- content: message,
89
- });
90
- await chatMemory.create(chatItem);
81
+ await this.chatRepository.findMemory(chat.id);
82
+ // const chatItem = new ChatItem({
83
+ // type: 'BOT_MESSAGE',
84
+ // content: message,
85
+ // })
86
+ // await chatMemory!.create(chatItem)
91
87
  }
92
88
  replaceTemplateParameters(template, data) {
93
89
  let result = template;
@@ -1,7 +1,6 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
2
  import { ChatMemory } from '../core/chat/repository/IChatMemory.js';
3
3
  import '../core/chat/repository/IChatRepository.js';
4
- import { ChatItem } from '../core/chat/ChatItem.js';
5
4
  import '../core/user/IUserRepository.js';
6
5
  import { injectable } from '../injection/index.js';
7
6
  import { ChatBotAdapter } from './ChatBotAdapter.js';
@@ -15,31 +14,31 @@ let ChatBot = class ChatBot {
15
14
  this.memory = memory;
16
15
  }
17
16
  async sendMessage(message, callback) {
18
- const newChatItem = new ChatItem({
19
- type: 'CONNECTION_MESSAGE',
20
- content: message,
21
- });
22
- await this.memory.create(newChatItem);
23
- this.processLoop(callback);
17
+ // const newChatItem = new ChatItem({
18
+ // type: 'CONNECTION_MESSAGE',
19
+ // content: message,
20
+ // })
21
+ // await this.memory.create(newChatItem)
22
+ // this.processLoop(callback)
24
23
  }
25
24
  async processLoop(callback) {
26
- const prevChatItems = await this.memory.findLastItems(10);
27
- if (prevChatItems.length === 0) {
28
- return;
29
- }
30
- const lastChatItem = prevChatItems[prevChatItems.length - 1];
31
- const lastItemType = lastChatItem.getType();
32
- if (lastItemType === 'BOT_MESSAGE') {
33
- return;
34
- }
35
- const newChatItem = await this.adapter.generateNextChatItem(prevChatItems);
36
- await this.memory.create(newChatItem);
37
- const newChatItemData = newChatItem.getData();
38
- if (newChatItemData.type === 'BOT_MESSAGE') {
39
- callback(newChatItemData.content);
40
- return;
41
- }
42
- this.processLoop(callback);
25
+ // const prevChatItems = await this.memory.findLastItems(10)
26
+ // if (prevChatItems.length === 0) {
27
+ // return
28
+ // }
29
+ // const lastChatItem = prevChatItems[prevChatItems.length - 1]
30
+ // const lastItemType = lastChatItem.getType()
31
+ // if (lastItemType === 'BOT_MESSAGE') {
32
+ // return
33
+ // }
34
+ // const newChatItem = await this.adapter.generateNextChatItem(prevChatItems)
35
+ // await this.memory.create(newChatItem)
36
+ // const newChatItemData = newChatItem.getData()
37
+ // if (newChatItemData.type === 'BOT_MESSAGE') {
38
+ // callback(newChatItemData.content)
39
+ // return
40
+ // }
41
+ // this.processLoop(callback)
43
42
  }
44
43
  };
45
44
  ChatBot = __decorate([
@@ -1,7 +1,3 @@
1
- import '../core/chat/repository/IChatRepository.js';
2
- import { ChatItem } from '../core/chat/ChatItem.js';
3
- import '../core/user/IUserRepository.js';
4
-
5
1
  class ChatBotAdapter {
6
2
  mindset;
7
3
  constructor(mindset) {
@@ -44,28 +40,30 @@ class ChatBotAdapter {
44
40
  return systemPrompt;
45
41
  }
46
42
  async buildBotMessageItem(text) {
47
- const senderName = (await this.mindset.identity()).name;
48
- const newBotMessage = new ChatItem({
49
- type: 'BOT_MESSAGE',
50
- content: {
51
- senderName,
52
- text,
53
- },
54
- });
55
- return newBotMessage;
43
+ // const senderName = (await this.mindset.identity()).name
44
+ // const newBotMessage = new ChatItem({
45
+ // type: 'BOT_MESSAGE',
46
+ // content: {
47
+ // senderName,
48
+ // text,
49
+ // },
50
+ // })
51
+ // return newBotMessage
52
+ return 0;
56
53
  }
57
54
  async buildFunctionCallItem(id, functionName, functionArguments) {
58
- const functionResult = await this.mindset.callFunction(functionName, functionArguments);
59
- const newFunctionCall = new ChatItem({
60
- type: 'FUNCTION_CALL',
61
- content: {
62
- id,
63
- name: functionName,
64
- arguments: functionArguments,
65
- result: functionResult,
66
- },
67
- });
68
- return newFunctionCall;
55
+ // const functionResult = await this.mindset.callFunction(functionName, functionArguments)
56
+ // const newFunctionCall = new ChatItem({
57
+ // type: 'FUNCTION_CALL',
58
+ // content: {
59
+ // id,
60
+ // name: functionName,
61
+ // arguments: functionArguments,
62
+ // result: functionResult,
63
+ // },
64
+ // })
65
+ // return newFunctionCall
66
+ return 0;
69
67
  }
70
68
  }
71
69
 
@@ -0,0 +1,3 @@
1
+ const chatItemTypeOptions = ['botMessage', 'connectionMessage', 'functionCall'];
2
+
3
+ export { chatItemTypeOptions };
@@ -68,6 +68,67 @@ interface IPersistentData extends IEntityData {
68
68
  declare class Persistent<D extends IPersistentData> extends Entity<D> {
69
69
  }
70
70
 
71
+ interface IChatMessage {
72
+ text?: string;
73
+ }
74
+ interface IFunctionCall {
75
+ id: string;
76
+ name: string;
77
+ arguments?: string;
78
+ result?: string;
79
+ }
80
+ declare const chatItemTypeOptions: readonly ["botMessage", "connectionMessage", "functionCall"];
81
+ type IBotMessageItem = {
82
+ type: 'botMessage';
83
+ botMessage: IChatMessage;
84
+ };
85
+ type IConnectionMessageItem = {
86
+ type: 'connectionMessage';
87
+ connectionMessage: IChatMessage;
88
+ };
89
+ type IFunctionCallItem = {
90
+ type: 'functionCall';
91
+ functionCall: IFunctionCall;
92
+ };
93
+ type IChatItem = IBotMessageItem | IConnectionMessageItem | IFunctionCallItem;
94
+ type IChatItemType = IChatItem['type'] & (typeof chatItemTypeOptions)[number];
95
+ interface IChatToolParameter {
96
+ type: string;
97
+ name: string;
98
+ description: string;
99
+ }
100
+ interface IChatTool {
101
+ language: string;
102
+ name: string;
103
+ description: string;
104
+ parameters: IChatToolParameter[];
105
+ }
106
+ interface IChatAdapterNextItemReq {
107
+ model: string;
108
+ systemPrompt: string;
109
+ tools: IChatTool[];
110
+ prevItems: IChatItem[];
111
+ }
112
+ interface IChatAdapter {
113
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatItem>;
114
+ }
115
+
116
+ type IChatItemData = IEntityData & IChatItem;
117
+ declare class ChatItem extends Entity<IChatItemData> {
118
+ getType(): "botMessage" | "connectionMessage" | "functionCall";
119
+ getContent(): IPrimitive | IStorableData | IPrimitive[] | IStorableData[];
120
+ getData(): IChatItemData;
121
+ }
122
+
123
+ interface IChatMemory {
124
+ findLastItems(count: number): Promise<ChatItem[]>;
125
+ create(item: ChatItem): Promise<void>;
126
+ }
127
+ declare class ChatMemory implements IChatMemory {
128
+ findLastItems(count: number): Promise<ChatItem[]>;
129
+ create(item: ChatItem): Promise<void>;
130
+ }
131
+
71
132
  type IChatType = 'PRIVATE' | 'GROUP';
72
133
  interface IChatConnection extends IStorableData {
73
134
  chatType: IChatType;
@@ -88,10 +149,22 @@ declare class Chat extends Entity<IChatData> {
88
149
  validate(): void;
89
150
  }
90
151
 
91
- interface IChatDocument extends IStorableData {
152
+ interface IChatRepository {
153
+ create(chat: Chat): Promise<void>;
154
+ findByConnection(query: IChatConnection): Promise<Chat | null>;
155
+ findMemory(chatId: string): Promise<IChatMemory | null>;
156
+ }
157
+ declare class ChatRepository implements IChatRepository {
158
+ create(chat: Chat): Promise<void>;
159
+ findByConnection(query: IChatConnection): Promise<Chat | null>;
160
+ findMemory(chatId: string): Promise<IChatMemory | null>;
92
161
  }
93
162
 
94
- interface IChatImage extends IStorableData {
163
+ interface IChatFunctionCall {
164
+ id: string;
165
+ name: string;
166
+ arguments?: string;
167
+ result?: string;
95
168
  }
96
169
 
97
170
  interface IUserConnection extends IStorableData {
@@ -113,66 +186,6 @@ declare class User extends Entity<IUserData> {
113
186
  addConnection(connection: IUserConnection): void;
114
187
  }
115
188
 
116
- interface IChatMessage extends IStorableData {
117
- text?: string;
118
- documents?: IChatDocument[];
119
- images?: IChatImage[];
120
- senderName?: string;
121
- }
122
- interface IConnectionChatMessage extends IChatMessage {
123
- chatConnection: IChatConnection;
124
- userConnection: IUserConnection;
125
- userId?: string;
126
- }
127
-
128
- interface IChatFunctionCall {
129
- id: string;
130
- name: string;
131
- arguments?: string;
132
- result?: string;
133
- }
134
-
135
- type ISystemMessageItem = {
136
- type: 'BOT_MESSAGE';
137
- content: IChatMessage;
138
- };
139
- type IReceivedMessageItem = {
140
- type: 'CONNECTION_MESSAGE';
141
- content: IConnectionChatMessage;
142
- };
143
- type ISystemFunctionCallItem = {
144
- type: 'FUNCTION_CALL';
145
- content: IChatFunctionCall;
146
- };
147
- type IChatItemRawData = ISystemMessageItem | IReceivedMessageItem | ISystemFunctionCallItem;
148
- type IChatItemData = IEntityData & IChatItemRawData;
149
- type IChatItemType = IChatItemData['type'];
150
- declare class ChatItem extends Entity<IChatItemData> {
151
- getType(): "BOT_MESSAGE" | "CONNECTION_MESSAGE" | "FUNCTION_CALL";
152
- getContent(): IChatMessage | IConnectionChatMessage | IChatFunctionCall;
153
- getData(): IChatItemData;
154
- }
155
-
156
- interface IChatMemory {
157
- findLastItems(count: number): Promise<ChatItem[]>;
158
- create(item: ChatItem): Promise<void>;
159
- }
160
- declare class ChatMemory implements IChatMemory {
161
- findLastItems(count: number): Promise<ChatItem[]>;
162
- create(item: ChatItem): Promise<void>;
163
- }
164
-
165
- interface IChatRepository {
166
- create(chat: Chat): Promise<void>;
167
- findByConnection(query: IChatConnection): Promise<Chat | null>;
168
- findMemory(chatId: string): Promise<IChatMemory | null>;
169
- }
170
- declare class ChatRepository implements IChatRepository {
171
- create(chat: Chat): Promise<void>;
172
- findByConnection(query: IChatConnection): Promise<Chat | null>;
173
- findMemory(chatId: string): Promise<IChatMemory | null>;
174
- }
175
-
176
189
  interface IUserRepository {
177
190
  create(chat: User): Promise<void>;
178
191
  update(chat: User): Promise<void>;
@@ -184,6 +197,12 @@ declare class UserRepository implements IUserRepository {
184
197
  findByConnection(query: IUserConnection): Promise<User | null>;
185
198
  }
186
199
 
200
+ interface IConnectionChatMessage extends IChatMessage {
201
+ chatConnection: IChatConnection;
202
+ userConnection: IUserConnection;
203
+ userId?: string;
204
+ }
205
+
187
206
  interface IMessageContext {
188
207
  message: IConnectionChatMessage;
189
208
  chat: Chat;
@@ -386,8 +405,8 @@ declare class ChatBotAdapter implements IChatBotAdapter {
386
405
  constructor(mindset: MindsetOperator);
387
406
  generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
388
407
  protected systemPrompt(): Promise<string>;
389
- protected buildBotMessageItem(text: string): Promise<ChatItem>;
390
- protected buildFunctionCallItem(id: string, functionName: string, functionArguments: string): Promise<ChatItem>;
408
+ protected buildBotMessageItem(text: string): Promise<any>;
409
+ protected buildFunctionCallItem(id: string, functionName: string, functionArguments: string): Promise<any>;
391
410
  }
392
411
 
393
412
  interface IChatBot {
@@ -402,27 +421,6 @@ declare class ChatBot implements IChatBot {
402
421
  protected processLoop(callback: (message: IChatMessage) => void): Promise<void>;
403
422
  }
404
423
 
405
- interface IChatToolParameter {
406
- type: string;
407
- name: string;
408
- description: string;
409
- }
410
- interface IChatTool {
411
- language: string;
412
- name: string;
413
- description: string;
414
- parameters: IChatToolParameter[];
415
- }
416
- interface IChatAdapterNextItemReq {
417
- model: string;
418
- systemPrompt: string;
419
- tools: IChatTool[];
420
- prevItems: IChatItemRawData[];
421
- }
422
- interface IChatAdapter {
423
- nextItem(req: IChatAdapterNextItemReq): Promise<IChatItemRawData>;
424
- }
425
-
426
424
  declare class DeepSeekChatBotAdapter extends ChatBotAdapter {
427
425
  private deepSeek;
428
426
  private model;
@@ -444,7 +442,7 @@ declare class OpenaiChatBotAdapter extends ChatBotAdapter {
444
442
  declare class OpenaiChatAdapter implements IChatAdapter {
445
443
  private openai;
446
444
  private logger;
447
- nextItem(req: IChatAdapterNextItemReq): Promise<IChatItemRawData>;
445
+ nextItem(req: IChatAdapterNextItemReq): Promise<IChatItem>;
448
446
  private mapChatItems;
449
447
  private mapConectionMessage;
450
448
  private mapBotMessage;
@@ -1435,4 +1433,4 @@ declare function validate<V>(value: any, modelConstructor: IConstructor<V>): IMo
1435
1433
 
1436
1434
  declare function modelInfo<V>(modelConstructor: IConstructor<V>): IModelValidatorsInfo<V>;
1437
1435
 
1438
- export { Async, Auth, AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, ClaudeChatBotAdapter, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatBotAdapter, EmailService, Entity, Env, EnvWhatsAppRepository, ExpressProvider, HtmlModule, HttpServerProvider, type IArrayValidationError, type IArrayValidationResult, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatBot, type IChatBotAdapter, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatFunctionCall, type IChatItemData, type IChatItemRawData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatTool, type IChatToolParameter, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConnectionChatMessage, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEmailService, type IEndPointMetadata, type IEntityData, type IEnvType, type IGetConfig, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IJobData, type IJobEvent, type IJobEventListener, type IJwtRefreshTokenData, type IListenWhatsAppMessageRequest, type IMessageContext, type IMessageMetadata, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IOtpService, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPostConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IReceivedMessageItem, type IRestControllerConfig, type IRestControllerMetadata, type ISendEmailRequest, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type IServerConfig, type IServerProvider, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type IStorableData, type ISystemFunctionCallItem, type ISystemMessageItem, type ITelegramChannelConfig, type IUserConnection, type IUserData, type IUserRepository, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppContact, type IWhatsAppData, type IWhatsAppMessage, type IWhatsAppMessageListener, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsAppTemplate, type IWhatsAppTemplateComponent, type IWhatsAppTemplateMessage, type IWhatsAppTemplateParameter, type IWhatsAppTemplateResponse, type IWhatsAppWebhookPayload, type IWhatsappChannelConfig, type IchatControllerConfig, type IrunChannelProps, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mapper, MessageContext, Mindset, MindsetMetadataStore, MindsetOperator, OpenaiChatAdapter, OpenaiChatBotAdapter, OtpService, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgRepositoryBase, PgUserRepository, PgWhatsAppRepository, RamChatMemory, RamChatRepository, RamUserRepository, Random, RegisterUserModule, RegisterUserWithEmailRequest, RestControllerMetadataStore, SendOneTimePasswordRequest, SocketChannel, SocketChannelConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, User, UserRepository, UserResolver, ValidateOneTimePasswordRequest, ValidationMetadataStore, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, cmd, command, commandHandler, container, get, inject, injectable, isArray, isBoolean, isDate, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, param, post, prepareChatContainer, restController, runAsyncCommandHandlers, runChannel, runRestControllers, runServer, scoped, singleton, socket, telegram, validate, validateArray, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsapp };
1436
+ export { Async, Auth, AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, ClaudeChatBotAdapter, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatBotAdapter, EmailService, Entity, Env, EnvWhatsAppRepository, ExpressProvider, HtmlModule, HttpServerProvider, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatBot, type IChatBotAdapter, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatFunctionCall, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatTool, type IChatToolParameter, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConnectionChatMessage, type IConnectionMessageItem, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEmailService, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGetConfig, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IJobData, type IJobEvent, type IJobEventListener, type IJwtRefreshTokenData, type IListenWhatsAppMessageRequest, type IMessageContext, type IMessageMetadata, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IOtpService, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPostConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IRestControllerConfig, type IRestControllerMetadata, type ISendEmailRequest, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type IServerConfig, type IServerProvider, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type IStorableData, type ITelegramChannelConfig, type IUserConnection, type IUserData, type IUserRepository, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppContact, type IWhatsAppData, type IWhatsAppMessage, type IWhatsAppMessageListener, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsAppTemplate, type IWhatsAppTemplateComponent, type IWhatsAppTemplateMessage, type IWhatsAppTemplateParameter, type IWhatsAppTemplateResponse, type IWhatsAppWebhookPayload, type IWhatsappChannelConfig, type IchatControllerConfig, type IrunChannelProps, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mapper, MessageContext, Mindset, MindsetMetadataStore, MindsetOperator, OpenaiChatAdapter, OpenaiChatBotAdapter, OtpService, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgRepositoryBase, PgUserRepository, PgWhatsAppRepository, RamChatMemory, RamChatRepository, RamUserRepository, Random, RegisterUserModule, RegisterUserWithEmailRequest, RestControllerMetadataStore, SendOneTimePasswordRequest, SocketChannel, SocketChannelConfig, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, User, UserRepository, UserResolver, ValidateOneTimePasswordRequest, ValidationMetadataStore, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, container, get, inject, injectable, isArray, isBoolean, isDate, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, param, post, prepareChatContainer, restController, runAsyncCommandHandlers, runChannel, runRestControllers, runServer, scoped, singleton, socket, telegram, validate, validateArray, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsapp };
package/dist/src/index.js CHANGED
@@ -49,6 +49,7 @@ export { ChatMemory } from './core/chat/repository/IChatMemory.js';
49
49
  export { ChatRepository } from './core/chat/repository/IChatRepository.js';
50
50
  export { Chat } from './core/chat/Chat.js';
51
51
  export { ChatItem } from './core/chat/ChatItem.js';
52
+ export { chatItemTypeOptions } from './core/chat/IChatAdapter.js';
52
53
  export { User } from './core/user/User.js';
53
54
  export { UserRepository } from './core/user/IUserRepository.js';
54
55
  export { MessageContext } from './core/IMessageContext.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wabot-dev/framework",
3
- "version": "0.1.0-beta.27",
3
+ "version": "0.1.0-beta.28",
4
4
  "description": "Framework for IA Chat Bots",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",