@inkeep/agents-manage-api 0.39.5 → 0.40.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/create-app.d.ts +21 -0
- package/dist/create-app.js +144 -0
- package/dist/data/agentFull.d.ts +15 -0
- package/dist/data/agentFull.js +84 -0
- package/dist/data/conversations.d.ts +77 -0
- package/dist/data/conversations.js +152 -0
- package/dist/data/db/dbClient.d.ts +6 -0
- package/dist/data/db/dbClient.js +17 -0
- package/dist/env.d.ts +61 -0
- package/dist/env.js +55 -0
- package/dist/factory.d.ts +17 -2
- package/dist/factory.js +35 -2
- package/dist/index.d.ts +119 -22
- package/dist/index.js +8 -5
- package/dist/initialization.d.ts +6 -0
- package/dist/initialization.js +79 -0
- package/dist/logger.d.ts +2 -0
- package/dist/logger.js +3 -0
- package/dist/middleware/auth.d.ts +24 -0
- package/dist/middleware/auth.js +55 -0
- package/dist/middleware/error-handler.d.ts +12 -0
- package/dist/middleware/error-handler.js +88 -0
- package/dist/middleware/require-permission.d.ts +19 -0
- package/dist/middleware/require-permission.js +80 -0
- package/dist/middleware/session-auth.d.ts +6 -0
- package/dist/middleware/session-auth.js +26 -0
- package/dist/middleware/tenant-access.d.ts +12 -0
- package/dist/middleware/tenant-access.js +54 -0
- package/dist/openapi.d.ts +7 -0
- package/dist/openapi.js +157 -0
- package/dist/routes/agent.d.ts +9 -0
- package/dist/routes/agent.js +244 -0
- package/dist/routes/agentFull.d.ts +9 -0
- package/dist/routes/agentFull.js +188 -0
- package/dist/routes/agentToolRelations.d.ts +9 -0
- package/dist/routes/agentToolRelations.js +284 -0
- package/dist/routes/apiKeys.d.ts +9 -0
- package/dist/routes/apiKeys.js +217 -0
- package/dist/routes/artifactComponents.d.ts +9 -0
- package/dist/routes/artifactComponents.js +204 -0
- package/dist/routes/cliAuth.d.ts +9 -0
- package/dist/routes/cliAuth.js +60 -0
- package/dist/routes/contextConfigs.d.ts +9 -0
- package/dist/routes/contextConfigs.js +175 -0
- package/dist/routes/conversations.d.ts +7 -0
- package/dist/routes/conversations.js +59 -0
- package/dist/routes/credentialStores.d.ts +9 -0
- package/dist/routes/credentialStores.js +81 -0
- package/dist/routes/credentials.d.ts +9 -0
- package/dist/routes/credentials.js +204 -0
- package/dist/routes/dataComponents.d.ts +9 -0
- package/dist/routes/dataComponents.js +188 -0
- package/dist/routes/externalAgents.d.ts +9 -0
- package/dist/routes/externalAgents.js +195 -0
- package/dist/routes/functionTools.d.ts +9 -0
- package/dist/routes/functionTools.js +252 -0
- package/dist/routes/functions.d.ts +9 -0
- package/dist/routes/functions.js +281 -0
- package/dist/routes/index.d.ts +7 -0
- package/dist/routes/index.js +54 -0
- package/dist/routes/invitations.d.ts +9 -0
- package/dist/routes/invitations.js +41 -0
- package/dist/routes/mcp.d.ts +7 -0
- package/dist/routes/mcp.js +45 -0
- package/dist/routes/mcpCatalog.d.ts +13 -0
- package/dist/routes/mcpCatalog.js +454 -0
- package/dist/routes/oauth.d.ts +10 -0
- package/dist/routes/oauth.js +314 -0
- package/dist/routes/playgroundToken.d.ts +9 -0
- package/dist/routes/playgroundToken.js +108 -0
- package/dist/routes/projectFull.d.ts +9 -0
- package/dist/routes/projectFull.js +193 -0
- package/dist/routes/projects.d.ts +9 -0
- package/dist/routes/projects.js +188 -0
- package/dist/routes/shared.d.ts +93 -0
- package/dist/routes/shared.js +44 -0
- package/dist/routes/signoz.d.ts +10 -0
- package/dist/routes/signoz.js +155 -0
- package/dist/routes/subAgentArtifactComponents.d.ts +9 -0
- package/dist/routes/subAgentArtifactComponents.js +198 -0
- package/dist/routes/subAgentDataComponents.d.ts +9 -0
- package/dist/routes/subAgentDataComponents.js +197 -0
- package/dist/routes/subAgentExternalAgentRelations.d.ts +9 -0
- package/dist/routes/subAgentExternalAgentRelations.js +213 -0
- package/dist/routes/subAgentRelations.d.ts +9 -0
- package/dist/routes/subAgentRelations.js +259 -0
- package/dist/routes/subAgentTeamAgentRelations.d.ts +9 -0
- package/dist/routes/subAgentTeamAgentRelations.js +213 -0
- package/dist/routes/subAgentToolRelations.d.ts +9 -0
- package/dist/routes/subAgentToolRelations.js +284 -0
- package/dist/routes/subAgents.d.ts +9 -0
- package/dist/routes/subAgents.js +210 -0
- package/dist/routes/thirdPartyMCPServers.d.ts +14 -0
- package/dist/routes/thirdPartyMCPServers.js +72 -0
- package/dist/routes/tools.d.ts +9 -0
- package/dist/routes/tools.js +256 -0
- package/dist/routes/userOrganizations.d.ts +9 -0
- package/dist/routes/userOrganizations.js +58 -0
- package/dist/sso-helpers.d.ts +20 -0
- package/dist/sso-helpers.js +51 -0
- package/dist/types/app.d.ts +47 -0
- package/dist/types/app.js +1 -0
- package/dist/utils/cors.d.ts +33 -0
- package/dist/utils/cors.js +98 -0
- package/dist/utils/oauth-service.d.ts +71 -0
- package/dist/utils/oauth-service.js +106 -0
- package/dist/utils/signoz-helpers.d.ts +9 -0
- package/dist/utils/signoz-helpers.js +33 -0
- package/dist/utils/temp-api-keys.d.ts +17 -0
- package/dist/utils/temp-api-keys.js +26 -0
- package/package.json +6 -13
- package/dist/chunk-VBDAOXYI.js +0 -832
- package/dist/chunk-VBDAOXYI.js.map +0 -1
- package/dist/factory2.d.ts +0 -41
- package/dist/factory2.d.ts.map +0 -1
- package/dist/factory2.js +0 -37085
- package/dist/factory2.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/nodefs.js +0 -27
- package/dist/nodefs.js.map +0 -1
- package/dist/opfs-ahp.js +0 -368
- package/dist/opfs-ahp.js.map +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseAppVariables } from "../types/app.js";
|
|
2
|
+
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
3
|
+
|
|
4
|
+
//#region src/routes/subAgentTeamAgentRelations.d.ts
|
|
5
|
+
declare const app: OpenAPIHono<{
|
|
6
|
+
Variables: BaseAppVariables;
|
|
7
|
+
}, {}, "/">;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { app as default };
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import dbClient_default from "../data/db/dbClient.js";
|
|
2
|
+
import { requirePermission } from "../middleware/require-permission.js";
|
|
3
|
+
import { speakeasyOffsetLimitPagination } from "./shared.js";
|
|
4
|
+
import { OpenAPIHono, createRoute } from "@hono/zod-openapi";
|
|
5
|
+
import { ErrorResponseSchema, PaginationQueryParamsSchema, SubAgentTeamAgentRelationApiInsertSchema, SubAgentTeamAgentRelationApiUpdateSchema, SubAgentTeamAgentRelationListResponse, SubAgentTeamAgentRelationResponse, TenantProjectAgentSubAgentIdParamsSchema, TenantProjectAgentSubAgentParamsSchema, commonGetErrorResponses, createApiError, createSubAgentTeamAgentRelation, deleteSubAgentTeamAgentRelation, getSubAgentTeamAgentRelationById, listSubAgentTeamAgentRelations, updateSubAgentTeamAgentRelation } from "@inkeep/agents-core";
|
|
6
|
+
import { nanoid } from "nanoid";
|
|
7
|
+
|
|
8
|
+
//#region src/routes/subAgentTeamAgentRelations.ts
|
|
9
|
+
const app = new OpenAPIHono();
|
|
10
|
+
app.use("/", async (c, next) => {
|
|
11
|
+
if (c.req.method === "POST") return requirePermission({ sub_agent: ["create"] })(c, next);
|
|
12
|
+
return next();
|
|
13
|
+
});
|
|
14
|
+
app.use("/:id", async (c, next) => {
|
|
15
|
+
if (c.req.method === "PUT") return requirePermission({ sub_agent: ["update"] })(c, next);
|
|
16
|
+
if (c.req.method === "DELETE") return requirePermission({ sub_agent: ["delete"] })(c, next);
|
|
17
|
+
return next();
|
|
18
|
+
});
|
|
19
|
+
app.openapi(createRoute({
|
|
20
|
+
method: "get",
|
|
21
|
+
path: "/",
|
|
22
|
+
summary: "List Sub Agent Team Agent Relations",
|
|
23
|
+
operationId: "list-sub-agent-team-agent-relations",
|
|
24
|
+
tags: ["Sub Agent Team Agent Relations"],
|
|
25
|
+
request: {
|
|
26
|
+
params: TenantProjectAgentSubAgentParamsSchema,
|
|
27
|
+
query: PaginationQueryParamsSchema
|
|
28
|
+
},
|
|
29
|
+
responses: {
|
|
30
|
+
200: {
|
|
31
|
+
description: "List of sub agent team agent relations retrieved successfully",
|
|
32
|
+
content: { "application/json": { schema: SubAgentTeamAgentRelationListResponse } }
|
|
33
|
+
},
|
|
34
|
+
...commonGetErrorResponses
|
|
35
|
+
},
|
|
36
|
+
...speakeasyOffsetLimitPagination
|
|
37
|
+
}), async (c) => {
|
|
38
|
+
const { tenantId, projectId, agentId, subAgentId } = c.req.valid("param");
|
|
39
|
+
const { page = 1, limit = 10 } = c.req.valid("query");
|
|
40
|
+
const pageNum = Number(page);
|
|
41
|
+
const limitNum = Math.min(Number(limit), 100);
|
|
42
|
+
try {
|
|
43
|
+
const result = await listSubAgentTeamAgentRelations(dbClient_default)({
|
|
44
|
+
scopes: {
|
|
45
|
+
tenantId,
|
|
46
|
+
projectId,
|
|
47
|
+
agentId,
|
|
48
|
+
subAgentId
|
|
49
|
+
},
|
|
50
|
+
pagination: {
|
|
51
|
+
page: pageNum,
|
|
52
|
+
limit: limitNum
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return c.json(result);
|
|
56
|
+
} catch (_error) {
|
|
57
|
+
throw createApiError({
|
|
58
|
+
code: "internal_server_error",
|
|
59
|
+
message: "Failed to retrieve sub agent team agent relations"
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
app.openapi(createRoute({
|
|
64
|
+
method: "get",
|
|
65
|
+
path: "/{id}",
|
|
66
|
+
summary: "Get Sub Agent Team Agent Relation",
|
|
67
|
+
operationId: "get-sub-agent-team-agent-relation-by-id",
|
|
68
|
+
tags: ["Sub Agent Team Agent Relations"],
|
|
69
|
+
request: { params: TenantProjectAgentSubAgentIdParamsSchema },
|
|
70
|
+
responses: {
|
|
71
|
+
200: {
|
|
72
|
+
description: "Sub Agent team agent relation found",
|
|
73
|
+
content: { "application/json": { schema: SubAgentTeamAgentRelationResponse } }
|
|
74
|
+
},
|
|
75
|
+
...commonGetErrorResponses
|
|
76
|
+
}
|
|
77
|
+
}), async (c) => {
|
|
78
|
+
const { tenantId, projectId, agentId, subAgentId, id } = c.req.valid("param");
|
|
79
|
+
const relation = await getSubAgentTeamAgentRelationById(dbClient_default)({
|
|
80
|
+
scopes: {
|
|
81
|
+
tenantId,
|
|
82
|
+
projectId,
|
|
83
|
+
agentId,
|
|
84
|
+
subAgentId
|
|
85
|
+
},
|
|
86
|
+
relationId: id
|
|
87
|
+
});
|
|
88
|
+
if (!relation) throw createApiError({
|
|
89
|
+
code: "not_found",
|
|
90
|
+
message: "Sub Agent Team Agent Relation not found"
|
|
91
|
+
});
|
|
92
|
+
return c.json({ data: relation });
|
|
93
|
+
});
|
|
94
|
+
app.openapi(createRoute({
|
|
95
|
+
method: "post",
|
|
96
|
+
path: "/",
|
|
97
|
+
summary: "Create Sub Agent Team Agent Relation",
|
|
98
|
+
operationId: "create-sub-agent-team-agent-relation",
|
|
99
|
+
tags: ["Sub Agent Team Agent Relations"],
|
|
100
|
+
request: {
|
|
101
|
+
params: TenantProjectAgentSubAgentParamsSchema,
|
|
102
|
+
body: { content: { "application/json": { schema: SubAgentTeamAgentRelationApiInsertSchema } } }
|
|
103
|
+
},
|
|
104
|
+
responses: {
|
|
105
|
+
201: {
|
|
106
|
+
description: "Sub Agent Team Agent Relation created successfully",
|
|
107
|
+
content: { "application/json": { schema: SubAgentTeamAgentRelationResponse } }
|
|
108
|
+
},
|
|
109
|
+
...commonGetErrorResponses
|
|
110
|
+
}
|
|
111
|
+
}), async (c) => {
|
|
112
|
+
const { tenantId, projectId, agentId, subAgentId } = c.req.valid("param");
|
|
113
|
+
const body = await c.req.valid("json");
|
|
114
|
+
if ((await listSubAgentTeamAgentRelations(dbClient_default)({
|
|
115
|
+
scopes: {
|
|
116
|
+
tenantId,
|
|
117
|
+
projectId,
|
|
118
|
+
agentId,
|
|
119
|
+
subAgentId
|
|
120
|
+
},
|
|
121
|
+
pagination: {
|
|
122
|
+
page: 1,
|
|
123
|
+
limit: 1e3
|
|
124
|
+
}
|
|
125
|
+
})).data.some((relation$1) => relation$1.targetAgentId === body.targetAgentId && relation$1.subAgentId === subAgentId)) throw createApiError({
|
|
126
|
+
code: "unprocessable_entity",
|
|
127
|
+
message: `A relation between this sub-agent and team agent already exists`
|
|
128
|
+
});
|
|
129
|
+
const relation = await createSubAgentTeamAgentRelation(dbClient_default)({
|
|
130
|
+
scopes: {
|
|
131
|
+
tenantId,
|
|
132
|
+
projectId,
|
|
133
|
+
agentId,
|
|
134
|
+
subAgentId
|
|
135
|
+
},
|
|
136
|
+
relationId: nanoid(),
|
|
137
|
+
data: {
|
|
138
|
+
targetAgentId: body.targetAgentId,
|
|
139
|
+
headers: body.headers || null
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return c.json({ data: relation }, 201);
|
|
143
|
+
});
|
|
144
|
+
app.openapi(createRoute({
|
|
145
|
+
method: "put",
|
|
146
|
+
path: "/{id}",
|
|
147
|
+
summary: "Update Sub Agent Team Agent Relation",
|
|
148
|
+
operationId: "update-sub-agent-team-agent-relation",
|
|
149
|
+
tags: ["Sub Agent Team Agent Relations"],
|
|
150
|
+
request: {
|
|
151
|
+
params: TenantProjectAgentSubAgentIdParamsSchema,
|
|
152
|
+
body: { content: { "application/json": { schema: SubAgentTeamAgentRelationApiUpdateSchema } } }
|
|
153
|
+
},
|
|
154
|
+
responses: {
|
|
155
|
+
200: {
|
|
156
|
+
description: "Sub Agent team agent relation updated successfully",
|
|
157
|
+
content: { "application/json": { schema: SubAgentTeamAgentRelationResponse } }
|
|
158
|
+
},
|
|
159
|
+
...commonGetErrorResponses
|
|
160
|
+
}
|
|
161
|
+
}), async (c) => {
|
|
162
|
+
const { tenantId, projectId, agentId, subAgentId, id } = c.req.valid("param");
|
|
163
|
+
const body = await c.req.valid("json");
|
|
164
|
+
const updatedRelation = await updateSubAgentTeamAgentRelation(dbClient_default)({
|
|
165
|
+
scopes: {
|
|
166
|
+
tenantId,
|
|
167
|
+
projectId,
|
|
168
|
+
agentId,
|
|
169
|
+
subAgentId
|
|
170
|
+
},
|
|
171
|
+
relationId: id,
|
|
172
|
+
data: body
|
|
173
|
+
});
|
|
174
|
+
if (!updatedRelation) throw createApiError({
|
|
175
|
+
code: "not_found",
|
|
176
|
+
message: "Sub Agent Team Agent Relation not found"
|
|
177
|
+
});
|
|
178
|
+
return c.json({ data: updatedRelation });
|
|
179
|
+
});
|
|
180
|
+
app.openapi(createRoute({
|
|
181
|
+
method: "delete",
|
|
182
|
+
path: "/{id}",
|
|
183
|
+
summary: "Delete Sub Agent Team Agent Relation",
|
|
184
|
+
operationId: "delete-sub-agent-team-agent-relation",
|
|
185
|
+
tags: ["Sub Agent Team Agent Relations"],
|
|
186
|
+
request: { params: TenantProjectAgentSubAgentIdParamsSchema },
|
|
187
|
+
responses: {
|
|
188
|
+
204: { description: "Sub Agent Team Agent Relation deleted successfully" },
|
|
189
|
+
404: {
|
|
190
|
+
description: "Sub Agent Team Agent Relation not found",
|
|
191
|
+
content: { "application/json": { schema: ErrorResponseSchema } }
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}), async (c) => {
|
|
195
|
+
const { tenantId, projectId, agentId, subAgentId, id } = c.req.valid("param");
|
|
196
|
+
if (!await deleteSubAgentTeamAgentRelation(dbClient_default)({
|
|
197
|
+
scopes: {
|
|
198
|
+
tenantId,
|
|
199
|
+
projectId,
|
|
200
|
+
agentId,
|
|
201
|
+
subAgentId
|
|
202
|
+
},
|
|
203
|
+
relationId: id
|
|
204
|
+
})) throw createApiError({
|
|
205
|
+
code: "not_found",
|
|
206
|
+
message: "Sub Agent Team Agent Relation not found"
|
|
207
|
+
});
|
|
208
|
+
return c.body(null, 204);
|
|
209
|
+
});
|
|
210
|
+
var subAgentTeamAgentRelations_default = app;
|
|
211
|
+
|
|
212
|
+
//#endregion
|
|
213
|
+
export { subAgentTeamAgentRelations_default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseAppVariables } from "../types/app.js";
|
|
2
|
+
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
3
|
+
|
|
4
|
+
//#region src/routes/subAgentToolRelations.d.ts
|
|
5
|
+
declare const app: OpenAPIHono<{
|
|
6
|
+
Variables: BaseAppVariables;
|
|
7
|
+
}, {}, "/">;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { app as default };
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import dbClient_default from "../data/db/dbClient.js";
|
|
2
|
+
import { requirePermission } from "../middleware/require-permission.js";
|
|
3
|
+
import { speakeasyOffsetLimitPagination } from "./shared.js";
|
|
4
|
+
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
5
|
+
import { ErrorResponseSchema, PaginationQueryParamsSchema, SubAgentToolRelationApiInsertSchema, SubAgentToolRelationApiUpdateSchema, SubAgentToolRelationListResponse, SubAgentToolRelationResponse, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, commonGetErrorResponses, createAgentToolRelation, createApiError, deleteAgentToolRelation, getAgentToolRelationByAgent, getAgentToolRelationById, getAgentToolRelationByTool, getAgentsForTool, listAgentToolRelations, updateAgentToolRelation } from "@inkeep/agents-core";
|
|
6
|
+
|
|
7
|
+
//#region src/routes/subAgentToolRelations.ts
|
|
8
|
+
const app = new OpenAPIHono();
|
|
9
|
+
app.use("/", async (c, next) => {
|
|
10
|
+
if (c.req.method === "POST") return requirePermission({ sub_agent: ["create"] })(c, next);
|
|
11
|
+
return next();
|
|
12
|
+
});
|
|
13
|
+
app.use("/:id", async (c, next) => {
|
|
14
|
+
if (c.req.method === "PUT") return requirePermission({ sub_agent: ["update"] })(c, next);
|
|
15
|
+
if (c.req.method === "DELETE") return requirePermission({ sub_agent: ["delete"] })(c, next);
|
|
16
|
+
return next();
|
|
17
|
+
});
|
|
18
|
+
app.openapi(createRoute({
|
|
19
|
+
method: "get",
|
|
20
|
+
path: "/",
|
|
21
|
+
summary: "List SubAgent Tool Relations",
|
|
22
|
+
operationId: "list-subagent-tool-relations",
|
|
23
|
+
tags: ["SubAgent Tool Relations"],
|
|
24
|
+
request: {
|
|
25
|
+
params: TenantProjectAgentParamsSchema,
|
|
26
|
+
query: PaginationQueryParamsSchema.extend({
|
|
27
|
+
subAgentId: z.string().optional(),
|
|
28
|
+
toolId: z.string().optional()
|
|
29
|
+
})
|
|
30
|
+
},
|
|
31
|
+
responses: {
|
|
32
|
+
200: {
|
|
33
|
+
description: "List of subAgent tool relations retrieved successfully",
|
|
34
|
+
content: { "application/json": { schema: SubAgentToolRelationListResponse } }
|
|
35
|
+
},
|
|
36
|
+
...commonGetErrorResponses
|
|
37
|
+
},
|
|
38
|
+
...speakeasyOffsetLimitPagination
|
|
39
|
+
}), async (c) => {
|
|
40
|
+
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
41
|
+
const { page, limit, subAgentId, toolId } = c.req.valid("query");
|
|
42
|
+
let result;
|
|
43
|
+
if (subAgentId) {
|
|
44
|
+
const dbResult = await getAgentToolRelationByAgent(dbClient_default)({
|
|
45
|
+
scopes: {
|
|
46
|
+
tenantId,
|
|
47
|
+
projectId,
|
|
48
|
+
agentId,
|
|
49
|
+
subAgentId
|
|
50
|
+
},
|
|
51
|
+
pagination: {
|
|
52
|
+
page,
|
|
53
|
+
limit
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
result = {
|
|
57
|
+
data: dbResult.data,
|
|
58
|
+
pagination: dbResult.pagination
|
|
59
|
+
};
|
|
60
|
+
} else if (toolId) {
|
|
61
|
+
const dbResult = await getAgentToolRelationByTool(dbClient_default)({
|
|
62
|
+
scopes: {
|
|
63
|
+
tenantId,
|
|
64
|
+
projectId,
|
|
65
|
+
agentId
|
|
66
|
+
},
|
|
67
|
+
toolId,
|
|
68
|
+
pagination: {
|
|
69
|
+
page,
|
|
70
|
+
limit
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
result = {
|
|
74
|
+
data: dbResult.data,
|
|
75
|
+
pagination: dbResult.pagination
|
|
76
|
+
};
|
|
77
|
+
} else {
|
|
78
|
+
const dbResult = await listAgentToolRelations(dbClient_default)({
|
|
79
|
+
scopes: {
|
|
80
|
+
tenantId,
|
|
81
|
+
projectId,
|
|
82
|
+
agentId
|
|
83
|
+
},
|
|
84
|
+
pagination: {
|
|
85
|
+
page,
|
|
86
|
+
limit
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
result = {
|
|
90
|
+
data: dbResult.data,
|
|
91
|
+
pagination: dbResult.pagination
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return c.json(result);
|
|
95
|
+
});
|
|
96
|
+
app.openapi(createRoute({
|
|
97
|
+
method: "get",
|
|
98
|
+
path: "/{id}",
|
|
99
|
+
summary: "Get SubAgent Tool Relation",
|
|
100
|
+
operationId: "get-subagent-tool-relation",
|
|
101
|
+
tags: ["SubAgent Tool Relations"],
|
|
102
|
+
request: { params: TenantProjectAgentIdParamsSchema },
|
|
103
|
+
responses: {
|
|
104
|
+
200: {
|
|
105
|
+
description: "SubAgent tool relation found",
|
|
106
|
+
content: { "application/json": { schema: SubAgentToolRelationResponse } }
|
|
107
|
+
},
|
|
108
|
+
...commonGetErrorResponses
|
|
109
|
+
}
|
|
110
|
+
}), async (c) => {
|
|
111
|
+
const { tenantId, projectId, agentId, id } = c.req.valid("param");
|
|
112
|
+
const agentToolRelation = await getAgentToolRelationById(dbClient_default)({
|
|
113
|
+
scopes: {
|
|
114
|
+
tenantId,
|
|
115
|
+
projectId,
|
|
116
|
+
agentId,
|
|
117
|
+
subAgentId: id
|
|
118
|
+
},
|
|
119
|
+
relationId: id
|
|
120
|
+
});
|
|
121
|
+
if (!agentToolRelation) throw createApiError({
|
|
122
|
+
code: "not_found",
|
|
123
|
+
message: "SubAgent tool relation not found"
|
|
124
|
+
});
|
|
125
|
+
return c.json({ data: agentToolRelation });
|
|
126
|
+
});
|
|
127
|
+
app.openapi(createRoute({
|
|
128
|
+
method: "get",
|
|
129
|
+
path: "/tool/{toolId}/sub-agents",
|
|
130
|
+
summary: "Get SubAgents for Tool",
|
|
131
|
+
operationId: "get-subagents-for-tool",
|
|
132
|
+
tags: ["SubAgent Tool Relations"],
|
|
133
|
+
request: {
|
|
134
|
+
params: TenantProjectAgentParamsSchema.extend({ toolId: z.string() }),
|
|
135
|
+
query: PaginationQueryParamsSchema
|
|
136
|
+
},
|
|
137
|
+
responses: {
|
|
138
|
+
200: {
|
|
139
|
+
description: "SubAgents for tool retrieved successfully",
|
|
140
|
+
content: { "application/json": { schema: SubAgentToolRelationListResponse } }
|
|
141
|
+
},
|
|
142
|
+
...commonGetErrorResponses
|
|
143
|
+
}
|
|
144
|
+
}), async (c) => {
|
|
145
|
+
const { tenantId, projectId, agentId, toolId } = c.req.valid("param");
|
|
146
|
+
const { page, limit } = c.req.valid("query");
|
|
147
|
+
const dbResult = await getAgentsForTool(dbClient_default)({
|
|
148
|
+
scopes: {
|
|
149
|
+
tenantId,
|
|
150
|
+
projectId,
|
|
151
|
+
agentId
|
|
152
|
+
},
|
|
153
|
+
toolId,
|
|
154
|
+
pagination: {
|
|
155
|
+
page,
|
|
156
|
+
limit
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
return c.json(dbResult);
|
|
160
|
+
});
|
|
161
|
+
app.openapi(createRoute({
|
|
162
|
+
method: "post",
|
|
163
|
+
path: "/",
|
|
164
|
+
summary: "Create SubAgent Tool Relation",
|
|
165
|
+
operationId: "create-subagent-tool-relation",
|
|
166
|
+
tags: ["SubAgent Tool Relations"],
|
|
167
|
+
request: {
|
|
168
|
+
params: TenantProjectAgentParamsSchema,
|
|
169
|
+
body: { content: { "application/json": { schema: SubAgentToolRelationApiInsertSchema } } }
|
|
170
|
+
},
|
|
171
|
+
responses: {
|
|
172
|
+
201: {
|
|
173
|
+
description: "SubAgent tool relation created successfully",
|
|
174
|
+
content: { "application/json": { schema: SubAgentToolRelationResponse } }
|
|
175
|
+
},
|
|
176
|
+
...commonGetErrorResponses
|
|
177
|
+
}
|
|
178
|
+
}), async (c) => {
|
|
179
|
+
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
180
|
+
const body = c.req.valid("json");
|
|
181
|
+
if ((await listAgentToolRelations(dbClient_default)({
|
|
182
|
+
scopes: {
|
|
183
|
+
tenantId,
|
|
184
|
+
projectId,
|
|
185
|
+
agentId
|
|
186
|
+
},
|
|
187
|
+
pagination: { limit: 1e3 }
|
|
188
|
+
})).data.some((relation) => {
|
|
189
|
+
const typedRelation = relation;
|
|
190
|
+
return typedRelation.subAgentId === body.subAgentId && typedRelation.toolId === body.toolId;
|
|
191
|
+
})) throw createApiError({
|
|
192
|
+
code: "unprocessable_entity",
|
|
193
|
+
message: "SubAgent tool relation already exists"
|
|
194
|
+
});
|
|
195
|
+
try {
|
|
196
|
+
const agentToolRelation = await createAgentToolRelation(dbClient_default)({
|
|
197
|
+
scopes: {
|
|
198
|
+
tenantId,
|
|
199
|
+
projectId,
|
|
200
|
+
agentId
|
|
201
|
+
},
|
|
202
|
+
data: body
|
|
203
|
+
});
|
|
204
|
+
return c.json({ data: agentToolRelation }, 201);
|
|
205
|
+
} catch (error) {
|
|
206
|
+
if (error?.cause?.code === "23503") throw createApiError({
|
|
207
|
+
code: "bad_request",
|
|
208
|
+
message: "Invalid subAgent ID or tool ID - referenced entity does not exist"
|
|
209
|
+
});
|
|
210
|
+
throw error;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
app.openapi(createRoute({
|
|
214
|
+
method: "put",
|
|
215
|
+
path: "/{id}",
|
|
216
|
+
summary: "Update SubAgent Tool Relation",
|
|
217
|
+
operationId: "update-subagent-tool-relation",
|
|
218
|
+
tags: ["SubAgent Tool Relations"],
|
|
219
|
+
request: {
|
|
220
|
+
params: TenantProjectAgentIdParamsSchema,
|
|
221
|
+
body: { content: { "application/json": { schema: SubAgentToolRelationApiUpdateSchema } } }
|
|
222
|
+
},
|
|
223
|
+
responses: {
|
|
224
|
+
200: {
|
|
225
|
+
description: "SubAgent tool relation updated successfully",
|
|
226
|
+
content: { "application/json": { schema: SubAgentToolRelationResponse } }
|
|
227
|
+
},
|
|
228
|
+
...commonGetErrorResponses
|
|
229
|
+
}
|
|
230
|
+
}), async (c) => {
|
|
231
|
+
const { tenantId, projectId, agentId, id } = c.req.valid("param");
|
|
232
|
+
const body = await c.req.valid("json");
|
|
233
|
+
if (Object.keys(body).length === 0) throw createApiError({
|
|
234
|
+
code: "bad_request",
|
|
235
|
+
message: "No fields to update"
|
|
236
|
+
});
|
|
237
|
+
const updatedAgentToolRelation = await updateAgentToolRelation(dbClient_default)({
|
|
238
|
+
scopes: {
|
|
239
|
+
tenantId,
|
|
240
|
+
projectId,
|
|
241
|
+
agentId
|
|
242
|
+
},
|
|
243
|
+
relationId: id,
|
|
244
|
+
data: body
|
|
245
|
+
});
|
|
246
|
+
if (!updatedAgentToolRelation) throw createApiError({
|
|
247
|
+
code: "not_found",
|
|
248
|
+
message: "SubAgent tool relation not found"
|
|
249
|
+
});
|
|
250
|
+
return c.json({ data: updatedAgentToolRelation });
|
|
251
|
+
});
|
|
252
|
+
app.openapi(createRoute({
|
|
253
|
+
method: "delete",
|
|
254
|
+
path: "/{id}",
|
|
255
|
+
summary: "Delete SubAgent Tool Relation",
|
|
256
|
+
operationId: "delete-subagent-tool-relation",
|
|
257
|
+
tags: ["SubAgent Tool Relations"],
|
|
258
|
+
request: { params: TenantProjectAgentIdParamsSchema },
|
|
259
|
+
responses: {
|
|
260
|
+
204: { description: "SubAgent tool relation deleted successfully" },
|
|
261
|
+
404: {
|
|
262
|
+
description: "SubAgent tool relation not found",
|
|
263
|
+
content: { "application/json": { schema: ErrorResponseSchema } }
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}), async (c) => {
|
|
267
|
+
const { tenantId, projectId, agentId, id } = c.req.valid("param");
|
|
268
|
+
if (!await deleteAgentToolRelation(dbClient_default)({
|
|
269
|
+
scopes: {
|
|
270
|
+
tenantId,
|
|
271
|
+
projectId,
|
|
272
|
+
agentId
|
|
273
|
+
},
|
|
274
|
+
relationId: id
|
|
275
|
+
})) throw createApiError({
|
|
276
|
+
code: "not_found",
|
|
277
|
+
message: "SubAgent tool relation not found"
|
|
278
|
+
});
|
|
279
|
+
return c.body(null, 204);
|
|
280
|
+
});
|
|
281
|
+
var subAgentToolRelations_default = app;
|
|
282
|
+
|
|
283
|
+
//#endregion
|
|
284
|
+
export { subAgentToolRelations_default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseAppVariables } from "../types/app.js";
|
|
2
|
+
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
3
|
+
|
|
4
|
+
//#region src/routes/subAgents.d.ts
|
|
5
|
+
declare const app: OpenAPIHono<{
|
|
6
|
+
Variables: BaseAppVariables;
|
|
7
|
+
}, {}, "/">;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { app as default };
|