@inkeep/agents-manage-api 0.0.0-dev-20251008200151 → 0.0.0-dev-20251009005405

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.
Files changed (3) hide show
  1. package/dist/index.cjs +378 -111
  2. package/dist/index.js +379 -112
  3. 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(app20) {
74
- app20.get("/openapi.json", (c) => {
73
+ function setupOpenAPIRoutes(app21) {
74
+ app21.get("/openapi.json", (c) => {
75
75
  try {
76
- const document = app20.getOpenAPIDocument({
76
+ const document = app21.getOpenAPIDocument({
77
77
  openapi: "3.0.0",
78
78
  info: {
79
79
  title: "Inkeep Agents Manage API",
@@ -94,7 +94,7 @@ function setupOpenAPIRoutes(app20) {
94
94
  return c.json({ error: "Failed to generate OpenAPI document", details: errorDetails }, 500);
95
95
  }
96
96
  });
97
- app20.get(
97
+ app21.get(
98
98
  "/docs",
99
99
  swaggerUi.swaggerUI({
100
100
  url: "/openapi.json",
@@ -3048,8 +3048,268 @@ app12.openapi(
3048
3048
  }
3049
3049
  );
3050
3050
  var externalAgents_default = app12;
3051
- var logger2 = agentsCore.getLogger("graphFull");
3051
+ var logger2 = agentsCore.getLogger("functions");
3052
3052
  var app13 = new zodOpenapi.OpenAPIHono();
3053
+ app13.openapi(
3054
+ zodOpenapi.createRoute({
3055
+ method: "get",
3056
+ path: "/",
3057
+ summary: "List Functions",
3058
+ operationId: "list-functions",
3059
+ tags: ["Functions"],
3060
+ request: {
3061
+ params: agentsCore.TenantProjectParamsSchema,
3062
+ query: agentsCore.PaginationQueryParamsSchema
3063
+ },
3064
+ responses: {
3065
+ 200: {
3066
+ description: "List of functions",
3067
+ content: {
3068
+ "application/json": {
3069
+ schema: agentsCore.ListResponseSchema(agentsCore.FunctionApiSelectSchema)
3070
+ }
3071
+ }
3072
+ },
3073
+ ...agentsCore.commonGetErrorResponses
3074
+ }
3075
+ }),
3076
+ async (c) => {
3077
+ const { tenantId, projectId } = c.req.valid("param");
3078
+ try {
3079
+ const functions = await agentsCore.listFunctions(dbClient_default)({ scopes: { tenantId, projectId } });
3080
+ return c.json({
3081
+ data: functions,
3082
+ pagination: {
3083
+ page: 1,
3084
+ limit: functions.length,
3085
+ total: functions.length,
3086
+ pages: 1
3087
+ }
3088
+ });
3089
+ } catch (error) {
3090
+ logger2.error({ error, tenantId }, "Failed to list functions");
3091
+ return c.json(
3092
+ agentsCore.createApiError({ code: "internal_server_error", message: "Failed to list functions" }),
3093
+ 500
3094
+ );
3095
+ }
3096
+ }
3097
+ );
3098
+ app13.openapi(
3099
+ zodOpenapi.createRoute({
3100
+ method: "get",
3101
+ path: "/{id}",
3102
+ summary: "Get Function by ID",
3103
+ operationId: "get-function",
3104
+ tags: ["Functions"],
3105
+ request: {
3106
+ params: agentsCore.TenantProjectParamsSchema.merge(agentsCore.IdParamsSchema)
3107
+ },
3108
+ responses: {
3109
+ 200: {
3110
+ description: "Function details",
3111
+ content: {
3112
+ "application/json": {
3113
+ schema: agentsCore.SingleResponseSchema(agentsCore.FunctionApiSelectSchema)
3114
+ }
3115
+ }
3116
+ },
3117
+ ...agentsCore.commonGetErrorResponses
3118
+ }
3119
+ }),
3120
+ async (c) => {
3121
+ const { tenantId, projectId, id } = c.req.valid("param");
3122
+ try {
3123
+ const functionData = await agentsCore.getFunction(dbClient_default)({
3124
+ functionId: id,
3125
+ scopes: { tenantId, projectId }
3126
+ });
3127
+ if (!functionData) {
3128
+ return c.json(
3129
+ agentsCore.createApiError({ code: "not_found", message: "Function not found" }),
3130
+ 404
3131
+ );
3132
+ }
3133
+ return c.json({ data: functionData });
3134
+ } catch (error) {
3135
+ logger2.error({ error, tenantId, id }, "Failed to get function");
3136
+ return c.json(
3137
+ agentsCore.createApiError({ code: "internal_server_error", message: "Failed to get function" }),
3138
+ 500
3139
+ );
3140
+ }
3141
+ }
3142
+ );
3143
+ app13.openapi(
3144
+ zodOpenapi.createRoute({
3145
+ method: "post",
3146
+ path: "/",
3147
+ summary: "Create Function",
3148
+ operationId: "create-function",
3149
+ tags: ["Functions"],
3150
+ request: {
3151
+ params: agentsCore.TenantProjectParamsSchema,
3152
+ body: {
3153
+ content: {
3154
+ "application/json": {
3155
+ schema: agentsCore.FunctionApiInsertSchema
3156
+ }
3157
+ }
3158
+ }
3159
+ },
3160
+ responses: {
3161
+ 201: {
3162
+ description: "Function created",
3163
+ content: {
3164
+ "application/json": {
3165
+ schema: agentsCore.SingleResponseSchema(agentsCore.FunctionApiSelectSchema)
3166
+ }
3167
+ }
3168
+ },
3169
+ ...agentsCore.commonGetErrorResponses
3170
+ }
3171
+ }),
3172
+ async (c) => {
3173
+ const { tenantId, projectId } = c.req.valid("param");
3174
+ const functionData = c.req.valid("json");
3175
+ try {
3176
+ const id = functionData.id || nanoid.nanoid();
3177
+ await agentsCore.upsertFunction(dbClient_default)({
3178
+ data: {
3179
+ ...functionData,
3180
+ id
3181
+ },
3182
+ scopes: { tenantId, projectId }
3183
+ });
3184
+ const created = await agentsCore.getFunction(dbClient_default)({
3185
+ functionId: id,
3186
+ scopes: { tenantId, projectId }
3187
+ });
3188
+ logger2.info({ tenantId, functionId: id }, "Function created");
3189
+ return c.json({ data: created }, 201);
3190
+ } catch (error) {
3191
+ logger2.error({ error, tenantId, functionData }, "Failed to create function");
3192
+ return c.json(
3193
+ agentsCore.createApiError({ code: "internal_server_error", message: "Failed to create function" }),
3194
+ 500
3195
+ );
3196
+ }
3197
+ }
3198
+ );
3199
+ app13.openapi(
3200
+ zodOpenapi.createRoute({
3201
+ method: "put",
3202
+ path: "/{id}",
3203
+ summary: "Update Function",
3204
+ operationId: "update-function",
3205
+ tags: ["Functions"],
3206
+ request: {
3207
+ params: agentsCore.TenantProjectParamsSchema.merge(agentsCore.IdParamsSchema),
3208
+ body: {
3209
+ content: {
3210
+ "application/json": {
3211
+ schema: agentsCore.FunctionApiUpdateSchema
3212
+ }
3213
+ }
3214
+ }
3215
+ },
3216
+ responses: {
3217
+ 200: {
3218
+ description: "Function updated",
3219
+ content: {
3220
+ "application/json": {
3221
+ schema: agentsCore.SingleResponseSchema(agentsCore.FunctionApiSelectSchema)
3222
+ }
3223
+ }
3224
+ },
3225
+ ...agentsCore.commonGetErrorResponses
3226
+ }
3227
+ }),
3228
+ async (c) => {
3229
+ const { tenantId, projectId, id } = c.req.valid("param");
3230
+ const updateData = c.req.valid("json");
3231
+ try {
3232
+ const existing = await agentsCore.getFunction(dbClient_default)({
3233
+ functionId: id,
3234
+ scopes: { tenantId, projectId }
3235
+ });
3236
+ if (!existing) {
3237
+ return c.json(
3238
+ agentsCore.createApiError({ code: "not_found", message: "Function not found" }),
3239
+ 404
3240
+ );
3241
+ }
3242
+ await agentsCore.upsertFunction(dbClient_default)({
3243
+ data: {
3244
+ ...existing,
3245
+ ...updateData,
3246
+ id
3247
+ },
3248
+ scopes: { tenantId, projectId }
3249
+ });
3250
+ const updated = await agentsCore.getFunction(dbClient_default)({
3251
+ functionId: id,
3252
+ scopes: { tenantId, projectId }
3253
+ });
3254
+ logger2.info({ tenantId, functionId: id }, "Function updated");
3255
+ return c.json({ data: updated });
3256
+ } catch (error) {
3257
+ logger2.error({ error, tenantId, id, updateData }, "Failed to update function");
3258
+ return c.json(
3259
+ agentsCore.createApiError({ code: "internal_server_error", message: "Failed to update function" }),
3260
+ 500
3261
+ );
3262
+ }
3263
+ }
3264
+ );
3265
+ app13.openapi(
3266
+ zodOpenapi.createRoute({
3267
+ method: "delete",
3268
+ path: "/{id}",
3269
+ summary: "Delete Function",
3270
+ operationId: "delete-function",
3271
+ tags: ["Functions"],
3272
+ request: {
3273
+ params: agentsCore.TenantProjectParamsSchema.merge(agentsCore.IdParamsSchema)
3274
+ },
3275
+ responses: {
3276
+ 204: {
3277
+ description: "Function deleted"
3278
+ },
3279
+ ...agentsCore.commonGetErrorResponses
3280
+ }
3281
+ }),
3282
+ async (c) => {
3283
+ const { tenantId, projectId, id } = c.req.valid("param");
3284
+ try {
3285
+ const existing = await agentsCore.getFunction(dbClient_default)({
3286
+ functionId: id,
3287
+ scopes: { tenantId, projectId }
3288
+ });
3289
+ if (!existing) {
3290
+ return c.json(
3291
+ agentsCore.createApiError({ code: "not_found", message: "Function not found" }),
3292
+ 404
3293
+ );
3294
+ }
3295
+ await agentsCore.deleteFunction(dbClient_default)({
3296
+ functionId: id,
3297
+ scopes: { tenantId, projectId }
3298
+ });
3299
+ logger2.info({ tenantId, functionId: id }, "Function deleted");
3300
+ return c.body(null, 204);
3301
+ } catch (error) {
3302
+ logger2.error({ error, tenantId, id }, "Failed to delete function");
3303
+ return c.json(
3304
+ agentsCore.createApiError({ code: "internal_server_error", message: "Failed to delete function" }),
3305
+ 500
3306
+ );
3307
+ }
3308
+ }
3309
+ );
3310
+ var functions_default = app13;
3311
+ var logger3 = agentsCore.getLogger("graphFull");
3312
+ var app14 = new zodOpenapi.OpenAPIHono();
3053
3313
  var GraphIdParamsSchema = zod.z.object({
3054
3314
  tenantId: zod.z.string().openapi({
3055
3315
  description: "Tenant identifier",
@@ -3064,7 +3324,7 @@ var GraphIdParamsSchema = zod.z.object({
3064
3324
  example: "graph_789"
3065
3325
  })
3066
3326
  }).openapi("GraphIdParams");
3067
- app13.openapi(
3327
+ app14.openapi(
3068
3328
  zodOpenapi.createRoute({
3069
3329
  method: "post",
3070
3330
  path: "/",
@@ -3106,14 +3366,14 @@ app13.openapi(
3106
3366
  const { tenantId, projectId } = c.req.valid("param");
3107
3367
  const graphData = c.req.valid("json");
3108
3368
  const validatedGraphData = agentsCore.FullGraphDefinitionSchema.parse(graphData);
3109
- const createdGraph = await agentsCore.createFullGraphServerSide(dbClient_default, logger2)(
3369
+ const createdGraph = await agentsCore.createFullGraphServerSide(dbClient_default, logger3)(
3110
3370
  { tenantId, projectId },
3111
3371
  validatedGraphData
3112
3372
  );
3113
3373
  return c.json({ data: createdGraph }, 201);
3114
3374
  }
3115
3375
  );
3116
- app13.openapi(
3376
+ app14.openapi(
3117
3377
  zodOpenapi.createRoute({
3118
3378
  method: "get",
3119
3379
  path: "/{graphId}",
@@ -3141,7 +3401,7 @@ app13.openapi(
3141
3401
  try {
3142
3402
  const graph = await agentsCore.getFullGraph(
3143
3403
  dbClient_default,
3144
- logger2
3404
+ logger3
3145
3405
  )({
3146
3406
  scopes: { tenantId, projectId, graphId }
3147
3407
  });
@@ -3166,7 +3426,7 @@ app13.openapi(
3166
3426
  }
3167
3427
  }
3168
3428
  );
3169
- app13.openapi(
3429
+ app14.openapi(
3170
3430
  zodOpenapi.createRoute({
3171
3431
  method: "put",
3172
3432
  path: "/{graphId}",
@@ -3217,15 +3477,15 @@ app13.openapi(
3217
3477
  }
3218
3478
  const existingGraph = await agentsCore.getFullGraph(
3219
3479
  dbClient_default,
3220
- logger2
3480
+ logger3
3221
3481
  )({
3222
3482
  scopes: { tenantId, projectId, graphId }
3223
3483
  });
3224
3484
  const isCreate = !existingGraph;
3225
- const updatedGraph = isCreate ? await agentsCore.createFullGraphServerSide(dbClient_default, logger2)(
3485
+ const updatedGraph = isCreate ? await agentsCore.createFullGraphServerSide(dbClient_default, logger3)(
3226
3486
  { tenantId, projectId },
3227
3487
  validatedGraphData
3228
- ) : await agentsCore.updateFullGraphServerSide(dbClient_default, logger2)(
3488
+ ) : await agentsCore.updateFullGraphServerSide(dbClient_default, logger3)(
3229
3489
  { tenantId, projectId },
3230
3490
  validatedGraphData
3231
3491
  );
@@ -3250,7 +3510,7 @@ app13.openapi(
3250
3510
  }
3251
3511
  }
3252
3512
  );
3253
- app13.openapi(
3513
+ app14.openapi(
3254
3514
  zodOpenapi.createRoute({
3255
3515
  method: "delete",
3256
3516
  path: "/{graphId}",
@@ -3273,7 +3533,7 @@ app13.openapi(
3273
3533
  try {
3274
3534
  const deleted = await agentsCore.deleteFullGraph(
3275
3535
  dbClient_default,
3276
- logger2
3536
+ logger3
3277
3537
  )({
3278
3538
  scopes: { tenantId, projectId, graphId }
3279
3539
  });
@@ -3298,9 +3558,9 @@ app13.openapi(
3298
3558
  }
3299
3559
  }
3300
3560
  );
3301
- var graphFull_default = app13;
3302
- var app14 = new zodOpenapi.OpenAPIHono();
3303
- app14.openapi(
3561
+ var graphFull_default = app14;
3562
+ var app15 = new zodOpenapi.OpenAPIHono();
3563
+ app15.openapi(
3304
3564
  zodOpenapi.createRoute({
3305
3565
  method: "get",
3306
3566
  path: "/",
@@ -3335,7 +3595,7 @@ app14.openapi(
3335
3595
  return c.json(result);
3336
3596
  }
3337
3597
  );
3338
- app14.openapi(
3598
+ app15.openapi(
3339
3599
  zodOpenapi.createRoute({
3340
3600
  method: "get",
3341
3601
  path: "/{id}",
@@ -3370,7 +3630,7 @@ app14.openapi(
3370
3630
  return c.json({ data: project });
3371
3631
  }
3372
3632
  );
3373
- app14.openapi(
3633
+ app15.openapi(
3374
3634
  zodOpenapi.createRoute({
3375
3635
  method: "post",
3376
3636
  path: "/",
@@ -3428,7 +3688,7 @@ app14.openapi(
3428
3688
  }
3429
3689
  }
3430
3690
  );
3431
- app14.openapi(
3691
+ app15.openapi(
3432
3692
  zodOpenapi.createRoute({
3433
3693
  method: "patch",
3434
3694
  path: "/{id}",
@@ -3474,7 +3734,7 @@ app14.openapi(
3474
3734
  return c.json({ data: project });
3475
3735
  }
3476
3736
  );
3477
- app14.openapi(
3737
+ app15.openapi(
3478
3738
  zodOpenapi.createRoute({
3479
3739
  method: "delete",
3480
3740
  path: "/{id}",
@@ -3524,10 +3784,10 @@ app14.openapi(
3524
3784
  }
3525
3785
  }
3526
3786
  );
3527
- var projects_default = app14;
3528
- var logger3 = agentsCore.getLogger("tools");
3529
- var app15 = new zodOpenapi.OpenAPIHono();
3530
- app15.openapi(
3787
+ var projects_default = app15;
3788
+ var logger4 = agentsCore.getLogger("tools");
3789
+ var app16 = new zodOpenapi.OpenAPIHono();
3790
+ app16.openapi(
3531
3791
  zodOpenapi.createRoute({
3532
3792
  method: "get",
3533
3793
  path: "/",
@@ -3587,7 +3847,7 @@ app15.openapi(
3587
3847
  return c.json(result);
3588
3848
  }
3589
3849
  );
3590
- app15.openapi(
3850
+ app16.openapi(
3591
3851
  zodOpenapi.createRoute({
3592
3852
  method: "get",
3593
3853
  path: "/{id}",
@@ -3624,7 +3884,7 @@ app15.openapi(
3624
3884
  });
3625
3885
  }
3626
3886
  );
3627
- app15.openapi(
3887
+ app16.openapi(
3628
3888
  zodOpenapi.createRoute({
3629
3889
  method: "post",
3630
3890
  path: "/",
@@ -3657,7 +3917,7 @@ app15.openapi(
3657
3917
  const { tenantId, projectId } = c.req.valid("param");
3658
3918
  const body = c.req.valid("json");
3659
3919
  const credentialStores = c.get("credentialStores");
3660
- logger3.info({ body }, "body");
3920
+ logger4.info({ body }, "body");
3661
3921
  const id = body.id || nanoid.nanoid();
3662
3922
  const tool = await agentsCore.createTool(dbClient_default)({
3663
3923
  tenantId,
@@ -3677,7 +3937,7 @@ app15.openapi(
3677
3937
  );
3678
3938
  }
3679
3939
  );
3680
- app15.openapi(
3940
+ app16.openapi(
3681
3941
  zodOpenapi.createRoute({
3682
3942
  method: "put",
3683
3943
  path: "/{id}",
@@ -3738,7 +3998,7 @@ app15.openapi(
3738
3998
  });
3739
3999
  }
3740
4000
  );
3741
- app15.openapi(
4001
+ app16.openapi(
3742
4002
  zodOpenapi.createRoute({
3743
4003
  method: "delete",
3744
4004
  path: "/{id}",
@@ -3774,30 +4034,31 @@ app15.openapi(
3774
4034
  return c.body(null, 204);
3775
4035
  }
3776
4036
  );
3777
- var tools_default = app15;
4037
+ var tools_default = app16;
3778
4038
 
3779
4039
  // src/routes/index.ts
3780
- var app16 = new zodOpenapi.OpenAPIHono();
3781
- app16.route("/projects", projects_default);
3782
- app16.route("/projects/:projectId/graphs/:graphId/agents", agents_default);
3783
- app16.route("/projects/:projectId/graphs/:graphId/agent-relations", agentRelations_default);
3784
- app16.route("/projects/:projectId/agent-graphs", agentGraph_default);
3785
- app16.route("/projects/:projectId/graphs/:graphId/agent-tool-relations", agentToolRelations_default);
3786
- app16.route(
4040
+ var app17 = new zodOpenapi.OpenAPIHono();
4041
+ app17.route("/projects", projects_default);
4042
+ app17.route("/projects/:projectId/graphs/:graphId/agents", agents_default);
4043
+ app17.route("/projects/:projectId/graphs/:graphId/agent-relations", agentRelations_default);
4044
+ app17.route("/projects/:projectId/agent-graphs", agentGraph_default);
4045
+ app17.route("/projects/:projectId/graphs/:graphId/agent-tool-relations", agentToolRelations_default);
4046
+ app17.route(
3787
4047
  "/projects/:projectId/graphs/:graphId/agent-artifact-components",
3788
4048
  agentArtifactComponents_default
3789
4049
  );
3790
- app16.route("/projects/:projectId/graphs/:graphId/agent-data-components", agentDataComponents_default);
3791
- app16.route("/projects/:projectId/artifact-components", artifactComponents_default);
3792
- app16.route("/projects/:projectId/graphs/:graphId/context-configs", contextConfigs_default);
3793
- app16.route("/projects/:projectId/credentials", credentials_default);
3794
- app16.route("/projects/:projectId/data-components", dataComponents_default);
3795
- app16.route("/projects/:projectId/graphs/:graphId/external-agents", externalAgents_default);
3796
- app16.route("/projects/:projectId/tools", tools_default);
3797
- app16.route("/projects/:projectId/api-keys", apiKeys_default);
3798
- app16.route("/projects/:projectId/graph", graphFull_default);
3799
- var routes_default = app16;
3800
- var logger4 = agentsCore.getLogger("oauth-service");
4050
+ app17.route("/projects/:projectId/graphs/:graphId/agent-data-components", agentDataComponents_default);
4051
+ app17.route("/projects/:projectId/artifact-components", artifactComponents_default);
4052
+ app17.route("/projects/:projectId/graphs/:graphId/context-configs", contextConfigs_default);
4053
+ app17.route("/projects/:projectId/credentials", credentials_default);
4054
+ app17.route("/projects/:projectId/data-components", dataComponents_default);
4055
+ app17.route("/projects/:projectId/graphs/:graphId/external-agents", externalAgents_default);
4056
+ app17.route("/projects/:projectId/functions", functions_default);
4057
+ app17.route("/projects/:projectId/tools", tools_default);
4058
+ app17.route("/projects/:projectId/api-keys", apiKeys_default);
4059
+ app17.route("/projects/:projectId/graph", graphFull_default);
4060
+ var routes_default = app17;
4061
+ var logger5 = agentsCore.getLogger("oauth-service");
3801
4062
  var pkceStore = /* @__PURE__ */ new Map();
3802
4063
  function storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId) {
3803
4064
  pkceStore.set(state, { codeVerifier, toolId, tenantId, projectId, clientId });
@@ -3832,7 +4093,10 @@ var OAuthService = class {
3832
4093
  */
3833
4094
  async initiateOAuthFlow(params) {
3834
4095
  const { tool, tenantId, projectId, toolId, baseUrl } = params;
3835
- const oAuthConfig = await agentsCore.discoverOAuthEndpoints(tool.config.mcp.server.url, logger4);
4096
+ if (tool.config.type !== "mcp") {
4097
+ throw new Error("OAuth is only supported for MCP tools");
4098
+ }
4099
+ const oAuthConfig = await agentsCore.discoverOAuthEndpoints(tool.config.mcp.server.url, logger5);
3836
4100
  if (!oAuthConfig) {
3837
4101
  throw new Error("OAuth not supported by this server");
3838
4102
  }
@@ -3856,7 +4120,7 @@ var OAuthService = class {
3856
4120
  resource: tool.config.mcp.server.url
3857
4121
  });
3858
4122
  storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId);
3859
- logger4.info({ toolId, oAuthConfig, tenantId, projectId }, "OAuth flow initiated successfully");
4123
+ logger5.info({ toolId, oAuthConfig, tenantId, projectId }, "OAuth flow initiated successfully");
3860
4124
  return {
3861
4125
  redirectUrl: authUrl,
3862
4126
  state
@@ -3867,7 +4131,10 @@ var OAuthService = class {
3867
4131
  */
3868
4132
  async exchangeCodeForTokens(params) {
3869
4133
  const { code, codeVerifier, clientId, tool, baseUrl } = params;
3870
- const oAuthConfig = await agentsCore.discoverOAuthEndpoints(tool.config.mcp.server.url, logger4);
4134
+ if (tool.config.type !== "mcp") {
4135
+ throw new Error("OAuth is only supported for MCP tools");
4136
+ }
4137
+ const oAuthConfig = await agentsCore.discoverOAuthEndpoints(tool.config.mcp.server.url, logger5);
3871
4138
  if (!oAuthConfig?.tokenUrl) {
3872
4139
  throw new Error("Could not discover OAuth token endpoint");
3873
4140
  }
@@ -3882,9 +4149,9 @@ var OAuthService = class {
3882
4149
  codeVerifier,
3883
4150
  redirectUri
3884
4151
  });
3885
- logger4.info({ tokenType: tokens.token_type }, "Token exchange successful with openid-client");
4152
+ logger5.info({ tokenType: tokens.token_type }, "Token exchange successful with openid-client");
3886
4153
  } catch (error) {
3887
- logger4.warn(
4154
+ logger5.warn(
3888
4155
  { error: error instanceof Error ? error.message : error },
3889
4156
  "openid-client failed, falling back to manual token exchange"
3890
4157
  );
@@ -3895,7 +4162,7 @@ var OAuthService = class {
3895
4162
  codeVerifier,
3896
4163
  redirectUri
3897
4164
  });
3898
- logger4.info({ tokenType: tokens.token_type }, "Manual token exchange successful");
4165
+ logger5.info({ tokenType: tokens.token_type }, "Manual token exchange successful");
3899
4166
  }
3900
4167
  return { tokens, oAuthConfig };
3901
4168
  }
@@ -3903,7 +4170,7 @@ var OAuthService = class {
3903
4170
  * Perform dynamic client registration
3904
4171
  */
3905
4172
  async performDynamicClientRegistration(registrationUrl, redirectUri) {
3906
- logger4.info({ registrationUrl }, "Attempting dynamic client registration");
4173
+ logger5.info({ registrationUrl }, "Attempting dynamic client registration");
3907
4174
  try {
3908
4175
  const registrationResponse = await fetch(registrationUrl, {
3909
4176
  method: "POST",
@@ -3926,11 +4193,11 @@ var OAuthService = class {
3926
4193
  });
3927
4194
  if (registrationResponse.ok) {
3928
4195
  const registration = await registrationResponse.json();
3929
- logger4.info({ clientId: registration.client_id }, "Dynamic client registration successful");
4196
+ logger5.info({ clientId: registration.client_id }, "Dynamic client registration successful");
3930
4197
  return registration.client_id;
3931
4198
  } else {
3932
4199
  const errorText = await registrationResponse.text();
3933
- logger4.warn(
4200
+ logger5.warn(
3934
4201
  {
3935
4202
  status: registrationResponse.status,
3936
4203
  errorText
@@ -3939,7 +4206,7 @@ var OAuthService = class {
3939
4206
  );
3940
4207
  }
3941
4208
  } catch (regError) {
3942
- logger4.warn(
4209
+ logger5.warn(
3943
4210
  { error: regError },
3944
4211
  "Dynamic client registration error, using default client_id"
3945
4212
  );
@@ -3969,7 +4236,7 @@ var OAuthService = class {
3969
4236
  const oauth = await import('openid-client');
3970
4237
  const tokenUrl = new URL(oAuthConfig.tokenUrl);
3971
4238
  const oauthServerUrl = `${tokenUrl.protocol}//${tokenUrl.host}`;
3972
- logger4.info({ oauthServerUrl, clientId }, "Attempting openid-client discovery");
4239
+ logger5.info({ oauthServerUrl, clientId }, "Attempting openid-client discovery");
3973
4240
  const config = await oauth.discovery(
3974
4241
  new URL(oauthServerUrl),
3975
4242
  clientId,
@@ -4001,7 +4268,7 @@ var OAuthService = class {
4001
4268
  */
4002
4269
  async exchangeManually(params) {
4003
4270
  const { oAuthConfig, clientId, code, codeVerifier, redirectUri } = params;
4004
- logger4.info({ tokenUrl: oAuthConfig.tokenUrl }, "Attempting manual token exchange");
4271
+ logger5.info({ tokenUrl: oAuthConfig.tokenUrl }, "Attempting manual token exchange");
4005
4272
  const tokenResponse = await fetch(oAuthConfig.tokenUrl, {
4006
4273
  method: "POST",
4007
4274
  headers: {
@@ -4019,7 +4286,7 @@ var OAuthService = class {
4019
4286
  });
4020
4287
  if (!tokenResponse.ok) {
4021
4288
  const errorText = await tokenResponse.text();
4022
- logger4.error(
4289
+ logger5.error(
4023
4290
  {
4024
4291
  status: tokenResponse.status,
4025
4292
  statusText: tokenResponse.statusText,
@@ -4062,8 +4329,8 @@ async function findOrCreateCredential(tenantId, projectId, credentialData) {
4062
4329
  throw new Error(`Failed to save credential '${credentialData.id}' to database`);
4063
4330
  }
4064
4331
  }
4065
- var app17 = new zodOpenapi.OpenAPIHono();
4066
- var logger5 = agentsCore.getLogger("oauth-callback");
4332
+ var app18 = new zodOpenapi.OpenAPIHono();
4333
+ var logger6 = agentsCore.getLogger("oauth-callback");
4067
4334
  function getBaseUrlFromRequest(c) {
4068
4335
  const url = new URL(c.req.url);
4069
4336
  return `${url.protocol}//${url.host}`;
@@ -4149,7 +4416,7 @@ var OAuthCallbackQuerySchema = zodOpenapi.z.object({
4149
4416
  error: zodOpenapi.z.string().optional(),
4150
4417
  error_description: zodOpenapi.z.string().optional()
4151
4418
  });
4152
- app17.openapi(
4419
+ app18.openapi(
4153
4420
  zodOpenapi.createRoute({
4154
4421
  method: "get",
4155
4422
  path: "/login",
@@ -4195,7 +4462,7 @@ app17.openapi(
4195
4462
  try {
4196
4463
  const tool = await agentsCore.getToolById(dbClient_default)({ scopes: { tenantId, projectId }, toolId });
4197
4464
  if (!tool) {
4198
- logger5.error({ toolId, tenantId, projectId }, "Tool not found for OAuth login");
4465
+ logger6.error({ toolId, tenantId, projectId }, "Tool not found for OAuth login");
4199
4466
  return c.text("Tool not found", 404);
4200
4467
  }
4201
4468
  const credentialStores = c.get("credentialStores");
@@ -4210,13 +4477,13 @@ app17.openapi(
4210
4477
  });
4211
4478
  return c.redirect(redirectUrl, 302);
4212
4479
  } catch (error) {
4213
- logger5.error({ toolId, tenantId, projectId, error }, "OAuth login failed");
4480
+ logger6.error({ toolId, tenantId, projectId, error }, "OAuth login failed");
4214
4481
  const errorMessage = error instanceof Error ? error.message : "Failed to initiate OAuth login";
4215
4482
  return c.text(`OAuth Error: ${errorMessage}`, 500);
4216
4483
  }
4217
4484
  }
4218
4485
  );
4219
- app17.openapi(
4486
+ app18.openapi(
4220
4487
  zodOpenapi.createRoute({
4221
4488
  method: "get",
4222
4489
  path: "/callback",
@@ -4252,9 +4519,9 @@ app17.openapi(
4252
4519
  async (c) => {
4253
4520
  try {
4254
4521
  const { code, state, error, error_description } = c.req.valid("query");
4255
- logger5.info({ state, hasCode: !!code }, "OAuth callback received");
4522
+ logger6.info({ state, hasCode: !!code }, "OAuth callback received");
4256
4523
  if (error) {
4257
- logger5.error({ error, error_description }, "OAuth authorization failed");
4524
+ logger6.error({ error, error_description }, "OAuth authorization failed");
4258
4525
  const errorMessage = error_description || error || "OAuth Authorization Failed. Please try again.";
4259
4526
  const errorPage = generateOAuthCallbackPage({
4260
4527
  title: "Authentication Failed",
@@ -4265,7 +4532,7 @@ app17.openapi(
4265
4532
  }
4266
4533
  const pkceData = retrievePKCEVerifier(state);
4267
4534
  if (!pkceData) {
4268
- logger5.error({ state }, "Invalid or expired OAuth state");
4535
+ logger6.error({ state }, "Invalid or expired OAuth state");
4269
4536
  const errorMessage = "OAuth Session Expired: The OAuth session has expired or is invalid. Please try again.";
4270
4537
  const expiredPage = generateOAuthCallbackPage({
4271
4538
  title: "Session Expired",
@@ -4282,8 +4549,8 @@ app17.openapi(
4282
4549
  if (!tool) {
4283
4550
  throw new Error(`Tool ${toolId} not found`);
4284
4551
  }
4285
- logger5.info({ toolId, tenantId, projectId }, "Processing OAuth callback");
4286
- logger5.info({ toolId }, "Exchanging authorization code for access token");
4552
+ logger6.info({ toolId, tenantId, projectId }, "Processing OAuth callback");
4553
+ logger6.info({ toolId }, "Exchanging authorization code for access token");
4287
4554
  const credentialStores = c.get("credentialStores");
4288
4555
  const mcpTool = await agentsCore.dbResultToMcpTool(tool, dbClient_default, credentialStores);
4289
4556
  const baseUrl = getBaseUrlFromRequest(c);
@@ -4294,7 +4561,7 @@ app17.openapi(
4294
4561
  tool: mcpTool,
4295
4562
  baseUrl
4296
4563
  });
4297
- logger5.info(
4564
+ logger6.info(
4298
4565
  { toolId, tokenType: tokens.token_type, hasRefresh: !!tokens.refresh_token },
4299
4566
  "Token exchange successful"
4300
4567
  );
@@ -4341,7 +4608,7 @@ app17.openapi(
4341
4608
  credentialReferenceId: newCredential.id
4342
4609
  }
4343
4610
  });
4344
- logger5.info({ toolId, credentialId: newCredential.id }, "OAuth flow completed successfully");
4611
+ logger6.info({ toolId, credentialId: newCredential.id }, "OAuth flow completed successfully");
4345
4612
  const successPage = generateOAuthCallbackPage({
4346
4613
  title: "Authentication Complete",
4347
4614
  message: "You have been successfully authenticated.",
@@ -4349,7 +4616,7 @@ app17.openapi(
4349
4616
  });
4350
4617
  return c.html(successPage);
4351
4618
  } catch (error) {
4352
- logger5.error({ error }, "OAuth callback processing failed");
4619
+ logger6.error({ error }, "OAuth callback processing failed");
4353
4620
  const errorMessage = "OAuth Processing Failed. Please try again.";
4354
4621
  const errorPage = generateOAuthCallbackPage({
4355
4622
  title: "Processing Failed",
@@ -4360,9 +4627,9 @@ app17.openapi(
4360
4627
  }
4361
4628
  }
4362
4629
  );
4363
- var oauth_default = app17;
4364
- var logger6 = agentsCore.getLogger("projectFull");
4365
- var app18 = new zodOpenapi.OpenAPIHono();
4630
+ var oauth_default = app18;
4631
+ var logger7 = agentsCore.getLogger("projectFull");
4632
+ var app19 = new zodOpenapi.OpenAPIHono();
4366
4633
  var ProjectIdParamsSchema = zod.z.object({
4367
4634
  tenantId: zod.z.string().openapi({
4368
4635
  description: "Tenant identifier",
@@ -4379,7 +4646,7 @@ var TenantParamsSchema2 = zod.z.object({
4379
4646
  example: "tenant_123"
4380
4647
  })
4381
4648
  }).openapi("TenantParams");
4382
- app18.openapi(
4649
+ app19.openapi(
4383
4650
  zodOpenapi.createRoute({
4384
4651
  method: "post",
4385
4652
  path: "/project-full",
@@ -4422,7 +4689,7 @@ app18.openapi(
4422
4689
  const projectData = c.req.valid("json");
4423
4690
  const validatedProjectData = agentsCore.FullProjectDefinitionSchema.parse(projectData);
4424
4691
  try {
4425
- const createdProject = await agentsCore.createFullProjectServerSide(dbClient_default, logger6)(
4692
+ const createdProject = await agentsCore.createFullProjectServerSide(dbClient_default, logger7)(
4426
4693
  { tenantId, projectId: validatedProjectData.id },
4427
4694
  validatedProjectData
4428
4695
  );
@@ -4438,7 +4705,7 @@ app18.openapi(
4438
4705
  }
4439
4706
  }
4440
4707
  );
4441
- app18.openapi(
4708
+ app19.openapi(
4442
4709
  zodOpenapi.createRoute({
4443
4710
  method: "get",
4444
4711
  path: "/project-full/{projectId}",
@@ -4466,7 +4733,7 @@ app18.openapi(
4466
4733
  try {
4467
4734
  const project = await agentsCore.getFullProject(
4468
4735
  dbClient_default,
4469
- logger6
4736
+ logger7
4470
4737
  )({
4471
4738
  scopes: { tenantId, projectId }
4472
4739
  });
@@ -4491,7 +4758,7 @@ app18.openapi(
4491
4758
  }
4492
4759
  }
4493
4760
  );
4494
- app18.openapi(
4761
+ app19.openapi(
4495
4762
  zodOpenapi.createRoute({
4496
4763
  method: "put",
4497
4764
  path: "/project-full/{projectId}",
@@ -4542,15 +4809,15 @@ app18.openapi(
4542
4809
  }
4543
4810
  const existingProject = await agentsCore.getFullProject(
4544
4811
  dbClient_default,
4545
- logger6
4812
+ logger7
4546
4813
  )({
4547
4814
  scopes: { tenantId, projectId }
4548
4815
  });
4549
4816
  const isCreate = !existingProject;
4550
- const updatedProject = isCreate ? await agentsCore.createFullProjectServerSide(dbClient_default, logger6)(
4817
+ const updatedProject = isCreate ? await agentsCore.createFullProjectServerSide(dbClient_default, logger7)(
4551
4818
  { tenantId, projectId },
4552
4819
  validatedProjectData
4553
- ) : await agentsCore.updateFullProjectServerSide(dbClient_default, logger6)(
4820
+ ) : await agentsCore.updateFullProjectServerSide(dbClient_default, logger7)(
4554
4821
  { tenantId, projectId },
4555
4822
  validatedProjectData
4556
4823
  );
@@ -4575,7 +4842,7 @@ app18.openapi(
4575
4842
  }
4576
4843
  }
4577
4844
  );
4578
- app18.openapi(
4845
+ app19.openapi(
4579
4846
  zodOpenapi.createRoute({
4580
4847
  method: "delete",
4581
4848
  path: "/project-full/{projectId}",
@@ -4598,7 +4865,7 @@ app18.openapi(
4598
4865
  try {
4599
4866
  const deleted = await agentsCore.deleteFullProject(
4600
4867
  dbClient_default,
4601
- logger6
4868
+ logger7
4602
4869
  )({
4603
4870
  scopes: { tenantId, projectId }
4604
4871
  });
@@ -4623,20 +4890,20 @@ app18.openapi(
4623
4890
  }
4624
4891
  }
4625
4892
  );
4626
- var projectFull_default = app18;
4893
+ var projectFull_default = app19;
4627
4894
 
4628
4895
  // src/app.ts
4629
- var logger7 = agentsCore.getLogger("agents-manage-api");
4630
- logger7.info({ logger: logger7.getTransports() }, "Logger initialized");
4896
+ var logger8 = agentsCore.getLogger("agents-manage-api");
4897
+ logger8.info({ logger: logger8.getTransports() }, "Logger initialized");
4631
4898
  function createManagementHono(serverConfig, credentialStores) {
4632
- const app20 = new zodOpenapi.OpenAPIHono();
4633
- app20.use("*", requestId.requestId());
4634
- app20.use("*", async (c, next) => {
4899
+ const app21 = new zodOpenapi.OpenAPIHono();
4900
+ app21.use("*", requestId.requestId());
4901
+ app21.use("*", async (c, next) => {
4635
4902
  c.set("serverConfig", serverConfig);
4636
4903
  c.set("credentialStores", credentialStores);
4637
4904
  return next();
4638
4905
  });
4639
- app20.use(
4906
+ app21.use(
4640
4907
  honoPino.pinoLogger({
4641
4908
  pino: agentsCore.getLogger("agents-manage-api").getPinoInstance(),
4642
4909
  http: {
@@ -4649,7 +4916,7 @@ function createManagementHono(serverConfig, credentialStores) {
4649
4916
  }
4650
4917
  })
4651
4918
  );
4652
- app20.onError(async (err, c) => {
4919
+ app21.onError(async (err, c) => {
4653
4920
  const isExpectedError = err instanceof httpException.HTTPException;
4654
4921
  const status = isExpectedError ? err.status : 500;
4655
4922
  const requestId2 = c.get("requestId") || "unknown";
@@ -4682,7 +4949,7 @@ function createManagementHono(serverConfig, credentialStores) {
4682
4949
  if (!isExpectedError) {
4683
4950
  const errorMessage = err instanceof Error ? err.message : String(err);
4684
4951
  const errorStack = err instanceof Error ? err.stack : void 0;
4685
- logger7.error(
4952
+ logger8.error(
4686
4953
  {
4687
4954
  error: err,
4688
4955
  message: errorMessage,
@@ -4693,7 +4960,7 @@ function createManagementHono(serverConfig, credentialStores) {
4693
4960
  "Unexpected server error occurred"
4694
4961
  );
4695
4962
  } else {
4696
- logger7.error(
4963
+ logger8.error(
4697
4964
  {
4698
4965
  error: err,
4699
4966
  path: c.req.path,
@@ -4709,7 +4976,7 @@ function createManagementHono(serverConfig, credentialStores) {
4709
4976
  const response = err.getResponse();
4710
4977
  return response;
4711
4978
  } catch (responseError) {
4712
- logger7.error({ error: responseError }, "Error while handling HTTPException response");
4979
+ logger8.error({ error: responseError }, "Error while handling HTTPException response");
4713
4980
  }
4714
4981
  }
4715
4982
  const { status: respStatus, title, detail, instance } = await agentsCore.handleApiError(err, requestId2);
@@ -4724,7 +4991,7 @@ function createManagementHono(serverConfig, credentialStores) {
4724
4991
  ...instance && { instance }
4725
4992
  });
4726
4993
  });
4727
- app20.use(
4994
+ app21.use(
4728
4995
  "*",
4729
4996
  cors.cors({
4730
4997
  origin: (origin) => {
@@ -4738,7 +5005,7 @@ function createManagementHono(serverConfig, credentialStores) {
4738
5005
  credentials: true
4739
5006
  })
4740
5007
  );
4741
- app20.openapi(
5008
+ app21.openapi(
4742
5009
  zodOpenapi.createRoute({
4743
5010
  method: "get",
4744
5011
  path: "/health",
@@ -4755,13 +5022,13 @@ function createManagementHono(serverConfig, credentialStores) {
4755
5022
  return c.body(null, 204);
4756
5023
  }
4757
5024
  );
4758
- app20.use("/tenants/*", apiKeyAuth());
4759
- app20.route("/tenants/:tenantId", routes_default);
4760
- app20.route("/tenants/:tenantId", projectFull_default);
4761
- app20.route("/oauth", oauth_default);
4762
- setupOpenAPIRoutes(app20);
5025
+ app21.use("/tenants/*", apiKeyAuth());
5026
+ app21.route("/tenants/:tenantId", routes_default);
5027
+ app21.route("/tenants/:tenantId", projectFull_default);
5028
+ app21.route("/oauth", oauth_default);
5029
+ setupOpenAPIRoutes(app21);
4763
5030
  const baseApp = new hono.Hono();
4764
- baseApp.route("/", app20);
5031
+ baseApp.route("/", app21);
4765
5032
  return baseApp;
4766
5033
  }
4767
5034
 
@@ -4777,8 +5044,8 @@ var defaultConfig = {
4777
5044
  };
4778
5045
  var defaultStores = agentsCore.createDefaultCredentialStores();
4779
5046
  var defaultRegistry = new agentsCore.CredentialStoreRegistry(defaultStores);
4780
- var app19 = createManagementHono(defaultConfig, defaultRegistry);
4781
- var index_default = app19;
5047
+ var app20 = createManagementHono(defaultConfig, defaultRegistry);
5048
+ var index_default = app20;
4782
5049
  function createManagementApp(config) {
4783
5050
  const serverConfig = config?.serverConfig ?? defaultConfig;
4784
5051
  const stores = config?.credentialStores ?? defaultStores;