@inkeep/agents-core 0.41.2 → 0.43.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 +60 -2
- package/dist/auth/authz/client.d.ts +87 -0
- package/dist/auth/authz/client.js +196 -0
- package/dist/auth/authz/config.d.ts +103 -0
- package/dist/auth/authz/config.js +93 -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 +53 -0
- package/dist/auth/authz/permissions.js +83 -0
- package/dist/auth/authz/sync.d.ts +106 -0
- package/dist/auth/authz/sync.js +321 -0
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/auth/permissions.js +2 -181
- package/dist/client-exports.d.ts +9 -3
- package/dist/client-exports.js +4 -2
- package/dist/constants/context-breakdown.d.ts +61 -0
- package/dist/constants/context-breakdown.js +124 -0
- package/dist/constants/execution-limits-shared/defaults.d.ts +1 -1
- package/dist/constants/execution-limits-shared/defaults.js +1 -1
- package/dist/constants/execution-limits-shared/index.d.ts +1 -1
- 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.d.ts +0 -6
- package/dist/context/TemplateEngine.js +4 -19
- package/dist/context/index.d.ts +1 -5
- package/dist/context/index.js +1 -5
- package/dist/credential-stores/keychain-store.d.ts +20 -8
- package/dist/credential-stores/keychain-store.js +107 -43
- 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} +209 -7
- package/dist/data-access/{agents.d.ts → manage/agents.d.ts} +64 -63
- package/dist/data-access/{agents.js → manage/agents.js} +80 -27
- package/dist/data-access/{artifactComponents.d.ts → manage/artifactComponents.d.ts} +33 -33
- package/dist/data-access/{artifactComponents.js → manage/artifactComponents.js} +5 -5
- package/dist/data-access/{contextConfigs.d.ts → manage/contextConfigs.d.ts} +26 -26
- 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} +26 -26
- 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/manage/functionTools.d.ts +242 -0
- package/dist/data-access/{functionTools.js → manage/functionTools.js} +124 -30
- 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} +43 -43
- package/dist/data-access/{subAgentExternalAgentRelations.js → manage/subAgentExternalAgentRelations.js} +2 -2
- package/dist/data-access/{subAgentRelations.d.ts → manage/subAgentRelations.d.ts} +65 -65
- package/dist/data-access/{subAgentRelations.js → manage/subAgentRelations.js} +3 -3
- package/dist/data-access/{subAgentTeamAgentRelations.d.ts → manage/subAgentTeamAgentRelations.d.ts} +43 -43
- package/dist/data-access/{subAgentTeamAgentRelations.js → manage/subAgentTeamAgentRelations.js} +2 -2
- package/dist/data-access/{subAgents.d.ts → manage/subAgents.d.ts} +28 -28
- package/dist/data-access/{subAgents.js → manage/subAgents.js} +4 -4
- package/dist/data-access/{tools.d.ts → manage/tools.d.ts} +65 -52
- package/dist/data-access/{tools.js → manage/tools.js} +109 -64
- package/dist/data-access/manage/triggers.d.ts +106 -0
- package/dist/data-access/manage/triggers.js +81 -0
- package/dist/data-access/{apiKeys.d.ts → runtime/apiKeys.d.ts} +37 -37
- 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} +80 -31
- 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} +24 -24
- 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} +16 -4
- 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} +1257 -969
- package/dist/db/{schema.js → manage/manage-schema.js} +436 -334
- 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/db/utils.d.ts +6 -0
- package/dist/db/utils.js +42 -0
- 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 +83 -0
- package/dist/dolt/migrate-dolt.d.ts +1 -0
- package/dist/dolt/migrate-dolt.js +25 -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 +135 -0
- package/dist/dolt/schema-sync.js +255 -0
- package/dist/env.d.ts +6 -4
- package/dist/env.js +3 -2
- package/dist/index.d.ts +73 -46
- package/dist/index.js +76 -49
- package/dist/types/@napi-rs__keyring/index.d.ts +14 -0
- package/dist/types/entities.d.ts +81 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/utility.d.ts +46 -5
- package/dist/types/utility.js +2 -1
- package/dist/utils/JsonTransformer.d.ts +42 -0
- package/dist/utils/JsonTransformer.js +103 -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 +8 -4
- package/dist/utils/index.js +8 -4
- package/dist/utils/internal-service-auth.d.ts +79 -0
- package/dist/utils/internal-service-auth.js +140 -0
- package/dist/utils/jmespath-utils.d.ts +152 -0
- package/dist/utils/jmespath-utils.js +213 -0
- package/dist/utils/jwt-helpers.d.ts +56 -0
- package/dist/utils/jwt-helpers.js +90 -0
- package/dist/utils/mcp-client.d.ts +1 -1
- package/dist/utils/mcp-client.js +1 -1
- package/dist/utils/service-token-auth.d.ts +9 -27
- package/dist/utils/service-token-auth.js +48 -96
- package/dist/utils/signature-validation.d.ts +2 -0
- package/dist/utils/signature-validation.js +3 -0
- 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.d.ts +13 -1
- package/dist/utils/third-party-mcp-servers/composio-client.js +47 -29
- package/dist/utils/third-party-mcp-servers/index.d.ts +2 -2
- package/dist/utils/third-party-mcp-servers/index.js +2 -2
- package/dist/utils/trigger-auth.d.ts +85 -0
- package/dist/utils/trigger-auth.js +233 -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 +5 -4
- package/dist/validation/index.js +4 -3
- package/dist/validation/render-validation.js +19 -0
- package/dist/validation/schemas.d.ts +18223 -5148
- package/dist/validation/schemas.js +559 -12
- package/dist/validation/stream-event-schemas.d.ts +96 -1
- package/dist/validation/stream-event-schemas.js +67 -2
- 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/0003_tiny_captain_universe.sql +8 -0
- package/drizzle/manage/0004_curious_phil_sheldon.sql +2 -0
- package/drizzle/manage/0005_silent_shatterstar.sql +53 -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/0003_snapshot.json +3134 -0
- package/drizzle/manage/meta/0004_snapshot.json +3141 -0
- package/drizzle/manage/meta/0005_snapshot.json +3141 -0
- package/drizzle/manage/meta/_journal.json +48 -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 +56 -18
- package/spicedb/schema.zed +114 -0
- 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/functionTools.d.ts +0 -169
- 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,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)
|
|
@@ -96,32 +96,41 @@ const upsertFunctionTool = (db) => async (params) => {
|
|
|
96
96
|
};
|
|
97
97
|
const getFunctionToolsForSubAgent = (db) => {
|
|
98
98
|
return async (params) => {
|
|
99
|
-
const
|
|
100
|
-
const
|
|
99
|
+
const page = params.pagination?.page || 1;
|
|
100
|
+
const limit = Math.min(params.pagination?.limit || 1e3, 1e3);
|
|
101
|
+
const offset = (page - 1) * limit;
|
|
102
|
+
const { tenantId, projectId, agentId } = params.scopes;
|
|
101
103
|
try {
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
const whereClause = and(eq(subAgentFunctionToolRelations.tenantId, tenantId), eq(subAgentFunctionToolRelations.projectId, projectId), eq(subAgentFunctionToolRelations.agentId, agentId), eq(subAgentFunctionToolRelations.subAgentId, params.subAgentId));
|
|
105
|
+
const [data, totalResult] = await Promise.all([db.select({
|
|
106
|
+
id: functionTools.id,
|
|
107
|
+
name: functionTools.name,
|
|
108
|
+
description: functionTools.description,
|
|
109
|
+
functionId: functionTools.functionId,
|
|
110
|
+
createdAt: functionTools.createdAt,
|
|
111
|
+
updatedAt: functionTools.updatedAt,
|
|
112
|
+
tenantId: functionTools.tenantId,
|
|
113
|
+
projectId: functionTools.projectId,
|
|
114
|
+
agentId: functionTools.agentId,
|
|
115
|
+
relationshipId: subAgentFunctionToolRelations.id,
|
|
116
|
+
toolPolicies: subAgentFunctionToolRelations.toolPolicies
|
|
117
|
+
}).from(subAgentFunctionToolRelations).innerJoin(functionTools, and(eq(subAgentFunctionToolRelations.functionToolId, functionTools.id), eq(subAgentFunctionToolRelations.tenantId, functionTools.tenantId), eq(subAgentFunctionToolRelations.projectId, functionTools.projectId), eq(subAgentFunctionToolRelations.agentId, functionTools.agentId))).where(whereClause).limit(limit).offset(offset).orderBy(desc(subAgentFunctionToolRelations.createdAt)), db.select({ count: count() }).from(subAgentFunctionToolRelations).where(whereClause)]);
|
|
118
|
+
const total = totalResult[0]?.count || 0;
|
|
119
|
+
return {
|
|
120
|
+
data,
|
|
108
121
|
pagination: {
|
|
109
|
-
page
|
|
110
|
-
limit
|
|
122
|
+
page,
|
|
123
|
+
limit,
|
|
124
|
+
total,
|
|
125
|
+
pages: Math.ceil(total / limit)
|
|
111
126
|
}
|
|
112
|
-
});
|
|
113
|
-
const relations$1 = await db.select().from(subAgentFunctionToolRelations).where(and(eq(subAgentFunctionToolRelations.tenantId, tenantId), eq(subAgentFunctionToolRelations.projectId, projectId), eq(subAgentFunctionToolRelations.agentId, agentId), eq(subAgentFunctionToolRelations.subAgentId, subAgentId)));
|
|
114
|
-
const relatedFunctionToolIds = new Set(relations$1.map((r) => r.functionToolId));
|
|
115
|
-
return {
|
|
116
|
-
data: functionToolsList.data.filter((ft) => relatedFunctionToolIds.has(ft.id)),
|
|
117
|
-
pagination: functionToolsList.pagination
|
|
118
127
|
};
|
|
119
128
|
} catch (error) {
|
|
120
129
|
logger.error({
|
|
121
130
|
tenantId,
|
|
122
131
|
projectId,
|
|
123
132
|
agentId,
|
|
124
|
-
subAgentId,
|
|
133
|
+
subAgentId: params.subAgentId,
|
|
125
134
|
error
|
|
126
135
|
}, "Failed to get function tools for agent");
|
|
127
136
|
throw error;
|
|
@@ -132,14 +141,15 @@ const getFunctionToolsForSubAgent = (db) => {
|
|
|
132
141
|
* Upsert a sub_agent-function tool relation (create if it doesn't exist, update if it does)
|
|
133
142
|
*/
|
|
134
143
|
const upsertSubAgentFunctionToolRelation = (db) => async (params) => {
|
|
135
|
-
const { scopes, subAgentId, functionToolId, relationId } = params;
|
|
144
|
+
const { scopes, subAgentId, functionToolId, toolPolicies, relationId } = params;
|
|
136
145
|
const { tenantId, projectId, agentId } = scopes;
|
|
137
146
|
if (relationId) return await updateSubAgentFunctionToolRelation(db)({
|
|
138
147
|
scopes,
|
|
139
148
|
relationId,
|
|
140
149
|
data: {
|
|
141
150
|
subAgentId,
|
|
142
|
-
functionToolId
|
|
151
|
+
functionToolId,
|
|
152
|
+
...toolPolicies !== void 0 ? { toolPolicies } : {}
|
|
143
153
|
}
|
|
144
154
|
});
|
|
145
155
|
try {
|
|
@@ -173,18 +183,19 @@ const upsertSubAgentFunctionToolRelation = (db) => async (params) => {
|
|
|
173
183
|
*/
|
|
174
184
|
const addFunctionToolToSubAgent = (db) => {
|
|
175
185
|
return async (params) => {
|
|
176
|
-
const { scopes, subAgentId, functionToolId } = params;
|
|
186
|
+
const { scopes, subAgentId, functionToolId, toolPolicies } = params;
|
|
177
187
|
const { tenantId, projectId, agentId } = scopes;
|
|
178
188
|
try {
|
|
179
189
|
const relationId = generateId();
|
|
180
|
-
await db.insert(subAgentFunctionToolRelations).values({
|
|
190
|
+
const [result] = await db.insert(subAgentFunctionToolRelations).values({
|
|
181
191
|
id: relationId,
|
|
182
192
|
tenantId,
|
|
183
193
|
projectId,
|
|
184
194
|
agentId,
|
|
185
195
|
subAgentId,
|
|
186
|
-
functionToolId
|
|
187
|
-
|
|
196
|
+
functionToolId,
|
|
197
|
+
...toolPolicies !== void 0 ? { toolPolicies } : {}
|
|
198
|
+
}).returning();
|
|
188
199
|
logger.info({
|
|
189
200
|
tenantId,
|
|
190
201
|
projectId,
|
|
@@ -193,7 +204,7 @@ const addFunctionToolToSubAgent = (db) => {
|
|
|
193
204
|
functionToolId,
|
|
194
205
|
relationId
|
|
195
206
|
}, "Function tool added to sub_agent");
|
|
196
|
-
return
|
|
207
|
+
return result;
|
|
197
208
|
} catch (error) {
|
|
198
209
|
logger.error({
|
|
199
210
|
tenantId,
|
|
@@ -217,7 +228,8 @@ const updateSubAgentFunctionToolRelation = (db) => {
|
|
|
217
228
|
try {
|
|
218
229
|
await db.update(subAgentFunctionToolRelations).set({
|
|
219
230
|
subAgentId: data.subAgentId,
|
|
220
|
-
functionToolId: data.functionToolId
|
|
231
|
+
functionToolId: data.functionToolId,
|
|
232
|
+
...data.toolPolicies !== void 0 ? { toolPolicies: data.toolPolicies } : {}
|
|
221
233
|
}).where(and(eq(subAgentFunctionToolRelations.id, relationId), eq(subAgentFunctionToolRelations.tenantId, tenantId), eq(subAgentFunctionToolRelations.projectId, projectId), eq(subAgentFunctionToolRelations.agentId, agentId)));
|
|
222
234
|
logger.info({
|
|
223
235
|
tenantId,
|
|
@@ -240,6 +252,88 @@ const updateSubAgentFunctionToolRelation = (db) => {
|
|
|
240
252
|
}
|
|
241
253
|
};
|
|
242
254
|
};
|
|
255
|
+
/**
|
|
256
|
+
* Get all sub-agents that use a specific function tool
|
|
257
|
+
*/
|
|
258
|
+
const getSubAgentsUsingFunctionTool = (db) => {
|
|
259
|
+
return async (params) => {
|
|
260
|
+
const { scopes, functionToolId } = params;
|
|
261
|
+
const { tenantId, projectId, agentId } = scopes;
|
|
262
|
+
try {
|
|
263
|
+
return await db.select({
|
|
264
|
+
subAgentId: subAgentFunctionToolRelations.subAgentId,
|
|
265
|
+
createdAt: subAgentFunctionToolRelations.createdAt
|
|
266
|
+
}).from(subAgentFunctionToolRelations).where(and(eq(subAgentFunctionToolRelations.tenantId, tenantId), eq(subAgentFunctionToolRelations.projectId, projectId), eq(subAgentFunctionToolRelations.agentId, agentId), eq(subAgentFunctionToolRelations.functionToolId, functionToolId)));
|
|
267
|
+
} catch (error) {
|
|
268
|
+
logger.error({
|
|
269
|
+
tenantId,
|
|
270
|
+
projectId,
|
|
271
|
+
agentId,
|
|
272
|
+
functionToolId,
|
|
273
|
+
error
|
|
274
|
+
}, "Failed to get sub-agents using function tool");
|
|
275
|
+
throw error;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* Remove a function tool from a sub-agent
|
|
281
|
+
*/
|
|
282
|
+
const removeFunctionToolFromSubAgent = (db) => {
|
|
283
|
+
return async (params) => {
|
|
284
|
+
const { scopes, subAgentId, functionToolId } = params;
|
|
285
|
+
const { tenantId, projectId, agentId } = scopes;
|
|
286
|
+
try {
|
|
287
|
+
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;
|
|
288
|
+
if (removed) logger.info({
|
|
289
|
+
tenantId,
|
|
290
|
+
projectId,
|
|
291
|
+
agentId,
|
|
292
|
+
subAgentId,
|
|
293
|
+
functionToolId
|
|
294
|
+
}, "Function tool removed from sub-agent");
|
|
295
|
+
return removed;
|
|
296
|
+
} catch (error) {
|
|
297
|
+
logger.error({
|
|
298
|
+
tenantId,
|
|
299
|
+
projectId,
|
|
300
|
+
agentId,
|
|
301
|
+
subAgentId,
|
|
302
|
+
functionToolId,
|
|
303
|
+
error
|
|
304
|
+
}, "Failed to remove function tool from sub-agent");
|
|
305
|
+
throw error;
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* Check if a function tool is associated with a sub-agent
|
|
311
|
+
*/
|
|
312
|
+
const isFunctionToolAssociatedWithSubAgent = (db) => {
|
|
313
|
+
return async (params) => {
|
|
314
|
+
const { scopes, subAgentId, functionToolId } = params;
|
|
315
|
+
const { tenantId, projectId, agentId } = scopes;
|
|
316
|
+
try {
|
|
317
|
+
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;
|
|
318
|
+
} catch (error) {
|
|
319
|
+
logger.error({
|
|
320
|
+
tenantId,
|
|
321
|
+
projectId,
|
|
322
|
+
agentId,
|
|
323
|
+
subAgentId,
|
|
324
|
+
functionToolId,
|
|
325
|
+
error
|
|
326
|
+
}, "Failed to check function tool association with sub-agent");
|
|
327
|
+
throw error;
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* Associate a function tool with a sub-agent (alias for addFunctionToolToSubAgent)
|
|
333
|
+
*/
|
|
334
|
+
const associateFunctionToolWithSubAgent = (db) => {
|
|
335
|
+
return addFunctionToolToSubAgent(db);
|
|
336
|
+
};
|
|
243
337
|
|
|
244
338
|
//#endregion
|
|
245
|
-
export { addFunctionToolToSubAgent, createFunctionTool, deleteFunctionTool, getFunctionToolById, getFunctionToolsForSubAgent, listFunctionTools, updateFunctionTool, updateSubAgentFunctionToolRelation, upsertFunctionTool, upsertSubAgentFunctionToolRelation };
|
|
339
|
+
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 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getLogger } from "
|
|
1
|
+
import { getLogger } from "../../utils/logger.js";
|
|
2
2
|
import { deleteExternalAgent, listExternalAgents, upsertExternalAgent } from "./externalAgents.js";
|
|
3
3
|
import { deleteFunction, listFunctions, upsertFunction } from "./functions.js";
|
|
4
4
|
import { deleteCredentialReference, listCredentialReferences, upsertCredentialReference } from "./credentialReferences.js";
|
|
@@ -6,10 +6,10 @@ import { deleteTool, listTools, upsertTool } from "./tools.js";
|
|
|
6
6
|
import { listAgents } from "./agents.js";
|
|
7
7
|
import { deleteArtifactComponent, listArtifactComponents, upsertArtifactComponent } from "./artifactComponents.js";
|
|
8
8
|
import { deleteDataComponent, listDataComponents, upsertDataComponent } from "./dataComponents.js";
|
|
9
|
-
import { createFullAgentServerSide, deleteFullAgent, getFullAgent, updateFullAgentServerSide } from "./agentFull.js";
|
|
9
|
+
import { createFullAgentServerSide, deleteFullAgent, getFullAgent, getFullAgentWithRelationIds, updateFullAgentServerSide } from "./agentFull.js";
|
|
10
10
|
import { createProject, deleteProject, getProject, updateProject } from "./projects.js";
|
|
11
11
|
|
|
12
|
-
//#region src/data-access/projectFull.ts
|
|
12
|
+
//#region src/data-access/manage/projectFull.ts
|
|
13
13
|
const defaultLogger = getLogger("projectFull");
|
|
14
14
|
/**
|
|
15
15
|
* Validate and type the project data
|
|
@@ -21,7 +21,8 @@ function validateAndTypeProjectData(projectData) {
|
|
|
21
21
|
* Server-side implementation of createFullProject that performs actual database operations.
|
|
22
22
|
* This function creates a complete project with all agent and their nested resources.
|
|
23
23
|
*/
|
|
24
|
-
const createFullProjectServerSide = (db, logger = defaultLogger) => async (
|
|
24
|
+
const createFullProjectServerSide = (db, logger = defaultLogger) => async (params) => {
|
|
25
|
+
const { scopes, projectData } = params;
|
|
25
26
|
const { tenantId } = scopes;
|
|
26
27
|
const typed = validateAndTypeProjectData(projectData);
|
|
27
28
|
logger.info({
|
|
@@ -336,10 +337,12 @@ const createFullProjectServerSide = (db, logger = defaultLogger) => async (scope
|
|
|
336
337
|
}, "Phase 2 complete: All sub-agents added successfully");
|
|
337
338
|
}
|
|
338
339
|
logger.info({ projectId: typed.id }, "Full project created successfully");
|
|
339
|
-
|
|
340
|
+
const fullProject = await getFullProject(db, logger)({ scopes: {
|
|
340
341
|
tenantId,
|
|
341
342
|
projectId: typed.id
|
|
342
343
|
} });
|
|
344
|
+
if (!fullProject) throw new Error(`Failed to retrieve created project ${typed.id}`);
|
|
345
|
+
return fullProject;
|
|
343
346
|
} catch (error) {
|
|
344
347
|
logger.error({
|
|
345
348
|
tenantId,
|
|
@@ -353,7 +356,8 @@ const createFullProjectServerSide = (db, logger = defaultLogger) => async (scope
|
|
|
353
356
|
* Server-side implementation of updateFullProject that performs actual database operations.
|
|
354
357
|
* This function updates a complete project with all agent and their nested resources.
|
|
355
358
|
*/
|
|
356
|
-
const updateFullProjectServerSide = (db, logger = defaultLogger) => async (
|
|
359
|
+
const updateFullProjectServerSide = (db, logger = defaultLogger) => async (params) => {
|
|
360
|
+
const { scopes, projectData } = params;
|
|
357
361
|
const { tenantId } = scopes;
|
|
358
362
|
const typed = validateAndTypeProjectData(projectData);
|
|
359
363
|
if (!typed.id) throw new Error("Project ID is required");
|
|
@@ -369,9 +373,12 @@ const updateFullProjectServerSide = (db, logger = defaultLogger) => async (scope
|
|
|
369
373
|
} })) {
|
|
370
374
|
logger.info({ projectId: typed.id }, "Project not found, creating new project");
|
|
371
375
|
return await createFullProjectServerSide(db, logger)({
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
376
|
+
scopes: {
|
|
377
|
+
tenantId,
|
|
378
|
+
projectId: typed.id
|
|
379
|
+
},
|
|
380
|
+
projectData
|
|
381
|
+
});
|
|
375
382
|
}
|
|
376
383
|
const projectUpdatePayload = {
|
|
377
384
|
name: typed.name,
|
|
@@ -831,10 +838,12 @@ const updateFullProjectServerSide = (db, logger = defaultLogger) => async (scope
|
|
|
831
838
|
}, "All project agent updated successfully");
|
|
832
839
|
}
|
|
833
840
|
logger.info({ projectId: typed.id }, "Full project updated successfully");
|
|
834
|
-
|
|
841
|
+
const fullProject = await getFullProject(db, logger)({ scopes: {
|
|
835
842
|
tenantId,
|
|
836
843
|
projectId: typed.id
|
|
837
844
|
} });
|
|
845
|
+
if (!fullProject) throw new Error("Failed to retrieve full project");
|
|
846
|
+
return fullProject;
|
|
838
847
|
} catch (error) {
|
|
839
848
|
logger.error({
|
|
840
849
|
tenantId,
|
|
@@ -847,12 +856,13 @@ const updateFullProjectServerSide = (db, logger = defaultLogger) => async (scope
|
|
|
847
856
|
/**
|
|
848
857
|
* Get a complete project definition with all nested resources
|
|
849
858
|
*/
|
|
850
|
-
const
|
|
851
|
-
const { scopes } = params;
|
|
859
|
+
const getFullProjectInternal = (db, logger = defaultLogger) => async (params) => {
|
|
860
|
+
const { scopes, includeRelationIds = false } = params;
|
|
852
861
|
const { tenantId, projectId } = scopes;
|
|
853
862
|
logger.info({
|
|
854
863
|
tenantId,
|
|
855
|
-
projectId
|
|
864
|
+
projectId,
|
|
865
|
+
includeRelationIds
|
|
856
866
|
}, "Retrieving full project definition");
|
|
857
867
|
try {
|
|
858
868
|
const project = await getProject(db)({ scopes: {
|
|
@@ -891,15 +901,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
|
|
|
891
901
|
limit: 1e3
|
|
892
902
|
}
|
|
893
903
|
});
|
|
894
|
-
for (const tool of toolsList.data) projectTools[tool.id] =
|
|
895
|
-
id: tool.id,
|
|
896
|
-
name: tool.name,
|
|
897
|
-
config: tool.config,
|
|
898
|
-
credentialReferenceId: tool.credentialReferenceId || void 0,
|
|
899
|
-
imageUrl: tool.imageUrl || void 0,
|
|
900
|
-
capabilities: tool.capabilities || void 0,
|
|
901
|
-
lastError: tool.lastError || void 0
|
|
902
|
-
};
|
|
904
|
+
for (const tool of toolsList.data) projectTools[tool.id] = tool;
|
|
903
905
|
logger.info({
|
|
904
906
|
tenantId,
|
|
905
907
|
projectId,
|
|
@@ -918,13 +920,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
|
|
|
918
920
|
tenantId,
|
|
919
921
|
projectId
|
|
920
922
|
} });
|
|
921
|
-
for (const externalAgent of externalAgentsList) projectExternalAgents[externalAgent.id] =
|
|
922
|
-
id: externalAgent.id,
|
|
923
|
-
name: externalAgent.name,
|
|
924
|
-
description: externalAgent.description,
|
|
925
|
-
baseUrl: externalAgent.baseUrl,
|
|
926
|
-
credentialReferenceId: externalAgent.credentialReferenceId || void 0
|
|
927
|
-
};
|
|
923
|
+
for (const externalAgent of externalAgentsList) projectExternalAgents[externalAgent.id] = externalAgent;
|
|
928
924
|
logger.info({
|
|
929
925
|
tenantId,
|
|
930
926
|
projectId,
|
|
@@ -943,13 +939,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
|
|
|
943
939
|
tenantId,
|
|
944
940
|
projectId
|
|
945
941
|
} });
|
|
946
|
-
for (const component of dataComponentsList) projectDataComponents[component.id] =
|
|
947
|
-
id: component.id,
|
|
948
|
-
name: component.name,
|
|
949
|
-
description: component.description,
|
|
950
|
-
props: component.props,
|
|
951
|
-
render: component.render
|
|
952
|
-
};
|
|
942
|
+
for (const component of dataComponentsList) projectDataComponents[component.id] = component;
|
|
953
943
|
logger.info({
|
|
954
944
|
tenantId,
|
|
955
945
|
projectId,
|
|
@@ -968,12 +958,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
|
|
|
968
958
|
tenantId,
|
|
969
959
|
projectId
|
|
970
960
|
} });
|
|
971
|
-
for (const component of artifactComponentsList) projectArtifactComponents[component.id] =
|
|
972
|
-
id: component.id,
|
|
973
|
-
name: component.name,
|
|
974
|
-
description: component.description,
|
|
975
|
-
props: component.props
|
|
976
|
-
};
|
|
961
|
+
for (const component of artifactComponentsList) projectArtifactComponents[component.id] = component;
|
|
977
962
|
logger.info({
|
|
978
963
|
tenantId,
|
|
979
964
|
projectId,
|
|
@@ -992,13 +977,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
|
|
|
992
977
|
tenantId,
|
|
993
978
|
projectId
|
|
994
979
|
} });
|
|
995
|
-
for (const credential of credentialReferencesList) projectCredentialReferences[credential.id] =
|
|
996
|
-
id: credential.id,
|
|
997
|
-
name: credential.name,
|
|
998
|
-
type: credential.type,
|
|
999
|
-
credentialStoreId: credential.credentialStoreId,
|
|
1000
|
-
retrievalParams: credential.retrievalParams
|
|
1001
|
-
};
|
|
980
|
+
for (const credential of credentialReferencesList) projectCredentialReferences[credential.id] = credential;
|
|
1002
981
|
logger.info({
|
|
1003
982
|
tenantId,
|
|
1004
983
|
projectId,
|
|
@@ -1017,12 +996,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
|
|
|
1017
996
|
tenantId,
|
|
1018
997
|
projectId
|
|
1019
998
|
} });
|
|
1020
|
-
for (const func of functionsList) projectFunctions[func.id] =
|
|
1021
|
-
id: func.id,
|
|
1022
|
-
inputSchema: func.inputSchema,
|
|
1023
|
-
executeCode: func.executeCode,
|
|
1024
|
-
dependencies: func.dependencies
|
|
1025
|
-
};
|
|
999
|
+
for (const func of functionsList) projectFunctions[func.id] = func;
|
|
1026
1000
|
logger.info({
|
|
1027
1001
|
tenantId,
|
|
1028
1002
|
projectId,
|
|
@@ -1037,6 +1011,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
|
|
|
1037
1011
|
}
|
|
1038
1012
|
const agents = {};
|
|
1039
1013
|
if (agentList.length > 0) {
|
|
1014
|
+
const getAgentFn = includeRelationIds ? getFullAgentWithRelationIds : getFullAgent;
|
|
1040
1015
|
const agentPromises = agentList.map(async (agent) => {
|
|
1041
1016
|
try {
|
|
1042
1017
|
logger.info({
|
|
@@ -1044,7 +1019,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
|
|
|
1044
1019
|
projectId,
|
|
1045
1020
|
agentId: agent.id
|
|
1046
1021
|
}, "Retrieving full agent definition");
|
|
1047
|
-
const fullAgent = await
|
|
1022
|
+
const fullAgent = await getAgentFn(db)({ scopes: {
|
|
1048
1023
|
tenantId,
|
|
1049
1024
|
projectId,
|
|
1050
1025
|
agentId: agent.id
|
|
@@ -1072,20 +1047,30 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
|
|
|
1072
1047
|
});
|
|
1073
1048
|
await Promise.all(agentPromises);
|
|
1074
1049
|
}
|
|
1075
|
-
|
|
1050
|
+
const projectModels = project.models ?? {
|
|
1051
|
+
base: { model: "claude-sonnet-4-5" },
|
|
1052
|
+
structuredOutput: { model: "claude-sonnet-4-5" },
|
|
1053
|
+
summarizer: { model: "claude-sonnet-4-5" }
|
|
1054
|
+
};
|
|
1055
|
+
if (!projectModels.base) logger.warn({
|
|
1056
|
+
tenantId,
|
|
1057
|
+
projectId
|
|
1058
|
+
}, `Project ${project.id} is missing base model configuration. Using default: claude-sonnet-4-5`);
|
|
1076
1059
|
const fullProjectDefinition = {
|
|
1077
1060
|
id: project.id,
|
|
1078
1061
|
name: project.name,
|
|
1079
1062
|
description: project.description,
|
|
1080
|
-
models:
|
|
1081
|
-
stopWhen: project.stopWhen
|
|
1063
|
+
models: projectModels,
|
|
1064
|
+
stopWhen: project.stopWhen ?? null,
|
|
1082
1065
|
agents,
|
|
1083
1066
|
tools: projectTools,
|
|
1084
|
-
functions: projectFunctions,
|
|
1085
|
-
externalAgents: projectExternalAgents,
|
|
1086
|
-
dataComponents: projectDataComponents,
|
|
1087
|
-
artifactComponents: projectArtifactComponents,
|
|
1088
|
-
credentialReferences: projectCredentialReferences,
|
|
1067
|
+
functions: Object.keys(projectFunctions).length > 0 ? projectFunctions : null,
|
|
1068
|
+
externalAgents: Object.keys(projectExternalAgents).length > 0 ? projectExternalAgents : null,
|
|
1069
|
+
dataComponents: Object.keys(projectDataComponents).length > 0 ? projectDataComponents : null,
|
|
1070
|
+
artifactComponents: Object.keys(projectArtifactComponents).length > 0 ? projectArtifactComponents : null,
|
|
1071
|
+
credentialReferences: Object.keys(projectCredentialReferences).length > 0 ? projectCredentialReferences : null,
|
|
1072
|
+
statusUpdates: null,
|
|
1073
|
+
functionTools: null,
|
|
1089
1074
|
createdAt: project.createdAt,
|
|
1090
1075
|
updatedAt: project.updatedAt
|
|
1091
1076
|
};
|
|
@@ -1104,6 +1089,20 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
|
|
|
1104
1089
|
throw error;
|
|
1105
1090
|
}
|
|
1106
1091
|
};
|
|
1092
|
+
const getFullProject = (db, logger = defaultLogger) => async (params) => {
|
|
1093
|
+
const { scopes } = params;
|
|
1094
|
+
return getFullProjectInternal(db, logger)({
|
|
1095
|
+
scopes,
|
|
1096
|
+
includeRelationIds: false
|
|
1097
|
+
});
|
|
1098
|
+
};
|
|
1099
|
+
const getFullProjectWithRelationIds = (db, logger = defaultLogger) => async (params) => {
|
|
1100
|
+
const { scopes } = params;
|
|
1101
|
+
return getFullProjectInternal(db, logger)({
|
|
1102
|
+
scopes,
|
|
1103
|
+
includeRelationIds: true
|
|
1104
|
+
});
|
|
1105
|
+
};
|
|
1107
1106
|
/**
|
|
1108
1107
|
* Delete a complete project and cascade to all related entities
|
|
1109
1108
|
*/
|
|
@@ -1192,4 +1191,4 @@ const deleteFullProject = (db, logger = defaultLogger) => async (params) => {
|
|
|
1192
1191
|
};
|
|
1193
1192
|
|
|
1194
1193
|
//#endregion
|
|
1195
|
-
export { createFullProjectServerSide, deleteFullProject, getFullProject, updateFullProjectServerSide };
|
|
1194
|
+
export { createFullProjectServerSide, deleteFullProject, getFullProject, getFullProjectWithRelationIds, updateFullProjectServerSide };
|