@inkeep/agents-core 0.0.0-dev-20260202155313 → 0.0.0-dev-20260203024837
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 +104 -104
- package/dist/auth/auth-validation-schemas.d.ts +129 -129
- package/dist/auth/auth.d.ts +53 -53
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/client-exports.d.ts +2 -1
- package/dist/data-access/index.d.ts +3 -2
- package/dist/data-access/index.js +3 -2
- package/dist/data-access/manage/agents.d.ts +20 -20
- package/dist/data-access/manage/artifactComponents.d.ts +10 -10
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- 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/subAgentExternalAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgentRelations.d.ts +32 -32
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgents.d.ts +12 -12
- package/dist/data-access/manage/tools.d.ts +32 -27
- package/dist/data-access/manage/tools.js +20 -1
- package/dist/data-access/manage/triggers.d.ts +2 -2
- package/dist/data-access/runtime/apiKeys.d.ts +20 -20
- package/dist/data-access/runtime/cascade-delete.d.ts +48 -1
- package/dist/data-access/runtime/cascade-delete.js +52 -2
- package/dist/data-access/runtime/conversations.d.ts +31 -31
- package/dist/data-access/runtime/github-work-app-installations.d.ts +261 -0
- package/dist/data-access/runtime/github-work-app-installations.js +457 -0
- package/dist/data-access/runtime/messages.d.ts +18 -18
- package/dist/data-access/runtime/tasks.d.ts +8 -8
- package/dist/db/manage/manage-schema.d.ts +398 -381
- package/dist/db/manage/manage-schema.js +1 -0
- package/dist/db/runtime/runtime-schema.d.ts +1009 -165
- package/dist/db/runtime/runtime-schema.js +173 -5
- package/dist/dolt/branch.js +1 -1
- package/dist/dolt/branches-api.js +1 -1
- package/dist/dolt/index.js +3 -3
- package/dist/dolt/migrate-all-branches.js +1 -1
- package/dist/dolt/ref-helpers.js +1 -1
- package/dist/dolt/ref-middleware.js +1 -1
- package/dist/dolt/ref-scope.js +1 -1
- package/dist/env.d.ts +6 -4
- package/dist/env.js +11 -10
- package/dist/index.d.ts +7 -6
- package/dist/index.js +11 -10
- package/dist/types/entities.d.ts +9 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/utility.d.ts +16 -2
- package/dist/validation/dolt-schemas.d.ts +1 -1
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +2 -2
- package/dist/validation/schemas.d.ts +3120 -1316
- package/dist/validation/schemas.js +48 -2
- package/drizzle/manage/0006_fixed_umar.sql +1 -0
- package/drizzle/manage/meta/0006_snapshot.json +3148 -0
- package/drizzle/manage/meta/_journal.json +7 -0
- package/drizzle/runtime/0010_previous_black_knight.sql +84 -0
- package/drizzle/runtime/meta/0010_snapshot.json +3066 -0
- package/drizzle/runtime/meta/_journal.json +7 -0
- package/package.json +1 -1
|
@@ -18,23 +18,24 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
18
18
|
scopes: ProjectScopeConfig;
|
|
19
19
|
toolId: string;
|
|
20
20
|
}) => Promise<{
|
|
21
|
+
tenantId: string;
|
|
22
|
+
projectId: string;
|
|
21
23
|
id: string;
|
|
22
24
|
name: string;
|
|
23
|
-
createdAt: string;
|
|
24
|
-
updatedAt: string;
|
|
25
25
|
description: string | null;
|
|
26
|
-
headers: Record<string, string> | null;
|
|
27
|
-
tenantId: string;
|
|
28
|
-
projectId: string;
|
|
29
26
|
config: {
|
|
30
27
|
type: "mcp";
|
|
31
28
|
mcp: ToolMcpConfig;
|
|
32
29
|
};
|
|
33
30
|
credentialReferenceId: string | null;
|
|
31
|
+
createdAt: string;
|
|
32
|
+
updatedAt: string;
|
|
33
|
+
headers: Record<string, string> | null;
|
|
34
34
|
credentialScope: string;
|
|
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;
|
|
@@ -74,23 +76,24 @@ declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
74
76
|
};
|
|
75
77
|
}>;
|
|
76
78
|
declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInsert) => Promise<{
|
|
79
|
+
tenantId: string;
|
|
80
|
+
projectId: string;
|
|
77
81
|
id: string;
|
|
78
82
|
name: string;
|
|
79
|
-
createdAt: string;
|
|
80
|
-
updatedAt: string;
|
|
81
83
|
description: string | null;
|
|
82
|
-
headers: Record<string, string> | null;
|
|
83
|
-
tenantId: string;
|
|
84
|
-
projectId: string;
|
|
85
84
|
config: {
|
|
86
85
|
type: "mcp";
|
|
87
86
|
mcp: ToolMcpConfig;
|
|
88
87
|
};
|
|
89
88
|
credentialReferenceId: string | null;
|
|
89
|
+
createdAt: string;
|
|
90
|
+
updatedAt: string;
|
|
91
|
+
headers: Record<string, string> | null;
|
|
90
92
|
credentialScope: string;
|
|
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;
|
|
@@ -129,14 +133,14 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
129
133
|
needsApproval?: boolean;
|
|
130
134
|
}> | null;
|
|
131
135
|
}) => Promise<{
|
|
132
|
-
id: string;
|
|
133
|
-
createdAt: string;
|
|
134
|
-
updatedAt: string;
|
|
135
|
-
headers: Record<string, string> | null;
|
|
136
136
|
tenantId: string;
|
|
137
137
|
projectId: string;
|
|
138
|
+
id: string;
|
|
138
139
|
agentId: string;
|
|
140
|
+
createdAt: string;
|
|
141
|
+
updatedAt: string;
|
|
139
142
|
toolId: string;
|
|
143
|
+
headers: Record<string, string> | null;
|
|
140
144
|
toolPolicies: Record<string, {
|
|
141
145
|
needsApproval?: boolean;
|
|
142
146
|
}> | null;
|
|
@@ -148,14 +152,14 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
|
|
|
148
152
|
subAgentId: string;
|
|
149
153
|
toolId: string;
|
|
150
154
|
}) => Promise<{
|
|
151
|
-
id: string;
|
|
152
|
-
createdAt: string;
|
|
153
|
-
updatedAt: string;
|
|
154
|
-
headers: Record<string, string> | null;
|
|
155
155
|
tenantId: string;
|
|
156
156
|
projectId: string;
|
|
157
|
+
id: string;
|
|
157
158
|
agentId: string;
|
|
159
|
+
createdAt: string;
|
|
160
|
+
updatedAt: string;
|
|
158
161
|
toolId: string;
|
|
162
|
+
headers: Record<string, string> | null;
|
|
159
163
|
toolPolicies: Record<string, {
|
|
160
164
|
needsApproval?: boolean;
|
|
161
165
|
}> | null;
|
|
@@ -176,14 +180,14 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
176
180
|
}> | null;
|
|
177
181
|
relationId?: string;
|
|
178
182
|
}) => Promise<{
|
|
179
|
-
id: string;
|
|
180
|
-
createdAt: string;
|
|
181
|
-
updatedAt: string;
|
|
182
|
-
headers: Record<string, string> | null;
|
|
183
183
|
tenantId: string;
|
|
184
184
|
projectId: string;
|
|
185
|
+
id: string;
|
|
185
186
|
agentId: string;
|
|
187
|
+
createdAt: string;
|
|
188
|
+
updatedAt: string;
|
|
186
189
|
toolId: string;
|
|
190
|
+
headers: Record<string, string> | null;
|
|
187
191
|
toolPolicies: Record<string, {
|
|
188
192
|
needsApproval?: boolean;
|
|
189
193
|
}> | null;
|
|
@@ -196,23 +200,24 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
196
200
|
declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
197
201
|
data: ToolInsert;
|
|
198
202
|
}) => Promise<{
|
|
203
|
+
tenantId: string;
|
|
204
|
+
projectId: string;
|
|
199
205
|
id: string;
|
|
200
206
|
name: string;
|
|
201
|
-
createdAt: string;
|
|
202
|
-
updatedAt: string;
|
|
203
207
|
description: string | null;
|
|
204
|
-
headers: Record<string, string> | null;
|
|
205
|
-
tenantId: string;
|
|
206
|
-
projectId: string;
|
|
207
208
|
config: {
|
|
208
209
|
type: "mcp";
|
|
209
210
|
mcp: ToolMcpConfig;
|
|
210
211
|
};
|
|
211
212
|
credentialReferenceId: string | null;
|
|
213
|
+
createdAt: string;
|
|
214
|
+
updatedAt: string;
|
|
215
|
+
headers: Record<string, string> | null;
|
|
212
216
|
credentialScope: string;
|
|
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
|
|
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" | "
|
|
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" | "
|
|
49
|
+
source: "literal" | "header" | "body";
|
|
50
50
|
required: boolean;
|
|
51
51
|
key?: string | undefined;
|
|
52
52
|
value?: string | undefined;
|
|
@@ -7,49 +7,49 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
7
7
|
scopes: ProjectScopeConfig;
|
|
8
8
|
id: string;
|
|
9
9
|
}) => Promise<{
|
|
10
|
-
id: string;
|
|
11
|
-
name: string | null;
|
|
12
|
-
createdAt: string;
|
|
13
|
-
updatedAt: string;
|
|
14
|
-
expiresAt: string | null;
|
|
15
10
|
tenantId: string;
|
|
16
11
|
projectId: string;
|
|
12
|
+
id: string;
|
|
13
|
+
name: string | null;
|
|
17
14
|
agentId: string;
|
|
18
15
|
publicId: string;
|
|
19
16
|
keyHash: string;
|
|
20
17
|
keyPrefix: string;
|
|
21
18
|
lastUsedAt: string | null;
|
|
22
|
-
|
|
23
|
-
declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
|
|
24
|
-
id: string;
|
|
25
|
-
name: string | null;
|
|
19
|
+
expiresAt: string | null;
|
|
26
20
|
createdAt: string;
|
|
27
21
|
updatedAt: string;
|
|
28
|
-
|
|
22
|
+
} | undefined>;
|
|
23
|
+
declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
|
|
29
24
|
tenantId: string;
|
|
30
25
|
projectId: string;
|
|
26
|
+
id: string;
|
|
27
|
+
name: string | null;
|
|
31
28
|
agentId: string;
|
|
32
29
|
publicId: string;
|
|
33
30
|
keyHash: string;
|
|
34
31
|
keyPrefix: string;
|
|
35
32
|
lastUsedAt: string | null;
|
|
33
|
+
expiresAt: string | null;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
updatedAt: string;
|
|
36
36
|
} | undefined>;
|
|
37
37
|
declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
38
38
|
scopes: ProjectScopeConfig;
|
|
39
39
|
agentId?: string;
|
|
40
40
|
}) => Promise<{
|
|
41
|
-
id: string;
|
|
42
|
-
name: string | null;
|
|
43
|
-
createdAt: string;
|
|
44
|
-
updatedAt: string;
|
|
45
|
-
expiresAt: string | null;
|
|
46
41
|
tenantId: string;
|
|
47
42
|
projectId: string;
|
|
43
|
+
id: string;
|
|
44
|
+
name: string | null;
|
|
48
45
|
agentId: string;
|
|
49
46
|
publicId: string;
|
|
50
47
|
keyHash: string;
|
|
51
48
|
keyPrefix: string;
|
|
52
49
|
lastUsedAt: string | null;
|
|
50
|
+
expiresAt: string | null;
|
|
51
|
+
createdAt: string;
|
|
52
|
+
updatedAt: string;
|
|
53
53
|
}[]>;
|
|
54
54
|
declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
55
55
|
scopes: ProjectScopeConfig;
|
|
@@ -65,18 +65,18 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
65
65
|
};
|
|
66
66
|
}>;
|
|
67
67
|
declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
|
|
68
|
-
id: string;
|
|
69
|
-
name: string | null;
|
|
70
|
-
createdAt: string;
|
|
71
|
-
updatedAt: string;
|
|
72
|
-
expiresAt: string | null;
|
|
73
68
|
tenantId: string;
|
|
74
69
|
projectId: string;
|
|
70
|
+
id: string;
|
|
71
|
+
name: string | null;
|
|
75
72
|
agentId: string;
|
|
76
73
|
publicId: string;
|
|
77
74
|
keyHash: string;
|
|
78
75
|
keyPrefix: string;
|
|
79
76
|
lastUsedAt: string | null;
|
|
77
|
+
expiresAt: string | null;
|
|
78
|
+
createdAt: string;
|
|
79
|
+
updatedAt: string;
|
|
80
80
|
}>;
|
|
81
81
|
declare const updateApiKey: (db: AgentsRunDatabaseClient) => (params: {
|
|
82
82
|
scopes: ProjectScopeConfig;
|
|
@@ -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 };
|
|
@@ -15,20 +15,20 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
15
15
|
total: number;
|
|
16
16
|
}>;
|
|
17
17
|
declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
|
|
18
|
+
tenantId: string;
|
|
19
|
+
projectId: string;
|
|
18
20
|
id: string;
|
|
21
|
+
title: string | null;
|
|
22
|
+
agentId: string | null;
|
|
19
23
|
createdAt: string;
|
|
20
24
|
updatedAt: string;
|
|
25
|
+
userId: string | null;
|
|
26
|
+
metadata: ConversationMetadata | null;
|
|
21
27
|
ref: {
|
|
22
|
-
type: "
|
|
28
|
+
type: "commit" | "tag" | "branch";
|
|
23
29
|
name: string;
|
|
24
30
|
hash: string;
|
|
25
31
|
} | null;
|
|
26
|
-
userId: string | null;
|
|
27
|
-
metadata: ConversationMetadata | null;
|
|
28
|
-
title: string | null;
|
|
29
|
-
tenantId: string;
|
|
30
|
-
projectId: string;
|
|
31
|
-
agentId: string | null;
|
|
32
32
|
activeSubAgentId: string;
|
|
33
33
|
lastContextResolution: string | null;
|
|
34
34
|
}>;
|
|
@@ -43,7 +43,7 @@ declare const updateConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
43
43
|
agentId: string | null;
|
|
44
44
|
activeSubAgentId: string;
|
|
45
45
|
ref: {
|
|
46
|
-
type: "
|
|
46
|
+
type: "commit" | "tag" | "branch";
|
|
47
47
|
name: string;
|
|
48
48
|
hash: string;
|
|
49
49
|
} | null;
|
|
@@ -69,7 +69,7 @@ declare const updateConversationActiveSubAgent: (db: AgentsRunDatabaseClient) =>
|
|
|
69
69
|
agentId: string | null;
|
|
70
70
|
activeSubAgentId: string;
|
|
71
71
|
ref: {
|
|
72
|
-
type: "
|
|
72
|
+
type: "commit" | "tag" | "branch";
|
|
73
73
|
name: string;
|
|
74
74
|
hash: string;
|
|
75
75
|
} | null;
|
|
@@ -84,20 +84,20 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
84
84
|
scopes: ProjectScopeConfig;
|
|
85
85
|
conversationId: string;
|
|
86
86
|
}) => Promise<{
|
|
87
|
+
tenantId: string;
|
|
88
|
+
projectId: string;
|
|
87
89
|
id: string;
|
|
90
|
+
title: string | null;
|
|
91
|
+
agentId: string | null;
|
|
88
92
|
createdAt: string;
|
|
89
93
|
updatedAt: string;
|
|
94
|
+
userId: string | null;
|
|
95
|
+
metadata: ConversationMetadata | null;
|
|
90
96
|
ref: {
|
|
91
|
-
type: "
|
|
97
|
+
type: "commit" | "tag" | "branch";
|
|
92
98
|
name: string;
|
|
93
99
|
hash: string;
|
|
94
100
|
} | null;
|
|
95
|
-
userId: string | null;
|
|
96
|
-
metadata: ConversationMetadata | null;
|
|
97
|
-
title: string | null;
|
|
98
|
-
tenantId: string;
|
|
99
|
-
projectId: string;
|
|
100
|
-
agentId: string | null;
|
|
101
101
|
activeSubAgentId: string;
|
|
102
102
|
lastContextResolution: string | null;
|
|
103
103
|
} | undefined>;
|
|
@@ -107,7 +107,7 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
107
107
|
tenantId: string;
|
|
108
108
|
id: string;
|
|
109
109
|
ref: {
|
|
110
|
-
type: "
|
|
110
|
+
type: "commit" | "tag" | "branch";
|
|
111
111
|
name: string;
|
|
112
112
|
hash: string;
|
|
113
113
|
};
|
|
@@ -120,20 +120,20 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
120
120
|
metadata?: ConversationMetadata | null | undefined;
|
|
121
121
|
contextConfigId?: string | undefined;
|
|
122
122
|
} | {
|
|
123
|
+
tenantId: string;
|
|
124
|
+
projectId: string;
|
|
123
125
|
id: string;
|
|
126
|
+
title: string | null;
|
|
127
|
+
agentId: string | null;
|
|
124
128
|
createdAt: string;
|
|
125
129
|
updatedAt: string;
|
|
130
|
+
userId: string | null;
|
|
131
|
+
metadata: ConversationMetadata | null;
|
|
126
132
|
ref: {
|
|
127
|
-
type: "
|
|
133
|
+
type: "commit" | "tag" | "branch";
|
|
128
134
|
name: string;
|
|
129
135
|
hash: string;
|
|
130
136
|
} | null;
|
|
131
|
-
userId: string | null;
|
|
132
|
-
metadata: ConversationMetadata | null;
|
|
133
|
-
title: string | null;
|
|
134
|
-
tenantId: string;
|
|
135
|
-
projectId: string;
|
|
136
|
-
agentId: string | null;
|
|
137
137
|
activeSubAgentId: string;
|
|
138
138
|
lastContextResolution: string | null;
|
|
139
139
|
}>;
|
|
@@ -152,20 +152,20 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
152
152
|
scopes: ProjectScopeConfig;
|
|
153
153
|
conversationId: string;
|
|
154
154
|
}) => Promise<{
|
|
155
|
+
tenantId: string;
|
|
156
|
+
projectId: string;
|
|
155
157
|
id: string;
|
|
158
|
+
title: string | null;
|
|
159
|
+
agentId: string | null;
|
|
156
160
|
createdAt: string;
|
|
157
161
|
updatedAt: string;
|
|
162
|
+
userId: string | null;
|
|
163
|
+
metadata: ConversationMetadata | null;
|
|
158
164
|
ref: {
|
|
159
|
-
type: "
|
|
165
|
+
type: "commit" | "tag" | "branch";
|
|
160
166
|
name: string;
|
|
161
167
|
hash: string;
|
|
162
168
|
} | null;
|
|
163
|
-
userId: string | null;
|
|
164
|
-
metadata: ConversationMetadata | null;
|
|
165
|
-
title: string | null;
|
|
166
|
-
tenantId: string;
|
|
167
|
-
projectId: string;
|
|
168
|
-
agentId: string | null;
|
|
169
169
|
activeSubAgentId: string;
|
|
170
170
|
lastContextResolution: string | null;
|
|
171
171
|
} | undefined>;
|