@inkeep/agents-core 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -7
- package/dist/{chunk-YVGNJIQZ.js → chunk-J7YOVSV7.js} +1 -1
- package/dist/{chunk-URSDNK76.js → chunk-KBRQN63H.js} +82 -206
- package/dist/{chunk-JXAL2ALG.js → chunk-R5V3UTGB.js} +1 -1
- package/dist/client-exports.cjs +80 -200
- package/dist/client-exports.d.cts +7 -7
- package/dist/client-exports.d.ts +7 -7
- package/dist/client-exports.js +2 -2
- package/dist/db/schema.cjs +80 -204
- package/dist/db/schema.d.cts +2 -2
- package/dist/db/schema.d.ts +2 -2
- package/dist/db/schema.js +1 -1
- package/dist/index.cjs +80 -208
- package/dist/index.d.cts +225 -223
- package/dist/index.d.ts +225 -223
- package/dist/index.js +6 -6
- package/dist/{schema-D66X7wP_.d.ts → schema-BA1ATr-V.d.ts} +674 -663
- package/dist/{schema-BXVLXPQq.d.cts → schema-CGo-G_SM.d.cts} +674 -663
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/{utility-D7QP8MkV.d.cts → utility-ChGndcyd.d.cts} +1031 -1007
- package/dist/{utility-D7QP8MkV.d.ts → utility-ChGndcyd.d.ts} +1031 -1007
- package/dist/validation/index.cjs +80 -200
- package/dist/validation/index.d.cts +2 -2
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +2 -2
- package/package.json +4 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __export } from './chunk-MKBO26DX.js';
|
|
2
2
|
import { relations, sql } from 'drizzle-orm';
|
|
3
|
-
import { sqliteTable,
|
|
3
|
+
import { sqliteTable, text, primaryKey, foreignKey, blob, integer, index, unique } from 'drizzle-orm/sqlite-core';
|
|
4
4
|
|
|
5
5
|
// src/db/schema.ts
|
|
6
6
|
var schema_exports = {};
|
|
@@ -34,11 +34,7 @@ __export(schema_exports, {
|
|
|
34
34
|
externalAgents: () => externalAgents,
|
|
35
35
|
externalAgentsRelations: () => externalAgentsRelations,
|
|
36
36
|
ledgerArtifacts: () => ledgerArtifacts,
|
|
37
|
-
ledgerArtifactsContextIdIdx: () => ledgerArtifactsContextIdIdx,
|
|
38
37
|
ledgerArtifactsRelations: () => ledgerArtifactsRelations,
|
|
39
|
-
ledgerArtifactsTaskContextNameUnique: () => ledgerArtifactsTaskContextNameUnique,
|
|
40
|
-
ledgerArtifactsTaskIdIdx: () => ledgerArtifactsTaskIdIdx,
|
|
41
|
-
ledgerArtifactsToolCallIdIdx: () => ledgerArtifactsToolCallIdIdx,
|
|
42
38
|
messages: () => messages,
|
|
43
39
|
messagesRelations: () => messagesRelations,
|
|
44
40
|
projects: () => projects,
|
|
@@ -50,29 +46,47 @@ __export(schema_exports, {
|
|
|
50
46
|
tools: () => tools,
|
|
51
47
|
toolsRelations: () => toolsRelations
|
|
52
48
|
});
|
|
49
|
+
var tenantScoped = {
|
|
50
|
+
tenantId: text("tenant_id").notNull(),
|
|
51
|
+
id: text("id").notNull()
|
|
52
|
+
};
|
|
53
|
+
var projectScoped = {
|
|
54
|
+
...tenantScoped,
|
|
55
|
+
projectId: text("project_id").notNull()
|
|
56
|
+
};
|
|
57
|
+
var graphScoped = {
|
|
58
|
+
...projectScoped,
|
|
59
|
+
graphId: text("graph_id").notNull()
|
|
60
|
+
};
|
|
61
|
+
var agentScoped = {
|
|
62
|
+
...graphScoped,
|
|
63
|
+
agentId: text("agent_id").notNull()
|
|
64
|
+
};
|
|
65
|
+
var uiProperties = {
|
|
66
|
+
name: text("name").notNull(),
|
|
67
|
+
description: text("description").notNull()
|
|
68
|
+
};
|
|
69
|
+
var timestamps = {
|
|
70
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
71
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
72
|
+
};
|
|
53
73
|
var projects = sqliteTable(
|
|
54
74
|
"projects",
|
|
55
75
|
{
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// This IS the project ID
|
|
59
|
-
name: text("name").notNull(),
|
|
60
|
-
description: text("description").notNull(),
|
|
76
|
+
...tenantScoped,
|
|
77
|
+
...uiProperties,
|
|
61
78
|
// Project-level default model settings that can be inherited by graphs and agents
|
|
62
79
|
models: text("models", { mode: "json" }).$type(),
|
|
63
80
|
// Project-level stopWhen configuration that can be inherited by graphs and agents
|
|
64
81
|
stopWhen: text("stop_when", { mode: "json" }).$type(),
|
|
65
|
-
|
|
66
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
82
|
+
...timestamps
|
|
67
83
|
},
|
|
68
84
|
(table) => [primaryKey({ columns: [table.tenantId, table.id] })]
|
|
69
85
|
);
|
|
70
86
|
var agentGraph = sqliteTable(
|
|
71
87
|
"agent_graph",
|
|
72
88
|
{
|
|
73
|
-
|
|
74
|
-
projectId: text("project_id").notNull(),
|
|
75
|
-
id: text("id").notNull(),
|
|
89
|
+
...projectScoped,
|
|
76
90
|
name: text("name").notNull(),
|
|
77
91
|
description: text("description"),
|
|
78
92
|
defaultAgentId: text("default_agent_id"),
|
|
@@ -87,8 +101,7 @@ var agentGraph = sqliteTable(
|
|
|
87
101
|
graphPrompt: text("graph_prompt"),
|
|
88
102
|
// Graph-level stopWhen configuration that can be inherited by agents
|
|
89
103
|
stopWhen: text("stop_when", { mode: "json" }).$type(),
|
|
90
|
-
|
|
91
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
104
|
+
...timestamps
|
|
92
105
|
},
|
|
93
106
|
(table) => [
|
|
94
107
|
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -102,19 +115,14 @@ var agentGraph = sqliteTable(
|
|
|
102
115
|
var contextConfigs = sqliteTable(
|
|
103
116
|
"context_configs",
|
|
104
117
|
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// Add graph level scoping
|
|
108
|
-
id: text("id").notNull(),
|
|
109
|
-
name: text("name").notNull(),
|
|
110
|
-
description: text("description").notNull(),
|
|
118
|
+
...projectScoped,
|
|
119
|
+
...uiProperties,
|
|
111
120
|
// Developer-defined Zod schema for validating incoming request context
|
|
112
121
|
requestContextSchema: blob("request_context_schema", { mode: "json" }).$type(),
|
|
113
122
|
// Stores serialized Zod schema
|
|
114
123
|
// Object mapping template keys to fetch definitions that use request context data
|
|
115
124
|
contextVariables: blob("context_variables", { mode: "json" }).$type(),
|
|
116
|
-
|
|
117
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
125
|
+
...timestamps
|
|
118
126
|
},
|
|
119
127
|
(table) => [
|
|
120
128
|
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -128,9 +136,7 @@ var contextConfigs = sqliteTable(
|
|
|
128
136
|
var contextCache = sqliteTable(
|
|
129
137
|
"context_cache",
|
|
130
138
|
{
|
|
131
|
-
|
|
132
|
-
projectId: text("project_id").notNull(),
|
|
133
|
-
id: text("id").notNull(),
|
|
139
|
+
...projectScoped,
|
|
134
140
|
// Always scoped to conversation for complete data isolation
|
|
135
141
|
conversationId: text("conversation_id").notNull(),
|
|
136
142
|
// Reference to the context config and specific fetch definition
|
|
@@ -147,8 +153,7 @@ var contextCache = sqliteTable(
|
|
|
147
153
|
fetchSource: text("fetch_source"),
|
|
148
154
|
// URL or source identifier
|
|
149
155
|
fetchDurationMs: integer("fetch_duration_ms"),
|
|
150
|
-
|
|
151
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
156
|
+
...timestamps
|
|
152
157
|
},
|
|
153
158
|
(table) => [
|
|
154
159
|
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -167,12 +172,8 @@ var contextCache = sqliteTable(
|
|
|
167
172
|
var agents = sqliteTable(
|
|
168
173
|
"agents",
|
|
169
174
|
{
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
graphId: text("graph_id").notNull(),
|
|
173
|
-
id: text("id").notNull(),
|
|
174
|
-
name: text("name").notNull(),
|
|
175
|
-
description: text("description").notNull(),
|
|
175
|
+
...graphScoped,
|
|
176
|
+
...uiProperties,
|
|
176
177
|
prompt: text("prompt").notNull(),
|
|
177
178
|
conversationHistoryConfig: text("conversation_history_config", {
|
|
178
179
|
mode: "json"
|
|
@@ -180,8 +181,7 @@ var agents = sqliteTable(
|
|
|
180
181
|
models: text("models", { mode: "json" }).$type(),
|
|
181
182
|
// Agent-level stopWhen configuration (inherited from project)
|
|
182
183
|
stopWhen: text("stop_when", { mode: "json" }).$type(),
|
|
183
|
-
|
|
184
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
184
|
+
...timestamps
|
|
185
185
|
},
|
|
186
186
|
(table) => [
|
|
187
187
|
primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
|
|
@@ -195,10 +195,7 @@ var agents = sqliteTable(
|
|
|
195
195
|
var agentRelations = sqliteTable(
|
|
196
196
|
"agent_relations",
|
|
197
197
|
{
|
|
198
|
-
|
|
199
|
-
projectId: text("project_id").notNull(),
|
|
200
|
-
graphId: text("graph_id").notNull(),
|
|
201
|
-
id: text("id").notNull(),
|
|
198
|
+
...graphScoped,
|
|
202
199
|
sourceAgentId: text("source_agent_id").notNull(),
|
|
203
200
|
// For internal relationships
|
|
204
201
|
targetAgentId: text("target_agent_id"),
|
|
@@ -206,8 +203,7 @@ var agentRelations = sqliteTable(
|
|
|
206
203
|
externalAgentId: text("external_agent_id"),
|
|
207
204
|
relationType: text("relation_type"),
|
|
208
205
|
// 'transfer' | 'delegate'
|
|
209
|
-
|
|
210
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
206
|
+
...timestamps
|
|
211
207
|
},
|
|
212
208
|
(table) => [
|
|
213
209
|
primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
|
|
@@ -221,18 +217,13 @@ var agentRelations = sqliteTable(
|
|
|
221
217
|
var externalAgents = sqliteTable(
|
|
222
218
|
"external_agents",
|
|
223
219
|
{
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
graphId: text("graph_id").notNull(),
|
|
227
|
-
id: text("id").notNull(),
|
|
228
|
-
name: text("name").notNull(),
|
|
229
|
-
description: text("description").notNull(),
|
|
220
|
+
...graphScoped,
|
|
221
|
+
...uiProperties,
|
|
230
222
|
baseUrl: text("base_url").notNull(),
|
|
231
223
|
// A2A endpoint URL
|
|
232
224
|
credentialReferenceId: text("credential_reference_id"),
|
|
233
225
|
headers: blob("headers", { mode: "json" }).$type(),
|
|
234
|
-
|
|
235
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
226
|
+
...timestamps
|
|
236
227
|
},
|
|
237
228
|
(table) => [
|
|
238
229
|
primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
|
|
@@ -255,37 +246,30 @@ var externalAgents = sqliteTable(
|
|
|
255
246
|
var tasks = sqliteTable(
|
|
256
247
|
"tasks",
|
|
257
248
|
{
|
|
258
|
-
|
|
259
|
-
projectId: text("project_id").notNull(),
|
|
260
|
-
id: text("id").notNull(),
|
|
249
|
+
...agentScoped,
|
|
261
250
|
contextId: text("context_id").notNull(),
|
|
262
251
|
status: text("status").notNull(),
|
|
263
252
|
metadata: blob("metadata", { mode: "json" }).$type(),
|
|
264
|
-
|
|
265
|
-
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
266
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
253
|
+
...timestamps
|
|
267
254
|
},
|
|
268
255
|
(table) => [
|
|
269
256
|
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
270
257
|
foreignKey({
|
|
271
|
-
columns: [table.tenantId, table.projectId],
|
|
272
|
-
foreignColumns: [
|
|
273
|
-
name: "
|
|
258
|
+
columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
|
|
259
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
|
|
260
|
+
name: "tasks_agent_fk"
|
|
274
261
|
}).onDelete("cascade")
|
|
275
262
|
]
|
|
276
263
|
);
|
|
277
264
|
var taskRelations = sqliteTable(
|
|
278
265
|
"task_relations",
|
|
279
266
|
{
|
|
280
|
-
|
|
281
|
-
projectId: text("project_id").notNull(),
|
|
282
|
-
id: text("id").notNull(),
|
|
267
|
+
...projectScoped,
|
|
283
268
|
parentTaskId: text("parent_task_id").notNull(),
|
|
284
269
|
childTaskId: text("child_task_id").notNull(),
|
|
285
270
|
relationType: text("relation_type").default("parent_child"),
|
|
286
271
|
// Could be extended for other relation types
|
|
287
|
-
|
|
288
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
272
|
+
...timestamps
|
|
289
273
|
},
|
|
290
274
|
(table) => [
|
|
291
275
|
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -299,14 +283,10 @@ var taskRelations = sqliteTable(
|
|
|
299
283
|
var dataComponents = sqliteTable(
|
|
300
284
|
"data_components",
|
|
301
285
|
{
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
id: text("id").notNull(),
|
|
305
|
-
name: text("name").notNull(),
|
|
306
|
-
description: text("description").notNull(),
|
|
286
|
+
...projectScoped,
|
|
287
|
+
...uiProperties,
|
|
307
288
|
props: blob("props", { mode: "json" }).$type(),
|
|
308
|
-
|
|
309
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
289
|
+
...timestamps
|
|
310
290
|
},
|
|
311
291
|
(table) => [
|
|
312
292
|
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -320,11 +300,7 @@ var dataComponents = sqliteTable(
|
|
|
320
300
|
var agentDataComponents = sqliteTable(
|
|
321
301
|
"agent_data_components",
|
|
322
302
|
{
|
|
323
|
-
|
|
324
|
-
projectId: text("project_id").notNull(),
|
|
325
|
-
graphId: text("graph_id").notNull(),
|
|
326
|
-
agentId: text("agent_id").notNull(),
|
|
327
|
-
id: text("id").notNull(),
|
|
303
|
+
...agentScoped,
|
|
328
304
|
dataComponentId: text("data_component_id").notNull(),
|
|
329
305
|
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
330
306
|
},
|
|
@@ -347,15 +323,11 @@ var agentDataComponents = sqliteTable(
|
|
|
347
323
|
var artifactComponents = sqliteTable(
|
|
348
324
|
"artifact_components",
|
|
349
325
|
{
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
id: text("id").notNull(),
|
|
353
|
-
name: text("name").notNull(),
|
|
354
|
-
description: text("description").notNull(),
|
|
326
|
+
...projectScoped,
|
|
327
|
+
...uiProperties,
|
|
355
328
|
summaryProps: blob("summary_props", { mode: "json" }).$type(),
|
|
356
329
|
fullProps: blob("full_props", { mode: "json" }).$type(),
|
|
357
|
-
|
|
358
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
330
|
+
...timestamps
|
|
359
331
|
},
|
|
360
332
|
(table) => [
|
|
361
333
|
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -369,11 +341,7 @@ var artifactComponents = sqliteTable(
|
|
|
369
341
|
var agentArtifactComponents = sqliteTable(
|
|
370
342
|
"agent_artifact_components",
|
|
371
343
|
{
|
|
372
|
-
|
|
373
|
-
projectId: text("project_id").notNull(),
|
|
374
|
-
graphId: text("graph_id").notNull(),
|
|
375
|
-
agentId: text("agent_id").notNull(),
|
|
376
|
-
id: text("id").notNull(),
|
|
344
|
+
...agentScoped,
|
|
377
345
|
artifactComponentId: text("artifact_component_id").notNull(),
|
|
378
346
|
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
379
347
|
},
|
|
@@ -402,9 +370,7 @@ var agentArtifactComponents = sqliteTable(
|
|
|
402
370
|
var tools = sqliteTable(
|
|
403
371
|
"tools",
|
|
404
372
|
{
|
|
405
|
-
|
|
406
|
-
projectId: text("project_id").notNull(),
|
|
407
|
-
id: text("id").notNull(),
|
|
373
|
+
...projectScoped,
|
|
408
374
|
name: text("name").notNull(),
|
|
409
375
|
// Enhanced MCP configuration
|
|
410
376
|
config: blob("config", { mode: "json" }).$type().notNull(),
|
|
@@ -415,8 +381,7 @@ var tools = sqliteTable(
|
|
|
415
381
|
// Server capabilities and status
|
|
416
382
|
capabilities: blob("capabilities", { mode: "json" }).$type(),
|
|
417
383
|
lastError: text("last_error"),
|
|
418
|
-
|
|
419
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
384
|
+
...timestamps
|
|
420
385
|
},
|
|
421
386
|
(table) => [
|
|
422
387
|
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -430,16 +395,11 @@ var tools = sqliteTable(
|
|
|
430
395
|
var agentToolRelations = sqliteTable(
|
|
431
396
|
"agent_tool_relations",
|
|
432
397
|
{
|
|
433
|
-
|
|
434
|
-
projectId: text("project_id").notNull(),
|
|
435
|
-
graphId: text("graph_id").notNull(),
|
|
436
|
-
agentId: text("agent_id").notNull(),
|
|
437
|
-
id: text("id").notNull(),
|
|
398
|
+
...agentScoped,
|
|
438
399
|
toolId: text("tool_id").notNull(),
|
|
439
400
|
selectedTools: blob("selected_tools", { mode: "json" }).$type(),
|
|
440
401
|
headers: blob("headers", { mode: "json" }).$type(),
|
|
441
|
-
|
|
442
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
402
|
+
...timestamps
|
|
443
403
|
},
|
|
444
404
|
(table) => [
|
|
445
405
|
primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
|
|
@@ -460,16 +420,13 @@ var agentToolRelations = sqliteTable(
|
|
|
460
420
|
var conversations = sqliteTable(
|
|
461
421
|
"conversations",
|
|
462
422
|
{
|
|
463
|
-
|
|
464
|
-
projectId: text("project_id").notNull(),
|
|
465
|
-
id: text("id").notNull(),
|
|
423
|
+
...projectScoped,
|
|
466
424
|
userId: text("user_id"),
|
|
467
425
|
activeAgentId: text("active_agent_id").notNull(),
|
|
468
426
|
title: text("title"),
|
|
469
427
|
lastContextResolution: text("last_context_resolution"),
|
|
470
428
|
metadata: blob("metadata", { mode: "json" }).$type(),
|
|
471
|
-
|
|
472
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
429
|
+
...timestamps
|
|
473
430
|
},
|
|
474
431
|
(table) => [
|
|
475
432
|
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -483,9 +440,7 @@ var conversations = sqliteTable(
|
|
|
483
440
|
var messages = sqliteTable(
|
|
484
441
|
"messages",
|
|
485
442
|
{
|
|
486
|
-
|
|
487
|
-
projectId: text("project_id").notNull(),
|
|
488
|
-
id: text("id").notNull(),
|
|
443
|
+
...projectScoped,
|
|
489
444
|
conversationId: text("conversation_id").notNull(),
|
|
490
445
|
// Role mapping: user, agent, system (unified for both formats)
|
|
491
446
|
role: text("role").notNull(),
|
|
@@ -520,8 +475,7 @@ var messages = sqliteTable(
|
|
|
520
475
|
// A2A session identifier
|
|
521
476
|
// Metadata for extensions
|
|
522
477
|
metadata: blob("metadata", { mode: "json" }).$type(),
|
|
523
|
-
|
|
524
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
478
|
+
...timestamps
|
|
525
479
|
},
|
|
526
480
|
(table) => [
|
|
527
481
|
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -535,10 +489,7 @@ var messages = sqliteTable(
|
|
|
535
489
|
var ledgerArtifacts = sqliteTable(
|
|
536
490
|
"ledger_artifacts",
|
|
537
491
|
{
|
|
538
|
-
|
|
539
|
-
tenantId: text("tenant_id").notNull(),
|
|
540
|
-
projectId: text("project_id").notNull(),
|
|
541
|
-
id: text("id").notNull(),
|
|
492
|
+
...projectScoped,
|
|
542
493
|
// Links
|
|
543
494
|
taskId: text("task_id").notNull(),
|
|
544
495
|
toolCallId: text("tool_call_id"),
|
|
@@ -556,9 +507,7 @@ var ledgerArtifacts = sqliteTable(
|
|
|
556
507
|
visibility: text("visibility").default("context"),
|
|
557
508
|
allowedAgents: blob("allowed_agents", { mode: "json" }).$type(),
|
|
558
509
|
derivedFrom: text("derived_from"),
|
|
559
|
-
|
|
560
|
-
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
561
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
510
|
+
...timestamps
|
|
562
511
|
},
|
|
563
512
|
(table) => [
|
|
564
513
|
primaryKey({ columns: [table.tenantId, table.projectId, table.id, table.taskId] }),
|
|
@@ -566,16 +515,21 @@ var ledgerArtifacts = sqliteTable(
|
|
|
566
515
|
columns: [table.tenantId, table.projectId],
|
|
567
516
|
foreignColumns: [projects.tenantId, projects.id],
|
|
568
517
|
name: "ledger_artifacts_project_fk"
|
|
569
|
-
}).onDelete("cascade")
|
|
518
|
+
}).onDelete("cascade"),
|
|
519
|
+
index("ledger_artifacts_task_id_idx").on(table.taskId),
|
|
520
|
+
index("ledger_artifacts_tool_call_id_idx").on(table.toolCallId),
|
|
521
|
+
index("ledger_artifacts_context_id_idx").on(table.contextId),
|
|
522
|
+
unique("ledger_artifacts_task_context_name_unique").on(
|
|
523
|
+
table.taskId,
|
|
524
|
+
table.contextId,
|
|
525
|
+
table.name
|
|
526
|
+
)
|
|
570
527
|
]
|
|
571
528
|
);
|
|
572
529
|
var apiKeys = sqliteTable(
|
|
573
530
|
"api_keys",
|
|
574
531
|
{
|
|
575
|
-
|
|
576
|
-
tenantId: text("tenant_id").notNull(),
|
|
577
|
-
projectId: text("project_id").notNull(),
|
|
578
|
-
graphId: text("graph_id").notNull(),
|
|
532
|
+
...graphScoped,
|
|
579
533
|
publicId: text("public_id").notNull().unique(),
|
|
580
534
|
// Public ID for O(1) lookup (e.g., "abc123def456")
|
|
581
535
|
keyHash: text("key_hash").notNull(),
|
|
@@ -585,8 +539,7 @@ var apiKeys = sqliteTable(
|
|
|
585
539
|
name: text("name"),
|
|
586
540
|
lastUsedAt: text("last_used_at"),
|
|
587
541
|
expiresAt: text("expires_at"),
|
|
588
|
-
|
|
589
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
542
|
+
...timestamps
|
|
590
543
|
},
|
|
591
544
|
(t) => [
|
|
592
545
|
foreignKey({
|
|
@@ -607,16 +560,13 @@ var apiKeys = sqliteTable(
|
|
|
607
560
|
var credentialReferences = sqliteTable(
|
|
608
561
|
"credential_references",
|
|
609
562
|
{
|
|
610
|
-
|
|
611
|
-
projectId: text("project_id").notNull(),
|
|
612
|
-
id: text("id").notNull(),
|
|
563
|
+
...projectScoped,
|
|
613
564
|
type: text("type").notNull(),
|
|
614
565
|
// Implementation type: 'keychain', 'nango', 'memory', etc.
|
|
615
566
|
credentialStoreId: text("credential_store_id").notNull(),
|
|
616
567
|
// Maps to framework.getCredentialStore(id)
|
|
617
568
|
retrievalParams: blob("retrieval_params", { mode: "json" }).$type(),
|
|
618
|
-
|
|
619
|
-
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
569
|
+
...timestamps
|
|
620
570
|
},
|
|
621
571
|
(t) => [
|
|
622
572
|
primaryKey({ columns: [t.tenantId, t.projectId, t.id] }),
|
|
@@ -627,18 +577,6 @@ var credentialReferences = sqliteTable(
|
|
|
627
577
|
}).onDelete("cascade")
|
|
628
578
|
]
|
|
629
579
|
);
|
|
630
|
-
var ledgerArtifactsTaskIdIdx = index("ledger_artifacts_task_id_idx").on(
|
|
631
|
-
ledgerArtifacts.taskId
|
|
632
|
-
);
|
|
633
|
-
var ledgerArtifactsToolCallIdIdx = index("ledger_artifacts_tool_call_id_idx").on(
|
|
634
|
-
ledgerArtifacts.toolCallId
|
|
635
|
-
);
|
|
636
|
-
var ledgerArtifactsContextIdIdx = index("ledger_artifacts_context_id_idx").on(
|
|
637
|
-
ledgerArtifacts.contextId
|
|
638
|
-
);
|
|
639
|
-
var ledgerArtifactsTaskContextNameUnique = unique(
|
|
640
|
-
"ledger_artifacts_task_context_name_unique"
|
|
641
|
-
).on(ledgerArtifacts.taskId, ledgerArtifacts.contextId, ledgerArtifacts.name);
|
|
642
580
|
var tasksRelations = relations(tasks, ({ one, many }) => ({
|
|
643
581
|
// A task belongs to one project
|
|
644
582
|
project: one(projects, {
|
|
@@ -664,37 +602,24 @@ var tasksRelations = relations(tasks, ({ one, many }) => ({
|
|
|
664
602
|
ledgerArtifacts: many(ledgerArtifacts)
|
|
665
603
|
}));
|
|
666
604
|
var projectsRelations = relations(projects, ({ many }) => ({
|
|
667
|
-
// A project can have many agents
|
|
668
605
|
agents: many(agents),
|
|
669
|
-
// A project can have many agent graphs
|
|
670
606
|
agentGraphs: many(agentGraph),
|
|
671
|
-
// A project can have many tools
|
|
672
607
|
tools: many(tools),
|
|
673
|
-
// A project can have many context configs
|
|
674
608
|
contextConfigs: many(contextConfigs),
|
|
675
|
-
// A project can have many external agents
|
|
676
609
|
externalAgents: many(externalAgents),
|
|
677
|
-
// A project can have many conversations
|
|
678
610
|
conversations: many(conversations),
|
|
679
|
-
// A project can have many tasks
|
|
680
611
|
tasks: many(tasks),
|
|
681
|
-
// A project can have many data components
|
|
682
612
|
dataComponents: many(dataComponents),
|
|
683
|
-
// A project can have many artifact components
|
|
684
613
|
artifactComponents: many(artifactComponents),
|
|
685
|
-
// A project can have many ledger artifacts
|
|
686
614
|
ledgerArtifacts: many(ledgerArtifacts),
|
|
687
|
-
// A project can have many credential references
|
|
688
615
|
credentialReferences: many(credentialReferences)
|
|
689
616
|
}));
|
|
690
617
|
var taskRelationsRelations = relations(taskRelations, ({ one }) => ({
|
|
691
|
-
// Each relation has one parent task
|
|
692
618
|
parentTask: one(tasks, {
|
|
693
619
|
fields: [taskRelations.parentTaskId],
|
|
694
620
|
references: [tasks.id],
|
|
695
621
|
relationName: "parentTask"
|
|
696
622
|
}),
|
|
697
|
-
// Each relation has one child task
|
|
698
623
|
childTask: one(tasks, {
|
|
699
624
|
fields: [taskRelations.childTaskId],
|
|
700
625
|
references: [tasks.id],
|
|
@@ -702,107 +627,85 @@ var taskRelationsRelations = relations(taskRelations, ({ one }) => ({
|
|
|
702
627
|
})
|
|
703
628
|
}));
|
|
704
629
|
var contextConfigsRelations = relations(contextConfigs, ({ many, one }) => ({
|
|
705
|
-
// A context config belongs to one project
|
|
706
630
|
project: one(projects, {
|
|
707
631
|
fields: [contextConfigs.tenantId, contextConfigs.projectId],
|
|
708
632
|
references: [projects.tenantId, projects.id]
|
|
709
633
|
}),
|
|
710
|
-
// A context config can be used by many agent graphs
|
|
711
634
|
graphs: many(agentGraph),
|
|
712
|
-
// A context config can have many cached entries
|
|
713
635
|
cache: many(contextCache)
|
|
714
636
|
}));
|
|
715
637
|
var contextCacheRelations = relations(contextCache, ({ one }) => ({
|
|
716
|
-
// Each cache entry belongs to one context config
|
|
717
638
|
contextConfig: one(contextConfigs, {
|
|
718
639
|
fields: [contextCache.contextConfigId],
|
|
719
640
|
references: [contextConfigs.id]
|
|
720
641
|
})
|
|
721
642
|
}));
|
|
722
643
|
var agentsRelations = relations(agents, ({ many, one }) => ({
|
|
723
|
-
// A context config belongs to one project
|
|
724
644
|
project: one(projects, {
|
|
725
645
|
fields: [agents.tenantId, agents.projectId],
|
|
726
646
|
references: [projects.tenantId, projects.id]
|
|
727
647
|
}),
|
|
728
|
-
// An agent can have many tasks
|
|
729
648
|
tasks: many(tasks),
|
|
730
|
-
// An agent can be the default agent for many graphs
|
|
731
649
|
defaultForGraphs: many(agentGraph),
|
|
732
|
-
// Agent relation tracking
|
|
733
650
|
sourceRelations: many(agentRelations, {
|
|
734
651
|
relationName: "sourceRelations"
|
|
735
652
|
}),
|
|
736
653
|
targetRelations: many(agentRelations, {
|
|
737
654
|
relationName: "targetRelations"
|
|
738
655
|
}),
|
|
739
|
-
// Message tracking relations
|
|
740
656
|
sentMessages: many(messages, {
|
|
741
657
|
relationName: "sentMessages"
|
|
742
658
|
}),
|
|
743
659
|
receivedMessages: many(messages, {
|
|
744
660
|
relationName: "receivedMessages"
|
|
745
661
|
}),
|
|
746
|
-
// Legacy message association (consider deprecating)
|
|
747
662
|
associatedMessages: many(messages, {
|
|
748
663
|
relationName: "associatedAgent"
|
|
749
664
|
}),
|
|
750
665
|
toolRelations: many(agentToolRelations),
|
|
751
|
-
// Data component relations
|
|
752
666
|
dataComponentRelations: many(agentDataComponents),
|
|
753
|
-
// Artifact component relations
|
|
754
667
|
artifactComponentRelations: many(agentArtifactComponents)
|
|
755
668
|
}));
|
|
756
669
|
var agentGraphRelations = relations(agentGraph, ({ one }) => ({
|
|
757
|
-
// An agent graph belongs to one project
|
|
758
670
|
project: one(projects, {
|
|
759
671
|
fields: [agentGraph.tenantId, agentGraph.projectId],
|
|
760
672
|
references: [projects.tenantId, projects.id]
|
|
761
673
|
}),
|
|
762
|
-
// An agent graph may have one default agent (optional)
|
|
763
674
|
defaultAgent: one(agents, {
|
|
764
675
|
fields: [agentGraph.defaultAgentId],
|
|
765
676
|
references: [agents.id]
|
|
766
677
|
}),
|
|
767
|
-
// An agent graph can reference one context config
|
|
768
678
|
contextConfig: one(contextConfigs, {
|
|
769
679
|
fields: [agentGraph.contextConfigId],
|
|
770
680
|
references: [contextConfigs.id]
|
|
771
681
|
})
|
|
772
682
|
}));
|
|
773
683
|
var externalAgentsRelations = relations(externalAgents, ({ one, many }) => ({
|
|
774
|
-
// An external agent belongs to one project
|
|
775
684
|
project: one(projects, {
|
|
776
685
|
fields: [externalAgents.tenantId, externalAgents.projectId],
|
|
777
686
|
references: [projects.tenantId, projects.id]
|
|
778
687
|
}),
|
|
779
|
-
// An external agent can be referenced by many agent relations
|
|
780
688
|
agentRelations: many(agentRelations),
|
|
781
|
-
// An external agent may have one credential reference
|
|
782
689
|
credentialReference: one(credentialReferences, {
|
|
783
690
|
fields: [externalAgents.credentialReferenceId],
|
|
784
691
|
references: [credentialReferences.id]
|
|
785
692
|
})
|
|
786
693
|
}));
|
|
787
694
|
var apiKeysRelations = relations(apiKeys, ({ one }) => ({
|
|
788
|
-
// An API key belongs to one project
|
|
789
695
|
project: one(projects, {
|
|
790
696
|
fields: [apiKeys.tenantId, apiKeys.projectId],
|
|
791
697
|
references: [projects.tenantId, projects.id]
|
|
792
698
|
}),
|
|
793
|
-
// An API key belongs to one tenant and graph
|
|
794
699
|
graph: one(agentGraph, {
|
|
795
700
|
fields: [apiKeys.graphId],
|
|
796
701
|
references: [agentGraph.id]
|
|
797
702
|
})
|
|
798
703
|
}));
|
|
799
704
|
var agentToolRelationsRelations = relations(agentToolRelations, ({ one }) => ({
|
|
800
|
-
// An agent-tool relation belongs to one agent
|
|
801
705
|
agent: one(agents, {
|
|
802
706
|
fields: [agentToolRelations.agentId],
|
|
803
707
|
references: [agents.id]
|
|
804
708
|
}),
|
|
805
|
-
// An agent-tool relation belongs to one tool
|
|
806
709
|
tool: one(tools, {
|
|
807
710
|
fields: [agentToolRelations.toolId],
|
|
808
711
|
references: [tools.id]
|
|
@@ -812,35 +715,28 @@ var credentialReferencesRelations = relations(credentialReferences, ({ many }) =
|
|
|
812
715
|
tools: many(tools)
|
|
813
716
|
}));
|
|
814
717
|
var toolsRelations = relations(tools, ({ one, many }) => ({
|
|
815
|
-
// A tool belongs to one project
|
|
816
718
|
project: one(projects, {
|
|
817
719
|
fields: [tools.tenantId, tools.projectId],
|
|
818
720
|
references: [projects.tenantId, projects.id]
|
|
819
721
|
}),
|
|
820
|
-
// A tool can be used by many agents through agent-tool relations
|
|
821
722
|
agentRelations: many(agentToolRelations),
|
|
822
|
-
// A tool may have one credential reference
|
|
823
723
|
credentialReference: one(credentialReferences, {
|
|
824
724
|
fields: [tools.credentialReferenceId],
|
|
825
725
|
references: [credentialReferences.id]
|
|
826
726
|
})
|
|
827
727
|
}));
|
|
828
728
|
var conversationsRelations = relations(conversations, ({ one, many }) => ({
|
|
829
|
-
// A conversation belongs to one project
|
|
830
729
|
project: one(projects, {
|
|
831
730
|
fields: [conversations.tenantId, conversations.projectId],
|
|
832
731
|
references: [projects.tenantId, projects.id]
|
|
833
732
|
}),
|
|
834
|
-
// A conversation has many messages
|
|
835
733
|
messages: many(messages),
|
|
836
|
-
// A conversation has one active agent
|
|
837
734
|
activeAgent: one(agents, {
|
|
838
735
|
fields: [conversations.activeAgentId],
|
|
839
736
|
references: [agents.id]
|
|
840
737
|
})
|
|
841
738
|
}));
|
|
842
739
|
var messagesRelations = relations(messages, ({ one, many }) => ({
|
|
843
|
-
// A message belongs to one conversation
|
|
844
740
|
conversation: one(conversations, {
|
|
845
741
|
fields: [messages.conversationId],
|
|
846
742
|
references: [conversations.id]
|
|
@@ -851,118 +747,98 @@ var messagesRelations = relations(messages, ({ one, many }) => ({
|
|
|
851
747
|
references: [agents.id],
|
|
852
748
|
relationName: "associatedAgent"
|
|
853
749
|
}),
|
|
854
|
-
// Sender tracking relations
|
|
855
750
|
fromAgent: one(agents, {
|
|
856
751
|
fields: [messages.fromAgentId],
|
|
857
752
|
references: [agents.id],
|
|
858
753
|
relationName: "sentMessages"
|
|
859
754
|
}),
|
|
860
|
-
// Recipient tracking relations
|
|
861
755
|
toAgent: one(agents, {
|
|
862
756
|
fields: [messages.toAgentId],
|
|
863
757
|
references: [agents.id],
|
|
864
758
|
relationName: "receivedMessages"
|
|
865
759
|
}),
|
|
866
|
-
// External agent sender tracking relations
|
|
867
760
|
fromExternalAgent: one(externalAgents, {
|
|
868
761
|
fields: [messages.fromExternalAgentId],
|
|
869
762
|
references: [externalAgents.id],
|
|
870
763
|
relationName: "receivedExternalMessages"
|
|
871
764
|
}),
|
|
872
|
-
// External agent recipient tracking relations
|
|
873
765
|
toExternalAgent: one(externalAgents, {
|
|
874
766
|
fields: [messages.toExternalAgentId],
|
|
875
767
|
references: [externalAgents.id],
|
|
876
768
|
relationName: "sentExternalMessages"
|
|
877
769
|
}),
|
|
878
|
-
// A message may be associated with a task
|
|
879
770
|
task: one(tasks, {
|
|
880
771
|
fields: [messages.taskId],
|
|
881
772
|
references: [tasks.id]
|
|
882
773
|
}),
|
|
883
|
-
// A message may have a parent message (for threading)
|
|
884
774
|
parentMessage: one(messages, {
|
|
885
775
|
fields: [messages.parentMessageId],
|
|
886
776
|
references: [messages.id],
|
|
887
777
|
relationName: "parentChild"
|
|
888
778
|
}),
|
|
889
|
-
// A message may have child messages
|
|
890
779
|
childMessages: many(messages, {
|
|
891
780
|
relationName: "parentChild"
|
|
892
781
|
})
|
|
893
782
|
}));
|
|
894
783
|
var artifactComponentsRelations = relations(artifactComponents, ({ many }) => ({
|
|
895
|
-
// An artifact component can be associated with many agents
|
|
896
784
|
agentRelations: many(agentArtifactComponents)
|
|
897
785
|
}));
|
|
898
786
|
var agentArtifactComponentsRelations = relations(agentArtifactComponents, ({ one }) => ({
|
|
899
|
-
// An agent-artifact component relation belongs to one agent
|
|
900
787
|
agent: one(agents, {
|
|
901
788
|
fields: [agentArtifactComponents.agentId],
|
|
902
789
|
references: [agents.id]
|
|
903
790
|
}),
|
|
904
|
-
// An agent-artifact component relation belongs to one artifact component
|
|
905
791
|
artifactComponent: one(artifactComponents, {
|
|
906
792
|
fields: [agentArtifactComponents.artifactComponentId],
|
|
907
793
|
references: [artifactComponents.id]
|
|
908
794
|
})
|
|
909
795
|
}));
|
|
910
796
|
var dataComponentsRelations = relations(dataComponents, ({ many, one }) => ({
|
|
911
|
-
// A data component belongs to one project
|
|
912
797
|
project: one(projects, {
|
|
913
798
|
fields: [dataComponents.tenantId, dataComponents.projectId],
|
|
914
799
|
references: [projects.tenantId, projects.id]
|
|
915
800
|
}),
|
|
916
|
-
// A data component can be associated with many agents
|
|
917
801
|
agentRelations: many(agentDataComponents)
|
|
918
802
|
}));
|
|
919
803
|
var agentDataComponentsRelations = relations(agentDataComponents, ({ one }) => ({
|
|
920
|
-
// An agent-data component relation belongs to one agent
|
|
921
804
|
agent: one(agents, {
|
|
922
805
|
fields: [agentDataComponents.agentId],
|
|
923
806
|
references: [agents.id]
|
|
924
807
|
}),
|
|
925
|
-
// An agent-data component relation belongs to one data component
|
|
926
808
|
dataComponent: one(dataComponents, {
|
|
927
809
|
fields: [agentDataComponents.dataComponentId],
|
|
928
810
|
references: [dataComponents.id]
|
|
929
811
|
})
|
|
930
812
|
}));
|
|
931
813
|
var ledgerArtifactsRelations = relations(ledgerArtifacts, ({ one }) => ({
|
|
932
|
-
// A ledger artifact belongs to one project
|
|
933
814
|
project: one(projects, {
|
|
934
815
|
fields: [ledgerArtifacts.tenantId, ledgerArtifacts.projectId],
|
|
935
816
|
references: [projects.tenantId, projects.id]
|
|
936
817
|
}),
|
|
937
|
-
// A ledger artifact may be associated with one task
|
|
938
818
|
task: one(tasks, {
|
|
939
819
|
fields: [ledgerArtifacts.taskId],
|
|
940
820
|
references: [tasks.id]
|
|
941
821
|
})
|
|
942
822
|
}));
|
|
943
823
|
var agentRelationsRelations = relations(agentRelations, ({ one }) => ({
|
|
944
|
-
// An agent relation belongs to one graph
|
|
945
824
|
graph: one(agentGraph, {
|
|
946
825
|
fields: [agentRelations.graphId],
|
|
947
826
|
references: [agentGraph.id]
|
|
948
827
|
}),
|
|
949
|
-
// An agent relation has one source agent
|
|
950
828
|
sourceAgent: one(agents, {
|
|
951
829
|
fields: [agentRelations.sourceAgentId],
|
|
952
830
|
references: [agents.id],
|
|
953
831
|
relationName: "sourceRelations"
|
|
954
832
|
}),
|
|
955
|
-
// An agent relation may have one target agent (for internal relations)
|
|
956
833
|
targetAgent: one(agents, {
|
|
957
834
|
fields: [agentRelations.targetAgentId],
|
|
958
835
|
references: [agents.id],
|
|
959
836
|
relationName: "targetRelations"
|
|
960
837
|
}),
|
|
961
|
-
// An agent relation may have one external agent (for external relations)
|
|
962
838
|
externalAgent: one(externalAgents, {
|
|
963
839
|
fields: [agentRelations.externalAgentId],
|
|
964
840
|
references: [externalAgents.id]
|
|
965
841
|
})
|
|
966
842
|
}));
|
|
967
843
|
|
|
968
|
-
export { agentArtifactComponents, agentArtifactComponentsRelations, agentDataComponents, agentDataComponentsRelations, agentGraph, agentGraphRelations, agentRelations, agentRelationsRelations, agentToolRelations, agentToolRelationsRelations, agents, agentsRelations, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, ledgerArtifacts,
|
|
844
|
+
export { agentArtifactComponents, agentArtifactComponentsRelations, agentDataComponents, agentDataComponentsRelations, agentGraph, agentGraphRelations, agentRelations, agentRelationsRelations, agentToolRelations, agentToolRelationsRelations, agents, agentsRelations, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, ledgerArtifacts, ledgerArtifactsRelations, messages, messagesRelations, projects, projectsRelations, schema_exports, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations };
|