@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,252 @@
|
|
|
1
|
+
import { getLogger as getLogger$1 } from "../logger.js";
|
|
2
|
+
import dbClient_default from "../data/db/dbClient.js";
|
|
3
|
+
import { requirePermission } from "../middleware/require-permission.js";
|
|
4
|
+
import { speakeasyOffsetLimitPagination } from "./shared.js";
|
|
5
|
+
import { OpenAPIHono, createRoute } from "@hono/zod-openapi";
|
|
6
|
+
import { FunctionToolApiInsertSchema, FunctionToolApiUpdateSchema, FunctionToolListResponse, FunctionToolResponse, PaginationQueryParamsSchema, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, commonGetErrorResponses, createApiError, createFunctionTool, deleteFunctionTool, generateId, getFunctionToolById, listFunctionTools, updateFunctionTool } from "@inkeep/agents-core";
|
|
7
|
+
|
|
8
|
+
//#region src/routes/functionTools.ts
|
|
9
|
+
const logger = getLogger$1("functionTools");
|
|
10
|
+
const app = new OpenAPIHono();
|
|
11
|
+
app.use("/", async (c, next) => {
|
|
12
|
+
if (c.req.method === "POST") return requirePermission({ function: ["create"] })(c, next);
|
|
13
|
+
return next();
|
|
14
|
+
});
|
|
15
|
+
app.use("/:id", async (c, next) => {
|
|
16
|
+
if (c.req.method === "PUT") return requirePermission({ function: ["update"] })(c, next);
|
|
17
|
+
if (c.req.method === "DELETE") return requirePermission({ function: ["delete"] })(c, next);
|
|
18
|
+
return next();
|
|
19
|
+
});
|
|
20
|
+
app.openapi(createRoute({
|
|
21
|
+
method: "get",
|
|
22
|
+
path: "/",
|
|
23
|
+
summary: "List Function Tools",
|
|
24
|
+
operationId: "list-function-tools",
|
|
25
|
+
tags: ["Function Tools"],
|
|
26
|
+
request: {
|
|
27
|
+
params: TenantProjectAgentParamsSchema,
|
|
28
|
+
query: PaginationQueryParamsSchema
|
|
29
|
+
},
|
|
30
|
+
responses: {
|
|
31
|
+
200: {
|
|
32
|
+
description: "List of function tools retrieved successfully",
|
|
33
|
+
content: { "application/json": { schema: FunctionToolListResponse } }
|
|
34
|
+
},
|
|
35
|
+
...commonGetErrorResponses
|
|
36
|
+
},
|
|
37
|
+
...speakeasyOffsetLimitPagination
|
|
38
|
+
}), async (c) => {
|
|
39
|
+
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
40
|
+
const { page, limit } = c.req.valid("query");
|
|
41
|
+
try {
|
|
42
|
+
const result = await listFunctionTools(dbClient_default)({
|
|
43
|
+
scopes: {
|
|
44
|
+
tenantId,
|
|
45
|
+
projectId,
|
|
46
|
+
agentId
|
|
47
|
+
},
|
|
48
|
+
pagination: {
|
|
49
|
+
page,
|
|
50
|
+
limit
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return c.json(result);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
logger.error({
|
|
56
|
+
error,
|
|
57
|
+
tenantId,
|
|
58
|
+
projectId,
|
|
59
|
+
agentId
|
|
60
|
+
}, "Failed to list function tools");
|
|
61
|
+
return c.json(createApiError({
|
|
62
|
+
code: "internal_server_error",
|
|
63
|
+
message: "Failed to list function tools"
|
|
64
|
+
}), 500);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
app.openapi(createRoute({
|
|
68
|
+
method: "get",
|
|
69
|
+
path: "/{id}",
|
|
70
|
+
summary: "Get Function Tool by ID",
|
|
71
|
+
operationId: "get-function-tool",
|
|
72
|
+
tags: ["Function Tools"],
|
|
73
|
+
request: { params: TenantProjectAgentIdParamsSchema },
|
|
74
|
+
responses: {
|
|
75
|
+
200: {
|
|
76
|
+
description: "Function tool retrieved successfully",
|
|
77
|
+
content: { "application/json": { schema: FunctionToolResponse } }
|
|
78
|
+
},
|
|
79
|
+
...commonGetErrorResponses
|
|
80
|
+
}
|
|
81
|
+
}), async (c) => {
|
|
82
|
+
const { tenantId, projectId, agentId, id } = c.req.valid("param");
|
|
83
|
+
try {
|
|
84
|
+
const functionTool = await getFunctionToolById(dbClient_default)({
|
|
85
|
+
scopes: {
|
|
86
|
+
tenantId,
|
|
87
|
+
projectId,
|
|
88
|
+
agentId
|
|
89
|
+
},
|
|
90
|
+
functionToolId: id
|
|
91
|
+
});
|
|
92
|
+
if (!functionTool) return c.json(createApiError({
|
|
93
|
+
code: "not_found",
|
|
94
|
+
message: "Function tool not found"
|
|
95
|
+
}), 404);
|
|
96
|
+
return c.json({ data: functionTool });
|
|
97
|
+
} catch (error) {
|
|
98
|
+
logger.error({
|
|
99
|
+
error,
|
|
100
|
+
tenantId,
|
|
101
|
+
projectId,
|
|
102
|
+
agentId,
|
|
103
|
+
id
|
|
104
|
+
}, "Failed to get function tool");
|
|
105
|
+
return c.json(createApiError({
|
|
106
|
+
code: "internal_server_error",
|
|
107
|
+
message: "Failed to get function tool"
|
|
108
|
+
}), 500);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
app.openapi(createRoute({
|
|
112
|
+
method: "post",
|
|
113
|
+
path: "/",
|
|
114
|
+
summary: "Create Function Tool",
|
|
115
|
+
operationId: "create-function-tool",
|
|
116
|
+
tags: ["Function Tools"],
|
|
117
|
+
request: {
|
|
118
|
+
params: TenantProjectAgentParamsSchema,
|
|
119
|
+
body: { content: { "application/json": { schema: FunctionToolApiInsertSchema } } }
|
|
120
|
+
},
|
|
121
|
+
responses: {
|
|
122
|
+
201: {
|
|
123
|
+
description: "Function tool created successfully",
|
|
124
|
+
content: { "application/json": { schema: FunctionToolResponse } }
|
|
125
|
+
},
|
|
126
|
+
...commonGetErrorResponses
|
|
127
|
+
}
|
|
128
|
+
}), async (c) => {
|
|
129
|
+
const { tenantId, projectId, agentId } = c.req.valid("param");
|
|
130
|
+
const body = c.req.valid("json");
|
|
131
|
+
try {
|
|
132
|
+
const id = body.id || generateId();
|
|
133
|
+
const functionTool = await createFunctionTool(dbClient_default)({
|
|
134
|
+
scopes: {
|
|
135
|
+
tenantId,
|
|
136
|
+
projectId,
|
|
137
|
+
agentId
|
|
138
|
+
},
|
|
139
|
+
data: {
|
|
140
|
+
...body,
|
|
141
|
+
id
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
return c.json({ data: functionTool }, 201);
|
|
145
|
+
} catch (error) {
|
|
146
|
+
logger.error({
|
|
147
|
+
error,
|
|
148
|
+
tenantId,
|
|
149
|
+
projectId,
|
|
150
|
+
agentId,
|
|
151
|
+
body
|
|
152
|
+
}, "Failed to create function tool");
|
|
153
|
+
return c.json(createApiError({
|
|
154
|
+
code: "internal_server_error",
|
|
155
|
+
message: "Failed to create function tool"
|
|
156
|
+
}), 500);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
app.openapi(createRoute({
|
|
160
|
+
method: "put",
|
|
161
|
+
path: "/{id}",
|
|
162
|
+
summary: "Update Function Tool",
|
|
163
|
+
operationId: "update-function-tool",
|
|
164
|
+
tags: ["Function Tools"],
|
|
165
|
+
request: {
|
|
166
|
+
params: TenantProjectAgentIdParamsSchema,
|
|
167
|
+
body: { content: { "application/json": { schema: FunctionToolApiUpdateSchema } } }
|
|
168
|
+
},
|
|
169
|
+
responses: {
|
|
170
|
+
200: {
|
|
171
|
+
description: "Function tool updated successfully",
|
|
172
|
+
content: { "application/json": { schema: FunctionToolResponse } }
|
|
173
|
+
},
|
|
174
|
+
...commonGetErrorResponses
|
|
175
|
+
}
|
|
176
|
+
}), async (c) => {
|
|
177
|
+
const { tenantId, projectId, agentId, id } = c.req.valid("param");
|
|
178
|
+
const body = c.req.valid("json");
|
|
179
|
+
try {
|
|
180
|
+
const functionTool = await updateFunctionTool(dbClient_default)({
|
|
181
|
+
scopes: {
|
|
182
|
+
tenantId,
|
|
183
|
+
projectId,
|
|
184
|
+
agentId
|
|
185
|
+
},
|
|
186
|
+
functionToolId: id,
|
|
187
|
+
data: body
|
|
188
|
+
});
|
|
189
|
+
if (!functionTool) return c.json(createApiError({
|
|
190
|
+
code: "not_found",
|
|
191
|
+
message: "Function tool not found"
|
|
192
|
+
}), 404);
|
|
193
|
+
return c.json({ data: functionTool });
|
|
194
|
+
} catch (error) {
|
|
195
|
+
logger.error({
|
|
196
|
+
error,
|
|
197
|
+
tenantId,
|
|
198
|
+
projectId,
|
|
199
|
+
agentId,
|
|
200
|
+
id,
|
|
201
|
+
body
|
|
202
|
+
}, "Failed to update function tool");
|
|
203
|
+
return c.json(createApiError({
|
|
204
|
+
code: "internal_server_error",
|
|
205
|
+
message: "Failed to update function tool"
|
|
206
|
+
}), 500);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
app.openapi(createRoute({
|
|
210
|
+
method: "delete",
|
|
211
|
+
path: "/{id}",
|
|
212
|
+
summary: "Delete Function Tool",
|
|
213
|
+
operationId: "delete-function-tool",
|
|
214
|
+
tags: ["Function Tools"],
|
|
215
|
+
request: { params: TenantProjectAgentIdParamsSchema },
|
|
216
|
+
responses: {
|
|
217
|
+
204: { description: "Function tool deleted successfully" },
|
|
218
|
+
...commonGetErrorResponses
|
|
219
|
+
}
|
|
220
|
+
}), async (c) => {
|
|
221
|
+
const { tenantId, projectId, agentId, id } = c.req.valid("param");
|
|
222
|
+
try {
|
|
223
|
+
if (!await deleteFunctionTool(dbClient_default)({
|
|
224
|
+
scopes: {
|
|
225
|
+
tenantId,
|
|
226
|
+
projectId,
|
|
227
|
+
agentId
|
|
228
|
+
},
|
|
229
|
+
functionToolId: id
|
|
230
|
+
})) return c.json(createApiError({
|
|
231
|
+
code: "not_found",
|
|
232
|
+
message: "Function tool not found"
|
|
233
|
+
}), 404);
|
|
234
|
+
return c.body(null, 204);
|
|
235
|
+
} catch (error) {
|
|
236
|
+
logger.error({
|
|
237
|
+
error,
|
|
238
|
+
tenantId,
|
|
239
|
+
projectId,
|
|
240
|
+
agentId,
|
|
241
|
+
id
|
|
242
|
+
}, "Failed to delete function tool");
|
|
243
|
+
return c.json(createApiError({
|
|
244
|
+
code: "internal_server_error",
|
|
245
|
+
message: "Failed to delete function tool"
|
|
246
|
+
}), 500);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
var functionTools_default = app;
|
|
250
|
+
|
|
251
|
+
//#endregion
|
|
252
|
+
export { functionTools_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/functions.d.ts
|
|
5
|
+
declare const app: OpenAPIHono<{
|
|
6
|
+
Variables: BaseAppVariables;
|
|
7
|
+
}, {}, "/">;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { app as default };
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { getLogger as getLogger$1 } from "../logger.js";
|
|
2
|
+
import dbClient_default from "../data/db/dbClient.js";
|
|
3
|
+
import { requirePermission } from "../middleware/require-permission.js";
|
|
4
|
+
import { speakeasyOffsetLimitPagination } from "./shared.js";
|
|
5
|
+
import { OpenAPIHono, createRoute } from "@hono/zod-openapi";
|
|
6
|
+
import { FunctionApiInsertSchema, FunctionApiUpdateSchema, FunctionListResponse, FunctionResponse, PaginationQueryParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, commonGetErrorResponses, createApiError, deleteFunction, generateId, getFunction, listFunctionsPaginated, upsertFunction } from "@inkeep/agents-core";
|
|
7
|
+
|
|
8
|
+
//#region src/routes/functions.ts
|
|
9
|
+
const logger = getLogger$1("functions");
|
|
10
|
+
const app = new OpenAPIHono();
|
|
11
|
+
app.use("/", async (c, next) => {
|
|
12
|
+
if (c.req.method === "POST") return requirePermission({ function: ["create"] })(c, next);
|
|
13
|
+
return next();
|
|
14
|
+
});
|
|
15
|
+
app.use("/:id", async (c, next) => {
|
|
16
|
+
if (c.req.method === "PUT") return requirePermission({ function: ["update"] })(c, next);
|
|
17
|
+
if (c.req.method === "DELETE") return requirePermission({ function: ["delete"] })(c, next);
|
|
18
|
+
return next();
|
|
19
|
+
});
|
|
20
|
+
app.openapi(createRoute({
|
|
21
|
+
method: "get",
|
|
22
|
+
path: "/",
|
|
23
|
+
summary: "List Functions",
|
|
24
|
+
operationId: "list-functions",
|
|
25
|
+
tags: ["Functions"],
|
|
26
|
+
request: {
|
|
27
|
+
params: TenantProjectParamsSchema,
|
|
28
|
+
query: PaginationQueryParamsSchema
|
|
29
|
+
},
|
|
30
|
+
responses: {
|
|
31
|
+
200: {
|
|
32
|
+
description: "List of functions",
|
|
33
|
+
content: { "application/json": { schema: FunctionListResponse } }
|
|
34
|
+
},
|
|
35
|
+
...commonGetErrorResponses
|
|
36
|
+
},
|
|
37
|
+
...speakeasyOffsetLimitPagination
|
|
38
|
+
}), async (c) => {
|
|
39
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
40
|
+
const page = Number(c.req.query("page")) || 1;
|
|
41
|
+
const limit = Math.min(Number(c.req.query("limit")) || 10, 100);
|
|
42
|
+
try {
|
|
43
|
+
const result = await listFunctionsPaginated(dbClient_default)({
|
|
44
|
+
scopes: {
|
|
45
|
+
tenantId,
|
|
46
|
+
projectId
|
|
47
|
+
},
|
|
48
|
+
pagination: {
|
|
49
|
+
page,
|
|
50
|
+
limit
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return c.json(result);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
logger.error({
|
|
56
|
+
error,
|
|
57
|
+
tenantId
|
|
58
|
+
}, "Failed to list functions");
|
|
59
|
+
return c.json(createApiError({
|
|
60
|
+
code: "internal_server_error",
|
|
61
|
+
message: "Failed to list functions"
|
|
62
|
+
}), 500);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
app.openapi(createRoute({
|
|
66
|
+
method: "get",
|
|
67
|
+
path: "/{id}",
|
|
68
|
+
summary: "Get Function by ID",
|
|
69
|
+
operationId: "get-function",
|
|
70
|
+
tags: ["Functions"],
|
|
71
|
+
request: { params: TenantProjectIdParamsSchema },
|
|
72
|
+
responses: {
|
|
73
|
+
200: {
|
|
74
|
+
description: "Function details",
|
|
75
|
+
content: { "application/json": { schema: FunctionResponse } }
|
|
76
|
+
},
|
|
77
|
+
...commonGetErrorResponses
|
|
78
|
+
}
|
|
79
|
+
}), async (c) => {
|
|
80
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
81
|
+
try {
|
|
82
|
+
const functionData = await getFunction(dbClient_default)({
|
|
83
|
+
functionId: id,
|
|
84
|
+
scopes: {
|
|
85
|
+
tenantId,
|
|
86
|
+
projectId
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
if (!functionData) return c.json(createApiError({
|
|
90
|
+
code: "not_found",
|
|
91
|
+
message: "Function not found"
|
|
92
|
+
}), 404);
|
|
93
|
+
return c.json({ data: functionData });
|
|
94
|
+
} catch (error) {
|
|
95
|
+
logger.error({
|
|
96
|
+
error,
|
|
97
|
+
tenantId,
|
|
98
|
+
id
|
|
99
|
+
}, "Failed to get function");
|
|
100
|
+
return c.json(createApiError({
|
|
101
|
+
code: "internal_server_error",
|
|
102
|
+
message: "Failed to get function"
|
|
103
|
+
}), 500);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
app.openapi(createRoute({
|
|
107
|
+
method: "post",
|
|
108
|
+
path: "/",
|
|
109
|
+
summary: "Create Function",
|
|
110
|
+
operationId: "create-function",
|
|
111
|
+
tags: ["Functions"],
|
|
112
|
+
request: {
|
|
113
|
+
params: TenantProjectParamsSchema,
|
|
114
|
+
body: { content: { "application/json": { schema: FunctionApiInsertSchema } } }
|
|
115
|
+
},
|
|
116
|
+
responses: {
|
|
117
|
+
201: {
|
|
118
|
+
description: "Function created",
|
|
119
|
+
content: { "application/json": { schema: FunctionResponse } }
|
|
120
|
+
},
|
|
121
|
+
...commonGetErrorResponses
|
|
122
|
+
}
|
|
123
|
+
}), async (c) => {
|
|
124
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
125
|
+
const functionData = c.req.valid("json");
|
|
126
|
+
try {
|
|
127
|
+
const id = functionData.id || generateId();
|
|
128
|
+
await upsertFunction(dbClient_default)({
|
|
129
|
+
data: {
|
|
130
|
+
...functionData,
|
|
131
|
+
id
|
|
132
|
+
},
|
|
133
|
+
scopes: {
|
|
134
|
+
tenantId,
|
|
135
|
+
projectId
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
const created = await getFunction(dbClient_default)({
|
|
139
|
+
functionId: id,
|
|
140
|
+
scopes: {
|
|
141
|
+
tenantId,
|
|
142
|
+
projectId
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
logger.info({
|
|
146
|
+
tenantId,
|
|
147
|
+
functionId: id
|
|
148
|
+
}, "Function created");
|
|
149
|
+
return c.json({ data: created }, 201);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
logger.error({
|
|
152
|
+
error,
|
|
153
|
+
tenantId,
|
|
154
|
+
functionData
|
|
155
|
+
}, "Failed to create function");
|
|
156
|
+
return c.json(createApiError({
|
|
157
|
+
code: "internal_server_error",
|
|
158
|
+
message: "Failed to create function"
|
|
159
|
+
}), 500);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
app.openapi(createRoute({
|
|
163
|
+
method: "put",
|
|
164
|
+
path: "/{id}",
|
|
165
|
+
summary: "Update Function",
|
|
166
|
+
operationId: "update-function",
|
|
167
|
+
tags: ["Functions"],
|
|
168
|
+
request: {
|
|
169
|
+
params: TenantProjectIdParamsSchema,
|
|
170
|
+
body: { content: { "application/json": { schema: FunctionApiUpdateSchema } } }
|
|
171
|
+
},
|
|
172
|
+
responses: {
|
|
173
|
+
200: {
|
|
174
|
+
description: "Function updated",
|
|
175
|
+
content: { "application/json": { schema: FunctionResponse } }
|
|
176
|
+
},
|
|
177
|
+
...commonGetErrorResponses
|
|
178
|
+
}
|
|
179
|
+
}), async (c) => {
|
|
180
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
181
|
+
const updateData = c.req.valid("json");
|
|
182
|
+
try {
|
|
183
|
+
const existing = await getFunction(dbClient_default)({
|
|
184
|
+
functionId: id,
|
|
185
|
+
scopes: {
|
|
186
|
+
tenantId,
|
|
187
|
+
projectId
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
if (!existing) return c.json(createApiError({
|
|
191
|
+
code: "not_found",
|
|
192
|
+
message: "Function not found"
|
|
193
|
+
}), 404);
|
|
194
|
+
await upsertFunction(dbClient_default)({
|
|
195
|
+
data: {
|
|
196
|
+
...existing,
|
|
197
|
+
...updateData,
|
|
198
|
+
id
|
|
199
|
+
},
|
|
200
|
+
scopes: {
|
|
201
|
+
tenantId,
|
|
202
|
+
projectId
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
const updated = await getFunction(dbClient_default)({
|
|
206
|
+
functionId: id,
|
|
207
|
+
scopes: {
|
|
208
|
+
tenantId,
|
|
209
|
+
projectId
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
logger.info({
|
|
213
|
+
tenantId,
|
|
214
|
+
functionId: id
|
|
215
|
+
}, "Function updated");
|
|
216
|
+
return c.json({ data: updated });
|
|
217
|
+
} catch (error) {
|
|
218
|
+
logger.error({
|
|
219
|
+
error,
|
|
220
|
+
tenantId,
|
|
221
|
+
id,
|
|
222
|
+
updateData
|
|
223
|
+
}, "Failed to update function");
|
|
224
|
+
return c.json(createApiError({
|
|
225
|
+
code: "internal_server_error",
|
|
226
|
+
message: "Failed to update function"
|
|
227
|
+
}), 500);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
app.openapi(createRoute({
|
|
231
|
+
method: "delete",
|
|
232
|
+
path: "/{id}",
|
|
233
|
+
summary: "Delete Function",
|
|
234
|
+
operationId: "delete-function",
|
|
235
|
+
tags: ["Functions"],
|
|
236
|
+
request: { params: TenantProjectIdParamsSchema },
|
|
237
|
+
responses: {
|
|
238
|
+
204: { description: "Function deleted" },
|
|
239
|
+
...commonGetErrorResponses
|
|
240
|
+
}
|
|
241
|
+
}), async (c) => {
|
|
242
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
243
|
+
try {
|
|
244
|
+
if (!await getFunction(dbClient_default)({
|
|
245
|
+
functionId: id,
|
|
246
|
+
scopes: {
|
|
247
|
+
tenantId,
|
|
248
|
+
projectId
|
|
249
|
+
}
|
|
250
|
+
})) return c.json(createApiError({
|
|
251
|
+
code: "not_found",
|
|
252
|
+
message: "Function not found"
|
|
253
|
+
}), 404);
|
|
254
|
+
await deleteFunction(dbClient_default)({
|
|
255
|
+
functionId: id,
|
|
256
|
+
scopes: {
|
|
257
|
+
tenantId,
|
|
258
|
+
projectId
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
logger.info({
|
|
262
|
+
tenantId,
|
|
263
|
+
functionId: id
|
|
264
|
+
}, "Function deleted");
|
|
265
|
+
return c.body(null, 204);
|
|
266
|
+
} catch (error) {
|
|
267
|
+
logger.error({
|
|
268
|
+
error,
|
|
269
|
+
tenantId,
|
|
270
|
+
id
|
|
271
|
+
}, "Failed to delete function");
|
|
272
|
+
return c.json(createApiError({
|
|
273
|
+
code: "internal_server_error",
|
|
274
|
+
message: "Failed to delete function"
|
|
275
|
+
}), 500);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
var functions_default = app;
|
|
279
|
+
|
|
280
|
+
//#endregion
|
|
281
|
+
export { functions_default as default };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import agent_default from "./agent.js";
|
|
2
|
+
import agentFull_default from "./agentFull.js";
|
|
3
|
+
import apiKeys_default from "./apiKeys.js";
|
|
4
|
+
import artifactComponents_default from "./artifactComponents.js";
|
|
5
|
+
import contextConfigs_default from "./contextConfigs.js";
|
|
6
|
+
import conversations_default from "./conversations.js";
|
|
7
|
+
import credentialStores_default from "./credentialStores.js";
|
|
8
|
+
import credentials_default from "./credentials.js";
|
|
9
|
+
import dataComponents_default from "./dataComponents.js";
|
|
10
|
+
import externalAgents_default from "./externalAgents.js";
|
|
11
|
+
import functions_default from "./functions.js";
|
|
12
|
+
import functionTools_default from "./functionTools.js";
|
|
13
|
+
import mcpCatalog_default from "./mcpCatalog.js";
|
|
14
|
+
import projects_default from "./projects.js";
|
|
15
|
+
import subAgentArtifactComponents_default from "./subAgentArtifactComponents.js";
|
|
16
|
+
import subAgentDataComponents_default from "./subAgentDataComponents.js";
|
|
17
|
+
import subAgentExternalAgentRelations_default from "./subAgentExternalAgentRelations.js";
|
|
18
|
+
import subAgentRelations_default from "./subAgentRelations.js";
|
|
19
|
+
import subAgents_default from "./subAgents.js";
|
|
20
|
+
import subAgentTeamAgentRelations_default from "./subAgentTeamAgentRelations.js";
|
|
21
|
+
import subAgentToolRelations_default from "./subAgentToolRelations.js";
|
|
22
|
+
import thirdPartyMCPServers_default from "./thirdPartyMCPServers.js";
|
|
23
|
+
import tools_default from "./tools.js";
|
|
24
|
+
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
25
|
+
|
|
26
|
+
//#region src/routes/index.ts
|
|
27
|
+
const app = new OpenAPIHono();
|
|
28
|
+
app.route("/projects", projects_default);
|
|
29
|
+
app.route("/projects/:projectId/agents/:agentId/sub-agents", subAgents_default);
|
|
30
|
+
app.route("/projects/:projectId/agents/:agentId/sub-agent-relations", subAgentRelations_default);
|
|
31
|
+
app.route("/projects/:projectId/agents/:agentId/sub-agents/:subAgentId/external-agent-relations", subAgentExternalAgentRelations_default);
|
|
32
|
+
app.route("/projects/:projectId/agents/:agentId/sub-agents/:subAgentId/team-agent-relations", subAgentTeamAgentRelations_default);
|
|
33
|
+
app.route("/projects/:projectId/agents", agent_default);
|
|
34
|
+
app.route("/projects/:projectId/agents/:agentId/sub-agent-tool-relations", subAgentToolRelations_default);
|
|
35
|
+
app.route("/projects/:projectId/agents/:agentId/sub-agent-artifact-components", subAgentArtifactComponents_default);
|
|
36
|
+
app.route("/projects/:projectId/agents/:agentId/sub-agent-data-components", subAgentDataComponents_default);
|
|
37
|
+
app.route("/projects/:projectId/artifact-components", artifactComponents_default);
|
|
38
|
+
app.route("/projects/:projectId/agents/:agentId/context-configs", contextConfigs_default);
|
|
39
|
+
app.route("/projects/:projectId/conversations", conversations_default);
|
|
40
|
+
app.route("/projects/:projectId/credentials", credentials_default);
|
|
41
|
+
app.route("/projects/:projectId/credential-stores", credentialStores_default);
|
|
42
|
+
app.route("/projects/:projectId/data-components", dataComponents_default);
|
|
43
|
+
app.route("/projects/:projectId/external-agents", externalAgents_default);
|
|
44
|
+
app.route("/projects/:projectId/agents/:agentId/function-tools", functionTools_default);
|
|
45
|
+
app.route("/projects/:projectId/functions", functions_default);
|
|
46
|
+
app.route("/projects/:projectId/tools", tools_default);
|
|
47
|
+
app.route("/projects/:projectId/api-keys", apiKeys_default);
|
|
48
|
+
app.route("/projects/:projectId/agent", agentFull_default);
|
|
49
|
+
app.route("/projects/:projectId/mcp-catalog", mcpCatalog_default);
|
|
50
|
+
app.route("/projects/:projectId/third-party-mcp-servers", thirdPartyMCPServers_default);
|
|
51
|
+
var routes_default = app;
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
export { routes_default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppVariables } from "../create-app.js";
|
|
2
|
+
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
3
|
+
|
|
4
|
+
//#region src/routes/invitations.d.ts
|
|
5
|
+
declare const invitationsRoutes: OpenAPIHono<{
|
|
6
|
+
Variables: AppVariables;
|
|
7
|
+
}, {}, "/">;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { invitationsRoutes as default };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import dbClient_default from "../data/db/dbClient.js";
|
|
2
|
+
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
3
|
+
import { getPendingInvitationsByEmail } from "@inkeep/agents-core";
|
|
4
|
+
|
|
5
|
+
//#region src/routes/invitations.ts
|
|
6
|
+
const invitationsRoutes = new OpenAPIHono();
|
|
7
|
+
const PendingInvitationSchema = z.object({
|
|
8
|
+
id: z.string(),
|
|
9
|
+
email: z.string(),
|
|
10
|
+
organizationId: z.string(),
|
|
11
|
+
organizationName: z.string().nullable(),
|
|
12
|
+
organizationSlug: z.string().nullable(),
|
|
13
|
+
role: z.string().nullable(),
|
|
14
|
+
status: z.string(),
|
|
15
|
+
expiresAt: z.number(),
|
|
16
|
+
inviterId: z.string()
|
|
17
|
+
});
|
|
18
|
+
const PendingInvitationsResponseSchema = z.array(PendingInvitationSchema);
|
|
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");
|
|
32
|
+
const response = (await getPendingInvitationsByEmail(dbClient_default)(email)).map((inv) => ({
|
|
33
|
+
...inv,
|
|
34
|
+
expiresAt: inv.expiresAt instanceof Date ? inv.expiresAt.getTime() : inv.expiresAt
|
|
35
|
+
}));
|
|
36
|
+
return c.json(response);
|
|
37
|
+
});
|
|
38
|
+
var invitations_default = invitationsRoutes;
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { invitations_default as default };
|