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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/auth/auth-schema.d.ts +107 -107
  2. package/dist/auth/auth-validation-schemas.d.ts +152 -152
  3. package/dist/auth/auth.d.ts +28 -28
  4. package/dist/auth/auth.js +2 -2
  5. package/dist/auth/permissions.d.ts +13 -13
  6. package/dist/client-exports.d.ts +5 -4
  7. package/dist/client-exports.js +2 -2
  8. package/dist/data-access/index.d.ts +3 -3
  9. package/dist/data-access/index.js +3 -3
  10. package/dist/data-access/manage/agents.d.ts +47 -47
  11. package/dist/data-access/manage/agents.js +25 -11
  12. package/dist/data-access/manage/artifactComponents.d.ts +16 -16
  13. package/dist/data-access/manage/contextConfigs.d.ts +12 -12
  14. package/dist/data-access/manage/dataComponents.d.ts +6 -6
  15. package/dist/data-access/manage/functionTools.d.ts +16 -16
  16. package/dist/data-access/manage/skills.d.ts +13 -13
  17. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +18 -18
  18. package/dist/data-access/manage/subAgentRelations.d.ts +26 -26
  19. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
  20. package/dist/data-access/manage/subAgents.d.ts +21 -21
  21. package/dist/data-access/manage/tools.d.ts +21 -21
  22. package/dist/data-access/manage/triggerCleanup.d.ts +12 -0
  23. package/dist/data-access/manage/triggerCleanup.js +51 -0
  24. package/dist/data-access/manage/triggers.d.ts +13 -2
  25. package/dist/data-access/manage/triggers.js +8 -1
  26. package/dist/data-access/runtime/apiKeys.d.ts +20 -20
  27. package/dist/data-access/runtime/conversations.d.ts +12 -12
  28. package/dist/data-access/runtime/messages.d.ts +24 -24
  29. package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +3 -3
  30. package/dist/data-access/runtime/tasks.d.ts +4 -4
  31. package/dist/data-access/runtime/users.d.ts +5 -1
  32. package/dist/data-access/runtime/users.js +14 -1
  33. package/dist/db/manage/manage-schema.d.ts +487 -449
  34. package/dist/db/manage/manage-schema.js +2 -0
  35. package/dist/db/runtime/runtime-schema.d.ts +296 -296
  36. package/dist/index.d.ts +4 -4
  37. package/dist/index.js +4 -4
  38. package/dist/middleware/no-auth.d.ts +2 -2
  39. package/dist/utils/error.d.ts +51 -51
  40. package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
  41. package/dist/validation/index.d.ts +2 -2
  42. package/dist/validation/index.js +2 -2
  43. package/dist/validation/schemas.d.ts +2157 -1988
  44. package/dist/validation/schemas.js +18 -5
  45. package/drizzle/manage/0012_petite_weapon_omega.sql +2 -0
  46. package/drizzle/manage/meta/0012_snapshot.json +3697 -0
  47. package/drizzle/manage/meta/_journal.json +7 -0
  48. package/package.json +1 -1
  49. package/dist/auth/cleanup.d.ts +0 -12
  50. package/dist/auth/cleanup.js +0 -43
@@ -0,0 +1,51 @@
1
+ import { manage_schema_exports } from "../../db/manage/manage-schema.js";
2
+ import { getLogger } from "../../utils/logger.js";
3
+ import { resolveProjectMainRefs } from "../../dolt/ref-helpers.js";
4
+ import { listProjectsMetadata } from "../runtime/projects.js";
5
+ import { deleteScheduledTriggersByRunAsUserId } from "./scheduledTriggers.js";
6
+ import { deleteTriggersByRunAsUserId } from "./triggers.js";
7
+ import { withRef } from "../../dolt/ref-scope.js";
8
+ import { drizzle } from "drizzle-orm/node-postgres";
9
+
10
+ //#region src/data-access/manage/triggerCleanup.ts
11
+ const logger = getLogger("auth-cleanup");
12
+ async function cleanupUserTriggers(params) {
13
+ const { tenantId, userId, runDb, manageDbPool } = params;
14
+ const projects = await listProjectsMetadata(runDb)({ tenantId });
15
+ if (projects.length === 0) return;
16
+ const connection = await manageDbPool.connect();
17
+ let resolvedRefs;
18
+ try {
19
+ resolvedRefs = await resolveProjectMainRefs(drizzle(connection, { schema: manage_schema_exports }))(tenantId, projects.map((p) => p.id));
20
+ } finally {
21
+ connection.release();
22
+ }
23
+ const results = await Promise.allSettled(resolvedRefs.map(({ projectId, ref }) => withRef(manageDbPool, ref, async (db) => {
24
+ await deleteScheduledTriggersByRunAsUserId(db)({
25
+ tenantId,
26
+ projectId,
27
+ runAsUserId: userId
28
+ });
29
+ await deleteTriggersByRunAsUserId(db)({
30
+ tenantId,
31
+ projectId,
32
+ runAsUserId: userId
33
+ });
34
+ }, {
35
+ commit: true,
36
+ commitMessage: `Remove triggers for departing user ${userId}`
37
+ })));
38
+ for (let i = 0; i < results.length; i++) {
39
+ const result = results[i];
40
+ const { projectId } = resolvedRefs[i];
41
+ if (result.status === "rejected") logger.error({
42
+ tenantId,
43
+ projectId,
44
+ userId,
45
+ error: result.reason
46
+ }, "Failed to clean up scheduled triggers for project");
47
+ }
48
+ }
49
+
50
+ //#endregion
51
+ export { cleanupUserTriggers };
@@ -46,7 +46,7 @@ declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params
46
46
  regex?: string | undefined;
47
47
  };
48
48
  signedComponents: {
49
- source: "header" | "literal" | "body";
49
+ source: "literal" | "header" | "body";
50
50
  required: boolean;
51
51
  key?: string | undefined;
52
52
  value?: string | undefined;
@@ -62,6 +62,8 @@ declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params
62
62
  normalizeUnicode: boolean;
63
63
  } | undefined;
64
64
  } | null;
65
+ runAsUserId: string | null;
66
+ createdBy: string | null;
65
67
  name: string;
66
68
  description: string | null;
67
69
  agentId: string;
@@ -95,6 +97,15 @@ declare const deleteTrigger: (db: AgentsManageDatabaseClient) => (params: {
95
97
  scopes: AgentScopeConfig;
96
98
  triggerId: string;
97
99
  }) => Promise<void>;
100
+ /**
101
+ * Delete all webhook triggers for a given runAsUserId within a tenant+project scope.
102
+ * Operates across all agents in the project (not agent-scoped).
103
+ */
104
+ declare const deleteTriggersByRunAsUserId: (db: AgentsManageDatabaseClient) => (params: {
105
+ tenantId: string;
106
+ projectId: string;
107
+ runAsUserId: string;
108
+ }) => Promise<void>;
98
109
  /**
99
110
  * Upsert a trigger (create or update based on existence)
100
111
  */
@@ -103,4 +114,4 @@ declare const upsertTrigger: (db: AgentsManageDatabaseClient) => (params: {
103
114
  data: TriggerInsert;
104
115
  }) => Promise<TriggerSelect>;
105
116
  //#endregion
106
- export { createTrigger, deleteTrigger, getTriggerById, listTriggers, listTriggersPaginated, updateTrigger, upsertTrigger };
117
+ export { createTrigger, deleteTrigger, deleteTriggersByRunAsUserId, getTriggerById, listTriggers, listTriggersPaginated, updateTrigger, upsertTrigger };
@@ -58,6 +58,13 @@ const deleteTrigger = (db) => async (params) => {
58
58
  await db.delete(triggers).where(and(eq(triggers.tenantId, params.scopes.tenantId), eq(triggers.projectId, params.scopes.projectId), eq(triggers.agentId, params.scopes.agentId), eq(triggers.id, params.triggerId)));
59
59
  };
60
60
  /**
61
+ * Delete all webhook triggers for a given runAsUserId within a tenant+project scope.
62
+ * Operates across all agents in the project (not agent-scoped).
63
+ */
64
+ const deleteTriggersByRunAsUserId = (db) => async (params) => {
65
+ await db.delete(triggers).where(and(eq(triggers.tenantId, params.tenantId), eq(triggers.projectId, params.projectId), eq(triggers.runAsUserId, params.runAsUserId)));
66
+ };
67
+ /**
61
68
  * Upsert a trigger (create or update based on existence)
62
69
  */
63
70
  const upsertTrigger = (db) => async (params) => {
@@ -78,4 +85,4 @@ const upsertTrigger = (db) => async (params) => {
78
85
  };
79
86
 
80
87
  //#endregion
81
- export { createTrigger, deleteTrigger, getTriggerById, listTriggers, listTriggersPaginated, updateTrigger, upsertTrigger };
88
+ export { createTrigger, deleteTrigger, deleteTriggersByRunAsUserId, getTriggerById, listTriggers, listTriggersPaginated, updateTrigger, upsertTrigger };
@@ -8,49 +8,49 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
8
8
  scopes: ProjectScopeConfig;
9
9
  id: string;
10
10
  }) => Promise<{
11
- name: string | null;
11
+ tenantId: string;
12
+ projectId: string;
13
+ agentId: string;
12
14
  id: string;
15
+ name: string | null;
13
16
  createdAt: string;
14
17
  updatedAt: string;
15
- projectId: string;
16
- tenantId: string;
17
- agentId: 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
- name: string | null;
25
+ tenantId: string;
26
+ projectId: string;
27
+ agentId: string;
26
28
  id: string;
29
+ name: string | null;
27
30
  createdAt: string;
28
31
  updatedAt: string;
29
- projectId: string;
30
- tenantId: string;
31
- agentId: 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;
40
40
  agentId?: string;
41
41
  }) => Promise<{
42
- name: string | null;
42
+ tenantId: string;
43
+ projectId: string;
44
+ agentId: string;
43
45
  id: string;
46
+ name: string | null;
44
47
  createdAt: string;
45
48
  updatedAt: string;
46
- projectId: string;
47
- tenantId: string;
48
- agentId: 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;
@@ -66,18 +66,18 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
66
66
  };
67
67
  }>;
68
68
  declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
69
- name: string | null;
69
+ tenantId: string;
70
+ projectId: string;
71
+ agentId: string;
70
72
  id: string;
73
+ name: string | null;
71
74
  createdAt: string;
72
75
  updatedAt: string;
73
- projectId: string;
74
- tenantId: string;
75
- agentId: 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;
@@ -17,13 +17,13 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
17
17
  }>;
18
18
  declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
19
19
  title: string | null;
20
+ tenantId: string;
21
+ projectId: string;
22
+ agentId: string | null;
20
23
  id: string;
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
29
  type: "commit" | "tag" | "branch";
@@ -86,13 +86,13 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
86
86
  conversationId: string;
87
87
  }) => Promise<{
88
88
  title: string | null;
89
+ tenantId: string;
90
+ projectId: string;
91
+ agentId: string | null;
89
92
  id: string;
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
98
  type: "commit" | "tag" | "branch";
@@ -122,13 +122,13 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
122
122
  contextConfigId?: string | undefined;
123
123
  } | {
124
124
  title: string | null;
125
+ tenantId: string;
126
+ projectId: string;
127
+ agentId: string | null;
125
128
  id: string;
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
134
  type: "commit" | "tag" | "branch";
@@ -154,13 +154,13 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
154
154
  conversationId: string;
155
155
  }) => Promise<{
156
156
  title: string | null;
157
+ tenantId: string;
158
+ projectId: string;
159
+ agentId: string | null;
157
160
  id: string;
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
166
  type: "commit" | "tag" | "branch";
@@ -10,26 +10,26 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
10
10
  scopes: ProjectScopeConfig;
11
11
  messageId: string;
12
12
  }) => Promise<{
13
- fromSubAgentId: string | null;
14
- toSubAgentId: string | null;
15
- fromExternalAgentId: string | null;
16
- toExternalAgentId: string | null;
17
- taskId: string | null;
18
- a2aTaskId: string | null;
13
+ tenantId: string;
14
+ projectId: string;
19
15
  id: string;
20
16
  createdAt: string;
21
17
  updatedAt: string;
22
- projectId: string;
23
- tenantId: string;
24
18
  metadata: MessageMetadata | null;
25
19
  content: MessageContent;
26
20
  conversationId: string;
27
21
  role: string;
22
+ fromSubAgentId: string | null;
23
+ toSubAgentId: string | null;
24
+ fromExternalAgentId: string | null;
25
+ toExternalAgentId: string | null;
28
26
  fromTeamAgentId: string | null;
29
27
  toTeamAgentId: string | null;
30
28
  visibility: string;
31
29
  messageType: string;
30
+ taskId: string | null;
32
31
  parentMessageId: string | null;
32
+ a2aTaskId: string | null;
33
33
  a2aSessionId: string | null;
34
34
  } | undefined>;
35
35
  declare const listMessages: (db: AgentsRunDatabaseClient) => (params: {
@@ -141,26 +141,26 @@ declare const getVisibleMessages: (db: AgentsRunDatabaseClient) => (params: {
141
141
  id: string;
142
142
  }[]>;
143
143
  declare const createMessage: (db: AgentsRunDatabaseClient) => (params: MessageInsert) => Promise<{
144
- fromSubAgentId: string | null;
145
- toSubAgentId: string | null;
146
- fromExternalAgentId: string | null;
147
- toExternalAgentId: string | null;
148
- taskId: string | null;
149
- a2aTaskId: string | null;
144
+ tenantId: string;
145
+ projectId: string;
150
146
  id: string;
151
147
  createdAt: string;
152
148
  updatedAt: string;
153
- projectId: string;
154
- tenantId: string;
155
149
  metadata: MessageMetadata | null;
156
150
  content: MessageContent;
157
151
  conversationId: string;
158
152
  role: string;
153
+ fromSubAgentId: string | null;
154
+ toSubAgentId: string | null;
155
+ fromExternalAgentId: string | null;
156
+ toExternalAgentId: string | null;
159
157
  fromTeamAgentId: string | null;
160
158
  toTeamAgentId: string | null;
161
159
  visibility: string;
162
160
  messageType: string;
161
+ taskId: string | null;
163
162
  parentMessageId: string | null;
163
+ a2aTaskId: string | null;
164
164
  a2aSessionId: string | null;
165
165
  }>;
166
166
  declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
@@ -194,26 +194,26 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
194
194
  scopes: ProjectScopeConfig;
195
195
  messageId: string;
196
196
  }) => Promise<{
197
- fromSubAgentId: string | null;
198
- toSubAgentId: string | null;
199
- fromExternalAgentId: string | null;
200
- toExternalAgentId: string | null;
201
- taskId: string | null;
202
- a2aTaskId: string | null;
197
+ tenantId: string;
198
+ projectId: string;
203
199
  id: string;
204
200
  createdAt: string;
205
201
  updatedAt: string;
206
- projectId: string;
207
- tenantId: string;
208
202
  metadata: MessageMetadata | null;
209
203
  content: MessageContent;
210
204
  conversationId: string;
211
205
  role: string;
206
+ fromSubAgentId: string | null;
207
+ toSubAgentId: string | null;
208
+ fromExternalAgentId: string | null;
209
+ toExternalAgentId: string | null;
212
210
  fromTeamAgentId: string | null;
213
211
  toTeamAgentId: string | null;
214
212
  visibility: string;
215
213
  messageType: string;
214
+ taskId: string | null;
216
215
  parentMessageId: string | null;
216
+ a2aTaskId: string | null;
217
217
  a2aSessionId: string | null;
218
218
  }>;
219
219
  declare const countMessagesByConversation: (db: AgentsRunDatabaseClient) => (params: {
@@ -34,7 +34,7 @@ declare const listScheduledTriggerInvocationsPaginated: (db: AgentsRunDatabaseCl
34
34
  }) => Promise<{
35
35
  data: {
36
36
  scheduledTriggerId: string;
37
- status: "pending" | "failed" | "running" | "completed" | "cancelled";
37
+ status: "pending" | "running" | "completed" | "failed" | "cancelled";
38
38
  scheduledFor: string;
39
39
  startedAt: string | null;
40
40
  completedAt: string | null;
@@ -174,7 +174,7 @@ declare const listUpcomingInvocationsForAgentPaginated: (db: AgentsRunDatabaseCl
174
174
  }) => Promise<{
175
175
  data: {
176
176
  scheduledTriggerId: string;
177
- status: "pending" | "failed" | "running" | "completed" | "cancelled";
177
+ status: "pending" | "running" | "completed" | "failed" | "cancelled";
178
178
  scheduledFor: string;
179
179
  startedAt: string | null;
180
180
  completedAt: string | null;
@@ -208,7 +208,7 @@ declare const listProjectScheduledTriggerInvocationsPaginated: (db: AgentsRunDat
208
208
  }) => Promise<{
209
209
  data: {
210
210
  scheduledTriggerId: string;
211
- status: "pending" | "failed" | "running" | "completed" | "cancelled";
211
+ status: "pending" | "running" | "completed" | "failed" | "cancelled";
212
212
  scheduledFor: string;
213
213
  startedAt: string | null;
214
214
  completedAt: string | null;
@@ -6,21 +6,21 @@ 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
+ tenantId: string;
10
+ projectId: string;
11
+ agentId: string;
9
12
  subAgentId: string;
10
13
  id: string;
11
14
  createdAt: string;
12
15
  updatedAt: string;
13
- projectId: string;
14
- tenantId: string;
15
16
  metadata: TaskMetadataConfig | null;
16
17
  status: string;
17
- agentId: string;
18
- contextId: string;
19
18
  ref: {
20
19
  type: "commit" | "tag" | "branch";
21
20
  name: string;
22
21
  hash: string;
23
22
  } | null;
23
+ contextId: string;
24
24
  }>;
25
25
  declare const getTask: (db: AgentsRunDatabaseClient) => (params: {
26
26
  id: string;
@@ -19,9 +19,13 @@ declare const getUserByEmail: (db: AgentsRunDatabaseClient) => (email: string) =
19
19
  * Get organization member by email
20
20
  * Returns the user if they are a member of the specified organization
21
21
  */
22
+ declare const getOrganizationMemberByUserId: (db: AgentsRunDatabaseClient) => (organizationId: string, userId: string) => Promise<(User & {
23
+ role: string;
24
+ memberId: string;
25
+ }) | null>;
22
26
  declare const getOrganizationMemberByEmail: (db: AgentsRunDatabaseClient) => (organizationId: string, email: string) => Promise<(User & {
23
27
  role: string;
24
28
  memberId: string;
25
29
  }) | null>;
26
30
  //#endregion
27
- export { getOrganizationMemberByEmail, getUserByEmail, getUserById };
31
+ export { getOrganizationMemberByEmail, getOrganizationMemberByUserId, getUserByEmail, getUserById };
@@ -22,6 +22,19 @@ const getUserByEmail = (db) => async (email) => {
22
22
  * Get organization member by email
23
23
  * Returns the user if they are a member of the specified organization
24
24
  */
25
+ const getOrganizationMemberByUserId = (db) => async (organizationId, userId) => {
26
+ return (await db.select({
27
+ id: user.id,
28
+ name: user.name,
29
+ email: user.email,
30
+ emailVerified: user.emailVerified,
31
+ image: user.image,
32
+ createdAt: user.createdAt,
33
+ updatedAt: user.updatedAt,
34
+ role: member.role,
35
+ memberId: member.id
36
+ }).from(member).innerJoin(user, eq(member.userId, user.id)).where(and(eq(member.organizationId, organizationId), eq(user.id, userId))).limit(1))[0] || null;
37
+ };
25
38
  const getOrganizationMemberByEmail = (db) => async (organizationId, email) => {
26
39
  return (await db.select({
27
40
  id: user.id,
@@ -37,4 +50,4 @@ const getOrganizationMemberByEmail = (db) => async (organizationId, email) => {
37
50
  };
38
51
 
39
52
  //#endregion
40
- export { getOrganizationMemberByEmail, getUserByEmail, getUserById };
53
+ export { getOrganizationMemberByEmail, getOrganizationMemberByUserId, getUserByEmail, getUserById };