@happyvertical/smrt-chat 0.57.32 → 0.57.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/AGENTS.md +1 -1
  2. package/agents/tool-loop.md +224 -0
  3. package/dist/assistant-turn-events.d.ts +10 -1
  4. package/dist/assistant-turn-events.d.ts.map +1 -1
  5. package/dist/assistant-turn.d.ts +42 -5
  6. package/dist/assistant-turn.d.ts.map +1 -1
  7. package/dist/chat-stream.d.ts +15 -0
  8. package/dist/chat-stream.d.ts.map +1 -1
  9. package/dist/chunks/{ChatService-DjGf2AoJ.js → ChatService-D0XuiCTk.js} +3 -2
  10. package/dist/chunks/ChatService-D0XuiCTk.js.map +1 -0
  11. package/dist/chunks/assistant-turn-events-BbZUf-Ju.js.map +1 -1
  12. package/dist/chunks/{chat-stream-DJuup0go.js → chat-stream-CsD8FwnS.js} +552 -77
  13. package/dist/chunks/chat-stream-CsD8FwnS.js.map +1 -0
  14. package/dist/data-surface-tools.d.ts +1 -1
  15. package/dist/data-surface-tools.d.ts.map +1 -1
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +9 -5
  19. package/dist/index.js.map +1 -1
  20. package/dist/internal/agent-runtime.js +1 -1
  21. package/dist/manifest.json +1 -1
  22. package/dist/persona-conversation.d.ts +41 -1
  23. package/dist/persona-conversation.d.ts.map +1 -1
  24. package/dist/services/ChatService.d.ts +6 -0
  25. package/dist/services/ChatService.d.ts.map +1 -1
  26. package/dist/smrt-knowledge.json +11 -6
  27. package/dist/svelte/components/assistant/assistant-http-client.d.ts +7 -0
  28. package/dist/svelte/components/assistant/assistant-http-client.d.ts.map +1 -1
  29. package/dist/svelte/components/assistant/assistant-http-client.js +8 -0
  30. package/dist/svelte/components/assistant/assistant-transport.d.ts.map +1 -1
  31. package/dist/svelte/components/assistant/assistant-transport.js +3 -0
  32. package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.d.ts.map +1 -1
  33. package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.js +10 -4
  34. package/dist/sveltekit.d.ts +26 -0
  35. package/dist/sveltekit.d.ts.map +1 -1
  36. package/dist/sveltekit.js +27 -10
  37. package/dist/sveltekit.js.map +1 -1
  38. package/dist/tool-loop.d.ts +223 -2
  39. package/dist/tool-loop.d.ts.map +1 -1
  40. package/dist/voice.d.ts.map +1 -1
  41. package/package.json +17 -18
  42. package/dist/chunks/ChatService-DjGf2AoJ.js.map +0 -1
  43. package/dist/chunks/chat-stream-DJuup0go.js.map +0 -1
@@ -7,7 +7,7 @@ import { RUNTIME_REPORT_BUCKETS, RUNTIME_REPORT_CHART_TYPES, RUNTIME_REPORT_FILT
7
7
  import { getCurrentTenant, isSuperAdminBypass, isSystemContext, isTenancyEnabled, withTenant } from "@happyvertical/smrt-tenancy";
8
8
  import { personaLearningMemory, resolvePersonaInstructions } from "@happyvertical/smrt-personas";
9
9
  //#region src/__smrt-register__.ts
10
- ObjectRegistry.registerPackageManifest(JSON.parse(`{"version":"1.0.0","timestamp":0,"packageName":"@happyvertical/smrt-chat","packageVersion":"0.57.32","objects":{"@happyvertical/smrt-chat:AgentSessionCollection":{"name":"agentsessioncollection","className":"AgentSessionCollection","qualifiedName":"@happyvertical/smrt-chat:AgentSessionCollection","collection":"agentsessions","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/collections/AgentSessionCollection.ts","packageName":"@happyvertical/smrt-chat","fields":{},"methods":{"findActiveByParticipant":{"name":"findActiveByParticipant","async":true,"parameters":[{"name":"participantProfileId","type":"string","optional":false}],"returnType":"Promise<AgentSession[]>","isStatic":false,"isPublic":true},"findActiveSession":{"name":"findActiveSession","async":true,"parameters":[{"name":"agentId","type":"string","optional":false},{"name":"participantProfileId","type":"string","optional":false},{"name":"tenantId","type":"string | null","optional":false,"unionBranches":[{"type":"string"},{"type":"null"}]},{"name":"sessionKey","type":"string | null","optional":true,"unionBranches":[{"type":"string"},{"type":"null"}]}],"returnType":"Promise<AgentSession | null>","isStatic":false,"isPublic":true},"findOrCreate":{"name":"findOrCreate","async":true,"parameters":[{"name":"params","type":"object","optional":false,"memberTypes":["string","string | null","string[]"]}],"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,"memberTypes":["string | null","string"]}],"returnType":"Promise<number>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"agent_sessions","api":{"include":["list","get"]},"mcp":{"include":["list","get"]}},"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 \\"tenant_id\\" UUID,\\n \\"agent_id\\" TEXT NOT NULL DEFAULT '',\\n \\"agent_profile_id\\" UUID,\\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":""},"agent_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"participant_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"chat_room_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"agent_sessions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"agent_sessions_agent_profile_id_idx","columns":["agent_profile_id"]},{"name":"agent_sessions_participant_profile_id_idx","columns":["participant_profile_id"]},{"name":"agent_sessions_chat_room_id_idx","columns":["chat_room_id"]}],"version":"56b10067"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatMessageCollection":{"name":"chatmessagecollection","className":"ChatMessageCollection","qualifiedName":"@happyvertical/smrt-chat:ChatMessageCollection","collection":"chatmessages","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/collections/ChatMessageCollection.ts","packageName":"@happyvertical/smrt-chat","fields":{},"methods":{"getByRoom":{"name":"getByRoom","async":true,"parameters":[{"name":"roomId","type":"string","optional":false},{"name":"tenantId","type":"string","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["number","string"]}],"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,"typeUnresolved":true}],"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,"unionBranches":[{"type":"string"},{"type":"null"}]}],"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","api":{"include":["list","get"]},"mcp":{"include":["list","get"]}},"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 \\"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,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"thread_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_threads","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"sender_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"agent_session_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"agent_sessions","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_messages_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_messages_room_id_idx","columns":["room_id"]},{"name":"chat_messages_thread_id_idx","columns":["thread_id"]},{"name":"chat_messages_sender_profile_id_idx","columns":["sender_profile_id"]},{"name":"chat_messages_agent_session_id_idx","columns":["agent_session_id"]},{"name":"chat_messages_reply_to_message_id_idx","columns":["reply_to_message_id"]}],"version":"cca14e75"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatParticipantCollection":{"name":"chatparticipantcollection","className":"ChatParticipantCollection","qualifiedName":"@happyvertical/smrt-chat:ChatParticipantCollection","collection":"chatparticipants","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/collections/ChatParticipantCollection.ts","packageName":"@happyvertical/smrt-chat","fields":{},"methods":{"getByRoom":{"name":"getByRoom","async":true,"parameters":[{"name":"roomId","type":"string","optional":false}],"returnType":"Promise<ChatParticipant[]>","isStatic":false,"isPublic":true},"getByProfile":{"name":"getByProfile","async":true,"parameters":[{"name":"profileId","type":"string","optional":false}],"returnType":"Promise<ChatParticipant[]>","isStatic":false,"isPublic":true},"findMembership":{"name":"findMembership","async":true,"parameters":[{"name":"roomId","type":"string","optional":false},{"name":"profileId","type":"string","optional":false},{"name":"tenantId","type":"string","optional":true}],"returnType":"Promise<ChatParticipant | null>","isStatic":false,"isPublic":true},"findActiveMembership":{"name":"findActiveMembership","async":true,"parameters":[{"name":"roomId","type":"string","optional":false},{"name":"profileId","type":"string","optional":false},{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<ChatParticipant | null>","isStatic":false,"isPublic":true},"isActiveMember":{"name":"isActiveMember","async":true,"parameters":[{"name":"roomId","type":"string","optional":false},{"name":"profileId","type":"string","optional":false},{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<boolean>","isStatic":false,"isPublic":true},"getOnlineInRoom":{"name":"getOnlineInRoom","async":true,"parameters":[{"name":"roomId","type":"string","optional":false}],"returnType":"Promise<ChatParticipant[]>","isStatic":false,"isPublic":true},"getAdminsInRoom":{"name":"getAdminsInRoom","async":true,"parameters":[{"name":"roomId","type":"string","optional":false}],"returnType":"Promise<ChatParticipant[]>","isStatic":false,"isPublic":true},"countInRoom":{"name":"countInRoom","async":true,"parameters":[{"name":"roomId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"chat_participants","api":{"include":["list","get"]},"mcp":{"include":["list","get"]}},"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 \\"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,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_participants_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_participants_room_id_idx","columns":["room_id"]},{"name":"chat_participants_profile_id_idx","columns":["profile_id"]},{"name":"chat_participants_last_read_message_id_idx","columns":["last_read_message_id"]}],"version":"07714046"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatReactionCollection":{"name":"chatreactioncollection","className":"ChatReactionCollection","qualifiedName":"@happyvertical/smrt-chat:ChatReactionCollection","collection":"chatreactions","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/collections/ChatReactionCollection.ts","packageName":"@happyvertical/smrt-chat","fields":{},"methods":{"getByMessage":{"name":"getByMessage","async":true,"parameters":[{"name":"messageId","type":"string","optional":false}],"returnType":"Promise<ChatReaction[]>","isStatic":false,"isPublic":true},"getReactionCounts":{"name":"getReactionCounts","async":true,"parameters":[{"name":"messageId","type":"string","optional":false}],"returnType":"Promise<Map<string, object>>","isStatic":false,"isPublic":true},"toggle":{"name":"toggle","async":true,"parameters":[{"name":"messageId","type":"string","optional":false},{"name":"profileId","type":"string","optional":false},{"name":"emoji","type":"string","optional":false},{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<object>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"chat_reactions","api":{"include":["list"]},"mcp":{"include":["list"]},"cli":false},"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 \\"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,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"emoji":{"type":"TEXT","notNull":true,"unique":false,"default":""}},"indexes":[{"name":"chat_reactions_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_reactions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_reactions_message_id_idx","columns":["message_id"]},{"name":"chat_reactions_profile_id_idx","columns":["profile_id"]}],"version":"5b1969a6"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatRoomCollection":{"name":"chatroomcollection","className":"ChatRoomCollection","qualifiedName":"@happyvertical/smrt-chat:ChatRoomCollection","collection":"chatrooms","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/collections/ChatRoomCollection.ts","packageName":"@happyvertical/smrt-chat","fields":{},"methods":{"findByType":{"name":"findByType","async":true,"parameters":[{"name":"roomType","type":"ChatRoomType","optional":false}],"returnType":"Promise<ChatRoom[]>","isStatic":false,"isPublic":true},"findPublic":{"name":"findPublic","async":true,"parameters":[],"returnType":"Promise<ChatRoom[]>","isStatic":false,"isPublic":true},"findDMs":{"name":"findDMs","async":true,"parameters":[],"returnType":"Promise<ChatRoom[]>","isStatic":false,"isPublic":true},"findAgentRooms":{"name":"findAgentRooms","async":true,"parameters":[],"returnType":"Promise<ChatRoom[]>","isStatic":false,"isPublic":true},"search":{"name":"search","async":true,"parameters":[{"name":"query","type":"string","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["number"]}],"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","api":{"include":["list","get"]},"mcp":{"include":["list","get"]}},"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 \\"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_rooms_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_rooms_created_by_profile_id_idx","columns":["created_by_profile_id"]}],"version":"3665d881"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatThreadCollection":{"name":"chatthreadcollection","className":"ChatThreadCollection","qualifiedName":"@happyvertical/smrt-chat:ChatThreadCollection","collection":"chatthreads","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/collections/ChatThreadCollection.ts","packageName":"@happyvertical/smrt-chat","fields":{},"methods":{"getByRoom":{"name":"getByRoom","async":true,"parameters":[{"name":"roomId","type":"string","optional":false}],"returnType":"Promise<ChatThread[]>","isStatic":false,"isPublic":true},"getActive":{"name":"getActive","async":true,"parameters":[{"name":"roomId","type":"string","optional":false}],"returnType":"Promise<ChatThread[]>","isStatic":false,"isPublic":true},"getUnresolved":{"name":"getUnresolved","async":true,"parameters":[],"returnType":"Promise<ChatThread[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"chat_threads","api":{"include":["list","get"]},"mcp":{"include":["list","get"]}},"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 \\"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,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"root_message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_threads_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_threads_room_id_idx","columns":["room_id"]},{"name":"chat_threads_root_message_id_idx","columns":["root_message_id"]}],"version":"e1ae958b"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:VoiceGatewayTurnCollection":{"name":"voicegatewayturncollection","className":"VoiceGatewayTurnCollection","qualifiedName":"@happyvertical/smrt-chat:VoiceGatewayTurnCollection","collection":"voicegatewayturns","filePath":"/home/runner/work/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,"memberTypes":["string"]}],"returnType":"Promise<VoiceGatewayTurn>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"voice_gateway_turns","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":false},"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 \\"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,"foreignKey":{"table":"voice_sessions","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"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_voice_session_id_gateway_turn_id_idx","columns":["voice_session_id","gateway_turn_id"],"unique":true},{"name":"voice_gateway_turns_slug_context_idx","columns":["slug","context"]},{"name":"voice_gateway_turns_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"c4d871b8"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:VoiceSessionCollection":{"name":"voicesessioncollection","className":"VoiceSessionCollection","qualifiedName":"@happyvertical/smrt-chat:VoiceSessionCollection","collection":"voicesessions","filePath":"/home/runner/work/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,"memberTypes":["string"]}],"returnType":"Promise<number>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"voice_sessions","api":{"include":["list","get"]},"mcp":{"include":["list","get"]}},"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 \\"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,"foreignKey":{"table":"agent_sessions","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"chat_room_id":{"type":"UUID","referenceKind":"foreignKey","notNull":true,"unique":false,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"thread_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_threads","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"voice_sessions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"voice_sessions_actor_profile_id_idx","columns":["actor_profile_id"]},{"name":"voice_sessions_actor_user_id_idx","columns":["actor_user_id"]},{"name":"voice_sessions_persona_id_idx","columns":["persona_id"]},{"name":"voice_sessions_agent_session_id_idx","columns":["agent_session_id"]},{"name":"voice_sessions_chat_room_id_idx","columns":["chat_room_id"]},{"name":"voice_sessions_thread_id_idx","columns":["thread_id"]}],"version":"d5cfb90c"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:AgentSession":{"name":"agentsession","className":"AgentSession","qualifiedName":"@happyvertical/smrt-chat:AgentSession","collection":"agentsessions","description":"Agent conversation session.","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/models/AgentSession.ts","packageName":"@happyvertical/smrt-chat","fields":{"tenantId":{"type":"text","required":false,"_meta":{"sqlType":"UUID","nullable":true,"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false}}},"agentId":{"type":"text","required":true,"default":"","_meta":{"required":true}},"agentProfileId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-profiles:Profile"},"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},"enum":["active","closed","expired"]},"allowedTools":{"type":"text","required":false,"default":"[]"},"sessionContext":{"type":"text","required":false,"default":"{}","_meta":{"sensitive":true},"sensitive":true},"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, unknown>","isStatic":false,"isPublic":true},"setSessionContext":{"name":"setSessionContext","async":false,"parameters":[{"name":"ctx","type":"Record<string, unknown>","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, unknown>","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":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"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 \\"agent_profile_id\\" UUID,\\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":""},"agent_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"participant_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"chat_room_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"agent_sessions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"agent_sessions_agent_profile_id_idx","columns":["agent_profile_id"]},{"name":"agent_sessions_participant_profile_id_idx","columns":["participant_profile_id"]},{"name":"agent_sessions_chat_room_id_idx","columns":["chat_room_id"]}],"version":"56b10067"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatMessage":{"name":"chatmessage","className":"ChatMessage","qualifiedName":"@happyvertical/smrt-chat:ChatMessage","collection":"chatmessages","description":"Chat message. Internal model \u2014 all mutations must go through the membership-checked ChatService (S5 #1392).","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/models/ChatMessage.ts","packageName":"@happyvertical/smrt-chat","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"roomId":{"type":"foreignKey","required":true,"related":"ChatRoom","description":"The room in which this message was sent.","_meta":{"description":"The room in which this message was sent.","required":true}},"threadId":{"type":"foreignKey","required":false,"related":"ChatThread","description":"The discussion thread containing this message, when there is one.","_meta":{"description":"The discussion thread containing this message, when there is one."}},"senderProfileId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-profiles:Profile","description":"The person or assistant who sent this message.","_meta":{"description":"The person or assistant who sent this message."}},"agentSessionId":{"type":"foreignKey","required":false,"related":"AgentSession","description":"The assistant conversation associated with this message, when applicable.","_meta":{"description":"The assistant conversation associated with this message, when applicable."}},"content":{"type":"text","required":false,"default":"","description":"The text of the message shared with the conversation.","_meta":{"description":"The text of the message shared with the conversation."}},"messageType":{"type":"text","required":true,"default":"text","description":"The kind of message, such as text, a file, or an activity notice.","_meta":{"required":true,"description":"The kind of message, such as text, a file, or an activity notice."},"enum":["text","system","action","file","tool_call","tool_result"]},"role":{"type":"text","required":true,"default":"user","description":"Whether this message comes from a person, an assistant, or an automated action.","_meta":{"required":true,"description":"Whether this message comes from a person, an assistant, or an automated action."},"enum":["user","assistant","system","tool"]},"isEdited":{"type":"boolean","required":false,"default":false,"description":"Whether the message has changed since it was sent.","_meta":{"description":"Whether the message has changed since it was sent."}},"editedAt":{"type":"datetime","required":false,"description":"When the message was most recently edited.","_meta":{"description":"When the message was most recently edited."}},"isDeleted":{"type":"boolean","required":false,"default":false,"description":"Whether this message has been removed from the conversation.","_meta":{"description":"Whether this message has been removed from the conversation."}},"replyToMessageId":{"type":"foreignKey","required":false,"related":"ChatMessage","description":"The earlier message this reply responds to.","_meta":{"description":"The earlier message this reply responds to."}},"metadata":{"type":"text","required":false,"default":"{}","description":"Additional message details maintained by the application.","_meta":{"description":"Additional message details maintained by the application."}},"toolCallData":{"type":"text","required":false,"description":"Details of an automated action associated with this message.","_meta":{"description":"Details of an automated action associated with this message."}},"attachments":{"type":"text","required":false,"default":"[]","description":"Files shared alongside the text of this message.","_meta":{"description":"Files shared alongside the text of this message."}}},"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,"memberTypes":["string","number"]}],"returnType":"void","isStatic":false,"isPublic":true},"getMetadata":{"name":"getMetadata","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setMetadata":{"name":"setMetadata","async":false,"parameters":[{"name":"data","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getToolCallData":{"name":"getToolCallData","async":false,"parameters":[],"returnType":"Record<string, unknown> | null","isStatic":false,"isPublic":true},"setToolCallData":{"name":"setToolCallData","async":false,"parameters":[{"name":"data","type":"Record<string, unknown> | null","optional":false,"unionBranches":[{"type":"Record<string, unknown>"},{"type":"null"}]}],"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":{"skipApiCheck":true},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"ChatMessage","collectionExportName":"ChatMessageCollection","validationRules":[{"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,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"thread_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_threads","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"sender_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"agent_session_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"agent_sessions","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_messages_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_messages_room_id_idx","columns":["room_id"]},{"name":"chat_messages_thread_id_idx","columns":["thread_id"]},{"name":"chat_messages_sender_profile_id_idx","columns":["sender_profile_id"]},{"name":"chat_messages_agent_session_id_idx","columns":["agent_session_id"]},{"name":"chat_messages_reply_to_message_id_idx","columns":["reply_to_message_id"]}],"version":"cca14e75"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatParticipant":{"name":"chatparticipant","className":"ChatParticipant","qualifiedName":"@happyvertical/smrt-chat:ChatParticipant","collection":"chatparticipants","description":"Room membership row. Internal model \u2014 membership must be established and mutated only through the membership/owner-checked ChatService (S5 #1392).","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/models/ChatParticipant.ts","packageName":"@happyvertical/smrt-chat","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"roomId":{"type":"foreignKey","required":true,"related":"ChatRoom","description":"The room to which this membership belongs.","_meta":{"description":"The room to which this membership belongs.","required":true}},"profileId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-profiles:Profile","description":"The person or assistant participating in the room.","_meta":{"description":"The person or assistant participating in the room."}},"role":{"type":"text","required":true,"default":"member","description":"The member role that determines what they can do in the room.","_meta":{"required":true,"description":"The member role that determines what they can do in the room."},"enum":["owner","admin","member","viewer"]},"status":{"type":"text","required":true,"default":"active","description":"Whether this member is active, has left, was removed, or is banned.","_meta":{"required":true,"description":"Whether this member is active, has left, was removed, or is banned."},"enum":["active","left","kicked","banned"]},"onlineStatus":{"type":"text","required":true,"default":"offline","description":"The availability shown for this member, such as online or away.","_meta":{"required":true,"description":"The availability shown for this member, such as online or away."},"enum":["online","away","dnd","offline"]},"lastReadMessageId":{"type":"foreignKey","required":false,"related":"ChatMessage","description":"The most recent message this member has read.","_meta":{"description":"The most recent message this member has read."}},"lastSeenAt":{"type":"datetime","required":false,"description":"When this member was last seen in the conversation.","_meta":{"description":"When this member was last seen in the conversation."}},"joinedAt":{"type":"datetime","required":false,"description":"When this member joined the room.","_meta":{"description":"When this member joined the room."}},"nickname":{"type":"text","required":false,"default":"","description":"The display name this member uses within the room.","_meta":{"description":"The display name this member uses within the room."}},"isMuted":{"type":"boolean","required":false,"default":false,"description":"Whether notifications for this room are muted for this member.","_meta":{"description":"Whether notifications for this room are muted for this member."}},"isPinned":{"type":"boolean","required":false,"default":false,"description":"Whether this room is pinned for this member.","_meta":{"description":"Whether this room is pinned for this member."}}},"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":{"skipApiCheck":true},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"ChatParticipant","collectionExportName":"ChatParticipantCollection","validationRules":[{"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,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_participants_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_participants_room_id_idx","columns":["room_id"]},{"name":"chat_participants_profile_id_idx","columns":["profile_id"]},{"name":"chat_participants_last_read_message_id_idx","columns":["last_read_message_id"]}],"version":"07714046"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatReaction":{"name":"chatreaction","className":"ChatReaction","qualifiedName":"@happyvertical/smrt-chat:ChatReaction","collection":"chatreactions","description":"Message reaction. Internal model \u2014 reactions must be added/removed only through the membership-checked ChatService (S5 #1392).","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/models/ChatReaction.ts","packageName":"@happyvertical/smrt-chat","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"messageId":{"type":"foreignKey","required":true,"related":"ChatMessage","description":"The message to which this reaction was added.","_meta":{"description":"The message to which this reaction was added.","required":true}},"profileId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-profiles:Profile","description":"The person who added this reaction.","_meta":{"description":"The person who added this reaction."}},"emoji":{"type":"text","required":true,"default":"","description":"The symbol chosen to express a response to the message.","_meta":{"required":true,"description":"The symbol chosen to express a response to the message."}}},"methods":{},"decoratorConfig":{"tableName":"chat_reactions","api":{"include":["list"]},"mcp":{"include":["list"]},"cli":false,"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"ChatReaction","collectionExportName":"ChatReactionCollection","validationRules":[{"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,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"emoji":{"type":"TEXT","notNull":true,"unique":false,"default":""}},"indexes":[{"name":"chat_reactions_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_reactions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_reactions_message_id_idx","columns":["message_id"]},{"name":"chat_reactions_profile_id_idx","columns":["profile_id"]}],"version":"5b1969a6"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatRoom":{"name":"chatroom","className":"ChatRoom","qualifiedName":"@happyvertical/smrt-chat:ChatRoom","collection":"chatrooms","description":"Chat room supporting public channels, private groups, DMs, and agent conversations.","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/models/ChatRoom.ts","packageName":"@happyvertical/smrt-chat","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"name":{"type":"text","required":false,"default":"","description":"A recognizable name that helps teammates find this room.","_meta":{"description":"A recognizable name that helps teammates find this room."}},"description":{"type":"text","required":false,"default":"","description":"Explain the purpose of the room and who should join.","_meta":{"description":"Explain the purpose of the room and who should join."}},"roomType":{"type":"text","required":true,"default":"public","description":"Whether the room is public, private, a direct message, or an assistant conversation.","_meta":{"required":true,"description":"Whether the room is public, private, a direct message, or an assistant conversation."},"enum":["public","private","dm","agent"]},"status":{"type":"text","required":true,"default":"active","description":"Whether this room is active, archived, or deleted.","_meta":{"required":true,"description":"Whether this room is active, archived, or deleted."},"enum":["active","archived","deleted"]},"topic":{"type":"text","required":false,"default":"","description":"The current subject or focus of the room.","_meta":{"description":"The current subject or focus of the room."}},"avatarUrl":{"type":"text","required":false,"default":"","description":"The address of the image used to represent this room.","_meta":{"description":"The address of the image used to represent this room."}},"isArchived":{"type":"boolean","required":false,"default":false,"description":"Whether the room has been archived from active conversations.","_meta":{"description":"Whether the room has been archived from active conversations."}},"maxParticipants":{"type":"integer","required":false,"default":0,"description":"The maximum number of members; zero means no configured limit.","_meta":{"description":"The maximum number of members; zero means no configured limit."}},"metadata":{"type":"text","required":false,"default":"{}","description":"Additional room details maintained by the application.","_meta":{"description":"Additional room details maintained by the application."}},"createdByProfileId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-profiles:Profile","description":"The person who originally created this room.","_meta":{"description":"The person who originally created this room."}},"lastMessageAt":{"type":"datetime","required":false,"description":"When the most recent message was sent in this room.","_meta":{"description":"When the most recent message was sent in this room."}}},"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":{"skipApiCheck":true},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"ChatRoom","collectionExportName":"ChatRoomCollection","displayLabelField":"name","validationRules":[{"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_rooms_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_rooms_created_by_profile_id_idx","columns":["created_by_profile_id"]}],"version":"3665d881"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatThread":{"name":"chatthread","className":"ChatThread","qualifiedName":"@happyvertical/smrt-chat:ChatThread","collection":"chatthreads","description":"Conversation thread. Internal model \u2014 threads must be created/mutated only through the membership-checked ChatService (S5 #1392).","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/models/ChatThread.ts","packageName":"@happyvertical/smrt-chat","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"roomId":{"type":"foreignKey","required":true,"related":"ChatRoom","description":"The room containing this discussion thread.","_meta":{"description":"The room containing this discussion thread.","required":true}},"rootMessageId":{"type":"foreignKey","required":false,"related":"ChatMessage","description":"The message that started this thread, when it began as a reply.","_meta":{"description":"The message that started this thread, when it began as a reply.","nullable":true}},"title":{"type":"text","required":false,"default":"","description":"A short title describing the subject of this thread.","_meta":{"description":"A short title describing the subject of this thread."}},"isResolved":{"type":"boolean","required":false,"default":false,"description":"Whether the discussion has reached a resolution.","_meta":{"description":"Whether the discussion has reached a resolution."}},"messageCount":{"type":"integer","required":false,"default":0,"description":"The number of messages in this thread.","_meta":{"description":"The number of messages in this thread."}},"lastMessageAt":{"type":"datetime","required":false,"description":"When the most recent message was sent in this thread.","_meta":{"description":"When the most recent message was sent in this thread."}},"participantCount":{"type":"integer","required":false,"default":0,"description":"The number of people participating in this thread.","_meta":{"description":"The number of people participating in this thread."}}},"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":{"skipApiCheck":true},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"ChatThread","collectionExportName":"ChatThreadCollection","displayLabelField":"title","validationRules":[{"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,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"root_message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_threads_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_threads_room_id_idx","columns":["room_id"]},{"name":"chat_threads_root_message_id_idx","columns":["root_message_id"]}],"version":"e1ae958b"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:VoiceGatewayTurn":{"name":"voicegatewayturn","className":"VoiceGatewayTurn","qualifiedName":"@happyvertical/smrt-chat:VoiceGatewayTurn","collection":"voicegatewayturns","description":"Durable reservation for a gateway turn. The natural key makes turn_id replay checks concurrency-safe before transcript messages are written.","filePath":"/home/runner/work/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},"enum":["processing","completed","failed"]},"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":"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,"foreignKey":{"table":"voice_sessions","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"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_voice_session_id_gateway_turn_id_idx","columns":["voice_session_id","gateway_turn_id"],"unique":true},{"name":"voice_gateway_turns_slug_context_idx","columns":["slug","context"]},{"name":"voice_gateway_turns_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"c4d871b8"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:VoiceSession":{"name":"voicesession","className":"VoiceSession","qualifiedName":"@happyvertical/smrt-chat:VoiceSession","collection":"voicesessions","description":"Short-lived binding proving a voice gateway turn belongs to an authenticated SMRT actor, persona, and chat session.","filePath":"/home/runner/work/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},"enum":["active","expired","revoked"]},"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, unknown>","isStatic":false,"isPublic":true},"setMetadata":{"name":"setMetadata","async":false,"parameters":[{"name":"metadata","type":"Record<string, unknown>","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":{"skipApiCheck":true},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"VoiceSession","collectionExportName":"VoiceSessionCollection","validationRules":[{"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,"foreignKey":{"table":"agent_sessions","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"chat_room_id":{"type":"UUID","referenceKind":"foreignKey","notNull":true,"unique":false,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"thread_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_threads","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"voice_sessions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"voice_sessions_actor_profile_id_idx","columns":["actor_profile_id"]},{"name":"voice_sessions_actor_user_id_idx","columns":["actor_user_id"]},{"name":"voice_sessions_persona_id_idx","columns":["persona_id"]},{"name":"voice_sessions_agent_session_id_idx","columns":["agent_session_id"]},{"name":"voice_sessions_chat_room_id_idx","columns":["chat_room_id"]},{"name":"voice_sessions_thread_id_idx","columns":["thread_id"]}],"version":"d5cfb90c"},"importPath":"@happyvertical/smrt-chat"}},"moduleType":"smrt","recipes":[{"id":"chat.assistant","className":"AssistantRecipe","label":"Assistant","summary":"Ask an AI assistant about the page you are on, from a dock in the app shell.","synonyms":["ai assistant","ai chat","copilot","chatbot","ask ai","helper"],"models":["@happyvertical/smrt-chat:AgentSession","@happyvertical/smrt-chat:ChatRoom","@happyvertical/smrt-chat:ChatParticipant","@happyvertical/smrt-chat:ChatThread","@happyvertical/smrt-chat:ChatMessage"],"nav":[],"requires":[],"help":{"markdown":"## Overview\\n\\nThe assistant is a chat panel that opens from a button in the app's top bar. It\\nsees the page you are on, so you can ask about what is in front of you and get\\nan answer without leaving it.\\n\\nYou can keep several conversations and come back to them later. The assistant\\nonly reaches the data and actions the app owner allows, and it works with your\\nown permissions: it cannot show you anything you could not open yourself.\\n\\n## Tasks\\n\\n### Ask a question\\n\\n1. Choose the assistant button in the top bar to open the panel.\\n2. Type your question and send it.\\n3. Read the reply as it arrives. Open the panel again from any page to carry on.\\n\\n### Start a new conversation\\n\\n1. Open the panel and choose the conversation list.\\n2. Start a new conversation, or pick an earlier one to carry on.\\n\\n### Approve a change\\n\\nWhen the assistant proposes a change, it shows what will happen and waits.\\n\\n1. Read the proposed change.\\n2. Confirm it to go ahead, or reject it. Nothing changes until you confirm.\\n\\n### Choose a model\\n\\nIf the app offers more than one model, pick one from the list in the panel\\nbefore you send a message.\\n\\n## What the app owner sets up\\n\\n- A model. Hosted models need the service key their provider issues, stored as\\n a secret in the app (\`OPENAI_API_KEY\`, \`ANTHROPIC_API_KEY\` or\\n \`GEMINI_API_KEY\`); only the key for the model the app uses is needed. Models\\n that run in the browser need no key.\\n- The tools the assistant may use. It is offered nothing unless the app lists\\n it, so an empty list means conversation only.\\n- Optionally, report tools. An app can let the assistant draft a report from a\\n request, preview it, and save it only after a person approves that exact\\n report.\\n","fieldRefs":[]},"surfaces":[{"kind":"shell-widget","slot":"header.end","export":"@happyvertical/smrt-chat/svelte#AssistantDock","label":"Assistant","icon":"bot"}],"providers":[{"id":"llm","kind":"llm","options":["openai","anthropic","gemini","webllm","bitgpu"],"required":true,"secrets":["OPENAI_API_KEY","ANTHROPIC_API_KEY","GEMINI_API_KEY"],"browserOptions":["webllm","bitgpu"]}],"runtime":"both","demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: node:crypto + node:async_hooks; and its package depends on @happyvertical/smrt-agents, @happyvertical/smrt-images, @happyvertical/smrt-jobs, @happyvertical/smrt-profiles, @happyvertical/smrt-reports, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3615, #3617, #3624, #3625, #3626, #3627, #3628).","Provider llm has an in-browser option (webllm, bitgpu)."]}},{"id":"chat.rooms","className":"ChatRoomsRecipe","label":"Team Chat","summary":"Organize team conversations in rooms with threads and reactions.","synonyms":["team chat","channels","group chat","conversations"],"models":["@happyvertical/smrt-chat:ChatRoom","@happyvertical/smrt-chat:ChatMessage","@happyvertical/smrt-chat:ChatParticipant","@happyvertical/smrt-chat:ChatThread","@happyvertical/smrt-chat:ChatReaction"],"nav":[{"label":"Chat rooms","model":"@happyvertical/smrt-chat:ChatRoom","icon":"users","description":"Team conversations organized by topic or audience.","noun":"chat room"}],"requires":[],"group":{"id":"team-collaboration","label":"Team collaboration","summary":"Keep conversations and shared work in one place."},"section":{"id":"team","label":"Team","icon":"users","description":"People and the conversations that keep them aligned."},"options":{"@happyvertical/smrt-chat:ChatRoom":{"fields":{"metadata":{"visibility":"hidden"},"createdByProfileId":{"visibility":"hidden"},"lastMessageAt":{"label":"Last message","order":1}}},"@happyvertical/smrt-chat:ChatMessage":{"fields":{"metadata":{"visibility":"hidden"},"toolCallData":{"visibility":"hidden"},"attachments":{"visibility":"advanced"}}},"@happyvertical/smrt-chat:ChatParticipant":{"fields":{"lastReadMessageId":{"visibility":"hidden"},"lastSeenAt":{"visibility":"advanced"}}}},"help":{"markdown":"## Overview\\n\\nTeam Chat keeps conversations in rooms so people can find the right discussion,\\nfollow threads, and see reactions without mixing unrelated work together. The\\nroom and message lists are read-only generated views. Create rooms, manage\\nmembers, and send messages through the app's authorized chat workflow.\\n\\n## Tasks\\n\\n### Find the right room\\n\\n1. Open **Chat rooms** from the navigation.\\n2. Search for a room by its **{field:ChatRoom.name}**, or use its\\n **{field:ChatRoom.topic}** to tell similar rooms apart.\\n3. Open the room and check **{field:ChatRoom.lastMessageAt}** to see where the\\n most recent discussion happened.\\n\\n### Follow a conversation\\n\\n1. Read the room messages and open a thread when you need the discussion in\\n one place.\\n2. Use the thread **{field:ChatThread.title}** to describe the subject when\\n your app supplies one.\\n3. Add a reaction by choosing the **{field:ChatReaction.emoji}** that best\\n communicates your response.\\n\\n### Keep a room useful\\n\\n1. Give the room a clear **{field:ChatRoom.name}** and a short\\n **{field:ChatRoom.description}**.\\n2. Set **{field:ChatRoom.roomType}** deliberately: public for broad team\\n discussion, private for restricted groups, and direct messages for one-to-one\\n conversations.\\n3. Use a focused **{field:ChatMessage.content}** so teammates can scan the\\n conversation and reply in context.\\n","fieldRefs":["ChatMessage.content","ChatReaction.emoji","ChatRoom.description","ChatRoom.lastMessageAt","ChatRoom.name","ChatRoom.roomType","ChatRoom.topic","ChatThread.title"]},"surfaces":[{"kind":"route","path":"/chat/rooms","export":"@happyvertical/smrt-chat/svelte#ChatLayout","label":"Team chat"}],"runtime":"both","demoSeed":{"export":"@happyvertical/smrt-chat/playground#chatRoomsFixture"},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: node:crypto + node:async_hooks; and its package depends on @happyvertical/smrt-agents, @happyvertical/smrt-images, @happyvertical/smrt-jobs, @happyvertical/smrt-profiles, @happyvertical/smrt-reports, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3615, #3617, #3624, #3625, #3626, #3627, #3628)."]}}],"smrtDependencies":["@happyvertical/smrt-agents","@happyvertical/smrt-assets","@happyvertical/smrt-core","@happyvertical/smrt-images","@happyvertical/smrt-personas","@happyvertical/smrt-profiles","@happyvertical/smrt-reports","@happyvertical/smrt-tenancy","@happyvertical/smrt-users"],"browser":{"status":"server-only","issues":["#3615","#3617","#3624","#3625","#3626","#3627","#3628"],"reason":"node:crypto + node:async_hooks","via":["@happyvertical/smrt-agents","@happyvertical/smrt-images","@happyvertical/smrt-jobs","@happyvertical/smrt-profiles","@happyvertical/smrt-reports","@happyvertical/smrt-secrets","@happyvertical/smrt-tenancy","@happyvertical/smrt-users"]},"stampsConstructors":true}`));
10
+ ObjectRegistry.registerPackageManifest(JSON.parse(`{"version":"1.0.0","timestamp":0,"packageName":"@happyvertical/smrt-chat","packageVersion":"0.57.34","objects":{"@happyvertical/smrt-chat:AgentSessionCollection":{"name":"agentsessioncollection","className":"AgentSessionCollection","qualifiedName":"@happyvertical/smrt-chat:AgentSessionCollection","collection":"agentsessions","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/collections/AgentSessionCollection.ts","packageName":"@happyvertical/smrt-chat","fields":{},"methods":{"findActiveByParticipant":{"name":"findActiveByParticipant","async":true,"parameters":[{"name":"participantProfileId","type":"string","optional":false}],"returnType":"Promise<AgentSession[]>","isStatic":false,"isPublic":true},"findActiveSession":{"name":"findActiveSession","async":true,"parameters":[{"name":"agentId","type":"string","optional":false},{"name":"participantProfileId","type":"string","optional":false},{"name":"tenantId","type":"string | null","optional":false,"unionBranches":[{"type":"string"},{"type":"null"}]},{"name":"sessionKey","type":"string | null","optional":true,"unionBranches":[{"type":"string"},{"type":"null"}]}],"returnType":"Promise<AgentSession | null>","isStatic":false,"isPublic":true},"findOrCreate":{"name":"findOrCreate","async":true,"parameters":[{"name":"params","type":"object","optional":false,"memberTypes":["string","string | null","string[]"]}],"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,"memberTypes":["string | null","string"]}],"returnType":"Promise<number>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"agent_sessions","api":{"include":["list","get"]},"mcp":{"include":["list","get"]}},"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 \\"tenant_id\\" UUID,\\n \\"agent_id\\" TEXT NOT NULL DEFAULT '',\\n \\"agent_profile_id\\" UUID,\\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":""},"agent_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"participant_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"chat_room_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"agent_sessions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"agent_sessions_agent_profile_id_idx","columns":["agent_profile_id"]},{"name":"agent_sessions_participant_profile_id_idx","columns":["participant_profile_id"]},{"name":"agent_sessions_chat_room_id_idx","columns":["chat_room_id"]}],"version":"56b10067"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatMessageCollection":{"name":"chatmessagecollection","className":"ChatMessageCollection","qualifiedName":"@happyvertical/smrt-chat:ChatMessageCollection","collection":"chatmessages","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/collections/ChatMessageCollection.ts","packageName":"@happyvertical/smrt-chat","fields":{},"methods":{"getByRoom":{"name":"getByRoom","async":true,"parameters":[{"name":"roomId","type":"string","optional":false},{"name":"tenantId","type":"string","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["number","string"]}],"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,"typeUnresolved":true}],"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,"unionBranches":[{"type":"string"},{"type":"null"}]}],"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","api":{"include":["list","get"]},"mcp":{"include":["list","get"]}},"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 \\"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,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"thread_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_threads","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"sender_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"agent_session_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"agent_sessions","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_messages_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_messages_room_id_idx","columns":["room_id"]},{"name":"chat_messages_thread_id_idx","columns":["thread_id"]},{"name":"chat_messages_sender_profile_id_idx","columns":["sender_profile_id"]},{"name":"chat_messages_agent_session_id_idx","columns":["agent_session_id"]},{"name":"chat_messages_reply_to_message_id_idx","columns":["reply_to_message_id"]}],"version":"cca14e75"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatParticipantCollection":{"name":"chatparticipantcollection","className":"ChatParticipantCollection","qualifiedName":"@happyvertical/smrt-chat:ChatParticipantCollection","collection":"chatparticipants","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/collections/ChatParticipantCollection.ts","packageName":"@happyvertical/smrt-chat","fields":{},"methods":{"getByRoom":{"name":"getByRoom","async":true,"parameters":[{"name":"roomId","type":"string","optional":false}],"returnType":"Promise<ChatParticipant[]>","isStatic":false,"isPublic":true},"getByProfile":{"name":"getByProfile","async":true,"parameters":[{"name":"profileId","type":"string","optional":false}],"returnType":"Promise<ChatParticipant[]>","isStatic":false,"isPublic":true},"findMembership":{"name":"findMembership","async":true,"parameters":[{"name":"roomId","type":"string","optional":false},{"name":"profileId","type":"string","optional":false},{"name":"tenantId","type":"string","optional":true}],"returnType":"Promise<ChatParticipant | null>","isStatic":false,"isPublic":true},"findActiveMembership":{"name":"findActiveMembership","async":true,"parameters":[{"name":"roomId","type":"string","optional":false},{"name":"profileId","type":"string","optional":false},{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<ChatParticipant | null>","isStatic":false,"isPublic":true},"isActiveMember":{"name":"isActiveMember","async":true,"parameters":[{"name":"roomId","type":"string","optional":false},{"name":"profileId","type":"string","optional":false},{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<boolean>","isStatic":false,"isPublic":true},"getOnlineInRoom":{"name":"getOnlineInRoom","async":true,"parameters":[{"name":"roomId","type":"string","optional":false}],"returnType":"Promise<ChatParticipant[]>","isStatic":false,"isPublic":true},"getAdminsInRoom":{"name":"getAdminsInRoom","async":true,"parameters":[{"name":"roomId","type":"string","optional":false}],"returnType":"Promise<ChatParticipant[]>","isStatic":false,"isPublic":true},"countInRoom":{"name":"countInRoom","async":true,"parameters":[{"name":"roomId","type":"string","optional":false}],"returnType":"Promise<number>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"chat_participants","api":{"include":["list","get"]},"mcp":{"include":["list","get"]}},"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 \\"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,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_participants_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_participants_room_id_idx","columns":["room_id"]},{"name":"chat_participants_profile_id_idx","columns":["profile_id"]},{"name":"chat_participants_last_read_message_id_idx","columns":["last_read_message_id"]}],"version":"07714046"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatReactionCollection":{"name":"chatreactioncollection","className":"ChatReactionCollection","qualifiedName":"@happyvertical/smrt-chat:ChatReactionCollection","collection":"chatreactions","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/collections/ChatReactionCollection.ts","packageName":"@happyvertical/smrt-chat","fields":{},"methods":{"getByMessage":{"name":"getByMessage","async":true,"parameters":[{"name":"messageId","type":"string","optional":false}],"returnType":"Promise<ChatReaction[]>","isStatic":false,"isPublic":true},"getReactionCounts":{"name":"getReactionCounts","async":true,"parameters":[{"name":"messageId","type":"string","optional":false}],"returnType":"Promise<Map<string, object>>","isStatic":false,"isPublic":true},"toggle":{"name":"toggle","async":true,"parameters":[{"name":"messageId","type":"string","optional":false},{"name":"profileId","type":"string","optional":false},{"name":"emoji","type":"string","optional":false},{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<object>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"chat_reactions","api":{"include":["list"]},"mcp":{"include":["list"]},"cli":false},"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 \\"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,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"emoji":{"type":"TEXT","notNull":true,"unique":false,"default":""}},"indexes":[{"name":"chat_reactions_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_reactions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_reactions_message_id_idx","columns":["message_id"]},{"name":"chat_reactions_profile_id_idx","columns":["profile_id"]}],"version":"5b1969a6"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatRoomCollection":{"name":"chatroomcollection","className":"ChatRoomCollection","qualifiedName":"@happyvertical/smrt-chat:ChatRoomCollection","collection":"chatrooms","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/collections/ChatRoomCollection.ts","packageName":"@happyvertical/smrt-chat","fields":{},"methods":{"findByType":{"name":"findByType","async":true,"parameters":[{"name":"roomType","type":"ChatRoomType","optional":false}],"returnType":"Promise<ChatRoom[]>","isStatic":false,"isPublic":true},"findPublic":{"name":"findPublic","async":true,"parameters":[],"returnType":"Promise<ChatRoom[]>","isStatic":false,"isPublic":true},"findDMs":{"name":"findDMs","async":true,"parameters":[],"returnType":"Promise<ChatRoom[]>","isStatic":false,"isPublic":true},"findAgentRooms":{"name":"findAgentRooms","async":true,"parameters":[],"returnType":"Promise<ChatRoom[]>","isStatic":false,"isPublic":true},"search":{"name":"search","async":true,"parameters":[{"name":"query","type":"string","optional":false},{"name":"options","type":"object","optional":true,"memberTypes":["number"]}],"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","api":{"include":["list","get"]},"mcp":{"include":["list","get"]}},"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 \\"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_rooms_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_rooms_created_by_profile_id_idx","columns":["created_by_profile_id"]}],"version":"3665d881"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatThreadCollection":{"name":"chatthreadcollection","className":"ChatThreadCollection","qualifiedName":"@happyvertical/smrt-chat:ChatThreadCollection","collection":"chatthreads","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/collections/ChatThreadCollection.ts","packageName":"@happyvertical/smrt-chat","fields":{},"methods":{"getByRoom":{"name":"getByRoom","async":true,"parameters":[{"name":"roomId","type":"string","optional":false}],"returnType":"Promise<ChatThread[]>","isStatic":false,"isPublic":true},"getActive":{"name":"getActive","async":true,"parameters":[{"name":"roomId","type":"string","optional":false}],"returnType":"Promise<ChatThread[]>","isStatic":false,"isPublic":true},"getUnresolved":{"name":"getUnresolved","async":true,"parameters":[],"returnType":"Promise<ChatThread[]>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"chat_threads","api":{"include":["list","get"]},"mcp":{"include":["list","get"]}},"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 \\"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,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"root_message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_threads_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_threads_room_id_idx","columns":["room_id"]},{"name":"chat_threads_root_message_id_idx","columns":["root_message_id"]}],"version":"e1ae958b"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:VoiceGatewayTurnCollection":{"name":"voicegatewayturncollection","className":"VoiceGatewayTurnCollection","qualifiedName":"@happyvertical/smrt-chat:VoiceGatewayTurnCollection","collection":"voicegatewayturns","filePath":"/home/runner/work/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,"memberTypes":["string"]}],"returnType":"Promise<VoiceGatewayTurn>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"voice_gateway_turns","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":false},"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 \\"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,"foreignKey":{"table":"voice_sessions","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"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_voice_session_id_gateway_turn_id_idx","columns":["voice_session_id","gateway_turn_id"],"unique":true},{"name":"voice_gateway_turns_slug_context_idx","columns":["slug","context"]},{"name":"voice_gateway_turns_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"c4d871b8"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:VoiceSessionCollection":{"name":"voicesessioncollection","className":"VoiceSessionCollection","qualifiedName":"@happyvertical/smrt-chat:VoiceSessionCollection","collection":"voicesessions","filePath":"/home/runner/work/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,"memberTypes":["string"]}],"returnType":"Promise<number>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"voice_sessions","api":{"include":["list","get"]},"mcp":{"include":["list","get"]}},"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 \\"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,"foreignKey":{"table":"agent_sessions","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"chat_room_id":{"type":"UUID","referenceKind":"foreignKey","notNull":true,"unique":false,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"thread_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_threads","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"voice_sessions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"voice_sessions_actor_profile_id_idx","columns":["actor_profile_id"]},{"name":"voice_sessions_actor_user_id_idx","columns":["actor_user_id"]},{"name":"voice_sessions_persona_id_idx","columns":["persona_id"]},{"name":"voice_sessions_agent_session_id_idx","columns":["agent_session_id"]},{"name":"voice_sessions_chat_room_id_idx","columns":["chat_room_id"]},{"name":"voice_sessions_thread_id_idx","columns":["thread_id"]}],"version":"d5cfb90c"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:AgentSession":{"name":"agentsession","className":"AgentSession","qualifiedName":"@happyvertical/smrt-chat:AgentSession","collection":"agentsessions","description":"Agent conversation session.","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/models/AgentSession.ts","packageName":"@happyvertical/smrt-chat","fields":{"tenantId":{"type":"text","required":false,"_meta":{"sqlType":"UUID","nullable":true,"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false}}},"agentId":{"type":"text","required":true,"default":"","_meta":{"required":true}},"agentProfileId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-profiles:Profile"},"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},"enum":["active","closed","expired"]},"allowedTools":{"type":"text","required":false,"default":"[]"},"sessionContext":{"type":"text","required":false,"default":"{}","_meta":{"sensitive":true},"sensitive":true},"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, unknown>","isStatic":false,"isPublic":true},"setSessionContext":{"name":"setSessionContext","async":false,"parameters":[{"name":"ctx","type":"Record<string, unknown>","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, unknown>","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":{"skipApiCheck":true},"tenantScoped":{"mode":"optional"},"conflictColumns":["tenant_id","slug","context"]},"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 \\"agent_profile_id\\" UUID,\\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":""},"agent_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"participant_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"chat_room_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true,"nullsNotDistinct":true},{"name":"agent_sessions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"agent_sessions_agent_profile_id_idx","columns":["agent_profile_id"]},{"name":"agent_sessions_participant_profile_id_idx","columns":["participant_profile_id"]},{"name":"agent_sessions_chat_room_id_idx","columns":["chat_room_id"]}],"version":"56b10067"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatMessage":{"name":"chatmessage","className":"ChatMessage","qualifiedName":"@happyvertical/smrt-chat:ChatMessage","collection":"chatmessages","description":"Chat message. Internal model \u2014 all mutations must go through the membership-checked ChatService (S5 #1392).","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/models/ChatMessage.ts","packageName":"@happyvertical/smrt-chat","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"roomId":{"type":"foreignKey","required":true,"related":"ChatRoom","description":"The room in which this message was sent.","_meta":{"description":"The room in which this message was sent.","required":true}},"threadId":{"type":"foreignKey","required":false,"related":"ChatThread","description":"The discussion thread containing this message, when there is one.","_meta":{"description":"The discussion thread containing this message, when there is one."}},"senderProfileId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-profiles:Profile","description":"The person or assistant who sent this message.","_meta":{"description":"The person or assistant who sent this message."}},"agentSessionId":{"type":"foreignKey","required":false,"related":"AgentSession","description":"The assistant conversation associated with this message, when applicable.","_meta":{"description":"The assistant conversation associated with this message, when applicable."}},"content":{"type":"text","required":false,"default":"","description":"The text of the message shared with the conversation.","_meta":{"description":"The text of the message shared with the conversation."}},"messageType":{"type":"text","required":true,"default":"text","description":"The kind of message, such as text, a file, or an activity notice.","_meta":{"required":true,"description":"The kind of message, such as text, a file, or an activity notice."},"enum":["text","system","action","file","tool_call","tool_result"]},"role":{"type":"text","required":true,"default":"user","description":"Whether this message comes from a person, an assistant, or an automated action.","_meta":{"required":true,"description":"Whether this message comes from a person, an assistant, or an automated action."},"enum":["user","assistant","system","tool"]},"isEdited":{"type":"boolean","required":false,"default":false,"description":"Whether the message has changed since it was sent.","_meta":{"description":"Whether the message has changed since it was sent."}},"editedAt":{"type":"datetime","required":false,"description":"When the message was most recently edited.","_meta":{"description":"When the message was most recently edited."}},"isDeleted":{"type":"boolean","required":false,"default":false,"description":"Whether this message has been removed from the conversation.","_meta":{"description":"Whether this message has been removed from the conversation."}},"replyToMessageId":{"type":"foreignKey","required":false,"related":"ChatMessage","description":"The earlier message this reply responds to.","_meta":{"description":"The earlier message this reply responds to."}},"metadata":{"type":"text","required":false,"default":"{}","description":"Additional message details maintained by the application.","_meta":{"description":"Additional message details maintained by the application."}},"toolCallData":{"type":"text","required":false,"description":"Details of an automated action associated with this message.","_meta":{"description":"Details of an automated action associated with this message."}},"attachments":{"type":"text","required":false,"default":"[]","description":"Files shared alongside the text of this message.","_meta":{"description":"Files shared alongside the text of this message."}}},"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,"memberTypes":["string","number"]}],"returnType":"void","isStatic":false,"isPublic":true},"getMetadata":{"name":"getMetadata","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setMetadata":{"name":"setMetadata","async":false,"parameters":[{"name":"data","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getToolCallData":{"name":"getToolCallData","async":false,"parameters":[],"returnType":"Record<string, unknown> | null","isStatic":false,"isPublic":true},"setToolCallData":{"name":"setToolCallData","async":false,"parameters":[{"name":"data","type":"Record<string, unknown> | null","optional":false,"unionBranches":[{"type":"Record<string, unknown>"},{"type":"null"}]}],"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":{"skipApiCheck":true},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"ChatMessage","collectionExportName":"ChatMessageCollection","validationRules":[{"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,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"thread_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_threads","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"sender_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"agent_session_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"agent_sessions","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_messages_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_messages_room_id_idx","columns":["room_id"]},{"name":"chat_messages_thread_id_idx","columns":["thread_id"]},{"name":"chat_messages_sender_profile_id_idx","columns":["sender_profile_id"]},{"name":"chat_messages_agent_session_id_idx","columns":["agent_session_id"]},{"name":"chat_messages_reply_to_message_id_idx","columns":["reply_to_message_id"]}],"version":"cca14e75"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatParticipant":{"name":"chatparticipant","className":"ChatParticipant","qualifiedName":"@happyvertical/smrt-chat:ChatParticipant","collection":"chatparticipants","description":"Room membership row. Internal model \u2014 membership must be established and mutated only through the membership/owner-checked ChatService (S5 #1392).","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/models/ChatParticipant.ts","packageName":"@happyvertical/smrt-chat","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"roomId":{"type":"foreignKey","required":true,"related":"ChatRoom","description":"The room to which this membership belongs.","_meta":{"description":"The room to which this membership belongs.","required":true}},"profileId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-profiles:Profile","description":"The person or assistant participating in the room.","_meta":{"description":"The person or assistant participating in the room."}},"role":{"type":"text","required":true,"default":"member","description":"The member role that determines what they can do in the room.","_meta":{"required":true,"description":"The member role that determines what they can do in the room."},"enum":["owner","admin","member","viewer"]},"status":{"type":"text","required":true,"default":"active","description":"Whether this member is active, has left, was removed, or is banned.","_meta":{"required":true,"description":"Whether this member is active, has left, was removed, or is banned."},"enum":["active","left","kicked","banned"]},"onlineStatus":{"type":"text","required":true,"default":"offline","description":"The availability shown for this member, such as online or away.","_meta":{"required":true,"description":"The availability shown for this member, such as online or away."},"enum":["online","away","dnd","offline"]},"lastReadMessageId":{"type":"foreignKey","required":false,"related":"ChatMessage","description":"The most recent message this member has read.","_meta":{"description":"The most recent message this member has read."}},"lastSeenAt":{"type":"datetime","required":false,"description":"When this member was last seen in the conversation.","_meta":{"description":"When this member was last seen in the conversation."}},"joinedAt":{"type":"datetime","required":false,"description":"When this member joined the room.","_meta":{"description":"When this member joined the room."}},"nickname":{"type":"text","required":false,"default":"","description":"The display name this member uses within the room.","_meta":{"description":"The display name this member uses within the room."}},"isMuted":{"type":"boolean","required":false,"default":false,"description":"Whether notifications for this room are muted for this member.","_meta":{"description":"Whether notifications for this room are muted for this member."}},"isPinned":{"type":"boolean","required":false,"default":false,"description":"Whether this room is pinned for this member.","_meta":{"description":"Whether this room is pinned for this member."}}},"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":{"skipApiCheck":true},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"ChatParticipant","collectionExportName":"ChatParticipantCollection","validationRules":[{"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,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_participants_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_participants_room_id_idx","columns":["room_id"]},{"name":"chat_participants_profile_id_idx","columns":["profile_id"]},{"name":"chat_participants_last_read_message_id_idx","columns":["last_read_message_id"]}],"version":"07714046"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatReaction":{"name":"chatreaction","className":"ChatReaction","qualifiedName":"@happyvertical/smrt-chat:ChatReaction","collection":"chatreactions","description":"Message reaction. Internal model \u2014 reactions must be added/removed only through the membership-checked ChatService (S5 #1392).","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/models/ChatReaction.ts","packageName":"@happyvertical/smrt-chat","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"messageId":{"type":"foreignKey","required":true,"related":"ChatMessage","description":"The message to which this reaction was added.","_meta":{"description":"The message to which this reaction was added.","required":true}},"profileId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-profiles:Profile","description":"The person who added this reaction.","_meta":{"description":"The person who added this reaction."}},"emoji":{"type":"text","required":true,"default":"","description":"The symbol chosen to express a response to the message.","_meta":{"required":true,"description":"The symbol chosen to express a response to the message."}}},"methods":{},"decoratorConfig":{"tableName":"chat_reactions","api":{"include":["list"]},"mcp":{"include":["list"]},"cli":false,"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"ChatReaction","collectionExportName":"ChatReactionCollection","validationRules":[{"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,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"emoji":{"type":"TEXT","notNull":true,"unique":false,"default":""}},"indexes":[{"name":"chat_reactions_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_reactions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_reactions_message_id_idx","columns":["message_id"]},{"name":"chat_reactions_profile_id_idx","columns":["profile_id"]}],"version":"5b1969a6"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatRoom":{"name":"chatroom","className":"ChatRoom","qualifiedName":"@happyvertical/smrt-chat:ChatRoom","collection":"chatrooms","description":"Chat room supporting public channels, private groups, DMs, and agent conversations.","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/models/ChatRoom.ts","packageName":"@happyvertical/smrt-chat","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"name":{"type":"text","required":false,"default":"","description":"A recognizable name that helps teammates find this room.","_meta":{"description":"A recognizable name that helps teammates find this room."}},"description":{"type":"text","required":false,"default":"","description":"Explain the purpose of the room and who should join.","_meta":{"description":"Explain the purpose of the room and who should join."}},"roomType":{"type":"text","required":true,"default":"public","description":"Whether the room is public, private, a direct message, or an assistant conversation.","_meta":{"required":true,"description":"Whether the room is public, private, a direct message, or an assistant conversation."},"enum":["public","private","dm","agent"]},"status":{"type":"text","required":true,"default":"active","description":"Whether this room is active, archived, or deleted.","_meta":{"required":true,"description":"Whether this room is active, archived, or deleted."},"enum":["active","archived","deleted"]},"topic":{"type":"text","required":false,"default":"","description":"The current subject or focus of the room.","_meta":{"description":"The current subject or focus of the room."}},"avatarUrl":{"type":"text","required":false,"default":"","description":"The address of the image used to represent this room.","_meta":{"description":"The address of the image used to represent this room."}},"isArchived":{"type":"boolean","required":false,"default":false,"description":"Whether the room has been archived from active conversations.","_meta":{"description":"Whether the room has been archived from active conversations."}},"maxParticipants":{"type":"integer","required":false,"default":0,"description":"The maximum number of members; zero means no configured limit.","_meta":{"description":"The maximum number of members; zero means no configured limit."}},"metadata":{"type":"text","required":false,"default":"{}","description":"Additional room details maintained by the application.","_meta":{"description":"Additional room details maintained by the application."}},"createdByProfileId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-profiles:Profile","description":"The person who originally created this room.","_meta":{"description":"The person who originally created this room."}},"lastMessageAt":{"type":"datetime","required":false,"description":"When the most recent message was sent in this room.","_meta":{"description":"When the most recent message was sent in this room."}}},"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":{"skipApiCheck":true},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"ChatRoom","collectionExportName":"ChatRoomCollection","displayLabelField":"name","validationRules":[{"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_rooms_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_rooms_created_by_profile_id_idx","columns":["created_by_profile_id"]}],"version":"3665d881"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:ChatThread":{"name":"chatthread","className":"ChatThread","qualifiedName":"@happyvertical/smrt-chat:ChatThread","collection":"chatthreads","description":"Conversation thread. Internal model \u2014 threads must be created/mutated only through the membership-checked ChatService (S5 #1392).","filePath":"/home/runner/work/smrt/smrt/packages/chat/src/models/ChatThread.ts","packageName":"@happyvertical/smrt-chat","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"roomId":{"type":"foreignKey","required":true,"related":"ChatRoom","description":"The room containing this discussion thread.","_meta":{"description":"The room containing this discussion thread.","required":true}},"rootMessageId":{"type":"foreignKey","required":false,"related":"ChatMessage","description":"The message that started this thread, when it began as a reply.","_meta":{"description":"The message that started this thread, when it began as a reply.","nullable":true}},"title":{"type":"text","required":false,"default":"","description":"A short title describing the subject of this thread.","_meta":{"description":"A short title describing the subject of this thread."}},"isResolved":{"type":"boolean","required":false,"default":false,"description":"Whether the discussion has reached a resolution.","_meta":{"description":"Whether the discussion has reached a resolution."}},"messageCount":{"type":"integer","required":false,"default":0,"description":"The number of messages in this thread.","_meta":{"description":"The number of messages in this thread."}},"lastMessageAt":{"type":"datetime","required":false,"description":"When the most recent message was sent in this thread.","_meta":{"description":"When the most recent message was sent in this thread."}},"participantCount":{"type":"integer","required":false,"default":0,"description":"The number of people participating in this thread.","_meta":{"description":"The number of people participating in this thread."}}},"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":{"skipApiCheck":true},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"ChatThread","collectionExportName":"ChatThreadCollection","displayLabelField":"title","validationRules":[{"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,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"root_message_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_messages","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"chat_threads_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"chat_threads_room_id_idx","columns":["room_id"]},{"name":"chat_threads_root_message_id_idx","columns":["root_message_id"]}],"version":"e1ae958b"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:VoiceGatewayTurn":{"name":"voicegatewayturn","className":"VoiceGatewayTurn","qualifiedName":"@happyvertical/smrt-chat:VoiceGatewayTurn","collection":"voicegatewayturns","description":"Durable reservation for a gateway turn. The natural key makes turn_id replay checks concurrency-safe before transcript messages are written.","filePath":"/home/runner/work/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},"enum":["processing","completed","failed"]},"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":"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,"foreignKey":{"table":"voice_sessions","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"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_voice_session_id_gateway_turn_id_idx","columns":["voice_session_id","gateway_turn_id"],"unique":true},{"name":"voice_gateway_turns_slug_context_idx","columns":["slug","context"]},{"name":"voice_gateway_turns_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"c4d871b8"},"importPath":"@happyvertical/smrt-chat"},"@happyvertical/smrt-chat:VoiceSession":{"name":"voicesession","className":"VoiceSession","qualifiedName":"@happyvertical/smrt-chat:VoiceSession","collection":"voicesessions","description":"Short-lived binding proving a voice gateway turn belongs to an authenticated SMRT actor, persona, and chat session.","filePath":"/home/runner/work/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},"enum":["active","expired","revoked"]},"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, unknown>","isStatic":false,"isPublic":true},"setMetadata":{"name":"setMetadata","async":false,"parameters":[{"name":"metadata","type":"Record<string, unknown>","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":{"skipApiCheck":true},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"VoiceSession","collectionExportName":"VoiceSessionCollection","validationRules":[{"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,"foreignKey":{"table":"agent_sessions","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"chat_room_id":{"type":"UUID","referenceKind":"foreignKey","notNull":true,"unique":false,"foreignKey":{"table":"chat_rooms","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"thread_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"chat_threads","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"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_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"voice_sessions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"voice_sessions_actor_profile_id_idx","columns":["actor_profile_id"]},{"name":"voice_sessions_actor_user_id_idx","columns":["actor_user_id"]},{"name":"voice_sessions_persona_id_idx","columns":["persona_id"]},{"name":"voice_sessions_agent_session_id_idx","columns":["agent_session_id"]},{"name":"voice_sessions_chat_room_id_idx","columns":["chat_room_id"]},{"name":"voice_sessions_thread_id_idx","columns":["thread_id"]}],"version":"d5cfb90c"},"importPath":"@happyvertical/smrt-chat"}},"moduleType":"smrt","recipes":[{"id":"chat.assistant","className":"AssistantRecipe","label":"Assistant","summary":"Ask an AI assistant about the page you are on, from a dock in the app shell.","synonyms":["ai assistant","ai chat","copilot","chatbot","ask ai","helper"],"models":["@happyvertical/smrt-chat:AgentSession","@happyvertical/smrt-chat:ChatRoom","@happyvertical/smrt-chat:ChatParticipant","@happyvertical/smrt-chat:ChatThread","@happyvertical/smrt-chat:ChatMessage"],"nav":[],"requires":[],"help":{"markdown":"## Overview\\n\\nThe assistant is a chat panel that opens from a button in the app's top bar. It\\nsees the page you are on, so you can ask about what is in front of you and get\\nan answer without leaving it.\\n\\nYou can keep several conversations and come back to them later. The assistant\\nonly reaches the data and actions the app owner allows, and it works with your\\nown permissions: it cannot show you anything you could not open yourself.\\n\\n## Tasks\\n\\n### Ask a question\\n\\n1. Choose the assistant button in the top bar to open the panel.\\n2. Type your question and send it.\\n3. Read the reply as it arrives. Open the panel again from any page to carry on.\\n\\n### Start a new conversation\\n\\n1. Open the panel and choose the conversation list.\\n2. Start a new conversation, or pick an earlier one to carry on.\\n\\n### Approve a change\\n\\nWhen the assistant proposes a change, it shows what will happen and waits.\\n\\n1. Read the proposed change.\\n2. Confirm it to go ahead, or reject it. Nothing changes until you confirm.\\n\\n### Choose a model\\n\\nIf the app offers more than one model, pick one from the list in the panel\\nbefore you send a message.\\n\\n## What the app owner sets up\\n\\n- A model. Hosted models need the service key their provider issues, stored as\\n a secret in the app (\`OPENAI_API_KEY\`, \`ANTHROPIC_API_KEY\` or\\n \`GEMINI_API_KEY\`); only the key for the model the app uses is needed. Models\\n that run in the browser need no key.\\n- The tools the assistant may use. It is offered nothing unless the app lists\\n it, so an empty list means conversation only.\\n- Optionally, report tools. An app can let the assistant draft a report from a\\n request, preview it, and save it only after a person approves that exact\\n report.\\n","fieldRefs":[]},"surfaces":[{"kind":"shell-widget","slot":"header.end","export":"@happyvertical/smrt-chat/svelte#AssistantDock","label":"Assistant","icon":"bot"}],"providers":[{"id":"llm","kind":"llm","options":["openai","anthropic","gemini","webllm","bitgpu"],"required":true,"secrets":["OPENAI_API_KEY","ANTHROPIC_API_KEY","GEMINI_API_KEY"],"browserOptions":["webllm","bitgpu"]}],"runtime":"both","demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: node:crypto + node:async_hooks; and its package depends on @happyvertical/smrt-agents, @happyvertical/smrt-images, @happyvertical/smrt-jobs, @happyvertical/smrt-profiles, @happyvertical/smrt-reports, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3615, #3617, #3624, #3625, #3626, #3627, #3628).","Provider llm has an in-browser option (webllm, bitgpu)."]}},{"id":"chat.rooms","className":"ChatRoomsRecipe","label":"Team Chat","summary":"Organize team conversations in rooms with threads and reactions.","synonyms":["team chat","channels","group chat","conversations"],"models":["@happyvertical/smrt-chat:ChatRoom","@happyvertical/smrt-chat:ChatMessage","@happyvertical/smrt-chat:ChatParticipant","@happyvertical/smrt-chat:ChatThread","@happyvertical/smrt-chat:ChatReaction"],"nav":[{"label":"Chat rooms","model":"@happyvertical/smrt-chat:ChatRoom","icon":"users","description":"Team conversations organized by topic or audience.","noun":"chat room"}],"requires":[],"group":{"id":"team-collaboration","label":"Team collaboration","summary":"Keep conversations and shared work in one place."},"section":{"id":"team","label":"Team","icon":"users","description":"People and the conversations that keep them aligned."},"options":{"@happyvertical/smrt-chat:ChatRoom":{"fields":{"metadata":{"visibility":"hidden"},"createdByProfileId":{"visibility":"hidden"},"lastMessageAt":{"label":"Last message","order":1}}},"@happyvertical/smrt-chat:ChatMessage":{"fields":{"metadata":{"visibility":"hidden"},"toolCallData":{"visibility":"hidden"},"attachments":{"visibility":"advanced"}}},"@happyvertical/smrt-chat:ChatParticipant":{"fields":{"lastReadMessageId":{"visibility":"hidden"},"lastSeenAt":{"visibility":"advanced"}}}},"help":{"markdown":"## Overview\\n\\nTeam Chat keeps conversations in rooms so people can find the right discussion,\\nfollow threads, and see reactions without mixing unrelated work together. The\\nroom and message lists are read-only generated views. Create rooms, manage\\nmembers, and send messages through the app's authorized chat workflow.\\n\\n## Tasks\\n\\n### Find the right room\\n\\n1. Open **Chat rooms** from the navigation.\\n2. Search for a room by its **{field:ChatRoom.name}**, or use its\\n **{field:ChatRoom.topic}** to tell similar rooms apart.\\n3. Open the room and check **{field:ChatRoom.lastMessageAt}** to see where the\\n most recent discussion happened.\\n\\n### Follow a conversation\\n\\n1. Read the room messages and open a thread when you need the discussion in\\n one place.\\n2. Use the thread **{field:ChatThread.title}** to describe the subject when\\n your app supplies one.\\n3. Add a reaction by choosing the **{field:ChatReaction.emoji}** that best\\n communicates your response.\\n\\n### Keep a room useful\\n\\n1. Give the room a clear **{field:ChatRoom.name}** and a short\\n **{field:ChatRoom.description}**.\\n2. Set **{field:ChatRoom.roomType}** deliberately: public for broad team\\n discussion, private for restricted groups, and direct messages for one-to-one\\n conversations.\\n3. Use a focused **{field:ChatMessage.content}** so teammates can scan the\\n conversation and reply in context.\\n","fieldRefs":["ChatMessage.content","ChatReaction.emoji","ChatRoom.description","ChatRoom.lastMessageAt","ChatRoom.name","ChatRoom.roomType","ChatRoom.topic","ChatThread.title"]},"surfaces":[{"kind":"route","path":"/chat/rooms","export":"@happyvertical/smrt-chat/svelte#ChatLayout","label":"Team chat"}],"runtime":"both","demoSeed":{"export":"@happyvertical/smrt-chat/playground#chatRoomsFixture"},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: node:crypto + node:async_hooks; and its package depends on @happyvertical/smrt-agents, @happyvertical/smrt-images, @happyvertical/smrt-jobs, @happyvertical/smrt-profiles, @happyvertical/smrt-reports, @happyvertical/smrt-secrets, @happyvertical/smrt-tenancy, @happyvertical/smrt-users, which do not build for a browser (#3615, #3617, #3624, #3625, #3626, #3627, #3628)."]}}],"smrtDependencies":["@happyvertical/smrt-agents","@happyvertical/smrt-assets","@happyvertical/smrt-core","@happyvertical/smrt-images","@happyvertical/smrt-personas","@happyvertical/smrt-profiles","@happyvertical/smrt-reports","@happyvertical/smrt-tenancy","@happyvertical/smrt-users"],"browser":{"status":"server-only","issues":["#3615","#3617","#3624","#3625","#3626","#3627","#3628"],"reason":"node:crypto + node:async_hooks","via":["@happyvertical/smrt-agents","@happyvertical/smrt-images","@happyvertical/smrt-jobs","@happyvertical/smrt-profiles","@happyvertical/smrt-reports","@happyvertical/smrt-secrets","@happyvertical/smrt-tenancy","@happyvertical/smrt-users"]},"stampsConstructors":true}`));
11
11
  //#endregion
12
12
  //#region src/runtime-report-tools.ts
13
13
  var RUNTIME_REPORT_SOURCES_TOOL_SLUG = "reports.runtime.sources";
@@ -492,12 +492,38 @@ function asRecord(value) {
492
492
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
493
493
  }
494
494
  function parseToolArguments(raw) {
495
- if (!raw) return {};
495
+ if (raw === void 0 || raw === null || raw.trim() === "") return {};
496
+ let parsed;
496
497
  try {
497
- return asRecord(JSON.parse(raw));
498
+ parsed = JSON.parse(raw);
498
499
  } catch {
499
- return {};
500
+ return null;
500
501
  }
502
+ if (parsed === null) return {};
503
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
504
+ }
505
+ var TOOL_ARGUMENTS_MALFORMED = "TOOL_ARGUMENTS_MALFORMED";
506
+ var TOOL_ARGUMENTS_INVALID = "TOOL_ARGUMENTS_INVALID";
507
+ function malformedArgumentsError() {
508
+ return new ValidationError("The tool-call arguments were not a valid JSON object, so the tool did not run. Send the arguments as one JSON object, for example {\"field\": \"value\"}.", TOOL_ARGUMENTS_MALFORMED);
509
+ }
510
+ var READ_ARGUMENT_KEYS = /* @__PURE__ */ new Set([
511
+ "id",
512
+ "where",
513
+ "limit",
514
+ "offset"
515
+ ]);
516
+ function assertReadArguments(slug, args) {
517
+ const problems = [];
518
+ if (Object.keys(args).some((key) => !READ_ARGUMENT_KEYS.has(key))) problems.push("it accepts only id, where, limit and offset");
519
+ const present = (key) => Object.hasOwn(args, key) && args[key] !== void 0 && args[key] !== null;
520
+ if (present("id") && typeof args.id !== "string") problems.push("id must be a string");
521
+ if (present("where") && (typeof args.where !== "object" || Array.isArray(args.where))) problems.push("where must be an object of equality filters like {\"status\": \"open\"}");
522
+ for (const [key, min] of [["limit", 1], ["offset", 0]]) {
523
+ const value = args[key];
524
+ if (present(key) && (typeof value !== "number" || !Number.isInteger(value) || value < min)) problems.push(`${key} must be an integer of at least ${min}`);
525
+ }
526
+ if (problems.length > 0) throw new ValidationError(`'${slug}' arguments were rejected: ${problems.join("; ")}. Put equality filters inside where.`, TOOL_ARGUMENTS_INVALID);
501
527
  }
502
528
  function actionFromDefinition(def) {
503
529
  const collection = def.collection;
@@ -582,11 +608,18 @@ function toolParameters(tool) {
582
608
  },
583
609
  where: {
584
610
  type: "object",
585
- description: "Equality filters for a list."
611
+ description: "Equality filters for a list, e.g. {\"status\": \"open\"}. The only way to filter."
586
612
  },
587
- limit: { type: "number" },
588
- offset: { type: "number" }
589
- }
613
+ limit: {
614
+ type: "integer",
615
+ minimum: 1
616
+ },
617
+ offset: {
618
+ type: "integer",
619
+ minimum: 0
620
+ }
621
+ },
622
+ additionalProperties: false
590
623
  };
591
624
  case "create": return {
592
625
  type: "object",
@@ -664,6 +697,7 @@ async function invokeManifestTool(run, tool, args, options = {}) {
664
697
  const collection = await ObjectRegistry.getCollection(registryKeyFor(tool), db ? { db } : {});
665
698
  switch (tool.action) {
666
699
  case "read": {
700
+ assertReadArguments(tool.slug, args);
667
701
  const id = typeof args.id === "string" ? args.id : void 0;
668
702
  if (id) {
669
703
  const item = await collection.get(id);
@@ -714,7 +748,7 @@ async function invokeManifestTool(run, tool, args, options = {}) {
714
748
  }
715
749
  }
716
750
  async function runToolLoop(options) {
717
- const { ai, messages, tools, extraTools = [], principal, db, maxSteps = 8, model, temperature, maxTokens, toolChoice = "auto", executeTool, onInvocation, onToken, clientTools = [], initialSteps = 0, maxTotalTokens, initialTokens = 0, deadline, now = Date.now, signal, onStep, onUsage, onBehalfOfUserId, agentClass, audit, postgresRls, permissions } = options;
751
+ const { ai, messages, tools, extraTools = [], principal, db, maxSteps = 8, model, temperature, maxTokens, toolChoice = "auto", executeTool, onInvocation, onToken, clientTools = [], initialSteps = 0, maxTotalTokens, initialTokens = 0, deadline, now = Date.now, requestTimeoutMs, answerFromReasoning = false, onReasoning, signal, onStep, onUsage, onBehalfOfUserId, agentClass, audit, postgresRls, permissions } = options;
718
752
  const serverNames = /* @__PURE__ */ new Set([...tools.flatMap((tool) => [tool.slug, toolFunctionName(tool.slug)]), ...extraTools.flatMap((tool) => [tool.slug, tool.aiTool.function.name])]);
719
753
  const offeredClient = /* @__PURE__ */ new Map();
720
754
  for (const tool of clientTools) if (!serverNames.has(tool.name) && !offeredClient.has(tool.name)) offeredClient.set(tool.name, tool);
@@ -745,6 +779,23 @@ async function runToolLoop(options) {
745
779
  }, async (run) => {
746
780
  const working = [...messages];
747
781
  const invocations = [];
782
+ const priorReadOnlyCalls = /* @__PURE__ */ new Map();
783
+ const auditFailure = async (invocation) => {
784
+ if (!audit) return;
785
+ const record = toolFailureRecord(invocation);
786
+ if (!record) return;
787
+ try {
788
+ await audit({
789
+ action: "chat.tool_call_failed",
790
+ actorUserId: principal.runAsUserId,
791
+ onBehalfOfUserId: onBehalfOfUserId ?? null,
792
+ tenantId: principal.tenantId ?? null,
793
+ ...agentClass ? { agentClass } : {},
794
+ actsAsProfileId: principal.actsAsProfileId ?? null,
795
+ metadata: toolFailureAuditMetadata(record)
796
+ });
797
+ } catch {}
798
+ };
748
799
  let executedRounds = Math.max(0, Math.floor(initialSteps));
749
800
  let totalTokens = 0;
750
801
  let response;
@@ -757,21 +808,28 @@ async function runToolLoop(options) {
757
808
  totalTokens,
758
809
  pendingClientToolCalls: []
759
810
  });
760
- for (;;) {
761
- if (signal?.aborted) return cancelled();
762
- const budgetSpent = maxTotalTokens !== void 0 && initialTokens + totalTokens >= maxTotalTokens || deadline !== void 0 && now() >= deadline;
763
- const offerTools = aiTools.length > 0 && executedRounds < maxSteps && !budgetSpent;
764
- onStep?.({
765
- type: "round",
766
- step: executedRounds
767
- });
811
+ const timedOut = (emptyRetried, capReason) => ({
812
+ content: "",
813
+ steps: executedRounds,
814
+ stoppedReason: "timeout",
815
+ invocations,
816
+ messages: working,
817
+ totalTokens,
818
+ pendingClientToolCalls: [],
819
+ ...emptyRetried ? { emptyRetried } : {},
820
+ ...capReason ? { capReason } : {}
821
+ });
822
+ const budgetExhausted = () => maxTotalTokens !== void 0 && initialTokens + totalTokens >= maxTotalTokens || deadline !== void 0 && now() >= deadline;
823
+ const callModel = async (callMessages, withTools) => {
824
+ let result;
768
825
  try {
769
- response = await ai.chat(working, {
826
+ result = await ai.chat(callMessages, {
770
827
  model,
771
828
  temperature,
772
829
  maxTokens,
773
- tools: offerTools ? aiTools : void 0,
774
- toolChoice: offerTools ? toolChoice : "none",
830
+ tools: withTools ? aiTools : void 0,
831
+ toolChoice: withTools ? toolChoice : "none",
832
+ ...requestTimeoutMs !== void 0 ? { timeout: requestTimeoutMs } : {},
775
833
  ...onToken ? {
776
834
  stream: true,
777
835
  onProgress: onToken
@@ -779,28 +837,100 @@ async function runToolLoop(options) {
779
837
  ...signal ? { signal } : {}
780
838
  });
781
839
  } catch (error) {
782
- if (signal?.aborted) return cancelled();
840
+ if (signal?.aborted) return "cancelled";
841
+ if (isModelTimeoutError(error)) return "timeout";
783
842
  throw error;
784
843
  }
785
- totalTokens += response.usage?.totalTokens ?? 0;
786
- if (response.usage && onUsage) try {
844
+ totalTokens += result.usage?.totalTokens ?? 0;
845
+ if (result.usage && onUsage) try {
787
846
  onUsage({
788
- promptTokens: response.usage.promptTokens ?? 0,
789
- completionTokens: response.usage.completionTokens ?? 0,
790
- totalTokens: response.usage.totalTokens ?? 0,
791
- ...response.model || model ? { model: response.model ?? model } : {}
847
+ promptTokens: result.usage.promptTokens ?? 0,
848
+ completionTokens: result.usage.completionTokens ?? 0,
849
+ totalTokens: result.usage.totalTokens ?? 0,
850
+ ...result.model || model ? { model: result.model ?? model } : {}
792
851
  });
793
852
  } catch {}
853
+ noteFinishReason(ai, result.finishReason);
854
+ const reasoning = reasoningOf(result);
855
+ if (reasoning && onReasoning) try {
856
+ onReasoning(reasoning, executedRounds);
857
+ } catch {}
858
+ return result;
859
+ };
860
+ for (;;) {
861
+ if (signal?.aborted) return cancelled();
862
+ const budgetSpent = budgetExhausted();
863
+ const offerTools = aiTools.length > 0 && executedRounds < maxSteps && !budgetSpent;
864
+ onStep?.({
865
+ type: "round",
866
+ step: executedRounds
867
+ });
868
+ const forcedFinal = aiTools.length > 0 && !offerTools;
869
+ const outcome = await callModel(forcedFinal ? withAnswerNowInstruction(working) : working, offerTools);
870
+ if (outcome === "cancelled") return cancelled();
871
+ if (outcome === "timeout") return timedOut(false, forcedFinal ? executedRounds >= maxSteps ? "max_steps" : "budget" : void 0);
872
+ response = outcome;
794
873
  const toolCalls = offerTools ? response.toolCalls ?? [] : [];
795
- if (toolCalls.length === 0) return {
796
- content: response.content ?? "",
797
- steps: executedRounds,
798
- stoppedReason: aiTools.length === 0 ? "no_tools" : offerTools ? "stop" : executedRounds >= maxSteps ? "max_steps" : "budget",
799
- invocations,
800
- messages: working,
801
- totalTokens,
802
- pendingClientToolCalls: []
803
- };
874
+ if (toolCalls.length === 0) {
875
+ const stoppedReason = aiTools.length === 0 ? "no_tools" : offerTools ? "stop" : executedRounds >= maxSteps ? "max_steps" : "budget";
876
+ const capReason = forcedFinal ? executedRounds >= maxSteps ? "max_steps" : "budget" : void 0;
877
+ const first = response;
878
+ let final = first;
879
+ let emptyRetried = false;
880
+ const streamed = Boolean(onToken);
881
+ const firstSuspect = isSuspectedQuietTimeout(ai, first, streamed);
882
+ if (isBlank(first)) {
883
+ const retry = !budgetExhausted();
884
+ onStep?.({
885
+ type: "empty_round",
886
+ step: executedRounds,
887
+ retry,
888
+ ...first.finishReason ? { finishReason: first.finishReason } : {},
889
+ hasReasoning: reasoningOf(first) !== void 0,
890
+ suspectedTimeout: firstSuspect
891
+ });
892
+ if (retry) {
893
+ emptyRetried = true;
894
+ if (signal?.aborted) return cancelled();
895
+ const outcome2 = await callModel(withAnswerNowInstruction(working), false);
896
+ if (outcome2 === "cancelled") return cancelled();
897
+ if (outcome2 === "timeout") return timedOut(true, capReason);
898
+ final = outcome2;
899
+ if (isBlank(final)) onStep?.({
900
+ type: "empty_round",
901
+ step: executedRounds,
902
+ retry: false,
903
+ ...final.finishReason ? { finishReason: final.finishReason } : {},
904
+ hasReasoning: reasoningOf(final) !== void 0,
905
+ suspectedTimeout: isSuspectedQuietTimeout(ai, final, streamed)
906
+ });
907
+ }
908
+ }
909
+ const reasoning = reasoningOf(final) ?? reasoningOf(first);
910
+ let content = final.content ?? "";
911
+ let finalReason = stoppedReason;
912
+ let contentFromReasoning = false;
913
+ if (isBlank(final)) if (answerFromReasoning && reasoning) {
914
+ content = reasoning;
915
+ contentFromReasoning = true;
916
+ } else {
917
+ content = "";
918
+ finalReason = firstSuspect && (final === first || isSuspectedQuietTimeout(ai, final, streamed)) ? "timeout" : "empty";
919
+ }
920
+ return {
921
+ content,
922
+ steps: executedRounds,
923
+ stoppedReason: finalReason,
924
+ invocations,
925
+ messages: working,
926
+ totalTokens,
927
+ pendingClientToolCalls: [],
928
+ ...emptyRetried ? { emptyRetried } : {},
929
+ ...capReason ? { capReason } : {},
930
+ ...reasoning ? { reasoning } : {},
931
+ ...contentFromReasoning ? { contentFromReasoning } : {}
932
+ };
933
+ }
804
934
  working.push({
805
935
  role: "assistant",
806
936
  content: response.content ?? "",
@@ -809,10 +939,32 @@ async function runToolLoop(options) {
809
939
  const pendingClient = [];
810
940
  for (const call of toolCalls) {
811
941
  const requestedName = call.function.name;
812
- const args = parseToolArguments(call.function.arguments);
942
+ const parsedArgs = parseToolArguments(call.function.arguments);
943
+ const args = parsedArgs ?? {};
813
944
  const tool = offered.get(requestedName);
814
945
  const extraTool = tool ? void 0 : offeredExtra.get(requestedName);
815
946
  const clientTool = tool || extraTool ? void 0 : offeredClient.get(requestedName);
947
+ if (clientTool && parsedArgs === null) {
948
+ const malformed = {
949
+ slug: clientTool.name,
950
+ args: {},
951
+ ok: false,
952
+ rejected: false,
953
+ observation: toolErrorObservation(malformedArgumentsError(), "invalid_request"),
954
+ error: "invalid_request"
955
+ };
956
+ malformed.modelContent = serverObservationContent(malformed.observation);
957
+ invocations.push(malformed);
958
+ await auditFailure(malformed);
959
+ await onInvocation?.(malformed);
960
+ working.push({
961
+ role: "tool",
962
+ name: requestedName,
963
+ tool_call_id: call.id,
964
+ content: malformed.modelContent
965
+ });
966
+ continue;
967
+ }
816
968
  if (clientTool) {
817
969
  pendingClient.push({
818
970
  id: call.id,
@@ -847,6 +999,8 @@ async function runToolLoop(options) {
847
999
  location: "server"
848
1000
  });
849
1001
  let invocation;
1002
+ const dedupeKey = tool || extraTool ? readOnlyCallKey(tool, extraTool, slug, parsedArgs) : null;
1003
+ const prior = dedupeKey ? priorReadOnlyCalls.get(dedupeKey) : void 0;
850
1004
  if (!tool && !extraTool) invocation = {
851
1005
  slug,
852
1006
  args,
@@ -855,6 +1009,26 @@ async function runToolLoop(options) {
855
1009
  observation: { error: `Tool '${slug}' is not permitted for this persona.` },
856
1010
  error: "not_permitted"
857
1011
  };
1012
+ else if (prior) invocation = {
1013
+ slug,
1014
+ args,
1015
+ ok: prior.ok,
1016
+ rejected: prior.rejected,
1017
+ observation: {
1018
+ deduped: true,
1019
+ note: prior.ok ? TOOL_CALL_DEDUPED_NOTE : TOOL_CALL_DEDUPED_REJECTED_NOTE
1020
+ },
1021
+ ...prior.error ? { error: prior.error } : {},
1022
+ deduped: true
1023
+ };
1024
+ else if (parsedArgs === null) invocation = {
1025
+ slug,
1026
+ args,
1027
+ ok: false,
1028
+ rejected: false,
1029
+ observation: toolErrorObservation(malformedArgumentsError(), "invalid_request"),
1030
+ error: "invalid_request"
1031
+ };
858
1032
  else try {
859
1033
  invocation = {
860
1034
  slug,
@@ -883,7 +1057,25 @@ async function runToolLoop(options) {
883
1057
  error: kind
884
1058
  };
885
1059
  }
1060
+ invocation.modelContent = serverObservationContent(invocation.observation);
886
1061
  invocations.push(invocation);
1062
+ if ((tool || extraTool) && !isReadOnlyTool(tool, extraTool)) priorReadOnlyCalls.clear();
1063
+ else if (dedupeKey && !invocation.deduped && invocation.error !== "execution_error" && priorReadOnlyCalls.size < 64) priorReadOnlyCalls.set(dedupeKey, invocation);
1064
+ if (invocation.deduped && audit) try {
1065
+ await audit({
1066
+ action: "chat.tool_call_deduped",
1067
+ actorUserId: principal.runAsUserId,
1068
+ onBehalfOfUserId: onBehalfOfUserId ?? null,
1069
+ tenantId: principal.tenantId ?? null,
1070
+ ...agentClass ? { agentClass } : {},
1071
+ actsAsProfileId: principal.actsAsProfileId ?? null,
1072
+ metadata: {
1073
+ name: slug.slice(0, 128),
1074
+ deduped: true
1075
+ }
1076
+ });
1077
+ } catch {}
1078
+ else if (!invocation.ok) await auditFailure(invocation);
887
1079
  await onInvocation?.(invocation);
888
1080
  onStep?.({
889
1081
  type: "tool_result",
@@ -897,7 +1089,7 @@ async function runToolLoop(options) {
897
1089
  role: "tool",
898
1090
  name: requestedName,
899
1091
  tool_call_id: call.id,
900
- content: JSON.stringify(invocation.observation)
1092
+ content: invocation.modelContent
901
1093
  });
902
1094
  }
903
1095
  executedRounds += 1;
@@ -914,6 +1106,101 @@ async function runToolLoop(options) {
914
1106
  }
915
1107
  });
916
1108
  }
1109
+ var TOOL_LOOP_ANSWER_NOW_INSTRUCTION = "Tools are no longer available for this turn. Answer the user's question now from the tool results above, without calling tools. If they do not answer the question, say so.";
1110
+ function withAnswerNowInstruction(messages) {
1111
+ const last = messages.at(-1);
1112
+ if (last?.role === "user") return [...messages.slice(0, -1), {
1113
+ ...last,
1114
+ content: typeof last.content === "string" ? `${last.content}
1115
+
1116
+ ${TOOL_LOOP_ANSWER_NOW_INSTRUCTION}` : [...last.content, {
1117
+ type: "text",
1118
+ text: TOOL_LOOP_ANSWER_NOW_INSTRUCTION
1119
+ }]
1120
+ }];
1121
+ return [...messages, {
1122
+ role: "user",
1123
+ content: TOOL_LOOP_ANSWER_NOW_INSTRUCTION
1124
+ }];
1125
+ }
1126
+ var DEFAULT_EMPTY_ANSWER_FALLBACK = "I couldn't produce an answer to that. Please try again, or rephrase the question.";
1127
+ var FALLBACK_REPLY_METADATA_KEY = "fallback";
1128
+ function resolveTurnReply(result, fallback = DEFAULT_EMPTY_ANSWER_FALLBACK) {
1129
+ const content = result.content.trim();
1130
+ if (content) return { content };
1131
+ return {
1132
+ content: fallback.trim() || "I couldn't produce an answer to that. Please try again, or rephrase the question.",
1133
+ fallback: result.stoppedReason === "timeout" ? "timeout" : "empty"
1134
+ };
1135
+ }
1136
+ function replyContentFor(result, fallback) {
1137
+ return resolveTurnReply(result, fallback).content;
1138
+ }
1139
+ var STOP_REASONS = /* @__PURE__ */ new Set([
1140
+ "stop",
1141
+ "max_steps",
1142
+ "budget",
1143
+ "no_tools",
1144
+ "client_tools",
1145
+ "cancelled",
1146
+ "empty",
1147
+ "timeout"
1148
+ ]);
1149
+ function replyMetadataFor(result, reply) {
1150
+ const metadata = {};
1151
+ if (result.stoppedReason && STOP_REASONS.has(result.stoppedReason)) metadata.stoppedReason = result.stoppedReason;
1152
+ if (result.capReason === "max_steps" || result.capReason === "budget") metadata.capReason = result.capReason;
1153
+ if (reply.fallback) metadata[FALLBACK_REPLY_METADATA_KEY] = reply.fallback;
1154
+ return metadata;
1155
+ }
1156
+ var FALLBACK_HISTORY_PLACEHOLDER = "(No answer was given to this message.)";
1157
+ function isFallbackReply(message) {
1158
+ let metadata;
1159
+ try {
1160
+ metadata = typeof message.getMetadata === "function" ? message.getMetadata() : typeof message.metadata === "string" ? JSON.parse(message.metadata) : message.metadata;
1161
+ } catch {
1162
+ return false;
1163
+ }
1164
+ if (!metadata || typeof metadata !== "object") return false;
1165
+ const value = metadata[FALLBACK_REPLY_METADATA_KEY];
1166
+ return value === "empty" || value === "timeout";
1167
+ }
1168
+ var MAX_TOOL_LOOP_REASONING_CHARS = 4e3;
1169
+ function reasoningOf(response) {
1170
+ const raw = response.reasoning;
1171
+ if (typeof raw !== "string") return void 0;
1172
+ const trimmed = raw.trim();
1173
+ if (!trimmed) return void 0;
1174
+ return capCodePoints(trimmed, MAX_TOOL_LOOP_REASONING_CHARS);
1175
+ }
1176
+ function capCodePoints(value, max) {
1177
+ if (value.length <= max) return value;
1178
+ return Array.from(value.slice(0, max * 2)).slice(0, max).join("");
1179
+ }
1180
+ function isBlank(response) {
1181
+ return (response.content ?? "").trim() === "";
1182
+ }
1183
+ var finishReasonReporters = /* @__PURE__ */ new WeakSet();
1184
+ function noteFinishReason(ai, reason) {
1185
+ if (typeof reason === "string" && reason) finishReasonReporters.add(ai);
1186
+ }
1187
+ function reportsFinishReason(ai) {
1188
+ return finishReasonReporters.has(ai);
1189
+ }
1190
+ function isSuspectedQuietTimeout(ai, response, streamed) {
1191
+ return streamed && isBlank(response) && (response.toolCalls?.length ?? 0) === 0 && !response.finishReason && reportsFinishReason(ai);
1192
+ }
1193
+ var TIMEOUT_ERROR_CODES = /* @__PURE__ */ new Set([
1194
+ "AI_TIMEOUT",
1195
+ "TIMEOUT",
1196
+ "REQUEST_TIMEOUT"
1197
+ ]);
1198
+ function isModelTimeoutError(error) {
1199
+ if (!error || typeof error !== "object") return false;
1200
+ const { code, name } = error;
1201
+ if (typeof code === "string" && TIMEOUT_ERROR_CODES.has(code)) return true;
1202
+ return name === "TimeoutError" || name === "AbortError";
1203
+ }
917
1204
  var MAX_CLIENT_TOOLS = 64;
918
1205
  var MAX_CLIENT_TOOL_SCHEMA_BYTES = 8192;
919
1206
  var MAX_CLIENT_TOOL_RESULT_CHARS = 16e3;
@@ -993,9 +1280,92 @@ function appendClientToolResults(transcript, pending, results) {
993
1280
  }
994
1281
  return next;
995
1282
  }
1283
+ var MAX_SERVER_TOOL_OBSERVATION_CHARS = MAX_CLIENT_TOOL_RESULT_CHARS;
1284
+ var SERVER_TOOL_OBSERVATION_TRUNCATED_MARKER = " [truncated: this tool result was too large and was cut off, so it is incomplete. Do not treat it as the full result. Narrow the request and call the tool again: add a filter, project fewer fields, request a smaller page, or use a count.]";
1285
+ function serverObservationContent(observation) {
1286
+ let serialized;
1287
+ try {
1288
+ serialized = JSON.stringify(observation) ?? "null";
1289
+ } catch {
1290
+ return JSON.stringify({ error: "unserializable_result" });
1291
+ }
1292
+ return serialized.length > 16e3 ? `${sliceOnCodePoint(serialized, MAX_SERVER_TOOL_OBSERVATION_CHARS)}${SERVER_TOOL_OBSERVATION_TRUNCATED_MARKER}` : serialized;
1293
+ }
1294
+ function sliceOnCodePoint(value, max) {
1295
+ if (value.length <= max) return value;
1296
+ const code = value.charCodeAt(max - 1);
1297
+ const end = code >= 55296 && code <= 56319 ? max - 1 : max;
1298
+ return value.slice(0, end);
1299
+ }
996
1300
  function truncate(value, max = MAX_CLIENT_TOOL_RESULT_CHARS) {
997
- return value.length > max ? `${value.slice(0, max)}\u2026 [truncated]` : value;
1301
+ return value.length > max ? `${sliceOnCodePoint(value, max)}\u2026 [truncated]` : value;
1302
+ }
1303
+ var TOOL_CALL_DEDUPED_NOTE = "This exact call was already made in this turn; its result is above. Use it, or change the arguments.";
1304
+ var TOOL_CALL_DEDUPED_REJECTED_NOTE = "This exact call was already rejected above; repeating it will not work. Fix the arguments as the error says.";
1305
+ var MAX_DEDUPED_CALLS_PER_TURN = 64;
1306
+ var MAX_DEDUPE_KEY_CHARS = 4e3;
1307
+ var DEDUPABLE_EXTRA_TOOLS = /* @__PURE__ */ new Set([
1308
+ "data.discover",
1309
+ "data.inspect",
1310
+ "data.query"
1311
+ ]);
1312
+ function canonicalJson(value) {
1313
+ if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
1314
+ if (value && typeof value === "object") return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`).join(",")}}`;
1315
+ return JSON.stringify(value) ?? "null";
1316
+ }
1317
+ function isReadOnlyTool(tool, extraTool) {
1318
+ if (tool) return tool.action === "read";
1319
+ return extraTool ? DEDUPABLE_EXTRA_TOOLS.has(extraTool.slug) : false;
1320
+ }
1321
+ function readOnlyCallKey(tool, extraTool, slug, args) {
1322
+ if (args === null) return null;
1323
+ if (!isReadOnlyTool(tool, extraTool)) return null;
1324
+ let key;
1325
+ try {
1326
+ key = `${slug}\0${canonicalJson(args)}`;
1327
+ } catch {
1328
+ return null;
1329
+ }
1330
+ return key.length > MAX_DEDUPE_KEY_CHARS ? null : key;
1331
+ }
1332
+ var MAX_TOOL_FAILURE_ARGS_CHARS = 2e3;
1333
+ var STABLE_CODE = /^[A-Z0-9_]{1,64}$/;
1334
+ function toolFailureRecord(invocation) {
1335
+ if (invocation.ok) return null;
1336
+ if (invocation.deduped) return null;
1337
+ const errorKind = invocation.error ?? "execution_error";
1338
+ const observation = asRecord(invocation.observation);
1339
+ const code = typeof observation.code === "string" && STABLE_CODE.test(observation.code) ? observation.code : errorKind;
1340
+ let args = invocation.args;
1341
+ let argsChars = 0;
1342
+ try {
1343
+ argsChars = (JSON.stringify(args) ?? "").length;
1344
+ if (argsChars > 2e3) args = { truncated: true };
1345
+ } catch {
1346
+ args = { unserializable: true };
1347
+ }
1348
+ return {
1349
+ name: invocation.slug.slice(0, 128),
1350
+ args,
1351
+ argsChars,
1352
+ status: invocation.rejected ? "rejected" : "error",
1353
+ errorKind,
1354
+ errorCode: code,
1355
+ shown: invocation.modelContent ?? serverObservationContent(invocation.observation)
1356
+ };
1357
+ }
1358
+ function toolFailureAuditMetadata(record) {
1359
+ return {
1360
+ name: record.name,
1361
+ status: record.status,
1362
+ errorKind: record.errorKind,
1363
+ errorCode: record.errorCode,
1364
+ argsChars: record.argsChars,
1365
+ shownChars: record.shown.length
1366
+ };
998
1367
  }
1368
+ var TOOL_EXECUTION_ERROR_HINT = "The tool failed on the server; this was not caused by your arguments. Do not repeat the same call. Answer with what you already have; if that does not answer the question, say so and tell the user the data could not be read right now.";
999
1369
  function errorStatus(error) {
1000
1370
  if (!error || typeof error !== "object") return void 0;
1001
1371
  const { status, statusCode } = error;
@@ -1023,8 +1393,14 @@ function classifyToolError(error) {
1023
1393
  }
1024
1394
  function toolErrorObservation(error, kind) {
1025
1395
  const message = error instanceof Error ? error.message : String(error);
1396
+ const { publicMessage, code } = error ?? {};
1397
+ if (kind === "execution_error") return {
1398
+ error: message,
1399
+ kind,
1400
+ ...typeof code === "string" && /^[A-Z0-9_]{1,64}$/.test(code) ? { code } : {},
1401
+ hint: TOOL_EXECUTION_ERROR_HINT
1402
+ };
1026
1403
  if (kind !== "invalid_request") return { error: message };
1027
- const { publicMessage, code } = error;
1028
1404
  return {
1029
1405
  error: typeof publicMessage === "string" && publicMessage ? publicMessage : message,
1030
1406
  kind,
@@ -1127,6 +1503,18 @@ function createSessionContinuationStore(session, options = {}) {
1127
1503
  }
1128
1504
  };
1129
1505
  }
1506
+ function defaultFailedInvocationReply(failure) {
1507
+ return {
1508
+ content: failure.shown,
1509
+ messageType: "tool_result",
1510
+ toolCallData: {
1511
+ name: failure.name,
1512
+ args: failure.args,
1513
+ status: failure.status,
1514
+ errorCode: failure.errorCode
1515
+ }
1516
+ };
1517
+ }
1130
1518
  function defaultSerialize(message) {
1131
1519
  const candidate = message;
1132
1520
  return typeof candidate?.toJSON === "function" ? candidate.toJSON() : message;
@@ -1324,7 +1712,7 @@ async function runTurn(options, emit, status, serialize, describe, leg) {
1324
1712
  }
1325
1713
  return label;
1326
1714
  };
1327
- const sendAgentReply = author ? (await import("./ChatService-DjGf2AoJ.js").then((n) => n.r)).sendAgentReply : null;
1715
+ const sendAgentReply = author ? (await import("./ChatService-D0XuiCTk.js").then((n) => n.r)).sendAgentReply : null;
1328
1716
  const loop = await runToolLoop({
1329
1717
  ai: options.ai,
1330
1718
  messages,
@@ -1347,6 +1735,9 @@ async function runTurn(options, emit, status, serialize, describe, leg) {
1347
1735
  temperature: options.temperature,
1348
1736
  maxTokens: options.maxTokens,
1349
1737
  toolChoice: options.toolChoice,
1738
+ ...options.requestTimeoutMs !== void 0 ? { requestTimeoutMs: options.requestTimeoutMs } : {},
1739
+ ...options.answerFromReasoning ? { answerFromReasoning: true } : {},
1740
+ ...options.onReasoning ? { onReasoning: options.onReasoning } : {},
1350
1741
  signal: options.signal,
1351
1742
  onUsage: options.onUsage,
1352
1743
  permissions: options.permissions,
@@ -1361,6 +1752,7 @@ async function runTurn(options, emit, status, serialize, describe, leg) {
1361
1752
  });
1362
1753
  },
1363
1754
  onStep: (event) => {
1755
+ if (event.type === "empty_round") return;
1364
1756
  if (event.type === "round") {
1365
1757
  if (event.step > initialSteps) {
1366
1758
  emit({
@@ -1413,9 +1805,11 @@ async function runTurn(options, emit, status, serialize, describe, leg) {
1413
1805
  });
1414
1806
  },
1415
1807
  onInvocation: async (invocation) => {
1416
- if (!author || !sendAgentReply || !invocation.ok) return;
1417
- const reply = author.authorInvocation?.(invocation);
1418
- if (!reply) return;
1808
+ if (!author || !sendAgentReply) return;
1809
+ const failure = toolFailureRecord(invocation);
1810
+ if (!invocation.ok && !failure) return;
1811
+ const reply2 = failure ? author.authorFailedInvocation ? author.authorFailedInvocation(invocation) : defaultFailedInvocationReply(failure) : author.authorInvocation?.(invocation);
1812
+ if (!reply2) return;
1419
1813
  try {
1420
1814
  emit({
1421
1815
  type: "message",
@@ -1425,12 +1819,18 @@ async function runTurn(options, emit, status, serialize, describe, leg) {
1425
1819
  threadId: author.threadId ?? null,
1426
1820
  replyToMessageId: originMessageId ?? null,
1427
1821
  kind: "tool",
1428
- content: reply.content,
1429
- messageType: reply.messageType ?? "tool_result",
1430
- toolCallData: reply.toolCallData ?? null
1822
+ content: reply2.content,
1823
+ messageType: reply2.messageType ?? "tool_result",
1824
+ toolCallData: reply2.toolCallData ?? null,
1825
+ ...failure ? { metadata: {
1826
+ toolStatus: failure.status,
1827
+ errorKind: failure.errorKind,
1828
+ errorCode: failure.errorCode
1829
+ } } : {}
1431
1830
  }))
1432
1831
  });
1433
1832
  } catch (error) {
1833
+ if (failure) return;
1434
1834
  emit({
1435
1835
  type: "step",
1436
1836
  step: {
@@ -1503,7 +1903,9 @@ async function runTurn(options, emit, status, serialize, describe, leg) {
1503
1903
  ...originMessageId ? { originMessageId } : {}
1504
1904
  };
1505
1905
  }
1506
- const content = loop.content.trim() || "Done.";
1906
+ const reply = resolveTurnReply(loop, options.emptyAnswerFallback);
1907
+ const content = reply.content;
1908
+ const replyMetadata = replyMetadataFor(loop, reply);
1507
1909
  let finalMessage;
1508
1910
  if (author && sendAgentReply) {
1509
1911
  finalMessage = serialize(await sendAgentReply(author.chatService, {
@@ -1512,7 +1914,8 @@ async function runTurn(options, emit, status, serialize, describe, leg) {
1512
1914
  threadId: author.threadId ?? null,
1513
1915
  replyToMessageId: originMessageId ?? null,
1514
1916
  kind: "assistant",
1515
- content
1917
+ content,
1918
+ metadata: replyMetadata
1516
1919
  }));
1517
1920
  emit({
1518
1921
  type: "message",
@@ -1523,7 +1926,8 @@ async function runTurn(options, emit, status, serialize, describe, leg) {
1523
1926
  emit({
1524
1927
  type: "done",
1525
1928
  ...finalMessage ? { message: finalMessage } : {},
1526
- stoppedReason: loop.stoppedReason
1929
+ stoppedReason: loop.stoppedReason,
1930
+ ...loop.capReason ? { capReason: loop.capReason } : {}
1527
1931
  });
1528
1932
  emit(status({
1529
1933
  state: "done",
@@ -1531,6 +1935,7 @@ async function runTurn(options, emit, status, serialize, describe, leg) {
1531
1935
  }));
1532
1936
  return {
1533
1937
  stoppedReason: loop.stoppedReason,
1938
+ ...loop.capReason ? { capReason: loop.capReason } : {},
1534
1939
  content,
1535
1940
  loop,
1536
1941
  ...originMessageId ? { originMessageId } : {}
@@ -1699,6 +2104,12 @@ async function runPersonaConversationTurn(options) {
1699
2104
  model: options.model,
1700
2105
  temperature: options.temperature,
1701
2106
  maxTokens: options.maxTokens,
2107
+ ...options.toolChoice !== void 0 ? { toolChoice: options.toolChoice } : {},
2108
+ ...options.maxTotalTokens !== void 0 ? { maxTotalTokens: options.maxTotalTokens } : {},
2109
+ ...options.deadline !== void 0 ? { deadline: options.deadline } : {},
2110
+ ...options.requestTimeoutMs !== void 0 ? { requestTimeoutMs: options.requestTimeoutMs } : {},
2111
+ ...options.answerFromReasoning ? { answerFromReasoning: true } : {},
2112
+ ...options.onReasoning ? { onReasoning: options.onReasoning } : {},
1702
2113
  onBehalfOfUserId: options.onBehalfOfUserId,
1703
2114
  agentClass: persona.agentClass,
1704
2115
  postgresRls: options.postgresRls,
@@ -1706,16 +2117,22 @@ async function runPersonaConversationTurn(options) {
1706
2117
  permissions: options.permissions,
1707
2118
  onToken: options.onToken
1708
2119
  });
2120
+ const turnReply = resolveTurnReply(result, options.emptyAnswerFallback);
2121
+ const reply = turnReply.content;
1709
2122
  let authoredMessages;
1710
2123
  if (options.chatService && options.session?.id) authoredMessages = await authorConversationReply({
1711
2124
  chatService: options.chatService,
1712
2125
  session: options.session,
1713
2126
  tenantId,
1714
2127
  threadId: options.threadId ?? null,
1715
- result
2128
+ result,
2129
+ reply,
2130
+ metadata: replyMetadataFor(result, turnReply)
1716
2131
  });
1717
2132
  return {
1718
2133
  result,
2134
+ reply,
2135
+ ...turnReply.fallback ? { replyFallback: turnReply.fallback } : {},
1719
2136
  correlationId,
1720
2137
  recalled,
1721
2138
  systemPrompt,
@@ -1733,10 +2150,36 @@ async function bindPersonaToSession(options) {
1733
2150
  });
1734
2151
  }
1735
2152
  async function authorConversationReply(input) {
1736
- const { sendAgentReply } = await import("./ChatService-DjGf2AoJ.js").then((n) => n.r);
2153
+ const { sendAgentReply } = await import("./ChatService-D0XuiCTk.js").then((n) => n.r);
1737
2154
  const toolMessages = [];
1738
2155
  for (const invocation of input.result.invocations) {
1739
- if (!invocation.ok) continue;
2156
+ if (!invocation.ok) {
2157
+ const record = toolFailureRecord(invocation);
2158
+ if (!record) continue;
2159
+ try {
2160
+ const message2 = await sendAgentReply(input.chatService, {
2161
+ tenantId: input.tenantId,
2162
+ agentSessionId: input.session.id,
2163
+ threadId: input.threadId,
2164
+ content: record.shown,
2165
+ kind: "tool",
2166
+ messageType: "tool_result",
2167
+ toolCallData: {
2168
+ name: record.name,
2169
+ args: record.args,
2170
+ status: record.status,
2171
+ errorCode: record.errorCode
2172
+ },
2173
+ metadata: {
2174
+ toolStatus: record.status,
2175
+ errorKind: record.errorKind,
2176
+ errorCode: record.errorCode
2177
+ }
2178
+ });
2179
+ toolMessages.push(message2);
2180
+ } catch {}
2181
+ continue;
2182
+ }
1740
2183
  const message = await sendAgentReply(input.chatService, {
1741
2184
  tenantId: input.tenantId,
1742
2185
  agentSessionId: input.session.id,
@@ -1746,7 +2189,8 @@ async function authorConversationReply(input) {
1746
2189
  messageType: "tool_result",
1747
2190
  toolCallData: {
1748
2191
  name: invocation.slug,
1749
- args: invocation.args
2192
+ args: invocation.args,
2193
+ ...invocation.deduped ? { deduped: true } : {}
1750
2194
  }
1751
2195
  });
1752
2196
  toolMessages.push(message);
@@ -1757,8 +2201,9 @@ async function authorConversationReply(input) {
1757
2201
  tenantId: input.tenantId,
1758
2202
  agentSessionId: input.session.id,
1759
2203
  threadId: input.threadId,
1760
- content: input.result.content,
1761
- kind: "assistant"
2204
+ content: input.reply,
2205
+ kind: "assistant",
2206
+ ...input.metadata ? { metadata: input.metadata } : {}
1762
2207
  })
1763
2208
  };
1764
2209
  }
@@ -1767,6 +2212,7 @@ async function authorConversationReply(input) {
1767
2212
  var MAX_CHAT_STREAM_MESSAGES = 50;
1768
2213
  var MAX_CHAT_STREAM_CONTENT_LENGTH = 12e3;
1769
2214
  var DEFAULT_CHAT_STREAM_HEARTBEAT_MS = 15e3;
2215
+ var CHAT_STREAM_TIMEOUT_ERROR = "The model did not answer in time. Please try again.";
1770
2216
  var ChatStreamError = class extends Error {
1771
2217
  status;
1772
2218
  code;
@@ -1791,7 +2237,7 @@ var ChatStreamUnauthorizedError = class extends ChatStreamError {
1791
2237
  };
1792
2238
  async function* runChatConversationStream(options) {
1793
2239
  const { context } = options;
1794
- const { history, userMessage } = splitConversation(normalizeMessages(options.messages));
2240
+ const { history, userMessage } = splitConversation(normalizeMessages(options.messages), fallbackTexts(context.emptyAnswerFallback));
1795
2241
  if (!userMessage) {
1796
2242
  yield {
1797
2243
  type: "error",
@@ -1833,6 +2279,8 @@ async function* streamPersonaConversation(context, binding, history, userMessage
1833
2279
  temperature: context.temperature,
1834
2280
  maxTokens: context.maxTokens,
1835
2281
  maxSteps: context.maxSteps,
2282
+ ...context.requestTimeoutMs !== void 0 ? { requestTimeoutMs: context.requestTimeoutMs } : {},
2283
+ ...context.emptyAnswerFallback !== void 0 ? { emptyAnswerFallback: context.emptyAnswerFallback } : {},
1836
2284
  onBehalfOfUserId: binding.onBehalfOfUserId,
1837
2285
  audit: binding.audit,
1838
2286
  postgresRls: binding.postgresRls,
@@ -1883,24 +2331,48 @@ async function* streamPlainConversation(context, history, userMessage) {
1883
2331
  content: userMessage
1884
2332
  });
1885
2333
  let content = "";
1886
- try {
1887
- for await (const chunk of context.ai.stream(messages, {
1888
- model: context.model,
1889
- temperature: context.temperature,
1890
- maxTokens: context.maxTokens
1891
- })) if (chunk) {
1892
- content += chunk;
2334
+ let finishReason;
2335
+ let suspectedTimeout = false;
2336
+ for (let attempt = 0; attempt < 2; attempt += 1) {
2337
+ content = "";
2338
+ finishReason = void 0;
2339
+ try {
2340
+ for await (const chunk of context.ai.stream(messages, {
2341
+ model: context.model,
2342
+ temperature: context.temperature,
2343
+ maxTokens: context.maxTokens,
2344
+ ...context.requestTimeoutMs !== void 0 ? { timeout: context.requestTimeoutMs } : {},
2345
+ onFinishReason: (reason) => {
2346
+ finishReason = reason;
2347
+ noteFinishReason(context.ai, reason);
2348
+ }
2349
+ })) if (chunk) {
2350
+ content += chunk;
2351
+ yield {
2352
+ type: "token",
2353
+ text: chunk
2354
+ };
2355
+ }
2356
+ } catch (error) {
1893
2357
  yield {
1894
- type: "token",
1895
- text: chunk
2358
+ type: "error",
2359
+ error: toErrorMessage(error)
1896
2360
  };
2361
+ return;
1897
2362
  }
1898
- } catch (error) {
1899
- yield {
1900
- type: "error",
1901
- error: toErrorMessage(error)
1902
- };
1903
- return;
2363
+ if (content.trim()) break;
2364
+ const quiet = finishReason === void 0 && reportsFinishReason(context.ai);
2365
+ suspectedTimeout = attempt === 0 ? quiet : suspectedTimeout && quiet;
2366
+ }
2367
+ if (!content.trim()) {
2368
+ if (suspectedTimeout) {
2369
+ yield {
2370
+ type: "error",
2371
+ error: CHAT_STREAM_TIMEOUT_ERROR
2372
+ };
2373
+ return;
2374
+ }
2375
+ content = replyContentFor({ content }, context.emptyAnswerFallback);
1904
2376
  }
1905
2377
  yield {
1906
2378
  type: "done",
@@ -2044,7 +2516,10 @@ function normalizeMessages(messages) {
2044
2516
  }
2045
2517
  return out;
2046
2518
  }
2047
- function splitConversation(messages) {
2519
+ function fallbackTexts(configured) {
2520
+ return /* @__PURE__ */ new Set([replyContentFor({ content: "" }, configured), DEFAULT_EMPTY_ANSWER_FALLBACK]);
2521
+ }
2522
+ function splitConversation(messages, fallbacks) {
2048
2523
  let lastUserIndex = -1;
2049
2524
  for (let i = messages.length - 1; i >= 0; i -= 1) if (messages[i].role === "user") {
2050
2525
  lastUserIndex = i;
@@ -2057,7 +2532,7 @@ function splitConversation(messages) {
2057
2532
  return {
2058
2533
  history: messages.slice(0, lastUserIndex).map((message) => ({
2059
2534
  role: message.role,
2060
- content: message.content
2535
+ content: message.role === "assistant" && fallbacks.has(message.content.trim()) ? FALLBACK_HISTORY_PLACEHOLDER : message.content
2061
2536
  })),
2062
2537
  userMessage: messages[lastUserIndex].content
2063
2538
  };
@@ -2065,7 +2540,7 @@ function splitConversation(messages) {
2065
2540
  function resolvePersonaDoneMessage(turn) {
2066
2541
  const persisted = turn.authoredMessages?.assistantMessage;
2067
2542
  if (persisted) return toStreamMessage(persisted);
2068
- return synthesizeAssistantMessage(turn.result.content);
2543
+ return synthesizeAssistantMessage(turn.reply);
2069
2544
  }
2070
2545
  function toWireRole(role) {
2071
2546
  return role === "user" || role === "system" ? role : "assistant";
@@ -2121,6 +2596,6 @@ function corsHeaders(request, allowedOrigins, allowCredentials) {
2121
2596
  return headers;
2122
2597
  }
2123
2598
  //#endregion
2124
- export { MAX_CLIENT_TOOLS as A, RUNTIME_REPORT_DEFINE_FUNCTION_NAME as B, SESSION_CONTINUATIONS_FIELD as C, runAssistantTurn as D, createSessionContinuationStore as E, classifyToolError as F, RUNTIME_REPORT_RUN_TOOL_SLUG as G, RUNTIME_REPORT_LIST_FUNCTION_NAME as H, invokeManifestTool as I, createRuntimeReportTools as J, RUNTIME_REPORT_SOURCES_FUNCTION_NAME as K, manifestToolToAITool as L, MAX_CLIENT_TOOL_SCHEMA_BYTES as M, appendClientToolResults as N, CLIENT_TOOL_RESULT_GUIDANCE as O, buildManifestToolCatalog as P, runToolLoop as R, DEFAULT_CONTINUATION_TTL_MS as S, createMemoryContinuationStore as T, RUNTIME_REPORT_LIST_TOOL_SLUG as U, RUNTIME_REPORT_DEFINE_TOOL_SLUG as V, RUNTIME_REPORT_RUN_FUNCTION_NAME as W, runPersonaConversationTurn as _, MAX_CHAT_STREAM_CONTENT_LENGTH as a, CONTINUATION_CLAIM_TTL_MS as b, encodeChatStreamEvent as c, conversationPersonaFromAgentPersona as d, conversationPersonaFromResolved as f, resolveConversationInstructions as g, recallPersonaMemory as h, DEFAULT_CHAT_STREAM_HEARTBEAT_MS as i, MAX_CLIENT_TOOL_RESULT_CHARS as j, DEFAULT_MAX_STEPS as k, runChatConversationStream as l, principalBindingFor as m, ChatStreamError as n, MAX_CHAT_STREAM_MESSAGES as o, formatRecalledMemory as p, RUNTIME_REPORT_SOURCES_TOOL_SLUG as q, ChatStreamUnauthorizedError as r, createChatStreamHandler as s, ChatStreamBadRequestError as t, bindPersonaToSession as u, ASSISTANT_TURN_GENERIC_ERROR as v, createAssistantTurnResponse as w, DEFAULT_ASSISTANT_TURN_HEARTBEAT_MS as x, AssistantTurnUserError as y, sanitizeClientToolDeclarations as z };
2599
+ export { replyMetadataFor as $, DEFAULT_EMPTY_ANSWER_FALLBACK as A, MAX_TOOL_LOOP_REASONING_CHARS as B, DEFAULT_CONTINUATION_TTL_MS as C, createSessionContinuationStore as D, createMemoryContinuationStore as E, MAX_CLIENT_TOOL_RESULT_CHARS as F, TOOL_LOOP_ANSWER_NOW_INSTRUCTION as G, TOOL_CALL_DEDUPED_NOTE as H, MAX_CLIENT_TOOL_SCHEMA_BYTES as I, classifyToolError as J, appendClientToolResults as K, MAX_DEDUPED_CALLS_PER_TURN as L, FALLBACK_HISTORY_PLACEHOLDER as M, FALLBACK_REPLY_METADATA_KEY as N, runAssistantTurn as O, MAX_CLIENT_TOOLS as P, replyContentFor as Q, MAX_SERVER_TOOL_OBSERVATION_CHARS as R, DEFAULT_ASSISTANT_TURN_HEARTBEAT_MS as S, createAssistantTurnResponse as T, TOOL_CALL_DEDUPED_REJECTED_NOTE as U, SERVER_TOOL_OBSERVATION_TRUNCATED_MARKER as V, TOOL_EXECUTION_ERROR_HINT as W, isFallbackReply as X, invokeManifestTool as Y, manifestToolToAITool as Z, resolveConversationInstructions as _, DEFAULT_CHAT_STREAM_HEARTBEAT_MS as a, RUNTIME_REPORT_DEFINE_FUNCTION_NAME as at, AssistantTurnUserError as b, createChatStreamHandler as c, RUNTIME_REPORT_LIST_TOOL_SLUG as ct, bindPersonaToSession as d, RUNTIME_REPORT_SOURCES_FUNCTION_NAME as dt, resolveTurnReply as et, conversationPersonaFromAgentPersona as f, RUNTIME_REPORT_SOURCES_TOOL_SLUG as ft, recallPersonaMemory as g, principalBindingFor as h, ChatStreamUnauthorizedError as i, toolFailureRecord as it, DEFAULT_MAX_STEPS as j, CLIENT_TOOL_RESULT_GUIDANCE as k, encodeChatStreamEvent as l, RUNTIME_REPORT_RUN_FUNCTION_NAME as lt, formatRecalledMemory as m, ChatStreamBadRequestError as n, sanitizeClientToolDeclarations as nt, MAX_CHAT_STREAM_CONTENT_LENGTH as o, RUNTIME_REPORT_DEFINE_TOOL_SLUG as ot, conversationPersonaFromResolved as p, createRuntimeReportTools as pt, buildManifestToolCatalog as q, ChatStreamError as r, toolFailureAuditMetadata as rt, MAX_CHAT_STREAM_MESSAGES as s, RUNTIME_REPORT_LIST_FUNCTION_NAME as st, CHAT_STREAM_TIMEOUT_ERROR as t, runToolLoop as tt, runChatConversationStream as u, RUNTIME_REPORT_RUN_TOOL_SLUG as ut, runPersonaConversationTurn as v, SESSION_CONTINUATIONS_FIELD as w, CONTINUATION_CLAIM_TTL_MS as x, ASSISTANT_TURN_GENERIC_ERROR as y, MAX_TOOL_FAILURE_ARGS_CHARS as z };
2125
2600
 
2126
- //# sourceMappingURL=chat-stream-DJuup0go.js.map
2601
+ //# sourceMappingURL=chat-stream-CsD8FwnS.js.map