@inkeep/agents-core 0.58.3 → 0.58.4

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 (37) hide show
  1. package/dist/auth/auth.d.ts +28 -28
  2. package/dist/auth/permissions.d.ts +13 -13
  3. package/dist/constants/models.d.ts +34 -2
  4. package/dist/constants/models.js +37 -5
  5. package/dist/data-access/manage/agents.d.ts +31 -31
  6. package/dist/data-access/manage/artifactComponents.d.ts +16 -16
  7. package/dist/data-access/manage/contextConfigs.d.ts +12 -12
  8. package/dist/data-access/manage/dataComponents.d.ts +6 -6
  9. package/dist/data-access/manage/functionTools.d.ts +18 -18
  10. package/dist/data-access/manage/skills.d.ts +14 -14
  11. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
  12. package/dist/data-access/manage/subAgentRelations.d.ts +28 -28
  13. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +24 -24
  14. package/dist/data-access/manage/subAgents.d.ts +21 -21
  15. package/dist/data-access/manage/tools.d.ts +24 -24
  16. package/dist/data-access/manage/tools.js +2 -0
  17. package/dist/data-access/manage/triggers.d.ts +2 -2
  18. package/dist/data-access/runtime/apiKeys.d.ts +16 -16
  19. package/dist/data-access/runtime/cascade-delete.js +2 -2
  20. package/dist/data-access/runtime/conversations.d.ts +23 -23
  21. package/dist/data-access/runtime/github-work-app-installations.d.ts +25 -5
  22. package/dist/data-access/runtime/github-work-app-installations.js +20 -17
  23. package/dist/data-access/runtime/messages.d.ts +24 -24
  24. package/dist/data-access/runtime/tasks.d.ts +6 -6
  25. package/dist/db/manage/manage-schema.d.ts +453 -453
  26. package/dist/db/runtime/runtime-schema.d.ts +318 -318
  27. package/dist/db/runtime/runtime-schema.js +5 -1
  28. package/dist/middleware/no-auth.d.ts +2 -2
  29. package/dist/setup/setup.js +14 -3
  30. package/dist/utils/error.d.ts +51 -51
  31. package/dist/validation/dolt-schemas.d.ts +1 -1
  32. package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
  33. package/dist/validation/schemas.d.ts +606 -606
  34. package/drizzle/runtime/0021_careful_xorn.sql +2 -0
  35. package/drizzle/runtime/meta/0021_snapshot.json +4124 -0
  36. package/drizzle/runtime/meta/_journal.json +7 -0
  37. package/package.json +1 -1
@@ -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
22
  id: string;
24
23
  name: string;
24
+ description: string | null;
25
+ tenantId: string;
26
+ projectId: string;
25
27
  createdAt: string;
26
28
  updatedAt: string;
27
- projectId: string;
28
- tenantId: 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
80
  id: string;
82
81
  name: string;
82
+ description: string | null;
83
+ tenantId: string;
84
+ projectId: string;
83
85
  createdAt: string;
84
86
  updatedAt: string;
85
- projectId: string;
86
- tenantId: string;
87
87
  headers: Record<string, string> | null;
88
88
  config: {
89
89
  type: "mcp";
@@ -134,18 +134,18 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
134
134
  needsApproval?: boolean;
135
135
  }> | null;
136
136
  }) => Promise<{
137
- subAgentId: string;
138
137
  id: string;
139
- createdAt: string;
140
- updatedAt: string;
141
- projectId: string;
142
138
  tenantId: string;
139
+ projectId: string;
143
140
  agentId: string;
144
- headers: Record<string, string> | null;
141
+ createdAt: string;
142
+ updatedAt: string;
145
143
  toolId: string;
144
+ headers: Record<string, string> | null;
146
145
  toolPolicies: Record<string, {
147
146
  needsApproval?: boolean;
148
147
  }> | null;
148
+ subAgentId: string;
149
149
  selectedTools: string[] | null;
150
150
  }>;
151
151
  declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params: {
@@ -153,18 +153,18 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
153
153
  subAgentId: string;
154
154
  toolId: string;
155
155
  }) => Promise<{
156
- subAgentId: string;
157
156
  id: string;
158
- createdAt: string;
159
- updatedAt: string;
160
- projectId: string;
161
157
  tenantId: string;
158
+ projectId: string;
162
159
  agentId: string;
163
- headers: Record<string, string> | null;
160
+ createdAt: string;
161
+ updatedAt: string;
164
162
  toolId: string;
163
+ headers: Record<string, string> | null;
165
164
  toolPolicies: Record<string, {
166
165
  needsApproval?: boolean;
167
166
  }> | null;
167
+ subAgentId: string;
168
168
  selectedTools: string[] | null;
169
169
  }>;
170
170
  /**
@@ -181,18 +181,18 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
181
181
  }> | null;
182
182
  relationId?: string;
183
183
  }) => Promise<{
184
- subAgentId: string;
185
184
  id: string;
186
- createdAt: string;
187
- updatedAt: string;
188
- projectId: string;
189
185
  tenantId: string;
186
+ projectId: string;
190
187
  agentId: string;
191
- headers: Record<string, string> | null;
188
+ createdAt: string;
189
+ updatedAt: string;
192
190
  toolId: string;
191
+ headers: Record<string, string> | null;
193
192
  toolPolicies: Record<string, {
194
193
  needsApproval?: boolean;
195
194
  }> | null;
195
+ subAgentId: string;
196
196
  selectedTools: string[] | null;
197
197
  }>;
198
198
  /**
@@ -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
204
  id: string;
206
205
  name: string;
206
+ description: string | null;
207
+ tenantId: string;
208
+ projectId: string;
207
209
  createdAt: string;
208
210
  updatedAt: string;
209
- projectId: string;
210
- tenantId: string;
211
211
  headers: Record<string, string> | null;
212
212
  config: {
213
213
  type: "mcp";
@@ -123,6 +123,8 @@ const discoverToolsFromServer = async (tool, credentialReference, credentialStor
123
123
  if (isGithubWorkAppTool(tool)) serverConfig.headers = {
124
124
  ...serverConfig.headers,
125
125
  "x-inkeep-tool-id": tool.id,
126
+ "x-inkeep-tenant-id": tool.tenantId,
127
+ "x-inkeep-project-id": tool.projectId,
126
128
  Authorization: `Bearer ${env.GITHUB_MCP_API_KEY}`
127
129
  };
128
130
  if (isSlackWorkAppTool(tool)) serverConfig.headers = {
@@ -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" | "header" | "body";
43
+ source: "query" | "body" | "header";
44
44
  key: string;
45
45
  prefix?: string | undefined;
46
46
  regex?: string | undefined;
47
47
  };
48
48
  signedComponents: {
49
- source: "literal" | "header" | "body";
49
+ source: "literal" | "body" | "header";
50
50
  required: boolean;
51
51
  key?: string | undefined;
52
52
  value?: string | undefined;
@@ -10,30 +10,30 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
10
10
  }) => Promise<{
11
11
  id: string;
12
12
  name: string | null;
13
- createdAt: string;
14
- updatedAt: string;
15
- projectId: string;
16
13
  tenantId: string;
14
+ projectId: string;
17
15
  agentId: string;
16
+ createdAt: string;
17
+ updatedAt: 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
- createdAt: string;
28
- updatedAt: string;
29
- projectId: string;
30
27
  tenantId: string;
28
+ projectId: string;
31
29
  agentId: string;
30
+ createdAt: string;
31
+ updatedAt: 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;
@@ -41,16 +41,16 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
41
41
  }) => Promise<{
42
42
  id: string;
43
43
  name: string | null;
44
- createdAt: string;
45
- updatedAt: string;
46
- projectId: string;
47
44
  tenantId: string;
45
+ projectId: string;
48
46
  agentId: string;
47
+ createdAt: string;
48
+ updatedAt: 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;
@@ -68,16 +68,16 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
68
68
  declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
69
69
  id: string;
70
70
  name: string | null;
71
- createdAt: string;
72
- updatedAt: string;
73
- projectId: string;
74
71
  tenantId: string;
72
+ projectId: string;
75
73
  agentId: string;
74
+ createdAt: string;
75
+ updatedAt: 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;
@@ -139,8 +139,8 @@ const cascadeDeleteByContextConfig = (db) => async (params) => {
139
139
  */
140
140
  const cascadeDeleteByTool = (db) => async (params) => {
141
141
  const { toolId, tenantId, projectId } = params;
142
- const repositoryAccessResult = await db.delete(workAppGitHubMcpToolRepositoryAccess).where(eq(workAppGitHubMcpToolRepositoryAccess.toolId, toolId)).returning();
143
- const accessModeResult = await db.delete(workAppGitHubMcpToolAccessMode).where(eq(workAppGitHubMcpToolAccessMode.toolId, toolId)).returning();
142
+ const repositoryAccessResult = await db.delete(workAppGitHubMcpToolRepositoryAccess).where(and(eq(workAppGitHubMcpToolRepositoryAccess.tenantId, tenantId), eq(workAppGitHubMcpToolRepositoryAccess.projectId, projectId), eq(workAppGitHubMcpToolRepositoryAccess.toolId, toolId))).returning();
143
+ const accessModeResult = await db.delete(workAppGitHubMcpToolAccessMode).where(and(eq(workAppGitHubMcpToolAccessMode.tenantId, tenantId), eq(workAppGitHubMcpToolAccessMode.projectId, projectId), eq(workAppGitHubMcpToolAccessMode.toolId, toolId))).returning();
144
144
  const slackMcpDeleted = await deleteSlackMcpToolAccessConfig(db)({
145
145
  tenantId,
146
146
  projectId,
@@ -16,17 +16,17 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
16
16
  total: number;
17
17
  }>;
18
18
  declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
19
- title: string | null;
20
19
  id: string;
20
+ tenantId: string;
21
+ projectId: string;
22
+ agentId: string | null;
23
+ title: string | null;
21
24
  createdAt: string;
22
25
  updatedAt: string;
23
- projectId: string;
24
- tenantId: string;
25
26
  metadata: ConversationMetadata | null;
26
- agentId: string | null;
27
27
  userId: string | null;
28
28
  ref: {
29
- type: "commit" | "tag" | "branch";
29
+ type: "tag" | "commit" | "branch";
30
30
  name: string;
31
31
  hash: string;
32
32
  } | null;
@@ -44,7 +44,7 @@ declare const updateConversation: (db: AgentsRunDatabaseClient) => (params: {
44
44
  agentId: string | null;
45
45
  activeSubAgentId: string;
46
46
  ref: {
47
- type: "commit" | "tag" | "branch";
47
+ type: "tag" | "commit" | "branch";
48
48
  name: string;
49
49
  hash: string;
50
50
  } | null;
@@ -70,7 +70,7 @@ declare const updateConversationActiveSubAgent: (db: AgentsRunDatabaseClient) =>
70
70
  agentId: string | null;
71
71
  activeSubAgentId: string;
72
72
  ref: {
73
- type: "commit" | "tag" | "branch";
73
+ type: "tag" | "commit" | "branch";
74
74
  name: string;
75
75
  hash: string;
76
76
  } | null;
@@ -85,17 +85,17 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
85
85
  scopes: ProjectScopeConfig;
86
86
  conversationId: string;
87
87
  }) => Promise<{
88
- title: string | null;
89
88
  id: string;
89
+ tenantId: string;
90
+ projectId: string;
91
+ agentId: string | null;
92
+ title: string | null;
90
93
  createdAt: string;
91
94
  updatedAt: string;
92
- projectId: string;
93
- tenantId: string;
94
95
  metadata: ConversationMetadata | null;
95
- agentId: string | null;
96
96
  userId: string | null;
97
97
  ref: {
98
- type: "commit" | "tag" | "branch";
98
+ type: "tag" | "commit" | "branch";
99
99
  name: string;
100
100
  hash: string;
101
101
  } | null;
@@ -108,7 +108,7 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
108
108
  tenantId: string;
109
109
  id: string;
110
110
  ref: {
111
- type: "commit" | "tag" | "branch";
111
+ type: "tag" | "commit" | "branch";
112
112
  name: string;
113
113
  hash: string;
114
114
  };
@@ -121,17 +121,17 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
121
121
  metadata?: ConversationMetadata | null | undefined;
122
122
  contextConfigId?: string | undefined;
123
123
  } | {
124
- title: string | null;
125
124
  id: string;
125
+ tenantId: string;
126
+ projectId: string;
127
+ agentId: string | null;
128
+ title: string | null;
126
129
  createdAt: string;
127
130
  updatedAt: string;
128
- projectId: string;
129
- tenantId: string;
130
131
  metadata: ConversationMetadata | null;
131
- agentId: string | null;
132
132
  userId: string | null;
133
133
  ref: {
134
- type: "commit" | "tag" | "branch";
134
+ type: "tag" | "commit" | "branch";
135
135
  name: string;
136
136
  hash: string;
137
137
  } | null;
@@ -153,17 +153,17 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
153
153
  scopes: ProjectScopeConfig;
154
154
  conversationId: string;
155
155
  }) => Promise<{
156
- title: string | null;
157
156
  id: string;
157
+ tenantId: string;
158
+ projectId: string;
159
+ agentId: string | null;
160
+ title: string | null;
158
161
  createdAt: string;
159
162
  updatedAt: string;
160
- projectId: string;
161
- tenantId: string;
162
163
  metadata: ConversationMetadata | null;
163
- agentId: string | null;
164
164
  userId: string | null;
165
165
  ref: {
166
- type: "commit" | "tag" | "branch";
166
+ type: "tag" | "commit" | "branch";
167
167
  name: string;
168
168
  hash: string;
169
169
  } | null;
@@ -187,7 +187,11 @@ declare const setMcpToolRepositoryAccess: (db: AgentsRunDatabaseClient) => (para
187
187
  * Get MCP tool repository access entries
188
188
  * These entries are used when mode='selected'. Check mode via getMcpToolAccessMode().
189
189
  */
190
- declare const getMcpToolRepositoryAccess: (db: AgentsRunDatabaseClient) => (toolId: string) => Promise<{
190
+ declare const getMcpToolRepositoryAccess: (db: AgentsRunDatabaseClient) => (scope: {
191
+ tenantId: string;
192
+ projectId: string;
193
+ toolId: string;
194
+ }) => Promise<{
191
195
  id: string;
192
196
  toolId: string;
193
197
  tenantId: string;
@@ -201,7 +205,11 @@ declare const getMcpToolRepositoryAccess: (db: AgentsRunDatabaseClient) => (tool
201
205
  * If the tool's access mode is 'all', returns all repositories the project has access to.
202
206
  * If mode is 'selected' (or not set), returns only explicitly granted repositories.
203
207
  */
204
- declare const getMcpToolRepositoryAccessWithDetails: (db: AgentsRunDatabaseClient) => (toolId: string) => Promise<(WorkAppGitHubRepositorySelect & {
208
+ declare const getMcpToolRepositoryAccessWithDetails: (db: AgentsRunDatabaseClient) => (scope: {
209
+ tenantId: string;
210
+ projectId: string;
211
+ toolId: string;
212
+ }) => Promise<(WorkAppGitHubRepositorySelect & {
205
213
  accessId: string;
206
214
  installationAccountLogin: string;
207
215
  installationId: string;
@@ -209,7 +217,11 @@ declare const getMcpToolRepositoryAccessWithDetails: (db: AgentsRunDatabaseClien
209
217
  /**
210
218
  * Remove all MCP tool repository access for a specific tool
211
219
  */
212
- declare const clearMcpToolRepositoryAccess: (db: AgentsRunDatabaseClient) => (toolId: string) => Promise<number>;
220
+ declare const clearMcpToolRepositoryAccess: (db: AgentsRunDatabaseClient) => (scope: {
221
+ tenantId: string;
222
+ projectId: string;
223
+ toolId: string;
224
+ }) => Promise<number>;
213
225
  declare const isGithubWorkAppTool: (tool: ToolSelect | McpTool) => boolean | undefined;
214
226
  type WorkAppGitHubAccessMode = 'all' | 'selected';
215
227
  /**
@@ -252,10 +264,18 @@ declare const setMcpToolAccessMode: (db: AgentsRunDatabaseClient) => (params: {
252
264
  * Get the access mode for an MCP tool's GitHub repository access.
253
265
  * Returns 'selected' if no mode is explicitly set (fail-safe default).
254
266
  */
255
- declare const getMcpToolAccessMode: (db: AgentsRunDatabaseClient) => (toolId: string) => Promise<WorkAppGitHubAccessMode>;
267
+ declare const getMcpToolAccessMode: (db: AgentsRunDatabaseClient) => (scope: {
268
+ tenantId: string;
269
+ projectId: string;
270
+ toolId: string;
271
+ }) => Promise<WorkAppGitHubAccessMode>;
256
272
  /**
257
273
  * Delete the access mode entry for an MCP tool
258
274
  */
259
- declare const deleteMcpToolAccessMode: (db: AgentsRunDatabaseClient) => (toolId: string) => Promise<boolean>;
275
+ declare const deleteMcpToolAccessMode: (db: AgentsRunDatabaseClient) => (scope: {
276
+ tenantId: string;
277
+ projectId: string;
278
+ toolId: string;
279
+ }) => Promise<boolean>;
260
280
  //#endregion
261
281
  export { WorkAppGitHubAccessMode, addRepositories, checkProjectRepositoryAccess, clearMcpToolRepositoryAccess, clearProjectRepositoryAccess, createInstallation, deleteInstallation, deleteMcpToolAccessMode, deleteProjectAccessMode, disconnectInstallation, getInstallationByGitHubId, getInstallationById, getInstallationsByTenantId, getMcpToolAccessMode, getMcpToolRepositoryAccess, getMcpToolRepositoryAccessWithDetails, getProjectAccessMode, getProjectRepositoryAccess, getProjectRepositoryAccessWithDetails, getRepositoriesByInstallationId, getRepositoriesByTenantId, getRepositoryByFullName, getRepositoryById, getRepositoryCount, getRepositoryCountsByTenantId, isGithubWorkAppTool, removeRepositories, setMcpToolAccessMode, setMcpToolRepositoryAccess, setProjectAccessMode, setProjectRepositoryAccess, syncRepositories, updateInstallationStatus, updateInstallationStatusByGitHubId, validateRepositoryOwnership };
@@ -327,7 +327,7 @@ const getRepositoryCountsByTenantId = (db) => async (params) => {
327
327
  */
328
328
  const setMcpToolRepositoryAccess = (db) => async (params) => {
329
329
  const now = (/* @__PURE__ */ new Date()).toISOString();
330
- await db.delete(workAppGitHubMcpToolRepositoryAccess).where(eq(workAppGitHubMcpToolRepositoryAccess.toolId, params.toolId));
330
+ await db.delete(workAppGitHubMcpToolRepositoryAccess).where(and(eq(workAppGitHubMcpToolRepositoryAccess.tenantId, params.tenantId), eq(workAppGitHubMcpToolRepositoryAccess.projectId, params.projectId), eq(workAppGitHubMcpToolRepositoryAccess.toolId, params.toolId)));
331
331
  if (params.repositoryIds.length > 0) await db.insert(workAppGitHubMcpToolRepositoryAccess).values(params.repositoryIds.map((repoId) => ({
332
332
  id: generateId(),
333
333
  toolId: params.toolId,
@@ -342,23 +342,22 @@ const setMcpToolRepositoryAccess = (db) => async (params) => {
342
342
  * Get MCP tool repository access entries
343
343
  * These entries are used when mode='selected'. Check mode via getMcpToolAccessMode().
344
344
  */
345
- const getMcpToolRepositoryAccess = (db) => async (toolId) => {
346
- return await db.select().from(workAppGitHubMcpToolRepositoryAccess).where(eq(workAppGitHubMcpToolRepositoryAccess.toolId, toolId));
345
+ const getMcpToolRepositoryAccess = (db) => async (scope) => {
346
+ return await db.select().from(workAppGitHubMcpToolRepositoryAccess).where(and(eq(workAppGitHubMcpToolRepositoryAccess.tenantId, scope.tenantId), eq(workAppGitHubMcpToolRepositoryAccess.projectId, scope.projectId), eq(workAppGitHubMcpToolRepositoryAccess.toolId, scope.toolId)));
347
347
  };
348
348
  /**
349
349
  * Get MCP tool repository access with full repository details.
350
350
  * If the tool's access mode is 'all', returns all repositories the project has access to.
351
351
  * If mode is 'selected' (or not set), returns only explicitly granted repositories.
352
352
  */
353
- const getMcpToolRepositoryAccessWithDetails = (db) => async (toolId) => {
354
- const accessMode = (await db.select({
353
+ const getMcpToolRepositoryAccessWithDetails = (db) => async (scope) => {
354
+ if ((await db.select({
355
355
  mode: workAppGitHubMcpToolAccessMode.mode,
356
356
  projectId: workAppGitHubMcpToolAccessMode.projectId,
357
357
  tenantId: workAppGitHubMcpToolAccessMode.tenantId
358
- }).from(workAppGitHubMcpToolAccessMode).where(eq(workAppGitHubMcpToolAccessMode.toolId, toolId)).limit(1))[0];
359
- if (accessMode?.mode === "all") return getProjectRepositoryAccessWithDetails(db)({
360
- tenantId: accessMode.tenantId,
361
- projectId: accessMode.projectId
358
+ }).from(workAppGitHubMcpToolAccessMode).where(and(eq(workAppGitHubMcpToolAccessMode.tenantId, scope.tenantId), eq(workAppGitHubMcpToolAccessMode.projectId, scope.projectId), eq(workAppGitHubMcpToolAccessMode.toolId, scope.toolId))).limit(1))[0]?.mode === "all") return getProjectRepositoryAccessWithDetails(db)({
359
+ tenantId: scope.tenantId,
360
+ projectId: scope.projectId
362
361
  });
363
362
  return await db.select({
364
363
  accessId: workAppGitHubMcpToolRepositoryAccess.id,
@@ -372,13 +371,13 @@ const getMcpToolRepositoryAccessWithDetails = (db) => async (toolId) => {
372
371
  createdAt: workAppGitHubRepositories.createdAt,
373
372
  updatedAt: workAppGitHubRepositories.updatedAt,
374
373
  installationAccountLogin: workAppGitHubInstallations.accountLogin
375
- }).from(workAppGitHubMcpToolRepositoryAccess).innerJoin(workAppGitHubRepositories, eq(workAppGitHubMcpToolRepositoryAccess.repositoryDbId, workAppGitHubRepositories.id)).innerJoin(workAppGitHubInstallations, eq(workAppGitHubRepositories.installationDbId, workAppGitHubInstallations.id)).where(eq(workAppGitHubMcpToolRepositoryAccess.toolId, toolId));
374
+ }).from(workAppGitHubMcpToolRepositoryAccess).innerJoin(workAppGitHubRepositories, eq(workAppGitHubMcpToolRepositoryAccess.repositoryDbId, workAppGitHubRepositories.id)).innerJoin(workAppGitHubInstallations, eq(workAppGitHubRepositories.installationDbId, workAppGitHubInstallations.id)).where(and(eq(workAppGitHubMcpToolRepositoryAccess.tenantId, scope.tenantId), eq(workAppGitHubMcpToolRepositoryAccess.projectId, scope.projectId), eq(workAppGitHubMcpToolRepositoryAccess.toolId, scope.toolId)));
376
375
  };
377
376
  /**
378
377
  * Remove all MCP tool repository access for a specific tool
379
378
  */
380
- const clearMcpToolRepositoryAccess = (db) => async (toolId) => {
381
- return (await db.delete(workAppGitHubMcpToolRepositoryAccess).where(eq(workAppGitHubMcpToolRepositoryAccess.toolId, toolId)).returning()).length;
379
+ const clearMcpToolRepositoryAccess = (db) => async (scope) => {
380
+ return (await db.delete(workAppGitHubMcpToolRepositoryAccess).where(and(eq(workAppGitHubMcpToolRepositoryAccess.tenantId, scope.tenantId), eq(workAppGitHubMcpToolRepositoryAccess.projectId, scope.projectId), eq(workAppGitHubMcpToolRepositoryAccess.toolId, scope.toolId))).returning()).length;
382
381
  };
383
382
  const isGithubWorkAppTool = (tool) => {
384
383
  return tool.isWorkApp && tool.config.mcp.server.url.includes("/github/mcp");
@@ -432,7 +431,11 @@ const setMcpToolAccessMode = (db) => async (params) => {
432
431
  createdAt: now,
433
432
  updatedAt: now
434
433
  }).onConflictDoUpdate({
435
- target: [workAppGitHubMcpToolAccessMode.toolId],
434
+ target: [
435
+ workAppGitHubMcpToolAccessMode.tenantId,
436
+ workAppGitHubMcpToolAccessMode.projectId,
437
+ workAppGitHubMcpToolAccessMode.toolId
438
+ ],
436
439
  set: {
437
440
  mode: params.mode,
438
441
  updatedAt: now
@@ -443,14 +446,14 @@ const setMcpToolAccessMode = (db) => async (params) => {
443
446
  * Get the access mode for an MCP tool's GitHub repository access.
444
447
  * Returns 'selected' if no mode is explicitly set (fail-safe default).
445
448
  */
446
- const getMcpToolAccessMode = (db) => async (toolId) => {
447
- return (await db.select({ mode: workAppGitHubMcpToolAccessMode.mode }).from(workAppGitHubMcpToolAccessMode).where(eq(workAppGitHubMcpToolAccessMode.toolId, toolId)).limit(1))[0]?.mode ?? "selected";
449
+ const getMcpToolAccessMode = (db) => async (scope) => {
450
+ return (await db.select({ mode: workAppGitHubMcpToolAccessMode.mode }).from(workAppGitHubMcpToolAccessMode).where(and(eq(workAppGitHubMcpToolAccessMode.tenantId, scope.tenantId), eq(workAppGitHubMcpToolAccessMode.projectId, scope.projectId), eq(workAppGitHubMcpToolAccessMode.toolId, scope.toolId))).limit(1))[0]?.mode ?? "selected";
448
451
  };
449
452
  /**
450
453
  * Delete the access mode entry for an MCP tool
451
454
  */
452
- const deleteMcpToolAccessMode = (db) => async (toolId) => {
453
- return (await db.delete(workAppGitHubMcpToolAccessMode).where(eq(workAppGitHubMcpToolAccessMode.toolId, toolId)).returning()).length > 0;
455
+ const deleteMcpToolAccessMode = (db) => async (scope) => {
456
+ return (await db.delete(workAppGitHubMcpToolAccessMode).where(and(eq(workAppGitHubMcpToolAccessMode.tenantId, scope.tenantId), eq(workAppGitHubMcpToolAccessMode.projectId, scope.projectId), eq(workAppGitHubMcpToolAccessMode.toolId, scope.toolId))).returning()).length > 0;
454
457
  };
455
458
 
456
459
  //#endregion
@@ -10,21 +10,21 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
10
10
  scopes: ProjectScopeConfig;
11
11
  messageId: string;
12
12
  }) => Promise<{
13
+ id: string;
14
+ tenantId: string;
15
+ projectId: string;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ metadata: MessageMetadata | null;
19
+ content: MessageContent;
20
+ role: string;
13
21
  fromSubAgentId: string | null;
14
22
  toSubAgentId: string | null;
15
23
  fromExternalAgentId: string | null;
16
24
  toExternalAgentId: string | null;
17
25
  taskId: string | null;
18
26
  a2aTaskId: string | null;
19
- id: string;
20
- createdAt: string;
21
- updatedAt: string;
22
- projectId: string;
23
- tenantId: string;
24
- metadata: MessageMetadata | null;
25
- content: MessageContent;
26
27
  conversationId: string;
27
- role: string;
28
28
  fromTeamAgentId: string | null;
29
29
  toTeamAgentId: string | null;
30
30
  visibility: string;
@@ -141,21 +141,21 @@ declare const getVisibleMessages: (db: AgentsRunDatabaseClient) => (params: {
141
141
  id: string;
142
142
  }[]>;
143
143
  declare const createMessage: (db: AgentsRunDatabaseClient) => (params: MessageInsert) => Promise<{
144
+ id: string;
145
+ tenantId: string;
146
+ projectId: string;
147
+ createdAt: string;
148
+ updatedAt: string;
149
+ metadata: MessageMetadata | null;
150
+ content: MessageContent;
151
+ role: string;
144
152
  fromSubAgentId: string | null;
145
153
  toSubAgentId: string | null;
146
154
  fromExternalAgentId: string | null;
147
155
  toExternalAgentId: string | null;
148
156
  taskId: string | null;
149
157
  a2aTaskId: string | null;
150
- id: string;
151
- createdAt: string;
152
- updatedAt: string;
153
- projectId: string;
154
- tenantId: string;
155
- metadata: MessageMetadata | null;
156
- content: MessageContent;
157
158
  conversationId: string;
158
- role: string;
159
159
  fromTeamAgentId: string | null;
160
160
  toTeamAgentId: string | null;
161
161
  visibility: string;
@@ -194,21 +194,21 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
194
194
  scopes: ProjectScopeConfig;
195
195
  messageId: string;
196
196
  }) => Promise<{
197
+ id: string;
198
+ tenantId: string;
199
+ projectId: string;
200
+ createdAt: string;
201
+ updatedAt: string;
202
+ metadata: MessageMetadata | null;
203
+ content: MessageContent;
204
+ role: string;
197
205
  fromSubAgentId: string | null;
198
206
  toSubAgentId: string | null;
199
207
  fromExternalAgentId: string | null;
200
208
  toExternalAgentId: string | null;
201
209
  taskId: string | null;
202
210
  a2aTaskId: string | null;
203
- id: string;
204
- createdAt: string;
205
- updatedAt: string;
206
- projectId: string;
207
- tenantId: string;
208
- metadata: MessageMetadata | null;
209
- content: MessageContent;
210
211
  conversationId: string;
211
- role: string;
212
212
  fromTeamAgentId: string | null;
213
213
  toTeamAgentId: string | null;
214
214
  visibility: string;
@@ -6,18 +6,18 @@ import { TaskInsert, TaskSelect } from "../../types/entities.js";
6
6
 
7
7
  //#region src/data-access/runtime/tasks.d.ts
8
8
  declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert) => Promise<{
9
- subAgentId: string;
10
9
  id: string;
10
+ tenantId: string;
11
+ projectId: string;
12
+ agentId: string;
11
13
  createdAt: string;
12
14
  updatedAt: string;
13
- projectId: string;
14
- tenantId: string;
15
15
  metadata: TaskMetadataConfig | null;
16
- agentId: string;
17
16
  status: string;
17
+ subAgentId: string;
18
18
  contextId: string;
19
19
  ref: {
20
- type: "commit" | "tag" | "branch";
20
+ type: "tag" | "commit" | "branch";
21
21
  name: string;
22
22
  hash: string;
23
23
  } | null;
@@ -36,7 +36,7 @@ declare const updateTask: (db: AgentsRunDatabaseClient) => (params: {
36
36
  updatedAt: string;
37
37
  contextId: string;
38
38
  ref: {
39
- type: "commit" | "tag" | "branch";
39
+ type: "tag" | "commit" | "branch";
40
40
  name: string;
41
41
  hash: string;
42
42
  } | null;