@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.
Files changed (114) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +10 -10
  3. package/SUPPLEMENTAL_TERMS.md +40 -0
  4. package/dist/index.cjs +5365 -0
  5. package/dist/index.d.cts +15 -0
  6. package/dist/index.d.ts +13 -18
  7. package/dist/index.js +5334 -26
  8. package/package.json +11 -11
  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 -11
  25. package/dist/app.d.ts.map +0 -1
  26. package/dist/app.js +0 -148
  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 -82
  43. package/dist/data/tools.d.ts.map +0 -1
  44. package/dist/data/tools.js +0 -271
  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 -10
  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 -21
  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 -11
  107. package/dist/routes/tools.d.ts.map +0 -1
  108. package/dist/routes/tools.js +0 -555
  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,82 +0,0 @@
1
- import { type McpServerCapabilities, type McpTool, type McpToolDefinition, type McpToolStatus, type CredentialStoreRegistry } 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
- createdAt: string;
14
- updatedAt: string;
15
- status: string;
16
- config: {
17
- type: "mcp";
18
- mcp: import("@inkeep/agents-core").ToolMcpConfig;
19
- };
20
- credentialReferenceId: string | null;
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: McpToolDefinition[] | null;
27
- lastToolsSync: string | null;
28
- }>;
29
- export declare const checkToolHealth: (tool: McpTool, credentialStoreRegistry?: CredentialStoreRegistry) => Promise<{
30
- status: McpToolStatus;
31
- error?: string;
32
- capabilities?: McpServerCapabilities;
33
- }>;
34
- export declare const discoverToolsFromServer: (tool: McpTool, credentialStoreRegistry?: CredentialStoreRegistry) => Promise<McpToolDefinition[]>;
35
- export declare const syncToolDefinitions: ({ tenantId, projectId, toolId, credentialStoreRegistry, }: {
36
- tenantId: string;
37
- projectId: string;
38
- toolId: string;
39
- credentialStoreRegistry?: CredentialStoreRegistry;
40
- }) => Promise<{
41
- tenantId: string;
42
- projectId: string;
43
- id: string;
44
- name: string;
45
- createdAt: string;
46
- updatedAt: string;
47
- status: string;
48
- config: {
49
- type: "mcp";
50
- mcp: import("@inkeep/agents-core").ToolMcpConfig;
51
- };
52
- credentialReferenceId: string | null;
53
- headers: Record<string, string> | null;
54
- imageUrl: string | null;
55
- capabilities: import("@inkeep/agents-core").ToolServerCapabilities | null;
56
- lastHealthCheck: string | null;
57
- lastError: string | null;
58
- availableTools: McpToolDefinition[] | null;
59
- lastToolsSync: string | null;
60
- }>;
61
- export declare const checkAllToolsHealth: (tenantId: string, projectId: string, credentialStoreRegistry?: CredentialStoreRegistry) => Promise<PromiseSettledResult<{
62
- tenantId: string;
63
- projectId: string;
64
- id: string;
65
- name: string;
66
- createdAt: string;
67
- updatedAt: string;
68
- status: string;
69
- config: {
70
- type: "mcp";
71
- mcp: import("@inkeep/agents-core").ToolMcpConfig;
72
- };
73
- credentialReferenceId: string | null;
74
- headers: Record<string, string> | null;
75
- imageUrl: string | null;
76
- capabilities: import("@inkeep/agents-core").ToolServerCapabilities | null;
77
- lastHealthCheck: string | null;
78
- lastError: string | null;
79
- availableTools: McpToolDefinition[] | null;
80
- lastToolsSync: string | null;
81
- }>[]>;
82
- //# sourceMappingURL=tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/data/tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,qBAAqB,EAC1B,KAAK,OAAO,EACZ,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAUlB,KAAK,uBAAuB,EAC7B,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,EACb,0BAA0B,uBAAuB,KAChD,OAAO,CAAC;IACT,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,qBAAqB,CAAC;CACtC,CAqGA,CAAC;AAGF,eAAO,MAAM,uBAAuB,GAAU,MAAM,OAAO,EAAE,0BAA0B,uBAAuB,KAAG,OAAO,CAAC,iBAAiB,EAAE,CAuF3I,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,2DAKvC;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD;;;;;;;;;;;;;;;;;;;;EA+CA,CAAC;AAGF,eAAO,MAAM,mBAAmB,GAAU,UAAU,MAAM,EAAE,WAAW,MAAM,EAAE,0BAA0B,uBAAuB;;;;;;;;;;;;;;;;;;;;KAiB/H,CAAC"}
@@ -1,271 +0,0 @@
1
- import { getLogger } from '../logger.js';
2
- import dbClient from './db/dbClient.js';
3
- import { McpClient, CredentialStuffer, getCredentialReference, updateTool, dbResultToMcpTool, listTools, getToolById, detectAuthenticationRequired, ContextResolver, } from '@inkeep/agents-core';
4
- /**
5
- * Extract input schema from MCP tool definition, handling multiple formats
6
- * Different MCP servers may use different schema structures:
7
- * - inputSchema (direct) - e.g., Notion MCP
8
- * - parameters.properties - e.g., some other MCP servers
9
- * - parameters (direct) - alternative format
10
- * - schema - another possible location
11
- */
12
- function extractInputSchema(toolDef) {
13
- // Try different possible locations for the input schema
14
- if (toolDef.inputSchema) {
15
- return toolDef.inputSchema;
16
- }
17
- if (toolDef.parameters?.properties) {
18
- return toolDef.parameters.properties;
19
- }
20
- if (toolDef.parameters && typeof toolDef.parameters === 'object') {
21
- return toolDef.parameters;
22
- }
23
- if (toolDef.schema) {
24
- return toolDef.schema;
25
- }
26
- // If none found, return empty object
27
- return {};
28
- }
29
- const logger = getLogger('tools');
30
- // Helper function to convert McpTool to MCPToolConfig format for CredentialStuffer
31
- const convertToMCPToolConfig = (tool) => {
32
- return {
33
- id: tool.id,
34
- name: tool.name,
35
- description: tool.name, // Use name as description fallback
36
- serverUrl: tool.config.mcp.server.url,
37
- mcpType: tool.config.mcp.server.url.includes('api.nango.dev') ? 'nango' : 'generic',
38
- transport: tool.config.mcp.transport,
39
- headers: tool.headers,
40
- };
41
- };
42
- // Health checking and monitoring
43
- export const updateToolHealth = async ({ tenantId, projectId, toolId, status, error, }) => {
44
- const now = new Date().toISOString();
45
- const updateData = {
46
- status,
47
- lastHealthCheck: now,
48
- updatedAt: now,
49
- };
50
- if (error !== undefined) {
51
- updateData.lastError = error;
52
- }
53
- const tool = await updateTool(dbClient)({
54
- scopes: { tenantId, projectId },
55
- toolId,
56
- data: updateData,
57
- });
58
- return tool;
59
- };
60
- export const checkToolHealth = async (tool, credentialStoreRegistry) => {
61
- try {
62
- const transportType = tool.config.mcp.transport?.type || 'streamable_http';
63
- const baseConfig = {
64
- url: tool.config.mcp.server.url,
65
- };
66
- const credentialReferenceId = tool.credentialReferenceId;
67
- let serverConfig;
68
- // Build server config with credentials if available
69
- if (credentialReferenceId) {
70
- // Get credential store configuration
71
- const credentialReference = await getCredentialReference(dbClient)({
72
- scopes: { tenantId: tool.tenantId, projectId: tool.projectId },
73
- id: credentialReferenceId,
74
- });
75
- if (!credentialReference) {
76
- throw new Error(`Credential store not found: ${credentialReferenceId}`);
77
- }
78
- const storeReference = {
79
- credentialStoreId: credentialReference.credentialStoreId,
80
- retrievalParams: credentialReference.retrievalParams || {},
81
- };
82
- // Use CredentialStuffer to build proper config with auth headers
83
- if (!credentialStoreRegistry) {
84
- throw new Error('CredentialStoreRegistry is required for authenticated tools');
85
- }
86
- const contextResolver = new ContextResolver(tool.tenantId, tool.projectId, dbClient, credentialStoreRegistry);
87
- const credentialStuffer = new CredentialStuffer(credentialStoreRegistry, contextResolver);
88
- serverConfig = await credentialStuffer.buildMcpServerConfig({ tenantId: tool.tenantId, projectId: tool.projectId }, convertToMCPToolConfig(tool), storeReference);
89
- }
90
- else {
91
- if (transportType === 'sse') {
92
- serverConfig = {
93
- type: 'sse',
94
- url: baseConfig.url,
95
- activeTools: tool.config.mcp.activeTools,
96
- eventSourceInit: tool.config.mcp.transport?.eventSourceInit,
97
- };
98
- }
99
- else {
100
- serverConfig = {
101
- type: 'streamable_http',
102
- url: baseConfig.url,
103
- activeTools: tool.config.mcp.activeTools,
104
- requestInit: tool.config.mcp.transport?.requestInit,
105
- eventSourceInit: tool.config.mcp.transport?.eventSourceInit,
106
- reconnectionOptions: tool.config.mcp.transport?.reconnectionOptions,
107
- sessionId: tool.config.mcp.transport?.sessionId,
108
- };
109
- }
110
- }
111
- const client = new McpClient({
112
- name: tool.name,
113
- server: serverConfig,
114
- });
115
- await client.connect();
116
- // Try to list tools to verify connection
117
- await client.tools();
118
- await client.disconnect();
119
- return {
120
- status: 'healthy',
121
- capabilities: {
122
- tools: true,
123
- resources: false, // Could be enhanced to check actual capabilities
124
- prompts: false,
125
- logging: false,
126
- },
127
- };
128
- }
129
- catch (error) {
130
- logger.error({ toolId: tool.id, error }, 'Tool health check failed');
131
- // Check if error indicates authentication is required
132
- if (error instanceof Error && (await detectAuthenticationRequired(tool, error))) {
133
- return {
134
- status: 'needs_auth',
135
- error: 'Authentication required - OAuth login needed',
136
- };
137
- }
138
- return {
139
- status: 'unhealthy',
140
- error: error instanceof Error ? error.message : 'Unknown error',
141
- };
142
- }
143
- };
144
- // Tool discovery
145
- export const discoverToolsFromServer = async (tool, credentialStoreRegistry) => {
146
- try {
147
- const credentialReferenceId = tool.credentialReferenceId;
148
- let serverConfig;
149
- // Build server config with credentials if available
150
- if (credentialReferenceId) {
151
- // Get credential store configuration
152
- const credentialReference = await getCredentialReference(dbClient)({
153
- scopes: { tenantId: tool.tenantId, projectId: tool.projectId },
154
- id: credentialReferenceId,
155
- });
156
- if (!credentialReference) {
157
- throw new Error(`Credential store not found: ${credentialReferenceId}`);
158
- }
159
- const storeReference = {
160
- credentialStoreId: credentialReference.credentialStoreId,
161
- retrievalParams: credentialReference.retrievalParams || {},
162
- };
163
- // Use CredentialStuffer to build proper config with auth headers
164
- if (!credentialStoreRegistry) {
165
- throw new Error('CredentialStoreRegistry is required for authenticated tools');
166
- }
167
- const contextResolver = new ContextResolver(tool.tenantId, tool.projectId, dbClient, credentialStoreRegistry);
168
- const credentialStuffer = new CredentialStuffer(credentialStoreRegistry, contextResolver);
169
- serverConfig = (await credentialStuffer.buildMcpServerConfig({ tenantId: tool.tenantId, projectId: tool.projectId }, convertToMCPToolConfig(tool), storeReference));
170
- }
171
- else {
172
- // No credentials - build basic config
173
- const transportType = tool.config.mcp.transport?.type || 'streamable_http';
174
- if (transportType === 'sse') {
175
- serverConfig = {
176
- type: 'sse',
177
- url: tool.config.mcp.server.url,
178
- activeTools: tool.config.mcp.activeTools,
179
- eventSourceInit: tool.config.mcp.transport?.eventSourceInit,
180
- };
181
- }
182
- else {
183
- serverConfig = {
184
- type: 'streamable_http',
185
- url: tool.config.mcp.server.url,
186
- activeTools: tool.config.mcp.activeTools,
187
- requestInit: tool.config.mcp.transport?.requestInit,
188
- eventSourceInit: tool.config.mcp.transport?.eventSourceInit,
189
- reconnectionOptions: tool.config.mcp.transport?.reconnectionOptions,
190
- sessionId: tool.config.mcp.transport?.sessionId,
191
- };
192
- }
193
- }
194
- const client = new McpClient({
195
- name: tool.name,
196
- server: serverConfig,
197
- });
198
- await client.connect();
199
- // Get tools from the MCP client
200
- const serverTools = await client.tools();
201
- await client.disconnect();
202
- // Convert to our format
203
- const toolDefinitions = Object.entries(serverTools).map(([name, toolDef]) => ({
204
- name,
205
- description: toolDef.description || '',
206
- inputSchema: extractInputSchema(toolDef),
207
- }));
208
- return toolDefinitions;
209
- }
210
- catch (error) {
211
- logger.error({ toolId: tool.id, error }, 'Tool discovery failed');
212
- throw error;
213
- }
214
- };
215
- export const syncToolDefinitions = async ({ tenantId, projectId, toolId, credentialStoreRegistry, }) => {
216
- const tool = await getToolById(dbClient)({ scopes: { tenantId, projectId }, toolId });
217
- if (!tool) {
218
- throw new Error(`Tool ${toolId} not found`);
219
- }
220
- const mcpTool = dbResultToMcpTool(tool);
221
- try {
222
- const availableTools = await discoverToolsFromServer(mcpTool, credentialStoreRegistry);
223
- const updatedTool = await updateTool(dbClient)({
224
- scopes: { tenantId, projectId },
225
- toolId,
226
- data: {
227
- availableTools,
228
- lastToolsSync: new Date().toISOString(),
229
- status: 'healthy',
230
- updatedAt: new Date().toISOString(),
231
- },
232
- });
233
- return updatedTool;
234
- }
235
- catch (error) {
236
- const toolNeedsAuth = error instanceof Error && (await detectAuthenticationRequired(mcpTool, error));
237
- const now = new Date().toISOString();
238
- const updatedTool = await updateTool(dbClient)({
239
- scopes: { tenantId, projectId },
240
- toolId,
241
- data: {
242
- availableTools: [],
243
- lastToolsSync: new Date().toISOString(),
244
- status: toolNeedsAuth ? 'needs_auth' : 'unhealthy',
245
- lastError: toolNeedsAuth
246
- ? 'Authentication required - OAuth login needed'
247
- : error instanceof Error
248
- ? error.message
249
- : 'Tool sync failed',
250
- lastHealthCheck: now,
251
- updatedAt: now,
252
- },
253
- });
254
- return updatedTool;
255
- }
256
- };
257
- // Bulk health checking
258
- export const checkAllToolsHealth = async (tenantId, projectId, credentialStoreRegistry) => {
259
- const toolsList = await listTools(dbClient)({ scopes: { tenantId, projectId } });
260
- const results = await Promise.allSettled(toolsList.data.map(async (tool) => {
261
- const healthResult = await checkToolHealth(dbResultToMcpTool(tool), credentialStoreRegistry);
262
- return await updateToolHealth({
263
- tenantId,
264
- projectId: tool.projectId,
265
- toolId: tool.id,
266
- status: healthResult.status,
267
- error: healthResult.error,
268
- });
269
- }));
270
- return results;
271
- };
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
- pentest: "pentest";
11
- production: "production";
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
- error: "error";
20
- debug: "debug";
21
- info: "info";
22
- trace: "trace";
23
- warn: "warn";
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: "error" | "debug" | "info" | "trace" | "warn";
33
- NODE_ENV?: "development" | "production" | "test" | undefined;
34
- ENVIRONMENT?: "development" | "pentest" | "production" | "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,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EACL,uBAAuB,EAEvB,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,qBAAqB,CAAC;AAiB7B,QAAA,MAAM,GAAG;;;;;WAAuD,CAAC;AAGjE,eAAe,GAAG,CAAC;AAGnB,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAGhC,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE;IAC3C,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;CACtC;;;;;YAMA"}
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"}