@inkeep/agents-manage-api 0.24.1 → 0.25.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/index.cjs +339 -143
- package/dist/index.js +340 -144
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadEnvironmentFiles, getLogger, createDatabaseClient, commonGetErrorResponses, AgentListResponse, PaginationQueryParamsSchema, TenantProjectParamsSchema, listAgents, AgentResponse, TenantProjectIdParamsSchema, getAgentById, createApiError, ListResponseSchema, getAgentSubAgentInfos, SingleResponseSchema, TenantProjectAgentParamsSchema, AgentWithinContextOfProjectSchema, getFullAgentDefinition, AgentApiInsertSchema, createAgent, AgentApiUpdateSchema, updateAgent, ErrorResponseSchema, deleteAgent, createFullAgentServerSide, getFullAgent, updateFullAgentServerSide, deleteFullAgent, ApiKeyListResponse, listApiKeysPaginated, ApiKeyResponse, getApiKeyById, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, generateApiKey, createApiKey, ApiKeyApiUpdateSchema, updateApiKey, deleteApiKey, ArtifactComponentListResponse, listArtifactComponentsPaginated, ArtifactComponentResponse, getArtifactComponentById, ArtifactComponentApiInsertSchema, validatePropsAsJsonSchema, createArtifactComponent, ArtifactComponentApiUpdateSchema, updateArtifactComponent, deleteArtifactComponent, ContextConfigListResponse, listContextConfigsPaginated, ContextConfigResponse, TenantProjectAgentIdParamsSchema, getContextConfigById, ContextConfigApiInsertSchema, createContextConfig, commonUpdateErrorResponses, ContextConfigApiUpdateSchema, updateContextConfig, commonDeleteErrorResponses, deleteContextConfig, CredentialStoreType, CredentialReferenceListResponse, listCredentialReferencesPaginated, CredentialReferenceApiSelectSchema, CredentialReferenceResponse,
|
|
1
|
+
import { loadEnvironmentFiles, getLogger, createDatabaseClient, commonGetErrorResponses, AgentListResponse, PaginationQueryParamsSchema, TenantProjectParamsSchema, listAgents, AgentResponse, TenantProjectIdParamsSchema, getAgentById, createApiError, ListResponseSchema, getAgentSubAgentInfos, SingleResponseSchema, TenantProjectAgentParamsSchema, AgentWithinContextOfProjectSchema, getFullAgentDefinition, AgentApiInsertSchema, createAgent, generateId, AgentApiUpdateSchema, updateAgent, ErrorResponseSchema, deleteAgent, createFullAgentServerSide, getFullAgent, updateFullAgentServerSide, deleteFullAgent, ApiKeyListResponse, listApiKeysPaginated, ApiKeyResponse, getApiKeyById, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, generateApiKey, createApiKey, ApiKeyApiUpdateSchema, updateApiKey, deleteApiKey, ArtifactComponentListResponse, listArtifactComponentsPaginated, ArtifactComponentResponse, getArtifactComponentById, ArtifactComponentApiInsertSchema, validatePropsAsJsonSchema, createArtifactComponent, ArtifactComponentApiUpdateSchema, updateArtifactComponent, deleteArtifactComponent, ContextConfigListResponse, listContextConfigsPaginated, ContextConfigResponse, TenantProjectAgentIdParamsSchema, getContextConfigById, ContextConfigApiInsertSchema, createContextConfig, commonUpdateErrorResponses, ContextConfigApiUpdateSchema, updateContextConfig, commonDeleteErrorResponses, deleteContextConfig, CredentialStoreType, CredentialReferenceListResponse, listCredentialReferencesPaginated, CredentialReferenceApiSelectSchema, CredentialReferenceResponse, getCredentialReferenceWithResources, CredentialReferenceApiInsertSchema, createCredentialReference, CredentialReferenceApiUpdateSchema, updateCredentialReference, getCredentialReferenceById, getCredentialStoreLookupKeyFromRetrievalParams, deleteCredentialReference, DataComponentListResponse, listDataComponentsPaginated, DataComponentResponse, getDataComponent, DataComponentApiInsertSchema, createDataComponent, DataComponentApiUpdateSchema, updateDataComponent, deleteDataComponent, ExternalAgentListResponse, listExternalAgentsPaginated, ExternalAgentResponse, getExternalAgent, ExternalAgentApiInsertSchema, createExternalAgent, ExternalAgentApiUpdateSchema, updateExternalAgent, deleteExternalAgent, FunctionListResponse, listFunctions, FunctionResponse, getFunction, FunctionApiInsertSchema, upsertFunction, FunctionApiUpdateSchema, deleteFunction, FunctionToolApiSelectSchema, listFunctionTools, getFunctionToolById, FunctionToolApiInsertSchema, createFunctionTool, FunctionToolApiUpdateSchema, updateFunctionTool, deleteFunctionTool, ProjectListResponse, TenantParamsSchema, listProjectsPaginated, ProjectResponse, TenantIdParamsSchema, getProject, ProjectApiInsertSchema, createProject, ProjectApiUpdateSchema, updateProject, deleteProject, ArtifactComponentApiSelectSchema, getArtifactComponentsForAgent, getAgentsUsingArtifactComponent, SubAgentArtifactComponentApiInsertSchema, SubAgentArtifactComponentApiSelectSchema, getSubAgentById, isArtifactComponentAssociatedWithAgent, associateArtifactComponentWithAgent, RemovedResponseSchema, removeArtifactComponentFromAgent, ExistsResponseSchema, DataComponentApiSelectSchema, getDataComponentsForAgent, getAgentsUsingDataComponent, SubAgentDataComponentApiInsertSchema, SubAgentDataComponentApiSelectSchema, isDataComponentAssociatedWithAgent, associateDataComponentWithAgent, removeDataComponentFromAgent, TenantProjectAgentSubAgentParamsSchema, SubAgentExternalAgentRelationApiSelectSchema, listSubAgentExternalAgentRelations, TenantProjectAgentSubAgentIdParamsSchema, getSubAgentExternalAgentRelationById, SubAgentExternalAgentRelationApiInsertSchema, createSubAgentExternalAgentRelation, SubAgentExternalAgentRelationApiUpdateSchema, updateSubAgentExternalAgentRelation, deleteSubAgentExternalAgentRelation, SubAgentRelationApiSelectSchema, SubAgentRelationQuerySchema, getAgentRelationsBySource, getSubAgentRelationsByTarget, listAgentRelations, getAgentRelationById, SubAgentRelationApiInsertSchema, validateSubAgent, createSubAgentRelation, SubAgentRelationApiUpdateSchema, updateAgentRelation, deleteSubAgentRelation, SubAgentListResponse, listSubAgentsPaginated, SubAgentResponse, SubAgentApiInsertSchema, createSubAgent, SubAgentApiUpdateSchema, updateSubAgent, deleteSubAgent, SubAgentToolRelationApiSelectSchema, getAgentToolRelationByAgent, getAgentToolRelationByTool, listAgentToolRelations, getAgentToolRelationById, getAgentsForTool, SubAgentToolRelationApiInsertSchema, createAgentToolRelation, SubAgentToolRelationApiUpdateSchema, updateAgentToolRelation, deleteAgentToolRelation, McpToolSchema, ToolStatusSchema, listTools, dbResultToMcpTool, getToolById, ToolApiInsertSchema, createTool, ToolApiUpdateSchema, updateTool, deleteTool, generateIdFromName, FullProjectDefinitionSchema, createFullProjectServerSide, getFullProject, updateFullProjectServerSide, deleteFullProject, createDefaultCredentialStores, CredentialStoreRegistry, initiateMcpOAuthFlow, exchangeMcpAuthorizationCode, handleApiError } from '@inkeep/agents-core';
|
|
2
2
|
import { OpenAPIHono, createRoute, z as z$1 } from '@hono/zod-openapi';
|
|
3
3
|
import { Hono } from 'hono';
|
|
4
4
|
import { cors } from 'hono/cors';
|
|
@@ -68,10 +68,10 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
|
|
|
68
68
|
await next();
|
|
69
69
|
return;
|
|
70
70
|
});
|
|
71
|
-
function setupOpenAPIRoutes(
|
|
72
|
-
|
|
71
|
+
function setupOpenAPIRoutes(app24) {
|
|
72
|
+
app24.get("/openapi.json", (c) => {
|
|
73
73
|
try {
|
|
74
|
-
const document =
|
|
74
|
+
const document = app24.getOpenAPIDocument({
|
|
75
75
|
openapi: "3.0.0",
|
|
76
76
|
info: {
|
|
77
77
|
title: "Inkeep Agents Manage API",
|
|
@@ -92,7 +92,7 @@ function setupOpenAPIRoutes(app23) {
|
|
|
92
92
|
return c.json({ error: "Failed to generate OpenAPI document", details: errorDetails }, 500);
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
|
-
|
|
95
|
+
app24.get(
|
|
96
96
|
"/docs",
|
|
97
97
|
swaggerUI({
|
|
98
98
|
url: "/openapi.json",
|
|
@@ -319,7 +319,7 @@ app.openapi(
|
|
|
319
319
|
const agent = await createAgent(dbClient_default)({
|
|
320
320
|
tenantId,
|
|
321
321
|
projectId,
|
|
322
|
-
id: validatedBody.id ||
|
|
322
|
+
id: validatedBody.id || generateId(),
|
|
323
323
|
name: validatedBody.name,
|
|
324
324
|
defaultSubAgentId: validatedBody.defaultSubAgentId,
|
|
325
325
|
contextConfigId: validatedBody.contextConfigId ?? void 0
|
|
@@ -574,6 +574,7 @@ app2.openapi(
|
|
|
574
574
|
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
575
575
|
const agentData = c.req.valid("json");
|
|
576
576
|
try {
|
|
577
|
+
logger2.info({}, "test agent data");
|
|
577
578
|
const validatedAgentData = AgentWithinContextOfProjectSchema.parse(agentData);
|
|
578
579
|
if (agentId !== validatedAgentData.id) {
|
|
579
580
|
throw createApiError({
|
|
@@ -1036,7 +1037,7 @@ app4.openapi(
|
|
|
1036
1037
|
});
|
|
1037
1038
|
}
|
|
1038
1039
|
}
|
|
1039
|
-
const finalId = body.id ? String(body.id) :
|
|
1040
|
+
const finalId = body.id ? String(body.id) : generateId();
|
|
1040
1041
|
const componentData = {
|
|
1041
1042
|
tenantId,
|
|
1042
1043
|
projectId,
|
|
@@ -1550,7 +1551,7 @@ app7.openapi(
|
|
|
1550
1551
|
}),
|
|
1551
1552
|
async (c) => {
|
|
1552
1553
|
const { tenantId, projectId, id } = c.req.valid("param");
|
|
1553
|
-
const credential = await
|
|
1554
|
+
const credential = await getCredentialReferenceWithResources(dbClient_default)({
|
|
1554
1555
|
scopes: { tenantId, projectId },
|
|
1555
1556
|
id
|
|
1556
1557
|
});
|
|
@@ -1953,7 +1954,7 @@ app9.openapi(
|
|
|
1953
1954
|
operationId: "list-external-agents",
|
|
1954
1955
|
tags: ["External Agents"],
|
|
1955
1956
|
request: {
|
|
1956
|
-
params:
|
|
1957
|
+
params: TenantProjectParamsSchema,
|
|
1957
1958
|
query: PaginationQueryParamsSchema
|
|
1958
1959
|
},
|
|
1959
1960
|
responses: {
|
|
@@ -1969,10 +1970,10 @@ app9.openapi(
|
|
|
1969
1970
|
}
|
|
1970
1971
|
}),
|
|
1971
1972
|
async (c) => {
|
|
1972
|
-
const { tenantId, projectId
|
|
1973
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
1973
1974
|
const { page, limit } = c.req.valid("query");
|
|
1974
1975
|
const result = await listExternalAgentsPaginated(dbClient_default)({
|
|
1975
|
-
scopes: { tenantId, projectId
|
|
1976
|
+
scopes: { tenantId, projectId },
|
|
1976
1977
|
pagination: { page, limit }
|
|
1977
1978
|
});
|
|
1978
1979
|
const dataWithType = {
|
|
@@ -1993,7 +1994,7 @@ app9.openapi(
|
|
|
1993
1994
|
operationId: "get-external-agent-by-id",
|
|
1994
1995
|
tags: ["External Agents"],
|
|
1995
1996
|
request: {
|
|
1996
|
-
params:
|
|
1997
|
+
params: TenantProjectIdParamsSchema
|
|
1997
1998
|
},
|
|
1998
1999
|
responses: {
|
|
1999
2000
|
200: {
|
|
@@ -2008,10 +2009,10 @@ app9.openapi(
|
|
|
2008
2009
|
}
|
|
2009
2010
|
}),
|
|
2010
2011
|
async (c) => {
|
|
2011
|
-
const { tenantId, projectId,
|
|
2012
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
2012
2013
|
const externalAgent = await getExternalAgent(dbClient_default)({
|
|
2013
|
-
scopes: { tenantId, projectId
|
|
2014
|
-
|
|
2014
|
+
scopes: { tenantId, projectId },
|
|
2015
|
+
externalAgentId: id
|
|
2015
2016
|
});
|
|
2016
2017
|
if (!externalAgent) {
|
|
2017
2018
|
throw createApiError({
|
|
@@ -2034,7 +2035,7 @@ app9.openapi(
|
|
|
2034
2035
|
operationId: "create-external-agent",
|
|
2035
2036
|
tags: ["External Agents"],
|
|
2036
2037
|
request: {
|
|
2037
|
-
params:
|
|
2038
|
+
params: TenantProjectParamsSchema,
|
|
2038
2039
|
body: {
|
|
2039
2040
|
content: {
|
|
2040
2041
|
"application/json": {
|
|
@@ -2056,18 +2057,16 @@ app9.openapi(
|
|
|
2056
2057
|
}
|
|
2057
2058
|
}),
|
|
2058
2059
|
async (c) => {
|
|
2059
|
-
const { tenantId, projectId
|
|
2060
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
2060
2061
|
const body = c.req.valid("json");
|
|
2061
2062
|
const externalAgentData = {
|
|
2062
2063
|
tenantId,
|
|
2063
2064
|
projectId,
|
|
2064
|
-
|
|
2065
|
-
id: body.id ? String(body.id) : nanoid(),
|
|
2065
|
+
id: body.id ? String(body.id) : generateId(),
|
|
2066
2066
|
name: body.name,
|
|
2067
2067
|
description: body.description,
|
|
2068
2068
|
baseUrl: body.baseUrl,
|
|
2069
|
-
credentialReferenceId: body.credentialReferenceId || void 0
|
|
2070
|
-
headers: body.headers || void 0
|
|
2069
|
+
credentialReferenceId: body.credentialReferenceId || void 0
|
|
2071
2070
|
};
|
|
2072
2071
|
const externalAgent = await createExternalAgent(dbClient_default)(externalAgentData);
|
|
2073
2072
|
const agentWithType = {
|
|
@@ -2085,7 +2084,7 @@ app9.openapi(
|
|
|
2085
2084
|
operationId: "update-external-agent",
|
|
2086
2085
|
tags: ["External Agents"],
|
|
2087
2086
|
request: {
|
|
2088
|
-
params:
|
|
2087
|
+
params: TenantProjectIdParamsSchema,
|
|
2089
2088
|
body: {
|
|
2090
2089
|
content: {
|
|
2091
2090
|
"application/json": {
|
|
@@ -2107,11 +2106,11 @@ app9.openapi(
|
|
|
2107
2106
|
}
|
|
2108
2107
|
}),
|
|
2109
2108
|
async (c) => {
|
|
2110
|
-
const { tenantId, projectId,
|
|
2109
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
2111
2110
|
const body = c.req.valid("json");
|
|
2112
2111
|
const updatedExternalAgent = await updateExternalAgent(dbClient_default)({
|
|
2113
|
-
scopes: { tenantId, projectId
|
|
2114
|
-
|
|
2112
|
+
scopes: { tenantId, projectId },
|
|
2113
|
+
externalAgentId: id,
|
|
2115
2114
|
data: body
|
|
2116
2115
|
});
|
|
2117
2116
|
if (!updatedExternalAgent) {
|
|
@@ -2135,7 +2134,7 @@ app9.openapi(
|
|
|
2135
2134
|
operationId: "delete-external-agent",
|
|
2136
2135
|
tags: ["External Agents"],
|
|
2137
2136
|
request: {
|
|
2138
|
-
params:
|
|
2137
|
+
params: TenantProjectIdParamsSchema
|
|
2139
2138
|
},
|
|
2140
2139
|
responses: {
|
|
2141
2140
|
204: {
|
|
@@ -2152,10 +2151,10 @@ app9.openapi(
|
|
|
2152
2151
|
}
|
|
2153
2152
|
}),
|
|
2154
2153
|
async (c) => {
|
|
2155
|
-
const { tenantId, projectId,
|
|
2154
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
2156
2155
|
const deleted = await deleteExternalAgent(dbClient_default)({
|
|
2157
|
-
scopes: { tenantId, projectId
|
|
2158
|
-
|
|
2156
|
+
scopes: { tenantId, projectId },
|
|
2157
|
+
externalAgentId: id
|
|
2159
2158
|
});
|
|
2160
2159
|
if (!deleted) {
|
|
2161
2160
|
throw createApiError({
|
|
@@ -2292,7 +2291,7 @@ app10.openapi(
|
|
|
2292
2291
|
const { tenantId, projectId } = c.req.valid("param");
|
|
2293
2292
|
const functionData = c.req.valid("json");
|
|
2294
2293
|
try {
|
|
2295
|
-
const id = functionData.id ||
|
|
2294
|
+
const id = functionData.id || generateId();
|
|
2296
2295
|
await upsertFunction(dbClient_default)({
|
|
2297
2296
|
data: {
|
|
2298
2297
|
...functionData,
|
|
@@ -2550,7 +2549,7 @@ app11.openapi(
|
|
|
2550
2549
|
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
2551
2550
|
const body = c.req.valid("json");
|
|
2552
2551
|
try {
|
|
2553
|
-
const id = body.id ||
|
|
2552
|
+
const id = body.id || generateId();
|
|
2554
2553
|
const functionTool = await createFunctionTool(dbClient_default)({
|
|
2555
2554
|
scopes: { tenantId, projectId, agentId },
|
|
2556
2555
|
data: {
|
|
@@ -3365,6 +3364,228 @@ app14.openapi(
|
|
|
3365
3364
|
var subAgentDataComponents_default = app14;
|
|
3366
3365
|
var app15 = new OpenAPIHono();
|
|
3367
3366
|
app15.openapi(
|
|
3367
|
+
createRoute({
|
|
3368
|
+
method: "get",
|
|
3369
|
+
path: "/",
|
|
3370
|
+
summary: "List Sub Agent External Agent Relations",
|
|
3371
|
+
operationId: "list-sub-agent-external-agent-relations",
|
|
3372
|
+
tags: ["Sub Agent External Agent Relations"],
|
|
3373
|
+
request: {
|
|
3374
|
+
params: TenantProjectAgentSubAgentParamsSchema,
|
|
3375
|
+
query: PaginationQueryParamsSchema
|
|
3376
|
+
},
|
|
3377
|
+
responses: {
|
|
3378
|
+
200: {
|
|
3379
|
+
description: "List of sub agent external agent relations retrieved successfully",
|
|
3380
|
+
content: {
|
|
3381
|
+
"application/json": {
|
|
3382
|
+
schema: ListResponseSchema(SubAgentExternalAgentRelationApiSelectSchema)
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
},
|
|
3386
|
+
...commonGetErrorResponses
|
|
3387
|
+
}
|
|
3388
|
+
}),
|
|
3389
|
+
async (c) => {
|
|
3390
|
+
const { tenantId, projectId, agentId, subAgentId } = c.req.valid("param");
|
|
3391
|
+
const { page = 1, limit = 10 } = c.req.valid("query");
|
|
3392
|
+
const pageNum = Number(page);
|
|
3393
|
+
const limitNum = Math.min(Number(limit), 100);
|
|
3394
|
+
try {
|
|
3395
|
+
const result = await listSubAgentExternalAgentRelations(dbClient_default)({
|
|
3396
|
+
scopes: { tenantId, projectId, agentId, subAgentId },
|
|
3397
|
+
pagination: { page: pageNum, limit: limitNum }
|
|
3398
|
+
});
|
|
3399
|
+
return c.json(result);
|
|
3400
|
+
} catch (_error) {
|
|
3401
|
+
throw createApiError({
|
|
3402
|
+
code: "internal_server_error",
|
|
3403
|
+
message: "Failed to retrieve sub agent external agent relations"
|
|
3404
|
+
});
|
|
3405
|
+
}
|
|
3406
|
+
}
|
|
3407
|
+
);
|
|
3408
|
+
app15.openapi(
|
|
3409
|
+
createRoute({
|
|
3410
|
+
method: "get",
|
|
3411
|
+
path: "/{id}",
|
|
3412
|
+
summary: "Get Sub Agent External Agent Relation",
|
|
3413
|
+
operationId: "get-sub-agent-external-agent-relation-by-id",
|
|
3414
|
+
tags: ["Sub Agent External Agent Relations"],
|
|
3415
|
+
request: {
|
|
3416
|
+
params: TenantProjectAgentSubAgentIdParamsSchema
|
|
3417
|
+
},
|
|
3418
|
+
responses: {
|
|
3419
|
+
200: {
|
|
3420
|
+
description: "Sub Agent external agent relation found",
|
|
3421
|
+
content: {
|
|
3422
|
+
"application/json": {
|
|
3423
|
+
schema: SingleResponseSchema(SubAgentExternalAgentRelationApiSelectSchema)
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
},
|
|
3427
|
+
...commonGetErrorResponses
|
|
3428
|
+
}
|
|
3429
|
+
}),
|
|
3430
|
+
async (c) => {
|
|
3431
|
+
const { tenantId, projectId, agentId, subAgentId, id } = c.req.valid("param");
|
|
3432
|
+
const relation = await getSubAgentExternalAgentRelationById(dbClient_default)({
|
|
3433
|
+
scopes: { tenantId, projectId, agentId, subAgentId },
|
|
3434
|
+
relationId: id
|
|
3435
|
+
});
|
|
3436
|
+
if (!relation) {
|
|
3437
|
+
throw createApiError({
|
|
3438
|
+
code: "not_found",
|
|
3439
|
+
message: "Sub Agent External Agent Relation not found"
|
|
3440
|
+
});
|
|
3441
|
+
}
|
|
3442
|
+
return c.json({ data: relation });
|
|
3443
|
+
}
|
|
3444
|
+
);
|
|
3445
|
+
app15.openapi(
|
|
3446
|
+
createRoute({
|
|
3447
|
+
method: "post",
|
|
3448
|
+
path: "/",
|
|
3449
|
+
summary: "Create Sub Agent External Agent Relation",
|
|
3450
|
+
operationId: "create-sub-agent-external-agent-relation",
|
|
3451
|
+
tags: ["Sub Agent External Agent Relations"],
|
|
3452
|
+
request: {
|
|
3453
|
+
params: TenantProjectAgentSubAgentParamsSchema,
|
|
3454
|
+
body: {
|
|
3455
|
+
content: {
|
|
3456
|
+
"application/json": {
|
|
3457
|
+
schema: SubAgentExternalAgentRelationApiInsertSchema
|
|
3458
|
+
}
|
|
3459
|
+
}
|
|
3460
|
+
}
|
|
3461
|
+
},
|
|
3462
|
+
responses: {
|
|
3463
|
+
201: {
|
|
3464
|
+
description: "Sub Agent External Agent Relation created successfully",
|
|
3465
|
+
content: {
|
|
3466
|
+
"application/json": {
|
|
3467
|
+
schema: SingleResponseSchema(SubAgentExternalAgentRelationApiSelectSchema)
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
},
|
|
3471
|
+
...commonGetErrorResponses
|
|
3472
|
+
}
|
|
3473
|
+
}),
|
|
3474
|
+
async (c) => {
|
|
3475
|
+
const { tenantId, projectId, agentId, subAgentId } = c.req.valid("param");
|
|
3476
|
+
const body = await c.req.valid("json");
|
|
3477
|
+
const existingRelations = await listSubAgentExternalAgentRelations(dbClient_default)({
|
|
3478
|
+
scopes: { tenantId, projectId, agentId, subAgentId },
|
|
3479
|
+
pagination: { page: 1, limit: 1e3 }
|
|
3480
|
+
});
|
|
3481
|
+
const isDuplicate = existingRelations.data.some(
|
|
3482
|
+
(relation2) => relation2.externalAgentId === body.externalAgentId && relation2.subAgentId === subAgentId
|
|
3483
|
+
);
|
|
3484
|
+
if (isDuplicate) {
|
|
3485
|
+
throw createApiError({
|
|
3486
|
+
code: "unprocessable_entity",
|
|
3487
|
+
message: `A relation between this sub-agent and external agent already exists`
|
|
3488
|
+
});
|
|
3489
|
+
}
|
|
3490
|
+
const relation = await createSubAgentExternalAgentRelation(dbClient_default)({
|
|
3491
|
+
scopes: { tenantId, projectId, agentId, subAgentId },
|
|
3492
|
+
relationId: nanoid(),
|
|
3493
|
+
data: {
|
|
3494
|
+
externalAgentId: body.externalAgentId,
|
|
3495
|
+
headers: body.headers || null
|
|
3496
|
+
}
|
|
3497
|
+
});
|
|
3498
|
+
return c.json({ data: relation }, 201);
|
|
3499
|
+
}
|
|
3500
|
+
);
|
|
3501
|
+
app15.openapi(
|
|
3502
|
+
createRoute({
|
|
3503
|
+
method: "put",
|
|
3504
|
+
path: "/{id}",
|
|
3505
|
+
summary: "Update Sub Agent External Agent Relation",
|
|
3506
|
+
operationId: "update-sub-agent-external-agent-relation",
|
|
3507
|
+
tags: ["Sub Agent External Agent Relations"],
|
|
3508
|
+
request: {
|
|
3509
|
+
params: TenantProjectAgentSubAgentIdParamsSchema,
|
|
3510
|
+
body: {
|
|
3511
|
+
content: {
|
|
3512
|
+
"application/json": {
|
|
3513
|
+
schema: SubAgentExternalAgentRelationApiUpdateSchema
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3517
|
+
},
|
|
3518
|
+
responses: {
|
|
3519
|
+
200: {
|
|
3520
|
+
description: "Sub Agent external agent relation updated successfully",
|
|
3521
|
+
content: {
|
|
3522
|
+
"application/json": {
|
|
3523
|
+
schema: SingleResponseSchema(SubAgentExternalAgentRelationApiSelectSchema)
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
},
|
|
3527
|
+
...commonGetErrorResponses
|
|
3528
|
+
}
|
|
3529
|
+
}),
|
|
3530
|
+
async (c) => {
|
|
3531
|
+
const { tenantId, projectId, agentId, subAgentId, id } = c.req.valid("param");
|
|
3532
|
+
const body = await c.req.valid("json");
|
|
3533
|
+
const updatedRelation = await updateSubAgentExternalAgentRelation(dbClient_default)({
|
|
3534
|
+
scopes: { tenantId, projectId, agentId, subAgentId },
|
|
3535
|
+
relationId: id,
|
|
3536
|
+
data: body
|
|
3537
|
+
});
|
|
3538
|
+
if (!updatedRelation) {
|
|
3539
|
+
throw createApiError({
|
|
3540
|
+
code: "not_found",
|
|
3541
|
+
message: "Sub Agent External Agent Relation not found"
|
|
3542
|
+
});
|
|
3543
|
+
}
|
|
3544
|
+
return c.json({ data: updatedRelation });
|
|
3545
|
+
}
|
|
3546
|
+
);
|
|
3547
|
+
app15.openapi(
|
|
3548
|
+
createRoute({
|
|
3549
|
+
method: "delete",
|
|
3550
|
+
path: "/{id}",
|
|
3551
|
+
summary: "Delete Sub Agent External Agent Relation",
|
|
3552
|
+
operationId: "delete-sub-agent-external-agent-relation",
|
|
3553
|
+
tags: ["Sub Agent External Agent Relations"],
|
|
3554
|
+
request: {
|
|
3555
|
+
params: TenantProjectAgentSubAgentIdParamsSchema
|
|
3556
|
+
},
|
|
3557
|
+
responses: {
|
|
3558
|
+
204: {
|
|
3559
|
+
description: "Sub Agent External Agent Relation deleted successfully"
|
|
3560
|
+
},
|
|
3561
|
+
404: {
|
|
3562
|
+
description: "Sub Agent External Agent Relation not found",
|
|
3563
|
+
content: {
|
|
3564
|
+
"application/json": {
|
|
3565
|
+
schema: ErrorResponseSchema
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
}),
|
|
3571
|
+
async (c) => {
|
|
3572
|
+
const { tenantId, projectId, agentId, subAgentId, id } = c.req.valid("param");
|
|
3573
|
+
const deleted = await deleteSubAgentExternalAgentRelation(dbClient_default)({
|
|
3574
|
+
scopes: { tenantId, projectId, agentId, subAgentId },
|
|
3575
|
+
relationId: id
|
|
3576
|
+
});
|
|
3577
|
+
if (!deleted) {
|
|
3578
|
+
throw createApiError({
|
|
3579
|
+
code: "not_found",
|
|
3580
|
+
message: "Sub Agent External Agent Relation not found"
|
|
3581
|
+
});
|
|
3582
|
+
}
|
|
3583
|
+
return c.body(null, 204);
|
|
3584
|
+
}
|
|
3585
|
+
);
|
|
3586
|
+
var subAgentExternalAgentRelations_default = app15;
|
|
3587
|
+
var app16 = new OpenAPIHono();
|
|
3588
|
+
app16.openapi(
|
|
3368
3589
|
createRoute({
|
|
3369
3590
|
method: "get",
|
|
3370
3591
|
path: "/",
|
|
@@ -3389,13 +3610,7 @@ app15.openapi(
|
|
|
3389
3610
|
}),
|
|
3390
3611
|
async (c) => {
|
|
3391
3612
|
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
3392
|
-
const {
|
|
3393
|
-
page = 1,
|
|
3394
|
-
limit = 10,
|
|
3395
|
-
sourceSubAgentId,
|
|
3396
|
-
targetSubAgentId,
|
|
3397
|
-
externalSubAgentId
|
|
3398
|
-
} = c.req.valid("query");
|
|
3613
|
+
const { page = 1, limit = 10, sourceSubAgentId, targetSubAgentId } = c.req.valid("query");
|
|
3399
3614
|
const pageNum = Number(page);
|
|
3400
3615
|
const limitNum = Math.min(Number(limit), 100);
|
|
3401
3616
|
try {
|
|
@@ -3414,13 +3629,6 @@ app15.openapi(
|
|
|
3414
3629
|
pagination: { page: pageNum, limit: limitNum }
|
|
3415
3630
|
});
|
|
3416
3631
|
result = { ...rawResult, data: rawResult.data };
|
|
3417
|
-
} else if (externalSubAgentId) {
|
|
3418
|
-
const rawResult = await getExternalAgentRelations(dbClient_default)({
|
|
3419
|
-
scopes: { tenantId, projectId, agentId },
|
|
3420
|
-
externalSubAgentId,
|
|
3421
|
-
pagination: { page: pageNum, limit: limitNum }
|
|
3422
|
-
});
|
|
3423
|
-
result = { ...rawResult, data: rawResult.data };
|
|
3424
3632
|
} else {
|
|
3425
3633
|
const rawResult = await listAgentRelations(dbClient_default)({
|
|
3426
3634
|
scopes: { tenantId, projectId, agentId },
|
|
@@ -3437,7 +3645,7 @@ app15.openapi(
|
|
|
3437
3645
|
}
|
|
3438
3646
|
}
|
|
3439
3647
|
);
|
|
3440
|
-
|
|
3648
|
+
app16.openapi(
|
|
3441
3649
|
createRoute({
|
|
3442
3650
|
method: "get",
|
|
3443
3651
|
path: "/{id}",
|
|
@@ -3474,7 +3682,7 @@ app15.openapi(
|
|
|
3474
3682
|
return c.json({ data: agentRelation });
|
|
3475
3683
|
}
|
|
3476
3684
|
);
|
|
3477
|
-
|
|
3685
|
+
app16.openapi(
|
|
3478
3686
|
createRoute({
|
|
3479
3687
|
method: "post",
|
|
3480
3688
|
path: "/",
|
|
@@ -3506,26 +3714,14 @@ app15.openapi(
|
|
|
3506
3714
|
async (c) => {
|
|
3507
3715
|
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
3508
3716
|
const body = await c.req.valid("json");
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
const externalAgentExists = await validateExternalAgent(dbClient_default)({
|
|
3512
|
-
scopes: { tenantId, projectId, agentId, subAgentId: body.externalSubAgentId }
|
|
3513
|
-
});
|
|
3514
|
-
if (!externalAgentExists) {
|
|
3515
|
-
throw createApiError({
|
|
3516
|
-
code: "bad_request",
|
|
3517
|
-
message: `External agent with ID ${body.externalSubAgentId} not found`
|
|
3518
|
-
});
|
|
3519
|
-
}
|
|
3520
|
-
}
|
|
3521
|
-
if (!isExternalAgent && body.targetSubAgentId) {
|
|
3522
|
-
const internalAgentExists = await validateInternalSubAgent(dbClient_default)({
|
|
3717
|
+
if (body.targetSubAgentId) {
|
|
3718
|
+
const subAgentExists = await validateSubAgent(dbClient_default)({
|
|
3523
3719
|
scopes: { tenantId, projectId, agentId, subAgentId: body.targetSubAgentId }
|
|
3524
3720
|
});
|
|
3525
|
-
if (!
|
|
3721
|
+
if (!subAgentExists) {
|
|
3526
3722
|
throw createApiError({
|
|
3527
3723
|
code: "bad_request",
|
|
3528
|
-
message: `
|
|
3724
|
+
message: `Sub agent with ID ${body.targetSubAgentId} not found`
|
|
3529
3725
|
});
|
|
3530
3726
|
}
|
|
3531
3727
|
}
|
|
@@ -3537,26 +3733,21 @@ app15.openapi(
|
|
|
3537
3733
|
if (relation.agentId !== agentId || relation.sourceSubAgentId !== body.sourceSubAgentId) {
|
|
3538
3734
|
return false;
|
|
3539
3735
|
}
|
|
3540
|
-
if (isExternalAgent) {
|
|
3541
|
-
return relation.externalSubAgentId === body.externalSubAgentId;
|
|
3542
|
-
}
|
|
3543
3736
|
return relation.targetSubAgentId === body.targetSubAgentId;
|
|
3544
3737
|
});
|
|
3545
3738
|
if (isDuplicate) {
|
|
3546
|
-
const agentType = isExternalAgent ? "external" : "internal";
|
|
3547
3739
|
throw createApiError({
|
|
3548
3740
|
code: "unprocessable_entity",
|
|
3549
|
-
message: `A relation between these agents
|
|
3741
|
+
message: `A relation between these agents in this agent already exists`
|
|
3550
3742
|
});
|
|
3551
3743
|
}
|
|
3552
3744
|
const relationData = {
|
|
3553
3745
|
agentId,
|
|
3554
3746
|
tenantId,
|
|
3555
|
-
id:
|
|
3747
|
+
id: generateId(),
|
|
3556
3748
|
projectId,
|
|
3557
3749
|
sourceSubAgentId: body.sourceSubAgentId,
|
|
3558
|
-
targetSubAgentId:
|
|
3559
|
-
externalSubAgentId: isExternalAgent ? body.externalSubAgentId : void 0,
|
|
3750
|
+
targetSubAgentId: body.targetSubAgentId,
|
|
3560
3751
|
relationType: body.relationType
|
|
3561
3752
|
};
|
|
3562
3753
|
const agentRelation = await createSubAgentRelation(dbClient_default)({
|
|
@@ -3565,7 +3756,7 @@ app15.openapi(
|
|
|
3565
3756
|
return c.json({ data: agentRelation }, 201);
|
|
3566
3757
|
}
|
|
3567
3758
|
);
|
|
3568
|
-
|
|
3759
|
+
app16.openapi(
|
|
3569
3760
|
createRoute({
|
|
3570
3761
|
method: "put",
|
|
3571
3762
|
path: "/{id}",
|
|
@@ -3611,7 +3802,7 @@ app15.openapi(
|
|
|
3611
3802
|
return c.json({ data: updatedAgentRelation });
|
|
3612
3803
|
}
|
|
3613
3804
|
);
|
|
3614
|
-
|
|
3805
|
+
app16.openapi(
|
|
3615
3806
|
createRoute({
|
|
3616
3807
|
method: "delete",
|
|
3617
3808
|
path: "/{id}",
|
|
@@ -3650,9 +3841,9 @@ app15.openapi(
|
|
|
3650
3841
|
return c.body(null, 204);
|
|
3651
3842
|
}
|
|
3652
3843
|
);
|
|
3653
|
-
var subAgentRelations_default =
|
|
3654
|
-
var
|
|
3655
|
-
|
|
3844
|
+
var subAgentRelations_default = app16;
|
|
3845
|
+
var app17 = new OpenAPIHono();
|
|
3846
|
+
app17.openapi(
|
|
3656
3847
|
createRoute({
|
|
3657
3848
|
method: "get",
|
|
3658
3849
|
path: "/",
|
|
@@ -3693,7 +3884,7 @@ app16.openapi(
|
|
|
3693
3884
|
return c.json(dataWithType);
|
|
3694
3885
|
}
|
|
3695
3886
|
);
|
|
3696
|
-
|
|
3887
|
+
app17.openapi(
|
|
3697
3888
|
createRoute({
|
|
3698
3889
|
method: "get",
|
|
3699
3890
|
path: "/{id}",
|
|
@@ -3734,7 +3925,7 @@ app16.openapi(
|
|
|
3734
3925
|
return c.json({ data: subAgentWithType });
|
|
3735
3926
|
}
|
|
3736
3927
|
);
|
|
3737
|
-
|
|
3928
|
+
app17.openapi(
|
|
3738
3929
|
createRoute({
|
|
3739
3930
|
method: "post",
|
|
3740
3931
|
path: "/",
|
|
@@ -3766,7 +3957,7 @@ app16.openapi(
|
|
|
3766
3957
|
async (c) => {
|
|
3767
3958
|
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
3768
3959
|
const body = c.req.valid("json");
|
|
3769
|
-
const subAgentId = body.id ? String(body.id) :
|
|
3960
|
+
const subAgentId = body.id ? String(body.id) : generateId();
|
|
3770
3961
|
const subAgent = await createSubAgent(dbClient_default)({
|
|
3771
3962
|
...body,
|
|
3772
3963
|
id: subAgentId,
|
|
@@ -3781,7 +3972,7 @@ app16.openapi(
|
|
|
3781
3972
|
return c.json({ data: subAgentWithType }, 201);
|
|
3782
3973
|
}
|
|
3783
3974
|
);
|
|
3784
|
-
|
|
3975
|
+
app17.openapi(
|
|
3785
3976
|
createRoute({
|
|
3786
3977
|
method: "put",
|
|
3787
3978
|
path: "/{id}",
|
|
@@ -3831,7 +4022,7 @@ app16.openapi(
|
|
|
3831
4022
|
return c.json({ data: subAgentWithType });
|
|
3832
4023
|
}
|
|
3833
4024
|
);
|
|
3834
|
-
|
|
4025
|
+
app17.openapi(
|
|
3835
4026
|
createRoute({
|
|
3836
4027
|
method: "delete",
|
|
3837
4028
|
path: "/{id}",
|
|
@@ -3870,9 +4061,9 @@ app16.openapi(
|
|
|
3870
4061
|
return c.body(null, 204);
|
|
3871
4062
|
}
|
|
3872
4063
|
);
|
|
3873
|
-
var subAgents_default =
|
|
3874
|
-
var
|
|
3875
|
-
|
|
4064
|
+
var subAgents_default = app17;
|
|
4065
|
+
var app18 = new OpenAPIHono();
|
|
4066
|
+
app18.openapi(
|
|
3876
4067
|
createRoute({
|
|
3877
4068
|
method: "get",
|
|
3878
4069
|
path: "/",
|
|
@@ -3934,7 +4125,7 @@ app17.openapi(
|
|
|
3934
4125
|
return c.json(result);
|
|
3935
4126
|
}
|
|
3936
4127
|
);
|
|
3937
|
-
|
|
4128
|
+
app18.openapi(
|
|
3938
4129
|
createRoute({
|
|
3939
4130
|
method: "get",
|
|
3940
4131
|
path: "/{id}",
|
|
@@ -3971,7 +4162,7 @@ app17.openapi(
|
|
|
3971
4162
|
return c.json({ data: agentToolRelation });
|
|
3972
4163
|
}
|
|
3973
4164
|
);
|
|
3974
|
-
|
|
4165
|
+
app18.openapi(
|
|
3975
4166
|
createRoute({
|
|
3976
4167
|
method: "get",
|
|
3977
4168
|
path: "/tool/{toolId}/sub-agents",
|
|
@@ -4007,7 +4198,7 @@ app17.openapi(
|
|
|
4007
4198
|
return c.json(dbResult);
|
|
4008
4199
|
}
|
|
4009
4200
|
);
|
|
4010
|
-
|
|
4201
|
+
app18.openapi(
|
|
4011
4202
|
createRoute({
|
|
4012
4203
|
method: "post",
|
|
4013
4204
|
path: "/",
|
|
@@ -4070,7 +4261,7 @@ app17.openapi(
|
|
|
4070
4261
|
}
|
|
4071
4262
|
}
|
|
4072
4263
|
);
|
|
4073
|
-
|
|
4264
|
+
app18.openapi(
|
|
4074
4265
|
createRoute({
|
|
4075
4266
|
method: "put",
|
|
4076
4267
|
path: "/{id}",
|
|
@@ -4123,7 +4314,7 @@ app17.openapi(
|
|
|
4123
4314
|
return c.json({ data: updatedAgentToolRelation });
|
|
4124
4315
|
}
|
|
4125
4316
|
);
|
|
4126
|
-
|
|
4317
|
+
app18.openapi(
|
|
4127
4318
|
createRoute({
|
|
4128
4319
|
method: "delete",
|
|
4129
4320
|
path: "/{id}",
|
|
@@ -4162,10 +4353,10 @@ app17.openapi(
|
|
|
4162
4353
|
return c.body(null, 204);
|
|
4163
4354
|
}
|
|
4164
4355
|
);
|
|
4165
|
-
var subAgentToolRelations_default =
|
|
4356
|
+
var subAgentToolRelations_default = app18;
|
|
4166
4357
|
var logger5 = getLogger("tools");
|
|
4167
|
-
var
|
|
4168
|
-
|
|
4358
|
+
var app19 = new OpenAPIHono();
|
|
4359
|
+
app19.openapi(
|
|
4169
4360
|
createRoute({
|
|
4170
4361
|
method: "get",
|
|
4171
4362
|
path: "/",
|
|
@@ -4225,7 +4416,7 @@ app18.openapi(
|
|
|
4225
4416
|
return c.json(result);
|
|
4226
4417
|
}
|
|
4227
4418
|
);
|
|
4228
|
-
|
|
4419
|
+
app19.openapi(
|
|
4229
4420
|
createRoute({
|
|
4230
4421
|
method: "get",
|
|
4231
4422
|
path: "/{id}",
|
|
@@ -4262,7 +4453,7 @@ app18.openapi(
|
|
|
4262
4453
|
});
|
|
4263
4454
|
}
|
|
4264
4455
|
);
|
|
4265
|
-
|
|
4456
|
+
app19.openapi(
|
|
4266
4457
|
createRoute({
|
|
4267
4458
|
method: "post",
|
|
4268
4459
|
path: "/",
|
|
@@ -4296,7 +4487,7 @@ app18.openapi(
|
|
|
4296
4487
|
const body = c.req.valid("json");
|
|
4297
4488
|
const credentialStores = c.get("credentialStores");
|
|
4298
4489
|
logger5.info({ body }, "body");
|
|
4299
|
-
const id = body.id ||
|
|
4490
|
+
const id = body.id || generateId();
|
|
4300
4491
|
const tool = await createTool(dbClient_default)({
|
|
4301
4492
|
tenantId,
|
|
4302
4493
|
projectId,
|
|
@@ -4315,7 +4506,7 @@ app18.openapi(
|
|
|
4315
4506
|
);
|
|
4316
4507
|
}
|
|
4317
4508
|
);
|
|
4318
|
-
|
|
4509
|
+
app19.openapi(
|
|
4319
4510
|
createRoute({
|
|
4320
4511
|
method: "put",
|
|
4321
4512
|
path: "/{id}",
|
|
@@ -4376,7 +4567,7 @@ app18.openapi(
|
|
|
4376
4567
|
});
|
|
4377
4568
|
}
|
|
4378
4569
|
);
|
|
4379
|
-
|
|
4570
|
+
app19.openapi(
|
|
4380
4571
|
createRoute({
|
|
4381
4572
|
method: "delete",
|
|
4382
4573
|
path: "/{id}",
|
|
@@ -4412,38 +4603,42 @@ app18.openapi(
|
|
|
4412
4603
|
return c.body(null, 204);
|
|
4413
4604
|
}
|
|
4414
4605
|
);
|
|
4415
|
-
var tools_default =
|
|
4606
|
+
var tools_default = app19;
|
|
4416
4607
|
|
|
4417
4608
|
// src/routes/index.ts
|
|
4418
|
-
var
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4609
|
+
var app20 = new OpenAPIHono();
|
|
4610
|
+
app20.route("/projects", projects_default);
|
|
4611
|
+
app20.route("/projects/:projectId/agents/:agentId/sub-agents", subAgents_default);
|
|
4612
|
+
app20.route("/projects/:projectId/agents/:agentId/sub-agent-relations", subAgentRelations_default);
|
|
4613
|
+
app20.route(
|
|
4614
|
+
"/projects/:projectId/agents/:agentId/sub-agents/:subAgentId/external-agent-relations",
|
|
4615
|
+
subAgentExternalAgentRelations_default
|
|
4616
|
+
);
|
|
4617
|
+
app20.route("/projects/:projectId/agents", agent_default);
|
|
4618
|
+
app20.route(
|
|
4424
4619
|
"/projects/:projectId/agents/:agentId/sub-agent-tool-relations",
|
|
4425
4620
|
subAgentToolRelations_default
|
|
4426
4621
|
);
|
|
4427
|
-
|
|
4622
|
+
app20.route(
|
|
4428
4623
|
"/projects/:projectId/agents/:agentId/sub-agent-artifact-components",
|
|
4429
4624
|
subAgentArtifactComponents_default
|
|
4430
4625
|
);
|
|
4431
|
-
|
|
4626
|
+
app20.route(
|
|
4432
4627
|
"/projects/:projectId/agents/:agentId/sub-agent-data-components",
|
|
4433
4628
|
subAgentDataComponents_default
|
|
4434
4629
|
);
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
var routes_default =
|
|
4630
|
+
app20.route("/projects/:projectId/artifact-components", artifactComponents_default);
|
|
4631
|
+
app20.route("/projects/:projectId/agents/:agentId/context-configs", contextConfigs_default);
|
|
4632
|
+
app20.route("/projects/:projectId/credentials", credentials_default);
|
|
4633
|
+
app20.route("/projects/:projectId/credential-stores", credentialStores_default);
|
|
4634
|
+
app20.route("/projects/:projectId/data-components", dataComponents_default);
|
|
4635
|
+
app20.route("/projects/:projectId/external-agents", externalAgents_default);
|
|
4636
|
+
app20.route("/projects/:projectId/agents/:agentId/function-tools", functionTools_default);
|
|
4637
|
+
app20.route("/projects/:projectId/functions", functions_default);
|
|
4638
|
+
app20.route("/projects/:projectId/tools", tools_default);
|
|
4639
|
+
app20.route("/projects/:projectId/api-keys", apiKeys_default);
|
|
4640
|
+
app20.route("/projects/:projectId/agent", agentFull_default);
|
|
4641
|
+
var routes_default = app20;
|
|
4447
4642
|
var logger6 = getLogger("oauth-service");
|
|
4448
4643
|
var pkceStore = /* @__PURE__ */ new Map();
|
|
4449
4644
|
function storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientInformation, metadata, resourceUrl) {
|
|
@@ -4558,7 +4753,7 @@ var oauthService = new OAuthService();
|
|
|
4558
4753
|
// src/routes/oauth.ts
|
|
4559
4754
|
async function findOrCreateCredential(tenantId, projectId, credentialData) {
|
|
4560
4755
|
try {
|
|
4561
|
-
const existingCredential = await
|
|
4756
|
+
const existingCredential = await getCredentialReferenceWithResources(dbClient_default)({
|
|
4562
4757
|
scopes: { tenantId, projectId },
|
|
4563
4758
|
id: credentialData.id
|
|
4564
4759
|
});
|
|
@@ -4581,7 +4776,7 @@ async function findOrCreateCredential(tenantId, projectId, credentialData) {
|
|
|
4581
4776
|
throw new Error(`Failed to save credential '${credentialData.id}' to database`);
|
|
4582
4777
|
}
|
|
4583
4778
|
}
|
|
4584
|
-
var
|
|
4779
|
+
var app21 = new OpenAPIHono();
|
|
4585
4780
|
var logger7 = getLogger("oauth-callback");
|
|
4586
4781
|
function getBaseUrlFromRequest(c) {
|
|
4587
4782
|
const url = new URL(c.req.url);
|
|
@@ -4668,7 +4863,7 @@ var OAuthCallbackQuerySchema = z$1.object({
|
|
|
4668
4863
|
error: z$1.string().optional(),
|
|
4669
4864
|
error_description: z$1.string().optional()
|
|
4670
4865
|
});
|
|
4671
|
-
|
|
4866
|
+
app21.openapi(
|
|
4672
4867
|
createRoute({
|
|
4673
4868
|
method: "get",
|
|
4674
4869
|
path: "/login",
|
|
@@ -4733,7 +4928,7 @@ app20.openapi(
|
|
|
4733
4928
|
}
|
|
4734
4929
|
}
|
|
4735
4930
|
);
|
|
4736
|
-
|
|
4931
|
+
app21.openapi(
|
|
4737
4932
|
createRoute({
|
|
4738
4933
|
method: "get",
|
|
4739
4934
|
path: "/callback",
|
|
@@ -4875,9 +5070,9 @@ app20.openapi(
|
|
|
4875
5070
|
}
|
|
4876
5071
|
}
|
|
4877
5072
|
);
|
|
4878
|
-
var oauth_default =
|
|
5073
|
+
var oauth_default = app21;
|
|
4879
5074
|
var logger8 = getLogger("projectFull");
|
|
4880
|
-
var
|
|
5075
|
+
var app22 = new OpenAPIHono();
|
|
4881
5076
|
var ProjectIdParamsSchema = z.object({
|
|
4882
5077
|
tenantId: z.string().openapi({
|
|
4883
5078
|
description: "Tenant identifier",
|
|
@@ -4894,7 +5089,7 @@ var TenantParamsSchema2 = z.object({
|
|
|
4894
5089
|
example: "tenant_123"
|
|
4895
5090
|
})
|
|
4896
5091
|
}).openapi("TenantParams");
|
|
4897
|
-
|
|
5092
|
+
app22.openapi(
|
|
4898
5093
|
createRoute({
|
|
4899
5094
|
method: "post",
|
|
4900
5095
|
path: "/project-full",
|
|
@@ -4936,6 +5131,7 @@ app21.openapi(
|
|
|
4936
5131
|
const { tenantId } = c.req.valid("param");
|
|
4937
5132
|
const projectData = c.req.valid("json");
|
|
4938
5133
|
const validatedProjectData = FullProjectDefinitionSchema.parse(projectData);
|
|
5134
|
+
console.log("validatedProjectData", validatedProjectData);
|
|
4939
5135
|
try {
|
|
4940
5136
|
const createdProject = await createFullProjectServerSide(dbClient_default, logger8)(
|
|
4941
5137
|
{ tenantId, projectId: validatedProjectData.id },
|
|
@@ -4953,7 +5149,7 @@ app21.openapi(
|
|
|
4953
5149
|
}
|
|
4954
5150
|
}
|
|
4955
5151
|
);
|
|
4956
|
-
|
|
5152
|
+
app22.openapi(
|
|
4957
5153
|
createRoute({
|
|
4958
5154
|
method: "get",
|
|
4959
5155
|
path: "/project-full/{projectId}",
|
|
@@ -5006,7 +5202,7 @@ app21.openapi(
|
|
|
5006
5202
|
}
|
|
5007
5203
|
}
|
|
5008
5204
|
);
|
|
5009
|
-
|
|
5205
|
+
app22.openapi(
|
|
5010
5206
|
createRoute({
|
|
5011
5207
|
method: "put",
|
|
5012
5208
|
path: "/project-full/{projectId}",
|
|
@@ -5090,7 +5286,7 @@ app21.openapi(
|
|
|
5090
5286
|
}
|
|
5091
5287
|
}
|
|
5092
5288
|
);
|
|
5093
|
-
|
|
5289
|
+
app22.openapi(
|
|
5094
5290
|
createRoute({
|
|
5095
5291
|
method: "delete",
|
|
5096
5292
|
path: "/project-full/{projectId}",
|
|
@@ -5138,20 +5334,20 @@ app21.openapi(
|
|
|
5138
5334
|
}
|
|
5139
5335
|
}
|
|
5140
5336
|
);
|
|
5141
|
-
var projectFull_default =
|
|
5337
|
+
var projectFull_default = app22;
|
|
5142
5338
|
|
|
5143
5339
|
// src/app.ts
|
|
5144
5340
|
var logger9 = getLogger("agents-manage-api");
|
|
5145
5341
|
logger9.info({ logger: logger9.getTransports() }, "Logger initialized");
|
|
5146
5342
|
function createManagementHono(serverConfig, credentialStores) {
|
|
5147
|
-
const
|
|
5148
|
-
|
|
5149
|
-
|
|
5343
|
+
const app24 = new OpenAPIHono();
|
|
5344
|
+
app24.use("*", requestId());
|
|
5345
|
+
app24.use("*", async (c, next) => {
|
|
5150
5346
|
c.set("serverConfig", serverConfig);
|
|
5151
5347
|
c.set("credentialStores", credentialStores);
|
|
5152
5348
|
return next();
|
|
5153
5349
|
});
|
|
5154
|
-
|
|
5350
|
+
app24.use(
|
|
5155
5351
|
pinoLogger({
|
|
5156
5352
|
pino: getLogger("agents-manage-api").getPinoInstance(),
|
|
5157
5353
|
http: {
|
|
@@ -5164,7 +5360,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5164
5360
|
}
|
|
5165
5361
|
})
|
|
5166
5362
|
);
|
|
5167
|
-
|
|
5363
|
+
app24.onError(async (err, c) => {
|
|
5168
5364
|
const isExpectedError = err instanceof HTTPException;
|
|
5169
5365
|
const status = isExpectedError ? err.status : 500;
|
|
5170
5366
|
const requestId2 = c.get("requestId") || "unknown";
|
|
@@ -5239,7 +5435,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5239
5435
|
...instance && { instance }
|
|
5240
5436
|
});
|
|
5241
5437
|
});
|
|
5242
|
-
|
|
5438
|
+
app24.use(
|
|
5243
5439
|
"*",
|
|
5244
5440
|
cors({
|
|
5245
5441
|
origin: (origin) => {
|
|
@@ -5253,7 +5449,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5253
5449
|
credentials: true
|
|
5254
5450
|
})
|
|
5255
5451
|
);
|
|
5256
|
-
|
|
5452
|
+
app24.openapi(
|
|
5257
5453
|
createRoute({
|
|
5258
5454
|
method: "get",
|
|
5259
5455
|
path: "/health",
|
|
@@ -5270,13 +5466,13 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5270
5466
|
return c.body(null, 204);
|
|
5271
5467
|
}
|
|
5272
5468
|
);
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
setupOpenAPIRoutes(
|
|
5469
|
+
app24.use("/tenants/*", apiKeyAuth());
|
|
5470
|
+
app24.route("/tenants/:tenantId", routes_default);
|
|
5471
|
+
app24.route("/tenants/:tenantId", projectFull_default);
|
|
5472
|
+
app24.route("/oauth", oauth_default);
|
|
5473
|
+
setupOpenAPIRoutes(app24);
|
|
5278
5474
|
const baseApp = new Hono();
|
|
5279
|
-
baseApp.route("/",
|
|
5475
|
+
baseApp.route("/", app24);
|
|
5280
5476
|
return baseApp;
|
|
5281
5477
|
}
|
|
5282
5478
|
|
|
@@ -5292,8 +5488,8 @@ var defaultConfig = {
|
|
|
5292
5488
|
};
|
|
5293
5489
|
var defaultStores = createDefaultCredentialStores();
|
|
5294
5490
|
var defaultRegistry = new CredentialStoreRegistry(defaultStores);
|
|
5295
|
-
var
|
|
5296
|
-
var index_default =
|
|
5491
|
+
var app23 = createManagementHono(defaultConfig, defaultRegistry);
|
|
5492
|
+
var index_default = app23;
|
|
5297
5493
|
function createManagementApp(config) {
|
|
5298
5494
|
const serverConfig = config?.serverConfig ?? defaultConfig;
|
|
5299
5495
|
const stores = config?.credentialStores ?? defaultStores;
|