@happyvertical/smrt-agents 0.51.39 → 0.52.0
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/AGENTS.md +22 -0
- package/dist/agent.d.ts +16 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/chunks/{execute-as-principal-uuJq7EFs.js → execute-as-principal-DtwCUq2t.js} +11 -2
- package/dist/chunks/execute-as-principal-DtwCUq2t.js.map +1 -0
- package/dist/data-surface.d.ts +21 -2
- package/dist/data-surface.d.ts.map +1 -1
- package/dist/identity.d.ts +19 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +510 -34
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +2 -1
- package/dist/migrations/tenant-agent-config-keys.d.ts +143 -0
- package/dist/migrations/tenant-agent-config-keys.d.ts.map +1 -0
- package/dist/server/jobs-data-surface-action-queue.d.ts +12 -1
- package/dist/server/jobs-data-surface-action-queue.d.ts.map +1 -1
- package/dist/server/serialization.d.ts +7 -2
- package/dist/server/serialization.d.ts.map +1 -1
- package/dist/server.js +19 -9
- package/dist/server.js.map +1 -1
- package/dist/smrt-collection-data-surface.d.ts +32 -1
- package/dist/smrt-collection-data-surface.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +6 -6
- package/dist/ui.d.ts +94 -0
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +33 -1
- package/dist/ui.js.map +1 -1
- package/package.json +19 -19
- package/dist/chunks/execute-as-principal-uuJq7EFs.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as getAgentClassName, c as instanceScopedSubscriber, i as AgentConfigCollection, n as executeAsPrincipal, o as getAgentTypeAliases, r as AgentConfig, s as getAgentTypeName, t as PrincipalToolNotAllowedError } from "./chunks/execute-as-principal-
|
|
2
|
-
import { AgentUIRegistry, createUIRegistry } from "./ui.js";
|
|
3
|
-
import { DEFAULT_DATA_QUERY_RESULT_BYTES, DataQueryValidationError, LearningMemory, MAX_DATA_QUERY_FILTERS, MAX_DATA_QUERY_OFFSET, MAX_DATA_QUERY_REQUEST_BYTES, ObjectRegistry, SmrtCollection, SmrtObject, canonicalizeDataQuery, createDataQueryFingerprint, createDispatchBus, field, getClassConfigResolvers, getConfigResolver, isLazyConfigSentinel, listConfigResolvers, normalizeDataQueryRequest, normalizeDataQueryResult, normalizeDataQuerySchema, registerConfigResolver, resetConfigResolvers, resolveDispatchTenantScope, resolveLazyConfig, smrt, unregisterConfigResolver } from "@happyvertical/smrt-core";
|
|
1
|
+
import { a as getAgentClassName, c as instanceScopedSubscriber, i as AgentConfigCollection, l as parseTenantAgentConfigOwnerId, n as executeAsPrincipal, o as getAgentTypeAliases, r as AgentConfig, s as getAgentTypeName, t as PrincipalToolNotAllowedError, u as tenantAgentConfigOwnerId } from "./chunks/execute-as-principal-DtwCUq2t.js";
|
|
2
|
+
import { AgentUIRegistry, createUIRegistry, isAgentCreateEntryAvailable, resolveAgentCreateEntries } from "./ui.js";
|
|
3
|
+
import { DEFAULT_DATA_QUERY_RESULT_BYTES, DataQueryValidationError, LearningMemory, MAX_DATA_QUERY_FILTERS, MAX_DATA_QUERY_OFFSET, MAX_DATA_QUERY_REQUEST_BYTES, ObjectRegistry, SmrtCollection, SmrtObject, canonicalizeDataQuery, createDataQueryFingerprint, createDispatchBus, detectEngine, field, getClassConfigResolvers, getClassName, getConfigResolver, isLazyConfigSentinel, listConfigResolvers, normalizeDataQueryRequest, normalizeDataQueryResult, normalizeDataQuerySchema, registerConfigResolver, resetConfigResolvers, resolveDispatchTenantScope, resolveLazyConfig, smrt, toSnakeCase, 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, getTenantScopedConfig, isSuperAdminBypass, isSystemContext, isTenancyEnabled, isTenantScopedClass, queryGlobal, queryWithGlobals, tenantId, withTenant } from "@happyvertical/smrt-tenancy";
|
|
@@ -11,7 +11,7 @@ import { BackfillTracker } from "@happyvertical/smrt-core/migrations";
|
|
|
11
11
|
import { createServerStepEvaluator, preflightPlaybook } from "@happyvertical/smrt-playbooks";
|
|
12
12
|
import { applyReportExport, applyReportRefresh, buildReportAdapterDescriptor, buildReportDrilldownQuery, createReportExportRequest, createReportExportSnapshot, previewReportExport, previewReportRefresh, queryReportMaterializedRows } from "@happyvertical/smrt-reports";
|
|
13
13
|
//#region src/__smrt-register__.ts
|
|
14
|
-
ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":0,\"packageName\":\"@happyvertical/smrt-agents\",\"packageVersion\":\"0.51.39\",\"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\":{\"getInstanceKey\":{\"name\":\"getInstanceKey\",\"async\":false,\"parameters\":[],\"returnType\":\"string | null\",\"isStatic\":false,\"isPublic\":true},\"getConfigOwnerId\":{\"name\":\"getConfigOwnerId\",\"async\":false,\"parameters\":[{\"name\":\"slotId\",\"type\":\"string\",\"optional\":true}],\"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, unknown>>>\",\"isStatic\":false,\"isPublic\":true},\"saveSlotConfig\":{\"name\":\"saveSlotConfig\",\"async\":true,\"parameters\":[{\"name\":\"slotId\",\"type\":\"string\",\"optional\":false},{\"name\":\"data\",\"type\":\"Record<string, unknown>\",\"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, unknown>>\",\"isStatic\":false,\"isPublic\":true},\"exportConfig\":{\"name\":\"exportConfig\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"boolean\"]}],\"returnType\":\"Promise<Record<string, unknown>>\",\"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\":\"unknown\",\"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},\"initialize\":{\"name\":\"initialize\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this>\",\"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\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\",\"_meta_type\"]},\"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_slug_context_meta_type_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\",\"_meta_type\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"agents_meta_type_idx\",\"columns\":[\"_meta_type\"]},{\"name\":\"agents_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"dde8777b\"},\"importPath\":\"@happyvertical/smrt-agents\"},\"@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, unknown>>>\",\"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, unknown>>>>\",\"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, unknown> | undefined>\",\"isStatic\":true,\"isPublic\":true},\"saveSlot\":{\"name\":\"saveSlot\",\"async\":true,\"parameters\":[{\"name\":\"data\",\"type\":\"object\",\"optional\":false,\"memberTypes\":[\"string\",\"Record<string, unknown>\"]},{\"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\":{\"skipApiCheck\":true},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"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_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"agent_configs_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"25c6ac4c\"},\"importPath\":\"@happyvertical/smrt-agents\"},\"@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 \\\"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_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"agent_configs_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"25c6ac4c\"},\"importPath\":\"@happyvertical/smrt-agents\"},\"@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\"]},\"indexes\":[{\"name\":\"_smrt_agent_schedules_enabled_status_next_run_idx\",\"columns\":[\"enabled\",\"status\",\"nextRun\"]}],\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"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_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"_smrt_agent_schedules_enabled_status_next_run_idx\",\"columns\":[\"enabled\",\"status\",\"next_run\"]},{\"name\":\"_smrt_agent_schedules_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"c21a1f29\"},\"importPath\":\"@happyvertical/smrt-agents\"},\"@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,\"unionBranches\":[{\"type\":\"ScheduleStatus\"},{\"type\":\"ScheduleStatus[]\"}]},{\"name\":\"options\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"number\"]}],\"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,\"memberTypes\":[\"number\",\"boolean\"]}],\"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 \\\"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_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"_smrt_agent_schedules_enabled_status_next_run_idx\",\"columns\":[\"enabled\",\"status\",\"next_run\"]},{\"name\":\"_smrt_agent_schedules_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"c21a1f29\"},\"importPath\":\"@happyvertical/smrt-agents\"},\"@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\":[],\"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_tenant_id_agent_class_idx\",\"columns\":[\"tenant_id\",\"agent_class\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"tenant_agents_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"tenant_agents_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"9892a054\"},\"importPath\":\"@happyvertical/smrt-agents\"},\"@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 \\\"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_tenant_id_agent_class_idx\",\"columns\":[\"tenant_id\",\"agent_class\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"tenant_agents_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"tenant_agents_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"9892a054\"},\"importPath\":\"@happyvertical/smrt-agents\"},\"@happyvertical/smrt-agents:SmrtDataSurfaceActionTask\":{\"name\":\"smrtdatasurfaceactiontask\",\"className\":\"SmrtDataSurfaceActionTask\",\"qualifiedName\":\"@happyvertical/smrt-agents:SmrtDataSurfaceActionTask\",\"collection\":\"smrtdatasurfaceactiontasks\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/agents/src/server/jobs-data-surface-action-queue.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}}},\"args\":{\"type\":\"json\",\"required\":true,\"_meta\":{\"required\":true}}},\"methods\":{\"run\":{\"name\":\"run\",\"async\":true,\"parameters\":[{\"name\":\"args\",\"type\":\"DataSurfaceActionJobArgs\",\"optional\":true},{\"name\":\"context\",\"type\":\"JobExecutionContext\",\"optional\":true}],\"returnType\":\"Promise<DataSurfaceActionResult>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"_smrt_data_surface_action_tasks\",\"api\":false,\"cli\":false,\"mcp\":false,\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"SmrtDataSurfaceActionTask\",\"collectionExportName\":\"SmrtDataSurfaceActionTaskCollection\",\"validationRules\":[{\"field\":\"args\",\"rule\":\"required\",\"fieldType\":\"json\"}],\"schema\":{\"tableName\":\"_smrt_data_surface_action_tasks\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_data_surface_action_tasks\\\" (\\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 \\\"args\\\" JSON NOT NULL\\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},\"args\":{\"type\":\"JSON\",\"notNull\":true,\"unique\":false}},\"indexes\":[{\"name\":\"_smrt_data_surface_action_tasks_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"_smrt_data_surface_action_tasks_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"d1c4adf8\"},\"importPath\":\"@happyvertical/smrt-agents/server\"},\"@happyvertical/smrt-agents:DataSurfaceActionTokenState\":{\"name\":\"datasurfaceactiontokenstate\",\"className\":\"DataSurfaceActionTokenState\",\"qualifiedName\":\"@happyvertical/smrt-agents:DataSurfaceActionTokenState\",\"collection\":\"datasurfaceactiontokenstates\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/agents/src/server/sql-data-surface-action-state.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"fields\":{\"tokenHash\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"required\":true,\"unique\":true}},\"record\":{\"type\":\"json\",\"required\":true,\"_meta\":{\"required\":true}},\"consumedBy\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"_smrt_data_surface_action_tokens\",\"api\":false,\"cli\":false,\"mcp\":false},\"extends\":\"SmrtObject\",\"exportName\":\"DataSurfaceActionTokenState\",\"collectionExportName\":\"DataSurfaceActionTokenStateCollection\",\"validationRules\":[{\"field\":\"tokenHash\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"record\",\"rule\":\"required\",\"fieldType\":\"json\"}],\"schema\":{\"tableName\":\"_smrt_data_surface_action_tokens\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_data_surface_action_tokens\\\" (\\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 \\\"token_hash\\\" TEXT NOT NULL UNIQUE,\\n \\\"record\\\" JSON NOT NULL,\\n \\\"consumed_by\\\" 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\"},\"token_hash\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":true},\"record\":{\"type\":\"JSON\",\"notNull\":true,\"unique\":false},\"consumed_by\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"_smrt_data_surface_action_tokens_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true},{\"name\":\"_smrt_data_surface_action_tokens_created_at_idx\",\"columns\":[\"created_at\"]}],\"version\":\"497cf260\"},\"importPath\":\"@happyvertical/smrt-agents/server\"},\"@happyvertical/smrt-agents:DataSurfaceActionIdempotencyState\":{\"name\":\"datasurfaceactionidempotencystate\",\"className\":\"DataSurfaceActionIdempotencyState\",\"qualifiedName\":\"@happyvertical/smrt-agents:DataSurfaceActionIdempotencyState\",\"collection\":\"datasurfaceactionidempotencystates\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/agents/src/server/sql-data-surface-action-state.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"fields\":{\"keyHash\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"required\":true,\"unique\":true}},\"status\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"required\":true}},\"requestFingerprint\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"required\":true}},\"ownerHash\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"reservedAt\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"result\":{\"type\":\"json\",\"required\":false,\"_meta\":{\"nullable\":true}},\"recovery\":{\"type\":\"json\",\"required\":false,\"_meta\":{\"nullable\":true}}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"_smrt_data_surface_action_idempotency\",\"api\":false,\"cli\":false,\"mcp\":false},\"extends\":\"SmrtObject\",\"exportName\":\"DataSurfaceActionIdempotencyState\",\"collectionExportName\":\"DataSurfaceActionIdempotencyStateCollection\",\"validationRules\":[{\"field\":\"keyHash\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"status\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"requestFingerprint\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"_smrt_data_surface_action_idempotency\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_data_surface_action_idempotency\\\" (\\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 \\\"key_hash\\\" TEXT NOT NULL UNIQUE,\\n \\\"status\\\" TEXT NOT NULL,\\n \\\"request_fingerprint\\\" TEXT NOT NULL,\\n \\\"owner_hash\\\" TEXT,\\n \\\"reserved_at\\\" TEXT,\\n \\\"result\\\" JSON,\\n \\\"recovery\\\" 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\"},\"key_hash\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":true},\"status\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false},\"request_fingerprint\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false},\"owner_hash\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"reserved_at\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"result\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false},\"recovery\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"_smrt_data_surface_action_idempotency_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true},{\"name\":\"_smrt_data_surface_action_idempotency_created_at_idx\",\"columns\":[\"created_at\"]}],\"version\":\"eb65ff1e\"},\"importPath\":\"@happyvertical/smrt-agents/server\"}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\",\"@happyvertical/smrt-jobs\",\"@happyvertical/smrt-playbooks\",\"@happyvertical/smrt-reports\",\"@happyvertical/smrt-secrets\",\"@happyvertical/smrt-tenancy\",\"@happyvertical/smrt-users\"]}"));
|
|
14
|
+
ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":0,\"packageName\":\"@happyvertical/smrt-agents\",\"packageVersion\":\"0.52.0\",\"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\":{\"getInstanceKey\":{\"name\":\"getInstanceKey\",\"async\":false,\"parameters\":[],\"returnType\":\"string | null\",\"isStatic\":false,\"isPublic\":true},\"getConfigOwnerId\":{\"name\":\"getConfigOwnerId\",\"async\":false,\"parameters\":[{\"name\":\"slotId\",\"type\":\"string\",\"optional\":true}],\"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, unknown>>>\",\"isStatic\":false,\"isPublic\":true},\"saveSlotConfig\":{\"name\":\"saveSlotConfig\",\"async\":true,\"parameters\":[{\"name\":\"slotId\",\"type\":\"string\",\"optional\":false},{\"name\":\"data\",\"type\":\"Record<string, unknown>\",\"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, unknown>>\",\"isStatic\":false,\"isPublic\":true},\"exportConfig\":{\"name\":\"exportConfig\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"boolean\"]}],\"returnType\":\"Promise<Record<string, unknown>>\",\"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\":\"unknown\",\"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},\"initialize\":{\"name\":\"initialize\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<this>\",\"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\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\",\"_meta_type\"]},\"extends\":\"SmrtObject\",\"exportName\":\"Agent\",\"collectionExportName\":\"AgentCollection\",\"staticProperties\":{\"uiSlots\":{},\"adminRoutes\":[],\"createEntries\":[],\"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_slug_context_meta_type_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\",\"_meta_type\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"agents_meta_type_idx\",\"columns\":[\"_meta_type\"]},{\"name\":\"agents_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"dde8777b\"},\"importPath\":\"@happyvertical/smrt-agents\"},\"@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, unknown>>>\",\"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, unknown>>>>\",\"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, unknown> | undefined>\",\"isStatic\":true,\"isPublic\":true},\"saveSlot\":{\"name\":\"saveSlot\",\"async\":true,\"parameters\":[{\"name\":\"data\",\"type\":\"object\",\"optional\":false,\"memberTypes\":[\"string\",\"Record<string, unknown>\"]},{\"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\":{\"skipApiCheck\":true},\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"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_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"agent_configs_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"25c6ac4c\"},\"importPath\":\"@happyvertical/smrt-agents\"},\"@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 \\\"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_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"agent_configs_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"25c6ac4c\"},\"importPath\":\"@happyvertical/smrt-agents\"},\"@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\"]},\"indexes\":[{\"name\":\"_smrt_agent_schedules_enabled_status_next_run_idx\",\"columns\":[\"enabled\",\"status\",\"nextRun\"]}],\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"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_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"_smrt_agent_schedules_enabled_status_next_run_idx\",\"columns\":[\"enabled\",\"status\",\"next_run\"]},{\"name\":\"_smrt_agent_schedules_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"c21a1f29\"},\"importPath\":\"@happyvertical/smrt-agents\"},\"@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,\"unionBranches\":[{\"type\":\"ScheduleStatus\"},{\"type\":\"ScheduleStatus[]\"}]},{\"name\":\"options\",\"type\":\"object\",\"optional\":true,\"memberTypes\":[\"number\"]}],\"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,\"memberTypes\":[\"number\",\"boolean\"]}],\"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 \\\"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_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"_smrt_agent_schedules_enabled_status_next_run_idx\",\"columns\":[\"enabled\",\"status\",\"next_run\"]},{\"name\":\"_smrt_agent_schedules_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"c21a1f29\"},\"importPath\":\"@happyvertical/smrt-agents\"},\"@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\":[],\"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_tenant_id_agent_class_idx\",\"columns\":[\"tenant_id\",\"agent_class\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"tenant_agents_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"tenant_agents_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"9892a054\"},\"importPath\":\"@happyvertical/smrt-agents\"},\"@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 \\\"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_tenant_id_agent_class_idx\",\"columns\":[\"tenant_id\",\"agent_class\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"tenant_agents_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"tenant_agents_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"9892a054\"},\"importPath\":\"@happyvertical/smrt-agents\"},\"@happyvertical/smrt-agents:SmrtDataSurfaceActionTask\":{\"name\":\"smrtdatasurfaceactiontask\",\"className\":\"SmrtDataSurfaceActionTask\",\"qualifiedName\":\"@happyvertical/smrt-agents:SmrtDataSurfaceActionTask\",\"collection\":\"smrtdatasurfaceactiontasks\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/agents/src/server/jobs-data-surface-action-queue.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}}},\"args\":{\"type\":\"json\",\"required\":true,\"_meta\":{\"required\":true}}},\"methods\":{\"run\":{\"name\":\"run\",\"async\":true,\"parameters\":[{\"name\":\"args\",\"type\":\"DataSurfaceActionJobArgs\",\"optional\":true},{\"name\":\"context\",\"type\":\"JobExecutionContext\",\"optional\":true}],\"returnType\":\"Promise<DataSurfaceActionResult>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"_smrt_data_surface_action_tasks\",\"api\":false,\"cli\":false,\"mcp\":false,\"tenantScoped\":{\"mode\":\"optional\"},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"SmrtDataSurfaceActionTask\",\"collectionExportName\":\"SmrtDataSurfaceActionTaskCollection\",\"validationRules\":[{\"field\":\"args\",\"rule\":\"required\",\"fieldType\":\"json\"}],\"schema\":{\"tableName\":\"_smrt_data_surface_action_tasks\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_data_surface_action_tasks\\\" (\\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 \\\"args\\\" JSON NOT NULL\\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},\"args\":{\"type\":\"JSON\",\"notNull\":true,\"unique\":false}},\"indexes\":[{\"name\":\"_smrt_data_surface_action_tasks_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"_smrt_data_surface_action_tasks_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"d1c4adf8\"},\"importPath\":\"@happyvertical/smrt-agents/server\"},\"@happyvertical/smrt-agents:DataSurfaceActionTokenState\":{\"name\":\"datasurfaceactiontokenstate\",\"className\":\"DataSurfaceActionTokenState\",\"qualifiedName\":\"@happyvertical/smrt-agents:DataSurfaceActionTokenState\",\"collection\":\"datasurfaceactiontokenstates\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/agents/src/server/sql-data-surface-action-state.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"fields\":{\"tokenHash\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"required\":true,\"unique\":true}},\"record\":{\"type\":\"json\",\"required\":true,\"_meta\":{\"required\":true}},\"consumedBy\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"_smrt_data_surface_action_tokens\",\"api\":false,\"cli\":false,\"mcp\":false},\"extends\":\"SmrtObject\",\"exportName\":\"DataSurfaceActionTokenState\",\"collectionExportName\":\"DataSurfaceActionTokenStateCollection\",\"validationRules\":[{\"field\":\"tokenHash\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"record\",\"rule\":\"required\",\"fieldType\":\"json\"}],\"schema\":{\"tableName\":\"_smrt_data_surface_action_tokens\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_data_surface_action_tokens\\\" (\\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 \\\"token_hash\\\" TEXT NOT NULL UNIQUE,\\n \\\"record\\\" JSON NOT NULL,\\n \\\"consumed_by\\\" 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\"},\"token_hash\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":true},\"record\":{\"type\":\"JSON\",\"notNull\":true,\"unique\":false},\"consumed_by\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"_smrt_data_surface_action_tokens_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true},{\"name\":\"_smrt_data_surface_action_tokens_created_at_idx\",\"columns\":[\"created_at\"]}],\"version\":\"497cf260\"},\"importPath\":\"@happyvertical/smrt-agents/server\"},\"@happyvertical/smrt-agents:DataSurfaceActionIdempotencyState\":{\"name\":\"datasurfaceactionidempotencystate\",\"className\":\"DataSurfaceActionIdempotencyState\",\"qualifiedName\":\"@happyvertical/smrt-agents:DataSurfaceActionIdempotencyState\",\"collection\":\"datasurfaceactionidempotencystates\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/agents/src/server/sql-data-surface-action-state.ts\",\"packageName\":\"@happyvertical/smrt-agents\",\"fields\":{\"keyHash\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"required\":true,\"unique\":true}},\"status\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"required\":true}},\"requestFingerprint\":{\"type\":\"text\",\"required\":true,\"_meta\":{\"required\":true}},\"ownerHash\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"reservedAt\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"nullable\":true}},\"result\":{\"type\":\"json\",\"required\":false,\"_meta\":{\"nullable\":true}},\"recovery\":{\"type\":\"json\",\"required\":false,\"_meta\":{\"nullable\":true}}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"_smrt_data_surface_action_idempotency\",\"api\":false,\"cli\":false,\"mcp\":false},\"extends\":\"SmrtObject\",\"exportName\":\"DataSurfaceActionIdempotencyState\",\"collectionExportName\":\"DataSurfaceActionIdempotencyStateCollection\",\"validationRules\":[{\"field\":\"keyHash\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"status\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"requestFingerprint\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"_smrt_data_surface_action_idempotency\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_data_surface_action_idempotency\\\" (\\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 \\\"key_hash\\\" TEXT NOT NULL UNIQUE,\\n \\\"status\\\" TEXT NOT NULL,\\n \\\"request_fingerprint\\\" TEXT NOT NULL,\\n \\\"owner_hash\\\" TEXT,\\n \\\"reserved_at\\\" TEXT,\\n \\\"result\\\" JSON,\\n \\\"recovery\\\" 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\"},\"key_hash\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":true},\"status\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false},\"request_fingerprint\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false},\"owner_hash\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"reserved_at\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"result\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false},\"recovery\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"_smrt_data_surface_action_idempotency_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true},{\"name\":\"_smrt_data_surface_action_idempotency_created_at_idx\",\"columns\":[\"created_at\"]}],\"version\":\"eb65ff1e\"},\"importPath\":\"@happyvertical/smrt-agents/server\"}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\",\"@happyvertical/smrt-jobs\",\"@happyvertical/smrt-playbooks\",\"@happyvertical/smrt-reports\",\"@happyvertical/smrt-secrets\",\"@happyvertical/smrt-tenancy\",\"@happyvertical/smrt-users\"]}"));
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/ai-config.ts
|
|
17
17
|
var DEFAULT_SECRET_NAMES = {
|
|
@@ -1012,6 +1012,21 @@ __publicField(Agent, "uiSlots", {});
|
|
|
1012
1012
|
*/
|
|
1013
1013
|
__publicField(Agent, "adminRoutes", []);
|
|
1014
1014
|
/**
|
|
1015
|
+
* Create options this agent contributes to the host's "create" menu
|
|
1016
|
+
* (e.g. "Write about a meeting"). Plain data captured into the agent
|
|
1017
|
+
* manifest; hosts read it with `resolveAgentCreateEntries()` from
|
|
1018
|
+
* `@happyvertical/smrt-agents/ui`. Must be a literal array.
|
|
1019
|
+
*
|
|
1020
|
+
* @example
|
|
1021
|
+
* ```typescript
|
|
1022
|
+
* static override createEntries: AgentCreateEntry[] = [
|
|
1023
|
+
* { id: 'meeting-article', type: 'news/politics', label: 'Write about a meeting',
|
|
1024
|
+
* route: 'articles/new/source?for=meeting', availability: { accessLevels: ['admin', 'editor'] } },
|
|
1025
|
+
* ];
|
|
1026
|
+
* ```
|
|
1027
|
+
*/
|
|
1028
|
+
__publicField(Agent, "createEntries", []);
|
|
1029
|
+
/**
|
|
1015
1030
|
* Signal types this agent subscribes to by default
|
|
1016
1031
|
*
|
|
1017
1032
|
* These are seedable defaults — on `initialize()`, the agent checks the
|
|
@@ -1176,22 +1191,77 @@ var reportedFailureErrors = /* @__PURE__ */ new WeakSet();
|
|
|
1176
1191
|
var DataSurfaceRequestError = class extends Error {
|
|
1177
1192
|
status = 400;
|
|
1178
1193
|
code = "DATA_SURFACE_REQUEST_INVALID";
|
|
1179
|
-
|
|
1180
|
-
|
|
1194
|
+
/** The underlying `DataQueryValidationError` code, when there was one. */
|
|
1195
|
+
reason;
|
|
1196
|
+
constructor(message = "Data surface query request is invalid.", reason) {
|
|
1197
|
+
super(message);
|
|
1181
1198
|
this.name = "DataSurfaceRequestError";
|
|
1199
|
+
if (reason !== void 0) this.reason = reason;
|
|
1182
1200
|
}
|
|
1183
1201
|
};
|
|
1184
|
-
var
|
|
1185
|
-
|
|
1186
|
-
"
|
|
1187
|
-
"
|
|
1188
|
-
"
|
|
1202
|
+
var DATA_QUERY_REQUEST_SHAPE_HINT = "Request shape: {\"mode\":\"rows\"|\"count\"|\"facets\", \"projection\":[field], \"filter\":{\"kind\":\"condition\",\"field\":f,\"operator\":op,\"value\":v} | {\"kind\":\"all\"|\"any\",\"filters\":[filter]} | {\"kind\":\"not\",\"filter\":filter}, \"sort\":[{\"field\":f,\"direction\":\"asc\"|\"desc\"}], \"page\":{\"kind\":\"offset\",\"offset\":0,\"limit\":n}, \"facets\":[{\"field\":f,\"limit\":n}]}. projection/sort/page are for rows mode only; facets for facets mode only. Datetime values are RFC 3339 instants such as 2026-09-01T00:00:00Z. Call data.inspect for the fields and operators this surface accepts.";
|
|
1203
|
+
var EXECUTOR_REQUEST_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
1204
|
+
"DATA_QUERY_VALUE_INVALID",
|
|
1205
|
+
"DATA_QUERY_OPERATOR_NOT_ALLOWED",
|
|
1206
|
+
"DATA_QUERY_UNSUPPORTED"
|
|
1189
1207
|
]);
|
|
1208
|
+
function fieldList(schema, predicate) {
|
|
1209
|
+
return schema.fields.filter(predicate).map((field) => field.id);
|
|
1210
|
+
}
|
|
1211
|
+
function listOrNone(label, ids, none) {
|
|
1212
|
+
return ids.length > 0 ? `${label}: ${ids.join(", ")}.` : none;
|
|
1213
|
+
}
|
|
1214
|
+
function disallowedCondition(filter, schema, depth = 0) {
|
|
1215
|
+
if (!isRecord$1(filter) || depth > 16) return void 0;
|
|
1216
|
+
if (filter.kind === "condition" && typeof filter.field === "string") {
|
|
1217
|
+
const descriptor2 = schema.fields.find((field) => field.id === filter.field);
|
|
1218
|
+
const allowed = descriptor2?.filterOperators ?? [];
|
|
1219
|
+
return descriptor2 && !allowed.includes(filter.operator) ? {
|
|
1220
|
+
field: filter.field,
|
|
1221
|
+
allowed
|
|
1222
|
+
} : void 0;
|
|
1223
|
+
}
|
|
1224
|
+
const children = Array.isArray(filter.filters) ? filter.filters : [filter.filter];
|
|
1225
|
+
for (const child of children) {
|
|
1226
|
+
const found = disallowedCondition(child, schema, depth + 1);
|
|
1227
|
+
if (found) return found;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
function explainRequestError(error, schema, request) {
|
|
1231
|
+
const reason = error.publicMessage.replace(/\.?$/, ".");
|
|
1232
|
+
let hint;
|
|
1233
|
+
switch (error.code) {
|
|
1234
|
+
case "DATA_QUERY_FIELD_NOT_ALLOWED":
|
|
1235
|
+
hint = listOrNone("Filterable fields", fieldList(schema, (field) => (field.filterOperators?.length ?? 0) > 0), "This surface has no filterable fields; omit filter.");
|
|
1236
|
+
break;
|
|
1237
|
+
case "DATA_QUERY_OPERATOR_NOT_ALLOWED": {
|
|
1238
|
+
const found = isRecord$1(request) ? disallowedCondition(request.filter, schema) : void 0;
|
|
1239
|
+
hint = found ? found.allowed.length > 0 ? `Allowed operators for ${found.field}: ${found.allowed.join(", ")}.` : `${found.field} cannot be filtered.` : "Call data.inspect for each field’s filterOperators.";
|
|
1240
|
+
break;
|
|
1241
|
+
}
|
|
1242
|
+
case "DATA_QUERY_PROJECTION_NOT_ALLOWED":
|
|
1243
|
+
hint = listOrNone("Projectable fields", fieldList(schema, (field) => field.projectable !== false || field.id === schema.identityField), "Omit projection.");
|
|
1244
|
+
break;
|
|
1245
|
+
case "DATA_QUERY_SORT_NOT_ALLOWED":
|
|
1246
|
+
hint = listOrNone("Sortable fields", fieldList(schema, (field) => field.sortable === true || field.id === schema.identityField), "Omit sort.");
|
|
1247
|
+
break;
|
|
1248
|
+
case "DATA_QUERY_FACET_NOT_ALLOWED":
|
|
1249
|
+
hint = listOrNone("Facetable fields", fieldList(schema, (field) => field.facetable === true), "This surface has no facetable fields; use mode \"count\" or \"rows\".");
|
|
1250
|
+
break;
|
|
1251
|
+
case "DATA_QUERY_UNSUPPORTED": {
|
|
1252
|
+
const supports = schema.supports ?? {};
|
|
1253
|
+
hint = `This surface supports offset paging${supports.cursorPagination ? ", cursor paging" : ""}${supports.facets ? ", facets" : ""}${supports.consistency ? ", consistency options" : ""}.`;
|
|
1254
|
+
break;
|
|
1255
|
+
}
|
|
1256
|
+
default: hint = DATA_QUERY_REQUEST_SHAPE_HINT;
|
|
1257
|
+
}
|
|
1258
|
+
return new DataSurfaceRequestError(`${reason} ${hint}`, error.code);
|
|
1259
|
+
}
|
|
1190
1260
|
function normalizeSurfaceRequest(value, schema) {
|
|
1191
1261
|
try {
|
|
1192
1262
|
return normalizeDataQueryRequest(value, schema);
|
|
1193
1263
|
} catch (error) {
|
|
1194
|
-
if (error instanceof DataQueryValidationError
|
|
1264
|
+
if (error instanceof DataQueryValidationError) throw explainRequestError(error, schema, value);
|
|
1195
1265
|
throw error;
|
|
1196
1266
|
}
|
|
1197
1267
|
}
|
|
@@ -1501,8 +1571,171 @@ async function bounded(promise, deadlineMs, controller) {
|
|
|
1501
1571
|
}
|
|
1502
1572
|
}
|
|
1503
1573
|
function requestFromArgs(args) {
|
|
1504
|
-
|
|
1505
|
-
|
|
1574
|
+
let raw;
|
|
1575
|
+
if (Object.hasOwn(args, "request")) raw = args.request;
|
|
1576
|
+
else {
|
|
1577
|
+
const { surfaceId: _surfaceId, ...rest } = args;
|
|
1578
|
+
raw = rest;
|
|
1579
|
+
}
|
|
1580
|
+
if (!isRecord$1(raw)) return raw;
|
|
1581
|
+
const request = {
|
|
1582
|
+
...raw,
|
|
1583
|
+
version: raw.version ?? 1,
|
|
1584
|
+
requestId: raw.requestId ?? `dq_${randomUUID()}`,
|
|
1585
|
+
mode: raw.mode ?? (raw.facets !== void 0 ? "facets" : "rows")
|
|
1586
|
+
};
|
|
1587
|
+
if (isRecord$1(raw.page)) {
|
|
1588
|
+
const kind = raw.page.kind ?? "offset";
|
|
1589
|
+
request.page = {
|
|
1590
|
+
...raw.page,
|
|
1591
|
+
kind,
|
|
1592
|
+
...kind === "offset" ? { offset: raw.page.offset ?? 0 } : {}
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
return request;
|
|
1596
|
+
}
|
|
1597
|
+
var DATA_QUERY_OPERATORS = [
|
|
1598
|
+
"eq",
|
|
1599
|
+
"ne",
|
|
1600
|
+
"gt",
|
|
1601
|
+
"gte",
|
|
1602
|
+
"lt",
|
|
1603
|
+
"lte",
|
|
1604
|
+
"in",
|
|
1605
|
+
"notIn",
|
|
1606
|
+
"like"
|
|
1607
|
+
];
|
|
1608
|
+
var DATA_QUERY_SCALAR_SCHEMA = [
|
|
1609
|
+
{ type: "string" },
|
|
1610
|
+
{ type: "number" },
|
|
1611
|
+
{ type: "boolean" },
|
|
1612
|
+
{ type: "null" }
|
|
1613
|
+
];
|
|
1614
|
+
var DATA_QUERY_TOOL_PARAMETERS = {
|
|
1615
|
+
type: "object",
|
|
1616
|
+
required: ["surfaceId", "request"],
|
|
1617
|
+
additionalProperties: false,
|
|
1618
|
+
properties: {
|
|
1619
|
+
surfaceId: {
|
|
1620
|
+
type: "string",
|
|
1621
|
+
description: "A surface id from data.discover."
|
|
1622
|
+
},
|
|
1623
|
+
request: {
|
|
1624
|
+
type: "object",
|
|
1625
|
+
additionalProperties: false,
|
|
1626
|
+
properties: {
|
|
1627
|
+
mode: {
|
|
1628
|
+
type: "string",
|
|
1629
|
+
enum: [
|
|
1630
|
+
"rows",
|
|
1631
|
+
"count",
|
|
1632
|
+
"facets"
|
|
1633
|
+
],
|
|
1634
|
+
description: "rows (default): matching records. count: only the total (no projection, sort, or page). facets: value counts for facetable fields."
|
|
1635
|
+
},
|
|
1636
|
+
projection: {
|
|
1637
|
+
type: "array",
|
|
1638
|
+
items: { type: "string" },
|
|
1639
|
+
maxItems: 50,
|
|
1640
|
+
description: "rows only. Projectable fields to return; the identity field is always included."
|
|
1641
|
+
},
|
|
1642
|
+
filter: {
|
|
1643
|
+
type: "object",
|
|
1644
|
+
description: "Optional. A condition {\"kind\":\"condition\",\"field\":f,\"operator\":op,\"value\":v}; {\"kind\":\"all\"|\"any\",\"filters\":[...]} to AND/OR nested filters; or {\"kind\":\"not\",\"filter\":{...}}. field must list op in its filterOperators (data.inspect). value is a scalar, or a non-empty array (max 100) for in/notIn. like takes SQL wildcards (%council%) on string fields. Datetimes are RFC 3339 instants (2026-09-01T00:00:00Z). String fields whose only operators are eq/ne/in/notIn hold ids: compare them with complete id values.",
|
|
1645
|
+
properties: {
|
|
1646
|
+
kind: {
|
|
1647
|
+
type: "string",
|
|
1648
|
+
enum: [
|
|
1649
|
+
"condition",
|
|
1650
|
+
"all",
|
|
1651
|
+
"any",
|
|
1652
|
+
"not"
|
|
1653
|
+
]
|
|
1654
|
+
},
|
|
1655
|
+
field: { type: "string" },
|
|
1656
|
+
operator: {
|
|
1657
|
+
type: "string",
|
|
1658
|
+
enum: [...DATA_QUERY_OPERATORS]
|
|
1659
|
+
},
|
|
1660
|
+
value: { anyOf: [...DATA_QUERY_SCALAR_SCHEMA, {
|
|
1661
|
+
type: "array",
|
|
1662
|
+
items: { anyOf: DATA_QUERY_SCALAR_SCHEMA }
|
|
1663
|
+
}] },
|
|
1664
|
+
filters: {
|
|
1665
|
+
type: "array",
|
|
1666
|
+
items: { type: "object" }
|
|
1667
|
+
},
|
|
1668
|
+
filter: { type: "object" }
|
|
1669
|
+
},
|
|
1670
|
+
required: ["kind"]
|
|
1671
|
+
},
|
|
1672
|
+
sort: {
|
|
1673
|
+
type: "array",
|
|
1674
|
+
description: "rows only. Sortable fields, earlier terms first. Empty values sort first ascending and last descending.",
|
|
1675
|
+
items: {
|
|
1676
|
+
type: "object",
|
|
1677
|
+
additionalProperties: false,
|
|
1678
|
+
required: ["field", "direction"],
|
|
1679
|
+
properties: {
|
|
1680
|
+
field: { type: "string" },
|
|
1681
|
+
direction: {
|
|
1682
|
+
type: "string",
|
|
1683
|
+
enum: ["asc", "desc"]
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
},
|
|
1688
|
+
page: {
|
|
1689
|
+
type: "object",
|
|
1690
|
+
additionalProperties: false,
|
|
1691
|
+
description: "rows only. {\"kind\":\"offset\",\"offset\":0,\"limit\":10}; kind defaults to offset and offset to 0. limit is capped at the surface maxPageLimit. Use {\"kind\":\"cursor\",\"after\":nextCursor,\"limit\":n} only where supports.cursorPagination.",
|
|
1692
|
+
properties: {
|
|
1693
|
+
kind: {
|
|
1694
|
+
type: "string",
|
|
1695
|
+
enum: ["offset", "cursor"]
|
|
1696
|
+
},
|
|
1697
|
+
offset: {
|
|
1698
|
+
type: "integer",
|
|
1699
|
+
minimum: 0
|
|
1700
|
+
},
|
|
1701
|
+
limit: {
|
|
1702
|
+
type: "integer",
|
|
1703
|
+
minimum: 1
|
|
1704
|
+
},
|
|
1705
|
+
after: { type: "string" }
|
|
1706
|
+
},
|
|
1707
|
+
required: ["limit"]
|
|
1708
|
+
},
|
|
1709
|
+
facets: {
|
|
1710
|
+
type: "array",
|
|
1711
|
+
description: "facets mode only (supports.facets). One entry per facetable field.",
|
|
1712
|
+
items: {
|
|
1713
|
+
type: "object",
|
|
1714
|
+
additionalProperties: false,
|
|
1715
|
+
required: ["field", "limit"],
|
|
1716
|
+
properties: {
|
|
1717
|
+
field: { type: "string" },
|
|
1718
|
+
limit: {
|
|
1719
|
+
type: "integer",
|
|
1720
|
+
minimum: 1
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
},
|
|
1725
|
+
version: {
|
|
1726
|
+
type: "integer",
|
|
1727
|
+
enum: [1],
|
|
1728
|
+
description: "Optional; defaults to 1."
|
|
1729
|
+
},
|
|
1730
|
+
requestId: {
|
|
1731
|
+
type: "string",
|
|
1732
|
+
description: "Optional correlation id; generated when omitted."
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
};
|
|
1738
|
+
var DATA_QUERY_TOOL_DESCRIPTION = "Run a bounded, read-only query against one data surface. Call data.inspect first: only the fields, operators, sort fields, facets, and page limits it lists are accepted. Use mode \"count\" for how-many questions and mode \"facets\" for breakdowns by value. Example request: {\"mode\":\"rows\",\"projection\":[\"title\",\"updated_at\"],\"filter\":{\"kind\":\"condition\",\"field\":\"status\",\"operator\":\"eq\",\"value\":\"published\"},\"sort\":[{\"field\":\"updated_at\",\"direction\":\"desc\"}],\"page\":{\"kind\":\"offset\",\"offset\":0,\"limit\":10}}. An invalid request fails with a message naming what was wrong and what is allowed.";
|
|
1506
1739
|
function tool(slug, functionName, description, parameters, execute) {
|
|
1507
1740
|
return {
|
|
1508
1741
|
slug,
|
|
@@ -1567,15 +1800,7 @@ function createDataSurfaceTools(options) {
|
|
|
1567
1800
|
}, run);
|
|
1568
1801
|
return descriptor(entry.surface, entry.schema);
|
|
1569
1802
|
}),
|
|
1570
|
-
tool(DATA_QUERY_TOOL_SLUG, DATA_QUERY_FUNCTION_NAME,
|
|
1571
|
-
type: "object",
|
|
1572
|
-
required: ["surfaceId", "request"],
|
|
1573
|
-
properties: {
|
|
1574
|
-
surfaceId: { type: "string" },
|
|
1575
|
-
request: { type: "object" }
|
|
1576
|
-
},
|
|
1577
|
-
additionalProperties: false
|
|
1578
|
-
}, async ({ run, args, db }) => {
|
|
1803
|
+
tool(DATA_QUERY_TOOL_SLUG, DATA_QUERY_FUNCTION_NAME, DATA_QUERY_TOOL_DESCRIPTION, DATA_QUERY_TOOL_PARAMETERS, async ({ run, args, db }) => {
|
|
1579
1804
|
run.assertToolAllowed(DATA_QUERY_TOOL_SLUG);
|
|
1580
1805
|
const entry = findSurface(await catalog(run, "query"), args.surfaceId);
|
|
1581
1806
|
if (!entry) throw new DataSurfaceDeniedError();
|
|
@@ -1591,6 +1816,9 @@ function createDataSurfaceTools(options) {
|
|
|
1591
1816
|
principal,
|
|
1592
1817
|
db: run.context.database ?? db,
|
|
1593
1818
|
signal: signal.signal
|
|
1819
|
+
}).catch((error) => {
|
|
1820
|
+
if (error instanceof DataQueryValidationError && EXECUTOR_REQUEST_ERROR_CODES.has(error.code)) throw new DataSurfaceRequestError(error.publicMessage, error.code);
|
|
1821
|
+
throw error;
|
|
1594
1822
|
}), deadlineMs, signal);
|
|
1595
1823
|
const rawRecord = isRecord$1(raw) ? raw : void 0;
|
|
1596
1824
|
const rawRows = Array.isArray(raw) ? raw : rawRecord && Array.isArray(rawRecord.rows) ? rawRecord.rows : [];
|
|
@@ -1624,6 +1852,7 @@ function createDataSurfaceTools(options) {
|
|
|
1624
1852
|
}, run);
|
|
1625
1853
|
return result;
|
|
1626
1854
|
} catch (error) {
|
|
1855
|
+
if (error instanceof DataSurfaceRequestError) throw error;
|
|
1627
1856
|
if (!(typeof error === "object" && error !== null || typeof error === "function" ? reportedFailureErrors.has(error) : false)) await reportFailure(options, run, "query", entry.surface.id, request.requestId, error);
|
|
1628
1857
|
if (error instanceof DataSurfaceDeadlineError || error instanceof DataSurfaceResultOrderError || error instanceof DataSurfaceQueryError) throw error;
|
|
1629
1858
|
throw new DataSurfaceQueryError();
|
|
@@ -1958,7 +2187,7 @@ function normalizeRows(rows) {
|
|
|
1958
2187
|
}
|
|
1959
2188
|
return candidates;
|
|
1960
2189
|
}
|
|
1961
|
-
async function readRows(db) {
|
|
2190
|
+
async function readRows$1(db) {
|
|
1962
2191
|
return (await db.query(`SELECT id, slug, context, tenant_id FROM "${AGENT_SCHEDULE_TABLE}" ORDER BY id`)).rows;
|
|
1963
2192
|
}
|
|
1964
2193
|
async function assertSupportedShape(db) {
|
|
@@ -1972,7 +2201,7 @@ function timeout(value, fallback) {
|
|
|
1972
2201
|
}
|
|
1973
2202
|
async function planAgentScheduleSlugMigration(db) {
|
|
1974
2203
|
await assertSupportedShape(db);
|
|
1975
|
-
return { pending: normalizeRows(await readRows(db)).length };
|
|
2204
|
+
return { pending: normalizeRows(await readRows$1(db)).length };
|
|
1976
2205
|
}
|
|
1977
2206
|
async function migrateAgentScheduleSlugs(db, options = {}) {
|
|
1978
2207
|
if (!db.transaction) throw new AgentScheduleSlugBackfillError("Agent schedule slug migration requires a transaction-capable PostgreSQL adapter");
|
|
@@ -1985,7 +2214,7 @@ async function migrateAgentScheduleSlugs(db, options = {}) {
|
|
|
1985
2214
|
await tx.query(`SET LOCAL lock_timeout = '${timeout(options.lockTimeout, 3e4)}'`);
|
|
1986
2215
|
await tx.query(`SET LOCAL statement_timeout = '${timeout(options.statementTimeout, 6e4)}'`);
|
|
1987
2216
|
await tx.query(`LOCK TABLE "${AGENT_SCHEDULE_TABLE}" IN ACCESS EXCLUSIVE MODE`);
|
|
1988
|
-
const candidates = normalizeRows(await readRows(tx));
|
|
2217
|
+
const candidates = normalizeRows(await readRows$1(tx));
|
|
1989
2218
|
if (await transactionTracker.isApplied(backfillName)) {
|
|
1990
2219
|
if (candidates.length > 0) throw new AgentScheduleSlugBackfillError("The schedule slug backfill marker exists but rows still need migration; refusing inconsistent state");
|
|
1991
2220
|
return {
|
|
@@ -1994,7 +2223,7 @@ async function migrateAgentScheduleSlugs(db, options = {}) {
|
|
|
1994
2223
|
};
|
|
1995
2224
|
}
|
|
1996
2225
|
for (const candidate of candidates) await tx.query(`UPDATE "${AGENT_SCHEDULE_TABLE}" SET slug = ? WHERE id = ? AND (slug IS NULL OR slug = '')`, candidate.slug, candidate.id);
|
|
1997
|
-
if (normalizeRows(await readRows(tx)).length > 0) throw new AgentScheduleSlugBackfillError("Schedule slug migration did not fill every missing slug");
|
|
2226
|
+
if (normalizeRows(await readRows$1(tx)).length > 0) throw new AgentScheduleSlugBackfillError("Schedule slug migration did not fill every missing slug");
|
|
1998
2227
|
await tx.query(`ALTER TABLE "${AGENT_SCHEDULE_TABLE}" ALTER COLUMN slug SET NOT NULL`);
|
|
1999
2228
|
await transactionTracker.recordApplied(backfillName, {
|
|
2000
2229
|
description: "Backfilled canonical slugs for legacy AgentSchedule rows.",
|
|
@@ -2007,6 +2236,221 @@ async function migrateAgentScheduleSlugs(db, options = {}) {
|
|
|
2007
2236
|
});
|
|
2008
2237
|
}
|
|
2009
2238
|
//#endregion
|
|
2239
|
+
//#region src/migrations/tenant-agent-config-keys.ts
|
|
2240
|
+
var TENANT_AGENTS_TABLE = "tenant_agents";
|
|
2241
|
+
var AGENT_CONFIGS_TABLE = "agent_configs";
|
|
2242
|
+
var TenantAgentConfigKeyRepairError = class extends Error {
|
|
2243
|
+
constructor(message) {
|
|
2244
|
+
super(message);
|
|
2245
|
+
this.name = "TenantAgentConfigKeyRepairError";
|
|
2246
|
+
}
|
|
2247
|
+
};
|
|
2248
|
+
function text(value) {
|
|
2249
|
+
return value === null || value === void 0 ? "" : String(value);
|
|
2250
|
+
}
|
|
2251
|
+
function optionalText(value) {
|
|
2252
|
+
const value_ = text(value);
|
|
2253
|
+
return value_.length > 0 ? value_ : null;
|
|
2254
|
+
}
|
|
2255
|
+
function canonicalizer(options) {
|
|
2256
|
+
if (options.resolveAgentType) return options.resolveAgentType;
|
|
2257
|
+
const aliases = options.aliases ?? {};
|
|
2258
|
+
return (stored) => Object.hasOwn(aliases, stored) ? aliases[stored] : getAgentTypeName(stored);
|
|
2259
|
+
}
|
|
2260
|
+
function group(rows, key) {
|
|
2261
|
+
const groups = /* @__PURE__ */ new Map();
|
|
2262
|
+
for (const row of rows) {
|
|
2263
|
+
const k = key(row);
|
|
2264
|
+
groups.set(k, [...groups.get(k) ?? [], row]);
|
|
2265
|
+
}
|
|
2266
|
+
return groups;
|
|
2267
|
+
}
|
|
2268
|
+
function planTenantAgentConfigKeyRepairRows(tenantAgentRows, configRows, options = {}) {
|
|
2269
|
+
const canonical = canonicalizer(options);
|
|
2270
|
+
const plan = {
|
|
2271
|
+
tenantAgents: {
|
|
2272
|
+
clean: [],
|
|
2273
|
+
planned: [],
|
|
2274
|
+
blocked: []
|
|
2275
|
+
},
|
|
2276
|
+
configs: {
|
|
2277
|
+
clean: [],
|
|
2278
|
+
planned: [],
|
|
2279
|
+
blocked: [],
|
|
2280
|
+
skipped: []
|
|
2281
|
+
}
|
|
2282
|
+
};
|
|
2283
|
+
const bindings = tenantAgentRows.map((row) => {
|
|
2284
|
+
const agentClass = text(row.agent_class);
|
|
2285
|
+
return {
|
|
2286
|
+
id: text(row.id),
|
|
2287
|
+
tenantId: text(row.tenant_id),
|
|
2288
|
+
agentClass,
|
|
2289
|
+
targetAgentClass: canonical(agentClass)
|
|
2290
|
+
};
|
|
2291
|
+
});
|
|
2292
|
+
const bindingPeers = group(bindings, (row) => `${row.tenantId}\0${row.targetAgentClass}`);
|
|
2293
|
+
for (const row of bindings) {
|
|
2294
|
+
const peers = bindingPeers.get(`${row.tenantId}\0${row.targetAgentClass}`) ?? [];
|
|
2295
|
+
if (peers.length > 1) {
|
|
2296
|
+
row.reason = `${peers.length} bindings for this tenant resolve to ${row.targetAgentClass}`;
|
|
2297
|
+
plan.tenantAgents.blocked.push(row);
|
|
2298
|
+
} else if (row.agentClass === row.targetAgentClass) plan.tenantAgents.clean.push(row);
|
|
2299
|
+
else plan.tenantAgents.planned.push(row);
|
|
2300
|
+
}
|
|
2301
|
+
const boundOwnerIds = new Set(bindings.map((row) => `${row.tenantId}:${row.targetAgentClass}`));
|
|
2302
|
+
const configs = configRows.map((row) => {
|
|
2303
|
+
const tenantId = optionalText(row.tenant_id);
|
|
2304
|
+
const agentId = text(row.agent_id);
|
|
2305
|
+
const agentClass = text(row.agent_class);
|
|
2306
|
+
const slotId = text(row.slot_id);
|
|
2307
|
+
const slug = text(row.slug);
|
|
2308
|
+
const ownerType = tenantId ? parseTenantAgentConfigOwnerId(agentId, tenantId) : null;
|
|
2309
|
+
const base = {
|
|
2310
|
+
id: text(row.id),
|
|
2311
|
+
tenantId,
|
|
2312
|
+
slotId,
|
|
2313
|
+
agentId,
|
|
2314
|
+
agentClass,
|
|
2315
|
+
slug
|
|
2316
|
+
};
|
|
2317
|
+
if (!tenantId || !ownerType) return {
|
|
2318
|
+
...base,
|
|
2319
|
+
targetAgentId: agentId,
|
|
2320
|
+
targetAgentClass: agentClass,
|
|
2321
|
+
targetSlug: slug,
|
|
2322
|
+
unbound: false,
|
|
2323
|
+
reason: tenantId ? "owner id is not <tenant>:<agent type>" : "no tenant_id"
|
|
2324
|
+
};
|
|
2325
|
+
const targetType = canonical(ownerType);
|
|
2326
|
+
const targetAgentId = targetType === ownerType ? agentId : `${tenantId}:${targetType}`;
|
|
2327
|
+
const moved = targetAgentId !== agentId;
|
|
2328
|
+
return {
|
|
2329
|
+
...base,
|
|
2330
|
+
targetAgentId,
|
|
2331
|
+
targetAgentClass: targetType,
|
|
2332
|
+
targetSlug: moved ? `${targetAgentId}-${slotId}` : slug,
|
|
2333
|
+
unbound: !boundOwnerIds.has(targetAgentId)
|
|
2334
|
+
};
|
|
2335
|
+
});
|
|
2336
|
+
const slotPeers = group(configs.filter((row) => !row.reason), (row) => `${row.tenantId}\0${row.targetAgentId}\0${row.slotId}`);
|
|
2337
|
+
const slugPeers = group(configs, (row) => `${row.tenantId}\0${row.targetSlug}`);
|
|
2338
|
+
for (const row of configs) {
|
|
2339
|
+
if (row.reason) {
|
|
2340
|
+
plan.configs.skipped.push(row);
|
|
2341
|
+
continue;
|
|
2342
|
+
}
|
|
2343
|
+
const sameSlot = slotPeers.get(`${row.tenantId}\0${row.targetAgentId}\0${row.slotId}`) ?? [];
|
|
2344
|
+
const sameSlug = slugPeers.get(`${row.tenantId}\0${row.targetSlug}`) ?? [];
|
|
2345
|
+
if (sameSlot.length > 1) {
|
|
2346
|
+
row.reason = `${sameSlot.length} rows hold slot "${row.slotId}" for ${row.targetAgentId}`;
|
|
2347
|
+
plan.configs.blocked.push(row);
|
|
2348
|
+
} else if (sameSlug.length > 1) {
|
|
2349
|
+
row.reason = `slug ${row.targetSlug} is already taken`;
|
|
2350
|
+
plan.configs.blocked.push(row);
|
|
2351
|
+
} else if (row.agentId === row.targetAgentId && row.agentClass === row.targetAgentClass && row.slug === row.targetSlug) plan.configs.clean.push(row);
|
|
2352
|
+
else plan.configs.planned.push(row);
|
|
2353
|
+
}
|
|
2354
|
+
return plan;
|
|
2355
|
+
}
|
|
2356
|
+
async function readRows(db) {
|
|
2357
|
+
const tenantAgents = await db.query(`SELECT id, tenant_id, agent_class FROM ${TENANT_AGENTS_TABLE} ORDER BY tenant_id, agent_class, id`);
|
|
2358
|
+
const configs = await db.query(`SELECT id, tenant_id, agent_id, agent_class, slot_id, slug FROM ${AGENT_CONFIGS_TABLE} ORDER BY tenant_id, agent_id, slot_id, id`);
|
|
2359
|
+
return {
|
|
2360
|
+
tenantAgents: tenantAgents.rows,
|
|
2361
|
+
configs: configs.rows
|
|
2362
|
+
};
|
|
2363
|
+
}
|
|
2364
|
+
async function planTenantAgentConfigKeyRepair(db, options = {}) {
|
|
2365
|
+
const rows = await readRows(db);
|
|
2366
|
+
return planTenantAgentConfigKeyRepairRows(rows.tenantAgents, rows.configs, options);
|
|
2367
|
+
}
|
|
2368
|
+
function describeBlocked(plan) {
|
|
2369
|
+
return [...plan.tenantAgents.blocked.map((row) => `${TENANT_AGENTS_TABLE} ${row.id} (${row.tenantId} ${row.agentClass}): ${row.reason}`), ...plan.configs.blocked.map((row) => `${AGENT_CONFIGS_TABLE} ${row.id} (${row.agentId}/${row.slotId}): ${row.reason}`)];
|
|
2370
|
+
}
|
|
2371
|
+
function totalsFor(plan, changed) {
|
|
2372
|
+
const { tenantAgents: ta, configs: c } = plan;
|
|
2373
|
+
const considered = [
|
|
2374
|
+
...c.clean,
|
|
2375
|
+
...c.planned,
|
|
2376
|
+
...c.blocked
|
|
2377
|
+
];
|
|
2378
|
+
return {
|
|
2379
|
+
tenantAgents: {
|
|
2380
|
+
total: ta.clean.length + ta.planned.length + ta.blocked.length,
|
|
2381
|
+
clean: ta.clean.length,
|
|
2382
|
+
planned: ta.planned.length,
|
|
2383
|
+
blocked: ta.blocked.length
|
|
2384
|
+
},
|
|
2385
|
+
configs: {
|
|
2386
|
+
total: considered.length + c.skipped.length,
|
|
2387
|
+
clean: c.clean.length,
|
|
2388
|
+
planned: c.planned.length,
|
|
2389
|
+
blocked: c.blocked.length,
|
|
2390
|
+
skipped: c.skipped.length,
|
|
2391
|
+
unbound: considered.filter((row) => row.unbound).length
|
|
2392
|
+
},
|
|
2393
|
+
changed
|
|
2394
|
+
};
|
|
2395
|
+
}
|
|
2396
|
+
async function repairTenantAgentConfigKeys(db, options = {}) {
|
|
2397
|
+
if (!options.apply) {
|
|
2398
|
+
const plan = await planTenantAgentConfigKeyRepair(db, options);
|
|
2399
|
+
return {
|
|
2400
|
+
mode: "dry-run",
|
|
2401
|
+
plan,
|
|
2402
|
+
totals: totalsFor(plan, 0),
|
|
2403
|
+
ledger: []
|
|
2404
|
+
};
|
|
2405
|
+
}
|
|
2406
|
+
if (!db.transaction) throw new TenantAgentConfigKeyRepairError("Applying the tenant agent config key repair requires a transaction-capable database adapter");
|
|
2407
|
+
const postgres = detectEngine(db.url ?? "") === "postgres";
|
|
2408
|
+
return db.transaction(async (tx) => {
|
|
2409
|
+
if (postgres) await tx.query(`LOCK TABLE ${TENANT_AGENTS_TABLE}, ${AGENT_CONFIGS_TABLE} IN SHARE ROW EXCLUSIVE MODE`);
|
|
2410
|
+
const plan = await planTenantAgentConfigKeyRepair(tx, options);
|
|
2411
|
+
const blocked = describeBlocked(plan);
|
|
2412
|
+
if (blocked.length > 0) throw new TenantAgentConfigKeyRepairError(`Tenant agent config key repair refused: ${blocked.length} row(s) blocked. Nothing was changed.
|
|
2413
|
+
${blocked.join("\n")}`);
|
|
2414
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2415
|
+
const ledger = [];
|
|
2416
|
+
for (const row of plan.tenantAgents.planned) {
|
|
2417
|
+
await tx.query(`UPDATE ${TENANT_AGENTS_TABLE} SET agent_class = ?, updated_at = ? WHERE id = ? AND agent_class = ?`, row.targetAgentClass, now, row.id, row.agentClass);
|
|
2418
|
+
ledger.push({
|
|
2419
|
+
table: TENANT_AGENTS_TABLE,
|
|
2420
|
+
id: row.id,
|
|
2421
|
+
before: { agent_class: row.agentClass },
|
|
2422
|
+
after: { agent_class: row.targetAgentClass }
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2425
|
+
for (const row of plan.configs.planned) {
|
|
2426
|
+
await tx.query(`UPDATE ${AGENT_CONFIGS_TABLE} SET agent_id = ?, agent_class = ?, slug = ?, updated_at = ? WHERE id = ? AND agent_id = ?`, row.targetAgentId, row.targetAgentClass, row.targetSlug, now, row.id, row.agentId);
|
|
2427
|
+
ledger.push({
|
|
2428
|
+
table: AGENT_CONFIGS_TABLE,
|
|
2429
|
+
id: row.id,
|
|
2430
|
+
before: {
|
|
2431
|
+
agent_id: row.agentId,
|
|
2432
|
+
agent_class: row.agentClass,
|
|
2433
|
+
slug: row.slug
|
|
2434
|
+
},
|
|
2435
|
+
after: {
|
|
2436
|
+
agent_id: row.targetAgentId,
|
|
2437
|
+
agent_class: row.targetAgentClass,
|
|
2438
|
+
slug: row.targetSlug
|
|
2439
|
+
}
|
|
2440
|
+
});
|
|
2441
|
+
}
|
|
2442
|
+
const after = await planTenantAgentConfigKeyRepair(tx, options);
|
|
2443
|
+
const remaining = after.tenantAgents.planned.length + after.configs.planned.length;
|
|
2444
|
+
if (remaining > 0 || describeBlocked(after).length > 0) throw new TenantAgentConfigKeyRepairError(`Tenant agent config key repair post-check failed (${remaining} row(s) still to repair); rolled back.`);
|
|
2445
|
+
return {
|
|
2446
|
+
mode: "apply",
|
|
2447
|
+
plan: after,
|
|
2448
|
+
totals: totalsFor(after, ledger.length),
|
|
2449
|
+
ledger
|
|
2450
|
+
};
|
|
2451
|
+
});
|
|
2452
|
+
}
|
|
2453
|
+
//#endregion
|
|
2010
2454
|
//#region src/playbook-preflight.ts
|
|
2011
2455
|
var PLAYBOOK_PREFLIGHT_TOOL_SLUG = "playbooks.preflight";
|
|
2012
2456
|
var PLAYBOOK_PREFLIGHT_FUNCTION_NAME = "playbook_preflight";
|
|
@@ -2834,6 +3278,40 @@ function filterOperatorsFor(type) {
|
|
|
2834
3278
|
case "json": return;
|
|
2835
3279
|
}
|
|
2836
3280
|
}
|
|
3281
|
+
var ID_FIELD_FILTER_OPERATORS = [
|
|
3282
|
+
"eq",
|
|
3283
|
+
"in",
|
|
3284
|
+
"ne",
|
|
3285
|
+
"notIn"
|
|
3286
|
+
];
|
|
3287
|
+
var UUID_VALUE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
3288
|
+
function uuidColumnFieldIds(qualifiedName, fieldIds) {
|
|
3289
|
+
const columns = (ObjectRegistry.getSchema(qualifiedName) ?? ObjectRegistry.getSchema(getClassName(qualifiedName)))?.columns ?? {};
|
|
3290
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3291
|
+
for (const id of fieldIds) {
|
|
3292
|
+
const column = columns[toSnakeCase(id)] ?? columns[id];
|
|
3293
|
+
if (String(column?.type ?? "").toUpperCase() === "UUID") ids.add(id);
|
|
3294
|
+
}
|
|
3295
|
+
return ids;
|
|
3296
|
+
}
|
|
3297
|
+
function assertIdFieldConditions(filter, idFields) {
|
|
3298
|
+
if (!filter || idFields.size === 0) return;
|
|
3299
|
+
if (filter.kind === "condition") {
|
|
3300
|
+
if (!idFields.has(filter.field)) return;
|
|
3301
|
+
if (!ID_FIELD_FILTER_OPERATORS.includes(filter.operator)) queryFail(`Data query operator ${filter.operator} is not allowed for ${filter.field}: it holds ids, which support only ${ID_FIELD_FILTER_OPERATORS.join(", ")}`, "DATA_QUERY_OPERATOR_NOT_ALLOWED");
|
|
3302
|
+
if ((Array.isArray(filter.value) ? filter.value : [filter.value]).some((value) => value !== null && (typeof value !== "string" || !UUID_VALUE.test(value)))) queryFail(`Data query value for ${filter.field} must be a complete id (a UUID such as 123e4567-e89b-12d3-a456-426614174000)`, "DATA_QUERY_VALUE_INVALID");
|
|
3303
|
+
return;
|
|
3304
|
+
}
|
|
3305
|
+
if (filter.kind === "not") {
|
|
3306
|
+
assertIdFieldConditions(filter.filter, idFields);
|
|
3307
|
+
return;
|
|
3308
|
+
}
|
|
3309
|
+
for (const child of filter.filters) assertIdFieldConditions(child, idFields);
|
|
3310
|
+
}
|
|
3311
|
+
function dataQueryOrderByTerms(sort) {
|
|
3312
|
+
if (!sort || sort.length === 0) return void 0;
|
|
3313
|
+
return sort.map((term) => term.direction === "desc" ? `${term.field} DESC NULLS LAST` : `${term.field} ASC NULLS FIRST`);
|
|
3314
|
+
}
|
|
2837
3315
|
function meta(field) {
|
|
2838
3316
|
return isPlainRecord(field._meta) ? field._meta : {};
|
|
2839
3317
|
}
|
|
@@ -2861,12 +3339,13 @@ async function registryFieldPolicyExclusionSet(qualifiedName, exclude) {
|
|
|
2861
3339
|
async function buildQuerySchemaForClass(qualifiedName, options) {
|
|
2862
3340
|
const registered = await ObjectRegistry.getAllFields(qualifiedName);
|
|
2863
3341
|
const tenantField = getTenantScopedConfig(qualifiedName)?.field ?? "tenantId";
|
|
3342
|
+
const idFields = uuidColumnFieldIds(qualifiedName, registered.keys());
|
|
2864
3343
|
const fields = [];
|
|
2865
3344
|
for (const [name, field] of registered) {
|
|
2866
3345
|
if (isPolicyExcludedField(name, field, tenantField, options.exclude)) continue;
|
|
2867
3346
|
const type = queryFieldType(field.type);
|
|
2868
3347
|
if (!type) continue;
|
|
2869
|
-
const filterOperators = filterOperatorsFor(type);
|
|
3348
|
+
const filterOperators = idFields.has(name) ? [...ID_FIELD_FILTER_OPERATORS] : filterOperatorsFor(type);
|
|
2870
3349
|
fields.push({
|
|
2871
3350
|
id: name,
|
|
2872
3351
|
type,
|
|
@@ -3036,10 +3515,6 @@ function mergeQueryScope(scope, callerWhere) {
|
|
|
3036
3515
|
if (merged.some((branch) => branch.length === 0)) return queryFail("Data query filter produced an unbounded OR branch", "DATA_QUERY_UNSUPPORTED");
|
|
3037
3516
|
return merged;
|
|
3038
3517
|
}
|
|
3039
|
-
function orderByTerms(sort) {
|
|
3040
|
-
if (!sort || sort.length === 0) return void 0;
|
|
3041
|
-
return sort.map((term) => term.direction === "desc" ? `${term.field} desc` : term.field);
|
|
3042
|
-
}
|
|
3043
3518
|
function computeCursorBinding(request, schema, where) {
|
|
3044
3519
|
const canonicalRequest = canonicalizeDataQuery(request, schema);
|
|
3045
3520
|
return createHash("sha256").update(canonicalRequest).update("\0").update(JSON.stringify(where ?? null)).digest("base64url");
|
|
@@ -3255,6 +3730,7 @@ async function executeSmrtCollectionQuery(collection, rawRequest, options) {
|
|
|
3255
3730
|
truncated: false
|
|
3256
3731
|
}, request, schema);
|
|
3257
3732
|
}
|
|
3733
|
+
assertIdFieldConditions(request.filter, uuidColumnFieldIds(options.qualifiedName, declared));
|
|
3258
3734
|
const callerWhere = request.filter ? filterToDnf(request.filter, declared) : void 0;
|
|
3259
3735
|
const scopeConditions = [...normalizeScopeConditions(resolveTenantReadScope(options.qualifiedName)), ...normalizeApplicationScope(options.scope, schema.identityField)];
|
|
3260
3736
|
const where = mergeQueryScope(scopeConditions.length > 0 ? scopeConditions : void 0, callerWhere);
|
|
@@ -3265,7 +3741,7 @@ async function executeSmrtCollectionQuery(collection, rawRequest, options) {
|
|
|
3265
3741
|
const isCursor = request.page?.kind === "cursor";
|
|
3266
3742
|
const offset = isCursor ? decodeCursor(request.page?.kind === "cursor" ? request.page.after : void 0, cursorBinding) : request.page?.kind === "offset" ? request.page.offset : 0;
|
|
3267
3743
|
const limit = request.page?.limit ?? schema.defaultPageLimit ?? DEFAULT_PAGE_LIMIT;
|
|
3268
|
-
const orderBy =
|
|
3744
|
+
const orderBy = dataQueryOrderByTerms(request.sort);
|
|
3269
3745
|
if (signal) assertNotAborted(signal);
|
|
3270
3746
|
const listed = await collection.list({
|
|
3271
3747
|
select: projection,
|
|
@@ -3640,6 +4116,6 @@ function getManifestForAgent(manifests, agentTypeOrIdentifier) {
|
|
|
3640
4116
|
return manifests.get(agentTypeOrIdentifier) || manifests.get(getAgentClassName(agentTypeOrIdentifier));
|
|
3641
4117
|
}
|
|
3642
4118
|
//#endregion
|
|
3643
|
-
export { AGENT_COMPLETED_SIGNAL, AGENT_INVOKE_SIGNAL, AGENT_SCHEDULE_SLUG_BACKFILL, AGENT_SCHEDULE_TABLE, Agent, AgentConfig, AgentConfigCollection, AgentSchedule, AgentScheduleCollection, AgentScheduleSlugBackfillError, AgentUIRegistry, DATA_DISCOVER_FUNCTION_NAME, DATA_DISCOVER_TOOL_SLUG, DATA_INSPECT_FUNCTION_NAME, DATA_INSPECT_TOOL_SLUG, DATA_QUERY_FUNCTION_NAME, DATA_QUERY_TOOL_SLUG, DEFAULT_DATA_SURFACE_DEADLINE_MS, DataSurfaceDeadlineError, DataSurfaceDeniedError, DataSurfaceQueryError, DataSurfaceRequestError, DataSurfaceResultOrderError, DelegationDepthExceededError, INVOKE_AGENT_FUNCTION_NAME, INVOKE_AGENT_TOOL_SLUG, MAX_DATA_SURFACE_DEADLINE_MS, MAX_DELEGATION_DEPTH, PLAYBOOK_PREFLIGHT_FUNCTION_NAME, PLAYBOOK_PREFLIGHT_TOOL_SLUG, PrincipalToolNotAllowedError, PrincipalWideningError, REPORT_DRILLDOWN_FUNCTION_NAME, REPORT_DRILLDOWN_TOOL_SLUG, REPORT_EXPORT_FUNCTION_NAME, REPORT_EXPORT_TOOL_SLUG, REPORT_QUERY_FUNCTION_NAME, REPORT_QUERY_TOOL_SLUG, REPORT_REFRESH_FUNCTION_NAME, REPORT_REFRESH_TOOL_SLUG, ReportDataSurfaceConfigurationError, ReportDataSurfaceVisibleError, TenantAgent, TenantAgentCollection, agentInvokeSignalType, assertPrincipalNotWidened, assertSmrtCollectionQuerySchema, assertWithinDelegationDepth, buildDataQuerySchemaForClass, canonicalScheduleSlug, clearSmrtCollectionQuerySchemaCache, createDataSurfaceQueryFingerprint, createDataSurfaceTools, createDispatchInvokeTransport, createInvokeAgentTool, createPlaybookPreflightTool, createReportDataSurfaceDefinition, createReportDataSurfaceTools, createSmrtCollectionDataSurfaceDefinition, createUIRegistry, deriveDelegationEnvelope, emitAgentCompletion, executeAsPrincipal, executeDelegatedInvocation, executeSmrtCollectionQuery, filterPlaybooksByPreflight, getClassConfigResolvers, getConfigResolver, inlineInvokeAgentTransport, instanceScopedSubscriber, isLazyConfigSentinel, listConfigResolvers, mergeFilters, migrateAgentScheduleSlugs, normalizeSort, planAgentScheduleSlugMigration, playbookStepCollection, playbookStepToolSlug, processAgentInvocations, registerConfigResolver, resetConfigResolvers, resolveAgentAIOptions, resolveAgentLearning, resolveLazyConfig, rootDelegationEnvelope, surfaceAgentCompletions, unregisterConfigResolver };
|
|
4119
|
+
export { AGENT_COMPLETED_SIGNAL, AGENT_CONFIGS_TABLE, AGENT_INVOKE_SIGNAL, AGENT_SCHEDULE_SLUG_BACKFILL, AGENT_SCHEDULE_TABLE, Agent, AgentConfig, AgentConfigCollection, AgentSchedule, AgentScheduleCollection, AgentScheduleSlugBackfillError, AgentUIRegistry, DATA_DISCOVER_FUNCTION_NAME, DATA_DISCOVER_TOOL_SLUG, DATA_INSPECT_FUNCTION_NAME, DATA_INSPECT_TOOL_SLUG, DATA_QUERY_FUNCTION_NAME, DATA_QUERY_TOOL_PARAMETERS, DATA_QUERY_TOOL_SLUG, DEFAULT_DATA_SURFACE_DEADLINE_MS, DataSurfaceDeadlineError, DataSurfaceDeniedError, DataSurfaceQueryError, DataSurfaceRequestError, DataSurfaceResultOrderError, DelegationDepthExceededError, ID_FIELD_FILTER_OPERATORS, INVOKE_AGENT_FUNCTION_NAME, INVOKE_AGENT_TOOL_SLUG, MAX_DATA_SURFACE_DEADLINE_MS, MAX_DELEGATION_DEPTH, PLAYBOOK_PREFLIGHT_FUNCTION_NAME, PLAYBOOK_PREFLIGHT_TOOL_SLUG, PrincipalToolNotAllowedError, PrincipalWideningError, REPORT_DRILLDOWN_FUNCTION_NAME, REPORT_DRILLDOWN_TOOL_SLUG, REPORT_EXPORT_FUNCTION_NAME, REPORT_EXPORT_TOOL_SLUG, REPORT_QUERY_FUNCTION_NAME, REPORT_QUERY_TOOL_SLUG, REPORT_REFRESH_FUNCTION_NAME, REPORT_REFRESH_TOOL_SLUG, ReportDataSurfaceConfigurationError, ReportDataSurfaceVisibleError, TENANT_AGENTS_TABLE, TenantAgent, TenantAgentCollection, TenantAgentConfigKeyRepairError, agentInvokeSignalType, assertIdFieldConditions, assertPrincipalNotWidened, assertSmrtCollectionQuerySchema, assertWithinDelegationDepth, buildDataQuerySchemaForClass, canonicalScheduleSlug, clearSmrtCollectionQuerySchemaCache, createDataSurfaceQueryFingerprint, createDataSurfaceTools, createDispatchInvokeTransport, createInvokeAgentTool, createPlaybookPreflightTool, createReportDataSurfaceDefinition, createReportDataSurfaceTools, createSmrtCollectionDataSurfaceDefinition, createUIRegistry, dataQueryOrderByTerms, deriveDelegationEnvelope, emitAgentCompletion, executeAsPrincipal, executeDelegatedInvocation, executeSmrtCollectionQuery, filterPlaybooksByPreflight, getAgentClassName, getAgentTypeName, getClassConfigResolvers, getConfigResolver, inlineInvokeAgentTransport, instanceScopedSubscriber, isAgentCreateEntryAvailable, isLazyConfigSentinel, listConfigResolvers, mergeFilters, migrateAgentScheduleSlugs, normalizeSort, parseTenantAgentConfigOwnerId, planAgentScheduleSlugMigration, planTenantAgentConfigKeyRepair, planTenantAgentConfigKeyRepairRows, playbookStepCollection, playbookStepToolSlug, processAgentInvocations, registerConfigResolver, repairTenantAgentConfigKeys, resetConfigResolvers, resolveAgentAIOptions, resolveAgentCreateEntries, resolveAgentLearning, resolveLazyConfig, rootDelegationEnvelope, surfaceAgentCompletions, tenantAgentConfigOwnerId, unregisterConfigResolver, uuidColumnFieldIds };
|
|
3644
4120
|
|
|
3645
4121
|
//# sourceMappingURL=index.js.map
|