@inkeep/agents-manage-api 0.6.4 → 0.6.5
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 +41 -105
- package/dist/index.js +42 -106
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2430,7 +2430,7 @@ app10.openapi(
|
|
|
2430
2430
|
}),
|
|
2431
2431
|
async (c) => {
|
|
2432
2432
|
const { tenantId, projectId, id } = c.req.valid("param");
|
|
2433
|
-
const credential = await agentsCore.
|
|
2433
|
+
const credential = await agentsCore.getCredentialReferenceWithTools(dbClient_default)({
|
|
2434
2434
|
scopes: { tenantId, projectId },
|
|
2435
2435
|
id
|
|
2436
2436
|
});
|
|
@@ -3771,71 +3771,7 @@ var checkAllToolsHealth = async (tenantId, projectId, credentialStoreRegistry) =
|
|
|
3771
3771
|
);
|
|
3772
3772
|
return results;
|
|
3773
3773
|
};
|
|
3774
|
-
|
|
3775
|
-
// src/utils/auth-detection.ts
|
|
3776
|
-
var logger4 = agentsCore.getLogger("auth-detection");
|
|
3777
|
-
var getWellKnownUrls = (baseUrl) => [
|
|
3778
|
-
`${baseUrl}/.well-known/oauth-authorization-server`,
|
|
3779
|
-
`${baseUrl}/.well-known/openid-configuration`
|
|
3780
|
-
];
|
|
3781
|
-
var validateOAuthMetadata = (metadata) => {
|
|
3782
|
-
return metadata.code_challenge_methods_supported?.includes("S256");
|
|
3783
|
-
};
|
|
3784
|
-
var buildOAuthConfig = (metadata) => ({
|
|
3785
|
-
authorizationUrl: metadata.authorization_endpoint,
|
|
3786
|
-
tokenUrl: metadata.token_endpoint,
|
|
3787
|
-
registrationUrl: metadata.registration_endpoint,
|
|
3788
|
-
supportsDynamicRegistration: !!metadata.registration_endpoint
|
|
3789
|
-
});
|
|
3790
|
-
var tryWellKnownEndpoints = async (baseUrl) => {
|
|
3791
|
-
const wellKnownUrls = getWellKnownUrls(baseUrl);
|
|
3792
|
-
for (const wellKnownUrl of wellKnownUrls) {
|
|
3793
|
-
try {
|
|
3794
|
-
const response = await fetch(wellKnownUrl);
|
|
3795
|
-
if (response.ok) {
|
|
3796
|
-
const metadata = await response.json();
|
|
3797
|
-
if (validateOAuthMetadata(metadata)) {
|
|
3798
|
-
logger4.debug({ baseUrl, wellKnownUrl }, "OAuth 2.1/PKCE support detected");
|
|
3799
|
-
return buildOAuthConfig(metadata);
|
|
3800
|
-
}
|
|
3801
|
-
}
|
|
3802
|
-
} catch (error) {
|
|
3803
|
-
logger4.debug({ wellKnownUrl, error }, "OAuth endpoint check failed");
|
|
3804
|
-
}
|
|
3805
|
-
}
|
|
3806
|
-
return null;
|
|
3807
|
-
};
|
|
3808
|
-
var discoverOAuthEndpoints = async (serverUrl) => {
|
|
3809
|
-
try {
|
|
3810
|
-
const response = await fetch(serverUrl, {
|
|
3811
|
-
method: "POST",
|
|
3812
|
-
headers: { "Content-Type": "application/json" },
|
|
3813
|
-
body: JSON.stringify({})
|
|
3814
|
-
});
|
|
3815
|
-
if (response.status === 401) {
|
|
3816
|
-
const wwwAuth = response.headers.get("WWW-Authenticate");
|
|
3817
|
-
if (wwwAuth) {
|
|
3818
|
-
const metadataMatch = wwwAuth.match(/as_uri="([^"]+)"/);
|
|
3819
|
-
if (metadataMatch) {
|
|
3820
|
-
const metadataResponse = await fetch(metadataMatch[1]);
|
|
3821
|
-
if (metadataResponse.ok) {
|
|
3822
|
-
const metadata = await metadataResponse.json();
|
|
3823
|
-
if (metadata.authorization_servers?.length > 0) {
|
|
3824
|
-
return await tryWellKnownEndpoints(metadata.authorization_servers[0]);
|
|
3825
|
-
}
|
|
3826
|
-
}
|
|
3827
|
-
}
|
|
3828
|
-
}
|
|
3829
|
-
}
|
|
3830
|
-
} catch (_error) {
|
|
3831
|
-
}
|
|
3832
|
-
const url = new URL(serverUrl);
|
|
3833
|
-
const baseUrl = `${url.protocol}//${url.host}`;
|
|
3834
|
-
return await tryWellKnownEndpoints(baseUrl);
|
|
3835
|
-
};
|
|
3836
|
-
|
|
3837
|
-
// src/utils/oauth-service.ts
|
|
3838
|
-
var logger5 = agentsCore.getLogger("oauth-service");
|
|
3774
|
+
var logger4 = agentsCore.getLogger("oauth-service");
|
|
3839
3775
|
var pkceStore = /* @__PURE__ */ new Map();
|
|
3840
3776
|
function storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId) {
|
|
3841
3777
|
pkceStore.set(state, { codeVerifier, toolId, tenantId, projectId, clientId });
|
|
@@ -3870,7 +3806,7 @@ var OAuthService = class {
|
|
|
3870
3806
|
*/
|
|
3871
3807
|
async initiateOAuthFlow(params) {
|
|
3872
3808
|
const { tool, tenantId, projectId, toolId } = params;
|
|
3873
|
-
const oAuthConfig = await discoverOAuthEndpoints(tool.config.mcp.server.url);
|
|
3809
|
+
const oAuthConfig = await agentsCore.discoverOAuthEndpoints(tool.config.mcp.server.url, logger4);
|
|
3874
3810
|
if (!oAuthConfig) {
|
|
3875
3811
|
throw new Error("OAuth not supported by this server");
|
|
3876
3812
|
}
|
|
@@ -3893,7 +3829,7 @@ var OAuthService = class {
|
|
|
3893
3829
|
resource: tool.config.mcp.server.url
|
|
3894
3830
|
});
|
|
3895
3831
|
storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId);
|
|
3896
|
-
|
|
3832
|
+
logger4.info({ toolId, oAuthConfig, tenantId, projectId }, "OAuth flow initiated successfully");
|
|
3897
3833
|
return {
|
|
3898
3834
|
redirectUrl: authUrl,
|
|
3899
3835
|
state
|
|
@@ -3904,7 +3840,7 @@ var OAuthService = class {
|
|
|
3904
3840
|
*/
|
|
3905
3841
|
async exchangeCodeForTokens(params) {
|
|
3906
3842
|
const { code, codeVerifier, clientId, tool } = params;
|
|
3907
|
-
const oAuthConfig = await discoverOAuthEndpoints(tool.config.mcp.server.url);
|
|
3843
|
+
const oAuthConfig = await agentsCore.discoverOAuthEndpoints(tool.config.mcp.server.url, logger4);
|
|
3908
3844
|
if (!oAuthConfig?.tokenUrl) {
|
|
3909
3845
|
throw new Error("Could not discover OAuth token endpoint");
|
|
3910
3846
|
}
|
|
@@ -3918,9 +3854,9 @@ var OAuthService = class {
|
|
|
3918
3854
|
codeVerifier,
|
|
3919
3855
|
redirectUri
|
|
3920
3856
|
});
|
|
3921
|
-
|
|
3857
|
+
logger4.info({ tokenType: tokens.token_type }, "Token exchange successful with openid-client");
|
|
3922
3858
|
} catch (error) {
|
|
3923
|
-
|
|
3859
|
+
logger4.warn(
|
|
3924
3860
|
{ error: error instanceof Error ? error.message : error },
|
|
3925
3861
|
"openid-client failed, falling back to manual token exchange"
|
|
3926
3862
|
);
|
|
@@ -3931,7 +3867,7 @@ var OAuthService = class {
|
|
|
3931
3867
|
codeVerifier,
|
|
3932
3868
|
redirectUri
|
|
3933
3869
|
});
|
|
3934
|
-
|
|
3870
|
+
logger4.info({ tokenType: tokens.token_type }, "Manual token exchange successful");
|
|
3935
3871
|
}
|
|
3936
3872
|
return { tokens, oAuthConfig };
|
|
3937
3873
|
}
|
|
@@ -3939,7 +3875,7 @@ var OAuthService = class {
|
|
|
3939
3875
|
* Perform dynamic client registration
|
|
3940
3876
|
*/
|
|
3941
3877
|
async performDynamicClientRegistration(registrationUrl, redirectUri) {
|
|
3942
|
-
|
|
3878
|
+
logger4.info({ registrationUrl }, "Attempting dynamic client registration");
|
|
3943
3879
|
try {
|
|
3944
3880
|
const registrationResponse = await fetch(registrationUrl, {
|
|
3945
3881
|
method: "POST",
|
|
@@ -3962,11 +3898,11 @@ var OAuthService = class {
|
|
|
3962
3898
|
});
|
|
3963
3899
|
if (registrationResponse.ok) {
|
|
3964
3900
|
const registration = await registrationResponse.json();
|
|
3965
|
-
|
|
3901
|
+
logger4.info({ clientId: registration.client_id }, "Dynamic client registration successful");
|
|
3966
3902
|
return registration.client_id;
|
|
3967
3903
|
} else {
|
|
3968
3904
|
const errorText = await registrationResponse.text();
|
|
3969
|
-
|
|
3905
|
+
logger4.warn(
|
|
3970
3906
|
{
|
|
3971
3907
|
status: registrationResponse.status,
|
|
3972
3908
|
errorText
|
|
@@ -3975,7 +3911,7 @@ var OAuthService = class {
|
|
|
3975
3911
|
);
|
|
3976
3912
|
}
|
|
3977
3913
|
} catch (regError) {
|
|
3978
|
-
|
|
3914
|
+
logger4.warn(
|
|
3979
3915
|
{ error: regError },
|
|
3980
3916
|
"Dynamic client registration error, using default client_id"
|
|
3981
3917
|
);
|
|
@@ -4005,7 +3941,7 @@ var OAuthService = class {
|
|
|
4005
3941
|
const oauth = await import('openid-client');
|
|
4006
3942
|
const tokenUrl = new URL(oAuthConfig.tokenUrl);
|
|
4007
3943
|
const oauthServerUrl = `${tokenUrl.protocol}//${tokenUrl.host}`;
|
|
4008
|
-
|
|
3944
|
+
logger4.info({ oauthServerUrl, clientId }, "Attempting openid-client discovery");
|
|
4009
3945
|
const config = await oauth.discovery(
|
|
4010
3946
|
new URL(oauthServerUrl),
|
|
4011
3947
|
clientId,
|
|
@@ -4037,7 +3973,7 @@ var OAuthService = class {
|
|
|
4037
3973
|
*/
|
|
4038
3974
|
async exchangeManually(params) {
|
|
4039
3975
|
const { oAuthConfig, clientId, code, codeVerifier, redirectUri } = params;
|
|
4040
|
-
|
|
3976
|
+
logger4.info({ tokenUrl: oAuthConfig.tokenUrl }, "Attempting manual token exchange");
|
|
4041
3977
|
const tokenResponse = await fetch(oAuthConfig.tokenUrl, {
|
|
4042
3978
|
method: "POST",
|
|
4043
3979
|
headers: {
|
|
@@ -4055,7 +3991,7 @@ var OAuthService = class {
|
|
|
4055
3991
|
});
|
|
4056
3992
|
if (!tokenResponse.ok) {
|
|
4057
3993
|
const errorText = await tokenResponse.text();
|
|
4058
|
-
|
|
3994
|
+
logger4.error(
|
|
4059
3995
|
{
|
|
4060
3996
|
status: tokenResponse.status,
|
|
4061
3997
|
statusText: tokenResponse.statusText,
|
|
@@ -4073,7 +4009,7 @@ var OAuthService = class {
|
|
|
4073
4009
|
var oauthService = new OAuthService();
|
|
4074
4010
|
|
|
4075
4011
|
// src/routes/tools.ts
|
|
4076
|
-
var
|
|
4012
|
+
var logger5 = agentsCore.getLogger("tools");
|
|
4077
4013
|
var app15 = new zodOpenapi.OpenAPIHono();
|
|
4078
4014
|
app15.openapi(
|
|
4079
4015
|
zodOpenapi.createRoute({
|
|
@@ -4196,7 +4132,7 @@ app15.openapi(
|
|
|
4196
4132
|
async (c) => {
|
|
4197
4133
|
const { tenantId, projectId } = c.req.valid("param");
|
|
4198
4134
|
const body = c.req.valid("json");
|
|
4199
|
-
|
|
4135
|
+
logger5.info({ body }, "body");
|
|
4200
4136
|
const id = body.id || nanoid.nanoid();
|
|
4201
4137
|
const tool = await agentsCore.createTool(dbClient_default)({
|
|
4202
4138
|
tenantId,
|
|
@@ -4634,7 +4570,7 @@ app15.openapi(
|
|
|
4634
4570
|
});
|
|
4635
4571
|
return c.redirect(redirectUrl, 302);
|
|
4636
4572
|
} catch (error) {
|
|
4637
|
-
|
|
4573
|
+
logger5.error({ toolId: id, error }, "OAuth login failed");
|
|
4638
4574
|
if (error && typeof error === "object" && "code" in error) {
|
|
4639
4575
|
const apiError = error;
|
|
4640
4576
|
return c.json({ error: apiError.message }, apiError.code === "not_found" ? 404 : 400);
|
|
@@ -4669,7 +4605,7 @@ app16.route("/projects/:projectId/api-keys", apiKeys_default);
|
|
|
4669
4605
|
app16.route("/projects/:projectId/graph", graphFull_default);
|
|
4670
4606
|
var routes_default = app16;
|
|
4671
4607
|
var app17 = new zodOpenapi.OpenAPIHono();
|
|
4672
|
-
var
|
|
4608
|
+
var logger6 = agentsCore.getLogger("oauth-callback");
|
|
4673
4609
|
var OAuthCallbackQuerySchema = zodOpenapi.z.object({
|
|
4674
4610
|
code: zodOpenapi.z.string().min(1, "Authorization code is required"),
|
|
4675
4611
|
state: zodOpenapi.z.string().min(1, "State parameter is required"),
|
|
@@ -4712,15 +4648,15 @@ app17.openapi(
|
|
|
4712
4648
|
async (c) => {
|
|
4713
4649
|
try {
|
|
4714
4650
|
const { code, state, error, error_description } = c.req.valid("query");
|
|
4715
|
-
|
|
4651
|
+
logger6.info({ state, hasCode: !!code }, "OAuth callback received");
|
|
4716
4652
|
if (error) {
|
|
4717
|
-
|
|
4653
|
+
logger6.error({ error, error_description }, "OAuth authorization failed");
|
|
4718
4654
|
const errorMessage = "OAuth Authorization Failed. Please try again.";
|
|
4719
4655
|
return c.text(errorMessage, 400);
|
|
4720
4656
|
}
|
|
4721
4657
|
const pkceData = retrievePKCEVerifier(state);
|
|
4722
4658
|
if (!pkceData) {
|
|
4723
|
-
|
|
4659
|
+
logger6.error({ state }, "Invalid or expired OAuth state");
|
|
4724
4660
|
return c.text(
|
|
4725
4661
|
"OAuth Session Expired: The OAuth session has expired or is invalid. Please try again.",
|
|
4726
4662
|
400
|
|
@@ -4734,8 +4670,8 @@ app17.openapi(
|
|
|
4734
4670
|
if (!tool) {
|
|
4735
4671
|
throw new Error(`Tool ${toolId} not found`);
|
|
4736
4672
|
}
|
|
4737
|
-
|
|
4738
|
-
|
|
4673
|
+
logger6.info({ toolId, tenantId, projectId }, "Processing OAuth callback");
|
|
4674
|
+
logger6.info({ toolId }, "Exchanging authorization code for access token");
|
|
4739
4675
|
const mcpTool = agentsCore.dbResultToMcpTool(tool);
|
|
4740
4676
|
const { tokens } = await oauthService.exchangeCodeForTokens({
|
|
4741
4677
|
code,
|
|
@@ -4743,7 +4679,7 @@ app17.openapi(
|
|
|
4743
4679
|
clientId,
|
|
4744
4680
|
tool: mcpTool
|
|
4745
4681
|
});
|
|
4746
|
-
|
|
4682
|
+
logger6.info(
|
|
4747
4683
|
{ toolId, tokenType: tokens.token_type, hasRefresh: !!tokens.refresh_token },
|
|
4748
4684
|
"Token exchange successful"
|
|
4749
4685
|
);
|
|
@@ -4765,14 +4701,14 @@ app17.openapi(
|
|
|
4765
4701
|
};
|
|
4766
4702
|
let credential;
|
|
4767
4703
|
if (existingCredential) {
|
|
4768
|
-
|
|
4704
|
+
logger6.info({ credentialId: existingCredential.id }, "Updating existing credential");
|
|
4769
4705
|
credential = await agentsCore.updateCredentialReference(dbClient_default)({
|
|
4770
4706
|
scopes: { tenantId, projectId },
|
|
4771
4707
|
id: existingCredential.id,
|
|
4772
4708
|
data: credentialData
|
|
4773
4709
|
});
|
|
4774
4710
|
} else {
|
|
4775
|
-
|
|
4711
|
+
logger6.info({ credentialId }, "Creating new credential");
|
|
4776
4712
|
credential = await agentsCore.createCredentialReference(dbClient_default)({
|
|
4777
4713
|
tenantId,
|
|
4778
4714
|
projectId,
|
|
@@ -4790,7 +4726,7 @@ app17.openapi(
|
|
|
4790
4726
|
credentialReferenceId: credential.id
|
|
4791
4727
|
}
|
|
4792
4728
|
});
|
|
4793
|
-
|
|
4729
|
+
logger6.info({ toolId, credentialId: credential.id }, "OAuth flow completed successfully");
|
|
4794
4730
|
const successPage = `
|
|
4795
4731
|
<!DOCTYPE html>
|
|
4796
4732
|
<html>
|
|
@@ -4832,14 +4768,14 @@ app17.openapi(
|
|
|
4832
4768
|
`;
|
|
4833
4769
|
return c.html(successPage);
|
|
4834
4770
|
} catch (error) {
|
|
4835
|
-
|
|
4771
|
+
logger6.error({ error }, "OAuth callback processing failed");
|
|
4836
4772
|
const errorMessage = "OAuth Processing Failed. Please try again.";
|
|
4837
4773
|
return c.text(errorMessage, 500);
|
|
4838
4774
|
}
|
|
4839
4775
|
}
|
|
4840
4776
|
);
|
|
4841
4777
|
var oauth_default = app17;
|
|
4842
|
-
var
|
|
4778
|
+
var logger7 = agentsCore.getLogger("projectFull");
|
|
4843
4779
|
var app18 = new zodOpenapi.OpenAPIHono();
|
|
4844
4780
|
var ProjectIdParamsSchema = zod.z.object({
|
|
4845
4781
|
tenantId: zod.z.string().openapi({
|
|
@@ -4900,7 +4836,7 @@ app18.openapi(
|
|
|
4900
4836
|
const projectData = c.req.valid("json");
|
|
4901
4837
|
const validatedProjectData = agentsCore.FullProjectDefinitionSchema.parse(projectData);
|
|
4902
4838
|
try {
|
|
4903
|
-
const createdProject = await agentsCore.createFullProjectServerSide(dbClient_default,
|
|
4839
|
+
const createdProject = await agentsCore.createFullProjectServerSide(dbClient_default, logger7)(
|
|
4904
4840
|
{ tenantId, projectId: validatedProjectData.id },
|
|
4905
4841
|
validatedProjectData
|
|
4906
4842
|
);
|
|
@@ -4944,7 +4880,7 @@ app18.openapi(
|
|
|
4944
4880
|
try {
|
|
4945
4881
|
const project = await agentsCore.getFullProject(
|
|
4946
4882
|
dbClient_default,
|
|
4947
|
-
|
|
4883
|
+
logger7
|
|
4948
4884
|
)({
|
|
4949
4885
|
scopes: { tenantId, projectId }
|
|
4950
4886
|
});
|
|
@@ -5020,15 +4956,15 @@ app18.openapi(
|
|
|
5020
4956
|
}
|
|
5021
4957
|
const existingProject = await agentsCore.getFullProject(
|
|
5022
4958
|
dbClient_default,
|
|
5023
|
-
|
|
4959
|
+
logger7
|
|
5024
4960
|
)({
|
|
5025
4961
|
scopes: { tenantId, projectId }
|
|
5026
4962
|
});
|
|
5027
4963
|
const isCreate = !existingProject;
|
|
5028
|
-
const updatedProject = isCreate ? await agentsCore.createFullProjectServerSide(dbClient_default,
|
|
4964
|
+
const updatedProject = isCreate ? await agentsCore.createFullProjectServerSide(dbClient_default, logger7)(
|
|
5029
4965
|
{ tenantId, projectId },
|
|
5030
4966
|
validatedProjectData
|
|
5031
|
-
) : await agentsCore.updateFullProjectServerSide(dbClient_default,
|
|
4967
|
+
) : await agentsCore.updateFullProjectServerSide(dbClient_default, logger7)(
|
|
5032
4968
|
{ tenantId, projectId },
|
|
5033
4969
|
validatedProjectData
|
|
5034
4970
|
);
|
|
@@ -5076,7 +5012,7 @@ app18.openapi(
|
|
|
5076
5012
|
try {
|
|
5077
5013
|
const deleted = await agentsCore.deleteFullProject(
|
|
5078
5014
|
dbClient_default,
|
|
5079
|
-
|
|
5015
|
+
logger7
|
|
5080
5016
|
)({
|
|
5081
5017
|
scopes: { tenantId, projectId }
|
|
5082
5018
|
});
|
|
@@ -5104,8 +5040,8 @@ app18.openapi(
|
|
|
5104
5040
|
var projectFull_default = app18;
|
|
5105
5041
|
|
|
5106
5042
|
// src/app.ts
|
|
5107
|
-
var
|
|
5108
|
-
|
|
5043
|
+
var logger8 = agentsCore.getLogger("agents-manage-api");
|
|
5044
|
+
logger8.info({ logger: logger8.getTransports() }, "Logger initialized");
|
|
5109
5045
|
function createManagementHono(serverConfig, credentialStores) {
|
|
5110
5046
|
const app20 = new zodOpenapi.OpenAPIHono();
|
|
5111
5047
|
app20.use("*", requestId.requestId());
|
|
@@ -5160,7 +5096,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5160
5096
|
if (!isExpectedError) {
|
|
5161
5097
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
5162
5098
|
const errorStack = err instanceof Error ? err.stack : void 0;
|
|
5163
|
-
|
|
5099
|
+
logger8.error(
|
|
5164
5100
|
{
|
|
5165
5101
|
error: err,
|
|
5166
5102
|
message: errorMessage,
|
|
@@ -5171,7 +5107,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5171
5107
|
"Unexpected server error occurred"
|
|
5172
5108
|
);
|
|
5173
5109
|
} else {
|
|
5174
|
-
|
|
5110
|
+
logger8.error(
|
|
5175
5111
|
{
|
|
5176
5112
|
error: err,
|
|
5177
5113
|
path: c.req.path,
|
|
@@ -5187,7 +5123,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5187
5123
|
const response = err.getResponse();
|
|
5188
5124
|
return response;
|
|
5189
5125
|
} catch (responseError) {
|
|
5190
|
-
|
|
5126
|
+
logger8.error({ error: responseError }, "Error while handling HTTPException response");
|
|
5191
5127
|
}
|
|
5192
5128
|
}
|
|
5193
5129
|
const { status: respStatus, title, detail, instance } = await agentsCore.handleApiError(err, requestId2);
|
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, 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,
|
|
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, 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, listToolsByStatus, dbResultToMcpTool, listTools, getToolById, ToolApiInsertSchema, createTool, ToolApiUpdateSchema, updateTool, deleteTool, getCredentialReference, CredentialStoreType, FullProjectDefinitionSchema, createFullProjectServerSide, getFullProject, updateFullProjectServerSide, deleteFullProject, createDefaultCredentialStores, CredentialStoreRegistry, discoverOAuthEndpoints, 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';
|
|
@@ -2426,7 +2426,7 @@ app10.openapi(
|
|
|
2426
2426
|
}),
|
|
2427
2427
|
async (c) => {
|
|
2428
2428
|
const { tenantId, projectId, id } = c.req.valid("param");
|
|
2429
|
-
const credential = await
|
|
2429
|
+
const credential = await getCredentialReferenceWithTools(dbClient_default)({
|
|
2430
2430
|
scopes: { tenantId, projectId },
|
|
2431
2431
|
id
|
|
2432
2432
|
});
|
|
@@ -3767,71 +3767,7 @@ var checkAllToolsHealth = async (tenantId, projectId, credentialStoreRegistry) =
|
|
|
3767
3767
|
);
|
|
3768
3768
|
return results;
|
|
3769
3769
|
};
|
|
3770
|
-
|
|
3771
|
-
// src/utils/auth-detection.ts
|
|
3772
|
-
var logger4 = getLogger("auth-detection");
|
|
3773
|
-
var getWellKnownUrls = (baseUrl) => [
|
|
3774
|
-
`${baseUrl}/.well-known/oauth-authorization-server`,
|
|
3775
|
-
`${baseUrl}/.well-known/openid-configuration`
|
|
3776
|
-
];
|
|
3777
|
-
var validateOAuthMetadata = (metadata) => {
|
|
3778
|
-
return metadata.code_challenge_methods_supported?.includes("S256");
|
|
3779
|
-
};
|
|
3780
|
-
var buildOAuthConfig = (metadata) => ({
|
|
3781
|
-
authorizationUrl: metadata.authorization_endpoint,
|
|
3782
|
-
tokenUrl: metadata.token_endpoint,
|
|
3783
|
-
registrationUrl: metadata.registration_endpoint,
|
|
3784
|
-
supportsDynamicRegistration: !!metadata.registration_endpoint
|
|
3785
|
-
});
|
|
3786
|
-
var tryWellKnownEndpoints = async (baseUrl) => {
|
|
3787
|
-
const wellKnownUrls = getWellKnownUrls(baseUrl);
|
|
3788
|
-
for (const wellKnownUrl of wellKnownUrls) {
|
|
3789
|
-
try {
|
|
3790
|
-
const response = await fetch(wellKnownUrl);
|
|
3791
|
-
if (response.ok) {
|
|
3792
|
-
const metadata = await response.json();
|
|
3793
|
-
if (validateOAuthMetadata(metadata)) {
|
|
3794
|
-
logger4.debug({ baseUrl, wellKnownUrl }, "OAuth 2.1/PKCE support detected");
|
|
3795
|
-
return buildOAuthConfig(metadata);
|
|
3796
|
-
}
|
|
3797
|
-
}
|
|
3798
|
-
} catch (error) {
|
|
3799
|
-
logger4.debug({ wellKnownUrl, error }, "OAuth endpoint check failed");
|
|
3800
|
-
}
|
|
3801
|
-
}
|
|
3802
|
-
return null;
|
|
3803
|
-
};
|
|
3804
|
-
var discoverOAuthEndpoints = async (serverUrl) => {
|
|
3805
|
-
try {
|
|
3806
|
-
const response = await fetch(serverUrl, {
|
|
3807
|
-
method: "POST",
|
|
3808
|
-
headers: { "Content-Type": "application/json" },
|
|
3809
|
-
body: JSON.stringify({})
|
|
3810
|
-
});
|
|
3811
|
-
if (response.status === 401) {
|
|
3812
|
-
const wwwAuth = response.headers.get("WWW-Authenticate");
|
|
3813
|
-
if (wwwAuth) {
|
|
3814
|
-
const metadataMatch = wwwAuth.match(/as_uri="([^"]+)"/);
|
|
3815
|
-
if (metadataMatch) {
|
|
3816
|
-
const metadataResponse = await fetch(metadataMatch[1]);
|
|
3817
|
-
if (metadataResponse.ok) {
|
|
3818
|
-
const metadata = await metadataResponse.json();
|
|
3819
|
-
if (metadata.authorization_servers?.length > 0) {
|
|
3820
|
-
return await tryWellKnownEndpoints(metadata.authorization_servers[0]);
|
|
3821
|
-
}
|
|
3822
|
-
}
|
|
3823
|
-
}
|
|
3824
|
-
}
|
|
3825
|
-
}
|
|
3826
|
-
} catch (_error) {
|
|
3827
|
-
}
|
|
3828
|
-
const url = new URL(serverUrl);
|
|
3829
|
-
const baseUrl = `${url.protocol}//${url.host}`;
|
|
3830
|
-
return await tryWellKnownEndpoints(baseUrl);
|
|
3831
|
-
};
|
|
3832
|
-
|
|
3833
|
-
// src/utils/oauth-service.ts
|
|
3834
|
-
var logger5 = getLogger("oauth-service");
|
|
3770
|
+
var logger4 = getLogger("oauth-service");
|
|
3835
3771
|
var pkceStore = /* @__PURE__ */ new Map();
|
|
3836
3772
|
function storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId) {
|
|
3837
3773
|
pkceStore.set(state, { codeVerifier, toolId, tenantId, projectId, clientId });
|
|
@@ -3866,7 +3802,7 @@ var OAuthService = class {
|
|
|
3866
3802
|
*/
|
|
3867
3803
|
async initiateOAuthFlow(params) {
|
|
3868
3804
|
const { tool, tenantId, projectId, toolId } = params;
|
|
3869
|
-
const oAuthConfig = await discoverOAuthEndpoints(tool.config.mcp.server.url);
|
|
3805
|
+
const oAuthConfig = await discoverOAuthEndpoints(tool.config.mcp.server.url, logger4);
|
|
3870
3806
|
if (!oAuthConfig) {
|
|
3871
3807
|
throw new Error("OAuth not supported by this server");
|
|
3872
3808
|
}
|
|
@@ -3889,7 +3825,7 @@ var OAuthService = class {
|
|
|
3889
3825
|
resource: tool.config.mcp.server.url
|
|
3890
3826
|
});
|
|
3891
3827
|
storePKCEVerifier(state, codeVerifier, toolId, tenantId, projectId, clientId);
|
|
3892
|
-
|
|
3828
|
+
logger4.info({ toolId, oAuthConfig, tenantId, projectId }, "OAuth flow initiated successfully");
|
|
3893
3829
|
return {
|
|
3894
3830
|
redirectUrl: authUrl,
|
|
3895
3831
|
state
|
|
@@ -3900,7 +3836,7 @@ var OAuthService = class {
|
|
|
3900
3836
|
*/
|
|
3901
3837
|
async exchangeCodeForTokens(params) {
|
|
3902
3838
|
const { code, codeVerifier, clientId, tool } = params;
|
|
3903
|
-
const oAuthConfig = await discoverOAuthEndpoints(tool.config.mcp.server.url);
|
|
3839
|
+
const oAuthConfig = await discoverOAuthEndpoints(tool.config.mcp.server.url, logger4);
|
|
3904
3840
|
if (!oAuthConfig?.tokenUrl) {
|
|
3905
3841
|
throw new Error("Could not discover OAuth token endpoint");
|
|
3906
3842
|
}
|
|
@@ -3914,9 +3850,9 @@ var OAuthService = class {
|
|
|
3914
3850
|
codeVerifier,
|
|
3915
3851
|
redirectUri
|
|
3916
3852
|
});
|
|
3917
|
-
|
|
3853
|
+
logger4.info({ tokenType: tokens.token_type }, "Token exchange successful with openid-client");
|
|
3918
3854
|
} catch (error) {
|
|
3919
|
-
|
|
3855
|
+
logger4.warn(
|
|
3920
3856
|
{ error: error instanceof Error ? error.message : error },
|
|
3921
3857
|
"openid-client failed, falling back to manual token exchange"
|
|
3922
3858
|
);
|
|
@@ -3927,7 +3863,7 @@ var OAuthService = class {
|
|
|
3927
3863
|
codeVerifier,
|
|
3928
3864
|
redirectUri
|
|
3929
3865
|
});
|
|
3930
|
-
|
|
3866
|
+
logger4.info({ tokenType: tokens.token_type }, "Manual token exchange successful");
|
|
3931
3867
|
}
|
|
3932
3868
|
return { tokens, oAuthConfig };
|
|
3933
3869
|
}
|
|
@@ -3935,7 +3871,7 @@ var OAuthService = class {
|
|
|
3935
3871
|
* Perform dynamic client registration
|
|
3936
3872
|
*/
|
|
3937
3873
|
async performDynamicClientRegistration(registrationUrl, redirectUri) {
|
|
3938
|
-
|
|
3874
|
+
logger4.info({ registrationUrl }, "Attempting dynamic client registration");
|
|
3939
3875
|
try {
|
|
3940
3876
|
const registrationResponse = await fetch(registrationUrl, {
|
|
3941
3877
|
method: "POST",
|
|
@@ -3958,11 +3894,11 @@ var OAuthService = class {
|
|
|
3958
3894
|
});
|
|
3959
3895
|
if (registrationResponse.ok) {
|
|
3960
3896
|
const registration = await registrationResponse.json();
|
|
3961
|
-
|
|
3897
|
+
logger4.info({ clientId: registration.client_id }, "Dynamic client registration successful");
|
|
3962
3898
|
return registration.client_id;
|
|
3963
3899
|
} else {
|
|
3964
3900
|
const errorText = await registrationResponse.text();
|
|
3965
|
-
|
|
3901
|
+
logger4.warn(
|
|
3966
3902
|
{
|
|
3967
3903
|
status: registrationResponse.status,
|
|
3968
3904
|
errorText
|
|
@@ -3971,7 +3907,7 @@ var OAuthService = class {
|
|
|
3971
3907
|
);
|
|
3972
3908
|
}
|
|
3973
3909
|
} catch (regError) {
|
|
3974
|
-
|
|
3910
|
+
logger4.warn(
|
|
3975
3911
|
{ error: regError },
|
|
3976
3912
|
"Dynamic client registration error, using default client_id"
|
|
3977
3913
|
);
|
|
@@ -4001,7 +3937,7 @@ var OAuthService = class {
|
|
|
4001
3937
|
const oauth = await import('openid-client');
|
|
4002
3938
|
const tokenUrl = new URL(oAuthConfig.tokenUrl);
|
|
4003
3939
|
const oauthServerUrl = `${tokenUrl.protocol}//${tokenUrl.host}`;
|
|
4004
|
-
|
|
3940
|
+
logger4.info({ oauthServerUrl, clientId }, "Attempting openid-client discovery");
|
|
4005
3941
|
const config = await oauth.discovery(
|
|
4006
3942
|
new URL(oauthServerUrl),
|
|
4007
3943
|
clientId,
|
|
@@ -4033,7 +3969,7 @@ var OAuthService = class {
|
|
|
4033
3969
|
*/
|
|
4034
3970
|
async exchangeManually(params) {
|
|
4035
3971
|
const { oAuthConfig, clientId, code, codeVerifier, redirectUri } = params;
|
|
4036
|
-
|
|
3972
|
+
logger4.info({ tokenUrl: oAuthConfig.tokenUrl }, "Attempting manual token exchange");
|
|
4037
3973
|
const tokenResponse = await fetch(oAuthConfig.tokenUrl, {
|
|
4038
3974
|
method: "POST",
|
|
4039
3975
|
headers: {
|
|
@@ -4051,7 +3987,7 @@ var OAuthService = class {
|
|
|
4051
3987
|
});
|
|
4052
3988
|
if (!tokenResponse.ok) {
|
|
4053
3989
|
const errorText = await tokenResponse.text();
|
|
4054
|
-
|
|
3990
|
+
logger4.error(
|
|
4055
3991
|
{
|
|
4056
3992
|
status: tokenResponse.status,
|
|
4057
3993
|
statusText: tokenResponse.statusText,
|
|
@@ -4069,7 +4005,7 @@ var OAuthService = class {
|
|
|
4069
4005
|
var oauthService = new OAuthService();
|
|
4070
4006
|
|
|
4071
4007
|
// src/routes/tools.ts
|
|
4072
|
-
var
|
|
4008
|
+
var logger5 = getLogger("tools");
|
|
4073
4009
|
var app15 = new OpenAPIHono();
|
|
4074
4010
|
app15.openapi(
|
|
4075
4011
|
createRoute({
|
|
@@ -4192,7 +4128,7 @@ app15.openapi(
|
|
|
4192
4128
|
async (c) => {
|
|
4193
4129
|
const { tenantId, projectId } = c.req.valid("param");
|
|
4194
4130
|
const body = c.req.valid("json");
|
|
4195
|
-
|
|
4131
|
+
logger5.info({ body }, "body");
|
|
4196
4132
|
const id = body.id || nanoid();
|
|
4197
4133
|
const tool = await createTool(dbClient_default)({
|
|
4198
4134
|
tenantId,
|
|
@@ -4630,7 +4566,7 @@ app15.openapi(
|
|
|
4630
4566
|
});
|
|
4631
4567
|
return c.redirect(redirectUrl, 302);
|
|
4632
4568
|
} catch (error) {
|
|
4633
|
-
|
|
4569
|
+
logger5.error({ toolId: id, error }, "OAuth login failed");
|
|
4634
4570
|
if (error && typeof error === "object" && "code" in error) {
|
|
4635
4571
|
const apiError = error;
|
|
4636
4572
|
return c.json({ error: apiError.message }, apiError.code === "not_found" ? 404 : 400);
|
|
@@ -4665,7 +4601,7 @@ app16.route("/projects/:projectId/api-keys", apiKeys_default);
|
|
|
4665
4601
|
app16.route("/projects/:projectId/graph", graphFull_default);
|
|
4666
4602
|
var routes_default = app16;
|
|
4667
4603
|
var app17 = new OpenAPIHono();
|
|
4668
|
-
var
|
|
4604
|
+
var logger6 = getLogger("oauth-callback");
|
|
4669
4605
|
var OAuthCallbackQuerySchema = z$1.object({
|
|
4670
4606
|
code: z$1.string().min(1, "Authorization code is required"),
|
|
4671
4607
|
state: z$1.string().min(1, "State parameter is required"),
|
|
@@ -4708,15 +4644,15 @@ app17.openapi(
|
|
|
4708
4644
|
async (c) => {
|
|
4709
4645
|
try {
|
|
4710
4646
|
const { code, state, error, error_description } = c.req.valid("query");
|
|
4711
|
-
|
|
4647
|
+
logger6.info({ state, hasCode: !!code }, "OAuth callback received");
|
|
4712
4648
|
if (error) {
|
|
4713
|
-
|
|
4649
|
+
logger6.error({ error, error_description }, "OAuth authorization failed");
|
|
4714
4650
|
const errorMessage = "OAuth Authorization Failed. Please try again.";
|
|
4715
4651
|
return c.text(errorMessage, 400);
|
|
4716
4652
|
}
|
|
4717
4653
|
const pkceData = retrievePKCEVerifier(state);
|
|
4718
4654
|
if (!pkceData) {
|
|
4719
|
-
|
|
4655
|
+
logger6.error({ state }, "Invalid or expired OAuth state");
|
|
4720
4656
|
return c.text(
|
|
4721
4657
|
"OAuth Session Expired: The OAuth session has expired or is invalid. Please try again.",
|
|
4722
4658
|
400
|
|
@@ -4730,8 +4666,8 @@ app17.openapi(
|
|
|
4730
4666
|
if (!tool) {
|
|
4731
4667
|
throw new Error(`Tool ${toolId} not found`);
|
|
4732
4668
|
}
|
|
4733
|
-
|
|
4734
|
-
|
|
4669
|
+
logger6.info({ toolId, tenantId, projectId }, "Processing OAuth callback");
|
|
4670
|
+
logger6.info({ toolId }, "Exchanging authorization code for access token");
|
|
4735
4671
|
const mcpTool = dbResultToMcpTool(tool);
|
|
4736
4672
|
const { tokens } = await oauthService.exchangeCodeForTokens({
|
|
4737
4673
|
code,
|
|
@@ -4739,7 +4675,7 @@ app17.openapi(
|
|
|
4739
4675
|
clientId,
|
|
4740
4676
|
tool: mcpTool
|
|
4741
4677
|
});
|
|
4742
|
-
|
|
4678
|
+
logger6.info(
|
|
4743
4679
|
{ toolId, tokenType: tokens.token_type, hasRefresh: !!tokens.refresh_token },
|
|
4744
4680
|
"Token exchange successful"
|
|
4745
4681
|
);
|
|
@@ -4761,14 +4697,14 @@ app17.openapi(
|
|
|
4761
4697
|
};
|
|
4762
4698
|
let credential;
|
|
4763
4699
|
if (existingCredential) {
|
|
4764
|
-
|
|
4700
|
+
logger6.info({ credentialId: existingCredential.id }, "Updating existing credential");
|
|
4765
4701
|
credential = await updateCredentialReference(dbClient_default)({
|
|
4766
4702
|
scopes: { tenantId, projectId },
|
|
4767
4703
|
id: existingCredential.id,
|
|
4768
4704
|
data: credentialData
|
|
4769
4705
|
});
|
|
4770
4706
|
} else {
|
|
4771
|
-
|
|
4707
|
+
logger6.info({ credentialId }, "Creating new credential");
|
|
4772
4708
|
credential = await createCredentialReference(dbClient_default)({
|
|
4773
4709
|
tenantId,
|
|
4774
4710
|
projectId,
|
|
@@ -4786,7 +4722,7 @@ app17.openapi(
|
|
|
4786
4722
|
credentialReferenceId: credential.id
|
|
4787
4723
|
}
|
|
4788
4724
|
});
|
|
4789
|
-
|
|
4725
|
+
logger6.info({ toolId, credentialId: credential.id }, "OAuth flow completed successfully");
|
|
4790
4726
|
const successPage = `
|
|
4791
4727
|
<!DOCTYPE html>
|
|
4792
4728
|
<html>
|
|
@@ -4828,14 +4764,14 @@ app17.openapi(
|
|
|
4828
4764
|
`;
|
|
4829
4765
|
return c.html(successPage);
|
|
4830
4766
|
} catch (error) {
|
|
4831
|
-
|
|
4767
|
+
logger6.error({ error }, "OAuth callback processing failed");
|
|
4832
4768
|
const errorMessage = "OAuth Processing Failed. Please try again.";
|
|
4833
4769
|
return c.text(errorMessage, 500);
|
|
4834
4770
|
}
|
|
4835
4771
|
}
|
|
4836
4772
|
);
|
|
4837
4773
|
var oauth_default = app17;
|
|
4838
|
-
var
|
|
4774
|
+
var logger7 = getLogger("projectFull");
|
|
4839
4775
|
var app18 = new OpenAPIHono();
|
|
4840
4776
|
var ProjectIdParamsSchema = z.object({
|
|
4841
4777
|
tenantId: z.string().openapi({
|
|
@@ -4896,7 +4832,7 @@ app18.openapi(
|
|
|
4896
4832
|
const projectData = c.req.valid("json");
|
|
4897
4833
|
const validatedProjectData = FullProjectDefinitionSchema.parse(projectData);
|
|
4898
4834
|
try {
|
|
4899
|
-
const createdProject = await createFullProjectServerSide(dbClient_default,
|
|
4835
|
+
const createdProject = await createFullProjectServerSide(dbClient_default, logger7)(
|
|
4900
4836
|
{ tenantId, projectId: validatedProjectData.id },
|
|
4901
4837
|
validatedProjectData
|
|
4902
4838
|
);
|
|
@@ -4940,7 +4876,7 @@ app18.openapi(
|
|
|
4940
4876
|
try {
|
|
4941
4877
|
const project = await getFullProject(
|
|
4942
4878
|
dbClient_default,
|
|
4943
|
-
|
|
4879
|
+
logger7
|
|
4944
4880
|
)({
|
|
4945
4881
|
scopes: { tenantId, projectId }
|
|
4946
4882
|
});
|
|
@@ -5016,15 +4952,15 @@ app18.openapi(
|
|
|
5016
4952
|
}
|
|
5017
4953
|
const existingProject = await getFullProject(
|
|
5018
4954
|
dbClient_default,
|
|
5019
|
-
|
|
4955
|
+
logger7
|
|
5020
4956
|
)({
|
|
5021
4957
|
scopes: { tenantId, projectId }
|
|
5022
4958
|
});
|
|
5023
4959
|
const isCreate = !existingProject;
|
|
5024
|
-
const updatedProject = isCreate ? await createFullProjectServerSide(dbClient_default,
|
|
4960
|
+
const updatedProject = isCreate ? await createFullProjectServerSide(dbClient_default, logger7)(
|
|
5025
4961
|
{ tenantId, projectId },
|
|
5026
4962
|
validatedProjectData
|
|
5027
|
-
) : await updateFullProjectServerSide(dbClient_default,
|
|
4963
|
+
) : await updateFullProjectServerSide(dbClient_default, logger7)(
|
|
5028
4964
|
{ tenantId, projectId },
|
|
5029
4965
|
validatedProjectData
|
|
5030
4966
|
);
|
|
@@ -5072,7 +5008,7 @@ app18.openapi(
|
|
|
5072
5008
|
try {
|
|
5073
5009
|
const deleted = await deleteFullProject(
|
|
5074
5010
|
dbClient_default,
|
|
5075
|
-
|
|
5011
|
+
logger7
|
|
5076
5012
|
)({
|
|
5077
5013
|
scopes: { tenantId, projectId }
|
|
5078
5014
|
});
|
|
@@ -5100,8 +5036,8 @@ app18.openapi(
|
|
|
5100
5036
|
var projectFull_default = app18;
|
|
5101
5037
|
|
|
5102
5038
|
// src/app.ts
|
|
5103
|
-
var
|
|
5104
|
-
|
|
5039
|
+
var logger8 = getLogger("agents-manage-api");
|
|
5040
|
+
logger8.info({ logger: logger8.getTransports() }, "Logger initialized");
|
|
5105
5041
|
function createManagementHono(serverConfig, credentialStores) {
|
|
5106
5042
|
const app20 = new OpenAPIHono();
|
|
5107
5043
|
app20.use("*", requestId());
|
|
@@ -5156,7 +5092,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5156
5092
|
if (!isExpectedError) {
|
|
5157
5093
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
5158
5094
|
const errorStack = err instanceof Error ? err.stack : void 0;
|
|
5159
|
-
|
|
5095
|
+
logger8.error(
|
|
5160
5096
|
{
|
|
5161
5097
|
error: err,
|
|
5162
5098
|
message: errorMessage,
|
|
@@ -5167,7 +5103,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5167
5103
|
"Unexpected server error occurred"
|
|
5168
5104
|
);
|
|
5169
5105
|
} else {
|
|
5170
|
-
|
|
5106
|
+
logger8.error(
|
|
5171
5107
|
{
|
|
5172
5108
|
error: err,
|
|
5173
5109
|
path: c.req.path,
|
|
@@ -5183,7 +5119,7 @@ function createManagementHono(serverConfig, credentialStores) {
|
|
|
5183
5119
|
const response = err.getResponse();
|
|
5184
5120
|
return response;
|
|
5185
5121
|
} catch (responseError) {
|
|
5186
|
-
|
|
5122
|
+
logger8.error({ error: responseError }, "Error while handling HTTPException response");
|
|
5187
5123
|
}
|
|
5188
5124
|
}
|
|
5189
5125
|
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.6.
|
|
3
|
+
"version": "0.6.5",
|
|
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.6.
|
|
27
|
+
"@inkeep/agents-core": "^0.6.5"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@hono/vite-dev-server": "^0.20.1",
|