@inkeep/agents-core 0.55.3 → 0.56.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/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 +2 -2
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/client-exports.d.ts +2 -2
- package/dist/client-exports.js +2 -2
- package/dist/data-access/index.d.ts +3 -3
- package/dist/data-access/index.js +3 -3
- package/dist/data-access/manage/agents.d.ts +42 -42
- package/dist/data-access/manage/agents.js +25 -11
- package/dist/data-access/manage/artifactComponents.d.ts +6 -6
- package/dist/data-access/manage/contextConfigs.d.ts +8 -8
- package/dist/data-access/manage/dataComponents.d.ts +4 -4
- package/dist/data-access/manage/functionTools.d.ts +14 -14
- package/dist/data-access/manage/skills.d.ts +6 -6
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgentRelations.d.ts +22 -22
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgents.d.ts +18 -18
- package/dist/data-access/manage/tools.d.ts +18 -18
- package/dist/data-access/manage/triggerCleanup.d.ts +12 -0
- package/dist/data-access/manage/triggerCleanup.js +51 -0
- package/dist/data-access/manage/triggers.d.ts +12 -1
- package/dist/data-access/manage/triggers.js +8 -1
- package/dist/data-access/runtime/apiKeys.d.ts +12 -12
- package/dist/data-access/runtime/conversations.d.ts +16 -16
- package/dist/data-access/runtime/messages.d.ts +3 -3
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +3 -3
- package/dist/data-access/runtime/tasks.d.ts +4 -4
- package/dist/data-access/runtime/users.d.ts +5 -1
- package/dist/data-access/runtime/users.js +14 -1
- package/dist/db/manage/manage-schema.d.ts +485 -447
- package/dist/db/manage/manage-schema.js +2 -0
- package/dist/db/runtime/runtime-schema.d.ts +294 -294
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/utils/error.d.ts +51 -51
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +2 -2
- package/dist/validation/schemas.d.ts +1943 -1774
- package/dist/validation/schemas.js +18 -5
- package/drizzle/manage/0012_petite_weapon_omega.sql +2 -0
- package/drizzle/manage/meta/0012_snapshot.json +3697 -0
- package/drizzle/manage/meta/_journal.json +7 -0
- package/package.json +1 -1
- package/dist/auth/cleanup.d.ts +0 -12
- package/dist/auth/cleanup.js +0 -43
|
@@ -12,9 +12,9 @@ declare const getAgentRelationById: (db: AgentsManageDatabaseClient) => (params:
|
|
|
12
12
|
id: string;
|
|
13
13
|
createdAt: string;
|
|
14
14
|
updatedAt: string;
|
|
15
|
-
agentId: string;
|
|
16
|
-
projectId: string;
|
|
17
15
|
tenantId: string;
|
|
16
|
+
projectId: string;
|
|
17
|
+
agentId: string;
|
|
18
18
|
sourceSubAgentId: string;
|
|
19
19
|
targetSubAgentId: string | null;
|
|
20
20
|
relationType: string | null;
|
|
@@ -47,9 +47,9 @@ declare const getAgentRelations: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
47
47
|
id: string;
|
|
48
48
|
createdAt: string;
|
|
49
49
|
updatedAt: string;
|
|
50
|
-
agentId: string;
|
|
51
|
-
projectId: string;
|
|
52
50
|
tenantId: string;
|
|
51
|
+
projectId: string;
|
|
52
|
+
agentId: string;
|
|
53
53
|
sourceSubAgentId: string;
|
|
54
54
|
targetSubAgentId: string | null;
|
|
55
55
|
relationType: string | null;
|
|
@@ -60,9 +60,9 @@ declare const getAgentRelationsByAgent: (db: AgentsManageDatabaseClient) => (par
|
|
|
60
60
|
id: string;
|
|
61
61
|
createdAt: string;
|
|
62
62
|
updatedAt: string;
|
|
63
|
-
agentId: string;
|
|
64
|
-
projectId: string;
|
|
65
63
|
tenantId: string;
|
|
64
|
+
projectId: string;
|
|
65
|
+
agentId: string;
|
|
66
66
|
sourceSubAgentId: string;
|
|
67
67
|
targetSubAgentId: string | null;
|
|
68
68
|
relationType: string | null;
|
|
@@ -129,9 +129,9 @@ declare const createSubAgentRelation: (db: AgentsManageDatabaseClient) => (param
|
|
|
129
129
|
id: string;
|
|
130
130
|
createdAt: string;
|
|
131
131
|
updatedAt: string;
|
|
132
|
-
agentId: string;
|
|
133
|
-
projectId: string;
|
|
134
132
|
tenantId: string;
|
|
133
|
+
projectId: string;
|
|
134
|
+
agentId: string;
|
|
135
135
|
sourceSubAgentId: string;
|
|
136
136
|
targetSubAgentId: string | null;
|
|
137
137
|
relationType: string | null;
|
|
@@ -148,9 +148,9 @@ declare const getAgentRelationByParams: (db: AgentsManageDatabaseClient) => (par
|
|
|
148
148
|
id: string;
|
|
149
149
|
createdAt: string;
|
|
150
150
|
updatedAt: string;
|
|
151
|
-
agentId: string;
|
|
152
|
-
projectId: string;
|
|
153
151
|
tenantId: string;
|
|
152
|
+
projectId: string;
|
|
153
|
+
agentId: string;
|
|
154
154
|
sourceSubAgentId: string;
|
|
155
155
|
targetSubAgentId: string | null;
|
|
156
156
|
relationType: string | null;
|
|
@@ -162,9 +162,9 @@ declare const upsertSubAgentRelation: (db: AgentsManageDatabaseClient) => (param
|
|
|
162
162
|
id: string;
|
|
163
163
|
createdAt: string;
|
|
164
164
|
updatedAt: string;
|
|
165
|
-
agentId: string;
|
|
166
|
-
projectId: string;
|
|
167
165
|
tenantId: string;
|
|
166
|
+
projectId: string;
|
|
167
|
+
agentId: string;
|
|
168
168
|
sourceSubAgentId: string;
|
|
169
169
|
targetSubAgentId: string | null;
|
|
170
170
|
relationType: string | null;
|
|
@@ -207,15 +207,15 @@ declare const createAgentToolRelation: (db: AgentsManageDatabaseClient) => (para
|
|
|
207
207
|
id: string;
|
|
208
208
|
createdAt: string;
|
|
209
209
|
updatedAt: string;
|
|
210
|
-
agentId: string;
|
|
211
|
-
projectId: string;
|
|
212
210
|
tenantId: string;
|
|
213
|
-
|
|
211
|
+
projectId: string;
|
|
212
|
+
agentId: string;
|
|
213
|
+
toolId: string;
|
|
214
|
+
headers: Record<string, string> | null;
|
|
214
215
|
toolPolicies: Record<string, {
|
|
215
216
|
needsApproval?: boolean;
|
|
216
217
|
}> | null;
|
|
217
|
-
|
|
218
|
-
toolId: string;
|
|
218
|
+
subAgentId: string;
|
|
219
219
|
selectedTools: string[] | null;
|
|
220
220
|
}>;
|
|
221
221
|
declare const updateAgentToolRelation: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -251,15 +251,15 @@ declare const getAgentToolRelationById: (db: AgentsManageDatabaseClient) => (par
|
|
|
251
251
|
id: string;
|
|
252
252
|
createdAt: string;
|
|
253
253
|
updatedAt: string;
|
|
254
|
-
agentId: string;
|
|
255
|
-
projectId: string;
|
|
256
254
|
tenantId: string;
|
|
257
|
-
|
|
255
|
+
projectId: string;
|
|
256
|
+
agentId: string;
|
|
257
|
+
toolId: string;
|
|
258
|
+
headers: Record<string, string> | null;
|
|
258
259
|
toolPolicies: Record<string, {
|
|
259
260
|
needsApproval?: boolean;
|
|
260
261
|
}> | null;
|
|
261
|
-
|
|
262
|
-
toolId: string;
|
|
262
|
+
subAgentId: string;
|
|
263
263
|
selectedTools: string[] | null;
|
|
264
264
|
} | undefined>;
|
|
265
265
|
declare const getAgentToolRelationByAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -12,11 +12,11 @@ declare const getSubAgentTeamAgentRelationById: (db: AgentsManageDatabaseClient)
|
|
|
12
12
|
id: string;
|
|
13
13
|
createdAt: string;
|
|
14
14
|
updatedAt: string;
|
|
15
|
-
agentId: string;
|
|
16
|
-
projectId: string;
|
|
17
15
|
tenantId: string;
|
|
18
|
-
|
|
16
|
+
projectId: string;
|
|
17
|
+
agentId: string;
|
|
19
18
|
headers: Record<string, string> | null;
|
|
19
|
+
subAgentId: string;
|
|
20
20
|
targetAgentId: string;
|
|
21
21
|
} | undefined>;
|
|
22
22
|
declare const listSubAgentTeamAgentRelations: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -47,11 +47,11 @@ declare const getSubAgentTeamAgentRelations: (db: AgentsManageDatabaseClient) =>
|
|
|
47
47
|
id: string;
|
|
48
48
|
createdAt: string;
|
|
49
49
|
updatedAt: string;
|
|
50
|
-
agentId: string;
|
|
51
|
-
projectId: string;
|
|
52
50
|
tenantId: string;
|
|
53
|
-
|
|
51
|
+
projectId: string;
|
|
52
|
+
agentId: string;
|
|
54
53
|
headers: Record<string, string> | null;
|
|
54
|
+
subAgentId: string;
|
|
55
55
|
targetAgentId: string;
|
|
56
56
|
}[]>;
|
|
57
57
|
declare const getSubAgentTeamAgentRelationsByAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -60,11 +60,11 @@ declare const getSubAgentTeamAgentRelationsByAgent: (db: AgentsManageDatabaseCli
|
|
|
60
60
|
id: string;
|
|
61
61
|
createdAt: string;
|
|
62
62
|
updatedAt: string;
|
|
63
|
-
agentId: string;
|
|
64
|
-
projectId: string;
|
|
65
63
|
tenantId: string;
|
|
66
|
-
|
|
64
|
+
projectId: string;
|
|
65
|
+
agentId: string;
|
|
67
66
|
headers: Record<string, string> | null;
|
|
67
|
+
subAgentId: string;
|
|
68
68
|
targetAgentId: string;
|
|
69
69
|
}[]>;
|
|
70
70
|
declare const getSubAgentTeamAgentRelationsByTeamAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -213,11 +213,11 @@ declare const createSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient)
|
|
|
213
213
|
id: string;
|
|
214
214
|
createdAt: string;
|
|
215
215
|
updatedAt: string;
|
|
216
|
-
agentId: string;
|
|
217
|
-
projectId: string;
|
|
218
216
|
tenantId: string;
|
|
219
|
-
|
|
217
|
+
projectId: string;
|
|
218
|
+
agentId: string;
|
|
220
219
|
headers: Record<string, string> | null;
|
|
220
|
+
subAgentId: string;
|
|
221
221
|
targetAgentId: string;
|
|
222
222
|
}>;
|
|
223
223
|
/**
|
|
@@ -230,11 +230,11 @@ declare const getSubAgentTeamAgentRelationByParams: (db: AgentsManageDatabaseCli
|
|
|
230
230
|
id: string;
|
|
231
231
|
createdAt: string;
|
|
232
232
|
updatedAt: string;
|
|
233
|
-
agentId: string;
|
|
234
|
-
projectId: string;
|
|
235
233
|
tenantId: string;
|
|
236
|
-
|
|
234
|
+
projectId: string;
|
|
235
|
+
agentId: string;
|
|
237
236
|
headers: Record<string, string> | null;
|
|
237
|
+
subAgentId: string;
|
|
238
238
|
targetAgentId: string;
|
|
239
239
|
} | undefined>;
|
|
240
240
|
/**
|
|
@@ -251,11 +251,11 @@ declare const upsertSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient)
|
|
|
251
251
|
id: string;
|
|
252
252
|
createdAt: string;
|
|
253
253
|
updatedAt: string;
|
|
254
|
-
agentId: string;
|
|
255
|
-
projectId: string;
|
|
256
254
|
tenantId: string;
|
|
257
|
-
|
|
255
|
+
projectId: string;
|
|
256
|
+
agentId: string;
|
|
258
257
|
headers: Record<string, string> | null;
|
|
258
|
+
subAgentId: string;
|
|
259
259
|
targetAgentId: string;
|
|
260
260
|
}>;
|
|
261
261
|
declare const updateSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -12,11 +12,6 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
12
12
|
id: string;
|
|
13
13
|
name: string;
|
|
14
14
|
description: string | null;
|
|
15
|
-
createdAt: string;
|
|
16
|
-
updatedAt: string;
|
|
17
|
-
agentId: string;
|
|
18
|
-
projectId: string;
|
|
19
|
-
tenantId: string;
|
|
20
15
|
models: {
|
|
21
16
|
base?: {
|
|
22
17
|
model?: string | undefined;
|
|
@@ -31,10 +26,15 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
31
26
|
providerOptions?: Record<string, any> | undefined;
|
|
32
27
|
} | undefined;
|
|
33
28
|
} | null;
|
|
34
|
-
prompt: string | null;
|
|
35
29
|
stopWhen: {
|
|
36
30
|
stepCountIs?: number | undefined;
|
|
37
31
|
} | null;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
updatedAt: string;
|
|
34
|
+
tenantId: string;
|
|
35
|
+
projectId: string;
|
|
36
|
+
prompt: string | null;
|
|
37
|
+
agentId: string;
|
|
38
38
|
conversationHistoryConfig: ConversationHistoryConfig | null;
|
|
39
39
|
} | undefined>;
|
|
40
40
|
declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -43,11 +43,6 @@ declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
43
43
|
id: string;
|
|
44
44
|
name: string;
|
|
45
45
|
description: string | null;
|
|
46
|
-
createdAt: string;
|
|
47
|
-
updatedAt: string;
|
|
48
|
-
agentId: string;
|
|
49
|
-
projectId: string;
|
|
50
|
-
tenantId: string;
|
|
51
46
|
models: {
|
|
52
47
|
base?: {
|
|
53
48
|
model?: string | undefined;
|
|
@@ -62,10 +57,15 @@ declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
62
57
|
providerOptions?: Record<string, any> | undefined;
|
|
63
58
|
} | undefined;
|
|
64
59
|
} | null;
|
|
65
|
-
prompt: string | null;
|
|
66
60
|
stopWhen: {
|
|
67
61
|
stepCountIs?: number | undefined;
|
|
68
62
|
} | null;
|
|
63
|
+
createdAt: string;
|
|
64
|
+
updatedAt: string;
|
|
65
|
+
tenantId: string;
|
|
66
|
+
projectId: string;
|
|
67
|
+
prompt: string | null;
|
|
68
|
+
agentId: string;
|
|
69
69
|
conversationHistoryConfig: ConversationHistoryConfig | null;
|
|
70
70
|
}[]>;
|
|
71
71
|
declare const listSubAgentsPaginated: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -112,11 +112,6 @@ declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAg
|
|
|
112
112
|
id: string;
|
|
113
113
|
name: string;
|
|
114
114
|
description: string | null;
|
|
115
|
-
createdAt: string;
|
|
116
|
-
updatedAt: string;
|
|
117
|
-
agentId: string;
|
|
118
|
-
projectId: string;
|
|
119
|
-
tenantId: string;
|
|
120
115
|
models: {
|
|
121
116
|
base?: {
|
|
122
117
|
model?: string | undefined;
|
|
@@ -131,10 +126,15 @@ declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAg
|
|
|
131
126
|
providerOptions?: Record<string, any> | undefined;
|
|
132
127
|
} | undefined;
|
|
133
128
|
} | null;
|
|
134
|
-
prompt: string | null;
|
|
135
129
|
stopWhen: {
|
|
136
130
|
stepCountIs?: number | undefined;
|
|
137
131
|
} | null;
|
|
132
|
+
createdAt: string;
|
|
133
|
+
updatedAt: string;
|
|
134
|
+
tenantId: string;
|
|
135
|
+
projectId: string;
|
|
136
|
+
prompt: string | null;
|
|
137
|
+
agentId: string;
|
|
138
138
|
conversationHistoryConfig: ConversationHistoryConfig | null;
|
|
139
139
|
}>;
|
|
140
140
|
declare const updateSubAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -24,8 +24,8 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
24
24
|
description: string | null;
|
|
25
25
|
createdAt: string;
|
|
26
26
|
updatedAt: string;
|
|
27
|
-
projectId: string;
|
|
28
27
|
tenantId: string;
|
|
28
|
+
projectId: string;
|
|
29
29
|
headers: Record<string, string> | null;
|
|
30
30
|
config: {
|
|
31
31
|
type: "mcp";
|
|
@@ -82,8 +82,8 @@ declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInser
|
|
|
82
82
|
description: string | null;
|
|
83
83
|
createdAt: string;
|
|
84
84
|
updatedAt: string;
|
|
85
|
-
projectId: string;
|
|
86
85
|
tenantId: string;
|
|
86
|
+
projectId: string;
|
|
87
87
|
headers: Record<string, string> | null;
|
|
88
88
|
config: {
|
|
89
89
|
type: "mcp";
|
|
@@ -137,15 +137,15 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
137
137
|
id: string;
|
|
138
138
|
createdAt: string;
|
|
139
139
|
updatedAt: string;
|
|
140
|
-
agentId: string;
|
|
141
|
-
projectId: string;
|
|
142
140
|
tenantId: string;
|
|
143
|
-
|
|
141
|
+
projectId: string;
|
|
142
|
+
agentId: string;
|
|
143
|
+
toolId: string;
|
|
144
|
+
headers: Record<string, string> | null;
|
|
144
145
|
toolPolicies: Record<string, {
|
|
145
146
|
needsApproval?: boolean;
|
|
146
147
|
}> | null;
|
|
147
|
-
|
|
148
|
-
toolId: string;
|
|
148
|
+
subAgentId: string;
|
|
149
149
|
selectedTools: string[] | null;
|
|
150
150
|
}>;
|
|
151
151
|
declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -156,15 +156,15 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
|
|
|
156
156
|
id: string;
|
|
157
157
|
createdAt: string;
|
|
158
158
|
updatedAt: string;
|
|
159
|
-
agentId: string;
|
|
160
|
-
projectId: string;
|
|
161
159
|
tenantId: string;
|
|
162
|
-
|
|
160
|
+
projectId: string;
|
|
161
|
+
agentId: string;
|
|
162
|
+
toolId: string;
|
|
163
|
+
headers: Record<string, string> | null;
|
|
163
164
|
toolPolicies: Record<string, {
|
|
164
165
|
needsApproval?: boolean;
|
|
165
166
|
}> | null;
|
|
166
|
-
|
|
167
|
-
toolId: string;
|
|
167
|
+
subAgentId: string;
|
|
168
168
|
selectedTools: string[] | null;
|
|
169
169
|
}>;
|
|
170
170
|
/**
|
|
@@ -184,15 +184,15 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
184
184
|
id: string;
|
|
185
185
|
createdAt: string;
|
|
186
186
|
updatedAt: string;
|
|
187
|
-
agentId: string;
|
|
188
|
-
projectId: string;
|
|
189
187
|
tenantId: string;
|
|
190
|
-
|
|
188
|
+
projectId: string;
|
|
189
|
+
agentId: string;
|
|
190
|
+
toolId: string;
|
|
191
|
+
headers: Record<string, string> | null;
|
|
191
192
|
toolPolicies: Record<string, {
|
|
192
193
|
needsApproval?: boolean;
|
|
193
194
|
}> | null;
|
|
194
|
-
|
|
195
|
-
toolId: string;
|
|
195
|
+
subAgentId: string;
|
|
196
196
|
selectedTools: string[] | null;
|
|
197
197
|
}>;
|
|
198
198
|
/**
|
|
@@ -206,8 +206,8 @@ declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
206
206
|
description: string | null;
|
|
207
207
|
createdAt: string;
|
|
208
208
|
updatedAt: string;
|
|
209
|
-
projectId: string;
|
|
210
209
|
tenantId: string;
|
|
210
|
+
projectId: string;
|
|
211
211
|
headers: Record<string, string> | null;
|
|
212
212
|
config: {
|
|
213
213
|
type: "mcp";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
2
|
+
import { Pool } from "pg";
|
|
3
|
+
|
|
4
|
+
//#region src/data-access/manage/triggerCleanup.d.ts
|
|
5
|
+
declare function cleanupUserTriggers(params: {
|
|
6
|
+
tenantId: string;
|
|
7
|
+
userId: string;
|
|
8
|
+
runDb: AgentsRunDatabaseClient;
|
|
9
|
+
manageDbPool: Pool;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { cleanupUserTriggers };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { manage_schema_exports } from "../../db/manage/manage-schema.js";
|
|
2
|
+
import { getLogger } from "../../utils/logger.js";
|
|
3
|
+
import { resolveProjectMainRefs } from "../../dolt/ref-helpers.js";
|
|
4
|
+
import { listProjectsMetadata } from "../runtime/projects.js";
|
|
5
|
+
import { deleteScheduledTriggersByRunAsUserId } from "./scheduledTriggers.js";
|
|
6
|
+
import { deleteTriggersByRunAsUserId } from "./triggers.js";
|
|
7
|
+
import { withRef } from "../../dolt/ref-scope.js";
|
|
8
|
+
import { drizzle } from "drizzle-orm/node-postgres";
|
|
9
|
+
|
|
10
|
+
//#region src/data-access/manage/triggerCleanup.ts
|
|
11
|
+
const logger = getLogger("auth-cleanup");
|
|
12
|
+
async function cleanupUserTriggers(params) {
|
|
13
|
+
const { tenantId, userId, runDb, manageDbPool } = params;
|
|
14
|
+
const projects = await listProjectsMetadata(runDb)({ tenantId });
|
|
15
|
+
if (projects.length === 0) return;
|
|
16
|
+
const connection = await manageDbPool.connect();
|
|
17
|
+
let resolvedRefs;
|
|
18
|
+
try {
|
|
19
|
+
resolvedRefs = await resolveProjectMainRefs(drizzle(connection, { schema: manage_schema_exports }))(tenantId, projects.map((p) => p.id));
|
|
20
|
+
} finally {
|
|
21
|
+
connection.release();
|
|
22
|
+
}
|
|
23
|
+
const results = await Promise.allSettled(resolvedRefs.map(({ projectId, ref }) => withRef(manageDbPool, ref, async (db) => {
|
|
24
|
+
await deleteScheduledTriggersByRunAsUserId(db)({
|
|
25
|
+
tenantId,
|
|
26
|
+
projectId,
|
|
27
|
+
runAsUserId: userId
|
|
28
|
+
});
|
|
29
|
+
await deleteTriggersByRunAsUserId(db)({
|
|
30
|
+
tenantId,
|
|
31
|
+
projectId,
|
|
32
|
+
runAsUserId: userId
|
|
33
|
+
});
|
|
34
|
+
}, {
|
|
35
|
+
commit: true,
|
|
36
|
+
commitMessage: `Remove triggers for departing user ${userId}`
|
|
37
|
+
})));
|
|
38
|
+
for (let i = 0; i < results.length; i++) {
|
|
39
|
+
const result = results[i];
|
|
40
|
+
const { projectId } = resolvedRefs[i];
|
|
41
|
+
if (result.status === "rejected") logger.error({
|
|
42
|
+
tenantId,
|
|
43
|
+
projectId,
|
|
44
|
+
userId,
|
|
45
|
+
error: result.reason
|
|
46
|
+
}, "Failed to clean up scheduled triggers for project");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { cleanupUserTriggers };
|
|
@@ -62,6 +62,8 @@ declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params
|
|
|
62
62
|
normalizeUnicode: boolean;
|
|
63
63
|
} | undefined;
|
|
64
64
|
} | null;
|
|
65
|
+
runAsUserId: string | null;
|
|
66
|
+
createdBy: string | null;
|
|
65
67
|
name: string;
|
|
66
68
|
description: string | null;
|
|
67
69
|
agentId: string;
|
|
@@ -95,6 +97,15 @@ declare const deleteTrigger: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
95
97
|
scopes: AgentScopeConfig;
|
|
96
98
|
triggerId: string;
|
|
97
99
|
}) => Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Delete all webhook triggers for a given runAsUserId within a tenant+project scope.
|
|
102
|
+
* Operates across all agents in the project (not agent-scoped).
|
|
103
|
+
*/
|
|
104
|
+
declare const deleteTriggersByRunAsUserId: (db: AgentsManageDatabaseClient) => (params: {
|
|
105
|
+
tenantId: string;
|
|
106
|
+
projectId: string;
|
|
107
|
+
runAsUserId: string;
|
|
108
|
+
}) => Promise<void>;
|
|
98
109
|
/**
|
|
99
110
|
* Upsert a trigger (create or update based on existence)
|
|
100
111
|
*/
|
|
@@ -103,4 +114,4 @@ declare const upsertTrigger: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
103
114
|
data: TriggerInsert;
|
|
104
115
|
}) => Promise<TriggerSelect>;
|
|
105
116
|
//#endregion
|
|
106
|
-
export { createTrigger, deleteTrigger, getTriggerById, listTriggers, listTriggersPaginated, updateTrigger, upsertTrigger };
|
|
117
|
+
export { createTrigger, deleteTrigger, deleteTriggersByRunAsUserId, getTriggerById, listTriggers, listTriggersPaginated, updateTrigger, upsertTrigger };
|
|
@@ -58,6 +58,13 @@ const deleteTrigger = (db) => async (params) => {
|
|
|
58
58
|
await db.delete(triggers).where(and(eq(triggers.tenantId, params.scopes.tenantId), eq(triggers.projectId, params.scopes.projectId), eq(triggers.agentId, params.scopes.agentId), eq(triggers.id, params.triggerId)));
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
|
+
* Delete all webhook triggers for a given runAsUserId within a tenant+project scope.
|
|
62
|
+
* Operates across all agents in the project (not agent-scoped).
|
|
63
|
+
*/
|
|
64
|
+
const deleteTriggersByRunAsUserId = (db) => async (params) => {
|
|
65
|
+
await db.delete(triggers).where(and(eq(triggers.tenantId, params.tenantId), eq(triggers.projectId, params.projectId), eq(triggers.runAsUserId, params.runAsUserId)));
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
61
68
|
* Upsert a trigger (create or update based on existence)
|
|
62
69
|
*/
|
|
63
70
|
const upsertTrigger = (db) => async (params) => {
|
|
@@ -78,4 +85,4 @@ const upsertTrigger = (db) => async (params) => {
|
|
|
78
85
|
};
|
|
79
86
|
|
|
80
87
|
//#endregion
|
|
81
|
-
export { createTrigger, deleteTrigger, getTriggerById, listTriggers, listTriggersPaginated, updateTrigger, upsertTrigger };
|
|
88
|
+
export { createTrigger, deleteTrigger, deleteTriggersByRunAsUserId, getTriggerById, listTriggers, listTriggersPaginated, updateTrigger, upsertTrigger };
|
|
@@ -12,28 +12,28 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
12
12
|
name: string | null;
|
|
13
13
|
createdAt: string;
|
|
14
14
|
updatedAt: string;
|
|
15
|
-
agentId: string;
|
|
16
|
-
projectId: string;
|
|
17
15
|
tenantId: string;
|
|
16
|
+
projectId: string;
|
|
17
|
+
agentId: string;
|
|
18
|
+
expiresAt: string | null;
|
|
18
19
|
publicId: string;
|
|
19
20
|
keyHash: string;
|
|
20
21
|
keyPrefix: string;
|
|
21
22
|
lastUsedAt: string | null;
|
|
22
|
-
expiresAt: string | null;
|
|
23
23
|
} | undefined>;
|
|
24
24
|
declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
|
|
25
25
|
id: string;
|
|
26
26
|
name: string | null;
|
|
27
27
|
createdAt: string;
|
|
28
28
|
updatedAt: string;
|
|
29
|
-
agentId: string;
|
|
30
|
-
projectId: string;
|
|
31
29
|
tenantId: string;
|
|
30
|
+
projectId: string;
|
|
31
|
+
agentId: string;
|
|
32
|
+
expiresAt: string | null;
|
|
32
33
|
publicId: string;
|
|
33
34
|
keyHash: string;
|
|
34
35
|
keyPrefix: string;
|
|
35
36
|
lastUsedAt: string | null;
|
|
36
|
-
expiresAt: string | null;
|
|
37
37
|
} | undefined>;
|
|
38
38
|
declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
39
39
|
scopes: ProjectScopeConfig;
|
|
@@ -43,14 +43,14 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
43
43
|
name: string | null;
|
|
44
44
|
createdAt: string;
|
|
45
45
|
updatedAt: string;
|
|
46
|
-
agentId: string;
|
|
47
|
-
projectId: string;
|
|
48
46
|
tenantId: string;
|
|
47
|
+
projectId: string;
|
|
48
|
+
agentId: string;
|
|
49
|
+
expiresAt: string | null;
|
|
49
50
|
publicId: string;
|
|
50
51
|
keyHash: string;
|
|
51
52
|
keyPrefix: string;
|
|
52
53
|
lastUsedAt: string | null;
|
|
53
|
-
expiresAt: string | null;
|
|
54
54
|
}[]>;
|
|
55
55
|
declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
56
56
|
scopes: ProjectScopeConfig;
|
|
@@ -70,14 +70,14 @@ declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInse
|
|
|
70
70
|
name: string | null;
|
|
71
71
|
createdAt: string;
|
|
72
72
|
updatedAt: string;
|
|
73
|
-
agentId: string;
|
|
74
|
-
projectId: string;
|
|
75
73
|
tenantId: string;
|
|
74
|
+
projectId: string;
|
|
75
|
+
agentId: string;
|
|
76
|
+
expiresAt: string | null;
|
|
76
77
|
publicId: string;
|
|
77
78
|
keyHash: string;
|
|
78
79
|
keyPrefix: string;
|
|
79
80
|
lastUsedAt: string | null;
|
|
80
|
-
expiresAt: string | null;
|
|
81
81
|
}>;
|
|
82
82
|
declare const updateApiKey: (db: AgentsRunDatabaseClient) => (params: {
|
|
83
83
|
scopes: ProjectScopeConfig;
|
|
@@ -17,20 +17,20 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
17
17
|
}>;
|
|
18
18
|
declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
|
|
19
19
|
id: string;
|
|
20
|
+
title: string | null;
|
|
20
21
|
createdAt: string;
|
|
21
22
|
updatedAt: string;
|
|
22
|
-
agentId: string | null;
|
|
23
|
-
projectId: string;
|
|
24
23
|
tenantId: string;
|
|
25
|
-
|
|
24
|
+
projectId: string;
|
|
26
25
|
metadata: ConversationMetadata | null;
|
|
26
|
+
agentId: string | null;
|
|
27
27
|
userId: string | null;
|
|
28
|
+
activeSubAgentId: string;
|
|
28
29
|
ref: {
|
|
29
30
|
type: "commit" | "tag" | "branch";
|
|
30
31
|
name: string;
|
|
31
32
|
hash: string;
|
|
32
33
|
} | null;
|
|
33
|
-
activeSubAgentId: string;
|
|
34
34
|
lastContextResolution: string | null;
|
|
35
35
|
}>;
|
|
36
36
|
declare const updateConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -86,20 +86,20 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
86
86
|
conversationId: string;
|
|
87
87
|
}) => Promise<{
|
|
88
88
|
id: string;
|
|
89
|
+
title: string | null;
|
|
89
90
|
createdAt: string;
|
|
90
91
|
updatedAt: string;
|
|
91
|
-
agentId: string | null;
|
|
92
|
-
projectId: string;
|
|
93
92
|
tenantId: string;
|
|
94
|
-
|
|
93
|
+
projectId: string;
|
|
95
94
|
metadata: ConversationMetadata | null;
|
|
95
|
+
agentId: string | null;
|
|
96
96
|
userId: string | null;
|
|
97
|
+
activeSubAgentId: string;
|
|
97
98
|
ref: {
|
|
98
99
|
type: "commit" | "tag" | "branch";
|
|
99
100
|
name: string;
|
|
100
101
|
hash: string;
|
|
101
102
|
} | null;
|
|
102
|
-
activeSubAgentId: string;
|
|
103
103
|
lastContextResolution: string | null;
|
|
104
104
|
} | undefined>;
|
|
105
105
|
declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input: ConversationInsert) => Promise<{
|
|
@@ -122,20 +122,20 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
122
122
|
contextConfigId?: string | undefined;
|
|
123
123
|
} | {
|
|
124
124
|
id: string;
|
|
125
|
+
title: string | null;
|
|
125
126
|
createdAt: string;
|
|
126
127
|
updatedAt: string;
|
|
127
|
-
agentId: string | null;
|
|
128
|
-
projectId: string;
|
|
129
128
|
tenantId: string;
|
|
130
|
-
|
|
129
|
+
projectId: string;
|
|
131
130
|
metadata: ConversationMetadata | null;
|
|
131
|
+
agentId: string | null;
|
|
132
132
|
userId: string | null;
|
|
133
|
+
activeSubAgentId: string;
|
|
133
134
|
ref: {
|
|
134
135
|
type: "commit" | "tag" | "branch";
|
|
135
136
|
name: string;
|
|
136
137
|
hash: string;
|
|
137
138
|
} | null;
|
|
138
|
-
activeSubAgentId: string;
|
|
139
139
|
lastContextResolution: string | null;
|
|
140
140
|
}>;
|
|
141
141
|
/**
|
|
@@ -154,20 +154,20 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
154
154
|
conversationId: string;
|
|
155
155
|
}) => Promise<{
|
|
156
156
|
id: string;
|
|
157
|
+
title: string | null;
|
|
157
158
|
createdAt: string;
|
|
158
159
|
updatedAt: string;
|
|
159
|
-
agentId: string | null;
|
|
160
|
-
projectId: string;
|
|
161
160
|
tenantId: string;
|
|
162
|
-
|
|
161
|
+
projectId: string;
|
|
163
162
|
metadata: ConversationMetadata | null;
|
|
163
|
+
agentId: string | null;
|
|
164
164
|
userId: string | null;
|
|
165
|
+
activeSubAgentId: string;
|
|
165
166
|
ref: {
|
|
166
167
|
type: "commit" | "tag" | "branch";
|
|
167
168
|
name: string;
|
|
168
169
|
hash: string;
|
|
169
170
|
} | null;
|
|
170
|
-
activeSubAgentId: string;
|
|
171
171
|
lastContextResolution: string | null;
|
|
172
172
|
} | undefined>;
|
|
173
173
|
/**
|
|
@@ -13,8 +13,8 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
13
13
|
id: string;
|
|
14
14
|
createdAt: string;
|
|
15
15
|
updatedAt: string;
|
|
16
|
-
projectId: string;
|
|
17
16
|
tenantId: string;
|
|
17
|
+
projectId: string;
|
|
18
18
|
metadata: MessageMetadata | null;
|
|
19
19
|
content: MessageContent;
|
|
20
20
|
conversationId: string;
|
|
@@ -144,8 +144,8 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: MessageIn
|
|
|
144
144
|
id: string;
|
|
145
145
|
createdAt: string;
|
|
146
146
|
updatedAt: string;
|
|
147
|
-
projectId: string;
|
|
148
147
|
tenantId: string;
|
|
148
|
+
projectId: string;
|
|
149
149
|
metadata: MessageMetadata | null;
|
|
150
150
|
content: MessageContent;
|
|
151
151
|
conversationId: string;
|
|
@@ -197,8 +197,8 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
197
197
|
id: string;
|
|
198
198
|
createdAt: string;
|
|
199
199
|
updatedAt: string;
|
|
200
|
-
projectId: string;
|
|
201
200
|
tenantId: string;
|
|
201
|
+
projectId: string;
|
|
202
202
|
metadata: MessageMetadata | null;
|
|
203
203
|
content: MessageContent;
|
|
204
204
|
conversationId: string;
|