@happyvertical/smrt-chat 0.38.20 → 0.38.22

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.
package/dist/index.js CHANGED
@@ -1,9 +1,521 @@
1
- import { a as ChatReaction, c as AgentSession, i as ChatRoom, o as ChatParticipant, r as ChatThread, s as ChatMessage, t as ChatService } from "./chunks/ChatService-hKK-GI17.js";
1
+ import { a as ChatRoom, c as ChatMessage, i as ChatThread, l as AgentSession, o as ChatReaction, s as ChatParticipant, t as ChatService } from "./chunks/ChatService-BRsE5HmY.js";
2
2
  import { CHAT_MODULE_META, CHAT_UI_SLOTS } from "./ui.js";
3
3
  import { ObjectRegistry } from "@happyvertical/smrt-core";
4
+ import { FeedbackCollection, feedbackSourceFor, personaLearningMemory, personaMemoryScope, reinforceFromFeedback, resolvePersonaInstructions } from "@happyvertical/smrt-personas";
5
+ import { getDatabase } from "@happyvertical/sql";
6
+ import { PrincipalToolNotAllowedError, executeAsPrincipal } from "@happyvertical/smrt-agents";
7
+ import { OperationPermissionError, PermissionCatalogService } from "@happyvertical/smrt-users";
4
8
  //#region src/__smrt-register__.ts
5
- ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":1783576238922,\"packageName\":\"@happyvertical/smrt-chat\",\"packageVersion\":\"0.38.20\",\"objects\":{\"@happyvertical/smrt-chat:AgentSessionCollection\":{\"name\":\"agentsessioncollection\",\"className\":\"AgentSessionCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:AgentSessionCollection\",\"collection\":\"agentsessions\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/collections/AgentSessionCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"findActiveByParticipant\":{\"name\":\"findActiveByParticipant\",\"async\":true,\"parameters\":[{\"name\":\"participantProfileId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AgentSession[]>\",\"isStatic\":false,\"isPublic\":true},\"findActiveSession\":{\"name\":\"findActiveSession\",\"async\":true,\"parameters\":[{\"name\":\"agentId\",\"type\":\"string\",\"optional\":false},{\"name\":\"participantProfileId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string | null\",\"optional\":false},{\"name\":\"sessionKey\",\"type\":\"string | null\",\"optional\":true}],\"returnType\":\"Promise<AgentSession | null>\",\"isStatic\":false,\"isPublic\":true},\"findOrCreate\":{\"name\":\"findOrCreate\",\"async\":true,\"parameters\":[{\"name\":\"params\",\"type\":\"object\",\"optional\":false}],\"returnType\":\"Promise<AgentSession>\",\"isStatic\":false,\"isPublic\":true},\"findByAgent\":{\"name\":\"findByAgent\",\"async\":true,\"parameters\":[{\"name\":\"agentId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AgentSession[]>\",\"isStatic\":false,\"isPublic\":true},\"expireStale\":{\"name\":\"expireStale\",\"async\":true,\"parameters\":[{\"name\":\"olderThan\",\"type\":\"Date\",\"optional\":false},{\"name\":\"scope\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_sessions\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"AgentSession\",\"exportName\":\"AgentSessionCollection\",\"collectionExportName\":\"AgentSessionCollectionCollection\",\"schema\":{\"tableName\":\"agent_sessions\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"agent_sessions_id_idx\",\"columns\":[\"id\"]},{\"name\":\"agent_sessions_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"e5de0db6\"}},\"@happyvertical/smrt-chat:ChatMessageCollection\":{\"name\":\"chatmessagecollection\",\"className\":\"ChatMessageCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatMessageCollection\",\"collection\":\"chatmessages\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatMessageCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"getByRoom\":{\"name\":\"getByRoom\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<ChatMessage[]>\",\"isStatic\":false,\"isPublic\":true},\"getByThread\":{\"name\":\"getByThread\",\"async\":true,\"parameters\":[{\"name\":\"threadId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatMessage[]>\",\"isStatic\":false,\"isPublic\":true},\"getByAgentSession\":{\"name\":\"getByAgentSession\",\"async\":true,\"parameters\":[{\"name\":\"agentSessionId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatMessage[]>\",\"isStatic\":false,\"isPublic\":true},\"search\":{\"name\":\"search\",\"async\":true,\"parameters\":[{\"name\":\"filters\",\"type\":\"any\",\"optional\":false}],\"returnType\":\"Promise<ChatMessage[]>\",\"isStatic\":false,\"isPublic\":true},\"getUnreadCount\":{\"name\":\"getUnreadCount\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"lastReadMessageId\",\"type\":\"string | null\",\"optional\":false}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"getLatestPerRoom\":{\"name\":\"getLatestPerRoom\",\"async\":true,\"parameters\":[{\"name\":\"roomIds\",\"type\":\"string[]\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Map<string, ChatMessage>>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_messages\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"ChatMessage\",\"exportName\":\"ChatMessageCollection\",\"collectionExportName\":\"ChatMessageCollectionCollection\",\"schema\":{\"tableName\":\"chat_messages\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"chat_messages_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_messages_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"13b2dccb\"}},\"@happyvertical/smrt-chat:ChatParticipantCollection\":{\"name\":\"chatparticipantcollection\",\"className\":\"ChatParticipantCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatParticipantCollection\",\"collection\":\"chatparticipants\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatParticipantCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"getByRoom\":{\"name\":\"getByRoom\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatParticipant[]>\",\"isStatic\":false,\"isPublic\":true},\"getByProfile\":{\"name\":\"getByProfile\",\"async\":true,\"parameters\":[{\"name\":\"profileId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatParticipant[]>\",\"isStatic\":false,\"isPublic\":true},\"findMembership\":{\"name\":\"findMembership\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false},{\"name\":\"profileId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":true}],\"returnType\":\"Promise<ChatParticipant | null>\",\"isStatic\":false,\"isPublic\":true},\"findActiveMembership\":{\"name\":\"findActiveMembership\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false},{\"name\":\"profileId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatParticipant | null>\",\"isStatic\":false,\"isPublic\":true},\"isActiveMember\":{\"name\":\"isActiveMember\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false},{\"name\":\"profileId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<boolean>\",\"isStatic\":false,\"isPublic\":true},\"getOnlineInRoom\":{\"name\":\"getOnlineInRoom\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatParticipant[]>\",\"isStatic\":false,\"isPublic\":true},\"getAdminsInRoom\":{\"name\":\"getAdminsInRoom\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatParticipant[]>\",\"isStatic\":false,\"isPublic\":true},\"countInRoom\":{\"name\":\"countInRoom\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_participants\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"ChatParticipant\",\"exportName\":\"ChatParticipantCollection\",\"collectionExportName\":\"ChatParticipantCollectionCollection\",\"schema\":{\"tableName\":\"chat_participants\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"chat_participants_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_participants_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"f70abec0\"}},\"@happyvertical/smrt-chat:ChatReactionCollection\":{\"name\":\"chatreactioncollection\",\"className\":\"ChatReactionCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatReactionCollection\",\"collection\":\"chatreactions\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatReactionCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"getByMessage\":{\"name\":\"getByMessage\",\"async\":true,\"parameters\":[{\"name\":\"messageId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatReaction[]>\",\"isStatic\":false,\"isPublic\":true},\"getReactionCounts\":{\"name\":\"getReactionCounts\",\"async\":true,\"parameters\":[{\"name\":\"messageId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Map<string, object>>\",\"isStatic\":false,\"isPublic\":true},\"toggle\":{\"name\":\"toggle\",\"async\":true,\"parameters\":[{\"name\":\"messageId\",\"type\":\"string\",\"optional\":false},{\"name\":\"profileId\",\"type\":\"string\",\"optional\":false},{\"name\":\"emoji\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<object>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_reactions\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"ChatReaction\",\"exportName\":\"ChatReactionCollection\",\"collectionExportName\":\"ChatReactionCollectionCollection\",\"schema\":{\"tableName\":\"chat_reactions\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"chat_reactions_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_reactions_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"0ea62683\"}},\"@happyvertical/smrt-chat:ChatRoomCollection\":{\"name\":\"chatroomcollection\",\"className\":\"ChatRoomCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatRoomCollection\",\"collection\":\"chatrooms\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatRoomCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"findByType\":{\"name\":\"findByType\",\"async\":true,\"parameters\":[{\"name\":\"roomType\",\"type\":\"ChatRoomType\",\"optional\":false}],\"returnType\":\"Promise<ChatRoom[]>\",\"isStatic\":false,\"isPublic\":true},\"findPublic\":{\"name\":\"findPublic\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<ChatRoom[]>\",\"isStatic\":false,\"isPublic\":true},\"findDMs\":{\"name\":\"findDMs\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<ChatRoom[]>\",\"isStatic\":false,\"isPublic\":true},\"findAgentRooms\":{\"name\":\"findAgentRooms\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<ChatRoom[]>\",\"isStatic\":false,\"isPublic\":true},\"search\":{\"name\":\"search\",\"async\":true,\"parameters\":[{\"name\":\"query\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<ChatRoom[]>\",\"isStatic\":false,\"isPublic\":true},\"findOrCreateDM\":{\"name\":\"findOrCreateDM\",\"async\":true,\"parameters\":[{\"name\":\"profileId1\",\"type\":\"string\",\"optional\":false},{\"name\":\"profileId2\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"participants\",\"type\":\"ChatParticipantCollection\",\"optional\":false}],\"returnType\":\"Promise<ChatRoom>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_rooms\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"ChatRoom\",\"exportName\":\"ChatRoomCollection\",\"collectionExportName\":\"ChatRoomCollectionCollection\",\"schema\":{\"tableName\":\"chat_rooms\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"chat_rooms_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_rooms_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"40be4b86\"}},\"@happyvertical/smrt-chat:ChatThreadCollection\":{\"name\":\"chatthreadcollection\",\"className\":\"ChatThreadCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatThreadCollection\",\"collection\":\"chatthreads\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatThreadCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"getByRoom\":{\"name\":\"getByRoom\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatThread[]>\",\"isStatic\":false,\"isPublic\":true},\"getActive\":{\"name\":\"getActive\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatThread[]>\",\"isStatic\":false,\"isPublic\":true},\"getUnresolved\":{\"name\":\"getUnresolved\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<ChatThread[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_threads\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"ChatThread\",\"exportName\":\"ChatThreadCollection\",\"collectionExportName\":\"ChatThreadCollectionCollection\",\"schema\":{\"tableName\":\"chat_threads\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"chat_threads_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_threads_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"760b62bd\"}},\"@happyvertical/smrt-chat:AgentSession\":{\"name\":\"agentsession\",\"className\":\"AgentSession\",\"qualifiedName\":\"@happyvertical/smrt-chat:AgentSession\",\"collection\":\"agentsessions\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/models/AgentSession.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"agentId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"participantProfileId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-profiles:Profile\"},\"chatRoomId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"ChatRoom\"},\"status\":{\"type\":\"text\",\"required\":true,\"default\":\"active\",\"_meta\":{\"required\":true}},\"allowedTools\":{\"type\":\"text\",\"required\":false,\"default\":\"[]\"},\"sessionContext\":{\"type\":\"text\",\"required\":false,\"default\":\"{}\"},\"systemPrompt\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"messageCount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalTokensUsed\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"maxTokens\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"maxMessages\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"lastMessageAt\":{\"type\":\"datetime\",\"required\":false},\"expiresAt\":{\"type\":\"datetime\",\"required\":false},\"closedAt\":{\"type\":\"datetime\",\"required\":false}},\"methods\":{\"getAllowedTools\":{\"name\":\"getAllowedTools\",\"async\":false,\"parameters\":[],\"returnType\":\"string[]\",\"isStatic\":false,\"isPublic\":true},\"setAllowedTools\":{\"name\":\"setAllowedTools\",\"async\":false,\"parameters\":[{\"name\":\"tools\",\"type\":\"string[]\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"isToolAllowed\":{\"name\":\"isToolAllowed\",\"async\":false,\"parameters\":[{\"name\":\"toolName\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isActive\":{\"name\":\"isActive\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isExpired\":{\"name\":\"isExpired\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"close\":{\"name\":\"close\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"expire\":{\"name\":\"expire\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"getSessionContext\":{\"name\":\"getSessionContext\",\"async\":false,\"parameters\":[],\"returnType\":\"Record<string>\",\"isStatic\":false,\"isPublic\":true},\"setSessionContext\":{\"name\":\"setSessionContext\",\"async\":false,\"parameters\":[{\"name\":\"ctx\",\"type\":\"Record<string>\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"getSessionKey\":{\"name\":\"getSessionKey\",\"async\":false,\"parameters\":[],\"returnType\":\"string | null\",\"isStatic\":false,\"isPublic\":true},\"updateSessionContext\":{\"name\":\"updateSessionContext\",\"async\":true,\"parameters\":[{\"name\":\"updates\",\"type\":\"Record<string>\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"recordMessage\":{\"name\":\"recordMessage\",\"async\":true,\"parameters\":[{\"name\":\"tokensUsed\",\"type\":\"number\",\"optional\":true}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_sessions\",\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"AgentSession\",\"collectionExportName\":\"AgentSessionCollection\",\"validationRules\":[{\"field\":\"agentId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"participantProfileId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"},{\"field\":\"status\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"agent_sessions\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"agent_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"participant_profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"chat_room_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"active\"},\"allowed_tools\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"[]\"},\"session_context\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"{}\"},\"system_prompt\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"message_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"total_tokens_used\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"max_tokens\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"max_messages\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"last_message_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"expires_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"closed_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"agent_sessions_id_idx\",\"columns\":[\"id\"]},{\"name\":\"agent_sessions_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"9de59339\"}},\"@happyvertical/smrt-chat:ChatMessage\":{\"name\":\"chatmessage\",\"className\":\"ChatMessage\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatMessage\",\"collection\":\"chatmessages\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatMessage.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":true,\"autoPopulate\":true,\"nullable\":false,\"mode\":\"required\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"roomId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"ChatRoom\",\"_meta\":{\"required\":true}},\"threadId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"ChatThread\"},\"senderProfileId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-profiles:Profile\"},\"agentSessionId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"AgentSession\"},\"content\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"messageType\":{\"type\":\"text\",\"required\":true,\"default\":\"text\",\"_meta\":{\"required\":true}},\"role\":{\"type\":\"text\",\"required\":true,\"default\":\"user\",\"_meta\":{\"required\":true}},\"isEdited\":{\"type\":\"boolean\",\"required\":false,\"default\":false},\"editedAt\":{\"type\":\"datetime\",\"required\":false},\"isDeleted\":{\"type\":\"boolean\",\"required\":false,\"default\":false},\"replyToMessageId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"ChatMessage\"},\"metadata\":{\"type\":\"text\",\"required\":false,\"default\":\"{}\"},\"toolCallData\":{\"type\":\"text\",\"required\":false},\"attachments\":{\"type\":\"text\",\"required\":false,\"default\":\"[]\"}},\"methods\":{\"getAttachments\":{\"name\":\"getAttachments\",\"async\":false,\"parameters\":[],\"returnType\":\"Array<object>\",\"isStatic\":false,\"isPublic\":true},\"setAttachments\":{\"name\":\"setAttachments\",\"async\":false,\"parameters\":[{\"name\":\"items\",\"type\":\"Array<object>\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"getMetadata\":{\"name\":\"getMetadata\",\"async\":false,\"parameters\":[],\"returnType\":\"Record<string>\",\"isStatic\":false,\"isPublic\":true},\"setMetadata\":{\"name\":\"setMetadata\",\"async\":false,\"parameters\":[{\"name\":\"data\",\"type\":\"Record<string>\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"getToolCallData\":{\"name\":\"getToolCallData\",\"async\":false,\"parameters\":[],\"returnType\":\"Record<string> | null\",\"isStatic\":false,\"isPublic\":true},\"setToolCallData\":{\"name\":\"setToolCallData\",\"async\":false,\"parameters\":[{\"name\":\"data\",\"type\":\"Record<string> | null\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"hasAttachments\":{\"name\":\"hasAttachments\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isToolCall\":{\"name\":\"isToolCall\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isToolResult\":{\"name\":\"isToolResult\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isFromAgent\":{\"name\":\"isFromAgent\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isSystemMessage\":{\"name\":\"isSystemMessage\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"edit\":{\"name\":\"edit\",\"async\":true,\"parameters\":[{\"name\":\"newContent\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"softDelete\":{\"name\":\"softDelete\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"getPreview\":{\"name\":\"getPreview\",\"async\":false,\"parameters\":[{\"name\":\"maxLength\",\"type\":\"any\",\"optional\":true}],\"returnType\":\"string\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_messages\",\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"ChatMessage\",\"collectionExportName\":\"ChatMessageCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"roomId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"},{\"field\":\"senderProfileId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"},{\"field\":\"messageType\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"role\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"chat_messages\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"room_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false},\"thread_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"sender_profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"agent_session_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"content\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"message_type\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"text\"},\"role\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"user\"},\"is_edited\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":false},\"edited_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"is_deleted\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":false},\"reply_to_message_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"metadata\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"{}\"},\"tool_call_data\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"attachments\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"[]\"}},\"indexes\":[{\"name\":\"chat_messages_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_messages_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"7469514e\"}},\"@happyvertical/smrt-chat:ChatParticipant\":{\"name\":\"chatparticipant\",\"className\":\"ChatParticipant\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatParticipant\",\"collection\":\"chatparticipants\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatParticipant.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":true,\"autoPopulate\":true,\"nullable\":false,\"mode\":\"required\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"roomId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"ChatRoom\",\"_meta\":{\"required\":true}},\"profileId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-profiles:Profile\"},\"role\":{\"type\":\"text\",\"required\":true,\"default\":\"member\",\"_meta\":{\"required\":true}},\"status\":{\"type\":\"text\",\"required\":true,\"default\":\"active\",\"_meta\":{\"required\":true}},\"onlineStatus\":{\"type\":\"text\",\"required\":true,\"default\":\"offline\",\"_meta\":{\"required\":true}},\"lastReadMessageId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"ChatMessage\"},\"lastSeenAt\":{\"type\":\"datetime\",\"required\":false},\"joinedAt\":{\"type\":\"datetime\",\"required\":false},\"nickname\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"isMuted\":{\"type\":\"boolean\",\"required\":false,\"default\":false},\"isPinned\":{\"type\":\"boolean\",\"required\":false,\"default\":false}},\"methods\":{\"isActive\":{\"name\":\"isActive\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isOwner\":{\"name\":\"isOwner\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isAdmin\":{\"name\":\"isAdmin\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"markRead\":{\"name\":\"markRead\",\"async\":true,\"parameters\":[{\"name\":\"messageId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"leave\":{\"name\":\"leave\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"setOnline\":{\"name\":\"setOnline\",\"async\":true,\"parameters\":[{\"name\":\"status\",\"type\":\"OnlineStatus\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_participants\",\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"ChatParticipant\",\"collectionExportName\":\"ChatParticipantCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"roomId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"},{\"field\":\"profileId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"},{\"field\":\"role\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"status\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"onlineStatus\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"chat_participants\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"room_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false},\"profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"role\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"member\"},\"status\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"active\"},\"online_status\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"offline\"},\"last_read_message_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"last_seen_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"joined_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"nickname\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"is_muted\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":false},\"is_pinned\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":false}},\"indexes\":[{\"name\":\"chat_participants_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_participants_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"50824444\"}},\"@happyvertical/smrt-chat:ChatReaction\":{\"name\":\"chatreaction\",\"className\":\"ChatReaction\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatReaction\",\"collection\":\"chatreactions\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatReaction.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":true,\"autoPopulate\":true,\"nullable\":false,\"mode\":\"required\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"messageId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"ChatMessage\",\"_meta\":{\"required\":true}},\"profileId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-profiles:Profile\"},\"emoji\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"chat_reactions\",\"api\":{\"include\":[\"list\"]},\"mcp\":{\"include\":[\"list\"]},\"cli\":false,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"ChatReaction\",\"collectionExportName\":\"ChatReactionCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"messageId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"},{\"field\":\"profileId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"},{\"field\":\"emoji\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"chat_reactions\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"message_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false},\"profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"emoji\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"}},\"indexes\":[{\"name\":\"chat_reactions_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_reactions_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"8378c874\"}},\"@happyvertical/smrt-chat:ChatRoom\":{\"name\":\"chatroom\",\"className\":\"ChatRoom\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatRoom\",\"collection\":\"chatrooms\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatRoom.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":true,\"autoPopulate\":true,\"nullable\":false,\"mode\":\"required\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"name\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"description\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"roomType\":{\"type\":\"text\",\"required\":true,\"default\":\"public\",\"_meta\":{\"required\":true}},\"status\":{\"type\":\"text\",\"required\":true,\"default\":\"active\",\"_meta\":{\"required\":true}},\"topic\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"avatarUrl\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"isArchived\":{\"type\":\"boolean\",\"required\":false,\"default\":false},\"maxParticipants\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"metadata\":{\"type\":\"text\",\"required\":false,\"default\":\"{}\"},\"createdByProfileId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-profiles:Profile\"},\"lastMessageAt\":{\"type\":\"datetime\",\"required\":false}},\"methods\":{\"getMetadata\":{\"name\":\"getMetadata\",\"async\":false,\"parameters\":[],\"returnType\":\"ChatRoomMetadata\",\"isStatic\":false,\"isPublic\":true},\"setMetadata\":{\"name\":\"setMetadata\",\"async\":false,\"parameters\":[{\"name\":\"data\",\"type\":\"ChatRoomMetadata\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"updateMetadata\":{\"name\":\"updateMetadata\",\"async\":false,\"parameters\":[{\"name\":\"updates\",\"type\":\"ChatRoomMetadata\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"isDM\":{\"name\":\"isDM\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isAgentRoom\":{\"name\":\"isAgentRoom\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isPublic\":{\"name\":\"isPublic\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isActive\":{\"name\":\"isActive\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"archive\":{\"name\":\"archive\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"unarchive\":{\"name\":\"unarchive\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_rooms\",\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"ChatRoom\",\"collectionExportName\":\"ChatRoomCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"roomType\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"status\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"chat_rooms\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"room_type\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"public\"},\"status\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"active\"},\"topic\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"avatar_url\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"is_archived\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":false},\"max_participants\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"metadata\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"{}\"},\"created_by_profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":false,\"unique\":false},\"last_message_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"chat_rooms_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_rooms_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"3665d881\"}},\"@happyvertical/smrt-chat:ChatThread\":{\"name\":\"chatthread\",\"className\":\"ChatThread\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatThread\",\"collection\":\"chatthreads\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatThread.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":true,\"autoPopulate\":true,\"nullable\":false,\"mode\":\"required\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"roomId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"ChatRoom\",\"_meta\":{\"required\":true}},\"rootMessageId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"ChatMessage\",\"_meta\":{\"nullable\":true}},\"title\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"isResolved\":{\"type\":\"boolean\",\"required\":false,\"default\":false},\"messageCount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"lastMessageAt\":{\"type\":\"datetime\",\"required\":false},\"participantCount\":{\"type\":\"integer\",\"required\":false,\"default\":0}},\"methods\":{\"resolve\":{\"name\":\"resolve\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"reopen\":{\"name\":\"reopen\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_threads\",\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"ChatThread\",\"collectionExportName\":\"ChatThreadCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"roomId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"}],\"schema\":{\"tableName\":\"chat_threads\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"room_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false},\"root_message_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"title\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"is_resolved\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":false},\"message_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"last_message_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"participant_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0}},\"indexes\":[{\"name\":\"chat_threads_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_threads_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"6fd35191\"}}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-agents\",\"@happyvertical/smrt-core\",\"@happyvertical/smrt-profiles\",\"@happyvertical/smrt-tenancy\"]}"));
9
+ ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":1783586724637,\"packageName\":\"@happyvertical/smrt-chat\",\"packageVersion\":\"0.38.22\",\"objects\":{\"@happyvertical/smrt-chat:AgentSessionCollection\":{\"name\":\"agentsessioncollection\",\"className\":\"AgentSessionCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:AgentSessionCollection\",\"collection\":\"agentsessions\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/collections/AgentSessionCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"findActiveByParticipant\":{\"name\":\"findActiveByParticipant\",\"async\":true,\"parameters\":[{\"name\":\"participantProfileId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AgentSession[]>\",\"isStatic\":false,\"isPublic\":true},\"findActiveSession\":{\"name\":\"findActiveSession\",\"async\":true,\"parameters\":[{\"name\":\"agentId\",\"type\":\"string\",\"optional\":false},{\"name\":\"participantProfileId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string | null\",\"optional\":false},{\"name\":\"sessionKey\",\"type\":\"string | null\",\"optional\":true}],\"returnType\":\"Promise<AgentSession | null>\",\"isStatic\":false,\"isPublic\":true},\"findOrCreate\":{\"name\":\"findOrCreate\",\"async\":true,\"parameters\":[{\"name\":\"params\",\"type\":\"object\",\"optional\":false}],\"returnType\":\"Promise<AgentSession>\",\"isStatic\":false,\"isPublic\":true},\"findByAgent\":{\"name\":\"findByAgent\",\"async\":true,\"parameters\":[{\"name\":\"agentId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AgentSession[]>\",\"isStatic\":false,\"isPublic\":true},\"expireStale\":{\"name\":\"expireStale\",\"async\":true,\"parameters\":[{\"name\":\"olderThan\",\"type\":\"Date\",\"optional\":false},{\"name\":\"scope\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_sessions\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"AgentSession\",\"exportName\":\"AgentSessionCollection\",\"collectionExportName\":\"AgentSessionCollectionCollection\",\"schema\":{\"tableName\":\"agent_sessions\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"agent_sessions_id_idx\",\"columns\":[\"id\"]},{\"name\":\"agent_sessions_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"e5de0db6\"}},\"@happyvertical/smrt-chat:ChatMessageCollection\":{\"name\":\"chatmessagecollection\",\"className\":\"ChatMessageCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatMessageCollection\",\"collection\":\"chatmessages\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatMessageCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"getByRoom\":{\"name\":\"getByRoom\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<ChatMessage[]>\",\"isStatic\":false,\"isPublic\":true},\"getByThread\":{\"name\":\"getByThread\",\"async\":true,\"parameters\":[{\"name\":\"threadId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatMessage[]>\",\"isStatic\":false,\"isPublic\":true},\"getByAgentSession\":{\"name\":\"getByAgentSession\",\"async\":true,\"parameters\":[{\"name\":\"agentSessionId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatMessage[]>\",\"isStatic\":false,\"isPublic\":true},\"search\":{\"name\":\"search\",\"async\":true,\"parameters\":[{\"name\":\"filters\",\"type\":\"any\",\"optional\":false}],\"returnType\":\"Promise<ChatMessage[]>\",\"isStatic\":false,\"isPublic\":true},\"getUnreadCount\":{\"name\":\"getUnreadCount\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"lastReadMessageId\",\"type\":\"string | null\",\"optional\":false}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"getLatestPerRoom\":{\"name\":\"getLatestPerRoom\",\"async\":true,\"parameters\":[{\"name\":\"roomIds\",\"type\":\"string[]\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Map<string, ChatMessage>>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_messages\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"ChatMessage\",\"exportName\":\"ChatMessageCollection\",\"collectionExportName\":\"ChatMessageCollectionCollection\",\"schema\":{\"tableName\":\"chat_messages\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"chat_messages_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_messages_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"13b2dccb\"}},\"@happyvertical/smrt-chat:ChatParticipantCollection\":{\"name\":\"chatparticipantcollection\",\"className\":\"ChatParticipantCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatParticipantCollection\",\"collection\":\"chatparticipants\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatParticipantCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"getByRoom\":{\"name\":\"getByRoom\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatParticipant[]>\",\"isStatic\":false,\"isPublic\":true},\"getByProfile\":{\"name\":\"getByProfile\",\"async\":true,\"parameters\":[{\"name\":\"profileId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatParticipant[]>\",\"isStatic\":false,\"isPublic\":true},\"findMembership\":{\"name\":\"findMembership\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false},{\"name\":\"profileId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":true}],\"returnType\":\"Promise<ChatParticipant | null>\",\"isStatic\":false,\"isPublic\":true},\"findActiveMembership\":{\"name\":\"findActiveMembership\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false},{\"name\":\"profileId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatParticipant | null>\",\"isStatic\":false,\"isPublic\":true},\"isActiveMember\":{\"name\":\"isActiveMember\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false},{\"name\":\"profileId\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<boolean>\",\"isStatic\":false,\"isPublic\":true},\"getOnlineInRoom\":{\"name\":\"getOnlineInRoom\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatParticipant[]>\",\"isStatic\":false,\"isPublic\":true},\"getAdminsInRoom\":{\"name\":\"getAdminsInRoom\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatParticipant[]>\",\"isStatic\":false,\"isPublic\":true},\"countInRoom\":{\"name\":\"countInRoom\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_participants\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"ChatParticipant\",\"exportName\":\"ChatParticipantCollection\",\"collectionExportName\":\"ChatParticipantCollectionCollection\",\"schema\":{\"tableName\":\"chat_participants\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"chat_participants_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_participants_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"f70abec0\"}},\"@happyvertical/smrt-chat:ChatReactionCollection\":{\"name\":\"chatreactioncollection\",\"className\":\"ChatReactionCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatReactionCollection\",\"collection\":\"chatreactions\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatReactionCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"getByMessage\":{\"name\":\"getByMessage\",\"async\":true,\"parameters\":[{\"name\":\"messageId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatReaction[]>\",\"isStatic\":false,\"isPublic\":true},\"getReactionCounts\":{\"name\":\"getReactionCounts\",\"async\":true,\"parameters\":[{\"name\":\"messageId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Map<string, object>>\",\"isStatic\":false,\"isPublic\":true},\"toggle\":{\"name\":\"toggle\",\"async\":true,\"parameters\":[{\"name\":\"messageId\",\"type\":\"string\",\"optional\":false},{\"name\":\"profileId\",\"type\":\"string\",\"optional\":false},{\"name\":\"emoji\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<object>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_reactions\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"ChatReaction\",\"exportName\":\"ChatReactionCollection\",\"collectionExportName\":\"ChatReactionCollectionCollection\",\"schema\":{\"tableName\":\"chat_reactions\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"chat_reactions_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_reactions_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"0ea62683\"}},\"@happyvertical/smrt-chat:ChatRoomCollection\":{\"name\":\"chatroomcollection\",\"className\":\"ChatRoomCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatRoomCollection\",\"collection\":\"chatrooms\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatRoomCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"findByType\":{\"name\":\"findByType\",\"async\":true,\"parameters\":[{\"name\":\"roomType\",\"type\":\"ChatRoomType\",\"optional\":false}],\"returnType\":\"Promise<ChatRoom[]>\",\"isStatic\":false,\"isPublic\":true},\"findPublic\":{\"name\":\"findPublic\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<ChatRoom[]>\",\"isStatic\":false,\"isPublic\":true},\"findDMs\":{\"name\":\"findDMs\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<ChatRoom[]>\",\"isStatic\":false,\"isPublic\":true},\"findAgentRooms\":{\"name\":\"findAgentRooms\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<ChatRoom[]>\",\"isStatic\":false,\"isPublic\":true},\"search\":{\"name\":\"search\",\"async\":true,\"parameters\":[{\"name\":\"query\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<ChatRoom[]>\",\"isStatic\":false,\"isPublic\":true},\"findOrCreateDM\":{\"name\":\"findOrCreateDM\",\"async\":true,\"parameters\":[{\"name\":\"profileId1\",\"type\":\"string\",\"optional\":false},{\"name\":\"profileId2\",\"type\":\"string\",\"optional\":false},{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"participants\",\"type\":\"ChatParticipantCollection\",\"optional\":false}],\"returnType\":\"Promise<ChatRoom>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_rooms\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"ChatRoom\",\"exportName\":\"ChatRoomCollection\",\"collectionExportName\":\"ChatRoomCollectionCollection\",\"schema\":{\"tableName\":\"chat_rooms\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"chat_rooms_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_rooms_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"40be4b86\"}},\"@happyvertical/smrt-chat:ChatThreadCollection\":{\"name\":\"chatthreadcollection\",\"className\":\"ChatThreadCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatThreadCollection\",\"collection\":\"chatthreads\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/collections/ChatThreadCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"getByRoom\":{\"name\":\"getByRoom\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatThread[]>\",\"isStatic\":false,\"isPublic\":true},\"getActive\":{\"name\":\"getActive\",\"async\":true,\"parameters\":[{\"name\":\"roomId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<ChatThread[]>\",\"isStatic\":false,\"isPublic\":true},\"getUnresolved\":{\"name\":\"getUnresolved\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<ChatThread[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_threads\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"ChatThread\",\"exportName\":\"ChatThreadCollection\",\"collectionExportName\":\"ChatThreadCollectionCollection\",\"schema\":{\"tableName\":\"chat_threads\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"chat_threads_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_threads_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"760b62bd\"}},\"@happyvertical/smrt-chat:AgentSession\":{\"name\":\"agentsession\",\"className\":\"AgentSession\",\"qualifiedName\":\"@happyvertical/smrt-chat:AgentSession\",\"collection\":\"agentsessions\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/models/AgentSession.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"agentId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"participantProfileId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-profiles:Profile\"},\"chatRoomId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"ChatRoom\"},\"status\":{\"type\":\"text\",\"required\":true,\"default\":\"active\",\"_meta\":{\"required\":true}},\"allowedTools\":{\"type\":\"text\",\"required\":false,\"default\":\"[]\"},\"sessionContext\":{\"type\":\"text\",\"required\":false,\"default\":\"{}\"},\"systemPrompt\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"messageCount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"totalTokensUsed\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"maxTokens\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"maxMessages\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"lastMessageAt\":{\"type\":\"datetime\",\"required\":false},\"expiresAt\":{\"type\":\"datetime\",\"required\":false},\"closedAt\":{\"type\":\"datetime\",\"required\":false}},\"methods\":{\"getAllowedTools\":{\"name\":\"getAllowedTools\",\"async\":false,\"parameters\":[],\"returnType\":\"string[]\",\"isStatic\":false,\"isPublic\":true},\"setAllowedTools\":{\"name\":\"setAllowedTools\",\"async\":false,\"parameters\":[{\"name\":\"tools\",\"type\":\"string[]\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"isToolAllowed\":{\"name\":\"isToolAllowed\",\"async\":false,\"parameters\":[{\"name\":\"toolName\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isActive\":{\"name\":\"isActive\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isExpired\":{\"name\":\"isExpired\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"close\":{\"name\":\"close\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"expire\":{\"name\":\"expire\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"getSessionContext\":{\"name\":\"getSessionContext\",\"async\":false,\"parameters\":[],\"returnType\":\"Record<string>\",\"isStatic\":false,\"isPublic\":true},\"setSessionContext\":{\"name\":\"setSessionContext\",\"async\":false,\"parameters\":[{\"name\":\"ctx\",\"type\":\"Record<string>\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"getSessionKey\":{\"name\":\"getSessionKey\",\"async\":false,\"parameters\":[],\"returnType\":\"string | null\",\"isStatic\":false,\"isPublic\":true},\"updateSessionContext\":{\"name\":\"updateSessionContext\",\"async\":true,\"parameters\":[{\"name\":\"updates\",\"type\":\"Record<string>\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"recordMessage\":{\"name\":\"recordMessage\",\"async\":true,\"parameters\":[{\"name\":\"tokensUsed\",\"type\":\"number\",\"optional\":true}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_sessions\",\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"AgentSession\",\"collectionExportName\":\"AgentSessionCollection\",\"validationRules\":[{\"field\":\"agentId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"participantProfileId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"},{\"field\":\"status\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"agent_sessions\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"agent_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"participant_profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"chat_room_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"active\"},\"allowed_tools\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"[]\"},\"session_context\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"{}\"},\"system_prompt\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"message_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"total_tokens_used\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"max_tokens\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"max_messages\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"last_message_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"expires_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"closed_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"agent_sessions_id_idx\",\"columns\":[\"id\"]},{\"name\":\"agent_sessions_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"9de59339\"}},\"@happyvertical/smrt-chat:ChatMessage\":{\"name\":\"chatmessage\",\"className\":\"ChatMessage\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatMessage\",\"collection\":\"chatmessages\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatMessage.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":true,\"autoPopulate\":true,\"nullable\":false,\"mode\":\"required\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"roomId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"ChatRoom\",\"_meta\":{\"required\":true}},\"threadId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"ChatThread\"},\"senderProfileId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-profiles:Profile\"},\"agentSessionId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"AgentSession\"},\"content\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"messageType\":{\"type\":\"text\",\"required\":true,\"default\":\"text\",\"_meta\":{\"required\":true}},\"role\":{\"type\":\"text\",\"required\":true,\"default\":\"user\",\"_meta\":{\"required\":true}},\"isEdited\":{\"type\":\"boolean\",\"required\":false,\"default\":false},\"editedAt\":{\"type\":\"datetime\",\"required\":false},\"isDeleted\":{\"type\":\"boolean\",\"required\":false,\"default\":false},\"replyToMessageId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"ChatMessage\"},\"metadata\":{\"type\":\"text\",\"required\":false,\"default\":\"{}\"},\"toolCallData\":{\"type\":\"text\",\"required\":false},\"attachments\":{\"type\":\"text\",\"required\":false,\"default\":\"[]\"}},\"methods\":{\"getAttachments\":{\"name\":\"getAttachments\",\"async\":false,\"parameters\":[],\"returnType\":\"Array<object>\",\"isStatic\":false,\"isPublic\":true},\"setAttachments\":{\"name\":\"setAttachments\",\"async\":false,\"parameters\":[{\"name\":\"items\",\"type\":\"Array<object>\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"getMetadata\":{\"name\":\"getMetadata\",\"async\":false,\"parameters\":[],\"returnType\":\"Record<string>\",\"isStatic\":false,\"isPublic\":true},\"setMetadata\":{\"name\":\"setMetadata\",\"async\":false,\"parameters\":[{\"name\":\"data\",\"type\":\"Record<string>\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"getToolCallData\":{\"name\":\"getToolCallData\",\"async\":false,\"parameters\":[],\"returnType\":\"Record<string> | null\",\"isStatic\":false,\"isPublic\":true},\"setToolCallData\":{\"name\":\"setToolCallData\",\"async\":false,\"parameters\":[{\"name\":\"data\",\"type\":\"Record<string> | null\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"hasAttachments\":{\"name\":\"hasAttachments\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isToolCall\":{\"name\":\"isToolCall\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isToolResult\":{\"name\":\"isToolResult\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isFromAgent\":{\"name\":\"isFromAgent\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isSystemMessage\":{\"name\":\"isSystemMessage\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"edit\":{\"name\":\"edit\",\"async\":true,\"parameters\":[{\"name\":\"newContent\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"softDelete\":{\"name\":\"softDelete\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"getPreview\":{\"name\":\"getPreview\",\"async\":false,\"parameters\":[{\"name\":\"maxLength\",\"type\":\"any\",\"optional\":true}],\"returnType\":\"string\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_messages\",\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"ChatMessage\",\"collectionExportName\":\"ChatMessageCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"roomId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"},{\"field\":\"senderProfileId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"},{\"field\":\"messageType\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"role\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"chat_messages\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"room_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false},\"thread_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"sender_profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"agent_session_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"content\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"message_type\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"text\"},\"role\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"user\"},\"is_edited\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":false},\"edited_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"is_deleted\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":false},\"reply_to_message_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"metadata\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"{}\"},\"tool_call_data\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"attachments\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"[]\"}},\"indexes\":[{\"name\":\"chat_messages_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_messages_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"7469514e\"}},\"@happyvertical/smrt-chat:ChatParticipant\":{\"name\":\"chatparticipant\",\"className\":\"ChatParticipant\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatParticipant\",\"collection\":\"chatparticipants\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatParticipant.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":true,\"autoPopulate\":true,\"nullable\":false,\"mode\":\"required\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"roomId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"ChatRoom\",\"_meta\":{\"required\":true}},\"profileId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-profiles:Profile\"},\"role\":{\"type\":\"text\",\"required\":true,\"default\":\"member\",\"_meta\":{\"required\":true}},\"status\":{\"type\":\"text\",\"required\":true,\"default\":\"active\",\"_meta\":{\"required\":true}},\"onlineStatus\":{\"type\":\"text\",\"required\":true,\"default\":\"offline\",\"_meta\":{\"required\":true}},\"lastReadMessageId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"ChatMessage\"},\"lastSeenAt\":{\"type\":\"datetime\",\"required\":false},\"joinedAt\":{\"type\":\"datetime\",\"required\":false},\"nickname\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"isMuted\":{\"type\":\"boolean\",\"required\":false,\"default\":false},\"isPinned\":{\"type\":\"boolean\",\"required\":false,\"default\":false}},\"methods\":{\"isActive\":{\"name\":\"isActive\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isOwner\":{\"name\":\"isOwner\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isAdmin\":{\"name\":\"isAdmin\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"markRead\":{\"name\":\"markRead\",\"async\":true,\"parameters\":[{\"name\":\"messageId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"leave\":{\"name\":\"leave\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"setOnline\":{\"name\":\"setOnline\",\"async\":true,\"parameters\":[{\"name\":\"status\",\"type\":\"OnlineStatus\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_participants\",\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"ChatParticipant\",\"collectionExportName\":\"ChatParticipantCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"roomId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"},{\"field\":\"profileId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"},{\"field\":\"role\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"status\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"onlineStatus\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"chat_participants\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"room_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false},\"profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"role\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"member\"},\"status\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"active\"},\"online_status\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"offline\"},\"last_read_message_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"last_seen_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"joined_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"nickname\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"is_muted\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":false},\"is_pinned\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":false}},\"indexes\":[{\"name\":\"chat_participants_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_participants_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"50824444\"}},\"@happyvertical/smrt-chat:ChatReaction\":{\"name\":\"chatreaction\",\"className\":\"ChatReaction\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatReaction\",\"collection\":\"chatreactions\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatReaction.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":true,\"autoPopulate\":true,\"nullable\":false,\"mode\":\"required\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"messageId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"ChatMessage\",\"_meta\":{\"required\":true}},\"profileId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-profiles:Profile\"},\"emoji\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"chat_reactions\",\"api\":{\"include\":[\"list\"]},\"mcp\":{\"include\":[\"list\"]},\"cli\":false,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"ChatReaction\",\"collectionExportName\":\"ChatReactionCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"messageId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"},{\"field\":\"profileId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"},{\"field\":\"emoji\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"chat_reactions\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"message_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false},\"profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"emoji\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"}},\"indexes\":[{\"name\":\"chat_reactions_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_reactions_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"8378c874\"}},\"@happyvertical/smrt-chat:ChatRoom\":{\"name\":\"chatroom\",\"className\":\"ChatRoom\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatRoom\",\"collection\":\"chatrooms\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatRoom.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":true,\"autoPopulate\":true,\"nullable\":false,\"mode\":\"required\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"name\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"description\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"roomType\":{\"type\":\"text\",\"required\":true,\"default\":\"public\",\"_meta\":{\"required\":true}},\"status\":{\"type\":\"text\",\"required\":true,\"default\":\"active\",\"_meta\":{\"required\":true}},\"topic\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"avatarUrl\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"isArchived\":{\"type\":\"boolean\",\"required\":false,\"default\":false},\"maxParticipants\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"metadata\":{\"type\":\"text\",\"required\":false,\"default\":\"{}\"},\"createdByProfileId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-profiles:Profile\"},\"lastMessageAt\":{\"type\":\"datetime\",\"required\":false}},\"methods\":{\"getMetadata\":{\"name\":\"getMetadata\",\"async\":false,\"parameters\":[],\"returnType\":\"ChatRoomMetadata\",\"isStatic\":false,\"isPublic\":true},\"setMetadata\":{\"name\":\"setMetadata\",\"async\":false,\"parameters\":[{\"name\":\"data\",\"type\":\"ChatRoomMetadata\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"updateMetadata\":{\"name\":\"updateMetadata\",\"async\":false,\"parameters\":[{\"name\":\"updates\",\"type\":\"ChatRoomMetadata\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"isDM\":{\"name\":\"isDM\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isAgentRoom\":{\"name\":\"isAgentRoom\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isPublic\":{\"name\":\"isPublic\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isActive\":{\"name\":\"isActive\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"archive\":{\"name\":\"archive\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"unarchive\":{\"name\":\"unarchive\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_rooms\",\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"ChatRoom\",\"collectionExportName\":\"ChatRoomCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"roomType\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"status\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"chat_rooms\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"room_type\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"public\"},\"status\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"active\"},\"topic\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"avatar_url\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"is_archived\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":false},\"max_participants\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"metadata\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"{}\"},\"created_by_profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":false,\"unique\":false},\"last_message_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"chat_rooms_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_rooms_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"3665d881\"}},\"@happyvertical/smrt-chat:ChatThread\":{\"name\":\"chatthread\",\"className\":\"ChatThread\",\"qualifiedName\":\"@happyvertical/smrt-chat:ChatThread\",\"collection\":\"chatthreads\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/chat/src/models/ChatThread.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":true,\"autoPopulate\":true,\"nullable\":false,\"mode\":\"required\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"roomId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"ChatRoom\",\"_meta\":{\"required\":true}},\"rootMessageId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"ChatMessage\",\"_meta\":{\"nullable\":true}},\"title\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"isResolved\":{\"type\":\"boolean\",\"required\":false,\"default\":false},\"messageCount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"lastMessageAt\":{\"type\":\"datetime\",\"required\":false},\"participantCount\":{\"type\":\"integer\",\"required\":false,\"default\":0}},\"methods\":{\"resolve\":{\"name\":\"resolve\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"reopen\":{\"name\":\"reopen\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"chat_threads\",\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"ChatThread\",\"collectionExportName\":\"ChatThreadCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"roomId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"}],\"schema\":{\"tableName\":\"chat_threads\",\"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);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":true,\"unique\":false},\"room_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false},\"root_message_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"title\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"is_resolved\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":false},\"message_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"last_message_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"participant_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0}},\"indexes\":[{\"name\":\"chat_threads_id_idx\",\"columns\":[\"id\"]},{\"name\":\"chat_threads_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"6fd35191\"}}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-agents\",\"@happyvertical/smrt-core\",\"@happyvertical/smrt-personas\",\"@happyvertical/smrt-profiles\",\"@happyvertical/smrt-tenancy\",\"@happyvertical/smrt-users\"]}"));
6
10
  //#endregion
7
- export { AgentSession, CHAT_MODULE_META, CHAT_UI_SLOTS, ChatMessage, ChatParticipant, ChatReaction, ChatRoom, ChatService, ChatThread };
11
+ //#region src/chat-feedback.ts
12
+ async function captureChatFeedback(options) {
13
+ if (!options.persona.id) throw new Error("captureChatFeedback requires a persisted persona (missing id)");
14
+ const memoryScope = personaMemoryScope(options.persona);
15
+ const feedback = await (await FeedbackCollection.create({ db: options.db })).create({
16
+ tenantId: options.persona.tenantId ?? null,
17
+ personaId: options.persona.id,
18
+ agentClass: options.persona.agentClass ?? "",
19
+ memoryScope,
20
+ scope: options.scope,
21
+ key: options.key,
22
+ signalType: options.signalType,
23
+ source: feedbackSourceFor(options.signalType),
24
+ correlationId: options.correlationId,
25
+ correlationType: options.correlationType ?? "chat_message",
26
+ rating: options.rating ?? null,
27
+ correction: options.correction ?? null,
28
+ comment: options.comment ?? null,
29
+ actorId: options.actorId ?? null
30
+ });
31
+ if (options.metadata) feedback.setMetadata(options.metadata);
32
+ await feedback.save();
33
+ let reinforced = null;
34
+ if (options.reinforce !== false) {
35
+ reinforced = await reinforceFromFeedback(personaLearningMemory({
36
+ db: await getDatabase(options.db),
37
+ persona: options.persona,
38
+ semanticSearch: options.semanticSearch
39
+ }), feedback, { ratingNeutral: options.ratingNeutral });
40
+ feedback.reinforcedAt = /* @__PURE__ */ new Date();
41
+ await feedback.save();
42
+ }
43
+ return {
44
+ feedback,
45
+ reinforced
46
+ };
47
+ }
48
+ function acceptAppliedChange(options) {
49
+ return captureChatFeedback({
50
+ ...options,
51
+ signalType: "accept"
52
+ });
53
+ }
54
+ function rejectAppliedChange(options) {
55
+ return captureChatFeedback({
56
+ ...options,
57
+ signalType: "reject"
58
+ });
59
+ }
60
+ function correctResponse(options) {
61
+ return captureChatFeedback({
62
+ ...options,
63
+ signalType: "correction",
64
+ correction: options.correction
65
+ });
66
+ }
67
+ function rateResponse(options) {
68
+ return captureChatFeedback({
69
+ ...options,
70
+ signalType: "rating",
71
+ rating: options.rating
72
+ });
73
+ }
74
+ function thumbsUp(options) {
75
+ return captureChatFeedback({
76
+ ...options,
77
+ signalType: "rating",
78
+ rating: 1
79
+ });
80
+ }
81
+ function thumbsDown(options) {
82
+ return captureChatFeedback({
83
+ ...options,
84
+ signalType: "rating",
85
+ rating: -1
86
+ });
87
+ }
88
+ //#endregion
89
+ //#region src/tool-loop.ts
90
+ var DEFAULT_MAX_STEPS = 8;
91
+ function asRecord(value) {
92
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
93
+ }
94
+ function parseToolArguments(raw) {
95
+ if (!raw) return {};
96
+ try {
97
+ return asRecord(JSON.parse(raw));
98
+ } catch {
99
+ return {};
100
+ }
101
+ }
102
+ function actionFromDefinition(def) {
103
+ const collection = def.collection;
104
+ if (!collection || !def.slug.startsWith(`${collection}.`)) return null;
105
+ const action = def.slug.slice(collection.length + 1);
106
+ return action.length > 0 ? action : null;
107
+ }
108
+ function buildManifestToolCatalog(options = {}) {
109
+ const definitions = options.catalog ?? PermissionCatalogService.create(options).getCatalog().permissions;
110
+ const filter = options.all === true ? null : new Set(options.allowedTools ?? []);
111
+ const tools = [];
112
+ for (const def of definitions) {
113
+ if (!def.className || !def.collection) continue;
114
+ if (filter && !filter.has(def.slug)) continue;
115
+ const action = actionFromDefinition(def);
116
+ if (!action) continue;
117
+ tools.push({
118
+ slug: def.slug,
119
+ collection: def.collection,
120
+ className: def.className,
121
+ action,
122
+ qualifiedName: def.qualifiedName,
123
+ description: def.description
124
+ });
125
+ }
126
+ return tools;
127
+ }
128
+ function toolParameters(tool) {
129
+ const fieldProps = () => {
130
+ const props = {};
131
+ try {
132
+ for (const [name] of ObjectRegistry.getFields(tool.className)) if (typeof name === "string") props[name] = { type: "string" };
133
+ } catch {}
134
+ return props;
135
+ };
136
+ switch (tool.action) {
137
+ case "read": return {
138
+ type: "object",
139
+ properties: {
140
+ id: {
141
+ type: "string",
142
+ description: "Fetch one row by id (omit to list)."
143
+ },
144
+ where: {
145
+ type: "object",
146
+ description: "Equality filters for a list."
147
+ },
148
+ limit: { type: "number" },
149
+ offset: { type: "number" }
150
+ }
151
+ };
152
+ case "create": return {
153
+ type: "object",
154
+ properties: fieldProps()
155
+ };
156
+ case "update": return {
157
+ type: "object",
158
+ required: ["id"],
159
+ properties: {
160
+ id: { type: "string" },
161
+ ...fieldProps()
162
+ }
163
+ };
164
+ case "delete": return {
165
+ type: "object",
166
+ required: ["id"],
167
+ properties: { id: { type: "string" } }
168
+ };
169
+ default: return {
170
+ type: "object",
171
+ required: ["id"],
172
+ properties: { id: {
173
+ type: "string",
174
+ description: "Target row id for the action."
175
+ } }
176
+ };
177
+ }
178
+ }
179
+ function toolFunctionName(slug) {
180
+ return slug.replace(/[^A-Za-z0-9_-]/g, "-").slice(0, 64);
181
+ }
182
+ function manifestToolToAITool(tool) {
183
+ return {
184
+ type: "function",
185
+ function: {
186
+ name: toolFunctionName(tool.slug),
187
+ description: tool.description ?? `Manifest operation '${tool.action}' on '${tool.collection}'.`,
188
+ parameters: toolParameters(tool)
189
+ }
190
+ };
191
+ }
192
+ function itemToObservation(item) {
193
+ const candidate = item;
194
+ return typeof candidate?.toJSON === "function" ? candidate.toJSON() : item;
195
+ }
196
+ async function invokeManifestTool(run, tool, args, options = {}) {
197
+ run.assertToolAllowed(tool.slug);
198
+ await run.assertOperation(tool.collection, tool.action);
199
+ const db = run.context.database ?? options.db;
200
+ const collection = await ObjectRegistry.getCollection(tool.className, db ? { db } : {});
201
+ switch (tool.action) {
202
+ case "read": {
203
+ const id = typeof args.id === "string" ? args.id : void 0;
204
+ if (id) {
205
+ const item = await collection.get(id);
206
+ return item ? itemToObservation(item) : { found: false };
207
+ }
208
+ return (await collection.list({
209
+ where: asRecord(args.where),
210
+ limit: typeof args.limit === "number" ? args.limit : 50,
211
+ offset: typeof args.offset === "number" ? args.offset : 0
212
+ })).map(itemToObservation);
213
+ }
214
+ case "create": {
215
+ const item = await collection.create(args);
216
+ await item.save();
217
+ return itemToObservation(item);
218
+ }
219
+ case "update": {
220
+ const { id, ...rest } = args;
221
+ if (typeof id !== "string" || id.length === 0) throw new Error(`'${tool.slug}' requires an 'id' to update.`);
222
+ const item = await collection.get(id);
223
+ if (!item) return { found: false };
224
+ Object.assign(item, rest);
225
+ await item.save();
226
+ return itemToObservation(item);
227
+ }
228
+ case "delete": {
229
+ const id = typeof args.id === "string" ? args.id : void 0;
230
+ if (!id) throw new Error(`'${tool.slug}' requires an 'id' to delete.`);
231
+ const item = await collection.get(id);
232
+ if (!item) return { found: false };
233
+ await item.delete();
234
+ return {
235
+ success: true,
236
+ id
237
+ };
238
+ }
239
+ default: {
240
+ const { id, ...rest } = args;
241
+ if (typeof id !== "string" || id.length === 0) throw new Error(`'${tool.slug}' requires an 'id' for a custom action.`);
242
+ const item = await collection.get(id);
243
+ if (!item) return { found: false };
244
+ const method = item[tool.action];
245
+ if (typeof method !== "function") throw new Error(`Method '${tool.action}' not found on '${tool.className}'.`);
246
+ const result = await method.call(item, rest);
247
+ return result === void 0 ? { success: true } : itemToObservation(result);
248
+ }
249
+ }
250
+ }
251
+ async function runToolLoop(options) {
252
+ const { ai, messages, tools, extraTools = [], principal, db, maxSteps = 8, model, temperature, maxTokens, toolChoice = "auto", executeTool, onInvocation, onBehalfOfUserId, agentClass, audit, postgresRls } = options;
253
+ const aiTools = [...tools.map(manifestToolToAITool), ...extraTools.map((tool) => tool.aiTool)];
254
+ const offered = /* @__PURE__ */ new Map();
255
+ for (const tool of tools) {
256
+ offered.set(tool.slug, tool);
257
+ offered.set(toolFunctionName(tool.slug), tool);
258
+ }
259
+ const offeredExtra = /* @__PURE__ */ new Map();
260
+ for (const tool of extraTools) {
261
+ offeredExtra.set(tool.slug, tool);
262
+ offeredExtra.set(tool.aiTool.function.name, tool);
263
+ }
264
+ return executeAsPrincipal({
265
+ db,
266
+ principal,
267
+ onBehalfOfUserId,
268
+ agentClass,
269
+ action: "chat.tool_loop",
270
+ postgresRls,
271
+ audit
272
+ }, async (run) => {
273
+ const working = [...messages];
274
+ const invocations = [];
275
+ let executedRounds = 0;
276
+ let totalTokens = 0;
277
+ let response;
278
+ for (;;) {
279
+ const offerTools = aiTools.length > 0 && executedRounds < maxSteps;
280
+ response = await ai.chat(working, {
281
+ model,
282
+ temperature,
283
+ maxTokens,
284
+ tools: offerTools ? aiTools : void 0,
285
+ toolChoice: offerTools ? toolChoice : "none"
286
+ });
287
+ totalTokens += response.usage?.totalTokens ?? 0;
288
+ const toolCalls = offerTools ? response.toolCalls ?? [] : [];
289
+ if (toolCalls.length === 0) return {
290
+ content: response.content ?? "",
291
+ steps: executedRounds,
292
+ stoppedReason: aiTools.length === 0 ? "no_tools" : offerTools ? "stop" : "max_steps",
293
+ invocations,
294
+ messages: working,
295
+ totalTokens
296
+ };
297
+ working.push({
298
+ role: "assistant",
299
+ content: response.content ?? "",
300
+ tool_calls: toolCalls
301
+ });
302
+ for (const call of toolCalls) {
303
+ const requestedName = call.function.name;
304
+ const args = parseToolArguments(call.function.arguments);
305
+ const tool = offered.get(requestedName);
306
+ const extraTool = tool ? void 0 : offeredExtra.get(requestedName);
307
+ const slug = tool?.slug ?? extraTool?.slug ?? requestedName;
308
+ let invocation;
309
+ if (!tool && !extraTool) invocation = {
310
+ slug,
311
+ args,
312
+ ok: false,
313
+ rejected: true,
314
+ observation: { error: `Tool '${slug}' is not permitted for this persona.` },
315
+ error: "not_permitted"
316
+ };
317
+ else try {
318
+ invocation = {
319
+ slug,
320
+ args,
321
+ ok: true,
322
+ rejected: false,
323
+ observation: await (tool ? executeTool ? executeTool({
324
+ run,
325
+ tool,
326
+ args,
327
+ db
328
+ }) : invokeManifestTool(run, tool, args, { db }) : extraTool.execute({
329
+ run,
330
+ args,
331
+ db
332
+ }))
333
+ };
334
+ } catch (error) {
335
+ const rejected = error instanceof PrincipalToolNotAllowedError || error instanceof OperationPermissionError;
336
+ invocation = {
337
+ slug,
338
+ args,
339
+ ok: false,
340
+ rejected,
341
+ observation: { error: error instanceof Error ? error.message : String(error) },
342
+ error: rejected ? "not_permitted" : "execution_error"
343
+ };
344
+ }
345
+ invocations.push(invocation);
346
+ await onInvocation?.(invocation);
347
+ working.push({
348
+ role: "tool",
349
+ name: requestedName,
350
+ tool_call_id: call.id,
351
+ content: JSON.stringify(invocation.observation)
352
+ });
353
+ }
354
+ executedRounds += 1;
355
+ }
356
+ });
357
+ }
358
+ //#endregion
359
+ //#region src/persona-conversation.ts
360
+ function conversationPersonaFromResolved(resolved) {
361
+ return {
362
+ id: resolved.personaId ?? null,
363
+ tenantId: resolved.tenantId,
364
+ agentClass: resolved.agentClass,
365
+ runAsUserId: resolved.runAsUserId ?? "",
366
+ actsAsProfileId: resolved.actsAsProfileId ?? null,
367
+ allowedTools: resolved.allowedTools,
368
+ instructions: resolved.instructions,
369
+ memoryScope: resolved.memoryScope
370
+ };
371
+ }
372
+ function conversationPersonaFromAgentPersona(persona) {
373
+ return {
374
+ id: persona.id ?? null,
375
+ tenantId: persona.tenantId,
376
+ agentClass: persona.agentClass,
377
+ runAsUserId: persona.runAsUserId,
378
+ actsAsProfileId: persona.actsAsProfileId ?? null,
379
+ allowedTools: persona.getAllowedTools(),
380
+ instructions: persona.instructions,
381
+ memoryScope: persona.memoryScope
382
+ };
383
+ }
384
+ function principalBindingFor(persona) {
385
+ return {
386
+ runAsUserId: persona.runAsUserId,
387
+ tenantId: persona.tenantId,
388
+ allowedTools: persona.allowedTools,
389
+ actsAsProfileId: persona.actsAsProfileId ?? null
390
+ };
391
+ }
392
+ async function recallPersonaMemory(db, persona, options = {}) {
393
+ if (!persona.memoryScope && !persona.id) return [];
394
+ return personaLearningMemory({
395
+ db: await getDatabase(db),
396
+ persona,
397
+ semanticSearch: options.semanticSearch
398
+ }).recall(options.scope ?? "chat", {
399
+ key: options.key,
400
+ query: options.query,
401
+ limit: options.limit ?? 5,
402
+ minConfidence: options.minConfidence
403
+ });
404
+ }
405
+ function formatRecalledMemory(records) {
406
+ if (records.length === 0) return "";
407
+ return `What you have learned about this organisation:
408
+ ${records.map((record) => {
409
+ const value = typeof record.value === "string" ? record.value : JSON.stringify(record.value);
410
+ return `- [confidence ${record.confidence.toFixed(2)}] ${record.key}: ${value}`;
411
+ }).join("\n")}`;
412
+ }
413
+ async function resolveConversationInstructions(db, persona) {
414
+ if (persona.id) try {
415
+ const resolved = await resolvePersonaInstructions({
416
+ persona: {
417
+ id: persona.id,
418
+ tenantId: persona.tenantId
419
+ },
420
+ db
421
+ });
422
+ if (resolved) return resolved;
423
+ } catch {}
424
+ return persona.instructions ?? "";
425
+ }
426
+ function assembleSystemPrompt(instructions, memoryBlock, sessionPrompt) {
427
+ const blocks = [
428
+ sessionPrompt,
429
+ instructions,
430
+ memoryBlock
431
+ ].map((part) => part?.trim()).filter((part) => Boolean(part));
432
+ return [...new Set(blocks)].join("\n\n");
433
+ }
434
+ async function runPersonaConversationTurn(options) {
435
+ const { ai, db, persona, userMessage, tenantId } = options;
436
+ if (!persona.runAsUserId) throw new Error("runPersonaConversationTurn requires a persona bound to a run-as user (runAsUserId); an unbound/default persona cannot operate the app.");
437
+ const correlationId = options.correlationId ?? crypto.randomUUID();
438
+ const recalled = options.recall === false ? [] : await recallPersonaMemory(db, persona, options.recall ?? {});
439
+ const systemPrompt = assembleSystemPrompt(await resolveConversationInstructions(db, persona), formatRecalledMemory(recalled), options.session?.systemPrompt);
440
+ const messages = [];
441
+ if (systemPrompt) messages.push({
442
+ role: "system",
443
+ content: systemPrompt
444
+ });
445
+ if (options.history) messages.push(...options.history);
446
+ messages.push({
447
+ role: "user",
448
+ content: userMessage
449
+ });
450
+ const result = await runToolLoop({
451
+ ai,
452
+ messages,
453
+ tools: options.tools ?? buildManifestToolCatalog({
454
+ db,
455
+ allowedTools: persona.allowedTools
456
+ }),
457
+ extraTools: (options.extraTools ?? []).filter((tool) => persona.allowedTools.includes(tool.slug)),
458
+ principal: principalBindingFor(persona),
459
+ db,
460
+ maxSteps: options.maxSteps,
461
+ model: options.model,
462
+ temperature: options.temperature,
463
+ maxTokens: options.maxTokens,
464
+ onBehalfOfUserId: options.onBehalfOfUserId,
465
+ agentClass: persona.agentClass,
466
+ postgresRls: options.postgresRls,
467
+ audit: options.audit
468
+ });
469
+ if (options.chatService && options.session?.id) await authorConversationReply({
470
+ chatService: options.chatService,
471
+ session: options.session,
472
+ tenantId,
473
+ threadId: options.threadId ?? null,
474
+ result
475
+ });
476
+ return {
477
+ result,
478
+ correlationId,
479
+ recalled,
480
+ systemPrompt
481
+ };
482
+ }
483
+ async function bindPersonaToSession(options) {
484
+ const instructions = options.instructions ?? (options.db ? await resolveConversationInstructions(options.db, options.persona) : options.persona.instructions ?? "");
485
+ return options.chatService.updateAgentSessionConfig({
486
+ agentSessionId: options.session.id,
487
+ actorProfileId: options.actorProfileId,
488
+ tenantId: options.tenantId,
489
+ allowedTools: options.persona.allowedTools,
490
+ systemPrompt: instructions
491
+ });
492
+ }
493
+ async function authorConversationReply(input) {
494
+ const { sendAgentReply } = await import("./chunks/ChatService-BRsE5HmY.js").then((n) => n.n);
495
+ for (const invocation of input.result.invocations) {
496
+ if (!invocation.ok) continue;
497
+ await sendAgentReply(input.chatService, {
498
+ tenantId: input.tenantId,
499
+ agentSessionId: input.session.id,
500
+ threadId: input.threadId,
501
+ content: JSON.stringify(invocation.observation),
502
+ kind: "tool",
503
+ messageType: "tool_result",
504
+ toolCallData: {
505
+ name: invocation.slug,
506
+ args: invocation.args
507
+ }
508
+ });
509
+ }
510
+ await sendAgentReply(input.chatService, {
511
+ tenantId: input.tenantId,
512
+ agentSessionId: input.session.id,
513
+ threadId: input.threadId,
514
+ content: input.result.content,
515
+ kind: "assistant"
516
+ });
517
+ }
518
+ //#endregion
519
+ export { AgentSession, CHAT_MODULE_META, CHAT_UI_SLOTS, ChatMessage, ChatParticipant, ChatReaction, ChatRoom, ChatService, ChatThread, DEFAULT_MAX_STEPS, acceptAppliedChange, bindPersonaToSession, buildManifestToolCatalog, captureChatFeedback, conversationPersonaFromAgentPersona, conversationPersonaFromResolved, correctResponse, formatRecalledMemory, invokeManifestTool, manifestToolToAITool, principalBindingFor, rateResponse, recallPersonaMemory, rejectAppliedChange, resolveConversationInstructions, runPersonaConversationTurn, runToolLoop, thumbsDown, thumbsUp };
8
520
 
9
521
  //# sourceMappingURL=index.js.map