@inkeep/agents-manage-api 0.39.5 → 0.41.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 +163 -57
- 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 +64 -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 +206 -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,204 @@
|
|
|
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 { CredentialReferenceApiInsertSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiUpdateSchema, CredentialReferenceListResponse, CredentialReferenceResponse, ErrorResponseSchema, ListResponseSchema, PaginationQueryParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, commonGetErrorResponses, createApiError, createCredentialReference, deleteCredentialReference, getCredentialReferenceById, getCredentialReferenceWithResources, getCredentialStoreLookupKeyFromRetrievalParams, listCredentialReferencesPaginated, updateCredentialReference } from "@inkeep/agents-core";
|
|
6
|
+
|
|
7
|
+
//#region src/routes/credentials.ts
|
|
8
|
+
const app = new OpenAPIHono();
|
|
9
|
+
app.use("/", async (c, next) => {
|
|
10
|
+
if (c.req.method === "POST") return requirePermission({ credential: ["create"] })(c, next);
|
|
11
|
+
return next();
|
|
12
|
+
});
|
|
13
|
+
app.use("/:id", async (c, next) => {
|
|
14
|
+
if (c.req.method === "PATCH") return requirePermission({ credential: ["update"] })(c, next);
|
|
15
|
+
if (c.req.method === "DELETE") return requirePermission({ credential: ["delete"] })(c, next);
|
|
16
|
+
return next();
|
|
17
|
+
});
|
|
18
|
+
app.openapi(createRoute({
|
|
19
|
+
method: "get",
|
|
20
|
+
path: "/",
|
|
21
|
+
summary: "List Credentials",
|
|
22
|
+
operationId: "list-credentials",
|
|
23
|
+
tags: ["Credential"],
|
|
24
|
+
request: {
|
|
25
|
+
params: TenantProjectParamsSchema,
|
|
26
|
+
query: PaginationQueryParamsSchema
|
|
27
|
+
},
|
|
28
|
+
responses: {
|
|
29
|
+
200: {
|
|
30
|
+
description: "List of credentials retrieved successfully",
|
|
31
|
+
content: { "application/json": { schema: CredentialReferenceListResponse } }
|
|
32
|
+
},
|
|
33
|
+
...commonGetErrorResponses
|
|
34
|
+
},
|
|
35
|
+
...speakeasyOffsetLimitPagination
|
|
36
|
+
}), async (c) => {
|
|
37
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
38
|
+
const page = Number(c.req.query("page")) || 1;
|
|
39
|
+
const limit = Math.min(Number(c.req.query("limit")) || 10, 100);
|
|
40
|
+
const result = await listCredentialReferencesPaginated(dbClient_default)({
|
|
41
|
+
scopes: {
|
|
42
|
+
tenantId,
|
|
43
|
+
projectId
|
|
44
|
+
},
|
|
45
|
+
pagination: {
|
|
46
|
+
page,
|
|
47
|
+
limit
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const validatedResult = ListResponseSchema(CredentialReferenceApiSelectSchema).parse(result);
|
|
51
|
+
return c.json(validatedResult);
|
|
52
|
+
});
|
|
53
|
+
app.openapi(createRoute({
|
|
54
|
+
method: "get",
|
|
55
|
+
path: "/{id}",
|
|
56
|
+
summary: "Get Credential",
|
|
57
|
+
operationId: "get-credential-by-id",
|
|
58
|
+
tags: ["Credential"],
|
|
59
|
+
request: { params: TenantProjectIdParamsSchema },
|
|
60
|
+
responses: {
|
|
61
|
+
200: {
|
|
62
|
+
description: "Credential found",
|
|
63
|
+
content: { "application/json": { schema: CredentialReferenceResponse } }
|
|
64
|
+
},
|
|
65
|
+
...commonGetErrorResponses
|
|
66
|
+
}
|
|
67
|
+
}), async (c) => {
|
|
68
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
69
|
+
const credential = await getCredentialReferenceWithResources(dbClient_default)({
|
|
70
|
+
scopes: {
|
|
71
|
+
tenantId,
|
|
72
|
+
projectId
|
|
73
|
+
},
|
|
74
|
+
id
|
|
75
|
+
});
|
|
76
|
+
if (!credential) throw createApiError({
|
|
77
|
+
code: "not_found",
|
|
78
|
+
message: "Credential not found"
|
|
79
|
+
});
|
|
80
|
+
const validatedCredential = CredentialReferenceApiSelectSchema.parse(credential);
|
|
81
|
+
return c.json({ data: validatedCredential });
|
|
82
|
+
});
|
|
83
|
+
app.openapi(createRoute({
|
|
84
|
+
method: "post",
|
|
85
|
+
path: "/",
|
|
86
|
+
summary: "Create Credential",
|
|
87
|
+
operationId: "create-credential",
|
|
88
|
+
tags: ["Credential"],
|
|
89
|
+
request: {
|
|
90
|
+
params: TenantProjectParamsSchema,
|
|
91
|
+
body: { content: { "application/json": { schema: CredentialReferenceApiInsertSchema } } }
|
|
92
|
+
},
|
|
93
|
+
responses: {
|
|
94
|
+
201: {
|
|
95
|
+
description: "Credential created successfully",
|
|
96
|
+
content: { "application/json": { schema: CredentialReferenceResponse } }
|
|
97
|
+
},
|
|
98
|
+
...commonGetErrorResponses
|
|
99
|
+
}
|
|
100
|
+
}), async (c) => {
|
|
101
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
102
|
+
const credentialData = {
|
|
103
|
+
...c.req.valid("json"),
|
|
104
|
+
tenantId,
|
|
105
|
+
projectId
|
|
106
|
+
};
|
|
107
|
+
const credential = await createCredentialReference(dbClient_default)(credentialData);
|
|
108
|
+
const validatedCredential = CredentialReferenceApiSelectSchema.parse(credential);
|
|
109
|
+
return c.json({ data: validatedCredential }, 201);
|
|
110
|
+
});
|
|
111
|
+
app.openapi(createRoute({
|
|
112
|
+
method: "put",
|
|
113
|
+
path: "/{id}",
|
|
114
|
+
summary: "Update Credential",
|
|
115
|
+
operationId: "update-credential",
|
|
116
|
+
tags: ["Credential"],
|
|
117
|
+
request: {
|
|
118
|
+
params: TenantProjectIdParamsSchema,
|
|
119
|
+
body: { content: { "application/json": { schema: CredentialReferenceApiUpdateSchema } } }
|
|
120
|
+
},
|
|
121
|
+
responses: {
|
|
122
|
+
200: {
|
|
123
|
+
description: "Credential updated successfully",
|
|
124
|
+
content: { "application/json": { schema: CredentialReferenceResponse } }
|
|
125
|
+
},
|
|
126
|
+
...commonGetErrorResponses
|
|
127
|
+
}
|
|
128
|
+
}), async (c) => {
|
|
129
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
130
|
+
const body = c.req.valid("json");
|
|
131
|
+
const updatedCredential = await updateCredentialReference(dbClient_default)({
|
|
132
|
+
scopes: {
|
|
133
|
+
tenantId,
|
|
134
|
+
projectId
|
|
135
|
+
},
|
|
136
|
+
id,
|
|
137
|
+
data: body
|
|
138
|
+
});
|
|
139
|
+
if (!updatedCredential) throw createApiError({
|
|
140
|
+
code: "not_found",
|
|
141
|
+
message: "Credential not found"
|
|
142
|
+
});
|
|
143
|
+
const validatedCredential = CredentialReferenceApiSelectSchema.parse(updatedCredential);
|
|
144
|
+
return c.json({ data: validatedCredential });
|
|
145
|
+
});
|
|
146
|
+
app.openapi(createRoute({
|
|
147
|
+
method: "delete",
|
|
148
|
+
path: "/{id}",
|
|
149
|
+
summary: "Delete Credential",
|
|
150
|
+
operationId: "delete-credential",
|
|
151
|
+
tags: ["Credential"],
|
|
152
|
+
request: { params: TenantProjectIdParamsSchema },
|
|
153
|
+
responses: {
|
|
154
|
+
204: { description: "Credential deleted successfully" },
|
|
155
|
+
404: {
|
|
156
|
+
description: "Credential not found",
|
|
157
|
+
content: { "application/json": { schema: ErrorResponseSchema } }
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}), async (c) => {
|
|
161
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
162
|
+
const credential = await getCredentialReferenceById(dbClient_default)({
|
|
163
|
+
scopes: {
|
|
164
|
+
tenantId,
|
|
165
|
+
projectId
|
|
166
|
+
},
|
|
167
|
+
id
|
|
168
|
+
});
|
|
169
|
+
if (!credential) throw createApiError({
|
|
170
|
+
code: "not_found",
|
|
171
|
+
message: "Credential not found"
|
|
172
|
+
});
|
|
173
|
+
const credentialStore = c.get("credentialStores").get(credential.credentialStoreId);
|
|
174
|
+
if (credentialStore && credential.retrievalParams) {
|
|
175
|
+
const lookupKey = getCredentialStoreLookupKeyFromRetrievalParams({
|
|
176
|
+
retrievalParams: credential.retrievalParams,
|
|
177
|
+
credentialStoreType: credentialStore.type
|
|
178
|
+
});
|
|
179
|
+
if (!lookupKey) throw createApiError({
|
|
180
|
+
code: "bad_request",
|
|
181
|
+
message: "Could not generate lookup key for credential store"
|
|
182
|
+
});
|
|
183
|
+
try {
|
|
184
|
+
await credentialStore.delete(lookupKey);
|
|
185
|
+
} catch (error) {
|
|
186
|
+
console.error(`Failed to delete credential from external store "${credential.credentialStoreId}":`, error);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (!await deleteCredentialReference(dbClient_default)({
|
|
190
|
+
scopes: {
|
|
191
|
+
tenantId,
|
|
192
|
+
projectId
|
|
193
|
+
},
|
|
194
|
+
id
|
|
195
|
+
})) throw createApiError({
|
|
196
|
+
code: "not_found",
|
|
197
|
+
message: "Failed to delete credential"
|
|
198
|
+
});
|
|
199
|
+
return c.body(null, 204);
|
|
200
|
+
});
|
|
201
|
+
var credentials_default = app;
|
|
202
|
+
|
|
203
|
+
//#endregion
|
|
204
|
+
export { credentials_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/dataComponents.d.ts
|
|
5
|
+
declare const app: OpenAPIHono<{
|
|
6
|
+
Variables: BaseAppVariables;
|
|
7
|
+
}, {}, "/">;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { app as default };
|
|
@@ -0,0 +1,188 @@
|
|
|
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 { DataComponentApiInsertSchema, DataComponentApiUpdateSchema, DataComponentListResponse, DataComponentResponse, ErrorResponseSchema, PaginationQueryParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, commonGetErrorResponses, createApiError, createDataComponent, deleteDataComponent, getDataComponent, listDataComponentsPaginated, updateDataComponent, validatePropsAsJsonSchema } from "@inkeep/agents-core";
|
|
6
|
+
|
|
7
|
+
//#region src/routes/dataComponents.ts
|
|
8
|
+
const app = new OpenAPIHono();
|
|
9
|
+
app.use("/", async (c, next) => {
|
|
10
|
+
if (c.req.method === "POST") return requirePermission({ data_component: ["create"] })(c, next);
|
|
11
|
+
return next();
|
|
12
|
+
});
|
|
13
|
+
app.use("/:id", async (c, next) => {
|
|
14
|
+
if (c.req.method === "PATCH") return requirePermission({ data_component: ["update"] })(c, next);
|
|
15
|
+
if (c.req.method === "DELETE") return requirePermission({ data_component: ["delete"] })(c, next);
|
|
16
|
+
return next();
|
|
17
|
+
});
|
|
18
|
+
app.openapi(createRoute({
|
|
19
|
+
method: "get",
|
|
20
|
+
path: "/",
|
|
21
|
+
summary: "List Data Components",
|
|
22
|
+
operationId: "list-data-components",
|
|
23
|
+
tags: ["Data Component"],
|
|
24
|
+
request: {
|
|
25
|
+
params: TenantProjectParamsSchema,
|
|
26
|
+
query: PaginationQueryParamsSchema
|
|
27
|
+
},
|
|
28
|
+
responses: {
|
|
29
|
+
200: {
|
|
30
|
+
description: "List of data components retrieved successfully",
|
|
31
|
+
content: { "application/json": { schema: DataComponentListResponse } }
|
|
32
|
+
},
|
|
33
|
+
...commonGetErrorResponses
|
|
34
|
+
},
|
|
35
|
+
...speakeasyOffsetLimitPagination
|
|
36
|
+
}), async (c) => {
|
|
37
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
38
|
+
const page = Number(c.req.query("page")) || 1;
|
|
39
|
+
const limit = Math.min(Number(c.req.query("limit")) || 10, 100);
|
|
40
|
+
const result = await listDataComponentsPaginated(dbClient_default)({
|
|
41
|
+
scopes: {
|
|
42
|
+
tenantId,
|
|
43
|
+
projectId
|
|
44
|
+
},
|
|
45
|
+
pagination: {
|
|
46
|
+
page,
|
|
47
|
+
limit
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return c.json(result);
|
|
51
|
+
});
|
|
52
|
+
app.openapi(createRoute({
|
|
53
|
+
method: "get",
|
|
54
|
+
path: "/{id}",
|
|
55
|
+
summary: "Get Data Component",
|
|
56
|
+
operationId: "get-data-component-by-id",
|
|
57
|
+
tags: ["Data Component"],
|
|
58
|
+
request: { params: TenantProjectIdParamsSchema },
|
|
59
|
+
responses: {
|
|
60
|
+
200: {
|
|
61
|
+
description: "Data component found",
|
|
62
|
+
content: { "application/json": { schema: DataComponentResponse } }
|
|
63
|
+
},
|
|
64
|
+
...commonGetErrorResponses
|
|
65
|
+
}
|
|
66
|
+
}), async (c) => {
|
|
67
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
68
|
+
const dataComponent = await getDataComponent(dbClient_default)({
|
|
69
|
+
scopes: {
|
|
70
|
+
tenantId,
|
|
71
|
+
projectId
|
|
72
|
+
},
|
|
73
|
+
dataComponentId: id
|
|
74
|
+
});
|
|
75
|
+
if (!dataComponent) throw createApiError({
|
|
76
|
+
code: "not_found",
|
|
77
|
+
message: "Data component not found"
|
|
78
|
+
});
|
|
79
|
+
return c.json({ data: dataComponent });
|
|
80
|
+
});
|
|
81
|
+
app.openapi(createRoute({
|
|
82
|
+
method: "post",
|
|
83
|
+
path: "/",
|
|
84
|
+
summary: "Create Data Component",
|
|
85
|
+
operationId: "create-data-component",
|
|
86
|
+
tags: ["Data Component"],
|
|
87
|
+
request: {
|
|
88
|
+
params: TenantProjectParamsSchema,
|
|
89
|
+
body: { content: { "application/json": { schema: DataComponentApiInsertSchema } } }
|
|
90
|
+
},
|
|
91
|
+
responses: {
|
|
92
|
+
201: {
|
|
93
|
+
description: "Data component created successfully",
|
|
94
|
+
content: { "application/json": { schema: DataComponentResponse } }
|
|
95
|
+
},
|
|
96
|
+
...commonGetErrorResponses
|
|
97
|
+
}
|
|
98
|
+
}), async (c) => {
|
|
99
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
100
|
+
const body = c.req.valid("json");
|
|
101
|
+
if (body.props) {
|
|
102
|
+
const propsValidation = validatePropsAsJsonSchema(body.props);
|
|
103
|
+
if (!propsValidation.isValid) throw createApiError({
|
|
104
|
+
code: "bad_request",
|
|
105
|
+
message: `Invalid props schema: ${propsValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ")}`
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const dataComponentData = {
|
|
109
|
+
...body,
|
|
110
|
+
tenantId,
|
|
111
|
+
projectId
|
|
112
|
+
};
|
|
113
|
+
const dataComponent = await createDataComponent(dbClient_default)(dataComponentData);
|
|
114
|
+
return c.json({ data: dataComponent }, 201);
|
|
115
|
+
});
|
|
116
|
+
app.openapi(createRoute({
|
|
117
|
+
method: "put",
|
|
118
|
+
path: "/{id}",
|
|
119
|
+
summary: "Update Data Component",
|
|
120
|
+
operationId: "update-data-component",
|
|
121
|
+
tags: ["Data Component"],
|
|
122
|
+
request: {
|
|
123
|
+
params: TenantProjectIdParamsSchema,
|
|
124
|
+
body: { content: { "application/json": { schema: DataComponentApiUpdateSchema } } }
|
|
125
|
+
},
|
|
126
|
+
responses: {
|
|
127
|
+
200: {
|
|
128
|
+
description: "Data component updated successfully",
|
|
129
|
+
content: { "application/json": { schema: DataComponentResponse } }
|
|
130
|
+
},
|
|
131
|
+
...commonGetErrorResponses
|
|
132
|
+
}
|
|
133
|
+
}), async (c) => {
|
|
134
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
135
|
+
const body = c.req.valid("json");
|
|
136
|
+
if (body.props !== void 0 && body.props !== null) {
|
|
137
|
+
const propsValidation = validatePropsAsJsonSchema(body.props);
|
|
138
|
+
if (!propsValidation.isValid) throw createApiError({
|
|
139
|
+
code: "bad_request",
|
|
140
|
+
message: `Invalid props schema: ${propsValidation.errors.map((e) => `${e.field}: ${e.message}`).join(", ")}`
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
const updatedDataComponent = await updateDataComponent(dbClient_default)({
|
|
144
|
+
scopes: {
|
|
145
|
+
tenantId,
|
|
146
|
+
projectId
|
|
147
|
+
},
|
|
148
|
+
dataComponentId: id,
|
|
149
|
+
data: body
|
|
150
|
+
});
|
|
151
|
+
if (!updatedDataComponent) throw createApiError({
|
|
152
|
+
code: "not_found",
|
|
153
|
+
message: "Data component not found"
|
|
154
|
+
});
|
|
155
|
+
return c.json({ data: updatedDataComponent });
|
|
156
|
+
});
|
|
157
|
+
app.openapi(createRoute({
|
|
158
|
+
method: "delete",
|
|
159
|
+
path: "/{id}",
|
|
160
|
+
summary: "Delete Data Component",
|
|
161
|
+
operationId: "delete-data-component",
|
|
162
|
+
tags: ["Data Component"],
|
|
163
|
+
request: { params: TenantProjectIdParamsSchema },
|
|
164
|
+
responses: {
|
|
165
|
+
204: { description: "Data component deleted successfully" },
|
|
166
|
+
404: {
|
|
167
|
+
description: "Data component not found",
|
|
168
|
+
content: { "application/json": { schema: ErrorResponseSchema } }
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}), async (c) => {
|
|
172
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
173
|
+
if (!await deleteDataComponent(dbClient_default)({
|
|
174
|
+
scopes: {
|
|
175
|
+
tenantId,
|
|
176
|
+
projectId
|
|
177
|
+
},
|
|
178
|
+
dataComponentId: id
|
|
179
|
+
})) throw createApiError({
|
|
180
|
+
code: "not_found",
|
|
181
|
+
message: "Data component not found"
|
|
182
|
+
});
|
|
183
|
+
return c.body(null, 204);
|
|
184
|
+
});
|
|
185
|
+
var dataComponents_default = app;
|
|
186
|
+
|
|
187
|
+
//#endregion
|
|
188
|
+
export { dataComponents_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/externalAgents.d.ts
|
|
5
|
+
declare const app: OpenAPIHono<{
|
|
6
|
+
Variables: BaseAppVariables;
|
|
7
|
+
}, {}, "/">;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { app as default };
|
|
@@ -0,0 +1,195 @@
|
|
|
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, ExternalAgentApiInsertSchema, ExternalAgentApiUpdateSchema, ExternalAgentListResponse, ExternalAgentResponse, PaginationQueryParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, commonGetErrorResponses, createApiError, createExternalAgent, deleteExternalAgent, generateId, getExternalAgent, listExternalAgentsPaginated, updateExternalAgent } from "@inkeep/agents-core";
|
|
6
|
+
|
|
7
|
+
//#region src/routes/externalAgents.ts
|
|
8
|
+
const app = new OpenAPIHono();
|
|
9
|
+
app.use("/", async (c, next) => {
|
|
10
|
+
if (c.req.method === "POST") return requirePermission({ external_agent: ["create"] })(c, next);
|
|
11
|
+
return next();
|
|
12
|
+
});
|
|
13
|
+
app.use("/:id", async (c, next) => {
|
|
14
|
+
if (c.req.method === "PATCH") return requirePermission({ external_agent: ["update"] })(c, next);
|
|
15
|
+
if (c.req.method === "DELETE") return requirePermission({ external_agent: ["delete"] })(c, next);
|
|
16
|
+
return next();
|
|
17
|
+
});
|
|
18
|
+
app.openapi(createRoute({
|
|
19
|
+
method: "get",
|
|
20
|
+
path: "/",
|
|
21
|
+
summary: "List External Agents",
|
|
22
|
+
operationId: "list-external-agents",
|
|
23
|
+
tags: ["External Agents"],
|
|
24
|
+
request: {
|
|
25
|
+
params: TenantProjectParamsSchema,
|
|
26
|
+
query: PaginationQueryParamsSchema
|
|
27
|
+
},
|
|
28
|
+
responses: {
|
|
29
|
+
200: {
|
|
30
|
+
description: "List of external agents retrieved successfully",
|
|
31
|
+
content: { "application/json": { schema: ExternalAgentListResponse } }
|
|
32
|
+
},
|
|
33
|
+
...commonGetErrorResponses
|
|
34
|
+
},
|
|
35
|
+
...speakeasyOffsetLimitPagination
|
|
36
|
+
}), async (c) => {
|
|
37
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
38
|
+
const { page, limit } = c.req.valid("query");
|
|
39
|
+
const result = await listExternalAgentsPaginated(dbClient_default)({
|
|
40
|
+
scopes: {
|
|
41
|
+
tenantId,
|
|
42
|
+
projectId
|
|
43
|
+
},
|
|
44
|
+
pagination: {
|
|
45
|
+
page,
|
|
46
|
+
limit
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const dataWithType = {
|
|
50
|
+
...result,
|
|
51
|
+
data: result.data.map((agent) => ({
|
|
52
|
+
...agent,
|
|
53
|
+
type: "external"
|
|
54
|
+
}))
|
|
55
|
+
};
|
|
56
|
+
return c.json(dataWithType);
|
|
57
|
+
});
|
|
58
|
+
app.openapi(createRoute({
|
|
59
|
+
method: "get",
|
|
60
|
+
path: "/{id}",
|
|
61
|
+
summary: "Get External Agent",
|
|
62
|
+
operationId: "get-external-agent-by-id",
|
|
63
|
+
tags: ["External Agents"],
|
|
64
|
+
request: { params: TenantProjectIdParamsSchema },
|
|
65
|
+
responses: {
|
|
66
|
+
200: {
|
|
67
|
+
description: "External agent found",
|
|
68
|
+
content: { "application/json": { schema: ExternalAgentResponse } }
|
|
69
|
+
},
|
|
70
|
+
...commonGetErrorResponses
|
|
71
|
+
}
|
|
72
|
+
}), async (c) => {
|
|
73
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
74
|
+
const externalAgent = await getExternalAgent(dbClient_default)({
|
|
75
|
+
scopes: {
|
|
76
|
+
tenantId,
|
|
77
|
+
projectId
|
|
78
|
+
},
|
|
79
|
+
externalAgentId: id
|
|
80
|
+
});
|
|
81
|
+
if (!externalAgent) throw createApiError({
|
|
82
|
+
code: "not_found",
|
|
83
|
+
message: "External agent not found"
|
|
84
|
+
});
|
|
85
|
+
const agentWithType = {
|
|
86
|
+
...externalAgent,
|
|
87
|
+
type: "external"
|
|
88
|
+
};
|
|
89
|
+
return c.json({ data: agentWithType });
|
|
90
|
+
});
|
|
91
|
+
app.openapi(createRoute({
|
|
92
|
+
method: "post",
|
|
93
|
+
path: "/",
|
|
94
|
+
summary: "Create External Agent",
|
|
95
|
+
operationId: "create-external-agent",
|
|
96
|
+
tags: ["External Agents"],
|
|
97
|
+
request: {
|
|
98
|
+
params: TenantProjectParamsSchema,
|
|
99
|
+
body: { content: { "application/json": { schema: ExternalAgentApiInsertSchema } } }
|
|
100
|
+
},
|
|
101
|
+
responses: {
|
|
102
|
+
201: {
|
|
103
|
+
description: "External agent created successfully",
|
|
104
|
+
content: { "application/json": { schema: ExternalAgentResponse } }
|
|
105
|
+
},
|
|
106
|
+
...commonGetErrorResponses
|
|
107
|
+
}
|
|
108
|
+
}), async (c) => {
|
|
109
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
110
|
+
const body = c.req.valid("json");
|
|
111
|
+
const externalAgentData = {
|
|
112
|
+
tenantId,
|
|
113
|
+
projectId,
|
|
114
|
+
id: body.id ? String(body.id) : generateId(),
|
|
115
|
+
name: body.name,
|
|
116
|
+
description: body.description,
|
|
117
|
+
baseUrl: body.baseUrl,
|
|
118
|
+
credentialReferenceId: body.credentialReferenceId || void 0
|
|
119
|
+
};
|
|
120
|
+
const agentWithType = {
|
|
121
|
+
...await createExternalAgent(dbClient_default)(externalAgentData),
|
|
122
|
+
type: "external"
|
|
123
|
+
};
|
|
124
|
+
return c.json({ data: agentWithType }, 201);
|
|
125
|
+
});
|
|
126
|
+
app.openapi(createRoute({
|
|
127
|
+
method: "put",
|
|
128
|
+
path: "/{id}",
|
|
129
|
+
summary: "Update External Agent",
|
|
130
|
+
operationId: "update-external-agent",
|
|
131
|
+
tags: ["External Agents"],
|
|
132
|
+
request: {
|
|
133
|
+
params: TenantProjectIdParamsSchema,
|
|
134
|
+
body: { content: { "application/json": { schema: ExternalAgentApiUpdateSchema } } }
|
|
135
|
+
},
|
|
136
|
+
responses: {
|
|
137
|
+
200: {
|
|
138
|
+
description: "External agent updated successfully",
|
|
139
|
+
content: { "application/json": { schema: ExternalAgentResponse } }
|
|
140
|
+
},
|
|
141
|
+
...commonGetErrorResponses
|
|
142
|
+
}
|
|
143
|
+
}), async (c) => {
|
|
144
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
145
|
+
const body = c.req.valid("json");
|
|
146
|
+
const updatedExternalAgent = await updateExternalAgent(dbClient_default)({
|
|
147
|
+
scopes: {
|
|
148
|
+
tenantId,
|
|
149
|
+
projectId
|
|
150
|
+
},
|
|
151
|
+
externalAgentId: id,
|
|
152
|
+
data: body
|
|
153
|
+
});
|
|
154
|
+
if (!updatedExternalAgent) throw createApiError({
|
|
155
|
+
code: "not_found",
|
|
156
|
+
message: "External agent not found"
|
|
157
|
+
});
|
|
158
|
+
const agentWithType = {
|
|
159
|
+
...updatedExternalAgent,
|
|
160
|
+
type: "external"
|
|
161
|
+
};
|
|
162
|
+
return c.json({ data: agentWithType });
|
|
163
|
+
});
|
|
164
|
+
app.openapi(createRoute({
|
|
165
|
+
method: "delete",
|
|
166
|
+
path: "/{id}",
|
|
167
|
+
summary: "Delete External Agent",
|
|
168
|
+
operationId: "delete-external-agent",
|
|
169
|
+
tags: ["External Agents"],
|
|
170
|
+
request: { params: TenantProjectIdParamsSchema },
|
|
171
|
+
responses: {
|
|
172
|
+
204: { description: "External agent deleted successfully" },
|
|
173
|
+
404: {
|
|
174
|
+
description: "External agent not found",
|
|
175
|
+
content: { "application/json": { schema: ErrorResponseSchema } }
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}), async (c) => {
|
|
179
|
+
const { tenantId, projectId, id } = c.req.valid("param");
|
|
180
|
+
if (!await deleteExternalAgent(dbClient_default)({
|
|
181
|
+
scopes: {
|
|
182
|
+
tenantId,
|
|
183
|
+
projectId
|
|
184
|
+
},
|
|
185
|
+
externalAgentId: id
|
|
186
|
+
})) throw createApiError({
|
|
187
|
+
code: "not_found",
|
|
188
|
+
message: "External agent not found"
|
|
189
|
+
});
|
|
190
|
+
return c.body(null, 204);
|
|
191
|
+
});
|
|
192
|
+
var externalAgents_default = app;
|
|
193
|
+
|
|
194
|
+
//#endregion
|
|
195
|
+
export { externalAgents_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/functionTools.d.ts
|
|
5
|
+
declare const app: OpenAPIHono<{
|
|
6
|
+
Variables: BaseAppVariables;
|
|
7
|
+
}, {}, "/">;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { app as default };
|