@inkeep/agents-core 0.58.13 → 0.58.15
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 +107 -107
- package/dist/auth/auth-validation-schemas.d.ts +152 -152
- package/dist/auth/auth.d.ts +9 -9
- package/dist/auth/auth.js +17 -45
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/data-access/index.d.ts +6 -1
- package/dist/data-access/index.js +6 -1
- package/dist/data-access/manage/agentFull.js +28 -12
- package/dist/data-access/manage/agents.d.ts +40 -39
- package/dist/data-access/manage/agents.js +33 -33
- package/dist/data-access/manage/artifactComponents.d.ts +8 -8
- package/dist/data-access/manage/artifactComponents.js +14 -13
- package/dist/data-access/manage/audit-queries.d.ts +29 -0
- package/dist/data-access/manage/audit-queries.js +30 -0
- package/dist/data-access/manage/contextConfigs.d.ts +4 -4
- 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 +4 -4
- 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 +11 -15
- 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 +11 -11
- package/dist/data-access/manage/skills.js +14 -9
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgentRelations.js +28 -26
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgentTeamAgentRelations.js +16 -16
- package/dist/data-access/manage/subAgents.d.ts +21 -21
- package/dist/data-access/manage/subAgents.js +8 -7
- package/dist/data-access/manage/tools.d.ts +15 -15
- package/dist/data-access/manage/tools.js +8 -6
- package/dist/data-access/manage/triggers.d.ts +2 -2
- package/dist/data-access/manage/triggers.js +12 -8
- package/dist/data-access/runtime/apiKeys.d.ts +16 -16
- package/dist/data-access/runtime/apiKeys.js +16 -12
- package/dist/data-access/runtime/apps.d.ts +6 -6
- package/dist/data-access/runtime/apps.js +8 -7
- package/dist/data-access/runtime/audit-queries.d.ts +41 -0
- package/dist/data-access/runtime/audit-queries.js +37 -0
- 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 +16 -16
- 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 +21 -21
- package/dist/data-access/runtime/messages.js +9 -8
- package/dist/data-access/runtime/projects.js +6 -5
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +3 -3
- 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 +9 -5
- 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/data-reconciliation/audit.d.ts +6 -0
- package/dist/data-reconciliation/audit.js +37 -0
- package/dist/data-reconciliation/index.d.ts +4 -0
- package/dist/data-reconciliation/index.js +5 -0
- package/dist/data-reconciliation/reconcile.d.ts +6 -0
- package/dist/data-reconciliation/reconcile.js +58 -0
- package/dist/data-reconciliation/types.d.ts +116 -0
- package/dist/data-reconciliation/types.js +7 -0
- package/dist/db/manage/manage-schema.d.ts +453 -453
- package/dist/db/runtime/runtime-schema.d.ts +326 -326
- package/dist/index.d.ts +12 -2
- package/dist/index.js +12 -1
- 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/setup/setup.d.ts +1 -0
- package/dist/setup/setup.js +25 -8
- package/dist/utils/error.d.ts +51 -51
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/schemas.d.ts +1987 -1990
- package/dist/validation/schemas.js +5 -1
- package/package.json +1 -1
|
@@ -9,14 +9,14 @@ declare const getSubAgentTeamAgentRelationById: (db: AgentsManageDatabaseClient)
|
|
|
9
9
|
scopes: SubAgentScopeConfig;
|
|
10
10
|
relationId: string;
|
|
11
11
|
}) => Promise<{
|
|
12
|
-
id: string;
|
|
13
12
|
tenantId: string;
|
|
14
13
|
projectId: string;
|
|
15
14
|
agentId: string;
|
|
15
|
+
subAgentId: string;
|
|
16
|
+
id: string;
|
|
16
17
|
createdAt: string;
|
|
17
18
|
updatedAt: string;
|
|
18
19
|
headers: Record<string, string> | null;
|
|
19
|
-
subAgentId: string;
|
|
20
20
|
targetAgentId: string;
|
|
21
21
|
} | undefined>;
|
|
22
22
|
declare const listSubAgentTeamAgentRelations: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -44,27 +44,27 @@ declare const listSubAgentTeamAgentRelations: (db: AgentsManageDatabaseClient) =
|
|
|
44
44
|
declare const getSubAgentTeamAgentRelations: (db: AgentsManageDatabaseClient) => (params: {
|
|
45
45
|
scopes: SubAgentScopeConfig;
|
|
46
46
|
}) => Promise<{
|
|
47
|
-
id: string;
|
|
48
47
|
tenantId: string;
|
|
49
48
|
projectId: string;
|
|
50
49
|
agentId: string;
|
|
50
|
+
subAgentId: string;
|
|
51
|
+
id: string;
|
|
51
52
|
createdAt: string;
|
|
52
53
|
updatedAt: string;
|
|
53
54
|
headers: Record<string, string> | null;
|
|
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
|
-
id: string;
|
|
61
60
|
tenantId: string;
|
|
62
61
|
projectId: string;
|
|
63
62
|
agentId: string;
|
|
63
|
+
subAgentId: string;
|
|
64
|
+
id: string;
|
|
64
65
|
createdAt: string;
|
|
65
66
|
updatedAt: string;
|
|
66
67
|
headers: Record<string, string> | null;
|
|
67
|
-
subAgentId: string;
|
|
68
68
|
targetAgentId: string;
|
|
69
69
|
}[]>;
|
|
70
70
|
declare const getSubAgentTeamAgentRelationsByTeamAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -210,14 +210,14 @@ declare const createSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient)
|
|
|
210
210
|
headers?: Record<string, string> | null;
|
|
211
211
|
};
|
|
212
212
|
}) => Promise<{
|
|
213
|
-
id: string;
|
|
214
213
|
tenantId: string;
|
|
215
214
|
projectId: string;
|
|
216
215
|
agentId: string;
|
|
216
|
+
subAgentId: string;
|
|
217
|
+
id: string;
|
|
217
218
|
createdAt: string;
|
|
218
219
|
updatedAt: string;
|
|
219
220
|
headers: Record<string, string> | null;
|
|
220
|
-
subAgentId: string;
|
|
221
221
|
targetAgentId: string;
|
|
222
222
|
}>;
|
|
223
223
|
/**
|
|
@@ -227,14 +227,14 @@ declare const getSubAgentTeamAgentRelationByParams: (db: AgentsManageDatabaseCli
|
|
|
227
227
|
scopes: SubAgentScopeConfig;
|
|
228
228
|
targetAgentId: string;
|
|
229
229
|
}) => Promise<{
|
|
230
|
-
id: string;
|
|
231
230
|
tenantId: string;
|
|
232
231
|
projectId: string;
|
|
233
232
|
agentId: string;
|
|
233
|
+
subAgentId: string;
|
|
234
|
+
id: string;
|
|
234
235
|
createdAt: string;
|
|
235
236
|
updatedAt: string;
|
|
236
237
|
headers: Record<string, string> | null;
|
|
237
|
-
subAgentId: string;
|
|
238
238
|
targetAgentId: string;
|
|
239
239
|
} | undefined>;
|
|
240
240
|
/**
|
|
@@ -248,14 +248,14 @@ declare const upsertSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient)
|
|
|
248
248
|
headers?: Record<string, string> | null;
|
|
249
249
|
};
|
|
250
250
|
}) => Promise<{
|
|
251
|
-
id: string;
|
|
252
251
|
tenantId: string;
|
|
253
252
|
projectId: string;
|
|
254
253
|
agentId: string;
|
|
254
|
+
subAgentId: string;
|
|
255
|
+
id: string;
|
|
255
256
|
createdAt: string;
|
|
256
257
|
updatedAt: string;
|
|
257
258
|
headers: Record<string, string> | null;
|
|
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
|
|
@@ -9,14 +9,14 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
9
9
|
scopes: AgentScopeConfig;
|
|
10
10
|
subAgentId: string;
|
|
11
11
|
}) => Promise<{
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
description: string | null;
|
|
15
12
|
tenantId: string;
|
|
16
13
|
projectId: string;
|
|
17
14
|
agentId: string;
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
description: string | null;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
updatedAt: string;
|
|
20
20
|
models: {
|
|
21
21
|
base?: {
|
|
22
22
|
model?: string | undefined;
|
|
@@ -34,20 +34,20 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
34
34
|
stopWhen: {
|
|
35
35
|
stepCountIs?: number | undefined;
|
|
36
36
|
} | null;
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
prompt: string | null;
|
|
38
|
+
conversationHistoryConfig: ConversationHistoryConfig | null;
|
|
39
39
|
} | undefined>;
|
|
40
40
|
declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
|
|
41
41
|
scopes: AgentScopeConfig;
|
|
42
42
|
}) => Promise<{
|
|
43
|
-
id: string;
|
|
44
|
-
name: string;
|
|
45
|
-
description: string | null;
|
|
46
43
|
tenantId: string;
|
|
47
44
|
projectId: string;
|
|
48
45
|
agentId: string;
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
description: string | null;
|
|
49
|
+
createdAt: string;
|
|
50
|
+
updatedAt: string;
|
|
51
51
|
models: {
|
|
52
52
|
base?: {
|
|
53
53
|
model?: string | undefined;
|
|
@@ -65,8 +65,8 @@ declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
65
65
|
stopWhen: {
|
|
66
66
|
stepCountIs?: number | undefined;
|
|
67
67
|
} | null;
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
prompt: string | null;
|
|
69
|
+
conversationHistoryConfig: ConversationHistoryConfig | null;
|
|
70
70
|
}[]>;
|
|
71
71
|
declare const listSubAgentsPaginated: (db: AgentsManageDatabaseClient) => (params: {
|
|
72
72
|
scopes: AgentScopeConfig;
|
|
@@ -109,14 +109,14 @@ declare const listSubAgentsPaginated: (db: AgentsManageDatabaseClient) => (param
|
|
|
109
109
|
};
|
|
110
110
|
}>;
|
|
111
111
|
declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAgentInsert) => Promise<{
|
|
112
|
-
id: string;
|
|
113
|
-
name: string;
|
|
114
|
-
description: string | null;
|
|
115
112
|
tenantId: string;
|
|
116
113
|
projectId: string;
|
|
117
114
|
agentId: string;
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
id: string;
|
|
116
|
+
name: string;
|
|
117
|
+
description: string | null;
|
|
118
|
+
createdAt: string;
|
|
119
|
+
updatedAt: string;
|
|
120
120
|
models: {
|
|
121
121
|
base?: {
|
|
122
122
|
model?: string | undefined;
|
|
@@ -134,8 +134,8 @@ declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAg
|
|
|
134
134
|
stopWhen: {
|
|
135
135
|
stepCountIs?: number | undefined;
|
|
136
136
|
} | null;
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
prompt: string | null;
|
|
138
|
+
conversationHistoryConfig: ConversationHistoryConfig | null;
|
|
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
|
|
@@ -20,11 +20,11 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
20
20
|
scopes: ProjectScopeConfig;
|
|
21
21
|
toolId: string;
|
|
22
22
|
}) => Promise<{
|
|
23
|
+
tenantId: string;
|
|
24
|
+
projectId: string;
|
|
23
25
|
id: string;
|
|
24
26
|
name: string;
|
|
25
27
|
description: string | null;
|
|
26
|
-
tenantId: string;
|
|
27
|
-
projectId: string;
|
|
28
28
|
createdAt: string;
|
|
29
29
|
updatedAt: string;
|
|
30
30
|
headers: Record<string, string> | null;
|
|
@@ -78,11 +78,11 @@ declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
78
78
|
};
|
|
79
79
|
}>;
|
|
80
80
|
declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInsert) => Promise<{
|
|
81
|
+
tenantId: string;
|
|
82
|
+
projectId: string;
|
|
81
83
|
id: string;
|
|
82
84
|
name: string;
|
|
83
85
|
description: string | null;
|
|
84
|
-
tenantId: string;
|
|
85
|
-
projectId: string;
|
|
86
86
|
createdAt: string;
|
|
87
87
|
updatedAt: string;
|
|
88
88
|
headers: Record<string, string> | null;
|
|
@@ -135,18 +135,18 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
135
135
|
needsApproval?: boolean;
|
|
136
136
|
}> | null;
|
|
137
137
|
}) => Promise<{
|
|
138
|
-
id: string;
|
|
139
138
|
tenantId: string;
|
|
140
139
|
projectId: string;
|
|
141
140
|
agentId: string;
|
|
141
|
+
subAgentId: string;
|
|
142
|
+
toolId: string;
|
|
143
|
+
id: string;
|
|
142
144
|
createdAt: string;
|
|
143
145
|
updatedAt: string;
|
|
144
|
-
toolId: string;
|
|
145
146
|
headers: Record<string, string> | null;
|
|
146
147
|
toolPolicies: Record<string, {
|
|
147
148
|
needsApproval?: boolean;
|
|
148
149
|
}> | null;
|
|
149
|
-
subAgentId: string;
|
|
150
150
|
selectedTools: string[] | null;
|
|
151
151
|
}>;
|
|
152
152
|
declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -154,18 +154,18 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
|
|
|
154
154
|
subAgentId: string;
|
|
155
155
|
toolId: string;
|
|
156
156
|
}) => Promise<{
|
|
157
|
-
id: string;
|
|
158
157
|
tenantId: string;
|
|
159
158
|
projectId: string;
|
|
160
159
|
agentId: string;
|
|
160
|
+
subAgentId: string;
|
|
161
|
+
toolId: string;
|
|
162
|
+
id: string;
|
|
161
163
|
createdAt: string;
|
|
162
164
|
updatedAt: string;
|
|
163
|
-
toolId: string;
|
|
164
165
|
headers: Record<string, string> | null;
|
|
165
166
|
toolPolicies: Record<string, {
|
|
166
167
|
needsApproval?: boolean;
|
|
167
168
|
}> | null;
|
|
168
|
-
subAgentId: string;
|
|
169
169
|
selectedTools: string[] | null;
|
|
170
170
|
}>;
|
|
171
171
|
/**
|
|
@@ -182,18 +182,18 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
182
182
|
}> | null;
|
|
183
183
|
relationId?: string;
|
|
184
184
|
}) => Promise<{
|
|
185
|
-
id: string;
|
|
186
185
|
tenantId: string;
|
|
187
186
|
projectId: string;
|
|
188
187
|
agentId: string;
|
|
188
|
+
subAgentId: string;
|
|
189
|
+
toolId: string;
|
|
190
|
+
id: string;
|
|
189
191
|
createdAt: string;
|
|
190
192
|
updatedAt: string;
|
|
191
|
-
toolId: string;
|
|
192
193
|
headers: Record<string, string> | null;
|
|
193
194
|
toolPolicies: Record<string, {
|
|
194
195
|
needsApproval?: boolean;
|
|
195
196
|
}> | null;
|
|
196
|
-
subAgentId: string;
|
|
197
197
|
selectedTools: string[] | null;
|
|
198
198
|
}>;
|
|
199
199
|
/**
|
|
@@ -202,11 +202,11 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
202
202
|
declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
203
203
|
data: ToolInsert;
|
|
204
204
|
}) => Promise<{
|
|
205
|
+
tenantId: string;
|
|
206
|
+
projectId: string;
|
|
205
207
|
id: string;
|
|
206
208
|
name: string;
|
|
207
209
|
description: string | null;
|
|
208
|
-
tenantId: string;
|
|
209
|
-
projectId: string;
|
|
210
210
|
createdAt: string;
|
|
211
211
|
updatedAt: string;
|
|
212
212
|
headers: Record<string, string> | null;
|
|
@@ -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
|
/**
|
|
@@ -40,13 +40,13 @@ declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params
|
|
|
40
40
|
algorithm: "sha256" | "sha512" | "sha384" | "sha1" | "md5";
|
|
41
41
|
encoding: "hex" | "base64";
|
|
42
42
|
signature: {
|
|
43
|
-
source: "query" | "
|
|
43
|
+
source: "query" | "body" | "header";
|
|
44
44
|
key: string;
|
|
45
45
|
prefix?: string | undefined;
|
|
46
46
|
regex?: string | undefined;
|
|
47
47
|
};
|
|
48
48
|
signedComponents: {
|
|
49
|
-
source: "literal" | "
|
|
49
|
+
source: "literal" | "body" | "header";
|
|
50
50
|
required: boolean;
|
|
51
51
|
key?: string | undefined;
|
|
52
52
|
value?: string | undefined;
|
|
@@ -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,
|