@inkeep/agents-core 0.0.0-dev-20250925023031 → 0.0.0-dev-20250925025705

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.
@@ -1,4 +1,4 @@
1
- import { FullGraphDefinitionSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-ZORVFHVU.js';
1
+ import { FullGraphDefinitionSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-GL4IGNT7.js';
2
2
 
3
3
  // src/validation/graphFull.ts
4
4
  function isInternalAgent(agent) {
@@ -16,10 +16,10 @@ function validateToolReferences(graphData, availableToolIds) {
16
16
  }
17
17
  const errors = [];
18
18
  for (const [agentId, agentData] of Object.entries(graphData.agents)) {
19
- if (isInternalAgent(agentData) && agentData.tools && Array.isArray(agentData.tools)) {
20
- for (const toolId of agentData.tools) {
21
- if (!availableToolIds.has(toolId)) {
22
- errors.push(`Agent '${agentId}' references non-existent tool '${toolId}'`);
19
+ if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
20
+ for (const canUseItem of agentData.canUse) {
21
+ if (!availableToolIds.has(canUseItem.toolId)) {
22
+ errors.push(`Agent '${agentId}' references non-existent tool '${canUseItem.toolId}'`);
23
23
  }
24
24
  }
25
25
  }
@@ -1,5 +1,5 @@
1
- import { agents, agentRelations, agentGraph, tasks, taskRelations, tools, conversations, messages, contextCache, dataComponents, agentDataComponents, artifactComponents, agentArtifactComponents, externalAgents, apiKeys, credentialReferences, contextConfigs, agentToolRelations, ledgerArtifacts, projects } from './chunk-LFWFXR4O.js';
2
1
  import { VALID_RELATION_TYPES, MCPTransportType, TOOL_STATUS_VALUES, CredentialStoreType, MCPServerType } from './chunk-SVGQSPW4.js';
2
+ import { agents, agentRelations, agentGraph, tasks, taskRelations, tools, conversations, messages, contextCache, dataComponents, agentDataComponents, artifactComponents, agentArtifactComponents, externalAgents, apiKeys, credentialReferences, contextConfigs, agentToolRelations, ledgerArtifacts, projects } from './chunk-LFWFXR4O.js';
3
3
  import { z } from '@hono/zod-openapi';
4
4
  import { createSelectSchema, createInsertSchema } from 'drizzle-zod';
5
5
 
@@ -233,8 +233,6 @@ var ArtifactComponentApiInsertSchema = ArtifactComponentInsertSchema.omit({
233
233
  projectId: true,
234
234
  createdAt: true,
235
235
  updatedAt: true
236
- }).extend({
237
- id: resourceIdSchema.optional()
238
236
  });
239
237
  var ArtifactComponentApiUpdateSchema = createApiUpdateSchema(
240
238
  ArtifactComponentUpdateSchema
@@ -454,10 +452,13 @@ var StatusUpdateSchema = z.object({
454
452
  prompt: z.string().max(2e3, "Custom prompt cannot exceed 2000 characters").optional(),
455
453
  statusComponents: z.array(StatusComponentSchema).optional()
456
454
  });
455
+ var CanUseItemSchema = z.object({
456
+ toolId: z.string(),
457
+ toolSelection: z.array(z.string()).nullable().optional()
458
+ });
457
459
  var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
458
460
  type: z.literal("internal"),
459
- tools: z.array(z.string()),
460
- selectedTools: z.record(z.string(), z.array(z.string())).optional(),
461
+ canUse: z.array(CanUseItemSchema),
461
462
  dataComponents: z.array(z.string()).optional(),
462
463
  artifactComponents: z.array(z.string()).optional(),
463
464
  canTransferTo: z.array(z.string()).optional(),
@@ -619,4 +620,4 @@ var PaginationQueryParamsSchema = z.object({
619
620
  limit: z.coerce.number().min(1).max(100).default(10)
620
621
  });
621
622
 
622
- export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiSelectSchema, AgentArtifactComponentApiUpdateSchema, AgentArtifactComponentInsertSchema, AgentArtifactComponentSelectSchema, AgentArtifactComponentUpdateSchema, AgentDataComponentApiInsertSchema, AgentDataComponentApiSelectSchema, AgentDataComponentApiUpdateSchema, AgentDataComponentInsertSchema, AgentDataComponentSelectSchema, AgentDataComponentUpdateSchema, AgentGraphApiInsertSchema, AgentGraphApiSelectSchema, AgentGraphApiUpdateSchema, AgentGraphInsertSchema, AgentGraphSelectSchema, AgentGraphUpdateSchema, AgentInsertSchema, AgentRelationApiInsertSchema, AgentRelationApiSelectSchema, AgentRelationApiUpdateSchema, AgentRelationInsertSchema, AgentRelationQuerySchema, AgentRelationSelectSchema, AgentRelationUpdateSchema, AgentSelectSchema, AgentStopWhenSchema, AgentToolRelationApiInsertSchema, AgentToolRelationApiSelectSchema, AgentToolRelationApiUpdateSchema, AgentToolRelationInsertSchema, AgentToolRelationSelectSchema, AgentToolRelationUpdateSchema, AgentUpdateSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentInsertSchema, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, 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, ExternalAgentRelationApiInsertSchema, ExternalAgentRelationInsertSchema, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, FetchConfigSchema, FetchDefinitionSchema, FullGraphAgentInsertSchema, FullGraphDefinitionSchema, FullProjectDefinitionSchema, GraphStopWhenSchema, GraphWithinContextOfProjectSchema, HeadersScopeSchema, IdParamsSchema, 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, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectGraphIdParamsSchema, TenantProjectGraphParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema };
623
+ export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiSelectSchema, AgentArtifactComponentApiUpdateSchema, AgentArtifactComponentInsertSchema, AgentArtifactComponentSelectSchema, AgentArtifactComponentUpdateSchema, AgentDataComponentApiInsertSchema, AgentDataComponentApiSelectSchema, AgentDataComponentApiUpdateSchema, AgentDataComponentInsertSchema, AgentDataComponentSelectSchema, AgentDataComponentUpdateSchema, AgentGraphApiInsertSchema, AgentGraphApiSelectSchema, AgentGraphApiUpdateSchema, AgentGraphInsertSchema, AgentGraphSelectSchema, AgentGraphUpdateSchema, AgentInsertSchema, AgentRelationApiInsertSchema, AgentRelationApiSelectSchema, AgentRelationApiUpdateSchema, AgentRelationInsertSchema, AgentRelationQuerySchema, AgentRelationSelectSchema, AgentRelationUpdateSchema, AgentSelectSchema, AgentStopWhenSchema, AgentToolRelationApiInsertSchema, AgentToolRelationApiSelectSchema, AgentToolRelationApiUpdateSchema, AgentToolRelationInsertSchema, AgentToolRelationSelectSchema, AgentToolRelationUpdateSchema, AgentUpdateSchema, 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, ExternalAgentRelationApiInsertSchema, ExternalAgentRelationInsertSchema, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, FetchConfigSchema, FetchDefinitionSchema, FullGraphAgentInsertSchema, FullGraphDefinitionSchema, FullProjectDefinitionSchema, GraphStopWhenSchema, GraphWithinContextOfProjectSchema, HeadersScopeSchema, IdParamsSchema, 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, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectGraphIdParamsSchema, TenantProjectGraphParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema };
@@ -1175,8 +1175,6 @@ var ArtifactComponentApiInsertSchema = ArtifactComponentInsertSchema.omit({
1175
1175
  projectId: true,
1176
1176
  createdAt: true,
1177
1177
  updatedAt: true
1178
- }).extend({
1179
- id: resourceIdSchema.optional()
1180
1178
  });
1181
1179
  createApiUpdateSchema(
1182
1180
  ArtifactComponentUpdateSchema
@@ -1395,10 +1393,13 @@ var StatusUpdateSchema = zodOpenapi.z.object({
1395
1393
  prompt: zodOpenapi.z.string().max(2e3, "Custom prompt cannot exceed 2000 characters").optional(),
1396
1394
  statusComponents: zodOpenapi.z.array(StatusComponentSchema).optional()
1397
1395
  });
1396
+ var CanUseItemSchema = zodOpenapi.z.object({
1397
+ toolId: zodOpenapi.z.string(),
1398
+ toolSelection: zodOpenapi.z.array(zodOpenapi.z.string()).nullable().optional()
1399
+ });
1398
1400
  var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
1399
1401
  type: zodOpenapi.z.literal("internal"),
1400
- tools: zodOpenapi.z.array(zodOpenapi.z.string()),
1401
- selectedTools: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.array(zodOpenapi.z.string())).optional(),
1402
+ canUse: zodOpenapi.z.array(CanUseItemSchema),
1402
1403
  dataComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
1403
1404
  artifactComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
1404
1405
  canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
@@ -1640,13 +1641,13 @@ var CredentialReferenceApiInsertSchema2 = zod.z.object({
1640
1641
  retrievalParams: zod.z.record(zod.z.string(), zod.z.unknown()).nullish()
1641
1642
  });
1642
1643
  var DataComponentApiInsertSchema2 = zod.z.object({
1643
- id: zod.z.string().optional(),
1644
+ id: zod.z.string(),
1644
1645
  name: zod.z.string(),
1645
1646
  description: zod.z.string().optional(),
1646
1647
  props: zod.z.record(zod.z.string(), zod.z.unknown())
1647
1648
  });
1648
1649
  var ArtifactComponentApiInsertSchema2 = zod.z.object({
1649
- id: zod.z.string().optional(),
1650
+ id: zod.z.string(),
1650
1651
  name: zod.z.string(),
1651
1652
  description: zod.z.string().optional(),
1652
1653
  summaryProps: zod.z.record(zod.z.string(), zod.z.unknown()),
@@ -1676,29 +1677,7 @@ var FullGraphDefinitionSchema2 = AgentGraphApiInsertSchema2.extend({
1676
1677
  agents: zod.z.record(
1677
1678
  zod.z.string(),
1678
1679
  zod.z.union([
1679
- AgentApiInsertSchema2.extend({
1680
- id: zod.z.string(),
1681
- tools: zod.z.array(zod.z.string()),
1682
- dataComponents: zod.z.array(zod.z.string()).optional(),
1683
- artifactComponents: zod.z.array(zod.z.string()).optional(),
1684
- canTransferTo: zod.z.array(zod.z.string()).optional(),
1685
- canDelegateTo: zod.z.array(zod.z.string()).optional(),
1686
- type: zod.z.enum(["internal", "external"]).optional(),
1687
- models: zod.z.object({
1688
- base: zod.z.object({
1689
- model: zod.z.string(),
1690
- providerOptions: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.unknown())).optional()
1691
- }).optional(),
1692
- structuredOutput: zod.z.object({
1693
- model: zod.z.string(),
1694
- providerOptions: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.unknown())).optional()
1695
- }).optional(),
1696
- summarizer: zod.z.object({
1697
- model: zod.z.string(),
1698
- providerOptions: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.unknown())).optional()
1699
- }).optional()
1700
- }).optional()
1701
- }),
1680
+ FullGraphAgentInsertSchema,
1702
1681
  ExternalAgentApiInsertSchema2.extend({
1703
1682
  id: zod.z.string()
1704
1683
  })
@@ -1,4 +1,5 @@
1
- export { AgentStopWhenSchema, GraphStopWhenSchema, StopWhenSchema } from './chunk-ZORVFHVU.js';
1
+ import { FullGraphAgentInsertSchema } from './chunk-GL4IGNT7.js';
2
+ export { AgentStopWhenSchema, GraphStopWhenSchema, StopWhenSchema } from './chunk-GL4IGNT7.js';
2
3
  import { CredentialStoreType } from './chunk-SVGQSPW4.js';
3
4
  export { CredentialStoreType, MCPTransportType } from './chunk-SVGQSPW4.js';
4
5
  import { z } from 'zod';
@@ -89,13 +90,13 @@ var CredentialReferenceApiInsertSchema = z.object({
89
90
  retrievalParams: z.record(z.string(), z.unknown()).nullish()
90
91
  });
91
92
  var DataComponentApiInsertSchema = z.object({
92
- id: z.string().optional(),
93
+ id: z.string(),
93
94
  name: z.string(),
94
95
  description: z.string().optional(),
95
96
  props: z.record(z.string(), z.unknown())
96
97
  });
97
98
  var ArtifactComponentApiInsertSchema = z.object({
98
- id: z.string().optional(),
99
+ id: z.string(),
99
100
  name: z.string(),
100
101
  description: z.string().optional(),
101
102
  summaryProps: z.record(z.string(), z.unknown()),
@@ -125,29 +126,7 @@ var FullGraphDefinitionSchema = AgentGraphApiInsertSchema.extend({
125
126
  agents: z.record(
126
127
  z.string(),
127
128
  z.union([
128
- AgentApiInsertSchema.extend({
129
- id: z.string(),
130
- tools: z.array(z.string()),
131
- dataComponents: z.array(z.string()).optional(),
132
- artifactComponents: z.array(z.string()).optional(),
133
- canTransferTo: z.array(z.string()).optional(),
134
- canDelegateTo: z.array(z.string()).optional(),
135
- type: z.enum(["internal", "external"]).optional(),
136
- models: z.object({
137
- base: z.object({
138
- model: z.string(),
139
- providerOptions: z.record(z.string(), z.record(z.string(), z.unknown())).optional()
140
- }).optional(),
141
- structuredOutput: z.object({
142
- model: z.string(),
143
- providerOptions: z.record(z.string(), z.record(z.string(), z.unknown())).optional()
144
- }).optional(),
145
- summarizer: z.object({
146
- model: z.string(),
147
- providerOptions: z.record(z.string(), z.record(z.string(), z.unknown())).optional()
148
- }).optional()
149
- }).optional()
150
- }),
129
+ FullGraphAgentInsertSchema,
151
130
  ExternalAgentApiInsertSchema.extend({
152
131
  id: z.string()
153
132
  })
package/dist/index.cjs CHANGED
@@ -1423,8 +1423,6 @@ var ArtifactComponentApiInsertSchema = ArtifactComponentInsertSchema.omit({
1423
1423
  projectId: true,
1424
1424
  createdAt: true,
1425
1425
  updatedAt: true
1426
- }).extend({
1427
- id: resourceIdSchema.optional()
1428
1426
  });
1429
1427
  var ArtifactComponentApiUpdateSchema = createApiUpdateSchema(
1430
1428
  ArtifactComponentUpdateSchema
@@ -1644,10 +1642,13 @@ var StatusUpdateSchema = zodOpenapi.z.object({
1644
1642
  prompt: zodOpenapi.z.string().max(2e3, "Custom prompt cannot exceed 2000 characters").optional(),
1645
1643
  statusComponents: zodOpenapi.z.array(StatusComponentSchema).optional()
1646
1644
  });
1645
+ var CanUseItemSchema = zodOpenapi.z.object({
1646
+ toolId: zodOpenapi.z.string(),
1647
+ toolSelection: zodOpenapi.z.array(zodOpenapi.z.string()).nullable().optional()
1648
+ });
1647
1649
  var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
1648
1650
  type: zodOpenapi.z.literal("internal"),
1649
- tools: zodOpenapi.z.array(zodOpenapi.z.string()),
1650
- selectedTools: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.array(zodOpenapi.z.string())).optional(),
1651
+ canUse: zodOpenapi.z.array(CanUseItemSchema),
1651
1652
  dataComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
1652
1653
  artifactComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
1653
1654
  canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
@@ -2609,16 +2610,21 @@ var getRelatedAgentsForGraph = (db) => async (params) => {
2609
2610
  name: agents.name,
2610
2611
  description: agents.description,
2611
2612
  relationType: agentRelations.relationType
2612
- }).from(agentRelations).innerJoin(agents, drizzleOrm.eq(agentRelations.targetAgentId, agents.id)).where(
2613
+ }).from(agentRelations).innerJoin(
2614
+ agents,
2615
+ drizzleOrm.and(
2616
+ drizzleOrm.eq(agentRelations.targetAgentId, agents.id),
2617
+ drizzleOrm.eq(agentRelations.tenantId, agents.tenantId),
2618
+ drizzleOrm.eq(agentRelations.projectId, agents.projectId),
2619
+ drizzleOrm.eq(agentRelations.graphId, agents.graphId)
2620
+ )
2621
+ ).where(
2613
2622
  drizzleOrm.and(
2614
2623
  drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
2615
2624
  drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
2616
2625
  drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
2617
2626
  drizzleOrm.eq(agentRelations.sourceAgentId, params.agentId),
2618
- drizzleOrm.isNotNull(agentRelations.targetAgentId),
2619
- drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
2620
- drizzleOrm.eq(agents.projectId, params.scopes.projectId),
2621
- drizzleOrm.eq(agents.graphId, params.scopes.graphId)
2627
+ drizzleOrm.isNotNull(agentRelations.targetAgentId)
2622
2628
  )
2623
2629
  );
2624
2630
  const externalRelations = await db.select({
@@ -2630,16 +2636,21 @@ var getRelatedAgentsForGraph = (db) => async (params) => {
2630
2636
  description: externalAgents.description,
2631
2637
  baseUrl: externalAgents.baseUrl
2632
2638
  }
2633
- }).from(agentRelations).innerJoin(externalAgents, drizzleOrm.eq(agentRelations.externalAgentId, externalAgents.id)).where(
2639
+ }).from(agentRelations).innerJoin(
2640
+ externalAgents,
2641
+ drizzleOrm.and(
2642
+ drizzleOrm.eq(agentRelations.externalAgentId, externalAgents.id),
2643
+ drizzleOrm.eq(agentRelations.tenantId, externalAgents.tenantId),
2644
+ drizzleOrm.eq(agentRelations.projectId, externalAgents.projectId),
2645
+ drizzleOrm.eq(agentRelations.graphId, externalAgents.graphId)
2646
+ )
2647
+ ).where(
2634
2648
  drizzleOrm.and(
2635
2649
  drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
2636
2650
  drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
2637
2651
  drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
2638
2652
  drizzleOrm.eq(agentRelations.sourceAgentId, params.agentId),
2639
- drizzleOrm.isNotNull(agentRelations.externalAgentId),
2640
- drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
2641
- drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
2642
- drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId)
2653
+ drizzleOrm.isNotNull(agentRelations.externalAgentId)
2643
2654
  )
2644
2655
  );
2645
2656
  return {
@@ -2902,7 +2913,14 @@ var getToolsForAgent = (db) => async (params) => {
2902
2913
  availableTools: tools.availableTools,
2903
2914
  credentialReferenceId: tools.credentialReferenceId
2904
2915
  }
2905
- }).from(agentToolRelations).innerJoin(tools, drizzleOrm.eq(agentToolRelations.toolId, tools.id)).where(
2916
+ }).from(agentToolRelations).innerJoin(
2917
+ tools,
2918
+ drizzleOrm.and(
2919
+ drizzleOrm.eq(agentToolRelations.tenantId, tools.tenantId),
2920
+ drizzleOrm.eq(agentToolRelations.projectId, tools.projectId),
2921
+ drizzleOrm.eq(agentToolRelations.toolId, tools.id)
2922
+ )
2923
+ ).where(
2906
2924
  drizzleOrm.and(
2907
2925
  drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
2908
2926
  drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
@@ -2950,7 +2968,15 @@ var getAgentsForTool = (db) => async (params) => {
2950
2968
  createdAt: agents.createdAt,
2951
2969
  updatedAt: agents.updatedAt
2952
2970
  }
2953
- }).from(agentToolRelations).innerJoin(agents, drizzleOrm.eq(agentToolRelations.agentId, agents.id)).where(
2971
+ }).from(agentToolRelations).innerJoin(
2972
+ agents,
2973
+ drizzleOrm.and(
2974
+ drizzleOrm.eq(agentToolRelations.agentId, agents.id),
2975
+ drizzleOrm.eq(agentToolRelations.tenantId, agents.tenantId),
2976
+ drizzleOrm.eq(agentToolRelations.projectId, agents.projectId),
2977
+ drizzleOrm.eq(agentToolRelations.graphId, agents.graphId)
2978
+ )
2979
+ ).where(
2954
2980
  drizzleOrm.and(
2955
2981
  drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
2956
2982
  drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
@@ -3637,8 +3663,20 @@ var getFullGraphDefinition = (db) => async ({
3637
3663
  availableTools: tools.availableTools,
3638
3664
  lastToolsSync: tools.lastToolsSync,
3639
3665
  selectedTools: agentToolRelations.selectedTools
3640
- }).from(agentToolRelations).innerJoin(tools, drizzleOrm.eq(agentToolRelations.toolId, tools.id)).where(
3641
- drizzleOrm.and(drizzleOrm.eq(agentToolRelations.tenantId, tenantId), drizzleOrm.eq(agentToolRelations.agentId, agent.id))
3666
+ }).from(agentToolRelations).innerJoin(
3667
+ tools,
3668
+ drizzleOrm.and(
3669
+ drizzleOrm.eq(agentToolRelations.toolId, tools.id),
3670
+ drizzleOrm.eq(agentToolRelations.tenantId, tools.tenantId),
3671
+ drizzleOrm.eq(agentToolRelations.projectId, tools.projectId)
3672
+ )
3673
+ ).where(
3674
+ drizzleOrm.and(
3675
+ drizzleOrm.eq(agentToolRelations.tenantId, tenantId),
3676
+ drizzleOrm.eq(agentToolRelations.projectId, projectId),
3677
+ drizzleOrm.eq(agentToolRelations.graphId, graphId),
3678
+ drizzleOrm.eq(agentToolRelations.agentId, agent.id)
3679
+ )
3642
3680
  );
3643
3681
  const agentDataComponentRelations = await db.query.agentDataComponents.findMany({
3644
3682
  where: drizzleOrm.and(
@@ -3656,12 +3694,10 @@ var getFullGraphDefinition = (db) => async ({
3656
3694
  const agentArtifactComponentIds = agentArtifactComponentRelations.map(
3657
3695
  (rel) => rel.artifactComponentId
3658
3696
  );
3659
- const selectedTools = {};
3660
- agentTools.forEach((tool2) => {
3661
- if (tool2.selectedTools && Array.isArray(tool2.selectedTools)) {
3662
- selectedTools[tool2.id] = tool2.selectedTools;
3663
- }
3664
- });
3697
+ const canUse = agentTools.map((tool2) => ({
3698
+ toolId: tool2.id,
3699
+ toolSelection: tool2.selectedTools || null
3700
+ }));
3665
3701
  return {
3666
3702
  id: agent.id,
3667
3703
  name: agent.name,
@@ -3673,20 +3709,8 @@ var getFullGraphDefinition = (db) => async ({
3673
3709
  canDelegateTo,
3674
3710
  dataComponents: agentDataComponentIds,
3675
3711
  artifactComponents: agentArtifactComponentIds,
3676
- ...Object.keys(selectedTools).length > 0 && { selectedTools },
3677
- tools: agentTools.map((tool2) => ({
3678
- id: tool2.id,
3679
- name: tool2.name,
3680
- config: tool2.config,
3681
- imageUrl: tool2.imageUrl || void 0,
3682
- status: tool2.status,
3683
- capabilities: tool2.capabilities || void 0,
3684
- lastHealthCheck: tool2.lastHealthCheck && !Number.isNaN(new Date(tool2.lastHealthCheck).getTime()) ? new Date(tool2.lastHealthCheck).toISOString() : void 0,
3685
- lastError: tool2.lastError || void 0,
3686
- availableTools: tool2.availableTools || void 0,
3687
- activeTools: tool2.config?.mcp?.activeTools || void 0,
3688
- lastToolsSync: tool2.lastToolsSync && !Number.isNaN(new Date(tool2.lastToolsSync).getTime()) ? new Date(tool2.lastToolsSync).toISOString() : void 0
3689
- }))
3712
+ canUse
3713
+ // Use the new canUse structure
3690
3714
  };
3691
3715
  })
3692
3716
  );
@@ -3709,7 +3733,6 @@ var getFullGraphDefinition = (db) => async ({
3709
3733
  (agent) => agent !== null
3710
3734
  );
3711
3735
  const agentsObject = {};
3712
- const toolsObject = {};
3713
3736
  for (const agent of validAgents) {
3714
3737
  const isExternalAgent2 = "baseUrl" in agent && agent.baseUrl;
3715
3738
  if (isExternalAgent2) {
@@ -3720,22 +3743,7 @@ var getFullGraphDefinition = (db) => async ({
3720
3743
  baseUrl: agent.baseUrl
3721
3744
  };
3722
3745
  } else {
3723
- const toolsData = agent.tools || [];
3724
- const toolIds = [];
3725
- const agentSelectedTools = {};
3726
- for (const tool2 of toolsData) {
3727
- toolsObject[tool2.id] = tool2;
3728
- toolIds.push(tool2.id);
3729
- if (tool2.selectedTools !== null && tool2.selectedTools !== void 0) {
3730
- agentSelectedTools[tool2.id] = tool2.selectedTools;
3731
- }
3732
- }
3733
- agentsObject[agent.id] = {
3734
- ...agent,
3735
- tools: toolIds,
3736
- // Replace tool objects with tool IDs
3737
- ...Object.keys(agentSelectedTools).length > 0 && { selectedTools: agentSelectedTools }
3738
- };
3746
+ agentsObject[agent.id] = agent;
3739
3747
  }
3740
3748
  }
3741
3749
  let contextConfig2 = null;
@@ -3749,11 +3757,10 @@ var getFullGraphDefinition = (db) => async ({
3749
3757
  console.warn(`Failed to retrieve contextConfig ${graph.contextConfigId}:`, error);
3750
3758
  }
3751
3759
  }
3752
- let dataComponentsObject = {};
3753
3760
  try {
3754
3761
  const internalAgentIds = graphAgents.map((agent) => agent.id);
3755
3762
  const agentIds = Array.from(internalAgentIds);
3756
- dataComponentsObject = await fetchComponentRelationships(db)(
3763
+ await fetchComponentRelationships(db)(
3757
3764
  { tenantId, projectId },
3758
3765
  agentIds,
3759
3766
  {
@@ -3772,11 +3779,10 @@ var getFullGraphDefinition = (db) => async ({
3772
3779
  } catch (error) {
3773
3780
  console.warn("Failed to retrieve dataComponents:", error);
3774
3781
  }
3775
- let artifactComponentsObject = {};
3776
3782
  try {
3777
3783
  const internalAgentIds = graphAgents.map((agent) => agent.id);
3778
3784
  const agentIds = Array.from(internalAgentIds);
3779
- artifactComponentsObject = await fetchComponentRelationships(db)(
3785
+ await fetchComponentRelationships(db)(
3780
3786
  { tenantId, projectId },
3781
3787
  agentIds,
3782
3788
  {
@@ -3802,7 +3808,7 @@ var getFullGraphDefinition = (db) => async ({
3802
3808
  description: graph.description,
3803
3809
  defaultAgentId: graph.defaultAgentId,
3804
3810
  agents: agentsObject,
3805
- tools: toolsObject,
3811
+ // No tools field - tools are defined at project level
3806
3812
  createdAt: graph.createdAt && !Number.isNaN(new Date(graph.createdAt).getTime()) ? new Date(graph.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
3807
3813
  updatedAt: graph.updatedAt && !Number.isNaN(new Date(graph.updatedAt).getTime()) ? new Date(graph.updatedAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
3808
3814
  };
@@ -3827,12 +3833,6 @@ var getFullGraphDefinition = (db) => async ({
3827
3833
  contextVariables: contextConfig2.contextVariables
3828
3834
  };
3829
3835
  }
3830
- if (Object.keys(dataComponentsObject).length > 0) {
3831
- result.dataComponents = dataComponentsObject;
3832
- }
3833
- if (Object.keys(artifactComponentsObject).length > 0) {
3834
- result.artifactComponents = artifactComponentsObject;
3835
- }
3836
3836
  try {
3837
3837
  if (!db.query?.projects?.findFirst) {
3838
3838
  return result;
@@ -4304,7 +4304,21 @@ var isArtifactComponentAssociatedWithAgent = (db) => async (params) => {
4304
4304
  return result.length > 0;
4305
4305
  };
4306
4306
  var graphHasArtifactComponents = (db) => async (params) => {
4307
- const result = await db.select({ count: drizzleOrm.count() }).from(agentArtifactComponents).innerJoin(agents, drizzleOrm.eq(agentArtifactComponents.agentId, agents.id)).innerJoin(agentRelations, drizzleOrm.eq(agents.id, agentRelations.sourceAgentId)).where(
4307
+ const result = await db.select({ count: drizzleOrm.count() }).from(agentArtifactComponents).innerJoin(
4308
+ agents,
4309
+ drizzleOrm.and(
4310
+ drizzleOrm.eq(agentArtifactComponents.agentId, agents.id),
4311
+ drizzleOrm.eq(agentArtifactComponents.tenantId, agents.tenantId)
4312
+ )
4313
+ ).innerJoin(
4314
+ agentRelations,
4315
+ drizzleOrm.and(
4316
+ drizzleOrm.eq(agents.id, agentRelations.sourceAgentId),
4317
+ drizzleOrm.eq(agents.tenantId, agentRelations.tenantId),
4318
+ drizzleOrm.eq(agents.projectId, agentRelations.projectId),
4319
+ drizzleOrm.eq(agents.graphId, agentRelations.graphId)
4320
+ )
4321
+ ).where(
4308
4322
  drizzleOrm.and(
4309
4323
  drizzleOrm.eq(agentArtifactComponents.tenantId, params.scopes.tenantId),
4310
4324
  drizzleOrm.eq(agentArtifactComponents.projectId, params.scopes.projectId),
@@ -5067,10 +5081,10 @@ function validateToolReferences(graphData, availableToolIds) {
5067
5081
  }
5068
5082
  const errors = [];
5069
5083
  for (const [agentId, agentData] of Object.entries(graphData.agents)) {
5070
- if (isInternalAgent(agentData) && agentData.tools && Array.isArray(agentData.tools)) {
5071
- for (const toolId of agentData.tools) {
5072
- if (!availableToolIds.has(toolId)) {
5073
- errors.push(`Agent '${agentId}' references non-existent tool '${toolId}'`);
5084
+ if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
5085
+ for (const canUseItem of agentData.canUse) {
5086
+ if (!availableToolIds.has(canUseItem.toolId)) {
5087
+ errors.push(`Agent '${agentId}' references non-existent tool '${canUseItem.toolId}'`);
5074
5088
  }
5075
5089
  }
5076
5090
  }
@@ -5605,22 +5619,22 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
5605
5619
  }
5606
5620
  const agentToolPromises = [];
5607
5621
  for (const [agentId, agentData] of Object.entries(typed.agents)) {
5608
- if (isInternalAgent(agentData) && agentData.tools && Array.isArray(agentData.tools)) {
5609
- for (const toolId of agentData.tools) {
5622
+ if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
5623
+ for (const canUseItem of agentData.canUse) {
5610
5624
  agentToolPromises.push(
5611
5625
  (async () => {
5612
5626
  try {
5613
- const selectedTools = agentData.selectedTools?.[toolId];
5627
+ const { toolId, toolSelection } = canUseItem;
5614
5628
  logger11.info({ agentId, toolId }, "Processing agent-tool relation");
5615
5629
  await upsertAgentToolRelation(db)({
5616
5630
  scopes: { tenantId, projectId, graphId: finalGraphId },
5617
5631
  agentId,
5618
5632
  toolId,
5619
- selectedTools
5633
+ selectedTools: toolSelection || void 0
5620
5634
  });
5621
5635
  logger11.info({ agentId, toolId }, "Agent-tool relation processed successfully");
5622
5636
  } catch (error) {
5623
- logger11.error({ agentId, toolId, error }, "Failed to create agent-tool relation");
5637
+ logger11.error({ agentId, toolId: canUseItem.toolId, error }, "Failed to create agent-tool relation");
5624
5638
  }
5625
5639
  })()
5626
5640
  );
@@ -5998,23 +6012,23 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
5998
6012
  }
5999
6013
  const agentToolPromises = [];
6000
6014
  for (const [agentId, agentData] of Object.entries(typedGraphDefinition.agents)) {
6001
- if (isInternalAgent(agentData) && agentData.tools && Array.isArray(agentData.tools)) {
6002
- for (const toolId of agentData.tools) {
6015
+ if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
6016
+ for (const canUseItem of agentData.canUse) {
6003
6017
  agentToolPromises.push(
6004
6018
  (async () => {
6005
6019
  try {
6006
- const selectedTools = agentData.selectedTools?.[toolId];
6020
+ const { toolId, toolSelection } = canUseItem;
6007
6021
  await createAgentToolRelation(db)({
6008
6022
  scopes: { tenantId, projectId, graphId: finalGraphId },
6009
6023
  data: {
6010
6024
  agentId,
6011
6025
  toolId,
6012
- selectedTools
6026
+ selectedTools: toolSelection || void 0
6013
6027
  }
6014
6028
  });
6015
6029
  logger11.info({ agentId, toolId }, "Agent-tool relation created");
6016
6030
  } catch (error) {
6017
- logger11.error({ agentId, toolId, error }, "Failed to create agent-tool relation");
6031
+ logger11.error({ agentId, toolId: canUseItem.toolId, error }, "Failed to create agent-tool relation");
6018
6032
  }
6019
6033
  })()
6020
6034
  );
@@ -6878,7 +6892,6 @@ var createFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scop
6878
6892
  );
6879
6893
  await upsertArtifactComponent(db)({
6880
6894
  data: {
6881
- id: componentId,
6882
6895
  ...componentData,
6883
6896
  tenantId,
6884
6897
  projectId: typed.id
@@ -7184,7 +7197,6 @@ var updateFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scop
7184
7197
  );
7185
7198
  await upsertArtifactComponent(db)({
7186
7199
  data: {
7187
- id: componentId,
7188
7200
  ...componentData,
7189
7201
  tenantId,
7190
7202
  projectId: typed.id
@@ -7310,14 +7322,10 @@ var getFullProject = (db, logger11 = defaultLogger2) => async (params) => {
7310
7322
  id: tool2.id,
7311
7323
  name: tool2.name,
7312
7324
  config: tool2.config,
7313
- imageUrl: tool2.imageUrl || void 0,
7314
- status: tool2.status,
7315
- capabilities: tool2.capabilities || void 0,
7316
- lastHealthCheck: tool2.lastHealthCheck && !Number.isNaN(new Date(tool2.lastHealthCheck).getTime()) ? new Date(tool2.lastHealthCheck).toISOString() : void 0,
7317
- lastError: tool2.lastError || void 0,
7318
- availableTools: tool2.availableTools || void 0,
7319
- activeTools: tool2.config?.mcp?.activeTools || void 0,
7320
- lastToolsSync: tool2.lastToolsSync && !Number.isNaN(new Date(tool2.lastToolsSync).getTime()) ? new Date(tool2.lastToolsSync).toISOString() : void 0
7325
+ credentialReferenceId: tool2.credentialReferenceId || void 0,
7326
+ imageUrl: tool2.imageUrl || void 0
7327
+ // Don't include runtime fields in configuration
7328
+ // status, capabilities, lastHealthCheck, lastError, availableTools, activeTools, lastToolsSync are all runtime
7321
7329
  };
7322
7330
  }
7323
7331
  logger11.info(
@@ -10233,7 +10241,7 @@ var loadEnvironmentFiles = () => {
10233
10241
  loadEnvironmentFiles();
10234
10242
  var envSchema = zod.z.object({
10235
10243
  ENVIRONMENT: zod.z.enum(["development", "production", "pentest", "test"]).optional(),
10236
- DB_FILE_NAME: zod.z.string(),
10244
+ DB_FILE_NAME: zod.z.string().optional(),
10237
10245
  OTEL_TRACES_FORCE_FLUSH_ENABLED: zod.z.coerce.boolean().optional()
10238
10246
  });
10239
10247
  var parseEnv = () => {
@@ -10323,6 +10331,7 @@ exports.ArtifactComponentApiUpdateSchema = ArtifactComponentApiUpdateSchema;
10323
10331
  exports.ArtifactComponentInsertSchema = ArtifactComponentInsertSchema;
10324
10332
  exports.ArtifactComponentSelectSchema = ArtifactComponentSelectSchema;
10325
10333
  exports.ArtifactComponentUpdateSchema = ArtifactComponentUpdateSchema;
10334
+ exports.CanUseItemSchema = CanUseItemSchema;
10326
10335
  exports.ContextCache = ContextCache;
10327
10336
  exports.ContextCacheApiInsertSchema = ContextCacheApiInsertSchema;
10328
10337
  exports.ContextCacheApiSelectSchema = ContextCacheApiSelectSchema;
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  export { TaskState } from './chunk-H2F72PDA.js';
2
- import { validateAndTypeGraphData, validateGraphStructure, isInternalAgent, isExternalAgent } from './chunk-IIW7VAP3.js';
3
- export { generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAndTypeGraphData, validateArtifactComponentReferences, validateDataComponentReferences, validateGraphStructure, validateToolReferences } from './chunk-IIW7VAP3.js';
4
- import { ContextConfigApiUpdateSchema } from './chunk-ZORVFHVU.js';
5
- export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiSelectSchema, AgentArtifactComponentApiUpdateSchema, AgentArtifactComponentInsertSchema, AgentArtifactComponentSelectSchema, AgentArtifactComponentUpdateSchema, AgentDataComponentApiInsertSchema, AgentDataComponentApiSelectSchema, AgentDataComponentApiUpdateSchema, AgentDataComponentInsertSchema, AgentDataComponentSelectSchema, AgentDataComponentUpdateSchema, AgentGraphApiInsertSchema, AgentGraphApiSelectSchema, AgentGraphApiUpdateSchema, AgentGraphInsertSchema, AgentGraphSelectSchema, AgentGraphUpdateSchema, AgentInsertSchema, AgentRelationApiInsertSchema, AgentRelationApiSelectSchema, AgentRelationApiUpdateSchema, AgentRelationInsertSchema, AgentRelationQuerySchema, AgentRelationSelectSchema, AgentRelationUpdateSchema, AgentSelectSchema, AgentStopWhenSchema, AgentToolRelationApiInsertSchema, AgentToolRelationApiSelectSchema, AgentToolRelationApiUpdateSchema, AgentToolRelationInsertSchema, AgentToolRelationSelectSchema, AgentToolRelationUpdateSchema, AgentUpdateSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentInsertSchema, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, 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, ExternalAgentRelationApiInsertSchema, ExternalAgentRelationInsertSchema, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, FetchConfigSchema, FetchDefinitionSchema, FullGraphAgentInsertSchema, FullGraphDefinitionSchema, FullProjectDefinitionSchema, GraphStopWhenSchema, GraphWithinContextOfProjectSchema, HeadersScopeSchema, IdParamsSchema, 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, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectGraphIdParamsSchema, TenantProjectGraphParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema } from './chunk-ZORVFHVU.js';
6
- import { schema_exports, agentRelations, agents, externalAgents, agentToolRelations, tools, contextConfigs, agentGraph, agentDataComponents, agentArtifactComponents, dataComponents, artifactComponents, projects, apiKeys, contextCache, conversations, messages, credentialReferences, ledgerArtifacts, tasks, taskRelations } from './chunk-LFWFXR4O.js';
7
- export { agentArtifactComponents, agentArtifactComponentsRelations, agentDataComponents, agentDataComponentsRelations, agentGraph, agentGraphRelations, agentRelations, agentRelationsRelations, agentToolRelations, agentToolRelationsRelations, agents, agentsRelations, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, ledgerArtifacts, ledgerArtifactsContextIdIdx, ledgerArtifactsRelations, ledgerArtifactsTaskContextNameUnique, ledgerArtifactsTaskIdIdx, messages, messagesRelations, projects, projectsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations } from './chunk-LFWFXR4O.js';
2
+ import { validateAndTypeGraphData, validateGraphStructure, isInternalAgent, isExternalAgent } from './chunk-BE5QULB4.js';
3
+ export { generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAndTypeGraphData, validateArtifactComponentReferences, validateDataComponentReferences, validateGraphStructure, validateToolReferences } from './chunk-BE5QULB4.js';
4
+ import { ContextConfigApiUpdateSchema } from './chunk-GL4IGNT7.js';
5
+ export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiSelectSchema, AgentArtifactComponentApiUpdateSchema, AgentArtifactComponentInsertSchema, AgentArtifactComponentSelectSchema, AgentArtifactComponentUpdateSchema, AgentDataComponentApiInsertSchema, AgentDataComponentApiSelectSchema, AgentDataComponentApiUpdateSchema, AgentDataComponentInsertSchema, AgentDataComponentSelectSchema, AgentDataComponentUpdateSchema, AgentGraphApiInsertSchema, AgentGraphApiSelectSchema, AgentGraphApiUpdateSchema, AgentGraphInsertSchema, AgentGraphSelectSchema, AgentGraphUpdateSchema, AgentInsertSchema, AgentRelationApiInsertSchema, AgentRelationApiSelectSchema, AgentRelationApiUpdateSchema, AgentRelationInsertSchema, AgentRelationQuerySchema, AgentRelationSelectSchema, AgentRelationUpdateSchema, AgentSelectSchema, AgentStopWhenSchema, AgentToolRelationApiInsertSchema, AgentToolRelationApiSelectSchema, AgentToolRelationApiUpdateSchema, AgentToolRelationInsertSchema, AgentToolRelationSelectSchema, AgentToolRelationUpdateSchema, AgentUpdateSchema, 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, ExternalAgentRelationApiInsertSchema, ExternalAgentRelationInsertSchema, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, FetchConfigSchema, FetchDefinitionSchema, FullGraphAgentInsertSchema, FullGraphDefinitionSchema, FullProjectDefinitionSchema, GraphStopWhenSchema, GraphWithinContextOfProjectSchema, HeadersScopeSchema, IdParamsSchema, 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, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectGraphIdParamsSchema, TenantProjectGraphParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema } from './chunk-GL4IGNT7.js';
8
6
  import { CredentialStoreType, MCPServerType, MCPTransportType } from './chunk-SVGQSPW4.js';
9
7
  export { CredentialStoreType, MCPServerType, MCPTransportType, TOOL_STATUS_VALUES, VALID_RELATION_TYPES } from './chunk-SVGQSPW4.js';
8
+ import { schema_exports, agentRelations, agents, externalAgents, agentToolRelations, tools, contextConfigs, agentGraph, agentDataComponents, agentArtifactComponents, dataComponents, artifactComponents, projects, apiKeys, contextCache, conversations, messages, credentialReferences, ledgerArtifacts, tasks, taskRelations } from './chunk-LFWFXR4O.js';
9
+ export { agentArtifactComponents, agentArtifactComponentsRelations, agentDataComponents, agentDataComponentsRelations, agentGraph, agentGraphRelations, agentRelations, agentRelationsRelations, agentToolRelations, agentToolRelationsRelations, agents, agentsRelations, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, ledgerArtifacts, ledgerArtifactsContextIdIdx, ledgerArtifactsRelations, ledgerArtifactsTaskContextNameUnique, ledgerArtifactsTaskIdIdx, messages, messagesRelations, projects, projectsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations } from './chunk-LFWFXR4O.js';
10
10
  import { __publicField } from './chunk-MKBO26DX.js';
11
11
  import { z as z$1 } from 'zod';
12
12
  import pino from 'pino';
@@ -981,16 +981,21 @@ var getRelatedAgentsForGraph = (db) => async (params) => {
981
981
  name: agents.name,
982
982
  description: agents.description,
983
983
  relationType: agentRelations.relationType
984
- }).from(agentRelations).innerJoin(agents, eq(agentRelations.targetAgentId, agents.id)).where(
984
+ }).from(agentRelations).innerJoin(
985
+ agents,
986
+ and(
987
+ eq(agentRelations.targetAgentId, agents.id),
988
+ eq(agentRelations.tenantId, agents.tenantId),
989
+ eq(agentRelations.projectId, agents.projectId),
990
+ eq(agentRelations.graphId, agents.graphId)
991
+ )
992
+ ).where(
985
993
  and(
986
994
  eq(agentRelations.tenantId, params.scopes.tenantId),
987
995
  eq(agentRelations.projectId, params.scopes.projectId),
988
996
  eq(agentRelations.graphId, params.scopes.graphId),
989
997
  eq(agentRelations.sourceAgentId, params.agentId),
990
- isNotNull(agentRelations.targetAgentId),
991
- eq(agents.tenantId, params.scopes.tenantId),
992
- eq(agents.projectId, params.scopes.projectId),
993
- eq(agents.graphId, params.scopes.graphId)
998
+ isNotNull(agentRelations.targetAgentId)
994
999
  )
995
1000
  );
996
1001
  const externalRelations = await db.select({
@@ -1002,16 +1007,21 @@ var getRelatedAgentsForGraph = (db) => async (params) => {
1002
1007
  description: externalAgents.description,
1003
1008
  baseUrl: externalAgents.baseUrl
1004
1009
  }
1005
- }).from(agentRelations).innerJoin(externalAgents, eq(agentRelations.externalAgentId, externalAgents.id)).where(
1010
+ }).from(agentRelations).innerJoin(
1011
+ externalAgents,
1012
+ and(
1013
+ eq(agentRelations.externalAgentId, externalAgents.id),
1014
+ eq(agentRelations.tenantId, externalAgents.tenantId),
1015
+ eq(agentRelations.projectId, externalAgents.projectId),
1016
+ eq(agentRelations.graphId, externalAgents.graphId)
1017
+ )
1018
+ ).where(
1006
1019
  and(
1007
1020
  eq(agentRelations.tenantId, params.scopes.tenantId),
1008
1021
  eq(agentRelations.projectId, params.scopes.projectId),
1009
1022
  eq(agentRelations.graphId, params.scopes.graphId),
1010
1023
  eq(agentRelations.sourceAgentId, params.agentId),
1011
- isNotNull(agentRelations.externalAgentId),
1012
- eq(externalAgents.tenantId, params.scopes.tenantId),
1013
- eq(externalAgents.projectId, params.scopes.projectId),
1014
- eq(externalAgents.graphId, params.scopes.graphId)
1024
+ isNotNull(agentRelations.externalAgentId)
1015
1025
  )
1016
1026
  );
1017
1027
  return {
@@ -1274,7 +1284,14 @@ var getToolsForAgent = (db) => async (params) => {
1274
1284
  availableTools: tools.availableTools,
1275
1285
  credentialReferenceId: tools.credentialReferenceId
1276
1286
  }
1277
- }).from(agentToolRelations).innerJoin(tools, eq(agentToolRelations.toolId, tools.id)).where(
1287
+ }).from(agentToolRelations).innerJoin(
1288
+ tools,
1289
+ and(
1290
+ eq(agentToolRelations.tenantId, tools.tenantId),
1291
+ eq(agentToolRelations.projectId, tools.projectId),
1292
+ eq(agentToolRelations.toolId, tools.id)
1293
+ )
1294
+ ).where(
1278
1295
  and(
1279
1296
  eq(agentToolRelations.tenantId, params.scopes.tenantId),
1280
1297
  eq(agentToolRelations.projectId, params.scopes.projectId),
@@ -1322,7 +1339,15 @@ var getAgentsForTool = (db) => async (params) => {
1322
1339
  createdAt: agents.createdAt,
1323
1340
  updatedAt: agents.updatedAt
1324
1341
  }
1325
- }).from(agentToolRelations).innerJoin(agents, eq(agentToolRelations.agentId, agents.id)).where(
1342
+ }).from(agentToolRelations).innerJoin(
1343
+ agents,
1344
+ and(
1345
+ eq(agentToolRelations.agentId, agents.id),
1346
+ eq(agentToolRelations.tenantId, agents.tenantId),
1347
+ eq(agentToolRelations.projectId, agents.projectId),
1348
+ eq(agentToolRelations.graphId, agents.graphId)
1349
+ )
1350
+ ).where(
1326
1351
  and(
1327
1352
  eq(agentToolRelations.tenantId, params.scopes.tenantId),
1328
1353
  eq(agentToolRelations.projectId, params.scopes.projectId),
@@ -2009,8 +2034,20 @@ var getFullGraphDefinition = (db) => async ({
2009
2034
  availableTools: tools.availableTools,
2010
2035
  lastToolsSync: tools.lastToolsSync,
2011
2036
  selectedTools: agentToolRelations.selectedTools
2012
- }).from(agentToolRelations).innerJoin(tools, eq(agentToolRelations.toolId, tools.id)).where(
2013
- and(eq(agentToolRelations.tenantId, tenantId), eq(agentToolRelations.agentId, agent.id))
2037
+ }).from(agentToolRelations).innerJoin(
2038
+ tools,
2039
+ and(
2040
+ eq(agentToolRelations.toolId, tools.id),
2041
+ eq(agentToolRelations.tenantId, tools.tenantId),
2042
+ eq(agentToolRelations.projectId, tools.projectId)
2043
+ )
2044
+ ).where(
2045
+ and(
2046
+ eq(agentToolRelations.tenantId, tenantId),
2047
+ eq(agentToolRelations.projectId, projectId),
2048
+ eq(agentToolRelations.graphId, graphId),
2049
+ eq(agentToolRelations.agentId, agent.id)
2050
+ )
2014
2051
  );
2015
2052
  const agentDataComponentRelations = await db.query.agentDataComponents.findMany({
2016
2053
  where: and(
@@ -2028,12 +2065,10 @@ var getFullGraphDefinition = (db) => async ({
2028
2065
  const agentArtifactComponentIds = agentArtifactComponentRelations.map(
2029
2066
  (rel) => rel.artifactComponentId
2030
2067
  );
2031
- const selectedTools = {};
2032
- agentTools.forEach((tool2) => {
2033
- if (tool2.selectedTools && Array.isArray(tool2.selectedTools)) {
2034
- selectedTools[tool2.id] = tool2.selectedTools;
2035
- }
2036
- });
2068
+ const canUse = agentTools.map((tool2) => ({
2069
+ toolId: tool2.id,
2070
+ toolSelection: tool2.selectedTools || null
2071
+ }));
2037
2072
  return {
2038
2073
  id: agent.id,
2039
2074
  name: agent.name,
@@ -2045,20 +2080,8 @@ var getFullGraphDefinition = (db) => async ({
2045
2080
  canDelegateTo,
2046
2081
  dataComponents: agentDataComponentIds,
2047
2082
  artifactComponents: agentArtifactComponentIds,
2048
- ...Object.keys(selectedTools).length > 0 && { selectedTools },
2049
- tools: agentTools.map((tool2) => ({
2050
- id: tool2.id,
2051
- name: tool2.name,
2052
- config: tool2.config,
2053
- imageUrl: tool2.imageUrl || void 0,
2054
- status: tool2.status,
2055
- capabilities: tool2.capabilities || void 0,
2056
- lastHealthCheck: tool2.lastHealthCheck && !Number.isNaN(new Date(tool2.lastHealthCheck).getTime()) ? new Date(tool2.lastHealthCheck).toISOString() : void 0,
2057
- lastError: tool2.lastError || void 0,
2058
- availableTools: tool2.availableTools || void 0,
2059
- activeTools: tool2.config?.mcp?.activeTools || void 0,
2060
- lastToolsSync: tool2.lastToolsSync && !Number.isNaN(new Date(tool2.lastToolsSync).getTime()) ? new Date(tool2.lastToolsSync).toISOString() : void 0
2061
- }))
2083
+ canUse
2084
+ // Use the new canUse structure
2062
2085
  };
2063
2086
  })
2064
2087
  );
@@ -2081,7 +2104,6 @@ var getFullGraphDefinition = (db) => async ({
2081
2104
  (agent) => agent !== null
2082
2105
  );
2083
2106
  const agentsObject = {};
2084
- const toolsObject = {};
2085
2107
  for (const agent of validAgents) {
2086
2108
  const isExternalAgent2 = "baseUrl" in agent && agent.baseUrl;
2087
2109
  if (isExternalAgent2) {
@@ -2092,22 +2114,7 @@ var getFullGraphDefinition = (db) => async ({
2092
2114
  baseUrl: agent.baseUrl
2093
2115
  };
2094
2116
  } else {
2095
- const toolsData = agent.tools || [];
2096
- const toolIds = [];
2097
- const agentSelectedTools = {};
2098
- for (const tool2 of toolsData) {
2099
- toolsObject[tool2.id] = tool2;
2100
- toolIds.push(tool2.id);
2101
- if (tool2.selectedTools !== null && tool2.selectedTools !== void 0) {
2102
- agentSelectedTools[tool2.id] = tool2.selectedTools;
2103
- }
2104
- }
2105
- agentsObject[agent.id] = {
2106
- ...agent,
2107
- tools: toolIds,
2108
- // Replace tool objects with tool IDs
2109
- ...Object.keys(agentSelectedTools).length > 0 && { selectedTools: agentSelectedTools }
2110
- };
2117
+ agentsObject[agent.id] = agent;
2111
2118
  }
2112
2119
  }
2113
2120
  let contextConfig2 = null;
@@ -2121,11 +2128,10 @@ var getFullGraphDefinition = (db) => async ({
2121
2128
  console.warn(`Failed to retrieve contextConfig ${graph.contextConfigId}:`, error);
2122
2129
  }
2123
2130
  }
2124
- let dataComponentsObject = {};
2125
2131
  try {
2126
2132
  const internalAgentIds = graphAgents.map((agent) => agent.id);
2127
2133
  const agentIds = Array.from(internalAgentIds);
2128
- dataComponentsObject = await fetchComponentRelationships(db)(
2134
+ await fetchComponentRelationships(db)(
2129
2135
  { tenantId, projectId },
2130
2136
  agentIds,
2131
2137
  {
@@ -2144,11 +2150,10 @@ var getFullGraphDefinition = (db) => async ({
2144
2150
  } catch (error) {
2145
2151
  console.warn("Failed to retrieve dataComponents:", error);
2146
2152
  }
2147
- let artifactComponentsObject = {};
2148
2153
  try {
2149
2154
  const internalAgentIds = graphAgents.map((agent) => agent.id);
2150
2155
  const agentIds = Array.from(internalAgentIds);
2151
- artifactComponentsObject = await fetchComponentRelationships(db)(
2156
+ await fetchComponentRelationships(db)(
2152
2157
  { tenantId, projectId },
2153
2158
  agentIds,
2154
2159
  {
@@ -2174,7 +2179,7 @@ var getFullGraphDefinition = (db) => async ({
2174
2179
  description: graph.description,
2175
2180
  defaultAgentId: graph.defaultAgentId,
2176
2181
  agents: agentsObject,
2177
- tools: toolsObject,
2182
+ // No tools field - tools are defined at project level
2178
2183
  createdAt: graph.createdAt && !Number.isNaN(new Date(graph.createdAt).getTime()) ? new Date(graph.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
2179
2184
  updatedAt: graph.updatedAt && !Number.isNaN(new Date(graph.updatedAt).getTime()) ? new Date(graph.updatedAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
2180
2185
  };
@@ -2199,12 +2204,6 @@ var getFullGraphDefinition = (db) => async ({
2199
2204
  contextVariables: contextConfig2.contextVariables
2200
2205
  };
2201
2206
  }
2202
- if (Object.keys(dataComponentsObject).length > 0) {
2203
- result.dataComponents = dataComponentsObject;
2204
- }
2205
- if (Object.keys(artifactComponentsObject).length > 0) {
2206
- result.artifactComponents = artifactComponentsObject;
2207
- }
2208
2207
  try {
2209
2208
  if (!db.query?.projects?.findFirst) {
2210
2209
  return result;
@@ -2676,7 +2675,21 @@ var isArtifactComponentAssociatedWithAgent = (db) => async (params) => {
2676
2675
  return result.length > 0;
2677
2676
  };
2678
2677
  var graphHasArtifactComponents = (db) => async (params) => {
2679
- const result = await db.select({ count: count() }).from(agentArtifactComponents).innerJoin(agents, eq(agentArtifactComponents.agentId, agents.id)).innerJoin(agentRelations, eq(agents.id, agentRelations.sourceAgentId)).where(
2678
+ const result = await db.select({ count: count() }).from(agentArtifactComponents).innerJoin(
2679
+ agents,
2680
+ and(
2681
+ eq(agentArtifactComponents.agentId, agents.id),
2682
+ eq(agentArtifactComponents.tenantId, agents.tenantId)
2683
+ )
2684
+ ).innerJoin(
2685
+ agentRelations,
2686
+ and(
2687
+ eq(agents.id, agentRelations.sourceAgentId),
2688
+ eq(agents.tenantId, agentRelations.tenantId),
2689
+ eq(agents.projectId, agentRelations.projectId),
2690
+ eq(agents.graphId, agentRelations.graphId)
2691
+ )
2692
+ ).where(
2680
2693
  and(
2681
2694
  eq(agentArtifactComponents.tenantId, params.scopes.tenantId),
2682
2695
  eq(agentArtifactComponents.projectId, params.scopes.projectId),
@@ -3864,22 +3877,22 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
3864
3877
  }
3865
3878
  const agentToolPromises = [];
3866
3879
  for (const [agentId, agentData] of Object.entries(typed.agents)) {
3867
- if (isInternalAgent(agentData) && agentData.tools && Array.isArray(agentData.tools)) {
3868
- for (const toolId of agentData.tools) {
3880
+ if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
3881
+ for (const canUseItem of agentData.canUse) {
3869
3882
  agentToolPromises.push(
3870
3883
  (async () => {
3871
3884
  try {
3872
- const selectedTools = agentData.selectedTools?.[toolId];
3885
+ const { toolId, toolSelection } = canUseItem;
3873
3886
  logger11.info({ agentId, toolId }, "Processing agent-tool relation");
3874
3887
  await upsertAgentToolRelation(db)({
3875
3888
  scopes: { tenantId, projectId, graphId: finalGraphId },
3876
3889
  agentId,
3877
3890
  toolId,
3878
- selectedTools
3891
+ selectedTools: toolSelection || void 0
3879
3892
  });
3880
3893
  logger11.info({ agentId, toolId }, "Agent-tool relation processed successfully");
3881
3894
  } catch (error) {
3882
- logger11.error({ agentId, toolId, error }, "Failed to create agent-tool relation");
3895
+ logger11.error({ agentId, toolId: canUseItem.toolId, error }, "Failed to create agent-tool relation");
3883
3896
  }
3884
3897
  })()
3885
3898
  );
@@ -4257,23 +4270,23 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
4257
4270
  }
4258
4271
  const agentToolPromises = [];
4259
4272
  for (const [agentId, agentData] of Object.entries(typedGraphDefinition.agents)) {
4260
- if (isInternalAgent(agentData) && agentData.tools && Array.isArray(agentData.tools)) {
4261
- for (const toolId of agentData.tools) {
4273
+ if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
4274
+ for (const canUseItem of agentData.canUse) {
4262
4275
  agentToolPromises.push(
4263
4276
  (async () => {
4264
4277
  try {
4265
- const selectedTools = agentData.selectedTools?.[toolId];
4278
+ const { toolId, toolSelection } = canUseItem;
4266
4279
  await createAgentToolRelation(db)({
4267
4280
  scopes: { tenantId, projectId, graphId: finalGraphId },
4268
4281
  data: {
4269
4282
  agentId,
4270
4283
  toolId,
4271
- selectedTools
4284
+ selectedTools: toolSelection || void 0
4272
4285
  }
4273
4286
  });
4274
4287
  logger11.info({ agentId, toolId }, "Agent-tool relation created");
4275
4288
  } catch (error) {
4276
- logger11.error({ agentId, toolId, error }, "Failed to create agent-tool relation");
4289
+ logger11.error({ agentId, toolId: canUseItem.toolId, error }, "Failed to create agent-tool relation");
4277
4290
  }
4278
4291
  })()
4279
4292
  );
@@ -5137,7 +5150,6 @@ var createFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scop
5137
5150
  );
5138
5151
  await upsertArtifactComponent(db)({
5139
5152
  data: {
5140
- id: componentId,
5141
5153
  ...componentData,
5142
5154
  tenantId,
5143
5155
  projectId: typed.id
@@ -5443,7 +5455,6 @@ var updateFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scop
5443
5455
  );
5444
5456
  await upsertArtifactComponent(db)({
5445
5457
  data: {
5446
- id: componentId,
5447
5458
  ...componentData,
5448
5459
  tenantId,
5449
5460
  projectId: typed.id
@@ -5569,14 +5580,10 @@ var getFullProject = (db, logger11 = defaultLogger2) => async (params) => {
5569
5580
  id: tool2.id,
5570
5581
  name: tool2.name,
5571
5582
  config: tool2.config,
5572
- imageUrl: tool2.imageUrl || void 0,
5573
- status: tool2.status,
5574
- capabilities: tool2.capabilities || void 0,
5575
- lastHealthCheck: tool2.lastHealthCheck && !Number.isNaN(new Date(tool2.lastHealthCheck).getTime()) ? new Date(tool2.lastHealthCheck).toISOString() : void 0,
5576
- lastError: tool2.lastError || void 0,
5577
- availableTools: tool2.availableTools || void 0,
5578
- activeTools: tool2.config?.mcp?.activeTools || void 0,
5579
- lastToolsSync: tool2.lastToolsSync && !Number.isNaN(new Date(tool2.lastToolsSync).getTime()) ? new Date(tool2.lastToolsSync).toISOString() : void 0
5583
+ credentialReferenceId: tool2.credentialReferenceId || void 0,
5584
+ imageUrl: tool2.imageUrl || void 0
5585
+ // Don't include runtime fields in configuration
5586
+ // status, capabilities, lastHealthCheck, lastError, availableTools, activeTools, lastToolsSync are all runtime
5580
5587
  };
5581
5588
  }
5582
5589
  logger11.info(
@@ -8492,7 +8499,7 @@ var loadEnvironmentFiles = () => {
8492
8499
  loadEnvironmentFiles();
8493
8500
  var envSchema = z$1.object({
8494
8501
  ENVIRONMENT: z$1.enum(["development", "production", "pentest", "test"]).optional(),
8495
- DB_FILE_NAME: z$1.string(),
8502
+ DB_FILE_NAME: z$1.string().optional(),
8496
8503
  OTEL_TRACES_FORCE_FLUSH_ENABLED: z$1.coerce.boolean().optional()
8497
8504
  });
8498
8505
  var parseEnv = () => {
@@ -1174,8 +1174,6 @@ var ArtifactComponentApiInsertSchema = ArtifactComponentInsertSchema.omit({
1174
1174
  projectId: true,
1175
1175
  createdAt: true,
1176
1176
  updatedAt: true
1177
- }).extend({
1178
- id: resourceIdSchema.optional()
1179
1177
  });
1180
1178
  var ArtifactComponentApiUpdateSchema = createApiUpdateSchema(
1181
1179
  ArtifactComponentUpdateSchema
@@ -1395,10 +1393,13 @@ var StatusUpdateSchema = zodOpenapi.z.object({
1395
1393
  prompt: zodOpenapi.z.string().max(2e3, "Custom prompt cannot exceed 2000 characters").optional(),
1396
1394
  statusComponents: zodOpenapi.z.array(StatusComponentSchema).optional()
1397
1395
  });
1396
+ var CanUseItemSchema = zodOpenapi.z.object({
1397
+ toolId: zodOpenapi.z.string(),
1398
+ toolSelection: zodOpenapi.z.array(zodOpenapi.z.string()).nullable().optional()
1399
+ });
1398
1400
  var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
1399
1401
  type: zodOpenapi.z.literal("internal"),
1400
- tools: zodOpenapi.z.array(zodOpenapi.z.string()),
1401
- selectedTools: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.array(zodOpenapi.z.string())).optional(),
1402
+ canUse: zodOpenapi.z.array(CanUseItemSchema),
1402
1403
  dataComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
1403
1404
  artifactComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
1404
1405
  canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
@@ -1576,10 +1577,10 @@ function validateToolReferences(graphData, availableToolIds) {
1576
1577
  }
1577
1578
  const errors = [];
1578
1579
  for (const [agentId, agentData] of Object.entries(graphData.agents)) {
1579
- if (isInternalAgent(agentData) && agentData.tools && Array.isArray(agentData.tools)) {
1580
- for (const toolId of agentData.tools) {
1581
- if (!availableToolIds.has(toolId)) {
1582
- errors.push(`Agent '${agentId}' references non-existent tool '${toolId}'`);
1580
+ if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
1581
+ for (const canUseItem of agentData.canUse) {
1582
+ if (!availableToolIds.has(canUseItem.toolId)) {
1583
+ errors.push(`Agent '${agentId}' references non-existent tool '${canUseItem.toolId}'`);
1583
1584
  }
1584
1585
  }
1585
1586
  }
@@ -1743,6 +1744,7 @@ exports.ArtifactComponentApiUpdateSchema = ArtifactComponentApiUpdateSchema;
1743
1744
  exports.ArtifactComponentInsertSchema = ArtifactComponentInsertSchema;
1744
1745
  exports.ArtifactComponentSelectSchema = ArtifactComponentSelectSchema;
1745
1746
  exports.ArtifactComponentUpdateSchema = ArtifactComponentUpdateSchema;
1747
+ exports.CanUseItemSchema = CanUseItemSchema;
1746
1748
  exports.ContextCacheApiInsertSchema = ContextCacheApiInsertSchema;
1747
1749
  exports.ContextCacheApiSelectSchema = ContextCacheApiSelectSchema;
1748
1750
  exports.ContextCacheApiUpdateSchema = ContextCacheApiUpdateSchema;
@@ -1,2 +1,2 @@
1
- export { generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAndTypeGraphData, validateArtifactComponentReferences, validateDataComponentReferences, validateGraphStructure, validateToolReferences } from '../chunk-IIW7VAP3.js';
2
- export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiSelectSchema, AgentArtifactComponentApiUpdateSchema, AgentArtifactComponentInsertSchema, AgentArtifactComponentSelectSchema, AgentArtifactComponentUpdateSchema, AgentDataComponentApiInsertSchema, AgentDataComponentApiSelectSchema, AgentDataComponentApiUpdateSchema, AgentDataComponentInsertSchema, AgentDataComponentSelectSchema, AgentDataComponentUpdateSchema, AgentGraphApiInsertSchema, AgentGraphApiSelectSchema, AgentGraphApiUpdateSchema, AgentGraphInsertSchema, AgentGraphSelectSchema, AgentGraphUpdateSchema, AgentInsertSchema, AgentRelationApiInsertSchema, AgentRelationApiSelectSchema, AgentRelationApiUpdateSchema, AgentRelationInsertSchema, AgentRelationQuerySchema, AgentRelationSelectSchema, AgentRelationUpdateSchema, AgentSelectSchema, AgentStopWhenSchema, AgentToolRelationApiInsertSchema, AgentToolRelationApiSelectSchema, AgentToolRelationApiUpdateSchema, AgentToolRelationInsertSchema, AgentToolRelationSelectSchema, AgentToolRelationUpdateSchema, AgentUpdateSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentInsertSchema, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, 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, ExternalAgentRelationApiInsertSchema, ExternalAgentRelationInsertSchema, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, FetchConfigSchema, FetchDefinitionSchema, FullGraphAgentInsertSchema, FullGraphDefinitionSchema, FullProjectDefinitionSchema, GraphStopWhenSchema, GraphWithinContextOfProjectSchema, HeadersScopeSchema, IdParamsSchema, 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, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectGraphIdParamsSchema, TenantProjectGraphParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema } from '../chunk-ZORVFHVU.js';
1
+ export { generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAndTypeGraphData, validateArtifactComponentReferences, validateDataComponentReferences, validateGraphStructure, validateToolReferences } from '../chunk-BE5QULB4.js';
2
+ export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiSelectSchema, AgentArtifactComponentApiUpdateSchema, AgentArtifactComponentInsertSchema, AgentArtifactComponentSelectSchema, AgentArtifactComponentUpdateSchema, AgentDataComponentApiInsertSchema, AgentDataComponentApiSelectSchema, AgentDataComponentApiUpdateSchema, AgentDataComponentInsertSchema, AgentDataComponentSelectSchema, AgentDataComponentUpdateSchema, AgentGraphApiInsertSchema, AgentGraphApiSelectSchema, AgentGraphApiUpdateSchema, AgentGraphInsertSchema, AgentGraphSelectSchema, AgentGraphUpdateSchema, AgentInsertSchema, AgentRelationApiInsertSchema, AgentRelationApiSelectSchema, AgentRelationApiUpdateSchema, AgentRelationInsertSchema, AgentRelationQuerySchema, AgentRelationSelectSchema, AgentRelationUpdateSchema, AgentSelectSchema, AgentStopWhenSchema, AgentToolRelationApiInsertSchema, AgentToolRelationApiSelectSchema, AgentToolRelationApiUpdateSchema, AgentToolRelationInsertSchema, AgentToolRelationSelectSchema, AgentToolRelationUpdateSchema, AgentUpdateSchema, 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, ExternalAgentRelationApiInsertSchema, ExternalAgentRelationInsertSchema, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, FetchConfigSchema, FetchDefinitionSchema, FullGraphAgentInsertSchema, FullGraphDefinitionSchema, FullProjectDefinitionSchema, GraphStopWhenSchema, GraphWithinContextOfProjectSchema, HeadersScopeSchema, IdParamsSchema, 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, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectGraphIdParamsSchema, TenantProjectGraphParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema } from '../chunk-GL4IGNT7.js';
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@inkeep/agents-core",
3
- "version": "0.0.0-dev-20250925023031",
3
+ "version": "0.0.0-dev-20250925025705",
4
4
  "description": "Agents Core contains the database schema, types, and validation schemas for Inkeep Agent Framework, along with core components.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
7
7
  "main": "dist/index.js",
8
+ "types": "./dist/index.d.ts",
8
9
  "exports": {
9
10
  ".": "./dist/index.js",
10
11
  "./schema": "./dist/schema/index.js",