@inkeep/agents-manage-api 0.15.0 → 0.16.1

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 +430 -119
  2. package/dist/index.js +431 -120
  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",
@@ -2037,6 +2037,16 @@ app8.openapi(
2037
2037
  async (c) => {
2038
2038
  const { tenantId, projectId } = c.req.valid("param");
2039
2039
  const body = c.req.valid("json");
2040
+ if (body.props !== null && body.props !== void 0) {
2041
+ const propsValidation = agentsCore.validatePropsAsJsonSchema(body.props);
2042
+ if (!propsValidation.isValid) {
2043
+ const errorMessages = propsValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ");
2044
+ throw agentsCore.createApiError({
2045
+ code: "bad_request",
2046
+ message: `Invalid props schema: ${errorMessages}`
2047
+ });
2048
+ }
2049
+ }
2040
2050
  const finalId = body.id ? String(body.id) : nanoid.nanoid();
2041
2051
  const componentData = {
2042
2052
  tenantId,
@@ -2044,8 +2054,7 @@ app8.openapi(
2044
2054
  id: finalId,
2045
2055
  name: String(body.name),
2046
2056
  description: String(body.description),
2047
- summaryProps: body.summaryProps || void 0,
2048
- fullProps: body.fullProps || void 0
2057
+ props: body.props ?? null
2049
2058
  };
2050
2059
  try {
2051
2060
  const artifactComponent = await agentsCore.createArtifactComponent(dbClient_default)({
@@ -2095,15 +2104,30 @@ app8.openapi(
2095
2104
  async (c) => {
2096
2105
  const { tenantId, projectId, id } = c.req.valid("param");
2097
2106
  const body = c.req.valid("json");
2107
+ if (body.props !== void 0 && body.props !== null) {
2108
+ const propsValidation = agentsCore.validatePropsAsJsonSchema(body.props);
2109
+ if (!propsValidation.isValid) {
2110
+ const errorMessages = propsValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ");
2111
+ throw agentsCore.createApiError({
2112
+ code: "bad_request",
2113
+ message: `Invalid props schema: ${errorMessages}`
2114
+ });
2115
+ }
2116
+ }
2117
+ const updateData = {};
2118
+ if (body.name !== void 0) {
2119
+ updateData.name = String(body.name);
2120
+ }
2121
+ if (body.description !== void 0) {
2122
+ updateData.description = String(body.description);
2123
+ }
2124
+ if (body.props !== void 0) {
2125
+ updateData.props = body.props ?? null;
2126
+ }
2098
2127
  const updatedArtifactComponent = await agentsCore.updateArtifactComponent(dbClient_default)({
2099
2128
  scopes: { tenantId, projectId },
2100
2129
  id,
2101
- data: {
2102
- name: body.name ? String(body.name) : void 0,
2103
- description: body.description ? String(body.description) : void 0,
2104
- summaryProps: body.summaryProps || void 0,
2105
- fullProps: body.fullProps || void 0
2106
- }
2130
+ data: updateData
2107
2131
  });
2108
2132
  if (!updatedArtifactComponent) {
2109
2133
  throw agentsCore.createApiError({
@@ -2686,6 +2710,16 @@ app11.openapi(
2686
2710
  async (c) => {
2687
2711
  const { tenantId, projectId } = c.req.valid("param");
2688
2712
  const body = c.req.valid("json");
2713
+ if (body.props) {
2714
+ const propsValidation = agentsCore.validatePropsAsJsonSchema(body.props);
2715
+ if (!propsValidation.isValid) {
2716
+ const errorMessages = propsValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ");
2717
+ throw agentsCore.createApiError({
2718
+ code: "bad_request",
2719
+ message: `Invalid props schema: ${errorMessages}`
2720
+ });
2721
+ }
2722
+ }
2689
2723
  const dataComponentData = {
2690
2724
  ...body,
2691
2725
  tenantId,
@@ -2727,6 +2761,16 @@ app11.openapi(
2727
2761
  async (c) => {
2728
2762
  const { tenantId, projectId, id } = c.req.valid("param");
2729
2763
  const body = c.req.valid("json");
2764
+ if (body.props !== void 0 && body.props !== null) {
2765
+ const propsValidation = agentsCore.validatePropsAsJsonSchema(body.props);
2766
+ if (!propsValidation.isValid) {
2767
+ const errorMessages = propsValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ");
2768
+ throw agentsCore.createApiError({
2769
+ code: "bad_request",
2770
+ message: `Invalid props schema: ${errorMessages}`
2771
+ });
2772
+ }
2773
+ }
2730
2774
  const updatedDataComponent = await agentsCore.updateDataComponent(dbClient_default)({
2731
2775
  scopes: { tenantId, projectId },
2732
2776
  dataComponentId: id,
@@ -3004,8 +3048,268 @@ app12.openapi(
3004
3048
  }
3005
3049
  );
3006
3050
  var externalAgents_default = app12;
3007
- var logger2 = agentsCore.getLogger("graphFull");
3051
+ var logger2 = agentsCore.getLogger("functions");
3008
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();
3009
3313
  var GraphIdParamsSchema = zod.z.object({
3010
3314
  tenantId: zod.z.string().openapi({
3011
3315
  description: "Tenant identifier",
@@ -3020,7 +3324,7 @@ var GraphIdParamsSchema = zod.z.object({
3020
3324
  example: "graph_789"
3021
3325
  })
3022
3326
  }).openapi("GraphIdParams");
3023
- app13.openapi(
3327
+ app14.openapi(
3024
3328
  zodOpenapi.createRoute({
3025
3329
  method: "post",
3026
3330
  path: "/",
@@ -3062,14 +3366,14 @@ app13.openapi(
3062
3366
  const { tenantId, projectId } = c.req.valid("param");
3063
3367
  const graphData = c.req.valid("json");
3064
3368
  const validatedGraphData = agentsCore.FullGraphDefinitionSchema.parse(graphData);
3065
- const createdGraph = await agentsCore.createFullGraphServerSide(dbClient_default, logger2)(
3369
+ const createdGraph = await agentsCore.createFullGraphServerSide(dbClient_default, logger3)(
3066
3370
  { tenantId, projectId },
3067
3371
  validatedGraphData
3068
3372
  );
3069
3373
  return c.json({ data: createdGraph }, 201);
3070
3374
  }
3071
3375
  );
3072
- app13.openapi(
3376
+ app14.openapi(
3073
3377
  zodOpenapi.createRoute({
3074
3378
  method: "get",
3075
3379
  path: "/{graphId}",
@@ -3097,7 +3401,7 @@ app13.openapi(
3097
3401
  try {
3098
3402
  const graph = await agentsCore.getFullGraph(
3099
3403
  dbClient_default,
3100
- logger2
3404
+ logger3
3101
3405
  )({
3102
3406
  scopes: { tenantId, projectId, graphId }
3103
3407
  });
@@ -3122,7 +3426,7 @@ app13.openapi(
3122
3426
  }
3123
3427
  }
3124
3428
  );
3125
- app13.openapi(
3429
+ app14.openapi(
3126
3430
  zodOpenapi.createRoute({
3127
3431
  method: "put",
3128
3432
  path: "/{graphId}",
@@ -3173,15 +3477,15 @@ app13.openapi(
3173
3477
  }
3174
3478
  const existingGraph = await agentsCore.getFullGraph(
3175
3479
  dbClient_default,
3176
- logger2
3480
+ logger3
3177
3481
  )({
3178
3482
  scopes: { tenantId, projectId, graphId }
3179
3483
  });
3180
3484
  const isCreate = !existingGraph;
3181
- const updatedGraph = isCreate ? await agentsCore.createFullGraphServerSide(dbClient_default, logger2)(
3485
+ const updatedGraph = isCreate ? await agentsCore.createFullGraphServerSide(dbClient_default, logger3)(
3182
3486
  { tenantId, projectId },
3183
3487
  validatedGraphData
3184
- ) : await agentsCore.updateFullGraphServerSide(dbClient_default, logger2)(
3488
+ ) : await agentsCore.updateFullGraphServerSide(dbClient_default, logger3)(
3185
3489
  { tenantId, projectId },
3186
3490
  validatedGraphData
3187
3491
  );
@@ -3206,7 +3510,7 @@ app13.openapi(
3206
3510
  }
3207
3511
  }
3208
3512
  );
3209
- app13.openapi(
3513
+ app14.openapi(
3210
3514
  zodOpenapi.createRoute({
3211
3515
  method: "delete",
3212
3516
  path: "/{graphId}",
@@ -3229,7 +3533,7 @@ app13.openapi(
3229
3533
  try {
3230
3534
  const deleted = await agentsCore.deleteFullGraph(
3231
3535
  dbClient_default,
3232
- logger2
3536
+ logger3
3233
3537
  )({
3234
3538
  scopes: { tenantId, projectId, graphId }
3235
3539
  });
@@ -3254,9 +3558,9 @@ app13.openapi(
3254
3558
  }
3255
3559
  }
3256
3560
  );
3257
- var graphFull_default = app13;
3258
- var app14 = new zodOpenapi.OpenAPIHono();
3259
- app14.openapi(
3561
+ var graphFull_default = app14;
3562
+ var app15 = new zodOpenapi.OpenAPIHono();
3563
+ app15.openapi(
3260
3564
  zodOpenapi.createRoute({
3261
3565
  method: "get",
3262
3566
  path: "/",
@@ -3291,7 +3595,7 @@ app14.openapi(
3291
3595
  return c.json(result);
3292
3596
  }
3293
3597
  );
3294
- app14.openapi(
3598
+ app15.openapi(
3295
3599
  zodOpenapi.createRoute({
3296
3600
  method: "get",
3297
3601
  path: "/{id}",
@@ -3326,7 +3630,7 @@ app14.openapi(
3326
3630
  return c.json({ data: project });
3327
3631
  }
3328
3632
  );
3329
- app14.openapi(
3633
+ app15.openapi(
3330
3634
  zodOpenapi.createRoute({
3331
3635
  method: "post",
3332
3636
  path: "/",
@@ -3384,7 +3688,7 @@ app14.openapi(
3384
3688
  }
3385
3689
  }
3386
3690
  );
3387
- app14.openapi(
3691
+ app15.openapi(
3388
3692
  zodOpenapi.createRoute({
3389
3693
  method: "patch",
3390
3694
  path: "/{id}",
@@ -3430,7 +3734,7 @@ app14.openapi(
3430
3734
  return c.json({ data: project });
3431
3735
  }
3432
3736
  );
3433
- app14.openapi(
3737
+ app15.openapi(
3434
3738
  zodOpenapi.createRoute({
3435
3739
  method: "delete",
3436
3740
  path: "/{id}",
@@ -3480,10 +3784,10 @@ app14.openapi(
3480
3784
  }
3481
3785
  }
3482
3786
  );
3483
- var projects_default = app14;
3484
- var logger3 = agentsCore.getLogger("tools");
3485
- var app15 = new zodOpenapi.OpenAPIHono();
3486
- app15.openapi(
3787
+ var projects_default = app15;
3788
+ var logger4 = agentsCore.getLogger("tools");
3789
+ var app16 = new zodOpenapi.OpenAPIHono();
3790
+ app16.openapi(
3487
3791
  zodOpenapi.createRoute({
3488
3792
  method: "get",
3489
3793
  path: "/",
@@ -3543,7 +3847,7 @@ app15.openapi(
3543
3847
  return c.json(result);
3544
3848
  }
3545
3849
  );
3546
- app15.openapi(
3850
+ app16.openapi(
3547
3851
  zodOpenapi.createRoute({
3548
3852
  method: "get",
3549
3853
  path: "/{id}",
@@ -3580,7 +3884,7 @@ app15.openapi(
3580
3884
  });
3581
3885
  }
3582
3886
  );
3583
- app15.openapi(
3887
+ app16.openapi(
3584
3888
  zodOpenapi.createRoute({
3585
3889
  method: "post",
3586
3890
  path: "/",
@@ -3613,7 +3917,7 @@ app15.openapi(
3613
3917
  const { tenantId, projectId } = c.req.valid("param");
3614
3918
  const body = c.req.valid("json");
3615
3919
  const credentialStores = c.get("credentialStores");
3616
- logger3.info({ body }, "body");
3920
+ logger4.info({ body }, "body");
3617
3921
  const id = body.id || nanoid.nanoid();
3618
3922
  const tool = await agentsCore.createTool(dbClient_default)({
3619
3923
  tenantId,
@@ -3633,7 +3937,7 @@ app15.openapi(
3633
3937
  );
3634
3938
  }
3635
3939
  );
3636
- app15.openapi(
3940
+ app16.openapi(
3637
3941
  zodOpenapi.createRoute({
3638
3942
  method: "put",
3639
3943
  path: "/{id}",
@@ -3694,7 +3998,7 @@ app15.openapi(
3694
3998
  });
3695
3999
  }
3696
4000
  );
3697
- app15.openapi(
4001
+ app16.openapi(
3698
4002
  zodOpenapi.createRoute({
3699
4003
  method: "delete",
3700
4004
  path: "/{id}",
@@ -3730,30 +4034,31 @@ app15.openapi(
3730
4034
  return c.body(null, 204);
3731
4035
  }
3732
4036
  );
3733
- var tools_default = app15;
4037
+ var tools_default = app16;
3734
4038
 
3735
4039
  // src/routes/index.ts
3736
- var app16 = new zodOpenapi.OpenAPIHono();
3737
- app16.route("/projects", projects_default);
3738
- app16.route("/projects/:projectId/graphs/:graphId/agents", agents_default);
3739
- app16.route("/projects/:projectId/graphs/:graphId/agent-relations", agentRelations_default);
3740
- app16.route("/projects/:projectId/agent-graphs", agentGraph_default);
3741
- app16.route("/projects/:projectId/graphs/:graphId/agent-tool-relations", agentToolRelations_default);
3742
- 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(
3743
4047
  "/projects/:projectId/graphs/:graphId/agent-artifact-components",
3744
4048
  agentArtifactComponents_default
3745
4049
  );
3746
- app16.route("/projects/:projectId/graphs/:graphId/agent-data-components", agentDataComponents_default);
3747
- app16.route("/projects/:projectId/artifact-components", artifactComponents_default);
3748
- app16.route("/projects/:projectId/graphs/:graphId/context-configs", contextConfigs_default);
3749
- app16.route("/projects/:projectId/credentials", credentials_default);
3750
- app16.route("/projects/:projectId/data-components", dataComponents_default);
3751
- app16.route("/projects/:projectId/graphs/:graphId/external-agents", externalAgents_default);
3752
- app16.route("/projects/:projectId/tools", tools_default);
3753
- app16.route("/projects/:projectId/api-keys", apiKeys_default);
3754
- app16.route("/projects/:projectId/graph", graphFull_default);
3755
- var routes_default = app16;
3756
- 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");
3757
4062
  var pkceStore = /* @__PURE__ */ new Map();
3758
4063
  function storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId) {
3759
4064
  pkceStore.set(state, { codeVerifier, toolId, tenantId, projectId, clientId });
@@ -3788,7 +4093,10 @@ var OAuthService = class {
3788
4093
  */
3789
4094
  async initiateOAuthFlow(params) {
3790
4095
  const { tool, tenantId, projectId, toolId, baseUrl } = params;
3791
- 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);
3792
4100
  if (!oAuthConfig) {
3793
4101
  throw new Error("OAuth not supported by this server");
3794
4102
  }
@@ -3812,7 +4120,7 @@ var OAuthService = class {
3812
4120
  resource: tool.config.mcp.server.url
3813
4121
  });
3814
4122
  storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId);
3815
- logger4.info({ toolId, oAuthConfig, tenantId, projectId }, "OAuth flow initiated successfully");
4123
+ logger5.info({ toolId, oAuthConfig, tenantId, projectId }, "OAuth flow initiated successfully");
3816
4124
  return {
3817
4125
  redirectUrl: authUrl,
3818
4126
  state
@@ -3823,7 +4131,10 @@ var OAuthService = class {
3823
4131
  */
3824
4132
  async exchangeCodeForTokens(params) {
3825
4133
  const { code, codeVerifier, clientId, tool, baseUrl } = params;
3826
- 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);
3827
4138
  if (!oAuthConfig?.tokenUrl) {
3828
4139
  throw new Error("Could not discover OAuth token endpoint");
3829
4140
  }
@@ -3838,9 +4149,9 @@ var OAuthService = class {
3838
4149
  codeVerifier,
3839
4150
  redirectUri
3840
4151
  });
3841
- 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");
3842
4153
  } catch (error) {
3843
- logger4.warn(
4154
+ logger5.warn(
3844
4155
  { error: error instanceof Error ? error.message : error },
3845
4156
  "openid-client failed, falling back to manual token exchange"
3846
4157
  );
@@ -3851,7 +4162,7 @@ var OAuthService = class {
3851
4162
  codeVerifier,
3852
4163
  redirectUri
3853
4164
  });
3854
- logger4.info({ tokenType: tokens.token_type }, "Manual token exchange successful");
4165
+ logger5.info({ tokenType: tokens.token_type }, "Manual token exchange successful");
3855
4166
  }
3856
4167
  return { tokens, oAuthConfig };
3857
4168
  }
@@ -3859,7 +4170,7 @@ var OAuthService = class {
3859
4170
  * Perform dynamic client registration
3860
4171
  */
3861
4172
  async performDynamicClientRegistration(registrationUrl, redirectUri) {
3862
- logger4.info({ registrationUrl }, "Attempting dynamic client registration");
4173
+ logger5.info({ registrationUrl }, "Attempting dynamic client registration");
3863
4174
  try {
3864
4175
  const registrationResponse = await fetch(registrationUrl, {
3865
4176
  method: "POST",
@@ -3882,11 +4193,11 @@ var OAuthService = class {
3882
4193
  });
3883
4194
  if (registrationResponse.ok) {
3884
4195
  const registration = await registrationResponse.json();
3885
- logger4.info({ clientId: registration.client_id }, "Dynamic client registration successful");
4196
+ logger5.info({ clientId: registration.client_id }, "Dynamic client registration successful");
3886
4197
  return registration.client_id;
3887
4198
  } else {
3888
4199
  const errorText = await registrationResponse.text();
3889
- logger4.warn(
4200
+ logger5.warn(
3890
4201
  {
3891
4202
  status: registrationResponse.status,
3892
4203
  errorText
@@ -3895,7 +4206,7 @@ var OAuthService = class {
3895
4206
  );
3896
4207
  }
3897
4208
  } catch (regError) {
3898
- logger4.warn(
4209
+ logger5.warn(
3899
4210
  { error: regError },
3900
4211
  "Dynamic client registration error, using default client_id"
3901
4212
  );
@@ -3925,7 +4236,7 @@ var OAuthService = class {
3925
4236
  const oauth = await import('openid-client');
3926
4237
  const tokenUrl = new URL(oAuthConfig.tokenUrl);
3927
4238
  const oauthServerUrl = `${tokenUrl.protocol}//${tokenUrl.host}`;
3928
- logger4.info({ oauthServerUrl, clientId }, "Attempting openid-client discovery");
4239
+ logger5.info({ oauthServerUrl, clientId }, "Attempting openid-client discovery");
3929
4240
  const config = await oauth.discovery(
3930
4241
  new URL(oauthServerUrl),
3931
4242
  clientId,
@@ -3957,7 +4268,7 @@ var OAuthService = class {
3957
4268
  */
3958
4269
  async exchangeManually(params) {
3959
4270
  const { oAuthConfig, clientId, code, codeVerifier, redirectUri } = params;
3960
- logger4.info({ tokenUrl: oAuthConfig.tokenUrl }, "Attempting manual token exchange");
4271
+ logger5.info({ tokenUrl: oAuthConfig.tokenUrl }, "Attempting manual token exchange");
3961
4272
  const tokenResponse = await fetch(oAuthConfig.tokenUrl, {
3962
4273
  method: "POST",
3963
4274
  headers: {
@@ -3975,7 +4286,7 @@ var OAuthService = class {
3975
4286
  });
3976
4287
  if (!tokenResponse.ok) {
3977
4288
  const errorText = await tokenResponse.text();
3978
- logger4.error(
4289
+ logger5.error(
3979
4290
  {
3980
4291
  status: tokenResponse.status,
3981
4292
  statusText: tokenResponse.statusText,
@@ -4018,8 +4329,8 @@ async function findOrCreateCredential(tenantId, projectId, credentialData) {
4018
4329
  throw new Error(`Failed to save credential '${credentialData.id}' to database`);
4019
4330
  }
4020
4331
  }
4021
- var app17 = new zodOpenapi.OpenAPIHono();
4022
- var logger5 = agentsCore.getLogger("oauth-callback");
4332
+ var app18 = new zodOpenapi.OpenAPIHono();
4333
+ var logger6 = agentsCore.getLogger("oauth-callback");
4023
4334
  function getBaseUrlFromRequest(c) {
4024
4335
  const url = new URL(c.req.url);
4025
4336
  return `${url.protocol}//${url.host}`;
@@ -4105,7 +4416,7 @@ var OAuthCallbackQuerySchema = zodOpenapi.z.object({
4105
4416
  error: zodOpenapi.z.string().optional(),
4106
4417
  error_description: zodOpenapi.z.string().optional()
4107
4418
  });
4108
- app17.openapi(
4419
+ app18.openapi(
4109
4420
  zodOpenapi.createRoute({
4110
4421
  method: "get",
4111
4422
  path: "/login",
@@ -4151,7 +4462,7 @@ app17.openapi(
4151
4462
  try {
4152
4463
  const tool = await agentsCore.getToolById(dbClient_default)({ scopes: { tenantId, projectId }, toolId });
4153
4464
  if (!tool) {
4154
- logger5.error({ toolId, tenantId, projectId }, "Tool not found for OAuth login");
4465
+ logger6.error({ toolId, tenantId, projectId }, "Tool not found for OAuth login");
4155
4466
  return c.text("Tool not found", 404);
4156
4467
  }
4157
4468
  const credentialStores = c.get("credentialStores");
@@ -4166,13 +4477,13 @@ app17.openapi(
4166
4477
  });
4167
4478
  return c.redirect(redirectUrl, 302);
4168
4479
  } catch (error) {
4169
- logger5.error({ toolId, tenantId, projectId, error }, "OAuth login failed");
4480
+ logger6.error({ toolId, tenantId, projectId, error }, "OAuth login failed");
4170
4481
  const errorMessage = error instanceof Error ? error.message : "Failed to initiate OAuth login";
4171
4482
  return c.text(`OAuth Error: ${errorMessage}`, 500);
4172
4483
  }
4173
4484
  }
4174
4485
  );
4175
- app17.openapi(
4486
+ app18.openapi(
4176
4487
  zodOpenapi.createRoute({
4177
4488
  method: "get",
4178
4489
  path: "/callback",
@@ -4208,9 +4519,9 @@ app17.openapi(
4208
4519
  async (c) => {
4209
4520
  try {
4210
4521
  const { code, state, error, error_description } = c.req.valid("query");
4211
- logger5.info({ state, hasCode: !!code }, "OAuth callback received");
4522
+ logger6.info({ state, hasCode: !!code }, "OAuth callback received");
4212
4523
  if (error) {
4213
- logger5.error({ error, error_description }, "OAuth authorization failed");
4524
+ logger6.error({ error, error_description }, "OAuth authorization failed");
4214
4525
  const errorMessage = error_description || error || "OAuth Authorization Failed. Please try again.";
4215
4526
  const errorPage = generateOAuthCallbackPage({
4216
4527
  title: "Authentication Failed",
@@ -4221,7 +4532,7 @@ app17.openapi(
4221
4532
  }
4222
4533
  const pkceData = retrievePKCEVerifier(state);
4223
4534
  if (!pkceData) {
4224
- logger5.error({ state }, "Invalid or expired OAuth state");
4535
+ logger6.error({ state }, "Invalid or expired OAuth state");
4225
4536
  const errorMessage = "OAuth Session Expired: The OAuth session has expired or is invalid. Please try again.";
4226
4537
  const expiredPage = generateOAuthCallbackPage({
4227
4538
  title: "Session Expired",
@@ -4238,8 +4549,8 @@ app17.openapi(
4238
4549
  if (!tool) {
4239
4550
  throw new Error(`Tool ${toolId} not found`);
4240
4551
  }
4241
- logger5.info({ toolId, tenantId, projectId }, "Processing OAuth callback");
4242
- 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");
4243
4554
  const credentialStores = c.get("credentialStores");
4244
4555
  const mcpTool = await agentsCore.dbResultToMcpTool(tool, dbClient_default, credentialStores);
4245
4556
  const baseUrl = getBaseUrlFromRequest(c);
@@ -4250,7 +4561,7 @@ app17.openapi(
4250
4561
  tool: mcpTool,
4251
4562
  baseUrl
4252
4563
  });
4253
- logger5.info(
4564
+ logger6.info(
4254
4565
  { toolId, tokenType: tokens.token_type, hasRefresh: !!tokens.refresh_token },
4255
4566
  "Token exchange successful"
4256
4567
  );
@@ -4297,7 +4608,7 @@ app17.openapi(
4297
4608
  credentialReferenceId: newCredential.id
4298
4609
  }
4299
4610
  });
4300
- logger5.info({ toolId, credentialId: newCredential.id }, "OAuth flow completed successfully");
4611
+ logger6.info({ toolId, credentialId: newCredential.id }, "OAuth flow completed successfully");
4301
4612
  const successPage = generateOAuthCallbackPage({
4302
4613
  title: "Authentication Complete",
4303
4614
  message: "You have been successfully authenticated.",
@@ -4305,7 +4616,7 @@ app17.openapi(
4305
4616
  });
4306
4617
  return c.html(successPage);
4307
4618
  } catch (error) {
4308
- logger5.error({ error }, "OAuth callback processing failed");
4619
+ logger6.error({ error }, "OAuth callback processing failed");
4309
4620
  const errorMessage = "OAuth Processing Failed. Please try again.";
4310
4621
  const errorPage = generateOAuthCallbackPage({
4311
4622
  title: "Processing Failed",
@@ -4316,9 +4627,9 @@ app17.openapi(
4316
4627
  }
4317
4628
  }
4318
4629
  );
4319
- var oauth_default = app17;
4320
- var logger6 = agentsCore.getLogger("projectFull");
4321
- var app18 = new zodOpenapi.OpenAPIHono();
4630
+ var oauth_default = app18;
4631
+ var logger7 = agentsCore.getLogger("projectFull");
4632
+ var app19 = new zodOpenapi.OpenAPIHono();
4322
4633
  var ProjectIdParamsSchema = zod.z.object({
4323
4634
  tenantId: zod.z.string().openapi({
4324
4635
  description: "Tenant identifier",
@@ -4335,7 +4646,7 @@ var TenantParamsSchema2 = zod.z.object({
4335
4646
  example: "tenant_123"
4336
4647
  })
4337
4648
  }).openapi("TenantParams");
4338
- app18.openapi(
4649
+ app19.openapi(
4339
4650
  zodOpenapi.createRoute({
4340
4651
  method: "post",
4341
4652
  path: "/project-full",
@@ -4378,7 +4689,7 @@ app18.openapi(
4378
4689
  const projectData = c.req.valid("json");
4379
4690
  const validatedProjectData = agentsCore.FullProjectDefinitionSchema.parse(projectData);
4380
4691
  try {
4381
- const createdProject = await agentsCore.createFullProjectServerSide(dbClient_default, logger6)(
4692
+ const createdProject = await agentsCore.createFullProjectServerSide(dbClient_default, logger7)(
4382
4693
  { tenantId, projectId: validatedProjectData.id },
4383
4694
  validatedProjectData
4384
4695
  );
@@ -4394,7 +4705,7 @@ app18.openapi(
4394
4705
  }
4395
4706
  }
4396
4707
  );
4397
- app18.openapi(
4708
+ app19.openapi(
4398
4709
  zodOpenapi.createRoute({
4399
4710
  method: "get",
4400
4711
  path: "/project-full/{projectId}",
@@ -4422,7 +4733,7 @@ app18.openapi(
4422
4733
  try {
4423
4734
  const project = await agentsCore.getFullProject(
4424
4735
  dbClient_default,
4425
- logger6
4736
+ logger7
4426
4737
  )({
4427
4738
  scopes: { tenantId, projectId }
4428
4739
  });
@@ -4447,7 +4758,7 @@ app18.openapi(
4447
4758
  }
4448
4759
  }
4449
4760
  );
4450
- app18.openapi(
4761
+ app19.openapi(
4451
4762
  zodOpenapi.createRoute({
4452
4763
  method: "put",
4453
4764
  path: "/project-full/{projectId}",
@@ -4498,15 +4809,15 @@ app18.openapi(
4498
4809
  }
4499
4810
  const existingProject = await agentsCore.getFullProject(
4500
4811
  dbClient_default,
4501
- logger6
4812
+ logger7
4502
4813
  )({
4503
4814
  scopes: { tenantId, projectId }
4504
4815
  });
4505
4816
  const isCreate = !existingProject;
4506
- const updatedProject = isCreate ? await agentsCore.createFullProjectServerSide(dbClient_default, logger6)(
4817
+ const updatedProject = isCreate ? await agentsCore.createFullProjectServerSide(dbClient_default, logger7)(
4507
4818
  { tenantId, projectId },
4508
4819
  validatedProjectData
4509
- ) : await agentsCore.updateFullProjectServerSide(dbClient_default, logger6)(
4820
+ ) : await agentsCore.updateFullProjectServerSide(dbClient_default, logger7)(
4510
4821
  { tenantId, projectId },
4511
4822
  validatedProjectData
4512
4823
  );
@@ -4531,7 +4842,7 @@ app18.openapi(
4531
4842
  }
4532
4843
  }
4533
4844
  );
4534
- app18.openapi(
4845
+ app19.openapi(
4535
4846
  zodOpenapi.createRoute({
4536
4847
  method: "delete",
4537
4848
  path: "/project-full/{projectId}",
@@ -4554,7 +4865,7 @@ app18.openapi(
4554
4865
  try {
4555
4866
  const deleted = await agentsCore.deleteFullProject(
4556
4867
  dbClient_default,
4557
- logger6
4868
+ logger7
4558
4869
  )({
4559
4870
  scopes: { tenantId, projectId }
4560
4871
  });
@@ -4579,20 +4890,20 @@ app18.openapi(
4579
4890
  }
4580
4891
  }
4581
4892
  );
4582
- var projectFull_default = app18;
4893
+ var projectFull_default = app19;
4583
4894
 
4584
4895
  // src/app.ts
4585
- var logger7 = agentsCore.getLogger("agents-manage-api");
4586
- logger7.info({ logger: logger7.getTransports() }, "Logger initialized");
4896
+ var logger8 = agentsCore.getLogger("agents-manage-api");
4897
+ logger8.info({ logger: logger8.getTransports() }, "Logger initialized");
4587
4898
  function createManagementHono(serverConfig, credentialStores) {
4588
- const app20 = new zodOpenapi.OpenAPIHono();
4589
- app20.use("*", requestId.requestId());
4590
- app20.use("*", async (c, next) => {
4899
+ const app21 = new zodOpenapi.OpenAPIHono();
4900
+ app21.use("*", requestId.requestId());
4901
+ app21.use("*", async (c, next) => {
4591
4902
  c.set("serverConfig", serverConfig);
4592
4903
  c.set("credentialStores", credentialStores);
4593
4904
  return next();
4594
4905
  });
4595
- app20.use(
4906
+ app21.use(
4596
4907
  honoPino.pinoLogger({
4597
4908
  pino: agentsCore.getLogger("agents-manage-api").getPinoInstance(),
4598
4909
  http: {
@@ -4605,7 +4916,7 @@ function createManagementHono(serverConfig, credentialStores) {
4605
4916
  }
4606
4917
  })
4607
4918
  );
4608
- app20.onError(async (err, c) => {
4919
+ app21.onError(async (err, c) => {
4609
4920
  const isExpectedError = err instanceof httpException.HTTPException;
4610
4921
  const status = isExpectedError ? err.status : 500;
4611
4922
  const requestId2 = c.get("requestId") || "unknown";
@@ -4638,7 +4949,7 @@ function createManagementHono(serverConfig, credentialStores) {
4638
4949
  if (!isExpectedError) {
4639
4950
  const errorMessage = err instanceof Error ? err.message : String(err);
4640
4951
  const errorStack = err instanceof Error ? err.stack : void 0;
4641
- logger7.error(
4952
+ logger8.error(
4642
4953
  {
4643
4954
  error: err,
4644
4955
  message: errorMessage,
@@ -4649,7 +4960,7 @@ function createManagementHono(serverConfig, credentialStores) {
4649
4960
  "Unexpected server error occurred"
4650
4961
  );
4651
4962
  } else {
4652
- logger7.error(
4963
+ logger8.error(
4653
4964
  {
4654
4965
  error: err,
4655
4966
  path: c.req.path,
@@ -4665,7 +4976,7 @@ function createManagementHono(serverConfig, credentialStores) {
4665
4976
  const response = err.getResponse();
4666
4977
  return response;
4667
4978
  } catch (responseError) {
4668
- logger7.error({ error: responseError }, "Error while handling HTTPException response");
4979
+ logger8.error({ error: responseError }, "Error while handling HTTPException response");
4669
4980
  }
4670
4981
  }
4671
4982
  const { status: respStatus, title, detail, instance } = await agentsCore.handleApiError(err, requestId2);
@@ -4680,7 +4991,7 @@ function createManagementHono(serverConfig, credentialStores) {
4680
4991
  ...instance && { instance }
4681
4992
  });
4682
4993
  });
4683
- app20.use(
4994
+ app21.use(
4684
4995
  "*",
4685
4996
  cors.cors({
4686
4997
  origin: (origin) => {
@@ -4694,7 +5005,7 @@ function createManagementHono(serverConfig, credentialStores) {
4694
5005
  credentials: true
4695
5006
  })
4696
5007
  );
4697
- app20.openapi(
5008
+ app21.openapi(
4698
5009
  zodOpenapi.createRoute({
4699
5010
  method: "get",
4700
5011
  path: "/health",
@@ -4711,13 +5022,13 @@ function createManagementHono(serverConfig, credentialStores) {
4711
5022
  return c.body(null, 204);
4712
5023
  }
4713
5024
  );
4714
- app20.use("/tenants/*", apiKeyAuth());
4715
- app20.route("/tenants/:tenantId", routes_default);
4716
- app20.route("/tenants/:tenantId", projectFull_default);
4717
- app20.route("/oauth", oauth_default);
4718
- 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);
4719
5030
  const baseApp = new hono.Hono();
4720
- baseApp.route("/", app20);
5031
+ baseApp.route("/", app21);
4721
5032
  return baseApp;
4722
5033
  }
4723
5034
 
@@ -4733,8 +5044,8 @@ var defaultConfig = {
4733
5044
  };
4734
5045
  var defaultStores = agentsCore.createDefaultCredentialStores();
4735
5046
  var defaultRegistry = new agentsCore.CredentialStoreRegistry(defaultStores);
4736
- var app19 = createManagementHono(defaultConfig, defaultRegistry);
4737
- var index_default = app19;
5047
+ var app20 = createManagementHono(defaultConfig, defaultRegistry);
5048
+ var index_default = app20;
4738
5049
  function createManagementApp(config) {
4739
5050
  const serverConfig = config?.serverConfig ?? defaultConfig;
4740
5051
  const stores = config?.credentialStores ?? defaultStores;