@inkeep/agents-core 0.72.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.
- package/dist/auth/auth.d.ts +9 -9
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/data-access/index.d.ts +2 -2
- package/dist/data-access/index.js +2 -2
- package/dist/data-access/manage/agents.d.ts +26 -26
- package/dist/data-access/manage/artifactComponents.d.ts +14 -14
- package/dist/data-access/manage/contextConfigs.d.ts +20 -20
- package/dist/data-access/manage/dataComponents.d.ts +6 -6
- package/dist/data-access/manage/functionTools.d.ts +18 -18
- package/dist/data-access/manage/skills.d.ts +12 -12
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgentRelations.d.ts +26 -26
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgents.d.ts +18 -18
- package/dist/data-access/manage/tools.d.ts +24 -24
- package/dist/data-access/manage/triggers.d.ts +5 -5
- package/dist/data-access/runtime/apiKeys.d.ts +16 -16
- package/dist/data-access/runtime/apps.d.ts +12 -12
- package/dist/data-access/runtime/cascade-delete.d.ts +14 -3
- package/dist/data-access/runtime/cascade-delete.js +30 -7
- package/dist/data-access/runtime/conversations.d.ts +24 -24
- package/dist/data-access/runtime/conversations.js +13 -1
- package/dist/data-access/runtime/events.d.ts +11 -7
- package/dist/data-access/runtime/events.js +6 -2
- package/dist/data-access/runtime/feedback.d.ts +8 -8
- package/dist/data-access/runtime/messages.d.ts +27 -27
- package/dist/data-access/runtime/scheduledTriggerUsers.d.ts +1 -1
- package/dist/data-access/runtime/tasks.d.ts +5 -5
- package/dist/db/manage/manage-schema.d.ts +4 -4
- package/dist/db/runtime/runtime-schema.d.ts +2 -2
- package/dist/db/runtime/runtime-schema.js +1 -27
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/utils/error.d.ts +51 -51
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/schemas/skills.d.ts +19 -19
- package/dist/validation/schemas.d.ts +865 -865
- package/drizzle/runtime/0041_salty_wilson_fisk.sql +3 -0
- package/drizzle/runtime/meta/0041_snapshot.json +6298 -0
- package/drizzle/runtime/meta/_journal.json +7 -0
- package/package.json +1 -1
|
@@ -8,13 +8,13 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
8
8
|
scopes: ProjectScopeConfig;
|
|
9
9
|
id: string;
|
|
10
10
|
}) => Promise<{
|
|
11
|
+
tenantId: string;
|
|
12
|
+
projectId: string;
|
|
11
13
|
id: string;
|
|
12
|
-
createdAt: string;
|
|
13
14
|
name: string | null;
|
|
14
|
-
updatedAt: string;
|
|
15
15
|
agentId: string;
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
18
|
expiresAt: string | null;
|
|
19
19
|
publicId: string;
|
|
20
20
|
keyHash: string;
|
|
@@ -22,13 +22,13 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
22
22
|
lastUsedAt: string | null;
|
|
23
23
|
} | undefined>;
|
|
24
24
|
declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
|
|
25
|
+
tenantId: string;
|
|
26
|
+
projectId: string;
|
|
25
27
|
id: string;
|
|
26
|
-
createdAt: string;
|
|
27
28
|
name: string | null;
|
|
28
|
-
updatedAt: string;
|
|
29
29
|
agentId: string;
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
createdAt: string;
|
|
31
|
+
updatedAt: string;
|
|
32
32
|
expiresAt: string | null;
|
|
33
33
|
publicId: string;
|
|
34
34
|
keyHash: string;
|
|
@@ -39,13 +39,13 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
39
39
|
scopes: ProjectScopeConfig;
|
|
40
40
|
agentId?: string;
|
|
41
41
|
}) => Promise<{
|
|
42
|
+
tenantId: string;
|
|
43
|
+
projectId: string;
|
|
42
44
|
id: string;
|
|
43
|
-
createdAt: string;
|
|
44
45
|
name: string | null;
|
|
45
|
-
updatedAt: string;
|
|
46
46
|
agentId: string;
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
createdAt: string;
|
|
48
|
+
updatedAt: string;
|
|
49
49
|
expiresAt: string | null;
|
|
50
50
|
publicId: string;
|
|
51
51
|
keyHash: string;
|
|
@@ -66,13 +66,13 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
66
66
|
};
|
|
67
67
|
}>;
|
|
68
68
|
declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
|
|
69
|
+
tenantId: string;
|
|
70
|
+
projectId: string;
|
|
69
71
|
id: string;
|
|
70
|
-
createdAt: string;
|
|
71
72
|
name: string | null;
|
|
72
|
-
updatedAt: string;
|
|
73
73
|
agentId: string;
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
createdAt: string;
|
|
75
|
+
updatedAt: string;
|
|
76
76
|
expiresAt: string | null;
|
|
77
77
|
publicId: string;
|
|
78
78
|
keyHash: string;
|
|
@@ -5,15 +5,15 @@ import { AppInsert, AppSelect, AppUpdate } from "../../types/entities.js";
|
|
|
5
5
|
|
|
6
6
|
//#region src/data-access/runtime/apps.d.ts
|
|
7
7
|
declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promise<{
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
tenantId: string | null;
|
|
9
|
+
projectId: string | null;
|
|
10
10
|
id: string;
|
|
11
|
-
createdAt: string;
|
|
12
11
|
name: string;
|
|
13
|
-
updatedAt: string;
|
|
14
|
-
projectId: string | null;
|
|
15
|
-
tenantId: string | null;
|
|
16
12
|
description: string | null;
|
|
13
|
+
type: AppType;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
enabled: boolean;
|
|
17
17
|
prompt: string | null;
|
|
18
18
|
config: {
|
|
19
19
|
type: "web_client";
|
|
@@ -74,15 +74,15 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
74
74
|
};
|
|
75
75
|
}>;
|
|
76
76
|
declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
tenantId: string | null;
|
|
78
|
+
projectId: string | null;
|
|
79
79
|
id: string;
|
|
80
|
-
createdAt: string;
|
|
81
80
|
name: string;
|
|
82
|
-
updatedAt: string;
|
|
83
|
-
projectId: string | null;
|
|
84
|
-
tenantId: string | null;
|
|
85
81
|
description: string | null;
|
|
82
|
+
type: AppType;
|
|
83
|
+
createdAt: string;
|
|
84
|
+
updatedAt: string;
|
|
85
|
+
enabled: boolean;
|
|
86
86
|
prompt: string | null;
|
|
87
87
|
config: {
|
|
88
88
|
type: "web_client";
|
|
@@ -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
|
/**
|
|
@@ -15,15 +15,15 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
15
15
|
total: number;
|
|
16
16
|
}>;
|
|
17
17
|
declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
|
|
18
|
-
id: string;
|
|
19
|
-
createdAt: string;
|
|
20
|
-
updatedAt: string;
|
|
21
|
-
agentId: string | null;
|
|
22
|
-
projectId: string;
|
|
23
18
|
tenantId: string;
|
|
19
|
+
projectId: string;
|
|
20
|
+
id: string;
|
|
21
|
+
metadata: ConversationMetadata | null;
|
|
24
22
|
properties: Record<string, unknown> | null;
|
|
25
23
|
title: string | null;
|
|
26
|
-
|
|
24
|
+
agentId: string | null;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
updatedAt: string;
|
|
27
27
|
ref: {
|
|
28
28
|
type: "commit" | "tag" | "branch";
|
|
29
29
|
name: string;
|
|
@@ -90,15 +90,15 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
90
90
|
scopes: ProjectScopeConfig;
|
|
91
91
|
conversationId: string;
|
|
92
92
|
}) => Promise<{
|
|
93
|
-
id: string;
|
|
94
|
-
createdAt: string;
|
|
95
|
-
updatedAt: string;
|
|
96
|
-
agentId: string | null;
|
|
97
|
-
projectId: string;
|
|
98
93
|
tenantId: string;
|
|
94
|
+
projectId: string;
|
|
95
|
+
id: string;
|
|
96
|
+
metadata: ConversationMetadata | null;
|
|
99
97
|
properties: Record<string, unknown> | null;
|
|
100
98
|
title: string | null;
|
|
101
|
-
|
|
99
|
+
agentId: string | null;
|
|
100
|
+
createdAt: string;
|
|
101
|
+
updatedAt: string;
|
|
102
102
|
ref: {
|
|
103
103
|
type: "commit" | "tag" | "branch";
|
|
104
104
|
name: string;
|
|
@@ -130,15 +130,15 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
130
130
|
userProperties?: Record<string, unknown> | null | undefined;
|
|
131
131
|
properties?: Record<string, unknown> | null | undefined;
|
|
132
132
|
} | {
|
|
133
|
-
id: string;
|
|
134
|
-
createdAt: string;
|
|
135
|
-
updatedAt: string;
|
|
136
|
-
agentId: string | null;
|
|
137
|
-
projectId: string;
|
|
138
133
|
tenantId: string;
|
|
134
|
+
projectId: string;
|
|
135
|
+
id: string;
|
|
136
|
+
metadata: ConversationMetadata | null;
|
|
139
137
|
properties: Record<string, unknown> | null;
|
|
140
138
|
title: string | null;
|
|
141
|
-
|
|
139
|
+
agentId: string | null;
|
|
140
|
+
createdAt: string;
|
|
141
|
+
updatedAt: string;
|
|
142
142
|
ref: {
|
|
143
143
|
type: "commit" | "tag" | "branch";
|
|
144
144
|
name: string;
|
|
@@ -164,15 +164,15 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
164
164
|
scopes: ProjectScopeConfig;
|
|
165
165
|
conversationId: string;
|
|
166
166
|
}) => Promise<{
|
|
167
|
-
id: string;
|
|
168
|
-
createdAt: string;
|
|
169
|
-
updatedAt: string;
|
|
170
|
-
agentId: string | null;
|
|
171
|
-
projectId: string;
|
|
172
167
|
tenantId: string;
|
|
168
|
+
projectId: string;
|
|
169
|
+
id: string;
|
|
170
|
+
metadata: ConversationMetadata | null;
|
|
173
171
|
properties: Record<string, unknown> | null;
|
|
174
172
|
title: string | null;
|
|
175
|
-
|
|
173
|
+
agentId: string | null;
|
|
174
|
+
createdAt: string;
|
|
175
|
+
updatedAt: string;
|
|
176
176
|
ref: {
|
|
177
177
|
type: "commit" | "tag" | "branch";
|
|
178
178
|
name: string;
|
|
@@ -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
|
-
|
|
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
|
};
|
|
@@ -7,15 +7,15 @@ import { EventInsert } from "../../types/entities.js";
|
|
|
7
7
|
//#region src/data-access/runtime/events.d.ts
|
|
8
8
|
declare const createEvent: (db: AgentsRunDatabaseClient) => (params: EventInsert) => Promise<{
|
|
9
9
|
row: {
|
|
10
|
-
|
|
10
|
+
tenantId: string;
|
|
11
|
+
projectId: string;
|
|
11
12
|
id: string;
|
|
13
|
+
metadata: Record<string, unknown> | null;
|
|
14
|
+
type: string;
|
|
15
|
+
properties: Record<string, unknown> | null;
|
|
16
|
+
agentId: string | null;
|
|
12
17
|
createdAt: string;
|
|
13
18
|
updatedAt: string;
|
|
14
|
-
agentId: string | null;
|
|
15
|
-
projectId: string;
|
|
16
|
-
tenantId: string;
|
|
17
|
-
properties: Record<string, unknown> | null;
|
|
18
|
-
metadata: Record<string, unknown> | null;
|
|
19
19
|
conversationId: string | null;
|
|
20
20
|
userProperties: Record<string, unknown> | null;
|
|
21
21
|
messageId: string | null;
|
|
@@ -89,5 +89,9 @@ declare const listEventsByConversationId: (db: AgentsRunDatabaseClient) => (para
|
|
|
89
89
|
tenantId: string;
|
|
90
90
|
id: string;
|
|
91
91
|
}[]>;
|
|
92
|
+
declare const deleteEventsByConversationIds: (db: AgentsRunDatabaseClient) => (params: {
|
|
93
|
+
scopes: ProjectScopeConfig;
|
|
94
|
+
conversationIds: string[];
|
|
95
|
+
}) => Promise<number>;
|
|
92
96
|
//#endregion
|
|
93
|
-
export { createEvent, getEventById, listEventsByConversationId };
|
|
97
|
+
export { createEvent, deleteEventsByConversationIds, getEventById, listEventsByConversationId };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { events } from "../../db/runtime/runtime-schema.js";
|
|
2
2
|
import { projectScopedWhere } from "../manage/scope-helpers.js";
|
|
3
|
-
import { and, desc, eq } from "drizzle-orm";
|
|
3
|
+
import { and, desc, eq, inArray } from "drizzle-orm";
|
|
4
4
|
|
|
5
5
|
//#region src/data-access/runtime/events.ts
|
|
6
6
|
const createEvent = (db) => async (params) => {
|
|
@@ -38,6 +38,10 @@ const listEventsByConversationId = (db) => async (params) => {
|
|
|
38
38
|
const offset = (page - 1) * limit;
|
|
39
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
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
|
+
};
|
|
41
45
|
|
|
42
46
|
//#endregion
|
|
43
|
-
export { createEvent, getEventById, listEventsByConversationId };
|
|
47
|
+
export { createEvent, deleteEventsByConversationIds, getEventById, listEventsByConversationId };
|
|
@@ -70,15 +70,15 @@ declare const getFeedbackByIds: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
70
70
|
agentId: string | null;
|
|
71
71
|
}[]>;
|
|
72
72
|
declare const createFeedback: (db: AgentsRunDatabaseClient) => (params: FeedbackInsert) => Promise<{
|
|
73
|
-
|
|
73
|
+
tenantId: string;
|
|
74
|
+
projectId: string;
|
|
74
75
|
id: string;
|
|
76
|
+
type: "positive" | "negative";
|
|
75
77
|
createdAt: string;
|
|
76
78
|
updatedAt: string;
|
|
77
|
-
projectId: string;
|
|
78
|
-
tenantId: string;
|
|
79
|
-
details: string | null;
|
|
80
79
|
conversationId: string;
|
|
81
80
|
messageId: string | null;
|
|
81
|
+
details: string | null;
|
|
82
82
|
}>;
|
|
83
83
|
declare const createFeedbackBulk: (db: AgentsRunDatabaseClient) => (items: FeedbackInsert[]) => Promise<(typeof feedback.$inferSelect)[]>;
|
|
84
84
|
declare const updateFeedback: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -100,15 +100,15 @@ declare const deleteFeedback: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
100
100
|
scopes: ProjectScopeConfig;
|
|
101
101
|
feedbackId: string;
|
|
102
102
|
}) => Promise<{
|
|
103
|
-
|
|
103
|
+
tenantId: string;
|
|
104
|
+
projectId: string;
|
|
104
105
|
id: string;
|
|
106
|
+
type: "positive" | "negative";
|
|
105
107
|
createdAt: string;
|
|
106
108
|
updatedAt: string;
|
|
107
|
-
projectId: string;
|
|
108
|
-
tenantId: string;
|
|
109
|
-
details: string | null;
|
|
110
109
|
conversationId: string;
|
|
111
110
|
messageId: string | null;
|
|
111
|
+
details: string | null;
|
|
112
112
|
}>;
|
|
113
113
|
//#endregion
|
|
114
114
|
export { createFeedback, createFeedbackBulk, deleteFeedback, getFeedbackById, getFeedbackByIds, listFeedback, listFeedbackByConversation, updateFeedback };
|
|
@@ -10,28 +10,28 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
10
10
|
scopes: ProjectScopeConfig;
|
|
11
11
|
messageId: string;
|
|
12
12
|
}) => Promise<{
|
|
13
|
-
id: string;
|
|
14
|
-
createdAt: string;
|
|
15
|
-
updatedAt: string;
|
|
16
|
-
projectId: string;
|
|
17
13
|
tenantId: string;
|
|
18
|
-
|
|
14
|
+
projectId: string;
|
|
15
|
+
id: string;
|
|
19
16
|
metadata: MessageMetadata | null;
|
|
20
17
|
content: MessageContent;
|
|
18
|
+
properties: Record<string, unknown> | null;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
updatedAt: string;
|
|
21
21
|
role: string;
|
|
22
|
+
conversationId: string;
|
|
23
|
+
userProperties: Record<string, unknown> | null;
|
|
22
24
|
fromSubAgentId: string | null;
|
|
23
25
|
toSubAgentId: string | null;
|
|
24
26
|
fromExternalAgentId: string | null;
|
|
25
27
|
toExternalAgentId: string | null;
|
|
26
|
-
taskId: string | null;
|
|
27
|
-
a2aTaskId: string | null;
|
|
28
|
-
conversationId: string;
|
|
29
|
-
userProperties: Record<string, unknown> | null;
|
|
30
28
|
fromTeamAgentId: string | null;
|
|
31
29
|
toTeamAgentId: string | null;
|
|
32
30
|
visibility: string;
|
|
33
31
|
messageType: string;
|
|
32
|
+
taskId: string | null;
|
|
34
33
|
parentMessageId: string | null;
|
|
34
|
+
a2aTaskId: string | null;
|
|
35
35
|
a2aSessionId: string | null;
|
|
36
36
|
} | undefined>;
|
|
37
37
|
declare const listMessages: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -154,28 +154,28 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
154
154
|
scopes: ProjectScopeConfig;
|
|
155
155
|
data: Omit<MessageInsert, "tenantId" | "projectId">;
|
|
156
156
|
}) => Promise<{
|
|
157
|
-
id: string;
|
|
158
|
-
createdAt: string;
|
|
159
|
-
updatedAt: string;
|
|
160
|
-
projectId: string;
|
|
161
157
|
tenantId: string;
|
|
162
|
-
|
|
158
|
+
projectId: string;
|
|
159
|
+
id: string;
|
|
163
160
|
metadata: MessageMetadata | null;
|
|
164
161
|
content: MessageContent;
|
|
162
|
+
properties: Record<string, unknown> | null;
|
|
163
|
+
createdAt: string;
|
|
164
|
+
updatedAt: string;
|
|
165
165
|
role: string;
|
|
166
|
+
conversationId: string;
|
|
167
|
+
userProperties: Record<string, unknown> | null;
|
|
166
168
|
fromSubAgentId: string | null;
|
|
167
169
|
toSubAgentId: string | null;
|
|
168
170
|
fromExternalAgentId: string | null;
|
|
169
171
|
toExternalAgentId: string | null;
|
|
170
|
-
taskId: string | null;
|
|
171
|
-
a2aTaskId: string | null;
|
|
172
|
-
conversationId: string;
|
|
173
|
-
userProperties: Record<string, unknown> | null;
|
|
174
172
|
fromTeamAgentId: string | null;
|
|
175
173
|
toTeamAgentId: string | null;
|
|
176
174
|
visibility: string;
|
|
177
175
|
messageType: string;
|
|
176
|
+
taskId: string | null;
|
|
178
177
|
parentMessageId: string | null;
|
|
178
|
+
a2aTaskId: string | null;
|
|
179
179
|
a2aSessionId: string | null;
|
|
180
180
|
}>;
|
|
181
181
|
declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -211,28 +211,28 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
211
211
|
scopes: ProjectScopeConfig;
|
|
212
212
|
messageId: string;
|
|
213
213
|
}) => Promise<{
|
|
214
|
-
id: string;
|
|
215
|
-
createdAt: string;
|
|
216
|
-
updatedAt: string;
|
|
217
|
-
projectId: string;
|
|
218
214
|
tenantId: string;
|
|
219
|
-
|
|
215
|
+
projectId: string;
|
|
216
|
+
id: string;
|
|
220
217
|
metadata: MessageMetadata | null;
|
|
221
218
|
content: MessageContent;
|
|
219
|
+
properties: Record<string, unknown> | null;
|
|
220
|
+
createdAt: string;
|
|
221
|
+
updatedAt: string;
|
|
222
222
|
role: string;
|
|
223
|
+
conversationId: string;
|
|
224
|
+
userProperties: Record<string, unknown> | null;
|
|
223
225
|
fromSubAgentId: string | null;
|
|
224
226
|
toSubAgentId: string | null;
|
|
225
227
|
fromExternalAgentId: string | null;
|
|
226
228
|
toExternalAgentId: string | null;
|
|
227
|
-
taskId: string | null;
|
|
228
|
-
a2aTaskId: string | null;
|
|
229
|
-
conversationId: string;
|
|
230
|
-
userProperties: Record<string, unknown> | null;
|
|
231
229
|
fromTeamAgentId: string | null;
|
|
232
230
|
toTeamAgentId: string | null;
|
|
233
231
|
visibility: string;
|
|
234
232
|
messageType: string;
|
|
233
|
+
taskId: string | null;
|
|
235
234
|
parentMessageId: string | null;
|
|
235
|
+
a2aTaskId: string | null;
|
|
236
236
|
a2aSessionId: string | null;
|
|
237
237
|
}>;
|
|
238
238
|
declare const countMessagesByConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -15,8 +15,8 @@ declare const createScheduledTriggerUser: (db: AgentsRunDatabaseClient) => (para
|
|
|
15
15
|
scheduledTriggerId: string;
|
|
16
16
|
userId: string;
|
|
17
17
|
}) => Promise<{
|
|
18
|
-
createdAt: string;
|
|
19
18
|
tenantId: string;
|
|
19
|
+
createdAt: string;
|
|
20
20
|
userId: string;
|
|
21
21
|
scheduledTriggerId: string;
|
|
22
22
|
}>;
|
|
@@ -7,20 +7,20 @@ import { TaskInsert, TaskSelect } from "../../types/entities.js";
|
|
|
7
7
|
|
|
8
8
|
//#region src/data-access/runtime/tasks.d.ts
|
|
9
9
|
declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert) => Promise<{
|
|
10
|
+
tenantId: string;
|
|
11
|
+
projectId: string;
|
|
10
12
|
id: string;
|
|
13
|
+
metadata: TaskMetadataConfig | null;
|
|
14
|
+
agentId: string;
|
|
15
|
+
subAgentId: string;
|
|
11
16
|
createdAt: string;
|
|
12
17
|
updatedAt: string;
|
|
13
|
-
agentId: string;
|
|
14
|
-
projectId: string;
|
|
15
|
-
tenantId: string;
|
|
16
|
-
metadata: TaskMetadataConfig | null;
|
|
17
18
|
ref: {
|
|
18
19
|
type: "commit" | "tag" | "branch";
|
|
19
20
|
name: string;
|
|
20
21
|
hash: string;
|
|
21
22
|
} | null;
|
|
22
23
|
status: string;
|
|
23
|
-
subAgentId: string;
|
|
24
24
|
contextId: string;
|
|
25
25
|
}>;
|
|
26
26
|
declare const getTask: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -858,13 +858,13 @@ declare const triggers: drizzle_orm_pg_core1565.PgTableWithColumns<{
|
|
|
858
858
|
algorithm: "md5" | "sha256" | "sha512" | "sha384" | "sha1";
|
|
859
859
|
encoding: "base64" | "hex";
|
|
860
860
|
signature: {
|
|
861
|
-
source: "query" | "
|
|
861
|
+
source: "query" | "body" | "header";
|
|
862
862
|
key: string;
|
|
863
863
|
prefix?: string | undefined;
|
|
864
864
|
regex?: string | undefined;
|
|
865
865
|
};
|
|
866
866
|
signedComponents: {
|
|
867
|
-
source: "literal" | "
|
|
867
|
+
source: "literal" | "body" | "header";
|
|
868
868
|
required: boolean;
|
|
869
869
|
key?: string | undefined;
|
|
870
870
|
value?: string | undefined;
|
|
@@ -895,13 +895,13 @@ declare const triggers: drizzle_orm_pg_core1565.PgTableWithColumns<{
|
|
|
895
895
|
algorithm: "md5" | "sha256" | "sha512" | "sha384" | "sha1";
|
|
896
896
|
encoding: "base64" | "hex";
|
|
897
897
|
signature: {
|
|
898
|
-
source: "query" | "
|
|
898
|
+
source: "query" | "body" | "header";
|
|
899
899
|
key: string;
|
|
900
900
|
prefix?: string | undefined;
|
|
901
901
|
regex?: string | undefined;
|
|
902
902
|
};
|
|
903
903
|
signedComponents: {
|
|
904
|
-
source: "literal" | "
|
|
904
|
+
source: "literal" | "body" | "header";
|
|
905
905
|
required: boolean;
|
|
906
906
|
key?: string | undefined;
|
|
907
907
|
value?: string | undefined;
|