@inkeep/agents-manage-api 0.24.2 → 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 +332 -135
- package/dist/index.js +333 -136
- 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, 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,
|
|
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';
|
|
@@ -8,6 +8,7 @@ import { pinoLogger } from 'hono-pino';
|
|
|
8
8
|
import { createMiddleware } from 'hono/factory';
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
import { swaggerUI } from '@hono/swagger-ui';
|
|
11
|
+
import { nanoid } from 'nanoid';
|
|
11
12
|
|
|
12
13
|
var __defProp = Object.defineProperty;
|
|
13
14
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -67,10 +68,10 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
|
|
|
67
68
|
await next();
|
|
68
69
|
return;
|
|
69
70
|
});
|
|
70
|
-
function setupOpenAPIRoutes(
|
|
71
|
-
|
|
71
|
+
function setupOpenAPIRoutes(app24) {
|
|
72
|
+
app24.get("/openapi.json", (c) => {
|
|
72
73
|
try {
|
|
73
|
-
const document =
|
|
74
|
+
const document = app24.getOpenAPIDocument({
|
|
74
75
|
openapi: "3.0.0",
|
|
75
76
|
info: {
|
|
76
77
|
title: "Inkeep Agents Manage API",
|
|
@@ -91,7 +92,7 @@ function setupOpenAPIRoutes(app23) {
|
|
|
91
92
|
return c.json({ error: "Failed to generate OpenAPI document", details: errorDetails }, 500);
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
|
-
|
|
95
|
+
app24.get(
|
|
95
96
|
"/docs",
|
|
96
97
|
swaggerUI({
|
|
97
98
|
url: "/openapi.json",
|
|
@@ -573,6 +574,7 @@ app2.openapi(
|
|
|
573
574
|
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
574
575
|
const agentData = c.req.valid("json");
|
|
575
576
|
try {
|
|
577
|
+
logger2.info({}, "test agent data");
|
|
576
578
|
const validatedAgentData = AgentWithinContextOfProjectSchema.parse(agentData);
|
|
577
579
|
if (agentId !== validatedAgentData.id) {
|
|
578
580
|
throw createApiError({
|
|
@@ -1549,7 +1551,7 @@ app7.openapi(
|
|
|
1549
1551
|
}),
|
|
1550
1552
|
async (c) => {
|
|
1551
1553
|
const { tenantId, projectId, id } = c.req.valid("param");
|
|
1552
|
-
const credential = await
|
|
1554
|
+
const credential = await getCredentialReferenceWithResources(dbClient_default)({
|
|
1553
1555
|
scopes: { tenantId, projectId },
|
|
1554
1556
|
id
|
|
1555
1557
|
});
|
|
@@ -1952,7 +1954,7 @@ app9.openapi(
|
|
|
1952
1954
|
operationId: "list-external-agents",
|
|
1953
1955
|
tags: ["External Agents"],
|
|
1954
1956
|
request: {
|
|
1955
|
-
params:
|
|
1957
|
+
params: TenantProjectParamsSchema,
|
|
1956
1958
|
query: PaginationQueryParamsSchema
|
|
1957
1959
|
},
|
|
1958
1960
|
responses: {
|
|
@@ -1968,10 +1970,10 @@ app9.openapi(
|
|
|
1968
1970
|
}
|
|
1969
1971
|
}),
|
|
1970
1972
|
async (c) => {
|
|
1971
|
-
const { tenantId, projectId
|
|
1973
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
1972
1974
|
const { page, limit } = c.req.valid("query");
|
|
1973
1975
|
const result = await listExternalAgentsPaginated(dbClient_default)({
|
|
1974
|
-
scopes: { tenantId, projectId
|
|
1976
|
+
scopes: { tenantId, projectId },
|
|
1975
1977
|
pagination: { page, limit }
|
|
1976
1978
|
});
|
|
1977
1979
|
const dataWithType = {
|
|
@@ -1992,7 +1994,7 @@ app9.openapi(
|
|
|
1992
1994
|
operationId: "get-external-agent-by-id",
|
|
1993
1995
|
tags: ["External Agents"],
|
|
1994
1996
|
request: {
|
|
1995
|
-
params:
|
|
1997
|
+
params: TenantProjectIdParamsSchema
|
|
1996
1998
|
},
|
|
1997
1999
|
responses: {
|
|
1998
2000
|
200: {
|
|
@@ -2007,10 +2009,10 @@ app9.openapi(
|
|
|
2007
2009
|
}
|
|
2008
2010
|
}),
|
|
2009
2011
|
async (c) => {
|
|
2010
|
-
const { tenantId, projectId,
|
|
2012
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
2011
2013
|
const externalAgent = await getExternalAgent(dbClient_default)({
|
|
2012
|
-
scopes: { tenantId, projectId
|
|
2013
|
-
|
|
2014
|
+
scopes: { tenantId, projectId },
|
|
2015
|
+
externalAgentId: id
|
|
2014
2016
|
});
|
|
2015
2017
|
if (!externalAgent) {
|
|
2016
2018
|
throw createApiError({
|
|
@@ -2033,7 +2035,7 @@ app9.openapi(
|
|
|
2033
2035
|
operationId: "create-external-agent",
|
|
2034
2036
|
tags: ["External Agents"],
|
|
2035
2037
|
request: {
|
|
2036
|
-
params:
|
|
2038
|
+
params: TenantProjectParamsSchema,
|
|
2037
2039
|
body: {
|
|
2038
2040
|
content: {
|
|
2039
2041
|
"application/json": {
|
|
@@ -2055,18 +2057,16 @@ app9.openapi(
|
|
|
2055
2057
|
}
|
|
2056
2058
|
}),
|
|
2057
2059
|
async (c) => {
|
|
2058
|
-
const { tenantId, projectId
|
|
2060
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
2059
2061
|
const body = c.req.valid("json");
|
|
2060
2062
|
const externalAgentData = {
|
|
2061
2063
|
tenantId,
|
|
2062
2064
|
projectId,
|
|
2063
|
-
agentId,
|
|
2064
2065
|
id: body.id ? String(body.id) : generateId(),
|
|
2065
2066
|
name: body.name,
|
|
2066
2067
|
description: body.description,
|
|
2067
2068
|
baseUrl: body.baseUrl,
|
|
2068
|
-
credentialReferenceId: body.credentialReferenceId || void 0
|
|
2069
|
-
headers: body.headers || void 0
|
|
2069
|
+
credentialReferenceId: body.credentialReferenceId || void 0
|
|
2070
2070
|
};
|
|
2071
2071
|
const externalAgent = await createExternalAgent(dbClient_default)(externalAgentData);
|
|
2072
2072
|
const agentWithType = {
|
|
@@ -2084,7 +2084,7 @@ app9.openapi(
|
|
|
2084
2084
|
operationId: "update-external-agent",
|
|
2085
2085
|
tags: ["External Agents"],
|
|
2086
2086
|
request: {
|
|
2087
|
-
params:
|
|
2087
|
+
params: TenantProjectIdParamsSchema,
|
|
2088
2088
|
body: {
|
|
2089
2089
|
content: {
|
|
2090
2090
|
"application/json": {
|
|
@@ -2106,11 +2106,11 @@ app9.openapi(
|
|
|
2106
2106
|
}
|
|
2107
2107
|
}),
|
|
2108
2108
|
async (c) => {
|
|
2109
|
-
const { tenantId, projectId,
|
|
2109
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
2110
2110
|
const body = c.req.valid("json");
|
|
2111
2111
|
const updatedExternalAgent = await updateExternalAgent(dbClient_default)({
|
|
2112
|
-
scopes: { tenantId, projectId
|
|
2113
|
-
|
|
2112
|
+
scopes: { tenantId, projectId },
|
|
2113
|
+
externalAgentId: id,
|
|
2114
2114
|
data: body
|
|
2115
2115
|
});
|
|
2116
2116
|
if (!updatedExternalAgent) {
|
|
@@ -2134,7 +2134,7 @@ app9.openapi(
|
|
|
2134
2134
|
operationId: "delete-external-agent",
|
|
2135
2135
|
tags: ["External Agents"],
|
|
2136
2136
|
request: {
|
|
2137
|
-
params:
|
|
2137
|
+
params: TenantProjectIdParamsSchema
|
|
2138
2138
|
},
|
|
2139
2139
|
responses: {
|
|
2140
2140
|
204: {
|
|
@@ -2151,10 +2151,10 @@ app9.openapi(
|
|
|
2151
2151
|
}
|
|
2152
2152
|
}),
|
|
2153
2153
|
async (c) => {
|
|
2154
|
-
const { tenantId, projectId,
|
|
2154
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
2155
2155
|
const deleted = await deleteExternalAgent(dbClient_default)({
|
|
2156
|
-
scopes: { tenantId, projectId
|
|
2157
|
-
|
|
2156
|
+
scopes: { tenantId, projectId },
|
|
2157
|
+
externalAgentId: id
|
|
2158
2158
|
});
|
|
2159
2159
|
if (!deleted) {
|
|
2160
2160
|
throw createApiError({
|
|
@@ -3364,6 +3364,228 @@ app14.openapi(
|
|
|
3364
3364
|
var subAgentDataComponents_default = app14;
|
|
3365
3365
|
var app15 = new OpenAPIHono();
|
|
3366
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(
|
|
3367
3589
|
createRoute({
|
|
3368
3590
|
method: "get",
|
|
3369
3591
|
path: "/",
|
|
@@ -3388,13 +3610,7 @@ app15.openapi(
|
|
|
3388
3610
|
}),
|
|
3389
3611
|
async (c) => {
|
|
3390
3612
|
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
3391
|
-
const {
|
|
3392
|
-
page = 1,
|
|
3393
|
-
limit = 10,
|
|
3394
|
-
sourceSubAgentId,
|
|
3395
|
-
targetSubAgentId,
|
|
3396
|
-
externalSubAgentId
|
|
3397
|
-
} = c.req.valid("query");
|
|
3613
|
+
const { page = 1, limit = 10, sourceSubAgentId, targetSubAgentId } = c.req.valid("query");
|
|
3398
3614
|
const pageNum = Number(page);
|
|
3399
3615
|
const limitNum = Math.min(Number(limit), 100);
|
|
3400
3616
|
try {
|
|
@@ -3413,13 +3629,6 @@ app15.openapi(
|
|
|
3413
3629
|
pagination: { page: pageNum, limit: limitNum }
|
|
3414
3630
|
});
|
|
3415
3631
|
result = { ...rawResult, data: rawResult.data };
|
|
3416
|
-
} else if (externalSubAgentId) {
|
|
3417
|
-
const rawResult = await getExternalAgentRelations(dbClient_default)({
|
|
3418
|
-
scopes: { tenantId, projectId, agentId },
|
|
3419
|
-
externalSubAgentId,
|
|
3420
|
-
pagination: { page: pageNum, limit: limitNum }
|
|
3421
|
-
});
|
|
3422
|
-
result = { ...rawResult, data: rawResult.data };
|
|
3423
3632
|
} else {
|
|
3424
3633
|
const rawResult = await listAgentRelations(dbClient_default)({
|
|
3425
3634
|
scopes: { tenantId, projectId, agentId },
|
|
@@ -3436,7 +3645,7 @@ app15.openapi(
|
|
|
3436
3645
|
}
|
|
3437
3646
|
}
|
|
3438
3647
|
);
|
|
3439
|
-
|
|
3648
|
+
app16.openapi(
|
|
3440
3649
|
createRoute({
|
|
3441
3650
|
method: "get",
|
|
3442
3651
|
path: "/{id}",
|
|
@@ -3473,7 +3682,7 @@ app15.openapi(
|
|
|
3473
3682
|
return c.json({ data: agentRelation });
|
|
3474
3683
|
}
|
|
3475
3684
|
);
|
|
3476
|
-
|
|
3685
|
+
app16.openapi(
|
|
3477
3686
|
createRoute({
|
|
3478
3687
|
method: "post",
|
|
3479
3688
|
path: "/",
|
|
@@ -3505,26 +3714,14 @@ app15.openapi(
|
|
|
3505
3714
|
async (c) => {
|
|
3506
3715
|
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
3507
3716
|
const body = await c.req.valid("json");
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
const externalAgentExists = await validateExternalAgent(dbClient_default)({
|
|
3511
|
-
scopes: { tenantId, projectId, agentId, subAgentId: body.externalSubAgentId }
|
|
3512
|
-
});
|
|
3513
|
-
if (!externalAgentExists) {
|
|
3514
|
-
throw createApiError({
|
|
3515
|
-
code: "bad_request",
|
|
3516
|
-
message: `External agent with ID ${body.externalSubAgentId} not found`
|
|
3517
|
-
});
|
|
3518
|
-
}
|
|
3519
|
-
}
|
|
3520
|
-
if (!isExternalAgent && body.targetSubAgentId) {
|
|
3521
|
-
const internalAgentExists = await validateInternalSubAgent(dbClient_default)({
|
|
3717
|
+
if (body.targetSubAgentId) {
|
|
3718
|
+
const subAgentExists = await validateSubAgent(dbClient_default)({
|
|
3522
3719
|
scopes: { tenantId, projectId, agentId, subAgentId: body.targetSubAgentId }
|
|
3523
3720
|
});
|
|
3524
|
-
if (!
|
|
3721
|
+
if (!subAgentExists) {
|
|
3525
3722
|
throw createApiError({
|
|
3526
3723
|
code: "bad_request",
|
|
3527
|
-
message: `
|
|
3724
|
+
message: `Sub agent with ID ${body.targetSubAgentId} not found`
|
|
3528
3725
|
});
|
|
3529
3726
|
}
|
|
3530
3727
|
}
|
|
@@ -3536,16 +3733,12 @@ app15.openapi(
|
|
|
3536
3733
|
if (relation.agentId !== agentId || relation.sourceSubAgentId !== body.sourceSubAgentId) {
|
|
3537
3734
|
return false;
|
|
3538
3735
|
}
|
|
3539
|
-
if (isExternalAgent) {
|
|
3540
|
-
return relation.externalSubAgentId === body.externalSubAgentId;
|
|
3541
|
-
}
|
|
3542
3736
|
return relation.targetSubAgentId === body.targetSubAgentId;
|
|
3543
3737
|
});
|
|
3544
3738
|
if (isDuplicate) {
|
|
3545
|
-
const agentType = isExternalAgent ? "external" : "internal";
|
|
3546
3739
|
throw createApiError({
|
|
3547
3740
|
code: "unprocessable_entity",
|
|
3548
|
-
message: `A relation between these agents
|
|
3741
|
+
message: `A relation between these agents in this agent already exists`
|
|
3549
3742
|
});
|
|
3550
3743
|
}
|
|
3551
3744
|
const relationData = {
|
|
@@ -3554,8 +3747,7 @@ app15.openapi(
|
|
|
3554
3747
|
id: generateId(),
|
|
3555
3748
|
projectId,
|
|
3556
3749
|
sourceSubAgentId: body.sourceSubAgentId,
|
|
3557
|
-
targetSubAgentId:
|
|
3558
|
-
externalSubAgentId: isExternalAgent ? body.externalSubAgentId : void 0,
|
|
3750
|
+
targetSubAgentId: body.targetSubAgentId,
|
|
3559
3751
|
relationType: body.relationType
|
|
3560
3752
|
};
|
|
3561
3753
|
const agentRelation = await createSubAgentRelation(dbClient_default)({
|
|
@@ -3564,7 +3756,7 @@ app15.openapi(
|
|
|
3564
3756
|
return c.json({ data: agentRelation }, 201);
|
|
3565
3757
|
}
|
|
3566
3758
|
);
|
|
3567
|
-
|
|
3759
|
+
app16.openapi(
|
|
3568
3760
|
createRoute({
|
|
3569
3761
|
method: "put",
|
|
3570
3762
|
path: "/{id}",
|
|
@@ -3610,7 +3802,7 @@ app15.openapi(
|
|
|
3610
3802
|
return c.json({ data: updatedAgentRelation });
|
|
3611
3803
|
}
|
|
3612
3804
|
);
|
|
3613
|
-
|
|
3805
|
+
app16.openapi(
|
|
3614
3806
|
createRoute({
|
|
3615
3807
|
method: "delete",
|
|
3616
3808
|
path: "/{id}",
|
|
@@ -3649,9 +3841,9 @@ app15.openapi(
|
|
|
3649
3841
|
return c.body(null, 204);
|
|
3650
3842
|
}
|
|
3651
3843
|
);
|
|
3652
|
-
var subAgentRelations_default =
|
|
3653
|
-
var
|
|
3654
|
-
|
|
3844
|
+
var subAgentRelations_default = app16;
|
|
3845
|
+
var app17 = new OpenAPIHono();
|
|
3846
|
+
app17.openapi(
|
|
3655
3847
|
createRoute({
|
|
3656
3848
|
method: "get",
|
|
3657
3849
|
path: "/",
|
|
@@ -3692,7 +3884,7 @@ app16.openapi(
|
|
|
3692
3884
|
return c.json(dataWithType);
|
|
3693
3885
|
}
|
|
3694
3886
|
);
|
|
3695
|
-
|
|
3887
|
+
app17.openapi(
|
|
3696
3888
|
createRoute({
|
|
3697
3889
|
method: "get",
|
|
3698
3890
|
path: "/{id}",
|
|
@@ -3733,7 +3925,7 @@ app16.openapi(
|
|
|
3733
3925
|
return c.json({ data: subAgentWithType });
|
|
3734
3926
|
}
|
|
3735
3927
|
);
|
|
3736
|
-
|
|
3928
|
+
app17.openapi(
|
|
3737
3929
|
createRoute({
|
|
3738
3930
|
method: "post",
|
|
3739
3931
|
path: "/",
|
|
@@ -3780,7 +3972,7 @@ app16.openapi(
|
|
|
3780
3972
|
return c.json({ data: subAgentWithType }, 201);
|
|
3781
3973
|
}
|
|
3782
3974
|
);
|
|
3783
|
-
|
|
3975
|
+
app17.openapi(
|
|
3784
3976
|
createRoute({
|
|
3785
3977
|
method: "put",
|
|
3786
3978
|
path: "/{id}",
|
|
@@ -3830,7 +4022,7 @@ app16.openapi(
|
|
|
3830
4022
|
return c.json({ data: subAgentWithType });
|
|
3831
4023
|
}
|
|
3832
4024
|
);
|
|
3833
|
-
|
|
4025
|
+
app17.openapi(
|
|
3834
4026
|
createRoute({
|
|
3835
4027
|
method: "delete",
|
|
3836
4028
|
path: "/{id}",
|
|
@@ -3869,9 +4061,9 @@ app16.openapi(
|
|
|
3869
4061
|
return c.body(null, 204);
|
|
3870
4062
|
}
|
|
3871
4063
|
);
|
|
3872
|
-
var subAgents_default =
|
|
3873
|
-
var
|
|
3874
|
-
|
|
4064
|
+
var subAgents_default = app17;
|
|
4065
|
+
var app18 = new OpenAPIHono();
|
|
4066
|
+
app18.openapi(
|
|
3875
4067
|
createRoute({
|
|
3876
4068
|
method: "get",
|
|
3877
4069
|
path: "/",
|
|
@@ -3933,7 +4125,7 @@ app17.openapi(
|
|
|
3933
4125
|
return c.json(result);
|
|
3934
4126
|
}
|
|
3935
4127
|
);
|
|
3936
|
-
|
|
4128
|
+
app18.openapi(
|
|
3937
4129
|
createRoute({
|
|
3938
4130
|
method: "get",
|
|
3939
4131
|
path: "/{id}",
|
|
@@ -3970,7 +4162,7 @@ app17.openapi(
|
|
|
3970
4162
|
return c.json({ data: agentToolRelation });
|
|
3971
4163
|
}
|
|
3972
4164
|
);
|
|
3973
|
-
|
|
4165
|
+
app18.openapi(
|
|
3974
4166
|
createRoute({
|
|
3975
4167
|
method: "get",
|
|
3976
4168
|
path: "/tool/{toolId}/sub-agents",
|
|
@@ -4006,7 +4198,7 @@ app17.openapi(
|
|
|
4006
4198
|
return c.json(dbResult);
|
|
4007
4199
|
}
|
|
4008
4200
|
);
|
|
4009
|
-
|
|
4201
|
+
app18.openapi(
|
|
4010
4202
|
createRoute({
|
|
4011
4203
|
method: "post",
|
|
4012
4204
|
path: "/",
|
|
@@ -4069,7 +4261,7 @@ app17.openapi(
|
|
|
4069
4261
|
}
|
|
4070
4262
|
}
|
|
4071
4263
|
);
|
|
4072
|
-
|
|
4264
|
+
app18.openapi(
|
|
4073
4265
|
createRoute({
|
|
4074
4266
|
method: "put",
|
|
4075
4267
|
path: "/{id}",
|
|
@@ -4122,7 +4314,7 @@ app17.openapi(
|
|
|
4122
4314
|
return c.json({ data: updatedAgentToolRelation });
|
|
4123
4315
|
}
|
|
4124
4316
|
);
|
|
4125
|
-
|
|
4317
|
+
app18.openapi(
|
|
4126
4318
|
createRoute({
|
|
4127
4319
|
method: "delete",
|
|
4128
4320
|
path: "/{id}",
|
|
@@ -4161,10 +4353,10 @@ app17.openapi(
|
|
|
4161
4353
|
return c.body(null, 204);
|
|
4162
4354
|
}
|
|
4163
4355
|
);
|
|
4164
|
-
var subAgentToolRelations_default =
|
|
4356
|
+
var subAgentToolRelations_default = app18;
|
|
4165
4357
|
var logger5 = getLogger("tools");
|
|
4166
|
-
var
|
|
4167
|
-
|
|
4358
|
+
var app19 = new OpenAPIHono();
|
|
4359
|
+
app19.openapi(
|
|
4168
4360
|
createRoute({
|
|
4169
4361
|
method: "get",
|
|
4170
4362
|
path: "/",
|
|
@@ -4224,7 +4416,7 @@ app18.openapi(
|
|
|
4224
4416
|
return c.json(result);
|
|
4225
4417
|
}
|
|
4226
4418
|
);
|
|
4227
|
-
|
|
4419
|
+
app19.openapi(
|
|
4228
4420
|
createRoute({
|
|
4229
4421
|
method: "get",
|
|
4230
4422
|
path: "/{id}",
|
|
@@ -4261,7 +4453,7 @@ app18.openapi(
|
|
|
4261
4453
|
});
|
|
4262
4454
|
}
|
|
4263
4455
|
);
|
|
4264
|
-
|
|
4456
|
+
app19.openapi(
|
|
4265
4457
|
createRoute({
|
|
4266
4458
|
method: "post",
|
|
4267
4459
|
path: "/",
|
|
@@ -4314,7 +4506,7 @@ app18.openapi(
|
|
|
4314
4506
|
);
|
|
4315
4507
|
}
|
|
4316
4508
|
);
|
|
4317
|
-
|
|
4509
|
+
app19.openapi(
|
|
4318
4510
|
createRoute({
|
|
4319
4511
|
method: "put",
|
|
4320
4512
|
path: "/{id}",
|
|
@@ -4375,7 +4567,7 @@ app18.openapi(
|
|
|
4375
4567
|
});
|
|
4376
4568
|
}
|
|
4377
4569
|
);
|
|
4378
|
-
|
|
4570
|
+
app19.openapi(
|
|
4379
4571
|
createRoute({
|
|
4380
4572
|
method: "delete",
|
|
4381
4573
|
path: "/{id}",
|
|
@@ -4411,38 +4603,42 @@ app18.openapi(
|
|
|
4411
4603
|
return c.body(null, 204);
|
|
4412
4604
|
}
|
|
4413
4605
|
);
|
|
4414
|
-
var tools_default =
|
|
4606
|
+
var tools_default = app19;
|
|
4415
4607
|
|
|
4416
4608
|
// src/routes/index.ts
|
|
4417
|
-
var
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
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(
|
|
4423
4619
|
"/projects/:projectId/agents/:agentId/sub-agent-tool-relations",
|
|
4424
4620
|
subAgentToolRelations_default
|
|
4425
4621
|
);
|
|
4426
|
-
|
|
4622
|
+
app20.route(
|
|
4427
4623
|
"/projects/:projectId/agents/:agentId/sub-agent-artifact-components",
|
|
4428
4624
|
subAgentArtifactComponents_default
|
|
4429
4625
|
);
|
|
4430
|
-
|
|
4626
|
+
app20.route(
|
|
4431
4627
|
"/projects/:projectId/agents/:agentId/sub-agent-data-components",
|
|
4432
4628
|
subAgentDataComponents_default
|
|
4433
4629
|
);
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
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;
|
|
4446
4642
|
var logger6 = getLogger("oauth-service");
|
|
4447
4643
|
var pkceStore = /* @__PURE__ */ new Map();
|
|
4448
4644
|
function storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientInformation, metadata, resourceUrl) {
|
|
@@ -4557,7 +4753,7 @@ var oauthService = new OAuthService();
|
|
|
4557
4753
|
// src/routes/oauth.ts
|
|
4558
4754
|
async function findOrCreateCredential(tenantId, projectId, credentialData) {
|
|
4559
4755
|
try {
|
|
4560
|
-
const existingCredential = await
|
|
4756
|
+
const existingCredential = await getCredentialReferenceWithResources(dbClient_default)({
|
|
4561
4757
|
scopes: { tenantId, projectId },
|
|
4562
4758
|
id: credentialData.id
|
|
4563
4759
|
});
|
|
@@ -4580,7 +4776,7 @@ async function findOrCreateCredential(tenantId, projectId, credentialData) {
|
|
|
4580
4776
|
throw new Error(`Failed to save credential '${credentialData.id}' to database`);
|
|
4581
4777
|
}
|
|
4582
4778
|
}
|
|
4583
|
-
var
|
|
4779
|
+
var app21 = new OpenAPIHono();
|
|
4584
4780
|
var logger7 = getLogger("oauth-callback");
|
|
4585
4781
|
function getBaseUrlFromRequest(c) {
|
|
4586
4782
|
const url = new URL(c.req.url);
|
|
@@ -4667,7 +4863,7 @@ var OAuthCallbackQuerySchema = z$1.object({
|
|
|
4667
4863
|
error: z$1.string().optional(),
|
|
4668
4864
|
error_description: z$1.string().optional()
|
|
4669
4865
|
});
|
|
4670
|
-
|
|
4866
|
+
app21.openapi(
|
|
4671
4867
|
createRoute({
|
|
4672
4868
|
method: "get",
|
|
4673
4869
|
path: "/login",
|
|
@@ -4732,7 +4928,7 @@ app20.openapi(
|
|
|
4732
4928
|
}
|
|
4733
4929
|
}
|
|
4734
4930
|
);
|
|
4735
|
-
|
|
4931
|
+
app21.openapi(
|
|
4736
4932
|
createRoute({
|
|
4737
4933
|
method: "get",
|
|
4738
4934
|
path: "/callback",
|
|
@@ -4874,9 +5070,9 @@ app20.openapi(
|
|
|
4874
5070
|
}
|
|
4875
5071
|
}
|
|
4876
5072
|
);
|
|
4877
|
-
var oauth_default =
|
|
5073
|
+
var oauth_default = app21;
|
|
4878
5074
|
var logger8 = getLogger("projectFull");
|
|
4879
|
-
var
|
|
5075
|
+
var app22 = new OpenAPIHono();
|
|
4880
5076
|
var ProjectIdParamsSchema = z.object({
|
|
4881
5077
|
tenantId: z.string().openapi({
|
|
4882
5078
|
description: "Tenant identifier",
|
|
@@ -4893,7 +5089,7 @@ var TenantParamsSchema2 = z.object({
|
|
|
4893
5089
|
example: "tenant_123"
|
|
4894
5090
|
})
|
|
4895
5091
|
}).openapi("TenantParams");
|
|
4896
|
-
|
|
5092
|
+
app22.openapi(
|
|
4897
5093
|
createRoute({
|
|
4898
5094
|
method: "post",
|
|
4899
5095
|
path: "/project-full",
|
|
@@ -4935,6 +5131,7 @@ app21.openapi(
|
|
|
4935
5131
|
const { tenantId } = c.req.valid("param");
|
|
4936
5132
|
const projectData = c.req.valid("json");
|
|
4937
5133
|
const validatedProjectData = FullProjectDefinitionSchema.parse(projectData);
|
|
5134
|
+
console.log("validatedProjectData", validatedProjectData);
|
|
4938
5135
|
try {
|
|
4939
5136
|
const createdProject = await createFullProjectServerSide(dbClient_default, logger8)(
|
|
4940
5137
|
{ tenantId, projectId: validatedProjectData.id },
|
|
@@ -4952,7 +5149,7 @@ app21.openapi(
|
|
|
4952
5149
|
}
|
|
4953
5150
|
}
|
|
4954
5151
|
);
|
|
4955
|
-
|
|
5152
|
+
app22.openapi(
|
|
4956
5153
|
createRoute({
|
|
4957
5154
|
method: "get",
|
|
4958
5155
|
path: "/project-full/{projectId}",
|
|
@@ -5005,7 +5202,7 @@ app21.openapi(
|
|
|
5005
5202
|
}
|
|
5006
5203
|
}
|
|
5007
5204
|
);
|
|
5008
|
-
|
|
5205
|
+
app22.openapi(
|
|
5009
5206
|
createRoute({
|
|
5010
5207
|
method: "put",
|
|
5011
5208
|
path: "/project-full/{projectId}",
|
|
@@ -5089,7 +5286,7 @@ app21.openapi(
|
|
|
5089
5286
|
}
|
|
5090
5287
|
}
|
|
5091
5288
|
);
|
|
5092
|
-
|
|
5289
|
+
app22.openapi(
|
|
5093
5290
|
createRoute({
|
|
5094
5291
|
method: "delete",
|
|
5095
5292
|
path: "/project-full/{projectId}",
|
|
@@ -5137,20 +5334,20 @@ app21.openapi(
|
|
|
5137
5334
|
}
|
|
5138
5335
|
}
|
|
5139
5336
|
);
|
|
5140
|
-
var projectFull_default =
|
|
5337
|
+
var projectFull_default = app22;
|
|
5141
5338
|
|
|
5142
5339
|
// src/app.ts
|
|
5143
5340
|
var logger9 = getLogger("agents-manage-api");
|
|
5144
5341
|
logger9.info({ logger: logger9.getTransports() }, "Logger initialized");
|
|
5145
5342
|
function createManagementHono(serverConfig, credentialStores) {
|
|
5146
|
-
const
|
|
5147
|
-
|
|
5148
|
-
|
|
5343
|
+
const app24 = new OpenAPIHono();
|
|
5344
|
+
app24.use("*", requestId());
|
|
5345
|
+
app24.use("*", async (c, next) => {
|
|
5149
5346
|
c.set("serverConfig", serverConfig);
|
|
5150
5347
|
c.set("credentialStores", credentialStores);
|
|
5151
5348
|
return next();
|
|
5152
5349
|
});
|
|
5153
|
-
|
|
5350
|
+
app24.use(
|
|
5154
5351
|
pinoLogger({
|
|
5155
5352
|
pino: getLogger("agents-manage-api").getPinoInstance(),
|
|
5156
5353
|
http: {
|
|
@@ -5163,7 +5360,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5163
5360
|
}
|
|
5164
5361
|
})
|
|
5165
5362
|
);
|
|
5166
|
-
|
|
5363
|
+
app24.onError(async (err, c) => {
|
|
5167
5364
|
const isExpectedError = err instanceof HTTPException;
|
|
5168
5365
|
const status = isExpectedError ? err.status : 500;
|
|
5169
5366
|
const requestId2 = c.get("requestId") || "unknown";
|
|
@@ -5238,7 +5435,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5238
5435
|
...instance && { instance }
|
|
5239
5436
|
});
|
|
5240
5437
|
});
|
|
5241
|
-
|
|
5438
|
+
app24.use(
|
|
5242
5439
|
"*",
|
|
5243
5440
|
cors({
|
|
5244
5441
|
origin: (origin) => {
|
|
@@ -5252,7 +5449,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5252
5449
|
credentials: true
|
|
5253
5450
|
})
|
|
5254
5451
|
);
|
|
5255
|
-
|
|
5452
|
+
app24.openapi(
|
|
5256
5453
|
createRoute({
|
|
5257
5454
|
method: "get",
|
|
5258
5455
|
path: "/health",
|
|
@@ -5269,13 +5466,13 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5269
5466
|
return c.body(null, 204);
|
|
5270
5467
|
}
|
|
5271
5468
|
);
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
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);
|
|
5277
5474
|
const baseApp = new Hono();
|
|
5278
|
-
baseApp.route("/",
|
|
5475
|
+
baseApp.route("/", app24);
|
|
5279
5476
|
return baseApp;
|
|
5280
5477
|
}
|
|
5281
5478
|
|
|
@@ -5291,8 +5488,8 @@ var defaultConfig = {
|
|
|
5291
5488
|
};
|
|
5292
5489
|
var defaultStores = createDefaultCredentialStores();
|
|
5293
5490
|
var defaultRegistry = new CredentialStoreRegistry(defaultStores);
|
|
5294
|
-
var
|
|
5295
|
-
var index_default =
|
|
5491
|
+
var app23 = createManagementHono(defaultConfig, defaultRegistry);
|
|
5492
|
+
var index_default = app23;
|
|
5296
5493
|
function createManagementApp(config) {
|
|
5297
5494
|
const serverConfig = config?.serverConfig ?? defaultConfig;
|
|
5298
5495
|
const stores = config?.credentialStores ?? defaultStores;
|