@inkeep/agents-manage-api 0.1.2 → 0.1.7
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/LICENSE.md +7 -0
- package/README.md +10 -10
- package/SUPPLEMENTAL_TERMS.md +40 -0
- package/dist/index.cjs +5365 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +13 -18
- package/dist/index.js +5334 -26
- package/package.json +11 -11
- package/dist/ManagementServer.d.ts +0 -28
- package/dist/ManagementServer.d.ts.map +0 -1
- package/dist/ManagementServer.js +0 -41
- package/dist/__tests__/setup.d.ts +0 -2
- package/dist/__tests__/setup.d.ts.map +0 -1
- package/dist/__tests__/setup.js +0 -26
- package/dist/__tests__/utils/testProject.d.ts +0 -18
- package/dist/__tests__/utils/testProject.d.ts.map +0 -1
- package/dist/__tests__/utils/testProject.js +0 -26
- package/dist/__tests__/utils/testRequest.d.ts +0 -2
- package/dist/__tests__/utils/testRequest.d.ts.map +0 -1
- package/dist/__tests__/utils/testRequest.js +0 -11
- package/dist/__tests__/utils/testTenant.d.ts +0 -64
- package/dist/__tests__/utils/testTenant.d.ts.map +0 -1
- package/dist/__tests__/utils/testTenant.js +0 -71
- package/dist/app.d.ts +0 -11
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js +0 -148
- package/dist/data/conversations.d.ts +0 -59
- package/dist/data/conversations.d.ts.map +0 -1
- package/dist/data/conversations.js +0 -216
- package/dist/data/db/clean.d.ts +0 -6
- package/dist/data/db/clean.d.ts.map +0 -1
- package/dist/data/db/clean.js +0 -77
- package/dist/data/db/dbClient.d.ts +0 -3
- package/dist/data/db/dbClient.d.ts.map +0 -1
- package/dist/data/db/dbClient.js +0 -13
- package/dist/data/graphFull.d.ts +0 -11
- package/dist/data/graphFull.d.ts.map +0 -1
- package/dist/data/graphFull.js +0 -90
- package/dist/data/graphFullClient.d.ts +0 -22
- package/dist/data/graphFullClient.d.ts.map +0 -1
- package/dist/data/graphFullClient.js +0 -189
- package/dist/data/tools.d.ts +0 -82
- package/dist/data/tools.d.ts.map +0 -1
- package/dist/data/tools.js +0 -271
- package/dist/env.d.ts +0 -41
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -59
- package/dist/index.d.ts.map +0 -1
- package/dist/logger.d.ts +0 -4
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -32
- package/dist/middleware/auth.d.ts +0 -12
- package/dist/middleware/auth.d.ts.map +0 -1
- package/dist/middleware/auth.js +0 -36
- package/dist/openapi.d.ts +0 -2
- package/dist/openapi.d.ts.map +0 -1
- package/dist/openapi.js +0 -38
- package/dist/routes/agentArtifactComponents.d.ts +0 -4
- package/dist/routes/agentArtifactComponents.d.ts.map +0 -1
- package/dist/routes/agentArtifactComponents.js +0 -230
- package/dist/routes/agentDataComponents.d.ts +0 -4
- package/dist/routes/agentDataComponents.d.ts.map +0 -1
- package/dist/routes/agentDataComponents.js +0 -225
- package/dist/routes/agentGraph.d.ts +0 -4
- package/dist/routes/agentGraph.d.ts.map +0 -1
- package/dist/routes/agentGraph.js +0 -289
- package/dist/routes/agentRelations.d.ts +0 -4
- package/dist/routes/agentRelations.d.ts.map +0 -1
- package/dist/routes/agentRelations.js +0 -290
- package/dist/routes/agentToolRelations.d.ts +0 -4
- package/dist/routes/agentToolRelations.d.ts.map +0 -1
- package/dist/routes/agentToolRelations.js +0 -342
- package/dist/routes/agents.d.ts +0 -4
- package/dist/routes/agents.d.ts.map +0 -1
- package/dist/routes/agents.js +0 -213
- package/dist/routes/apiKeys.d.ts +0 -4
- package/dist/routes/apiKeys.d.ts.map +0 -1
- package/dist/routes/apiKeys.js +0 -236
- package/dist/routes/artifactComponents.d.ts +0 -4
- package/dist/routes/artifactComponents.d.ts.map +0 -1
- package/dist/routes/artifactComponents.js +0 -202
- package/dist/routes/contextConfigs.d.ts +0 -4
- package/dist/routes/contextConfigs.d.ts.map +0 -1
- package/dist/routes/contextConfigs.js +0 -181
- package/dist/routes/credentials.d.ts +0 -10
- package/dist/routes/credentials.d.ts.map +0 -1
- package/dist/routes/credentials.js +0 -219
- package/dist/routes/dataComponents.d.ts +0 -4
- package/dist/routes/dataComponents.d.ts.map +0 -1
- package/dist/routes/dataComponents.js +0 -188
- package/dist/routes/externalAgents.d.ts +0 -4
- package/dist/routes/externalAgents.d.ts.map +0 -1
- package/dist/routes/externalAgents.js +0 -216
- package/dist/routes/graphFull.d.ts +0 -4
- package/dist/routes/graphFull.d.ts.map +0 -1
- package/dist/routes/graphFull.js +0 -248
- package/dist/routes/index.d.ts +0 -4
- package/dist/routes/index.d.ts.map +0 -1
- package/dist/routes/index.js +0 -37
- package/dist/routes/oauth.d.ts +0 -21
- package/dist/routes/oauth.d.ts.map +0 -1
- package/dist/routes/oauth.js +0 -191
- package/dist/routes/projects.d.ts +0 -4
- package/dist/routes/projects.d.ts.map +0 -1
- package/dist/routes/projects.js +0 -221
- package/dist/routes/tools.d.ts +0 -11
- package/dist/routes/tools.d.ts.map +0 -1
- package/dist/routes/tools.js +0 -555
- package/dist/utils/auth-detection.d.ts +0 -22
- package/dist/utils/auth-detection.d.ts.map +0 -1
- package/dist/utils/auth-detection.js +0 -149
- package/dist/utils/oauth-service.d.ts +0 -88
- package/dist/utils/oauth-service.d.ts.map +0 -1
- package/dist/utils/oauth-service.js +0 -240
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { getAgentById } from '@inkeep/agents-core';
|
|
4
|
-
import { commonGetErrorResponses, createApiError } from '@inkeep/agents-core';
|
|
5
|
-
import { AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiSelectSchema, ErrorResponseSchema, SingleResponseSchema, TenantProjectParamsSchema, ArtifactComponentApiSelectSchema, associateArtifactComponentWithAgent, getAgentsUsingArtifactComponent, getArtifactComponentById, getArtifactComponentsForAgent, isArtifactComponentAssociatedWithAgent, removeArtifactComponentFromAgent, RemovedResponseSchema, ExistsResponseSchema, } from '@inkeep/agents-core';
|
|
6
|
-
import dbClient from '../data/db/dbClient.js';
|
|
7
|
-
const app = new OpenAPIHono();
|
|
8
|
-
// List artifact components for a specific agent in a graph
|
|
9
|
-
app.openapi(createRoute({
|
|
10
|
-
method: 'get',
|
|
11
|
-
path: '/agent/:agentId',
|
|
12
|
-
summary: 'Get Artifact Components for Agent',
|
|
13
|
-
operationId: 'get-artifact-components-for-agent',
|
|
14
|
-
tags: ['CRUD Agent Artifact Component Relations'],
|
|
15
|
-
request: {
|
|
16
|
-
params: TenantProjectParamsSchema.extend({
|
|
17
|
-
agentId: z.string(),
|
|
18
|
-
}),
|
|
19
|
-
},
|
|
20
|
-
responses: {
|
|
21
|
-
200: {
|
|
22
|
-
description: 'Artifact components retrieved successfully',
|
|
23
|
-
content: {
|
|
24
|
-
'application/json': {
|
|
25
|
-
schema: z.object({
|
|
26
|
-
data: z.array(ArtifactComponentApiSelectSchema),
|
|
27
|
-
}),
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
...commonGetErrorResponses,
|
|
32
|
-
},
|
|
33
|
-
}), async (c) => {
|
|
34
|
-
const { tenantId, projectId, agentId } = c.req.valid('param');
|
|
35
|
-
const artifactComponents = await getArtifactComponentsForAgent(dbClient)({
|
|
36
|
-
scopes: { tenantId, projectId },
|
|
37
|
-
agentId,
|
|
38
|
-
});
|
|
39
|
-
return c.json({
|
|
40
|
-
data: artifactComponents,
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
// List agents using a specific artifact component
|
|
44
|
-
app.openapi(createRoute({
|
|
45
|
-
method: 'get',
|
|
46
|
-
path: '/component/:artifactComponentId/agents',
|
|
47
|
-
summary: 'Get Agents Using Artifact Component',
|
|
48
|
-
operationId: 'get-agents-using-artifact-component',
|
|
49
|
-
tags: ['CRUD Agent Artifact Component Relations'],
|
|
50
|
-
request: {
|
|
51
|
-
params: TenantProjectParamsSchema.extend({
|
|
52
|
-
artifactComponentId: z.string(),
|
|
53
|
-
}),
|
|
54
|
-
},
|
|
55
|
-
responses: {
|
|
56
|
-
200: {
|
|
57
|
-
description: 'Agents retrieved successfully',
|
|
58
|
-
content: {
|
|
59
|
-
'application/json': {
|
|
60
|
-
schema: z.object({
|
|
61
|
-
data: z.array(z.object({
|
|
62
|
-
agentId: z.string(),
|
|
63
|
-
createdAt: z.string(),
|
|
64
|
-
})),
|
|
65
|
-
}),
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
...commonGetErrorResponses,
|
|
70
|
-
},
|
|
71
|
-
}), async (c) => {
|
|
72
|
-
const { tenantId, projectId, artifactComponentId } = c.req.valid('param');
|
|
73
|
-
const agents = await getAgentsUsingArtifactComponent(dbClient)({
|
|
74
|
-
scopes: { tenantId, projectId },
|
|
75
|
-
artifactComponentId,
|
|
76
|
-
});
|
|
77
|
-
return c.json({ data: agents });
|
|
78
|
-
});
|
|
79
|
-
// Create agent artifact component association
|
|
80
|
-
app.openapi(createRoute({
|
|
81
|
-
method: 'post',
|
|
82
|
-
path: '/',
|
|
83
|
-
summary: 'Associate Artifact Component with Agent',
|
|
84
|
-
operationId: 'associate-artifact-component-with-agent',
|
|
85
|
-
tags: ['CRUD Agent Artifact Component Relations'],
|
|
86
|
-
request: {
|
|
87
|
-
params: TenantProjectParamsSchema,
|
|
88
|
-
body: {
|
|
89
|
-
content: {
|
|
90
|
-
'application/json': {
|
|
91
|
-
schema: AgentArtifactComponentApiInsertSchema,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
responses: {
|
|
97
|
-
201: {
|
|
98
|
-
description: 'Agent artifact component association created successfully',
|
|
99
|
-
content: {
|
|
100
|
-
'application/json': {
|
|
101
|
-
schema: SingleResponseSchema(AgentArtifactComponentApiSelectSchema),
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
409: {
|
|
106
|
-
description: 'Association already exists',
|
|
107
|
-
content: {
|
|
108
|
-
'application/json': {
|
|
109
|
-
schema: ErrorResponseSchema,
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
...commonGetErrorResponses,
|
|
114
|
-
},
|
|
115
|
-
}), async (c) => {
|
|
116
|
-
const { tenantId, projectId } = c.req.valid('param');
|
|
117
|
-
const { agentId, artifactComponentId } = c.req.valid('json');
|
|
118
|
-
// Validate that both agent and artifact component exist before creating association
|
|
119
|
-
const agent = await getAgentById(dbClient)({ scopes: { tenantId, projectId }, agentId });
|
|
120
|
-
const artifactComponent = await getArtifactComponentById(dbClient)({
|
|
121
|
-
scopes: { tenantId, projectId },
|
|
122
|
-
id: artifactComponentId,
|
|
123
|
-
});
|
|
124
|
-
if (!agent) {
|
|
125
|
-
throw createApiError({
|
|
126
|
-
code: 'not_found',
|
|
127
|
-
message: `Agent with id '${agentId}' not found`,
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
if (!artifactComponent) {
|
|
131
|
-
throw createApiError({
|
|
132
|
-
code: 'not_found',
|
|
133
|
-
message: `Artifact component with id '${artifactComponentId}' not found`,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
// Check if association already exists
|
|
137
|
-
const exists = await isArtifactComponentAssociatedWithAgent(dbClient)({
|
|
138
|
-
scopes: { tenantId, projectId },
|
|
139
|
-
agentId,
|
|
140
|
-
artifactComponentId,
|
|
141
|
-
});
|
|
142
|
-
if (exists) {
|
|
143
|
-
throw createApiError({
|
|
144
|
-
code: 'conflict',
|
|
145
|
-
message: 'Agent artifact component association already exists',
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
const association = await associateArtifactComponentWithAgent(dbClient)({
|
|
149
|
-
scopes: { tenantId, projectId },
|
|
150
|
-
agentId,
|
|
151
|
-
artifactComponentId,
|
|
152
|
-
});
|
|
153
|
-
return c.json({ data: association }, 201);
|
|
154
|
-
});
|
|
155
|
-
// Remove agent artifact component association
|
|
156
|
-
app.openapi(createRoute({
|
|
157
|
-
method: 'delete',
|
|
158
|
-
path: '/agent/:agentId/component/:artifactComponentId',
|
|
159
|
-
summary: 'Remove Artifact Component from Agent',
|
|
160
|
-
operationId: 'remove-artifact-component-from-agent',
|
|
161
|
-
tags: ['CRUD Agent Artifact Component Relations'],
|
|
162
|
-
request: {
|
|
163
|
-
params: TenantProjectParamsSchema.extend({
|
|
164
|
-
agentId: z.string(),
|
|
165
|
-
artifactComponentId: z.string(),
|
|
166
|
-
}),
|
|
167
|
-
},
|
|
168
|
-
responses: {
|
|
169
|
-
200: {
|
|
170
|
-
description: 'Association removed successfully',
|
|
171
|
-
content: {
|
|
172
|
-
'application/json': {
|
|
173
|
-
schema: RemovedResponseSchema,
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
...commonGetErrorResponses,
|
|
178
|
-
},
|
|
179
|
-
}), async (c) => {
|
|
180
|
-
const { tenantId, projectId, agentId, artifactComponentId } = c.req.valid('param');
|
|
181
|
-
const removed = await removeArtifactComponentFromAgent(dbClient)({
|
|
182
|
-
scopes: { tenantId, projectId },
|
|
183
|
-
agentId,
|
|
184
|
-
artifactComponentId,
|
|
185
|
-
});
|
|
186
|
-
if (!removed) {
|
|
187
|
-
throw createApiError({
|
|
188
|
-
code: 'not_found',
|
|
189
|
-
message: 'Agent artifact component association not found',
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
return c.json({
|
|
193
|
-
message: 'Association removed successfully',
|
|
194
|
-
removed: true,
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
// Check if artifact component is associated with agent
|
|
198
|
-
app.openapi(createRoute({
|
|
199
|
-
method: 'get',
|
|
200
|
-
path: '/agent/:agentId/component/:artifactComponentId/exists',
|
|
201
|
-
summary: 'Check if Artifact Component is Associated with Agent',
|
|
202
|
-
operationId: 'check-artifact-component-agent-association',
|
|
203
|
-
tags: ['CRUD Agent Artifact Component Relations'],
|
|
204
|
-
request: {
|
|
205
|
-
params: TenantProjectParamsSchema.extend({
|
|
206
|
-
agentId: z.string(),
|
|
207
|
-
artifactComponentId: z.string(),
|
|
208
|
-
}),
|
|
209
|
-
},
|
|
210
|
-
responses: {
|
|
211
|
-
200: {
|
|
212
|
-
description: 'Association status retrieved successfully',
|
|
213
|
-
content: {
|
|
214
|
-
'application/json': {
|
|
215
|
-
schema: ExistsResponseSchema,
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
...commonGetErrorResponses,
|
|
220
|
-
},
|
|
221
|
-
}), async (c) => {
|
|
222
|
-
const { tenantId, projectId, agentId, artifactComponentId } = c.req.valid('param');
|
|
223
|
-
const exists = await isArtifactComponentAssociatedWithAgent(dbClient)({
|
|
224
|
-
scopes: { tenantId, projectId },
|
|
225
|
-
agentId,
|
|
226
|
-
artifactComponentId,
|
|
227
|
-
});
|
|
228
|
-
return c.json({ exists });
|
|
229
|
-
});
|
|
230
|
-
export default app;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agentDataComponents.d.ts","sourceRoot":"","sources":["../../src/routes/agentDataComponents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAsB7D,QAAA,MAAM,GAAG,0CAAoB,CAAC;AAkQ9B,eAAe,GAAG,CAAC"}
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { associateDataComponentWithAgent, getAgentsUsingDataComponent, getDataComponentsForAgent, getDataComponent, getAgentById, isDataComponentAssociatedWithAgent, removeDataComponentFromAgent, AgentDataComponentApiInsertSchema, AgentDataComponentApiSelectSchema, DataComponentApiSelectSchema, ErrorResponseSchema, SingleResponseSchema, TenantProjectParamsSchema, RemovedResponseSchema, ExistsResponseSchema, } from '@inkeep/agents-core';
|
|
4
|
-
import { commonGetErrorResponses, createApiError } from '@inkeep/agents-core';
|
|
5
|
-
import dbClient from '../data/db/dbClient.js';
|
|
6
|
-
const app = new OpenAPIHono();
|
|
7
|
-
// List data components for a specific agent in a graph
|
|
8
|
-
app.openapi(createRoute({
|
|
9
|
-
method: 'get',
|
|
10
|
-
path: '/agent/:agentId',
|
|
11
|
-
summary: 'Get Data Components for Agent',
|
|
12
|
-
operationId: 'get-data-components-for-agent',
|
|
13
|
-
tags: ['CRUD Agent Data Component Relations'],
|
|
14
|
-
request: {
|
|
15
|
-
params: TenantProjectParamsSchema.extend({
|
|
16
|
-
agentId: z.string(),
|
|
17
|
-
}),
|
|
18
|
-
},
|
|
19
|
-
responses: {
|
|
20
|
-
200: {
|
|
21
|
-
description: 'Data components retrieved successfully',
|
|
22
|
-
content: {
|
|
23
|
-
'application/json': {
|
|
24
|
-
schema: z.object({
|
|
25
|
-
data: z.array(DataComponentApiSelectSchema),
|
|
26
|
-
}),
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
...commonGetErrorResponses,
|
|
31
|
-
},
|
|
32
|
-
}), async (c) => {
|
|
33
|
-
const { tenantId, projectId, agentId } = c.req.valid('param');
|
|
34
|
-
const dataComponents = await getDataComponentsForAgent(dbClient)({
|
|
35
|
-
scopes: { tenantId, projectId },
|
|
36
|
-
agentId,
|
|
37
|
-
});
|
|
38
|
-
return c.json({ data: dataComponents });
|
|
39
|
-
});
|
|
40
|
-
// List agent ids using a specific data component
|
|
41
|
-
app.openapi(createRoute({
|
|
42
|
-
method: 'get',
|
|
43
|
-
path: '/component/:dataComponentId/agents',
|
|
44
|
-
summary: 'Get Agents Using Data Component',
|
|
45
|
-
operationId: 'get-agents-using-data-component',
|
|
46
|
-
tags: ['CRUD Agent Data Component Relations'],
|
|
47
|
-
request: {
|
|
48
|
-
params: TenantProjectParamsSchema.extend({
|
|
49
|
-
dataComponentId: z.string(),
|
|
50
|
-
}),
|
|
51
|
-
},
|
|
52
|
-
responses: {
|
|
53
|
-
200: {
|
|
54
|
-
description: 'Agents retrieved successfully',
|
|
55
|
-
content: {
|
|
56
|
-
'application/json': {
|
|
57
|
-
schema: z.object({
|
|
58
|
-
data: z.array(z.object({
|
|
59
|
-
agentId: z.string(),
|
|
60
|
-
createdAt: z.string(),
|
|
61
|
-
})),
|
|
62
|
-
}),
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
...commonGetErrorResponses,
|
|
67
|
-
},
|
|
68
|
-
}), async (c) => {
|
|
69
|
-
const { tenantId, projectId, dataComponentId } = c.req.valid('param');
|
|
70
|
-
const agents = await getAgentsUsingDataComponent(dbClient)({
|
|
71
|
-
scopes: { tenantId, projectId },
|
|
72
|
-
dataComponentId,
|
|
73
|
-
});
|
|
74
|
-
return c.json({ data: agents });
|
|
75
|
-
});
|
|
76
|
-
// Create agent data component association
|
|
77
|
-
app.openapi(createRoute({
|
|
78
|
-
method: 'post',
|
|
79
|
-
path: '/',
|
|
80
|
-
summary: 'Associate Data Component with Agent',
|
|
81
|
-
operationId: 'associate-data-component-with-agent',
|
|
82
|
-
tags: ['CRUD Agent Data Component Relations'],
|
|
83
|
-
request: {
|
|
84
|
-
params: TenantProjectParamsSchema,
|
|
85
|
-
body: {
|
|
86
|
-
content: {
|
|
87
|
-
'application/json': {
|
|
88
|
-
schema: AgentDataComponentApiInsertSchema,
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
responses: {
|
|
94
|
-
201: {
|
|
95
|
-
description: 'Agent data component association created successfully',
|
|
96
|
-
content: {
|
|
97
|
-
'application/json': {
|
|
98
|
-
schema: SingleResponseSchema(AgentDataComponentApiSelectSchema),
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
409: {
|
|
103
|
-
description: 'Association already exists',
|
|
104
|
-
content: {
|
|
105
|
-
'application/json': {
|
|
106
|
-
schema: ErrorResponseSchema,
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
...commonGetErrorResponses,
|
|
111
|
-
},
|
|
112
|
-
}), async (c) => {
|
|
113
|
-
const { tenantId, projectId } = c.req.valid('param');
|
|
114
|
-
const { agentId, dataComponentId } = c.req.valid('json');
|
|
115
|
-
const [agent, dataComponent] = await Promise.all([
|
|
116
|
-
getAgentById(dbClient)({ scopes: { tenantId, projectId }, agentId }),
|
|
117
|
-
getDataComponent(dbClient)({ scopes: { tenantId, projectId }, dataComponentId }),
|
|
118
|
-
]);
|
|
119
|
-
if (!agent) {
|
|
120
|
-
throw createApiError({
|
|
121
|
-
code: 'not_found',
|
|
122
|
-
message: `Agent with id '${agentId}' not found`,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
if (!dataComponent) {
|
|
126
|
-
throw createApiError({
|
|
127
|
-
code: 'not_found',
|
|
128
|
-
message: `Data component with id '${dataComponentId}' not found`,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
// Check if association already exists
|
|
132
|
-
const exists = await isDataComponentAssociatedWithAgent(dbClient)({
|
|
133
|
-
scopes: { tenantId, projectId },
|
|
134
|
-
agentId,
|
|
135
|
-
dataComponentId,
|
|
136
|
-
});
|
|
137
|
-
if (exists) {
|
|
138
|
-
throw createApiError({
|
|
139
|
-
code: 'conflict',
|
|
140
|
-
message: 'Agent data component association already exists',
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
const association = await associateDataComponentWithAgent(dbClient)({
|
|
144
|
-
scopes: { tenantId, projectId },
|
|
145
|
-
agentId,
|
|
146
|
-
dataComponentId,
|
|
147
|
-
});
|
|
148
|
-
return c.json({ data: association }, 201);
|
|
149
|
-
});
|
|
150
|
-
// Remove agent data component association
|
|
151
|
-
app.openapi(createRoute({
|
|
152
|
-
method: 'delete',
|
|
153
|
-
path: '/agent/:agentId/component/:dataComponentId',
|
|
154
|
-
summary: 'Remove Data Component from Agent',
|
|
155
|
-
operationId: 'remove-data-component-from-agent',
|
|
156
|
-
tags: ['CRUD Agent Data Component Relations'],
|
|
157
|
-
request: {
|
|
158
|
-
params: TenantProjectParamsSchema.extend({
|
|
159
|
-
agentId: z.string(),
|
|
160
|
-
dataComponentId: z.string(),
|
|
161
|
-
}),
|
|
162
|
-
},
|
|
163
|
-
responses: {
|
|
164
|
-
200: {
|
|
165
|
-
description: 'Association removed successfully',
|
|
166
|
-
content: {
|
|
167
|
-
'application/json': {
|
|
168
|
-
schema: RemovedResponseSchema,
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
...commonGetErrorResponses,
|
|
173
|
-
},
|
|
174
|
-
}), async (c) => {
|
|
175
|
-
const { tenantId, projectId, agentId, dataComponentId } = c.req.valid('param');
|
|
176
|
-
const removed = await removeDataComponentFromAgent(dbClient)({
|
|
177
|
-
scopes: { tenantId, projectId },
|
|
178
|
-
agentId,
|
|
179
|
-
dataComponentId,
|
|
180
|
-
});
|
|
181
|
-
if (!removed) {
|
|
182
|
-
throw createApiError({
|
|
183
|
-
code: 'not_found',
|
|
184
|
-
message: 'Agent data component association not found',
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
return c.json({
|
|
188
|
-
message: 'Association removed successfully',
|
|
189
|
-
removed: true,
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
// Check if data component is associated with agent
|
|
193
|
-
app.openapi(createRoute({
|
|
194
|
-
method: 'get',
|
|
195
|
-
path: '/agent/:agentId/component/:dataComponentId/exists',
|
|
196
|
-
summary: 'Check if Data Component is Associated with Agent',
|
|
197
|
-
operationId: 'check-data-component-agent-association',
|
|
198
|
-
tags: ['CRUD Agent Data Component Relations'],
|
|
199
|
-
request: {
|
|
200
|
-
params: TenantProjectParamsSchema.extend({
|
|
201
|
-
agentId: z.string(),
|
|
202
|
-
dataComponentId: z.string(),
|
|
203
|
-
}),
|
|
204
|
-
},
|
|
205
|
-
responses: {
|
|
206
|
-
200: {
|
|
207
|
-
description: 'Association status retrieved successfully',
|
|
208
|
-
content: {
|
|
209
|
-
'application/json': {
|
|
210
|
-
schema: ExistsResponseSchema,
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
...commonGetErrorResponses,
|
|
215
|
-
},
|
|
216
|
-
}), async (c) => {
|
|
217
|
-
const { tenantId, projectId, agentId, dataComponentId } = c.req.valid('param');
|
|
218
|
-
const exists = await isDataComponentAssociatedWithAgent(dbClient)({
|
|
219
|
-
scopes: { tenantId, projectId },
|
|
220
|
-
agentId,
|
|
221
|
-
dataComponentId,
|
|
222
|
-
});
|
|
223
|
-
return c.json({ exists });
|
|
224
|
-
});
|
|
225
|
-
export default app;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agentGraph.d.ts","sourceRoot":"","sources":["../../src/routes/agentGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA8B7D,QAAA,MAAM,GAAG,0CAAoB,CAAC;AAsU9B,eAAe,GAAG,CAAC"}
|