@inkeep/agents-core 0.58.14 → 0.58.16
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/auth/auth-schema.d.ts +85 -85
- package/dist/auth/auth-validation-schemas.d.ts +135 -135
- package/dist/auth/auth.js +17 -45
- package/dist/data-access/index.d.ts +5 -2
- package/dist/data-access/index.js +5 -2
- package/dist/data-access/manage/agentFull.js +28 -12
- package/dist/data-access/manage/agents.d.ts +35 -34
- package/dist/data-access/manage/agents.js +33 -33
- package/dist/data-access/manage/artifactComponents.d.ts +12 -12
- package/dist/data-access/manage/artifactComponents.js +14 -13
- package/dist/data-access/manage/audit-queries.js +6 -5
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- package/dist/data-access/manage/contextConfigs.js +7 -6
- package/dist/data-access/manage/credentialReferences.js +12 -11
- package/dist/data-access/manage/dataComponents.d.ts +6 -6
- package/dist/data-access/manage/dataComponents.js +13 -11
- package/dist/data-access/manage/evalConfig.js +42 -41
- package/dist/data-access/manage/externalAgents.js +8 -7
- package/dist/data-access/manage/functionTools.d.ts +17 -21
- package/dist/data-access/manage/functionTools.js +27 -65
- package/dist/data-access/manage/functions.js +7 -10
- package/dist/data-access/manage/projects.js +37 -36
- package/dist/data-access/manage/scheduledTriggers.js +10 -6
- package/dist/data-access/manage/scheduledWorkflows.js +3 -2
- package/dist/data-access/manage/scope-helpers.d.ts +2 -1
- package/dist/data-access/manage/scope-helpers.js +2 -1
- package/dist/data-access/manage/skills.d.ts +14 -14
- package/dist/data-access/manage/skills.js +14 -9
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgentRelations.d.ts +28 -28
- package/dist/data-access/manage/subAgentRelations.js +28 -26
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgentTeamAgentRelations.js +16 -16
- package/dist/data-access/manage/subAgents.d.ts +18 -18
- package/dist/data-access/manage/subAgents.js +8 -7
- package/dist/data-access/manage/tools.d.ts +24 -24
- package/dist/data-access/manage/tools.js +8 -6
- package/dist/data-access/manage/triggers.js +12 -8
- package/dist/data-access/runtime/apiKeys.d.ts +20 -20
- package/dist/data-access/runtime/apiKeys.js +16 -12
- package/dist/data-access/runtime/apps.d.ts +10 -10
- package/dist/data-access/runtime/apps.js +8 -7
- package/dist/data-access/runtime/audit-queries.js +7 -7
- package/dist/data-access/runtime/auth.d.ts +18 -0
- package/dist/data-access/runtime/auth.js +35 -0
- package/dist/data-access/runtime/cascade-delete.js +29 -24
- package/dist/data-access/runtime/contextCache.d.ts +1 -0
- package/dist/data-access/runtime/contextCache.js +9 -8
- package/dist/data-access/runtime/conversations.d.ts +27 -27
- package/dist/data-access/runtime/conversations.js +8 -12
- package/dist/data-access/runtime/evalRuns.js +23 -22
- package/dist/data-access/runtime/github-work-app-installations.js +32 -21
- package/dist/data-access/runtime/ledgerArtifacts.js +9 -24
- package/dist/data-access/runtime/messages.d.ts +24 -19
- package/dist/data-access/runtime/messages.js +15 -9
- package/dist/data-access/runtime/projects.js +6 -5
- package/dist/data-access/runtime/scheduledTriggerInvocations.js +16 -26
- package/dist/data-access/runtime/slack-work-app-mcp.js +6 -5
- package/dist/data-access/runtime/tasks.d.ts +10 -6
- package/dist/data-access/runtime/tasks.js +4 -5
- package/dist/data-access/runtime/triggerInvocations.js +4 -8
- package/dist/data-access/runtime/workAppSlack.js +21 -14
- package/dist/db/manage/manage-schema.d.ts +357 -357
- package/dist/db/runtime/runtime-schema.d.ts +300 -300
- package/dist/index.d.ts +7 -3
- package/dist/index.js +8 -2
- package/dist/retry/index.d.ts +3 -0
- package/dist/retry/index.js +4 -0
- package/dist/retry/retryable-errors.d.ts +10 -0
- package/dist/retry/retryable-errors.js +72 -0
- package/dist/retry/withRetry.d.ts +15 -0
- package/dist/retry/withRetry.js +37 -0
- package/dist/validation/dolt-schemas.d.ts +1 -1
- package/dist/validation/schemas.d.ts +1704 -1704
- package/package.json +1 -1
|
@@ -10,13 +10,13 @@ declare const getSubAgentTeamAgentRelationById: (db: AgentsManageDatabaseClient)
|
|
|
10
10
|
relationId: string;
|
|
11
11
|
}) => Promise<{
|
|
12
12
|
id: string;
|
|
13
|
+
tenantId: string;
|
|
14
|
+
projectId: string;
|
|
15
|
+
agentId: string;
|
|
13
16
|
createdAt: string;
|
|
14
17
|
updatedAt: string;
|
|
15
|
-
subAgentId: string;
|
|
16
|
-
projectId: string;
|
|
17
|
-
tenantId: string;
|
|
18
18
|
headers: Record<string, string> | null;
|
|
19
|
-
|
|
19
|
+
subAgentId: string;
|
|
20
20
|
targetAgentId: string;
|
|
21
21
|
} | undefined>;
|
|
22
22
|
declare const listSubAgentTeamAgentRelations: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -45,26 +45,26 @@ declare const getSubAgentTeamAgentRelations: (db: AgentsManageDatabaseClient) =>
|
|
|
45
45
|
scopes: SubAgentScopeConfig;
|
|
46
46
|
}) => Promise<{
|
|
47
47
|
id: string;
|
|
48
|
+
tenantId: string;
|
|
49
|
+
projectId: string;
|
|
50
|
+
agentId: string;
|
|
48
51
|
createdAt: string;
|
|
49
52
|
updatedAt: string;
|
|
50
|
-
subAgentId: string;
|
|
51
|
-
projectId: string;
|
|
52
|
-
tenantId: string;
|
|
53
53
|
headers: Record<string, string> | null;
|
|
54
|
-
|
|
54
|
+
subAgentId: string;
|
|
55
55
|
targetAgentId: string;
|
|
56
56
|
}[]>;
|
|
57
57
|
declare const getSubAgentTeamAgentRelationsByAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
58
58
|
scopes: AgentScopeConfig;
|
|
59
59
|
}) => Promise<{
|
|
60
60
|
id: string;
|
|
61
|
+
tenantId: string;
|
|
62
|
+
projectId: string;
|
|
63
|
+
agentId: string;
|
|
61
64
|
createdAt: string;
|
|
62
65
|
updatedAt: string;
|
|
63
|
-
subAgentId: string;
|
|
64
|
-
projectId: string;
|
|
65
|
-
tenantId: string;
|
|
66
66
|
headers: Record<string, string> | null;
|
|
67
|
-
|
|
67
|
+
subAgentId: string;
|
|
68
68
|
targetAgentId: string;
|
|
69
69
|
}[]>;
|
|
70
70
|
declare const getSubAgentTeamAgentRelationsByTeamAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -211,13 +211,13 @@ declare const createSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient)
|
|
|
211
211
|
};
|
|
212
212
|
}) => Promise<{
|
|
213
213
|
id: string;
|
|
214
|
+
tenantId: string;
|
|
215
|
+
projectId: string;
|
|
216
|
+
agentId: string;
|
|
214
217
|
createdAt: string;
|
|
215
218
|
updatedAt: string;
|
|
216
|
-
subAgentId: string;
|
|
217
|
-
projectId: string;
|
|
218
|
-
tenantId: string;
|
|
219
219
|
headers: Record<string, string> | null;
|
|
220
|
-
|
|
220
|
+
subAgentId: string;
|
|
221
221
|
targetAgentId: string;
|
|
222
222
|
}>;
|
|
223
223
|
/**
|
|
@@ -228,13 +228,13 @@ declare const getSubAgentTeamAgentRelationByParams: (db: AgentsManageDatabaseCli
|
|
|
228
228
|
targetAgentId: string;
|
|
229
229
|
}) => Promise<{
|
|
230
230
|
id: string;
|
|
231
|
+
tenantId: string;
|
|
232
|
+
projectId: string;
|
|
233
|
+
agentId: string;
|
|
231
234
|
createdAt: string;
|
|
232
235
|
updatedAt: string;
|
|
233
|
-
subAgentId: string;
|
|
234
|
-
projectId: string;
|
|
235
|
-
tenantId: string;
|
|
236
236
|
headers: Record<string, string> | null;
|
|
237
|
-
|
|
237
|
+
subAgentId: string;
|
|
238
238
|
targetAgentId: string;
|
|
239
239
|
} | undefined>;
|
|
240
240
|
/**
|
|
@@ -249,13 +249,13 @@ declare const upsertSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient)
|
|
|
249
249
|
};
|
|
250
250
|
}) => Promise<{
|
|
251
251
|
id: string;
|
|
252
|
+
tenantId: string;
|
|
253
|
+
projectId: string;
|
|
254
|
+
agentId: string;
|
|
252
255
|
createdAt: string;
|
|
253
256
|
updatedAt: string;
|
|
254
|
-
subAgentId: string;
|
|
255
|
-
projectId: string;
|
|
256
|
-
tenantId: string;
|
|
257
257
|
headers: Record<string, string> | null;
|
|
258
|
-
|
|
258
|
+
subAgentId: string;
|
|
259
259
|
targetAgentId: string;
|
|
260
260
|
}>;
|
|
261
261
|
declare const updateSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { agents, subAgentTeamAgentRelations, subAgents } from "../../db/manage/manage-schema.js";
|
|
2
|
+
import { agentScopedWhere, subAgentScopedWhere } from "./scope-helpers.js";
|
|
2
3
|
import { and, count, desc, eq } from "drizzle-orm";
|
|
3
4
|
import { nanoid } from "nanoid";
|
|
4
5
|
|
|
5
6
|
//#region src/data-access/manage/subAgentTeamAgentRelations.ts
|
|
6
7
|
const getSubAgentTeamAgentRelationById = (db) => async (params) => {
|
|
7
|
-
return db.query.subAgentTeamAgentRelations.findFirst({ where: and(
|
|
8
|
+
return db.query.subAgentTeamAgentRelations.findFirst({ where: and(subAgentScopedWhere(subAgentTeamAgentRelations, params.scopes), eq(subAgentTeamAgentRelations.id, params.relationId)) });
|
|
8
9
|
};
|
|
9
10
|
const listSubAgentTeamAgentRelations = (db) => async (params) => {
|
|
10
11
|
const page = params.pagination?.page || 1;
|
|
11
12
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
12
13
|
const offset = (page - 1) * limit;
|
|
13
|
-
const whereClause =
|
|
14
|
+
const whereClause = subAgentScopedWhere(subAgentTeamAgentRelations, params.scopes);
|
|
14
15
|
const [data, totalResult] = await Promise.all([db.select().from(subAgentTeamAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(desc(subAgentTeamAgentRelations.createdAt)), db.select({ count: count() }).from(subAgentTeamAgentRelations).where(whereClause)]);
|
|
15
16
|
const total = totalResult[0]?.count || 0;
|
|
16
17
|
return {
|
|
@@ -24,16 +25,16 @@ const listSubAgentTeamAgentRelations = (db) => async (params) => {
|
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
27
|
const getSubAgentTeamAgentRelations = (db) => async (params) => {
|
|
27
|
-
return await db.query.subAgentTeamAgentRelations.findMany({ where:
|
|
28
|
+
return await db.query.subAgentTeamAgentRelations.findMany({ where: subAgentScopedWhere(subAgentTeamAgentRelations, params.scopes) });
|
|
28
29
|
};
|
|
29
30
|
const getSubAgentTeamAgentRelationsByAgent = (db) => async (params) => {
|
|
30
|
-
return await db.query.subAgentTeamAgentRelations.findMany({ where:
|
|
31
|
+
return await db.query.subAgentTeamAgentRelations.findMany({ where: agentScopedWhere(subAgentTeamAgentRelations, params.scopes) });
|
|
31
32
|
};
|
|
32
33
|
const getSubAgentTeamAgentRelationsByTeamAgent = (db) => async (params) => {
|
|
33
34
|
const page = params.pagination?.page || 1;
|
|
34
35
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
35
36
|
const offset = (page - 1) * limit;
|
|
36
|
-
const whereClause = and(
|
|
37
|
+
const whereClause = and(agentScopedWhere(subAgentTeamAgentRelations, params.scopes), eq(subAgentTeamAgentRelations.targetAgentId, params.targetAgentId));
|
|
37
38
|
const [data, totalResult] = await Promise.all([db.select().from(subAgentTeamAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(desc(subAgentTeamAgentRelations.createdAt)), db.select({ count: count() }).from(subAgentTeamAgentRelations).where(whereClause)]);
|
|
38
39
|
const total = totalResult[0]?.count || 0;
|
|
39
40
|
return {
|
|
@@ -50,6 +51,7 @@ const getTeamAgentsForSubAgent = (db) => async (params) => {
|
|
|
50
51
|
const page = params.pagination?.page || 1;
|
|
51
52
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
52
53
|
const offset = (page - 1) * limit;
|
|
54
|
+
const whereClause = subAgentScopedWhere(subAgentTeamAgentRelations, params.scopes);
|
|
53
55
|
const [data, totalResult] = await Promise.all([db.select({
|
|
54
56
|
id: subAgentTeamAgentRelations.id,
|
|
55
57
|
tenantId: subAgentTeamAgentRelations.tenantId,
|
|
@@ -73,7 +75,7 @@ const getTeamAgentsForSubAgent = (db) => async (params) => {
|
|
|
73
75
|
createdAt: agents.createdAt,
|
|
74
76
|
updatedAt: agents.updatedAt
|
|
75
77
|
}
|
|
76
|
-
}).from(subAgentTeamAgentRelations).innerJoin(agents, and(eq(subAgentTeamAgentRelations.tenantId, agents.tenantId), eq(subAgentTeamAgentRelations.projectId, agents.projectId), eq(subAgentTeamAgentRelations.targetAgentId, agents.id))).where(
|
|
78
|
+
}).from(subAgentTeamAgentRelations).innerJoin(agents, and(eq(subAgentTeamAgentRelations.tenantId, agents.tenantId), eq(subAgentTeamAgentRelations.projectId, agents.projectId), eq(subAgentTeamAgentRelations.targetAgentId, agents.id))).where(whereClause).limit(limit).offset(offset).orderBy(desc(subAgentTeamAgentRelations.createdAt)), db.select({ count: count() }).from(subAgentTeamAgentRelations).where(whereClause)]);
|
|
77
79
|
const total = totalResult[0]?.count || 0;
|
|
78
80
|
return {
|
|
79
81
|
data,
|
|
@@ -89,6 +91,7 @@ const getSubAgentsForTeamAgent = (db) => async (params) => {
|
|
|
89
91
|
const page = params.pagination?.page || 1;
|
|
90
92
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
91
93
|
const offset = (page - 1) * limit;
|
|
94
|
+
const whereClause = and(agentScopedWhere(subAgentTeamAgentRelations, params.scopes), eq(subAgentTeamAgentRelations.targetAgentId, params.targetAgentId));
|
|
92
95
|
const [data, totalResult] = await Promise.all([db.select({
|
|
93
96
|
id: subAgentTeamAgentRelations.id,
|
|
94
97
|
tenantId: subAgentTeamAgentRelations.tenantId,
|
|
@@ -109,7 +112,7 @@ const getSubAgentsForTeamAgent = (db) => async (params) => {
|
|
|
109
112
|
createdAt: subAgents.createdAt,
|
|
110
113
|
updatedAt: subAgents.updatedAt
|
|
111
114
|
}
|
|
112
|
-
}).from(subAgentTeamAgentRelations).innerJoin(subAgents, and(eq(subAgentTeamAgentRelations.subAgentId, subAgents.id), eq(subAgentTeamAgentRelations.tenantId, subAgents.tenantId), eq(subAgentTeamAgentRelations.projectId, subAgents.projectId), eq(subAgentTeamAgentRelations.agentId, subAgents.agentId))).where(
|
|
115
|
+
}).from(subAgentTeamAgentRelations).innerJoin(subAgents, and(eq(subAgentTeamAgentRelations.subAgentId, subAgents.id), eq(subAgentTeamAgentRelations.tenantId, subAgents.tenantId), eq(subAgentTeamAgentRelations.projectId, subAgents.projectId), eq(subAgentTeamAgentRelations.agentId, subAgents.agentId))).where(whereClause).limit(limit).offset(offset).orderBy(desc(subAgentTeamAgentRelations.createdAt)), db.select({ count: count() }).from(subAgentTeamAgentRelations).where(whereClause)]);
|
|
113
116
|
const total = totalResult[0]?.count || 0;
|
|
114
117
|
return {
|
|
115
118
|
data,
|
|
@@ -125,10 +128,7 @@ const createSubAgentTeamAgentRelation = (db) => async (params) => {
|
|
|
125
128
|
const finalRelationId = params.relationId ?? nanoid();
|
|
126
129
|
return (await db.insert(subAgentTeamAgentRelations).values({
|
|
127
130
|
id: finalRelationId,
|
|
128
|
-
|
|
129
|
-
projectId: params.scopes.projectId,
|
|
130
|
-
agentId: params.scopes.agentId,
|
|
131
|
-
subAgentId: params.scopes.subAgentId,
|
|
131
|
+
...params.scopes,
|
|
132
132
|
targetAgentId: params.data.targetAgentId,
|
|
133
133
|
headers: params.data.headers
|
|
134
134
|
}).returning())[0];
|
|
@@ -137,7 +137,7 @@ const createSubAgentTeamAgentRelation = (db) => async (params) => {
|
|
|
137
137
|
* Check if sub-agent team agent relation exists by params
|
|
138
138
|
*/
|
|
139
139
|
const getSubAgentTeamAgentRelationByParams = (db) => async (params) => {
|
|
140
|
-
return db.query.subAgentTeamAgentRelations.findFirst({ where: and(
|
|
140
|
+
return db.query.subAgentTeamAgentRelations.findFirst({ where: and(subAgentScopedWhere(subAgentTeamAgentRelations, params.scopes), eq(subAgentTeamAgentRelations.targetAgentId, params.targetAgentId)) });
|
|
141
141
|
};
|
|
142
142
|
/**
|
|
143
143
|
* Upsert sub-agent team agent relation (create if it doesn't exist, update if it does)
|
|
@@ -164,16 +164,16 @@ const updateSubAgentTeamAgentRelation = (db) => async (params) => {
|
|
|
164
164
|
...params.data,
|
|
165
165
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
166
166
|
};
|
|
167
|
-
return (await db.update(subAgentTeamAgentRelations).set(updateData).where(and(
|
|
167
|
+
return (await db.update(subAgentTeamAgentRelations).set(updateData).where(and(subAgentScopedWhere(subAgentTeamAgentRelations, params.scopes), eq(subAgentTeamAgentRelations.id, params.relationId))).returning())[0];
|
|
168
168
|
};
|
|
169
169
|
const deleteSubAgentTeamAgentRelation = (db) => async (params) => {
|
|
170
|
-
return (await db.delete(subAgentTeamAgentRelations).where(and(
|
|
170
|
+
return (await db.delete(subAgentTeamAgentRelations).where(and(subAgentScopedWhere(subAgentTeamAgentRelations, params.scopes), eq(subAgentTeamAgentRelations.id, params.relationId))).returning()).length > 0;
|
|
171
171
|
};
|
|
172
172
|
const deleteSubAgentTeamAgentRelationsBySubAgent = (db) => async (params) => {
|
|
173
|
-
return (await db.delete(subAgentTeamAgentRelations).where(
|
|
173
|
+
return (await db.delete(subAgentTeamAgentRelations).where(subAgentScopedWhere(subAgentTeamAgentRelations, params.scopes)).returning()).length > 0;
|
|
174
174
|
};
|
|
175
175
|
const deleteSubAgentTeamAgentRelationsByAgent = (db) => async (params) => {
|
|
176
|
-
return (await db.delete(subAgentTeamAgentRelations).where(
|
|
176
|
+
return (await db.delete(subAgentTeamAgentRelations).where(agentScopedWhere(subAgentTeamAgentRelations, params.scopes)).returning()).length > 0;
|
|
177
177
|
};
|
|
178
178
|
|
|
179
179
|
//#endregion
|
|
@@ -11,11 +11,12 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
11
11
|
}) => Promise<{
|
|
12
12
|
id: string;
|
|
13
13
|
name: string;
|
|
14
|
-
createdAt: string;
|
|
15
|
-
updatedAt: string;
|
|
16
14
|
description: string | null;
|
|
17
|
-
projectId: string;
|
|
18
15
|
tenantId: string;
|
|
16
|
+
projectId: string;
|
|
17
|
+
agentId: string;
|
|
18
|
+
prompt: string | null;
|
|
19
|
+
conversationHistoryConfig: ConversationHistoryConfig | null;
|
|
19
20
|
models: {
|
|
20
21
|
base?: {
|
|
21
22
|
model?: string | undefined;
|
|
@@ -33,20 +34,20 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
33
34
|
stopWhen: {
|
|
34
35
|
stepCountIs?: number | undefined;
|
|
35
36
|
} | null;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
agentId: string;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
updatedAt: string;
|
|
39
39
|
} | undefined>;
|
|
40
40
|
declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
|
|
41
41
|
scopes: AgentScopeConfig;
|
|
42
42
|
}) => Promise<{
|
|
43
43
|
id: string;
|
|
44
44
|
name: string;
|
|
45
|
-
createdAt: string;
|
|
46
|
-
updatedAt: string;
|
|
47
45
|
description: string | null;
|
|
48
|
-
projectId: string;
|
|
49
46
|
tenantId: string;
|
|
47
|
+
projectId: string;
|
|
48
|
+
agentId: string;
|
|
49
|
+
prompt: string | null;
|
|
50
|
+
conversationHistoryConfig: ConversationHistoryConfig | null;
|
|
50
51
|
models: {
|
|
51
52
|
base?: {
|
|
52
53
|
model?: string | undefined;
|
|
@@ -64,9 +65,8 @@ declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
64
65
|
stopWhen: {
|
|
65
66
|
stepCountIs?: number | undefined;
|
|
66
67
|
} | null;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
agentId: string;
|
|
68
|
+
createdAt: string;
|
|
69
|
+
updatedAt: string;
|
|
70
70
|
}[]>;
|
|
71
71
|
declare const listSubAgentsPaginated: (db: AgentsManageDatabaseClient) => (params: {
|
|
72
72
|
scopes: AgentScopeConfig;
|
|
@@ -111,11 +111,12 @@ declare const listSubAgentsPaginated: (db: AgentsManageDatabaseClient) => (param
|
|
|
111
111
|
declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAgentInsert) => Promise<{
|
|
112
112
|
id: string;
|
|
113
113
|
name: string;
|
|
114
|
-
createdAt: string;
|
|
115
|
-
updatedAt: string;
|
|
116
114
|
description: string | null;
|
|
117
|
-
projectId: string;
|
|
118
115
|
tenantId: string;
|
|
116
|
+
projectId: string;
|
|
117
|
+
agentId: string;
|
|
118
|
+
prompt: string | null;
|
|
119
|
+
conversationHistoryConfig: ConversationHistoryConfig | null;
|
|
119
120
|
models: {
|
|
120
121
|
base?: {
|
|
121
122
|
model?: string | undefined;
|
|
@@ -133,9 +134,8 @@ declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAg
|
|
|
133
134
|
stopWhen: {
|
|
134
135
|
stepCountIs?: number | undefined;
|
|
135
136
|
} | null;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
agentId: string;
|
|
137
|
+
createdAt: string;
|
|
138
|
+
updatedAt: string;
|
|
139
139
|
}>;
|
|
140
140
|
declare const updateSubAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
141
141
|
scopes: AgentScopeConfig;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { agents, subAgents } from "../../db/manage/manage-schema.js";
|
|
2
|
+
import { agentScopedWhere, projectScopedWhere } from "./scope-helpers.js";
|
|
2
3
|
import { and, count, desc, eq, inArray } from "drizzle-orm";
|
|
3
4
|
|
|
4
5
|
//#region src/data-access/manage/subAgents.ts
|
|
5
6
|
const getSubAgentById = (db) => async (params) => {
|
|
6
|
-
return await db.query.subAgents.findFirst({ where: and(
|
|
7
|
+
return await db.query.subAgents.findFirst({ where: and(agentScopedWhere(subAgents, params.scopes), eq(subAgents.id, params.subAgentId)) });
|
|
7
8
|
};
|
|
8
9
|
const listSubAgents = (db) => async (params) => {
|
|
9
|
-
return await db.query.subAgents.findMany({ where:
|
|
10
|
+
return await db.query.subAgents.findMany({ where: agentScopedWhere(subAgents, params.scopes) });
|
|
10
11
|
};
|
|
11
12
|
const listSubAgentsPaginated = (db) => async (params) => {
|
|
12
13
|
const page = params.pagination?.page || 1;
|
|
13
14
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
14
15
|
const offset = (page - 1) * limit;
|
|
15
|
-
const whereClause =
|
|
16
|
+
const whereClause = agentScopedWhere(subAgents, params.scopes);
|
|
16
17
|
const [data, totalResult] = await Promise.all([db.select().from(subAgents).where(whereClause).limit(limit).offset(offset).orderBy(desc(subAgents.createdAt)), db.select({ count: count() }).from(subAgents).where(whereClause)]);
|
|
17
18
|
const total = totalResult[0]?.count || 0;
|
|
18
19
|
return {
|
|
@@ -37,7 +38,7 @@ const updateSubAgent = (db) => async (params) => {
|
|
|
37
38
|
...data,
|
|
38
39
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
39
40
|
};
|
|
40
|
-
return (await db.update(subAgents).set(updateData).where(and(
|
|
41
|
+
return (await db.update(subAgents).set(updateData).where(and(agentScopedWhere(subAgents, params.scopes), inArray(subAgents.id, [params.subAgentId]))).returning())[0] ?? null;
|
|
41
42
|
};
|
|
42
43
|
/**
|
|
43
44
|
* Upsert agent (create if it doesn't exist, update if it does)
|
|
@@ -78,8 +79,8 @@ var SubAgentIsDefaultError = class extends Error {
|
|
|
78
79
|
}
|
|
79
80
|
};
|
|
80
81
|
const deleteSubAgent = (db) => async (params) => {
|
|
81
|
-
if ((await db.select().from(agents).where(and(
|
|
82
|
-
await db.delete(subAgents).where(and(
|
|
82
|
+
if ((await db.select().from(agents).where(and(projectScopedWhere(agents, params.scopes), eq(agents.id, params.scopes.agentId), eq(agents.defaultSubAgentId, params.subAgentId))).limit(1)).length > 0) throw new SubAgentIsDefaultError(params.subAgentId, params.scopes.agentId);
|
|
83
|
+
await db.delete(subAgents).where(and(agentScopedWhere(subAgents, params.scopes), inArray(subAgents.id, [params.subAgentId])));
|
|
83
84
|
return await getSubAgentById(db)({
|
|
84
85
|
scopes: params.scopes,
|
|
85
86
|
subAgentId: params.subAgentId
|
|
@@ -87,7 +88,7 @@ const deleteSubAgent = (db) => async (params) => {
|
|
|
87
88
|
};
|
|
88
89
|
const getSubAgentsByIds = (db) => async (params) => {
|
|
89
90
|
if (params.subAgentIds.length === 0) return [];
|
|
90
|
-
return await db.select().from(subAgents).where(and(
|
|
91
|
+
return await db.select().from(subAgents).where(and(agentScopedWhere(subAgents, params.scopes), inArray(subAgents.id, params.subAgentIds)));
|
|
91
92
|
};
|
|
92
93
|
|
|
93
94
|
//#endregion
|
|
@@ -22,11 +22,11 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
22
22
|
}) => Promise<{
|
|
23
23
|
id: string;
|
|
24
24
|
name: string;
|
|
25
|
-
createdAt: string;
|
|
26
|
-
updatedAt: string;
|
|
27
25
|
description: string | null;
|
|
28
|
-
projectId: string;
|
|
29
26
|
tenantId: string;
|
|
27
|
+
projectId: string;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
updatedAt: string;
|
|
30
30
|
headers: Record<string, string> | null;
|
|
31
31
|
config: {
|
|
32
32
|
type: "mcp";
|
|
@@ -80,11 +80,11 @@ declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
80
80
|
declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInsert) => Promise<{
|
|
81
81
|
id: string;
|
|
82
82
|
name: string;
|
|
83
|
-
createdAt: string;
|
|
84
|
-
updatedAt: string;
|
|
85
83
|
description: string | null;
|
|
86
|
-
projectId: string;
|
|
87
84
|
tenantId: string;
|
|
85
|
+
projectId: string;
|
|
86
|
+
createdAt: string;
|
|
87
|
+
updatedAt: string;
|
|
88
88
|
headers: Record<string, string> | null;
|
|
89
89
|
config: {
|
|
90
90
|
type: "mcp";
|
|
@@ -136,17 +136,17 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
136
136
|
}> | null;
|
|
137
137
|
}) => Promise<{
|
|
138
138
|
id: string;
|
|
139
|
-
createdAt: string;
|
|
140
|
-
updatedAt: string;
|
|
141
|
-
subAgentId: string;
|
|
142
|
-
projectId: string;
|
|
143
139
|
tenantId: string;
|
|
144
|
-
|
|
140
|
+
projectId: string;
|
|
145
141
|
agentId: string;
|
|
142
|
+
createdAt: string;
|
|
143
|
+
updatedAt: string;
|
|
146
144
|
toolId: string;
|
|
145
|
+
headers: Record<string, string> | null;
|
|
147
146
|
toolPolicies: Record<string, {
|
|
148
147
|
needsApproval?: boolean;
|
|
149
148
|
}> | null;
|
|
149
|
+
subAgentId: string;
|
|
150
150
|
selectedTools: string[] | null;
|
|
151
151
|
}>;
|
|
152
152
|
declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -155,17 +155,17 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
|
|
|
155
155
|
toolId: string;
|
|
156
156
|
}) => Promise<{
|
|
157
157
|
id: string;
|
|
158
|
-
createdAt: string;
|
|
159
|
-
updatedAt: string;
|
|
160
|
-
subAgentId: string;
|
|
161
|
-
projectId: string;
|
|
162
158
|
tenantId: string;
|
|
163
|
-
|
|
159
|
+
projectId: string;
|
|
164
160
|
agentId: string;
|
|
161
|
+
createdAt: string;
|
|
162
|
+
updatedAt: string;
|
|
165
163
|
toolId: string;
|
|
164
|
+
headers: Record<string, string> | null;
|
|
166
165
|
toolPolicies: Record<string, {
|
|
167
166
|
needsApproval?: boolean;
|
|
168
167
|
}> | null;
|
|
168
|
+
subAgentId: string;
|
|
169
169
|
selectedTools: string[] | null;
|
|
170
170
|
}>;
|
|
171
171
|
/**
|
|
@@ -183,17 +183,17 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
183
183
|
relationId?: string;
|
|
184
184
|
}) => Promise<{
|
|
185
185
|
id: string;
|
|
186
|
-
createdAt: string;
|
|
187
|
-
updatedAt: string;
|
|
188
|
-
subAgentId: string;
|
|
189
|
-
projectId: string;
|
|
190
186
|
tenantId: string;
|
|
191
|
-
|
|
187
|
+
projectId: string;
|
|
192
188
|
agentId: string;
|
|
189
|
+
createdAt: string;
|
|
190
|
+
updatedAt: string;
|
|
193
191
|
toolId: string;
|
|
192
|
+
headers: Record<string, string> | null;
|
|
194
193
|
toolPolicies: Record<string, {
|
|
195
194
|
needsApproval?: boolean;
|
|
196
195
|
}> | null;
|
|
196
|
+
subAgentId: string;
|
|
197
197
|
selectedTools: string[] | null;
|
|
198
198
|
}>;
|
|
199
199
|
/**
|
|
@@ -204,11 +204,11 @@ declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
204
204
|
}) => Promise<{
|
|
205
205
|
id: string;
|
|
206
206
|
name: string;
|
|
207
|
-
createdAt: string;
|
|
208
|
-
updatedAt: string;
|
|
209
207
|
description: string | null;
|
|
210
|
-
projectId: string;
|
|
211
208
|
tenantId: string;
|
|
209
|
+
projectId: string;
|
|
210
|
+
createdAt: string;
|
|
211
|
+
updatedAt: string;
|
|
212
212
|
headers: Record<string, string> | null;
|
|
213
213
|
config: {
|
|
214
214
|
type: "mcp";
|
|
@@ -9,9 +9,11 @@ import "../../credential-stuffer/index.js";
|
|
|
9
9
|
import { createAgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
10
10
|
import { generateId } from "../../utils/conversations.js";
|
|
11
11
|
import { getActiveBranch } from "../../dolt/schema-sync.js";
|
|
12
|
+
import { agentScopedWhere, projectScopedWhere } from "./scope-helpers.js";
|
|
12
13
|
import { isSlackWorkAppTool } from "../runtime/slack-work-app-mcp.js";
|
|
13
14
|
import { cascadeDeleteByTool } from "../runtime/cascade-delete.js";
|
|
14
15
|
import { updateAgentToolRelation } from "./subAgentRelations.js";
|
|
16
|
+
import { isSerializationError } from "../../retry/retryable-errors.js";
|
|
15
17
|
import { toISODateString } from "../../utils/date.js";
|
|
16
18
|
import { McpClient } from "../../utils/mcp-client.js";
|
|
17
19
|
import { configureComposioMCPServer } from "../../utils/third-party-mcp-servers/composio-client.js";
|
|
@@ -270,7 +272,7 @@ const dbResultToMcpTool = async (dbResult, dbClient, credentialStoreRegistry, re
|
|
|
270
272
|
}
|
|
271
273
|
});
|
|
272
274
|
} catch (updateError) {
|
|
273
|
-
if (
|
|
275
|
+
if (isSerializationError(updateError)) logger.debug({ toolId: dbResult.id }, "Skipping tool metadata update due to serialization conflict (concurrent request)");
|
|
274
276
|
else logger.warn({
|
|
275
277
|
toolId: dbResult.id,
|
|
276
278
|
error: updateError
|
|
@@ -293,7 +295,7 @@ const dbResultToMcpTool = async (dbResult, dbClient, credentialStoreRegistry, re
|
|
|
293
295
|
};
|
|
294
296
|
};
|
|
295
297
|
const getToolById = (db) => async (params) => {
|
|
296
|
-
return await db.query.tools.findFirst({ where: and(
|
|
298
|
+
return await db.query.tools.findFirst({ where: and(projectScopedWhere(tools, params.scopes), eq(tools.id, params.toolId)) }) ?? null;
|
|
297
299
|
};
|
|
298
300
|
const getMcpToolById = (db) => async (params) => {
|
|
299
301
|
const tool = await getToolById(db)({
|
|
@@ -307,7 +309,7 @@ const listTools = (db) => async (params) => {
|
|
|
307
309
|
const page = params.pagination?.page || 1;
|
|
308
310
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
309
311
|
const offset = (page - 1) * limit;
|
|
310
|
-
const whereClause =
|
|
312
|
+
const whereClause = projectScopedWhere(tools, params.scopes);
|
|
311
313
|
const [toolsDbResults, totalResult] = await Promise.all([db.select().from(tools).where(whereClause).limit(limit).offset(offset).orderBy(desc(tools.createdAt)), db.select({ count: count() }).from(tools).where(whereClause)]);
|
|
312
314
|
const total = totalResult[0]?.count || 0;
|
|
313
315
|
return {
|
|
@@ -334,11 +336,11 @@ const updateTool = (db) => async (params) => {
|
|
|
334
336
|
const [updated] = await db.update(tools).set({
|
|
335
337
|
...params.data,
|
|
336
338
|
updatedAt: now
|
|
337
|
-
}).where(and(
|
|
339
|
+
}).where(and(projectScopedWhere(tools, params.scopes), eq(tools.id, params.toolId))).returning();
|
|
338
340
|
return updated ?? null;
|
|
339
341
|
};
|
|
340
342
|
const deleteTool = (db) => async (params) => {
|
|
341
|
-
const [deleted] = await db.delete(tools).where(and(
|
|
343
|
+
const [deleted] = await db.delete(tools).where(and(projectScopedWhere(tools, params.scopes), eq(tools.id, params.toolId))).returning();
|
|
342
344
|
if (!deleted) return false;
|
|
343
345
|
if (deleted.isWorkApp && deleted.config.mcp.server.url.includes("/github/mcp") || isSlackWorkAppTool(deleted)) try {
|
|
344
346
|
if (await getActiveBranch(db)() === `${params.scopes.tenantId}_${params.scopes.projectId}_main`) await cascadeDeleteByTool(createAgentsRunDatabaseClient())({
|
|
@@ -373,7 +375,7 @@ const addToolToAgent = (db) => async (params) => {
|
|
|
373
375
|
return created;
|
|
374
376
|
};
|
|
375
377
|
const removeToolFromAgent = (db) => async (params) => {
|
|
376
|
-
const [deleted] = await db.delete(subAgentToolRelations).where(and(
|
|
378
|
+
const [deleted] = await db.delete(subAgentToolRelations).where(and(agentScopedWhere(subAgentToolRelations, params.scopes), eq(subAgentToolRelations.subAgentId, params.subAgentId), eq(subAgentToolRelations.toolId, params.toolId))).returning();
|
|
377
379
|
return deleted;
|
|
378
380
|
};
|
|
379
381
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { triggers } from "../../db/manage/manage-schema.js";
|
|
2
|
+
import { agentScopedWhere, projectScopedWhere } from "./scope-helpers.js";
|
|
2
3
|
import { and, count, desc, eq } from "drizzle-orm";
|
|
3
4
|
|
|
4
5
|
//#region src/data-access/manage/triggers.ts
|
|
@@ -7,13 +8,13 @@ import { and, count, desc, eq } from "drizzle-orm";
|
|
|
7
8
|
*/
|
|
8
9
|
const getTriggerById = (db) => async (params) => {
|
|
9
10
|
const { scopes, triggerId } = params;
|
|
10
|
-
return await db.query.triggers.findFirst({ where: and(
|
|
11
|
+
return await db.query.triggers.findFirst({ where: and(agentScopedWhere(triggers, scopes), eq(triggers.id, triggerId)) });
|
|
11
12
|
};
|
|
12
13
|
/**
|
|
13
14
|
* List all triggers for an agent
|
|
14
15
|
*/
|
|
15
16
|
const listTriggers = (db) => async (params) => {
|
|
16
|
-
return await db.query.triggers.findMany({ where:
|
|
17
|
+
return await db.query.triggers.findMany({ where: agentScopedWhere(triggers, params.scopes) });
|
|
17
18
|
};
|
|
18
19
|
/**
|
|
19
20
|
* List triggers for an agent with pagination
|
|
@@ -22,7 +23,7 @@ const listTriggersPaginated = (db) => async (params) => {
|
|
|
22
23
|
const page = params.pagination?.page || 1;
|
|
23
24
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
24
25
|
const offset = (page - 1) * limit;
|
|
25
|
-
const whereClause =
|
|
26
|
+
const whereClause = agentScopedWhere(triggers, params.scopes);
|
|
26
27
|
const [data, totalResult] = await Promise.all([db.select().from(triggers).where(whereClause).limit(limit).offset(offset).orderBy(desc(triggers.createdAt)), db.select({ count: count() }).from(triggers).where(whereClause)]);
|
|
27
28
|
const total = totalResult[0]?.count || 0;
|
|
28
29
|
return {
|
|
@@ -49,32 +50,35 @@ const updateTrigger = (db) => async (params) => {
|
|
|
49
50
|
...params.data,
|
|
50
51
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
51
52
|
};
|
|
52
|
-
return (await db.update(triggers).set(updateData).where(and(
|
|
53
|
+
return (await db.update(triggers).set(updateData).where(and(agentScopedWhere(triggers, params.scopes), eq(triggers.id, params.triggerId))).returning())[0];
|
|
53
54
|
};
|
|
54
55
|
/**
|
|
55
56
|
* Delete a trigger (agent-scoped)
|
|
56
57
|
*/
|
|
57
58
|
const deleteTrigger = (db) => async (params) => {
|
|
58
|
-
await db.delete(triggers).where(and(
|
|
59
|
+
await db.delete(triggers).where(and(agentScopedWhere(triggers, params.scopes), eq(triggers.id, params.triggerId)));
|
|
59
60
|
};
|
|
60
61
|
/**
|
|
61
62
|
* Delete all webhook triggers for a given runAsUserId within a tenant+project scope.
|
|
62
63
|
* Operates across all agents in the project (not agent-scoped).
|
|
63
64
|
*/
|
|
64
65
|
const deleteTriggersByRunAsUserId = (db) => async (params) => {
|
|
65
|
-
await db.delete(triggers).where(and(
|
|
66
|
+
await db.delete(triggers).where(and(projectScopedWhere(triggers, {
|
|
67
|
+
tenantId: params.tenantId,
|
|
68
|
+
projectId: params.projectId
|
|
69
|
+
}), eq(triggers.runAsUserId, params.runAsUserId)));
|
|
66
70
|
};
|
|
67
71
|
/**
|
|
68
72
|
* Upsert a trigger (create or update based on existence)
|
|
69
73
|
*/
|
|
70
74
|
const upsertTrigger = (db) => async (params) => {
|
|
71
75
|
const { scopes, data } = params;
|
|
72
|
-
if (await db.query.triggers.findFirst({ where: and(
|
|
76
|
+
if (await db.query.triggers.findFirst({ where: and(agentScopedWhere(triggers, scopes), eq(triggers.id, data.id)) })) {
|
|
73
77
|
const updateData = {
|
|
74
78
|
...data,
|
|
75
79
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
76
80
|
};
|
|
77
|
-
return (await db.update(triggers).set(updateData).where(and(
|
|
81
|
+
return (await db.update(triggers).set(updateData).where(and(agentScopedWhere(triggers, scopes), eq(triggers.id, data.id))).returning())[0];
|
|
78
82
|
}
|
|
79
83
|
return (await db.insert(triggers).values({
|
|
80
84
|
...data,
|