@happyvertical/smrt-chat 0.37.6 → 0.37.8

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.
@@ -1,279 +1,119 @@
1
1
  {
2
2
  "version": "1.0.0",
3
- "timestamp": 1782960045835,
3
+ "timestamp": 1783059832073,
4
4
  "packageName": "@happyvertical/smrt-chat",
5
- "packageVersion": "0.37.6",
5
+ "packageVersion": "0.37.8",
6
6
  "objects": {
7
- "@happyvertical/smrt-chat:AgentSession": {
8
- "name": "agentsession",
9
- "className": "AgentSession",
10
- "qualifiedName": "@happyvertical/smrt-chat:AgentSession",
7
+ "@happyvertical/smrt-chat:AgentSessionCollection": {
8
+ "name": "agentsessioncollection",
9
+ "className": "AgentSessionCollection",
10
+ "qualifiedName": "@happyvertical/smrt-chat:AgentSessionCollection",
11
11
  "collection": "agentsessions",
12
- "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/models/AgentSession.ts",
12
+ "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/collections/AgentSessionCollection.ts",
13
13
  "packageName": "@happyvertical/smrt-chat",
14
- "fields": {
15
- "tenantId": {
16
- "type": "text",
17
- "required": false,
18
- "_meta": {
19
- "sqlType": "UUID",
20
- "nullable": true,
21
- "__tenancy": {
22
- "isTenantIdField": true,
23
- "autoFilter": true,
24
- "required": false,
25
- "autoPopulate": true,
26
- "nullable": true,
27
- "mode": "optional",
28
- "field": "tenantId",
29
- "allowSuperAdminBypass": false
30
- }
31
- }
32
- },
33
- "agentId": {
34
- "type": "text",
35
- "required": true,
36
- "default": "",
37
- "_meta": {
38
- "required": true
39
- }
40
- },
41
- "participantProfileId": {
42
- "type": "crossPackageRef",
43
- "required": true,
44
- "related": "@happyvertical/smrt-profiles:Profile"
45
- },
46
- "chatRoomId": {
47
- "type": "foreignKey",
48
- "required": false,
49
- "related": "ChatRoom"
50
- },
51
- "status": {
52
- "type": "text",
53
- "required": true,
54
- "default": "active",
55
- "_meta": {
56
- "required": true
57
- }
58
- },
59
- "allowedTools": {
60
- "type": "text",
61
- "required": false,
62
- "default": "[]"
63
- },
64
- "sessionContext": {
65
- "type": "text",
66
- "required": false,
67
- "default": "{}"
68
- },
69
- "systemPrompt": {
70
- "type": "text",
71
- "required": false,
72
- "default": ""
73
- },
74
- "messageCount": {
75
- "type": "integer",
76
- "required": false,
77
- "default": 0
78
- },
79
- "totalTokensUsed": {
80
- "type": "integer",
81
- "required": false,
82
- "default": 0
83
- },
84
- "maxTokens": {
85
- "type": "integer",
86
- "required": false,
87
- "default": 0
88
- },
89
- "maxMessages": {
90
- "type": "integer",
91
- "required": false,
92
- "default": 0
93
- },
94
- "lastMessageAt": {
95
- "type": "datetime",
96
- "required": false
97
- },
98
- "expiresAt": {
99
- "type": "datetime",
100
- "required": false
101
- },
102
- "closedAt": {
103
- "type": "datetime",
104
- "required": false
105
- }
106
- },
14
+ "fields": {},
107
15
  "methods": {
108
- "getAllowedTools": {
109
- "name": "getAllowedTools",
110
- "async": false,
111
- "parameters": [],
112
- "returnType": "string[]",
113
- "isStatic": false,
114
- "isPublic": true
115
- },
116
- "setAllowedTools": {
117
- "name": "setAllowedTools",
118
- "async": false,
16
+ "findActiveByParticipant": {
17
+ "name": "findActiveByParticipant",
18
+ "async": true,
119
19
  "parameters": [
120
20
  {
121
- "name": "tools",
122
- "type": "string[]",
21
+ "name": "participantProfileId",
22
+ "type": "string",
123
23
  "optional": false
124
24
  }
125
25
  ],
126
- "returnType": "void",
26
+ "returnType": "Promise<AgentSession[]>",
127
27
  "isStatic": false,
128
28
  "isPublic": true
129
29
  },
130
- "isToolAllowed": {
131
- "name": "isToolAllowed",
132
- "async": false,
30
+ "findActiveSession": {
31
+ "name": "findActiveSession",
32
+ "async": true,
133
33
  "parameters": [
134
34
  {
135
- "name": "toolName",
35
+ "name": "agentId",
36
+ "type": "string",
37
+ "optional": false
38
+ },
39
+ {
40
+ "name": "participantProfileId",
136
41
  "type": "string",
137
42
  "optional": false
43
+ },
44
+ {
45
+ "name": "tenantId",
46
+ "type": "string | null",
47
+ "optional": false
48
+ },
49
+ {
50
+ "name": "sessionKey",
51
+ "type": "string | null",
52
+ "optional": true
138
53
  }
139
54
  ],
140
- "returnType": "boolean",
141
- "isStatic": false,
142
- "isPublic": true
143
- },
144
- "isActive": {
145
- "name": "isActive",
146
- "async": false,
147
- "parameters": [],
148
- "returnType": "boolean",
149
- "isStatic": false,
150
- "isPublic": true
151
- },
152
- "isExpired": {
153
- "name": "isExpired",
154
- "async": false,
155
- "parameters": [],
156
- "returnType": "boolean",
157
- "isStatic": false,
158
- "isPublic": true
159
- },
160
- "close": {
161
- "name": "close",
162
- "async": true,
163
- "parameters": [],
164
- "returnType": "Promise<void>",
55
+ "returnType": "Promise<AgentSession | null>",
165
56
  "isStatic": false,
166
57
  "isPublic": true
167
58
  },
168
- "expire": {
169
- "name": "expire",
59
+ "findOrCreate": {
60
+ "name": "findOrCreate",
170
61
  "async": true,
171
- "parameters": [],
172
- "returnType": "Promise<void>",
173
- "isStatic": false,
174
- "isPublic": true
175
- },
176
- "getSessionContext": {
177
- "name": "getSessionContext",
178
- "async": false,
179
- "parameters": [],
180
- "returnType": "Record<string>",
181
- "isStatic": false,
182
- "isPublic": true
183
- },
184
- "setSessionContext": {
185
- "name": "setSessionContext",
186
- "async": false,
187
62
  "parameters": [
188
63
  {
189
- "name": "ctx",
190
- "type": "Record<string>",
64
+ "name": "params",
65
+ "type": "object",
191
66
  "optional": false
192
67
  }
193
68
  ],
194
- "returnType": "void",
195
- "isStatic": false,
196
- "isPublic": true
197
- },
198
- "getSessionKey": {
199
- "name": "getSessionKey",
200
- "async": false,
201
- "parameters": [],
202
- "returnType": "string | null",
69
+ "returnType": "Promise<AgentSession>",
203
70
  "isStatic": false,
204
71
  "isPublic": true
205
72
  },
206
- "updateSessionContext": {
207
- "name": "updateSessionContext",
73
+ "findByAgent": {
74
+ "name": "findByAgent",
208
75
  "async": true,
209
76
  "parameters": [
210
77
  {
211
- "name": "updates",
212
- "type": "Record<string>",
78
+ "name": "agentId",
79
+ "type": "string",
213
80
  "optional": false
214
81
  }
215
82
  ],
216
- "returnType": "Promise<void>",
83
+ "returnType": "Promise<AgentSession[]>",
217
84
  "isStatic": false,
218
85
  "isPublic": true
219
86
  },
220
- "recordMessage": {
221
- "name": "recordMessage",
87
+ "expireStale": {
88
+ "name": "expireStale",
222
89
  "async": true,
223
90
  "parameters": [
224
91
  {
225
- "name": "tokensUsed",
226
- "type": "number",
92
+ "name": "olderThan",
93
+ "type": "Date",
94
+ "optional": false
95
+ },
96
+ {
97
+ "name": "scope",
98
+ "type": "object",
227
99
  "optional": true
228
100
  }
229
101
  ],
230
- "returnType": "Promise<void>",
102
+ "returnType": "Promise<number>",
231
103
  "isStatic": false,
232
104
  "isPublic": true
233
105
  }
234
106
  },
235
107
  "decoratorConfig": {
236
- "tableName": "agent_sessions",
237
- "api": {
238
- "include": [
239
- "list",
240
- "get"
241
- ]
242
- },
243
- "mcp": {
244
- "include": [
245
- "list",
246
- "get"
247
- ]
248
- },
249
- "cli": true,
250
- "tenantScoped": {
251
- "mode": "optional"
252
- }
108
+ "tableName": "agent_sessions"
253
109
  },
254
- "extends": "SmrtObject",
255
- "exportName": "AgentSession",
256
- "collectionExportName": "AgentSessionCollection",
257
- "validationRules": [
258
- {
259
- "field": "agentId",
260
- "rule": "required",
261
- "fieldType": "text"
262
- },
263
- {
264
- "field": "participantProfileId",
265
- "rule": "required",
266
- "fieldType": "crossPackageRef"
267
- },
268
- {
269
- "field": "status",
270
- "rule": "required",
271
- "fieldType": "text"
272
- }
273
- ],
110
+ "extends": "SmrtCollection",
111
+ "extendsTypeArg": "AgentSession",
112
+ "exportName": "AgentSessionCollection",
113
+ "collectionExportName": "AgentSessionCollectionCollection",
274
114
  "schema": {
275
115
  "tableName": "agent_sessions",
276
- "ddl": "CREATE TABLE IF NOT EXISTS \"agent_sessions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"agent_id\" TEXT NOT NULL DEFAULT '',\n \"participant_profile_id\" UUID NOT NULL,\n \"chat_room_id\" UUID,\n \"status\" TEXT NOT NULL DEFAULT 'active',\n \"allowed_tools\" TEXT DEFAULT '[]',\n \"session_context\" TEXT DEFAULT '{}',\n \"system_prompt\" TEXT DEFAULT '',\n \"message_count\" INTEGER DEFAULT 0,\n \"total_tokens_used\" INTEGER DEFAULT 0,\n \"max_tokens\" INTEGER DEFAULT 0,\n \"max_messages\" INTEGER DEFAULT 0,\n \"last_message_at\" TIMESTAMP,\n \"expires_at\" TIMESTAMP,\n \"closed_at\" TIMESTAMP\n);",
116
+ "ddl": "CREATE TABLE IF NOT EXISTS \"agent_sessions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
277
117
  "columns": {
278
118
  "id": {
279
119
  "type": "UUID",
@@ -299,93 +139,6 @@
299
139
  "type": "TIMESTAMP",
300
140
  "notNull": true,
301
141
  "default": "current_timestamp"
302
- },
303
- "tenant_id": {
304
- "type": "UUID",
305
- "referenceKind": "tenantId",
306
- "notNull": false,
307
- "unique": false
308
- },
309
- "agent_id": {
310
- "type": "TEXT",
311
- "notNull": true,
312
- "unique": false,
313
- "default": ""
314
- },
315
- "participant_profile_id": {
316
- "type": "UUID",
317
- "referenceKind": "crossPackageRef",
318
- "notNull": true,
319
- "unique": false
320
- },
321
- "chat_room_id": {
322
- "type": "UUID",
323
- "referenceKind": "foreignKey",
324
- "notNull": false,
325
- "unique": false
326
- },
327
- "status": {
328
- "type": "TEXT",
329
- "notNull": true,
330
- "unique": false,
331
- "default": "active"
332
- },
333
- "allowed_tools": {
334
- "type": "TEXT",
335
- "notNull": false,
336
- "unique": false,
337
- "default": "[]"
338
- },
339
- "session_context": {
340
- "type": "TEXT",
341
- "notNull": false,
342
- "unique": false,
343
- "default": "{}"
344
- },
345
- "system_prompt": {
346
- "type": "TEXT",
347
- "notNull": false,
348
- "unique": false,
349
- "default": ""
350
- },
351
- "message_count": {
352
- "type": "INTEGER",
353
- "notNull": false,
354
- "unique": false,
355
- "default": 0
356
- },
357
- "total_tokens_used": {
358
- "type": "INTEGER",
359
- "notNull": false,
360
- "unique": false,
361
- "default": 0
362
- },
363
- "max_tokens": {
364
- "type": "INTEGER",
365
- "notNull": false,
366
- "unique": false,
367
- "default": 0
368
- },
369
- "max_messages": {
370
- "type": "INTEGER",
371
- "notNull": false,
372
- "unique": false,
373
- "default": 0
374
- },
375
- "last_message_at": {
376
- "type": "TIMESTAMP",
377
- "notNull": false,
378
- "unique": false
379
- },
380
- "expires_at": {
381
- "type": "TIMESTAMP",
382
- "notNull": false,
383
- "unique": false
384
- },
385
- "closed_at": {
386
- "type": "TIMESTAMP",
387
- "notNull": false,
388
- "unique": false
389
142
  }
390
143
  },
391
144
  "indexes": [
@@ -404,308 +157,148 @@
404
157
  "unique": true
405
158
  }
406
159
  ],
407
- "version": "9de59339"
160
+ "version": "e5de0db6"
408
161
  }
409
162
  },
410
- "@happyvertical/smrt-chat:ChatMessage": {
411
- "name": "chatmessage",
412
- "className": "ChatMessage",
413
- "qualifiedName": "@happyvertical/smrt-chat:ChatMessage",
163
+ "@happyvertical/smrt-chat:ChatMessageCollection": {
164
+ "name": "chatmessagecollection",
165
+ "className": "ChatMessageCollection",
166
+ "qualifiedName": "@happyvertical/smrt-chat:ChatMessageCollection",
414
167
  "collection": "chatmessages",
415
- "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatMessage.ts",
168
+ "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatMessageCollection.ts",
416
169
  "packageName": "@happyvertical/smrt-chat",
417
- "fields": {
418
- "tenantId": {
419
- "type": "text",
420
- "required": true,
421
- "_meta": {
422
- "sqlType": "UUID",
423
- "__tenancy": {
424
- "isTenantIdField": true,
425
- "autoFilter": true,
426
- "required": true,
427
- "autoPopulate": true,
428
- "nullable": false,
429
- "mode": "required",
430
- "field": "tenantId",
431
- "allowSuperAdminBypass": false
432
- }
433
- }
434
- },
435
- "roomId": {
436
- "type": "foreignKey",
437
- "required": true,
438
- "related": "ChatRoom",
439
- "_meta": {
440
- "required": true
441
- }
442
- },
443
- "threadId": {
444
- "type": "foreignKey",
445
- "required": false,
446
- "related": "ChatThread"
447
- },
448
- "senderProfileId": {
449
- "type": "crossPackageRef",
450
- "required": true,
451
- "related": "@happyvertical/smrt-profiles:Profile"
452
- },
453
- "agentSessionId": {
454
- "type": "foreignKey",
455
- "required": false,
456
- "related": "AgentSession"
457
- },
458
- "content": {
459
- "type": "text",
460
- "required": false,
461
- "default": ""
462
- },
463
- "messageType": {
464
- "type": "text",
465
- "required": true,
466
- "default": "text",
467
- "_meta": {
468
- "required": true
469
- }
470
- },
471
- "role": {
472
- "type": "text",
473
- "required": true,
474
- "default": "user",
475
- "_meta": {
476
- "required": true
477
- }
478
- },
479
- "isEdited": {
480
- "type": "boolean",
481
- "required": false,
482
- "default": false
483
- },
484
- "editedAt": {
485
- "type": "datetime",
486
- "required": false
487
- },
488
- "isDeleted": {
489
- "type": "boolean",
490
- "required": false,
491
- "default": false
492
- },
493
- "replyToMessageId": {
494
- "type": "foreignKey",
495
- "required": false,
496
- "related": "ChatMessage"
497
- },
498
- "metadata": {
499
- "type": "text",
500
- "required": false,
501
- "default": "{}"
502
- },
503
- "toolCallData": {
504
- "type": "text",
505
- "required": false
506
- },
507
- "attachments": {
508
- "type": "text",
509
- "required": false,
510
- "default": "[]"
511
- }
512
- },
170
+ "fields": {},
513
171
  "methods": {
514
- "getAttachments": {
515
- "name": "getAttachments",
516
- "async": false,
517
- "parameters": [],
518
- "returnType": "Array<object>",
519
- "isStatic": false,
520
- "isPublic": true
521
- },
522
- "setAttachments": {
523
- "name": "setAttachments",
524
- "async": false,
172
+ "getByRoom": {
173
+ "name": "getByRoom",
174
+ "async": true,
525
175
  "parameters": [
526
176
  {
527
- "name": "items",
528
- "type": "Array<object>",
177
+ "name": "roomId",
178
+ "type": "string",
179
+ "optional": false
180
+ },
181
+ {
182
+ "name": "tenantId",
183
+ "type": "string",
529
184
  "optional": false
185
+ },
186
+ {
187
+ "name": "options",
188
+ "type": "object",
189
+ "optional": true
530
190
  }
531
191
  ],
532
- "returnType": "void",
533
- "isStatic": false,
534
- "isPublic": true
535
- },
536
- "getMetadata": {
537
- "name": "getMetadata",
538
- "async": false,
539
- "parameters": [],
540
- "returnType": "Record<string>",
192
+ "returnType": "Promise<ChatMessage[]>",
541
193
  "isStatic": false,
542
194
  "isPublic": true
543
195
  },
544
- "setMetadata": {
545
- "name": "setMetadata",
546
- "async": false,
196
+ "getByThread": {
197
+ "name": "getByThread",
198
+ "async": true,
547
199
  "parameters": [
548
200
  {
549
- "name": "data",
550
- "type": "Record<string>",
201
+ "name": "threadId",
202
+ "type": "string",
203
+ "optional": false
204
+ },
205
+ {
206
+ "name": "tenantId",
207
+ "type": "string",
551
208
  "optional": false
552
209
  }
553
210
  ],
554
- "returnType": "void",
555
- "isStatic": false,
556
- "isPublic": true
557
- },
558
- "getToolCallData": {
559
- "name": "getToolCallData",
560
- "async": false,
561
- "parameters": [],
562
- "returnType": "Record<string> | null",
211
+ "returnType": "Promise<ChatMessage[]>",
563
212
  "isStatic": false,
564
213
  "isPublic": true
565
214
  },
566
- "setToolCallData": {
567
- "name": "setToolCallData",
568
- "async": false,
215
+ "getByAgentSession": {
216
+ "name": "getByAgentSession",
217
+ "async": true,
569
218
  "parameters": [
570
219
  {
571
- "name": "data",
572
- "type": "Record<string> | null",
220
+ "name": "agentSessionId",
221
+ "type": "string",
222
+ "optional": false
223
+ },
224
+ {
225
+ "name": "tenantId",
226
+ "type": "string",
573
227
  "optional": false
574
228
  }
575
229
  ],
576
- "returnType": "void",
577
- "isStatic": false,
578
- "isPublic": true
579
- },
580
- "hasAttachments": {
581
- "name": "hasAttachments",
582
- "async": false,
583
- "parameters": [],
584
- "returnType": "boolean",
585
- "isStatic": false,
586
- "isPublic": true
587
- },
588
- "isToolCall": {
589
- "name": "isToolCall",
590
- "async": false,
591
- "parameters": [],
592
- "returnType": "boolean",
593
- "isStatic": false,
594
- "isPublic": true
595
- },
596
- "isToolResult": {
597
- "name": "isToolResult",
598
- "async": false,
599
- "parameters": [],
600
- "returnType": "boolean",
601
- "isStatic": false,
602
- "isPublic": true
603
- },
604
- "isFromAgent": {
605
- "name": "isFromAgent",
606
- "async": false,
607
- "parameters": [],
608
- "returnType": "boolean",
230
+ "returnType": "Promise<ChatMessage[]>",
609
231
  "isStatic": false,
610
232
  "isPublic": true
611
233
  },
612
- "isSystemMessage": {
613
- "name": "isSystemMessage",
614
- "async": false,
615
- "parameters": [],
616
- "returnType": "boolean",
234
+ "search": {
235
+ "name": "search",
236
+ "async": true,
237
+ "parameters": [
238
+ {
239
+ "name": "filters",
240
+ "type": "any",
241
+ "optional": false
242
+ }
243
+ ],
244
+ "returnType": "Promise<ChatMessage[]>",
617
245
  "isStatic": false,
618
246
  "isPublic": true
619
247
  },
620
- "edit": {
621
- "name": "edit",
248
+ "getUnreadCount": {
249
+ "name": "getUnreadCount",
622
250
  "async": true,
623
251
  "parameters": [
624
252
  {
625
- "name": "newContent",
253
+ "name": "roomId",
254
+ "type": "string",
255
+ "optional": false
256
+ },
257
+ {
258
+ "name": "tenantId",
626
259
  "type": "string",
627
260
  "optional": false
261
+ },
262
+ {
263
+ "name": "lastReadMessageId",
264
+ "type": "string | null",
265
+ "optional": false
628
266
  }
629
267
  ],
630
- "returnType": "Promise<void>",
268
+ "returnType": "Promise<number>",
631
269
  "isStatic": false,
632
270
  "isPublic": true
633
271
  },
634
- "softDelete": {
635
- "name": "softDelete",
272
+ "getLatestPerRoom": {
273
+ "name": "getLatestPerRoom",
636
274
  "async": true,
637
- "parameters": [],
638
- "returnType": "Promise<void>",
639
- "isStatic": false,
640
- "isPublic": true
641
- },
642
- "getPreview": {
643
- "name": "getPreview",
644
- "async": false,
645
275
  "parameters": [
646
276
  {
647
- "name": "maxLength",
648
- "type": "any",
649
- "optional": true
277
+ "name": "roomIds",
278
+ "type": "string[]",
279
+ "optional": false
280
+ },
281
+ {
282
+ "name": "tenantId",
283
+ "type": "string",
284
+ "optional": false
650
285
  }
651
286
  ],
652
- "returnType": "string",
287
+ "returnType": "Promise<Map<string, ChatMessage>>",
653
288
  "isStatic": false,
654
289
  "isPublic": true
655
290
  }
656
291
  },
657
292
  "decoratorConfig": {
658
- "tableName": "chat_messages",
659
- "api": {
660
- "include": [
661
- "list",
662
- "get"
663
- ]
664
- },
665
- "mcp": {
666
- "include": [
667
- "list",
668
- "get"
669
- ]
670
- },
671
- "cli": true,
672
- "tenantScoped": {
673
- "mode": "required"
674
- }
293
+ "tableName": "chat_messages"
675
294
  },
676
- "extends": "SmrtObject",
677
- "exportName": "ChatMessage",
678
- "collectionExportName": "ChatMessageCollection",
679
- "validationRules": [
680
- {
681
- "field": "tenantId",
682
- "rule": "required",
683
- "fieldType": "text"
684
- },
685
- {
686
- "field": "roomId",
687
- "rule": "required",
688
- "fieldType": "foreignKey"
689
- },
690
- {
691
- "field": "senderProfileId",
692
- "rule": "required",
693
- "fieldType": "crossPackageRef"
694
- },
695
- {
696
- "field": "messageType",
697
- "rule": "required",
698
- "fieldType": "text"
699
- },
700
- {
701
- "field": "role",
702
- "rule": "required",
703
- "fieldType": "text"
704
- }
705
- ],
295
+ "extends": "SmrtCollection",
296
+ "extendsTypeArg": "ChatMessage",
297
+ "exportName": "ChatMessageCollection",
298
+ "collectionExportName": "ChatMessageCollectionCollection",
706
299
  "schema": {
707
300
  "tableName": "chat_messages",
708
- "ddl": "CREATE TABLE IF NOT EXISTS \"chat_messages\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"room_id\" UUID NOT NULL,\n \"thread_id\" UUID,\n \"sender_profile_id\" UUID NOT NULL,\n \"agent_session_id\" UUID,\n \"content\" TEXT DEFAULT '',\n \"message_type\" TEXT NOT NULL DEFAULT 'text',\n \"role\" TEXT NOT NULL DEFAULT 'user',\n \"is_edited\" BOOLEAN DEFAULT FALSE,\n \"edited_at\" TIMESTAMP,\n \"is_deleted\" BOOLEAN DEFAULT FALSE,\n \"reply_to_message_id\" UUID,\n \"metadata\" TEXT DEFAULT '{}',\n \"tool_call_data\" TEXT,\n \"attachments\" TEXT DEFAULT '[]'\n);",
301
+ "ddl": "CREATE TABLE IF NOT EXISTS \"chat_messages\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
709
302
  "columns": {
710
303
  "id": {
711
304
  "type": "UUID",
@@ -731,105 +324,225 @@
731
324
  "type": "TIMESTAMP",
732
325
  "notNull": true,
733
326
  "default": "current_timestamp"
327
+ }
328
+ },
329
+ "indexes": [
330
+ {
331
+ "name": "chat_messages_id_idx",
332
+ "columns": [
333
+ "id"
334
+ ]
734
335
  },
735
- "tenant_id": {
736
- "type": "UUID",
737
- "referenceKind": "tenantId",
738
- "notNull": true,
739
- "unique": false
740
- },
741
- "room_id": {
742
- "type": "UUID",
743
- "referenceKind": "foreignKey",
744
- "notNull": true,
745
- "unique": false
746
- },
747
- "thread_id": {
748
- "type": "UUID",
749
- "referenceKind": "foreignKey",
750
- "notNull": false,
751
- "unique": false
752
- },
753
- "sender_profile_id": {
754
- "type": "UUID",
755
- "referenceKind": "crossPackageRef",
756
- "notNull": true,
757
- "unique": false
758
- },
759
- "agent_session_id": {
760
- "type": "UUID",
761
- "referenceKind": "foreignKey",
762
- "notNull": false,
763
- "unique": false
764
- },
765
- "content": {
766
- "type": "TEXT",
767
- "notNull": false,
768
- "unique": false,
769
- "default": ""
770
- },
771
- "message_type": {
772
- "type": "TEXT",
773
- "notNull": true,
774
- "unique": false,
775
- "default": "text"
776
- },
777
- "role": {
778
- "type": "TEXT",
779
- "notNull": true,
780
- "unique": false,
781
- "default": "user"
782
- },
783
- "is_edited": {
784
- "type": "BOOLEAN",
785
- "notNull": false,
786
- "unique": false,
787
- "default": false
788
- },
789
- "edited_at": {
790
- "type": "TIMESTAMP",
791
- "notNull": false,
792
- "unique": false
793
- },
794
- "is_deleted": {
795
- "type": "BOOLEAN",
796
- "notNull": false,
797
- "unique": false,
798
- "default": false
799
- },
800
- "reply_to_message_id": {
336
+ {
337
+ "name": "chat_messages_slug_context_idx",
338
+ "columns": [
339
+ "slug",
340
+ "context"
341
+ ],
342
+ "unique": true
343
+ }
344
+ ],
345
+ "version": "13b2dccb"
346
+ }
347
+ },
348
+ "@happyvertical/smrt-chat:ChatParticipantCollection": {
349
+ "name": "chatparticipantcollection",
350
+ "className": "ChatParticipantCollection",
351
+ "qualifiedName": "@happyvertical/smrt-chat:ChatParticipantCollection",
352
+ "collection": "chatparticipants",
353
+ "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatParticipantCollection.ts",
354
+ "packageName": "@happyvertical/smrt-chat",
355
+ "fields": {},
356
+ "methods": {
357
+ "getByRoom": {
358
+ "name": "getByRoom",
359
+ "async": true,
360
+ "parameters": [
361
+ {
362
+ "name": "roomId",
363
+ "type": "string",
364
+ "optional": false
365
+ }
366
+ ],
367
+ "returnType": "Promise<ChatParticipant[]>",
368
+ "isStatic": false,
369
+ "isPublic": true
370
+ },
371
+ "getByProfile": {
372
+ "name": "getByProfile",
373
+ "async": true,
374
+ "parameters": [
375
+ {
376
+ "name": "profileId",
377
+ "type": "string",
378
+ "optional": false
379
+ }
380
+ ],
381
+ "returnType": "Promise<ChatParticipant[]>",
382
+ "isStatic": false,
383
+ "isPublic": true
384
+ },
385
+ "findMembership": {
386
+ "name": "findMembership",
387
+ "async": true,
388
+ "parameters": [
389
+ {
390
+ "name": "roomId",
391
+ "type": "string",
392
+ "optional": false
393
+ },
394
+ {
395
+ "name": "profileId",
396
+ "type": "string",
397
+ "optional": false
398
+ },
399
+ {
400
+ "name": "tenantId",
401
+ "type": "string",
402
+ "optional": true
403
+ }
404
+ ],
405
+ "returnType": "Promise<ChatParticipant | null>",
406
+ "isStatic": false,
407
+ "isPublic": true
408
+ },
409
+ "findActiveMembership": {
410
+ "name": "findActiveMembership",
411
+ "async": true,
412
+ "parameters": [
413
+ {
414
+ "name": "roomId",
415
+ "type": "string",
416
+ "optional": false
417
+ },
418
+ {
419
+ "name": "profileId",
420
+ "type": "string",
421
+ "optional": false
422
+ },
423
+ {
424
+ "name": "tenantId",
425
+ "type": "string",
426
+ "optional": false
427
+ }
428
+ ],
429
+ "returnType": "Promise<ChatParticipant | null>",
430
+ "isStatic": false,
431
+ "isPublic": true
432
+ },
433
+ "isActiveMember": {
434
+ "name": "isActiveMember",
435
+ "async": true,
436
+ "parameters": [
437
+ {
438
+ "name": "roomId",
439
+ "type": "string",
440
+ "optional": false
441
+ },
442
+ {
443
+ "name": "profileId",
444
+ "type": "string",
445
+ "optional": false
446
+ },
447
+ {
448
+ "name": "tenantId",
449
+ "type": "string",
450
+ "optional": false
451
+ }
452
+ ],
453
+ "returnType": "Promise<boolean>",
454
+ "isStatic": false,
455
+ "isPublic": true
456
+ },
457
+ "getOnlineInRoom": {
458
+ "name": "getOnlineInRoom",
459
+ "async": true,
460
+ "parameters": [
461
+ {
462
+ "name": "roomId",
463
+ "type": "string",
464
+ "optional": false
465
+ }
466
+ ],
467
+ "returnType": "Promise<ChatParticipant[]>",
468
+ "isStatic": false,
469
+ "isPublic": true
470
+ },
471
+ "getAdminsInRoom": {
472
+ "name": "getAdminsInRoom",
473
+ "async": true,
474
+ "parameters": [
475
+ {
476
+ "name": "roomId",
477
+ "type": "string",
478
+ "optional": false
479
+ }
480
+ ],
481
+ "returnType": "Promise<ChatParticipant[]>",
482
+ "isStatic": false,
483
+ "isPublic": true
484
+ },
485
+ "countInRoom": {
486
+ "name": "countInRoom",
487
+ "async": true,
488
+ "parameters": [
489
+ {
490
+ "name": "roomId",
491
+ "type": "string",
492
+ "optional": false
493
+ }
494
+ ],
495
+ "returnType": "Promise<number>",
496
+ "isStatic": false,
497
+ "isPublic": true
498
+ }
499
+ },
500
+ "decoratorConfig": {
501
+ "tableName": "chat_participants"
502
+ },
503
+ "extends": "SmrtCollection",
504
+ "extendsTypeArg": "ChatParticipant",
505
+ "exportName": "ChatParticipantCollection",
506
+ "collectionExportName": "ChatParticipantCollectionCollection",
507
+ "schema": {
508
+ "tableName": "chat_participants",
509
+ "ddl": "CREATE TABLE IF NOT EXISTS \"chat_participants\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
510
+ "columns": {
511
+ "id": {
801
512
  "type": "UUID",
802
- "referenceKind": "foreignKey",
803
- "notNull": false,
804
- "unique": false
513
+ "primaryKey": true,
514
+ "referenceKind": "id",
515
+ "notNull": true
805
516
  },
806
- "metadata": {
517
+ "slug": {
807
518
  "type": "TEXT",
808
- "notNull": false,
809
- "unique": false,
810
- "default": "{}"
519
+ "notNull": true
811
520
  },
812
- "tool_call_data": {
521
+ "context": {
813
522
  "type": "TEXT",
814
- "notNull": false,
815
- "unique": false
523
+ "notNull": true,
524
+ "default": ""
816
525
  },
817
- "attachments": {
818
- "type": "TEXT",
819
- "notNull": false,
820
- "unique": false,
821
- "default": "[]"
526
+ "created_at": {
527
+ "type": "TIMESTAMP",
528
+ "notNull": true,
529
+ "default": "current_timestamp"
530
+ },
531
+ "updated_at": {
532
+ "type": "TIMESTAMP",
533
+ "notNull": true,
534
+ "default": "current_timestamp"
822
535
  }
823
536
  },
824
537
  "indexes": [
825
538
  {
826
- "name": "chat_messages_id_idx",
539
+ "name": "chat_participants_id_idx",
827
540
  "columns": [
828
541
  "id"
829
542
  ]
830
543
  },
831
544
  {
832
- "name": "chat_messages_slug_context_idx",
545
+ "name": "chat_participants_slug_context_idx",
833
546
  "columns": [
834
547
  "slug",
835
548
  "context"
@@ -837,219 +550,238 @@
837
550
  "unique": true
838
551
  }
839
552
  ],
840
- "version": "7469514e"
553
+ "version": "f70abec0"
841
554
  }
842
555
  },
843
- "@happyvertical/smrt-chat:ChatParticipant": {
844
- "name": "chatparticipant",
845
- "className": "ChatParticipant",
846
- "qualifiedName": "@happyvertical/smrt-chat:ChatParticipant",
847
- "collection": "chatparticipants",
848
- "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatParticipant.ts",
556
+ "@happyvertical/smrt-chat:ChatReactionCollection": {
557
+ "name": "chatreactioncollection",
558
+ "className": "ChatReactionCollection",
559
+ "qualifiedName": "@happyvertical/smrt-chat:ChatReactionCollection",
560
+ "collection": "chatreactions",
561
+ "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatReactionCollection.ts",
849
562
  "packageName": "@happyvertical/smrt-chat",
850
- "fields": {
851
- "tenantId": {
852
- "type": "text",
853
- "required": true,
854
- "_meta": {
855
- "sqlType": "UUID",
856
- "__tenancy": {
857
- "isTenantIdField": true,
858
- "autoFilter": true,
859
- "required": true,
860
- "autoPopulate": true,
861
- "nullable": false,
862
- "mode": "required",
863
- "field": "tenantId",
864
- "allowSuperAdminBypass": false
563
+ "fields": {},
564
+ "methods": {
565
+ "getByMessage": {
566
+ "name": "getByMessage",
567
+ "async": true,
568
+ "parameters": [
569
+ {
570
+ "name": "messageId",
571
+ "type": "string",
572
+ "optional": false
865
573
  }
866
- }
867
- },
868
- "roomId": {
869
- "type": "foreignKey",
870
- "required": true,
871
- "related": "ChatRoom",
872
- "_meta": {
873
- "required": true
874
- }
875
- },
876
- "profileId": {
877
- "type": "crossPackageRef",
878
- "required": true,
879
- "related": "@happyvertical/smrt-profiles:Profile"
574
+ ],
575
+ "returnType": "Promise<ChatReaction[]>",
576
+ "isStatic": false,
577
+ "isPublic": true
880
578
  },
881
- "role": {
882
- "type": "text",
883
- "required": true,
884
- "default": "member",
885
- "_meta": {
886
- "required": true
887
- }
579
+ "getReactionCounts": {
580
+ "name": "getReactionCounts",
581
+ "async": true,
582
+ "parameters": [
583
+ {
584
+ "name": "messageId",
585
+ "type": "string",
586
+ "optional": false
587
+ }
588
+ ],
589
+ "returnType": "Promise<Map<string, object>>",
590
+ "isStatic": false,
591
+ "isPublic": true
888
592
  },
889
- "status": {
890
- "type": "text",
891
- "required": true,
892
- "default": "active",
893
- "_meta": {
894
- "required": true
593
+ "toggle": {
594
+ "name": "toggle",
595
+ "async": true,
596
+ "parameters": [
597
+ {
598
+ "name": "messageId",
599
+ "type": "string",
600
+ "optional": false
601
+ },
602
+ {
603
+ "name": "profileId",
604
+ "type": "string",
605
+ "optional": false
606
+ },
607
+ {
608
+ "name": "emoji",
609
+ "type": "string",
610
+ "optional": false
611
+ },
612
+ {
613
+ "name": "tenantId",
614
+ "type": "string",
615
+ "optional": false
616
+ }
617
+ ],
618
+ "returnType": "Promise<object>",
619
+ "isStatic": false,
620
+ "isPublic": true
621
+ }
622
+ },
623
+ "decoratorConfig": {
624
+ "tableName": "chat_reactions"
625
+ },
626
+ "extends": "SmrtCollection",
627
+ "extendsTypeArg": "ChatReaction",
628
+ "exportName": "ChatReactionCollection",
629
+ "collectionExportName": "ChatReactionCollectionCollection",
630
+ "schema": {
631
+ "tableName": "chat_reactions",
632
+ "ddl": "CREATE TABLE IF NOT EXISTS \"chat_reactions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
633
+ "columns": {
634
+ "id": {
635
+ "type": "UUID",
636
+ "primaryKey": true,
637
+ "referenceKind": "id",
638
+ "notNull": true
639
+ },
640
+ "slug": {
641
+ "type": "TEXT",
642
+ "notNull": true
643
+ },
644
+ "context": {
645
+ "type": "TEXT",
646
+ "notNull": true,
647
+ "default": ""
648
+ },
649
+ "created_at": {
650
+ "type": "TIMESTAMP",
651
+ "notNull": true,
652
+ "default": "current_timestamp"
653
+ },
654
+ "updated_at": {
655
+ "type": "TIMESTAMP",
656
+ "notNull": true,
657
+ "default": "current_timestamp"
895
658
  }
896
659
  },
897
- "onlineStatus": {
898
- "type": "text",
899
- "required": true,
900
- "default": "offline",
901
- "_meta": {
902
- "required": true
660
+ "indexes": [
661
+ {
662
+ "name": "chat_reactions_id_idx",
663
+ "columns": [
664
+ "id"
665
+ ]
666
+ },
667
+ {
668
+ "name": "chat_reactions_slug_context_idx",
669
+ "columns": [
670
+ "slug",
671
+ "context"
672
+ ],
673
+ "unique": true
903
674
  }
904
- },
905
- "lastReadMessageId": {
906
- "type": "foreignKey",
907
- "required": false,
908
- "related": "ChatMessage"
909
- },
910
- "lastSeenAt": {
911
- "type": "datetime",
912
- "required": false
913
- },
914
- "joinedAt": {
915
- "type": "datetime",
916
- "required": false
917
- },
918
- "nickname": {
919
- "type": "text",
920
- "required": false,
921
- "default": ""
922
- },
923
- "isMuted": {
924
- "type": "boolean",
925
- "required": false,
926
- "default": false
927
- },
928
- "isPinned": {
929
- "type": "boolean",
930
- "required": false,
931
- "default": false
932
- }
933
- },
675
+ ],
676
+ "version": "0ea62683"
677
+ }
678
+ },
679
+ "@happyvertical/smrt-chat:ChatRoomCollection": {
680
+ "name": "chatroomcollection",
681
+ "className": "ChatRoomCollection",
682
+ "qualifiedName": "@happyvertical/smrt-chat:ChatRoomCollection",
683
+ "collection": "chatrooms",
684
+ "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatRoomCollection.ts",
685
+ "packageName": "@happyvertical/smrt-chat",
686
+ "fields": {},
934
687
  "methods": {
935
- "isActive": {
936
- "name": "isActive",
937
- "async": false,
688
+ "findByType": {
689
+ "name": "findByType",
690
+ "async": true,
691
+ "parameters": [
692
+ {
693
+ "name": "roomType",
694
+ "type": "ChatRoomType",
695
+ "optional": false
696
+ }
697
+ ],
698
+ "returnType": "Promise<ChatRoom[]>",
699
+ "isStatic": false,
700
+ "isPublic": true
701
+ },
702
+ "findPublic": {
703
+ "name": "findPublic",
704
+ "async": true,
938
705
  "parameters": [],
939
- "returnType": "boolean",
706
+ "returnType": "Promise<ChatRoom[]>",
940
707
  "isStatic": false,
941
708
  "isPublic": true
942
709
  },
943
- "isOwner": {
944
- "name": "isOwner",
945
- "async": false,
710
+ "findDMs": {
711
+ "name": "findDMs",
712
+ "async": true,
946
713
  "parameters": [],
947
- "returnType": "boolean",
714
+ "returnType": "Promise<ChatRoom[]>",
948
715
  "isStatic": false,
949
716
  "isPublic": true
950
717
  },
951
- "isAdmin": {
952
- "name": "isAdmin",
953
- "async": false,
718
+ "findAgentRooms": {
719
+ "name": "findAgentRooms",
720
+ "async": true,
954
721
  "parameters": [],
955
- "returnType": "boolean",
722
+ "returnType": "Promise<ChatRoom[]>",
956
723
  "isStatic": false,
957
724
  "isPublic": true
958
725
  },
959
- "markRead": {
960
- "name": "markRead",
726
+ "search": {
727
+ "name": "search",
961
728
  "async": true,
962
729
  "parameters": [
963
730
  {
964
- "name": "messageId",
731
+ "name": "query",
965
732
  "type": "string",
966
733
  "optional": false
734
+ },
735
+ {
736
+ "name": "options",
737
+ "type": "object",
738
+ "optional": true
967
739
  }
968
740
  ],
969
- "returnType": "Promise<void>",
970
- "isStatic": false,
971
- "isPublic": true
972
- },
973
- "leave": {
974
- "name": "leave",
975
- "async": true,
976
- "parameters": [],
977
- "returnType": "Promise<void>",
741
+ "returnType": "Promise<ChatRoom[]>",
978
742
  "isStatic": false,
979
743
  "isPublic": true
980
744
  },
981
- "setOnline": {
982
- "name": "setOnline",
745
+ "findOrCreateDM": {
746
+ "name": "findOrCreateDM",
983
747
  "async": true,
984
748
  "parameters": [
985
749
  {
986
- "name": "status",
987
- "type": "OnlineStatus",
750
+ "name": "profileId1",
751
+ "type": "string",
752
+ "optional": false
753
+ },
754
+ {
755
+ "name": "profileId2",
756
+ "type": "string",
757
+ "optional": false
758
+ },
759
+ {
760
+ "name": "tenantId",
761
+ "type": "string",
762
+ "optional": false
763
+ },
764
+ {
765
+ "name": "participants",
766
+ "type": "ChatParticipantCollection",
988
767
  "optional": false
989
768
  }
990
769
  ],
991
- "returnType": "Promise<void>",
770
+ "returnType": "Promise<ChatRoom>",
992
771
  "isStatic": false,
993
772
  "isPublic": true
994
773
  }
995
774
  },
996
775
  "decoratorConfig": {
997
- "tableName": "chat_participants",
998
- "api": {
999
- "include": [
1000
- "list",
1001
- "get"
1002
- ]
1003
- },
1004
- "mcp": {
1005
- "include": [
1006
- "list",
1007
- "get"
1008
- ]
1009
- },
1010
- "cli": true,
1011
- "tenantScoped": {
1012
- "mode": "required"
1013
- }
776
+ "tableName": "chat_rooms"
1014
777
  },
1015
- "extends": "SmrtObject",
1016
- "exportName": "ChatParticipant",
1017
- "collectionExportName": "ChatParticipantCollection",
1018
- "validationRules": [
1019
- {
1020
- "field": "tenantId",
1021
- "rule": "required",
1022
- "fieldType": "text"
1023
- },
1024
- {
1025
- "field": "roomId",
1026
- "rule": "required",
1027
- "fieldType": "foreignKey"
1028
- },
1029
- {
1030
- "field": "profileId",
1031
- "rule": "required",
1032
- "fieldType": "crossPackageRef"
1033
- },
1034
- {
1035
- "field": "role",
1036
- "rule": "required",
1037
- "fieldType": "text"
1038
- },
1039
- {
1040
- "field": "status",
1041
- "rule": "required",
1042
- "fieldType": "text"
1043
- },
1044
- {
1045
- "field": "onlineStatus",
1046
- "rule": "required",
1047
- "fieldType": "text"
1048
- }
1049
- ],
778
+ "extends": "SmrtCollection",
779
+ "extendsTypeArg": "ChatRoom",
780
+ "exportName": "ChatRoomCollection",
781
+ "collectionExportName": "ChatRoomCollectionCollection",
1050
782
  "schema": {
1051
- "tableName": "chat_participants",
1052
- "ddl": "CREATE TABLE IF NOT EXISTS \"chat_participants\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"room_id\" UUID NOT NULL,\n \"profile_id\" UUID NOT NULL,\n \"role\" TEXT NOT NULL DEFAULT 'member',\n \"status\" TEXT NOT NULL DEFAULT 'active',\n \"online_status\" TEXT NOT NULL DEFAULT 'offline',\n \"last_read_message_id\" UUID,\n \"last_seen_at\" TIMESTAMP,\n \"joined_at\" TIMESTAMP,\n \"nickname\" TEXT DEFAULT '',\n \"is_muted\" BOOLEAN DEFAULT FALSE,\n \"is_pinned\" BOOLEAN DEFAULT FALSE\n);",
783
+ "tableName": "chat_rooms",
784
+ "ddl": "CREATE TABLE IF NOT EXISTS \"chat_rooms\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
1053
785
  "columns": {
1054
786
  "id": {
1055
787
  "type": "UUID",
@@ -1075,87 +807,17 @@
1075
807
  "type": "TIMESTAMP",
1076
808
  "notNull": true,
1077
809
  "default": "current_timestamp"
1078
- },
1079
- "tenant_id": {
1080
- "type": "UUID",
1081
- "referenceKind": "tenantId",
1082
- "notNull": true,
1083
- "unique": false
1084
- },
1085
- "room_id": {
1086
- "type": "UUID",
1087
- "referenceKind": "foreignKey",
1088
- "notNull": true,
1089
- "unique": false
1090
- },
1091
- "profile_id": {
1092
- "type": "UUID",
1093
- "referenceKind": "crossPackageRef",
1094
- "notNull": true,
1095
- "unique": false
1096
- },
1097
- "role": {
1098
- "type": "TEXT",
1099
- "notNull": true,
1100
- "unique": false,
1101
- "default": "member"
1102
- },
1103
- "status": {
1104
- "type": "TEXT",
1105
- "notNull": true,
1106
- "unique": false,
1107
- "default": "active"
1108
- },
1109
- "online_status": {
1110
- "type": "TEXT",
1111
- "notNull": true,
1112
- "unique": false,
1113
- "default": "offline"
1114
- },
1115
- "last_read_message_id": {
1116
- "type": "UUID",
1117
- "referenceKind": "foreignKey",
1118
- "notNull": false,
1119
- "unique": false
1120
- },
1121
- "last_seen_at": {
1122
- "type": "TIMESTAMP",
1123
- "notNull": false,
1124
- "unique": false
1125
- },
1126
- "joined_at": {
1127
- "type": "TIMESTAMP",
1128
- "notNull": false,
1129
- "unique": false
1130
- },
1131
- "nickname": {
1132
- "type": "TEXT",
1133
- "notNull": false,
1134
- "unique": false,
1135
- "default": ""
1136
- },
1137
- "is_muted": {
1138
- "type": "BOOLEAN",
1139
- "notNull": false,
1140
- "unique": false,
1141
- "default": false
1142
- },
1143
- "is_pinned": {
1144
- "type": "BOOLEAN",
1145
- "notNull": false,
1146
- "unique": false,
1147
- "default": false
1148
810
  }
1149
811
  },
1150
812
  "indexes": [
1151
813
  {
1152
- "name": "chat_participants_id_idx",
814
+ "name": "chat_rooms_id_idx",
1153
815
  "columns": [
1154
816
  "id"
1155
817
  ]
1156
818
  },
1157
819
  {
1158
- "name": "chat_participants_slug_context_idx",
820
+ "name": "chat_rooms_slug_context_idx",
1159
821
  "columns": [
1160
822
  "slug",
1161
823
  "context"
@@ -1163,102 +825,65 @@
1163
825
  "unique": true
1164
826
  }
1165
827
  ],
1166
- "version": "50824444"
828
+ "version": "40be4b86"
1167
829
  }
1168
830
  },
1169
- "@happyvertical/smrt-chat:ChatReaction": {
1170
- "name": "chatreaction",
1171
- "className": "ChatReaction",
1172
- "qualifiedName": "@happyvertical/smrt-chat:ChatReaction",
1173
- "collection": "chatreactions",
1174
- "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatReaction.ts",
831
+ "@happyvertical/smrt-chat:ChatThreadCollection": {
832
+ "name": "chatthreadcollection",
833
+ "className": "ChatThreadCollection",
834
+ "qualifiedName": "@happyvertical/smrt-chat:ChatThreadCollection",
835
+ "collection": "chatthreads",
836
+ "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatThreadCollection.ts",
1175
837
  "packageName": "@happyvertical/smrt-chat",
1176
- "fields": {
1177
- "tenantId": {
1178
- "type": "text",
1179
- "required": true,
1180
- "_meta": {
1181
- "sqlType": "UUID",
1182
- "__tenancy": {
1183
- "isTenantIdField": true,
1184
- "autoFilter": true,
1185
- "required": true,
1186
- "autoPopulate": true,
1187
- "nullable": false,
1188
- "mode": "required",
1189
- "field": "tenantId",
1190
- "allowSuperAdminBypass": false
838
+ "fields": {},
839
+ "methods": {
840
+ "getByRoom": {
841
+ "name": "getByRoom",
842
+ "async": true,
843
+ "parameters": [
844
+ {
845
+ "name": "roomId",
846
+ "type": "string",
847
+ "optional": false
1191
848
  }
1192
- }
1193
- },
1194
- "messageId": {
1195
- "type": "foreignKey",
1196
- "required": true,
1197
- "related": "ChatMessage",
1198
- "_meta": {
1199
- "required": true
1200
- }
1201
- },
1202
- "profileId": {
1203
- "type": "crossPackageRef",
1204
- "required": true,
1205
- "related": "@happyvertical/smrt-profiles:Profile"
1206
- },
1207
- "emoji": {
1208
- "type": "text",
1209
- "required": true,
1210
- "default": "",
1211
- "_meta": {
1212
- "required": true
1213
- }
1214
- }
1215
- },
1216
- "methods": {},
1217
- "decoratorConfig": {
1218
- "tableName": "chat_reactions",
1219
- "api": {
1220
- "include": [
1221
- "list"
1222
- ]
1223
- },
1224
- "mcp": {
1225
- "include": [
1226
- "list"
1227
- ]
1228
- },
1229
- "cli": false,
1230
- "tenantScoped": {
1231
- "mode": "required"
1232
- }
1233
- },
1234
- "extends": "SmrtObject",
1235
- "exportName": "ChatReaction",
1236
- "collectionExportName": "ChatReactionCollection",
1237
- "validationRules": [
1238
- {
1239
- "field": "tenantId",
1240
- "rule": "required",
1241
- "fieldType": "text"
1242
- },
1243
- {
1244
- "field": "messageId",
1245
- "rule": "required",
1246
- "fieldType": "foreignKey"
849
+ ],
850
+ "returnType": "Promise<ChatThread[]>",
851
+ "isStatic": false,
852
+ "isPublic": true
1247
853
  },
1248
- {
1249
- "field": "profileId",
1250
- "rule": "required",
1251
- "fieldType": "crossPackageRef"
854
+ "getActive": {
855
+ "name": "getActive",
856
+ "async": true,
857
+ "parameters": [
858
+ {
859
+ "name": "roomId",
860
+ "type": "string",
861
+ "optional": false
862
+ }
863
+ ],
864
+ "returnType": "Promise<ChatThread[]>",
865
+ "isStatic": false,
866
+ "isPublic": true
1252
867
  },
1253
- {
1254
- "field": "emoji",
1255
- "rule": "required",
1256
- "fieldType": "text"
868
+ "getUnresolved": {
869
+ "name": "getUnresolved",
870
+ "async": true,
871
+ "parameters": [],
872
+ "returnType": "Promise<ChatThread[]>",
873
+ "isStatic": false,
874
+ "isPublic": true
1257
875
  }
1258
- ],
876
+ },
877
+ "decoratorConfig": {
878
+ "tableName": "chat_threads"
879
+ },
880
+ "extends": "SmrtCollection",
881
+ "extendsTypeArg": "ChatThread",
882
+ "exportName": "ChatThreadCollection",
883
+ "collectionExportName": "ChatThreadCollectionCollection",
1259
884
  "schema": {
1260
- "tableName": "chat_reactions",
1261
- "ddl": "CREATE TABLE IF NOT EXISTS \"chat_reactions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"message_id\" UUID NOT NULL,\n \"profile_id\" UUID NOT NULL,\n \"emoji\" TEXT NOT NULL DEFAULT ''\n);",
885
+ "tableName": "chat_threads",
886
+ "ddl": "CREATE TABLE IF NOT EXISTS \"chat_threads\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
1262
887
  "columns": {
1263
888
  "id": {
1264
889
  "type": "UUID",
@@ -1284,41 +909,17 @@
1284
909
  "type": "TIMESTAMP",
1285
910
  "notNull": true,
1286
911
  "default": "current_timestamp"
1287
- },
1288
- "tenant_id": {
1289
- "type": "UUID",
1290
- "referenceKind": "tenantId",
1291
- "notNull": true,
1292
- "unique": false
1293
- },
1294
- "message_id": {
1295
- "type": "UUID",
1296
- "referenceKind": "foreignKey",
1297
- "notNull": true,
1298
- "unique": false
1299
- },
1300
- "profile_id": {
1301
- "type": "UUID",
1302
- "referenceKind": "crossPackageRef",
1303
- "notNull": true,
1304
- "unique": false
1305
- },
1306
- "emoji": {
1307
- "type": "TEXT",
1308
- "notNull": true,
1309
- "unique": false,
1310
- "default": ""
1311
912
  }
1312
913
  },
1313
914
  "indexes": [
1314
915
  {
1315
- "name": "chat_reactions_id_idx",
916
+ "name": "chat_threads_id_idx",
1316
917
  "columns": [
1317
918
  "id"
1318
919
  ]
1319
920
  },
1320
921
  {
1321
- "name": "chat_reactions_slug_context_idx",
922
+ "name": "chat_threads_slug_context_idx",
1322
923
  "columns": [
1323
924
  "slug",
1324
925
  "context"
@@ -1326,52 +927,53 @@
1326
927
  "unique": true
1327
928
  }
1328
929
  ],
1329
- "version": "8378c874"
930
+ "version": "760b62bd"
1330
931
  }
1331
932
  },
1332
- "@happyvertical/smrt-chat:ChatRoom": {
1333
- "name": "chatroom",
1334
- "className": "ChatRoom",
1335
- "qualifiedName": "@happyvertical/smrt-chat:ChatRoom",
1336
- "collection": "chatrooms",
1337
- "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatRoom.ts",
933
+ "@happyvertical/smrt-chat:AgentSession": {
934
+ "name": "agentsession",
935
+ "className": "AgentSession",
936
+ "qualifiedName": "@happyvertical/smrt-chat:AgentSession",
937
+ "collection": "agentsessions",
938
+ "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/models/AgentSession.ts",
1338
939
  "packageName": "@happyvertical/smrt-chat",
1339
940
  "fields": {
1340
941
  "tenantId": {
1341
942
  "type": "text",
1342
- "required": true,
943
+ "required": false,
1343
944
  "_meta": {
1344
945
  "sqlType": "UUID",
946
+ "nullable": true,
1345
947
  "__tenancy": {
1346
948
  "isTenantIdField": true,
1347
949
  "autoFilter": true,
1348
- "required": true,
950
+ "required": false,
1349
951
  "autoPopulate": true,
1350
- "nullable": false,
1351
- "mode": "required",
952
+ "nullable": true,
953
+ "mode": "optional",
1352
954
  "field": "tenantId",
1353
955
  "allowSuperAdminBypass": false
1354
956
  }
1355
957
  }
1356
958
  },
1357
- "name": {
1358
- "type": "text",
1359
- "required": false,
1360
- "default": ""
1361
- },
1362
- "description": {
1363
- "type": "text",
1364
- "required": false,
1365
- "default": ""
1366
- },
1367
- "roomType": {
959
+ "agentId": {
1368
960
  "type": "text",
1369
961
  "required": true,
1370
- "default": "public",
962
+ "default": "",
1371
963
  "_meta": {
1372
964
  "required": true
1373
965
  }
1374
966
  },
967
+ "participantProfileId": {
968
+ "type": "crossPackageRef",
969
+ "required": true,
970
+ "related": "@happyvertical/smrt-profiles:Profile"
971
+ },
972
+ "chatRoomId": {
973
+ "type": "foreignKey",
974
+ "required": false,
975
+ "related": "ChatRoom"
976
+ },
1375
977
  "status": {
1376
978
  "type": "text",
1377
979
  "required": true,
@@ -1380,57 +982,70 @@
1380
982
  "required": true
1381
983
  }
1382
984
  },
1383
- "topic": {
985
+ "allowedTools": {
1384
986
  "type": "text",
1385
987
  "required": false,
1386
- "default": ""
988
+ "default": "[]"
1387
989
  },
1388
- "avatarUrl": {
990
+ "sessionContext": {
991
+ "type": "text",
992
+ "required": false,
993
+ "default": "{}"
994
+ },
995
+ "systemPrompt": {
1389
996
  "type": "text",
1390
997
  "required": false,
1391
998
  "default": ""
1392
999
  },
1393
- "isArchived": {
1394
- "type": "boolean",
1000
+ "messageCount": {
1001
+ "type": "integer",
1395
1002
  "required": false,
1396
- "default": false
1003
+ "default": 0
1397
1004
  },
1398
- "maxParticipants": {
1005
+ "totalTokensUsed": {
1399
1006
  "type": "integer",
1400
1007
  "required": false,
1401
1008
  "default": 0
1402
1009
  },
1403
- "metadata": {
1404
- "type": "text",
1010
+ "maxTokens": {
1011
+ "type": "integer",
1405
1012
  "required": false,
1406
- "default": "{}"
1013
+ "default": 0
1407
1014
  },
1408
- "createdByProfileId": {
1409
- "type": "crossPackageRef",
1015
+ "maxMessages": {
1016
+ "type": "integer",
1410
1017
  "required": false,
1411
- "related": "@happyvertical/smrt-profiles:Profile"
1018
+ "default": 0
1412
1019
  },
1413
1020
  "lastMessageAt": {
1414
1021
  "type": "datetime",
1415
1022
  "required": false
1023
+ },
1024
+ "expiresAt": {
1025
+ "type": "datetime",
1026
+ "required": false
1027
+ },
1028
+ "closedAt": {
1029
+ "type": "datetime",
1030
+ "required": false
1416
1031
  }
1417
1032
  },
1418
1033
  "methods": {
1419
- "getMetadata": {
1420
- "name": "getMetadata",
1034
+ "getAllowedTools": {
1035
+ "name": "getAllowedTools",
1421
1036
  "async": false,
1422
1037
  "parameters": [],
1423
- "returnType": "ChatRoomMetadata",
1038
+ "returnType": "string[]",
1424
1039
  "isStatic": false,
1425
1040
  "isPublic": true
1426
1041
  },
1427
- "setMetadata": {
1428
- "name": "setMetadata",
1042
+ "setAllowedTools": {
1043
+ "name": "setAllowedTools",
1429
1044
  "async": false,
1430
1045
  "parameters": [
1431
1046
  {
1432
- "name": "data",
1433
- "type": "ChatRoomMetadata",
1047
+ "name": "tools",
1048
+ "type": "string[]",
1434
1049
  "optional": false
1435
1050
  }
1436
1051
  ],
@@ -1438,71 +1053,113 @@
1438
1053
  "isStatic": false,
1439
1054
  "isPublic": true
1440
1055
  },
1441
- "updateMetadata": {
1442
- "name": "updateMetadata",
1056
+ "isToolAllowed": {
1057
+ "name": "isToolAllowed",
1443
1058
  "async": false,
1444
1059
  "parameters": [
1445
1060
  {
1446
- "name": "updates",
1447
- "type": "ChatRoomMetadata",
1061
+ "name": "toolName",
1062
+ "type": "string",
1448
1063
  "optional": false
1449
1064
  }
1450
1065
  ],
1451
- "returnType": "void",
1066
+ "returnType": "boolean",
1452
1067
  "isStatic": false,
1453
1068
  "isPublic": true
1454
1069
  },
1455
- "isDM": {
1456
- "name": "isDM",
1070
+ "isActive": {
1071
+ "name": "isActive",
1457
1072
  "async": false,
1458
1073
  "parameters": [],
1459
1074
  "returnType": "boolean",
1460
1075
  "isStatic": false,
1461
1076
  "isPublic": true
1462
1077
  },
1463
- "isAgentRoom": {
1464
- "name": "isAgentRoom",
1078
+ "isExpired": {
1079
+ "name": "isExpired",
1465
1080
  "async": false,
1466
1081
  "parameters": [],
1467
1082
  "returnType": "boolean",
1468
1083
  "isStatic": false,
1469
1084
  "isPublic": true
1470
1085
  },
1471
- "isPublic": {
1472
- "name": "isPublic",
1086
+ "close": {
1087
+ "name": "close",
1088
+ "async": true,
1089
+ "parameters": [],
1090
+ "returnType": "Promise<void>",
1091
+ "isStatic": false,
1092
+ "isPublic": true
1093
+ },
1094
+ "expire": {
1095
+ "name": "expire",
1096
+ "async": true,
1097
+ "parameters": [],
1098
+ "returnType": "Promise<void>",
1099
+ "isStatic": false,
1100
+ "isPublic": true
1101
+ },
1102
+ "getSessionContext": {
1103
+ "name": "getSessionContext",
1473
1104
  "async": false,
1474
1105
  "parameters": [],
1475
- "returnType": "boolean",
1106
+ "returnType": "Record<string>",
1476
1107
  "isStatic": false,
1477
1108
  "isPublic": true
1478
1109
  },
1479
- "isActive": {
1480
- "name": "isActive",
1110
+ "setSessionContext": {
1111
+ "name": "setSessionContext",
1112
+ "async": false,
1113
+ "parameters": [
1114
+ {
1115
+ "name": "ctx",
1116
+ "type": "Record<string>",
1117
+ "optional": false
1118
+ }
1119
+ ],
1120
+ "returnType": "void",
1121
+ "isStatic": false,
1122
+ "isPublic": true
1123
+ },
1124
+ "getSessionKey": {
1125
+ "name": "getSessionKey",
1481
1126
  "async": false,
1482
1127
  "parameters": [],
1483
- "returnType": "boolean",
1128
+ "returnType": "string | null",
1484
1129
  "isStatic": false,
1485
1130
  "isPublic": true
1486
1131
  },
1487
- "archive": {
1488
- "name": "archive",
1132
+ "updateSessionContext": {
1133
+ "name": "updateSessionContext",
1489
1134
  "async": true,
1490
- "parameters": [],
1135
+ "parameters": [
1136
+ {
1137
+ "name": "updates",
1138
+ "type": "Record<string>",
1139
+ "optional": false
1140
+ }
1141
+ ],
1491
1142
  "returnType": "Promise<void>",
1492
1143
  "isStatic": false,
1493
1144
  "isPublic": true
1494
1145
  },
1495
- "unarchive": {
1496
- "name": "unarchive",
1146
+ "recordMessage": {
1147
+ "name": "recordMessage",
1497
1148
  "async": true,
1498
- "parameters": [],
1149
+ "parameters": [
1150
+ {
1151
+ "name": "tokensUsed",
1152
+ "type": "number",
1153
+ "optional": true
1154
+ }
1155
+ ],
1499
1156
  "returnType": "Promise<void>",
1500
1157
  "isStatic": false,
1501
1158
  "isPublic": true
1502
1159
  }
1503
1160
  },
1504
1161
  "decoratorConfig": {
1505
- "tableName": "chat_rooms",
1162
+ "tableName": "agent_sessions",
1506
1163
  "api": {
1507
1164
  "include": [
1508
1165
  "list",
@@ -1517,22 +1174,22 @@
1517
1174
  },
1518
1175
  "cli": true,
1519
1176
  "tenantScoped": {
1520
- "mode": "required"
1177
+ "mode": "optional"
1521
1178
  }
1522
1179
  },
1523
1180
  "extends": "SmrtObject",
1524
- "exportName": "ChatRoom",
1525
- "collectionExportName": "ChatRoomCollection",
1181
+ "exportName": "AgentSession",
1182
+ "collectionExportName": "AgentSessionCollection",
1526
1183
  "validationRules": [
1527
1184
  {
1528
- "field": "tenantId",
1185
+ "field": "agentId",
1529
1186
  "rule": "required",
1530
1187
  "fieldType": "text"
1531
1188
  },
1532
1189
  {
1533
- "field": "roomType",
1190
+ "field": "participantProfileId",
1534
1191
  "rule": "required",
1535
- "fieldType": "text"
1192
+ "fieldType": "crossPackageRef"
1536
1193
  },
1537
1194
  {
1538
1195
  "field": "status",
@@ -1540,9 +1197,9 @@
1540
1197
  "fieldType": "text"
1541
1198
  }
1542
1199
  ],
1543
- "schema": {
1544
- "tableName": "chat_rooms",
1545
- "ddl": "CREATE TABLE IF NOT EXISTS \"chat_rooms\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"room_type\" TEXT NOT NULL DEFAULT 'public',\n \"status\" TEXT NOT NULL DEFAULT 'active',\n \"topic\" TEXT DEFAULT '',\n \"avatar_url\" TEXT DEFAULT '',\n \"is_archived\" BOOLEAN DEFAULT FALSE,\n \"max_participants\" INTEGER DEFAULT 0,\n \"metadata\" TEXT DEFAULT '{}',\n \"created_by_profile_id\" UUID,\n \"last_message_at\" TIMESTAMP\n);",
1200
+ "schema": {
1201
+ "tableName": "agent_sessions",
1202
+ "ddl": "CREATE TABLE IF NOT EXISTS \"agent_sessions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"agent_id\" TEXT NOT NULL DEFAULT '',\n \"participant_profile_id\" UUID NOT NULL,\n \"chat_room_id\" UUID,\n \"status\" TEXT NOT NULL DEFAULT 'active',\n \"allowed_tools\" TEXT DEFAULT '[]',\n \"session_context\" TEXT DEFAULT '{}',\n \"system_prompt\" TEXT DEFAULT '',\n \"message_count\" INTEGER DEFAULT 0,\n \"total_tokens_used\" INTEGER DEFAULT 0,\n \"max_tokens\" INTEGER DEFAULT 0,\n \"max_messages\" INTEGER DEFAULT 0,\n \"last_message_at\" TIMESTAMP,\n \"expires_at\" TIMESTAMP,\n \"closed_at\" TIMESTAMP\n);",
1546
1203
  "columns": {
1547
1204
  "id": {
1548
1205
  "type": "UUID",
@@ -1572,84 +1229,100 @@
1572
1229
  "tenant_id": {
1573
1230
  "type": "UUID",
1574
1231
  "referenceKind": "tenantId",
1575
- "notNull": true,
1232
+ "notNull": false,
1576
1233
  "unique": false
1577
1234
  },
1578
- "name": {
1235
+ "agent_id": {
1579
1236
  "type": "TEXT",
1580
- "notNull": false,
1237
+ "notNull": true,
1581
1238
  "unique": false,
1582
1239
  "default": ""
1583
1240
  },
1584
- "description": {
1585
- "type": "TEXT",
1241
+ "participant_profile_id": {
1242
+ "type": "UUID",
1243
+ "referenceKind": "crossPackageRef",
1244
+ "notNull": true,
1245
+ "unique": false
1246
+ },
1247
+ "chat_room_id": {
1248
+ "type": "UUID",
1249
+ "referenceKind": "foreignKey",
1586
1250
  "notNull": false,
1587
- "unique": false,
1588
- "default": ""
1251
+ "unique": false
1589
1252
  },
1590
- "room_type": {
1253
+ "status": {
1591
1254
  "type": "TEXT",
1592
1255
  "notNull": true,
1593
1256
  "unique": false,
1594
- "default": "public"
1257
+ "default": "active"
1595
1258
  },
1596
- "status": {
1259
+ "allowed_tools": {
1597
1260
  "type": "TEXT",
1598
- "notNull": true,
1261
+ "notNull": false,
1599
1262
  "unique": false,
1600
- "default": "active"
1263
+ "default": "[]"
1601
1264
  },
1602
- "topic": {
1265
+ "session_context": {
1603
1266
  "type": "TEXT",
1604
1267
  "notNull": false,
1605
1268
  "unique": false,
1606
- "default": ""
1269
+ "default": "{}"
1607
1270
  },
1608
- "avatar_url": {
1271
+ "system_prompt": {
1609
1272
  "type": "TEXT",
1610
1273
  "notNull": false,
1611
1274
  "unique": false,
1612
1275
  "default": ""
1613
1276
  },
1614
- "is_archived": {
1615
- "type": "BOOLEAN",
1277
+ "message_count": {
1278
+ "type": "INTEGER",
1616
1279
  "notNull": false,
1617
1280
  "unique": false,
1618
- "default": false
1281
+ "default": 0
1619
1282
  },
1620
- "max_participants": {
1283
+ "total_tokens_used": {
1621
1284
  "type": "INTEGER",
1622
1285
  "notNull": false,
1623
1286
  "unique": false,
1624
1287
  "default": 0
1625
1288
  },
1626
- "metadata": {
1627
- "type": "TEXT",
1289
+ "max_tokens": {
1290
+ "type": "INTEGER",
1628
1291
  "notNull": false,
1629
1292
  "unique": false,
1630
- "default": "{}"
1293
+ "default": 0
1631
1294
  },
1632
- "created_by_profile_id": {
1633
- "type": "UUID",
1634
- "referenceKind": "crossPackageRef",
1295
+ "max_messages": {
1296
+ "type": "INTEGER",
1635
1297
  "notNull": false,
1636
- "unique": false
1298
+ "unique": false,
1299
+ "default": 0
1637
1300
  },
1638
1301
  "last_message_at": {
1639
1302
  "type": "TIMESTAMP",
1640
1303
  "notNull": false,
1641
1304
  "unique": false
1305
+ },
1306
+ "expires_at": {
1307
+ "type": "TIMESTAMP",
1308
+ "notNull": false,
1309
+ "unique": false
1310
+ },
1311
+ "closed_at": {
1312
+ "type": "TIMESTAMP",
1313
+ "notNull": false,
1314
+ "unique": false
1642
1315
  }
1643
1316
  },
1644
1317
  "indexes": [
1645
1318
  {
1646
- "name": "chat_rooms_id_idx",
1319
+ "name": "agent_sessions_id_idx",
1647
1320
  "columns": [
1648
1321
  "id"
1649
1322
  ]
1650
1323
  },
1651
1324
  {
1652
- "name": "chat_rooms_slug_context_idx",
1325
+ "name": "agent_sessions_slug_context_idx",
1653
1326
  "columns": [
1654
1327
  "slug",
1655
1328
  "context"
@@ -1657,15 +1330,15 @@
1657
1330
  "unique": true
1658
1331
  }
1659
1332
  ],
1660
- "version": "3665d881"
1333
+ "version": "9de59339"
1661
1334
  }
1662
1335
  },
1663
- "@happyvertical/smrt-chat:ChatThread": {
1664
- "name": "chatthread",
1665
- "className": "ChatThread",
1666
- "qualifiedName": "@happyvertical/smrt-chat:ChatThread",
1667
- "collection": "chatthreads",
1668
- "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatThread.ts",
1336
+ "@happyvertical/smrt-chat:ChatMessage": {
1337
+ "name": "chatmessage",
1338
+ "className": "ChatMessage",
1339
+ "qualifiedName": "@happyvertical/smrt-chat:ChatMessage",
1340
+ "collection": "chatmessages",
1341
+ "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatMessage.ts",
1669
1342
  "packageName": "@happyvertical/smrt-chat",
1670
1343
  "fields": {
1671
1344
  "tenantId": {
@@ -1693,59 +1366,222 @@
1693
1366
  "required": true
1694
1367
  }
1695
1368
  },
1696
- "rootMessageId": {
1369
+ "threadId": {
1697
1370
  "type": "foreignKey",
1698
1371
  "required": false,
1699
- "related": "ChatMessage",
1372
+ "related": "ChatThread"
1373
+ },
1374
+ "senderProfileId": {
1375
+ "type": "crossPackageRef",
1376
+ "required": true,
1377
+ "related": "@happyvertical/smrt-profiles:Profile"
1378
+ },
1379
+ "agentSessionId": {
1380
+ "type": "foreignKey",
1381
+ "required": false,
1382
+ "related": "AgentSession"
1383
+ },
1384
+ "content": {
1385
+ "type": "text",
1386
+ "required": false,
1387
+ "default": ""
1388
+ },
1389
+ "messageType": {
1390
+ "type": "text",
1391
+ "required": true,
1392
+ "default": "text",
1700
1393
  "_meta": {
1701
- "nullable": true
1394
+ "required": true
1702
1395
  }
1703
1396
  },
1704
- "title": {
1397
+ "role": {
1705
1398
  "type": "text",
1399
+ "required": true,
1400
+ "default": "user",
1401
+ "_meta": {
1402
+ "required": true
1403
+ }
1404
+ },
1405
+ "isEdited": {
1406
+ "type": "boolean",
1706
1407
  "required": false,
1707
- "default": ""
1408
+ "default": false
1708
1409
  },
1709
- "isResolved": {
1410
+ "editedAt": {
1411
+ "type": "datetime",
1412
+ "required": false
1413
+ },
1414
+ "isDeleted": {
1710
1415
  "type": "boolean",
1711
1416
  "required": false,
1712
1417
  "default": false
1713
1418
  },
1714
- "messageCount": {
1715
- "type": "integer",
1419
+ "replyToMessageId": {
1420
+ "type": "foreignKey",
1716
1421
  "required": false,
1717
- "default": 0
1422
+ "related": "ChatMessage"
1718
1423
  },
1719
- "lastMessageAt": {
1720
- "type": "datetime",
1424
+ "metadata": {
1425
+ "type": "text",
1426
+ "required": false,
1427
+ "default": "{}"
1428
+ },
1429
+ "toolCallData": {
1430
+ "type": "text",
1721
1431
  "required": false
1722
1432
  },
1723
- "participantCount": {
1724
- "type": "integer",
1725
- "required": false,
1726
- "default": 0
1727
- }
1728
- },
1729
- "methods": {
1730
- "resolve": {
1731
- "name": "resolve",
1433
+ "attachments": {
1434
+ "type": "text",
1435
+ "required": false,
1436
+ "default": "[]"
1437
+ }
1438
+ },
1439
+ "methods": {
1440
+ "getAttachments": {
1441
+ "name": "getAttachments",
1442
+ "async": false,
1443
+ "parameters": [],
1444
+ "returnType": "Array<object>",
1445
+ "isStatic": false,
1446
+ "isPublic": true
1447
+ },
1448
+ "setAttachments": {
1449
+ "name": "setAttachments",
1450
+ "async": false,
1451
+ "parameters": [
1452
+ {
1453
+ "name": "items",
1454
+ "type": "Array<object>",
1455
+ "optional": false
1456
+ }
1457
+ ],
1458
+ "returnType": "void",
1459
+ "isStatic": false,
1460
+ "isPublic": true
1461
+ },
1462
+ "getMetadata": {
1463
+ "name": "getMetadata",
1464
+ "async": false,
1465
+ "parameters": [],
1466
+ "returnType": "Record<string>",
1467
+ "isStatic": false,
1468
+ "isPublic": true
1469
+ },
1470
+ "setMetadata": {
1471
+ "name": "setMetadata",
1472
+ "async": false,
1473
+ "parameters": [
1474
+ {
1475
+ "name": "data",
1476
+ "type": "Record<string>",
1477
+ "optional": false
1478
+ }
1479
+ ],
1480
+ "returnType": "void",
1481
+ "isStatic": false,
1482
+ "isPublic": true
1483
+ },
1484
+ "getToolCallData": {
1485
+ "name": "getToolCallData",
1486
+ "async": false,
1487
+ "parameters": [],
1488
+ "returnType": "Record<string> | null",
1489
+ "isStatic": false,
1490
+ "isPublic": true
1491
+ },
1492
+ "setToolCallData": {
1493
+ "name": "setToolCallData",
1494
+ "async": false,
1495
+ "parameters": [
1496
+ {
1497
+ "name": "data",
1498
+ "type": "Record<string> | null",
1499
+ "optional": false
1500
+ }
1501
+ ],
1502
+ "returnType": "void",
1503
+ "isStatic": false,
1504
+ "isPublic": true
1505
+ },
1506
+ "hasAttachments": {
1507
+ "name": "hasAttachments",
1508
+ "async": false,
1509
+ "parameters": [],
1510
+ "returnType": "boolean",
1511
+ "isStatic": false,
1512
+ "isPublic": true
1513
+ },
1514
+ "isToolCall": {
1515
+ "name": "isToolCall",
1516
+ "async": false,
1517
+ "parameters": [],
1518
+ "returnType": "boolean",
1519
+ "isStatic": false,
1520
+ "isPublic": true
1521
+ },
1522
+ "isToolResult": {
1523
+ "name": "isToolResult",
1524
+ "async": false,
1525
+ "parameters": [],
1526
+ "returnType": "boolean",
1527
+ "isStatic": false,
1528
+ "isPublic": true
1529
+ },
1530
+ "isFromAgent": {
1531
+ "name": "isFromAgent",
1532
+ "async": false,
1533
+ "parameters": [],
1534
+ "returnType": "boolean",
1535
+ "isStatic": false,
1536
+ "isPublic": true
1537
+ },
1538
+ "isSystemMessage": {
1539
+ "name": "isSystemMessage",
1540
+ "async": false,
1541
+ "parameters": [],
1542
+ "returnType": "boolean",
1543
+ "isStatic": false,
1544
+ "isPublic": true
1545
+ },
1546
+ "edit": {
1547
+ "name": "edit",
1732
1548
  "async": true,
1733
- "parameters": [],
1549
+ "parameters": [
1550
+ {
1551
+ "name": "newContent",
1552
+ "type": "string",
1553
+ "optional": false
1554
+ }
1555
+ ],
1734
1556
  "returnType": "Promise<void>",
1735
1557
  "isStatic": false,
1736
1558
  "isPublic": true
1737
1559
  },
1738
- "reopen": {
1739
- "name": "reopen",
1560
+ "softDelete": {
1561
+ "name": "softDelete",
1740
1562
  "async": true,
1741
1563
  "parameters": [],
1742
1564
  "returnType": "Promise<void>",
1743
1565
  "isStatic": false,
1744
1566
  "isPublic": true
1567
+ },
1568
+ "getPreview": {
1569
+ "name": "getPreview",
1570
+ "async": false,
1571
+ "parameters": [
1572
+ {
1573
+ "name": "maxLength",
1574
+ "type": "any",
1575
+ "optional": true
1576
+ }
1577
+ ],
1578
+ "returnType": "string",
1579
+ "isStatic": false,
1580
+ "isPublic": true
1745
1581
  }
1746
1582
  },
1747
1583
  "decoratorConfig": {
1748
- "tableName": "chat_threads",
1584
+ "tableName": "chat_messages",
1749
1585
  "api": {
1750
1586
  "include": [
1751
1587
  "list",
@@ -1764,8 +1600,8 @@
1764
1600
  }
1765
1601
  },
1766
1602
  "extends": "SmrtObject",
1767
- "exportName": "ChatThread",
1768
- "collectionExportName": "ChatThreadCollection",
1603
+ "exportName": "ChatMessage",
1604
+ "collectionExportName": "ChatMessageCollection",
1769
1605
  "validationRules": [
1770
1606
  {
1771
1607
  "field": "tenantId",
@@ -1776,11 +1612,26 @@
1776
1612
  "field": "roomId",
1777
1613
  "rule": "required",
1778
1614
  "fieldType": "foreignKey"
1615
+ },
1616
+ {
1617
+ "field": "senderProfileId",
1618
+ "rule": "required",
1619
+ "fieldType": "crossPackageRef"
1620
+ },
1621
+ {
1622
+ "field": "messageType",
1623
+ "rule": "required",
1624
+ "fieldType": "text"
1625
+ },
1626
+ {
1627
+ "field": "role",
1628
+ "rule": "required",
1629
+ "fieldType": "text"
1779
1630
  }
1780
1631
  ],
1781
1632
  "schema": {
1782
- "tableName": "chat_threads",
1783
- "ddl": "CREATE TABLE IF NOT EXISTS \"chat_threads\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"room_id\" UUID NOT NULL,\n \"root_message_id\" UUID,\n \"title\" TEXT DEFAULT '',\n \"is_resolved\" BOOLEAN DEFAULT FALSE,\n \"message_count\" INTEGER DEFAULT 0,\n \"last_message_at\" TIMESTAMP,\n \"participant_count\" INTEGER DEFAULT 0\n);",
1633
+ "tableName": "chat_messages",
1634
+ "ddl": "CREATE TABLE IF NOT EXISTS \"chat_messages\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"room_id\" UUID NOT NULL,\n \"thread_id\" UUID,\n \"sender_profile_id\" UUID NOT NULL,\n \"agent_session_id\" UUID,\n \"content\" TEXT DEFAULT '',\n \"message_type\" TEXT NOT NULL DEFAULT 'text',\n \"role\" TEXT NOT NULL DEFAULT 'user',\n \"is_edited\" BOOLEAN DEFAULT FALSE,\n \"edited_at\" TIMESTAMP,\n \"is_deleted\" BOOLEAN DEFAULT FALSE,\n \"reply_to_message_id\" UUID,\n \"metadata\" TEXT DEFAULT '{}',\n \"tool_call_data\" TEXT,\n \"attachments\" TEXT DEFAULT '[]'\n);",
1784
1635
  "columns": {
1785
1636
  "id": {
1786
1637
  "type": "UUID",
@@ -1819,207 +1670,92 @@
1819
1670
  "notNull": true,
1820
1671
  "unique": false
1821
1672
  },
1822
- "root_message_id": {
1673
+ "thread_id": {
1823
1674
  "type": "UUID",
1824
1675
  "referenceKind": "foreignKey",
1825
1676
  "notNull": false,
1826
1677
  "unique": false
1827
1678
  },
1828
- "title": {
1679
+ "sender_profile_id": {
1680
+ "type": "UUID",
1681
+ "referenceKind": "crossPackageRef",
1682
+ "notNull": true,
1683
+ "unique": false
1684
+ },
1685
+ "agent_session_id": {
1686
+ "type": "UUID",
1687
+ "referenceKind": "foreignKey",
1688
+ "notNull": false,
1689
+ "unique": false
1690
+ },
1691
+ "content": {
1829
1692
  "type": "TEXT",
1830
1693
  "notNull": false,
1831
1694
  "unique": false,
1832
1695
  "default": ""
1833
1696
  },
1834
- "is_resolved": {
1835
- "type": "BOOLEAN",
1836
- "notNull": false,
1697
+ "message_type": {
1698
+ "type": "TEXT",
1699
+ "notNull": true,
1837
1700
  "unique": false,
1838
- "default": false
1701
+ "default": "text"
1839
1702
  },
1840
- "message_count": {
1841
- "type": "INTEGER",
1703
+ "role": {
1704
+ "type": "TEXT",
1705
+ "notNull": true,
1706
+ "unique": false,
1707
+ "default": "user"
1708
+ },
1709
+ "is_edited": {
1710
+ "type": "BOOLEAN",
1842
1711
  "notNull": false,
1843
1712
  "unique": false,
1844
- "default": 0
1713
+ "default": false
1845
1714
  },
1846
- "last_message_at": {
1715
+ "edited_at": {
1847
1716
  "type": "TIMESTAMP",
1848
1717
  "notNull": false,
1849
1718
  "unique": false
1850
1719
  },
1851
- "participant_count": {
1852
- "type": "INTEGER",
1720
+ "is_deleted": {
1721
+ "type": "BOOLEAN",
1853
1722
  "notNull": false,
1854
1723
  "unique": false,
1855
- "default": 0
1856
- }
1857
- },
1858
- "indexes": [
1859
- {
1860
- "name": "chat_threads_id_idx",
1861
- "columns": [
1862
- "id"
1863
- ]
1724
+ "default": false
1864
1725
  },
1865
- {
1866
- "name": "chat_threads_slug_context_idx",
1867
- "columns": [
1868
- "slug",
1869
- "context"
1870
- ],
1871
- "unique": true
1872
- }
1873
- ],
1874
- "version": "6fd35191"
1875
- }
1876
- },
1877
- "@happyvertical/smrt-chat:AgentSessionCollection": {
1878
- "name": "agentsessioncollection",
1879
- "className": "AgentSessionCollection",
1880
- "qualifiedName": "@happyvertical/smrt-chat:AgentSessionCollection",
1881
- "collection": "agentsessions",
1882
- "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/collections/AgentSessionCollection.ts",
1883
- "packageName": "@happyvertical/smrt-chat",
1884
- "fields": {},
1885
- "methods": {
1886
- "findActiveByParticipant": {
1887
- "name": "findActiveByParticipant",
1888
- "async": true,
1889
- "parameters": [
1890
- {
1891
- "name": "participantProfileId",
1892
- "type": "string",
1893
- "optional": false
1894
- }
1895
- ],
1896
- "returnType": "Promise<AgentSession[]>",
1897
- "isStatic": false,
1898
- "isPublic": true
1899
- },
1900
- "findActiveSession": {
1901
- "name": "findActiveSession",
1902
- "async": true,
1903
- "parameters": [
1904
- {
1905
- "name": "agentId",
1906
- "type": "string",
1907
- "optional": false
1908
- },
1909
- {
1910
- "name": "participantProfileId",
1911
- "type": "string",
1912
- "optional": false
1913
- },
1914
- {
1915
- "name": "tenantId",
1916
- "type": "string | null",
1917
- "optional": false
1918
- },
1919
- {
1920
- "name": "sessionKey",
1921
- "type": "string | null",
1922
- "optional": true
1923
- }
1924
- ],
1925
- "returnType": "Promise<AgentSession | null>",
1926
- "isStatic": false,
1927
- "isPublic": true
1928
- },
1929
- "findOrCreate": {
1930
- "name": "findOrCreate",
1931
- "async": true,
1932
- "parameters": [
1933
- {
1934
- "name": "params",
1935
- "type": "object",
1936
- "optional": false
1937
- }
1938
- ],
1939
- "returnType": "Promise<AgentSession>",
1940
- "isStatic": false,
1941
- "isPublic": true
1942
- },
1943
- "findByAgent": {
1944
- "name": "findByAgent",
1945
- "async": true,
1946
- "parameters": [
1947
- {
1948
- "name": "agentId",
1949
- "type": "string",
1950
- "optional": false
1951
- }
1952
- ],
1953
- "returnType": "Promise<AgentSession[]>",
1954
- "isStatic": false,
1955
- "isPublic": true
1956
- },
1957
- "expireStale": {
1958
- "name": "expireStale",
1959
- "async": true,
1960
- "parameters": [
1961
- {
1962
- "name": "olderThan",
1963
- "type": "Date",
1964
- "optional": false
1965
- },
1966
- {
1967
- "name": "scope",
1968
- "type": "object",
1969
- "optional": true
1970
- }
1971
- ],
1972
- "returnType": "Promise<number>",
1973
- "isStatic": false,
1974
- "isPublic": true
1975
- }
1976
- },
1977
- "decoratorConfig": {
1978
- "tableName": "agent_sessions"
1979
- },
1980
- "extends": "SmrtCollection",
1981
- "extendsTypeArg": "AgentSession",
1982
- "exportName": "AgentSessionCollection",
1983
- "collectionExportName": "AgentSessionCollectionCollection",
1984
- "schema": {
1985
- "tableName": "agent_sessions",
1986
- "ddl": "CREATE TABLE IF NOT EXISTS \"agent_sessions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
1987
- "columns": {
1988
- "id": {
1726
+ "reply_to_message_id": {
1989
1727
  "type": "UUID",
1990
- "primaryKey": true,
1991
- "referenceKind": "id",
1992
- "notNull": true
1728
+ "referenceKind": "foreignKey",
1729
+ "notNull": false,
1730
+ "unique": false
1993
1731
  },
1994
- "slug": {
1732
+ "metadata": {
1995
1733
  "type": "TEXT",
1996
- "notNull": true
1734
+ "notNull": false,
1735
+ "unique": false,
1736
+ "default": "{}"
1997
1737
  },
1998
- "context": {
1738
+ "tool_call_data": {
1999
1739
  "type": "TEXT",
2000
- "notNull": true,
2001
- "default": ""
2002
- },
2003
- "created_at": {
2004
- "type": "TIMESTAMP",
2005
- "notNull": true,
2006
- "default": "current_timestamp"
1740
+ "notNull": false,
1741
+ "unique": false
2007
1742
  },
2008
- "updated_at": {
2009
- "type": "TIMESTAMP",
2010
- "notNull": true,
2011
- "default": "current_timestamp"
1743
+ "attachments": {
1744
+ "type": "TEXT",
1745
+ "notNull": false,
1746
+ "unique": false,
1747
+ "default": "[]"
2012
1748
  }
2013
1749
  },
2014
1750
  "indexes": [
2015
1751
  {
2016
- "name": "agent_sessions_id_idx",
1752
+ "name": "chat_messages_id_idx",
2017
1753
  "columns": [
2018
1754
  "id"
2019
1755
  ]
2020
1756
  },
2021
1757
  {
2022
- "name": "agent_sessions_slug_context_idx",
1758
+ "name": "chat_messages_slug_context_idx",
2023
1759
  "columns": [
2024
1760
  "slug",
2025
1761
  "context"
@@ -2027,148 +1763,219 @@
2027
1763
  "unique": true
2028
1764
  }
2029
1765
  ],
2030
- "version": "e5de0db6"
1766
+ "version": "7469514e"
2031
1767
  }
2032
1768
  },
2033
- "@happyvertical/smrt-chat:ChatMessageCollection": {
2034
- "name": "chatmessagecollection",
2035
- "className": "ChatMessageCollection",
2036
- "qualifiedName": "@happyvertical/smrt-chat:ChatMessageCollection",
2037
- "collection": "chatmessages",
2038
- "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatMessageCollection.ts",
1769
+ "@happyvertical/smrt-chat:ChatParticipant": {
1770
+ "name": "chatparticipant",
1771
+ "className": "ChatParticipant",
1772
+ "qualifiedName": "@happyvertical/smrt-chat:ChatParticipant",
1773
+ "collection": "chatparticipants",
1774
+ "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatParticipant.ts",
2039
1775
  "packageName": "@happyvertical/smrt-chat",
2040
- "fields": {},
2041
- "methods": {
2042
- "getByRoom": {
2043
- "name": "getByRoom",
2044
- "async": true,
2045
- "parameters": [
2046
- {
2047
- "name": "roomId",
2048
- "type": "string",
2049
- "optional": false
2050
- },
2051
- {
2052
- "name": "tenantId",
2053
- "type": "string",
2054
- "optional": false
2055
- },
2056
- {
2057
- "name": "options",
2058
- "type": "object",
2059
- "optional": true
1776
+ "fields": {
1777
+ "tenantId": {
1778
+ "type": "text",
1779
+ "required": true,
1780
+ "_meta": {
1781
+ "sqlType": "UUID",
1782
+ "__tenancy": {
1783
+ "isTenantIdField": true,
1784
+ "autoFilter": true,
1785
+ "required": true,
1786
+ "autoPopulate": true,
1787
+ "nullable": false,
1788
+ "mode": "required",
1789
+ "field": "tenantId",
1790
+ "allowSuperAdminBypass": false
2060
1791
  }
2061
- ],
2062
- "returnType": "Promise<ChatMessage[]>",
1792
+ }
1793
+ },
1794
+ "roomId": {
1795
+ "type": "foreignKey",
1796
+ "required": true,
1797
+ "related": "ChatRoom",
1798
+ "_meta": {
1799
+ "required": true
1800
+ }
1801
+ },
1802
+ "profileId": {
1803
+ "type": "crossPackageRef",
1804
+ "required": true,
1805
+ "related": "@happyvertical/smrt-profiles:Profile"
1806
+ },
1807
+ "role": {
1808
+ "type": "text",
1809
+ "required": true,
1810
+ "default": "member",
1811
+ "_meta": {
1812
+ "required": true
1813
+ }
1814
+ },
1815
+ "status": {
1816
+ "type": "text",
1817
+ "required": true,
1818
+ "default": "active",
1819
+ "_meta": {
1820
+ "required": true
1821
+ }
1822
+ },
1823
+ "onlineStatus": {
1824
+ "type": "text",
1825
+ "required": true,
1826
+ "default": "offline",
1827
+ "_meta": {
1828
+ "required": true
1829
+ }
1830
+ },
1831
+ "lastReadMessageId": {
1832
+ "type": "foreignKey",
1833
+ "required": false,
1834
+ "related": "ChatMessage"
1835
+ },
1836
+ "lastSeenAt": {
1837
+ "type": "datetime",
1838
+ "required": false
1839
+ },
1840
+ "joinedAt": {
1841
+ "type": "datetime",
1842
+ "required": false
1843
+ },
1844
+ "nickname": {
1845
+ "type": "text",
1846
+ "required": false,
1847
+ "default": ""
1848
+ },
1849
+ "isMuted": {
1850
+ "type": "boolean",
1851
+ "required": false,
1852
+ "default": false
1853
+ },
1854
+ "isPinned": {
1855
+ "type": "boolean",
1856
+ "required": false,
1857
+ "default": false
1858
+ }
1859
+ },
1860
+ "methods": {
1861
+ "isActive": {
1862
+ "name": "isActive",
1863
+ "async": false,
1864
+ "parameters": [],
1865
+ "returnType": "boolean",
2063
1866
  "isStatic": false,
2064
1867
  "isPublic": true
2065
1868
  },
2066
- "getByThread": {
2067
- "name": "getByThread",
2068
- "async": true,
2069
- "parameters": [
2070
- {
2071
- "name": "threadId",
2072
- "type": "string",
2073
- "optional": false
2074
- },
2075
- {
2076
- "name": "tenantId",
2077
- "type": "string",
2078
- "optional": false
2079
- }
2080
- ],
2081
- "returnType": "Promise<ChatMessage[]>",
1869
+ "isOwner": {
1870
+ "name": "isOwner",
1871
+ "async": false,
1872
+ "parameters": [],
1873
+ "returnType": "boolean",
2082
1874
  "isStatic": false,
2083
1875
  "isPublic": true
2084
1876
  },
2085
- "getByAgentSession": {
2086
- "name": "getByAgentSession",
2087
- "async": true,
2088
- "parameters": [
2089
- {
2090
- "name": "agentSessionId",
2091
- "type": "string",
2092
- "optional": false
2093
- },
2094
- {
2095
- "name": "tenantId",
2096
- "type": "string",
2097
- "optional": false
2098
- }
2099
- ],
2100
- "returnType": "Promise<ChatMessage[]>",
1877
+ "isAdmin": {
1878
+ "name": "isAdmin",
1879
+ "async": false,
1880
+ "parameters": [],
1881
+ "returnType": "boolean",
2101
1882
  "isStatic": false,
2102
1883
  "isPublic": true
2103
1884
  },
2104
- "search": {
2105
- "name": "search",
1885
+ "markRead": {
1886
+ "name": "markRead",
2106
1887
  "async": true,
2107
1888
  "parameters": [
2108
1889
  {
2109
- "name": "filters",
2110
- "type": "any",
1890
+ "name": "messageId",
1891
+ "type": "string",
2111
1892
  "optional": false
2112
1893
  }
2113
1894
  ],
2114
- "returnType": "Promise<ChatMessage[]>",
1895
+ "returnType": "Promise<void>",
2115
1896
  "isStatic": false,
2116
1897
  "isPublic": true
2117
1898
  },
2118
- "getUnreadCount": {
2119
- "name": "getUnreadCount",
1899
+ "leave": {
1900
+ "name": "leave",
2120
1901
  "async": true,
2121
- "parameters": [
2122
- {
2123
- "name": "roomId",
2124
- "type": "string",
2125
- "optional": false
2126
- },
2127
- {
2128
- "name": "tenantId",
2129
- "type": "string",
2130
- "optional": false
2131
- },
2132
- {
2133
- "name": "lastReadMessageId",
2134
- "type": "string | null",
2135
- "optional": false
2136
- }
2137
- ],
2138
- "returnType": "Promise<number>",
1902
+ "parameters": [],
1903
+ "returnType": "Promise<void>",
2139
1904
  "isStatic": false,
2140
1905
  "isPublic": true
2141
1906
  },
2142
- "getLatestPerRoom": {
2143
- "name": "getLatestPerRoom",
1907
+ "setOnline": {
1908
+ "name": "setOnline",
2144
1909
  "async": true,
2145
1910
  "parameters": [
2146
1911
  {
2147
- "name": "roomIds",
2148
- "type": "string[]",
2149
- "optional": false
2150
- },
2151
- {
2152
- "name": "tenantId",
2153
- "type": "string",
1912
+ "name": "status",
1913
+ "type": "OnlineStatus",
2154
1914
  "optional": false
2155
1915
  }
2156
1916
  ],
2157
- "returnType": "Promise<Map<string, ChatMessage>>",
1917
+ "returnType": "Promise<void>",
2158
1918
  "isStatic": false,
2159
1919
  "isPublic": true
2160
1920
  }
2161
1921
  },
2162
- "decoratorConfig": {
2163
- "tableName": "chat_messages"
2164
- },
2165
- "extends": "SmrtCollection",
2166
- "extendsTypeArg": "ChatMessage",
2167
- "exportName": "ChatMessageCollection",
2168
- "collectionExportName": "ChatMessageCollectionCollection",
1922
+ "decoratorConfig": {
1923
+ "tableName": "chat_participants",
1924
+ "api": {
1925
+ "include": [
1926
+ "list",
1927
+ "get"
1928
+ ]
1929
+ },
1930
+ "mcp": {
1931
+ "include": [
1932
+ "list",
1933
+ "get"
1934
+ ]
1935
+ },
1936
+ "cli": true,
1937
+ "tenantScoped": {
1938
+ "mode": "required"
1939
+ }
1940
+ },
1941
+ "extends": "SmrtObject",
1942
+ "exportName": "ChatParticipant",
1943
+ "collectionExportName": "ChatParticipantCollection",
1944
+ "validationRules": [
1945
+ {
1946
+ "field": "tenantId",
1947
+ "rule": "required",
1948
+ "fieldType": "text"
1949
+ },
1950
+ {
1951
+ "field": "roomId",
1952
+ "rule": "required",
1953
+ "fieldType": "foreignKey"
1954
+ },
1955
+ {
1956
+ "field": "profileId",
1957
+ "rule": "required",
1958
+ "fieldType": "crossPackageRef"
1959
+ },
1960
+ {
1961
+ "field": "role",
1962
+ "rule": "required",
1963
+ "fieldType": "text"
1964
+ },
1965
+ {
1966
+ "field": "status",
1967
+ "rule": "required",
1968
+ "fieldType": "text"
1969
+ },
1970
+ {
1971
+ "field": "onlineStatus",
1972
+ "rule": "required",
1973
+ "fieldType": "text"
1974
+ }
1975
+ ],
2169
1976
  "schema": {
2170
- "tableName": "chat_messages",
2171
- "ddl": "CREATE TABLE IF NOT EXISTS \"chat_messages\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
1977
+ "tableName": "chat_participants",
1978
+ "ddl": "CREATE TABLE IF NOT EXISTS \"chat_participants\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"room_id\" UUID NOT NULL,\n \"profile_id\" UUID NOT NULL,\n \"role\" TEXT NOT NULL DEFAULT 'member',\n \"status\" TEXT NOT NULL DEFAULT 'active',\n \"online_status\" TEXT NOT NULL DEFAULT 'offline',\n \"last_read_message_id\" UUID,\n \"last_seen_at\" TIMESTAMP,\n \"joined_at\" TIMESTAMP,\n \"nickname\" TEXT DEFAULT '',\n \"is_muted\" BOOLEAN DEFAULT FALSE,\n \"is_pinned\" BOOLEAN DEFAULT FALSE\n);",
2172
1979
  "columns": {
2173
1980
  "id": {
2174
1981
  "type": "UUID",
@@ -2194,17 +2001,87 @@
2194
2001
  "type": "TIMESTAMP",
2195
2002
  "notNull": true,
2196
2003
  "default": "current_timestamp"
2004
+ },
2005
+ "tenant_id": {
2006
+ "type": "UUID",
2007
+ "referenceKind": "tenantId",
2008
+ "notNull": true,
2009
+ "unique": false
2010
+ },
2011
+ "room_id": {
2012
+ "type": "UUID",
2013
+ "referenceKind": "foreignKey",
2014
+ "notNull": true,
2015
+ "unique": false
2016
+ },
2017
+ "profile_id": {
2018
+ "type": "UUID",
2019
+ "referenceKind": "crossPackageRef",
2020
+ "notNull": true,
2021
+ "unique": false
2022
+ },
2023
+ "role": {
2024
+ "type": "TEXT",
2025
+ "notNull": true,
2026
+ "unique": false,
2027
+ "default": "member"
2028
+ },
2029
+ "status": {
2030
+ "type": "TEXT",
2031
+ "notNull": true,
2032
+ "unique": false,
2033
+ "default": "active"
2034
+ },
2035
+ "online_status": {
2036
+ "type": "TEXT",
2037
+ "notNull": true,
2038
+ "unique": false,
2039
+ "default": "offline"
2040
+ },
2041
+ "last_read_message_id": {
2042
+ "type": "UUID",
2043
+ "referenceKind": "foreignKey",
2044
+ "notNull": false,
2045
+ "unique": false
2046
+ },
2047
+ "last_seen_at": {
2048
+ "type": "TIMESTAMP",
2049
+ "notNull": false,
2050
+ "unique": false
2051
+ },
2052
+ "joined_at": {
2053
+ "type": "TIMESTAMP",
2054
+ "notNull": false,
2055
+ "unique": false
2056
+ },
2057
+ "nickname": {
2058
+ "type": "TEXT",
2059
+ "notNull": false,
2060
+ "unique": false,
2061
+ "default": ""
2062
+ },
2063
+ "is_muted": {
2064
+ "type": "BOOLEAN",
2065
+ "notNull": false,
2066
+ "unique": false,
2067
+ "default": false
2068
+ },
2069
+ "is_pinned": {
2070
+ "type": "BOOLEAN",
2071
+ "notNull": false,
2072
+ "unique": false,
2073
+ "default": false
2197
2074
  }
2198
2075
  },
2199
2076
  "indexes": [
2200
2077
  {
2201
- "name": "chat_messages_id_idx",
2078
+ "name": "chat_participants_id_idx",
2202
2079
  "columns": [
2203
2080
  "id"
2204
2081
  ]
2205
2082
  },
2206
2083
  {
2207
- "name": "chat_messages_slug_context_idx",
2084
+ "name": "chat_participants_slug_context_idx",
2208
2085
  "columns": [
2209
2086
  "slug",
2210
2087
  "context"
@@ -2212,171 +2089,102 @@
2212
2089
  "unique": true
2213
2090
  }
2214
2091
  ],
2215
- "version": "13b2dccb"
2092
+ "version": "50824444"
2216
2093
  }
2217
2094
  },
2218
- "@happyvertical/smrt-chat:ChatParticipantCollection": {
2219
- "name": "chatparticipantcollection",
2220
- "className": "ChatParticipantCollection",
2221
- "qualifiedName": "@happyvertical/smrt-chat:ChatParticipantCollection",
2222
- "collection": "chatparticipants",
2223
- "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatParticipantCollection.ts",
2095
+ "@happyvertical/smrt-chat:ChatReaction": {
2096
+ "name": "chatreaction",
2097
+ "className": "ChatReaction",
2098
+ "qualifiedName": "@happyvertical/smrt-chat:ChatReaction",
2099
+ "collection": "chatreactions",
2100
+ "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatReaction.ts",
2224
2101
  "packageName": "@happyvertical/smrt-chat",
2225
- "fields": {},
2226
- "methods": {
2227
- "getByRoom": {
2228
- "name": "getByRoom",
2229
- "async": true,
2230
- "parameters": [
2231
- {
2232
- "name": "roomId",
2233
- "type": "string",
2234
- "optional": false
2235
- }
2236
- ],
2237
- "returnType": "Promise<ChatParticipant[]>",
2238
- "isStatic": false,
2239
- "isPublic": true
2240
- },
2241
- "getByProfile": {
2242
- "name": "getByProfile",
2243
- "async": true,
2244
- "parameters": [
2245
- {
2246
- "name": "profileId",
2247
- "type": "string",
2248
- "optional": false
2249
- }
2250
- ],
2251
- "returnType": "Promise<ChatParticipant[]>",
2252
- "isStatic": false,
2253
- "isPublic": true
2254
- },
2255
- "findMembership": {
2256
- "name": "findMembership",
2257
- "async": true,
2258
- "parameters": [
2259
- {
2260
- "name": "roomId",
2261
- "type": "string",
2262
- "optional": false
2263
- },
2264
- {
2265
- "name": "profileId",
2266
- "type": "string",
2267
- "optional": false
2268
- },
2269
- {
2270
- "name": "tenantId",
2271
- "type": "string",
2272
- "optional": true
2273
- }
2274
- ],
2275
- "returnType": "Promise<ChatParticipant | null>",
2276
- "isStatic": false,
2277
- "isPublic": true
2278
- },
2279
- "findActiveMembership": {
2280
- "name": "findActiveMembership",
2281
- "async": true,
2282
- "parameters": [
2283
- {
2284
- "name": "roomId",
2285
- "type": "string",
2286
- "optional": false
2287
- },
2288
- {
2289
- "name": "profileId",
2290
- "type": "string",
2291
- "optional": false
2292
- },
2293
- {
2294
- "name": "tenantId",
2295
- "type": "string",
2296
- "optional": false
2297
- }
2298
- ],
2299
- "returnType": "Promise<ChatParticipant | null>",
2300
- "isStatic": false,
2301
- "isPublic": true
2302
- },
2303
- "isActiveMember": {
2304
- "name": "isActiveMember",
2305
- "async": true,
2306
- "parameters": [
2307
- {
2308
- "name": "roomId",
2309
- "type": "string",
2310
- "optional": false
2311
- },
2312
- {
2313
- "name": "profileId",
2314
- "type": "string",
2315
- "optional": false
2316
- },
2317
- {
2318
- "name": "tenantId",
2319
- "type": "string",
2320
- "optional": false
2321
- }
2322
- ],
2323
- "returnType": "Promise<boolean>",
2324
- "isStatic": false,
2325
- "isPublic": true
2326
- },
2327
- "getOnlineInRoom": {
2328
- "name": "getOnlineInRoom",
2329
- "async": true,
2330
- "parameters": [
2331
- {
2332
- "name": "roomId",
2333
- "type": "string",
2334
- "optional": false
2102
+ "fields": {
2103
+ "tenantId": {
2104
+ "type": "text",
2105
+ "required": true,
2106
+ "_meta": {
2107
+ "sqlType": "UUID",
2108
+ "__tenancy": {
2109
+ "isTenantIdField": true,
2110
+ "autoFilter": true,
2111
+ "required": true,
2112
+ "autoPopulate": true,
2113
+ "nullable": false,
2114
+ "mode": "required",
2115
+ "field": "tenantId",
2116
+ "allowSuperAdminBypass": false
2335
2117
  }
2336
- ],
2337
- "returnType": "Promise<ChatParticipant[]>",
2338
- "isStatic": false,
2339
- "isPublic": true
2118
+ }
2340
2119
  },
2341
- "getAdminsInRoom": {
2342
- "name": "getAdminsInRoom",
2343
- "async": true,
2344
- "parameters": [
2345
- {
2346
- "name": "roomId",
2347
- "type": "string",
2348
- "optional": false
2349
- }
2350
- ],
2351
- "returnType": "Promise<ChatParticipant[]>",
2352
- "isStatic": false,
2353
- "isPublic": true
2120
+ "messageId": {
2121
+ "type": "foreignKey",
2122
+ "required": true,
2123
+ "related": "ChatMessage",
2124
+ "_meta": {
2125
+ "required": true
2126
+ }
2354
2127
  },
2355
- "countInRoom": {
2356
- "name": "countInRoom",
2357
- "async": true,
2358
- "parameters": [
2359
- {
2360
- "name": "roomId",
2361
- "type": "string",
2362
- "optional": false
2363
- }
2364
- ],
2365
- "returnType": "Promise<number>",
2366
- "isStatic": false,
2367
- "isPublic": true
2128
+ "profileId": {
2129
+ "type": "crossPackageRef",
2130
+ "required": true,
2131
+ "related": "@happyvertical/smrt-profiles:Profile"
2132
+ },
2133
+ "emoji": {
2134
+ "type": "text",
2135
+ "required": true,
2136
+ "default": "",
2137
+ "_meta": {
2138
+ "required": true
2139
+ }
2368
2140
  }
2369
2141
  },
2142
+ "methods": {},
2370
2143
  "decoratorConfig": {
2371
- "tableName": "chat_participants"
2144
+ "tableName": "chat_reactions",
2145
+ "api": {
2146
+ "include": [
2147
+ "list"
2148
+ ]
2149
+ },
2150
+ "mcp": {
2151
+ "include": [
2152
+ "list"
2153
+ ]
2154
+ },
2155
+ "cli": false,
2156
+ "tenantScoped": {
2157
+ "mode": "required"
2158
+ }
2372
2159
  },
2373
- "extends": "SmrtCollection",
2374
- "extendsTypeArg": "ChatParticipant",
2375
- "exportName": "ChatParticipantCollection",
2376
- "collectionExportName": "ChatParticipantCollectionCollection",
2160
+ "extends": "SmrtObject",
2161
+ "exportName": "ChatReaction",
2162
+ "collectionExportName": "ChatReactionCollection",
2163
+ "validationRules": [
2164
+ {
2165
+ "field": "tenantId",
2166
+ "rule": "required",
2167
+ "fieldType": "text"
2168
+ },
2169
+ {
2170
+ "field": "messageId",
2171
+ "rule": "required",
2172
+ "fieldType": "foreignKey"
2173
+ },
2174
+ {
2175
+ "field": "profileId",
2176
+ "rule": "required",
2177
+ "fieldType": "crossPackageRef"
2178
+ },
2179
+ {
2180
+ "field": "emoji",
2181
+ "rule": "required",
2182
+ "fieldType": "text"
2183
+ }
2184
+ ],
2377
2185
  "schema": {
2378
- "tableName": "chat_participants",
2379
- "ddl": "CREATE TABLE IF NOT EXISTS \"chat_participants\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
2186
+ "tableName": "chat_reactions",
2187
+ "ddl": "CREATE TABLE IF NOT EXISTS \"chat_reactions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"message_id\" UUID NOT NULL,\n \"profile_id\" UUID NOT NULL,\n \"emoji\" TEXT NOT NULL DEFAULT ''\n);",
2380
2188
  "columns": {
2381
2189
  "id": {
2382
2190
  "type": "UUID",
@@ -2402,17 +2210,41 @@
2402
2210
  "type": "TIMESTAMP",
2403
2211
  "notNull": true,
2404
2212
  "default": "current_timestamp"
2213
+ },
2214
+ "tenant_id": {
2215
+ "type": "UUID",
2216
+ "referenceKind": "tenantId",
2217
+ "notNull": true,
2218
+ "unique": false
2219
+ },
2220
+ "message_id": {
2221
+ "type": "UUID",
2222
+ "referenceKind": "foreignKey",
2223
+ "notNull": true,
2224
+ "unique": false
2225
+ },
2226
+ "profile_id": {
2227
+ "type": "UUID",
2228
+ "referenceKind": "crossPackageRef",
2229
+ "notNull": true,
2230
+ "unique": false
2231
+ },
2232
+ "emoji": {
2233
+ "type": "TEXT",
2234
+ "notNull": true,
2235
+ "unique": false,
2236
+ "default": ""
2405
2237
  }
2406
2238
  },
2407
2239
  "indexes": [
2408
2240
  {
2409
- "name": "chat_participants_id_idx",
2241
+ "name": "chat_reactions_id_idx",
2410
2242
  "columns": [
2411
2243
  "id"
2412
2244
  ]
2413
2245
  },
2414
2246
  {
2415
- "name": "chat_participants_slug_context_idx",
2247
+ "name": "chat_reactions_slug_context_idx",
2416
2248
  "columns": [
2417
2249
  "slug",
2418
2250
  "context"
@@ -2420,238 +2252,223 @@
2420
2252
  "unique": true
2421
2253
  }
2422
2254
  ],
2423
- "version": "f70abec0"
2255
+ "version": "8378c874"
2424
2256
  }
2425
2257
  },
2426
- "@happyvertical/smrt-chat:ChatReactionCollection": {
2427
- "name": "chatreactioncollection",
2428
- "className": "ChatReactionCollection",
2429
- "qualifiedName": "@happyvertical/smrt-chat:ChatReactionCollection",
2430
- "collection": "chatreactions",
2431
- "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatReactionCollection.ts",
2258
+ "@happyvertical/smrt-chat:ChatRoom": {
2259
+ "name": "chatroom",
2260
+ "className": "ChatRoom",
2261
+ "qualifiedName": "@happyvertical/smrt-chat:ChatRoom",
2262
+ "collection": "chatrooms",
2263
+ "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatRoom.ts",
2432
2264
  "packageName": "@happyvertical/smrt-chat",
2433
- "fields": {},
2434
- "methods": {
2435
- "getByMessage": {
2436
- "name": "getByMessage",
2437
- "async": true,
2438
- "parameters": [
2439
- {
2440
- "name": "messageId",
2441
- "type": "string",
2442
- "optional": false
2265
+ "fields": {
2266
+ "tenantId": {
2267
+ "type": "text",
2268
+ "required": true,
2269
+ "_meta": {
2270
+ "sqlType": "UUID",
2271
+ "__tenancy": {
2272
+ "isTenantIdField": true,
2273
+ "autoFilter": true,
2274
+ "required": true,
2275
+ "autoPopulate": true,
2276
+ "nullable": false,
2277
+ "mode": "required",
2278
+ "field": "tenantId",
2279
+ "allowSuperAdminBypass": false
2443
2280
  }
2444
- ],
2445
- "returnType": "Promise<ChatReaction[]>",
2446
- "isStatic": false,
2447
- "isPublic": true
2281
+ }
2448
2282
  },
2449
- "getReactionCounts": {
2450
- "name": "getReactionCounts",
2451
- "async": true,
2452
- "parameters": [
2453
- {
2454
- "name": "messageId",
2455
- "type": "string",
2456
- "optional": false
2457
- }
2458
- ],
2459
- "returnType": "Promise<Map<string, object>>",
2283
+ "name": {
2284
+ "type": "text",
2285
+ "required": false,
2286
+ "default": ""
2287
+ },
2288
+ "description": {
2289
+ "type": "text",
2290
+ "required": false,
2291
+ "default": ""
2292
+ },
2293
+ "roomType": {
2294
+ "type": "text",
2295
+ "required": true,
2296
+ "default": "public",
2297
+ "_meta": {
2298
+ "required": true
2299
+ }
2300
+ },
2301
+ "status": {
2302
+ "type": "text",
2303
+ "required": true,
2304
+ "default": "active",
2305
+ "_meta": {
2306
+ "required": true
2307
+ }
2308
+ },
2309
+ "topic": {
2310
+ "type": "text",
2311
+ "required": false,
2312
+ "default": ""
2313
+ },
2314
+ "avatarUrl": {
2315
+ "type": "text",
2316
+ "required": false,
2317
+ "default": ""
2318
+ },
2319
+ "isArchived": {
2320
+ "type": "boolean",
2321
+ "required": false,
2322
+ "default": false
2323
+ },
2324
+ "maxParticipants": {
2325
+ "type": "integer",
2326
+ "required": false,
2327
+ "default": 0
2328
+ },
2329
+ "metadata": {
2330
+ "type": "text",
2331
+ "required": false,
2332
+ "default": "{}"
2333
+ },
2334
+ "createdByProfileId": {
2335
+ "type": "crossPackageRef",
2336
+ "required": false,
2337
+ "related": "@happyvertical/smrt-profiles:Profile"
2338
+ },
2339
+ "lastMessageAt": {
2340
+ "type": "datetime",
2341
+ "required": false
2342
+ }
2343
+ },
2344
+ "methods": {
2345
+ "getMetadata": {
2346
+ "name": "getMetadata",
2347
+ "async": false,
2348
+ "parameters": [],
2349
+ "returnType": "ChatRoomMetadata",
2460
2350
  "isStatic": false,
2461
2351
  "isPublic": true
2462
2352
  },
2463
- "toggle": {
2464
- "name": "toggle",
2465
- "async": true,
2353
+ "setMetadata": {
2354
+ "name": "setMetadata",
2355
+ "async": false,
2466
2356
  "parameters": [
2467
2357
  {
2468
- "name": "messageId",
2469
- "type": "string",
2470
- "optional": false
2471
- },
2472
- {
2473
- "name": "profileId",
2474
- "type": "string",
2475
- "optional": false
2476
- },
2477
- {
2478
- "name": "emoji",
2479
- "type": "string",
2480
- "optional": false
2481
- },
2482
- {
2483
- "name": "tenantId",
2484
- "type": "string",
2358
+ "name": "data",
2359
+ "type": "ChatRoomMetadata",
2485
2360
  "optional": false
2486
2361
  }
2487
2362
  ],
2488
- "returnType": "Promise<object>",
2363
+ "returnType": "void",
2489
2364
  "isStatic": false,
2490
2365
  "isPublic": true
2491
- }
2492
- },
2493
- "decoratorConfig": {
2494
- "tableName": "chat_reactions"
2495
- },
2496
- "extends": "SmrtCollection",
2497
- "extendsTypeArg": "ChatReaction",
2498
- "exportName": "ChatReactionCollection",
2499
- "collectionExportName": "ChatReactionCollectionCollection",
2500
- "schema": {
2501
- "tableName": "chat_reactions",
2502
- "ddl": "CREATE TABLE IF NOT EXISTS \"chat_reactions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
2503
- "columns": {
2504
- "id": {
2505
- "type": "UUID",
2506
- "primaryKey": true,
2507
- "referenceKind": "id",
2508
- "notNull": true
2509
- },
2510
- "slug": {
2511
- "type": "TEXT",
2512
- "notNull": true
2513
- },
2514
- "context": {
2515
- "type": "TEXT",
2516
- "notNull": true,
2517
- "default": ""
2518
- },
2519
- "created_at": {
2520
- "type": "TIMESTAMP",
2521
- "notNull": true,
2522
- "default": "current_timestamp"
2523
- },
2524
- "updated_at": {
2525
- "type": "TIMESTAMP",
2526
- "notNull": true,
2527
- "default": "current_timestamp"
2528
- }
2529
2366
  },
2530
- "indexes": [
2531
- {
2532
- "name": "chat_reactions_id_idx",
2533
- "columns": [
2534
- "id"
2535
- ]
2536
- },
2537
- {
2538
- "name": "chat_reactions_slug_context_idx",
2539
- "columns": [
2540
- "slug",
2541
- "context"
2542
- ],
2543
- "unique": true
2544
- }
2545
- ],
2546
- "version": "0ea62683"
2547
- }
2548
- },
2549
- "@happyvertical/smrt-chat:ChatRoomCollection": {
2550
- "name": "chatroomcollection",
2551
- "className": "ChatRoomCollection",
2552
- "qualifiedName": "@happyvertical/smrt-chat:ChatRoomCollection",
2553
- "collection": "chatrooms",
2554
- "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatRoomCollection.ts",
2555
- "packageName": "@happyvertical/smrt-chat",
2556
- "fields": {},
2557
- "methods": {
2558
- "findByType": {
2559
- "name": "findByType",
2560
- "async": true,
2367
+ "updateMetadata": {
2368
+ "name": "updateMetadata",
2369
+ "async": false,
2561
2370
  "parameters": [
2562
2371
  {
2563
- "name": "roomType",
2564
- "type": "ChatRoomType",
2372
+ "name": "updates",
2373
+ "type": "ChatRoomMetadata",
2565
2374
  "optional": false
2566
2375
  }
2567
2376
  ],
2568
- "returnType": "Promise<ChatRoom[]>",
2377
+ "returnType": "void",
2569
2378
  "isStatic": false,
2570
2379
  "isPublic": true
2571
2380
  },
2572
- "findPublic": {
2573
- "name": "findPublic",
2574
- "async": true,
2381
+ "isDM": {
2382
+ "name": "isDM",
2383
+ "async": false,
2575
2384
  "parameters": [],
2576
- "returnType": "Promise<ChatRoom[]>",
2385
+ "returnType": "boolean",
2577
2386
  "isStatic": false,
2578
2387
  "isPublic": true
2579
2388
  },
2580
- "findDMs": {
2581
- "name": "findDMs",
2582
- "async": true,
2389
+ "isAgentRoom": {
2390
+ "name": "isAgentRoom",
2391
+ "async": false,
2583
2392
  "parameters": [],
2584
- "returnType": "Promise<ChatRoom[]>",
2393
+ "returnType": "boolean",
2585
2394
  "isStatic": false,
2586
2395
  "isPublic": true
2587
2396
  },
2588
- "findAgentRooms": {
2589
- "name": "findAgentRooms",
2590
- "async": true,
2397
+ "isPublic": {
2398
+ "name": "isPublic",
2399
+ "async": false,
2591
2400
  "parameters": [],
2592
- "returnType": "Promise<ChatRoom[]>",
2401
+ "returnType": "boolean",
2593
2402
  "isStatic": false,
2594
2403
  "isPublic": true
2595
2404
  },
2596
- "search": {
2597
- "name": "search",
2405
+ "isActive": {
2406
+ "name": "isActive",
2407
+ "async": false,
2408
+ "parameters": [],
2409
+ "returnType": "boolean",
2410
+ "isStatic": false,
2411
+ "isPublic": true
2412
+ },
2413
+ "archive": {
2414
+ "name": "archive",
2598
2415
  "async": true,
2599
- "parameters": [
2600
- {
2601
- "name": "query",
2602
- "type": "string",
2603
- "optional": false
2604
- },
2605
- {
2606
- "name": "options",
2607
- "type": "object",
2608
- "optional": true
2609
- }
2610
- ],
2611
- "returnType": "Promise<ChatRoom[]>",
2416
+ "parameters": [],
2417
+ "returnType": "Promise<void>",
2612
2418
  "isStatic": false,
2613
2419
  "isPublic": true
2614
2420
  },
2615
- "findOrCreateDM": {
2616
- "name": "findOrCreateDM",
2421
+ "unarchive": {
2422
+ "name": "unarchive",
2617
2423
  "async": true,
2618
- "parameters": [
2619
- {
2620
- "name": "profileId1",
2621
- "type": "string",
2622
- "optional": false
2623
- },
2624
- {
2625
- "name": "profileId2",
2626
- "type": "string",
2627
- "optional": false
2628
- },
2629
- {
2630
- "name": "tenantId",
2631
- "type": "string",
2632
- "optional": false
2633
- },
2634
- {
2635
- "name": "participants",
2636
- "type": "ChatParticipantCollection",
2637
- "optional": false
2638
- }
2639
- ],
2640
- "returnType": "Promise<ChatRoom>",
2424
+ "parameters": [],
2425
+ "returnType": "Promise<void>",
2641
2426
  "isStatic": false,
2642
2427
  "isPublic": true
2643
2428
  }
2644
2429
  },
2645
2430
  "decoratorConfig": {
2646
- "tableName": "chat_rooms"
2431
+ "tableName": "chat_rooms",
2432
+ "api": {
2433
+ "include": [
2434
+ "list",
2435
+ "get"
2436
+ ]
2437
+ },
2438
+ "mcp": {
2439
+ "include": [
2440
+ "list",
2441
+ "get"
2442
+ ]
2443
+ },
2444
+ "cli": true,
2445
+ "tenantScoped": {
2446
+ "mode": "required"
2447
+ }
2647
2448
  },
2648
- "extends": "SmrtCollection",
2649
- "extendsTypeArg": "ChatRoom",
2650
- "exportName": "ChatRoomCollection",
2651
- "collectionExportName": "ChatRoomCollectionCollection",
2449
+ "extends": "SmrtObject",
2450
+ "exportName": "ChatRoom",
2451
+ "collectionExportName": "ChatRoomCollection",
2452
+ "validationRules": [
2453
+ {
2454
+ "field": "tenantId",
2455
+ "rule": "required",
2456
+ "fieldType": "text"
2457
+ },
2458
+ {
2459
+ "field": "roomType",
2460
+ "rule": "required",
2461
+ "fieldType": "text"
2462
+ },
2463
+ {
2464
+ "field": "status",
2465
+ "rule": "required",
2466
+ "fieldType": "text"
2467
+ }
2468
+ ],
2652
2469
  "schema": {
2653
2470
  "tableName": "chat_rooms",
2654
- "ddl": "CREATE TABLE IF NOT EXISTS \"chat_rooms\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
2471
+ "ddl": "CREATE TABLE IF NOT EXISTS \"chat_rooms\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"room_type\" TEXT NOT NULL DEFAULT 'public',\n \"status\" TEXT NOT NULL DEFAULT 'active',\n \"topic\" TEXT DEFAULT '',\n \"avatar_url\" TEXT DEFAULT '',\n \"is_archived\" BOOLEAN DEFAULT FALSE,\n \"max_participants\" INTEGER DEFAULT 0,\n \"metadata\" TEXT DEFAULT '{}',\n \"created_by_profile_id\" UUID,\n \"last_message_at\" TIMESTAMP\n);",
2655
2472
  "columns": {
2656
2473
  "id": {
2657
2474
  "type": "UUID",
@@ -2659,24 +2476,95 @@
2659
2476
  "referenceKind": "id",
2660
2477
  "notNull": true
2661
2478
  },
2662
- "slug": {
2479
+ "slug": {
2480
+ "type": "TEXT",
2481
+ "notNull": true
2482
+ },
2483
+ "context": {
2484
+ "type": "TEXT",
2485
+ "notNull": true,
2486
+ "default": ""
2487
+ },
2488
+ "created_at": {
2489
+ "type": "TIMESTAMP",
2490
+ "notNull": true,
2491
+ "default": "current_timestamp"
2492
+ },
2493
+ "updated_at": {
2494
+ "type": "TIMESTAMP",
2495
+ "notNull": true,
2496
+ "default": "current_timestamp"
2497
+ },
2498
+ "tenant_id": {
2499
+ "type": "UUID",
2500
+ "referenceKind": "tenantId",
2501
+ "notNull": true,
2502
+ "unique": false
2503
+ },
2504
+ "name": {
2505
+ "type": "TEXT",
2506
+ "notNull": false,
2507
+ "unique": false,
2508
+ "default": ""
2509
+ },
2510
+ "description": {
2663
2511
  "type": "TEXT",
2664
- "notNull": true
2512
+ "notNull": false,
2513
+ "unique": false,
2514
+ "default": ""
2665
2515
  },
2666
- "context": {
2516
+ "room_type": {
2667
2517
  "type": "TEXT",
2668
2518
  "notNull": true,
2669
- "default": ""
2519
+ "unique": false,
2520
+ "default": "public"
2670
2521
  },
2671
- "created_at": {
2672
- "type": "TIMESTAMP",
2522
+ "status": {
2523
+ "type": "TEXT",
2673
2524
  "notNull": true,
2674
- "default": "current_timestamp"
2525
+ "unique": false,
2526
+ "default": "active"
2675
2527
  },
2676
- "updated_at": {
2528
+ "topic": {
2529
+ "type": "TEXT",
2530
+ "notNull": false,
2531
+ "unique": false,
2532
+ "default": ""
2533
+ },
2534
+ "avatar_url": {
2535
+ "type": "TEXT",
2536
+ "notNull": false,
2537
+ "unique": false,
2538
+ "default": ""
2539
+ },
2540
+ "is_archived": {
2541
+ "type": "BOOLEAN",
2542
+ "notNull": false,
2543
+ "unique": false,
2544
+ "default": false
2545
+ },
2546
+ "max_participants": {
2547
+ "type": "INTEGER",
2548
+ "notNull": false,
2549
+ "unique": false,
2550
+ "default": 0
2551
+ },
2552
+ "metadata": {
2553
+ "type": "TEXT",
2554
+ "notNull": false,
2555
+ "unique": false,
2556
+ "default": "{}"
2557
+ },
2558
+ "created_by_profile_id": {
2559
+ "type": "UUID",
2560
+ "referenceKind": "crossPackageRef",
2561
+ "notNull": false,
2562
+ "unique": false
2563
+ },
2564
+ "last_message_at": {
2677
2565
  "type": "TIMESTAMP",
2678
- "notNull": true,
2679
- "default": "current_timestamp"
2566
+ "notNull": false,
2567
+ "unique": false
2680
2568
  }
2681
2569
  },
2682
2570
  "indexes": [
@@ -2695,65 +2583,130 @@
2695
2583
  "unique": true
2696
2584
  }
2697
2585
  ],
2698
- "version": "40be4b86"
2586
+ "version": "3665d881"
2699
2587
  }
2700
2588
  },
2701
- "@happyvertical/smrt-chat:ChatThreadCollection": {
2702
- "name": "chatthreadcollection",
2703
- "className": "ChatThreadCollection",
2704
- "qualifiedName": "@happyvertical/smrt-chat:ChatThreadCollection",
2589
+ "@happyvertical/smrt-chat:ChatThread": {
2590
+ "name": "chatthread",
2591
+ "className": "ChatThread",
2592
+ "qualifiedName": "@happyvertical/smrt-chat:ChatThread",
2705
2593
  "collection": "chatthreads",
2706
- "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatThreadCollection.ts",
2594
+ "filePath": "/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatThread.ts",
2707
2595
  "packageName": "@happyvertical/smrt-chat",
2708
- "fields": {},
2709
- "methods": {
2710
- "getByRoom": {
2711
- "name": "getByRoom",
2712
- "async": true,
2713
- "parameters": [
2714
- {
2715
- "name": "roomId",
2716
- "type": "string",
2717
- "optional": false
2596
+ "fields": {
2597
+ "tenantId": {
2598
+ "type": "text",
2599
+ "required": true,
2600
+ "_meta": {
2601
+ "sqlType": "UUID",
2602
+ "__tenancy": {
2603
+ "isTenantIdField": true,
2604
+ "autoFilter": true,
2605
+ "required": true,
2606
+ "autoPopulate": true,
2607
+ "nullable": false,
2608
+ "mode": "required",
2609
+ "field": "tenantId",
2610
+ "allowSuperAdminBypass": false
2718
2611
  }
2719
- ],
2720
- "returnType": "Promise<ChatThread[]>",
2721
- "isStatic": false,
2722
- "isPublic": true
2612
+ }
2723
2613
  },
2724
- "getActive": {
2725
- "name": "getActive",
2614
+ "roomId": {
2615
+ "type": "foreignKey",
2616
+ "required": true,
2617
+ "related": "ChatRoom",
2618
+ "_meta": {
2619
+ "required": true
2620
+ }
2621
+ },
2622
+ "rootMessageId": {
2623
+ "type": "foreignKey",
2624
+ "required": false,
2625
+ "related": "ChatMessage",
2626
+ "_meta": {
2627
+ "nullable": true
2628
+ }
2629
+ },
2630
+ "title": {
2631
+ "type": "text",
2632
+ "required": false,
2633
+ "default": ""
2634
+ },
2635
+ "isResolved": {
2636
+ "type": "boolean",
2637
+ "required": false,
2638
+ "default": false
2639
+ },
2640
+ "messageCount": {
2641
+ "type": "integer",
2642
+ "required": false,
2643
+ "default": 0
2644
+ },
2645
+ "lastMessageAt": {
2646
+ "type": "datetime",
2647
+ "required": false
2648
+ },
2649
+ "participantCount": {
2650
+ "type": "integer",
2651
+ "required": false,
2652
+ "default": 0
2653
+ }
2654
+ },
2655
+ "methods": {
2656
+ "resolve": {
2657
+ "name": "resolve",
2726
2658
  "async": true,
2727
- "parameters": [
2728
- {
2729
- "name": "roomId",
2730
- "type": "string",
2731
- "optional": false
2732
- }
2733
- ],
2734
- "returnType": "Promise<ChatThread[]>",
2659
+ "parameters": [],
2660
+ "returnType": "Promise<void>",
2735
2661
  "isStatic": false,
2736
2662
  "isPublic": true
2737
2663
  },
2738
- "getUnresolved": {
2739
- "name": "getUnresolved",
2664
+ "reopen": {
2665
+ "name": "reopen",
2740
2666
  "async": true,
2741
2667
  "parameters": [],
2742
- "returnType": "Promise<ChatThread[]>",
2668
+ "returnType": "Promise<void>",
2743
2669
  "isStatic": false,
2744
2670
  "isPublic": true
2745
2671
  }
2746
2672
  },
2747
2673
  "decoratorConfig": {
2748
- "tableName": "chat_threads"
2674
+ "tableName": "chat_threads",
2675
+ "api": {
2676
+ "include": [
2677
+ "list",
2678
+ "get"
2679
+ ]
2680
+ },
2681
+ "mcp": {
2682
+ "include": [
2683
+ "list",
2684
+ "get"
2685
+ ]
2686
+ },
2687
+ "cli": true,
2688
+ "tenantScoped": {
2689
+ "mode": "required"
2690
+ }
2749
2691
  },
2750
- "extends": "SmrtCollection",
2751
- "extendsTypeArg": "ChatThread",
2752
- "exportName": "ChatThreadCollection",
2753
- "collectionExportName": "ChatThreadCollectionCollection",
2692
+ "extends": "SmrtObject",
2693
+ "exportName": "ChatThread",
2694
+ "collectionExportName": "ChatThreadCollection",
2695
+ "validationRules": [
2696
+ {
2697
+ "field": "tenantId",
2698
+ "rule": "required",
2699
+ "fieldType": "text"
2700
+ },
2701
+ {
2702
+ "field": "roomId",
2703
+ "rule": "required",
2704
+ "fieldType": "foreignKey"
2705
+ }
2706
+ ],
2754
2707
  "schema": {
2755
2708
  "tableName": "chat_threads",
2756
- "ddl": "CREATE TABLE IF NOT EXISTS \"chat_threads\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
2709
+ "ddl": "CREATE TABLE IF NOT EXISTS \"chat_threads\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"room_id\" UUID NOT NULL,\n \"root_message_id\" UUID,\n \"title\" TEXT DEFAULT '',\n \"is_resolved\" BOOLEAN DEFAULT FALSE,\n \"message_count\" INTEGER DEFAULT 0,\n \"last_message_at\" TIMESTAMP,\n \"participant_count\" INTEGER DEFAULT 0\n);",
2757
2710
  "columns": {
2758
2711
  "id": {
2759
2712
  "type": "UUID",
@@ -2779,6 +2732,53 @@
2779
2732
  "type": "TIMESTAMP",
2780
2733
  "notNull": true,
2781
2734
  "default": "current_timestamp"
2735
+ },
2736
+ "tenant_id": {
2737
+ "type": "UUID",
2738
+ "referenceKind": "tenantId",
2739
+ "notNull": true,
2740
+ "unique": false
2741
+ },
2742
+ "room_id": {
2743
+ "type": "UUID",
2744
+ "referenceKind": "foreignKey",
2745
+ "notNull": true,
2746
+ "unique": false
2747
+ },
2748
+ "root_message_id": {
2749
+ "type": "UUID",
2750
+ "referenceKind": "foreignKey",
2751
+ "notNull": false,
2752
+ "unique": false
2753
+ },
2754
+ "title": {
2755
+ "type": "TEXT",
2756
+ "notNull": false,
2757
+ "unique": false,
2758
+ "default": ""
2759
+ },
2760
+ "is_resolved": {
2761
+ "type": "BOOLEAN",
2762
+ "notNull": false,
2763
+ "unique": false,
2764
+ "default": false
2765
+ },
2766
+ "message_count": {
2767
+ "type": "INTEGER",
2768
+ "notNull": false,
2769
+ "unique": false,
2770
+ "default": 0
2771
+ },
2772
+ "last_message_at": {
2773
+ "type": "TIMESTAMP",
2774
+ "notNull": false,
2775
+ "unique": false
2776
+ },
2777
+ "participant_count": {
2778
+ "type": "INTEGER",
2779
+ "notNull": false,
2780
+ "unique": false,
2781
+ "default": 0
2782
2782
  }
2783
2783
  },
2784
2784
  "indexes": [
@@ -2797,7 +2797,7 @@
2797
2797
  "unique": true
2798
2798
  }
2799
2799
  ],
2800
- "version": "760b62bd"
2800
+ "version": "6fd35191"
2801
2801
  }
2802
2802
  }
2803
2803
  },