@inkeep/agents-manage-api 0.0.0-dev-20251212052837 → 0.0.0-dev-20251212193302
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/{chunk-OR52SACL.js → chunk-BAMAX6LI.js} +347 -76
- package/dist/factory.js +1 -1
- package/dist/index.js +2 -2
- package/package.json +4 -6
|
@@ -14,6 +14,7 @@ import { swaggerUI } from '@hono/swagger-ui';
|
|
|
14
14
|
import { nanoid } from 'nanoid';
|
|
15
15
|
import { StreamableHTTPTransport } from '@hono/mcp';
|
|
16
16
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
17
|
+
import axios from 'axios';
|
|
17
18
|
import { UserOrganizationsResponseSchema, AddUserToOrganizationResponseSchema, AddUserToOrganizationRequestSchema } from '@inkeep/agents-core/auth/validation';
|
|
18
19
|
import { eq, and } from 'drizzle-orm';
|
|
19
20
|
import * as client from 'openid-client';
|
|
@@ -38,7 +39,10 @@ var envSchema = z.object({
|
|
|
38
39
|
message: "Password must be at least 8 characters"
|
|
39
40
|
}),
|
|
40
41
|
DISABLE_AUTH: z.string().optional().default("false").transform((val) => val === "true"),
|
|
41
|
-
INKEEP_AGENTS_TEMP_JWT_PRIVATE_KEY: z.string().optional()
|
|
42
|
+
INKEEP_AGENTS_TEMP_JWT_PRIVATE_KEY: z.string().optional(),
|
|
43
|
+
SIGNOZ_URL: z.string().optional(),
|
|
44
|
+
SIGNOZ_API_KEY: z.string().optional(),
|
|
45
|
+
PUBLIC_SIGNOZ_URL: z.string().optional()
|
|
42
46
|
});
|
|
43
47
|
var parseEnv = () => {
|
|
44
48
|
try {
|
|
@@ -5310,11 +5314,11 @@ var requireTenantAccess = () => createMiddleware(async (c, next) => {
|
|
|
5310
5314
|
});
|
|
5311
5315
|
}
|
|
5312
5316
|
});
|
|
5313
|
-
function setupOpenAPIRoutes(
|
|
5314
|
-
|
|
5317
|
+
function setupOpenAPIRoutes(app30) {
|
|
5318
|
+
app30.get("/openapi.json", (c) => {
|
|
5315
5319
|
try {
|
|
5316
5320
|
const serverUrl = process.env.VERCEL_ENV === "production" && process.env.VERCEL_PROJECT_PRODUCTION_URL ? `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}` : process.env.VERCEL_ENV === "preview" && process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : env.INKEEP_AGENTS_MANAGE_API_URL;
|
|
5317
|
-
const document2 =
|
|
5321
|
+
const document2 = app30.getOpenAPIDocument({
|
|
5318
5322
|
openapi: "3.0.0",
|
|
5319
5323
|
info: {
|
|
5320
5324
|
title: "Inkeep Agents Manage API",
|
|
@@ -5453,7 +5457,7 @@ function setupOpenAPIRoutes(app29) {
|
|
|
5453
5457
|
return c.json({ error: "Failed to generate OpenAPI document", details: errorDetails }, 500);
|
|
5454
5458
|
}
|
|
5455
5459
|
});
|
|
5456
|
-
|
|
5460
|
+
app30.get(
|
|
5457
5461
|
"/docs",
|
|
5458
5462
|
swaggerUI({
|
|
5459
5463
|
url: "/openapi.json",
|
|
@@ -15758,91 +15762,109 @@ var ClientSDK = class {
|
|
|
15758
15762
|
};
|
|
15759
15763
|
var jsonLikeContentTypeRE = /(application|text)\/.*?\+*json.*/;
|
|
15760
15764
|
var jsonlLikeContentTypeRE = /(application|text)\/(.*?\+*\bjsonl\b.*|.*?\+*\bx-ndjson\b.*)/;
|
|
15761
|
-
async function logRequest(
|
|
15762
|
-
if (!
|
|
15765
|
+
async function logRequest(logger14, req) {
|
|
15766
|
+
if (!logger14) {
|
|
15763
15767
|
return;
|
|
15764
15768
|
}
|
|
15765
15769
|
const contentType = req.headers.get("content-type");
|
|
15766
15770
|
const ct2 = contentType?.split(";")[0] || "";
|
|
15767
|
-
|
|
15768
|
-
|
|
15771
|
+
logger14.group(`> Request: ${req.method} ${req.url}`);
|
|
15772
|
+
logger14.group("Headers:");
|
|
15769
15773
|
for (const [k3, v2] of req.headers.entries()) {
|
|
15770
|
-
|
|
15774
|
+
logger14.log(`${k3}: ${v2}`);
|
|
15771
15775
|
}
|
|
15772
|
-
|
|
15773
|
-
|
|
15776
|
+
logger14.groupEnd();
|
|
15777
|
+
logger14.group("Body:");
|
|
15774
15778
|
switch (true) {
|
|
15775
15779
|
case jsonLikeContentTypeRE.test(ct2):
|
|
15776
|
-
|
|
15780
|
+
logger14.log(await req.clone().json());
|
|
15777
15781
|
break;
|
|
15778
15782
|
case ct2.startsWith("text/"):
|
|
15779
|
-
|
|
15783
|
+
logger14.log(await req.clone().text());
|
|
15780
15784
|
break;
|
|
15781
15785
|
case ct2 === "multipart/form-data": {
|
|
15782
15786
|
const body2 = await req.clone().formData();
|
|
15783
15787
|
for (const [k3, v2] of body2) {
|
|
15784
15788
|
const vlabel = v2 instanceof Blob ? "<Blob>" : v2;
|
|
15785
|
-
|
|
15789
|
+
logger14.log(`${k3}: ${vlabel}`);
|
|
15786
15790
|
}
|
|
15787
15791
|
break;
|
|
15788
15792
|
}
|
|
15789
15793
|
default:
|
|
15790
|
-
|
|
15794
|
+
logger14.log(`<${contentType}>`);
|
|
15791
15795
|
break;
|
|
15792
15796
|
}
|
|
15793
|
-
|
|
15794
|
-
|
|
15797
|
+
logger14.groupEnd();
|
|
15798
|
+
logger14.groupEnd();
|
|
15795
15799
|
}
|
|
15796
|
-
async function logResponse(
|
|
15797
|
-
if (!
|
|
15800
|
+
async function logResponse(logger14, res, req) {
|
|
15801
|
+
if (!logger14) {
|
|
15798
15802
|
return;
|
|
15799
15803
|
}
|
|
15800
15804
|
const contentType = res.headers.get("content-type");
|
|
15801
15805
|
const ct2 = contentType?.split(";")[0] || "";
|
|
15802
|
-
|
|
15803
|
-
|
|
15804
|
-
|
|
15806
|
+
logger14.group(`< Response: ${req.method} ${req.url}`);
|
|
15807
|
+
logger14.log("Status Code:", res.status, res.statusText);
|
|
15808
|
+
logger14.group("Headers:");
|
|
15805
15809
|
for (const [k3, v2] of res.headers.entries()) {
|
|
15806
|
-
|
|
15810
|
+
logger14.log(`${k3}: ${v2}`);
|
|
15807
15811
|
}
|
|
15808
|
-
|
|
15809
|
-
|
|
15812
|
+
logger14.groupEnd();
|
|
15813
|
+
logger14.group("Body:");
|
|
15810
15814
|
switch (true) {
|
|
15811
15815
|
case (matchContentType(res, "application/json") || jsonLikeContentTypeRE.test(ct2) && !jsonlLikeContentTypeRE.test(ct2)):
|
|
15812
|
-
|
|
15816
|
+
logger14.log(await res.clone().json());
|
|
15813
15817
|
break;
|
|
15814
15818
|
case (matchContentType(res, "application/jsonl") || jsonlLikeContentTypeRE.test(ct2)):
|
|
15815
|
-
|
|
15819
|
+
logger14.log(await res.clone().text());
|
|
15816
15820
|
break;
|
|
15817
15821
|
case matchContentType(res, "text/event-stream"):
|
|
15818
|
-
|
|
15822
|
+
logger14.log(`<${contentType}>`);
|
|
15819
15823
|
break;
|
|
15820
15824
|
case matchContentType(res, "text/*"):
|
|
15821
|
-
|
|
15825
|
+
logger14.log(await res.clone().text());
|
|
15822
15826
|
break;
|
|
15823
15827
|
case matchContentType(res, "multipart/form-data"): {
|
|
15824
15828
|
const body2 = await res.clone().formData();
|
|
15825
15829
|
for (const [k3, v2] of body2) {
|
|
15826
15830
|
const vlabel = v2 instanceof Blob ? "<Blob>" : v2;
|
|
15827
|
-
|
|
15831
|
+
logger14.log(`${k3}: ${vlabel}`);
|
|
15828
15832
|
}
|
|
15829
15833
|
break;
|
|
15830
15834
|
}
|
|
15831
15835
|
default:
|
|
15832
|
-
|
|
15836
|
+
logger14.log(`<${contentType}>`);
|
|
15833
15837
|
break;
|
|
15834
15838
|
}
|
|
15835
|
-
|
|
15836
|
-
|
|
15839
|
+
logger14.groupEnd();
|
|
15840
|
+
logger14.groupEnd();
|
|
15837
15841
|
}
|
|
15838
15842
|
var InkeepAgentsCore = class extends ClientSDK {
|
|
15839
15843
|
};
|
|
15844
|
+
var HeaderForwardingHook = class {
|
|
15845
|
+
headersToForward;
|
|
15846
|
+
constructor(headersToForward) {
|
|
15847
|
+
this.headersToForward = headersToForward;
|
|
15848
|
+
}
|
|
15849
|
+
async beforeRequest(_hookCtx, request) {
|
|
15850
|
+
if (Object.keys(this.headersToForward).length === 0) {
|
|
15851
|
+
return request;
|
|
15852
|
+
}
|
|
15853
|
+
const newHeaders = new Headers(request.headers);
|
|
15854
|
+
for (const [key, value] of Object.entries(this.headersToForward)) {
|
|
15855
|
+
if (!newHeaders.has(key)) {
|
|
15856
|
+
newHeaders.set(key, value);
|
|
15857
|
+
}
|
|
15858
|
+
}
|
|
15859
|
+
return new Request(request, { headers: newHeaders });
|
|
15860
|
+
}
|
|
15861
|
+
};
|
|
15840
15862
|
var consoleLoggerLevels = ["debug", "warning", "info", "error"];
|
|
15841
15863
|
function createConsoleLogger(level) {
|
|
15842
15864
|
const min = consoleLoggerLevels.indexOf(level);
|
|
15843
15865
|
const noop = () => {
|
|
15844
15866
|
};
|
|
15845
|
-
const
|
|
15867
|
+
const logger14 = {
|
|
15846
15868
|
debug: noop,
|
|
15847
15869
|
warning: noop,
|
|
15848
15870
|
info: noop,
|
|
@@ -15855,7 +15877,7 @@ function createConsoleLogger(level) {
|
|
|
15855
15877
|
}
|
|
15856
15878
|
logger22[level2] = log.bind(null, level2);
|
|
15857
15879
|
return logger22;
|
|
15858
|
-
},
|
|
15880
|
+
}, logger14);
|
|
15859
15881
|
}
|
|
15860
15882
|
function log(level, message, data) {
|
|
15861
15883
|
let line = "";
|
|
@@ -16493,7 +16515,7 @@ async function consumeSSE(value) {
|
|
|
16493
16515
|
}
|
|
16494
16516
|
return content;
|
|
16495
16517
|
}
|
|
16496
|
-
function createRegisterTool(
|
|
16518
|
+
function createRegisterTool(logger14, server, getSDK, allowedScopes, allowedTools) {
|
|
16497
16519
|
return (tool) => {
|
|
16498
16520
|
if (allowedTools && !allowedTools.has(tool.name)) {
|
|
16499
16521
|
return;
|
|
@@ -16514,7 +16536,7 @@ function createRegisterTool(logger13, server, getSDK, allowedScopes, allowedTool
|
|
|
16514
16536
|
return tool.tool(getSDK(), ctx);
|
|
16515
16537
|
});
|
|
16516
16538
|
}
|
|
16517
|
-
|
|
16539
|
+
logger14.debug("Registered tool", { name: tool.name });
|
|
16518
16540
|
};
|
|
16519
16541
|
}
|
|
16520
16542
|
var args2 = {
|
|
@@ -33775,12 +33797,32 @@ function createMCPServer(deps) {
|
|
|
33775
33797
|
return server;
|
|
33776
33798
|
}
|
|
33777
33799
|
var app25 = new Hono();
|
|
33800
|
+
var FORWARDED_HEADERS = ["x-forwarded-cookie", "authorization", "cookie"];
|
|
33778
33801
|
app25.all("/", async (c) => {
|
|
33779
33802
|
const transport = new StreamableHTTPTransport();
|
|
33780
33803
|
const noOpLogger = createConsoleLogger("error");
|
|
33804
|
+
const headersToForward = {};
|
|
33805
|
+
for (const headerName of FORWARDED_HEADERS) {
|
|
33806
|
+
const value = c.req.header(headerName);
|
|
33807
|
+
if (value) {
|
|
33808
|
+
headersToForward[headerName] = value;
|
|
33809
|
+
}
|
|
33810
|
+
}
|
|
33811
|
+
if (headersToForward["x-forwarded-cookie"] && !headersToForward["cookie"]) {
|
|
33812
|
+
headersToForward["cookie"] = headersToForward["x-forwarded-cookie"];
|
|
33813
|
+
}
|
|
33814
|
+
const createSDKWithHeaders = () => {
|
|
33815
|
+
const hooks = new SDKHooks();
|
|
33816
|
+
hooks.registerBeforeRequestHook(new HeaderForwardingHook(headersToForward));
|
|
33817
|
+
return new InkeepAgentsCore({
|
|
33818
|
+
serverURL: env.INKEEP_AGENTS_MANAGE_API_URL,
|
|
33819
|
+
hooks
|
|
33820
|
+
});
|
|
33821
|
+
};
|
|
33781
33822
|
const mcpServer = createMCPServer({
|
|
33782
33823
|
logger: noOpLogger,
|
|
33783
|
-
serverURL: env.INKEEP_AGENTS_MANAGE_API_URL
|
|
33824
|
+
serverURL: env.INKEEP_AGENTS_MANAGE_API_URL,
|
|
33825
|
+
getSDK: createSDKWithHeaders
|
|
33784
33826
|
});
|
|
33785
33827
|
await mcpServer.connect(transport);
|
|
33786
33828
|
return transport.handleRequest(c);
|
|
@@ -34574,6 +34616,210 @@ app28.openapi(
|
|
|
34574
34616
|
}
|
|
34575
34617
|
);
|
|
34576
34618
|
var projectFull_default = app28;
|
|
34619
|
+
|
|
34620
|
+
// src/utils/signoz-helpers.ts
|
|
34621
|
+
function enforceProjectFilter(payload, projectId) {
|
|
34622
|
+
const modifiedPayload = JSON.parse(JSON.stringify(payload));
|
|
34623
|
+
if (modifiedPayload.compositeQuery?.builderQueries) {
|
|
34624
|
+
for (const queryKey in modifiedPayload.compositeQuery.builderQueries) {
|
|
34625
|
+
const query = modifiedPayload.compositeQuery.builderQueries[queryKey];
|
|
34626
|
+
if (!query.filters) {
|
|
34627
|
+
query.filters = { op: "AND", items: [] };
|
|
34628
|
+
}
|
|
34629
|
+
query.filters.items = query.filters.items.filter(
|
|
34630
|
+
(item) => item.key?.key !== "project.id"
|
|
34631
|
+
);
|
|
34632
|
+
query.filters.items.push({
|
|
34633
|
+
key: {
|
|
34634
|
+
key: "project.id",
|
|
34635
|
+
dataType: "string",
|
|
34636
|
+
type: "tag",
|
|
34637
|
+
isColumn: false,
|
|
34638
|
+
isJSON: false,
|
|
34639
|
+
id: "false"
|
|
34640
|
+
},
|
|
34641
|
+
op: "=",
|
|
34642
|
+
value: projectId
|
|
34643
|
+
});
|
|
34644
|
+
}
|
|
34645
|
+
}
|
|
34646
|
+
return modifiedPayload;
|
|
34647
|
+
}
|
|
34648
|
+
|
|
34649
|
+
// src/routes/signoz.ts
|
|
34650
|
+
var logger11 = getLogger("signoz-proxy");
|
|
34651
|
+
var app29 = new Hono();
|
|
34652
|
+
app29.post("/query", async (c) => {
|
|
34653
|
+
let payload = await c.req.json();
|
|
34654
|
+
const requestedProjectId = payload.projectId;
|
|
34655
|
+
const tenantId = c.get("tenantId");
|
|
34656
|
+
logger11.info(
|
|
34657
|
+
{ tenantId, projectId: requestedProjectId, hasProjectId: !!requestedProjectId },
|
|
34658
|
+
"Processing SigNoz query request"
|
|
34659
|
+
);
|
|
34660
|
+
if (requestedProjectId) {
|
|
34661
|
+
const projectExistsCheck = await projectExists(dbClient_default)({
|
|
34662
|
+
tenantId,
|
|
34663
|
+
projectId: requestedProjectId
|
|
34664
|
+
});
|
|
34665
|
+
if (!projectExistsCheck) {
|
|
34666
|
+
logger11.warn(
|
|
34667
|
+
{ tenantId, projectId: requestedProjectId },
|
|
34668
|
+
"Project not found or access denied"
|
|
34669
|
+
);
|
|
34670
|
+
return c.json(
|
|
34671
|
+
{
|
|
34672
|
+
error: "Forbidden",
|
|
34673
|
+
message: "You do not have access to this project"
|
|
34674
|
+
},
|
|
34675
|
+
403
|
|
34676
|
+
);
|
|
34677
|
+
}
|
|
34678
|
+
payload = enforceProjectFilter(payload, requestedProjectId);
|
|
34679
|
+
logger11.debug({ projectId: requestedProjectId }, "Project filter enforced");
|
|
34680
|
+
}
|
|
34681
|
+
const signozUrl = env.SIGNOZ_URL || env.PUBLIC_SIGNOZ_URL;
|
|
34682
|
+
const signozApiKey = env.SIGNOZ_API_KEY;
|
|
34683
|
+
if (!signozUrl || !signozApiKey) {
|
|
34684
|
+
logger11.error({}, "SigNoz not configured");
|
|
34685
|
+
return c.json(
|
|
34686
|
+
{
|
|
34687
|
+
error: "Service Unavailable",
|
|
34688
|
+
message: "SigNoz is not configured"
|
|
34689
|
+
},
|
|
34690
|
+
500
|
|
34691
|
+
);
|
|
34692
|
+
}
|
|
34693
|
+
try {
|
|
34694
|
+
const signozEndpoint = `${signozUrl}/api/v4/query_range`;
|
|
34695
|
+
logger11.debug({ endpoint: signozEndpoint }, "Proxying to SigNoz");
|
|
34696
|
+
const response = await axios.post(signozEndpoint, payload, {
|
|
34697
|
+
headers: {
|
|
34698
|
+
"Content-Type": "application/json",
|
|
34699
|
+
"SIGNOZ-API-KEY": signozApiKey
|
|
34700
|
+
},
|
|
34701
|
+
timeout: 3e4
|
|
34702
|
+
});
|
|
34703
|
+
logger11.info({ status: response.status }, "SigNoz query successful");
|
|
34704
|
+
return c.json(response.data);
|
|
34705
|
+
} catch (error) {
|
|
34706
|
+
if (axios.isAxiosError(error)) {
|
|
34707
|
+
if (error.code === "ECONNREFUSED" || error.code === "ENOTFOUND") {
|
|
34708
|
+
logger11.error({ error: error.message }, "SigNoz service unavailable");
|
|
34709
|
+
return c.json(
|
|
34710
|
+
{
|
|
34711
|
+
error: "Service Unavailable",
|
|
34712
|
+
message: "SigNoz service is unavailable"
|
|
34713
|
+
},
|
|
34714
|
+
503
|
|
34715
|
+
);
|
|
34716
|
+
}
|
|
34717
|
+
if (error.response?.status === 401 || error.response?.status === 403) {
|
|
34718
|
+
logger11.error({ status: error.response.status }, "SigNoz authentication failed");
|
|
34719
|
+
return c.json(
|
|
34720
|
+
{
|
|
34721
|
+
error: "Internal Server Error",
|
|
34722
|
+
message: "SigNoz authentication failed"
|
|
34723
|
+
},
|
|
34724
|
+
500
|
|
34725
|
+
);
|
|
34726
|
+
}
|
|
34727
|
+
if (error.response?.status === 400) {
|
|
34728
|
+
logger11.warn({ status: error.response.status }, "Invalid SigNoz query");
|
|
34729
|
+
return c.json(
|
|
34730
|
+
{
|
|
34731
|
+
error: "Bad Request",
|
|
34732
|
+
message: "Invalid query parameters"
|
|
34733
|
+
},
|
|
34734
|
+
400
|
|
34735
|
+
);
|
|
34736
|
+
}
|
|
34737
|
+
}
|
|
34738
|
+
logger11.error({ error }, "SigNoz query failed");
|
|
34739
|
+
return c.json(
|
|
34740
|
+
{
|
|
34741
|
+
error: "Internal Server Error",
|
|
34742
|
+
message: "Failed to query SigNoz"
|
|
34743
|
+
},
|
|
34744
|
+
500
|
|
34745
|
+
);
|
|
34746
|
+
}
|
|
34747
|
+
});
|
|
34748
|
+
app29.get("/health", async (c) => {
|
|
34749
|
+
const signozUrl = env.SIGNOZ_URL || env.PUBLIC_SIGNOZ_URL;
|
|
34750
|
+
const signozApiKey = env.SIGNOZ_API_KEY;
|
|
34751
|
+
logger11.info(
|
|
34752
|
+
{
|
|
34753
|
+
hasUrl: !!signozUrl,
|
|
34754
|
+
hasApiKey: !!signozApiKey,
|
|
34755
|
+
url: signozUrl
|
|
34756
|
+
},
|
|
34757
|
+
"Checking SigNoz configuration"
|
|
34758
|
+
);
|
|
34759
|
+
if (!signozUrl || !signozApiKey) {
|
|
34760
|
+
logger11.warn({}, "SigNoz credentials not set");
|
|
34761
|
+
return c.json({
|
|
34762
|
+
status: "not_configured",
|
|
34763
|
+
configured: false,
|
|
34764
|
+
error: "SIGNOZ_URL or SIGNOZ_API_KEY not set"
|
|
34765
|
+
});
|
|
34766
|
+
}
|
|
34767
|
+
try {
|
|
34768
|
+
const testPayload = {
|
|
34769
|
+
start: Date.now() - 3e5,
|
|
34770
|
+
// 5 minutes ago
|
|
34771
|
+
end: Date.now(),
|
|
34772
|
+
step: 60,
|
|
34773
|
+
compositeQuery: {
|
|
34774
|
+
queryType: "builder",
|
|
34775
|
+
panelType: "table",
|
|
34776
|
+
builderQueries: {}
|
|
34777
|
+
}
|
|
34778
|
+
};
|
|
34779
|
+
const signozEndpoint = `${signozUrl}/api/v4/query_range`;
|
|
34780
|
+
logger11.info({ endpoint: signozEndpoint }, "Testing SigNoz connection");
|
|
34781
|
+
await axios.post(signozEndpoint, testPayload, {
|
|
34782
|
+
headers: {
|
|
34783
|
+
"Content-Type": "application/json",
|
|
34784
|
+
"SIGNOZ-API-KEY": signozApiKey
|
|
34785
|
+
},
|
|
34786
|
+
timeout: 5e3,
|
|
34787
|
+
validateStatus: (status) => status === 200 || status === 400
|
|
34788
|
+
// Both OK (valid API key)
|
|
34789
|
+
});
|
|
34790
|
+
logger11.info({}, "SigNoz health check successful");
|
|
34791
|
+
return c.json({
|
|
34792
|
+
status: "ok",
|
|
34793
|
+
configured: true
|
|
34794
|
+
});
|
|
34795
|
+
} catch (error) {
|
|
34796
|
+
logger11.error(
|
|
34797
|
+
{
|
|
34798
|
+
error,
|
|
34799
|
+
message: error instanceof Error ? error.message : "Unknown error",
|
|
34800
|
+
code: axios.isAxiosError(error) ? error.code : void 0,
|
|
34801
|
+
status: axios.isAxiosError(error) ? error.response?.status : void 0
|
|
34802
|
+
},
|
|
34803
|
+
"SigNoz connection test failed"
|
|
34804
|
+
);
|
|
34805
|
+
let errorMessage = "Failed to connect to SigNoz";
|
|
34806
|
+
if (axios.isAxiosError(error)) {
|
|
34807
|
+
if (error.code === "ECONNREFUSED" || error.code === "ENOTFOUND") {
|
|
34808
|
+
errorMessage = "Check SIGNOZ_URL";
|
|
34809
|
+
} else if (error.response?.status === 401 || error.response?.status === 403) {
|
|
34810
|
+
errorMessage = "Invalid SIGNOZ_API_KEY";
|
|
34811
|
+
} else if (error.code === "ETIMEDOUT" || error.code === "ECONNABORTED") {
|
|
34812
|
+
errorMessage = "SigNoz connection timed out";
|
|
34813
|
+
}
|
|
34814
|
+
}
|
|
34815
|
+
return c.json({
|
|
34816
|
+
status: "connection_failed",
|
|
34817
|
+
configured: false,
|
|
34818
|
+
error: errorMessage
|
|
34819
|
+
});
|
|
34820
|
+
}
|
|
34821
|
+
});
|
|
34822
|
+
var signoz_default = app29;
|
|
34577
34823
|
var userOrganizationsRoutes = new OpenAPIHono();
|
|
34578
34824
|
userOrganizationsRoutes.openapi(
|
|
34579
34825
|
createRoute({
|
|
@@ -34704,19 +34950,19 @@ var defaultCorsConfig = {
|
|
|
34704
34950
|
};
|
|
34705
34951
|
|
|
34706
34952
|
// src/app.ts
|
|
34707
|
-
var
|
|
34708
|
-
|
|
34953
|
+
var logger12 = getLogger("agents-manage-api");
|
|
34954
|
+
logger12.info({ logger: logger12.getTransports() }, "Logger initialized");
|
|
34709
34955
|
var isTestEnvironment = () => process.env.ENVIRONMENT === "test";
|
|
34710
34956
|
function createManagementHono(serverConfig, credentialStores, auth) {
|
|
34711
|
-
const
|
|
34712
|
-
|
|
34713
|
-
|
|
34957
|
+
const app30 = new OpenAPIHono();
|
|
34958
|
+
app30.use("*", requestId());
|
|
34959
|
+
app30.use("*", async (c, next) => {
|
|
34714
34960
|
c.set("serverConfig", serverConfig);
|
|
34715
34961
|
c.set("credentialStores", credentialStores);
|
|
34716
34962
|
c.set("auth", auth);
|
|
34717
34963
|
return next();
|
|
34718
34964
|
});
|
|
34719
|
-
|
|
34965
|
+
app30.use(
|
|
34720
34966
|
pinoLogger({
|
|
34721
34967
|
pino: getLogger("agents-manage-api").getPinoInstance(),
|
|
34722
34968
|
http: {
|
|
@@ -34729,24 +34975,48 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
34729
34975
|
}
|
|
34730
34976
|
})
|
|
34731
34977
|
);
|
|
34732
|
-
|
|
34978
|
+
app30.onError(errorHandler);
|
|
34733
34979
|
if (auth) {
|
|
34734
|
-
|
|
34735
|
-
|
|
34980
|
+
app30.use("/api/auth/*", cors(authCorsConfig));
|
|
34981
|
+
app30.on(["POST", "GET"], "/api/auth/*", (c) => {
|
|
34736
34982
|
return auth.handler(c.req.raw);
|
|
34737
34983
|
});
|
|
34738
34984
|
}
|
|
34739
|
-
|
|
34740
|
-
|
|
34985
|
+
app30.use("/tenants/*/playground/token", cors(playgroundCorsConfig));
|
|
34986
|
+
app30.use(
|
|
34987
|
+
"/tenants/*/signoz/*",
|
|
34988
|
+
cors({
|
|
34989
|
+
origin: (origin) => {
|
|
34990
|
+
return isOriginAllowed(origin) ? origin : null;
|
|
34991
|
+
},
|
|
34992
|
+
allowHeaders: [
|
|
34993
|
+
"content-type",
|
|
34994
|
+
"Content-Type",
|
|
34995
|
+
"authorization",
|
|
34996
|
+
"Authorization",
|
|
34997
|
+
"User-Agent",
|
|
34998
|
+
"Cookie",
|
|
34999
|
+
"X-Forwarded-Cookie"
|
|
35000
|
+
],
|
|
35001
|
+
allowMethods: ["GET", "POST", "OPTIONS"],
|
|
35002
|
+
exposeHeaders: ["Content-Length", "Set-Cookie"],
|
|
35003
|
+
maxAge: 600,
|
|
35004
|
+
credentials: true
|
|
35005
|
+
})
|
|
35006
|
+
);
|
|
35007
|
+
app30.use("*", async (c, next) => {
|
|
34741
35008
|
if (auth && c.req.path.startsWith("/api/auth/")) {
|
|
34742
35009
|
return next();
|
|
34743
35010
|
}
|
|
34744
35011
|
if (c.req.path.includes("/playground/token")) {
|
|
34745
35012
|
return next();
|
|
34746
35013
|
}
|
|
35014
|
+
if (c.req.path.includes("/signoz/")) {
|
|
35015
|
+
return next();
|
|
35016
|
+
}
|
|
34747
35017
|
return cors(defaultCorsConfig)(c, next);
|
|
34748
35018
|
});
|
|
34749
|
-
|
|
35019
|
+
app30.use("*", async (c, next) => {
|
|
34750
35020
|
if (env.DISABLE_AUTH || !auth) {
|
|
34751
35021
|
c.set("user", null);
|
|
34752
35022
|
c.set("session", null);
|
|
@@ -34769,7 +35039,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
34769
35039
|
c.set("session", session.session);
|
|
34770
35040
|
await next();
|
|
34771
35041
|
});
|
|
34772
|
-
|
|
35042
|
+
app30.openapi(
|
|
34773
35043
|
createRoute({
|
|
34774
35044
|
method: "get",
|
|
34775
35045
|
path: "/health",
|
|
@@ -34786,7 +35056,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
34786
35056
|
return c.body(null, 204);
|
|
34787
35057
|
}
|
|
34788
35058
|
);
|
|
34789
|
-
|
|
35059
|
+
app30.use("/tenants/*", async (c, next) => {
|
|
34790
35060
|
if (env.DISABLE_AUTH || isTestEnvironment()) {
|
|
34791
35061
|
await next();
|
|
34792
35062
|
return;
|
|
@@ -34798,7 +35068,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
34798
35068
|
return sessionAuth()(c, next);
|
|
34799
35069
|
});
|
|
34800
35070
|
if (env.DISABLE_AUTH || isTestEnvironment()) {
|
|
34801
|
-
|
|
35071
|
+
app30.use("/tenants/:tenantId/*", async (c, next) => {
|
|
34802
35072
|
const tenantId = c.req.param("tenantId");
|
|
34803
35073
|
if (tenantId) {
|
|
34804
35074
|
c.set("tenantId", tenantId);
|
|
@@ -34807,21 +35077,22 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
34807
35077
|
await next();
|
|
34808
35078
|
});
|
|
34809
35079
|
} else {
|
|
34810
|
-
|
|
34811
|
-
}
|
|
34812
|
-
|
|
34813
|
-
|
|
34814
|
-
|
|
34815
|
-
|
|
34816
|
-
|
|
34817
|
-
|
|
34818
|
-
|
|
34819
|
-
|
|
35080
|
+
app30.use("/tenants/:tenantId/*", requireTenantAccess());
|
|
35081
|
+
}
|
|
35082
|
+
app30.route("/api/users/:userId/organizations", userOrganizations_default);
|
|
35083
|
+
app30.route("/api/invitations", invitations_default);
|
|
35084
|
+
app30.route("/tenants/:tenantId", routes_default);
|
|
35085
|
+
app30.route("/tenants/:tenantId/playground/token", playgroundToken_default);
|
|
35086
|
+
app30.route("/tenants/:tenantId/signoz", signoz_default);
|
|
35087
|
+
app30.route("/tenants/:tenantId", projectFull_default);
|
|
35088
|
+
app30.route("/oauth", oauth_default);
|
|
35089
|
+
app30.route("/mcp", mcp_default);
|
|
35090
|
+
setupOpenAPIRoutes(app30);
|
|
34820
35091
|
const baseApp = new Hono();
|
|
34821
|
-
baseApp.route("/",
|
|
35092
|
+
baseApp.route("/", app30);
|
|
34822
35093
|
return baseApp;
|
|
34823
35094
|
}
|
|
34824
|
-
var
|
|
35095
|
+
var logger13 = getLogger("initialization");
|
|
34825
35096
|
async function initializeDefaultUser(authInstance) {
|
|
34826
35097
|
const { INKEEP_AGENTS_MANAGE_UI_USERNAME, INKEEP_AGENTS_MANAGE_UI_PASSWORD, DISABLE_AUTH } = env;
|
|
34827
35098
|
const hasCredentials = INKEEP_AGENTS_MANAGE_UI_USERNAME && INKEEP_AGENTS_MANAGE_UI_PASSWORD;
|
|
@@ -34836,23 +35107,23 @@ async function initializeDefaultUser(authInstance) {
|
|
|
34836
35107
|
logo: null,
|
|
34837
35108
|
metadata: null
|
|
34838
35109
|
});
|
|
34839
|
-
|
|
35110
|
+
logger13.info({ organizationId: orgId }, "Created default organization");
|
|
34840
35111
|
} else {
|
|
34841
|
-
|
|
35112
|
+
logger13.info({ organizationId: orgId }, "Organization already exists");
|
|
34842
35113
|
}
|
|
34843
35114
|
if (!hasCredentials || DISABLE_AUTH || !authInstance) {
|
|
34844
|
-
|
|
35115
|
+
logger13.info({ hasCredentials: false }, "Skipping default user creation");
|
|
34845
35116
|
return;
|
|
34846
35117
|
}
|
|
34847
35118
|
try {
|
|
34848
35119
|
let user = await getUserByEmail(dbClient_default)(INKEEP_AGENTS_MANAGE_UI_USERNAME);
|
|
34849
35120
|
if (user) {
|
|
34850
|
-
|
|
35121
|
+
logger13.info(
|
|
34851
35122
|
{ email: INKEEP_AGENTS_MANAGE_UI_USERNAME, userId: user.id },
|
|
34852
35123
|
"Default user already exists"
|
|
34853
35124
|
);
|
|
34854
35125
|
} else {
|
|
34855
|
-
|
|
35126
|
+
logger13.info(
|
|
34856
35127
|
{ email: INKEEP_AGENTS_MANAGE_UI_USERNAME },
|
|
34857
35128
|
"Creating default user with Better Auth..."
|
|
34858
35129
|
);
|
|
@@ -34871,7 +35142,7 @@ async function initializeDefaultUser(authInstance) {
|
|
|
34871
35142
|
if (!user) {
|
|
34872
35143
|
throw new Error("User was created but could not be retrieved from database");
|
|
34873
35144
|
}
|
|
34874
|
-
|
|
35145
|
+
logger13.info(
|
|
34875
35146
|
{
|
|
34876
35147
|
email: user.email,
|
|
34877
35148
|
id: user.id
|
|
@@ -34888,14 +35159,14 @@ async function initializeDefaultUser(authInstance) {
|
|
|
34888
35159
|
role: "owner",
|
|
34889
35160
|
createdAt: /* @__PURE__ */ new Date()
|
|
34890
35161
|
});
|
|
34891
|
-
|
|
35162
|
+
logger13.info({ userId: user.id, organizationId: orgId }, "Added user as organization owner");
|
|
34892
35163
|
} else {
|
|
34893
|
-
|
|
35164
|
+
logger13.info(
|
|
34894
35165
|
{ userId: user.id, organizationId: orgId },
|
|
34895
35166
|
"User already a member of organization"
|
|
34896
35167
|
);
|
|
34897
35168
|
}
|
|
34898
|
-
|
|
35169
|
+
logger13.info(
|
|
34899
35170
|
{
|
|
34900
35171
|
organizationId: orgId,
|
|
34901
35172
|
organizationSlug: env.TENANT_ID,
|
|
@@ -34905,7 +35176,7 @@ async function initializeDefaultUser(authInstance) {
|
|
|
34905
35176
|
"\u2705 Initialization complete - login with these credentials"
|
|
34906
35177
|
);
|
|
34907
35178
|
} catch (error) {
|
|
34908
|
-
|
|
35179
|
+
logger13.error(
|
|
34909
35180
|
{ error, email: INKEEP_AGENTS_MANAGE_UI_USERNAME },
|
|
34910
35181
|
"\u274C Failed to create default user"
|
|
34911
35182
|
);
|
package/dist/factory.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createAuth0Provider, createManagementApp, createManagementHono, createOIDCProvider, initializeDefaultUser } from './chunk-
|
|
1
|
+
export { createAuth0Provider, createManagementApp, createManagementHono, createOIDCProvider, initializeDefaultUser } from './chunk-BAMAX6LI.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createAuth0Provider, createManagementHono, env, initializeDefaultUser, dbClient_default } from './chunk-
|
|
2
|
-
export { createAuth0Provider, createManagementApp, createManagementHono, createOIDCProvider, initializeDefaultUser } from './chunk-
|
|
1
|
+
import { createAuth0Provider, createManagementHono, env, initializeDefaultUser, dbClient_default } from './chunk-BAMAX6LI.js';
|
|
2
|
+
export { createAuth0Provider, createManagementApp, createManagementHono, createOIDCProvider, initializeDefaultUser } from './chunk-BAMAX6LI.js';
|
|
3
3
|
import { createDefaultCredentialStores, CredentialStoreRegistry } from '@inkeep/agents-core';
|
|
4
4
|
import { createAuth } from '@inkeep/agents-core/auth';
|
|
5
5
|
export { Hono } from 'hono';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-manage-api",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20251212193302",
|
|
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,6 +24,7 @@
|
|
|
24
24
|
"@modelcontextprotocol/sdk": "^1.17.0",
|
|
25
25
|
"@nangohq/node": "^0.69.5",
|
|
26
26
|
"@nangohq/types": "^0.69.5",
|
|
27
|
+
"axios": "^1.7.9",
|
|
27
28
|
"dotenv": "^17.2.1",
|
|
28
29
|
"drizzle-orm": "^0.44.4",
|
|
29
30
|
"hono": "^4.10.4",
|
|
@@ -32,8 +33,8 @@
|
|
|
32
33
|
"nanoid": "^5.1.5",
|
|
33
34
|
"openid-client": "^6.6.4",
|
|
34
35
|
"pino": "^9.7.0",
|
|
35
|
-
"@inkeep/agents-core": "^0.0.0-dev-
|
|
36
|
-
"@inkeep/agents-manage-mcp": "^0.0.0-dev-
|
|
36
|
+
"@inkeep/agents-core": "^0.0.0-dev-20251212193302",
|
|
37
|
+
"@inkeep/agents-manage-mcp": "^0.0.0-dev-20251212193302"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"@hono/zod-openapi": "^1.1.5",
|
|
@@ -55,9 +56,6 @@
|
|
|
55
56
|
"vite-tsconfig-paths": "^5.1.4",
|
|
56
57
|
"vitest": "^3.2.4"
|
|
57
58
|
},
|
|
58
|
-
"engines": {
|
|
59
|
-
"node": ">=22.0.0"
|
|
60
|
-
},
|
|
61
59
|
"publishConfig": {
|
|
62
60
|
"access": "public",
|
|
63
61
|
"registry": "https://registry.npmjs.org/"
|