@inkeep/agents-core 0.0.0-dev-20260202155313 → 0.0.0-dev-20260203023016

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 (55) hide show
  1. package/dist/auth/auth-validation-schemas.d.ts +146 -146
  2. package/dist/auth/auth.d.ts +53 -53
  3. package/dist/auth/permissions.d.ts +13 -13
  4. package/dist/client-exports.d.ts +11 -11
  5. package/dist/data-access/index.d.ts +3 -2
  6. package/dist/data-access/index.js +3 -2
  7. package/dist/data-access/manage/agents.d.ts +17 -17
  8. package/dist/data-access/manage/artifactComponents.d.ts +2 -2
  9. package/dist/data-access/manage/dataComponents.d.ts +2 -2
  10. package/dist/data-access/manage/functionTools.d.ts +4 -4
  11. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +12 -12
  12. package/dist/data-access/manage/subAgentRelations.d.ts +4 -4
  13. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +12 -12
  14. package/dist/data-access/manage/subAgents.d.ts +15 -15
  15. package/dist/data-access/manage/tools.d.ts +14 -9
  16. package/dist/data-access/manage/tools.js +20 -1
  17. package/dist/data-access/manage/triggers.d.ts +2 -2
  18. package/dist/data-access/runtime/cascade-delete.d.ts +48 -1
  19. package/dist/data-access/runtime/cascade-delete.js +52 -2
  20. package/dist/data-access/runtime/conversations.d.ts +7 -7
  21. package/dist/data-access/runtime/github-work-app-installations.d.ts +261 -0
  22. package/dist/data-access/runtime/github-work-app-installations.js +457 -0
  23. package/dist/data-access/runtime/messages.d.ts +3 -3
  24. package/dist/data-access/runtime/tasks.d.ts +3 -3
  25. package/dist/db/manage/manage-schema.d.ts +322 -305
  26. package/dist/db/manage/manage-schema.js +1 -0
  27. package/dist/db/runtime/runtime-schema.d.ts +1009 -165
  28. package/dist/db/runtime/runtime-schema.js +173 -5
  29. package/dist/dolt/branch.js +1 -1
  30. package/dist/dolt/branches-api.js +1 -1
  31. package/dist/dolt/index.js +3 -3
  32. package/dist/dolt/migrate-all-branches.js +1 -1
  33. package/dist/dolt/ref-helpers.js +1 -1
  34. package/dist/dolt/ref-middleware.js +1 -1
  35. package/dist/dolt/ref-scope.js +1 -1
  36. package/dist/env.d.ts +2 -0
  37. package/dist/env.js +2 -1
  38. package/dist/index.d.ts +7 -6
  39. package/dist/index.js +11 -10
  40. package/dist/types/entities.d.ts +9 -2
  41. package/dist/types/index.d.ts +3 -3
  42. package/dist/types/utility.d.ts +16 -2
  43. package/dist/validation/dolt-schemas.d.ts +1 -1
  44. package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
  45. package/dist/validation/index.d.ts +2 -2
  46. package/dist/validation/index.js +2 -2
  47. package/dist/validation/schemas.d.ts +3396 -1592
  48. package/dist/validation/schemas.js +48 -2
  49. package/drizzle/manage/0006_fixed_umar.sql +1 -0
  50. package/drizzle/manage/meta/0006_snapshot.json +3148 -0
  51. package/drizzle/manage/meta/_journal.json +7 -0
  52. package/drizzle/runtime/0010_previous_black_knight.sql +84 -0
  53. package/drizzle/runtime/meta/0010_snapshot.json +3066 -0
  54. package/drizzle/runtime/meta/_journal.json +7 -0
  55. package/package.json +1 -1
@@ -68,8 +68,8 @@ declare const associateDataComponentWithAgent: (db: AgentsManageDatabaseClient)
68
68
  createdAt: string;
69
69
  tenantId: string;
70
70
  projectId: string;
71
- agentId: string;
72
71
  subAgentId: string;
72
+ agentId: string;
73
73
  dataComponentId: string;
74
74
  }>;
75
75
  /**
@@ -110,8 +110,8 @@ declare const upsertAgentDataComponentRelation: (db: AgentsManageDatabaseClient)
110
110
  createdAt: string;
111
111
  tenantId: string;
112
112
  projectId: string;
113
- agentId: string;
114
113
  subAgentId: string;
114
+ agentId: string;
115
115
  dataComponentId: string;
116
116
  } | null>;
117
117
  /**
@@ -166,12 +166,12 @@ declare const addFunctionToolToSubAgent: (db: AgentsManageDatabaseClient) => (pa
166
166
  updatedAt: string;
167
167
  tenantId: string;
168
168
  projectId: string;
169
+ subAgentId: string;
169
170
  agentId: string;
171
+ functionToolId: string;
170
172
  toolPolicies: Record<string, {
171
173
  needsApproval?: boolean;
172
174
  }> | null;
173
- subAgentId: string;
174
- functionToolId: string;
175
175
  }>;
176
176
  /**
177
177
  * Update an agent-function tool relation
@@ -231,12 +231,12 @@ declare const associateFunctionToolWithSubAgent: (db: AgentsManageDatabaseClient
231
231
  updatedAt: string;
232
232
  tenantId: string;
233
233
  projectId: string;
234
+ subAgentId: string;
234
235
  agentId: string;
236
+ functionToolId: string;
235
237
  toolPolicies: Record<string, {
236
238
  needsApproval?: boolean;
237
239
  }> | null;
238
- subAgentId: string;
239
- functionToolId: string;
240
240
  }>;
241
241
  //#endregion
242
242
  export { addFunctionToolToSubAgent, associateFunctionToolWithSubAgent, createFunctionTool, deleteFunctionTool, getFunctionToolById, getFunctionToolsForSubAgent, getSubAgentsUsingFunctionTool, isFunctionToolAssociatedWithSubAgent, listFunctionTools, removeFunctionToolFromSubAgent, updateFunctionTool, updateSubAgentFunctionToolRelation, upsertFunctionTool, upsertSubAgentFunctionToolRelation };
@@ -11,12 +11,12 @@ declare const getSubAgentExternalAgentRelationById: (db: AgentsManageDatabaseCli
11
11
  id: string;
12
12
  createdAt: string;
13
13
  updatedAt: string;
14
- headers: Record<string, string> | null;
15
14
  tenantId: string;
16
15
  projectId: string;
16
+ subAgentId: string;
17
+ headers: Record<string, string> | null;
17
18
  agentId: string;
18
19
  externalAgentId: string;
19
- subAgentId: string;
20
20
  } | undefined>;
21
21
  declare const listSubAgentExternalAgentRelations: (db: AgentsManageDatabaseClient) => (params: {
22
22
  scopes: SubAgentScopeConfig;
@@ -46,12 +46,12 @@ declare const getSubAgentExternalAgentRelations: (db: AgentsManageDatabaseClient
46
46
  id: string;
47
47
  createdAt: string;
48
48
  updatedAt: string;
49
- headers: Record<string, string> | null;
50
49
  tenantId: string;
51
50
  projectId: string;
51
+ subAgentId: string;
52
+ headers: Record<string, string> | null;
52
53
  agentId: string;
53
54
  externalAgentId: string;
54
- subAgentId: string;
55
55
  }[]>;
56
56
  declare const getSubAgentExternalAgentRelationsByAgent: (db: AgentsManageDatabaseClient) => (params: {
57
57
  scopes: AgentScopeConfig;
@@ -59,12 +59,12 @@ declare const getSubAgentExternalAgentRelationsByAgent: (db: AgentsManageDatabas
59
59
  id: string;
60
60
  createdAt: string;
61
61
  updatedAt: string;
62
- headers: Record<string, string> | null;
63
62
  tenantId: string;
64
63
  projectId: string;
64
+ subAgentId: string;
65
+ headers: Record<string, string> | null;
65
66
  agentId: string;
66
67
  externalAgentId: string;
67
- subAgentId: string;
68
68
  }[]>;
69
69
  declare const getSubAgentExternalAgentRelationsByExternalAgent: (db: AgentsManageDatabaseClient) => (params: {
70
70
  scopes: AgentScopeConfig;
@@ -182,12 +182,12 @@ declare const createSubAgentExternalAgentRelation: (db: AgentsManageDatabaseClie
182
182
  id: string;
183
183
  createdAt: string;
184
184
  updatedAt: string;
185
- headers: Record<string, string> | null;
186
185
  tenantId: string;
187
186
  projectId: string;
187
+ subAgentId: string;
188
+ headers: Record<string, string> | null;
188
189
  agentId: string;
189
190
  externalAgentId: string;
190
- subAgentId: string;
191
191
  }>;
192
192
  /**
193
193
  * Check if sub-agent external agent relation exists by params
@@ -199,12 +199,12 @@ declare const getSubAgentExternalAgentRelationByParams: (db: AgentsManageDatabas
199
199
  id: string;
200
200
  createdAt: string;
201
201
  updatedAt: string;
202
- headers: Record<string, string> | null;
203
202
  tenantId: string;
204
203
  projectId: string;
204
+ subAgentId: string;
205
+ headers: Record<string, string> | null;
205
206
  agentId: string;
206
207
  externalAgentId: string;
207
- subAgentId: string;
208
208
  } | undefined>;
209
209
  /**
210
210
  * Upsert sub-agent external agent relation (create if it doesn't exist, update if it does)
@@ -220,12 +220,12 @@ declare const upsertSubAgentExternalAgentRelation: (db: AgentsManageDatabaseClie
220
220
  id: string;
221
221
  createdAt: string;
222
222
  updatedAt: string;
223
- headers: Record<string, string> | null;
224
223
  tenantId: string;
225
224
  projectId: string;
225
+ subAgentId: string;
226
+ headers: Record<string, string> | null;
226
227
  agentId: string;
227
228
  externalAgentId: string;
228
- subAgentId: string;
229
229
  }>;
230
230
  declare const updateSubAgentExternalAgentRelation: (db: AgentsManageDatabaseClient) => (params: {
231
231
  scopes: SubAgentScopeConfig;
@@ -206,15 +206,15 @@ declare const createAgentToolRelation: (db: AgentsManageDatabaseClient) => (para
206
206
  id: string;
207
207
  createdAt: string;
208
208
  updatedAt: string;
209
- headers: Record<string, string> | null;
210
209
  tenantId: string;
211
210
  projectId: string;
211
+ subAgentId: string;
212
+ headers: Record<string, string> | null;
212
213
  agentId: string;
213
214
  toolId: string;
214
215
  toolPolicies: Record<string, {
215
216
  needsApproval?: boolean;
216
217
  }> | null;
217
- subAgentId: string;
218
218
  selectedTools: string[] | null;
219
219
  }>;
220
220
  declare const updateAgentToolRelation: (db: AgentsManageDatabaseClient) => (params: {
@@ -250,15 +250,15 @@ declare const getAgentToolRelationById: (db: AgentsManageDatabaseClient) => (par
250
250
  id: string;
251
251
  createdAt: string;
252
252
  updatedAt: string;
253
- headers: Record<string, string> | null;
254
253
  tenantId: string;
255
254
  projectId: string;
255
+ subAgentId: string;
256
+ headers: Record<string, string> | null;
256
257
  agentId: string;
257
258
  toolId: string;
258
259
  toolPolicies: Record<string, {
259
260
  needsApproval?: boolean;
260
261
  }> | null;
261
- subAgentId: string;
262
262
  selectedTools: string[] | null;
263
263
  } | undefined>;
264
264
  declare const getAgentToolRelationByAgent: (db: AgentsManageDatabaseClient) => (params: {
@@ -11,11 +11,11 @@ declare const getSubAgentTeamAgentRelationById: (db: AgentsManageDatabaseClient)
11
11
  id: string;
12
12
  createdAt: string;
13
13
  updatedAt: string;
14
- headers: Record<string, string> | null;
15
14
  tenantId: string;
16
15
  projectId: string;
17
- agentId: string;
18
16
  subAgentId: string;
17
+ headers: Record<string, string> | null;
18
+ agentId: string;
19
19
  targetAgentId: string;
20
20
  } | undefined>;
21
21
  declare const listSubAgentTeamAgentRelations: (db: AgentsManageDatabaseClient) => (params: {
@@ -46,11 +46,11 @@ declare const getSubAgentTeamAgentRelations: (db: AgentsManageDatabaseClient) =>
46
46
  id: string;
47
47
  createdAt: string;
48
48
  updatedAt: string;
49
- headers: Record<string, string> | null;
50
49
  tenantId: string;
51
50
  projectId: string;
52
- agentId: string;
53
51
  subAgentId: string;
52
+ headers: Record<string, string> | null;
53
+ agentId: string;
54
54
  targetAgentId: string;
55
55
  }[]>;
56
56
  declare const getSubAgentTeamAgentRelationsByAgent: (db: AgentsManageDatabaseClient) => (params: {
@@ -59,11 +59,11 @@ declare const getSubAgentTeamAgentRelationsByAgent: (db: AgentsManageDatabaseCli
59
59
  id: string;
60
60
  createdAt: string;
61
61
  updatedAt: string;
62
- headers: Record<string, string> | null;
63
62
  tenantId: string;
64
63
  projectId: string;
65
- agentId: string;
66
64
  subAgentId: string;
65
+ headers: Record<string, string> | null;
66
+ agentId: string;
67
67
  targetAgentId: string;
68
68
  }[]>;
69
69
  declare const getSubAgentTeamAgentRelationsByTeamAgent: (db: AgentsManageDatabaseClient) => (params: {
@@ -212,11 +212,11 @@ declare const createSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient)
212
212
  id: string;
213
213
  createdAt: string;
214
214
  updatedAt: string;
215
- headers: Record<string, string> | null;
216
215
  tenantId: string;
217
216
  projectId: string;
218
- agentId: string;
219
217
  subAgentId: string;
218
+ headers: Record<string, string> | null;
219
+ agentId: string;
220
220
  targetAgentId: string;
221
221
  }>;
222
222
  /**
@@ -229,11 +229,11 @@ declare const getSubAgentTeamAgentRelationByParams: (db: AgentsManageDatabaseCli
229
229
  id: string;
230
230
  createdAt: string;
231
231
  updatedAt: string;
232
- headers: Record<string, string> | null;
233
232
  tenantId: string;
234
233
  projectId: string;
235
- agentId: string;
236
234
  subAgentId: string;
235
+ headers: Record<string, string> | null;
236
+ agentId: string;
237
237
  targetAgentId: string;
238
238
  } | undefined>;
239
239
  /**
@@ -250,11 +250,11 @@ declare const upsertSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient)
250
250
  id: string;
251
251
  createdAt: string;
252
252
  updatedAt: string;
253
- headers: Record<string, string> | null;
254
253
  tenantId: string;
255
254
  projectId: string;
256
- agentId: string;
257
255
  subAgentId: string;
256
+ headers: Record<string, string> | null;
257
+ agentId: string;
258
258
  targetAgentId: string;
259
259
  }>;
260
260
  declare const updateSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient) => (params: {
@@ -15,8 +15,11 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
15
15
  description: string | null;
16
16
  tenantId: string;
17
17
  projectId: string;
18
+ stopWhen: {
19
+ stepCountIs?: number | undefined;
20
+ } | null;
18
21
  prompt: string | null;
19
- agentId: string;
22
+ conversationHistoryConfig: ConversationHistoryConfig | null;
20
23
  models: {
21
24
  base?: {
22
25
  model?: string | undefined;
@@ -31,10 +34,7 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
31
34
  providerOptions?: Record<string, any> | undefined;
32
35
  } | undefined;
33
36
  } | null;
34
- stopWhen: {
35
- stepCountIs?: number | undefined;
36
- } | null;
37
- conversationHistoryConfig: ConversationHistoryConfig | null;
37
+ agentId: string;
38
38
  } | undefined>;
39
39
  declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
40
40
  scopes: AgentScopeConfig;
@@ -46,8 +46,11 @@ declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
46
46
  description: string | null;
47
47
  tenantId: string;
48
48
  projectId: string;
49
+ stopWhen: {
50
+ stepCountIs?: number | undefined;
51
+ } | null;
49
52
  prompt: string | null;
50
- agentId: string;
53
+ conversationHistoryConfig: ConversationHistoryConfig | null;
51
54
  models: {
52
55
  base?: {
53
56
  model?: string | undefined;
@@ -62,10 +65,7 @@ declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
62
65
  providerOptions?: Record<string, any> | undefined;
63
66
  } | undefined;
64
67
  } | null;
65
- stopWhen: {
66
- stepCountIs?: number | undefined;
67
- } | null;
68
- conversationHistoryConfig: ConversationHistoryConfig | null;
68
+ agentId: string;
69
69
  }[]>;
70
70
  declare const listSubAgentsPaginated: (db: AgentsManageDatabaseClient) => (params: {
71
71
  scopes: AgentScopeConfig;
@@ -115,8 +115,11 @@ declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAg
115
115
  description: string | null;
116
116
  tenantId: string;
117
117
  projectId: string;
118
+ stopWhen: {
119
+ stepCountIs?: number | undefined;
120
+ } | null;
118
121
  prompt: string | null;
119
- agentId: string;
122
+ conversationHistoryConfig: ConversationHistoryConfig | null;
120
123
  models: {
121
124
  base?: {
122
125
  model?: string | undefined;
@@ -131,10 +134,7 @@ declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAg
131
134
  providerOptions?: Record<string, any> | undefined;
132
135
  } | undefined;
133
136
  } | null;
134
- stopWhen: {
135
- stepCountIs?: number | undefined;
136
- } | null;
137
- conversationHistoryConfig: ConversationHistoryConfig | null;
137
+ agentId: string;
138
138
  }>;
139
139
  declare const updateSubAgent: (db: AgentsManageDatabaseClient) => (params: {
140
140
  scopes: AgentScopeConfig;
@@ -23,9 +23,9 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
23
23
  createdAt: string;
24
24
  updatedAt: string;
25
25
  description: string | null;
26
- headers: Record<string, string> | null;
27
26
  tenantId: string;
28
27
  projectId: string;
28
+ headers: Record<string, string> | null;
29
29
  config: {
30
30
  type: "mcp";
31
31
  mcp: ToolMcpConfig;
@@ -35,6 +35,7 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
35
35
  imageUrl: string | null;
36
36
  capabilities: ToolServerCapabilities | null;
37
37
  lastError: string | null;
38
+ isWorkApp: boolean;
38
39
  } | null>;
39
40
  declare const getMcpToolById: (db: AgentsManageDatabaseClient) => (params: {
40
41
  scopes: ProjectScopeConfig;
@@ -62,6 +63,7 @@ declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
62
63
  imageUrl: string | null;
63
64
  capabilities: ToolServerCapabilities | null;
64
65
  lastError: string | null;
66
+ isWorkApp: boolean;
65
67
  projectId: string;
66
68
  tenantId: string;
67
69
  id: string;
@@ -79,9 +81,9 @@ declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInser
79
81
  createdAt: string;
80
82
  updatedAt: string;
81
83
  description: string | null;
82
- headers: Record<string, string> | null;
83
84
  tenantId: string;
84
85
  projectId: string;
86
+ headers: Record<string, string> | null;
85
87
  config: {
86
88
  type: "mcp";
87
89
  mcp: ToolMcpConfig;
@@ -91,6 +93,7 @@ declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInser
91
93
  imageUrl: string | null;
92
94
  capabilities: ToolServerCapabilities | null;
93
95
  lastError: string | null;
96
+ isWorkApp: boolean;
94
97
  }>;
95
98
  declare const updateTool: (db: AgentsManageDatabaseClient) => (params: {
96
99
  scopes: ProjectScopeConfig;
@@ -111,6 +114,7 @@ declare const updateTool: (db: AgentsManageDatabaseClient) => (params: {
111
114
  imageUrl: string | null;
112
115
  capabilities: ToolServerCapabilities | null;
113
116
  lastError: string | null;
117
+ isWorkApp: boolean;
114
118
  projectId: string;
115
119
  tenantId: string;
116
120
  id: string;
@@ -132,15 +136,15 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
132
136
  id: string;
133
137
  createdAt: string;
134
138
  updatedAt: string;
135
- headers: Record<string, string> | null;
136
139
  tenantId: string;
137
140
  projectId: string;
141
+ subAgentId: string;
142
+ headers: Record<string, string> | null;
138
143
  agentId: string;
139
144
  toolId: string;
140
145
  toolPolicies: Record<string, {
141
146
  needsApproval?: boolean;
142
147
  }> | null;
143
- subAgentId: string;
144
148
  selectedTools: string[] | null;
145
149
  }>;
146
150
  declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params: {
@@ -151,15 +155,15 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
151
155
  id: string;
152
156
  createdAt: string;
153
157
  updatedAt: string;
154
- headers: Record<string, string> | null;
155
158
  tenantId: string;
156
159
  projectId: string;
160
+ subAgentId: string;
161
+ headers: Record<string, string> | null;
157
162
  agentId: string;
158
163
  toolId: string;
159
164
  toolPolicies: Record<string, {
160
165
  needsApproval?: boolean;
161
166
  }> | null;
162
- subAgentId: string;
163
167
  selectedTools: string[] | null;
164
168
  }>;
165
169
  /**
@@ -179,15 +183,15 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
179
183
  id: string;
180
184
  createdAt: string;
181
185
  updatedAt: string;
182
- headers: Record<string, string> | null;
183
186
  tenantId: string;
184
187
  projectId: string;
188
+ subAgentId: string;
189
+ headers: Record<string, string> | null;
185
190
  agentId: string;
186
191
  toolId: string;
187
192
  toolPolicies: Record<string, {
188
193
  needsApproval?: boolean;
189
194
  }> | null;
190
- subAgentId: string;
191
195
  selectedTools: string[] | null;
192
196
  }>;
193
197
  /**
@@ -201,9 +205,9 @@ declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
201
205
  createdAt: string;
202
206
  updatedAt: string;
203
207
  description: string | null;
204
- headers: Record<string, string> | null;
205
208
  tenantId: string;
206
209
  projectId: string;
210
+ headers: Record<string, string> | null;
207
211
  config: {
208
212
  type: "mcp";
209
213
  mcp: ToolMcpConfig;
@@ -213,6 +217,7 @@ declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
213
217
  imageUrl: string | null;
214
218
  capabilities: ToolServerCapabilities | null;
215
219
  lastError: string | null;
220
+ isWorkApp: boolean;
216
221
  }>;
217
222
  //#endregion
218
223
  export { addToolToAgent, createTool, dbResultToMcpTool, dbResultToMcpToolSkeleton, deleteTool, getMcpToolById, getToolById, listTools, removeToolFromAgent, updateTool, upsertSubAgentToolRelation, upsertTool };
@@ -1,17 +1,22 @@
1
1
  import { CredentialStoreType, MCPServerType, MCPTransportType } from "../../types/utility.js";
2
2
  import { subAgentToolRelations, tools } from "../../db/manage/manage-schema.js";
3
3
  import { detectAuthenticationRequired } from "../../utils/auth-detection.js";
4
+ import { env } from "../../env.js";
4
5
  import { getLogger } from "../../utils/logger.js";
5
6
  import { getCredentialStoreLookupKeyFromRetrievalParams } from "../../utils/credential-store-utils.js";
6
7
  import { CredentialStuffer } from "../../credential-stuffer/CredentialStuffer.js";
7
8
  import "../../credential-stuffer/index.js";
9
+ import { createAgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
8
10
  import { generateId } from "../../utils/conversations.js";
9
11
  import { updateAgentToolRelation } from "./subAgentRelations.js";
12
+ import { getActiveBranch } from "../../dolt/schema-sync.js";
10
13
  import { toISODateString } from "../../utils/date.js";
11
14
  import { McpClient } from "../../utils/mcp-client.js";
12
15
  import { buildComposioMCPUrl } from "../../utils/third-party-mcp-servers/composio-client.js";
13
16
  import { isThirdPartyMCPServerAuthenticated } from "../../utils/third-party-mcp-servers/third-party-check.js";
14
17
  import "../../utils/index.js";
18
+ import { cascadeDeleteByTool } from "../runtime/cascade-delete.js";
19
+ import { isGithubWorkAppTool } from "../runtime/github-work-app-installations.js";
15
20
  import { getCredentialReference, getUserScopedCredentialReference } from "./credentialReferences.js";
16
21
  import { and, count, desc, eq } from "drizzle-orm";
17
22
  import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
@@ -114,6 +119,11 @@ const discoverToolsFromServer = async (tool, credentialReference, credentialStor
114
119
  sessionId: tool.config.mcp.transport?.sessionId
115
120
  };
116
121
  if (serverConfig.url) serverConfig.url = buildComposioMCPUrl(serverConfig.url.toString(), tool.tenantId, tool.projectId, tool.credentialScope === "user" ? "user" : "project", userId);
122
+ if (isGithubWorkAppTool(tool)) serverConfig.headers = {
123
+ ...serverConfig.headers,
124
+ "x-inkeep-tool-id": tool.id,
125
+ Authorization: `Bearer ${env.GITHUB_MCP_API_KEY}`
126
+ };
117
127
  const client = new McpClient({
118
128
  name: tool.name,
119
129
  server: serverConfig
@@ -307,7 +317,16 @@ const updateTool = (db) => async (params) => {
307
317
  };
308
318
  const deleteTool = (db) => async (params) => {
309
319
  const [deleted] = await db.delete(tools).where(and(eq(tools.tenantId, params.scopes.tenantId), eq(tools.projectId, params.scopes.projectId), eq(tools.id, params.toolId))).returning();
310
- return !!deleted;
320
+ if (!deleted) return false;
321
+ if (deleted.isWorkApp && deleted.config.mcp.server.url.includes("/github/mcp")) try {
322
+ if (await getActiveBranch(db)() === `${params.scopes.tenantId}_${params.scopes.projectId}_main`) await cascadeDeleteByTool(createAgentsRunDatabaseClient())({ toolId: params.toolId });
323
+ } catch (error) {
324
+ logger.debug({
325
+ error,
326
+ toolId: params.toolId
327
+ }, "Skipping cascade delete - active_branch() not available");
328
+ }
329
+ return true;
311
330
  };
312
331
  const addToolToAgent = (db) => async (params) => {
313
332
  const id = generateId();
@@ -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;
@@ -73,5 +73,52 @@ declare const cascadeDeleteByContextConfig: (db: AgentsRunDatabaseClient) => (pa
73
73
  }) => Promise<{
74
74
  contextCacheDeleted: number;
75
75
  }>;
76
+ /**
77
+ * Result of a tool cascade delete operation
78
+ */
79
+ type ToolCascadeDeleteResult = {
80
+ mcpToolRepositoryAccessDeleted: number;
81
+ mcpToolAccessModeDeleted: boolean;
82
+ };
83
+ /**
84
+ * Delete all runtime entities for a specific MCP tool.
85
+ * Called when an MCP tool is deleted from the manage database.
86
+ *
87
+ * Cleans up:
88
+ * - workAppGitHubMcpToolRepositoryAccess entries
89
+ * - workAppGitHubMcpToolAccessMode entry
90
+ *
91
+ * @param db - Runtime database client
92
+ * @returns Function that performs the cascade delete
93
+ */
94
+ declare const cascadeDeleteByTool: (db: AgentsRunDatabaseClient) => (params: {
95
+ toolId: string;
96
+ }) => Promise<ToolCascadeDeleteResult>;
97
+ /**
98
+ * Result of a project cascade delete operation (GitHub access only)
99
+ */
100
+ type ProjectGitHubAccessCascadeDeleteResult = {
101
+ projectRepositoryAccessDeleted: number;
102
+ projectAccessModeDeleted: boolean;
103
+ mcpToolRepositoryAccessDeleted: number;
104
+ mcpToolAccessModesDeleted: number;
105
+ };
106
+ /**
107
+ * Delete all GitHub access runtime entities for a specific project.
108
+ * Called when a project is deleted from the manage database.
109
+ *
110
+ * Cleans up:
111
+ * - workAppGitHubProjectRepositoryAccess entries
112
+ * - workAppGitHubProjectAccessMode entry
113
+ * - workAppGitHubMcpToolRepositoryAccess entries (for tools in this project)
114
+ * - workAppGitHubMcpToolAccessMode entries (for tools in this project)
115
+ *
116
+ * @param db - Runtime database client
117
+ * @returns Function that performs the cascade delete
118
+ */
119
+ declare const cascadeDeleteGitHubAccessByProject: (db: AgentsRunDatabaseClient) => (params: {
120
+ tenantId: string;
121
+ projectId: string;
122
+ }) => Promise<ProjectGitHubAccessCascadeDeleteResult>;
76
123
  //#endregion
77
- export { CascadeDeleteResult, cascadeDeleteByAgent, cascadeDeleteByBranch, cascadeDeleteByContextConfig, cascadeDeleteByProject, cascadeDeleteBySubAgent };
124
+ export { CascadeDeleteResult, ProjectGitHubAccessCascadeDeleteResult, ToolCascadeDeleteResult, cascadeDeleteByAgent, cascadeDeleteByBranch, cascadeDeleteByContextConfig, cascadeDeleteByProject, cascadeDeleteBySubAgent, cascadeDeleteByTool, cascadeDeleteGitHubAccessByProject };
@@ -1,4 +1,4 @@
1
- import { apiKeys, contextCache, conversations, tasks } from "../../db/runtime/runtime-schema.js";
1
+ import { apiKeys, contextCache, conversations, tasks, workAppGitHubMcpToolAccessMode, workAppGitHubMcpToolRepositoryAccess, workAppGitHubProjectAccessMode, workAppGitHubProjectRepositoryAccess } from "../../db/runtime/runtime-schema.js";
2
2
  import { and, eq, inArray, sql } from "drizzle-orm";
3
3
 
4
4
  //#region src/data-access/runtime/cascade-delete.ts
@@ -35,6 +35,10 @@ const cascadeDeleteByProject = (db) => async (params) => {
35
35
  const conversationsResult = await db.delete(conversations).where(and(eq(conversations.tenantId, scopes.tenantId), eq(conversations.projectId, scopes.projectId), sql`${conversations.ref}->>'name' = ${fullBranchName}`)).returning();
36
36
  const tasksResult = await db.delete(tasks).where(and(eq(tasks.tenantId, scopes.tenantId), eq(tasks.projectId, scopes.projectId), sql`${tasks.ref}->>'name' = ${fullBranchName}`)).returning();
37
37
  const apiKeysResult = await db.delete(apiKeys).where(and(eq(apiKeys.tenantId, scopes.tenantId), eq(apiKeys.projectId, scopes.projectId))).returning();
38
+ await cascadeDeleteGitHubAccessByProject(db)({
39
+ tenantId: scopes.tenantId,
40
+ projectId: scopes.projectId
41
+ });
38
42
  return {
39
43
  conversationsDeleted: conversationsResult.length,
40
44
  tasksDeleted: tasksResult.length,
@@ -106,6 +110,52 @@ const cascadeDeleteByContextConfig = (db) => async (params) => {
106
110
  const { scopes, contextConfigId, fullBranchName } = params;
107
111
  return { contextCacheDeleted: (await db.delete(contextCache).where(and(eq(contextCache.tenantId, scopes.tenantId), eq(contextCache.projectId, scopes.projectId), eq(contextCache.contextConfigId, contextConfigId), sql`${contextCache.ref}->>'name' = ${fullBranchName}`)).returning()).length };
108
112
  };
113
+ /**
114
+ * Delete all runtime entities for a specific MCP tool.
115
+ * Called when an MCP tool is deleted from the manage database.
116
+ *
117
+ * Cleans up:
118
+ * - workAppGitHubMcpToolRepositoryAccess entries
119
+ * - workAppGitHubMcpToolAccessMode entry
120
+ *
121
+ * @param db - Runtime database client
122
+ * @returns Function that performs the cascade delete
123
+ */
124
+ const cascadeDeleteByTool = (db) => async (params) => {
125
+ const { toolId } = params;
126
+ const repositoryAccessResult = await db.delete(workAppGitHubMcpToolRepositoryAccess).where(eq(workAppGitHubMcpToolRepositoryAccess.toolId, toolId)).returning();
127
+ const accessModeResult = await db.delete(workAppGitHubMcpToolAccessMode).where(eq(workAppGitHubMcpToolAccessMode.toolId, toolId)).returning();
128
+ return {
129
+ mcpToolRepositoryAccessDeleted: repositoryAccessResult.length,
130
+ mcpToolAccessModeDeleted: accessModeResult.length > 0
131
+ };
132
+ };
133
+ /**
134
+ * Delete all GitHub access runtime entities for a specific project.
135
+ * Called when a project is deleted from the manage database.
136
+ *
137
+ * Cleans up:
138
+ * - workAppGitHubProjectRepositoryAccess entries
139
+ * - workAppGitHubProjectAccessMode entry
140
+ * - workAppGitHubMcpToolRepositoryAccess entries (for tools in this project)
141
+ * - workAppGitHubMcpToolAccessMode entries (for tools in this project)
142
+ *
143
+ * @param db - Runtime database client
144
+ * @returns Function that performs the cascade delete
145
+ */
146
+ const cascadeDeleteGitHubAccessByProject = (db) => async (params) => {
147
+ const { tenantId, projectId } = params;
148
+ const projectRepoAccessResult = await db.delete(workAppGitHubProjectRepositoryAccess).where(and(eq(workAppGitHubProjectRepositoryAccess.tenantId, tenantId), eq(workAppGitHubProjectRepositoryAccess.projectId, projectId))).returning();
149
+ const projectAccessModeResult = await db.delete(workAppGitHubProjectAccessMode).where(and(eq(workAppGitHubProjectAccessMode.tenantId, tenantId), eq(workAppGitHubProjectAccessMode.projectId, projectId))).returning();
150
+ const mcpToolRepoAccessResult = await db.delete(workAppGitHubMcpToolRepositoryAccess).where(and(eq(workAppGitHubMcpToolRepositoryAccess.tenantId, tenantId), eq(workAppGitHubMcpToolRepositoryAccess.projectId, projectId))).returning();
151
+ const mcpToolAccessModeResult = await db.delete(workAppGitHubMcpToolAccessMode).where(and(eq(workAppGitHubMcpToolAccessMode.tenantId, tenantId), eq(workAppGitHubMcpToolAccessMode.projectId, projectId))).returning();
152
+ return {
153
+ projectRepositoryAccessDeleted: projectRepoAccessResult.length,
154
+ projectAccessModeDeleted: projectAccessModeResult.length > 0,
155
+ mcpToolRepositoryAccessDeleted: mcpToolRepoAccessResult.length,
156
+ mcpToolAccessModesDeleted: mcpToolAccessModeResult.length
157
+ };
158
+ };
109
159
 
110
160
  //#endregion
111
- export { cascadeDeleteByAgent, cascadeDeleteByBranch, cascadeDeleteByContextConfig, cascadeDeleteByProject, cascadeDeleteBySubAgent };
161
+ export { cascadeDeleteByAgent, cascadeDeleteByBranch, cascadeDeleteByContextConfig, cascadeDeleteByProject, cascadeDeleteBySubAgent, cascadeDeleteByTool, cascadeDeleteGitHubAccessByProject };