@inkeep/agents-core 0.10.2 → 0.11.1
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
|
@@ -6,29 +6,47 @@ var drizzleOrm = require('drizzle-orm');
|
|
|
6
6
|
var sqliteCore = require('drizzle-orm/sqlite-core');
|
|
7
7
|
|
|
8
8
|
// src/validation/schemas.ts
|
|
9
|
+
var tenantScoped = {
|
|
10
|
+
tenantId: sqliteCore.text("tenant_id").notNull(),
|
|
11
|
+
id: sqliteCore.text("id").notNull()
|
|
12
|
+
};
|
|
13
|
+
var projectScoped = {
|
|
14
|
+
...tenantScoped,
|
|
15
|
+
projectId: sqliteCore.text("project_id").notNull()
|
|
16
|
+
};
|
|
17
|
+
var graphScoped = {
|
|
18
|
+
...projectScoped,
|
|
19
|
+
graphId: sqliteCore.text("graph_id").notNull()
|
|
20
|
+
};
|
|
21
|
+
var agentScoped = {
|
|
22
|
+
...graphScoped,
|
|
23
|
+
agentId: sqliteCore.text("agent_id").notNull()
|
|
24
|
+
};
|
|
25
|
+
var uiProperties = {
|
|
26
|
+
name: sqliteCore.text("name").notNull(),
|
|
27
|
+
description: sqliteCore.text("description").notNull()
|
|
28
|
+
};
|
|
29
|
+
var timestamps = {
|
|
30
|
+
createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
|
|
31
|
+
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
32
|
+
};
|
|
9
33
|
var projects = sqliteCore.sqliteTable(
|
|
10
34
|
"projects",
|
|
11
35
|
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// This IS the project ID
|
|
15
|
-
name: sqliteCore.text("name").notNull(),
|
|
16
|
-
description: sqliteCore.text("description").notNull(),
|
|
36
|
+
...tenantScoped,
|
|
37
|
+
...uiProperties,
|
|
17
38
|
// Project-level default model settings that can be inherited by graphs and agents
|
|
18
39
|
models: sqliteCore.text("models", { mode: "json" }).$type(),
|
|
19
40
|
// Project-level stopWhen configuration that can be inherited by graphs and agents
|
|
20
41
|
stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
|
|
21
|
-
|
|
22
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
42
|
+
...timestamps
|
|
23
43
|
},
|
|
24
44
|
(table) => [sqliteCore.primaryKey({ columns: [table.tenantId, table.id] })]
|
|
25
45
|
);
|
|
26
46
|
var agentGraph = sqliteCore.sqliteTable(
|
|
27
47
|
"agent_graph",
|
|
28
48
|
{
|
|
29
|
-
|
|
30
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
31
|
-
id: sqliteCore.text("id").notNull(),
|
|
49
|
+
...projectScoped,
|
|
32
50
|
name: sqliteCore.text("name").notNull(),
|
|
33
51
|
description: sqliteCore.text("description"),
|
|
34
52
|
defaultAgentId: sqliteCore.text("default_agent_id"),
|
|
@@ -43,8 +61,7 @@ var agentGraph = sqliteCore.sqliteTable(
|
|
|
43
61
|
graphPrompt: sqliteCore.text("graph_prompt"),
|
|
44
62
|
// Graph-level stopWhen configuration that can be inherited by agents
|
|
45
63
|
stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
|
|
46
|
-
|
|
47
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
64
|
+
...timestamps
|
|
48
65
|
},
|
|
49
66
|
(table) => [
|
|
50
67
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -58,19 +75,14 @@ var agentGraph = sqliteCore.sqliteTable(
|
|
|
58
75
|
var contextConfigs = sqliteCore.sqliteTable(
|
|
59
76
|
"context_configs",
|
|
60
77
|
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// Add graph level scoping
|
|
64
|
-
id: sqliteCore.text("id").notNull(),
|
|
65
|
-
name: sqliteCore.text("name").notNull(),
|
|
66
|
-
description: sqliteCore.text("description").notNull(),
|
|
78
|
+
...projectScoped,
|
|
79
|
+
...uiProperties,
|
|
67
80
|
// Developer-defined Zod schema for validating incoming request context
|
|
68
81
|
requestContextSchema: sqliteCore.blob("request_context_schema", { mode: "json" }).$type(),
|
|
69
82
|
// Stores serialized Zod schema
|
|
70
83
|
// Object mapping template keys to fetch definitions that use request context data
|
|
71
84
|
contextVariables: sqliteCore.blob("context_variables", { mode: "json" }).$type(),
|
|
72
|
-
|
|
73
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
85
|
+
...timestamps
|
|
74
86
|
},
|
|
75
87
|
(table) => [
|
|
76
88
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -84,9 +96,7 @@ var contextConfigs = sqliteCore.sqliteTable(
|
|
|
84
96
|
var contextCache = sqliteCore.sqliteTable(
|
|
85
97
|
"context_cache",
|
|
86
98
|
{
|
|
87
|
-
|
|
88
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
89
|
-
id: sqliteCore.text("id").notNull(),
|
|
99
|
+
...projectScoped,
|
|
90
100
|
// Always scoped to conversation for complete data isolation
|
|
91
101
|
conversationId: sqliteCore.text("conversation_id").notNull(),
|
|
92
102
|
// Reference to the context config and specific fetch definition
|
|
@@ -103,8 +113,7 @@ var contextCache = sqliteCore.sqliteTable(
|
|
|
103
113
|
fetchSource: sqliteCore.text("fetch_source"),
|
|
104
114
|
// URL or source identifier
|
|
105
115
|
fetchDurationMs: sqliteCore.integer("fetch_duration_ms"),
|
|
106
|
-
|
|
107
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
116
|
+
...timestamps
|
|
108
117
|
},
|
|
109
118
|
(table) => [
|
|
110
119
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -123,12 +132,8 @@ var contextCache = sqliteCore.sqliteTable(
|
|
|
123
132
|
var agents = sqliteCore.sqliteTable(
|
|
124
133
|
"agents",
|
|
125
134
|
{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
graphId: sqliteCore.text("graph_id").notNull(),
|
|
129
|
-
id: sqliteCore.text("id").notNull(),
|
|
130
|
-
name: sqliteCore.text("name").notNull(),
|
|
131
|
-
description: sqliteCore.text("description").notNull(),
|
|
135
|
+
...graphScoped,
|
|
136
|
+
...uiProperties,
|
|
132
137
|
prompt: sqliteCore.text("prompt").notNull(),
|
|
133
138
|
conversationHistoryConfig: sqliteCore.text("conversation_history_config", {
|
|
134
139
|
mode: "json"
|
|
@@ -136,8 +141,7 @@ var agents = sqliteCore.sqliteTable(
|
|
|
136
141
|
models: sqliteCore.text("models", { mode: "json" }).$type(),
|
|
137
142
|
// Agent-level stopWhen configuration (inherited from project)
|
|
138
143
|
stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
|
|
139
|
-
|
|
140
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
144
|
+
...timestamps
|
|
141
145
|
},
|
|
142
146
|
(table) => [
|
|
143
147
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
|
|
@@ -151,10 +155,7 @@ var agents = sqliteCore.sqliteTable(
|
|
|
151
155
|
var agentRelations = sqliteCore.sqliteTable(
|
|
152
156
|
"agent_relations",
|
|
153
157
|
{
|
|
154
|
-
|
|
155
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
156
|
-
graphId: sqliteCore.text("graph_id").notNull(),
|
|
157
|
-
id: sqliteCore.text("id").notNull(),
|
|
158
|
+
...graphScoped,
|
|
158
159
|
sourceAgentId: sqliteCore.text("source_agent_id").notNull(),
|
|
159
160
|
// For internal relationships
|
|
160
161
|
targetAgentId: sqliteCore.text("target_agent_id"),
|
|
@@ -162,8 +163,7 @@ var agentRelations = sqliteCore.sqliteTable(
|
|
|
162
163
|
externalAgentId: sqliteCore.text("external_agent_id"),
|
|
163
164
|
relationType: sqliteCore.text("relation_type"),
|
|
164
165
|
// 'transfer' | 'delegate'
|
|
165
|
-
|
|
166
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
166
|
+
...timestamps
|
|
167
167
|
},
|
|
168
168
|
(table) => [
|
|
169
169
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
|
|
@@ -177,18 +177,13 @@ var agentRelations = sqliteCore.sqliteTable(
|
|
|
177
177
|
var externalAgents = sqliteCore.sqliteTable(
|
|
178
178
|
"external_agents",
|
|
179
179
|
{
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
graphId: sqliteCore.text("graph_id").notNull(),
|
|
183
|
-
id: sqliteCore.text("id").notNull(),
|
|
184
|
-
name: sqliteCore.text("name").notNull(),
|
|
185
|
-
description: sqliteCore.text("description").notNull(),
|
|
180
|
+
...graphScoped,
|
|
181
|
+
...uiProperties,
|
|
186
182
|
baseUrl: sqliteCore.text("base_url").notNull(),
|
|
187
183
|
// A2A endpoint URL
|
|
188
184
|
credentialReferenceId: sqliteCore.text("credential_reference_id"),
|
|
189
185
|
headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
|
|
190
|
-
|
|
191
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
186
|
+
...timestamps
|
|
192
187
|
},
|
|
193
188
|
(table) => [
|
|
194
189
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
|
|
@@ -211,37 +206,30 @@ var externalAgents = sqliteCore.sqliteTable(
|
|
|
211
206
|
var tasks = sqliteCore.sqliteTable(
|
|
212
207
|
"tasks",
|
|
213
208
|
{
|
|
214
|
-
|
|
215
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
216
|
-
id: sqliteCore.text("id").notNull(),
|
|
209
|
+
...agentScoped,
|
|
217
210
|
contextId: sqliteCore.text("context_id").notNull(),
|
|
218
211
|
status: sqliteCore.text("status").notNull(),
|
|
219
212
|
metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
|
|
220
|
-
|
|
221
|
-
createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
|
|
222
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
213
|
+
...timestamps
|
|
223
214
|
},
|
|
224
215
|
(table) => [
|
|
225
216
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
226
217
|
sqliteCore.foreignKey({
|
|
227
|
-
columns: [table.tenantId, table.projectId],
|
|
228
|
-
foreignColumns: [
|
|
229
|
-
name: "
|
|
218
|
+
columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
|
|
219
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
|
|
220
|
+
name: "tasks_agent_fk"
|
|
230
221
|
}).onDelete("cascade")
|
|
231
222
|
]
|
|
232
223
|
);
|
|
233
224
|
var taskRelations = sqliteCore.sqliteTable(
|
|
234
225
|
"task_relations",
|
|
235
226
|
{
|
|
236
|
-
|
|
237
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
238
|
-
id: sqliteCore.text("id").notNull(),
|
|
227
|
+
...projectScoped,
|
|
239
228
|
parentTaskId: sqliteCore.text("parent_task_id").notNull(),
|
|
240
229
|
childTaskId: sqliteCore.text("child_task_id").notNull(),
|
|
241
230
|
relationType: sqliteCore.text("relation_type").default("parent_child"),
|
|
242
231
|
// Could be extended for other relation types
|
|
243
|
-
|
|
244
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
232
|
+
...timestamps
|
|
245
233
|
},
|
|
246
234
|
(table) => [
|
|
247
235
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -255,14 +243,10 @@ var taskRelations = sqliteCore.sqliteTable(
|
|
|
255
243
|
var dataComponents = sqliteCore.sqliteTable(
|
|
256
244
|
"data_components",
|
|
257
245
|
{
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
id: sqliteCore.text("id").notNull(),
|
|
261
|
-
name: sqliteCore.text("name").notNull(),
|
|
262
|
-
description: sqliteCore.text("description").notNull(),
|
|
246
|
+
...projectScoped,
|
|
247
|
+
...uiProperties,
|
|
263
248
|
props: sqliteCore.blob("props", { mode: "json" }).$type(),
|
|
264
|
-
|
|
265
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
249
|
+
...timestamps
|
|
266
250
|
},
|
|
267
251
|
(table) => [
|
|
268
252
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -276,11 +260,7 @@ var dataComponents = sqliteCore.sqliteTable(
|
|
|
276
260
|
var agentDataComponents = sqliteCore.sqliteTable(
|
|
277
261
|
"agent_data_components",
|
|
278
262
|
{
|
|
279
|
-
|
|
280
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
281
|
-
graphId: sqliteCore.text("graph_id").notNull(),
|
|
282
|
-
agentId: sqliteCore.text("agent_id").notNull(),
|
|
283
|
-
id: sqliteCore.text("id").notNull(),
|
|
263
|
+
...agentScoped,
|
|
284
264
|
dataComponentId: sqliteCore.text("data_component_id").notNull(),
|
|
285
265
|
createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
286
266
|
},
|
|
@@ -303,15 +283,11 @@ var agentDataComponents = sqliteCore.sqliteTable(
|
|
|
303
283
|
var artifactComponents = sqliteCore.sqliteTable(
|
|
304
284
|
"artifact_components",
|
|
305
285
|
{
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
id: sqliteCore.text("id").notNull(),
|
|
309
|
-
name: sqliteCore.text("name").notNull(),
|
|
310
|
-
description: sqliteCore.text("description").notNull(),
|
|
286
|
+
...projectScoped,
|
|
287
|
+
...uiProperties,
|
|
311
288
|
summaryProps: sqliteCore.blob("summary_props", { mode: "json" }).$type(),
|
|
312
289
|
fullProps: sqliteCore.blob("full_props", { mode: "json" }).$type(),
|
|
313
|
-
|
|
314
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
290
|
+
...timestamps
|
|
315
291
|
},
|
|
316
292
|
(table) => [
|
|
317
293
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -325,11 +301,7 @@ var artifactComponents = sqliteCore.sqliteTable(
|
|
|
325
301
|
var agentArtifactComponents = sqliteCore.sqliteTable(
|
|
326
302
|
"agent_artifact_components",
|
|
327
303
|
{
|
|
328
|
-
|
|
329
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
330
|
-
graphId: sqliteCore.text("graph_id").notNull(),
|
|
331
|
-
agentId: sqliteCore.text("agent_id").notNull(),
|
|
332
|
-
id: sqliteCore.text("id").notNull(),
|
|
304
|
+
...agentScoped,
|
|
333
305
|
artifactComponentId: sqliteCore.text("artifact_component_id").notNull(),
|
|
334
306
|
createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
335
307
|
},
|
|
@@ -358,9 +330,7 @@ var agentArtifactComponents = sqliteCore.sqliteTable(
|
|
|
358
330
|
var tools = sqliteCore.sqliteTable(
|
|
359
331
|
"tools",
|
|
360
332
|
{
|
|
361
|
-
|
|
362
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
363
|
-
id: sqliteCore.text("id").notNull(),
|
|
333
|
+
...projectScoped,
|
|
364
334
|
name: sqliteCore.text("name").notNull(),
|
|
365
335
|
// Enhanced MCP configuration
|
|
366
336
|
config: sqliteCore.blob("config", { mode: "json" }).$type().notNull(),
|
|
@@ -371,8 +341,7 @@ var tools = sqliteCore.sqliteTable(
|
|
|
371
341
|
// Server capabilities and status
|
|
372
342
|
capabilities: sqliteCore.blob("capabilities", { mode: "json" }).$type(),
|
|
373
343
|
lastError: sqliteCore.text("last_error"),
|
|
374
|
-
|
|
375
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
344
|
+
...timestamps
|
|
376
345
|
},
|
|
377
346
|
(table) => [
|
|
378
347
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -386,16 +355,11 @@ var tools = sqliteCore.sqliteTable(
|
|
|
386
355
|
var agentToolRelations = sqliteCore.sqliteTable(
|
|
387
356
|
"agent_tool_relations",
|
|
388
357
|
{
|
|
389
|
-
|
|
390
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
391
|
-
graphId: sqliteCore.text("graph_id").notNull(),
|
|
392
|
-
agentId: sqliteCore.text("agent_id").notNull(),
|
|
393
|
-
id: sqliteCore.text("id").notNull(),
|
|
358
|
+
...agentScoped,
|
|
394
359
|
toolId: sqliteCore.text("tool_id").notNull(),
|
|
395
360
|
selectedTools: sqliteCore.blob("selected_tools", { mode: "json" }).$type(),
|
|
396
361
|
headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
|
|
397
|
-
|
|
398
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
362
|
+
...timestamps
|
|
399
363
|
},
|
|
400
364
|
(table) => [
|
|
401
365
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
|
|
@@ -416,16 +380,13 @@ var agentToolRelations = sqliteCore.sqliteTable(
|
|
|
416
380
|
var conversations = sqliteCore.sqliteTable(
|
|
417
381
|
"conversations",
|
|
418
382
|
{
|
|
419
|
-
|
|
420
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
421
|
-
id: sqliteCore.text("id").notNull(),
|
|
383
|
+
...projectScoped,
|
|
422
384
|
userId: sqliteCore.text("user_id"),
|
|
423
385
|
activeAgentId: sqliteCore.text("active_agent_id").notNull(),
|
|
424
386
|
title: sqliteCore.text("title"),
|
|
425
387
|
lastContextResolution: sqliteCore.text("last_context_resolution"),
|
|
426
388
|
metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
|
|
427
|
-
|
|
428
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
389
|
+
...timestamps
|
|
429
390
|
},
|
|
430
391
|
(table) => [
|
|
431
392
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -439,9 +400,7 @@ var conversations = sqliteCore.sqliteTable(
|
|
|
439
400
|
var messages = sqliteCore.sqliteTable(
|
|
440
401
|
"messages",
|
|
441
402
|
{
|
|
442
|
-
|
|
443
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
444
|
-
id: sqliteCore.text("id").notNull(),
|
|
403
|
+
...projectScoped,
|
|
445
404
|
conversationId: sqliteCore.text("conversation_id").notNull(),
|
|
446
405
|
// Role mapping: user, agent, system (unified for both formats)
|
|
447
406
|
role: sqliteCore.text("role").notNull(),
|
|
@@ -476,8 +435,7 @@ var messages = sqliteCore.sqliteTable(
|
|
|
476
435
|
// A2A session identifier
|
|
477
436
|
// Metadata for extensions
|
|
478
437
|
metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
|
|
479
|
-
|
|
480
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
438
|
+
...timestamps
|
|
481
439
|
},
|
|
482
440
|
(table) => [
|
|
483
441
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
@@ -491,10 +449,7 @@ var messages = sqliteCore.sqliteTable(
|
|
|
491
449
|
var ledgerArtifacts = sqliteCore.sqliteTable(
|
|
492
450
|
"ledger_artifacts",
|
|
493
451
|
{
|
|
494
|
-
|
|
495
|
-
tenantId: sqliteCore.text("tenant_id").notNull(),
|
|
496
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
497
|
-
id: sqliteCore.text("id").notNull(),
|
|
452
|
+
...projectScoped,
|
|
498
453
|
// Links
|
|
499
454
|
taskId: sqliteCore.text("task_id").notNull(),
|
|
500
455
|
toolCallId: sqliteCore.text("tool_call_id"),
|
|
@@ -512,9 +467,7 @@ var ledgerArtifacts = sqliteCore.sqliteTable(
|
|
|
512
467
|
visibility: sqliteCore.text("visibility").default("context"),
|
|
513
468
|
allowedAgents: sqliteCore.blob("allowed_agents", { mode: "json" }).$type(),
|
|
514
469
|
derivedFrom: sqliteCore.text("derived_from"),
|
|
515
|
-
|
|
516
|
-
createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
|
|
517
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
470
|
+
...timestamps
|
|
518
471
|
},
|
|
519
472
|
(table) => [
|
|
520
473
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id, table.taskId] }),
|
|
@@ -522,16 +475,21 @@ var ledgerArtifacts = sqliteCore.sqliteTable(
|
|
|
522
475
|
columns: [table.tenantId, table.projectId],
|
|
523
476
|
foreignColumns: [projects.tenantId, projects.id],
|
|
524
477
|
name: "ledger_artifacts_project_fk"
|
|
525
|
-
}).onDelete("cascade")
|
|
478
|
+
}).onDelete("cascade"),
|
|
479
|
+
sqliteCore.index("ledger_artifacts_task_id_idx").on(table.taskId),
|
|
480
|
+
sqliteCore.index("ledger_artifacts_tool_call_id_idx").on(table.toolCallId),
|
|
481
|
+
sqliteCore.index("ledger_artifacts_context_id_idx").on(table.contextId),
|
|
482
|
+
sqliteCore.unique("ledger_artifacts_task_context_name_unique").on(
|
|
483
|
+
table.taskId,
|
|
484
|
+
table.contextId,
|
|
485
|
+
table.name
|
|
486
|
+
)
|
|
526
487
|
]
|
|
527
488
|
);
|
|
528
489
|
var apiKeys = sqliteCore.sqliteTable(
|
|
529
490
|
"api_keys",
|
|
530
491
|
{
|
|
531
|
-
|
|
532
|
-
tenantId: sqliteCore.text("tenant_id").notNull(),
|
|
533
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
534
|
-
graphId: sqliteCore.text("graph_id").notNull(),
|
|
492
|
+
...graphScoped,
|
|
535
493
|
publicId: sqliteCore.text("public_id").notNull().unique(),
|
|
536
494
|
// Public ID for O(1) lookup (e.g., "abc123def456")
|
|
537
495
|
keyHash: sqliteCore.text("key_hash").notNull(),
|
|
@@ -541,8 +499,7 @@ var apiKeys = sqliteCore.sqliteTable(
|
|
|
541
499
|
name: sqliteCore.text("name"),
|
|
542
500
|
lastUsedAt: sqliteCore.text("last_used_at"),
|
|
543
501
|
expiresAt: sqliteCore.text("expires_at"),
|
|
544
|
-
|
|
545
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
502
|
+
...timestamps
|
|
546
503
|
},
|
|
547
504
|
(t) => [
|
|
548
505
|
sqliteCore.foreignKey({
|
|
@@ -563,16 +520,13 @@ var apiKeys = sqliteCore.sqliteTable(
|
|
|
563
520
|
var credentialReferences = sqliteCore.sqliteTable(
|
|
564
521
|
"credential_references",
|
|
565
522
|
{
|
|
566
|
-
|
|
567
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
568
|
-
id: sqliteCore.text("id").notNull(),
|
|
523
|
+
...projectScoped,
|
|
569
524
|
type: sqliteCore.text("type").notNull(),
|
|
570
525
|
// Implementation type: 'keychain', 'nango', 'memory', etc.
|
|
571
526
|
credentialStoreId: sqliteCore.text("credential_store_id").notNull(),
|
|
572
527
|
// Maps to framework.getCredentialStore(id)
|
|
573
528
|
retrievalParams: sqliteCore.blob("retrieval_params", { mode: "json" }).$type(),
|
|
574
|
-
|
|
575
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
529
|
+
...timestamps
|
|
576
530
|
},
|
|
577
531
|
(t) => [
|
|
578
532
|
sqliteCore.primaryKey({ columns: [t.tenantId, t.projectId, t.id] }),
|
|
@@ -583,18 +537,6 @@ var credentialReferences = sqliteCore.sqliteTable(
|
|
|
583
537
|
}).onDelete("cascade")
|
|
584
538
|
]
|
|
585
539
|
);
|
|
586
|
-
sqliteCore.index("ledger_artifacts_task_id_idx").on(
|
|
587
|
-
ledgerArtifacts.taskId
|
|
588
|
-
);
|
|
589
|
-
sqliteCore.index("ledger_artifacts_tool_call_id_idx").on(
|
|
590
|
-
ledgerArtifacts.toolCallId
|
|
591
|
-
);
|
|
592
|
-
sqliteCore.index("ledger_artifacts_context_id_idx").on(
|
|
593
|
-
ledgerArtifacts.contextId
|
|
594
|
-
);
|
|
595
|
-
sqliteCore.unique(
|
|
596
|
-
"ledger_artifacts_task_context_name_unique"
|
|
597
|
-
).on(ledgerArtifacts.taskId, ledgerArtifacts.contextId, ledgerArtifacts.name);
|
|
598
540
|
drizzleOrm.relations(tasks, ({ one, many }) => ({
|
|
599
541
|
// A task belongs to one project
|
|
600
542
|
project: one(projects, {
|
|
@@ -620,37 +562,24 @@ drizzleOrm.relations(tasks, ({ one, many }) => ({
|
|
|
620
562
|
ledgerArtifacts: many(ledgerArtifacts)
|
|
621
563
|
}));
|
|
622
564
|
drizzleOrm.relations(projects, ({ many }) => ({
|
|
623
|
-
// A project can have many agents
|
|
624
565
|
agents: many(agents),
|
|
625
|
-
// A project can have many agent graphs
|
|
626
566
|
agentGraphs: many(agentGraph),
|
|
627
|
-
// A project can have many tools
|
|
628
567
|
tools: many(tools),
|
|
629
|
-
// A project can have many context configs
|
|
630
568
|
contextConfigs: many(contextConfigs),
|
|
631
|
-
// A project can have many external agents
|
|
632
569
|
externalAgents: many(externalAgents),
|
|
633
|
-
// A project can have many conversations
|
|
634
570
|
conversations: many(conversations),
|
|
635
|
-
// A project can have many tasks
|
|
636
571
|
tasks: many(tasks),
|
|
637
|
-
// A project can have many data components
|
|
638
572
|
dataComponents: many(dataComponents),
|
|
639
|
-
// A project can have many artifact components
|
|
640
573
|
artifactComponents: many(artifactComponents),
|
|
641
|
-
// A project can have many ledger artifacts
|
|
642
574
|
ledgerArtifacts: many(ledgerArtifacts),
|
|
643
|
-
// A project can have many credential references
|
|
644
575
|
credentialReferences: many(credentialReferences)
|
|
645
576
|
}));
|
|
646
577
|
drizzleOrm.relations(taskRelations, ({ one }) => ({
|
|
647
|
-
// Each relation has one parent task
|
|
648
578
|
parentTask: one(tasks, {
|
|
649
579
|
fields: [taskRelations.parentTaskId],
|
|
650
580
|
references: [tasks.id],
|
|
651
581
|
relationName: "parentTask"
|
|
652
582
|
}),
|
|
653
|
-
// Each relation has one child task
|
|
654
583
|
childTask: one(tasks, {
|
|
655
584
|
fields: [taskRelations.childTaskId],
|
|
656
585
|
references: [tasks.id],
|
|
@@ -658,107 +587,85 @@ drizzleOrm.relations(taskRelations, ({ one }) => ({
|
|
|
658
587
|
})
|
|
659
588
|
}));
|
|
660
589
|
drizzleOrm.relations(contextConfigs, ({ many, one }) => ({
|
|
661
|
-
// A context config belongs to one project
|
|
662
590
|
project: one(projects, {
|
|
663
591
|
fields: [contextConfigs.tenantId, contextConfigs.projectId],
|
|
664
592
|
references: [projects.tenantId, projects.id]
|
|
665
593
|
}),
|
|
666
|
-
// A context config can be used by many agent graphs
|
|
667
594
|
graphs: many(agentGraph),
|
|
668
|
-
// A context config can have many cached entries
|
|
669
595
|
cache: many(contextCache)
|
|
670
596
|
}));
|
|
671
597
|
drizzleOrm.relations(contextCache, ({ one }) => ({
|
|
672
|
-
// Each cache entry belongs to one context config
|
|
673
598
|
contextConfig: one(contextConfigs, {
|
|
674
599
|
fields: [contextCache.contextConfigId],
|
|
675
600
|
references: [contextConfigs.id]
|
|
676
601
|
})
|
|
677
602
|
}));
|
|
678
603
|
drizzleOrm.relations(agents, ({ many, one }) => ({
|
|
679
|
-
// A context config belongs to one project
|
|
680
604
|
project: one(projects, {
|
|
681
605
|
fields: [agents.tenantId, agents.projectId],
|
|
682
606
|
references: [projects.tenantId, projects.id]
|
|
683
607
|
}),
|
|
684
|
-
// An agent can have many tasks
|
|
685
608
|
tasks: many(tasks),
|
|
686
|
-
// An agent can be the default agent for many graphs
|
|
687
609
|
defaultForGraphs: many(agentGraph),
|
|
688
|
-
// Agent relation tracking
|
|
689
610
|
sourceRelations: many(agentRelations, {
|
|
690
611
|
relationName: "sourceRelations"
|
|
691
612
|
}),
|
|
692
613
|
targetRelations: many(agentRelations, {
|
|
693
614
|
relationName: "targetRelations"
|
|
694
615
|
}),
|
|
695
|
-
// Message tracking relations
|
|
696
616
|
sentMessages: many(messages, {
|
|
697
617
|
relationName: "sentMessages"
|
|
698
618
|
}),
|
|
699
619
|
receivedMessages: many(messages, {
|
|
700
620
|
relationName: "receivedMessages"
|
|
701
621
|
}),
|
|
702
|
-
// Legacy message association (consider deprecating)
|
|
703
622
|
associatedMessages: many(messages, {
|
|
704
623
|
relationName: "associatedAgent"
|
|
705
624
|
}),
|
|
706
625
|
toolRelations: many(agentToolRelations),
|
|
707
|
-
// Data component relations
|
|
708
626
|
dataComponentRelations: many(agentDataComponents),
|
|
709
|
-
// Artifact component relations
|
|
710
627
|
artifactComponentRelations: many(agentArtifactComponents)
|
|
711
628
|
}));
|
|
712
629
|
drizzleOrm.relations(agentGraph, ({ one }) => ({
|
|
713
|
-
// An agent graph belongs to one project
|
|
714
630
|
project: one(projects, {
|
|
715
631
|
fields: [agentGraph.tenantId, agentGraph.projectId],
|
|
716
632
|
references: [projects.tenantId, projects.id]
|
|
717
633
|
}),
|
|
718
|
-
// An agent graph may have one default agent (optional)
|
|
719
634
|
defaultAgent: one(agents, {
|
|
720
635
|
fields: [agentGraph.defaultAgentId],
|
|
721
636
|
references: [agents.id]
|
|
722
637
|
}),
|
|
723
|
-
// An agent graph can reference one context config
|
|
724
638
|
contextConfig: one(contextConfigs, {
|
|
725
639
|
fields: [agentGraph.contextConfigId],
|
|
726
640
|
references: [contextConfigs.id]
|
|
727
641
|
})
|
|
728
642
|
}));
|
|
729
643
|
drizzleOrm.relations(externalAgents, ({ one, many }) => ({
|
|
730
|
-
// An external agent belongs to one project
|
|
731
644
|
project: one(projects, {
|
|
732
645
|
fields: [externalAgents.tenantId, externalAgents.projectId],
|
|
733
646
|
references: [projects.tenantId, projects.id]
|
|
734
647
|
}),
|
|
735
|
-
// An external agent can be referenced by many agent relations
|
|
736
648
|
agentRelations: many(agentRelations),
|
|
737
|
-
// An external agent may have one credential reference
|
|
738
649
|
credentialReference: one(credentialReferences, {
|
|
739
650
|
fields: [externalAgents.credentialReferenceId],
|
|
740
651
|
references: [credentialReferences.id]
|
|
741
652
|
})
|
|
742
653
|
}));
|
|
743
654
|
drizzleOrm.relations(apiKeys, ({ one }) => ({
|
|
744
|
-
// An API key belongs to one project
|
|
745
655
|
project: one(projects, {
|
|
746
656
|
fields: [apiKeys.tenantId, apiKeys.projectId],
|
|
747
657
|
references: [projects.tenantId, projects.id]
|
|
748
658
|
}),
|
|
749
|
-
// An API key belongs to one tenant and graph
|
|
750
659
|
graph: one(agentGraph, {
|
|
751
660
|
fields: [apiKeys.graphId],
|
|
752
661
|
references: [agentGraph.id]
|
|
753
662
|
})
|
|
754
663
|
}));
|
|
755
664
|
drizzleOrm.relations(agentToolRelations, ({ one }) => ({
|
|
756
|
-
// An agent-tool relation belongs to one agent
|
|
757
665
|
agent: one(agents, {
|
|
758
666
|
fields: [agentToolRelations.agentId],
|
|
759
667
|
references: [agents.id]
|
|
760
668
|
}),
|
|
761
|
-
// An agent-tool relation belongs to one tool
|
|
762
669
|
tool: one(tools, {
|
|
763
670
|
fields: [agentToolRelations.toolId],
|
|
764
671
|
references: [tools.id]
|
|
@@ -768,35 +675,28 @@ drizzleOrm.relations(credentialReferences, ({ many }) => ({
|
|
|
768
675
|
tools: many(tools)
|
|
769
676
|
}));
|
|
770
677
|
drizzleOrm.relations(tools, ({ one, many }) => ({
|
|
771
|
-
// A tool belongs to one project
|
|
772
678
|
project: one(projects, {
|
|
773
679
|
fields: [tools.tenantId, tools.projectId],
|
|
774
680
|
references: [projects.tenantId, projects.id]
|
|
775
681
|
}),
|
|
776
|
-
// A tool can be used by many agents through agent-tool relations
|
|
777
682
|
agentRelations: many(agentToolRelations),
|
|
778
|
-
// A tool may have one credential reference
|
|
779
683
|
credentialReference: one(credentialReferences, {
|
|
780
684
|
fields: [tools.credentialReferenceId],
|
|
781
685
|
references: [credentialReferences.id]
|
|
782
686
|
})
|
|
783
687
|
}));
|
|
784
688
|
drizzleOrm.relations(conversations, ({ one, many }) => ({
|
|
785
|
-
// A conversation belongs to one project
|
|
786
689
|
project: one(projects, {
|
|
787
690
|
fields: [conversations.tenantId, conversations.projectId],
|
|
788
691
|
references: [projects.tenantId, projects.id]
|
|
789
692
|
}),
|
|
790
|
-
// A conversation has many messages
|
|
791
693
|
messages: many(messages),
|
|
792
|
-
// A conversation has one active agent
|
|
793
694
|
activeAgent: one(agents, {
|
|
794
695
|
fields: [conversations.activeAgentId],
|
|
795
696
|
references: [agents.id]
|
|
796
697
|
})
|
|
797
698
|
}));
|
|
798
699
|
drizzleOrm.relations(messages, ({ one, many }) => ({
|
|
799
|
-
// A message belongs to one conversation
|
|
800
700
|
conversation: one(conversations, {
|
|
801
701
|
fields: [messages.conversationId],
|
|
802
702
|
references: [conversations.id]
|
|
@@ -807,114 +707,94 @@ drizzleOrm.relations(messages, ({ one, many }) => ({
|
|
|
807
707
|
references: [agents.id],
|
|
808
708
|
relationName: "associatedAgent"
|
|
809
709
|
}),
|
|
810
|
-
// Sender tracking relations
|
|
811
710
|
fromAgent: one(agents, {
|
|
812
711
|
fields: [messages.fromAgentId],
|
|
813
712
|
references: [agents.id],
|
|
814
713
|
relationName: "sentMessages"
|
|
815
714
|
}),
|
|
816
|
-
// Recipient tracking relations
|
|
817
715
|
toAgent: one(agents, {
|
|
818
716
|
fields: [messages.toAgentId],
|
|
819
717
|
references: [agents.id],
|
|
820
718
|
relationName: "receivedMessages"
|
|
821
719
|
}),
|
|
822
|
-
// External agent sender tracking relations
|
|
823
720
|
fromExternalAgent: one(externalAgents, {
|
|
824
721
|
fields: [messages.fromExternalAgentId],
|
|
825
722
|
references: [externalAgents.id],
|
|
826
723
|
relationName: "receivedExternalMessages"
|
|
827
724
|
}),
|
|
828
|
-
// External agent recipient tracking relations
|
|
829
725
|
toExternalAgent: one(externalAgents, {
|
|
830
726
|
fields: [messages.toExternalAgentId],
|
|
831
727
|
references: [externalAgents.id],
|
|
832
728
|
relationName: "sentExternalMessages"
|
|
833
729
|
}),
|
|
834
|
-
// A message may be associated with a task
|
|
835
730
|
task: one(tasks, {
|
|
836
731
|
fields: [messages.taskId],
|
|
837
732
|
references: [tasks.id]
|
|
838
733
|
}),
|
|
839
|
-
// A message may have a parent message (for threading)
|
|
840
734
|
parentMessage: one(messages, {
|
|
841
735
|
fields: [messages.parentMessageId],
|
|
842
736
|
references: [messages.id],
|
|
843
737
|
relationName: "parentChild"
|
|
844
738
|
}),
|
|
845
|
-
// A message may have child messages
|
|
846
739
|
childMessages: many(messages, {
|
|
847
740
|
relationName: "parentChild"
|
|
848
741
|
})
|
|
849
742
|
}));
|
|
850
743
|
drizzleOrm.relations(artifactComponents, ({ many }) => ({
|
|
851
|
-
// An artifact component can be associated with many agents
|
|
852
744
|
agentRelations: many(agentArtifactComponents)
|
|
853
745
|
}));
|
|
854
746
|
drizzleOrm.relations(agentArtifactComponents, ({ one }) => ({
|
|
855
|
-
// An agent-artifact component relation belongs to one agent
|
|
856
747
|
agent: one(agents, {
|
|
857
748
|
fields: [agentArtifactComponents.agentId],
|
|
858
749
|
references: [agents.id]
|
|
859
750
|
}),
|
|
860
|
-
// An agent-artifact component relation belongs to one artifact component
|
|
861
751
|
artifactComponent: one(artifactComponents, {
|
|
862
752
|
fields: [agentArtifactComponents.artifactComponentId],
|
|
863
753
|
references: [artifactComponents.id]
|
|
864
754
|
})
|
|
865
755
|
}));
|
|
866
756
|
drizzleOrm.relations(dataComponents, ({ many, one }) => ({
|
|
867
|
-
// A data component belongs to one project
|
|
868
757
|
project: one(projects, {
|
|
869
758
|
fields: [dataComponents.tenantId, dataComponents.projectId],
|
|
870
759
|
references: [projects.tenantId, projects.id]
|
|
871
760
|
}),
|
|
872
|
-
// A data component can be associated with many agents
|
|
873
761
|
agentRelations: many(agentDataComponents)
|
|
874
762
|
}));
|
|
875
763
|
drizzleOrm.relations(agentDataComponents, ({ one }) => ({
|
|
876
|
-
// An agent-data component relation belongs to one agent
|
|
877
764
|
agent: one(agents, {
|
|
878
765
|
fields: [agentDataComponents.agentId],
|
|
879
766
|
references: [agents.id]
|
|
880
767
|
}),
|
|
881
|
-
// An agent-data component relation belongs to one data component
|
|
882
768
|
dataComponent: one(dataComponents, {
|
|
883
769
|
fields: [agentDataComponents.dataComponentId],
|
|
884
770
|
references: [dataComponents.id]
|
|
885
771
|
})
|
|
886
772
|
}));
|
|
887
773
|
drizzleOrm.relations(ledgerArtifacts, ({ one }) => ({
|
|
888
|
-
// A ledger artifact belongs to one project
|
|
889
774
|
project: one(projects, {
|
|
890
775
|
fields: [ledgerArtifacts.tenantId, ledgerArtifacts.projectId],
|
|
891
776
|
references: [projects.tenantId, projects.id]
|
|
892
777
|
}),
|
|
893
|
-
// A ledger artifact may be associated with one task
|
|
894
778
|
task: one(tasks, {
|
|
895
779
|
fields: [ledgerArtifacts.taskId],
|
|
896
780
|
references: [tasks.id]
|
|
897
781
|
})
|
|
898
782
|
}));
|
|
899
783
|
drizzleOrm.relations(agentRelations, ({ one }) => ({
|
|
900
|
-
// An agent relation belongs to one graph
|
|
901
784
|
graph: one(agentGraph, {
|
|
902
785
|
fields: [agentRelations.graphId],
|
|
903
786
|
references: [agentGraph.id]
|
|
904
787
|
}),
|
|
905
|
-
// An agent relation has one source agent
|
|
906
788
|
sourceAgent: one(agents, {
|
|
907
789
|
fields: [agentRelations.sourceAgentId],
|
|
908
790
|
references: [agents.id],
|
|
909
791
|
relationName: "sourceRelations"
|
|
910
792
|
}),
|
|
911
|
-
// An agent relation may have one target agent (for internal relations)
|
|
912
793
|
targetAgent: one(agents, {
|
|
913
794
|
fields: [agentRelations.targetAgentId],
|
|
914
795
|
references: [agents.id],
|
|
915
796
|
relationName: "targetRelations"
|
|
916
797
|
}),
|
|
917
|
-
// An agent relation may have one external agent (for external relations)
|
|
918
798
|
externalAgent: one(externalAgents, {
|
|
919
799
|
fields: [agentRelations.externalAgentId],
|
|
920
800
|
references: [externalAgents.id]
|