@wabot-dev/framework 0.0.2 → 0.0.4

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 (93) hide show
  1. package/dist/src/index.d.ts +445 -10
  2. package/dist/src/mindset/metadata/mindsets/@mindset.js +1 -1
  3. package/dist/src/server/runChannel.js +1 -1
  4. package/dist/src/server/runServer.js +1 -1
  5. package/package.json +5 -5
  6. package/dist/src/_virtual/_commonjsHelpers.js +0 -5
  7. package/dist/src/_virtual/main.js +0 -7
  8. package/dist/src/_virtual/main2.js +0 -3
  9. package/dist/src/ai/index.d.ts +0 -1
  10. package/dist/src/ai/openia/OpenaiChatBotAdapter.d.ts +0 -9
  11. package/dist/src/ai/openia/index.d.ts +0 -1
  12. package/dist/src/channels/cmd/CmdChannel.d.ts +0 -9
  13. package/dist/src/channels/cmd/index.d.ts +0 -1
  14. package/dist/src/channels/index.d.ts +0 -2
  15. package/dist/src/channels/telegram/@telegram.d.ts +0 -2
  16. package/dist/src/channels/telegram/TelegramChannel.d.ts +0 -12
  17. package/dist/src/channels/telegram/TelegramChannelConfig.d.ts +0 -7
  18. package/dist/src/channels/telegram/index.d.ts +0 -3
  19. package/dist/src/chatbot/ChatBot.d.ts +0 -11
  20. package/dist/src/chatbot/ChatBotAdapter.d.ts +0 -26
  21. package/dist/src/chatbot/IChatBot.d.ts +0 -4
  22. package/dist/src/chatbot/chat/Chat.d.ts +0 -23
  23. package/dist/src/chatbot/chat/IChatFunctionCall.d.ts +0 -6
  24. package/dist/src/chatbot/chat/IChatItem.d.ts +0 -19
  25. package/dist/src/chatbot/chat/index.d.ts +0 -4
  26. package/dist/src/chatbot/chat/repository/IChatMemory.d.ts +0 -9
  27. package/dist/src/chatbot/chat/repository/IChatRepository.d.ts +0 -12
  28. package/dist/src/chatbot/chat/repository/index.d.ts +0 -3
  29. package/dist/src/chatbot/chat/repository/ram/RamChatMemory.d.ts +0 -8
  30. package/dist/src/chatbot/chat/repository/ram/RamChatRepository.d.ts +0 -11
  31. package/dist/src/chatbot/chat/repository/ram/index.d.ts +0 -2
  32. package/dist/src/chatbot/index.d.ts +0 -5
  33. package/dist/src/chatbot/metadata/@chatBot.d.ts +0 -3
  34. package/dist/src/chatbot/metadata/ChatBotMetadataStore.d.ts +0 -6
  35. package/dist/src/chatbot/metadata/IChatBotMetadata.d.ts +0 -7
  36. package/dist/src/chatbot/metadata/index.d.ts +0 -3
  37. package/dist/src/context/IContext.d.ts +0 -18
  38. package/dist/src/context/index.d.ts +0 -1
  39. package/dist/src/controller/channel/ChatResolver.d.ts +0 -9
  40. package/dist/src/controller/channel/IChatChannel.d.ts +0 -5
  41. package/dist/src/controller/channel/IMessageContext.d.ts +0 -10
  42. package/dist/src/controller/channel/index.d.ts +0 -3
  43. package/dist/src/controller/index.d.ts +0 -2
  44. package/dist/src/controller/metadata/ControllerMetadataStore.d.ts +0 -12
  45. package/dist/src/controller/metadata/channel/IChannelMetadata.d.ts +0 -8
  46. package/dist/src/controller/metadata/channel/index.d.ts +0 -1
  47. package/dist/src/controller/metadata/controller/@chatController.d.ts +0 -3
  48. package/dist/src/controller/metadata/controller/IChatControllerConfig.d.ts +0 -2
  49. package/dist/src/controller/metadata/controller/IChatControllerMetadata.d.ts +0 -3
  50. package/dist/src/controller/metadata/controller/index.d.ts +0 -3
  51. package/dist/src/controller/metadata/index.d.ts +0 -3
  52. package/dist/src/injection/Container.d.ts +0 -18
  53. package/dist/src/injection/index.d.ts +0 -3
  54. package/dist/src/message/IChatDocument.d.ts +0 -2
  55. package/dist/src/message/IChatImage.d.ts +0 -2
  56. package/dist/src/message/IChatMessage.d.ts +0 -9
  57. package/dist/src/message/IChatSender.d.ts +0 -4
  58. package/dist/src/message/index.d.ts +0 -4
  59. package/dist/src/mindset/IMindset.d.ts +0 -17
  60. package/dist/src/mindset/MindsetOperator.d.ts +0 -25
  61. package/dist/src/mindset/index.d.ts +0 -3
  62. package/dist/src/mindset/metadata/IMindsetMetadata.d.ts +0 -28
  63. package/dist/src/mindset/metadata/MindsetMetadataStore.d.ts +0 -19
  64. package/dist/src/mindset/metadata/functions/@mindsetFunction.d.ts +0 -3
  65. package/dist/src/mindset/metadata/functions/IMindsetFunctionConfig.d.ts +0 -3
  66. package/dist/src/mindset/metadata/functions/IMindsetFunctionDecoration.d.ts +0 -7
  67. package/dist/src/mindset/metadata/functions/decoratorNames.d.ts +0 -1
  68. package/dist/src/mindset/metadata/functions/index.d.ts +0 -4
  69. package/dist/src/mindset/metadata/index.d.ts +0 -6
  70. package/dist/src/mindset/metadata/mindsets/@mindset.d.ts +0 -5
  71. package/dist/src/mindset/metadata/mindsets/IMindsetConfig.d.ts +0 -4
  72. package/dist/src/mindset/metadata/mindsets/IMindsetDecoration.d.ts +0 -6
  73. package/dist/src/mindset/metadata/mindsets/decoratorNames.d.ts +0 -1
  74. package/dist/src/mindset/metadata/mindsets/index.d.ts +0 -3
  75. package/dist/src/mindset/metadata/modules/@mindsetModule.d.ts +0 -4
  76. package/dist/src/mindset/metadata/modules/IMindsetModuleConfig.d.ts +0 -3
  77. package/dist/src/mindset/metadata/modules/IMindsetModuleDecoration.d.ts +0 -5
  78. package/dist/src/mindset/metadata/modules/decoratorNames.d.ts +0 -1
  79. package/dist/src/mindset/metadata/modules/index.d.ts +0 -4
  80. package/dist/src/mindset/metadata/params/@isOptional.d.ts +0 -2
  81. package/dist/src/mindset/metadata/params/@param.d.ts +0 -3
  82. package/dist/src/mindset/metadata/params/IParamConfig.d.ts +0 -4
  83. package/dist/src/mindset/metadata/params/IParamDecoration.d.ts +0 -7
  84. package/dist/src/mindset/metadata/params/decoratorNames.d.ts +0 -2
  85. package/dist/src/mindset/metadata/params/index.d.ts +0 -3
  86. package/dist/src/node_modules/dotenv/lib/main.js +0 -376
  87. package/dist/src/node_modules/dotenv/package.json.js +0 -5
  88. package/dist/src/server/index.d.ts +0 -3
  89. package/dist/src/server/prepareChatContainer.d.ts +0 -5
  90. package/dist/src/server/runChannel.d.ts +0 -12
  91. package/dist/src/server/runServer.d.ts +0 -8
  92. package/dist/src/shared/IConstructor.d.ts +0 -1
  93. package/dist/src/shared/index.d.ts +0 -1
@@ -1,10 +1,445 @@
1
- export * from './ai';
2
- export * from './channels';
3
- export * from './chatbot';
4
- export * from './context';
5
- export * from './controller';
6
- export * from './injection';
7
- export * from './message';
8
- export * from './mindset';
9
- export * from './server';
10
- export * from './shared';
1
+ import * as tsyringe from 'tsyringe';
2
+ import { DependencyContainer, InjectionToken } from 'tsyringe';
3
+ export { DependencyContainer } from 'tsyringe';
4
+ import { InterceptionOptions } from 'tsyringe/dist/typings/types';
5
+ import { PreResolutionInterceptorCallback, PostResolutionInterceptorCallback } from 'tsyringe/dist/typings/types/dependency-container';
6
+
7
+ interface IChatDocument {
8
+ }
9
+
10
+ interface IChatImage {
11
+ }
12
+
13
+ interface IChatSender {
14
+ shortName: string;
15
+ senderId?: string;
16
+ }
17
+
18
+ interface IChatMessage {
19
+ sender: IChatSender;
20
+ text?: string;
21
+ documents?: IChatDocument[];
22
+ images?: IChatImage[];
23
+ }
24
+
25
+ interface IChatFunctionCall {
26
+ foreignId: string;
27
+ name: string;
28
+ arguments?: string;
29
+ result: string;
30
+ }
31
+
32
+ type ISystemMessageItem = {
33
+ type: 'BOT_MESSAGE';
34
+ content: IChatMessage;
35
+ };
36
+ type IUserMessageItem = {
37
+ type: 'USER_MESSAGE';
38
+ content: IChatMessage;
39
+ };
40
+ type ISystemFunctionCallItem = {
41
+ type: 'FUNCTION_CALL';
42
+ content: IChatFunctionCall;
43
+ };
44
+ type IChatItem = {
45
+ id: string;
46
+ createdAt: Date;
47
+ } & (ISystemMessageItem | IUserMessageItem | ISystemFunctionCallItem);
48
+ type IChatItemType = IChatItem['type'];
49
+
50
+ interface IChatMemory {
51
+ findLastItems(count: number): Promise<IChatItem[]>;
52
+ saveItem(item: IChatItem): Promise<void>;
53
+ }
54
+ declare class ChatMemory implements IChatMemory {
55
+ findLastItems(count: number): Promise<IChatItem[]>;
56
+ saveItem(item: IChatItem): Promise<void>;
57
+ }
58
+
59
+ declare class RamChatMemory implements IChatMemory {
60
+ private memory;
61
+ findLastItems(count: number): Promise<IChatItem[]>;
62
+ saveItem(item: IChatItem): Promise<void>;
63
+ clearMemory(): Promise<void>;
64
+ }
65
+
66
+ type IChatType = 'PRIVATE' | 'GROUP';
67
+ interface IChatConnection {
68
+ channelType: string;
69
+ chatId: string;
70
+ }
71
+ interface IChatData {
72
+ id?: string;
73
+ createdAt?: Date;
74
+ type: IChatType;
75
+ connections: IChatConnection[];
76
+ }
77
+ declare class Chat {
78
+ private data;
79
+ constructor(data: IChatData);
80
+ isPrivate(): boolean;
81
+ isGroup(): boolean;
82
+ hasConnection(connection: IChatConnection): boolean;
83
+ private validatePrivateChat;
84
+ private validateGroupChat;
85
+ getId(): string;
86
+ wasCreated(): boolean;
87
+ validate(): void;
88
+ }
89
+
90
+ interface IChatRepository {
91
+ create(chat: Chat): Promise<void>;
92
+ findByConnection(query: IChatConnection): Promise<Chat | null>;
93
+ findMemory(chatId: string): Promise<IChatMemory | null>;
94
+ }
95
+ declare class ChatRepository implements IChatRepository {
96
+ create(chat: Chat): Promise<void>;
97
+ findByConnection(query: IChatConnection): Promise<Chat | null>;
98
+ findMemory(chatId: string): Promise<IChatMemory | null>;
99
+ }
100
+
101
+ declare class RamChatRepository implements IChatRepository {
102
+ private items;
103
+ private memories;
104
+ create(chat: Chat): Promise<void>;
105
+ findByConnection(query: IChatConnection): Promise<Chat | null>;
106
+ findMemory(chatId: string): Promise<IChatMemory | null>;
107
+ private getMemory;
108
+ }
109
+
110
+ interface IMindsetFunctionConfig {
111
+ description: string;
112
+ }
113
+
114
+ declare function mindsetFunction(config: IMindsetFunctionConfig): (target: object, propertyKey: string | symbol) => void;
115
+
116
+ declare const MINDSET_FUNCTION_DECORATION_FUNCTION = "mindsetFunction";
117
+
118
+ interface IMindsetFunctionDecoration {
119
+ decorationName: string;
120
+ functionName: string;
121
+ constructor: Function;
122
+ paramsTypes: Function[];
123
+ decorationConfig: any;
124
+ }
125
+
126
+ type IConstructor<T> = new (...args: any[]) => T;
127
+
128
+ interface IMindsetIdentity {
129
+ name: string;
130
+ language: string;
131
+ age?: number;
132
+ personality?: string;
133
+ emotions?: string;
134
+ }
135
+ interface IMindset {
136
+ identity(): Promise<IMindsetIdentity>;
137
+ skills(): Promise<string>;
138
+ limits(): Promise<string>;
139
+ }
140
+ declare class Mindset implements IMindset {
141
+ identity(): Promise<IMindsetIdentity>;
142
+ skills(): Promise<string>;
143
+ limits(): Promise<string>;
144
+ }
145
+
146
+ interface IMindsetConfig {
147
+ modules?: IConstructor<any>[];
148
+ }
149
+
150
+ declare function mindset(config?: IMindsetConfig): (target: IConstructor<IMindset>) => void;
151
+
152
+ declare const MINDSET_DECORATION_MINDSET = "mindset";
153
+
154
+ interface IMindsetDecoration {
155
+ decorationName: string;
156
+ constructor: Function;
157
+ decorationConfig: IMindsetConfig;
158
+ }
159
+
160
+ interface IMindsetModuleConfig {
161
+ description: string;
162
+ }
163
+
164
+ declare function mindsetModule<A>(config: IMindsetModuleConfig): (target: IConstructor<A>) => void;
165
+
166
+ declare const MINDSET_MODULE_DECORATION_MODULE = "mindsetModule";
167
+
168
+ interface IMindsetModuleDecoration {
169
+ decorationName: string;
170
+ constructor: Function;
171
+ decorationConfig: any;
172
+ }
173
+
174
+ declare function isOptional(): PropertyDecorator;
175
+
176
+ interface IParamConfig {
177
+ name?: string;
178
+ description: string;
179
+ }
180
+
181
+ declare function param(config: IParamConfig): PropertyDecorator;
182
+
183
+ interface IParamDecoration {
184
+ decorationName: string;
185
+ paramType: any;
186
+ paramName: string;
187
+ constructor: Function;
188
+ decorationConfig: any;
189
+ }
190
+
191
+ interface IMindsetFunctionParamMetadata {
192
+ config: IParamConfig;
193
+ name: string;
194
+ type: Function;
195
+ }
196
+ interface IMindsetFunctionMetadata {
197
+ moduleConstructor: Function;
198
+ requestConstructor?: Function;
199
+ name: string;
200
+ config: IMindsetFunctionConfig;
201
+ params: IMindsetFunctionParamMetadata[];
202
+ }
203
+ interface IMindsetModuleMetadata {
204
+ constructor: Function;
205
+ config: IMindsetModuleConfig;
206
+ functions: IMindsetFunctionMetadata[];
207
+ }
208
+ interface IMindsetMetadata {
209
+ constructor: IConstructor<IMindset>;
210
+ config: IMindsetConfig;
211
+ modules: IMindsetModuleMetadata[];
212
+ }
213
+
214
+ declare class MindsetMetadataStore {
215
+ private readonly paramsDecorations;
216
+ private readonly functionsDecorations;
217
+ private readonly modulesDecorations;
218
+ private readonly mindsetsDecorations;
219
+ saveParamDecoration(paramDecoration: IParamDecoration): void;
220
+ saveFunctionDecoration(functionDecoration: IMindsetFunctionDecoration): void;
221
+ saveModuleDecoration(moduleDecoration: IMindsetModuleDecoration): void;
222
+ saveMindsetDecoration(mindsetDecoration: IMindsetDecoration): void;
223
+ getRequestParamsMetadata(requestConstructor: Function): IMindsetFunctionParamMetadata[];
224
+ getFunctionsMetadata(moduleConstructor: Function): IMindsetFunctionMetadata[];
225
+ getModuleMetadata(moduleConstructor: Function): IMindsetModuleMetadata;
226
+ getMindsetMetadata(ctor: Function): IMindsetMetadata;
227
+ }
228
+
229
+ declare class Container implements DependencyContainer {
230
+ register(token: unknown, provider: unknown, options?: unknown): DependencyContainer;
231
+ registerSingleton(from: unknown, to?: unknown): DependencyContainer;
232
+ registerType<T>(from: InjectionToken<T>, to: InjectionToken<T>): DependencyContainer;
233
+ registerInstance<T>(token: InjectionToken<T>, instance: T): DependencyContainer;
234
+ resolve<T>(token: InjectionToken<T>): T;
235
+ resolveAll<T>(token: InjectionToken<T>): T[];
236
+ isRegistered<T>(token: InjectionToken<T>, recursive?: boolean): boolean;
237
+ reset(): void;
238
+ clearInstances(): void;
239
+ createChildContainer(): DependencyContainer;
240
+ beforeResolution<T>(token: InjectionToken<T>, callback: PreResolutionInterceptorCallback<T>, options?: InterceptionOptions): void;
241
+ afterResolution<T>(token: InjectionToken<T>, callback: PostResolutionInterceptorCallback<T>, options?: InterceptionOptions): void;
242
+ dispose(): Promise<void> | void;
243
+ }
244
+
245
+ declare const injectable: typeof tsyringe.injectable;
246
+ declare const container: tsyringe.DependencyContainer;
247
+ declare const singleton: typeof tsyringe.singleton;
248
+ declare const inject: typeof tsyringe.inject;
249
+
250
+ declare class MindsetOperator implements IMindset {
251
+ private mindset;
252
+ private container;
253
+ private metadata;
254
+ constructor(mindset: Mindset, container: Container, metadataStore: MindsetMetadataStore);
255
+ identity(): Promise<IMindsetIdentity>;
256
+ skills(): Promise<string>;
257
+ limits(): Promise<string>;
258
+ callFunction(name: string, params: string): Promise<string>;
259
+ allFunctionsDescriptors(): Promise<{
260
+ readonly type: "function";
261
+ readonly name: string;
262
+ readonly description: string;
263
+ readonly parameters: {
264
+ readonly type: "object";
265
+ readonly properties: {};
266
+ readonly required: string[];
267
+ };
268
+ }[]>;
269
+ private functionDescriptor;
270
+ private toolParam;
271
+ }
272
+
273
+ declare function chatBot(mindset: IConstructor<IMindset>): (target: object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
274
+
275
+ interface IChatBotMetadata {
276
+ constructor: IConstructor<any>;
277
+ mindsetConstructor: IConstructor<IMindset>;
278
+ injectionToken: string;
279
+ }
280
+
281
+ declare class ChatBotMetadataStore {
282
+ private chatBots;
283
+ saveChatBotMetadata(chatBot: IChatBotMetadata): void;
284
+ getChatBotsMetadata(): IChatBotMetadata[];
285
+ }
286
+
287
+ interface IChatBotAdapter {
288
+ generateNextChatItem(chatItems: IChatItem[]): Promise<IChatItem>;
289
+ }
290
+ declare class ChatBotAdapter implements IChatBotAdapter {
291
+ protected mindset: MindsetOperator;
292
+ constructor(mindset: MindsetOperator);
293
+ generateNextChatItem(chatItems: IChatItem[]): Promise<IChatItem>;
294
+ protected systemPrompt(): Promise<string>;
295
+ protected buildBotMessageItem(text: string): Promise<{
296
+ id: string;
297
+ createdAt: Date;
298
+ } & ISystemMessageItem>;
299
+ protected buildFunctionCallItem(foreignId: string, functionName: string, functionArguments: string): Promise<{
300
+ readonly id: string;
301
+ readonly createdAt: Date;
302
+ readonly type: "FUNCTION_CALL";
303
+ readonly content: {
304
+ readonly foreignId: string;
305
+ readonly name: string;
306
+ readonly arguments: string;
307
+ readonly result: string;
308
+ };
309
+ }>;
310
+ }
311
+
312
+ interface IChatBot {
313
+ sendMessage(message: IChatMessage, callback: (message: IChatMessage) => void): void | Promise<void>;
314
+ }
315
+
316
+ declare class ChatBot implements IChatBot {
317
+ private memory;
318
+ private adapter;
319
+ constructor(memory: ChatMemory, adapter: ChatBotAdapter);
320
+ sendMessage(message: IChatMessage, callback: (message: IChatMessage) => void): Promise<void>;
321
+ protected processLoop(callback: (message: IChatMessage) => void): Promise<void>;
322
+ }
323
+
324
+ declare class OpenaiChatBotAdapter extends ChatBotAdapter {
325
+ private openai;
326
+ private model;
327
+ constructor(mindset: MindsetOperator);
328
+ generateNextChatItem(chatItems: IChatItem[]): Promise<IChatItem>;
329
+ private mapChatItems;
330
+ }
331
+
332
+ interface IChatContext {
333
+ chatId: string;
334
+ message: IChatMessage;
335
+ reply: (message: IChatMessage) => void;
336
+ }
337
+ interface IUserContext {
338
+ userId: string;
339
+ }
340
+ interface IContext {
341
+ user?: IUserContext;
342
+ chat: IChatContext;
343
+ }
344
+ declare class Context implements IContext {
345
+ chat: IChatContext;
346
+ user?: IUserContext | undefined;
347
+ constructor(chat: IChatContext, user?: IUserContext | undefined);
348
+ }
349
+
350
+ interface IMessageOrigin {
351
+ chatId: string;
352
+ chatType: IChatType;
353
+ channelType: Function;
354
+ }
355
+ interface IMessageContext extends IChatContext {
356
+ origin: IMessageOrigin;
357
+ }
358
+
359
+ declare class ChatResolver {
360
+ private chatRepository;
361
+ constructor(chatRepository: ChatRepository);
362
+ resolve(origin: IMessageOrigin): Promise<Chat>;
363
+ private resolveGroupChat;
364
+ private resolvePrivateChat;
365
+ }
366
+
367
+ interface IChatChannel {
368
+ listen(callback: (message: IMessageContext) => void): void;
369
+ connect(): void;
370
+ }
371
+
372
+ interface IchatControllerConfig {
373
+ }
374
+
375
+ declare function chatController(config?: IchatControllerConfig): (target: IConstructor<any>) => void;
376
+
377
+ interface IChatControllerMetadata {
378
+ controllerConstructor: Function;
379
+ }
380
+
381
+ interface IChannelMetadata {
382
+ controllerConstructor: IConstructor<any>;
383
+ functionName: string;
384
+ channelConstructor: IConstructor<IChatChannel>;
385
+ channelConfig: object;
386
+ }
387
+
388
+ declare class ControllerMetadataStore {
389
+ private channels;
390
+ private chatControllers;
391
+ saveChannelMetadata(channelMetadata: IChannelMetadata): void;
392
+ saveChatControllerMetadata(controllerMetadata: IChatControllerMetadata): void;
393
+ getChatControllerMetadata(controllerConstructor: Function): {
394
+ config: IChatControllerMetadata;
395
+ channels: IChannelMetadata[];
396
+ } | null;
397
+ }
398
+
399
+ declare class CmdChannel implements IChatChannel {
400
+ private chatResolver;
401
+ private rl;
402
+ private callBack;
403
+ constructor(chatResolver: ChatResolver);
404
+ listen(callback: (message: IMessageContext) => void): void;
405
+ connect(): void;
406
+ }
407
+
408
+ interface ITelegramChannelConfig {
409
+ botToken: string;
410
+ }
411
+ declare class TelegramChannelConfig implements ITelegramChannelConfig {
412
+ botToken: string;
413
+ constructor(botToken: string);
414
+ }
415
+
416
+ declare function telegram(config: ITelegramChannelConfig): (target: object, propertyKey: string | symbol) => void;
417
+
418
+ declare class TelegramChannel implements IChatChannel {
419
+ private config;
420
+ private chatResolver;
421
+ private bot;
422
+ constructor(config: TelegramChannelConfig, chatResolver: ChatResolver);
423
+ listen(callback: (message: IMessageContext) => void): void;
424
+ connect(): void;
425
+ }
426
+
427
+ declare function prepareChatContainer(container: DependencyContainer, context: IContext, mindsetCtor?: IConstructor<IMindset>): Promise<DependencyContainer>;
428
+
429
+ interface IrunChannelProps {
430
+ channel: IConstructor<IChatChannel>;
431
+ channelConfig?: object;
432
+ mindset: IConstructor<IMindset>;
433
+ chatRepository: IConstructor<IChatRepository>;
434
+ chatBotAdapter: IConstructor<IChatBotAdapter>;
435
+ }
436
+ declare function runChannel(props: IrunChannelProps): void;
437
+
438
+ interface IServerConfig {
439
+ controllers: IConstructor<any>[];
440
+ chatRepository?: IConstructor<IChatRepository>;
441
+ chatBotAdapter?: IConstructor<IChatBotAdapter>;
442
+ }
443
+ declare function runServer(config: IServerConfig): void;
444
+
445
+ export { Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Container, Context, ControllerMetadataStore, type IChannelMetadata, type IChatBot, type IChatBotAdapter, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatContext, type IChatControllerMetadata, type IChatData, type IChatDocument, type IChatFunctionCall, type IChatImage, type IChatItem, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatSender, type IChatType, type IConstructor, type IContext, type IMessageContext, type IMessageOrigin, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IParamDecoration, type IServerConfig, type ISystemFunctionCallItem, type ISystemMessageItem, type ITelegramChannelConfig, type IUserContext, type IUserMessageItem, type IchatControllerConfig, type IrunChannelProps, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mindset, MindsetMetadataStore, MindsetOperator, OpenaiChatBotAdapter, RamChatMemory, RamChatRepository, TelegramChannel, TelegramChannelConfig, chatBot, chatController, container, inject, injectable, isOptional, mindset, mindsetFunction, mindsetModule, param, prepareChatContainer, runChannel, runServer, singleton, telegram };
@@ -9,7 +9,7 @@ function mindset(config) {
9
9
  store.saveMindsetDecoration({
10
10
  decorationName: MINDSET_DECORATION_MINDSET,
11
11
  constructor: target,
12
- decorationConfig: config,
12
+ decorationConfig: config ?? {},
13
13
  });
14
14
  injectable()(target);
15
15
  };
@@ -1,4 +1,4 @@
1
- import dotenv from '../_virtual/main.js';
1
+ import dotenv from 'dotenv';
2
2
  import '../chatbot/chat/repository/ram/RamChatRepository.js';
3
3
  import { ChatRepository } from '../chatbot/chat/repository/IChatRepository.js';
4
4
  import { container } from '../injection/index.js';
@@ -1,4 +1,4 @@
1
- import dotenv from '../_virtual/main.js';
1
+ import dotenv from 'dotenv';
2
2
  import { RamChatRepository } from '../chatbot/chat/repository/ram/RamChatRepository.js';
3
3
  import { ChatRepository } from '../chatbot/chat/repository/IChatRepository.js';
4
4
  import { container } from '../injection/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wabot-dev/framework",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Framework for IA Chat Bots",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -10,8 +10,7 @@
10
10
  "dist/src"
11
11
  ],
12
12
  "scripts": {
13
- "build": "rollup --config rollup.config.ts --configPlugin typescript && tsc --declaration --emitDeclarationOnly --declarationDir dist",
14
- "publish": "npm publish --access public",
13
+ "build": "rollup --config rollup.config.ts --configPlugin typescript && tsup --dts-only --format esm --out-dir dist/src src/index.ts",
15
14
  "test:units": "node --import @yucacodes/ts/src/custom-import.mjs --test './src/**/*.unit.test.ts'",
16
15
  "test:integration": "node --import @yucacodes/ts/src/custom-import.mjs --test './src/**/*.integration.test.ts'",
17
16
  "fmt": "prettier --write .",
@@ -28,9 +27,9 @@
28
27
  "@rollup/plugin-typescript": "12.1.2",
29
28
  "@types/node": "22.14.1",
30
29
  "@yucacodes/ts": "^0.0.4",
31
- "dotenv": "^16.5.0",
32
30
  "prettier": "^3.5.3",
33
31
  "rollup": "4.39.0",
32
+ "tsup": "^8.4.0",
34
33
  "typescript": "5.8.3"
35
34
  },
36
35
  "peerDependencies": {
@@ -42,6 +41,7 @@
42
41
  "reflect-metadata": "^0.2.2",
43
42
  "tslib": "^2.8.1",
44
43
  "tsyringe": "^4.9.1",
45
- "uuid": "^11.1.0"
44
+ "uuid": "^11.1.0",
45
+ "dotenv": "^16.5.0"
46
46
  }
47
47
  }
@@ -1,5 +0,0 @@
1
- function getDefaultExportFromCjs (x) {
2
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
3
- }
4
-
5
- export { getDefaultExportFromCjs };
@@ -1,7 +0,0 @@
1
- import { getDefaultExportFromCjs } from './_commonjsHelpers.js';
2
- import { __require as requireMain } from '../node_modules/dotenv/lib/main.js';
3
-
4
- var mainExports = requireMain();
5
- var dotenv = /*@__PURE__*/getDefaultExportFromCjs(mainExports);
6
-
7
- export { dotenv as default };
@@ -1,3 +0,0 @@
1
- var main = {exports: {}};
2
-
3
- export { main as __module };
@@ -1 +0,0 @@
1
- export * from './openia';
@@ -1,9 +0,0 @@
1
- import { ChatBotAdapter, IChatItem } from '@/chatbot';
2
- import { MindsetOperator } from '@/mindset';
3
- export declare class OpenaiChatBotAdapter extends ChatBotAdapter {
4
- private openai;
5
- private model;
6
- constructor(mindset: MindsetOperator);
7
- generateNextChatItem(chatItems: IChatItem[]): Promise<IChatItem>;
8
- private mapChatItems;
9
- }
@@ -1 +0,0 @@
1
- export * from './OpenaiChatBotAdapter';
@@ -1,9 +0,0 @@
1
- import { ChatResolver, IChatChannel, IMessageContext } from '@/controller';
2
- export declare class CmdChannel implements IChatChannel {
3
- private chatResolver;
4
- private rl;
5
- private callBack;
6
- constructor(chatResolver: ChatResolver);
7
- listen(callback: (message: IMessageContext) => void): void;
8
- connect(): void;
9
- }
@@ -1 +0,0 @@
1
- export * from './CmdChannel';
@@ -1,2 +0,0 @@
1
- export * from './cmd';
2
- export * from './telegram';
@@ -1,2 +0,0 @@
1
- import { ITelegramChannelConfig } from './TelegramChannelConfig';
2
- export declare function telegram(config: ITelegramChannelConfig): (target: object, propertyKey: string | symbol) => void;
@@ -1,12 +0,0 @@
1
- import { IChatChannel } from '../../controller/channel/IChatChannel';
2
- import { ChatResolver } from '../../controller/channel/ChatResolver';
3
- import { IMessageContext } from '../../controller/channel/IMessageContext';
4
- import { TelegramChannelConfig } from './TelegramChannelConfig';
5
- export declare class TelegramChannel implements IChatChannel {
6
- private config;
7
- private chatResolver;
8
- private bot;
9
- constructor(config: TelegramChannelConfig, chatResolver: ChatResolver);
10
- listen(callback: (message: IMessageContext) => void): void;
11
- connect(): void;
12
- }
@@ -1,7 +0,0 @@
1
- export interface ITelegramChannelConfig {
2
- botToken: string;
3
- }
4
- export declare class TelegramChannelConfig implements ITelegramChannelConfig {
5
- botToken: string;
6
- constructor(botToken: string);
7
- }
@@ -1,3 +0,0 @@
1
- export * from './@telegram';
2
- export * from './TelegramChannelConfig';
3
- export * from './TelegramChannel';
@@ -1,11 +0,0 @@
1
- import { IChatMessage } from '@/message';
2
- import { ChatBotAdapter } from './ChatBotAdapter';
3
- import { IChatBot } from './IChatBot';
4
- import { ChatMemory } from './chat';
5
- export declare class ChatBot implements IChatBot {
6
- private memory;
7
- private adapter;
8
- constructor(memory: ChatMemory, adapter: ChatBotAdapter);
9
- sendMessage(message: IChatMessage, callback: (message: IChatMessage) => void): Promise<void>;
10
- protected processLoop(callback: (message: IChatMessage) => void): Promise<void>;
11
- }
@@ -1,26 +0,0 @@
1
- import { MindsetOperator } from '@/mindset/MindsetOperator';
2
- import { IChatItem } from './chat/IChatItem';
3
- export interface IChatBotAdapter {
4
- generateNextChatItem(chatItems: IChatItem[]): Promise<IChatItem>;
5
- }
6
- export declare class ChatBotAdapter implements IChatBotAdapter {
7
- protected mindset: MindsetOperator;
8
- constructor(mindset: MindsetOperator);
9
- generateNextChatItem(chatItems: IChatItem[]): Promise<IChatItem>;
10
- protected systemPrompt(): Promise<string>;
11
- protected buildBotMessageItem(text: string): Promise<{
12
- id: string;
13
- createdAt: Date;
14
- } & import("./chat").ISystemMessageItem>;
15
- protected buildFunctionCallItem(foreignId: string, functionName: string, functionArguments: string): Promise<{
16
- readonly id: string;
17
- readonly createdAt: Date;
18
- readonly type: "FUNCTION_CALL";
19
- readonly content: {
20
- readonly foreignId: string;
21
- readonly name: string;
22
- readonly arguments: string;
23
- readonly result: string;
24
- };
25
- }>;
26
- }
@@ -1,4 +0,0 @@
1
- import { IChatMessage } from '@/message';
2
- export interface IChatBot {
3
- sendMessage(message: IChatMessage, callback: (message: IChatMessage) => void): void | Promise<void>;
4
- }
@@ -1,23 +0,0 @@
1
- export type IChatType = 'PRIVATE' | 'GROUP';
2
- export interface IChatConnection {
3
- channelType: string;
4
- chatId: string;
5
- }
6
- export interface IChatData {
7
- id?: string;
8
- createdAt?: Date;
9
- type: IChatType;
10
- connections: IChatConnection[];
11
- }
12
- export declare class Chat {
13
- private data;
14
- constructor(data: IChatData);
15
- isPrivate(): boolean;
16
- isGroup(): boolean;
17
- hasConnection(connection: IChatConnection): boolean;
18
- private validatePrivateChat;
19
- private validateGroupChat;
20
- getId(): string;
21
- wasCreated(): boolean;
22
- validate(): void;
23
- }