@inkeep/agents-core 0.58.19 → 0.58.21
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.d.ts +28 -28
- package/dist/auth/cookie-names.d.ts +7 -0
- package/dist/auth/cookie-names.js +13 -0
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/data-access/manage/skills.d.ts +1 -1
- package/dist/data-access/manage/tools.js +4 -2
- package/dist/data-access/manage/triggers.d.ts +2 -2
- package/dist/data-access/runtime/apiKeys.d.ts +4 -4
- package/dist/data-access/runtime/apps.d.ts +4 -4
- package/dist/data-access/runtime/cascade-delete.d.ts +4 -0
- package/dist/data-access/runtime/cascade-delete.js +27 -1
- package/dist/data-access/runtime/conversations.d.ts +7 -7
- package/dist/data-access/runtime/messages.d.ts +9 -9
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +15 -0
- package/dist/data-access/runtime/tasks.d.ts +2 -2
- package/dist/data-access/runtime/triggerInvocations.d.ts +5 -0
- package/dist/db/manage/manage-schema.d.ts +453 -453
- package/dist/db/runtime/runtime-schema.d.ts +440 -332
- package/dist/db/runtime/runtime-schema.js +4 -0
- package/dist/env.js +7 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/middleware/no-auth.d.ts +2 -2
- package/dist/utils/env-detection.d.ts +6 -0
- package/dist/utils/env-detection.js +13 -0
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/work-app-mcp.d.ts +8 -0
- package/dist/utils/work-app-mcp.js +18 -0
- package/dist/validation/dolt-schemas.d.ts +1 -1
- package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
- package/dist/validation/schemas.d.ts +1554 -3342
- package/dist/validation/schemas.js +7 -6
- package/drizzle/runtime/0023_bumpy_vampiro.sql +4 -0
- package/drizzle/runtime/meta/0023_snapshot.json +4264 -0
- package/drizzle/runtime/meta/_journal.json +7 -0
- package/package.json +9 -1
package/dist/auth/auth.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as zod0 from "zod";
|
|
|
4
4
|
import * as better_auth0 from "better-auth";
|
|
5
5
|
import { BetterAuthAdvancedOptions } from "better-auth";
|
|
6
6
|
import * as _better_auth_sso0 from "@better-auth/sso";
|
|
7
|
-
import * as
|
|
7
|
+
import * as better_auth_plugins0 from "better-auth/plugins";
|
|
8
8
|
import { GoogleOptions } from "better-auth/social-providers";
|
|
9
9
|
|
|
10
10
|
//#region src/auth/auth.d.ts
|
|
@@ -277,7 +277,7 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
277
277
|
handler: (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<void>;
|
|
278
278
|
}[];
|
|
279
279
|
};
|
|
280
|
-
options:
|
|
280
|
+
options: better_auth_plugins0.BearerOptions | undefined;
|
|
281
281
|
}, {
|
|
282
282
|
id: "sso";
|
|
283
283
|
endpoints: {
|
|
@@ -1268,30 +1268,30 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
1268
1268
|
handler: (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<void>;
|
|
1269
1269
|
}[];
|
|
1270
1270
|
};
|
|
1271
|
-
},
|
|
1271
|
+
}, better_auth_plugins0.DefaultOrganizationPlugin<{
|
|
1272
1272
|
allowUserToCreateOrganization: true;
|
|
1273
|
-
ac:
|
|
1273
|
+
ac: better_auth_plugins0.AccessControl;
|
|
1274
1274
|
roles: {
|
|
1275
1275
|
member: {
|
|
1276
|
-
authorize<K_1 extends "
|
|
1277
|
-
actions:
|
|
1276
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
|
|
1277
|
+
actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
|
|
1278
1278
|
connector: "OR" | "AND";
|
|
1279
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
1280
|
-
statements:
|
|
1279
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
1280
|
+
statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
|
|
1281
1281
|
};
|
|
1282
1282
|
admin: {
|
|
1283
|
-
authorize<K_1 extends "
|
|
1284
|
-
actions:
|
|
1283
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
|
|
1284
|
+
actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
|
|
1285
1285
|
connector: "OR" | "AND";
|
|
1286
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
1287
|
-
statements:
|
|
1286
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
1287
|
+
statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
|
|
1288
1288
|
};
|
|
1289
1289
|
owner: {
|
|
1290
|
-
authorize<K_1 extends "
|
|
1291
|
-
actions:
|
|
1290
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
|
|
1291
|
+
actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
|
|
1292
1292
|
connector: "OR" | "AND";
|
|
1293
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
1294
|
-
statements:
|
|
1293
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
1294
|
+
statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
|
|
1295
1295
|
};
|
|
1296
1296
|
};
|
|
1297
1297
|
creatorRole: "admin";
|
|
@@ -1302,9 +1302,9 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
1302
1302
|
id: string;
|
|
1303
1303
|
role: string;
|
|
1304
1304
|
email: string;
|
|
1305
|
-
organization:
|
|
1306
|
-
invitation:
|
|
1307
|
-
inviter:
|
|
1305
|
+
organization: better_auth_plugins0.Organization;
|
|
1306
|
+
invitation: better_auth_plugins0.Invitation;
|
|
1307
|
+
inviter: better_auth_plugins0.Member & {
|
|
1308
1308
|
user: better_auth0.User;
|
|
1309
1309
|
};
|
|
1310
1310
|
}): Promise<void>;
|
|
@@ -1339,28 +1339,28 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
1339
1339
|
user,
|
|
1340
1340
|
organization: org
|
|
1341
1341
|
}: {
|
|
1342
|
-
invitation:
|
|
1343
|
-
member:
|
|
1342
|
+
invitation: better_auth_plugins0.Invitation & Record<string, any>;
|
|
1343
|
+
member: better_auth_plugins0.Member & Record<string, any>;
|
|
1344
1344
|
user: better_auth0.User & Record<string, any>;
|
|
1345
|
-
organization:
|
|
1345
|
+
organization: better_auth_plugins0.Organization & Record<string, any>;
|
|
1346
1346
|
}) => Promise<void>;
|
|
1347
1347
|
beforeUpdateMemberRole: ({
|
|
1348
1348
|
member,
|
|
1349
1349
|
organization: org,
|
|
1350
1350
|
newRole
|
|
1351
1351
|
}: {
|
|
1352
|
-
member:
|
|
1352
|
+
member: better_auth_plugins0.Member & Record<string, any>;
|
|
1353
1353
|
newRole: string;
|
|
1354
1354
|
user: better_auth0.User & Record<string, any>;
|
|
1355
|
-
organization:
|
|
1355
|
+
organization: better_auth_plugins0.Organization & Record<string, any>;
|
|
1356
1356
|
}) => Promise<void>;
|
|
1357
1357
|
beforeRemoveMember: ({
|
|
1358
1358
|
member,
|
|
1359
1359
|
organization: org
|
|
1360
1360
|
}: {
|
|
1361
|
-
member:
|
|
1361
|
+
member: better_auth_plugins0.Member & Record<string, any>;
|
|
1362
1362
|
user: better_auth0.User & Record<string, any>;
|
|
1363
|
-
organization:
|
|
1363
|
+
organization: better_auth_plugins0.Organization & Record<string, any>;
|
|
1364
1364
|
}) => Promise<void>;
|
|
1365
1365
|
};
|
|
1366
1366
|
}>, {
|
|
@@ -1701,8 +1701,8 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
|
|
|
1701
1701
|
readonly AUTHENTICATION_REQUIRED: "Authentication required";
|
|
1702
1702
|
};
|
|
1703
1703
|
options: Partial<{
|
|
1704
|
-
expiresIn:
|
|
1705
|
-
interval:
|
|
1704
|
+
expiresIn: better_auth_plugins0.TimeString;
|
|
1705
|
+
interval: better_auth_plugins0.TimeString;
|
|
1706
1706
|
deviceCodeLength: number;
|
|
1707
1707
|
userCodeLength: number;
|
|
1708
1708
|
schema: {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/auth/cookie-names.d.ts
|
|
2
|
+
declare const AUTH_COOKIE_PREFIX = "better-auth";
|
|
3
|
+
declare const SESSION_COOKIE_NAME = "better-auth.session_token";
|
|
4
|
+
declare function isAuthCookie(cookieName: string): boolean;
|
|
5
|
+
declare function isSessionCookie(cookieName: string): boolean;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { AUTH_COOKIE_PREFIX, SESSION_COOKIE_NAME, isAuthCookie, isSessionCookie };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/auth/cookie-names.ts
|
|
2
|
+
const AUTH_COOKIE_PREFIX = "better-auth";
|
|
3
|
+
const SECURE_PREFIX = "__Secure-";
|
|
4
|
+
const SESSION_COOKIE_NAME = `${AUTH_COOKIE_PREFIX}.session_token`;
|
|
5
|
+
function isAuthCookie(cookieName) {
|
|
6
|
+
return cookieName.startsWith(AUTH_COOKIE_PREFIX) || cookieName.startsWith(`${SECURE_PREFIX}${AUTH_COOKIE_PREFIX}`);
|
|
7
|
+
}
|
|
8
|
+
function isSessionCookie(cookieName) {
|
|
9
|
+
return cookieName === SESSION_COOKIE_NAME || cookieName === `${SECURE_PREFIX}${SESSION_COOKIE_NAME}`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { AUTH_COOKIE_PREFIX, SESSION_COOKIE_NAME, isAuthCookie, isSessionCookie };
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as better_auth_plugins35 from "better-auth/plugins";
|
|
2
2
|
import { AccessControl } from "better-auth/plugins/access";
|
|
3
3
|
import { organizationClient } from "better-auth/client/plugins";
|
|
4
4
|
|
|
5
5
|
//#region src/auth/permissions.d.ts
|
|
6
6
|
declare const ac: AccessControl;
|
|
7
7
|
declare const memberRole: {
|
|
8
|
-
authorize<K_1 extends "
|
|
9
|
-
actions:
|
|
8
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>[key] | {
|
|
9
|
+
actions: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>[key];
|
|
10
10
|
connector: "OR" | "AND";
|
|
11
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
12
|
-
statements:
|
|
11
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins35.AuthorizeResponse;
|
|
12
|
+
statements: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>;
|
|
13
13
|
};
|
|
14
14
|
declare const adminRole: {
|
|
15
|
-
authorize<K_1 extends "
|
|
16
|
-
actions:
|
|
15
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>[key] | {
|
|
16
|
+
actions: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>[key];
|
|
17
17
|
connector: "OR" | "AND";
|
|
18
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
19
|
-
statements:
|
|
18
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins35.AuthorizeResponse;
|
|
19
|
+
statements: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>;
|
|
20
20
|
};
|
|
21
21
|
declare const ownerRole: {
|
|
22
|
-
authorize<K_1 extends "
|
|
23
|
-
actions:
|
|
22
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>[key] | {
|
|
23
|
+
actions: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>[key];
|
|
24
24
|
connector: "OR" | "AND";
|
|
25
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
26
|
-
statements:
|
|
25
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins35.AuthorizeResponse;
|
|
26
|
+
statements: better_auth_plugins35.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins35.Statements>;
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
29
|
export { ac, adminRole, memberRole, organizationClient, ownerRole };
|
|
@@ -99,8 +99,8 @@ declare const upsertSubAgentSkill: (db: AgentsManageDatabaseClient) => (params:
|
|
|
99
99
|
updatedAt: string;
|
|
100
100
|
index: number;
|
|
101
101
|
alwaysLoaded: boolean;
|
|
102
|
-
subAgentId: string;
|
|
103
102
|
skillId: string;
|
|
103
|
+
subAgentId: string;
|
|
104
104
|
}>;
|
|
105
105
|
declare const deleteSubAgentSkill: (db: AgentsManageDatabaseClient) => (params: {
|
|
106
106
|
scopes: AgentScopeConfig;
|
|
@@ -18,6 +18,7 @@ import { toISODateString } from "../../utils/date.js";
|
|
|
18
18
|
import { McpClient } from "../../utils/mcp-client.js";
|
|
19
19
|
import { configureComposioMCPServer } from "../../utils/third-party-mcp-servers/composio-client.js";
|
|
20
20
|
import { isThirdPartyMCPServerAuthenticated } from "../../utils/third-party-mcp-servers/third-party-check.js";
|
|
21
|
+
import { TRUSTED_WORK_APP_MCP_PATHS, isTrustedWorkAppMcpUrl } from "../../utils/work-app-mcp.js";
|
|
21
22
|
import "../../utils/index.js";
|
|
22
23
|
import { isGithubWorkAppTool } from "../runtime/github-work-app-installations.js";
|
|
23
24
|
import { getCredentialReference, getUserScopedCredentialReference } from "./credentialReferences.js";
|
|
@@ -122,14 +123,15 @@ const discoverToolsFromServer = async (tool, credentialReference, credentialStor
|
|
|
122
123
|
sessionId: tool.config.mcp.transport?.sessionId
|
|
123
124
|
};
|
|
124
125
|
configureComposioMCPServer(serverConfig, tool.tenantId, tool.projectId, tool.credentialScope === "user" ? "user" : "project", userId);
|
|
125
|
-
|
|
126
|
+
const urlString = String(serverConfig.url);
|
|
127
|
+
if (isGithubWorkAppTool(tool) && isTrustedWorkAppMcpUrl(urlString, TRUSTED_WORK_APP_MCP_PATHS.github, env.INKEEP_AGENTS_API_URL)) serverConfig.headers = {
|
|
126
128
|
...serverConfig.headers,
|
|
127
129
|
"x-inkeep-tool-id": tool.id,
|
|
128
130
|
"x-inkeep-tenant-id": tool.tenantId,
|
|
129
131
|
"x-inkeep-project-id": tool.projectId,
|
|
130
132
|
Authorization: `Bearer ${env.GITHUB_MCP_API_KEY}`
|
|
131
133
|
};
|
|
132
|
-
if (isSlackWorkAppTool(tool)) serverConfig.headers = {
|
|
134
|
+
if (isSlackWorkAppTool(tool) && isTrustedWorkAppMcpUrl(urlString, TRUSTED_WORK_APP_MCP_PATHS.slack, env.INKEEP_AGENTS_API_URL)) serverConfig.headers = {
|
|
133
135
|
...serverConfig.headers,
|
|
134
136
|
"x-inkeep-tool-id": tool.id,
|
|
135
137
|
"x-inkeep-tenant-id": tool.tenantId,
|
|
@@ -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" | "body" | "header";
|
|
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" | "body" | "header";
|
|
50
50
|
required: boolean;
|
|
51
51
|
key?: string | undefined;
|
|
52
52
|
value?: string | undefined;
|
|
@@ -16,10 +16,10 @@ declare const getApiKeyById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
16
16
|
createdAt: string;
|
|
17
17
|
updatedAt: string;
|
|
18
18
|
expiresAt: string | null;
|
|
19
|
-
lastUsedAt: string | null;
|
|
20
19
|
publicId: string;
|
|
21
20
|
keyHash: string;
|
|
22
21
|
keyPrefix: string;
|
|
22
|
+
lastUsedAt: string | null;
|
|
23
23
|
} | undefined>;
|
|
24
24
|
declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: string) => Promise<{
|
|
25
25
|
id: string;
|
|
@@ -30,10 +30,10 @@ declare const getApiKeyByPublicId: (db: AgentsRunDatabaseClient) => (publicId: s
|
|
|
30
30
|
createdAt: string;
|
|
31
31
|
updatedAt: string;
|
|
32
32
|
expiresAt: string | null;
|
|
33
|
-
lastUsedAt: string | null;
|
|
34
33
|
publicId: string;
|
|
35
34
|
keyHash: string;
|
|
36
35
|
keyPrefix: string;
|
|
36
|
+
lastUsedAt: string | null;
|
|
37
37
|
} | undefined>;
|
|
38
38
|
declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
39
39
|
scopes: ProjectScopeConfig;
|
|
@@ -47,10 +47,10 @@ declare const listApiKeys: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
47
47
|
createdAt: string;
|
|
48
48
|
updatedAt: string;
|
|
49
49
|
expiresAt: string | null;
|
|
50
|
-
lastUsedAt: string | null;
|
|
51
50
|
publicId: string;
|
|
52
51
|
keyHash: string;
|
|
53
52
|
keyPrefix: string;
|
|
53
|
+
lastUsedAt: string | null;
|
|
54
54
|
}[]>;
|
|
55
55
|
declare const listApiKeysPaginated: (db: AgentsRunDatabaseClient) => (params: {
|
|
56
56
|
scopes: ProjectScopeConfig;
|
|
@@ -74,10 +74,10 @@ declare const createApiKey: (db: AgentsRunDatabaseClient) => (params: ApiKeyInse
|
|
|
74
74
|
createdAt: string;
|
|
75
75
|
updatedAt: string;
|
|
76
76
|
expiresAt: string | null;
|
|
77
|
-
lastUsedAt: string | null;
|
|
78
77
|
publicId: string;
|
|
79
78
|
keyHash: string;
|
|
80
79
|
keyPrefix: string;
|
|
80
|
+
lastUsedAt: string | null;
|
|
81
81
|
}>;
|
|
82
82
|
declare const updateApiKey: (db: AgentsRunDatabaseClient) => (params: {
|
|
83
83
|
scopes: ProjectScopeConfig;
|
|
@@ -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
|
-
defaultAgentId: string | null;
|
|
27
|
-
defaultProjectId: string | null;
|
|
28
26
|
lastUsedAt: string | null;
|
|
27
|
+
defaultProjectId: string | null;
|
|
28
|
+
defaultAgentId: string | null;
|
|
29
29
|
} | undefined>;
|
|
30
30
|
declare const updateAppLastUsed: (db: AgentsRunDatabaseClient) => (id: string) => Promise<void>;
|
|
31
31
|
declare const getAppByIdForTenant: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -70,9 +70,9 @@ declare const createApp: (db: AgentsRunDatabaseClient) => (params: AppInsert) =>
|
|
|
70
70
|
type: "api";
|
|
71
71
|
api: Record<string, never>;
|
|
72
72
|
};
|
|
73
|
-
defaultAgentId: string | null;
|
|
74
|
-
defaultProjectId: string | null;
|
|
75
73
|
lastUsedAt: string | null;
|
|
74
|
+
defaultProjectId: string | null;
|
|
75
|
+
defaultAgentId: string | null;
|
|
76
76
|
}>;
|
|
77
77
|
declare const updateAppForTenant: (db: AgentsRunDatabaseClient) => (params: {
|
|
78
78
|
scopes: TenantScopeConfig;
|
|
@@ -10,6 +10,10 @@ type CascadeDeleteResult = {
|
|
|
10
10
|
conversationsDeleted: number;
|
|
11
11
|
tasksDeleted: number;
|
|
12
12
|
contextCacheDeleted: number;
|
|
13
|
+
triggerInvocationsDeleted: number;
|
|
14
|
+
scheduledTriggerInvocationsDeleted: number;
|
|
15
|
+
datasetRunsDeleted: number;
|
|
16
|
+
evaluationRunsDeleted: number;
|
|
13
17
|
apiKeysDeleted: number;
|
|
14
18
|
slackChannelConfigsDeleted: number;
|
|
15
19
|
slackWorkspaceDefaultsCleared: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { apiKeys, contextCache, conversations, tasks, workAppGitHubMcpToolAccessMode, workAppGitHubMcpToolRepositoryAccess, workAppGitHubProjectAccessMode, workAppGitHubProjectRepositoryAccess } from "../../db/runtime/runtime-schema.js";
|
|
1
|
+
import { apiKeys, contextCache, conversations, datasetRun, evaluationRun, scheduledTriggerInvocations, tasks, triggerInvocations, workAppGitHubMcpToolAccessMode, workAppGitHubMcpToolRepositoryAccess, workAppGitHubProjectAccessMode, workAppGitHubProjectRepositoryAccess } from "../../db/runtime/runtime-schema.js";
|
|
2
2
|
import { projectScopedWhere } from "../manage/scope-helpers.js";
|
|
3
3
|
import { clearAppDefaultsByAgent, clearAppDefaultsByProject, deleteAppsByProject } from "./apps.js";
|
|
4
4
|
import { deleteSlackMcpToolAccessConfig } from "./slack-work-app-mcp.js";
|
|
@@ -18,10 +18,18 @@ const cascadeDeleteByBranch = (db) => async (params) => {
|
|
|
18
18
|
const contextCacheResult = await db.delete(contextCache).where(and(projectScopedWhere(contextCache, scopes), sql`${contextCache.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
19
19
|
const conversationsResult = await db.delete(conversations).where(and(projectScopedWhere(conversations, scopes), sql`${conversations.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
20
20
|
const tasksResult = await db.delete(tasks).where(and(projectScopedWhere(tasks, scopes), sql`${tasks.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
21
|
+
const triggerInvocationsResult = await db.delete(triggerInvocations).where(and(eq(triggerInvocations.tenantId, scopes.tenantId), eq(triggerInvocations.projectId, scopes.projectId), sql`${triggerInvocations.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
22
|
+
const scheduledTriggerInvocationsResult = await db.delete(scheduledTriggerInvocations).where(and(eq(scheduledTriggerInvocations.tenantId, scopes.tenantId), eq(scheduledTriggerInvocations.projectId, scopes.projectId), sql`${scheduledTriggerInvocations.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
23
|
+
const datasetRunsResult = await db.delete(datasetRun).where(and(eq(datasetRun.tenantId, scopes.tenantId), eq(datasetRun.projectId, scopes.projectId), sql`${datasetRun.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
24
|
+
const evaluationRunsResult = await db.delete(evaluationRun).where(and(eq(evaluationRun.tenantId, scopes.tenantId), eq(evaluationRun.projectId, scopes.projectId), sql`${evaluationRun.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
21
25
|
return {
|
|
22
26
|
conversationsDeleted: conversationsResult.length,
|
|
23
27
|
tasksDeleted: tasksResult.length,
|
|
24
28
|
contextCacheDeleted: contextCacheResult.length,
|
|
29
|
+
triggerInvocationsDeleted: triggerInvocationsResult.length,
|
|
30
|
+
scheduledTriggerInvocationsDeleted: scheduledTriggerInvocationsResult.length,
|
|
31
|
+
datasetRunsDeleted: datasetRunsResult.length,
|
|
32
|
+
evaluationRunsDeleted: evaluationRunsResult.length,
|
|
25
33
|
apiKeysDeleted: 0,
|
|
26
34
|
slackChannelConfigsDeleted: 0,
|
|
27
35
|
slackWorkspaceDefaultsCleared: 0,
|
|
@@ -42,6 +50,10 @@ const cascadeDeleteByProject = (db) => async (params) => {
|
|
|
42
50
|
const contextCacheResult = await db.delete(contextCache).where(and(projectScopedWhere(contextCache, scopes), sql`${contextCache.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
43
51
|
const conversationsResult = await db.delete(conversations).where(and(projectScopedWhere(conversations, scopes), sql`${conversations.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
44
52
|
const tasksResult = await db.delete(tasks).where(and(projectScopedWhere(tasks, scopes), sql`${tasks.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
53
|
+
const triggerInvocationsResult = await db.delete(triggerInvocations).where(and(eq(triggerInvocations.tenantId, scopes.tenantId), eq(triggerInvocations.projectId, scopes.projectId), sql`${triggerInvocations.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
54
|
+
const scheduledTriggerInvocationsResult = await db.delete(scheduledTriggerInvocations).where(and(eq(scheduledTriggerInvocations.tenantId, scopes.tenantId), eq(scheduledTriggerInvocations.projectId, scopes.projectId), sql`${scheduledTriggerInvocations.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
55
|
+
const datasetRunsResult = await db.delete(datasetRun).where(and(eq(datasetRun.tenantId, scopes.tenantId), eq(datasetRun.projectId, scopes.projectId), sql`${datasetRun.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
56
|
+
const evaluationRunsResult = await db.delete(evaluationRun).where(and(eq(evaluationRun.tenantId, scopes.tenantId), eq(evaluationRun.projectId, scopes.projectId), sql`${evaluationRun.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
45
57
|
const apiKeysResult = await db.delete(apiKeys).where(projectScopedWhere(apiKeys, scopes)).returning();
|
|
46
58
|
await cascadeDeleteGitHubAccessByProject(db)({
|
|
47
59
|
tenantId: scopes.tenantId,
|
|
@@ -56,6 +68,10 @@ const cascadeDeleteByProject = (db) => async (params) => {
|
|
|
56
68
|
conversationsDeleted: conversationsResult.length,
|
|
57
69
|
tasksDeleted: tasksResult.length,
|
|
58
70
|
contextCacheDeleted: contextCacheResult.length,
|
|
71
|
+
triggerInvocationsDeleted: triggerInvocationsResult.length,
|
|
72
|
+
scheduledTriggerInvocationsDeleted: scheduledTriggerInvocationsResult.length,
|
|
73
|
+
datasetRunsDeleted: datasetRunsResult.length,
|
|
74
|
+
evaluationRunsDeleted: evaluationRunsResult.length,
|
|
59
75
|
apiKeysDeleted: apiKeysResult.length,
|
|
60
76
|
slackChannelConfigsDeleted,
|
|
61
77
|
slackWorkspaceDefaultsCleared,
|
|
@@ -85,6 +101,8 @@ const cascadeDeleteByAgent = (db) => async (params) => {
|
|
|
85
101
|
}
|
|
86
102
|
}
|
|
87
103
|
tasksDeleted = (await db.delete(tasks).where(and(projectScopedWhere(tasks, scopes), eq(tasks.agentId, scopes.agentId), sql`${tasks.ref}->>'name' = ${fullBranchName}`)).returning()).length;
|
|
104
|
+
const triggerInvocationsResult = await db.delete(triggerInvocations).where(and(eq(triggerInvocations.tenantId, scopes.tenantId), eq(triggerInvocations.projectId, scopes.projectId), eq(triggerInvocations.agentId, scopes.agentId), sql`${triggerInvocations.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
105
|
+
const scheduledTriggerInvocationsResult = await db.delete(scheduledTriggerInvocations).where(and(eq(scheduledTriggerInvocations.tenantId, scopes.tenantId), eq(scheduledTriggerInvocations.projectId, scopes.projectId), eq(scheduledTriggerInvocations.agentId, scopes.agentId), sql`${scheduledTriggerInvocations.ref}->>'name' = ${fullBranchName}`)).returning();
|
|
88
106
|
apiKeysDeleted = (await db.delete(apiKeys).where(and(projectScopedWhere(apiKeys, scopes), eq(apiKeys.agentId, scopes.agentId))).returning()).length;
|
|
89
107
|
const appDefaultsCleared = await clearAppDefaultsByAgent(db)(scopes.tenantId, scopes.agentId);
|
|
90
108
|
const slackChannelConfigsDeleted = await deleteWorkAppSlackChannelAgentConfigsByAgent(db)(scopes.tenantId, scopes.projectId, scopes.agentId);
|
|
@@ -94,6 +112,10 @@ const cascadeDeleteByAgent = (db) => async (params) => {
|
|
|
94
112
|
conversationsDeleted,
|
|
95
113
|
tasksDeleted,
|
|
96
114
|
contextCacheDeleted,
|
|
115
|
+
triggerInvocationsDeleted: triggerInvocationsResult.length,
|
|
116
|
+
scheduledTriggerInvocationsDeleted: scheduledTriggerInvocationsResult.length,
|
|
117
|
+
datasetRunsDeleted: 0,
|
|
118
|
+
evaluationRunsDeleted: 0,
|
|
97
119
|
apiKeysDeleted,
|
|
98
120
|
slackChannelConfigsDeleted,
|
|
99
121
|
slackWorkspaceDefaultsCleared,
|
|
@@ -121,6 +143,10 @@ const cascadeDeleteBySubAgent = (db) => async (params) => {
|
|
|
121
143
|
conversationsDeleted,
|
|
122
144
|
tasksDeleted: tasksResult.length,
|
|
123
145
|
contextCacheDeleted,
|
|
146
|
+
triggerInvocationsDeleted: 0,
|
|
147
|
+
scheduledTriggerInvocationsDeleted: 0,
|
|
148
|
+
datasetRunsDeleted: 0,
|
|
149
|
+
evaluationRunsDeleted: 0,
|
|
124
150
|
apiKeysDeleted: 0,
|
|
125
151
|
slackChannelConfigsDeleted: 0,
|
|
126
152
|
slackWorkspaceDefaultsCleared: 0,
|
|
@@ -25,7 +25,7 @@ declare const createConversation: (db: AgentsRunDatabaseClient) => (params: Conv
|
|
|
25
25
|
updatedAt: string;
|
|
26
26
|
metadata: ConversationMetadata | null;
|
|
27
27
|
ref: {
|
|
28
|
-
type: "
|
|
28
|
+
type: "commit" | "tag" | "branch";
|
|
29
29
|
name: string;
|
|
30
30
|
hash: string;
|
|
31
31
|
} | null;
|
|
@@ -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;
|
|
@@ -94,7 +94,7 @@ declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
94
94
|
updatedAt: string;
|
|
95
95
|
metadata: ConversationMetadata | null;
|
|
96
96
|
ref: {
|
|
97
|
-
type: "
|
|
97
|
+
type: "commit" | "tag" | "branch";
|
|
98
98
|
name: string;
|
|
99
99
|
hash: string;
|
|
100
100
|
} | null;
|
|
@@ -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
|
};
|
|
@@ -130,7 +130,7 @@ declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input:
|
|
|
130
130
|
updatedAt: string;
|
|
131
131
|
metadata: ConversationMetadata | null;
|
|
132
132
|
ref: {
|
|
133
|
-
type: "
|
|
133
|
+
type: "commit" | "tag" | "branch";
|
|
134
134
|
name: string;
|
|
135
135
|
hash: string;
|
|
136
136
|
} | null;
|
|
@@ -162,7 +162,7 @@ declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (p
|
|
|
162
162
|
updatedAt: string;
|
|
163
163
|
metadata: ConversationMetadata | null;
|
|
164
164
|
ref: {
|
|
165
|
-
type: "
|
|
165
|
+
type: "commit" | "tag" | "branch";
|
|
166
166
|
name: string;
|
|
167
167
|
hash: string;
|
|
168
168
|
} | null;
|
|
@@ -18,18 +18,18 @@ declare const getMessageById: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
18
18
|
metadata: MessageMetadata | null;
|
|
19
19
|
content: MessageContent;
|
|
20
20
|
role: string;
|
|
21
|
+
conversationId: string;
|
|
21
22
|
fromSubAgentId: string | null;
|
|
22
23
|
toSubAgentId: string | null;
|
|
23
24
|
fromExternalAgentId: string | null;
|
|
24
25
|
toExternalAgentId: string | null;
|
|
25
|
-
taskId: string | null;
|
|
26
|
-
a2aTaskId: string | null;
|
|
27
|
-
conversationId: 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: {
|
|
@@ -152,18 +152,18 @@ declare const createMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
152
152
|
metadata: MessageMetadata | null;
|
|
153
153
|
content: MessageContent;
|
|
154
154
|
role: string;
|
|
155
|
+
conversationId: string;
|
|
155
156
|
fromSubAgentId: string | null;
|
|
156
157
|
toSubAgentId: string | null;
|
|
157
158
|
fromExternalAgentId: string | null;
|
|
158
159
|
toExternalAgentId: string | null;
|
|
159
|
-
taskId: string | null;
|
|
160
|
-
a2aTaskId: string | null;
|
|
161
|
-
conversationId: string;
|
|
162
160
|
fromTeamAgentId: string | null;
|
|
163
161
|
toTeamAgentId: string | null;
|
|
164
162
|
visibility: string;
|
|
165
163
|
messageType: string;
|
|
164
|
+
taskId: string | null;
|
|
166
165
|
parentMessageId: string | null;
|
|
166
|
+
a2aTaskId: string | null;
|
|
167
167
|
a2aSessionId: string | null;
|
|
168
168
|
}>;
|
|
169
169
|
declare const updateMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -205,18 +205,18 @@ declare const deleteMessage: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
205
205
|
metadata: MessageMetadata | null;
|
|
206
206
|
content: MessageContent;
|
|
207
207
|
role: string;
|
|
208
|
+
conversationId: string;
|
|
208
209
|
fromSubAgentId: string | null;
|
|
209
210
|
toSubAgentId: string | null;
|
|
210
211
|
fromExternalAgentId: string | null;
|
|
211
212
|
toExternalAgentId: string | null;
|
|
212
|
-
taskId: string | null;
|
|
213
|
-
a2aTaskId: string | null;
|
|
214
|
-
conversationId: string;
|
|
215
213
|
fromTeamAgentId: string | null;
|
|
216
214
|
toTeamAgentId: string | null;
|
|
217
215
|
visibility: string;
|
|
218
216
|
messageType: string;
|
|
217
|
+
taskId: string | null;
|
|
219
218
|
parentMessageId: string | null;
|
|
219
|
+
a2aTaskId: string | null;
|
|
220
220
|
a2aSessionId: string | null;
|
|
221
221
|
}>;
|
|
222
222
|
declare const countMessagesByConversation: (db: AgentsRunDatabaseClient) => (params: {
|
|
@@ -34,6 +34,11 @@ declare const listScheduledTriggerInvocationsPaginated: (db: AgentsRunDatabaseCl
|
|
|
34
34
|
}) => Promise<{
|
|
35
35
|
data: {
|
|
36
36
|
scheduledTriggerId: string;
|
|
37
|
+
ref: {
|
|
38
|
+
type: "commit" | "tag" | "branch";
|
|
39
|
+
name: string;
|
|
40
|
+
hash: string;
|
|
41
|
+
} | null;
|
|
37
42
|
status: "pending" | "failed" | "running" | "completed" | "cancelled";
|
|
38
43
|
scheduledFor: string;
|
|
39
44
|
startedAt: string | null;
|
|
@@ -174,6 +179,11 @@ declare const listUpcomingInvocationsForAgentPaginated: (db: AgentsRunDatabaseCl
|
|
|
174
179
|
}) => Promise<{
|
|
175
180
|
data: {
|
|
176
181
|
scheduledTriggerId: string;
|
|
182
|
+
ref: {
|
|
183
|
+
type: "commit" | "tag" | "branch";
|
|
184
|
+
name: string;
|
|
185
|
+
hash: string;
|
|
186
|
+
} | null;
|
|
177
187
|
status: "pending" | "failed" | "running" | "completed" | "cancelled";
|
|
178
188
|
scheduledFor: string;
|
|
179
189
|
startedAt: string | null;
|
|
@@ -208,6 +218,11 @@ declare const listProjectScheduledTriggerInvocationsPaginated: (db: AgentsRunDat
|
|
|
208
218
|
}) => Promise<{
|
|
209
219
|
data: {
|
|
210
220
|
scheduledTriggerId: string;
|
|
221
|
+
ref: {
|
|
222
|
+
type: "commit" | "tag" | "branch";
|
|
223
|
+
name: string;
|
|
224
|
+
hash: string;
|
|
225
|
+
} | null;
|
|
211
226
|
status: "pending" | "failed" | "running" | "completed" | "cancelled";
|
|
212
227
|
scheduledFor: string;
|
|
213
228
|
startedAt: string | null;
|
|
@@ -15,7 +15,7 @@ declare const createTask: (db: AgentsRunDatabaseClient) => (params: TaskInsert)
|
|
|
15
15
|
updatedAt: string;
|
|
16
16
|
metadata: TaskMetadataConfig | null;
|
|
17
17
|
ref: {
|
|
18
|
-
type: "
|
|
18
|
+
type: "commit" | "tag" | "branch";
|
|
19
19
|
name: string;
|
|
20
20
|
hash: string;
|
|
21
21
|
} | null;
|
|
@@ -39,7 +39,7 @@ declare const updateTask: (db: AgentsRunDatabaseClient) => (params: {
|
|
|
39
39
|
updatedAt: string;
|
|
40
40
|
contextId: string;
|
|
41
41
|
ref: {
|
|
42
|
-
type: "
|
|
42
|
+
type: "commit" | "tag" | "branch";
|
|
43
43
|
name: string;
|
|
44
44
|
hash: string;
|
|
45
45
|
} | null;
|
|
@@ -28,6 +28,11 @@ declare const listTriggerInvocationsPaginated: (db: AgentsRunDatabaseClient) =>
|
|
|
28
28
|
data: {
|
|
29
29
|
triggerId: string;
|
|
30
30
|
conversationId: string | null;
|
|
31
|
+
ref: {
|
|
32
|
+
type: "commit" | "tag" | "branch";
|
|
33
|
+
name: string;
|
|
34
|
+
hash: string;
|
|
35
|
+
} | null;
|
|
31
36
|
status: string;
|
|
32
37
|
requestPayload: unknown;
|
|
33
38
|
transformedPayload: unknown;
|