@inkeep/agents-core 0.2.1 → 0.3.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/dist/{chunk-MXQKLGQK.js → chunk-LFWFXR4O.js} +123 -82
- package/dist/{chunk-MY4NEHGT.js → chunk-LPIKPCE5.js} +76 -29
- package/dist/{chunk-GDVT5LPG.js → chunk-XQRFKXVV.js} +20 -12
- package/dist/client-exports.cjs +195 -111
- package/dist/client-exports.js +4 -5
- package/dist/db/schema.cjs +121 -80
- package/dist/db/schema.js +1 -1
- package/dist/index.cjs +598 -615
- package/dist/index.js +379 -499
- package/dist/validation/index.cjs +213 -118
- package/dist/validation/index.js +2 -2
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -23,12 +23,22 @@ var ai = require('ai');
|
|
|
23
23
|
var exitHook = require('exit-hook');
|
|
24
24
|
var tsPattern = require('ts-pattern');
|
|
25
25
|
var node = require('@nangohq/node');
|
|
26
|
+
var fs = require('fs');
|
|
27
|
+
var os = require('os');
|
|
28
|
+
var path = require('path');
|
|
29
|
+
var dotenv = require('dotenv');
|
|
30
|
+
var dotenvExpand = require('dotenv-expand');
|
|
31
|
+
var findUp = require('find-up');
|
|
26
32
|
|
|
27
33
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
28
34
|
|
|
29
35
|
var jmespath__default = /*#__PURE__*/_interopDefault(jmespath);
|
|
30
36
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
31
37
|
var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
|
|
38
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
39
|
+
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
40
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
41
|
+
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
32
42
|
|
|
33
43
|
var __defProp = Object.defineProperty;
|
|
34
44
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -122,6 +132,7 @@ __export(schema_exports, {
|
|
|
122
132
|
agentArtifactComponents: () => agentArtifactComponents,
|
|
123
133
|
agentArtifactComponentsRelations: () => agentArtifactComponentsRelations,
|
|
124
134
|
agentDataComponents: () => agentDataComponents,
|
|
135
|
+
agentDataComponentsRelations: () => agentDataComponentsRelations,
|
|
125
136
|
agentGraph: () => agentGraph,
|
|
126
137
|
agentGraphRelations: () => agentGraphRelations,
|
|
127
138
|
agentRelations: () => agentRelations,
|
|
@@ -143,10 +154,12 @@ __export(schema_exports, {
|
|
|
143
154
|
credentialReferences: () => credentialReferences,
|
|
144
155
|
credentialReferencesRelations: () => credentialReferencesRelations,
|
|
145
156
|
dataComponents: () => dataComponents,
|
|
157
|
+
dataComponentsRelations: () => dataComponentsRelations,
|
|
146
158
|
externalAgents: () => externalAgents,
|
|
147
159
|
externalAgentsRelations: () => externalAgentsRelations,
|
|
148
160
|
ledgerArtifacts: () => ledgerArtifacts,
|
|
149
161
|
ledgerArtifactsContextIdIdx: () => ledgerArtifactsContextIdIdx,
|
|
162
|
+
ledgerArtifactsRelations: () => ledgerArtifactsRelations,
|
|
150
163
|
ledgerArtifactsTaskContextNameUnique: () => ledgerArtifactsTaskContextNameUnique,
|
|
151
164
|
ledgerArtifactsTaskIdIdx: () => ledgerArtifactsTaskIdIdx,
|
|
152
165
|
messages: () => messages,
|
|
@@ -177,11 +190,44 @@ var projects = sqliteCore.sqliteTable(
|
|
|
177
190
|
},
|
|
178
191
|
(table) => [sqliteCore.primaryKey({ columns: [table.tenantId, table.id] })]
|
|
179
192
|
);
|
|
193
|
+
var agentGraph = sqliteCore.sqliteTable(
|
|
194
|
+
"agent_graph",
|
|
195
|
+
{
|
|
196
|
+
tenantId: sqliteCore.text("tenant_id").notNull(),
|
|
197
|
+
projectId: sqliteCore.text("project_id").notNull(),
|
|
198
|
+
id: sqliteCore.text("id").notNull(),
|
|
199
|
+
name: sqliteCore.text("name").notNull(),
|
|
200
|
+
description: sqliteCore.text("description"),
|
|
201
|
+
defaultAgentId: sqliteCore.text("default_agent_id"),
|
|
202
|
+
// Reference to shared context configuration for all agents in this graph
|
|
203
|
+
contextConfigId: sqliteCore.text("context_config_id"),
|
|
204
|
+
// add fk relationship
|
|
205
|
+
// Graph-level model settingsuration that can be inherited by agents
|
|
206
|
+
models: sqliteCore.text("models", { mode: "json" }).$type(),
|
|
207
|
+
// Status updates configuration for intelligent progress summaries
|
|
208
|
+
statusUpdates: sqliteCore.text("status_updates", { mode: "json" }).$type(),
|
|
209
|
+
// Graph-level prompt that can be used as additional context for agents
|
|
210
|
+
graphPrompt: sqliteCore.text("graph_prompt"),
|
|
211
|
+
// Graph-level stopWhen configuration that can be inherited by agents
|
|
212
|
+
stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
|
|
213
|
+
createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
|
|
214
|
+
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
215
|
+
},
|
|
216
|
+
(table) => [
|
|
217
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
218
|
+
sqliteCore.foreignKey({
|
|
219
|
+
columns: [table.tenantId, table.projectId],
|
|
220
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
221
|
+
name: "agent_graph_project_fk"
|
|
222
|
+
}).onDelete("cascade")
|
|
223
|
+
]
|
|
224
|
+
);
|
|
180
225
|
var contextConfigs = sqliteCore.sqliteTable(
|
|
181
226
|
"context_configs",
|
|
182
227
|
{
|
|
183
228
|
tenantId: sqliteCore.text("tenant_id").notNull(),
|
|
184
229
|
projectId: sqliteCore.text("project_id").notNull(),
|
|
230
|
+
// Add graph level scoping
|
|
185
231
|
id: sqliteCore.text("id").notNull(),
|
|
186
232
|
name: sqliteCore.text("name").notNull(),
|
|
187
233
|
description: sqliteCore.text("description").notNull(),
|
|
@@ -246,6 +292,7 @@ var agents = sqliteCore.sqliteTable(
|
|
|
246
292
|
{
|
|
247
293
|
tenantId: sqliteCore.text("tenant_id").notNull(),
|
|
248
294
|
projectId: sqliteCore.text("project_id").notNull(),
|
|
295
|
+
graphId: sqliteCore.text("graph_id").notNull(),
|
|
249
296
|
id: sqliteCore.text("id").notNull(),
|
|
250
297
|
name: sqliteCore.text("name").notNull(),
|
|
251
298
|
description: sqliteCore.text("description").notNull(),
|
|
@@ -260,11 +307,11 @@ var agents = sqliteCore.sqliteTable(
|
|
|
260
307
|
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
261
308
|
},
|
|
262
309
|
(table) => [
|
|
263
|
-
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
310
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
|
|
264
311
|
sqliteCore.foreignKey({
|
|
265
|
-
columns: [table.tenantId, table.projectId],
|
|
266
|
-
foreignColumns: [
|
|
267
|
-
name: "
|
|
312
|
+
columns: [table.tenantId, table.projectId, table.graphId],
|
|
313
|
+
foreignColumns: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id],
|
|
314
|
+
name: "agents_graph_fk"
|
|
268
315
|
}).onDelete("cascade")
|
|
269
316
|
]
|
|
270
317
|
);
|
|
@@ -273,8 +320,8 @@ var agentRelations = sqliteCore.sqliteTable(
|
|
|
273
320
|
{
|
|
274
321
|
tenantId: sqliteCore.text("tenant_id").notNull(),
|
|
275
322
|
projectId: sqliteCore.text("project_id").notNull(),
|
|
276
|
-
id: sqliteCore.text("id").notNull(),
|
|
277
323
|
graphId: sqliteCore.text("graph_id").notNull(),
|
|
324
|
+
id: sqliteCore.text("id").notNull(),
|
|
278
325
|
sourceAgentId: sqliteCore.text("source_agent_id").notNull(),
|
|
279
326
|
// For internal relationships
|
|
280
327
|
targetAgentId: sqliteCore.text("target_agent_id"),
|
|
@@ -286,11 +333,11 @@ var agentRelations = sqliteCore.sqliteTable(
|
|
|
286
333
|
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
287
334
|
},
|
|
288
335
|
(table) => [
|
|
289
|
-
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
336
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
|
|
290
337
|
sqliteCore.foreignKey({
|
|
291
|
-
columns: [table.tenantId, table.projectId],
|
|
292
|
-
foreignColumns: [
|
|
293
|
-
name: "
|
|
338
|
+
columns: [table.tenantId, table.projectId, table.graphId],
|
|
339
|
+
foreignColumns: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id],
|
|
340
|
+
name: "agent_relations_graph_fk"
|
|
294
341
|
}).onDelete("cascade")
|
|
295
342
|
]
|
|
296
343
|
);
|
|
@@ -299,6 +346,7 @@ var externalAgents = sqliteCore.sqliteTable(
|
|
|
299
346
|
{
|
|
300
347
|
tenantId: sqliteCore.text("tenant_id").notNull(),
|
|
301
348
|
projectId: sqliteCore.text("project_id").notNull(),
|
|
349
|
+
graphId: sqliteCore.text("graph_id").notNull(),
|
|
302
350
|
id: sqliteCore.text("id").notNull(),
|
|
303
351
|
name: sqliteCore.text("name").notNull(),
|
|
304
352
|
description: sqliteCore.text("description").notNull(),
|
|
@@ -310,11 +358,11 @@ var externalAgents = sqliteCore.sqliteTable(
|
|
|
310
358
|
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
311
359
|
},
|
|
312
360
|
(table) => [
|
|
313
|
-
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
361
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
|
|
314
362
|
sqliteCore.foreignKey({
|
|
315
|
-
columns: [table.tenantId, table.projectId],
|
|
316
|
-
foreignColumns: [
|
|
317
|
-
name: "
|
|
363
|
+
columns: [table.tenantId, table.projectId, table.graphId],
|
|
364
|
+
foreignColumns: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id],
|
|
365
|
+
name: "external_agents_graph_fk"
|
|
318
366
|
}).onDelete("cascade"),
|
|
319
367
|
sqliteCore.foreignKey({
|
|
320
368
|
columns: [table.tenantId, table.projectId, table.credentialReferenceId],
|
|
@@ -327,37 +375,6 @@ var externalAgents = sqliteCore.sqliteTable(
|
|
|
327
375
|
}).onDelete("set null")
|
|
328
376
|
]
|
|
329
377
|
);
|
|
330
|
-
var agentGraph = sqliteCore.sqliteTable(
|
|
331
|
-
"agent_graph",
|
|
332
|
-
{
|
|
333
|
-
tenantId: sqliteCore.text("tenant_id").notNull(),
|
|
334
|
-
projectId: sqliteCore.text("project_id").notNull(),
|
|
335
|
-
id: sqliteCore.text("id").notNull(),
|
|
336
|
-
name: sqliteCore.text("name").notNull(),
|
|
337
|
-
description: sqliteCore.text("description"),
|
|
338
|
-
defaultAgentId: sqliteCore.text("default_agent_id").notNull(),
|
|
339
|
-
// Reference to shared context configuration for all agents in this graph
|
|
340
|
-
contextConfigId: sqliteCore.text("context_config_id"),
|
|
341
|
-
// Graph-level model settingsuration that can be inherited by agents
|
|
342
|
-
models: sqliteCore.text("models", { mode: "json" }).$type(),
|
|
343
|
-
// Status updates configuration for intelligent progress summaries
|
|
344
|
-
statusUpdates: sqliteCore.text("status_updates", { mode: "json" }).$type(),
|
|
345
|
-
// Graph-level prompt that can be used as additional context for agents
|
|
346
|
-
graphPrompt: sqliteCore.text("graph_prompt"),
|
|
347
|
-
// Graph-level stopWhen configuration that can be inherited by agents
|
|
348
|
-
stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
|
|
349
|
-
createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
|
|
350
|
-
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
351
|
-
},
|
|
352
|
-
(table) => [
|
|
353
|
-
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
354
|
-
sqliteCore.foreignKey({
|
|
355
|
-
columns: [table.tenantId, table.projectId],
|
|
356
|
-
foreignColumns: [projects.tenantId, projects.id],
|
|
357
|
-
name: "agent_graph_project_fk"
|
|
358
|
-
}).onDelete("cascade")
|
|
359
|
-
]
|
|
360
|
-
);
|
|
361
378
|
var tasks = sqliteCore.sqliteTable(
|
|
362
379
|
"tasks",
|
|
363
380
|
{
|
|
@@ -428,23 +445,18 @@ var agentDataComponents = sqliteCore.sqliteTable(
|
|
|
428
445
|
{
|
|
429
446
|
tenantId: sqliteCore.text("tenant_id").notNull(),
|
|
430
447
|
projectId: sqliteCore.text("project_id").notNull(),
|
|
431
|
-
|
|
448
|
+
graphId: sqliteCore.text("graph_id").notNull(),
|
|
432
449
|
agentId: sqliteCore.text("agent_id").notNull(),
|
|
450
|
+
id: sqliteCore.text("id").notNull(),
|
|
433
451
|
dataComponentId: sqliteCore.text("data_component_id").notNull(),
|
|
434
452
|
createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
435
453
|
},
|
|
436
454
|
(table) => [
|
|
437
455
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
438
|
-
// Foreign key constraint to
|
|
439
|
-
sqliteCore.foreignKey({
|
|
440
|
-
columns: [table.tenantId, table.projectId],
|
|
441
|
-
foreignColumns: [projects.tenantId, projects.id],
|
|
442
|
-
name: "agent_data_components_project_fk"
|
|
443
|
-
}).onDelete("cascade"),
|
|
444
|
-
// Foreign key constraint to agents table
|
|
456
|
+
// Foreign key constraint to agents table (ensures graph and project exist via cascade)
|
|
445
457
|
sqliteCore.foreignKey({
|
|
446
|
-
columns: [table.tenantId, table.projectId, table.agentId],
|
|
447
|
-
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
458
|
+
columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
|
|
459
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
|
|
448
460
|
name: "agent_data_components_agent_fk"
|
|
449
461
|
}).onDelete("cascade"),
|
|
450
462
|
// Foreign key constraint to data_components table
|
|
@@ -482,23 +494,20 @@ var agentArtifactComponents = sqliteCore.sqliteTable(
|
|
|
482
494
|
{
|
|
483
495
|
tenantId: sqliteCore.text("tenant_id").notNull(),
|
|
484
496
|
projectId: sqliteCore.text("project_id").notNull(),
|
|
485
|
-
|
|
497
|
+
graphId: sqliteCore.text("graph_id").notNull(),
|
|
486
498
|
agentId: sqliteCore.text("agent_id").notNull(),
|
|
499
|
+
id: sqliteCore.text("id").notNull(),
|
|
487
500
|
artifactComponentId: sqliteCore.text("artifact_component_id").notNull(),
|
|
488
501
|
createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
489
502
|
},
|
|
490
503
|
(table) => [
|
|
491
|
-
sqliteCore.primaryKey({
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
foreignColumns: [projects.tenantId, projects.id],
|
|
496
|
-
name: "agent_artifact_components_project_fk"
|
|
497
|
-
}).onDelete("cascade"),
|
|
498
|
-
// Foreign key constraint to agents table
|
|
504
|
+
sqliteCore.primaryKey({
|
|
505
|
+
columns: [table.tenantId, table.projectId, table.graphId, table.agentId, table.id]
|
|
506
|
+
}),
|
|
507
|
+
// Foreign key constraint to agents table (ensures graph and project exist via cascade)
|
|
499
508
|
sqliteCore.foreignKey({
|
|
500
|
-
columns: [table.tenantId, table.projectId, table.agentId],
|
|
501
|
-
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
509
|
+
columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
|
|
510
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
|
|
502
511
|
name: "agent_artifact_components_agent_fk"
|
|
503
512
|
}).onDelete("cascade"),
|
|
504
513
|
// Foreign key constraint to artifact_components table
|
|
@@ -552,25 +561,20 @@ var agentToolRelations = sqliteCore.sqliteTable(
|
|
|
552
561
|
{
|
|
553
562
|
tenantId: sqliteCore.text("tenant_id").notNull(),
|
|
554
563
|
projectId: sqliteCore.text("project_id").notNull(),
|
|
555
|
-
|
|
564
|
+
graphId: sqliteCore.text("graph_id").notNull(),
|
|
556
565
|
agentId: sqliteCore.text("agent_id").notNull(),
|
|
566
|
+
id: sqliteCore.text("id").notNull(),
|
|
557
567
|
toolId: sqliteCore.text("tool_id").notNull(),
|
|
558
568
|
selectedTools: sqliteCore.blob("selected_tools", { mode: "json" }).$type(),
|
|
559
569
|
createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
|
|
560
570
|
updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
561
571
|
},
|
|
562
572
|
(table) => [
|
|
563
|
-
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
564
|
-
// Foreign key constraint to
|
|
573
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
|
|
574
|
+
// Foreign key constraint to agents table (which includes project and graph scope)
|
|
565
575
|
sqliteCore.foreignKey({
|
|
566
|
-
columns: [table.tenantId, table.projectId],
|
|
567
|
-
foreignColumns: [
|
|
568
|
-
name: "agent_tool_relations_project_fk"
|
|
569
|
-
}).onDelete("cascade"),
|
|
570
|
-
// Foreign key constraint to agents table
|
|
571
|
-
sqliteCore.foreignKey({
|
|
572
|
-
columns: [table.tenantId, table.projectId, table.agentId],
|
|
573
|
-
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
576
|
+
columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
|
|
577
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
|
|
574
578
|
name: "agent_tool_relations_agent_fk"
|
|
575
579
|
}).onDelete("cascade"),
|
|
576
580
|
// Foreign key constraint to tools table
|
|
@@ -777,7 +781,9 @@ var tasksRelations = drizzleOrm.relations(tasks, ({ one, many }) => ({
|
|
|
777
781
|
references: [agents.id]
|
|
778
782
|
}),
|
|
779
783
|
// A task can have many messages associated with it
|
|
780
|
-
messages: many(messages)
|
|
784
|
+
messages: many(messages),
|
|
785
|
+
// A task can have many ledger artifacts
|
|
786
|
+
ledgerArtifacts: many(ledgerArtifacts)
|
|
781
787
|
}));
|
|
782
788
|
var projectsRelations = drizzleOrm.relations(projects, ({ many }) => ({
|
|
783
789
|
// A project can have many agents
|
|
@@ -793,7 +799,15 @@ var projectsRelations = drizzleOrm.relations(projects, ({ many }) => ({
|
|
|
793
799
|
// A project can have many conversations
|
|
794
800
|
conversations: many(conversations),
|
|
795
801
|
// A project can have many tasks
|
|
796
|
-
tasks: many(tasks)
|
|
802
|
+
tasks: many(tasks),
|
|
803
|
+
// A project can have many data components
|
|
804
|
+
dataComponents: many(dataComponents),
|
|
805
|
+
// A project can have many artifact components
|
|
806
|
+
artifactComponents: many(artifactComponents),
|
|
807
|
+
// A project can have many ledger artifacts
|
|
808
|
+
ledgerArtifacts: many(ledgerArtifacts),
|
|
809
|
+
// A project can have many credential references
|
|
810
|
+
credentialReferences: many(credentialReferences)
|
|
797
811
|
}));
|
|
798
812
|
var taskRelationsRelations = drizzleOrm.relations(taskRelations, ({ one }) => ({
|
|
799
813
|
// Each relation has one parent task
|
|
@@ -855,7 +869,11 @@ var agentsRelations = drizzleOrm.relations(agents, ({ many, one }) => ({
|
|
|
855
869
|
associatedMessages: many(messages, {
|
|
856
870
|
relationName: "associatedAgent"
|
|
857
871
|
}),
|
|
858
|
-
toolRelations: many(agentToolRelations)
|
|
872
|
+
toolRelations: many(agentToolRelations),
|
|
873
|
+
// Data component relations
|
|
874
|
+
dataComponentRelations: many(agentDataComponents),
|
|
875
|
+
// Artifact component relations
|
|
876
|
+
artifactComponentRelations: many(agentArtifactComponents)
|
|
859
877
|
}));
|
|
860
878
|
var agentGraphRelations = drizzleOrm.relations(agentGraph, ({ one }) => ({
|
|
861
879
|
// An agent graph belongs to one project
|
|
@@ -863,7 +881,7 @@ var agentGraphRelations = drizzleOrm.relations(agentGraph, ({ one }) => ({
|
|
|
863
881
|
fields: [agentGraph.tenantId, agentGraph.projectId],
|
|
864
882
|
references: [projects.tenantId, projects.id]
|
|
865
883
|
}),
|
|
866
|
-
// An agent graph
|
|
884
|
+
// An agent graph may have one default agent (optional)
|
|
867
885
|
defaultAgent: one(agents, {
|
|
868
886
|
fields: [agentGraph.defaultAgentId],
|
|
869
887
|
references: [agents.id]
|
|
@@ -1011,6 +1029,39 @@ var agentArtifactComponentsRelations = drizzleOrm.relations(agentArtifactCompone
|
|
|
1011
1029
|
references: [artifactComponents.id]
|
|
1012
1030
|
})
|
|
1013
1031
|
}));
|
|
1032
|
+
var dataComponentsRelations = drizzleOrm.relations(dataComponents, ({ many, one }) => ({
|
|
1033
|
+
// A data component belongs to one project
|
|
1034
|
+
project: one(projects, {
|
|
1035
|
+
fields: [dataComponents.tenantId, dataComponents.projectId],
|
|
1036
|
+
references: [projects.tenantId, projects.id]
|
|
1037
|
+
}),
|
|
1038
|
+
// A data component can be associated with many agents
|
|
1039
|
+
agentRelations: many(agentDataComponents)
|
|
1040
|
+
}));
|
|
1041
|
+
var agentDataComponentsRelations = drizzleOrm.relations(agentDataComponents, ({ one }) => ({
|
|
1042
|
+
// An agent-data component relation belongs to one agent
|
|
1043
|
+
agent: one(agents, {
|
|
1044
|
+
fields: [agentDataComponents.agentId],
|
|
1045
|
+
references: [agents.id]
|
|
1046
|
+
}),
|
|
1047
|
+
// An agent-data component relation belongs to one data component
|
|
1048
|
+
dataComponent: one(dataComponents, {
|
|
1049
|
+
fields: [agentDataComponents.dataComponentId],
|
|
1050
|
+
references: [dataComponents.id]
|
|
1051
|
+
})
|
|
1052
|
+
}));
|
|
1053
|
+
var ledgerArtifactsRelations = drizzleOrm.relations(ledgerArtifacts, ({ one }) => ({
|
|
1054
|
+
// A ledger artifact belongs to one project
|
|
1055
|
+
project: one(projects, {
|
|
1056
|
+
fields: [ledgerArtifacts.tenantId, ledgerArtifacts.projectId],
|
|
1057
|
+
references: [projects.tenantId, projects.id]
|
|
1058
|
+
}),
|
|
1059
|
+
// A ledger artifact may be associated with one task
|
|
1060
|
+
task: one(tasks, {
|
|
1061
|
+
fields: [ledgerArtifacts.taskId],
|
|
1062
|
+
references: [tasks.id]
|
|
1063
|
+
})
|
|
1064
|
+
}));
|
|
1014
1065
|
var agentRelationsRelations = drizzleOrm.relations(agentRelations, ({ one }) => ({
|
|
1015
1066
|
// An agent relation belongs to one graph
|
|
1016
1067
|
graph: one(agentGraph, {
|
|
@@ -1092,15 +1143,18 @@ var ProjectModelSchema = zodOpenapi.z.object({
|
|
|
1092
1143
|
var createApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
|
|
1093
1144
|
var createApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
|
|
1094
1145
|
var createApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true }).partial();
|
|
1146
|
+
var createGraphScopedApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true });
|
|
1147
|
+
var createGraphScopedApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true });
|
|
1148
|
+
var createGraphScopedApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true }).partial();
|
|
1095
1149
|
var AgentSelectSchema = drizzleZod.createSelectSchema(agents);
|
|
1096
1150
|
var AgentInsertSchema = drizzleZod.createInsertSchema(agents).extend({
|
|
1097
1151
|
id: resourceIdSchema,
|
|
1098
1152
|
models: ModelSchema.optional()
|
|
1099
1153
|
});
|
|
1100
1154
|
var AgentUpdateSchema = AgentInsertSchema.partial();
|
|
1101
|
-
var AgentApiSelectSchema =
|
|
1102
|
-
var AgentApiInsertSchema =
|
|
1103
|
-
var AgentApiUpdateSchema =
|
|
1155
|
+
var AgentApiSelectSchema = createGraphScopedApiSchema(AgentSelectSchema);
|
|
1156
|
+
var AgentApiInsertSchema = createGraphScopedApiInsertSchema(AgentInsertSchema);
|
|
1157
|
+
var AgentApiUpdateSchema = createGraphScopedApiUpdateSchema(AgentUpdateSchema);
|
|
1104
1158
|
var AgentRelationSelectSchema = drizzleZod.createSelectSchema(agentRelations);
|
|
1105
1159
|
var AgentRelationInsertSchema = drizzleZod.createInsertSchema(agentRelations).extend({
|
|
1106
1160
|
id: resourceIdSchema,
|
|
@@ -1110,8 +1164,10 @@ var AgentRelationInsertSchema = drizzleZod.createInsertSchema(agentRelations).ex
|
|
|
1110
1164
|
externalAgentId: resourceIdSchema.optional()
|
|
1111
1165
|
});
|
|
1112
1166
|
var AgentRelationUpdateSchema = AgentRelationInsertSchema.partial();
|
|
1113
|
-
var AgentRelationApiSelectSchema =
|
|
1114
|
-
var AgentRelationApiInsertSchema =
|
|
1167
|
+
var AgentRelationApiSelectSchema = createGraphScopedApiSchema(AgentRelationSelectSchema);
|
|
1168
|
+
var AgentRelationApiInsertSchema = createGraphScopedApiInsertSchema(
|
|
1169
|
+
AgentRelationInsertSchema
|
|
1170
|
+
).extend({
|
|
1115
1171
|
relationType: zodOpenapi.z.enum(VALID_RELATION_TYPES)
|
|
1116
1172
|
}).refine(
|
|
1117
1173
|
(data) => {
|
|
@@ -1124,7 +1180,9 @@ var AgentRelationApiInsertSchema = createApiInsertSchema(AgentRelationInsertSche
|
|
|
1124
1180
|
path: ["targetAgentId", "externalAgentId"]
|
|
1125
1181
|
}
|
|
1126
1182
|
);
|
|
1127
|
-
var AgentRelationApiUpdateSchema =
|
|
1183
|
+
var AgentRelationApiUpdateSchema = createGraphScopedApiUpdateSchema(
|
|
1184
|
+
AgentRelationUpdateSchema
|
|
1185
|
+
).extend({
|
|
1128
1186
|
relationType: zodOpenapi.z.enum(VALID_RELATION_TYPES).optional()
|
|
1129
1187
|
}).refine(
|
|
1130
1188
|
(data) => {
|
|
@@ -1161,7 +1219,7 @@ var AgentGraphInsertSchema = drizzleZod.createInsertSchema(agentGraph).extend({
|
|
|
1161
1219
|
var AgentGraphUpdateSchema = AgentGraphInsertSchema.partial();
|
|
1162
1220
|
var AgentGraphApiSelectSchema = createApiSchema(AgentGraphSelectSchema);
|
|
1163
1221
|
var AgentGraphApiInsertSchema = createApiInsertSchema(AgentGraphInsertSchema).extend({
|
|
1164
|
-
id: resourceIdSchema
|
|
1222
|
+
id: resourceIdSchema
|
|
1165
1223
|
});
|
|
1166
1224
|
var AgentGraphApiUpdateSchema = createApiUpdateSchema(AgentGraphUpdateSchema);
|
|
1167
1225
|
var TaskSelectSchema = drizzleZod.createSelectSchema(tasks);
|
|
@@ -1260,11 +1318,16 @@ var DataComponentApiUpdateSchema = createApiUpdateSchema(DataComponentUpdateSche
|
|
|
1260
1318
|
var AgentDataComponentSelectSchema = drizzleZod.createSelectSchema(agentDataComponents);
|
|
1261
1319
|
var AgentDataComponentInsertSchema = drizzleZod.createInsertSchema(agentDataComponents);
|
|
1262
1320
|
var AgentDataComponentUpdateSchema = AgentDataComponentInsertSchema.partial();
|
|
1263
|
-
var AgentDataComponentApiSelectSchema =
|
|
1264
|
-
|
|
1265
|
-
AgentDataComponentInsertSchema
|
|
1321
|
+
var AgentDataComponentApiSelectSchema = createGraphScopedApiSchema(
|
|
1322
|
+
AgentDataComponentSelectSchema
|
|
1266
1323
|
);
|
|
1267
|
-
var
|
|
1324
|
+
var AgentDataComponentApiInsertSchema = AgentDataComponentInsertSchema.omit({
|
|
1325
|
+
tenantId: true,
|
|
1326
|
+
projectId: true,
|
|
1327
|
+
id: true,
|
|
1328
|
+
createdAt: true
|
|
1329
|
+
});
|
|
1330
|
+
var AgentDataComponentApiUpdateSchema = createGraphScopedApiUpdateSchema(
|
|
1268
1331
|
AgentDataComponentUpdateSchema
|
|
1269
1332
|
);
|
|
1270
1333
|
var ArtifactComponentSelectSchema = drizzleZod.createSelectSchema(artifactComponents);
|
|
@@ -1293,7 +1356,7 @@ var AgentArtifactComponentInsertSchema = drizzleZod.createInsertSchema(
|
|
|
1293
1356
|
artifactComponentId: resourceIdSchema
|
|
1294
1357
|
});
|
|
1295
1358
|
var AgentArtifactComponentUpdateSchema = AgentArtifactComponentInsertSchema.partial();
|
|
1296
|
-
var AgentArtifactComponentApiSelectSchema =
|
|
1359
|
+
var AgentArtifactComponentApiSelectSchema = createGraphScopedApiSchema(
|
|
1297
1360
|
AgentArtifactComponentSelectSchema
|
|
1298
1361
|
);
|
|
1299
1362
|
var AgentArtifactComponentApiInsertSchema = AgentArtifactComponentInsertSchema.omit({
|
|
@@ -1302,7 +1365,7 @@ var AgentArtifactComponentApiInsertSchema = AgentArtifactComponentInsertSchema.o
|
|
|
1302
1365
|
id: true,
|
|
1303
1366
|
createdAt: true
|
|
1304
1367
|
});
|
|
1305
|
-
var AgentArtifactComponentApiUpdateSchema =
|
|
1368
|
+
var AgentArtifactComponentApiUpdateSchema = createGraphScopedApiUpdateSchema(
|
|
1306
1369
|
AgentArtifactComponentUpdateSchema
|
|
1307
1370
|
);
|
|
1308
1371
|
var ExternalAgentSelectSchema = drizzleZod.createSelectSchema(externalAgents).extend({
|
|
@@ -1313,9 +1376,9 @@ var ExternalAgentInsertSchema = drizzleZod.createInsertSchema(externalAgents).ex
|
|
|
1313
1376
|
id: resourceIdSchema
|
|
1314
1377
|
});
|
|
1315
1378
|
var ExternalAgentUpdateSchema = ExternalAgentInsertSchema.partial();
|
|
1316
|
-
var ExternalAgentApiSelectSchema =
|
|
1317
|
-
var ExternalAgentApiInsertSchema =
|
|
1318
|
-
var ExternalAgentApiUpdateSchema =
|
|
1379
|
+
var ExternalAgentApiSelectSchema = createGraphScopedApiSchema(ExternalAgentSelectSchema);
|
|
1380
|
+
var ExternalAgentApiInsertSchema = createGraphScopedApiInsertSchema(ExternalAgentInsertSchema);
|
|
1381
|
+
var ExternalAgentApiUpdateSchema = createGraphScopedApiUpdateSchema(ExternalAgentUpdateSchema);
|
|
1319
1382
|
var AllAgentSchema = zodOpenapi.z.discriminatedUnion("type", [
|
|
1320
1383
|
AgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("internal") }),
|
|
1321
1384
|
ExternalAgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("external") })
|
|
@@ -1371,10 +1434,8 @@ var CredentialReferenceSelectSchema = zodOpenapi.z.object({
|
|
|
1371
1434
|
createdAt: zodOpenapi.z.string(),
|
|
1372
1435
|
updatedAt: zodOpenapi.z.string()
|
|
1373
1436
|
});
|
|
1374
|
-
var CredentialReferenceInsertSchema =
|
|
1437
|
+
var CredentialReferenceInsertSchema = drizzleZod.createInsertSchema(credentialReferences).extend({
|
|
1375
1438
|
id: resourceIdSchema,
|
|
1376
|
-
tenantId: zodOpenapi.z.string(),
|
|
1377
|
-
projectId: zodOpenapi.z.string(),
|
|
1378
1439
|
type: zodOpenapi.z.string(),
|
|
1379
1440
|
credentialStoreId: resourceIdSchema,
|
|
1380
1441
|
retrievalParams: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).nullish()
|
|
@@ -1470,11 +1531,13 @@ var AgentToolRelationInsertSchema = drizzleZod.createInsertSchema(agentToolRelat
|
|
|
1470
1531
|
selectedTools: zodOpenapi.z.array(zodOpenapi.z.string()).nullish()
|
|
1471
1532
|
});
|
|
1472
1533
|
var AgentToolRelationUpdateSchema = AgentToolRelationInsertSchema.partial();
|
|
1473
|
-
var AgentToolRelationApiSelectSchema =
|
|
1474
|
-
|
|
1534
|
+
var AgentToolRelationApiSelectSchema = createGraphScopedApiSchema(
|
|
1535
|
+
AgentToolRelationSelectSchema
|
|
1536
|
+
);
|
|
1537
|
+
var AgentToolRelationApiInsertSchema = createGraphScopedApiInsertSchema(
|
|
1475
1538
|
AgentToolRelationInsertSchema
|
|
1476
1539
|
);
|
|
1477
|
-
var AgentToolRelationApiUpdateSchema =
|
|
1540
|
+
var AgentToolRelationApiUpdateSchema = createGraphScopedApiUpdateSchema(
|
|
1478
1541
|
AgentToolRelationUpdateSchema
|
|
1479
1542
|
);
|
|
1480
1543
|
var LedgerArtifactSelectSchema = drizzleZod.createSelectSchema(ledgerArtifacts);
|
|
@@ -1500,6 +1563,7 @@ var StatusUpdateSchema = zodOpenapi.z.object({
|
|
|
1500
1563
|
statusComponents: zodOpenapi.z.array(StatusComponentSchema).optional()
|
|
1501
1564
|
});
|
|
1502
1565
|
var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
|
|
1566
|
+
type: zodOpenapi.z.literal("internal"),
|
|
1503
1567
|
tools: zodOpenapi.z.array(zodOpenapi.z.string()),
|
|
1504
1568
|
selectedTools: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.array(zodOpenapi.z.string())).optional(),
|
|
1505
1569
|
dataComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
@@ -1509,10 +1573,9 @@ var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
|
|
|
1509
1573
|
});
|
|
1510
1574
|
var FullGraphDefinitionSchema = AgentGraphApiInsertSchema.extend({
|
|
1511
1575
|
agents: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])),
|
|
1512
|
-
|
|
1513
|
-
credentialReferences
|
|
1514
|
-
|
|
1515
|
-
artifactComponents: zodOpenapi.z.record(zodOpenapi.z.string(), ArtifactComponentApiInsertSchema).optional(),
|
|
1576
|
+
// Removed project-scoped resources - these are now managed at project level:
|
|
1577
|
+
// tools, credentialReferences, dataComponents, artifactComponents
|
|
1578
|
+
// Agent relationships to these resources are maintained via agent.tools, agent.dataComponents, etc.
|
|
1516
1579
|
contextConfig: zodOpenapi.z.optional(ContextConfigApiInsertSchema),
|
|
1517
1580
|
statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
|
|
1518
1581
|
models: ModelSchema.optional(),
|
|
@@ -1520,7 +1583,13 @@ var FullGraphDefinitionSchema = AgentGraphApiInsertSchema.extend({
|
|
|
1520
1583
|
graphPrompt: zodOpenapi.z.string().max(5e3, "Graph prompt cannot exceed 5000 characters").optional()
|
|
1521
1584
|
});
|
|
1522
1585
|
var GraphWithinContextOfProjectSchema = AgentGraphApiInsertSchema.extend({
|
|
1523
|
-
agents: zodOpenapi.z.record(
|
|
1586
|
+
agents: zodOpenapi.z.record(
|
|
1587
|
+
zodOpenapi.z.string(),
|
|
1588
|
+
zodOpenapi.z.discriminatedUnion("type", [
|
|
1589
|
+
FullGraphAgentInsertSchema,
|
|
1590
|
+
ExternalAgentApiInsertSchema.extend({ type: zodOpenapi.z.literal("external") })
|
|
1591
|
+
])
|
|
1592
|
+
),
|
|
1524
1593
|
models: ModelSchema.optional(),
|
|
1525
1594
|
stopWhen: GraphStopWhenSchema.optional(),
|
|
1526
1595
|
graphPrompt: zodOpenapi.z.string().max(5e3, "Graph prompt cannot exceed 5000 characters").optional()
|
|
@@ -1603,6 +1672,35 @@ var TenantProjectParamsSchema = zodOpenapi.z.object({
|
|
|
1603
1672
|
example: "project_456"
|
|
1604
1673
|
})
|
|
1605
1674
|
}).openapi("TenantProjectParams");
|
|
1675
|
+
var TenantProjectGraphParamsSchema = zodOpenapi.z.object({
|
|
1676
|
+
tenantId: zodOpenapi.z.string().openapi({
|
|
1677
|
+
description: "Tenant identifier",
|
|
1678
|
+
example: "tenant_123"
|
|
1679
|
+
}),
|
|
1680
|
+
projectId: zodOpenapi.z.string().openapi({
|
|
1681
|
+
description: "Project identifier",
|
|
1682
|
+
example: "project_456"
|
|
1683
|
+
}),
|
|
1684
|
+
graphId: zodOpenapi.z.string().openapi({
|
|
1685
|
+
description: "Graph identifier",
|
|
1686
|
+
example: "graph_789"
|
|
1687
|
+
})
|
|
1688
|
+
}).openapi("TenantProjectGraphParams");
|
|
1689
|
+
var TenantProjectGraphIdParamsSchema = zodOpenapi.z.object({
|
|
1690
|
+
tenantId: zodOpenapi.z.string().openapi({
|
|
1691
|
+
description: "Tenant identifier",
|
|
1692
|
+
example: "tenant_123"
|
|
1693
|
+
}),
|
|
1694
|
+
projectId: zodOpenapi.z.string().openapi({
|
|
1695
|
+
description: "Project identifier",
|
|
1696
|
+
example: "project_456"
|
|
1697
|
+
}),
|
|
1698
|
+
graphId: zodOpenapi.z.string().openapi({
|
|
1699
|
+
description: "Graph identifier",
|
|
1700
|
+
example: "graph_789"
|
|
1701
|
+
}),
|
|
1702
|
+
id: resourceIdSchema
|
|
1703
|
+
}).openapi("TenantProjectGraphIdParams");
|
|
1606
1704
|
var TenantProjectIdParamsSchema = zodOpenapi.z.object({
|
|
1607
1705
|
tenantId: zodOpenapi.z.string().openapi({
|
|
1608
1706
|
description: "Tenant identifier",
|
|
@@ -1939,8 +2037,8 @@ var _TemplateEngine = class _TemplateEngine {
|
|
|
1939
2037
|
* Process variable substitutions {{variable.path}} using JMESPath
|
|
1940
2038
|
*/
|
|
1941
2039
|
static processVariables(template, context, options) {
|
|
1942
|
-
return template.replace(/\{\{([^}]+)\}\}/g, (match2,
|
|
1943
|
-
const trimmedPath =
|
|
2040
|
+
return template.replace(/\{\{([^}]+)\}\}/g, (match2, path2) => {
|
|
2041
|
+
const trimmedPath = path2.trim();
|
|
1944
2042
|
try {
|
|
1945
2043
|
if (trimmedPath.startsWith("$")) {
|
|
1946
2044
|
return _TemplateEngine.processBuiltinVariable(trimmedPath);
|
|
@@ -2319,6 +2417,7 @@ var getAgentRelationById = (db) => async (params) => {
|
|
|
2319
2417
|
where: drizzleOrm.and(
|
|
2320
2418
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2321
2419
|
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2420
|
+
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2322
2421
|
drizzleOrm.eq(agentRelations.id, params.relationId)
|
|
2323
2422
|
)
|
|
2324
2423
|
});
|
|
@@ -2329,7 +2428,8 @@ var listAgentRelations = (db) => async (params) => {
|
|
|
2329
2428
|
const offset = (page - 1) * limit;
|
|
2330
2429
|
const whereClause = drizzleOrm.and(
|
|
2331
2430
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2332
|
-
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId)
|
|
2431
|
+
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2432
|
+
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId)
|
|
2333
2433
|
);
|
|
2334
2434
|
const [data, totalResult] = await Promise.all([
|
|
2335
2435
|
db.select().from(agentRelations).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(agentRelations.createdAt)),
|
|
@@ -2344,8 +2444,8 @@ var getAgentRelations = (db) => async (params) => {
|
|
|
2344
2444
|
where: drizzleOrm.and(
|
|
2345
2445
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2346
2446
|
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2347
|
-
drizzleOrm.eq(agentRelations.graphId, params.graphId),
|
|
2348
|
-
drizzleOrm.eq(agentRelations.sourceAgentId, params.agentId)
|
|
2447
|
+
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2448
|
+
drizzleOrm.eq(agentRelations.sourceAgentId, params.scopes.agentId)
|
|
2349
2449
|
)
|
|
2350
2450
|
});
|
|
2351
2451
|
};
|
|
@@ -2354,7 +2454,7 @@ var getAgentRelationsByGraph = (db) => async (params) => {
|
|
|
2354
2454
|
where: drizzleOrm.and(
|
|
2355
2455
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2356
2456
|
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2357
|
-
drizzleOrm.eq(agentRelations.graphId, params.graphId)
|
|
2457
|
+
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId)
|
|
2358
2458
|
)
|
|
2359
2459
|
});
|
|
2360
2460
|
};
|
|
@@ -2365,6 +2465,7 @@ var getAgentRelationsBySource = (db) => async (params) => {
|
|
|
2365
2465
|
const whereClause = drizzleOrm.and(
|
|
2366
2466
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2367
2467
|
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2468
|
+
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2368
2469
|
drizzleOrm.eq(agentRelations.sourceAgentId, params.sourceAgentId)
|
|
2369
2470
|
);
|
|
2370
2471
|
const [data, totalResult] = await Promise.all([
|
|
@@ -2385,6 +2486,7 @@ var getAgentRelationsByTarget = (db) => async (params) => {
|
|
|
2385
2486
|
const whereClause = drizzleOrm.and(
|
|
2386
2487
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2387
2488
|
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2489
|
+
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2388
2490
|
drizzleOrm.eq(agentRelations.targetAgentId, params.targetAgentId)
|
|
2389
2491
|
);
|
|
2390
2492
|
const [data, totalResult] = await Promise.all([
|
|
@@ -2405,6 +2507,7 @@ var getExternalAgentRelations = (db) => async (params) => {
|
|
|
2405
2507
|
const whereClause = drizzleOrm.and(
|
|
2406
2508
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2407
2509
|
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2510
|
+
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2408
2511
|
drizzleOrm.eq(agentRelations.externalAgentId, params.externalAgentId)
|
|
2409
2512
|
);
|
|
2410
2513
|
const [data, totalResult] = await Promise.all([
|
|
@@ -2428,11 +2531,12 @@ var getRelatedAgentsForGraph = (db) => async (params) => {
|
|
|
2428
2531
|
drizzleOrm.and(
|
|
2429
2532
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2430
2533
|
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2431
|
-
drizzleOrm.eq(agentRelations.graphId, params.graphId),
|
|
2534
|
+
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2432
2535
|
drizzleOrm.eq(agentRelations.sourceAgentId, params.agentId),
|
|
2433
2536
|
drizzleOrm.isNotNull(agentRelations.targetAgentId),
|
|
2434
2537
|
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
2435
|
-
drizzleOrm.eq(agents.projectId, params.scopes.projectId)
|
|
2538
|
+
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
2539
|
+
drizzleOrm.eq(agents.graphId, params.scopes.graphId)
|
|
2436
2540
|
)
|
|
2437
2541
|
);
|
|
2438
2542
|
const externalRelations = await db.select({
|
|
@@ -2448,11 +2552,12 @@ var getRelatedAgentsForGraph = (db) => async (params) => {
|
|
|
2448
2552
|
drizzleOrm.and(
|
|
2449
2553
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2450
2554
|
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2451
|
-
drizzleOrm.eq(agentRelations.graphId, params.graphId),
|
|
2555
|
+
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2452
2556
|
drizzleOrm.eq(agentRelations.sourceAgentId, params.agentId),
|
|
2453
2557
|
drizzleOrm.isNotNull(agentRelations.externalAgentId),
|
|
2454
2558
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
2455
|
-
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId)
|
|
2559
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
2560
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId)
|
|
2456
2561
|
)
|
|
2457
2562
|
);
|
|
2458
2563
|
return {
|
|
@@ -2478,7 +2583,7 @@ var getAgentRelationByParams = (db) => async (params) => {
|
|
|
2478
2583
|
const whereConditions = [
|
|
2479
2584
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2480
2585
|
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2481
|
-
drizzleOrm.eq(agentRelations.graphId, params.graphId),
|
|
2586
|
+
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2482
2587
|
drizzleOrm.eq(agentRelations.sourceAgentId, params.sourceAgentId),
|
|
2483
2588
|
drizzleOrm.eq(agentRelations.relationType, params.relationType)
|
|
2484
2589
|
];
|
|
@@ -2494,8 +2599,7 @@ var getAgentRelationByParams = (db) => async (params) => {
|
|
|
2494
2599
|
};
|
|
2495
2600
|
var upsertAgentRelation = (db) => async (params) => {
|
|
2496
2601
|
const existing = await getAgentRelationByParams(db)({
|
|
2497
|
-
scopes: { tenantId: params.tenantId, projectId: params.projectId },
|
|
2498
|
-
graphId: params.graphId,
|
|
2602
|
+
scopes: { tenantId: params.tenantId, projectId: params.projectId, graphId: params.graphId },
|
|
2499
2603
|
sourceAgentId: params.sourceAgentId,
|
|
2500
2604
|
targetAgentId: params.targetAgentId,
|
|
2501
2605
|
externalAgentId: params.externalAgentId,
|
|
@@ -2521,6 +2625,7 @@ var updateAgentRelation = (db) => async (params) => {
|
|
|
2521
2625
|
drizzleOrm.and(
|
|
2522
2626
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2523
2627
|
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2628
|
+
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2524
2629
|
drizzleOrm.eq(agentRelations.id, params.relationId)
|
|
2525
2630
|
)
|
|
2526
2631
|
).returning();
|
|
@@ -2531,6 +2636,7 @@ var deleteAgentRelation = (db) => async (params) => {
|
|
|
2531
2636
|
drizzleOrm.and(
|
|
2532
2637
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2533
2638
|
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2639
|
+
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2534
2640
|
drizzleOrm.eq(agentRelations.id, params.relationId)
|
|
2535
2641
|
)
|
|
2536
2642
|
);
|
|
@@ -2540,7 +2646,7 @@ var deleteAgentRelationsByGraph = (db) => async (params) => {
|
|
|
2540
2646
|
const result = await db.delete(agentRelations).where(
|
|
2541
2647
|
drizzleOrm.and(
|
|
2542
2648
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2543
|
-
drizzleOrm.eq(agentRelations.graphId, params.graphId)
|
|
2649
|
+
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId)
|
|
2544
2650
|
)
|
|
2545
2651
|
);
|
|
2546
2652
|
return (result.rowsAffected || 0) > 0;
|
|
@@ -2551,6 +2657,7 @@ var createAgentToolRelation = (db) => async (params) => {
|
|
|
2551
2657
|
id: finalRelationId,
|
|
2552
2658
|
tenantId: params.scopes.tenantId,
|
|
2553
2659
|
projectId: params.scopes.projectId,
|
|
2660
|
+
graphId: params.scopes.graphId,
|
|
2554
2661
|
agentId: params.data.agentId,
|
|
2555
2662
|
toolId: params.data.toolId,
|
|
2556
2663
|
selectedTools: params.data.selectedTools
|
|
@@ -2566,6 +2673,7 @@ var updateAgentToolRelation = (db) => async (params) => {
|
|
|
2566
2673
|
drizzleOrm.and(
|
|
2567
2674
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2568
2675
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2676
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId),
|
|
2569
2677
|
drizzleOrm.eq(agentToolRelations.id, params.relationId)
|
|
2570
2678
|
)
|
|
2571
2679
|
).returning();
|
|
@@ -2576,6 +2684,7 @@ var deleteAgentToolRelation = (db) => async (params) => {
|
|
|
2576
2684
|
drizzleOrm.and(
|
|
2577
2685
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2578
2686
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2687
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId),
|
|
2579
2688
|
drizzleOrm.eq(agentToolRelations.id, params.relationId)
|
|
2580
2689
|
)
|
|
2581
2690
|
);
|
|
@@ -2585,7 +2694,9 @@ var deleteAgentToolRelationByAgent = (db) => async (params) => {
|
|
|
2585
2694
|
const result = await db.delete(agentToolRelations).where(
|
|
2586
2695
|
drizzleOrm.and(
|
|
2587
2696
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2588
|
-
drizzleOrm.eq(agentToolRelations.
|
|
2697
|
+
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2698
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId),
|
|
2699
|
+
drizzleOrm.eq(agentToolRelations.agentId, params.scopes.agentId)
|
|
2589
2700
|
)
|
|
2590
2701
|
);
|
|
2591
2702
|
return (result.rowsAffected || 0) > 0;
|
|
@@ -2595,6 +2706,7 @@ var getAgentToolRelationById = (db) => async (params) => {
|
|
|
2595
2706
|
where: drizzleOrm.and(
|
|
2596
2707
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2597
2708
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2709
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId),
|
|
2598
2710
|
drizzleOrm.eq(agentToolRelations.id, params.relationId)
|
|
2599
2711
|
)
|
|
2600
2712
|
});
|
|
@@ -2608,14 +2720,14 @@ var getAgentToolRelationByAgent = (db) => async (params) => {
|
|
|
2608
2720
|
drizzleOrm.and(
|
|
2609
2721
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2610
2722
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2611
|
-
drizzleOrm.eq(agentToolRelations.agentId, params.agentId)
|
|
2723
|
+
drizzleOrm.eq(agentToolRelations.agentId, params.scopes.agentId)
|
|
2612
2724
|
)
|
|
2613
2725
|
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(agentToolRelations.createdAt)),
|
|
2614
2726
|
db.select({ count: drizzleOrm.count() }).from(agentToolRelations).where(
|
|
2615
2727
|
drizzleOrm.and(
|
|
2616
2728
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2617
2729
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2618
|
-
drizzleOrm.eq(agentToolRelations.agentId, params.agentId)
|
|
2730
|
+
drizzleOrm.eq(agentToolRelations.agentId, params.scopes.agentId)
|
|
2619
2731
|
)
|
|
2620
2732
|
)
|
|
2621
2733
|
]);
|
|
@@ -2635,6 +2747,7 @@ var getAgentToolRelationByTool = (db) => async (params) => {
|
|
|
2635
2747
|
drizzleOrm.and(
|
|
2636
2748
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2637
2749
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2750
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId),
|
|
2638
2751
|
drizzleOrm.eq(agentToolRelations.toolId, params.toolId)
|
|
2639
2752
|
)
|
|
2640
2753
|
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(agentToolRelations.createdAt)),
|
|
@@ -2642,6 +2755,7 @@ var getAgentToolRelationByTool = (db) => async (params) => {
|
|
|
2642
2755
|
drizzleOrm.and(
|
|
2643
2756
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2644
2757
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2758
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId),
|
|
2645
2759
|
drizzleOrm.eq(agentToolRelations.toolId, params.toolId)
|
|
2646
2760
|
)
|
|
2647
2761
|
)
|
|
@@ -2661,13 +2775,15 @@ var listAgentToolRelations = (db) => async (params) => {
|
|
|
2661
2775
|
db.select().from(agentToolRelations).where(
|
|
2662
2776
|
drizzleOrm.and(
|
|
2663
2777
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2664
|
-
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId)
|
|
2778
|
+
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2779
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId)
|
|
2665
2780
|
)
|
|
2666
2781
|
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(agentToolRelations.createdAt)),
|
|
2667
2782
|
db.select({ count: drizzleOrm.count() }).from(agentToolRelations).where(
|
|
2668
2783
|
drizzleOrm.and(
|
|
2669
2784
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2670
|
-
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId)
|
|
2785
|
+
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2786
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId)
|
|
2671
2787
|
)
|
|
2672
2788
|
)
|
|
2673
2789
|
]);
|
|
@@ -2678,26 +2794,6 @@ var listAgentToolRelations = (db) => async (params) => {
|
|
|
2678
2794
|
pagination: { page, limit, total, pages }
|
|
2679
2795
|
};
|
|
2680
2796
|
};
|
|
2681
|
-
var listAgentToolRelationsByAgent = (db) => async (params) => {
|
|
2682
|
-
const page = params.pagination?.page || 1;
|
|
2683
|
-
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
2684
|
-
const offset = (page - 1) * limit;
|
|
2685
|
-
const whereClause = drizzleOrm.and(
|
|
2686
|
-
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2687
|
-
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2688
|
-
drizzleOrm.eq(agentToolRelations.agentId, params.agentId)
|
|
2689
|
-
);
|
|
2690
|
-
const [data, totalResult] = await Promise.all([
|
|
2691
|
-
db.select().from(agentToolRelations).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(agentToolRelations.createdAt)),
|
|
2692
|
-
db.select({ count: drizzleOrm.count() }).from(agentToolRelations).where(whereClause)
|
|
2693
|
-
]);
|
|
2694
|
-
const total = totalResult[0]?.count || 0;
|
|
2695
|
-
const pages = Math.ceil(total / limit);
|
|
2696
|
-
return {
|
|
2697
|
-
data,
|
|
2698
|
-
pagination: { page, limit, total, pages }
|
|
2699
|
-
};
|
|
2700
|
-
};
|
|
2701
2797
|
var getToolsForAgent = (db) => async (params) => {
|
|
2702
2798
|
const page = params.pagination?.page || 1;
|
|
2703
2799
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
@@ -2728,14 +2824,16 @@ var getToolsForAgent = (db) => async (params) => {
|
|
|
2728
2824
|
drizzleOrm.and(
|
|
2729
2825
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2730
2826
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2731
|
-
drizzleOrm.eq(agentToolRelations.
|
|
2827
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId),
|
|
2828
|
+
drizzleOrm.eq(agentToolRelations.agentId, params.scopes.agentId)
|
|
2732
2829
|
)
|
|
2733
2830
|
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(agentToolRelations.createdAt)),
|
|
2734
2831
|
db.select({ count: drizzleOrm.count() }).from(agentToolRelations).where(
|
|
2735
2832
|
drizzleOrm.and(
|
|
2736
2833
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2737
2834
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2738
|
-
drizzleOrm.eq(agentToolRelations.
|
|
2835
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId),
|
|
2836
|
+
drizzleOrm.eq(agentToolRelations.agentId, params.scopes.agentId)
|
|
2739
2837
|
)
|
|
2740
2838
|
)
|
|
2741
2839
|
]);
|
|
@@ -2764,6 +2862,9 @@ var getAgentsForTool = (db) => async (params) => {
|
|
|
2764
2862
|
name: agents.name,
|
|
2765
2863
|
description: agents.description,
|
|
2766
2864
|
prompt: agents.prompt,
|
|
2865
|
+
conversationHistoryConfig: agents.conversationHistoryConfig,
|
|
2866
|
+
models: agents.models,
|
|
2867
|
+
stopWhen: agents.stopWhen,
|
|
2767
2868
|
createdAt: agents.createdAt,
|
|
2768
2869
|
updatedAt: agents.updatedAt
|
|
2769
2870
|
}
|
|
@@ -2771,6 +2872,7 @@ var getAgentsForTool = (db) => async (params) => {
|
|
|
2771
2872
|
drizzleOrm.and(
|
|
2772
2873
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2773
2874
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2875
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId),
|
|
2774
2876
|
drizzleOrm.eq(agentToolRelations.toolId, params.toolId)
|
|
2775
2877
|
)
|
|
2776
2878
|
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(agentToolRelations.createdAt)),
|
|
@@ -2778,6 +2880,7 @@ var getAgentsForTool = (db) => async (params) => {
|
|
|
2778
2880
|
drizzleOrm.and(
|
|
2779
2881
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2780
2882
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
2883
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId),
|
|
2781
2884
|
drizzleOrm.eq(agentToolRelations.toolId, params.toolId)
|
|
2782
2885
|
)
|
|
2783
2886
|
)
|
|
@@ -2794,7 +2897,8 @@ var validateInternalAgent = (db) => async (params) => {
|
|
|
2794
2897
|
drizzleOrm.and(
|
|
2795
2898
|
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
2796
2899
|
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
2797
|
-
drizzleOrm.eq(agents.
|
|
2900
|
+
drizzleOrm.eq(agents.graphId, params.scopes.graphId),
|
|
2901
|
+
drizzleOrm.eq(agents.id, params.scopes.agentId)
|
|
2798
2902
|
)
|
|
2799
2903
|
).limit(1);
|
|
2800
2904
|
return result.length > 0;
|
|
@@ -2804,7 +2908,8 @@ var validateExternalAgent = (db) => async (params) => {
|
|
|
2804
2908
|
drizzleOrm.and(
|
|
2805
2909
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
2806
2910
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
2807
|
-
drizzleOrm.eq(externalAgents.
|
|
2911
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId),
|
|
2912
|
+
drizzleOrm.eq(externalAgents.id, params.scopes.agentId)
|
|
2808
2913
|
)
|
|
2809
2914
|
).limit(1);
|
|
2810
2915
|
return result.length > 0;
|
|
@@ -2814,6 +2919,7 @@ var getAgentById = (db) => async (params) => {
|
|
|
2814
2919
|
where: drizzleOrm.and(
|
|
2815
2920
|
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
2816
2921
|
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
2922
|
+
drizzleOrm.eq(agents.graphId, params.scopes.graphId),
|
|
2817
2923
|
drizzleOrm.eq(agents.id, params.agentId)
|
|
2818
2924
|
)
|
|
2819
2925
|
});
|
|
@@ -2823,7 +2929,8 @@ var listAgents = (db) => async (params) => {
|
|
|
2823
2929
|
return await db.query.agents.findMany({
|
|
2824
2930
|
where: drizzleOrm.and(
|
|
2825
2931
|
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
2826
|
-
drizzleOrm.eq(agents.projectId, params.scopes.projectId)
|
|
2932
|
+
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
2933
|
+
drizzleOrm.eq(agents.graphId, params.scopes.graphId)
|
|
2827
2934
|
)
|
|
2828
2935
|
});
|
|
2829
2936
|
};
|
|
@@ -2833,7 +2940,8 @@ var listAgentsPaginated = (db) => async (params) => {
|
|
|
2833
2940
|
const offset = (page - 1) * limit;
|
|
2834
2941
|
const whereClause = drizzleOrm.and(
|
|
2835
2942
|
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
2836
|
-
drizzleOrm.eq(agents.projectId, params.scopes.projectId)
|
|
2943
|
+
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
2944
|
+
drizzleOrm.eq(agents.graphId, params.scopes.graphId)
|
|
2837
2945
|
);
|
|
2838
2946
|
const [data, totalResult] = await Promise.all([
|
|
2839
2947
|
db.select().from(agents).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(agents.createdAt)),
|
|
@@ -2865,13 +2973,18 @@ var updateAgent = (db) => async (params) => {
|
|
|
2865
2973
|
drizzleOrm.and(
|
|
2866
2974
|
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
2867
2975
|
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
2976
|
+
drizzleOrm.eq(agents.graphId, params.scopes.graphId),
|
|
2868
2977
|
drizzleOrm.eq(agents.id, params.agentId)
|
|
2869
2978
|
)
|
|
2870
2979
|
).returning();
|
|
2871
2980
|
return agent[0] ?? null;
|
|
2872
2981
|
};
|
|
2873
2982
|
var upsertAgent = (db) => async (params) => {
|
|
2874
|
-
const scopes = {
|
|
2983
|
+
const scopes = {
|
|
2984
|
+
tenantId: params.data.tenantId,
|
|
2985
|
+
projectId: params.data.projectId,
|
|
2986
|
+
graphId: params.data.graphId
|
|
2987
|
+
};
|
|
2875
2988
|
const existing = await getAgentById(db)({
|
|
2876
2989
|
scopes,
|
|
2877
2990
|
agentId: params.data.id
|
|
@@ -2902,6 +3015,7 @@ var deleteAgent = (db) => async (params) => {
|
|
|
2902
3015
|
drizzleOrm.and(
|
|
2903
3016
|
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
2904
3017
|
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
3018
|
+
drizzleOrm.eq(agents.graphId, params.scopes.graphId),
|
|
2905
3019
|
drizzleOrm.eq(agents.id, params.agentId)
|
|
2906
3020
|
)
|
|
2907
3021
|
);
|
|
@@ -2919,36 +3033,11 @@ var getAgentsByIds = (db) => async (params) => {
|
|
|
2919
3033
|
drizzleOrm.and(
|
|
2920
3034
|
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
2921
3035
|
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
3036
|
+
drizzleOrm.eq(agents.graphId, params.scopes.graphId),
|
|
2922
3037
|
drizzleOrm.inArray(agents.id, params.agentIds)
|
|
2923
3038
|
)
|
|
2924
3039
|
);
|
|
2925
3040
|
};
|
|
2926
|
-
var getAgentInGraphContext = (db) => async (params) => {
|
|
2927
|
-
return await db.select({
|
|
2928
|
-
id: agents.id,
|
|
2929
|
-
name: agents.name,
|
|
2930
|
-
description: agents.description,
|
|
2931
|
-
prompt: agents.prompt,
|
|
2932
|
-
tenantId: agents.tenantId,
|
|
2933
|
-
graphId: agentRelations.graphId,
|
|
2934
|
-
sourceAgentId: agentRelations.sourceAgentId
|
|
2935
|
-
}).from(agents).innerJoin(
|
|
2936
|
-
agentRelations,
|
|
2937
|
-
drizzleOrm.and(
|
|
2938
|
-
drizzleOrm.eq(agents.tenantId, agentRelations.tenantId),
|
|
2939
|
-
drizzleOrm.eq(agents.projectId, agentRelations.projectId),
|
|
2940
|
-
drizzleOrm.eq(agents.id, agentRelations.sourceAgentId),
|
|
2941
|
-
drizzleOrm.eq(agentRelations.graphId, params.graphId)
|
|
2942
|
-
)
|
|
2943
|
-
).where(
|
|
2944
|
-
drizzleOrm.and(
|
|
2945
|
-
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
2946
|
-
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
2947
|
-
drizzleOrm.eq(agents.id, params.agentId),
|
|
2948
|
-
drizzleOrm.eq(agentRelations.graphId, params.graphId)
|
|
2949
|
-
)
|
|
2950
|
-
);
|
|
2951
|
-
};
|
|
2952
3041
|
var getContextConfigById = (db) => async (params) => {
|
|
2953
3042
|
return await db.query.contextConfigs.findFirst({
|
|
2954
3043
|
where: drizzleOrm.and(
|
|
@@ -3103,6 +3192,8 @@ var getExternalAgent = (db) => async (params) => {
|
|
|
3103
3192
|
const result = await db.query.externalAgents.findFirst({
|
|
3104
3193
|
where: drizzleOrm.and(
|
|
3105
3194
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3195
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3196
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId),
|
|
3106
3197
|
drizzleOrm.eq(externalAgents.id, params.agentId)
|
|
3107
3198
|
)
|
|
3108
3199
|
});
|
|
@@ -3112,6 +3203,8 @@ var getExternalAgentByUrl = (db) => async (params) => {
|
|
|
3112
3203
|
const result = await db.query.externalAgents.findFirst({
|
|
3113
3204
|
where: drizzleOrm.and(
|
|
3114
3205
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3206
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3207
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId),
|
|
3115
3208
|
drizzleOrm.eq(externalAgents.baseUrl, params.baseUrl)
|
|
3116
3209
|
)
|
|
3117
3210
|
});
|
|
@@ -3119,7 +3212,11 @@ var getExternalAgentByUrl = (db) => async (params) => {
|
|
|
3119
3212
|
};
|
|
3120
3213
|
var listExternalAgents = (db) => async (params) => {
|
|
3121
3214
|
return await db.query.externalAgents.findMany({
|
|
3122
|
-
where: drizzleOrm.
|
|
3215
|
+
where: drizzleOrm.and(
|
|
3216
|
+
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3217
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3218
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId)
|
|
3219
|
+
),
|
|
3123
3220
|
orderBy: [drizzleOrm.asc(externalAgents.name)]
|
|
3124
3221
|
});
|
|
3125
3222
|
};
|
|
@@ -3128,8 +3225,20 @@ var listExternalAgentsPaginated = (db) => async (params) => {
|
|
|
3128
3225
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
3129
3226
|
const offset = (page - 1) * limit;
|
|
3130
3227
|
const [data, totalResult] = await Promise.all([
|
|
3131
|
-
db.select().from(externalAgents).where(
|
|
3132
|
-
|
|
3228
|
+
db.select().from(externalAgents).where(
|
|
3229
|
+
drizzleOrm.and(
|
|
3230
|
+
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3231
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3232
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId)
|
|
3233
|
+
)
|
|
3234
|
+
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(externalAgents.createdAt)),
|
|
3235
|
+
db.select({ count: drizzleOrm.count() }).from(externalAgents).where(
|
|
3236
|
+
drizzleOrm.and(
|
|
3237
|
+
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3238
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3239
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId)
|
|
3240
|
+
)
|
|
3241
|
+
)
|
|
3133
3242
|
]);
|
|
3134
3243
|
const total = typeof totalResult[0]?.count === "string" ? parseInt(totalResult[0].count, 10) : totalResult[0]?.count || 0;
|
|
3135
3244
|
const pages = Math.ceil(total / limit);
|
|
@@ -3155,13 +3264,19 @@ var updateExternalAgent = (db) => async (params) => {
|
|
|
3155
3264
|
const result = await db.update(externalAgents).set(updateData).where(
|
|
3156
3265
|
drizzleOrm.and(
|
|
3157
3266
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3267
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3268
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId),
|
|
3158
3269
|
drizzleOrm.eq(externalAgents.id, params.agentId)
|
|
3159
3270
|
)
|
|
3160
3271
|
).returning();
|
|
3161
3272
|
return result[0] || null;
|
|
3162
3273
|
};
|
|
3163
3274
|
var upsertExternalAgent = (db) => async (params) => {
|
|
3164
|
-
const scopes = {
|
|
3275
|
+
const scopes = {
|
|
3276
|
+
tenantId: params.data.tenantId,
|
|
3277
|
+
projectId: params.data.projectId,
|
|
3278
|
+
graphId: params.data.graphId
|
|
3279
|
+
};
|
|
3165
3280
|
const existing = await getExternalAgent(db)({
|
|
3166
3281
|
scopes,
|
|
3167
3282
|
agentId: params.data.id
|
|
@@ -3191,6 +3306,8 @@ var deleteExternalAgent = (db) => async (params) => {
|
|
|
3191
3306
|
const result = await db.delete(externalAgents).where(
|
|
3192
3307
|
drizzleOrm.and(
|
|
3193
3308
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3309
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3310
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId),
|
|
3194
3311
|
drizzleOrm.eq(externalAgents.id, params.agentId)
|
|
3195
3312
|
)
|
|
3196
3313
|
).returning();
|
|
@@ -3209,27 +3326,24 @@ var externalAgentUrlExists = (db) => async (params) => {
|
|
|
3209
3326
|
return agent !== null;
|
|
3210
3327
|
};
|
|
3211
3328
|
var countExternalAgents = (db) => async (params) => {
|
|
3212
|
-
const result = await db.select({ count: drizzleOrm.count() }).from(externalAgents).where(
|
|
3329
|
+
const result = await db.select({ count: drizzleOrm.count() }).from(externalAgents).where(
|
|
3330
|
+
drizzleOrm.and(
|
|
3331
|
+
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3332
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3333
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId)
|
|
3334
|
+
)
|
|
3335
|
+
);
|
|
3213
3336
|
const countValue = result[0]?.count;
|
|
3214
3337
|
return typeof countValue === "string" ? parseInt(countValue, 10) : countValue || 0;
|
|
3215
3338
|
};
|
|
3216
3339
|
|
|
3217
3340
|
// src/data-access/agentGraphs.ts
|
|
3218
|
-
var getAgentGraph = (db) => async (params) => {
|
|
3219
|
-
return await db.query.agentGraph.findFirst({
|
|
3220
|
-
where: drizzleOrm.and(
|
|
3221
|
-
drizzleOrm.eq(agentGraph.tenantId, params.scopes.tenantId),
|
|
3222
|
-
drizzleOrm.eq(agentGraph.projectId, params.scopes.projectId),
|
|
3223
|
-
drizzleOrm.eq(agentGraph.id, params.graphId)
|
|
3224
|
-
)
|
|
3225
|
-
});
|
|
3226
|
-
};
|
|
3227
3341
|
var getAgentGraphById = (db) => async (params) => {
|
|
3228
3342
|
const result = await db.query.agentGraph.findFirst({
|
|
3229
3343
|
where: drizzleOrm.and(
|
|
3230
3344
|
drizzleOrm.eq(agentGraph.tenantId, params.scopes.tenantId),
|
|
3231
3345
|
drizzleOrm.eq(agentGraph.projectId, params.scopes.projectId),
|
|
3232
|
-
drizzleOrm.eq(agentGraph.id, params.graphId)
|
|
3346
|
+
drizzleOrm.eq(agentGraph.id, params.scopes.graphId)
|
|
3233
3347
|
)
|
|
3234
3348
|
});
|
|
3235
3349
|
return result ?? null;
|
|
@@ -3239,7 +3353,7 @@ var getAgentGraphWithDefaultAgent = (db) => async (params) => {
|
|
|
3239
3353
|
where: drizzleOrm.and(
|
|
3240
3354
|
drizzleOrm.eq(agentGraph.tenantId, params.scopes.tenantId),
|
|
3241
3355
|
drizzleOrm.eq(agentGraph.projectId, params.scopes.projectId),
|
|
3242
|
-
drizzleOrm.eq(agentGraph.id, params.graphId)
|
|
3356
|
+
drizzleOrm.eq(agentGraph.id, params.scopes.graphId)
|
|
3243
3357
|
),
|
|
3244
3358
|
with: {
|
|
3245
3359
|
defaultAgent: true
|
|
@@ -3332,7 +3446,7 @@ var updateAgentGraph = (db) => async (params) => {
|
|
|
3332
3446
|
drizzleOrm.and(
|
|
3333
3447
|
drizzleOrm.eq(agentGraph.tenantId, params.scopes.tenantId),
|
|
3334
3448
|
drizzleOrm.eq(agentGraph.projectId, params.scopes.projectId),
|
|
3335
|
-
drizzleOrm.eq(agentGraph.id, params.graphId)
|
|
3449
|
+
drizzleOrm.eq(agentGraph.id, params.scopes.graphId)
|
|
3336
3450
|
)
|
|
3337
3451
|
).returning();
|
|
3338
3452
|
return graph[0] ?? null;
|
|
@@ -3342,7 +3456,7 @@ var deleteAgentGraph = (db) => async (params) => {
|
|
|
3342
3456
|
drizzleOrm.and(
|
|
3343
3457
|
drizzleOrm.eq(agentGraph.tenantId, params.scopes.tenantId),
|
|
3344
3458
|
drizzleOrm.eq(agentGraph.projectId, params.scopes.projectId),
|
|
3345
|
-
drizzleOrm.eq(agentGraph.id, params.graphId)
|
|
3459
|
+
drizzleOrm.eq(agentGraph.id, params.scopes.graphId)
|
|
3346
3460
|
)
|
|
3347
3461
|
).returning();
|
|
3348
3462
|
return result.length > 0;
|
|
@@ -3369,17 +3483,14 @@ var getGraphAgentInfos = (db) => async ({
|
|
|
3369
3483
|
agentId
|
|
3370
3484
|
}) => {
|
|
3371
3485
|
const { tenantId, projectId } = scopes;
|
|
3372
|
-
const graph = await
|
|
3373
|
-
scopes: { tenantId, projectId }
|
|
3374
|
-
graphId
|
|
3486
|
+
const graph = await getAgentGraphById(db)({
|
|
3487
|
+
scopes: { tenantId, projectId, graphId }
|
|
3375
3488
|
});
|
|
3376
3489
|
if (!graph) {
|
|
3377
3490
|
throw new Error(`Agent graph with ID ${graphId} not found for tenant ${tenantId}`);
|
|
3378
3491
|
}
|
|
3379
3492
|
const relations2 = await getAgentRelations(db)({
|
|
3380
|
-
scopes: { tenantId, projectId }
|
|
3381
|
-
graphId,
|
|
3382
|
-
agentId
|
|
3493
|
+
scopes: { tenantId, projectId, graphId, agentId }
|
|
3383
3494
|
});
|
|
3384
3495
|
const targetAgentIds = relations2.map((relation) => relation.targetAgentId).filter((id) => id !== null);
|
|
3385
3496
|
if (targetAgentIds.length === 0) {
|
|
@@ -3388,7 +3499,7 @@ var getGraphAgentInfos = (db) => async ({
|
|
|
3388
3499
|
const agentInfos = await Promise.all(
|
|
3389
3500
|
targetAgentIds.map(async (targetAgentId) => {
|
|
3390
3501
|
const agent = await getAgentById(db)({
|
|
3391
|
-
scopes: { tenantId, projectId },
|
|
3502
|
+
scopes: { tenantId, projectId, graphId },
|
|
3392
3503
|
agentId: targetAgentId
|
|
3393
3504
|
});
|
|
3394
3505
|
if (agent !== void 0) {
|
|
@@ -3400,55 +3511,35 @@ var getGraphAgentInfos = (db) => async ({
|
|
|
3400
3511
|
return agentInfos.filter((agent) => agent !== null);
|
|
3401
3512
|
};
|
|
3402
3513
|
var getFullGraphDefinition = (db) => async ({
|
|
3403
|
-
scopes: { tenantId, projectId }
|
|
3404
|
-
graphId
|
|
3514
|
+
scopes: { tenantId, projectId, graphId }
|
|
3405
3515
|
}) => {
|
|
3406
3516
|
const graph = await getAgentGraphById(db)({
|
|
3407
|
-
scopes: { tenantId, projectId }
|
|
3408
|
-
graphId
|
|
3517
|
+
scopes: { tenantId, projectId, graphId }
|
|
3409
3518
|
});
|
|
3410
3519
|
if (!graph) {
|
|
3411
3520
|
return null;
|
|
3412
3521
|
}
|
|
3413
3522
|
const graphRelations = await getAgentRelationsByGraph(db)({
|
|
3414
|
-
scopes: { tenantId, projectId }
|
|
3415
|
-
|
|
3523
|
+
scopes: { tenantId, projectId, graphId }
|
|
3524
|
+
});
|
|
3525
|
+
const graphAgents = await db.query.agents.findMany({
|
|
3526
|
+
where: drizzleOrm.and(
|
|
3527
|
+
drizzleOrm.eq(agents.tenantId, tenantId),
|
|
3528
|
+
drizzleOrm.eq(agents.projectId, projectId),
|
|
3529
|
+
drizzleOrm.eq(agents.graphId, graphId)
|
|
3530
|
+
)
|
|
3416
3531
|
});
|
|
3417
|
-
const internalAgentIds = /* @__PURE__ */ new Set();
|
|
3418
3532
|
const externalAgentIds = /* @__PURE__ */ new Set();
|
|
3419
|
-
internalAgentIds.add(graph.defaultAgentId);
|
|
3420
3533
|
for (const relation of graphRelations) {
|
|
3421
|
-
if (relation.sourceAgentId) {
|
|
3422
|
-
internalAgentIds.add(relation.sourceAgentId);
|
|
3423
|
-
}
|
|
3424
|
-
if (relation.targetAgentId) {
|
|
3425
|
-
internalAgentIds.add(relation.targetAgentId);
|
|
3426
|
-
}
|
|
3427
3534
|
if (relation.externalAgentId) {
|
|
3428
3535
|
externalAgentIds.add(relation.externalAgentId);
|
|
3429
3536
|
}
|
|
3430
3537
|
}
|
|
3431
|
-
const
|
|
3432
|
-
|
|
3433
|
-
drizzleOrm.eq(agentToolRelations.tenantId, tenantId),
|
|
3434
|
-
drizzleOrm.eq(agentToolRelations.projectId, projectId),
|
|
3435
|
-
// We need to find tools that belong to this graph
|
|
3436
|
-
// Tools created as part of a graph have IDs that include the graph ID
|
|
3437
|
-
drizzleOrm.like(tools.id, `%${graphId}%`)
|
|
3438
|
-
)
|
|
3439
|
-
);
|
|
3440
|
-
for (const agentTool of agentsWithTools) {
|
|
3441
|
-
internalAgentIds.add(agentTool.agentId);
|
|
3442
|
-
}
|
|
3443
|
-
const graphAgents = await Promise.all(
|
|
3444
|
-
Array.from(internalAgentIds).map(async (agentId) => {
|
|
3445
|
-
const agent = await getAgentById(db)({
|
|
3446
|
-
scopes: { tenantId, projectId },
|
|
3447
|
-
agentId
|
|
3448
|
-
});
|
|
3538
|
+
const processedAgents = await Promise.all(
|
|
3539
|
+
graphAgents.map(async (agent) => {
|
|
3449
3540
|
if (!agent) return null;
|
|
3450
3541
|
const agentRelationsList = graphRelations.filter(
|
|
3451
|
-
(relation) => relation.sourceAgentId ===
|
|
3542
|
+
(relation) => relation.sourceAgentId === agent.id
|
|
3452
3543
|
);
|
|
3453
3544
|
const canTransferTo = agentRelationsList.filter((rel) => rel.relationType === "transfer" || rel.relationType === "transfer_to").map((rel) => rel.targetAgentId).filter((id) => id !== null);
|
|
3454
3545
|
const canDelegateTo = agentRelationsList.filter((rel) => rel.relationType === "delegate" || rel.relationType === "delegate_to").map((rel) => rel.targetAgentId || rel.externalAgentId).filter((id) => id !== null);
|
|
@@ -3465,19 +3556,19 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3465
3556
|
lastToolsSync: tools.lastToolsSync,
|
|
3466
3557
|
selectedTools: agentToolRelations.selectedTools
|
|
3467
3558
|
}).from(agentToolRelations).innerJoin(tools, drizzleOrm.eq(agentToolRelations.toolId, tools.id)).where(
|
|
3468
|
-
drizzleOrm.and(drizzleOrm.eq(agentToolRelations.tenantId, tenantId), drizzleOrm.eq(agentToolRelations.agentId,
|
|
3559
|
+
drizzleOrm.and(drizzleOrm.eq(agentToolRelations.tenantId, tenantId), drizzleOrm.eq(agentToolRelations.agentId, agent.id))
|
|
3469
3560
|
);
|
|
3470
3561
|
const agentDataComponentRelations = await db.query.agentDataComponents.findMany({
|
|
3471
3562
|
where: drizzleOrm.and(
|
|
3472
3563
|
drizzleOrm.eq(agentDataComponents.tenantId, tenantId),
|
|
3473
|
-
drizzleOrm.eq(agentDataComponents.agentId,
|
|
3564
|
+
drizzleOrm.eq(agentDataComponents.agentId, agent.id)
|
|
3474
3565
|
)
|
|
3475
3566
|
});
|
|
3476
3567
|
const agentDataComponentIds = agentDataComponentRelations.map((rel) => rel.dataComponentId);
|
|
3477
3568
|
const agentArtifactComponentRelations = await db.query.agentArtifactComponents.findMany({
|
|
3478
3569
|
where: drizzleOrm.and(
|
|
3479
3570
|
drizzleOrm.eq(agentArtifactComponents.tenantId, tenantId),
|
|
3480
|
-
drizzleOrm.eq(agentArtifactComponents.agentId,
|
|
3571
|
+
drizzleOrm.eq(agentArtifactComponents.agentId, agent.id)
|
|
3481
3572
|
)
|
|
3482
3573
|
});
|
|
3483
3574
|
const agentArtifactComponentIds = agentArtifactComponentRelations.map(
|
|
@@ -3520,7 +3611,7 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3520
3611
|
const externalAgents2 = await Promise.all(
|
|
3521
3612
|
Array.from(externalAgentIds).map(async (agentId) => {
|
|
3522
3613
|
const agent = await getExternalAgent(db)({
|
|
3523
|
-
scopes: { tenantId, projectId },
|
|
3614
|
+
scopes: { tenantId, projectId, graphId },
|
|
3524
3615
|
agentId
|
|
3525
3616
|
});
|
|
3526
3617
|
if (!agent) return null;
|
|
@@ -3532,7 +3623,7 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3532
3623
|
};
|
|
3533
3624
|
})
|
|
3534
3625
|
);
|
|
3535
|
-
const validAgents = [...
|
|
3626
|
+
const validAgents = [...processedAgents, ...externalAgents2].filter(
|
|
3536
3627
|
(agent) => agent !== null
|
|
3537
3628
|
);
|
|
3538
3629
|
const agentsObject = {};
|
|
@@ -3578,6 +3669,7 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3578
3669
|
}
|
|
3579
3670
|
let dataComponentsObject = {};
|
|
3580
3671
|
try {
|
|
3672
|
+
const internalAgentIds = graphAgents.map((agent) => agent.id);
|
|
3581
3673
|
const agentIds = Array.from(internalAgentIds);
|
|
3582
3674
|
dataComponentsObject = await fetchComponentRelationships(db)(
|
|
3583
3675
|
{ tenantId, projectId },
|
|
@@ -3600,6 +3692,7 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3600
3692
|
}
|
|
3601
3693
|
let artifactComponentsObject = {};
|
|
3602
3694
|
try {
|
|
3695
|
+
const internalAgentIds = graphAgents.map((agent) => agent.id);
|
|
3603
3696
|
const agentIds = Array.from(internalAgentIds);
|
|
3604
3697
|
artifactComponentsObject = await fetchComponentRelationships(db)(
|
|
3605
3698
|
{ tenantId, projectId },
|
|
@@ -3706,16 +3799,14 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3706
3799
|
return result;
|
|
3707
3800
|
};
|
|
3708
3801
|
var upsertAgentGraph = (db) => async (params) => {
|
|
3709
|
-
const scopes = { tenantId: params.data.tenantId, projectId: params.data.projectId };
|
|
3710
3802
|
const graphId = params.data.id || nanoid.nanoid();
|
|
3803
|
+
const scopes = { tenantId: params.data.tenantId, projectId: params.data.projectId, graphId };
|
|
3711
3804
|
const existing = await getAgentGraphById(db)({
|
|
3712
|
-
scopes
|
|
3713
|
-
graphId
|
|
3805
|
+
scopes
|
|
3714
3806
|
});
|
|
3715
3807
|
if (existing) {
|
|
3716
3808
|
return await updateAgentGraph(db)({
|
|
3717
3809
|
scopes,
|
|
3718
|
-
graphId,
|
|
3719
3810
|
data: {
|
|
3720
3811
|
name: params.data.name,
|
|
3721
3812
|
defaultAgentId: params.data.defaultAgentId,
|
|
@@ -4061,7 +4152,8 @@ var getArtifactComponentsForAgent = (db) => async (params) => {
|
|
|
4061
4152
|
drizzleOrm.and(
|
|
4062
4153
|
drizzleOrm.eq(artifactComponents.tenantId, params.scopes.tenantId),
|
|
4063
4154
|
drizzleOrm.eq(artifactComponents.projectId, params.scopes.projectId),
|
|
4064
|
-
drizzleOrm.eq(agentArtifactComponents.
|
|
4155
|
+
drizzleOrm.eq(agentArtifactComponents.graphId, params.scopes.graphId),
|
|
4156
|
+
drizzleOrm.eq(agentArtifactComponents.agentId, params.scopes.agentId)
|
|
4065
4157
|
)
|
|
4066
4158
|
).orderBy(drizzleOrm.desc(artifactComponents.createdAt));
|
|
4067
4159
|
};
|
|
@@ -4070,7 +4162,8 @@ var associateArtifactComponentWithAgent = (db) => async (params) => {
|
|
|
4070
4162
|
id: nanoid.nanoid(),
|
|
4071
4163
|
tenantId: params.scopes.tenantId,
|
|
4072
4164
|
projectId: params.scopes.projectId,
|
|
4073
|
-
|
|
4165
|
+
graphId: params.scopes.graphId,
|
|
4166
|
+
agentId: params.scopes.agentId,
|
|
4074
4167
|
artifactComponentId: params.artifactComponentId,
|
|
4075
4168
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4076
4169
|
}).returning();
|
|
@@ -4082,7 +4175,8 @@ var removeArtifactComponentFromAgent = (db) => async (params) => {
|
|
|
4082
4175
|
drizzleOrm.and(
|
|
4083
4176
|
drizzleOrm.eq(agentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
4084
4177
|
drizzleOrm.eq(agentArtifactComponents.projectId, params.scopes.projectId),
|
|
4085
|
-
drizzleOrm.eq(agentArtifactComponents.
|
|
4178
|
+
drizzleOrm.eq(agentArtifactComponents.graphId, params.scopes.graphId),
|
|
4179
|
+
drizzleOrm.eq(agentArtifactComponents.agentId, params.scopes.agentId),
|
|
4086
4180
|
drizzleOrm.eq(agentArtifactComponents.artifactComponentId, params.artifactComponentId)
|
|
4087
4181
|
)
|
|
4088
4182
|
).returning();
|
|
@@ -4096,13 +4190,15 @@ var deleteAgentArtifactComponentRelationByAgent = (db) => async (params) => {
|
|
|
4096
4190
|
const result = await db.delete(agentArtifactComponents).where(
|
|
4097
4191
|
drizzleOrm.and(
|
|
4098
4192
|
drizzleOrm.eq(agentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
4099
|
-
drizzleOrm.eq(agentArtifactComponents.
|
|
4193
|
+
drizzleOrm.eq(agentArtifactComponents.graphId, params.scopes.graphId),
|
|
4194
|
+
drizzleOrm.eq(agentArtifactComponents.agentId, params.scopes.agentId)
|
|
4100
4195
|
)
|
|
4101
4196
|
);
|
|
4102
4197
|
return (result.rowsAffected || 0) > 0;
|
|
4103
4198
|
};
|
|
4104
4199
|
var getAgentsUsingArtifactComponent = (db) => async (params) => {
|
|
4105
4200
|
return await db.select({
|
|
4201
|
+
graphId: agentArtifactComponents.graphId,
|
|
4106
4202
|
agentId: agentArtifactComponents.agentId,
|
|
4107
4203
|
createdAt: agentArtifactComponents.createdAt
|
|
4108
4204
|
}).from(agentArtifactComponents).where(
|
|
@@ -4118,7 +4214,8 @@ var isArtifactComponentAssociatedWithAgent = (db) => async (params) => {
|
|
|
4118
4214
|
drizzleOrm.and(
|
|
4119
4215
|
drizzleOrm.eq(agentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
4120
4216
|
drizzleOrm.eq(agentArtifactComponents.projectId, params.scopes.projectId),
|
|
4121
|
-
drizzleOrm.eq(agentArtifactComponents.
|
|
4217
|
+
drizzleOrm.eq(agentArtifactComponents.graphId, params.scopes.graphId),
|
|
4218
|
+
drizzleOrm.eq(agentArtifactComponents.agentId, params.scopes.agentId),
|
|
4122
4219
|
drizzleOrm.eq(agentArtifactComponents.artifactComponentId, params.artifactComponentId)
|
|
4123
4220
|
)
|
|
4124
4221
|
).limit(1);
|
|
@@ -4129,7 +4226,7 @@ var graphHasArtifactComponents = (db) => async (params) => {
|
|
|
4129
4226
|
drizzleOrm.and(
|
|
4130
4227
|
drizzleOrm.eq(agentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
4131
4228
|
drizzleOrm.eq(agentArtifactComponents.projectId, params.scopes.projectId),
|
|
4132
|
-
drizzleOrm.eq(agentRelations.graphId, params.graphId)
|
|
4229
|
+
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId)
|
|
4133
4230
|
)
|
|
4134
4231
|
).limit(1);
|
|
4135
4232
|
const total = result[0]?.count || 0;
|
|
@@ -4151,7 +4248,8 @@ var countArtifactComponentsForAgent = (db) => async (params) => {
|
|
|
4151
4248
|
drizzleOrm.and(
|
|
4152
4249
|
drizzleOrm.eq(agentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
4153
4250
|
drizzleOrm.eq(agentArtifactComponents.projectId, params.scopes.projectId),
|
|
4154
|
-
drizzleOrm.eq(agentArtifactComponents.
|
|
4251
|
+
drizzleOrm.eq(agentArtifactComponents.graphId, params.scopes.graphId),
|
|
4252
|
+
drizzleOrm.eq(agentArtifactComponents.agentId, params.scopes.agentId)
|
|
4155
4253
|
)
|
|
4156
4254
|
);
|
|
4157
4255
|
const total = result[0]?.count || 0;
|
|
@@ -4771,7 +4869,8 @@ var getDataComponentsForAgent = (db) => async (params) => {
|
|
|
4771
4869
|
drizzleOrm.and(
|
|
4772
4870
|
drizzleOrm.eq(dataComponents.tenantId, params.scopes.tenantId),
|
|
4773
4871
|
drizzleOrm.eq(dataComponents.projectId, params.scopes.projectId),
|
|
4774
|
-
drizzleOrm.eq(agentDataComponents.
|
|
4872
|
+
drizzleOrm.eq(agentDataComponents.graphId, params.scopes.graphId),
|
|
4873
|
+
drizzleOrm.eq(agentDataComponents.agentId, params.scopes.agentId)
|
|
4775
4874
|
)
|
|
4776
4875
|
).orderBy(drizzleOrm.desc(dataComponents.createdAt));
|
|
4777
4876
|
};
|
|
@@ -4780,7 +4879,8 @@ var associateDataComponentWithAgent = (db) => async (params) => {
|
|
|
4780
4879
|
id: nanoid.nanoid(),
|
|
4781
4880
|
tenantId: params.scopes.tenantId,
|
|
4782
4881
|
projectId: params.scopes.projectId,
|
|
4783
|
-
|
|
4882
|
+
graphId: params.scopes.graphId,
|
|
4883
|
+
agentId: params.scopes.agentId,
|
|
4784
4884
|
dataComponentId: params.dataComponentId
|
|
4785
4885
|
}).returning();
|
|
4786
4886
|
return association[0];
|
|
@@ -4790,7 +4890,8 @@ var removeDataComponentFromAgent = (db) => async (params) => {
|
|
|
4790
4890
|
drizzleOrm.and(
|
|
4791
4891
|
drizzleOrm.eq(agentDataComponents.tenantId, params.scopes.tenantId),
|
|
4792
4892
|
drizzleOrm.eq(agentDataComponents.projectId, params.scopes.projectId),
|
|
4793
|
-
drizzleOrm.eq(agentDataComponents.
|
|
4893
|
+
drizzleOrm.eq(agentDataComponents.graphId, params.scopes.graphId),
|
|
4894
|
+
drizzleOrm.eq(agentDataComponents.agentId, params.scopes.agentId),
|
|
4794
4895
|
drizzleOrm.eq(agentDataComponents.dataComponentId, params.dataComponentId)
|
|
4795
4896
|
)
|
|
4796
4897
|
).returning();
|
|
@@ -4800,7 +4901,8 @@ var deleteAgentDataComponentRelationByAgent = (db) => async (params) => {
|
|
|
4800
4901
|
const result = await db.delete(agentDataComponents).where(
|
|
4801
4902
|
drizzleOrm.and(
|
|
4802
4903
|
drizzleOrm.eq(agentDataComponents.tenantId, params.scopes.tenantId),
|
|
4803
|
-
drizzleOrm.eq(agentDataComponents.
|
|
4904
|
+
drizzleOrm.eq(agentDataComponents.graphId, params.scopes.graphId),
|
|
4905
|
+
drizzleOrm.eq(agentDataComponents.agentId, params.scopes.agentId)
|
|
4804
4906
|
)
|
|
4805
4907
|
);
|
|
4806
4908
|
return (result.rowsAffected || 0) > 0;
|
|
@@ -4822,7 +4924,8 @@ var isDataComponentAssociatedWithAgent = (db) => async (params) => {
|
|
|
4822
4924
|
drizzleOrm.and(
|
|
4823
4925
|
drizzleOrm.eq(agentDataComponents.tenantId, params.scopes.tenantId),
|
|
4824
4926
|
drizzleOrm.eq(agentDataComponents.projectId, params.scopes.projectId),
|
|
4825
|
-
drizzleOrm.eq(agentDataComponents.
|
|
4927
|
+
drizzleOrm.eq(agentDataComponents.graphId, params.scopes.graphId),
|
|
4928
|
+
drizzleOrm.eq(agentDataComponents.agentId, params.scopes.agentId),
|
|
4826
4929
|
drizzleOrm.eq(agentDataComponents.dataComponentId, params.dataComponentId)
|
|
4827
4930
|
)
|
|
4828
4931
|
).limit(1);
|
|
@@ -4876,9 +4979,11 @@ function isExternalAgent(agent) {
|
|
|
4876
4979
|
function validateAndTypeGraphData(data) {
|
|
4877
4980
|
return FullGraphDefinitionSchema.parse(data);
|
|
4878
4981
|
}
|
|
4879
|
-
function validateToolReferences(graphData) {
|
|
4982
|
+
function validateToolReferences(graphData, availableToolIds) {
|
|
4983
|
+
if (!availableToolIds) {
|
|
4984
|
+
return;
|
|
4985
|
+
}
|
|
4880
4986
|
const errors = [];
|
|
4881
|
-
const availableToolIds = new Set(Object.keys(graphData.tools || {}));
|
|
4882
4987
|
for (const [agentId, agentData] of Object.entries(graphData.agents)) {
|
|
4883
4988
|
if (isInternalAgent(agentData) && agentData.tools && Array.isArray(agentData.tools)) {
|
|
4884
4989
|
for (const toolId of agentData.tools) {
|
|
@@ -4893,9 +4998,11 @@ function validateToolReferences(graphData) {
|
|
|
4893
4998
|
${errors.join("\n")}`);
|
|
4894
4999
|
}
|
|
4895
5000
|
}
|
|
4896
|
-
function validateDataComponentReferences(graphData) {
|
|
5001
|
+
function validateDataComponentReferences(graphData, availableDataComponentIds) {
|
|
5002
|
+
if (!availableDataComponentIds) {
|
|
5003
|
+
return;
|
|
5004
|
+
}
|
|
4897
5005
|
const errors = [];
|
|
4898
|
-
const availableDataComponentIds = new Set(Object.keys(graphData.dataComponents || {}));
|
|
4899
5006
|
for (const [agentId, agentData] of Object.entries(graphData.agents)) {
|
|
4900
5007
|
if (isInternalAgent(agentData) && agentData.dataComponents) {
|
|
4901
5008
|
for (const dataComponentId of agentData.dataComponents) {
|
|
@@ -4912,9 +5019,11 @@ function validateDataComponentReferences(graphData) {
|
|
|
4912
5019
|
${errors.join("\n")}`);
|
|
4913
5020
|
}
|
|
4914
5021
|
}
|
|
4915
|
-
function validateArtifactComponentReferences(graphData) {
|
|
5022
|
+
function validateArtifactComponentReferences(graphData, availableArtifactComponentIds) {
|
|
5023
|
+
if (!availableArtifactComponentIds) {
|
|
5024
|
+
return;
|
|
5025
|
+
}
|
|
4916
5026
|
const errors = [];
|
|
4917
|
-
const availableArtifactComponentIds = new Set(Object.keys(graphData.artifactComponents || {}));
|
|
4918
5027
|
for (const [agentId, agentData] of Object.entries(graphData.agents)) {
|
|
4919
5028
|
if (isInternalAgent(agentData) && agentData.artifactComponents) {
|
|
4920
5029
|
for (const artifactComponentId of agentData.artifactComponents) {
|
|
@@ -4961,13 +5070,15 @@ function validateAgentRelationships(graphData) {
|
|
|
4961
5070
|
${errors.join("\n")}`);
|
|
4962
5071
|
}
|
|
4963
5072
|
}
|
|
4964
|
-
function validateGraphStructure(graphData) {
|
|
4965
|
-
if (!graphData.agents[graphData.defaultAgentId]) {
|
|
5073
|
+
function validateGraphStructure(graphData, projectResources) {
|
|
5074
|
+
if (graphData.defaultAgentId && !graphData.agents[graphData.defaultAgentId]) {
|
|
4966
5075
|
throw new Error(`Default agent '${graphData.defaultAgentId}' does not exist in agents`);
|
|
4967
5076
|
}
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
5077
|
+
if (projectResources) {
|
|
5078
|
+
validateToolReferences(graphData, projectResources.toolIds);
|
|
5079
|
+
validateDataComponentReferences(graphData, projectResources.dataComponentIds);
|
|
5080
|
+
validateArtifactComponentReferences(graphData, projectResources.artifactComponentIds);
|
|
5081
|
+
}
|
|
4971
5082
|
validateAgentRelationships(graphData);
|
|
4972
5083
|
}
|
|
4973
5084
|
var dbResultToMcpTool = (dbResult) => {
|
|
@@ -5088,6 +5199,7 @@ var addToolToAgent = (db) => async (params) => {
|
|
|
5088
5199
|
id,
|
|
5089
5200
|
tenantId: params.scopes.tenantId,
|
|
5090
5201
|
projectId: params.scopes.projectId,
|
|
5202
|
+
graphId: params.scopes.graphId,
|
|
5091
5203
|
agentId: params.agentId,
|
|
5092
5204
|
toolId: params.toolId,
|
|
5093
5205
|
selectedTools: params.selectedTools,
|
|
@@ -5101,6 +5213,7 @@ var removeToolFromAgent = (db) => async (params) => {
|
|
|
5101
5213
|
drizzleOrm.and(
|
|
5102
5214
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
5103
5215
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
5216
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId),
|
|
5104
5217
|
drizzleOrm.eq(agentToolRelations.agentId, params.agentId),
|
|
5105
5218
|
drizzleOrm.eq(agentToolRelations.toolId, params.toolId)
|
|
5106
5219
|
)
|
|
@@ -5112,6 +5225,7 @@ var upsertAgentToolRelation = (db) => async (params) => {
|
|
|
5112
5225
|
where: drizzleOrm.and(
|
|
5113
5226
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
5114
5227
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
5228
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId),
|
|
5115
5229
|
drizzleOrm.eq(agentToolRelations.agentId, params.agentId),
|
|
5116
5230
|
drizzleOrm.eq(agentToolRelations.toolId, params.toolId)
|
|
5117
5231
|
)
|
|
@@ -5168,13 +5282,17 @@ var getHealthyToolsForAgent = (db) => async (params) => {
|
|
|
5168
5282
|
}).from(tools).innerJoin(
|
|
5169
5283
|
agentToolRelations,
|
|
5170
5284
|
drizzleOrm.and(
|
|
5171
|
-
drizzleOrm.eq(tools.
|
|
5172
|
-
drizzleOrm.eq(
|
|
5173
|
-
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId)
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5285
|
+
drizzleOrm.eq(tools.tenantId, params.scopes.tenantId),
|
|
5286
|
+
drizzleOrm.eq(tools.projectId, params.scopes.projectId),
|
|
5287
|
+
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
5288
|
+
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
5289
|
+
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId),
|
|
5290
|
+
drizzleOrm.eq(agentToolRelations.agentId, params.scopes.agentId),
|
|
5291
|
+
drizzleOrm.eq(tools.id, agentToolRelations.toolId)
|
|
5292
|
+
)
|
|
5293
|
+
).where(drizzleOrm.eq(tools.status, "healthy"));
|
|
5294
|
+
return healthyTools.map((row) => row.tool);
|
|
5295
|
+
};
|
|
5178
5296
|
|
|
5179
5297
|
// src/data-access/graphFull.ts
|
|
5180
5298
|
var defaultLogger = {
|
|
@@ -5267,59 +5385,37 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5267
5385
|
validateGraphStructure(typed);
|
|
5268
5386
|
await applyExecutionLimitsInheritance(db, logger11, { tenantId, projectId }, typed);
|
|
5269
5387
|
try {
|
|
5270
|
-
if (typed.credentialReferences && Object.keys(typed.credentialReferences).length > 0) {
|
|
5271
|
-
logger11.info(
|
|
5272
|
-
{ credentialReferencesCount: Object.keys(typed.credentialReferences).length },
|
|
5273
|
-
"Processing credential references"
|
|
5274
|
-
);
|
|
5275
|
-
const credentialRefPromises = Object.entries(typed.credentialReferences).map(
|
|
5276
|
-
async ([_credId, credData]) => {
|
|
5277
|
-
try {
|
|
5278
|
-
logger11.info({ credId: credData.id }, "Processing credential reference");
|
|
5279
|
-
await upsertCredentialReference(db)({
|
|
5280
|
-
data: {
|
|
5281
|
-
...credData,
|
|
5282
|
-
tenantId,
|
|
5283
|
-
projectId
|
|
5284
|
-
}
|
|
5285
|
-
});
|
|
5286
|
-
logger11.info({ credId: credData.id }, "Credential reference processed successfully");
|
|
5287
|
-
} catch (error) {
|
|
5288
|
-
logger11.error(
|
|
5289
|
-
{ credId: credData.id, error },
|
|
5290
|
-
"Failed to create/update credential reference"
|
|
5291
|
-
);
|
|
5292
|
-
throw error;
|
|
5293
|
-
}
|
|
5294
|
-
}
|
|
5295
|
-
);
|
|
5296
|
-
await Promise.all(credentialRefPromises);
|
|
5297
|
-
logger11.info(
|
|
5298
|
-
{ credentialReferencesCount: Object.keys(typed.credentialReferences).length },
|
|
5299
|
-
"All credential references created/updated successfully"
|
|
5300
|
-
);
|
|
5301
|
-
}
|
|
5302
|
-
const toolPromises = Object.entries(typed.tools || {}).map(async ([toolId, toolData]) => {
|
|
5303
|
-
try {
|
|
5304
|
-
logger11.info({ toolId }, "Processing tool");
|
|
5305
|
-
await upsertTool(db)({
|
|
5306
|
-
data: {
|
|
5307
|
-
tenantId,
|
|
5308
|
-
projectId,
|
|
5309
|
-
...toolData
|
|
5310
|
-
}
|
|
5311
|
-
});
|
|
5312
|
-
logger11.info({ toolId }, "Tool processed successfully");
|
|
5313
|
-
} catch (error) {
|
|
5314
|
-
logger11.error({ toolId, error }, "Failed to create/update tool");
|
|
5315
|
-
throw error;
|
|
5316
|
-
}
|
|
5317
|
-
});
|
|
5318
|
-
await Promise.all(toolPromises);
|
|
5319
5388
|
logger11.info(
|
|
5320
|
-
{
|
|
5321
|
-
"
|
|
5389
|
+
{},
|
|
5390
|
+
"CredentialReferences are project-scoped - skipping credential reference creation in graph"
|
|
5322
5391
|
);
|
|
5392
|
+
logger11.info({}, "Tools are project-scoped - skipping tool creation in graph");
|
|
5393
|
+
let finalGraphId;
|
|
5394
|
+
try {
|
|
5395
|
+
const graphId = typed.id || nanoid.nanoid();
|
|
5396
|
+
logger11.info({ graphId }, "Creating agent graph metadata");
|
|
5397
|
+
const agentGraph2 = await upsertAgentGraph(db)({
|
|
5398
|
+
data: {
|
|
5399
|
+
id: graphId,
|
|
5400
|
+
tenantId,
|
|
5401
|
+
projectId,
|
|
5402
|
+
name: typed.name,
|
|
5403
|
+
defaultAgentId: typed.defaultAgentId,
|
|
5404
|
+
description: typed.description,
|
|
5405
|
+
contextConfigId: void 0,
|
|
5406
|
+
// Will be updated later if context config exists
|
|
5407
|
+
models: typed.models,
|
|
5408
|
+
statusUpdates: typed.statusUpdates,
|
|
5409
|
+
graphPrompt: typed.graphPrompt,
|
|
5410
|
+
stopWhen: typed.stopWhen
|
|
5411
|
+
}
|
|
5412
|
+
});
|
|
5413
|
+
finalGraphId = agentGraph2.id;
|
|
5414
|
+
logger11.info({ graphId: finalGraphId }, "Agent graph metadata created successfully");
|
|
5415
|
+
} catch (error) {
|
|
5416
|
+
logger11.error({ graphId: typed.id, error }, "Failed to create/update graph metadata");
|
|
5417
|
+
throw error;
|
|
5418
|
+
}
|
|
5323
5419
|
let contextConfigId;
|
|
5324
5420
|
if (typed.contextConfig) {
|
|
5325
5421
|
try {
|
|
@@ -5341,66 +5437,14 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5341
5437
|
throw error;
|
|
5342
5438
|
}
|
|
5343
5439
|
}
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
tenantId,
|
|
5353
|
-
projectId,
|
|
5354
|
-
name: dataComponentData.name,
|
|
5355
|
-
description: dataComponentData.description || "",
|
|
5356
|
-
props: dataComponentData.props || {}
|
|
5357
|
-
}
|
|
5358
|
-
});
|
|
5359
|
-
logger11.info({ dataComponentId }, "Data component processed successfully");
|
|
5360
|
-
} catch (error) {
|
|
5361
|
-
logger11.error({ dataComponentId, error }, "Failed to create/update dataComponent");
|
|
5362
|
-
throw error;
|
|
5363
|
-
}
|
|
5364
|
-
}
|
|
5365
|
-
);
|
|
5366
|
-
await Promise.all(dataComponentPromises);
|
|
5367
|
-
logger11.info(
|
|
5368
|
-
{ dataComponentCount: Object.keys(typed.dataComponents).length },
|
|
5369
|
-
"All dataComponents created/updated successfully"
|
|
5370
|
-
);
|
|
5371
|
-
}
|
|
5372
|
-
if (typed.artifactComponents && Object.keys(typed.artifactComponents).length > 0) {
|
|
5373
|
-
const artifactComponentPromises = Object.entries(typed.artifactComponents).map(
|
|
5374
|
-
async ([artifactComponentId, artifactComponentData]) => {
|
|
5375
|
-
try {
|
|
5376
|
-
logger11.info({ artifactComponentId }, "Processing artifact component");
|
|
5377
|
-
await upsertArtifactComponent(db)({
|
|
5378
|
-
data: {
|
|
5379
|
-
id: artifactComponentId,
|
|
5380
|
-
tenantId,
|
|
5381
|
-
projectId,
|
|
5382
|
-
name: artifactComponentData.name,
|
|
5383
|
-
description: artifactComponentData.description || "",
|
|
5384
|
-
summaryProps: artifactComponentData.summaryProps || {},
|
|
5385
|
-
fullProps: artifactComponentData.fullProps || {}
|
|
5386
|
-
}
|
|
5387
|
-
});
|
|
5388
|
-
logger11.info({ artifactComponentId }, "Artifact component processed successfully");
|
|
5389
|
-
} catch (error) {
|
|
5390
|
-
logger11.error(
|
|
5391
|
-
{ artifactComponentId, error },
|
|
5392
|
-
"Failed to create/update artifactComponent"
|
|
5393
|
-
);
|
|
5394
|
-
throw error;
|
|
5395
|
-
}
|
|
5396
|
-
}
|
|
5397
|
-
);
|
|
5398
|
-
await Promise.all(artifactComponentPromises);
|
|
5399
|
-
logger11.info(
|
|
5400
|
-
{ artifactComponentCount: Object.keys(typed.artifactComponents).length },
|
|
5401
|
-
"All artifactComponents created/updated successfully"
|
|
5402
|
-
);
|
|
5403
|
-
}
|
|
5440
|
+
logger11.info(
|
|
5441
|
+
{},
|
|
5442
|
+
"DataComponents are project-scoped - skipping dataComponent creation in graph"
|
|
5443
|
+
);
|
|
5444
|
+
logger11.info(
|
|
5445
|
+
{},
|
|
5446
|
+
"ArtifactComponents are project-scoped - skipping artifactComponent creation in graph"
|
|
5447
|
+
);
|
|
5404
5448
|
const internalAgentPromises = Object.entries(typed.agents).filter(([_, agentData]) => isInternalAgent(agentData)).map(async ([agentId, agentData]) => {
|
|
5405
5449
|
const internalAgent = agentData;
|
|
5406
5450
|
try {
|
|
@@ -5410,6 +5454,7 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5410
5454
|
id: agentId,
|
|
5411
5455
|
tenantId,
|
|
5412
5456
|
projectId,
|
|
5457
|
+
graphId: finalGraphId,
|
|
5413
5458
|
name: internalAgent.name || "",
|
|
5414
5459
|
description: internalAgent.description || "",
|
|
5415
5460
|
prompt: internalAgent.prompt || "",
|
|
@@ -5438,6 +5483,7 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5438
5483
|
id: agentId,
|
|
5439
5484
|
tenantId,
|
|
5440
5485
|
projectId,
|
|
5486
|
+
graphId: finalGraphId,
|
|
5441
5487
|
name: externalAgent.name,
|
|
5442
5488
|
description: externalAgent.description || "",
|
|
5443
5489
|
baseUrl: externalAgent.baseUrl,
|
|
@@ -5456,29 +5502,24 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5456
5502
|
([_, agentData]) => isExternalAgent(agentData)
|
|
5457
5503
|
).length;
|
|
5458
5504
|
logger11.info({ externalAgentCount }, "All external agents created/updated successfully");
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
projectId,
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
}
|
|
5477
|
-
finalGraphId = agentGraph2.id;
|
|
5478
|
-
logger11.info({ graphId: finalGraphId }, "Agent graph metadata processed successfully");
|
|
5479
|
-
} catch (error) {
|
|
5480
|
-
logger11.error({ graphId: typed.id, error }, "Failed to create/update graph metadata");
|
|
5481
|
-
throw error;
|
|
5505
|
+
if (contextConfigId) {
|
|
5506
|
+
try {
|
|
5507
|
+
logger11.info(
|
|
5508
|
+
{ graphId: finalGraphId, contextConfigId },
|
|
5509
|
+
"Updating graph with context config"
|
|
5510
|
+
);
|
|
5511
|
+
await updateAgentGraph(db)({
|
|
5512
|
+
scopes: { tenantId, projectId, graphId: finalGraphId },
|
|
5513
|
+
data: { contextConfigId }
|
|
5514
|
+
});
|
|
5515
|
+
logger11.info({ graphId: finalGraphId }, "Graph updated with context config");
|
|
5516
|
+
} catch (error) {
|
|
5517
|
+
logger11.error(
|
|
5518
|
+
{ graphId: finalGraphId, error },
|
|
5519
|
+
"Failed to update graph with context config"
|
|
5520
|
+
);
|
|
5521
|
+
throw error;
|
|
5522
|
+
}
|
|
5482
5523
|
}
|
|
5483
5524
|
const agentToolPromises = [];
|
|
5484
5525
|
for (const [agentId, agentData] of Object.entries(typed.agents)) {
|
|
@@ -5490,7 +5531,7 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5490
5531
|
const selectedTools = agentData.selectedTools?.[toolId];
|
|
5491
5532
|
logger11.info({ agentId, toolId }, "Processing agent-tool relation");
|
|
5492
5533
|
await upsertAgentToolRelation(db)({
|
|
5493
|
-
scopes: { tenantId, projectId },
|
|
5534
|
+
scopes: { tenantId, projectId, graphId: finalGraphId },
|
|
5494
5535
|
agentId,
|
|
5495
5536
|
toolId,
|
|
5496
5537
|
selectedTools
|
|
@@ -5521,8 +5562,7 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5521
5562
|
"Processing agent-data component relation"
|
|
5522
5563
|
);
|
|
5523
5564
|
await upsertAgentDataComponentRelation(db)({
|
|
5524
|
-
scopes: { tenantId, projectId },
|
|
5525
|
-
agentId,
|
|
5565
|
+
scopes: { tenantId, projectId, graphId: finalGraphId, agentId },
|
|
5526
5566
|
dataComponentId
|
|
5527
5567
|
});
|
|
5528
5568
|
logger11.info(
|
|
@@ -5554,8 +5594,7 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5554
5594
|
"Processing agent-artifact component relation"
|
|
5555
5595
|
);
|
|
5556
5596
|
await upsertAgentArtifactComponentRelation(db)({
|
|
5557
|
-
scopes: { tenantId, projectId },
|
|
5558
|
-
agentId,
|
|
5597
|
+
scopes: { tenantId, projectId, graphId: finalGraphId, agentId },
|
|
5559
5598
|
artifactComponentId
|
|
5560
5599
|
});
|
|
5561
5600
|
logger11.info(
|
|
@@ -5651,8 +5690,7 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5651
5690
|
"All agent relations created"
|
|
5652
5691
|
);
|
|
5653
5692
|
const createdGraph = await getFullGraphDefinition(db)({
|
|
5654
|
-
scopes: { tenantId, projectId }
|
|
5655
|
-
graphId: finalGraphId
|
|
5693
|
+
scopes: { tenantId, projectId, graphId: finalGraphId }
|
|
5656
5694
|
});
|
|
5657
5695
|
if (!createdGraph) {
|
|
5658
5696
|
throw new Error("Failed to retrieve created graph");
|
|
@@ -5675,8 +5713,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5675
5713
|
{
|
|
5676
5714
|
tenantId,
|
|
5677
5715
|
graphId: typedGraphDefinition.id,
|
|
5678
|
-
agentCount: Object.keys(typedGraphDefinition.agents).length
|
|
5679
|
-
toolCount: Object.keys(typedGraphDefinition.tools || {}).length
|
|
5716
|
+
agentCount: Object.keys(typedGraphDefinition.agents).length
|
|
5680
5717
|
},
|
|
5681
5718
|
"Updating full graph in database"
|
|
5682
5719
|
);
|
|
@@ -5689,8 +5726,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5689
5726
|
);
|
|
5690
5727
|
try {
|
|
5691
5728
|
const existingGraph = await getAgentGraphById(db)({
|
|
5692
|
-
scopes: { tenantId, projectId }
|
|
5693
|
-
graphId: typedGraphDefinition.id
|
|
5729
|
+
scopes: { tenantId, projectId, graphId: typedGraphDefinition.id }
|
|
5694
5730
|
});
|
|
5695
5731
|
if (!existingGraph) {
|
|
5696
5732
|
logger11.info(
|
|
@@ -5700,65 +5736,40 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5700
5736
|
return createFullGraphServerSide(db)(scopes, graphData);
|
|
5701
5737
|
}
|
|
5702
5738
|
const existingGraphModels = existingGraph.models;
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
const
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
);
|
|
5727
|
-
throw error;
|
|
5728
|
-
}
|
|
5739
|
+
logger11.info(
|
|
5740
|
+
{},
|
|
5741
|
+
"CredentialReferences are project-scoped - skipping credential reference update in graph"
|
|
5742
|
+
);
|
|
5743
|
+
logger11.info({}, "Tools are project-scoped - skipping tool creation in graph update");
|
|
5744
|
+
let finalGraphId;
|
|
5745
|
+
try {
|
|
5746
|
+
const graphId = typedGraphDefinition.id || nanoid.nanoid();
|
|
5747
|
+
logger11.info({ graphId }, "Getting/creating agent graph metadata");
|
|
5748
|
+
const agentGraph2 = await upsertAgentGraph(db)({
|
|
5749
|
+
data: {
|
|
5750
|
+
id: graphId,
|
|
5751
|
+
tenantId,
|
|
5752
|
+
projectId,
|
|
5753
|
+
name: typedGraphDefinition.name,
|
|
5754
|
+
defaultAgentId: typedGraphDefinition.defaultAgentId,
|
|
5755
|
+
description: typedGraphDefinition.description,
|
|
5756
|
+
contextConfigId: void 0,
|
|
5757
|
+
// Will be updated later if context config exists
|
|
5758
|
+
models: typedGraphDefinition.models,
|
|
5759
|
+
statusUpdates: typedGraphDefinition.statusUpdates,
|
|
5760
|
+
graphPrompt: typedGraphDefinition.graphPrompt,
|
|
5761
|
+
stopWhen: typedGraphDefinition.stopWhen
|
|
5729
5762
|
}
|
|
5763
|
+
});
|
|
5764
|
+
finalGraphId = agentGraph2.id;
|
|
5765
|
+
logger11.info({ graphId: finalGraphId }, "Agent graph metadata ready");
|
|
5766
|
+
} catch (error) {
|
|
5767
|
+
logger11.error(
|
|
5768
|
+
{ graphId: typedGraphDefinition.id, error },
|
|
5769
|
+
"Failed to get/update graph metadata"
|
|
5730
5770
|
);
|
|
5731
|
-
|
|
5732
|
-
logger11.info(
|
|
5733
|
-
{
|
|
5734
|
-
credentialReferencesCount: Object.keys(typedGraphDefinition.credentialReferences).length
|
|
5735
|
-
},
|
|
5736
|
-
"All credential references created/updated successfully"
|
|
5737
|
-
);
|
|
5771
|
+
throw error;
|
|
5738
5772
|
}
|
|
5739
|
-
const toolPromises = Object.entries(typedGraphDefinition.tools || {}).map(
|
|
5740
|
-
async ([toolId, toolData]) => {
|
|
5741
|
-
try {
|
|
5742
|
-
logger11.info({ toolId }, "Processing tool");
|
|
5743
|
-
await upsertTool(db)({
|
|
5744
|
-
data: {
|
|
5745
|
-
tenantId,
|
|
5746
|
-
projectId,
|
|
5747
|
-
...toolData
|
|
5748
|
-
}
|
|
5749
|
-
});
|
|
5750
|
-
logger11.info({ toolId }, "Tool processed successfully");
|
|
5751
|
-
} catch (error) {
|
|
5752
|
-
logger11.error({ toolId, error }, "Failed to create/update tool");
|
|
5753
|
-
throw error;
|
|
5754
|
-
}
|
|
5755
|
-
}
|
|
5756
|
-
);
|
|
5757
|
-
await Promise.all(toolPromises);
|
|
5758
|
-
logger11.info(
|
|
5759
|
-
{ toolCount: Object.keys(typedGraphDefinition.tools || {}).length },
|
|
5760
|
-
"All tools created/updated successfully"
|
|
5761
|
-
);
|
|
5762
5773
|
let contextConfigId;
|
|
5763
5774
|
if (typedGraphDefinition.contextConfig) {
|
|
5764
5775
|
try {
|
|
@@ -5783,66 +5794,11 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5783
5794
|
throw error;
|
|
5784
5795
|
}
|
|
5785
5796
|
}
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
await upsertDataComponent(db)({
|
|
5792
|
-
data: {
|
|
5793
|
-
id: dataComponentId,
|
|
5794
|
-
tenantId,
|
|
5795
|
-
projectId,
|
|
5796
|
-
name: dataComponentData.name,
|
|
5797
|
-
description: dataComponentData.description || "",
|
|
5798
|
-
props: dataComponentData.props || {}
|
|
5799
|
-
}
|
|
5800
|
-
});
|
|
5801
|
-
logger11.info({ dataComponentId }, "Data component processed successfully");
|
|
5802
|
-
} catch (error) {
|
|
5803
|
-
logger11.error({ dataComponentId, error }, "Failed to create/update dataComponent");
|
|
5804
|
-
throw error;
|
|
5805
|
-
}
|
|
5806
|
-
}
|
|
5807
|
-
);
|
|
5808
|
-
await Promise.all(dataComponentPromises);
|
|
5809
|
-
logger11.info(
|
|
5810
|
-
{ dataComponentCount: Object.keys(typedGraphDefinition.dataComponents).length },
|
|
5811
|
-
"All dataComponents created/updated successfully"
|
|
5812
|
-
);
|
|
5813
|
-
}
|
|
5814
|
-
if (typedGraphDefinition.artifactComponents && Object.keys(typedGraphDefinition.artifactComponents).length > 0) {
|
|
5815
|
-
const artifactComponentPromises = Object.entries(
|
|
5816
|
-
typedGraphDefinition.artifactComponents
|
|
5817
|
-
).map(async ([artifactComponentId, artifactComponentData]) => {
|
|
5818
|
-
try {
|
|
5819
|
-
logger11.info({ artifactComponentId }, "Processing artifact component");
|
|
5820
|
-
await upsertArtifactComponent(db)({
|
|
5821
|
-
data: {
|
|
5822
|
-
id: artifactComponentId,
|
|
5823
|
-
tenantId,
|
|
5824
|
-
projectId,
|
|
5825
|
-
name: artifactComponentData.name,
|
|
5826
|
-
description: artifactComponentData.description || "",
|
|
5827
|
-
summaryProps: artifactComponentData.summaryProps || {},
|
|
5828
|
-
fullProps: artifactComponentData.fullProps || {}
|
|
5829
|
-
}
|
|
5830
|
-
});
|
|
5831
|
-
logger11.info({ artifactComponentId }, "Artifact component processed successfully");
|
|
5832
|
-
} catch (error) {
|
|
5833
|
-
logger11.error(
|
|
5834
|
-
{ artifactComponentId, error },
|
|
5835
|
-
"Failed to create/update artifactComponent"
|
|
5836
|
-
);
|
|
5837
|
-
throw error;
|
|
5838
|
-
}
|
|
5839
|
-
});
|
|
5840
|
-
await Promise.all(artifactComponentPromises);
|
|
5841
|
-
logger11.info(
|
|
5842
|
-
{ artifactComponentCount: Object.keys(typedGraphDefinition.artifactComponents).length },
|
|
5843
|
-
"All artifactComponents created/updated successfully"
|
|
5844
|
-
);
|
|
5845
|
-
}
|
|
5797
|
+
logger11.info({}, "DataComponents are project-scoped - skipping dataComponent update in graph");
|
|
5798
|
+
logger11.info(
|
|
5799
|
+
{},
|
|
5800
|
+
"ArtifactComponents are project-scoped - skipping artifactComponent update in graph"
|
|
5801
|
+
);
|
|
5846
5802
|
const internalAgentPromises = Object.entries(typedGraphDefinition.agents).filter(([_, agentData]) => isInternalAgent(agentData)).map(async ([agentId, agentData]) => {
|
|
5847
5803
|
const internalAgent = agentData;
|
|
5848
5804
|
let existingAgent = null;
|
|
@@ -5891,6 +5847,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5891
5847
|
id: agentId,
|
|
5892
5848
|
tenantId,
|
|
5893
5849
|
projectId,
|
|
5850
|
+
graphId: finalGraphId,
|
|
5894
5851
|
name: internalAgent.name || "",
|
|
5895
5852
|
description: internalAgent.description || "",
|
|
5896
5853
|
prompt: internalAgent.prompt || "",
|
|
@@ -5919,6 +5876,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5919
5876
|
id: agentId,
|
|
5920
5877
|
tenantId,
|
|
5921
5878
|
projectId,
|
|
5879
|
+
graphId: finalGraphId,
|
|
5922
5880
|
name: externalAgent.name,
|
|
5923
5881
|
description: externalAgent.description || "",
|
|
5924
5882
|
baseUrl: externalAgent.baseUrl,
|
|
@@ -5938,8 +5896,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5938
5896
|
).length;
|
|
5939
5897
|
logger11.info({ externalAgentCount }, "All external agents created/updated successfully");
|
|
5940
5898
|
await updateAgentGraph(db)({
|
|
5941
|
-
scopes: { tenantId, projectId },
|
|
5942
|
-
graphId: typedGraphDefinition.id,
|
|
5899
|
+
scopes: { tenantId, projectId, graphId: typedGraphDefinition.id },
|
|
5943
5900
|
data: {
|
|
5944
5901
|
name: typedGraphDefinition.name,
|
|
5945
5902
|
defaultAgentId: typedGraphDefinition.defaultAgentId,
|
|
@@ -5954,8 +5911,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5954
5911
|
logger11.info({ graphId: typedGraphDefinition.id }, "Graph metadata updated");
|
|
5955
5912
|
for (const agentId of Object.keys(typedGraphDefinition.agents)) {
|
|
5956
5913
|
await deleteAgentToolRelationByAgent(db)({
|
|
5957
|
-
scopes: { tenantId, projectId }
|
|
5958
|
-
agentId
|
|
5914
|
+
scopes: { tenantId, projectId, graphId: finalGraphId, agentId }
|
|
5959
5915
|
});
|
|
5960
5916
|
}
|
|
5961
5917
|
const agentToolPromises = [];
|
|
@@ -5967,7 +5923,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5967
5923
|
try {
|
|
5968
5924
|
const selectedTools = agentData.selectedTools?.[toolId];
|
|
5969
5925
|
await createAgentToolRelation(db)({
|
|
5970
|
-
scopes: { tenantId, projectId },
|
|
5926
|
+
scopes: { tenantId, projectId, graphId: finalGraphId },
|
|
5971
5927
|
data: {
|
|
5972
5928
|
agentId,
|
|
5973
5929
|
toolId,
|
|
@@ -5990,8 +5946,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5990
5946
|
);
|
|
5991
5947
|
for (const agentId of Object.keys(typedGraphDefinition.agents)) {
|
|
5992
5948
|
await deleteAgentDataComponentRelationByAgent(db)({
|
|
5993
|
-
scopes: { tenantId, projectId }
|
|
5994
|
-
agentId
|
|
5949
|
+
scopes: { tenantId, projectId, graphId: finalGraphId, agentId }
|
|
5995
5950
|
});
|
|
5996
5951
|
}
|
|
5997
5952
|
const agentDataComponentPromises = [];
|
|
@@ -6002,8 +5957,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
6002
5957
|
(async () => {
|
|
6003
5958
|
try {
|
|
6004
5959
|
await associateDataComponentWithAgent(db)({
|
|
6005
|
-
scopes: { tenantId, projectId },
|
|
6006
|
-
agentId,
|
|
5960
|
+
scopes: { tenantId, projectId, graphId: finalGraphId, agentId },
|
|
6007
5961
|
dataComponentId
|
|
6008
5962
|
});
|
|
6009
5963
|
logger11.info({ agentId, dataComponentId }, "Agent-dataComponent relation created");
|
|
@@ -6025,8 +5979,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
6025
5979
|
);
|
|
6026
5980
|
for (const agentId of Object.keys(typedGraphDefinition.agents)) {
|
|
6027
5981
|
await deleteAgentArtifactComponentRelationByAgent(db)({
|
|
6028
|
-
scopes: { tenantId, projectId }
|
|
6029
|
-
agentId
|
|
5982
|
+
scopes: { tenantId, projectId, graphId: finalGraphId, agentId }
|
|
6030
5983
|
});
|
|
6031
5984
|
}
|
|
6032
5985
|
const agentArtifactComponentPromises = [];
|
|
@@ -6037,8 +5990,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
6037
5990
|
(async () => {
|
|
6038
5991
|
try {
|
|
6039
5992
|
await associateArtifactComponentWithAgent(db)({
|
|
6040
|
-
scopes: { tenantId, projectId },
|
|
6041
|
-
agentId,
|
|
5993
|
+
scopes: { tenantId, projectId, graphId: finalGraphId, agentId },
|
|
6042
5994
|
artifactComponentId
|
|
6043
5995
|
});
|
|
6044
5996
|
logger11.info(
|
|
@@ -6062,8 +6014,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
6062
6014
|
"All agent-artifactComponent relations updated"
|
|
6063
6015
|
);
|
|
6064
6016
|
await deleteAgentRelationsByGraph(db)({
|
|
6065
|
-
scopes: { tenantId, projectId }
|
|
6066
|
-
graphId: typedGraphDefinition.id
|
|
6017
|
+
scopes: { tenantId, projectId, graphId: typedGraphDefinition.id }
|
|
6067
6018
|
});
|
|
6068
6019
|
const agentRelationPromises = [];
|
|
6069
6020
|
for (const [agentId, agentData] of Object.entries(typedGraphDefinition.agents)) {
|
|
@@ -6139,8 +6090,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
6139
6090
|
"All agent relations updated"
|
|
6140
6091
|
);
|
|
6141
6092
|
const updatedGraph = await getFullGraphDefinition(db)({
|
|
6142
|
-
scopes: { tenantId, projectId }
|
|
6143
|
-
graphId: typedGraphDefinition.id
|
|
6093
|
+
scopes: { tenantId, projectId, graphId: typedGraphDefinition.id }
|
|
6144
6094
|
});
|
|
6145
6095
|
if (!updatedGraph) {
|
|
6146
6096
|
throw new Error("Failed to retrieve updated graph");
|
|
@@ -6153,22 +6103,21 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
6153
6103
|
}
|
|
6154
6104
|
};
|
|
6155
6105
|
var getFullGraph = (db, logger11 = defaultLogger) => async (params) => {
|
|
6156
|
-
const { scopes
|
|
6106
|
+
const { scopes } = params;
|
|
6157
6107
|
const { tenantId, projectId } = scopes;
|
|
6158
|
-
logger11.info({ tenantId, graphId }, "Retrieving full graph definition");
|
|
6108
|
+
logger11.info({ tenantId, graphId: scopes.graphId }, "Retrieving full graph definition");
|
|
6159
6109
|
try {
|
|
6160
6110
|
const graph = await getFullGraphDefinition(db)({
|
|
6161
|
-
scopes: { tenantId, projectId }
|
|
6162
|
-
graphId
|
|
6111
|
+
scopes: { tenantId, projectId, graphId: scopes.graphId }
|
|
6163
6112
|
});
|
|
6164
6113
|
if (!graph) {
|
|
6165
|
-
logger11.info({ tenantId, graphId }, "Graph not found");
|
|
6114
|
+
logger11.info({ tenantId, graphId: scopes.graphId }, "Graph not found");
|
|
6166
6115
|
return null;
|
|
6167
6116
|
}
|
|
6168
6117
|
logger11.info(
|
|
6169
6118
|
{
|
|
6170
6119
|
tenantId,
|
|
6171
|
-
graphId,
|
|
6120
|
+
graphId: scopes.graphId,
|
|
6172
6121
|
agentCount: Object.keys(graph.agents).length
|
|
6173
6122
|
},
|
|
6174
6123
|
"Full graph retrieved successfully"
|
|
@@ -6178,7 +6127,7 @@ var getFullGraph = (db, logger11 = defaultLogger) => async (params) => {
|
|
|
6178
6127
|
logger11.error(
|
|
6179
6128
|
{
|
|
6180
6129
|
tenantId,
|
|
6181
|
-
graphId,
|
|
6130
|
+
graphId: scopes.graphId,
|
|
6182
6131
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
6183
6132
|
},
|
|
6184
6133
|
"Failed to retrieve full graph"
|
|
@@ -6187,29 +6136,25 @@ var getFullGraph = (db, logger11 = defaultLogger) => async (params) => {
|
|
|
6187
6136
|
}
|
|
6188
6137
|
};
|
|
6189
6138
|
var deleteFullGraph = (db, logger11 = defaultLogger) => async (params) => {
|
|
6190
|
-
const {
|
|
6191
|
-
const { tenantId, projectId } = scopes;
|
|
6139
|
+
const { tenantId, projectId, graphId } = params.scopes;
|
|
6192
6140
|
logger11.info({ tenantId, graphId }, "Deleting full graph and related entities");
|
|
6193
6141
|
try {
|
|
6194
6142
|
const graph = await getFullGraphDefinition(db)({
|
|
6195
|
-
scopes: { tenantId, projectId }
|
|
6196
|
-
graphId
|
|
6143
|
+
scopes: { tenantId, projectId, graphId }
|
|
6197
6144
|
});
|
|
6198
6145
|
if (!graph) {
|
|
6199
6146
|
logger11.info({ tenantId, graphId }, "Graph not found for deletion");
|
|
6200
6147
|
return false;
|
|
6201
6148
|
}
|
|
6202
6149
|
await deleteAgentRelationsByGraph(db)({
|
|
6203
|
-
scopes: { tenantId, projectId }
|
|
6204
|
-
graphId
|
|
6150
|
+
scopes: { tenantId, projectId, graphId }
|
|
6205
6151
|
});
|
|
6206
6152
|
logger11.info({ tenantId, graphId }, "Agent relations deleted");
|
|
6207
6153
|
const agentIds = Object.keys(graph.agents);
|
|
6208
6154
|
if (agentIds.length > 0) {
|
|
6209
6155
|
for (const agentId of agentIds) {
|
|
6210
6156
|
await deleteAgentToolRelationByAgent(db)({
|
|
6211
|
-
scopes: { tenantId, projectId }
|
|
6212
|
-
agentId
|
|
6157
|
+
scopes: { tenantId, projectId, graphId, agentId }
|
|
6213
6158
|
});
|
|
6214
6159
|
}
|
|
6215
6160
|
logger11.info(
|
|
@@ -6218,8 +6163,7 @@ var deleteFullGraph = (db, logger11 = defaultLogger) => async (params) => {
|
|
|
6218
6163
|
);
|
|
6219
6164
|
}
|
|
6220
6165
|
await deleteAgentGraph(db)({
|
|
6221
|
-
scopes: { tenantId, projectId }
|
|
6222
|
-
graphId
|
|
6166
|
+
scopes: { tenantId, projectId, graphId }
|
|
6223
6167
|
});
|
|
6224
6168
|
logger11.info({ tenantId, graphId }, "Graph metadata deleted");
|
|
6225
6169
|
logger11.info({ tenantId, graphId }, "Full graph deleted successfully");
|
|
@@ -6928,8 +6872,7 @@ var createFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scop
|
|
|
6928
6872
|
db,
|
|
6929
6873
|
logger11
|
|
6930
6874
|
)({
|
|
6931
|
-
scopes: { tenantId, projectId: typed.id }
|
|
6932
|
-
projectId: typed.id
|
|
6875
|
+
scopes: { tenantId, projectId: typed.id }
|
|
6933
6876
|
});
|
|
6934
6877
|
} catch (error) {
|
|
6935
6878
|
logger11.error(
|
|
@@ -7235,8 +7178,7 @@ var updateFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scop
|
|
|
7235
7178
|
db,
|
|
7236
7179
|
logger11
|
|
7237
7180
|
)({
|
|
7238
|
-
scopes: { tenantId, projectId: typed.id }
|
|
7239
|
-
projectId: typed.id
|
|
7181
|
+
scopes: { tenantId, projectId: typed.id }
|
|
7240
7182
|
});
|
|
7241
7183
|
} catch (error) {
|
|
7242
7184
|
logger11.error(
|
|
@@ -7251,8 +7193,8 @@ var updateFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scop
|
|
|
7251
7193
|
}
|
|
7252
7194
|
};
|
|
7253
7195
|
var getFullProject = (db, logger11 = defaultLogger2) => async (params) => {
|
|
7254
|
-
const { scopes
|
|
7255
|
-
const { tenantId } = scopes;
|
|
7196
|
+
const { scopes } = params;
|
|
7197
|
+
const { tenantId, projectId } = scopes;
|
|
7256
7198
|
logger11.info({ tenantId, projectId }, "Retrieving full project definition");
|
|
7257
7199
|
try {
|
|
7258
7200
|
const project = await getProject(db)({
|
|
@@ -7406,18 +7348,10 @@ var getFullProject = (db, logger11 = defaultLogger2) => async (params) => {
|
|
|
7406
7348
|
"Retrieving full graph definition"
|
|
7407
7349
|
);
|
|
7408
7350
|
const fullGraph = await getFullGraph(db)({
|
|
7409
|
-
scopes: { tenantId, projectId }
|
|
7410
|
-
graphId: graph.id
|
|
7351
|
+
scopes: { tenantId, projectId, graphId: graph.id }
|
|
7411
7352
|
});
|
|
7412
7353
|
if (fullGraph) {
|
|
7413
|
-
const {
|
|
7414
|
-
tools: _tools,
|
|
7415
|
-
dataComponents: _dataComponents,
|
|
7416
|
-
artifactComponents: _artifactComponents,
|
|
7417
|
-
contextConfig: _contextConfig,
|
|
7418
|
-
credentialReferences: _credentialReferences,
|
|
7419
|
-
...graphWithoutProjectResources
|
|
7420
|
-
} = fullGraph;
|
|
7354
|
+
const { contextConfig: _contextConfig, ...graphWithoutProjectResources } = fullGraph;
|
|
7421
7355
|
graphs[graph.id] = graphWithoutProjectResources;
|
|
7422
7356
|
logger11.info(
|
|
7423
7357
|
{ tenantId, projectId, graphId: graph.id },
|
|
@@ -7472,16 +7406,15 @@ var getFullProject = (db, logger11 = defaultLogger2) => async (params) => {
|
|
|
7472
7406
|
}
|
|
7473
7407
|
};
|
|
7474
7408
|
var deleteFullProject = (db, logger11 = defaultLogger2) => async (params) => {
|
|
7475
|
-
const { scopes
|
|
7476
|
-
const { tenantId } = scopes;
|
|
7409
|
+
const { scopes } = params;
|
|
7410
|
+
const { tenantId, projectId } = scopes;
|
|
7477
7411
|
logger11.info({ tenantId, projectId }, "Deleting full project and related entities");
|
|
7478
7412
|
try {
|
|
7479
7413
|
const project = await getFullProject(
|
|
7480
7414
|
db,
|
|
7481
7415
|
logger11
|
|
7482
7416
|
)({
|
|
7483
|
-
scopes: { tenantId, projectId }
|
|
7484
|
-
projectId
|
|
7417
|
+
scopes: { tenantId, projectId }
|
|
7485
7418
|
});
|
|
7486
7419
|
if (!project) {
|
|
7487
7420
|
logger11.info({ tenantId, projectId }, "Project not found for deletion");
|
|
@@ -7503,8 +7436,7 @@ var deleteFullProject = (db, logger11 = defaultLogger2) => async (params) => {
|
|
|
7503
7436
|
db,
|
|
7504
7437
|
logger11
|
|
7505
7438
|
)({
|
|
7506
|
-
scopes: { tenantId, projectId }
|
|
7507
|
-
graphId
|
|
7439
|
+
scopes: { tenantId, projectId, graphId }
|
|
7508
7440
|
});
|
|
7509
7441
|
logger11.info(
|
|
7510
7442
|
{ tenantId, projectId, graphId },
|
|
@@ -8919,8 +8851,7 @@ async function validateRequestContext({
|
|
|
8919
8851
|
}) {
|
|
8920
8852
|
try {
|
|
8921
8853
|
const agentGraph2 = await getAgentGraphWithDefaultAgent(dbClient)({
|
|
8922
|
-
scopes: { tenantId, projectId }
|
|
8923
|
-
graphId
|
|
8854
|
+
scopes: { tenantId, projectId, graphId }
|
|
8924
8855
|
});
|
|
8925
8856
|
if (!agentGraph2?.contextConfigId) {
|
|
8926
8857
|
logger7.debug({ graphId }, "No context config found for graph, skipping validation");
|
|
@@ -9060,13 +8991,11 @@ function contextValidationMiddleware(dbClient) {
|
|
|
9060
8991
|
},
|
|
9061
8992
|
"Request context validation failed"
|
|
9062
8993
|
);
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
400
|
|
9069
|
-
);
|
|
8994
|
+
const errorMessage = `Invalid request context: ${validationResult.errors.map((e) => `${e.field}: ${e.message}`).join(", ")}`;
|
|
8995
|
+
throw createApiError({
|
|
8996
|
+
code: "bad_request",
|
|
8997
|
+
message: errorMessage
|
|
8998
|
+
});
|
|
9070
8999
|
}
|
|
9071
9000
|
c.set("validatedContext", validationResult.validatedContext);
|
|
9072
9001
|
logger7.debug(
|
|
@@ -9085,13 +9014,10 @@ function contextValidationMiddleware(dbClient) {
|
|
|
9085
9014
|
},
|
|
9086
9015
|
"Context validation middleware error"
|
|
9087
9016
|
);
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
},
|
|
9093
|
-
500
|
|
9094
|
-
);
|
|
9017
|
+
throw createApiError({
|
|
9018
|
+
code: "internal_server_error",
|
|
9019
|
+
message: "Context validation failed"
|
|
9020
|
+
});
|
|
9095
9021
|
}
|
|
9096
9022
|
};
|
|
9097
9023
|
}
|
|
@@ -9467,7 +9393,15 @@ async function handleContextConfigChange(tenantId, projectId, conversationId, gr
|
|
|
9467
9393
|
);
|
|
9468
9394
|
}
|
|
9469
9395
|
}
|
|
9470
|
-
async function handleContextResolution(
|
|
9396
|
+
async function handleContextResolution({
|
|
9397
|
+
tenantId,
|
|
9398
|
+
projectId,
|
|
9399
|
+
graphId,
|
|
9400
|
+
conversationId,
|
|
9401
|
+
requestContext,
|
|
9402
|
+
dbClient,
|
|
9403
|
+
credentialStores
|
|
9404
|
+
}) {
|
|
9471
9405
|
return tracer.startActiveSpan(
|
|
9472
9406
|
"context.handle_context_resolution",
|
|
9473
9407
|
{
|
|
@@ -9480,8 +9414,7 @@ async function handleContextResolution(tenantId, projectId, conversationId, grap
|
|
|
9480
9414
|
let trigger;
|
|
9481
9415
|
try {
|
|
9482
9416
|
agentGraph2 = await getAgentGraphWithDefaultAgent(dbClient)({
|
|
9483
|
-
scopes: { tenantId, projectId }
|
|
9484
|
-
graphId
|
|
9417
|
+
scopes: { tenantId, projectId, graphId }
|
|
9485
9418
|
});
|
|
9486
9419
|
if (!agentGraph2?.contextConfigId) {
|
|
9487
9420
|
logger9.debug({ graphId }, "No context config found for graph");
|
|
@@ -10190,6 +10123,53 @@ function createDefaultCredentialStores() {
|
|
|
10190
10123
|
stores.push(createKeyChainStore("keychain-default"));
|
|
10191
10124
|
return stores;
|
|
10192
10125
|
}
|
|
10126
|
+
var loadEnvironmentFiles = () => {
|
|
10127
|
+
const environmentFiles = [];
|
|
10128
|
+
const currentEnv = path__default.default.resolve(process.cwd(), ".env");
|
|
10129
|
+
if (fs__default.default.existsSync(currentEnv)) {
|
|
10130
|
+
environmentFiles.push(currentEnv);
|
|
10131
|
+
}
|
|
10132
|
+
const rootEnv = findUp.findUpSync(".env", { cwd: path__default.default.dirname(process.cwd()) });
|
|
10133
|
+
if (rootEnv) {
|
|
10134
|
+
if (rootEnv !== currentEnv) {
|
|
10135
|
+
environmentFiles.push(rootEnv);
|
|
10136
|
+
}
|
|
10137
|
+
}
|
|
10138
|
+
const userConfigPath = path__default.default.join(os__default.default.homedir(), ".inkeep", "config");
|
|
10139
|
+
if (fs__default.default.existsSync(userConfigPath)) {
|
|
10140
|
+
dotenv__default.default.config({ path: userConfigPath, override: true, quiet: true });
|
|
10141
|
+
}
|
|
10142
|
+
if (environmentFiles.length > 0) {
|
|
10143
|
+
dotenv__default.default.config({
|
|
10144
|
+
path: environmentFiles,
|
|
10145
|
+
override: false,
|
|
10146
|
+
quiet: true
|
|
10147
|
+
});
|
|
10148
|
+
dotenvExpand.expand({ processEnv: process.env });
|
|
10149
|
+
}
|
|
10150
|
+
};
|
|
10151
|
+
loadEnvironmentFiles();
|
|
10152
|
+
var envSchema = zod.z.object({
|
|
10153
|
+
ENVIRONMENT: zod.z.enum(["development", "production", "pentest", "test"]).optional(),
|
|
10154
|
+
DB_FILE_NAME: zod.z.string(),
|
|
10155
|
+
OTEL_TRACES_FORCE_FLUSH_ENABLED: zod.z.coerce.boolean().optional()
|
|
10156
|
+
});
|
|
10157
|
+
var parseEnv = () => {
|
|
10158
|
+
try {
|
|
10159
|
+
const parsedEnv = envSchema.parse(process.env);
|
|
10160
|
+
return parsedEnv;
|
|
10161
|
+
} catch (error) {
|
|
10162
|
+
if (error instanceof zod.z.ZodError) {
|
|
10163
|
+
const missingVars = error.issues.map((issue) => issue.path.join("."));
|
|
10164
|
+
throw new Error(
|
|
10165
|
+
`\u274C Invalid environment variables: ${missingVars.join(", ")}
|
|
10166
|
+
${error.message}`
|
|
10167
|
+
);
|
|
10168
|
+
}
|
|
10169
|
+
throw error;
|
|
10170
|
+
}
|
|
10171
|
+
};
|
|
10172
|
+
parseEnv();
|
|
10193
10173
|
|
|
10194
10174
|
// src/validation/id-validation.ts
|
|
10195
10175
|
function isValidResourceId(id) {
|
|
@@ -10381,6 +10361,8 @@ exports.TaskUpdateSchema = TaskUpdateSchema;
|
|
|
10381
10361
|
exports.TemplateEngine = TemplateEngine;
|
|
10382
10362
|
exports.TenantIdParamsSchema = TenantIdParamsSchema;
|
|
10383
10363
|
exports.TenantParamsSchema = TenantParamsSchema;
|
|
10364
|
+
exports.TenantProjectGraphIdParamsSchema = TenantProjectGraphIdParamsSchema;
|
|
10365
|
+
exports.TenantProjectGraphParamsSchema = TenantProjectGraphParamsSchema;
|
|
10384
10366
|
exports.TenantProjectIdParamsSchema = TenantProjectIdParamsSchema;
|
|
10385
10367
|
exports.TenantProjectParamsSchema = TenantProjectParamsSchema;
|
|
10386
10368
|
exports.ToolApiInsertSchema = ToolApiInsertSchema;
|
|
@@ -10397,6 +10379,7 @@ exports.addToolToAgent = addToolToAgent;
|
|
|
10397
10379
|
exports.agentArtifactComponents = agentArtifactComponents;
|
|
10398
10380
|
exports.agentArtifactComponentsRelations = agentArtifactComponentsRelations;
|
|
10399
10381
|
exports.agentDataComponents = agentDataComponents;
|
|
10382
|
+
exports.agentDataComponentsRelations = agentDataComponentsRelations;
|
|
10400
10383
|
exports.agentGraph = agentGraph;
|
|
10401
10384
|
exports.agentGraphRelations = agentGraphRelations;
|
|
10402
10385
|
exports.agentRelations = agentRelations;
|
|
@@ -10467,6 +10450,7 @@ exports.createValidatedDataAccess = createValidatedDataAccess;
|
|
|
10467
10450
|
exports.credentialReferences = credentialReferences;
|
|
10468
10451
|
exports.credentialReferencesRelations = credentialReferencesRelations;
|
|
10469
10452
|
exports.dataComponents = dataComponents;
|
|
10453
|
+
exports.dataComponentsRelations = dataComponentsRelations;
|
|
10470
10454
|
exports.dbResultToMcpTool = dbResultToMcpTool;
|
|
10471
10455
|
exports.deleteAgent = deleteAgent;
|
|
10472
10456
|
exports.deleteAgentArtifactComponentRelationByAgent = deleteAgentArtifactComponentRelationByAgent;
|
|
@@ -10507,10 +10491,8 @@ exports.generateApiKey = generateApiKey;
|
|
|
10507
10491
|
exports.generateIdFromName = generateIdFromName;
|
|
10508
10492
|
exports.getActiveAgentForConversation = getActiveAgentForConversation;
|
|
10509
10493
|
exports.getAgentById = getAgentById;
|
|
10510
|
-
exports.getAgentGraph = getAgentGraph;
|
|
10511
10494
|
exports.getAgentGraphById = getAgentGraphById;
|
|
10512
10495
|
exports.getAgentGraphWithDefaultAgent = getAgentGraphWithDefaultAgent;
|
|
10513
|
-
exports.getAgentInGraphContext = getAgentInGraphContext;
|
|
10514
10496
|
exports.getAgentRelationById = getAgentRelationById;
|
|
10515
10497
|
exports.getAgentRelationByParams = getAgentRelationByParams;
|
|
10516
10498
|
exports.getAgentRelations = getAgentRelations;
|
|
@@ -10585,13 +10567,13 @@ exports.isValidHttpRequest = isValidHttpRequest;
|
|
|
10585
10567
|
exports.isValidResourceId = isValidResourceId;
|
|
10586
10568
|
exports.ledgerArtifacts = ledgerArtifacts;
|
|
10587
10569
|
exports.ledgerArtifactsContextIdIdx = ledgerArtifactsContextIdIdx;
|
|
10570
|
+
exports.ledgerArtifactsRelations = ledgerArtifactsRelations;
|
|
10588
10571
|
exports.ledgerArtifactsTaskContextNameUnique = ledgerArtifactsTaskContextNameUnique;
|
|
10589
10572
|
exports.ledgerArtifactsTaskIdIdx = ledgerArtifactsTaskIdIdx;
|
|
10590
10573
|
exports.listAgentGraphs = listAgentGraphs;
|
|
10591
10574
|
exports.listAgentGraphsPaginated = listAgentGraphsPaginated;
|
|
10592
10575
|
exports.listAgentRelations = listAgentRelations;
|
|
10593
10576
|
exports.listAgentToolRelations = listAgentToolRelations;
|
|
10594
|
-
exports.listAgentToolRelationsByAgent = listAgentToolRelationsByAgent;
|
|
10595
10577
|
exports.listAgents = listAgents;
|
|
10596
10578
|
exports.listAgentsPaginated = listAgentsPaginated;
|
|
10597
10579
|
exports.listApiKeys = listApiKeys;
|
|
@@ -10613,6 +10595,7 @@ exports.listProjectsPaginated = listProjectsPaginated;
|
|
|
10613
10595
|
exports.listTaskIdsByContextId = listTaskIdsByContextId;
|
|
10614
10596
|
exports.listTools = listTools;
|
|
10615
10597
|
exports.listToolsByStatus = listToolsByStatus;
|
|
10598
|
+
exports.loadEnvironmentFiles = loadEnvironmentFiles;
|
|
10616
10599
|
exports.loggerFactory = loggerFactory;
|
|
10617
10600
|
exports.maskApiKey = maskApiKey;
|
|
10618
10601
|
exports.messages = messages;
|