@inkeep/agents-api 0.44.0 → 0.45.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/.well-known/workflow/v1/manifest.debug.json +20 -20
- package/dist/.well-known/workflow/v1/step.cjs +403 -401
- package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
- package/dist/domains/evals/routes/index.d.ts +2 -2
- package/dist/domains/manage/index.js +2 -0
- package/dist/domains/manage/routes/availableAgents.d.ts +7 -0
- package/dist/domains/manage/routes/availableAgents.js +94 -0
- package/dist/domains/manage/routes/branches.js +9 -0
- package/dist/domains/manage/routes/conversations.d.ts +2 -2
- package/dist/domains/manage/routes/evals/datasetItems.js +13 -0
- package/dist/domains/manage/routes/evals/datasets.js +9 -0
- package/dist/domains/manage/routes/evals/evaluationJobConfigEvaluatorRelations.js +5 -0
- package/dist/domains/manage/routes/evals/evaluationJobConfigs.js +9 -0
- package/dist/domains/manage/routes/evals/evaluationResults.d.ts +4 -2
- package/dist/domains/manage/routes/evals/evaluationResults.js +9 -0
- package/dist/domains/manage/routes/evals/evaluationRunConfigs.js +9 -0
- package/dist/domains/manage/routes/evals/evaluationSuiteConfigEvaluatorRelations.js +5 -0
- package/dist/domains/manage/routes/evals/evaluationSuiteConfigs.js +9 -0
- package/dist/domains/manage/routes/evals/evaluators.js +9 -0
- package/dist/domains/manage/routes/index.d.ts +2 -2
- package/dist/domains/manage/routes/invitations.d.ts +4 -3
- package/dist/domains/manage/routes/invitations.js +16 -28
- package/dist/domains/manage/routes/mcp.d.ts +2 -2
- package/dist/domains/manage/routes/playgroundToken.js +3 -2
- package/dist/domains/manage/routes/signoz.d.ts +2 -2
- package/dist/domains/manage/routes/signoz.js +22 -16
- package/dist/domains/manage/routes/userOrganizations.d.ts +4 -3
- package/dist/domains/manage/routes/userOrganizations.js +16 -45
- package/dist/domains/mcp/routes/mcp.d.ts +2 -2
- package/dist/domains/run/agents/relationTools.js +2 -1
- package/dist/env.js +5 -5
- package/dist/middleware/evalsAuth.d.ts +2 -2
- package/dist/middleware/manageAuth.d.ts +2 -2
- package/dist/middleware/projectAccess.d.ts +2 -2
- package/dist/middleware/projectConfig.d.ts +3 -3
- package/dist/middleware/requirePermission.d.ts +2 -2
- package/dist/middleware/runAuth.d.ts +4 -4
- package/dist/middleware/runAuth.js +39 -4
- package/dist/middleware/sessionAuth.d.ts +3 -3
- package/dist/middleware/tenantAccess.d.ts +2 -2
- package/dist/middleware/tracing.d.ts +3 -3
- package/dist/openapi.d.ts +0 -2
- package/dist/openapi.js +0 -2
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono2 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/evals/routes/datasetTriggers.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono2.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono3 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/evals/routes/index.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono3.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import availableAgents_default from "./routes/availableAgents.js";
|
|
1
2
|
import cliAuth_default from "./routes/cliAuth.js";
|
|
2
3
|
import github_default from "./routes/github.js";
|
|
3
4
|
import routes_default from "./routes/index.js";
|
|
@@ -27,6 +28,7 @@ function createManageRoutes() {
|
|
|
27
28
|
app.route("/tenants/:tenantId", projectFull_default);
|
|
28
29
|
app.route("/oauth", oauth_default);
|
|
29
30
|
app.route("/mcp", mcp_default);
|
|
31
|
+
app.route("/available-agents", availableAgents_default);
|
|
30
32
|
return app;
|
|
31
33
|
}
|
|
32
34
|
const manageRoutes = createManageRoutes();
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { getLogger as getLogger$1 } from "../../../logger.js";
|
|
2
|
+
import { env } from "../../../env.js";
|
|
3
|
+
import manageDbClient_default from "../../../data/db/manageDbClient.js";
|
|
4
|
+
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
5
|
+
import { createApiError, listAgentsAcrossProjectBranches, listUsableProjectIds, verifyTempToken } from "@inkeep/agents-core";
|
|
6
|
+
|
|
7
|
+
//#region src/domains/manage/routes/availableAgents.ts
|
|
8
|
+
const logger = getLogger$1("availableAgents");
|
|
9
|
+
const app = new OpenAPIHono();
|
|
10
|
+
async function tryTempTokenAuth(token) {
|
|
11
|
+
if (!env.INKEEP_AGENTS_TEMP_JWT_PUBLIC_KEY) return null;
|
|
12
|
+
try {
|
|
13
|
+
const payload = await verifyTempToken(Buffer.from(env.INKEEP_AGENTS_TEMP_JWT_PUBLIC_KEY, "base64").toString("utf-8"), token);
|
|
14
|
+
return {
|
|
15
|
+
userId: payload.sub,
|
|
16
|
+
tenantId: payload.tenantId,
|
|
17
|
+
tokenType: "temp-jwt"
|
|
18
|
+
};
|
|
19
|
+
} catch (error) {
|
|
20
|
+
logger.warn({
|
|
21
|
+
token,
|
|
22
|
+
error
|
|
23
|
+
}, "Failed to verify temp token");
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Identify user from any supported token type
|
|
29
|
+
* Add new token types by adding them to this function
|
|
30
|
+
*/
|
|
31
|
+
async function identifyUserFromToken(token) {
|
|
32
|
+
const tempResult = await tryTempTokenAuth(token);
|
|
33
|
+
if (tempResult) return tempResult;
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const AvailableAgentSchema = z.object({
|
|
37
|
+
agentId: z.string(),
|
|
38
|
+
agentName: z.string(),
|
|
39
|
+
projectId: z.string()
|
|
40
|
+
});
|
|
41
|
+
const AvailableAgentsResponseSchema = z.object({ data: z.array(AvailableAgentSchema) });
|
|
42
|
+
app.openapi(createRoute({
|
|
43
|
+
method: "get",
|
|
44
|
+
path: "/",
|
|
45
|
+
summary: "List available agents",
|
|
46
|
+
operationId: "list-available-agents",
|
|
47
|
+
tags: ["Agents"],
|
|
48
|
+
description: "List all agents the user can invoke. Requires a valid JWT token.",
|
|
49
|
+
security: [{ bearerAuth: [] }],
|
|
50
|
+
responses: {
|
|
51
|
+
200: {
|
|
52
|
+
description: "List of available agents",
|
|
53
|
+
content: { "application/json": { schema: AvailableAgentsResponseSchema } }
|
|
54
|
+
},
|
|
55
|
+
401: { description: "Unauthorized - invalid or missing JWT token" },
|
|
56
|
+
500: { description: "Internal server error" }
|
|
57
|
+
}
|
|
58
|
+
}), async (c) => {
|
|
59
|
+
const authHeader = c.req.header("Authorization");
|
|
60
|
+
if (!authHeader?.startsWith("Bearer ")) throw createApiError({
|
|
61
|
+
code: "unauthorized",
|
|
62
|
+
message: "Missing or invalid authorization header. Expected: Bearer <jwt_token>"
|
|
63
|
+
});
|
|
64
|
+
const token = authHeader.substring(7);
|
|
65
|
+
if (!token.startsWith("eyJ")) throw createApiError({
|
|
66
|
+
code: "unauthorized",
|
|
67
|
+
message: "Invalid token format. Expected a JWT token."
|
|
68
|
+
});
|
|
69
|
+
const user = await identifyUserFromToken(token);
|
|
70
|
+
if (!user) {
|
|
71
|
+
logger.warn({}, "Token verification failed - no valid auth method found");
|
|
72
|
+
throw createApiError({
|
|
73
|
+
code: "unauthorized",
|
|
74
|
+
message: "Invalid or expired token"
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const { userId, tenantId } = user;
|
|
78
|
+
const projectIds = await listUsableProjectIds({ userId });
|
|
79
|
+
if (projectIds.length === 0) return c.json({ data: [] });
|
|
80
|
+
const agents = await listAgentsAcrossProjectBranches(manageDbClient_default, {
|
|
81
|
+
tenantId,
|
|
82
|
+
projectIds
|
|
83
|
+
});
|
|
84
|
+
logger.info({
|
|
85
|
+
userId,
|
|
86
|
+
tenantId,
|
|
87
|
+
agentCount: agents.length
|
|
88
|
+
}, "Returning usable agents");
|
|
89
|
+
return c.json({ data: agents });
|
|
90
|
+
});
|
|
91
|
+
var availableAgents_default = app;
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { availableAgents_default as default };
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
2
|
+
import { requireProjectPermission } from "../../../middleware/projectAccess.js";
|
|
2
3
|
import { OpenAPIHono, createRoute } from "@hono/zod-openapi";
|
|
3
4
|
import { BranchListResponseSchema, BranchNameParamsSchema, BranchResponseSchema, CreateBranchRequestSchema, ErrorResponseSchema, TenantProjectAgentParamsSchema, TenantProjectParamsSchema, cascadeDeleteByBranch, commonGetErrorResponses, createApiError, createBranch, deleteBranch, getBranch, listBranches, listBranchesForAgent } from "@inkeep/agents-core";
|
|
4
5
|
|
|
5
6
|
//#region src/domains/manage/routes/branches.ts
|
|
6
7
|
const app = new OpenAPIHono();
|
|
8
|
+
app.use("/", async (c, next) => {
|
|
9
|
+
if (c.req.method === "POST") return requireProjectPermission("edit")(c, next);
|
|
10
|
+
return next();
|
|
11
|
+
});
|
|
12
|
+
app.use("/:branchName", async (c, next) => {
|
|
13
|
+
if (c.req.method === "DELETE") return requireProjectPermission("edit")(c, next);
|
|
14
|
+
return next();
|
|
15
|
+
});
|
|
7
16
|
app.openapi(createRoute({
|
|
8
17
|
method: "get",
|
|
9
18
|
path: "/",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono8 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/conversations.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono8.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../../logger.js";
|
|
2
|
+
import { requireProjectPermission } from "../../../../middleware/projectAccess.js";
|
|
2
3
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
3
4
|
import { DatasetItemApiInsertSchema, DatasetItemApiSelectSchema, DatasetItemApiUpdateSchema, ListResponseSchema, SingleResponseSchema, TenantProjectParamsSchema, commonGetErrorResponses, createApiError, createDatasetItem, createDatasetItems, deleteDatasetItem, generateId, getDatasetItemById, listDatasetItems, updateDatasetItem } from "@inkeep/agents-core";
|
|
4
5
|
|
|
5
6
|
//#region src/domains/manage/routes/evals/datasetItems.ts
|
|
6
7
|
const app = new OpenAPIHono();
|
|
7
8
|
const logger = getLogger$1("datasetItems");
|
|
9
|
+
app.use("/:datasetId/items", async (c, next) => {
|
|
10
|
+
if (c.req.method === "POST") return requireProjectPermission("edit")(c, next);
|
|
11
|
+
return next();
|
|
12
|
+
});
|
|
13
|
+
app.use("/:datasetId/items/bulk", async (c, next) => {
|
|
14
|
+
if (c.req.method === "POST") return requireProjectPermission("edit")(c, next);
|
|
15
|
+
return next();
|
|
16
|
+
});
|
|
17
|
+
app.use("/:datasetId/items/:itemId", async (c, next) => {
|
|
18
|
+
if (["PATCH", "DELETE"].includes(c.req.method)) return requireProjectPermission("edit")(c, next);
|
|
19
|
+
return next();
|
|
20
|
+
});
|
|
8
21
|
app.openapi(createRoute({
|
|
9
22
|
method: "get",
|
|
10
23
|
path: "/{datasetId}",
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../../logger.js";
|
|
2
|
+
import { requireProjectPermission } from "../../../../middleware/projectAccess.js";
|
|
2
3
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
3
4
|
import { DatasetApiInsertSchema, DatasetApiSelectSchema, DatasetApiUpdateSchema, ListResponseSchema, SingleResponseSchema, TenantProjectParamsSchema, commonGetErrorResponses, createApiError, createDataset, deleteDataset, generateId, getDatasetById, listDatasets, updateDataset } from "@inkeep/agents-core";
|
|
4
5
|
|
|
5
6
|
//#region src/domains/manage/routes/evals/datasets.ts
|
|
6
7
|
const app = new OpenAPIHono();
|
|
7
8
|
const logger = getLogger$1("datasets");
|
|
9
|
+
app.use("/", async (c, next) => {
|
|
10
|
+
if (c.req.method === "POST") return requireProjectPermission("edit")(c, next);
|
|
11
|
+
return next();
|
|
12
|
+
});
|
|
13
|
+
app.use("/:datasetId", async (c, next) => {
|
|
14
|
+
if (["PATCH", "DELETE"].includes(c.req.method)) return requireProjectPermission("edit")(c, next);
|
|
15
|
+
return next();
|
|
16
|
+
});
|
|
8
17
|
app.openapi(createRoute({
|
|
9
18
|
method: "get",
|
|
10
19
|
path: "/",
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../../logger.js";
|
|
2
|
+
import { requireProjectPermission } from "../../../../middleware/projectAccess.js";
|
|
2
3
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
3
4
|
import { TenantProjectParamsSchema, commonGetErrorResponses, createApiError, createEvaluationJobConfigEvaluatorRelation, deleteEvaluationJobConfigEvaluatorRelation, generateId, getEvaluationJobConfigEvaluatorRelations } from "@inkeep/agents-core";
|
|
4
5
|
|
|
5
6
|
//#region src/domains/manage/routes/evals/evaluationJobConfigEvaluatorRelations.ts
|
|
6
7
|
const app = new OpenAPIHono();
|
|
7
8
|
const logger = getLogger$1("evaluationJobConfigEvaluatorRelations");
|
|
9
|
+
app.use("/:configId/evaluators/:evaluatorId", async (c, next) => {
|
|
10
|
+
if (["POST", "DELETE"].includes(c.req.method)) return requireProjectPermission("edit")(c, next);
|
|
11
|
+
return next();
|
|
12
|
+
});
|
|
8
13
|
app.openapi(createRoute({
|
|
9
14
|
method: "get",
|
|
10
15
|
path: "/{configId}/evaluators",
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../../logger.js";
|
|
2
2
|
import runDbClient_default from "../../../../data/db/runDbClient.js";
|
|
3
3
|
import { queueEvaluationJobConversations } from "../../../evals/services/evaluationJob.js";
|
|
4
|
+
import { requireProjectPermission } from "../../../../middleware/projectAccess.js";
|
|
4
5
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
5
6
|
import { EvaluationJobConfigApiInsertSchema, EvaluationJobConfigApiSelectSchema, EvaluationResultApiSelectSchema, ListResponseSchema, SingleResponseSchema, TenantProjectParamsSchema, commonGetErrorResponses, createApiError, createEvaluationJobConfig, createEvaluationJobConfigEvaluatorRelation, deleteEvaluationJobConfig, generateId, getConversation, getEvaluationJobConfigById, getMessagesByConversation, listEvaluationJobConfigs, listEvaluationResultsByRun, listEvaluationRuns } from "@inkeep/agents-core";
|
|
6
7
|
|
|
7
8
|
//#region src/domains/manage/routes/evals/evaluationJobConfigs.ts
|
|
8
9
|
const app = new OpenAPIHono();
|
|
9
10
|
const logger = getLogger$1("evaluationJobConfigs");
|
|
11
|
+
app.use("/", async (c, next) => {
|
|
12
|
+
if (c.req.method === "POST") return requireProjectPermission("edit")(c, next);
|
|
13
|
+
return next();
|
|
14
|
+
});
|
|
15
|
+
app.use("/:configId", async (c, next) => {
|
|
16
|
+
if (c.req.method === "DELETE") return requireProjectPermission("edit")(c, next);
|
|
17
|
+
return next();
|
|
18
|
+
});
|
|
10
19
|
/**
|
|
11
20
|
* Extract plain filter criteria from a potential Filter wrapper.
|
|
12
21
|
* Returns null if the filter is a complex and/or combinator.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { ManageAppVariables } from "../../../../types/app.js";
|
|
1
2
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as hono18 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/evals/evaluationResults.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<{
|
|
6
|
+
Variables: ManageAppVariables;
|
|
7
|
+
}, {}, "/">;
|
|
6
8
|
//#endregion
|
|
7
9
|
export { app as default };
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../../logger.js";
|
|
2
2
|
import runDbClient_default from "../../../../data/db/runDbClient.js";
|
|
3
|
+
import { requireProjectPermission } from "../../../../middleware/projectAccess.js";
|
|
3
4
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
4
5
|
import { EvaluationResultApiInsertSchema, EvaluationResultApiSelectSchema, EvaluationResultApiUpdateSchema, SingleResponseSchema, TenantProjectParamsSchema, commonGetErrorResponses, createApiError, createEvaluationResult, deleteEvaluationResult, generateId, getEvaluationResultById, updateEvaluationResult } from "@inkeep/agents-core";
|
|
5
6
|
|
|
6
7
|
//#region src/domains/manage/routes/evals/evaluationResults.ts
|
|
7
8
|
const app = new OpenAPIHono();
|
|
8
9
|
const logger = getLogger$1("evaluationResults");
|
|
10
|
+
app.use("/", async (c, next) => {
|
|
11
|
+
if (c.req.method === "POST") return requireProjectPermission("edit")(c, next);
|
|
12
|
+
return next();
|
|
13
|
+
});
|
|
14
|
+
app.use("/:resultId", async (c, next) => {
|
|
15
|
+
if (["PATCH", "DELETE"].includes(c.req.method)) return requireProjectPermission("edit")(c, next);
|
|
16
|
+
return next();
|
|
17
|
+
});
|
|
9
18
|
app.openapi(createRoute({
|
|
10
19
|
method: "get",
|
|
11
20
|
path: "/{resultId}",
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../../logger.js";
|
|
2
2
|
import runDbClient_default from "../../../../data/db/runDbClient.js";
|
|
3
|
+
import { requireProjectPermission } from "../../../../middleware/projectAccess.js";
|
|
3
4
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
4
5
|
import { EvaluationResultApiSelectSchema, EvaluationRunConfigApiInsertSchema, EvaluationRunConfigApiUpdateSchema, EvaluationRunConfigWithSuiteConfigsApiSelectSchema, ListResponseSchema, SingleResponseSchema, TenantProjectParamsSchema, commonGetErrorResponses, createApiError, createEvaluationRunConfig, createEvaluationRunConfigEvaluationSuiteConfigRelation, deleteEvaluationRunConfig, deleteEvaluationRunConfigEvaluationSuiteConfigRelation, generateId, getConversation, getEvaluationRunConfigById, getEvaluationRunConfigEvaluationSuiteConfigRelations, getMessagesByConversation, listEvaluationResultsByRun, listEvaluationRunConfigsWithSuiteConfigs, listEvaluationRuns, updateEvaluationRunConfig } from "@inkeep/agents-core";
|
|
5
6
|
|
|
6
7
|
//#region src/domains/manage/routes/evals/evaluationRunConfigs.ts
|
|
7
8
|
const app = new OpenAPIHono();
|
|
8
9
|
const logger = getLogger$1("evaluationRunConfigs");
|
|
10
|
+
app.use("/", async (c, next) => {
|
|
11
|
+
if (c.req.method === "POST") return requireProjectPermission("edit")(c, next);
|
|
12
|
+
return next();
|
|
13
|
+
});
|
|
14
|
+
app.use("/:configId", async (c, next) => {
|
|
15
|
+
if (["PATCH", "DELETE"].includes(c.req.method)) return requireProjectPermission("edit")(c, next);
|
|
16
|
+
return next();
|
|
17
|
+
});
|
|
9
18
|
app.openapi(createRoute({
|
|
10
19
|
method: "get",
|
|
11
20
|
path: "/",
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../../logger.js";
|
|
2
|
+
import { requireProjectPermission } from "../../../../middleware/projectAccess.js";
|
|
2
3
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
3
4
|
import { TenantProjectParamsSchema, commonGetErrorResponses, createApiError, createEvaluationSuiteConfigEvaluatorRelation, deleteEvaluationSuiteConfigEvaluatorRelation, generateId, getEvaluationSuiteConfigEvaluatorRelations } from "@inkeep/agents-core";
|
|
4
5
|
|
|
5
6
|
//#region src/domains/manage/routes/evals/evaluationSuiteConfigEvaluatorRelations.ts
|
|
6
7
|
const app = new OpenAPIHono();
|
|
7
8
|
const logger = getLogger$1("evaluationSuiteConfigEvaluatorRelations");
|
|
9
|
+
app.use("/:configId/evaluators/:evaluatorId", async (c, next) => {
|
|
10
|
+
if (["POST", "DELETE"].includes(c.req.method)) return requireProjectPermission("edit")(c, next);
|
|
11
|
+
return next();
|
|
12
|
+
});
|
|
8
13
|
app.openapi(createRoute({
|
|
9
14
|
method: "get",
|
|
10
15
|
path: "/{configId}/evaluators",
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../../logger.js";
|
|
2
|
+
import { requireProjectPermission } from "../../../../middleware/projectAccess.js";
|
|
2
3
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
3
4
|
import { EvaluationSuiteConfigApiInsertSchema, EvaluationSuiteConfigApiSelectSchema, EvaluationSuiteConfigApiUpdateSchema, ListResponseSchema, SingleResponseSchema, TenantProjectParamsSchema, commonGetErrorResponses, createApiError, createEvaluationSuiteConfig, createEvaluationSuiteConfigEvaluatorRelation, deleteEvaluationSuiteConfig, generateId, getEvaluationSuiteConfigById, listEvaluationSuiteConfigs, updateEvaluationSuiteConfig } from "@inkeep/agents-core";
|
|
4
5
|
|
|
5
6
|
//#region src/domains/manage/routes/evals/evaluationSuiteConfigs.ts
|
|
6
7
|
const app = new OpenAPIHono();
|
|
7
8
|
const logger = getLogger$1("evaluationSuiteConfigs");
|
|
9
|
+
app.use("/", async (c, next) => {
|
|
10
|
+
if (c.req.method === "POST") return requireProjectPermission("edit")(c, next);
|
|
11
|
+
return next();
|
|
12
|
+
});
|
|
13
|
+
app.use("/:configId", async (c, next) => {
|
|
14
|
+
if (["PATCH", "DELETE"].includes(c.req.method)) return requireProjectPermission("edit")(c, next);
|
|
15
|
+
return next();
|
|
16
|
+
});
|
|
8
17
|
app.openapi(createRoute({
|
|
9
18
|
method: "get",
|
|
10
19
|
path: "/",
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../../logger.js";
|
|
2
|
+
import { requireProjectPermission } from "../../../../middleware/projectAccess.js";
|
|
2
3
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
3
4
|
import { EvaluatorApiInsertSchema, EvaluatorApiSelectSchema, EvaluatorApiUpdateSchema, ListResponseSchema, SingleResponseSchema, TenantProjectParamsSchema, commonGetErrorResponses, createApiError, createEvaluator, deleteEvaluator, generateId, getEvaluatorById, getEvaluatorsByIds, listEvaluators, updateEvaluator } from "@inkeep/agents-core";
|
|
4
5
|
|
|
5
6
|
//#region src/domains/manage/routes/evals/evaluators.ts
|
|
6
7
|
const app = new OpenAPIHono();
|
|
7
8
|
const logger = getLogger$1("evaluators");
|
|
9
|
+
app.use("/", async (c, next) => {
|
|
10
|
+
if (c.req.method === "POST") return requireProjectPermission("edit")(c, next);
|
|
11
|
+
return next();
|
|
12
|
+
});
|
|
13
|
+
app.use("/:evaluatorId", async (c, next) => {
|
|
14
|
+
if (["PATCH", "DELETE"].includes(c.req.method)) return requireProjectPermission("edit")(c, next);
|
|
15
|
+
return next();
|
|
16
|
+
});
|
|
8
17
|
app.openapi(createRoute({
|
|
9
18
|
method: "get",
|
|
10
19
|
path: "/",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono18 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/index.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono18.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import * as hono_types7 from "hono/types";
|
|
3
4
|
|
|
4
5
|
//#region src/domains/manage/routes/invitations.d.ts
|
|
5
|
-
declare const invitationsRoutes:
|
|
6
|
+
declare const invitationsRoutes: Hono<{
|
|
6
7
|
Variables: ManageAppVariables;
|
|
7
|
-
},
|
|
8
|
+
}, hono_types7.BlankSchema, "/">;
|
|
8
9
|
//#endregion
|
|
9
10
|
export { invitationsRoutes as default };
|
|
@@ -1,34 +1,22 @@
|
|
|
1
1
|
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
2
|
-
import {
|
|
3
|
-
import { getPendingInvitationsByEmail } from "@inkeep/agents-core";
|
|
2
|
+
import { sessionAuth } from "../../../middleware/sessionAuth.js";
|
|
3
|
+
import { createApiError, getPendingInvitationsByEmail } from "@inkeep/agents-core";
|
|
4
|
+
import { Hono } from "hono";
|
|
4
5
|
|
|
5
6
|
//#region src/domains/manage/routes/invitations.ts
|
|
6
|
-
const invitationsRoutes = new
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
email
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
invitationsRoutes.openapi(createRoute({
|
|
20
|
-
method: "get",
|
|
21
|
-
path: "/pending",
|
|
22
|
-
tags: ["Invitations"],
|
|
23
|
-
summary: "Get pending invitations",
|
|
24
|
-
description: "Get all pending (non-expired) invitations for a given email address",
|
|
25
|
-
request: { query: z.object({ email: z.email().describe("Email address to check for invitations") }) },
|
|
26
|
-
responses: { 200: {
|
|
27
|
-
description: "List of pending invitations",
|
|
28
|
-
content: { "application/json": { schema: PendingInvitationsResponseSchema } }
|
|
29
|
-
} }
|
|
30
|
-
}), async (c) => {
|
|
31
|
-
const { email } = c.req.valid("query");
|
|
7
|
+
const invitationsRoutes = new Hono();
|
|
8
|
+
invitationsRoutes.use("*", sessionAuth());
|
|
9
|
+
invitationsRoutes.get("/pending", async (c) => {
|
|
10
|
+
const email = c.req.query("email");
|
|
11
|
+
const authenticatedEmail = c.get("userEmail");
|
|
12
|
+
if (!email) throw createApiError({
|
|
13
|
+
code: "bad_request",
|
|
14
|
+
message: "Email parameter is required"
|
|
15
|
+
});
|
|
16
|
+
if (email !== authenticatedEmail) throw createApiError({
|
|
17
|
+
code: "forbidden",
|
|
18
|
+
message: "Cannot access invitations for another email"
|
|
19
|
+
});
|
|
32
20
|
const response = (await getPendingInvitationsByEmail(runDbClient_default)(email)).map((inv) => ({
|
|
33
21
|
...inv,
|
|
34
22
|
expiresAt: inv.expiresAt instanceof Date ? inv.expiresAt.getTime() : inv.expiresAt
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types8 from "hono/types";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/mcp.d.ts
|
|
5
|
-
declare const app: Hono<
|
|
5
|
+
declare const app: Hono<hono_types8.BlankEnv, hono_types8.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
|
-
import * as
|
|
3
|
+
import * as hono_types10 from "hono/types";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/manage/routes/signoz.d.ts
|
|
6
6
|
declare const app: Hono<{
|
|
7
7
|
Variables: ManageAppVariables;
|
|
8
|
-
},
|
|
8
|
+
}, hono_types10.BlankSchema, "/">;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { app as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../logger.js";
|
|
2
2
|
import { env } from "../../../env.js";
|
|
3
3
|
import { enforceSecurityFilters } from "../../../utils/signozHelpers.js";
|
|
4
|
-
import {
|
|
4
|
+
import { canViewProject, createApiError } from "@inkeep/agents-core";
|
|
5
5
|
import { Hono } from "hono";
|
|
6
6
|
import axios from "axios";
|
|
7
7
|
|
|
@@ -12,10 +12,12 @@ app.post("/query", async (c) => {
|
|
|
12
12
|
let payload = await c.req.json();
|
|
13
13
|
const requestedProjectId = payload.projectId;
|
|
14
14
|
const tenantId = c.get("tenantId");
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const userId = c.get("userId");
|
|
16
|
+
const tenantRole = c.get("tenantRole");
|
|
17
|
+
if (!userId || !tenantId) throw createApiError({
|
|
17
18
|
code: "unauthorized",
|
|
18
|
-
message: "
|
|
19
|
+
message: "User or organization context not found",
|
|
20
|
+
instance: c.req.path
|
|
19
21
|
});
|
|
20
22
|
logger.debug({
|
|
21
23
|
tenantId,
|
|
@@ -23,18 +25,22 @@ app.post("/query", async (c) => {
|
|
|
23
25
|
hasProjectId: !!requestedProjectId
|
|
24
26
|
}, "Processing SigNoz query request");
|
|
25
27
|
if (requestedProjectId) {
|
|
26
|
-
if (!
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
if (!(userId === "system" || userId?.startsWith("apikey:"))) {
|
|
29
|
+
if (!await canViewProject({
|
|
30
|
+
userId,
|
|
31
|
+
projectId: requestedProjectId,
|
|
32
|
+
orgRole: tenantRole
|
|
33
|
+
})) {
|
|
34
|
+
logger.warn({
|
|
35
|
+
tenantId,
|
|
36
|
+
projectId: requestedProjectId,
|
|
37
|
+
userId
|
|
38
|
+
}, "Project not found or access denied");
|
|
39
|
+
return c.json({
|
|
40
|
+
error: "Forbidden",
|
|
41
|
+
message: "You do not have access to this project"
|
|
42
|
+
}, 403);
|
|
43
|
+
}
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
payload = enforceSecurityFilters(payload, tenantId, requestedProjectId);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import * as hono_types13 from "hono/types";
|
|
3
4
|
|
|
4
5
|
//#region src/domains/manage/routes/userOrganizations.d.ts
|
|
5
|
-
declare const userOrganizationsRoutes:
|
|
6
|
+
declare const userOrganizationsRoutes: Hono<{
|
|
6
7
|
Variables: ManageAppVariables;
|
|
7
|
-
},
|
|
8
|
+
}, hono_types13.BlankSchema, "/">;
|
|
8
9
|
//#endregion
|
|
9
10
|
export { userOrganizationsRoutes as default };
|
|
@@ -1,57 +1,28 @@
|
|
|
1
1
|
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { sessionAuth } from "../../../middleware/sessionAuth.js";
|
|
3
|
+
import { createApiError, getUserOrganizationsFromDb } from "@inkeep/agents-core";
|
|
4
|
+
import { Hono } from "hono";
|
|
5
5
|
|
|
6
6
|
//#region src/domains/manage/routes/userOrganizations.ts
|
|
7
|
-
const userOrganizationsRoutes = new
|
|
8
|
-
userOrganizationsRoutes.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})
|
|
20
|
-
const { userId } = c.req.valid("param");
|
|
7
|
+
const userOrganizationsRoutes = new Hono();
|
|
8
|
+
userOrganizationsRoutes.use("*", sessionAuth());
|
|
9
|
+
userOrganizationsRoutes.get("/", async (c) => {
|
|
10
|
+
const userId = c.req.param("userId");
|
|
11
|
+
const authenticatedUserId = c.get("userId");
|
|
12
|
+
if (!userId) throw createApiError({
|
|
13
|
+
code: "bad_request",
|
|
14
|
+
message: "User ID is required"
|
|
15
|
+
});
|
|
16
|
+
if (userId !== authenticatedUserId) throw createApiError({
|
|
17
|
+
code: "forbidden",
|
|
18
|
+
message: "Cannot access another user's organizations"
|
|
19
|
+
});
|
|
21
20
|
const userOrganizations = (await getUserOrganizationsFromDb(runDbClient_default)(userId)).map((org) => ({
|
|
22
21
|
...org,
|
|
23
22
|
createdAt: org.createdAt.toISOString()
|
|
24
23
|
}));
|
|
25
24
|
return c.json(userOrganizations);
|
|
26
25
|
});
|
|
27
|
-
userOrganizationsRoutes.openapi(createRoute({
|
|
28
|
-
method: "post",
|
|
29
|
-
path: "/",
|
|
30
|
-
tags: ["User Organizations"],
|
|
31
|
-
summary: "Add user to organization",
|
|
32
|
-
description: "Associate a user with an organization",
|
|
33
|
-
request: {
|
|
34
|
-
params: z.object({ userId: z.string().describe("User ID") }),
|
|
35
|
-
body: { content: { "application/json": { schema: AddUserToOrganizationRequestSchema } } }
|
|
36
|
-
},
|
|
37
|
-
responses: { 201: {
|
|
38
|
-
description: "User added to organization",
|
|
39
|
-
content: { "application/json": { schema: AddUserToOrganizationResponseSchema } }
|
|
40
|
-
} }
|
|
41
|
-
}), async (c) => {
|
|
42
|
-
const { userId } = c.req.valid("param");
|
|
43
|
-
const { organizationId, role } = c.req.valid("json");
|
|
44
|
-
await addUserToOrganization(runDbClient_default)({
|
|
45
|
-
userId,
|
|
46
|
-
organizationId,
|
|
47
|
-
role
|
|
48
|
-
});
|
|
49
|
-
return c.json({
|
|
50
|
-
organizationId,
|
|
51
|
-
role,
|
|
52
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
53
|
-
}, 201);
|
|
54
|
-
});
|
|
55
26
|
var userOrganizations_default = userOrganizationsRoutes;
|
|
56
27
|
|
|
57
28
|
//#endregion
|