@inkeep/agents-manage-api 0.0.0-dev-20251010175818 → 0.0.0-dev-20251010180500
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 +386 -133
- package/dist/index.js +387 -134
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -70,10 +70,10 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
|
|
|
70
70
|
await next();
|
|
71
71
|
return;
|
|
72
72
|
});
|
|
73
|
-
function setupOpenAPIRoutes(
|
|
74
|
-
|
|
73
|
+
function setupOpenAPIRoutes(app22) {
|
|
74
|
+
app22.get("/openapi.json", (c) => {
|
|
75
75
|
try {
|
|
76
|
-
const document =
|
|
76
|
+
const document = app22.getOpenAPIDocument({
|
|
77
77
|
openapi: "3.0.0",
|
|
78
78
|
info: {
|
|
79
79
|
title: "Inkeep Agents Manage API",
|
|
@@ -94,7 +94,7 @@ function setupOpenAPIRoutes(app21) {
|
|
|
94
94
|
return c.json({ error: "Failed to generate OpenAPI document", details: errorDetails }, 500);
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
|
-
|
|
97
|
+
app22.get(
|
|
98
98
|
"/docs",
|
|
99
99
|
swaggerUi.swaggerUI({
|
|
100
100
|
url: "/openapi.json",
|
|
@@ -2562,8 +2562,260 @@ app10.openapi(
|
|
|
2562
2562
|
}
|
|
2563
2563
|
);
|
|
2564
2564
|
var functions_default = app10;
|
|
2565
|
-
var logger3 = agentsCore.getLogger("
|
|
2565
|
+
var logger3 = agentsCore.getLogger("functionTools");
|
|
2566
2566
|
var app11 = new zodOpenapi.OpenAPIHono();
|
|
2567
|
+
app11.openapi(
|
|
2568
|
+
zodOpenapi.createRoute({
|
|
2569
|
+
method: "get",
|
|
2570
|
+
path: "/",
|
|
2571
|
+
summary: "List Function Tools",
|
|
2572
|
+
operationId: "list-function-tools",
|
|
2573
|
+
tags: ["Function Tools"],
|
|
2574
|
+
request: {
|
|
2575
|
+
params: agentsCore.TenantProjectGraphParamsSchema,
|
|
2576
|
+
query: agentsCore.PaginationQueryParamsSchema
|
|
2577
|
+
},
|
|
2578
|
+
responses: {
|
|
2579
|
+
200: {
|
|
2580
|
+
description: "List of function tools retrieved successfully",
|
|
2581
|
+
content: {
|
|
2582
|
+
"application/json": {
|
|
2583
|
+
schema: agentsCore.ListResponseSchema(agentsCore.FunctionToolApiSelectSchema)
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
},
|
|
2587
|
+
...agentsCore.commonGetErrorResponses
|
|
2588
|
+
}
|
|
2589
|
+
}),
|
|
2590
|
+
async (c) => {
|
|
2591
|
+
const { tenantId, projectId, graphId } = c.req.valid("param");
|
|
2592
|
+
const { page, limit } = c.req.valid("query");
|
|
2593
|
+
try {
|
|
2594
|
+
const result = await agentsCore.listFunctionTools(dbClient_default)({
|
|
2595
|
+
scopes: { tenantId, projectId, graphId },
|
|
2596
|
+
pagination: { page, limit }
|
|
2597
|
+
});
|
|
2598
|
+
return c.json(result);
|
|
2599
|
+
} catch (error) {
|
|
2600
|
+
logger3.error({ error, tenantId, projectId, graphId }, "Failed to list function tools");
|
|
2601
|
+
return c.json(
|
|
2602
|
+
agentsCore.createApiError({ code: "internal_server_error", message: "Failed to list function tools" }),
|
|
2603
|
+
500
|
|
2604
|
+
);
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
);
|
|
2608
|
+
app11.openapi(
|
|
2609
|
+
zodOpenapi.createRoute({
|
|
2610
|
+
method: "get",
|
|
2611
|
+
path: "/:id",
|
|
2612
|
+
summary: "Get Function Tool by ID",
|
|
2613
|
+
operationId: "get-function-tool",
|
|
2614
|
+
tags: ["Function Tools"],
|
|
2615
|
+
request: {
|
|
2616
|
+
params: agentsCore.TenantProjectGraphParamsSchema.extend({
|
|
2617
|
+
id: zod.z.string()
|
|
2618
|
+
})
|
|
2619
|
+
},
|
|
2620
|
+
responses: {
|
|
2621
|
+
200: {
|
|
2622
|
+
description: "Function tool retrieved successfully",
|
|
2623
|
+
content: {
|
|
2624
|
+
"application/json": {
|
|
2625
|
+
schema: agentsCore.SingleResponseSchema(agentsCore.FunctionToolApiSelectSchema)
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
},
|
|
2629
|
+
...agentsCore.commonGetErrorResponses
|
|
2630
|
+
}
|
|
2631
|
+
}),
|
|
2632
|
+
async (c) => {
|
|
2633
|
+
const { tenantId, projectId, graphId, id } = c.req.valid("param");
|
|
2634
|
+
try {
|
|
2635
|
+
const functionTool = await agentsCore.getFunctionToolById(dbClient_default)({
|
|
2636
|
+
scopes: { tenantId, projectId, graphId },
|
|
2637
|
+
functionToolId: id
|
|
2638
|
+
});
|
|
2639
|
+
if (!functionTool) {
|
|
2640
|
+
return c.json(
|
|
2641
|
+
agentsCore.createApiError({ code: "not_found", message: "Function tool not found" }),
|
|
2642
|
+
404
|
|
2643
|
+
);
|
|
2644
|
+
}
|
|
2645
|
+
return c.json({ data: functionTool });
|
|
2646
|
+
} catch (error) {
|
|
2647
|
+
logger3.error({ error, tenantId, projectId, graphId, id }, "Failed to get function tool");
|
|
2648
|
+
return c.json(
|
|
2649
|
+
agentsCore.createApiError({ code: "internal_server_error", message: "Failed to get function tool" }),
|
|
2650
|
+
500
|
|
2651
|
+
);
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
);
|
|
2655
|
+
app11.openapi(
|
|
2656
|
+
zodOpenapi.createRoute({
|
|
2657
|
+
method: "post",
|
|
2658
|
+
path: "/",
|
|
2659
|
+
summary: "Create Function Tool",
|
|
2660
|
+
operationId: "create-function-tool",
|
|
2661
|
+
tags: ["Function Tools"],
|
|
2662
|
+
request: {
|
|
2663
|
+
params: agentsCore.TenantProjectGraphParamsSchema,
|
|
2664
|
+
body: {
|
|
2665
|
+
content: {
|
|
2666
|
+
"application/json": {
|
|
2667
|
+
schema: agentsCore.FunctionToolApiInsertSchema
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
},
|
|
2672
|
+
responses: {
|
|
2673
|
+
201: {
|
|
2674
|
+
description: "Function tool created successfully",
|
|
2675
|
+
content: {
|
|
2676
|
+
"application/json": {
|
|
2677
|
+
schema: agentsCore.SingleResponseSchema(agentsCore.FunctionToolApiSelectSchema)
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
},
|
|
2681
|
+
...agentsCore.commonGetErrorResponses
|
|
2682
|
+
}
|
|
2683
|
+
}),
|
|
2684
|
+
async (c) => {
|
|
2685
|
+
const { tenantId, projectId, graphId } = c.req.valid("param");
|
|
2686
|
+
const body = c.req.valid("json");
|
|
2687
|
+
try {
|
|
2688
|
+
const id = body.id || nanoid.nanoid();
|
|
2689
|
+
const functionTool = await agentsCore.createFunctionTool(dbClient_default)({
|
|
2690
|
+
scopes: { tenantId, projectId, graphId },
|
|
2691
|
+
data: {
|
|
2692
|
+
...body,
|
|
2693
|
+
id
|
|
2694
|
+
}
|
|
2695
|
+
});
|
|
2696
|
+
return c.json({ data: functionTool }, 201);
|
|
2697
|
+
} catch (error) {
|
|
2698
|
+
logger3.error({ error, tenantId, projectId, graphId, body }, "Failed to create function tool");
|
|
2699
|
+
return c.json(
|
|
2700
|
+
agentsCore.createApiError({
|
|
2701
|
+
code: "internal_server_error",
|
|
2702
|
+
message: "Failed to create function tool"
|
|
2703
|
+
}),
|
|
2704
|
+
500
|
|
2705
|
+
);
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
);
|
|
2709
|
+
app11.openapi(
|
|
2710
|
+
zodOpenapi.createRoute({
|
|
2711
|
+
method: "put",
|
|
2712
|
+
path: "/:id",
|
|
2713
|
+
summary: "Update Function Tool",
|
|
2714
|
+
operationId: "update-function-tool",
|
|
2715
|
+
tags: ["Function Tools"],
|
|
2716
|
+
request: {
|
|
2717
|
+
params: agentsCore.TenantProjectGraphParamsSchema.extend({
|
|
2718
|
+
id: zod.z.string()
|
|
2719
|
+
}),
|
|
2720
|
+
body: {
|
|
2721
|
+
content: {
|
|
2722
|
+
"application/json": {
|
|
2723
|
+
schema: agentsCore.FunctionToolApiUpdateSchema
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
},
|
|
2728
|
+
responses: {
|
|
2729
|
+
200: {
|
|
2730
|
+
description: "Function tool updated successfully",
|
|
2731
|
+
content: {
|
|
2732
|
+
"application/json": {
|
|
2733
|
+
schema: agentsCore.SingleResponseSchema(agentsCore.FunctionToolApiSelectSchema)
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
},
|
|
2737
|
+
...agentsCore.commonGetErrorResponses
|
|
2738
|
+
}
|
|
2739
|
+
}),
|
|
2740
|
+
async (c) => {
|
|
2741
|
+
const { tenantId, projectId, graphId, id } = c.req.valid("param");
|
|
2742
|
+
const body = c.req.valid("json");
|
|
2743
|
+
try {
|
|
2744
|
+
const functionTool = await agentsCore.updateFunctionTool(dbClient_default)({
|
|
2745
|
+
scopes: { tenantId, projectId, graphId },
|
|
2746
|
+
functionToolId: id,
|
|
2747
|
+
data: body
|
|
2748
|
+
});
|
|
2749
|
+
if (!functionTool) {
|
|
2750
|
+
return c.json(
|
|
2751
|
+
agentsCore.createApiError({ code: "not_found", message: "Function tool not found" }),
|
|
2752
|
+
404
|
|
2753
|
+
);
|
|
2754
|
+
}
|
|
2755
|
+
return c.json({ data: functionTool });
|
|
2756
|
+
} catch (error) {
|
|
2757
|
+
logger3.error(
|
|
2758
|
+
{ error, tenantId, projectId, graphId, id, body },
|
|
2759
|
+
"Failed to update function tool"
|
|
2760
|
+
);
|
|
2761
|
+
return c.json(
|
|
2762
|
+
agentsCore.createApiError({
|
|
2763
|
+
code: "internal_server_error",
|
|
2764
|
+
message: "Failed to update function tool"
|
|
2765
|
+
}),
|
|
2766
|
+
500
|
|
2767
|
+
);
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
);
|
|
2771
|
+
app11.openapi(
|
|
2772
|
+
zodOpenapi.createRoute({
|
|
2773
|
+
method: "delete",
|
|
2774
|
+
path: "/:id",
|
|
2775
|
+
summary: "Delete Function Tool",
|
|
2776
|
+
operationId: "delete-function-tool",
|
|
2777
|
+
tags: ["Function Tools"],
|
|
2778
|
+
request: {
|
|
2779
|
+
params: agentsCore.TenantProjectGraphParamsSchema.extend({
|
|
2780
|
+
id: zod.z.string()
|
|
2781
|
+
})
|
|
2782
|
+
},
|
|
2783
|
+
responses: {
|
|
2784
|
+
204: {
|
|
2785
|
+
description: "Function tool deleted successfully"
|
|
2786
|
+
},
|
|
2787
|
+
...agentsCore.commonGetErrorResponses
|
|
2788
|
+
}
|
|
2789
|
+
}),
|
|
2790
|
+
async (c) => {
|
|
2791
|
+
const { tenantId, projectId, graphId, id } = c.req.valid("param");
|
|
2792
|
+
try {
|
|
2793
|
+
const deleted = await agentsCore.deleteFunctionTool(dbClient_default)({
|
|
2794
|
+
scopes: { tenantId, projectId, graphId },
|
|
2795
|
+
functionToolId: id
|
|
2796
|
+
});
|
|
2797
|
+
if (!deleted) {
|
|
2798
|
+
return c.json(
|
|
2799
|
+
agentsCore.createApiError({ code: "not_found", message: "Function tool not found" }),
|
|
2800
|
+
404
|
|
2801
|
+
);
|
|
2802
|
+
}
|
|
2803
|
+
return c.body(null, 204);
|
|
2804
|
+
} catch (error) {
|
|
2805
|
+
logger3.error({ error, tenantId, projectId, graphId, id }, "Failed to delete function tool");
|
|
2806
|
+
return c.json(
|
|
2807
|
+
agentsCore.createApiError({
|
|
2808
|
+
code: "internal_server_error",
|
|
2809
|
+
message: "Failed to delete function tool"
|
|
2810
|
+
}),
|
|
2811
|
+
500
|
|
2812
|
+
);
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
);
|
|
2816
|
+
var functionTools_default = app11;
|
|
2817
|
+
var logger4 = agentsCore.getLogger("graphFull");
|
|
2818
|
+
var app12 = new zodOpenapi.OpenAPIHono();
|
|
2567
2819
|
var GraphIdParamsSchema = zod.z.object({
|
|
2568
2820
|
tenantId: zod.z.string().openapi({
|
|
2569
2821
|
description: "Tenant identifier",
|
|
@@ -2578,7 +2830,7 @@ var GraphIdParamsSchema = zod.z.object({
|
|
|
2578
2830
|
example: "graph_789"
|
|
2579
2831
|
})
|
|
2580
2832
|
}).openapi("GraphIdParams");
|
|
2581
|
-
|
|
2833
|
+
app12.openapi(
|
|
2582
2834
|
zodOpenapi.createRoute({
|
|
2583
2835
|
method: "post",
|
|
2584
2836
|
path: "/",
|
|
@@ -2620,14 +2872,14 @@ app11.openapi(
|
|
|
2620
2872
|
const { tenantId, projectId } = c.req.valid("param");
|
|
2621
2873
|
const graphData = c.req.valid("json");
|
|
2622
2874
|
const validatedGraphData = agentsCore.GraphWithinContextOfProjectSchema.parse(graphData);
|
|
2623
|
-
const createdGraph = await agentsCore.createFullGraphServerSide(dbClient_default,
|
|
2875
|
+
const createdGraph = await agentsCore.createFullGraphServerSide(dbClient_default, logger4)(
|
|
2624
2876
|
{ tenantId, projectId },
|
|
2625
2877
|
validatedGraphData
|
|
2626
2878
|
);
|
|
2627
2879
|
return c.json({ data: createdGraph }, 201);
|
|
2628
2880
|
}
|
|
2629
2881
|
);
|
|
2630
|
-
|
|
2882
|
+
app12.openapi(
|
|
2631
2883
|
zodOpenapi.createRoute({
|
|
2632
2884
|
method: "get",
|
|
2633
2885
|
path: "/{graphId}",
|
|
@@ -2655,7 +2907,7 @@ app11.openapi(
|
|
|
2655
2907
|
try {
|
|
2656
2908
|
const graph = await agentsCore.getFullGraph(
|
|
2657
2909
|
dbClient_default,
|
|
2658
|
-
|
|
2910
|
+
logger4
|
|
2659
2911
|
)({
|
|
2660
2912
|
scopes: { tenantId, projectId, graphId }
|
|
2661
2913
|
});
|
|
@@ -2680,7 +2932,7 @@ app11.openapi(
|
|
|
2680
2932
|
}
|
|
2681
2933
|
}
|
|
2682
2934
|
);
|
|
2683
|
-
|
|
2935
|
+
app12.openapi(
|
|
2684
2936
|
zodOpenapi.createRoute({
|
|
2685
2937
|
method: "put",
|
|
2686
2938
|
path: "/{graphId}",
|
|
@@ -2731,15 +2983,15 @@ app11.openapi(
|
|
|
2731
2983
|
}
|
|
2732
2984
|
const existingGraph = await agentsCore.getFullGraph(
|
|
2733
2985
|
dbClient_default,
|
|
2734
|
-
|
|
2986
|
+
logger4
|
|
2735
2987
|
)({
|
|
2736
2988
|
scopes: { tenantId, projectId, graphId }
|
|
2737
2989
|
});
|
|
2738
2990
|
const isCreate = !existingGraph;
|
|
2739
|
-
const updatedGraph = isCreate ? await agentsCore.createFullGraphServerSide(dbClient_default,
|
|
2991
|
+
const updatedGraph = isCreate ? await agentsCore.createFullGraphServerSide(dbClient_default, logger4)(
|
|
2740
2992
|
{ tenantId, projectId },
|
|
2741
2993
|
validatedGraphData
|
|
2742
|
-
) : await agentsCore.updateFullGraphServerSide(dbClient_default,
|
|
2994
|
+
) : await agentsCore.updateFullGraphServerSide(dbClient_default, logger4)(
|
|
2743
2995
|
{ tenantId, projectId },
|
|
2744
2996
|
validatedGraphData
|
|
2745
2997
|
);
|
|
@@ -2764,7 +3016,7 @@ app11.openapi(
|
|
|
2764
3016
|
}
|
|
2765
3017
|
}
|
|
2766
3018
|
);
|
|
2767
|
-
|
|
3019
|
+
app12.openapi(
|
|
2768
3020
|
zodOpenapi.createRoute({
|
|
2769
3021
|
method: "delete",
|
|
2770
3022
|
path: "/{graphId}",
|
|
@@ -2787,7 +3039,7 @@ app11.openapi(
|
|
|
2787
3039
|
try {
|
|
2788
3040
|
const deleted = await agentsCore.deleteFullGraph(
|
|
2789
3041
|
dbClient_default,
|
|
2790
|
-
|
|
3042
|
+
logger4
|
|
2791
3043
|
)({
|
|
2792
3044
|
scopes: { tenantId, projectId, graphId }
|
|
2793
3045
|
});
|
|
@@ -2812,9 +3064,9 @@ app11.openapi(
|
|
|
2812
3064
|
}
|
|
2813
3065
|
}
|
|
2814
3066
|
);
|
|
2815
|
-
var graphFull_default =
|
|
2816
|
-
var
|
|
2817
|
-
|
|
3067
|
+
var graphFull_default = app12;
|
|
3068
|
+
var app13 = new zodOpenapi.OpenAPIHono();
|
|
3069
|
+
app13.openapi(
|
|
2818
3070
|
zodOpenapi.createRoute({
|
|
2819
3071
|
method: "get",
|
|
2820
3072
|
path: "/",
|
|
@@ -2849,7 +3101,7 @@ app12.openapi(
|
|
|
2849
3101
|
return c.json(result);
|
|
2850
3102
|
}
|
|
2851
3103
|
);
|
|
2852
|
-
|
|
3104
|
+
app13.openapi(
|
|
2853
3105
|
zodOpenapi.createRoute({
|
|
2854
3106
|
method: "get",
|
|
2855
3107
|
path: "/{id}",
|
|
@@ -2884,7 +3136,7 @@ app12.openapi(
|
|
|
2884
3136
|
return c.json({ data: project });
|
|
2885
3137
|
}
|
|
2886
3138
|
);
|
|
2887
|
-
|
|
3139
|
+
app13.openapi(
|
|
2888
3140
|
zodOpenapi.createRoute({
|
|
2889
3141
|
method: "post",
|
|
2890
3142
|
path: "/",
|
|
@@ -2942,7 +3194,7 @@ app12.openapi(
|
|
|
2942
3194
|
}
|
|
2943
3195
|
}
|
|
2944
3196
|
);
|
|
2945
|
-
|
|
3197
|
+
app13.openapi(
|
|
2946
3198
|
zodOpenapi.createRoute({
|
|
2947
3199
|
method: "patch",
|
|
2948
3200
|
path: "/{id}",
|
|
@@ -2988,7 +3240,7 @@ app12.openapi(
|
|
|
2988
3240
|
return c.json({ data: project });
|
|
2989
3241
|
}
|
|
2990
3242
|
);
|
|
2991
|
-
|
|
3243
|
+
app13.openapi(
|
|
2992
3244
|
zodOpenapi.createRoute({
|
|
2993
3245
|
method: "delete",
|
|
2994
3246
|
path: "/{id}",
|
|
@@ -3038,9 +3290,9 @@ app12.openapi(
|
|
|
3038
3290
|
}
|
|
3039
3291
|
}
|
|
3040
3292
|
);
|
|
3041
|
-
var projects_default =
|
|
3042
|
-
var
|
|
3043
|
-
|
|
3293
|
+
var projects_default = app13;
|
|
3294
|
+
var app14 = new zodOpenapi.OpenAPIHono();
|
|
3295
|
+
app14.openapi(
|
|
3044
3296
|
zodOpenapi.createRoute({
|
|
3045
3297
|
method: "get",
|
|
3046
3298
|
path: "/agent/:subAgentId",
|
|
@@ -3076,7 +3328,7 @@ app13.openapi(
|
|
|
3076
3328
|
});
|
|
3077
3329
|
}
|
|
3078
3330
|
);
|
|
3079
|
-
|
|
3331
|
+
app14.openapi(
|
|
3080
3332
|
zodOpenapi.createRoute({
|
|
3081
3333
|
method: "get",
|
|
3082
3334
|
path: "/component/:artifactComponentId/agents",
|
|
@@ -3116,7 +3368,7 @@ app13.openapi(
|
|
|
3116
3368
|
return c.json({ data: agents });
|
|
3117
3369
|
}
|
|
3118
3370
|
);
|
|
3119
|
-
|
|
3371
|
+
app14.openapi(
|
|
3120
3372
|
zodOpenapi.createRoute({
|
|
3121
3373
|
method: "post",
|
|
3122
3374
|
path: "/",
|
|
@@ -3193,7 +3445,7 @@ app13.openapi(
|
|
|
3193
3445
|
return c.json({ data: association }, 201);
|
|
3194
3446
|
}
|
|
3195
3447
|
);
|
|
3196
|
-
|
|
3448
|
+
app14.openapi(
|
|
3197
3449
|
zodOpenapi.createRoute({
|
|
3198
3450
|
method: "delete",
|
|
3199
3451
|
path: "/agent/:subAgentId/component/:artifactComponentId",
|
|
@@ -3236,7 +3488,7 @@ app13.openapi(
|
|
|
3236
3488
|
});
|
|
3237
3489
|
}
|
|
3238
3490
|
);
|
|
3239
|
-
|
|
3491
|
+
app14.openapi(
|
|
3240
3492
|
zodOpenapi.createRoute({
|
|
3241
3493
|
method: "get",
|
|
3242
3494
|
path: "/agent/:subAgentId/component/:artifactComponentId/exists",
|
|
@@ -3270,9 +3522,9 @@ app13.openapi(
|
|
|
3270
3522
|
return c.json({ exists });
|
|
3271
3523
|
}
|
|
3272
3524
|
);
|
|
3273
|
-
var subAgentArtifactComponents_default =
|
|
3274
|
-
var
|
|
3275
|
-
|
|
3525
|
+
var subAgentArtifactComponents_default = app14;
|
|
3526
|
+
var app15 = new zodOpenapi.OpenAPIHono();
|
|
3527
|
+
app15.openapi(
|
|
3276
3528
|
zodOpenapi.createRoute({
|
|
3277
3529
|
method: "get",
|
|
3278
3530
|
path: "/agent/:subAgentId",
|
|
@@ -3306,7 +3558,7 @@ app14.openapi(
|
|
|
3306
3558
|
return c.json({ data: dataComponents });
|
|
3307
3559
|
}
|
|
3308
3560
|
);
|
|
3309
|
-
|
|
3561
|
+
app15.openapi(
|
|
3310
3562
|
zodOpenapi.createRoute({
|
|
3311
3563
|
method: "get",
|
|
3312
3564
|
path: "/component/:dataComponentId/agents",
|
|
@@ -3346,7 +3598,7 @@ app14.openapi(
|
|
|
3346
3598
|
return c.json({ data: agents });
|
|
3347
3599
|
}
|
|
3348
3600
|
);
|
|
3349
|
-
|
|
3601
|
+
app15.openapi(
|
|
3350
3602
|
zodOpenapi.createRoute({
|
|
3351
3603
|
method: "post",
|
|
3352
3604
|
path: "/",
|
|
@@ -3419,7 +3671,7 @@ app14.openapi(
|
|
|
3419
3671
|
return c.json({ data: association }, 201);
|
|
3420
3672
|
}
|
|
3421
3673
|
);
|
|
3422
|
-
|
|
3674
|
+
app15.openapi(
|
|
3423
3675
|
zodOpenapi.createRoute({
|
|
3424
3676
|
method: "delete",
|
|
3425
3677
|
path: "/agent/:subAgentId/component/:dataComponentId",
|
|
@@ -3462,7 +3714,7 @@ app14.openapi(
|
|
|
3462
3714
|
});
|
|
3463
3715
|
}
|
|
3464
3716
|
);
|
|
3465
|
-
|
|
3717
|
+
app15.openapi(
|
|
3466
3718
|
zodOpenapi.createRoute({
|
|
3467
3719
|
method: "get",
|
|
3468
3720
|
path: "/agent/:subAgentId/component/:dataComponentId/exists",
|
|
@@ -3496,9 +3748,9 @@ app14.openapi(
|
|
|
3496
3748
|
return c.json({ exists });
|
|
3497
3749
|
}
|
|
3498
3750
|
);
|
|
3499
|
-
var subAgentDataComponents_default =
|
|
3500
|
-
var
|
|
3501
|
-
|
|
3751
|
+
var subAgentDataComponents_default = app15;
|
|
3752
|
+
var app16 = new zodOpenapi.OpenAPIHono();
|
|
3753
|
+
app16.openapi(
|
|
3502
3754
|
zodOpenapi.createRoute({
|
|
3503
3755
|
method: "get",
|
|
3504
3756
|
path: "/",
|
|
@@ -3571,7 +3823,7 @@ app15.openapi(
|
|
|
3571
3823
|
}
|
|
3572
3824
|
}
|
|
3573
3825
|
);
|
|
3574
|
-
|
|
3826
|
+
app16.openapi(
|
|
3575
3827
|
zodOpenapi.createRoute({
|
|
3576
3828
|
method: "get",
|
|
3577
3829
|
path: "/{id}",
|
|
@@ -3608,7 +3860,7 @@ app15.openapi(
|
|
|
3608
3860
|
return c.json({ data: agentRelation });
|
|
3609
3861
|
}
|
|
3610
3862
|
);
|
|
3611
|
-
|
|
3863
|
+
app16.openapi(
|
|
3612
3864
|
zodOpenapi.createRoute({
|
|
3613
3865
|
method: "post",
|
|
3614
3866
|
path: "/",
|
|
@@ -3699,7 +3951,7 @@ app15.openapi(
|
|
|
3699
3951
|
return c.json({ data: agentRelation }, 201);
|
|
3700
3952
|
}
|
|
3701
3953
|
);
|
|
3702
|
-
|
|
3954
|
+
app16.openapi(
|
|
3703
3955
|
zodOpenapi.createRoute({
|
|
3704
3956
|
method: "put",
|
|
3705
3957
|
path: "/{id}",
|
|
@@ -3745,7 +3997,7 @@ app15.openapi(
|
|
|
3745
3997
|
return c.json({ data: updatedAgentRelation });
|
|
3746
3998
|
}
|
|
3747
3999
|
);
|
|
3748
|
-
|
|
4000
|
+
app16.openapi(
|
|
3749
4001
|
zodOpenapi.createRoute({
|
|
3750
4002
|
method: "delete",
|
|
3751
4003
|
path: "/{id}",
|
|
@@ -3784,10 +4036,10 @@ app15.openapi(
|
|
|
3784
4036
|
return c.body(null, 204);
|
|
3785
4037
|
}
|
|
3786
4038
|
);
|
|
3787
|
-
var subAgentRelations_default =
|
|
3788
|
-
var
|
|
3789
|
-
var
|
|
3790
|
-
|
|
4039
|
+
var subAgentRelations_default = app16;
|
|
4040
|
+
var logger5 = agentsCore.getLogger("tools");
|
|
4041
|
+
var app17 = new zodOpenapi.OpenAPIHono();
|
|
4042
|
+
app17.openapi(
|
|
3791
4043
|
zodOpenapi.createRoute({
|
|
3792
4044
|
method: "get",
|
|
3793
4045
|
path: "/",
|
|
@@ -3847,7 +4099,7 @@ app16.openapi(
|
|
|
3847
4099
|
return c.json(result);
|
|
3848
4100
|
}
|
|
3849
4101
|
);
|
|
3850
|
-
|
|
4102
|
+
app17.openapi(
|
|
3851
4103
|
zodOpenapi.createRoute({
|
|
3852
4104
|
method: "get",
|
|
3853
4105
|
path: "/{id}",
|
|
@@ -3884,7 +4136,7 @@ app16.openapi(
|
|
|
3884
4136
|
});
|
|
3885
4137
|
}
|
|
3886
4138
|
);
|
|
3887
|
-
|
|
4139
|
+
app17.openapi(
|
|
3888
4140
|
zodOpenapi.createRoute({
|
|
3889
4141
|
method: "post",
|
|
3890
4142
|
path: "/",
|
|
@@ -3917,7 +4169,7 @@ app16.openapi(
|
|
|
3917
4169
|
const { tenantId, projectId } = c.req.valid("param");
|
|
3918
4170
|
const body = c.req.valid("json");
|
|
3919
4171
|
const credentialStores = c.get("credentialStores");
|
|
3920
|
-
|
|
4172
|
+
logger5.info({ body }, "body");
|
|
3921
4173
|
const id = body.id || nanoid.nanoid();
|
|
3922
4174
|
const tool = await agentsCore.createTool(dbClient_default)({
|
|
3923
4175
|
tenantId,
|
|
@@ -3937,7 +4189,7 @@ app16.openapi(
|
|
|
3937
4189
|
);
|
|
3938
4190
|
}
|
|
3939
4191
|
);
|
|
3940
|
-
|
|
4192
|
+
app17.openapi(
|
|
3941
4193
|
zodOpenapi.createRoute({
|
|
3942
4194
|
method: "put",
|
|
3943
4195
|
path: "/{id}",
|
|
@@ -3998,7 +4250,7 @@ app16.openapi(
|
|
|
3998
4250
|
});
|
|
3999
4251
|
}
|
|
4000
4252
|
);
|
|
4001
|
-
|
|
4253
|
+
app17.openapi(
|
|
4002
4254
|
zodOpenapi.createRoute({
|
|
4003
4255
|
method: "delete",
|
|
4004
4256
|
path: "/{id}",
|
|
@@ -4034,34 +4286,35 @@ app16.openapi(
|
|
|
4034
4286
|
return c.body(null, 204);
|
|
4035
4287
|
}
|
|
4036
4288
|
);
|
|
4037
|
-
var tools_default =
|
|
4289
|
+
var tools_default = app17;
|
|
4038
4290
|
|
|
4039
4291
|
// src/routes/index.ts
|
|
4040
|
-
var
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4292
|
+
var app18 = new zodOpenapi.OpenAPIHono();
|
|
4293
|
+
app18.route("/projects", projects_default);
|
|
4294
|
+
app18.route("/projects/:projectId/graphs/:graphId/sub-agents", subAgents_default);
|
|
4295
|
+
app18.route("/projects/:projectId/graphs/:graphId/sub-agent-relations", subAgentRelations_default);
|
|
4296
|
+
app18.route("/projects/:projectId/agent-graphs", agentGraph_default);
|
|
4297
|
+
app18.route("/projects/:projectId/graphs/:graphId/sub-agent-tool-relations", subAgentToolRelations_default);
|
|
4298
|
+
app18.route(
|
|
4047
4299
|
"/projects/:projectId/graphs/:graphId/sub-agent-artifact-components",
|
|
4048
4300
|
subAgentArtifactComponents_default
|
|
4049
4301
|
);
|
|
4050
|
-
|
|
4302
|
+
app18.route(
|
|
4051
4303
|
"/projects/:projectId/graphs/:graphId/sub-agent-data-components",
|
|
4052
4304
|
subAgentDataComponents_default
|
|
4053
4305
|
);
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
var
|
|
4306
|
+
app18.route("/projects/:projectId/artifact-components", artifactComponents_default);
|
|
4307
|
+
app18.route("/projects/:projectId/graphs/:graphId/context-configs", contextConfigs_default);
|
|
4308
|
+
app18.route("/projects/:projectId/credentials", credentials_default);
|
|
4309
|
+
app18.route("/projects/:projectId/data-components", dataComponents_default);
|
|
4310
|
+
app18.route("/projects/:projectId/graphs/:graphId/external-agents", externalAgents_default);
|
|
4311
|
+
app18.route("/projects/:projectId/graphs/:graphId/function-tools", functionTools_default);
|
|
4312
|
+
app18.route("/projects/:projectId/functions", functions_default);
|
|
4313
|
+
app18.route("/projects/:projectId/tools", tools_default);
|
|
4314
|
+
app18.route("/projects/:projectId/api-keys", apiKeys_default);
|
|
4315
|
+
app18.route("/projects/:projectId/graph", graphFull_default);
|
|
4316
|
+
var routes_default = app18;
|
|
4317
|
+
var logger6 = agentsCore.getLogger("oauth-service");
|
|
4065
4318
|
var pkceStore = /* @__PURE__ */ new Map();
|
|
4066
4319
|
function storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId) {
|
|
4067
4320
|
pkceStore.set(state, { codeVerifier, toolId, tenantId, projectId, clientId });
|
|
@@ -4099,7 +4352,7 @@ var OAuthService = class {
|
|
|
4099
4352
|
if (tool.config.type !== "mcp") {
|
|
4100
4353
|
throw new Error("OAuth is only supported for MCP tools");
|
|
4101
4354
|
}
|
|
4102
|
-
const oAuthConfig = await agentsCore.discoverOAuthEndpoints(tool.config.mcp.server.url,
|
|
4355
|
+
const oAuthConfig = await agentsCore.discoverOAuthEndpoints(tool.config.mcp.server.url, logger6);
|
|
4103
4356
|
if (!oAuthConfig) {
|
|
4104
4357
|
throw new Error("OAuth not supported by this server");
|
|
4105
4358
|
}
|
|
@@ -4123,7 +4376,7 @@ var OAuthService = class {
|
|
|
4123
4376
|
resource: tool.config.mcp.server.url
|
|
4124
4377
|
});
|
|
4125
4378
|
storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId);
|
|
4126
|
-
|
|
4379
|
+
logger6.info({ toolId, oAuthConfig, tenantId, projectId }, "OAuth flow initiated successfully");
|
|
4127
4380
|
return {
|
|
4128
4381
|
redirectUrl: authUrl,
|
|
4129
4382
|
state
|
|
@@ -4137,7 +4390,7 @@ var OAuthService = class {
|
|
|
4137
4390
|
if (tool.config.type !== "mcp") {
|
|
4138
4391
|
throw new Error("OAuth is only supported for MCP tools");
|
|
4139
4392
|
}
|
|
4140
|
-
const oAuthConfig = await agentsCore.discoverOAuthEndpoints(tool.config.mcp.server.url,
|
|
4393
|
+
const oAuthConfig = await agentsCore.discoverOAuthEndpoints(tool.config.mcp.server.url, logger6);
|
|
4141
4394
|
if (!oAuthConfig?.tokenUrl) {
|
|
4142
4395
|
throw new Error("Could not discover OAuth token endpoint");
|
|
4143
4396
|
}
|
|
@@ -4152,9 +4405,9 @@ var OAuthService = class {
|
|
|
4152
4405
|
codeVerifier,
|
|
4153
4406
|
redirectUri
|
|
4154
4407
|
});
|
|
4155
|
-
|
|
4408
|
+
logger6.info({ tokenType: tokens.token_type }, "Token exchange successful with openid-client");
|
|
4156
4409
|
} catch (error) {
|
|
4157
|
-
|
|
4410
|
+
logger6.warn(
|
|
4158
4411
|
{ error: error instanceof Error ? error.message : error },
|
|
4159
4412
|
"openid-client failed, falling back to manual token exchange"
|
|
4160
4413
|
);
|
|
@@ -4165,7 +4418,7 @@ var OAuthService = class {
|
|
|
4165
4418
|
codeVerifier,
|
|
4166
4419
|
redirectUri
|
|
4167
4420
|
});
|
|
4168
|
-
|
|
4421
|
+
logger6.info({ tokenType: tokens.token_type }, "Manual token exchange successful");
|
|
4169
4422
|
}
|
|
4170
4423
|
return { tokens, oAuthConfig };
|
|
4171
4424
|
}
|
|
@@ -4173,7 +4426,7 @@ var OAuthService = class {
|
|
|
4173
4426
|
* Perform dynamic client registration
|
|
4174
4427
|
*/
|
|
4175
4428
|
async performDynamicClientRegistration(registrationUrl, redirectUri) {
|
|
4176
|
-
|
|
4429
|
+
logger6.info({ registrationUrl }, "Attempting dynamic client registration");
|
|
4177
4430
|
try {
|
|
4178
4431
|
const registrationResponse = await fetch(registrationUrl, {
|
|
4179
4432
|
method: "POST",
|
|
@@ -4196,11 +4449,11 @@ var OAuthService = class {
|
|
|
4196
4449
|
});
|
|
4197
4450
|
if (registrationResponse.ok) {
|
|
4198
4451
|
const registration = await registrationResponse.json();
|
|
4199
|
-
|
|
4452
|
+
logger6.info({ clientId: registration.client_id }, "Dynamic client registration successful");
|
|
4200
4453
|
return registration.client_id;
|
|
4201
4454
|
} else {
|
|
4202
4455
|
const errorText = await registrationResponse.text();
|
|
4203
|
-
|
|
4456
|
+
logger6.warn(
|
|
4204
4457
|
{
|
|
4205
4458
|
status: registrationResponse.status,
|
|
4206
4459
|
errorText
|
|
@@ -4209,7 +4462,7 @@ var OAuthService = class {
|
|
|
4209
4462
|
);
|
|
4210
4463
|
}
|
|
4211
4464
|
} catch (regError) {
|
|
4212
|
-
|
|
4465
|
+
logger6.warn(
|
|
4213
4466
|
{ error: regError },
|
|
4214
4467
|
"Dynamic client registration error, using default client_id"
|
|
4215
4468
|
);
|
|
@@ -4239,7 +4492,7 @@ var OAuthService = class {
|
|
|
4239
4492
|
const oauth = await import('openid-client');
|
|
4240
4493
|
const tokenUrl = new URL(oAuthConfig.tokenUrl);
|
|
4241
4494
|
const oauthServerUrl = `${tokenUrl.protocol}//${tokenUrl.host}`;
|
|
4242
|
-
|
|
4495
|
+
logger6.info({ oauthServerUrl, clientId }, "Attempting openid-client discovery");
|
|
4243
4496
|
const config = await oauth.discovery(
|
|
4244
4497
|
new URL(oauthServerUrl),
|
|
4245
4498
|
clientId,
|
|
@@ -4271,7 +4524,7 @@ var OAuthService = class {
|
|
|
4271
4524
|
*/
|
|
4272
4525
|
async exchangeManually(params) {
|
|
4273
4526
|
const { oAuthConfig, clientId, code, codeVerifier, redirectUri } = params;
|
|
4274
|
-
|
|
4527
|
+
logger6.info({ tokenUrl: oAuthConfig.tokenUrl }, "Attempting manual token exchange");
|
|
4275
4528
|
const tokenResponse = await fetch(oAuthConfig.tokenUrl, {
|
|
4276
4529
|
method: "POST",
|
|
4277
4530
|
headers: {
|
|
@@ -4289,7 +4542,7 @@ var OAuthService = class {
|
|
|
4289
4542
|
});
|
|
4290
4543
|
if (!tokenResponse.ok) {
|
|
4291
4544
|
const errorText = await tokenResponse.text();
|
|
4292
|
-
|
|
4545
|
+
logger6.error(
|
|
4293
4546
|
{
|
|
4294
4547
|
status: tokenResponse.status,
|
|
4295
4548
|
statusText: tokenResponse.statusText,
|
|
@@ -4332,8 +4585,8 @@ async function findOrCreateCredential(tenantId, projectId, credentialData) {
|
|
|
4332
4585
|
throw new Error(`Failed to save credential '${credentialData.id}' to database`);
|
|
4333
4586
|
}
|
|
4334
4587
|
}
|
|
4335
|
-
var
|
|
4336
|
-
var
|
|
4588
|
+
var app19 = new zodOpenapi.OpenAPIHono();
|
|
4589
|
+
var logger7 = agentsCore.getLogger("oauth-callback");
|
|
4337
4590
|
function getBaseUrlFromRequest(c) {
|
|
4338
4591
|
const url = new URL(c.req.url);
|
|
4339
4592
|
return `${url.protocol}//${url.host}`;
|
|
@@ -4419,7 +4672,7 @@ var OAuthCallbackQuerySchema = zodOpenapi.z.object({
|
|
|
4419
4672
|
error: zodOpenapi.z.string().optional(),
|
|
4420
4673
|
error_description: zodOpenapi.z.string().optional()
|
|
4421
4674
|
});
|
|
4422
|
-
|
|
4675
|
+
app19.openapi(
|
|
4423
4676
|
zodOpenapi.createRoute({
|
|
4424
4677
|
method: "get",
|
|
4425
4678
|
path: "/login",
|
|
@@ -4465,7 +4718,7 @@ app18.openapi(
|
|
|
4465
4718
|
try {
|
|
4466
4719
|
const tool = await agentsCore.getToolById(dbClient_default)({ scopes: { tenantId, projectId }, toolId });
|
|
4467
4720
|
if (!tool) {
|
|
4468
|
-
|
|
4721
|
+
logger7.error({ toolId, tenantId, projectId }, "Tool not found for OAuth login");
|
|
4469
4722
|
return c.text("Tool not found", 404);
|
|
4470
4723
|
}
|
|
4471
4724
|
const credentialStores = c.get("credentialStores");
|
|
@@ -4480,13 +4733,13 @@ app18.openapi(
|
|
|
4480
4733
|
});
|
|
4481
4734
|
return c.redirect(redirectUrl, 302);
|
|
4482
4735
|
} catch (error) {
|
|
4483
|
-
|
|
4736
|
+
logger7.error({ toolId, tenantId, projectId, error }, "OAuth login failed");
|
|
4484
4737
|
const errorMessage = error instanceof Error ? error.message : "Failed to initiate OAuth login";
|
|
4485
4738
|
return c.text(`OAuth Error: ${errorMessage}`, 500);
|
|
4486
4739
|
}
|
|
4487
4740
|
}
|
|
4488
4741
|
);
|
|
4489
|
-
|
|
4742
|
+
app19.openapi(
|
|
4490
4743
|
zodOpenapi.createRoute({
|
|
4491
4744
|
method: "get",
|
|
4492
4745
|
path: "/callback",
|
|
@@ -4522,9 +4775,9 @@ app18.openapi(
|
|
|
4522
4775
|
async (c) => {
|
|
4523
4776
|
try {
|
|
4524
4777
|
const { code, state, error, error_description } = c.req.valid("query");
|
|
4525
|
-
|
|
4778
|
+
logger7.info({ state, hasCode: !!code }, "OAuth callback received");
|
|
4526
4779
|
if (error) {
|
|
4527
|
-
|
|
4780
|
+
logger7.error({ error, error_description }, "OAuth authorization failed");
|
|
4528
4781
|
const errorMessage = error_description || error || "OAuth Authorization Failed. Please try again.";
|
|
4529
4782
|
const errorPage = generateOAuthCallbackPage({
|
|
4530
4783
|
title: "Authentication Failed",
|
|
@@ -4535,7 +4788,7 @@ app18.openapi(
|
|
|
4535
4788
|
}
|
|
4536
4789
|
const pkceData = retrievePKCEVerifier(state);
|
|
4537
4790
|
if (!pkceData) {
|
|
4538
|
-
|
|
4791
|
+
logger7.error({ state }, "Invalid or expired OAuth state");
|
|
4539
4792
|
const errorMessage = "OAuth Session Expired: The OAuth session has expired or is invalid. Please try again.";
|
|
4540
4793
|
const expiredPage = generateOAuthCallbackPage({
|
|
4541
4794
|
title: "Session Expired",
|
|
@@ -4552,8 +4805,8 @@ app18.openapi(
|
|
|
4552
4805
|
if (!tool) {
|
|
4553
4806
|
throw new Error(`Tool ${toolId} not found`);
|
|
4554
4807
|
}
|
|
4555
|
-
|
|
4556
|
-
|
|
4808
|
+
logger7.info({ toolId, tenantId, projectId }, "Processing OAuth callback");
|
|
4809
|
+
logger7.info({ toolId }, "Exchanging authorization code for access token");
|
|
4557
4810
|
const credentialStores = c.get("credentialStores");
|
|
4558
4811
|
const mcpTool = await agentsCore.dbResultToMcpTool(tool, dbClient_default, credentialStores);
|
|
4559
4812
|
const baseUrl = getBaseUrlFromRequest(c);
|
|
@@ -4564,7 +4817,7 @@ app18.openapi(
|
|
|
4564
4817
|
tool: mcpTool,
|
|
4565
4818
|
baseUrl
|
|
4566
4819
|
});
|
|
4567
|
-
|
|
4820
|
+
logger7.info(
|
|
4568
4821
|
{ toolId, tokenType: tokens.token_type, hasRefresh: !!tokens.refresh_token },
|
|
4569
4822
|
"Token exchange successful"
|
|
4570
4823
|
);
|
|
@@ -4611,7 +4864,7 @@ app18.openapi(
|
|
|
4611
4864
|
credentialReferenceId: newCredential.id
|
|
4612
4865
|
}
|
|
4613
4866
|
});
|
|
4614
|
-
|
|
4867
|
+
logger7.info({ toolId, credentialId: newCredential.id }, "OAuth flow completed successfully");
|
|
4615
4868
|
const successPage = generateOAuthCallbackPage({
|
|
4616
4869
|
title: "Authentication Complete",
|
|
4617
4870
|
message: "You have been successfully authenticated.",
|
|
@@ -4619,7 +4872,7 @@ app18.openapi(
|
|
|
4619
4872
|
});
|
|
4620
4873
|
return c.html(successPage);
|
|
4621
4874
|
} catch (error) {
|
|
4622
|
-
|
|
4875
|
+
logger7.error({ error }, "OAuth callback processing failed");
|
|
4623
4876
|
const errorMessage = "OAuth Processing Failed. Please try again.";
|
|
4624
4877
|
const errorPage = generateOAuthCallbackPage({
|
|
4625
4878
|
title: "Processing Failed",
|
|
@@ -4630,9 +4883,9 @@ app18.openapi(
|
|
|
4630
4883
|
}
|
|
4631
4884
|
}
|
|
4632
4885
|
);
|
|
4633
|
-
var oauth_default =
|
|
4634
|
-
var
|
|
4635
|
-
var
|
|
4886
|
+
var oauth_default = app19;
|
|
4887
|
+
var logger8 = agentsCore.getLogger("projectFull");
|
|
4888
|
+
var app20 = new zodOpenapi.OpenAPIHono();
|
|
4636
4889
|
var ProjectIdParamsSchema = zod.z.object({
|
|
4637
4890
|
tenantId: zod.z.string().openapi({
|
|
4638
4891
|
description: "Tenant identifier",
|
|
@@ -4649,7 +4902,7 @@ var TenantParamsSchema2 = zod.z.object({
|
|
|
4649
4902
|
example: "tenant_123"
|
|
4650
4903
|
})
|
|
4651
4904
|
}).openapi("TenantParams");
|
|
4652
|
-
|
|
4905
|
+
app20.openapi(
|
|
4653
4906
|
zodOpenapi.createRoute({
|
|
4654
4907
|
method: "post",
|
|
4655
4908
|
path: "/project-full",
|
|
@@ -4692,7 +4945,7 @@ app19.openapi(
|
|
|
4692
4945
|
const projectData = c.req.valid("json");
|
|
4693
4946
|
const validatedProjectData = agentsCore.FullProjectDefinitionSchema.parse(projectData);
|
|
4694
4947
|
try {
|
|
4695
|
-
const createdProject = await agentsCore.createFullProjectServerSide(dbClient_default,
|
|
4948
|
+
const createdProject = await agentsCore.createFullProjectServerSide(dbClient_default, logger8)(
|
|
4696
4949
|
{ tenantId, projectId: validatedProjectData.id },
|
|
4697
4950
|
validatedProjectData
|
|
4698
4951
|
);
|
|
@@ -4708,7 +4961,7 @@ app19.openapi(
|
|
|
4708
4961
|
}
|
|
4709
4962
|
}
|
|
4710
4963
|
);
|
|
4711
|
-
|
|
4964
|
+
app20.openapi(
|
|
4712
4965
|
zodOpenapi.createRoute({
|
|
4713
4966
|
method: "get",
|
|
4714
4967
|
path: "/project-full/{projectId}",
|
|
@@ -4736,7 +4989,7 @@ app19.openapi(
|
|
|
4736
4989
|
try {
|
|
4737
4990
|
const project = await agentsCore.getFullProject(
|
|
4738
4991
|
dbClient_default,
|
|
4739
|
-
|
|
4992
|
+
logger8
|
|
4740
4993
|
)({
|
|
4741
4994
|
scopes: { tenantId, projectId }
|
|
4742
4995
|
});
|
|
@@ -4761,7 +5014,7 @@ app19.openapi(
|
|
|
4761
5014
|
}
|
|
4762
5015
|
}
|
|
4763
5016
|
);
|
|
4764
|
-
|
|
5017
|
+
app20.openapi(
|
|
4765
5018
|
zodOpenapi.createRoute({
|
|
4766
5019
|
method: "put",
|
|
4767
5020
|
path: "/project-full/{projectId}",
|
|
@@ -4812,15 +5065,15 @@ app19.openapi(
|
|
|
4812
5065
|
}
|
|
4813
5066
|
const existingProject = await agentsCore.getFullProject(
|
|
4814
5067
|
dbClient_default,
|
|
4815
|
-
|
|
5068
|
+
logger8
|
|
4816
5069
|
)({
|
|
4817
5070
|
scopes: { tenantId, projectId }
|
|
4818
5071
|
});
|
|
4819
5072
|
const isCreate = !existingProject;
|
|
4820
|
-
const updatedProject = isCreate ? await agentsCore.createFullProjectServerSide(dbClient_default,
|
|
5073
|
+
const updatedProject = isCreate ? await agentsCore.createFullProjectServerSide(dbClient_default, logger8)(
|
|
4821
5074
|
{ tenantId, projectId },
|
|
4822
5075
|
validatedProjectData
|
|
4823
|
-
) : await agentsCore.updateFullProjectServerSide(dbClient_default,
|
|
5076
|
+
) : await agentsCore.updateFullProjectServerSide(dbClient_default, logger8)(
|
|
4824
5077
|
{ tenantId, projectId },
|
|
4825
5078
|
validatedProjectData
|
|
4826
5079
|
);
|
|
@@ -4845,7 +5098,7 @@ app19.openapi(
|
|
|
4845
5098
|
}
|
|
4846
5099
|
}
|
|
4847
5100
|
);
|
|
4848
|
-
|
|
5101
|
+
app20.openapi(
|
|
4849
5102
|
zodOpenapi.createRoute({
|
|
4850
5103
|
method: "delete",
|
|
4851
5104
|
path: "/project-full/{projectId}",
|
|
@@ -4868,7 +5121,7 @@ app19.openapi(
|
|
|
4868
5121
|
try {
|
|
4869
5122
|
const deleted = await agentsCore.deleteFullProject(
|
|
4870
5123
|
dbClient_default,
|
|
4871
|
-
|
|
5124
|
+
logger8
|
|
4872
5125
|
)({
|
|
4873
5126
|
scopes: { tenantId, projectId }
|
|
4874
5127
|
});
|
|
@@ -4893,20 +5146,20 @@ app19.openapi(
|
|
|
4893
5146
|
}
|
|
4894
5147
|
}
|
|
4895
5148
|
);
|
|
4896
|
-
var projectFull_default =
|
|
5149
|
+
var projectFull_default = app20;
|
|
4897
5150
|
|
|
4898
5151
|
// src/app.ts
|
|
4899
|
-
var
|
|
4900
|
-
|
|
5152
|
+
var logger9 = agentsCore.getLogger("agents-manage-api");
|
|
5153
|
+
logger9.info({ logger: logger9.getTransports() }, "Logger initialized");
|
|
4901
5154
|
function createManagementHono(serverConfig, credentialStores) {
|
|
4902
|
-
const
|
|
4903
|
-
|
|
4904
|
-
|
|
5155
|
+
const app22 = new zodOpenapi.OpenAPIHono();
|
|
5156
|
+
app22.use("*", requestId.requestId());
|
|
5157
|
+
app22.use("*", async (c, next) => {
|
|
4905
5158
|
c.set("serverConfig", serverConfig);
|
|
4906
5159
|
c.set("credentialStores", credentialStores);
|
|
4907
5160
|
return next();
|
|
4908
5161
|
});
|
|
4909
|
-
|
|
5162
|
+
app22.use(
|
|
4910
5163
|
honoPino.pinoLogger({
|
|
4911
5164
|
pino: agentsCore.getLogger("agents-manage-api").getPinoInstance(),
|
|
4912
5165
|
http: {
|
|
@@ -4919,7 +5172,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
4919
5172
|
}
|
|
4920
5173
|
})
|
|
4921
5174
|
);
|
|
4922
|
-
|
|
5175
|
+
app22.onError(async (err, c) => {
|
|
4923
5176
|
const isExpectedError = err instanceof httpException.HTTPException;
|
|
4924
5177
|
const status = isExpectedError ? err.status : 500;
|
|
4925
5178
|
const requestId2 = c.get("requestId") || "unknown";
|
|
@@ -4952,7 +5205,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
4952
5205
|
if (!isExpectedError) {
|
|
4953
5206
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
4954
5207
|
const errorStack = err instanceof Error ? err.stack : void 0;
|
|
4955
|
-
|
|
5208
|
+
logger9.error(
|
|
4956
5209
|
{
|
|
4957
5210
|
error: err,
|
|
4958
5211
|
message: errorMessage,
|
|
@@ -4963,7 +5216,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
4963
5216
|
"Unexpected server error occurred"
|
|
4964
5217
|
);
|
|
4965
5218
|
} else {
|
|
4966
|
-
|
|
5219
|
+
logger9.error(
|
|
4967
5220
|
{
|
|
4968
5221
|
error: err,
|
|
4969
5222
|
path: c.req.path,
|
|
@@ -4979,7 +5232,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
4979
5232
|
const response = err.getResponse();
|
|
4980
5233
|
return response;
|
|
4981
5234
|
} catch (responseError) {
|
|
4982
|
-
|
|
5235
|
+
logger9.error({ error: responseError }, "Error while handling HTTPException response");
|
|
4983
5236
|
}
|
|
4984
5237
|
}
|
|
4985
5238
|
const { status: respStatus, title, detail, instance } = await agentsCore.handleApiError(err, requestId2);
|
|
@@ -4994,7 +5247,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
4994
5247
|
...instance && { instance }
|
|
4995
5248
|
});
|
|
4996
5249
|
});
|
|
4997
|
-
|
|
5250
|
+
app22.use(
|
|
4998
5251
|
"*",
|
|
4999
5252
|
cors.cors({
|
|
5000
5253
|
origin: (origin) => {
|
|
@@ -5008,7 +5261,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5008
5261
|
credentials: true
|
|
5009
5262
|
})
|
|
5010
5263
|
);
|
|
5011
|
-
|
|
5264
|
+
app22.openapi(
|
|
5012
5265
|
zodOpenapi.createRoute({
|
|
5013
5266
|
method: "get",
|
|
5014
5267
|
path: "/health",
|
|
@@ -5025,13 +5278,13 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5025
5278
|
return c.body(null, 204);
|
|
5026
5279
|
}
|
|
5027
5280
|
);
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
setupOpenAPIRoutes(
|
|
5281
|
+
app22.use("/tenants/*", apiKeyAuth());
|
|
5282
|
+
app22.route("/tenants/:tenantId", routes_default);
|
|
5283
|
+
app22.route("/tenants/:tenantId", projectFull_default);
|
|
5284
|
+
app22.route("/oauth", oauth_default);
|
|
5285
|
+
setupOpenAPIRoutes(app22);
|
|
5033
5286
|
const baseApp = new hono.Hono();
|
|
5034
|
-
baseApp.route("/",
|
|
5287
|
+
baseApp.route("/", app22);
|
|
5035
5288
|
return baseApp;
|
|
5036
5289
|
}
|
|
5037
5290
|
|
|
@@ -5047,8 +5300,8 @@ var defaultConfig = {
|
|
|
5047
5300
|
};
|
|
5048
5301
|
var defaultStores = agentsCore.createDefaultCredentialStores();
|
|
5049
5302
|
var defaultRegistry = new agentsCore.CredentialStoreRegistry(defaultStores);
|
|
5050
|
-
var
|
|
5051
|
-
var index_default =
|
|
5303
|
+
var app21 = createManagementHono(defaultConfig, defaultRegistry);
|
|
5304
|
+
var index_default = app21;
|
|
5052
5305
|
function createManagementApp(config) {
|
|
5053
5306
|
const serverConfig = config?.serverConfig ?? defaultConfig;
|
|
5054
5307
|
const stores = config?.credentialStores ?? defaultStores;
|