@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
@@ -11,9 +11,9 @@ declare const getSubAgentTeamAgentRelationById: (db: AgentsManageDatabaseClient)
11
11
  }) => Promise<{
12
12
  tenantId: string;
13
13
  projectId: string;
14
+ id: string;
14
15
  agentId: string;
15
16
  subAgentId: string;
16
- id: string;
17
17
  createdAt: string;
18
18
  updatedAt: string;
19
19
  headers: Record<string, string> | null;
@@ -46,9 +46,9 @@ declare const getSubAgentTeamAgentRelations: (db: AgentsManageDatabaseClient) =>
46
46
  }) => Promise<{
47
47
  tenantId: string;
48
48
  projectId: string;
49
+ id: string;
49
50
  agentId: string;
50
51
  subAgentId: string;
51
- id: string;
52
52
  createdAt: string;
53
53
  updatedAt: string;
54
54
  headers: Record<string, string> | null;
@@ -59,9 +59,9 @@ declare const getSubAgentTeamAgentRelationsByAgent: (db: AgentsManageDatabaseCli
59
59
  }) => Promise<{
60
60
  tenantId: string;
61
61
  projectId: string;
62
+ id: string;
62
63
  agentId: string;
63
64
  subAgentId: string;
64
- id: string;
65
65
  createdAt: string;
66
66
  updatedAt: string;
67
67
  headers: Record<string, string> | null;
@@ -224,9 +224,9 @@ declare const createSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient)
224
224
  }) => Promise<{
225
225
  tenantId: string;
226
226
  projectId: string;
227
+ id: string;
227
228
  agentId: string;
228
229
  subAgentId: string;
229
- id: string;
230
230
  createdAt: string;
231
231
  updatedAt: string;
232
232
  headers: Record<string, string> | null;
@@ -241,9 +241,9 @@ declare const getSubAgentTeamAgentRelationByParams: (db: AgentsManageDatabaseCli
241
241
  }) => Promise<{
242
242
  tenantId: string;
243
243
  projectId: string;
244
+ id: string;
244
245
  agentId: string;
245
246
  subAgentId: string;
246
- id: string;
247
247
  createdAt: string;
248
248
  updatedAt: string;
249
249
  headers: Record<string, string> | null;
@@ -262,9 +262,9 @@ declare const upsertSubAgentTeamAgentRelation: (db: AgentsManageDatabaseClient)
262
262
  }) => Promise<{
263
263
  tenantId: string;
264
264
  projectId: string;
265
+ id: string;
265
266
  agentId: string;
266
267
  subAgentId: string;
267
- id: string;
268
268
  createdAt: string;
269
269
  updatedAt: string;
270
270
  headers: Record<string, string> | null;
@@ -11,12 +11,13 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
11
11
  }) => Promise<{
12
12
  tenantId: string;
13
13
  projectId: string;
14
- agentId: string;
15
14
  id: string;
16
15
  name: string;
16
+ description: string | null;
17
+ agentId: string;
17
18
  createdAt: string;
18
19
  updatedAt: string;
19
- description: string | null;
20
+ prompt: string | null;
20
21
  models: {
21
22
  base?: {
22
23
  model?: string | undefined;
@@ -40,7 +41,6 @@ declare const getSubAgentById: (db: AgentsManageDatabaseClient) => (params: {
40
41
  stopWhen: {
41
42
  stepCountIs?: number | undefined;
42
43
  } | null;
43
- prompt: string | null;
44
44
  conversationHistoryConfig: ConversationHistoryConfig | null;
45
45
  } | undefined>;
46
46
  declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
@@ -48,12 +48,13 @@ declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
48
48
  }) => Promise<{
49
49
  tenantId: string;
50
50
  projectId: string;
51
- agentId: string;
52
51
  id: string;
53
52
  name: string;
53
+ description: string | null;
54
+ agentId: string;
54
55
  createdAt: string;
55
56
  updatedAt: string;
56
- description: string | null;
57
+ prompt: string | null;
57
58
  models: {
58
59
  base?: {
59
60
  model?: string | undefined;
@@ -77,7 +78,6 @@ declare const listSubAgents: (db: AgentsManageDatabaseClient) => (params: {
77
78
  stopWhen: {
78
79
  stepCountIs?: number | undefined;
79
80
  } | null;
80
- prompt: string | null;
81
81
  conversationHistoryConfig: ConversationHistoryConfig | null;
82
82
  }[]>;
83
83
  declare const listSubAgentsPaginated: (db: AgentsManageDatabaseClient) => (params: {
@@ -129,12 +129,13 @@ declare const listSubAgentsPaginated: (db: AgentsManageDatabaseClient) => (param
129
129
  declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAgentInsert) => Promise<{
130
130
  tenantId: string;
131
131
  projectId: string;
132
- agentId: string;
133
132
  id: string;
134
133
  name: string;
134
+ description: string | null;
135
+ agentId: string;
135
136
  createdAt: string;
136
137
  updatedAt: string;
137
- description: string | null;
138
+ prompt: string | null;
138
139
  models: {
139
140
  base?: {
140
141
  model?: string | undefined;
@@ -158,7 +159,6 @@ declare const createSubAgent: (db: AgentsManageDatabaseClient) => (params: SubAg
158
159
  stopWhen: {
159
160
  stepCountIs?: number | undefined;
160
161
  } | null;
161
- prompt: string | null;
162
162
  conversationHistoryConfig: ConversationHistoryConfig | null;
163
163
  }>;
164
164
  declare const updateSubAgent: (db: AgentsManageDatabaseClient) => (params: {
@@ -24,16 +24,16 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
24
24
  projectId: string;
25
25
  id: string;
26
26
  name: string;
27
+ description: string | null;
27
28
  createdAt: string;
28
29
  updatedAt: string;
29
- description: string | null;
30
+ headers: Record<string, string> | null;
30
31
  config: {
31
32
  type: "mcp";
32
33
  mcp: ToolMcpConfig;
33
34
  };
34
35
  credentialReferenceId: string | null;
35
36
  credentialScope: string;
36
- headers: Record<string, string> | null;
37
37
  imageUrl: string | null;
38
38
  capabilities: ToolServerCapabilities | null;
39
39
  lastError: string | null;
@@ -82,16 +82,16 @@ declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInser
82
82
  projectId: string;
83
83
  id: string;
84
84
  name: string;
85
+ description: string | null;
85
86
  createdAt: string;
86
87
  updatedAt: string;
87
- description: string | null;
88
+ headers: Record<string, string> | null;
88
89
  config: {
89
90
  type: "mcp";
90
91
  mcp: ToolMcpConfig;
91
92
  };
92
93
  credentialReferenceId: string | null;
93
94
  credentialScope: string;
94
- headers: Record<string, string> | null;
95
95
  imageUrl: string | null;
96
96
  capabilities: ToolServerCapabilities | null;
97
97
  lastError: string | null;
@@ -137,17 +137,17 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
137
137
  }) => Promise<{
138
138
  tenantId: string;
139
139
  projectId: string;
140
+ id: string;
140
141
  agentId: string;
141
142
  subAgentId: string;
142
143
  toolId: string;
143
- id: string;
144
144
  createdAt: string;
145
145
  updatedAt: string;
146
146
  headers: Record<string, string> | null;
147
- selectedTools: string[] | null;
148
147
  toolPolicies: Record<string, {
149
148
  needsApproval?: boolean;
150
149
  }> | null;
150
+ selectedTools: string[] | null;
151
151
  }>;
152
152
  declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params: {
153
153
  scopes: AgentScopeConfig;
@@ -156,17 +156,17 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
156
156
  }) => Promise<{
157
157
  tenantId: string;
158
158
  projectId: string;
159
+ id: string;
159
160
  agentId: string;
160
161
  subAgentId: string;
161
162
  toolId: string;
162
- id: string;
163
163
  createdAt: string;
164
164
  updatedAt: string;
165
165
  headers: Record<string, string> | null;
166
- selectedTools: string[] | null;
167
166
  toolPolicies: Record<string, {
168
167
  needsApproval?: boolean;
169
168
  }> | null;
169
+ selectedTools: string[] | null;
170
170
  }>;
171
171
  /**
172
172
  * Upsert agent-tool relation (create if it doesn't exist, update if it does)
@@ -184,17 +184,17 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
184
184
  }) => Promise<{
185
185
  tenantId: string;
186
186
  projectId: string;
187
+ id: string;
187
188
  agentId: string;
188
189
  subAgentId: string;
189
190
  toolId: string;
190
- id: string;
191
191
  createdAt: string;
192
192
  updatedAt: string;
193
193
  headers: Record<string, string> | null;
194
- selectedTools: string[] | null;
195
194
  toolPolicies: Record<string, {
196
195
  needsApproval?: boolean;
197
196
  }> | null;
197
+ selectedTools: string[] | null;
198
198
  }>;
199
199
  /**
200
200
  * Upsert a tool (create if it doesn't exist, update if it does)
@@ -206,16 +206,16 @@ declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
206
206
  projectId: string;
207
207
  id: string;
208
208
  name: string;
209
+ description: string | null;
209
210
  createdAt: string;
210
211
  updatedAt: string;
211
- description: string | null;
212
+ headers: Record<string, string> | null;
212
213
  config: {
213
214
  type: "mcp";
214
215
  mcp: ToolMcpConfig;
215
216
  };
216
217
  credentialReferenceId: string | null;
217
218
  credentialScope: string;
218
- headers: Record<string, string> | null;
219
219
  imageUrl: string | null;
220
220
  capabilities: ToolServerCapabilities | null;
221
221
  lastError: string | null;
@@ -10,9 +10,9 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
10
10
  }) => Promise<{
11
11
  tenantId: string;
12
12
  projectId: string;
13
- agentId: string;
14
13
  id: string;
15
14
  name: string | null;
15
+ agentId: string;
16
16
  createdAt: string;
17
17
  updatedAt: string;
18
18
  expiresAt: string | null;
@@ -24,9 +24,9 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
24
24
  declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
25
25
  tenantId: string;
26
26
  projectId: string;
27
- agentId: string;
28
27
  id: string;
29
28
  name: string | null;
29
+ agentId: string;
30
30
  createdAt: string;
31
31
  updatedAt: string;
32
32
  expiresAt: string | null;
@@ -41,9 +41,9 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
41
41
  }) => Promise<{
42
42
  tenantId: string;
43
43
  projectId: string;
44
- agentId: string;
45
44
  id: string;
46
45
  name: string | null;
46
+ agentId: string;
47
47
  createdAt: string;
48
48
  updatedAt: string;
49
49
  expiresAt: string | null;
@@ -68,9 +68,9 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
68
68
  declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
69
69
  tenantId: string;
70
70
  projectId: string;
71
- agentId: string;
72
71
  id: string;
73
72
  name: string | null;
73
+ agentId: string;
74
74
  createdAt: string;
75
75
  updatedAt: string;
76
76
  expiresAt: string | null;
@@ -7,12 +7,14 @@ import { AppInsert, AppSelect, AppUpdate } from "../../types/entities.js";
7
7
  declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promise<{
8
8
  tenantId: string | null;
9
9
  projectId: string | null;
10
- type: AppType;
11
10
  id: string;
12
11
  name: string;
12
+ description: string | null;
13
+ type: AppType;
13
14
  createdAt: string;
14
15
  updatedAt: string;
15
- description: string | null;
16
+ enabled: boolean;
17
+ prompt: string | null;
16
18
  config: {
17
19
  type: "web_client";
18
20
  webClient: {
@@ -43,8 +45,6 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
43
45
  }[] | undefined;
44
46
  };
45
47
  };
46
- prompt: string | null;
47
- enabled: boolean;
48
48
  lastUsedAt: string | null;
49
49
  defaultProjectId: string | null;
50
50
  defaultAgentId: string | null;
@@ -76,12 +76,14 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
76
76
  declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
77
77
  tenantId: string | null;
78
78
  projectId: string | null;
79
- type: AppType;
80
79
  id: string;
81
80
  name: string;
81
+ description: string | null;
82
+ type: AppType;
82
83
  createdAt: string;
83
84
  updatedAt: string;
84
- description: string | null;
85
+ enabled: boolean;
86
+ prompt: string | null;
85
87
  config: {
86
88
  type: "web_client";
87
89
  webClient: {
@@ -112,8 +114,6 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
112
114
  }[] | undefined;
113
115
  };
114
116
  };
115
- prompt: string | null;
116
- enabled: boolean;
117
117
  lastUsedAt: string | null;
118
118
  defaultProjectId: string | null;
119
119
  defaultAgentId: string | null;
@@ -3,8 +3,16 @@ import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
3
3
  import "../../types/index.js";
4
4
 
5
5
  //#region src/data-access/runtime/cascade-delete.d.ts
6
+
6
7
  /**
7
- * Result of a cascade delete operation
8
+ * Result of a cascade delete operation.
9
+ *
10
+ * Conversation-child cleanup strategies in this module (taxonomy):
11
+ * - DB-level FK cascade only: feedback
12
+ * - DB-level FK cascade plus app-level explicit delete: messages, contextCache
13
+ * - App-level only (no FK): events — forward-anchored events may reference
14
+ * conversation/message IDs that don't yet exist, so an FK is incompatible
15
+ * with the table's analytics-stream semantics (see specs/2026-05-11-events-drop-fk/SPEC.md).
8
16
  */
9
17
  type CascadeDeleteResult = {
10
18
  conversationsDeleted: number;
@@ -20,10 +28,12 @@ type CascadeDeleteResult = {
20
28
  appsDeleted: number;
21
29
  appDefaultsCleared: number;
22
30
  scheduledTriggersDeleted: number;
31
+ eventsDeleted: number;
23
32
  };
24
33
  /**
25
34
  * Delete all runtime entities for a specific branch.
26
- * PostgreSQL cascades handle: messages, taskRelations, ledgerArtifacts
35
+ * PostgreSQL cascades handle: messages, taskRelations, ledgerArtifacts.
36
+ * Events are deleted explicitly before conversations (no FK cascade).
27
37
  *
28
38
  * @param db - Runtime database client
29
39
  * @returns Function that performs the cascade delete
@@ -36,7 +46,8 @@ declare const cascadeDeleteByBranch: (db: AgentsRunDatabaseClient) => (params: {
36
46
  /**
37
47
  * Delete all runtime entities for a project across all branches.
38
48
  * Used when deleting a project entirely.
39
- * PostgreSQL cascades handle: messages, taskRelations, ledgerArtifacts
49
+ * PostgreSQL cascades handle: messages, taskRelations, ledgerArtifacts.
50
+ * Events are deleted explicitly before conversations (no FK cascade).
40
51
  *
41
52
  * @param db - Runtime database client
42
53
  * @returns Function that performs the cascade delete
@@ -1,6 +1,7 @@
1
- import { apiKeys, contextCache, conversations, datasetRun, evaluationRun, scheduledTriggerInvocations, scheduledTriggers, tasks, triggerInvocations, workAppGitHubMcpToolAccessMode, workAppGitHubMcpToolRepositoryAccess, workAppGitHubProjectAccessMode, workAppGitHubProjectRepositoryAccess } from "../../db/runtime/runtime-schema.js";
1
+ import { apiKeys, contextCache, conversations, datasetRun, evaluationRun, events, scheduledTriggerInvocations, scheduledTriggers, tasks, triggerInvocations, workAppGitHubMcpToolAccessMode, workAppGitHubMcpToolRepositoryAccess, workAppGitHubProjectAccessMode, workAppGitHubProjectRepositoryAccess } from "../../db/runtime/runtime-schema.js";
2
2
  import { projectScopedWhere } from "../manage/scope-helpers.js";
3
3
  import { clearAppDefaultsByAgent, clearAppDefaultsByProject, deleteAppsByProject } from "./apps.js";
4
+ import { deleteEventsByConversationIds } from "./events.js";
4
5
  import { deleteSlackMcpToolAccessConfig } from "./slack-work-app-mcp.js";
5
6
  import { clearDevConfigWorkspaceDefaultsByAgent, clearDevConfigWorkspaceDefaultsByProject, clearWorkspaceDefaultsByAgent, clearWorkspaceDefaultsByProject, deleteWorkAppSlackChannelAgentConfigsByAgent, deleteWorkAppSlackChannelAgentConfigsByProject } from "./workAppSlack.js";
6
7
  import { and, eq, inArray, sql } from "drizzle-orm";
@@ -8,7 +9,8 @@ import { and, eq, inArray, sql } from "drizzle-orm";
8
9
  //#region src/data-access/runtime/cascade-delete.ts
9
10
  /**
10
11
  * Delete all runtime entities for a specific branch.
11
- * PostgreSQL cascades handle: messages, taskRelations, ledgerArtifacts
12
+ * PostgreSQL cascades handle: messages, taskRelations, ledgerArtifacts.
13
+ * Events are deleted explicitly before conversations (no FK cascade).
12
14
  *
13
15
  * @param db - Runtime database client
14
16
  * @returns Function that performs the cascade delete
@@ -16,6 +18,11 @@ import { and, eq, inArray, sql } from "drizzle-orm";
16
18
  const cascadeDeleteByBranch = (db) => async (params) => {
17
19
  const { scopes, fullBranchName, ref } = params;
18
20
  const contextCacheResult = await db.delete(contextCache).where(and(projectScopedWhere(contextCache, scopes), sql`${contextCache.ref}->>'name' = ${fullBranchName}`)).returning();
21
+ const branchConversationIds = (await db.select({ id: conversations.id }).from(conversations).where(and(projectScopedWhere(conversations, scopes), sql`${conversations.ref}->>'name' = ${fullBranchName}`))).map((c) => c.id);
22
+ const eventsDeleted = await deleteEventsByConversationIds(db)({
23
+ scopes,
24
+ conversationIds: branchConversationIds
25
+ });
19
26
  const conversationsResult = await db.delete(conversations).where(and(projectScopedWhere(conversations, scopes), sql`${conversations.ref}->>'name' = ${fullBranchName}`)).returning();
20
27
  const tasksResult = await db.delete(tasks).where(and(projectScopedWhere(tasks, scopes), sql`${tasks.ref}->>'name' = ${fullBranchName}`)).returning();
21
28
  const triggerInvocationsResult = await db.delete(triggerInvocations).where(and(eq(triggerInvocations.tenantId, scopes.tenantId), eq(triggerInvocations.projectId, scopes.projectId), sql`${triggerInvocations.ref}->>'name' = ${fullBranchName}`)).returning();
@@ -36,13 +43,15 @@ const cascadeDeleteByBranch = (db) => async (params) => {
36
43
  slackWorkspaceDefaultsCleared: 0,
37
44
  appsDeleted: 0,
38
45
  appDefaultsCleared: 0,
39
- scheduledTriggersDeleted: scheduledTriggersResult.length
46
+ scheduledTriggersDeleted: scheduledTriggersResult.length,
47
+ eventsDeleted
40
48
  };
41
49
  };
42
50
  /**
43
51
  * Delete all runtime entities for a project across all branches.
44
52
  * Used when deleting a project entirely.
45
- * PostgreSQL cascades handle: messages, taskRelations, ledgerArtifacts
53
+ * PostgreSQL cascades handle: messages, taskRelations, ledgerArtifacts.
54
+ * Events are deleted explicitly before conversations (no FK cascade).
46
55
  *
47
56
  * @param db - Runtime database client
48
57
  * @returns Function that performs the cascade delete
@@ -50,6 +59,7 @@ const cascadeDeleteByBranch = (db) => async (params) => {
50
59
  const cascadeDeleteByProject = (db) => async (params) => {
51
60
  const { scopes } = params;
52
61
  const contextCacheResult = await db.delete(contextCache).where(projectScopedWhere(contextCache, scopes)).returning();
62
+ const eventsResult = await db.delete(events).where(projectScopedWhere(events, scopes)).returning();
53
63
  const conversationsResult = await db.delete(conversations).where(projectScopedWhere(conversations, scopes)).returning();
54
64
  const tasksResult = await db.delete(tasks).where(projectScopedWhere(tasks, scopes)).returning();
55
65
  const triggerInvocationsResult = await db.delete(triggerInvocations).where(and(eq(triggerInvocations.tenantId, scopes.tenantId), eq(triggerInvocations.projectId, scopes.projectId))).returning();
@@ -80,7 +90,8 @@ const cascadeDeleteByProject = (db) => async (params) => {
80
90
  slackWorkspaceDefaultsCleared,
81
91
  appsDeleted,
82
92
  appDefaultsCleared,
83
- scheduledTriggersDeleted: scheduledTriggersResult.length
93
+ scheduledTriggersDeleted: scheduledTriggersResult.length,
94
+ eventsDeleted: eventsResult.length
84
95
  };
85
96
  };
86
97
  /**
@@ -97,10 +108,15 @@ const cascadeDeleteByAgent = (db) => async (params) => {
97
108
  let conversationsDeleted = 0;
98
109
  let tasksDeleted = 0;
99
110
  let apiKeysDeleted = 0;
111
+ let eventsDeleted = 0;
100
112
  if (subAgentIds.length > 0) {
101
113
  const conversationIds = (await db.select({ id: conversations.id }).from(conversations).where(and(projectScopedWhere(conversations, scopes), inArray(conversations.activeSubAgentId, subAgentIds), sql`${conversations.ref}->>'name' = ${fullBranchName}`))).map((c) => c.id);
102
114
  if (conversationIds.length > 0) {
103
115
  contextCacheDeleted = (await db.delete(contextCache).where(and(projectScopedWhere(contextCache, scopes), inArray(contextCache.conversationId, conversationIds))).returning()).length;
116
+ eventsDeleted = await deleteEventsByConversationIds(db)({
117
+ scopes,
118
+ conversationIds
119
+ });
104
120
  conversationsDeleted = (await db.delete(conversations).where(and(projectScopedWhere(conversations, scopes), inArray(conversations.id, conversationIds))).returning()).length;
105
121
  }
106
122
  }
@@ -126,7 +142,8 @@ const cascadeDeleteByAgent = (db) => async (params) => {
126
142
  slackWorkspaceDefaultsCleared,
127
143
  appsDeleted: 0,
128
144
  appDefaultsCleared,
129
- scheduledTriggersDeleted: scheduledTriggersResult.length
145
+ scheduledTriggersDeleted: scheduledTriggersResult.length,
146
+ eventsDeleted
130
147
  };
131
148
  };
132
149
  /**
@@ -140,8 +157,13 @@ const cascadeDeleteBySubAgent = (db) => async (params) => {
140
157
  const conversationIds = (await db.select({ id: conversations.id }).from(conversations).where(and(projectScopedWhere(conversations, scopes), eq(conversations.activeSubAgentId, subAgentId), sql`${conversations.ref}->>'name' = ${fullBranchName}`))).map((c) => c.id);
141
158
  let contextCacheDeleted = 0;
142
159
  let conversationsDeleted = 0;
160
+ let eventsDeleted = 0;
143
161
  if (conversationIds.length > 0) {
144
162
  contextCacheDeleted = (await db.delete(contextCache).where(and(projectScopedWhere(contextCache, scopes), inArray(contextCache.conversationId, conversationIds))).returning()).length;
163
+ eventsDeleted = await deleteEventsByConversationIds(db)({
164
+ scopes,
165
+ conversationIds
166
+ });
145
167
  conversationsDeleted = (await db.delete(conversations).where(and(projectScopedWhere(conversations, scopes), inArray(conversations.id, conversationIds))).returning()).length;
146
168
  }
147
169
  const tasksResult = await db.delete(tasks).where(and(projectScopedWhere(tasks, scopes), eq(tasks.subAgentId, subAgentId), sql`${tasks.ref}->>'name' = ${fullBranchName}`)).returning();
@@ -158,7 +180,8 @@ const cascadeDeleteBySubAgent = (db) => async (params) => {
158
180
  slackWorkspaceDefaultsCleared: 0,
159
181
  appsDeleted: 0,
160
182
  appDefaultsCleared: 0,
161
- scheduledTriggersDeleted: 0
183
+ scheduledTriggersDeleted: 0,
184
+ eventsDeleted
162
185
  };
163
186
  };
164
187
  /**
@@ -17,18 +17,20 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
17
17
  declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
18
18
  tenantId: string;
19
19
  projectId: string;
20
- agentId: string | null;
21
20
  id: string;
22
- createdAt: string;
23
- updatedAt: string;
24
21
  metadata: ConversationMetadata | null;
22
+ properties: Record<string, unknown> | null;
25
23
  title: string | null;
26
- userId: string | null;
24
+ agentId: string | null;
25
+ createdAt: string;
26
+ updatedAt: string;
27
27
  ref: {
28
28
  type: "commit" | "tag" | "branch";
29
29
  name: string;
30
30
  hash: string;
31
31
  } | null;
32
+ userId: string | null;
33
+ userProperties: Record<string, unknown> | null;
32
34
  activeSubAgentId: string;
33
35
  lastContextResolution: string | null;
34
36
  }>;
@@ -50,6 +52,8 @@ declare const updateConversation: (db: AgentsRunDatabaseClient) => (params: {
50
52
  title: string | null;
51
53
  lastContextResolution: string | null;
52
54
  metadata: ConversationMetadata | null;
55
+ userProperties: Record<string, unknown> | null;
56
+ properties: Record<string, unknown> | null;
53
57
  projectId: string;
54
58
  tenantId: string;
55
59
  id: string;
@@ -76,6 +80,8 @@ declare const updateConversationActiveSubAgent: (db: AgentsRunDatabaseClient) =>
76
80
  title: string | null;
77
81
  lastContextResolution: string | null;
78
82
  metadata: ConversationMetadata | null;
83
+ userProperties: Record<string, unknown> | null;
84
+ properties: Record<string, unknown> | null;
79
85
  projectId: string;
80
86
  tenantId: string;
81
87
  id: string;
@@ -86,18 +92,20 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
86
92
  }) => Promise<{
87
93
  tenantId: string;
88
94
  projectId: string;
89
- agentId: string | null;
90
95
  id: string;
91
- createdAt: string;
92
- updatedAt: string;
93
96
  metadata: ConversationMetadata | null;
97
+ properties: Record<string, unknown> | null;
94
98
  title: string | null;
95
- userId: string | null;
99
+ agentId: string | null;
100
+ createdAt: string;
101
+ updatedAt: string;
96
102
  ref: {
97
103
  type: "commit" | "tag" | "branch";
98
104
  name: string;
99
105
  hash: string;
100
106
  } | null;
107
+ userId: string | null;
108
+ userProperties: Record<string, unknown> | null;
101
109
  activeSubAgentId: string;
102
110
  lastContextResolution: string | null;
103
111
  } | undefined>;
@@ -119,21 +127,25 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
119
127
  lastContextResolution?: string | null | undefined;
120
128
  metadata?: ConversationMetadata | null | undefined;
121
129
  contextConfigId?: string | undefined;
130
+ userProperties?: Record<string, unknown> | null | undefined;
131
+ properties?: Record<string, unknown> | null | undefined;
122
132
  } | {
123
133
  tenantId: string;
124
134
  projectId: string;
125
- agentId: string | null;
126
135
  id: string;
127
- createdAt: string;
128
- updatedAt: string;
129
136
  metadata: ConversationMetadata | null;
137
+ properties: Record<string, unknown> | null;
130
138
  title: string | null;
131
- userId: string | null;
139
+ agentId: string | null;
140
+ createdAt: string;
141
+ updatedAt: string;
132
142
  ref: {
133
143
  type: "commit" | "tag" | "branch";
134
144
  name: string;
135
145
  hash: string;
136
146
  } | null;
147
+ userId: string | null;
148
+ userProperties: Record<string, unknown> | null;
137
149
  activeSubAgentId: string;
138
150
  lastContextResolution: string | null;
139
151
  }>;
@@ -154,18 +166,20 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
154
166
  }) => Promise<{
155
167
  tenantId: string;
156
168
  projectId: string;
157
- agentId: string | null;
158
169
  id: string;
159
- createdAt: string;
160
- updatedAt: string;
161
170
  metadata: ConversationMetadata | null;
171
+ properties: Record<string, unknown> | null;
162
172
  title: string | null;
163
- userId: string | null;
173
+ agentId: string | null;
174
+ createdAt: string;
175
+ updatedAt: string;
164
176
  ref: {
165
177
  type: "commit" | "tag" | "branch";
166
178
  name: string;
167
179
  hash: string;
168
180
  } | null;
181
+ userId: string | null;
182
+ userProperties: Record<string, unknown> | null;
169
183
  activeSubAgentId: string;
170
184
  lastContextResolution: string | null;
171
185
  } | undefined>;
@@ -180,6 +194,8 @@ declare const setActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
180
194
  ref: ResolvedRef;
181
195
  userId?: string;
182
196
  metadata?: ConversationMetadata;
197
+ userProperties?: Record<string, unknown> | null;
198
+ properties?: Record<string, unknown> | null;
183
199
  }) => Promise<void>;
184
200
  declare const setActiveAgentForThread: (db: AgentsRunDatabaseClient) => ({
185
201
  scopes,