@wabot-dev/framework 0.1.0-beta.11 → 0.1.0-beta.13

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 (61) hide show
  1. package/dist/src/ai/claude/ClaudeChatBotAdapter.js +115 -0
  2. package/dist/src/channels/whatsapp/WhatsApp.js +2 -2
  3. package/dist/src/channels/whatsapp/WhatsAppSender.js +10 -1
  4. package/dist/src/channels/whatsapp/WhatsAppSenderByCloudApi.js +3 -9
  5. package/dist/src/channels/whatsapp/WhatsAppSenderByDevConnection.js +6 -11
  6. package/dist/src/core/{Persistent.js → Entity.js} +24 -9
  7. package/dist/src/core/Storable.js +8 -0
  8. package/dist/src/core/chat/Chat.js +2 -2
  9. package/dist/src/core/chat/ChatItem.js +2 -2
  10. package/dist/src/core/user/User.js +2 -2
  11. package/dist/src/error/CustomError.js +1 -0
  12. package/dist/src/index.d.ts +250 -181
  13. package/dist/src/index.js +13 -9
  14. package/dist/src/node_modules/@anthropic-ai/sdk/_vendor/partial-json-parser/parser.js +221 -0
  15. package/dist/src/node_modules/@anthropic-ai/sdk/client.js +540 -0
  16. package/dist/src/node_modules/@anthropic-ai/sdk/core/api-promise.js +74 -0
  17. package/dist/src/node_modules/@anthropic-ai/sdk/core/error.js +100 -0
  18. package/dist/src/node_modules/@anthropic-ai/sdk/core/pagination.js +119 -0
  19. package/dist/src/node_modules/@anthropic-ai/sdk/core/resource.js +8 -0
  20. package/dist/src/node_modules/@anthropic-ai/sdk/core/streaming.js +283 -0
  21. package/dist/src/node_modules/@anthropic-ai/sdk/internal/constants.js +16 -0
  22. package/dist/src/node_modules/@anthropic-ai/sdk/internal/decoders/jsonl.js +37 -0
  23. package/dist/src/node_modules/@anthropic-ai/sdk/internal/decoders/line.js +110 -0
  24. package/dist/src/node_modules/@anthropic-ai/sdk/internal/detect-platform.js +159 -0
  25. package/dist/src/node_modules/@anthropic-ai/sdk/internal/errors.js +37 -0
  26. package/dist/src/node_modules/@anthropic-ai/sdk/internal/headers.js +71 -0
  27. package/dist/src/node_modules/@anthropic-ai/sdk/internal/parse.js +53 -0
  28. package/dist/src/node_modules/@anthropic-ai/sdk/internal/request-options.js +11 -0
  29. package/dist/src/node_modules/@anthropic-ai/sdk/internal/shims.js +86 -0
  30. package/dist/src/node_modules/@anthropic-ai/sdk/internal/to-file.js +94 -0
  31. package/dist/src/node_modules/@anthropic-ai/sdk/internal/tslib.js +14 -0
  32. package/dist/src/node_modules/@anthropic-ai/sdk/internal/uploads.js +113 -0
  33. package/dist/src/node_modules/@anthropic-ai/sdk/internal/utils/bytes.js +27 -0
  34. package/dist/src/node_modules/@anthropic-ai/sdk/internal/utils/env.js +19 -0
  35. package/dist/src/node_modules/@anthropic-ai/sdk/internal/utils/log.js +82 -0
  36. package/dist/src/node_modules/@anthropic-ai/sdk/internal/utils/path.js +76 -0
  37. package/dist/src/node_modules/@anthropic-ai/sdk/internal/utils/sleep.js +4 -0
  38. package/dist/src/node_modules/@anthropic-ai/sdk/internal/utils/uuid.js +16 -0
  39. package/dist/src/node_modules/@anthropic-ai/sdk/internal/utils/values.js +48 -0
  40. package/dist/src/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.js +588 -0
  41. package/dist/src/node_modules/@anthropic-ai/sdk/lib/MessageStream.js +582 -0
  42. package/dist/src/node_modules/@anthropic-ai/sdk/resources/beta/beta.js +19 -0
  43. package/dist/src/node_modules/@anthropic-ai/sdk/resources/beta/files.js +120 -0
  44. package/dist/src/node_modules/@anthropic-ai/sdk/resources/beta/messages/batches.js +202 -0
  45. package/dist/src/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.js +85 -0
  46. package/dist/src/node_modules/@anthropic-ai/sdk/resources/beta/models.js +58 -0
  47. package/dist/src/node_modules/@anthropic-ai/sdk/resources/completions.js +21 -0
  48. package/dist/src/node_modules/@anthropic-ai/sdk/resources/messages/batches.js +151 -0
  49. package/dist/src/node_modules/@anthropic-ai/sdk/resources/messages/messages.js +71 -0
  50. package/dist/src/node_modules/@anthropic-ai/sdk/resources/models.js +43 -0
  51. package/dist/src/node_modules/@anthropic-ai/sdk/version.js +3 -0
  52. package/dist/src/pre-made/repository/chat/ram/RamChatRepository.js +1 -1
  53. package/dist/src/repository/pg/PgCrudRepository.js +2 -2
  54. package/dist/src/repository/pg/PgRepositoryBase.js +2 -2
  55. package/dist/src/rest-controller/metadata/@middleware.js +16 -0
  56. package/dist/src/rest-controller/metadata/RestControllerMetadataStore.js +13 -0
  57. package/dist/src/rest-controller/runRestControllers.js +30 -22
  58. package/dist/src/server/prepareChatContainer.js +2 -2
  59. package/dist/src/validation/metadata/@isModel.js +18 -0
  60. package/dist/src/validation/validators/validateModel.js +2 -6
  61. package/package.json +2 -1
package/dist/src/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { DeepSeekChatBotAdapter } from './ai/deepseek/DeepSeekChatBotAdapter.js';
2
2
  export { OpenaiChatBotAdapter } from './ai/openia/OpenaiChatBotAdapter.js';
3
+ export { ClaudeChatBotAdapter } from './ai/claude/ClaudeChatBotAdapter.js';
3
4
  export { cmd } from './channels/cmd/@cmd.js';
4
5
  export { CmdChannel } from './channels/cmd/CmdChannel.js';
5
6
  export { ExpressProvider } from './channels/express/ExpressProvider.js';
@@ -12,6 +13,8 @@ export { telegram } from './channels/telegram/@telegram.js';
12
13
  export { TelegramChannelConfig } from './channels/telegram/TelegramChannelConfig.js';
13
14
  export { TelegramChannel } from './channels/telegram/TelegramChannel.js';
14
15
  export { whatsapp } from './channels/whatsapp/@whatsapp.js';
16
+ export { EnvWhatsAppRepository } from './channels/whatsapp/EnvWhatsAppRepository.js';
17
+ export { PgWhatsAppRepository } from './channels/whatsapp/PgWhatsAppRepository.js';
15
18
  export { WhatsApp } from './channels/whatsapp/WhatsApp.js';
16
19
  export { WhatsAppChannel } from './channels/whatsapp/WhatsAppChannel.js';
17
20
  export { WhatsappChannelConfig } from './channels/whatsapp/WhatsAppChannelConfig.js';
@@ -20,10 +23,8 @@ export { WhatsAppReceiverByDevConnection } from './channels/whatsapp/WhatsAppRec
20
23
  export { WhatsAppReceiverByWebHook } from './channels/whatsapp/WhatsAppReceiverByWebHook.js';
21
24
  export { WhatsAppRepository } from './channels/whatsapp/WhatsAppRepository.js';
22
25
  export { WhatsAppSender } from './channels/whatsapp/WhatsAppSender.js';
23
- export { WhatsAppSenderByDevConnection } from './channels/whatsapp/WhatsAppSenderByDevConnection.js';
24
26
  export { WhatsAppSenderByCloudApi } from './channels/whatsapp/WhatsAppSenderByCloudApi.js';
25
- export { PgWhatsAppRepository } from './channels/whatsapp/PgWhatsAppRepository.js';
26
- export { EnvWhatsAppRepository } from './channels/whatsapp/EnvWhatsAppRepository.js';
27
+ export { WhatsAppSenderByDevConnection } from './channels/whatsapp/WhatsAppSenderByDevConnection.js';
27
28
  export { chatBot } from './chatbot/metadata/@chatBot.js';
28
29
  export { ChatBotMetadataStore } from './chatbot/metadata/ChatBotMetadataStore.js';
29
30
  export { ChatBot } from './chatbot/ChatBot.js';
@@ -39,8 +40,11 @@ export { ChatItem } from './core/chat/ChatItem.js';
39
40
  export { User } from './core/user/User.js';
40
41
  export { UserRepository } from './core/user/IUserRepository.js';
41
42
  export { MessageContext } from './core/IMessageContext.js';
42
- export { Persistent } from './core/Persistent.js';
43
+ export { Entity, Persistent } from './core/Entity.js';
44
+ export { WabotEnv } from './env/WabotEnv.js';
45
+ export { CustomError } from './error/CustomError.js';
43
46
  export { container, inject, injectable, singleton } from './injection/index.js';
47
+ export { Logger } from './logger/Logger.js';
44
48
  export { mindsetFunction } from './mindset/metadata/functions/@mindsetFunction.js';
45
49
  export { MINDSET_FUNCTION_DECORATION_FUNCTION } from './mindset/metadata/functions/decoratorNames.js';
46
50
  export { mindset } from './mindset/metadata/mindsets/@mindset.js';
@@ -52,9 +56,6 @@ export { PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM } from './mindset/
52
56
  export { MindsetMetadataStore } from './mindset/metadata/MindsetMetadataStore.js';
53
57
  export { Mindset } from './mindset/IMindset.js';
54
58
  export { MindsetOperator } from './mindset/MindsetOperator.js';
55
- export { prepareChatContainer } from './server/prepareChatContainer.js';
56
- export { runChannel } from './server/runChannel.js';
57
- export { runServer } from './server/runServer.js';
58
59
  export { SendOneTimePasswordRequest } from './pre-made/module/authentication/requests/SendOneTimePasswordRequest.js';
59
60
  export { ValidateOneTimePasswordRequest } from './pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js';
60
61
  export { AuthenticationModule } from './pre-made/module/authentication/AuthenticationModule.js';
@@ -71,15 +72,18 @@ export { RamChatMemory } from './pre-made/repository/chat/ram/RamChatMemory.js';
71
72
  export { RamChatRepository } from './pre-made/repository/chat/ram/RamChatRepository.js';
72
73
  export { PgCrudRepository } from './repository/pg/PgCrudRepository.js';
73
74
  export { PgRepositoryBase } from './repository/pg/PgRepositoryBase.js';
74
- export { Logger } from './logger/Logger.js';
75
- export { WabotEnv } from './env/WabotEnv.js';
76
75
  export { get } from './rest-controller/metadata/@get.js';
76
+ export { middleware } from './rest-controller/metadata/@middleware.js';
77
77
  export { post } from './rest-controller/metadata/@post.js';
78
78
  export { restController } from './rest-controller/metadata/@restController.js';
79
79
  export { RestControllerMetadataStore } from './rest-controller/metadata/RestControllerMetadataStore.js';
80
80
  export { runRestControllers } from './rest-controller/runRestControllers.js';
81
+ export { prepareChatContainer } from './server/prepareChatContainer.js';
82
+ export { runChannel } from './server/runChannel.js';
83
+ export { runServer } from './server/runServer.js';
81
84
  export { isBoolean } from './validation/metadata/@isBoolean.js';
82
85
  export { isDate } from './validation/metadata/@isDate.js';
86
+ export { isModel } from './validation/metadata/@isModel.js';
83
87
  export { isNotEmpty } from './validation/metadata/@isNotEmpty.js';
84
88
  export { isNumber } from './validation/metadata/@isNumber.js';
85
89
  export { isOptional } from './validation/metadata/@isOptional.js';
@@ -0,0 +1,221 @@
1
+ const tokenize = (input) => {
2
+ let current = 0;
3
+ let tokens = [];
4
+ while (current < input.length) {
5
+ let char = input[current];
6
+ if (char === '\\') {
7
+ current++;
8
+ continue;
9
+ }
10
+ if (char === '{') {
11
+ tokens.push({
12
+ type: 'brace',
13
+ value: '{',
14
+ });
15
+ current++;
16
+ continue;
17
+ }
18
+ if (char === '}') {
19
+ tokens.push({
20
+ type: 'brace',
21
+ value: '}',
22
+ });
23
+ current++;
24
+ continue;
25
+ }
26
+ if (char === '[') {
27
+ tokens.push({
28
+ type: 'paren',
29
+ value: '[',
30
+ });
31
+ current++;
32
+ continue;
33
+ }
34
+ if (char === ']') {
35
+ tokens.push({
36
+ type: 'paren',
37
+ value: ']',
38
+ });
39
+ current++;
40
+ continue;
41
+ }
42
+ if (char === ':') {
43
+ tokens.push({
44
+ type: 'separator',
45
+ value: ':',
46
+ });
47
+ current++;
48
+ continue;
49
+ }
50
+ if (char === ',') {
51
+ tokens.push({
52
+ type: 'delimiter',
53
+ value: ',',
54
+ });
55
+ current++;
56
+ continue;
57
+ }
58
+ if (char === '"') {
59
+ let value = '';
60
+ let danglingQuote = false;
61
+ char = input[++current];
62
+ while (char !== '"') {
63
+ if (current === input.length) {
64
+ danglingQuote = true;
65
+ break;
66
+ }
67
+ if (char === '\\') {
68
+ current++;
69
+ if (current === input.length) {
70
+ danglingQuote = true;
71
+ break;
72
+ }
73
+ value += char + input[current];
74
+ char = input[++current];
75
+ }
76
+ else {
77
+ value += char;
78
+ char = input[++current];
79
+ }
80
+ }
81
+ char = input[++current];
82
+ if (!danglingQuote) {
83
+ tokens.push({
84
+ type: 'string',
85
+ value,
86
+ });
87
+ }
88
+ continue;
89
+ }
90
+ let WHITESPACE = /\s/;
91
+ if (char && WHITESPACE.test(char)) {
92
+ current++;
93
+ continue;
94
+ }
95
+ let NUMBERS = /[0-9]/;
96
+ if ((char && NUMBERS.test(char)) || char === '-' || char === '.') {
97
+ let value = '';
98
+ if (char === '-') {
99
+ value += char;
100
+ char = input[++current];
101
+ }
102
+ while ((char && NUMBERS.test(char)) || char === '.') {
103
+ value += char;
104
+ char = input[++current];
105
+ }
106
+ tokens.push({
107
+ type: 'number',
108
+ value,
109
+ });
110
+ continue;
111
+ }
112
+ let LETTERS = /[a-z]/i;
113
+ if (char && LETTERS.test(char)) {
114
+ let value = '';
115
+ while (char && LETTERS.test(char)) {
116
+ if (current === input.length) {
117
+ break;
118
+ }
119
+ value += char;
120
+ char = input[++current];
121
+ }
122
+ if (value == 'true' || value == 'false' || value === 'null') {
123
+ tokens.push({
124
+ type: 'name',
125
+ value,
126
+ });
127
+ }
128
+ else {
129
+ // unknown token, e.g. `nul` which isn't quite `null`
130
+ current++;
131
+ continue;
132
+ }
133
+ continue;
134
+ }
135
+ current++;
136
+ }
137
+ return tokens;
138
+ }, strip = (tokens) => {
139
+ if (tokens.length === 0) {
140
+ return tokens;
141
+ }
142
+ let lastToken = tokens[tokens.length - 1];
143
+ switch (lastToken.type) {
144
+ case 'separator':
145
+ tokens = tokens.slice(0, tokens.length - 1);
146
+ return strip(tokens);
147
+ case 'number':
148
+ let lastCharacterOfLastToken = lastToken.value[lastToken.value.length - 1];
149
+ if (lastCharacterOfLastToken === '.' || lastCharacterOfLastToken === '-') {
150
+ tokens = tokens.slice(0, tokens.length - 1);
151
+ return strip(tokens);
152
+ }
153
+ case 'string':
154
+ let tokenBeforeTheLastToken = tokens[tokens.length - 2];
155
+ if (tokenBeforeTheLastToken?.type === 'delimiter') {
156
+ tokens = tokens.slice(0, tokens.length - 1);
157
+ return strip(tokens);
158
+ }
159
+ else if (tokenBeforeTheLastToken?.type === 'brace' && tokenBeforeTheLastToken.value === '{') {
160
+ tokens = tokens.slice(0, tokens.length - 1);
161
+ return strip(tokens);
162
+ }
163
+ break;
164
+ case 'delimiter':
165
+ tokens = tokens.slice(0, tokens.length - 1);
166
+ return strip(tokens);
167
+ }
168
+ return tokens;
169
+ }, unstrip = (tokens) => {
170
+ let tail = [];
171
+ tokens.map((token) => {
172
+ if (token.type === 'brace') {
173
+ if (token.value === '{') {
174
+ tail.push('}');
175
+ }
176
+ else {
177
+ tail.splice(tail.lastIndexOf('}'), 1);
178
+ }
179
+ }
180
+ if (token.type === 'paren') {
181
+ if (token.value === '[') {
182
+ tail.push(']');
183
+ }
184
+ else {
185
+ tail.splice(tail.lastIndexOf(']'), 1);
186
+ }
187
+ }
188
+ });
189
+ if (tail.length > 0) {
190
+ tail.reverse().map((item) => {
191
+ if (item === '}') {
192
+ tokens.push({
193
+ type: 'brace',
194
+ value: '}',
195
+ });
196
+ }
197
+ else if (item === ']') {
198
+ tokens.push({
199
+ type: 'paren',
200
+ value: ']',
201
+ });
202
+ }
203
+ });
204
+ }
205
+ return tokens;
206
+ }, generate = (tokens) => {
207
+ let output = '';
208
+ tokens.map((token) => {
209
+ switch (token.type) {
210
+ case 'string':
211
+ output += '"' + token.value + '"';
212
+ break;
213
+ default:
214
+ output += token.value;
215
+ break;
216
+ }
217
+ });
218
+ return output;
219
+ }, partialParse = (input) => JSON.parse(generate(unstrip(strip(tokenize(input)))));
220
+
221
+ export { partialParse };