@inkeep/agents-core 0.58.7 → 0.58.8
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 +152 -152
- package/dist/auth/auth.d.ts +9 -9
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/client-exports.d.ts +6 -4
- 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 +10 -10
- package/dist/data-access/manage/artifactComponents.d.ts +6 -6
- package/dist/data-access/manage/contextConfigs.d.ts +8 -8
- package/dist/data-access/manage/dataComponents.d.ts +2 -2
- package/dist/data-access/manage/functionTools.d.ts +8 -8
- package/dist/data-access/manage/skills.d.ts +11 -11
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgentRelations.d.ts +16 -16
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +12 -12
- package/dist/data-access/manage/subAgents.d.ts +6 -6
- package/dist/data-access/manage/tools.d.ts +12 -12
- package/dist/data-access/manage/triggers.d.ts +2 -2
- 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 +32 -31
- package/dist/data-access/runtime/conversations.js +1 -0
- package/dist/data-access/runtime/messages.d.ts +9 -9
- package/dist/data-access/runtime/tasks.d.ts +9 -9
- package/dist/db/manage/manage-schema.d.ts +453 -453
- package/dist/db/runtime/runtime-schema.d.ts +582 -321
- 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/dolt-schemas.d.ts +1 -1
- 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 +3282 -2001
- 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
|
@@ -21,11 +21,11 @@ declare const getToolById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
21
21
|
}) => Promise<{
|
|
22
22
|
id: string;
|
|
23
23
|
name: string;
|
|
24
|
-
createdAt: string;
|
|
25
|
-
updatedAt: string;
|
|
26
24
|
description: string | null;
|
|
27
25
|
tenantId: string;
|
|
28
26
|
projectId: string;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
updatedAt: string;
|
|
29
29
|
headers: Record<string, string> | null;
|
|
30
30
|
config: {
|
|
31
31
|
type: "mcp";
|
|
@@ -79,11 +79,11 @@ declare const listTools: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
79
79
|
declare const createTool: (db: AgentsManageDatabaseClient) => (params: ToolInsert) => Promise<{
|
|
80
80
|
id: string;
|
|
81
81
|
name: string;
|
|
82
|
-
createdAt: string;
|
|
83
|
-
updatedAt: string;
|
|
84
82
|
description: string | null;
|
|
85
83
|
tenantId: string;
|
|
86
84
|
projectId: string;
|
|
85
|
+
createdAt: string;
|
|
86
|
+
updatedAt: string;
|
|
87
87
|
headers: Record<string, string> | null;
|
|
88
88
|
config: {
|
|
89
89
|
type: "mcp";
|
|
@@ -135,11 +135,11 @@ declare const addToolToAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
135
135
|
}> | null;
|
|
136
136
|
}) => Promise<{
|
|
137
137
|
id: string;
|
|
138
|
-
createdAt: string;
|
|
139
|
-
updatedAt: string;
|
|
140
138
|
tenantId: string;
|
|
141
139
|
projectId: string;
|
|
142
140
|
agentId: string;
|
|
141
|
+
createdAt: string;
|
|
142
|
+
updatedAt: string;
|
|
143
143
|
toolId: string;
|
|
144
144
|
headers: Record<string, string> | null;
|
|
145
145
|
toolPolicies: Record<string, {
|
|
@@ -154,11 +154,11 @@ declare const removeToolFromAgent: (db: AgentsManageDatabaseClient) => (params:
|
|
|
154
154
|
toolId: string;
|
|
155
155
|
}) => Promise<{
|
|
156
156
|
id: string;
|
|
157
|
-
createdAt: string;
|
|
158
|
-
updatedAt: string;
|
|
159
157
|
tenantId: string;
|
|
160
158
|
projectId: string;
|
|
161
159
|
agentId: string;
|
|
160
|
+
createdAt: string;
|
|
161
|
+
updatedAt: string;
|
|
162
162
|
toolId: string;
|
|
163
163
|
headers: Record<string, string> | null;
|
|
164
164
|
toolPolicies: Record<string, {
|
|
@@ -182,11 +182,11 @@ declare const upsertSubAgentToolRelation: (db: AgentsManageDatabaseClient) => (p
|
|
|
182
182
|
relationId?: string;
|
|
183
183
|
}) => Promise<{
|
|
184
184
|
id: string;
|
|
185
|
-
createdAt: string;
|
|
186
|
-
updatedAt: string;
|
|
187
185
|
tenantId: string;
|
|
188
186
|
projectId: string;
|
|
189
187
|
agentId: string;
|
|
188
|
+
createdAt: string;
|
|
189
|
+
updatedAt: string;
|
|
190
190
|
toolId: string;
|
|
191
191
|
headers: Record<string, string> | null;
|
|
192
192
|
toolPolicies: Record<string, {
|
|
@@ -203,11 +203,11 @@ declare const upsertTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
203
203
|
}) => Promise<{
|
|
204
204
|
id: string;
|
|
205
205
|
name: string;
|
|
206
|
-
createdAt: string;
|
|
207
|
-
updatedAt: string;
|
|
208
206
|
description: string | null;
|
|
209
207
|
tenantId: string;
|
|
210
208
|
projectId: string;
|
|
209
|
+
createdAt: string;
|
|
210
|
+
updatedAt: string;
|
|
211
211
|
headers: Record<string, string> | null;
|
|
212
212
|
config: {
|
|
213
213
|
type: "mcp";
|
|
@@ -40,13 +40,13 @@ declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params
|
|
|
40
40
|
algorithm: "sha256" | "sha512" | "sha384" | "sha1" | "md5";
|
|
41
41
|
encoding: "hex" | "base64";
|
|
42
42
|
signature: {
|
|
43
|
-
source: "query" | "
|
|
43
|
+
source: "query" | "header" | "body";
|
|
44
44
|
key: string;
|
|
45
45
|
prefix?: string | undefined;
|
|
46
46
|
regex?: string | undefined;
|
|
47
47
|
};
|
|
48
48
|
signedComponents: {
|
|
49
|
-
source: "literal" | "
|
|
49
|
+
source: "literal" | "header" | "body";
|
|
50
50
|
required: boolean;
|
|
51
51
|
key?: string | undefined;
|
|
52
52
|
value?: string | undefined;
|
|
@@ -10,30 +10,30 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
10
10
|
}) => Promise<{
|
|
11
11
|
id: string;
|
|
12
12
|
name: string | null;
|
|
13
|
-
createdAt: string;
|
|
14
|
-
updatedAt: string;
|
|
15
|
-
expiresAt: string | null;
|
|
16
13
|
tenantId: string;
|
|
17
14
|
projectId: string;
|
|
18
15
|
agentId: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
19
18
|
publicId: string;
|
|
20
19
|
keyHash: string;
|
|
21
20
|
keyPrefix: string;
|
|
22
21
|
lastUsedAt: string | null;
|
|
22
|
+
expiresAt: string | null;
|
|
23
23
|
} | undefined>;
|
|
24
24
|
declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
|
|
25
25
|
id: string;
|
|
26
26
|
name: string | null;
|
|
27
|
-
createdAt: string;
|
|
28
|
-
updatedAt: string;
|
|
29
|
-
expiresAt: string | null;
|
|
30
27
|
tenantId: string;
|
|
31
28
|
projectId: string;
|
|
32
29
|
agentId: string;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
updatedAt: string;
|
|
33
32
|
publicId: string;
|
|
34
33
|
keyHash: string;
|
|
35
34
|
keyPrefix: string;
|
|
36
35
|
lastUsedAt: string | null;
|
|
36
|
+
expiresAt: string | null;
|
|
37
37
|
} | undefined>;
|
|
38
38
|
declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
39
39
|
scopes: ProjectScopeConfig;
|
|
@@ -41,16 +41,16 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
41
41
|
}) => Promise<{
|
|
42
42
|
id: string;
|
|
43
43
|
name: string | null;
|
|
44
|
-
createdAt: string;
|
|
45
|
-
updatedAt: string;
|
|
46
|
-
expiresAt: string | null;
|
|
47
44
|
tenantId: string;
|
|
48
45
|
projectId: string;
|
|
49
46
|
agentId: string;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
updatedAt: string;
|
|
50
49
|
publicId: string;
|
|
51
50
|
keyHash: string;
|
|
52
51
|
keyPrefix: string;
|
|
53
52
|
lastUsedAt: string | null;
|
|
53
|
+
expiresAt: string | null;
|
|
54
54
|
}[]>;
|
|
55
55
|
declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
56
56
|
scopes: ProjectScopeConfig;
|
|
@@ -68,16 +68,16 @@ declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
68
68
|
declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInsert) => Promise<{
|
|
69
69
|
id: string;
|
|
70
70
|
name: string | null;
|
|
71
|
-
createdAt: string;
|
|
72
|
-
updatedAt: string;
|
|
73
|
-
expiresAt: string | null;
|
|
74
71
|
tenantId: string;
|
|
75
72
|
projectId: string;
|
|
76
73
|
agentId: string;
|
|
74
|
+
createdAt: string;
|
|
75
|
+
updatedAt: string;
|
|
77
76
|
publicId: string;
|
|
78
77
|
keyHash: string;
|
|
79
78
|
keyPrefix: string;
|
|
80
79
|
lastUsedAt: string | null;
|
|
80
|
+
expiresAt: string | null;
|
|
81
81
|
}>;
|
|
82
82
|
declare const updateApiKey: (db: AgentsRunDatabaseClient) => (params: {
|
|
83
83
|
scopes: ProjectScopeConfig;
|
|
@@ -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
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string | null;
|
|
11
|
+
tenantId: string | null;
|
|
12
|
+
projectId: string | null;
|
|
13
|
+
type: AppType;
|
|
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
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
description: string | null;
|
|
54
|
+
tenantId: string | null;
|
|
55
|
+
projectId: string | null;
|
|
56
|
+
type: AppType;
|
|
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
|
/**
|
|
@@ -17,19 +17,19 @@ declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
17
17
|
}>;
|
|
18
18
|
declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
|
|
19
19
|
id: string;
|
|
20
|
+
tenantId: string;
|
|
21
|
+
projectId: string;
|
|
22
|
+
agentId: string | null;
|
|
23
|
+
title: string | null;
|
|
20
24
|
createdAt: string;
|
|
21
25
|
updatedAt: string;
|
|
26
|
+
metadata: ConversationMetadata | null;
|
|
27
|
+
userId: string | null;
|
|
22
28
|
ref: {
|
|
23
|
-
type: "
|
|
29
|
+
type: "commit" | "tag" | "branch";
|
|
24
30
|
name: string;
|
|
25
31
|
hash: string;
|
|
26
32
|
} | null;
|
|
27
|
-
userId: string | null;
|
|
28
|
-
metadata: ConversationMetadata | null;
|
|
29
|
-
tenantId: string;
|
|
30
|
-
projectId: string;
|
|
31
|
-
agentId: string | null;
|
|
32
|
-
title: string | null;
|
|
33
33
|
activeSubAgentId: string;
|
|
34
34
|
lastContextResolution: string | null;
|
|
35
35
|
}>;
|
|
@@ -44,7 +44,7 @@ declare const updateConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
44
44
|
agentId: string | null;
|
|
45
45
|
activeSubAgentId: string;
|
|
46
46
|
ref: {
|
|
47
|
-
type: "
|
|
47
|
+
type: "commit" | "tag" | "branch";
|
|
48
48
|
name: string;
|
|
49
49
|
hash: string;
|
|
50
50
|
} | null;
|
|
@@ -70,7 +70,7 @@ declare const updateConversationActiveSubAgent: (db: AgentsRunDatabaseClient) =>
|
|
|
70
70
|
agentId: string | null;
|
|
71
71
|
activeSubAgentId: string;
|
|
72
72
|
ref: {
|
|
73
|
-
type: "
|
|
73
|
+
type: "commit" | "tag" | "branch";
|
|
74
74
|
name: string;
|
|
75
75
|
hash: string;
|
|
76
76
|
} | null;
|
|
@@ -86,19 +86,19 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
86
86
|
conversationId: string;
|
|
87
87
|
}) => Promise<{
|
|
88
88
|
id: string;
|
|
89
|
+
tenantId: string;
|
|
90
|
+
projectId: string;
|
|
91
|
+
agentId: string | null;
|
|
92
|
+
title: string | null;
|
|
89
93
|
createdAt: string;
|
|
90
94
|
updatedAt: string;
|
|
95
|
+
metadata: ConversationMetadata | null;
|
|
96
|
+
userId: string | null;
|
|
91
97
|
ref: {
|
|
92
|
-
type: "
|
|
98
|
+
type: "commit" | "tag" | "branch";
|
|
93
99
|
name: string;
|
|
94
100
|
hash: string;
|
|
95
101
|
} | null;
|
|
96
|
-
userId: string | null;
|
|
97
|
-
metadata: ConversationMetadata | null;
|
|
98
|
-
tenantId: string;
|
|
99
|
-
projectId: string;
|
|
100
|
-
agentId: string | null;
|
|
101
|
-
title: string | null;
|
|
102
102
|
activeSubAgentId: string;
|
|
103
103
|
lastContextResolution: string | null;
|
|
104
104
|
} | undefined>;
|
|
@@ -108,7 +108,7 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
108
108
|
tenantId: string;
|
|
109
109
|
id: string;
|
|
110
110
|
ref: {
|
|
111
|
-
type: "
|
|
111
|
+
type: "commit" | "tag" | "branch";
|
|
112
112
|
name: string;
|
|
113
113
|
hash: string;
|
|
114
114
|
};
|
|
@@ -122,19 +122,19 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
122
122
|
contextConfigId?: string | undefined;
|
|
123
123
|
} | {
|
|
124
124
|
id: string;
|
|
125
|
+
tenantId: string;
|
|
126
|
+
projectId: string;
|
|
127
|
+
agentId: string | null;
|
|
128
|
+
title: string | null;
|
|
125
129
|
createdAt: string;
|
|
126
130
|
updatedAt: string;
|
|
131
|
+
metadata: ConversationMetadata | null;
|
|
132
|
+
userId: string | null;
|
|
127
133
|
ref: {
|
|
128
|
-
type: "
|
|
134
|
+
type: "commit" | "tag" | "branch";
|
|
129
135
|
name: string;
|
|
130
136
|
hash: string;
|
|
131
137
|
} | null;
|
|
132
|
-
userId: string | null;
|
|
133
|
-
metadata: ConversationMetadata | null;
|
|
134
|
-
tenantId: string;
|
|
135
|
-
projectId: string;
|
|
136
|
-
agentId: string | null;
|
|
137
|
-
title: string | null;
|
|
138
138
|
activeSubAgentId: string;
|
|
139
139
|
lastContextResolution: string | null;
|
|
140
140
|
}>;
|
|
@@ -154,19 +154,19 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
154
154
|
conversationId: string;
|
|
155
155
|
}) => Promise<{
|
|
156
156
|
id: string;
|
|
157
|
+
tenantId: string;
|
|
158
|
+
projectId: string;
|
|
159
|
+
agentId: string | null;
|
|
160
|
+
title: string | null;
|
|
157
161
|
createdAt: string;
|
|
158
162
|
updatedAt: string;
|
|
163
|
+
metadata: ConversationMetadata | null;
|
|
164
|
+
userId: string | null;
|
|
159
165
|
ref: {
|
|
160
|
-
type: "
|
|
166
|
+
type: "commit" | "tag" | "branch";
|
|
161
167
|
name: string;
|
|
162
168
|
hash: string;
|
|
163
169
|
} | null;
|
|
164
|
-
userId: string | null;
|
|
165
|
-
metadata: ConversationMetadata | null;
|
|
166
|
-
tenantId: string;
|
|
167
|
-
projectId: string;
|
|
168
|
-
agentId: string | null;
|
|
169
|
-
title: string | null;
|
|
170
170
|
activeSubAgentId: string;
|
|
171
171
|
lastContextResolution: string | null;
|
|
172
172
|
} | undefined>;
|
|
@@ -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({
|
|
@@ -11,12 +11,11 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
11
11
|
messageId: string;
|
|
12
12
|
}) => Promise<{
|
|
13
13
|
id: string;
|
|
14
|
+
tenantId: string;
|
|
15
|
+
projectId: string;
|
|
14
16
|
createdAt: string;
|
|
15
17
|
updatedAt: string;
|
|
16
18
|
metadata: MessageMetadata | null;
|
|
17
|
-
role: string;
|
|
18
|
-
tenantId: string;
|
|
19
|
-
projectId: string;
|
|
20
19
|
content: MessageContent;
|
|
21
20
|
fromSubAgentId: string | null;
|
|
22
21
|
toSubAgentId: string | null;
|
|
@@ -25,6 +24,7 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
25
24
|
taskId: string | null;
|
|
26
25
|
a2aTaskId: string | null;
|
|
27
26
|
conversationId: string;
|
|
27
|
+
role: string;
|
|
28
28
|
fromTeamAgentId: string | null;
|
|
29
29
|
toTeamAgentId: string | null;
|
|
30
30
|
visibility: string;
|
|
@@ -142,12 +142,11 @@ declare const getVisibleMessages: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
142
142
|
}[]>;
|
|
143
143
|
declare const createMessage: (db: AgentsRunDatabaseClient) => (params: MessageInsert) => Promise<{
|
|
144
144
|
id: string;
|
|
145
|
+
tenantId: string;
|
|
146
|
+
projectId: string;
|
|
145
147
|
createdAt: string;
|
|
146
148
|
updatedAt: string;
|
|
147
149
|
metadata: MessageMetadata | null;
|
|
148
|
-
role: string;
|
|
149
|
-
tenantId: string;
|
|
150
|
-
projectId: string;
|
|
151
150
|
content: MessageContent;
|
|
152
151
|
fromSubAgentId: string | null;
|
|
153
152
|
toSubAgentId: string | null;
|
|
@@ -156,6 +155,7 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: MessageIn
|
|
|
156
155
|
taskId: string | null;
|
|
157
156
|
a2aTaskId: string | null;
|
|
158
157
|
conversationId: string;
|
|
158
|
+
role: string;
|
|
159
159
|
fromTeamAgentId: string | null;
|
|
160
160
|
toTeamAgentId: string | null;
|
|
161
161
|
visibility: string;
|
|
@@ -195,12 +195,11 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
195
195
|
messageId: string;
|
|
196
196
|
}) => Promise<{
|
|
197
197
|
id: string;
|
|
198
|
+
tenantId: string;
|
|
199
|
+
projectId: string;
|
|
198
200
|
createdAt: string;
|
|
199
201
|
updatedAt: string;
|
|
200
202
|
metadata: MessageMetadata | null;
|
|
201
|
-
role: string;
|
|
202
|
-
tenantId: string;
|
|
203
|
-
projectId: string;
|
|
204
203
|
content: MessageContent;
|
|
205
204
|
fromSubAgentId: string | null;
|
|
206
205
|
toSubAgentId: string | null;
|
|
@@ -209,6 +208,7 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
209
208
|
taskId: string | null;
|
|
210
209
|
a2aTaskId: string | null;
|
|
211
210
|
conversationId: string;
|
|
211
|
+
role: string;
|
|
212
212
|
fromTeamAgentId: string | null;
|
|
213
213
|
toTeamAgentId: string | null;
|
|
214
214
|
visibility: string;
|