@inkeep/agents-manage-api 0.0.0-dev-20250910232631

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.
Files changed (108) hide show
  1. package/LICENSE.md +49 -0
  2. package/README.md +176 -0
  3. package/dist/__tests__/setup.d.ts +2 -0
  4. package/dist/__tests__/setup.d.ts.map +1 -0
  5. package/dist/__tests__/setup.js +26 -0
  6. package/dist/__tests__/utils/testProject.d.ts +18 -0
  7. package/dist/__tests__/utils/testProject.d.ts.map +1 -0
  8. package/dist/__tests__/utils/testProject.js +26 -0
  9. package/dist/__tests__/utils/testRequest.d.ts +2 -0
  10. package/dist/__tests__/utils/testRequest.d.ts.map +1 -0
  11. package/dist/__tests__/utils/testRequest.js +11 -0
  12. package/dist/__tests__/utils/testTenant.d.ts +64 -0
  13. package/dist/__tests__/utils/testTenant.d.ts.map +1 -0
  14. package/dist/__tests__/utils/testTenant.js +71 -0
  15. package/dist/app.d.ts +5 -0
  16. package/dist/app.d.ts.map +1 -0
  17. package/dist/app.js +151 -0
  18. package/dist/data/conversations.d.ts +59 -0
  19. package/dist/data/conversations.d.ts.map +1 -0
  20. package/dist/data/conversations.js +216 -0
  21. package/dist/data/db/clean.d.ts +6 -0
  22. package/dist/data/db/clean.d.ts.map +1 -0
  23. package/dist/data/db/clean.js +77 -0
  24. package/dist/data/db/dbClient.d.ts +3 -0
  25. package/dist/data/db/dbClient.d.ts.map +1 -0
  26. package/dist/data/db/dbClient.js +13 -0
  27. package/dist/data/graphFull.d.ts +11 -0
  28. package/dist/data/graphFull.d.ts.map +1 -0
  29. package/dist/data/graphFull.js +90 -0
  30. package/dist/data/graphFullClient.d.ts +22 -0
  31. package/dist/data/graphFullClient.d.ts.map +1 -0
  32. package/dist/data/graphFullClient.js +189 -0
  33. package/dist/data/tools.d.ts +82 -0
  34. package/dist/data/tools.d.ts.map +1 -0
  35. package/dist/data/tools.js +271 -0
  36. package/dist/env.d.ts +41 -0
  37. package/dist/env.d.ts.map +1 -0
  38. package/dist/env.js +59 -0
  39. package/dist/index.d.ts +10 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +27 -0
  42. package/dist/logger.d.ts +4 -0
  43. package/dist/logger.d.ts.map +1 -0
  44. package/dist/logger.js +32 -0
  45. package/dist/middleware/auth.d.ts +12 -0
  46. package/dist/middleware/auth.d.ts.map +1 -0
  47. package/dist/middleware/auth.js +36 -0
  48. package/dist/openapi.d.ts +2 -0
  49. package/dist/openapi.d.ts.map +1 -0
  50. package/dist/openapi.js +38 -0
  51. package/dist/routes/agentArtifactComponents.d.ts +4 -0
  52. package/dist/routes/agentArtifactComponents.d.ts.map +1 -0
  53. package/dist/routes/agentArtifactComponents.js +228 -0
  54. package/dist/routes/agentDataComponents.d.ts +4 -0
  55. package/dist/routes/agentDataComponents.d.ts.map +1 -0
  56. package/dist/routes/agentDataComponents.js +224 -0
  57. package/dist/routes/agentGraph.d.ts +4 -0
  58. package/dist/routes/agentGraph.d.ts.map +1 -0
  59. package/dist/routes/agentGraph.js +287 -0
  60. package/dist/routes/agentRelations.d.ts +4 -0
  61. package/dist/routes/agentRelations.d.ts.map +1 -0
  62. package/dist/routes/agentRelations.js +289 -0
  63. package/dist/routes/agentToolRelations.d.ts +4 -0
  64. package/dist/routes/agentToolRelations.d.ts.map +1 -0
  65. package/dist/routes/agentToolRelations.js +342 -0
  66. package/dist/routes/agents.d.ts +4 -0
  67. package/dist/routes/agents.d.ts.map +1 -0
  68. package/dist/routes/agents.js +212 -0
  69. package/dist/routes/apiKeys.d.ts +4 -0
  70. package/dist/routes/apiKeys.d.ts.map +1 -0
  71. package/dist/routes/apiKeys.js +235 -0
  72. package/dist/routes/artifactComponents.d.ts +4 -0
  73. package/dist/routes/artifactComponents.d.ts.map +1 -0
  74. package/dist/routes/artifactComponents.js +201 -0
  75. package/dist/routes/contextConfigs.d.ts +4 -0
  76. package/dist/routes/contextConfigs.d.ts.map +1 -0
  77. package/dist/routes/contextConfigs.js +180 -0
  78. package/dist/routes/credentials.d.ts +10 -0
  79. package/dist/routes/credentials.d.ts.map +1 -0
  80. package/dist/routes/credentials.js +218 -0
  81. package/dist/routes/dataComponents.d.ts +4 -0
  82. package/dist/routes/dataComponents.d.ts.map +1 -0
  83. package/dist/routes/dataComponents.js +187 -0
  84. package/dist/routes/externalAgents.d.ts +4 -0
  85. package/dist/routes/externalAgents.d.ts.map +1 -0
  86. package/dist/routes/externalAgents.js +215 -0
  87. package/dist/routes/graphFull.d.ts +4 -0
  88. package/dist/routes/graphFull.d.ts.map +1 -0
  89. package/dist/routes/graphFull.js +247 -0
  90. package/dist/routes/index.d.ts +4 -0
  91. package/dist/routes/index.d.ts.map +1 -0
  92. package/dist/routes/index.js +37 -0
  93. package/dist/routes/oauth.d.ts +21 -0
  94. package/dist/routes/oauth.d.ts.map +1 -0
  95. package/dist/routes/oauth.js +191 -0
  96. package/dist/routes/projects.d.ts +4 -0
  97. package/dist/routes/projects.d.ts.map +1 -0
  98. package/dist/routes/projects.js +220 -0
  99. package/dist/routes/tools.d.ts +11 -0
  100. package/dist/routes/tools.d.ts.map +1 -0
  101. package/dist/routes/tools.js +554 -0
  102. package/dist/utils/auth-detection.d.ts +22 -0
  103. package/dist/utils/auth-detection.d.ts.map +1 -0
  104. package/dist/utils/auth-detection.js +149 -0
  105. package/dist/utils/oauth-service.d.ts +88 -0
  106. package/dist/utils/oauth-service.d.ts.map +1 -0
  107. package/dist/utils/oauth-service.js +240 -0
  108. package/package.json +69 -0
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ import { CredentialStoreRegistry, createDefaultCredentialStores, } from '@inkeep/agents-core';
2
+ import { createManagementHono } from './app';
3
+ // Create default configuration
4
+ const defaultConfig = {
5
+ port: 3002,
6
+ serverOptions: {
7
+ requestTimeout: 60000, // 60 seconds for management requests
8
+ keepAliveTimeout: 60000,
9
+ keepAlive: true,
10
+ },
11
+ };
12
+ // Create default credential stores
13
+ const defaultStores = createDefaultCredentialStores();
14
+ const defaultRegistry = new CredentialStoreRegistry(defaultStores);
15
+ // Create default app instance for simple usage
16
+ const app = createManagementHono(defaultConfig, defaultRegistry);
17
+ // Export the default app for Vite dev server and simple deployments
18
+ export default app;
19
+ // Also export the factory function for advanced usage
20
+ export { createManagementHono };
21
+ // Export a helper to create app with custom credential stores
22
+ export function createManagementApp(config) {
23
+ const serverConfig = config?.serverConfig ?? defaultConfig;
24
+ const stores = config?.credentialStores ?? defaultStores;
25
+ const registry = new CredentialStoreRegistry(stores);
26
+ return createManagementHono(serverConfig, registry);
27
+ }
@@ -0,0 +1,4 @@
1
+ import type { Next } from 'hono';
2
+ export declare function getLogger(name?: string): import("pino").Logger<never, boolean>;
3
+ export declare function withRequestContext(reqId: string, fn: Next): Promise<void>;
4
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAwBjC,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,yCAOtC;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,iBAEzD"}
package/dist/logger.js ADDED
@@ -0,0 +1,32 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import { pino } from 'pino';
3
+ // import { createGcpLoggingPinoConfig } from '@google-cloud/pino-logging-gcp-config';
4
+ import { env } from './env';
5
+ const logger = pino({
6
+ level: env.LOG_LEVEL,
7
+ serializers: {
8
+ obj: (value) => ({ ...value }),
9
+ },
10
+ redact: ['req.headers.authorization', 'req.headers["x-inkeep-admin-authentication"]'],
11
+ transport: {
12
+ target: 'pino-pretty',
13
+ options: {
14
+ sync: true,
15
+ destination: 1, // stdout
16
+ colorize: true,
17
+ translateTime: 'SYS:standard',
18
+ },
19
+ },
20
+ });
21
+ const asyncLocalStorage = new AsyncLocalStorage();
22
+ export function getLogger(name) {
23
+ const store = asyncLocalStorage.getStore();
24
+ const reqId = store?.get('requestId') || undefined;
25
+ if (!reqId) {
26
+ return logger.child({ name });
27
+ }
28
+ return logger.child({ reqId, name });
29
+ }
30
+ export function withRequestContext(reqId, fn) {
31
+ return asyncLocalStorage.run(new Map([['requestId', reqId]]), fn);
32
+ }
@@ -0,0 +1,12 @@
1
+ import { type ExecutionContext } from '@inkeep/agents-core';
2
+ /**
3
+ * Middleware to authenticate API requests using Bearer token authentication
4
+ * First checks if token matches INKEEP_AGENTS_RUN_BYPASS_SECRET, then falls back to API key validation
5
+ * Extracts and validates API keys, then adds execution context to the request
6
+ */
7
+ export declare const apiKeyAuth: () => import("hono").MiddlewareHandler<{
8
+ Variables: {
9
+ executionContext: ExecutionContext;
10
+ };
11
+ }, string, {}>;
12
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAa,MAAM,qBAAqB,CAAC;AAMvE;;;;GAIG;AACH,eAAO,MAAM,UAAU;eAER;QACT,gBAAgB,EAAE,gBAAgB,CAAC;KACpC;cA6BD,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { getLogger } from '@inkeep/agents-core';
2
+ import { createMiddleware } from 'hono/factory';
3
+ import { HTTPException } from 'hono/http-exception';
4
+ import { env } from '../env';
5
+ const logger = getLogger('env-key-auth');
6
+ /**
7
+ * Middleware to authenticate API requests using Bearer token authentication
8
+ * First checks if token matches INKEEP_AGENTS_RUN_BYPASS_SECRET, then falls back to API key validation
9
+ * Extracts and validates API keys, then adds execution context to the request
10
+ */
11
+ export const apiKeyAuth = () => createMiddleware(async (c, next) => {
12
+ // If bypass secret is configured, only allow bypass authentication
13
+ if (env.INKEEP_AGENTS_MANAGE_API_SECRET) {
14
+ const authHeader = c.req.header('Authorization');
15
+ // Check for Bearer token
16
+ if (!authHeader || !authHeader.startsWith('Bearer ')) {
17
+ throw new HTTPException(401, {
18
+ message: 'Missing or invalid authorization header. Expected: Bearer <api_key>',
19
+ });
20
+ }
21
+ const apiKey = authHeader.substring(7); // Remove 'Bearer ' prefix
22
+ if (apiKey === env.INKEEP_AGENTS_MANAGE_API_SECRET) {
23
+ logger.info({}, 'Bypass secret authenticated successfully');
24
+ await next();
25
+ return;
26
+ }
27
+ else {
28
+ // Bypass secret is set but token doesn't match - reject
29
+ throw new HTTPException(401, {
30
+ message: 'Invalid Token',
31
+ });
32
+ }
33
+ }
34
+ await next();
35
+ return;
36
+ });
@@ -0,0 +1,2 @@
1
+ export declare function setupOpenAPIRoutes(app: any): void;
2
+ //# sourceMappingURL=openapi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AAIA,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,QAwC1C"}
@@ -0,0 +1,38 @@
1
+ import { swaggerUI } from '@hono/swagger-ui';
2
+ import { env } from './env';
3
+ export function setupOpenAPIRoutes(app) {
4
+ // OpenAPI specification endpoint - serves the complete API spec
5
+ app.get('/openapi.json', (c) => {
6
+ try {
7
+ const document = app.getOpenAPIDocument({
8
+ openapi: '3.0.0',
9
+ info: {
10
+ title: 'Inkeep Agent Framework Management API',
11
+ version: '1.0.0',
12
+ description: 'Complete REST API for Inkeep Agent Framework Management application including chat completions, A2A agent communication, and comprehensive CRUD operations for all entities',
13
+ },
14
+ servers: [
15
+ {
16
+ url: env.MANAGEMENT_PORT
17
+ ? `http://localhost:${env.MANAGEMENT_PORT}`
18
+ : `http://localhost:3002`,
19
+ description: 'Development server',
20
+ },
21
+ ],
22
+ });
23
+ return c.json(document);
24
+ }
25
+ catch (error) {
26
+ console.error('OpenAPI document generation failed:', error);
27
+ const errorDetails = error instanceof Error
28
+ ? { message: error.message, stack: error.stack }
29
+ : JSON.stringify(error, null, 2);
30
+ return c.json({ error: 'Failed to generate OpenAPI document', details: errorDetails }, 500);
31
+ }
32
+ });
33
+ // Swagger UI endpoint for interactive documentation
34
+ app.get('/docs', swaggerUI({
35
+ url: '/openapi.json',
36
+ title: 'InkeepAgent Framework Management API Documentation',
37
+ }));
38
+ }
@@ -0,0 +1,4 @@
1
+ import { OpenAPIHono } from '@hono/zod-openapi';
2
+ declare const app: OpenAPIHono<import("hono").Env, {}, "/">;
3
+ export default app;
4
+ //# sourceMappingURL=agentArtifactComponents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentArtifactComponents.d.ts","sourceRoot":"","sources":["../../src/routes/agentArtifactComponents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAuB7D,QAAA,MAAM,GAAG,0CAAoB,CAAC;AAsQ9B,eAAe,GAAG,CAAC"}
@@ -0,0 +1,228 @@
1
+ import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
2
+ import { AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiSelectSchema, ArtifactComponentApiSelectSchema, associateArtifactComponentWithAgent, commonGetErrorResponses, createApiError, ErrorResponseSchema, ExistsResponseSchema, getAgentById, getAgentsUsingArtifactComponent, getArtifactComponentById, getArtifactComponentsForAgent, isArtifactComponentAssociatedWithAgent, RemovedResponseSchema, removeArtifactComponentFromAgent, SingleResponseSchema, TenantProjectParamsSchema, } from '@inkeep/agents-core';
3
+ import { z } from 'zod';
4
+ import dbClient from '../data/db/dbClient';
5
+ const app = new OpenAPIHono();
6
+ // List artifact components for a specific agent in a graph
7
+ app.openapi(createRoute({
8
+ method: 'get',
9
+ path: '/agent/:agentId',
10
+ summary: 'Get Artifact Components for Agent',
11
+ operationId: 'get-artifact-components-for-agent',
12
+ tags: ['CRUD Agent Artifact Component Relations'],
13
+ request: {
14
+ params: TenantProjectParamsSchema.extend({
15
+ agentId: z.string(),
16
+ }),
17
+ },
18
+ responses: {
19
+ 200: {
20
+ description: 'Artifact components retrieved successfully',
21
+ content: {
22
+ 'application/json': {
23
+ schema: z.object({
24
+ data: z.array(ArtifactComponentApiSelectSchema),
25
+ }),
26
+ },
27
+ },
28
+ },
29
+ ...commonGetErrorResponses,
30
+ },
31
+ }), async (c) => {
32
+ const { tenantId, projectId, agentId } = c.req.valid('param');
33
+ const artifactComponents = await getArtifactComponentsForAgent(dbClient)({
34
+ scopes: { tenantId, projectId },
35
+ agentId,
36
+ });
37
+ return c.json({
38
+ data: artifactComponents,
39
+ });
40
+ });
41
+ // List agents using a specific artifact component
42
+ app.openapi(createRoute({
43
+ method: 'get',
44
+ path: '/component/:artifactComponentId/agents',
45
+ summary: 'Get Agents Using Artifact Component',
46
+ operationId: 'get-agents-using-artifact-component',
47
+ tags: ['CRUD Agent Artifact Component Relations'],
48
+ request: {
49
+ params: TenantProjectParamsSchema.extend({
50
+ artifactComponentId: z.string(),
51
+ }),
52
+ },
53
+ responses: {
54
+ 200: {
55
+ description: 'Agents retrieved successfully',
56
+ content: {
57
+ 'application/json': {
58
+ schema: z.object({
59
+ data: z.array(z.object({
60
+ agentId: z.string(),
61
+ createdAt: z.string(),
62
+ })),
63
+ }),
64
+ },
65
+ },
66
+ },
67
+ ...commonGetErrorResponses,
68
+ },
69
+ }), async (c) => {
70
+ const { tenantId, projectId, artifactComponentId } = c.req.valid('param');
71
+ const agents = await getAgentsUsingArtifactComponent(dbClient)({
72
+ scopes: { tenantId, projectId },
73
+ artifactComponentId,
74
+ });
75
+ return c.json({ data: agents });
76
+ });
77
+ // Create agent artifact component association
78
+ app.openapi(createRoute({
79
+ method: 'post',
80
+ path: '/',
81
+ summary: 'Associate Artifact Component with Agent',
82
+ operationId: 'associate-artifact-component-with-agent',
83
+ tags: ['CRUD Agent Artifact Component Relations'],
84
+ request: {
85
+ params: TenantProjectParamsSchema,
86
+ body: {
87
+ content: {
88
+ 'application/json': {
89
+ schema: AgentArtifactComponentApiInsertSchema,
90
+ },
91
+ },
92
+ },
93
+ },
94
+ responses: {
95
+ 201: {
96
+ description: 'Agent artifact component association created successfully',
97
+ content: {
98
+ 'application/json': {
99
+ schema: SingleResponseSchema(AgentArtifactComponentApiSelectSchema),
100
+ },
101
+ },
102
+ },
103
+ 409: {
104
+ description: 'Association already exists',
105
+ content: {
106
+ 'application/json': {
107
+ schema: ErrorResponseSchema,
108
+ },
109
+ },
110
+ },
111
+ ...commonGetErrorResponses,
112
+ },
113
+ }), async (c) => {
114
+ const { tenantId, projectId } = c.req.valid('param');
115
+ const { agentId, artifactComponentId } = c.req.valid('json');
116
+ // Validate that both agent and artifact component exist before creating association
117
+ const agent = await getAgentById(dbClient)({ scopes: { tenantId, projectId }, agentId });
118
+ const artifactComponent = await getArtifactComponentById(dbClient)({
119
+ scopes: { tenantId, projectId },
120
+ id: artifactComponentId,
121
+ });
122
+ if (!agent) {
123
+ throw createApiError({
124
+ code: 'not_found',
125
+ message: `Agent with id '${agentId}' not found`,
126
+ });
127
+ }
128
+ if (!artifactComponent) {
129
+ throw createApiError({
130
+ code: 'not_found',
131
+ message: `Artifact component with id '${artifactComponentId}' not found`,
132
+ });
133
+ }
134
+ // Check if association already exists
135
+ const exists = await isArtifactComponentAssociatedWithAgent(dbClient)({
136
+ scopes: { tenantId, projectId },
137
+ agentId,
138
+ artifactComponentId,
139
+ });
140
+ if (exists) {
141
+ throw createApiError({
142
+ code: 'conflict',
143
+ message: 'Agent artifact component association already exists',
144
+ });
145
+ }
146
+ const association = await associateArtifactComponentWithAgent(dbClient)({
147
+ scopes: { tenantId, projectId },
148
+ agentId,
149
+ artifactComponentId,
150
+ });
151
+ return c.json({ data: association }, 201);
152
+ });
153
+ // Remove agent artifact component association
154
+ app.openapi(createRoute({
155
+ method: 'delete',
156
+ path: '/agent/:agentId/component/:artifactComponentId',
157
+ summary: 'Remove Artifact Component from Agent',
158
+ operationId: 'remove-artifact-component-from-agent',
159
+ tags: ['CRUD Agent Artifact Component Relations'],
160
+ request: {
161
+ params: TenantProjectParamsSchema.extend({
162
+ agentId: z.string(),
163
+ artifactComponentId: z.string(),
164
+ }),
165
+ },
166
+ responses: {
167
+ 200: {
168
+ description: 'Association removed successfully',
169
+ content: {
170
+ 'application/json': {
171
+ schema: RemovedResponseSchema,
172
+ },
173
+ },
174
+ },
175
+ ...commonGetErrorResponses,
176
+ },
177
+ }), async (c) => {
178
+ const { tenantId, projectId, agentId, artifactComponentId } = c.req.valid('param');
179
+ const removed = await removeArtifactComponentFromAgent(dbClient)({
180
+ scopes: { tenantId, projectId },
181
+ agentId,
182
+ artifactComponentId,
183
+ });
184
+ if (!removed) {
185
+ throw createApiError({
186
+ code: 'not_found',
187
+ message: 'Agent artifact component association not found',
188
+ });
189
+ }
190
+ return c.json({
191
+ message: 'Association removed successfully',
192
+ removed: true,
193
+ });
194
+ });
195
+ // Check if artifact component is associated with agent
196
+ app.openapi(createRoute({
197
+ method: 'get',
198
+ path: '/agent/:agentId/component/:artifactComponentId/exists',
199
+ summary: 'Check if Artifact Component is Associated with Agent',
200
+ operationId: 'check-artifact-component-agent-association',
201
+ tags: ['CRUD Agent Artifact Component Relations'],
202
+ request: {
203
+ params: TenantProjectParamsSchema.extend({
204
+ agentId: z.string(),
205
+ artifactComponentId: z.string(),
206
+ }),
207
+ },
208
+ responses: {
209
+ 200: {
210
+ description: 'Association status retrieved successfully',
211
+ content: {
212
+ 'application/json': {
213
+ schema: ExistsResponseSchema,
214
+ },
215
+ },
216
+ },
217
+ ...commonGetErrorResponses,
218
+ },
219
+ }), async (c) => {
220
+ const { tenantId, projectId, agentId, artifactComponentId } = c.req.valid('param');
221
+ const exists = await isArtifactComponentAssociatedWithAgent(dbClient)({
222
+ scopes: { tenantId, projectId },
223
+ agentId,
224
+ artifactComponentId,
225
+ });
226
+ return c.json({ exists });
227
+ });
228
+ export default app;
@@ -0,0 +1,4 @@
1
+ import { OpenAPIHono } from '@hono/zod-openapi';
2
+ declare const app: OpenAPIHono<import("hono").Env, {}, "/">;
3
+ export default app;
4
+ //# sourceMappingURL=agentDataComponents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentDataComponents.d.ts","sourceRoot":"","sources":["../../src/routes/agentDataComponents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAuB7D,QAAA,MAAM,GAAG,0CAAoB,CAAC;AAkQ9B,eAAe,GAAG,CAAC"}
@@ -0,0 +1,224 @@
1
+ import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
2
+ import { AgentDataComponentApiInsertSchema, AgentDataComponentApiSelectSchema, associateDataComponentWithAgent, commonGetErrorResponses, createApiError, DataComponentApiSelectSchema, ErrorResponseSchema, ExistsResponseSchema, getAgentById, getAgentsUsingDataComponent, getDataComponent, getDataComponentsForAgent, isDataComponentAssociatedWithAgent, RemovedResponseSchema, removeDataComponentFromAgent, SingleResponseSchema, TenantProjectParamsSchema, } from '@inkeep/agents-core';
3
+ import { z } from 'zod';
4
+ import dbClient from '../data/db/dbClient';
5
+ const app = new OpenAPIHono();
6
+ // List data components for a specific agent in a graph
7
+ app.openapi(createRoute({
8
+ method: 'get',
9
+ path: '/agent/:agentId',
10
+ summary: 'Get Data Components for Agent',
11
+ operationId: 'get-data-components-for-agent',
12
+ tags: ['CRUD Agent Data Component Relations'],
13
+ request: {
14
+ params: TenantProjectParamsSchema.extend({
15
+ agentId: z.string(),
16
+ }),
17
+ },
18
+ responses: {
19
+ 200: {
20
+ description: 'Data components retrieved successfully',
21
+ content: {
22
+ 'application/json': {
23
+ schema: z.object({
24
+ data: z.array(DataComponentApiSelectSchema),
25
+ }),
26
+ },
27
+ },
28
+ },
29
+ ...commonGetErrorResponses,
30
+ },
31
+ }), async (c) => {
32
+ const { tenantId, projectId, agentId } = c.req.valid('param');
33
+ const dataComponents = await getDataComponentsForAgent(dbClient)({
34
+ scopes: { tenantId, projectId },
35
+ agentId,
36
+ });
37
+ return c.json({ data: dataComponents });
38
+ });
39
+ // List agent ids using a specific data component
40
+ app.openapi(createRoute({
41
+ method: 'get',
42
+ path: '/component/:dataComponentId/agents',
43
+ summary: 'Get Agents Using Data Component',
44
+ operationId: 'get-agents-using-data-component',
45
+ tags: ['CRUD Agent Data Component Relations'],
46
+ request: {
47
+ params: TenantProjectParamsSchema.extend({
48
+ dataComponentId: z.string(),
49
+ }),
50
+ },
51
+ responses: {
52
+ 200: {
53
+ description: 'Agents retrieved successfully',
54
+ content: {
55
+ 'application/json': {
56
+ schema: z.object({
57
+ data: z.array(z.object({
58
+ agentId: z.string(),
59
+ createdAt: z.string(),
60
+ })),
61
+ }),
62
+ },
63
+ },
64
+ },
65
+ ...commonGetErrorResponses,
66
+ },
67
+ }), async (c) => {
68
+ const { tenantId, projectId, dataComponentId } = c.req.valid('param');
69
+ const agents = await getAgentsUsingDataComponent(dbClient)({
70
+ scopes: { tenantId, projectId },
71
+ dataComponentId,
72
+ });
73
+ return c.json({ data: agents });
74
+ });
75
+ // Create agent data component association
76
+ app.openapi(createRoute({
77
+ method: 'post',
78
+ path: '/',
79
+ summary: 'Associate Data Component with Agent',
80
+ operationId: 'associate-data-component-with-agent',
81
+ tags: ['CRUD Agent Data Component Relations'],
82
+ request: {
83
+ params: TenantProjectParamsSchema,
84
+ body: {
85
+ content: {
86
+ 'application/json': {
87
+ schema: AgentDataComponentApiInsertSchema,
88
+ },
89
+ },
90
+ },
91
+ },
92
+ responses: {
93
+ 201: {
94
+ description: 'Agent data component association created successfully',
95
+ content: {
96
+ 'application/json': {
97
+ schema: SingleResponseSchema(AgentDataComponentApiSelectSchema),
98
+ },
99
+ },
100
+ },
101
+ 409: {
102
+ description: 'Association already exists',
103
+ content: {
104
+ 'application/json': {
105
+ schema: ErrorResponseSchema,
106
+ },
107
+ },
108
+ },
109
+ ...commonGetErrorResponses,
110
+ },
111
+ }), async (c) => {
112
+ const { tenantId, projectId } = c.req.valid('param');
113
+ const { agentId, dataComponentId } = c.req.valid('json');
114
+ const [agent, dataComponent] = await Promise.all([
115
+ getAgentById(dbClient)({ scopes: { tenantId, projectId }, agentId }),
116
+ getDataComponent(dbClient)({ scopes: { tenantId, projectId }, dataComponentId }),
117
+ ]);
118
+ if (!agent) {
119
+ throw createApiError({
120
+ code: 'not_found',
121
+ message: `Agent with id '${agentId}' not found`,
122
+ });
123
+ }
124
+ if (!dataComponent) {
125
+ throw createApiError({
126
+ code: 'not_found',
127
+ message: `Data component with id '${dataComponentId}' not found`,
128
+ });
129
+ }
130
+ // Check if association already exists
131
+ const exists = await isDataComponentAssociatedWithAgent(dbClient)({
132
+ scopes: { tenantId, projectId },
133
+ agentId,
134
+ dataComponentId,
135
+ });
136
+ if (exists) {
137
+ throw createApiError({
138
+ code: 'conflict',
139
+ message: 'Agent data component association already exists',
140
+ });
141
+ }
142
+ const association = await associateDataComponentWithAgent(dbClient)({
143
+ scopes: { tenantId, projectId },
144
+ agentId,
145
+ dataComponentId,
146
+ });
147
+ return c.json({ data: association }, 201);
148
+ });
149
+ // Remove agent data component association
150
+ app.openapi(createRoute({
151
+ method: 'delete',
152
+ path: '/agent/:agentId/component/:dataComponentId',
153
+ summary: 'Remove Data Component from Agent',
154
+ operationId: 'remove-data-component-from-agent',
155
+ tags: ['CRUD Agent Data Component Relations'],
156
+ request: {
157
+ params: TenantProjectParamsSchema.extend({
158
+ agentId: z.string(),
159
+ dataComponentId: z.string(),
160
+ }),
161
+ },
162
+ responses: {
163
+ 200: {
164
+ description: 'Association removed successfully',
165
+ content: {
166
+ 'application/json': {
167
+ schema: RemovedResponseSchema,
168
+ },
169
+ },
170
+ },
171
+ ...commonGetErrorResponses,
172
+ },
173
+ }), async (c) => {
174
+ const { tenantId, projectId, agentId, dataComponentId } = c.req.valid('param');
175
+ const removed = await removeDataComponentFromAgent(dbClient)({
176
+ scopes: { tenantId, projectId },
177
+ agentId,
178
+ dataComponentId,
179
+ });
180
+ if (!removed) {
181
+ throw createApiError({
182
+ code: 'not_found',
183
+ message: 'Agent data component association not found',
184
+ });
185
+ }
186
+ return c.json({
187
+ message: 'Association removed successfully',
188
+ removed: true,
189
+ });
190
+ });
191
+ // Check if data component is associated with agent
192
+ app.openapi(createRoute({
193
+ method: 'get',
194
+ path: '/agent/:agentId/component/:dataComponentId/exists',
195
+ summary: 'Check if Data Component is Associated with Agent',
196
+ operationId: 'check-data-component-agent-association',
197
+ tags: ['CRUD Agent Data Component Relations'],
198
+ request: {
199
+ params: TenantProjectParamsSchema.extend({
200
+ agentId: z.string(),
201
+ dataComponentId: z.string(),
202
+ }),
203
+ },
204
+ responses: {
205
+ 200: {
206
+ description: 'Association status retrieved successfully',
207
+ content: {
208
+ 'application/json': {
209
+ schema: ExistsResponseSchema,
210
+ },
211
+ },
212
+ },
213
+ ...commonGetErrorResponses,
214
+ },
215
+ }), async (c) => {
216
+ const { tenantId, projectId, agentId, dataComponentId } = c.req.valid('param');
217
+ const exists = await isDataComponentAssociatedWithAgent(dbClient)({
218
+ scopes: { tenantId, projectId },
219
+ agentId,
220
+ dataComponentId,
221
+ });
222
+ return c.json({ exists });
223
+ });
224
+ export default app;
@@ -0,0 +1,4 @@
1
+ import { OpenAPIHono } from '@hono/zod-openapi';
2
+ declare const app: OpenAPIHono<import("hono").Env, {}, "/">;
3
+ export default app;
4
+ //# sourceMappingURL=agentGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentGraph.d.ts","sourceRoot":"","sources":["../../src/routes/agentGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA0B7D,QAAA,MAAM,GAAG,0CAAoB,CAAC;AAsU9B,eAAe,GAAG,CAAC"}