@inkeep/agents-core 0.0.0-dev-20251012022558 → 0.0.0-dev-20251012045242

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-ASA7FU3H.js → chunk-3GZBRBXP.js} +84 -87
  3. package/dist/{chunk-JK3LPVOW.js → chunk-3XUV5Q4D.js} +34 -34
  4. package/dist/{chunk-OEKS3RQI.js → chunk-B6F3RF4T.js} +86 -119
  5. package/dist/{chunk-H6PMWHNV.js → chunk-SLL6V3AE.js} +12 -12
  6. package/dist/client-exports.cjs +189 -225
  7. package/dist/client-exports.d.cts +13 -14
  8. package/dist/client-exports.d.ts +13 -14
  9. package/dist/client-exports.js +10 -10
  10. package/dist/db/schema.cjs +85 -118
  11. package/dist/db/schema.d.cts +2 -3
  12. package/dist/db/schema.d.ts +2 -3
  13. package/dist/db/schema.js +1 -1
  14. package/dist/index.cjs +983 -1038
  15. package/dist/index.d.cts +208 -208
  16. package/dist/index.d.ts +208 -208
  17. package/dist/index.js +744 -762
  18. package/dist/{schema-ULFEZCOL.d.cts → schema-Dp-qgdBT.d.ts} +54 -52
  19. package/dist/{schema-wbZXiVWb.d.ts → schema-DrDaCn6H.d.cts} +54 -52
  20. package/dist/{signoz-queries-BuiipZTk.d.cts → signoz-queries-CuWMQh1H.d.cts} +10 -10
  21. package/dist/{signoz-queries-BuiipZTk.d.ts → signoz-queries-CuWMQh1H.d.ts} +10 -10
  22. package/dist/types/index.d.cts +2 -3
  23. package/dist/types/index.d.ts +2 -3
  24. package/dist/{utility-CyPQ1tC_.d.cts → utility-BxbySenH.d.cts} +152 -301
  25. package/dist/{utility-CyPQ1tC_.d.ts → utility-BxbySenH.d.ts} +152 -301
  26. package/dist/validation/index.cjs +212 -249
  27. package/dist/validation/index.d.cts +12 -13
  28. package/dist/validation/index.d.ts +12 -13
  29. package/dist/validation/index.js +2 -2
  30. package/drizzle/0007_mighty_typhoid_mary.sql +227 -0
  31. package/drizzle/meta/0007_snapshot.json +2766 -0
  32. package/drizzle/meta/_journal.json +7 -0
  33. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
- export { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AGGREGATE_OPERATORS, AI_OPERATIONS, AI_TOOL_TYPES, DATA_SOURCES, DATA_TYPES, DELEGATION_FROM_SUB_AGENT_ID, DELEGATION_ID, DELEGATION_TO_SUB_AGENT_ID, FIELD_TYPES, OPERATORS, ORDER_DIRECTIONS, PANEL_TYPES, QUERY_DEFAULTS, QUERY_EXPRESSIONS, QUERY_FIELD_CONFIGS, QUERY_TYPES, REDUCE_OPERATIONS, SPAN_KEYS, SPAN_NAMES, TRANSFER_FROM_SUB_AGENT_ID, TRANSFER_TO_SUB_AGENT_ID, UNKNOWN_VALUE } from './chunk-H6PMWHNV.js';
1
+ export { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AGGREGATE_OPERATORS, AI_OPERATIONS, AI_TOOL_TYPES, DATA_SOURCES, DATA_TYPES, DELEGATION_FROM_SUB_AGENT_ID, DELEGATION_ID, DELEGATION_TO_SUB_AGENT_ID, FIELD_TYPES, OPERATORS, ORDER_DIRECTIONS, PANEL_TYPES, QUERY_DEFAULTS, QUERY_EXPRESSIONS, QUERY_FIELD_CONFIGS, QUERY_TYPES, REDUCE_OPERATIONS, SPAN_KEYS, SPAN_NAMES, TRANSFER_FROM_SUB_AGENT_ID, TRANSFER_TO_SUB_AGENT_ID, UNKNOWN_VALUE } from './chunk-SLL6V3AE.js';
2
2
  export { ANTHROPIC_MODELS, GOOGLE_MODELS, OPENAI_MODELS } from './chunk-HYS7HUYJ.js';
3
3
  export { TaskState } from './chunk-H2F72PDA.js';
4
4
  import { getLogger, convertZodToJsonSchema } from './chunk-YECQCT5N.js';
5
5
  export { PinoLogger, convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, extractPreviewFields, getLogger, isZodSchema, loggerFactory, preview } from './chunk-YECQCT5N.js';
6
- import { validateAndTypeGraphData, validateGraphStructure, isInternalAgent, isExternalAgent } from './chunk-JK3LPVOW.js';
7
- export { A2AMessageMetadataSchema, DataOperationDetailsSchema, DataOperationEventSchema, DelegationReturnedDataSchema, DelegationSentDataSchema, TransferDataSchema, generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAndTypeGraphData, validateArtifactComponentReferences, validateDataComponentReferences, validateGraphStructure, validateToolReferences } from './chunk-JK3LPVOW.js';
8
- import { ContextConfigApiUpdateSchema, validatePropsAsJsonSchema } from './chunk-ASA7FU3H.js';
9
- export { AgentGraphApiInsertSchema, AgentGraphApiSelectSchema, AgentGraphApiUpdateSchema, AgentGraphInsertSchema, AgentGraphSelectSchema, AgentGraphUpdateSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentInsertSchema, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, CanUseItemSchema, ContextCacheApiInsertSchema, ContextCacheApiSelectSchema, ContextCacheApiUpdateSchema, ContextCacheInsertSchema, ContextCacheSelectSchema, ContextCacheUpdateSchema, ContextConfigApiInsertSchema, ContextConfigApiSelectSchema, ContextConfigApiUpdateSchema, ContextConfigInsertSchema, ContextConfigSelectSchema, ContextConfigUpdateSchema, ConversationApiInsertSchema, ConversationApiSelectSchema, ConversationApiUpdateSchema, ConversationInsertSchema, ConversationSelectSchema, ConversationUpdateSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiUpdateSchema, CredentialReferenceInsertSchema, CredentialReferenceSelectSchema, CredentialReferenceUpdateSchema, DataComponentApiInsertSchema, DataComponentApiSelectSchema, DataComponentApiUpdateSchema, DataComponentBaseSchema, DataComponentInsertSchema, DataComponentSelectSchema, DataComponentUpdateSchema, ErrorResponseSchema, ExistsResponseSchema, ExternalAgentApiInsertSchema, ExternalAgentApiSelectSchema, ExternalAgentApiUpdateSchema, ExternalAgentInsertSchema, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, ExternalSubAgentRelationApiInsertSchema, ExternalSubAgentRelationInsertSchema, FetchConfigSchema, FetchDefinitionSchema, FullGraphAgentInsertSchema, FullGraphDefinitionSchema, FullProjectDefinitionSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, FunctionInsertSchema, FunctionSelectSchema, FunctionToolApiInsertSchema, FunctionToolApiSelectSchema, FunctionToolApiUpdateSchema, FunctionToolConfigSchema, FunctionToolInsertSchema, FunctionToolSelectSchema, FunctionToolUpdateSchema, FunctionUpdateSchema, GraphStopWhenSchema, GraphWithinContextOfProjectSchema, HeadersScopeSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiUpdateSchema, LedgerArtifactInsertSchema, LedgerArtifactSelectSchema, LedgerArtifactUpdateSchema, ListResponseSchema, MAX_ID_LENGTH, MCPToolConfigSchema, MIN_ID_LENGTH, McpToolDefinitionSchema, McpToolSchema, McpTransportConfigSchema, MessageApiInsertSchema, MessageApiSelectSchema, MessageApiUpdateSchema, MessageInsertSchema, MessageSelectSchema, MessageUpdateSchema, ModelSchema, ModelSettingsSchema, PaginationQueryParamsSchema, PaginationSchema, ProjectApiInsertSchema, ProjectApiSelectSchema, ProjectApiUpdateSchema, ProjectInsertSchema, ProjectModelSchema, ProjectSelectSchema, ProjectUpdateSchema, RemovedResponseSchema, SandboxConfigSchema, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, SubAgentApiInsertSchema, SubAgentApiSelectSchema, SubAgentApiUpdateSchema, SubAgentArtifactComponentApiInsertSchema, SubAgentArtifactComponentApiSelectSchema, SubAgentArtifactComponentApiUpdateSchema, SubAgentArtifactComponentInsertSchema, SubAgentArtifactComponentSelectSchema, SubAgentArtifactComponentUpdateSchema, SubAgentDataComponentApiInsertSchema, SubAgentDataComponentApiSelectSchema, SubAgentDataComponentApiUpdateSchema, SubAgentDataComponentInsertSchema, SubAgentDataComponentSelectSchema, SubAgentDataComponentUpdateSchema, SubAgentInsertSchema, SubAgentRelationApiInsertSchema, SubAgentRelationApiSelectSchema, SubAgentRelationApiUpdateSchema, SubAgentRelationInsertSchema, SubAgentRelationQuerySchema, SubAgentRelationSelectSchema, SubAgentRelationUpdateSchema, SubAgentSelectSchema, SubAgentStopWhenSchema, SubAgentToolRelationApiInsertSchema, SubAgentToolRelationApiSelectSchema, SubAgentToolRelationApiUpdateSchema, SubAgentToolRelationInsertSchema, SubAgentToolRelationSelectSchema, SubAgentToolRelationUpdateSchema, SubAgentUpdateSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectGraphIdParamsSchema, TenantProjectGraphParamsSchema, TenantProjectGraphSubAgentIdParamsSchema, TenantProjectGraphSubAgentParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema, validatePropsAsJsonSchema } from './chunk-ASA7FU3H.js';
10
- import { schema_exports, contextConfigs, externalAgents, functions, functionTools, agentFunctionToolRelations, subAgentRelations, subAgents, subAgentToolRelations, tools, credentialReferences, agentGraph, subAgentDataComponents, subAgentArtifactComponents, dataComponents, artifactComponents, projects, apiKeys, contextCache, conversations, messages, ledgerArtifacts, tasks, taskRelations } from './chunk-OEKS3RQI.js';
11
- export { agentFunctionToolRelations, agentFunctionToolRelationsRelations, agentGraph, agentGraphRelations, agentToolRelationsRelations, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, functionTools, functionToolsRelations, functions, functionsRelations, ledgerArtifacts, ledgerArtifactsRelations, messages, messagesRelations, projects, projectsRelations, subAgentArtifactComponents, subAgentArtifactComponentsRelations, subAgentDataComponents, subAgentDataComponentsRelations, subAgentRelations, subAgentRelationsRelations, subAgentToolRelations, subAgents, subAgentsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations } from './chunk-OEKS3RQI.js';
6
+ import { validateAndTypeAgentData, validateAgentStructure, isInternalAgent, isExternalAgent } from './chunk-3XUV5Q4D.js';
7
+ export { A2AMessageMetadataSchema, DataOperationDetailsSchema, DataOperationEventSchema, DelegationReturnedDataSchema, DelegationSentDataSchema, TransferDataSchema, generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAgentStructure, validateAndTypeAgentData, validateArtifactComponentReferences, validateDataComponentReferences, validateToolReferences } from './chunk-3XUV5Q4D.js';
8
+ import { ContextConfigApiUpdateSchema, validatePropsAsJsonSchema } from './chunk-3GZBRBXP.js';
9
+ export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentInsertSchema, AgentSelectSchema, AgentStopWhenSchema, AgentUpdateSchema, AgentWithinContextOfProjectSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentInsertSchema, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, CanUseItemSchema, ContextCacheApiInsertSchema, ContextCacheApiSelectSchema, ContextCacheApiUpdateSchema, ContextCacheInsertSchema, ContextCacheSelectSchema, ContextCacheUpdateSchema, ContextConfigApiInsertSchema, ContextConfigApiSelectSchema, ContextConfigApiUpdateSchema, ContextConfigInsertSchema, ContextConfigSelectSchema, ContextConfigUpdateSchema, ConversationApiInsertSchema, ConversationApiSelectSchema, ConversationApiUpdateSchema, ConversationInsertSchema, ConversationSelectSchema, ConversationUpdateSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiUpdateSchema, CredentialReferenceInsertSchema, CredentialReferenceSelectSchema, CredentialReferenceUpdateSchema, DataComponentApiInsertSchema, DataComponentApiSelectSchema, DataComponentApiUpdateSchema, DataComponentBaseSchema, DataComponentInsertSchema, DataComponentSelectSchema, DataComponentUpdateSchema, ErrorResponseSchema, ExistsResponseSchema, ExternalAgentApiInsertSchema, ExternalAgentApiSelectSchema, ExternalAgentApiUpdateSchema, ExternalAgentInsertSchema, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, ExternalSubAgentRelationApiInsertSchema, ExternalSubAgentRelationInsertSchema, FetchConfigSchema, FetchDefinitionSchema, FullAgentAgentInsertSchema, FullProjectDefinitionSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, FunctionInsertSchema, FunctionSelectSchema, FunctionToolApiInsertSchema, FunctionToolApiSelectSchema, FunctionToolApiUpdateSchema, FunctionToolConfigSchema, FunctionToolInsertSchema, FunctionToolSelectSchema, FunctionToolUpdateSchema, FunctionUpdateSchema, HeadersScopeSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiUpdateSchema, LedgerArtifactInsertSchema, LedgerArtifactSelectSchema, LedgerArtifactUpdateSchema, ListResponseSchema, MAX_ID_LENGTH, MCPToolConfigSchema, MIN_ID_LENGTH, McpToolDefinitionSchema, McpToolSchema, McpTransportConfigSchema, MessageApiInsertSchema, MessageApiSelectSchema, MessageApiUpdateSchema, MessageInsertSchema, MessageSelectSchema, MessageUpdateSchema, ModelSchema, ModelSettingsSchema, PaginationQueryParamsSchema, PaginationSchema, ProjectApiInsertSchema, ProjectApiSelectSchema, ProjectApiUpdateSchema, ProjectInsertSchema, ProjectModelSchema, ProjectSelectSchema, ProjectUpdateSchema, RemovedResponseSchema, SandboxConfigSchema, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, SubAgentApiInsertSchema, SubAgentApiSelectSchema, SubAgentApiUpdateSchema, SubAgentArtifactComponentApiInsertSchema, SubAgentArtifactComponentApiSelectSchema, SubAgentArtifactComponentApiUpdateSchema, SubAgentArtifactComponentInsertSchema, SubAgentArtifactComponentSelectSchema, SubAgentArtifactComponentUpdateSchema, SubAgentDataComponentApiInsertSchema, SubAgentDataComponentApiSelectSchema, SubAgentDataComponentApiUpdateSchema, SubAgentDataComponentInsertSchema, SubAgentDataComponentSelectSchema, SubAgentDataComponentUpdateSchema, SubAgentInsertSchema, SubAgentRelationApiInsertSchema, SubAgentRelationApiSelectSchema, SubAgentRelationApiUpdateSchema, SubAgentRelationInsertSchema, SubAgentRelationQuerySchema, SubAgentRelationSelectSchema, SubAgentRelationUpdateSchema, SubAgentSelectSchema, SubAgentStopWhenSchema, SubAgentToolRelationApiInsertSchema, SubAgentToolRelationApiSelectSchema, SubAgentToolRelationApiUpdateSchema, SubAgentToolRelationInsertSchema, SubAgentToolRelationSelectSchema, SubAgentToolRelationUpdateSchema, SubAgentUpdateSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, TenantProjectAgentSubAgentIdParamsSchema, TenantProjectAgentSubAgentParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema, validatePropsAsJsonSchema } from './chunk-3GZBRBXP.js';
10
+ import { schema_exports, contextConfigs, externalAgents, functions, functionTools, agentFunctionToolRelations, subAgentRelations, subAgents, subAgentToolRelations, tools, credentialReferences, agents, subAgentDataComponents, subAgentArtifactComponents, dataComponents, artifactComponents, projects, apiKeys, contextCache, conversations, messages, ledgerArtifacts, tasks, taskRelations } from './chunk-B6F3RF4T.js';
11
+ export { agentFunctionToolRelations, agentFunctionToolRelationsRelations, agentRelations, agentToolRelationsRelations, agents, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, functionTools, functionToolsRelations, functions, functionsRelations, ledgerArtifacts, ledgerArtifactsRelations, messages, messagesRelations, projects, projectsRelations, subAgentArtifactComponents, subAgentArtifactComponentsRelations, subAgentDataComponents, subAgentDataComponentsRelations, subAgentRelations, subAgentRelationsRelations, subAgentToolRelations, subAgents, subAgentsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations } from './chunk-B6F3RF4T.js';
12
12
  import { CredentialStoreType, MCPServerType, MCPTransportType } from './chunk-YFHT5M2R.js';
13
13
  export { CredentialStoreType, MCPServerType, MCPTransportType, TOOL_STATUS_VALUES, VALID_RELATION_TYPES } from './chunk-YFHT5M2R.js';
14
14
  import { __commonJS, __require, __publicField } from './chunk-E6R6PML7.js';
@@ -212903,10 +212903,10 @@ var ContextConfigBuilder = class {
212903
212903
  __publicField(this, "baseURL");
212904
212904
  __publicField(this, "tenantId");
212905
212905
  __publicField(this, "projectId");
212906
- __publicField(this, "graphId");
212906
+ __publicField(this, "agentId");
212907
212907
  this.tenantId = options.tenantId || "default";
212908
212908
  this.projectId = options.projectId || "default";
212909
- this.graphId = options.graphId || "default";
212909
+ this.agentId = options.agentId || "default";
212910
212910
  this.baseURL = process.env.INKEEP_AGENTS_MANAGE_API_URL || "http://localhost:3002";
212911
212911
  let headers2;
212912
212912
  if (options.headers) {
@@ -212955,23 +212955,23 @@ var ContextConfigBuilder = class {
212955
212955
  );
212956
212956
  }
212957
212957
  /**
212958
- * Set the context (tenantId, projectId, graphId) for this context config
212959
- * Called by graph.setConfig() when the graph is configured
212958
+ * Set the context (tenantId, projectId, agentId) for this context config
212959
+ * Called by agent.setConfig() when the agent is configured
212960
212960
  */
212961
- setContext(tenantId, projectId, graphId, baseURL) {
212961
+ setContext(tenantId, projectId, agentId, baseURL) {
212962
212962
  this.tenantId = tenantId;
212963
212963
  this.projectId = projectId;
212964
- this.graphId = graphId;
212964
+ this.agentId = agentId;
212965
212965
  this.baseURL = baseURL;
212966
212966
  this.config.tenantId = tenantId;
212967
212967
  this.config.projectId = projectId;
212968
- this.config.graphId = graphId;
212968
+ this.config.agentId = agentId;
212969
212969
  logger.info(
212970
212970
  {
212971
212971
  contextConfigId: this.config.id,
212972
212972
  tenantId: this.tenantId,
212973
212973
  projectId: this.projectId,
212974
- graphId: this.graphId
212974
+ agentId: this.agentId
212975
212975
  },
212976
212976
  "ContextConfig context updated"
212977
212977
  );
@@ -212984,7 +212984,7 @@ var ContextConfigBuilder = class {
212984
212984
  id: this.getId(),
212985
212985
  tenantId: this.tenantId,
212986
212986
  projectId: this.projectId,
212987
- graphId: this.graphId,
212987
+ agentId: this.agentId,
212988
212988
  headersSchema: this.getHeadersSchema(),
212989
212989
  contextVariables: this.getContextVariables(),
212990
212990
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -213075,7 +213075,7 @@ var ContextConfigBuilder = class {
213075
213075
  };
213076
213076
  try {
213077
213077
  const updateResponse = await fetch(
213078
- `${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/graphs/${this.graphId}/context-configs/${this.getId()}`,
213078
+ `${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/agent/${this.agentId}/context-configs/${this.getId()}`,
213079
213079
  {
213080
213080
  method: "PUT",
213081
213081
  headers: {
@@ -213101,7 +213101,7 @@ var ContextConfigBuilder = class {
213101
213101
  "Context config not found, creating new config"
213102
213102
  );
213103
213103
  const createResponse = await fetch(
213104
- `${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/graphs/${this.graphId}/context-configs`,
213104
+ `${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/agent/${this.agentId}/context-configs`,
213105
213105
  {
213106
213106
  method: "POST",
213107
213107
  headers: {
@@ -213582,7 +213582,7 @@ var getContextConfigById = (db) => async (params) => {
213582
213582
  where: and(
213583
213583
  eq(contextConfigs.tenantId, params.scopes.tenantId),
213584
213584
  eq(contextConfigs.projectId, params.scopes.projectId),
213585
- eq(contextConfigs.graphId, params.scopes.graphId),
213585
+ eq(contextConfigs.agentId, params.scopes.agentId),
213586
213586
  eq(contextConfigs.id, params.id)
213587
213587
  )
213588
213588
  });
@@ -213592,7 +213592,7 @@ var listContextConfigs = (db) => async (params) => {
213592
213592
  where: and(
213593
213593
  eq(contextConfigs.tenantId, params.scopes.tenantId),
213594
213594
  eq(contextConfigs.projectId, params.scopes.projectId),
213595
- eq(contextConfigs.graphId, params.scopes.graphId)
213595
+ eq(contextConfigs.agentId, params.scopes.agentId)
213596
213596
  ),
213597
213597
  orderBy: [desc(contextConfigs.createdAt)]
213598
213598
  });
@@ -213604,7 +213604,7 @@ var listContextConfigsPaginated = (db) => async (params) => {
213604
213604
  const whereClause = and(
213605
213605
  eq(contextConfigs.tenantId, params.scopes.tenantId),
213606
213606
  eq(contextConfigs.projectId, params.scopes.projectId),
213607
- eq(contextConfigs.graphId, params.scopes.graphId)
213607
+ eq(contextConfigs.agentId, params.scopes.agentId)
213608
213608
  );
213609
213609
  const [contextConfigList, totalResult] = await Promise.all([
213610
213610
  db.select().from(contextConfigs).where(whereClause).limit(limit).offset(offset).orderBy(desc(contextConfigs.createdAt)),
@@ -213633,7 +213633,7 @@ var createContextConfig = (db) => async (params) => {
213633
213633
  id,
213634
213634
  tenantId: params.tenantId,
213635
213635
  projectId: params.projectId,
213636
- graphId: params.graphId,
213636
+ agentId: params.agentId,
213637
213637
  headersSchema: params.headersSchema ?? null,
213638
213638
  contextVariables: contextVariables ?? null,
213639
213639
  createdAt: now,
@@ -213659,7 +213659,7 @@ var updateContextConfig = (db) => async (params) => {
213659
213659
  and(
213660
213660
  eq(contextConfigs.tenantId, params.scopes.tenantId),
213661
213661
  eq(contextConfigs.projectId, params.scopes.projectId),
213662
- eq(contextConfigs.graphId, params.scopes.graphId),
213662
+ eq(contextConfigs.agentId, params.scopes.agentId),
213663
213663
  eq(contextConfigs.id, params.id)
213664
213664
  )
213665
213665
  ).returning();
@@ -213671,7 +213671,7 @@ var deleteContextConfig = (db) => async (params) => {
213671
213671
  and(
213672
213672
  eq(contextConfigs.tenantId, params.scopes.tenantId),
213673
213673
  eq(contextConfigs.projectId, params.scopes.projectId),
213674
- eq(contextConfigs.graphId, params.scopes.graphId),
213674
+ eq(contextConfigs.agentId, params.scopes.agentId),
213675
213675
  eq(contextConfigs.id, params.id)
213676
213676
  )
213677
213677
  ).returning();
@@ -213690,7 +213690,7 @@ var countContextConfigs = (db) => async (params) => {
213690
213690
  and(
213691
213691
  eq(contextConfigs.tenantId, params.scopes.tenantId),
213692
213692
  eq(contextConfigs.projectId, params.scopes.projectId),
213693
- eq(contextConfigs.graphId, params.scopes.graphId)
213693
+ eq(contextConfigs.agentId, params.scopes.agentId)
213694
213694
  )
213695
213695
  );
213696
213696
  const total = result[0]?.count || 0;
@@ -213700,7 +213700,7 @@ var upsertContextConfig = (db) => async (params) => {
213700
213700
  const scopes = {
213701
213701
  tenantId: params.data.tenantId,
213702
213702
  projectId: params.data.projectId,
213703
- graphId: params.data.graphId
213703
+ agentId: params.data.agentId
213704
213704
  };
213705
213705
  if (params.data.id) {
213706
213706
  const existing = await getContextConfigById(db)({
@@ -213729,7 +213729,7 @@ var getExternalAgent = (db) => async (params) => {
213729
213729
  where: and(
213730
213730
  eq(externalAgents.tenantId, params.scopes.tenantId),
213731
213731
  eq(externalAgents.projectId, params.scopes.projectId),
213732
- eq(externalAgents.graphId, params.scopes.graphId),
213732
+ eq(externalAgents.agentId, params.scopes.agentId),
213733
213733
  eq(externalAgents.id, params.subAgentId)
213734
213734
  )
213735
213735
  });
@@ -213740,7 +213740,7 @@ var getExternalAgentByUrl = (db) => async (params) => {
213740
213740
  where: and(
213741
213741
  eq(externalAgents.tenantId, params.scopes.tenantId),
213742
213742
  eq(externalAgents.projectId, params.scopes.projectId),
213743
- eq(externalAgents.graphId, params.scopes.graphId),
213743
+ eq(externalAgents.agentId, params.scopes.agentId),
213744
213744
  eq(externalAgents.baseUrl, params.baseUrl)
213745
213745
  )
213746
213746
  });
@@ -213751,7 +213751,7 @@ var listExternalAgents = (db) => async (params) => {
213751
213751
  where: and(
213752
213752
  eq(externalAgents.tenantId, params.scopes.tenantId),
213753
213753
  eq(externalAgents.projectId, params.scopes.projectId),
213754
- eq(externalAgents.graphId, params.scopes.graphId)
213754
+ eq(externalAgents.agentId, params.scopes.agentId)
213755
213755
  ),
213756
213756
  orderBy: [asc(externalAgents.name)]
213757
213757
  });
@@ -213765,14 +213765,14 @@ var listExternalAgentsPaginated = (db) => async (params) => {
213765
213765
  and(
213766
213766
  eq(externalAgents.tenantId, params.scopes.tenantId),
213767
213767
  eq(externalAgents.projectId, params.scopes.projectId),
213768
- eq(externalAgents.graphId, params.scopes.graphId)
213768
+ eq(externalAgents.agentId, params.scopes.agentId)
213769
213769
  )
213770
213770
  ).limit(limit).offset(offset).orderBy(desc(externalAgents.createdAt)),
213771
213771
  db.select({ count: count() }).from(externalAgents).where(
213772
213772
  and(
213773
213773
  eq(externalAgents.tenantId, params.scopes.tenantId),
213774
213774
  eq(externalAgents.projectId, params.scopes.projectId),
213775
- eq(externalAgents.graphId, params.scopes.graphId)
213775
+ eq(externalAgents.agentId, params.scopes.agentId)
213776
213776
  )
213777
213777
  )
213778
213778
  ]);
@@ -213801,7 +213801,7 @@ var updateExternalAgent = (db) => async (params) => {
213801
213801
  and(
213802
213802
  eq(externalAgents.tenantId, params.scopes.tenantId),
213803
213803
  eq(externalAgents.projectId, params.scopes.projectId),
213804
- eq(externalAgents.graphId, params.scopes.graphId),
213804
+ eq(externalAgents.agentId, params.scopes.agentId),
213805
213805
  eq(externalAgents.id, params.subAgentId)
213806
213806
  )
213807
213807
  ).returning();
@@ -213811,7 +213811,7 @@ var upsertExternalAgent = (db) => async (params) => {
213811
213811
  const scopes = {
213812
213812
  tenantId: params.data.tenantId,
213813
213813
  projectId: params.data.projectId,
213814
- graphId: params.data.graphId
213814
+ agentId: params.data.agentId
213815
213815
  };
213816
213816
  const existing = await getExternalAgent(db)({
213817
213817
  scopes,
@@ -213843,7 +213843,7 @@ var deleteExternalAgent = (db) => async (params) => {
213843
213843
  and(
213844
213844
  eq(externalAgents.tenantId, params.scopes.tenantId),
213845
213845
  eq(externalAgents.projectId, params.scopes.projectId),
213846
- eq(externalAgents.graphId, params.scopes.graphId),
213846
+ eq(externalAgents.agentId, params.scopes.agentId),
213847
213847
  eq(externalAgents.id, params.subAgentId)
213848
213848
  )
213849
213849
  ).returning();
@@ -213866,7 +213866,7 @@ var countExternalAgents = (db) => async (params) => {
213866
213866
  and(
213867
213867
  eq(externalAgents.tenantId, params.scopes.tenantId),
213868
213868
  eq(externalAgents.projectId, params.scopes.projectId),
213869
- eq(externalAgents.graphId, params.scopes.graphId)
213869
+ eq(externalAgents.agentId, params.scopes.agentId)
213870
213870
  )
213871
213871
  );
213872
213872
  const countValue = result[0]?.count;
@@ -214010,7 +214010,7 @@ var getFunctionToolById = (db) => async (params) => {
214010
214010
  and(
214011
214011
  eq(functionTools.tenantId, params.scopes.tenantId),
214012
214012
  eq(functionTools.projectId, params.scopes.projectId),
214013
- eq(functionTools.graphId, params.scopes.graphId),
214013
+ eq(functionTools.agentId, params.scopes.agentId),
214014
214014
  eq(functionTools.id, params.functionToolId)
214015
214015
  )
214016
214016
  ).limit(1);
@@ -214023,7 +214023,7 @@ var listFunctionTools = (db) => async (params) => {
214023
214023
  const whereClause = and(
214024
214024
  eq(functionTools.tenantId, params.scopes.tenantId),
214025
214025
  eq(functionTools.projectId, params.scopes.projectId),
214026
- eq(functionTools.graphId, params.scopes.graphId)
214026
+ eq(functionTools.agentId, params.scopes.agentId)
214027
214027
  );
214028
214028
  const [functionToolsDbResults, totalResult] = await Promise.all([
214029
214029
  db.select().from(functionTools).where(whereClause).limit(limit).offset(offset).orderBy(desc(functionTools.createdAt)),
@@ -214038,11 +214038,11 @@ var listFunctionTools = (db) => async (params) => {
214038
214038
  };
214039
214039
  var createFunctionTool = (db) => async (params) => {
214040
214040
  const { data, scopes } = params;
214041
- const { tenantId, projectId, graphId } = scopes;
214041
+ const { tenantId, projectId, agentId } = scopes;
214042
214042
  const [created] = await db.insert(functionTools).values({
214043
214043
  tenantId,
214044
214044
  projectId,
214045
- graphId,
214045
+ agentId,
214046
214046
  id: data.id,
214047
214047
  name: data.name,
214048
214048
  description: data.description,
@@ -214061,7 +214061,7 @@ var updateFunctionTool = (db) => async (params) => {
214061
214061
  and(
214062
214062
  eq(functionTools.tenantId, params.scopes.tenantId),
214063
214063
  eq(functionTools.projectId, params.scopes.projectId),
214064
- eq(functionTools.graphId, params.scopes.graphId),
214064
+ eq(functionTools.agentId, params.scopes.agentId),
214065
214065
  eq(functionTools.id, params.functionToolId)
214066
214066
  )
214067
214067
  ).returning();
@@ -214072,7 +214072,7 @@ var deleteFunctionTool = (db) => async (params) => {
214072
214072
  and(
214073
214073
  eq(functionTools.tenantId, params.scopes.tenantId),
214074
214074
  eq(functionTools.projectId, params.scopes.projectId),
214075
- eq(functionTools.graphId, params.scopes.graphId),
214075
+ eq(functionTools.agentId, params.scopes.agentId),
214076
214076
  eq(functionTools.id, params.functionToolId)
214077
214077
  )
214078
214078
  ).returning();
@@ -214082,7 +214082,7 @@ var upsertFunctionTool = (db) => async (params) => {
214082
214082
  const scopes = {
214083
214083
  tenantId: params.scopes.tenantId,
214084
214084
  projectId: params.scopes.projectId,
214085
- graphId: params.scopes.graphId
214085
+ agentId: params.scopes.agentId
214086
214086
  };
214087
214087
  const existing = await getFunctionToolById(db)({
214088
214088
  scopes,
@@ -214108,17 +214108,17 @@ var upsertFunctionTool = (db) => async (params) => {
214108
214108
  var getFunctionToolsForSubAgent = (db) => {
214109
214109
  return async (params) => {
214110
214110
  const { scopes, subAgentId } = params;
214111
- const { tenantId, projectId, graphId } = scopes;
214111
+ const { tenantId, projectId, agentId } = scopes;
214112
214112
  try {
214113
214113
  const functionToolsList = await listFunctionTools(db)({
214114
- scopes: { tenantId, projectId, graphId },
214114
+ scopes: { tenantId, projectId, agentId },
214115
214115
  pagination: { page: 1, limit: 1e3 }
214116
214116
  });
214117
214117
  const relations = await db.select().from(agentFunctionToolRelations).where(
214118
214118
  and(
214119
214119
  eq(agentFunctionToolRelations.tenantId, tenantId),
214120
214120
  eq(agentFunctionToolRelations.projectId, projectId),
214121
- eq(agentFunctionToolRelations.graphId, graphId),
214121
+ eq(agentFunctionToolRelations.agentId, agentId),
214122
214122
  eq(agentFunctionToolRelations.subAgentId, subAgentId)
214123
214123
  )
214124
214124
  );
@@ -214132,7 +214132,7 @@ var getFunctionToolsForSubAgent = (db) => {
214132
214132
  };
214133
214133
  } catch (error) {
214134
214134
  logger3.error(
214135
- { tenantId, projectId, graphId, subAgentId, error },
214135
+ { tenantId, projectId, agentId, subAgentId, error },
214136
214136
  "Failed to get function tools for agent"
214137
214137
  );
214138
214138
  throw error;
@@ -214155,25 +214155,25 @@ var upsertSubAgentFunctionToolRelation = (db) => async (params) => {
214155
214155
  var addFunctionToolToSubAgent = (db) => {
214156
214156
  return async (params) => {
214157
214157
  const { scopes, subAgentId, functionToolId } = params;
214158
- const { tenantId, projectId, graphId } = scopes;
214158
+ const { tenantId, projectId, agentId } = scopes;
214159
214159
  try {
214160
214160
  const relationId = nanoid();
214161
214161
  await db.insert(agentFunctionToolRelations).values({
214162
214162
  id: relationId,
214163
214163
  tenantId,
214164
214164
  projectId,
214165
- graphId,
214165
+ agentId,
214166
214166
  subAgentId,
214167
214167
  functionToolId
214168
214168
  });
214169
214169
  logger3.info(
214170
- { tenantId, projectId, graphId, subAgentId, functionToolId, relationId },
214170
+ { tenantId, projectId, agentId, subAgentId, functionToolId, relationId },
214171
214171
  "Function tool added to agent"
214172
214172
  );
214173
214173
  return { id: relationId };
214174
214174
  } catch (error) {
214175
214175
  logger3.error(
214176
- { tenantId, projectId, graphId, subAgentId, functionToolId, error },
214176
+ { tenantId, projectId, agentId, subAgentId, functionToolId, error },
214177
214177
  "Failed to add function tool to agent"
214178
214178
  );
214179
214179
  throw error;
@@ -214183,7 +214183,7 @@ var addFunctionToolToSubAgent = (db) => {
214183
214183
  var updateSubAgentFunctionToolRelation = (db) => {
214184
214184
  return async (params) => {
214185
214185
  const { scopes, relationId, data } = params;
214186
- const { tenantId, projectId, graphId } = scopes;
214186
+ const { tenantId, projectId, agentId } = scopes;
214187
214187
  try {
214188
214188
  await db.update(agentFunctionToolRelations).set({
214189
214189
  subAgentId: data.subAgentId,
@@ -214193,17 +214193,17 @@ var updateSubAgentFunctionToolRelation = (db) => {
214193
214193
  eq(agentFunctionToolRelations.id, relationId),
214194
214194
  eq(agentFunctionToolRelations.tenantId, tenantId),
214195
214195
  eq(agentFunctionToolRelations.projectId, projectId),
214196
- eq(agentFunctionToolRelations.graphId, graphId)
214196
+ eq(agentFunctionToolRelations.agentId, agentId)
214197
214197
  )
214198
214198
  );
214199
214199
  logger3.info(
214200
- { tenantId, projectId, graphId, relationId, data },
214200
+ { tenantId, projectId, agentId, relationId, data },
214201
214201
  "Agent-function tool relation updated"
214202
214202
  );
214203
214203
  return { id: relationId };
214204
214204
  } catch (error) {
214205
214205
  logger3.error(
214206
- { tenantId, projectId, graphId, relationId, data, error },
214206
+ { tenantId, projectId, agentId, relationId, data, error },
214207
214207
  "Failed to update agent-function tool relation"
214208
214208
  );
214209
214209
  throw error;
@@ -214215,7 +214215,7 @@ var getAgentRelationById = (db) => async (params) => {
214215
214215
  where: and(
214216
214216
  eq(subAgentRelations.tenantId, params.scopes.tenantId),
214217
214217
  eq(subAgentRelations.projectId, params.scopes.projectId),
214218
- eq(subAgentRelations.graphId, params.scopes.graphId),
214218
+ eq(subAgentRelations.agentId, params.scopes.agentId),
214219
214219
  eq(subAgentRelations.id, params.relationId)
214220
214220
  )
214221
214221
  });
@@ -214227,7 +214227,7 @@ var listAgentRelations = (db) => async (params) => {
214227
214227
  const whereClause = and(
214228
214228
  eq(subAgentRelations.tenantId, params.scopes.tenantId),
214229
214229
  eq(subAgentRelations.projectId, params.scopes.projectId),
214230
- eq(subAgentRelations.graphId, params.scopes.graphId)
214230
+ eq(subAgentRelations.agentId, params.scopes.agentId)
214231
214231
  );
214232
214232
  const [data, totalResult] = await Promise.all([
214233
214233
  db.select().from(subAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(desc(subAgentRelations.createdAt)),
@@ -214242,17 +214242,17 @@ var getAgentRelations = (db) => async (params) => {
214242
214242
  where: and(
214243
214243
  eq(subAgentRelations.tenantId, params.scopes.tenantId),
214244
214244
  eq(subAgentRelations.projectId, params.scopes.projectId),
214245
- eq(subAgentRelations.graphId, params.scopes.graphId),
214245
+ eq(subAgentRelations.agentId, params.scopes.agentId),
214246
214246
  eq(subAgentRelations.sourceSubAgentId, params.scopes.subAgentId)
214247
214247
  )
214248
214248
  });
214249
214249
  };
214250
- var getAgentRelationsByGraph = (db) => async (params) => {
214250
+ var getAgentRelationsByAgent = (db) => async (params) => {
214251
214251
  return await db.query.subAgentRelations.findMany({
214252
214252
  where: and(
214253
214253
  eq(subAgentRelations.tenantId, params.scopes.tenantId),
214254
214254
  eq(subAgentRelations.projectId, params.scopes.projectId),
214255
- eq(subAgentRelations.graphId, params.scopes.graphId)
214255
+ eq(subAgentRelations.agentId, params.scopes.agentId)
214256
214256
  )
214257
214257
  });
214258
214258
  };
@@ -214263,7 +214263,7 @@ var getAgentRelationsBySource = (db) => async (params) => {
214263
214263
  const whereClause = and(
214264
214264
  eq(subAgentRelations.tenantId, params.scopes.tenantId),
214265
214265
  eq(subAgentRelations.projectId, params.scopes.projectId),
214266
- eq(subAgentRelations.graphId, params.scopes.graphId),
214266
+ eq(subAgentRelations.agentId, params.scopes.agentId),
214267
214267
  eq(subAgentRelations.sourceSubAgentId, params.sourceSubAgentId)
214268
214268
  );
214269
214269
  const [data, totalResult] = await Promise.all([
@@ -214284,7 +214284,7 @@ var getAgentRelationsByTarget = (db) => async (params) => {
214284
214284
  const whereClause = and(
214285
214285
  eq(subAgentRelations.tenantId, params.scopes.tenantId),
214286
214286
  eq(subAgentRelations.projectId, params.scopes.projectId),
214287
- eq(subAgentRelations.graphId, params.scopes.graphId),
214287
+ eq(subAgentRelations.agentId, params.scopes.agentId),
214288
214288
  eq(subAgentRelations.targetSubAgentId, params.targetSubAgentId)
214289
214289
  );
214290
214290
  const [data, totalResult] = await Promise.all([
@@ -214305,7 +214305,7 @@ var getExternalAgentRelations = (db) => async (params) => {
214305
214305
  const whereClause = and(
214306
214306
  eq(subAgentRelations.tenantId, params.scopes.tenantId),
214307
214307
  eq(subAgentRelations.projectId, params.scopes.projectId),
214308
- eq(subAgentRelations.graphId, params.scopes.graphId),
214308
+ eq(subAgentRelations.agentId, params.scopes.agentId),
214309
214309
  eq(subAgentRelations.externalSubAgentId, params.externalSubAgentId)
214310
214310
  );
214311
214311
  const [data, totalResult] = await Promise.all([
@@ -214319,7 +214319,7 @@ var getExternalAgentRelations = (db) => async (params) => {
214319
214319
  pagination: { page, limit, total, pages }
214320
214320
  };
214321
214321
  };
214322
- var getRelatedAgentsForGraph = (db) => async (params) => {
214322
+ var getRelatedAgentsForAgent = (db) => async (params) => {
214323
214323
  const internalRelations = await db.select({
214324
214324
  id: subAgents.id,
214325
214325
  name: subAgents.name,
@@ -214331,13 +214331,13 @@ var getRelatedAgentsForGraph = (db) => async (params) => {
214331
214331
  eq(subAgentRelations.targetSubAgentId, subAgents.id),
214332
214332
  eq(subAgentRelations.tenantId, subAgents.tenantId),
214333
214333
  eq(subAgentRelations.projectId, subAgents.projectId),
214334
- eq(subAgentRelations.graphId, subAgents.graphId)
214334
+ eq(subAgentRelations.agentId, subAgents.agentId)
214335
214335
  )
214336
214336
  ).where(
214337
214337
  and(
214338
214338
  eq(subAgentRelations.tenantId, params.scopes.tenantId),
214339
214339
  eq(subAgentRelations.projectId, params.scopes.projectId),
214340
- eq(subAgentRelations.graphId, params.scopes.graphId),
214340
+ eq(subAgentRelations.agentId, params.scopes.agentId),
214341
214341
  eq(subAgentRelations.sourceSubAgentId, params.subAgentId),
214342
214342
  isNotNull(subAgentRelations.targetSubAgentId)
214343
214343
  )
@@ -214357,13 +214357,13 @@ var getRelatedAgentsForGraph = (db) => async (params) => {
214357
214357
  eq(subAgentRelations.externalSubAgentId, externalAgents.id),
214358
214358
  eq(subAgentRelations.tenantId, externalAgents.tenantId),
214359
214359
  eq(subAgentRelations.projectId, externalAgents.projectId),
214360
- eq(subAgentRelations.graphId, externalAgents.graphId)
214360
+ eq(subAgentRelations.agentId, externalAgents.agentId)
214361
214361
  )
214362
214362
  ).where(
214363
214363
  and(
214364
214364
  eq(subAgentRelations.tenantId, params.scopes.tenantId),
214365
214365
  eq(subAgentRelations.projectId, params.scopes.projectId),
214366
- eq(subAgentRelations.graphId, params.scopes.graphId),
214366
+ eq(subAgentRelations.agentId, params.scopes.agentId),
214367
214367
  eq(subAgentRelations.sourceSubAgentId, params.subAgentId),
214368
214368
  isNotNull(subAgentRelations.externalSubAgentId)
214369
214369
  )
@@ -214391,7 +214391,7 @@ var getAgentRelationByParams = (db) => async (params) => {
214391
214391
  const whereConditions = [
214392
214392
  eq(subAgentRelations.tenantId, params.scopes.tenantId),
214393
214393
  eq(subAgentRelations.projectId, params.scopes.projectId),
214394
- eq(subAgentRelations.graphId, params.scopes.graphId),
214394
+ eq(subAgentRelations.agentId, params.scopes.agentId),
214395
214395
  eq(subAgentRelations.sourceSubAgentId, params.sourceSubAgentId),
214396
214396
  eq(subAgentRelations.relationType, params.relationType)
214397
214397
  ];
@@ -214407,7 +214407,7 @@ var getAgentRelationByParams = (db) => async (params) => {
214407
214407
  };
214408
214408
  var upsertAgentRelation = (db) => async (params) => {
214409
214409
  const existing = await getAgentRelationByParams(db)({
214410
- scopes: { tenantId: params.tenantId, projectId: params.projectId, graphId: params.graphId },
214410
+ scopes: { tenantId: params.tenantId, projectId: params.projectId, agentId: params.agentId },
214411
214411
  sourceSubAgentId: params.sourceSubAgentId,
214412
214412
  targetSubAgentId: params.targetSubAgentId,
214413
214413
  externalSubAgentId: params.externalSubAgentId,
@@ -214433,7 +214433,7 @@ var updateAgentRelation = (db) => async (params) => {
214433
214433
  and(
214434
214434
  eq(subAgentRelations.tenantId, params.scopes.tenantId),
214435
214435
  eq(subAgentRelations.projectId, params.scopes.projectId),
214436
- eq(subAgentRelations.graphId, params.scopes.graphId),
214436
+ eq(subAgentRelations.agentId, params.scopes.agentId),
214437
214437
  eq(subAgentRelations.id, params.relationId)
214438
214438
  )
214439
214439
  ).returning();
@@ -214444,17 +214444,17 @@ var deleteSubAgentRelation = (db) => async (params) => {
214444
214444
  and(
214445
214445
  eq(subAgentRelations.tenantId, params.scopes.tenantId),
214446
214446
  eq(subAgentRelations.projectId, params.scopes.projectId),
214447
- eq(subAgentRelations.graphId, params.scopes.graphId),
214447
+ eq(subAgentRelations.agentId, params.scopes.agentId),
214448
214448
  eq(subAgentRelations.id, params.relationId)
214449
214449
  )
214450
214450
  );
214451
214451
  return (result.rowsAffected || 0) > 0;
214452
214452
  };
214453
- var deleteAgentRelationsByGraph = (db) => async (params) => {
214453
+ var deleteAgentRelationsByAgent = (db) => async (params) => {
214454
214454
  const result = await db.delete(subAgentRelations).where(
214455
214455
  and(
214456
214456
  eq(subAgentRelations.tenantId, params.scopes.tenantId),
214457
- eq(subAgentRelations.graphId, params.scopes.graphId)
214457
+ eq(subAgentRelations.agentId, params.scopes.agentId)
214458
214458
  )
214459
214459
  );
214460
214460
  return (result.rowsAffected || 0) > 0;
@@ -214465,7 +214465,7 @@ var createAgentToolRelation = (db) => async (params) => {
214465
214465
  id: finalRelationId,
214466
214466
  tenantId: params.scopes.tenantId,
214467
214467
  projectId: params.scopes.projectId,
214468
- graphId: params.scopes.graphId,
214468
+ agentId: params.scopes.agentId,
214469
214469
  subAgentId: params.data.subAgentId,
214470
214470
  toolId: params.data.toolId,
214471
214471
  selectedTools: params.data.selectedTools,
@@ -214482,7 +214482,7 @@ var updateAgentToolRelation = (db) => async (params) => {
214482
214482
  and(
214483
214483
  eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
214484
214484
  eq(subAgentToolRelations.projectId, params.scopes.projectId),
214485
- eq(subAgentToolRelations.graphId, params.scopes.graphId),
214485
+ eq(subAgentToolRelations.agentId, params.scopes.agentId),
214486
214486
  eq(subAgentToolRelations.id, params.relationId)
214487
214487
  )
214488
214488
  ).returning();
@@ -214493,7 +214493,7 @@ var deleteAgentToolRelation = (db) => async (params) => {
214493
214493
  and(
214494
214494
  eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
214495
214495
  eq(subAgentToolRelations.projectId, params.scopes.projectId),
214496
- eq(subAgentToolRelations.graphId, params.scopes.graphId),
214496
+ eq(subAgentToolRelations.agentId, params.scopes.agentId),
214497
214497
  eq(subAgentToolRelations.id, params.relationId)
214498
214498
  )
214499
214499
  );
@@ -214504,7 +214504,7 @@ var deleteAgentToolRelationByAgent = (db) => async (params) => {
214504
214504
  and(
214505
214505
  eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
214506
214506
  eq(subAgentToolRelations.projectId, params.scopes.projectId),
214507
- eq(subAgentToolRelations.graphId, params.scopes.graphId),
214507
+ eq(subAgentToolRelations.agentId, params.scopes.agentId),
214508
214508
  eq(subAgentToolRelations.subAgentId, params.scopes.subAgentId)
214509
214509
  )
214510
214510
  );
@@ -214515,7 +214515,7 @@ var getAgentToolRelationById = (db) => async (params) => {
214515
214515
  where: and(
214516
214516
  eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
214517
214517
  eq(subAgentToolRelations.projectId, params.scopes.projectId),
214518
- eq(subAgentToolRelations.graphId, params.scopes.graphId),
214518
+ eq(subAgentToolRelations.agentId, params.scopes.agentId),
214519
214519
  eq(subAgentToolRelations.id, params.relationId)
214520
214520
  )
214521
214521
  });
@@ -214556,7 +214556,7 @@ var getAgentToolRelationByTool = (db) => async (params) => {
214556
214556
  and(
214557
214557
  eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
214558
214558
  eq(subAgentToolRelations.projectId, params.scopes.projectId),
214559
- eq(subAgentToolRelations.graphId, params.scopes.graphId),
214559
+ eq(subAgentToolRelations.agentId, params.scopes.agentId),
214560
214560
  eq(subAgentToolRelations.toolId, params.toolId)
214561
214561
  )
214562
214562
  ).limit(limit).offset(offset).orderBy(desc(subAgentToolRelations.createdAt)),
@@ -214564,7 +214564,7 @@ var getAgentToolRelationByTool = (db) => async (params) => {
214564
214564
  and(
214565
214565
  eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
214566
214566
  eq(subAgentToolRelations.projectId, params.scopes.projectId),
214567
- eq(subAgentToolRelations.graphId, params.scopes.graphId),
214567
+ eq(subAgentToolRelations.agentId, params.scopes.agentId),
214568
214568
  eq(subAgentToolRelations.toolId, params.toolId)
214569
214569
  )
214570
214570
  )
@@ -214585,14 +214585,14 @@ var listAgentToolRelations = (db) => async (params) => {
214585
214585
  and(
214586
214586
  eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
214587
214587
  eq(subAgentToolRelations.projectId, params.scopes.projectId),
214588
- eq(subAgentToolRelations.graphId, params.scopes.graphId)
214588
+ eq(subAgentToolRelations.agentId, params.scopes.agentId)
214589
214589
  )
214590
214590
  ).limit(limit).offset(offset).orderBy(desc(subAgentToolRelations.createdAt)),
214591
214591
  db.select({ count: count() }).from(subAgentToolRelations).where(
214592
214592
  and(
214593
214593
  eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
214594
214594
  eq(subAgentToolRelations.projectId, params.scopes.projectId),
214595
- eq(subAgentToolRelations.graphId, params.scopes.graphId)
214595
+ eq(subAgentToolRelations.agentId, params.scopes.agentId)
214596
214596
  )
214597
214597
  )
214598
214598
  ]);
@@ -214643,7 +214643,7 @@ var getToolsForAgent = (db) => async (params) => {
214643
214643
  and(
214644
214644
  eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
214645
214645
  eq(subAgentToolRelations.projectId, params.scopes.projectId),
214646
- eq(subAgentToolRelations.graphId, params.scopes.graphId),
214646
+ eq(subAgentToolRelations.agentId, params.scopes.agentId),
214647
214647
  eq(subAgentToolRelations.subAgentId, params.scopes.subAgentId)
214648
214648
  )
214649
214649
  ).limit(limit).offset(offset).orderBy(desc(subAgentToolRelations.createdAt)),
@@ -214651,7 +214651,7 @@ var getToolsForAgent = (db) => async (params) => {
214651
214651
  and(
214652
214652
  eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
214653
214653
  eq(subAgentToolRelations.projectId, params.scopes.projectId),
214654
- eq(subAgentToolRelations.graphId, params.scopes.graphId),
214654
+ eq(subAgentToolRelations.agentId, params.scopes.agentId),
214655
214655
  eq(subAgentToolRelations.subAgentId, params.scopes.subAgentId)
214656
214656
  )
214657
214657
  )
@@ -214694,13 +214694,13 @@ var getAgentsForTool = (db) => async (params) => {
214694
214694
  eq(subAgentToolRelations.subAgentId, subAgents.id),
214695
214695
  eq(subAgentToolRelations.tenantId, subAgents.tenantId),
214696
214696
  eq(subAgentToolRelations.projectId, subAgents.projectId),
214697
- eq(subAgentToolRelations.graphId, subAgents.graphId)
214697
+ eq(subAgentToolRelations.agentId, subAgents.agentId)
214698
214698
  )
214699
214699
  ).where(
214700
214700
  and(
214701
214701
  eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
214702
214702
  eq(subAgentToolRelations.projectId, params.scopes.projectId),
214703
- eq(subAgentToolRelations.graphId, params.scopes.graphId),
214703
+ eq(subAgentToolRelations.agentId, params.scopes.agentId),
214704
214704
  eq(subAgentToolRelations.toolId, params.toolId)
214705
214705
  )
214706
214706
  ).limit(limit).offset(offset).orderBy(desc(subAgentToolRelations.createdAt)),
@@ -214708,7 +214708,7 @@ var getAgentsForTool = (db) => async (params) => {
214708
214708
  and(
214709
214709
  eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
214710
214710
  eq(subAgentToolRelations.projectId, params.scopes.projectId),
214711
- eq(subAgentToolRelations.graphId, params.scopes.graphId),
214711
+ eq(subAgentToolRelations.agentId, params.scopes.agentId),
214712
214712
  eq(subAgentToolRelations.toolId, params.toolId)
214713
214713
  )
214714
214714
  )
@@ -214725,7 +214725,7 @@ var validateInternalSubAgent = (db) => async (params) => {
214725
214725
  and(
214726
214726
  eq(subAgents.tenantId, params.scopes.tenantId),
214727
214727
  eq(subAgents.projectId, params.scopes.projectId),
214728
- eq(subAgents.graphId, params.scopes.graphId),
214728
+ eq(subAgents.agentId, params.scopes.agentId),
214729
214729
  eq(subAgents.id, params.scopes.subAgentId)
214730
214730
  )
214731
214731
  ).limit(1);
@@ -214736,7 +214736,7 @@ var validateExternalAgent = (db) => async (params) => {
214736
214736
  and(
214737
214737
  eq(externalAgents.tenantId, params.scopes.tenantId),
214738
214738
  eq(externalAgents.projectId, params.scopes.projectId),
214739
- eq(externalAgents.graphId, params.scopes.graphId),
214739
+ eq(externalAgents.agentId, params.scopes.agentId),
214740
214740
  eq(externalAgents.id, params.scopes.subAgentId)
214741
214741
  )
214742
214742
  ).limit(1);
@@ -214747,7 +214747,7 @@ var getSubAgentById = (db) => async (params) => {
214747
214747
  where: and(
214748
214748
  eq(subAgents.tenantId, params.scopes.tenantId),
214749
214749
  eq(subAgents.projectId, params.scopes.projectId),
214750
- eq(subAgents.graphId, params.scopes.graphId),
214750
+ eq(subAgents.agentId, params.scopes.agentId),
214751
214751
  eq(subAgents.id, params.subAgentId)
214752
214752
  )
214753
214753
  });
@@ -214758,7 +214758,7 @@ var listSubAgents = (db) => async (params) => {
214758
214758
  where: and(
214759
214759
  eq(subAgents.tenantId, params.scopes.tenantId),
214760
214760
  eq(subAgents.projectId, params.scopes.projectId),
214761
- eq(subAgents.graphId, params.scopes.graphId)
214761
+ eq(subAgents.agentId, params.scopes.agentId)
214762
214762
  )
214763
214763
  });
214764
214764
  };
@@ -214769,7 +214769,7 @@ var listSubAgentsPaginated = (db) => async (params) => {
214769
214769
  const whereClause = and(
214770
214770
  eq(subAgents.tenantId, params.scopes.tenantId),
214771
214771
  eq(subAgents.projectId, params.scopes.projectId),
214772
- eq(subAgents.graphId, params.scopes.graphId)
214772
+ eq(subAgents.agentId, params.scopes.agentId)
214773
214773
  );
214774
214774
  const [data, totalResult] = await Promise.all([
214775
214775
  db.select().from(subAgents).where(whereClause).limit(limit).offset(offset).orderBy(desc(subAgents.createdAt)),
@@ -214801,7 +214801,7 @@ var updateSubAgent = (db) => async (params) => {
214801
214801
  and(
214802
214802
  eq(subAgents.tenantId, params.scopes.tenantId),
214803
214803
  eq(subAgents.projectId, params.scopes.projectId),
214804
- eq(subAgents.graphId, params.scopes.graphId),
214804
+ eq(subAgents.agentId, params.scopes.agentId),
214805
214805
  eq(subAgents.id, params.subAgentId)
214806
214806
  )
214807
214807
  ).returning();
@@ -214811,7 +214811,7 @@ var upsertSubAgent = (db) => async (params) => {
214811
214811
  const scopes = {
214812
214812
  tenantId: params.data.tenantId,
214813
214813
  projectId: params.data.projectId,
214814
- graphId: params.data.graphId
214814
+ agentId: params.data.agentId
214815
214815
  };
214816
214816
  const existing = await getSubAgentById(db)({
214817
214817
  scopes,
@@ -214843,7 +214843,7 @@ var deleteSubAgent = (db) => async (params) => {
214843
214843
  and(
214844
214844
  eq(subAgents.tenantId, params.scopes.tenantId),
214845
214845
  eq(subAgents.projectId, params.scopes.projectId),
214846
- eq(subAgents.graphId, params.scopes.graphId),
214846
+ eq(subAgents.agentId, params.scopes.agentId),
214847
214847
  eq(subAgents.id, params.subAgentId)
214848
214848
  )
214849
214849
  );
@@ -214861,7 +214861,7 @@ var getSubAgentsByIds = (db) => async (params) => {
214861
214861
  and(
214862
214862
  eq(subAgents.tenantId, params.scopes.tenantId),
214863
214863
  eq(subAgents.projectId, params.scopes.projectId),
214864
- eq(subAgents.graphId, params.scopes.graphId),
214864
+ eq(subAgents.agentId, params.scopes.agentId),
214865
214865
  inArray(subAgents.id, params.subAgentIds)
214866
214866
  )
214867
214867
  );
@@ -215329,7 +215329,7 @@ function createExecutionContext(params) {
215329
215329
  apiKey: params.apiKey,
215330
215330
  tenantId: params.tenantId,
215331
215331
  projectId: params.projectId,
215332
- graphId: params.graphId,
215332
+ agentId: params.agentId,
215333
215333
  baseUrl: params.baseUrl || process.env.API_URL || "http://localhost:3003",
215334
215334
  apiKeyId: params.apiKeyId
215335
215335
  };
@@ -215949,7 +215949,7 @@ var addToolToAgent = (db) => async (params) => {
215949
215949
  id,
215950
215950
  tenantId: params.scopes.tenantId,
215951
215951
  projectId: params.scopes.projectId,
215952
- graphId: params.scopes.graphId,
215952
+ agentId: params.scopes.agentId,
215953
215953
  subAgentId: params.subAgentId,
215954
215954
  toolId: params.toolId,
215955
215955
  selectedTools: params.selectedTools,
@@ -215964,7 +215964,7 @@ var removeToolFromAgent = (db) => async (params) => {
215964
215964
  and(
215965
215965
  eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
215966
215966
  eq(subAgentToolRelations.projectId, params.scopes.projectId),
215967
- eq(subAgentToolRelations.graphId, params.scopes.graphId),
215967
+ eq(subAgentToolRelations.agentId, params.scopes.agentId),
215968
215968
  eq(subAgentToolRelations.subAgentId, params.subAgentId),
215969
215969
  eq(subAgentToolRelations.toolId, params.toolId)
215970
215970
  )
@@ -216009,23 +216009,23 @@ var upsertTool = (db) => async (params) => {
216009
216009
  }
216010
216010
  };
216011
216011
 
216012
- // src/data-access/agentGraphs.ts
216013
- var getAgentGraphById = (db) => async (params) => {
216014
- const result = await db.query.agentGraph.findFirst({
216012
+ // src/data-access/agents.ts
216013
+ var getAgentById = (db) => async (params) => {
216014
+ const result = await db.query.agents.findFirst({
216015
216015
  where: and(
216016
- eq(agentGraph.tenantId, params.scopes.tenantId),
216017
- eq(agentGraph.projectId, params.scopes.projectId),
216018
- eq(agentGraph.id, params.scopes.graphId)
216016
+ eq(agents.tenantId, params.scopes.tenantId),
216017
+ eq(agents.projectId, params.scopes.projectId),
216018
+ eq(agents.id, params.scopes.agentId)
216019
216019
  )
216020
216020
  });
216021
216021
  return result ?? null;
216022
216022
  };
216023
- var getAgentGraphWithDefaultSubAgent = (db) => async (params) => {
216024
- const result = await db.query.agentGraph.findFirst({
216023
+ var getAgentWithDefaultSubAgent = (db) => async (params) => {
216024
+ const result = await db.query.agents.findFirst({
216025
216025
  where: and(
216026
- eq(agentGraph.tenantId, params.scopes.tenantId),
216027
- eq(agentGraph.projectId, params.scopes.projectId),
216028
- eq(agentGraph.id, params.scopes.graphId)
216026
+ eq(agents.tenantId, params.scopes.tenantId),
216027
+ eq(agents.projectId, params.scopes.projectId),
216028
+ eq(agents.id, params.scopes.agentId)
216029
216029
  ),
216030
216030
  with: {
216031
216031
  defaultSubAgent: true
@@ -216033,26 +216033,26 @@ var getAgentGraphWithDefaultSubAgent = (db) => async (params) => {
216033
216033
  });
216034
216034
  return result ?? null;
216035
216035
  };
216036
- var listAgentGraphs = (db) => async (params) => {
216037
- return await db.query.agentGraph.findMany({
216036
+ var listAgents = (db) => async (params) => {
216037
+ return await db.query.agents.findMany({
216038
216038
  where: and(
216039
- eq(agentGraph.tenantId, params.scopes.tenantId),
216040
- eq(agentGraph.projectId, params.scopes.projectId)
216039
+ eq(agents.tenantId, params.scopes.tenantId),
216040
+ eq(agents.projectId, params.scopes.projectId)
216041
216041
  )
216042
216042
  });
216043
216043
  };
216044
- var listAgentGraphsPaginated = (db) => async (params) => {
216044
+ var listAgentsPaginated = (db) => async (params) => {
216045
216045
  const page = params.pagination?.page || 1;
216046
216046
  const limit = Math.min(params.pagination?.limit || 10, 100);
216047
216047
  const offset = (page - 1) * limit;
216048
216048
  const whereClause = and(
216049
- eq(agentGraph.tenantId, params.scopes.tenantId),
216050
- eq(agentGraph.projectId, params.scopes.projectId)
216049
+ eq(agents.tenantId, params.scopes.tenantId),
216050
+ eq(agents.projectId, params.scopes.projectId)
216051
216051
  );
216052
- const query = db.select().from(agentGraph).where(whereClause).limit(limit).offset(offset).orderBy(desc(agentGraph.createdAt));
216052
+ const query = db.select().from(agents).where(whereClause).limit(limit).offset(offset).orderBy(desc(agents.createdAt));
216053
216053
  const [data, totalResult] = await Promise.all([
216054
216054
  query,
216055
- db.select({ count: count() }).from(agentGraph).where(whereClause)
216055
+ db.select({ count: count() }).from(agents).where(whereClause)
216056
216056
  ]);
216057
216057
  const total = totalResult[0]?.count || 0;
216058
216058
  const pages = Math.ceil(total / limit);
@@ -216061,74 +216061,62 @@ var listAgentGraphsPaginated = (db) => async (params) => {
216061
216061
  pagination: { page, limit, total, pages }
216062
216062
  };
216063
216063
  };
216064
- var createAgentGraph = (db) => async (data) => {
216064
+ var createAgent = (db) => async (data) => {
216065
216065
  const now = (/* @__PURE__ */ new Date()).toISOString();
216066
216066
  const insertData = {
216067
216067
  ...data,
216068
216068
  createdAt: now,
216069
- updatedAt: now
216069
+ updatedAt: now,
216070
+ ...data.description !== void 0 && { description: data.description },
216071
+ ...data.contextConfigId !== void 0 && { contextConfigId: data.contextConfigId },
216072
+ ...data.models !== void 0 && { models: data.models },
216073
+ ...data.statusUpdates !== void 0 && { statusUpdates: data.statusUpdates },
216074
+ ...data.prompt !== void 0 && { prompt: data.prompt },
216075
+ ...data.stopWhen !== void 0 && { stopWhen: data.stopWhen }
216070
216076
  };
216071
- if (data.description !== void 0) {
216072
- insertData.description = data.description;
216073
- }
216074
- if (data.contextConfigId !== void 0) {
216075
- insertData.contextConfigId = data.contextConfigId;
216076
- }
216077
- if (data.models !== void 0) {
216078
- insertData.models = data.models;
216079
- }
216080
- if (data.statusUpdates !== void 0) {
216081
- insertData.statusUpdates = data.statusUpdates;
216082
- }
216083
- if (data.graphPrompt !== void 0) {
216084
- insertData.graphPrompt = data.graphPrompt;
216085
- }
216086
- if (data.stopWhen !== void 0) {
216087
- insertData.stopWhen = data.stopWhen;
216088
- }
216089
- const graph = await db.insert(agentGraph).values(insertData).returning();
216090
- return graph[0];
216077
+ const agent = await db.insert(agents).values(insertData).returning();
216078
+ return agent[0];
216091
216079
  };
216092
- var updateAgentGraph = (db) => async (params) => {
216080
+ var updateAgent = (db) => async (params) => {
216093
216081
  const data = params.data;
216082
+ const updateData = {
216083
+ ...data,
216084
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
216085
+ };
216094
216086
  if (data.models !== void 0) {
216095
216087
  if (!data.models || !data.models.base?.model && !data.models.structuredOutput?.model && !data.models.summarizer?.model && !data.models.base?.providerOptions && !data.models.structuredOutput?.providerOptions && !data.models.summarizer?.providerOptions) {
216096
- data.models = null;
216088
+ updateData.models = null;
216097
216089
  }
216098
216090
  }
216099
216091
  if (data.statusUpdates !== void 0) {
216100
216092
  if (!data.statusUpdates) {
216101
- data.statusUpdates = null;
216093
+ updateData.statusUpdates = null;
216102
216094
  }
216103
216095
  }
216104
216096
  if (data.contextConfigId !== void 0 && !data.contextConfigId) {
216105
- data.contextConfigId = null;
216097
+ updateData.contextConfigId = null;
216106
216098
  }
216107
- if (data.graphPrompt !== void 0 && !data.graphPrompt) {
216108
- data.graphPrompt = null;
216099
+ if (data.prompt !== void 0 && !data.prompt) {
216100
+ updateData.prompt = null;
216109
216101
  }
216110
216102
  if (data.stopWhen !== void 0 && !data.stopWhen) {
216111
- data.stopWhen = null;
216103
+ updateData.stopWhen = null;
216112
216104
  }
216113
- const updateData = {
216114
- ...data,
216115
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
216116
- };
216117
- const graph = await db.update(agentGraph).set(updateData).where(
216105
+ const agent = await db.update(agents).set(updateData).where(
216118
216106
  and(
216119
- eq(agentGraph.tenantId, params.scopes.tenantId),
216120
- eq(agentGraph.projectId, params.scopes.projectId),
216121
- eq(agentGraph.id, params.scopes.graphId)
216107
+ eq(agents.tenantId, params.scopes.tenantId),
216108
+ eq(agents.projectId, params.scopes.projectId),
216109
+ eq(agents.id, params.scopes.agentId)
216122
216110
  )
216123
216111
  ).returning();
216124
- return graph[0] ?? null;
216112
+ return agent[0] ?? null;
216125
216113
  };
216126
- var deleteAgentGraph = (db) => async (params) => {
216127
- const result = await db.delete(agentGraph).where(
216114
+ var deleteAgent = (db) => async (params) => {
216115
+ const result = await db.delete(agents).where(
216128
216116
  and(
216129
- eq(agentGraph.tenantId, params.scopes.tenantId),
216130
- eq(agentGraph.projectId, params.scopes.projectId),
216131
- eq(agentGraph.id, params.scopes.graphId)
216117
+ eq(agents.tenantId, params.scopes.tenantId),
216118
+ eq(agents.projectId, params.scopes.projectId),
216119
+ eq(agents.id, params.scopes.agentId)
216132
216120
  )
216133
216121
  ).returning();
216134
216122
  return result.length > 0;
@@ -216136,7 +216124,10 @@ var deleteAgentGraph = (db) => async (params) => {
216136
216124
  var fetchComponentRelationships = (db) => async (scopes, subAgentIds, config) => {
216137
216125
  const componentsObject = {};
216138
216126
  if (subAgentIds.length > 0) {
216139
- const results = await db.select(config.selectFields).from(config.relationTable).innerJoin(config.componentTable, eq(config.relationIdField, config.componentIdField)).where(
216127
+ const results = await db.select(config.selectFields).from(config.relationTable).innerJoin(
216128
+ config.componentTable,
216129
+ eq(config.relationIdField, config.componentIdField)
216130
+ ).where(
216140
216131
  and(
216141
216132
  eq(config.relationTable.tenantId, scopes.tenantId),
216142
216133
  eq(config.relationTable.projectId, scopes.projectId),
@@ -216149,20 +216140,19 @@ var fetchComponentRelationships = (db) => async (scopes, subAgentIds, config) =>
216149
216140
  }
216150
216141
  return componentsObject;
216151
216142
  };
216152
- var getGraphAgentInfos = (db) => async ({
216153
- scopes,
216154
- graphId,
216143
+ var getAgentSubAgentInfos = (db) => async ({
216144
+ scopes: { tenantId, projectId },
216145
+ agentId,
216155
216146
  subAgentId
216156
216147
  }) => {
216157
- const { tenantId, projectId } = scopes;
216158
- const graph = await getAgentGraphById(db)({
216159
- scopes: { tenantId, projectId, graphId }
216148
+ const agent = await getAgentById(db)({
216149
+ scopes: { tenantId, projectId, agentId }
216160
216150
  });
216161
- if (!graph) {
216162
- throw new Error(`Agent graph with ID ${graphId} not found for tenant ${tenantId}`);
216151
+ if (!agent) {
216152
+ throw new Error(`Agent with ID ${agentId} not found for tenant ${tenantId}`);
216163
216153
  }
216164
216154
  const relations = await getAgentRelations(db)({
216165
- scopes: { tenantId, projectId, graphId, subAgentId }
216155
+ scopes: { tenantId, projectId, agentId, subAgentId }
216166
216156
  });
216167
216157
  const targetSubAgentIds = relations.map((relation) => relation.targetSubAgentId).filter((id) => id !== null);
216168
216158
  if (targetSubAgentIds.length === 0) {
@@ -216170,48 +216160,45 @@ var getGraphAgentInfos = (db) => async ({
216170
216160
  }
216171
216161
  const agentInfos = await Promise.all(
216172
216162
  targetSubAgentIds.map(async (subAgentId2) => {
216173
- const agent = await getSubAgentById(db)({
216174
- scopes: { tenantId, projectId, graphId },
216163
+ const agent2 = await getSubAgentById(db)({
216164
+ scopes: { tenantId, projectId, agentId },
216175
216165
  subAgentId: subAgentId2
216176
216166
  });
216177
- if (agent !== void 0) {
216178
- return { id: agent.id, name: agent.name, description: agent.description };
216179
- }
216180
- return null;
216167
+ return agent2 ? { id: agent2.id, name: agent2.name, description: agent2.description } : null;
216181
216168
  })
216182
216169
  );
216183
- return agentInfos.filter((agent) => agent !== null);
216170
+ return agentInfos.filter((agent2) => agent2 !== null);
216184
216171
  };
216185
- var getFullGraphDefinition = (db) => async ({
216186
- scopes: { tenantId, projectId, graphId }
216172
+ var getFullAgentDefinition = (db) => async ({
216173
+ scopes: { tenantId, projectId, agentId }
216187
216174
  }) => {
216188
- const graph = await getAgentGraphById(db)({
216189
- scopes: { tenantId, projectId, graphId }
216175
+ const agent = await getAgentById(db)({
216176
+ scopes: { tenantId, projectId, agentId }
216190
216177
  });
216191
- if (!graph) {
216178
+ if (!agent) {
216192
216179
  return null;
216193
216180
  }
216194
- const graphRelations = await getAgentRelationsByGraph(db)({
216195
- scopes: { tenantId, projectId, graphId }
216181
+ const agentRelations2 = await getAgentRelationsByAgent(db)({
216182
+ scopes: { tenantId, projectId, agentId }
216196
216183
  });
216197
- const graphSubAgents = await db.query.subAgents.findMany({
216184
+ const agentSubAgents = await db.query.subAgents.findMany({
216198
216185
  where: and(
216199
216186
  eq(subAgents.tenantId, tenantId),
216200
216187
  eq(subAgents.projectId, projectId),
216201
- eq(subAgents.graphId, graphId)
216188
+ eq(subAgents.agentId, agentId)
216202
216189
  )
216203
216190
  });
216204
216191
  const externalSubAgentIds = /* @__PURE__ */ new Set();
216205
- for (const relation of graphRelations) {
216192
+ for (const relation of agentRelations2) {
216206
216193
  if (relation.externalSubAgentId) {
216207
216194
  externalSubAgentIds.add(relation.externalSubAgentId);
216208
216195
  }
216209
216196
  }
216210
216197
  const processedSubAgents = await Promise.all(
216211
- graphSubAgents.map(async (agent) => {
216212
- if (!agent) return null;
216213
- const subAgentRelationsList = graphRelations.filter(
216214
- (relation) => relation.sourceSubAgentId === agent.id
216198
+ agentSubAgents.map(async (agent2) => {
216199
+ if (!agent2) return null;
216200
+ const subAgentRelationsList = agentRelations2.filter(
216201
+ (relation) => relation.sourceSubAgentId === agent2.id
216215
216202
  );
216216
216203
  const canTransferTo = subAgentRelationsList.filter((rel) => rel.relationType === "transfer" || rel.relationType === "transfer_to").map((rel) => rel.targetSubAgentId).filter((id) => id !== null);
216217
216204
  const canDelegateTo = subAgentRelationsList.filter((rel) => rel.relationType === "delegate" || rel.relationType === "delegate_to").map((rel) => rel.targetSubAgentId || rel.externalSubAgentId).filter((id) => id !== null);
@@ -216241,8 +216228,8 @@ var getFullGraphDefinition = (db) => async ({
216241
216228
  and(
216242
216229
  eq(subAgentToolRelations.tenantId, tenantId),
216243
216230
  eq(subAgentToolRelations.projectId, projectId),
216244
- eq(subAgentToolRelations.graphId, graphId),
216245
- eq(subAgentToolRelations.subAgentId, agent.id)
216231
+ eq(subAgentToolRelations.agentId, agentId),
216232
+ eq(subAgentToolRelations.subAgentId, agent2.id)
216246
216233
  )
216247
216234
  );
216248
216235
  const agentFunctionTools = await db.select({
@@ -216254,7 +216241,7 @@ var getFullGraphDefinition = (db) => async ({
216254
216241
  updatedAt: functionTools.updatedAt,
216255
216242
  tenantId: functionTools.tenantId,
216256
216243
  projectId: functionTools.projectId,
216257
- graphId: functionTools.graphId,
216244
+ agentId: functionTools.agentId,
216258
216245
  agentToolRelationId: agentFunctionToolRelations.id
216259
216246
  }).from(agentFunctionToolRelations).innerJoin(
216260
216247
  functionTools,
@@ -216262,27 +216249,27 @@ var getFullGraphDefinition = (db) => async ({
216262
216249
  eq(agentFunctionToolRelations.functionToolId, functionTools.id),
216263
216250
  eq(agentFunctionToolRelations.tenantId, functionTools.tenantId),
216264
216251
  eq(agentFunctionToolRelations.projectId, functionTools.projectId),
216265
- eq(agentFunctionToolRelations.graphId, functionTools.graphId)
216252
+ eq(agentFunctionToolRelations.agentId, functionTools.agentId)
216266
216253
  )
216267
216254
  ).where(
216268
216255
  and(
216269
216256
  eq(agentFunctionToolRelations.tenantId, tenantId),
216270
216257
  eq(agentFunctionToolRelations.projectId, projectId),
216271
- eq(agentFunctionToolRelations.graphId, graphId),
216272
- eq(agentFunctionToolRelations.subAgentId, agent.id)
216258
+ eq(agentFunctionToolRelations.agentId, agentId),
216259
+ eq(agentFunctionToolRelations.subAgentId, agent2.id)
216273
216260
  )
216274
216261
  );
216275
216262
  const agentDataComponentRelations = await db.query.subAgentDataComponents.findMany({
216276
216263
  where: and(
216277
216264
  eq(subAgentDataComponents.tenantId, tenantId),
216278
- eq(subAgentDataComponents.subAgentId, agent.id)
216265
+ eq(subAgentDataComponents.subAgentId, agent2.id)
216279
216266
  )
216280
216267
  });
216281
216268
  const agentDataComponentIds = agentDataComponentRelations.map((rel) => rel.dataComponentId);
216282
216269
  const agentArtifactComponentRelations = await db.query.subAgentArtifactComponents.findMany({
216283
216270
  where: and(
216284
216271
  eq(subAgentArtifactComponents.tenantId, tenantId),
216285
- eq(subAgentArtifactComponents.subAgentId, agent.id)
216272
+ eq(subAgentArtifactComponents.subAgentId, agent2.id)
216286
216273
  )
216287
216274
  });
216288
216275
  const agentArtifactComponentIds = agentArtifactComponentRelations.map(
@@ -216304,12 +216291,12 @@ var getFullGraphDefinition = (db) => async ({
216304
216291
  }));
216305
216292
  const canUse = [...mcpToolCanUse, ...functionToolCanUse];
216306
216293
  return {
216307
- id: agent.id,
216308
- name: agent.name,
216309
- description: agent.description,
216310
- prompt: agent.prompt,
216311
- models: agent.models,
216312
- stopWhen: agent.stopWhen,
216294
+ id: agent2.id,
216295
+ name: agent2.name,
216296
+ description: agent2.description,
216297
+ prompt: agent2.prompt,
216298
+ models: agent2.models,
216299
+ stopWhen: agent2.stopWhen,
216313
216300
  canTransferTo,
216314
216301
  canDelegateTo,
216315
216302
  dataComponents: agentDataComponentIds,
@@ -216321,54 +216308,48 @@ var getFullGraphDefinition = (db) => async ({
216321
216308
  const externalAgents2 = await Promise.all(
216322
216309
  Array.from(externalSubAgentIds).map(async (subAgentId) => {
216323
216310
  const subAgent = await getExternalAgent(db)({
216324
- scopes: { tenantId, projectId, graphId },
216311
+ scopes: { tenantId, projectId, agentId },
216325
216312
  subAgentId
216326
216313
  });
216327
216314
  if (!subAgent) return null;
216328
216315
  return {
216329
- id: subAgent.id,
216330
- name: subAgent.name,
216331
- description: subAgent.description,
216332
- baseUrl: subAgent.baseUrl,
216333
- headers: subAgent.headers,
216334
- credentialReferenceId: subAgent.credentialReferenceId,
216316
+ ...subAgent,
216335
216317
  type: "external"
216336
216318
  };
216337
216319
  })
216338
216320
  );
216339
- const validAgents = [...processedSubAgents, ...externalAgents2].filter(
216340
- (agent) => agent !== null
216321
+ const validSubAgents = [...processedSubAgents, ...externalAgents2].filter(
216322
+ (agent2) => agent2 !== null
216341
216323
  );
216342
216324
  const agentsObject = {};
216343
- for (const agent of validAgents) {
216344
- const isExternalAgent2 = "baseUrl" in agent && agent.baseUrl;
216345
- if (isExternalAgent2) {
216346
- agentsObject[agent.id] = {
216347
- id: agent.id,
216348
- name: agent.name,
216349
- description: agent.description,
216350
- baseUrl: agent.baseUrl,
216351
- credentialReferenceId: agent.credentialReferenceId,
216352
- headers: agent.headers,
216325
+ for (const subAgent of validSubAgents) {
216326
+ if ("baseUrl" in subAgent && subAgent.baseUrl) {
216327
+ agentsObject[subAgent.id] = {
216328
+ id: subAgent.id,
216329
+ name: subAgent.name,
216330
+ description: subAgent.description,
216331
+ baseUrl: subAgent.baseUrl,
216332
+ credentialReferenceId: subAgent.credentialReferenceId,
216333
+ headers: subAgent.headers,
216353
216334
  type: "external"
216354
216335
  };
216355
216336
  } else {
216356
- agentsObject[agent.id] = agent;
216337
+ agentsObject[subAgent.id] = subAgent;
216357
216338
  }
216358
216339
  }
216359
216340
  let contextConfig2 = null;
216360
- if (graph.contextConfigId) {
216341
+ if (agent.contextConfigId) {
216361
216342
  try {
216362
216343
  contextConfig2 = await getContextConfigById(db)({
216363
- scopes: { tenantId, projectId, graphId },
216364
- id: graph.contextConfigId
216344
+ scopes: { tenantId, projectId, agentId },
216345
+ id: agent.contextConfigId
216365
216346
  });
216366
216347
  } catch (error) {
216367
- console.warn(`Failed to retrieve contextConfig ${graph.contextConfigId}:`, error);
216348
+ console.warn(`Failed to retrieve contextConfig ${agent.contextConfigId}:`, error);
216368
216349
  }
216369
216350
  }
216370
216351
  try {
216371
- const internalAgentIds = graphSubAgents.map((agent) => agent.id);
216352
+ const internalAgentIds = agentSubAgents.map((subAgent) => subAgent.id);
216372
216353
  const subAgentIds = Array.from(internalAgentIds);
216373
216354
  await fetchComponentRelationships(db)({ tenantId, projectId }, subAgentIds, {
216374
216355
  relationTable: subAgentDataComponents,
@@ -216387,7 +216368,7 @@ var getFullGraphDefinition = (db) => async ({
216387
216368
  console.warn("Failed to retrieve dataComponents:", error);
216388
216369
  }
216389
216370
  try {
216390
- const internalAgentIds = graphSubAgents.map((agent) => agent.id);
216371
+ const internalAgentIds = agentSubAgents.map((subAgent) => subAgent.id);
216391
216372
  const subAgentIds = Array.from(internalAgentIds);
216392
216373
  await fetchComponentRelationships(db)({ tenantId, projectId }, subAgentIds, {
216393
216374
  relationTable: subAgentArtifactComponents,
@@ -216406,33 +216387,29 @@ var getFullGraphDefinition = (db) => async ({
216406
216387
  console.warn("Failed to retrieve artifactComponents:", error);
216407
216388
  }
216408
216389
  const result = {
216409
- id: graph.id,
216410
- name: graph.name,
216411
- description: graph.description,
216412
- defaultSubAgentId: graph.defaultSubAgentId,
216390
+ id: agent.id,
216391
+ name: agent.name,
216392
+ description: agent.description,
216393
+ defaultSubAgentId: agent.defaultSubAgentId,
216413
216394
  subAgents: agentsObject,
216414
- // No tools field - tools are defined at project level
216415
- createdAt: graph.createdAt && !Number.isNaN(new Date(graph.createdAt).getTime()) ? new Date(graph.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
216416
- updatedAt: graph.updatedAt && !Number.isNaN(new Date(graph.updatedAt).getTime()) ? new Date(graph.updatedAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
216395
+ createdAt: agent.createdAt && !Number.isNaN(new Date(agent.createdAt).getTime()) ? new Date(agent.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
216396
+ updatedAt: agent.updatedAt && !Number.isNaN(new Date(agent.updatedAt).getTime()) ? new Date(agent.updatedAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
216417
216397
  };
216418
- if (graph.models) {
216419
- result.models = graph.models;
216398
+ if (agent.models) {
216399
+ result.models = agent.models;
216420
216400
  }
216421
- if (graph.statusUpdates) {
216422
- result.statusUpdates = graph.statusUpdates;
216401
+ if (agent.statusUpdates) {
216402
+ result.statusUpdates = agent.statusUpdates;
216423
216403
  }
216424
- if (graph.graphPrompt) {
216425
- result.graphPrompt = graph.graphPrompt;
216404
+ if (agent.prompt) {
216405
+ result.prompt = agent.prompt;
216426
216406
  }
216427
- if (graph.stopWhen) {
216428
- result.stopWhen = graph.stopWhen;
216407
+ if (agent.stopWhen) {
216408
+ result.stopWhen = agent.stopWhen;
216429
216409
  }
216430
216410
  if (contextConfig2) {
216431
- result.contextConfig = {
216432
- id: contextConfig2.id,
216433
- headersSchema: contextConfig2.headersSchema,
216434
- contextVariables: contextConfig2.contextVariables
216435
- };
216411
+ const { id, headersSchema, contextVariables } = contextConfig2;
216412
+ result.contextConfig = { id, headersSchema, contextVariables };
216436
216413
  }
216437
216414
  try {
216438
216415
  if (!db.query?.projects?.findFirst) {
@@ -216443,33 +216420,36 @@ var getFullGraphDefinition = (db) => async ({
216443
216420
  });
216444
216421
  if (project?.stopWhen) {
216445
216422
  const projectStopWhen = project.stopWhen;
216446
- if (projectStopWhen?.stepCountIs !== void 0) {
216447
- for (const [subAgentId, agentData] of Object.entries(result.subAgents)) {
216448
- if (agentData && typeof agentData === "object" && !("baseUrl" in agentData)) {
216449
- const agent = agentData;
216450
- const needsInheritance = !agent.stopWhen || agent.stopWhen.stepCountIs === void 0;
216451
- if (needsInheritance) {
216452
- if (!agent.stopWhen) {
216453
- agent.stopWhen = {};
216454
- }
216455
- agent.stopWhen.stepCountIs = projectStopWhen.stepCountIs;
216456
- try {
216457
- await db.update(subAgents).set({
216458
- stopWhen: agent.stopWhen,
216459
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
216460
- }).where(
216461
- and(
216462
- eq(subAgents.tenantId, tenantId),
216463
- eq(subAgents.projectId, projectId),
216464
- eq(subAgents.id, subAgentId)
216465
- )
216466
- );
216467
- result.subAgents[subAgentId] = {
216468
- ...result.subAgents[subAgentId],
216469
- stopWhen: agent.stopWhen
216470
- };
216471
- } catch (dbError) {
216472
- console.warn(`Failed to persist stopWhen for agent ${subAgentId}:`, dbError);
216423
+ if (projectStopWhen.stepCountIs !== void 0) {
216424
+ const resultSubAgents = result.subAgents;
216425
+ if (resultSubAgents) {
216426
+ for (const [subAgentId, agentData] of Object.entries(resultSubAgents)) {
216427
+ if (agentData && typeof agentData === "object" && !("baseUrl" in agentData)) {
216428
+ const agent2 = agentData;
216429
+ const needsInheritance = !agent2.stopWhen || agent2.stopWhen.stepCountIs === void 0;
216430
+ if (needsInheritance) {
216431
+ if (!agent2.stopWhen) {
216432
+ agent2.stopWhen = {};
216433
+ }
216434
+ agent2.stopWhen.stepCountIs = projectStopWhen.stepCountIs;
216435
+ try {
216436
+ await db.update(subAgents).set({
216437
+ stopWhen: agent2.stopWhen,
216438
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
216439
+ }).where(
216440
+ and(
216441
+ eq(subAgents.tenantId, tenantId),
216442
+ eq(subAgents.projectId, projectId),
216443
+ eq(subAgents.id, subAgentId)
216444
+ )
216445
+ );
216446
+ result.subAgents[subAgentId] = {
216447
+ ...result.subAgents[subAgentId],
216448
+ stopWhen: agent2.stopWhen
216449
+ };
216450
+ } catch (dbError) {
216451
+ console.warn(`Failed to persist stopWhen for agent ${subAgentId}:`, dbError);
216452
+ }
216473
216453
  }
216474
216454
  }
216475
216455
  }
@@ -216497,7 +216477,7 @@ var getFullGraphDefinition = (db) => async ({
216497
216477
  }
216498
216478
  result.tools = toolsObject;
216499
216479
  const functionToolsList = await listFunctionTools(db)({
216500
- scopes: { tenantId, projectId, graphId },
216480
+ scopes: { tenantId, projectId, agentId },
216501
216481
  pagination: { page: 1, limit: 1e3 }
216502
216482
  });
216503
216483
  const functionToolsObject = {};
@@ -216517,36 +216497,38 @@ var getFullGraphDefinition = (db) => async ({
216517
216497
  }
216518
216498
  }
216519
216499
  if (functionIds.size > 0) {
216520
- const functionsObject = {};
216521
- for (const functionId of functionIds) {
216522
- const func = await getFunction(db)({
216523
- functionId,
216524
- scopes: { tenantId, projectId }
216525
- });
216526
- if (func) {
216527
- functionsObject[functionId] = {
216528
- id: func.id,
216529
- inputSchema: func.inputSchema,
216530
- executeCode: func.executeCode,
216531
- dependencies: func.dependencies
216532
- };
216533
- }
216534
- }
216535
- result.functions = functionsObject;
216500
+ const functions2 = (await Promise.all(
216501
+ Array.from(functionIds).map(async (functionId) => {
216502
+ const func = await getFunction(db)({
216503
+ functionId,
216504
+ scopes: { tenantId, projectId }
216505
+ });
216506
+ return func ? [
216507
+ functionId,
216508
+ {
216509
+ id: func.id,
216510
+ inputSchema: func.inputSchema,
216511
+ executeCode: func.executeCode,
216512
+ dependencies: func.dependencies
216513
+ }
216514
+ ] : null;
216515
+ })
216516
+ )).filter((entry) => entry !== null);
216517
+ result.functions = Object.fromEntries(functions2);
216536
216518
  }
216537
216519
  } catch (error) {
216538
216520
  console.warn("Failed to load tools/functions lookups:", error);
216539
216521
  }
216540
216522
  return result;
216541
216523
  };
216542
- var upsertAgentGraph = (db) => async (params) => {
216543
- const graphId = params.data.id || nanoid();
216544
- const scopes = { tenantId: params.data.tenantId, projectId: params.data.projectId, graphId };
216545
- const existing = await getAgentGraphById(db)({
216524
+ var upsertAgent = (db) => async (params) => {
216525
+ const agentId = params.data.id || nanoid();
216526
+ const scopes = { tenantId: params.data.tenantId, projectId: params.data.projectId, agentId };
216527
+ const existing = await getAgentById(db)({
216546
216528
  scopes
216547
216529
  });
216548
216530
  if (existing) {
216549
- return await updateAgentGraph(db)({
216531
+ return await updateAgent(db)({
216550
216532
  scopes,
216551
216533
  data: {
216552
216534
  name: params.data.name,
@@ -216557,12 +216539,11 @@ var upsertAgentGraph = (db) => async (params) => {
216557
216539
  statusUpdates: params.data.statusUpdates
216558
216540
  }
216559
216541
  });
216560
- } else {
216561
- return await createAgentGraph(db)({
216562
- ...params.data,
216563
- id: graphId
216564
- });
216565
216542
  }
216543
+ return await createAgent(db)({
216544
+ ...params.data,
216545
+ id: agentId
216546
+ });
216566
216547
  };
216567
216548
  var getApiKeyById = (db) => async (params) => {
216568
216549
  return await db.query.apiKeys.findFirst({
@@ -216583,8 +216564,8 @@ var listApiKeys = (db) => async (params) => {
216583
216564
  eq(apiKeys.tenantId, params.scopes.tenantId),
216584
216565
  eq(apiKeys.projectId, params.scopes.projectId)
216585
216566
  ];
216586
- if (params.graphId) {
216587
- conditions.push(eq(apiKeys.graphId, params.graphId));
216567
+ if (params.agentId) {
216568
+ conditions.push(eq(apiKeys.agentId, params.agentId));
216588
216569
  }
216589
216570
  return await db.query.apiKeys.findMany({
216590
216571
  where: and(...conditions),
@@ -216599,8 +216580,8 @@ var listApiKeysPaginated = (db) => async (params) => {
216599
216580
  eq(apiKeys.tenantId, params.scopes.tenantId),
216600
216581
  eq(apiKeys.projectId, params.scopes.projectId)
216601
216582
  ];
216602
- if (params.graphId) {
216603
- conditions.push(eq(apiKeys.graphId, params.graphId));
216583
+ if (params.agentId) {
216584
+ conditions.push(eq(apiKeys.agentId, params.agentId));
216604
216585
  }
216605
216586
  const whereClause = and(...conditions);
216606
216587
  const [data, totalResult] = await Promise.all([
@@ -216622,7 +216603,7 @@ var createApiKey = (db) => async (params) => {
216622
216603
  name: params.name,
216623
216604
  tenantId: params.tenantId,
216624
216605
  projectId: params.projectId,
216625
- graphId: params.graphId,
216606
+ agentId: params.agentId,
216626
216607
  publicId: params.publicId,
216627
216608
  keyHash: params.keyHash,
216628
216609
  keyPrefix: params.keyPrefix,
@@ -216681,20 +216662,20 @@ var countApiKeys = (db) => async (params) => {
216681
216662
  eq(apiKeys.tenantId, params.scopes.tenantId),
216682
216663
  eq(apiKeys.projectId, params.scopes.projectId)
216683
216664
  ];
216684
- if (params.graphId) {
216685
- conditions.push(eq(apiKeys.graphId, params.graphId));
216665
+ if (params.agentId) {
216666
+ conditions.push(eq(apiKeys.agentId, params.agentId));
216686
216667
  }
216687
216668
  const result = await db.select({ count: count() }).from(apiKeys).where(and(...conditions));
216688
216669
  const total = result[0]?.count || 0;
216689
216670
  return typeof total === "string" ? Number.parseInt(total, 10) : total;
216690
216671
  };
216691
216672
  var generateAndCreateApiKey = async (params, db) => {
216692
- const { tenantId, projectId, graphId, expiresAt, name } = params;
216673
+ const { tenantId, projectId, agentId, expiresAt, name } = params;
216693
216674
  const keyData = await generateApiKey();
216694
216675
  const apiKey = await createApiKey(db)({
216695
216676
  tenantId,
216696
216677
  projectId,
216697
- graphId,
216678
+ agentId,
216698
216679
  name,
216699
216680
  expiresAt,
216700
216681
  ...keyData
@@ -216834,7 +216815,7 @@ var getArtifactComponentsForAgent = (db) => async (params) => {
216834
216815
  and(
216835
216816
  eq(artifactComponents.tenantId, params.scopes.tenantId),
216836
216817
  eq(artifactComponents.projectId, params.scopes.projectId),
216837
- eq(subAgentArtifactComponents.graphId, params.scopes.graphId),
216818
+ eq(subAgentArtifactComponents.agentId, params.scopes.agentId),
216838
216819
  eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId)
216839
216820
  )
216840
216821
  ).orderBy(desc(artifactComponents.createdAt));
@@ -216844,7 +216825,7 @@ var associateArtifactComponentWithAgent = (db) => async (params) => {
216844
216825
  id: nanoid(),
216845
216826
  tenantId: params.scopes.tenantId,
216846
216827
  projectId: params.scopes.projectId,
216847
- graphId: params.scopes.graphId,
216828
+ agentId: params.scopes.agentId,
216848
216829
  subAgentId: params.scopes.subAgentId,
216849
216830
  artifactComponentId: params.artifactComponentId,
216850
216831
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
@@ -216857,7 +216838,7 @@ var removeArtifactComponentFromAgent = (db) => async (params) => {
216857
216838
  and(
216858
216839
  eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
216859
216840
  eq(subAgentArtifactComponents.projectId, params.scopes.projectId),
216860
- eq(subAgentArtifactComponents.graphId, params.scopes.graphId),
216841
+ eq(subAgentArtifactComponents.agentId, params.scopes.agentId),
216861
216842
  eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId),
216862
216843
  eq(subAgentArtifactComponents.artifactComponentId, params.artifactComponentId)
216863
216844
  )
@@ -216872,7 +216853,7 @@ var deleteAgentArtifactComponentRelationByAgent = (db) => async (params) => {
216872
216853
  const result = await db.delete(subAgentArtifactComponents).where(
216873
216854
  and(
216874
216855
  eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
216875
- eq(subAgentArtifactComponents.graphId, params.scopes.graphId),
216856
+ eq(subAgentArtifactComponents.agentId, params.scopes.agentId),
216876
216857
  eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId)
216877
216858
  )
216878
216859
  );
@@ -216880,7 +216861,7 @@ var deleteAgentArtifactComponentRelationByAgent = (db) => async (params) => {
216880
216861
  };
216881
216862
  var getAgentsUsingArtifactComponent = (db) => async (params) => {
216882
216863
  return await db.select({
216883
- graphId: subAgentArtifactComponents.graphId,
216864
+ agentId: subAgentArtifactComponents.agentId,
216884
216865
  subAgentId: subAgentArtifactComponents.subAgentId,
216885
216866
  createdAt: subAgentArtifactComponents.createdAt
216886
216867
  }).from(subAgentArtifactComponents).where(
@@ -216896,14 +216877,14 @@ var isArtifactComponentAssociatedWithAgent = (db) => async (params) => {
216896
216877
  and(
216897
216878
  eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
216898
216879
  eq(subAgentArtifactComponents.projectId, params.scopes.projectId),
216899
- eq(subAgentArtifactComponents.graphId, params.scopes.graphId),
216880
+ eq(subAgentArtifactComponents.agentId, params.scopes.agentId),
216900
216881
  eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId),
216901
216882
  eq(subAgentArtifactComponents.artifactComponentId, params.artifactComponentId)
216902
216883
  )
216903
216884
  ).limit(1);
216904
216885
  return result.length > 0;
216905
216886
  };
216906
- var graphHasArtifactComponents = (db) => async (params) => {
216887
+ var agentHasArtifactComponents = (db) => async (params) => {
216907
216888
  const result = await db.select({ count: count() }).from(subAgentArtifactComponents).innerJoin(
216908
216889
  subAgents,
216909
216890
  and(
@@ -216916,13 +216897,13 @@ var graphHasArtifactComponents = (db) => async (params) => {
216916
216897
  eq(subAgents.id, subAgentRelations.sourceSubAgentId),
216917
216898
  eq(subAgents.tenantId, subAgentRelations.tenantId),
216918
216899
  eq(subAgents.projectId, subAgentRelations.projectId),
216919
- eq(subAgents.graphId, subAgentRelations.graphId)
216900
+ eq(subAgents.agentId, subAgentRelations.agentId)
216920
216901
  )
216921
216902
  ).where(
216922
216903
  and(
216923
216904
  eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
216924
216905
  eq(subAgentArtifactComponents.projectId, params.scopes.projectId),
216925
- eq(subAgentRelations.graphId, params.scopes.graphId)
216906
+ eq(subAgentRelations.agentId, params.scopes.agentId)
216926
216907
  )
216927
216908
  ).limit(1);
216928
216909
  const total = result[0]?.count || 0;
@@ -216944,7 +216925,7 @@ var countArtifactComponentsForAgent = (db) => async (params) => {
216944
216925
  and(
216945
216926
  eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
216946
216927
  eq(subAgentArtifactComponents.projectId, params.scopes.projectId),
216947
- eq(subAgentArtifactComponents.graphId, params.scopes.graphId),
216928
+ eq(subAgentArtifactComponents.agentId, params.scopes.agentId),
216948
216929
  eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId)
216949
216930
  )
216950
216931
  );
@@ -217428,7 +217409,7 @@ var getDataComponentsForAgent = (db) => async (params) => {
217428
217409
  and(
217429
217410
  eq(dataComponents.tenantId, params.scopes.tenantId),
217430
217411
  eq(dataComponents.projectId, params.scopes.projectId),
217431
- eq(subAgentDataComponents.graphId, params.scopes.graphId),
217412
+ eq(subAgentDataComponents.agentId, params.scopes.agentId),
217432
217413
  eq(subAgentDataComponents.subAgentId, params.scopes.subAgentId)
217433
217414
  )
217434
217415
  ).orderBy(desc(dataComponents.createdAt));
@@ -217438,7 +217419,7 @@ var associateDataComponentWithAgent = (db) => async (params) => {
217438
217419
  id: nanoid(),
217439
217420
  tenantId: params.scopes.tenantId,
217440
217421
  projectId: params.scopes.projectId,
217441
- graphId: params.scopes.graphId,
217422
+ agentId: params.scopes.agentId,
217442
217423
  subAgentId: params.scopes.subAgentId,
217443
217424
  dataComponentId: params.dataComponentId
217444
217425
  }).returning();
@@ -217449,7 +217430,7 @@ var removeDataComponentFromAgent = (db) => async (params) => {
217449
217430
  and(
217450
217431
  eq(subAgentDataComponents.tenantId, params.scopes.tenantId),
217451
217432
  eq(subAgentDataComponents.projectId, params.scopes.projectId),
217452
- eq(subAgentDataComponents.graphId, params.scopes.graphId),
217433
+ eq(subAgentDataComponents.agentId, params.scopes.agentId),
217453
217434
  eq(subAgentDataComponents.subAgentId, params.scopes.subAgentId),
217454
217435
  eq(subAgentDataComponents.dataComponentId, params.dataComponentId)
217455
217436
  )
@@ -217460,7 +217441,7 @@ var deleteAgentDataComponentRelationByAgent = (db) => async (params) => {
217460
217441
  const result = await db.delete(subAgentDataComponents).where(
217461
217442
  and(
217462
217443
  eq(subAgentDataComponents.tenantId, params.scopes.tenantId),
217463
- eq(subAgentDataComponents.graphId, params.scopes.graphId),
217444
+ eq(subAgentDataComponents.agentId, params.scopes.agentId),
217464
217445
  eq(subAgentDataComponents.subAgentId, params.scopes.subAgentId)
217465
217446
  )
217466
217447
  );
@@ -217483,7 +217464,7 @@ var isDataComponentAssociatedWithAgent = (db) => async (params) => {
217483
217464
  and(
217484
217465
  eq(subAgentDataComponents.tenantId, params.scopes.tenantId),
217485
217466
  eq(subAgentDataComponents.projectId, params.scopes.projectId),
217486
- eq(subAgentDataComponents.graphId, params.scopes.graphId),
217467
+ eq(subAgentDataComponents.agentId, params.scopes.agentId),
217487
217468
  eq(subAgentDataComponents.subAgentId, params.scopes.subAgentId),
217488
217469
  eq(subAgentDataComponents.dataComponentId, params.dataComponentId)
217489
217470
  )
@@ -217533,7 +217514,7 @@ var defaultLogger = {
217533
217514
  error: () => {
217534
217515
  }
217535
217516
  };
217536
- async function applyExecutionLimitsInheritance(db, logger13, scopes, graphData) {
217517
+ async function applyExecutionLimitsInheritance(db, logger13, scopes, agentData) {
217537
217518
  const { tenantId, projectId } = scopes;
217538
217519
  try {
217539
217520
  const project = await db.query.projects.findFirst({
@@ -217551,27 +217532,27 @@ async function applyExecutionLimitsInheritance(db, logger13, scopes, graphData)
217551
217532
  },
217552
217533
  "Found project stopWhen configuration"
217553
217534
  );
217554
- if (!graphData.stopWhen) {
217555
- graphData.stopWhen = {};
217535
+ if (!agentData.stopWhen) {
217536
+ agentData.stopWhen = {};
217556
217537
  }
217557
- if (graphData.stopWhen.transferCountIs === void 0 && projectStopWhen?.transferCountIs !== void 0) {
217558
- graphData.stopWhen.transferCountIs = projectStopWhen.transferCountIs;
217538
+ if (agentData.stopWhen.transferCountIs === void 0 && projectStopWhen?.transferCountIs !== void 0) {
217539
+ agentData.stopWhen.transferCountIs = projectStopWhen.transferCountIs;
217559
217540
  logger13.info(
217560
217541
  {
217561
- graphId: graphData.id,
217542
+ agentId: agentData.id,
217562
217543
  inheritedValue: projectStopWhen.transferCountIs
217563
217544
  },
217564
- "Graph inherited transferCountIs from project"
217545
+ "Agent inherited transferCountIs from project"
217565
217546
  );
217566
217547
  }
217567
- if (graphData.stopWhen.transferCountIs === void 0) {
217568
- graphData.stopWhen.transferCountIs = 10;
217548
+ if (agentData.stopWhen.transferCountIs === void 0) {
217549
+ agentData.stopWhen.transferCountIs = 10;
217569
217550
  logger13.info(
217570
217551
  {
217571
- graphId: graphData.id,
217552
+ agentId: agentData.id,
217572
217553
  defaultValue: 10
217573
217554
  },
217574
- "Graph set to default transferCountIs"
217555
+ "Agent set to default transferCountIs"
217575
217556
  );
217576
217557
  }
217577
217558
  if (projectStopWhen?.stepCountIs !== void 0) {
@@ -217582,8 +217563,8 @@ async function applyExecutionLimitsInheritance(db, logger13, scopes, graphData)
217582
217563
  },
217583
217564
  "Propagating stepCountIs to agents"
217584
217565
  );
217585
- for (const [subAgentId, agentData] of Object.entries(graphData.subAgents)) {
217586
- if (isInternalAgent(agentData)) {
217566
+ for (const [subAgentId, subAgentData] of Object.entries(agentData.subAgents)) {
217567
+ if (isInternalAgent(subAgentData)) {
217587
217568
  const agent = agentData;
217588
217569
  if (!agent.stopWhen) {
217589
217570
  agent.stopWhen = {};
@@ -217611,24 +217592,24 @@ async function applyExecutionLimitsInheritance(db, logger13, scopes, graphData)
217611
217592
  );
217612
217593
  }
217613
217594
  }
217614
- var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes, graphData) => {
217595
+ var createFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes, agentData) => {
217615
217596
  const { tenantId, projectId } = scopes;
217616
- const typed = validateAndTypeGraphData(graphData);
217617
- validateGraphStructure(typed);
217597
+ const typed = validateAndTypeAgentData(agentData);
217598
+ validateAgentStructure(typed);
217618
217599
  await applyExecutionLimitsInheritance(db, logger13, { tenantId, projectId }, typed);
217619
217600
  try {
217620
217601
  logger13.info(
217621
217602
  {},
217622
- "CredentialReferences are project-scoped - skipping credential reference creation in graph"
217603
+ "CredentialReferences are project-scoped - skipping credential reference creation in agent"
217623
217604
  );
217624
- logger13.info({}, "MCP Tools are project-scoped - skipping tool creation in graph");
217625
- let finalGraphId;
217605
+ logger13.info({}, "MCP Tools are project-scoped - skipping tool creation in agent");
217606
+ let finalAgentId;
217626
217607
  try {
217627
- const graphId = typed.id || nanoid();
217628
- logger13.info({ graphId }, "Creating agent graph metadata");
217629
- const agentGraph2 = await upsertAgentGraph(db)({
217608
+ const agentId = typed.id || nanoid();
217609
+ logger13.info({ agentId }, "Creating agent agent metadata");
217610
+ const agent = await upsertAgent(db)({
217630
217611
  data: {
217631
- id: graphId,
217612
+ id: agentId,
217632
217613
  tenantId,
217633
217614
  projectId,
217634
217615
  name: typed.name,
@@ -217638,14 +217619,17 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217638
217619
  // Will be updated later if context config exists
217639
217620
  models: typed.models,
217640
217621
  statusUpdates: typed.statusUpdates,
217641
- graphPrompt: typed.graphPrompt,
217622
+ prompt: typed.prompt,
217642
217623
  stopWhen: typed.stopWhen
217643
217624
  }
217644
217625
  });
217645
- finalGraphId = agentGraph2.id;
217646
- logger13.info({ graphId: finalGraphId }, "Agent graph metadata created successfully");
217626
+ if (!agent?.id) {
217627
+ throw new Error("Failed to create agent: no ID returned");
217628
+ }
217629
+ finalAgentId = agent.id;
217630
+ logger13.info({ agentId: finalAgentId }, "Agent agent metadata created successfully");
217647
217631
  } catch (error) {
217648
- logger13.error({ graphId: typed.id, error }, "Failed to create/update graph metadata");
217632
+ logger13.error({ agentId: typed.id, error }, "Failed to create/update agent metadata");
217649
217633
  throw error;
217650
217634
  }
217651
217635
  let contextConfigId;
@@ -217655,7 +217639,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217655
217639
  const contextConfig2 = await upsertContextConfig(db)({
217656
217640
  data: {
217657
217641
  ...typed.contextConfig,
217658
- graphId: finalGraphId,
217642
+ agentId: finalAgentId,
217659
217643
  tenantId,
217660
217644
  projectId
217661
217645
  }
@@ -217673,12 +217657,12 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217673
217657
  if (contextConfigId) {
217674
217658
  try {
217675
217659
  logger13.info(
217676
- { graphId: finalGraphId, contextConfigId },
217677
- "Updating graph with contextConfigId"
217660
+ { agentId: finalAgentId, contextConfigId },
217661
+ "Updating agent with contextConfigId"
217678
217662
  );
217679
- await upsertAgentGraph(db)({
217663
+ await upsertAgent(db)({
217680
217664
  data: {
217681
- id: finalGraphId,
217665
+ id: finalAgentId,
217682
217666
  tenantId,
217683
217667
  projectId,
217684
217668
  name: typed.name,
@@ -217687,42 +217671,42 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217687
217671
  contextConfigId,
217688
217672
  models: typed.models,
217689
217673
  statusUpdates: typed.statusUpdates,
217690
- graphPrompt: typed.graphPrompt,
217674
+ prompt: typed.prompt,
217691
217675
  stopWhen: typed.stopWhen
217692
217676
  }
217693
217677
  });
217694
217678
  logger13.info(
217695
- { graphId: finalGraphId, contextConfigId },
217696
- "Graph updated with contextConfigId successfully"
217679
+ { agentId: finalAgentId, contextConfigId },
217680
+ "Agent updated with contextConfigId successfully"
217697
217681
  );
217698
217682
  } catch (error) {
217699
217683
  logger13.error(
217700
- { graphId: finalGraphId, contextConfigId, error },
217701
- "Failed to update graph with contextConfigId"
217684
+ { agentId: finalAgentId, contextConfigId, error },
217685
+ "Failed to update agent with contextConfigId"
217702
217686
  );
217703
217687
  throw error;
217704
217688
  }
217705
217689
  }
217706
217690
  logger13.info(
217707
217691
  {},
217708
- "DataComponents are project-scoped - skipping dataComponent creation in graph"
217692
+ "DataComponents are project-scoped - skipping dataComponent creation in agent"
217709
217693
  );
217710
217694
  logger13.info(
217711
217695
  {},
217712
- "ArtifactComponents are project-scoped - skipping artifactComponent creation in graph"
217696
+ "ArtifactComponents are project-scoped - skipping artifactComponent creation in agent"
217713
217697
  );
217714
217698
  if (typed.functions && Object.keys(typed.functions).length > 0) {
217715
217699
  logger13.info(
217716
217700
  {
217717
- graphId: finalGraphId,
217701
+ agentId: finalAgentId,
217718
217702
  functionCount: Object.keys(typed.functions).length
217719
217703
  },
217720
- "Creating functions for graph"
217704
+ "Creating functions for agent"
217721
217705
  );
217722
217706
  const functionPromises = Object.entries(typed.functions).map(
217723
217707
  async ([functionId, functionData]) => {
217724
217708
  try {
217725
- logger13.info({ graphId: finalGraphId, functionId }, "Creating function for graph");
217709
+ logger13.info({ agentId: finalAgentId, functionId }, "Creating function for agent");
217726
217710
  await upsertFunction(db)({
217727
217711
  data: {
217728
217712
  ...functionData,
@@ -217730,11 +217714,11 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217730
217714
  },
217731
217715
  scopes: { tenantId, projectId }
217732
217716
  });
217733
- logger13.info({ graphId: finalGraphId, functionId }, "Function created successfully");
217717
+ logger13.info({ agentId: finalAgentId, functionId }, "Function created successfully");
217734
217718
  } catch (error) {
217735
217719
  logger13.error(
217736
- { graphId: finalGraphId, functionId, error },
217737
- "Failed to create function for graph"
217720
+ { agentId: finalAgentId, functionId, error },
217721
+ "Failed to create function for agent"
217738
217722
  );
217739
217723
  throw error;
217740
217724
  }
@@ -217743,7 +217727,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217743
217727
  await Promise.all(functionPromises);
217744
217728
  logger13.info(
217745
217729
  {
217746
- graphId: finalGraphId,
217730
+ agentId: finalAgentId,
217747
217731
  functionCount: Object.keys(typed.functions).length
217748
217732
  },
217749
217733
  "All functions created successfully"
@@ -217752,33 +217736,33 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217752
217736
  if (typed.functionTools && Object.keys(typed.functionTools).length > 0) {
217753
217737
  logger13.info(
217754
217738
  {
217755
- graphId: finalGraphId,
217739
+ agentId: finalAgentId,
217756
217740
  functionToolCount: Object.keys(typed.functionTools).length
217757
217741
  },
217758
- "Creating function tools for graph"
217742
+ "Creating function tools for agent"
217759
217743
  );
217760
217744
  const functionToolPromises = Object.entries(typed.functionTools).map(
217761
217745
  async ([functionToolId, functionToolData]) => {
217762
217746
  try {
217763
217747
  logger13.info(
217764
- { graphId: finalGraphId, functionToolId },
217765
- "Creating function tool in graph"
217748
+ { agentId: finalAgentId, functionToolId },
217749
+ "Creating function tool in agent"
217766
217750
  );
217767
217751
  await upsertFunctionTool(db)({
217768
217752
  data: {
217769
217753
  ...functionToolData,
217770
217754
  id: functionToolId
217771
217755
  },
217772
- scopes: { tenantId, projectId, graphId: finalGraphId }
217756
+ scopes: { tenantId, projectId, agentId: finalAgentId }
217773
217757
  });
217774
217758
  logger13.info(
217775
- { graphId: finalGraphId, functionToolId },
217759
+ { agentId: finalAgentId, functionToolId },
217776
217760
  "Function tool created successfully"
217777
217761
  );
217778
217762
  } catch (error) {
217779
217763
  logger13.error(
217780
- { graphId: finalGraphId, functionToolId, error },
217781
- "Failed to create function tool in graph"
217764
+ { agentId: finalAgentId, functionToolId, error },
217765
+ "Failed to create function tool in agent"
217782
217766
  );
217783
217767
  throw error;
217784
217768
  }
@@ -217787,14 +217771,14 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217787
217771
  await Promise.all(functionToolPromises);
217788
217772
  logger13.info(
217789
217773
  {
217790
- graphId: finalGraphId,
217774
+ agentId: finalAgentId,
217791
217775
  functionToolCount: Object.keys(typed.functionTools).length
217792
217776
  },
217793
217777
  "All function tools created successfully"
217794
217778
  );
217795
217779
  }
217796
- const internalAgentPromises = Object.entries(typed.subAgents).filter(([_, agentData]) => isInternalAgent(agentData)).map(async ([subAgentId, agentData]) => {
217797
- const internalAgent = agentData;
217780
+ const internalAgentPromises = Object.entries(typed.subAgents).filter(([_, agentData2]) => isInternalAgent(agentData2)).map(async ([subAgentId, agentData2]) => {
217781
+ const internalAgent = agentData2;
217798
217782
  try {
217799
217783
  logger13.info({ subAgentId }, "Processing internal agent");
217800
217784
  await upsertSubAgent(db)({
@@ -217802,7 +217786,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217802
217786
  id: subAgentId,
217803
217787
  tenantId,
217804
217788
  projectId,
217805
- graphId: finalGraphId,
217789
+ agentId: finalAgentId,
217806
217790
  name: internalAgent.name || "",
217807
217791
  description: internalAgent.description || "",
217808
217792
  prompt: internalAgent.prompt || "",
@@ -217819,11 +217803,11 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217819
217803
  });
217820
217804
  await Promise.all(internalAgentPromises);
217821
217805
  const internalAgentCount = Object.entries(typed.subAgents).filter(
217822
- ([_, agentData]) => isInternalAgent(agentData)
217806
+ ([_, agentData2]) => isInternalAgent(agentData2)
217823
217807
  ).length;
217824
217808
  logger13.info({ internalAgentCount }, "All internal agents created/updated successfully");
217825
- const externalAgentPromises = Object.entries(typed.subAgents).filter(([_, agentData]) => isExternalAgent(agentData)).map(async ([subAgentId, agentData]) => {
217826
- const externalAgent = agentData;
217809
+ const externalAgentPromises = Object.entries(typed.subAgents).filter(([_, agentData2]) => isExternalAgent(agentData2)).map(async ([subAgentId, agentData2]) => {
217810
+ const externalAgent = agentData2;
217827
217811
  try {
217828
217812
  logger13.info({ subAgentId }, "Processing external agent");
217829
217813
  await upsertExternalAgent(db)({
@@ -217831,7 +217815,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217831
217815
  id: subAgentId,
217832
217816
  tenantId,
217833
217817
  projectId,
217834
- graphId: finalGraphId,
217818
+ agentId: finalAgentId,
217835
217819
  name: externalAgent.name,
217836
217820
  description: externalAgent.description || "",
217837
217821
  baseUrl: externalAgent.baseUrl,
@@ -217847,32 +217831,32 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217847
217831
  });
217848
217832
  await Promise.all(externalAgentPromises);
217849
217833
  const externalAgentCount = Object.entries(typed.subAgents).filter(
217850
- ([_, agentData]) => isExternalAgent(agentData)
217834
+ ([_, agentData2]) => isExternalAgent(agentData2)
217851
217835
  ).length;
217852
217836
  logger13.info({ externalAgentCount }, "All external agents created/updated successfully");
217853
217837
  if (contextConfigId) {
217854
217838
  try {
217855
217839
  logger13.info(
217856
- { graphId: finalGraphId, contextConfigId },
217857
- "Updating graph with context config"
217840
+ { agentId: finalAgentId, contextConfigId },
217841
+ "Updating agent with context config"
217858
217842
  );
217859
- await updateAgentGraph(db)({
217860
- scopes: { tenantId, projectId, graphId: finalGraphId },
217843
+ await updateAgent(db)({
217844
+ scopes: { tenantId, projectId, agentId: finalAgentId },
217861
217845
  data: { contextConfigId }
217862
217846
  });
217863
- logger13.info({ graphId: finalGraphId }, "Graph updated with context config");
217847
+ logger13.info({ agentId: finalAgentId }, "Agent updated with context config");
217864
217848
  } catch (error) {
217865
217849
  logger13.error(
217866
- { graphId: finalGraphId, error },
217867
- "Failed to update graph with context config"
217850
+ { agentId: finalAgentId, error },
217851
+ "Failed to update agent with context config"
217868
217852
  );
217869
217853
  throw error;
217870
217854
  }
217871
217855
  }
217872
217856
  const agentToolPromises = [];
217873
- for (const [subAgentId, agentData] of Object.entries(typed.subAgents)) {
217874
- if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
217875
- for (const canUseItem of agentData.canUse) {
217857
+ for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
217858
+ if (isInternalAgent(agentData2) && agentData2.canUse && Array.isArray(agentData2.canUse)) {
217859
+ for (const canUseItem of agentData2.canUse) {
217876
217860
  agentToolPromises.push(
217877
217861
  (async () => {
217878
217862
  try {
@@ -217891,7 +217875,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217891
217875
  if (isFunctionTool) {
217892
217876
  logger13.info({ subAgentId, toolId }, "Processing agent-function tool relation");
217893
217877
  await upsertSubAgentFunctionToolRelation(db)({
217894
- scopes: { tenantId, projectId, graphId: finalGraphId },
217878
+ scopes: { tenantId, projectId, agentId: finalAgentId },
217895
217879
  subAgentId,
217896
217880
  functionToolId: toolId,
217897
217881
  relationId: agentToolRelationId
@@ -217903,7 +217887,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217903
217887
  } else {
217904
217888
  logger13.info({ subAgentId, toolId }, "Processing agent-MCP tool relation");
217905
217889
  await upsertSubAgentToolRelation(db)({
217906
- scopes: { tenantId, projectId, graphId: finalGraphId },
217890
+ scopes: { tenantId, projectId, agentId: finalAgentId },
217907
217891
  subAgentId,
217908
217892
  toolId,
217909
217893
  selectedTools: toolSelection || void 0,
@@ -217932,9 +217916,9 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217932
217916
  "All agent-tool relations created"
217933
217917
  );
217934
217918
  const agentDataComponentPromises = [];
217935
- for (const [subAgentId, agentData] of Object.entries(typed.subAgents)) {
217936
- if (isInternalAgent(agentData) && agentData.dataComponents) {
217937
- for (const dataComponentId of agentData.dataComponents) {
217919
+ for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
217920
+ if (isInternalAgent(agentData2) && agentData2.dataComponents) {
217921
+ for (const dataComponentId of agentData2.dataComponents) {
217938
217922
  agentDataComponentPromises.push(
217939
217923
  (async () => {
217940
217924
  try {
@@ -217943,7 +217927,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217943
217927
  "Processing agent-data component relation"
217944
217928
  );
217945
217929
  await upsertAgentDataComponentRelation(db)({
217946
- scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId },
217930
+ scopes: { tenantId, projectId, agentId: finalAgentId, subAgentId },
217947
217931
  dataComponentId
217948
217932
  });
217949
217933
  logger13.info(
@@ -217964,9 +217948,9 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217964
217948
  await Promise.all(agentDataComponentPromises);
217965
217949
  logger13.info({}, "All agent-data component relations created");
217966
217950
  const agentArtifactComponentPromises = [];
217967
- for (const [subAgentId, agentData] of Object.entries(typed.subAgents)) {
217968
- if (isInternalAgent(agentData) && agentData.artifactComponents) {
217969
- for (const artifactComponentId of agentData.artifactComponents) {
217951
+ for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
217952
+ if (isInternalAgent(agentData2) && agentData2.artifactComponents) {
217953
+ for (const artifactComponentId of agentData2.artifactComponents) {
217970
217954
  agentArtifactComponentPromises.push(
217971
217955
  (async () => {
217972
217956
  try {
@@ -217975,7 +217959,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217975
217959
  "Processing agent-artifact component relation"
217976
217960
  );
217977
217961
  await upsertAgentArtifactComponentRelation(db)({
217978
- scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId },
217962
+ scopes: { tenantId, projectId, agentId: finalAgentId, subAgentId },
217979
217963
  artifactComponentId
217980
217964
  });
217981
217965
  logger13.info(
@@ -217996,9 +217980,9 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
217996
217980
  await Promise.all(agentArtifactComponentPromises);
217997
217981
  logger13.info({}, "All agent-artifact component relations created");
217998
217982
  const agentRelationPromises = [];
217999
- for (const [subAgentId, agentData] of Object.entries(typed.subAgents)) {
218000
- if (isInternalAgent(agentData) && agentData.canTransferTo) {
218001
- for (const targetSubAgentId of agentData.canTransferTo) {
217983
+ for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
217984
+ if (isInternalAgent(agentData2) && agentData2.canTransferTo) {
217985
+ for (const targetSubAgentId of agentData2.canTransferTo) {
218002
217986
  agentRelationPromises.push(
218003
217987
  (async () => {
218004
217988
  try {
@@ -218010,7 +217994,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218010
217994
  id: nanoid(),
218011
217995
  tenantId,
218012
217996
  projectId,
218013
- graphId: finalGraphId,
217997
+ agentId: finalAgentId,
218014
217998
  sourceSubAgentId: subAgentId,
218015
217999
  targetSubAgentId,
218016
218000
  relationType: "transfer"
@@ -218029,8 +218013,8 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218029
218013
  );
218030
218014
  }
218031
218015
  }
218032
- if (isInternalAgent(agentData) && agentData.canDelegateTo) {
218033
- for (const targetSubAgentId of agentData.canDelegateTo) {
218016
+ if (isInternalAgent(agentData2) && agentData2.canDelegateTo) {
218017
+ for (const targetSubAgentId of agentData2.canDelegateTo) {
218034
218018
  const targetAgentData = typed.subAgents[targetSubAgentId];
218035
218019
  const isTargetExternal = isExternalAgent(targetAgentData);
218036
218020
  agentRelationPromises.push(
@@ -218044,7 +218028,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218044
218028
  id: nanoid(),
218045
218029
  tenantId,
218046
218030
  projectId,
218047
- graphId: finalGraphId,
218031
+ agentId: finalAgentId,
218048
218032
  sourceSubAgentId: subAgentId,
218049
218033
  targetSubAgentId: isTargetExternal ? void 0 : targetSubAgentId,
218050
218034
  externalSubAgentId: isTargetExternal ? targetSubAgentId : void 0,
@@ -218070,100 +218054,103 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218070
218054
  { agentRelationCount: agentRelationPromises.length },
218071
218055
  "All agent relations created"
218072
218056
  );
218073
- const createdGraph = await getFullGraphDefinition(db)({
218074
- scopes: { tenantId, projectId, graphId: finalGraphId }
218057
+ const createdAgent = await getFullAgentDefinition(db)({
218058
+ scopes: { tenantId, projectId, agentId: finalAgentId }
218075
218059
  });
218076
- if (!createdGraph) {
218077
- throw new Error("Failed to retrieve created graph");
218060
+ if (!createdAgent) {
218061
+ throw new Error("Failed to retrieve created agent");
218078
218062
  }
218079
- logger13.info({ tenantId, graphId: finalGraphId }, "Full graph created successfully");
218080
- return createdGraph;
218063
+ logger13.info({ tenantId, agentId: finalAgentId }, "Full agent created successfully");
218064
+ return createdAgent;
218081
218065
  } catch (error) {
218082
- const errorGraphId = typed.id || "unknown";
218083
- logger13.error({ tenantId, graphId: errorGraphId, error }, "Failed to create full graph");
218066
+ const errorAgentId = typed.id || "unknown";
218067
+ logger13.error({ tenantId, agentId: errorAgentId, error }, "Failed to create full agent");
218084
218068
  throw error;
218085
218069
  }
218086
218070
  };
218087
- var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes, graphData) => {
218071
+ var updateFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes, agentData) => {
218088
218072
  const { tenantId, projectId } = scopes;
218089
- const typedGraphDefinition = validateAndTypeGraphData(graphData);
218090
- if (!typedGraphDefinition.id) {
218091
- throw new Error("Graph ID is required");
218073
+ const typedAgentDefinition = validateAndTypeAgentData(agentData);
218074
+ if (!typedAgentDefinition.id) {
218075
+ throw new Error("Agent ID is required");
218092
218076
  }
218093
218077
  logger13.info(
218094
218078
  {
218095
218079
  tenantId,
218096
- graphId: typedGraphDefinition.id,
218097
- agentCount: Object.keys(typedGraphDefinition.subAgents).length
218080
+ agentId: typedAgentDefinition.id,
218081
+ agentCount: Object.keys(typedAgentDefinition.subAgents).length
218098
218082
  },
218099
- "Updating full graph in database"
218083
+ "Updating full agent in database"
218100
218084
  );
218101
- validateGraphStructure(typedGraphDefinition);
218085
+ validateAgentStructure(typedAgentDefinition);
218102
218086
  await applyExecutionLimitsInheritance(
218103
218087
  db,
218104
218088
  logger13,
218105
218089
  { tenantId, projectId },
218106
- typedGraphDefinition
218090
+ typedAgentDefinition
218107
218091
  );
218108
218092
  try {
218109
- const existingGraph = await getAgentGraphById(db)({
218110
- scopes: { tenantId, projectId, graphId: typedGraphDefinition.id }
218093
+ const existingAgent = await getAgentById(db)({
218094
+ scopes: { tenantId, projectId, agentId: typedAgentDefinition.id }
218111
218095
  });
218112
- if (!existingGraph) {
218096
+ if (!existingAgent) {
218113
218097
  logger13.info(
218114
- { graphId: typedGraphDefinition.id },
218115
- "Graph does not exist, creating new graph"
218098
+ { agentId: typedAgentDefinition.id },
218099
+ "Agent does not exist, creating new agent"
218116
218100
  );
218117
- return createFullGraphServerSide(db, logger13)(scopes, graphData);
218101
+ return createFullAgentServerSide(db, logger13)(scopes, agentData);
218118
218102
  }
218119
- const existingGraphModels = existingGraph.models;
218103
+ const existingAgentModels = existingAgent.models;
218120
218104
  logger13.info(
218121
218105
  {},
218122
- "CredentialReferences are project-scoped - skipping credential reference update in graph"
218106
+ "CredentialReferences are project-scoped - skipping credential reference update in agent"
218123
218107
  );
218124
- logger13.info({}, "MCP Tools are project-scoped - skipping tool creation in graph update");
218125
- let finalGraphId;
218108
+ logger13.info({}, "MCP Tools are project-scoped - skipping tool creation in agent update");
218109
+ let finalAgentId;
218126
218110
  try {
218127
- const graphId = typedGraphDefinition.id || nanoid();
218128
- logger13.info({ graphId }, "Getting/creating agent graph metadata");
218129
- const agentGraph2 = await upsertAgentGraph(db)({
218111
+ const agentId = typedAgentDefinition.id || nanoid();
218112
+ logger13.info({ agentId }, "Getting/creating agent metadata");
218113
+ const agent = await upsertAgent(db)({
218130
218114
  data: {
218131
- id: graphId,
218115
+ id: agentId,
218132
218116
  tenantId,
218133
218117
  projectId,
218134
- name: typedGraphDefinition.name,
218135
- defaultSubAgentId: typedGraphDefinition.defaultSubAgentId,
218136
- description: typedGraphDefinition.description,
218118
+ name: typedAgentDefinition.name,
218119
+ defaultSubAgentId: typedAgentDefinition.defaultSubAgentId,
218120
+ description: typedAgentDefinition.description,
218137
218121
  contextConfigId: void 0,
218138
218122
  // Will be updated later if context config exists
218139
- models: typedGraphDefinition.models,
218140
- statusUpdates: typedGraphDefinition.statusUpdates,
218141
- graphPrompt: typedGraphDefinition.graphPrompt,
218142
- stopWhen: typedGraphDefinition.stopWhen
218123
+ models: typedAgentDefinition.models,
218124
+ statusUpdates: typedAgentDefinition.statusUpdates,
218125
+ prompt: typedAgentDefinition.prompt,
218126
+ stopWhen: typedAgentDefinition.stopWhen
218143
218127
  }
218144
218128
  });
218145
- finalGraphId = agentGraph2.id;
218146
- logger13.info({ graphId: finalGraphId }, "Agent graph metadata ready");
218129
+ if (!agent?.id) {
218130
+ throw new Error("Failed to upsert agent: no ID returned");
218131
+ }
218132
+ finalAgentId = agent.id;
218133
+ logger13.info({ agentId: finalAgentId }, "Agent agent metadata ready");
218147
218134
  } catch (error) {
218148
218135
  logger13.error(
218149
- { graphId: typedGraphDefinition.id, error },
218150
- "Failed to get/update graph metadata"
218136
+ { agentId: typedAgentDefinition.id, error },
218137
+ "Failed to get/update agent metadata"
218151
218138
  );
218152
218139
  throw error;
218153
218140
  }
218154
218141
  let contextConfigId;
218155
- if (typedGraphDefinition.contextConfig) {
218142
+ if (typedAgentDefinition.contextConfig) {
218156
218143
  logger13.info(
218157
- { contextConfigId: typedGraphDefinition.contextConfig?.id },
218144
+ { contextConfigId: typedAgentDefinition.contextConfig?.id },
218158
218145
  " context config exists"
218159
218146
  );
218160
218147
  }
218161
- if (typedGraphDefinition.contextConfig) {
218148
+ if (typedAgentDefinition.contextConfig) {
218162
218149
  try {
218163
218150
  const contextConfig2 = await upsertContextConfig(db)({
218164
218151
  data: {
218165
- ...typedGraphDefinition.contextConfig,
218166
- graphId: finalGraphId,
218152
+ ...typedAgentDefinition.contextConfig,
218153
+ agentId: finalAgentId,
218167
218154
  tenantId,
218168
218155
  projectId
218169
218156
  }
@@ -218172,7 +218159,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218172
218159
  logger13.info({ contextConfigId }, "Context config processed successfully");
218173
218160
  } catch (error) {
218174
218161
  logger13.error(
218175
- { contextConfigId: typedGraphDefinition.contextConfig.id, error },
218162
+ { contextConfigId: typedAgentDefinition.contextConfig.id, error },
218176
218163
  "Failed to create/update context config"
218177
218164
  );
218178
218165
  throw error;
@@ -218181,53 +218168,53 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218181
218168
  if (contextConfigId) {
218182
218169
  try {
218183
218170
  logger13.info(
218184
- { graphId: finalGraphId, contextConfigId },
218185
- "Updating graph with contextConfigId"
218171
+ { agentId: finalAgentId, contextConfigId },
218172
+ "Updating agent with contextConfigId"
218186
218173
  );
218187
- await upsertAgentGraph(db)({
218174
+ await upsertAgent(db)({
218188
218175
  data: {
218189
- id: finalGraphId,
218176
+ id: finalAgentId,
218190
218177
  tenantId,
218191
218178
  projectId,
218192
- name: typedGraphDefinition.name,
218193
- defaultSubAgentId: typedGraphDefinition.defaultSubAgentId,
218194
- description: typedGraphDefinition.description,
218179
+ name: typedAgentDefinition.name,
218180
+ defaultSubAgentId: typedAgentDefinition.defaultSubAgentId,
218181
+ description: typedAgentDefinition.description,
218195
218182
  contextConfigId,
218196
- models: typedGraphDefinition.models,
218197
- statusUpdates: typedGraphDefinition.statusUpdates,
218198
- graphPrompt: typedGraphDefinition.graphPrompt,
218199
- stopWhen: typedGraphDefinition.stopWhen
218183
+ models: typedAgentDefinition.models,
218184
+ statusUpdates: typedAgentDefinition.statusUpdates,
218185
+ prompt: typedAgentDefinition.prompt,
218186
+ stopWhen: typedAgentDefinition.stopWhen
218200
218187
  }
218201
218188
  });
218202
218189
  logger13.info(
218203
- { graphId: finalGraphId, contextConfigId },
218204
- "Graph updated with contextConfigId successfully"
218190
+ { agentId: finalAgentId, contextConfigId },
218191
+ "Agent updated with contextConfigId successfully"
218205
218192
  );
218206
218193
  } catch (error) {
218207
218194
  logger13.error(
218208
- { graphId: finalGraphId, contextConfigId, error },
218209
- "Failed to update graph with contextConfigId"
218195
+ { agentId: finalAgentId, contextConfigId, error },
218196
+ "Failed to update agent with contextConfigId"
218210
218197
  );
218211
218198
  throw error;
218212
218199
  }
218213
218200
  }
218214
- logger13.info({}, "DataComponents are project-scoped - skipping dataComponent update in graph");
218201
+ logger13.info({}, "DataComponents are project-scoped - skipping dataComponent update in agent");
218215
218202
  logger13.info(
218216
218203
  {},
218217
- "ArtifactComponents are project-scoped - skipping artifactComponent update in graph"
218204
+ "ArtifactComponents are project-scoped - skipping artifactComponent update in agent"
218218
218205
  );
218219
- if (typedGraphDefinition.functions && Object.keys(typedGraphDefinition.functions).length > 0) {
218206
+ if (typedAgentDefinition.functions && Object.keys(typedAgentDefinition.functions).length > 0) {
218220
218207
  logger13.info(
218221
218208
  {
218222
- graphId: finalGraphId,
218223
- functionCount: Object.keys(typedGraphDefinition.functions).length
218209
+ agentId: finalAgentId,
218210
+ functionCount: Object.keys(typedAgentDefinition.functions).length
218224
218211
  },
218225
- "Updating functions for graph"
218212
+ "Updating functions for agent"
218226
218213
  );
218227
- const functionPromises = Object.entries(typedGraphDefinition.functions).map(
218214
+ const functionPromises = Object.entries(typedAgentDefinition.functions).map(
218228
218215
  async ([functionId, functionData]) => {
218229
218216
  try {
218230
- logger13.info({ graphId: finalGraphId, functionId }, "Updating function for graph");
218217
+ logger13.info({ agentId: finalAgentId, functionId }, "Updating function for agent");
218231
218218
  await upsertFunction(db)({
218232
218219
  data: {
218233
218220
  ...functionData,
@@ -218235,11 +218222,11 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218235
218222
  },
218236
218223
  scopes: { tenantId, projectId }
218237
218224
  });
218238
- logger13.info({ graphId: finalGraphId, functionId }, "Function updated successfully");
218225
+ logger13.info({ agentId: finalAgentId, functionId }, "Function updated successfully");
218239
218226
  } catch (error) {
218240
218227
  logger13.error(
218241
- { graphId: finalGraphId, functionId, error },
218242
- "Failed to update function for graph"
218228
+ { agentId: finalAgentId, functionId, error },
218229
+ "Failed to update function for agent"
218243
218230
  );
218244
218231
  throw error;
218245
218232
  }
@@ -218248,42 +218235,42 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218248
218235
  await Promise.all(functionPromises);
218249
218236
  logger13.info(
218250
218237
  {
218251
- graphId: finalGraphId,
218252
- functionCount: Object.keys(typedGraphDefinition.functions).length
218238
+ agentId: finalAgentId,
218239
+ functionCount: Object.keys(typedAgentDefinition.functions).length
218253
218240
  },
218254
218241
  "All functions updated successfully"
218255
218242
  );
218256
218243
  }
218257
- if (typedGraphDefinition.functionTools && Object.keys(typedGraphDefinition.functionTools).length > 0) {
218244
+ if (typedAgentDefinition.functionTools && Object.keys(typedAgentDefinition.functionTools).length > 0) {
218258
218245
  logger13.info(
218259
218246
  {
218260
- graphId: finalGraphId,
218261
- functionToolCount: Object.keys(typedGraphDefinition.functionTools).length
218247
+ agentId: finalAgentId,
218248
+ functionToolCount: Object.keys(typedAgentDefinition.functionTools).length
218262
218249
  },
218263
- "Updating function tools for graph"
218250
+ "Updating function tools for agent"
218264
218251
  );
218265
- const functionToolPromises = Object.entries(typedGraphDefinition.functionTools).map(
218252
+ const functionToolPromises = Object.entries(typedAgentDefinition.functionTools).map(
218266
218253
  async ([functionToolId, functionToolData]) => {
218267
218254
  try {
218268
218255
  logger13.info(
218269
- { graphId: finalGraphId, functionToolId },
218270
- "Updating function tool in graph"
218256
+ { agentId: finalAgentId, functionToolId },
218257
+ "Updating function tool in agent"
218271
218258
  );
218272
218259
  await upsertFunctionTool(db)({
218273
218260
  data: {
218274
218261
  ...functionToolData,
218275
218262
  id: functionToolId
218276
218263
  },
218277
- scopes: { tenantId, projectId, graphId: finalGraphId }
218264
+ scopes: { tenantId, projectId, agentId: finalAgentId }
218278
218265
  });
218279
218266
  logger13.info(
218280
- { graphId: finalGraphId, functionToolId },
218267
+ { agentId: finalAgentId, functionToolId },
218281
218268
  "Function tool updated successfully"
218282
218269
  );
218283
218270
  } catch (error) {
218284
218271
  logger13.error(
218285
- { graphId: finalGraphId, functionToolId, error },
218286
- "Failed to update function tool in graph"
218272
+ { agentId: finalAgentId, functionToolId, error },
218273
+ "Failed to update function tool in agent"
218287
218274
  );
218288
218275
  throw error;
218289
218276
  }
@@ -218292,17 +218279,17 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218292
218279
  await Promise.all(functionToolPromises);
218293
218280
  logger13.info(
218294
218281
  {
218295
- graphId: finalGraphId,
218296
- functionToolCount: Object.keys(typedGraphDefinition.functionTools).length
218282
+ agentId: finalAgentId,
218283
+ functionToolCount: Object.keys(typedAgentDefinition.functionTools).length
218297
218284
  },
218298
218285
  "All function tools updated successfully"
218299
218286
  );
218300
218287
  }
218301
- const internalAgentPromises = Object.entries(typedGraphDefinition.subAgents).filter(([_, agentData]) => isInternalAgent(agentData)).map(async ([subAgentId, agentData]) => {
218302
- const internalAgent = agentData;
218303
- let existingAgent = null;
218288
+ const internalAgentPromises = Object.entries(typedAgentDefinition.subAgents).filter(([_, agentData2]) => isInternalAgent(agentData2)).map(async ([subAgentId, agentData2]) => {
218289
+ const internalAgent = agentData2;
218290
+ let existingSubAgent = null;
218304
218291
  try {
218305
- existingAgent = await db.query.subAgents.findFirst({
218292
+ existingSubAgent = await db.query.subAgents.findFirst({
218306
218293
  where: and(
218307
218294
  eq(subAgents.id, subAgentId),
218308
218295
  eq(subAgents.tenantId, tenantId),
@@ -218315,25 +218302,25 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218315
218302
  } catch (_error) {
218316
218303
  }
218317
218304
  let finalModelSettings = internalAgent.models === void 0 ? void 0 : internalAgent.models;
218318
- if (existingAgent?.models && typedGraphDefinition.models) {
218319
- const agentModels = existingAgent.models;
218320
- const graphModels = typedGraphDefinition.models;
218305
+ if (existingSubAgent?.models && typedAgentDefinition.models) {
218306
+ const subAgentModels = existingSubAgent.models;
218307
+ const agentModels = typedAgentDefinition.models;
218321
218308
  const modelTypes = ["base", "structuredOutput", "summarizer"];
218322
218309
  const cascadedModels = { ...finalModelSettings };
218323
218310
  for (const modelType of modelTypes) {
218324
- if (agentModels[modelType]?.model && existingGraphModels?.[modelType]?.model && agentModels[modelType].model === existingGraphModels[modelType].model && graphModels[modelType] && // Model name changed
218325
- (graphModels[modelType].model !== existingGraphModels[modelType].model || // OR providerOptions changed
218326
- JSON.stringify(graphModels[modelType].providerOptions) !== JSON.stringify(existingGraphModels[modelType].providerOptions))) {
218327
- cascadedModels[modelType] = graphModels[modelType];
218311
+ if (subAgentModels[modelType]?.model && existingAgentModels?.[modelType]?.model && subAgentModels[modelType].model === existingAgentModels[modelType].model && agentModels[modelType] && // Model name changed
218312
+ (agentModels[modelType].model !== existingAgentModels[modelType]?.model || // OR providerOptions changed
218313
+ JSON.stringify(agentModels[modelType].providerOptions) !== JSON.stringify(existingAgentModels[modelType]?.providerOptions))) {
218314
+ cascadedModels[modelType] = agentModels[modelType];
218328
218315
  logger13.info(
218329
218316
  {
218330
218317
  subAgentId,
218331
218318
  modelType,
218332
- oldModel: agentModels[modelType].model,
218333
- newModel: graphModels[modelType].model,
218334
- hasProviderOptions: !!graphModels[modelType].providerOptions
218319
+ oldModel: existingAgentModels[modelType]?.model,
218320
+ newModel: agentModels[modelType].model,
218321
+ hasProviderOptions: !!agentModels[modelType].providerOptions
218335
218322
  },
218336
- "Cascading model change from graph to agent"
218323
+ "Cascading model change from parent agent to subAgent"
218337
218324
  );
218338
218325
  }
218339
218326
  }
@@ -218346,7 +218333,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218346
218333
  id: subAgentId,
218347
218334
  tenantId,
218348
218335
  projectId,
218349
- graphId: finalGraphId,
218336
+ agentId: finalAgentId,
218350
218337
  name: internalAgent.name || "",
218351
218338
  description: internalAgent.description || "",
218352
218339
  prompt: internalAgent.prompt || "",
@@ -218362,12 +218349,12 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218362
218349
  }
218363
218350
  });
218364
218351
  await Promise.all(internalAgentPromises);
218365
- const internalAgentCount = Object.entries(typedGraphDefinition.subAgents).filter(
218366
- ([_, agentData]) => isInternalAgent(agentData)
218352
+ const internalAgentCount = Object.entries(typedAgentDefinition.subAgents).filter(
218353
+ ([_, agentData2]) => isInternalAgent(agentData2)
218367
218354
  ).length;
218368
218355
  logger13.info({ internalAgentCount }, "All internal agents created/updated successfully");
218369
- const externalAgentPromises = Object.entries(typedGraphDefinition.subAgents).filter(([_, agentData]) => isExternalAgent(agentData)).map(async ([subAgentId, agentData]) => {
218370
- const externalAgent = agentData;
218356
+ const externalAgentPromises = Object.entries(typedAgentDefinition.subAgents).filter(([_, agentData2]) => isExternalAgent(agentData2)).map(async ([subAgentId, agentData2]) => {
218357
+ const externalAgent = agentData2;
218371
218358
  try {
218372
218359
  logger13.info({ subAgentId }, "Processing external agent");
218373
218360
  await upsertExternalAgent(db)({
@@ -218375,7 +218362,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218375
218362
  id: subAgentId,
218376
218363
  tenantId,
218377
218364
  projectId,
218378
- graphId: finalGraphId,
218365
+ agentId: finalAgentId,
218379
218366
  name: externalAgent.name,
218380
218367
  description: externalAgent.description || "",
218381
218368
  baseUrl: externalAgent.baseUrl,
@@ -218390,23 +218377,23 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218390
218377
  }
218391
218378
  });
218392
218379
  await Promise.all(externalAgentPromises);
218393
- const externalAgentCount = Object.entries(typedGraphDefinition.subAgents).filter(
218394
- ([_, agentData]) => isExternalAgent(agentData)
218380
+ const externalAgentCount = Object.entries(typedAgentDefinition.subAgents).filter(
218381
+ ([_, agentData2]) => isExternalAgent(agentData2)
218395
218382
  ).length;
218396
218383
  logger13.info({ externalAgentCount }, "All external agents created/updated successfully");
218397
- const incomingAgentIds = new Set(Object.keys(typedGraphDefinition.subAgents));
218384
+ const incomingAgentIds = new Set(Object.keys(typedAgentDefinition.subAgents));
218398
218385
  const existingInternalAgents = await listSubAgents(db)({
218399
- scopes: { tenantId, projectId, graphId: finalGraphId }
218386
+ scopes: { tenantId, projectId, agentId: finalAgentId }
218400
218387
  });
218401
218388
  const existingExternalAgents = await listExternalAgents(db)({
218402
- scopes: { tenantId, projectId, graphId: finalGraphId }
218389
+ scopes: { tenantId, projectId, agentId: finalAgentId }
218403
218390
  });
218404
218391
  let deletedInternalCount = 0;
218405
218392
  for (const agent of existingInternalAgents) {
218406
218393
  if (!incomingAgentIds.has(agent.id)) {
218407
218394
  try {
218408
218395
  await deleteSubAgent(db)({
218409
- scopes: { tenantId, projectId, graphId: finalGraphId },
218396
+ scopes: { tenantId, projectId, agentId: finalAgentId },
218410
218397
  subAgentId: agent.id
218411
218398
  });
218412
218399
  deletedInternalCount++;
@@ -218424,7 +218411,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218424
218411
  if (!incomingAgentIds.has(agent.id)) {
218425
218412
  try {
218426
218413
  await deleteExternalAgent(db)({
218427
- scopes: { tenantId, projectId, graphId: finalGraphId },
218414
+ scopes: { tenantId, projectId, agentId: finalAgentId },
218428
218415
  subAgentId: agent.id
218429
218416
  });
218430
218417
  deletedExternalCount++;
@@ -218444,34 +218431,34 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218444
218431
  deletedExternalCount,
218445
218432
  totalDeleted: deletedInternalCount + deletedExternalCount
218446
218433
  },
218447
- "Deleted orphaned agents from graph"
218434
+ "Deleted orphaned agents from agent"
218448
218435
  );
218449
218436
  }
218450
- await updateAgentGraph(db)({
218451
- scopes: { tenantId, projectId, graphId: typedGraphDefinition.id },
218437
+ await updateAgent(db)({
218438
+ scopes: { tenantId, projectId, agentId: typedAgentDefinition.id },
218452
218439
  data: {
218453
- name: typedGraphDefinition.name,
218454
- defaultSubAgentId: typedGraphDefinition.defaultSubAgentId,
218455
- description: typedGraphDefinition.description,
218440
+ name: typedAgentDefinition.name,
218441
+ defaultSubAgentId: typedAgentDefinition.defaultSubAgentId,
218442
+ description: typedAgentDefinition.description,
218456
218443
  contextConfigId,
218457
- models: typedGraphDefinition.models,
218458
- statusUpdates: typedGraphDefinition.statusUpdates,
218459
- graphPrompt: typedGraphDefinition.graphPrompt,
218460
- stopWhen: typedGraphDefinition.stopWhen
218444
+ models: typedAgentDefinition.models,
218445
+ statusUpdates: typedAgentDefinition.statusUpdates,
218446
+ prompt: typedAgentDefinition.prompt,
218447
+ stopWhen: typedAgentDefinition.stopWhen
218461
218448
  }
218462
218449
  });
218463
- logger13.info({ graphId: typedGraphDefinition.id }, "Graph metadata updated");
218450
+ logger13.info({ agentId: typedAgentDefinition.id }, "Agent metadata updated");
218464
218451
  const incomingRelationshipIds = /* @__PURE__ */ new Set();
218465
- for (const [_subAgentId, agentData] of Object.entries(typedGraphDefinition.subAgents)) {
218466
- if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
218467
- for (const canUseItem of agentData.canUse) {
218452
+ for (const [_subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
218453
+ if (isInternalAgent(agentData2) && agentData2.canUse && Array.isArray(agentData2.canUse)) {
218454
+ for (const canUseItem of agentData2.canUse) {
218468
218455
  if (canUseItem.agentToolRelationId) {
218469
218456
  incomingRelationshipIds.add(canUseItem.agentToolRelationId);
218470
218457
  }
218471
218458
  }
218472
218459
  }
218473
218460
  }
218474
- for (const subAgentId of Object.keys(typedGraphDefinition.subAgents)) {
218461
+ for (const subAgentId of Object.keys(typedAgentDefinition.subAgents)) {
218475
218462
  try {
218476
218463
  let deletedCount = 0;
218477
218464
  if (incomingRelationshipIds.size === 0) {
@@ -218479,7 +218466,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218479
218466
  and(
218480
218467
  eq(subAgentToolRelations.tenantId, tenantId),
218481
218468
  eq(subAgentToolRelations.projectId, projectId),
218482
- eq(subAgentToolRelations.graphId, finalGraphId),
218469
+ eq(subAgentToolRelations.agentId, finalAgentId),
218483
218470
  eq(subAgentToolRelations.subAgentId, subAgentId)
218484
218471
  )
218485
218472
  );
@@ -218489,7 +218476,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218489
218476
  and(
218490
218477
  eq(subAgentToolRelations.tenantId, tenantId),
218491
218478
  eq(subAgentToolRelations.projectId, projectId),
218492
- eq(subAgentToolRelations.graphId, finalGraphId),
218479
+ eq(subAgentToolRelations.agentId, finalAgentId),
218493
218480
  eq(subAgentToolRelations.subAgentId, subAgentId),
218494
218481
  not(inArray(subAgentToolRelations.id, Array.from(incomingRelationshipIds)))
218495
218482
  )
@@ -218504,18 +218491,18 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218504
218491
  }
218505
218492
  }
218506
218493
  const agentToolPromises = [];
218507
- for (const [subAgentId, agentData] of Object.entries(typedGraphDefinition.subAgents)) {
218508
- if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
218509
- for (const canUseItem of agentData.canUse) {
218494
+ for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
218495
+ if (isInternalAgent(agentData2) && agentData2.canUse && Array.isArray(agentData2.canUse)) {
218496
+ for (const canUseItem of agentData2.canUse) {
218510
218497
  agentToolPromises.push(
218511
218498
  (async () => {
218512
218499
  try {
218513
218500
  const { toolId, toolSelection, headers: headers2, agentToolRelationId } = canUseItem;
218514
- const isFunctionTool = typedGraphDefinition.functionTools && toolId in typedGraphDefinition.functionTools;
218501
+ const isFunctionTool = typedAgentDefinition.functionTools && toolId in typedAgentDefinition.functionTools;
218515
218502
  if (isFunctionTool) {
218516
218503
  logger13.info({ subAgentId, toolId }, "Processing agent-function tool relation");
218517
218504
  await upsertSubAgentFunctionToolRelation(db)({
218518
- scopes: { tenantId, projectId, graphId: finalGraphId },
218505
+ scopes: { tenantId, projectId, agentId: finalAgentId },
218519
218506
  subAgentId,
218520
218507
  functionToolId: toolId,
218521
218508
  relationId: agentToolRelationId
@@ -218527,7 +218514,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218527
218514
  } else {
218528
218515
  logger13.info({ subAgentId, toolId }, "Processing agent-MCP tool relation");
218529
218516
  await upsertSubAgentToolRelation(db)({
218530
- scopes: { tenantId, projectId, graphId: finalGraphId },
218517
+ scopes: { tenantId, projectId, agentId: finalAgentId },
218531
218518
  subAgentId,
218532
218519
  toolId,
218533
218520
  selectedTools: toolSelection || void 0,
@@ -218560,20 +218547,20 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218560
218547
  { agentToolPromisesCount: agentToolPromises.length },
218561
218548
  "All agent-tool relations updated"
218562
218549
  );
218563
- for (const subAgentId of Object.keys(typedGraphDefinition.subAgents)) {
218550
+ for (const subAgentId of Object.keys(typedAgentDefinition.subAgents)) {
218564
218551
  await deleteAgentDataComponentRelationByAgent(db)({
218565
- scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId }
218552
+ scopes: { tenantId, projectId, agentId: finalAgentId, subAgentId }
218566
218553
  });
218567
218554
  }
218568
218555
  const agentDataComponentPromises = [];
218569
- for (const [subAgentId, agentData] of Object.entries(typedGraphDefinition.subAgents)) {
218570
- if (isInternalAgent(agentData) && agentData.dataComponents) {
218571
- for (const dataComponentId of agentData.dataComponents) {
218556
+ for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
218557
+ if (isInternalAgent(agentData2) && agentData2.dataComponents) {
218558
+ for (const dataComponentId of agentData2.dataComponents) {
218572
218559
  agentDataComponentPromises.push(
218573
218560
  (async () => {
218574
218561
  try {
218575
218562
  await associateDataComponentWithAgent(db)({
218576
- scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId },
218563
+ scopes: { tenantId, projectId, agentId: finalAgentId, subAgentId },
218577
218564
  dataComponentId
218578
218565
  });
218579
218566
  logger13.info(
@@ -218596,20 +218583,20 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218596
218583
  { agentDataComponentPromisesCount: agentDataComponentPromises.length },
218597
218584
  "All agent-dataComponent relations updated"
218598
218585
  );
218599
- for (const subAgentId of Object.keys(typedGraphDefinition.subAgents)) {
218586
+ for (const subAgentId of Object.keys(typedAgentDefinition.subAgents)) {
218600
218587
  await deleteAgentArtifactComponentRelationByAgent(db)({
218601
- scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId }
218588
+ scopes: { tenantId, projectId, agentId: finalAgentId, subAgentId }
218602
218589
  });
218603
218590
  }
218604
218591
  const agentArtifactComponentPromises = [];
218605
- for (const [subAgentId, agentData] of Object.entries(typedGraphDefinition.subAgents)) {
218606
- if (isInternalAgent(agentData) && agentData.artifactComponents) {
218607
- for (const artifactComponentId of agentData.artifactComponents) {
218592
+ for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
218593
+ if (isInternalAgent(agentData2) && agentData2.artifactComponents) {
218594
+ for (const artifactComponentId of agentData2.artifactComponents) {
218608
218595
  agentArtifactComponentPromises.push(
218609
218596
  (async () => {
218610
218597
  try {
218611
218598
  await associateArtifactComponentWithAgent(db)({
218612
- scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId },
218599
+ scopes: { tenantId, projectId, agentId: finalAgentId, subAgentId },
218613
218600
  artifactComponentId
218614
218601
  });
218615
218602
  logger13.info(
@@ -218632,22 +218619,22 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218632
218619
  { agentArtifactComponentPromisesCount: agentArtifactComponentPromises.length },
218633
218620
  "All agent-artifactComponent relations updated"
218634
218621
  );
218635
- await deleteAgentRelationsByGraph(db)({
218636
- scopes: { tenantId, projectId, graphId: typedGraphDefinition.id }
218622
+ await deleteAgentRelationsByAgent(db)({
218623
+ scopes: { tenantId, projectId, agentId: typedAgentDefinition.id }
218637
218624
  });
218638
218625
  const agentRelationPromises = [];
218639
- for (const [subAgentId, agentData] of Object.entries(typedGraphDefinition.subAgents)) {
218640
- if (isInternalAgent(agentData) && agentData.canTransferTo) {
218641
- for (const targetSubAgentId of agentData.canTransferTo) {
218626
+ for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
218627
+ if (isInternalAgent(agentData2) && agentData2.canTransferTo) {
218628
+ for (const targetSubAgentId of agentData2.canTransferTo) {
218642
218629
  agentRelationPromises.push(
218643
218630
  (async () => {
218644
218631
  try {
218645
- const targetAgentData = typedGraphDefinition.subAgents[targetSubAgentId];
218632
+ const targetAgentData = typedAgentDefinition.subAgents[targetSubAgentId];
218646
218633
  const isTargetExternal = isExternalAgent(targetAgentData);
218647
218634
  const targetField = isTargetExternal ? "externalSubAgentId" : "targetSubAgentId";
218648
218635
  const relationData = {
218649
218636
  id: nanoid(),
218650
- graphId: typedGraphDefinition.id || "",
218637
+ agentId: typedAgentDefinition.id || "",
218651
218638
  sourceSubAgentId: subAgentId,
218652
218639
  relationType: "transfer",
218653
218640
  [targetField]: targetSubAgentId
@@ -218671,9 +218658,9 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218671
218658
  );
218672
218659
  }
218673
218660
  }
218674
- if (isInternalAgent(agentData) && agentData.canDelegateTo) {
218675
- for (const targetSubAgentId of agentData.canDelegateTo) {
218676
- const targetAgentData = typedGraphDefinition.subAgents[targetSubAgentId];
218661
+ if (isInternalAgent(agentData2) && agentData2.canDelegateTo) {
218662
+ for (const targetSubAgentId of agentData2.canDelegateTo) {
218663
+ const targetAgentData = typedAgentDefinition.subAgents[targetSubAgentId];
218677
218664
  const isTargetExternal = isExternalAgent(targetAgentData);
218678
218665
  const targetField = isTargetExternal ? "externalSubAgentId" : "targetSubAgentId";
218679
218666
  agentRelationPromises.push(
@@ -218681,7 +218668,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218681
218668
  try {
218682
218669
  const relationData = {
218683
218670
  id: nanoid(),
218684
- graphId: typedGraphDefinition.id || "",
218671
+ agentId: typedAgentDefinition.id || "",
218685
218672
  sourceSubAgentId: subAgentId,
218686
218673
  relationType: "delegate",
218687
218674
  [targetField]: targetSubAgentId
@@ -218708,93 +218695,93 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
218708
218695
  { agentRelationPromisesCount: agentRelationPromises.length },
218709
218696
  "All agent relations updated"
218710
218697
  );
218711
- const updatedGraph = await getFullGraphDefinition(db)({
218712
- scopes: { tenantId, projectId, graphId: typedGraphDefinition.id }
218698
+ const updatedAgent = await getFullAgentDefinition(db)({
218699
+ scopes: { tenantId, projectId, agentId: typedAgentDefinition.id }
218713
218700
  });
218714
- if (!updatedGraph) {
218715
- throw new Error("Failed to retrieve updated graph");
218701
+ if (!updatedAgent) {
218702
+ throw new Error("Failed to retrieve updated agent");
218716
218703
  }
218717
- logger13.info({ graphId: typedGraphDefinition.id }, "Full graph updated successfully");
218718
- return updatedGraph;
218704
+ logger13.info({ agentId: typedAgentDefinition.id }, "Full agent updated successfully");
218705
+ return updatedAgent;
218719
218706
  } catch (error) {
218720
- logger13.error({ graphId: typedGraphDefinition.id, error }, "Failed to update full graph");
218707
+ logger13.error({ agentId: typedAgentDefinition.id, error }, "Failed to update full agent");
218721
218708
  throw error;
218722
218709
  }
218723
218710
  };
218724
- var getFullGraph = (db, logger13 = defaultLogger) => async (params) => {
218711
+ var getFullAgent = (db, logger13 = defaultLogger) => async (params) => {
218725
218712
  const { scopes } = params;
218726
218713
  const { tenantId, projectId } = scopes;
218727
- logger13.info({ tenantId, graphId: scopes.graphId }, "Retrieving full graph definition");
218714
+ logger13.info({ tenantId, agentId: scopes.agentId }, "Retrieving full agent definition");
218728
218715
  try {
218729
- const graph = await getFullGraphDefinition(db)({
218730
- scopes: { tenantId, projectId, graphId: scopes.graphId }
218716
+ const agent = await getFullAgentDefinition(db)({
218717
+ scopes: { tenantId, projectId, agentId: scopes.agentId }
218731
218718
  });
218732
- if (!graph) {
218733
- logger13.info({ tenantId, graphId: scopes.graphId }, "Graph not found");
218719
+ if (!agent) {
218720
+ logger13.info({ tenantId, agentId: scopes.agentId }, "Agent not found");
218734
218721
  return null;
218735
218722
  }
218736
218723
  logger13.info(
218737
218724
  {
218738
218725
  tenantId,
218739
- graphId: scopes.graphId,
218740
- agentCount: Object.keys(graph.subAgents).length
218726
+ agentId: scopes.agentId,
218727
+ agentCount: Object.keys(agent.subAgents).length
218741
218728
  },
218742
- "Full graph retrieved successfully"
218729
+ "Full agent retrieved successfully"
218743
218730
  );
218744
- return graph;
218731
+ return agent;
218745
218732
  } catch (error) {
218746
218733
  logger13.error(
218747
218734
  {
218748
218735
  tenantId,
218749
- graphId: scopes.graphId,
218736
+ agentId: scopes.agentId,
218750
218737
  error: error instanceof Error ? error.message : "Unknown error"
218751
218738
  },
218752
- "Failed to retrieve full graph"
218739
+ "Failed to retrieve full agent"
218753
218740
  );
218754
218741
  throw error;
218755
218742
  }
218756
218743
  };
218757
- var deleteFullGraph = (db, logger13 = defaultLogger) => async (params) => {
218758
- const { tenantId, projectId, graphId } = params.scopes;
218759
- logger13.info({ tenantId, graphId }, "Deleting full graph and related entities");
218744
+ var deleteFullAgent = (db, logger13 = defaultLogger) => async (params) => {
218745
+ const { tenantId, projectId, agentId } = params.scopes;
218746
+ logger13.info({ tenantId, agentId }, "Deleting full agent and related entities");
218760
218747
  try {
218761
- const graph = await getFullGraphDefinition(db)({
218762
- scopes: { tenantId, projectId, graphId }
218748
+ const agent = await getFullAgentDefinition(db)({
218749
+ scopes: { tenantId, projectId, agentId }
218763
218750
  });
218764
- if (!graph) {
218765
- logger13.info({ tenantId, graphId }, "Graph not found for deletion");
218751
+ if (!agent) {
218752
+ logger13.info({ tenantId, agentId }, "Agent not found for deletion");
218766
218753
  return false;
218767
218754
  }
218768
- await deleteAgentRelationsByGraph(db)({
218769
- scopes: { tenantId, projectId, graphId }
218755
+ await deleteAgentRelationsByAgent(db)({
218756
+ scopes: { tenantId, projectId, agentId }
218770
218757
  });
218771
- logger13.info({ tenantId, graphId }, "Agent relations deleted");
218772
- const subAgentIds = Object.keys(graph.subAgents);
218758
+ logger13.info({ tenantId, agentId }, "Agent relations deleted");
218759
+ const subAgentIds = Object.keys(agent.subAgents);
218773
218760
  if (subAgentIds.length > 0) {
218774
218761
  for (const subAgentId of subAgentIds) {
218775
218762
  await deleteAgentToolRelationByAgent(db)({
218776
- scopes: { tenantId, projectId, graphId, subAgentId }
218763
+ scopes: { tenantId, projectId, agentId, subAgentId }
218777
218764
  });
218778
218765
  }
218779
218766
  logger13.info(
218780
- { tenantId, graphId, agentCount: subAgentIds.length },
218767
+ { tenantId, agentId, agentCount: subAgentIds.length },
218781
218768
  "Agent-tool relations deleted"
218782
218769
  );
218783
218770
  }
218784
- await deleteAgentGraph(db)({
218785
- scopes: { tenantId, projectId, graphId }
218771
+ await deleteAgent(db)({
218772
+ scopes: { tenantId, projectId, agentId }
218786
218773
  });
218787
- logger13.info({ tenantId, graphId }, "Graph metadata deleted");
218788
- logger13.info({ tenantId, graphId }, "Full graph deleted successfully");
218774
+ logger13.info({ tenantId, agentId }, "Agent metadata deleted");
218775
+ logger13.info({ tenantId, agentId }, "Full agent deleted successfully");
218789
218776
  return true;
218790
218777
  } catch (error) {
218791
218778
  logger13.error(
218792
218779
  {
218793
218780
  tenantId,
218794
- graphId,
218781
+ agentId,
218795
218782
  error: error instanceof Error ? error.message : "Unknown error"
218796
218783
  },
218797
- "Failed to delete full graph"
218784
+ "Failed to delete full agent"
218798
218785
  );
218799
218786
  throw error;
218800
218787
  }
@@ -219177,7 +219164,7 @@ var listProjects = (db) => async (params) => {
219177
219164
  }
219178
219165
  const projectIdSets = await Promise.all([
219179
219166
  db.selectDistinct({ projectId: subAgents.projectId }).from(subAgents).where(eq(subAgents.tenantId, params.tenantId)),
219180
- db.selectDistinct({ projectId: agentGraph.projectId }).from(agentGraph).where(eq(agentGraph.tenantId, params.tenantId)),
219167
+ db.selectDistinct({ projectId: agents.projectId }).from(agents).where(eq(agents.tenantId, params.tenantId)),
219181
219168
  db.selectDistinct({ projectId: tools.projectId }).from(tools).where(eq(tools.tenantId, params.tenantId)),
219182
219169
  db.selectDistinct({ projectId: contextConfigs.projectId }).from(contextConfigs).where(eq(contextConfigs.tenantId, params.tenantId)),
219183
219170
  db.selectDistinct({ projectId: externalAgents.projectId }).from(externalAgents).where(eq(externalAgents.tenantId, params.tenantId)),
@@ -219223,16 +219210,16 @@ var listProjectsPaginated = (db) => async (params) => {
219223
219210
  };
219224
219211
  var getProjectResourceCounts = (db) => async (params) => {
219225
219212
  const whereClause = (table) => and(eq(table.tenantId, params.tenantId), eq(table.projectId, params.projectId));
219226
- const [agentResults, graphResults, toolResults, contextConfigResults, externalAgentResults] = await Promise.all([
219213
+ const [subAgentResults, agentResults, toolResults, contextConfigResults, externalAgentResults] = await Promise.all([
219227
219214
  db.select({ count: subAgents.id }).from(subAgents).where(whereClause(subAgents)),
219228
- db.select({ count: agentGraph.id }).from(agentGraph).where(whereClause(agentGraph)),
219215
+ db.select({ count: agents.id }).from(agents).where(whereClause(agents)),
219229
219216
  db.select({ count: tools.id }).from(tools).where(whereClause(tools)),
219230
219217
  db.select({ count: contextConfigs.id }).from(contextConfigs).where(whereClause(contextConfigs)),
219231
219218
  db.select({ count: externalAgents.id }).from(externalAgents).where(whereClause(externalAgents))
219232
219219
  ]);
219233
219220
  return {
219221
+ subAgents: subAgentResults.length,
219234
219222
  agents: agentResults.length,
219235
- agentGraphs: graphResults.length,
219236
219223
  tools: toolResults.length,
219237
219224
  contextConfigs: contextConfigResults.length,
219238
219225
  externalAgents: externalAgentResults.length
@@ -219242,7 +219229,7 @@ var projectExists = (db) => async (params) => {
219242
219229
  const whereClause = (table) => and(eq(table.tenantId, params.tenantId), eq(table.projectId, params.projectId));
219243
219230
  const checks = [
219244
219231
  db.select({ id: subAgents.id }).from(subAgents).where(whereClause(subAgents)).limit(1),
219245
- db.select({ id: agentGraph.id }).from(agentGraph).where(whereClause(agentGraph)).limit(1),
219232
+ db.select({ id: agents.id }).from(agents).where(whereClause(agents)).limit(1),
219246
219233
  db.select({ id: tools.id }).from(tools).where(whereClause(tools)).limit(1),
219247
219234
  db.select({ id: contextConfigs.id }).from(contextConfigs).where(whereClause(contextConfigs)).limit(1),
219248
219235
  db.select({ id: externalAgents.id }).from(externalAgents).where(whereClause(externalAgents)).limit(1),
@@ -219324,24 +219311,24 @@ var deleteProject = (db) => async (params) => {
219324
219311
  async function cascadeStopWhenUpdates(db, scopes, oldStopWhen, newStopWhen) {
219325
219312
  const { tenantId, projectId } = scopes;
219326
219313
  if (oldStopWhen?.transferCountIs !== newStopWhen?.transferCountIs) {
219327
- const graphsToUpdate = await db.query.agentGraph.findMany({
219328
- where: and(eq(agentGraph.tenantId, tenantId), eq(agentGraph.projectId, projectId))
219314
+ const agentsToUpdate = await db.query.agents.findMany({
219315
+ where: and(eq(agents.tenantId, tenantId), eq(agents.projectId, projectId))
219329
219316
  });
219330
- for (const graph of graphsToUpdate) {
219331
- const graphStopWhen = graph.stopWhen;
219332
- if (!graphStopWhen?.transferCountIs || graphStopWhen.transferCountIs === oldStopWhen?.transferCountIs) {
219317
+ for (const agent of agentsToUpdate) {
219318
+ const agentStopWhen = agent.stopWhen;
219319
+ if (!agentStopWhen?.transferCountIs || agentStopWhen.transferCountIs === oldStopWhen?.transferCountIs) {
219333
219320
  const updatedStopWhen = {
219334
- ...graphStopWhen || {},
219321
+ ...agentStopWhen || {},
219335
219322
  transferCountIs: newStopWhen?.transferCountIs
219336
219323
  };
219337
- await db.update(agentGraph).set({
219324
+ await db.update(agents).set({
219338
219325
  stopWhen: updatedStopWhen,
219339
219326
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
219340
219327
  }).where(
219341
219328
  and(
219342
- eq(agentGraph.tenantId, tenantId),
219343
- eq(agentGraph.projectId, projectId),
219344
- eq(agentGraph.id, graph.id)
219329
+ eq(agents.tenantId, tenantId),
219330
+ eq(agents.projectId, projectId),
219331
+ eq(agents.id, agent.id)
219345
219332
  )
219346
219333
  );
219347
219334
  }
@@ -219385,7 +219372,7 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
219385
219372
  {
219386
219373
  tenantId,
219387
219374
  projectId: typed.id,
219388
- graphCount: Object.keys(typed.graphs || {}).length
219375
+ agentCount: Object.keys(typed.agents || {}).length
219389
219376
  },
219390
219377
  "Creating full project in database"
219391
219378
  );
@@ -219604,19 +219591,19 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
219604
219591
  "All project artifactComponents created successfully"
219605
219592
  );
219606
219593
  }
219607
- if (typed.graphs && Object.keys(typed.graphs).length > 0) {
219594
+ if (typed.agents && Object.keys(typed.agents).length > 0) {
219608
219595
  logger13.info(
219609
219596
  {
219610
219597
  projectId: typed.id,
219611
- graphCount: Object.keys(typed.graphs).length
219598
+ agentCount: Object.keys(typed.agents).length
219612
219599
  },
219613
- "Creating project graphs"
219600
+ "Creating project agent"
219614
219601
  );
219615
- const graphPromises = Object.entries(typed.graphs).map(async ([graphId, graphData]) => {
219602
+ const agentPromises = Object.entries(typed.agents).map(async ([agentId, agentData]) => {
219616
219603
  try {
219617
- logger13.info({ projectId: typed.id, graphId }, "Creating graph in project");
219618
- const graphDataWithProjectResources = {
219619
- ...graphData,
219604
+ logger13.info({ projectId: typed.id, agentId }, "Creating agent in project");
219605
+ const agentDataWithProjectResources = {
219606
+ ...agentData,
219620
219607
  tools: typed.tools || {},
219621
219608
  // Pass project-level MCP tools for validation
219622
219609
  functions: typed.functions || {},
@@ -219624,28 +219611,28 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
219624
219611
  dataComponents: typed.dataComponents || {},
219625
219612
  artifactComponents: typed.artifactComponents || {},
219626
219613
  credentialReferences: typed.credentialReferences || {},
219627
- statusUpdates: graphData.statusUpdates === null ? void 0 : graphData.statusUpdates
219614
+ statusUpdates: agentData.statusUpdates === null ? void 0 : agentData.statusUpdates
219628
219615
  };
219629
- await createFullGraphServerSide(db, logger13)(
219616
+ await createFullAgentServerSide(db, logger13)(
219630
219617
  { tenantId, projectId: typed.id },
219631
- graphDataWithProjectResources
219618
+ agentDataWithProjectResources
219632
219619
  );
219633
- logger13.info({ projectId: typed.id, graphId }, "Graph created successfully in project");
219620
+ logger13.info({ projectId: typed.id, agentId }, "Agent created successfully in project");
219634
219621
  } catch (error) {
219635
219622
  logger13.error(
219636
- { projectId: typed.id, graphId, error },
219637
- "Failed to create graph in project"
219623
+ { projectId: typed.id, agentId, error },
219624
+ "Failed to create agent in project"
219638
219625
  );
219639
219626
  throw error;
219640
219627
  }
219641
219628
  });
219642
- await Promise.all(graphPromises);
219629
+ await Promise.all(agentPromises);
219643
219630
  logger13.info(
219644
219631
  {
219645
219632
  projectId: typed.id,
219646
- graphCount: Object.keys(typed.graphs).length
219633
+ agentCount: Object.keys(typed.agents).length
219647
219634
  },
219648
- "All project graphs created successfully"
219635
+ "All project agent created successfully"
219649
219636
  );
219650
219637
  }
219651
219638
  logger13.info({ projectId: typed.id }, "Full project created successfully");
@@ -219677,7 +219664,7 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
219677
219664
  {
219678
219665
  tenantId,
219679
219666
  projectId: typed.id,
219680
- graphCount: Object.keys(typed.graphs || {}).length
219667
+ agentCount: Object.keys(typed.agents || {}).length
219681
219668
  },
219682
219669
  "Updating full project in database"
219683
219670
  );
@@ -219912,52 +219899,52 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
219912
219899
  "All project artifactComponents updated successfully"
219913
219900
  );
219914
219901
  }
219915
- const incomingGraphIds = new Set(Object.keys(typed.graphs || {}));
219916
- const existingGraphs = await listAgentGraphs(db)({
219902
+ const incomingAgentIds = new Set(Object.keys(typed.agents || {}));
219903
+ const existingAgents = await listAgents(db)({
219917
219904
  scopes: { tenantId, projectId: typed.id }
219918
219905
  });
219919
- let deletedGraphCount = 0;
219920
- for (const graph of existingGraphs) {
219921
- if (!incomingGraphIds.has(graph.id)) {
219906
+ let deletedAgentCount = 0;
219907
+ for (const agent of existingAgents) {
219908
+ if (!incomingAgentIds.has(agent.id)) {
219922
219909
  try {
219923
- await deleteFullGraph(
219910
+ await deleteFullAgent(
219924
219911
  db,
219925
219912
  logger13
219926
219913
  )({
219927
- scopes: { tenantId, projectId: typed.id, graphId: graph.id }
219914
+ scopes: { tenantId, projectId: typed.id, agentId: agent.id }
219928
219915
  });
219929
- deletedGraphCount++;
219930
- logger13.info({ graphId: graph.id }, "Deleted orphaned graph from project");
219916
+ deletedAgentCount++;
219917
+ logger13.info({ agentId: agent.id }, "Deleted orphaned agent from project");
219931
219918
  } catch (error) {
219932
219919
  logger13.error(
219933
- { graphId: graph.id, error },
219934
- "Failed to delete orphaned graph from project"
219920
+ { agentId: agent.id, error },
219921
+ "Failed to delete orphaned agent from project"
219935
219922
  );
219936
219923
  }
219937
219924
  }
219938
219925
  }
219939
- if (deletedGraphCount > 0) {
219926
+ if (deletedAgentCount > 0) {
219940
219927
  logger13.info(
219941
219928
  {
219942
- deletedGraphCount,
219929
+ deletedAgentCount,
219943
219930
  projectId: typed.id
219944
219931
  },
219945
- "Deleted orphaned graphs from project"
219932
+ "Deleted orphaned agent from project"
219946
219933
  );
219947
219934
  }
219948
- if (typed.graphs && Object.keys(typed.graphs).length > 0) {
219935
+ if (typed.agents && Object.keys(typed.agents).length > 0) {
219949
219936
  logger13.info(
219950
219937
  {
219951
219938
  projectId: typed.id,
219952
- graphCount: Object.keys(typed.graphs).length
219939
+ agentCount: Object.keys(typed.agents).length
219953
219940
  },
219954
- "Updating project graphs"
219941
+ "Updating project agent"
219955
219942
  );
219956
- const graphPromises = Object.entries(typed.graphs).map(async ([graphId, graphData]) => {
219943
+ const agentPromises = Object.entries(typed.agents).map(async ([agentId, agentData]) => {
219957
219944
  try {
219958
- logger13.info({ projectId: typed.id, graphId }, "Updating graph in project");
219959
- const graphDataWithProjectResources = {
219960
- ...graphData,
219945
+ logger13.info({ projectId: typed.id, agentId }, "Updating agent in project");
219946
+ const agentDataWithProjectResources = {
219947
+ ...agentData,
219961
219948
  tools: typed.tools || {},
219962
219949
  // Pass project-level MCP tools for validation
219963
219950
  functions: typed.functions || {},
@@ -219965,28 +219952,28 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
219965
219952
  dataComponents: typed.dataComponents || {},
219966
219953
  artifactComponents: typed.artifactComponents || {},
219967
219954
  credentialReferences: typed.credentialReferences || {},
219968
- statusUpdates: graphData.statusUpdates === null ? void 0 : graphData.statusUpdates
219955
+ statusUpdates: agentData.statusUpdates === null ? void 0 : agentData.statusUpdates
219969
219956
  };
219970
- await updateFullGraphServerSide(db, logger13)(
219957
+ await updateFullAgentServerSide(db, logger13)(
219971
219958
  { tenantId, projectId: typed.id },
219972
- graphDataWithProjectResources
219959
+ agentDataWithProjectResources
219973
219960
  );
219974
- logger13.info({ projectId: typed.id, graphId }, "Graph updated successfully in project");
219961
+ logger13.info({ projectId: typed.id, agentId }, "Agent updated successfully in project");
219975
219962
  } catch (error) {
219976
219963
  logger13.error(
219977
- { projectId: typed.id, graphId, error },
219978
- "Failed to update graph in project"
219964
+ { projectId: typed.id, agentId, error },
219965
+ "Failed to update agent in project"
219979
219966
  );
219980
219967
  throw error;
219981
219968
  }
219982
219969
  });
219983
- await Promise.all(graphPromises);
219970
+ await Promise.all(agentPromises);
219984
219971
  logger13.info(
219985
219972
  {
219986
219973
  projectId: typed.id,
219987
- graphCount: Object.keys(typed.graphs).length
219974
+ agentCount: Object.keys(typed.agents).length
219988
219975
  },
219989
- "All project graphs updated successfully"
219976
+ "All project agent updated successfully"
219990
219977
  );
219991
219978
  }
219992
219979
  logger13.info({ projectId: typed.id }, "Full project updated successfully");
@@ -220021,16 +220008,16 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
220021
220008
  return null;
220022
220009
  }
220023
220010
  logger13.info({ tenantId, projectId }, "Project metadata retrieved");
220024
- const graphList = await listAgentGraphs(db)({
220011
+ const agentList = await listAgents(db)({
220025
220012
  scopes: { tenantId, projectId }
220026
220013
  });
220027
220014
  logger13.info(
220028
220015
  {
220029
220016
  tenantId,
220030
220017
  projectId,
220031
- graphCount: graphList.length
220018
+ agentCount: agentList.length
220032
220019
  },
220033
- "Found graphs for project"
220020
+ "Found agent for project"
220034
220021
  );
220035
220022
  const projectTools = {};
220036
220023
  try {
@@ -220128,34 +220115,34 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
220128
220115
  "Failed to retrieve credentialReferences for project"
220129
220116
  );
220130
220117
  }
220131
- const graphs = {};
220132
- if (graphList.length > 0) {
220133
- const graphPromises = graphList.map(async (graph) => {
220118
+ const agents2 = {};
220119
+ if (agentList.length > 0) {
220120
+ const agentPromises = agentList.map(async (agent) => {
220134
220121
  try {
220135
220122
  logger13.info(
220136
- { tenantId, projectId, graphId: graph.id },
220137
- "Retrieving full graph definition"
220123
+ { tenantId, projectId, agentId: agent.id },
220124
+ "Retrieving full agent definition"
220138
220125
  );
220139
- const fullGraph = await getFullGraph(db)({
220140
- scopes: { tenantId, projectId, graphId: graph.id }
220126
+ const fullAgent = await getFullAgent(db)({
220127
+ scopes: { tenantId, projectId, agentId: agent.id }
220141
220128
  });
220142
- if (fullGraph) {
220143
- graphs[graph.id] = fullGraph;
220129
+ if (fullAgent) {
220130
+ agents2[agent.id] = fullAgent;
220144
220131
  logger13.info(
220145
- { tenantId, projectId, graphId: graph.id },
220146
- "Full graph definition retrieved"
220132
+ { tenantId, projectId, agentId: agent.id },
220133
+ "Full agent definition retrieved"
220147
220134
  );
220148
220135
  } else {
220149
- logger13.warn({ tenantId, projectId, graphId: graph.id }, "Graph definition not found");
220136
+ logger13.warn({ tenantId, projectId, agentId: agent.id }, "Agent definition not found");
220150
220137
  }
220151
220138
  } catch (error) {
220152
220139
  logger13.error(
220153
- { tenantId, projectId, graphId: graph.id, error },
220154
- "Failed to retrieve full graph definition"
220140
+ { tenantId, projectId, agentId: agent.id, error },
220141
+ "Failed to retrieve full agent definition"
220155
220142
  );
220156
220143
  }
220157
220144
  });
220158
- await Promise.all(graphPromises);
220145
+ await Promise.all(agentPromises);
220159
220146
  }
220160
220147
  if (!project.models) {
220161
220148
  throw new Error(
@@ -220168,7 +220155,7 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
220168
220155
  description: project.description,
220169
220156
  models: project.models,
220170
220157
  stopWhen: project.stopWhen || void 0,
220171
- graphs,
220158
+ agents: agents2,
220172
220159
  tools: projectTools,
220173
220160
  dataComponents: projectDataComponents,
220174
220161
  artifactComponents: projectArtifactComponents,
@@ -220180,7 +220167,7 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
220180
220167
  {
220181
220168
  tenantId,
220182
220169
  projectId,
220183
- graphCount: Object.keys(fullProjectDefinition.graphs).length
220170
+ agentCount: Object.keys(fullProjectDefinition.agents).length
220184
220171
  },
220185
220172
  "Full project definition retrieved"
220186
220173
  );
@@ -220212,44 +220199,44 @@ var deleteFullProject = (db, logger13 = defaultLogger2) => async (params) => {
220212
220199
  logger13.info({ tenantId, projectId }, "Project not found for deletion");
220213
220200
  return false;
220214
220201
  }
220215
- if (project.graphs && Object.keys(project.graphs).length > 0) {
220202
+ if (project.agents && Object.keys(project.agents).length > 0) {
220216
220203
  logger13.info(
220217
220204
  {
220218
220205
  tenantId,
220219
220206
  projectId,
220220
- graphCount: Object.keys(project.graphs).length
220207
+ agentCount: Object.keys(project.agents).length
220221
220208
  },
220222
- "Deleting project graphs"
220209
+ "Deleting project agent"
220223
220210
  );
220224
- const graphPromises = Object.keys(project.graphs).map(async (graphId) => {
220211
+ const agentPromises = Object.keys(project.agents).map(async (agentId) => {
220225
220212
  try {
220226
- logger13.info({ tenantId, projectId, graphId }, "Deleting graph from project");
220227
- await deleteFullGraph(
220213
+ logger13.info({ tenantId, projectId, agentId }, "Deleting agent from project");
220214
+ await deleteFullAgent(
220228
220215
  db,
220229
220216
  logger13
220230
220217
  )({
220231
- scopes: { tenantId, projectId, graphId }
220218
+ scopes: { tenantId, projectId, agentId }
220232
220219
  });
220233
220220
  logger13.info(
220234
- { tenantId, projectId, graphId },
220235
- "Graph deleted successfully from project"
220221
+ { tenantId, projectId, agentId },
220222
+ "Agent deleted successfully from project"
220236
220223
  );
220237
220224
  } catch (error) {
220238
220225
  logger13.error(
220239
- { tenantId, projectId, graphId, error },
220240
- "Failed to delete graph from project"
220226
+ { tenantId, projectId, agentId, error },
220227
+ "Failed to delete agent from project"
220241
220228
  );
220242
220229
  throw error;
220243
220230
  }
220244
220231
  });
220245
- await Promise.all(graphPromises);
220232
+ await Promise.all(agentPromises);
220246
220233
  logger13.info(
220247
220234
  {
220248
220235
  tenantId,
220249
220236
  projectId,
220250
- graphCount: Object.keys(project.graphs).length
220237
+ agentCount: Object.keys(project.agents).length
220251
220238
  },
220252
- "All project graphs deleted successfully"
220239
+ "All project agent deleted successfully"
220253
220240
  );
220254
220241
  }
220255
220242
  const deleted = await deleteProject(db)({
@@ -221038,10 +221025,7 @@ async function fetchExistingHeaders({
221038
221025
  credentialStores
221039
221026
  }) {
221040
221027
  const contextResolver = new ContextResolver(tenantId, projectId, dbClient, credentialStores);
221041
- const headers2 = await contextResolver.resolveHeaders(
221042
- conversationId,
221043
- contextConfig2.id
221044
- );
221028
+ const headers2 = await contextResolver.resolveHeaders(conversationId, contextConfig2.id);
221045
221029
  if (Object.keys(headers2).length > 0) {
221046
221030
  return {
221047
221031
  valid: true,
@@ -221049,25 +221033,23 @@ async function fetchExistingHeaders({
221049
221033
  validatedContext: headers2
221050
221034
  };
221051
221035
  }
221052
- throw new Error(
221053
- "No headers found in cache. Please provide headers in request."
221054
- );
221036
+ throw new Error("No headers found in cache. Please provide headers in request.");
221055
221037
  }
221056
221038
  async function validateHeaders({
221057
221039
  tenantId,
221058
221040
  projectId,
221059
- graphId,
221041
+ agentId,
221060
221042
  conversationId,
221061
221043
  parsedRequest,
221062
221044
  dbClient,
221063
221045
  credentialStores
221064
221046
  }) {
221065
221047
  try {
221066
- const agentGraph2 = await getAgentGraphWithDefaultSubAgent(dbClient)({
221067
- scopes: { tenantId, projectId, graphId }
221048
+ const agent = await getAgentWithDefaultSubAgent(dbClient)({
221049
+ scopes: { tenantId, projectId, agentId }
221068
221050
  });
221069
- if (!agentGraph2?.contextConfigId) {
221070
- logger9.debug({ graphId }, "No context config found for graph, skipping validation");
221051
+ if (!agent?.contextConfigId) {
221052
+ logger9.debug({ agentId }, "No context config found for agent, skipping validation");
221071
221053
  return {
221072
221054
  valid: true,
221073
221055
  errors: [],
@@ -221075,11 +221057,11 @@ async function validateHeaders({
221075
221057
  };
221076
221058
  }
221077
221059
  const contextConfig2 = await getContextConfigById(dbClient)({
221078
- scopes: { tenantId, projectId, graphId },
221079
- id: agentGraph2.contextConfigId
221060
+ scopes: { tenantId, projectId, agentId },
221061
+ id: agent.contextConfigId
221080
221062
  });
221081
221063
  if (!contextConfig2) {
221082
- logger9.warn({ contextConfigId: agentGraph2.contextConfigId }, "Context config not found");
221064
+ logger9.warn({ contextConfigId: agent.contextConfigId }, "Context config not found");
221083
221065
  return {
221084
221066
  valid: false,
221085
221067
  errors: [
@@ -221147,7 +221129,7 @@ async function validateHeaders({
221147
221129
  logger9.error(
221148
221130
  {
221149
221131
  tenantId,
221150
- graphId,
221132
+ agentId,
221151
221133
  error: error instanceof Error ? error.message : "Unknown error"
221152
221134
  },
221153
221135
  "Failed to validate headers"
@@ -221167,13 +221149,13 @@ function contextValidationMiddleware(dbClient) {
221167
221149
  return async (c, next) => {
221168
221150
  try {
221169
221151
  const executionContext = getRequestExecutionContext(c);
221170
- let { tenantId, projectId, graphId } = executionContext;
221171
- if (!tenantId || !projectId || !graphId) {
221152
+ let { tenantId, projectId, agentId } = executionContext;
221153
+ if (!tenantId || !projectId || !agentId) {
221172
221154
  tenantId = c.req.param("tenantId");
221173
221155
  projectId = c.req.param("projectId");
221174
- graphId = c.req.param("graphId");
221156
+ agentId = c.req.param("agentId");
221175
221157
  }
221176
- if (!tenantId || !projectId || !graphId) {
221158
+ if (!tenantId || !projectId || !agentId) {
221177
221159
  return next();
221178
221160
  }
221179
221161
  const body = c.get("requestBody") || {};
@@ -221189,7 +221171,7 @@ function contextValidationMiddleware(dbClient) {
221189
221171
  const validationResult = await validateHeaders({
221190
221172
  tenantId,
221191
221173
  projectId,
221192
- graphId,
221174
+ agentId,
221193
221175
  conversationId,
221194
221176
  parsedRequest,
221195
221177
  dbClient,
@@ -221199,7 +221181,7 @@ function contextValidationMiddleware(dbClient) {
221199
221181
  logger9.warn(
221200
221182
  {
221201
221183
  tenantId,
221202
- graphId,
221184
+ agentId,
221203
221185
  errors: validationResult.errors
221204
221186
  },
221205
221187
  "Headers validation failed"
@@ -221214,7 +221196,7 @@ function contextValidationMiddleware(dbClient) {
221214
221196
  logger9.debug(
221215
221197
  {
221216
221198
  tenantId,
221217
- graphId,
221199
+ agentId,
221218
221200
  contextKeys: Object.keys(validationResult.validatedContext || {})
221219
221201
  },
221220
221202
  "Request context validation successful"
@@ -221241,8 +221223,8 @@ var checkGraphQLErrors = (data) => {
221241
221223
  if (data && typeof data === "object" && "errors" in data) {
221242
221224
  const errorObj = data;
221243
221225
  if (Array.isArray(errorObj.errors) && errorObj.errors.length > 0) {
221244
- const graphqlErrors = errorObj.errors;
221245
- const errorMessage = `GraphQL request failed with ${graphqlErrors.length} errors: ${graphqlErrors.map((e) => e.message || "Unknown error").join(", ")}`;
221226
+ const agentqlErrors = errorObj.errors;
221227
+ const errorMessage = `GraphQL request failed with ${agentqlErrors.length} errors: ${agentqlErrors.map((e) => e.message || "Unknown error").join(", ")}`;
221246
221228
  throw new Error(errorMessage);
221247
221229
  }
221248
221230
  }
@@ -221587,7 +221569,7 @@ async function determineContextTrigger(tenantId, projectId, conversationId, dbCl
221587
221569
  }
221588
221570
  return "invocation";
221589
221571
  }
221590
- async function handleContextConfigChange(tenantId, projectId, conversationId, graphId, newContextConfigId, dbClient, credentialStores) {
221572
+ async function handleContextConfigChange(tenantId, projectId, conversationId, agentId, newContextConfigId, dbClient, credentialStores) {
221591
221573
  const conversation = await getConversation(dbClient)({
221592
221574
  scopes: { tenantId, projectId },
221593
221575
  conversationId
@@ -221599,7 +221581,7 @@ async function handleContextConfigChange(tenantId, projectId, conversationId, gr
221599
221581
  logger11.info(
221600
221582
  {
221601
221583
  conversationId,
221602
- graphId,
221584
+ agentId,
221603
221585
  contextConfigId: newContextConfigId
221604
221586
  },
221605
221587
  "Potential context config change for existing conversation, cache cleared"
@@ -221609,7 +221591,7 @@ async function handleContextConfigChange(tenantId, projectId, conversationId, gr
221609
221591
  async function handleContextResolution({
221610
221592
  tenantId,
221611
221593
  projectId,
221612
- graphId,
221594
+ agentId,
221613
221595
  conversationId,
221614
221596
  headers: headers2,
221615
221597
  dbClient,
@@ -221623,38 +221605,38 @@ async function handleContextResolution({
221623
221605
  }
221624
221606
  },
221625
221607
  async (parentSpan) => {
221626
- let agentGraph2;
221608
+ let agent;
221627
221609
  let trigger;
221628
221610
  try {
221629
- agentGraph2 = await getAgentGraphWithDefaultSubAgent(dbClient)({
221630
- scopes: { tenantId, projectId, graphId }
221611
+ agent = await getAgentWithDefaultSubAgent(dbClient)({
221612
+ scopes: { tenantId, projectId, agentId }
221631
221613
  });
221632
- if (!agentGraph2?.contextConfigId) {
221633
- logger11.debug({ graphId }, "No context config found for graph");
221614
+ if (!agent?.contextConfigId) {
221615
+ logger11.debug({ agentId }, "No context config found for agent");
221634
221616
  return null;
221635
221617
  }
221636
221618
  await handleContextConfigChange(
221637
221619
  tenantId,
221638
221620
  projectId,
221639
221621
  conversationId,
221640
- graphId,
221641
- agentGraph2.contextConfigId,
221622
+ agentId,
221623
+ agent.contextConfigId,
221642
221624
  dbClient,
221643
221625
  credentialStores
221644
221626
  );
221645
221627
  trigger = await determineContextTrigger(tenantId, projectId, conversationId, dbClient);
221646
221628
  const contextConfig2 = await getContextConfigById(dbClient)({
221647
- scopes: { tenantId, projectId, graphId },
221648
- id: agentGraph2.contextConfigId
221629
+ scopes: { tenantId, projectId, agentId },
221630
+ id: agent.contextConfigId
221649
221631
  });
221650
221632
  if (!contextConfig2) {
221651
221633
  logger11.warn(
221652
- { contextConfigId: agentGraph2.contextConfigId },
221634
+ { contextConfigId: agent.contextConfigId },
221653
221635
  "Context config not found, proceeding without context resolution"
221654
221636
  );
221655
221637
  parentSpan.setStatus({ code: SpanStatusCode.ERROR });
221656
221638
  parentSpan.addEvent("context.config_not_found", {
221657
- contextConfigId: agentGraph2.contextConfigId
221639
+ contextConfigId: agent.contextConfigId
221658
221640
  });
221659
221641
  return null;
221660
221642
  }
@@ -221693,7 +221675,7 @@ async function handleContextResolution({
221693
221675
  logger11.info(
221694
221676
  {
221695
221677
  conversationId,
221696
- graphId,
221678
+ agentId,
221697
221679
  contextConfigId: contextConfig2.id,
221698
221680
  trigger,
221699
221681
  resolvedKeys: Object.keys(resolvedContext),
@@ -221702,7 +221684,7 @@ async function handleContextResolution({
221702
221684
  fetchedDefinitions: contextResult.fetchedDefinitions.length,
221703
221685
  errors: contextResult.errors.length
221704
221686
  },
221705
- "Context resolution completed (contextConfigId derived from graph)"
221687
+ "Context resolution completed (contextConfigId derived from agent)"
221706
221688
  );
221707
221689
  return resolvedContext;
221708
221690
  } catch (error) {
@@ -221715,7 +221697,7 @@ async function handleContextResolution({
221715
221697
  logger11.error(
221716
221698
  {
221717
221699
  error: errorMessage,
221718
- contextConfigId: agentGraph2?.contextConfigId,
221700
+ contextConfigId: agent?.contextConfigId,
221719
221701
  trigger: await determineContextTrigger(
221720
221702
  tenantId,
221721
221703
  projectId,
@@ -222573,4 +222555,4 @@ typescript/lib/typescript.js:
222573
222555
  ***************************************************************************** *)
222574
222556
  */
222575
222557
 
222576
- export { ContextCache, ContextConfigBuilder, ContextFetcher, ContextResolver, CredentialStoreRegistry, CredentialStuffer, ERROR_DOCS_BASE_URL, ErrorCode, HTTP_REQUEST_PARTS, InMemoryCredentialStore, KeyChainStore, McpClient, NangoCredentialStore, TemplateEngine, addFunctionToolToSubAgent, addLedgerArtifacts, addToolToAgent, apiFetch, associateArtifactComponentWithAgent, associateDataComponentWithAgent, cleanupTenantCache, clearContextConfigCache, clearConversationCache, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, contextConfig, contextValidationMiddleware, countApiKeys, countArtifactComponents, countArtifactComponentsForAgent, countContextConfigs, countCredentialReferences, countDataComponents, countExternalAgents, countLedgerArtifactsByTask, countMessagesByConversation, countProjects, createAgentGraph, createAgentToolRelation, createApiError, createApiKey, createArtifactComponent, createContextConfig, createConversation, createCredentialReference, createDataComponent, createDatabaseClient, createDefaultCredentialStores, createExecutionContext, createExternalAgent, createExternalAgentRelation, createFullGraphServerSide, createFullProjectServerSide, createFunctionTool, createInMemoryDatabaseClient, createKeyChainStore, createMessage, createNangoCredentialStore, createOrGetConversation, createProject, createSubAgent, createSubAgentRelation, createTask, createTool, createValidatedDataAccess, dbResultToMcpTool, deleteAgentArtifactComponentRelationByAgent, deleteAgentDataComponentRelationByAgent, deleteAgentGraph, deleteAgentRelationsByGraph, deleteAgentToolRelation, deleteAgentToolRelationByAgent, deleteApiKey, deleteArtifactComponent, deleteContextConfig, deleteConversation, deleteCredentialReference, deleteDataComponent, deleteExternalAgent, deleteFullGraph, deleteFullProject, deleteFunction, deleteFunctionTool, deleteLedgerArtifactsByContext, deleteLedgerArtifactsByTask, deleteMessage, deleteProject, deleteSubAgent, deleteSubAgentRelation, deleteTool, detectAuthenticationRequired, determineContextTrigger, discoverOAuthEndpoints, errorResponseSchema, errorSchemaFactory, externalAgentExists, externalAgentUrlExists, extractPublicId, fetchComponentRelationships, fetchDefinition, generateAndCreateApiKey, generateApiKey, generateId, getActiveAgentForConversation, getAgentGraphById, getAgentGraphWithDefaultSubAgent, getAgentRelationById, getAgentRelationByParams, getAgentRelations, getAgentRelationsByGraph, getAgentRelationsBySource, getAgentRelationsByTarget, getAgentToolRelationByAgent, getAgentToolRelationById, getAgentToolRelationByTool, getAgentsForTool, getAgentsUsingArtifactComponent, getAgentsUsingDataComponent, getApiKeyById, getApiKeyByPublicId, getArtifactComponentById, getArtifactComponentsForAgent, getCacheEntry, getCachedValidator, getContextConfigById, getContextConfigCacheEntries, getConversation, getConversationCacheEntries, getConversationHistory, getConversationId, getCredentialReference, getCredentialReferenceById, getCredentialReferenceWithTools, getCredentialStoreLookupKeyFromRetrievalParams, getDataComponent, getDataComponentsForAgent, getExternalAgent, getExternalAgentByUrl, getExternalAgentRelations, getFullGraph, getFullGraphDefinition, getFullProject, getFunction, getFunctionToolById, getFunctionToolsForSubAgent, getGraphAgentInfos, getLedgerArtifacts, getLedgerArtifactsByContext, getMessageById, getMessagesByConversation, getMessagesByTask, getProject, getProjectResourceCounts, getRelatedAgentsForGraph, getRequestExecutionContext, getSubAgentById, getSubAgentsByIds, getTask, getToolById, getToolsForAgent, getTracer, getVisibleMessages, graphHasArtifactComponents, handleApiError, handleContextConfigChange, handleContextResolution, hasApiKey, hasContextConfig, hasCredentialReference, hashApiKey, headers, invalidateHeadersCache, invalidateInvocationDefinitionsCache, isApiKeyExpired, isArtifactComponentAssociatedWithAgent, isDataComponentAssociatedWithAgent, isValidHttpRequest, listAgentGraphs, listAgentGraphsPaginated, listAgentRelations, listAgentToolRelations, listApiKeys, listApiKeysPaginated, listArtifactComponents, listArtifactComponentsPaginated, listContextConfigs, listContextConfigsPaginated, listConversations, listCredentialReferences, listCredentialReferencesPaginated, listDataComponents, listDataComponentsPaginated, listExternalAgents, listExternalAgentsPaginated, listFunctionTools, listFunctions, listMessages, listProjects, listProjectsPaginated, listSubAgents, listSubAgentsPaginated, listTaskIdsByContextId, listTools, loadEnvironmentFiles, maskApiKey, problemDetailsSchema, projectExists, projectExistsInTable, projectHasResources, removeArtifactComponentFromAgent, removeDataComponentFromAgent, removeToolFromAgent, setActiveAgentForConversation, setActiveAgentForThread, setCacheEntry, setSpanWithError, updateAgentGraph, updateAgentRelation, updateAgentToolRelation, updateApiKey, updateApiKeyLastUsed, updateArtifactComponent, updateContextConfig, updateConversation, updateConversationActiveAgent, updateCredentialReference, updateDataComponent, updateExternalAgent, updateFullGraphServerSide, updateFullProjectServerSide, updateFunctionTool, updateMessage, updateProject, updateSubAgent, updateSubAgentFunctionToolRelation, updateTask, updateTool, upsertAgentArtifactComponentRelation, upsertAgentDataComponentRelation, upsertAgentGraph, upsertAgentRelation, upsertArtifactComponent, upsertContextConfig, upsertCredentialReference, upsertDataComponent, upsertExternalAgent, upsertFunction, upsertFunctionTool, upsertLedgerArtifact, upsertSubAgent, upsertSubAgentFunctionToolRelation, upsertSubAgentToolRelation, upsertTool, validateAgainstJsonSchema, validateAndGetApiKey, validateApiKey, validateExternalAgent, validateHeaders, validateHttpRequestHeaders, validateInternalSubAgent, validateProjectExists, validationHelper, withProjectValidation };
222558
+ export { ContextCache, ContextConfigBuilder, ContextFetcher, ContextResolver, CredentialStoreRegistry, CredentialStuffer, ERROR_DOCS_BASE_URL, ErrorCode, HTTP_REQUEST_PARTS, InMemoryCredentialStore, KeyChainStore, McpClient, NangoCredentialStore, TemplateEngine, addFunctionToolToSubAgent, addLedgerArtifacts, addToolToAgent, agentHasArtifactComponents, apiFetch, associateArtifactComponentWithAgent, associateDataComponentWithAgent, cleanupTenantCache, clearContextConfigCache, clearConversationCache, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, contextConfig, contextValidationMiddleware, countApiKeys, countArtifactComponents, countArtifactComponentsForAgent, countContextConfigs, countCredentialReferences, countDataComponents, countExternalAgents, countLedgerArtifactsByTask, countMessagesByConversation, countProjects, createAgent, createAgentToolRelation, createApiError, createApiKey, createArtifactComponent, createContextConfig, createConversation, createCredentialReference, createDataComponent, createDatabaseClient, createDefaultCredentialStores, createExecutionContext, createExternalAgent, createExternalAgentRelation, createFullAgentServerSide, createFullProjectServerSide, createFunctionTool, createInMemoryDatabaseClient, createKeyChainStore, createMessage, createNangoCredentialStore, createOrGetConversation, createProject, createSubAgent, createSubAgentRelation, createTask, createTool, createValidatedDataAccess, dbResultToMcpTool, deleteAgent, deleteAgentArtifactComponentRelationByAgent, deleteAgentDataComponentRelationByAgent, deleteAgentRelationsByAgent, deleteAgentToolRelation, deleteAgentToolRelationByAgent, deleteApiKey, deleteArtifactComponent, deleteContextConfig, deleteConversation, deleteCredentialReference, deleteDataComponent, deleteExternalAgent, deleteFullAgent, deleteFullProject, deleteFunction, deleteFunctionTool, deleteLedgerArtifactsByContext, deleteLedgerArtifactsByTask, deleteMessage, deleteProject, deleteSubAgent, deleteSubAgentRelation, deleteTool, detectAuthenticationRequired, determineContextTrigger, discoverOAuthEndpoints, errorResponseSchema, errorSchemaFactory, externalAgentExists, externalAgentUrlExists, extractPublicId, fetchComponentRelationships, fetchDefinition, generateAndCreateApiKey, generateApiKey, generateId, getActiveAgentForConversation, getAgentById, getAgentRelationById, getAgentRelationByParams, getAgentRelations, getAgentRelationsByAgent, getAgentRelationsBySource, getAgentRelationsByTarget, getAgentSubAgentInfos, getAgentToolRelationByAgent, getAgentToolRelationById, getAgentToolRelationByTool, getAgentWithDefaultSubAgent, getAgentsForTool, getAgentsUsingArtifactComponent, getAgentsUsingDataComponent, getApiKeyById, getApiKeyByPublicId, getArtifactComponentById, getArtifactComponentsForAgent, getCacheEntry, getCachedValidator, getContextConfigById, getContextConfigCacheEntries, getConversation, getConversationCacheEntries, getConversationHistory, getConversationId, getCredentialReference, getCredentialReferenceById, getCredentialReferenceWithTools, getCredentialStoreLookupKeyFromRetrievalParams, getDataComponent, getDataComponentsForAgent, getExternalAgent, getExternalAgentByUrl, getExternalAgentRelations, getFullAgent, getFullAgentDefinition, getFullProject, getFunction, getFunctionToolById, getFunctionToolsForSubAgent, getLedgerArtifacts, getLedgerArtifactsByContext, getMessageById, getMessagesByConversation, getMessagesByTask, getProject, getProjectResourceCounts, getRelatedAgentsForAgent, getRequestExecutionContext, getSubAgentById, getSubAgentsByIds, getTask, getToolById, getToolsForAgent, getTracer, getVisibleMessages, handleApiError, handleContextConfigChange, handleContextResolution, hasApiKey, hasContextConfig, hasCredentialReference, hashApiKey, headers, invalidateHeadersCache, invalidateInvocationDefinitionsCache, isApiKeyExpired, isArtifactComponentAssociatedWithAgent, isDataComponentAssociatedWithAgent, isValidHttpRequest, listAgentRelations, listAgentToolRelations, listAgents, listAgentsPaginated, listApiKeys, listApiKeysPaginated, listArtifactComponents, listArtifactComponentsPaginated, listContextConfigs, listContextConfigsPaginated, listConversations, listCredentialReferences, listCredentialReferencesPaginated, listDataComponents, listDataComponentsPaginated, listExternalAgents, listExternalAgentsPaginated, listFunctionTools, listFunctions, listMessages, listProjects, listProjectsPaginated, listSubAgents, listSubAgentsPaginated, listTaskIdsByContextId, listTools, loadEnvironmentFiles, maskApiKey, problemDetailsSchema, projectExists, projectExistsInTable, projectHasResources, removeArtifactComponentFromAgent, removeDataComponentFromAgent, removeToolFromAgent, setActiveAgentForConversation, setActiveAgentForThread, setCacheEntry, setSpanWithError, updateAgent, updateAgentRelation, updateAgentToolRelation, updateApiKey, updateApiKeyLastUsed, updateArtifactComponent, updateContextConfig, updateConversation, updateConversationActiveAgent, updateCredentialReference, updateDataComponent, updateExternalAgent, updateFullAgentServerSide, updateFullProjectServerSide, updateFunctionTool, updateMessage, updateProject, updateSubAgent, updateSubAgentFunctionToolRelation, updateTask, updateTool, upsertAgent, upsertAgentArtifactComponentRelation, upsertAgentDataComponentRelation, upsertAgentRelation, upsertArtifactComponent, upsertContextConfig, upsertCredentialReference, upsertDataComponent, upsertExternalAgent, upsertFunction, upsertFunctionTool, upsertLedgerArtifact, upsertSubAgent, upsertSubAgentFunctionToolRelation, upsertSubAgentToolRelation, upsertTool, validateAgainstJsonSchema, validateAndGetApiKey, validateApiKey, validateExternalAgent, validateHeaders, validateHttpRequestHeaders, validateInternalSubAgent, validateProjectExists, validationHelper, withProjectValidation };