@inkeep/agents-core 0.43.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/auth/auth.d.ts +4 -2
  2. package/dist/auth/auth.js +4 -3
  3. package/dist/auth/authz/client.d.ts +0 -1
  4. package/dist/auth/authz/client.js +0 -1
  5. package/dist/auth/authz/config.d.ts +1 -7
  6. package/dist/auth/authz/config.js +1 -9
  7. package/dist/auth/authz/index.d.ts +3 -3
  8. package/dist/auth/authz/index.js +3 -3
  9. package/dist/auth/authz/permissions.d.ts +16 -1
  10. package/dist/auth/authz/permissions.js +30 -9
  11. package/dist/auth/authz/sync.js +1 -11
  12. package/dist/auth/init.d.ts +1 -0
  13. package/dist/auth/init.js +115 -0
  14. package/dist/client-exports.d.ts +2 -6
  15. package/dist/client-exports.js +3 -7
  16. package/dist/constants/otel-attributes.d.ts +6 -0
  17. package/dist/constants/otel-attributes.js +9 -3
  18. package/dist/constants/signoz-queries.d.ts +1 -0
  19. package/dist/constants/signoz-queries.js +2 -1
  20. package/dist/data-access/index.d.ts +4 -3
  21. package/dist/data-access/index.js +6 -5
  22. package/dist/data-access/manage/agentFull.js +42 -1
  23. package/dist/data-access/manage/agents.d.ts +27 -10
  24. package/dist/data-access/manage/agents.js +33 -2
  25. package/dist/data-access/manage/artifactComponents.d.ts +4 -4
  26. package/dist/data-access/manage/artifactComponents.js +1 -1
  27. package/dist/data-access/manage/contextConfigs.d.ts +12 -12
  28. package/dist/data-access/manage/dataComponents.d.ts +4 -4
  29. package/dist/data-access/manage/dataComponents.js +1 -1
  30. package/dist/data-access/manage/functionTools.d.ts +4 -4
  31. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +12 -12
  32. package/dist/data-access/manage/subAgentRelations.d.ts +18 -18
  33. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +12 -12
  34. package/dist/data-access/manage/subAgents.d.ts +3 -3
  35. package/dist/data-access/manage/tools.d.ts +20 -15
  36. package/dist/data-access/manage/tools.js +20 -1
  37. package/dist/data-access/runtime/apiKeys.d.ts +4 -4
  38. package/dist/data-access/runtime/cascade-delete.d.ts +48 -1
  39. package/dist/data-access/runtime/cascade-delete.js +52 -2
  40. package/dist/data-access/runtime/conversations.d.ts +19 -19
  41. package/dist/data-access/runtime/github-work-app-installations.d.ts +261 -0
  42. package/dist/data-access/runtime/github-work-app-installations.js +457 -0
  43. package/dist/data-access/runtime/messages.d.ts +6 -6
  44. package/dist/data-access/runtime/organizations.js +2 -2
  45. package/dist/data-access/runtime/tasks.d.ts +4 -4
  46. package/dist/db/manage/manage-schema.d.ts +17 -0
  47. package/dist/db/manage/manage-schema.js +1 -0
  48. package/dist/db/runtime/runtime-schema.d.ts +1009 -165
  49. package/dist/db/runtime/runtime-schema.js +173 -5
  50. package/dist/dolt/ref-middleware.js +1 -1
  51. package/dist/env.d.ts +6 -4
  52. package/dist/env.js +11 -10
  53. package/dist/index.d.ts +10 -11
  54. package/dist/index.js +22 -23
  55. package/dist/types/entities.d.ts +9 -2
  56. package/dist/types/index.d.ts +3 -3
  57. package/dist/types/utility.d.ts +16 -2
  58. package/dist/utils/temp-jwt.d.ts +2 -1
  59. package/dist/utils/temp-jwt.js +3 -2
  60. package/dist/validation/agentFull.js +1 -1
  61. package/dist/validation/dolt-schemas.d.ts +1 -1
  62. package/dist/validation/drizzle-schema-helpers.d.ts +1 -20
  63. package/dist/validation/drizzle-schema-helpers.js +3 -30
  64. package/dist/validation/index.d.ts +2 -4
  65. package/dist/validation/index.js +4 -6
  66. package/dist/validation/schemas.d.ts +3021 -1228
  67. package/dist/validation/schemas.js +164 -79
  68. package/drizzle/manage/0006_fixed_umar.sql +1 -0
  69. package/drizzle/manage/meta/0006_snapshot.json +3148 -0
  70. package/drizzle/manage/meta/_journal.json +7 -0
  71. package/drizzle/runtime/0010_previous_black_knight.sql +84 -0
  72. package/drizzle/runtime/meta/0010_snapshot.json +3066 -0
  73. package/drizzle/runtime/meta/_journal.json +7 -0
  74. package/package.json +4 -2
  75. package/dist/validation/id-validation.d.ts +0 -24
  76. package/dist/validation/id-validation.js +0 -52
@@ -19,18 +19,18 @@ declare const createConversation: (db: AgentsRunDatabaseClient) => (params: Conv
19
19
  createdAt: string;
20
20
  updatedAt: string;
21
21
  ref: {
22
- type: "commit" | "tag" | "branch";
22
+ type: "tag" | "commit" | "branch";
23
23
  name: string;
24
24
  hash: string;
25
25
  } | null;
26
26
  userId: string | null;
27
27
  metadata: ConversationMetadata | null;
28
- tenantId: string;
29
28
  agentId: string | null;
30
- activeSubAgentId: string;
29
+ projectId: string;
30
+ tenantId: string;
31
31
  title: string | null;
32
+ activeSubAgentId: string;
32
33
  lastContextResolution: string | null;
33
- projectId: string;
34
34
  }>;
35
35
  declare const updateConversation: (db: AgentsRunDatabaseClient) => (params: {
36
36
  scopes: ProjectScopeConfig;
@@ -43,7 +43,7 @@ declare const updateConversation: (db: AgentsRunDatabaseClient) => (params: {
43
43
  agentId: string | null;
44
44
  activeSubAgentId: string;
45
45
  ref: {
46
- type: "commit" | "tag" | "branch";
46
+ type: "tag" | "commit" | "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: "commit" | "tag" | "branch";
72
+ type: "tag" | "commit" | "branch";
73
73
  name: string;
74
74
  hash: string;
75
75
  } | null;
@@ -88,18 +88,18 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
88
88
  createdAt: string;
89
89
  updatedAt: string;
90
90
  ref: {
91
- type: "commit" | "tag" | "branch";
91
+ type: "tag" | "commit" | "branch";
92
92
  name: string;
93
93
  hash: string;
94
94
  } | null;
95
95
  userId: string | null;
96
96
  metadata: ConversationMetadata | null;
97
- tenantId: string;
98
97
  agentId: string | null;
99
- activeSubAgentId: string;
98
+ projectId: string;
99
+ tenantId: string;
100
100
  title: string | null;
101
+ activeSubAgentId: string;
101
102
  lastContextResolution: string | null;
102
- projectId: string;
103
103
  } | undefined>;
104
104
  declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input: ConversationInsert) => Promise<{
105
105
  activeSubAgentId: string;
@@ -107,7 +107,7 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
107
107
  tenantId: string;
108
108
  id: string;
109
109
  ref: {
110
- type: "commit" | "tag" | "branch";
110
+ type: "tag" | "commit" | "branch";
111
111
  name: string;
112
112
  hash: string;
113
113
  };
@@ -124,18 +124,18 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
124
124
  createdAt: string;
125
125
  updatedAt: string;
126
126
  ref: {
127
- type: "commit" | "tag" | "branch";
127
+ type: "tag" | "commit" | "branch";
128
128
  name: string;
129
129
  hash: string;
130
130
  } | null;
131
131
  userId: string | null;
132
132
  metadata: ConversationMetadata | null;
133
- tenantId: string;
134
133
  agentId: string | null;
135
- activeSubAgentId: string;
134
+ projectId: string;
135
+ tenantId: string;
136
136
  title: string | null;
137
+ activeSubAgentId: string;
137
138
  lastContextResolution: string | null;
138
- projectId: string;
139
139
  }>;
140
140
  /**
141
141
  * Get conversation history with filtering and context management
@@ -156,18 +156,18 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
156
156
  createdAt: string;
157
157
  updatedAt: string;
158
158
  ref: {
159
- type: "commit" | "tag" | "branch";
159
+ type: "tag" | "commit" | "branch";
160
160
  name: string;
161
161
  hash: string;
162
162
  } | null;
163
163
  userId: string | null;
164
164
  metadata: ConversationMetadata | null;
165
- tenantId: string;
166
165
  agentId: string | null;
167
- activeSubAgentId: string;
166
+ projectId: string;
167
+ tenantId: string;
168
168
  title: string | null;
169
+ activeSubAgentId: string;
169
170
  lastContextResolution: string | null;
170
- projectId: string;
171
171
  } | undefined>;
172
172
  /**
173
173
  * Set active agent for a conversation (upsert operation)
@@ -0,0 +1,261 @@
1
+ import { WorkAppGitHubInstallationStatus } from "../../types/utility.js";
2
+ import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
3
+ import { McpTool, ToolSelect, WorkAppGitHubInstallationInsert, WorkAppGitHubInstallationSelect, WorkAppGitHubProjectRepositoryAccessSelect, WorkAppGitHubRepositoryInput, WorkAppGitHubRepositorySelect } from "../../types/entities.js";
4
+
5
+ //#region src/data-access/runtime/github-work-app-installations.d.ts
6
+
7
+ /**
8
+ * Create a new GitHub App installation record
9
+ */
10
+ declare const createInstallation: (db: AgentsRunDatabaseClient) => (input: WorkAppGitHubInstallationInsert) => Promise<WorkAppGitHubInstallationSelect>;
11
+ /**
12
+ * Get installation by GitHub installation ID
13
+ */
14
+ declare const getInstallationByGitHubId: (db: AgentsRunDatabaseClient) => (gitHubInstallationId: string) => Promise<WorkAppGitHubInstallationSelect | null>;
15
+ /**
16
+ * Get installation by internal ID with tenant validation
17
+ */
18
+ declare const getInstallationById: (db: AgentsRunDatabaseClient) => (params: {
19
+ tenantId: string;
20
+ id: string;
21
+ }) => Promise<WorkAppGitHubInstallationSelect | null>;
22
+ /**
23
+ * Get all installations for a tenant
24
+ */
25
+ declare const getInstallationsByTenantId: (db: AgentsRunDatabaseClient) => (params: {
26
+ tenantId: string;
27
+ includeDisconnected?: boolean;
28
+ }) => Promise<WorkAppGitHubInstallationSelect[]>;
29
+ /**
30
+ * Update installation status
31
+ */
32
+ declare const updateInstallationStatus: (db: AgentsRunDatabaseClient) => (params: {
33
+ tenantId: string;
34
+ id: string;
35
+ status: WorkAppGitHubInstallationStatus;
36
+ }) => Promise<WorkAppGitHubInstallationSelect | null>;
37
+ /**
38
+ * Update installation status by GitHub installation ID (for webhook handlers)
39
+ */
40
+ declare const updateInstallationStatusByGitHubId: (db: AgentsRunDatabaseClient) => (params: {
41
+ gitHubInstallationId: string;
42
+ status: WorkAppGitHubInstallationStatus;
43
+ }) => Promise<WorkAppGitHubInstallationSelect | null>;
44
+ /**
45
+ * Soft delete an installation (set status to 'disconnected')
46
+ * Also removes all project repository access for this installation's repositories
47
+ */
48
+ declare const disconnectInstallation: (db: AgentsRunDatabaseClient) => (params: {
49
+ tenantId: string;
50
+ id: string;
51
+ }) => Promise<boolean>;
52
+ /**
53
+ * Delete an installation (hard delete)
54
+ * Returns the deleted installation if found, null otherwise
55
+ */
56
+ declare const deleteInstallation: (db: AgentsRunDatabaseClient) => (params: {
57
+ tenantId: string;
58
+ id: string;
59
+ }) => Promise<WorkAppGitHubInstallationSelect | null>;
60
+ /**
61
+ * Sync repositories for an installation
62
+ * Adds new repos, removes missing repos, updates existing
63
+ */
64
+ declare const syncRepositories: (db: AgentsRunDatabaseClient) => (params: {
65
+ installationId: string;
66
+ repositories: WorkAppGitHubRepositoryInput[];
67
+ }) => Promise<{
68
+ added: number;
69
+ removed: number;
70
+ updated: number;
71
+ }>;
72
+ /**
73
+ * Add repositories to an installation (for webhook 'added' events)
74
+ */
75
+ declare const addRepositories: (db: AgentsRunDatabaseClient) => (params: {
76
+ installationId: string;
77
+ repositories: WorkAppGitHubRepositoryInput[];
78
+ }) => Promise<WorkAppGitHubRepositorySelect[]>;
79
+ /**
80
+ * Remove repositories from an installation (for webhook 'removed' events)
81
+ * Also removes associated project repository access entries
82
+ */
83
+ declare const removeRepositories: (db: AgentsRunDatabaseClient) => (params: {
84
+ installationId: string;
85
+ repositoryIds: string[];
86
+ }) => Promise<number>;
87
+ /**
88
+ * Get all repositories for an installation
89
+ */
90
+ declare const getRepositoriesByInstallationId: (db: AgentsRunDatabaseClient) => (installationId: string) => Promise<WorkAppGitHubRepositorySelect[]>;
91
+ /**
92
+ * Get repository by full name (e.g., "org/repo")
93
+ */
94
+ declare const getRepositoryByFullName: (db: AgentsRunDatabaseClient) => (repositoryFullName: string) => Promise<WorkAppGitHubRepositorySelect | null>;
95
+ /**
96
+ * Get repository by internal ID
97
+ */
98
+ declare const getRepositoryById: (db: AgentsRunDatabaseClient) => (id: string) => Promise<WorkAppGitHubRepositorySelect | null>;
99
+ /**
100
+ * Get all repositories for a tenant (across all installations)
101
+ */
102
+ declare const getRepositoriesByTenantId: (db: AgentsRunDatabaseClient) => (tenantId: string) => Promise<(WorkAppGitHubRepositorySelect & {
103
+ installationAccountLogin: string;
104
+ installationId: string;
105
+ })[]>;
106
+ /**
107
+ * Set project repository access (full replacement)
108
+ * Used when mode='selected' to specify which repositories the project can access.
109
+ * Pass empty array to clear all access entries.
110
+ *
111
+ * Also cascades changes to MCP tools: any MCP tool in this project with mode='selected'
112
+ * will have its selected repositories filtered to only include repos that remain
113
+ * in the project's access list.
114
+ */
115
+ declare const setProjectRepositoryAccess: (db: AgentsRunDatabaseClient) => (params: {
116
+ tenantId: string;
117
+ projectId: string;
118
+ repositoryIds: string[];
119
+ }) => Promise<void>;
120
+ /**
121
+ * Get project repository access entries
122
+ * These entries are used when mode='selected'. Check mode via getProjectAccessMode().
123
+ */
124
+ declare const getProjectRepositoryAccess: (db: AgentsRunDatabaseClient) => (projectId: string) => Promise<WorkAppGitHubProjectRepositoryAccessSelect[]>;
125
+ /**
126
+ * Get project repository access with full repository details.
127
+ * If project access mode is 'all', returns all tenant repositories.
128
+ * If mode is 'selected' (or not set), returns only explicitly granted repositories.
129
+ */
130
+ declare const getProjectRepositoryAccessWithDetails: (db: AgentsRunDatabaseClient) => (params: {
131
+ tenantId: string;
132
+ projectId: string;
133
+ }) => Promise<(WorkAppGitHubRepositorySelect & {
134
+ accessId: string;
135
+ installationAccountLogin: string;
136
+ installationId: string;
137
+ })[]>;
138
+ /**
139
+ * Check if a project has access to a specific repository
140
+ * Returns true if:
141
+ * - Project mode is 'all' and repository belongs to tenant installations
142
+ * - Project mode is 'selected' and repository is explicitly in the project's access list
143
+ */
144
+ declare const checkProjectRepositoryAccess: (db: AgentsRunDatabaseClient) => (params: {
145
+ projectId: string;
146
+ repositoryFullName: string;
147
+ tenantId: string;
148
+ }) => Promise<{
149
+ hasAccess: boolean;
150
+ reason: string;
151
+ }>;
152
+ /**
153
+ * Remove all project repository access for a specific project
154
+ */
155
+ declare const clearProjectRepositoryAccess: (db: AgentsRunDatabaseClient) => (projectId: string) => Promise<number>;
156
+ /**
157
+ * Validate that all repository IDs belong to installations owned by a tenant
158
+ * Returns list of invalid repository IDs
159
+ */
160
+ declare const validateRepositoryOwnership: (db: AgentsRunDatabaseClient) => (params: {
161
+ tenantId: string;
162
+ repositoryIds: string[];
163
+ }) => Promise<string[]>;
164
+ /**
165
+ * Get repository count for an installation
166
+ */
167
+ declare const getRepositoryCount: (db: AgentsRunDatabaseClient) => (installationId: string) => Promise<number>;
168
+ /**
169
+ * Get repository counts for all installations belonging to a tenant
170
+ */
171
+ declare const getRepositoryCountsByTenantId: (db: AgentsRunDatabaseClient) => (params: {
172
+ tenantId: string;
173
+ includeDisconnected?: boolean;
174
+ }) => Promise<Map<string, number>>;
175
+ /**
176
+ * Set MCP tool repository access (full replacement)
177
+ * Used when mode='selected' to specify which repositories the tool can access.
178
+ * Pass empty array to clear all access entries.
179
+ */
180
+ declare const setMcpToolRepositoryAccess: (db: AgentsRunDatabaseClient) => (params: {
181
+ toolId: string;
182
+ tenantId: string;
183
+ projectId: string;
184
+ repositoryIds: string[];
185
+ }) => Promise<void>;
186
+ /**
187
+ * Get MCP tool repository access entries
188
+ * These entries are used when mode='selected'. Check mode via getMcpToolAccessMode().
189
+ */
190
+ declare const getMcpToolRepositoryAccess: (db: AgentsRunDatabaseClient) => (toolId: string) => Promise<{
191
+ id: string;
192
+ toolId: string;
193
+ tenantId: string;
194
+ projectId: string;
195
+ repositoryDbId: string;
196
+ createdAt: string;
197
+ updatedAt: string;
198
+ }[]>;
199
+ /**
200
+ * Get MCP tool repository access with full repository details.
201
+ * If the tool's access mode is 'all', returns all repositories the project has access to.
202
+ * If mode is 'selected' (or not set), returns only explicitly granted repositories.
203
+ */
204
+ declare const getMcpToolRepositoryAccessWithDetails: (db: AgentsRunDatabaseClient) => (toolId: string) => Promise<(WorkAppGitHubRepositorySelect & {
205
+ accessId: string;
206
+ installationAccountLogin: string;
207
+ installationId: string;
208
+ })[]>;
209
+ /**
210
+ * Remove all MCP tool repository access for a specific tool
211
+ */
212
+ declare const clearMcpToolRepositoryAccess: (db: AgentsRunDatabaseClient) => (toolId: string) => Promise<number>;
213
+ declare const isGithubWorkAppTool: (tool: ToolSelect | McpTool) => boolean | undefined;
214
+ type WorkAppGitHubAccessMode = 'all' | 'selected';
215
+ /**
216
+ * Set the access mode for a project's GitHub repository access.
217
+ * - 'all': Project has access to all repositories from tenant GitHub installations
218
+ * - 'selected': Project only has access to repositories listed in work_app_github_project_repository_access
219
+ */
220
+ declare const setProjectAccessMode: (db: AgentsRunDatabaseClient) => (params: {
221
+ tenantId: string;
222
+ projectId: string;
223
+ mode: WorkAppGitHubAccessMode;
224
+ }) => Promise<void>;
225
+ /**
226
+ * Get the access mode for a project's GitHub repository access.
227
+ * Returns 'selected' if no mode is explicitly set (fail-safe default).
228
+ */
229
+ declare const getProjectAccessMode: (db: AgentsRunDatabaseClient) => (params: {
230
+ tenantId: string;
231
+ projectId: string;
232
+ }) => Promise<WorkAppGitHubAccessMode>;
233
+ /**
234
+ * Delete the access mode entry for a project
235
+ */
236
+ declare const deleteProjectAccessMode: (db: AgentsRunDatabaseClient) => (params: {
237
+ tenantId: string;
238
+ projectId: string;
239
+ }) => Promise<boolean>;
240
+ /**
241
+ * Set the access mode for an MCP tool's GitHub repository access.
242
+ * - 'all': Tool has access to all repositories the project has access to
243
+ * - 'selected': Tool only has access to repositories listed in work_app_github_mcp_tool_repository_access
244
+ */
245
+ declare const setMcpToolAccessMode: (db: AgentsRunDatabaseClient) => (params: {
246
+ toolId: string;
247
+ tenantId: string;
248
+ projectId: string;
249
+ mode: WorkAppGitHubAccessMode;
250
+ }) => Promise<void>;
251
+ /**
252
+ * Get the access mode for an MCP tool's GitHub repository access.
253
+ * Returns 'selected' if no mode is explicitly set (fail-safe default).
254
+ */
255
+ declare const getMcpToolAccessMode: (db: AgentsRunDatabaseClient) => (toolId: string) => Promise<WorkAppGitHubAccessMode>;
256
+ /**
257
+ * Delete the access mode entry for an MCP tool
258
+ */
259
+ declare const deleteMcpToolAccessMode: (db: AgentsRunDatabaseClient) => (toolId: string) => Promise<boolean>;
260
+ //#endregion
261
+ 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 };