@inkeep/agents-core 0.58.14 → 0.58.16
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/auth/auth.js +17 -45
- package/dist/data-access/index.d.ts +5 -2
- package/dist/data-access/index.js +5 -2
- package/dist/data-access/manage/agentFull.js +28 -12
- package/dist/data-access/manage/agents.d.ts +35 -34
- package/dist/data-access/manage/agents.js +33 -33
- package/dist/data-access/manage/artifactComponents.d.ts +12 -12
- package/dist/data-access/manage/artifactComponents.js +14 -13
- package/dist/data-access/manage/audit-queries.js +6 -5
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- package/dist/data-access/manage/contextConfigs.js +7 -6
- package/dist/data-access/manage/credentialReferences.js +12 -11
- package/dist/data-access/manage/dataComponents.d.ts +6 -6
- package/dist/data-access/manage/dataComponents.js +13 -11
- package/dist/data-access/manage/evalConfig.js +42 -41
- package/dist/data-access/manage/externalAgents.js +8 -7
- package/dist/data-access/manage/functionTools.d.ts +17 -21
- package/dist/data-access/manage/functionTools.js +27 -65
- package/dist/data-access/manage/functions.js +7 -10
- package/dist/data-access/manage/projects.js +37 -36
- package/dist/data-access/manage/scheduledTriggers.js +10 -6
- package/dist/data-access/manage/scheduledWorkflows.js +3 -2
- package/dist/data-access/manage/scope-helpers.d.ts +2 -1
- package/dist/data-access/manage/scope-helpers.js +2 -1
- package/dist/data-access/manage/skills.d.ts +14 -14
- package/dist/data-access/manage/skills.js +14 -9
- 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/subAgentRelations.js +28 -26
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgentTeamAgentRelations.js +16 -16
- package/dist/data-access/manage/subAgents.d.ts +18 -18
- package/dist/data-access/manage/subAgents.js +8 -7
- package/dist/data-access/manage/tools.d.ts +24 -24
- package/dist/data-access/manage/tools.js +8 -6
- package/dist/data-access/manage/triggers.js +12 -8
- package/dist/data-access/runtime/apiKeys.d.ts +20 -20
- package/dist/data-access/runtime/apiKeys.js +16 -12
- package/dist/data-access/runtime/apps.d.ts +10 -10
- package/dist/data-access/runtime/apps.js +8 -7
- package/dist/data-access/runtime/audit-queries.js +7 -7
- package/dist/data-access/runtime/auth.d.ts +18 -0
- package/dist/data-access/runtime/auth.js +35 -0
- package/dist/data-access/runtime/cascade-delete.js +29 -24
- package/dist/data-access/runtime/contextCache.d.ts +1 -0
- package/dist/data-access/runtime/contextCache.js +9 -8
- package/dist/data-access/runtime/conversations.d.ts +27 -27
- package/dist/data-access/runtime/conversations.js +8 -12
- package/dist/data-access/runtime/evalRuns.js +23 -22
- package/dist/data-access/runtime/github-work-app-installations.js +32 -21
- package/dist/data-access/runtime/ledgerArtifacts.js +9 -24
- package/dist/data-access/runtime/messages.d.ts +24 -19
- package/dist/data-access/runtime/messages.js +15 -9
- package/dist/data-access/runtime/projects.js +6 -5
- package/dist/data-access/runtime/scheduledTriggerInvocations.js +16 -26
- package/dist/data-access/runtime/slack-work-app-mcp.js +6 -5
- package/dist/data-access/runtime/tasks.d.ts +10 -6
- package/dist/data-access/runtime/tasks.js +4 -5
- package/dist/data-access/runtime/triggerInvocations.js +4 -8
- package/dist/data-access/runtime/workAppSlack.js +21 -14
- package/dist/db/manage/manage-schema.d.ts +357 -357
- package/dist/db/runtime/runtime-schema.d.ts +300 -300
- package/dist/index.d.ts +7 -3
- package/dist/index.js +8 -2
- package/dist/retry/index.d.ts +3 -0
- package/dist/retry/index.js +4 -0
- package/dist/retry/retryable-errors.d.ts +10 -0
- package/dist/retry/retryable-errors.js +72 -0
- package/dist/retry/withRetry.d.ts +15 -0
- package/dist/retry/withRetry.js +37 -0
- package/dist/validation/dolt-schemas.d.ts +1 -1
- package/dist/validation/schemas.d.ts +1704 -1704
- package/package.json +1 -1
|
@@ -10,30 +10,30 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
10
10
|
}) => Promise<{
|
|
11
11
|
id: string;
|
|
12
12
|
name: string | null;
|
|
13
|
+
tenantId: string;
|
|
14
|
+
projectId: string;
|
|
15
|
+
agentId: string;
|
|
13
16
|
createdAt: string;
|
|
14
17
|
updatedAt: string;
|
|
15
18
|
expiresAt: string | null;
|
|
16
|
-
|
|
17
|
-
tenantId: string;
|
|
18
|
-
agentId: string;
|
|
19
|
+
lastUsedAt: string | null;
|
|
19
20
|
publicId: string;
|
|
20
21
|
keyHash: string;
|
|
21
22
|
keyPrefix: string;
|
|
22
|
-
lastUsedAt: 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
|
+
tenantId: string;
|
|
28
|
+
projectId: string;
|
|
29
|
+
agentId: string;
|
|
27
30
|
createdAt: string;
|
|
28
31
|
updatedAt: string;
|
|
29
32
|
expiresAt: string | null;
|
|
30
|
-
|
|
31
|
-
tenantId: string;
|
|
32
|
-
agentId: string;
|
|
33
|
+
lastUsedAt: string | null;
|
|
33
34
|
publicId: string;
|
|
34
35
|
keyHash: string;
|
|
35
36
|
keyPrefix: string;
|
|
36
|
-
lastUsedAt: 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
|
+
tenantId: string;
|
|
45
|
+
projectId: string;
|
|
46
|
+
agentId: string;
|
|
44
47
|
createdAt: string;
|
|
45
48
|
updatedAt: string;
|
|
46
49
|
expiresAt: string | null;
|
|
47
|
-
|
|
48
|
-
tenantId: string;
|
|
49
|
-
agentId: string;
|
|
50
|
+
lastUsedAt: string | null;
|
|
50
51
|
publicId: string;
|
|
51
52
|
keyHash: string;
|
|
52
53
|
keyPrefix: string;
|
|
53
|
-
lastUsedAt: 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
|
+
tenantId: string;
|
|
72
|
+
projectId: string;
|
|
73
|
+
agentId: string;
|
|
71
74
|
createdAt: string;
|
|
72
75
|
updatedAt: string;
|
|
73
76
|
expiresAt: string | null;
|
|
74
|
-
|
|
75
|
-
tenantId: string;
|
|
76
|
-
agentId: string;
|
|
77
|
+
lastUsedAt: string | null;
|
|
77
78
|
publicId: string;
|
|
78
79
|
keyHash: string;
|
|
79
80
|
keyPrefix: string;
|
|
80
|
-
lastUsedAt: string | null;
|
|
81
81
|
}>;
|
|
82
82
|
declare const updateApiKey: (db: AgentsRunDatabaseClient) => (params: {
|
|
83
83
|
scopes: ProjectScopeConfig;
|
|
@@ -105,7 +105,10 @@ declare const hasApiKey: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
105
105
|
scopes: ProjectScopeConfig;
|
|
106
106
|
id: string;
|
|
107
107
|
}) => Promise<boolean>;
|
|
108
|
-
declare const updateApiKeyLastUsed: (db: AgentsRunDatabaseClient) => (
|
|
108
|
+
declare const updateApiKeyLastUsed: (db: AgentsRunDatabaseClient) => (params: {
|
|
109
|
+
id: string;
|
|
110
|
+
scopes: ProjectScopeConfig;
|
|
111
|
+
}) => Promise<void>;
|
|
109
112
|
declare const countApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
110
113
|
scopes: ProjectScopeConfig;
|
|
111
114
|
agentId?: string;
|
|
@@ -115,9 +118,6 @@ declare const countApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
115
118
|
* Returns both the API key record and the full key (which should be shown to the user only once)
|
|
116
119
|
*/
|
|
117
120
|
declare const generateAndCreateApiKey: (params: CreateApiKeyParams, db: AgentsRunDatabaseClient) => Promise<ApiKeyCreateResult>;
|
|
118
|
-
/**
|
|
119
|
-
* Validate an API key and return the associated record if valid
|
|
120
|
-
*/
|
|
121
121
|
declare const validateAndGetApiKey: (key: string, db: AgentsRunDatabaseClient) => Promise<ApiKeySelect | null>;
|
|
122
122
|
//#endregion
|
|
123
123
|
export { countApiKeys, createApiKey, deleteApiKey, generateAndCreateApiKey, getApiKeyById, getApiKeyByPublicId, hasApiKey, listApiKeys, listApiKeysPaginated, updateApiKey, updateApiKeyLastUsed, validateAndGetApiKey };
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { apiKeys } from "../../db/runtime/runtime-schema.js";
|
|
2
|
+
import { projectScopedWhere } from "../manage/scope-helpers.js";
|
|
2
3
|
import { extractPublicId, generateApiKey, isApiKeyExpired, validateApiKey } from "../../utils/apiKeys.js";
|
|
3
4
|
import { and, count, desc, eq } from "drizzle-orm";
|
|
4
5
|
|
|
5
6
|
//#region src/data-access/runtime/apiKeys.ts
|
|
6
7
|
const getApiKeyById = (db) => async (params) => {
|
|
7
|
-
return await db.query.apiKeys.findFirst({ where: and(
|
|
8
|
+
return await db.query.apiKeys.findFirst({ where: and(projectScopedWhere(apiKeys, params.scopes), eq(apiKeys.id, params.id)) });
|
|
8
9
|
};
|
|
9
10
|
const getApiKeyByPublicId = (db) => async (publicId) => {
|
|
10
11
|
return await db.query.apiKeys.findFirst({ where: eq(apiKeys.publicId, publicId) });
|
|
11
12
|
};
|
|
12
13
|
const listApiKeys = (db) => async (params) => {
|
|
13
|
-
const conditions = [
|
|
14
|
+
const conditions = [projectScopedWhere(apiKeys, params.scopes)];
|
|
14
15
|
if (params.agentId) conditions.push(eq(apiKeys.agentId, params.agentId));
|
|
15
16
|
return await db.query.apiKeys.findMany({
|
|
16
17
|
where: and(...conditions),
|
|
@@ -21,7 +22,7 @@ const listApiKeysPaginated = (db) => async (params) => {
|
|
|
21
22
|
const page = params.pagination?.page || 1;
|
|
22
23
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
23
24
|
const offset = (page - 1) * limit;
|
|
24
|
-
const conditions = [
|
|
25
|
+
const conditions = [projectScopedWhere(apiKeys, params.scopes)];
|
|
25
26
|
if (params.agentId) conditions.push(eq(apiKeys.agentId, params.agentId));
|
|
26
27
|
const whereClause = and(...conditions);
|
|
27
28
|
const [data, totalResult] = await Promise.all([db.select().from(apiKeys).where(whereClause).limit(limit).offset(offset).orderBy(desc(apiKeys.createdAt)), db.select({ count: count() }).from(apiKeys).where(whereClause)]);
|
|
@@ -60,7 +61,7 @@ const updateApiKey = (db) => async (params) => {
|
|
|
60
61
|
name: params.data.name,
|
|
61
62
|
expiresAt: params.data.expiresAt,
|
|
62
63
|
updatedAt: now
|
|
63
|
-
}).where(and(
|
|
64
|
+
}).where(and(projectScopedWhere(apiKeys, params.scopes), eq(apiKeys.id, params.id))).returning();
|
|
64
65
|
return updatedKey;
|
|
65
66
|
};
|
|
66
67
|
const deleteApiKey = (db) => async (params) => {
|
|
@@ -72,7 +73,7 @@ const deleteApiKey = (db) => async (params) => {
|
|
|
72
73
|
console.error("API key not found", { params });
|
|
73
74
|
return false;
|
|
74
75
|
}
|
|
75
|
-
await db.delete(apiKeys).where(and(
|
|
76
|
+
await db.delete(apiKeys).where(and(projectScopedWhere(apiKeys, params.scopes), eq(apiKeys.id, params.id)));
|
|
76
77
|
return true;
|
|
77
78
|
} catch (error) {
|
|
78
79
|
console.error("Error deleting API key:", error);
|
|
@@ -82,11 +83,11 @@ const deleteApiKey = (db) => async (params) => {
|
|
|
82
83
|
const hasApiKey = (db) => async (params) => {
|
|
83
84
|
return await getApiKeyById(db)(params) !== null;
|
|
84
85
|
};
|
|
85
|
-
const updateApiKeyLastUsed = (db) => async (
|
|
86
|
-
await db.update(apiKeys).set({ lastUsedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(eq(apiKeys.id, id));
|
|
86
|
+
const updateApiKeyLastUsed = (db) => async (params) => {
|
|
87
|
+
await db.update(apiKeys).set({ lastUsedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(and(projectScopedWhere(apiKeys, params.scopes), eq(apiKeys.id, params.id)));
|
|
87
88
|
};
|
|
88
89
|
const countApiKeys = (db) => async (params) => {
|
|
89
|
-
const conditions = [
|
|
90
|
+
const conditions = [projectScopedWhere(apiKeys, params.scopes)];
|
|
90
91
|
if (params.agentId) conditions.push(eq(apiKeys.agentId, params.agentId));
|
|
91
92
|
const total = (await db.select({ count: count() }).from(apiKeys).where(and(...conditions)))[0]?.count || 0;
|
|
92
93
|
return typeof total === "string" ? Number.parseInt(total, 10) : total;
|
|
@@ -110,9 +111,6 @@ const generateAndCreateApiKey = async (params, db) => {
|
|
|
110
111
|
key: keyData.key
|
|
111
112
|
};
|
|
112
113
|
};
|
|
113
|
-
/**
|
|
114
|
-
* Validate an API key and return the associated record if valid
|
|
115
|
-
*/
|
|
116
114
|
const validateAndGetApiKey = async (key, db) => {
|
|
117
115
|
const publicId = extractPublicId(key);
|
|
118
116
|
if (!publicId) return null;
|
|
@@ -120,7 +118,13 @@ const validateAndGetApiKey = async (key, db) => {
|
|
|
120
118
|
if (!apiKey) return null;
|
|
121
119
|
if (!await validateApiKey(key, apiKey.keyHash)) return null;
|
|
122
120
|
if (isApiKeyExpired(apiKey.expiresAt)) return null;
|
|
123
|
-
await updateApiKeyLastUsed(db)(
|
|
121
|
+
await updateApiKeyLastUsed(db)({
|
|
122
|
+
id: apiKey.id,
|
|
123
|
+
scopes: {
|
|
124
|
+
tenantId: apiKey.tenantId,
|
|
125
|
+
projectId: apiKey.projectId
|
|
126
|
+
}
|
|
127
|
+
});
|
|
124
128
|
return apiKey;
|
|
125
129
|
};
|
|
126
130
|
|
|
@@ -8,11 +8,11 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
|
|
|
8
8
|
type: AppType;
|
|
9
9
|
id: string;
|
|
10
10
|
name: string;
|
|
11
|
-
createdAt: string;
|
|
12
|
-
updatedAt: string;
|
|
13
11
|
description: string | null;
|
|
14
|
-
projectId: string | null;
|
|
15
12
|
tenantId: string | null;
|
|
13
|
+
projectId: string | null;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
16
|
enabled: boolean;
|
|
17
17
|
config: {
|
|
18
18
|
type: "web_client";
|
|
@@ -23,9 +23,9 @@ declare const getAppById: (db: AgentsRunDatabaseClient) => (id: string) => Promi
|
|
|
23
23
|
type: "api";
|
|
24
24
|
api: Record<string, never>;
|
|
25
25
|
};
|
|
26
|
-
lastUsedAt: string | null;
|
|
27
|
-
defaultProjectId: string | null;
|
|
28
26
|
defaultAgentId: string | null;
|
|
27
|
+
defaultProjectId: string | null;
|
|
28
|
+
lastUsedAt: string | null;
|
|
29
29
|
} | undefined>;
|
|
30
30
|
declare const updateAppLastUsed: (db: AgentsRunDatabaseClient) => (id: string) => Promise<void>;
|
|
31
31
|
declare const getAppByIdForTenant: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -51,11 +51,11 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
|
|
|
51
51
|
type: AppType;
|
|
52
52
|
id: string;
|
|
53
53
|
name: string;
|
|
54
|
-
createdAt: string;
|
|
55
|
-
updatedAt: string;
|
|
56
54
|
description: string | null;
|
|
57
|
-
projectId: string | null;
|
|
58
55
|
tenantId: string | null;
|
|
56
|
+
projectId: string | null;
|
|
57
|
+
createdAt: string;
|
|
58
|
+
updatedAt: string;
|
|
59
59
|
enabled: boolean;
|
|
60
60
|
config: {
|
|
61
61
|
type: "web_client";
|
|
@@ -66,9 +66,9 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
|
|
|
66
66
|
type: "api";
|
|
67
67
|
api: Record<string, never>;
|
|
68
68
|
};
|
|
69
|
-
lastUsedAt: string | null;
|
|
70
|
-
defaultProjectId: string | null;
|
|
71
69
|
defaultAgentId: string | null;
|
|
70
|
+
defaultProjectId: string | null;
|
|
71
|
+
lastUsedAt: string | null;
|
|
72
72
|
}>;
|
|
73
73
|
declare const updateAppForTenant: (db: AgentsRunDatabaseClient) => (params: {
|
|
74
74
|
scopes: TenantScopeConfig;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { apps } from "../../db/runtime/runtime-schema.js";
|
|
2
|
+
import { tenantScopedWhere } from "../manage/scope-helpers.js";
|
|
2
3
|
import { and, count, desc, eq } from "drizzle-orm";
|
|
3
4
|
|
|
4
5
|
//#region src/data-access/runtime/apps.ts
|
|
@@ -9,13 +10,13 @@ const updateAppLastUsed = (db) => async (id) => {
|
|
|
9
10
|
await db.update(apps).set({ lastUsedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(eq(apps.id, id));
|
|
10
11
|
};
|
|
11
12
|
const getAppByIdForTenant = (db) => async (params) => {
|
|
12
|
-
return db.query.apps.findFirst({ where: and(eq(apps.id, params.id),
|
|
13
|
+
return db.query.apps.findFirst({ where: and(eq(apps.id, params.id), tenantScopedWhere(apps, params.scopes)) });
|
|
13
14
|
};
|
|
14
15
|
const listAppsPaginated = (db) => async (params) => {
|
|
15
16
|
const page = params.pagination?.page || 1;
|
|
16
17
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
17
18
|
const offset = (page - 1) * limit;
|
|
18
|
-
const conditions = [
|
|
19
|
+
const conditions = [tenantScopedWhere(apps, params.scopes)];
|
|
19
20
|
if (params.scopes.projectId) conditions.push(eq(apps.projectId, params.scopes.projectId));
|
|
20
21
|
if (params.type) conditions.push(eq(apps.type, params.type));
|
|
21
22
|
const whereClause = and(...conditions);
|
|
@@ -46,27 +47,27 @@ const updateAppForTenant = (db) => async (params) => {
|
|
|
46
47
|
const [updatedApp] = await db.update(apps).set({
|
|
47
48
|
...params.data,
|
|
48
49
|
updatedAt: now
|
|
49
|
-
}).where(and(eq(apps.id, params.id),
|
|
50
|
+
}).where(and(eq(apps.id, params.id), tenantScopedWhere(apps, params.scopes))).returning();
|
|
50
51
|
return updatedApp;
|
|
51
52
|
};
|
|
52
53
|
const deleteAppForTenant = (db) => async (params) => {
|
|
53
|
-
return (await db.delete(apps).where(and(eq(apps.id, params.id),
|
|
54
|
+
return (await db.delete(apps).where(and(eq(apps.id, params.id), tenantScopedWhere(apps, params.scopes))).returning()).length > 0;
|
|
54
55
|
};
|
|
55
56
|
const deleteAppsByProject = (db) => async (tenantId, projectId) => {
|
|
56
|
-
return (await db.delete(apps).where(and(
|
|
57
|
+
return (await db.delete(apps).where(and(tenantScopedWhere(apps, { tenantId }), eq(apps.projectId, projectId))).returning()).length;
|
|
57
58
|
};
|
|
58
59
|
const clearAppDefaultsByProject = (db) => async (tenantId, projectId) => {
|
|
59
60
|
return (await db.update(apps).set({
|
|
60
61
|
defaultProjectId: null,
|
|
61
62
|
defaultAgentId: null,
|
|
62
63
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
63
|
-
}).where(and(
|
|
64
|
+
}).where(and(tenantScopedWhere(apps, { tenantId }), eq(apps.defaultProjectId, projectId))).returning()).length;
|
|
64
65
|
};
|
|
65
66
|
const clearAppDefaultsByAgent = (db) => async (tenantId, agentId) => {
|
|
66
67
|
return (await db.update(apps).set({
|
|
67
68
|
defaultAgentId: null,
|
|
68
69
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
69
|
-
}).where(and(
|
|
70
|
+
}).where(and(tenantScopedWhere(apps, { tenantId }), eq(apps.defaultAgentId, agentId))).returning()).length;
|
|
70
71
|
};
|
|
71
72
|
const updateApp = (db) => async (params) => {
|
|
72
73
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { apiKeys, contextCache, workAppGitHubMcpToolAccessMode, workAppGitHubMcpToolRepositoryAccess, workAppSlackChannelAgentConfigs, workAppSlackMcpToolAccessConfig } from "../../db/runtime/runtime-schema.js";
|
|
2
|
-
import {
|
|
2
|
+
import { projectScopedWhere } from "../manage/scope-helpers.js";
|
|
3
3
|
|
|
4
4
|
//#region src/data-access/runtime/audit-queries.ts
|
|
5
5
|
const listGitHubToolAccessByProject = (db) => async (params) => {
|
|
6
6
|
return db.select({
|
|
7
7
|
id: workAppGitHubMcpToolRepositoryAccess.id,
|
|
8
8
|
toolId: workAppGitHubMcpToolRepositoryAccess.toolId
|
|
9
|
-
}).from(workAppGitHubMcpToolRepositoryAccess).where(
|
|
9
|
+
}).from(workAppGitHubMcpToolRepositoryAccess).where(projectScopedWhere(workAppGitHubMcpToolRepositoryAccess, params.scopes));
|
|
10
10
|
};
|
|
11
11
|
const listGitHubToolAccessModeByProject = (db) => async (params) => {
|
|
12
|
-
return db.select({ toolId: workAppGitHubMcpToolAccessMode.toolId }).from(workAppGitHubMcpToolAccessMode).where(
|
|
12
|
+
return db.select({ toolId: workAppGitHubMcpToolAccessMode.toolId }).from(workAppGitHubMcpToolAccessMode).where(projectScopedWhere(workAppGitHubMcpToolAccessMode, params.scopes));
|
|
13
13
|
};
|
|
14
14
|
const listSlackToolAccessConfigByProject = (db) => async (params) => {
|
|
15
|
-
return db.select({ toolId: workAppSlackMcpToolAccessConfig.toolId }).from(workAppSlackMcpToolAccessConfig).where(
|
|
15
|
+
return db.select({ toolId: workAppSlackMcpToolAccessConfig.toolId }).from(workAppSlackMcpToolAccessConfig).where(projectScopedWhere(workAppSlackMcpToolAccessConfig, params.scopes));
|
|
16
16
|
};
|
|
17
17
|
const listContextCacheByProject = (db) => async (params) => {
|
|
18
18
|
return db.select({
|
|
19
19
|
id: contextCache.id,
|
|
20
20
|
contextConfigId: contextCache.contextConfigId
|
|
21
|
-
}).from(contextCache).where(
|
|
21
|
+
}).from(contextCache).where(projectScopedWhere(contextCache, params.scopes));
|
|
22
22
|
};
|
|
23
23
|
const listApiKeysByProject = (db) => async (params) => {
|
|
24
24
|
return db.select({
|
|
25
25
|
id: apiKeys.id,
|
|
26
26
|
agentId: apiKeys.agentId
|
|
27
|
-
}).from(apiKeys).where(
|
|
27
|
+
}).from(apiKeys).where(projectScopedWhere(apiKeys, params.scopes));
|
|
28
28
|
};
|
|
29
29
|
const listSlackChannelAgentConfigsByProject = (db) => async (params) => {
|
|
30
30
|
return db.select({
|
|
31
31
|
id: workAppSlackChannelAgentConfigs.id,
|
|
32
32
|
agentId: workAppSlackChannelAgentConfigs.agentId
|
|
33
|
-
}).from(workAppSlackChannelAgentConfigs).where(
|
|
33
|
+
}).from(workAppSlackChannelAgentConfigs).where(projectScopedWhere(workAppSlackChannelAgentConfigs, params.scopes));
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
|
|
2
|
+
|
|
3
|
+
//#region src/data-access/runtime/auth.d.ts
|
|
4
|
+
declare const getInitialOrganization: (db: AgentsRunDatabaseClient) => (userId: string) => Promise<{
|
|
5
|
+
id: string;
|
|
6
|
+
} | null>;
|
|
7
|
+
declare const queryHasCredentialAccount: (db: AgentsRunDatabaseClient) => (userId: string) => Promise<boolean>;
|
|
8
|
+
interface SSOProviderRegistration {
|
|
9
|
+
providerId: string;
|
|
10
|
+
issuer: string;
|
|
11
|
+
domain: string;
|
|
12
|
+
organizationId?: string;
|
|
13
|
+
oidcConfig?: object;
|
|
14
|
+
samlConfig?: object;
|
|
15
|
+
}
|
|
16
|
+
declare const registerSSOProvider: (db: AgentsRunDatabaseClient) => (provider: SSOProviderRegistration) => Promise<void>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { SSOProviderRegistration, getInitialOrganization, queryHasCredentialAccount, registerSSOProvider };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { account, member, ssoProvider } from "../../auth/auth-schema.js";
|
|
2
|
+
import { generateId } from "../../utils/conversations.js";
|
|
3
|
+
import "../../utils/index.js";
|
|
4
|
+
import { and, eq } from "drizzle-orm";
|
|
5
|
+
|
|
6
|
+
//#region src/data-access/runtime/auth.ts
|
|
7
|
+
const getInitialOrganization = (db) => async (userId) => {
|
|
8
|
+
const [membership] = await db.select({ organizationId: member.organizationId }).from(member).where(eq(member.userId, userId)).orderBy(member.createdAt).limit(1);
|
|
9
|
+
return membership ? { id: membership.organizationId } : null;
|
|
10
|
+
};
|
|
11
|
+
const queryHasCredentialAccount = (db) => async (userId) => {
|
|
12
|
+
const [row] = await db.select({ id: account.id }).from(account).where(and(eq(account.userId, userId), eq(account.providerId, "credential"))).limit(1);
|
|
13
|
+
return !!row;
|
|
14
|
+
};
|
|
15
|
+
const registerSSOProvider = (db) => async (provider) => {
|
|
16
|
+
try {
|
|
17
|
+
if ((await db.select().from(ssoProvider).where(eq(ssoProvider.providerId, provider.providerId)).limit(1)).length > 0) return;
|
|
18
|
+
if (!provider.domain) throw new Error(`SSO provider '${provider.providerId}' must have a domain`);
|
|
19
|
+
await db.insert(ssoProvider).values({
|
|
20
|
+
id: generateId(),
|
|
21
|
+
providerId: provider.providerId,
|
|
22
|
+
issuer: provider.issuer,
|
|
23
|
+
domain: provider.domain,
|
|
24
|
+
oidcConfig: provider.oidcConfig ? JSON.stringify(provider.oidcConfig) : null,
|
|
25
|
+
samlConfig: provider.samlConfig ? JSON.stringify(provider.samlConfig) : null,
|
|
26
|
+
userId: null,
|
|
27
|
+
organizationId: provider.organizationId || null
|
|
28
|
+
});
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error(`❌ Failed to register SSO provider '${provider.providerId}':`, error);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { getInitialOrganization, queryHasCredentialAccount, registerSSOProvider };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { apiKeys, contextCache, conversations, tasks, workAppGitHubMcpToolAccessMode, workAppGitHubMcpToolRepositoryAccess, workAppGitHubProjectAccessMode, workAppGitHubProjectRepositoryAccess } from "../../db/runtime/runtime-schema.js";
|
|
2
|
+
import { projectScopedWhere } from "../manage/scope-helpers.js";
|
|
2
3
|
import { clearAppDefaultsByAgent, clearAppDefaultsByProject, deleteAppsByProject } from "./apps.js";
|
|
3
4
|
import { deleteSlackMcpToolAccessConfig } from "./slack-work-app-mcp.js";
|
|
4
5
|
import { clearDevConfigWorkspaceDefaultsByAgent, clearDevConfigWorkspaceDefaultsByProject, clearWorkspaceDefaultsByAgent, clearWorkspaceDefaultsByProject, deleteWorkAppSlackChannelAgentConfigsByAgent, deleteWorkAppSlackChannelAgentConfigsByProject } from "./workAppSlack.js";
|
|
@@ -14,9 +15,9 @@ import { and, eq, inArray, sql } from "drizzle-orm";
|
|
|
14
15
|
*/
|
|
15
16
|
const cascadeDeleteByBranch = (db) => async (params) => {
|
|
16
17
|
const { scopes, fullBranchName } = params;
|
|
17
|
-
const contextCacheResult = await db.delete(contextCache).where(and(
|
|
18
|
-
const conversationsResult = await db.delete(conversations).where(and(
|
|
19
|
-
const tasksResult = await db.delete(tasks).where(and(
|
|
18
|
+
const contextCacheResult = await db.delete(contextCache).where(and(projectScopedWhere(contextCache, scopes), sql`${contextCache.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
19
|
+
const conversationsResult = await db.delete(conversations).where(and(projectScopedWhere(conversations, scopes), sql`${conversations.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
20
|
+
const tasksResult = await db.delete(tasks).where(and(projectScopedWhere(tasks, scopes), sql`${tasks.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
20
21
|
return {
|
|
21
22
|
conversationsDeleted: conversationsResult.length,
|
|
22
23
|
tasksDeleted: tasksResult.length,
|
|
@@ -38,10 +39,10 @@ const cascadeDeleteByBranch = (db) => async (params) => {
|
|
|
38
39
|
*/
|
|
39
40
|
const cascadeDeleteByProject = (db) => async (params) => {
|
|
40
41
|
const { scopes, fullBranchName } = params;
|
|
41
|
-
const contextCacheResult = await db.delete(contextCache).where(and(
|
|
42
|
-
const conversationsResult = await db.delete(conversations).where(and(
|
|
43
|
-
const tasksResult = await db.delete(tasks).where(and(
|
|
44
|
-
const apiKeysResult = await db.delete(apiKeys).where(
|
|
42
|
+
const contextCacheResult = await db.delete(contextCache).where(and(projectScopedWhere(contextCache, scopes), sql`${contextCache.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
43
|
+
const conversationsResult = await db.delete(conversations).where(and(projectScopedWhere(conversations, scopes), sql`${conversations.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
44
|
+
const tasksResult = await db.delete(tasks).where(and(projectScopedWhere(tasks, scopes), sql`${tasks.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
45
|
+
const apiKeysResult = await db.delete(apiKeys).where(projectScopedWhere(apiKeys, scopes)).returning();
|
|
45
46
|
await cascadeDeleteGitHubAccessByProject(db)({
|
|
46
47
|
tenantId: scopes.tenantId,
|
|
47
48
|
projectId: scopes.projectId
|
|
@@ -77,14 +78,14 @@ const cascadeDeleteByAgent = (db) => async (params) => {
|
|
|
77
78
|
let tasksDeleted = 0;
|
|
78
79
|
let apiKeysDeleted = 0;
|
|
79
80
|
if (subAgentIds.length > 0) {
|
|
80
|
-
const conversationIds = (await db.select({ id: conversations.id }).from(conversations).where(and(
|
|
81
|
+
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);
|
|
81
82
|
if (conversationIds.length > 0) {
|
|
82
|
-
contextCacheDeleted = (await db.delete(contextCache).where(and(
|
|
83
|
-
conversationsDeleted = (await db.delete(conversations).where(and(
|
|
83
|
+
contextCacheDeleted = (await db.delete(contextCache).where(and(projectScopedWhere(contextCache, scopes), inArray(contextCache.conversationId, conversationIds))).returning()).length;
|
|
84
|
+
conversationsDeleted = (await db.delete(conversations).where(and(projectScopedWhere(conversations, scopes), inArray(conversations.id, conversationIds))).returning()).length;
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
|
-
tasksDeleted = (await db.delete(tasks).where(and(
|
|
87
|
-
apiKeysDeleted = (await db.delete(apiKeys).where(and(
|
|
87
|
+
tasksDeleted = (await db.delete(tasks).where(and(projectScopedWhere(tasks, scopes), eq(tasks.agentId, scopes.agentId), sql`${tasks.ref}->>'name' = ${fullBranchName}`)).returning()).length;
|
|
88
|
+
apiKeysDeleted = (await db.delete(apiKeys).where(and(projectScopedWhere(apiKeys, scopes), eq(apiKeys.agentId, scopes.agentId))).returning()).length;
|
|
88
89
|
const appDefaultsCleared = await clearAppDefaultsByAgent(db)(scopes.tenantId, scopes.agentId);
|
|
89
90
|
const slackChannelConfigsDeleted = await deleteWorkAppSlackChannelAgentConfigsByAgent(db)(scopes.tenantId, scopes.projectId, scopes.agentId);
|
|
90
91
|
const slackWorkspaceDefaultsCleared = await clearWorkspaceDefaultsByAgent(db)(scopes.tenantId, scopes.projectId, scopes.agentId);
|
|
@@ -108,14 +109,14 @@ const cascadeDeleteByAgent = (db) => async (params) => {
|
|
|
108
109
|
*/
|
|
109
110
|
const cascadeDeleteBySubAgent = (db) => async (params) => {
|
|
110
111
|
const { scopes, subAgentId, fullBranchName } = params;
|
|
111
|
-
const conversationIds = (await db.select({ id: conversations.id }).from(conversations).where(and(
|
|
112
|
+
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);
|
|
112
113
|
let contextCacheDeleted = 0;
|
|
113
114
|
let conversationsDeleted = 0;
|
|
114
115
|
if (conversationIds.length > 0) {
|
|
115
|
-
contextCacheDeleted = (await db.delete(contextCache).where(and(
|
|
116
|
-
conversationsDeleted = (await db.delete(conversations).where(and(
|
|
116
|
+
contextCacheDeleted = (await db.delete(contextCache).where(and(projectScopedWhere(contextCache, scopes), inArray(contextCache.conversationId, conversationIds))).returning()).length;
|
|
117
|
+
conversationsDeleted = (await db.delete(conversations).where(and(projectScopedWhere(conversations, scopes), inArray(conversations.id, conversationIds))).returning()).length;
|
|
117
118
|
}
|
|
118
|
-
const tasksResult = await db.delete(tasks).where(and(
|
|
119
|
+
const tasksResult = await db.delete(tasks).where(and(projectScopedWhere(tasks, scopes), eq(tasks.subAgentId, subAgentId), sql`${tasks.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
119
120
|
return {
|
|
120
121
|
conversationsDeleted,
|
|
121
122
|
tasksDeleted: tasksResult.length,
|
|
@@ -136,7 +137,7 @@ const cascadeDeleteBySubAgent = (db) => async (params) => {
|
|
|
136
137
|
*/
|
|
137
138
|
const cascadeDeleteByContextConfig = (db) => async (params) => {
|
|
138
139
|
const { scopes, contextConfigId, fullBranchName } = params;
|
|
139
|
-
return { contextCacheDeleted: (await db.delete(contextCache).where(and(
|
|
140
|
+
return { contextCacheDeleted: (await db.delete(contextCache).where(and(projectScopedWhere(contextCache, scopes), eq(contextCache.contextConfigId, contextConfigId), sql`${contextCache.ref}->>'name' = ${fullBranchName}`)).returning()).length };
|
|
140
141
|
};
|
|
141
142
|
/**
|
|
142
143
|
* Delete all runtime entities for a specific MCP tool.
|
|
@@ -151,8 +152,12 @@ const cascadeDeleteByContextConfig = (db) => async (params) => {
|
|
|
151
152
|
*/
|
|
152
153
|
const cascadeDeleteByTool = (db) => async (params) => {
|
|
153
154
|
const { toolId, tenantId, projectId } = params;
|
|
154
|
-
const
|
|
155
|
-
|
|
155
|
+
const scopes = {
|
|
156
|
+
tenantId,
|
|
157
|
+
projectId
|
|
158
|
+
};
|
|
159
|
+
const repositoryAccessResult = await db.delete(workAppGitHubMcpToolRepositoryAccess).where(and(projectScopedWhere(workAppGitHubMcpToolRepositoryAccess, scopes), eq(workAppGitHubMcpToolRepositoryAccess.toolId, toolId))).returning();
|
|
160
|
+
const accessModeResult = await db.delete(workAppGitHubMcpToolAccessMode).where(and(projectScopedWhere(workAppGitHubMcpToolAccessMode, scopes), eq(workAppGitHubMcpToolAccessMode.toolId, toolId))).returning();
|
|
156
161
|
const slackMcpDeleted = await deleteSlackMcpToolAccessConfig(db)({
|
|
157
162
|
tenantId,
|
|
158
163
|
projectId,
|
|
@@ -178,11 +183,11 @@ const cascadeDeleteByTool = (db) => async (params) => {
|
|
|
178
183
|
* @returns Function that performs the cascade delete
|
|
179
184
|
*/
|
|
180
185
|
const cascadeDeleteGitHubAccessByProject = (db) => async (params) => {
|
|
181
|
-
const
|
|
182
|
-
const projectRepoAccessResult = await db.delete(workAppGitHubProjectRepositoryAccess).where(
|
|
183
|
-
const projectAccessModeResult = await db.delete(workAppGitHubProjectAccessMode).where(
|
|
184
|
-
const mcpToolRepoAccessResult = await db.delete(workAppGitHubMcpToolRepositoryAccess).where(
|
|
185
|
-
const mcpToolAccessModeResult = await db.delete(workAppGitHubMcpToolAccessMode).where(
|
|
186
|
+
const scopes = params;
|
|
187
|
+
const projectRepoAccessResult = await db.delete(workAppGitHubProjectRepositoryAccess).where(projectScopedWhere(workAppGitHubProjectRepositoryAccess, scopes)).returning();
|
|
188
|
+
const projectAccessModeResult = await db.delete(workAppGitHubProjectAccessMode).where(projectScopedWhere(workAppGitHubProjectAccessMode, scopes)).returning();
|
|
189
|
+
const mcpToolRepoAccessResult = await db.delete(workAppGitHubMcpToolRepositoryAccess).where(projectScopedWhere(workAppGitHubMcpToolRepositoryAccess, scopes)).returning();
|
|
190
|
+
const mcpToolAccessModeResult = await db.delete(workAppGitHubMcpToolAccessMode).where(projectScopedWhere(workAppGitHubMcpToolAccessMode, scopes)).returning();
|
|
186
191
|
return {
|
|
187
192
|
projectRepositoryAccessDeleted: projectRepoAccessResult.length,
|
|
188
193
|
projectAccessModeDeleted: projectAccessModeResult.length > 0,
|
|
@@ -12,6 +12,7 @@ declare const getCacheEntry: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
12
12
|
contextConfigId: string;
|
|
13
13
|
contextVariableKey: string;
|
|
14
14
|
requestHash?: string;
|
|
15
|
+
scopes: ProjectScopeConfig;
|
|
15
16
|
}) => Promise<ContextCacheSelect | null>;
|
|
16
17
|
/**
|
|
17
18
|
* Set cached context data for a conversation
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { contextCache } from "../../db/runtime/runtime-schema.js";
|
|
2
2
|
import { generateId } from "../../utils/conversations.js";
|
|
3
|
+
import { projectScopedWhere } from "../manage/scope-helpers.js";
|
|
3
4
|
import { and, eq } from "drizzle-orm";
|
|
4
5
|
|
|
5
6
|
//#region src/data-access/runtime/contextCache.ts
|
|
@@ -8,7 +9,7 @@ import { and, eq } from "drizzle-orm";
|
|
|
8
9
|
*/
|
|
9
10
|
const getCacheEntry = (db) => async (params) => {
|
|
10
11
|
try {
|
|
11
|
-
const cacheEntry = await db.query.contextCache.findFirst({ where: and(eq(contextCache.conversationId, params.conversationId), eq(contextCache.contextConfigId, params.contextConfigId), eq(contextCache.contextVariableKey, params.contextVariableKey)) });
|
|
12
|
+
const cacheEntry = await db.query.contextCache.findFirst({ where: and(projectScopedWhere(contextCache, params.scopes), eq(contextCache.conversationId, params.conversationId), eq(contextCache.contextConfigId, params.contextConfigId), eq(contextCache.contextVariableKey, params.contextVariableKey)) });
|
|
12
13
|
if (!cacheEntry) return null;
|
|
13
14
|
if (params.requestHash && cacheEntry.requestHash && cacheEntry.requestHash !== params.requestHash) return null;
|
|
14
15
|
return {
|
|
@@ -52,25 +53,25 @@ const setCacheEntry = (db) => async (entry) => {
|
|
|
52
53
|
* Clear cache entries for a specific conversation
|
|
53
54
|
*/
|
|
54
55
|
const clearConversationCache = (db) => async (params) => {
|
|
55
|
-
return (await db.delete(contextCache).where(and(
|
|
56
|
+
return (await db.delete(contextCache).where(and(projectScopedWhere(contextCache, params.scopes), eq(contextCache.conversationId, params.conversationId))).returning()).length;
|
|
56
57
|
};
|
|
57
58
|
/**
|
|
58
59
|
* Clear all cache entries for a specific context configuration
|
|
59
60
|
*/
|
|
60
61
|
const clearContextConfigCache = (db) => async (params) => {
|
|
61
|
-
return (await db.delete(contextCache).where(and(
|
|
62
|
+
return (await db.delete(contextCache).where(and(projectScopedWhere(contextCache, params.scopes), eq(contextCache.contextConfigId, params.contextConfigId))).returning()).length;
|
|
62
63
|
};
|
|
63
64
|
/**
|
|
64
65
|
* Clean up all cache entries for a tenant
|
|
65
66
|
*/
|
|
66
67
|
const cleanupTenantCache = (db) => async (params) => {
|
|
67
|
-
return (await db.delete(contextCache).where(
|
|
68
|
+
return (await db.delete(contextCache).where(projectScopedWhere(contextCache, params.scopes)).returning()).length;
|
|
68
69
|
};
|
|
69
70
|
/**
|
|
70
71
|
* Invalidate the headers cache for a conversation
|
|
71
72
|
*/
|
|
72
73
|
const invalidateHeadersCache = (db) => async (params) => {
|
|
73
|
-
return (await db.delete(contextCache).where(and(
|
|
74
|
+
return (await db.delete(contextCache).where(and(projectScopedWhere(contextCache, params.scopes), eq(contextCache.conversationId, params.conversationId), eq(contextCache.contextConfigId, params.contextConfigId), eq(contextCache.contextVariableKey, "headers"))).returning()).length;
|
|
74
75
|
};
|
|
75
76
|
/**
|
|
76
77
|
* Invalidate specific cache entries for invocation-trigger definitions
|
|
@@ -78,7 +79,7 @@ const invalidateHeadersCache = (db) => async (params) => {
|
|
|
78
79
|
const invalidateInvocationDefinitionsCache = (db) => async (params) => {
|
|
79
80
|
let totalRowsAffected = 0;
|
|
80
81
|
for (const definitionId of params.invocationDefinitionIds) {
|
|
81
|
-
const result = await db.delete(contextCache).where(and(
|
|
82
|
+
const result = await db.delete(contextCache).where(and(projectScopedWhere(contextCache, params.scopes), eq(contextCache.conversationId, params.conversationId), eq(contextCache.contextConfigId, params.contextConfigId), eq(contextCache.contextVariableKey, definitionId))).returning();
|
|
82
83
|
totalRowsAffected += result.length;
|
|
83
84
|
}
|
|
84
85
|
return totalRowsAffected;
|
|
@@ -87,7 +88,7 @@ const invalidateInvocationDefinitionsCache = (db) => async (params) => {
|
|
|
87
88
|
* Get all cache entries for a conversation
|
|
88
89
|
*/
|
|
89
90
|
const getConversationCacheEntries = (db) => async (params) => {
|
|
90
|
-
return (await db.query.contextCache.findMany({ where: and(
|
|
91
|
+
return (await db.query.contextCache.findMany({ where: and(projectScopedWhere(contextCache, params.scopes), eq(contextCache.conversationId, params.conversationId)) })).map((entry) => ({
|
|
91
92
|
...entry,
|
|
92
93
|
value: entry.value
|
|
93
94
|
}));
|
|
@@ -96,7 +97,7 @@ const getConversationCacheEntries = (db) => async (params) => {
|
|
|
96
97
|
* Get all cache entries for a context configuration
|
|
97
98
|
*/
|
|
98
99
|
const getContextConfigCacheEntries = (db) => async (params) => {
|
|
99
|
-
return (await db.query.contextCache.findMany({ where: and(
|
|
100
|
+
return (await db.query.contextCache.findMany({ where: and(projectScopedWhere(contextCache, params.scopes), eq(contextCache.contextConfigId, params.contextConfigId)) })).map((entry) => ({
|
|
100
101
|
...entry,
|
|
101
102
|
value: entry.value
|
|
102
103
|
}));
|