@inkeep/agents-manage-api 0.0.0-dev-20251008200151 → 0.0.0-dev-20251009005405
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +378 -111
- package/dist/index.js +379 -112
- 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, 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, 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(
|
|
70
|
-
|
|
69
|
+
function setupOpenAPIRoutes(app21) {
|
|
70
|
+
app21.get("/openapi.json", (c) => {
|
|
71
71
|
try {
|
|
72
|
-
const document =
|
|
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
|
-
|
|
93
|
+
app21.get(
|
|
94
94
|
"/docs",
|
|
95
95
|
swaggerUI({
|
|
96
96
|
url: "/openapi.json",
|
|
@@ -3044,8 +3044,268 @@ app12.openapi(
|
|
|
3044
3044
|
}
|
|
3045
3045
|
);
|
|
3046
3046
|
var externalAgents_default = app12;
|
|
3047
|
-
var logger2 = getLogger("
|
|
3047
|
+
var logger2 = getLogger("functions");
|
|
3048
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();
|
|
3049
3309
|
var GraphIdParamsSchema = z.object({
|
|
3050
3310
|
tenantId: z.string().openapi({
|
|
3051
3311
|
description: "Tenant identifier",
|
|
@@ -3060,7 +3320,7 @@ var GraphIdParamsSchema = z.object({
|
|
|
3060
3320
|
example: "graph_789"
|
|
3061
3321
|
})
|
|
3062
3322
|
}).openapi("GraphIdParams");
|
|
3063
|
-
|
|
3323
|
+
app14.openapi(
|
|
3064
3324
|
createRoute({
|
|
3065
3325
|
method: "post",
|
|
3066
3326
|
path: "/",
|
|
@@ -3102,14 +3362,14 @@ app13.openapi(
|
|
|
3102
3362
|
const { tenantId, projectId } = c.req.valid("param");
|
|
3103
3363
|
const graphData = c.req.valid("json");
|
|
3104
3364
|
const validatedGraphData = FullGraphDefinitionSchema.parse(graphData);
|
|
3105
|
-
const createdGraph = await createFullGraphServerSide(dbClient_default,
|
|
3365
|
+
const createdGraph = await createFullGraphServerSide(dbClient_default, logger3)(
|
|
3106
3366
|
{ tenantId, projectId },
|
|
3107
3367
|
validatedGraphData
|
|
3108
3368
|
);
|
|
3109
3369
|
return c.json({ data: createdGraph }, 201);
|
|
3110
3370
|
}
|
|
3111
3371
|
);
|
|
3112
|
-
|
|
3372
|
+
app14.openapi(
|
|
3113
3373
|
createRoute({
|
|
3114
3374
|
method: "get",
|
|
3115
3375
|
path: "/{graphId}",
|
|
@@ -3137,7 +3397,7 @@ app13.openapi(
|
|
|
3137
3397
|
try {
|
|
3138
3398
|
const graph = await getFullGraph(
|
|
3139
3399
|
dbClient_default,
|
|
3140
|
-
|
|
3400
|
+
logger3
|
|
3141
3401
|
)({
|
|
3142
3402
|
scopes: { tenantId, projectId, graphId }
|
|
3143
3403
|
});
|
|
@@ -3162,7 +3422,7 @@ app13.openapi(
|
|
|
3162
3422
|
}
|
|
3163
3423
|
}
|
|
3164
3424
|
);
|
|
3165
|
-
|
|
3425
|
+
app14.openapi(
|
|
3166
3426
|
createRoute({
|
|
3167
3427
|
method: "put",
|
|
3168
3428
|
path: "/{graphId}",
|
|
@@ -3213,15 +3473,15 @@ app13.openapi(
|
|
|
3213
3473
|
}
|
|
3214
3474
|
const existingGraph = await getFullGraph(
|
|
3215
3475
|
dbClient_default,
|
|
3216
|
-
|
|
3476
|
+
logger3
|
|
3217
3477
|
)({
|
|
3218
3478
|
scopes: { tenantId, projectId, graphId }
|
|
3219
3479
|
});
|
|
3220
3480
|
const isCreate = !existingGraph;
|
|
3221
|
-
const updatedGraph = isCreate ? await createFullGraphServerSide(dbClient_default,
|
|
3481
|
+
const updatedGraph = isCreate ? await createFullGraphServerSide(dbClient_default, logger3)(
|
|
3222
3482
|
{ tenantId, projectId },
|
|
3223
3483
|
validatedGraphData
|
|
3224
|
-
) : await updateFullGraphServerSide(dbClient_default,
|
|
3484
|
+
) : await updateFullGraphServerSide(dbClient_default, logger3)(
|
|
3225
3485
|
{ tenantId, projectId },
|
|
3226
3486
|
validatedGraphData
|
|
3227
3487
|
);
|
|
@@ -3246,7 +3506,7 @@ app13.openapi(
|
|
|
3246
3506
|
}
|
|
3247
3507
|
}
|
|
3248
3508
|
);
|
|
3249
|
-
|
|
3509
|
+
app14.openapi(
|
|
3250
3510
|
createRoute({
|
|
3251
3511
|
method: "delete",
|
|
3252
3512
|
path: "/{graphId}",
|
|
@@ -3269,7 +3529,7 @@ app13.openapi(
|
|
|
3269
3529
|
try {
|
|
3270
3530
|
const deleted = await deleteFullGraph(
|
|
3271
3531
|
dbClient_default,
|
|
3272
|
-
|
|
3532
|
+
logger3
|
|
3273
3533
|
)({
|
|
3274
3534
|
scopes: { tenantId, projectId, graphId }
|
|
3275
3535
|
});
|
|
@@ -3294,9 +3554,9 @@ app13.openapi(
|
|
|
3294
3554
|
}
|
|
3295
3555
|
}
|
|
3296
3556
|
);
|
|
3297
|
-
var graphFull_default =
|
|
3298
|
-
var
|
|
3299
|
-
|
|
3557
|
+
var graphFull_default = app14;
|
|
3558
|
+
var app15 = new OpenAPIHono();
|
|
3559
|
+
app15.openapi(
|
|
3300
3560
|
createRoute({
|
|
3301
3561
|
method: "get",
|
|
3302
3562
|
path: "/",
|
|
@@ -3331,7 +3591,7 @@ app14.openapi(
|
|
|
3331
3591
|
return c.json(result);
|
|
3332
3592
|
}
|
|
3333
3593
|
);
|
|
3334
|
-
|
|
3594
|
+
app15.openapi(
|
|
3335
3595
|
createRoute({
|
|
3336
3596
|
method: "get",
|
|
3337
3597
|
path: "/{id}",
|
|
@@ -3366,7 +3626,7 @@ app14.openapi(
|
|
|
3366
3626
|
return c.json({ data: project });
|
|
3367
3627
|
}
|
|
3368
3628
|
);
|
|
3369
|
-
|
|
3629
|
+
app15.openapi(
|
|
3370
3630
|
createRoute({
|
|
3371
3631
|
method: "post",
|
|
3372
3632
|
path: "/",
|
|
@@ -3424,7 +3684,7 @@ app14.openapi(
|
|
|
3424
3684
|
}
|
|
3425
3685
|
}
|
|
3426
3686
|
);
|
|
3427
|
-
|
|
3687
|
+
app15.openapi(
|
|
3428
3688
|
createRoute({
|
|
3429
3689
|
method: "patch",
|
|
3430
3690
|
path: "/{id}",
|
|
@@ -3470,7 +3730,7 @@ app14.openapi(
|
|
|
3470
3730
|
return c.json({ data: project });
|
|
3471
3731
|
}
|
|
3472
3732
|
);
|
|
3473
|
-
|
|
3733
|
+
app15.openapi(
|
|
3474
3734
|
createRoute({
|
|
3475
3735
|
method: "delete",
|
|
3476
3736
|
path: "/{id}",
|
|
@@ -3520,10 +3780,10 @@ app14.openapi(
|
|
|
3520
3780
|
}
|
|
3521
3781
|
}
|
|
3522
3782
|
);
|
|
3523
|
-
var projects_default =
|
|
3524
|
-
var
|
|
3525
|
-
var
|
|
3526
|
-
|
|
3783
|
+
var projects_default = app15;
|
|
3784
|
+
var logger4 = getLogger("tools");
|
|
3785
|
+
var app16 = new OpenAPIHono();
|
|
3786
|
+
app16.openapi(
|
|
3527
3787
|
createRoute({
|
|
3528
3788
|
method: "get",
|
|
3529
3789
|
path: "/",
|
|
@@ -3583,7 +3843,7 @@ app15.openapi(
|
|
|
3583
3843
|
return c.json(result);
|
|
3584
3844
|
}
|
|
3585
3845
|
);
|
|
3586
|
-
|
|
3846
|
+
app16.openapi(
|
|
3587
3847
|
createRoute({
|
|
3588
3848
|
method: "get",
|
|
3589
3849
|
path: "/{id}",
|
|
@@ -3620,7 +3880,7 @@ app15.openapi(
|
|
|
3620
3880
|
});
|
|
3621
3881
|
}
|
|
3622
3882
|
);
|
|
3623
|
-
|
|
3883
|
+
app16.openapi(
|
|
3624
3884
|
createRoute({
|
|
3625
3885
|
method: "post",
|
|
3626
3886
|
path: "/",
|
|
@@ -3653,7 +3913,7 @@ app15.openapi(
|
|
|
3653
3913
|
const { tenantId, projectId } = c.req.valid("param");
|
|
3654
3914
|
const body = c.req.valid("json");
|
|
3655
3915
|
const credentialStores = c.get("credentialStores");
|
|
3656
|
-
|
|
3916
|
+
logger4.info({ body }, "body");
|
|
3657
3917
|
const id = body.id || nanoid();
|
|
3658
3918
|
const tool = await createTool(dbClient_default)({
|
|
3659
3919
|
tenantId,
|
|
@@ -3673,7 +3933,7 @@ app15.openapi(
|
|
|
3673
3933
|
);
|
|
3674
3934
|
}
|
|
3675
3935
|
);
|
|
3676
|
-
|
|
3936
|
+
app16.openapi(
|
|
3677
3937
|
createRoute({
|
|
3678
3938
|
method: "put",
|
|
3679
3939
|
path: "/{id}",
|
|
@@ -3734,7 +3994,7 @@ app15.openapi(
|
|
|
3734
3994
|
});
|
|
3735
3995
|
}
|
|
3736
3996
|
);
|
|
3737
|
-
|
|
3997
|
+
app16.openapi(
|
|
3738
3998
|
createRoute({
|
|
3739
3999
|
method: "delete",
|
|
3740
4000
|
path: "/{id}",
|
|
@@ -3770,30 +4030,31 @@ app15.openapi(
|
|
|
3770
4030
|
return c.body(null, 204);
|
|
3771
4031
|
}
|
|
3772
4032
|
);
|
|
3773
|
-
var tools_default =
|
|
4033
|
+
var tools_default = app16;
|
|
3774
4034
|
|
|
3775
4035
|
// src/routes/index.ts
|
|
3776
|
-
var
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
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(
|
|
3783
4043
|
"/projects/:projectId/graphs/:graphId/agent-artifact-components",
|
|
3784
4044
|
agentArtifactComponents_default
|
|
3785
4045
|
);
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
var
|
|
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");
|
|
3797
4058
|
var pkceStore = /* @__PURE__ */ new Map();
|
|
3798
4059
|
function storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId) {
|
|
3799
4060
|
pkceStore.set(state, { codeVerifier, toolId, tenantId, projectId, clientId });
|
|
@@ -3828,7 +4089,10 @@ var OAuthService = class {
|
|
|
3828
4089
|
*/
|
|
3829
4090
|
async initiateOAuthFlow(params) {
|
|
3830
4091
|
const { tool, tenantId, projectId, toolId, baseUrl } = params;
|
|
3831
|
-
|
|
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);
|
|
3832
4096
|
if (!oAuthConfig) {
|
|
3833
4097
|
throw new Error("OAuth not supported by this server");
|
|
3834
4098
|
}
|
|
@@ -3852,7 +4116,7 @@ var OAuthService = class {
|
|
|
3852
4116
|
resource: tool.config.mcp.server.url
|
|
3853
4117
|
});
|
|
3854
4118
|
storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId);
|
|
3855
|
-
|
|
4119
|
+
logger5.info({ toolId, oAuthConfig, tenantId, projectId }, "OAuth flow initiated successfully");
|
|
3856
4120
|
return {
|
|
3857
4121
|
redirectUrl: authUrl,
|
|
3858
4122
|
state
|
|
@@ -3863,7 +4127,10 @@ var OAuthService = class {
|
|
|
3863
4127
|
*/
|
|
3864
4128
|
async exchangeCodeForTokens(params) {
|
|
3865
4129
|
const { code, codeVerifier, clientId, tool, baseUrl } = params;
|
|
3866
|
-
|
|
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);
|
|
3867
4134
|
if (!oAuthConfig?.tokenUrl) {
|
|
3868
4135
|
throw new Error("Could not discover OAuth token endpoint");
|
|
3869
4136
|
}
|
|
@@ -3878,9 +4145,9 @@ var OAuthService = class {
|
|
|
3878
4145
|
codeVerifier,
|
|
3879
4146
|
redirectUri
|
|
3880
4147
|
});
|
|
3881
|
-
|
|
4148
|
+
logger5.info({ tokenType: tokens.token_type }, "Token exchange successful with openid-client");
|
|
3882
4149
|
} catch (error) {
|
|
3883
|
-
|
|
4150
|
+
logger5.warn(
|
|
3884
4151
|
{ error: error instanceof Error ? error.message : error },
|
|
3885
4152
|
"openid-client failed, falling back to manual token exchange"
|
|
3886
4153
|
);
|
|
@@ -3891,7 +4158,7 @@ var OAuthService = class {
|
|
|
3891
4158
|
codeVerifier,
|
|
3892
4159
|
redirectUri
|
|
3893
4160
|
});
|
|
3894
|
-
|
|
4161
|
+
logger5.info({ tokenType: tokens.token_type }, "Manual token exchange successful");
|
|
3895
4162
|
}
|
|
3896
4163
|
return { tokens, oAuthConfig };
|
|
3897
4164
|
}
|
|
@@ -3899,7 +4166,7 @@ var OAuthService = class {
|
|
|
3899
4166
|
* Perform dynamic client registration
|
|
3900
4167
|
*/
|
|
3901
4168
|
async performDynamicClientRegistration(registrationUrl, redirectUri) {
|
|
3902
|
-
|
|
4169
|
+
logger5.info({ registrationUrl }, "Attempting dynamic client registration");
|
|
3903
4170
|
try {
|
|
3904
4171
|
const registrationResponse = await fetch(registrationUrl, {
|
|
3905
4172
|
method: "POST",
|
|
@@ -3922,11 +4189,11 @@ var OAuthService = class {
|
|
|
3922
4189
|
});
|
|
3923
4190
|
if (registrationResponse.ok) {
|
|
3924
4191
|
const registration = await registrationResponse.json();
|
|
3925
|
-
|
|
4192
|
+
logger5.info({ clientId: registration.client_id }, "Dynamic client registration successful");
|
|
3926
4193
|
return registration.client_id;
|
|
3927
4194
|
} else {
|
|
3928
4195
|
const errorText = await registrationResponse.text();
|
|
3929
|
-
|
|
4196
|
+
logger5.warn(
|
|
3930
4197
|
{
|
|
3931
4198
|
status: registrationResponse.status,
|
|
3932
4199
|
errorText
|
|
@@ -3935,7 +4202,7 @@ var OAuthService = class {
|
|
|
3935
4202
|
);
|
|
3936
4203
|
}
|
|
3937
4204
|
} catch (regError) {
|
|
3938
|
-
|
|
4205
|
+
logger5.warn(
|
|
3939
4206
|
{ error: regError },
|
|
3940
4207
|
"Dynamic client registration error, using default client_id"
|
|
3941
4208
|
);
|
|
@@ -3965,7 +4232,7 @@ var OAuthService = class {
|
|
|
3965
4232
|
const oauth = await import('openid-client');
|
|
3966
4233
|
const tokenUrl = new URL(oAuthConfig.tokenUrl);
|
|
3967
4234
|
const oauthServerUrl = `${tokenUrl.protocol}//${tokenUrl.host}`;
|
|
3968
|
-
|
|
4235
|
+
logger5.info({ oauthServerUrl, clientId }, "Attempting openid-client discovery");
|
|
3969
4236
|
const config = await oauth.discovery(
|
|
3970
4237
|
new URL(oauthServerUrl),
|
|
3971
4238
|
clientId,
|
|
@@ -3997,7 +4264,7 @@ var OAuthService = class {
|
|
|
3997
4264
|
*/
|
|
3998
4265
|
async exchangeManually(params) {
|
|
3999
4266
|
const { oAuthConfig, clientId, code, codeVerifier, redirectUri } = params;
|
|
4000
|
-
|
|
4267
|
+
logger5.info({ tokenUrl: oAuthConfig.tokenUrl }, "Attempting manual token exchange");
|
|
4001
4268
|
const tokenResponse = await fetch(oAuthConfig.tokenUrl, {
|
|
4002
4269
|
method: "POST",
|
|
4003
4270
|
headers: {
|
|
@@ -4015,7 +4282,7 @@ var OAuthService = class {
|
|
|
4015
4282
|
});
|
|
4016
4283
|
if (!tokenResponse.ok) {
|
|
4017
4284
|
const errorText = await tokenResponse.text();
|
|
4018
|
-
|
|
4285
|
+
logger5.error(
|
|
4019
4286
|
{
|
|
4020
4287
|
status: tokenResponse.status,
|
|
4021
4288
|
statusText: tokenResponse.statusText,
|
|
@@ -4058,8 +4325,8 @@ async function findOrCreateCredential(tenantId, projectId, credentialData) {
|
|
|
4058
4325
|
throw new Error(`Failed to save credential '${credentialData.id}' to database`);
|
|
4059
4326
|
}
|
|
4060
4327
|
}
|
|
4061
|
-
var
|
|
4062
|
-
var
|
|
4328
|
+
var app18 = new OpenAPIHono();
|
|
4329
|
+
var logger6 = getLogger("oauth-callback");
|
|
4063
4330
|
function getBaseUrlFromRequest(c) {
|
|
4064
4331
|
const url = new URL(c.req.url);
|
|
4065
4332
|
return `${url.protocol}//${url.host}`;
|
|
@@ -4145,7 +4412,7 @@ var OAuthCallbackQuerySchema = z$1.object({
|
|
|
4145
4412
|
error: z$1.string().optional(),
|
|
4146
4413
|
error_description: z$1.string().optional()
|
|
4147
4414
|
});
|
|
4148
|
-
|
|
4415
|
+
app18.openapi(
|
|
4149
4416
|
createRoute({
|
|
4150
4417
|
method: "get",
|
|
4151
4418
|
path: "/login",
|
|
@@ -4191,7 +4458,7 @@ app17.openapi(
|
|
|
4191
4458
|
try {
|
|
4192
4459
|
const tool = await getToolById(dbClient_default)({ scopes: { tenantId, projectId }, toolId });
|
|
4193
4460
|
if (!tool) {
|
|
4194
|
-
|
|
4461
|
+
logger6.error({ toolId, tenantId, projectId }, "Tool not found for OAuth login");
|
|
4195
4462
|
return c.text("Tool not found", 404);
|
|
4196
4463
|
}
|
|
4197
4464
|
const credentialStores = c.get("credentialStores");
|
|
@@ -4206,13 +4473,13 @@ app17.openapi(
|
|
|
4206
4473
|
});
|
|
4207
4474
|
return c.redirect(redirectUrl, 302);
|
|
4208
4475
|
} catch (error) {
|
|
4209
|
-
|
|
4476
|
+
logger6.error({ toolId, tenantId, projectId, error }, "OAuth login failed");
|
|
4210
4477
|
const errorMessage = error instanceof Error ? error.message : "Failed to initiate OAuth login";
|
|
4211
4478
|
return c.text(`OAuth Error: ${errorMessage}`, 500);
|
|
4212
4479
|
}
|
|
4213
4480
|
}
|
|
4214
4481
|
);
|
|
4215
|
-
|
|
4482
|
+
app18.openapi(
|
|
4216
4483
|
createRoute({
|
|
4217
4484
|
method: "get",
|
|
4218
4485
|
path: "/callback",
|
|
@@ -4248,9 +4515,9 @@ app17.openapi(
|
|
|
4248
4515
|
async (c) => {
|
|
4249
4516
|
try {
|
|
4250
4517
|
const { code, state, error, error_description } = c.req.valid("query");
|
|
4251
|
-
|
|
4518
|
+
logger6.info({ state, hasCode: !!code }, "OAuth callback received");
|
|
4252
4519
|
if (error) {
|
|
4253
|
-
|
|
4520
|
+
logger6.error({ error, error_description }, "OAuth authorization failed");
|
|
4254
4521
|
const errorMessage = error_description || error || "OAuth Authorization Failed. Please try again.";
|
|
4255
4522
|
const errorPage = generateOAuthCallbackPage({
|
|
4256
4523
|
title: "Authentication Failed",
|
|
@@ -4261,7 +4528,7 @@ app17.openapi(
|
|
|
4261
4528
|
}
|
|
4262
4529
|
const pkceData = retrievePKCEVerifier(state);
|
|
4263
4530
|
if (!pkceData) {
|
|
4264
|
-
|
|
4531
|
+
logger6.error({ state }, "Invalid or expired OAuth state");
|
|
4265
4532
|
const errorMessage = "OAuth Session Expired: The OAuth session has expired or is invalid. Please try again.";
|
|
4266
4533
|
const expiredPage = generateOAuthCallbackPage({
|
|
4267
4534
|
title: "Session Expired",
|
|
@@ -4278,8 +4545,8 @@ app17.openapi(
|
|
|
4278
4545
|
if (!tool) {
|
|
4279
4546
|
throw new Error(`Tool ${toolId} not found`);
|
|
4280
4547
|
}
|
|
4281
|
-
|
|
4282
|
-
|
|
4548
|
+
logger6.info({ toolId, tenantId, projectId }, "Processing OAuth callback");
|
|
4549
|
+
logger6.info({ toolId }, "Exchanging authorization code for access token");
|
|
4283
4550
|
const credentialStores = c.get("credentialStores");
|
|
4284
4551
|
const mcpTool = await dbResultToMcpTool(tool, dbClient_default, credentialStores);
|
|
4285
4552
|
const baseUrl = getBaseUrlFromRequest(c);
|
|
@@ -4290,7 +4557,7 @@ app17.openapi(
|
|
|
4290
4557
|
tool: mcpTool,
|
|
4291
4558
|
baseUrl
|
|
4292
4559
|
});
|
|
4293
|
-
|
|
4560
|
+
logger6.info(
|
|
4294
4561
|
{ toolId, tokenType: tokens.token_type, hasRefresh: !!tokens.refresh_token },
|
|
4295
4562
|
"Token exchange successful"
|
|
4296
4563
|
);
|
|
@@ -4337,7 +4604,7 @@ app17.openapi(
|
|
|
4337
4604
|
credentialReferenceId: newCredential.id
|
|
4338
4605
|
}
|
|
4339
4606
|
});
|
|
4340
|
-
|
|
4607
|
+
logger6.info({ toolId, credentialId: newCredential.id }, "OAuth flow completed successfully");
|
|
4341
4608
|
const successPage = generateOAuthCallbackPage({
|
|
4342
4609
|
title: "Authentication Complete",
|
|
4343
4610
|
message: "You have been successfully authenticated.",
|
|
@@ -4345,7 +4612,7 @@ app17.openapi(
|
|
|
4345
4612
|
});
|
|
4346
4613
|
return c.html(successPage);
|
|
4347
4614
|
} catch (error) {
|
|
4348
|
-
|
|
4615
|
+
logger6.error({ error }, "OAuth callback processing failed");
|
|
4349
4616
|
const errorMessage = "OAuth Processing Failed. Please try again.";
|
|
4350
4617
|
const errorPage = generateOAuthCallbackPage({
|
|
4351
4618
|
title: "Processing Failed",
|
|
@@ -4356,9 +4623,9 @@ app17.openapi(
|
|
|
4356
4623
|
}
|
|
4357
4624
|
}
|
|
4358
4625
|
);
|
|
4359
|
-
var oauth_default =
|
|
4360
|
-
var
|
|
4361
|
-
var
|
|
4626
|
+
var oauth_default = app18;
|
|
4627
|
+
var logger7 = getLogger("projectFull");
|
|
4628
|
+
var app19 = new OpenAPIHono();
|
|
4362
4629
|
var ProjectIdParamsSchema = z.object({
|
|
4363
4630
|
tenantId: z.string().openapi({
|
|
4364
4631
|
description: "Tenant identifier",
|
|
@@ -4375,7 +4642,7 @@ var TenantParamsSchema2 = z.object({
|
|
|
4375
4642
|
example: "tenant_123"
|
|
4376
4643
|
})
|
|
4377
4644
|
}).openapi("TenantParams");
|
|
4378
|
-
|
|
4645
|
+
app19.openapi(
|
|
4379
4646
|
createRoute({
|
|
4380
4647
|
method: "post",
|
|
4381
4648
|
path: "/project-full",
|
|
@@ -4418,7 +4685,7 @@ app18.openapi(
|
|
|
4418
4685
|
const projectData = c.req.valid("json");
|
|
4419
4686
|
const validatedProjectData = FullProjectDefinitionSchema.parse(projectData);
|
|
4420
4687
|
try {
|
|
4421
|
-
const createdProject = await createFullProjectServerSide(dbClient_default,
|
|
4688
|
+
const createdProject = await createFullProjectServerSide(dbClient_default, logger7)(
|
|
4422
4689
|
{ tenantId, projectId: validatedProjectData.id },
|
|
4423
4690
|
validatedProjectData
|
|
4424
4691
|
);
|
|
@@ -4434,7 +4701,7 @@ app18.openapi(
|
|
|
4434
4701
|
}
|
|
4435
4702
|
}
|
|
4436
4703
|
);
|
|
4437
|
-
|
|
4704
|
+
app19.openapi(
|
|
4438
4705
|
createRoute({
|
|
4439
4706
|
method: "get",
|
|
4440
4707
|
path: "/project-full/{projectId}",
|
|
@@ -4462,7 +4729,7 @@ app18.openapi(
|
|
|
4462
4729
|
try {
|
|
4463
4730
|
const project = await getFullProject(
|
|
4464
4731
|
dbClient_default,
|
|
4465
|
-
|
|
4732
|
+
logger7
|
|
4466
4733
|
)({
|
|
4467
4734
|
scopes: { tenantId, projectId }
|
|
4468
4735
|
});
|
|
@@ -4487,7 +4754,7 @@ app18.openapi(
|
|
|
4487
4754
|
}
|
|
4488
4755
|
}
|
|
4489
4756
|
);
|
|
4490
|
-
|
|
4757
|
+
app19.openapi(
|
|
4491
4758
|
createRoute({
|
|
4492
4759
|
method: "put",
|
|
4493
4760
|
path: "/project-full/{projectId}",
|
|
@@ -4538,15 +4805,15 @@ app18.openapi(
|
|
|
4538
4805
|
}
|
|
4539
4806
|
const existingProject = await getFullProject(
|
|
4540
4807
|
dbClient_default,
|
|
4541
|
-
|
|
4808
|
+
logger7
|
|
4542
4809
|
)({
|
|
4543
4810
|
scopes: { tenantId, projectId }
|
|
4544
4811
|
});
|
|
4545
4812
|
const isCreate = !existingProject;
|
|
4546
|
-
const updatedProject = isCreate ? await createFullProjectServerSide(dbClient_default,
|
|
4813
|
+
const updatedProject = isCreate ? await createFullProjectServerSide(dbClient_default, logger7)(
|
|
4547
4814
|
{ tenantId, projectId },
|
|
4548
4815
|
validatedProjectData
|
|
4549
|
-
) : await updateFullProjectServerSide(dbClient_default,
|
|
4816
|
+
) : await updateFullProjectServerSide(dbClient_default, logger7)(
|
|
4550
4817
|
{ tenantId, projectId },
|
|
4551
4818
|
validatedProjectData
|
|
4552
4819
|
);
|
|
@@ -4571,7 +4838,7 @@ app18.openapi(
|
|
|
4571
4838
|
}
|
|
4572
4839
|
}
|
|
4573
4840
|
);
|
|
4574
|
-
|
|
4841
|
+
app19.openapi(
|
|
4575
4842
|
createRoute({
|
|
4576
4843
|
method: "delete",
|
|
4577
4844
|
path: "/project-full/{projectId}",
|
|
@@ -4594,7 +4861,7 @@ app18.openapi(
|
|
|
4594
4861
|
try {
|
|
4595
4862
|
const deleted = await deleteFullProject(
|
|
4596
4863
|
dbClient_default,
|
|
4597
|
-
|
|
4864
|
+
logger7
|
|
4598
4865
|
)({
|
|
4599
4866
|
scopes: { tenantId, projectId }
|
|
4600
4867
|
});
|
|
@@ -4619,20 +4886,20 @@ app18.openapi(
|
|
|
4619
4886
|
}
|
|
4620
4887
|
}
|
|
4621
4888
|
);
|
|
4622
|
-
var projectFull_default =
|
|
4889
|
+
var projectFull_default = app19;
|
|
4623
4890
|
|
|
4624
4891
|
// src/app.ts
|
|
4625
|
-
var
|
|
4626
|
-
|
|
4892
|
+
var logger8 = getLogger("agents-manage-api");
|
|
4893
|
+
logger8.info({ logger: logger8.getTransports() }, "Logger initialized");
|
|
4627
4894
|
function createManagementHono(serverConfig, credentialStores) {
|
|
4628
|
-
const
|
|
4629
|
-
|
|
4630
|
-
|
|
4895
|
+
const app21 = new OpenAPIHono();
|
|
4896
|
+
app21.use("*", requestId());
|
|
4897
|
+
app21.use("*", async (c, next) => {
|
|
4631
4898
|
c.set("serverConfig", serverConfig);
|
|
4632
4899
|
c.set("credentialStores", credentialStores);
|
|
4633
4900
|
return next();
|
|
4634
4901
|
});
|
|
4635
|
-
|
|
4902
|
+
app21.use(
|
|
4636
4903
|
pinoLogger({
|
|
4637
4904
|
pino: getLogger("agents-manage-api").getPinoInstance(),
|
|
4638
4905
|
http: {
|
|
@@ -4645,7 +4912,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
4645
4912
|
}
|
|
4646
4913
|
})
|
|
4647
4914
|
);
|
|
4648
|
-
|
|
4915
|
+
app21.onError(async (err, c) => {
|
|
4649
4916
|
const isExpectedError = err instanceof HTTPException;
|
|
4650
4917
|
const status = isExpectedError ? err.status : 500;
|
|
4651
4918
|
const requestId2 = c.get("requestId") || "unknown";
|
|
@@ -4678,7 +4945,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
4678
4945
|
if (!isExpectedError) {
|
|
4679
4946
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
4680
4947
|
const errorStack = err instanceof Error ? err.stack : void 0;
|
|
4681
|
-
|
|
4948
|
+
logger8.error(
|
|
4682
4949
|
{
|
|
4683
4950
|
error: err,
|
|
4684
4951
|
message: errorMessage,
|
|
@@ -4689,7 +4956,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
4689
4956
|
"Unexpected server error occurred"
|
|
4690
4957
|
);
|
|
4691
4958
|
} else {
|
|
4692
|
-
|
|
4959
|
+
logger8.error(
|
|
4693
4960
|
{
|
|
4694
4961
|
error: err,
|
|
4695
4962
|
path: c.req.path,
|
|
@@ -4705,7 +4972,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
4705
4972
|
const response = err.getResponse();
|
|
4706
4973
|
return response;
|
|
4707
4974
|
} catch (responseError) {
|
|
4708
|
-
|
|
4975
|
+
logger8.error({ error: responseError }, "Error while handling HTTPException response");
|
|
4709
4976
|
}
|
|
4710
4977
|
}
|
|
4711
4978
|
const { status: respStatus, title, detail, instance } = await handleApiError(err, requestId2);
|
|
@@ -4720,7 +4987,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
4720
4987
|
...instance && { instance }
|
|
4721
4988
|
});
|
|
4722
4989
|
});
|
|
4723
|
-
|
|
4990
|
+
app21.use(
|
|
4724
4991
|
"*",
|
|
4725
4992
|
cors({
|
|
4726
4993
|
origin: (origin) => {
|
|
@@ -4734,7 +5001,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
4734
5001
|
credentials: true
|
|
4735
5002
|
})
|
|
4736
5003
|
);
|
|
4737
|
-
|
|
5004
|
+
app21.openapi(
|
|
4738
5005
|
createRoute({
|
|
4739
5006
|
method: "get",
|
|
4740
5007
|
path: "/health",
|
|
@@ -4751,13 +5018,13 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
4751
5018
|
return c.body(null, 204);
|
|
4752
5019
|
}
|
|
4753
5020
|
);
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
setupOpenAPIRoutes(
|
|
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);
|
|
4759
5026
|
const baseApp = new Hono();
|
|
4760
|
-
baseApp.route("/",
|
|
5027
|
+
baseApp.route("/", app21);
|
|
4761
5028
|
return baseApp;
|
|
4762
5029
|
}
|
|
4763
5030
|
|
|
@@ -4773,8 +5040,8 @@ var defaultConfig = {
|
|
|
4773
5040
|
};
|
|
4774
5041
|
var defaultStores = createDefaultCredentialStores();
|
|
4775
5042
|
var defaultRegistry = new CredentialStoreRegistry(defaultStores);
|
|
4776
|
-
var
|
|
4777
|
-
var index_default =
|
|
5043
|
+
var app20 = createManagementHono(defaultConfig, defaultRegistry);
|
|
5044
|
+
var index_default = app20;
|
|
4778
5045
|
function createManagementApp(config) {
|
|
4779
5046
|
const serverConfig = config?.serverConfig ?? defaultConfig;
|
|
4780
5047
|
const stores = config?.credentialStores ?? defaultStores;
|