@inkeep/agents-manage-api 0.3.0 → 0.6.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.
- package/dist/index.cjs +45 -74
- package/dist/index.js +44 -73
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -9,10 +9,8 @@ var cors = require('hono/cors');
|
|
|
9
9
|
var httpException = require('hono/http-exception');
|
|
10
10
|
var requestId = require('hono/request-id');
|
|
11
11
|
var honoPino = require('hono-pino');
|
|
12
|
-
var async_hooks = require('async_hooks');
|
|
13
|
-
var pino = require('pino');
|
|
14
|
-
var zod = require('zod');
|
|
15
12
|
var factory = require('hono/factory');
|
|
13
|
+
var zod = require('zod');
|
|
16
14
|
var swaggerUi = require('@hono/swagger-ui');
|
|
17
15
|
var nanoid = require('nanoid');
|
|
18
16
|
|
|
@@ -46,39 +44,8 @@ ${error.message}`
|
|
|
46
44
|
};
|
|
47
45
|
var env = parseEnv();
|
|
48
46
|
|
|
49
|
-
// src/
|
|
50
|
-
var
|
|
51
|
-
var loggerConfig = {
|
|
52
|
-
level: env.LOG_LEVEL,
|
|
53
|
-
serializers: {
|
|
54
|
-
obj: (value) => ({ ...value })
|
|
55
|
-
},
|
|
56
|
-
redact: ["req.headers.authorization", 'req.headers["x-inkeep-admin-authentication"]'],
|
|
57
|
-
// Only use pino-pretty in development
|
|
58
|
-
...isDevelopment && {
|
|
59
|
-
transport: {
|
|
60
|
-
target: "pino-pretty",
|
|
61
|
-
options: {
|
|
62
|
-
sync: true,
|
|
63
|
-
destination: 1,
|
|
64
|
-
// stdout
|
|
65
|
-
colorize: true,
|
|
66
|
-
translateTime: "SYS:standard"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var logger = pino.pino(loggerConfig);
|
|
72
|
-
var asyncLocalStorage = new async_hooks.AsyncLocalStorage();
|
|
73
|
-
function getLogger(name) {
|
|
74
|
-
const store = asyncLocalStorage.getStore();
|
|
75
|
-
const reqId = store?.get("requestId") || void 0;
|
|
76
|
-
if (!reqId) {
|
|
77
|
-
return logger.child({ name });
|
|
78
|
-
}
|
|
79
|
-
return logger.child({ reqId, name });
|
|
80
|
-
}
|
|
81
|
-
var logger2 = agentsCore.getLogger("env-key-auth");
|
|
47
|
+
// src/middleware/auth.ts
|
|
48
|
+
var logger = agentsCore.getLogger("env-key-auth");
|
|
82
49
|
var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
|
|
83
50
|
if (env.INKEEP_AGENTS_MANAGE_API_BYPASS_SECRET) {
|
|
84
51
|
const authHeader = c.req.header("Authorization");
|
|
@@ -89,7 +56,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
|
|
|
89
56
|
}
|
|
90
57
|
const apiKey = authHeader.substring(7);
|
|
91
58
|
if (apiKey === env.INKEEP_AGENTS_MANAGE_API_BYPASS_SECRET) {
|
|
92
|
-
|
|
59
|
+
logger.info({}, "Bypass secret authenticated successfully");
|
|
93
60
|
await next();
|
|
94
61
|
return;
|
|
95
62
|
} else {
|
|
@@ -1860,6 +1827,7 @@ app7.openapi(
|
|
|
1860
1827
|
const insertData = {
|
|
1861
1828
|
tenantId,
|
|
1862
1829
|
projectId,
|
|
1830
|
+
name: body.name,
|
|
1863
1831
|
graphId: body.graphId,
|
|
1864
1832
|
...keyDataWithoutKey,
|
|
1865
1833
|
expiresAt: body.expiresAt || void 0
|
|
@@ -1928,7 +1896,8 @@ app7.openapi(
|
|
|
1928
1896
|
scopes: { tenantId, projectId },
|
|
1929
1897
|
id,
|
|
1930
1898
|
data: {
|
|
1931
|
-
expiresAt: body.expiresAt
|
|
1899
|
+
expiresAt: body.expiresAt,
|
|
1900
|
+
name: body.name
|
|
1932
1901
|
}
|
|
1933
1902
|
});
|
|
1934
1903
|
if (!updatedApiKey) {
|
|
@@ -3058,7 +3027,7 @@ app12.openapi(
|
|
|
3058
3027
|
}
|
|
3059
3028
|
);
|
|
3060
3029
|
var externalAgents_default = app12;
|
|
3061
|
-
var
|
|
3030
|
+
var logger2 = agentsCore.getLogger("graphFull");
|
|
3062
3031
|
var app13 = new zodOpenapi.OpenAPIHono();
|
|
3063
3032
|
var GraphIdParamsSchema = zod.z.object({
|
|
3064
3033
|
tenantId: zod.z.string().openapi({
|
|
@@ -3116,7 +3085,7 @@ app13.openapi(
|
|
|
3116
3085
|
const { tenantId, projectId } = c.req.valid("param");
|
|
3117
3086
|
const graphData = c.req.valid("json");
|
|
3118
3087
|
const validatedGraphData = agentsCore.FullGraphDefinitionSchema.parse(graphData);
|
|
3119
|
-
const createdGraph = await agentsCore.createFullGraphServerSide(dbClient_default,
|
|
3088
|
+
const createdGraph = await agentsCore.createFullGraphServerSide(dbClient_default, logger2)(
|
|
3120
3089
|
{ tenantId, projectId },
|
|
3121
3090
|
validatedGraphData
|
|
3122
3091
|
);
|
|
@@ -3151,7 +3120,7 @@ app13.openapi(
|
|
|
3151
3120
|
try {
|
|
3152
3121
|
const graph = await agentsCore.getFullGraph(
|
|
3153
3122
|
dbClient_default,
|
|
3154
|
-
|
|
3123
|
+
logger2
|
|
3155
3124
|
)({
|
|
3156
3125
|
scopes: { tenantId, projectId, graphId }
|
|
3157
3126
|
});
|
|
@@ -3227,15 +3196,15 @@ app13.openapi(
|
|
|
3227
3196
|
}
|
|
3228
3197
|
const existingGraph = await agentsCore.getFullGraph(
|
|
3229
3198
|
dbClient_default,
|
|
3230
|
-
|
|
3199
|
+
logger2
|
|
3231
3200
|
)({
|
|
3232
3201
|
scopes: { tenantId, projectId, graphId }
|
|
3233
3202
|
});
|
|
3234
3203
|
const isCreate = !existingGraph;
|
|
3235
|
-
const updatedGraph = isCreate ? await agentsCore.createFullGraphServerSide(dbClient_default,
|
|
3204
|
+
const updatedGraph = isCreate ? await agentsCore.createFullGraphServerSide(dbClient_default, logger2)(
|
|
3236
3205
|
{ tenantId, projectId },
|
|
3237
3206
|
validatedGraphData
|
|
3238
|
-
) : await agentsCore.updateFullGraphServerSide(dbClient_default,
|
|
3207
|
+
) : await agentsCore.updateFullGraphServerSide(dbClient_default, logger2)(
|
|
3239
3208
|
{ tenantId, projectId },
|
|
3240
3209
|
validatedGraphData
|
|
3241
3210
|
);
|
|
@@ -3283,7 +3252,7 @@ app13.openapi(
|
|
|
3283
3252
|
try {
|
|
3284
3253
|
const deleted = await agentsCore.deleteFullGraph(
|
|
3285
3254
|
dbClient_default,
|
|
3286
|
-
|
|
3255
|
+
logger2
|
|
3287
3256
|
)({
|
|
3288
3257
|
scopes: { tenantId, projectId, graphId }
|
|
3289
3258
|
});
|
|
@@ -3550,7 +3519,7 @@ function extractInputSchema(toolDef) {
|
|
|
3550
3519
|
}
|
|
3551
3520
|
return {};
|
|
3552
3521
|
}
|
|
3553
|
-
var
|
|
3522
|
+
var logger3 = agentsCore.getLogger("tools");
|
|
3554
3523
|
var convertToMCPToolConfig = (tool) => {
|
|
3555
3524
|
return {
|
|
3556
3525
|
id: tool.id,
|
|
@@ -3659,7 +3628,7 @@ var checkToolHealth = async (tool, credentialStoreRegistry) => {
|
|
|
3659
3628
|
}
|
|
3660
3629
|
};
|
|
3661
3630
|
} catch (error) {
|
|
3662
|
-
|
|
3631
|
+
logger3.error({ toolId: tool.id, error }, "Tool health check failed");
|
|
3663
3632
|
if (error instanceof Error && await agentsCore.detectAuthenticationRequired(tool, error)) {
|
|
3664
3633
|
return {
|
|
3665
3634
|
status: "needs_auth",
|
|
@@ -3740,7 +3709,7 @@ var discoverToolsFromServer = async (tool, credentialStoreRegistry) => {
|
|
|
3740
3709
|
);
|
|
3741
3710
|
return toolDefinitions;
|
|
3742
3711
|
} catch (error) {
|
|
3743
|
-
|
|
3712
|
+
logger3.error({ toolId: tool.id, error }, "Tool discovery failed");
|
|
3744
3713
|
throw error;
|
|
3745
3714
|
}
|
|
3746
3715
|
};
|
|
@@ -3804,7 +3773,7 @@ var checkAllToolsHealth = async (tenantId, projectId, credentialStoreRegistry) =
|
|
|
3804
3773
|
};
|
|
3805
3774
|
|
|
3806
3775
|
// src/utils/auth-detection.ts
|
|
3807
|
-
var
|
|
3776
|
+
var logger4 = agentsCore.getLogger("auth-detection");
|
|
3808
3777
|
var getWellKnownUrls = (baseUrl) => [
|
|
3809
3778
|
`${baseUrl}/.well-known/oauth-authorization-server`,
|
|
3810
3779
|
`${baseUrl}/.well-known/openid-configuration`
|
|
@@ -3826,12 +3795,12 @@ var tryWellKnownEndpoints = async (baseUrl) => {
|
|
|
3826
3795
|
if (response.ok) {
|
|
3827
3796
|
const metadata = await response.json();
|
|
3828
3797
|
if (validateOAuthMetadata(metadata)) {
|
|
3829
|
-
|
|
3798
|
+
logger4.debug({ baseUrl, wellKnownUrl }, "OAuth 2.1/PKCE support detected");
|
|
3830
3799
|
return buildOAuthConfig(metadata);
|
|
3831
3800
|
}
|
|
3832
3801
|
}
|
|
3833
3802
|
} catch (error) {
|
|
3834
|
-
|
|
3803
|
+
logger4.debug({ wellKnownUrl, error }, "OAuth endpoint check failed");
|
|
3835
3804
|
}
|
|
3836
3805
|
}
|
|
3837
3806
|
return null;
|
|
@@ -3866,7 +3835,7 @@ var discoverOAuthEndpoints = async (serverUrl) => {
|
|
|
3866
3835
|
};
|
|
3867
3836
|
|
|
3868
3837
|
// src/utils/oauth-service.ts
|
|
3869
|
-
var
|
|
3838
|
+
var logger5 = agentsCore.getLogger("oauth-service");
|
|
3870
3839
|
var pkceStore = /* @__PURE__ */ new Map();
|
|
3871
3840
|
function storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId) {
|
|
3872
3841
|
pkceStore.set(state, { codeVerifier, toolId, tenantId, projectId, clientId });
|
|
@@ -3924,7 +3893,7 @@ var OAuthService = class {
|
|
|
3924
3893
|
resource: tool.config.mcp.server.url
|
|
3925
3894
|
});
|
|
3926
3895
|
storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId);
|
|
3927
|
-
|
|
3896
|
+
logger5.info({ toolId, oAuthConfig, tenantId, projectId }, "OAuth flow initiated successfully");
|
|
3928
3897
|
return {
|
|
3929
3898
|
redirectUrl: authUrl,
|
|
3930
3899
|
state
|
|
@@ -3949,9 +3918,9 @@ var OAuthService = class {
|
|
|
3949
3918
|
codeVerifier,
|
|
3950
3919
|
redirectUri
|
|
3951
3920
|
});
|
|
3952
|
-
|
|
3921
|
+
logger5.info({ tokenType: tokens.token_type }, "Token exchange successful with openid-client");
|
|
3953
3922
|
} catch (error) {
|
|
3954
|
-
|
|
3923
|
+
logger5.warn(
|
|
3955
3924
|
{ error: error instanceof Error ? error.message : error },
|
|
3956
3925
|
"openid-client failed, falling back to manual token exchange"
|
|
3957
3926
|
);
|
|
@@ -3962,7 +3931,7 @@ var OAuthService = class {
|
|
|
3962
3931
|
codeVerifier,
|
|
3963
3932
|
redirectUri
|
|
3964
3933
|
});
|
|
3965
|
-
|
|
3934
|
+
logger5.info({ tokenType: tokens.token_type }, "Manual token exchange successful");
|
|
3966
3935
|
}
|
|
3967
3936
|
return { tokens, oAuthConfig };
|
|
3968
3937
|
}
|
|
@@ -3970,7 +3939,7 @@ var OAuthService = class {
|
|
|
3970
3939
|
* Perform dynamic client registration
|
|
3971
3940
|
*/
|
|
3972
3941
|
async performDynamicClientRegistration(registrationUrl, redirectUri) {
|
|
3973
|
-
|
|
3942
|
+
logger5.info({ registrationUrl }, "Attempting dynamic client registration");
|
|
3974
3943
|
try {
|
|
3975
3944
|
const registrationResponse = await fetch(registrationUrl, {
|
|
3976
3945
|
method: "POST",
|
|
@@ -3993,11 +3962,11 @@ var OAuthService = class {
|
|
|
3993
3962
|
});
|
|
3994
3963
|
if (registrationResponse.ok) {
|
|
3995
3964
|
const registration = await registrationResponse.json();
|
|
3996
|
-
|
|
3965
|
+
logger5.info({ clientId: registration.client_id }, "Dynamic client registration successful");
|
|
3997
3966
|
return registration.client_id;
|
|
3998
3967
|
} else {
|
|
3999
3968
|
const errorText = await registrationResponse.text();
|
|
4000
|
-
|
|
3969
|
+
logger5.warn(
|
|
4001
3970
|
{
|
|
4002
3971
|
status: registrationResponse.status,
|
|
4003
3972
|
errorText
|
|
@@ -4006,7 +3975,7 @@ var OAuthService = class {
|
|
|
4006
3975
|
);
|
|
4007
3976
|
}
|
|
4008
3977
|
} catch (regError) {
|
|
4009
|
-
|
|
3978
|
+
logger5.warn(
|
|
4010
3979
|
{ error: regError },
|
|
4011
3980
|
"Dynamic client registration error, using default client_id"
|
|
4012
3981
|
);
|
|
@@ -4036,7 +4005,7 @@ var OAuthService = class {
|
|
|
4036
4005
|
const oauth = await import('openid-client');
|
|
4037
4006
|
const tokenUrl = new URL(oAuthConfig.tokenUrl);
|
|
4038
4007
|
const oauthServerUrl = `${tokenUrl.protocol}//${tokenUrl.host}`;
|
|
4039
|
-
|
|
4008
|
+
logger5.info({ oauthServerUrl, clientId }, "Attempting openid-client discovery");
|
|
4040
4009
|
const config = await oauth.discovery(
|
|
4041
4010
|
new URL(oauthServerUrl),
|
|
4042
4011
|
clientId,
|
|
@@ -4068,7 +4037,7 @@ var OAuthService = class {
|
|
|
4068
4037
|
*/
|
|
4069
4038
|
async exchangeManually(params) {
|
|
4070
4039
|
const { oAuthConfig, clientId, code, codeVerifier, redirectUri } = params;
|
|
4071
|
-
|
|
4040
|
+
logger5.info({ tokenUrl: oAuthConfig.tokenUrl }, "Attempting manual token exchange");
|
|
4072
4041
|
const tokenResponse = await fetch(oAuthConfig.tokenUrl, {
|
|
4073
4042
|
method: "POST",
|
|
4074
4043
|
headers: {
|
|
@@ -4086,7 +4055,7 @@ var OAuthService = class {
|
|
|
4086
4055
|
});
|
|
4087
4056
|
if (!tokenResponse.ok) {
|
|
4088
4057
|
const errorText = await tokenResponse.text();
|
|
4089
|
-
|
|
4058
|
+
logger5.error(
|
|
4090
4059
|
{
|
|
4091
4060
|
status: tokenResponse.status,
|
|
4092
4061
|
statusText: tokenResponse.statusText,
|
|
@@ -4104,6 +4073,7 @@ var OAuthService = class {
|
|
|
4104
4073
|
var oauthService = new OAuthService();
|
|
4105
4074
|
|
|
4106
4075
|
// src/routes/tools.ts
|
|
4076
|
+
var logger6 = agentsCore.getLogger("tools");
|
|
4107
4077
|
var app15 = new zodOpenapi.OpenAPIHono();
|
|
4108
4078
|
app15.openapi(
|
|
4109
4079
|
zodOpenapi.createRoute({
|
|
@@ -4226,7 +4196,7 @@ app15.openapi(
|
|
|
4226
4196
|
async (c) => {
|
|
4227
4197
|
const { tenantId, projectId } = c.req.valid("param");
|
|
4228
4198
|
const body = c.req.valid("json");
|
|
4229
|
-
|
|
4199
|
+
logger6.info({ body }, "body");
|
|
4230
4200
|
const id = body.id || nanoid.nanoid();
|
|
4231
4201
|
const tool = await agentsCore.createTool(dbClient_default)({
|
|
4232
4202
|
tenantId,
|
|
@@ -4647,7 +4617,6 @@ app15.openapi(
|
|
|
4647
4617
|
}),
|
|
4648
4618
|
async (c) => {
|
|
4649
4619
|
const { tenantId, projectId, id } = c.req.valid("param");
|
|
4650
|
-
const logger9 = getLogger("oauth-login");
|
|
4651
4620
|
try {
|
|
4652
4621
|
const tool = await agentsCore.getToolById(dbClient_default)({ scopes: { tenantId, projectId }, toolId: id });
|
|
4653
4622
|
if (!tool) {
|
|
@@ -4665,7 +4634,7 @@ app15.openapi(
|
|
|
4665
4634
|
});
|
|
4666
4635
|
return c.redirect(redirectUrl, 302);
|
|
4667
4636
|
} catch (error) {
|
|
4668
|
-
|
|
4637
|
+
logger6.error({ toolId: id, error }, "OAuth login failed");
|
|
4669
4638
|
if (error && typeof error === "object" && "code" in error) {
|
|
4670
4639
|
const apiError = error;
|
|
4671
4640
|
return c.json({ error: apiError.message }, apiError.code === "not_found" ? 404 : 400);
|
|
@@ -4700,7 +4669,7 @@ app16.route("/projects/:projectId/api-keys", apiKeys_default);
|
|
|
4700
4669
|
app16.route("/projects/:projectId/graph", graphFull_default);
|
|
4701
4670
|
var routes_default = app16;
|
|
4702
4671
|
var app17 = new zodOpenapi.OpenAPIHono();
|
|
4703
|
-
var logger7 = getLogger("oauth-callback");
|
|
4672
|
+
var logger7 = agentsCore.getLogger("oauth-callback");
|
|
4704
4673
|
var OAuthCallbackQuerySchema = zodOpenapi.z.object({
|
|
4705
4674
|
code: zodOpenapi.z.string().min(1, "Authorization code is required"),
|
|
4706
4675
|
state: zodOpenapi.z.string().min(1, "State parameter is required"),
|
|
@@ -4766,7 +4735,7 @@ app17.openapi(
|
|
|
4766
4735
|
throw new Error(`Tool ${toolId} not found`);
|
|
4767
4736
|
}
|
|
4768
4737
|
logger7.info({ toolId, tenantId, projectId }, "Processing OAuth callback");
|
|
4769
|
-
logger7.info("Exchanging authorization code for access token");
|
|
4738
|
+
logger7.info({ toolId }, "Exchanging authorization code for access token");
|
|
4770
4739
|
const mcpTool = agentsCore.dbResultToMcpTool(tool);
|
|
4771
4740
|
const { tokens } = await oauthService.exchangeCodeForTokens({
|
|
4772
4741
|
code,
|
|
@@ -4803,7 +4772,7 @@ app17.openapi(
|
|
|
4803
4772
|
data: credentialData
|
|
4804
4773
|
});
|
|
4805
4774
|
} else {
|
|
4806
|
-
logger7.info("Creating new credential");
|
|
4775
|
+
logger7.info({ credentialId }, "Creating new credential");
|
|
4807
4776
|
credential = await agentsCore.createCredentialReference(dbClient_default)({
|
|
4808
4777
|
tenantId,
|
|
4809
4778
|
projectId,
|
|
@@ -4870,7 +4839,7 @@ app17.openapi(
|
|
|
4870
4839
|
}
|
|
4871
4840
|
);
|
|
4872
4841
|
var oauth_default = app17;
|
|
4873
|
-
var logger8 = getLogger("projectFull");
|
|
4842
|
+
var logger8 = agentsCore.getLogger("projectFull");
|
|
4874
4843
|
var app18 = new zodOpenapi.OpenAPIHono();
|
|
4875
4844
|
var ProjectIdParamsSchema = zod.z.object({
|
|
4876
4845
|
tenantId: zod.z.string().openapi({
|
|
@@ -5135,6 +5104,8 @@ app18.openapi(
|
|
|
5135
5104
|
var projectFull_default = app18;
|
|
5136
5105
|
|
|
5137
5106
|
// src/app.ts
|
|
5107
|
+
var logger9 = agentsCore.getLogger("agents-manage-api");
|
|
5108
|
+
logger9.info({ logger: logger9.getTransports() }, "Logger initialized");
|
|
5138
5109
|
function createManagementHono(serverConfig, credentialStores) {
|
|
5139
5110
|
const app20 = new zodOpenapi.OpenAPIHono();
|
|
5140
5111
|
app20.use("*", requestId.requestId());
|
|
@@ -5145,7 +5116,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5145
5116
|
});
|
|
5146
5117
|
app20.use(
|
|
5147
5118
|
honoPino.pinoLogger({
|
|
5148
|
-
pino: getLogger(),
|
|
5119
|
+
pino: agentsCore.getLogger("agents-manage-api").getPinoInstance(),
|
|
5149
5120
|
http: {
|
|
5150
5121
|
onResLevel(c) {
|
|
5151
5122
|
if (c.res.status >= 500) {
|
|
@@ -5189,7 +5160,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5189
5160
|
if (!isExpectedError) {
|
|
5190
5161
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
5191
5162
|
const errorStack = err instanceof Error ? err.stack : void 0;
|
|
5192
|
-
|
|
5163
|
+
logger9.error(
|
|
5193
5164
|
{
|
|
5194
5165
|
error: err,
|
|
5195
5166
|
message: errorMessage,
|
|
@@ -5200,7 +5171,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5200
5171
|
"Unexpected server error occurred"
|
|
5201
5172
|
);
|
|
5202
5173
|
} else {
|
|
5203
|
-
|
|
5174
|
+
logger9.error(
|
|
5204
5175
|
{
|
|
5205
5176
|
error: err,
|
|
5206
5177
|
path: c.req.path,
|
|
@@ -5216,7 +5187,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5216
5187
|
const response = err.getResponse();
|
|
5217
5188
|
return response;
|
|
5218
5189
|
} catch (responseError) {
|
|
5219
|
-
|
|
5190
|
+
logger9.error({ error: responseError }, "Error while handling HTTPException response");
|
|
5220
5191
|
}
|
|
5221
5192
|
}
|
|
5222
5193
|
const { status: respStatus, title, detail, instance } = await agentsCore.handleApiError(err, requestId2);
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { loadEnvironmentFiles, getLogger
|
|
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, getToolsForAgent, 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, getCredentialReferenceById, CredentialReferenceApiInsertSchema, createCredentialReference, CredentialReferenceApiUpdateSchema, updateCredentialReference, 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, listToolsByStatus, dbResultToMcpTool, listTools, getToolById, ToolApiInsertSchema, createTool, ToolApiUpdateSchema, updateTool, deleteTool, getCredentialReference, CredentialStoreType, FullProjectDefinitionSchema, createFullProjectServerSide, getFullProject, updateFullProjectServerSide, deleteFullProject, createDefaultCredentialStores, CredentialStoreRegistry, ContextResolver, CredentialStuffer, McpClient, detectAuthenticationRequired, handleApiError, MCPServerType, MCPTransportType } 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';
|
|
5
5
|
import { HTTPException } from 'hono/http-exception';
|
|
6
6
|
import { requestId } from 'hono/request-id';
|
|
7
7
|
import { pinoLogger } from 'hono-pino';
|
|
8
|
-
import { AsyncLocalStorage } from 'async_hooks';
|
|
9
|
-
import { pino } from 'pino';
|
|
10
|
-
import { z } from 'zod';
|
|
11
8
|
import { createMiddleware } from 'hono/factory';
|
|
9
|
+
import { z } from 'zod';
|
|
12
10
|
import { swaggerUI } from '@hono/swagger-ui';
|
|
13
11
|
import { nanoid } from 'nanoid';
|
|
14
12
|
|
|
@@ -42,39 +40,8 @@ ${error.message}`
|
|
|
42
40
|
};
|
|
43
41
|
var env = parseEnv();
|
|
44
42
|
|
|
45
|
-
// src/
|
|
46
|
-
var
|
|
47
|
-
var loggerConfig = {
|
|
48
|
-
level: env.LOG_LEVEL,
|
|
49
|
-
serializers: {
|
|
50
|
-
obj: (value) => ({ ...value })
|
|
51
|
-
},
|
|
52
|
-
redact: ["req.headers.authorization", 'req.headers["x-inkeep-admin-authentication"]'],
|
|
53
|
-
// Only use pino-pretty in development
|
|
54
|
-
...isDevelopment && {
|
|
55
|
-
transport: {
|
|
56
|
-
target: "pino-pretty",
|
|
57
|
-
options: {
|
|
58
|
-
sync: true,
|
|
59
|
-
destination: 1,
|
|
60
|
-
// stdout
|
|
61
|
-
colorize: true,
|
|
62
|
-
translateTime: "SYS:standard"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
var logger = pino(loggerConfig);
|
|
68
|
-
var asyncLocalStorage = new AsyncLocalStorage();
|
|
69
|
-
function getLogger(name) {
|
|
70
|
-
const store = asyncLocalStorage.getStore();
|
|
71
|
-
const reqId = store?.get("requestId") || void 0;
|
|
72
|
-
if (!reqId) {
|
|
73
|
-
return logger.child({ name });
|
|
74
|
-
}
|
|
75
|
-
return logger.child({ reqId, name });
|
|
76
|
-
}
|
|
77
|
-
var logger2 = getLogger$1("env-key-auth");
|
|
43
|
+
// src/middleware/auth.ts
|
|
44
|
+
var logger = getLogger("env-key-auth");
|
|
78
45
|
var apiKeyAuth = () => createMiddleware(async (c, next) => {
|
|
79
46
|
if (env.INKEEP_AGENTS_MANAGE_API_BYPASS_SECRET) {
|
|
80
47
|
const authHeader = c.req.header("Authorization");
|
|
@@ -85,7 +52,7 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
|
|
|
85
52
|
}
|
|
86
53
|
const apiKey = authHeader.substring(7);
|
|
87
54
|
if (apiKey === env.INKEEP_AGENTS_MANAGE_API_BYPASS_SECRET) {
|
|
88
|
-
|
|
55
|
+
logger.info({}, "Bypass secret authenticated successfully");
|
|
89
56
|
await next();
|
|
90
57
|
return;
|
|
91
58
|
} else {
|
|
@@ -1856,6 +1823,7 @@ app7.openapi(
|
|
|
1856
1823
|
const insertData = {
|
|
1857
1824
|
tenantId,
|
|
1858
1825
|
projectId,
|
|
1826
|
+
name: body.name,
|
|
1859
1827
|
graphId: body.graphId,
|
|
1860
1828
|
...keyDataWithoutKey,
|
|
1861
1829
|
expiresAt: body.expiresAt || void 0
|
|
@@ -1924,7 +1892,8 @@ app7.openapi(
|
|
|
1924
1892
|
scopes: { tenantId, projectId },
|
|
1925
1893
|
id,
|
|
1926
1894
|
data: {
|
|
1927
|
-
expiresAt: body.expiresAt
|
|
1895
|
+
expiresAt: body.expiresAt,
|
|
1896
|
+
name: body.name
|
|
1928
1897
|
}
|
|
1929
1898
|
});
|
|
1930
1899
|
if (!updatedApiKey) {
|
|
@@ -3054,7 +3023,7 @@ app12.openapi(
|
|
|
3054
3023
|
}
|
|
3055
3024
|
);
|
|
3056
3025
|
var externalAgents_default = app12;
|
|
3057
|
-
var
|
|
3026
|
+
var logger2 = getLogger("graphFull");
|
|
3058
3027
|
var app13 = new OpenAPIHono();
|
|
3059
3028
|
var GraphIdParamsSchema = z.object({
|
|
3060
3029
|
tenantId: z.string().openapi({
|
|
@@ -3112,7 +3081,7 @@ app13.openapi(
|
|
|
3112
3081
|
const { tenantId, projectId } = c.req.valid("param");
|
|
3113
3082
|
const graphData = c.req.valid("json");
|
|
3114
3083
|
const validatedGraphData = FullGraphDefinitionSchema.parse(graphData);
|
|
3115
|
-
const createdGraph = await createFullGraphServerSide(dbClient_default,
|
|
3084
|
+
const createdGraph = await createFullGraphServerSide(dbClient_default, logger2)(
|
|
3116
3085
|
{ tenantId, projectId },
|
|
3117
3086
|
validatedGraphData
|
|
3118
3087
|
);
|
|
@@ -3147,7 +3116,7 @@ app13.openapi(
|
|
|
3147
3116
|
try {
|
|
3148
3117
|
const graph = await getFullGraph(
|
|
3149
3118
|
dbClient_default,
|
|
3150
|
-
|
|
3119
|
+
logger2
|
|
3151
3120
|
)({
|
|
3152
3121
|
scopes: { tenantId, projectId, graphId }
|
|
3153
3122
|
});
|
|
@@ -3223,15 +3192,15 @@ app13.openapi(
|
|
|
3223
3192
|
}
|
|
3224
3193
|
const existingGraph = await getFullGraph(
|
|
3225
3194
|
dbClient_default,
|
|
3226
|
-
|
|
3195
|
+
logger2
|
|
3227
3196
|
)({
|
|
3228
3197
|
scopes: { tenantId, projectId, graphId }
|
|
3229
3198
|
});
|
|
3230
3199
|
const isCreate = !existingGraph;
|
|
3231
|
-
const updatedGraph = isCreate ? await createFullGraphServerSide(dbClient_default,
|
|
3200
|
+
const updatedGraph = isCreate ? await createFullGraphServerSide(dbClient_default, logger2)(
|
|
3232
3201
|
{ tenantId, projectId },
|
|
3233
3202
|
validatedGraphData
|
|
3234
|
-
) : await updateFullGraphServerSide(dbClient_default,
|
|
3203
|
+
) : await updateFullGraphServerSide(dbClient_default, logger2)(
|
|
3235
3204
|
{ tenantId, projectId },
|
|
3236
3205
|
validatedGraphData
|
|
3237
3206
|
);
|
|
@@ -3279,7 +3248,7 @@ app13.openapi(
|
|
|
3279
3248
|
try {
|
|
3280
3249
|
const deleted = await deleteFullGraph(
|
|
3281
3250
|
dbClient_default,
|
|
3282
|
-
|
|
3251
|
+
logger2
|
|
3283
3252
|
)({
|
|
3284
3253
|
scopes: { tenantId, projectId, graphId }
|
|
3285
3254
|
});
|
|
@@ -3546,7 +3515,7 @@ function extractInputSchema(toolDef) {
|
|
|
3546
3515
|
}
|
|
3547
3516
|
return {};
|
|
3548
3517
|
}
|
|
3549
|
-
var
|
|
3518
|
+
var logger3 = getLogger("tools");
|
|
3550
3519
|
var convertToMCPToolConfig = (tool) => {
|
|
3551
3520
|
return {
|
|
3552
3521
|
id: tool.id,
|
|
@@ -3655,7 +3624,7 @@ var checkToolHealth = async (tool, credentialStoreRegistry) => {
|
|
|
3655
3624
|
}
|
|
3656
3625
|
};
|
|
3657
3626
|
} catch (error) {
|
|
3658
|
-
|
|
3627
|
+
logger3.error({ toolId: tool.id, error }, "Tool health check failed");
|
|
3659
3628
|
if (error instanceof Error && await detectAuthenticationRequired(tool, error)) {
|
|
3660
3629
|
return {
|
|
3661
3630
|
status: "needs_auth",
|
|
@@ -3736,7 +3705,7 @@ var discoverToolsFromServer = async (tool, credentialStoreRegistry) => {
|
|
|
3736
3705
|
);
|
|
3737
3706
|
return toolDefinitions;
|
|
3738
3707
|
} catch (error) {
|
|
3739
|
-
|
|
3708
|
+
logger3.error({ toolId: tool.id, error }, "Tool discovery failed");
|
|
3740
3709
|
throw error;
|
|
3741
3710
|
}
|
|
3742
3711
|
};
|
|
@@ -3800,7 +3769,7 @@ var checkAllToolsHealth = async (tenantId, projectId, credentialStoreRegistry) =
|
|
|
3800
3769
|
};
|
|
3801
3770
|
|
|
3802
3771
|
// src/utils/auth-detection.ts
|
|
3803
|
-
var
|
|
3772
|
+
var logger4 = getLogger("auth-detection");
|
|
3804
3773
|
var getWellKnownUrls = (baseUrl) => [
|
|
3805
3774
|
`${baseUrl}/.well-known/oauth-authorization-server`,
|
|
3806
3775
|
`${baseUrl}/.well-known/openid-configuration`
|
|
@@ -3822,12 +3791,12 @@ var tryWellKnownEndpoints = async (baseUrl) => {
|
|
|
3822
3791
|
if (response.ok) {
|
|
3823
3792
|
const metadata = await response.json();
|
|
3824
3793
|
if (validateOAuthMetadata(metadata)) {
|
|
3825
|
-
|
|
3794
|
+
logger4.debug({ baseUrl, wellKnownUrl }, "OAuth 2.1/PKCE support detected");
|
|
3826
3795
|
return buildOAuthConfig(metadata);
|
|
3827
3796
|
}
|
|
3828
3797
|
}
|
|
3829
3798
|
} catch (error) {
|
|
3830
|
-
|
|
3799
|
+
logger4.debug({ wellKnownUrl, error }, "OAuth endpoint check failed");
|
|
3831
3800
|
}
|
|
3832
3801
|
}
|
|
3833
3802
|
return null;
|
|
@@ -3862,7 +3831,7 @@ var discoverOAuthEndpoints = async (serverUrl) => {
|
|
|
3862
3831
|
};
|
|
3863
3832
|
|
|
3864
3833
|
// src/utils/oauth-service.ts
|
|
3865
|
-
var
|
|
3834
|
+
var logger5 = getLogger("oauth-service");
|
|
3866
3835
|
var pkceStore = /* @__PURE__ */ new Map();
|
|
3867
3836
|
function storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId) {
|
|
3868
3837
|
pkceStore.set(state, { codeVerifier, toolId, tenantId, projectId, clientId });
|
|
@@ -3920,7 +3889,7 @@ var OAuthService = class {
|
|
|
3920
3889
|
resource: tool.config.mcp.server.url
|
|
3921
3890
|
});
|
|
3922
3891
|
storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId);
|
|
3923
|
-
|
|
3892
|
+
logger5.info({ toolId, oAuthConfig, tenantId, projectId }, "OAuth flow initiated successfully");
|
|
3924
3893
|
return {
|
|
3925
3894
|
redirectUrl: authUrl,
|
|
3926
3895
|
state
|
|
@@ -3945,9 +3914,9 @@ var OAuthService = class {
|
|
|
3945
3914
|
codeVerifier,
|
|
3946
3915
|
redirectUri
|
|
3947
3916
|
});
|
|
3948
|
-
|
|
3917
|
+
logger5.info({ tokenType: tokens.token_type }, "Token exchange successful with openid-client");
|
|
3949
3918
|
} catch (error) {
|
|
3950
|
-
|
|
3919
|
+
logger5.warn(
|
|
3951
3920
|
{ error: error instanceof Error ? error.message : error },
|
|
3952
3921
|
"openid-client failed, falling back to manual token exchange"
|
|
3953
3922
|
);
|
|
@@ -3958,7 +3927,7 @@ var OAuthService = class {
|
|
|
3958
3927
|
codeVerifier,
|
|
3959
3928
|
redirectUri
|
|
3960
3929
|
});
|
|
3961
|
-
|
|
3930
|
+
logger5.info({ tokenType: tokens.token_type }, "Manual token exchange successful");
|
|
3962
3931
|
}
|
|
3963
3932
|
return { tokens, oAuthConfig };
|
|
3964
3933
|
}
|
|
@@ -3966,7 +3935,7 @@ var OAuthService = class {
|
|
|
3966
3935
|
* Perform dynamic client registration
|
|
3967
3936
|
*/
|
|
3968
3937
|
async performDynamicClientRegistration(registrationUrl, redirectUri) {
|
|
3969
|
-
|
|
3938
|
+
logger5.info({ registrationUrl }, "Attempting dynamic client registration");
|
|
3970
3939
|
try {
|
|
3971
3940
|
const registrationResponse = await fetch(registrationUrl, {
|
|
3972
3941
|
method: "POST",
|
|
@@ -3989,11 +3958,11 @@ var OAuthService = class {
|
|
|
3989
3958
|
});
|
|
3990
3959
|
if (registrationResponse.ok) {
|
|
3991
3960
|
const registration = await registrationResponse.json();
|
|
3992
|
-
|
|
3961
|
+
logger5.info({ clientId: registration.client_id }, "Dynamic client registration successful");
|
|
3993
3962
|
return registration.client_id;
|
|
3994
3963
|
} else {
|
|
3995
3964
|
const errorText = await registrationResponse.text();
|
|
3996
|
-
|
|
3965
|
+
logger5.warn(
|
|
3997
3966
|
{
|
|
3998
3967
|
status: registrationResponse.status,
|
|
3999
3968
|
errorText
|
|
@@ -4002,7 +3971,7 @@ var OAuthService = class {
|
|
|
4002
3971
|
);
|
|
4003
3972
|
}
|
|
4004
3973
|
} catch (regError) {
|
|
4005
|
-
|
|
3974
|
+
logger5.warn(
|
|
4006
3975
|
{ error: regError },
|
|
4007
3976
|
"Dynamic client registration error, using default client_id"
|
|
4008
3977
|
);
|
|
@@ -4032,7 +4001,7 @@ var OAuthService = class {
|
|
|
4032
4001
|
const oauth = await import('openid-client');
|
|
4033
4002
|
const tokenUrl = new URL(oAuthConfig.tokenUrl);
|
|
4034
4003
|
const oauthServerUrl = `${tokenUrl.protocol}//${tokenUrl.host}`;
|
|
4035
|
-
|
|
4004
|
+
logger5.info({ oauthServerUrl, clientId }, "Attempting openid-client discovery");
|
|
4036
4005
|
const config = await oauth.discovery(
|
|
4037
4006
|
new URL(oauthServerUrl),
|
|
4038
4007
|
clientId,
|
|
@@ -4064,7 +4033,7 @@ var OAuthService = class {
|
|
|
4064
4033
|
*/
|
|
4065
4034
|
async exchangeManually(params) {
|
|
4066
4035
|
const { oAuthConfig, clientId, code, codeVerifier, redirectUri } = params;
|
|
4067
|
-
|
|
4036
|
+
logger5.info({ tokenUrl: oAuthConfig.tokenUrl }, "Attempting manual token exchange");
|
|
4068
4037
|
const tokenResponse = await fetch(oAuthConfig.tokenUrl, {
|
|
4069
4038
|
method: "POST",
|
|
4070
4039
|
headers: {
|
|
@@ -4082,7 +4051,7 @@ var OAuthService = class {
|
|
|
4082
4051
|
});
|
|
4083
4052
|
if (!tokenResponse.ok) {
|
|
4084
4053
|
const errorText = await tokenResponse.text();
|
|
4085
|
-
|
|
4054
|
+
logger5.error(
|
|
4086
4055
|
{
|
|
4087
4056
|
status: tokenResponse.status,
|
|
4088
4057
|
statusText: tokenResponse.statusText,
|
|
@@ -4100,6 +4069,7 @@ var OAuthService = class {
|
|
|
4100
4069
|
var oauthService = new OAuthService();
|
|
4101
4070
|
|
|
4102
4071
|
// src/routes/tools.ts
|
|
4072
|
+
var logger6 = getLogger("tools");
|
|
4103
4073
|
var app15 = new OpenAPIHono();
|
|
4104
4074
|
app15.openapi(
|
|
4105
4075
|
createRoute({
|
|
@@ -4222,7 +4192,7 @@ app15.openapi(
|
|
|
4222
4192
|
async (c) => {
|
|
4223
4193
|
const { tenantId, projectId } = c.req.valid("param");
|
|
4224
4194
|
const body = c.req.valid("json");
|
|
4225
|
-
|
|
4195
|
+
logger6.info({ body }, "body");
|
|
4226
4196
|
const id = body.id || nanoid();
|
|
4227
4197
|
const tool = await createTool(dbClient_default)({
|
|
4228
4198
|
tenantId,
|
|
@@ -4643,7 +4613,6 @@ app15.openapi(
|
|
|
4643
4613
|
}),
|
|
4644
4614
|
async (c) => {
|
|
4645
4615
|
const { tenantId, projectId, id } = c.req.valid("param");
|
|
4646
|
-
const logger9 = getLogger("oauth-login");
|
|
4647
4616
|
try {
|
|
4648
4617
|
const tool = await getToolById(dbClient_default)({ scopes: { tenantId, projectId }, toolId: id });
|
|
4649
4618
|
if (!tool) {
|
|
@@ -4661,7 +4630,7 @@ app15.openapi(
|
|
|
4661
4630
|
});
|
|
4662
4631
|
return c.redirect(redirectUrl, 302);
|
|
4663
4632
|
} catch (error) {
|
|
4664
|
-
|
|
4633
|
+
logger6.error({ toolId: id, error }, "OAuth login failed");
|
|
4665
4634
|
if (error && typeof error === "object" && "code" in error) {
|
|
4666
4635
|
const apiError = error;
|
|
4667
4636
|
return c.json({ error: apiError.message }, apiError.code === "not_found" ? 404 : 400);
|
|
@@ -4762,7 +4731,7 @@ app17.openapi(
|
|
|
4762
4731
|
throw new Error(`Tool ${toolId} not found`);
|
|
4763
4732
|
}
|
|
4764
4733
|
logger7.info({ toolId, tenantId, projectId }, "Processing OAuth callback");
|
|
4765
|
-
logger7.info("Exchanging authorization code for access token");
|
|
4734
|
+
logger7.info({ toolId }, "Exchanging authorization code for access token");
|
|
4766
4735
|
const mcpTool = dbResultToMcpTool(tool);
|
|
4767
4736
|
const { tokens } = await oauthService.exchangeCodeForTokens({
|
|
4768
4737
|
code,
|
|
@@ -4799,7 +4768,7 @@ app17.openapi(
|
|
|
4799
4768
|
data: credentialData
|
|
4800
4769
|
});
|
|
4801
4770
|
} else {
|
|
4802
|
-
logger7.info("Creating new credential");
|
|
4771
|
+
logger7.info({ credentialId }, "Creating new credential");
|
|
4803
4772
|
credential = await createCredentialReference(dbClient_default)({
|
|
4804
4773
|
tenantId,
|
|
4805
4774
|
projectId,
|
|
@@ -5131,6 +5100,8 @@ app18.openapi(
|
|
|
5131
5100
|
var projectFull_default = app18;
|
|
5132
5101
|
|
|
5133
5102
|
// src/app.ts
|
|
5103
|
+
var logger9 = getLogger("agents-manage-api");
|
|
5104
|
+
logger9.info({ logger: logger9.getTransports() }, "Logger initialized");
|
|
5134
5105
|
function createManagementHono(serverConfig, credentialStores) {
|
|
5135
5106
|
const app20 = new OpenAPIHono();
|
|
5136
5107
|
app20.use("*", requestId());
|
|
@@ -5141,7 +5112,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5141
5112
|
});
|
|
5142
5113
|
app20.use(
|
|
5143
5114
|
pinoLogger({
|
|
5144
|
-
pino: getLogger(),
|
|
5115
|
+
pino: getLogger("agents-manage-api").getPinoInstance(),
|
|
5145
5116
|
http: {
|
|
5146
5117
|
onResLevel(c) {
|
|
5147
5118
|
if (c.res.status >= 500) {
|
|
@@ -5185,7 +5156,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5185
5156
|
if (!isExpectedError) {
|
|
5186
5157
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
5187
5158
|
const errorStack = err instanceof Error ? err.stack : void 0;
|
|
5188
|
-
|
|
5159
|
+
logger9.error(
|
|
5189
5160
|
{
|
|
5190
5161
|
error: err,
|
|
5191
5162
|
message: errorMessage,
|
|
@@ -5196,7 +5167,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5196
5167
|
"Unexpected server error occurred"
|
|
5197
5168
|
);
|
|
5198
5169
|
} else {
|
|
5199
|
-
|
|
5170
|
+
logger9.error(
|
|
5200
5171
|
{
|
|
5201
5172
|
error: err,
|
|
5202
5173
|
path: c.req.path,
|
|
@@ -5212,7 +5183,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5212
5183
|
const response = err.getResponse();
|
|
5213
5184
|
return response;
|
|
5214
5185
|
} catch (responseError) {
|
|
5215
|
-
|
|
5186
|
+
logger9.error({ error: responseError }, "Error while handling HTTPException response");
|
|
5216
5187
|
}
|
|
5217
5188
|
}
|
|
5218
5189
|
const { status: respStatus, title, detail, instance } = await handleApiError(err, requestId2);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-manage-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Agents Manage API for Inkeep Agent Framework - handles CRUD operations and OAuth",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"openid-client": "^6.6.4",
|
|
25
25
|
"pino": "^9.7.0",
|
|
26
26
|
"zod": "^4.1.5",
|
|
27
|
-
"@inkeep/agents-core": "^0.
|
|
27
|
+
"@inkeep/agents-core": "^0.6.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@hono/vite-dev-server": "^0.20.1",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"scripts": {
|
|
61
61
|
"dev": "vite",
|
|
62
62
|
"build": "tsup",
|
|
63
|
-
"start": "node dist/
|
|
63
|
+
"start": "node dist/index.js",
|
|
64
64
|
"test": "vitest --run",
|
|
65
65
|
"test:watch": "vitest",
|
|
66
66
|
"test:coverage": "vitest --run --coverage",
|