@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,81 +0,0 @@
1
- import { type McpServerCapabilities, type McpTool, type McpToolDefinition, type McpToolStatus } from '@inkeep/agents-core';
2
- export declare const updateToolHealth: ({ tenantId, projectId, toolId, status, error, }: {
3
- tenantId: string;
4
- projectId: string;
5
- toolId: string;
6
- status: McpToolStatus;
7
- error?: string;
8
- }) => Promise<{
9
- tenantId: string;
10
- projectId: string;
11
- id: string;
12
- name: string;
13
- config: {
14
- type: "mcp";
15
- mcp: import("@inkeep/agents-core").ToolMcpConfig;
16
- };
17
- credentialReferenceId: string | null;
18
- createdAt: string;
19
- updatedAt: string;
20
- status: string;
21
- headers: Record<string, string> | null;
22
- imageUrl: string | null;
23
- capabilities: import("@inkeep/agents-core").ToolServerCapabilities | null;
24
- lastHealthCheck: string | null;
25
- lastError: string | null;
26
- availableTools: import("@inkeep/agents-core").McpToolDefinition[] | null;
27
- lastToolsSync: string | null;
28
- }>;
29
- export declare const checkToolHealth: (tool: McpTool) => Promise<{
30
- status: McpToolStatus;
31
- error?: string;
32
- capabilities?: McpServerCapabilities;
33
- }>;
34
- export declare const discoverToolsFromServer: (tool: McpTool) => Promise<McpToolDefinition[]>;
35
- export declare const syncToolDefinitions: ({ tenantId, projectId, toolId, }: {
36
- tenantId: string;
37
- projectId: string;
38
- toolId: string;
39
- }) => Promise<{
40
- tenantId: string;
41
- projectId: string;
42
- id: string;
43
- name: string;
44
- config: {
45
- type: "mcp";
46
- mcp: import("@inkeep/agents-core").ToolMcpConfig;
47
- };
48
- credentialReferenceId: string | null;
49
- createdAt: string;
50
- updatedAt: string;
51
- status: string;
52
- headers: Record<string, string> | null;
53
- imageUrl: string | null;
54
- capabilities: import("@inkeep/agents-core").ToolServerCapabilities | null;
55
- lastHealthCheck: string | null;
56
- lastError: string | null;
57
- availableTools: import("@inkeep/agents-core").McpToolDefinition[] | null;
58
- lastToolsSync: string | null;
59
- }>;
60
- export declare const checkAllToolsHealth: (tenantId: string, projectId: string) => Promise<PromiseSettledResult<{
61
- tenantId: string;
62
- projectId: string;
63
- id: string;
64
- name: string;
65
- config: {
66
- type: "mcp";
67
- mcp: import("@inkeep/agents-core").ToolMcpConfig;
68
- };
69
- credentialReferenceId: string | null;
70
- createdAt: string;
71
- updatedAt: string;
72
- status: string;
73
- headers: Record<string, string> | null;
74
- imageUrl: string | null;
75
- capabilities: import("@inkeep/agents-core").ToolServerCapabilities | null;
76
- lastHealthCheck: string | null;
77
- lastError: string | null;
78
- availableTools: import("@inkeep/agents-core").McpToolDefinition[] | null;
79
- lastToolsSync: string | null;
80
- }>[]>;
81
- //# sourceMappingURL=tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/data/tools.ts"],"names":[],"mappings":"AAIA,OAAO,EAML,KAAK,qBAAqB,EAC1B,KAAK,OAAO,EACZ,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAUnB,MAAM,qBAAqB,CAAC;AAgD7B,eAAO,MAAM,gBAAgB,GAAU,iDAMpC;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;;;;;;;;;;;;;;;;;;;;EAmBA,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,MAAM,OAAO,KACZ,OAAO,CAAC;IACT,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,qBAAqB,CAAC;CACtC,CAkGA,CAAC;AAGF,eAAO,MAAM,uBAAuB,GAAU,MAAM,OAAO,KAAG,OAAO,CAAC,iBAAiB,EAAE,CAoFxF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,kCAIvC;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;;;;;;;;;;;;;;;;;;;;EA+CA,CAAC;AAGF,eAAO,MAAM,mBAAmB,GAAU,UAAU,MAAM,EAAE,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;KAiB5E,CAAC"}
@@ -1,266 +0,0 @@
1
- import { managementServer } from '../index.js';
2
- import { getLogger } from '../logger.js';
3
- import dbClient from './db/dbClient.js';
4
- import { McpClient, CredentialStuffer, getCredentialReference, updateTool, dbResultToMcpTool, listTools, getToolById, detectAuthenticationRequired, ContextResolver, } from '@inkeep/agents-core';
5
- /**
6
- * Extract input schema from MCP tool definition, handling multiple formats
7
- * Different MCP servers may use different schema structures:
8
- * - inputSchema (direct) - e.g., Notion MCP
9
- * - parameters.properties - e.g., some other MCP servers
10
- * - parameters (direct) - alternative format
11
- * - schema - another possible location
12
- */
13
- function extractInputSchema(toolDef) {
14
- // Try different possible locations for the input schema
15
- if (toolDef.inputSchema) {
16
- return toolDef.inputSchema;
17
- }
18
- if (toolDef.parameters?.properties) {
19
- return toolDef.parameters.properties;
20
- }
21
- if (toolDef.parameters && typeof toolDef.parameters === 'object') {
22
- return toolDef.parameters;
23
- }
24
- if (toolDef.schema) {
25
- return toolDef.schema;
26
- }
27
- // If none found, return empty object
28
- return {};
29
- }
30
- const logger = getLogger('tools');
31
- // Helper function to convert McpTool to MCPToolConfig format for CredentialStuffer
32
- const convertToMCPToolConfig = (tool) => {
33
- return {
34
- id: tool.id,
35
- name: tool.name,
36
- description: tool.name, // Use name as description fallback
37
- serverUrl: tool.config.mcp.server.url,
38
- mcpType: tool.config.mcp.server.url.includes('api.nango.dev') ? 'nango' : 'generic',
39
- transport: tool.config.mcp.transport,
40
- headers: tool.headers,
41
- };
42
- };
43
- // Health checking and monitoring
44
- export const updateToolHealth = async ({ tenantId, projectId, toolId, status, error, }) => {
45
- const now = new Date().toISOString();
46
- const updateData = {
47
- status,
48
- lastHealthCheck: now,
49
- updatedAt: now,
50
- };
51
- if (error !== undefined) {
52
- updateData.lastError = error;
53
- }
54
- const tool = await updateTool(dbClient)({
55
- scopes: { tenantId, projectId },
56
- toolId,
57
- data: updateData,
58
- });
59
- return tool;
60
- };
61
- export const checkToolHealth = async (tool) => {
62
- try {
63
- const transportType = tool.config.mcp.transport?.type || 'streamable_http';
64
- const baseConfig = {
65
- url: tool.config.mcp.server.url,
66
- };
67
- const credentialReferenceId = tool.credentialReferenceId;
68
- let serverConfig;
69
- // Build server config with credentials if available
70
- if (credentialReferenceId) {
71
- // Get credential store configuration
72
- const credentialReference = await getCredentialReference(dbClient)({
73
- scopes: { tenantId: tool.tenantId, projectId: tool.projectId },
74
- id: credentialReferenceId,
75
- });
76
- if (!credentialReference) {
77
- throw new Error(`Credential store not found: ${credentialReferenceId}`);
78
- }
79
- const storeReference = {
80
- credentialStoreId: credentialReference.credentialStoreId,
81
- retrievalParams: credentialReference.retrievalParams || {},
82
- };
83
- // Use CredentialStuffer to build proper config with auth headers
84
- const contextResolver = new ContextResolver(tool.tenantId, tool.projectId, dbClient, managementServer);
85
- const credentialStuffer = new CredentialStuffer(managementServer, contextResolver);
86
- serverConfig = await credentialStuffer.buildMcpServerConfig({ tenantId: tool.tenantId, projectId: tool.projectId }, convertToMCPToolConfig(tool), storeReference);
87
- }
88
- else {
89
- if (transportType === 'sse') {
90
- serverConfig = {
91
- type: 'sse',
92
- url: baseConfig.url,
93
- activeTools: tool.config.mcp.activeTools,
94
- eventSourceInit: tool.config.mcp.transport?.eventSourceInit,
95
- };
96
- }
97
- else {
98
- serverConfig = {
99
- type: 'streamable_http',
100
- url: baseConfig.url,
101
- activeTools: tool.config.mcp.activeTools,
102
- requestInit: tool.config.mcp.transport?.requestInit,
103
- eventSourceInit: tool.config.mcp.transport?.eventSourceInit,
104
- reconnectionOptions: tool.config.mcp.transport?.reconnectionOptions,
105
- sessionId: tool.config.mcp.transport?.sessionId,
106
- };
107
- }
108
- }
109
- const client = new McpClient({
110
- name: tool.name,
111
- server: serverConfig,
112
- });
113
- await client.connect();
114
- // Try to list tools to verify connection
115
- await client.tools();
116
- await client.disconnect();
117
- return {
118
- status: 'healthy',
119
- capabilities: {
120
- tools: true,
121
- resources: false, // Could be enhanced to check actual capabilities
122
- prompts: false,
123
- logging: false,
124
- },
125
- };
126
- }
127
- catch (error) {
128
- logger.error({ toolId: tool.id, error }, 'Tool health check failed');
129
- // Check if error indicates authentication is required
130
- if (error instanceof Error && (await detectAuthenticationRequired(tool, error))) {
131
- return {
132
- status: 'needs_auth',
133
- error: 'Authentication required - OAuth login needed',
134
- };
135
- }
136
- return {
137
- status: 'unhealthy',
138
- error: error instanceof Error ? error.message : 'Unknown error',
139
- };
140
- }
141
- };
142
- // Tool discovery
143
- export const discoverToolsFromServer = async (tool) => {
144
- try {
145
- const credentialReferenceId = tool.credentialReferenceId;
146
- let serverConfig;
147
- // Build server config with credentials if available
148
- if (credentialReferenceId) {
149
- // Get credential store configuration
150
- const credentialReference = await getCredentialReference(dbClient)({
151
- scopes: { tenantId: tool.tenantId, projectId: tool.projectId },
152
- id: credentialReferenceId,
153
- });
154
- if (!credentialReference) {
155
- throw new Error(`Credential store not found: ${credentialReferenceId}`);
156
- }
157
- const storeReference = {
158
- credentialStoreId: credentialReference.credentialStoreId,
159
- retrievalParams: credentialReference.retrievalParams || {},
160
- };
161
- // Use CredentialStuffer to build proper config with auth headers
162
- const contextResolver = new ContextResolver(tool.tenantId, tool.projectId, dbClient, managementServer);
163
- const credentialStuffer = new CredentialStuffer(managementServer, contextResolver);
164
- serverConfig = (await credentialStuffer.buildMcpServerConfig({ tenantId: tool.tenantId, projectId: tool.projectId }, convertToMCPToolConfig(tool), storeReference));
165
- }
166
- else {
167
- // No credentials - build basic config
168
- const transportType = tool.config.mcp.transport?.type || 'streamable_http';
169
- if (transportType === 'sse') {
170
- serverConfig = {
171
- type: 'sse',
172
- url: tool.config.mcp.server.url,
173
- activeTools: tool.config.mcp.activeTools,
174
- eventSourceInit: tool.config.mcp.transport?.eventSourceInit,
175
- };
176
- }
177
- else {
178
- serverConfig = {
179
- type: 'streamable_http',
180
- url: tool.config.mcp.server.url,
181
- activeTools: tool.config.mcp.activeTools,
182
- requestInit: tool.config.mcp.transport?.requestInit,
183
- eventSourceInit: tool.config.mcp.transport?.eventSourceInit,
184
- reconnectionOptions: tool.config.mcp.transport?.reconnectionOptions,
185
- sessionId: tool.config.mcp.transport?.sessionId,
186
- };
187
- }
188
- }
189
- const client = new McpClient({
190
- name: tool.name,
191
- server: serverConfig,
192
- });
193
- await client.connect();
194
- // Get tools from the MCP client
195
- const serverTools = await client.tools();
196
- await client.disconnect();
197
- // Convert to our format
198
- const toolDefinitions = Object.entries(serverTools).map(([name, toolDef]) => ({
199
- name,
200
- description: toolDef.description || '',
201
- inputSchema: extractInputSchema(toolDef),
202
- }));
203
- return toolDefinitions;
204
- }
205
- catch (error) {
206
- logger.error({ toolId: tool.id, error }, 'Tool discovery failed');
207
- throw error;
208
- }
209
- };
210
- export const syncToolDefinitions = async ({ tenantId, projectId, toolId, }) => {
211
- const tool = await getToolById(dbClient)({ scopes: { tenantId, projectId }, toolId });
212
- if (!tool) {
213
- throw new Error(`Tool ${toolId} not found`);
214
- }
215
- const mcpTool = dbResultToMcpTool(tool);
216
- try {
217
- const availableTools = await discoverToolsFromServer(mcpTool);
218
- const updatedTool = await updateTool(dbClient)({
219
- scopes: { tenantId, projectId },
220
- toolId,
221
- data: {
222
- availableTools,
223
- lastToolsSync: new Date().toISOString(),
224
- status: 'healthy',
225
- updatedAt: new Date().toISOString(),
226
- },
227
- });
228
- return updatedTool;
229
- }
230
- catch (error) {
231
- const toolNeedsAuth = error instanceof Error && (await detectAuthenticationRequired(mcpTool, error));
232
- const now = new Date().toISOString();
233
- const updatedTool = await updateTool(dbClient)({
234
- scopes: { tenantId, projectId },
235
- toolId,
236
- data: {
237
- availableTools: [],
238
- lastToolsSync: new Date().toISOString(),
239
- status: toolNeedsAuth ? 'needs_auth' : 'unhealthy',
240
- lastError: toolNeedsAuth
241
- ? 'Authentication required - OAuth login needed'
242
- : error instanceof Error
243
- ? error.message
244
- : 'Tool sync failed',
245
- lastHealthCheck: now,
246
- updatedAt: now,
247
- },
248
- });
249
- return updatedTool;
250
- }
251
- };
252
- // Bulk health checking
253
- export const checkAllToolsHealth = async (tenantId, projectId) => {
254
- const toolsList = await listTools(dbClient)({ scopes: { tenantId, projectId } });
255
- const results = await Promise.allSettled(toolsList.data.map(async (tool) => {
256
- const healthResult = await checkToolHealth(dbResultToMcpTool(tool));
257
- return await updateToolHealth({
258
- tenantId,
259
- projectId: tool.projectId,
260
- toolId: tool.id,
261
- status: healthResult.status,
262
- error: healthResult.error,
263
- });
264
- }));
265
- return results;
266
- };
package/dist/env.d.ts DELETED
@@ -1,41 +0,0 @@
1
- import { z } from 'zod';
2
- declare const envSchema: z.ZodObject<{
3
- NODE_ENV: z.ZodOptional<z.ZodEnum<{
4
- development: "development";
5
- production: "production";
6
- test: "test";
7
- }>>;
8
- ENVIRONMENT: z.ZodOptional<z.ZodEnum<{
9
- development: "development";
10
- production: "production";
11
- pentest: "pentest";
12
- test: "test";
13
- }>>;
14
- DB_FILE_NAME: z.ZodDefault<z.ZodString>;
15
- PORT: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
16
- MANAGEMENT_PORT: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
17
- AGENT_BASE_URL: z.ZodOptional<z.ZodString>;
18
- LOG_LEVEL: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
19
- trace: "trace";
20
- debug: "debug";
21
- info: "info";
22
- warn: "warn";
23
- error: "error";
24
- }>>>;
25
- NANGO_SECRET_KEY: z.ZodOptional<z.ZodString>;
26
- INKEEP_AGENTS_MANAGE_API_SECRET: z.ZodOptional<z.ZodString>;
27
- }, z.core.$strip>;
28
- export declare const env: {
29
- DB_FILE_NAME: string;
30
- PORT: number;
31
- MANAGEMENT_PORT: number;
32
- LOG_LEVEL: "trace" | "debug" | "info" | "warn" | "error";
33
- NODE_ENV?: "development" | "production" | "test" | undefined;
34
- ENVIRONMENT?: "development" | "production" | "pentest" | "test" | undefined;
35
- AGENT_BASE_URL?: string | undefined;
36
- NANGO_SECRET_KEY?: string | undefined;
37
- INKEEP_AGENTS_MANAGE_API_SECRET?: string | undefined;
38
- };
39
- export type Env = z.infer<typeof envSchema>;
40
- export {};
41
- //# sourceMappingURL=env.d.ts.map
package/dist/env.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkCxB,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;iBAUb,CAAC;AAuBH,eAAO,MAAM,GAAG;;;;;;;;;;CAAa,CAAC;AAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC"}
package/dist/env.js DELETED
@@ -1,59 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import * as dotenv from 'dotenv';
4
- import { z } from 'zod';
5
- dotenv.config({ quiet: true });
6
- const nodeEnvSchema = z.enum(['development', 'production']).default('development');
7
- const environmentSchema = z.enum(['development', 'pentest', 'production', 'test']);
8
- const criticalEnv = z
9
- .object({
10
- ENVIRONMENT: environmentSchema,
11
- })
12
- .parse(process.env);
13
- const loadEnvFile = () => {
14
- // Priority of environment variables:
15
- // 1. Existing process.env variables (highest priority)
16
- // 2. Values from .env.{nodeEnv}.nonsecret file (lower priority)
17
- // 3. Default values defined in schema (lowest priority)
18
- const envPath = path.resolve(process.cwd(), `.env.${criticalEnv.ENVIRONMENT}.nonsecret`);
19
- if (fs.existsSync(envPath)) {
20
- const envConfig = dotenv.parse(fs.readFileSync(envPath));
21
- for (const k in envConfig) {
22
- // Only set if the environment variable doesn't already exist
23
- // This preserves any values that were already set in process.env
24
- if (!(k in process.env)) {
25
- process.env[k] = envConfig[k];
26
- }
27
- }
28
- }
29
- };
30
- loadEnvFile();
31
- const envSchema = z.object({
32
- NODE_ENV: z.enum(['development', 'production', 'test']).optional(),
33
- ENVIRONMENT: z.enum(['development', 'production', 'pentest', 'test']).optional(),
34
- DB_FILE_NAME: z.string().default('file:../local.db'),
35
- PORT: z.coerce.number().optional().default(3002),
36
- MANAGEMENT_PORT: z.coerce.number().optional().default(3002),
37
- AGENT_BASE_URL: z.string().optional(),
38
- LOG_LEVEL: z.enum(['trace', 'debug', 'info', 'warn', 'error']).optional().default('debug'),
39
- NANGO_SECRET_KEY: z.string().optional(),
40
- INKEEP_AGENTS_MANAGE_API_SECRET: z.string().optional(),
41
- });
42
- const parseEnv = () => {
43
- try {
44
- const parsedEnv = envSchema.parse(process.env);
45
- // Set default AGENT_BASE_URL if not provided
46
- if (!parsedEnv.AGENT_BASE_URL) {
47
- parsedEnv.AGENT_BASE_URL = `http://localhost:${parsedEnv.PORT}`;
48
- }
49
- return parsedEnv;
50
- }
51
- catch (error) {
52
- if (error instanceof z.ZodError) {
53
- const missingVars = error.issues.map((issue) => issue.path.join('.'));
54
- throw new Error(`❌ Invalid environment variables: ${missingVars.join(', ')}\n${error.message}`);
55
- }
56
- throw error;
57
- }
58
- };
59
- export const env = parseEnv();
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAUzD,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAgBxC,eAAO,MAAM,gBAAgB,kBAQ3B,CAAC"}
package/dist/logger.d.ts DELETED
@@ -1,4 +0,0 @@
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
@@ -1 +0,0 @@
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 DELETED
@@ -1,32 +0,0 @@
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.js';
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
- }
@@ -1,12 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAa,MAAM,qBAAqB,CAAC;AAIvE;;;;GAIG;AACH,eAAO,MAAM,UAAU;eAER;QACT,gBAAgB,EAAE,gBAAgB,CAAC;KACpC;cA6BD,CAAC"}
@@ -1,36 +0,0 @@
1
- import { createMiddleware } from 'hono/factory';
2
- import { HTTPException } from 'hono/http-exception';
3
- import { getLogger } from '@inkeep/agents-core';
4
- import { env } from '../env.js';
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
- });
package/dist/openapi.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare function setupOpenAPIRoutes(app: any): void;
2
- //# sourceMappingURL=openapi.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AAIA,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,QAwC1C"}
package/dist/openapi.js DELETED
@@ -1,38 +0,0 @@
1
- import { swaggerUI } from '@hono/swagger-ui';
2
- import { env } from './env.js';
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
- }
@@ -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=agentArtifactComponents.d.ts.map
@@ -1 +0,0 @@
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"}