@happyvertical/smrt-chat 0.39.4 → 0.39.6

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
@@ -3,11 +3,11 @@ import { CHAT_MODULE_META, CHAT_UI_SLOTS } from "./ui.js";
3
3
  import { ObjectRegistry, SmrtCollection, SmrtObject, ValidationError, field, foreignKey, smrt } from "@happyvertical/smrt-core";
4
4
  import { FeedbackCollection, feedbackSourceFor, personaLearningMemory, personaMemoryScope, reinforceFromFeedback, resolvePersonaInstructions } from "@happyvertical/smrt-personas";
5
5
  import { getDatabase } from "@happyvertical/sql";
6
- import { TenantScoped, tenantId } from "@happyvertical/smrt-tenancy";
7
6
  import { PrincipalToolNotAllowedError, executeAsPrincipal } from "@happyvertical/smrt-agents";
8
7
  import { OperationPermissionError, PermissionCatalogService } from "@happyvertical/smrt-users";
8
+ import { TenantScoped, tenantId } from "@happyvertical/smrt-tenancy";
9
9
  //#region src/__smrt-register__.ts
10
- ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":1783819645340,\"packageName\":\"@happyvertical/smrt-chat\",\"packageVersion\":\"0.39.4\",\"objects\":{\"@happyvertical/smrt-chat:AgentSessionCollection\":{\"name\":\"agentsessioncollection\",\"className\":\"AgentSessionCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:AgentSessionCollection\",\"collection\":\"agentsessions\",\"filePath\":\"/home/runner/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/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:VoiceGatewayTurnCollection\":{\"name\":\"voicegatewayturncollection\",\"className\":\"VoiceGatewayTurnCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:VoiceGatewayTurnCollection\",\"collection\":\"voicegatewayturns\",\"filePath\":\"/home/runner/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/smrt/smrt/packages/chat/src/collections/VoiceGatewayTurnCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"reserveTurn\":{\"name\":\"reserveTurn\",\"async\":true,\"parameters\":[{\"name\":\"input\",\"type\":\"object\",\"optional\":false}],\"returnType\":\"Promise<VoiceGatewayTurn>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"voice_gateway_turns\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"VoiceGatewayTurn\",\"exportName\":\"VoiceGatewayTurnCollection\",\"collectionExportName\":\"VoiceGatewayTurnCollectionCollection\",\"schema\":{\"tableName\":\"voice_gateway_turns\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"voice_gateway_turns\\\" (\\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\":\"voice_gateway_turns_id_idx\",\"columns\":[\"id\"]},{\"name\":\"voice_gateway_turns_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"b0808d94\"}},\"@happyvertical/smrt-chat:VoiceSessionCollection\":{\"name\":\"voicesessioncollection\",\"className\":\"VoiceSessionCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:VoiceSessionCollection\",\"collection\":\"voicesessions\",\"filePath\":\"/home/runner/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/smrt/smrt/packages/chat/src/collections/VoiceSessionCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"getActiveById\":{\"name\":\"getActiveById\",\"async\":true,\"parameters\":[{\"name\":\"id\",\"type\":\"string\",\"optional\":false},{\"name\":\"target\",\"type\":\"any\",\"optional\":true,\"default\":\"smrt:chat\"}],\"returnType\":\"Promise<VoiceSession | null>\",\"isStatic\":false,\"isPublic\":true},\"expireStale\":{\"name\":\"expireStale\",\"async\":true,\"parameters\":[{\"name\":\"olderThan\",\"type\":\"Date\",\"optional\":true},{\"name\":\"scope\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"voice_sessions\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"VoiceSession\",\"exportName\":\"VoiceSessionCollection\",\"collectionExportName\":\"VoiceSessionCollectionCollection\",\"schema\":{\"tableName\":\"voice_sessions\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"voice_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\":\"voice_sessions_id_idx\",\"columns\":[\"id\"]},{\"name\":\"voice_sessions_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"d9f462ed\"}},\"@happyvertical/smrt-chat:AgentSession\":{\"name\":\"agentsession\",\"className\":\"AgentSession\",\"qualifiedName\":\"@happyvertical/smrt-chat:AgentSession\",\"collection\":\"agentsessions\",\"filePath\":\"/home/runner/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/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\"}},\"@happyvertical/smrt-chat:VoiceGatewayTurn\":{\"name\":\"voicegatewayturn\",\"className\":\"VoiceGatewayTurn\",\"qualifiedName\":\"@happyvertical/smrt-chat:VoiceGatewayTurn\",\"collection\":\"voicegatewayturns\",\"filePath\":\"/home/runner/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/smrt/smrt/packages/chat/src/models/VoiceGatewayTurn.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}}},\"voiceSessionId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"VoiceSession\",\"_meta\":{\"required\":true}},\"gatewaySessionId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"gatewayTurnId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"target\":{\"type\":\"text\",\"required\":true,\"default\":\"smrt:chat\",\"_meta\":{\"required\":true}},\"status\":{\"type\":\"text\",\"required\":true,\"default\":\"processing\",\"_meta\":{\"required\":true}},\"completedAt\":{\"type\":\"datetime\",\"required\":false},\"failedAt\":{\"type\":\"datetime\",\"required\":false}},\"methods\":{\"complete\":{\"name\":\"complete\",\"async\":true,\"parameters\":[{\"name\":\"now\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"fail\":{\"name\":\"fail\",\"async\":true,\"parameters\":[{\"name\":\"now\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"voice_gateway_turns\",\"conflictColumns\":[\"voice_session_id\",\"gateway_turn_id\"],\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":false,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"VoiceGatewayTurn\",\"collectionExportName\":\"VoiceGatewayTurnCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"voiceSessionId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"},{\"field\":\"gatewaySessionId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"gatewayTurnId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"target\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"status\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"voice_gateway_turns\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"voice_gateway_turns\\\" (\\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 \\\"voice_session_id\\\" UUID NOT NULL,\\n \\\"gateway_session_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"gateway_turn_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"target\\\" TEXT NOT NULL DEFAULT 'smrt:chat',\\n \\\"status\\\" TEXT NOT NULL DEFAULT 'processing',\\n \\\"completed_at\\\" TIMESTAMP,\\n \\\"failed_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},\"voice_session_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false},\"gateway_session_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"gateway_turn_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"target\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"smrt:chat\"},\"status\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"processing\"},\"completed_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"failed_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"voice_gateway_turns_id_idx\",\"columns\":[\"id\"]},{\"name\":\"voice_gateway_turns_voice_session_id_gateway_turn_id_idx\",\"columns\":[\"voice_session_id\",\"gateway_turn_id\"],\"unique\":true}],\"version\":\"45e2867c\"}},\"@happyvertical/smrt-chat:VoiceSession\":{\"name\":\"voicesession\",\"className\":\"VoiceSession\",\"qualifiedName\":\"@happyvertical/smrt-chat:VoiceSession\",\"collection\":\"voicesessions\",\"filePath\":\"/home/runner/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-b6zmd/smrt/smrt/packages/chat/src/models/VoiceSession.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}}},\"gatewaySessionId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"actorProfileId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-profiles:Profile\"},\"actorUserId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-users:User\",\"_meta\":{\"nullable\":true}},\"personaId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-personas:AgentPersona\"},\"agentSessionId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"AgentSession\",\"_meta\":{\"required\":true}},\"chatRoomId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"ChatRoom\",\"_meta\":{\"required\":true}},\"threadId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"ChatThread\"},\"target\":{\"type\":\"text\",\"required\":true,\"default\":\"smrt:chat\",\"_meta\":{\"required\":true}},\"status\":{\"type\":\"text\",\"required\":true,\"default\":\"active\",\"_meta\":{\"required\":true}},\"expiresAt\":{\"type\":\"datetime\",\"required\":true,\"_meta\":{\"required\":true}},\"lastTurnAt\":{\"type\":\"datetime\",\"required\":false},\"lastGatewayTurnId\":{\"type\":\"text\",\"required\":false},\"personaSnapshot\":{\"type\":\"text\",\"required\":false,\"default\":\"{}\"},\"metadata\":{\"type\":\"text\",\"required\":false,\"default\":\"{}\"},\"processedTurnIds\":{\"type\":\"text\",\"required\":false,\"default\":\"[]\"}},\"methods\":{\"isActive\":{\"name\":\"isActive\",\"async\":false,\"parameters\":[{\"name\":\"now\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isExpired\":{\"name\":\"isExpired\",\"async\":false,\"parameters\":[{\"name\":\"now\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"expire\":{\"name\":\"expire\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"revoke\":{\"name\":\"revoke\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"getPersonaSnapshot\":{\"name\":\"getPersonaSnapshot\",\"async\":false,\"parameters\":[],\"returnType\":\"ConversationPersona\",\"isStatic\":false,\"isPublic\":true},\"setPersonaSnapshot\":{\"name\":\"setPersonaSnapshot\",\"async\":false,\"parameters\":[{\"name\":\"persona\",\"type\":\"ConversationPersona\",\"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\":\"metadata\",\"type\":\"Record<string>\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"getProcessedTurnIds\":{\"name\":\"getProcessedTurnIds\",\"async\":false,\"parameters\":[],\"returnType\":\"string[]\",\"isStatic\":false,\"isPublic\":true},\"hasProcessedTurn\":{\"name\":\"hasProcessedTurn\",\"async\":false,\"parameters\":[{\"name\":\"turnId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"recordGatewayTurn\":{\"name\":\"recordGatewayTurn\",\"async\":false,\"parameters\":[{\"name\":\"turnId\",\"type\":\"string\",\"optional\":false},{\"name\":\"maxRememberedTurns\",\"type\":\"any\",\"optional\":true}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"voice_sessions\",\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"VoiceSession\",\"collectionExportName\":\"VoiceSessionCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"gatewaySessionId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"actorProfileId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"},{\"field\":\"personaId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"},{\"field\":\"agentSessionId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"},{\"field\":\"chatRoomId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"},{\"field\":\"target\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"status\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"expiresAt\",\"rule\":\"required\",\"fieldType\":\"datetime\"}],\"schema\":{\"tableName\":\"voice_sessions\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"voice_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 NOT NULL,\\n \\\"gateway_session_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"actor_profile_id\\\" UUID NOT NULL,\\n \\\"actor_user_id\\\" UUID,\\n \\\"persona_id\\\" UUID NOT NULL,\\n \\\"agent_session_id\\\" UUID NOT NULL,\\n \\\"chat_room_id\\\" UUID NOT NULL,\\n \\\"thread_id\\\" UUID,\\n \\\"target\\\" TEXT NOT NULL DEFAULT 'smrt:chat',\\n \\\"status\\\" TEXT NOT NULL DEFAULT 'active',\\n \\\"expires_at\\\" TIMESTAMP NOT NULL,\\n \\\"last_turn_at\\\" TIMESTAMP,\\n \\\"last_gateway_turn_id\\\" TEXT,\\n \\\"persona_snapshot\\\" TEXT DEFAULT '{}',\\n \\\"metadata\\\" TEXT DEFAULT '{}',\\n \\\"processed_turn_ids\\\" 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},\"gateway_session_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"actor_profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"actor_user_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":false,\"unique\":false},\"persona_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"agent_session_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false},\"chat_room_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false},\"thread_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"target\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"smrt:chat\"},\"status\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"active\"},\"expires_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"unique\":false},\"last_turn_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"last_gateway_turn_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"persona_snapshot\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"{}\"},\"metadata\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"{}\"},\"processed_turn_ids\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"[]\"}},\"indexes\":[{\"name\":\"voice_sessions_id_idx\",\"columns\":[\"id\"]},{\"name\":\"voice_sessions_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"348c29ef\"}}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-agents\",\"@happyvertical/smrt-core\",\"@happyvertical/smrt-personas\",\"@happyvertical/smrt-profiles\",\"@happyvertical/smrt-tenancy\",\"@happyvertical/smrt-users\"]}"));
10
+ ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":1783845616112,\"packageName\":\"@happyvertical/smrt-chat\",\"packageVersion\":\"0.39.6\",\"objects\":{\"@happyvertical/smrt-chat:AgentSessionCollection\":{\"name\":\"agentsessioncollection\",\"className\":\"AgentSessionCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:AgentSessionCollection\",\"collection\":\"agentsessions\",\"filePath\":\"/home/runner/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/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:VoiceGatewayTurnCollection\":{\"name\":\"voicegatewayturncollection\",\"className\":\"VoiceGatewayTurnCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:VoiceGatewayTurnCollection\",\"collection\":\"voicegatewayturns\",\"filePath\":\"/home/runner/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/smrt/smrt/packages/chat/src/collections/VoiceGatewayTurnCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"reserveTurn\":{\"name\":\"reserveTurn\",\"async\":true,\"parameters\":[{\"name\":\"input\",\"type\":\"object\",\"optional\":false}],\"returnType\":\"Promise<VoiceGatewayTurn>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"voice_gateway_turns\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"VoiceGatewayTurn\",\"exportName\":\"VoiceGatewayTurnCollection\",\"collectionExportName\":\"VoiceGatewayTurnCollectionCollection\",\"schema\":{\"tableName\":\"voice_gateway_turns\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"voice_gateway_turns\\\" (\\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\":\"voice_gateway_turns_id_idx\",\"columns\":[\"id\"]},{\"name\":\"voice_gateway_turns_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"b0808d94\"}},\"@happyvertical/smrt-chat:VoiceSessionCollection\":{\"name\":\"voicesessioncollection\",\"className\":\"VoiceSessionCollection\",\"qualifiedName\":\"@happyvertical/smrt-chat:VoiceSessionCollection\",\"collection\":\"voicesessions\",\"filePath\":\"/home/runner/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/smrt/smrt/packages/chat/src/collections/VoiceSessionCollection.ts\",\"packageName\":\"@happyvertical/smrt-chat\",\"fields\":{},\"methods\":{\"getActiveById\":{\"name\":\"getActiveById\",\"async\":true,\"parameters\":[{\"name\":\"id\",\"type\":\"string\",\"optional\":false},{\"name\":\"target\",\"type\":\"any\",\"optional\":true,\"default\":\"smrt:chat\"}],\"returnType\":\"Promise<VoiceSession | null>\",\"isStatic\":false,\"isPublic\":true},\"expireStale\":{\"name\":\"expireStale\",\"async\":true,\"parameters\":[{\"name\":\"olderThan\",\"type\":\"Date\",\"optional\":true},{\"name\":\"scope\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"voice_sessions\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"VoiceSession\",\"exportName\":\"VoiceSessionCollection\",\"collectionExportName\":\"VoiceSessionCollectionCollection\",\"schema\":{\"tableName\":\"voice_sessions\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"voice_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\":\"voice_sessions_id_idx\",\"columns\":[\"id\"]},{\"name\":\"voice_sessions_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"d9f462ed\"}},\"@happyvertical/smrt-chat:AgentSession\":{\"name\":\"agentsession\",\"className\":\"AgentSession\",\"qualifiedName\":\"@happyvertical/smrt-chat:AgentSession\",\"collection\":\"agentsessions\",\"filePath\":\"/home/runner/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/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/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/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\"}},\"@happyvertical/smrt-chat:VoiceGatewayTurn\":{\"name\":\"voicegatewayturn\",\"className\":\"VoiceGatewayTurn\",\"qualifiedName\":\"@happyvertical/smrt-chat:VoiceGatewayTurn\",\"collection\":\"voicegatewayturns\",\"filePath\":\"/home/runner/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/smrt/smrt/packages/chat/src/models/VoiceGatewayTurn.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}}},\"voiceSessionId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"VoiceSession\",\"_meta\":{\"required\":true}},\"gatewaySessionId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"gatewayTurnId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"target\":{\"type\":\"text\",\"required\":true,\"default\":\"smrt:chat\",\"_meta\":{\"required\":true}},\"status\":{\"type\":\"text\",\"required\":true,\"default\":\"processing\",\"_meta\":{\"required\":true}},\"completedAt\":{\"type\":\"datetime\",\"required\":false},\"failedAt\":{\"type\":\"datetime\",\"required\":false}},\"methods\":{\"complete\":{\"name\":\"complete\",\"async\":true,\"parameters\":[{\"name\":\"now\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"fail\":{\"name\":\"fail\",\"async\":true,\"parameters\":[{\"name\":\"now\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"voice_gateway_turns\",\"conflictColumns\":[\"voice_session_id\",\"gateway_turn_id\"],\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":false,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"VoiceGatewayTurn\",\"collectionExportName\":\"VoiceGatewayTurnCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"voiceSessionId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"},{\"field\":\"gatewaySessionId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"gatewayTurnId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"target\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"status\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"voice_gateway_turns\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"voice_gateway_turns\\\" (\\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 \\\"voice_session_id\\\" UUID NOT NULL,\\n \\\"gateway_session_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"gateway_turn_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"target\\\" TEXT NOT NULL DEFAULT 'smrt:chat',\\n \\\"status\\\" TEXT NOT NULL DEFAULT 'processing',\\n \\\"completed_at\\\" TIMESTAMP,\\n \\\"failed_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},\"voice_session_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false},\"gateway_session_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"gateway_turn_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"target\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"smrt:chat\"},\"status\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"processing\"},\"completed_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"failed_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"voice_gateway_turns_id_idx\",\"columns\":[\"id\"]},{\"name\":\"voice_gateway_turns_voice_session_id_gateway_turn_id_idx\",\"columns\":[\"voice_session_id\",\"gateway_turn_id\"],\"unique\":true}],\"version\":\"45e2867c\"}},\"@happyvertical/smrt-chat:VoiceSession\":{\"name\":\"voicesession\",\"className\":\"VoiceSession\",\"qualifiedName\":\"@happyvertical/smrt-chat:VoiceSession\",\"collection\":\"voicesessions\",\"filePath\":\"/home/runner/.local/share/pnpm/store/.workspaces/arc-happyvertical-node-phdrb-runner-xv52x/smrt/smrt/packages/chat/src/models/VoiceSession.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}}},\"gatewaySessionId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"actorProfileId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-profiles:Profile\"},\"actorUserId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-users:User\",\"_meta\":{\"nullable\":true}},\"personaId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-personas:AgentPersona\"},\"agentSessionId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"AgentSession\",\"_meta\":{\"required\":true}},\"chatRoomId\":{\"type\":\"foreignKey\",\"required\":true,\"related\":\"ChatRoom\",\"_meta\":{\"required\":true}},\"threadId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"ChatThread\"},\"target\":{\"type\":\"text\",\"required\":true,\"default\":\"smrt:chat\",\"_meta\":{\"required\":true}},\"status\":{\"type\":\"text\",\"required\":true,\"default\":\"active\",\"_meta\":{\"required\":true}},\"expiresAt\":{\"type\":\"datetime\",\"required\":true,\"_meta\":{\"required\":true}},\"lastTurnAt\":{\"type\":\"datetime\",\"required\":false},\"lastGatewayTurnId\":{\"type\":\"text\",\"required\":false},\"personaSnapshot\":{\"type\":\"text\",\"required\":false,\"default\":\"{}\"},\"metadata\":{\"type\":\"text\",\"required\":false,\"default\":\"{}\"},\"processedTurnIds\":{\"type\":\"text\",\"required\":false,\"default\":\"[]\"}},\"methods\":{\"isActive\":{\"name\":\"isActive\",\"async\":false,\"parameters\":[{\"name\":\"now\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isExpired\":{\"name\":\"isExpired\",\"async\":false,\"parameters\":[{\"name\":\"now\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"expire\":{\"name\":\"expire\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"revoke\":{\"name\":\"revoke\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"getPersonaSnapshot\":{\"name\":\"getPersonaSnapshot\",\"async\":false,\"parameters\":[],\"returnType\":\"ConversationPersona\",\"isStatic\":false,\"isPublic\":true},\"setPersonaSnapshot\":{\"name\":\"setPersonaSnapshot\",\"async\":false,\"parameters\":[{\"name\":\"persona\",\"type\":\"ConversationPersona\",\"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\":\"metadata\",\"type\":\"Record<string>\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"getProcessedTurnIds\":{\"name\":\"getProcessedTurnIds\",\"async\":false,\"parameters\":[],\"returnType\":\"string[]\",\"isStatic\":false,\"isPublic\":true},\"hasProcessedTurn\":{\"name\":\"hasProcessedTurn\",\"async\":false,\"parameters\":[{\"name\":\"turnId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"recordGatewayTurn\":{\"name\":\"recordGatewayTurn\",\"async\":false,\"parameters\":[{\"name\":\"turnId\",\"type\":\"string\",\"optional\":false},{\"name\":\"maxRememberedTurns\",\"type\":\"any\",\"optional\":true}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"voice_sessions\",\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"VoiceSession\",\"collectionExportName\":\"VoiceSessionCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"gatewaySessionId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"actorProfileId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"},{\"field\":\"personaId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"},{\"field\":\"agentSessionId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"},{\"field\":\"chatRoomId\",\"rule\":\"required\",\"fieldType\":\"foreignKey\"},{\"field\":\"target\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"status\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"expiresAt\",\"rule\":\"required\",\"fieldType\":\"datetime\"}],\"schema\":{\"tableName\":\"voice_sessions\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"voice_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 NOT NULL,\\n \\\"gateway_session_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"actor_profile_id\\\" UUID NOT NULL,\\n \\\"actor_user_id\\\" UUID,\\n \\\"persona_id\\\" UUID NOT NULL,\\n \\\"agent_session_id\\\" UUID NOT NULL,\\n \\\"chat_room_id\\\" UUID NOT NULL,\\n \\\"thread_id\\\" UUID,\\n \\\"target\\\" TEXT NOT NULL DEFAULT 'smrt:chat',\\n \\\"status\\\" TEXT NOT NULL DEFAULT 'active',\\n \\\"expires_at\\\" TIMESTAMP NOT NULL,\\n \\\"last_turn_at\\\" TIMESTAMP,\\n \\\"last_gateway_turn_id\\\" TEXT,\\n \\\"persona_snapshot\\\" TEXT DEFAULT '{}',\\n \\\"metadata\\\" TEXT DEFAULT '{}',\\n \\\"processed_turn_ids\\\" 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},\"gateway_session_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"actor_profile_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"actor_user_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":false,\"unique\":false},\"persona_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"agent_session_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false},\"chat_room_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":true,\"unique\":false},\"thread_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"target\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"smrt:chat\"},\"status\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"active\"},\"expires_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"unique\":false},\"last_turn_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"last_gateway_turn_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"persona_snapshot\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"{}\"},\"metadata\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"{}\"},\"processed_turn_ids\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"[]\"}},\"indexes\":[{\"name\":\"voice_sessions_id_idx\",\"columns\":[\"id\"]},{\"name\":\"voice_sessions_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"348c29ef\"}}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-agents\",\"@happyvertical/smrt-core\",\"@happyvertical/smrt-personas\",\"@happyvertical/smrt-profiles\",\"@happyvertical/smrt-tenancy\",\"@happyvertical/smrt-users\"]}"));
11
11
  //#endregion
12
12
  //#region src/chat-feedback.ts
13
13
  async function captureChatFeedback(options) {
@@ -87,63 +87,6 @@ function thumbsDown(options) {
87
87
  });
88
88
  }
89
89
  //#endregion
90
- //#region src/models/VoiceGatewayTurn.ts
91
- var __defProp = Object.defineProperty;
92
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
93
- var __decorateClass = (decorators, target, key, kind) => {
94
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
95
- for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
96
- if (kind && result) __defProp(target, key, result);
97
- return result;
98
- };
99
- var VoiceGatewayTurn = class extends SmrtObject {
100
- tenantId = "";
101
- voiceSessionId = "";
102
- gatewaySessionId = "";
103
- gatewayTurnId = "";
104
- target = "smrt:chat";
105
- status = "processing";
106
- completedAt = null;
107
- failedAt = null;
108
- constructor(options = {}) {
109
- super(options);
110
- if (options.tenantId !== void 0) this.tenantId = options.tenantId;
111
- if (options.voiceSessionId !== void 0) this.voiceSessionId = options.voiceSessionId;
112
- if (options.gatewaySessionId !== void 0) this.gatewaySessionId = options.gatewaySessionId;
113
- if (options.gatewayTurnId !== void 0) this.gatewayTurnId = options.gatewayTurnId;
114
- if (options.target !== void 0) this.target = options.target;
115
- if (options.status !== void 0) this.status = options.status;
116
- if (options.completedAt !== void 0) this.completedAt = options.completedAt;
117
- if (options.failedAt !== void 0) this.failedAt = options.failedAt;
118
- }
119
- async complete(now = /* @__PURE__ */ new Date()) {
120
- this.status = "completed";
121
- this.completedAt = now;
122
- this.failedAt = null;
123
- await this.save();
124
- }
125
- async fail(now = /* @__PURE__ */ new Date()) {
126
- this.status = "failed";
127
- this.failedAt = now;
128
- await this.save();
129
- }
130
- };
131
- __decorateClass([tenantId()], VoiceGatewayTurn.prototype, "tenantId", 2);
132
- __decorateClass([foreignKey("VoiceSession", { required: true })], VoiceGatewayTurn.prototype, "voiceSessionId", 2);
133
- __decorateClass([field({ required: true })], VoiceGatewayTurn.prototype, "gatewaySessionId", 2);
134
- __decorateClass([field({ required: true })], VoiceGatewayTurn.prototype, "gatewayTurnId", 2);
135
- __decorateClass([field({ required: true })], VoiceGatewayTurn.prototype, "target", 2);
136
- __decorateClass([field({ required: true })], VoiceGatewayTurn.prototype, "status", 2);
137
- __decorateClass([field()], VoiceGatewayTurn.prototype, "completedAt", 2);
138
- __decorateClass([field()], VoiceGatewayTurn.prototype, "failedAt", 2);
139
- VoiceGatewayTurn = __decorateClass([TenantScoped({ mode: "required" }), smrt({
140
- tableName: "voice_gateway_turns",
141
- conflictColumns: ["voice_session_id", "gateway_turn_id"],
142
- api: { include: ["list", "get"] },
143
- mcp: { include: ["list", "get"] },
144
- cli: false
145
- })], VoiceGatewayTurn);
146
- //#endregion
147
90
  //#region src/tool-loop.ts
148
91
  var DEFAULT_MAX_STEPS = 8;
149
92
  function asRecord(value) {
@@ -307,7 +250,7 @@ async function invokeManifestTool(run, tool, args, options = {}) {
307
250
  }
308
251
  }
309
252
  async function runToolLoop(options) {
310
- const { ai, messages, tools, extraTools = [], principal, db, maxSteps = 8, model, temperature, maxTokens, toolChoice = "auto", executeTool, onInvocation, onBehalfOfUserId, agentClass, audit, postgresRls } = options;
253
+ const { ai, messages, tools, extraTools = [], principal, db, maxSteps = 8, model, temperature, maxTokens, toolChoice = "auto", executeTool, onInvocation, onToken, onBehalfOfUserId, agentClass, audit, postgresRls } = options;
311
254
  const aiTools = [...tools.map(manifestToolToAITool), ...extraTools.map((tool) => tool.aiTool)];
312
255
  const offered = /* @__PURE__ */ new Map();
313
256
  for (const tool of tools) {
@@ -340,7 +283,11 @@ async function runToolLoop(options) {
340
283
  temperature,
341
284
  maxTokens,
342
285
  tools: offerTools ? aiTools : void 0,
343
- toolChoice: offerTools ? toolChoice : "none"
286
+ toolChoice: offerTools ? toolChoice : "none",
287
+ ...onToken ? {
288
+ stream: true,
289
+ onProgress: onToken
290
+ } : {}
344
291
  });
345
292
  totalTokens += response.usage?.totalTokens ?? 0;
346
293
  const toolCalls = offerTools ? response.toolCalls ?? [] : [];
@@ -522,7 +469,8 @@ async function runPersonaConversationTurn(options) {
522
469
  onBehalfOfUserId: options.onBehalfOfUserId,
523
470
  agentClass: persona.agentClass,
524
471
  postgresRls: options.postgresRls,
525
- audit: options.audit
472
+ audit: options.audit,
473
+ onToken: options.onToken
526
474
  });
527
475
  let authoredMessages;
528
476
  if (options.chatService && options.session?.id) authoredMessages = await authorConversationReply({
@@ -581,6 +529,420 @@ async function authorConversationReply(input) {
581
529
  };
582
530
  }
583
531
  //#endregion
532
+ //#region src/chat-stream.ts
533
+ var MAX_CHAT_STREAM_MESSAGES = 50;
534
+ var MAX_CHAT_STREAM_CONTENT_LENGTH = 12e3;
535
+ var DEFAULT_CHAT_STREAM_HEARTBEAT_MS = 15e3;
536
+ var ChatStreamError = class extends Error {
537
+ status;
538
+ code;
539
+ constructor(message, status, code) {
540
+ super(message);
541
+ this.name = "ChatStreamError";
542
+ this.status = status;
543
+ this.code = code;
544
+ }
545
+ };
546
+ var ChatStreamBadRequestError = class extends ChatStreamError {
547
+ constructor(message = "Invalid chat stream request") {
548
+ super(message, 400, "chat_stream_bad_request");
549
+ this.name = "ChatStreamBadRequestError";
550
+ }
551
+ };
552
+ var ChatStreamUnauthorizedError = class extends ChatStreamError {
553
+ constructor(message = "Unauthorized") {
554
+ super(message, 401, "chat_stream_unauthorized");
555
+ this.name = "ChatStreamUnauthorizedError";
556
+ }
557
+ };
558
+ async function* runChatConversationStream(options) {
559
+ const { context } = options;
560
+ const { history, userMessage } = splitConversation(normalizeMessages(options.messages));
561
+ if (!userMessage) {
562
+ yield {
563
+ type: "error",
564
+ error: "No user message to respond to"
565
+ };
566
+ return;
567
+ }
568
+ if (context.binding) yield* streamPersonaConversation(context, context.binding, history, userMessage);
569
+ else yield* streamPlainConversation(context, history, userMessage);
570
+ }
571
+ async function* streamPersonaConversation(context, binding, history, userMessage) {
572
+ const queue = [];
573
+ let notify = null;
574
+ let finished = false;
575
+ const wake = () => {
576
+ const resume = notify;
577
+ notify = null;
578
+ resume?.();
579
+ };
580
+ const emit = (event) => {
581
+ queue.push(event);
582
+ wake();
583
+ };
584
+ const turnPromise = (async () => {
585
+ try {
586
+ const turn = await runPersonaConversationTurn({
587
+ ai: context.ai,
588
+ db: binding.db,
589
+ persona: binding.persona,
590
+ tenantId: binding.tenantId,
591
+ userMessage,
592
+ history,
593
+ chatService: binding.chatService,
594
+ session: binding.session,
595
+ threadId: binding.threadId,
596
+ recall: binding.recall,
597
+ model: context.model,
598
+ temperature: context.temperature,
599
+ maxTokens: context.maxTokens,
600
+ maxSteps: context.maxSteps,
601
+ onBehalfOfUserId: binding.onBehalfOfUserId,
602
+ audit: binding.audit,
603
+ postgresRls: binding.postgresRls,
604
+ onToken: (chunk) => {
605
+ if (chunk) emit({
606
+ type: "token",
607
+ text: chunk
608
+ });
609
+ }
610
+ });
611
+ emit({
612
+ type: "done",
613
+ message: resolvePersonaDoneMessage(turn)
614
+ });
615
+ } catch (error) {
616
+ emit({
617
+ type: "error",
618
+ error: toErrorMessage(error)
619
+ });
620
+ } finally {
621
+ finished = true;
622
+ wake();
623
+ }
624
+ })();
625
+ try {
626
+ for (;;) {
627
+ if (queue.length > 0) {
628
+ yield queue.shift();
629
+ continue;
630
+ }
631
+ if (finished) break;
632
+ await new Promise((resolve) => {
633
+ notify = resolve;
634
+ });
635
+ }
636
+ } finally {
637
+ await turnPromise;
638
+ }
639
+ }
640
+ async function* streamPlainConversation(context, history, userMessage) {
641
+ const messages = [];
642
+ if (context.systemPrompt) messages.push({
643
+ role: "system",
644
+ content: context.systemPrompt
645
+ });
646
+ messages.push(...history, {
647
+ role: "user",
648
+ content: userMessage
649
+ });
650
+ let content = "";
651
+ try {
652
+ for await (const chunk of context.ai.stream(messages, {
653
+ model: context.model,
654
+ temperature: context.temperature,
655
+ maxTokens: context.maxTokens
656
+ })) if (chunk) {
657
+ content += chunk;
658
+ yield {
659
+ type: "token",
660
+ text: chunk
661
+ };
662
+ }
663
+ } catch (error) {
664
+ yield {
665
+ type: "error",
666
+ error: toErrorMessage(error)
667
+ };
668
+ return;
669
+ }
670
+ yield {
671
+ type: "done",
672
+ message: synthesizeAssistantMessage(content)
673
+ };
674
+ }
675
+ function createChatStreamHandler(options) {
676
+ const allowedOrigins = normalizeAllowedOrigins(options.allowedOrigins);
677
+ const allowCredentials = options.allowCredentials === true;
678
+ const cors = (request) => corsHeaders(request, allowedOrigins, allowCredentials);
679
+ return async (request) => {
680
+ if (request.method === "OPTIONS") {
681
+ const headers = cors(request);
682
+ if (!("Access-Control-Allow-Origin" in headers)) return new Response(null, { status: 403 });
683
+ return new Response(null, {
684
+ status: 204,
685
+ headers: {
686
+ ...headers,
687
+ "Access-Control-Allow-Methods": "POST,OPTIONS",
688
+ "Access-Control-Allow-Headers": "Authorization,Content-Type",
689
+ "Access-Control-Max-Age": "86400"
690
+ }
691
+ });
692
+ }
693
+ if (request.method !== "POST") return jsonResponse$1({
694
+ error: "Method not allowed",
695
+ code: "method_not_allowed"
696
+ }, 405, cors(request));
697
+ let body;
698
+ try {
699
+ body = await request.json();
700
+ } catch {
701
+ return jsonResponse$1({
702
+ error: "Request body must be JSON",
703
+ code: "chat_stream_bad_request"
704
+ }, 400, cors(request));
705
+ }
706
+ if (!body || typeof body !== "object") return jsonResponse$1({
707
+ error: "Request body must be an object",
708
+ code: "chat_stream_bad_request"
709
+ }, 400, cors(request));
710
+ let context;
711
+ try {
712
+ context = await options.authorize(request, body);
713
+ } catch (error) {
714
+ const status = error instanceof ChatStreamError ? error.status : 500;
715
+ const code = error instanceof ChatStreamError ? error.code : "chat_stream_error";
716
+ return jsonResponse$1({
717
+ error: toErrorMessage(error),
718
+ code
719
+ }, status, cors(request));
720
+ }
721
+ const messages = Array.isArray(body.messages) ? body.messages : [];
722
+ const events = runChatConversationStream({
723
+ context,
724
+ messages
725
+ });
726
+ return new Response(sseBody(events, options.heartbeatMs), {
727
+ status: 200,
728
+ headers: {
729
+ ...cors(request),
730
+ "Content-Type": "text/event-stream",
731
+ "Cache-Control": "no-cache, no-transform",
732
+ Connection: "keep-alive",
733
+ "X-Accel-Buffering": "no"
734
+ }
735
+ });
736
+ };
737
+ }
738
+ var encoder = new TextEncoder();
739
+ function encodeChatStreamEvent(event) {
740
+ return `data: ${JSON.stringify(event)}
741
+
742
+ `;
743
+ }
744
+ var HEARTBEAT_FRAME = encoder.encode(": heartbeat\n\n");
745
+ function sseBody(events, heartbeatMs = DEFAULT_CHAT_STREAM_HEARTBEAT_MS) {
746
+ let heartbeat = null;
747
+ let closed = false;
748
+ const stopHeartbeat = () => {
749
+ if (heartbeat) {
750
+ clearInterval(heartbeat);
751
+ heartbeat = null;
752
+ }
753
+ };
754
+ return new ReadableStream({
755
+ start(controller) {
756
+ if (!Number.isFinite(heartbeatMs) || heartbeatMs <= 0) return;
757
+ heartbeat = setInterval(() => {
758
+ if (closed) return;
759
+ try {
760
+ controller.enqueue(HEARTBEAT_FRAME);
761
+ } catch {
762
+ closed = true;
763
+ stopHeartbeat();
764
+ }
765
+ }, heartbeatMs);
766
+ heartbeat.unref?.();
767
+ },
768
+ async pull(controller) {
769
+ try {
770
+ const { value, done } = await events.next();
771
+ if (done) {
772
+ closed = true;
773
+ stopHeartbeat();
774
+ controller.close();
775
+ return;
776
+ }
777
+ controller.enqueue(encoder.encode(encodeChatStreamEvent(value)));
778
+ } catch (error) {
779
+ closed = true;
780
+ stopHeartbeat();
781
+ controller.enqueue(encoder.encode(encodeChatStreamEvent({
782
+ type: "error",
783
+ error: toErrorMessage(error)
784
+ })));
785
+ controller.close();
786
+ }
787
+ },
788
+ async cancel() {
789
+ closed = true;
790
+ stopHeartbeat();
791
+ await events.return?.(void 0);
792
+ }
793
+ });
794
+ }
795
+ function normalizeMessages(messages) {
796
+ if (!Array.isArray(messages)) return [];
797
+ const out = [];
798
+ for (const message of messages.slice(-50)) {
799
+ const role = message?.role;
800
+ if (role !== "user" && role !== "assistant" && role !== "system") continue;
801
+ const content = typeof message.content === "string" ? message.content.trim() : "";
802
+ if (!content) continue;
803
+ out.push({
804
+ ...typeof message.id === "string" ? { id: message.id } : {},
805
+ role,
806
+ content: content.slice(0, MAX_CHAT_STREAM_CONTENT_LENGTH),
807
+ ...typeof message.createdAt === "string" ? { createdAt: message.createdAt } : {}
808
+ });
809
+ }
810
+ return out;
811
+ }
812
+ function splitConversation(messages) {
813
+ let lastUserIndex = -1;
814
+ for (let i = messages.length - 1; i >= 0; i -= 1) if (messages[i].role === "user") {
815
+ lastUserIndex = i;
816
+ break;
817
+ }
818
+ if (lastUserIndex === -1) return {
819
+ history: [],
820
+ userMessage: ""
821
+ };
822
+ return {
823
+ history: messages.slice(0, lastUserIndex).map((message) => ({
824
+ role: message.role,
825
+ content: message.content
826
+ })),
827
+ userMessage: messages[lastUserIndex].content
828
+ };
829
+ }
830
+ function resolvePersonaDoneMessage(turn) {
831
+ const persisted = turn.authoredMessages?.assistantMessage;
832
+ if (persisted) return toStreamMessage(persisted);
833
+ return synthesizeAssistantMessage(turn.result.content);
834
+ }
835
+ function toWireRole(role) {
836
+ return role === "user" || role === "system" ? role : "assistant";
837
+ }
838
+ function toStreamMessage(message) {
839
+ const createdAt = message.createdAt;
840
+ return {
841
+ id: message.id ?? crypto.randomUUID(),
842
+ role: toWireRole(message.role),
843
+ content: message.content ?? "",
844
+ createdAt: toIsoString(createdAt)
845
+ };
846
+ }
847
+ function synthesizeAssistantMessage(content) {
848
+ return {
849
+ id: crypto.randomUUID(),
850
+ role: "assistant",
851
+ content,
852
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
853
+ };
854
+ }
855
+ function toIsoString(value) {
856
+ if (value instanceof Date) return value.toISOString();
857
+ if (typeof value === "string" && value) return value;
858
+ return (/* @__PURE__ */ new Date()).toISOString();
859
+ }
860
+ function toErrorMessage(error) {
861
+ return error instanceof Error ? error.message : String(error);
862
+ }
863
+ function jsonResponse$1(body, status, extraHeaders = {}) {
864
+ return new Response(JSON.stringify(body), {
865
+ status,
866
+ headers: {
867
+ "Content-Type": "application/json",
868
+ ...extraHeaders
869
+ }
870
+ });
871
+ }
872
+ function normalizeAllowedOrigins(origins) {
873
+ if (!Array.isArray(origins)) return void 0;
874
+ const cleaned = [...new Set(origins.filter((o) => typeof o === "string").map((o) => o.trim()).filter((o) => o.length > 0))];
875
+ return cleaned.length > 0 ? cleaned : void 0;
876
+ }
877
+ function corsHeaders(request, allowedOrigins, allowCredentials) {
878
+ if (!allowedOrigins) return {};
879
+ const origin = request.headers.get("origin");
880
+ if (!origin || !allowedOrigins.includes(origin)) return {};
881
+ const headers = {
882
+ "Access-Control-Allow-Origin": origin,
883
+ Vary: "Origin"
884
+ };
885
+ if (allowCredentials) headers["Access-Control-Allow-Credentials"] = "true";
886
+ return headers;
887
+ }
888
+ //#endregion
889
+ //#region src/models/VoiceGatewayTurn.ts
890
+ var __defProp = Object.defineProperty;
891
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
892
+ var __decorateClass = (decorators, target, key, kind) => {
893
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
894
+ for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
895
+ if (kind && result) __defProp(target, key, result);
896
+ return result;
897
+ };
898
+ var VoiceGatewayTurn = class extends SmrtObject {
899
+ tenantId = "";
900
+ voiceSessionId = "";
901
+ gatewaySessionId = "";
902
+ gatewayTurnId = "";
903
+ target = "smrt:chat";
904
+ status = "processing";
905
+ completedAt = null;
906
+ failedAt = null;
907
+ constructor(options = {}) {
908
+ super(options);
909
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
910
+ if (options.voiceSessionId !== void 0) this.voiceSessionId = options.voiceSessionId;
911
+ if (options.gatewaySessionId !== void 0) this.gatewaySessionId = options.gatewaySessionId;
912
+ if (options.gatewayTurnId !== void 0) this.gatewayTurnId = options.gatewayTurnId;
913
+ if (options.target !== void 0) this.target = options.target;
914
+ if (options.status !== void 0) this.status = options.status;
915
+ if (options.completedAt !== void 0) this.completedAt = options.completedAt;
916
+ if (options.failedAt !== void 0) this.failedAt = options.failedAt;
917
+ }
918
+ async complete(now = /* @__PURE__ */ new Date()) {
919
+ this.status = "completed";
920
+ this.completedAt = now;
921
+ this.failedAt = null;
922
+ await this.save();
923
+ }
924
+ async fail(now = /* @__PURE__ */ new Date()) {
925
+ this.status = "failed";
926
+ this.failedAt = now;
927
+ await this.save();
928
+ }
929
+ };
930
+ __decorateClass([tenantId()], VoiceGatewayTurn.prototype, "tenantId", 2);
931
+ __decorateClass([foreignKey("VoiceSession", { required: true })], VoiceGatewayTurn.prototype, "voiceSessionId", 2);
932
+ __decorateClass([field({ required: true })], VoiceGatewayTurn.prototype, "gatewaySessionId", 2);
933
+ __decorateClass([field({ required: true })], VoiceGatewayTurn.prototype, "gatewayTurnId", 2);
934
+ __decorateClass([field({ required: true })], VoiceGatewayTurn.prototype, "target", 2);
935
+ __decorateClass([field({ required: true })], VoiceGatewayTurn.prototype, "status", 2);
936
+ __decorateClass([field()], VoiceGatewayTurn.prototype, "completedAt", 2);
937
+ __decorateClass([field()], VoiceGatewayTurn.prototype, "failedAt", 2);
938
+ VoiceGatewayTurn = __decorateClass([TenantScoped({ mode: "required" }), smrt({
939
+ tableName: "voice_gateway_turns",
940
+ conflictColumns: ["voice_session_id", "gateway_turn_id"],
941
+ api: { include: ["list", "get"] },
942
+ mcp: { include: ["list", "get"] },
943
+ cli: false
944
+ })], VoiceGatewayTurn);
945
+ //#endregion
584
946
  //#region src/collections/VoiceGatewayTurnCollection.ts
585
947
  var VoiceGatewayTurnCollection = class extends SmrtCollection {
586
948
  static _itemClass = VoiceGatewayTurn;
@@ -998,6 +1360,6 @@ function jsonResponse(body, status) {
998
1360
  });
999
1361
  }
1000
1362
  //#endregion
1001
- export { AgentSession, CHAT_MODULE_META, CHAT_UI_SLOTS, ChatMessage, ChatParticipant, ChatReaction, ChatRoom, ChatService, ChatThread, DEFAULT_MAX_STEPS, MAX_VOICE_GATEWAY_TEXT_LENGTH, SMRT_CHAT_VOICE_TARGET, VoiceGatewayBadRequestError, VoiceGatewayError, VoiceGatewayReplayError, VoiceGatewayTurn, VoiceGatewayUnauthorizedError, VoiceSession, VoiceSessionExpiredError, VoiceSessionRejectedError, acceptAppliedChange, assertVoiceGatewayBearer, bindPersonaToSession, buildManifestToolCatalog, captureChatFeedback, conversationPersonaFromAgentPersona, conversationPersonaFromResolved, correctResponse, createVoiceChatSession, createVoiceGatewayTurnHandler, formatRecalledMemory, handleVoiceGatewayTurn, invokeManifestTool, manifestToolToAITool, principalBindingFor, rateResponse, recallPersonaMemory, rejectAppliedChange, resolveConversationInstructions, runPersonaConversationTurn, runToolLoop, thumbsDown, thumbsUp };
1363
+ export { AgentSession, CHAT_MODULE_META, CHAT_UI_SLOTS, ChatMessage, ChatParticipant, ChatReaction, ChatRoom, ChatService, ChatStreamBadRequestError, ChatStreamError, ChatStreamUnauthorizedError, ChatThread, DEFAULT_CHAT_STREAM_HEARTBEAT_MS, DEFAULT_MAX_STEPS, MAX_CHAT_STREAM_CONTENT_LENGTH, MAX_CHAT_STREAM_MESSAGES, MAX_VOICE_GATEWAY_TEXT_LENGTH, SMRT_CHAT_VOICE_TARGET, VoiceGatewayBadRequestError, VoiceGatewayError, VoiceGatewayReplayError, VoiceGatewayTurn, VoiceGatewayUnauthorizedError, VoiceSession, VoiceSessionExpiredError, VoiceSessionRejectedError, acceptAppliedChange, assertVoiceGatewayBearer, bindPersonaToSession, buildManifestToolCatalog, captureChatFeedback, conversationPersonaFromAgentPersona, conversationPersonaFromResolved, correctResponse, createChatStreamHandler, createVoiceChatSession, createVoiceGatewayTurnHandler, encodeChatStreamEvent, formatRecalledMemory, handleVoiceGatewayTurn, invokeManifestTool, manifestToolToAITool, principalBindingFor, rateResponse, recallPersonaMemory, rejectAppliedChange, resolveConversationInstructions, runChatConversationStream, runPersonaConversationTurn, runToolLoop, thumbsDown, thumbsUp };
1002
1364
 
1003
1365
  //# sourceMappingURL=index.js.map