@inkeep/agents-api 0.0.0-dev-20260127201912 → 0.0.0-dev-20260127205750
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/createApp.d.ts +2 -2
- package/dist/data/db/runDbClient.d.ts +2 -2
- package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
- package/dist/domains/evals/routes/index.d.ts +2 -2
- package/dist/domains/evals/workflow/routes.d.ts +2 -2
- package/dist/domains/github/index.d.ts +3 -3
- package/dist/domains/github/routes/tokenExchange.d.ts +2 -2
- package/dist/domains/manage/routes/conversations.d.ts +2 -2
- package/dist/domains/manage/routes/index.d.ts +2 -2
- package/dist/domains/manage/routes/mcp.d.ts +2 -2
- package/dist/domains/mcp/routes/mcp.d.ts +2 -2
- package/dist/domains/run/agents/relationTools.d.ts +2 -2
- package/dist/factory.d.ts +262 -262
- package/dist/index.d.ts +261 -261
- 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/requirePermission.d.ts +2 -2
- package/dist/middleware/runAuth.d.ts +4 -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/package.json +5 -10
- package/dist/domains/evals/services/startEvaluation.d.ts +0 -19
- package/dist/domains/evals/services/startEvaluation.js +0 -18
- package/dist/domains/index.d.ts +0 -5
- package/dist/domains/index.js +0 -6
- package/dist/domains/manage/routes/agentToolRelations.d.ts +0 -9
- package/dist/domains/manage/routes/agentToolRelations.js +0 -292
- package/dist/domains/run/agents/ModelFactory.d.ts +0 -63
- package/dist/domains/run/agents/ModelFactory.js +0 -194
- package/dist/domains/run/data/agent.d.ts +0 -7
- package/dist/domains/run/data/agent.js +0 -67
- package/dist/domains/run/services/evaluationRunConfigMatcher.d.ts +0 -4
- package/dist/domains/run/services/evaluationRunConfigMatcher.js +0 -7
- package/dist/domains/run/utils/cleanup.d.ts +0 -21
- package/dist/domains/run/utils/cleanup.js +0 -59
- package/dist/utils/tempApiKeys.d.ts +0 -17
- package/dist/utils/tempApiKeys.js +0 -26
- package/dist/utils/workflowApiHelpers.d.ts +0 -1
- package/dist/utils/workflowApiHelpers.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono1 from "hono";
|
|
2
2
|
import { BaseExecutionContext } from "@inkeep/agents-core";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/evalsAuth.d.ts
|
|
@@ -7,7 +7,7 @@ import { BaseExecutionContext } from "@inkeep/agents-core";
|
|
|
7
7
|
* Middleware to authenticate API requests using Bearer token authentication
|
|
8
8
|
* First checks if token matches INKEEP_AGENTS_EVAL_API_BYPASS_SECRET,
|
|
9
9
|
*/
|
|
10
|
-
declare const evalApiKeyAuth: () =>
|
|
10
|
+
declare const evalApiKeyAuth: () => hono1.MiddlewareHandler<{
|
|
11
11
|
Variables: {
|
|
12
12
|
executionContext: BaseExecutionContext;
|
|
13
13
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono17 from "hono";
|
|
2
2
|
import { BaseExecutionContext } from "@inkeep/agents-core";
|
|
3
3
|
import { createAuth } from "@inkeep/agents-core/auth";
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@ import { createAuth } from "@inkeep/agents-core/auth";
|
|
|
12
12
|
* 3. Database API key
|
|
13
13
|
* 4. Internal service token
|
|
14
14
|
*/
|
|
15
|
-
declare const manageApiKeyAuth: () =>
|
|
15
|
+
declare const manageApiKeyAuth: () => hono17.MiddlewareHandler<{
|
|
16
16
|
Variables: {
|
|
17
17
|
executionContext: BaseExecutionContext;
|
|
18
18
|
userId?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../types/app.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono2 from "hono";
|
|
3
3
|
import { ProjectPermissionLevel } from "@inkeep/agents-core";
|
|
4
4
|
|
|
5
5
|
//#region src/middleware/projectAccess.d.ts
|
|
@@ -19,6 +19,6 @@ declare const requireProjectPermission: <Env$1 extends {
|
|
|
19
19
|
Variables: ManageAppVariables;
|
|
20
20
|
} = {
|
|
21
21
|
Variables: ManageAppVariables;
|
|
22
|
-
}>(permission?: ProjectPermissionLevel) =>
|
|
22
|
+
}>(permission?: ProjectPermissionLevel) => hono2.MiddlewareHandler<Env$1, string, {}, Response>;
|
|
23
23
|
//#endregion
|
|
24
24
|
export { requireProjectPermission };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../types/app.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono0 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/requirePermission.d.ts
|
|
5
5
|
type Permission = {
|
|
@@ -9,6 +9,6 @@ declare const requirePermission: <Env$1 extends {
|
|
|
9
9
|
Variables: ManageAppVariables;
|
|
10
10
|
} = {
|
|
11
11
|
Variables: ManageAppVariables;
|
|
12
|
-
}>(permissions: Permission) =>
|
|
12
|
+
}>(permissions: Permission) => hono0.MiddlewareHandler<Env$1, string, {}, Response>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { requirePermission };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono5 from "hono";
|
|
2
2
|
import { BaseExecutionContext } from "@inkeep/agents-core";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/runAuth.d.ts
|
|
5
|
-
declare const runApiKeyAuth: () =>
|
|
5
|
+
declare const runApiKeyAuth: () => hono5.MiddlewareHandler<{
|
|
6
6
|
Variables: {
|
|
7
7
|
executionContext: BaseExecutionContext;
|
|
8
8
|
};
|
|
@@ -11,7 +11,7 @@ declare const runApiKeyAuth: () => hono14.MiddlewareHandler<{
|
|
|
11
11
|
* Creates a middleware that applies API key authentication except for specified route patterns
|
|
12
12
|
* @param skipRouteCheck - Function that returns true if the route should skip authentication
|
|
13
13
|
*/
|
|
14
|
-
declare const runApiKeyAuthExcept: (skipRouteCheck: (path: string) => boolean) =>
|
|
14
|
+
declare const runApiKeyAuthExcept: (skipRouteCheck: (path: string) => boolean) => hono5.MiddlewareHandler<{
|
|
15
15
|
Variables: {
|
|
16
16
|
executionContext: BaseExecutionContext;
|
|
17
17
|
};
|
|
@@ -20,7 +20,7 @@ declare const runApiKeyAuthExcept: (skipRouteCheck: (path: string) => boolean) =
|
|
|
20
20
|
* Helper middleware for endpoints that optionally support API key authentication
|
|
21
21
|
* If no auth header is present, it continues without setting the executionContext
|
|
22
22
|
*/
|
|
23
|
-
declare const runOptionalAuth: () =>
|
|
23
|
+
declare const runOptionalAuth: () => hono5.MiddlewareHandler<{
|
|
24
24
|
Variables: {
|
|
25
25
|
executionContext?: BaseExecutionContext;
|
|
26
26
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono8 from "hono";
|
|
2
2
|
|
|
3
3
|
//#region src/middleware/sessionAuth.d.ts
|
|
4
4
|
|
|
@@ -7,11 +7,11 @@ import * as hono0 from "hono";
|
|
|
7
7
|
* Requires that a user has already been authenticated via Better Auth session.
|
|
8
8
|
* Used primarily for manage routes that require an active user session.
|
|
9
9
|
*/
|
|
10
|
-
declare const sessionAuth: () =>
|
|
10
|
+
declare const sessionAuth: () => hono8.MiddlewareHandler<any, string, {}, Response>;
|
|
11
11
|
/**
|
|
12
12
|
* Global session middleware - sets user and session in context for all routes
|
|
13
13
|
* Used for all routes that require an active user session.
|
|
14
14
|
*/
|
|
15
|
-
declare const sessionContext: () =>
|
|
15
|
+
declare const sessionContext: () => hono8.MiddlewareHandler<any, string, {}, Response>;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { sessionAuth, sessionContext };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono10 from "hono";
|
|
2
2
|
|
|
3
3
|
//#region src/middleware/tenantAccess.d.ts
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@ import * as hono2 from "hono";
|
|
|
11
11
|
* - API key user: Access only to the tenant associated with the API key
|
|
12
12
|
* - Session user: Access based on organization membership
|
|
13
13
|
*/
|
|
14
|
-
declare const requireTenantAccess: () =>
|
|
14
|
+
declare const requireTenantAccess: () => hono10.MiddlewareHandler<{
|
|
15
15
|
Variables: {
|
|
16
16
|
userId: string;
|
|
17
17
|
tenantId: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono11 from "hono";
|
|
2
2
|
|
|
3
3
|
//#region src/middleware/tracing.d.ts
|
|
4
|
-
declare const otelBaggageMiddleware: () =>
|
|
5
|
-
declare const executionBaggageMiddleware: () =>
|
|
4
|
+
declare const otelBaggageMiddleware: () => hono11.MiddlewareHandler<any, string, {}, Response>;
|
|
5
|
+
declare const executionBaggageMiddleware: () => hono11.MiddlewareHandler<any, string, {}, Response>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { executionBaggageMiddleware, otelBaggageMiddleware };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-api",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20260127205750",
|
|
4
4
|
"description": "Unified Inkeep Agents API - combines management, runtime, and evaluation capabilities",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -32,17 +32,11 @@
|
|
|
32
32
|
"type": "module",
|
|
33
33
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@ai-sdk/anthropic": "3.0.7",
|
|
36
|
-
"@ai-sdk/gateway": "3.0.9",
|
|
37
35
|
"@ai-sdk/google": "3.0.4",
|
|
38
|
-
"@ai-sdk/openai": "3.0.7",
|
|
39
|
-
"@ai-sdk/openai-compatible": "2.0.4",
|
|
40
36
|
"@hono/mcp": "^0.1.5",
|
|
41
|
-
"@hono/otel": "^0.4.0",
|
|
42
37
|
"@hono/swagger-ui": "^0.5.1",
|
|
43
38
|
"@hono/zod-openapi": "^1.1.5",
|
|
44
39
|
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
45
|
-
"@openrouter/ai-sdk-provider": "^1.2.0",
|
|
46
40
|
"@opentelemetry/api": "^1.9.0",
|
|
47
41
|
"@opentelemetry/auto-instrumentations-node": "^0.64.1",
|
|
48
42
|
"@opentelemetry/baggage-span-processor": "^0.4.0",
|
|
@@ -72,9 +66,9 @@
|
|
|
72
66
|
"openid-client": "^6.8.1",
|
|
73
67
|
"pg": "^8.16.3",
|
|
74
68
|
"workflow": "4.0.1-beta.33",
|
|
75
|
-
"@inkeep/agents-core": "^0.0.0-dev-
|
|
76
|
-
"@inkeep/agents-manage-mcp": "^0.0.0-dev-
|
|
77
|
-
"@inkeep/agents-mcp": "^0.0.0-dev-
|
|
69
|
+
"@inkeep/agents-core": "^0.0.0-dev-20260127205750",
|
|
70
|
+
"@inkeep/agents-manage-mcp": "^0.0.0-dev-20260127205750",
|
|
71
|
+
"@inkeep/agents-mcp": "^0.0.0-dev-20260127205750"
|
|
78
72
|
},
|
|
79
73
|
"peerDependencies": {
|
|
80
74
|
"@hono/zod-openapi": "^1.1.5",
|
|
@@ -110,6 +104,7 @@
|
|
|
110
104
|
"directory": "agents-api"
|
|
111
105
|
},
|
|
112
106
|
"scripts": {
|
|
107
|
+
"knip": "knip --directory .. --workspace agents-api --config agents-api/knip.config.ts --dependencies --files",
|
|
113
108
|
"workflow:build": "tsx src/domains/evals/scripts/build-workflow.ts",
|
|
114
109
|
"well-known:copy": "tsx scripts/copy-well-known.ts",
|
|
115
110
|
"dev": "pnpm workflow:build && vite",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//#region src/domains/evals/services/startEvaluation.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Service to start evaluation workflows.
|
|
4
|
-
* This encapsulates the workflow logic so consumers don't need to import workflow packages.
|
|
5
|
-
*/
|
|
6
|
-
interface StartEvaluationParams {
|
|
7
|
-
tenantId: string;
|
|
8
|
-
projectId: string;
|
|
9
|
-
conversationId: string;
|
|
10
|
-
evaluatorIds: string[];
|
|
11
|
-
evaluationRunId: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Start an evaluation workflow for a conversation.
|
|
15
|
-
* This is a convenience wrapper that handles workflow initialization internally.
|
|
16
|
-
*/
|
|
17
|
-
declare function startConversationEvaluation(params: StartEvaluationParams): Promise<void>;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { StartEvaluationParams, startConversationEvaluation };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { evaluateConversationWorkflow } from "../workflow/functions/evaluateConversation.js";
|
|
2
|
-
import { start } from "workflow/api";
|
|
3
|
-
|
|
4
|
-
//#region src/domains/evals/services/startEvaluation.ts
|
|
5
|
-
/**
|
|
6
|
-
* Service to start evaluation workflows.
|
|
7
|
-
* This encapsulates the workflow logic so consumers don't need to import workflow packages.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Start an evaluation workflow for a conversation.
|
|
11
|
-
* This is a convenience wrapper that handles workflow initialization internally.
|
|
12
|
-
*/
|
|
13
|
-
async function startConversationEvaluation(params) {
|
|
14
|
-
await start(evaluateConversationWorkflow, [params]);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
export { startConversationEvaluation };
|
package/dist/domains/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createEvalRoutes, evalRoutes } from "./evals/index.js";
|
|
2
|
-
import { createGithubRoutes, githubRoutes } from "./github/index.js";
|
|
3
|
-
import { createManageRoutes, manageRoutes } from "./manage/index.js";
|
|
4
|
-
import { createRunRoutes, runRoutes } from "./run/index.js";
|
|
5
|
-
export { createEvalRoutes, createGithubRoutes, createManageRoutes, createRunRoutes, evalRoutes, githubRoutes, manageRoutes, runRoutes };
|
package/dist/domains/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createEvalRoutes, evalRoutes } from "./evals/index.js";
|
|
2
|
-
import { createGithubRoutes, githubRoutes } from "./github/index.js";
|
|
3
|
-
import { createManageRoutes, manageRoutes } from "./manage/index.js";
|
|
4
|
-
import { createRunRoutes, runRoutes } from "./run/index.js";
|
|
5
|
-
|
|
6
|
-
export { createEvalRoutes, createGithubRoutes, createManageRoutes, createRunRoutes, evalRoutes, githubRoutes, manageRoutes, runRoutes };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
|
-
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
3
|
-
|
|
4
|
-
//#region src/domains/manage/routes/agentToolRelations.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<{
|
|
6
|
-
Variables: ManageAppVariables;
|
|
7
|
-
}, {}, "/">;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { app as default };
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import { requireProjectPermission } from "../../../middleware/projectAccess.js";
|
|
2
|
-
import { speakeasyOffsetLimitPagination } from "../../../utils/speakeasy.js";
|
|
3
|
-
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
4
|
-
import { ErrorResponseSchema, PaginationQueryParamsSchema, SubAgentToolRelationApiInsertSchema, SubAgentToolRelationApiUpdateSchema, SubAgentToolRelationListResponse, SubAgentToolRelationResponse, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, commonGetErrorResponses, createAgentToolRelation, createApiError, deleteAgentToolRelation, getAgentToolRelationByAgent, getAgentToolRelationById, getAgentToolRelationByTool, getAgentsForTool, listAgentToolRelations, updateAgentToolRelation } from "@inkeep/agents-core";
|
|
5
|
-
|
|
6
|
-
//#region src/domains/manage/routes/agentToolRelations.ts
|
|
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("/:id", async (c, next) => {
|
|
13
|
-
if ([
|
|
14
|
-
"PUT",
|
|
15
|
-
"PATCH",
|
|
16
|
-
"DELETE"
|
|
17
|
-
].includes(c.req.method)) return requireProjectPermission("edit")(c, next);
|
|
18
|
-
return next();
|
|
19
|
-
});
|
|
20
|
-
app.openapi(createRoute({
|
|
21
|
-
method: "get",
|
|
22
|
-
path: "/",
|
|
23
|
-
summary: "List Agent Tool Relations",
|
|
24
|
-
operationId: "list-agent-tool-relations",
|
|
25
|
-
tags: ["Agents", "Tools"],
|
|
26
|
-
request: {
|
|
27
|
-
params: TenantProjectAgentParamsSchema,
|
|
28
|
-
query: PaginationQueryParamsSchema.extend({
|
|
29
|
-
subAgentId: z.string().optional(),
|
|
30
|
-
toolId: z.string().optional()
|
|
31
|
-
})
|
|
32
|
-
},
|
|
33
|
-
responses: {
|
|
34
|
-
200: {
|
|
35
|
-
description: "List of agent tool relations retrieved successfully",
|
|
36
|
-
content: { "application/json": { schema: SubAgentToolRelationListResponse } }
|
|
37
|
-
},
|
|
38
|
-
...commonGetErrorResponses
|
|
39
|
-
},
|
|
40
|
-
...speakeasyOffsetLimitPagination
|
|
41
|
-
}), async (c) => {
|
|
42
|
-
const db = c.get("db");
|
|
43
|
-
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
44
|
-
const { page, limit, subAgentId, toolId } = c.req.valid("query");
|
|
45
|
-
let result;
|
|
46
|
-
if (subAgentId) {
|
|
47
|
-
const dbResult = await getAgentToolRelationByAgent(db)({
|
|
48
|
-
scopes: {
|
|
49
|
-
tenantId,
|
|
50
|
-
projectId,
|
|
51
|
-
agentId,
|
|
52
|
-
subAgentId
|
|
53
|
-
},
|
|
54
|
-
pagination: {
|
|
55
|
-
page,
|
|
56
|
-
limit
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
result = {
|
|
60
|
-
data: dbResult.data,
|
|
61
|
-
pagination: dbResult.pagination
|
|
62
|
-
};
|
|
63
|
-
} else if (toolId) {
|
|
64
|
-
const dbResult = await getAgentToolRelationByTool(db)({
|
|
65
|
-
scopes: {
|
|
66
|
-
tenantId,
|
|
67
|
-
projectId,
|
|
68
|
-
agentId
|
|
69
|
-
},
|
|
70
|
-
toolId,
|
|
71
|
-
pagination: {
|
|
72
|
-
page,
|
|
73
|
-
limit
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
result = {
|
|
77
|
-
data: dbResult.data,
|
|
78
|
-
pagination: dbResult.pagination
|
|
79
|
-
};
|
|
80
|
-
} else {
|
|
81
|
-
const dbResult = await listAgentToolRelations(db)({
|
|
82
|
-
scopes: {
|
|
83
|
-
tenantId,
|
|
84
|
-
projectId,
|
|
85
|
-
agentId
|
|
86
|
-
},
|
|
87
|
-
pagination: {
|
|
88
|
-
page,
|
|
89
|
-
limit
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
result = {
|
|
93
|
-
data: dbResult.data,
|
|
94
|
-
pagination: dbResult.pagination
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
return c.json(result);
|
|
98
|
-
});
|
|
99
|
-
app.openapi(createRoute({
|
|
100
|
-
method: "get",
|
|
101
|
-
path: "/{id}",
|
|
102
|
-
summary: "Get Agent Tool Relation",
|
|
103
|
-
operationId: "get-agent-tool-relation",
|
|
104
|
-
tags: ["Agent", "Tools"],
|
|
105
|
-
request: { params: TenantProjectAgentIdParamsSchema },
|
|
106
|
-
responses: {
|
|
107
|
-
200: {
|
|
108
|
-
description: "Agent tool relation found",
|
|
109
|
-
content: { "application/json": { schema: SubAgentToolRelationResponse } }
|
|
110
|
-
},
|
|
111
|
-
...commonGetErrorResponses
|
|
112
|
-
}
|
|
113
|
-
}), async (c) => {
|
|
114
|
-
const db = c.get("db");
|
|
115
|
-
const { tenantId, projectId, agentId, id } = c.req.valid("param");
|
|
116
|
-
const agentToolRelation = await getAgentToolRelationById(db)({
|
|
117
|
-
scopes: {
|
|
118
|
-
tenantId,
|
|
119
|
-
projectId,
|
|
120
|
-
agentId,
|
|
121
|
-
subAgentId: id
|
|
122
|
-
},
|
|
123
|
-
relationId: id
|
|
124
|
-
});
|
|
125
|
-
if (!agentToolRelation) throw createApiError({
|
|
126
|
-
code: "not_found",
|
|
127
|
-
message: "Agent tool relation not found"
|
|
128
|
-
});
|
|
129
|
-
return c.json({ data: agentToolRelation });
|
|
130
|
-
});
|
|
131
|
-
app.openapi(createRoute({
|
|
132
|
-
method: "get",
|
|
133
|
-
path: "/tool/{toolId}/agents",
|
|
134
|
-
summary: "Get Agents for Tool",
|
|
135
|
-
operationId: "get-agents-for-tool",
|
|
136
|
-
tags: ["Agent", "Tools"],
|
|
137
|
-
request: {
|
|
138
|
-
params: TenantProjectAgentParamsSchema.extend({ toolId: z.string() }),
|
|
139
|
-
query: PaginationQueryParamsSchema
|
|
140
|
-
},
|
|
141
|
-
responses: {
|
|
142
|
-
200: {
|
|
143
|
-
description: "Agents for tool retrieved successfully",
|
|
144
|
-
content: { "application/json": { schema: SubAgentToolRelationListResponse } }
|
|
145
|
-
},
|
|
146
|
-
...commonGetErrorResponses
|
|
147
|
-
}
|
|
148
|
-
}), async (c) => {
|
|
149
|
-
const db = c.get("db");
|
|
150
|
-
const { tenantId, projectId, agentId, toolId } = c.req.valid("param");
|
|
151
|
-
const { page, limit } = c.req.valid("query");
|
|
152
|
-
const dbResult = await getAgentsForTool(db)({
|
|
153
|
-
scopes: {
|
|
154
|
-
tenantId,
|
|
155
|
-
projectId,
|
|
156
|
-
agentId
|
|
157
|
-
},
|
|
158
|
-
toolId,
|
|
159
|
-
pagination: {
|
|
160
|
-
page,
|
|
161
|
-
limit
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
return c.json(dbResult);
|
|
165
|
-
});
|
|
166
|
-
app.openapi(createRoute({
|
|
167
|
-
method: "post",
|
|
168
|
-
path: "/",
|
|
169
|
-
summary: "Create Agent Tool Relation",
|
|
170
|
-
operationId: "create-agent-tool-relation",
|
|
171
|
-
tags: ["Agent", "Tools"],
|
|
172
|
-
request: {
|
|
173
|
-
params: TenantProjectAgentParamsSchema,
|
|
174
|
-
body: { content: { "application/json": { schema: SubAgentToolRelationApiInsertSchema } } }
|
|
175
|
-
},
|
|
176
|
-
responses: {
|
|
177
|
-
201: {
|
|
178
|
-
description: "Agent tool relation created successfully",
|
|
179
|
-
content: { "application/json": { schema: SubAgentToolRelationResponse } }
|
|
180
|
-
},
|
|
181
|
-
...commonGetErrorResponses
|
|
182
|
-
}
|
|
183
|
-
}), async (c) => {
|
|
184
|
-
const db = c.get("db");
|
|
185
|
-
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
186
|
-
const body = c.req.valid("json");
|
|
187
|
-
if ((await listAgentToolRelations(db)({
|
|
188
|
-
scopes: {
|
|
189
|
-
tenantId,
|
|
190
|
-
projectId,
|
|
191
|
-
agentId
|
|
192
|
-
},
|
|
193
|
-
pagination: { limit: 1e3 }
|
|
194
|
-
})).data.some((relation) => {
|
|
195
|
-
const typedRelation = relation;
|
|
196
|
-
return typedRelation.subAgentId === body.subAgentId && typedRelation.toolId === body.toolId;
|
|
197
|
-
})) throw createApiError({
|
|
198
|
-
code: "unprocessable_entity",
|
|
199
|
-
message: "Agent tool relation already exists"
|
|
200
|
-
});
|
|
201
|
-
try {
|
|
202
|
-
const agentToolRelation = await createAgentToolRelation(db)({
|
|
203
|
-
scopes: {
|
|
204
|
-
tenantId,
|
|
205
|
-
projectId,
|
|
206
|
-
agentId
|
|
207
|
-
},
|
|
208
|
-
data: body
|
|
209
|
-
});
|
|
210
|
-
return c.json({ data: agentToolRelation }, 201);
|
|
211
|
-
} catch (error) {
|
|
212
|
-
if (error?.cause?.code === "23503") throw createApiError({
|
|
213
|
-
code: "bad_request",
|
|
214
|
-
message: "Invalid agent ID or tool ID - referenced entity does not exist"
|
|
215
|
-
});
|
|
216
|
-
throw error;
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
app.openapi(createRoute({
|
|
220
|
-
method: "put",
|
|
221
|
-
path: "/{id}",
|
|
222
|
-
summary: "Update Agent Tool Relation",
|
|
223
|
-
operationId: "update-agent-tool-relation",
|
|
224
|
-
tags: ["Agent", "Tools"],
|
|
225
|
-
request: {
|
|
226
|
-
params: TenantProjectAgentIdParamsSchema,
|
|
227
|
-
body: { content: { "application/json": { schema: SubAgentToolRelationApiUpdateSchema } } }
|
|
228
|
-
},
|
|
229
|
-
responses: {
|
|
230
|
-
200: {
|
|
231
|
-
description: "Agent tool relation updated successfully",
|
|
232
|
-
content: { "application/json": { schema: SubAgentToolRelationResponse } }
|
|
233
|
-
},
|
|
234
|
-
...commonGetErrorResponses
|
|
235
|
-
}
|
|
236
|
-
}), async (c) => {
|
|
237
|
-
const db = c.get("db");
|
|
238
|
-
const { tenantId, projectId, agentId, id } = c.req.valid("param");
|
|
239
|
-
const body = await c.req.valid("json");
|
|
240
|
-
if (Object.keys(body).length === 0) throw createApiError({
|
|
241
|
-
code: "bad_request",
|
|
242
|
-
message: "No fields to update"
|
|
243
|
-
});
|
|
244
|
-
const updatedSubAgentToolRelation = await updateAgentToolRelation(db)({
|
|
245
|
-
scopes: {
|
|
246
|
-
tenantId,
|
|
247
|
-
projectId,
|
|
248
|
-
agentId
|
|
249
|
-
},
|
|
250
|
-
relationId: id,
|
|
251
|
-
data: body
|
|
252
|
-
});
|
|
253
|
-
if (!updatedSubAgentToolRelation) throw createApiError({
|
|
254
|
-
code: "not_found",
|
|
255
|
-
message: "Agent tool relation not found"
|
|
256
|
-
});
|
|
257
|
-
return c.json({ data: updatedSubAgentToolRelation });
|
|
258
|
-
});
|
|
259
|
-
app.openapi(createRoute({
|
|
260
|
-
method: "delete",
|
|
261
|
-
path: "/{id}",
|
|
262
|
-
summary: "Delete Agent Tool Relation",
|
|
263
|
-
operationId: "delete-agent-tool-relation",
|
|
264
|
-
tags: ["Agent", "Tools"],
|
|
265
|
-
request: { params: TenantProjectAgentIdParamsSchema },
|
|
266
|
-
responses: {
|
|
267
|
-
204: { description: "Agent tool relation deleted successfully" },
|
|
268
|
-
404: {
|
|
269
|
-
description: "Agent tool relation not found",
|
|
270
|
-
content: { "application/json": { schema: ErrorResponseSchema } }
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}), async (c) => {
|
|
274
|
-
const db = c.get("db");
|
|
275
|
-
const { tenantId, projectId, agentId, id } = c.req.valid("param");
|
|
276
|
-
if (!await deleteAgentToolRelation(db)({
|
|
277
|
-
scopes: {
|
|
278
|
-
tenantId,
|
|
279
|
-
projectId,
|
|
280
|
-
agentId
|
|
281
|
-
},
|
|
282
|
-
relationId: id
|
|
283
|
-
})) throw createApiError({
|
|
284
|
-
code: "not_found",
|
|
285
|
-
message: "Agent tool relation not found"
|
|
286
|
-
});
|
|
287
|
-
return c.body(null, 204);
|
|
288
|
-
});
|
|
289
|
-
var agentToolRelations_default = app;
|
|
290
|
-
|
|
291
|
-
//#endregion
|
|
292
|
-
export { agentToolRelations_default as default };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { LanguageModel } from "ai";
|
|
2
|
-
|
|
3
|
-
//#region src/domains/run/agents/ModelFactory.d.ts
|
|
4
|
-
interface ModelSettings {
|
|
5
|
-
model?: string;
|
|
6
|
-
providerOptions?: Record<string, unknown>;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Factory for creating AI SDK language models from configuration
|
|
10
|
-
* Supports multiple providers and AI Gateway integration
|
|
11
|
-
*/
|
|
12
|
-
declare class ModelFactory {
|
|
13
|
-
/**
|
|
14
|
-
* Create a provider instance with custom configuration
|
|
15
|
-
* Returns a provider with at least languageModel method
|
|
16
|
-
*/
|
|
17
|
-
private static createProvider;
|
|
18
|
-
/**
|
|
19
|
-
* Extract provider configuration from providerOptions
|
|
20
|
-
* Only includes settings that go to the provider constructor (baseURL, apiKey, etc.)
|
|
21
|
-
*/
|
|
22
|
-
private static extractProviderConfig;
|
|
23
|
-
/**
|
|
24
|
-
* Create a language model instance from configuration
|
|
25
|
-
* Throws error if no config provided - models must be configured at project level
|
|
26
|
-
*/
|
|
27
|
-
static createModel(config: ModelSettings): LanguageModel;
|
|
28
|
-
/**
|
|
29
|
-
* Built-in providers that have special handling
|
|
30
|
-
*/
|
|
31
|
-
private static readonly BUILT_IN_PROVIDERS;
|
|
32
|
-
/**
|
|
33
|
-
* Parse model string to extract provider and model name
|
|
34
|
-
* Examples: "anthropic/claude-sonnet-4" -> { provider: "anthropic", modelName: "claude-sonnet-4" }
|
|
35
|
-
* "openrouter/anthropic/claude-sonnet-4" -> { provider: "openrouter", modelName: "anthropic/claude-sonnet-4" }
|
|
36
|
-
* "claude-sonnet-4" -> { provider: "anthropic", modelName: "claude-sonnet-4" } (default to anthropic)
|
|
37
|
-
*/
|
|
38
|
-
static parseModelString(modelString: string): {
|
|
39
|
-
provider: string;
|
|
40
|
-
modelName: string;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Get generation parameters from provider options
|
|
44
|
-
* These are parameters that get passed to generateText/streamText calls
|
|
45
|
-
*/
|
|
46
|
-
static getGenerationParams(providerOptions?: Record<string, unknown>): Record<string, unknown>;
|
|
47
|
-
/**
|
|
48
|
-
* Prepare complete generation configuration from model settings
|
|
49
|
-
* Returns model instance and generation parameters ready to spread into generateText/streamText
|
|
50
|
-
* Includes maxDuration if specified in provider options (in seconds, following Vercel standard)
|
|
51
|
-
*/
|
|
52
|
-
static prepareGenerationConfig(modelSettings?: ModelSettings): {
|
|
53
|
-
model: LanguageModel;
|
|
54
|
-
maxDuration?: number;
|
|
55
|
-
} & Record<string, unknown>;
|
|
56
|
-
/**
|
|
57
|
-
* Validate model settingsuration
|
|
58
|
-
* Basic validation only - let AI SDK handle parameter-specific validation
|
|
59
|
-
*/
|
|
60
|
-
static validateConfig(config: ModelSettings): string[];
|
|
61
|
-
}
|
|
62
|
-
//#endregion
|
|
63
|
-
export { ModelFactory, ModelSettings };
|