@inkeep/agents-core 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -170,14 +170,14 @@ Tests use in-memory SQLite databases for isolation and speed.
170
170
 
171
171
  This package is designed to support a multi-service architecture:
172
172
 
173
- ### Management API
173
+ ### Agents Manage API
174
174
  Handles CRUD operations and entity management:
175
175
  - Creating/updating agents
176
176
  - Managing agent relationships
177
177
  - Configuring tools
178
178
  - Database migrations
179
179
 
180
- ### Execution API
180
+ ### Agents Run API
181
181
  Handles runtime operations:
182
182
  - Processing conversations
183
183
  - Executing tasks
@@ -0,0 +1,126 @@
1
+ import { FullGraphDefinitionSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-R3VVJXX7.js';
2
+
3
+ // src/validation/graphFull.ts
4
+ function isInternalAgent(agent) {
5
+ return "prompt" in agent;
6
+ }
7
+ function isExternalAgent(agent) {
8
+ return "baseUrl" in agent;
9
+ }
10
+ function validateAndTypeGraphData(data) {
11
+ return FullGraphDefinitionSchema.parse(data);
12
+ }
13
+ function validateToolReferences(graphData) {
14
+ const errors = [];
15
+ const availableToolIds = new Set(Object.keys(graphData.tools || {}));
16
+ for (const [agentId, agentData] of Object.entries(graphData.agents)) {
17
+ if (isInternalAgent(agentData) && agentData.tools && Array.isArray(agentData.tools)) {
18
+ for (const toolId of agentData.tools) {
19
+ if (!availableToolIds.has(toolId)) {
20
+ errors.push(`Agent '${agentId}' references non-existent tool '${toolId}'`);
21
+ }
22
+ }
23
+ }
24
+ }
25
+ if (errors.length > 0) {
26
+ throw new Error(`Tool reference validation failed:
27
+ ${errors.join("\n")}`);
28
+ }
29
+ }
30
+ function validateDataComponentReferences(graphData) {
31
+ const errors = [];
32
+ const availableDataComponentIds = new Set(Object.keys(graphData.dataComponents || {}));
33
+ for (const [agentId, agentData] of Object.entries(graphData.agents)) {
34
+ if (isInternalAgent(agentData) && agentData.dataComponents) {
35
+ for (const dataComponentId of agentData.dataComponents) {
36
+ if (!availableDataComponentIds.has(dataComponentId)) {
37
+ errors.push(
38
+ `Agent '${agentId}' references non-existent dataComponent '${dataComponentId}'`
39
+ );
40
+ }
41
+ }
42
+ }
43
+ }
44
+ if (errors.length > 0) {
45
+ throw new Error(`DataComponent reference validation failed:
46
+ ${errors.join("\n")}`);
47
+ }
48
+ }
49
+ function validateArtifactComponentReferences(graphData) {
50
+ const errors = [];
51
+ const availableArtifactComponentIds = new Set(Object.keys(graphData.artifactComponents || {}));
52
+ for (const [agentId, agentData] of Object.entries(graphData.agents)) {
53
+ if (isInternalAgent(agentData) && agentData.artifactComponents) {
54
+ for (const artifactComponentId of agentData.artifactComponents) {
55
+ if (!availableArtifactComponentIds.has(artifactComponentId)) {
56
+ errors.push(
57
+ `Agent '${agentId}' references non-existent artifactComponent '${artifactComponentId}'`
58
+ );
59
+ }
60
+ }
61
+ }
62
+ }
63
+ if (errors.length > 0) {
64
+ throw new Error(`ArtifactComponent reference validation failed:
65
+ ${errors.join("\n")}`);
66
+ }
67
+ }
68
+ function validateAgentRelationships(graphData) {
69
+ const errors = [];
70
+ const availableAgentIds = new Set(Object.keys(graphData.agents));
71
+ for (const [agentId, agentData] of Object.entries(graphData.agents)) {
72
+ if (isInternalAgent(agentData)) {
73
+ if (agentData.canTransferTo && Array.isArray(agentData.canTransferTo)) {
74
+ for (const targetId of agentData.canTransferTo) {
75
+ if (!availableAgentIds.has(targetId)) {
76
+ errors.push(
77
+ `Agent '${agentId}' has transfer target '${targetId}' that doesn't exist in graph`
78
+ );
79
+ }
80
+ }
81
+ }
82
+ if (agentData.canDelegateTo && Array.isArray(agentData.canDelegateTo)) {
83
+ for (const targetId of agentData.canDelegateTo) {
84
+ if (!availableAgentIds.has(targetId)) {
85
+ errors.push(
86
+ `Agent '${agentId}' has delegation target '${targetId}' that doesn't exist in graph`
87
+ );
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ if (errors.length > 0) {
94
+ throw new Error(`Agent relationship validation failed:
95
+ ${errors.join("\n")}`);
96
+ }
97
+ }
98
+ function validateGraphStructure(graphData) {
99
+ if (!graphData.agents[graphData.defaultAgentId]) {
100
+ throw new Error(`Default agent '${graphData.defaultAgentId}' does not exist in agents`);
101
+ }
102
+ validateToolReferences(graphData);
103
+ validateDataComponentReferences(graphData);
104
+ validateArtifactComponentReferences(graphData);
105
+ validateAgentRelationships(graphData);
106
+ }
107
+
108
+ // src/validation/id-validation.ts
109
+ function isValidResourceId(id) {
110
+ const result = resourceIdSchema.safeParse(id);
111
+ return result.success;
112
+ }
113
+ function generateIdFromName(name) {
114
+ const id = name.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-");
115
+ if (!id) {
116
+ throw new Error("Cannot generate valid ID from provided name");
117
+ }
118
+ const truncatedId = id.substring(0, MAX_ID_LENGTH);
119
+ const result = resourceIdSchema.safeParse(truncatedId);
120
+ if (!result.success) {
121
+ throw new Error(`Generated ID "${truncatedId}" is not valid: ${result.error.message}`);
122
+ }
123
+ return truncatedId;
124
+ }
125
+
126
+ export { generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAndTypeGraphData, validateArtifactComponentReferences, validateDataComponentReferences, validateGraphStructure, validateToolReferences };
@@ -1,6 +1,6 @@
1
1
  import { __export } from './chunk-MKBO26DX.js';
2
2
  import { relations, sql } from 'drizzle-orm';
3
- import { sqliteTable, index, unique, text, primaryKey, blob, integer, foreignKey } from 'drizzle-orm/sqlite-core';
3
+ import { sqliteTable, index, unique, text, primaryKey, blob, foreignKey, integer } from 'drizzle-orm/sqlite-core';
4
4
 
5
5
  // src/db/schema.ts
6
6
  var schema_exports = {};
@@ -54,7 +54,7 @@ var projects = sqliteTable(
54
54
  // This IS the project ID
55
55
  name: text("name").notNull(),
56
56
  description: text("description").notNull(),
57
- // Project-level default model settingsuration that can be inherited by graphs and agents
57
+ // Project-level default model settings that can be inherited by graphs and agents
58
58
  models: text("models", { mode: "json" }).$type(),
59
59
  // Project-level stopWhen configuration that can be inherited by graphs and agents
60
60
  stopWhen: text("stop_when", { mode: "json" }).$type(),
@@ -79,7 +79,14 @@ var contextConfigs = sqliteTable(
79
79
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
80
80
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
81
81
  },
82
- (table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
82
+ (table) => [
83
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
84
+ foreignKey({
85
+ columns: [table.tenantId, table.projectId],
86
+ foreignColumns: [projects.tenantId, projects.id],
87
+ name: "context_configs_project_fk"
88
+ }).onDelete("cascade")
89
+ ]
83
90
  );
84
91
  var contextCache = sqliteTable(
85
92
  "context_cache",
@@ -108,6 +115,11 @@ var contextCache = sqliteTable(
108
115
  },
109
116
  (table) => [
110
117
  primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
118
+ foreignKey({
119
+ columns: [table.tenantId, table.projectId],
120
+ foreignColumns: [projects.tenantId, projects.id],
121
+ name: "context_cache_project_fk"
122
+ }).onDelete("cascade"),
111
123
  index("context_cache_lookup_idx").on(
112
124
  table.conversationId,
113
125
  table.contextConfigId,
@@ -139,7 +151,7 @@ var agents = sqliteTable(
139
151
  columns: [table.tenantId, table.projectId],
140
152
  foreignColumns: [projects.tenantId, projects.id],
141
153
  name: "agents_project_fk"
142
- })
154
+ }).onDelete("cascade")
143
155
  ]
144
156
  );
145
157
  var agentRelations = sqliteTable(
@@ -165,7 +177,7 @@ var agentRelations = sqliteTable(
165
177
  columns: [table.tenantId, table.projectId],
166
178
  foreignColumns: [projects.tenantId, projects.id],
167
179
  name: "agent_relations_project_fk"
168
- })
180
+ }).onDelete("cascade")
169
181
  ]
170
182
  );
171
183
  var externalAgents = sqliteTable(
@@ -185,6 +197,11 @@ var externalAgents = sqliteTable(
185
197
  },
186
198
  (table) => [
187
199
  primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
200
+ foreignKey({
201
+ columns: [table.tenantId, table.projectId],
202
+ foreignColumns: [projects.tenantId, projects.id],
203
+ name: "external_agents_project_fk"
204
+ }).onDelete("cascade"),
188
205
  foreignKey({
189
206
  columns: [table.tenantId, table.projectId, table.credentialReferenceId],
190
207
  foreignColumns: [
@@ -224,7 +241,7 @@ var agentGraph = sqliteTable(
224
241
  columns: [table.tenantId, table.projectId],
225
242
  foreignColumns: [projects.tenantId, projects.id],
226
243
  name: "agent_graph_project_fk"
227
- })
244
+ }).onDelete("cascade")
228
245
  ]
229
246
  );
230
247
  var tasks = sqliteTable(
@@ -240,7 +257,14 @@ var tasks = sqliteTable(
240
257
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
241
258
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
242
259
  },
243
- (table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
260
+ (table) => [
261
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
262
+ foreignKey({
263
+ columns: [table.tenantId, table.projectId],
264
+ foreignColumns: [projects.tenantId, projects.id],
265
+ name: "tasks_project_fk"
266
+ }).onDelete("cascade")
267
+ ]
244
268
  );
245
269
  var taskRelations = sqliteTable(
246
270
  "task_relations",
@@ -255,7 +279,14 @@ var taskRelations = sqliteTable(
255
279
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
256
280
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
257
281
  },
258
- (table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
282
+ (table) => [
283
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
284
+ foreignKey({
285
+ columns: [table.tenantId, table.projectId],
286
+ foreignColumns: [projects.tenantId, projects.id],
287
+ name: "task_relations_project_fk"
288
+ }).onDelete("cascade")
289
+ ]
259
290
  );
260
291
  var dataComponents = sqliteTable(
261
292
  "data_components",
@@ -269,7 +300,14 @@ var dataComponents = sqliteTable(
269
300
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
270
301
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
271
302
  },
272
- (table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
303
+ (table) => [
304
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
305
+ foreignKey({
306
+ columns: [table.tenantId, table.projectId],
307
+ foreignColumns: [projects.tenantId, projects.id],
308
+ name: "data_components_project_fk"
309
+ }).onDelete("cascade")
310
+ ]
273
311
  );
274
312
  var agentDataComponents = sqliteTable(
275
313
  "agent_data_components",
@@ -283,6 +321,12 @@ var agentDataComponents = sqliteTable(
283
321
  },
284
322
  (table) => [
285
323
  primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
324
+ // Foreign key constraint to projects table
325
+ foreignKey({
326
+ columns: [table.tenantId, table.projectId],
327
+ foreignColumns: [projects.tenantId, projects.id],
328
+ name: "agent_data_components_project_fk"
329
+ }).onDelete("cascade"),
286
330
  // Foreign key constraint to agents table
287
331
  foreignKey({
288
332
  columns: [table.tenantId, table.projectId, table.agentId],
@@ -310,7 +354,14 @@ var artifactComponents = sqliteTable(
310
354
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
311
355
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
312
356
  },
313
- (table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
357
+ (table) => [
358
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
359
+ foreignKey({
360
+ columns: [table.tenantId, table.projectId],
361
+ foreignColumns: [projects.tenantId, projects.id],
362
+ name: "artifact_components_project_fk"
363
+ }).onDelete("cascade")
364
+ ]
314
365
  );
315
366
  var agentArtifactComponents = sqliteTable(
316
367
  "agent_artifact_components",
@@ -324,6 +375,12 @@ var agentArtifactComponents = sqliteTable(
324
375
  },
325
376
  (table) => [
326
377
  primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
378
+ // Foreign key constraint to projects table
379
+ foreignKey({
380
+ columns: [table.tenantId, table.projectId],
381
+ foreignColumns: [projects.tenantId, projects.id],
382
+ name: "agent_artifact_components_project_fk"
383
+ }).onDelete("cascade"),
327
384
  // Foreign key constraint to agents table
328
385
  foreignKey({
329
386
  columns: [table.tenantId, table.projectId, table.agentId],
@@ -367,7 +424,14 @@ var tools = sqliteTable(
367
424
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
368
425
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
369
426
  },
370
- (table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
427
+ (table) => [
428
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
429
+ foreignKey({
430
+ columns: [table.tenantId, table.projectId],
431
+ foreignColumns: [projects.tenantId, projects.id],
432
+ name: "tools_project_fk"
433
+ }).onDelete("cascade")
434
+ ]
371
435
  );
372
436
  var agentToolRelations = sqliteTable(
373
437
  "agent_tool_relations",
@@ -383,6 +447,12 @@ var agentToolRelations = sqliteTable(
383
447
  },
384
448
  (table) => [
385
449
  primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
450
+ // Foreign key constraint to projects table
451
+ foreignKey({
452
+ columns: [table.tenantId, table.projectId],
453
+ foreignColumns: [projects.tenantId, projects.id],
454
+ name: "agent_tool_relations_project_fk"
455
+ }).onDelete("cascade"),
386
456
  // Foreign key constraint to agents table
387
457
  foreignKey({
388
458
  columns: [table.tenantId, table.projectId, table.agentId],
@@ -411,7 +481,14 @@ var conversations = sqliteTable(
411
481
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
412
482
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
413
483
  },
414
- (table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
484
+ (table) => [
485
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
486
+ foreignKey({
487
+ columns: [table.tenantId, table.projectId],
488
+ foreignColumns: [projects.tenantId, projects.id],
489
+ name: "conversations_project_fk"
490
+ }).onDelete("cascade")
491
+ ]
415
492
  );
416
493
  var messages = sqliteTable(
417
494
  "messages",
@@ -456,7 +533,14 @@ var messages = sqliteTable(
456
533
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
457
534
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
458
535
  },
459
- (table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
536
+ (table) => [
537
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
538
+ foreignKey({
539
+ columns: [table.tenantId, table.projectId],
540
+ foreignColumns: [projects.tenantId, projects.id],
541
+ name: "messages_project_fk"
542
+ }).onDelete("cascade")
543
+ ]
460
544
  );
461
545
  var ledgerArtifacts = sqliteTable(
462
546
  "ledger_artifacts",
@@ -484,7 +568,14 @@ var ledgerArtifacts = sqliteTable(
484
568
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
485
569
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
486
570
  },
487
- (table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
571
+ (table) => [
572
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
573
+ foreignKey({
574
+ columns: [table.tenantId, table.projectId],
575
+ foreignColumns: [projects.tenantId, projects.id],
576
+ name: "ledger_artifacts_project_fk"
577
+ }).onDelete("cascade")
578
+ ]
488
579
  );
489
580
  var apiKeys = sqliteTable(
490
581
  "api_keys",
@@ -505,6 +596,11 @@ var apiKeys = sqliteTable(
505
596
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
506
597
  },
507
598
  (t) => [
599
+ foreignKey({
600
+ columns: [t.tenantId, t.projectId],
601
+ foreignColumns: [projects.tenantId, projects.id],
602
+ name: "api_keys_project_fk"
603
+ }).onDelete("cascade"),
508
604
  foreignKey({
509
605
  columns: [t.tenantId, t.projectId, t.graphId],
510
606
  foreignColumns: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id],
@@ -529,7 +625,14 @@ var credentialReferences = sqliteTable(
529
625
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
530
626
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
531
627
  },
532
- (t) => [primaryKey({ columns: [t.tenantId, t.projectId, t.id] })]
628
+ (t) => [
629
+ primaryKey({ columns: [t.tenantId, t.projectId, t.id] }),
630
+ foreignKey({
631
+ columns: [t.tenantId, t.projectId],
632
+ foreignColumns: [projects.tenantId, projects.id],
633
+ name: "credential_references_project_fk"
634
+ }).onDelete("cascade")
635
+ ]
533
636
  );
534
637
  var ledgerArtifactsTaskIdIdx = index("ledger_artifacts_task_id_idx").on(
535
638
  ledgerArtifacts.taskId
@@ -1,8 +1,14 @@
1
+ import { agents, agentRelations, agentGraph, tasks, taskRelations, tools, conversations, messages, contextCache, dataComponents, agentDataComponents, artifactComponents, agentArtifactComponents, externalAgents, apiKeys, contextConfigs, agentToolRelations, ledgerArtifacts, projects } from './chunk-MXQKLGQK.js';
1
2
  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, contextConfigs, agentToolRelations, ledgerArtifacts, projects } from './chunk-M4JXMAG7.js';
3
3
  import { z } from '@hono/zod-openapi';
4
4
  import { createSelectSchema, createInsertSchema } from 'drizzle-zod';
5
5
 
6
+ var StopWhenSchema = z.object({
7
+ transferCountIs: z.number().min(1).max(100).optional(),
8
+ stepCountIs: z.number().min(1).max(1e3).optional()
9
+ });
10
+ var GraphStopWhenSchema = StopWhenSchema.pick({ transferCountIs: true });
11
+ var AgentStopWhenSchema = StopWhenSchema.pick({ stepCountIs: true });
6
12
  var MIN_ID_LENGTH = 1;
7
13
  var MAX_ID_LENGTH = 255;
8
14
  var URL_SAFE_ID_PATTERN = /^[a-zA-Z0-9\-_.]+$/;
@@ -446,16 +452,20 @@ var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
446
452
  });
447
453
  var FullGraphDefinitionSchema = AgentGraphApiInsertSchema.extend({
448
454
  agents: z.record(z.string(), z.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])),
449
- tools: z.record(z.string(), ToolApiInsertSchema),
455
+ tools: z.record(z.string(), ToolApiInsertSchema).optional(),
450
456
  credentialReferences: z.array(CredentialReferenceApiInsertSchema).optional(),
451
457
  dataComponents: z.record(z.string(), DataComponentApiInsertSchema).optional(),
452
458
  artifactComponents: z.record(z.string(), ArtifactComponentApiInsertSchema).optional(),
453
459
  contextConfig: z.optional(ContextConfigApiInsertSchema),
454
460
  statusUpdates: z.optional(StatusUpdateSchema),
455
461
  models: ModelSchema.optional(),
456
- stopWhen: z.object({
457
- transferCountIs: z.number().min(1).max(100).optional()
458
- }).optional(),
462
+ stopWhen: GraphStopWhenSchema.optional(),
463
+ graphPrompt: z.string().max(5e3, "Graph prompt cannot exceed 5000 characters").optional()
464
+ });
465
+ var GraphWithinContextOfProjectSchema = AgentGraphApiInsertSchema.extend({
466
+ agents: z.record(z.string(), z.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])),
467
+ models: ModelSchema.optional(),
468
+ stopWhen: GraphStopWhenSchema.optional(),
459
469
  graphPrompt: z.string().max(5e3, "Graph prompt cannot exceed 5000 characters").optional()
460
470
  });
461
471
  var PaginationSchema = z.object({
@@ -485,7 +495,8 @@ var RemovedResponseSchema = z.object({
485
495
  });
486
496
  var ProjectSelectSchema = createSelectSchema(projects);
487
497
  var ProjectInsertSchema = createInsertSchema(projects).extend({
488
- models: ProjectModelSchema.optional()
498
+ models: ProjectModelSchema.optional(),
499
+ stopWhen: StopWhenSchema.optional()
489
500
  }).omit({
490
501
  createdAt: true,
491
502
  updatedAt: true
@@ -494,6 +505,17 @@ var ProjectUpdateSchema = ProjectInsertSchema.partial();
494
505
  var ProjectApiSelectSchema = ProjectSelectSchema.omit({ tenantId: true });
495
506
  var ProjectApiInsertSchema = ProjectInsertSchema.omit({ tenantId: true });
496
507
  var ProjectApiUpdateSchema = ProjectUpdateSchema.omit({ tenantId: true });
508
+ var FullProjectDefinitionSchema = ProjectApiInsertSchema.extend({
509
+ graphs: z.record(z.string(), GraphWithinContextOfProjectSchema),
510
+ tools: z.record(z.string(), ToolApiInsertSchema),
511
+ dataComponents: z.record(z.string(), DataComponentApiInsertSchema).optional(),
512
+ artifactComponents: z.record(z.string(), ArtifactComponentApiInsertSchema).optional(),
513
+ contextConfig: z.record(z.string(), ContextConfigApiInsertSchema).optional(),
514
+ statusUpdates: z.optional(StatusUpdateSchema),
515
+ credentialReferences: z.array(CredentialReferenceApiInsertSchema).optional(),
516
+ createdAt: z.string().optional(),
517
+ updatedAt: z.string().optional()
518
+ });
497
519
  var HeadersScopeSchema = z.object({
498
520
  "x-inkeep-tenant-id": z.string().optional().openapi({
499
521
  description: "Tenant identifier",
@@ -550,127 +572,4 @@ var PaginationQueryParamsSchema = z.object({
550
572
  limit: z.coerce.number().min(1).max(100).default(10)
551
573
  });
552
574
 
553
- // src/validation/graphFull.ts
554
- function isInternalAgent(agent) {
555
- return "prompt" in agent;
556
- }
557
- function isExternalAgent(agent) {
558
- return "baseUrl" in agent;
559
- }
560
- function validateAndTypeGraphData(data) {
561
- return FullGraphDefinitionSchema.parse(data);
562
- }
563
- function validateToolReferences(graphData) {
564
- const errors = [];
565
- const availableToolIds = new Set(Object.keys(graphData.tools));
566
- for (const [agentId, agentData] of Object.entries(graphData.agents)) {
567
- if (isInternalAgent(agentData) && agentData.tools && Array.isArray(agentData.tools)) {
568
- for (const toolId of agentData.tools) {
569
- if (!availableToolIds.has(toolId)) {
570
- errors.push(`Agent '${agentId}' references non-existent tool '${toolId}'`);
571
- }
572
- }
573
- }
574
- }
575
- if (errors.length > 0) {
576
- throw new Error(`Tool reference validation failed:
577
- ${errors.join("\n")}`);
578
- }
579
- }
580
- function validateDataComponentReferences(graphData) {
581
- const errors = [];
582
- const availableDataComponentIds = new Set(Object.keys(graphData.dataComponents || {}));
583
- for (const [agentId, agentData] of Object.entries(graphData.agents)) {
584
- if (isInternalAgent(agentData) && agentData.dataComponents) {
585
- for (const dataComponentId of agentData.dataComponents) {
586
- if (!availableDataComponentIds.has(dataComponentId)) {
587
- errors.push(
588
- `Agent '${agentId}' references non-existent dataComponent '${dataComponentId}'`
589
- );
590
- }
591
- }
592
- }
593
- }
594
- if (errors.length > 0) {
595
- throw new Error(`DataComponent reference validation failed:
596
- ${errors.join("\n")}`);
597
- }
598
- }
599
- function validateArtifactComponentReferences(graphData) {
600
- const errors = [];
601
- const availableArtifactComponentIds = new Set(Object.keys(graphData.artifactComponents || {}));
602
- for (const [agentId, agentData] of Object.entries(graphData.agents)) {
603
- if (isInternalAgent(agentData) && agentData.artifactComponents) {
604
- for (const artifactComponentId of agentData.artifactComponents) {
605
- if (!availableArtifactComponentIds.has(artifactComponentId)) {
606
- errors.push(
607
- `Agent '${agentId}' references non-existent artifactComponent '${artifactComponentId}'`
608
- );
609
- }
610
- }
611
- }
612
- }
613
- if (errors.length > 0) {
614
- throw new Error(`ArtifactComponent reference validation failed:
615
- ${errors.join("\n")}`);
616
- }
617
- }
618
- function validateAgentRelationships(graphData) {
619
- const errors = [];
620
- const availableAgentIds = new Set(Object.keys(graphData.agents));
621
- for (const [agentId, agentData] of Object.entries(graphData.agents)) {
622
- if (isInternalAgent(agentData)) {
623
- if (agentData.canTransferTo && Array.isArray(agentData.canTransferTo)) {
624
- for (const targetId of agentData.canTransferTo) {
625
- if (!availableAgentIds.has(targetId)) {
626
- errors.push(
627
- `Agent '${agentId}' has transfer target '${targetId}' that doesn't exist in graph`
628
- );
629
- }
630
- }
631
- }
632
- if (agentData.canDelegateTo && Array.isArray(agentData.canDelegateTo)) {
633
- for (const targetId of agentData.canDelegateTo) {
634
- if (!availableAgentIds.has(targetId)) {
635
- errors.push(
636
- `Agent '${agentId}' has delegation target '${targetId}' that doesn't exist in graph`
637
- );
638
- }
639
- }
640
- }
641
- }
642
- }
643
- if (errors.length > 0) {
644
- throw new Error(`Agent relationship validation failed:
645
- ${errors.join("\n")}`);
646
- }
647
- }
648
- function validateGraphStructure(graphData) {
649
- if (!graphData.agents[graphData.defaultAgentId]) {
650
- throw new Error(`Default agent '${graphData.defaultAgentId}' does not exist in agents`);
651
- }
652
- validateToolReferences(graphData);
653
- validateDataComponentReferences(graphData);
654
- validateArtifactComponentReferences(graphData);
655
- validateAgentRelationships(graphData);
656
- }
657
-
658
- // src/validation/id-validation.ts
659
- function isValidResourceId(id) {
660
- const result = resourceIdSchema.safeParse(id);
661
- return result.success;
662
- }
663
- function generateIdFromName(name) {
664
- const id = name.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-");
665
- if (!id) {
666
- throw new Error("Cannot generate valid ID from provided name");
667
- }
668
- const truncatedId = id.substring(0, MAX_ID_LENGTH);
669
- const result = resourceIdSchema.safeParse(truncatedId);
670
- if (!result.success) {
671
- throw new Error(`Generated ID "${truncatedId}" is not valid: ${result.error.message}`);
672
- }
673
- return truncatedId;
674
- }
675
-
676
- 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, 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, 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, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, resourceIdSchema, validateAgentRelationships, validateAndTypeGraphData, validateArtifactComponentReferences, validateDataComponentReferences, validateGraphStructure, validateToolReferences };
575
+ 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, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema };