@happyvertical/smrt-agents 0.51.3 → 0.51.4
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 +1 -0
- package/README.md +62 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +553 -4
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/sveltekit-data-surface-routes.d.ts +42 -0
- package/dist/server/sveltekit-data-surface-routes.d.ts.map +1 -0
- package/dist/server.js +142 -1
- package/dist/server.js.map +1 -1
- package/dist/smrt-collection-data-surface.d.ts +136 -0
- package/dist/smrt-collection-data-surface.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +5 -5
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
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-DIyBp1oE.js";
|
|
2
2
|
import { AgentUIRegistry, createUIRegistry } from "./ui.js";
|
|
3
|
-
import { DEFAULT_DATA_QUERY_RESULT_BYTES, DataQueryValidationError, LearningMemory, MAX_DATA_QUERY_FILTERS, MAX_DATA_QUERY_REQUEST_BYTES, ObjectRegistry, SmrtCollection, SmrtObject, createDataQueryFingerprint, createDispatchBus, field, getClassConfigResolvers, getConfigResolver, isLazyConfigSentinel, listConfigResolvers, normalizeDataQueryRequest, normalizeDataQueryResult, normalizeDataQuerySchema, registerConfigResolver, resetConfigResolvers, resolveDispatchTenantScope, resolveLazyConfig, smrt, unregisterConfigResolver } from "@happyvertical/smrt-core";
|
|
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";
|
|
4
4
|
import { createLogger } from "@happyvertical/logger";
|
|
5
5
|
import { sanitizeConfig } from "@happyvertical/smrt-config";
|
|
6
|
-
import { TenantScoped, getCurrentTenant, queryGlobal, queryWithGlobals, tenantId, withTenant } from "@happyvertical/smrt-tenancy";
|
|
6
|
+
import { TenantScoped, getCurrentTenant, getTenantScopedConfig, isSuperAdminBypass, isSystemContext, isTenancyEnabled, isTenantScopedClass, queryGlobal, queryWithGlobals, tenantId, withTenant } from "@happyvertical/smrt-tenancy";
|
|
7
7
|
import { SecretService } from "@happyvertical/smrt-secrets";
|
|
8
8
|
import { OperationPermissionError, TenantCollection } from "@happyvertical/smrt-users";
|
|
9
9
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -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.3\",\"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.51.4\",\"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\"]}"));
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/ai-config.ts
|
|
17
17
|
var DEFAULT_SECRET_NAMES = {
|
|
@@ -2751,6 +2751,555 @@ function matchesCronField(value, expr) {
|
|
|
2751
2751
|
return value === parseInt(expr, 10);
|
|
2752
2752
|
}
|
|
2753
2753
|
//#endregion
|
|
2754
|
+
//#region src/smrt-collection-data-surface.ts
|
|
2755
|
+
var DEFAULT_PAGE_LIMIT = 50;
|
|
2756
|
+
var DEFAULT_MAX_PAGE_LIMIT = 200;
|
|
2757
|
+
var DEFAULT_MAX_RESULT_BYTES = 1e6;
|
|
2758
|
+
var RESULT_ENVELOPE_RESERVE_BYTES = 4096;
|
|
2759
|
+
var MIN_RESULT_ROW_BYTES = 512;
|
|
2760
|
+
var MIN_RESULT_BYTES = 4608;
|
|
2761
|
+
var MAX_OR_BRANCHES = 128;
|
|
2762
|
+
function requiredName(value, fallback, label) {
|
|
2763
|
+
const resolved = value ?? fallback;
|
|
2764
|
+
if (resolved.trim().length === 0) throw new Error(`${label} must be a non-empty string`);
|
|
2765
|
+
return resolved;
|
|
2766
|
+
}
|
|
2767
|
+
function queryFail(message, code = "INVALID_DATA_QUERY") {
|
|
2768
|
+
throw new DataQueryValidationError(message, code);
|
|
2769
|
+
}
|
|
2770
|
+
function isPlainRecord(value) {
|
|
2771
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
2772
|
+
const prototype = Object.getPrototypeOf(value);
|
|
2773
|
+
return prototype === Object.prototype || prototype === null;
|
|
2774
|
+
}
|
|
2775
|
+
function queryFieldType(type) {
|
|
2776
|
+
switch (type) {
|
|
2777
|
+
case "text":
|
|
2778
|
+
case "foreignKey":
|
|
2779
|
+
case "crossPackageRef": return "string";
|
|
2780
|
+
case "integer":
|
|
2781
|
+
case "decimal": return "number";
|
|
2782
|
+
case "boolean": return "boolean";
|
|
2783
|
+
case "datetime": return "datetime";
|
|
2784
|
+
case "json": return "json";
|
|
2785
|
+
default: return;
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
function filterOperatorsFor(type) {
|
|
2789
|
+
switch (type) {
|
|
2790
|
+
case "string": return [
|
|
2791
|
+
"eq",
|
|
2792
|
+
"ne",
|
|
2793
|
+
"gt",
|
|
2794
|
+
"gte",
|
|
2795
|
+
"lt",
|
|
2796
|
+
"lte",
|
|
2797
|
+
"in",
|
|
2798
|
+
"notIn",
|
|
2799
|
+
"like"
|
|
2800
|
+
];
|
|
2801
|
+
case "number":
|
|
2802
|
+
case "datetime": return [
|
|
2803
|
+
"eq",
|
|
2804
|
+
"ne",
|
|
2805
|
+
"gt",
|
|
2806
|
+
"gte",
|
|
2807
|
+
"lt",
|
|
2808
|
+
"lte",
|
|
2809
|
+
"in",
|
|
2810
|
+
"notIn"
|
|
2811
|
+
];
|
|
2812
|
+
case "boolean": return [
|
|
2813
|
+
"eq",
|
|
2814
|
+
"ne",
|
|
2815
|
+
"in",
|
|
2816
|
+
"notIn"
|
|
2817
|
+
];
|
|
2818
|
+
case "json": return;
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
function meta(field) {
|
|
2822
|
+
return isPlainRecord(field._meta) ? field._meta : {};
|
|
2823
|
+
}
|
|
2824
|
+
function isRestrictedField(field) {
|
|
2825
|
+
const fieldMeta = meta(field);
|
|
2826
|
+
return field.sensitive === true || fieldMeta.sensitive === true || typeof field.readPermission === "string" || typeof fieldMeta.readPermission === "string";
|
|
2827
|
+
}
|
|
2828
|
+
function isTransientField(field) {
|
|
2829
|
+
return field.transient === true || meta(field).transient === true;
|
|
2830
|
+
}
|
|
2831
|
+
function isTenantField(name, field, tenantField) {
|
|
2832
|
+
const fieldMeta = meta(field);
|
|
2833
|
+
return (isPlainRecord(field.__tenancy) ? field.__tenancy : isPlainRecord(fieldMeta.__tenancy) ? fieldMeta.__tenancy : void 0)?.isTenantIdField === true || name === tenantField || name === "tenantId" || name === "tenant_id";
|
|
2834
|
+
}
|
|
2835
|
+
function isPolicyExcludedField(name, field, tenantField, exclude) {
|
|
2836
|
+
return name.startsWith("_") || exclude.has(name) || isRestrictedField(field) || isTransientField(field) || isTenantField(name, field, tenantField);
|
|
2837
|
+
}
|
|
2838
|
+
async function registryFieldPolicyExclusionSet(qualifiedName, exclude) {
|
|
2839
|
+
const registered = await ObjectRegistry.getAllFields(qualifiedName);
|
|
2840
|
+
const tenantField = getTenantScopedConfig(qualifiedName)?.field ?? "tenantId";
|
|
2841
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
2842
|
+
for (const [name, field] of registered) if (isPolicyExcludedField(name, field, tenantField, exclude)) excluded.add(name);
|
|
2843
|
+
return excluded;
|
|
2844
|
+
}
|
|
2845
|
+
async function buildQuerySchemaForClass(qualifiedName, options) {
|
|
2846
|
+
const registered = await ObjectRegistry.getAllFields(qualifiedName);
|
|
2847
|
+
const tenantField = getTenantScopedConfig(qualifiedName)?.field ?? "tenantId";
|
|
2848
|
+
const fields = [];
|
|
2849
|
+
for (const [name, field] of registered) {
|
|
2850
|
+
if (isPolicyExcludedField(name, field, tenantField, options.exclude)) continue;
|
|
2851
|
+
const type = queryFieldType(field.type);
|
|
2852
|
+
if (!type) continue;
|
|
2853
|
+
const filterOperators = filterOperatorsFor(type);
|
|
2854
|
+
fields.push({
|
|
2855
|
+
id: name,
|
|
2856
|
+
type,
|
|
2857
|
+
projectable: true,
|
|
2858
|
+
sortable: type !== "json",
|
|
2859
|
+
facetable: name !== options.identityField && (type === "string" || type === "boolean" || type === "number"),
|
|
2860
|
+
...filterOperators ? { filterOperators } : {}
|
|
2861
|
+
});
|
|
2862
|
+
}
|
|
2863
|
+
if (!fields.find((field) => field.id === options.identityField)) throw new Error(`${qualifiedName} does not declare a queryable '${options.identityField}' field`);
|
|
2864
|
+
const declared = new Set(fields.map((field) => field.id));
|
|
2865
|
+
const defaultSort = (options.defaultSort ?? []).filter((term) => declared.has(term.field));
|
|
2866
|
+
return {
|
|
2867
|
+
version: 1,
|
|
2868
|
+
identityField: options.identityField,
|
|
2869
|
+
fields,
|
|
2870
|
+
defaultPageLimit: options.defaultPageLimit,
|
|
2871
|
+
maxPageLimit: options.maxPageLimit,
|
|
2872
|
+
maxResultBytes: options.maxResultBytes,
|
|
2873
|
+
...defaultSort.length > 0 ? { defaultSort } : {},
|
|
2874
|
+
supports: {
|
|
2875
|
+
cursorPagination: options.cursorPagination,
|
|
2876
|
+
consistency: false,
|
|
2877
|
+
facets: options.facets
|
|
2878
|
+
}
|
|
2879
|
+
};
|
|
2880
|
+
}
|
|
2881
|
+
var schemaCache = /* @__PURE__ */ new Map();
|
|
2882
|
+
function buildDataQuerySchemaForClass(qualifiedName, options = {}) {
|
|
2883
|
+
const identityField = options.identityField ?? "id";
|
|
2884
|
+
const excluded = [...new Set(options.exclude ?? [])].sort();
|
|
2885
|
+
const maxPageLimit = options.maxPageLimit ?? DEFAULT_MAX_PAGE_LIMIT;
|
|
2886
|
+
const defaultPageLimit = options.defaultPageLimit ?? Math.min(DEFAULT_PAGE_LIMIT, maxPageLimit);
|
|
2887
|
+
const maxResultBytes = options.maxResultBytes ?? DEFAULT_MAX_RESULT_BYTES;
|
|
2888
|
+
const cursorPagination = options.cursorPagination ?? true;
|
|
2889
|
+
const facets = options.facets ?? true;
|
|
2890
|
+
const canonicalDefaultSort = (options.defaultSort ?? []).map((term) => `${term.field}:${term.direction}`).join(",");
|
|
2891
|
+
const key = [
|
|
2892
|
+
qualifiedName,
|
|
2893
|
+
identityField,
|
|
2894
|
+
excluded.join(","),
|
|
2895
|
+
defaultPageLimit,
|
|
2896
|
+
maxPageLimit,
|
|
2897
|
+
maxResultBytes,
|
|
2898
|
+
canonicalDefaultSort,
|
|
2899
|
+
cursorPagination,
|
|
2900
|
+
facets
|
|
2901
|
+
].join("::");
|
|
2902
|
+
const cached = schemaCache.get(key);
|
|
2903
|
+
if (cached) return cached;
|
|
2904
|
+
const pending = buildQuerySchemaForClass(qualifiedName, {
|
|
2905
|
+
exclude: new Set(excluded),
|
|
2906
|
+
identityField,
|
|
2907
|
+
defaultPageLimit,
|
|
2908
|
+
maxPageLimit,
|
|
2909
|
+
maxResultBytes,
|
|
2910
|
+
defaultSort: options.defaultSort,
|
|
2911
|
+
cursorPagination,
|
|
2912
|
+
facets
|
|
2913
|
+
}).catch((cause) => {
|
|
2914
|
+
schemaCache.delete(key);
|
|
2915
|
+
throw cause;
|
|
2916
|
+
});
|
|
2917
|
+
schemaCache.set(key, pending);
|
|
2918
|
+
return pending;
|
|
2919
|
+
}
|
|
2920
|
+
function clearSmrtCollectionQuerySchemaCache() {
|
|
2921
|
+
schemaCache.clear();
|
|
2922
|
+
}
|
|
2923
|
+
function redactedQuerySchema(schema) {
|
|
2924
|
+
return {
|
|
2925
|
+
...schema,
|
|
2926
|
+
fields: schema.fields.filter(({ sensitive, readPermission }) => {
|
|
2927
|
+
if (sensitive) return false;
|
|
2928
|
+
return !readPermission;
|
|
2929
|
+
}).map(({ sensitive: _sensitive, readPermission: _readPermission, metadata: _metadata, ...field }) => field)
|
|
2930
|
+
};
|
|
2931
|
+
}
|
|
2932
|
+
function assertUsableResultBudget(schema) {
|
|
2933
|
+
const budget = schema.maxResultBytes ?? DEFAULT_MAX_RESULT_BYTES;
|
|
2934
|
+
if (budget >= MIN_RESULT_BYTES) return;
|
|
2935
|
+
throw new Error(`Data query schema maxResultBytes must be at least ${MIN_RESULT_BYTES} (${RESULT_ENVELOPE_RESERVE_BYTES} reserved for the result envelope, ${MIN_RESULT_ROW_BYTES} for rows); received ${budget}.`);
|
|
2936
|
+
}
|
|
2937
|
+
function assertSmrtCollectionQuerySchema(schema) {
|
|
2938
|
+
normalizeDataQuerySchema(schema);
|
|
2939
|
+
assertUsableResultBudget(schema);
|
|
2940
|
+
}
|
|
2941
|
+
function resolveTenantReadScope(qualifiedName) {
|
|
2942
|
+
if (!isTenancyEnabled()) return void 0;
|
|
2943
|
+
if (!isTenantScopedClass(qualifiedName)) return void 0;
|
|
2944
|
+
if (isSuperAdminBypass() || isSystemContext()) return void 0;
|
|
2945
|
+
return { [getTenantScopedConfig(qualifiedName)?.field ?? "tenantId"]: getCurrentTenant()?.tenantId ?? null };
|
|
2946
|
+
}
|
|
2947
|
+
function inverseOperator(operator) {
|
|
2948
|
+
switch (operator) {
|
|
2949
|
+
case "eq": return "ne";
|
|
2950
|
+
case "ne": return "eq";
|
|
2951
|
+
case "gt": return "lte";
|
|
2952
|
+
case "gte": return "lt";
|
|
2953
|
+
case "lt": return "gte";
|
|
2954
|
+
case "lte": return "gt";
|
|
2955
|
+
case "in": return "notIn";
|
|
2956
|
+
case "notIn": return "in";
|
|
2957
|
+
case "like": return queryFail("Data queries cannot negate a like predicate", "DATA_QUERY_UNSUPPORTED");
|
|
2958
|
+
}
|
|
2959
|
+
}
|
|
2960
|
+
function conditionToDnf(field, operator, value, negated = false) {
|
|
2961
|
+
const key = (suffix) => suffix ? `${field} ${suffix}` : field;
|
|
2962
|
+
const single = (whereKey, whereValue) => [[{ [whereKey]: whereValue }]];
|
|
2963
|
+
if (operator === "in") {
|
|
2964
|
+
const values = value ?? [];
|
|
2965
|
+
const nonNull = values.filter((entry) => entry !== null);
|
|
2966
|
+
if (nonNull.length === 0) return single(field, null);
|
|
2967
|
+
if (nonNull.length === values.length) return single(key("in"), nonNull);
|
|
2968
|
+
return [[{ [field]: null }], [{ [key("in")]: nonNull }]];
|
|
2969
|
+
}
|
|
2970
|
+
if (operator === "notIn") {
|
|
2971
|
+
const values = value ?? [];
|
|
2972
|
+
if (values.length === 0) return queryFail("Data query notIn requires at least one value", "DATA_QUERY_UNSUPPORTED");
|
|
2973
|
+
const inequalities = values.filter((entry) => entry !== null).map((entry) => ({ [key("!=")]: entry }));
|
|
2974
|
+
if (values.some((entry) => entry === null)) return [[...inequalities, { [key("!=")]: null }]];
|
|
2975
|
+
return [[{ [field]: null }], inequalities];
|
|
2976
|
+
}
|
|
2977
|
+
if (operator === "ne" && value !== null) return [[{ [field]: null }], [{ [key("!=")]: value }]];
|
|
2978
|
+
const suffixes = {
|
|
2979
|
+
eq: "",
|
|
2980
|
+
ne: "!=",
|
|
2981
|
+
gt: ">",
|
|
2982
|
+
gte: ">=",
|
|
2983
|
+
lt: "<",
|
|
2984
|
+
lte: "<=",
|
|
2985
|
+
like: "like"
|
|
2986
|
+
};
|
|
2987
|
+
if (negated && (operator === "gt" || operator === "gte" || operator === "lt" || operator === "lte")) return [[{ [field]: null }], [{ [key(suffixes[operator])]: value }]];
|
|
2988
|
+
return single(key(suffixes[operator]), value);
|
|
2989
|
+
}
|
|
2990
|
+
function crossProduct(left, right) {
|
|
2991
|
+
if (left.length * right.length > MAX_OR_BRANCHES) return queryFail(`Data query filter expands beyond ${MAX_OR_BRANCHES} OR branches`, "DATA_QUERY_UNSUPPORTED");
|
|
2992
|
+
return left.flatMap((leftGroup) => right.map((rightGroup) => [...leftGroup, ...rightGroup]));
|
|
2993
|
+
}
|
|
2994
|
+
function filterToDnf(filter, declared, negate = false) {
|
|
2995
|
+
if (filter.kind === "condition") {
|
|
2996
|
+
if (!declared.has(filter.field)) return queryFail(`Data query filter field is not declared: ${filter.field}`, "DATA_QUERY_FILTER_NOT_ALLOWED");
|
|
2997
|
+
return conditionToDnf(filter.field, negate ? inverseOperator(filter.operator) : filter.operator, filter.value, negate);
|
|
2998
|
+
}
|
|
2999
|
+
if (filter.kind === "not") return filterToDnf(filter.filter, declared, !negate);
|
|
3000
|
+
if (filter.kind === "all" && !negate || filter.kind === "any" && negate) return filter.filters.reduce((combined, child) => crossProduct(combined, filterToDnf(child, declared, negate)), [[]]);
|
|
3001
|
+
const branches = filter.filters.flatMap((child) => filterToDnf(child, declared, negate));
|
|
3002
|
+
if (branches.length > MAX_OR_BRANCHES) return queryFail(`Data query filter expands beyond ${MAX_OR_BRANCHES} OR branches`, "DATA_QUERY_UNSUPPORTED");
|
|
3003
|
+
return branches;
|
|
3004
|
+
}
|
|
3005
|
+
function normalizeScopeConditions(scope) {
|
|
3006
|
+
if (scope === void 0) return [];
|
|
3007
|
+
return (Array.isArray(scope) ? scope : [scope]).map((candidate) => {
|
|
3008
|
+
if (!isPlainRecord(candidate) || Object.keys(candidate).length === 0) throw new Error("Data query scope conditions must be non-empty plain objects");
|
|
3009
|
+
return { ...candidate };
|
|
3010
|
+
});
|
|
3011
|
+
}
|
|
3012
|
+
function normalizeApplicationScope(scope, _identityField) {
|
|
3013
|
+
if (scope === void 0) return [];
|
|
3014
|
+
return normalizeScopeConditions(scope);
|
|
3015
|
+
}
|
|
3016
|
+
function mergeQueryScope(scope, callerWhere) {
|
|
3017
|
+
const scopeConditions = normalizeScopeConditions(scope);
|
|
3018
|
+
const merged = (callerWhere && callerWhere.length > 0 ? callerWhere : [[]]).map((branch) => [...scopeConditions, ...branch]);
|
|
3019
|
+
if (merged.length === 1 && merged[0].length === 0) return void 0;
|
|
3020
|
+
if (merged.some((branch) => branch.length === 0)) return queryFail("Data query filter produced an unbounded OR branch", "DATA_QUERY_UNSUPPORTED");
|
|
3021
|
+
return merged;
|
|
3022
|
+
}
|
|
3023
|
+
function orderByTerms(sort) {
|
|
3024
|
+
if (!sort || sort.length === 0) return void 0;
|
|
3025
|
+
return sort.map((term) => term.direction === "desc" ? `${term.field} desc` : term.field);
|
|
3026
|
+
}
|
|
3027
|
+
function computeCursorBinding(request, schema, where) {
|
|
3028
|
+
const canonicalRequest = canonicalizeDataQuery(request, schema);
|
|
3029
|
+
return createHash("sha256").update(canonicalRequest).update("\0").update(JSON.stringify(where ?? null)).digest("base64url");
|
|
3030
|
+
}
|
|
3031
|
+
function encodeCursor(offset, binding) {
|
|
3032
|
+
return Buffer.from(JSON.stringify({
|
|
3033
|
+
binding,
|
|
3034
|
+
offset
|
|
3035
|
+
}), "utf8").toString("base64url");
|
|
3036
|
+
}
|
|
3037
|
+
function decodeCursor(cursor, binding) {
|
|
3038
|
+
if (!cursor) return 0;
|
|
3039
|
+
let parsed;
|
|
3040
|
+
try {
|
|
3041
|
+
parsed = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
3042
|
+
} catch {
|
|
3043
|
+
return queryFail("Data query cursor is invalid", "DATA_QUERY_UNSUPPORTED");
|
|
3044
|
+
}
|
|
3045
|
+
if (!isPlainRecord(parsed) || typeof parsed.binding !== "string" || typeof parsed.offset !== "number") return queryFail("Data query cursor is invalid", "DATA_QUERY_UNSUPPORTED");
|
|
3046
|
+
if (!Number.isInteger(parsed.offset) || parsed.offset < 0) return queryFail("Data query cursor is invalid", "DATA_QUERY_UNSUPPORTED");
|
|
3047
|
+
if (parsed.offset > MAX_DATA_QUERY_OFFSET) return queryFail(`Data query cursor offset cannot exceed ${MAX_DATA_QUERY_OFFSET}`, "DATA_QUERY_UNSUPPORTED");
|
|
3048
|
+
if (parsed.binding !== binding) return queryFail("Data query cursor does not match the current query", "DATA_QUERY_UNSUPPORTED");
|
|
3049
|
+
return parsed.offset;
|
|
3050
|
+
}
|
|
3051
|
+
async function resolveCollection(options, context) {
|
|
3052
|
+
return typeof options.collection === "function" ? options.collection(context) : options.collection;
|
|
3053
|
+
}
|
|
3054
|
+
async function resolveScope(options, context) {
|
|
3055
|
+
return typeof options.scope === "function" ? options.scope(context) : options.scope;
|
|
3056
|
+
}
|
|
3057
|
+
function assertNotAborted(signal) {
|
|
3058
|
+
if (signal.aborted) throw new DOMException("Data query was aborted", "AbortError");
|
|
3059
|
+
}
|
|
3060
|
+
async function executeSmrtCollectionQuery(collection, rawRequest, options) {
|
|
3061
|
+
const schema = options.schema;
|
|
3062
|
+
assertUsableResultBudget(schema);
|
|
3063
|
+
const request = normalizeDataQueryRequest(rawRequest, schema);
|
|
3064
|
+
const signal = options.signal;
|
|
3065
|
+
if (signal) assertNotAborted(signal);
|
|
3066
|
+
const queryFingerprint = createDataQueryFingerprint(request, schema);
|
|
3067
|
+
const descriptors = new Map(schema.fields.map((field) => [field.id, field]));
|
|
3068
|
+
const declared = new Set(descriptors.keys());
|
|
3069
|
+
const warnings = [];
|
|
3070
|
+
if (options.scope !== void 0 && normalizeScopeConditions(options.scope).length === 0) {
|
|
3071
|
+
if (request.mode === "rows") {
|
|
3072
|
+
const isCursor = request.page?.kind === "cursor";
|
|
3073
|
+
const offset = !isCursor && request.page?.kind === "offset" ? request.page.offset : 0;
|
|
3074
|
+
const limit = request.page?.limit ?? schema.defaultPageLimit ?? DEFAULT_PAGE_LIMIT;
|
|
3075
|
+
const page = isCursor ? {
|
|
3076
|
+
kind: "cursor",
|
|
3077
|
+
limit,
|
|
3078
|
+
hasMore: false
|
|
3079
|
+
} : {
|
|
3080
|
+
kind: "offset",
|
|
3081
|
+
offset,
|
|
3082
|
+
limit,
|
|
3083
|
+
hasMore: false
|
|
3084
|
+
};
|
|
3085
|
+
return normalizeDataQueryResult({
|
|
3086
|
+
version: 1,
|
|
3087
|
+
requestId: request.requestId,
|
|
3088
|
+
queryFingerprint,
|
|
3089
|
+
identityField: schema.identityField,
|
|
3090
|
+
rows: [],
|
|
3091
|
+
page,
|
|
3092
|
+
total: {
|
|
3093
|
+
kind: "exact",
|
|
3094
|
+
value: 0
|
|
3095
|
+
},
|
|
3096
|
+
freshness: {
|
|
3097
|
+
state: "fresh",
|
|
3098
|
+
asOf: (/* @__PURE__ */ new Date()).toISOString()
|
|
3099
|
+
},
|
|
3100
|
+
warnings,
|
|
3101
|
+
truncated: false
|
|
3102
|
+
}, request, schema);
|
|
3103
|
+
}
|
|
3104
|
+
let deniedFacets;
|
|
3105
|
+
if (request.mode === "facets") deniedFacets = (request.facets ?? []).map((facet) => {
|
|
3106
|
+
if (!descriptors.has(facet.field)) return queryFail(`Data query returned an undeclared facet: ${facet.field}`, "DATA_QUERY_RESULT_NOT_ALLOWED");
|
|
3107
|
+
return {
|
|
3108
|
+
field: facet.field,
|
|
3109
|
+
values: [],
|
|
3110
|
+
truncated: false
|
|
3111
|
+
};
|
|
3112
|
+
});
|
|
3113
|
+
return normalizeDataQueryResult({
|
|
3114
|
+
version: 1,
|
|
3115
|
+
requestId: request.requestId,
|
|
3116
|
+
queryFingerprint,
|
|
3117
|
+
identityField: schema.identityField,
|
|
3118
|
+
rows: [],
|
|
3119
|
+
total: {
|
|
3120
|
+
kind: "exact",
|
|
3121
|
+
value: 0
|
|
3122
|
+
},
|
|
3123
|
+
...deniedFacets === void 0 ? {} : { facets: deniedFacets },
|
|
3124
|
+
freshness: {
|
|
3125
|
+
state: "fresh",
|
|
3126
|
+
asOf: (/* @__PURE__ */ new Date()).toISOString()
|
|
3127
|
+
},
|
|
3128
|
+
warnings,
|
|
3129
|
+
truncated: false
|
|
3130
|
+
}, request, schema);
|
|
3131
|
+
}
|
|
3132
|
+
const callerWhere = request.filter ? filterToDnf(request.filter, declared) : void 0;
|
|
3133
|
+
const scopeConditions = [...normalizeScopeConditions(resolveTenantReadScope(options.qualifiedName)), ...normalizeApplicationScope(options.scope, schema.identityField)];
|
|
3134
|
+
const where = mergeQueryScope(scopeConditions.length > 0 ? scopeConditions : void 0, callerWhere);
|
|
3135
|
+
const countOptions = where === void 0 ? void 0 : { where };
|
|
3136
|
+
const cursorBinding = computeCursorBinding(request, schema, where);
|
|
3137
|
+
if (request.mode === "rows") {
|
|
3138
|
+
const projection = request.projection ?? [schema.identityField];
|
|
3139
|
+
const isCursor = request.page?.kind === "cursor";
|
|
3140
|
+
const offset = isCursor ? decodeCursor(request.page?.kind === "cursor" ? request.page.after : void 0, cursorBinding) : request.page?.kind === "offset" ? request.page.offset : 0;
|
|
3141
|
+
const limit = request.page?.limit ?? schema.defaultPageLimit ?? DEFAULT_PAGE_LIMIT;
|
|
3142
|
+
const orderBy = orderByTerms(request.sort);
|
|
3143
|
+
if (signal) assertNotAborted(signal);
|
|
3144
|
+
const rows = (await collection.list({
|
|
3145
|
+
select: projection,
|
|
3146
|
+
offset,
|
|
3147
|
+
limit,
|
|
3148
|
+
...orderBy ? { orderBy: orderBy.length === 1 ? orderBy[0] : orderBy } : {},
|
|
3149
|
+
...where === void 0 ? {} : { where }
|
|
3150
|
+
})).map((row) => {
|
|
3151
|
+
const out = {};
|
|
3152
|
+
for (const field of projection) {
|
|
3153
|
+
if (!descriptors.has(field)) return queryFail(`Data query returned an undeclared field: ${field}`, "DATA_QUERY_RESULT_NOT_ALLOWED");
|
|
3154
|
+
out[field] = row[field] ?? null;
|
|
3155
|
+
}
|
|
3156
|
+
return out;
|
|
3157
|
+
});
|
|
3158
|
+
if (signal) assertNotAborted(signal);
|
|
3159
|
+
const total2 = await collection.count(countOptions);
|
|
3160
|
+
if (signal) assertNotAborted(signal);
|
|
3161
|
+
const hasMore = offset + rows.length < total2;
|
|
3162
|
+
if (rows.length < limit && offset + rows.length < total2) warnings.push("The collection returned fewer rows than requested; it may enforce its own maximum list limit below this schema’s maxPageLimit.");
|
|
3163
|
+
const page = isCursor ? {
|
|
3164
|
+
kind: "cursor",
|
|
3165
|
+
limit,
|
|
3166
|
+
hasMore,
|
|
3167
|
+
...hasMore ? { nextCursor: encodeCursor(offset + rows.length, cursorBinding) } : {}
|
|
3168
|
+
} : {
|
|
3169
|
+
kind: "offset",
|
|
3170
|
+
offset,
|
|
3171
|
+
limit,
|
|
3172
|
+
hasMore
|
|
3173
|
+
};
|
|
3174
|
+
return normalizeDataQueryResult({
|
|
3175
|
+
version: 1,
|
|
3176
|
+
requestId: request.requestId,
|
|
3177
|
+
queryFingerprint,
|
|
3178
|
+
identityField: schema.identityField,
|
|
3179
|
+
rows,
|
|
3180
|
+
page,
|
|
3181
|
+
total: {
|
|
3182
|
+
kind: "exact",
|
|
3183
|
+
value: total2
|
|
3184
|
+
},
|
|
3185
|
+
freshness: {
|
|
3186
|
+
state: "fresh",
|
|
3187
|
+
asOf: (/* @__PURE__ */ new Date()).toISOString()
|
|
3188
|
+
},
|
|
3189
|
+
warnings,
|
|
3190
|
+
truncated: false
|
|
3191
|
+
}, request, schema);
|
|
3192
|
+
}
|
|
3193
|
+
if (signal) assertNotAborted(signal);
|
|
3194
|
+
const total = await collection.count(countOptions);
|
|
3195
|
+
if (signal) assertNotAborted(signal);
|
|
3196
|
+
let facets;
|
|
3197
|
+
if (request.mode === "facets") {
|
|
3198
|
+
if (!collection.facets) return queryFail("This collection does not support facet queries", "DATA_QUERY_UNSUPPORTED");
|
|
3199
|
+
const requested = request.facets ?? [];
|
|
3200
|
+
if (signal) assertNotAborted(signal);
|
|
3201
|
+
const sourceFacets = await collection.facets({
|
|
3202
|
+
fields: requested.map((facet) => ({
|
|
3203
|
+
field: facet.field,
|
|
3204
|
+
limit: facet.limit
|
|
3205
|
+
})),
|
|
3206
|
+
...where === void 0 ? {} : { where }
|
|
3207
|
+
});
|
|
3208
|
+
if (signal) assertNotAborted(signal);
|
|
3209
|
+
const byField = new Map(sourceFacets.map((facet) => [facet.field, facet]));
|
|
3210
|
+
facets = requested.map((facet) => {
|
|
3211
|
+
if (!descriptors.has(facet.field)) return queryFail(`Data query returned an undeclared facet: ${facet.field}`, "DATA_QUERY_RESULT_NOT_ALLOWED");
|
|
3212
|
+
const values = (byField.get(facet.field)?.values ?? []).slice(0, facet.limit);
|
|
3213
|
+
return {
|
|
3214
|
+
field: facet.field,
|
|
3215
|
+
values: values.map((entry) => ({
|
|
3216
|
+
value: entry.value,
|
|
3217
|
+
count: entry.count
|
|
3218
|
+
})),
|
|
3219
|
+
truncated: (byField.get(facet.field)?.values.length ?? 0) >= facet.limit
|
|
3220
|
+
};
|
|
3221
|
+
});
|
|
3222
|
+
}
|
|
3223
|
+
return normalizeDataQueryResult({
|
|
3224
|
+
version: 1,
|
|
3225
|
+
requestId: request.requestId,
|
|
3226
|
+
queryFingerprint,
|
|
3227
|
+
identityField: schema.identityField,
|
|
3228
|
+
rows: [],
|
|
3229
|
+
total: {
|
|
3230
|
+
kind: "exact",
|
|
3231
|
+
value: total
|
|
3232
|
+
},
|
|
3233
|
+
...facets === void 0 ? {} : { facets },
|
|
3234
|
+
freshness: {
|
|
3235
|
+
state: "fresh",
|
|
3236
|
+
asOf: (/* @__PURE__ */ new Date()).toISOString()
|
|
3237
|
+
},
|
|
3238
|
+
warnings,
|
|
3239
|
+
truncated: false
|
|
3240
|
+
}, request, schema);
|
|
3241
|
+
}
|
|
3242
|
+
async function createSmrtCollectionDataSurfaceDefinition(options) {
|
|
3243
|
+
const identityField = options.identityField ?? "id";
|
|
3244
|
+
let schema;
|
|
3245
|
+
if (options.schema) {
|
|
3246
|
+
const excludedByRegistry = await registryFieldPolicyExclusionSet(options.qualifiedName, new Set(options.exclude ?? []));
|
|
3247
|
+
schema = {
|
|
3248
|
+
...options.schema,
|
|
3249
|
+
fields: options.schema.fields.filter((field) => !excludedByRegistry.has(field.id))
|
|
3250
|
+
};
|
|
3251
|
+
} else schema = await buildDataQuerySchemaForClass(options.qualifiedName, {
|
|
3252
|
+
exclude: options.exclude,
|
|
3253
|
+
identityField,
|
|
3254
|
+
defaultPageLimit: options.defaultPageLimit,
|
|
3255
|
+
maxPageLimit: options.maxPageLimit,
|
|
3256
|
+
maxResultBytes: options.maxResultBytes,
|
|
3257
|
+
defaultSort: options.defaultSort,
|
|
3258
|
+
cursorPagination: options.cursorPagination,
|
|
3259
|
+
facets: options.facets ?? (typeof options.collection === "function" ? true : typeof options.collection.facets === "function")
|
|
3260
|
+
});
|
|
3261
|
+
const executableSchema = redactedQuerySchema(schema);
|
|
3262
|
+
assertSmrtCollectionQuerySchema(executableSchema);
|
|
3263
|
+
return {
|
|
3264
|
+
id: requiredName(options.id, options.collectionName ?? options.qualifiedName, "SmrtObject collection data surface id"),
|
|
3265
|
+
collection: requiredName(options.collectionName, options.qualifiedName, "SmrtObject collection permission collection"),
|
|
3266
|
+
className: options.qualifiedName,
|
|
3267
|
+
label: options.label ?? options.qualifiedName,
|
|
3268
|
+
description: options.description ?? "Bounded, tenant-safe rows, counts, facets, and continuations.",
|
|
3269
|
+
metadata: {
|
|
3270
|
+
domain: "smrt-collection",
|
|
3271
|
+
adapter: "SmrtCollection",
|
|
3272
|
+
queryModes: [
|
|
3273
|
+
"rows",
|
|
3274
|
+
"count",
|
|
3275
|
+
"facets"
|
|
3276
|
+
],
|
|
3277
|
+
...options.actions ? {
|
|
3278
|
+
actions: options.actions.map((action) => action.id),
|
|
3279
|
+
actionCatalog: JSON.stringify(options.actions)
|
|
3280
|
+
} : {},
|
|
3281
|
+
...options.metadata
|
|
3282
|
+
},
|
|
3283
|
+
schema: executableSchema,
|
|
3284
|
+
execute: async (_surface, request, context) => {
|
|
3285
|
+
normalizeDataQueryRequest(request, executableSchema);
|
|
3286
|
+
assertNotAborted(context.signal);
|
|
3287
|
+
const run = async () => executeSmrtCollectionQuery(await resolveCollection(options, context), request, {
|
|
3288
|
+
schema: executableSchema,
|
|
3289
|
+
qualifiedName: options.qualifiedName,
|
|
3290
|
+
scope: await resolveScope(options, context),
|
|
3291
|
+
signal: context.signal
|
|
3292
|
+
});
|
|
3293
|
+
if (isTenancyEnabled()) {
|
|
3294
|
+
const activeTenant = getCurrentTenant();
|
|
3295
|
+
if (activeTenant === void 0 && context.principal.tenantId && !isSystemContext() && !isSuperAdminBypass()) return withTenant({ tenantId: context.principal.tenantId }, run);
|
|
3296
|
+
if (activeTenant !== void 0 && activeTenant.tenantId !== (context.principal.tenantId ?? null) && !isSystemContext() && !isSuperAdminBypass()) throw new Error(`Data surface execution refused: an active tenant context ('${activeTenant.tenantId}') does not match the authenticated principal's tenant ('${context.principal.tenantId ?? "null"}').`);
|
|
3297
|
+
}
|
|
3298
|
+
return run();
|
|
3299
|
+
}
|
|
3300
|
+
};
|
|
3301
|
+
}
|
|
3302
|
+
//#endregion
|
|
2754
3303
|
//#region src/tenant-agent.ts
|
|
2755
3304
|
var __defProp = Object.defineProperty;
|
|
2756
3305
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -2959,6 +3508,6 @@ function getManifestForAgent(manifests, agentTypeOrIdentifier) {
|
|
|
2959
3508
|
return manifests.get(agentTypeOrIdentifier) || manifests.get(getAgentClassName(agentTypeOrIdentifier));
|
|
2960
3509
|
}
|
|
2961
3510
|
//#endregion
|
|
2962
|
-
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, assertWithinDelegationDepth, canonicalScheduleSlug, createDataSurfaceQueryFingerprint, createDataSurfaceTools, createDispatchInvokeTransport, createInvokeAgentTool, createPlaybookPreflightTool, createReportDataSurfaceDefinition, createReportDataSurfaceTools, createUIRegistry, deriveDelegationEnvelope, emitAgentCompletion, executeAsPrincipal, executeDelegatedInvocation, filterPlaybooksByPreflight, getClassConfigResolvers, getConfigResolver, inlineInvokeAgentTransport, instanceScopedSubscriber, isLazyConfigSentinel, listConfigResolvers, mergeFilters, migrateAgentScheduleSlugs, normalizeSort, planAgentScheduleSlugMigration, playbookStepCollection, playbookStepToolSlug, processAgentInvocations, registerConfigResolver, resetConfigResolvers, resolveAgentAIOptions, resolveAgentLearning, resolveLazyConfig, rootDelegationEnvelope, surfaceAgentCompletions, unregisterConfigResolver };
|
|
3511
|
+
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 };
|
|
2963
3512
|
|
|
2964
3513
|
//# sourceMappingURL=index.js.map
|