@inkeep/agents-core 0.71.0 → 0.72.1

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 (59) hide show
  1. package/dist/auth/auth-schema.d.ts +163 -163
  2. package/dist/auth/auth-validation-schemas.d.ts +137 -137
  3. package/dist/auth/auth.d.ts +122 -122
  4. package/dist/auth/password-policy.d.ts +2 -2
  5. package/dist/auth/permissions.d.ts +13 -13
  6. package/dist/client-exports.d.ts +2 -2
  7. package/dist/client-exports.js +2 -2
  8. package/dist/constants/signoz-queries.d.ts +2 -0
  9. package/dist/constants/signoz-queries.js +3 -1
  10. package/dist/data-access/index.d.ts +2 -1
  11. package/dist/data-access/index.js +2 -1
  12. package/dist/data-access/manage/agents.d.ts +31 -31
  13. package/dist/data-access/manage/artifactComponents.d.ts +4 -4
  14. package/dist/data-access/manage/contextConfigs.d.ts +4 -4
  15. package/dist/data-access/manage/dataComponents.d.ts +2 -2
  16. package/dist/data-access/manage/functionTools.d.ts +8 -8
  17. package/dist/data-access/manage/skills.d.ts +8 -8
  18. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +6 -6
  19. package/dist/data-access/manage/subAgentRelations.d.ts +10 -10
  20. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +6 -6
  21. package/dist/data-access/manage/subAgents.d.ts +9 -9
  22. package/dist/data-access/manage/tools.d.ts +12 -12
  23. package/dist/data-access/runtime/apiKeys.d.ts +4 -4
  24. package/dist/data-access/runtime/apps.d.ts +8 -8
  25. package/dist/data-access/runtime/cascade-delete.d.ts +14 -3
  26. package/dist/data-access/runtime/cascade-delete.js +30 -7
  27. package/dist/data-access/runtime/conversations.d.ts +32 -16
  28. package/dist/data-access/runtime/conversations.js +43 -9
  29. package/dist/data-access/runtime/events.d.ts +97 -0
  30. package/dist/data-access/runtime/events.js +47 -0
  31. package/dist/data-access/runtime/feedback.d.ts +2 -2
  32. package/dist/data-access/runtime/messages.d.ts +22 -6
  33. package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +4 -4
  34. package/dist/data-access/runtime/tasks.d.ts +3 -3
  35. package/dist/db/manage/manage-schema.d.ts +478 -478
  36. package/dist/db/runtime/runtime-schema.d.ts +765 -433
  37. package/dist/db/runtime/runtime-schema.js +26 -1
  38. package/dist/index.d.ts +6 -5
  39. package/dist/index.js +5 -4
  40. package/dist/types/entities.d.ts +6 -2
  41. package/dist/types/index.d.ts +2 -2
  42. package/dist/utils/conversations.d.ts +7 -2
  43. package/dist/utils/conversations.js +16 -3
  44. package/dist/utils/index.d.ts +2 -2
  45. package/dist/utils/index.js +2 -2
  46. package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
  47. package/dist/validation/index.d.ts +2 -2
  48. package/dist/validation/index.js +2 -2
  49. package/dist/validation/schemas/skills.d.ts +54 -54
  50. package/dist/validation/schemas.d.ts +2516 -2680
  51. package/dist/validation/schemas.js +61 -9
  52. package/drizzle/runtime/0039_abandoned_old_lace.sql +21 -0
  53. package/drizzle/runtime/0040_living_forgotten_one.sql +4 -0
  54. package/drizzle/runtime/0041_salty_wilson_fisk.sql +3 -0
  55. package/drizzle/runtime/meta/0039_snapshot.json +6309 -0
  56. package/drizzle/runtime/meta/0040_snapshot.json +6333 -0
  57. package/drizzle/runtime/meta/0041_snapshot.json +6298 -0
  58. package/drizzle/runtime/meta/_journal.json +21 -0
  59. package/package.json +1 -1
@@ -1,9 +1,12 @@
1
1
  import { conversations, messages } from "../../db/runtime/runtime-schema.js";
2
+ import { getLogger } from "../../utils/logger.js";
2
3
  import { getConversationId } from "../../utils/conversations.js";
3
4
  import { projectScopedWhere } from "../manage/scope-helpers.js";
5
+ import { deleteEventsByConversationIds } from "./events.js";
4
6
  import { and, count, desc, eq, inArray } from "drizzle-orm";
5
7
 
6
8
  //#region src/data-access/runtime/conversations.ts
9
+ const logger = getLogger("data-access/runtime/conversations");
7
10
  const listConversations = (db) => async (params) => {
8
11
  const { userId, pagination } = params;
9
12
  const page = pagination?.page || 1;
@@ -37,11 +40,20 @@ const updateConversation = (db) => async (params) => {
37
40
  };
38
41
  const deleteConversation = (db) => async (params) => {
39
42
  try {
43
+ await deleteEventsByConversationIds(db)({
44
+ scopes: params.scopes,
45
+ conversationIds: [params.conversationId]
46
+ });
40
47
  await db.delete(messages).where(and(projectScopedWhere(messages, params.scopes), eq(messages.conversationId, params.conversationId)));
41
48
  await db.delete(conversations).where(and(projectScopedWhere(conversations, params.scopes), eq(conversations.id, params.conversationId)));
42
49
  return true;
43
50
  } catch (error) {
44
- console.error("Error deleting conversation:", error);
51
+ logger.error({
52
+ tenantId: params.scopes.tenantId,
53
+ projectId: params.scopes.projectId,
54
+ conversationId: params.conversationId,
55
+ error: error instanceof Error ? error.message : String(error)
56
+ }, "Failed to delete conversation (events/messages/conversation cleanup chain)");
45
57
  return false;
46
58
  }
47
59
  };
@@ -60,14 +72,27 @@ const createOrGetConversation = (db) => async (input) => {
60
72
  if (input.id) {
61
73
  const existing = await db.query.conversations.findFirst({ where: and(eq(conversations.tenantId, input.tenantId), eq(conversations.id, input.id)) });
62
74
  if (existing) {
75
+ const updateSet = { updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
76
+ let needsUpdate = false;
63
77
  if (existing.activeSubAgentId !== input.activeSubAgentId) {
64
- await db.update(conversations).set({
65
- activeSubAgentId: input.activeSubAgentId,
66
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
67
- }).where(eq(conversations.id, input.id));
78
+ updateSet.activeSubAgentId = input.activeSubAgentId;
79
+ needsUpdate = true;
80
+ }
81
+ if (input.userProperties !== void 0) {
82
+ updateSet.userProperties = input.userProperties;
83
+ needsUpdate = true;
84
+ }
85
+ if (input.properties !== void 0) {
86
+ updateSet.properties = input.properties;
87
+ needsUpdate = true;
88
+ }
89
+ if (needsUpdate) {
90
+ await db.update(conversations).set(updateSet).where(eq(conversations.id, input.id));
68
91
  return {
69
92
  ...existing,
70
- activeSubAgentId: input.activeSubAgentId
93
+ ...updateSet.activeSubAgentId ? { activeSubAgentId: updateSet.activeSubAgentId } : {},
94
+ ...input.userProperties !== void 0 ? { userProperties: input.userProperties } : {},
95
+ ...input.properties !== void 0 ? { properties: input.properties } : {}
71
96
  };
72
97
  }
73
98
  return existing;
@@ -83,6 +108,8 @@ const createOrGetConversation = (db) => async (input) => {
83
108
  title: input.title,
84
109
  lastContextResolution: input.lastContextResolution,
85
110
  metadata: input.metadata,
111
+ userProperties: input.userProperties,
112
+ properties: input.properties,
86
113
  ref: input.ref,
87
114
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
88
115
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
@@ -134,6 +161,8 @@ function applyContextWindowManagement(messageHistory, maxOutputTokens) {
134
161
  a2aTaskId: null,
135
162
  a2aSessionId: null,
136
163
  metadata: null,
164
+ userProperties: null,
165
+ properties: null,
137
166
  createdAt: referenceMessage.createdAt,
138
167
  updatedAt: referenceMessage.updatedAt
139
168
  };
@@ -167,6 +196,7 @@ const getActiveAgentForConversation = (db) => async (params) => {
167
196
  * Set active agent for a conversation (upsert operation)
168
197
  */
169
198
  const setActiveAgentForConversation = (db) => async (params) => {
199
+ const now = (/* @__PURE__ */ new Date()).toISOString();
170
200
  await db.insert(conversations).values({
171
201
  id: params.conversationId,
172
202
  tenantId: params.scopes.tenantId,
@@ -176,8 +206,10 @@ const setActiveAgentForConversation = (db) => async (params) => {
176
206
  ref: params.ref,
177
207
  userId: params.userId,
178
208
  metadata: params.metadata,
179
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
180
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
209
+ userProperties: params.userProperties,
210
+ properties: params.properties,
211
+ createdAt: now,
212
+ updatedAt: now
181
213
  }).onConflictDoUpdate({
182
214
  target: [
183
215
  conversations.tenantId,
@@ -186,7 +218,9 @@ const setActiveAgentForConversation = (db) => async (params) => {
186
218
  ],
187
219
  set: {
188
220
  activeSubAgentId: params.subAgentId,
189
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
221
+ updatedAt: now,
222
+ ...params.userProperties !== void 0 ? { userProperties: params.userProperties } : {},
223
+ ...params.properties !== void 0 ? { properties: params.properties } : {}
190
224
  }
191
225
  });
192
226
  };
@@ -0,0 +1,97 @@
1
+ import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
2
+ import { PaginationConfig } from "../../types/utility.js";
3
+ import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
4
+ import "../../types/index.js";
5
+ import { EventInsert } from "../../types/entities.js";
6
+
7
+ //#region src/data-access/runtime/events.d.ts
8
+ declare const createEvent: (db: AgentsRunDatabaseClient) => (params: EventInsert) => Promise<{
9
+ row: {
10
+ tenantId: string;
11
+ projectId: string;
12
+ id: string;
13
+ metadata: Record<string, unknown> | null;
14
+ type: string;
15
+ properties: Record<string, unknown> | null;
16
+ agentId: string | null;
17
+ createdAt: string;
18
+ updatedAt: string;
19
+ conversationId: string | null;
20
+ userProperties: Record<string, unknown> | null;
21
+ messageId: string | null;
22
+ serverMetadata: {
23
+ [k: string]: unknown;
24
+ authMethod?: string;
25
+ } | null;
26
+ };
27
+ conflict: false;
28
+ } | {
29
+ row: {
30
+ createdAt: string;
31
+ updatedAt: string;
32
+ type: string;
33
+ agentId: string | null;
34
+ conversationId: string | null;
35
+ messageId: string | null;
36
+ properties: Record<string, unknown> | null;
37
+ userProperties: Record<string, unknown> | null;
38
+ metadata: Record<string, unknown> | null;
39
+ serverMetadata: {
40
+ [k: string]: unknown;
41
+ authMethod?: string;
42
+ } | null;
43
+ projectId: string;
44
+ tenantId: string;
45
+ id: string;
46
+ };
47
+ conflict: true;
48
+ }>;
49
+ declare const getEventById: (db: AgentsRunDatabaseClient) => (params: {
50
+ scopes: ProjectScopeConfig;
51
+ eventId: string;
52
+ }) => Promise<{
53
+ createdAt: string;
54
+ updatedAt: string;
55
+ type: string;
56
+ agentId: string | null;
57
+ conversationId: string | null;
58
+ messageId: string | null;
59
+ properties: Record<string, unknown> | null;
60
+ userProperties: Record<string, unknown> | null;
61
+ metadata: Record<string, unknown> | null;
62
+ serverMetadata: {
63
+ [k: string]: unknown;
64
+ authMethod?: string;
65
+ } | null;
66
+ projectId: string;
67
+ tenantId: string;
68
+ id: string;
69
+ }>;
70
+ declare const listEventsByConversationId: (db: AgentsRunDatabaseClient) => (params: {
71
+ scopes: ProjectScopeConfig;
72
+ conversationId: string;
73
+ pagination?: PaginationConfig;
74
+ }) => Promise<{
75
+ createdAt: string;
76
+ updatedAt: string;
77
+ type: string;
78
+ agentId: string | null;
79
+ conversationId: string | null;
80
+ messageId: string | null;
81
+ properties: Record<string, unknown> | null;
82
+ userProperties: Record<string, unknown> | null;
83
+ metadata: Record<string, unknown> | null;
84
+ serverMetadata: {
85
+ [k: string]: unknown;
86
+ authMethod?: string;
87
+ } | null;
88
+ projectId: string;
89
+ tenantId: string;
90
+ id: string;
91
+ }[]>;
92
+ declare const deleteEventsByConversationIds: (db: AgentsRunDatabaseClient) => (params: {
93
+ scopes: ProjectScopeConfig;
94
+ conversationIds: string[];
95
+ }) => Promise<number>;
96
+ //#endregion
97
+ export { createEvent, deleteEventsByConversationIds, getEventById, listEventsByConversationId };
@@ -0,0 +1,47 @@
1
+ import { events } from "../../db/runtime/runtime-schema.js";
2
+ import { projectScopedWhere } from "../manage/scope-helpers.js";
3
+ import { and, desc, eq, inArray } from "drizzle-orm";
4
+
5
+ //#region src/data-access/runtime/events.ts
6
+ const createEvent = (db) => async (params) => {
7
+ const now = (/* @__PURE__ */ new Date()).toISOString();
8
+ const [inserted] = await db.insert(events).values({
9
+ ...params,
10
+ createdAt: now,
11
+ updatedAt: now
12
+ }).onConflictDoNothing({ target: [
13
+ events.tenantId,
14
+ events.projectId,
15
+ events.id
16
+ ] }).returning();
17
+ if (inserted) return {
18
+ row: inserted,
19
+ conflict: false
20
+ };
21
+ const [existing] = await db.select().from(events).where(and(projectScopedWhere(events, {
22
+ tenantId: params.tenantId,
23
+ projectId: params.projectId
24
+ }), eq(events.id, params.id))).limit(1);
25
+ if (!existing) throw new Error(`createEvent: insert returned no row and no existing row found for id=${params.id}`);
26
+ return {
27
+ row: existing,
28
+ conflict: true
29
+ };
30
+ };
31
+ const getEventById = (db) => async (params) => {
32
+ const [result] = await db.select().from(events).where(and(projectScopedWhere(events, params.scopes), eq(events.id, params.eventId))).limit(1);
33
+ return result;
34
+ };
35
+ const listEventsByConversationId = (db) => async (params) => {
36
+ const page = params.pagination?.page || 1;
37
+ const limit = Math.min(params.pagination?.limit || 100, 100);
38
+ const offset = (page - 1) * limit;
39
+ return db.select().from(events).where(and(projectScopedWhere(events, params.scopes), eq(events.conversationId, params.conversationId))).orderBy(desc(events.createdAt)).limit(limit).offset(offset);
40
+ };
41
+ const deleteEventsByConversationIds = (db) => async (params) => {
42
+ if (params.conversationIds.length === 0) return 0;
43
+ return (await db.delete(events).where(and(projectScopedWhere(events, params.scopes), inArray(events.conversationId, params.conversationIds))).returning()).length;
44
+ };
45
+
46
+ //#endregion
47
+ export { createEvent, deleteEventsByConversationIds, getEventById, listEventsByConversationId };
@@ -72,8 +72,8 @@ declare const getFeedbackByIds: (db: AgentsRunDatabaseClient) => (params: {
72
72
  declare const createFeedback: (db: AgentsRunDatabaseClient) => (params: FeedbackInsert) => Promise<{
73
73
  tenantId: string;
74
74
  projectId: string;
75
- type: "positive" | "negative";
76
75
  id: string;
76
+ type: "positive" | "negative";
77
77
  createdAt: string;
78
78
  updatedAt: string;
79
79
  conversationId: string;
@@ -102,8 +102,8 @@ declare const deleteFeedback: (db: AgentsRunDatabaseClient) => (params: {
102
102
  }) => Promise<{
103
103
  tenantId: string;
104
104
  projectId: string;
105
- type: "positive" | "negative";
106
105
  id: string;
106
+ type: "positive" | "negative";
107
107
  createdAt: string;
108
108
  updatedAt: string;
109
109
  conversationId: string;
@@ -13,12 +13,14 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
13
13
  tenantId: string;
14
14
  projectId: string;
15
15
  id: string;
16
- createdAt: string;
17
- updatedAt: string;
18
16
  metadata: MessageMetadata | null;
19
17
  content: MessageContent;
18
+ properties: Record<string, unknown> | null;
19
+ createdAt: string;
20
+ updatedAt: string;
20
21
  role: string;
21
22
  conversationId: string;
23
+ userProperties: Record<string, unknown> | null;
22
24
  fromSubAgentId: string | null;
23
25
  toSubAgentId: string | null;
24
26
  fromExternalAgentId: string | null;
@@ -54,6 +56,8 @@ declare const listMessages: (db: AgentsRunDatabaseClient) => (params: {
54
56
  a2aTaskId: string | null;
55
57
  a2aSessionId: string | null;
56
58
  metadata: MessageMetadata | null;
59
+ userProperties: Record<string, unknown> | null;
60
+ properties: Record<string, unknown> | null;
57
61
  projectId: string;
58
62
  tenantId: string;
59
63
  id: string;
@@ -81,6 +85,8 @@ declare const getMessagesByConversation: (db: AgentsRunDatabaseClient) => (param
81
85
  a2aTaskId: string | null;
82
86
  a2aSessionId: string | null;
83
87
  metadata: MessageMetadata | null;
88
+ userProperties: Record<string, unknown> | null;
89
+ properties: Record<string, unknown> | null;
84
90
  projectId: string;
85
91
  tenantId: string;
86
92
  id: string;
@@ -108,6 +114,8 @@ declare const getMessagesByTask: (db: AgentsRunDatabaseClient) => (params: {
108
114
  a2aTaskId: string | null;
109
115
  a2aSessionId: string | null;
110
116
  metadata: MessageMetadata | null;
117
+ userProperties: Record<string, unknown> | null;
118
+ properties: Record<string, unknown> | null;
111
119
  projectId: string;
112
120
  tenantId: string;
113
121
  id: string;
@@ -136,6 +144,8 @@ declare const getVisibleMessages: (db: AgentsRunDatabaseClient) => (params: {
136
144
  a2aTaskId: string | null;
137
145
  a2aSessionId: string | null;
138
146
  metadata: MessageMetadata | null;
147
+ userProperties: Record<string, unknown> | null;
148
+ properties: Record<string, unknown> | null;
139
149
  projectId: string;
140
150
  tenantId: string;
141
151
  id: string;
@@ -147,12 +157,14 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
147
157
  tenantId: string;
148
158
  projectId: string;
149
159
  id: string;
150
- createdAt: string;
151
- updatedAt: string;
152
160
  metadata: MessageMetadata | null;
153
161
  content: MessageContent;
162
+ properties: Record<string, unknown> | null;
163
+ createdAt: string;
164
+ updatedAt: string;
154
165
  role: string;
155
166
  conversationId: string;
167
+ userProperties: Record<string, unknown> | null;
156
168
  fromSubAgentId: string | null;
157
169
  toSubAgentId: string | null;
158
170
  fromExternalAgentId: string | null;
@@ -189,6 +201,8 @@ declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
189
201
  a2aTaskId: string | null;
190
202
  a2aSessionId: string | null;
191
203
  metadata: MessageMetadata | null;
204
+ userProperties: Record<string, unknown> | null;
205
+ properties: Record<string, unknown> | null;
192
206
  projectId: string;
193
207
  tenantId: string;
194
208
  id: string;
@@ -200,12 +214,14 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
200
214
  tenantId: string;
201
215
  projectId: string;
202
216
  id: string;
203
- createdAt: string;
204
- updatedAt: string;
205
217
  metadata: MessageMetadata | null;
206
218
  content: MessageContent;
219
+ properties: Record<string, unknown> | null;
220
+ createdAt: string;
221
+ updatedAt: string;
207
222
  role: string;
208
223
  conversationId: string;
224
+ userProperties: Record<string, unknown> | null;
209
225
  fromSubAgentId: string | null;
210
226
  toSubAgentId: string | null;
211
227
  fromExternalAgentId: string | null;
@@ -40,7 +40,7 @@ declare const listScheduledTriggerInvocationsPaginated: (db: AgentsRunDatabaseCl
40
40
  name: string;
41
41
  hash: string;
42
42
  } | null;
43
- status: "pending" | "running" | "completed" | "failed" | "cancelled";
43
+ status: "pending" | "failed" | "running" | "completed" | "cancelled";
44
44
  scheduledFor: string;
45
45
  startedAt: string | null;
46
46
  completedAt: string | null;
@@ -199,7 +199,7 @@ declare const listUpcomingInvocationsForAgentPaginated: (db: AgentsRunDatabaseCl
199
199
  name: string;
200
200
  hash: string;
201
201
  } | null;
202
- status: "pending" | "running" | "completed" | "failed" | "cancelled";
202
+ status: "pending" | "failed" | "running" | "completed" | "cancelled";
203
203
  scheduledFor: string;
204
204
  startedAt: string | null;
205
205
  completedAt: string | null;
@@ -239,7 +239,7 @@ declare const listProjectScheduledTriggerInvocationsPaginated: (db: AgentsRunDat
239
239
  name: string;
240
240
  hash: string;
241
241
  } | null;
242
- status: "pending" | "running" | "completed" | "failed" | "cancelled";
242
+ status: "pending" | "failed" | "running" | "completed" | "cancelled";
243
243
  scheduledFor: string;
244
244
  startedAt: string | null;
245
245
  completedAt: string | null;
@@ -292,7 +292,7 @@ declare const listScheduledTriggerInvocationsByTriggerId: (db: AgentsRunDatabase
292
292
  name: string;
293
293
  hash: string;
294
294
  } | null;
295
- status: "pending" | "running" | "completed" | "failed" | "cancelled";
295
+ status: "pending" | "failed" | "running" | "completed" | "cancelled";
296
296
  scheduledFor: string;
297
297
  startedAt: string | null;
298
298
  completedAt: string | null;
@@ -9,18 +9,18 @@ import { TaskInsert, TaskSelect } from "../../types/entities.js";
9
9
  declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert) => Promise<{
10
10
  tenantId: string;
11
11
  projectId: string;
12
+ id: string;
13
+ metadata: TaskMetadataConfig | null;
12
14
  agentId: string;
13
15
  subAgentId: string;
14
- id: string;
15
- status: string;
16
16
  createdAt: string;
17
17
  updatedAt: string;
18
- metadata: TaskMetadataConfig | null;
19
18
  ref: {
20
19
  type: "commit" | "tag" | "branch";
21
20
  name: string;
22
21
  hash: string;
23
22
  } | null;
23
+ status: string;
24
24
  contextId: string;
25
25
  }>;
26
26
  declare const getTask: (db: AgentsRunDatabaseClient) => (params: {