@inkeep/agents-core 0.0.0-dev-20260303063511 → 0.0.0-dev-20260303160903

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.
Files changed (47) hide show
  1. package/dist/auth/auth-schema.d.ts +107 -107
  2. package/dist/auth/auth-validation-schemas.d.ts +135 -135
  3. package/dist/auth/auth.d.ts +9 -9
  4. package/dist/auth/auth.js +2 -2
  5. package/dist/auth/permissions.d.ts +9 -9
  6. package/dist/client-exports.d.ts +5 -4
  7. package/dist/client-exports.js +2 -2
  8. package/dist/data-access/index.d.ts +3 -3
  9. package/dist/data-access/index.js +3 -3
  10. package/dist/data-access/manage/agents.d.ts +42 -42
  11. package/dist/data-access/manage/agents.js +25 -11
  12. package/dist/data-access/manage/artifactComponents.d.ts +10 -10
  13. package/dist/data-access/manage/contextConfigs.d.ts +12 -12
  14. package/dist/data-access/manage/dataComponents.d.ts +4 -4
  15. package/dist/data-access/manage/functionTools.d.ts +16 -16
  16. package/dist/data-access/manage/skills.d.ts +13 -13
  17. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +18 -18
  18. package/dist/data-access/manage/subAgentRelations.d.ts +26 -26
  19. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
  20. package/dist/data-access/manage/subAgents.d.ts +18 -18
  21. package/dist/data-access/manage/tools.d.ts +21 -21
  22. package/dist/data-access/manage/triggerCleanup.d.ts +12 -0
  23. package/dist/data-access/manage/triggerCleanup.js +51 -0
  24. package/dist/data-access/manage/triggers.d.ts +14 -3
  25. package/dist/data-access/manage/triggers.js +8 -1
  26. package/dist/data-access/runtime/apiKeys.d.ts +12 -12
  27. package/dist/data-access/runtime/conversations.d.ts +24 -24
  28. package/dist/data-access/runtime/messages.d.ts +18 -18
  29. package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +3 -3
  30. package/dist/data-access/runtime/tasks.d.ts +6 -6
  31. package/dist/data-access/runtime/users.d.ts +5 -1
  32. package/dist/data-access/runtime/users.js +14 -1
  33. package/dist/db/manage/manage-schema.d.ts +489 -451
  34. package/dist/db/manage/manage-schema.js +2 -0
  35. package/dist/db/runtime/runtime-schema.d.ts +294 -294
  36. package/dist/index.d.ts +4 -4
  37. package/dist/index.js +4 -4
  38. package/dist/validation/index.d.ts +2 -2
  39. package/dist/validation/index.js +2 -2
  40. package/dist/validation/schemas.d.ts +1897 -1728
  41. package/dist/validation/schemas.js +18 -5
  42. package/drizzle/manage/0012_petite_weapon_omega.sql +2 -0
  43. package/drizzle/manage/meta/0012_snapshot.json +3697 -0
  44. package/drizzle/manage/meta/_journal.json +7 -0
  45. package/package.json +1 -1
  46. package/dist/auth/cleanup.d.ts +0 -12
  47. package/dist/auth/cleanup.js +0 -43
@@ -9,13 +9,13 @@ declare const getSubAgentExternalAgentRelationById: (db: AgentsManageDatabaseCli
9
9
  scopes: SubAgentScopeConfig;
10
10
  relationId: string;
11
11
  }) => Promise<{
12
- id: string;
13
- createdAt: string;
14
- updatedAt: string;
15
12
  tenantId: string;
16
13
  projectId: string;
17
14
  agentId: string;
18
15
  subAgentId: string;
16
+ id: string;
17
+ createdAt: string;
18
+ updatedAt: string;
19
19
  headers: Record<string, string> | null;
20
20
  externalAgentId: string;
21
21
  } | undefined>;
@@ -44,26 +44,26 @@ declare const listSubAgentExternalAgentRelations: (db: AgentsManageDatabaseClien
44
44
  declare const getSubAgentExternalAgentRelations: (db: AgentsManageDatabaseClient) => (params: {
45
45
  scopes: SubAgentScopeConfig;
46
46
  }) => Promise<{
47
- id: string;
48
- createdAt: string;
49
- updatedAt: string;
50
47
  tenantId: string;
51
48
  projectId: string;
52
49
  agentId: string;
53
50
  subAgentId: string;
51
+ id: string;
52
+ createdAt: string;
53
+ updatedAt: string;
54
54
  headers: Record<string, string> | null;
55
55
  externalAgentId: string;
56
56
  }[]>;
57
57
  declare const getSubAgentExternalAgentRelationsByAgent: (db: AgentsManageDatabaseClient) => (params: {
58
58
  scopes: AgentScopeConfig;
59
59
  }) => Promise<{
60
- id: string;
61
- createdAt: string;
62
- updatedAt: string;
63
60
  tenantId: string;
64
61
  projectId: string;
65
62
  agentId: string;
66
63
  subAgentId: string;
64
+ id: string;
65
+ createdAt: string;
66
+ updatedAt: string;
67
67
  headers: Record<string, string> | null;
68
68
  externalAgentId: string;
69
69
  }[]>;
@@ -180,13 +180,13 @@ declare const createSubAgentExternalAgentRelation: (db: AgentsManageDatabaseClie
180
180
  headers?: Record<string, string> | null;
181
181
  };
182
182
  }) => Promise<{
183
- id: string;
184
- createdAt: string;
185
- updatedAt: string;
186
183
  tenantId: string;
187
184
  projectId: string;
188
185
  agentId: string;
189
186
  subAgentId: string;
187
+ id: string;
188
+ createdAt: string;
189
+ updatedAt: string;
190
190
  headers: Record<string, string> | null;
191
191
  externalAgentId: string;
192
192
  }>;
@@ -197,13 +197,13 @@ declare const getSubAgentExternalAgentRelationByParams: (db: AgentsManageDatabas
197
197
  scopes: SubAgentScopeConfig;
198
198
  externalAgentId: string;
199
199
  }) => Promise<{
200
- id: string;
201
- createdAt: string;
202
- updatedAt: string;
203
200
  tenantId: string;
204
201
  projectId: string;
205
202
  agentId: string;
206
203
  subAgentId: string;
204
+ id: string;
205
+ createdAt: string;
206
+ updatedAt: string;
207
207
  headers: Record<string, string> | null;
208
208
  externalAgentId: string;
209
209
  } | undefined>;
@@ -218,13 +218,13 @@ declare const upsertSubAgentExternalAgentRelation: (db: AgentsManageDatabaseClie
218
218
  headers?: Record<string, string> | null;
219
219
  };
220
220
  }) => Promise<{
221
- id: string;
222
- createdAt: string;
223
- updatedAt: string;
224
221
  tenantId: string;
225
222
  projectId: string;
226
223
  agentId: string;
227
224
  subAgentId: string;
225
+ id: string;
226
+ createdAt: string;
227
+ updatedAt: string;
228
228
  headers: Record<string, string> | null;
229
229
  externalAgentId: string;
230
230
  }>;
@@ -9,12 +9,12 @@ declare const getAgentRelationById: (db: AgentsManageDatabaseClient) => (params:
9
9
  scopes: AgentScopeConfig;
10
10
  relationId: string;
11
11
  }) => Promise<{
12
- id: string;
13
- createdAt: string;
14
- updatedAt: string;
15
12
  tenantId: string;
16
13
  projectId: string;
17
14
  agentId: string;
15
+ id: string;
16
+ createdAt: string;
17
+ updatedAt: string;
18
18
  sourceSubAgentId: string;
19
19
  targetSubAgentId: string | null;
20
20
  relationType: string | null;
@@ -44,12 +44,12 @@ declare const listAgentRelations: (db: AgentsManageDatabaseClient) => (params: {
44
44
  declare const getAgentRelations: (db: AgentsManageDatabaseClient) => (params: {
45
45
  scopes: SubAgentScopeConfig;
46
46
  }) => Promise<{
47
- id: string;
48
- createdAt: string;
49
- updatedAt: string;
50
47
  tenantId: string;
51
48
  projectId: string;
52
49
  agentId: string;
50
+ id: string;
51
+ createdAt: string;
52
+ updatedAt: string;
53
53
  sourceSubAgentId: string;
54
54
  targetSubAgentId: string | null;
55
55
  relationType: string | null;
@@ -57,12 +57,12 @@ declare const getAgentRelations: (db: AgentsManageDatabaseClient) => (params: {
57
57
  declare const getAgentRelationsByAgent: (db: AgentsManageDatabaseClient) => (params: {
58
58
  scopes: AgentScopeConfig;
59
59
  }) => Promise<{
60
- id: string;
61
- createdAt: string;
62
- updatedAt: string;
63
60
  tenantId: string;
64
61
  projectId: string;
65
62
  agentId: string;
63
+ id: string;
64
+ createdAt: string;
65
+ updatedAt: string;
66
66
  sourceSubAgentId: string;
67
67
  targetSubAgentId: string | null;
68
68
  relationType: string | null;
@@ -126,12 +126,12 @@ declare const getRelatedAgentsForAgent: (db: AgentsManageDatabaseClient) => (par
126
126
  }[];
127
127
  }>;
128
128
  declare const createSubAgentRelation: (db: AgentsManageDatabaseClient) => (params: SubAgentRelationInsert) => Promise<{
129
- id: string;
130
- createdAt: string;
131
- updatedAt: string;
132
129
  tenantId: string;
133
130
  projectId: string;
134
131
  agentId: string;
132
+ id: string;
133
+ createdAt: string;
134
+ updatedAt: string;
135
135
  sourceSubAgentId: string;
136
136
  targetSubAgentId: string | null;
137
137
  relationType: string | null;
@@ -145,12 +145,12 @@ declare const getAgentRelationByParams: (db: AgentsManageDatabaseClient) => (par
145
145
  targetSubAgentId?: string;
146
146
  relationType: string;
147
147
  }) => Promise<{
148
- id: string;
149
- createdAt: string;
150
- updatedAt: string;
151
148
  tenantId: string;
152
149
  projectId: string;
153
150
  agentId: string;
151
+ id: string;
152
+ createdAt: string;
153
+ updatedAt: string;
154
154
  sourceSubAgentId: string;
155
155
  targetSubAgentId: string | null;
156
156
  relationType: string | null;
@@ -159,12 +159,12 @@ declare const getAgentRelationByParams: (db: AgentsManageDatabaseClient) => (par
159
159
  * Upsert agent relation (create if it doesn't exist, no-op if it does)
160
160
  */
161
161
  declare const upsertSubAgentRelation: (db: AgentsManageDatabaseClient) => (params: SubAgentRelationInsert) => Promise<{
162
- id: string;
163
- createdAt: string;
164
- updatedAt: string;
165
162
  tenantId: string;
166
163
  projectId: string;
167
164
  agentId: string;
165
+ id: string;
166
+ createdAt: string;
167
+ updatedAt: string;
168
168
  sourceSubAgentId: string;
169
169
  targetSubAgentId: string | null;
170
170
  relationType: string | null;
@@ -204,15 +204,15 @@ declare const createAgentToolRelation: (db: AgentsManageDatabaseClient) => (para
204
204
  }> | null;
205
205
  };
206
206
  }) => Promise<{
207
- id: string;
208
- createdAt: string;
209
- updatedAt: string;
210
207
  tenantId: string;
211
208
  projectId: string;
212
209
  agentId: string;
213
210
  subAgentId: string;
214
- headers: Record<string, string> | null;
211
+ id: string;
212
+ createdAt: string;
213
+ updatedAt: string;
215
214
  toolId: string;
215
+ headers: Record<string, string> | null;
216
216
  toolPolicies: Record<string, {
217
217
  needsApproval?: boolean;
218
218
  }> | null;
@@ -248,15 +248,15 @@ declare const getAgentToolRelationById: (db: AgentsManageDatabaseClient) => (par
248
248
  scopes: SubAgentScopeConfig;
249
249
  relationId: string;
250
250
  }) => Promise<{
251
- id: string;
252
- createdAt: string;
253
- updatedAt: string;
254
251
  tenantId: string;
255
252
  projectId: string;
256
253
  agentId: string;
257
254
  subAgentId: string;
258
- headers: Record<string, string> | null;
255
+ id: string;
256
+ createdAt: string;
257
+ updatedAt: string;
259
258
  toolId: string;
259
+ headers: Record<string, string> | null;
260
260
  toolPolicies: Record<string, {
261
261
  needsApproval?: boolean;
262
262
  }> | null;
@@ -9,13 +9,13 @@ declare const getSubAgentTeamAgentRelationById: (db: AgentsManageDatabaseClient)
9
9
  scopes: SubAgentScopeConfig;
10
10
  relationId: string;
11
11
  }) => Promise<{
12
- id: string;
13
- createdAt: string;
14
- updatedAt: string;
15
12
  tenantId: string;
16
13
  projectId: string;
17
14
  agentId: string;
18
15
  subAgentId: string;
16
+ id: string;
17
+ createdAt: string;
18
+ updatedAt: string;
19
19
  headers: Record<string, string> | null;
20
20
  targetAgentId: string;
21
21
  } | undefined>;
@@ -44,26 +44,26 @@ declare const listSubAgentTeamAgentRelations: (db: AgentsManageDatabaseClient) =
44
44
  declare const getSubAgentTeamAgentRelations: (db: AgentsManageDatabaseClient) => (params: {
45
45
  scopes: SubAgentScopeConfig;
46
46
  }) => Promise<{
47
- id: string;
48
- createdAt: string;
49
- updatedAt: string;
50
47
  tenantId: string;
51
48
  projectId: string;
52
49
  agentId: string;
53
50
  subAgentId: string;
51
+ id: string;
52
+ createdAt: string;
53
+ updatedAt: string;
54
54
  headers: Record<string, string> | null;
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
- createdAt: string;
62
- updatedAt: string;
63
60
  tenantId: string;
64
61
  projectId: string;
65
62
  agentId: string;
66
63
  subAgentId: string;
64
+ id: string;
65
+ createdAt: string;
66
+ updatedAt: string;
67
67
  headers: Record<string, string> | null;
68
68
  targetAgentId: string;
69
69
  }[]>;
@@ -210,13 +210,13 @@ declare const createSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient)
210
210
  headers?: Record<string, string> | null;
211
211
  };
212
212
  }) => Promise<{
213
- id: string;
214
- createdAt: string;
215
- updatedAt: string;
216
213
  tenantId: string;
217
214
  projectId: string;
218
215
  agentId: string;
219
216
  subAgentId: string;
217
+ id: string;
218
+ createdAt: string;
219
+ updatedAt: string;
220
220
  headers: Record<string, string> | null;
221
221
  targetAgentId: string;
222
222
  }>;
@@ -227,13 +227,13 @@ declare const getSubAgentTeamAgentRelationByParams: (db: AgentsManageDatabaseCli
227
227
  scopes: SubAgentScopeConfig;
228
228
  targetAgentId: string;
229
229
  }) => Promise<{
230
- id: string;
231
- createdAt: string;
232
- updatedAt: string;
233
230
  tenantId: string;
234
231
  projectId: string;
235
232
  agentId: string;
236
233
  subAgentId: string;
234
+ id: string;
235
+ createdAt: string;
236
+ updatedAt: string;
237
237
  headers: Record<string, string> | null;
238
238
  targetAgentId: string;
239
239
  } | undefined>;
@@ -248,13 +248,13 @@ declare const upsertSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient)
248
248
  headers?: Record<string, string> | null;
249
249
  };
250
250
  }) => Promise<{
251
- id: string;
252
- createdAt: string;
253
- updatedAt: string;
254
251
  tenantId: string;
255
252
  projectId: string;
256
253
  agentId: string;
257
254
  subAgentId: string;
255
+ id: string;
256
+ createdAt: string;
257
+ updatedAt: string;
258
258
  headers: Record<string, string> | null;
259
259
  targetAgentId: string;
260
260
  }>;
@@ -9,13 +9,12 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
9
9
  scopes: AgentScopeConfig;
10
10
  subAgentId: string;
11
11
  }) => Promise<{
12
- id: string;
13
- name: string;
14
- createdAt: string;
15
- updatedAt: string;
16
12
  description: string | null;
17
13
  tenantId: string;
18
14
  projectId: string;
15
+ agentId: string;
16
+ id: string;
17
+ name: string;
19
18
  models: {
20
19
  base?: {
21
20
  model?: string | undefined;
@@ -30,23 +29,23 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
30
29
  providerOptions?: Record<string, any> | undefined;
31
30
  } | undefined;
32
31
  } | null;
32
+ prompt: string | null;
33
33
  stopWhen: {
34
34
  stepCountIs?: number | undefined;
35
35
  } | null;
36
- agentId: string;
37
- prompt: string | null;
36
+ createdAt: string;
37
+ updatedAt: string;
38
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
- createdAt: string;
46
- updatedAt: string;
47
43
  description: string | null;
48
44
  tenantId: string;
49
45
  projectId: string;
46
+ agentId: string;
47
+ id: string;
48
+ name: string;
50
49
  models: {
51
50
  base?: {
52
51
  model?: string | undefined;
@@ -61,11 +60,12 @@ declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
61
60
  providerOptions?: Record<string, any> | undefined;
62
61
  } | undefined;
63
62
  } | null;
63
+ prompt: string | null;
64
64
  stopWhen: {
65
65
  stepCountIs?: number | undefined;
66
66
  } | null;
67
- agentId: string;
68
- prompt: string | null;
67
+ createdAt: string;
68
+ updatedAt: string;
69
69
  conversationHistoryConfig: ConversationHistoryConfig | null;
70
70
  }[]>;
71
71
  declare const listSubAgentsPaginated: (db: AgentsManageDatabaseClient) => (params: {
@@ -109,13 +109,12 @@ 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
- createdAt: string;
115
- updatedAt: string;
116
112
  description: string | null;
117
113
  tenantId: string;
118
114
  projectId: string;
115
+ agentId: string;
116
+ id: string;
117
+ name: string;
119
118
  models: {
120
119
  base?: {
121
120
  model?: string | undefined;
@@ -130,11 +129,12 @@ declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAg
130
129
  providerOptions?: Record<string, any> | undefined;
131
130
  } | undefined;
132
131
  } | null;
132
+ prompt: string | null;
133
133
  stopWhen: {
134
134
  stepCountIs?: number | undefined;
135
135
  } | null;
136
- agentId: string;
137
- prompt: string | null;
136
+ createdAt: string;
137
+ updatedAt: string;
138
138
  conversationHistoryConfig: ConversationHistoryConfig | null;
139
139
  }>;
140
140
  declare const updateSubAgent: (db: AgentsManageDatabaseClient) => (params: {
@@ -19,13 +19,13 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
19
19
  scopes: ProjectScopeConfig;
20
20
  toolId: string;
21
21
  }) => Promise<{
22
+ description: string | null;
23
+ tenantId: string;
24
+ projectId: string;
22
25
  id: string;
23
26
  name: string;
24
27
  createdAt: string;
25
28
  updatedAt: string;
26
- description: string | null;
27
- tenantId: string;
28
- projectId: string;
29
29
  headers: Record<string, string> | null;
30
30
  config: {
31
31
  type: "mcp";
@@ -77,13 +77,13 @@ declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
77
77
  };
78
78
  }>;
79
79
  declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInsert) => Promise<{
80
+ description: string | null;
81
+ tenantId: string;
82
+ projectId: string;
80
83
  id: string;
81
84
  name: string;
82
85
  createdAt: string;
83
86
  updatedAt: string;
84
- description: string | null;
85
- tenantId: string;
86
- projectId: string;
87
87
  headers: Record<string, string> | null;
88
88
  config: {
89
89
  type: "mcp";
@@ -134,15 +134,15 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
134
134
  needsApproval?: boolean;
135
135
  }> | null;
136
136
  }) => Promise<{
137
- id: string;
138
- createdAt: string;
139
- updatedAt: string;
140
137
  tenantId: string;
141
138
  projectId: string;
142
139
  agentId: string;
143
140
  subAgentId: string;
144
- headers: Record<string, string> | null;
141
+ id: string;
142
+ createdAt: string;
143
+ updatedAt: string;
145
144
  toolId: string;
145
+ headers: Record<string, string> | null;
146
146
  toolPolicies: Record<string, {
147
147
  needsApproval?: boolean;
148
148
  }> | null;
@@ -153,15 +153,15 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
153
153
  subAgentId: string;
154
154
  toolId: string;
155
155
  }) => Promise<{
156
- id: string;
157
- createdAt: string;
158
- updatedAt: string;
159
156
  tenantId: string;
160
157
  projectId: string;
161
158
  agentId: string;
162
159
  subAgentId: string;
163
- headers: Record<string, string> | null;
160
+ id: string;
161
+ createdAt: string;
162
+ updatedAt: string;
164
163
  toolId: string;
164
+ headers: Record<string, string> | null;
165
165
  toolPolicies: Record<string, {
166
166
  needsApproval?: boolean;
167
167
  }> | null;
@@ -181,15 +181,15 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
181
181
  }> | null;
182
182
  relationId?: string;
183
183
  }) => Promise<{
184
- id: string;
185
- createdAt: string;
186
- updatedAt: string;
187
184
  tenantId: string;
188
185
  projectId: string;
189
186
  agentId: string;
190
187
  subAgentId: string;
191
- headers: Record<string, string> | null;
188
+ id: string;
189
+ createdAt: string;
190
+ updatedAt: string;
192
191
  toolId: string;
192
+ headers: Record<string, string> | null;
193
193
  toolPolicies: Record<string, {
194
194
  needsApproval?: boolean;
195
195
  }> | null;
@@ -201,13 +201,13 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
201
201
  declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
202
202
  data: ToolInsert;
203
203
  }) => Promise<{
204
+ description: string | null;
205
+ tenantId: string;
206
+ projectId: string;
204
207
  id: string;
205
208
  name: string;
206
209
  createdAt: string;
207
210
  updatedAt: string;
208
- description: string | null;
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 };
@@ -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" | "body" | "header";
43
+ source: "query" | "header" | "body";
44
44
  key: string;
45
45
  prefix?: string | undefined;
46
46
  regex?: string | undefined;
47
47
  };
48
48
  signedComponents: {
49
- source: "literal" | "body" | "header";
49
+ source: "literal" | "header" | "body";
50
50
  required: boolean;
51
51
  key?: string | undefined;
52
52
  value?: string | undefined;
@@ -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 };