@inkeep/agents-core 0.72.0 → 0.72.2
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 +122 -122
- package/dist/auth/password-policy.d.ts +2 -2
- 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 +32 -32
- package/dist/data-access/manage/artifactComponents.d.ts +6 -6
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- package/dist/data-access/manage/dataComponents.d.ts +2 -2
- package/dist/data-access/manage/functionTools.d.ts +10 -10
- package/dist/data-access/manage/skills.d.ts +9 -9
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgentRelations.d.ts +14 -14
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgents.d.ts +12 -12
- package/dist/data-access/manage/tools.d.ts +24 -24
- package/dist/data-access/manage/triggers.d.ts +4 -4
- package/dist/data-access/runtime/apiKeys.d.ts +12 -12
- package/dist/data-access/runtime/apps.d.ts +13 -13
- 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 +7 -3
- package/dist/data-access/runtime/events.js +6 -2
- package/dist/data-access/runtime/messages.d.ts +6 -6
- package/dist/data-access/runtime/scheduledTriggerUsers.d.ts +1 -1
- package/dist/data-access/runtime/tasks.d.ts +4 -4
- package/dist/db/manage/manage-schema.d.ts +381 -381
- package/dist/db/runtime/runtime-schema.d.ts +413 -413
- 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/schemas/skills.d.ts +42 -42
- package/dist/validation/schemas.d.ts +702 -702
- 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
|
@@ -9,13 +9,13 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
9
9
|
id: string;
|
|
10
10
|
}) => Promise<{
|
|
11
11
|
id: string;
|
|
12
|
-
createdAt: string;
|
|
13
12
|
name: string | null;
|
|
13
|
+
createdAt: string;
|
|
14
14
|
updatedAt: string;
|
|
15
|
-
|
|
15
|
+
expiresAt: string | null;
|
|
16
16
|
projectId: string;
|
|
17
17
|
tenantId: string;
|
|
18
|
-
|
|
18
|
+
agentId: string;
|
|
19
19
|
publicId: string;
|
|
20
20
|
keyHash: string;
|
|
21
21
|
keyPrefix: string;
|
|
@@ -23,13 +23,13 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
23
23
|
} | undefined>;
|
|
24
24
|
declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
|
|
25
25
|
id: string;
|
|
26
|
-
createdAt: string;
|
|
27
26
|
name: string | null;
|
|
27
|
+
createdAt: string;
|
|
28
28
|
updatedAt: string;
|
|
29
|
-
|
|
29
|
+
expiresAt: string | null;
|
|
30
30
|
projectId: string;
|
|
31
31
|
tenantId: string;
|
|
32
|
-
|
|
32
|
+
agentId: string;
|
|
33
33
|
publicId: string;
|
|
34
34
|
keyHash: string;
|
|
35
35
|
keyPrefix: string;
|
|
@@ -40,13 +40,13 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
40
40
|
agentId?: string;
|
|
41
41
|
}) => Promise<{
|
|
42
42
|
id: string;
|
|
43
|
-
createdAt: string;
|
|
44
43
|
name: string | null;
|
|
44
|
+
createdAt: string;
|
|
45
45
|
updatedAt: string;
|
|
46
|
-
|
|
46
|
+
expiresAt: string | null;
|
|
47
47
|
projectId: string;
|
|
48
48
|
tenantId: string;
|
|
49
|
-
|
|
49
|
+
agentId: string;
|
|
50
50
|
publicId: string;
|
|
51
51
|
keyHash: string;
|
|
52
52
|
keyPrefix: string;
|
|
@@ -67,13 +67,13 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
67
67
|
}>;
|
|
68
68
|
declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
|
|
69
69
|
id: string;
|
|
70
|
-
createdAt: string;
|
|
71
70
|
name: string | null;
|
|
71
|
+
createdAt: string;
|
|
72
72
|
updatedAt: string;
|
|
73
|
-
|
|
73
|
+
expiresAt: string | null;
|
|
74
74
|
projectId: string;
|
|
75
75
|
tenantId: string;
|
|
76
|
-
|
|
76
|
+
agentId: string;
|
|
77
77
|
publicId: string;
|
|
78
78
|
keyHash: string;
|
|
79
79
|
keyPrefix: string;
|
|
@@ -6,15 +6,12 @@ import { AppInsert, AppSelect, AppUpdate } from "../../types/entities.js";
|
|
|
6
6
|
//#region src/data-access/runtime/apps.d.ts
|
|
7
7
|
declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promise<{
|
|
8
8
|
type: AppType;
|
|
9
|
-
enabled: boolean;
|
|
10
9
|
id: string;
|
|
11
|
-
createdAt: string;
|
|
12
10
|
name: string;
|
|
11
|
+
createdAt: string;
|
|
13
12
|
updatedAt: string;
|
|
14
|
-
projectId: string | null;
|
|
15
|
-
tenantId: string | null;
|
|
16
13
|
description: string | null;
|
|
17
|
-
|
|
14
|
+
enabled: boolean;
|
|
18
15
|
config: {
|
|
19
16
|
type: "web_client";
|
|
20
17
|
webClient: {
|
|
@@ -22,7 +19,7 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
|
|
|
22
19
|
publicKeys: {
|
|
23
20
|
kid: string;
|
|
24
21
|
publicKey: string;
|
|
25
|
-
algorithm: "
|
|
22
|
+
algorithm: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
|
|
26
23
|
addedAt: string;
|
|
27
24
|
}[];
|
|
28
25
|
allowAnonymous: boolean;
|
|
@@ -45,6 +42,9 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
|
|
|
45
42
|
}[] | undefined;
|
|
46
43
|
};
|
|
47
44
|
};
|
|
45
|
+
projectId: string | null;
|
|
46
|
+
tenantId: string | null;
|
|
47
|
+
prompt: string | null;
|
|
48
48
|
lastUsedAt: string | null;
|
|
49
49
|
defaultProjectId: string | null;
|
|
50
50
|
defaultAgentId: string | null;
|
|
@@ -75,15 +75,12 @@ declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
75
75
|
}>;
|
|
76
76
|
declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
|
|
77
77
|
type: AppType;
|
|
78
|
-
enabled: boolean;
|
|
79
78
|
id: string;
|
|
80
|
-
createdAt: string;
|
|
81
79
|
name: string;
|
|
80
|
+
createdAt: string;
|
|
82
81
|
updatedAt: string;
|
|
83
|
-
projectId: string | null;
|
|
84
|
-
tenantId: string | null;
|
|
85
82
|
description: string | null;
|
|
86
|
-
|
|
83
|
+
enabled: boolean;
|
|
87
84
|
config: {
|
|
88
85
|
type: "web_client";
|
|
89
86
|
webClient: {
|
|
@@ -91,7 +88,7 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
|
|
|
91
88
|
publicKeys: {
|
|
92
89
|
kid: string;
|
|
93
90
|
publicKey: string;
|
|
94
|
-
algorithm: "
|
|
91
|
+
algorithm: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
|
|
95
92
|
addedAt: string;
|
|
96
93
|
}[];
|
|
97
94
|
allowAnonymous: boolean;
|
|
@@ -114,6 +111,9 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
|
|
|
114
111
|
}[] | undefined;
|
|
115
112
|
};
|
|
116
113
|
};
|
|
114
|
+
projectId: string | null;
|
|
115
|
+
tenantId: string | null;
|
|
116
|
+
prompt: string | null;
|
|
117
117
|
lastUsedAt: string | null;
|
|
118
118
|
defaultProjectId: string | null;
|
|
119
119
|
defaultAgentId: string | null;
|
|
@@ -174,7 +174,7 @@ declare const updateApp: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
174
174
|
publicKeys: {
|
|
175
175
|
kid: string;
|
|
176
176
|
publicKey: string;
|
|
177
|
-
algorithm: "
|
|
177
|
+
algorithm: "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA";
|
|
178
178
|
addedAt: string;
|
|
179
179
|
}[];
|
|
180
180
|
allowAnonymous: boolean;
|
|
@@ -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
|
/**
|
|
@@ -18,18 +18,18 @@ declare const createConversation: (db: AgentsRunDatabaseClient) => (params: Conv
|
|
|
18
18
|
id: string;
|
|
19
19
|
createdAt: string;
|
|
20
20
|
updatedAt: string;
|
|
21
|
-
agentId: string | null;
|
|
22
|
-
projectId: string;
|
|
23
|
-
tenantId: string;
|
|
24
|
-
properties: Record<string, unknown> | null;
|
|
25
|
-
title: string | null;
|
|
26
|
-
metadata: ConversationMetadata | null;
|
|
27
21
|
ref: {
|
|
28
22
|
type: "commit" | "tag" | "branch";
|
|
29
23
|
name: string;
|
|
30
24
|
hash: string;
|
|
31
25
|
} | null;
|
|
32
26
|
userId: string | null;
|
|
27
|
+
metadata: ConversationMetadata | null;
|
|
28
|
+
projectId: string;
|
|
29
|
+
tenantId: string;
|
|
30
|
+
properties: Record<string, unknown> | null;
|
|
31
|
+
title: string | null;
|
|
32
|
+
agentId: string | null;
|
|
33
33
|
userProperties: Record<string, unknown> | null;
|
|
34
34
|
activeSubAgentId: string;
|
|
35
35
|
lastContextResolution: string | null;
|
|
@@ -93,18 +93,18 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
93
93
|
id: string;
|
|
94
94
|
createdAt: string;
|
|
95
95
|
updatedAt: string;
|
|
96
|
-
agentId: string | null;
|
|
97
|
-
projectId: string;
|
|
98
|
-
tenantId: string;
|
|
99
|
-
properties: Record<string, unknown> | null;
|
|
100
|
-
title: string | null;
|
|
101
|
-
metadata: ConversationMetadata | null;
|
|
102
96
|
ref: {
|
|
103
97
|
type: "commit" | "tag" | "branch";
|
|
104
98
|
name: string;
|
|
105
99
|
hash: string;
|
|
106
100
|
} | null;
|
|
107
101
|
userId: string | null;
|
|
102
|
+
metadata: ConversationMetadata | null;
|
|
103
|
+
projectId: string;
|
|
104
|
+
tenantId: string;
|
|
105
|
+
properties: Record<string, unknown> | null;
|
|
106
|
+
title: string | null;
|
|
107
|
+
agentId: string | null;
|
|
108
108
|
userProperties: Record<string, unknown> | null;
|
|
109
109
|
activeSubAgentId: string;
|
|
110
110
|
lastContextResolution: string | null;
|
|
@@ -133,18 +133,18 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
133
133
|
id: string;
|
|
134
134
|
createdAt: string;
|
|
135
135
|
updatedAt: string;
|
|
136
|
-
agentId: string | null;
|
|
137
|
-
projectId: string;
|
|
138
|
-
tenantId: string;
|
|
139
|
-
properties: Record<string, unknown> | null;
|
|
140
|
-
title: string | null;
|
|
141
|
-
metadata: ConversationMetadata | null;
|
|
142
136
|
ref: {
|
|
143
137
|
type: "commit" | "tag" | "branch";
|
|
144
138
|
name: string;
|
|
145
139
|
hash: string;
|
|
146
140
|
} | null;
|
|
147
141
|
userId: string | null;
|
|
142
|
+
metadata: ConversationMetadata | null;
|
|
143
|
+
projectId: string;
|
|
144
|
+
tenantId: string;
|
|
145
|
+
properties: Record<string, unknown> | null;
|
|
146
|
+
title: string | null;
|
|
147
|
+
agentId: string | null;
|
|
148
148
|
userProperties: Record<string, unknown> | null;
|
|
149
149
|
activeSubAgentId: string;
|
|
150
150
|
lastContextResolution: string | null;
|
|
@@ -167,18 +167,18 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
167
167
|
id: string;
|
|
168
168
|
createdAt: string;
|
|
169
169
|
updatedAt: string;
|
|
170
|
-
agentId: string | null;
|
|
171
|
-
projectId: string;
|
|
172
|
-
tenantId: string;
|
|
173
|
-
properties: Record<string, unknown> | null;
|
|
174
|
-
title: string | null;
|
|
175
|
-
metadata: ConversationMetadata | null;
|
|
176
170
|
ref: {
|
|
177
171
|
type: "commit" | "tag" | "branch";
|
|
178
172
|
name: string;
|
|
179
173
|
hash: string;
|
|
180
174
|
} | null;
|
|
181
175
|
userId: string | null;
|
|
176
|
+
metadata: ConversationMetadata | null;
|
|
177
|
+
projectId: string;
|
|
178
|
+
tenantId: string;
|
|
179
|
+
properties: Record<string, unknown> | null;
|
|
180
|
+
title: string | null;
|
|
181
|
+
agentId: string | null;
|
|
182
182
|
userProperties: Record<string, unknown> | null;
|
|
183
183
|
activeSubAgentId: string;
|
|
184
184
|
lastContextResolution: string | null;
|
|
@@ -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
|
};
|
|
@@ -11,11 +11,11 @@ declare const createEvent: (db: AgentsRunDatabaseClient) => (params: EventInsert
|
|
|
11
11
|
id: string;
|
|
12
12
|
createdAt: string;
|
|
13
13
|
updatedAt: string;
|
|
14
|
-
|
|
14
|
+
metadata: Record<string, unknown> | null;
|
|
15
15
|
projectId: string;
|
|
16
16
|
tenantId: string;
|
|
17
17
|
properties: Record<string, unknown> | null;
|
|
18
|
-
|
|
18
|
+
agentId: string | 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 };
|
|
@@ -13,12 +13,12 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
13
13
|
id: string;
|
|
14
14
|
createdAt: string;
|
|
15
15
|
updatedAt: string;
|
|
16
|
+
metadata: MessageMetadata | null;
|
|
17
|
+
role: string;
|
|
16
18
|
projectId: string;
|
|
17
19
|
tenantId: string;
|
|
18
20
|
properties: Record<string, unknown> | null;
|
|
19
|
-
metadata: MessageMetadata | null;
|
|
20
21
|
content: MessageContent;
|
|
21
|
-
role: string;
|
|
22
22
|
fromSubAgentId: string | null;
|
|
23
23
|
toSubAgentId: string | null;
|
|
24
24
|
fromExternalAgentId: string | null;
|
|
@@ -157,12 +157,12 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
157
157
|
id: string;
|
|
158
158
|
createdAt: string;
|
|
159
159
|
updatedAt: string;
|
|
160
|
+
metadata: MessageMetadata | null;
|
|
161
|
+
role: string;
|
|
160
162
|
projectId: string;
|
|
161
163
|
tenantId: string;
|
|
162
164
|
properties: Record<string, unknown> | null;
|
|
163
|
-
metadata: MessageMetadata | null;
|
|
164
165
|
content: MessageContent;
|
|
165
|
-
role: string;
|
|
166
166
|
fromSubAgentId: string | null;
|
|
167
167
|
toSubAgentId: string | null;
|
|
168
168
|
fromExternalAgentId: string | null;
|
|
@@ -214,12 +214,12 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
214
214
|
id: string;
|
|
215
215
|
createdAt: string;
|
|
216
216
|
updatedAt: string;
|
|
217
|
+
metadata: MessageMetadata | null;
|
|
218
|
+
role: string;
|
|
217
219
|
projectId: string;
|
|
218
220
|
tenantId: string;
|
|
219
221
|
properties: Record<string, unknown> | null;
|
|
220
|
-
metadata: MessageMetadata | null;
|
|
221
222
|
content: MessageContent;
|
|
222
|
-
role: string;
|
|
223
223
|
fromSubAgentId: string | null;
|
|
224
224
|
toSubAgentId: string | null;
|
|
225
225
|
fromExternalAgentId: string | null;
|
|
@@ -16,8 +16,8 @@ declare const createScheduledTriggerUser: (db: AgentsRunDatabaseClient) => (para
|
|
|
16
16
|
userId: string;
|
|
17
17
|
}) => Promise<{
|
|
18
18
|
createdAt: string;
|
|
19
|
-
tenantId: string;
|
|
20
19
|
userId: string;
|
|
20
|
+
tenantId: string;
|
|
21
21
|
scheduledTriggerId: string;
|
|
22
22
|
}>;
|
|
23
23
|
declare const deleteScheduledTriggerUser: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -10,16 +10,16 @@ declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert)
|
|
|
10
10
|
id: string;
|
|
11
11
|
createdAt: string;
|
|
12
12
|
updatedAt: string;
|
|
13
|
-
agentId: string;
|
|
14
|
-
projectId: string;
|
|
15
|
-
tenantId: string;
|
|
16
|
-
metadata: TaskMetadataConfig | null;
|
|
17
13
|
ref: {
|
|
18
14
|
type: "commit" | "tag" | "branch";
|
|
19
15
|
name: string;
|
|
20
16
|
hash: string;
|
|
21
17
|
} | null;
|
|
18
|
+
metadata: TaskMetadataConfig | null;
|
|
22
19
|
status: string;
|
|
20
|
+
projectId: string;
|
|
21
|
+
tenantId: string;
|
|
22
|
+
agentId: string;
|
|
23
23
|
subAgentId: string;
|
|
24
24
|
contextId: string;
|
|
25
25
|
}>;
|