@inkeep/agents-manage-api 0.21.0 → 1.0.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 +673 -537
- package/dist/index.js +674 -538
- package/package.json +2 -2
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, 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, CredentialReferenceListResponse, listCredentialReferencesPaginated, CredentialReferenceApiSelectSchema, CredentialReferenceResponse, getCredentialReferenceWithTools, 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,
|
|
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, getCredentialReferenceWithTools, 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, SubAgentRelationApiSelectSchema, SubAgentRelationQuerySchema, getAgentRelationsBySource, getSubAgentRelationsByTarget, getExternalAgentRelations, listAgentRelations, getAgentRelationById, SubAgentRelationApiInsertSchema, validateExternalAgent, validateInternalSubAgent, 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, discoverOAuthEndpoints, 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';
|
|
@@ -67,10 +67,10 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
|
|
|
67
67
|
await next();
|
|
68
68
|
return;
|
|
69
69
|
});
|
|
70
|
-
function setupOpenAPIRoutes(
|
|
71
|
-
|
|
70
|
+
function setupOpenAPIRoutes(app23) {
|
|
71
|
+
app23.get("/openapi.json", (c) => {
|
|
72
72
|
try {
|
|
73
|
-
const document =
|
|
73
|
+
const document = app23.getOpenAPIDocument({
|
|
74
74
|
openapi: "3.0.0",
|
|
75
75
|
info: {
|
|
76
76
|
title: "Inkeep Agents Manage API",
|
|
@@ -91,7 +91,7 @@ function setupOpenAPIRoutes(app22) {
|
|
|
91
91
|
return c.json({ error: "Failed to generate OpenAPI document", details: errorDetails }, 500);
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
|
-
|
|
94
|
+
app23.get(
|
|
95
95
|
"/docs",
|
|
96
96
|
swaggerUI({
|
|
97
97
|
url: "/openapi.json",
|
|
@@ -204,7 +204,7 @@ app.openapi(
|
|
|
204
204
|
path: "/{agentId}/sub-agents/{subAgentId}/related",
|
|
205
205
|
summary: "Get Related Agent Infos",
|
|
206
206
|
operationId: "get-related-agent-infos",
|
|
207
|
-
tags: ["Agent
|
|
207
|
+
tags: ["Agent"],
|
|
208
208
|
request: {
|
|
209
209
|
params: TenantProjectParamsSchema.extend({
|
|
210
210
|
agentId: z.string(),
|
|
@@ -253,7 +253,7 @@ app.openapi(
|
|
|
253
253
|
path: "/{agentId}/full",
|
|
254
254
|
summary: "Get Full Agent Definition",
|
|
255
255
|
operationId: "get-full-agent-definition",
|
|
256
|
-
tags: ["Agent
|
|
256
|
+
tags: ["Agent"],
|
|
257
257
|
request: {
|
|
258
258
|
params: TenantProjectAgentParamsSchema
|
|
259
259
|
},
|
|
@@ -413,8 +413,259 @@ app.openapi(
|
|
|
413
413
|
}
|
|
414
414
|
);
|
|
415
415
|
var agent_default = app;
|
|
416
|
+
var logger2 = getLogger("agentFull");
|
|
416
417
|
var app2 = new OpenAPIHono();
|
|
418
|
+
var AgentIdParamsSchema = z.object({
|
|
419
|
+
tenantId: z.string().openapi({
|
|
420
|
+
description: "Tenant identifier",
|
|
421
|
+
example: "tenant_123"
|
|
422
|
+
}),
|
|
423
|
+
projectId: z.string().openapi({
|
|
424
|
+
description: "Project identifier",
|
|
425
|
+
example: "project_456"
|
|
426
|
+
}),
|
|
427
|
+
agentId: z.string().openapi({
|
|
428
|
+
description: "Agent identifier",
|
|
429
|
+
example: "agent_789"
|
|
430
|
+
})
|
|
431
|
+
}).openapi("AgentIdParams");
|
|
432
|
+
app2.openapi(
|
|
433
|
+
createRoute({
|
|
434
|
+
method: "post",
|
|
435
|
+
path: "/",
|
|
436
|
+
summary: "Create Full Agent",
|
|
437
|
+
operationId: "create-full-agent",
|
|
438
|
+
tags: ["Full Agent"],
|
|
439
|
+
description: "Create a complete agent with all agents, tools, and relationships from JSON definition",
|
|
440
|
+
request: {
|
|
441
|
+
params: TenantProjectParamsSchema,
|
|
442
|
+
body: {
|
|
443
|
+
content: {
|
|
444
|
+
"application/json": {
|
|
445
|
+
schema: AgentWithinContextOfProjectSchema
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
responses: {
|
|
451
|
+
201: {
|
|
452
|
+
description: "Full agent created successfully",
|
|
453
|
+
content: {
|
|
454
|
+
"application/json": {
|
|
455
|
+
schema: SingleResponseSchema(AgentWithinContextOfProjectSchema)
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
409: {
|
|
460
|
+
description: "Agent already exists",
|
|
461
|
+
content: {
|
|
462
|
+
"application/json": {
|
|
463
|
+
schema: ErrorResponseSchema
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
...commonGetErrorResponses
|
|
468
|
+
}
|
|
469
|
+
}),
|
|
470
|
+
async (c) => {
|
|
471
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
472
|
+
const agentData = c.req.valid("json");
|
|
473
|
+
const validatedAgentData = AgentWithinContextOfProjectSchema.parse(agentData);
|
|
474
|
+
const createdAgent = await createFullAgentServerSide(dbClient_default, logger2)(
|
|
475
|
+
{ tenantId, projectId },
|
|
476
|
+
validatedAgentData
|
|
477
|
+
);
|
|
478
|
+
return c.json({ data: createdAgent }, 201);
|
|
479
|
+
}
|
|
480
|
+
);
|
|
417
481
|
app2.openapi(
|
|
482
|
+
createRoute({
|
|
483
|
+
method: "get",
|
|
484
|
+
path: "/{agentId}",
|
|
485
|
+
summary: "Get Full Agent",
|
|
486
|
+
operationId: "get-full-agent",
|
|
487
|
+
tags: ["Full Agent"],
|
|
488
|
+
description: "Retrieve a complete agent definition with all agents, tools, and relationships",
|
|
489
|
+
request: {
|
|
490
|
+
params: AgentIdParamsSchema
|
|
491
|
+
},
|
|
492
|
+
responses: {
|
|
493
|
+
200: {
|
|
494
|
+
description: "Full agent found",
|
|
495
|
+
content: {
|
|
496
|
+
"application/json": {
|
|
497
|
+
schema: SingleResponseSchema(AgentWithinContextOfProjectSchema)
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
...commonGetErrorResponses
|
|
502
|
+
}
|
|
503
|
+
}),
|
|
504
|
+
async (c) => {
|
|
505
|
+
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
506
|
+
try {
|
|
507
|
+
const agent = await getFullAgent(
|
|
508
|
+
dbClient_default,
|
|
509
|
+
logger2
|
|
510
|
+
)({
|
|
511
|
+
scopes: { tenantId, projectId, agentId }
|
|
512
|
+
});
|
|
513
|
+
if (!agent) {
|
|
514
|
+
throw createApiError({
|
|
515
|
+
code: "not_found",
|
|
516
|
+
message: "Agent not found"
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
return c.json({ data: agent });
|
|
520
|
+
} catch (error) {
|
|
521
|
+
if (error instanceof Error && error.message.includes("not found")) {
|
|
522
|
+
throw createApiError({
|
|
523
|
+
code: "not_found",
|
|
524
|
+
message: "Agent not found"
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
throw createApiError({
|
|
528
|
+
code: "internal_server_error",
|
|
529
|
+
message: error instanceof Error ? error.message : "Failed to retrieve agent"
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
);
|
|
534
|
+
app2.openapi(
|
|
535
|
+
createRoute({
|
|
536
|
+
method: "put",
|
|
537
|
+
path: "/{agentId}",
|
|
538
|
+
summary: "Update Full Agent",
|
|
539
|
+
operationId: "update-full-agent",
|
|
540
|
+
tags: ["Full Agent"],
|
|
541
|
+
description: "Update or create a complete agent with all agents, tools, and relationships from JSON definition",
|
|
542
|
+
request: {
|
|
543
|
+
params: AgentIdParamsSchema,
|
|
544
|
+
body: {
|
|
545
|
+
content: {
|
|
546
|
+
"application/json": {
|
|
547
|
+
schema: AgentWithinContextOfProjectSchema
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
responses: {
|
|
553
|
+
200: {
|
|
554
|
+
description: "Full agent updated successfully",
|
|
555
|
+
content: {
|
|
556
|
+
"application/json": {
|
|
557
|
+
schema: SingleResponseSchema(AgentWithinContextOfProjectSchema)
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
201: {
|
|
562
|
+
description: "Full agent created successfully",
|
|
563
|
+
content: {
|
|
564
|
+
"application/json": {
|
|
565
|
+
schema: SingleResponseSchema(AgentWithinContextOfProjectSchema)
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
...commonGetErrorResponses
|
|
570
|
+
}
|
|
571
|
+
}),
|
|
572
|
+
async (c) => {
|
|
573
|
+
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
574
|
+
const agentData = c.req.valid("json");
|
|
575
|
+
try {
|
|
576
|
+
const validatedAgentData = AgentWithinContextOfProjectSchema.parse(agentData);
|
|
577
|
+
if (agentId !== validatedAgentData.id) {
|
|
578
|
+
throw createApiError({
|
|
579
|
+
code: "bad_request",
|
|
580
|
+
message: `Agent ID mismatch: expected ${agentId}, got ${validatedAgentData.id}`
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
const existingAgent = await getFullAgent(
|
|
584
|
+
dbClient_default,
|
|
585
|
+
logger2
|
|
586
|
+
)({
|
|
587
|
+
scopes: { tenantId, projectId, agentId }
|
|
588
|
+
});
|
|
589
|
+
const isCreate = !existingAgent;
|
|
590
|
+
const updatedAgent = isCreate ? await createFullAgentServerSide(dbClient_default, logger2)(
|
|
591
|
+
{ tenantId, projectId },
|
|
592
|
+
validatedAgentData
|
|
593
|
+
) : await updateFullAgentServerSide(dbClient_default, logger2)(
|
|
594
|
+
{ tenantId, projectId },
|
|
595
|
+
validatedAgentData
|
|
596
|
+
);
|
|
597
|
+
return c.json({ data: updatedAgent }, isCreate ? 201 : 200);
|
|
598
|
+
} catch (error) {
|
|
599
|
+
if (error instanceof z.ZodError) {
|
|
600
|
+
throw createApiError({
|
|
601
|
+
code: "bad_request",
|
|
602
|
+
message: "Invalid agent definition"
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
if (error instanceof Error && error.message.includes("ID mismatch")) {
|
|
606
|
+
throw createApiError({
|
|
607
|
+
code: "bad_request",
|
|
608
|
+
message: error.message
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
throw createApiError({
|
|
612
|
+
code: "internal_server_error",
|
|
613
|
+
message: error instanceof Error ? error.message : "Failed to update agent"
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
);
|
|
618
|
+
app2.openapi(
|
|
619
|
+
createRoute({
|
|
620
|
+
method: "delete",
|
|
621
|
+
path: "/{agentId}",
|
|
622
|
+
summary: "Delete Full Agent",
|
|
623
|
+
operationId: "delete-full-agent",
|
|
624
|
+
tags: ["Full Agent"],
|
|
625
|
+
description: "Delete a complete agent and cascade to all related entities (relationships, not other agents/tools)",
|
|
626
|
+
request: {
|
|
627
|
+
params: AgentIdParamsSchema
|
|
628
|
+
},
|
|
629
|
+
responses: {
|
|
630
|
+
204: {
|
|
631
|
+
description: "Agent deleted successfully"
|
|
632
|
+
},
|
|
633
|
+
...commonGetErrorResponses
|
|
634
|
+
}
|
|
635
|
+
}),
|
|
636
|
+
async (c) => {
|
|
637
|
+
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
638
|
+
try {
|
|
639
|
+
const deleted = await deleteFullAgent(
|
|
640
|
+
dbClient_default,
|
|
641
|
+
logger2
|
|
642
|
+
)({
|
|
643
|
+
scopes: { tenantId, projectId, agentId }
|
|
644
|
+
});
|
|
645
|
+
if (!deleted) {
|
|
646
|
+
throw createApiError({
|
|
647
|
+
code: "not_found",
|
|
648
|
+
message: "Agent not found"
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
return c.body(null, 204);
|
|
652
|
+
} catch (error) {
|
|
653
|
+
if (error instanceof Error && error.message.includes("not found")) {
|
|
654
|
+
throw createApiError({
|
|
655
|
+
code: "not_found",
|
|
656
|
+
message: "Agent not found"
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
throw createApiError({
|
|
660
|
+
code: "internal_server_error",
|
|
661
|
+
message: error instanceof Error ? error.message : "Failed to delete agent"
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
);
|
|
666
|
+
var agentFull_default = app2;
|
|
667
|
+
var app3 = new OpenAPIHono();
|
|
668
|
+
app3.openapi(
|
|
418
669
|
createRoute({
|
|
419
670
|
method: "get",
|
|
420
671
|
path: "/",
|
|
@@ -457,7 +708,7 @@ app2.openapi(
|
|
|
457
708
|
});
|
|
458
709
|
}
|
|
459
710
|
);
|
|
460
|
-
|
|
711
|
+
app3.openapi(
|
|
461
712
|
createRoute({
|
|
462
713
|
method: "get",
|
|
463
714
|
path: "/{id}",
|
|
@@ -502,7 +753,7 @@ app2.openapi(
|
|
|
502
753
|
});
|
|
503
754
|
}
|
|
504
755
|
);
|
|
505
|
-
|
|
756
|
+
app3.openapi(
|
|
506
757
|
createRoute({
|
|
507
758
|
method: "post",
|
|
508
759
|
path: "/",
|
|
@@ -572,7 +823,7 @@ app2.openapi(
|
|
|
572
823
|
}
|
|
573
824
|
}
|
|
574
825
|
);
|
|
575
|
-
|
|
826
|
+
app3.openapi(
|
|
576
827
|
createRoute({
|
|
577
828
|
method: "put",
|
|
578
829
|
path: "/{id}",
|
|
@@ -629,7 +880,7 @@ app2.openapi(
|
|
|
629
880
|
});
|
|
630
881
|
}
|
|
631
882
|
);
|
|
632
|
-
|
|
883
|
+
app3.openapi(
|
|
633
884
|
createRoute({
|
|
634
885
|
method: "delete",
|
|
635
886
|
path: "/{id}",
|
|
@@ -669,9 +920,9 @@ app2.openapi(
|
|
|
669
920
|
return c.body(null, 204);
|
|
670
921
|
}
|
|
671
922
|
);
|
|
672
|
-
var apiKeys_default =
|
|
673
|
-
var
|
|
674
|
-
|
|
923
|
+
var apiKeys_default = app3;
|
|
924
|
+
var app4 = new OpenAPIHono();
|
|
925
|
+
app4.openapi(
|
|
675
926
|
createRoute({
|
|
676
927
|
method: "get",
|
|
677
928
|
path: "/",
|
|
@@ -705,7 +956,7 @@ app3.openapi(
|
|
|
705
956
|
return c.json(result);
|
|
706
957
|
}
|
|
707
958
|
);
|
|
708
|
-
|
|
959
|
+
app4.openapi(
|
|
709
960
|
createRoute({
|
|
710
961
|
method: "get",
|
|
711
962
|
path: "/{id}",
|
|
@@ -742,7 +993,7 @@ app3.openapi(
|
|
|
742
993
|
return c.json({ data: artifactComponent });
|
|
743
994
|
}
|
|
744
995
|
);
|
|
745
|
-
|
|
996
|
+
app4.openapi(
|
|
746
997
|
createRoute({
|
|
747
998
|
method: "post",
|
|
748
999
|
path: "/",
|
|
@@ -809,7 +1060,7 @@ app3.openapi(
|
|
|
809
1060
|
}
|
|
810
1061
|
}
|
|
811
1062
|
);
|
|
812
|
-
|
|
1063
|
+
app4.openapi(
|
|
813
1064
|
createRoute({
|
|
814
1065
|
method: "put",
|
|
815
1066
|
path: "/{id}",
|
|
@@ -875,7 +1126,7 @@ app3.openapi(
|
|
|
875
1126
|
return c.json({ data: updatedArtifactComponent });
|
|
876
1127
|
}
|
|
877
1128
|
);
|
|
878
|
-
|
|
1129
|
+
app4.openapi(
|
|
879
1130
|
createRoute({
|
|
880
1131
|
method: "delete",
|
|
881
1132
|
path: "/{id}",
|
|
@@ -914,9 +1165,9 @@ app3.openapi(
|
|
|
914
1165
|
return c.body(null, 204);
|
|
915
1166
|
}
|
|
916
1167
|
);
|
|
917
|
-
var artifactComponents_default =
|
|
918
|
-
var
|
|
919
|
-
|
|
1168
|
+
var artifactComponents_default = app4;
|
|
1169
|
+
var app5 = new OpenAPIHono();
|
|
1170
|
+
app5.openapi(
|
|
920
1171
|
createRoute({
|
|
921
1172
|
method: "get",
|
|
922
1173
|
path: "/",
|
|
@@ -950,7 +1201,7 @@ app4.openapi(
|
|
|
950
1201
|
return c.json(result);
|
|
951
1202
|
}
|
|
952
1203
|
);
|
|
953
|
-
|
|
1204
|
+
app5.openapi(
|
|
954
1205
|
createRoute({
|
|
955
1206
|
method: "get",
|
|
956
1207
|
path: "/{id}",
|
|
@@ -987,7 +1238,7 @@ app4.openapi(
|
|
|
987
1238
|
return c.json({ data: contextConfig });
|
|
988
1239
|
}
|
|
989
1240
|
);
|
|
990
|
-
|
|
1241
|
+
app5.openapi(
|
|
991
1242
|
createRoute({
|
|
992
1243
|
method: "post",
|
|
993
1244
|
path: "/",
|
|
@@ -1029,7 +1280,7 @@ app4.openapi(
|
|
|
1029
1280
|
return c.json({ data: contextConfig }, 201);
|
|
1030
1281
|
}
|
|
1031
1282
|
);
|
|
1032
|
-
|
|
1283
|
+
app5.openapi(
|
|
1033
1284
|
createRoute({
|
|
1034
1285
|
method: "put",
|
|
1035
1286
|
path: "/{id}",
|
|
@@ -1075,7 +1326,7 @@ app4.openapi(
|
|
|
1075
1326
|
return c.json({ data: updatedContextConfig });
|
|
1076
1327
|
}
|
|
1077
1328
|
);
|
|
1078
|
-
|
|
1329
|
+
app5.openapi(
|
|
1079
1330
|
createRoute({
|
|
1080
1331
|
method: "delete",
|
|
1081
1332
|
path: "/{id}",
|
|
@@ -1107,9 +1358,139 @@ app4.openapi(
|
|
|
1107
1358
|
return c.body(null, 204);
|
|
1108
1359
|
}
|
|
1109
1360
|
);
|
|
1110
|
-
var contextConfigs_default =
|
|
1111
|
-
var
|
|
1112
|
-
|
|
1361
|
+
var contextConfigs_default = app5;
|
|
1362
|
+
var app6 = new OpenAPIHono();
|
|
1363
|
+
var CredentialStoreSchema = z.object({
|
|
1364
|
+
id: z.string().describe("Unique identifier of the credential store"),
|
|
1365
|
+
type: z.enum(CredentialStoreType),
|
|
1366
|
+
available: z.boolean().describe("Whether the store is functional and ready to use"),
|
|
1367
|
+
reason: z.string().nullable().describe("Reason why store is not available, if applicable")
|
|
1368
|
+
});
|
|
1369
|
+
var CredentialStoreListResponseSchema = z.object({
|
|
1370
|
+
data: z.array(CredentialStoreSchema).describe("List of credential stores")
|
|
1371
|
+
});
|
|
1372
|
+
var CreateCredentialInStoreRequestSchema = z.object({
|
|
1373
|
+
key: z.string().describe("The credential key"),
|
|
1374
|
+
value: z.string().describe("The credential value")
|
|
1375
|
+
});
|
|
1376
|
+
var CreateCredentialInStoreResponseSchema = z.object({
|
|
1377
|
+
data: z.object({
|
|
1378
|
+
key: z.string().describe("The credential key"),
|
|
1379
|
+
storeId: z.string().describe("The store ID where credential was created"),
|
|
1380
|
+
createdAt: z.string().describe("ISO timestamp of creation")
|
|
1381
|
+
})
|
|
1382
|
+
});
|
|
1383
|
+
app6.openapi(
|
|
1384
|
+
createRoute({
|
|
1385
|
+
method: "get",
|
|
1386
|
+
path: "/",
|
|
1387
|
+
summary: "List Credential Stores",
|
|
1388
|
+
operationId: "list-credential-stores",
|
|
1389
|
+
tags: ["Credential Store"],
|
|
1390
|
+
request: {
|
|
1391
|
+
params: TenantProjectParamsSchema
|
|
1392
|
+
},
|
|
1393
|
+
responses: {
|
|
1394
|
+
200: {
|
|
1395
|
+
description: "List of credential stores retrieved successfully",
|
|
1396
|
+
content: {
|
|
1397
|
+
"application/json": {
|
|
1398
|
+
schema: CredentialStoreListResponseSchema
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
},
|
|
1402
|
+
...commonGetErrorResponses
|
|
1403
|
+
}
|
|
1404
|
+
}),
|
|
1405
|
+
async (c) => {
|
|
1406
|
+
const credentialStores = c.get("credentialStores");
|
|
1407
|
+
const allStores = credentialStores.getAll();
|
|
1408
|
+
const storeStatuses = await Promise.all(
|
|
1409
|
+
allStores.map(async (store) => {
|
|
1410
|
+
const { available, reason } = await store.checkAvailability();
|
|
1411
|
+
return {
|
|
1412
|
+
id: store.id,
|
|
1413
|
+
type: store.type,
|
|
1414
|
+
available,
|
|
1415
|
+
reason: reason || null
|
|
1416
|
+
};
|
|
1417
|
+
})
|
|
1418
|
+
);
|
|
1419
|
+
return c.json({
|
|
1420
|
+
data: storeStatuses
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
);
|
|
1424
|
+
app6.openapi(
|
|
1425
|
+
createRoute({
|
|
1426
|
+
method: "post",
|
|
1427
|
+
path: "/{id}/credentials",
|
|
1428
|
+
summary: "Create Credential in Store",
|
|
1429
|
+
operationId: "create-credential-in-store",
|
|
1430
|
+
tags: ["Credential Store"],
|
|
1431
|
+
request: {
|
|
1432
|
+
params: TenantProjectIdParamsSchema.extend({
|
|
1433
|
+
id: z.string().describe("The credential store ID")
|
|
1434
|
+
}),
|
|
1435
|
+
body: {
|
|
1436
|
+
content: {
|
|
1437
|
+
"application/json": {
|
|
1438
|
+
schema: CreateCredentialInStoreRequestSchema
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
},
|
|
1443
|
+
responses: {
|
|
1444
|
+
201: {
|
|
1445
|
+
description: "Credential created successfully",
|
|
1446
|
+
content: {
|
|
1447
|
+
"application/json": {
|
|
1448
|
+
schema: CreateCredentialInStoreResponseSchema
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
},
|
|
1452
|
+
...commonGetErrorResponses
|
|
1453
|
+
}
|
|
1454
|
+
}),
|
|
1455
|
+
async (c) => {
|
|
1456
|
+
const { id: storeId } = c.req.param();
|
|
1457
|
+
const { key, value } = await c.req.json();
|
|
1458
|
+
const credentialStores = c.get("credentialStores");
|
|
1459
|
+
const store = credentialStores.get(storeId);
|
|
1460
|
+
if (!store) {
|
|
1461
|
+
throw createApiError({
|
|
1462
|
+
code: "not_found",
|
|
1463
|
+
message: `Credential store '${storeId}' not found`
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
try {
|
|
1467
|
+
const { available, reason } = await store.checkAvailability();
|
|
1468
|
+
if (!available) {
|
|
1469
|
+
throw createApiError({
|
|
1470
|
+
code: "internal_server_error",
|
|
1471
|
+
message: `Credential store '${storeId}' is not available: ${reason}`
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1474
|
+
await store.set(key, value);
|
|
1475
|
+
return c.json({
|
|
1476
|
+
data: {
|
|
1477
|
+
key,
|
|
1478
|
+
storeId,
|
|
1479
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1480
|
+
}
|
|
1481
|
+
}, 201);
|
|
1482
|
+
} catch (error) {
|
|
1483
|
+
console.error(`Error setting credential in store ${storeId}:`, error);
|
|
1484
|
+
throw createApiError({
|
|
1485
|
+
code: "internal_server_error",
|
|
1486
|
+
message: `Failed to store credential: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
);
|
|
1491
|
+
var credentialStores_default = app6;
|
|
1492
|
+
var app7 = new OpenAPIHono();
|
|
1493
|
+
app7.openapi(
|
|
1113
1494
|
createRoute({
|
|
1114
1495
|
method: "get",
|
|
1115
1496
|
path: "/",
|
|
@@ -1144,7 +1525,7 @@ app5.openapi(
|
|
|
1144
1525
|
return c.json(validatedResult);
|
|
1145
1526
|
}
|
|
1146
1527
|
);
|
|
1147
|
-
|
|
1528
|
+
app7.openapi(
|
|
1148
1529
|
createRoute({
|
|
1149
1530
|
method: "get",
|
|
1150
1531
|
path: "/{id}",
|
|
@@ -1182,7 +1563,7 @@ app5.openapi(
|
|
|
1182
1563
|
return c.json({ data: validatedCredential });
|
|
1183
1564
|
}
|
|
1184
1565
|
);
|
|
1185
|
-
|
|
1566
|
+
app7.openapi(
|
|
1186
1567
|
createRoute({
|
|
1187
1568
|
method: "post",
|
|
1188
1569
|
path: "/",
|
|
@@ -1224,7 +1605,7 @@ app5.openapi(
|
|
|
1224
1605
|
return c.json({ data: validatedCredential }, 201);
|
|
1225
1606
|
}
|
|
1226
1607
|
);
|
|
1227
|
-
|
|
1608
|
+
app7.openapi(
|
|
1228
1609
|
createRoute({
|
|
1229
1610
|
method: "put",
|
|
1230
1611
|
path: "/{id}",
|
|
@@ -1271,7 +1652,7 @@ app5.openapi(
|
|
|
1271
1652
|
return c.json({ data: validatedCredential });
|
|
1272
1653
|
}
|
|
1273
1654
|
);
|
|
1274
|
-
|
|
1655
|
+
app7.openapi(
|
|
1275
1656
|
createRoute({
|
|
1276
1657
|
method: "delete",
|
|
1277
1658
|
path: "/{id}",
|
|
@@ -1342,9 +1723,9 @@ app5.openapi(
|
|
|
1342
1723
|
return c.body(null, 204);
|
|
1343
1724
|
}
|
|
1344
1725
|
);
|
|
1345
|
-
var credentials_default =
|
|
1346
|
-
var
|
|
1347
|
-
|
|
1726
|
+
var credentials_default = app7;
|
|
1727
|
+
var app8 = new OpenAPIHono();
|
|
1728
|
+
app8.openapi(
|
|
1348
1729
|
createRoute({
|
|
1349
1730
|
method: "get",
|
|
1350
1731
|
path: "/",
|
|
@@ -1378,7 +1759,7 @@ app6.openapi(
|
|
|
1378
1759
|
return c.json(result);
|
|
1379
1760
|
}
|
|
1380
1761
|
);
|
|
1381
|
-
|
|
1762
|
+
app8.openapi(
|
|
1382
1763
|
createRoute({
|
|
1383
1764
|
method: "get",
|
|
1384
1765
|
path: "/{id}",
|
|
@@ -1415,7 +1796,7 @@ app6.openapi(
|
|
|
1415
1796
|
return c.json({ data: dataComponent });
|
|
1416
1797
|
}
|
|
1417
1798
|
);
|
|
1418
|
-
|
|
1799
|
+
app8.openapi(
|
|
1419
1800
|
createRoute({
|
|
1420
1801
|
method: "post",
|
|
1421
1802
|
path: "/",
|
|
@@ -1466,7 +1847,7 @@ app6.openapi(
|
|
|
1466
1847
|
return c.json({ data: dataComponent }, 201);
|
|
1467
1848
|
}
|
|
1468
1849
|
);
|
|
1469
|
-
|
|
1850
|
+
app8.openapi(
|
|
1470
1851
|
createRoute({
|
|
1471
1852
|
method: "put",
|
|
1472
1853
|
path: "/{id}",
|
|
@@ -1522,7 +1903,7 @@ app6.openapi(
|
|
|
1522
1903
|
return c.json({ data: updatedDataComponent });
|
|
1523
1904
|
}
|
|
1524
1905
|
);
|
|
1525
|
-
|
|
1906
|
+
app8.openapi(
|
|
1526
1907
|
createRoute({
|
|
1527
1908
|
method: "delete",
|
|
1528
1909
|
path: "/{id}",
|
|
@@ -1561,9 +1942,9 @@ app6.openapi(
|
|
|
1561
1942
|
return c.body(null, 204);
|
|
1562
1943
|
}
|
|
1563
1944
|
);
|
|
1564
|
-
var dataComponents_default =
|
|
1565
|
-
var
|
|
1566
|
-
|
|
1945
|
+
var dataComponents_default = app8;
|
|
1946
|
+
var app9 = new OpenAPIHono();
|
|
1947
|
+
app9.openapi(
|
|
1567
1948
|
createRoute({
|
|
1568
1949
|
method: "get",
|
|
1569
1950
|
path: "/",
|
|
@@ -1603,7 +1984,7 @@ app7.openapi(
|
|
|
1603
1984
|
return c.json(dataWithType);
|
|
1604
1985
|
}
|
|
1605
1986
|
);
|
|
1606
|
-
|
|
1987
|
+
app9.openapi(
|
|
1607
1988
|
createRoute({
|
|
1608
1989
|
method: "get",
|
|
1609
1990
|
path: "/{id}",
|
|
@@ -1644,7 +2025,7 @@ app7.openapi(
|
|
|
1644
2025
|
return c.json({ data: agentWithType });
|
|
1645
2026
|
}
|
|
1646
2027
|
);
|
|
1647
|
-
|
|
2028
|
+
app9.openapi(
|
|
1648
2029
|
createRoute({
|
|
1649
2030
|
method: "post",
|
|
1650
2031
|
path: "/",
|
|
@@ -1695,7 +2076,7 @@ app7.openapi(
|
|
|
1695
2076
|
return c.json({ data: agentWithType }, 201);
|
|
1696
2077
|
}
|
|
1697
2078
|
);
|
|
1698
|
-
|
|
2079
|
+
app9.openapi(
|
|
1699
2080
|
createRoute({
|
|
1700
2081
|
method: "put",
|
|
1701
2082
|
path: "/{id}",
|
|
@@ -1745,7 +2126,7 @@ app7.openapi(
|
|
|
1745
2126
|
return c.json({ data: agentWithType });
|
|
1746
2127
|
}
|
|
1747
2128
|
);
|
|
1748
|
-
|
|
2129
|
+
app9.openapi(
|
|
1749
2130
|
createRoute({
|
|
1750
2131
|
method: "delete",
|
|
1751
2132
|
path: "/{id}",
|
|
@@ -1784,10 +2165,10 @@ app7.openapi(
|
|
|
1784
2165
|
return c.body(null, 204);
|
|
1785
2166
|
}
|
|
1786
2167
|
);
|
|
1787
|
-
var externalAgents_default =
|
|
1788
|
-
var
|
|
1789
|
-
var
|
|
1790
|
-
|
|
2168
|
+
var externalAgents_default = app9;
|
|
2169
|
+
var logger3 = getLogger("functions");
|
|
2170
|
+
var app10 = new OpenAPIHono();
|
|
2171
|
+
app10.openapi(
|
|
1791
2172
|
createRoute({
|
|
1792
2173
|
method: "get",
|
|
1793
2174
|
path: "/",
|
|
@@ -1824,7 +2205,7 @@ app8.openapi(
|
|
|
1824
2205
|
}
|
|
1825
2206
|
});
|
|
1826
2207
|
} catch (error) {
|
|
1827
|
-
|
|
2208
|
+
logger3.error({ error, tenantId }, "Failed to list functions");
|
|
1828
2209
|
return c.json(
|
|
1829
2210
|
createApiError({ code: "internal_server_error", message: "Failed to list functions" }),
|
|
1830
2211
|
500
|
|
@@ -1832,7 +2213,7 @@ app8.openapi(
|
|
|
1832
2213
|
}
|
|
1833
2214
|
}
|
|
1834
2215
|
);
|
|
1835
|
-
|
|
2216
|
+
app10.openapi(
|
|
1836
2217
|
createRoute({
|
|
1837
2218
|
method: "get",
|
|
1838
2219
|
path: "/{id}",
|
|
@@ -1869,7 +2250,7 @@ app8.openapi(
|
|
|
1869
2250
|
}
|
|
1870
2251
|
return c.json({ data: functionData });
|
|
1871
2252
|
} catch (error) {
|
|
1872
|
-
|
|
2253
|
+
logger3.error({ error, tenantId, id }, "Failed to get function");
|
|
1873
2254
|
return c.json(
|
|
1874
2255
|
createApiError({ code: "internal_server_error", message: "Failed to get function" }),
|
|
1875
2256
|
500
|
|
@@ -1877,7 +2258,7 @@ app8.openapi(
|
|
|
1877
2258
|
}
|
|
1878
2259
|
}
|
|
1879
2260
|
);
|
|
1880
|
-
|
|
2261
|
+
app10.openapi(
|
|
1881
2262
|
createRoute({
|
|
1882
2263
|
method: "post",
|
|
1883
2264
|
path: "/",
|
|
@@ -1922,10 +2303,10 @@ app8.openapi(
|
|
|
1922
2303
|
functionId: id,
|
|
1923
2304
|
scopes: { tenantId, projectId }
|
|
1924
2305
|
});
|
|
1925
|
-
|
|
2306
|
+
logger3.info({ tenantId, functionId: id }, "Function created");
|
|
1926
2307
|
return c.json({ data: created }, 201);
|
|
1927
2308
|
} catch (error) {
|
|
1928
|
-
|
|
2309
|
+
logger3.error({ error, tenantId, functionData }, "Failed to create function");
|
|
1929
2310
|
return c.json(
|
|
1930
2311
|
createApiError({ code: "internal_server_error", message: "Failed to create function" }),
|
|
1931
2312
|
500
|
|
@@ -1933,7 +2314,7 @@ app8.openapi(
|
|
|
1933
2314
|
}
|
|
1934
2315
|
}
|
|
1935
2316
|
);
|
|
1936
|
-
|
|
2317
|
+
app10.openapi(
|
|
1937
2318
|
createRoute({
|
|
1938
2319
|
method: "put",
|
|
1939
2320
|
path: "/{id}",
|
|
@@ -1988,10 +2369,10 @@ app8.openapi(
|
|
|
1988
2369
|
functionId: id,
|
|
1989
2370
|
scopes: { tenantId, projectId }
|
|
1990
2371
|
});
|
|
1991
|
-
|
|
2372
|
+
logger3.info({ tenantId, functionId: id }, "Function updated");
|
|
1992
2373
|
return c.json({ data: updated });
|
|
1993
2374
|
} catch (error) {
|
|
1994
|
-
|
|
2375
|
+
logger3.error({ error, tenantId, id, updateData }, "Failed to update function");
|
|
1995
2376
|
return c.json(
|
|
1996
2377
|
createApiError({ code: "internal_server_error", message: "Failed to update function" }),
|
|
1997
2378
|
500
|
|
@@ -1999,7 +2380,7 @@ app8.openapi(
|
|
|
1999
2380
|
}
|
|
2000
2381
|
}
|
|
2001
2382
|
);
|
|
2002
|
-
|
|
2383
|
+
app10.openapi(
|
|
2003
2384
|
createRoute({
|
|
2004
2385
|
method: "delete",
|
|
2005
2386
|
path: "/{id}",
|
|
@@ -2033,10 +2414,10 @@ app8.openapi(
|
|
|
2033
2414
|
functionId: id,
|
|
2034
2415
|
scopes: { tenantId, projectId }
|
|
2035
2416
|
});
|
|
2036
|
-
|
|
2417
|
+
logger3.info({ tenantId, functionId: id }, "Function deleted");
|
|
2037
2418
|
return c.body(null, 204);
|
|
2038
2419
|
} catch (error) {
|
|
2039
|
-
|
|
2420
|
+
logger3.error({ error, tenantId, id }, "Failed to delete function");
|
|
2040
2421
|
return c.json(
|
|
2041
2422
|
createApiError({ code: "internal_server_error", message: "Failed to delete function" }),
|
|
2042
2423
|
500
|
|
@@ -2044,10 +2425,10 @@ app8.openapi(
|
|
|
2044
2425
|
}
|
|
2045
2426
|
}
|
|
2046
2427
|
);
|
|
2047
|
-
var functions_default =
|
|
2048
|
-
var
|
|
2049
|
-
var
|
|
2050
|
-
|
|
2428
|
+
var functions_default = app10;
|
|
2429
|
+
var logger4 = getLogger("functionTools");
|
|
2430
|
+
var app11 = new OpenAPIHono();
|
|
2431
|
+
app11.openapi(
|
|
2051
2432
|
createRoute({
|
|
2052
2433
|
method: "get",
|
|
2053
2434
|
path: "/",
|
|
@@ -2080,7 +2461,7 @@ app9.openapi(
|
|
|
2080
2461
|
});
|
|
2081
2462
|
return c.json(result);
|
|
2082
2463
|
} catch (error) {
|
|
2083
|
-
|
|
2464
|
+
logger4.error({ error, tenantId, projectId, agentId }, "Failed to list function tools");
|
|
2084
2465
|
return c.json(
|
|
2085
2466
|
createApiError({ code: "internal_server_error", message: "Failed to list function tools" }),
|
|
2086
2467
|
500
|
|
@@ -2088,7 +2469,7 @@ app9.openapi(
|
|
|
2088
2469
|
}
|
|
2089
2470
|
}
|
|
2090
2471
|
);
|
|
2091
|
-
|
|
2472
|
+
app11.openapi(
|
|
2092
2473
|
createRoute({
|
|
2093
2474
|
method: "get",
|
|
2094
2475
|
path: "/:id",
|
|
@@ -2127,7 +2508,7 @@ app9.openapi(
|
|
|
2127
2508
|
}
|
|
2128
2509
|
return c.json({ data: functionTool });
|
|
2129
2510
|
} catch (error) {
|
|
2130
|
-
|
|
2511
|
+
logger4.error({ error, tenantId, projectId, agentId, id }, "Failed to get function tool");
|
|
2131
2512
|
return c.json(
|
|
2132
2513
|
createApiError({ code: "internal_server_error", message: "Failed to get function tool" }),
|
|
2133
2514
|
500
|
|
@@ -2135,7 +2516,7 @@ app9.openapi(
|
|
|
2135
2516
|
}
|
|
2136
2517
|
}
|
|
2137
2518
|
);
|
|
2138
|
-
|
|
2519
|
+
app11.openapi(
|
|
2139
2520
|
createRoute({
|
|
2140
2521
|
method: "post",
|
|
2141
2522
|
path: "/",
|
|
@@ -2165,288 +2546,55 @@ app9.openapi(
|
|
|
2165
2546
|
}
|
|
2166
2547
|
}),
|
|
2167
2548
|
async (c) => {
|
|
2168
|
-
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
2169
|
-
const body = c.req.valid("json");
|
|
2170
|
-
try {
|
|
2171
|
-
const id = body.id || nanoid();
|
|
2172
|
-
const functionTool = await createFunctionTool(dbClient_default)({
|
|
2173
|
-
scopes: { tenantId, projectId, agentId },
|
|
2174
|
-
data: {
|
|
2175
|
-
...body,
|
|
2176
|
-
id
|
|
2177
|
-
}
|
|
2178
|
-
});
|
|
2179
|
-
return c.json({ data: functionTool }, 201);
|
|
2180
|
-
} catch (error) {
|
|
2181
|
-
logger3.error({ error, tenantId, projectId, agentId, body }, "Failed to create function tool");
|
|
2182
|
-
return c.json(
|
|
2183
|
-
createApiError({
|
|
2184
|
-
code: "internal_server_error",
|
|
2185
|
-
message: "Failed to create function tool"
|
|
2186
|
-
}),
|
|
2187
|
-
500
|
|
2188
|
-
);
|
|
2189
|
-
}
|
|
2190
|
-
}
|
|
2191
|
-
);
|
|
2192
|
-
app9.openapi(
|
|
2193
|
-
createRoute({
|
|
2194
|
-
method: "put",
|
|
2195
|
-
path: "/:id",
|
|
2196
|
-
summary: "Update Function Tool",
|
|
2197
|
-
operationId: "update-function-tool",
|
|
2198
|
-
tags: ["Function Tools"],
|
|
2199
|
-
request: {
|
|
2200
|
-
params: TenantProjectAgentParamsSchema.extend({
|
|
2201
|
-
id: z.string()
|
|
2202
|
-
}),
|
|
2203
|
-
body: {
|
|
2204
|
-
content: {
|
|
2205
|
-
"application/json": {
|
|
2206
|
-
schema: FunctionToolApiUpdateSchema
|
|
2207
|
-
}
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2210
|
-
},
|
|
2211
|
-
responses: {
|
|
2212
|
-
200: {
|
|
2213
|
-
description: "Function tool updated successfully",
|
|
2214
|
-
content: {
|
|
2215
|
-
"application/json": {
|
|
2216
|
-
schema: SingleResponseSchema(FunctionToolApiSelectSchema)
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
|
-
},
|
|
2220
|
-
...commonGetErrorResponses
|
|
2221
|
-
}
|
|
2222
|
-
}),
|
|
2223
|
-
async (c) => {
|
|
2224
|
-
const { tenantId, projectId, agentId, id } = c.req.valid("param");
|
|
2225
|
-
const body = c.req.valid("json");
|
|
2226
|
-
try {
|
|
2227
|
-
const functionTool = await updateFunctionTool(dbClient_default)({
|
|
2228
|
-
scopes: { tenantId, projectId, agentId },
|
|
2229
|
-
functionToolId: id,
|
|
2230
|
-
data: body
|
|
2231
|
-
});
|
|
2232
|
-
if (!functionTool) {
|
|
2233
|
-
return c.json(
|
|
2234
|
-
createApiError({ code: "not_found", message: "Function tool not found" }),
|
|
2235
|
-
404
|
|
2236
|
-
);
|
|
2237
|
-
}
|
|
2238
|
-
return c.json({ data: functionTool });
|
|
2239
|
-
} catch (error) {
|
|
2240
|
-
logger3.error(
|
|
2241
|
-
{ error, tenantId, projectId, agentId, id, body },
|
|
2242
|
-
"Failed to update function tool"
|
|
2243
|
-
);
|
|
2244
|
-
return c.json(
|
|
2245
|
-
createApiError({
|
|
2246
|
-
code: "internal_server_error",
|
|
2247
|
-
message: "Failed to update function tool"
|
|
2248
|
-
}),
|
|
2249
|
-
500
|
|
2250
|
-
);
|
|
2251
|
-
}
|
|
2252
|
-
}
|
|
2253
|
-
);
|
|
2254
|
-
app9.openapi(
|
|
2255
|
-
createRoute({
|
|
2256
|
-
method: "delete",
|
|
2257
|
-
path: "/:id",
|
|
2258
|
-
summary: "Delete Function Tool",
|
|
2259
|
-
operationId: "delete-function-tool",
|
|
2260
|
-
tags: ["Function Tools"],
|
|
2261
|
-
request: {
|
|
2262
|
-
params: TenantProjectAgentParamsSchema.extend({
|
|
2263
|
-
id: z.string()
|
|
2264
|
-
})
|
|
2265
|
-
},
|
|
2266
|
-
responses: {
|
|
2267
|
-
204: {
|
|
2268
|
-
description: "Function tool deleted successfully"
|
|
2269
|
-
},
|
|
2270
|
-
...commonGetErrorResponses
|
|
2271
|
-
}
|
|
2272
|
-
}),
|
|
2273
|
-
async (c) => {
|
|
2274
|
-
const { tenantId, projectId, agentId, id } = c.req.valid("param");
|
|
2275
|
-
try {
|
|
2276
|
-
const deleted = await deleteFunctionTool(dbClient_default)({
|
|
2277
|
-
scopes: { tenantId, projectId, agentId },
|
|
2278
|
-
functionToolId: id
|
|
2279
|
-
});
|
|
2280
|
-
if (!deleted) {
|
|
2281
|
-
return c.json(
|
|
2282
|
-
createApiError({ code: "not_found", message: "Function tool not found" }),
|
|
2283
|
-
404
|
|
2284
|
-
);
|
|
2285
|
-
}
|
|
2286
|
-
return c.body(null, 204);
|
|
2287
|
-
} catch (error) {
|
|
2288
|
-
logger3.error({ error, tenantId, projectId, agentId, id }, "Failed to delete function tool");
|
|
2289
|
-
return c.json(
|
|
2290
|
-
createApiError({
|
|
2291
|
-
code: "internal_server_error",
|
|
2292
|
-
message: "Failed to delete function tool"
|
|
2293
|
-
}),
|
|
2294
|
-
500
|
|
2295
|
-
);
|
|
2296
|
-
}
|
|
2297
|
-
}
|
|
2298
|
-
);
|
|
2299
|
-
var functionTools_default = app9;
|
|
2300
|
-
var logger4 = getLogger("agentFull");
|
|
2301
|
-
var app10 = new OpenAPIHono();
|
|
2302
|
-
var AgentIdParamsSchema = z.object({
|
|
2303
|
-
tenantId: z.string().openapi({
|
|
2304
|
-
description: "Tenant identifier",
|
|
2305
|
-
example: "tenant_123"
|
|
2306
|
-
}),
|
|
2307
|
-
projectId: z.string().openapi({
|
|
2308
|
-
description: "Project identifier",
|
|
2309
|
-
example: "project_456"
|
|
2310
|
-
}),
|
|
2311
|
-
agentId: z.string().openapi({
|
|
2312
|
-
description: "Agent identifier",
|
|
2313
|
-
example: "agent_789"
|
|
2314
|
-
})
|
|
2315
|
-
}).openapi("AgentIdParams");
|
|
2316
|
-
app10.openapi(
|
|
2317
|
-
createRoute({
|
|
2318
|
-
method: "post",
|
|
2319
|
-
path: "/",
|
|
2320
|
-
summary: "Create Full Agent",
|
|
2321
|
-
operationId: "create-full-agent",
|
|
2322
|
-
tags: ["Full Agent"],
|
|
2323
|
-
description: "Create a complete agent with all agents, tools, and relationships from JSON definition",
|
|
2324
|
-
request: {
|
|
2325
|
-
params: TenantProjectParamsSchema,
|
|
2326
|
-
body: {
|
|
2327
|
-
content: {
|
|
2328
|
-
"application/json": {
|
|
2329
|
-
schema: AgentWithinContextOfProjectSchema
|
|
2330
|
-
}
|
|
2331
|
-
}
|
|
2332
|
-
}
|
|
2333
|
-
},
|
|
2334
|
-
responses: {
|
|
2335
|
-
201: {
|
|
2336
|
-
description: "Full agent created successfully",
|
|
2337
|
-
content: {
|
|
2338
|
-
"application/json": {
|
|
2339
|
-
schema: SingleResponseSchema(AgentWithinContextOfProjectSchema)
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2342
|
-
},
|
|
2343
|
-
409: {
|
|
2344
|
-
description: "Agent already exists",
|
|
2345
|
-
content: {
|
|
2346
|
-
"application/json": {
|
|
2347
|
-
schema: ErrorResponseSchema
|
|
2348
|
-
}
|
|
2349
|
-
}
|
|
2350
|
-
},
|
|
2351
|
-
...commonGetErrorResponses
|
|
2352
|
-
}
|
|
2353
|
-
}),
|
|
2354
|
-
async (c) => {
|
|
2355
|
-
const { tenantId, projectId } = c.req.valid("param");
|
|
2356
|
-
const agentData = c.req.valid("json");
|
|
2357
|
-
const validatedAgentData = AgentWithinContextOfProjectSchema.parse(agentData);
|
|
2358
|
-
const createdAgent = await createFullAgentServerSide(dbClient_default, logger4)(
|
|
2359
|
-
{ tenantId, projectId },
|
|
2360
|
-
validatedAgentData
|
|
2361
|
-
);
|
|
2362
|
-
return c.json({ data: createdAgent }, 201);
|
|
2363
|
-
}
|
|
2364
|
-
);
|
|
2365
|
-
app10.openapi(
|
|
2366
|
-
createRoute({
|
|
2367
|
-
method: "get",
|
|
2368
|
-
path: "/{agentId}",
|
|
2369
|
-
summary: "Get Full Agent",
|
|
2370
|
-
operationId: "get-full-agent",
|
|
2371
|
-
tags: ["Full Agent"],
|
|
2372
|
-
description: "Retrieve a complete agent definition with all agents, tools, and relationships",
|
|
2373
|
-
request: {
|
|
2374
|
-
params: AgentIdParamsSchema
|
|
2375
|
-
},
|
|
2376
|
-
responses: {
|
|
2377
|
-
200: {
|
|
2378
|
-
description: "Full agent found",
|
|
2379
|
-
content: {
|
|
2380
|
-
"application/json": {
|
|
2381
|
-
schema: SingleResponseSchema(AgentWithinContextOfProjectSchema)
|
|
2382
|
-
}
|
|
2383
|
-
}
|
|
2384
|
-
},
|
|
2385
|
-
...commonGetErrorResponses
|
|
2386
|
-
}
|
|
2387
|
-
}),
|
|
2388
|
-
async (c) => {
|
|
2389
|
-
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
2390
|
-
try {
|
|
2391
|
-
const agent = await getFullAgent(
|
|
2392
|
-
dbClient_default,
|
|
2393
|
-
logger4
|
|
2394
|
-
)({
|
|
2395
|
-
scopes: { tenantId, projectId, agentId }
|
|
2396
|
-
});
|
|
2397
|
-
if (!agent) {
|
|
2398
|
-
throw createApiError({
|
|
2399
|
-
code: "not_found",
|
|
2400
|
-
message: "Agent not found"
|
|
2401
|
-
});
|
|
2402
|
-
}
|
|
2403
|
-
return c.json({ data: agent });
|
|
2404
|
-
} catch (error) {
|
|
2405
|
-
if (error instanceof Error && error.message.includes("not found")) {
|
|
2406
|
-
throw createApiError({
|
|
2407
|
-
code: "not_found",
|
|
2408
|
-
message: "Agent not found"
|
|
2409
|
-
});
|
|
2410
|
-
}
|
|
2411
|
-
throw createApiError({
|
|
2412
|
-
code: "internal_server_error",
|
|
2413
|
-
message: error instanceof Error ? error.message : "Failed to retrieve agent"
|
|
2549
|
+
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
2550
|
+
const body = c.req.valid("json");
|
|
2551
|
+
try {
|
|
2552
|
+
const id = body.id || nanoid();
|
|
2553
|
+
const functionTool = await createFunctionTool(dbClient_default)({
|
|
2554
|
+
scopes: { tenantId, projectId, agentId },
|
|
2555
|
+
data: {
|
|
2556
|
+
...body,
|
|
2557
|
+
id
|
|
2558
|
+
}
|
|
2414
2559
|
});
|
|
2560
|
+
return c.json({ data: functionTool }, 201);
|
|
2561
|
+
} catch (error) {
|
|
2562
|
+
logger4.error({ error, tenantId, projectId, agentId, body }, "Failed to create function tool");
|
|
2563
|
+
return c.json(
|
|
2564
|
+
createApiError({
|
|
2565
|
+
code: "internal_server_error",
|
|
2566
|
+
message: "Failed to create function tool"
|
|
2567
|
+
}),
|
|
2568
|
+
500
|
|
2569
|
+
);
|
|
2415
2570
|
}
|
|
2416
2571
|
}
|
|
2417
2572
|
);
|
|
2418
|
-
|
|
2573
|
+
app11.openapi(
|
|
2419
2574
|
createRoute({
|
|
2420
2575
|
method: "put",
|
|
2421
|
-
path: "
|
|
2422
|
-
summary: "Update
|
|
2423
|
-
operationId: "update-
|
|
2424
|
-
tags: ["
|
|
2425
|
-
description: "Update or create a complete agent with all agents, tools, and relationships from JSON definition",
|
|
2576
|
+
path: "/:id",
|
|
2577
|
+
summary: "Update Function Tool",
|
|
2578
|
+
operationId: "update-function-tool",
|
|
2579
|
+
tags: ["Function Tools"],
|
|
2426
2580
|
request: {
|
|
2427
|
-
params:
|
|
2581
|
+
params: TenantProjectAgentParamsSchema.extend({
|
|
2582
|
+
id: z.string()
|
|
2583
|
+
}),
|
|
2428
2584
|
body: {
|
|
2429
2585
|
content: {
|
|
2430
2586
|
"application/json": {
|
|
2431
|
-
schema:
|
|
2587
|
+
schema: FunctionToolApiUpdateSchema
|
|
2432
2588
|
}
|
|
2433
2589
|
}
|
|
2434
2590
|
}
|
|
2435
2591
|
},
|
|
2436
2592
|
responses: {
|
|
2437
2593
|
200: {
|
|
2438
|
-
description: "
|
|
2439
|
-
content: {
|
|
2440
|
-
"application/json": {
|
|
2441
|
-
schema: SingleResponseSchema(AgentWithinContextOfProjectSchema)
|
|
2442
|
-
}
|
|
2443
|
-
}
|
|
2444
|
-
},
|
|
2445
|
-
201: {
|
|
2446
|
-
description: "Full agent created successfully",
|
|
2594
|
+
description: "Function tool updated successfully",
|
|
2447
2595
|
content: {
|
|
2448
2596
|
"application/json": {
|
|
2449
|
-
schema: SingleResponseSchema(
|
|
2597
|
+
schema: SingleResponseSchema(FunctionToolApiSelectSchema)
|
|
2450
2598
|
}
|
|
2451
2599
|
}
|
|
2452
2600
|
},
|
|
@@ -2454,102 +2602,84 @@ app10.openapi(
|
|
|
2454
2602
|
}
|
|
2455
2603
|
}),
|
|
2456
2604
|
async (c) => {
|
|
2457
|
-
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
2458
|
-
const
|
|
2605
|
+
const { tenantId, projectId, agentId, id } = c.req.valid("param");
|
|
2606
|
+
const body = c.req.valid("json");
|
|
2459
2607
|
try {
|
|
2460
|
-
const
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
message: `Agent ID mismatch: expected ${agentId}, got ${validatedAgentData.id}`
|
|
2465
|
-
});
|
|
2466
|
-
}
|
|
2467
|
-
const existingAgent = await getFullAgent(
|
|
2468
|
-
dbClient_default,
|
|
2469
|
-
logger4
|
|
2470
|
-
)({
|
|
2471
|
-
scopes: { tenantId, projectId, agentId }
|
|
2608
|
+
const functionTool = await updateFunctionTool(dbClient_default)({
|
|
2609
|
+
scopes: { tenantId, projectId, agentId },
|
|
2610
|
+
functionToolId: id,
|
|
2611
|
+
data: body
|
|
2472
2612
|
});
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
{ tenantId, projectId },
|
|
2479
|
-
validatedAgentData
|
|
2480
|
-
);
|
|
2481
|
-
return c.json({ data: updatedAgent }, isCreate ? 201 : 200);
|
|
2482
|
-
} catch (error) {
|
|
2483
|
-
if (error instanceof z.ZodError) {
|
|
2484
|
-
throw createApiError({
|
|
2485
|
-
code: "bad_request",
|
|
2486
|
-
message: "Invalid agent definition"
|
|
2487
|
-
});
|
|
2488
|
-
}
|
|
2489
|
-
if (error instanceof Error && error.message.includes("ID mismatch")) {
|
|
2490
|
-
throw createApiError({
|
|
2491
|
-
code: "bad_request",
|
|
2492
|
-
message: error.message
|
|
2493
|
-
});
|
|
2613
|
+
if (!functionTool) {
|
|
2614
|
+
return c.json(
|
|
2615
|
+
createApiError({ code: "not_found", message: "Function tool not found" }),
|
|
2616
|
+
404
|
|
2617
|
+
);
|
|
2494
2618
|
}
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2619
|
+
return c.json({ data: functionTool });
|
|
2620
|
+
} catch (error) {
|
|
2621
|
+
logger4.error(
|
|
2622
|
+
{ error, tenantId, projectId, agentId, id, body },
|
|
2623
|
+
"Failed to update function tool"
|
|
2624
|
+
);
|
|
2625
|
+
return c.json(
|
|
2626
|
+
createApiError({
|
|
2627
|
+
code: "internal_server_error",
|
|
2628
|
+
message: "Failed to update function tool"
|
|
2629
|
+
}),
|
|
2630
|
+
500
|
|
2631
|
+
);
|
|
2499
2632
|
}
|
|
2500
2633
|
}
|
|
2501
2634
|
);
|
|
2502
|
-
|
|
2635
|
+
app11.openapi(
|
|
2503
2636
|
createRoute({
|
|
2504
2637
|
method: "delete",
|
|
2505
|
-
path: "
|
|
2506
|
-
summary: "Delete
|
|
2507
|
-
operationId: "delete-
|
|
2508
|
-
tags: ["
|
|
2509
|
-
description: "Delete a complete agent and cascade to all related entities (relationships, not other agents/tools)",
|
|
2638
|
+
path: "/:id",
|
|
2639
|
+
summary: "Delete Function Tool",
|
|
2640
|
+
operationId: "delete-function-tool",
|
|
2641
|
+
tags: ["Function Tools"],
|
|
2510
2642
|
request: {
|
|
2511
|
-
params:
|
|
2643
|
+
params: TenantProjectAgentParamsSchema.extend({
|
|
2644
|
+
id: z.string()
|
|
2645
|
+
})
|
|
2512
2646
|
},
|
|
2513
2647
|
responses: {
|
|
2514
2648
|
204: {
|
|
2515
|
-
description: "
|
|
2649
|
+
description: "Function tool deleted successfully"
|
|
2516
2650
|
},
|
|
2517
2651
|
...commonGetErrorResponses
|
|
2518
2652
|
}
|
|
2519
2653
|
}),
|
|
2520
2654
|
async (c) => {
|
|
2521
|
-
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
2655
|
+
const { tenantId, projectId, agentId, id } = c.req.valid("param");
|
|
2522
2656
|
try {
|
|
2523
|
-
const deleted = await
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
)({
|
|
2527
|
-
scopes: { tenantId, projectId, agentId }
|
|
2657
|
+
const deleted = await deleteFunctionTool(dbClient_default)({
|
|
2658
|
+
scopes: { tenantId, projectId, agentId },
|
|
2659
|
+
functionToolId: id
|
|
2528
2660
|
});
|
|
2529
2661
|
if (!deleted) {
|
|
2530
|
-
|
|
2531
|
-
code: "not_found",
|
|
2532
|
-
|
|
2533
|
-
|
|
2662
|
+
return c.json(
|
|
2663
|
+
createApiError({ code: "not_found", message: "Function tool not found" }),
|
|
2664
|
+
404
|
|
2665
|
+
);
|
|
2534
2666
|
}
|
|
2535
2667
|
return c.body(null, 204);
|
|
2536
2668
|
} catch (error) {
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
message: error instanceof Error ? error.message : "Failed to delete agent"
|
|
2546
|
-
});
|
|
2669
|
+
logger4.error({ error, tenantId, projectId, agentId, id }, "Failed to delete function tool");
|
|
2670
|
+
return c.json(
|
|
2671
|
+
createApiError({
|
|
2672
|
+
code: "internal_server_error",
|
|
2673
|
+
message: "Failed to delete function tool"
|
|
2674
|
+
}),
|
|
2675
|
+
500
|
|
2676
|
+
);
|
|
2547
2677
|
}
|
|
2548
2678
|
}
|
|
2549
2679
|
);
|
|
2550
|
-
var
|
|
2551
|
-
var
|
|
2552
|
-
|
|
2680
|
+
var functionTools_default = app11;
|
|
2681
|
+
var app12 = new OpenAPIHono();
|
|
2682
|
+
app12.openapi(
|
|
2553
2683
|
createRoute({
|
|
2554
2684
|
method: "get",
|
|
2555
2685
|
path: "/",
|
|
@@ -2584,7 +2714,7 @@ app11.openapi(
|
|
|
2584
2714
|
return c.json(result);
|
|
2585
2715
|
}
|
|
2586
2716
|
);
|
|
2587
|
-
|
|
2717
|
+
app12.openapi(
|
|
2588
2718
|
createRoute({
|
|
2589
2719
|
method: "get",
|
|
2590
2720
|
path: "/{id}",
|
|
@@ -2619,7 +2749,7 @@ app11.openapi(
|
|
|
2619
2749
|
return c.json({ data: project });
|
|
2620
2750
|
}
|
|
2621
2751
|
);
|
|
2622
|
-
|
|
2752
|
+
app12.openapi(
|
|
2623
2753
|
createRoute({
|
|
2624
2754
|
method: "post",
|
|
2625
2755
|
path: "/",
|
|
@@ -2677,7 +2807,7 @@ app11.openapi(
|
|
|
2677
2807
|
}
|
|
2678
2808
|
}
|
|
2679
2809
|
);
|
|
2680
|
-
|
|
2810
|
+
app12.openapi(
|
|
2681
2811
|
createRoute({
|
|
2682
2812
|
method: "patch",
|
|
2683
2813
|
path: "/{id}",
|
|
@@ -2723,7 +2853,7 @@ app11.openapi(
|
|
|
2723
2853
|
return c.json({ data: project });
|
|
2724
2854
|
}
|
|
2725
2855
|
);
|
|
2726
|
-
|
|
2856
|
+
app12.openapi(
|
|
2727
2857
|
createRoute({
|
|
2728
2858
|
method: "delete",
|
|
2729
2859
|
path: "/{id}",
|
|
@@ -2773,9 +2903,9 @@ app11.openapi(
|
|
|
2773
2903
|
}
|
|
2774
2904
|
}
|
|
2775
2905
|
);
|
|
2776
|
-
var projects_default =
|
|
2777
|
-
var
|
|
2778
|
-
|
|
2906
|
+
var projects_default = app12;
|
|
2907
|
+
var app13 = new OpenAPIHono();
|
|
2908
|
+
app13.openapi(
|
|
2779
2909
|
createRoute({
|
|
2780
2910
|
method: "get",
|
|
2781
2911
|
path: "/agent/:subAgentId",
|
|
@@ -2811,7 +2941,7 @@ app12.openapi(
|
|
|
2811
2941
|
});
|
|
2812
2942
|
}
|
|
2813
2943
|
);
|
|
2814
|
-
|
|
2944
|
+
app13.openapi(
|
|
2815
2945
|
createRoute({
|
|
2816
2946
|
method: "get",
|
|
2817
2947
|
path: "/component/:artifactComponentId/agents",
|
|
@@ -2851,7 +2981,7 @@ app12.openapi(
|
|
|
2851
2981
|
return c.json({ data: agents });
|
|
2852
2982
|
}
|
|
2853
2983
|
);
|
|
2854
|
-
|
|
2984
|
+
app13.openapi(
|
|
2855
2985
|
createRoute({
|
|
2856
2986
|
method: "post",
|
|
2857
2987
|
path: "/",
|
|
@@ -2928,7 +3058,7 @@ app12.openapi(
|
|
|
2928
3058
|
return c.json({ data: association }, 201);
|
|
2929
3059
|
}
|
|
2930
3060
|
);
|
|
2931
|
-
|
|
3061
|
+
app13.openapi(
|
|
2932
3062
|
createRoute({
|
|
2933
3063
|
method: "delete",
|
|
2934
3064
|
path: "/agent/:subAgentId/component/:artifactComponentId",
|
|
@@ -2971,7 +3101,7 @@ app12.openapi(
|
|
|
2971
3101
|
});
|
|
2972
3102
|
}
|
|
2973
3103
|
);
|
|
2974
|
-
|
|
3104
|
+
app13.openapi(
|
|
2975
3105
|
createRoute({
|
|
2976
3106
|
method: "get",
|
|
2977
3107
|
path: "/agent/:subAgentId/component/:artifactComponentId/exists",
|
|
@@ -3005,9 +3135,9 @@ app12.openapi(
|
|
|
3005
3135
|
return c.json({ exists });
|
|
3006
3136
|
}
|
|
3007
3137
|
);
|
|
3008
|
-
var subAgentArtifactComponents_default =
|
|
3009
|
-
var
|
|
3010
|
-
|
|
3138
|
+
var subAgentArtifactComponents_default = app13;
|
|
3139
|
+
var app14 = new OpenAPIHono();
|
|
3140
|
+
app14.openapi(
|
|
3011
3141
|
createRoute({
|
|
3012
3142
|
method: "get",
|
|
3013
3143
|
path: "/agent/:subAgentId",
|
|
@@ -3041,7 +3171,7 @@ app13.openapi(
|
|
|
3041
3171
|
return c.json({ data: dataComponents });
|
|
3042
3172
|
}
|
|
3043
3173
|
);
|
|
3044
|
-
|
|
3174
|
+
app14.openapi(
|
|
3045
3175
|
createRoute({
|
|
3046
3176
|
method: "get",
|
|
3047
3177
|
path: "/component/:dataComponentId/agents",
|
|
@@ -3081,7 +3211,7 @@ app13.openapi(
|
|
|
3081
3211
|
return c.json({ data: agents });
|
|
3082
3212
|
}
|
|
3083
3213
|
);
|
|
3084
|
-
|
|
3214
|
+
app14.openapi(
|
|
3085
3215
|
createRoute({
|
|
3086
3216
|
method: "post",
|
|
3087
3217
|
path: "/",
|
|
@@ -3154,7 +3284,7 @@ app13.openapi(
|
|
|
3154
3284
|
return c.json({ data: association }, 201);
|
|
3155
3285
|
}
|
|
3156
3286
|
);
|
|
3157
|
-
|
|
3287
|
+
app14.openapi(
|
|
3158
3288
|
createRoute({
|
|
3159
3289
|
method: "delete",
|
|
3160
3290
|
path: "/agent/:subAgentId/component/:dataComponentId",
|
|
@@ -3197,7 +3327,7 @@ app13.openapi(
|
|
|
3197
3327
|
});
|
|
3198
3328
|
}
|
|
3199
3329
|
);
|
|
3200
|
-
|
|
3330
|
+
app14.openapi(
|
|
3201
3331
|
createRoute({
|
|
3202
3332
|
method: "get",
|
|
3203
3333
|
path: "/agent/:subAgentId/component/:dataComponentId/exists",
|
|
@@ -3231,22 +3361,22 @@ app13.openapi(
|
|
|
3231
3361
|
return c.json({ exists });
|
|
3232
3362
|
}
|
|
3233
3363
|
);
|
|
3234
|
-
var subAgentDataComponents_default =
|
|
3235
|
-
var
|
|
3236
|
-
|
|
3364
|
+
var subAgentDataComponents_default = app14;
|
|
3365
|
+
var app15 = new OpenAPIHono();
|
|
3366
|
+
app15.openapi(
|
|
3237
3367
|
createRoute({
|
|
3238
3368
|
method: "get",
|
|
3239
3369
|
path: "/",
|
|
3240
|
-
summary: "List Agent Relations",
|
|
3241
|
-
operationId: "list-agent-relations",
|
|
3242
|
-
tags: ["Agent Relations"],
|
|
3370
|
+
summary: "List Sub Agent Relations",
|
|
3371
|
+
operationId: "list-sub-agent-relations",
|
|
3372
|
+
tags: ["Sub Agent Relations"],
|
|
3243
3373
|
request: {
|
|
3244
3374
|
params: TenantProjectAgentParamsSchema,
|
|
3245
3375
|
query: PaginationQueryParamsSchema.merge(SubAgentRelationQuerySchema)
|
|
3246
3376
|
},
|
|
3247
3377
|
responses: {
|
|
3248
3378
|
200: {
|
|
3249
|
-
description: "List of agent relations retrieved successfully",
|
|
3379
|
+
description: "List of sub agent relations retrieved successfully",
|
|
3250
3380
|
content: {
|
|
3251
3381
|
"application/json": {
|
|
3252
3382
|
schema: ListResponseSchema(SubAgentRelationApiSelectSchema)
|
|
@@ -3277,7 +3407,7 @@ app14.openapi(
|
|
|
3277
3407
|
});
|
|
3278
3408
|
result = { ...rawResult, data: rawResult.data };
|
|
3279
3409
|
} else if (targetSubAgentId) {
|
|
3280
|
-
const rawResult = await
|
|
3410
|
+
const rawResult = await getSubAgentRelationsByTarget(dbClient_default)({
|
|
3281
3411
|
scopes: { tenantId, projectId, agentId },
|
|
3282
3412
|
targetSubAgentId,
|
|
3283
3413
|
pagination: { page: pageNum, limit: limitNum }
|
|
@@ -3301,24 +3431,24 @@ app14.openapi(
|
|
|
3301
3431
|
} catch (_error) {
|
|
3302
3432
|
throw createApiError({
|
|
3303
3433
|
code: "internal_server_error",
|
|
3304
|
-
message: "Failed to retrieve agent relations"
|
|
3434
|
+
message: "Failed to retrieve sub agent relations"
|
|
3305
3435
|
});
|
|
3306
3436
|
}
|
|
3307
3437
|
}
|
|
3308
3438
|
);
|
|
3309
|
-
|
|
3439
|
+
app15.openapi(
|
|
3310
3440
|
createRoute({
|
|
3311
3441
|
method: "get",
|
|
3312
3442
|
path: "/{id}",
|
|
3313
|
-
summary: "Get Agent Relation",
|
|
3314
|
-
operationId: "get-agent-relation-by-id",
|
|
3315
|
-
tags: ["Agent Relations"],
|
|
3443
|
+
summary: "Get Sub Agent Relation",
|
|
3444
|
+
operationId: "get-sub-agent-relation-by-id",
|
|
3445
|
+
tags: ["Sub Agent Relations"],
|
|
3316
3446
|
request: {
|
|
3317
3447
|
params: TenantProjectAgentIdParamsSchema
|
|
3318
3448
|
},
|
|
3319
3449
|
responses: {
|
|
3320
3450
|
200: {
|
|
3321
|
-
description: "Agent relation found",
|
|
3451
|
+
description: "Sub Agent relation found",
|
|
3322
3452
|
content: {
|
|
3323
3453
|
"application/json": {
|
|
3324
3454
|
schema: SingleResponseSchema(SubAgentRelationApiSelectSchema)
|
|
@@ -3337,19 +3467,19 @@ app14.openapi(
|
|
|
3337
3467
|
if (!agentRelation) {
|
|
3338
3468
|
throw createApiError({
|
|
3339
3469
|
code: "not_found",
|
|
3340
|
-
message: "Agent
|
|
3470
|
+
message: "Sub Agent Relation not found"
|
|
3341
3471
|
});
|
|
3342
3472
|
}
|
|
3343
3473
|
return c.json({ data: agentRelation });
|
|
3344
3474
|
}
|
|
3345
3475
|
);
|
|
3346
|
-
|
|
3476
|
+
app15.openapi(
|
|
3347
3477
|
createRoute({
|
|
3348
3478
|
method: "post",
|
|
3349
3479
|
path: "/",
|
|
3350
|
-
summary: "Create Agent Relation",
|
|
3351
|
-
operationId: "create-agent-relation",
|
|
3352
|
-
tags: ["Agent Relations"],
|
|
3480
|
+
summary: "Create Sub Agent Relation",
|
|
3481
|
+
operationId: "create-sub-agent-relation",
|
|
3482
|
+
tags: ["Sub Agent Relations"],
|
|
3353
3483
|
request: {
|
|
3354
3484
|
params: TenantProjectAgentParamsSchema,
|
|
3355
3485
|
body: {
|
|
@@ -3362,7 +3492,7 @@ app14.openapi(
|
|
|
3362
3492
|
},
|
|
3363
3493
|
responses: {
|
|
3364
3494
|
201: {
|
|
3365
|
-
description: "Agent
|
|
3495
|
+
description: "Sub Agent Relation created successfully",
|
|
3366
3496
|
content: {
|
|
3367
3497
|
"application/json": {
|
|
3368
3498
|
schema: SingleResponseSchema(SubAgentRelationApiSelectSchema)
|
|
@@ -3434,13 +3564,13 @@ app14.openapi(
|
|
|
3434
3564
|
return c.json({ data: agentRelation }, 201);
|
|
3435
3565
|
}
|
|
3436
3566
|
);
|
|
3437
|
-
|
|
3567
|
+
app15.openapi(
|
|
3438
3568
|
createRoute({
|
|
3439
3569
|
method: "put",
|
|
3440
3570
|
path: "/{id}",
|
|
3441
|
-
summary: "Update Agent Relation",
|
|
3442
|
-
operationId: "update-agent-relation",
|
|
3443
|
-
tags: ["Agent Relations"],
|
|
3571
|
+
summary: "Update Sub Agent Relation",
|
|
3572
|
+
operationId: "update-sub-agent-relation",
|
|
3573
|
+
tags: ["Sub Agent Relations"],
|
|
3444
3574
|
request: {
|
|
3445
3575
|
params: TenantProjectAgentIdParamsSchema,
|
|
3446
3576
|
body: {
|
|
@@ -3453,7 +3583,7 @@ app14.openapi(
|
|
|
3453
3583
|
},
|
|
3454
3584
|
responses: {
|
|
3455
3585
|
200: {
|
|
3456
|
-
description: "Agent relation updated successfully",
|
|
3586
|
+
description: "Sub Agent relation updated successfully",
|
|
3457
3587
|
content: {
|
|
3458
3588
|
"application/json": {
|
|
3459
3589
|
schema: SingleResponseSchema(SubAgentRelationApiSelectSchema)
|
|
@@ -3474,28 +3604,28 @@ app14.openapi(
|
|
|
3474
3604
|
if (!updatedAgentRelation) {
|
|
3475
3605
|
throw createApiError({
|
|
3476
3606
|
code: "not_found",
|
|
3477
|
-
message: "Agent
|
|
3607
|
+
message: "Sub Agent Relation not found"
|
|
3478
3608
|
});
|
|
3479
3609
|
}
|
|
3480
3610
|
return c.json({ data: updatedAgentRelation });
|
|
3481
3611
|
}
|
|
3482
3612
|
);
|
|
3483
|
-
|
|
3613
|
+
app15.openapi(
|
|
3484
3614
|
createRoute({
|
|
3485
3615
|
method: "delete",
|
|
3486
3616
|
path: "/{id}",
|
|
3487
|
-
summary: "Delete Agent Relation",
|
|
3488
|
-
operationId: "delete-agent-relation",
|
|
3489
|
-
tags: ["Agent Relations"],
|
|
3617
|
+
summary: "Delete Sub Agent Relation",
|
|
3618
|
+
operationId: "delete-sub-agent-relation",
|
|
3619
|
+
tags: ["Sub Agent Relations"],
|
|
3490
3620
|
request: {
|
|
3491
3621
|
params: TenantProjectAgentIdParamsSchema
|
|
3492
3622
|
},
|
|
3493
3623
|
responses: {
|
|
3494
3624
|
204: {
|
|
3495
|
-
description: "Agent
|
|
3625
|
+
description: "Sub Agent Relation deleted successfully"
|
|
3496
3626
|
},
|
|
3497
3627
|
404: {
|
|
3498
|
-
description: "Agent
|
|
3628
|
+
description: "Sub Agent Relation not found",
|
|
3499
3629
|
content: {
|
|
3500
3630
|
"application/json": {
|
|
3501
3631
|
schema: ErrorResponseSchema
|
|
@@ -3513,15 +3643,15 @@ app14.openapi(
|
|
|
3513
3643
|
if (!deleted) {
|
|
3514
3644
|
throw createApiError({
|
|
3515
3645
|
code: "not_found",
|
|
3516
|
-
message: "Agent
|
|
3646
|
+
message: "Sub Agent Relation not found"
|
|
3517
3647
|
});
|
|
3518
3648
|
}
|
|
3519
3649
|
return c.body(null, 204);
|
|
3520
3650
|
}
|
|
3521
3651
|
);
|
|
3522
|
-
var subAgentRelations_default =
|
|
3523
|
-
var
|
|
3524
|
-
|
|
3652
|
+
var subAgentRelations_default = app15;
|
|
3653
|
+
var app16 = new OpenAPIHono();
|
|
3654
|
+
app16.openapi(
|
|
3525
3655
|
createRoute({
|
|
3526
3656
|
method: "get",
|
|
3527
3657
|
path: "/",
|
|
@@ -3562,7 +3692,7 @@ app15.openapi(
|
|
|
3562
3692
|
return c.json(dataWithType);
|
|
3563
3693
|
}
|
|
3564
3694
|
);
|
|
3565
|
-
|
|
3695
|
+
app16.openapi(
|
|
3566
3696
|
createRoute({
|
|
3567
3697
|
method: "get",
|
|
3568
3698
|
path: "/{id}",
|
|
@@ -3603,7 +3733,7 @@ app15.openapi(
|
|
|
3603
3733
|
return c.json({ data: subAgentWithType });
|
|
3604
3734
|
}
|
|
3605
3735
|
);
|
|
3606
|
-
|
|
3736
|
+
app16.openapi(
|
|
3607
3737
|
createRoute({
|
|
3608
3738
|
method: "post",
|
|
3609
3739
|
path: "/",
|
|
@@ -3650,7 +3780,7 @@ app15.openapi(
|
|
|
3650
3780
|
return c.json({ data: subAgentWithType }, 201);
|
|
3651
3781
|
}
|
|
3652
3782
|
);
|
|
3653
|
-
|
|
3783
|
+
app16.openapi(
|
|
3654
3784
|
createRoute({
|
|
3655
3785
|
method: "put",
|
|
3656
3786
|
path: "/{id}",
|
|
@@ -3700,7 +3830,7 @@ app15.openapi(
|
|
|
3700
3830
|
return c.json({ data: subAgentWithType });
|
|
3701
3831
|
}
|
|
3702
3832
|
);
|
|
3703
|
-
|
|
3833
|
+
app16.openapi(
|
|
3704
3834
|
createRoute({
|
|
3705
3835
|
method: "delete",
|
|
3706
3836
|
path: "/{id}",
|
|
@@ -3739,9 +3869,9 @@ app15.openapi(
|
|
|
3739
3869
|
return c.body(null, 204);
|
|
3740
3870
|
}
|
|
3741
3871
|
);
|
|
3742
|
-
var subAgents_default =
|
|
3743
|
-
var
|
|
3744
|
-
|
|
3872
|
+
var subAgents_default = app16;
|
|
3873
|
+
var app17 = new OpenAPIHono();
|
|
3874
|
+
app17.openapi(
|
|
3745
3875
|
createRoute({
|
|
3746
3876
|
method: "get",
|
|
3747
3877
|
path: "/",
|
|
@@ -3803,7 +3933,7 @@ app16.openapi(
|
|
|
3803
3933
|
return c.json(result);
|
|
3804
3934
|
}
|
|
3805
3935
|
);
|
|
3806
|
-
|
|
3936
|
+
app17.openapi(
|
|
3807
3937
|
createRoute({
|
|
3808
3938
|
method: "get",
|
|
3809
3939
|
path: "/{id}",
|
|
@@ -3840,7 +3970,7 @@ app16.openapi(
|
|
|
3840
3970
|
return c.json({ data: agentToolRelation });
|
|
3841
3971
|
}
|
|
3842
3972
|
);
|
|
3843
|
-
|
|
3973
|
+
app17.openapi(
|
|
3844
3974
|
createRoute({
|
|
3845
3975
|
method: "get",
|
|
3846
3976
|
path: "/tool/{toolId}/sub-agents",
|
|
@@ -3876,7 +4006,7 @@ app16.openapi(
|
|
|
3876
4006
|
return c.json(dbResult);
|
|
3877
4007
|
}
|
|
3878
4008
|
);
|
|
3879
|
-
|
|
4009
|
+
app17.openapi(
|
|
3880
4010
|
createRoute({
|
|
3881
4011
|
method: "post",
|
|
3882
4012
|
path: "/",
|
|
@@ -3939,7 +4069,7 @@ app16.openapi(
|
|
|
3939
4069
|
}
|
|
3940
4070
|
}
|
|
3941
4071
|
);
|
|
3942
|
-
|
|
4072
|
+
app17.openapi(
|
|
3943
4073
|
createRoute({
|
|
3944
4074
|
method: "put",
|
|
3945
4075
|
path: "/{id}",
|
|
@@ -3992,7 +4122,7 @@ app16.openapi(
|
|
|
3992
4122
|
return c.json({ data: updatedAgentToolRelation });
|
|
3993
4123
|
}
|
|
3994
4124
|
);
|
|
3995
|
-
|
|
4125
|
+
app17.openapi(
|
|
3996
4126
|
createRoute({
|
|
3997
4127
|
method: "delete",
|
|
3998
4128
|
path: "/{id}",
|
|
@@ -4031,10 +4161,10 @@ app16.openapi(
|
|
|
4031
4161
|
return c.body(null, 204);
|
|
4032
4162
|
}
|
|
4033
4163
|
);
|
|
4034
|
-
var subAgentToolRelations_default =
|
|
4164
|
+
var subAgentToolRelations_default = app17;
|
|
4035
4165
|
var logger5 = getLogger("tools");
|
|
4036
|
-
var
|
|
4037
|
-
|
|
4166
|
+
var app18 = new OpenAPIHono();
|
|
4167
|
+
app18.openapi(
|
|
4038
4168
|
createRoute({
|
|
4039
4169
|
method: "get",
|
|
4040
4170
|
path: "/",
|
|
@@ -4094,7 +4224,7 @@ app17.openapi(
|
|
|
4094
4224
|
return c.json(result);
|
|
4095
4225
|
}
|
|
4096
4226
|
);
|
|
4097
|
-
|
|
4227
|
+
app18.openapi(
|
|
4098
4228
|
createRoute({
|
|
4099
4229
|
method: "get",
|
|
4100
4230
|
path: "/{id}",
|
|
@@ -4131,7 +4261,7 @@ app17.openapi(
|
|
|
4131
4261
|
});
|
|
4132
4262
|
}
|
|
4133
4263
|
);
|
|
4134
|
-
|
|
4264
|
+
app18.openapi(
|
|
4135
4265
|
createRoute({
|
|
4136
4266
|
method: "post",
|
|
4137
4267
|
path: "/",
|
|
@@ -4184,7 +4314,7 @@ app17.openapi(
|
|
|
4184
4314
|
);
|
|
4185
4315
|
}
|
|
4186
4316
|
);
|
|
4187
|
-
|
|
4317
|
+
app18.openapi(
|
|
4188
4318
|
createRoute({
|
|
4189
4319
|
method: "put",
|
|
4190
4320
|
path: "/{id}",
|
|
@@ -4245,7 +4375,7 @@ app17.openapi(
|
|
|
4245
4375
|
});
|
|
4246
4376
|
}
|
|
4247
4377
|
);
|
|
4248
|
-
|
|
4378
|
+
app18.openapi(
|
|
4249
4379
|
createRoute({
|
|
4250
4380
|
method: "delete",
|
|
4251
4381
|
path: "/{id}",
|
|
@@ -4281,37 +4411,38 @@ app17.openapi(
|
|
|
4281
4411
|
return c.body(null, 204);
|
|
4282
4412
|
}
|
|
4283
4413
|
);
|
|
4284
|
-
var tools_default =
|
|
4414
|
+
var tools_default = app18;
|
|
4285
4415
|
|
|
4286
4416
|
// src/routes/index.ts
|
|
4287
|
-
var
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4417
|
+
var app19 = new OpenAPIHono();
|
|
4418
|
+
app19.route("/projects", projects_default);
|
|
4419
|
+
app19.route("/projects/:projectId/agents/:agentId/sub-agents", subAgents_default);
|
|
4420
|
+
app19.route("/projects/:projectId/agents/:agentId/sub-agent-relations", subAgentRelations_default);
|
|
4421
|
+
app19.route("/projects/:projectId/agents", agent_default);
|
|
4422
|
+
app19.route(
|
|
4293
4423
|
"/projects/:projectId/agents/:agentId/sub-agent-tool-relations",
|
|
4294
4424
|
subAgentToolRelations_default
|
|
4295
4425
|
);
|
|
4296
|
-
|
|
4426
|
+
app19.route(
|
|
4297
4427
|
"/projects/:projectId/agents/:agentId/sub-agent-artifact-components",
|
|
4298
4428
|
subAgentArtifactComponents_default
|
|
4299
4429
|
);
|
|
4300
|
-
|
|
4430
|
+
app19.route(
|
|
4301
4431
|
"/projects/:projectId/agents/:agentId/sub-agent-data-components",
|
|
4302
4432
|
subAgentDataComponents_default
|
|
4303
4433
|
);
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4434
|
+
app19.route("/projects/:projectId/artifact-components", artifactComponents_default);
|
|
4435
|
+
app19.route("/projects/:projectId/agents/:agentId/context-configs", contextConfigs_default);
|
|
4436
|
+
app19.route("/projects/:projectId/credentials", credentials_default);
|
|
4437
|
+
app19.route("/projects/:projectId/credential-stores", credentialStores_default);
|
|
4438
|
+
app19.route("/projects/:projectId/data-components", dataComponents_default);
|
|
4439
|
+
app19.route("/projects/:projectId/agents/:agentId/external-agents", externalAgents_default);
|
|
4440
|
+
app19.route("/projects/:projectId/agents/:agentId/function-tools", functionTools_default);
|
|
4441
|
+
app19.route("/projects/:projectId/functions", functions_default);
|
|
4442
|
+
app19.route("/projects/:projectId/tools", tools_default);
|
|
4443
|
+
app19.route("/projects/:projectId/api-keys", apiKeys_default);
|
|
4444
|
+
app19.route("/projects/:projectId/agent", agentFull_default);
|
|
4445
|
+
var routes_default = app19;
|
|
4315
4446
|
var logger6 = getLogger("oauth-service");
|
|
4316
4447
|
var pkceStore = /* @__PURE__ */ new Map();
|
|
4317
4448
|
function storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId) {
|
|
@@ -4583,7 +4714,7 @@ async function findOrCreateCredential(tenantId, projectId, credentialData) {
|
|
|
4583
4714
|
throw new Error(`Failed to save credential '${credentialData.id}' to database`);
|
|
4584
4715
|
}
|
|
4585
4716
|
}
|
|
4586
|
-
var
|
|
4717
|
+
var app20 = new OpenAPIHono();
|
|
4587
4718
|
var logger7 = getLogger("oauth-callback");
|
|
4588
4719
|
function getBaseUrlFromRequest(c) {
|
|
4589
4720
|
const url = new URL(c.req.url);
|
|
@@ -4670,7 +4801,7 @@ var OAuthCallbackQuerySchema = z$1.object({
|
|
|
4670
4801
|
error: z$1.string().optional(),
|
|
4671
4802
|
error_description: z$1.string().optional()
|
|
4672
4803
|
});
|
|
4673
|
-
|
|
4804
|
+
app20.openapi(
|
|
4674
4805
|
createRoute({
|
|
4675
4806
|
method: "get",
|
|
4676
4807
|
path: "/login",
|
|
@@ -4737,7 +4868,7 @@ app19.openapi(
|
|
|
4737
4868
|
}
|
|
4738
4869
|
}
|
|
4739
4870
|
);
|
|
4740
|
-
|
|
4871
|
+
app20.openapi(
|
|
4741
4872
|
createRoute({
|
|
4742
4873
|
method: "get",
|
|
4743
4874
|
path: "/callback",
|
|
@@ -4821,22 +4952,7 @@ app19.openapi(
|
|
|
4821
4952
|
);
|
|
4822
4953
|
const credentialTokenKey = `oauth_token_${toolId}`;
|
|
4823
4954
|
let newCredentialData;
|
|
4824
|
-
|
|
4825
|
-
if (keychainStore) {
|
|
4826
|
-
try {
|
|
4827
|
-
await keychainStore.set(credentialTokenKey, JSON.stringify(tokens));
|
|
4828
|
-
newCredentialData = {
|
|
4829
|
-
id: generateIdFromName(mcpTool.name),
|
|
4830
|
-
type: CredentialStoreType.keychain,
|
|
4831
|
-
credentialStoreId: "keychain-default",
|
|
4832
|
-
retrievalParams: {
|
|
4833
|
-
key: credentialTokenKey
|
|
4834
|
-
}
|
|
4835
|
-
};
|
|
4836
|
-
} catch {
|
|
4837
|
-
}
|
|
4838
|
-
}
|
|
4839
|
-
if (!newCredentialData && process.env.NANGO_SECRET_KEY) {
|
|
4955
|
+
if (process.env.NANGO_SECRET_KEY) {
|
|
4840
4956
|
const nangoStore = credentialStores.get("nango-default");
|
|
4841
4957
|
await nangoStore?.set(credentialTokenKey, JSON.stringify(tokens));
|
|
4842
4958
|
newCredentialData = {
|
|
@@ -4850,6 +4966,26 @@ app19.openapi(
|
|
|
4850
4966
|
authMode: "API_KEY"
|
|
4851
4967
|
}
|
|
4852
4968
|
};
|
|
4969
|
+
} else {
|
|
4970
|
+
const keychainStore = credentialStores.get("keychain-default");
|
|
4971
|
+
if (keychainStore) {
|
|
4972
|
+
try {
|
|
4973
|
+
await keychainStore.set(credentialTokenKey, JSON.stringify(tokens));
|
|
4974
|
+
newCredentialData = {
|
|
4975
|
+
id: generateIdFromName(mcpTool.name),
|
|
4976
|
+
type: CredentialStoreType.keychain,
|
|
4977
|
+
credentialStoreId: "keychain-default",
|
|
4978
|
+
retrievalParams: {
|
|
4979
|
+
key: credentialTokenKey
|
|
4980
|
+
}
|
|
4981
|
+
};
|
|
4982
|
+
} catch (error2) {
|
|
4983
|
+
logger7.info(
|
|
4984
|
+
{ error: error2 instanceof Error ? error2.message : error2 },
|
|
4985
|
+
"Keychain store not available."
|
|
4986
|
+
);
|
|
4987
|
+
}
|
|
4988
|
+
}
|
|
4853
4989
|
}
|
|
4854
4990
|
if (!newCredentialData) {
|
|
4855
4991
|
throw new Error("No credential store found");
|
|
@@ -4881,9 +5017,9 @@ app19.openapi(
|
|
|
4881
5017
|
}
|
|
4882
5018
|
}
|
|
4883
5019
|
);
|
|
4884
|
-
var oauth_default =
|
|
5020
|
+
var oauth_default = app20;
|
|
4885
5021
|
var logger8 = getLogger("projectFull");
|
|
4886
|
-
var
|
|
5022
|
+
var app21 = new OpenAPIHono();
|
|
4887
5023
|
var ProjectIdParamsSchema = z.object({
|
|
4888
5024
|
tenantId: z.string().openapi({
|
|
4889
5025
|
description: "Tenant identifier",
|
|
@@ -4900,7 +5036,7 @@ var TenantParamsSchema2 = z.object({
|
|
|
4900
5036
|
example: "tenant_123"
|
|
4901
5037
|
})
|
|
4902
5038
|
}).openapi("TenantParams");
|
|
4903
|
-
|
|
5039
|
+
app21.openapi(
|
|
4904
5040
|
createRoute({
|
|
4905
5041
|
method: "post",
|
|
4906
5042
|
path: "/project-full",
|
|
@@ -4959,7 +5095,7 @@ app20.openapi(
|
|
|
4959
5095
|
}
|
|
4960
5096
|
}
|
|
4961
5097
|
);
|
|
4962
|
-
|
|
5098
|
+
app21.openapi(
|
|
4963
5099
|
createRoute({
|
|
4964
5100
|
method: "get",
|
|
4965
5101
|
path: "/project-full/{projectId}",
|
|
@@ -5012,7 +5148,7 @@ app20.openapi(
|
|
|
5012
5148
|
}
|
|
5013
5149
|
}
|
|
5014
5150
|
);
|
|
5015
|
-
|
|
5151
|
+
app21.openapi(
|
|
5016
5152
|
createRoute({
|
|
5017
5153
|
method: "put",
|
|
5018
5154
|
path: "/project-full/{projectId}",
|
|
@@ -5096,7 +5232,7 @@ app20.openapi(
|
|
|
5096
5232
|
}
|
|
5097
5233
|
}
|
|
5098
5234
|
);
|
|
5099
|
-
|
|
5235
|
+
app21.openapi(
|
|
5100
5236
|
createRoute({
|
|
5101
5237
|
method: "delete",
|
|
5102
5238
|
path: "/project-full/{projectId}",
|
|
@@ -5144,20 +5280,20 @@ app20.openapi(
|
|
|
5144
5280
|
}
|
|
5145
5281
|
}
|
|
5146
5282
|
);
|
|
5147
|
-
var projectFull_default =
|
|
5283
|
+
var projectFull_default = app21;
|
|
5148
5284
|
|
|
5149
5285
|
// src/app.ts
|
|
5150
5286
|
var logger9 = getLogger("agents-manage-api");
|
|
5151
5287
|
logger9.info({ logger: logger9.getTransports() }, "Logger initialized");
|
|
5152
5288
|
function createManagementHono(serverConfig, credentialStores) {
|
|
5153
|
-
const
|
|
5154
|
-
|
|
5155
|
-
|
|
5289
|
+
const app23 = new OpenAPIHono();
|
|
5290
|
+
app23.use("*", requestId());
|
|
5291
|
+
app23.use("*", async (c, next) => {
|
|
5156
5292
|
c.set("serverConfig", serverConfig);
|
|
5157
5293
|
c.set("credentialStores", credentialStores);
|
|
5158
5294
|
return next();
|
|
5159
5295
|
});
|
|
5160
|
-
|
|
5296
|
+
app23.use(
|
|
5161
5297
|
pinoLogger({
|
|
5162
5298
|
pino: getLogger("agents-manage-api").getPinoInstance(),
|
|
5163
5299
|
http: {
|
|
@@ -5170,7 +5306,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5170
5306
|
}
|
|
5171
5307
|
})
|
|
5172
5308
|
);
|
|
5173
|
-
|
|
5309
|
+
app23.onError(async (err, c) => {
|
|
5174
5310
|
const isExpectedError = err instanceof HTTPException;
|
|
5175
5311
|
const status = isExpectedError ? err.status : 500;
|
|
5176
5312
|
const requestId2 = c.get("requestId") || "unknown";
|
|
@@ -5245,7 +5381,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5245
5381
|
...instance && { instance }
|
|
5246
5382
|
});
|
|
5247
5383
|
});
|
|
5248
|
-
|
|
5384
|
+
app23.use(
|
|
5249
5385
|
"*",
|
|
5250
5386
|
cors({
|
|
5251
5387
|
origin: (origin) => {
|
|
@@ -5259,7 +5395,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5259
5395
|
credentials: true
|
|
5260
5396
|
})
|
|
5261
5397
|
);
|
|
5262
|
-
|
|
5398
|
+
app23.openapi(
|
|
5263
5399
|
createRoute({
|
|
5264
5400
|
method: "get",
|
|
5265
5401
|
path: "/health",
|
|
@@ -5276,13 +5412,13 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5276
5412
|
return c.body(null, 204);
|
|
5277
5413
|
}
|
|
5278
5414
|
);
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
setupOpenAPIRoutes(
|
|
5415
|
+
app23.use("/tenants/*", apiKeyAuth());
|
|
5416
|
+
app23.route("/tenants/:tenantId", routes_default);
|
|
5417
|
+
app23.route("/tenants/:tenantId", projectFull_default);
|
|
5418
|
+
app23.route("/oauth", oauth_default);
|
|
5419
|
+
setupOpenAPIRoutes(app23);
|
|
5284
5420
|
const baseApp = new Hono();
|
|
5285
|
-
baseApp.route("/",
|
|
5421
|
+
baseApp.route("/", app23);
|
|
5286
5422
|
return baseApp;
|
|
5287
5423
|
}
|
|
5288
5424
|
|
|
@@ -5298,8 +5434,8 @@ var defaultConfig = {
|
|
|
5298
5434
|
};
|
|
5299
5435
|
var defaultStores = createDefaultCredentialStores();
|
|
5300
5436
|
var defaultRegistry = new CredentialStoreRegistry(defaultStores);
|
|
5301
|
-
var
|
|
5302
|
-
var index_default =
|
|
5437
|
+
var app22 = createManagementHono(defaultConfig, defaultRegistry);
|
|
5438
|
+
var index_default = app22;
|
|
5303
5439
|
function createManagementApp(config) {
|
|
5304
5440
|
const serverConfig = config?.serverConfig ?? defaultConfig;
|
|
5305
5441
|
const stores = config?.credentialStores ?? defaultStores;
|