@inkeep/agents-core 0.0.0-dev-20250910233133 → 0.0.0-dev-20250910233151

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/dist/chunk-BIIFENNH.js +11 -0
  2. package/dist/chunk-H2F72PDA.js +15 -0
  3. package/dist/chunk-MKBO26DX.js +9 -0
  4. package/dist/chunk-ODONDMHT.js +665 -0
  5. package/dist/chunk-TSPWAF64.js +821 -0
  6. package/dist/client-exports.cjs +232 -0
  7. package/dist/client-exports.d.cts +302 -0
  8. package/dist/client-exports.d.ts +46 -43
  9. package/dist/client-exports.js +200 -247
  10. package/dist/db/schema.cjs +818 -0
  11. package/dist/db/schema.d.cts +7 -0
  12. package/dist/db/schema.d.ts +7 -4335
  13. package/dist/db/schema.js +1 -696
  14. package/dist/index.cjs +9809 -0
  15. package/dist/index.d.cts +3992 -0
  16. package/dist/index.d.ts +3992 -12
  17. package/dist/index.js +7807 -13
  18. package/dist/schema-B5YbTpz8.d.ts +4382 -0
  19. package/dist/schema-E0ulMd3k.d.cts +4382 -0
  20. package/dist/types/index.cjs +29 -0
  21. package/dist/types/index.d.cts +123 -0
  22. package/dist/types/index.d.ts +123 -5
  23. package/dist/types/index.js +2 -6
  24. package/dist/{validation/schemas.d.ts → utility-D2Lb-YAS.d.cts} +1350 -617
  25. package/dist/utility-D2Lb-YAS.d.ts +7946 -0
  26. package/dist/validation/index.cjs +1617 -0
  27. package/dist/validation/index.d.cts +63 -0
  28. package/dist/validation/index.d.ts +63 -4
  29. package/dist/validation/index.js +1 -5
  30. package/package.json +2 -2
  31. package/dist/__tests__/integration/helpers.d.ts +0 -5
  32. package/dist/__tests__/integration/helpers.d.ts.map +0 -1
  33. package/dist/__tests__/integration/helpers.js +0 -37
  34. package/dist/__tests__/integration/helpers.js.map +0 -1
  35. package/dist/__tests__/setup.d.ts +0 -3
  36. package/dist/__tests__/setup.d.ts.map +0 -1
  37. package/dist/__tests__/setup.js +0 -29
  38. package/dist/__tests__/setup.js.map +0 -1
  39. package/dist/client-exports.d.ts.map +0 -1
  40. package/dist/client-exports.js.map +0 -1
  41. package/dist/context/ContextConfig.d.ts +0 -54
  42. package/dist/context/ContextConfig.d.ts.map +0 -1
  43. package/dist/context/ContextConfig.js +0 -302
  44. package/dist/context/ContextConfig.js.map +0 -1
  45. package/dist/context/ContextFetcher.d.ts +0 -64
  46. package/dist/context/ContextFetcher.d.ts.map +0 -1
  47. package/dist/context/ContextFetcher.js +0 -325
  48. package/dist/context/ContextFetcher.js.map +0 -1
  49. package/dist/context/ContextResolver.d.ts +0 -52
  50. package/dist/context/ContextResolver.d.ts.map +0 -1
  51. package/dist/context/ContextResolver.js +0 -298
  52. package/dist/context/ContextResolver.js.map +0 -1
  53. package/dist/context/TemplateEngine.d.ts +0 -46
  54. package/dist/context/TemplateEngine.d.ts.map +0 -1
  55. package/dist/context/TemplateEngine.js +0 -175
  56. package/dist/context/TemplateEngine.js.map +0 -1
  57. package/dist/context/context.d.ts +0 -8
  58. package/dist/context/context.d.ts.map +0 -1
  59. package/dist/context/context.js +0 -157
  60. package/dist/context/context.js.map +0 -1
  61. package/dist/context/contextCache.d.ts +0 -50
  62. package/dist/context/contextCache.d.ts.map +0 -1
  63. package/dist/context/contextCache.js +0 -175
  64. package/dist/context/contextCache.js.map +0 -1
  65. package/dist/context/index.d.ts +0 -11
  66. package/dist/context/index.d.ts.map +0 -1
  67. package/dist/context/index.js +0 -8
  68. package/dist/context/index.js.map +0 -1
  69. package/dist/credential-stores/CredentialStoreRegistry.d.ts +0 -39
  70. package/dist/credential-stores/CredentialStoreRegistry.d.ts.map +0 -1
  71. package/dist/credential-stores/CredentialStoreRegistry.js +0 -65
  72. package/dist/credential-stores/CredentialStoreRegistry.js.map +0 -1
  73. package/dist/credential-stores/defaults.d.ts +0 -6
  74. package/dist/credential-stores/defaults.d.ts.map +0 -1
  75. package/dist/credential-stores/defaults.js +0 -22
  76. package/dist/credential-stores/defaults.js.map +0 -1
  77. package/dist/credential-stores/index.d.ts +0 -6
  78. package/dist/credential-stores/index.d.ts.map +0 -1
  79. package/dist/credential-stores/index.js +0 -6
  80. package/dist/credential-stores/index.js.map +0 -1
  81. package/dist/credential-stores/keychain-store.d.ts +0 -100
  82. package/dist/credential-stores/keychain-store.d.ts.map +0 -1
  83. package/dist/credential-stores/keychain-store.js +0 -225
  84. package/dist/credential-stores/keychain-store.js.map +0 -1
  85. package/dist/credential-stores/memory-store.d.ts +0 -39
  86. package/dist/credential-stores/memory-store.d.ts.map +0 -1
  87. package/dist/credential-stores/memory-store.js +0 -58
  88. package/dist/credential-stores/memory-store.js.map +0 -1
  89. package/dist/credential-stores/nango-store.d.ts +0 -59
  90. package/dist/credential-stores/nango-store.d.ts.map +0 -1
  91. package/dist/credential-stores/nango-store.js +0 -264
  92. package/dist/credential-stores/nango-store.js.map +0 -1
  93. package/dist/credential-stuffer/CredentialStuffer.d.ts +0 -80
  94. package/dist/credential-stuffer/CredentialStuffer.d.ts.map +0 -1
  95. package/dist/credential-stuffer/CredentialStuffer.js +0 -186
  96. package/dist/credential-stuffer/CredentialStuffer.js.map +0 -1
  97. package/dist/credential-stuffer/index.d.ts +0 -2
  98. package/dist/credential-stuffer/index.d.ts.map +0 -1
  99. package/dist/credential-stuffer/index.js +0 -2
  100. package/dist/credential-stuffer/index.js.map +0 -1
  101. package/dist/data-access/agentDataComponents.d.ts +0 -1
  102. package/dist/data-access/agentDataComponents.d.ts.map +0 -1
  103. package/dist/data-access/agentDataComponents.js +0 -2
  104. package/dist/data-access/agentDataComponents.js.map +0 -1
  105. package/dist/data-access/agentGraphs.d.ts +0 -399
  106. package/dist/data-access/agentGraphs.d.ts.map +0 -1
  107. package/dist/data-access/agentGraphs.js +0 -551
  108. package/dist/data-access/agentGraphs.js.map +0 -1
  109. package/dist/data-access/agentRelations.d.ts +0 -456
  110. package/dist/data-access/agentRelations.d.ts.map +0 -1
  111. package/dist/data-access/agentRelations.js +0 -471
  112. package/dist/data-access/agentRelations.js.map +0 -1
  113. package/dist/data-access/agents.d.ts +0 -218
  114. package/dist/data-access/agents.d.ts.map +0 -1
  115. package/dist/data-access/agents.js +0 -130
  116. package/dist/data-access/agents.js.map +0 -1
  117. package/dist/data-access/apiKeys.d.ts +0 -114
  118. package/dist/data-access/apiKeys.d.ts.map +0 -1
  119. package/dist/data-access/apiKeys.js +0 -185
  120. package/dist/data-access/apiKeys.js.map +0 -1
  121. package/dist/data-access/artifactComponents.d.ts +0 -152
  122. package/dist/data-access/artifactComponents.d.ts.map +0 -1
  123. package/dist/data-access/artifactComponents.js +0 -214
  124. package/dist/data-access/artifactComponents.js.map +0 -1
  125. package/dist/data-access/contextCache.d.ts +0 -68
  126. package/dist/data-access/contextCache.d.ts.map +0 -1
  127. package/dist/data-access/contextCache.js +0 -135
  128. package/dist/data-access/contextCache.js.map +0 -1
  129. package/dist/data-access/contextConfigs.d.ts +0 -110
  130. package/dist/data-access/contextConfigs.d.ts.map +0 -1
  131. package/dist/data-access/contextConfigs.js +0 -156
  132. package/dist/data-access/contextConfigs.js.map +0 -1
  133. package/dist/data-access/conversations.d.ts +0 -125
  134. package/dist/data-access/conversations.d.ts.map +0 -1
  135. package/dist/data-access/conversations.js +0 -244
  136. package/dist/data-access/conversations.js.map +0 -1
  137. package/dist/data-access/credentialReferences.d.ts +0 -86
  138. package/dist/data-access/credentialReferences.d.ts.map +0 -1
  139. package/dist/data-access/credentialReferences.js +0 -175
  140. package/dist/data-access/credentialReferences.js.map +0 -1
  141. package/dist/data-access/dataComponents.d.ts +0 -129
  142. package/dist/data-access/dataComponents.d.ts.map +0 -1
  143. package/dist/data-access/dataComponents.js +0 -213
  144. package/dist/data-access/dataComponents.js.map +0 -1
  145. package/dist/data-access/externalAgents.d.ts +0 -83
  146. package/dist/data-access/externalAgents.d.ts.map +0 -1
  147. package/dist/data-access/externalAgents.js +0 -163
  148. package/dist/data-access/externalAgents.js.map +0 -1
  149. package/dist/data-access/graphFull.d.ts +0 -32
  150. package/dist/data-access/graphFull.d.ts.map +0 -1
  151. package/dist/data-access/graphFull.js +0 -996
  152. package/dist/data-access/graphFull.js.map +0 -1
  153. package/dist/data-access/index.d.ts +0 -21
  154. package/dist/data-access/index.d.ts.map +0 -1
  155. package/dist/data-access/index.js +0 -22
  156. package/dist/data-access/index.js.map +0 -1
  157. package/dist/data-access/ledgerArtifacts.d.ts +0 -49
  158. package/dist/data-access/ledgerArtifacts.d.ts.map +0 -1
  159. package/dist/data-access/ledgerArtifacts.js +0 -112
  160. package/dist/data-access/ledgerArtifacts.js.map +0 -1
  161. package/dist/data-access/messages.d.ts +0 -209
  162. package/dist/data-access/messages.d.ts.map +0 -1
  163. package/dist/data-access/messages.js +0 -100
  164. package/dist/data-access/messages.js.map +0 -1
  165. package/dist/data-access/projects.d.ts +0 -67
  166. package/dist/data-access/projects.d.ts.map +0 -1
  167. package/dist/data-access/projects.js +0 -337
  168. package/dist/data-access/projects.js.map +0 -1
  169. package/dist/data-access/tasks.d.ts +0 -37
  170. package/dist/data-access/tasks.d.ts.map +0 -1
  171. package/dist/data-access/tasks.js +0 -40
  172. package/dist/data-access/tasks.js.map +0 -1
  173. package/dist/data-access/tools.d.ts +0 -277
  174. package/dist/data-access/tools.d.ts.map +0 -1
  175. package/dist/data-access/tools.js +0 -183
  176. package/dist/data-access/tools.js.map +0 -1
  177. package/dist/data-access/validation.d.ts +0 -17
  178. package/dist/data-access/validation.d.ts.map +0 -1
  179. package/dist/data-access/validation.js +0 -52
  180. package/dist/data-access/validation.js.map +0 -1
  181. package/dist/db/clean.d.ts +0 -6
  182. package/dist/db/clean.d.ts.map +0 -1
  183. package/dist/db/clean.js +0 -81
  184. package/dist/db/clean.js.map +0 -1
  185. package/dist/db/client.d.ts +0 -19
  186. package/dist/db/client.d.ts.map +0 -1
  187. package/dist/db/client.js +0 -24
  188. package/dist/db/client.js.map +0 -1
  189. package/dist/db/schema.d.ts.map +0 -1
  190. package/dist/db/schema.js.map +0 -1
  191. package/dist/db/test-client.d.ts +0 -25
  192. package/dist/db/test-client.d.ts.map +0 -1
  193. package/dist/db/test-client.js +0 -136
  194. package/dist/db/test-client.js.map +0 -1
  195. package/dist/env.d.ts +0 -19
  196. package/dist/env.d.ts.map +0 -1
  197. package/dist/env.js +0 -49
  198. package/dist/env.js.map +0 -1
  199. package/dist/index.d.ts.map +0 -1
  200. package/dist/index.js.map +0 -1
  201. package/dist/middleware/contextValidation.d.ts +0 -49
  202. package/dist/middleware/contextValidation.d.ts.map +0 -1
  203. package/dist/middleware/contextValidation.js +0 -473
  204. package/dist/middleware/contextValidation.js.map +0 -1
  205. package/dist/middleware/index.d.ts +0 -2
  206. package/dist/middleware/index.d.ts.map +0 -1
  207. package/dist/middleware/index.js +0 -2
  208. package/dist/middleware/index.js.map +0 -1
  209. package/dist/types/a2a.d.ts +0 -373
  210. package/dist/types/a2a.d.ts.map +0 -1
  211. package/dist/types/a2a.js +0 -14
  212. package/dist/types/a2a.js.map +0 -1
  213. package/dist/types/entities.d.ts +0 -147
  214. package/dist/types/entities.d.ts.map +0 -1
  215. package/dist/types/entities.js +0 -2
  216. package/dist/types/entities.js.map +0 -1
  217. package/dist/types/index.d.ts.map +0 -1
  218. package/dist/types/index.js.map +0 -1
  219. package/dist/types/server.d.ts +0 -116
  220. package/dist/types/server.d.ts.map +0 -1
  221. package/dist/types/server.js +0 -2
  222. package/dist/types/server.js.map +0 -1
  223. package/dist/types/utility.d.ts +0 -213
  224. package/dist/types/utility.d.ts.map +0 -1
  225. package/dist/types/utility.js +0 -9
  226. package/dist/types/utility.js.map +0 -1
  227. package/dist/utils/apiKeys.d.ts +0 -32
  228. package/dist/utils/apiKeys.d.ts.map +0 -1
  229. package/dist/utils/apiKeys.js +0 -117
  230. package/dist/utils/apiKeys.js.map +0 -1
  231. package/dist/utils/auth-detection.d.ts +0 -23
  232. package/dist/utils/auth-detection.d.ts.map +0 -1
  233. package/dist/utils/auth-detection.js +0 -148
  234. package/dist/utils/auth-detection.js.map +0 -1
  235. package/dist/utils/credential-store-utils.d.ts +0 -11
  236. package/dist/utils/credential-store-utils.d.ts.map +0 -1
  237. package/dist/utils/credential-store-utils.js +0 -19
  238. package/dist/utils/credential-store-utils.js.map +0 -1
  239. package/dist/utils/error.d.ts +0 -526
  240. package/dist/utils/error.d.ts.map +0 -1
  241. package/dist/utils/error.js +0 -282
  242. package/dist/utils/error.js.map +0 -1
  243. package/dist/utils/execution.d.ts +0 -18
  244. package/dist/utils/execution.d.ts.map +0 -1
  245. package/dist/utils/execution.js +0 -25
  246. package/dist/utils/execution.js.map +0 -1
  247. package/dist/utils/index.d.ts +0 -9
  248. package/dist/utils/index.d.ts.map +0 -1
  249. package/dist/utils/index.js +0 -9
  250. package/dist/utils/index.js.map +0 -1
  251. package/dist/utils/logger.d.ts +0 -79
  252. package/dist/utils/logger.d.ts.map +0 -1
  253. package/dist/utils/logger.js +0 -102
  254. package/dist/utils/logger.js.map +0 -1
  255. package/dist/utils/logging.d.ts +0 -11
  256. package/dist/utils/logging.d.ts.map +0 -1
  257. package/dist/utils/logging.js +0 -6
  258. package/dist/utils/logging.js.map +0 -1
  259. package/dist/utils/mcp-client.d.ts +0 -48
  260. package/dist/utils/mcp-client.d.ts.map +0 -1
  261. package/dist/utils/mcp-client.js +0 -174
  262. package/dist/utils/mcp-client.js.map +0 -1
  263. package/dist/utils/tracer.d.ts +0 -24
  264. package/dist/utils/tracer.d.ts.map +0 -1
  265. package/dist/utils/tracer.js +0 -110
  266. package/dist/utils/tracer.js.map +0 -1
  267. package/dist/validation/graphFull.d.ts +0 -36
  268. package/dist/validation/graphFull.d.ts.map +0 -1
  269. package/dist/validation/graphFull.js +0 -128
  270. package/dist/validation/graphFull.js.map +0 -1
  271. package/dist/validation/id-validation.d.ts +0 -38
  272. package/dist/validation/id-validation.d.ts.map +0 -1
  273. package/dist/validation/id-validation.js +0 -60
  274. package/dist/validation/id-validation.js.map +0 -1
  275. package/dist/validation/index.d.ts.map +0 -1
  276. package/dist/validation/index.js.map +0 -1
  277. package/dist/validation/schemas.d.ts.map +0 -1
  278. package/dist/validation/schemas.js +0 -576
  279. package/dist/validation/schemas.js.map +0 -1
@@ -0,0 +1,665 @@
1
+ import { VALID_RELATION_TYPES, TOOL_STATUS_VALUES } from './chunk-BIIFENNH.js';
2
+ import { agents, agentRelations, agentGraph, tasks, taskRelations, tools, conversations, messages, contextCache, dataComponents, agentDataComponents, artifactComponents, agentArtifactComponents, externalAgents, apiKeys, contextConfigs, agentToolRelations, ledgerArtifacts, projects } from './chunk-TSPWAF64.js';
3
+ import { z } from '@hono/zod-openapi';
4
+ import { createSelectSchema, createInsertSchema } from 'drizzle-zod';
5
+
6
+ var MIN_ID_LENGTH = 1;
7
+ var MAX_ID_LENGTH = 255;
8
+ var URL_SAFE_ID_PATTERN = /^[a-zA-Z0-9\-_.]+$/;
9
+ var resourceIdSchema = z.string().min(MIN_ID_LENGTH).max(MAX_ID_LENGTH).regex(URL_SAFE_ID_PATTERN, {
10
+ message: "ID must contain only letters, numbers, hyphens, underscores, and dots"
11
+ }).openapi({
12
+ description: "Resource identifier",
13
+ example: "resource_789"
14
+ });
15
+ var ModelSettingsSchema = z.object({
16
+ model: z.string().optional(),
17
+ providerOptions: z.record(z.string(), z.unknown()).optional()
18
+ });
19
+ var ModelSchema = z.object({
20
+ base: ModelSettingsSchema.optional(),
21
+ structuredOutput: ModelSettingsSchema.optional(),
22
+ summarizer: ModelSettingsSchema.optional()
23
+ });
24
+ var createApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
25
+ var createApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
26
+ var createApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true }).partial();
27
+ var AgentSelectSchema = createSelectSchema(agents);
28
+ var AgentInsertSchema = createInsertSchema(agents).extend({
29
+ id: resourceIdSchema,
30
+ models: ModelSchema.optional()
31
+ });
32
+ var AgentUpdateSchema = AgentInsertSchema.partial();
33
+ var AgentApiSelectSchema = createApiSchema(AgentSelectSchema);
34
+ var AgentApiInsertSchema = createApiInsertSchema(AgentInsertSchema);
35
+ var AgentApiUpdateSchema = createApiUpdateSchema(AgentUpdateSchema);
36
+ var AgentRelationSelectSchema = createSelectSchema(agentRelations);
37
+ var AgentRelationInsertSchema = createInsertSchema(agentRelations).extend({
38
+ id: resourceIdSchema,
39
+ graphId: resourceIdSchema,
40
+ sourceAgentId: resourceIdSchema,
41
+ targetAgentId: resourceIdSchema.optional(),
42
+ externalAgentId: resourceIdSchema.optional()
43
+ });
44
+ var AgentRelationUpdateSchema = AgentRelationInsertSchema.partial();
45
+ var AgentRelationApiSelectSchema = createApiSchema(AgentRelationSelectSchema);
46
+ var AgentRelationApiInsertSchema = createApiInsertSchema(AgentRelationInsertSchema).extend({
47
+ relationType: z.enum(VALID_RELATION_TYPES)
48
+ }).refine(
49
+ (data) => {
50
+ const hasTarget = data.targetAgentId != null;
51
+ const hasExternal = data.externalAgentId != null;
52
+ return hasTarget !== hasExternal;
53
+ },
54
+ {
55
+ message: "Must specify exactly one of targetAgentId or externalAgentId",
56
+ path: ["targetAgentId", "externalAgentId"]
57
+ }
58
+ );
59
+ var AgentRelationApiUpdateSchema = createApiUpdateSchema(AgentRelationUpdateSchema).extend({
60
+ relationType: z.enum(VALID_RELATION_TYPES).optional()
61
+ }).refine(
62
+ (data) => {
63
+ const hasTarget = data.targetAgentId != null;
64
+ const hasExternal = data.externalAgentId != null;
65
+ if (!hasTarget && !hasExternal) {
66
+ return true;
67
+ }
68
+ return hasTarget !== hasExternal;
69
+ },
70
+ {
71
+ message: "Must specify exactly one of targetAgentId or externalAgentId when updating agent relationships",
72
+ path: ["targetAgentId", "externalAgentId"]
73
+ }
74
+ );
75
+ var AgentRelationQuerySchema = z.object({
76
+ sourceAgentId: z.string().optional(),
77
+ targetAgentId: z.string().optional(),
78
+ externalAgentId: z.string().optional()
79
+ });
80
+ var ExternalAgentRelationInsertSchema = createInsertSchema(agentRelations).extend({
81
+ id: resourceIdSchema,
82
+ graphId: resourceIdSchema,
83
+ sourceAgentId: resourceIdSchema,
84
+ externalAgentId: resourceIdSchema
85
+ });
86
+ var ExternalAgentRelationApiInsertSchema = createApiInsertSchema(
87
+ ExternalAgentRelationInsertSchema
88
+ );
89
+ var AgentGraphSelectSchema = createSelectSchema(agentGraph);
90
+ var AgentGraphInsertSchema = createInsertSchema(agentGraph).extend({
91
+ id: resourceIdSchema
92
+ });
93
+ var AgentGraphUpdateSchema = AgentGraphInsertSchema.partial();
94
+ var AgentGraphApiSelectSchema = createApiSchema(AgentGraphSelectSchema);
95
+ var AgentGraphApiInsertSchema = createApiInsertSchema(AgentGraphInsertSchema).extend({
96
+ id: resourceIdSchema.optional()
97
+ });
98
+ var AgentGraphApiUpdateSchema = createApiUpdateSchema(AgentGraphUpdateSchema);
99
+ var TaskSelectSchema = createSelectSchema(tasks);
100
+ var TaskInsertSchema = createInsertSchema(tasks).extend({
101
+ id: resourceIdSchema,
102
+ conversationId: resourceIdSchema.optional()
103
+ });
104
+ var TaskUpdateSchema = TaskInsertSchema.partial();
105
+ var TaskApiSelectSchema = createApiSchema(TaskSelectSchema);
106
+ var TaskApiInsertSchema = createApiInsertSchema(TaskInsertSchema);
107
+ var TaskApiUpdateSchema = createApiUpdateSchema(TaskUpdateSchema);
108
+ var TaskRelationSelectSchema = createSelectSchema(taskRelations);
109
+ var TaskRelationInsertSchema = createInsertSchema(taskRelations).extend({
110
+ id: resourceIdSchema,
111
+ parentTaskId: resourceIdSchema,
112
+ childTaskId: resourceIdSchema
113
+ });
114
+ var TaskRelationUpdateSchema = TaskRelationInsertSchema.partial();
115
+ var TaskRelationApiSelectSchema = createApiSchema(TaskRelationSelectSchema);
116
+ var TaskRelationApiInsertSchema = createApiInsertSchema(TaskRelationInsertSchema);
117
+ var TaskRelationApiUpdateSchema = createApiUpdateSchema(TaskRelationUpdateSchema);
118
+ var imageUrlSchema = z.string().optional().refine(
119
+ (url) => {
120
+ if (!url) return true;
121
+ if (url.startsWith("data:image/")) {
122
+ const base64Part = url.split(",")[1];
123
+ if (!base64Part) return false;
124
+ return base64Part.length < 14e5;
125
+ }
126
+ try {
127
+ const parsed = new URL(url);
128
+ return parsed.protocol === "http:" || parsed.protocol === "https:";
129
+ } catch {
130
+ return false;
131
+ }
132
+ },
133
+ {
134
+ message: "Image URL must be a valid HTTP(S) URL or a base64 data URL (max 1MB)"
135
+ }
136
+ );
137
+ var McpTransportConfigSchema = z.object({
138
+ type: z.enum(["streamable_http", "sse"]),
139
+ requestInit: z.record(z.string(), z.unknown()).optional(),
140
+ eventSourceInit: z.record(z.string(), z.unknown()).optional(),
141
+ reconnectionOptions: z.record(z.string(), z.unknown()).optional(),
142
+ sessionId: z.string().optional()
143
+ });
144
+ var ToolStatusSchema = z.enum(TOOL_STATUS_VALUES);
145
+ var McpToolDefinitionSchema = z.object({
146
+ name: z.string(),
147
+ description: z.string().optional(),
148
+ inputSchema: z.record(z.string(), z.unknown()).optional()
149
+ });
150
+ var ToolSelectSchema = createSelectSchema(tools);
151
+ var ToolInsertSchema = createInsertSchema(tools).extend({
152
+ id: resourceIdSchema,
153
+ imageUrl: imageUrlSchema
154
+ });
155
+ var ConversationSelectSchema = createSelectSchema(conversations);
156
+ var ConversationInsertSchema = createInsertSchema(conversations).extend({
157
+ id: resourceIdSchema,
158
+ contextConfigId: resourceIdSchema.optional()
159
+ });
160
+ var ConversationUpdateSchema = ConversationInsertSchema.partial();
161
+ var ConversationApiSelectSchema = createApiSchema(ConversationSelectSchema);
162
+ var ConversationApiInsertSchema = createApiInsertSchema(ConversationInsertSchema);
163
+ var ConversationApiUpdateSchema = createApiUpdateSchema(ConversationUpdateSchema);
164
+ var MessageSelectSchema = createSelectSchema(messages);
165
+ var MessageInsertSchema = createInsertSchema(messages).extend({
166
+ id: resourceIdSchema,
167
+ conversationId: resourceIdSchema,
168
+ taskId: resourceIdSchema.optional()
169
+ });
170
+ var MessageUpdateSchema = MessageInsertSchema.partial();
171
+ var MessageApiSelectSchema = createApiSchema(MessageSelectSchema);
172
+ var MessageApiInsertSchema = createApiInsertSchema(MessageInsertSchema);
173
+ var MessageApiUpdateSchema = createApiUpdateSchema(MessageUpdateSchema);
174
+ var ContextCacheSelectSchema = createSelectSchema(contextCache);
175
+ var ContextCacheInsertSchema = createInsertSchema(contextCache);
176
+ var ContextCacheUpdateSchema = ContextCacheInsertSchema.partial();
177
+ var ContextCacheApiSelectSchema = createApiSchema(ContextCacheSelectSchema);
178
+ var ContextCacheApiInsertSchema = createApiInsertSchema(ContextCacheInsertSchema);
179
+ var ContextCacheApiUpdateSchema = createApiUpdateSchema(ContextCacheUpdateSchema);
180
+ var DataComponentSelectSchema = createSelectSchema(dataComponents);
181
+ var DataComponentInsertSchema = createInsertSchema(dataComponents).extend({
182
+ id: resourceIdSchema
183
+ });
184
+ var DataComponentBaseSchema = DataComponentInsertSchema.omit({
185
+ createdAt: true,
186
+ updatedAt: true
187
+ });
188
+ var DataComponentUpdateSchema = DataComponentInsertSchema.partial();
189
+ var DataComponentApiSelectSchema = createApiSchema(DataComponentSelectSchema);
190
+ var DataComponentApiInsertSchema = createApiInsertSchema(DataComponentInsertSchema);
191
+ var DataComponentApiUpdateSchema = createApiUpdateSchema(DataComponentUpdateSchema);
192
+ var AgentDataComponentSelectSchema = createSelectSchema(agentDataComponents);
193
+ var AgentDataComponentInsertSchema = createInsertSchema(agentDataComponents);
194
+ var AgentDataComponentUpdateSchema = AgentDataComponentInsertSchema.partial();
195
+ var AgentDataComponentApiSelectSchema = createApiSchema(AgentDataComponentSelectSchema);
196
+ var AgentDataComponentApiInsertSchema = createApiInsertSchema(
197
+ AgentDataComponentInsertSchema
198
+ );
199
+ var AgentDataComponentApiUpdateSchema = createApiUpdateSchema(
200
+ AgentDataComponentUpdateSchema
201
+ );
202
+ var ArtifactComponentSelectSchema = createSelectSchema(artifactComponents);
203
+ var ArtifactComponentInsertSchema = createInsertSchema(artifactComponents).extend({
204
+ id: resourceIdSchema
205
+ });
206
+ var ArtifactComponentUpdateSchema = ArtifactComponentInsertSchema.partial();
207
+ var ArtifactComponentApiSelectSchema = createApiSchema(ArtifactComponentSelectSchema);
208
+ var ArtifactComponentApiInsertSchema = ArtifactComponentInsertSchema.omit({
209
+ tenantId: true,
210
+ projectId: true,
211
+ createdAt: true,
212
+ updatedAt: true
213
+ }).extend({
214
+ id: resourceIdSchema.optional()
215
+ });
216
+ var ArtifactComponentApiUpdateSchema = createApiUpdateSchema(
217
+ ArtifactComponentUpdateSchema
218
+ );
219
+ var AgentArtifactComponentSelectSchema = createSelectSchema(agentArtifactComponents);
220
+ var AgentArtifactComponentInsertSchema = createInsertSchema(
221
+ agentArtifactComponents
222
+ ).extend({
223
+ id: resourceIdSchema,
224
+ agentId: resourceIdSchema,
225
+ artifactComponentId: resourceIdSchema
226
+ });
227
+ var AgentArtifactComponentUpdateSchema = AgentArtifactComponentInsertSchema.partial();
228
+ var AgentArtifactComponentApiSelectSchema = createApiSchema(
229
+ AgentArtifactComponentSelectSchema
230
+ );
231
+ var AgentArtifactComponentApiInsertSchema = AgentArtifactComponentInsertSchema.omit({
232
+ tenantId: true,
233
+ projectId: true,
234
+ id: true,
235
+ createdAt: true
236
+ });
237
+ var AgentArtifactComponentApiUpdateSchema = createApiUpdateSchema(
238
+ AgentArtifactComponentUpdateSchema
239
+ );
240
+ var ExternalAgentSelectSchema = createSelectSchema(externalAgents).extend({
241
+ credentialReferenceId: z.string().nullable().optional(),
242
+ headers: z.record(z.string(), z.string()).nullable().optional()
243
+ });
244
+ var ExternalAgentInsertSchema = createInsertSchema(externalAgents).extend({
245
+ id: resourceIdSchema
246
+ });
247
+ var ExternalAgentUpdateSchema = ExternalAgentInsertSchema.partial();
248
+ var ExternalAgentApiSelectSchema = createApiSchema(ExternalAgentSelectSchema);
249
+ var ExternalAgentApiInsertSchema = createApiInsertSchema(ExternalAgentInsertSchema);
250
+ var ExternalAgentApiUpdateSchema = createApiUpdateSchema(ExternalAgentUpdateSchema);
251
+ var AllAgentSchema = z.discriminatedUnion("type", [
252
+ AgentApiSelectSchema.extend({ type: z.literal("internal") }),
253
+ ExternalAgentApiSelectSchema.extend({ type: z.literal("external") })
254
+ ]);
255
+ var ApiKeySelectSchema = createSelectSchema(apiKeys);
256
+ var ApiKeyInsertSchema = createInsertSchema(apiKeys).extend({
257
+ id: resourceIdSchema,
258
+ graphId: resourceIdSchema
259
+ });
260
+ var ApiKeyUpdateSchema = ApiKeyInsertSchema.partial().omit({
261
+ tenantId: true,
262
+ projectId: true,
263
+ id: true,
264
+ publicId: true,
265
+ keyHash: true,
266
+ keyPrefix: true,
267
+ createdAt: true
268
+ });
269
+ var ApiKeyApiSelectSchema = ApiKeySelectSchema.omit({
270
+ tenantId: true,
271
+ projectId: true,
272
+ keyHash: true
273
+ // Never expose the hash
274
+ });
275
+ var ApiKeyApiCreationResponseSchema = z.object({
276
+ data: z.object({
277
+ apiKey: ApiKeyApiSelectSchema,
278
+ key: z.string().describe("The full API key (shown only once)")
279
+ })
280
+ });
281
+ var ApiKeyApiInsertSchema = ApiKeyInsertSchema.omit({
282
+ tenantId: true,
283
+ projectId: true,
284
+ id: true,
285
+ // Auto-generated
286
+ publicId: true,
287
+ // Auto-generated
288
+ keyHash: true,
289
+ // Auto-generated
290
+ keyPrefix: true,
291
+ // Auto-generated
292
+ lastUsedAt: true
293
+ // Not set on creation
294
+ });
295
+ var ApiKeyApiUpdateSchema = ApiKeyUpdateSchema;
296
+ var CredentialReferenceSelectSchema = z.object({
297
+ id: z.string(),
298
+ tenantId: z.string(),
299
+ projectId: z.string(),
300
+ type: z.string(),
301
+ credentialStoreId: z.string(),
302
+ retrievalParams: z.record(z.string(), z.unknown()).nullish(),
303
+ createdAt: z.string(),
304
+ updatedAt: z.string()
305
+ });
306
+ var CredentialReferenceInsertSchema = z.object({
307
+ id: resourceIdSchema,
308
+ tenantId: z.string(),
309
+ projectId: z.string(),
310
+ type: z.string(),
311
+ credentialStoreId: resourceIdSchema,
312
+ retrievalParams: z.record(z.string(), z.unknown()).nullish()
313
+ });
314
+ var CredentialReferenceUpdateSchema = CredentialReferenceInsertSchema.partial();
315
+ var CredentialReferenceApiSelectSchema = createApiSchema(CredentialReferenceSelectSchema);
316
+ var CredentialReferenceApiInsertSchema = createApiInsertSchema(
317
+ CredentialReferenceInsertSchema
318
+ );
319
+ var CredentialReferenceApiUpdateSchema = createApiUpdateSchema(
320
+ CredentialReferenceUpdateSchema
321
+ );
322
+ var McpToolSchema = ToolInsertSchema.extend({
323
+ imageUrl: imageUrlSchema,
324
+ status: ToolStatusSchema.default("unknown"),
325
+ lastHealthCheck: z.date().optional(),
326
+ lastToolsSync: z.date().optional(),
327
+ version: z.string().optional(),
328
+ createdAt: z.date(),
329
+ updatedAt: z.date()
330
+ });
331
+ var McpToolServerConfigSchema = z.object({
332
+ type: z.string(),
333
+ version: z.string().optional()
334
+ });
335
+ var MCPToolConfigSchema = McpToolSchema.omit({
336
+ config: true,
337
+ tenantId: true,
338
+ projectId: true,
339
+ status: true,
340
+ lastHealthCheck: true,
341
+ lastToolsSync: true,
342
+ version: true,
343
+ createdAt: true,
344
+ updatedAt: true,
345
+ credentialReferenceId: true
346
+ }).extend({
347
+ tenantId: z.string().optional(),
348
+ projectId: z.string().optional(),
349
+ description: z.string().optional(),
350
+ server: McpToolServerConfigSchema.optional(),
351
+ serverUrl: z.url(),
352
+ toolName: z.string().optional(),
353
+ activeTools: z.array(z.string()).optional(),
354
+ mcpType: z.enum(["nango", "generic"]).optional(),
355
+ transport: McpTransportConfigSchema.optional(),
356
+ credential: CredentialReferenceApiInsertSchema.optional()
357
+ });
358
+ var ToolUpdateSchema = ToolInsertSchema.partial();
359
+ var ToolApiSelectSchema = createApiSchema(ToolSelectSchema);
360
+ var ToolApiInsertSchema = createApiInsertSchema(ToolInsertSchema);
361
+ var ToolApiUpdateSchema = createApiUpdateSchema(ToolUpdateSchema);
362
+ var FetchConfigSchema = z.object({
363
+ url: z.string().min(1, "URL is required"),
364
+ method: z.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).optional().default("GET"),
365
+ headers: z.record(z.string(), z.string()).optional(),
366
+ body: z.record(z.string(), z.unknown()).optional(),
367
+ transform: z.string().optional(),
368
+ // JSONPath or JS transform function
369
+ timeout: z.number().min(0).optional().default(1e4).optional()
370
+ });
371
+ var FetchDefinitionSchema = z.object({
372
+ id: z.string().min(1, "Fetch definition ID is required"),
373
+ name: z.string().optional(),
374
+ trigger: z.enum(["initialization", "invocation"]),
375
+ fetchConfig: FetchConfigSchema,
376
+ responseSchema: z.any().optional(),
377
+ // JSON Schema for validating HTTP response
378
+ defaultValue: z.unknown().optional(),
379
+ credential: CredentialReferenceApiInsertSchema.optional()
380
+ });
381
+ var ContextConfigSelectSchema = createSelectSchema(contextConfigs).extend({
382
+ requestContextSchema: z.unknown().optional()
383
+ });
384
+ var ContextConfigInsertSchema = createInsertSchema(contextConfigs).extend({
385
+ id: resourceIdSchema,
386
+ requestContextSchema: z.unknown().optional()
387
+ }).omit({
388
+ createdAt: true,
389
+ updatedAt: true
390
+ });
391
+ var ContextConfigUpdateSchema = ContextConfigInsertSchema.partial();
392
+ var ContextConfigApiSelectSchema = createApiSchema(ContextConfigSelectSchema);
393
+ var ContextConfigApiInsertSchema = createApiInsertSchema(ContextConfigInsertSchema);
394
+ var ContextConfigApiUpdateSchema = createApiUpdateSchema(ContextConfigUpdateSchema);
395
+ var AgentToolRelationSelectSchema = createSelectSchema(agentToolRelations);
396
+ var AgentToolRelationInsertSchema = createInsertSchema(agentToolRelations).extend({
397
+ id: resourceIdSchema,
398
+ agentId: resourceIdSchema,
399
+ toolId: resourceIdSchema
400
+ });
401
+ var AgentToolRelationUpdateSchema = AgentToolRelationInsertSchema.partial();
402
+ var AgentToolRelationApiSelectSchema = createApiSchema(AgentToolRelationSelectSchema);
403
+ var AgentToolRelationApiInsertSchema = createApiInsertSchema(
404
+ AgentToolRelationInsertSchema
405
+ );
406
+ var AgentToolRelationApiUpdateSchema = createApiUpdateSchema(
407
+ AgentToolRelationUpdateSchema
408
+ );
409
+ var LedgerArtifactSelectSchema = createSelectSchema(ledgerArtifacts);
410
+ var LedgerArtifactInsertSchema = createInsertSchema(ledgerArtifacts);
411
+ var LedgerArtifactUpdateSchema = LedgerArtifactInsertSchema.partial();
412
+ var LedgerArtifactApiSelectSchema = createApiSchema(LedgerArtifactSelectSchema);
413
+ var LedgerArtifactApiInsertSchema = createApiInsertSchema(LedgerArtifactInsertSchema);
414
+ var LedgerArtifactApiUpdateSchema = createApiUpdateSchema(LedgerArtifactUpdateSchema);
415
+ var StatusComponentSchema = z.object({
416
+ type: z.string(),
417
+ description: z.string().optional(),
418
+ detailsSchema: z.object({
419
+ type: z.literal("object"),
420
+ properties: z.record(z.string(), z.any()),
421
+ required: z.array(z.string()).optional()
422
+ }).optional()
423
+ });
424
+ var StatusUpdateSchema = z.object({
425
+ enabled: z.boolean().optional(),
426
+ numEvents: z.number().min(1).max(100).optional(),
427
+ timeInSeconds: z.number().min(1).max(600).optional(),
428
+ prompt: z.string().max(2e3, "Custom prompt cannot exceed 2000 characters").optional(),
429
+ statusComponents: z.array(StatusComponentSchema).optional()
430
+ });
431
+ var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
432
+ tools: z.array(z.string()),
433
+ dataComponents: z.array(z.string()).optional(),
434
+ artifactComponents: z.array(z.string()).optional(),
435
+ canTransferTo: z.array(z.string()).optional(),
436
+ canDelegateTo: z.array(z.string()).optional()
437
+ });
438
+ var FullGraphDefinitionSchema = AgentGraphApiInsertSchema.extend({
439
+ agents: z.record(z.string(), z.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])),
440
+ tools: z.record(z.string(), ToolApiInsertSchema),
441
+ credentialReferences: z.array(CredentialReferenceApiInsertSchema).optional(),
442
+ dataComponents: z.record(z.string(), DataComponentApiInsertSchema).optional(),
443
+ artifactComponents: z.record(z.string(), ArtifactComponentApiInsertSchema).optional(),
444
+ contextConfig: z.optional(ContextConfigApiInsertSchema),
445
+ statusUpdates: z.optional(StatusUpdateSchema),
446
+ models: ModelSchema.optional(),
447
+ stopWhen: z.object({
448
+ transferCountIs: z.number().min(1).max(100).optional()
449
+ }).optional(),
450
+ graphPrompt: z.string().max(5e3, "Graph prompt cannot exceed 5000 characters").optional()
451
+ });
452
+ var PaginationSchema = z.object({
453
+ page: z.coerce.number().min(1).default(1),
454
+ limit: z.coerce.number().min(1).max(100).default(10),
455
+ total: z.number(),
456
+ pages: z.number()
457
+ });
458
+ var ListResponseSchema = (itemSchema) => z.object({
459
+ data: z.array(itemSchema),
460
+ pagination: PaginationSchema
461
+ });
462
+ var SingleResponseSchema = (itemSchema) => z.object({
463
+ data: itemSchema
464
+ });
465
+ var ErrorResponseSchema = z.object({
466
+ error: z.string(),
467
+ message: z.string().optional(),
468
+ details: z.unknown().optional()
469
+ });
470
+ var ExistsResponseSchema = z.object({
471
+ exists: z.boolean()
472
+ });
473
+ var RemovedResponseSchema = z.object({
474
+ message: z.string(),
475
+ removed: z.boolean()
476
+ });
477
+ var ProjectSelectSchema = createSelectSchema(projects);
478
+ var ProjectInsertSchema = createInsertSchema(projects).omit({
479
+ createdAt: true,
480
+ updatedAt: true
481
+ });
482
+ var ProjectUpdateSchema = ProjectInsertSchema.partial();
483
+ var ProjectApiSelectSchema = ProjectSelectSchema.omit({ tenantId: true });
484
+ var ProjectApiInsertSchema = ProjectInsertSchema.omit({ tenantId: true });
485
+ var ProjectApiUpdateSchema = ProjectUpdateSchema.omit({ tenantId: true });
486
+ var HeadersScopeSchema = z.object({
487
+ "x-inkeep-tenant-id": z.string().optional().openapi({
488
+ description: "Tenant identifier",
489
+ example: "tenant_123"
490
+ }),
491
+ "x-inkeep-project-id": z.string().optional().openapi({
492
+ description: "Project identifier",
493
+ example: "project_456"
494
+ }),
495
+ "x-inkeep-graph-id": z.string().optional().openapi({
496
+ description: "Graph identifier",
497
+ example: "graph_789"
498
+ })
499
+ });
500
+ var TenantParamsSchema = z.object({
501
+ tenantId: z.string().openapi({
502
+ description: "Tenant identifier",
503
+ example: "tenant_123"
504
+ })
505
+ }).openapi("TenantParams");
506
+ var TenantProjectParamsSchema = z.object({
507
+ tenantId: z.string().openapi({
508
+ description: "Tenant identifier",
509
+ example: "tenant_123"
510
+ }),
511
+ projectId: z.string().openapi({
512
+ description: "Project identifier",
513
+ example: "project_456"
514
+ })
515
+ }).openapi("TenantProjectParams");
516
+ var TenantProjectIdParamsSchema = z.object({
517
+ tenantId: z.string().openapi({
518
+ description: "Tenant identifier",
519
+ example: "tenant_123"
520
+ }),
521
+ projectId: z.string().openapi({
522
+ description: "Project identifier",
523
+ example: "project_456"
524
+ }),
525
+ id: resourceIdSchema
526
+ }).openapi("TenantProjectIdParams");
527
+ var TenantIdParamsSchema = z.object({
528
+ tenantId: z.string().openapi({
529
+ description: "Tenant identifier",
530
+ example: "tenant_123"
531
+ }),
532
+ id: resourceIdSchema
533
+ }).openapi("TenantIdParams");
534
+ var IdParamsSchema = z.object({
535
+ id: resourceIdSchema
536
+ }).openapi("IdParams");
537
+ var PaginationQueryParamsSchema = z.object({
538
+ page: z.coerce.number().min(1).default(1),
539
+ limit: z.coerce.number().min(1).max(100).default(10)
540
+ });
541
+
542
+ // src/validation/graphFull.ts
543
+ function isInternalAgent(agent) {
544
+ return "prompt" in agent;
545
+ }
546
+ function isExternalAgent(agent) {
547
+ return "baseUrl" in agent;
548
+ }
549
+ function validateAndTypeGraphData(data) {
550
+ return FullGraphDefinitionSchema.parse(data);
551
+ }
552
+ function validateToolReferences(graphData) {
553
+ const errors = [];
554
+ const availableToolIds = new Set(Object.keys(graphData.tools));
555
+ for (const [agentId, agentData] of Object.entries(graphData.agents)) {
556
+ if (isInternalAgent(agentData) && agentData.tools && Array.isArray(agentData.tools)) {
557
+ for (const toolId of agentData.tools) {
558
+ if (!availableToolIds.has(toolId)) {
559
+ errors.push(`Agent '${agentId}' references non-existent tool '${toolId}'`);
560
+ }
561
+ }
562
+ }
563
+ }
564
+ if (errors.length > 0) {
565
+ throw new Error(`Tool reference validation failed:
566
+ ${errors.join("\n")}`);
567
+ }
568
+ }
569
+ function validateDataComponentReferences(graphData) {
570
+ const errors = [];
571
+ const availableDataComponentIds = new Set(Object.keys(graphData.dataComponents || {}));
572
+ for (const [agentId, agentData] of Object.entries(graphData.agents)) {
573
+ if (isInternalAgent(agentData) && agentData.dataComponents) {
574
+ for (const dataComponentId of agentData.dataComponents) {
575
+ if (!availableDataComponentIds.has(dataComponentId)) {
576
+ errors.push(
577
+ `Agent '${agentId}' references non-existent dataComponent '${dataComponentId}'`
578
+ );
579
+ }
580
+ }
581
+ }
582
+ }
583
+ if (errors.length > 0) {
584
+ throw new Error(`DataComponent reference validation failed:
585
+ ${errors.join("\n")}`);
586
+ }
587
+ }
588
+ function validateArtifactComponentReferences(graphData) {
589
+ const errors = [];
590
+ const availableArtifactComponentIds = new Set(Object.keys(graphData.artifactComponents || {}));
591
+ for (const [agentId, agentData] of Object.entries(graphData.agents)) {
592
+ if (isInternalAgent(agentData) && agentData.artifactComponents) {
593
+ for (const artifactComponentId of agentData.artifactComponents) {
594
+ if (!availableArtifactComponentIds.has(artifactComponentId)) {
595
+ errors.push(
596
+ `Agent '${agentId}' references non-existent artifactComponent '${artifactComponentId}'`
597
+ );
598
+ }
599
+ }
600
+ }
601
+ }
602
+ if (errors.length > 0) {
603
+ throw new Error(`ArtifactComponent reference validation failed:
604
+ ${errors.join("\n")}`);
605
+ }
606
+ }
607
+ function validateAgentRelationships(graphData) {
608
+ const errors = [];
609
+ const availableAgentIds = new Set(Object.keys(graphData.agents));
610
+ for (const [agentId, agentData] of Object.entries(graphData.agents)) {
611
+ if (isInternalAgent(agentData)) {
612
+ if (agentData.canTransferTo && Array.isArray(agentData.canTransferTo)) {
613
+ for (const targetId of agentData.canTransferTo) {
614
+ if (!availableAgentIds.has(targetId)) {
615
+ errors.push(
616
+ `Agent '${agentId}' has transfer target '${targetId}' that doesn't exist in graph`
617
+ );
618
+ }
619
+ }
620
+ }
621
+ if (agentData.canDelegateTo && Array.isArray(agentData.canDelegateTo)) {
622
+ for (const targetId of agentData.canDelegateTo) {
623
+ if (!availableAgentIds.has(targetId)) {
624
+ errors.push(
625
+ `Agent '${agentId}' has delegation target '${targetId}' that doesn't exist in graph`
626
+ );
627
+ }
628
+ }
629
+ }
630
+ }
631
+ }
632
+ if (errors.length > 0) {
633
+ throw new Error(`Agent relationship validation failed:
634
+ ${errors.join("\n")}`);
635
+ }
636
+ }
637
+ function validateGraphStructure(graphData) {
638
+ if (!graphData.agents[graphData.defaultAgentId]) {
639
+ throw new Error(`Default agent '${graphData.defaultAgentId}' does not exist in agents`);
640
+ }
641
+ validateToolReferences(graphData);
642
+ validateDataComponentReferences(graphData);
643
+ validateArtifactComponentReferences(graphData);
644
+ validateAgentRelationships(graphData);
645
+ }
646
+
647
+ // src/validation/id-validation.ts
648
+ function isValidResourceId(id) {
649
+ const result = resourceIdSchema.safeParse(id);
650
+ return result.success;
651
+ }
652
+ function generateIdFromName(name) {
653
+ const id = name.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-");
654
+ if (!id) {
655
+ throw new Error("Cannot generate valid ID from provided name");
656
+ }
657
+ const truncatedId = id.substring(0, MAX_ID_LENGTH);
658
+ const result = resourceIdSchema.safeParse(truncatedId);
659
+ if (!result.success) {
660
+ throw new Error(`Generated ID "${truncatedId}" is not valid: ${result.error.message}`);
661
+ }
662
+ return truncatedId;
663
+ }
664
+
665
+ 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, McpToolServerConfigSchema, McpTransportConfigSchema, MessageApiInsertSchema, MessageApiSelectSchema, MessageApiUpdateSchema, MessageInsertSchema, MessageSelectSchema, MessageUpdateSchema, ModelSchema, ModelSettingsSchema, PaginationQueryParamsSchema, PaginationSchema, ProjectApiInsertSchema, ProjectApiSelectSchema, ProjectApiUpdateSchema, ProjectInsertSchema, 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 };