@inkeep/agents-manage-api 0.1.1 → 0.1.6

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 (114) hide show
  1. package/LICENSE.md +29 -17
  2. package/README.md +1 -1
  3. package/SUPPLEMENTAL_TERMS.md +40 -0
  4. package/dist/index.cjs +5083 -0
  5. package/dist/index.d.cts +15 -0
  6. package/dist/index.d.ts +15 -4
  7. package/dist/index.js +5046 -35
  8. package/package.json +15 -13
  9. package/dist/ManagementServer.d.ts +0 -28
  10. package/dist/ManagementServer.d.ts.map +0 -1
  11. package/dist/ManagementServer.js +0 -41
  12. package/dist/__tests__/setup.d.ts +0 -2
  13. package/dist/__tests__/setup.d.ts.map +0 -1
  14. package/dist/__tests__/setup.js +0 -26
  15. package/dist/__tests__/utils/testProject.d.ts +0 -18
  16. package/dist/__tests__/utils/testProject.d.ts.map +0 -1
  17. package/dist/__tests__/utils/testProject.js +0 -26
  18. package/dist/__tests__/utils/testRequest.d.ts +0 -2
  19. package/dist/__tests__/utils/testRequest.d.ts.map +0 -1
  20. package/dist/__tests__/utils/testRequest.js +0 -11
  21. package/dist/__tests__/utils/testTenant.d.ts +0 -64
  22. package/dist/__tests__/utils/testTenant.d.ts.map +0 -1
  23. package/dist/__tests__/utils/testTenant.js +0 -71
  24. package/dist/app.d.ts +0 -4
  25. package/dist/app.d.ts.map +0 -1
  26. package/dist/app.js +0 -140
  27. package/dist/data/conversations.d.ts +0 -59
  28. package/dist/data/conversations.d.ts.map +0 -1
  29. package/dist/data/conversations.js +0 -216
  30. package/dist/data/db/clean.d.ts +0 -6
  31. package/dist/data/db/clean.d.ts.map +0 -1
  32. package/dist/data/db/clean.js +0 -77
  33. package/dist/data/db/dbClient.d.ts +0 -3
  34. package/dist/data/db/dbClient.d.ts.map +0 -1
  35. package/dist/data/db/dbClient.js +0 -13
  36. package/dist/data/graphFull.d.ts +0 -11
  37. package/dist/data/graphFull.d.ts.map +0 -1
  38. package/dist/data/graphFull.js +0 -90
  39. package/dist/data/graphFullClient.d.ts +0 -22
  40. package/dist/data/graphFullClient.d.ts.map +0 -1
  41. package/dist/data/graphFullClient.js +0 -189
  42. package/dist/data/tools.d.ts +0 -81
  43. package/dist/data/tools.d.ts.map +0 -1
  44. package/dist/data/tools.js +0 -266
  45. package/dist/env.d.ts +0 -41
  46. package/dist/env.d.ts.map +0 -1
  47. package/dist/env.js +0 -59
  48. package/dist/index.d.ts.map +0 -1
  49. package/dist/logger.d.ts +0 -4
  50. package/dist/logger.d.ts.map +0 -1
  51. package/dist/logger.js +0 -32
  52. package/dist/middleware/auth.d.ts +0 -12
  53. package/dist/middleware/auth.d.ts.map +0 -1
  54. package/dist/middleware/auth.js +0 -36
  55. package/dist/openapi.d.ts +0 -2
  56. package/dist/openapi.d.ts.map +0 -1
  57. package/dist/openapi.js +0 -38
  58. package/dist/routes/agentArtifactComponents.d.ts +0 -4
  59. package/dist/routes/agentArtifactComponents.d.ts.map +0 -1
  60. package/dist/routes/agentArtifactComponents.js +0 -230
  61. package/dist/routes/agentDataComponents.d.ts +0 -4
  62. package/dist/routes/agentDataComponents.d.ts.map +0 -1
  63. package/dist/routes/agentDataComponents.js +0 -225
  64. package/dist/routes/agentGraph.d.ts +0 -4
  65. package/dist/routes/agentGraph.d.ts.map +0 -1
  66. package/dist/routes/agentGraph.js +0 -289
  67. package/dist/routes/agentRelations.d.ts +0 -4
  68. package/dist/routes/agentRelations.d.ts.map +0 -1
  69. package/dist/routes/agentRelations.js +0 -290
  70. package/dist/routes/agentToolRelations.d.ts +0 -4
  71. package/dist/routes/agentToolRelations.d.ts.map +0 -1
  72. package/dist/routes/agentToolRelations.js +0 -342
  73. package/dist/routes/agents.d.ts +0 -4
  74. package/dist/routes/agents.d.ts.map +0 -1
  75. package/dist/routes/agents.js +0 -213
  76. package/dist/routes/apiKeys.d.ts +0 -4
  77. package/dist/routes/apiKeys.d.ts.map +0 -1
  78. package/dist/routes/apiKeys.js +0 -236
  79. package/dist/routes/artifactComponents.d.ts +0 -4
  80. package/dist/routes/artifactComponents.d.ts.map +0 -1
  81. package/dist/routes/artifactComponents.js +0 -202
  82. package/dist/routes/contextConfigs.d.ts +0 -4
  83. package/dist/routes/contextConfigs.d.ts.map +0 -1
  84. package/dist/routes/contextConfigs.js +0 -181
  85. package/dist/routes/credentials.d.ts +0 -4
  86. package/dist/routes/credentials.d.ts.map +0 -1
  87. package/dist/routes/credentials.js +0 -219
  88. package/dist/routes/dataComponents.d.ts +0 -4
  89. package/dist/routes/dataComponents.d.ts.map +0 -1
  90. package/dist/routes/dataComponents.js +0 -188
  91. package/dist/routes/externalAgents.d.ts +0 -4
  92. package/dist/routes/externalAgents.d.ts.map +0 -1
  93. package/dist/routes/externalAgents.js +0 -216
  94. package/dist/routes/graphFull.d.ts +0 -4
  95. package/dist/routes/graphFull.d.ts.map +0 -1
  96. package/dist/routes/graphFull.js +0 -248
  97. package/dist/routes/index.d.ts +0 -4
  98. package/dist/routes/index.d.ts.map +0 -1
  99. package/dist/routes/index.js +0 -37
  100. package/dist/routes/oauth.d.ts +0 -14
  101. package/dist/routes/oauth.d.ts.map +0 -1
  102. package/dist/routes/oauth.js +0 -191
  103. package/dist/routes/projects.d.ts +0 -4
  104. package/dist/routes/projects.d.ts.map +0 -1
  105. package/dist/routes/projects.js +0 -221
  106. package/dist/routes/tools.d.ts +0 -4
  107. package/dist/routes/tools.d.ts.map +0 -1
  108. package/dist/routes/tools.js +0 -547
  109. package/dist/utils/auth-detection.d.ts +0 -22
  110. package/dist/utils/auth-detection.d.ts.map +0 -1
  111. package/dist/utils/auth-detection.js +0 -149
  112. package/dist/utils/oauth-service.d.ts +0 -88
  113. package/dist/utils/oauth-service.d.ts.map +0 -1
  114. package/dist/utils/oauth-service.js +0 -240
@@ -1,248 +0,0 @@
1
- import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
2
- import { z } from 'zod';
3
- import { commonGetErrorResponses, createApiError } from '@inkeep/agents-core';
4
- import { createFullGraphServerSide, deleteFullGraph, getFullGraph, updateFullGraphServerSide, ErrorResponseSchema, FullGraphDefinitionSchema, SingleResponseSchema, TenantProjectParamsSchema, } from '@inkeep/agents-core';
5
- import dbClient from '../data/db/dbClient.js';
6
- import { getLogger } from '../logger.js';
7
- const logger = getLogger('graphFull');
8
- const app = new OpenAPIHono();
9
- // Schema for path parameters with graphId
10
- const GraphIdParamsSchema = z
11
- .object({
12
- tenantId: z.string().openapi({
13
- description: 'Tenant identifier',
14
- example: 'tenant_123',
15
- }),
16
- projectId: z.string().openapi({
17
- description: 'Project identifier',
18
- example: 'project_456',
19
- }),
20
- graphId: z.string().openapi({
21
- description: 'Graph identifier',
22
- example: 'graph_789',
23
- }),
24
- })
25
- .openapi('GraphIdParams');
26
- // Create full graph from JSON
27
- app.openapi(createRoute({
28
- method: 'post',
29
- path: '/',
30
- summary: 'Create Full Graph',
31
- operationId: 'create-full-graph',
32
- tags: ['CRUD Full Graph'],
33
- description: 'Create a complete agent graph with all agents, tools, and relationships from JSON definition',
34
- request: {
35
- params: TenantProjectParamsSchema,
36
- body: {
37
- content: {
38
- 'application/json': {
39
- schema: FullGraphDefinitionSchema,
40
- },
41
- },
42
- },
43
- },
44
- responses: {
45
- 201: {
46
- description: 'Full graph created successfully',
47
- content: {
48
- 'application/json': {
49
- schema: SingleResponseSchema(FullGraphDefinitionSchema),
50
- },
51
- },
52
- },
53
- 409: {
54
- description: 'Graph already exists',
55
- content: {
56
- 'application/json': {
57
- schema: ErrorResponseSchema,
58
- },
59
- },
60
- },
61
- ...commonGetErrorResponses,
62
- },
63
- }), async (c) => {
64
- const { tenantId, projectId } = c.req.valid('param');
65
- const graphData = c.req.valid('json');
66
- // Validate the graph data
67
- const validatedGraphData = FullGraphDefinitionSchema.parse(graphData);
68
- // Create the full graph using the server-side data layer operations
69
- const createdGraph = await createFullGraphServerSide(dbClient, logger)({ tenantId, projectId }, validatedGraphData);
70
- return c.json({ data: createdGraph }, 201);
71
- });
72
- // Get full graph by ID
73
- app.openapi(createRoute({
74
- method: 'get',
75
- path: '/{graphId}',
76
- summary: 'Get Full Graph',
77
- operationId: 'get-full-graph',
78
- tags: ['CRUD Full Graph'],
79
- description: 'Retrieve a complete agent graph definition with all agents, tools, and relationships',
80
- request: {
81
- params: GraphIdParamsSchema,
82
- },
83
- responses: {
84
- 200: {
85
- description: 'Full graph found',
86
- content: {
87
- 'application/json': {
88
- schema: SingleResponseSchema(FullGraphDefinitionSchema),
89
- },
90
- },
91
- },
92
- ...commonGetErrorResponses,
93
- },
94
- }), async (c) => {
95
- const { tenantId, projectId, graphId } = c.req.valid('param');
96
- try {
97
- const graph = await getFullGraph(dbClient, logger)({
98
- scopes: { tenantId, projectId },
99
- graphId,
100
- });
101
- if (!graph) {
102
- throw createApiError({
103
- code: 'not_found',
104
- message: 'Graph not found',
105
- });
106
- }
107
- return c.json({ data: graph });
108
- }
109
- catch (error) {
110
- if (error instanceof Error && error.message.includes('not found')) {
111
- throw createApiError({
112
- code: 'not_found',
113
- message: 'Graph not found',
114
- });
115
- }
116
- throw createApiError({
117
- code: 'internal_server_error',
118
- message: error instanceof Error ? error.message : 'Failed to retrieve graph',
119
- });
120
- }
121
- });
122
- // Update/upsert full graph
123
- app.openapi(createRoute({
124
- method: 'put',
125
- path: '/{graphId}',
126
- summary: 'Update Full Graph',
127
- operationId: 'update-full-graph',
128
- tags: ['CRUD Full Graph'],
129
- description: 'Update or create a complete agent graph with all agents, tools, and relationships from JSON definition',
130
- request: {
131
- params: GraphIdParamsSchema,
132
- body: {
133
- content: {
134
- 'application/json': {
135
- schema: FullGraphDefinitionSchema,
136
- },
137
- },
138
- },
139
- },
140
- responses: {
141
- 200: {
142
- description: 'Full graph updated successfully',
143
- content: {
144
- 'application/json': {
145
- schema: SingleResponseSchema(FullGraphDefinitionSchema),
146
- },
147
- },
148
- },
149
- 201: {
150
- description: 'Full graph created successfully',
151
- content: {
152
- 'application/json': {
153
- schema: SingleResponseSchema(FullGraphDefinitionSchema),
154
- },
155
- },
156
- },
157
- ...commonGetErrorResponses,
158
- },
159
- }), async (c) => {
160
- const { tenantId, projectId, graphId } = c.req.valid('param');
161
- const graphData = c.req.valid('json');
162
- try {
163
- // Validate the graph data
164
- const validatedGraphData = FullGraphDefinitionSchema.parse(graphData);
165
- // Validate that the URL graphId matches the data.id
166
- if (graphId !== validatedGraphData.id) {
167
- throw createApiError({
168
- code: 'bad_request',
169
- message: `Graph ID mismatch: expected ${graphId}, got ${validatedGraphData.id}`,
170
- });
171
- }
172
- // Check if the graph exists first to determine status code
173
- const existingGraph = await getFullGraph(dbClient, logger)({
174
- scopes: { tenantId, projectId },
175
- graphId,
176
- });
177
- const isCreate = !existingGraph;
178
- // Update/create the full graph using server-side data layer operations
179
- const updatedGraph = isCreate
180
- ? await createFullGraphServerSide(dbClient, logger)({ tenantId, projectId }, validatedGraphData)
181
- : await updateFullGraphServerSide(dbClient, logger)({ tenantId, projectId }, validatedGraphData);
182
- return c.json({ data: updatedGraph }, isCreate ? 201 : 200);
183
- }
184
- catch (error) {
185
- if (error instanceof z.ZodError) {
186
- throw createApiError({
187
- code: 'bad_request',
188
- message: 'Invalid graph definition',
189
- });
190
- }
191
- if (error instanceof Error && error.message.includes('ID mismatch')) {
192
- throw createApiError({
193
- code: 'bad_request',
194
- message: error.message,
195
- });
196
- }
197
- throw createApiError({
198
- code: 'internal_server_error',
199
- message: error instanceof Error ? error.message : 'Failed to update graph',
200
- });
201
- }
202
- });
203
- // Delete full graph
204
- app.openapi(createRoute({
205
- method: 'delete',
206
- path: '/{graphId}',
207
- summary: 'Delete Full Graph',
208
- operationId: 'delete-full-graph',
209
- tags: ['CRUD Full Graph'],
210
- description: 'Delete a complete agent graph and cascade to all related entities (relationships, not agents/tools)',
211
- request: {
212
- params: GraphIdParamsSchema,
213
- },
214
- responses: {
215
- 204: {
216
- description: 'Graph deleted successfully',
217
- },
218
- ...commonGetErrorResponses,
219
- },
220
- }), async (c) => {
221
- const { tenantId, projectId, graphId } = c.req.valid('param');
222
- try {
223
- const deleted = await deleteFullGraph(dbClient, logger)({
224
- scopes: { tenantId, projectId },
225
- graphId,
226
- });
227
- if (!deleted) {
228
- throw createApiError({
229
- code: 'not_found',
230
- message: 'Graph not found',
231
- });
232
- }
233
- return c.body(null, 204);
234
- }
235
- catch (error) {
236
- if (error instanceof Error && error.message.includes('not found')) {
237
- throw createApiError({
238
- code: 'not_found',
239
- message: 'Graph not found',
240
- });
241
- }
242
- throw createApiError({
243
- code: 'internal_server_error',
244
- message: error instanceof Error ? error.message : 'Failed to delete graph',
245
- });
246
- }
247
- });
248
- export default app;
@@ -1,4 +0,0 @@
1
- import { OpenAPIHono } from '@hono/zod-openapi';
2
- declare const app: OpenAPIHono<import("hono").Env, {}, "/">;
3
- export default app;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAmBhD,QAAA,MAAM,GAAG,0CAAoB,CAAC;AAuB9B,eAAe,GAAG,CAAC"}
@@ -1,37 +0,0 @@
1
- import { OpenAPIHono } from '@hono/zod-openapi';
2
- import agentArtifactComponentsRoutes from './agentArtifactComponents.js';
3
- import agentDataComponentsRoutes from './agentDataComponents.js';
4
- import agentGraphRoutes from './agentGraph.js';
5
- import agentRelationsRoutes from './agentRelations.js';
6
- // Import existing CRUD route modules (others can be added as they're created)
7
- import agentsRoutes from './agents.js';
8
- import agentToolRelationsRoutes from './agentToolRelations.js';
9
- import apiKeysRoutes from './apiKeys.js';
10
- import artifactComponentsRoutes from './artifactComponents.js';
11
- import contextConfigsRoutes from './contextConfigs.js';
12
- import credentialsRoutes from './credentials.js';
13
- import dataComponentsRoutes from './dataComponents.js';
14
- import externalAgentsRoutes from './externalAgents.js';
15
- import graphFullRoutes from './graphFull.js';
16
- import projectsRoutes from './projects.js';
17
- import toolsRoutes from './tools.js';
18
- const app = new OpenAPIHono();
19
- // Mount projects route first (no projectId in path)
20
- app.route('/projects', projectsRoutes);
21
- // Mount existing CRUD routes under project scope
22
- app.route('/projects/:projectId/agents', agentsRoutes);
23
- app.route('/projects/:projectId/agent-relations', agentRelationsRoutes);
24
- app.route('/projects/:projectId/agent-graphs', agentGraphRoutes);
25
- app.route('/projects/:projectId/agent-tool-relations', agentToolRelationsRoutes);
26
- app.route('/projects/:projectId/agent-artifact-components', agentArtifactComponentsRoutes);
27
- app.route('/projects/:projectId/agent-data-components', agentDataComponentsRoutes);
28
- app.route('/projects/:projectId/artifact-components', artifactComponentsRoutes);
29
- app.route('/projects/:projectId/context-configs', contextConfigsRoutes);
30
- app.route('/projects/:projectId/credentials', credentialsRoutes);
31
- app.route('/projects/:projectId/data-components', dataComponentsRoutes);
32
- app.route('/projects/:projectId/external-agents', externalAgentsRoutes);
33
- app.route('/projects/:projectId/tools', toolsRoutes);
34
- app.route('/projects/:projectId/api-keys', apiKeysRoutes);
35
- // Mount new full graph CRUD routes
36
- app.route('/projects/:projectId/graph', graphFullRoutes);
37
- export default app;
@@ -1,14 +0,0 @@
1
- /**
2
- * OAuth Callback Handler
3
- *
4
- * Handles OAuth 2.1 authorization code flows for MCP tools:
5
- * - Processes authorization codes from OAuth providers
6
- * - Exchanges codes for access tokens using PKCE
7
- * - Stores credentials in Keychain
8
- * - Updates MCP tool status
9
- * - Redirects users back to frontend
10
- */
11
- import { OpenAPIHono } from '@hono/zod-openapi';
12
- declare const app: OpenAPIHono<import("hono").Env, {}, "/">;
13
- export default app;
14
- //# sourceMappingURL=oauth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/routes/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAe,WAAW,EAAK,MAAM,mBAAmB,CAAC;AAehE,QAAA,MAAM,GAAG,0CAAoB,CAAC;AA6M9B,eAAe,GAAG,CAAC"}
@@ -1,191 +0,0 @@
1
- /**
2
- * OAuth Callback Handler
3
- *
4
- * Handles OAuth 2.1 authorization code flows for MCP tools:
5
- * - Processes authorization codes from OAuth providers
6
- * - Exchanges codes for access tokens using PKCE
7
- * - Stores credentials in Keychain
8
- * - Updates MCP tool status
9
- * - Redirects users back to frontend
10
- */
11
- import { createRoute, OpenAPIHono, z } from '@hono/zod-openapi';
12
- import { dbResultToMcpTool, getToolById, updateTool, createCredentialReference, getCredentialReference, updateCredentialReference, } from '@inkeep/agents-core';
13
- import { managementServer } from '../index.js';
14
- import { getLogger } from '../logger.js';
15
- import { oauthService, retrievePKCEVerifier } from '../utils/oauth-service.js';
16
- import dbClient from '../data/db/dbClient.js';
17
- const app = new OpenAPIHono();
18
- const logger = getLogger('oauth-callback');
19
- // OAuth callback endpoint schema
20
- const OAuthCallbackQuerySchema = z.object({
21
- code: z.string().min(1, 'Authorization code is required'),
22
- state: z.string().min(1, 'State parameter is required'),
23
- error: z.string().optional(),
24
- error_description: z.string().optional(),
25
- });
26
- // OAuth callback endpoint
27
- app.openapi(createRoute({
28
- method: 'get',
29
- path: '/callback',
30
- summary: 'OAuth authorization callback',
31
- description: 'Handles OAuth authorization codes and completes the authentication flow',
32
- operationId: 'oauth-callback',
33
- tags: ['OAuth'],
34
- request: {
35
- query: OAuthCallbackQuerySchema,
36
- },
37
- responses: {
38
- 302: {
39
- description: 'Redirect to frontend after successful OAuth',
40
- },
41
- 400: {
42
- description: 'OAuth error or invalid request',
43
- content: {
44
- 'text/html': {
45
- schema: z.string(),
46
- },
47
- },
48
- },
49
- 500: {
50
- description: 'Internal server error',
51
- content: {
52
- 'text/html': {
53
- schema: z.string(),
54
- },
55
- },
56
- },
57
- },
58
- }), async (c) => {
59
- try {
60
- const { code, state, error, error_description } = c.req.valid('query');
61
- logger.info({ state, hasCode: !!code }, 'OAuth callback received');
62
- // Check for OAuth errors
63
- if (error) {
64
- logger.error({ error, error_description }, 'OAuth authorization failed');
65
- const errorMessage = 'OAuth Authorization Failed. Please try again.';
66
- return c.text(errorMessage, 400);
67
- }
68
- // Retrieve PKCE verifier and tool info
69
- const pkceData = retrievePKCEVerifier(state);
70
- if (!pkceData) {
71
- logger.error({ state }, 'Invalid or expired OAuth state');
72
- return c.text('OAuth Session Expired: The OAuth session has expired or is invalid. Please try again.', 400);
73
- }
74
- const { codeVerifier, toolId, tenantId, projectId, clientId } = pkceData;
75
- // Get the MCP tool
76
- const tool = await getToolById(dbClient)({
77
- scopes: { tenantId, projectId },
78
- toolId,
79
- });
80
- if (!tool) {
81
- throw new Error(`Tool ${toolId} not found`);
82
- }
83
- logger.info({ toolId, tenantId, projectId }, 'Processing OAuth callback');
84
- // Exchange authorization code for access token using OAuth service
85
- logger.info('Exchanging authorization code for access token');
86
- // Convert database result to McpTool (using helper function)
87
- const mcpTool = dbResultToMcpTool(tool);
88
- const { tokens } = await oauthService.exchangeCodeForTokens({
89
- code,
90
- codeVerifier,
91
- clientId,
92
- tool: mcpTool,
93
- });
94
- logger.info({ toolId, tokenType: tokens.token_type, hasRefresh: !!tokens.refresh_token }, 'Token exchange successful');
95
- // Store access token in keychain
96
- const keychainStore = managementServer.getCredentialStore('keychain-default');
97
- const keychainKey = `oauth_token_${toolId}`;
98
- await keychainStore?.set(keychainKey, JSON.stringify(tokens));
99
- const credentialId = tool.name;
100
- const existingCredential = await getCredentialReference(dbClient)({
101
- scopes: { tenantId, projectId },
102
- id: credentialId,
103
- });
104
- const credentialData = {
105
- type: 'keychain',
106
- credentialStoreId: 'keychain-default',
107
- retrievalParams: {
108
- key: keychainKey,
109
- },
110
- };
111
- let credential;
112
- if (existingCredential) {
113
- // Update existing credential
114
- logger.info({ credentialId: existingCredential.id }, 'Updating existing credential');
115
- credential = await updateCredentialReference(dbClient)({
116
- scopes: { tenantId, projectId },
117
- id: existingCredential.id,
118
- data: credentialData,
119
- });
120
- }
121
- else {
122
- // Create new credential
123
- logger.info('Creating new credential');
124
- credential = await createCredentialReference(dbClient)({
125
- tenantId,
126
- projectId,
127
- id: credentialId,
128
- ...credentialData,
129
- });
130
- }
131
- if (!credential) {
132
- throw new Error('Failed to create or update credential');
133
- }
134
- // Update MCP tool to link the credential
135
- await updateTool(dbClient)({
136
- scopes: { tenantId, projectId },
137
- toolId,
138
- data: {
139
- credentialReferenceId: credential.id,
140
- },
141
- });
142
- logger.info({ toolId, credentialId: credential.id }, 'OAuth flow completed successfully');
143
- // Show simple success page that auto-closes the tab
144
- const successPage = `
145
- <!DOCTYPE html>
146
- <html>
147
- <head>
148
- <title>Authentication Complete</title>
149
- <meta charset="utf-8">
150
- </head>
151
- <body>
152
- <p>Authentication successful. Closing in <span id="countdown">3</span> seconds...</p>
153
- <script>
154
- let countdown = 3;
155
- const countdownEl = document.getElementById('countdown');
156
-
157
- // Notify parent window of successful authentication
158
- if (window.opener) {
159
- window.opener.postMessage({
160
- type: 'oauth-success',
161
- toolId: '${toolId}'
162
- }, '*');
163
- }
164
-
165
- const timer = setInterval(() => {
166
- countdown--;
167
- countdownEl.textContent = countdown;
168
-
169
- if (countdown <= 0) {
170
- clearInterval(timer);
171
- window.close();
172
- }
173
- }, 1000);
174
-
175
- // Also try to close immediately for some browsers
176
- setTimeout(() => {
177
- window.close();
178
- }, 3000);
179
- </script>
180
- </body>
181
- </html>
182
- `;
183
- return c.html(successPage);
184
- }
185
- catch (error) {
186
- logger.error({ error }, 'OAuth callback processing failed');
187
- const errorMessage = 'OAuth Processing Failed. Please try again.';
188
- return c.text(errorMessage, 500);
189
- }
190
- });
191
- export default app;
@@ -1,4 +0,0 @@
1
- import { OpenAPIHono } from '@hono/zod-openapi';
2
- declare const app: OpenAPIHono<import("hono").Env, {}, "/">;
3
- export default app;
4
- //# sourceMappingURL=projects.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../../src/routes/projects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAqB7D,QAAA,MAAM,GAAG,0CAAoB,CAAC;AAwP9B,eAAe,GAAG,CAAC"}