@inkeep/agents-core 0.50.1 → 0.50.4
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 +105 -105
- package/dist/auth/auth-validation-schemas.d.ts +148 -148
- package/dist/auth/auth.d.ts +24 -24
- package/dist/auth/auth.js +8 -9
- package/dist/auth/authz/sync.d.ts +22 -1
- package/dist/auth/authz/sync.js +59 -4
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/constants/models.d.ts +1 -0
- package/dist/constants/models.js +1 -0
- package/dist/constants/otel-attributes.d.ts +4 -0
- package/dist/constants/otel-attributes.js +4 -0
- package/dist/data-access/manage/agents.d.ts +43 -43
- package/dist/data-access/manage/artifactComponents.d.ts +12 -12
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- package/dist/data-access/manage/dataComponents.d.ts +6 -6
- package/dist/data-access/manage/functionTools.d.ts +18 -18
- package/dist/data-access/manage/scope-helpers.d.ts +25 -0
- package/dist/data-access/manage/scope-helpers.js +18 -0
- package/dist/data-access/manage/skills.d.ts +14 -14
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgentExternalAgentRelations.js +13 -12
- package/dist/data-access/manage/subAgentRelations.d.ts +20 -20
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgents.d.ts +21 -21
- package/dist/data-access/manage/tools.d.ts +24 -24
- package/dist/data-access/manage/triggers.d.ts +2 -2
- package/dist/data-access/runtime/apiKeys.d.ts +16 -16
- package/dist/data-access/runtime/conversations.d.ts +31 -31
- package/dist/data-access/runtime/messages.d.ts +18 -18
- package/dist/data-access/runtime/tasks.d.ts +9 -9
- package/dist/data-access/runtime/workAppSlack.js +1 -0
- package/dist/db/manage/manage-schema.d.ts +449 -449
- package/dist/db/runtime/runtime-schema.d.ts +313 -296
- package/dist/db/runtime/runtime-schema.js +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/middleware/authz-meta.d.ts +15 -0
- package/dist/middleware/authz-meta.js +11 -0
- package/dist/middleware/create-protected-route.d.ts +30 -0
- package/dist/middleware/create-protected-route.js +20 -0
- package/dist/middleware/index.d.ts +5 -0
- package/dist/middleware/index.js +6 -0
- package/dist/middleware/inherited-auth.d.ts +43 -0
- package/dist/middleware/inherited-auth.js +50 -0
- package/dist/middleware/no-auth.d.ts +6 -0
- package/dist/middleware/no-auth.js +11 -0
- package/dist/types/utility.d.ts +6 -0
- package/dist/utils/in-process-fetch.d.ts +30 -0
- package/dist/utils/in-process-fetch.js +51 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/slack-user-token.d.ts +11 -0
- package/dist/utils/slack-user-token.js +11 -3
- 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 +1867 -1867
- package/drizzle/runtime/0014_odd_oracle.sql +1 -0
- package/drizzle/runtime/meta/0014_snapshot.json +3753 -0
- package/drizzle/runtime/meta/_journal.json +7 -0
- package/package.json +5 -1
|
@@ -9,25 +9,25 @@ declare const getContextConfigById: (db: AgentsManageDatabaseClient) => (params:
|
|
|
9
9
|
id: string;
|
|
10
10
|
}) => Promise<{
|
|
11
11
|
id: string;
|
|
12
|
-
tenantId: string;
|
|
13
|
-
projectId: string;
|
|
14
|
-
agentId: string;
|
|
15
12
|
createdAt: string;
|
|
16
13
|
updatedAt: string;
|
|
17
14
|
headersSchema: unknown;
|
|
18
15
|
contextVariables: Record<string, ContextFetchDefinition> | null;
|
|
16
|
+
agentId: string;
|
|
17
|
+
projectId: string;
|
|
18
|
+
tenantId: string;
|
|
19
19
|
} | undefined>;
|
|
20
20
|
declare const listContextConfigs: (db: AgentsManageDatabaseClient) => (params: {
|
|
21
21
|
scopes: AgentScopeConfig;
|
|
22
22
|
}) => Promise<{
|
|
23
23
|
id: string;
|
|
24
|
-
tenantId: string;
|
|
25
|
-
projectId: string;
|
|
26
|
-
agentId: string;
|
|
27
24
|
createdAt: string;
|
|
28
25
|
updatedAt: string;
|
|
29
26
|
headersSchema: unknown;
|
|
30
27
|
contextVariables: Record<string, ContextFetchDefinition> | null;
|
|
28
|
+
agentId: string;
|
|
29
|
+
projectId: string;
|
|
30
|
+
tenantId: string;
|
|
31
31
|
}[]>;
|
|
32
32
|
declare const listContextConfigsPaginated: (db: AgentsManageDatabaseClient) => (params: {
|
|
33
33
|
scopes: AgentScopeConfig;
|
|
@@ -43,13 +43,13 @@ declare const listContextConfigsPaginated: (db: AgentsManageDatabaseClient) => (
|
|
|
43
43
|
}>;
|
|
44
44
|
declare const createContextConfig: (db: AgentsManageDatabaseClient) => (params: ContextConfigInsert) => Promise<{
|
|
45
45
|
id: string;
|
|
46
|
-
tenantId: string;
|
|
47
|
-
projectId: string;
|
|
48
|
-
agentId: string;
|
|
49
46
|
createdAt: string;
|
|
50
47
|
updatedAt: string;
|
|
51
48
|
headersSchema: unknown;
|
|
52
49
|
contextVariables: Record<string, ContextFetchDefinition> | null;
|
|
50
|
+
agentId: string;
|
|
51
|
+
projectId: string;
|
|
52
|
+
tenantId: string;
|
|
53
53
|
}>;
|
|
54
54
|
declare const updateContextConfig: (db: AgentsManageDatabaseClient) => (params: {
|
|
55
55
|
scopes: AgentScopeConfig;
|
|
@@ -83,13 +83,13 @@ declare const upsertContextConfig: (db: AgentsManageDatabaseClient) => (params:
|
|
|
83
83
|
data: ContextConfigInsert;
|
|
84
84
|
}) => Promise<{
|
|
85
85
|
id: string;
|
|
86
|
-
tenantId: string;
|
|
87
|
-
projectId: string;
|
|
88
|
-
agentId: string;
|
|
89
86
|
createdAt: string;
|
|
90
87
|
updatedAt: string;
|
|
91
88
|
headersSchema: unknown;
|
|
92
89
|
contextVariables: Record<string, ContextFetchDefinition> | null;
|
|
90
|
+
agentId: string;
|
|
91
|
+
projectId: string;
|
|
92
|
+
tenantId: string;
|
|
93
93
|
}>;
|
|
94
94
|
//#endregion
|
|
95
95
|
export { countContextConfigs, createContextConfig, deleteContextConfig, getContextConfigById, hasContextConfig, listContextConfigs, listContextConfigsPaginated, updateContextConfig, upsertContextConfig };
|
|
@@ -65,10 +65,10 @@ declare const associateDataComponentWithAgent: (db: AgentsManageDatabaseClient)
|
|
|
65
65
|
dataComponentId: string;
|
|
66
66
|
}) => Promise<{
|
|
67
67
|
id: string;
|
|
68
|
-
tenantId: string;
|
|
69
|
-
projectId: string;
|
|
70
|
-
agentId: string;
|
|
71
68
|
createdAt: string;
|
|
69
|
+
agentId: string;
|
|
70
|
+
projectId: string;
|
|
71
|
+
tenantId: string;
|
|
72
72
|
subAgentId: string;
|
|
73
73
|
dataComponentId: string;
|
|
74
74
|
}>;
|
|
@@ -107,10 +107,10 @@ declare const upsertAgentDataComponentRelation: (db: AgentsManageDatabaseClient)
|
|
|
107
107
|
dataComponentId: string;
|
|
108
108
|
}) => Promise<{
|
|
109
109
|
id: string;
|
|
110
|
-
tenantId: string;
|
|
111
|
-
projectId: string;
|
|
112
|
-
agentId: string;
|
|
113
110
|
createdAt: string;
|
|
111
|
+
agentId: string;
|
|
112
|
+
projectId: string;
|
|
113
|
+
tenantId: string;
|
|
114
114
|
subAgentId: string;
|
|
115
115
|
dataComponentId: string;
|
|
116
116
|
} | null>;
|
|
@@ -55,12 +55,12 @@ declare const createFunctionTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
55
55
|
}) => Promise<{
|
|
56
56
|
id: string;
|
|
57
57
|
name: string;
|
|
58
|
-
description: string | null;
|
|
59
|
-
tenantId: string;
|
|
60
|
-
projectId: string;
|
|
61
|
-
agentId: string;
|
|
62
58
|
createdAt: string;
|
|
63
59
|
updatedAt: string;
|
|
60
|
+
agentId: string;
|
|
61
|
+
projectId: string;
|
|
62
|
+
tenantId: string;
|
|
63
|
+
description: string | null;
|
|
64
64
|
functionId: string;
|
|
65
65
|
}>;
|
|
66
66
|
/**
|
|
@@ -97,12 +97,12 @@ declare const upsertFunctionTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
97
97
|
}) => Promise<{
|
|
98
98
|
id: string;
|
|
99
99
|
name: string;
|
|
100
|
-
description: string | null;
|
|
101
|
-
tenantId: string;
|
|
102
|
-
projectId: string;
|
|
103
|
-
agentId: string;
|
|
104
100
|
createdAt: string;
|
|
105
101
|
updatedAt: string;
|
|
102
|
+
agentId: string;
|
|
103
|
+
projectId: string;
|
|
104
|
+
tenantId: string;
|
|
105
|
+
description: string | null;
|
|
106
106
|
functionId: string;
|
|
107
107
|
}>;
|
|
108
108
|
declare const getFunctionToolsForSubAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -162,16 +162,16 @@ declare const addFunctionToolToSubAgent: (db: AgentsManageDatabaseClient) => (pa
|
|
|
162
162
|
}> | null;
|
|
163
163
|
}) => Promise<{
|
|
164
164
|
id: string;
|
|
165
|
-
tenantId: string;
|
|
166
|
-
projectId: string;
|
|
167
|
-
agentId: string;
|
|
168
165
|
createdAt: string;
|
|
169
166
|
updatedAt: string;
|
|
167
|
+
agentId: string;
|
|
168
|
+
projectId: string;
|
|
169
|
+
tenantId: string;
|
|
170
|
+
subAgentId: string;
|
|
171
|
+
functionToolId: string;
|
|
170
172
|
toolPolicies: Record<string, {
|
|
171
173
|
needsApproval?: boolean;
|
|
172
174
|
}> | null;
|
|
173
|
-
subAgentId: string;
|
|
174
|
-
functionToolId: string;
|
|
175
175
|
}>;
|
|
176
176
|
/**
|
|
177
177
|
* Update an agent-function tool relation
|
|
@@ -227,16 +227,16 @@ declare const associateFunctionToolWithSubAgent: (db: AgentsManageDatabaseClient
|
|
|
227
227
|
}> | null;
|
|
228
228
|
}) => Promise<{
|
|
229
229
|
id: string;
|
|
230
|
-
tenantId: string;
|
|
231
|
-
projectId: string;
|
|
232
|
-
agentId: string;
|
|
233
230
|
createdAt: string;
|
|
234
231
|
updatedAt: string;
|
|
232
|
+
agentId: string;
|
|
233
|
+
projectId: string;
|
|
234
|
+
tenantId: string;
|
|
235
|
+
subAgentId: string;
|
|
236
|
+
functionToolId: string;
|
|
235
237
|
toolPolicies: Record<string, {
|
|
236
238
|
needsApproval?: boolean;
|
|
237
239
|
}> | null;
|
|
238
|
-
subAgentId: string;
|
|
239
|
-
functionToolId: string;
|
|
240
240
|
}>;
|
|
241
241
|
//#endregion
|
|
242
242
|
export { addFunctionToolToSubAgent, associateFunctionToolWithSubAgent, createFunctionTool, deleteFunctionTool, getFunctionToolById, getFunctionToolsForSubAgent, getSubAgentsUsingFunctionTool, isFunctionToolAssociatedWithSubAgent, listFunctionTools, removeFunctionToolFromSubAgent, updateFunctionTool, updateSubAgentFunctionToolRelation, upsertFunctionTool, upsertSubAgentFunctionToolRelation };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AgentScopeConfig, ProjectScopeConfig, SubAgentScopeConfig } from "../../types/utility.js";
|
|
2
|
+
import * as drizzle_orm20 from "drizzle-orm";
|
|
3
|
+
|
|
4
|
+
//#region src/data-access/manage/scope-helpers.d.ts
|
|
5
|
+
type TenantScopeConfig = {
|
|
6
|
+
tenantId: string;
|
|
7
|
+
};
|
|
8
|
+
type TenantScopedColumns = {
|
|
9
|
+
tenantId: any;
|
|
10
|
+
};
|
|
11
|
+
type ProjectScopedColumns = TenantScopedColumns & {
|
|
12
|
+
projectId: any;
|
|
13
|
+
};
|
|
14
|
+
type AgentScopedColumns = ProjectScopedColumns & {
|
|
15
|
+
agentId: any;
|
|
16
|
+
};
|
|
17
|
+
type SubAgentScopedColumns = AgentScopedColumns & {
|
|
18
|
+
subAgentId: any;
|
|
19
|
+
};
|
|
20
|
+
declare function tenantScopedWhere<T extends TenantScopedColumns>(table: T, scopes: TenantScopeConfig): drizzle_orm20.SQL<unknown>;
|
|
21
|
+
declare function projectScopedWhere<T extends ProjectScopedColumns>(table: T, scopes: ProjectScopeConfig): drizzle_orm20.SQL<unknown> | undefined;
|
|
22
|
+
declare function agentScopedWhere<T extends AgentScopedColumns>(table: T, scopes: AgentScopeConfig): drizzle_orm20.SQL<unknown> | undefined;
|
|
23
|
+
declare function subAgentScopedWhere<T extends SubAgentScopedColumns>(table: T, scopes: SubAgentScopeConfig): drizzle_orm20.SQL<unknown> | undefined;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { agentScopedWhere, projectScopedWhere, subAgentScopedWhere, tenantScopedWhere };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { and, eq } from "drizzle-orm";
|
|
2
|
+
|
|
3
|
+
//#region src/data-access/manage/scope-helpers.ts
|
|
4
|
+
function tenantScopedWhere(table, scopes) {
|
|
5
|
+
return eq(table.tenantId, scopes.tenantId);
|
|
6
|
+
}
|
|
7
|
+
function projectScopedWhere(table, scopes) {
|
|
8
|
+
return and(eq(table.tenantId, scopes.tenantId), eq(table.projectId, scopes.projectId));
|
|
9
|
+
}
|
|
10
|
+
function agentScopedWhere(table, scopes) {
|
|
11
|
+
return and(eq(table.tenantId, scopes.tenantId), eq(table.projectId, scopes.projectId), eq(table.agentId, scopes.agentId));
|
|
12
|
+
}
|
|
13
|
+
function subAgentScopedWhere(table, scopes) {
|
|
14
|
+
return and(eq(table.tenantId, scopes.tenantId), eq(table.projectId, scopes.projectId), eq(table.agentId, scopes.agentId), eq(table.subAgentId, scopes.subAgentId));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { agentScopedWhere, projectScopedWhere, subAgentScopedWhere, tenantScopedWhere };
|
|
@@ -9,12 +9,12 @@ declare const getSkillById: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
9
9
|
}) => Promise<{
|
|
10
10
|
id: string;
|
|
11
11
|
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
tenantId: string;
|
|
14
|
-
projectId: string;
|
|
15
12
|
createdAt: string;
|
|
16
13
|
updatedAt: string;
|
|
17
14
|
metadata: Record<string, string> | null;
|
|
15
|
+
projectId: string;
|
|
16
|
+
tenantId: string;
|
|
17
|
+
description: string;
|
|
18
18
|
content: string;
|
|
19
19
|
} | null>;
|
|
20
20
|
declare const listSkills: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -42,23 +42,23 @@ declare const listSkills: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
42
42
|
declare const createSkill: (db: AgentsManageDatabaseClient) => (data: SkillInsert) => Promise<{
|
|
43
43
|
id: string;
|
|
44
44
|
name: string;
|
|
45
|
-
description: string;
|
|
46
|
-
tenantId: string;
|
|
47
|
-
projectId: string;
|
|
48
45
|
createdAt: string;
|
|
49
46
|
updatedAt: string;
|
|
50
47
|
metadata: Record<string, string> | null;
|
|
48
|
+
projectId: string;
|
|
49
|
+
tenantId: string;
|
|
50
|
+
description: string;
|
|
51
51
|
content: string;
|
|
52
52
|
}>;
|
|
53
53
|
declare const upsertSkill: (db: AgentsManageDatabaseClient) => (data: SkillInsert) => Promise<{
|
|
54
54
|
id: string;
|
|
55
55
|
name: string;
|
|
56
|
-
description: string;
|
|
57
|
-
tenantId: string;
|
|
58
|
-
projectId: string;
|
|
59
56
|
createdAt: string;
|
|
60
57
|
updatedAt: string;
|
|
61
58
|
metadata: Record<string, string> | null;
|
|
59
|
+
projectId: string;
|
|
60
|
+
tenantId: string;
|
|
61
|
+
description: string;
|
|
62
62
|
content: string;
|
|
63
63
|
}>;
|
|
64
64
|
declare const updateSkill: (db: AgentsManageDatabaseClient) => (params: {
|
|
@@ -91,15 +91,15 @@ declare const upsertSubAgentSkill: (db: AgentsManageDatabaseClient) => (params:
|
|
|
91
91
|
alwaysLoaded?: boolean;
|
|
92
92
|
}) => Promise<{
|
|
93
93
|
id: string;
|
|
94
|
-
tenantId: string;
|
|
95
|
-
projectId: string;
|
|
96
|
-
agentId: string;
|
|
97
94
|
createdAt: string;
|
|
98
95
|
updatedAt: string;
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
agentId: string;
|
|
97
|
+
projectId: string;
|
|
98
|
+
tenantId: string;
|
|
101
99
|
subAgentId: string;
|
|
102
100
|
skillId: string;
|
|
101
|
+
index: number;
|
|
102
|
+
alwaysLoaded: boolean;
|
|
103
103
|
}>;
|
|
104
104
|
declare const deleteSubAgentSkill: (db: AgentsManageDatabaseClient) => (params: {
|
|
105
105
|
scopes: AgentScopeConfig;
|
|
@@ -9,14 +9,14 @@ declare const getSubAgentExternalAgentRelationById: (db: AgentsManageDatabaseCli
|
|
|
9
9
|
relationId: string;
|
|
10
10
|
}) => Promise<{
|
|
11
11
|
id: string;
|
|
12
|
-
tenantId: string;
|
|
13
|
-
projectId: string;
|
|
14
|
-
agentId: string;
|
|
15
12
|
createdAt: string;
|
|
16
13
|
updatedAt: string;
|
|
17
14
|
headers: Record<string, string> | null;
|
|
18
|
-
|
|
15
|
+
agentId: string;
|
|
16
|
+
projectId: string;
|
|
17
|
+
tenantId: string;
|
|
19
18
|
subAgentId: string;
|
|
19
|
+
externalAgentId: string;
|
|
20
20
|
} | undefined>;
|
|
21
21
|
declare const listSubAgentExternalAgentRelations: (db: AgentsManageDatabaseClient) => (params: {
|
|
22
22
|
scopes: SubAgentScopeConfig;
|
|
@@ -44,27 +44,27 @@ declare const getSubAgentExternalAgentRelations: (db: AgentsManageDatabaseClient
|
|
|
44
44
|
scopes: SubAgentScopeConfig;
|
|
45
45
|
}) => Promise<{
|
|
46
46
|
id: string;
|
|
47
|
-
tenantId: string;
|
|
48
|
-
projectId: string;
|
|
49
|
-
agentId: string;
|
|
50
47
|
createdAt: string;
|
|
51
48
|
updatedAt: string;
|
|
52
49
|
headers: Record<string, string> | null;
|
|
53
|
-
|
|
50
|
+
agentId: string;
|
|
51
|
+
projectId: string;
|
|
52
|
+
tenantId: string;
|
|
54
53
|
subAgentId: string;
|
|
54
|
+
externalAgentId: string;
|
|
55
55
|
}[]>;
|
|
56
56
|
declare const getSubAgentExternalAgentRelationsByAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
57
57
|
scopes: AgentScopeConfig;
|
|
58
58
|
}) => Promise<{
|
|
59
59
|
id: string;
|
|
60
|
-
tenantId: string;
|
|
61
|
-
projectId: string;
|
|
62
|
-
agentId: string;
|
|
63
60
|
createdAt: string;
|
|
64
61
|
updatedAt: string;
|
|
65
62
|
headers: Record<string, string> | null;
|
|
66
|
-
|
|
63
|
+
agentId: string;
|
|
64
|
+
projectId: string;
|
|
65
|
+
tenantId: string;
|
|
67
66
|
subAgentId: string;
|
|
67
|
+
externalAgentId: string;
|
|
68
68
|
}[]>;
|
|
69
69
|
declare const getSubAgentExternalAgentRelationsByExternalAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
70
70
|
scopes: AgentScopeConfig;
|
|
@@ -180,14 +180,14 @@ declare const createSubAgentExternalAgentRelation: (db: AgentsManageDatabaseClie
|
|
|
180
180
|
};
|
|
181
181
|
}) => Promise<{
|
|
182
182
|
id: string;
|
|
183
|
-
tenantId: string;
|
|
184
|
-
projectId: string;
|
|
185
|
-
agentId: string;
|
|
186
183
|
createdAt: string;
|
|
187
184
|
updatedAt: string;
|
|
188
185
|
headers: Record<string, string> | null;
|
|
189
|
-
|
|
186
|
+
agentId: string;
|
|
187
|
+
projectId: string;
|
|
188
|
+
tenantId: string;
|
|
190
189
|
subAgentId: string;
|
|
190
|
+
externalAgentId: string;
|
|
191
191
|
}>;
|
|
192
192
|
/**
|
|
193
193
|
* Check if sub-agent external agent relation exists by params
|
|
@@ -197,14 +197,14 @@ declare const getSubAgentExternalAgentRelationByParams: (db: AgentsManageDatabas
|
|
|
197
197
|
externalAgentId: string;
|
|
198
198
|
}) => Promise<{
|
|
199
199
|
id: string;
|
|
200
|
-
tenantId: string;
|
|
201
|
-
projectId: string;
|
|
202
|
-
agentId: string;
|
|
203
200
|
createdAt: string;
|
|
204
201
|
updatedAt: string;
|
|
205
202
|
headers: Record<string, string> | null;
|
|
206
|
-
|
|
203
|
+
agentId: string;
|
|
204
|
+
projectId: string;
|
|
205
|
+
tenantId: string;
|
|
207
206
|
subAgentId: string;
|
|
207
|
+
externalAgentId: string;
|
|
208
208
|
} | undefined>;
|
|
209
209
|
/**
|
|
210
210
|
* Upsert sub-agent external agent relation (create if it doesn't exist, update if it does)
|
|
@@ -218,14 +218,14 @@ declare const upsertSubAgentExternalAgentRelation: (db: AgentsManageDatabaseClie
|
|
|
218
218
|
};
|
|
219
219
|
}) => Promise<{
|
|
220
220
|
id: string;
|
|
221
|
-
tenantId: string;
|
|
222
|
-
projectId: string;
|
|
223
|
-
agentId: string;
|
|
224
221
|
createdAt: string;
|
|
225
222
|
updatedAt: string;
|
|
226
223
|
headers: Record<string, string> | null;
|
|
227
|
-
|
|
224
|
+
agentId: string;
|
|
225
|
+
projectId: string;
|
|
226
|
+
tenantId: string;
|
|
228
227
|
subAgentId: string;
|
|
228
|
+
externalAgentId: string;
|
|
229
229
|
}>;
|
|
230
230
|
declare const updateSubAgentExternalAgentRelation: (db: AgentsManageDatabaseClient) => (params: {
|
|
231
231
|
scopes: SubAgentScopeConfig;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { externalAgents, subAgentExternalAgentRelations, subAgents } from "../../db/manage/manage-schema.js";
|
|
2
|
+
import { agentScopedWhere, subAgentScopedWhere } from "./scope-helpers.js";
|
|
2
3
|
import { and, count, desc, eq } from "drizzle-orm";
|
|
3
4
|
import { nanoid } from "nanoid";
|
|
4
5
|
|
|
5
6
|
//#region src/data-access/manage/subAgentExternalAgentRelations.ts
|
|
6
7
|
const getSubAgentExternalAgentRelationById = (db) => async (params) => {
|
|
7
|
-
return db.query.subAgentExternalAgentRelations.findFirst({ where: and(
|
|
8
|
+
return db.query.subAgentExternalAgentRelations.findFirst({ where: and(subAgentScopedWhere(subAgentExternalAgentRelations, params.scopes), eq(subAgentExternalAgentRelations.id, params.relationId)) });
|
|
8
9
|
};
|
|
9
10
|
const listSubAgentExternalAgentRelations = (db) => async (params) => {
|
|
10
11
|
const page = params.pagination?.page || 1;
|
|
11
12
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
12
13
|
const offset = (page - 1) * limit;
|
|
13
|
-
const whereClause =
|
|
14
|
+
const whereClause = subAgentScopedWhere(subAgentExternalAgentRelations, params.scopes);
|
|
14
15
|
const [data, totalResult] = await Promise.all([db.select().from(subAgentExternalAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(desc(subAgentExternalAgentRelations.createdAt)), db.select({ count: count() }).from(subAgentExternalAgentRelations).where(whereClause)]);
|
|
15
16
|
const total = totalResult[0]?.count || 0;
|
|
16
17
|
return {
|
|
@@ -24,16 +25,16 @@ const listSubAgentExternalAgentRelations = (db) => async (params) => {
|
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
27
|
const getSubAgentExternalAgentRelations = (db) => async (params) => {
|
|
27
|
-
return await db.query.subAgentExternalAgentRelations.findMany({ where:
|
|
28
|
+
return await db.query.subAgentExternalAgentRelations.findMany({ where: subAgentScopedWhere(subAgentExternalAgentRelations, params.scopes) });
|
|
28
29
|
};
|
|
29
30
|
const getSubAgentExternalAgentRelationsByAgent = (db) => async (params) => {
|
|
30
|
-
return await db.query.subAgentExternalAgentRelations.findMany({ where:
|
|
31
|
+
return await db.query.subAgentExternalAgentRelations.findMany({ where: agentScopedWhere(subAgentExternalAgentRelations, params.scopes) });
|
|
31
32
|
};
|
|
32
33
|
const getSubAgentExternalAgentRelationsByExternalAgent = (db) => async (params) => {
|
|
33
34
|
const page = params.pagination?.page || 1;
|
|
34
35
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
35
36
|
const offset = (page - 1) * limit;
|
|
36
|
-
const whereClause = and(
|
|
37
|
+
const whereClause = and(agentScopedWhere(subAgentExternalAgentRelations, params.scopes), eq(subAgentExternalAgentRelations.externalAgentId, params.externalAgentId));
|
|
37
38
|
const [data, totalResult] = await Promise.all([db.select().from(subAgentExternalAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(desc(subAgentExternalAgentRelations.createdAt)), db.select({ count: count() }).from(subAgentExternalAgentRelations).where(whereClause)]);
|
|
38
39
|
const total = totalResult[0]?.count || 0;
|
|
39
40
|
return {
|
|
@@ -71,7 +72,7 @@ const getExternalAgentsForSubAgent = (db) => async (params) => {
|
|
|
71
72
|
createdAt: externalAgents.createdAt,
|
|
72
73
|
updatedAt: externalAgents.updatedAt
|
|
73
74
|
}
|
|
74
|
-
}).from(subAgentExternalAgentRelations).innerJoin(externalAgents, and(eq(subAgentExternalAgentRelations.tenantId, externalAgents.tenantId), eq(subAgentExternalAgentRelations.projectId, externalAgents.projectId), eq(subAgentExternalAgentRelations.externalAgentId, externalAgents.id))).where(
|
|
75
|
+
}).from(subAgentExternalAgentRelations).innerJoin(externalAgents, and(eq(subAgentExternalAgentRelations.tenantId, externalAgents.tenantId), eq(subAgentExternalAgentRelations.projectId, externalAgents.projectId), eq(subAgentExternalAgentRelations.externalAgentId, externalAgents.id))).where(subAgentScopedWhere(subAgentExternalAgentRelations, params.scopes)).limit(limit).offset(offset).orderBy(desc(subAgentExternalAgentRelations.createdAt)), db.select({ count: count() }).from(subAgentExternalAgentRelations).where(subAgentScopedWhere(subAgentExternalAgentRelations, params.scopes))]);
|
|
75
76
|
const total = totalResult[0]?.count || 0;
|
|
76
77
|
return {
|
|
77
78
|
data,
|
|
@@ -108,7 +109,7 @@ const getSubAgentsForExternalAgent = (db) => async (params) => {
|
|
|
108
109
|
createdAt: subAgents.createdAt,
|
|
109
110
|
updatedAt: subAgents.updatedAt
|
|
110
111
|
}
|
|
111
|
-
}).from(subAgentExternalAgentRelations).innerJoin(subAgents, and(eq(subAgentExternalAgentRelations.subAgentId, subAgents.id), eq(subAgentExternalAgentRelations.tenantId, subAgents.tenantId), eq(subAgentExternalAgentRelations.projectId, subAgents.projectId), eq(subAgentExternalAgentRelations.agentId, subAgents.agentId))).where(and(
|
|
112
|
+
}).from(subAgentExternalAgentRelations).innerJoin(subAgents, and(eq(subAgentExternalAgentRelations.subAgentId, subAgents.id), eq(subAgentExternalAgentRelations.tenantId, subAgents.tenantId), eq(subAgentExternalAgentRelations.projectId, subAgents.projectId), eq(subAgentExternalAgentRelations.agentId, subAgents.agentId))).where(and(agentScopedWhere(subAgentExternalAgentRelations, params.scopes), eq(subAgentExternalAgentRelations.externalAgentId, params.externalAgentId))).limit(limit).offset(offset).orderBy(desc(subAgentExternalAgentRelations.createdAt)), db.select({ count: count() }).from(subAgentExternalAgentRelations).where(and(agentScopedWhere(subAgentExternalAgentRelations, params.scopes), eq(subAgentExternalAgentRelations.externalAgentId, params.externalAgentId)))]);
|
|
112
113
|
const total = totalResult[0]?.count || 0;
|
|
113
114
|
return {
|
|
114
115
|
data,
|
|
@@ -136,7 +137,7 @@ const createSubAgentExternalAgentRelation = (db) => async (params) => {
|
|
|
136
137
|
* Check if sub-agent external agent relation exists by params
|
|
137
138
|
*/
|
|
138
139
|
const getSubAgentExternalAgentRelationByParams = (db) => async (params) => {
|
|
139
|
-
return db.query.subAgentExternalAgentRelations.findFirst({ where: and(
|
|
140
|
+
return db.query.subAgentExternalAgentRelations.findFirst({ where: and(subAgentScopedWhere(subAgentExternalAgentRelations, params.scopes), eq(subAgentExternalAgentRelations.externalAgentId, params.externalAgentId)) });
|
|
140
141
|
};
|
|
141
142
|
/**
|
|
142
143
|
* Upsert sub-agent external agent relation (create if it doesn't exist, update if it does)
|
|
@@ -163,16 +164,16 @@ const updateSubAgentExternalAgentRelation = (db) => async (params) => {
|
|
|
163
164
|
...params.data,
|
|
164
165
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
165
166
|
};
|
|
166
|
-
return (await db.update(subAgentExternalAgentRelations).set(updateData).where(and(
|
|
167
|
+
return (await db.update(subAgentExternalAgentRelations).set(updateData).where(and(subAgentScopedWhere(subAgentExternalAgentRelations, params.scopes), eq(subAgentExternalAgentRelations.id, params.relationId))).returning())[0];
|
|
167
168
|
};
|
|
168
169
|
const deleteSubAgentExternalAgentRelation = (db) => async (params) => {
|
|
169
|
-
return (await db.delete(subAgentExternalAgentRelations).where(and(
|
|
170
|
+
return (await db.delete(subAgentExternalAgentRelations).where(and(subAgentScopedWhere(subAgentExternalAgentRelations, params.scopes), eq(subAgentExternalAgentRelations.id, params.relationId))).returning()).length > 0;
|
|
170
171
|
};
|
|
171
172
|
const deleteSubAgentExternalAgentRelationsBySubAgent = (db) => async (params) => {
|
|
172
|
-
return (await db.delete(subAgentExternalAgentRelations).where(
|
|
173
|
+
return (await db.delete(subAgentExternalAgentRelations).where(subAgentScopedWhere(subAgentExternalAgentRelations, params.scopes)).returning()).length > 0;
|
|
173
174
|
};
|
|
174
175
|
const deleteSubAgentExternalAgentRelationsByAgent = (db) => async (params) => {
|
|
175
|
-
return (await db.delete(subAgentExternalAgentRelations).where(
|
|
176
|
+
return (await db.delete(subAgentExternalAgentRelations).where(agentScopedWhere(subAgentExternalAgentRelations, params.scopes)).returning()).length > 0;
|
|
176
177
|
};
|
|
177
178
|
|
|
178
179
|
//#endregion
|
|
@@ -11,9 +11,9 @@ declare const getAgentRelationById: (db: AgentsManageDatabaseClient) => (params:
|
|
|
11
11
|
id: string;
|
|
12
12
|
createdAt: string;
|
|
13
13
|
updatedAt: string;
|
|
14
|
-
tenantId: string;
|
|
15
|
-
projectId: string;
|
|
16
14
|
agentId: string;
|
|
15
|
+
projectId: string;
|
|
16
|
+
tenantId: string;
|
|
17
17
|
sourceSubAgentId: string;
|
|
18
18
|
targetSubAgentId: string | null;
|
|
19
19
|
relationType: string | null;
|
|
@@ -46,9 +46,9 @@ declare const getAgentRelations: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
46
46
|
id: string;
|
|
47
47
|
createdAt: string;
|
|
48
48
|
updatedAt: string;
|
|
49
|
-
tenantId: string;
|
|
50
|
-
projectId: string;
|
|
51
49
|
agentId: string;
|
|
50
|
+
projectId: string;
|
|
51
|
+
tenantId: string;
|
|
52
52
|
sourceSubAgentId: string;
|
|
53
53
|
targetSubAgentId: string | null;
|
|
54
54
|
relationType: string | null;
|
|
@@ -59,9 +59,9 @@ declare const getAgentRelationsByAgent: (db: AgentsManageDatabaseClient) => (par
|
|
|
59
59
|
id: string;
|
|
60
60
|
createdAt: string;
|
|
61
61
|
updatedAt: string;
|
|
62
|
-
tenantId: string;
|
|
63
|
-
projectId: string;
|
|
64
62
|
agentId: string;
|
|
63
|
+
projectId: string;
|
|
64
|
+
tenantId: string;
|
|
65
65
|
sourceSubAgentId: string;
|
|
66
66
|
targetSubAgentId: string | null;
|
|
67
67
|
relationType: string | null;
|
|
@@ -128,9 +128,9 @@ declare const createSubAgentRelation: (db: AgentsManageDatabaseClient) => (param
|
|
|
128
128
|
id: string;
|
|
129
129
|
createdAt: string;
|
|
130
130
|
updatedAt: string;
|
|
131
|
-
tenantId: string;
|
|
132
|
-
projectId: string;
|
|
133
131
|
agentId: string;
|
|
132
|
+
projectId: string;
|
|
133
|
+
tenantId: string;
|
|
134
134
|
sourceSubAgentId: string;
|
|
135
135
|
targetSubAgentId: string | null;
|
|
136
136
|
relationType: string | null;
|
|
@@ -147,9 +147,9 @@ declare const getAgentRelationByParams: (db: AgentsManageDatabaseClient) => (par
|
|
|
147
147
|
id: string;
|
|
148
148
|
createdAt: string;
|
|
149
149
|
updatedAt: string;
|
|
150
|
-
tenantId: string;
|
|
151
|
-
projectId: string;
|
|
152
150
|
agentId: string;
|
|
151
|
+
projectId: string;
|
|
152
|
+
tenantId: string;
|
|
153
153
|
sourceSubAgentId: string;
|
|
154
154
|
targetSubAgentId: string | null;
|
|
155
155
|
relationType: string | null;
|
|
@@ -161,9 +161,9 @@ declare const upsertSubAgentRelation: (db: AgentsManageDatabaseClient) => (param
|
|
|
161
161
|
id: string;
|
|
162
162
|
createdAt: string;
|
|
163
163
|
updatedAt: string;
|
|
164
|
-
tenantId: string;
|
|
165
|
-
projectId: string;
|
|
166
164
|
agentId: string;
|
|
165
|
+
projectId: string;
|
|
166
|
+
tenantId: string;
|
|
167
167
|
sourceSubAgentId: string;
|
|
168
168
|
targetSubAgentId: string | null;
|
|
169
169
|
relationType: string | null;
|
|
@@ -206,16 +206,16 @@ declare const createAgentToolRelation: (db: AgentsManageDatabaseClient) => (para
|
|
|
206
206
|
id: string;
|
|
207
207
|
createdAt: string;
|
|
208
208
|
updatedAt: string;
|
|
209
|
-
|
|
210
|
-
projectId: string;
|
|
209
|
+
headers: Record<string, string> | null;
|
|
211
210
|
agentId: string;
|
|
211
|
+
projectId: string;
|
|
212
|
+
tenantId: string;
|
|
212
213
|
toolId: string;
|
|
213
214
|
subAgentId: string;
|
|
214
|
-
headers: Record<string, string> | null;
|
|
215
|
-
selectedTools: string[] | null;
|
|
216
215
|
toolPolicies: Record<string, {
|
|
217
216
|
needsApproval?: boolean;
|
|
218
217
|
}> | null;
|
|
218
|
+
selectedTools: string[] | null;
|
|
219
219
|
}>;
|
|
220
220
|
declare const updateAgentToolRelation: (db: AgentsManageDatabaseClient) => (params: {
|
|
221
221
|
scopes: AgentScopeConfig;
|
|
@@ -250,16 +250,16 @@ declare const getAgentToolRelationById: (db: AgentsManageDatabaseClient) => (par
|
|
|
250
250
|
id: string;
|
|
251
251
|
createdAt: string;
|
|
252
252
|
updatedAt: string;
|
|
253
|
-
|
|
254
|
-
projectId: string;
|
|
253
|
+
headers: Record<string, string> | null;
|
|
255
254
|
agentId: string;
|
|
255
|
+
projectId: string;
|
|
256
|
+
tenantId: string;
|
|
256
257
|
toolId: string;
|
|
257
258
|
subAgentId: string;
|
|
258
|
-
headers: Record<string, string> | null;
|
|
259
|
-
selectedTools: string[] | null;
|
|
260
259
|
toolPolicies: Record<string, {
|
|
261
260
|
needsApproval?: boolean;
|
|
262
261
|
}> | null;
|
|
262
|
+
selectedTools: string[] | null;
|
|
263
263
|
} | undefined>;
|
|
264
264
|
declare const getAgentToolRelationByAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
265
265
|
scopes: SubAgentScopeConfig;
|