@happyvertical/smrt-agents 0.38.19 → 0.38.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import { a as getAgentTypeName, i as getAgentTypeAliases, n as AgentConfigCollection, r as getAgentClassName, t as AgentConfig } from "./chunks/config-C73buv9Y.js";
1
+ import { a as getAgentTypeName, i as getAgentTypeAliases, n as AgentConfigCollection, o as instanceScopedSubscriber, r as getAgentClassName, t as AgentConfig } from "./chunks/config-BRQLhsFp.js";
2
2
  import { AgentUIRegistry, createUIRegistry } from "./ui.js";
3
3
  import { LearningMemory, ObjectRegistry, SmrtCollection, SmrtObject, createDispatchBus, field, getClassConfigResolvers, getConfigResolver, isLazyConfigSentinel, listConfigResolvers, registerConfigResolver, resetConfigResolvers, resolveDispatchTenantScope, resolveLazyConfig, smrt, unregisterConfigResolver } from "@happyvertical/smrt-core";
4
4
  import { createLogger } from "@happyvertical/logger";
5
5
  import { sanitizeConfig } from "@happyvertical/smrt-config";
6
6
  import { TenantScoped, getCurrentTenant, queryGlobal, queryWithGlobals, tenantId, withTenant } from "@happyvertical/smrt-tenancy";
7
7
  import { SecretService } from "@happyvertical/smrt-secrets";
8
- import { TenantCollection } from "@happyvertical/smrt-users";
8
+ import { TenantCollection, assertOperationPermission, withPrincipalPermissionContext } from "@happyvertical/smrt-users";
9
9
  //#region src/__smrt-register__.ts
10
- ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":1783562551157,\"packageName\":\"@happyvertical/smrt-agents\",\"packageVersion\":\"0.38.19\",\"objects\":{\"@happyvertical/smrt-agents:Agent\":{\"name\":\"agent\",\"className\":\"Agent\",\"qualifiedName\":\"@happyvertical/smrt-agents:Agent\",\"collection\":\"agents\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/agents/src/agent.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"fields\":{\"created_at\":{\"type\":\"datetime\",\"required\":false},\"updated_at\":{\"type\":\"datetime\",\"required\":false},\"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}}},\"status\":{\"type\":\"text\",\"required\":false,\"default\":\"idle\"}},\"methods\":{\"getAiUsageSnapshot\":{\"name\":\"getAiUsageSnapshot\",\"async\":false,\"parameters\":[],\"returnType\":\"AiUsageSnapshot | undefined\",\"isStatic\":false,\"isPublic\":true},\"resetAiUsage\":{\"name\":\"resetAiUsage\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"listAiUsage\":{\"name\":\"listAiUsage\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"AiUsageListOptions\",\"optional\":true}],\"returnType\":\"Promise<SmrtAiUsageRecord[]>\",\"isStatic\":false,\"isPublic\":true},\"summarizeAiUsage\":{\"name\":\"summarizeAiUsage\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"AiUsageSummaryOptions\",\"optional\":true}],\"returnType\":\"Promise<Record<string, AiUsageStats>>\",\"isStatic\":false,\"isPublic\":true},\"destroy\":{\"name\":\"destroy\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"markAsPersisted\":{\"name\":\"markAsPersisted\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"requireInsertOnSave\":{\"name\":\"requireInsertOnSave\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"initialize\":{\"name\":\"initialize\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise\",\"isStatic\":false,\"isPublic\":true},\"loadDataFromDb\":{\"name\":\"loadDataFromDb\",\"async\":true,\"parameters\":[{\"name\":\"data\",\"type\":\"Record<string>\",\"optional\":false}],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"getFields\":{\"name\":\"getFields\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<any>\",\"isStatic\":false,\"isPublic\":true},\"toJSON\":{\"name\":\"toJSON\",\"async\":false,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"toPlainObject\":{\"name\":\"toPlainObject\",\"async\":false,\"parameters\":[],\"returnType\":\"Record<string>\",\"isStatic\":false,\"isPublic\":true},\"toPublicJSON\":{\"name\":\"toPublicJSON\",\"async\":false,\"parameters\":[{\"name\":\"options\",\"type\":\"PublicJsonOptions\",\"optional\":true}],\"returnType\":\"Record<string>\",\"isStatic\":false,\"isPublic\":true},\"getId\":{\"name\":\"getId\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"getSlug\":{\"name\":\"getSlug\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"getSavedId\":{\"name\":\"getSavedId\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"isSaved\":{\"name\":\"isSaved\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"save\":{\"name\":\"save\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"classifyConstraintError\":{\"name\":\"classifyConstraintError\",\"async\":false,\"parameters\":[{\"name\":\"message\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"'unique' | 'not_null' | null\",\"isStatic\":true,\"isPublic\":true},\"loadFromId\":{\"name\":\"loadFromId\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"loadFromSlug\":{\"name\":\"loadFromSlug\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"is\":{\"name\":\"is\",\"async\":true,\"parameters\":[{\"name\":\"criteria\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"AiOperationOptions\",\"optional\":true}],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"do\":{\"name\":\"do\",\"async\":true,\"parameters\":[{\"name\":\"instructions\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"AiOperationOptions\",\"optional\":true}],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"describe\":{\"name\":\"describe\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"AiOperationOptions\",\"optional\":true}],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"delete\":{\"name\":\"delete\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"isRelatedLoaded\":{\"name\":\"isRelatedLoaded\",\"async\":false,\"parameters\":[{\"name\":\"fieldName\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"_setLoadedRelationship\":{\"name\":\"_setLoadedRelationship\",\"async\":false,\"parameters\":[{\"name\":\"fieldName\",\"type\":\"string\",\"optional\":false},{\"name\":\"value\",\"type\":\"any\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"loadRelated\":{\"name\":\"loadRelated\",\"async\":true,\"parameters\":[{\"name\":\"fieldName\",\"type\":\"string\",\"optional\":false},{\"name\":\"opts\",\"type\":\"LoadRelatedOptions\",\"optional\":true}],\"returnType\":\"Promise<any>\",\"isStatic\":false,\"isPublic\":true},\"loadRelatedMany\":{\"name\":\"loadRelatedMany\",\"async\":true,\"parameters\":[{\"name\":\"fieldName\",\"type\":\"string\",\"optional\":false},{\"name\":\"opts\",\"type\":\"LoadRelatedOptions\",\"optional\":true}],\"returnType\":\"Promise<any[]>\",\"isStatic\":false,\"isPublic\":true},\"getRelated\":{\"name\":\"getRelated\",\"async\":true,\"parameters\":[{\"name\":\"fieldName\",\"type\":\"string\",\"optional\":false},{\"name\":\"opts\",\"type\":\"LoadRelatedOptions\",\"optional\":true}],\"returnType\":\"Promise<any>\",\"isStatic\":false,\"isPublic\":true},\"getAvailableTools\":{\"name\":\"getAvailableTools\",\"async\":false,\"parameters\":[],\"returnType\":\"AITool[]\",\"isStatic\":false,\"isPublic\":true},\"executeToolCall\":{\"name\":\"executeToolCall\",\"async\":true,\"parameters\":[{\"name\":\"toolCall\",\"type\":\"ToolCall\",\"optional\":false}],\"returnType\":\"Promise<ToolCallResult>\",\"isStatic\":false,\"isPublic\":true},\"remember\":{\"name\":\"remember\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"recall\":{\"name\":\"recall\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":false}],\"returnType\":\"Promise\",\"isStatic\":false,\"isPublic\":true},\"recallAll\":{\"name\":\"recallAll\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<Map<string>>\",\"isStatic\":false,\"isPublic\":true},\"forget\":{\"name\":\"forget\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"forgetScope\":{\"name\":\"forgetScope\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":false}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"generateEmbeddings\":{\"name\":\"generateEmbeddings\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"GenerateEmbeddingsOptions\",\"optional\":true}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"getEmbedding\":{\"name\":\"getEmbedding\",\"async\":true,\"parameters\":[{\"name\":\"fieldName\",\"type\":\"string\",\"optional\":false},{\"name\":\"model\",\"type\":\"string\",\"optional\":true}],\"returnType\":\"Promise<number[] | null>\",\"isStatic\":false,\"isPublic\":true},\"hasStaleEmbeddings\":{\"name\":\"hasStaleEmbeddings\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<boolean>\",\"isStatic\":false,\"isPublic\":true},\"clearEmbeddings\":{\"name\":\"clearEmbeddings\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"getUISlots\":{\"name\":\"getUISlots\",\"async\":false,\"parameters\":[],\"returnType\":\"AgentUISlots\",\"isStatic\":false,\"isPublic\":true},\"loadConfigs\":{\"name\":\"loadConfigs\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Map<string, Record<string>>>\",\"isStatic\":false,\"isPublic\":true},\"saveSlotConfig\":{\"name\":\"saveSlotConfig\",\"async\":true,\"parameters\":[{\"name\":\"slotId\",\"type\":\"string\",\"optional\":false},{\"name\":\"data\",\"type\":\"Record<string>\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"getMergedConfig\":{\"name\":\"getMergedConfig\",\"async\":true,\"parameters\":[{\"name\":\"slotId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Record<string>>\",\"isStatic\":false,\"isPublic\":true},\"exportConfig\":{\"name\":\"exportConfig\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<Record<string>>\",\"isStatic\":false,\"isPublic\":true},\"getDispatch\":{\"name\":\"getDispatch\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<DispatchBus>\",\"isStatic\":false,\"isPublic\":true},\"handleDispatch\":{\"name\":\"handleDispatch\",\"async\":true,\"parameters\":[{\"name\":\"_payload\",\"type\":\"any\",\"optional\":false},{\"name\":\"_metadata\",\"type\":\"DispatchMetadata\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"processDispatches\":{\"name\":\"processDispatches\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"getLearningMemory\":{\"name\":\"getLearningMemory\",\"async\":false,\"parameters\":[],\"returnType\":\"LearningMemory | null\",\"isStatic\":false,\"isPublic\":true},\"validate\":{\"name\":\"validate\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"shutdown\":{\"name\":\"shutdown\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"execute\":{\"name\":\"execute\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"interesting\":{\"name\":\"interesting\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<InterestResult[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"cli\":false,\"api\":false,\"mcp\":false,\"tableStrategy\":\"sti\",\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"Agent\",\"collectionExportName\":\"AgentCollection\",\"staticProperties\":{\"uiSlots\":{},\"adminRoutes\":[],\"signalSubscriptions\":[]},\"schema\":{\"tableName\":\"agents\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"agents\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"_meta_type\\\" TEXT NOT NULL,\\n \\\"_meta_data\\\" JSON,\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"status\\\" TEXT DEFAULT 'idle'\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"_meta_type\":{\"type\":\"TEXT\",\"notNull\":true},\"_meta_data\":{\"type\":\"JSON\",\"notNull\":false},\"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},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"default\":\"idle\"}},\"indexes\":[{\"name\":\"agents_id_idx\",\"columns\":[\"id\"]},{\"name\":\"agents_slug_context_meta_type_idx\",\"columns\":[\"slug\",\"context\",\"_meta_type\"],\"unique\":true},{\"name\":\"agents_meta_type_idx\",\"columns\":[\"_meta_type\"]}],\"version\":\"dde8777b\"}},\"@happyvertical/smrt-agents:AgentConfig\":{\"name\":\"agentconfig\",\"className\":\"AgentConfig\",\"qualifiedName\":\"@happyvertical/smrt-agents:AgentConfig\",\"collection\":\"agentconfigs\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/agents/src/config.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"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\":false,\"_meta\":{}},\"agentClass\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"slotId\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"configData\":{\"type\":\"json\",\"required\":false,\"_meta\":{\"sensitive\":true},\"sensitive\":true},\"schemaVersion\":{\"type\":\"integer\",\"required\":false,\"_meta\":{}}},\"methods\":{\"forAgent\":{\"name\":\"forAgent\",\"async\":true,\"parameters\":[{\"name\":\"agentId\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"SmrtClassOptions\",\"optional\":false}],\"returnType\":\"Promise<Map<string, Record<string>>>\",\"isStatic\":true,\"isPublic\":true},\"forAgents\":{\"name\":\"forAgents\",\"async\":true,\"parameters\":[{\"name\":\"agentIds\",\"type\":\"string[]\",\"optional\":false},{\"name\":\"options\",\"type\":\"SmrtClassOptions\",\"optional\":false}],\"returnType\":\"Promise<Map<string, Map<string, Record<string>>>>\",\"isStatic\":true,\"isPublic\":true},\"forSlot\":{\"name\":\"forSlot\",\"async\":true,\"parameters\":[{\"name\":\"agentId\",\"type\":\"string\",\"optional\":false},{\"name\":\"slotId\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"SmrtClassOptions\",\"optional\":false}],\"returnType\":\"Promise<Record<string> | undefined>\",\"isStatic\":true,\"isPublic\":true},\"saveSlot\":{\"name\":\"saveSlot\",\"async\":true,\"parameters\":[{\"name\":\"data\",\"type\":\"object\",\"optional\":false},{\"name\":\"options\",\"type\":\"SmrtClassOptions\",\"optional\":false}],\"returnType\":\"Promise<AgentConfig>\",\"isStatic\":true,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_configs\",\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"AgentConfig\",\"collectionExportName\":\"AgentConfigCollection\",\"schema\":{\"tableName\":\"agent_configs\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"agent_configs\\\" (\\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,\\n \\\"agent_class\\\" TEXT,\\n \\\"slot_id\\\" TEXT,\\n \\\"config_data\\\" JSON,\\n \\\"schema_version\\\" INTEGER\\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\":false,\"unique\":false},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"slot_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"config_data\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false},\"schema_version\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"agent_configs_id_idx\",\"columns\":[\"id\"]},{\"name\":\"agent_configs_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"25c6ac4c\"}},\"@happyvertical/smrt-agents:AgentConfigCollection\":{\"name\":\"agentconfigcollection\",\"className\":\"AgentConfigCollection\",\"qualifiedName\":\"@happyvertical/smrt-agents:AgentConfigCollection\",\"collection\":\"agentconfigs\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/agents/src/config.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"fields\":{},\"methods\":{\"findByTenant\":{\"name\":\"findByTenant\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AgentConfig[]>\",\"isStatic\":false,\"isPublic\":true},\"findGlobal\":{\"name\":\"findGlobal\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<AgentConfig[]>\",\"isStatic\":false,\"isPublic\":true},\"findWithGlobals\":{\"name\":\"findWithGlobals\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AgentConfig[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_configs\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"AgentConfig\",\"exportName\":\"AgentConfigCollection\",\"collectionExportName\":\"AgentConfigCollectionCollection\",\"schema\":{\"tableName\":\"agent_configs\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"agent_configs\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"agent_configs_id_idx\",\"columns\":[\"id\"]},{\"name\":\"agent_configs_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"9162bcd3\"}},\"@happyvertical/smrt-agents:AgentSchedule\":{\"name\":\"agentschedule\",\"className\":\"AgentSchedule\",\"qualifiedName\":\"@happyvertical/smrt-agents:AgentSchedule\",\"collection\":\"agentschedules\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/agents/src/schedule.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"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}}},\"agentType\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"agentId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"agentConfig\":{\"type\":\"json\",\"required\":false,\"_meta\":{\"sqlType\":\"TEXT\",\"sensitive\":true},\"sensitive\":true},\"cron\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"timezone\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"enabled\":{\"type\":\"boolean\",\"required\":false,\"_meta\":{}},\"status\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"lastRun\":{\"type\":\"datetime\",\"required\":false,\"_meta\":{\"nullable\":true}},\"nextRun\":{\"type\":\"datetime\",\"required\":false,\"_meta\":{\"nullable\":true}},\"lastStatus\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"lastError\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"runCount\":{\"type\":\"integer\",\"required\":false,\"_meta\":{}},\"successCount\":{\"type\":\"integer\",\"required\":false,\"_meta\":{}},\"failureCount\":{\"type\":\"integer\",\"required\":false,\"_meta\":{}},\"maxConcurrent\":{\"type\":\"integer\",\"required\":false,\"_meta\":{}},\"runningCount\":{\"type\":\"integer\",\"required\":false,\"_meta\":{}},\"timeout\":{\"type\":\"integer\",\"required\":false,\"_meta\":{}},\"method\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"methodArgs\":{\"type\":\"json\",\"required\":false,\"_meta\":{\"sqlType\":\"TEXT\"}}},\"methods\":{\"enable\":{\"name\":\"enable\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"disable\":{\"name\":\"disable\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"pause\":{\"name\":\"pause\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"resume\":{\"name\":\"resume\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"calculateNextRun\":{\"name\":\"calculateNextRun\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"getDescription\":{\"name\":\"getDescription\",\"async\":false,\"parameters\":[],\"returnType\":\"string\",\"isStatic\":false,\"isPublic\":true},\"beforeSave\":{\"name\":\"beforeSave\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"_smrt_agent_schedules\",\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\"]},\"cli\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\",\"enable\",\"disable\"],\"skipApiCheck\":true},\"mcp\":{\"include\":[\"list\",\"get\"]},\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"AgentSchedule\",\"collectionExportName\":\"AgentScheduleCollection\",\"schema\":{\"tableName\":\"_smrt_agent_schedules\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_agent_schedules\\\" (\\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_type\\\" TEXT,\\n \\\"agent_id\\\" TEXT,\\n \\\"agent_config\\\" TEXT,\\n \\\"cron\\\" TEXT,\\n \\\"timezone\\\" TEXT,\\n \\\"enabled\\\" BOOLEAN,\\n \\\"status\\\" TEXT,\\n \\\"last_run\\\" TIMESTAMP,\\n \\\"next_run\\\" TIMESTAMP,\\n \\\"last_status\\\" TEXT,\\n \\\"last_error\\\" TEXT,\\n \\\"run_count\\\" INTEGER,\\n \\\"success_count\\\" INTEGER,\\n \\\"failure_count\\\" INTEGER,\\n \\\"max_concurrent\\\" INTEGER,\\n \\\"running_count\\\" INTEGER,\\n \\\"timeout\\\" INTEGER,\\n \\\"method\\\" TEXT,\\n \\\"method_args\\\" TEXT\\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_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"agent_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"agent_config\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"cron\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"timezone\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"enabled\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"last_run\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"next_run\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"last_status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"last_error\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"run_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false},\"success_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false},\"failure_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false},\"max_concurrent\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false},\"running_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false},\"timeout\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false},\"method\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"method_args\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"_smrt_agent_schedules_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_agent_schedules_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"c21a1f29\"}},\"@happyvertical/smrt-agents:AgentScheduleCollection\":{\"name\":\"agentschedulecollection\",\"className\":\"AgentScheduleCollection\",\"qualifiedName\":\"@happyvertical/smrt-agents:AgentScheduleCollection\",\"collection\":\"agentschedules\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/agents/src/schedule.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"fields\":{},\"methods\":{\"findByTenant\":{\"name\":\"findByTenant\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AgentSchedule[]>\",\"isStatic\":false,\"isPublic\":true},\"findGlobal\":{\"name\":\"findGlobal\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<AgentSchedule[]>\",\"isStatic\":false,\"isPublic\":true},\"findWithGlobals\":{\"name\":\"findWithGlobals\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AgentSchedule[]>\",\"isStatic\":false,\"isPublic\":true},\"listByStatus\":{\"name\":\"listByStatus\",\"async\":true,\"parameters\":[{\"name\":\"status\",\"type\":\"ScheduleStatus | ScheduleStatus[]\",\"optional\":false},{\"name\":\"options\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<AgentSchedule[]>\",\"isStatic\":false,\"isPublic\":true},\"listByAgentType\":{\"name\":\"listByAgentType\",\"async\":true,\"parameters\":[{\"name\":\"agentType\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<AgentSchedule[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"_smrt_agent_schedules\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"AgentSchedule\",\"exportName\":\"AgentScheduleCollection\",\"collectionExportName\":\"AgentScheduleCollectionCollection\",\"schema\":{\"tableName\":\"_smrt_agent_schedules\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_agent_schedules\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"_smrt_agent_schedules_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_agent_schedules_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"d45601b0\"}},\"@happyvertical/smrt-agents:TenantAgent\":{\"name\":\"tenantagent\",\"className\":\"TenantAgent\",\"qualifiedName\":\"@happyvertical/smrt-agents:TenantAgent\",\"collection\":\"tenantagents\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/agents/src/tenant-agent.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"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}}},\"agentClass\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"status\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"permissions\":{\"type\":\"json\",\"required\":false,\"_meta\":{\"nullable\":true}},\"config\":{\"type\":\"json\",\"required\":false,\"_meta\":{\"nullable\":true,\"sensitive\":true},\"sensitive\":true}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"tenant_agents\",\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\"]},\"cli\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"conflictColumns\":[\"tenant_id\",\"agent_class\"],\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"TenantAgent\",\"collectionExportName\":\"TenantAgentCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"tenant_agents\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"tenant_agents\\\" (\\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 \\\"agent_class\\\" TEXT,\\n \\\"status\\\" TEXT,\\n \\\"permissions\\\" JSON,\\n \\\"config\\\" JSON\\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},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"permissions\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false},\"config\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"tenant_agents_id_idx\",\"columns\":[\"id\"]},{\"name\":\"tenant_agents_tenant_id_agent_class_idx\",\"columns\":[\"tenant_id\",\"agent_class\"],\"unique\":true}],\"version\":\"9892a054\"}},\"@happyvertical/smrt-agents:TenantAgentCollection\":{\"name\":\"tenantagentcollection\",\"className\":\"TenantAgentCollection\",\"qualifiedName\":\"@happyvertical/smrt-agents:TenantAgentCollection\",\"collection\":\"tenantagents\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/agents/src/tenant-agent.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"fields\":{},\"methods\":{\"resolveForTenant\":{\"name\":\"resolveForTenant\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"getAncestorIds\",\"type\":\"Function\",\"optional\":false},{\"name\":\"manifests\",\"type\":\"Map<string, AgentManifestInfo>\",\"optional\":true}],\"returnType\":\"Promise<ResolvedAgentAvailability[]>\",\"isStatic\":false,\"isPublic\":true},\"enableAgent\":{\"name\":\"enableAgent\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"agentClass\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<TenantAgent>\",\"isStatic\":false,\"isPublic\":true},\"disableAgent\":{\"name\":\"disableAgent\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"agentClass\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<TenantAgent>\",\"isStatic\":false,\"isPublic\":true},\"clearOverride\":{\"name\":\"clearOverride\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"agentClass\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"setPermissions\":{\"name\":\"setPermissions\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"agentClass\",\"type\":\"string\",\"optional\":false},{\"name\":\"permissions\",\"type\":\"Record<string, boolean>\",\"optional\":false}],\"returnType\":\"Promise<TenantAgent>\",\"isStatic\":false,\"isPublic\":true},\"findByTenantAndClass\":{\"name\":\"findByTenantAndClass\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"agentClass\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<TenantAgent | null>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"tenant_agents\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"TenantAgent\",\"exportName\":\"TenantAgentCollection\",\"collectionExportName\":\"TenantAgentCollectionCollection\",\"schema\":{\"tableName\":\"tenant_agents\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"tenant_agents\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"tenant_agents_id_idx\",\"columns\":[\"id\"]},{\"name\":\"tenant_agents_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"fbe7be99\"}}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\",\"@happyvertical/smrt-secrets\",\"@happyvertical/smrt-tenancy\",\"@happyvertical/smrt-users\"]}"));
10
+ ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":1783580636247,\"packageName\":\"@happyvertical/smrt-agents\",\"packageVersion\":\"0.38.21\",\"objects\":{\"@happyvertical/smrt-agents:Agent\":{\"name\":\"agent\",\"className\":\"Agent\",\"qualifiedName\":\"@happyvertical/smrt-agents:Agent\",\"collection\":\"agents\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/agents/src/agent.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"fields\":{\"created_at\":{\"type\":\"datetime\",\"required\":false},\"updated_at\":{\"type\":\"datetime\",\"required\":false},\"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}}},\"status\":{\"type\":\"text\",\"required\":false,\"default\":\"idle\"}},\"methods\":{\"getAiUsageSnapshot\":{\"name\":\"getAiUsageSnapshot\",\"async\":false,\"parameters\":[],\"returnType\":\"AiUsageSnapshot | undefined\",\"isStatic\":false,\"isPublic\":true},\"resetAiUsage\":{\"name\":\"resetAiUsage\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"listAiUsage\":{\"name\":\"listAiUsage\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"AiUsageListOptions\",\"optional\":true}],\"returnType\":\"Promise<SmrtAiUsageRecord[]>\",\"isStatic\":false,\"isPublic\":true},\"summarizeAiUsage\":{\"name\":\"summarizeAiUsage\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"AiUsageSummaryOptions\",\"optional\":true}],\"returnType\":\"Promise<Record<string, AiUsageStats>>\",\"isStatic\":false,\"isPublic\":true},\"destroy\":{\"name\":\"destroy\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"markAsPersisted\":{\"name\":\"markAsPersisted\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"requireInsertOnSave\":{\"name\":\"requireInsertOnSave\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"initialize\":{\"name\":\"initialize\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise\",\"isStatic\":false,\"isPublic\":true},\"loadDataFromDb\":{\"name\":\"loadDataFromDb\",\"async\":true,\"parameters\":[{\"name\":\"data\",\"type\":\"Record<string>\",\"optional\":false}],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"getFields\":{\"name\":\"getFields\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<any>\",\"isStatic\":false,\"isPublic\":true},\"toJSON\":{\"name\":\"toJSON\",\"async\":false,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"toPlainObject\":{\"name\":\"toPlainObject\",\"async\":false,\"parameters\":[],\"returnType\":\"Record<string>\",\"isStatic\":false,\"isPublic\":true},\"toPublicJSON\":{\"name\":\"toPublicJSON\",\"async\":false,\"parameters\":[{\"name\":\"options\",\"type\":\"PublicJsonOptions\",\"optional\":true}],\"returnType\":\"Record<string>\",\"isStatic\":false,\"isPublic\":true},\"getId\":{\"name\":\"getId\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"getSlug\":{\"name\":\"getSlug\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"getSavedId\":{\"name\":\"getSavedId\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"isSaved\":{\"name\":\"isSaved\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"save\":{\"name\":\"save\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"classifyConstraintError\":{\"name\":\"classifyConstraintError\",\"async\":false,\"parameters\":[{\"name\":\"message\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"'unique' | 'not_null' | null\",\"isStatic\":true,\"isPublic\":true},\"loadFromId\":{\"name\":\"loadFromId\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"loadFromSlug\":{\"name\":\"loadFromSlug\",\"async\":true,\"parameters\":[],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"is\":{\"name\":\"is\",\"async\":true,\"parameters\":[{\"name\":\"criteria\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"AiOperationOptions\",\"optional\":true}],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"do\":{\"name\":\"do\",\"async\":true,\"parameters\":[{\"name\":\"instructions\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"AiOperationOptions\",\"optional\":true}],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"describe\":{\"name\":\"describe\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"AiOperationOptions\",\"optional\":true}],\"returnType\":\"any\",\"isStatic\":false,\"isPublic\":true},\"delete\":{\"name\":\"delete\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"isRelatedLoaded\":{\"name\":\"isRelatedLoaded\",\"async\":false,\"parameters\":[{\"name\":\"fieldName\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"_setLoadedRelationship\":{\"name\":\"_setLoadedRelationship\",\"async\":false,\"parameters\":[{\"name\":\"fieldName\",\"type\":\"string\",\"optional\":false},{\"name\":\"value\",\"type\":\"any\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"loadRelated\":{\"name\":\"loadRelated\",\"async\":true,\"parameters\":[{\"name\":\"fieldName\",\"type\":\"string\",\"optional\":false},{\"name\":\"opts\",\"type\":\"LoadRelatedOptions\",\"optional\":true}],\"returnType\":\"Promise<any>\",\"isStatic\":false,\"isPublic\":true},\"loadRelatedMany\":{\"name\":\"loadRelatedMany\",\"async\":true,\"parameters\":[{\"name\":\"fieldName\",\"type\":\"string\",\"optional\":false},{\"name\":\"opts\",\"type\":\"LoadRelatedOptions\",\"optional\":true}],\"returnType\":\"Promise<any[]>\",\"isStatic\":false,\"isPublic\":true},\"getRelated\":{\"name\":\"getRelated\",\"async\":true,\"parameters\":[{\"name\":\"fieldName\",\"type\":\"string\",\"optional\":false},{\"name\":\"opts\",\"type\":\"LoadRelatedOptions\",\"optional\":true}],\"returnType\":\"Promise<any>\",\"isStatic\":false,\"isPublic\":true},\"getAvailableTools\":{\"name\":\"getAvailableTools\",\"async\":false,\"parameters\":[],\"returnType\":\"AITool[]\",\"isStatic\":false,\"isPublic\":true},\"executeToolCall\":{\"name\":\"executeToolCall\",\"async\":true,\"parameters\":[{\"name\":\"toolCall\",\"type\":\"ToolCall\",\"optional\":false}],\"returnType\":\"Promise<ToolCallResult>\",\"isStatic\":false,\"isPublic\":true},\"remember\":{\"name\":\"remember\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"recall\":{\"name\":\"recall\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":false}],\"returnType\":\"Promise\",\"isStatic\":false,\"isPublic\":true},\"recallAll\":{\"name\":\"recallAll\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<Map<string>>\",\"isStatic\":false,\"isPublic\":true},\"forget\":{\"name\":\"forget\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"forgetScope\":{\"name\":\"forgetScope\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":false}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"generateEmbeddings\":{\"name\":\"generateEmbeddings\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"GenerateEmbeddingsOptions\",\"optional\":true}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"getEmbedding\":{\"name\":\"getEmbedding\",\"async\":true,\"parameters\":[{\"name\":\"fieldName\",\"type\":\"string\",\"optional\":false},{\"name\":\"model\",\"type\":\"string\",\"optional\":true}],\"returnType\":\"Promise<number[] | null>\",\"isStatic\":false,\"isPublic\":true},\"hasStaleEmbeddings\":{\"name\":\"hasStaleEmbeddings\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<boolean>\",\"isStatic\":false,\"isPublic\":true},\"clearEmbeddings\":{\"name\":\"clearEmbeddings\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"getInstanceKey\":{\"name\":\"getInstanceKey\",\"async\":false,\"parameters\":[],\"returnType\":\"string | null\",\"isStatic\":false,\"isPublic\":true},\"getDispatchSubscriber\":{\"name\":\"getDispatchSubscriber\",\"async\":false,\"parameters\":[],\"returnType\":\"string\",\"isStatic\":false,\"isPublic\":true},\"getUISlots\":{\"name\":\"getUISlots\",\"async\":false,\"parameters\":[],\"returnType\":\"AgentUISlots\",\"isStatic\":false,\"isPublic\":true},\"loadConfigs\":{\"name\":\"loadConfigs\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Map<string, Record<string>>>\",\"isStatic\":false,\"isPublic\":true},\"saveSlotConfig\":{\"name\":\"saveSlotConfig\",\"async\":true,\"parameters\":[{\"name\":\"slotId\",\"type\":\"string\",\"optional\":false},{\"name\":\"data\",\"type\":\"Record<string>\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"getMergedConfig\":{\"name\":\"getMergedConfig\",\"async\":true,\"parameters\":[{\"name\":\"slotId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Record<string>>\",\"isStatic\":false,\"isPublic\":true},\"exportConfig\":{\"name\":\"exportConfig\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<Record<string>>\",\"isStatic\":false,\"isPublic\":true},\"getDispatch\":{\"name\":\"getDispatch\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<DispatchBus>\",\"isStatic\":false,\"isPublic\":true},\"handleDispatch\":{\"name\":\"handleDispatch\",\"async\":true,\"parameters\":[{\"name\":\"_payload\",\"type\":\"any\",\"optional\":false},{\"name\":\"_metadata\",\"type\":\"DispatchMetadata\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"processDispatches\":{\"name\":\"processDispatches\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"getLearningMemory\":{\"name\":\"getLearningMemory\",\"async\":false,\"parameters\":[],\"returnType\":\"LearningMemory | null\",\"isStatic\":false,\"isPublic\":true},\"validate\":{\"name\":\"validate\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"shutdown\":{\"name\":\"shutdown\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"execute\":{\"name\":\"execute\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"interesting\":{\"name\":\"interesting\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<InterestResult[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"cli\":false,\"api\":false,\"mcp\":false,\"tableStrategy\":\"sti\",\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"Agent\",\"collectionExportName\":\"AgentCollection\",\"staticProperties\":{\"uiSlots\":{},\"adminRoutes\":[],\"signalSubscriptions\":[]},\"schema\":{\"tableName\":\"agents\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"agents\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"_meta_type\\\" TEXT NOT NULL,\\n \\\"_meta_data\\\" JSON,\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"status\\\" TEXT DEFAULT 'idle'\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"_meta_type\":{\"type\":\"TEXT\",\"notNull\":true},\"_meta_data\":{\"type\":\"JSON\",\"notNull\":false},\"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},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"default\":\"idle\"}},\"indexes\":[{\"name\":\"agents_id_idx\",\"columns\":[\"id\"]},{\"name\":\"agents_slug_context_meta_type_idx\",\"columns\":[\"slug\",\"context\",\"_meta_type\"],\"unique\":true},{\"name\":\"agents_meta_type_idx\",\"columns\":[\"_meta_type\"]}],\"version\":\"dde8777b\"}},\"@happyvertical/smrt-agents:AgentConfig\":{\"name\":\"agentconfig\",\"className\":\"AgentConfig\",\"qualifiedName\":\"@happyvertical/smrt-agents:AgentConfig\",\"collection\":\"agentconfigs\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/agents/src/config.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"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\":false,\"_meta\":{}},\"agentClass\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"slotId\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"configData\":{\"type\":\"json\",\"required\":false,\"_meta\":{\"sensitive\":true},\"sensitive\":true},\"schemaVersion\":{\"type\":\"integer\",\"required\":false,\"_meta\":{}}},\"methods\":{\"forAgent\":{\"name\":\"forAgent\",\"async\":true,\"parameters\":[{\"name\":\"agentId\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"SmrtClassOptions\",\"optional\":false}],\"returnType\":\"Promise<Map<string, Record<string>>>\",\"isStatic\":true,\"isPublic\":true},\"forAgents\":{\"name\":\"forAgents\",\"async\":true,\"parameters\":[{\"name\":\"agentIds\",\"type\":\"string[]\",\"optional\":false},{\"name\":\"options\",\"type\":\"SmrtClassOptions\",\"optional\":false}],\"returnType\":\"Promise<Map<string, Map<string, Record<string>>>>\",\"isStatic\":true,\"isPublic\":true},\"forSlot\":{\"name\":\"forSlot\",\"async\":true,\"parameters\":[{\"name\":\"agentId\",\"type\":\"string\",\"optional\":false},{\"name\":\"slotId\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"SmrtClassOptions\",\"optional\":false}],\"returnType\":\"Promise<Record<string> | undefined>\",\"isStatic\":true,\"isPublic\":true},\"saveSlot\":{\"name\":\"saveSlot\",\"async\":true,\"parameters\":[{\"name\":\"data\",\"type\":\"object\",\"optional\":false},{\"name\":\"options\",\"type\":\"SmrtClassOptions\",\"optional\":false}],\"returnType\":\"Promise<AgentConfig>\",\"isStatic\":true,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_configs\",\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"AgentConfig\",\"collectionExportName\":\"AgentConfigCollection\",\"schema\":{\"tableName\":\"agent_configs\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"agent_configs\\\" (\\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,\\n \\\"agent_class\\\" TEXT,\\n \\\"slot_id\\\" TEXT,\\n \\\"config_data\\\" JSON,\\n \\\"schema_version\\\" INTEGER\\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\":false,\"unique\":false},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"slot_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"config_data\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false},\"schema_version\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"agent_configs_id_idx\",\"columns\":[\"id\"]},{\"name\":\"agent_configs_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"25c6ac4c\"}},\"@happyvertical/smrt-agents:AgentConfigCollection\":{\"name\":\"agentconfigcollection\",\"className\":\"AgentConfigCollection\",\"qualifiedName\":\"@happyvertical/smrt-agents:AgentConfigCollection\",\"collection\":\"agentconfigs\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/agents/src/config.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"fields\":{},\"methods\":{\"findByTenant\":{\"name\":\"findByTenant\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AgentConfig[]>\",\"isStatic\":false,\"isPublic\":true},\"findGlobal\":{\"name\":\"findGlobal\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<AgentConfig[]>\",\"isStatic\":false,\"isPublic\":true},\"findWithGlobals\":{\"name\":\"findWithGlobals\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AgentConfig[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"agent_configs\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"AgentConfig\",\"exportName\":\"AgentConfigCollection\",\"collectionExportName\":\"AgentConfigCollectionCollection\",\"schema\":{\"tableName\":\"agent_configs\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"agent_configs\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"agent_configs_id_idx\",\"columns\":[\"id\"]},{\"name\":\"agent_configs_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"9162bcd3\"}},\"@happyvertical/smrt-agents:AgentSchedule\":{\"name\":\"agentschedule\",\"className\":\"AgentSchedule\",\"qualifiedName\":\"@happyvertical/smrt-agents:AgentSchedule\",\"collection\":\"agentschedules\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/agents/src/schedule.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"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}}},\"agentType\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"agentId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"agentConfig\":{\"type\":\"json\",\"required\":false,\"_meta\":{\"sqlType\":\"TEXT\",\"sensitive\":true},\"sensitive\":true},\"cron\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"timezone\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"enabled\":{\"type\":\"boolean\",\"required\":false,\"_meta\":{}},\"status\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"lastRun\":{\"type\":\"datetime\",\"required\":false,\"_meta\":{\"nullable\":true}},\"nextRun\":{\"type\":\"datetime\",\"required\":false,\"_meta\":{\"nullable\":true}},\"lastStatus\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"lastError\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"runCount\":{\"type\":\"integer\",\"required\":false,\"_meta\":{}},\"successCount\":{\"type\":\"integer\",\"required\":false,\"_meta\":{}},\"failureCount\":{\"type\":\"integer\",\"required\":false,\"_meta\":{}},\"maxConcurrent\":{\"type\":\"integer\",\"required\":false,\"_meta\":{}},\"runningCount\":{\"type\":\"integer\",\"required\":false,\"_meta\":{}},\"timeout\":{\"type\":\"integer\",\"required\":false,\"_meta\":{}},\"method\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"methodArgs\":{\"type\":\"json\",\"required\":false,\"_meta\":{\"sqlType\":\"TEXT\"}}},\"methods\":{\"enable\":{\"name\":\"enable\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"disable\":{\"name\":\"disable\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"pause\":{\"name\":\"pause\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"resume\":{\"name\":\"resume\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"calculateNextRun\":{\"name\":\"calculateNextRun\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"getDescription\":{\"name\":\"getDescription\",\"async\":false,\"parameters\":[],\"returnType\":\"string\",\"isStatic\":false,\"isPublic\":true},\"beforeSave\":{\"name\":\"beforeSave\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"_smrt_agent_schedules\",\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\"]},\"cli\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\",\"enable\",\"disable\"],\"skipApiCheck\":true},\"mcp\":{\"include\":[\"list\",\"get\"]},\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"AgentSchedule\",\"collectionExportName\":\"AgentScheduleCollection\",\"schema\":{\"tableName\":\"_smrt_agent_schedules\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_agent_schedules\\\" (\\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_type\\\" TEXT,\\n \\\"agent_id\\\" TEXT,\\n \\\"agent_config\\\" TEXT,\\n \\\"cron\\\" TEXT,\\n \\\"timezone\\\" TEXT,\\n \\\"enabled\\\" BOOLEAN,\\n \\\"status\\\" TEXT,\\n \\\"last_run\\\" TIMESTAMP,\\n \\\"next_run\\\" TIMESTAMP,\\n \\\"last_status\\\" TEXT,\\n \\\"last_error\\\" TEXT,\\n \\\"run_count\\\" INTEGER,\\n \\\"success_count\\\" INTEGER,\\n \\\"failure_count\\\" INTEGER,\\n \\\"max_concurrent\\\" INTEGER,\\n \\\"running_count\\\" INTEGER,\\n \\\"timeout\\\" INTEGER,\\n \\\"method\\\" TEXT,\\n \\\"method_args\\\" TEXT\\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_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"agent_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"agent_config\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"cron\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"timezone\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"enabled\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"last_run\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"next_run\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"last_status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"last_error\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"run_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false},\"success_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false},\"failure_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false},\"max_concurrent\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false},\"running_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false},\"timeout\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false},\"method\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"method_args\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"_smrt_agent_schedules_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_agent_schedules_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"c21a1f29\"}},\"@happyvertical/smrt-agents:AgentScheduleCollection\":{\"name\":\"agentschedulecollection\",\"className\":\"AgentScheduleCollection\",\"qualifiedName\":\"@happyvertical/smrt-agents:AgentScheduleCollection\",\"collection\":\"agentschedules\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/agents/src/schedule.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"fields\":{},\"methods\":{\"findByTenant\":{\"name\":\"findByTenant\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AgentSchedule[]>\",\"isStatic\":false,\"isPublic\":true},\"findGlobal\":{\"name\":\"findGlobal\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<AgentSchedule[]>\",\"isStatic\":false,\"isPublic\":true},\"findWithGlobals\":{\"name\":\"findWithGlobals\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<AgentSchedule[]>\",\"isStatic\":false,\"isPublic\":true},\"listByStatus\":{\"name\":\"listByStatus\",\"async\":true,\"parameters\":[{\"name\":\"status\",\"type\":\"ScheduleStatus | ScheduleStatus[]\",\"optional\":false},{\"name\":\"options\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<AgentSchedule[]>\",\"isStatic\":false,\"isPublic\":true},\"listByAgentType\":{\"name\":\"listByAgentType\",\"async\":true,\"parameters\":[{\"name\":\"agentType\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"object\",\"optional\":true}],\"returnType\":\"Promise<AgentSchedule[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"_smrt_agent_schedules\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"AgentSchedule\",\"exportName\":\"AgentScheduleCollection\",\"collectionExportName\":\"AgentScheduleCollectionCollection\",\"schema\":{\"tableName\":\"_smrt_agent_schedules\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_agent_schedules\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"_smrt_agent_schedules_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_agent_schedules_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"d45601b0\"}},\"@happyvertical/smrt-agents:TenantAgent\":{\"name\":\"tenantagent\",\"className\":\"TenantAgent\",\"qualifiedName\":\"@happyvertical/smrt-agents:TenantAgent\",\"collection\":\"tenantagents\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/agents/src/tenant-agent.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"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}}},\"agentClass\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"status\":{\"type\":\"text\",\"required\":false,\"_meta\":{}},\"permissions\":{\"type\":\"json\",\"required\":false,\"_meta\":{\"nullable\":true}},\"config\":{\"type\":\"json\",\"required\":false,\"_meta\":{\"nullable\":true,\"sensitive\":true},\"sensitive\":true}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"tenant_agents\",\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\",\"delete\"]},\"cli\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"conflictColumns\":[\"tenant_id\",\"agent_class\"],\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"TenantAgent\",\"collectionExportName\":\"TenantAgentCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"tenant_agents\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"tenant_agents\\\" (\\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 \\\"agent_class\\\" TEXT,\\n \\\"status\\\" TEXT,\\n \\\"permissions\\\" JSON,\\n \\\"config\\\" JSON\\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},\"agent_class\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"permissions\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false},\"config\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"tenant_agents_id_idx\",\"columns\":[\"id\"]},{\"name\":\"tenant_agents_tenant_id_agent_class_idx\",\"columns\":[\"tenant_id\",\"agent_class\"],\"unique\":true}],\"version\":\"9892a054\"}},\"@happyvertical/smrt-agents:TenantAgentCollection\":{\"name\":\"tenantagentcollection\",\"className\":\"TenantAgentCollection\",\"qualifiedName\":\"@happyvertical/smrt-agents:TenantAgentCollection\",\"collection\":\"tenantagents\",\"filePath\":\"/home/runner/_work/smrt/smrt/packages/agents/src/tenant-agent.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"fields\":{},\"methods\":{\"resolveForTenant\":{\"name\":\"resolveForTenant\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"getAncestorIds\",\"type\":\"Function\",\"optional\":false},{\"name\":\"manifests\",\"type\":\"Map<string, AgentManifestInfo>\",\"optional\":true}],\"returnType\":\"Promise<ResolvedAgentAvailability[]>\",\"isStatic\":false,\"isPublic\":true},\"enableAgent\":{\"name\":\"enableAgent\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"agentClass\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<TenantAgent>\",\"isStatic\":false,\"isPublic\":true},\"disableAgent\":{\"name\":\"disableAgent\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"agentClass\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<TenantAgent>\",\"isStatic\":false,\"isPublic\":true},\"clearOverride\":{\"name\":\"clearOverride\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"agentClass\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<void>\",\"isStatic\":false,\"isPublic\":true},\"setPermissions\":{\"name\":\"setPermissions\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"agentClass\",\"type\":\"string\",\"optional\":false},{\"name\":\"permissions\",\"type\":\"Record<string, boolean>\",\"optional\":false}],\"returnType\":\"Promise<TenantAgent>\",\"isStatic\":false,\"isPublic\":true},\"findByTenantAndClass\":{\"name\":\"findByTenantAndClass\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"agentClass\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<TenantAgent | null>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"tenant_agents\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"TenantAgent\",\"exportName\":\"TenantAgentCollection\",\"collectionExportName\":\"TenantAgentCollectionCollection\",\"schema\":{\"tableName\":\"tenant_agents\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"tenant_agents\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"tenant_agents_id_idx\",\"columns\":[\"id\"]},{\"name\":\"tenant_agents_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"fbe7be99\"}}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\",\"@happyvertical/smrt-secrets\",\"@happyvertical/smrt-tenancy\",\"@happyvertical/smrt-users\"]}"));
11
11
  //#endregion
12
12
  //#region src/ai-config.ts
13
13
  var DEFAULT_SECRET_NAMES = {
@@ -221,6 +221,65 @@ var Agent = class extends SmrtObject {
221
221
  return getAgentClassName(this.getAgentTypeName());
222
222
  }
223
223
  /**
224
+ * Whether this agent class opted into multiple durable instances per tenant.
225
+ */
226
+ isMultiInstance() {
227
+ return this.constructor.multiInstance === true;
228
+ }
229
+ /**
230
+ * The durable per-instance key for this agent, or `null` for a singleton.
231
+ *
232
+ * Returns `null` unless the class opts in (`static multiInstance = true`) AND a
233
+ * non-empty {@link AgentOptions.instanceKey} was supplied — so a non-opted
234
+ * agent is always singleton-identified even if a key is passed. This is the
235
+ * anchor the framework folds into the dispatch subscriber, memory scope, and
236
+ * scoping seams below.
237
+ */
238
+ getInstanceKey() {
239
+ if (!this.isMultiInstance()) return null;
240
+ const key = this.options.instanceKey;
241
+ return typeof key === "string" && key.length > 0 ? key : null;
242
+ }
243
+ /**
244
+ * Canonical dispatch subscriber identity for this agent.
245
+ *
246
+ * A singleton (no instance key) is the bare agent type — **unchanged** from the
247
+ * class-keyed behavior. A multi-instance agent is `` `${agentType}#${key}` ``,
248
+ * giving each instance its own subscription rows and its own pending-dispatch
249
+ * queue so instances don't compete for or double-process each other's
250
+ * dispatches. Used everywhere the agent subscribes, seeds, and processes.
251
+ */
252
+ getDispatchSubscriber() {
253
+ return instanceScopedSubscriber(this.getAgentTypeName(), this.getInstanceKey());
254
+ }
255
+ /**
256
+ * The signal types this instance should seed as dispatch subscriptions.
257
+ *
258
+ * Defaults to the class's static {@link Agent.signalSubscriptions} unchanged.
259
+ * A multi-instance package overrides this to derive **instance-scoped** signal
260
+ * types from the persona/instance config (e.g. append the instance key or a
261
+ * routing dimension), so an emit meant for one instance only matches that
262
+ * instance's subscription and the other never processes it.
263
+ */
264
+ resolveSignalSubscriptions() {
265
+ return this.constructor.signalSubscriptions;
266
+ }
267
+ /**
268
+ * An optional filter AND-merged (as the base layer) into every
269
+ * {@link interesting} query for this instance.
270
+ *
271
+ * `undefined` by default (no scoping — singleton behavior unchanged). A
272
+ * multi-instance package overrides it to return an instance-discriminating
273
+ * filter derived from the persona/instance config, so two instances of one
274
+ * class partition the objects they process and never double-handle the same
275
+ * row. Global and per-object interest filters layer on top (and win on key
276
+ * collision), so choose a dedicated discriminator key here.
277
+ *
278
+ * Applies to the standard filter path; custom `query` interest filters own
279
+ * their SQL and should incorporate {@link getInstanceKey} themselves.
280
+ */
281
+ instanceInterestFilter() {}
282
+ /**
224
283
  * Get UI slot definitions for this agent instance
225
284
  *
226
285
  * Returns the static uiSlots defined on the agent's class.
@@ -401,7 +460,7 @@ var Agent = class extends SmrtObject {
401
460
  * ```
402
461
  */
403
462
  async processDispatches() {
404
- return (await this.getDispatch()).process(this.getAgentTypeName(), this.handleDispatch.bind(this));
463
+ return (await this.getDispatch()).process(this.getDispatchSubscriber(), this.handleDispatch.bind(this));
405
464
  }
406
465
  /**
407
466
  * Base memory scope for this agent's learning.
@@ -412,7 +471,9 @@ var Agent = class extends SmrtObject {
412
471
  * memory never bleeds across tenants running the same agent class.
413
472
  */
414
473
  learningScope() {
415
- return resolveAgentLearning(this.constructor.learning).scope ?? `agent/${this.getAgentTypeName()}`;
474
+ const base = resolveAgentLearning(this.constructor.learning).scope ?? `agent/${this.getAgentTypeName()}`;
475
+ const instanceKey = this.getInstanceKey();
476
+ return instanceKey ? `${base}#${instanceKey}` : base;
416
477
  }
417
478
  /**
418
479
  * Optional semantic-search arm for {@link LearningMemory}.
@@ -559,9 +620,9 @@ var Agent = class extends SmrtObject {
559
620
  if (this._db) {
560
621
  const dispatch = await this.getDispatch();
561
622
  await this.migrateLegacyDispatchSubscriptions(dispatch);
562
- const subs = this.constructor.signalSubscriptions;
623
+ const subs = this.resolveSignalSubscriptions();
563
624
  if (subs.length > 0) {
564
- const subscriber = this.getAgentTypeName();
625
+ const subscriber = this.getDispatchSubscriber();
565
626
  const existing = await dispatch.listSubscriptions(subscriber);
566
627
  const existingTypes = new Set(existing.map((s) => s.signalType));
567
628
  for (const signalType of subs) if (!existingTypes.has(signalType)) await dispatch.subscribe({
@@ -709,7 +770,7 @@ var Agent = class extends SmrtObject {
709
770
  await this.validate();
710
771
  this.status = "running";
711
772
  if (this._db) {
712
- if ((await (await this.getDispatch()).listSubscriptions(this.getAgentTypeName())).length > 0) {
773
+ if ((await (await this.getDispatch()).listSubscriptions(this.getDispatchSubscriber())).length > 0) {
713
774
  const count = await this.processDispatches();
714
775
  if (count > 0) this.logger.info(`Processed ${count} pending dispatches`);
715
776
  }
@@ -849,7 +910,7 @@ var Agent = class extends SmrtObject {
849
910
  if (filter.qualify) items2 = await filter.qualify(items2);
850
911
  return items2;
851
912
  }
852
- const mergedFilter = mergeFilters(this.interests?.filter, filter.filter);
913
+ const mergedFilter = mergeFilters(mergeFilters(this.instanceInterestFilter(), this.interests?.filter), filter.filter);
853
914
  const queryOptions = {};
854
915
  if (Object.keys(mergedFilter).length > 0) queryOptions.where = mergedFilter;
855
916
  if (filter.sort) queryOptions.orderBy = filter.sort;
@@ -1011,6 +1072,26 @@ __publicField(Agent, "configResolvers", {});
1011
1072
  * ```
1012
1073
  */
1013
1074
  __publicField(Agent, "learning", false);
1075
+ /**
1076
+ * Opt into multiple durable instances of this agent class per tenant (#1890).
1077
+ *
1078
+ * **Off by default** — a non-opted class is a **singleton** (the N=1 case) and
1079
+ * behaves byte-for-byte as it does today: one dispatch subscriber keyed by the
1080
+ * agent type, one memory scope, class-wide interests. Setting this to `true`
1081
+ * lets N configured instances (personas, from `@happyvertical/smrt-personas`)
1082
+ * run independently: each is constructed with its own {@link AgentOptions.instanceKey},
1083
+ * which the framework folds into a per-instance dispatch subscriber
1084
+ * ({@link getDispatchSubscriber}), memory partition ({@link learningScope}),
1085
+ * and interest/subscription scoping seams ({@link instanceInterestFilter} /
1086
+ * {@link resolveSignalSubscriptions}) so two instances never double-process
1087
+ * each other's dispatches or interests.
1088
+ *
1089
+ * The framework provides the per-instance *identity*; a package scopes its own
1090
+ * dispatch/interests to the instance's config by overriding the seams. The
1091
+ * `default` persona reuses the singleton identity (null key), which makes the
1092
+ * singleton→multi upgrade non-destructive.
1093
+ */
1094
+ __publicField(Agent, "multiInstance", false);
1014
1095
  __decorateClass$2([tenantId({ nullable: true })], Agent.prototype, "tenantId", 2);
1015
1096
  Agent = __decorateClass$2([TenantScoped({ mode: "optional" }), smrt({
1016
1097
  cli: false,
@@ -1024,6 +1105,67 @@ function buildDispatchTenantUpdatePredicate(scope) {
1024
1105
  return [" AND tenant_id IS NULL", []];
1025
1106
  }
1026
1107
  //#endregion
1108
+ //#region src/execute-as-principal.ts
1109
+ var PrincipalToolNotAllowedError = class extends Error {
1110
+ tool;
1111
+ status = 403;
1112
+ constructor(tool) {
1113
+ super(`Tool '${tool}' is not permitted for this persona.`);
1114
+ this.name = "PrincipalToolNotAllowedError";
1115
+ this.tool = tool;
1116
+ }
1117
+ };
1118
+ async function emitAudit(entry, audit, logger) {
1119
+ if (audit) {
1120
+ await audit(entry);
1121
+ return;
1122
+ }
1123
+ (logger ?? createLogger({ level: "info" })).info("agent action executed on behalf of originating user", { ...entry });
1124
+ }
1125
+ async function executeAsPrincipal(options, fn) {
1126
+ const { principal, onBehalfOfUserId = null, agentClass, action = "agent.run", auditMetadata, permissions, resolver, postgresRls, enterTenantContext, audit, logger, ...smrtOptions } = options;
1127
+ const { runAsUserId, tenantId, actsAsProfileId = null } = principal;
1128
+ const toolWhitelist = Array.isArray(principal.allowedTools) ? principal.allowedTools : [];
1129
+ const isToolAllowed = (tool) => typeof tool === "string" && tool.length > 0 && toolWhitelist.includes(tool);
1130
+ await emitAudit({
1131
+ action,
1132
+ actorUserId: runAsUserId,
1133
+ onBehalfOfUserId,
1134
+ tenantId,
1135
+ agentClass,
1136
+ actsAsProfileId,
1137
+ metadata: auditMetadata
1138
+ }, audit, logger);
1139
+ return withPrincipalPermissionContext({
1140
+ ...smrtOptions,
1141
+ userId: runAsUserId,
1142
+ tenantId,
1143
+ permissions,
1144
+ resolver,
1145
+ postgresRls,
1146
+ enterTenantContext: enterTenantContext ?? tenantId !== null
1147
+ }, async (context) => {
1148
+ return fn({
1149
+ context,
1150
+ permissions: context.permissions,
1151
+ allowedTools: toolWhitelist,
1152
+ isToolAllowed,
1153
+ assertToolAllowed(tool) {
1154
+ if (!isToolAllowed(tool)) throw new PrincipalToolNotAllowedError(tool);
1155
+ },
1156
+ async assertOperation(collection, operationAction, extraOptions) {
1157
+ return assertOperationPermission({
1158
+ ...smrtOptions,
1159
+ ...extraOptions,
1160
+ collection,
1161
+ action: operationAction,
1162
+ permissionSet: context.permissionSet
1163
+ });
1164
+ }
1165
+ });
1166
+ });
1167
+ }
1168
+ //#endregion
1027
1169
  //#region src/schedule.ts
1028
1170
  var __defProp$1 = Object.defineProperty;
1029
1171
  var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
@@ -1497,6 +1639,6 @@ function getManifestForAgent(manifests, agentTypeOrIdentifier) {
1497
1639
  return manifests.get(agentTypeOrIdentifier) || manifests.get(getAgentClassName(agentTypeOrIdentifier));
1498
1640
  }
1499
1641
  //#endregion
1500
- export { Agent, AgentConfig, AgentConfigCollection, AgentSchedule, AgentScheduleCollection, AgentUIRegistry, TenantAgent, TenantAgentCollection, createUIRegistry, getClassConfigResolvers, getConfigResolver, isLazyConfigSentinel, listConfigResolvers, mergeFilters, normalizeSort, registerConfigResolver, resetConfigResolvers, resolveAgentAIOptions, resolveAgentLearning, resolveLazyConfig, unregisterConfigResolver };
1642
+ export { Agent, AgentConfig, AgentConfigCollection, AgentSchedule, AgentScheduleCollection, AgentUIRegistry, PrincipalToolNotAllowedError, TenantAgent, TenantAgentCollection, createUIRegistry, executeAsPrincipal, getClassConfigResolvers, getConfigResolver, instanceScopedSubscriber, isLazyConfigSentinel, listConfigResolvers, mergeFilters, normalizeSort, registerConfigResolver, resetConfigResolvers, resolveAgentAIOptions, resolveAgentLearning, resolveLazyConfig, unregisterConfigResolver };
1501
1643
 
1502
1644
  //# sourceMappingURL=index.js.map