@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,1689 @@
1
+ import { __export } from './chunk-E6R6PML7.js';
2
+ import { relations } from 'drizzle-orm';
3
+ import { pgTable, varchar, text, timestamp, jsonb, primaryKey, foreignKey, integer, index, unique, boolean, doublePrecision } from 'drizzle-orm/pg-core';
4
+
5
+ // src/db/schema.ts
6
+ var schema_exports = {};
7
+ __export(schema_exports, {
8
+ agentRelations: () => agentRelations,
9
+ agentToolRelationsRelations: () => agentToolRelationsRelations,
10
+ agents: () => agents,
11
+ apiKeys: () => apiKeys,
12
+ apiKeysRelations: () => apiKeysRelations,
13
+ artifactComponents: () => artifactComponents,
14
+ artifactComponentsRelations: () => artifactComponentsRelations,
15
+ contextCache: () => contextCache,
16
+ contextCacheRelations: () => contextCacheRelations,
17
+ contextConfigs: () => contextConfigs,
18
+ contextConfigsRelations: () => contextConfigsRelations,
19
+ conversations: () => conversations,
20
+ conversationsEvaluatorRelations: () => conversationsEvaluatorRelations,
21
+ conversationsRelations: () => conversationsRelations,
22
+ credentialReferences: () => credentialReferences,
23
+ credentialReferencesRelations: () => credentialReferencesRelations,
24
+ dataComponents: () => dataComponents,
25
+ dataComponentsRelations: () => dataComponentsRelations,
26
+ dataset: () => dataset,
27
+ datasetItem: () => datasetItem,
28
+ datasetItemRelations: () => datasetItemRelations,
29
+ datasetRelations: () => datasetRelations,
30
+ datasetRun: () => datasetRun,
31
+ datasetRunConfig: () => datasetRunConfig,
32
+ datasetRunConfigAgentRelations: () => datasetRunConfigAgentRelations,
33
+ datasetRunConfigAgentRelationsRelations: () => datasetRunConfigAgentRelationsRelations,
34
+ datasetRunConfigEvaluationRunConfigRelations: () => datasetRunConfigEvaluationRunConfigRelations,
35
+ datasetRunConfigEvaluationRunConfigRelationsRelations: () => datasetRunConfigEvaluationRunConfigRelationsRelations,
36
+ datasetRunConfigRelations: () => datasetRunConfigRelations,
37
+ datasetRunConversationRelations: () => datasetRunConversationRelations,
38
+ datasetRunConversationRelationsRelations: () => datasetRunConversationRelationsRelations,
39
+ datasetRunRelations: () => datasetRunRelations,
40
+ evaluationJobConfig: () => evaluationJobConfig,
41
+ evaluationJobConfigEvaluatorRelations: () => evaluationJobConfigEvaluatorRelations,
42
+ evaluationJobConfigEvaluatorRelationsRelations: () => evaluationJobConfigEvaluatorRelationsRelations,
43
+ evaluationJobConfigRelations: () => evaluationJobConfigRelations,
44
+ evaluationResult: () => evaluationResult,
45
+ evaluationResultRelations: () => evaluationResultRelations,
46
+ evaluationRun: () => evaluationRun,
47
+ evaluationRunConfig: () => evaluationRunConfig,
48
+ evaluationRunConfigEvaluationSuiteConfigRelations: () => evaluationRunConfigEvaluationSuiteConfigRelations,
49
+ evaluationRunConfigEvaluationSuiteConfigRelationsRelations: () => evaluationRunConfigEvaluationSuiteConfigRelationsRelations,
50
+ evaluationRunConfigRelations: () => evaluationRunConfigRelations,
51
+ evaluationRunRelations: () => evaluationRunRelations,
52
+ evaluationSuiteConfig: () => evaluationSuiteConfig,
53
+ evaluationSuiteConfigEvaluatorRelations: () => evaluationSuiteConfigEvaluatorRelations,
54
+ evaluationSuiteConfigEvaluatorRelationsRelations: () => evaluationSuiteConfigEvaluatorRelationsRelations,
55
+ evaluationSuiteConfigRelations: () => evaluationSuiteConfigRelations,
56
+ evaluator: () => evaluator,
57
+ evaluatorRelations: () => evaluatorRelations,
58
+ externalAgents: () => externalAgents,
59
+ externalAgentsRelations: () => externalAgentsRelations,
60
+ functionTools: () => functionTools,
61
+ functionToolsRelations: () => functionToolsRelations,
62
+ functions: () => functions,
63
+ functionsRelations: () => functionsRelations,
64
+ ledgerArtifacts: () => ledgerArtifacts,
65
+ ledgerArtifactsRelations: () => ledgerArtifactsRelations,
66
+ messages: () => messages,
67
+ messagesRelations: () => messagesRelations,
68
+ projects: () => projects,
69
+ projectsRelations: () => projectsRelations,
70
+ subAgentArtifactComponents: () => subAgentArtifactComponents,
71
+ subAgentArtifactComponentsRelations: () => subAgentArtifactComponentsRelations,
72
+ subAgentDataComponents: () => subAgentDataComponents,
73
+ subAgentDataComponentsRelations: () => subAgentDataComponentsRelations,
74
+ subAgentExternalAgentRelations: () => subAgentExternalAgentRelations,
75
+ subAgentExternalAgentRelationsRelations: () => subAgentExternalAgentRelationsRelations,
76
+ subAgentFunctionToolRelations: () => subAgentFunctionToolRelations,
77
+ subAgentFunctionToolRelationsRelations: () => subAgentFunctionToolRelationsRelations,
78
+ subAgentRelations: () => subAgentRelations,
79
+ subAgentRelationsRelations: () => subAgentRelationsRelations,
80
+ subAgentTeamAgentRelations: () => subAgentTeamAgentRelations,
81
+ subAgentTeamAgentRelationsRelations: () => subAgentTeamAgentRelationsRelations,
82
+ subAgentToolRelations: () => subAgentToolRelations,
83
+ subAgents: () => subAgents,
84
+ subAgentsRelations: () => subAgentsRelations,
85
+ taskRelations: () => taskRelations,
86
+ taskRelationsRelations: () => taskRelationsRelations,
87
+ tasks: () => tasks,
88
+ tasksRelations: () => tasksRelations,
89
+ tools: () => tools,
90
+ toolsRelations: () => toolsRelations
91
+ });
92
+ var tenantScoped = {
93
+ tenantId: varchar("tenant_id", { length: 256 }).notNull(),
94
+ id: varchar("id", { length: 256 }).notNull()
95
+ };
96
+ var projectScoped = {
97
+ ...tenantScoped,
98
+ projectId: varchar("project_id", { length: 256 }).notNull()
99
+ };
100
+ var agentScoped = {
101
+ ...projectScoped,
102
+ agentId: varchar("agent_id", { length: 256 }).notNull()
103
+ };
104
+ var subAgentScoped = {
105
+ ...agentScoped,
106
+ subAgentId: varchar("sub_agent_id", { length: 256 }).notNull()
107
+ };
108
+ var uiProperties = {
109
+ name: varchar("name", { length: 256 }).notNull(),
110
+ description: text("description").notNull()
111
+ };
112
+ var timestamps = {
113
+ createdAt: timestamp("created_at", { mode: "string" }).notNull().defaultNow(),
114
+ updatedAt: timestamp("updated_at", { mode: "string" }).notNull().defaultNow()
115
+ };
116
+ var projects = pgTable(
117
+ "projects",
118
+ {
119
+ ...tenantScoped,
120
+ ...uiProperties,
121
+ models: jsonb("models").$type(),
122
+ stopWhen: jsonb("stop_when").$type(),
123
+ ...timestamps
124
+ },
125
+ (table) => [primaryKey({ columns: [table.tenantId, table.id] })]
126
+ );
127
+ var agents = pgTable(
128
+ "agent",
129
+ {
130
+ ...projectScoped,
131
+ name: varchar("name", { length: 256 }).notNull(),
132
+ description: text("description"),
133
+ defaultSubAgentId: varchar("default_sub_agent_id", { length: 256 }),
134
+ contextConfigId: varchar("context_config_id", { length: 256 }),
135
+ models: jsonb("models").$type(),
136
+ statusUpdates: jsonb("status_updates").$type(),
137
+ prompt: text("prompt"),
138
+ stopWhen: jsonb("stop_when").$type(),
139
+ ...timestamps
140
+ },
141
+ (table) => [
142
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
143
+ foreignKey({
144
+ columns: [table.tenantId, table.projectId],
145
+ foreignColumns: [projects.tenantId, projects.id],
146
+ name: "agent_project_fk"
147
+ }).onDelete("cascade")
148
+ ]
149
+ );
150
+ var contextConfigs = pgTable(
151
+ "context_configs",
152
+ {
153
+ ...agentScoped,
154
+ headersSchema: jsonb("headers_schema").$type(),
155
+ contextVariables: jsonb("context_variables").$type(),
156
+ ...timestamps
157
+ },
158
+ (table) => [
159
+ primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
160
+ foreignKey({
161
+ columns: [table.tenantId, table.projectId, table.agentId],
162
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
163
+ name: "context_configs_agent_fk"
164
+ }).onDelete("cascade")
165
+ ]
166
+ );
167
+ var contextCache = pgTable(
168
+ "context_cache",
169
+ {
170
+ ...projectScoped,
171
+ conversationId: varchar("conversation_id", { length: 256 }).notNull(),
172
+ contextConfigId: varchar("context_config_id", { length: 256 }).notNull(),
173
+ contextVariableKey: varchar("context_variable_key", { length: 256 }).notNull(),
174
+ value: jsonb("value").$type().notNull(),
175
+ requestHash: varchar("request_hash", { length: 256 }),
176
+ fetchedAt: timestamp("fetched_at", { mode: "string" }).notNull().defaultNow(),
177
+ fetchSource: varchar("fetch_source", { length: 256 }),
178
+ fetchDurationMs: integer("fetch_duration_ms"),
179
+ ...timestamps
180
+ },
181
+ (table) => [
182
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
183
+ foreignKey({
184
+ columns: [table.tenantId, table.projectId],
185
+ foreignColumns: [projects.tenantId, projects.id],
186
+ name: "context_cache_project_fk"
187
+ }).onDelete("cascade"),
188
+ index("context_cache_lookup_idx").on(
189
+ table.conversationId,
190
+ table.contextConfigId,
191
+ table.contextVariableKey
192
+ )
193
+ ]
194
+ );
195
+ var subAgents = pgTable(
196
+ "sub_agents",
197
+ {
198
+ ...agentScoped,
199
+ ...uiProperties,
200
+ prompt: text("prompt").notNull(),
201
+ conversationHistoryConfig: jsonb("conversation_history_config").$type().default({
202
+ mode: "full",
203
+ limit: 50,
204
+ maxOutputTokens: 4e3,
205
+ includeInternal: false,
206
+ messageTypes: ["chat", "tool-result"]
207
+ }),
208
+ models: jsonb("models").$type(),
209
+ stopWhen: jsonb("stop_when").$type(),
210
+ ...timestamps
211
+ },
212
+ (table) => [
213
+ primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
214
+ foreignKey({
215
+ columns: [table.tenantId, table.projectId, table.agentId],
216
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
217
+ name: "sub_agents_agents_fk"
218
+ }).onDelete("cascade")
219
+ ]
220
+ );
221
+ var subAgentRelations = pgTable(
222
+ "sub_agent_relations",
223
+ {
224
+ ...agentScoped,
225
+ sourceSubAgentId: varchar("source_sub_agent_id", { length: 256 }).notNull(),
226
+ targetSubAgentId: varchar("target_sub_agent_id", { length: 256 }),
227
+ relationType: varchar("relation_type", { length: 256 }),
228
+ ...timestamps
229
+ },
230
+ (table) => [
231
+ primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
232
+ foreignKey({
233
+ columns: [table.tenantId, table.projectId, table.agentId],
234
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
235
+ name: "sub_agent_relations_agent_fk"
236
+ }).onDelete("cascade")
237
+ ]
238
+ );
239
+ var externalAgents = pgTable(
240
+ "external_agents",
241
+ {
242
+ ...projectScoped,
243
+ ...uiProperties,
244
+ baseUrl: text("base_url").notNull(),
245
+ credentialReferenceId: varchar("credential_reference_id", { length: 256 }),
246
+ ...timestamps
247
+ },
248
+ (table) => [
249
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
250
+ foreignKey({
251
+ columns: [table.tenantId, table.projectId],
252
+ foreignColumns: [projects.tenantId, projects.id],
253
+ name: "external_agents_project_fk"
254
+ }).onDelete("cascade"),
255
+ foreignKey({
256
+ columns: [table.tenantId, table.projectId, table.credentialReferenceId],
257
+ foreignColumns: [
258
+ credentialReferences.tenantId,
259
+ credentialReferences.projectId,
260
+ credentialReferences.id
261
+ ],
262
+ name: "external_agents_credential_reference_fk"
263
+ }).onDelete("cascade")
264
+ ]
265
+ );
266
+ var tasks = pgTable(
267
+ "tasks",
268
+ {
269
+ ...subAgentScoped,
270
+ contextId: varchar("context_id", { length: 256 }).notNull(),
271
+ status: varchar("status", { length: 256 }).notNull(),
272
+ metadata: jsonb("metadata").$type(),
273
+ ...timestamps
274
+ },
275
+ (table) => [
276
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
277
+ foreignKey({
278
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
279
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
280
+ name: "tasks_sub_agent_fk"
281
+ }).onDelete("cascade")
282
+ ]
283
+ );
284
+ var taskRelations = pgTable(
285
+ "task_relations",
286
+ {
287
+ ...projectScoped,
288
+ parentTaskId: varchar("parent_task_id", { length: 256 }).notNull(),
289
+ childTaskId: varchar("child_task_id", { length: 256 }).notNull(),
290
+ relationType: varchar("relation_type", { length: 256 }).default("parent_child"),
291
+ ...timestamps
292
+ },
293
+ (table) => [
294
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
295
+ foreignKey({
296
+ columns: [table.tenantId, table.projectId],
297
+ foreignColumns: [projects.tenantId, projects.id],
298
+ name: "task_relations_project_fk"
299
+ }).onDelete("cascade")
300
+ ]
301
+ );
302
+ var dataComponents = pgTable(
303
+ "data_components",
304
+ {
305
+ ...projectScoped,
306
+ ...uiProperties,
307
+ props: jsonb("props").$type(),
308
+ render: jsonb("render").$type(),
309
+ ...timestamps
310
+ },
311
+ (table) => [
312
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
313
+ foreignKey({
314
+ columns: [table.tenantId, table.projectId],
315
+ foreignColumns: [projects.tenantId, projects.id],
316
+ name: "data_components_project_fk"
317
+ }).onDelete("cascade")
318
+ ]
319
+ );
320
+ var subAgentDataComponents = pgTable(
321
+ "sub_agent_data_components",
322
+ {
323
+ ...subAgentScoped,
324
+ dataComponentId: varchar("data_component_id", { length: 256 }).notNull(),
325
+ createdAt: timestamp("created_at", { mode: "string" }).notNull().defaultNow()
326
+ },
327
+ (table) => [
328
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
329
+ foreignKey({
330
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
331
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
332
+ name: "sub_agent_data_components_sub_agent_fk"
333
+ }).onDelete("cascade"),
334
+ foreignKey({
335
+ columns: [table.tenantId, table.projectId, table.dataComponentId],
336
+ foreignColumns: [dataComponents.tenantId, dataComponents.projectId, dataComponents.id],
337
+ name: "sub_agent_data_components_data_component_fk"
338
+ }).onDelete("cascade")
339
+ ]
340
+ );
341
+ var artifactComponents = pgTable(
342
+ "artifact_components",
343
+ {
344
+ ...projectScoped,
345
+ ...uiProperties,
346
+ props: jsonb("props").$type(),
347
+ ...timestamps
348
+ },
349
+ (table) => [
350
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
351
+ foreignKey({
352
+ columns: [table.tenantId, table.projectId],
353
+ foreignColumns: [projects.tenantId, projects.id],
354
+ name: "artifact_components_project_fk"
355
+ }).onDelete("cascade")
356
+ ]
357
+ );
358
+ var subAgentArtifactComponents = pgTable(
359
+ "sub_agent_artifact_components",
360
+ {
361
+ ...subAgentScoped,
362
+ artifactComponentId: varchar("artifact_component_id", { length: 256 }).notNull(),
363
+ createdAt: timestamp("created_at", { mode: "string" }).notNull().defaultNow()
364
+ },
365
+ (table) => [
366
+ primaryKey({
367
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId, table.id]
368
+ }),
369
+ foreignKey({
370
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
371
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
372
+ name: "sub_agent_artifact_components_sub_agent_fk"
373
+ }).onDelete("cascade"),
374
+ foreignKey({
375
+ columns: [table.tenantId, table.projectId, table.artifactComponentId],
376
+ foreignColumns: [
377
+ artifactComponents.tenantId,
378
+ artifactComponents.projectId,
379
+ artifactComponents.id
380
+ ],
381
+ name: "sub_agent_artifact_components_artifact_component_fk"
382
+ }).onDelete("cascade")
383
+ ]
384
+ );
385
+ var tools = pgTable(
386
+ "tools",
387
+ {
388
+ ...projectScoped,
389
+ name: varchar("name", { length: 256 }).notNull(),
390
+ description: text("description"),
391
+ config: jsonb("config").$type().notNull(),
392
+ credentialReferenceId: varchar("credential_reference_id", { length: 256 }),
393
+ headers: jsonb("headers").$type(),
394
+ imageUrl: text("image_url"),
395
+ capabilities: jsonb("capabilities").$type(),
396
+ lastError: text("last_error"),
397
+ ...timestamps
398
+ },
399
+ (table) => [
400
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
401
+ foreignKey({
402
+ columns: [table.tenantId, table.projectId],
403
+ foreignColumns: [projects.tenantId, projects.id],
404
+ name: "tools_project_fk"
405
+ }).onDelete("cascade")
406
+ ]
407
+ );
408
+ var functionTools = pgTable(
409
+ "function_tools",
410
+ {
411
+ ...agentScoped,
412
+ name: varchar("name", { length: 256 }).notNull(),
413
+ description: text("description"),
414
+ functionId: varchar("function_id", { length: 256 }).notNull(),
415
+ ...timestamps
416
+ },
417
+ (table) => [
418
+ primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
419
+ foreignKey({
420
+ columns: [table.tenantId, table.projectId, table.agentId],
421
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
422
+ name: "function_tools_agent_fk"
423
+ }).onDelete("cascade"),
424
+ foreignKey({
425
+ columns: [table.tenantId, table.projectId, table.functionId],
426
+ foreignColumns: [functions.tenantId, functions.projectId, functions.id],
427
+ name: "function_tools_function_fk"
428
+ }).onDelete("cascade")
429
+ ]
430
+ );
431
+ var functions = pgTable(
432
+ "functions",
433
+ {
434
+ ...projectScoped,
435
+ inputSchema: jsonb("input_schema").$type(),
436
+ executeCode: text("execute_code").notNull(),
437
+ dependencies: jsonb("dependencies").$type(),
438
+ ...timestamps
439
+ },
440
+ (table) => [
441
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
442
+ foreignKey({
443
+ columns: [table.tenantId, table.projectId],
444
+ foreignColumns: [projects.tenantId, projects.id],
445
+ name: "functions_project_fk"
446
+ }).onDelete("cascade")
447
+ ]
448
+ );
449
+ var subAgentToolRelations = pgTable(
450
+ "sub_agent_tool_relations",
451
+ {
452
+ ...subAgentScoped,
453
+ toolId: varchar("tool_id", { length: 256 }).notNull(),
454
+ selectedTools: jsonb("selected_tools").$type(),
455
+ headers: jsonb("headers").$type(),
456
+ toolPolicies: jsonb("tool_policies").$type(),
457
+ ...timestamps
458
+ },
459
+ (table) => [
460
+ primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
461
+ foreignKey({
462
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
463
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
464
+ name: "sub_agent_tool_relations_agent_fk"
465
+ }).onDelete("cascade"),
466
+ foreignKey({
467
+ columns: [table.tenantId, table.projectId, table.toolId],
468
+ foreignColumns: [tools.tenantId, tools.projectId, tools.id],
469
+ name: "sub_agent_tool_relations_tool_fk"
470
+ }).onDelete("cascade")
471
+ ]
472
+ );
473
+ var subAgentExternalAgentRelations = pgTable(
474
+ "sub_agent_external_agent_relations",
475
+ {
476
+ ...subAgentScoped,
477
+ externalAgentId: varchar("external_agent_id", { length: 256 }).notNull(),
478
+ headers: jsonb("headers").$type(),
479
+ ...timestamps
480
+ },
481
+ (table) => [
482
+ primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
483
+ foreignKey({
484
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
485
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
486
+ name: "sub_agent_external_agent_relations_sub_agent_fk"
487
+ }).onDelete("cascade"),
488
+ foreignKey({
489
+ columns: [table.tenantId, table.projectId, table.externalAgentId],
490
+ foreignColumns: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
491
+ name: "sub_agent_external_agent_relations_external_agent_fk"
492
+ }).onDelete("cascade")
493
+ ]
494
+ );
495
+ var subAgentTeamAgentRelations = pgTable(
496
+ "sub_agent_team_agent_relations",
497
+ {
498
+ ...subAgentScoped,
499
+ targetAgentId: varchar("target_agent_id", { length: 256 }).notNull(),
500
+ headers: jsonb("headers").$type(),
501
+ ...timestamps
502
+ },
503
+ (table) => [
504
+ primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
505
+ foreignKey({
506
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
507
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
508
+ name: "sub_agent_team_agent_relations_sub_agent_fk"
509
+ }).onDelete("cascade"),
510
+ foreignKey({
511
+ columns: [table.tenantId, table.projectId, table.targetAgentId],
512
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
513
+ name: "sub_agent_team_agent_relations_target_agent_fk"
514
+ }).onDelete("cascade")
515
+ ]
516
+ );
517
+ var subAgentFunctionToolRelations = pgTable(
518
+ "sub_agent_function_tool_relations",
519
+ {
520
+ ...subAgentScoped,
521
+ functionToolId: varchar("function_tool_id", { length: 256 }).notNull(),
522
+ ...timestamps
523
+ },
524
+ (table) => [
525
+ primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
526
+ foreignKey({
527
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
528
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
529
+ name: "sub_agent_function_tool_relations_sub_agent_fk"
530
+ }).onDelete("cascade"),
531
+ foreignKey({
532
+ columns: [table.tenantId, table.projectId, table.agentId, table.functionToolId],
533
+ foreignColumns: [
534
+ functionTools.tenantId,
535
+ functionTools.projectId,
536
+ functionTools.agentId,
537
+ functionTools.id
538
+ ],
539
+ name: "sub_agent_function_tool_relations_function_tool_fk"
540
+ }).onDelete("cascade")
541
+ ]
542
+ );
543
+ var conversations = pgTable(
544
+ "conversations",
545
+ {
546
+ ...projectScoped,
547
+ userId: varchar("user_id", { length: 256 }),
548
+ activeSubAgentId: varchar("active_sub_agent_id", { length: 256 }).notNull(),
549
+ title: text("title"),
550
+ lastContextResolution: timestamp("last_context_resolution", { mode: "string" }),
551
+ metadata: jsonb("metadata").$type(),
552
+ ...timestamps
553
+ },
554
+ (table) => [
555
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
556
+ foreignKey({
557
+ columns: [table.tenantId, table.projectId],
558
+ foreignColumns: [projects.tenantId, projects.id],
559
+ name: "conversations_project_fk"
560
+ }).onDelete("cascade")
561
+ ]
562
+ );
563
+ var messages = pgTable(
564
+ "messages",
565
+ {
566
+ ...projectScoped,
567
+ conversationId: varchar("conversation_id", { length: 256 }).notNull(),
568
+ role: varchar("role", { length: 256 }).notNull(),
569
+ fromSubAgentId: varchar("from_sub_agent_id", { length: 256 }),
570
+ toSubAgentId: varchar("to_sub_agent_id", { length: 256 }),
571
+ fromExternalAgentId: varchar("from_external_sub_agent_id", { length: 256 }),
572
+ toExternalAgentId: varchar("to_external_sub_agent_id", { length: 256 }),
573
+ fromTeamAgentId: varchar("from_team_agent_id", { length: 256 }),
574
+ toTeamAgentId: varchar("to_team_agent_id", { length: 256 }),
575
+ content: jsonb("content").$type().notNull(),
576
+ visibility: varchar("visibility", { length: 256 }).notNull().default("user-facing"),
577
+ messageType: varchar("message_type", { length: 256 }).notNull().default("chat"),
578
+ taskId: varchar("task_id", { length: 256 }),
579
+ parentMessageId: varchar("parent_message_id", { length: 256 }),
580
+ a2aTaskId: varchar("a2a_task_id", { length: 256 }),
581
+ a2aSessionId: varchar("a2a_session_id", { length: 256 }),
582
+ metadata: jsonb("metadata").$type(),
583
+ ...timestamps
584
+ },
585
+ (table) => [
586
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
587
+ foreignKey({
588
+ columns: [table.tenantId, table.projectId],
589
+ foreignColumns: [projects.tenantId, projects.id],
590
+ name: "messages_project_fk"
591
+ }).onDelete("cascade")
592
+ ]
593
+ );
594
+ var ledgerArtifacts = pgTable(
595
+ "ledger_artifacts",
596
+ {
597
+ ...projectScoped,
598
+ taskId: varchar("task_id", { length: 256 }).notNull(),
599
+ toolCallId: varchar("tool_call_id", { length: 256 }),
600
+ contextId: varchar("context_id", { length: 256 }).notNull(),
601
+ type: varchar("type", { length: 256 }).notNull().default("source"),
602
+ name: varchar("name", { length: 256 }),
603
+ description: text("description"),
604
+ parts: jsonb("parts").$type(),
605
+ metadata: jsonb("metadata").$type(),
606
+ summary: text("summary"),
607
+ mime: jsonb("mime").$type(),
608
+ visibility: varchar("visibility", { length: 256 }).default("context"),
609
+ allowedAgents: jsonb("allowed_agents").$type(),
610
+ derivedFrom: varchar("derived_from", { length: 256 }),
611
+ ...timestamps
612
+ },
613
+ (table) => [
614
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id, table.taskId] }),
615
+ foreignKey({
616
+ columns: [table.tenantId, table.projectId],
617
+ foreignColumns: [projects.tenantId, projects.id],
618
+ name: "ledger_artifacts_project_fk"
619
+ }).onDelete("cascade"),
620
+ index("ledger_artifacts_task_id_idx").on(table.taskId),
621
+ index("ledger_artifacts_tool_call_id_idx").on(table.toolCallId),
622
+ index("ledger_artifacts_context_id_idx").on(table.contextId),
623
+ unique("ledger_artifacts_task_context_name_unique").on(
624
+ table.taskId,
625
+ table.contextId,
626
+ table.name
627
+ )
628
+ ]
629
+ );
630
+ var apiKeys = pgTable(
631
+ "api_keys",
632
+ {
633
+ ...agentScoped,
634
+ publicId: varchar("public_id", { length: 256 }).notNull().unique(),
635
+ keyHash: varchar("key_hash", { length: 256 }).notNull(),
636
+ keyPrefix: varchar("key_prefix", { length: 256 }).notNull(),
637
+ name: varchar("name", { length: 256 }),
638
+ lastUsedAt: timestamp("last_used_at", { mode: "string" }),
639
+ expiresAt: timestamp("expires_at", { mode: "string" }),
640
+ ...timestamps
641
+ },
642
+ (t) => [
643
+ foreignKey({
644
+ columns: [t.tenantId, t.projectId],
645
+ foreignColumns: [projects.tenantId, projects.id],
646
+ name: "api_keys_project_fk"
647
+ }).onDelete("cascade"),
648
+ foreignKey({
649
+ columns: [t.tenantId, t.projectId, t.agentId],
650
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
651
+ name: "api_keys_agent_fk"
652
+ }).onDelete("cascade"),
653
+ index("api_keys_tenant_agent_idx").on(t.tenantId, t.agentId),
654
+ index("api_keys_prefix_idx").on(t.keyPrefix),
655
+ index("api_keys_public_id_idx").on(t.publicId)
656
+ ]
657
+ );
658
+ var credentialReferences = pgTable(
659
+ "credential_references",
660
+ {
661
+ ...projectScoped,
662
+ name: varchar("name", { length: 256 }).notNull(),
663
+ type: varchar("type", { length: 256 }).notNull(),
664
+ credentialStoreId: varchar("credential_store_id", { length: 256 }).notNull(),
665
+ retrievalParams: jsonb("retrieval_params").$type(),
666
+ ...timestamps
667
+ },
668
+ (t) => [
669
+ primaryKey({ columns: [t.tenantId, t.projectId, t.id] }),
670
+ foreignKey({
671
+ columns: [t.tenantId, t.projectId],
672
+ foreignColumns: [projects.tenantId, projects.id],
673
+ name: "credential_references_project_fk"
674
+ }).onDelete("cascade")
675
+ ]
676
+ );
677
+ var dataset = pgTable(
678
+ "dataset",
679
+ {
680
+ ...projectScoped,
681
+ ...uiProperties,
682
+ ...timestamps
683
+ },
684
+ (table) => [
685
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
686
+ foreignKey({
687
+ columns: [table.tenantId, table.projectId],
688
+ foreignColumns: [projects.tenantId, projects.id],
689
+ name: "dataset_project_fk"
690
+ }).onDelete("cascade")
691
+ ]
692
+ );
693
+ var datasetItem = pgTable(
694
+ "dataset_item",
695
+ {
696
+ ...projectScoped,
697
+ datasetId: text("dataset_id").notNull(),
698
+ input: jsonb("input").$type().notNull(),
699
+ expectedOutput: jsonb("expected_output").$type(),
700
+ simulationAgent: jsonb("simulation_agent").$type(),
701
+ ...timestamps
702
+ },
703
+ (table) => [
704
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
705
+ foreignKey({
706
+ columns: [table.tenantId, table.projectId, table.datasetId],
707
+ foreignColumns: [dataset.tenantId, dataset.projectId, dataset.id],
708
+ name: "dataset_item_dataset_fk"
709
+ }).onDelete("cascade")
710
+ ]
711
+ );
712
+ var evaluator = pgTable(
713
+ "evaluator",
714
+ {
715
+ ...projectScoped,
716
+ ...uiProperties,
717
+ prompt: text("prompt").notNull(),
718
+ schema: jsonb("schema").$type().notNull(),
719
+ model: jsonb("model").$type().notNull(),
720
+ passCriteria: jsonb("pass_criteria").$type(),
721
+ ...timestamps
722
+ },
723
+ (table) => [
724
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
725
+ foreignKey({
726
+ columns: [table.tenantId, table.projectId],
727
+ foreignColumns: [projects.tenantId, projects.id],
728
+ name: "evaluator_project_fk"
729
+ }).onDelete("cascade")
730
+ ]
731
+ );
732
+ var datasetRunConfig = pgTable(
733
+ "dataset_run_config",
734
+ {
735
+ ...projectScoped,
736
+ ...uiProperties,
737
+ datasetId: text("dataset_id").notNull(),
738
+ ...timestamps
739
+ },
740
+ (table) => [
741
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
742
+ foreignKey({
743
+ columns: [table.tenantId, table.projectId],
744
+ foreignColumns: [projects.tenantId, projects.id],
745
+ name: "dataset_run_config_project_fk"
746
+ }).onDelete("cascade"),
747
+ foreignKey({
748
+ columns: [table.tenantId, table.projectId, table.datasetId],
749
+ foreignColumns: [dataset.tenantId, dataset.projectId, dataset.id],
750
+ name: "dataset_run_config_dataset_fk"
751
+ }).onDelete("cascade")
752
+ ]
753
+ );
754
+ var datasetRunConfigAgentRelations = pgTable(
755
+ "dataset_run_config_agent_relations",
756
+ {
757
+ ...projectScoped,
758
+ datasetRunConfigId: text("dataset_run_config_id").notNull(),
759
+ agentId: text("agent_id").notNull(),
760
+ ...timestamps
761
+ },
762
+ (table) => [
763
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
764
+ foreignKey({
765
+ columns: [table.tenantId, table.projectId, table.datasetRunConfigId],
766
+ foreignColumns: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id],
767
+ name: "dataset_run_config_agent_relations_dataset_run_config_fk"
768
+ }).onDelete("cascade"),
769
+ foreignKey({
770
+ columns: [table.tenantId, table.projectId, table.agentId],
771
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
772
+ name: "dataset_run_config_agent_relations_agent_fk"
773
+ }).onDelete("cascade")
774
+ ]
775
+ );
776
+ var datasetRunConfigEvaluationRunConfigRelations = pgTable(
777
+ "dataset_run_config_evaluation_run_config_relations",
778
+ {
779
+ ...projectScoped,
780
+ datasetRunConfigId: text("dataset_run_config_id").notNull(),
781
+ evaluationRunConfigId: text("evaluation_run_config_id").notNull(),
782
+ enabled: boolean("enabled").notNull().default(true),
783
+ ...timestamps
784
+ },
785
+ (table) => [
786
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
787
+ foreignKey({
788
+ columns: [table.tenantId, table.projectId, table.datasetRunConfigId],
789
+ foreignColumns: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id],
790
+ name: "dataset_run_config_evaluation_run_config_relations_dataset_run_config_fk"
791
+ }).onDelete("cascade"),
792
+ foreignKey({
793
+ columns: [table.tenantId, table.projectId, table.evaluationRunConfigId],
794
+ foreignColumns: [
795
+ evaluationRunConfig.tenantId,
796
+ evaluationRunConfig.projectId,
797
+ evaluationRunConfig.id
798
+ ],
799
+ name: "dataset_run_config_evaluation_run_config_relations_evaluation_run_config_fk"
800
+ }).onDelete("cascade")
801
+ ]
802
+ );
803
+ var datasetRun = pgTable(
804
+ "dataset_run",
805
+ {
806
+ ...projectScoped,
807
+ datasetId: text("dataset_id").notNull(),
808
+ datasetRunConfigId: text("dataset_run_config_id").notNull(),
809
+ evaluationJobConfigId: text("evaluation_job_config_id"),
810
+ ...timestamps
811
+ },
812
+ (table) => [
813
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
814
+ foreignKey({
815
+ columns: [table.tenantId, table.projectId, table.datasetId],
816
+ foreignColumns: [dataset.tenantId, dataset.projectId, dataset.id],
817
+ name: "dataset_run_dataset_fk"
818
+ }).onDelete("cascade"),
819
+ foreignKey({
820
+ columns: [table.tenantId, table.projectId, table.datasetRunConfigId],
821
+ foreignColumns: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id],
822
+ name: "dataset_run_dataset_run_config_fk"
823
+ }).onDelete("cascade"),
824
+ foreignKey({
825
+ columns: [table.tenantId, table.projectId, table.evaluationJobConfigId],
826
+ foreignColumns: [
827
+ evaluationJobConfig.tenantId,
828
+ evaluationJobConfig.projectId,
829
+ evaluationJobConfig.id
830
+ ],
831
+ name: "dataset_run_evaluation_job_config_fk"
832
+ }).onDelete("set null")
833
+ ]
834
+ );
835
+ var datasetRunConversationRelations = pgTable(
836
+ "dataset_run_conversation_relations",
837
+ {
838
+ ...projectScoped,
839
+ datasetRunId: text("dataset_run_id").notNull(),
840
+ conversationId: text("conversation_id").notNull(),
841
+ datasetItemId: text("dataset_item_id").notNull(),
842
+ ...timestamps
843
+ },
844
+ (table) => [
845
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
846
+ foreignKey({
847
+ columns: [table.tenantId, table.projectId, table.datasetRunId],
848
+ foreignColumns: [datasetRun.tenantId, datasetRun.projectId, datasetRun.id],
849
+ name: "dataset_run_conversation_relations_run_fk"
850
+ }).onDelete("cascade"),
851
+ foreignKey({
852
+ columns: [table.tenantId, table.projectId, table.conversationId],
853
+ foreignColumns: [conversations.tenantId, conversations.projectId, conversations.id],
854
+ name: "dataset_run_conversation_relations_conversation_fk"
855
+ }).onDelete("cascade"),
856
+ foreignKey({
857
+ columns: [table.tenantId, table.projectId, table.datasetItemId],
858
+ foreignColumns: [datasetItem.tenantId, datasetItem.projectId, datasetItem.id],
859
+ name: "dataset_run_conversation_relations_item_fk"
860
+ }).onDelete("cascade"),
861
+ unique("dataset_run_conversation_relations_unique").on(
862
+ table.datasetRunId,
863
+ table.conversationId
864
+ )
865
+ ]
866
+ );
867
+ var evaluationSuiteConfig = pgTable(
868
+ "evaluation_suite_config",
869
+ {
870
+ ...projectScoped,
871
+ ...uiProperties,
872
+ filters: jsonb("filters").$type(),
873
+ // Filters for the evaluation suite (supports and/or operations)
874
+ sampleRate: doublePrecision("sample_rate"),
875
+ ...timestamps
876
+ },
877
+ (table) => [
878
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
879
+ foreignKey({
880
+ columns: [table.tenantId, table.projectId],
881
+ foreignColumns: [projects.tenantId, projects.id],
882
+ name: "evaluation_suite_config_project_fk"
883
+ }).onDelete("cascade")
884
+ ]
885
+ );
886
+ var evaluationSuiteConfigEvaluatorRelations = pgTable(
887
+ "evaluation_suite_config_evaluator_relations",
888
+ {
889
+ ...projectScoped,
890
+ evaluationSuiteConfigId: text("evaluation_suite_config_id").notNull(),
891
+ evaluatorId: text("evaluator_id").notNull(),
892
+ ...timestamps
893
+ },
894
+ (table) => [
895
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
896
+ foreignKey({
897
+ columns: [table.tenantId, table.projectId, table.evaluationSuiteConfigId],
898
+ foreignColumns: [
899
+ evaluationSuiteConfig.tenantId,
900
+ evaluationSuiteConfig.projectId,
901
+ evaluationSuiteConfig.id
902
+ ],
903
+ name: "evaluation_suite_config_evaluator_relations_evaluation_suite_config_fk"
904
+ }).onDelete("cascade"),
905
+ foreignKey({
906
+ columns: [table.tenantId, table.projectId, table.evaluatorId],
907
+ foreignColumns: [evaluator.tenantId, evaluator.projectId, evaluator.id],
908
+ name: "evaluation_suite_config_evaluator_relations_evaluator_fk"
909
+ }).onDelete("cascade")
910
+ ]
911
+ );
912
+ var evaluationRunConfig = pgTable(
913
+ "evaluation_run_config",
914
+ {
915
+ ...projectScoped,
916
+ ...uiProperties,
917
+ isActive: boolean("is_active").notNull().default(true),
918
+ ...timestamps
919
+ },
920
+ (table) => [
921
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
922
+ foreignKey({
923
+ columns: [table.tenantId, table.projectId],
924
+ foreignColumns: [projects.tenantId, projects.id],
925
+ name: "evaluation_run_config_project_fk"
926
+ }).onDelete("cascade")
927
+ ]
928
+ );
929
+ var evaluationRunConfigEvaluationSuiteConfigRelations = pgTable(
930
+ "evaluation_run_config_evaluation_suite_config_relations",
931
+ {
932
+ ...projectScoped,
933
+ evaluationRunConfigId: text("evaluation_run_config_id").notNull(),
934
+ evaluationSuiteConfigId: text("evaluation_suite_config_id").notNull(),
935
+ ...timestamps
936
+ },
937
+ (table) => [
938
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
939
+ foreignKey({
940
+ columns: [table.tenantId, table.projectId, table.evaluationRunConfigId],
941
+ foreignColumns: [
942
+ evaluationRunConfig.tenantId,
943
+ evaluationRunConfig.projectId,
944
+ evaluationRunConfig.id
945
+ ],
946
+ name: "eval_run_config_eval_suite_rel_run_config_fk"
947
+ }).onDelete("cascade"),
948
+ foreignKey({
949
+ columns: [table.tenantId, table.projectId, table.evaluationSuiteConfigId],
950
+ foreignColumns: [
951
+ evaluationSuiteConfig.tenantId,
952
+ evaluationSuiteConfig.projectId,
953
+ evaluationSuiteConfig.id
954
+ ],
955
+ name: "eval_run_config_eval_suite_rel_suite_config_fk"
956
+ }).onDelete("cascade")
957
+ ]
958
+ );
959
+ var evaluationJobConfig = pgTable(
960
+ "evaluation_job_config",
961
+ {
962
+ ...projectScoped,
963
+ jobFilters: jsonb("job_filters").$type(),
964
+ ...timestamps
965
+ },
966
+ (table) => [
967
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
968
+ foreignKey({
969
+ columns: [table.tenantId, table.projectId],
970
+ foreignColumns: [projects.tenantId, projects.id],
971
+ name: "evaluation_job_config_project_fk"
972
+ }).onDelete("cascade")
973
+ ]
974
+ );
975
+ var evaluationJobConfigEvaluatorRelations = pgTable(
976
+ "evaluation_job_config_evaluator_relations",
977
+ {
978
+ ...projectScoped,
979
+ evaluationJobConfigId: text("evaluation_job_config_id").notNull(),
980
+ evaluatorId: text("evaluator_id").notNull(),
981
+ ...timestamps
982
+ },
983
+ (table) => [
984
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
985
+ foreignKey({
986
+ columns: [table.tenantId, table.projectId, table.evaluationJobConfigId],
987
+ foreignColumns: [
988
+ evaluationJobConfig.tenantId,
989
+ evaluationJobConfig.projectId,
990
+ evaluationJobConfig.id
991
+ ],
992
+ name: "evaluation_job_config_evaluator_relations_evaluation_job_config_fk"
993
+ }).onDelete("cascade"),
994
+ foreignKey({
995
+ columns: [table.tenantId, table.projectId, table.evaluatorId],
996
+ foreignColumns: [evaluator.tenantId, evaluator.projectId, evaluator.id],
997
+ name: "evaluation_job_config_evaluator_relations_evaluator_fk"
998
+ }).onDelete("cascade")
999
+ ]
1000
+ );
1001
+ var evaluationRun = pgTable(
1002
+ "evaluation_run",
1003
+ {
1004
+ ...projectScoped,
1005
+ evaluationJobConfigId: text("evaluation_job_config_id"),
1006
+ // Optional: if created from a job
1007
+ evaluationRunConfigId: text("evaluation_run_config_id"),
1008
+ // Optional: if created from a run config
1009
+ ...timestamps
1010
+ },
1011
+ (table) => [
1012
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
1013
+ foreignKey({
1014
+ columns: [table.tenantId, table.projectId, table.evaluationJobConfigId],
1015
+ foreignColumns: [
1016
+ evaluationJobConfig.tenantId,
1017
+ evaluationJobConfig.projectId,
1018
+ evaluationJobConfig.id
1019
+ ],
1020
+ name: "evaluation_run_evaluation_job_config_fk"
1021
+ }).onDelete("cascade"),
1022
+ foreignKey({
1023
+ columns: [table.tenantId, table.projectId, table.evaluationRunConfigId],
1024
+ foreignColumns: [
1025
+ evaluationRunConfig.tenantId,
1026
+ evaluationRunConfig.projectId,
1027
+ evaluationRunConfig.id
1028
+ ],
1029
+ name: "evaluation_run_evaluation_run_config_fk"
1030
+ }).onDelete("cascade")
1031
+ ]
1032
+ );
1033
+ var evaluationResult = pgTable(
1034
+ "evaluation_result",
1035
+ {
1036
+ ...projectScoped,
1037
+ conversationId: text("conversation_id").notNull(),
1038
+ evaluatorId: text("evaluator_id").notNull(),
1039
+ evaluationRunId: text("evaluation_run_id"),
1040
+ output: jsonb("output").$type(),
1041
+ ...timestamps
1042
+ },
1043
+ (table) => [
1044
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
1045
+ foreignKey({
1046
+ columns: [table.tenantId, table.projectId, table.conversationId],
1047
+ foreignColumns: [conversations.tenantId, conversations.projectId, conversations.id],
1048
+ name: "evaluation_result_conversation_fk"
1049
+ }).onDelete("cascade"),
1050
+ foreignKey({
1051
+ columns: [table.tenantId, table.projectId, table.evaluatorId],
1052
+ foreignColumns: [evaluator.tenantId, evaluator.projectId, evaluator.id],
1053
+ name: "evaluation_result_evaluator_fk"
1054
+ }).onDelete("cascade"),
1055
+ foreignKey({
1056
+ columns: [table.tenantId, table.projectId, table.evaluationRunId],
1057
+ foreignColumns: [evaluationRun.tenantId, evaluationRun.projectId, evaluationRun.id],
1058
+ name: "evaluation_result_evaluation_run_fk"
1059
+ }).onDelete("cascade")
1060
+ ]
1061
+ );
1062
+ var tasksRelations = relations(tasks, ({ one, many }) => ({
1063
+ project: one(projects, {
1064
+ fields: [tasks.tenantId, tasks.projectId],
1065
+ references: [projects.tenantId, projects.id]
1066
+ }),
1067
+ // A task can have many parent relationships (where it's the child)
1068
+ parentRelations: many(taskRelations, {
1069
+ relationName: "childTask"
1070
+ }),
1071
+ // A task can have many child relationships (where it's the parent)
1072
+ childRelations: many(taskRelations, {
1073
+ relationName: "parentTask"
1074
+ }),
1075
+ subAgent: one(subAgents, {
1076
+ fields: [tasks.subAgentId],
1077
+ references: [subAgents.id]
1078
+ }),
1079
+ messages: many(messages),
1080
+ ledgerArtifacts: many(ledgerArtifacts)
1081
+ }));
1082
+ var projectsRelations = relations(projects, ({ many }) => ({
1083
+ subAgents: many(subAgents),
1084
+ agents: many(agents),
1085
+ tools: many(tools),
1086
+ functions: many(functions),
1087
+ contextConfigs: many(contextConfigs),
1088
+ externalAgents: many(externalAgents),
1089
+ conversations: many(conversations),
1090
+ tasks: many(tasks),
1091
+ dataComponents: many(dataComponents),
1092
+ artifactComponents: many(artifactComponents),
1093
+ ledgerArtifacts: many(ledgerArtifacts),
1094
+ credentialReferences: many(credentialReferences),
1095
+ datasets: many(dataset),
1096
+ evaluators: many(evaluator),
1097
+ evaluationSuiteConfigs: many(evaluationSuiteConfig),
1098
+ datasetRunConfigs: many(datasetRunConfig)
1099
+ }));
1100
+ var taskRelationsRelations = relations(taskRelations, ({ one }) => ({
1101
+ parentTask: one(tasks, {
1102
+ fields: [taskRelations.parentTaskId],
1103
+ references: [tasks.id],
1104
+ relationName: "parentTask"
1105
+ }),
1106
+ childTask: one(tasks, {
1107
+ fields: [taskRelations.childTaskId],
1108
+ references: [tasks.id],
1109
+ relationName: "childTask"
1110
+ })
1111
+ }));
1112
+ var contextConfigsRelations = relations(contextConfigs, ({ many, one }) => ({
1113
+ project: one(projects, {
1114
+ fields: [contextConfigs.tenantId, contextConfigs.projectId],
1115
+ references: [projects.tenantId, projects.id]
1116
+ }),
1117
+ agents: many(agents),
1118
+ cache: many(contextCache)
1119
+ }));
1120
+ var contextCacheRelations = relations(contextCache, ({ one }) => ({
1121
+ contextConfig: one(contextConfigs, {
1122
+ fields: [contextCache.contextConfigId],
1123
+ references: [contextConfigs.id]
1124
+ })
1125
+ }));
1126
+ var subAgentsRelations = relations(subAgents, ({ many, one }) => ({
1127
+ project: one(projects, {
1128
+ fields: [subAgents.tenantId, subAgents.projectId],
1129
+ references: [projects.tenantId, projects.id]
1130
+ }),
1131
+ tasks: many(tasks),
1132
+ defaultForAgents: many(agents),
1133
+ sourceRelations: many(subAgentRelations, {
1134
+ relationName: "sourceRelations"
1135
+ }),
1136
+ targetRelations: many(subAgentRelations, {
1137
+ relationName: "targetRelations"
1138
+ }),
1139
+ sentMessages: many(messages, {
1140
+ relationName: "sentMessages"
1141
+ }),
1142
+ receivedMessages: many(messages, {
1143
+ relationName: "receivedMessages"
1144
+ }),
1145
+ toolRelations: many(subAgentToolRelations),
1146
+ functionToolRelations: many(subAgentFunctionToolRelations),
1147
+ dataComponentRelations: many(subAgentDataComponents),
1148
+ artifactComponentRelations: many(subAgentArtifactComponents)
1149
+ }));
1150
+ var agentRelations = relations(agents, ({ one, many }) => ({
1151
+ project: one(projects, {
1152
+ fields: [agents.tenantId, agents.projectId],
1153
+ references: [projects.tenantId, projects.id]
1154
+ }),
1155
+ defaultSubAgent: one(subAgents, {
1156
+ fields: [agents.defaultSubAgentId],
1157
+ references: [subAgents.id]
1158
+ }),
1159
+ contextConfig: one(contextConfigs, {
1160
+ fields: [agents.contextConfigId],
1161
+ references: [contextConfigs.id]
1162
+ }),
1163
+ functionTools: many(functionTools)
1164
+ }));
1165
+ var externalAgentsRelations = relations(externalAgents, ({ one, many }) => ({
1166
+ project: one(projects, {
1167
+ fields: [externalAgents.tenantId, externalAgents.projectId],
1168
+ references: [projects.tenantId, projects.id]
1169
+ }),
1170
+ subAgentExternalAgentRelations: many(subAgentExternalAgentRelations),
1171
+ credentialReference: one(credentialReferences, {
1172
+ fields: [externalAgents.credentialReferenceId],
1173
+ references: [credentialReferences.id]
1174
+ })
1175
+ }));
1176
+ var apiKeysRelations = relations(apiKeys, ({ one }) => ({
1177
+ project: one(projects, {
1178
+ fields: [apiKeys.tenantId, apiKeys.projectId],
1179
+ references: [projects.tenantId, projects.id]
1180
+ }),
1181
+ agent: one(agents, {
1182
+ fields: [apiKeys.agentId],
1183
+ references: [agents.id]
1184
+ })
1185
+ }));
1186
+ var agentToolRelationsRelations = relations(subAgentToolRelations, ({ one }) => ({
1187
+ subAgent: one(subAgents, {
1188
+ fields: [subAgentToolRelations.subAgentId],
1189
+ references: [subAgents.id]
1190
+ }),
1191
+ tool: one(tools, {
1192
+ fields: [subAgentToolRelations.toolId],
1193
+ references: [tools.id]
1194
+ })
1195
+ }));
1196
+ var credentialReferencesRelations = relations(credentialReferences, ({ one, many }) => ({
1197
+ project: one(projects, {
1198
+ fields: [credentialReferences.tenantId, credentialReferences.projectId],
1199
+ references: [projects.tenantId, projects.id]
1200
+ }),
1201
+ tools: many(tools),
1202
+ externalAgents: many(externalAgents)
1203
+ }));
1204
+ var toolsRelations = relations(tools, ({ one, many }) => ({
1205
+ project: one(projects, {
1206
+ fields: [tools.tenantId, tools.projectId],
1207
+ references: [projects.tenantId, projects.id]
1208
+ }),
1209
+ subAgentRelations: many(subAgentToolRelations),
1210
+ credentialReference: one(credentialReferences, {
1211
+ fields: [tools.credentialReferenceId],
1212
+ references: [credentialReferences.id]
1213
+ })
1214
+ }));
1215
+ var conversationsRelations = relations(conversations, ({ one, many }) => ({
1216
+ project: one(projects, {
1217
+ fields: [conversations.tenantId, conversations.projectId],
1218
+ references: [projects.tenantId, projects.id]
1219
+ }),
1220
+ messages: many(messages),
1221
+ activeSubAgent: one(subAgents, {
1222
+ fields: [conversations.activeSubAgentId],
1223
+ references: [subAgents.id]
1224
+ })
1225
+ }));
1226
+ var messagesRelations = relations(messages, ({ one, many }) => ({
1227
+ conversation: one(conversations, {
1228
+ fields: [messages.conversationId],
1229
+ references: [conversations.id]
1230
+ }),
1231
+ fromSubAgent: one(subAgents, {
1232
+ fields: [messages.fromSubAgentId],
1233
+ references: [subAgents.id],
1234
+ relationName: "sentMessages"
1235
+ }),
1236
+ toSubAgent: one(subAgents, {
1237
+ fields: [messages.toSubAgentId],
1238
+ references: [subAgents.id],
1239
+ relationName: "receivedMessages"
1240
+ }),
1241
+ fromTeamAgent: one(agents, {
1242
+ fields: [messages.fromTeamAgentId],
1243
+ references: [agents.id],
1244
+ relationName: "receivedTeamMessages"
1245
+ }),
1246
+ toTeamAgent: one(agents, {
1247
+ fields: [messages.toTeamAgentId],
1248
+ references: [agents.id],
1249
+ relationName: "sentTeamMessages"
1250
+ }),
1251
+ fromExternalAgent: one(externalAgents, {
1252
+ fields: [messages.tenantId, messages.projectId, messages.fromExternalAgentId],
1253
+ references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
1254
+ relationName: "receivedExternalMessages"
1255
+ }),
1256
+ toExternalAgent: one(externalAgents, {
1257
+ fields: [messages.tenantId, messages.projectId, messages.toExternalAgentId],
1258
+ references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
1259
+ relationName: "sentExternalMessages"
1260
+ }),
1261
+ task: one(tasks, {
1262
+ fields: [messages.taskId],
1263
+ references: [tasks.id]
1264
+ }),
1265
+ parentMessage: one(messages, {
1266
+ fields: [messages.parentMessageId],
1267
+ references: [messages.id],
1268
+ relationName: "parentChild"
1269
+ }),
1270
+ childMessages: many(messages, {
1271
+ relationName: "parentChild"
1272
+ })
1273
+ }));
1274
+ var artifactComponentsRelations = relations(artifactComponents, ({ many, one }) => ({
1275
+ project: one(projects, {
1276
+ fields: [artifactComponents.tenantId, artifactComponents.projectId],
1277
+ references: [projects.tenantId, projects.id]
1278
+ }),
1279
+ subAgentRelations: many(subAgentArtifactComponents)
1280
+ }));
1281
+ var subAgentArtifactComponentsRelations = relations(
1282
+ subAgentArtifactComponents,
1283
+ ({ one }) => ({
1284
+ subAgent: one(subAgents, {
1285
+ fields: [subAgentArtifactComponents.subAgentId],
1286
+ references: [subAgents.id]
1287
+ }),
1288
+ artifactComponent: one(artifactComponents, {
1289
+ fields: [subAgentArtifactComponents.artifactComponentId],
1290
+ references: [artifactComponents.id]
1291
+ })
1292
+ })
1293
+ );
1294
+ var dataComponentsRelations = relations(dataComponents, ({ many, one }) => ({
1295
+ project: one(projects, {
1296
+ fields: [dataComponents.tenantId, dataComponents.projectId],
1297
+ references: [projects.tenantId, projects.id]
1298
+ }),
1299
+ subAgentRelations: many(subAgentDataComponents)
1300
+ }));
1301
+ var subAgentDataComponentsRelations = relations(subAgentDataComponents, ({ one }) => ({
1302
+ subAgent: one(subAgents, {
1303
+ fields: [subAgentDataComponents.subAgentId],
1304
+ references: [subAgents.id]
1305
+ }),
1306
+ dataComponent: one(dataComponents, {
1307
+ fields: [subAgentDataComponents.dataComponentId],
1308
+ references: [dataComponents.id]
1309
+ })
1310
+ }));
1311
+ var ledgerArtifactsRelations = relations(ledgerArtifacts, ({ one }) => ({
1312
+ project: one(projects, {
1313
+ fields: [ledgerArtifacts.tenantId, ledgerArtifacts.projectId],
1314
+ references: [projects.tenantId, projects.id]
1315
+ }),
1316
+ task: one(tasks, {
1317
+ fields: [ledgerArtifacts.taskId],
1318
+ references: [tasks.id]
1319
+ })
1320
+ }));
1321
+ var functionsRelations = relations(functions, ({ many, one }) => ({
1322
+ functionTools: many(functionTools),
1323
+ project: one(projects, {
1324
+ fields: [functions.tenantId, functions.projectId],
1325
+ references: [projects.tenantId, projects.id]
1326
+ })
1327
+ }));
1328
+ var subAgentRelationsRelations = relations(subAgentRelations, ({ one }) => ({
1329
+ agent: one(agents, {
1330
+ fields: [subAgentRelations.agentId],
1331
+ references: [agents.id]
1332
+ }),
1333
+ sourceSubAgent: one(subAgents, {
1334
+ fields: [subAgentRelations.sourceSubAgentId],
1335
+ references: [subAgents.id],
1336
+ relationName: "sourceRelations"
1337
+ }),
1338
+ targetSubAgent: one(subAgents, {
1339
+ fields: [subAgentRelations.targetSubAgentId],
1340
+ references: [subAgents.id],
1341
+ relationName: "targetRelations"
1342
+ })
1343
+ }));
1344
+ var functionToolsRelations = relations(functionTools, ({ one, many }) => ({
1345
+ project: one(projects, {
1346
+ fields: [functionTools.tenantId, functionTools.projectId],
1347
+ references: [projects.tenantId, projects.id]
1348
+ }),
1349
+ agent: one(agents, {
1350
+ fields: [functionTools.tenantId, functionTools.projectId, functionTools.agentId],
1351
+ references: [agents.tenantId, agents.projectId, agents.id]
1352
+ }),
1353
+ function: one(functions, {
1354
+ fields: [functionTools.tenantId, functionTools.projectId, functionTools.functionId],
1355
+ references: [functions.tenantId, functions.projectId, functions.id]
1356
+ }),
1357
+ subAgentRelations: many(subAgentFunctionToolRelations)
1358
+ }));
1359
+ var subAgentFunctionToolRelationsRelations = relations(
1360
+ subAgentFunctionToolRelations,
1361
+ ({ one }) => ({
1362
+ subAgent: one(subAgents, {
1363
+ fields: [subAgentFunctionToolRelations.subAgentId],
1364
+ references: [subAgents.id]
1365
+ }),
1366
+ functionTool: one(functionTools, {
1367
+ fields: [subAgentFunctionToolRelations.functionToolId],
1368
+ references: [functionTools.id]
1369
+ })
1370
+ })
1371
+ );
1372
+ var subAgentExternalAgentRelationsRelations = relations(
1373
+ subAgentExternalAgentRelations,
1374
+ ({ one }) => ({
1375
+ subAgent: one(subAgents, {
1376
+ fields: [
1377
+ subAgentExternalAgentRelations.tenantId,
1378
+ subAgentExternalAgentRelations.projectId,
1379
+ subAgentExternalAgentRelations.agentId,
1380
+ subAgentExternalAgentRelations.subAgentId
1381
+ ],
1382
+ references: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id]
1383
+ }),
1384
+ externalAgent: one(externalAgents, {
1385
+ fields: [
1386
+ subAgentExternalAgentRelations.tenantId,
1387
+ subAgentExternalAgentRelations.projectId,
1388
+ subAgentExternalAgentRelations.externalAgentId
1389
+ ],
1390
+ references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id]
1391
+ })
1392
+ })
1393
+ );
1394
+ var subAgentTeamAgentRelationsRelations = relations(
1395
+ subAgentTeamAgentRelations,
1396
+ ({ one }) => ({
1397
+ subAgent: one(subAgents, {
1398
+ fields: [
1399
+ subAgentTeamAgentRelations.tenantId,
1400
+ subAgentTeamAgentRelations.projectId,
1401
+ subAgentTeamAgentRelations.agentId,
1402
+ subAgentTeamAgentRelations.subAgentId
1403
+ ],
1404
+ references: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id]
1405
+ }),
1406
+ targetAgent: one(agents, {
1407
+ fields: [
1408
+ subAgentTeamAgentRelations.tenantId,
1409
+ subAgentTeamAgentRelations.projectId,
1410
+ subAgentTeamAgentRelations.targetAgentId
1411
+ ],
1412
+ references: [agents.tenantId, agents.projectId, agents.id]
1413
+ })
1414
+ })
1415
+ );
1416
+ var datasetRelations = relations(dataset, ({ one, many }) => ({
1417
+ project: one(projects, {
1418
+ fields: [dataset.tenantId, dataset.projectId],
1419
+ references: [projects.tenantId, projects.id]
1420
+ }),
1421
+ items: many(datasetItem),
1422
+ datasetRuns: many(datasetRun)
1423
+ }));
1424
+ var datasetItemRelations = relations(datasetItem, ({ one }) => ({
1425
+ dataset: one(dataset, {
1426
+ fields: [datasetItem.tenantId, datasetItem.projectId, datasetItem.datasetId],
1427
+ references: [dataset.tenantId, dataset.projectId, dataset.id]
1428
+ })
1429
+ }));
1430
+ var evaluatorRelations = relations(evaluator, ({ one, many }) => ({
1431
+ project: one(projects, {
1432
+ fields: [evaluator.tenantId, evaluator.projectId],
1433
+ references: [projects.tenantId, projects.id]
1434
+ }),
1435
+ evaluationResults: many(evaluationResult),
1436
+ evaluationSuiteConfigs: many(evaluationSuiteConfigEvaluatorRelations),
1437
+ evaluationJobConfigs: many(evaluationJobConfigEvaluatorRelations)
1438
+ }));
1439
+ var datasetRunConfigRelations = relations(datasetRunConfig, ({ one, many }) => ({
1440
+ project: one(projects, {
1441
+ fields: [datasetRunConfig.tenantId, datasetRunConfig.projectId],
1442
+ references: [projects.tenantId, projects.id]
1443
+ }),
1444
+ dataset: one(dataset, {
1445
+ fields: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.datasetId],
1446
+ references: [dataset.tenantId, dataset.projectId, dataset.id]
1447
+ }),
1448
+ agents: many(datasetRunConfigAgentRelations),
1449
+ evaluationRunConfigs: many(datasetRunConfigEvaluationRunConfigRelations),
1450
+ runs: many(datasetRun)
1451
+ }));
1452
+ var datasetRunConfigAgentRelationsRelations = relations(
1453
+ datasetRunConfigAgentRelations,
1454
+ ({ one }) => ({
1455
+ datasetRunConfig: one(datasetRunConfig, {
1456
+ fields: [
1457
+ datasetRunConfigAgentRelations.tenantId,
1458
+ datasetRunConfigAgentRelations.projectId,
1459
+ datasetRunConfigAgentRelations.datasetRunConfigId
1460
+ ],
1461
+ references: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id]
1462
+ }),
1463
+ agent: one(agents, {
1464
+ fields: [
1465
+ datasetRunConfigAgentRelations.tenantId,
1466
+ datasetRunConfigAgentRelations.projectId,
1467
+ datasetRunConfigAgentRelations.agentId
1468
+ ],
1469
+ references: [agents.tenantId, agents.projectId, agents.id]
1470
+ })
1471
+ })
1472
+ );
1473
+ var datasetRunConfigEvaluationRunConfigRelationsRelations = relations(
1474
+ datasetRunConfigEvaluationRunConfigRelations,
1475
+ ({ one }) => ({
1476
+ datasetRunConfig: one(datasetRunConfig, {
1477
+ fields: [
1478
+ datasetRunConfigEvaluationRunConfigRelations.tenantId,
1479
+ datasetRunConfigEvaluationRunConfigRelations.projectId,
1480
+ datasetRunConfigEvaluationRunConfigRelations.datasetRunConfigId
1481
+ ],
1482
+ references: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id]
1483
+ }),
1484
+ evaluationRunConfig: one(evaluationRunConfig, {
1485
+ fields: [
1486
+ datasetRunConfigEvaluationRunConfigRelations.tenantId,
1487
+ datasetRunConfigEvaluationRunConfigRelations.projectId,
1488
+ datasetRunConfigEvaluationRunConfigRelations.evaluationRunConfigId
1489
+ ],
1490
+ references: [
1491
+ evaluationRunConfig.tenantId,
1492
+ evaluationRunConfig.projectId,
1493
+ evaluationRunConfig.id
1494
+ ]
1495
+ })
1496
+ })
1497
+ );
1498
+ var datasetRunRelations = relations(datasetRun, ({ one, many }) => ({
1499
+ dataset: one(dataset, {
1500
+ fields: [datasetRun.tenantId, datasetRun.projectId, datasetRun.datasetId],
1501
+ references: [dataset.tenantId, dataset.projectId, dataset.id]
1502
+ }),
1503
+ datasetRunConfig: one(datasetRunConfig, {
1504
+ fields: [datasetRun.tenantId, datasetRun.projectId, datasetRun.datasetRunConfigId],
1505
+ references: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id]
1506
+ }),
1507
+ conversations: many(datasetRunConversationRelations)
1508
+ }));
1509
+ var evaluationSuiteConfigRelations = relations(evaluationSuiteConfig, ({ one, many }) => ({
1510
+ project: one(projects, {
1511
+ fields: [evaluationSuiteConfig.tenantId, evaluationSuiteConfig.projectId],
1512
+ references: [projects.tenantId, projects.id]
1513
+ }),
1514
+ runConfigs: many(evaluationRunConfigEvaluationSuiteConfigRelations),
1515
+ evaluators: many(evaluationSuiteConfigEvaluatorRelations)
1516
+ }));
1517
+ var evaluationSuiteConfigEvaluatorRelationsRelations = relations(
1518
+ evaluationSuiteConfigEvaluatorRelations,
1519
+ ({ one }) => ({
1520
+ evaluationSuiteConfig: one(evaluationSuiteConfig, {
1521
+ fields: [
1522
+ evaluationSuiteConfigEvaluatorRelations.tenantId,
1523
+ evaluationSuiteConfigEvaluatorRelations.projectId,
1524
+ evaluationSuiteConfigEvaluatorRelations.evaluationSuiteConfigId
1525
+ ],
1526
+ references: [
1527
+ evaluationSuiteConfig.tenantId,
1528
+ evaluationSuiteConfig.projectId,
1529
+ evaluationSuiteConfig.id
1530
+ ]
1531
+ }),
1532
+ evaluator: one(evaluator, {
1533
+ fields: [
1534
+ evaluationSuiteConfigEvaluatorRelations.tenantId,
1535
+ evaluationSuiteConfigEvaluatorRelations.projectId,
1536
+ evaluationSuiteConfigEvaluatorRelations.evaluatorId
1537
+ ],
1538
+ references: [evaluator.tenantId, evaluator.projectId, evaluator.id]
1539
+ })
1540
+ })
1541
+ );
1542
+ var evaluationJobConfigEvaluatorRelationsRelations = relations(
1543
+ evaluationJobConfigEvaluatorRelations,
1544
+ ({ one }) => ({
1545
+ evaluationJobConfig: one(evaluationJobConfig, {
1546
+ fields: [
1547
+ evaluationJobConfigEvaluatorRelations.tenantId,
1548
+ evaluationJobConfigEvaluatorRelations.projectId,
1549
+ evaluationJobConfigEvaluatorRelations.evaluationJobConfigId
1550
+ ],
1551
+ references: [
1552
+ evaluationJobConfig.tenantId,
1553
+ evaluationJobConfig.projectId,
1554
+ evaluationJobConfig.id
1555
+ ]
1556
+ }),
1557
+ evaluator: one(evaluator, {
1558
+ fields: [
1559
+ evaluationJobConfigEvaluatorRelations.tenantId,
1560
+ evaluationJobConfigEvaluatorRelations.projectId,
1561
+ evaluationJobConfigEvaluatorRelations.evaluatorId
1562
+ ],
1563
+ references: [evaluator.tenantId, evaluator.projectId, evaluator.id]
1564
+ })
1565
+ })
1566
+ );
1567
+ var evaluationJobConfigRelations = relations(evaluationJobConfig, ({ one, many }) => ({
1568
+ project: one(projects, {
1569
+ fields: [evaluationJobConfig.tenantId, evaluationJobConfig.projectId],
1570
+ references: [projects.tenantId, projects.id]
1571
+ }),
1572
+ run: one(evaluationRun, {
1573
+ fields: [evaluationJobConfig.tenantId, evaluationJobConfig.projectId, evaluationJobConfig.id],
1574
+ references: [
1575
+ evaluationRun.tenantId,
1576
+ evaluationRun.projectId,
1577
+ evaluationRun.evaluationJobConfigId
1578
+ ]
1579
+ }),
1580
+ evaluators: many(evaluationJobConfigEvaluatorRelations)
1581
+ }));
1582
+ var evaluationRunConfigEvaluationSuiteConfigRelationsRelations = relations(
1583
+ evaluationRunConfigEvaluationSuiteConfigRelations,
1584
+ ({ one }) => ({
1585
+ evaluationRunConfig: one(evaluationRunConfig, {
1586
+ fields: [
1587
+ evaluationRunConfigEvaluationSuiteConfigRelations.tenantId,
1588
+ evaluationRunConfigEvaluationSuiteConfigRelations.projectId,
1589
+ evaluationRunConfigEvaluationSuiteConfigRelations.evaluationRunConfigId
1590
+ ],
1591
+ references: [
1592
+ evaluationRunConfig.tenantId,
1593
+ evaluationRunConfig.projectId,
1594
+ evaluationRunConfig.id
1595
+ ]
1596
+ }),
1597
+ evaluationSuiteConfig: one(evaluationSuiteConfig, {
1598
+ fields: [
1599
+ evaluationRunConfigEvaluationSuiteConfigRelations.tenantId,
1600
+ evaluationRunConfigEvaluationSuiteConfigRelations.projectId,
1601
+ evaluationRunConfigEvaluationSuiteConfigRelations.evaluationSuiteConfigId
1602
+ ],
1603
+ references: [
1604
+ evaluationSuiteConfig.tenantId,
1605
+ evaluationSuiteConfig.projectId,
1606
+ evaluationSuiteConfig.id
1607
+ ]
1608
+ })
1609
+ })
1610
+ );
1611
+ var evaluationRunConfigRelations = relations(evaluationRunConfig, ({ one, many }) => ({
1612
+ project: one(projects, {
1613
+ fields: [evaluationRunConfig.tenantId, evaluationRunConfig.projectId],
1614
+ references: [projects.tenantId, projects.id]
1615
+ }),
1616
+ suiteConfigs: many(evaluationRunConfigEvaluationSuiteConfigRelations),
1617
+ datasetRunConfigs: many(datasetRunConfigEvaluationRunConfigRelations),
1618
+ runs: many(evaluationRun)
1619
+ }));
1620
+ var evaluationRunRelations = relations(evaluationRun, ({ one, many }) => ({
1621
+ evaluationJobConfig: one(evaluationJobConfig, {
1622
+ fields: [evaluationRun.tenantId, evaluationRun.projectId, evaluationRun.evaluationJobConfigId],
1623
+ references: [
1624
+ evaluationJobConfig.tenantId,
1625
+ evaluationJobConfig.projectId,
1626
+ evaluationJobConfig.id
1627
+ ]
1628
+ }),
1629
+ evaluationRunConfig: one(evaluationRunConfig, {
1630
+ fields: [evaluationRun.tenantId, evaluationRun.projectId, evaluationRun.evaluationRunConfigId],
1631
+ references: [
1632
+ evaluationRunConfig.tenantId,
1633
+ evaluationRunConfig.projectId,
1634
+ evaluationRunConfig.id
1635
+ ]
1636
+ }),
1637
+ results: many(evaluationResult)
1638
+ }));
1639
+ var evaluationResultRelations = relations(evaluationResult, ({ one }) => ({
1640
+ conversation: one(conversations, {
1641
+ fields: [
1642
+ evaluationResult.tenantId,
1643
+ evaluationResult.projectId,
1644
+ evaluationResult.conversationId
1645
+ ],
1646
+ references: [conversations.tenantId, conversations.projectId, conversations.id],
1647
+ relationName: "conversationEvaluationResults"
1648
+ }),
1649
+ evaluator: one(evaluator, {
1650
+ fields: [evaluationResult.tenantId, evaluationResult.projectId, evaluationResult.evaluatorId],
1651
+ references: [evaluator.tenantId, evaluator.projectId, evaluator.id]
1652
+ }),
1653
+ evaluationRun: one(evaluationRun, {
1654
+ fields: [
1655
+ evaluationResult.tenantId,
1656
+ evaluationResult.projectId,
1657
+ evaluationResult.evaluationRunId
1658
+ ],
1659
+ references: [evaluationRun.tenantId, evaluationRun.projectId, evaluationRun.id]
1660
+ })
1661
+ }));
1662
+ var conversationsEvaluatorRelations = relations(conversations, ({ many }) => ({
1663
+ evaluationResults: many(evaluationResult, {
1664
+ relationName: "conversationEvaluationResults"
1665
+ })
1666
+ }));
1667
+ var datasetRunConversationRelationsRelations = relations(
1668
+ datasetRunConversationRelations,
1669
+ ({ one }) => ({
1670
+ datasetRun: one(datasetRun, {
1671
+ fields: [
1672
+ datasetRunConversationRelations.tenantId,
1673
+ datasetRunConversationRelations.projectId,
1674
+ datasetRunConversationRelations.datasetRunId
1675
+ ],
1676
+ references: [datasetRun.tenantId, datasetRun.projectId, datasetRun.id]
1677
+ }),
1678
+ conversation: one(conversations, {
1679
+ fields: [
1680
+ datasetRunConversationRelations.tenantId,
1681
+ datasetRunConversationRelations.projectId,
1682
+ datasetRunConversationRelations.conversationId
1683
+ ],
1684
+ references: [conversations.tenantId, conversations.projectId, conversations.id]
1685
+ })
1686
+ })
1687
+ );
1688
+
1689
+ export { agentRelations, agentToolRelationsRelations, agents, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsEvaluatorRelations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, dataset, datasetItem, datasetItemRelations, datasetRelations, datasetRun, datasetRunConfig, datasetRunConfigAgentRelations, datasetRunConfigAgentRelationsRelations, datasetRunConfigEvaluationRunConfigRelations, datasetRunConfigEvaluationRunConfigRelationsRelations, datasetRunConfigRelations, datasetRunConversationRelations, datasetRunConversationRelationsRelations, datasetRunRelations, evaluationJobConfig, evaluationJobConfigEvaluatorRelations, evaluationJobConfigEvaluatorRelationsRelations, evaluationJobConfigRelations, evaluationResult, evaluationResultRelations, evaluationRun, evaluationRunConfig, evaluationRunConfigEvaluationSuiteConfigRelations, evaluationRunConfigEvaluationSuiteConfigRelationsRelations, evaluationRunConfigRelations, evaluationRunRelations, evaluationSuiteConfig, evaluationSuiteConfigEvaluatorRelations, evaluationSuiteConfigEvaluatorRelationsRelations, evaluationSuiteConfigRelations, evaluator, evaluatorRelations, externalAgents, externalAgentsRelations, functionTools, functionToolsRelations, functions, functionsRelations, ledgerArtifacts, ledgerArtifactsRelations, messages, messagesRelations, projects, projectsRelations, schema_exports, subAgentArtifactComponents, subAgentArtifactComponentsRelations, subAgentDataComponents, subAgentDataComponentsRelations, subAgentExternalAgentRelations, subAgentExternalAgentRelationsRelations, subAgentFunctionToolRelations, subAgentFunctionToolRelationsRelations, subAgentRelations, subAgentRelationsRelations, subAgentTeamAgentRelations, subAgentTeamAgentRelationsRelations, subAgentToolRelations, subAgents, subAgentsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations };