@inkeep/agents-core 0.0.0-dev-20260310212230 → 0.0.0-dev-20260310215636
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-schema.d.ts +85 -85
- package/dist/auth/auth-validation-schemas.d.ts +135 -135
- package/dist/client-exports.d.ts +8 -6
- package/dist/client-exports.js +2 -2
- package/dist/data-access/index.d.ts +2 -1
- package/dist/data-access/index.js +2 -1
- package/dist/data-access/manage/agents.d.ts +16 -16
- package/dist/data-access/manage/artifactComponents.d.ts +14 -14
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- package/dist/data-access/manage/dataComponents.d.ts +8 -8
- package/dist/data-access/manage/functionTools.d.ts +16 -16
- package/dist/data-access/manage/skills.d.ts +13 -13
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgentRelations.d.ts +28 -28
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgents.d.ts +12 -12
- package/dist/data-access/manage/tools.d.ts +24 -24
- package/dist/data-access/runtime/apiKeys.d.ts +12 -12
- package/dist/data-access/runtime/apps.d.ts +113 -0
- package/dist/data-access/runtime/apps.js +86 -0
- package/dist/data-access/runtime/cascade-delete.d.ts +2 -0
- package/dist/data-access/runtime/cascade-delete.js +16 -4
- package/dist/data-access/runtime/conversations.d.ts +17 -16
- package/dist/data-access/runtime/conversations.js +1 -0
- package/dist/data-access/runtime/messages.d.ts +18 -18
- package/dist/data-access/runtime/tasks.d.ts +4 -4
- package/dist/db/manage/manage-schema.d.ts +357 -357
- package/dist/db/runtime/runtime-schema.d.ts +544 -283
- package/dist/db/runtime/runtime-schema.js +16 -1
- package/dist/index.d.ts +10 -7
- package/dist/index.js +7 -4
- package/dist/middleware/no-auth.d.ts +2 -2
- package/dist/setup/setup.js +10 -0
- package/dist/types/entities.d.ts +10 -2
- package/dist/types/index.d.ts +4 -4
- package/dist/types/utility.d.ts +9 -3
- package/dist/utils/apiKeys.d.ts +6 -1
- package/dist/utils/apiKeys.js +9 -1
- package/dist/utils/domain-validation.d.ts +4 -0
- package/dist/utils/domain-validation.js +25 -0
- package/dist/utils/error.d.ts +51 -51
- package/dist/utils/index.d.ts +4 -2
- package/dist/utils/index.js +4 -2
- package/dist/utils/pow.d.ts +13 -0
- package/dist/utils/pow.js +52 -0
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +2 -2
- package/dist/validation/schemas.d.ts +1819 -538
- package/dist/validation/schemas.js +57 -3
- package/drizzle/runtime/0022_superb_micromacro.sql +17 -0
- package/drizzle/runtime/meta/0022_snapshot.json +4240 -0
- package/drizzle/runtime/meta/_journal.json +7 -0
- package/package.json +3 -2
|
@@ -20,12 +20,12 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
20
20
|
toolId: string;
|
|
21
21
|
}) => Promise<{
|
|
22
22
|
name: string;
|
|
23
|
+
description: string | null;
|
|
24
|
+
tenantId: string;
|
|
25
|
+
projectId: string;
|
|
23
26
|
id: string;
|
|
24
27
|
createdAt: string;
|
|
25
28
|
updatedAt: string;
|
|
26
|
-
projectId: string;
|
|
27
|
-
tenantId: string;
|
|
28
|
-
description: string | null;
|
|
29
29
|
headers: Record<string, string> | null;
|
|
30
30
|
config: {
|
|
31
31
|
type: "mcp";
|
|
@@ -78,12 +78,12 @@ declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
78
78
|
}>;
|
|
79
79
|
declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInsert) => Promise<{
|
|
80
80
|
name: string;
|
|
81
|
+
description: string | null;
|
|
82
|
+
tenantId: string;
|
|
83
|
+
projectId: string;
|
|
81
84
|
id: string;
|
|
82
85
|
createdAt: string;
|
|
83
86
|
updatedAt: string;
|
|
84
|
-
projectId: string;
|
|
85
|
-
tenantId: string;
|
|
86
|
-
description: string | null;
|
|
87
87
|
headers: Record<string, string> | null;
|
|
88
88
|
config: {
|
|
89
89
|
type: "mcp";
|
|
@@ -134,15 +134,15 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
134
134
|
needsApproval?: boolean;
|
|
135
135
|
}> | null;
|
|
136
136
|
}) => Promise<{
|
|
137
|
+
tenantId: string;
|
|
138
|
+
projectId: string;
|
|
139
|
+
agentId: string;
|
|
140
|
+
subAgentId: string;
|
|
141
|
+
toolId: string;
|
|
137
142
|
id: string;
|
|
138
143
|
createdAt: string;
|
|
139
144
|
updatedAt: string;
|
|
140
|
-
agentId: string;
|
|
141
|
-
projectId: string;
|
|
142
|
-
tenantId: string;
|
|
143
|
-
subAgentId: string;
|
|
144
145
|
headers: Record<string, string> | null;
|
|
145
|
-
toolId: string;
|
|
146
146
|
toolPolicies: Record<string, {
|
|
147
147
|
needsApproval?: boolean;
|
|
148
148
|
}> | null;
|
|
@@ -153,15 +153,15 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
|
|
|
153
153
|
subAgentId: string;
|
|
154
154
|
toolId: string;
|
|
155
155
|
}) => Promise<{
|
|
156
|
+
tenantId: string;
|
|
157
|
+
projectId: string;
|
|
158
|
+
agentId: string;
|
|
159
|
+
subAgentId: string;
|
|
160
|
+
toolId: string;
|
|
156
161
|
id: string;
|
|
157
162
|
createdAt: string;
|
|
158
163
|
updatedAt: string;
|
|
159
|
-
agentId: string;
|
|
160
|
-
projectId: string;
|
|
161
|
-
tenantId: string;
|
|
162
|
-
subAgentId: string;
|
|
163
164
|
headers: Record<string, string> | null;
|
|
164
|
-
toolId: string;
|
|
165
165
|
toolPolicies: Record<string, {
|
|
166
166
|
needsApproval?: boolean;
|
|
167
167
|
}> | null;
|
|
@@ -181,15 +181,15 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
181
181
|
}> | null;
|
|
182
182
|
relationId?: string;
|
|
183
183
|
}) => Promise<{
|
|
184
|
+
tenantId: string;
|
|
185
|
+
projectId: string;
|
|
186
|
+
agentId: string;
|
|
187
|
+
subAgentId: string;
|
|
188
|
+
toolId: string;
|
|
184
189
|
id: string;
|
|
185
190
|
createdAt: string;
|
|
186
191
|
updatedAt: string;
|
|
187
|
-
agentId: string;
|
|
188
|
-
projectId: string;
|
|
189
|
-
tenantId: string;
|
|
190
|
-
subAgentId: string;
|
|
191
192
|
headers: Record<string, string> | null;
|
|
192
|
-
toolId: string;
|
|
193
193
|
toolPolicies: Record<string, {
|
|
194
194
|
needsApproval?: boolean;
|
|
195
195
|
}> | null;
|
|
@@ -202,12 +202,12 @@ declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
202
202
|
data: ToolInsert;
|
|
203
203
|
}) => Promise<{
|
|
204
204
|
name: string;
|
|
205
|
+
description: string | null;
|
|
206
|
+
tenantId: string;
|
|
207
|
+
projectId: string;
|
|
205
208
|
id: string;
|
|
206
209
|
createdAt: string;
|
|
207
210
|
updatedAt: string;
|
|
208
|
-
projectId: string;
|
|
209
|
-
tenantId: string;
|
|
210
|
-
description: string | null;
|
|
211
211
|
headers: Record<string, string> | null;
|
|
212
212
|
config: {
|
|
213
213
|
type: "mcp";
|
|
@@ -9,12 +9,12 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
9
9
|
id: string;
|
|
10
10
|
}) => Promise<{
|
|
11
11
|
name: string | null;
|
|
12
|
+
tenantId: string;
|
|
13
|
+
projectId: string;
|
|
14
|
+
agentId: string;
|
|
12
15
|
id: string;
|
|
13
16
|
createdAt: string;
|
|
14
17
|
updatedAt: string;
|
|
15
|
-
agentId: string;
|
|
16
|
-
projectId: string;
|
|
17
|
-
tenantId: string;
|
|
18
18
|
publicId: string;
|
|
19
19
|
keyHash: string;
|
|
20
20
|
keyPrefix: string;
|
|
@@ -23,12 +23,12 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
23
23
|
} | undefined>;
|
|
24
24
|
declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
|
|
25
25
|
name: string | null;
|
|
26
|
+
tenantId: string;
|
|
27
|
+
projectId: string;
|
|
28
|
+
agentId: string;
|
|
26
29
|
id: string;
|
|
27
30
|
createdAt: string;
|
|
28
31
|
updatedAt: string;
|
|
29
|
-
agentId: string;
|
|
30
|
-
projectId: string;
|
|
31
|
-
tenantId: string;
|
|
32
32
|
publicId: string;
|
|
33
33
|
keyHash: string;
|
|
34
34
|
keyPrefix: string;
|
|
@@ -40,12 +40,12 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
40
40
|
agentId?: string;
|
|
41
41
|
}) => Promise<{
|
|
42
42
|
name: string | null;
|
|
43
|
+
tenantId: string;
|
|
44
|
+
projectId: string;
|
|
45
|
+
agentId: string;
|
|
43
46
|
id: string;
|
|
44
47
|
createdAt: string;
|
|
45
48
|
updatedAt: string;
|
|
46
|
-
agentId: string;
|
|
47
|
-
projectId: string;
|
|
48
|
-
tenantId: string;
|
|
49
49
|
publicId: string;
|
|
50
50
|
keyHash: string;
|
|
51
51
|
keyPrefix: string;
|
|
@@ -67,12 +67,12 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
67
67
|
}>;
|
|
68
68
|
declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
|
|
69
69
|
name: string | null;
|
|
70
|
+
tenantId: string;
|
|
71
|
+
projectId: string;
|
|
72
|
+
agentId: string;
|
|
70
73
|
id: string;
|
|
71
74
|
createdAt: string;
|
|
72
75
|
updatedAt: string;
|
|
73
|
-
agentId: string;
|
|
74
|
-
projectId: string;
|
|
75
|
-
tenantId: string;
|
|
76
76
|
publicId: string;
|
|
77
77
|
keyHash: string;
|
|
78
78
|
keyPrefix: string;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { TenantScopeConfig } from "../../db/manage/scope-definitions.js";
|
|
2
|
+
import { AppType, PaginationConfig } from "../../types/utility.js";
|
|
3
|
+
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
4
|
+
import { AppInsert, AppSelect, AppUpdate } from "../../types/entities.js";
|
|
5
|
+
|
|
6
|
+
//#region src/data-access/runtime/apps.d.ts
|
|
7
|
+
declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promise<{
|
|
8
|
+
name: string;
|
|
9
|
+
type: AppType;
|
|
10
|
+
description: string | null;
|
|
11
|
+
tenantId: string | null;
|
|
12
|
+
projectId: string | null;
|
|
13
|
+
id: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
config: {
|
|
18
|
+
type: "web_client";
|
|
19
|
+
webClient: {
|
|
20
|
+
allowedDomains: string[];
|
|
21
|
+
};
|
|
22
|
+
} | {
|
|
23
|
+
type: "api";
|
|
24
|
+
api: Record<string, never>;
|
|
25
|
+
};
|
|
26
|
+
lastUsedAt: string | null;
|
|
27
|
+
defaultProjectId: string | null;
|
|
28
|
+
defaultAgentId: string | null;
|
|
29
|
+
} | undefined>;
|
|
30
|
+
declare const updateAppLastUsed: (db: AgentsRunDatabaseClient) => (id: string) => Promise<void>;
|
|
31
|
+
declare const getAppByIdForTenant: (db: AgentsRunDatabaseClient) => (params: {
|
|
32
|
+
scopes: TenantScopeConfig;
|
|
33
|
+
id: string;
|
|
34
|
+
}) => Promise<AppSelect | undefined>;
|
|
35
|
+
declare const listAppsPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
36
|
+
scopes: TenantScopeConfig & {
|
|
37
|
+
projectId?: string;
|
|
38
|
+
};
|
|
39
|
+
pagination?: PaginationConfig;
|
|
40
|
+
type?: AppType;
|
|
41
|
+
}) => Promise<{
|
|
42
|
+
data: AppSelect[];
|
|
43
|
+
pagination: {
|
|
44
|
+
page: number;
|
|
45
|
+
limit: number;
|
|
46
|
+
total: number;
|
|
47
|
+
pages: number;
|
|
48
|
+
};
|
|
49
|
+
}>;
|
|
50
|
+
declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) => Promise<{
|
|
51
|
+
name: string;
|
|
52
|
+
type: AppType;
|
|
53
|
+
description: string | null;
|
|
54
|
+
tenantId: string | null;
|
|
55
|
+
projectId: string | null;
|
|
56
|
+
id: string;
|
|
57
|
+
createdAt: string;
|
|
58
|
+
updatedAt: string;
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
config: {
|
|
61
|
+
type: "web_client";
|
|
62
|
+
webClient: {
|
|
63
|
+
allowedDomains: string[];
|
|
64
|
+
};
|
|
65
|
+
} | {
|
|
66
|
+
type: "api";
|
|
67
|
+
api: Record<string, never>;
|
|
68
|
+
};
|
|
69
|
+
lastUsedAt: string | null;
|
|
70
|
+
defaultProjectId: string | null;
|
|
71
|
+
defaultAgentId: string | null;
|
|
72
|
+
}>;
|
|
73
|
+
declare const updateAppForTenant: (db: AgentsRunDatabaseClient) => (params: {
|
|
74
|
+
scopes: TenantScopeConfig;
|
|
75
|
+
id: string;
|
|
76
|
+
data: AppUpdate;
|
|
77
|
+
}) => Promise<AppSelect | undefined>;
|
|
78
|
+
declare const deleteAppForTenant: (db: AgentsRunDatabaseClient) => (params: {
|
|
79
|
+
scopes: TenantScopeConfig;
|
|
80
|
+
id: string;
|
|
81
|
+
}) => Promise<boolean>;
|
|
82
|
+
declare const deleteAppsByProject: (db: AgentsRunDatabaseClient) => (tenantId: string, projectId: string) => Promise<number>;
|
|
83
|
+
declare const clearAppDefaultsByProject: (db: AgentsRunDatabaseClient) => (tenantId: string, projectId: string) => Promise<number>;
|
|
84
|
+
declare const clearAppDefaultsByAgent: (db: AgentsRunDatabaseClient) => (tenantId: string, agentId: string) => Promise<number>;
|
|
85
|
+
declare const updateApp: (db: AgentsRunDatabaseClient) => (params: {
|
|
86
|
+
id: string;
|
|
87
|
+
data: AppUpdate;
|
|
88
|
+
}) => Promise<{
|
|
89
|
+
createdAt: string;
|
|
90
|
+
updatedAt: string;
|
|
91
|
+
id: string;
|
|
92
|
+
tenantId: string | null;
|
|
93
|
+
projectId: string | null;
|
|
94
|
+
name: string;
|
|
95
|
+
description: string | null;
|
|
96
|
+
type: AppType;
|
|
97
|
+
defaultProjectId: string | null;
|
|
98
|
+
defaultAgentId: string | null;
|
|
99
|
+
enabled: boolean;
|
|
100
|
+
config: {
|
|
101
|
+
type: "web_client";
|
|
102
|
+
webClient: {
|
|
103
|
+
allowedDomains: string[];
|
|
104
|
+
};
|
|
105
|
+
} | {
|
|
106
|
+
type: "api";
|
|
107
|
+
api: Record<string, never>;
|
|
108
|
+
};
|
|
109
|
+
lastUsedAt: string | null;
|
|
110
|
+
}>;
|
|
111
|
+
declare const deleteApp: (db: AgentsRunDatabaseClient) => (id: string) => Promise<boolean>;
|
|
112
|
+
//#endregion
|
|
113
|
+
export { clearAppDefaultsByAgent, clearAppDefaultsByProject, createApp, deleteApp, deleteAppForTenant, deleteAppsByProject, getAppById, getAppByIdForTenant, listAppsPaginated, updateApp, updateAppForTenant, updateAppLastUsed };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { apps } from "../../db/runtime/runtime-schema.js";
|
|
2
|
+
import { and, count, desc, eq } from "drizzle-orm";
|
|
3
|
+
|
|
4
|
+
//#region src/data-access/runtime/apps.ts
|
|
5
|
+
const getAppById = (db) => async (id) => {
|
|
6
|
+
return await db.query.apps.findFirst({ where: eq(apps.id, id) });
|
|
7
|
+
};
|
|
8
|
+
const updateAppLastUsed = (db) => async (id) => {
|
|
9
|
+
await db.update(apps).set({ lastUsedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(eq(apps.id, id));
|
|
10
|
+
};
|
|
11
|
+
const getAppByIdForTenant = (db) => async (params) => {
|
|
12
|
+
return db.query.apps.findFirst({ where: and(eq(apps.id, params.id), eq(apps.tenantId, params.scopes.tenantId)) });
|
|
13
|
+
};
|
|
14
|
+
const listAppsPaginated = (db) => async (params) => {
|
|
15
|
+
const page = params.pagination?.page || 1;
|
|
16
|
+
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
17
|
+
const offset = (page - 1) * limit;
|
|
18
|
+
const conditions = [eq(apps.tenantId, params.scopes.tenantId)];
|
|
19
|
+
if (params.scopes.projectId) conditions.push(eq(apps.projectId, params.scopes.projectId));
|
|
20
|
+
if (params.type) conditions.push(eq(apps.type, params.type));
|
|
21
|
+
const whereClause = and(...conditions);
|
|
22
|
+
const [data, totalResult] = await Promise.all([db.select().from(apps).where(whereClause).limit(limit).offset(offset).orderBy(desc(apps.createdAt)), db.select({ count: count() }).from(apps).where(whereClause)]);
|
|
23
|
+
const total = totalResult[0]?.count || 0;
|
|
24
|
+
const totalNumber = typeof total === "string" ? Number.parseInt(total, 10) : total;
|
|
25
|
+
return {
|
|
26
|
+
data,
|
|
27
|
+
pagination: {
|
|
28
|
+
page,
|
|
29
|
+
limit,
|
|
30
|
+
total: totalNumber,
|
|
31
|
+
pages: Math.ceil(totalNumber / limit)
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
const createApp = (db) => async (params) => {
|
|
36
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
37
|
+
const [app] = await db.insert(apps).values({
|
|
38
|
+
...params,
|
|
39
|
+
createdAt: now,
|
|
40
|
+
updatedAt: now
|
|
41
|
+
}).returning();
|
|
42
|
+
return app;
|
|
43
|
+
};
|
|
44
|
+
const updateAppForTenant = (db) => async (params) => {
|
|
45
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
46
|
+
const [updatedApp] = await db.update(apps).set({
|
|
47
|
+
...params.data,
|
|
48
|
+
updatedAt: now
|
|
49
|
+
}).where(and(eq(apps.id, params.id), eq(apps.tenantId, params.scopes.tenantId))).returning();
|
|
50
|
+
return updatedApp;
|
|
51
|
+
};
|
|
52
|
+
const deleteAppForTenant = (db) => async (params) => {
|
|
53
|
+
return (await db.delete(apps).where(and(eq(apps.id, params.id), eq(apps.tenantId, params.scopes.tenantId))).returning()).length > 0;
|
|
54
|
+
};
|
|
55
|
+
const deleteAppsByProject = (db) => async (tenantId, projectId) => {
|
|
56
|
+
return (await db.delete(apps).where(and(eq(apps.tenantId, tenantId), eq(apps.projectId, projectId))).returning()).length;
|
|
57
|
+
};
|
|
58
|
+
const clearAppDefaultsByProject = (db) => async (tenantId, projectId) => {
|
|
59
|
+
return (await db.update(apps).set({
|
|
60
|
+
defaultProjectId: null,
|
|
61
|
+
defaultAgentId: null,
|
|
62
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
63
|
+
}).where(and(eq(apps.tenantId, tenantId), eq(apps.defaultProjectId, projectId))).returning()).length;
|
|
64
|
+
};
|
|
65
|
+
const clearAppDefaultsByAgent = (db) => async (tenantId, agentId) => {
|
|
66
|
+
return (await db.update(apps).set({
|
|
67
|
+
defaultAgentId: null,
|
|
68
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
69
|
+
}).where(and(eq(apps.tenantId, tenantId), eq(apps.defaultAgentId, agentId))).returning()).length;
|
|
70
|
+
};
|
|
71
|
+
const updateApp = (db) => async (params) => {
|
|
72
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
73
|
+
const [updatedApp] = await db.update(apps).set({
|
|
74
|
+
...params.data,
|
|
75
|
+
updatedAt: now
|
|
76
|
+
}).where(eq(apps.id, params.id)).returning();
|
|
77
|
+
return updatedApp;
|
|
78
|
+
};
|
|
79
|
+
const deleteApp = (db) => async (id) => {
|
|
80
|
+
if (!await getAppById(db)(id)) return false;
|
|
81
|
+
await db.delete(apps).where(eq(apps.id, id));
|
|
82
|
+
return true;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
86
|
+
export { clearAppDefaultsByAgent, clearAppDefaultsByProject, createApp, deleteApp, deleteAppForTenant, deleteAppsByProject, getAppById, getAppByIdForTenant, listAppsPaginated, updateApp, updateAppForTenant, updateAppLastUsed };
|
|
@@ -13,6 +13,8 @@ type CascadeDeleteResult = {
|
|
|
13
13
|
apiKeysDeleted: number;
|
|
14
14
|
slackChannelConfigsDeleted: number;
|
|
15
15
|
slackWorkspaceDefaultsCleared: number;
|
|
16
|
+
appsDeleted: number;
|
|
17
|
+
appDefaultsCleared: number;
|
|
16
18
|
};
|
|
17
19
|
/**
|
|
18
20
|
* Delete all runtime entities for a specific branch.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { apiKeys, contextCache, conversations, tasks, workAppGitHubMcpToolAccessMode, workAppGitHubMcpToolRepositoryAccess, workAppGitHubProjectAccessMode, workAppGitHubProjectRepositoryAccess } from "../../db/runtime/runtime-schema.js";
|
|
2
|
+
import { clearAppDefaultsByAgent, clearAppDefaultsByProject, deleteAppsByProject } from "./apps.js";
|
|
2
3
|
import { deleteSlackMcpToolAccessConfig } from "./slack-work-app-mcp.js";
|
|
3
4
|
import { clearDevConfigWorkspaceDefaultsByAgent, clearDevConfigWorkspaceDefaultsByProject, clearWorkspaceDefaultsByAgent, clearWorkspaceDefaultsByProject, deleteWorkAppSlackChannelAgentConfigsByAgent, deleteWorkAppSlackChannelAgentConfigsByProject } from "./workAppSlack.js";
|
|
4
5
|
import { and, eq, inArray, sql } from "drizzle-orm";
|
|
@@ -22,7 +23,9 @@ const cascadeDeleteByBranch = (db) => async (params) => {
|
|
|
22
23
|
contextCacheDeleted: contextCacheResult.length,
|
|
23
24
|
apiKeysDeleted: 0,
|
|
24
25
|
slackChannelConfigsDeleted: 0,
|
|
25
|
-
slackWorkspaceDefaultsCleared: 0
|
|
26
|
+
slackWorkspaceDefaultsCleared: 0,
|
|
27
|
+
appsDeleted: 0,
|
|
28
|
+
appDefaultsCleared: 0
|
|
26
29
|
};
|
|
27
30
|
};
|
|
28
31
|
/**
|
|
@@ -43,6 +46,8 @@ const cascadeDeleteByProject = (db) => async (params) => {
|
|
|
43
46
|
tenantId: scopes.tenantId,
|
|
44
47
|
projectId: scopes.projectId
|
|
45
48
|
});
|
|
49
|
+
const appsDeleted = await deleteAppsByProject(db)(scopes.tenantId, scopes.projectId);
|
|
50
|
+
const appDefaultsCleared = await clearAppDefaultsByProject(db)(scopes.tenantId, scopes.projectId);
|
|
46
51
|
const slackChannelConfigsDeleted = await deleteWorkAppSlackChannelAgentConfigsByProject(db)(scopes.tenantId, scopes.projectId);
|
|
47
52
|
const slackWorkspaceDefaultsCleared = await clearWorkspaceDefaultsByProject(db)(scopes.tenantId, scopes.projectId);
|
|
48
53
|
clearDevConfigWorkspaceDefaultsByProject(scopes.projectId);
|
|
@@ -52,7 +57,9 @@ const cascadeDeleteByProject = (db) => async (params) => {
|
|
|
52
57
|
contextCacheDeleted: contextCacheResult.length,
|
|
53
58
|
apiKeysDeleted: apiKeysResult.length,
|
|
54
59
|
slackChannelConfigsDeleted,
|
|
55
|
-
slackWorkspaceDefaultsCleared
|
|
60
|
+
slackWorkspaceDefaultsCleared,
|
|
61
|
+
appsDeleted,
|
|
62
|
+
appDefaultsCleared
|
|
56
63
|
};
|
|
57
64
|
};
|
|
58
65
|
/**
|
|
@@ -78,6 +85,7 @@ const cascadeDeleteByAgent = (db) => async (params) => {
|
|
|
78
85
|
}
|
|
79
86
|
tasksDeleted = (await db.delete(tasks).where(and(eq(tasks.tenantId, scopes.tenantId), eq(tasks.projectId, scopes.projectId), eq(tasks.agentId, scopes.agentId), sql`${tasks.ref}->>'name' = ${fullBranchName}`)).returning()).length;
|
|
80
87
|
apiKeysDeleted = (await db.delete(apiKeys).where(and(eq(apiKeys.tenantId, scopes.tenantId), eq(apiKeys.projectId, scopes.projectId), eq(apiKeys.agentId, scopes.agentId))).returning()).length;
|
|
88
|
+
const appDefaultsCleared = await clearAppDefaultsByAgent(db)(scopes.tenantId, scopes.agentId);
|
|
81
89
|
const slackChannelConfigsDeleted = await deleteWorkAppSlackChannelAgentConfigsByAgent(db)(scopes.tenantId, scopes.projectId, scopes.agentId);
|
|
82
90
|
const slackWorkspaceDefaultsCleared = await clearWorkspaceDefaultsByAgent(db)(scopes.tenantId, scopes.projectId, scopes.agentId);
|
|
83
91
|
clearDevConfigWorkspaceDefaultsByAgent(scopes.projectId, scopes.agentId);
|
|
@@ -87,7 +95,9 @@ const cascadeDeleteByAgent = (db) => async (params) => {
|
|
|
87
95
|
contextCacheDeleted,
|
|
88
96
|
apiKeysDeleted,
|
|
89
97
|
slackChannelConfigsDeleted,
|
|
90
|
-
slackWorkspaceDefaultsCleared
|
|
98
|
+
slackWorkspaceDefaultsCleared,
|
|
99
|
+
appsDeleted: 0,
|
|
100
|
+
appDefaultsCleared
|
|
91
101
|
};
|
|
92
102
|
};
|
|
93
103
|
/**
|
|
@@ -112,7 +122,9 @@ const cascadeDeleteBySubAgent = (db) => async (params) => {
|
|
|
112
122
|
contextCacheDeleted,
|
|
113
123
|
apiKeysDeleted: 0,
|
|
114
124
|
slackChannelConfigsDeleted: 0,
|
|
115
|
-
slackWorkspaceDefaultsCleared: 0
|
|
125
|
+
slackWorkspaceDefaultsCleared: 0,
|
|
126
|
+
appsDeleted: 0,
|
|
127
|
+
appDefaultsCleared: 0
|
|
116
128
|
};
|
|
117
129
|
};
|
|
118
130
|
/**
|
|
@@ -16,13 +16,13 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
16
16
|
total: number;
|
|
17
17
|
}>;
|
|
18
18
|
declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
|
|
19
|
+
title: string | null;
|
|
20
|
+
tenantId: string;
|
|
21
|
+
projectId: string;
|
|
22
|
+
agentId: string | null;
|
|
19
23
|
id: string;
|
|
20
24
|
createdAt: string;
|
|
21
25
|
updatedAt: string;
|
|
22
|
-
agentId: string | null;
|
|
23
|
-
projectId: string;
|
|
24
|
-
tenantId: string;
|
|
25
|
-
title: string | null;
|
|
26
26
|
metadata: ConversationMetadata | null;
|
|
27
27
|
userId: string | null;
|
|
28
28
|
ref: {
|
|
@@ -85,13 +85,13 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
85
85
|
scopes: ProjectScopeConfig;
|
|
86
86
|
conversationId: string;
|
|
87
87
|
}) => Promise<{
|
|
88
|
+
title: string | null;
|
|
89
|
+
tenantId: string;
|
|
90
|
+
projectId: string;
|
|
91
|
+
agentId: string | null;
|
|
88
92
|
id: string;
|
|
89
93
|
createdAt: string;
|
|
90
94
|
updatedAt: string;
|
|
91
|
-
agentId: string | null;
|
|
92
|
-
projectId: string;
|
|
93
|
-
tenantId: string;
|
|
94
|
-
title: string | null;
|
|
95
95
|
metadata: ConversationMetadata | null;
|
|
96
96
|
userId: string | null;
|
|
97
97
|
ref: {
|
|
@@ -121,13 +121,13 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
121
121
|
metadata?: ConversationMetadata | null | undefined;
|
|
122
122
|
contextConfigId?: string | undefined;
|
|
123
123
|
} | {
|
|
124
|
+
title: string | null;
|
|
125
|
+
tenantId: string;
|
|
126
|
+
projectId: string;
|
|
127
|
+
agentId: string | null;
|
|
124
128
|
id: string;
|
|
125
129
|
createdAt: string;
|
|
126
130
|
updatedAt: string;
|
|
127
|
-
agentId: string | null;
|
|
128
|
-
projectId: string;
|
|
129
|
-
tenantId: string;
|
|
130
|
-
title: string | null;
|
|
131
131
|
metadata: ConversationMetadata | null;
|
|
132
132
|
userId: string | null;
|
|
133
133
|
ref: {
|
|
@@ -153,13 +153,13 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
153
153
|
scopes: ProjectScopeConfig;
|
|
154
154
|
conversationId: string;
|
|
155
155
|
}) => Promise<{
|
|
156
|
+
title: string | null;
|
|
157
|
+
tenantId: string;
|
|
158
|
+
projectId: string;
|
|
159
|
+
agentId: string | null;
|
|
156
160
|
id: string;
|
|
157
161
|
createdAt: string;
|
|
158
162
|
updatedAt: string;
|
|
159
|
-
agentId: string | null;
|
|
160
|
-
projectId: string;
|
|
161
|
-
tenantId: string;
|
|
162
|
-
title: string | null;
|
|
163
163
|
metadata: ConversationMetadata | null;
|
|
164
164
|
userId: string | null;
|
|
165
165
|
ref: {
|
|
@@ -179,6 +179,7 @@ declare const setActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
179
179
|
subAgentId: string;
|
|
180
180
|
agentId: string;
|
|
181
181
|
ref: ResolvedRef;
|
|
182
|
+
userId?: string;
|
|
182
183
|
}) => Promise<void>;
|
|
183
184
|
declare const setActiveAgentForThread: (db: AgentsRunDatabaseClient) => ({
|
|
184
185
|
scopes,
|
|
@@ -162,6 +162,7 @@ const setActiveAgentForConversation = (db) => async (params) => {
|
|
|
162
162
|
activeSubAgentId: params.subAgentId,
|
|
163
163
|
agentId: params.agentId,
|
|
164
164
|
ref: params.ref,
|
|
165
|
+
userId: params.userId,
|
|
165
166
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
166
167
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
167
168
|
}).onConflictDoUpdate({
|
|
@@ -10,26 +10,26 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
10
10
|
scopes: ProjectScopeConfig;
|
|
11
11
|
messageId: string;
|
|
12
12
|
}) => Promise<{
|
|
13
|
+
tenantId: string;
|
|
14
|
+
projectId: string;
|
|
13
15
|
id: string;
|
|
14
16
|
createdAt: string;
|
|
15
17
|
updatedAt: string;
|
|
16
|
-
projectId: string;
|
|
17
|
-
tenantId: string;
|
|
18
18
|
metadata: MessageMetadata | null;
|
|
19
19
|
content: MessageContent;
|
|
20
|
+
conversationId: string;
|
|
21
|
+
role: string;
|
|
20
22
|
fromSubAgentId: string | null;
|
|
21
23
|
toSubAgentId: string | null;
|
|
22
24
|
fromExternalAgentId: string | null;
|
|
23
25
|
toExternalAgentId: string | null;
|
|
24
|
-
taskId: string | null;
|
|
25
|
-
a2aTaskId: string | null;
|
|
26
|
-
conversationId: string;
|
|
27
|
-
role: string;
|
|
28
26
|
fromTeamAgentId: string | null;
|
|
29
27
|
toTeamAgentId: string | null;
|
|
30
28
|
visibility: string;
|
|
31
29
|
messageType: string;
|
|
30
|
+
taskId: string | null;
|
|
32
31
|
parentMessageId: string | null;
|
|
32
|
+
a2aTaskId: string | null;
|
|
33
33
|
a2aSessionId: string | null;
|
|
34
34
|
} | undefined>;
|
|
35
35
|
declare const listMessages: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -141,26 +141,26 @@ declare const getVisibleMessages: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
141
141
|
id: string;
|
|
142
142
|
}[]>;
|
|
143
143
|
declare const createMessage: (db: AgentsRunDatabaseClient) => (params: MessageInsert) => Promise<{
|
|
144
|
+
tenantId: string;
|
|
145
|
+
projectId: string;
|
|
144
146
|
id: string;
|
|
145
147
|
createdAt: string;
|
|
146
148
|
updatedAt: string;
|
|
147
|
-
projectId: string;
|
|
148
|
-
tenantId: string;
|
|
149
149
|
metadata: MessageMetadata | null;
|
|
150
150
|
content: MessageContent;
|
|
151
|
+
conversationId: string;
|
|
152
|
+
role: string;
|
|
151
153
|
fromSubAgentId: string | null;
|
|
152
154
|
toSubAgentId: string | null;
|
|
153
155
|
fromExternalAgentId: string | null;
|
|
154
156
|
toExternalAgentId: string | null;
|
|
155
|
-
taskId: string | null;
|
|
156
|
-
a2aTaskId: string | null;
|
|
157
|
-
conversationId: string;
|
|
158
|
-
role: string;
|
|
159
157
|
fromTeamAgentId: string | null;
|
|
160
158
|
toTeamAgentId: string | null;
|
|
161
159
|
visibility: string;
|
|
162
160
|
messageType: string;
|
|
161
|
+
taskId: string | null;
|
|
163
162
|
parentMessageId: string | null;
|
|
163
|
+
a2aTaskId: string | null;
|
|
164
164
|
a2aSessionId: string | null;
|
|
165
165
|
}>;
|
|
166
166
|
declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -194,26 +194,26 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
194
194
|
scopes: ProjectScopeConfig;
|
|
195
195
|
messageId: string;
|
|
196
196
|
}) => Promise<{
|
|
197
|
+
tenantId: string;
|
|
198
|
+
projectId: string;
|
|
197
199
|
id: string;
|
|
198
200
|
createdAt: string;
|
|
199
201
|
updatedAt: string;
|
|
200
|
-
projectId: string;
|
|
201
|
-
tenantId: string;
|
|
202
202
|
metadata: MessageMetadata | null;
|
|
203
203
|
content: MessageContent;
|
|
204
|
+
conversationId: string;
|
|
205
|
+
role: string;
|
|
204
206
|
fromSubAgentId: string | null;
|
|
205
207
|
toSubAgentId: string | null;
|
|
206
208
|
fromExternalAgentId: string | null;
|
|
207
209
|
toExternalAgentId: string | null;
|
|
208
|
-
taskId: string | null;
|
|
209
|
-
a2aTaskId: string | null;
|
|
210
|
-
conversationId: string;
|
|
211
|
-
role: string;
|
|
212
210
|
fromTeamAgentId: string | null;
|
|
213
211
|
toTeamAgentId: string | null;
|
|
214
212
|
visibility: string;
|
|
215
213
|
messageType: string;
|
|
214
|
+
taskId: string | null;
|
|
216
215
|
parentMessageId: string | null;
|
|
216
|
+
a2aTaskId: string | null;
|
|
217
217
|
a2aSessionId: string | null;
|
|
218
218
|
}>;
|
|
219
219
|
declare const countMessagesByConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -6,15 +6,15 @@ import { TaskInsert, TaskSelect } from "../../types/entities.js";
|
|
|
6
6
|
|
|
7
7
|
//#region src/data-access/runtime/tasks.d.ts
|
|
8
8
|
declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert) => Promise<{
|
|
9
|
+
tenantId: string;
|
|
10
|
+
projectId: string;
|
|
11
|
+
agentId: string;
|
|
12
|
+
subAgentId: string;
|
|
9
13
|
id: string;
|
|
10
14
|
createdAt: string;
|
|
11
15
|
updatedAt: string;
|
|
12
|
-
agentId: string;
|
|
13
|
-
projectId: string;
|
|
14
|
-
tenantId: string;
|
|
15
16
|
metadata: TaskMetadataConfig | null;
|
|
16
17
|
status: string;
|
|
17
|
-
subAgentId: string;
|
|
18
18
|
contextId: string;
|
|
19
19
|
ref: {
|
|
20
20
|
type: "tag" | "commit" | "branch";
|