@inkeep/agents-core 0.41.2 → 0.42.0
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/api-client/base-client.d.ts +87 -8
- package/dist/api-client/base-client.js +174 -1
- package/dist/api-client/eval-api-client.d.ts +47 -0
- package/dist/api-client/eval-api-client.js +65 -0
- package/dist/api-client/index.d.ts +4 -0
- package/dist/api-client/index.js +5 -0
- package/dist/api-client/manage-api-client.d.ts +34 -0
- package/dist/api-client/manage-api-client.js +104 -0
- package/dist/auth/auth.d.ts +86 -20
- package/dist/auth/auth.js +55 -1
- package/dist/auth/authz/client.d.ts +81 -0
- package/dist/auth/authz/client.js +189 -0
- package/dist/auth/authz/config.d.ts +76 -0
- package/dist/auth/authz/config.js +76 -0
- package/dist/auth/authz/index.d.ts +5 -0
- package/dist/auth/authz/index.js +6 -0
- package/dist/auth/authz/permissions.d.ts +57 -0
- package/dist/auth/authz/permissions.js +83 -0
- package/dist/auth/authz/sync.d.ts +85 -0
- package/dist/auth/authz/sync.js +237 -0
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/auth/permissions.js +2 -181
- package/dist/client-exports.d.ts +8 -3
- package/dist/client-exports.js +3 -2
- package/dist/constants/context-breakdown.d.ts +61 -0
- package/dist/constants/context-breakdown.js +124 -0
- package/dist/constants/otel-attributes.d.ts +4 -0
- package/dist/constants/otel-attributes.js +4 -0
- package/dist/context/ContextConfig.d.ts +2 -2
- package/dist/context/ContextConfig.js +3 -3
- package/dist/context/TemplateEngine.js +0 -1
- package/dist/context/index.d.ts +1 -5
- package/dist/context/index.js +1 -5
- package/dist/credential-stuffer/CredentialStuffer.d.ts +1 -1
- package/dist/data-access/index.d.ts +34 -26
- package/dist/data-access/index.js +34 -26
- package/dist/data-access/manage/agentFull.d.ts +36 -0
- package/dist/data-access/{agentFull.js → manage/agentFull.js} +205 -7
- package/dist/data-access/{agents.d.ts → manage/agents.d.ts} +23 -22
- package/dist/data-access/{agents.js → manage/agents.js} +52 -7
- package/dist/data-access/{artifactComponents.d.ts → manage/artifactComponents.d.ts} +21 -21
- package/dist/data-access/{artifactComponents.js → manage/artifactComponents.js} +5 -5
- package/dist/data-access/{contextConfigs.d.ts → manage/contextConfigs.d.ts} +14 -14
- package/dist/data-access/{contextConfigs.js → manage/contextConfigs.js} +3 -3
- package/dist/data-access/{credentialReferences.d.ts → manage/credentialReferences.d.ts} +17 -17
- package/dist/data-access/{credentialReferences.js → manage/credentialReferences.js} +2 -2
- package/dist/data-access/{dataComponents.d.ts → manage/dataComponents.d.ts} +20 -20
- package/dist/data-access/{dataComponents.js → manage/dataComponents.js} +7 -7
- package/dist/data-access/manage/evalConfig.d.ts +221 -0
- package/dist/data-access/manage/evalConfig.js +275 -0
- package/dist/data-access/{externalAgents.d.ts → manage/externalAgents.d.ts} +16 -16
- package/dist/data-access/{externalAgents.js → manage/externalAgents.js} +2 -2
- package/dist/data-access/{functionTools.d.ts → manage/functionTools.d.ts} +65 -15
- package/dist/data-access/{functionTools.js → manage/functionTools.js} +90 -8
- package/dist/data-access/{functions.d.ts → manage/functions.d.ts} +9 -9
- package/dist/data-access/{functions.js → manage/functions.js} +3 -3
- package/dist/data-access/manage/projectFull.d.ts +38 -0
- package/dist/data-access/{projectFull.js → manage/projectFull.js} +64 -65
- package/dist/data-access/manage/projectLifecycle.d.ts +119 -0
- package/dist/data-access/manage/projectLifecycle.js +234 -0
- package/dist/data-access/manage/projects.d.ts +75 -0
- package/dist/data-access/{projects.js → manage/projects.js} +15 -16
- package/dist/data-access/{subAgentExternalAgentRelations.d.ts → manage/subAgentExternalAgentRelations.d.ts} +19 -19
- package/dist/data-access/{subAgentExternalAgentRelations.js → manage/subAgentExternalAgentRelations.js} +2 -2
- package/dist/data-access/{subAgentRelations.d.ts → manage/subAgentRelations.d.ts} +29 -29
- package/dist/data-access/{subAgentRelations.js → manage/subAgentRelations.js} +3 -3
- package/dist/data-access/{subAgentTeamAgentRelations.d.ts → manage/subAgentTeamAgentRelations.d.ts} +19 -19
- package/dist/data-access/{subAgentTeamAgentRelations.js → manage/subAgentTeamAgentRelations.js} +2 -2
- package/dist/data-access/{subAgents.d.ts → manage/subAgents.d.ts} +13 -13
- package/dist/data-access/{subAgents.js → manage/subAgents.js} +4 -4
- package/dist/data-access/{tools.d.ts → manage/tools.d.ts} +26 -19
- package/dist/data-access/{tools.js → manage/tools.js} +57 -35
- package/dist/data-access/manage/triggers.d.ts +80 -0
- package/dist/data-access/manage/triggers.js +81 -0
- package/dist/data-access/{apiKeys.d.ts → runtime/apiKeys.d.ts} +17 -17
- package/dist/data-access/{apiKeys.js → runtime/apiKeys.js} +3 -3
- package/dist/data-access/runtime/cascade-delete.d.ts +77 -0
- package/dist/data-access/runtime/cascade-delete.js +111 -0
- package/dist/data-access/{contextCache.d.ts → runtime/contextCache.d.ts} +13 -13
- package/dist/data-access/{contextCache.js → runtime/contextCache.js} +5 -5
- package/dist/data-access/{conversations.d.ts → runtime/conversations.d.ts} +68 -19
- package/dist/data-access/{conversations.js → runtime/conversations.js} +13 -7
- package/dist/data-access/runtime/evalRuns.d.ts +120 -0
- package/dist/data-access/runtime/evalRuns.js +168 -0
- package/dist/data-access/{ledgerArtifacts.d.ts → runtime/ledgerArtifacts.d.ts} +13 -13
- package/dist/data-access/{ledgerArtifacts.js → runtime/ledgerArtifacts.js} +3 -3
- package/dist/data-access/{messages.d.ts → runtime/messages.d.ts} +15 -15
- package/dist/data-access/{messages.js → runtime/messages.js} +2 -2
- package/dist/data-access/{organizations.d.ts → runtime/organizations.d.ts} +16 -7
- package/dist/data-access/{organizations.js → runtime/organizations.js} +15 -3
- package/dist/data-access/runtime/projects.d.ts +62 -0
- package/dist/data-access/runtime/projects.js +90 -0
- package/dist/data-access/runtime/tasks.d.ts +55 -0
- package/dist/data-access/{tasks.js → runtime/tasks.js} +2 -2
- package/dist/data-access/runtime/triggerInvocations.d.ts +62 -0
- package/dist/data-access/runtime/triggerInvocations.js +54 -0
- package/dist/data-access/runtime/users.d.ts +19 -0
- package/dist/data-access/{users.js → runtime/users.js} +2 -2
- package/dist/data-access/validation.d.ts +4 -4
- package/dist/data-access/validation.js +1 -1
- package/dist/db/clean.d.ts +8 -4
- package/dist/db/clean.js +14 -105
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +7 -10
- package/dist/db/manage/dolt-cleanup.d.ts +51 -0
- package/dist/db/manage/dolt-cleanup.js +132 -0
- package/dist/db/manage/manage-client.d.ts +26 -0
- package/dist/db/manage/manage-client.js +68 -0
- package/dist/db/{schema.d.ts → manage/manage-schema.d.ts} +1459 -1285
- package/dist/db/{schema.js → manage/manage-schema.js} +433 -341
- package/dist/db/manage/test-manage-client.d.ts +27 -0
- package/dist/db/manage/test-manage-client.js +68 -0
- package/dist/db/runtime/runtime-client.d.ts +20 -0
- package/dist/db/runtime/runtime-client.js +30 -0
- package/dist/db/runtime/runtime-schema.d.ts +2834 -0
- package/dist/db/runtime/runtime-schema.js +483 -0
- package/dist/db/runtime/test-runtime-client.d.ts +27 -0
- package/dist/db/{test-client.js → runtime/test-runtime-client.js} +11 -25
- package/dist/dolt/branch.d.ts +62 -0
- package/dist/dolt/branch.js +82 -0
- package/dist/dolt/branches-api.d.ts +108 -0
- package/dist/dolt/branches-api.js +162 -0
- package/dist/dolt/commit.d.ts +94 -0
- package/dist/dolt/commit.js +103 -0
- package/dist/dolt/diff.d.ts +27 -0
- package/dist/dolt/diff.js +21 -0
- package/dist/dolt/index.d.ts +10 -0
- package/dist/dolt/index.js +11 -0
- package/dist/dolt/merge.d.ts +63 -0
- package/dist/dolt/merge.js +81 -0
- package/dist/dolt/migrate-all-branches.d.ts +4 -0
- package/dist/dolt/migrate-all-branches.js +78 -0
- package/dist/dolt/migrate-dolt.d.ts +1 -0
- package/dist/dolt/migrate-dolt.js +22 -0
- package/dist/dolt/ref-helpers.d.ts +19 -0
- package/dist/dolt/ref-helpers.js +65 -0
- package/dist/dolt/ref-middleware.d.ts +82 -0
- package/dist/dolt/ref-middleware.js +217 -0
- package/dist/dolt/ref-scope.d.ts +101 -0
- package/dist/dolt/ref-scope.js +231 -0
- package/dist/dolt/schema-sync.d.ts +134 -0
- package/dist/dolt/schema-sync.js +246 -0
- package/dist/env.d.ts +6 -4
- package/dist/env.js +3 -2
- package/dist/index.d.ts +71 -44
- package/dist/index.js +74 -47
- package/dist/types/entities.d.ts +81 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/utility.d.ts +45 -4
- package/dist/utils/JsonTransformer.d.ts +44 -0
- package/dist/utils/JsonTransformer.js +112 -0
- package/dist/utils/apiKeys.d.ts +5 -1
- package/dist/utils/apiKeys.js +11 -1
- package/dist/utils/colors.d.ts +34 -0
- package/dist/utils/colors.js +49 -0
- package/dist/utils/credential-store-utils.d.ts +1 -1
- package/dist/utils/format-messages.d.ts +1 -1
- package/dist/utils/index.d.ts +7 -3
- package/dist/utils/index.js +7 -3
- package/dist/utils/internal-service-auth.d.ts +79 -0
- package/dist/utils/internal-service-auth.js +140 -0
- package/dist/utils/jwt-helpers.d.ts +56 -0
- package/dist/utils/jwt-helpers.js +90 -0
- package/dist/utils/service-token-auth.d.ts +9 -27
- package/dist/utils/service-token-auth.js +48 -96
- package/dist/utils/template-interpolation.d.ts +22 -0
- package/dist/utils/template-interpolation.js +62 -0
- package/dist/utils/third-party-mcp-servers/composio-client.js +23 -23
- package/dist/utils/trigger-auth.d.ts +62 -0
- package/dist/utils/trigger-auth.js +125 -0
- package/dist/validation/agentFull.js +2 -4
- package/dist/validation/dolt-schemas.d.ts +49 -0
- package/dist/validation/dolt-schemas.js +44 -0
- package/dist/validation/drizzle-schema-helpers.d.ts +4 -26
- package/dist/validation/drizzle-schema-helpers.js +5 -151
- package/dist/validation/index.d.ts +4 -3
- package/dist/validation/index.js +3 -2
- package/dist/validation/schemas.d.ts +17647 -4789
- package/dist/validation/schemas.js +328 -11
- package/drizzle/manage/0000_tearful_rhodey.sql +414 -0
- package/drizzle/manage/0001_broken_wendell_vaughn.sql +19 -0
- package/drizzle/manage/0002_bent_sunfire.sql +1 -0
- package/drizzle/manage/meta/0000_snapshot.json +2987 -0
- package/drizzle/manage/meta/0001_snapshot.json +3115 -0
- package/drizzle/manage/meta/0002_snapshot.json +3115 -0
- package/drizzle/manage/meta/_journal.json +27 -0
- package/drizzle/runtime/0008_silly_preak.sql +127 -0
- package/drizzle/runtime/0009_freezing_leo.sql +17 -0
- package/drizzle/runtime/meta/0008_snapshot.json +2263 -0
- package/drizzle/runtime/meta/0009_snapshot.json +2397 -0
- package/drizzle/{meta → runtime/meta}/_journal.json +14 -0
- package/package.json +48 -15
- package/dist/context/ContextFetcher.d.ts +0 -73
- package/dist/context/ContextFetcher.js +0 -291
- package/dist/context/ContextResolver.d.ts +0 -60
- package/dist/context/ContextResolver.js +0 -278
- package/dist/context/context.d.ts +0 -27
- package/dist/context/context.js +0 -128
- package/dist/context/contextCache.d.ts +0 -58
- package/dist/context/contextCache.js +0 -177
- package/dist/data-access/agentFull.d.ts +0 -33
- package/dist/data-access/projectFull.d.ts +0 -32
- package/dist/data-access/projects.d.ts +0 -71
- package/dist/data-access/tasks.d.ts +0 -45
- package/dist/data-access/users.d.ts +0 -19
- package/dist/db/client.d.ts +0 -20
- package/dist/db/client.js +0 -28
- package/dist/db/test-client.d.ts +0 -31
- package/dist/middleware/contextValidation.d.ts +0 -46
- package/dist/middleware/contextValidation.js +0 -280
- package/dist/middleware/index.d.ts +0 -2
- package/dist/middleware/index.js +0 -3
- package/dist/utils/execution.d.ts +0 -22
- package/dist/utils/execution.js +0 -25
- /package/drizzle/{0000_exotic_mysterio.sql → runtime/0000_exotic_mysterio.sql} +0 -0
- /package/drizzle/{0001_calm_sheva_callister.sql → runtime/0001_calm_sheva_callister.sql} +0 -0
- /package/drizzle/{0002_puzzling_goblin_queen.sql → runtime/0002_puzzling_goblin_queen.sql} +0 -0
- /package/drizzle/{0003_sweet_human_robot.sql → runtime/0003_sweet_human_robot.sql} +0 -0
- /package/drizzle/{0004_cuddly_shooting_star.sql → runtime/0004_cuddly_shooting_star.sql} +0 -0
- /package/drizzle/{0005_reflective_starfox.sql → runtime/0005_reflective_starfox.sql} +0 -0
- /package/drizzle/{0006_stale_thaddeus_ross.sql → runtime/0006_stale_thaddeus_ross.sql} +0 -0
- /package/drizzle/{0007_slim_karma.sql → runtime/0007_slim_karma.sql} +0 -0
- /package/drizzle/{meta → runtime/meta}/0000_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0001_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0003_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0005_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0006_snapshot.json +0 -0
- /package/drizzle/{meta → runtime/meta}/0007_snapshot.json +0 -0
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { PaginationConfig, ProjectScopeConfig } from "../../types/utility.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { AgentsManageDatabaseClient } from "../../db/manage/manage-client.js";
|
|
4
|
+
import { ExternalAgentInsert, ExternalAgentSelect, ExternalAgentUpdate } from "../../types/entities.js";
|
|
5
5
|
|
|
6
|
-
//#region src/data-access/externalAgents.d.ts
|
|
6
|
+
//#region src/data-access/manage/externalAgents.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* Create a new external agent
|
|
9
9
|
*/
|
|
10
|
-
declare const createExternalAgent: (db:
|
|
10
|
+
declare const createExternalAgent: (db: AgentsManageDatabaseClient) => (params: ExternalAgentInsert) => Promise<ExternalAgentSelect>;
|
|
11
11
|
/**
|
|
12
12
|
* Get external agent by ID
|
|
13
13
|
*/
|
|
14
|
-
declare const getExternalAgent: (db:
|
|
14
|
+
declare const getExternalAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
15
15
|
scopes: ProjectScopeConfig;
|
|
16
16
|
externalAgentId: string;
|
|
17
17
|
}) => Promise<ExternalAgentSelect | null>;
|
|
18
18
|
/**
|
|
19
19
|
* Get external agent by base URL
|
|
20
20
|
*/
|
|
21
|
-
declare const getExternalAgentByUrl: (db:
|
|
21
|
+
declare const getExternalAgentByUrl: (db: AgentsManageDatabaseClient) => (params: {
|
|
22
22
|
scopes: ProjectScopeConfig;
|
|
23
23
|
baseUrl: string;
|
|
24
24
|
}) => Promise<ExternalAgentSelect | null>;
|
|
25
25
|
/**
|
|
26
26
|
* List external agents for a project
|
|
27
27
|
*/
|
|
28
|
-
declare const listExternalAgents: (db:
|
|
28
|
+
declare const listExternalAgents: (db: AgentsManageDatabaseClient) => (params: {
|
|
29
29
|
scopes: ProjectScopeConfig;
|
|
30
30
|
}) => Promise<ExternalAgentSelect[]>;
|
|
31
31
|
/**
|
|
32
32
|
* List external agents with pagination
|
|
33
33
|
*/
|
|
34
|
-
declare const listExternalAgentsPaginated: (db:
|
|
34
|
+
declare const listExternalAgentsPaginated: (db: AgentsManageDatabaseClient) => (params: {
|
|
35
35
|
scopes: ProjectScopeConfig;
|
|
36
36
|
pagination?: PaginationConfig;
|
|
37
37
|
}) => Promise<{
|
|
@@ -46,7 +46,7 @@ declare const listExternalAgentsPaginated: (db: DatabaseClient) => (params: {
|
|
|
46
46
|
/**
|
|
47
47
|
* Update an existing external agent
|
|
48
48
|
*/
|
|
49
|
-
declare const updateExternalAgent: (db:
|
|
49
|
+
declare const updateExternalAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
50
50
|
scopes: ProjectScopeConfig;
|
|
51
51
|
externalAgentId: string;
|
|
52
52
|
data: Partial<ExternalAgentUpdate>;
|
|
@@ -54,34 +54,34 @@ declare const updateExternalAgent: (db: DatabaseClient) => (params: {
|
|
|
54
54
|
/**
|
|
55
55
|
* Upsert external agent (create if it doesn't exist, update if it does)
|
|
56
56
|
*/
|
|
57
|
-
declare const upsertExternalAgent: (db:
|
|
57
|
+
declare const upsertExternalAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
58
58
|
data: ExternalAgentInsert;
|
|
59
59
|
}) => Promise<ExternalAgentSelect>;
|
|
60
60
|
/**
|
|
61
61
|
* Delete an external agent
|
|
62
62
|
*/
|
|
63
|
-
declare const deleteExternalAgent: (db:
|
|
63
|
+
declare const deleteExternalAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
64
64
|
scopes: ProjectScopeConfig;
|
|
65
65
|
externalAgentId: string;
|
|
66
66
|
}) => Promise<boolean>;
|
|
67
67
|
/**
|
|
68
68
|
* Check if an external agent exists
|
|
69
69
|
*/
|
|
70
|
-
declare const externalAgentExists: (db:
|
|
70
|
+
declare const externalAgentExists: (db: AgentsManageDatabaseClient) => (params: {
|
|
71
71
|
scopes: ProjectScopeConfig;
|
|
72
72
|
externalAgentId: string;
|
|
73
73
|
}) => Promise<boolean>;
|
|
74
74
|
/**
|
|
75
75
|
* Check if an external agent exists by URL
|
|
76
76
|
*/
|
|
77
|
-
declare const externalAgentUrlExists: (db:
|
|
77
|
+
declare const externalAgentUrlExists: (db: AgentsManageDatabaseClient) => (params: {
|
|
78
78
|
scopes: ProjectScopeConfig;
|
|
79
79
|
baseUrl: string;
|
|
80
80
|
}) => Promise<boolean>;
|
|
81
81
|
/**
|
|
82
82
|
* Count external agents for a project
|
|
83
83
|
*/
|
|
84
|
-
declare const countExternalAgents: (db:
|
|
84
|
+
declare const countExternalAgents: (db: AgentsManageDatabaseClient) => (params: {
|
|
85
85
|
scopes: ProjectScopeConfig;
|
|
86
86
|
}) => Promise<number>;
|
|
87
87
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { externalAgents } from "
|
|
1
|
+
import { externalAgents } from "../../db/manage/manage-schema.js";
|
|
2
2
|
import { and, asc, count, desc, eq } from "drizzle-orm";
|
|
3
3
|
|
|
4
|
-
//#region src/data-access/externalAgents.ts
|
|
4
|
+
//#region src/data-access/manage/externalAgents.ts
|
|
5
5
|
/**
|
|
6
6
|
* Create a new external agent
|
|
7
7
|
*/
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { AgentScopeConfig, PaginationConfig } from "../../types/utility.js";
|
|
2
|
+
import { AgentsManageDatabaseClient } from "../../db/manage/manage-client.js";
|
|
3
|
+
import { FunctionToolApiInsert, FunctionToolApiUpdate } from "../../types/entities.js";
|
|
4
4
|
|
|
5
|
-
//#region src/data-access/functionTools.d.ts
|
|
5
|
+
//#region src/data-access/manage/functionTools.d.ts
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Get a function tool by ID (agent-scoped)
|
|
9
9
|
*/
|
|
10
|
-
declare const getFunctionToolById: (db:
|
|
10
|
+
declare const getFunctionToolById: (db: AgentsManageDatabaseClient) => (params: {
|
|
11
11
|
scopes: AgentScopeConfig;
|
|
12
12
|
functionToolId: string;
|
|
13
13
|
}) => Promise<{
|
|
@@ -24,7 +24,7 @@ declare const getFunctionToolById: (db: DatabaseClient) => (params: {
|
|
|
24
24
|
/**
|
|
25
25
|
* List function tools (agent-scoped)
|
|
26
26
|
*/
|
|
27
|
-
declare const listFunctionTools: (db:
|
|
27
|
+
declare const listFunctionTools: (db: AgentsManageDatabaseClient) => (params: {
|
|
28
28
|
scopes: AgentScopeConfig;
|
|
29
29
|
pagination?: PaginationConfig;
|
|
30
30
|
}) => Promise<{
|
|
@@ -49,7 +49,7 @@ declare const listFunctionTools: (db: DatabaseClient) => (params: {
|
|
|
49
49
|
/**
|
|
50
50
|
* Create a function tool (agent-scoped)
|
|
51
51
|
*/
|
|
52
|
-
declare const createFunctionTool: (db:
|
|
52
|
+
declare const createFunctionTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
53
53
|
data: FunctionToolApiInsert;
|
|
54
54
|
scopes: AgentScopeConfig;
|
|
55
55
|
}) => Promise<{
|
|
@@ -66,7 +66,7 @@ declare const createFunctionTool: (db: DatabaseClient) => (params: {
|
|
|
66
66
|
/**
|
|
67
67
|
* Update a function tool (agent-scoped)
|
|
68
68
|
*/
|
|
69
|
-
declare const updateFunctionTool: (db:
|
|
69
|
+
declare const updateFunctionTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
70
70
|
scopes: AgentScopeConfig;
|
|
71
71
|
functionToolId: string;
|
|
72
72
|
data: FunctionToolApiUpdate;
|
|
@@ -84,14 +84,14 @@ declare const updateFunctionTool: (db: DatabaseClient) => (params: {
|
|
|
84
84
|
/**
|
|
85
85
|
* Delete a function tool (agent-scoped)
|
|
86
86
|
*/
|
|
87
|
-
declare const deleteFunctionTool: (db:
|
|
87
|
+
declare const deleteFunctionTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
88
88
|
scopes: AgentScopeConfig;
|
|
89
89
|
functionToolId: string;
|
|
90
90
|
}) => Promise<boolean>;
|
|
91
91
|
/**
|
|
92
92
|
* Upsert a function tool (create if it doesn't exist, update if it does)
|
|
93
93
|
*/
|
|
94
|
-
declare const upsertFunctionTool: (db:
|
|
94
|
+
declare const upsertFunctionTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
95
95
|
data: FunctionToolApiInsert;
|
|
96
96
|
scopes: AgentScopeConfig;
|
|
97
97
|
}) => Promise<{
|
|
@@ -105,7 +105,7 @@ declare const upsertFunctionTool: (db: DatabaseClient) => (params: {
|
|
|
105
105
|
updatedAt: string;
|
|
106
106
|
functionId: string;
|
|
107
107
|
}>;
|
|
108
|
-
declare const getFunctionToolsForSubAgent: (db:
|
|
108
|
+
declare const getFunctionToolsForSubAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
109
109
|
scopes: {
|
|
110
110
|
tenantId: string;
|
|
111
111
|
projectId: string;
|
|
@@ -134,7 +134,7 @@ declare const getFunctionToolsForSubAgent: (db: DatabaseClient) => (params: {
|
|
|
134
134
|
/**
|
|
135
135
|
* Upsert a sub_agent-function tool relation (create if it doesn't exist, update if it does)
|
|
136
136
|
*/
|
|
137
|
-
declare const upsertSubAgentFunctionToolRelation: (db:
|
|
137
|
+
declare const upsertSubAgentFunctionToolRelation: (db: AgentsManageDatabaseClient) => (params: {
|
|
138
138
|
scopes: AgentScopeConfig;
|
|
139
139
|
subAgentId: string;
|
|
140
140
|
functionToolId: string;
|
|
@@ -145,17 +145,24 @@ declare const upsertSubAgentFunctionToolRelation: (db: DatabaseClient) => (param
|
|
|
145
145
|
/**
|
|
146
146
|
* Add a function tool to an agent
|
|
147
147
|
*/
|
|
148
|
-
declare const addFunctionToolToSubAgent: (db:
|
|
148
|
+
declare const addFunctionToolToSubAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
149
149
|
scopes: AgentScopeConfig;
|
|
150
150
|
subAgentId: string;
|
|
151
151
|
functionToolId: string;
|
|
152
152
|
}) => Promise<{
|
|
153
|
+
tenantId: string;
|
|
154
|
+
projectId: string;
|
|
153
155
|
id: string;
|
|
156
|
+
agentId: string;
|
|
157
|
+
createdAt: string;
|
|
158
|
+
updatedAt: string;
|
|
159
|
+
subAgentId: string;
|
|
160
|
+
functionToolId: string;
|
|
154
161
|
}>;
|
|
155
162
|
/**
|
|
156
163
|
* Update an agent-function tool relation
|
|
157
164
|
*/
|
|
158
|
-
declare const updateSubAgentFunctionToolRelation: (db:
|
|
165
|
+
declare const updateSubAgentFunctionToolRelation: (db: AgentsManageDatabaseClient) => (params: {
|
|
159
166
|
scopes: AgentScopeConfig;
|
|
160
167
|
relationId: string;
|
|
161
168
|
data: {
|
|
@@ -165,5 +172,48 @@ declare const updateSubAgentFunctionToolRelation: (db: DatabaseClient) => (param
|
|
|
165
172
|
}) => Promise<{
|
|
166
173
|
id: string;
|
|
167
174
|
}>;
|
|
175
|
+
/**
|
|
176
|
+
* Get all sub-agents that use a specific function tool
|
|
177
|
+
*/
|
|
178
|
+
declare const getSubAgentsUsingFunctionTool: (db: AgentsManageDatabaseClient) => (params: {
|
|
179
|
+
scopes: AgentScopeConfig;
|
|
180
|
+
functionToolId: string;
|
|
181
|
+
}) => Promise<{
|
|
182
|
+
subAgentId: string;
|
|
183
|
+
createdAt: string;
|
|
184
|
+
}[]>;
|
|
185
|
+
/**
|
|
186
|
+
* Remove a function tool from a sub-agent
|
|
187
|
+
*/
|
|
188
|
+
declare const removeFunctionToolFromSubAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
189
|
+
scopes: AgentScopeConfig;
|
|
190
|
+
subAgentId: string;
|
|
191
|
+
functionToolId: string;
|
|
192
|
+
}) => Promise<boolean>;
|
|
193
|
+
/**
|
|
194
|
+
* Check if a function tool is associated with a sub-agent
|
|
195
|
+
*/
|
|
196
|
+
declare const isFunctionToolAssociatedWithSubAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
197
|
+
scopes: AgentScopeConfig;
|
|
198
|
+
subAgentId: string;
|
|
199
|
+
functionToolId: string;
|
|
200
|
+
}) => Promise<boolean>;
|
|
201
|
+
/**
|
|
202
|
+
* Associate a function tool with a sub-agent (alias for addFunctionToolToSubAgent)
|
|
203
|
+
*/
|
|
204
|
+
declare const associateFunctionToolWithSubAgent: (db: AgentsManageDatabaseClient) => (params: {
|
|
205
|
+
scopes: AgentScopeConfig;
|
|
206
|
+
subAgentId: string;
|
|
207
|
+
functionToolId: string;
|
|
208
|
+
}) => Promise<{
|
|
209
|
+
tenantId: string;
|
|
210
|
+
projectId: string;
|
|
211
|
+
id: string;
|
|
212
|
+
agentId: string;
|
|
213
|
+
createdAt: string;
|
|
214
|
+
updatedAt: string;
|
|
215
|
+
subAgentId: string;
|
|
216
|
+
functionToolId: string;
|
|
217
|
+
}>;
|
|
168
218
|
//#endregion
|
|
169
|
-
export { addFunctionToolToSubAgent, createFunctionTool, deleteFunctionTool, getFunctionToolById, getFunctionToolsForSubAgent, listFunctionTools, updateFunctionTool, updateSubAgentFunctionToolRelation, upsertFunctionTool, upsertSubAgentFunctionToolRelation };
|
|
219
|
+
export { addFunctionToolToSubAgent, associateFunctionToolWithSubAgent, createFunctionTool, deleteFunctionTool, getFunctionToolById, getFunctionToolsForSubAgent, getSubAgentsUsingFunctionTool, isFunctionToolAssociatedWithSubAgent, listFunctionTools, removeFunctionToolFromSubAgent, updateFunctionTool, updateSubAgentFunctionToolRelation, upsertFunctionTool, upsertSubAgentFunctionToolRelation };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { functionTools, subAgentFunctionToolRelations } from "
|
|
2
|
-
import { getLogger } from "
|
|
3
|
-
import { generateId } from "
|
|
1
|
+
import { functionTools, subAgentFunctionToolRelations } from "../../db/manage/manage-schema.js";
|
|
2
|
+
import { getLogger } from "../../utils/logger.js";
|
|
3
|
+
import { generateId } from "../../utils/conversations.js";
|
|
4
4
|
import { and, count, desc, eq } from "drizzle-orm";
|
|
5
5
|
|
|
6
|
-
//#region src/data-access/functionTools.ts
|
|
6
|
+
//#region src/data-access/manage/functionTools.ts
|
|
7
7
|
const logger = getLogger("functionTools");
|
|
8
8
|
/**
|
|
9
9
|
* Get a function tool by ID (agent-scoped)
|
|
@@ -177,14 +177,14 @@ const addFunctionToolToSubAgent = (db) => {
|
|
|
177
177
|
const { tenantId, projectId, agentId } = scopes;
|
|
178
178
|
try {
|
|
179
179
|
const relationId = generateId();
|
|
180
|
-
await db.insert(subAgentFunctionToolRelations).values({
|
|
180
|
+
const [result] = await db.insert(subAgentFunctionToolRelations).values({
|
|
181
181
|
id: relationId,
|
|
182
182
|
tenantId,
|
|
183
183
|
projectId,
|
|
184
184
|
agentId,
|
|
185
185
|
subAgentId,
|
|
186
186
|
functionToolId
|
|
187
|
-
});
|
|
187
|
+
}).returning();
|
|
188
188
|
logger.info({
|
|
189
189
|
tenantId,
|
|
190
190
|
projectId,
|
|
@@ -193,7 +193,7 @@ const addFunctionToolToSubAgent = (db) => {
|
|
|
193
193
|
functionToolId,
|
|
194
194
|
relationId
|
|
195
195
|
}, "Function tool added to sub_agent");
|
|
196
|
-
return
|
|
196
|
+
return result;
|
|
197
197
|
} catch (error) {
|
|
198
198
|
logger.error({
|
|
199
199
|
tenantId,
|
|
@@ -240,6 +240,88 @@ const updateSubAgentFunctionToolRelation = (db) => {
|
|
|
240
240
|
}
|
|
241
241
|
};
|
|
242
242
|
};
|
|
243
|
+
/**
|
|
244
|
+
* Get all sub-agents that use a specific function tool
|
|
245
|
+
*/
|
|
246
|
+
const getSubAgentsUsingFunctionTool = (db) => {
|
|
247
|
+
return async (params) => {
|
|
248
|
+
const { scopes, functionToolId } = params;
|
|
249
|
+
const { tenantId, projectId, agentId } = scopes;
|
|
250
|
+
try {
|
|
251
|
+
return await db.select({
|
|
252
|
+
subAgentId: subAgentFunctionToolRelations.subAgentId,
|
|
253
|
+
createdAt: subAgentFunctionToolRelations.createdAt
|
|
254
|
+
}).from(subAgentFunctionToolRelations).where(and(eq(subAgentFunctionToolRelations.tenantId, tenantId), eq(subAgentFunctionToolRelations.projectId, projectId), eq(subAgentFunctionToolRelations.agentId, agentId), eq(subAgentFunctionToolRelations.functionToolId, functionToolId)));
|
|
255
|
+
} catch (error) {
|
|
256
|
+
logger.error({
|
|
257
|
+
tenantId,
|
|
258
|
+
projectId,
|
|
259
|
+
agentId,
|
|
260
|
+
functionToolId,
|
|
261
|
+
error
|
|
262
|
+
}, "Failed to get sub-agents using function tool");
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Remove a function tool from a sub-agent
|
|
269
|
+
*/
|
|
270
|
+
const removeFunctionToolFromSubAgent = (db) => {
|
|
271
|
+
return async (params) => {
|
|
272
|
+
const { scopes, subAgentId, functionToolId } = params;
|
|
273
|
+
const { tenantId, projectId, agentId } = scopes;
|
|
274
|
+
try {
|
|
275
|
+
const removed = (await db.delete(subAgentFunctionToolRelations).where(and(eq(subAgentFunctionToolRelations.tenantId, tenantId), eq(subAgentFunctionToolRelations.projectId, projectId), eq(subAgentFunctionToolRelations.agentId, agentId), eq(subAgentFunctionToolRelations.subAgentId, subAgentId), eq(subAgentFunctionToolRelations.functionToolId, functionToolId))).returning()).length > 0;
|
|
276
|
+
if (removed) logger.info({
|
|
277
|
+
tenantId,
|
|
278
|
+
projectId,
|
|
279
|
+
agentId,
|
|
280
|
+
subAgentId,
|
|
281
|
+
functionToolId
|
|
282
|
+
}, "Function tool removed from sub-agent");
|
|
283
|
+
return removed;
|
|
284
|
+
} catch (error) {
|
|
285
|
+
logger.error({
|
|
286
|
+
tenantId,
|
|
287
|
+
projectId,
|
|
288
|
+
agentId,
|
|
289
|
+
subAgentId,
|
|
290
|
+
functionToolId,
|
|
291
|
+
error
|
|
292
|
+
}, "Failed to remove function tool from sub-agent");
|
|
293
|
+
throw error;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Check if a function tool is associated with a sub-agent
|
|
299
|
+
*/
|
|
300
|
+
const isFunctionToolAssociatedWithSubAgent = (db) => {
|
|
301
|
+
return async (params) => {
|
|
302
|
+
const { scopes, subAgentId, functionToolId } = params;
|
|
303
|
+
const { tenantId, projectId, agentId } = scopes;
|
|
304
|
+
try {
|
|
305
|
+
return (await db.select({ id: subAgentFunctionToolRelations.id }).from(subAgentFunctionToolRelations).where(and(eq(subAgentFunctionToolRelations.tenantId, tenantId), eq(subAgentFunctionToolRelations.projectId, projectId), eq(subAgentFunctionToolRelations.agentId, agentId), eq(subAgentFunctionToolRelations.subAgentId, subAgentId), eq(subAgentFunctionToolRelations.functionToolId, functionToolId))).limit(1)).length > 0;
|
|
306
|
+
} catch (error) {
|
|
307
|
+
logger.error({
|
|
308
|
+
tenantId,
|
|
309
|
+
projectId,
|
|
310
|
+
agentId,
|
|
311
|
+
subAgentId,
|
|
312
|
+
functionToolId,
|
|
313
|
+
error
|
|
314
|
+
}, "Failed to check function tool association with sub-agent");
|
|
315
|
+
throw error;
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* Associate a function tool with a sub-agent (alias for addFunctionToolToSubAgent)
|
|
321
|
+
*/
|
|
322
|
+
const associateFunctionToolWithSubAgent = (db) => {
|
|
323
|
+
return addFunctionToolToSubAgent(db);
|
|
324
|
+
};
|
|
243
325
|
|
|
244
326
|
//#endregion
|
|
245
|
-
export { addFunctionToolToSubAgent, createFunctionTool, deleteFunctionTool, getFunctionToolById, getFunctionToolsForSubAgent, listFunctionTools, updateFunctionTool, updateSubAgentFunctionToolRelation, upsertFunctionTool, upsertSubAgentFunctionToolRelation };
|
|
327
|
+
export { addFunctionToolToSubAgent, associateFunctionToolWithSubAgent, createFunctionTool, deleteFunctionTool, getFunctionToolById, getFunctionToolsForSubAgent, getSubAgentsUsingFunctionTool, isFunctionToolAssociatedWithSubAgent, listFunctionTools, removeFunctionToolFromSubAgent, updateFunctionTool, updateSubAgentFunctionToolRelation, upsertFunctionTool, upsertSubAgentFunctionToolRelation };
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { PaginationConfig, ProjectScopeConfig } from "../../types/utility.js";
|
|
2
|
+
import { AgentsManageDatabaseClient } from "../../db/manage/manage-client.js";
|
|
3
|
+
import { FunctionApiInsert } from "../../types/entities.js";
|
|
4
4
|
|
|
5
|
-
//#region src/data-access/functions.d.ts
|
|
5
|
+
//#region src/data-access/manage/functions.d.ts
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Create or update a function (project-scoped)
|
|
9
9
|
*/
|
|
10
|
-
declare const upsertFunction: (db:
|
|
10
|
+
declare const upsertFunction: (db: AgentsManageDatabaseClient) => (params: {
|
|
11
11
|
data: FunctionApiInsert;
|
|
12
12
|
scopes: ProjectScopeConfig;
|
|
13
13
|
}) => Promise<void>;
|
|
14
14
|
/**
|
|
15
15
|
* Get a function by ID (project-scoped)
|
|
16
16
|
*/
|
|
17
|
-
declare const getFunction: (db:
|
|
17
|
+
declare const getFunction: (db: AgentsManageDatabaseClient) => (params: {
|
|
18
18
|
functionId: string;
|
|
19
19
|
scopes: ProjectScopeConfig;
|
|
20
20
|
}) => Promise<FunctionApiInsert | null>;
|
|
21
21
|
/**
|
|
22
22
|
* List all functions for a project
|
|
23
23
|
*/
|
|
24
|
-
declare const listFunctions: (db:
|
|
24
|
+
declare const listFunctions: (db: AgentsManageDatabaseClient) => (params: {
|
|
25
25
|
scopes: ProjectScopeConfig;
|
|
26
26
|
}) => Promise<FunctionApiInsert[]>;
|
|
27
27
|
/**
|
|
28
28
|
* List all functions for a project with pagination
|
|
29
29
|
*/
|
|
30
|
-
declare const listFunctionsPaginated: (db:
|
|
30
|
+
declare const listFunctionsPaginated: (db: AgentsManageDatabaseClient) => (params: {
|
|
31
31
|
scopes: ProjectScopeConfig;
|
|
32
32
|
pagination?: PaginationConfig;
|
|
33
33
|
}) => Promise<{
|
|
@@ -51,7 +51,7 @@ declare const listFunctionsPaginated: (db: DatabaseClient) => (params: {
|
|
|
51
51
|
/**
|
|
52
52
|
* Delete a function (project-scoped)
|
|
53
53
|
*/
|
|
54
|
-
declare const deleteFunction: (db:
|
|
54
|
+
declare const deleteFunction: (db: AgentsManageDatabaseClient) => (params: {
|
|
55
55
|
functionId: string;
|
|
56
56
|
scopes: ProjectScopeConfig;
|
|
57
57
|
}) => Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { functions } from "
|
|
1
|
+
import { functions } from "../../db/manage/manage-schema.js";
|
|
2
2
|
import { and, count, desc, eq } from "drizzle-orm";
|
|
3
3
|
|
|
4
|
-
//#region src/data-access/functions.ts
|
|
4
|
+
//#region src/data-access/manage/functions.ts
|
|
5
5
|
/**
|
|
6
6
|
* Create or update a function (project-scoped)
|
|
7
7
|
*/
|
|
@@ -10,7 +10,7 @@ const upsertFunction = (db) => async (params) => {
|
|
|
10
10
|
const { tenantId, projectId } = scopes;
|
|
11
11
|
let dependencies = data.dependencies;
|
|
12
12
|
if (!dependencies || Object.keys(dependencies).length === 0) {
|
|
13
|
-
const { autoDetectDependencies } = await import("
|
|
13
|
+
const { autoDetectDependencies } = await import("../../utils/detectDependencies.js");
|
|
14
14
|
dependencies = autoDetectDependencies(data.executeCode);
|
|
15
15
|
}
|
|
16
16
|
if ((await db.select().from(functions).where(and(eq(functions.tenantId, tenantId), eq(functions.projectId, projectId), eq(functions.id, data.id))).limit(1)).length > 0) await db.update(functions).set({
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ProjectScopeConfig } from "../../types/utility.js";
|
|
2
|
+
import { getLogger } from "../../utils/logger.js";
|
|
3
|
+
import { AgentsManageDatabaseClient } from "../../db/manage/manage-client.js";
|
|
4
|
+
import { FullProjectDefinition, FullProjectSelect, FullProjectSelectWithRelationIds } from "../../types/entities.js";
|
|
5
|
+
|
|
6
|
+
//#region src/data-access/manage/projectFull.d.ts
|
|
7
|
+
|
|
8
|
+
type ProjectLogger = ReturnType<typeof getLogger>;
|
|
9
|
+
/**
|
|
10
|
+
* Server-side implementation of createFullProject that performs actual database operations.
|
|
11
|
+
* This function creates a complete project with all agent and their nested resources.
|
|
12
|
+
*/
|
|
13
|
+
declare const createFullProjectServerSide: (db: AgentsManageDatabaseClient, logger?: ProjectLogger) => (params: {
|
|
14
|
+
scopes: ProjectScopeConfig;
|
|
15
|
+
projectData: FullProjectDefinition;
|
|
16
|
+
}) => Promise<FullProjectSelect>;
|
|
17
|
+
/**
|
|
18
|
+
* Server-side implementation of updateFullProject that performs actual database operations.
|
|
19
|
+
* This function updates a complete project with all agent and their nested resources.
|
|
20
|
+
*/
|
|
21
|
+
declare const updateFullProjectServerSide: (db: AgentsManageDatabaseClient, logger?: ProjectLogger) => (params: {
|
|
22
|
+
scopes: ProjectScopeConfig;
|
|
23
|
+
projectData: FullProjectDefinition;
|
|
24
|
+
}) => Promise<FullProjectSelect>;
|
|
25
|
+
declare const getFullProject: (db: AgentsManageDatabaseClient, logger?: ProjectLogger) => (params: {
|
|
26
|
+
scopes: ProjectScopeConfig;
|
|
27
|
+
}) => Promise<FullProjectSelect | null>;
|
|
28
|
+
declare const getFullProjectWithRelationIds: (db: AgentsManageDatabaseClient, logger?: ProjectLogger) => (params: {
|
|
29
|
+
scopes: ProjectScopeConfig;
|
|
30
|
+
}) => Promise<FullProjectSelectWithRelationIds | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Delete a complete project and cascade to all related entities
|
|
33
|
+
*/
|
|
34
|
+
declare const deleteFullProject: (db: AgentsManageDatabaseClient, logger?: ProjectLogger) => (params: {
|
|
35
|
+
scopes: ProjectScopeConfig;
|
|
36
|
+
}) => Promise<boolean>;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { ProjectLogger, createFullProjectServerSide, deleteFullProject, getFullProject, getFullProjectWithRelationIds, updateFullProjectServerSide };
|