@inkeep/agents-manage-api 0.14.16 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +448 -133
  2. package/dist/index.js +449 -134
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { loadEnvironmentFiles, getLogger, createDatabaseClient, commonGetErrorResponses, TenantProjectGraphParamsSchema, ArtifactComponentApiSelectSchema, getArtifactComponentsForAgent, getAgentsUsingArtifactComponent, ErrorResponseSchema, SingleResponseSchema, AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiSelectSchema, getAgentById, getArtifactComponentById, createApiError, isArtifactComponentAssociatedWithAgent, associateArtifactComponentWithAgent, RemovedResponseSchema, removeArtifactComponentFromAgent, ExistsResponseSchema, DataComponentApiSelectSchema, getDataComponentsForAgent, getAgentsUsingDataComponent, AgentDataComponentApiInsertSchema, AgentDataComponentApiSelectSchema, getDataComponent, isDataComponentAssociatedWithAgent, associateDataComponentWithAgent, removeDataComponentFromAgent, ListResponseSchema, PaginationQueryParamsSchema, TenantProjectParamsSchema, AgentGraphApiSelectSchema, listAgentGraphs, IdParamsSchema, getAgentGraphById, getGraphAgentInfos, FullGraphDefinitionSchema, getFullGraphDefinition, AgentGraphApiInsertSchema, createAgentGraph, AgentGraphApiUpdateSchema, updateAgentGraph, deleteAgentGraph, AgentRelationApiSelectSchema, AgentRelationQuerySchema, getAgentRelationsBySource, getAgentRelationsByTarget, getExternalAgentRelations, listAgentRelations, TenantProjectGraphIdParamsSchema, getAgentRelationById, AgentRelationApiInsertSchema, validateExternalAgent, validateInternalAgent, createAgentRelation, AgentRelationApiUpdateSchema, updateAgentRelation, deleteAgentRelation, AgentApiSelectSchema, listAgentsPaginated, AgentApiInsertSchema, createAgent, AgentApiUpdateSchema, updateAgent, deleteAgent, AgentToolRelationApiSelectSchema, getAgentToolRelationByAgent, getAgentToolRelationByTool, listAgentToolRelations, getAgentToolRelationById, getAgentsForTool, AgentToolRelationApiInsertSchema, createAgentToolRelation, AgentToolRelationApiUpdateSchema, updateAgentToolRelation, deleteAgentToolRelation, ApiKeyApiSelectSchema, listApiKeysPaginated, getApiKeyById, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, generateApiKey, createApiKey, ApiKeyApiUpdateSchema, updateApiKey, deleteApiKey, listArtifactComponentsPaginated, ArtifactComponentApiInsertSchema, createArtifactComponent, ArtifactComponentApiUpdateSchema, updateArtifactComponent, deleteArtifactComponent, ContextConfigApiSelectSchema, listContextConfigsPaginated, getContextConfigById, ContextConfigApiInsertSchema, createContextConfig, commonUpdateErrorResponses, ContextConfigApiUpdateSchema, updateContextConfig, commonDeleteErrorResponses, deleteContextConfig, CredentialReferenceApiSelectSchema, listCredentialReferencesPaginated, getCredentialReferenceWithTools, CredentialReferenceApiInsertSchema, createCredentialReference, CredentialReferenceApiUpdateSchema, updateCredentialReference, getCredentialReferenceById, getCredentialStoreLookupKeyFromRetrievalParams, deleteCredentialReference, listDataComponentsPaginated, DataComponentApiInsertSchema, createDataComponent, DataComponentApiUpdateSchema, updateDataComponent, deleteDataComponent, ExternalAgentApiSelectSchema, listExternalAgentsPaginated, getExternalAgent, ExternalAgentApiInsertSchema, createExternalAgent, ExternalAgentApiUpdateSchema, updateExternalAgent, deleteExternalAgent, createFullGraphServerSide, getFullGraph, updateFullGraphServerSide, deleteFullGraph, TenantParamsSchema, ProjectApiSelectSchema, listProjectsPaginated, TenantIdParamsSchema, getProject, ProjectApiInsertSchema, createProject, ProjectApiUpdateSchema, updateProject, deleteProject, McpToolSchema, ToolStatusSchema, listTools, dbResultToMcpTool, getToolById, ToolApiInsertSchema, createTool, ToolApiUpdateSchema, updateTool, deleteTool, CredentialStoreType, generateIdFromName, FullProjectDefinitionSchema, createFullProjectServerSide, getFullProject, updateFullProjectServerSide, deleteFullProject, createDefaultCredentialStores, CredentialStoreRegistry, discoverOAuthEndpoints, handleApiError } from '@inkeep/agents-core';
1
+ import { loadEnvironmentFiles, getLogger, createDatabaseClient, commonGetErrorResponses, TenantProjectGraphParamsSchema, ArtifactComponentApiSelectSchema, getArtifactComponentsForAgent, getAgentsUsingArtifactComponent, ErrorResponseSchema, SingleResponseSchema, AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiSelectSchema, getAgentById, getArtifactComponentById, createApiError, isArtifactComponentAssociatedWithAgent, associateArtifactComponentWithAgent, RemovedResponseSchema, removeArtifactComponentFromAgent, ExistsResponseSchema, DataComponentApiSelectSchema, getDataComponentsForAgent, getAgentsUsingDataComponent, AgentDataComponentApiInsertSchema, AgentDataComponentApiSelectSchema, getDataComponent, isDataComponentAssociatedWithAgent, associateDataComponentWithAgent, removeDataComponentFromAgent, ListResponseSchema, PaginationQueryParamsSchema, TenantProjectParamsSchema, AgentGraphApiSelectSchema, listAgentGraphs, IdParamsSchema, getAgentGraphById, getGraphAgentInfos, FullGraphDefinitionSchema, getFullGraphDefinition, AgentGraphApiInsertSchema, createAgentGraph, AgentGraphApiUpdateSchema, updateAgentGraph, deleteAgentGraph, AgentRelationApiSelectSchema, AgentRelationQuerySchema, getAgentRelationsBySource, getAgentRelationsByTarget, getExternalAgentRelations, listAgentRelations, TenantProjectGraphIdParamsSchema, getAgentRelationById, AgentRelationApiInsertSchema, validateExternalAgent, validateInternalAgent, createAgentRelation, AgentRelationApiUpdateSchema, updateAgentRelation, deleteAgentRelation, AgentApiSelectSchema, listAgentsPaginated, AgentApiInsertSchema, createAgent, AgentApiUpdateSchema, updateAgent, deleteAgent, AgentToolRelationApiSelectSchema, getAgentToolRelationByAgent, getAgentToolRelationByTool, listAgentToolRelations, getAgentToolRelationById, getAgentsForTool, AgentToolRelationApiInsertSchema, createAgentToolRelation, AgentToolRelationApiUpdateSchema, updateAgentToolRelation, deleteAgentToolRelation, ApiKeyApiSelectSchema, listApiKeysPaginated, getApiKeyById, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, generateApiKey, createApiKey, ApiKeyApiUpdateSchema, updateApiKey, deleteApiKey, listArtifactComponentsPaginated, ArtifactComponentApiInsertSchema, validatePropsAsJsonSchema, createArtifactComponent, ArtifactComponentApiUpdateSchema, updateArtifactComponent, deleteArtifactComponent, ContextConfigApiSelectSchema, listContextConfigsPaginated, getContextConfigById, ContextConfigApiInsertSchema, createContextConfig, commonUpdateErrorResponses, ContextConfigApiUpdateSchema, updateContextConfig, commonDeleteErrorResponses, deleteContextConfig, CredentialReferenceApiSelectSchema, listCredentialReferencesPaginated, getCredentialReferenceWithTools, CredentialReferenceApiInsertSchema, createCredentialReference, CredentialReferenceApiUpdateSchema, updateCredentialReference, getCredentialReferenceById, getCredentialStoreLookupKeyFromRetrievalParams, deleteCredentialReference, listDataComponentsPaginated, DataComponentApiInsertSchema, createDataComponent, DataComponentApiUpdateSchema, updateDataComponent, deleteDataComponent, ExternalAgentApiSelectSchema, listExternalAgentsPaginated, getExternalAgent, ExternalAgentApiInsertSchema, createExternalAgent, ExternalAgentApiUpdateSchema, updateExternalAgent, deleteExternalAgent, FunctionApiSelectSchema, listFunctions, getFunction, FunctionApiInsertSchema, upsertFunction, FunctionApiUpdateSchema, deleteFunction, createFullGraphServerSide, getFullGraph, updateFullGraphServerSide, deleteFullGraph, TenantParamsSchema, ProjectApiSelectSchema, listProjectsPaginated, TenantIdParamsSchema, getProject, ProjectApiInsertSchema, createProject, ProjectApiUpdateSchema, updateProject, deleteProject, McpToolSchema, ToolStatusSchema, listTools, dbResultToMcpTool, getToolById, ToolApiInsertSchema, createTool, ToolApiUpdateSchema, updateTool, deleteTool, CredentialStoreType, generateIdFromName, FullProjectDefinitionSchema, createFullProjectServerSide, getFullProject, updateFullProjectServerSide, deleteFullProject, createDefaultCredentialStores, CredentialStoreRegistry, discoverOAuthEndpoints, handleApiError } from '@inkeep/agents-core';
2
2
  import { OpenAPIHono, createRoute, z as z$1 } from '@hono/zod-openapi';
3
3
  import { Hono } from 'hono';
4
4
  import { cors } from 'hono/cors';
@@ -66,10 +66,10 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
66
66
  await next();
67
67
  return;
68
68
  });
69
- function setupOpenAPIRoutes(app20) {
70
- app20.get("/openapi.json", (c) => {
69
+ function setupOpenAPIRoutes(app21) {
70
+ app21.get("/openapi.json", (c) => {
71
71
  try {
72
- const document = app20.getOpenAPIDocument({
72
+ const document = app21.getOpenAPIDocument({
73
73
  openapi: "3.0.0",
74
74
  info: {
75
75
  title: "Inkeep Agents Manage API",
@@ -90,7 +90,7 @@ function setupOpenAPIRoutes(app20) {
90
90
  return c.json({ error: "Failed to generate OpenAPI document", details: errorDetails }, 500);
91
91
  }
92
92
  });
93
- app20.get(
93
+ app21.get(
94
94
  "/docs",
95
95
  swaggerUI({
96
96
  url: "/openapi.json",
@@ -2033,6 +2033,16 @@ app8.openapi(
2033
2033
  async (c) => {
2034
2034
  const { tenantId, projectId } = c.req.valid("param");
2035
2035
  const body = c.req.valid("json");
2036
+ if (body.props !== null && body.props !== void 0) {
2037
+ const propsValidation = validatePropsAsJsonSchema(body.props);
2038
+ if (!propsValidation.isValid) {
2039
+ const errorMessages = propsValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ");
2040
+ throw createApiError({
2041
+ code: "bad_request",
2042
+ message: `Invalid props schema: ${errorMessages}`
2043
+ });
2044
+ }
2045
+ }
2036
2046
  const finalId = body.id ? String(body.id) : nanoid();
2037
2047
  const componentData = {
2038
2048
  tenantId,
@@ -2040,8 +2050,7 @@ app8.openapi(
2040
2050
  id: finalId,
2041
2051
  name: String(body.name),
2042
2052
  description: String(body.description),
2043
- summaryProps: body.summaryProps || void 0,
2044
- fullProps: body.fullProps || void 0
2053
+ props: body.props ?? null
2045
2054
  };
2046
2055
  try {
2047
2056
  const artifactComponent = await createArtifactComponent(dbClient_default)({
@@ -2091,15 +2100,30 @@ app8.openapi(
2091
2100
  async (c) => {
2092
2101
  const { tenantId, projectId, id } = c.req.valid("param");
2093
2102
  const body = c.req.valid("json");
2103
+ if (body.props !== void 0 && body.props !== null) {
2104
+ const propsValidation = validatePropsAsJsonSchema(body.props);
2105
+ if (!propsValidation.isValid) {
2106
+ const errorMessages = propsValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ");
2107
+ throw createApiError({
2108
+ code: "bad_request",
2109
+ message: `Invalid props schema: ${errorMessages}`
2110
+ });
2111
+ }
2112
+ }
2113
+ const updateData = {};
2114
+ if (body.name !== void 0) {
2115
+ updateData.name = String(body.name);
2116
+ }
2117
+ if (body.description !== void 0) {
2118
+ updateData.description = String(body.description);
2119
+ }
2120
+ if (body.props !== void 0) {
2121
+ updateData.props = body.props ?? null;
2122
+ }
2094
2123
  const updatedArtifactComponent = await updateArtifactComponent(dbClient_default)({
2095
2124
  scopes: { tenantId, projectId },
2096
2125
  id,
2097
- data: {
2098
- name: body.name ? String(body.name) : void 0,
2099
- description: body.description ? String(body.description) : void 0,
2100
- summaryProps: body.summaryProps || void 0,
2101
- fullProps: body.fullProps || void 0
2102
- }
2126
+ data: updateData
2103
2127
  });
2104
2128
  if (!updatedArtifactComponent) {
2105
2129
  throw createApiError({
@@ -2159,7 +2183,7 @@ app9.openapi(
2159
2183
  operationId: "list-context-configs",
2160
2184
  tags: ["Context Config"],
2161
2185
  request: {
2162
- params: TenantProjectParamsSchema,
2186
+ params: TenantProjectGraphParamsSchema,
2163
2187
  query: PaginationQueryParamsSchema
2164
2188
  },
2165
2189
  responses: {
@@ -2175,11 +2199,11 @@ app9.openapi(
2175
2199
  }
2176
2200
  }),
2177
2201
  async (c) => {
2178
- const { tenantId, projectId } = c.req.valid("param");
2202
+ const { tenantId, projectId, graphId } = c.req.valid("param");
2179
2203
  const page = Number(c.req.query("page")) || 1;
2180
2204
  const limit = Math.min(Number(c.req.query("limit")) || 10, 100);
2181
2205
  const result = await listContextConfigsPaginated(dbClient_default)({
2182
- scopes: { tenantId, projectId },
2206
+ scopes: { tenantId, projectId, graphId },
2183
2207
  pagination: { page, limit }
2184
2208
  });
2185
2209
  return c.json(result);
@@ -2193,7 +2217,7 @@ app9.openapi(
2193
2217
  operationId: "get-context-config-by-id",
2194
2218
  tags: ["Context Config"],
2195
2219
  request: {
2196
- params: TenantProjectParamsSchema.merge(IdParamsSchema)
2220
+ params: TenantProjectGraphParamsSchema.merge(IdParamsSchema)
2197
2221
  },
2198
2222
  responses: {
2199
2223
  200: {
@@ -2208,9 +2232,9 @@ app9.openapi(
2208
2232
  }
2209
2233
  }),
2210
2234
  async (c) => {
2211
- const { tenantId, projectId, id } = c.req.valid("param");
2235
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
2212
2236
  const contextConfig = await getContextConfigById(dbClient_default)({
2213
- scopes: { tenantId, projectId },
2237
+ scopes: { tenantId, projectId, graphId },
2214
2238
  id
2215
2239
  });
2216
2240
  if (!contextConfig) {
@@ -2230,7 +2254,7 @@ app9.openapi(
2230
2254
  operationId: "create-context-config",
2231
2255
  tags: ["Context Config"],
2232
2256
  request: {
2233
- params: TenantProjectParamsSchema,
2257
+ params: TenantProjectGraphParamsSchema,
2234
2258
  body: {
2235
2259
  content: {
2236
2260
  "application/json": {
@@ -2252,11 +2276,12 @@ app9.openapi(
2252
2276
  }
2253
2277
  }),
2254
2278
  async (c) => {
2255
- const { tenantId, projectId } = c.req.valid("param");
2279
+ const { tenantId, projectId, graphId } = c.req.valid("param");
2256
2280
  const body = c.req.valid("json");
2257
2281
  const configData = {
2258
2282
  tenantId,
2259
2283
  projectId,
2284
+ graphId,
2260
2285
  ...body
2261
2286
  };
2262
2287
  const contextConfig = await createContextConfig(dbClient_default)(configData);
@@ -2271,7 +2296,7 @@ app9.openapi(
2271
2296
  operationId: "update-context-config",
2272
2297
  tags: ["Context Config"],
2273
2298
  request: {
2274
- params: TenantProjectParamsSchema.merge(IdParamsSchema),
2299
+ params: TenantProjectGraphParamsSchema.merge(IdParamsSchema),
2275
2300
  body: {
2276
2301
  content: {
2277
2302
  "application/json": {
@@ -2293,10 +2318,10 @@ app9.openapi(
2293
2318
  }
2294
2319
  }),
2295
2320
  async (c) => {
2296
- const { tenantId, projectId, id } = c.req.valid("param");
2321
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
2297
2322
  const body = c.req.valid("json");
2298
2323
  const updatedContextConfig = await updateContextConfig(dbClient_default)({
2299
- scopes: { tenantId, projectId },
2324
+ scopes: { tenantId, projectId, graphId },
2300
2325
  id,
2301
2326
  data: body
2302
2327
  });
@@ -2317,7 +2342,7 @@ app9.openapi(
2317
2342
  operationId: "delete-context-config",
2318
2343
  tags: ["Context Config"],
2319
2344
  request: {
2320
- params: TenantProjectParamsSchema.merge(IdParamsSchema)
2345
+ params: TenantProjectGraphParamsSchema.merge(IdParamsSchema)
2321
2346
  },
2322
2347
  responses: {
2323
2348
  204: {
@@ -2327,9 +2352,9 @@ app9.openapi(
2327
2352
  }
2328
2353
  }),
2329
2354
  async (c) => {
2330
- const { tenantId, projectId, id } = c.req.valid("param");
2355
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
2331
2356
  const deleted = await deleteContextConfig(dbClient_default)({
2332
- scopes: { tenantId, projectId },
2357
+ scopes: { tenantId, projectId, graphId },
2333
2358
  id
2334
2359
  });
2335
2360
  if (!deleted) {
@@ -2681,6 +2706,16 @@ app11.openapi(
2681
2706
  async (c) => {
2682
2707
  const { tenantId, projectId } = c.req.valid("param");
2683
2708
  const body = c.req.valid("json");
2709
+ if (body.props) {
2710
+ const propsValidation = validatePropsAsJsonSchema(body.props);
2711
+ if (!propsValidation.isValid) {
2712
+ const errorMessages = propsValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ");
2713
+ throw createApiError({
2714
+ code: "bad_request",
2715
+ message: `Invalid props schema: ${errorMessages}`
2716
+ });
2717
+ }
2718
+ }
2684
2719
  const dataComponentData = {
2685
2720
  ...body,
2686
2721
  tenantId,
@@ -2722,6 +2757,16 @@ app11.openapi(
2722
2757
  async (c) => {
2723
2758
  const { tenantId, projectId, id } = c.req.valid("param");
2724
2759
  const body = c.req.valid("json");
2760
+ if (body.props !== void 0 && body.props !== null) {
2761
+ const propsValidation = validatePropsAsJsonSchema(body.props);
2762
+ if (!propsValidation.isValid) {
2763
+ const errorMessages = propsValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ");
2764
+ throw createApiError({
2765
+ code: "bad_request",
2766
+ message: `Invalid props schema: ${errorMessages}`
2767
+ });
2768
+ }
2769
+ }
2725
2770
  const updatedDataComponent = await updateDataComponent(dbClient_default)({
2726
2771
  scopes: { tenantId, projectId },
2727
2772
  dataComponentId: id,
@@ -2999,8 +3044,268 @@ app12.openapi(
2999
3044
  }
3000
3045
  );
3001
3046
  var externalAgents_default = app12;
3002
- var logger2 = getLogger("graphFull");
3047
+ var logger2 = getLogger("functions");
3003
3048
  var app13 = new OpenAPIHono();
3049
+ app13.openapi(
3050
+ createRoute({
3051
+ method: "get",
3052
+ path: "/",
3053
+ summary: "List Functions",
3054
+ operationId: "list-functions",
3055
+ tags: ["Functions"],
3056
+ request: {
3057
+ params: TenantProjectParamsSchema,
3058
+ query: PaginationQueryParamsSchema
3059
+ },
3060
+ responses: {
3061
+ 200: {
3062
+ description: "List of functions",
3063
+ content: {
3064
+ "application/json": {
3065
+ schema: ListResponseSchema(FunctionApiSelectSchema)
3066
+ }
3067
+ }
3068
+ },
3069
+ ...commonGetErrorResponses
3070
+ }
3071
+ }),
3072
+ async (c) => {
3073
+ const { tenantId, projectId } = c.req.valid("param");
3074
+ try {
3075
+ const functions = await listFunctions(dbClient_default)({ scopes: { tenantId, projectId } });
3076
+ return c.json({
3077
+ data: functions,
3078
+ pagination: {
3079
+ page: 1,
3080
+ limit: functions.length,
3081
+ total: functions.length,
3082
+ pages: 1
3083
+ }
3084
+ });
3085
+ } catch (error) {
3086
+ logger2.error({ error, tenantId }, "Failed to list functions");
3087
+ return c.json(
3088
+ createApiError({ code: "internal_server_error", message: "Failed to list functions" }),
3089
+ 500
3090
+ );
3091
+ }
3092
+ }
3093
+ );
3094
+ app13.openapi(
3095
+ createRoute({
3096
+ method: "get",
3097
+ path: "/{id}",
3098
+ summary: "Get Function by ID",
3099
+ operationId: "get-function",
3100
+ tags: ["Functions"],
3101
+ request: {
3102
+ params: TenantProjectParamsSchema.merge(IdParamsSchema)
3103
+ },
3104
+ responses: {
3105
+ 200: {
3106
+ description: "Function details",
3107
+ content: {
3108
+ "application/json": {
3109
+ schema: SingleResponseSchema(FunctionApiSelectSchema)
3110
+ }
3111
+ }
3112
+ },
3113
+ ...commonGetErrorResponses
3114
+ }
3115
+ }),
3116
+ async (c) => {
3117
+ const { tenantId, projectId, id } = c.req.valid("param");
3118
+ try {
3119
+ const functionData = await getFunction(dbClient_default)({
3120
+ functionId: id,
3121
+ scopes: { tenantId, projectId }
3122
+ });
3123
+ if (!functionData) {
3124
+ return c.json(
3125
+ createApiError({ code: "not_found", message: "Function not found" }),
3126
+ 404
3127
+ );
3128
+ }
3129
+ return c.json({ data: functionData });
3130
+ } catch (error) {
3131
+ logger2.error({ error, tenantId, id }, "Failed to get function");
3132
+ return c.json(
3133
+ createApiError({ code: "internal_server_error", message: "Failed to get function" }),
3134
+ 500
3135
+ );
3136
+ }
3137
+ }
3138
+ );
3139
+ app13.openapi(
3140
+ createRoute({
3141
+ method: "post",
3142
+ path: "/",
3143
+ summary: "Create Function",
3144
+ operationId: "create-function",
3145
+ tags: ["Functions"],
3146
+ request: {
3147
+ params: TenantProjectParamsSchema,
3148
+ body: {
3149
+ content: {
3150
+ "application/json": {
3151
+ schema: FunctionApiInsertSchema
3152
+ }
3153
+ }
3154
+ }
3155
+ },
3156
+ responses: {
3157
+ 201: {
3158
+ description: "Function created",
3159
+ content: {
3160
+ "application/json": {
3161
+ schema: SingleResponseSchema(FunctionApiSelectSchema)
3162
+ }
3163
+ }
3164
+ },
3165
+ ...commonGetErrorResponses
3166
+ }
3167
+ }),
3168
+ async (c) => {
3169
+ const { tenantId, projectId } = c.req.valid("param");
3170
+ const functionData = c.req.valid("json");
3171
+ try {
3172
+ const id = functionData.id || nanoid();
3173
+ await upsertFunction(dbClient_default)({
3174
+ data: {
3175
+ ...functionData,
3176
+ id
3177
+ },
3178
+ scopes: { tenantId, projectId }
3179
+ });
3180
+ const created = await getFunction(dbClient_default)({
3181
+ functionId: id,
3182
+ scopes: { tenantId, projectId }
3183
+ });
3184
+ logger2.info({ tenantId, functionId: id }, "Function created");
3185
+ return c.json({ data: created }, 201);
3186
+ } catch (error) {
3187
+ logger2.error({ error, tenantId, functionData }, "Failed to create function");
3188
+ return c.json(
3189
+ createApiError({ code: "internal_server_error", message: "Failed to create function" }),
3190
+ 500
3191
+ );
3192
+ }
3193
+ }
3194
+ );
3195
+ app13.openapi(
3196
+ createRoute({
3197
+ method: "put",
3198
+ path: "/{id}",
3199
+ summary: "Update Function",
3200
+ operationId: "update-function",
3201
+ tags: ["Functions"],
3202
+ request: {
3203
+ params: TenantProjectParamsSchema.merge(IdParamsSchema),
3204
+ body: {
3205
+ content: {
3206
+ "application/json": {
3207
+ schema: FunctionApiUpdateSchema
3208
+ }
3209
+ }
3210
+ }
3211
+ },
3212
+ responses: {
3213
+ 200: {
3214
+ description: "Function updated",
3215
+ content: {
3216
+ "application/json": {
3217
+ schema: SingleResponseSchema(FunctionApiSelectSchema)
3218
+ }
3219
+ }
3220
+ },
3221
+ ...commonGetErrorResponses
3222
+ }
3223
+ }),
3224
+ async (c) => {
3225
+ const { tenantId, projectId, id } = c.req.valid("param");
3226
+ const updateData = c.req.valid("json");
3227
+ try {
3228
+ const existing = await getFunction(dbClient_default)({
3229
+ functionId: id,
3230
+ scopes: { tenantId, projectId }
3231
+ });
3232
+ if (!existing) {
3233
+ return c.json(
3234
+ createApiError({ code: "not_found", message: "Function not found" }),
3235
+ 404
3236
+ );
3237
+ }
3238
+ await upsertFunction(dbClient_default)({
3239
+ data: {
3240
+ ...existing,
3241
+ ...updateData,
3242
+ id
3243
+ },
3244
+ scopes: { tenantId, projectId }
3245
+ });
3246
+ const updated = await getFunction(dbClient_default)({
3247
+ functionId: id,
3248
+ scopes: { tenantId, projectId }
3249
+ });
3250
+ logger2.info({ tenantId, functionId: id }, "Function updated");
3251
+ return c.json({ data: updated });
3252
+ } catch (error) {
3253
+ logger2.error({ error, tenantId, id, updateData }, "Failed to update function");
3254
+ return c.json(
3255
+ createApiError({ code: "internal_server_error", message: "Failed to update function" }),
3256
+ 500
3257
+ );
3258
+ }
3259
+ }
3260
+ );
3261
+ app13.openapi(
3262
+ createRoute({
3263
+ method: "delete",
3264
+ path: "/{id}",
3265
+ summary: "Delete Function",
3266
+ operationId: "delete-function",
3267
+ tags: ["Functions"],
3268
+ request: {
3269
+ params: TenantProjectParamsSchema.merge(IdParamsSchema)
3270
+ },
3271
+ responses: {
3272
+ 204: {
3273
+ description: "Function deleted"
3274
+ },
3275
+ ...commonGetErrorResponses
3276
+ }
3277
+ }),
3278
+ async (c) => {
3279
+ const { tenantId, projectId, id } = c.req.valid("param");
3280
+ try {
3281
+ const existing = await getFunction(dbClient_default)({
3282
+ functionId: id,
3283
+ scopes: { tenantId, projectId }
3284
+ });
3285
+ if (!existing) {
3286
+ return c.json(
3287
+ createApiError({ code: "not_found", message: "Function not found" }),
3288
+ 404
3289
+ );
3290
+ }
3291
+ await deleteFunction(dbClient_default)({
3292
+ functionId: id,
3293
+ scopes: { tenantId, projectId }
3294
+ });
3295
+ logger2.info({ tenantId, functionId: id }, "Function deleted");
3296
+ return c.body(null, 204);
3297
+ } catch (error) {
3298
+ logger2.error({ error, tenantId, id }, "Failed to delete function");
3299
+ return c.json(
3300
+ createApiError({ code: "internal_server_error", message: "Failed to delete function" }),
3301
+ 500
3302
+ );
3303
+ }
3304
+ }
3305
+ );
3306
+ var functions_default = app13;
3307
+ var logger3 = getLogger("graphFull");
3308
+ var app14 = new OpenAPIHono();
3004
3309
  var GraphIdParamsSchema = z.object({
3005
3310
  tenantId: z.string().openapi({
3006
3311
  description: "Tenant identifier",
@@ -3015,7 +3320,7 @@ var GraphIdParamsSchema = z.object({
3015
3320
  example: "graph_789"
3016
3321
  })
3017
3322
  }).openapi("GraphIdParams");
3018
- app13.openapi(
3323
+ app14.openapi(
3019
3324
  createRoute({
3020
3325
  method: "post",
3021
3326
  path: "/",
@@ -3057,14 +3362,14 @@ app13.openapi(
3057
3362
  const { tenantId, projectId } = c.req.valid("param");
3058
3363
  const graphData = c.req.valid("json");
3059
3364
  const validatedGraphData = FullGraphDefinitionSchema.parse(graphData);
3060
- const createdGraph = await createFullGraphServerSide(dbClient_default, logger2)(
3365
+ const createdGraph = await createFullGraphServerSide(dbClient_default, logger3)(
3061
3366
  { tenantId, projectId },
3062
3367
  validatedGraphData
3063
3368
  );
3064
3369
  return c.json({ data: createdGraph }, 201);
3065
3370
  }
3066
3371
  );
3067
- app13.openapi(
3372
+ app14.openapi(
3068
3373
  createRoute({
3069
3374
  method: "get",
3070
3375
  path: "/{graphId}",
@@ -3092,7 +3397,7 @@ app13.openapi(
3092
3397
  try {
3093
3398
  const graph = await getFullGraph(
3094
3399
  dbClient_default,
3095
- logger2
3400
+ logger3
3096
3401
  )({
3097
3402
  scopes: { tenantId, projectId, graphId }
3098
3403
  });
@@ -3117,7 +3422,7 @@ app13.openapi(
3117
3422
  }
3118
3423
  }
3119
3424
  );
3120
- app13.openapi(
3425
+ app14.openapi(
3121
3426
  createRoute({
3122
3427
  method: "put",
3123
3428
  path: "/{graphId}",
@@ -3168,15 +3473,15 @@ app13.openapi(
3168
3473
  }
3169
3474
  const existingGraph = await getFullGraph(
3170
3475
  dbClient_default,
3171
- logger2
3476
+ logger3
3172
3477
  )({
3173
3478
  scopes: { tenantId, projectId, graphId }
3174
3479
  });
3175
3480
  const isCreate = !existingGraph;
3176
- const updatedGraph = isCreate ? await createFullGraphServerSide(dbClient_default, logger2)(
3481
+ const updatedGraph = isCreate ? await createFullGraphServerSide(dbClient_default, logger3)(
3177
3482
  { tenantId, projectId },
3178
3483
  validatedGraphData
3179
- ) : await updateFullGraphServerSide(dbClient_default, logger2)(
3484
+ ) : await updateFullGraphServerSide(dbClient_default, logger3)(
3180
3485
  { tenantId, projectId },
3181
3486
  validatedGraphData
3182
3487
  );
@@ -3201,7 +3506,7 @@ app13.openapi(
3201
3506
  }
3202
3507
  }
3203
3508
  );
3204
- app13.openapi(
3509
+ app14.openapi(
3205
3510
  createRoute({
3206
3511
  method: "delete",
3207
3512
  path: "/{graphId}",
@@ -3224,7 +3529,7 @@ app13.openapi(
3224
3529
  try {
3225
3530
  const deleted = await deleteFullGraph(
3226
3531
  dbClient_default,
3227
- logger2
3532
+ logger3
3228
3533
  )({
3229
3534
  scopes: { tenantId, projectId, graphId }
3230
3535
  });
@@ -3249,9 +3554,9 @@ app13.openapi(
3249
3554
  }
3250
3555
  }
3251
3556
  );
3252
- var graphFull_default = app13;
3253
- var app14 = new OpenAPIHono();
3254
- app14.openapi(
3557
+ var graphFull_default = app14;
3558
+ var app15 = new OpenAPIHono();
3559
+ app15.openapi(
3255
3560
  createRoute({
3256
3561
  method: "get",
3257
3562
  path: "/",
@@ -3286,7 +3591,7 @@ app14.openapi(
3286
3591
  return c.json(result);
3287
3592
  }
3288
3593
  );
3289
- app14.openapi(
3594
+ app15.openapi(
3290
3595
  createRoute({
3291
3596
  method: "get",
3292
3597
  path: "/{id}",
@@ -3321,7 +3626,7 @@ app14.openapi(
3321
3626
  return c.json({ data: project });
3322
3627
  }
3323
3628
  );
3324
- app14.openapi(
3629
+ app15.openapi(
3325
3630
  createRoute({
3326
3631
  method: "post",
3327
3632
  path: "/",
@@ -3379,7 +3684,7 @@ app14.openapi(
3379
3684
  }
3380
3685
  }
3381
3686
  );
3382
- app14.openapi(
3687
+ app15.openapi(
3383
3688
  createRoute({
3384
3689
  method: "patch",
3385
3690
  path: "/{id}",
@@ -3425,7 +3730,7 @@ app14.openapi(
3425
3730
  return c.json({ data: project });
3426
3731
  }
3427
3732
  );
3428
- app14.openapi(
3733
+ app15.openapi(
3429
3734
  createRoute({
3430
3735
  method: "delete",
3431
3736
  path: "/{id}",
@@ -3475,10 +3780,10 @@ app14.openapi(
3475
3780
  }
3476
3781
  }
3477
3782
  );
3478
- var projects_default = app14;
3479
- var logger3 = getLogger("tools");
3480
- var app15 = new OpenAPIHono();
3481
- app15.openapi(
3783
+ var projects_default = app15;
3784
+ var logger4 = getLogger("tools");
3785
+ var app16 = new OpenAPIHono();
3786
+ app16.openapi(
3482
3787
  createRoute({
3483
3788
  method: "get",
3484
3789
  path: "/",
@@ -3538,7 +3843,7 @@ app15.openapi(
3538
3843
  return c.json(result);
3539
3844
  }
3540
3845
  );
3541
- app15.openapi(
3846
+ app16.openapi(
3542
3847
  createRoute({
3543
3848
  method: "get",
3544
3849
  path: "/{id}",
@@ -3575,7 +3880,7 @@ app15.openapi(
3575
3880
  });
3576
3881
  }
3577
3882
  );
3578
- app15.openapi(
3883
+ app16.openapi(
3579
3884
  createRoute({
3580
3885
  method: "post",
3581
3886
  path: "/",
@@ -3608,7 +3913,7 @@ app15.openapi(
3608
3913
  const { tenantId, projectId } = c.req.valid("param");
3609
3914
  const body = c.req.valid("json");
3610
3915
  const credentialStores = c.get("credentialStores");
3611
- logger3.info({ body }, "body");
3916
+ logger4.info({ body }, "body");
3612
3917
  const id = body.id || nanoid();
3613
3918
  const tool = await createTool(dbClient_default)({
3614
3919
  tenantId,
@@ -3628,7 +3933,7 @@ app15.openapi(
3628
3933
  );
3629
3934
  }
3630
3935
  );
3631
- app15.openapi(
3936
+ app16.openapi(
3632
3937
  createRoute({
3633
3938
  method: "put",
3634
3939
  path: "/{id}",
@@ -3689,7 +3994,7 @@ app15.openapi(
3689
3994
  });
3690
3995
  }
3691
3996
  );
3692
- app15.openapi(
3997
+ app16.openapi(
3693
3998
  createRoute({
3694
3999
  method: "delete",
3695
4000
  path: "/{id}",
@@ -3725,27 +4030,31 @@ app15.openapi(
3725
4030
  return c.body(null, 204);
3726
4031
  }
3727
4032
  );
3728
- var tools_default = app15;
4033
+ var tools_default = app16;
3729
4034
 
3730
4035
  // src/routes/index.ts
3731
- var app16 = new OpenAPIHono();
3732
- app16.route("/projects", projects_default);
3733
- app16.route("/projects/:projectId/graphs/:graphId/agents", agents_default);
3734
- app16.route("/projects/:projectId/graphs/:graphId/agent-relations", agentRelations_default);
3735
- app16.route("/projects/:projectId/agent-graphs", agentGraph_default);
3736
- app16.route("/projects/:projectId/graphs/:graphId/agent-tool-relations", agentToolRelations_default);
3737
- app16.route("/projects/:projectId/graphs/:graphId/agent-artifact-components", agentArtifactComponents_default);
3738
- app16.route("/projects/:projectId/graphs/:graphId/agent-data-components", agentDataComponents_default);
3739
- app16.route("/projects/:projectId/artifact-components", artifactComponents_default);
3740
- app16.route("/projects/:projectId/context-configs", contextConfigs_default);
3741
- app16.route("/projects/:projectId/credentials", credentials_default);
3742
- app16.route("/projects/:projectId/data-components", dataComponents_default);
3743
- app16.route("/projects/:projectId/graphs/:graphId/external-agents", externalAgents_default);
3744
- app16.route("/projects/:projectId/tools", tools_default);
3745
- app16.route("/projects/:projectId/api-keys", apiKeys_default);
3746
- app16.route("/projects/:projectId/graph", graphFull_default);
3747
- var routes_default = app16;
3748
- var logger4 = getLogger("oauth-service");
4036
+ var app17 = new OpenAPIHono();
4037
+ app17.route("/projects", projects_default);
4038
+ app17.route("/projects/:projectId/graphs/:graphId/agents", agents_default);
4039
+ app17.route("/projects/:projectId/graphs/:graphId/agent-relations", agentRelations_default);
4040
+ app17.route("/projects/:projectId/agent-graphs", agentGraph_default);
4041
+ app17.route("/projects/:projectId/graphs/:graphId/agent-tool-relations", agentToolRelations_default);
4042
+ app17.route(
4043
+ "/projects/:projectId/graphs/:graphId/agent-artifact-components",
4044
+ agentArtifactComponents_default
4045
+ );
4046
+ app17.route("/projects/:projectId/graphs/:graphId/agent-data-components", agentDataComponents_default);
4047
+ app17.route("/projects/:projectId/artifact-components", artifactComponents_default);
4048
+ app17.route("/projects/:projectId/graphs/:graphId/context-configs", contextConfigs_default);
4049
+ app17.route("/projects/:projectId/credentials", credentials_default);
4050
+ app17.route("/projects/:projectId/data-components", dataComponents_default);
4051
+ app17.route("/projects/:projectId/graphs/:graphId/external-agents", externalAgents_default);
4052
+ app17.route("/projects/:projectId/functions", functions_default);
4053
+ app17.route("/projects/:projectId/tools", tools_default);
4054
+ app17.route("/projects/:projectId/api-keys", apiKeys_default);
4055
+ app17.route("/projects/:projectId/graph", graphFull_default);
4056
+ var routes_default = app17;
4057
+ var logger5 = getLogger("oauth-service");
3749
4058
  var pkceStore = /* @__PURE__ */ new Map();
3750
4059
  function storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId) {
3751
4060
  pkceStore.set(state, { codeVerifier, toolId, tenantId, projectId, clientId });
@@ -3780,7 +4089,10 @@ var OAuthService = class {
3780
4089
  */
3781
4090
  async initiateOAuthFlow(params) {
3782
4091
  const { tool, tenantId, projectId, toolId, baseUrl } = params;
3783
- const oAuthConfig = await discoverOAuthEndpoints(tool.config.mcp.server.url, logger4);
4092
+ if (tool.config.type !== "mcp") {
4093
+ throw new Error("OAuth is only supported for MCP tools");
4094
+ }
4095
+ const oAuthConfig = await discoverOAuthEndpoints(tool.config.mcp.server.url, logger5);
3784
4096
  if (!oAuthConfig) {
3785
4097
  throw new Error("OAuth not supported by this server");
3786
4098
  }
@@ -3804,7 +4116,7 @@ var OAuthService = class {
3804
4116
  resource: tool.config.mcp.server.url
3805
4117
  });
3806
4118
  storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId);
3807
- logger4.info({ toolId, oAuthConfig, tenantId, projectId }, "OAuth flow initiated successfully");
4119
+ logger5.info({ toolId, oAuthConfig, tenantId, projectId }, "OAuth flow initiated successfully");
3808
4120
  return {
3809
4121
  redirectUrl: authUrl,
3810
4122
  state
@@ -3815,7 +4127,10 @@ var OAuthService = class {
3815
4127
  */
3816
4128
  async exchangeCodeForTokens(params) {
3817
4129
  const { code, codeVerifier, clientId, tool, baseUrl } = params;
3818
- const oAuthConfig = await discoverOAuthEndpoints(tool.config.mcp.server.url, logger4);
4130
+ if (tool.config.type !== "mcp") {
4131
+ throw new Error("OAuth is only supported for MCP tools");
4132
+ }
4133
+ const oAuthConfig = await discoverOAuthEndpoints(tool.config.mcp.server.url, logger5);
3819
4134
  if (!oAuthConfig?.tokenUrl) {
3820
4135
  throw new Error("Could not discover OAuth token endpoint");
3821
4136
  }
@@ -3830,9 +4145,9 @@ var OAuthService = class {
3830
4145
  codeVerifier,
3831
4146
  redirectUri
3832
4147
  });
3833
- logger4.info({ tokenType: tokens.token_type }, "Token exchange successful with openid-client");
4148
+ logger5.info({ tokenType: tokens.token_type }, "Token exchange successful with openid-client");
3834
4149
  } catch (error) {
3835
- logger4.warn(
4150
+ logger5.warn(
3836
4151
  { error: error instanceof Error ? error.message : error },
3837
4152
  "openid-client failed, falling back to manual token exchange"
3838
4153
  );
@@ -3843,7 +4158,7 @@ var OAuthService = class {
3843
4158
  codeVerifier,
3844
4159
  redirectUri
3845
4160
  });
3846
- logger4.info({ tokenType: tokens.token_type }, "Manual token exchange successful");
4161
+ logger5.info({ tokenType: tokens.token_type }, "Manual token exchange successful");
3847
4162
  }
3848
4163
  return { tokens, oAuthConfig };
3849
4164
  }
@@ -3851,7 +4166,7 @@ var OAuthService = class {
3851
4166
  * Perform dynamic client registration
3852
4167
  */
3853
4168
  async performDynamicClientRegistration(registrationUrl, redirectUri) {
3854
- logger4.info({ registrationUrl }, "Attempting dynamic client registration");
4169
+ logger5.info({ registrationUrl }, "Attempting dynamic client registration");
3855
4170
  try {
3856
4171
  const registrationResponse = await fetch(registrationUrl, {
3857
4172
  method: "POST",
@@ -3874,11 +4189,11 @@ var OAuthService = class {
3874
4189
  });
3875
4190
  if (registrationResponse.ok) {
3876
4191
  const registration = await registrationResponse.json();
3877
- logger4.info({ clientId: registration.client_id }, "Dynamic client registration successful");
4192
+ logger5.info({ clientId: registration.client_id }, "Dynamic client registration successful");
3878
4193
  return registration.client_id;
3879
4194
  } else {
3880
4195
  const errorText = await registrationResponse.text();
3881
- logger4.warn(
4196
+ logger5.warn(
3882
4197
  {
3883
4198
  status: registrationResponse.status,
3884
4199
  errorText
@@ -3887,7 +4202,7 @@ var OAuthService = class {
3887
4202
  );
3888
4203
  }
3889
4204
  } catch (regError) {
3890
- logger4.warn(
4205
+ logger5.warn(
3891
4206
  { error: regError },
3892
4207
  "Dynamic client registration error, using default client_id"
3893
4208
  );
@@ -3917,7 +4232,7 @@ var OAuthService = class {
3917
4232
  const oauth = await import('openid-client');
3918
4233
  const tokenUrl = new URL(oAuthConfig.tokenUrl);
3919
4234
  const oauthServerUrl = `${tokenUrl.protocol}//${tokenUrl.host}`;
3920
- logger4.info({ oauthServerUrl, clientId }, "Attempting openid-client discovery");
4235
+ logger5.info({ oauthServerUrl, clientId }, "Attempting openid-client discovery");
3921
4236
  const config = await oauth.discovery(
3922
4237
  new URL(oauthServerUrl),
3923
4238
  clientId,
@@ -3949,7 +4264,7 @@ var OAuthService = class {
3949
4264
  */
3950
4265
  async exchangeManually(params) {
3951
4266
  const { oAuthConfig, clientId, code, codeVerifier, redirectUri } = params;
3952
- logger4.info({ tokenUrl: oAuthConfig.tokenUrl }, "Attempting manual token exchange");
4267
+ logger5.info({ tokenUrl: oAuthConfig.tokenUrl }, "Attempting manual token exchange");
3953
4268
  const tokenResponse = await fetch(oAuthConfig.tokenUrl, {
3954
4269
  method: "POST",
3955
4270
  headers: {
@@ -3967,7 +4282,7 @@ var OAuthService = class {
3967
4282
  });
3968
4283
  if (!tokenResponse.ok) {
3969
4284
  const errorText = await tokenResponse.text();
3970
- logger4.error(
4285
+ logger5.error(
3971
4286
  {
3972
4287
  status: tokenResponse.status,
3973
4288
  statusText: tokenResponse.statusText,
@@ -4010,8 +4325,8 @@ async function findOrCreateCredential(tenantId, projectId, credentialData) {
4010
4325
  throw new Error(`Failed to save credential '${credentialData.id}' to database`);
4011
4326
  }
4012
4327
  }
4013
- var app17 = new OpenAPIHono();
4014
- var logger5 = getLogger("oauth-callback");
4328
+ var app18 = new OpenAPIHono();
4329
+ var logger6 = getLogger("oauth-callback");
4015
4330
  function getBaseUrlFromRequest(c) {
4016
4331
  const url = new URL(c.req.url);
4017
4332
  return `${url.protocol}//${url.host}`;
@@ -4097,7 +4412,7 @@ var OAuthCallbackQuerySchema = z$1.object({
4097
4412
  error: z$1.string().optional(),
4098
4413
  error_description: z$1.string().optional()
4099
4414
  });
4100
- app17.openapi(
4415
+ app18.openapi(
4101
4416
  createRoute({
4102
4417
  method: "get",
4103
4418
  path: "/login",
@@ -4143,7 +4458,7 @@ app17.openapi(
4143
4458
  try {
4144
4459
  const tool = await getToolById(dbClient_default)({ scopes: { tenantId, projectId }, toolId });
4145
4460
  if (!tool) {
4146
- logger5.error({ toolId, tenantId, projectId }, "Tool not found for OAuth login");
4461
+ logger6.error({ toolId, tenantId, projectId }, "Tool not found for OAuth login");
4147
4462
  return c.text("Tool not found", 404);
4148
4463
  }
4149
4464
  const credentialStores = c.get("credentialStores");
@@ -4158,13 +4473,13 @@ app17.openapi(
4158
4473
  });
4159
4474
  return c.redirect(redirectUrl, 302);
4160
4475
  } catch (error) {
4161
- logger5.error({ toolId, tenantId, projectId, error }, "OAuth login failed");
4476
+ logger6.error({ toolId, tenantId, projectId, error }, "OAuth login failed");
4162
4477
  const errorMessage = error instanceof Error ? error.message : "Failed to initiate OAuth login";
4163
4478
  return c.text(`OAuth Error: ${errorMessage}`, 500);
4164
4479
  }
4165
4480
  }
4166
4481
  );
4167
- app17.openapi(
4482
+ app18.openapi(
4168
4483
  createRoute({
4169
4484
  method: "get",
4170
4485
  path: "/callback",
@@ -4200,9 +4515,9 @@ app17.openapi(
4200
4515
  async (c) => {
4201
4516
  try {
4202
4517
  const { code, state, error, error_description } = c.req.valid("query");
4203
- logger5.info({ state, hasCode: !!code }, "OAuth callback received");
4518
+ logger6.info({ state, hasCode: !!code }, "OAuth callback received");
4204
4519
  if (error) {
4205
- logger5.error({ error, error_description }, "OAuth authorization failed");
4520
+ logger6.error({ error, error_description }, "OAuth authorization failed");
4206
4521
  const errorMessage = error_description || error || "OAuth Authorization Failed. Please try again.";
4207
4522
  const errorPage = generateOAuthCallbackPage({
4208
4523
  title: "Authentication Failed",
@@ -4213,7 +4528,7 @@ app17.openapi(
4213
4528
  }
4214
4529
  const pkceData = retrievePKCEVerifier(state);
4215
4530
  if (!pkceData) {
4216
- logger5.error({ state }, "Invalid or expired OAuth state");
4531
+ logger6.error({ state }, "Invalid or expired OAuth state");
4217
4532
  const errorMessage = "OAuth Session Expired: The OAuth session has expired or is invalid. Please try again.";
4218
4533
  const expiredPage = generateOAuthCallbackPage({
4219
4534
  title: "Session Expired",
@@ -4230,8 +4545,8 @@ app17.openapi(
4230
4545
  if (!tool) {
4231
4546
  throw new Error(`Tool ${toolId} not found`);
4232
4547
  }
4233
- logger5.info({ toolId, tenantId, projectId }, "Processing OAuth callback");
4234
- logger5.info({ toolId }, "Exchanging authorization code for access token");
4548
+ logger6.info({ toolId, tenantId, projectId }, "Processing OAuth callback");
4549
+ logger6.info({ toolId }, "Exchanging authorization code for access token");
4235
4550
  const credentialStores = c.get("credentialStores");
4236
4551
  const mcpTool = await dbResultToMcpTool(tool, dbClient_default, credentialStores);
4237
4552
  const baseUrl = getBaseUrlFromRequest(c);
@@ -4242,7 +4557,7 @@ app17.openapi(
4242
4557
  tool: mcpTool,
4243
4558
  baseUrl
4244
4559
  });
4245
- logger5.info(
4560
+ logger6.info(
4246
4561
  { toolId, tokenType: tokens.token_type, hasRefresh: !!tokens.refresh_token },
4247
4562
  "Token exchange successful"
4248
4563
  );
@@ -4289,7 +4604,7 @@ app17.openapi(
4289
4604
  credentialReferenceId: newCredential.id
4290
4605
  }
4291
4606
  });
4292
- logger5.info({ toolId, credentialId: newCredential.id }, "OAuth flow completed successfully");
4607
+ logger6.info({ toolId, credentialId: newCredential.id }, "OAuth flow completed successfully");
4293
4608
  const successPage = generateOAuthCallbackPage({
4294
4609
  title: "Authentication Complete",
4295
4610
  message: "You have been successfully authenticated.",
@@ -4297,7 +4612,7 @@ app17.openapi(
4297
4612
  });
4298
4613
  return c.html(successPage);
4299
4614
  } catch (error) {
4300
- logger5.error({ error }, "OAuth callback processing failed");
4615
+ logger6.error({ error }, "OAuth callback processing failed");
4301
4616
  const errorMessage = "OAuth Processing Failed. Please try again.";
4302
4617
  const errorPage = generateOAuthCallbackPage({
4303
4618
  title: "Processing Failed",
@@ -4308,9 +4623,9 @@ app17.openapi(
4308
4623
  }
4309
4624
  }
4310
4625
  );
4311
- var oauth_default = app17;
4312
- var logger6 = getLogger("projectFull");
4313
- var app18 = new OpenAPIHono();
4626
+ var oauth_default = app18;
4627
+ var logger7 = getLogger("projectFull");
4628
+ var app19 = new OpenAPIHono();
4314
4629
  var ProjectIdParamsSchema = z.object({
4315
4630
  tenantId: z.string().openapi({
4316
4631
  description: "Tenant identifier",
@@ -4327,7 +4642,7 @@ var TenantParamsSchema2 = z.object({
4327
4642
  example: "tenant_123"
4328
4643
  })
4329
4644
  }).openapi("TenantParams");
4330
- app18.openapi(
4645
+ app19.openapi(
4331
4646
  createRoute({
4332
4647
  method: "post",
4333
4648
  path: "/project-full",
@@ -4370,7 +4685,7 @@ app18.openapi(
4370
4685
  const projectData = c.req.valid("json");
4371
4686
  const validatedProjectData = FullProjectDefinitionSchema.parse(projectData);
4372
4687
  try {
4373
- const createdProject = await createFullProjectServerSide(dbClient_default, logger6)(
4688
+ const createdProject = await createFullProjectServerSide(dbClient_default, logger7)(
4374
4689
  { tenantId, projectId: validatedProjectData.id },
4375
4690
  validatedProjectData
4376
4691
  );
@@ -4386,7 +4701,7 @@ app18.openapi(
4386
4701
  }
4387
4702
  }
4388
4703
  );
4389
- app18.openapi(
4704
+ app19.openapi(
4390
4705
  createRoute({
4391
4706
  method: "get",
4392
4707
  path: "/project-full/{projectId}",
@@ -4414,7 +4729,7 @@ app18.openapi(
4414
4729
  try {
4415
4730
  const project = await getFullProject(
4416
4731
  dbClient_default,
4417
- logger6
4732
+ logger7
4418
4733
  )({
4419
4734
  scopes: { tenantId, projectId }
4420
4735
  });
@@ -4439,7 +4754,7 @@ app18.openapi(
4439
4754
  }
4440
4755
  }
4441
4756
  );
4442
- app18.openapi(
4757
+ app19.openapi(
4443
4758
  createRoute({
4444
4759
  method: "put",
4445
4760
  path: "/project-full/{projectId}",
@@ -4490,15 +4805,15 @@ app18.openapi(
4490
4805
  }
4491
4806
  const existingProject = await getFullProject(
4492
4807
  dbClient_default,
4493
- logger6
4808
+ logger7
4494
4809
  )({
4495
4810
  scopes: { tenantId, projectId }
4496
4811
  });
4497
4812
  const isCreate = !existingProject;
4498
- const updatedProject = isCreate ? await createFullProjectServerSide(dbClient_default, logger6)(
4813
+ const updatedProject = isCreate ? await createFullProjectServerSide(dbClient_default, logger7)(
4499
4814
  { tenantId, projectId },
4500
4815
  validatedProjectData
4501
- ) : await updateFullProjectServerSide(dbClient_default, logger6)(
4816
+ ) : await updateFullProjectServerSide(dbClient_default, logger7)(
4502
4817
  { tenantId, projectId },
4503
4818
  validatedProjectData
4504
4819
  );
@@ -4523,7 +4838,7 @@ app18.openapi(
4523
4838
  }
4524
4839
  }
4525
4840
  );
4526
- app18.openapi(
4841
+ app19.openapi(
4527
4842
  createRoute({
4528
4843
  method: "delete",
4529
4844
  path: "/project-full/{projectId}",
@@ -4546,7 +4861,7 @@ app18.openapi(
4546
4861
  try {
4547
4862
  const deleted = await deleteFullProject(
4548
4863
  dbClient_default,
4549
- logger6
4864
+ logger7
4550
4865
  )({
4551
4866
  scopes: { tenantId, projectId }
4552
4867
  });
@@ -4571,20 +4886,20 @@ app18.openapi(
4571
4886
  }
4572
4887
  }
4573
4888
  );
4574
- var projectFull_default = app18;
4889
+ var projectFull_default = app19;
4575
4890
 
4576
4891
  // src/app.ts
4577
- var logger7 = getLogger("agents-manage-api");
4578
- logger7.info({ logger: logger7.getTransports() }, "Logger initialized");
4892
+ var logger8 = getLogger("agents-manage-api");
4893
+ logger8.info({ logger: logger8.getTransports() }, "Logger initialized");
4579
4894
  function createManagementHono(serverConfig, credentialStores) {
4580
- const app20 = new OpenAPIHono();
4581
- app20.use("*", requestId());
4582
- app20.use("*", async (c, next) => {
4895
+ const app21 = new OpenAPIHono();
4896
+ app21.use("*", requestId());
4897
+ app21.use("*", async (c, next) => {
4583
4898
  c.set("serverConfig", serverConfig);
4584
4899
  c.set("credentialStores", credentialStores);
4585
4900
  return next();
4586
4901
  });
4587
- app20.use(
4902
+ app21.use(
4588
4903
  pinoLogger({
4589
4904
  pino: getLogger("agents-manage-api").getPinoInstance(),
4590
4905
  http: {
@@ -4597,7 +4912,7 @@ function createManagementHono(serverConfig, credentialStores) {
4597
4912
  }
4598
4913
  })
4599
4914
  );
4600
- app20.onError(async (err, c) => {
4915
+ app21.onError(async (err, c) => {
4601
4916
  const isExpectedError = err instanceof HTTPException;
4602
4917
  const status = isExpectedError ? err.status : 500;
4603
4918
  const requestId2 = c.get("requestId") || "unknown";
@@ -4630,7 +4945,7 @@ function createManagementHono(serverConfig, credentialStores) {
4630
4945
  if (!isExpectedError) {
4631
4946
  const errorMessage = err instanceof Error ? err.message : String(err);
4632
4947
  const errorStack = err instanceof Error ? err.stack : void 0;
4633
- logger7.error(
4948
+ logger8.error(
4634
4949
  {
4635
4950
  error: err,
4636
4951
  message: errorMessage,
@@ -4641,7 +4956,7 @@ function createManagementHono(serverConfig, credentialStores) {
4641
4956
  "Unexpected server error occurred"
4642
4957
  );
4643
4958
  } else {
4644
- logger7.error(
4959
+ logger8.error(
4645
4960
  {
4646
4961
  error: err,
4647
4962
  path: c.req.path,
@@ -4657,7 +4972,7 @@ function createManagementHono(serverConfig, credentialStores) {
4657
4972
  const response = err.getResponse();
4658
4973
  return response;
4659
4974
  } catch (responseError) {
4660
- logger7.error({ error: responseError }, "Error while handling HTTPException response");
4975
+ logger8.error({ error: responseError }, "Error while handling HTTPException response");
4661
4976
  }
4662
4977
  }
4663
4978
  const { status: respStatus, title, detail, instance } = await handleApiError(err, requestId2);
@@ -4672,7 +4987,7 @@ function createManagementHono(serverConfig, credentialStores) {
4672
4987
  ...instance && { instance }
4673
4988
  });
4674
4989
  });
4675
- app20.use(
4990
+ app21.use(
4676
4991
  "*",
4677
4992
  cors({
4678
4993
  origin: (origin) => {
@@ -4686,7 +5001,7 @@ function createManagementHono(serverConfig, credentialStores) {
4686
5001
  credentials: true
4687
5002
  })
4688
5003
  );
4689
- app20.openapi(
5004
+ app21.openapi(
4690
5005
  createRoute({
4691
5006
  method: "get",
4692
5007
  path: "/health",
@@ -4703,13 +5018,13 @@ function createManagementHono(serverConfig, credentialStores) {
4703
5018
  return c.body(null, 204);
4704
5019
  }
4705
5020
  );
4706
- app20.use("/tenants/*", apiKeyAuth());
4707
- app20.route("/tenants/:tenantId", routes_default);
4708
- app20.route("/tenants/:tenantId", projectFull_default);
4709
- app20.route("/oauth", oauth_default);
4710
- setupOpenAPIRoutes(app20);
5021
+ app21.use("/tenants/*", apiKeyAuth());
5022
+ app21.route("/tenants/:tenantId", routes_default);
5023
+ app21.route("/tenants/:tenantId", projectFull_default);
5024
+ app21.route("/oauth", oauth_default);
5025
+ setupOpenAPIRoutes(app21);
4711
5026
  const baseApp = new Hono();
4712
- baseApp.route("/", app20);
5027
+ baseApp.route("/", app21);
4713
5028
  return baseApp;
4714
5029
  }
4715
5030
 
@@ -4725,8 +5040,8 @@ var defaultConfig = {
4725
5040
  };
4726
5041
  var defaultStores = createDefaultCredentialStores();
4727
5042
  var defaultRegistry = new CredentialStoreRegistry(defaultStores);
4728
- var app19 = createManagementHono(defaultConfig, defaultRegistry);
4729
- var index_default = app19;
5043
+ var app20 = createManagementHono(defaultConfig, defaultRegistry);
5044
+ var index_default = app20;
4730
5045
  function createManagementApp(config) {
4731
5046
  const serverConfig = config?.serverConfig ?? defaultConfig;
4732
5047
  const stores = config?.credentialStores ?? defaultStores;