@inkeep/agents-core 0.0.0-dev-20250910233133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +56 -0
- package/README.md +464 -0
- package/dist/__tests__/integration/helpers.d.ts +5 -0
- package/dist/__tests__/integration/helpers.d.ts.map +1 -0
- package/dist/__tests__/integration/helpers.js +37 -0
- package/dist/__tests__/integration/helpers.js.map +1 -0
- package/dist/__tests__/setup.d.ts +3 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/__tests__/setup.js +29 -0
- package/dist/__tests__/setup.js.map +1 -0
- package/dist/client-exports.d.ts +299 -0
- package/dist/client-exports.d.ts.map +1 -0
- package/dist/client-exports.js +252 -0
- package/dist/client-exports.js.map +1 -0
- package/dist/context/ContextConfig.d.ts +54 -0
- package/dist/context/ContextConfig.d.ts.map +1 -0
- package/dist/context/ContextConfig.js +302 -0
- package/dist/context/ContextConfig.js.map +1 -0
- package/dist/context/ContextFetcher.d.ts +64 -0
- package/dist/context/ContextFetcher.d.ts.map +1 -0
- package/dist/context/ContextFetcher.js +325 -0
- package/dist/context/ContextFetcher.js.map +1 -0
- package/dist/context/ContextResolver.d.ts +52 -0
- package/dist/context/ContextResolver.d.ts.map +1 -0
- package/dist/context/ContextResolver.js +298 -0
- package/dist/context/ContextResolver.js.map +1 -0
- package/dist/context/TemplateEngine.d.ts +46 -0
- package/dist/context/TemplateEngine.d.ts.map +1 -0
- package/dist/context/TemplateEngine.js +175 -0
- package/dist/context/TemplateEngine.js.map +1 -0
- package/dist/context/context.d.ts +8 -0
- package/dist/context/context.d.ts.map +1 -0
- package/dist/context/context.js +157 -0
- package/dist/context/context.js.map +1 -0
- package/dist/context/contextCache.d.ts +50 -0
- package/dist/context/contextCache.d.ts.map +1 -0
- package/dist/context/contextCache.js +175 -0
- package/dist/context/contextCache.js.map +1 -0
- package/dist/context/index.d.ts +11 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +8 -0
- package/dist/context/index.js.map +1 -0
- package/dist/credential-stores/CredentialStoreRegistry.d.ts +39 -0
- package/dist/credential-stores/CredentialStoreRegistry.d.ts.map +1 -0
- package/dist/credential-stores/CredentialStoreRegistry.js +65 -0
- package/dist/credential-stores/CredentialStoreRegistry.js.map +1 -0
- package/dist/credential-stores/defaults.d.ts +6 -0
- package/dist/credential-stores/defaults.d.ts.map +1 -0
- package/dist/credential-stores/defaults.js +22 -0
- package/dist/credential-stores/defaults.js.map +1 -0
- package/dist/credential-stores/index.d.ts +6 -0
- package/dist/credential-stores/index.d.ts.map +1 -0
- package/dist/credential-stores/index.js +6 -0
- package/dist/credential-stores/index.js.map +1 -0
- package/dist/credential-stores/keychain-store.d.ts +100 -0
- package/dist/credential-stores/keychain-store.d.ts.map +1 -0
- package/dist/credential-stores/keychain-store.js +225 -0
- package/dist/credential-stores/keychain-store.js.map +1 -0
- package/dist/credential-stores/memory-store.d.ts +39 -0
- package/dist/credential-stores/memory-store.d.ts.map +1 -0
- package/dist/credential-stores/memory-store.js +58 -0
- package/dist/credential-stores/memory-store.js.map +1 -0
- package/dist/credential-stores/nango-store.d.ts +59 -0
- package/dist/credential-stores/nango-store.d.ts.map +1 -0
- package/dist/credential-stores/nango-store.js +264 -0
- package/dist/credential-stores/nango-store.js.map +1 -0
- package/dist/credential-stuffer/CredentialStuffer.d.ts +80 -0
- package/dist/credential-stuffer/CredentialStuffer.d.ts.map +1 -0
- package/dist/credential-stuffer/CredentialStuffer.js +186 -0
- package/dist/credential-stuffer/CredentialStuffer.js.map +1 -0
- package/dist/credential-stuffer/index.d.ts +2 -0
- package/dist/credential-stuffer/index.d.ts.map +1 -0
- package/dist/credential-stuffer/index.js +2 -0
- package/dist/credential-stuffer/index.js.map +1 -0
- package/dist/data-access/agentDataComponents.d.ts +1 -0
- package/dist/data-access/agentDataComponents.d.ts.map +1 -0
- package/dist/data-access/agentDataComponents.js +2 -0
- package/dist/data-access/agentDataComponents.js.map +1 -0
- package/dist/data-access/agentGraphs.d.ts +399 -0
- package/dist/data-access/agentGraphs.d.ts.map +1 -0
- package/dist/data-access/agentGraphs.js +551 -0
- package/dist/data-access/agentGraphs.js.map +1 -0
- package/dist/data-access/agentRelations.d.ts +456 -0
- package/dist/data-access/agentRelations.d.ts.map +1 -0
- package/dist/data-access/agentRelations.js +471 -0
- package/dist/data-access/agentRelations.js.map +1 -0
- package/dist/data-access/agents.d.ts +218 -0
- package/dist/data-access/agents.d.ts.map +1 -0
- package/dist/data-access/agents.js +130 -0
- package/dist/data-access/agents.js.map +1 -0
- package/dist/data-access/apiKeys.d.ts +114 -0
- package/dist/data-access/apiKeys.d.ts.map +1 -0
- package/dist/data-access/apiKeys.js +185 -0
- package/dist/data-access/apiKeys.js.map +1 -0
- package/dist/data-access/artifactComponents.d.ts +152 -0
- package/dist/data-access/artifactComponents.d.ts.map +1 -0
- package/dist/data-access/artifactComponents.js +214 -0
- package/dist/data-access/artifactComponents.js.map +1 -0
- package/dist/data-access/contextCache.d.ts +68 -0
- package/dist/data-access/contextCache.d.ts.map +1 -0
- package/dist/data-access/contextCache.js +135 -0
- package/dist/data-access/contextCache.js.map +1 -0
- package/dist/data-access/contextConfigs.d.ts +110 -0
- package/dist/data-access/contextConfigs.d.ts.map +1 -0
- package/dist/data-access/contextConfigs.js +156 -0
- package/dist/data-access/contextConfigs.js.map +1 -0
- package/dist/data-access/conversations.d.ts +125 -0
- package/dist/data-access/conversations.d.ts.map +1 -0
- package/dist/data-access/conversations.js +244 -0
- package/dist/data-access/conversations.js.map +1 -0
- package/dist/data-access/credentialReferences.d.ts +86 -0
- package/dist/data-access/credentialReferences.d.ts.map +1 -0
- package/dist/data-access/credentialReferences.js +175 -0
- package/dist/data-access/credentialReferences.js.map +1 -0
- package/dist/data-access/dataComponents.d.ts +129 -0
- package/dist/data-access/dataComponents.d.ts.map +1 -0
- package/dist/data-access/dataComponents.js +213 -0
- package/dist/data-access/dataComponents.js.map +1 -0
- package/dist/data-access/externalAgents.d.ts +83 -0
- package/dist/data-access/externalAgents.d.ts.map +1 -0
- package/dist/data-access/externalAgents.js +163 -0
- package/dist/data-access/externalAgents.js.map +1 -0
- package/dist/data-access/graphFull.d.ts +32 -0
- package/dist/data-access/graphFull.d.ts.map +1 -0
- package/dist/data-access/graphFull.js +996 -0
- package/dist/data-access/graphFull.js.map +1 -0
- package/dist/data-access/index.d.ts +21 -0
- package/dist/data-access/index.d.ts.map +1 -0
- package/dist/data-access/index.js +22 -0
- package/dist/data-access/index.js.map +1 -0
- package/dist/data-access/ledgerArtifacts.d.ts +49 -0
- package/dist/data-access/ledgerArtifacts.d.ts.map +1 -0
- package/dist/data-access/ledgerArtifacts.js +112 -0
- package/dist/data-access/ledgerArtifacts.js.map +1 -0
- package/dist/data-access/messages.d.ts +209 -0
- package/dist/data-access/messages.d.ts.map +1 -0
- package/dist/data-access/messages.js +100 -0
- package/dist/data-access/messages.js.map +1 -0
- package/dist/data-access/projects.d.ts +67 -0
- package/dist/data-access/projects.d.ts.map +1 -0
- package/dist/data-access/projects.js +337 -0
- package/dist/data-access/projects.js.map +1 -0
- package/dist/data-access/tasks.d.ts +37 -0
- package/dist/data-access/tasks.d.ts.map +1 -0
- package/dist/data-access/tasks.js +40 -0
- package/dist/data-access/tasks.js.map +1 -0
- package/dist/data-access/tools.d.ts +277 -0
- package/dist/data-access/tools.d.ts.map +1 -0
- package/dist/data-access/tools.js +183 -0
- package/dist/data-access/tools.js.map +1 -0
- package/dist/data-access/validation.d.ts +17 -0
- package/dist/data-access/validation.d.ts.map +1 -0
- package/dist/data-access/validation.js +52 -0
- package/dist/data-access/validation.js.map +1 -0
- package/dist/db/clean.d.ts +6 -0
- package/dist/db/clean.d.ts.map +1 -0
- package/dist/db/clean.js +81 -0
- package/dist/db/clean.js.map +1 -0
- package/dist/db/client.d.ts +19 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +24 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/schema.d.ts +4335 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +696 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/db/test-client.d.ts +25 -0
- package/dist/db/test-client.d.ts.map +1 -0
- package/dist/db/test-client.js +136 -0
- package/dist/db/test-client.js.map +1 -0
- package/dist/env.d.ts +19 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +49 -0
- package/dist/env.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/contextValidation.d.ts +49 -0
- package/dist/middleware/contextValidation.d.ts.map +1 -0
- package/dist/middleware/contextValidation.js +473 -0
- package/dist/middleware/contextValidation.js.map +1 -0
- package/dist/middleware/index.d.ts +2 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +2 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/types/a2a.d.ts +373 -0
- package/dist/types/a2a.d.ts.map +1 -0
- package/dist/types/a2a.js +14 -0
- package/dist/types/a2a.js.map +1 -0
- package/dist/types/entities.d.ts +147 -0
- package/dist/types/entities.d.ts.map +1 -0
- package/dist/types/entities.js +2 -0
- package/dist/types/entities.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/server.d.ts +116 -0
- package/dist/types/server.d.ts.map +1 -0
- package/dist/types/server.js +2 -0
- package/dist/types/server.js.map +1 -0
- package/dist/types/utility.d.ts +213 -0
- package/dist/types/utility.d.ts.map +1 -0
- package/dist/types/utility.js +9 -0
- package/dist/types/utility.js.map +1 -0
- package/dist/utils/apiKeys.d.ts +32 -0
- package/dist/utils/apiKeys.d.ts.map +1 -0
- package/dist/utils/apiKeys.js +117 -0
- package/dist/utils/apiKeys.js.map +1 -0
- package/dist/utils/auth-detection.d.ts +23 -0
- package/dist/utils/auth-detection.d.ts.map +1 -0
- package/dist/utils/auth-detection.js +148 -0
- package/dist/utils/auth-detection.js.map +1 -0
- package/dist/utils/credential-store-utils.d.ts +11 -0
- package/dist/utils/credential-store-utils.d.ts.map +1 -0
- package/dist/utils/credential-store-utils.js +19 -0
- package/dist/utils/credential-store-utils.js.map +1 -0
- package/dist/utils/error.d.ts +526 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +282 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/execution.d.ts +18 -0
- package/dist/utils/execution.d.ts.map +1 -0
- package/dist/utils/execution.js +25 -0
- package/dist/utils/execution.js.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +79 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +102 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/logging.d.ts +11 -0
- package/dist/utils/logging.d.ts.map +1 -0
- package/dist/utils/logging.js +6 -0
- package/dist/utils/logging.js.map +1 -0
- package/dist/utils/mcp-client.d.ts +48 -0
- package/dist/utils/mcp-client.d.ts.map +1 -0
- package/dist/utils/mcp-client.js +174 -0
- package/dist/utils/mcp-client.js.map +1 -0
- package/dist/utils/tracer.d.ts +24 -0
- package/dist/utils/tracer.d.ts.map +1 -0
- package/dist/utils/tracer.js +110 -0
- package/dist/utils/tracer.js.map +1 -0
- package/dist/validation/graphFull.d.ts +36 -0
- package/dist/validation/graphFull.d.ts.map +1 -0
- package/dist/validation/graphFull.js +128 -0
- package/dist/validation/graphFull.js.map +1 -0
- package/dist/validation/id-validation.d.ts +38 -0
- package/dist/validation/id-validation.d.ts.map +1 -0
- package/dist/validation/id-validation.js +60 -0
- package/dist/validation/id-validation.js.map +1 -0
- package/dist/validation/index.d.ts +4 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +5 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/schemas.d.ts +7213 -0
- package/dist/validation/schemas.d.ts.map +1 -0
- package/dist/validation/schemas.js +576 -0
- package/dist/validation/schemas.js.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
/**
|
|
3
|
+
* Credential store interface for managing different types of credentials
|
|
4
|
+
*/
|
|
5
|
+
export interface CredentialStore {
|
|
6
|
+
/**
|
|
7
|
+
* Unique identifier for this credential store
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* Type of credential store
|
|
12
|
+
*/
|
|
13
|
+
type: string;
|
|
14
|
+
/**
|
|
15
|
+
* Get a credential by key
|
|
16
|
+
*/
|
|
17
|
+
get(key: string): Promise<string | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Set a credential
|
|
20
|
+
*/
|
|
21
|
+
set(key: string, value: string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a credential exists
|
|
24
|
+
*/
|
|
25
|
+
has(key: string): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Delete a credential
|
|
28
|
+
*/
|
|
29
|
+
delete(key: string): Promise<boolean>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Server configuration options for HTTP server behavior
|
|
33
|
+
* These settings control connection management, timeouts, and server behavior
|
|
34
|
+
*/
|
|
35
|
+
export interface ServerOptions {
|
|
36
|
+
/**
|
|
37
|
+
* Server port to listen on
|
|
38
|
+
* Default: 3000
|
|
39
|
+
*/
|
|
40
|
+
port?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Keep alive timeout in milliseconds
|
|
43
|
+
* Time to wait for additional data after the last response before closing the connection.
|
|
44
|
+
* Used for persistent connections to improve performance by reusing connections.
|
|
45
|
+
* Scenario: Set higher (10-30s) for high-traffic APIs, lower (1-5s) for low-traffic services.
|
|
46
|
+
* Default: 60000ms (60 seconds)
|
|
47
|
+
*/
|
|
48
|
+
keepAliveTimeout?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Enable keep alive connections
|
|
51
|
+
* When true, allows connection reuse for multiple requests.
|
|
52
|
+
* Improves performance but uses more server resources.
|
|
53
|
+
* Scenario: Enable for APIs with frequent requests, disable for one-off services.
|
|
54
|
+
* Default: true
|
|
55
|
+
*/
|
|
56
|
+
keepAlive?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Request timeout in milliseconds
|
|
59
|
+
* Maximum time to wait for a complete request from the client.
|
|
60
|
+
* Helps prevent DoS attacks by limiting resource consumption from slow clients.
|
|
61
|
+
* Scenario: Set lower (30s) for simple APIs, higher (5-10min) for file upload services.
|
|
62
|
+
* Default: 60000ms (60 seconds)
|
|
63
|
+
*/
|
|
64
|
+
requestTimeout?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* CORS configuration compatible with Hono's CORSOptions
|
|
68
|
+
*/
|
|
69
|
+
export interface CorsConfig {
|
|
70
|
+
/**
|
|
71
|
+
* Allowed origins - string, array of strings, or function
|
|
72
|
+
*/
|
|
73
|
+
origin?: string | string[] | ((origin: string, c?: Context) => string | null | undefined);
|
|
74
|
+
/**
|
|
75
|
+
* Allowed methods
|
|
76
|
+
*/
|
|
77
|
+
allowMethods?: string[];
|
|
78
|
+
/**
|
|
79
|
+
* Allowed headers
|
|
80
|
+
*/
|
|
81
|
+
allowHeaders?: string[];
|
|
82
|
+
/**
|
|
83
|
+
* Exposed headers
|
|
84
|
+
*/
|
|
85
|
+
exposeHeaders?: string[];
|
|
86
|
+
/**
|
|
87
|
+
* Max age for preflight requests
|
|
88
|
+
*/
|
|
89
|
+
maxAge?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Whether to allow credentials
|
|
92
|
+
*/
|
|
93
|
+
credentials?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Base server configuration for all Inkeep services
|
|
97
|
+
*/
|
|
98
|
+
export interface ServerConfig {
|
|
99
|
+
/**
|
|
100
|
+
* Server port to listen on
|
|
101
|
+
*/
|
|
102
|
+
port?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Server options for HTTP behavior
|
|
105
|
+
*/
|
|
106
|
+
serverOptions?: ServerOptions;
|
|
107
|
+
/**
|
|
108
|
+
* Array of credential stores for managing API keys, tokens, etc.
|
|
109
|
+
*/
|
|
110
|
+
credentialStores?: CredentialStore[];
|
|
111
|
+
/**
|
|
112
|
+
* CORS configuration
|
|
113
|
+
*/
|
|
114
|
+
cors?: CorsConfig;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/types/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAEzC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnC;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IAE1F;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAEzB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IAErC;;OAEG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/types/server.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { ApiKeySelect } from '../index';
|
|
3
|
+
import type { McpTransportConfigSchema, ModelSchema, StatusComponentSchema, StatusUpdateSchema } from '../validation/schemas';
|
|
4
|
+
export type MessageVisibility = 'user-facing' | 'internal' | 'system' | 'external';
|
|
5
|
+
export type MessageType = 'chat' | 'a2a-request' | 'a2a-response' | 'task-update' | 'tool-call';
|
|
6
|
+
export type MessageRole = 'user' | 'agent' | 'system';
|
|
7
|
+
export type MessageMode = 'full' | 'scoped' | 'none';
|
|
8
|
+
export type Models = z.infer<typeof ModelSchema>;
|
|
9
|
+
export type ModelSettings = {
|
|
10
|
+
model?: string;
|
|
11
|
+
providerOptions?: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
export type StatusUpdateSettings = z.infer<typeof StatusUpdateSchema>;
|
|
14
|
+
export type StatusComponent = z.infer<typeof StatusComponentSchema>;
|
|
15
|
+
export type PaginationConfig = {
|
|
16
|
+
page?: number;
|
|
17
|
+
limit?: number;
|
|
18
|
+
};
|
|
19
|
+
export type PaginationResult = {
|
|
20
|
+
page: number;
|
|
21
|
+
limit: number;
|
|
22
|
+
total: number;
|
|
23
|
+
pages: number;
|
|
24
|
+
};
|
|
25
|
+
export type ScopeConfig = {
|
|
26
|
+
tenantId: string;
|
|
27
|
+
projectId: string;
|
|
28
|
+
};
|
|
29
|
+
export interface ConversationScopeOptions {
|
|
30
|
+
taskId?: string;
|
|
31
|
+
agentId?: string;
|
|
32
|
+
}
|
|
33
|
+
export type ConversationHistoryConfig = {
|
|
34
|
+
mode?: 'full' | 'scoped' | 'none';
|
|
35
|
+
limit?: number;
|
|
36
|
+
maxOutputTokens?: number;
|
|
37
|
+
includeInternal?: boolean;
|
|
38
|
+
messageTypes?: MessageType[];
|
|
39
|
+
};
|
|
40
|
+
export interface AgentConversationHistoryConfig extends ConversationHistoryConfig {
|
|
41
|
+
mode: 'full' | 'scoped' | 'none';
|
|
42
|
+
}
|
|
43
|
+
export type ConversationMetadata = {
|
|
44
|
+
userContext?: Record<string, unknown>;
|
|
45
|
+
preferences?: Record<string, unknown>;
|
|
46
|
+
sessionData?: Record<string, unknown>;
|
|
47
|
+
};
|
|
48
|
+
export type MessageContent = {
|
|
49
|
+
text?: string;
|
|
50
|
+
parts?: Array<{
|
|
51
|
+
kind: string;
|
|
52
|
+
text?: string;
|
|
53
|
+
data?: string | Record<string, unknown>;
|
|
54
|
+
metadata?: Record<string, unknown>;
|
|
55
|
+
}>;
|
|
56
|
+
tool_calls?: Array<{
|
|
57
|
+
id: string;
|
|
58
|
+
type: string;
|
|
59
|
+
function: {
|
|
60
|
+
name: string;
|
|
61
|
+
arguments: string;
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
64
|
+
tool_call_id?: string;
|
|
65
|
+
name?: string;
|
|
66
|
+
};
|
|
67
|
+
export type MessageMetadata = {
|
|
68
|
+
openai_model?: string;
|
|
69
|
+
finish_reason?: string;
|
|
70
|
+
usage?: {
|
|
71
|
+
prompt_tokens?: number;
|
|
72
|
+
completion_tokens?: number;
|
|
73
|
+
total_tokens?: number;
|
|
74
|
+
};
|
|
75
|
+
a2a_metadata?: Record<string, unknown>;
|
|
76
|
+
processing_time_ms?: number;
|
|
77
|
+
error_details?: Record<string, unknown>;
|
|
78
|
+
};
|
|
79
|
+
export type ContextFetchDefinition = {
|
|
80
|
+
id: string;
|
|
81
|
+
name?: string;
|
|
82
|
+
trigger: 'initialization' | 'invocation';
|
|
83
|
+
fetchConfig: {
|
|
84
|
+
url: string;
|
|
85
|
+
method?: string;
|
|
86
|
+
headers?: Record<string, string>;
|
|
87
|
+
body?: Record<string, unknown>;
|
|
88
|
+
transform?: string;
|
|
89
|
+
timeout?: number;
|
|
90
|
+
};
|
|
91
|
+
responseSchema?: Record<string, unknown>;
|
|
92
|
+
defaultValue?: unknown;
|
|
93
|
+
credentialReferenceId?: string;
|
|
94
|
+
};
|
|
95
|
+
export type ContextCacheEntry = {
|
|
96
|
+
id: string;
|
|
97
|
+
tenantId: string;
|
|
98
|
+
projectId: string;
|
|
99
|
+
conversationId: string;
|
|
100
|
+
contextConfigId: string;
|
|
101
|
+
contextVariableKey: string;
|
|
102
|
+
value: unknown;
|
|
103
|
+
requestHash?: string;
|
|
104
|
+
fetchedAt: Date;
|
|
105
|
+
fetchSource?: string;
|
|
106
|
+
fetchDurationMs?: number;
|
|
107
|
+
createdAt: Date;
|
|
108
|
+
updatedAt: Date;
|
|
109
|
+
};
|
|
110
|
+
export type McpTranportType = 'streamable_http' | 'sse';
|
|
111
|
+
export type McpAuthType = 'bearer' | 'basic' | 'api_key' | 'none';
|
|
112
|
+
export type McpServerAuth = {
|
|
113
|
+
type: McpAuthType;
|
|
114
|
+
token?: string;
|
|
115
|
+
username?: string;
|
|
116
|
+
password?: string;
|
|
117
|
+
apiKey?: string;
|
|
118
|
+
headerName?: string;
|
|
119
|
+
};
|
|
120
|
+
export type McpTransportConfig = z.infer<typeof McpTransportConfigSchema>;
|
|
121
|
+
export type McpServerCapabilities = {
|
|
122
|
+
tools?: boolean;
|
|
123
|
+
resources?: boolean;
|
|
124
|
+
prompts?: boolean;
|
|
125
|
+
logging?: boolean;
|
|
126
|
+
};
|
|
127
|
+
export type McpToolDefinition = {
|
|
128
|
+
name: string;
|
|
129
|
+
description?: string;
|
|
130
|
+
inputSchema?: Record<string, unknown>;
|
|
131
|
+
};
|
|
132
|
+
export type ToolMcpConfig = {
|
|
133
|
+
server: {
|
|
134
|
+
url: string;
|
|
135
|
+
timeout?: number;
|
|
136
|
+
headers?: Record<string, string>;
|
|
137
|
+
};
|
|
138
|
+
transport?: McpTransportConfig;
|
|
139
|
+
activeTools?: string[];
|
|
140
|
+
};
|
|
141
|
+
export type ToolServerCapabilities = {
|
|
142
|
+
tools?: boolean;
|
|
143
|
+
resources?: boolean;
|
|
144
|
+
prompts?: boolean;
|
|
145
|
+
logging?: boolean;
|
|
146
|
+
streaming?: boolean;
|
|
147
|
+
};
|
|
148
|
+
export type TaskMetadataConfig = {
|
|
149
|
+
conversation_id: string;
|
|
150
|
+
message_id: string;
|
|
151
|
+
created_at: string;
|
|
152
|
+
updated_at: string;
|
|
153
|
+
root_agent_id?: string;
|
|
154
|
+
agent_id?: string;
|
|
155
|
+
tool_id?: string;
|
|
156
|
+
graph_id?: string;
|
|
157
|
+
stream_request_id?: string;
|
|
158
|
+
};
|
|
159
|
+
export interface ProjectInfo {
|
|
160
|
+
projectId: string;
|
|
161
|
+
}
|
|
162
|
+
export interface ProjectResourceCounts {
|
|
163
|
+
agents: number;
|
|
164
|
+
agentGraphs: number;
|
|
165
|
+
tools: number;
|
|
166
|
+
contextConfigs: number;
|
|
167
|
+
externalAgents: number;
|
|
168
|
+
}
|
|
169
|
+
export interface RequestSchemaDefinition {
|
|
170
|
+
body?: z.ZodSchema<any>;
|
|
171
|
+
headers?: z.ZodSchema<any>;
|
|
172
|
+
query?: z.ZodSchema<any>;
|
|
173
|
+
params?: z.ZodSchema<any>;
|
|
174
|
+
}
|
|
175
|
+
export interface RequestSchemaConfig {
|
|
176
|
+
schemas: RequestSchemaDefinition;
|
|
177
|
+
optional?: ('body' | 'headers' | 'query' | 'params')[];
|
|
178
|
+
}
|
|
179
|
+
export type toolStatus = 'healthy' | 'unhealthy' | 'unknown';
|
|
180
|
+
export declare const TOOL_STATUS_VALUES: readonly ["healthy", "unhealthy", "unknown", "disabled", "needs_auth"];
|
|
181
|
+
export declare const VALID_RELATION_TYPES: readonly ["transfer", "delegate"];
|
|
182
|
+
export type McpToolStatus = (typeof TOOL_STATUS_VALUES)[number];
|
|
183
|
+
export interface CreateApiKeyParams {
|
|
184
|
+
tenantId: string;
|
|
185
|
+
projectId: string;
|
|
186
|
+
graphId: string;
|
|
187
|
+
expiresAt?: string;
|
|
188
|
+
}
|
|
189
|
+
export interface ApiKeyCreateResult {
|
|
190
|
+
apiKey: ApiKeySelect;
|
|
191
|
+
key: string;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Execution context that gets propagated through agent calls
|
|
195
|
+
* Contains authentication and routing information for internal API calls
|
|
196
|
+
*/
|
|
197
|
+
export interface ExecutionContext {
|
|
198
|
+
/** The original API key from the client request */
|
|
199
|
+
apiKey: string;
|
|
200
|
+
/** Tenant ID extracted from API key */
|
|
201
|
+
tenantId: string;
|
|
202
|
+
/** Project ID extracted from API key */
|
|
203
|
+
projectId: string;
|
|
204
|
+
/** Graph ID extracted from API key */
|
|
205
|
+
graphId: string;
|
|
206
|
+
/** Base URL for internal API calls */
|
|
207
|
+
baseUrl: string;
|
|
208
|
+
/** API key ID for tracking */
|
|
209
|
+
apiKeyId: string;
|
|
210
|
+
/** Agent ID extracted from request headers (only for internal A2A calls) */
|
|
211
|
+
agentId?: string;
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=utility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../../src/types/utility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EACV,wBAAwB,EACxB,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAG/B,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAC;AACnF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,aAAa,GAAG,cAAc,GAAG,aAAa,GAAG,WAAW,CAAC;AAChG,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AACtD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAErD,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AACjD,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACtE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAA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C,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../src/types/utility.ts"],"names":[],"mappings":"AA6NA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,SAAS;IACT,WAAW;IACX,SAAS;IACT,UAAU;IACV,YAAY;CACJ,CAAC;AAEX,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,UAAU,EAAE,UAAU,CAAU,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type ApiKeyGenerationResult = {
|
|
2
|
+
id: string;
|
|
3
|
+
publicId: string;
|
|
4
|
+
key: string;
|
|
5
|
+
keyHash: string;
|
|
6
|
+
keyPrefix: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Generate a new API key with secure random bytes
|
|
10
|
+
*/
|
|
11
|
+
export declare function generateApiKey(): Promise<ApiKeyGenerationResult>;
|
|
12
|
+
/**
|
|
13
|
+
* Hash an API key using scrypt
|
|
14
|
+
*/
|
|
15
|
+
export declare function hashApiKey(key: string): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Validate an API key against its hash
|
|
18
|
+
*/
|
|
19
|
+
export declare function validateApiKey(key: string, storedHash: string): Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Check if an API key has expired
|
|
22
|
+
*/
|
|
23
|
+
export declare function isApiKeyExpired(expiresAt?: string | null): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Extract the publicId from an API key
|
|
26
|
+
*/
|
|
27
|
+
export declare function extractPublicId(key: string): string | null;
|
|
28
|
+
/**
|
|
29
|
+
* Mask an API key for display (show only prefix and last 4 chars)
|
|
30
|
+
*/
|
|
31
|
+
export declare function maskApiKey(keyPrefix: string): string;
|
|
32
|
+
//# sourceMappingURL=apiKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiKeys.d.ts","sourceRoot":"","sources":["../../src/utils/apiKeys.ts"],"names":[],"mappings":"AAkBA,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,sBAAsB,CAAC,CA0BtE;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAY7D;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAmBtF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CASlE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA2B1D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { randomBytes, scrypt, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import { customAlphabet, nanoid } from 'nanoid';
|
|
4
|
+
import { getLogger } from './logger';
|
|
5
|
+
const scryptAsync = promisify(scrypt);
|
|
6
|
+
const logger = getLogger('api-key');
|
|
7
|
+
// API key configuration
|
|
8
|
+
const API_KEY_LENGTH = 32; // Length of random bytes
|
|
9
|
+
const SALT_LENGTH = 32; // Length of salt for hashing
|
|
10
|
+
const KEY_LENGTH = 64; // Length of derived key from scrypt
|
|
11
|
+
const PUBLIC_ID_LENGTH = 12;
|
|
12
|
+
// Custom alphabet excluding underscores and dots
|
|
13
|
+
const PUBLIC_ID_ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-';
|
|
14
|
+
const generatePublicId = customAlphabet(PUBLIC_ID_ALPHABET, PUBLIC_ID_LENGTH);
|
|
15
|
+
/**
|
|
16
|
+
* Generate a new API key with secure random bytes
|
|
17
|
+
*/
|
|
18
|
+
export async function generateApiKey() {
|
|
19
|
+
const publicId = generatePublicId();
|
|
20
|
+
// Generate secret part (random bytes)
|
|
21
|
+
const secretBytes = randomBytes(API_KEY_LENGTH);
|
|
22
|
+
const secret = secretBytes.toString('base64url');
|
|
23
|
+
// Create key in format: sk_<env>_<publicId>.<secret>
|
|
24
|
+
const key = `sk_${publicId}.${secret}`;
|
|
25
|
+
// Extract prefix for identification (first 12 chars)
|
|
26
|
+
const keyPrefix = key.substring(0, 12);
|
|
27
|
+
// Hash the entire key for storage
|
|
28
|
+
const keyHash = await hashApiKey(key);
|
|
29
|
+
// Generate unique ID for database record
|
|
30
|
+
const id = nanoid();
|
|
31
|
+
return {
|
|
32
|
+
id,
|
|
33
|
+
publicId,
|
|
34
|
+
key,
|
|
35
|
+
keyHash,
|
|
36
|
+
keyPrefix,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Hash an API key using scrypt
|
|
41
|
+
*/
|
|
42
|
+
export async function hashApiKey(key) {
|
|
43
|
+
// Generate a random salt
|
|
44
|
+
const salt = randomBytes(SALT_LENGTH);
|
|
45
|
+
// Hash the key with scrypt
|
|
46
|
+
const hashedBuffer = (await scryptAsync(key, salt, KEY_LENGTH));
|
|
47
|
+
// Combine salt and hash for storage
|
|
48
|
+
const combined = Buffer.concat([salt, hashedBuffer]);
|
|
49
|
+
// Return as base64 string
|
|
50
|
+
return combined.toString('base64');
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Validate an API key against its hash
|
|
54
|
+
*/
|
|
55
|
+
export async function validateApiKey(key, storedHash) {
|
|
56
|
+
try {
|
|
57
|
+
// Decode the stored hash
|
|
58
|
+
const combined = Buffer.from(storedHash, 'base64');
|
|
59
|
+
// Extract salt and hash
|
|
60
|
+
const salt = combined.subarray(0, SALT_LENGTH);
|
|
61
|
+
const storedHashBuffer = combined.subarray(SALT_LENGTH);
|
|
62
|
+
// Hash the provided key with the same salt
|
|
63
|
+
const hashedBuffer = (await scryptAsync(key, salt, KEY_LENGTH));
|
|
64
|
+
// Use timing-safe comparison to prevent timing attacks
|
|
65
|
+
return timingSafeEqual(storedHashBuffer, hashedBuffer);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
logger.error({ error }, 'Error validating API key');
|
|
69
|
+
// Return false for any errors (invalid format, etc.)
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check if an API key has expired
|
|
75
|
+
*/
|
|
76
|
+
export function isApiKeyExpired(expiresAt) {
|
|
77
|
+
if (!expiresAt) {
|
|
78
|
+
return false; // No expiration set
|
|
79
|
+
}
|
|
80
|
+
const expirationDate = new Date(expiresAt);
|
|
81
|
+
const now = new Date();
|
|
82
|
+
return now > expirationDate;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Extract the publicId from an API key
|
|
86
|
+
*/
|
|
87
|
+
export function extractPublicId(key) {
|
|
88
|
+
try {
|
|
89
|
+
// Expected format: sk_<env>_<publicId>.<secret> or sk_<publicId>.<secret>
|
|
90
|
+
const parts = key.split('.');
|
|
91
|
+
if (parts.length !== 2) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
const prefixPart = parts[0]; // e.g., "sk_test_abc123def456" or "sk_abc123def456"
|
|
95
|
+
const segments = prefixPart.split('_');
|
|
96
|
+
if (segments.length < 2) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
// Get the last segment which should be the publicId
|
|
100
|
+
const publicId = segments[segments.length - 1];
|
|
101
|
+
// Validate publicId length (should be 12 chars)
|
|
102
|
+
if (publicId.length !== 12) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return publicId;
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Mask an API key for display (show only prefix and last 4 chars)
|
|
113
|
+
*/
|
|
114
|
+
export function maskApiKey(keyPrefix) {
|
|
115
|
+
return `${keyPrefix}...`;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=apiKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiKeys.js","sourceRoot":"","sources":["../../src/utils/apiKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AACtC,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;AAEpC,wBAAwB;AACxB,MAAM,cAAc,GAAG,EAAE,CAAC,CAAC,yBAAyB;AACpD,MAAM,WAAW,GAAG,EAAE,CAAC,CAAC,6BAA6B;AACrD,MAAM,UAAU,GAAG,EAAE,CAAC,CAAC,oCAAoC;AAC3D,MAAM,gBAAgB,GA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U,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,oDAAoD;QACjF,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEvC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,oDAAoD;QACpD,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAE/C,gDAAgD;QAChD,IAAI,QAAQ,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,SAAiB;IAC1C,OAAO,GAAG,SAAS,KAAK,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized authentication detection utilities for MCP tools
|
|
3
|
+
*/
|
|
4
|
+
import type { McpTool } from '../types/entities';
|
|
5
|
+
import type { Logger } from './logging';
|
|
6
|
+
/**
|
|
7
|
+
* OAuth configuration interface
|
|
8
|
+
*/
|
|
9
|
+
export interface OAuthConfig {
|
|
10
|
+
authorizationUrl: string;
|
|
11
|
+
tokenUrl: string;
|
|
12
|
+
registrationUrl?: string;
|
|
13
|
+
supportsDynamicRegistration: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Full OAuth endpoint discovery with complete configuration
|
|
17
|
+
*/
|
|
18
|
+
export declare const discoverOAuthEndpoints: (serverUrl: string, logger?: Logger) => Promise<OAuthConfig | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Detect if OAuth 2.1/PKCE authentication is specifically required for a tool
|
|
21
|
+
*/
|
|
22
|
+
export declare const detectAuthenticationRequired: (tool: McpTool, error: Error, logger?: Logger) => Promise<boolean>;
|
|
23
|
+
//# sourceMappingURL=auth-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-detection.d.ts","sourceRoot":"","sources":["../../src/utils/auth-detection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2BAA2B,EAAE,OAAO,CAAC;CACtC;AA6DD;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,WAAW,MAAM,EACjB,SAAS,MAAM,KACd,OAAO,CAAC,WAAW,GAAG,IAAI,CAkC5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,GACvC,MAAM,OAAO,EACb,OAAO,KAAK,EACZ,SAAS,MAAM,KACd,OAAO,CAAC,OAAO,CAsEjB,CAAC"}
|