@inkeep/agents-core 0.3.0 → 0.6.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-LPIKPCE5.js → chunk-7OCPFKGI.js} +7 -6
- package/dist/{chunk-XQRFKXVV.js → chunk-T5JVBY6K.js} +5 -5
- package/dist/{chunk-LFWFXR4O.js → chunk-TNFWLVL6.js} +1 -0
- package/dist/client-exports.cjs +9 -29
- package/dist/client-exports.js +5 -26
- package/dist/db/schema.cjs +1 -0
- package/dist/db/schema.js +1 -1
- package/dist/index.cjs +218 -125
- package/dist/index.js +211 -120
- package/dist/validation/index.cjs +11 -8
- package/dist/validation/index.js +2 -2
- package/package.json +4 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
|
+
var pino = require('pino');
|
|
5
|
+
var pinoPretty = require('pino-pretty');
|
|
4
6
|
var zodOpenapi = require('@hono/zod-openapi');
|
|
5
7
|
var drizzleZod = require('drizzle-zod');
|
|
6
8
|
var drizzleOrm = require('drizzle-orm');
|
|
@@ -32,6 +34,8 @@ var findUp = require('find-up');
|
|
|
32
34
|
|
|
33
35
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
34
36
|
|
|
37
|
+
var pino__default = /*#__PURE__*/_interopDefault(pino);
|
|
38
|
+
var pinoPretty__default = /*#__PURE__*/_interopDefault(pinoPretty);
|
|
35
39
|
var jmespath__default = /*#__PURE__*/_interopDefault(jmespath);
|
|
36
40
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
37
41
|
var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
|
|
@@ -47,33 +51,114 @@ var __export = (target, all) => {
|
|
|
47
51
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
48
52
|
};
|
|
49
53
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var ConsoleLogger = class {
|
|
53
|
-
constructor(name) {
|
|
54
|
+
var PinoLogger = class {
|
|
55
|
+
constructor(name, config = {}) {
|
|
54
56
|
this.name = name;
|
|
57
|
+
__publicField(this, "transportConfigs", []);
|
|
58
|
+
__publicField(this, "pinoInstance");
|
|
59
|
+
__publicField(this, "options");
|
|
60
|
+
this.options = {
|
|
61
|
+
name: this.name,
|
|
62
|
+
level: process.env.LOG_LEVEL || "info",
|
|
63
|
+
serializers: {
|
|
64
|
+
obj: (value) => ({ ...value })
|
|
65
|
+
},
|
|
66
|
+
redact: ["req.headers.authorization", 'req.headers["x-inkeep-admin-authentication"]'],
|
|
67
|
+
...config.options
|
|
68
|
+
};
|
|
69
|
+
if (config.transportConfigs) {
|
|
70
|
+
this.transportConfigs = config.transportConfigs;
|
|
71
|
+
}
|
|
72
|
+
if (this.transportConfigs.length > 0) {
|
|
73
|
+
this.pinoInstance = pino__default.default(this.options, pino__default.default.transport({ targets: this.transportConfigs }));
|
|
74
|
+
} else {
|
|
75
|
+
try {
|
|
76
|
+
const prettyStream = pinoPretty__default.default({
|
|
77
|
+
colorize: true,
|
|
78
|
+
translateTime: "HH:MM:ss",
|
|
79
|
+
ignore: "pid,hostname"
|
|
80
|
+
});
|
|
81
|
+
this.pinoInstance = pino__default.default(this.options, prettyStream);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.warn("Warning: pino-pretty failed, using standard JSON output:", error);
|
|
84
|
+
this.pinoInstance = pino__default.default(this.options);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
55
87
|
}
|
|
56
|
-
|
|
57
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Recreate the pino instance with current transports
|
|
90
|
+
*/
|
|
91
|
+
recreateInstance() {
|
|
92
|
+
if (this.pinoInstance && typeof this.pinoInstance.flush === "function") {
|
|
93
|
+
this.pinoInstance.flush();
|
|
94
|
+
}
|
|
95
|
+
if (this.transportConfigs.length === 0) {
|
|
96
|
+
try {
|
|
97
|
+
const prettyStream = pinoPretty__default.default({
|
|
98
|
+
colorize: true,
|
|
99
|
+
translateTime: "HH:MM:ss",
|
|
100
|
+
ignore: "pid,hostname"
|
|
101
|
+
});
|
|
102
|
+
this.pinoInstance = pino__default.default(this.options, prettyStream);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.warn("Warning: pino-pretty failed, using standard JSON output:", error);
|
|
105
|
+
this.pinoInstance = pino__default.default(this.options);
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
const multiTransport = { targets: this.transportConfigs };
|
|
109
|
+
const pinoTransport = pino__default.default.transport(multiTransport);
|
|
110
|
+
this.pinoInstance = pino__default.default(this.options, pinoTransport);
|
|
111
|
+
}
|
|
58
112
|
}
|
|
59
|
-
|
|
60
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Add a new transport to the logger
|
|
115
|
+
*/
|
|
116
|
+
addTransport(transportConfig) {
|
|
117
|
+
this.transportConfigs.push(transportConfig);
|
|
118
|
+
this.recreateInstance();
|
|
61
119
|
}
|
|
62
|
-
|
|
63
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Remove a transport by index
|
|
122
|
+
*/
|
|
123
|
+
removeTransport(index2) {
|
|
124
|
+
if (index2 >= 0 && index2 < this.transportConfigs.length) {
|
|
125
|
+
this.transportConfigs.splice(index2, 1);
|
|
126
|
+
this.recreateInstance();
|
|
127
|
+
}
|
|
64
128
|
}
|
|
65
|
-
|
|
66
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Get current transports
|
|
131
|
+
*/
|
|
132
|
+
getTransports() {
|
|
133
|
+
return [...this.transportConfigs];
|
|
67
134
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Update logger options
|
|
137
|
+
*/
|
|
138
|
+
updateOptions(options) {
|
|
139
|
+
this.options = {
|
|
140
|
+
...this.options,
|
|
141
|
+
...options
|
|
142
|
+
};
|
|
143
|
+
this.recreateInstance();
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get the underlying pino instance for advanced usage
|
|
147
|
+
*/
|
|
148
|
+
getPinoInstance() {
|
|
149
|
+
return this.pinoInstance;
|
|
71
150
|
}
|
|
72
|
-
|
|
151
|
+
error(data, message) {
|
|
152
|
+
this.pinoInstance.error(data, message);
|
|
73
153
|
}
|
|
74
|
-
|
|
154
|
+
warn(data, message) {
|
|
155
|
+
this.pinoInstance.warn(data, message);
|
|
75
156
|
}
|
|
76
|
-
|
|
157
|
+
info(data, message) {
|
|
158
|
+
this.pinoInstance.info(data, message);
|
|
159
|
+
}
|
|
160
|
+
debug(data, message) {
|
|
161
|
+
this.pinoInstance.debug(data, message);
|
|
77
162
|
}
|
|
78
163
|
};
|
|
79
164
|
var LoggerFactory = class {
|
|
@@ -105,7 +190,7 @@ var LoggerFactory = class {
|
|
|
105
190
|
} else if (this.config.defaultLogger) {
|
|
106
191
|
logger11 = this.config.defaultLogger;
|
|
107
192
|
} else {
|
|
108
|
-
logger11 = new
|
|
193
|
+
logger11 = new PinoLogger(name, this.config.pinoConfig);
|
|
109
194
|
}
|
|
110
195
|
this.loggers.set(name, logger11);
|
|
111
196
|
return logger11;
|
|
@@ -122,9 +207,6 @@ var loggerFactory = new LoggerFactory();
|
|
|
122
207
|
function getLogger(name) {
|
|
123
208
|
return loggerFactory.getLogger(name);
|
|
124
209
|
}
|
|
125
|
-
function configureLogging(config) {
|
|
126
|
-
loggerFactory.configure(config);
|
|
127
|
-
}
|
|
128
210
|
|
|
129
211
|
// src/db/schema.ts
|
|
130
212
|
var schema_exports = {};
|
|
@@ -708,6 +790,7 @@ var apiKeys = sqliteCore.sqliteTable(
|
|
|
708
790
|
// Hashed API key (never store plaintext)
|
|
709
791
|
keyPrefix: sqliteCore.text("key_prefix").notNull(),
|
|
710
792
|
// First 8 chars for identification (e.g., "sk_live_abc...")
|
|
793
|
+
name: sqliteCore.text("name"),
|
|
711
794
|
lastUsedAt: sqliteCore.text("last_used_at"),
|
|
712
795
|
expiresAt: sqliteCore.text("expires_at"),
|
|
713
796
|
createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
|
|
@@ -1341,8 +1424,6 @@ var ArtifactComponentApiInsertSchema = ArtifactComponentInsertSchema.omit({
|
|
|
1341
1424
|
projectId: true,
|
|
1342
1425
|
createdAt: true,
|
|
1343
1426
|
updatedAt: true
|
|
1344
|
-
}).extend({
|
|
1345
|
-
id: resourceIdSchema.optional()
|
|
1346
1427
|
});
|
|
1347
1428
|
var ArtifactComponentApiUpdateSchema = createApiUpdateSchema(
|
|
1348
1429
|
ArtifactComponentUpdateSchema
|
|
@@ -1562,10 +1643,13 @@ var StatusUpdateSchema = zodOpenapi.z.object({
|
|
|
1562
1643
|
prompt: zodOpenapi.z.string().max(2e3, "Custom prompt cannot exceed 2000 characters").optional(),
|
|
1563
1644
|
statusComponents: zodOpenapi.z.array(StatusComponentSchema).optional()
|
|
1564
1645
|
});
|
|
1646
|
+
var CanUseItemSchema = zodOpenapi.z.object({
|
|
1647
|
+
toolId: zodOpenapi.z.string(),
|
|
1648
|
+
toolSelection: zodOpenapi.z.array(zodOpenapi.z.string()).nullable().optional()
|
|
1649
|
+
});
|
|
1565
1650
|
var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
|
|
1566
1651
|
type: zodOpenapi.z.literal("internal"),
|
|
1567
|
-
|
|
1568
|
-
selectedTools: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.array(zodOpenapi.z.string())).optional(),
|
|
1652
|
+
canUse: zodOpenapi.z.array(CanUseItemSchema),
|
|
1569
1653
|
dataComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
1570
1654
|
artifactComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
1571
1655
|
canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
@@ -2527,16 +2611,21 @@ var getRelatedAgentsForGraph = (db) => async (params) => {
|
|
|
2527
2611
|
name: agents.name,
|
|
2528
2612
|
description: agents.description,
|
|
2529
2613
|
relationType: agentRelations.relationType
|
|
2530
|
-
}).from(agentRelations).innerJoin(
|
|
2614
|
+
}).from(agentRelations).innerJoin(
|
|
2615
|
+
agents,
|
|
2616
|
+
drizzleOrm.and(
|
|
2617
|
+
drizzleOrm.eq(agentRelations.targetAgentId, agents.id),
|
|
2618
|
+
drizzleOrm.eq(agentRelations.tenantId, agents.tenantId),
|
|
2619
|
+
drizzleOrm.eq(agentRelations.projectId, agents.projectId),
|
|
2620
|
+
drizzleOrm.eq(agentRelations.graphId, agents.graphId)
|
|
2621
|
+
)
|
|
2622
|
+
).where(
|
|
2531
2623
|
drizzleOrm.and(
|
|
2532
2624
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2533
2625
|
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2534
2626
|
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2535
2627
|
drizzleOrm.eq(agentRelations.sourceAgentId, params.agentId),
|
|
2536
|
-
drizzleOrm.isNotNull(agentRelations.targetAgentId)
|
|
2537
|
-
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
2538
|
-
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
2539
|
-
drizzleOrm.eq(agents.graphId, params.scopes.graphId)
|
|
2628
|
+
drizzleOrm.isNotNull(agentRelations.targetAgentId)
|
|
2540
2629
|
)
|
|
2541
2630
|
);
|
|
2542
2631
|
const externalRelations = await db.select({
|
|
@@ -2548,16 +2637,21 @@ var getRelatedAgentsForGraph = (db) => async (params) => {
|
|
|
2548
2637
|
description: externalAgents.description,
|
|
2549
2638
|
baseUrl: externalAgents.baseUrl
|
|
2550
2639
|
}
|
|
2551
|
-
}).from(agentRelations).innerJoin(
|
|
2640
|
+
}).from(agentRelations).innerJoin(
|
|
2641
|
+
externalAgents,
|
|
2642
|
+
drizzleOrm.and(
|
|
2643
|
+
drizzleOrm.eq(agentRelations.externalAgentId, externalAgents.id),
|
|
2644
|
+
drizzleOrm.eq(agentRelations.tenantId, externalAgents.tenantId),
|
|
2645
|
+
drizzleOrm.eq(agentRelations.projectId, externalAgents.projectId),
|
|
2646
|
+
drizzleOrm.eq(agentRelations.graphId, externalAgents.graphId)
|
|
2647
|
+
)
|
|
2648
|
+
).where(
|
|
2552
2649
|
drizzleOrm.and(
|
|
2553
2650
|
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2554
2651
|
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2555
2652
|
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2556
2653
|
drizzleOrm.eq(agentRelations.sourceAgentId, params.agentId),
|
|
2557
|
-
drizzleOrm.isNotNull(agentRelations.externalAgentId)
|
|
2558
|
-
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
2559
|
-
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
2560
|
-
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId)
|
|
2654
|
+
drizzleOrm.isNotNull(agentRelations.externalAgentId)
|
|
2561
2655
|
)
|
|
2562
2656
|
);
|
|
2563
2657
|
return {
|
|
@@ -2820,7 +2914,14 @@ var getToolsForAgent = (db) => async (params) => {
|
|
|
2820
2914
|
availableTools: tools.availableTools,
|
|
2821
2915
|
credentialReferenceId: tools.credentialReferenceId
|
|
2822
2916
|
}
|
|
2823
|
-
}).from(agentToolRelations).innerJoin(
|
|
2917
|
+
}).from(agentToolRelations).innerJoin(
|
|
2918
|
+
tools,
|
|
2919
|
+
drizzleOrm.and(
|
|
2920
|
+
drizzleOrm.eq(agentToolRelations.tenantId, tools.tenantId),
|
|
2921
|
+
drizzleOrm.eq(agentToolRelations.projectId, tools.projectId),
|
|
2922
|
+
drizzleOrm.eq(agentToolRelations.toolId, tools.id)
|
|
2923
|
+
)
|
|
2924
|
+
).where(
|
|
2824
2925
|
drizzleOrm.and(
|
|
2825
2926
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2826
2927
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
@@ -2868,7 +2969,15 @@ var getAgentsForTool = (db) => async (params) => {
|
|
|
2868
2969
|
createdAt: agents.createdAt,
|
|
2869
2970
|
updatedAt: agents.updatedAt
|
|
2870
2971
|
}
|
|
2871
|
-
}).from(agentToolRelations).innerJoin(
|
|
2972
|
+
}).from(agentToolRelations).innerJoin(
|
|
2973
|
+
agents,
|
|
2974
|
+
drizzleOrm.and(
|
|
2975
|
+
drizzleOrm.eq(agentToolRelations.agentId, agents.id),
|
|
2976
|
+
drizzleOrm.eq(agentToolRelations.tenantId, agents.tenantId),
|
|
2977
|
+
drizzleOrm.eq(agentToolRelations.projectId, agents.projectId),
|
|
2978
|
+
drizzleOrm.eq(agentToolRelations.graphId, agents.graphId)
|
|
2979
|
+
)
|
|
2980
|
+
).where(
|
|
2872
2981
|
drizzleOrm.and(
|
|
2873
2982
|
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
2874
2983
|
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
@@ -3555,8 +3664,20 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3555
3664
|
availableTools: tools.availableTools,
|
|
3556
3665
|
lastToolsSync: tools.lastToolsSync,
|
|
3557
3666
|
selectedTools: agentToolRelations.selectedTools
|
|
3558
|
-
}).from(agentToolRelations).innerJoin(
|
|
3559
|
-
|
|
3667
|
+
}).from(agentToolRelations).innerJoin(
|
|
3668
|
+
tools,
|
|
3669
|
+
drizzleOrm.and(
|
|
3670
|
+
drizzleOrm.eq(agentToolRelations.toolId, tools.id),
|
|
3671
|
+
drizzleOrm.eq(agentToolRelations.tenantId, tools.tenantId),
|
|
3672
|
+
drizzleOrm.eq(agentToolRelations.projectId, tools.projectId)
|
|
3673
|
+
)
|
|
3674
|
+
).where(
|
|
3675
|
+
drizzleOrm.and(
|
|
3676
|
+
drizzleOrm.eq(agentToolRelations.tenantId, tenantId),
|
|
3677
|
+
drizzleOrm.eq(agentToolRelations.projectId, projectId),
|
|
3678
|
+
drizzleOrm.eq(agentToolRelations.graphId, graphId),
|
|
3679
|
+
drizzleOrm.eq(agentToolRelations.agentId, agent.id)
|
|
3680
|
+
)
|
|
3560
3681
|
);
|
|
3561
3682
|
const agentDataComponentRelations = await db.query.agentDataComponents.findMany({
|
|
3562
3683
|
where: drizzleOrm.and(
|
|
@@ -3574,12 +3695,10 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3574
3695
|
const agentArtifactComponentIds = agentArtifactComponentRelations.map(
|
|
3575
3696
|
(rel) => rel.artifactComponentId
|
|
3576
3697
|
);
|
|
3577
|
-
const
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
}
|
|
3582
|
-
});
|
|
3698
|
+
const canUse = agentTools.map((tool2) => ({
|
|
3699
|
+
toolId: tool2.id,
|
|
3700
|
+
toolSelection: tool2.selectedTools || null
|
|
3701
|
+
}));
|
|
3583
3702
|
return {
|
|
3584
3703
|
id: agent.id,
|
|
3585
3704
|
name: agent.name,
|
|
@@ -3591,20 +3710,8 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3591
3710
|
canDelegateTo,
|
|
3592
3711
|
dataComponents: agentDataComponentIds,
|
|
3593
3712
|
artifactComponents: agentArtifactComponentIds,
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
id: tool2.id,
|
|
3597
|
-
name: tool2.name,
|
|
3598
|
-
config: tool2.config,
|
|
3599
|
-
imageUrl: tool2.imageUrl || void 0,
|
|
3600
|
-
status: tool2.status,
|
|
3601
|
-
capabilities: tool2.capabilities || void 0,
|
|
3602
|
-
lastHealthCheck: tool2.lastHealthCheck && !Number.isNaN(new Date(tool2.lastHealthCheck).getTime()) ? new Date(tool2.lastHealthCheck).toISOString() : void 0,
|
|
3603
|
-
lastError: tool2.lastError || void 0,
|
|
3604
|
-
availableTools: tool2.availableTools || void 0,
|
|
3605
|
-
activeTools: tool2.config?.mcp?.activeTools || void 0,
|
|
3606
|
-
lastToolsSync: tool2.lastToolsSync && !Number.isNaN(new Date(tool2.lastToolsSync).getTime()) ? new Date(tool2.lastToolsSync).toISOString() : void 0
|
|
3607
|
-
}))
|
|
3713
|
+
canUse
|
|
3714
|
+
// Use the new canUse structure
|
|
3608
3715
|
};
|
|
3609
3716
|
})
|
|
3610
3717
|
);
|
|
@@ -3627,7 +3734,6 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3627
3734
|
(agent) => agent !== null
|
|
3628
3735
|
);
|
|
3629
3736
|
const agentsObject = {};
|
|
3630
|
-
const toolsObject = {};
|
|
3631
3737
|
for (const agent of validAgents) {
|
|
3632
3738
|
const isExternalAgent2 = "baseUrl" in agent && agent.baseUrl;
|
|
3633
3739
|
if (isExternalAgent2) {
|
|
@@ -3638,22 +3744,7 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3638
3744
|
baseUrl: agent.baseUrl
|
|
3639
3745
|
};
|
|
3640
3746
|
} else {
|
|
3641
|
-
|
|
3642
|
-
const toolIds = [];
|
|
3643
|
-
const agentSelectedTools = {};
|
|
3644
|
-
for (const tool2 of toolsData) {
|
|
3645
|
-
toolsObject[tool2.id] = tool2;
|
|
3646
|
-
toolIds.push(tool2.id);
|
|
3647
|
-
if (tool2.selectedTools !== null && tool2.selectedTools !== void 0) {
|
|
3648
|
-
agentSelectedTools[tool2.id] = tool2.selectedTools;
|
|
3649
|
-
}
|
|
3650
|
-
}
|
|
3651
|
-
agentsObject[agent.id] = {
|
|
3652
|
-
...agent,
|
|
3653
|
-
tools: toolIds,
|
|
3654
|
-
// Replace tool objects with tool IDs
|
|
3655
|
-
...Object.keys(agentSelectedTools).length > 0 && { selectedTools: agentSelectedTools }
|
|
3656
|
-
};
|
|
3747
|
+
agentsObject[agent.id] = agent;
|
|
3657
3748
|
}
|
|
3658
3749
|
}
|
|
3659
3750
|
let contextConfig2 = null;
|
|
@@ -3667,11 +3758,10 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3667
3758
|
console.warn(`Failed to retrieve contextConfig ${graph.contextConfigId}:`, error);
|
|
3668
3759
|
}
|
|
3669
3760
|
}
|
|
3670
|
-
let dataComponentsObject = {};
|
|
3671
3761
|
try {
|
|
3672
3762
|
const internalAgentIds = graphAgents.map((agent) => agent.id);
|
|
3673
3763
|
const agentIds = Array.from(internalAgentIds);
|
|
3674
|
-
|
|
3764
|
+
await fetchComponentRelationships(db)(
|
|
3675
3765
|
{ tenantId, projectId },
|
|
3676
3766
|
agentIds,
|
|
3677
3767
|
{
|
|
@@ -3690,11 +3780,10 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3690
3780
|
} catch (error) {
|
|
3691
3781
|
console.warn("Failed to retrieve dataComponents:", error);
|
|
3692
3782
|
}
|
|
3693
|
-
let artifactComponentsObject = {};
|
|
3694
3783
|
try {
|
|
3695
3784
|
const internalAgentIds = graphAgents.map((agent) => agent.id);
|
|
3696
3785
|
const agentIds = Array.from(internalAgentIds);
|
|
3697
|
-
|
|
3786
|
+
await fetchComponentRelationships(db)(
|
|
3698
3787
|
{ tenantId, projectId },
|
|
3699
3788
|
agentIds,
|
|
3700
3789
|
{
|
|
@@ -3720,7 +3809,7 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3720
3809
|
description: graph.description,
|
|
3721
3810
|
defaultAgentId: graph.defaultAgentId,
|
|
3722
3811
|
agents: agentsObject,
|
|
3723
|
-
tools
|
|
3812
|
+
// No tools field - tools are defined at project level
|
|
3724
3813
|
createdAt: graph.createdAt && !Number.isNaN(new Date(graph.createdAt).getTime()) ? new Date(graph.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3725
3814
|
updatedAt: graph.updatedAt && !Number.isNaN(new Date(graph.updatedAt).getTime()) ? new Date(graph.updatedAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
|
|
3726
3815
|
};
|
|
@@ -3745,12 +3834,6 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
3745
3834
|
contextVariables: contextConfig2.contextVariables
|
|
3746
3835
|
};
|
|
3747
3836
|
}
|
|
3748
|
-
if (Object.keys(dataComponentsObject).length > 0) {
|
|
3749
|
-
result.dataComponents = dataComponentsObject;
|
|
3750
|
-
}
|
|
3751
|
-
if (Object.keys(artifactComponentsObject).length > 0) {
|
|
3752
|
-
result.artifactComponents = artifactComponentsObject;
|
|
3753
|
-
}
|
|
3754
3837
|
try {
|
|
3755
3838
|
if (!db.query?.projects?.findFirst) {
|
|
3756
3839
|
return result;
|
|
@@ -3953,6 +4036,7 @@ var createApiKey = (db) => async (params) => {
|
|
|
3953
4036
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3954
4037
|
const [apiKey] = await db.insert(apiKeys).values({
|
|
3955
4038
|
id: params.id,
|
|
4039
|
+
name: params.name,
|
|
3956
4040
|
tenantId: params.tenantId,
|
|
3957
4041
|
projectId: params.projectId,
|
|
3958
4042
|
graphId: params.graphId,
|
|
@@ -3968,6 +4052,7 @@ var createApiKey = (db) => async (params) => {
|
|
|
3968
4052
|
var updateApiKey = (db) => async (params) => {
|
|
3969
4053
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3970
4054
|
const [updatedKey] = await db.update(apiKeys).set({
|
|
4055
|
+
name: params.data.name,
|
|
3971
4056
|
expiresAt: params.data.expiresAt,
|
|
3972
4057
|
updatedAt: now
|
|
3973
4058
|
}).where(
|
|
@@ -4021,12 +4106,13 @@ var countApiKeys = (db) => async (params) => {
|
|
|
4021
4106
|
return typeof total === "string" ? Number.parseInt(total, 10) : total;
|
|
4022
4107
|
};
|
|
4023
4108
|
var generateAndCreateApiKey = async (params, db) => {
|
|
4024
|
-
const { tenantId, projectId, graphId, expiresAt } = params;
|
|
4109
|
+
const { tenantId, projectId, graphId, expiresAt, name } = params;
|
|
4025
4110
|
const keyData = await generateApiKey();
|
|
4026
4111
|
const apiKey = await createApiKey(db)({
|
|
4027
4112
|
tenantId,
|
|
4028
4113
|
projectId,
|
|
4029
4114
|
graphId,
|
|
4115
|
+
name,
|
|
4030
4116
|
expiresAt,
|
|
4031
4117
|
...keyData
|
|
4032
4118
|
});
|
|
@@ -4222,7 +4308,21 @@ var isArtifactComponentAssociatedWithAgent = (db) => async (params) => {
|
|
|
4222
4308
|
return result.length > 0;
|
|
4223
4309
|
};
|
|
4224
4310
|
var graphHasArtifactComponents = (db) => async (params) => {
|
|
4225
|
-
const result = await db.select({ count: drizzleOrm.count() }).from(agentArtifactComponents).innerJoin(
|
|
4311
|
+
const result = await db.select({ count: drizzleOrm.count() }).from(agentArtifactComponents).innerJoin(
|
|
4312
|
+
agents,
|
|
4313
|
+
drizzleOrm.and(
|
|
4314
|
+
drizzleOrm.eq(agentArtifactComponents.agentId, agents.id),
|
|
4315
|
+
drizzleOrm.eq(agentArtifactComponents.tenantId, agents.tenantId)
|
|
4316
|
+
)
|
|
4317
|
+
).innerJoin(
|
|
4318
|
+
agentRelations,
|
|
4319
|
+
drizzleOrm.and(
|
|
4320
|
+
drizzleOrm.eq(agents.id, agentRelations.sourceAgentId),
|
|
4321
|
+
drizzleOrm.eq(agents.tenantId, agentRelations.tenantId),
|
|
4322
|
+
drizzleOrm.eq(agents.projectId, agentRelations.projectId),
|
|
4323
|
+
drizzleOrm.eq(agents.graphId, agentRelations.graphId)
|
|
4324
|
+
)
|
|
4325
|
+
).where(
|
|
4226
4326
|
drizzleOrm.and(
|
|
4227
4327
|
drizzleOrm.eq(agentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
4228
4328
|
drizzleOrm.eq(agentArtifactComponents.projectId, params.scopes.projectId),
|
|
@@ -4985,10 +5085,10 @@ function validateToolReferences(graphData, availableToolIds) {
|
|
|
4985
5085
|
}
|
|
4986
5086
|
const errors = [];
|
|
4987
5087
|
for (const [agentId, agentData] of Object.entries(graphData.agents)) {
|
|
4988
|
-
if (isInternalAgent(agentData) && agentData.
|
|
4989
|
-
for (const
|
|
4990
|
-
if (!availableToolIds.has(toolId)) {
|
|
4991
|
-
errors.push(`Agent '${agentId}' references non-existent tool '${toolId}'`);
|
|
5088
|
+
if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
|
|
5089
|
+
for (const canUseItem of agentData.canUse) {
|
|
5090
|
+
if (!availableToolIds.has(canUseItem.toolId)) {
|
|
5091
|
+
errors.push(`Agent '${agentId}' references non-existent tool '${canUseItem.toolId}'`);
|
|
4992
5092
|
}
|
|
4993
5093
|
}
|
|
4994
5094
|
}
|
|
@@ -5523,22 +5623,22 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5523
5623
|
}
|
|
5524
5624
|
const agentToolPromises = [];
|
|
5525
5625
|
for (const [agentId, agentData] of Object.entries(typed.agents)) {
|
|
5526
|
-
if (isInternalAgent(agentData) && agentData.
|
|
5527
|
-
for (const
|
|
5626
|
+
if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
|
|
5627
|
+
for (const canUseItem of agentData.canUse) {
|
|
5528
5628
|
agentToolPromises.push(
|
|
5529
5629
|
(async () => {
|
|
5530
5630
|
try {
|
|
5531
|
-
const
|
|
5631
|
+
const { toolId, toolSelection } = canUseItem;
|
|
5532
5632
|
logger11.info({ agentId, toolId }, "Processing agent-tool relation");
|
|
5533
5633
|
await upsertAgentToolRelation(db)({
|
|
5534
5634
|
scopes: { tenantId, projectId, graphId: finalGraphId },
|
|
5535
5635
|
agentId,
|
|
5536
5636
|
toolId,
|
|
5537
|
-
selectedTools
|
|
5637
|
+
selectedTools: toolSelection || void 0
|
|
5538
5638
|
});
|
|
5539
5639
|
logger11.info({ agentId, toolId }, "Agent-tool relation processed successfully");
|
|
5540
5640
|
} catch (error) {
|
|
5541
|
-
logger11.error({ agentId, toolId, error }, "Failed to create agent-tool relation");
|
|
5641
|
+
logger11.error({ agentId, toolId: canUseItem.toolId, error }, "Failed to create agent-tool relation");
|
|
5542
5642
|
}
|
|
5543
5643
|
})()
|
|
5544
5644
|
);
|
|
@@ -5822,17 +5922,17 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5822
5922
|
const modelTypes = ["base", "structuredOutput", "summarizer"];
|
|
5823
5923
|
const cascadedModels = { ...finalModelSettings };
|
|
5824
5924
|
for (const modelType of modelTypes) {
|
|
5825
|
-
if (agentModels[modelType]?.model && existingGraphModels?.[modelType]?.model && agentModels[modelType].model === existingGraphModels[modelType].model && graphModels[modelType]
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
};
|
|
5925
|
+
if (agentModels[modelType]?.model && existingGraphModels?.[modelType]?.model && agentModels[modelType].model === existingGraphModels[modelType].model && graphModels[modelType] && // Model name changed
|
|
5926
|
+
(graphModels[modelType].model !== existingGraphModels[modelType].model || // OR providerOptions changed
|
|
5927
|
+
JSON.stringify(graphModels[modelType].providerOptions) !== JSON.stringify(existingGraphModels[modelType].providerOptions))) {
|
|
5928
|
+
cascadedModels[modelType] = graphModels[modelType];
|
|
5830
5929
|
logger11.info(
|
|
5831
5930
|
{
|
|
5832
5931
|
agentId,
|
|
5833
5932
|
modelType,
|
|
5834
5933
|
oldModel: agentModels[modelType].model,
|
|
5835
|
-
newModel: graphModels[modelType].model
|
|
5934
|
+
newModel: graphModels[modelType].model,
|
|
5935
|
+
hasProviderOptions: !!graphModels[modelType].providerOptions
|
|
5836
5936
|
},
|
|
5837
5937
|
"Cascading model change from graph to agent"
|
|
5838
5938
|
);
|
|
@@ -5916,23 +6016,23 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
|
|
|
5916
6016
|
}
|
|
5917
6017
|
const agentToolPromises = [];
|
|
5918
6018
|
for (const [agentId, agentData] of Object.entries(typedGraphDefinition.agents)) {
|
|
5919
|
-
if (isInternalAgent(agentData) && agentData.
|
|
5920
|
-
for (const
|
|
6019
|
+
if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
|
|
6020
|
+
for (const canUseItem of agentData.canUse) {
|
|
5921
6021
|
agentToolPromises.push(
|
|
5922
6022
|
(async () => {
|
|
5923
6023
|
try {
|
|
5924
|
-
const
|
|
6024
|
+
const { toolId, toolSelection } = canUseItem;
|
|
5925
6025
|
await createAgentToolRelation(db)({
|
|
5926
6026
|
scopes: { tenantId, projectId, graphId: finalGraphId },
|
|
5927
6027
|
data: {
|
|
5928
6028
|
agentId,
|
|
5929
6029
|
toolId,
|
|
5930
|
-
selectedTools
|
|
6030
|
+
selectedTools: toolSelection || void 0
|
|
5931
6031
|
}
|
|
5932
6032
|
});
|
|
5933
6033
|
logger11.info({ agentId, toolId }, "Agent-tool relation created");
|
|
5934
6034
|
} catch (error) {
|
|
5935
|
-
logger11.error({ agentId, toolId, error }, "Failed to create agent-tool relation");
|
|
6035
|
+
logger11.error({ agentId, toolId: canUseItem.toolId, error }, "Failed to create agent-tool relation");
|
|
5936
6036
|
}
|
|
5937
6037
|
})()
|
|
5938
6038
|
);
|
|
@@ -6796,7 +6896,6 @@ var createFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scop
|
|
|
6796
6896
|
);
|
|
6797
6897
|
await upsertArtifactComponent(db)({
|
|
6798
6898
|
data: {
|
|
6799
|
-
id: componentId,
|
|
6800
6899
|
...componentData,
|
|
6801
6900
|
tenantId,
|
|
6802
6901
|
projectId: typed.id
|
|
@@ -7102,7 +7201,6 @@ var updateFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scop
|
|
|
7102
7201
|
);
|
|
7103
7202
|
await upsertArtifactComponent(db)({
|
|
7104
7203
|
data: {
|
|
7105
|
-
id: componentId,
|
|
7106
7204
|
...componentData,
|
|
7107
7205
|
tenantId,
|
|
7108
7206
|
projectId: typed.id
|
|
@@ -7228,14 +7326,10 @@ var getFullProject = (db, logger11 = defaultLogger2) => async (params) => {
|
|
|
7228
7326
|
id: tool2.id,
|
|
7229
7327
|
name: tool2.name,
|
|
7230
7328
|
config: tool2.config,
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
lastError: tool2.lastError || void 0,
|
|
7236
|
-
availableTools: tool2.availableTools || void 0,
|
|
7237
|
-
activeTools: tool2.config?.mcp?.activeTools || void 0,
|
|
7238
|
-
lastToolsSync: tool2.lastToolsSync && !Number.isNaN(new Date(tool2.lastToolsSync).getTime()) ? new Date(tool2.lastToolsSync).toISOString() : void 0
|
|
7329
|
+
credentialReferenceId: tool2.credentialReferenceId || void 0,
|
|
7330
|
+
imageUrl: tool2.imageUrl || void 0
|
|
7331
|
+
// Don't include runtime fields in configuration
|
|
7332
|
+
// status, capabilities, lastHealthCheck, lastError, availableTools, activeTools, lastToolsSync are all runtime
|
|
7239
7333
|
};
|
|
7240
7334
|
}
|
|
7241
7335
|
logger11.info(
|
|
@@ -10115,7 +10209,7 @@ function createDefaultCredentialStores() {
|
|
|
10115
10209
|
if (process.env.NANGO_SECRET_KEY) {
|
|
10116
10210
|
stores.push(
|
|
10117
10211
|
createNangoCredentialStore("nango-default", {
|
|
10118
|
-
apiUrl: process.env.
|
|
10212
|
+
apiUrl: process.env.NANGO_SERVER_URL || "https://api.nango.dev",
|
|
10119
10213
|
secretKey: process.env.NANGO_SECRET_KEY
|
|
10120
10214
|
})
|
|
10121
10215
|
);
|
|
@@ -10151,7 +10245,7 @@ var loadEnvironmentFiles = () => {
|
|
|
10151
10245
|
loadEnvironmentFiles();
|
|
10152
10246
|
var envSchema = zod.z.object({
|
|
10153
10247
|
ENVIRONMENT: zod.z.enum(["development", "production", "pentest", "test"]).optional(),
|
|
10154
|
-
DB_FILE_NAME: zod.z.string(),
|
|
10248
|
+
DB_FILE_NAME: zod.z.string().optional(),
|
|
10155
10249
|
OTEL_TRACES_FORCE_FLUSH_ENABLED: zod.z.coerce.boolean().optional()
|
|
10156
10250
|
});
|
|
10157
10251
|
var parseEnv = () => {
|
|
@@ -10241,7 +10335,7 @@ exports.ArtifactComponentApiUpdateSchema = ArtifactComponentApiUpdateSchema;
|
|
|
10241
10335
|
exports.ArtifactComponentInsertSchema = ArtifactComponentInsertSchema;
|
|
10242
10336
|
exports.ArtifactComponentSelectSchema = ArtifactComponentSelectSchema;
|
|
10243
10337
|
exports.ArtifactComponentUpdateSchema = ArtifactComponentUpdateSchema;
|
|
10244
|
-
exports.
|
|
10338
|
+
exports.CanUseItemSchema = CanUseItemSchema;
|
|
10245
10339
|
exports.ContextCache = ContextCache;
|
|
10246
10340
|
exports.ContextCacheApiInsertSchema = ContextCacheApiInsertSchema;
|
|
10247
10341
|
exports.ContextCacheApiSelectSchema = ContextCacheApiSelectSchema;
|
|
@@ -10329,9 +10423,9 @@ exports.MessageUpdateSchema = MessageUpdateSchema;
|
|
|
10329
10423
|
exports.ModelSchema = ModelSchema;
|
|
10330
10424
|
exports.ModelSettingsSchema = ModelSettingsSchema;
|
|
10331
10425
|
exports.NangoCredentialStore = NangoCredentialStore;
|
|
10332
|
-
exports.NoOpLogger = NoOpLogger;
|
|
10333
10426
|
exports.PaginationQueryParamsSchema = PaginationQueryParamsSchema;
|
|
10334
10427
|
exports.PaginationSchema = PaginationSchema;
|
|
10428
|
+
exports.PinoLogger = PinoLogger;
|
|
10335
10429
|
exports.ProjectApiInsertSchema = ProjectApiInsertSchema;
|
|
10336
10430
|
exports.ProjectApiSelectSchema = ProjectApiSelectSchema;
|
|
10337
10431
|
exports.ProjectApiUpdateSchema = ProjectApiUpdateSchema;
|
|
@@ -10401,7 +10495,6 @@ exports.commonCreateErrorResponses = commonCreateErrorResponses;
|
|
|
10401
10495
|
exports.commonDeleteErrorResponses = commonDeleteErrorResponses;
|
|
10402
10496
|
exports.commonGetErrorResponses = commonGetErrorResponses;
|
|
10403
10497
|
exports.commonUpdateErrorResponses = commonUpdateErrorResponses;
|
|
10404
|
-
exports.configureLogging = configureLogging;
|
|
10405
10498
|
exports.contextCache = contextCache;
|
|
10406
10499
|
exports.contextCacheRelations = contextCacheRelations;
|
|
10407
10500
|
exports.contextConfig = contextConfig;
|