@inkeep/agents-core 0.0.0-chat-to-edit-20251119071712

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 (57) hide show
  1. package/LICENSE.md +56 -0
  2. package/README.md +458 -0
  3. package/SUPPLEMENTAL_TERMS.md +40 -0
  4. package/dist/auth-detection-CGqhPDnj.d.cts +435 -0
  5. package/dist/auth-detection-CGqhPDnj.d.ts +435 -0
  6. package/dist/chunk-7CLFCY6J.js +36 -0
  7. package/dist/chunk-A6JWG7FI.js +1689 -0
  8. package/dist/chunk-CMNLBV2A.js +39 -0
  9. package/dist/chunk-E6R6PML7.js +19 -0
  10. package/dist/chunk-OP3KPT4T.js +442 -0
  11. package/dist/chunk-TLSKVSBR.js +1234 -0
  12. package/dist/chunk-WG46C2WU.js +394 -0
  13. package/dist/chunk-YECQCT5N.js +223 -0
  14. package/dist/chunk-YFHT5M2R.js +18 -0
  15. package/dist/client-exports.cjs +3421 -0
  16. package/dist/client-exports.d.cts +292 -0
  17. package/dist/client-exports.d.ts +292 -0
  18. package/dist/client-exports.js +178 -0
  19. package/dist/constants/models.cjs +40 -0
  20. package/dist/constants/models.d.cts +42 -0
  21. package/dist/constants/models.d.ts +42 -0
  22. package/dist/constants/models.js +1 -0
  23. package/dist/db/schema.cjs +1686 -0
  24. package/dist/db/schema.d.cts +7 -0
  25. package/dist/db/schema.d.ts +7 -0
  26. package/dist/db/schema.js +1 -0
  27. package/dist/index.cjs +229792 -0
  28. package/dist/index.d.cts +5138 -0
  29. package/dist/index.d.ts +5138 -0
  30. package/dist/index.js +224908 -0
  31. package/dist/props-validation-BMR1qNiy.d.cts +15 -0
  32. package/dist/props-validation-BMR1qNiy.d.ts +15 -0
  33. package/dist/schema-C90zXlqp.d.ts +8012 -0
  34. package/dist/schema-keglUDw0.d.cts +8012 -0
  35. package/dist/types/index.cjs +64 -0
  36. package/dist/types/index.d.cts +175 -0
  37. package/dist/types/index.d.ts +175 -0
  38. package/dist/types/index.js +2 -0
  39. package/dist/utility-CXEG5391.d.cts +17265 -0
  40. package/dist/utility-CXEG5391.d.ts +17265 -0
  41. package/dist/utils/schema-conversion.cjs +236 -0
  42. package/dist/utils/schema-conversion.d.cts +26 -0
  43. package/dist/utils/schema-conversion.d.ts +26 -0
  44. package/dist/utils/schema-conversion.js +1 -0
  45. package/dist/validation/index.cjs +3521 -0
  46. package/dist/validation/index.d.cts +279 -0
  47. package/dist/validation/index.d.ts +279 -0
  48. package/dist/validation/index.js +2 -0
  49. package/drizzle/0000_exotic_mysterio.sql +398 -0
  50. package/drizzle/0001_greedy_the_phantom.sql +4 -0
  51. package/drizzle/0002_add_evaluation_features.sql +252 -0
  52. package/drizzle/0003_brave_micromax.sql +2 -0
  53. package/drizzle/meta/0000_snapshot.json +2519 -0
  54. package/drizzle/meta/0001_snapshot.json +2892 -0
  55. package/drizzle/meta/0002_snapshot.json +4485 -0
  56. package/drizzle/meta/_journal.json +34 -0
  57. package/package.json +133 -0
@@ -0,0 +1,3521 @@
1
+ 'use strict';
2
+
3
+ var zodOpenapi = require('@hono/zod-openapi');
4
+ var drizzleOrm = require('drizzle-orm');
5
+ var pgCore = require('drizzle-orm/pg-core');
6
+ var drizzleZod = require('drizzle-zod');
7
+ var zod = require('zod');
8
+ var Ajv = require('ajv');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
13
+
14
+ // src/validation/cycleDetection.ts
15
+ function detectDelegationCycles(agentData) {
16
+ const graph = buildDelegationGraph(agentData);
17
+ const cycles = [];
18
+ const visited = /* @__PURE__ */ new Set();
19
+ const stack = /* @__PURE__ */ new Set();
20
+ const path = [];
21
+ function dfs(node) {
22
+ visited.add(node);
23
+ stack.add(node);
24
+ path.push(node);
25
+ for (const neighbor of graph.get(node) || []) {
26
+ if (!visited.has(neighbor)) {
27
+ if (dfs(neighbor)) return true;
28
+ } else if (stack.has(neighbor)) {
29
+ const cycleStart = path.indexOf(neighbor);
30
+ cycles.push(
31
+ `Circular delegation detected: ${[...path.slice(cycleStart), neighbor].join(" \u2192 ")}`
32
+ );
33
+ return true;
34
+ }
35
+ }
36
+ stack.delete(node);
37
+ path.pop();
38
+ return false;
39
+ }
40
+ for (const node of graph.keys()) {
41
+ if (!visited.has(node)) {
42
+ path.length = 0;
43
+ dfs(node);
44
+ }
45
+ }
46
+ return cycles;
47
+ }
48
+ function buildDelegationGraph(agentData) {
49
+ const graph = /* @__PURE__ */ new Map();
50
+ for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
51
+ const delegates = subAgent.canDelegateTo?.filter((d) => typeof d === "string");
52
+ if (delegates?.length) {
53
+ graph.set(subAgentId, delegates);
54
+ }
55
+ }
56
+ return graph;
57
+ }
58
+
59
+ // src/constants/schema-validation/defaults.ts
60
+ var schemaValidationDefaults = {
61
+ // Agent Execution Transfer Count
62
+ // Controls how many times an agent can transfer control to sub-agents in a single conversation turn.
63
+ // This prevents infinite transfer loops while allowing multi-agent collaboration workflows.
64
+ AGENT_EXECUTION_TRANSFER_COUNT_MIN: 1,
65
+ AGENT_EXECUTION_TRANSFER_COUNT_MAX: 1e3,
66
+ // Sub-Agent Turn Generation Steps
67
+ // Limits how many AI generation steps a sub-agent can perform within a single turn.
68
+ // Each generation step typically involves sending a prompt to the LLM and processing its response.
69
+ // This prevents runaway token usage while allowing complex multi-step reasoning.
70
+ SUB_AGENT_TURN_GENERATION_STEPS_MIN: 1,
71
+ SUB_AGENT_TURN_GENERATION_STEPS_MAX: 1e3,
72
+ // Status Update Thresholds
73
+ // Real-time status updates are triggered when either threshold is exceeded during longer operations.
74
+ // MAX_NUM_EVENTS: Maximum number of internal events before forcing a status update to the client.
75
+ // MAX_INTERVAL_SECONDS: Maximum time between status updates regardless of event count.
76
+ STATUS_UPDATE_MAX_NUM_EVENTS: 100,
77
+ STATUS_UPDATE_MAX_INTERVAL_SECONDS: 600,
78
+ // 10 minutes
79
+ // Prompt Text Length Validation
80
+ // Maximum character limits for agent and sub-agent system prompts to prevent excessive token usage.
81
+ // Enforced during agent configuration to ensure prompts remain focused and manageable.
82
+ VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS: 2e3,
83
+ VALIDATION_AGENT_PROMPT_MAX_CHARS: 5e3,
84
+ // Context Fetcher HTTP Timeout
85
+ // Maximum time allowed for HTTP requests made by Context Fetchers (e.g., CRM lookups, external API calls).
86
+ // Context Fetchers automatically retrieve external data at the start of a conversation to enrich agent context.
87
+ CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT: 1e4
88
+ // 10 seconds
89
+ };
90
+ var tenantScoped = {
91
+ tenantId: pgCore.varchar("tenant_id", { length: 256 }).notNull(),
92
+ id: pgCore.varchar("id", { length: 256 }).notNull()
93
+ };
94
+ var projectScoped = {
95
+ ...tenantScoped,
96
+ projectId: pgCore.varchar("project_id", { length: 256 }).notNull()
97
+ };
98
+ var agentScoped = {
99
+ ...projectScoped,
100
+ agentId: pgCore.varchar("agent_id", { length: 256 }).notNull()
101
+ };
102
+ var subAgentScoped = {
103
+ ...agentScoped,
104
+ subAgentId: pgCore.varchar("sub_agent_id", { length: 256 }).notNull()
105
+ };
106
+ var uiProperties = {
107
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
108
+ description: pgCore.text("description").notNull()
109
+ };
110
+ var timestamps = {
111
+ createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow(),
112
+ updatedAt: pgCore.timestamp("updated_at", { mode: "string" }).notNull().defaultNow()
113
+ };
114
+ var projects = pgCore.pgTable(
115
+ "projects",
116
+ {
117
+ ...tenantScoped,
118
+ ...uiProperties,
119
+ models: pgCore.jsonb("models").$type(),
120
+ stopWhen: pgCore.jsonb("stop_when").$type(),
121
+ ...timestamps
122
+ },
123
+ (table) => [pgCore.primaryKey({ columns: [table.tenantId, table.id] })]
124
+ );
125
+ var agents = pgCore.pgTable(
126
+ "agent",
127
+ {
128
+ ...projectScoped,
129
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
130
+ description: pgCore.text("description"),
131
+ defaultSubAgentId: pgCore.varchar("default_sub_agent_id", { length: 256 }),
132
+ contextConfigId: pgCore.varchar("context_config_id", { length: 256 }),
133
+ models: pgCore.jsonb("models").$type(),
134
+ statusUpdates: pgCore.jsonb("status_updates").$type(),
135
+ prompt: pgCore.text("prompt"),
136
+ stopWhen: pgCore.jsonb("stop_when").$type(),
137
+ ...timestamps
138
+ },
139
+ (table) => [
140
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
141
+ pgCore.foreignKey({
142
+ columns: [table.tenantId, table.projectId],
143
+ foreignColumns: [projects.tenantId, projects.id],
144
+ name: "agent_project_fk"
145
+ }).onDelete("cascade")
146
+ ]
147
+ );
148
+ var contextConfigs = pgCore.pgTable(
149
+ "context_configs",
150
+ {
151
+ ...agentScoped,
152
+ headersSchema: pgCore.jsonb("headers_schema").$type(),
153
+ contextVariables: pgCore.jsonb("context_variables").$type(),
154
+ ...timestamps
155
+ },
156
+ (table) => [
157
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
158
+ pgCore.foreignKey({
159
+ columns: [table.tenantId, table.projectId, table.agentId],
160
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
161
+ name: "context_configs_agent_fk"
162
+ }).onDelete("cascade")
163
+ ]
164
+ );
165
+ var contextCache = pgCore.pgTable(
166
+ "context_cache",
167
+ {
168
+ ...projectScoped,
169
+ conversationId: pgCore.varchar("conversation_id", { length: 256 }).notNull(),
170
+ contextConfigId: pgCore.varchar("context_config_id", { length: 256 }).notNull(),
171
+ contextVariableKey: pgCore.varchar("context_variable_key", { length: 256 }).notNull(),
172
+ value: pgCore.jsonb("value").$type().notNull(),
173
+ requestHash: pgCore.varchar("request_hash", { length: 256 }),
174
+ fetchedAt: pgCore.timestamp("fetched_at", { mode: "string" }).notNull().defaultNow(),
175
+ fetchSource: pgCore.varchar("fetch_source", { length: 256 }),
176
+ fetchDurationMs: pgCore.integer("fetch_duration_ms"),
177
+ ...timestamps
178
+ },
179
+ (table) => [
180
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
181
+ pgCore.foreignKey({
182
+ columns: [table.tenantId, table.projectId],
183
+ foreignColumns: [projects.tenantId, projects.id],
184
+ name: "context_cache_project_fk"
185
+ }).onDelete("cascade"),
186
+ pgCore.index("context_cache_lookup_idx").on(
187
+ table.conversationId,
188
+ table.contextConfigId,
189
+ table.contextVariableKey
190
+ )
191
+ ]
192
+ );
193
+ var subAgents = pgCore.pgTable(
194
+ "sub_agents",
195
+ {
196
+ ...agentScoped,
197
+ ...uiProperties,
198
+ prompt: pgCore.text("prompt").notNull(),
199
+ conversationHistoryConfig: pgCore.jsonb("conversation_history_config").$type().default({
200
+ mode: "full",
201
+ limit: 50,
202
+ maxOutputTokens: 4e3,
203
+ includeInternal: false,
204
+ messageTypes: ["chat", "tool-result"]
205
+ }),
206
+ models: pgCore.jsonb("models").$type(),
207
+ stopWhen: pgCore.jsonb("stop_when").$type(),
208
+ ...timestamps
209
+ },
210
+ (table) => [
211
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
212
+ pgCore.foreignKey({
213
+ columns: [table.tenantId, table.projectId, table.agentId],
214
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
215
+ name: "sub_agents_agents_fk"
216
+ }).onDelete("cascade")
217
+ ]
218
+ );
219
+ var subAgentRelations = pgCore.pgTable(
220
+ "sub_agent_relations",
221
+ {
222
+ ...agentScoped,
223
+ sourceSubAgentId: pgCore.varchar("source_sub_agent_id", { length: 256 }).notNull(),
224
+ targetSubAgentId: pgCore.varchar("target_sub_agent_id", { length: 256 }),
225
+ relationType: pgCore.varchar("relation_type", { length: 256 }),
226
+ ...timestamps
227
+ },
228
+ (table) => [
229
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
230
+ pgCore.foreignKey({
231
+ columns: [table.tenantId, table.projectId, table.agentId],
232
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
233
+ name: "sub_agent_relations_agent_fk"
234
+ }).onDelete("cascade")
235
+ ]
236
+ );
237
+ var externalAgents = pgCore.pgTable(
238
+ "external_agents",
239
+ {
240
+ ...projectScoped,
241
+ ...uiProperties,
242
+ baseUrl: pgCore.text("base_url").notNull(),
243
+ credentialReferenceId: pgCore.varchar("credential_reference_id", { length: 256 }),
244
+ ...timestamps
245
+ },
246
+ (table) => [
247
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
248
+ pgCore.foreignKey({
249
+ columns: [table.tenantId, table.projectId],
250
+ foreignColumns: [projects.tenantId, projects.id],
251
+ name: "external_agents_project_fk"
252
+ }).onDelete("cascade"),
253
+ pgCore.foreignKey({
254
+ columns: [table.tenantId, table.projectId, table.credentialReferenceId],
255
+ foreignColumns: [
256
+ credentialReferences.tenantId,
257
+ credentialReferences.projectId,
258
+ credentialReferences.id
259
+ ],
260
+ name: "external_agents_credential_reference_fk"
261
+ }).onDelete("cascade")
262
+ ]
263
+ );
264
+ var tasks = pgCore.pgTable(
265
+ "tasks",
266
+ {
267
+ ...subAgentScoped,
268
+ contextId: pgCore.varchar("context_id", { length: 256 }).notNull(),
269
+ status: pgCore.varchar("status", { length: 256 }).notNull(),
270
+ metadata: pgCore.jsonb("metadata").$type(),
271
+ ...timestamps
272
+ },
273
+ (table) => [
274
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
275
+ pgCore.foreignKey({
276
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
277
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
278
+ name: "tasks_sub_agent_fk"
279
+ }).onDelete("cascade")
280
+ ]
281
+ );
282
+ var taskRelations = pgCore.pgTable(
283
+ "task_relations",
284
+ {
285
+ ...projectScoped,
286
+ parentTaskId: pgCore.varchar("parent_task_id", { length: 256 }).notNull(),
287
+ childTaskId: pgCore.varchar("child_task_id", { length: 256 }).notNull(),
288
+ relationType: pgCore.varchar("relation_type", { length: 256 }).default("parent_child"),
289
+ ...timestamps
290
+ },
291
+ (table) => [
292
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
293
+ pgCore.foreignKey({
294
+ columns: [table.tenantId, table.projectId],
295
+ foreignColumns: [projects.tenantId, projects.id],
296
+ name: "task_relations_project_fk"
297
+ }).onDelete("cascade")
298
+ ]
299
+ );
300
+ var dataComponents = pgCore.pgTable(
301
+ "data_components",
302
+ {
303
+ ...projectScoped,
304
+ ...uiProperties,
305
+ props: pgCore.jsonb("props").$type(),
306
+ render: pgCore.jsonb("render").$type(),
307
+ ...timestamps
308
+ },
309
+ (table) => [
310
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
311
+ pgCore.foreignKey({
312
+ columns: [table.tenantId, table.projectId],
313
+ foreignColumns: [projects.tenantId, projects.id],
314
+ name: "data_components_project_fk"
315
+ }).onDelete("cascade")
316
+ ]
317
+ );
318
+ var subAgentDataComponents = pgCore.pgTable(
319
+ "sub_agent_data_components",
320
+ {
321
+ ...subAgentScoped,
322
+ dataComponentId: pgCore.varchar("data_component_id", { length: 256 }).notNull(),
323
+ createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow()
324
+ },
325
+ (table) => [
326
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
327
+ pgCore.foreignKey({
328
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
329
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
330
+ name: "sub_agent_data_components_sub_agent_fk"
331
+ }).onDelete("cascade"),
332
+ pgCore.foreignKey({
333
+ columns: [table.tenantId, table.projectId, table.dataComponentId],
334
+ foreignColumns: [dataComponents.tenantId, dataComponents.projectId, dataComponents.id],
335
+ name: "sub_agent_data_components_data_component_fk"
336
+ }).onDelete("cascade")
337
+ ]
338
+ );
339
+ var artifactComponents = pgCore.pgTable(
340
+ "artifact_components",
341
+ {
342
+ ...projectScoped,
343
+ ...uiProperties,
344
+ props: pgCore.jsonb("props").$type(),
345
+ ...timestamps
346
+ },
347
+ (table) => [
348
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
349
+ pgCore.foreignKey({
350
+ columns: [table.tenantId, table.projectId],
351
+ foreignColumns: [projects.tenantId, projects.id],
352
+ name: "artifact_components_project_fk"
353
+ }).onDelete("cascade")
354
+ ]
355
+ );
356
+ var subAgentArtifactComponents = pgCore.pgTable(
357
+ "sub_agent_artifact_components",
358
+ {
359
+ ...subAgentScoped,
360
+ artifactComponentId: pgCore.varchar("artifact_component_id", { length: 256 }).notNull(),
361
+ createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow()
362
+ },
363
+ (table) => [
364
+ pgCore.primaryKey({
365
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId, table.id]
366
+ }),
367
+ pgCore.foreignKey({
368
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
369
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
370
+ name: "sub_agent_artifact_components_sub_agent_fk"
371
+ }).onDelete("cascade"),
372
+ pgCore.foreignKey({
373
+ columns: [table.tenantId, table.projectId, table.artifactComponentId],
374
+ foreignColumns: [
375
+ artifactComponents.tenantId,
376
+ artifactComponents.projectId,
377
+ artifactComponents.id
378
+ ],
379
+ name: "sub_agent_artifact_components_artifact_component_fk"
380
+ }).onDelete("cascade")
381
+ ]
382
+ );
383
+ var tools = pgCore.pgTable(
384
+ "tools",
385
+ {
386
+ ...projectScoped,
387
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
388
+ description: pgCore.text("description"),
389
+ config: pgCore.jsonb("config").$type().notNull(),
390
+ credentialReferenceId: pgCore.varchar("credential_reference_id", { length: 256 }),
391
+ headers: pgCore.jsonb("headers").$type(),
392
+ imageUrl: pgCore.text("image_url"),
393
+ capabilities: pgCore.jsonb("capabilities").$type(),
394
+ lastError: pgCore.text("last_error"),
395
+ ...timestamps
396
+ },
397
+ (table) => [
398
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
399
+ pgCore.foreignKey({
400
+ columns: [table.tenantId, table.projectId],
401
+ foreignColumns: [projects.tenantId, projects.id],
402
+ name: "tools_project_fk"
403
+ }).onDelete("cascade")
404
+ ]
405
+ );
406
+ var functionTools = pgCore.pgTable(
407
+ "function_tools",
408
+ {
409
+ ...agentScoped,
410
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
411
+ description: pgCore.text("description"),
412
+ functionId: pgCore.varchar("function_id", { length: 256 }).notNull(),
413
+ ...timestamps
414
+ },
415
+ (table) => [
416
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
417
+ pgCore.foreignKey({
418
+ columns: [table.tenantId, table.projectId, table.agentId],
419
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
420
+ name: "function_tools_agent_fk"
421
+ }).onDelete("cascade"),
422
+ pgCore.foreignKey({
423
+ columns: [table.tenantId, table.projectId, table.functionId],
424
+ foreignColumns: [functions.tenantId, functions.projectId, functions.id],
425
+ name: "function_tools_function_fk"
426
+ }).onDelete("cascade")
427
+ ]
428
+ );
429
+ var functions = pgCore.pgTable(
430
+ "functions",
431
+ {
432
+ ...projectScoped,
433
+ inputSchema: pgCore.jsonb("input_schema").$type(),
434
+ executeCode: pgCore.text("execute_code").notNull(),
435
+ dependencies: pgCore.jsonb("dependencies").$type(),
436
+ ...timestamps
437
+ },
438
+ (table) => [
439
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
440
+ pgCore.foreignKey({
441
+ columns: [table.tenantId, table.projectId],
442
+ foreignColumns: [projects.tenantId, projects.id],
443
+ name: "functions_project_fk"
444
+ }).onDelete("cascade")
445
+ ]
446
+ );
447
+ var subAgentToolRelations = pgCore.pgTable(
448
+ "sub_agent_tool_relations",
449
+ {
450
+ ...subAgentScoped,
451
+ toolId: pgCore.varchar("tool_id", { length: 256 }).notNull(),
452
+ selectedTools: pgCore.jsonb("selected_tools").$type(),
453
+ headers: pgCore.jsonb("headers").$type(),
454
+ toolPolicies: pgCore.jsonb("tool_policies").$type(),
455
+ ...timestamps
456
+ },
457
+ (table) => [
458
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
459
+ pgCore.foreignKey({
460
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
461
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
462
+ name: "sub_agent_tool_relations_agent_fk"
463
+ }).onDelete("cascade"),
464
+ pgCore.foreignKey({
465
+ columns: [table.tenantId, table.projectId, table.toolId],
466
+ foreignColumns: [tools.tenantId, tools.projectId, tools.id],
467
+ name: "sub_agent_tool_relations_tool_fk"
468
+ }).onDelete("cascade")
469
+ ]
470
+ );
471
+ var subAgentExternalAgentRelations = pgCore.pgTable(
472
+ "sub_agent_external_agent_relations",
473
+ {
474
+ ...subAgentScoped,
475
+ externalAgentId: pgCore.varchar("external_agent_id", { length: 256 }).notNull(),
476
+ headers: pgCore.jsonb("headers").$type(),
477
+ ...timestamps
478
+ },
479
+ (table) => [
480
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
481
+ pgCore.foreignKey({
482
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
483
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
484
+ name: "sub_agent_external_agent_relations_sub_agent_fk"
485
+ }).onDelete("cascade"),
486
+ pgCore.foreignKey({
487
+ columns: [table.tenantId, table.projectId, table.externalAgentId],
488
+ foreignColumns: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
489
+ name: "sub_agent_external_agent_relations_external_agent_fk"
490
+ }).onDelete("cascade")
491
+ ]
492
+ );
493
+ var subAgentTeamAgentRelations = pgCore.pgTable(
494
+ "sub_agent_team_agent_relations",
495
+ {
496
+ ...subAgentScoped,
497
+ targetAgentId: pgCore.varchar("target_agent_id", { length: 256 }).notNull(),
498
+ headers: pgCore.jsonb("headers").$type(),
499
+ ...timestamps
500
+ },
501
+ (table) => [
502
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
503
+ pgCore.foreignKey({
504
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
505
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
506
+ name: "sub_agent_team_agent_relations_sub_agent_fk"
507
+ }).onDelete("cascade"),
508
+ pgCore.foreignKey({
509
+ columns: [table.tenantId, table.projectId, table.targetAgentId],
510
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
511
+ name: "sub_agent_team_agent_relations_target_agent_fk"
512
+ }).onDelete("cascade")
513
+ ]
514
+ );
515
+ var subAgentFunctionToolRelations = pgCore.pgTable(
516
+ "sub_agent_function_tool_relations",
517
+ {
518
+ ...subAgentScoped,
519
+ functionToolId: pgCore.varchar("function_tool_id", { length: 256 }).notNull(),
520
+ ...timestamps
521
+ },
522
+ (table) => [
523
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
524
+ pgCore.foreignKey({
525
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
526
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
527
+ name: "sub_agent_function_tool_relations_sub_agent_fk"
528
+ }).onDelete("cascade"),
529
+ pgCore.foreignKey({
530
+ columns: [table.tenantId, table.projectId, table.agentId, table.functionToolId],
531
+ foreignColumns: [
532
+ functionTools.tenantId,
533
+ functionTools.projectId,
534
+ functionTools.agentId,
535
+ functionTools.id
536
+ ],
537
+ name: "sub_agent_function_tool_relations_function_tool_fk"
538
+ }).onDelete("cascade")
539
+ ]
540
+ );
541
+ var conversations = pgCore.pgTable(
542
+ "conversations",
543
+ {
544
+ ...projectScoped,
545
+ userId: pgCore.varchar("user_id", { length: 256 }),
546
+ activeSubAgentId: pgCore.varchar("active_sub_agent_id", { length: 256 }).notNull(),
547
+ title: pgCore.text("title"),
548
+ lastContextResolution: pgCore.timestamp("last_context_resolution", { mode: "string" }),
549
+ metadata: pgCore.jsonb("metadata").$type(),
550
+ ...timestamps
551
+ },
552
+ (table) => [
553
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
554
+ pgCore.foreignKey({
555
+ columns: [table.tenantId, table.projectId],
556
+ foreignColumns: [projects.tenantId, projects.id],
557
+ name: "conversations_project_fk"
558
+ }).onDelete("cascade")
559
+ ]
560
+ );
561
+ var messages = pgCore.pgTable(
562
+ "messages",
563
+ {
564
+ ...projectScoped,
565
+ conversationId: pgCore.varchar("conversation_id", { length: 256 }).notNull(),
566
+ role: pgCore.varchar("role", { length: 256 }).notNull(),
567
+ fromSubAgentId: pgCore.varchar("from_sub_agent_id", { length: 256 }),
568
+ toSubAgentId: pgCore.varchar("to_sub_agent_id", { length: 256 }),
569
+ fromExternalAgentId: pgCore.varchar("from_external_sub_agent_id", { length: 256 }),
570
+ toExternalAgentId: pgCore.varchar("to_external_sub_agent_id", { length: 256 }),
571
+ fromTeamAgentId: pgCore.varchar("from_team_agent_id", { length: 256 }),
572
+ toTeamAgentId: pgCore.varchar("to_team_agent_id", { length: 256 }),
573
+ content: pgCore.jsonb("content").$type().notNull(),
574
+ visibility: pgCore.varchar("visibility", { length: 256 }).notNull().default("user-facing"),
575
+ messageType: pgCore.varchar("message_type", { length: 256 }).notNull().default("chat"),
576
+ taskId: pgCore.varchar("task_id", { length: 256 }),
577
+ parentMessageId: pgCore.varchar("parent_message_id", { length: 256 }),
578
+ a2aTaskId: pgCore.varchar("a2a_task_id", { length: 256 }),
579
+ a2aSessionId: pgCore.varchar("a2a_session_id", { length: 256 }),
580
+ metadata: pgCore.jsonb("metadata").$type(),
581
+ ...timestamps
582
+ },
583
+ (table) => [
584
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
585
+ pgCore.foreignKey({
586
+ columns: [table.tenantId, table.projectId],
587
+ foreignColumns: [projects.tenantId, projects.id],
588
+ name: "messages_project_fk"
589
+ }).onDelete("cascade")
590
+ ]
591
+ );
592
+ var ledgerArtifacts = pgCore.pgTable(
593
+ "ledger_artifacts",
594
+ {
595
+ ...projectScoped,
596
+ taskId: pgCore.varchar("task_id", { length: 256 }).notNull(),
597
+ toolCallId: pgCore.varchar("tool_call_id", { length: 256 }),
598
+ contextId: pgCore.varchar("context_id", { length: 256 }).notNull(),
599
+ type: pgCore.varchar("type", { length: 256 }).notNull().default("source"),
600
+ name: pgCore.varchar("name", { length: 256 }),
601
+ description: pgCore.text("description"),
602
+ parts: pgCore.jsonb("parts").$type(),
603
+ metadata: pgCore.jsonb("metadata").$type(),
604
+ summary: pgCore.text("summary"),
605
+ mime: pgCore.jsonb("mime").$type(),
606
+ visibility: pgCore.varchar("visibility", { length: 256 }).default("context"),
607
+ allowedAgents: pgCore.jsonb("allowed_agents").$type(),
608
+ derivedFrom: pgCore.varchar("derived_from", { length: 256 }),
609
+ ...timestamps
610
+ },
611
+ (table) => [
612
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id, table.taskId] }),
613
+ pgCore.foreignKey({
614
+ columns: [table.tenantId, table.projectId],
615
+ foreignColumns: [projects.tenantId, projects.id],
616
+ name: "ledger_artifacts_project_fk"
617
+ }).onDelete("cascade"),
618
+ pgCore.index("ledger_artifacts_task_id_idx").on(table.taskId),
619
+ pgCore.index("ledger_artifacts_tool_call_id_idx").on(table.toolCallId),
620
+ pgCore.index("ledger_artifacts_context_id_idx").on(table.contextId),
621
+ pgCore.unique("ledger_artifacts_task_context_name_unique").on(
622
+ table.taskId,
623
+ table.contextId,
624
+ table.name
625
+ )
626
+ ]
627
+ );
628
+ var apiKeys = pgCore.pgTable(
629
+ "api_keys",
630
+ {
631
+ ...agentScoped,
632
+ publicId: pgCore.varchar("public_id", { length: 256 }).notNull().unique(),
633
+ keyHash: pgCore.varchar("key_hash", { length: 256 }).notNull(),
634
+ keyPrefix: pgCore.varchar("key_prefix", { length: 256 }).notNull(),
635
+ name: pgCore.varchar("name", { length: 256 }),
636
+ lastUsedAt: pgCore.timestamp("last_used_at", { mode: "string" }),
637
+ expiresAt: pgCore.timestamp("expires_at", { mode: "string" }),
638
+ ...timestamps
639
+ },
640
+ (t) => [
641
+ pgCore.foreignKey({
642
+ columns: [t.tenantId, t.projectId],
643
+ foreignColumns: [projects.tenantId, projects.id],
644
+ name: "api_keys_project_fk"
645
+ }).onDelete("cascade"),
646
+ pgCore.foreignKey({
647
+ columns: [t.tenantId, t.projectId, t.agentId],
648
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
649
+ name: "api_keys_agent_fk"
650
+ }).onDelete("cascade"),
651
+ pgCore.index("api_keys_tenant_agent_idx").on(t.tenantId, t.agentId),
652
+ pgCore.index("api_keys_prefix_idx").on(t.keyPrefix),
653
+ pgCore.index("api_keys_public_id_idx").on(t.publicId)
654
+ ]
655
+ );
656
+ var credentialReferences = pgCore.pgTable(
657
+ "credential_references",
658
+ {
659
+ ...projectScoped,
660
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
661
+ type: pgCore.varchar("type", { length: 256 }).notNull(),
662
+ credentialStoreId: pgCore.varchar("credential_store_id", { length: 256 }).notNull(),
663
+ retrievalParams: pgCore.jsonb("retrieval_params").$type(),
664
+ ...timestamps
665
+ },
666
+ (t) => [
667
+ pgCore.primaryKey({ columns: [t.tenantId, t.projectId, t.id] }),
668
+ pgCore.foreignKey({
669
+ columns: [t.tenantId, t.projectId],
670
+ foreignColumns: [projects.tenantId, projects.id],
671
+ name: "credential_references_project_fk"
672
+ }).onDelete("cascade")
673
+ ]
674
+ );
675
+ var dataset = pgCore.pgTable(
676
+ "dataset",
677
+ {
678
+ ...projectScoped,
679
+ ...uiProperties,
680
+ ...timestamps
681
+ },
682
+ (table) => [
683
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
684
+ pgCore.foreignKey({
685
+ columns: [table.tenantId, table.projectId],
686
+ foreignColumns: [projects.tenantId, projects.id],
687
+ name: "dataset_project_fk"
688
+ }).onDelete("cascade")
689
+ ]
690
+ );
691
+ var datasetItem = pgCore.pgTable(
692
+ "dataset_item",
693
+ {
694
+ ...projectScoped,
695
+ datasetId: pgCore.text("dataset_id").notNull(),
696
+ input: pgCore.jsonb("input").$type().notNull(),
697
+ expectedOutput: pgCore.jsonb("expected_output").$type(),
698
+ simulationAgent: pgCore.jsonb("simulation_agent").$type(),
699
+ ...timestamps
700
+ },
701
+ (table) => [
702
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
703
+ pgCore.foreignKey({
704
+ columns: [table.tenantId, table.projectId, table.datasetId],
705
+ foreignColumns: [dataset.tenantId, dataset.projectId, dataset.id],
706
+ name: "dataset_item_dataset_fk"
707
+ }).onDelete("cascade")
708
+ ]
709
+ );
710
+ var evaluator = pgCore.pgTable(
711
+ "evaluator",
712
+ {
713
+ ...projectScoped,
714
+ ...uiProperties,
715
+ prompt: pgCore.text("prompt").notNull(),
716
+ schema: pgCore.jsonb("schema").$type().notNull(),
717
+ model: pgCore.jsonb("model").$type().notNull(),
718
+ passCriteria: pgCore.jsonb("pass_criteria").$type(),
719
+ ...timestamps
720
+ },
721
+ (table) => [
722
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
723
+ pgCore.foreignKey({
724
+ columns: [table.tenantId, table.projectId],
725
+ foreignColumns: [projects.tenantId, projects.id],
726
+ name: "evaluator_project_fk"
727
+ }).onDelete("cascade")
728
+ ]
729
+ );
730
+ var datasetRunConfig = pgCore.pgTable(
731
+ "dataset_run_config",
732
+ {
733
+ ...projectScoped,
734
+ ...uiProperties,
735
+ datasetId: pgCore.text("dataset_id").notNull(),
736
+ ...timestamps
737
+ },
738
+ (table) => [
739
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
740
+ pgCore.foreignKey({
741
+ columns: [table.tenantId, table.projectId],
742
+ foreignColumns: [projects.tenantId, projects.id],
743
+ name: "dataset_run_config_project_fk"
744
+ }).onDelete("cascade"),
745
+ pgCore.foreignKey({
746
+ columns: [table.tenantId, table.projectId, table.datasetId],
747
+ foreignColumns: [dataset.tenantId, dataset.projectId, dataset.id],
748
+ name: "dataset_run_config_dataset_fk"
749
+ }).onDelete("cascade")
750
+ ]
751
+ );
752
+ var datasetRunConfigAgentRelations = pgCore.pgTable(
753
+ "dataset_run_config_agent_relations",
754
+ {
755
+ ...projectScoped,
756
+ datasetRunConfigId: pgCore.text("dataset_run_config_id").notNull(),
757
+ agentId: pgCore.text("agent_id").notNull(),
758
+ ...timestamps
759
+ },
760
+ (table) => [
761
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
762
+ pgCore.foreignKey({
763
+ columns: [table.tenantId, table.projectId, table.datasetRunConfigId],
764
+ foreignColumns: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id],
765
+ name: "dataset_run_config_agent_relations_dataset_run_config_fk"
766
+ }).onDelete("cascade"),
767
+ pgCore.foreignKey({
768
+ columns: [table.tenantId, table.projectId, table.agentId],
769
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
770
+ name: "dataset_run_config_agent_relations_agent_fk"
771
+ }).onDelete("cascade")
772
+ ]
773
+ );
774
+ var datasetRunConfigEvaluationRunConfigRelations = pgCore.pgTable(
775
+ "dataset_run_config_evaluation_run_config_relations",
776
+ {
777
+ ...projectScoped,
778
+ datasetRunConfigId: pgCore.text("dataset_run_config_id").notNull(),
779
+ evaluationRunConfigId: pgCore.text("evaluation_run_config_id").notNull(),
780
+ enabled: pgCore.boolean("enabled").notNull().default(true),
781
+ ...timestamps
782
+ },
783
+ (table) => [
784
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
785
+ pgCore.foreignKey({
786
+ columns: [table.tenantId, table.projectId, table.datasetRunConfigId],
787
+ foreignColumns: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id],
788
+ name: "dataset_run_config_evaluation_run_config_relations_dataset_run_config_fk"
789
+ }).onDelete("cascade"),
790
+ pgCore.foreignKey({
791
+ columns: [table.tenantId, table.projectId, table.evaluationRunConfigId],
792
+ foreignColumns: [
793
+ evaluationRunConfig.tenantId,
794
+ evaluationRunConfig.projectId,
795
+ evaluationRunConfig.id
796
+ ],
797
+ name: "dataset_run_config_evaluation_run_config_relations_evaluation_run_config_fk"
798
+ }).onDelete("cascade")
799
+ ]
800
+ );
801
+ var datasetRun = pgCore.pgTable(
802
+ "dataset_run",
803
+ {
804
+ ...projectScoped,
805
+ datasetId: pgCore.text("dataset_id").notNull(),
806
+ datasetRunConfigId: pgCore.text("dataset_run_config_id").notNull(),
807
+ evaluationJobConfigId: pgCore.text("evaluation_job_config_id"),
808
+ ...timestamps
809
+ },
810
+ (table) => [
811
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
812
+ pgCore.foreignKey({
813
+ columns: [table.tenantId, table.projectId, table.datasetId],
814
+ foreignColumns: [dataset.tenantId, dataset.projectId, dataset.id],
815
+ name: "dataset_run_dataset_fk"
816
+ }).onDelete("cascade"),
817
+ pgCore.foreignKey({
818
+ columns: [table.tenantId, table.projectId, table.datasetRunConfigId],
819
+ foreignColumns: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id],
820
+ name: "dataset_run_dataset_run_config_fk"
821
+ }).onDelete("cascade"),
822
+ pgCore.foreignKey({
823
+ columns: [table.tenantId, table.projectId, table.evaluationJobConfigId],
824
+ foreignColumns: [
825
+ evaluationJobConfig.tenantId,
826
+ evaluationJobConfig.projectId,
827
+ evaluationJobConfig.id
828
+ ],
829
+ name: "dataset_run_evaluation_job_config_fk"
830
+ }).onDelete("set null")
831
+ ]
832
+ );
833
+ var datasetRunConversationRelations = pgCore.pgTable(
834
+ "dataset_run_conversation_relations",
835
+ {
836
+ ...projectScoped,
837
+ datasetRunId: pgCore.text("dataset_run_id").notNull(),
838
+ conversationId: pgCore.text("conversation_id").notNull(),
839
+ datasetItemId: pgCore.text("dataset_item_id").notNull(),
840
+ ...timestamps
841
+ },
842
+ (table) => [
843
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
844
+ pgCore.foreignKey({
845
+ columns: [table.tenantId, table.projectId, table.datasetRunId],
846
+ foreignColumns: [datasetRun.tenantId, datasetRun.projectId, datasetRun.id],
847
+ name: "dataset_run_conversation_relations_run_fk"
848
+ }).onDelete("cascade"),
849
+ pgCore.foreignKey({
850
+ columns: [table.tenantId, table.projectId, table.conversationId],
851
+ foreignColumns: [conversations.tenantId, conversations.projectId, conversations.id],
852
+ name: "dataset_run_conversation_relations_conversation_fk"
853
+ }).onDelete("cascade"),
854
+ pgCore.foreignKey({
855
+ columns: [table.tenantId, table.projectId, table.datasetItemId],
856
+ foreignColumns: [datasetItem.tenantId, datasetItem.projectId, datasetItem.id],
857
+ name: "dataset_run_conversation_relations_item_fk"
858
+ }).onDelete("cascade"),
859
+ pgCore.unique("dataset_run_conversation_relations_unique").on(
860
+ table.datasetRunId,
861
+ table.conversationId
862
+ )
863
+ ]
864
+ );
865
+ var evaluationSuiteConfig = pgCore.pgTable(
866
+ "evaluation_suite_config",
867
+ {
868
+ ...projectScoped,
869
+ ...uiProperties,
870
+ filters: pgCore.jsonb("filters").$type(),
871
+ // Filters for the evaluation suite (supports and/or operations)
872
+ sampleRate: pgCore.doublePrecision("sample_rate"),
873
+ ...timestamps
874
+ },
875
+ (table) => [
876
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
877
+ pgCore.foreignKey({
878
+ columns: [table.tenantId, table.projectId],
879
+ foreignColumns: [projects.tenantId, projects.id],
880
+ name: "evaluation_suite_config_project_fk"
881
+ }).onDelete("cascade")
882
+ ]
883
+ );
884
+ var evaluationSuiteConfigEvaluatorRelations = pgCore.pgTable(
885
+ "evaluation_suite_config_evaluator_relations",
886
+ {
887
+ ...projectScoped,
888
+ evaluationSuiteConfigId: pgCore.text("evaluation_suite_config_id").notNull(),
889
+ evaluatorId: pgCore.text("evaluator_id").notNull(),
890
+ ...timestamps
891
+ },
892
+ (table) => [
893
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
894
+ pgCore.foreignKey({
895
+ columns: [table.tenantId, table.projectId, table.evaluationSuiteConfigId],
896
+ foreignColumns: [
897
+ evaluationSuiteConfig.tenantId,
898
+ evaluationSuiteConfig.projectId,
899
+ evaluationSuiteConfig.id
900
+ ],
901
+ name: "evaluation_suite_config_evaluator_relations_evaluation_suite_config_fk"
902
+ }).onDelete("cascade"),
903
+ pgCore.foreignKey({
904
+ columns: [table.tenantId, table.projectId, table.evaluatorId],
905
+ foreignColumns: [evaluator.tenantId, evaluator.projectId, evaluator.id],
906
+ name: "evaluation_suite_config_evaluator_relations_evaluator_fk"
907
+ }).onDelete("cascade")
908
+ ]
909
+ );
910
+ var evaluationRunConfig = pgCore.pgTable(
911
+ "evaluation_run_config",
912
+ {
913
+ ...projectScoped,
914
+ ...uiProperties,
915
+ isActive: pgCore.boolean("is_active").notNull().default(true),
916
+ ...timestamps
917
+ },
918
+ (table) => [
919
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
920
+ pgCore.foreignKey({
921
+ columns: [table.tenantId, table.projectId],
922
+ foreignColumns: [projects.tenantId, projects.id],
923
+ name: "evaluation_run_config_project_fk"
924
+ }).onDelete("cascade")
925
+ ]
926
+ );
927
+ var evaluationRunConfigEvaluationSuiteConfigRelations = pgCore.pgTable(
928
+ "evaluation_run_config_evaluation_suite_config_relations",
929
+ {
930
+ ...projectScoped,
931
+ evaluationRunConfigId: pgCore.text("evaluation_run_config_id").notNull(),
932
+ evaluationSuiteConfigId: pgCore.text("evaluation_suite_config_id").notNull(),
933
+ ...timestamps
934
+ },
935
+ (table) => [
936
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
937
+ pgCore.foreignKey({
938
+ columns: [table.tenantId, table.projectId, table.evaluationRunConfigId],
939
+ foreignColumns: [
940
+ evaluationRunConfig.tenantId,
941
+ evaluationRunConfig.projectId,
942
+ evaluationRunConfig.id
943
+ ],
944
+ name: "eval_run_config_eval_suite_rel_run_config_fk"
945
+ }).onDelete("cascade"),
946
+ pgCore.foreignKey({
947
+ columns: [table.tenantId, table.projectId, table.evaluationSuiteConfigId],
948
+ foreignColumns: [
949
+ evaluationSuiteConfig.tenantId,
950
+ evaluationSuiteConfig.projectId,
951
+ evaluationSuiteConfig.id
952
+ ],
953
+ name: "eval_run_config_eval_suite_rel_suite_config_fk"
954
+ }).onDelete("cascade")
955
+ ]
956
+ );
957
+ var evaluationJobConfig = pgCore.pgTable(
958
+ "evaluation_job_config",
959
+ {
960
+ ...projectScoped,
961
+ jobFilters: pgCore.jsonb("job_filters").$type(),
962
+ ...timestamps
963
+ },
964
+ (table) => [
965
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
966
+ pgCore.foreignKey({
967
+ columns: [table.tenantId, table.projectId],
968
+ foreignColumns: [projects.tenantId, projects.id],
969
+ name: "evaluation_job_config_project_fk"
970
+ }).onDelete("cascade")
971
+ ]
972
+ );
973
+ var evaluationJobConfigEvaluatorRelations = pgCore.pgTable(
974
+ "evaluation_job_config_evaluator_relations",
975
+ {
976
+ ...projectScoped,
977
+ evaluationJobConfigId: pgCore.text("evaluation_job_config_id").notNull(),
978
+ evaluatorId: pgCore.text("evaluator_id").notNull(),
979
+ ...timestamps
980
+ },
981
+ (table) => [
982
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
983
+ pgCore.foreignKey({
984
+ columns: [table.tenantId, table.projectId, table.evaluationJobConfigId],
985
+ foreignColumns: [
986
+ evaluationJobConfig.tenantId,
987
+ evaluationJobConfig.projectId,
988
+ evaluationJobConfig.id
989
+ ],
990
+ name: "evaluation_job_config_evaluator_relations_evaluation_job_config_fk"
991
+ }).onDelete("cascade"),
992
+ pgCore.foreignKey({
993
+ columns: [table.tenantId, table.projectId, table.evaluatorId],
994
+ foreignColumns: [evaluator.tenantId, evaluator.projectId, evaluator.id],
995
+ name: "evaluation_job_config_evaluator_relations_evaluator_fk"
996
+ }).onDelete("cascade")
997
+ ]
998
+ );
999
+ var evaluationRun = pgCore.pgTable(
1000
+ "evaluation_run",
1001
+ {
1002
+ ...projectScoped,
1003
+ evaluationJobConfigId: pgCore.text("evaluation_job_config_id"),
1004
+ // Optional: if created from a job
1005
+ evaluationRunConfigId: pgCore.text("evaluation_run_config_id"),
1006
+ // Optional: if created from a run config
1007
+ ...timestamps
1008
+ },
1009
+ (table) => [
1010
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
1011
+ pgCore.foreignKey({
1012
+ columns: [table.tenantId, table.projectId, table.evaluationJobConfigId],
1013
+ foreignColumns: [
1014
+ evaluationJobConfig.tenantId,
1015
+ evaluationJobConfig.projectId,
1016
+ evaluationJobConfig.id
1017
+ ],
1018
+ name: "evaluation_run_evaluation_job_config_fk"
1019
+ }).onDelete("cascade"),
1020
+ pgCore.foreignKey({
1021
+ columns: [table.tenantId, table.projectId, table.evaluationRunConfigId],
1022
+ foreignColumns: [
1023
+ evaluationRunConfig.tenantId,
1024
+ evaluationRunConfig.projectId,
1025
+ evaluationRunConfig.id
1026
+ ],
1027
+ name: "evaluation_run_evaluation_run_config_fk"
1028
+ }).onDelete("cascade")
1029
+ ]
1030
+ );
1031
+ var evaluationResult = pgCore.pgTable(
1032
+ "evaluation_result",
1033
+ {
1034
+ ...projectScoped,
1035
+ conversationId: pgCore.text("conversation_id").notNull(),
1036
+ evaluatorId: pgCore.text("evaluator_id").notNull(),
1037
+ evaluationRunId: pgCore.text("evaluation_run_id"),
1038
+ output: pgCore.jsonb("output").$type(),
1039
+ ...timestamps
1040
+ },
1041
+ (table) => [
1042
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
1043
+ pgCore.foreignKey({
1044
+ columns: [table.tenantId, table.projectId, table.conversationId],
1045
+ foreignColumns: [conversations.tenantId, conversations.projectId, conversations.id],
1046
+ name: "evaluation_result_conversation_fk"
1047
+ }).onDelete("cascade"),
1048
+ pgCore.foreignKey({
1049
+ columns: [table.tenantId, table.projectId, table.evaluatorId],
1050
+ foreignColumns: [evaluator.tenantId, evaluator.projectId, evaluator.id],
1051
+ name: "evaluation_result_evaluator_fk"
1052
+ }).onDelete("cascade"),
1053
+ pgCore.foreignKey({
1054
+ columns: [table.tenantId, table.projectId, table.evaluationRunId],
1055
+ foreignColumns: [evaluationRun.tenantId, evaluationRun.projectId, evaluationRun.id],
1056
+ name: "evaluation_result_evaluation_run_fk"
1057
+ }).onDelete("cascade")
1058
+ ]
1059
+ );
1060
+ drizzleOrm.relations(tasks, ({ one, many }) => ({
1061
+ project: one(projects, {
1062
+ fields: [tasks.tenantId, tasks.projectId],
1063
+ references: [projects.tenantId, projects.id]
1064
+ }),
1065
+ // A task can have many parent relationships (where it's the child)
1066
+ parentRelations: many(taskRelations, {
1067
+ relationName: "childTask"
1068
+ }),
1069
+ // A task can have many child relationships (where it's the parent)
1070
+ childRelations: many(taskRelations, {
1071
+ relationName: "parentTask"
1072
+ }),
1073
+ subAgent: one(subAgents, {
1074
+ fields: [tasks.subAgentId],
1075
+ references: [subAgents.id]
1076
+ }),
1077
+ messages: many(messages),
1078
+ ledgerArtifacts: many(ledgerArtifacts)
1079
+ }));
1080
+ drizzleOrm.relations(projects, ({ many }) => ({
1081
+ subAgents: many(subAgents),
1082
+ agents: many(agents),
1083
+ tools: many(tools),
1084
+ functions: many(functions),
1085
+ contextConfigs: many(contextConfigs),
1086
+ externalAgents: many(externalAgents),
1087
+ conversations: many(conversations),
1088
+ tasks: many(tasks),
1089
+ dataComponents: many(dataComponents),
1090
+ artifactComponents: many(artifactComponents),
1091
+ ledgerArtifacts: many(ledgerArtifacts),
1092
+ credentialReferences: many(credentialReferences),
1093
+ datasets: many(dataset),
1094
+ evaluators: many(evaluator),
1095
+ evaluationSuiteConfigs: many(evaluationSuiteConfig),
1096
+ datasetRunConfigs: many(datasetRunConfig)
1097
+ }));
1098
+ drizzleOrm.relations(taskRelations, ({ one }) => ({
1099
+ parentTask: one(tasks, {
1100
+ fields: [taskRelations.parentTaskId],
1101
+ references: [tasks.id],
1102
+ relationName: "parentTask"
1103
+ }),
1104
+ childTask: one(tasks, {
1105
+ fields: [taskRelations.childTaskId],
1106
+ references: [tasks.id],
1107
+ relationName: "childTask"
1108
+ })
1109
+ }));
1110
+ drizzleOrm.relations(contextConfigs, ({ many, one }) => ({
1111
+ project: one(projects, {
1112
+ fields: [contextConfigs.tenantId, contextConfigs.projectId],
1113
+ references: [projects.tenantId, projects.id]
1114
+ }),
1115
+ agents: many(agents),
1116
+ cache: many(contextCache)
1117
+ }));
1118
+ drizzleOrm.relations(contextCache, ({ one }) => ({
1119
+ contextConfig: one(contextConfigs, {
1120
+ fields: [contextCache.contextConfigId],
1121
+ references: [contextConfigs.id]
1122
+ })
1123
+ }));
1124
+ drizzleOrm.relations(subAgents, ({ many, one }) => ({
1125
+ project: one(projects, {
1126
+ fields: [subAgents.tenantId, subAgents.projectId],
1127
+ references: [projects.tenantId, projects.id]
1128
+ }),
1129
+ tasks: many(tasks),
1130
+ defaultForAgents: many(agents),
1131
+ sourceRelations: many(subAgentRelations, {
1132
+ relationName: "sourceRelations"
1133
+ }),
1134
+ targetRelations: many(subAgentRelations, {
1135
+ relationName: "targetRelations"
1136
+ }),
1137
+ sentMessages: many(messages, {
1138
+ relationName: "sentMessages"
1139
+ }),
1140
+ receivedMessages: many(messages, {
1141
+ relationName: "receivedMessages"
1142
+ }),
1143
+ toolRelations: many(subAgentToolRelations),
1144
+ functionToolRelations: many(subAgentFunctionToolRelations),
1145
+ dataComponentRelations: many(subAgentDataComponents),
1146
+ artifactComponentRelations: many(subAgentArtifactComponents)
1147
+ }));
1148
+ drizzleOrm.relations(agents, ({ one, many }) => ({
1149
+ project: one(projects, {
1150
+ fields: [agents.tenantId, agents.projectId],
1151
+ references: [projects.tenantId, projects.id]
1152
+ }),
1153
+ defaultSubAgent: one(subAgents, {
1154
+ fields: [agents.defaultSubAgentId],
1155
+ references: [subAgents.id]
1156
+ }),
1157
+ contextConfig: one(contextConfigs, {
1158
+ fields: [agents.contextConfigId],
1159
+ references: [contextConfigs.id]
1160
+ }),
1161
+ functionTools: many(functionTools)
1162
+ }));
1163
+ drizzleOrm.relations(externalAgents, ({ one, many }) => ({
1164
+ project: one(projects, {
1165
+ fields: [externalAgents.tenantId, externalAgents.projectId],
1166
+ references: [projects.tenantId, projects.id]
1167
+ }),
1168
+ subAgentExternalAgentRelations: many(subAgentExternalAgentRelations),
1169
+ credentialReference: one(credentialReferences, {
1170
+ fields: [externalAgents.credentialReferenceId],
1171
+ references: [credentialReferences.id]
1172
+ })
1173
+ }));
1174
+ drizzleOrm.relations(apiKeys, ({ one }) => ({
1175
+ project: one(projects, {
1176
+ fields: [apiKeys.tenantId, apiKeys.projectId],
1177
+ references: [projects.tenantId, projects.id]
1178
+ }),
1179
+ agent: one(agents, {
1180
+ fields: [apiKeys.agentId],
1181
+ references: [agents.id]
1182
+ })
1183
+ }));
1184
+ drizzleOrm.relations(subAgentToolRelations, ({ one }) => ({
1185
+ subAgent: one(subAgents, {
1186
+ fields: [subAgentToolRelations.subAgentId],
1187
+ references: [subAgents.id]
1188
+ }),
1189
+ tool: one(tools, {
1190
+ fields: [subAgentToolRelations.toolId],
1191
+ references: [tools.id]
1192
+ })
1193
+ }));
1194
+ drizzleOrm.relations(credentialReferences, ({ one, many }) => ({
1195
+ project: one(projects, {
1196
+ fields: [credentialReferences.tenantId, credentialReferences.projectId],
1197
+ references: [projects.tenantId, projects.id]
1198
+ }),
1199
+ tools: many(tools),
1200
+ externalAgents: many(externalAgents)
1201
+ }));
1202
+ drizzleOrm.relations(tools, ({ one, many }) => ({
1203
+ project: one(projects, {
1204
+ fields: [tools.tenantId, tools.projectId],
1205
+ references: [projects.tenantId, projects.id]
1206
+ }),
1207
+ subAgentRelations: many(subAgentToolRelations),
1208
+ credentialReference: one(credentialReferences, {
1209
+ fields: [tools.credentialReferenceId],
1210
+ references: [credentialReferences.id]
1211
+ })
1212
+ }));
1213
+ drizzleOrm.relations(conversations, ({ one, many }) => ({
1214
+ project: one(projects, {
1215
+ fields: [conversations.tenantId, conversations.projectId],
1216
+ references: [projects.tenantId, projects.id]
1217
+ }),
1218
+ messages: many(messages),
1219
+ activeSubAgent: one(subAgents, {
1220
+ fields: [conversations.activeSubAgentId],
1221
+ references: [subAgents.id]
1222
+ })
1223
+ }));
1224
+ drizzleOrm.relations(messages, ({ one, many }) => ({
1225
+ conversation: one(conversations, {
1226
+ fields: [messages.conversationId],
1227
+ references: [conversations.id]
1228
+ }),
1229
+ fromSubAgent: one(subAgents, {
1230
+ fields: [messages.fromSubAgentId],
1231
+ references: [subAgents.id],
1232
+ relationName: "sentMessages"
1233
+ }),
1234
+ toSubAgent: one(subAgents, {
1235
+ fields: [messages.toSubAgentId],
1236
+ references: [subAgents.id],
1237
+ relationName: "receivedMessages"
1238
+ }),
1239
+ fromTeamAgent: one(agents, {
1240
+ fields: [messages.fromTeamAgentId],
1241
+ references: [agents.id],
1242
+ relationName: "receivedTeamMessages"
1243
+ }),
1244
+ toTeamAgent: one(agents, {
1245
+ fields: [messages.toTeamAgentId],
1246
+ references: [agents.id],
1247
+ relationName: "sentTeamMessages"
1248
+ }),
1249
+ fromExternalAgent: one(externalAgents, {
1250
+ fields: [messages.tenantId, messages.projectId, messages.fromExternalAgentId],
1251
+ references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
1252
+ relationName: "receivedExternalMessages"
1253
+ }),
1254
+ toExternalAgent: one(externalAgents, {
1255
+ fields: [messages.tenantId, messages.projectId, messages.toExternalAgentId],
1256
+ references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
1257
+ relationName: "sentExternalMessages"
1258
+ }),
1259
+ task: one(tasks, {
1260
+ fields: [messages.taskId],
1261
+ references: [tasks.id]
1262
+ }),
1263
+ parentMessage: one(messages, {
1264
+ fields: [messages.parentMessageId],
1265
+ references: [messages.id],
1266
+ relationName: "parentChild"
1267
+ }),
1268
+ childMessages: many(messages, {
1269
+ relationName: "parentChild"
1270
+ })
1271
+ }));
1272
+ drizzleOrm.relations(artifactComponents, ({ many, one }) => ({
1273
+ project: one(projects, {
1274
+ fields: [artifactComponents.tenantId, artifactComponents.projectId],
1275
+ references: [projects.tenantId, projects.id]
1276
+ }),
1277
+ subAgentRelations: many(subAgentArtifactComponents)
1278
+ }));
1279
+ drizzleOrm.relations(
1280
+ subAgentArtifactComponents,
1281
+ ({ one }) => ({
1282
+ subAgent: one(subAgents, {
1283
+ fields: [subAgentArtifactComponents.subAgentId],
1284
+ references: [subAgents.id]
1285
+ }),
1286
+ artifactComponent: one(artifactComponents, {
1287
+ fields: [subAgentArtifactComponents.artifactComponentId],
1288
+ references: [artifactComponents.id]
1289
+ })
1290
+ })
1291
+ );
1292
+ drizzleOrm.relations(dataComponents, ({ many, one }) => ({
1293
+ project: one(projects, {
1294
+ fields: [dataComponents.tenantId, dataComponents.projectId],
1295
+ references: [projects.tenantId, projects.id]
1296
+ }),
1297
+ subAgentRelations: many(subAgentDataComponents)
1298
+ }));
1299
+ drizzleOrm.relations(subAgentDataComponents, ({ one }) => ({
1300
+ subAgent: one(subAgents, {
1301
+ fields: [subAgentDataComponents.subAgentId],
1302
+ references: [subAgents.id]
1303
+ }),
1304
+ dataComponent: one(dataComponents, {
1305
+ fields: [subAgentDataComponents.dataComponentId],
1306
+ references: [dataComponents.id]
1307
+ })
1308
+ }));
1309
+ drizzleOrm.relations(ledgerArtifacts, ({ one }) => ({
1310
+ project: one(projects, {
1311
+ fields: [ledgerArtifacts.tenantId, ledgerArtifacts.projectId],
1312
+ references: [projects.tenantId, projects.id]
1313
+ }),
1314
+ task: one(tasks, {
1315
+ fields: [ledgerArtifacts.taskId],
1316
+ references: [tasks.id]
1317
+ })
1318
+ }));
1319
+ drizzleOrm.relations(functions, ({ many, one }) => ({
1320
+ functionTools: many(functionTools),
1321
+ project: one(projects, {
1322
+ fields: [functions.tenantId, functions.projectId],
1323
+ references: [projects.tenantId, projects.id]
1324
+ })
1325
+ }));
1326
+ drizzleOrm.relations(subAgentRelations, ({ one }) => ({
1327
+ agent: one(agents, {
1328
+ fields: [subAgentRelations.agentId],
1329
+ references: [agents.id]
1330
+ }),
1331
+ sourceSubAgent: one(subAgents, {
1332
+ fields: [subAgentRelations.sourceSubAgentId],
1333
+ references: [subAgents.id],
1334
+ relationName: "sourceRelations"
1335
+ }),
1336
+ targetSubAgent: one(subAgents, {
1337
+ fields: [subAgentRelations.targetSubAgentId],
1338
+ references: [subAgents.id],
1339
+ relationName: "targetRelations"
1340
+ })
1341
+ }));
1342
+ drizzleOrm.relations(functionTools, ({ one, many }) => ({
1343
+ project: one(projects, {
1344
+ fields: [functionTools.tenantId, functionTools.projectId],
1345
+ references: [projects.tenantId, projects.id]
1346
+ }),
1347
+ agent: one(agents, {
1348
+ fields: [functionTools.tenantId, functionTools.projectId, functionTools.agentId],
1349
+ references: [agents.tenantId, agents.projectId, agents.id]
1350
+ }),
1351
+ function: one(functions, {
1352
+ fields: [functionTools.tenantId, functionTools.projectId, functionTools.functionId],
1353
+ references: [functions.tenantId, functions.projectId, functions.id]
1354
+ }),
1355
+ subAgentRelations: many(subAgentFunctionToolRelations)
1356
+ }));
1357
+ drizzleOrm.relations(
1358
+ subAgentFunctionToolRelations,
1359
+ ({ one }) => ({
1360
+ subAgent: one(subAgents, {
1361
+ fields: [subAgentFunctionToolRelations.subAgentId],
1362
+ references: [subAgents.id]
1363
+ }),
1364
+ functionTool: one(functionTools, {
1365
+ fields: [subAgentFunctionToolRelations.functionToolId],
1366
+ references: [functionTools.id]
1367
+ })
1368
+ })
1369
+ );
1370
+ drizzleOrm.relations(
1371
+ subAgentExternalAgentRelations,
1372
+ ({ one }) => ({
1373
+ subAgent: one(subAgents, {
1374
+ fields: [
1375
+ subAgentExternalAgentRelations.tenantId,
1376
+ subAgentExternalAgentRelations.projectId,
1377
+ subAgentExternalAgentRelations.agentId,
1378
+ subAgentExternalAgentRelations.subAgentId
1379
+ ],
1380
+ references: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id]
1381
+ }),
1382
+ externalAgent: one(externalAgents, {
1383
+ fields: [
1384
+ subAgentExternalAgentRelations.tenantId,
1385
+ subAgentExternalAgentRelations.projectId,
1386
+ subAgentExternalAgentRelations.externalAgentId
1387
+ ],
1388
+ references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id]
1389
+ })
1390
+ })
1391
+ );
1392
+ drizzleOrm.relations(
1393
+ subAgentTeamAgentRelations,
1394
+ ({ one }) => ({
1395
+ subAgent: one(subAgents, {
1396
+ fields: [
1397
+ subAgentTeamAgentRelations.tenantId,
1398
+ subAgentTeamAgentRelations.projectId,
1399
+ subAgentTeamAgentRelations.agentId,
1400
+ subAgentTeamAgentRelations.subAgentId
1401
+ ],
1402
+ references: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id]
1403
+ }),
1404
+ targetAgent: one(agents, {
1405
+ fields: [
1406
+ subAgentTeamAgentRelations.tenantId,
1407
+ subAgentTeamAgentRelations.projectId,
1408
+ subAgentTeamAgentRelations.targetAgentId
1409
+ ],
1410
+ references: [agents.tenantId, agents.projectId, agents.id]
1411
+ })
1412
+ })
1413
+ );
1414
+ drizzleOrm.relations(dataset, ({ one, many }) => ({
1415
+ project: one(projects, {
1416
+ fields: [dataset.tenantId, dataset.projectId],
1417
+ references: [projects.tenantId, projects.id]
1418
+ }),
1419
+ items: many(datasetItem),
1420
+ datasetRuns: many(datasetRun)
1421
+ }));
1422
+ drizzleOrm.relations(datasetItem, ({ one }) => ({
1423
+ dataset: one(dataset, {
1424
+ fields: [datasetItem.tenantId, datasetItem.projectId, datasetItem.datasetId],
1425
+ references: [dataset.tenantId, dataset.projectId, dataset.id]
1426
+ })
1427
+ }));
1428
+ drizzleOrm.relations(evaluator, ({ one, many }) => ({
1429
+ project: one(projects, {
1430
+ fields: [evaluator.tenantId, evaluator.projectId],
1431
+ references: [projects.tenantId, projects.id]
1432
+ }),
1433
+ evaluationResults: many(evaluationResult),
1434
+ evaluationSuiteConfigs: many(evaluationSuiteConfigEvaluatorRelations),
1435
+ evaluationJobConfigs: many(evaluationJobConfigEvaluatorRelations)
1436
+ }));
1437
+ drizzleOrm.relations(datasetRunConfig, ({ one, many }) => ({
1438
+ project: one(projects, {
1439
+ fields: [datasetRunConfig.tenantId, datasetRunConfig.projectId],
1440
+ references: [projects.tenantId, projects.id]
1441
+ }),
1442
+ dataset: one(dataset, {
1443
+ fields: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.datasetId],
1444
+ references: [dataset.tenantId, dataset.projectId, dataset.id]
1445
+ }),
1446
+ agents: many(datasetRunConfigAgentRelations),
1447
+ evaluationRunConfigs: many(datasetRunConfigEvaluationRunConfigRelations),
1448
+ runs: many(datasetRun)
1449
+ }));
1450
+ drizzleOrm.relations(
1451
+ datasetRunConfigAgentRelations,
1452
+ ({ one }) => ({
1453
+ datasetRunConfig: one(datasetRunConfig, {
1454
+ fields: [
1455
+ datasetRunConfigAgentRelations.tenantId,
1456
+ datasetRunConfigAgentRelations.projectId,
1457
+ datasetRunConfigAgentRelations.datasetRunConfigId
1458
+ ],
1459
+ references: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id]
1460
+ }),
1461
+ agent: one(agents, {
1462
+ fields: [
1463
+ datasetRunConfigAgentRelations.tenantId,
1464
+ datasetRunConfigAgentRelations.projectId,
1465
+ datasetRunConfigAgentRelations.agentId
1466
+ ],
1467
+ references: [agents.tenantId, agents.projectId, agents.id]
1468
+ })
1469
+ })
1470
+ );
1471
+ drizzleOrm.relations(
1472
+ datasetRunConfigEvaluationRunConfigRelations,
1473
+ ({ one }) => ({
1474
+ datasetRunConfig: one(datasetRunConfig, {
1475
+ fields: [
1476
+ datasetRunConfigEvaluationRunConfigRelations.tenantId,
1477
+ datasetRunConfigEvaluationRunConfigRelations.projectId,
1478
+ datasetRunConfigEvaluationRunConfigRelations.datasetRunConfigId
1479
+ ],
1480
+ references: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id]
1481
+ }),
1482
+ evaluationRunConfig: one(evaluationRunConfig, {
1483
+ fields: [
1484
+ datasetRunConfigEvaluationRunConfigRelations.tenantId,
1485
+ datasetRunConfigEvaluationRunConfigRelations.projectId,
1486
+ datasetRunConfigEvaluationRunConfigRelations.evaluationRunConfigId
1487
+ ],
1488
+ references: [
1489
+ evaluationRunConfig.tenantId,
1490
+ evaluationRunConfig.projectId,
1491
+ evaluationRunConfig.id
1492
+ ]
1493
+ })
1494
+ })
1495
+ );
1496
+ drizzleOrm.relations(datasetRun, ({ one, many }) => ({
1497
+ dataset: one(dataset, {
1498
+ fields: [datasetRun.tenantId, datasetRun.projectId, datasetRun.datasetId],
1499
+ references: [dataset.tenantId, dataset.projectId, dataset.id]
1500
+ }),
1501
+ datasetRunConfig: one(datasetRunConfig, {
1502
+ fields: [datasetRun.tenantId, datasetRun.projectId, datasetRun.datasetRunConfigId],
1503
+ references: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id]
1504
+ }),
1505
+ conversations: many(datasetRunConversationRelations)
1506
+ }));
1507
+ drizzleOrm.relations(evaluationSuiteConfig, ({ one, many }) => ({
1508
+ project: one(projects, {
1509
+ fields: [evaluationSuiteConfig.tenantId, evaluationSuiteConfig.projectId],
1510
+ references: [projects.tenantId, projects.id]
1511
+ }),
1512
+ runConfigs: many(evaluationRunConfigEvaluationSuiteConfigRelations),
1513
+ evaluators: many(evaluationSuiteConfigEvaluatorRelations)
1514
+ }));
1515
+ drizzleOrm.relations(
1516
+ evaluationSuiteConfigEvaluatorRelations,
1517
+ ({ one }) => ({
1518
+ evaluationSuiteConfig: one(evaluationSuiteConfig, {
1519
+ fields: [
1520
+ evaluationSuiteConfigEvaluatorRelations.tenantId,
1521
+ evaluationSuiteConfigEvaluatorRelations.projectId,
1522
+ evaluationSuiteConfigEvaluatorRelations.evaluationSuiteConfigId
1523
+ ],
1524
+ references: [
1525
+ evaluationSuiteConfig.tenantId,
1526
+ evaluationSuiteConfig.projectId,
1527
+ evaluationSuiteConfig.id
1528
+ ]
1529
+ }),
1530
+ evaluator: one(evaluator, {
1531
+ fields: [
1532
+ evaluationSuiteConfigEvaluatorRelations.tenantId,
1533
+ evaluationSuiteConfigEvaluatorRelations.projectId,
1534
+ evaluationSuiteConfigEvaluatorRelations.evaluatorId
1535
+ ],
1536
+ references: [evaluator.tenantId, evaluator.projectId, evaluator.id]
1537
+ })
1538
+ })
1539
+ );
1540
+ drizzleOrm.relations(
1541
+ evaluationJobConfigEvaluatorRelations,
1542
+ ({ one }) => ({
1543
+ evaluationJobConfig: one(evaluationJobConfig, {
1544
+ fields: [
1545
+ evaluationJobConfigEvaluatorRelations.tenantId,
1546
+ evaluationJobConfigEvaluatorRelations.projectId,
1547
+ evaluationJobConfigEvaluatorRelations.evaluationJobConfigId
1548
+ ],
1549
+ references: [
1550
+ evaluationJobConfig.tenantId,
1551
+ evaluationJobConfig.projectId,
1552
+ evaluationJobConfig.id
1553
+ ]
1554
+ }),
1555
+ evaluator: one(evaluator, {
1556
+ fields: [
1557
+ evaluationJobConfigEvaluatorRelations.tenantId,
1558
+ evaluationJobConfigEvaluatorRelations.projectId,
1559
+ evaluationJobConfigEvaluatorRelations.evaluatorId
1560
+ ],
1561
+ references: [evaluator.tenantId, evaluator.projectId, evaluator.id]
1562
+ })
1563
+ })
1564
+ );
1565
+ drizzleOrm.relations(evaluationJobConfig, ({ one, many }) => ({
1566
+ project: one(projects, {
1567
+ fields: [evaluationJobConfig.tenantId, evaluationJobConfig.projectId],
1568
+ references: [projects.tenantId, projects.id]
1569
+ }),
1570
+ run: one(evaluationRun, {
1571
+ fields: [evaluationJobConfig.tenantId, evaluationJobConfig.projectId, evaluationJobConfig.id],
1572
+ references: [
1573
+ evaluationRun.tenantId,
1574
+ evaluationRun.projectId,
1575
+ evaluationRun.evaluationJobConfigId
1576
+ ]
1577
+ }),
1578
+ evaluators: many(evaluationJobConfigEvaluatorRelations)
1579
+ }));
1580
+ drizzleOrm.relations(
1581
+ evaluationRunConfigEvaluationSuiteConfigRelations,
1582
+ ({ one }) => ({
1583
+ evaluationRunConfig: one(evaluationRunConfig, {
1584
+ fields: [
1585
+ evaluationRunConfigEvaluationSuiteConfigRelations.tenantId,
1586
+ evaluationRunConfigEvaluationSuiteConfigRelations.projectId,
1587
+ evaluationRunConfigEvaluationSuiteConfigRelations.evaluationRunConfigId
1588
+ ],
1589
+ references: [
1590
+ evaluationRunConfig.tenantId,
1591
+ evaluationRunConfig.projectId,
1592
+ evaluationRunConfig.id
1593
+ ]
1594
+ }),
1595
+ evaluationSuiteConfig: one(evaluationSuiteConfig, {
1596
+ fields: [
1597
+ evaluationRunConfigEvaluationSuiteConfigRelations.tenantId,
1598
+ evaluationRunConfigEvaluationSuiteConfigRelations.projectId,
1599
+ evaluationRunConfigEvaluationSuiteConfigRelations.evaluationSuiteConfigId
1600
+ ],
1601
+ references: [
1602
+ evaluationSuiteConfig.tenantId,
1603
+ evaluationSuiteConfig.projectId,
1604
+ evaluationSuiteConfig.id
1605
+ ]
1606
+ })
1607
+ })
1608
+ );
1609
+ drizzleOrm.relations(evaluationRunConfig, ({ one, many }) => ({
1610
+ project: one(projects, {
1611
+ fields: [evaluationRunConfig.tenantId, evaluationRunConfig.projectId],
1612
+ references: [projects.tenantId, projects.id]
1613
+ }),
1614
+ suiteConfigs: many(evaluationRunConfigEvaluationSuiteConfigRelations),
1615
+ datasetRunConfigs: many(datasetRunConfigEvaluationRunConfigRelations),
1616
+ runs: many(evaluationRun)
1617
+ }));
1618
+ drizzleOrm.relations(evaluationRun, ({ one, many }) => ({
1619
+ evaluationJobConfig: one(evaluationJobConfig, {
1620
+ fields: [evaluationRun.tenantId, evaluationRun.projectId, evaluationRun.evaluationJobConfigId],
1621
+ references: [
1622
+ evaluationJobConfig.tenantId,
1623
+ evaluationJobConfig.projectId,
1624
+ evaluationJobConfig.id
1625
+ ]
1626
+ }),
1627
+ evaluationRunConfig: one(evaluationRunConfig, {
1628
+ fields: [evaluationRun.tenantId, evaluationRun.projectId, evaluationRun.evaluationRunConfigId],
1629
+ references: [
1630
+ evaluationRunConfig.tenantId,
1631
+ evaluationRunConfig.projectId,
1632
+ evaluationRunConfig.id
1633
+ ]
1634
+ }),
1635
+ results: many(evaluationResult)
1636
+ }));
1637
+ drizzleOrm.relations(evaluationResult, ({ one }) => ({
1638
+ conversation: one(conversations, {
1639
+ fields: [
1640
+ evaluationResult.tenantId,
1641
+ evaluationResult.projectId,
1642
+ evaluationResult.conversationId
1643
+ ],
1644
+ references: [conversations.tenantId, conversations.projectId, conversations.id],
1645
+ relationName: "conversationEvaluationResults"
1646
+ }),
1647
+ evaluator: one(evaluator, {
1648
+ fields: [evaluationResult.tenantId, evaluationResult.projectId, evaluationResult.evaluatorId],
1649
+ references: [evaluator.tenantId, evaluator.projectId, evaluator.id]
1650
+ }),
1651
+ evaluationRun: one(evaluationRun, {
1652
+ fields: [
1653
+ evaluationResult.tenantId,
1654
+ evaluationResult.projectId,
1655
+ evaluationResult.evaluationRunId
1656
+ ],
1657
+ references: [evaluationRun.tenantId, evaluationRun.projectId, evaluationRun.id]
1658
+ })
1659
+ }));
1660
+ drizzleOrm.relations(conversations, ({ many }) => ({
1661
+ evaluationResults: many(evaluationResult, {
1662
+ relationName: "conversationEvaluationResults"
1663
+ })
1664
+ }));
1665
+ drizzleOrm.relations(
1666
+ datasetRunConversationRelations,
1667
+ ({ one }) => ({
1668
+ datasetRun: one(datasetRun, {
1669
+ fields: [
1670
+ datasetRunConversationRelations.tenantId,
1671
+ datasetRunConversationRelations.projectId,
1672
+ datasetRunConversationRelations.datasetRunId
1673
+ ],
1674
+ references: [datasetRun.tenantId, datasetRun.projectId, datasetRun.id]
1675
+ }),
1676
+ conversation: one(conversations, {
1677
+ fields: [
1678
+ datasetRunConversationRelations.tenantId,
1679
+ datasetRunConversationRelations.projectId,
1680
+ datasetRunConversationRelations.conversationId
1681
+ ],
1682
+ references: [conversations.tenantId, conversations.projectId, conversations.id]
1683
+ })
1684
+ })
1685
+ );
1686
+
1687
+ // src/types/utility.ts
1688
+ var TOOL_STATUS_VALUES = ["healthy", "unhealthy", "unknown", "needs_auth"];
1689
+ var VALID_RELATION_TYPES = ["transfer", "delegate"];
1690
+ var MCPTransportType = {
1691
+ streamableHttp: "streamable_http",
1692
+ sse: "sse"
1693
+ };
1694
+ var MCPServerType = {
1695
+ nango: "nango",
1696
+ generic: "generic"
1697
+ };
1698
+ var CredentialStoreType = {
1699
+ memory: "memory",
1700
+ keychain: "keychain",
1701
+ nango: "nango"
1702
+ };
1703
+ var MIN_ID_LENGTH = 1;
1704
+ var MAX_ID_LENGTH = 255;
1705
+ var URL_SAFE_ID_PATTERN = /^[a-zA-Z0-9\-_.]+$/;
1706
+ var resourceIdSchema = zodOpenapi.z.string().min(MIN_ID_LENGTH).max(MAX_ID_LENGTH).describe("Resource identifier").regex(URL_SAFE_ID_PATTERN, {
1707
+ message: "ID must contain only letters, numbers, hyphens, underscores, and dots"
1708
+ }).openapi({
1709
+ description: "Resource identifier",
1710
+ example: "resource_789"
1711
+ });
1712
+ resourceIdSchema.meta({
1713
+ description: "Resource identifier"
1714
+ });
1715
+ var FIELD_MODIFIERS = {
1716
+ id: (schema) => {
1717
+ const modified = schema.min(MIN_ID_LENGTH).max(MAX_ID_LENGTH).describe("Resource identifier").regex(URL_SAFE_ID_PATTERN, {
1718
+ message: "ID must contain only letters, numbers, hyphens, underscores, and dots"
1719
+ }).openapi({
1720
+ description: "Resource identifier",
1721
+ example: "resource_789"
1722
+ });
1723
+ modified.meta({
1724
+ description: "Resource identifier"
1725
+ });
1726
+ return modified;
1727
+ },
1728
+ name: (_schema) => {
1729
+ const modified = zodOpenapi.z.string().describe("Name");
1730
+ modified.meta({ description: "Name" });
1731
+ return modified;
1732
+ },
1733
+ description: (_schema) => {
1734
+ const modified = zodOpenapi.z.string().describe("Description");
1735
+ modified.meta({ description: "Description" });
1736
+ return modified;
1737
+ },
1738
+ tenantId: (schema) => {
1739
+ const modified = schema.describe("Tenant identifier");
1740
+ modified.meta({ description: "Tenant identifier" });
1741
+ return modified;
1742
+ },
1743
+ projectId: (schema) => {
1744
+ const modified = schema.describe("Project identifier");
1745
+ modified.meta({ description: "Project identifier" });
1746
+ return modified;
1747
+ },
1748
+ agentId: (schema) => {
1749
+ const modified = schema.describe("Agent identifier");
1750
+ modified.meta({ description: "Agent identifier" });
1751
+ return modified;
1752
+ },
1753
+ subAgentId: (schema) => {
1754
+ const modified = schema.describe("Sub-agent identifier");
1755
+ modified.meta({ description: "Sub-agent identifier" });
1756
+ return modified;
1757
+ },
1758
+ createdAt: (schema) => {
1759
+ const modified = schema.describe("Creation timestamp");
1760
+ modified.meta({ description: "Creation timestamp" });
1761
+ return modified;
1762
+ },
1763
+ updatedAt: (schema) => {
1764
+ const modified = schema.describe("Last update timestamp");
1765
+ modified.meta({ description: "Last update timestamp" });
1766
+ return modified;
1767
+ }
1768
+ };
1769
+ function createSelectSchemaWithModifiers(table, overrides) {
1770
+ const tableColumns = table._?.columns;
1771
+ if (!tableColumns) {
1772
+ return drizzleZod.createSelectSchema(table, overrides);
1773
+ }
1774
+ const tableFieldNames = Object.keys(tableColumns);
1775
+ const modifiers = {};
1776
+ for (const fieldName of tableFieldNames) {
1777
+ const fieldNameStr = String(fieldName);
1778
+ if (fieldNameStr in FIELD_MODIFIERS) {
1779
+ modifiers[fieldNameStr] = FIELD_MODIFIERS[fieldNameStr];
1780
+ }
1781
+ }
1782
+ const mergedModifiers = { ...modifiers, ...overrides };
1783
+ return drizzleZod.createSelectSchema(table, mergedModifiers);
1784
+ }
1785
+ function createInsertSchemaWithModifiers(table, overrides) {
1786
+ const tableColumns = table._?.columns;
1787
+ if (!tableColumns) {
1788
+ return drizzleZod.createInsertSchema(table, overrides);
1789
+ }
1790
+ const tableFieldNames = Object.keys(tableColumns);
1791
+ const modifiers = {};
1792
+ for (const fieldName of tableFieldNames) {
1793
+ const fieldNameStr = String(fieldName);
1794
+ if (fieldNameStr in FIELD_MODIFIERS) {
1795
+ modifiers[fieldNameStr] = FIELD_MODIFIERS[fieldNameStr];
1796
+ }
1797
+ }
1798
+ const mergedModifiers = { ...modifiers, ...overrides };
1799
+ return drizzleZod.createInsertSchema(table, mergedModifiers);
1800
+ }
1801
+ var createSelectSchema = createSelectSchemaWithModifiers;
1802
+ var createInsertSchema = createInsertSchemaWithModifiers;
1803
+ function registerFieldSchemas(schema) {
1804
+ if (!(schema instanceof zodOpenapi.z.ZodObject)) {
1805
+ return schema;
1806
+ }
1807
+ const shape = schema.shape;
1808
+ const fieldMetadata = {
1809
+ id: { description: "Resource identifier" },
1810
+ name: { description: "Name" },
1811
+ description: { description: "Description" },
1812
+ tenantId: { description: "Tenant identifier" },
1813
+ projectId: { description: "Project identifier" },
1814
+ agentId: { description: "Agent identifier" },
1815
+ subAgentId: { description: "Sub-agent identifier" },
1816
+ createdAt: { description: "Creation timestamp" },
1817
+ updatedAt: { description: "Last update timestamp" }
1818
+ };
1819
+ for (const [fieldName, fieldSchema] of Object.entries(shape)) {
1820
+ if (fieldName in fieldMetadata && fieldSchema) {
1821
+ let zodFieldSchema = fieldSchema;
1822
+ let innerSchema = null;
1823
+ if (zodFieldSchema instanceof zodOpenapi.z.ZodOptional) {
1824
+ innerSchema = zodFieldSchema._def.innerType;
1825
+ zodFieldSchema = innerSchema;
1826
+ }
1827
+ zodFieldSchema.meta(fieldMetadata[fieldName]);
1828
+ if (fieldName === "id" && zodFieldSchema instanceof zodOpenapi.z.ZodString) {
1829
+ zodFieldSchema.openapi({
1830
+ description: "Resource identifier",
1831
+ minLength: MIN_ID_LENGTH,
1832
+ maxLength: MAX_ID_LENGTH,
1833
+ pattern: URL_SAFE_ID_PATTERN.source,
1834
+ example: "resource_789"
1835
+ });
1836
+ } else if (zodFieldSchema instanceof zodOpenapi.z.ZodString) {
1837
+ zodFieldSchema.openapi({
1838
+ description: fieldMetadata[fieldName].description
1839
+ });
1840
+ }
1841
+ if (innerSchema && fieldSchema instanceof zodOpenapi.z.ZodOptional) {
1842
+ fieldSchema.meta(fieldMetadata[fieldName]);
1843
+ }
1844
+ }
1845
+ }
1846
+ return schema;
1847
+ }
1848
+
1849
+ // src/validation/schemas.ts
1850
+ var {
1851
+ AGENT_EXECUTION_TRANSFER_COUNT_MAX,
1852
+ AGENT_EXECUTION_TRANSFER_COUNT_MIN,
1853
+ CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT,
1854
+ STATUS_UPDATE_MAX_INTERVAL_SECONDS,
1855
+ STATUS_UPDATE_MAX_NUM_EVENTS,
1856
+ SUB_AGENT_TURN_GENERATION_STEPS_MAX,
1857
+ SUB_AGENT_TURN_GENERATION_STEPS_MIN,
1858
+ VALIDATION_AGENT_PROMPT_MAX_CHARS,
1859
+ VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS
1860
+ } = schemaValidationDefaults;
1861
+ var StopWhenSchema = zodOpenapi.z.object({
1862
+ transferCountIs: zodOpenapi.z.number().min(AGENT_EXECUTION_TRANSFER_COUNT_MIN).max(AGENT_EXECUTION_TRANSFER_COUNT_MAX).optional().describe("The maximum number of transfers to trigger the stop condition."),
1863
+ stepCountIs: zodOpenapi.z.number().min(SUB_AGENT_TURN_GENERATION_STEPS_MIN).max(SUB_AGENT_TURN_GENERATION_STEPS_MAX).optional().describe("The maximum number of steps to trigger the stop condition.")
1864
+ }).openapi("StopWhen");
1865
+ var AgentStopWhenSchema = StopWhenSchema.pick({ transferCountIs: true }).openapi(
1866
+ "AgentStopWhen"
1867
+ );
1868
+ var SubAgentStopWhenSchema = StopWhenSchema.pick({ stepCountIs: true }).openapi(
1869
+ "SubAgentStopWhen"
1870
+ );
1871
+ var pageNumber = zodOpenapi.z.coerce.number().min(1).default(1).openapi("PaginationPageQueryParam");
1872
+ var limitNumber = zodOpenapi.z.coerce.number().min(1).max(100).default(10).openapi("PaginationLimitQueryParam");
1873
+ var ModelSettingsSchema = zodOpenapi.z.object({
1874
+ model: zodOpenapi.z.string().optional().describe("The model to use for the project."),
1875
+ providerOptions: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.any()).optional().describe("The provider options to use for the project.")
1876
+ }).openapi("ModelSettings");
1877
+ var ModelSchema = zodOpenapi.z.object({
1878
+ base: ModelSettingsSchema.optional(),
1879
+ structuredOutput: ModelSettingsSchema.optional(),
1880
+ summarizer: ModelSettingsSchema.optional()
1881
+ }).openapi("Model");
1882
+ var ProjectModelSchema = zodOpenapi.z.object({
1883
+ base: ModelSettingsSchema,
1884
+ structuredOutput: ModelSettingsSchema.optional(),
1885
+ summarizer: ModelSettingsSchema.optional()
1886
+ }).openapi("ProjectModel");
1887
+ var FunctionToolConfigSchema = zodOpenapi.z.object({
1888
+ name: zodOpenapi.z.string(),
1889
+ description: zodOpenapi.z.string(),
1890
+ inputSchema: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()),
1891
+ dependencies: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).optional(),
1892
+ execute: zodOpenapi.z.union([zodOpenapi.z.function(), zodOpenapi.z.string()])
1893
+ });
1894
+ var createApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
1895
+ var createApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
1896
+ var createApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true }).partial();
1897
+ var createAgentScopedApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true, agentId: true });
1898
+ var createAgentScopedApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true, agentId: true });
1899
+ var createAgentScopedApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true, agentId: true }).partial();
1900
+ var SubAgentSelectSchema = createSelectSchema(subAgents);
1901
+ var SubAgentInsertSchema = createInsertSchema(subAgents).extend({
1902
+ id: resourceIdSchema,
1903
+ models: ModelSchema.optional()
1904
+ });
1905
+ var SubAgentUpdateSchema = SubAgentInsertSchema.partial();
1906
+ var SubAgentApiSelectSchema = createAgentScopedApiSchema(SubAgentSelectSchema).openapi("SubAgent");
1907
+ var SubAgentApiInsertSchema = createAgentScopedApiInsertSchema(SubAgentInsertSchema).openapi("SubAgentCreate");
1908
+ var SubAgentApiUpdateSchema = createAgentScopedApiUpdateSchema(SubAgentUpdateSchema).openapi("SubAgentUpdate");
1909
+ var SubAgentRelationSelectSchema = createSelectSchema(subAgentRelations);
1910
+ var SubAgentRelationInsertSchema = createInsertSchema(subAgentRelations).extend({
1911
+ id: resourceIdSchema,
1912
+ agentId: resourceIdSchema,
1913
+ sourceSubAgentId: resourceIdSchema,
1914
+ targetSubAgentId: resourceIdSchema.optional(),
1915
+ externalSubAgentId: resourceIdSchema.optional(),
1916
+ teamSubAgentId: resourceIdSchema.optional()
1917
+ });
1918
+ var SubAgentRelationUpdateSchema = SubAgentRelationInsertSchema.partial();
1919
+ var SubAgentRelationApiSelectSchema = createAgentScopedApiSchema(
1920
+ SubAgentRelationSelectSchema
1921
+ ).openapi("SubAgentRelation");
1922
+ var SubAgentRelationApiInsertSchema = createAgentScopedApiInsertSchema(
1923
+ SubAgentRelationInsertSchema
1924
+ ).extend({
1925
+ relationType: zodOpenapi.z.enum(VALID_RELATION_TYPES)
1926
+ }).refine(
1927
+ (data) => {
1928
+ const hasTarget = data.targetSubAgentId != null;
1929
+ const hasExternal = data.externalSubAgentId != null;
1930
+ const hasTeam = data.teamSubAgentId != null;
1931
+ const count = [hasTarget, hasExternal, hasTeam].filter(Boolean).length;
1932
+ return count === 1;
1933
+ },
1934
+ {
1935
+ message: "Must specify exactly one of targetSubAgentId, externalSubAgentId, or teamSubAgentId",
1936
+ path: ["targetSubAgentId", "externalSubAgentId", "teamSubAgentId"]
1937
+ }
1938
+ ).openapi("SubAgentRelationCreate");
1939
+ var SubAgentRelationApiUpdateSchema = createAgentScopedApiUpdateSchema(
1940
+ SubAgentRelationUpdateSchema
1941
+ ).extend({
1942
+ relationType: zodOpenapi.z.enum(VALID_RELATION_TYPES).optional()
1943
+ }).refine(
1944
+ (data) => {
1945
+ const hasTarget = data.targetSubAgentId != null;
1946
+ const hasExternal = data.externalSubAgentId != null;
1947
+ const hasTeam = data.teamSubAgentId != null;
1948
+ const count = [hasTarget, hasExternal, hasTeam].filter(Boolean).length;
1949
+ if (count === 0) {
1950
+ return true;
1951
+ }
1952
+ return count === 1;
1953
+ },
1954
+ {
1955
+ message: "Must specify exactly one of targetSubAgentId, externalSubAgentId, or teamSubAgentId when updating sub-agent relationships",
1956
+ path: ["targetSubAgentId", "externalSubAgentId", "teamSubAgentId"]
1957
+ }
1958
+ ).openapi("SubAgentRelationUpdate");
1959
+ var SubAgentRelationQuerySchema = zodOpenapi.z.object({
1960
+ sourceSubAgentId: zodOpenapi.z.string().optional(),
1961
+ targetSubAgentId: zodOpenapi.z.string().optional(),
1962
+ externalSubAgentId: zodOpenapi.z.string().optional(),
1963
+ teamSubAgentId: zodOpenapi.z.string().optional()
1964
+ });
1965
+ var ExternalSubAgentRelationInsertSchema = createInsertSchema(subAgentRelations).extend({
1966
+ id: resourceIdSchema,
1967
+ agentId: resourceIdSchema,
1968
+ sourceSubAgentId: resourceIdSchema,
1969
+ externalSubAgentId: resourceIdSchema
1970
+ });
1971
+ var ExternalSubAgentRelationApiInsertSchema = createApiInsertSchema(
1972
+ ExternalSubAgentRelationInsertSchema
1973
+ );
1974
+ var AgentSelectSchema = createSelectSchema(agents);
1975
+ var AgentInsertSchema = createInsertSchema(agents).extend({
1976
+ id: resourceIdSchema,
1977
+ name: zodOpenapi.z.string().trim().nonempty()
1978
+ });
1979
+ var AgentUpdateSchema = AgentInsertSchema.partial();
1980
+ var AgentApiSelectSchema = createApiSchema(AgentSelectSchema).openapi("Agent");
1981
+ var AgentApiInsertSchema = createApiInsertSchema(AgentInsertSchema).extend({
1982
+ id: resourceIdSchema
1983
+ }).openapi("AgentCreate");
1984
+ var AgentApiUpdateSchema = createApiUpdateSchema(AgentUpdateSchema).openapi("AgentUpdate");
1985
+ var TaskSelectSchema = createSelectSchema(tasks);
1986
+ var TaskInsertSchema = createInsertSchema(tasks).extend({
1987
+ id: resourceIdSchema,
1988
+ conversationId: resourceIdSchema.optional()
1989
+ });
1990
+ var TaskUpdateSchema = TaskInsertSchema.partial();
1991
+ var TaskApiSelectSchema = createApiSchema(TaskSelectSchema);
1992
+ var TaskApiInsertSchema = createApiInsertSchema(TaskInsertSchema);
1993
+ var TaskApiUpdateSchema = createApiUpdateSchema(TaskUpdateSchema);
1994
+ var TaskRelationSelectSchema = createSelectSchema(taskRelations);
1995
+ var TaskRelationInsertSchema = createInsertSchema(taskRelations).extend({
1996
+ id: resourceIdSchema,
1997
+ parentTaskId: resourceIdSchema,
1998
+ childTaskId: resourceIdSchema
1999
+ });
2000
+ var TaskRelationUpdateSchema = TaskRelationInsertSchema.partial();
2001
+ var TaskRelationApiSelectSchema = createApiSchema(TaskRelationSelectSchema);
2002
+ var TaskRelationApiInsertSchema = createApiInsertSchema(TaskRelationInsertSchema);
2003
+ var TaskRelationApiUpdateSchema = createApiUpdateSchema(TaskRelationUpdateSchema);
2004
+ var imageUrlSchema = zodOpenapi.z.string().optional().refine(
2005
+ (url) => {
2006
+ if (!url) return true;
2007
+ if (url.startsWith("data:image/")) {
2008
+ const base64Part = url.split(",")[1];
2009
+ if (!base64Part) return false;
2010
+ return base64Part.length < 14e5;
2011
+ }
2012
+ try {
2013
+ const parsed = new URL(url);
2014
+ return parsed.protocol === "http:" || parsed.protocol === "https:";
2015
+ } catch {
2016
+ return false;
2017
+ }
2018
+ },
2019
+ {
2020
+ message: "Image URL must be a valid HTTP(S) URL or a base64 data URL (max 1MB)"
2021
+ }
2022
+ );
2023
+ var McpTransportConfigSchema = zodOpenapi.z.object({
2024
+ type: zodOpenapi.z.enum(MCPTransportType),
2025
+ requestInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
2026
+ eventSourceInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
2027
+ reconnectionOptions: zodOpenapi.z.any().optional().openapi({
2028
+ type: "object",
2029
+ description: "Reconnection options for streamable HTTP transport"
2030
+ }),
2031
+ sessionId: zodOpenapi.z.string().optional()
2032
+ }).openapi("McpTransportConfig");
2033
+ var ToolStatusSchema = zodOpenapi.z.enum(TOOL_STATUS_VALUES);
2034
+ var McpToolDefinitionSchema = zodOpenapi.z.object({
2035
+ name: zodOpenapi.z.string(),
2036
+ description: zodOpenapi.z.string().optional(),
2037
+ inputSchema: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional()
2038
+ });
2039
+ var ToolSelectSchema = createSelectSchema(tools);
2040
+ var ToolInsertSchema = createInsertSchema(tools).extend({
2041
+ id: resourceIdSchema,
2042
+ imageUrl: imageUrlSchema,
2043
+ config: zodOpenapi.z.object({
2044
+ type: zodOpenapi.z.literal("mcp"),
2045
+ mcp: zodOpenapi.z.object({
2046
+ server: zodOpenapi.z.object({
2047
+ url: zodOpenapi.z.url()
2048
+ }),
2049
+ transport: zodOpenapi.z.object({
2050
+ type: zodOpenapi.z.enum(MCPTransportType),
2051
+ requestInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
2052
+ eventSourceInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
2053
+ reconnectionOptions: zodOpenapi.z.any().optional().openapi({
2054
+ type: "object",
2055
+ description: "Reconnection options for streamable HTTP transport"
2056
+ }),
2057
+ sessionId: zodOpenapi.z.string().optional()
2058
+ }).optional(),
2059
+ activeTools: zodOpenapi.z.array(zodOpenapi.z.string()).optional()
2060
+ })
2061
+ })
2062
+ });
2063
+ var ConversationSelectSchema = createSelectSchema(conversations);
2064
+ var ConversationInsertSchema = createInsertSchema(conversations).extend({
2065
+ id: resourceIdSchema,
2066
+ contextConfigId: resourceIdSchema.optional()
2067
+ });
2068
+ var ConversationUpdateSchema = ConversationInsertSchema.partial();
2069
+ var ConversationApiSelectSchema = createApiSchema(ConversationSelectSchema).openapi("Conversation");
2070
+ var ConversationApiInsertSchema = createApiInsertSchema(ConversationInsertSchema).openapi("ConversationCreate");
2071
+ var ConversationApiUpdateSchema = createApiUpdateSchema(ConversationUpdateSchema).openapi("ConversationUpdate");
2072
+ var MessageSelectSchema = createSelectSchema(messages);
2073
+ var MessageInsertSchema = createInsertSchema(messages).extend({
2074
+ id: resourceIdSchema,
2075
+ conversationId: resourceIdSchema,
2076
+ taskId: resourceIdSchema.optional()
2077
+ });
2078
+ var MessageUpdateSchema = MessageInsertSchema.partial();
2079
+ var MessageApiSelectSchema = createApiSchema(MessageSelectSchema).openapi("Message");
2080
+ var MessageApiInsertSchema = createApiInsertSchema(MessageInsertSchema).openapi("MessageCreate");
2081
+ var MessageApiUpdateSchema = createApiUpdateSchema(MessageUpdateSchema).openapi("MessageUpdate");
2082
+ var ContextCacheSelectSchema = createSelectSchema(contextCache);
2083
+ var ContextCacheInsertSchema = createInsertSchema(contextCache);
2084
+ var ContextCacheUpdateSchema = ContextCacheInsertSchema.partial();
2085
+ var ContextCacheApiSelectSchema = createApiSchema(ContextCacheSelectSchema);
2086
+ var ContextCacheApiInsertSchema = createApiInsertSchema(ContextCacheInsertSchema);
2087
+ var ContextCacheApiUpdateSchema = createApiUpdateSchema(ContextCacheUpdateSchema);
2088
+ var DataComponentSelectSchema = createSelectSchema(dataComponents);
2089
+ var DataComponentInsertSchema = createInsertSchema(dataComponents).extend({
2090
+ id: resourceIdSchema
2091
+ });
2092
+ var DataComponentBaseSchema = DataComponentInsertSchema.omit({
2093
+ createdAt: true,
2094
+ updatedAt: true
2095
+ });
2096
+ var DataComponentUpdateSchema = DataComponentInsertSchema.partial();
2097
+ var DataComponentApiSelectSchema = createApiSchema(DataComponentSelectSchema).openapi("DataComponent");
2098
+ var DataComponentApiInsertSchema = createApiInsertSchema(DataComponentInsertSchema).openapi("DataComponentCreate");
2099
+ var DataComponentApiUpdateSchema = createApiUpdateSchema(DataComponentUpdateSchema).openapi("DataComponentUpdate");
2100
+ var SubAgentDataComponentSelectSchema = createSelectSchema(subAgentDataComponents);
2101
+ var SubAgentDataComponentInsertSchema = createInsertSchema(subAgentDataComponents);
2102
+ var SubAgentDataComponentUpdateSchema = SubAgentDataComponentInsertSchema.partial();
2103
+ var SubAgentDataComponentApiSelectSchema = createAgentScopedApiSchema(
2104
+ SubAgentDataComponentSelectSchema
2105
+ );
2106
+ var SubAgentDataComponentApiInsertSchema = SubAgentDataComponentInsertSchema.omit({
2107
+ tenantId: true,
2108
+ projectId: true,
2109
+ id: true,
2110
+ createdAt: true
2111
+ });
2112
+ var SubAgentDataComponentApiUpdateSchema = createAgentScopedApiUpdateSchema(
2113
+ SubAgentDataComponentUpdateSchema
2114
+ );
2115
+ var ArtifactComponentSelectSchema = createSelectSchema(artifactComponents);
2116
+ var ArtifactComponentInsertSchema = createInsertSchema(artifactComponents).extend({
2117
+ id: resourceIdSchema
2118
+ });
2119
+ var ArtifactComponentUpdateSchema = ArtifactComponentInsertSchema.partial();
2120
+ var ArtifactComponentApiSelectSchema = createApiSchema(
2121
+ ArtifactComponentSelectSchema
2122
+ ).openapi("ArtifactComponent");
2123
+ var ArtifactComponentApiInsertSchema = ArtifactComponentInsertSchema.omit({
2124
+ tenantId: true,
2125
+ projectId: true,
2126
+ createdAt: true,
2127
+ updatedAt: true
2128
+ }).openapi("ArtifactComponentCreate");
2129
+ var ArtifactComponentApiUpdateSchema = createApiUpdateSchema(
2130
+ ArtifactComponentUpdateSchema
2131
+ ).openapi("ArtifactComponentUpdate");
2132
+ var SubAgentArtifactComponentSelectSchema = createSelectSchema(subAgentArtifactComponents);
2133
+ var SubAgentArtifactComponentInsertSchema = createInsertSchema(
2134
+ subAgentArtifactComponents
2135
+ ).extend({
2136
+ id: resourceIdSchema,
2137
+ subAgentId: resourceIdSchema,
2138
+ artifactComponentId: resourceIdSchema
2139
+ });
2140
+ var SubAgentArtifactComponentUpdateSchema = SubAgentArtifactComponentInsertSchema.partial();
2141
+ var SubAgentArtifactComponentApiSelectSchema = createAgentScopedApiSchema(
2142
+ SubAgentArtifactComponentSelectSchema
2143
+ );
2144
+ var SubAgentArtifactComponentApiInsertSchema = SubAgentArtifactComponentInsertSchema.omit({
2145
+ tenantId: true,
2146
+ projectId: true,
2147
+ id: true,
2148
+ createdAt: true
2149
+ });
2150
+ var SubAgentArtifactComponentApiUpdateSchema = createAgentScopedApiUpdateSchema(
2151
+ SubAgentArtifactComponentUpdateSchema
2152
+ );
2153
+ var ExternalAgentSelectSchema = createSelectSchema(externalAgents).extend({
2154
+ credentialReferenceId: zodOpenapi.z.string().nullable().optional()
2155
+ });
2156
+ var ExternalAgentInsertSchema = createInsertSchema(externalAgents).extend({
2157
+ id: resourceIdSchema
2158
+ });
2159
+ var ExternalAgentUpdateSchema = ExternalAgentInsertSchema.partial();
2160
+ var ExternalAgentApiSelectSchema = createApiSchema(ExternalAgentSelectSchema).openapi("ExternalAgent");
2161
+ var ExternalAgentApiInsertSchema = createApiInsertSchema(ExternalAgentInsertSchema).openapi("ExternalAgentCreate");
2162
+ var ExternalAgentApiUpdateSchema = createApiUpdateSchema(ExternalAgentUpdateSchema).openapi("ExternalAgentUpdate");
2163
+ var AllAgentSchema = zodOpenapi.z.discriminatedUnion("type", [
2164
+ SubAgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("internal") }),
2165
+ ExternalAgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("external") })
2166
+ ]);
2167
+ var ApiKeySelectSchema = createSelectSchema(apiKeys);
2168
+ var ApiKeyInsertSchema = createInsertSchema(apiKeys).extend({
2169
+ id: resourceIdSchema,
2170
+ agentId: resourceIdSchema
2171
+ });
2172
+ var ApiKeyUpdateSchema = ApiKeyInsertSchema.partial().omit({
2173
+ tenantId: true,
2174
+ projectId: true,
2175
+ id: true,
2176
+ publicId: true,
2177
+ keyHash: true,
2178
+ keyPrefix: true,
2179
+ createdAt: true
2180
+ });
2181
+ var ApiKeyApiSelectSchema = ApiKeySelectSchema.omit({
2182
+ tenantId: true,
2183
+ projectId: true,
2184
+ keyHash: true
2185
+ // Never expose the hash
2186
+ }).openapi("ApiKey");
2187
+ var ApiKeyApiCreationResponseSchema = zodOpenapi.z.object({
2188
+ data: zodOpenapi.z.object({
2189
+ apiKey: ApiKeyApiSelectSchema,
2190
+ key: zodOpenapi.z.string().describe("The full API key (shown only once)")
2191
+ })
2192
+ });
2193
+ var ApiKeyApiInsertSchema = ApiKeyInsertSchema.omit({
2194
+ tenantId: true,
2195
+ projectId: true,
2196
+ id: true,
2197
+ // Auto-generated
2198
+ publicId: true,
2199
+ // Auto-generated
2200
+ keyHash: true,
2201
+ // Auto-generated
2202
+ keyPrefix: true,
2203
+ // Auto-generated
2204
+ lastUsedAt: true
2205
+ // Not set on creation
2206
+ }).openapi("ApiKeyCreate");
2207
+ var ApiKeyApiUpdateSchema = ApiKeyUpdateSchema.openapi("ApiKeyUpdate");
2208
+ var CredentialReferenceSelectSchema = zodOpenapi.z.object({
2209
+ id: zodOpenapi.z.string(),
2210
+ tenantId: zodOpenapi.z.string(),
2211
+ projectId: zodOpenapi.z.string(),
2212
+ name: zodOpenapi.z.string(),
2213
+ type: zodOpenapi.z.string(),
2214
+ credentialStoreId: zodOpenapi.z.string(),
2215
+ retrievalParams: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).nullish(),
2216
+ createdAt: zodOpenapi.z.string(),
2217
+ updatedAt: zodOpenapi.z.string()
2218
+ });
2219
+ var CredentialReferenceInsertSchema = createInsertSchema(credentialReferences).extend({
2220
+ id: resourceIdSchema,
2221
+ type: zodOpenapi.z.string(),
2222
+ credentialStoreId: resourceIdSchema,
2223
+ retrievalParams: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).nullish()
2224
+ });
2225
+ var CredentialReferenceUpdateSchema = CredentialReferenceInsertSchema.partial();
2226
+ var CredentialReferenceApiSelectSchema = createApiSchema(CredentialReferenceSelectSchema).extend({
2227
+ type: zodOpenapi.z.enum(CredentialStoreType),
2228
+ tools: zodOpenapi.z.array(ToolSelectSchema).optional(),
2229
+ externalAgents: zodOpenapi.z.array(ExternalAgentSelectSchema).optional()
2230
+ }).openapi("CredentialReference");
2231
+ var CredentialReferenceApiInsertSchema = createApiInsertSchema(
2232
+ CredentialReferenceInsertSchema
2233
+ ).extend({
2234
+ type: zodOpenapi.z.enum(CredentialStoreType)
2235
+ }).openapi("CredentialReferenceCreate");
2236
+ var CredentialReferenceApiUpdateSchema = createApiUpdateSchema(
2237
+ CredentialReferenceUpdateSchema
2238
+ ).extend({
2239
+ type: zodOpenapi.z.enum(CredentialStoreType).optional()
2240
+ }).openapi("CredentialReferenceUpdate");
2241
+ var CredentialStoreSchema = zodOpenapi.z.object({
2242
+ id: zodOpenapi.z.string().describe("Unique identifier of the credential store"),
2243
+ type: zodOpenapi.z.enum(CredentialStoreType),
2244
+ available: zodOpenapi.z.boolean().describe("Whether the store is functional and ready to use"),
2245
+ reason: zodOpenapi.z.string().nullable().describe("Reason why store is not available, if applicable")
2246
+ }).openapi("CredentialStore");
2247
+ var CredentialStoreListResponseSchema = zodOpenapi.z.object({
2248
+ data: zodOpenapi.z.array(CredentialStoreSchema).describe("List of credential stores")
2249
+ }).openapi("CredentialStoreListResponse");
2250
+ var CreateCredentialInStoreRequestSchema = zodOpenapi.z.object({
2251
+ key: zodOpenapi.z.string().describe("The credential key"),
2252
+ value: zodOpenapi.z.string().describe("The credential value"),
2253
+ metadata: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish().describe("The metadata for the credential")
2254
+ }).openapi("CreateCredentialInStoreRequest");
2255
+ var CreateCredentialInStoreResponseSchema = zodOpenapi.z.object({
2256
+ data: zodOpenapi.z.object({
2257
+ key: zodOpenapi.z.string().describe("The credential key"),
2258
+ storeId: zodOpenapi.z.string().describe("The store ID where credential was created"),
2259
+ createdAt: zodOpenapi.z.string().describe("ISO timestamp of creation")
2260
+ })
2261
+ }).openapi("CreateCredentialInStoreResponse");
2262
+ var RelatedAgentInfoSchema = zodOpenapi.z.object({
2263
+ id: zodOpenapi.z.string(),
2264
+ name: zodOpenapi.z.string(),
2265
+ description: zodOpenapi.z.string()
2266
+ }).openapi("RelatedAgentInfo");
2267
+ var ComponentAssociationSchema = zodOpenapi.z.object({
2268
+ subAgentId: zodOpenapi.z.string(),
2269
+ createdAt: zodOpenapi.z.string()
2270
+ }).openapi("ComponentAssociation");
2271
+ var OAuthLoginQuerySchema = zodOpenapi.z.object({
2272
+ tenantId: zodOpenapi.z.string().min(1, "Tenant ID is required"),
2273
+ projectId: zodOpenapi.z.string().min(1, "Project ID is required"),
2274
+ toolId: zodOpenapi.z.string().min(1, "Tool ID is required")
2275
+ }).openapi("OAuthLoginQuery");
2276
+ var OAuthCallbackQuerySchema = zodOpenapi.z.object({
2277
+ code: zodOpenapi.z.string().min(1, "Authorization code is required"),
2278
+ state: zodOpenapi.z.string().min(1, "State parameter is required"),
2279
+ error: zodOpenapi.z.string().optional(),
2280
+ error_description: zodOpenapi.z.string().optional()
2281
+ }).openapi("OAuthCallbackQuery");
2282
+ var McpToolSchema = ToolInsertSchema.extend({
2283
+ imageUrl: imageUrlSchema,
2284
+ availableTools: zodOpenapi.z.array(McpToolDefinitionSchema).optional(),
2285
+ status: ToolStatusSchema.default("unknown"),
2286
+ version: zodOpenapi.z.string().optional(),
2287
+ expiresAt: zodOpenapi.z.string().optional(),
2288
+ relationshipId: zodOpenapi.z.string().optional()
2289
+ }).openapi("McpTool");
2290
+ var MCPToolConfigSchema = McpToolSchema.omit({
2291
+ config: true,
2292
+ tenantId: true,
2293
+ projectId: true,
2294
+ status: true,
2295
+ version: true,
2296
+ createdAt: true,
2297
+ updatedAt: true,
2298
+ credentialReferenceId: true
2299
+ }).extend({
2300
+ tenantId: zodOpenapi.z.string().optional(),
2301
+ projectId: zodOpenapi.z.string().optional(),
2302
+ description: zodOpenapi.z.string().optional(),
2303
+ serverUrl: zodOpenapi.z.url(),
2304
+ activeTools: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
2305
+ mcpType: zodOpenapi.z.enum(MCPServerType).optional(),
2306
+ transport: McpTransportConfigSchema.optional(),
2307
+ credential: CredentialReferenceApiInsertSchema.optional()
2308
+ });
2309
+ var ToolUpdateSchema = ToolInsertSchema.partial();
2310
+ var ToolApiSelectSchema = createApiSchema(ToolSelectSchema).openapi("Tool");
2311
+ var ToolApiInsertSchema = createApiInsertSchema(ToolInsertSchema).openapi("ToolCreate");
2312
+ var ToolApiUpdateSchema = createApiUpdateSchema(ToolUpdateSchema).openapi("ToolUpdate");
2313
+ var FunctionToolSelectSchema = createSelectSchema(functionTools);
2314
+ var FunctionToolInsertSchema = createInsertSchema(functionTools).extend({
2315
+ id: resourceIdSchema
2316
+ });
2317
+ var FunctionToolUpdateSchema = FunctionToolInsertSchema.partial();
2318
+ var FunctionToolApiSelectSchema = createApiSchema(FunctionToolSelectSchema).openapi("FunctionTool");
2319
+ var FunctionToolApiInsertSchema = createAgentScopedApiInsertSchema(FunctionToolInsertSchema).openapi("FunctionToolCreate");
2320
+ var FunctionToolApiUpdateSchema = createApiUpdateSchema(FunctionToolUpdateSchema).openapi("FunctionToolUpdate");
2321
+ var FunctionSelectSchema = createSelectSchema(functions);
2322
+ var FunctionInsertSchema = createInsertSchema(functions).extend({
2323
+ id: resourceIdSchema
2324
+ });
2325
+ var FunctionUpdateSchema = FunctionInsertSchema.partial();
2326
+ var FunctionApiSelectSchema = createApiSchema(FunctionSelectSchema).openapi("Function");
2327
+ var FunctionApiInsertSchema = createApiInsertSchema(FunctionInsertSchema).openapi("FunctionCreate");
2328
+ var FunctionApiUpdateSchema = createApiUpdateSchema(FunctionUpdateSchema).openapi("FunctionUpdate");
2329
+ var FetchConfigSchema = zodOpenapi.z.object({
2330
+ url: zodOpenapi.z.string().min(1, "URL is required"),
2331
+ method: zodOpenapi.z.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).optional().default("GET"),
2332
+ headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).optional(),
2333
+ body: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
2334
+ transform: zodOpenapi.z.string().optional(),
2335
+ // JSONPath or JS transform function
2336
+ timeout: zodOpenapi.z.number().min(0).optional().default(CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT).optional()
2337
+ }).openapi("FetchConfig");
2338
+ var FetchDefinitionSchema = zodOpenapi.z.object({
2339
+ id: zodOpenapi.z.string().min(1, "Fetch definition ID is required"),
2340
+ name: zodOpenapi.z.string().optional(),
2341
+ trigger: zodOpenapi.z.enum(["initialization", "invocation"]),
2342
+ fetchConfig: FetchConfigSchema,
2343
+ responseSchema: zodOpenapi.z.any().optional(),
2344
+ // JSON Schema for validating HTTP response
2345
+ defaultValue: zodOpenapi.z.any().optional().openapi({
2346
+ description: "Default value if fetch fails"
2347
+ }),
2348
+ credential: CredentialReferenceApiInsertSchema.optional()
2349
+ }).openapi("FetchDefinition");
2350
+ var ContextConfigSelectSchema = createSelectSchema(contextConfigs).extend({
2351
+ headersSchema: zodOpenapi.z.any().optional().openapi({
2352
+ type: "object",
2353
+ description: "JSON Schema for validating request headers"
2354
+ })
2355
+ });
2356
+ var ContextConfigInsertSchema = createInsertSchema(contextConfigs).extend({
2357
+ id: resourceIdSchema.optional(),
2358
+ headersSchema: zodOpenapi.z.any().nullable().optional().openapi({
2359
+ type: "object",
2360
+ description: "JSON Schema for validating request headers"
2361
+ }),
2362
+ contextVariables: zodOpenapi.z.any().nullable().optional().openapi({
2363
+ type: "object",
2364
+ description: "Context variables configuration with fetch definitions"
2365
+ })
2366
+ }).omit({
2367
+ createdAt: true,
2368
+ updatedAt: true
2369
+ });
2370
+ var ContextConfigUpdateSchema = ContextConfigInsertSchema.partial();
2371
+ var ContextConfigApiSelectSchema = createApiSchema(ContextConfigSelectSchema).omit({
2372
+ agentId: true
2373
+ }).openapi("ContextConfig");
2374
+ var ContextConfigApiInsertSchema = createApiInsertSchema(ContextConfigInsertSchema).omit({
2375
+ agentId: true
2376
+ }).openapi("ContextConfigCreate");
2377
+ var ContextConfigApiUpdateSchema = createApiUpdateSchema(ContextConfigUpdateSchema).omit({
2378
+ agentId: true
2379
+ }).openapi("ContextConfigUpdate");
2380
+ var SubAgentToolRelationSelectSchema = createSelectSchema(subAgentToolRelations);
2381
+ var SubAgentToolRelationInsertSchema = createInsertSchema(subAgentToolRelations).extend({
2382
+ id: resourceIdSchema,
2383
+ subAgentId: resourceIdSchema,
2384
+ toolId: resourceIdSchema,
2385
+ selectedTools: zodOpenapi.z.array(zodOpenapi.z.string()).nullish(),
2386
+ headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish(),
2387
+ toolPolicies: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.object({ needsApproval: zodOpenapi.z.boolean().optional() })).nullish()
2388
+ });
2389
+ var SubAgentToolRelationUpdateSchema = SubAgentToolRelationInsertSchema.partial();
2390
+ var SubAgentToolRelationApiSelectSchema = createAgentScopedApiSchema(
2391
+ SubAgentToolRelationSelectSchema
2392
+ ).openapi("SubAgentToolRelation");
2393
+ var SubAgentToolRelationApiInsertSchema = createAgentScopedApiInsertSchema(
2394
+ SubAgentToolRelationInsertSchema
2395
+ ).openapi("SubAgentToolRelationCreate");
2396
+ var SubAgentToolRelationApiUpdateSchema = createAgentScopedApiUpdateSchema(
2397
+ SubAgentToolRelationUpdateSchema
2398
+ ).openapi("SubAgentToolRelationUpdate");
2399
+ var SubAgentExternalAgentRelationSelectSchema = createSelectSchema(
2400
+ subAgentExternalAgentRelations
2401
+ );
2402
+ var SubAgentExternalAgentRelationInsertSchema = createInsertSchema(
2403
+ subAgentExternalAgentRelations
2404
+ ).extend({
2405
+ id: resourceIdSchema,
2406
+ subAgentId: resourceIdSchema,
2407
+ externalAgentId: resourceIdSchema,
2408
+ headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
2409
+ });
2410
+ var SubAgentExternalAgentRelationUpdateSchema = SubAgentExternalAgentRelationInsertSchema.partial();
2411
+ var SubAgentExternalAgentRelationApiSelectSchema = createAgentScopedApiSchema(
2412
+ SubAgentExternalAgentRelationSelectSchema
2413
+ ).openapi("SubAgentExternalAgentRelation");
2414
+ var SubAgentExternalAgentRelationApiInsertSchema = createAgentScopedApiInsertSchema(
2415
+ SubAgentExternalAgentRelationInsertSchema
2416
+ ).omit({ id: true, subAgentId: true }).openapi("SubAgentExternalAgentRelationCreate");
2417
+ var SubAgentExternalAgentRelationApiUpdateSchema = createAgentScopedApiUpdateSchema(
2418
+ SubAgentExternalAgentRelationUpdateSchema
2419
+ ).openapi("SubAgentExternalAgentRelationUpdate");
2420
+ var SubAgentTeamAgentRelationSelectSchema = createSelectSchema(subAgentTeamAgentRelations);
2421
+ var SubAgentTeamAgentRelationInsertSchema = createInsertSchema(
2422
+ subAgentTeamAgentRelations
2423
+ ).extend({
2424
+ id: resourceIdSchema,
2425
+ subAgentId: resourceIdSchema,
2426
+ targetAgentId: resourceIdSchema,
2427
+ headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
2428
+ });
2429
+ var SubAgentTeamAgentRelationUpdateSchema = SubAgentTeamAgentRelationInsertSchema.partial();
2430
+ var SubAgentTeamAgentRelationApiSelectSchema = createAgentScopedApiSchema(
2431
+ SubAgentTeamAgentRelationSelectSchema
2432
+ ).openapi("SubAgentTeamAgentRelation");
2433
+ var SubAgentTeamAgentRelationApiInsertSchema = createAgentScopedApiInsertSchema(
2434
+ SubAgentTeamAgentRelationInsertSchema
2435
+ ).omit({ id: true, subAgentId: true }).openapi("SubAgentTeamAgentRelationCreate");
2436
+ var SubAgentTeamAgentRelationApiUpdateSchema = createAgentScopedApiUpdateSchema(
2437
+ SubAgentTeamAgentRelationUpdateSchema
2438
+ ).openapi("SubAgentTeamAgentRelationUpdate");
2439
+ var LedgerArtifactSelectSchema = createSelectSchema(ledgerArtifacts);
2440
+ var LedgerArtifactInsertSchema = createInsertSchema(ledgerArtifacts);
2441
+ var LedgerArtifactUpdateSchema = LedgerArtifactInsertSchema.partial();
2442
+ var LedgerArtifactApiSelectSchema = createApiSchema(LedgerArtifactSelectSchema);
2443
+ var LedgerArtifactApiInsertSchema = createApiInsertSchema(LedgerArtifactInsertSchema);
2444
+ var LedgerArtifactApiUpdateSchema = createApiUpdateSchema(LedgerArtifactUpdateSchema);
2445
+ var StatusComponentSchema = zodOpenapi.z.object({
2446
+ type: zodOpenapi.z.string(),
2447
+ description: zodOpenapi.z.string().optional(),
2448
+ detailsSchema: zodOpenapi.z.object({
2449
+ type: zodOpenapi.z.literal("object"),
2450
+ properties: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.any()),
2451
+ required: zodOpenapi.z.array(zodOpenapi.z.string()).optional()
2452
+ }).optional()
2453
+ }).openapi("StatusComponent");
2454
+ var StatusUpdateSchema = zodOpenapi.z.object({
2455
+ enabled: zodOpenapi.z.boolean().optional(),
2456
+ numEvents: zodOpenapi.z.number().min(1).max(STATUS_UPDATE_MAX_NUM_EVENTS).optional(),
2457
+ timeInSeconds: zodOpenapi.z.number().min(1).max(STATUS_UPDATE_MAX_INTERVAL_SECONDS).optional(),
2458
+ prompt: zodOpenapi.z.string().max(
2459
+ VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS,
2460
+ `Custom prompt cannot exceed ${VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS} characters`
2461
+ ).optional(),
2462
+ statusComponents: zodOpenapi.z.array(StatusComponentSchema).optional()
2463
+ }).openapi("StatusUpdate");
2464
+ var CanUseItemSchema = zodOpenapi.z.object({
2465
+ agentToolRelationId: zodOpenapi.z.string().optional(),
2466
+ toolId: zodOpenapi.z.string(),
2467
+ toolSelection: zodOpenapi.z.array(zodOpenapi.z.string()).nullish(),
2468
+ headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish(),
2469
+ toolPolicies: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.object({ needsApproval: zodOpenapi.z.boolean().optional() })).nullish()
2470
+ }).openapi("CanUseItem");
2471
+ var canDelegateToExternalAgentSchema = zodOpenapi.z.object({
2472
+ externalAgentId: zodOpenapi.z.string(),
2473
+ subAgentExternalAgentRelationId: zodOpenapi.z.string().optional(),
2474
+ headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
2475
+ }).openapi("CanDelegateToExternalAgent");
2476
+ var canDelegateToTeamAgentSchema = zodOpenapi.z.object({
2477
+ agentId: zodOpenapi.z.string(),
2478
+ subAgentTeamAgentRelationId: zodOpenapi.z.string().optional(),
2479
+ headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
2480
+ }).openapi("CanDelegateToTeamAgent");
2481
+ var TeamAgentSchema = zodOpenapi.z.object({
2482
+ id: zodOpenapi.z.string(),
2483
+ name: zodOpenapi.z.string(),
2484
+ description: zodOpenapi.z.string()
2485
+ }).openapi("TeamAgent");
2486
+ var FullAgentAgentInsertSchema = SubAgentApiInsertSchema.extend({
2487
+ type: zodOpenapi.z.literal("internal"),
2488
+ canUse: zodOpenapi.z.array(CanUseItemSchema),
2489
+ // All tools (both MCP and function tools)
2490
+ dataComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
2491
+ artifactComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
2492
+ canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
2493
+ prompt: zodOpenapi.z.string().trim().nonempty(),
2494
+ canDelegateTo: zodOpenapi.z.array(
2495
+ zodOpenapi.z.union([
2496
+ zodOpenapi.z.string(),
2497
+ // Internal subAgent ID
2498
+ canDelegateToExternalAgentSchema,
2499
+ // External agent with headers
2500
+ canDelegateToTeamAgentSchema
2501
+ // Team agent with headers
2502
+ ])
2503
+ ).optional()
2504
+ }).openapi("FullAgentAgentInsert");
2505
+ var AgentWithinContextOfProjectSchema = AgentApiInsertSchema.extend({
2506
+ subAgents: zodOpenapi.z.record(zodOpenapi.z.string(), FullAgentAgentInsertSchema),
2507
+ // Lookup maps for UI to resolve canUse items
2508
+ tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema).optional(),
2509
+ // MCP tools (project-scoped)
2510
+ externalAgents: zodOpenapi.z.record(zodOpenapi.z.string(), ExternalAgentApiInsertSchema).optional(),
2511
+ // External agents (project-scoped)
2512
+ teamAgents: zodOpenapi.z.record(zodOpenapi.z.string(), TeamAgentSchema).optional(),
2513
+ // Team agents contain basic metadata for the agent to be delegated to
2514
+ functionTools: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionToolApiInsertSchema).optional(),
2515
+ // Function tools (agent-scoped)
2516
+ functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
2517
+ // Get function code for function tools
2518
+ contextConfig: zodOpenapi.z.optional(ContextConfigApiInsertSchema),
2519
+ statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
2520
+ models: ModelSchema.optional(),
2521
+ stopWhen: AgentStopWhenSchema.optional(),
2522
+ prompt: zodOpenapi.z.string().max(
2523
+ VALIDATION_AGENT_PROMPT_MAX_CHARS,
2524
+ `Agent prompt cannot exceed ${VALIDATION_AGENT_PROMPT_MAX_CHARS} characters`
2525
+ ).optional()
2526
+ }).openapi("AgentWithinContextOfProject");
2527
+ var PaginationSchema = zodOpenapi.z.object({
2528
+ page: pageNumber,
2529
+ limit: limitNumber,
2530
+ total: zodOpenapi.z.number(),
2531
+ pages: zodOpenapi.z.number()
2532
+ }).openapi("Pagination");
2533
+ var ListResponseSchema = (itemSchema) => zodOpenapi.z.object({
2534
+ data: zodOpenapi.z.array(itemSchema),
2535
+ pagination: PaginationSchema
2536
+ });
2537
+ var SingleResponseSchema = (itemSchema) => zodOpenapi.z.object({
2538
+ data: itemSchema
2539
+ });
2540
+ var ErrorResponseSchema = zodOpenapi.z.object({
2541
+ error: zodOpenapi.z.string(),
2542
+ message: zodOpenapi.z.string().optional(),
2543
+ details: zodOpenapi.z.any().optional().openapi({
2544
+ description: "Additional error details"
2545
+ })
2546
+ }).openapi("ErrorResponse");
2547
+ var ExistsResponseSchema = zodOpenapi.z.object({
2548
+ exists: zodOpenapi.z.boolean()
2549
+ }).openapi("ExistsResponse");
2550
+ var RemovedResponseSchema = zodOpenapi.z.object({
2551
+ message: zodOpenapi.z.string(),
2552
+ removed: zodOpenapi.z.boolean()
2553
+ }).openapi("RemovedResponse");
2554
+ var ProjectSelectSchema = registerFieldSchemas(
2555
+ createSelectSchema(projects).extend({
2556
+ models: ProjectModelSchema.nullable(),
2557
+ stopWhen: StopWhenSchema.nullable()
2558
+ })
2559
+ );
2560
+ var ProjectInsertSchema = createInsertSchema(projects).extend({
2561
+ models: ProjectModelSchema,
2562
+ stopWhen: StopWhenSchema.optional()
2563
+ }).omit({
2564
+ createdAt: true,
2565
+ updatedAt: true
2566
+ });
2567
+ var ProjectUpdateSchema = ProjectInsertSchema.partial().omit({
2568
+ id: true,
2569
+ tenantId: true
2570
+ });
2571
+ var ProjectApiSelectSchema = ProjectSelectSchema.omit({ tenantId: true }).openapi(
2572
+ "Project"
2573
+ );
2574
+ var ProjectApiInsertSchema = ProjectInsertSchema.omit({ tenantId: true }).openapi(
2575
+ "ProjectCreate"
2576
+ );
2577
+ var ProjectApiUpdateSchema = ProjectUpdateSchema.openapi("ProjectUpdate");
2578
+ var FullProjectDefinitionSchema = ProjectApiInsertSchema.extend({
2579
+ agents: zodOpenapi.z.record(zodOpenapi.z.string(), AgentWithinContextOfProjectSchema),
2580
+ tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema),
2581
+ functionTools: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionToolApiInsertSchema).optional(),
2582
+ functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
2583
+ dataComponents: zodOpenapi.z.record(zodOpenapi.z.string(), DataComponentApiInsertSchema).optional(),
2584
+ artifactComponents: zodOpenapi.z.record(zodOpenapi.z.string(), ArtifactComponentApiInsertSchema).optional(),
2585
+ externalAgents: zodOpenapi.z.record(zodOpenapi.z.string(), ExternalAgentApiInsertSchema).optional(),
2586
+ statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
2587
+ credentialReferences: zodOpenapi.z.record(zodOpenapi.z.string(), CredentialReferenceApiInsertSchema).optional(),
2588
+ createdAt: zodOpenapi.z.string().optional(),
2589
+ updatedAt: zodOpenapi.z.string().optional()
2590
+ }).openapi("FullProjectDefinition");
2591
+ var ProjectResponse = zodOpenapi.z.object({ data: ProjectApiSelectSchema }).openapi("ProjectResponse");
2592
+ var SubAgentResponse = zodOpenapi.z.object({ data: SubAgentApiSelectSchema }).openapi("SubAgentResponse");
2593
+ var AgentResponse = zodOpenapi.z.object({ data: AgentApiSelectSchema }).openapi("AgentResponse");
2594
+ var ToolResponse = zodOpenapi.z.object({ data: ToolApiSelectSchema }).openapi("ToolResponse");
2595
+ var ExternalAgentResponse = zodOpenapi.z.object({ data: ExternalAgentApiSelectSchema }).openapi("ExternalAgentResponse");
2596
+ var ContextConfigResponse = zodOpenapi.z.object({ data: ContextConfigApiSelectSchema }).openapi("ContextConfigResponse");
2597
+ var ApiKeyResponse = zodOpenapi.z.object({ data: ApiKeyApiSelectSchema }).openapi("ApiKeyResponse");
2598
+ var CredentialReferenceResponse = zodOpenapi.z.object({ data: CredentialReferenceApiSelectSchema }).openapi("CredentialReferenceResponse");
2599
+ var FunctionResponse = zodOpenapi.z.object({ data: FunctionApiSelectSchema }).openapi("FunctionResponse");
2600
+ var FunctionToolResponse = zodOpenapi.z.object({ data: FunctionToolApiSelectSchema }).openapi("FunctionToolResponse");
2601
+ var DataComponentResponse = zodOpenapi.z.object({ data: DataComponentApiSelectSchema }).openapi("DataComponentResponse");
2602
+ var ArtifactComponentResponse = zodOpenapi.z.object({ data: ArtifactComponentApiSelectSchema }).openapi("ArtifactComponentResponse");
2603
+ var SubAgentRelationResponse = zodOpenapi.z.object({ data: SubAgentRelationApiSelectSchema }).openapi("SubAgentRelationResponse");
2604
+ var SubAgentToolRelationResponse = zodOpenapi.z.object({ data: SubAgentToolRelationApiSelectSchema }).openapi("SubAgentToolRelationResponse");
2605
+ var ConversationResponse = zodOpenapi.z.object({ data: ConversationApiSelectSchema }).openapi("ConversationResponse");
2606
+ var MessageResponse = zodOpenapi.z.object({ data: MessageApiSelectSchema }).openapi("MessageResponse");
2607
+ var ProjectListResponse = zodOpenapi.z.object({
2608
+ data: zodOpenapi.z.array(ProjectApiSelectSchema),
2609
+ pagination: PaginationSchema
2610
+ }).openapi("ProjectListResponse");
2611
+ var SubAgentListResponse = zodOpenapi.z.object({
2612
+ data: zodOpenapi.z.array(SubAgentApiSelectSchema),
2613
+ pagination: PaginationSchema
2614
+ }).openapi("SubAgentListResponse");
2615
+ var AgentListResponse = zodOpenapi.z.object({
2616
+ data: zodOpenapi.z.array(AgentApiSelectSchema),
2617
+ pagination: PaginationSchema
2618
+ }).openapi("AgentListResponse");
2619
+ var ToolListResponse = zodOpenapi.z.object({
2620
+ data: zodOpenapi.z.array(ToolApiSelectSchema),
2621
+ pagination: PaginationSchema
2622
+ }).openapi("ToolListResponse");
2623
+ var ExternalAgentListResponse = zodOpenapi.z.object({
2624
+ data: zodOpenapi.z.array(ExternalAgentApiSelectSchema),
2625
+ pagination: PaginationSchema
2626
+ }).openapi("ExternalAgentListResponse");
2627
+ var ContextConfigListResponse = zodOpenapi.z.object({
2628
+ data: zodOpenapi.z.array(ContextConfigApiSelectSchema),
2629
+ pagination: PaginationSchema
2630
+ }).openapi("ContextConfigListResponse");
2631
+ var ApiKeyListResponse = zodOpenapi.z.object({
2632
+ data: zodOpenapi.z.array(ApiKeyApiSelectSchema),
2633
+ pagination: PaginationSchema
2634
+ }).openapi("ApiKeyListResponse");
2635
+ var CredentialReferenceListResponse = zodOpenapi.z.object({
2636
+ data: zodOpenapi.z.array(CredentialReferenceApiSelectSchema),
2637
+ pagination: PaginationSchema
2638
+ }).openapi("CredentialReferenceListResponse");
2639
+ var FunctionListResponse = zodOpenapi.z.object({
2640
+ data: zodOpenapi.z.array(FunctionApiSelectSchema),
2641
+ pagination: PaginationSchema
2642
+ }).openapi("FunctionListResponse");
2643
+ var FunctionToolListResponse = zodOpenapi.z.object({
2644
+ data: zodOpenapi.z.array(FunctionToolApiSelectSchema),
2645
+ pagination: PaginationSchema
2646
+ }).openapi("FunctionToolListResponse");
2647
+ var DataComponentListResponse = zodOpenapi.z.object({
2648
+ data: zodOpenapi.z.array(DataComponentApiSelectSchema),
2649
+ pagination: PaginationSchema
2650
+ }).openapi("DataComponentListResponse");
2651
+ var ArtifactComponentListResponse = zodOpenapi.z.object({
2652
+ data: zodOpenapi.z.array(ArtifactComponentApiSelectSchema),
2653
+ pagination: PaginationSchema
2654
+ }).openapi("ArtifactComponentListResponse");
2655
+ var SubAgentRelationListResponse = zodOpenapi.z.object({
2656
+ data: zodOpenapi.z.array(SubAgentRelationApiSelectSchema),
2657
+ pagination: PaginationSchema
2658
+ }).openapi("SubAgentRelationListResponse");
2659
+ var SubAgentToolRelationListResponse = zodOpenapi.z.object({
2660
+ data: zodOpenapi.z.array(SubAgentToolRelationApiSelectSchema),
2661
+ pagination: PaginationSchema
2662
+ }).openapi("SubAgentToolRelationListResponse");
2663
+ var ConversationListResponse = zodOpenapi.z.object({
2664
+ data: zodOpenapi.z.array(ConversationApiSelectSchema),
2665
+ pagination: PaginationSchema
2666
+ }).openapi("ConversationListResponse");
2667
+ var MessageListResponse = zodOpenapi.z.object({
2668
+ data: zodOpenapi.z.array(MessageApiSelectSchema),
2669
+ pagination: PaginationSchema
2670
+ }).openapi("MessageListResponse");
2671
+ var SubAgentDataComponentResponse = zodOpenapi.z.object({ data: SubAgentDataComponentApiSelectSchema }).openapi("SubAgentDataComponentResponse");
2672
+ var SubAgentArtifactComponentResponse = zodOpenapi.z.object({ data: SubAgentArtifactComponentApiSelectSchema }).openapi("SubAgentArtifactComponentResponse");
2673
+ var SubAgentDataComponentListResponse = zodOpenapi.z.object({
2674
+ data: zodOpenapi.z.array(SubAgentDataComponentApiSelectSchema),
2675
+ pagination: PaginationSchema
2676
+ }).openapi("SubAgentDataComponentListResponse");
2677
+ var SubAgentArtifactComponentListResponse = zodOpenapi.z.object({
2678
+ data: zodOpenapi.z.array(SubAgentArtifactComponentApiSelectSchema),
2679
+ pagination: PaginationSchema
2680
+ }).openapi("SubAgentArtifactComponentListResponse");
2681
+ var FullProjectDefinitionResponse = zodOpenapi.z.object({ data: FullProjectDefinitionSchema }).openapi("FullProjectDefinitionResponse");
2682
+ var AgentWithinContextOfProjectResponse = zodOpenapi.z.object({ data: AgentWithinContextOfProjectSchema }).openapi("AgentWithinContextOfProjectResponse");
2683
+ var RelatedAgentInfoListResponse = zodOpenapi.z.object({
2684
+ data: zodOpenapi.z.array(RelatedAgentInfoSchema),
2685
+ pagination: PaginationSchema
2686
+ }).openapi("RelatedAgentInfoListResponse");
2687
+ var ComponentAssociationListResponse = zodOpenapi.z.object({ data: zodOpenapi.z.array(ComponentAssociationSchema) }).openapi("ComponentAssociationListResponse");
2688
+ var McpToolResponse = zodOpenapi.z.object({ data: McpToolSchema }).openapi("McpToolResponse");
2689
+ var McpToolListResponse = zodOpenapi.z.object({
2690
+ data: zodOpenapi.z.array(McpToolSchema),
2691
+ pagination: PaginationSchema
2692
+ }).openapi("McpToolListResponse");
2693
+ var SubAgentTeamAgentRelationResponse = zodOpenapi.z.object({ data: SubAgentTeamAgentRelationApiSelectSchema }).openapi("SubAgentTeamAgentRelationResponse");
2694
+ var SubAgentTeamAgentRelationListResponse = zodOpenapi.z.object({
2695
+ data: zodOpenapi.z.array(SubAgentTeamAgentRelationApiSelectSchema),
2696
+ pagination: PaginationSchema
2697
+ }).openapi("SubAgentTeamAgentRelationListResponse");
2698
+ var SubAgentExternalAgentRelationResponse = zodOpenapi.z.object({ data: SubAgentExternalAgentRelationApiSelectSchema }).openapi("SubAgentExternalAgentRelationResponse");
2699
+ var SubAgentExternalAgentRelationListResponse = zodOpenapi.z.object({
2700
+ data: zodOpenapi.z.array(SubAgentExternalAgentRelationApiSelectSchema),
2701
+ pagination: PaginationSchema
2702
+ }).openapi("SubAgentExternalAgentRelationListResponse");
2703
+ var DataComponentArrayResponse = zodOpenapi.z.object({ data: zodOpenapi.z.array(DataComponentApiSelectSchema) }).openapi("DataComponentArrayResponse");
2704
+ var ArtifactComponentArrayResponse = zodOpenapi.z.object({ data: zodOpenapi.z.array(ArtifactComponentApiSelectSchema) }).openapi("ArtifactComponentArrayResponse");
2705
+ var HeadersScopeSchema = zodOpenapi.z.object({
2706
+ "x-inkeep-tenant-id": zodOpenapi.z.string().optional().openapi({
2707
+ description: "Tenant identifier",
2708
+ example: "tenant_123"
2709
+ }),
2710
+ "x-inkeep-project-id": zodOpenapi.z.string().optional().openapi({
2711
+ description: "Project identifier",
2712
+ example: "project_456"
2713
+ }),
2714
+ "x-inkeep-agent-id": zodOpenapi.z.string().optional().openapi({
2715
+ description: "Agent identifier",
2716
+ example: "agent_789"
2717
+ })
2718
+ });
2719
+ var TenantId = zodOpenapi.z.string().openapi("TenantIdPathParam", {
2720
+ param: {
2721
+ name: "tenantId",
2722
+ in: "path"
2723
+ },
2724
+ description: "Tenant identifier",
2725
+ example: "tenant_123"
2726
+ });
2727
+ var ProjectId = zodOpenapi.z.string().openapi("ProjectIdPathParam", {
2728
+ param: {
2729
+ name: "projectId",
2730
+ in: "path"
2731
+ },
2732
+ description: "Project identifier",
2733
+ example: "project_456"
2734
+ });
2735
+ var AgentId = zodOpenapi.z.string().openapi("AgentIdPathParam", {
2736
+ param: {
2737
+ name: "agentId",
2738
+ in: "path"
2739
+ },
2740
+ description: "Agent identifier",
2741
+ example: "agent_789"
2742
+ });
2743
+ var SubAgentId = zodOpenapi.z.string().openapi("SubAgentIdPathParam", {
2744
+ param: {
2745
+ name: "subAgentId",
2746
+ in: "path"
2747
+ },
2748
+ description: "Sub-agent identifier",
2749
+ example: "sub_agent_123"
2750
+ });
2751
+ var TenantParamsSchema = zodOpenapi.z.object({
2752
+ tenantId: TenantId
2753
+ });
2754
+ var TenantIdParamsSchema = TenantParamsSchema.extend({
2755
+ id: resourceIdSchema
2756
+ });
2757
+ var TenantProjectParamsSchema = TenantParamsSchema.extend({
2758
+ projectId: ProjectId
2759
+ });
2760
+ var TenantProjectIdParamsSchema = TenantProjectParamsSchema.extend({
2761
+ id: resourceIdSchema
2762
+ });
2763
+ var TenantProjectAgentParamsSchema = TenantProjectParamsSchema.extend({
2764
+ agentId: AgentId
2765
+ });
2766
+ var TenantProjectAgentIdParamsSchema = TenantProjectAgentParamsSchema.extend({
2767
+ id: resourceIdSchema
2768
+ });
2769
+ var TenantProjectAgentSubAgentParamsSchema = TenantProjectAgentParamsSchema.extend({
2770
+ subAgentId: SubAgentId
2771
+ });
2772
+ var TenantProjectAgentSubAgentIdParamsSchema = TenantProjectAgentSubAgentParamsSchema.extend({
2773
+ id: resourceIdSchema
2774
+ });
2775
+ var PaginationQueryParamsSchema = zodOpenapi.z.object({
2776
+ page: pageNumber,
2777
+ limit: limitNumber
2778
+ }).openapi("PaginationQueryParams");
2779
+ var PrebuiltMCPServerSchema = zodOpenapi.z.object({
2780
+ id: zodOpenapi.z.string().describe("Unique identifier for the MCP server"),
2781
+ name: zodOpenapi.z.string().describe("Display name of the MCP server"),
2782
+ url: zodOpenapi.z.url().describe("URL endpoint for the MCP server"),
2783
+ transport: zodOpenapi.z.enum(MCPTransportType).describe("Transport protocol type"),
2784
+ imageUrl: zodOpenapi.z.url().optional().describe("Logo/icon URL for the MCP server"),
2785
+ isOpen: zodOpenapi.z.boolean().optional().describe("Whether the MCP server is open (doesn't require authentication)"),
2786
+ category: zodOpenapi.z.string().optional().describe("Category of the MCP server (e.g., communication, project_management)"),
2787
+ description: zodOpenapi.z.string().optional().describe("Brief description of what the MCP server does"),
2788
+ thirdPartyConnectAccountUrl: zodOpenapi.z.url().optional().describe("URL to connect to the third party account")
2789
+ });
2790
+ var MCPCatalogListResponse = zodOpenapi.z.object({
2791
+ data: zodOpenapi.z.array(PrebuiltMCPServerSchema)
2792
+ }).openapi("MCPCatalogListResponse");
2793
+ var ThirdPartyMCPServerResponse = zodOpenapi.z.object({
2794
+ data: PrebuiltMCPServerSchema.nullable()
2795
+ }).openapi("ThirdPartyMCPServerResponse");
2796
+
2797
+ // src/validation/agentFull.ts
2798
+ function validateAndTypeAgentData(data) {
2799
+ return AgentWithinContextOfProjectSchema.parse(data);
2800
+ }
2801
+ function validateToolReferences(agentData, availableToolIds) {
2802
+ if (!availableToolIds) {
2803
+ return;
2804
+ }
2805
+ const errors = [];
2806
+ for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
2807
+ if (subAgent.canUse && Array.isArray(subAgent.canUse)) {
2808
+ for (const canUseItem of subAgent.canUse) {
2809
+ if (!availableToolIds.has(canUseItem.toolId)) {
2810
+ errors.push(`Agent '${subAgentId}' references non-existent tool '${canUseItem.toolId}'`);
2811
+ }
2812
+ }
2813
+ }
2814
+ }
2815
+ if (errors.length > 0) {
2816
+ throw new Error(`Tool reference validation failed:
2817
+ ${errors.join("\n")}`);
2818
+ }
2819
+ }
2820
+ function validateDataComponentReferences(agentData, availableDataComponentIds) {
2821
+ if (!availableDataComponentIds) {
2822
+ return;
2823
+ }
2824
+ const errors = [];
2825
+ for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
2826
+ if (subAgent.dataComponents) {
2827
+ for (const dataComponentId of subAgent.dataComponents) {
2828
+ if (!availableDataComponentIds.has(dataComponentId)) {
2829
+ errors.push(
2830
+ `Agent '${subAgentId}' references non-existent dataComponent '${dataComponentId}'`
2831
+ );
2832
+ }
2833
+ }
2834
+ }
2835
+ }
2836
+ if (errors.length > 0) {
2837
+ throw new Error(`DataComponent reference validation failed:
2838
+ ${errors.join("\n")}`);
2839
+ }
2840
+ }
2841
+ function validateArtifactComponentReferences(agentData, availableArtifactComponentIds) {
2842
+ if (!availableArtifactComponentIds) {
2843
+ return;
2844
+ }
2845
+ const errors = [];
2846
+ for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
2847
+ if (subAgent.artifactComponents) {
2848
+ for (const artifactComponentId of subAgent.artifactComponents) {
2849
+ if (!availableArtifactComponentIds.has(artifactComponentId)) {
2850
+ errors.push(
2851
+ `Agent '${subAgentId}' references non-existent artifactComponent '${artifactComponentId}'`
2852
+ );
2853
+ }
2854
+ }
2855
+ }
2856
+ }
2857
+ if (errors.length > 0) {
2858
+ throw new Error(`ArtifactComponent reference validation failed:
2859
+ ${errors.join("\n")}`);
2860
+ }
2861
+ }
2862
+ function validateAgentRelationships(agentData) {
2863
+ const errors = [];
2864
+ const availableAgentIds = new Set(Object.keys(agentData.subAgents));
2865
+ const availableExternalAgentIds = new Set(Object.keys(agentData.externalAgents ?? {}));
2866
+ for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
2867
+ if (subAgent.canTransferTo && Array.isArray(subAgent.canTransferTo)) {
2868
+ for (const targetId of subAgent.canTransferTo) {
2869
+ if (!availableAgentIds.has(targetId)) {
2870
+ errors.push(
2871
+ `Agent '${subAgentId}' has transfer target '${targetId}' that doesn't exist in agent`
2872
+ );
2873
+ }
2874
+ }
2875
+ }
2876
+ if (subAgent.canDelegateTo && Array.isArray(subAgent.canDelegateTo)) {
2877
+ for (const targetItem of subAgent.canDelegateTo) {
2878
+ console.log("targetItem", targetItem);
2879
+ if (typeof targetItem === "string") {
2880
+ console.log("targetItem is string", targetItem);
2881
+ if (!availableAgentIds.has(targetItem) && !availableExternalAgentIds.has(targetItem)) {
2882
+ errors.push(
2883
+ `Agent '${subAgentId}' has delegation target '${targetItem}' that doesn't exist in agent`
2884
+ );
2885
+ }
2886
+ }
2887
+ }
2888
+ }
2889
+ }
2890
+ const cycles = detectDelegationCycles(agentData);
2891
+ if (cycles.length > 0) {
2892
+ errors.push(...cycles);
2893
+ }
2894
+ if (errors.length > 0)
2895
+ throw new Error(`Agent relationship validation failed:
2896
+ ${errors.join("\n")}`);
2897
+ }
2898
+ function validateSubAgentExternalAgentRelations(agentData, availableExternalAgentIds) {
2899
+ if (!availableExternalAgentIds) {
2900
+ return;
2901
+ }
2902
+ const errors = [];
2903
+ for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
2904
+ if (subAgent.canDelegateTo && Array.isArray(subAgent.canDelegateTo)) {
2905
+ for (const targetItem of subAgent.canDelegateTo) {
2906
+ if (typeof targetItem === "object" && "externalAgentId" in targetItem) {
2907
+ if (!availableExternalAgentIds.has(targetItem.externalAgentId)) {
2908
+ errors.push(
2909
+ `Agent '${subAgentId}' has delegation target '${targetItem.externalAgentId}' that doesn't exist in agent`
2910
+ );
2911
+ }
2912
+ }
2913
+ }
2914
+ }
2915
+ }
2916
+ if (errors.length > 0)
2917
+ throw new Error(`Sub agent external agent relation validation failed:
2918
+ ${errors.join("\n")}`);
2919
+ }
2920
+ function validateAgentStructure(agentData, projectResources) {
2921
+ if (agentData.defaultSubAgentId && !agentData.subAgents[agentData.defaultSubAgentId]) {
2922
+ throw new Error(`Default agent '${agentData.defaultSubAgentId}' does not exist in agents`);
2923
+ }
2924
+ if (projectResources) {
2925
+ validateToolReferences(agentData, projectResources.toolIds);
2926
+ validateDataComponentReferences(agentData, projectResources.dataComponentIds);
2927
+ validateArtifactComponentReferences(agentData, projectResources.artifactComponentIds);
2928
+ validateSubAgentExternalAgentRelations(agentData, projectResources.externalAgentIds);
2929
+ }
2930
+ validateAgentRelationships(agentData);
2931
+ }
2932
+ var TransferDataSchema = zod.z.object({
2933
+ fromSubAgent: zod.z.string().describe("ID of the sub-agent transferring control"),
2934
+ targetSubAgent: zod.z.string().describe("ID of the sub-agent receiving control"),
2935
+ reason: zod.z.string().optional().describe("Reason for the transfer"),
2936
+ context: zod.z.any().optional().describe("Additional context data")
2937
+ });
2938
+ var DelegationSentDataSchema = zod.z.object({
2939
+ delegationId: zod.z.string().describe("Unique identifier for this delegation"),
2940
+ fromSubAgent: zod.z.string().describe("ID of the delegating sub-agent"),
2941
+ targetSubAgent: zod.z.string().describe("ID of the sub-agent receiving the delegation"),
2942
+ taskDescription: zod.z.string().describe("Description of the delegated task"),
2943
+ context: zod.z.any().optional().describe("Additional context data")
2944
+ });
2945
+ var DelegationReturnedDataSchema = zod.z.object({
2946
+ delegationId: zod.z.string().describe("Unique identifier matching the original delegation"),
2947
+ fromSubAgent: zod.z.string().describe("ID of the sub-agent that completed the task"),
2948
+ targetSubAgent: zod.z.string().describe("ID of the sub-agent receiving the result"),
2949
+ result: zod.z.any().optional().describe("Result data from the delegated task")
2950
+ });
2951
+ var DataOperationDetailsSchema = zod.z.object({
2952
+ timestamp: zod.z.number().describe("Unix timestamp in milliseconds"),
2953
+ subAgentId: zod.z.string().describe("ID of the sub-agent that generated this data"),
2954
+ data: zod.z.any().describe("The actual data payload")
2955
+ });
2956
+ var DataOperationEventSchema = zod.z.object({
2957
+ type: zod.z.string().describe("Event type identifier"),
2958
+ label: zod.z.string().describe("Human-readable label for the event"),
2959
+ details: DataOperationDetailsSchema
2960
+ });
2961
+ var A2AMessageMetadataSchema = zod.z.object({
2962
+ fromSubAgentId: zod.z.string().optional().describe("ID of the sending sub-agent"),
2963
+ toSubAgentId: zod.z.string().optional().describe("ID of the receiving sub-agent"),
2964
+ fromExternalAgentId: zod.z.string().optional().describe("ID of the sending external agent"),
2965
+ toExternalAgentId: zod.z.string().optional().describe("ID of the receiving external agent"),
2966
+ taskId: zod.z.string().optional().describe("Associated task ID"),
2967
+ a2aTaskId: zod.z.string().optional().describe("A2A-specific task ID")
2968
+ });
2969
+
2970
+ // src/validation/id-validation.ts
2971
+ function isValidResourceId(id) {
2972
+ const result = resourceIdSchema.safeParse(id);
2973
+ return result.success;
2974
+ }
2975
+ function generateIdFromName(name) {
2976
+ const id = name.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-");
2977
+ if (!id) {
2978
+ throw new Error("Cannot generate valid ID from provided name");
2979
+ }
2980
+ const truncatedId = id.substring(0, MAX_ID_LENGTH);
2981
+ const result = resourceIdSchema.safeParse(truncatedId);
2982
+ if (!result.success) {
2983
+ throw new Error(`Generated ID "${truncatedId}" is not valid: ${result.error.message}`);
2984
+ }
2985
+ return truncatedId;
2986
+ }
2987
+ function validatePropsAsJsonSchema(props) {
2988
+ if (!props || typeof props === "object" && Object.keys(props).length === 0) {
2989
+ return {
2990
+ isValid: true,
2991
+ errors: []
2992
+ };
2993
+ }
2994
+ if (typeof props !== "object" || Array.isArray(props)) {
2995
+ return {
2996
+ isValid: false,
2997
+ errors: [
2998
+ {
2999
+ field: "props",
3000
+ message: "Props must be a valid JSON Schema object",
3001
+ value: props
3002
+ }
3003
+ ]
3004
+ };
3005
+ }
3006
+ if (!props.type) {
3007
+ return {
3008
+ isValid: false,
3009
+ errors: [
3010
+ {
3011
+ field: "props.type",
3012
+ message: 'JSON Schema must have a "type" field'
3013
+ }
3014
+ ]
3015
+ };
3016
+ }
3017
+ if (props.type !== "object") {
3018
+ return {
3019
+ isValid: false,
3020
+ errors: [
3021
+ {
3022
+ field: "props.type",
3023
+ message: 'JSON Schema type must be "object" for component props',
3024
+ value: props.type
3025
+ }
3026
+ ]
3027
+ };
3028
+ }
3029
+ if (!props.properties || typeof props.properties !== "object") {
3030
+ return {
3031
+ isValid: false,
3032
+ errors: [
3033
+ {
3034
+ field: "props.properties",
3035
+ message: 'JSON Schema must have a "properties" object'
3036
+ }
3037
+ ]
3038
+ };
3039
+ }
3040
+ if (props.required !== void 0 && !Array.isArray(props.required)) {
3041
+ return {
3042
+ isValid: false,
3043
+ errors: [
3044
+ {
3045
+ field: "props.required",
3046
+ message: 'If present, "required" must be an array'
3047
+ }
3048
+ ]
3049
+ };
3050
+ }
3051
+ try {
3052
+ const schemaToValidate = { ...props };
3053
+ delete schemaToValidate.$schema;
3054
+ const schemaValidator = new Ajv__default.default({
3055
+ strict: false,
3056
+ // Allow unknown keywords like inPreview
3057
+ validateSchema: true,
3058
+ // Validate the schema itself
3059
+ addUsedSchema: false
3060
+ // Don't add schemas to the instance
3061
+ });
3062
+ const isValid = schemaValidator.validateSchema(schemaToValidate);
3063
+ if (!isValid) {
3064
+ const errors = schemaValidator.errors || [];
3065
+ return {
3066
+ isValid: false,
3067
+ errors: errors.map((error) => ({
3068
+ field: `props${error.instancePath || ""}`,
3069
+ message: error.message || "Invalid schema"
3070
+ }))
3071
+ };
3072
+ }
3073
+ return {
3074
+ isValid: true,
3075
+ errors: []
3076
+ };
3077
+ } catch (error) {
3078
+ return {
3079
+ isValid: false,
3080
+ errors: [
3081
+ {
3082
+ field: "props",
3083
+ message: `Schema validation failed: ${error instanceof Error ? error.message : "Unknown error"}`
3084
+ }
3085
+ ]
3086
+ };
3087
+ }
3088
+ }
3089
+
3090
+ // src/validation/render-validation.ts
3091
+ var MAX_CODE_SIZE = 5e4;
3092
+ var MAX_DATA_SIZE = 1e4;
3093
+ var DANGEROUS_PATTERNS = [
3094
+ {
3095
+ pattern: /\beval\s*\(/i,
3096
+ message: "eval() is not allowed"
3097
+ },
3098
+ {
3099
+ pattern: /\bFunction\s*\(/i,
3100
+ message: "Function constructor is not allowed"
3101
+ },
3102
+ {
3103
+ pattern: /dangerouslySetInnerHTML/i,
3104
+ message: "dangerouslySetInnerHTML is not allowed"
3105
+ },
3106
+ {
3107
+ pattern: /<script\b/i,
3108
+ message: "Script tags are not allowed"
3109
+ },
3110
+ {
3111
+ pattern: /\bon\w+\s*=/i,
3112
+ message: "Inline event handlers (onClick=, onLoad=, etc.) are not allowed"
3113
+ },
3114
+ {
3115
+ pattern: /document\.write/i,
3116
+ message: "document.write is not allowed"
3117
+ },
3118
+ {
3119
+ pattern: /window\.location/i,
3120
+ message: "window.location is not allowed"
3121
+ },
3122
+ {
3123
+ pattern: /\.innerHTML\s*=/i,
3124
+ message: "innerHTML manipulation is not allowed"
3125
+ }
3126
+ ];
3127
+ var ALLOWED_IMPORTS = ["lucide-react", "react"];
3128
+ function validateRender(render) {
3129
+ const errors = [];
3130
+ if (!render.component || typeof render.component !== "string") {
3131
+ return {
3132
+ isValid: false,
3133
+ errors: [{ field: "render.component", message: "Component must be a non-empty string" }]
3134
+ };
3135
+ }
3136
+ if (!render.mockData || typeof render.mockData !== "object") {
3137
+ return {
3138
+ isValid: false,
3139
+ errors: [{ field: "render.mockData", message: "MockData must be an object" }]
3140
+ };
3141
+ }
3142
+ if (render.component.length > MAX_CODE_SIZE) {
3143
+ errors.push({
3144
+ field: "render.component",
3145
+ message: `Component size exceeds maximum allowed (${MAX_CODE_SIZE} characters)`
3146
+ });
3147
+ }
3148
+ const dataString = JSON.stringify(render.mockData);
3149
+ if (dataString.length > MAX_DATA_SIZE) {
3150
+ errors.push({
3151
+ field: "render.mockData",
3152
+ message: `MockData size exceeds maximum allowed (${MAX_DATA_SIZE} characters)`
3153
+ });
3154
+ }
3155
+ for (const { pattern, message } of DANGEROUS_PATTERNS) {
3156
+ if (pattern.test(render.component)) {
3157
+ errors.push({
3158
+ field: "render.component",
3159
+ message: `Component contains potentially dangerous pattern: ${message}`
3160
+ });
3161
+ }
3162
+ }
3163
+ const importMatches = render.component.matchAll(/import\s+.*?\s+from\s+['"]([^'"]+)['"]/g);
3164
+ for (const match of importMatches) {
3165
+ const importPath = match[1];
3166
+ if (!ALLOWED_IMPORTS.includes(importPath) && !importPath.startsWith(".")) {
3167
+ errors.push({
3168
+ field: "render.component",
3169
+ message: `Import from "${importPath}" is not allowed. Only imports from ${ALLOWED_IMPORTS.join(", ")} are permitted`
3170
+ });
3171
+ }
3172
+ }
3173
+ const hasFunctionDeclaration = /function\s+\w+\s*\(/.test(render.component);
3174
+ if (!hasFunctionDeclaration) {
3175
+ errors.push({
3176
+ field: "render.component",
3177
+ message: "Component must contain a function declaration"
3178
+ });
3179
+ }
3180
+ const hasReturn = /return\s*\(?\s*</.test(render.component);
3181
+ if (!hasReturn) {
3182
+ errors.push({
3183
+ field: "render.component",
3184
+ message: "Component function must have a return statement with JSX"
3185
+ });
3186
+ }
3187
+ return {
3188
+ isValid: errors.length === 0,
3189
+ errors
3190
+ };
3191
+ }
3192
+ var TextStartEventSchema = zod.z.object({
3193
+ type: zod.z.literal("text-start"),
3194
+ id: zod.z.string()
3195
+ });
3196
+ var TextDeltaEventSchema = zod.z.object({
3197
+ type: zod.z.literal("text-delta"),
3198
+ id: zod.z.string(),
3199
+ delta: zod.z.string()
3200
+ });
3201
+ var TextEndEventSchema = zod.z.object({
3202
+ type: zod.z.literal("text-end"),
3203
+ id: zod.z.string()
3204
+ });
3205
+ var DataComponentStreamEventSchema = zod.z.object({
3206
+ type: zod.z.literal("data-component"),
3207
+ id: zod.z.string(),
3208
+ data: zod.z.any()
3209
+ });
3210
+ var DataOperationStreamEventSchema = zod.z.object({
3211
+ type: zod.z.literal("data-operation"),
3212
+ data: zod.z.any()
3213
+ // Contains OperationEvent types (AgentInitializingEvent, CompletionEvent, etc.)
3214
+ });
3215
+ var DataSummaryStreamEventSchema = zod.z.object({
3216
+ type: zod.z.literal("data-summary"),
3217
+ data: zod.z.any()
3218
+ // Contains SummaryEvent from entities.ts
3219
+ });
3220
+ var StreamErrorEventSchema = zod.z.object({
3221
+ type: zod.z.literal("error"),
3222
+ error: zod.z.string()
3223
+ });
3224
+ var StreamFinishEventSchema = zod.z.object({
3225
+ type: zod.z.literal("finish"),
3226
+ finishReason: zod.z.string().optional(),
3227
+ usage: zod.z.object({
3228
+ promptTokens: zod.z.number().optional(),
3229
+ completionTokens: zod.z.number().optional(),
3230
+ totalTokens: zod.z.number().optional()
3231
+ }).optional()
3232
+ });
3233
+ var StreamEventSchema = zod.z.discriminatedUnion("type", [
3234
+ TextStartEventSchema,
3235
+ TextDeltaEventSchema,
3236
+ TextEndEventSchema,
3237
+ DataComponentStreamEventSchema,
3238
+ DataOperationStreamEventSchema,
3239
+ DataSummaryStreamEventSchema,
3240
+ StreamErrorEventSchema,
3241
+ StreamFinishEventSchema
3242
+ ]);
3243
+
3244
+ exports.A2AMessageMetadataSchema = A2AMessageMetadataSchema;
3245
+ exports.AgentApiInsertSchema = AgentApiInsertSchema;
3246
+ exports.AgentApiSelectSchema = AgentApiSelectSchema;
3247
+ exports.AgentApiUpdateSchema = AgentApiUpdateSchema;
3248
+ exports.AgentInsertSchema = AgentInsertSchema;
3249
+ exports.AgentListResponse = AgentListResponse;
3250
+ exports.AgentResponse = AgentResponse;
3251
+ exports.AgentSelectSchema = AgentSelectSchema;
3252
+ exports.AgentStopWhenSchema = AgentStopWhenSchema;
3253
+ exports.AgentUpdateSchema = AgentUpdateSchema;
3254
+ exports.AgentWithinContextOfProjectResponse = AgentWithinContextOfProjectResponse;
3255
+ exports.AgentWithinContextOfProjectSchema = AgentWithinContextOfProjectSchema;
3256
+ exports.AllAgentSchema = AllAgentSchema;
3257
+ exports.ApiKeyApiCreationResponseSchema = ApiKeyApiCreationResponseSchema;
3258
+ exports.ApiKeyApiInsertSchema = ApiKeyApiInsertSchema;
3259
+ exports.ApiKeyApiSelectSchema = ApiKeyApiSelectSchema;
3260
+ exports.ApiKeyApiUpdateSchema = ApiKeyApiUpdateSchema;
3261
+ exports.ApiKeyInsertSchema = ApiKeyInsertSchema;
3262
+ exports.ApiKeyListResponse = ApiKeyListResponse;
3263
+ exports.ApiKeyResponse = ApiKeyResponse;
3264
+ exports.ApiKeySelectSchema = ApiKeySelectSchema;
3265
+ exports.ApiKeyUpdateSchema = ApiKeyUpdateSchema;
3266
+ exports.ArtifactComponentApiInsertSchema = ArtifactComponentApiInsertSchema;
3267
+ exports.ArtifactComponentApiSelectSchema = ArtifactComponentApiSelectSchema;
3268
+ exports.ArtifactComponentApiUpdateSchema = ArtifactComponentApiUpdateSchema;
3269
+ exports.ArtifactComponentArrayResponse = ArtifactComponentArrayResponse;
3270
+ exports.ArtifactComponentInsertSchema = ArtifactComponentInsertSchema;
3271
+ exports.ArtifactComponentListResponse = ArtifactComponentListResponse;
3272
+ exports.ArtifactComponentResponse = ArtifactComponentResponse;
3273
+ exports.ArtifactComponentSelectSchema = ArtifactComponentSelectSchema;
3274
+ exports.ArtifactComponentUpdateSchema = ArtifactComponentUpdateSchema;
3275
+ exports.CanUseItemSchema = CanUseItemSchema;
3276
+ exports.ComponentAssociationListResponse = ComponentAssociationListResponse;
3277
+ exports.ComponentAssociationSchema = ComponentAssociationSchema;
3278
+ exports.ContextCacheApiInsertSchema = ContextCacheApiInsertSchema;
3279
+ exports.ContextCacheApiSelectSchema = ContextCacheApiSelectSchema;
3280
+ exports.ContextCacheApiUpdateSchema = ContextCacheApiUpdateSchema;
3281
+ exports.ContextCacheInsertSchema = ContextCacheInsertSchema;
3282
+ exports.ContextCacheSelectSchema = ContextCacheSelectSchema;
3283
+ exports.ContextCacheUpdateSchema = ContextCacheUpdateSchema;
3284
+ exports.ContextConfigApiInsertSchema = ContextConfigApiInsertSchema;
3285
+ exports.ContextConfigApiSelectSchema = ContextConfigApiSelectSchema;
3286
+ exports.ContextConfigApiUpdateSchema = ContextConfigApiUpdateSchema;
3287
+ exports.ContextConfigInsertSchema = ContextConfigInsertSchema;
3288
+ exports.ContextConfigListResponse = ContextConfigListResponse;
3289
+ exports.ContextConfigResponse = ContextConfigResponse;
3290
+ exports.ContextConfigSelectSchema = ContextConfigSelectSchema;
3291
+ exports.ContextConfigUpdateSchema = ContextConfigUpdateSchema;
3292
+ exports.ConversationApiInsertSchema = ConversationApiInsertSchema;
3293
+ exports.ConversationApiSelectSchema = ConversationApiSelectSchema;
3294
+ exports.ConversationApiUpdateSchema = ConversationApiUpdateSchema;
3295
+ exports.ConversationInsertSchema = ConversationInsertSchema;
3296
+ exports.ConversationListResponse = ConversationListResponse;
3297
+ exports.ConversationResponse = ConversationResponse;
3298
+ exports.ConversationSelectSchema = ConversationSelectSchema;
3299
+ exports.ConversationUpdateSchema = ConversationUpdateSchema;
3300
+ exports.CreateCredentialInStoreRequestSchema = CreateCredentialInStoreRequestSchema;
3301
+ exports.CreateCredentialInStoreResponseSchema = CreateCredentialInStoreResponseSchema;
3302
+ exports.CredentialReferenceApiInsertSchema = CredentialReferenceApiInsertSchema;
3303
+ exports.CredentialReferenceApiSelectSchema = CredentialReferenceApiSelectSchema;
3304
+ exports.CredentialReferenceApiUpdateSchema = CredentialReferenceApiUpdateSchema;
3305
+ exports.CredentialReferenceInsertSchema = CredentialReferenceInsertSchema;
3306
+ exports.CredentialReferenceListResponse = CredentialReferenceListResponse;
3307
+ exports.CredentialReferenceResponse = CredentialReferenceResponse;
3308
+ exports.CredentialReferenceSelectSchema = CredentialReferenceSelectSchema;
3309
+ exports.CredentialReferenceUpdateSchema = CredentialReferenceUpdateSchema;
3310
+ exports.CredentialStoreListResponseSchema = CredentialStoreListResponseSchema;
3311
+ exports.CredentialStoreSchema = CredentialStoreSchema;
3312
+ exports.DataComponentApiInsertSchema = DataComponentApiInsertSchema;
3313
+ exports.DataComponentApiSelectSchema = DataComponentApiSelectSchema;
3314
+ exports.DataComponentApiUpdateSchema = DataComponentApiUpdateSchema;
3315
+ exports.DataComponentArrayResponse = DataComponentArrayResponse;
3316
+ exports.DataComponentBaseSchema = DataComponentBaseSchema;
3317
+ exports.DataComponentInsertSchema = DataComponentInsertSchema;
3318
+ exports.DataComponentListResponse = DataComponentListResponse;
3319
+ exports.DataComponentResponse = DataComponentResponse;
3320
+ exports.DataComponentSelectSchema = DataComponentSelectSchema;
3321
+ exports.DataComponentStreamEventSchema = DataComponentStreamEventSchema;
3322
+ exports.DataComponentUpdateSchema = DataComponentUpdateSchema;
3323
+ exports.DataOperationDetailsSchema = DataOperationDetailsSchema;
3324
+ exports.DataOperationEventSchema = DataOperationEventSchema;
3325
+ exports.DataOperationStreamEventSchema = DataOperationStreamEventSchema;
3326
+ exports.DataSummaryStreamEventSchema = DataSummaryStreamEventSchema;
3327
+ exports.DelegationReturnedDataSchema = DelegationReturnedDataSchema;
3328
+ exports.DelegationSentDataSchema = DelegationSentDataSchema;
3329
+ exports.ErrorResponseSchema = ErrorResponseSchema;
3330
+ exports.ExistsResponseSchema = ExistsResponseSchema;
3331
+ exports.ExternalAgentApiInsertSchema = ExternalAgentApiInsertSchema;
3332
+ exports.ExternalAgentApiSelectSchema = ExternalAgentApiSelectSchema;
3333
+ exports.ExternalAgentApiUpdateSchema = ExternalAgentApiUpdateSchema;
3334
+ exports.ExternalAgentInsertSchema = ExternalAgentInsertSchema;
3335
+ exports.ExternalAgentListResponse = ExternalAgentListResponse;
3336
+ exports.ExternalAgentResponse = ExternalAgentResponse;
3337
+ exports.ExternalAgentSelectSchema = ExternalAgentSelectSchema;
3338
+ exports.ExternalAgentUpdateSchema = ExternalAgentUpdateSchema;
3339
+ exports.ExternalSubAgentRelationApiInsertSchema = ExternalSubAgentRelationApiInsertSchema;
3340
+ exports.ExternalSubAgentRelationInsertSchema = ExternalSubAgentRelationInsertSchema;
3341
+ exports.FetchConfigSchema = FetchConfigSchema;
3342
+ exports.FetchDefinitionSchema = FetchDefinitionSchema;
3343
+ exports.FullAgentAgentInsertSchema = FullAgentAgentInsertSchema;
3344
+ exports.FullProjectDefinitionResponse = FullProjectDefinitionResponse;
3345
+ exports.FullProjectDefinitionSchema = FullProjectDefinitionSchema;
3346
+ exports.FunctionApiInsertSchema = FunctionApiInsertSchema;
3347
+ exports.FunctionApiSelectSchema = FunctionApiSelectSchema;
3348
+ exports.FunctionApiUpdateSchema = FunctionApiUpdateSchema;
3349
+ exports.FunctionInsertSchema = FunctionInsertSchema;
3350
+ exports.FunctionListResponse = FunctionListResponse;
3351
+ exports.FunctionResponse = FunctionResponse;
3352
+ exports.FunctionSelectSchema = FunctionSelectSchema;
3353
+ exports.FunctionToolApiInsertSchema = FunctionToolApiInsertSchema;
3354
+ exports.FunctionToolApiSelectSchema = FunctionToolApiSelectSchema;
3355
+ exports.FunctionToolApiUpdateSchema = FunctionToolApiUpdateSchema;
3356
+ exports.FunctionToolConfigSchema = FunctionToolConfigSchema;
3357
+ exports.FunctionToolInsertSchema = FunctionToolInsertSchema;
3358
+ exports.FunctionToolListResponse = FunctionToolListResponse;
3359
+ exports.FunctionToolResponse = FunctionToolResponse;
3360
+ exports.FunctionToolSelectSchema = FunctionToolSelectSchema;
3361
+ exports.FunctionToolUpdateSchema = FunctionToolUpdateSchema;
3362
+ exports.FunctionUpdateSchema = FunctionUpdateSchema;
3363
+ exports.HeadersScopeSchema = HeadersScopeSchema;
3364
+ exports.LedgerArtifactApiInsertSchema = LedgerArtifactApiInsertSchema;
3365
+ exports.LedgerArtifactApiSelectSchema = LedgerArtifactApiSelectSchema;
3366
+ exports.LedgerArtifactApiUpdateSchema = LedgerArtifactApiUpdateSchema;
3367
+ exports.LedgerArtifactInsertSchema = LedgerArtifactInsertSchema;
3368
+ exports.LedgerArtifactSelectSchema = LedgerArtifactSelectSchema;
3369
+ exports.LedgerArtifactUpdateSchema = LedgerArtifactUpdateSchema;
3370
+ exports.ListResponseSchema = ListResponseSchema;
3371
+ exports.MAX_ID_LENGTH = MAX_ID_LENGTH;
3372
+ exports.MCPCatalogListResponse = MCPCatalogListResponse;
3373
+ exports.MCPToolConfigSchema = MCPToolConfigSchema;
3374
+ exports.MIN_ID_LENGTH = MIN_ID_LENGTH;
3375
+ exports.McpToolDefinitionSchema = McpToolDefinitionSchema;
3376
+ exports.McpToolListResponse = McpToolListResponse;
3377
+ exports.McpToolResponse = McpToolResponse;
3378
+ exports.McpToolSchema = McpToolSchema;
3379
+ exports.McpTransportConfigSchema = McpTransportConfigSchema;
3380
+ exports.MessageApiInsertSchema = MessageApiInsertSchema;
3381
+ exports.MessageApiSelectSchema = MessageApiSelectSchema;
3382
+ exports.MessageApiUpdateSchema = MessageApiUpdateSchema;
3383
+ exports.MessageInsertSchema = MessageInsertSchema;
3384
+ exports.MessageListResponse = MessageListResponse;
3385
+ exports.MessageResponse = MessageResponse;
3386
+ exports.MessageSelectSchema = MessageSelectSchema;
3387
+ exports.MessageUpdateSchema = MessageUpdateSchema;
3388
+ exports.ModelSchema = ModelSchema;
3389
+ exports.ModelSettingsSchema = ModelSettingsSchema;
3390
+ exports.OAuthCallbackQuerySchema = OAuthCallbackQuerySchema;
3391
+ exports.OAuthLoginQuerySchema = OAuthLoginQuerySchema;
3392
+ exports.PaginationQueryParamsSchema = PaginationQueryParamsSchema;
3393
+ exports.PaginationSchema = PaginationSchema;
3394
+ exports.PrebuiltMCPServerSchema = PrebuiltMCPServerSchema;
3395
+ exports.ProjectApiInsertSchema = ProjectApiInsertSchema;
3396
+ exports.ProjectApiSelectSchema = ProjectApiSelectSchema;
3397
+ exports.ProjectApiUpdateSchema = ProjectApiUpdateSchema;
3398
+ exports.ProjectInsertSchema = ProjectInsertSchema;
3399
+ exports.ProjectListResponse = ProjectListResponse;
3400
+ exports.ProjectModelSchema = ProjectModelSchema;
3401
+ exports.ProjectResponse = ProjectResponse;
3402
+ exports.ProjectSelectSchema = ProjectSelectSchema;
3403
+ exports.ProjectUpdateSchema = ProjectUpdateSchema;
3404
+ exports.RelatedAgentInfoListResponse = RelatedAgentInfoListResponse;
3405
+ exports.RelatedAgentInfoSchema = RelatedAgentInfoSchema;
3406
+ exports.RemovedResponseSchema = RemovedResponseSchema;
3407
+ exports.SingleResponseSchema = SingleResponseSchema;
3408
+ exports.StatusComponentSchema = StatusComponentSchema;
3409
+ exports.StatusUpdateSchema = StatusUpdateSchema;
3410
+ exports.StopWhenSchema = StopWhenSchema;
3411
+ exports.StreamErrorEventSchema = StreamErrorEventSchema;
3412
+ exports.StreamEventSchema = StreamEventSchema;
3413
+ exports.StreamFinishEventSchema = StreamFinishEventSchema;
3414
+ exports.SubAgentApiInsertSchema = SubAgentApiInsertSchema;
3415
+ exports.SubAgentApiSelectSchema = SubAgentApiSelectSchema;
3416
+ exports.SubAgentApiUpdateSchema = SubAgentApiUpdateSchema;
3417
+ exports.SubAgentArtifactComponentApiInsertSchema = SubAgentArtifactComponentApiInsertSchema;
3418
+ exports.SubAgentArtifactComponentApiSelectSchema = SubAgentArtifactComponentApiSelectSchema;
3419
+ exports.SubAgentArtifactComponentApiUpdateSchema = SubAgentArtifactComponentApiUpdateSchema;
3420
+ exports.SubAgentArtifactComponentInsertSchema = SubAgentArtifactComponentInsertSchema;
3421
+ exports.SubAgentArtifactComponentListResponse = SubAgentArtifactComponentListResponse;
3422
+ exports.SubAgentArtifactComponentResponse = SubAgentArtifactComponentResponse;
3423
+ exports.SubAgentArtifactComponentSelectSchema = SubAgentArtifactComponentSelectSchema;
3424
+ exports.SubAgentArtifactComponentUpdateSchema = SubAgentArtifactComponentUpdateSchema;
3425
+ exports.SubAgentDataComponentApiInsertSchema = SubAgentDataComponentApiInsertSchema;
3426
+ exports.SubAgentDataComponentApiSelectSchema = SubAgentDataComponentApiSelectSchema;
3427
+ exports.SubAgentDataComponentApiUpdateSchema = SubAgentDataComponentApiUpdateSchema;
3428
+ exports.SubAgentDataComponentInsertSchema = SubAgentDataComponentInsertSchema;
3429
+ exports.SubAgentDataComponentListResponse = SubAgentDataComponentListResponse;
3430
+ exports.SubAgentDataComponentResponse = SubAgentDataComponentResponse;
3431
+ exports.SubAgentDataComponentSelectSchema = SubAgentDataComponentSelectSchema;
3432
+ exports.SubAgentDataComponentUpdateSchema = SubAgentDataComponentUpdateSchema;
3433
+ exports.SubAgentExternalAgentRelationApiInsertSchema = SubAgentExternalAgentRelationApiInsertSchema;
3434
+ exports.SubAgentExternalAgentRelationApiSelectSchema = SubAgentExternalAgentRelationApiSelectSchema;
3435
+ exports.SubAgentExternalAgentRelationApiUpdateSchema = SubAgentExternalAgentRelationApiUpdateSchema;
3436
+ exports.SubAgentExternalAgentRelationInsertSchema = SubAgentExternalAgentRelationInsertSchema;
3437
+ exports.SubAgentExternalAgentRelationListResponse = SubAgentExternalAgentRelationListResponse;
3438
+ exports.SubAgentExternalAgentRelationResponse = SubAgentExternalAgentRelationResponse;
3439
+ exports.SubAgentExternalAgentRelationSelectSchema = SubAgentExternalAgentRelationSelectSchema;
3440
+ exports.SubAgentExternalAgentRelationUpdateSchema = SubAgentExternalAgentRelationUpdateSchema;
3441
+ exports.SubAgentInsertSchema = SubAgentInsertSchema;
3442
+ exports.SubAgentListResponse = SubAgentListResponse;
3443
+ exports.SubAgentRelationApiInsertSchema = SubAgentRelationApiInsertSchema;
3444
+ exports.SubAgentRelationApiSelectSchema = SubAgentRelationApiSelectSchema;
3445
+ exports.SubAgentRelationApiUpdateSchema = SubAgentRelationApiUpdateSchema;
3446
+ exports.SubAgentRelationInsertSchema = SubAgentRelationInsertSchema;
3447
+ exports.SubAgentRelationListResponse = SubAgentRelationListResponse;
3448
+ exports.SubAgentRelationQuerySchema = SubAgentRelationQuerySchema;
3449
+ exports.SubAgentRelationResponse = SubAgentRelationResponse;
3450
+ exports.SubAgentRelationSelectSchema = SubAgentRelationSelectSchema;
3451
+ exports.SubAgentRelationUpdateSchema = SubAgentRelationUpdateSchema;
3452
+ exports.SubAgentResponse = SubAgentResponse;
3453
+ exports.SubAgentSelectSchema = SubAgentSelectSchema;
3454
+ exports.SubAgentStopWhenSchema = SubAgentStopWhenSchema;
3455
+ exports.SubAgentTeamAgentRelationApiInsertSchema = SubAgentTeamAgentRelationApiInsertSchema;
3456
+ exports.SubAgentTeamAgentRelationApiSelectSchema = SubAgentTeamAgentRelationApiSelectSchema;
3457
+ exports.SubAgentTeamAgentRelationApiUpdateSchema = SubAgentTeamAgentRelationApiUpdateSchema;
3458
+ exports.SubAgentTeamAgentRelationInsertSchema = SubAgentTeamAgentRelationInsertSchema;
3459
+ exports.SubAgentTeamAgentRelationListResponse = SubAgentTeamAgentRelationListResponse;
3460
+ exports.SubAgentTeamAgentRelationResponse = SubAgentTeamAgentRelationResponse;
3461
+ exports.SubAgentTeamAgentRelationSelectSchema = SubAgentTeamAgentRelationSelectSchema;
3462
+ exports.SubAgentTeamAgentRelationUpdateSchema = SubAgentTeamAgentRelationUpdateSchema;
3463
+ exports.SubAgentToolRelationApiInsertSchema = SubAgentToolRelationApiInsertSchema;
3464
+ exports.SubAgentToolRelationApiSelectSchema = SubAgentToolRelationApiSelectSchema;
3465
+ exports.SubAgentToolRelationApiUpdateSchema = SubAgentToolRelationApiUpdateSchema;
3466
+ exports.SubAgentToolRelationInsertSchema = SubAgentToolRelationInsertSchema;
3467
+ exports.SubAgentToolRelationListResponse = SubAgentToolRelationListResponse;
3468
+ exports.SubAgentToolRelationResponse = SubAgentToolRelationResponse;
3469
+ exports.SubAgentToolRelationSelectSchema = SubAgentToolRelationSelectSchema;
3470
+ exports.SubAgentToolRelationUpdateSchema = SubAgentToolRelationUpdateSchema;
3471
+ exports.SubAgentUpdateSchema = SubAgentUpdateSchema;
3472
+ exports.TaskApiInsertSchema = TaskApiInsertSchema;
3473
+ exports.TaskApiSelectSchema = TaskApiSelectSchema;
3474
+ exports.TaskApiUpdateSchema = TaskApiUpdateSchema;
3475
+ exports.TaskInsertSchema = TaskInsertSchema;
3476
+ exports.TaskRelationApiInsertSchema = TaskRelationApiInsertSchema;
3477
+ exports.TaskRelationApiSelectSchema = TaskRelationApiSelectSchema;
3478
+ exports.TaskRelationApiUpdateSchema = TaskRelationApiUpdateSchema;
3479
+ exports.TaskRelationInsertSchema = TaskRelationInsertSchema;
3480
+ exports.TaskRelationSelectSchema = TaskRelationSelectSchema;
3481
+ exports.TaskRelationUpdateSchema = TaskRelationUpdateSchema;
3482
+ exports.TaskSelectSchema = TaskSelectSchema;
3483
+ exports.TaskUpdateSchema = TaskUpdateSchema;
3484
+ exports.TeamAgentSchema = TeamAgentSchema;
3485
+ exports.TenantIdParamsSchema = TenantIdParamsSchema;
3486
+ exports.TenantParamsSchema = TenantParamsSchema;
3487
+ exports.TenantProjectAgentIdParamsSchema = TenantProjectAgentIdParamsSchema;
3488
+ exports.TenantProjectAgentParamsSchema = TenantProjectAgentParamsSchema;
3489
+ exports.TenantProjectAgentSubAgentIdParamsSchema = TenantProjectAgentSubAgentIdParamsSchema;
3490
+ exports.TenantProjectAgentSubAgentParamsSchema = TenantProjectAgentSubAgentParamsSchema;
3491
+ exports.TenantProjectIdParamsSchema = TenantProjectIdParamsSchema;
3492
+ exports.TenantProjectParamsSchema = TenantProjectParamsSchema;
3493
+ exports.TextDeltaEventSchema = TextDeltaEventSchema;
3494
+ exports.TextEndEventSchema = TextEndEventSchema;
3495
+ exports.TextStartEventSchema = TextStartEventSchema;
3496
+ exports.ThirdPartyMCPServerResponse = ThirdPartyMCPServerResponse;
3497
+ exports.ToolApiInsertSchema = ToolApiInsertSchema;
3498
+ exports.ToolApiSelectSchema = ToolApiSelectSchema;
3499
+ exports.ToolApiUpdateSchema = ToolApiUpdateSchema;
3500
+ exports.ToolInsertSchema = ToolInsertSchema;
3501
+ exports.ToolListResponse = ToolListResponse;
3502
+ exports.ToolResponse = ToolResponse;
3503
+ exports.ToolSelectSchema = ToolSelectSchema;
3504
+ exports.ToolStatusSchema = ToolStatusSchema;
3505
+ exports.ToolUpdateSchema = ToolUpdateSchema;
3506
+ exports.TransferDataSchema = TransferDataSchema;
3507
+ exports.URL_SAFE_ID_PATTERN = URL_SAFE_ID_PATTERN;
3508
+ exports.canDelegateToExternalAgentSchema = canDelegateToExternalAgentSchema;
3509
+ exports.canDelegateToTeamAgentSchema = canDelegateToTeamAgentSchema;
3510
+ exports.generateIdFromName = generateIdFromName;
3511
+ exports.isValidResourceId = isValidResourceId;
3512
+ exports.resourceIdSchema = resourceIdSchema;
3513
+ exports.validateAgentRelationships = validateAgentRelationships;
3514
+ exports.validateAgentStructure = validateAgentStructure;
3515
+ exports.validateAndTypeAgentData = validateAndTypeAgentData;
3516
+ exports.validateArtifactComponentReferences = validateArtifactComponentReferences;
3517
+ exports.validateDataComponentReferences = validateDataComponentReferences;
3518
+ exports.validatePropsAsJsonSchema = validatePropsAsJsonSchema;
3519
+ exports.validateRender = validateRender;
3520
+ exports.validateSubAgentExternalAgentRelations = validateSubAgentExternalAgentRelations;
3521
+ exports.validateToolReferences = validateToolReferences;