@juspay/neurolink 9.56.2 → 9.57.1
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/CHANGELOG.md +12 -0
- package/dist/auth/AuthProviderFactory.d.ts +3 -3
- package/dist/auth/providers/BaseAuthProvider.d.ts +2 -2
- package/dist/auth/providers/BaseAuthProvider.js +1 -1
- package/dist/auth/serverBridge.d.ts +2 -2
- package/dist/browser/neurolink.min.js +285 -285
- package/dist/cli/factories/commandFactory.js +32 -8
- package/dist/cli/loop/optionsSchema.js +4 -0
- package/dist/cli/parser.js +3 -3
- package/dist/constants/enums.d.ts +8 -1
- package/dist/constants/enums.js +7 -0
- package/dist/dynamic/dynamicResolver.d.ts +282 -0
- package/dist/dynamic/dynamicResolver.js +633 -0
- package/dist/dynamic/index.d.ts +10 -0
- package/dist/dynamic/index.js +12 -0
- package/dist/dynamic/resolution.d.ts +17 -0
- package/dist/dynamic/resolution.js +21 -0
- package/dist/evaluation/index.js +1 -1
- package/dist/index.js +19 -2
- package/dist/lib/auth/AuthProviderFactory.d.ts +3 -3
- package/dist/lib/auth/providers/BaseAuthProvider.d.ts +2 -2
- package/dist/lib/auth/providers/BaseAuthProvider.js +1 -1
- package/dist/lib/auth/serverBridge.d.ts +2 -2
- package/dist/lib/constants/enums.d.ts +8 -1
- package/dist/lib/constants/enums.js +7 -0
- package/dist/lib/dynamic/dynamicResolver.d.ts +282 -0
- package/dist/lib/dynamic/dynamicResolver.js +634 -0
- package/dist/lib/dynamic/index.d.ts +10 -0
- package/dist/lib/dynamic/index.js +13 -0
- package/dist/lib/dynamic/resolution.d.ts +17 -0
- package/dist/lib/dynamic/resolution.js +22 -0
- package/dist/lib/evaluation/index.js +1 -1
- package/dist/lib/index.js +19 -2
- package/dist/lib/mcp/mcpServerBase.d.ts +1 -1
- package/dist/lib/mcp/mcpServerBase.js +1 -1
- package/dist/lib/neurolink.d.ts +18 -6
- package/dist/lib/neurolink.js +187 -42
- package/dist/lib/observability/exporters/baseExporter.d.ts +1 -1
- package/dist/lib/observability/exporters/baseExporter.js +1 -1
- package/dist/lib/types/auth.d.ts +6 -6
- package/dist/lib/types/config.d.ts +4 -4
- package/dist/lib/types/dynamic.d.ts +98 -0
- package/dist/lib/types/dynamic.js +10 -0
- package/dist/lib/types/generate.d.ts +29 -0
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/index.js +2 -0
- package/dist/lib/types/scorer.d.ts +1 -1
- package/dist/lib/types/scorer.js +1 -1
- package/dist/lib/types/span.d.ts +1 -1
- package/dist/lib/types/span.js +1 -1
- package/dist/lib/types/stream.d.ts +6 -0
- package/dist/lib/utils/conversationMemory.d.ts +10 -0
- package/dist/lib/utils/conversationMemory.js +185 -1
- package/dist/lib/utils/errorHandling.d.ts +13 -0
- package/dist/lib/utils/errorHandling.js +31 -0
- package/dist/mcp/mcpServerBase.d.ts +1 -1
- package/dist/mcp/mcpServerBase.js +1 -1
- package/dist/neurolink.d.ts +18 -6
- package/dist/neurolink.js +187 -42
- package/dist/observability/exporters/baseExporter.d.ts +1 -1
- package/dist/observability/exporters/baseExporter.js +1 -1
- package/dist/types/auth.d.ts +6 -6
- package/dist/types/config.d.ts +4 -4
- package/dist/types/dynamic.d.ts +98 -0
- package/dist/types/dynamic.js +9 -0
- package/dist/types/generate.d.ts +29 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/scorer.d.ts +1 -1
- package/dist/types/scorer.js +1 -1
- package/dist/types/span.d.ts +1 -1
- package/dist/types/span.js +1 -1
- package/dist/types/stream.d.ts +6 -0
- package/dist/utils/conversationMemory.d.ts +10 -0
- package/dist/utils/conversationMemory.js +185 -1
- package/dist/utils/errorHandling.d.ts +13 -0
- package/dist/utils/errorHandling.js +31 -0
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ export { AIProviderFactory };
|
|
|
37
37
|
export { GoogleTTSHandler } from "./adapters/tts/googleTTSHandler.js";
|
|
38
38
|
// Config Manager export
|
|
39
39
|
export { NeuroLinkConfigManager as ConfigManager } from "./config/configManager.js";
|
|
40
|
-
// Core Infrastructure exports (
|
|
40
|
+
// Core Infrastructure exports (factory + registry patterns)
|
|
41
41
|
export { BaseFactory, BaseRegistry, NeuroLinkFeatureError, createErrorFactory, withRetry, TypedEventEmitter, } from "./core/infrastructure/index.js";
|
|
42
42
|
// ============================================================================
|
|
43
43
|
// CLIENT SDK EXPORTS - Type-safe API access for browser and Node.js
|
|
@@ -107,6 +107,23 @@ export { SpanSerializer } from "./observability/utils/spanSerializer.js";
|
|
|
107
107
|
// Middleware exports
|
|
108
108
|
// Version
|
|
109
109
|
export const VERSION = "1.0.0";
|
|
110
|
+
// ============================================================================
|
|
111
|
+
// Dynamic Arguments
|
|
112
|
+
// ============================================================================
|
|
113
|
+
//
|
|
114
|
+
// Dynamic arguments let you pass functions instead of static values to
|
|
115
|
+
// generate() and stream(). Resolution happens automatically before
|
|
116
|
+
// provider dispatch. Pass dynamicContext inline for per-request
|
|
117
|
+
// user/tenant/session context that dynamic functions can read.
|
|
118
|
+
//
|
|
119
|
+
// Example:
|
|
120
|
+
// await neurolink.generate({
|
|
121
|
+
// input: { text: "Hello" },
|
|
122
|
+
// model: (ctx) => ctx.requestContext.tenant?.plan === "enterprise"
|
|
123
|
+
// ? "gpt-4o" : "gpt-4o-mini",
|
|
124
|
+
// dynamicContext: { tenant: { id: "t1", plan: "enterprise" } },
|
|
125
|
+
// });
|
|
126
|
+
// ============================================================================
|
|
110
127
|
/**
|
|
111
128
|
* Quick start factory function for creating AI provider instances.
|
|
112
129
|
*
|
|
@@ -348,7 +365,7 @@ export async function getTelemetryStatus() {
|
|
|
348
365
|
export {
|
|
349
366
|
// Main Evaluator
|
|
350
367
|
Evaluator,
|
|
351
|
-
// Factory and Registry
|
|
368
|
+
// Factory and Registry
|
|
352
369
|
EvaluationAggregator, EvaluatorFactory, getEvaluatorFactory, getEvaluatorRegistry,
|
|
353
370
|
// Error utilities
|
|
354
371
|
evaluationErrors, isRetryableEvaluationError, isEvaluationError, createEvaluationFailedError, createParseError, createStrategyNotFoundError, createProviderError, createMaxRetriesExceededError, createBatchEvaluationError, createConfigurationError, contextToErrorContext,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* extension, no singleton instance. Providers are registered by
|
|
6
6
|
* AuthProviderRegistry using dynamic imports to avoid circular dependencies.
|
|
7
7
|
*/
|
|
8
|
-
import type { AuthProviderConfig, AuthProviderConstructor, AuthProviderMetadata,
|
|
8
|
+
import type { AuthProviderConfig, AuthProviderConstructor, AuthProviderMetadata, AuthProvider } from "../types/index.js";
|
|
9
9
|
/**
|
|
10
10
|
* AuthProviderFactory - Creates authentication provider instances
|
|
11
11
|
*
|
|
@@ -33,7 +33,7 @@ export declare class AuthProviderFactory {
|
|
|
33
33
|
/**
|
|
34
34
|
* Create a provider instance
|
|
35
35
|
*/
|
|
36
|
-
static createProvider(typeOrAlias: string, config: AuthProviderConfig): Promise<
|
|
36
|
+
static createProvider(typeOrAlias: string, config: AuthProviderConfig): Promise<AuthProvider>;
|
|
37
37
|
/**
|
|
38
38
|
* Check if a provider is registered
|
|
39
39
|
*/
|
|
@@ -66,4 +66,4 @@ export declare class AuthProviderFactory {
|
|
|
66
66
|
/**
|
|
67
67
|
* Create an auth provider using the factory
|
|
68
68
|
*/
|
|
69
|
-
export declare function createAuthProvider(type: string, config: AuthProviderConfig): Promise<
|
|
69
|
+
export declare function createAuthProvider(type: string, config: AuthProviderConfig): Promise<AuthProvider>;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* - Error handling via unified AuthError factory
|
|
11
11
|
*/
|
|
12
12
|
import { EventEmitter } from "events";
|
|
13
|
-
import type { AuthenticatedContext, AuthHealthCheck, AuthorizationResult, AuthProviderConfig, AuthProviderType, AuthRequestContext, AuthSession, AuthUser,
|
|
13
|
+
import type { AuthenticatedContext, AuthHealthCheck, AuthorizationResult, AuthProviderConfig, AuthProviderType, AuthRequestContext, AuthSession, AuthUser, AuthProvider, RBACConfig, SessionConfig, SessionStorage, SessionValidationResult, TokenClaims, TokenValidationResult } from "../../types/index.js";
|
|
14
14
|
/**
|
|
15
15
|
* @deprecated Use `AuthError` from `../errors.js` instead.
|
|
16
16
|
* Kept for backward compatibility with CognitoProvider / KeycloakProvider.
|
|
@@ -81,7 +81,7 @@ export declare class InMemorySessionStorage implements SessionStorage {
|
|
|
81
81
|
* - updateUserPermissions() - Update user permissions in provider
|
|
82
82
|
* - dispose() - Clean up resources
|
|
83
83
|
*/
|
|
84
|
-
export declare abstract class BaseAuthProvider implements
|
|
84
|
+
export declare abstract class BaseAuthProvider implements AuthProvider {
|
|
85
85
|
abstract readonly type: AuthProviderType;
|
|
86
86
|
readonly config: AuthProviderConfig;
|
|
87
87
|
protected sessionStorage: SessionStorage;
|
|
@@ -607,7 +607,7 @@ export class BaseAuthProvider {
|
|
|
607
607
|
logger.debug(`[BaseAuthProvider] Disposed ${this.type} provider`);
|
|
608
608
|
}
|
|
609
609
|
// ===========================================================================
|
|
610
|
-
// METHODS FROM
|
|
610
|
+
// METHODS FROM AuthProvider INTERFACE
|
|
611
611
|
// ===========================================================================
|
|
612
612
|
/**
|
|
613
613
|
* Check if a user is authorized to perform an action
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Converts an auth provider's authenticateToken() into the validate
|
|
4
4
|
* callback expected by the existing createAuthMiddleware.
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { AuthProvider } from "../types/index.js";
|
|
7
7
|
/**
|
|
8
8
|
* Create a validate function for server auth middleware from an auth provider.
|
|
9
9
|
*/
|
|
10
|
-
export declare function createAuthValidatorFromProvider(provider:
|
|
10
|
+
export declare function createAuthValidatorFromProvider(provider: AuthProvider): (token: string, ctx: unknown) => Promise<{
|
|
11
11
|
id: string;
|
|
12
12
|
email?: string;
|
|
13
13
|
roles?: string[];
|
|
@@ -594,7 +594,14 @@ export declare enum ErrorCategory {
|
|
|
594
594
|
PERMISSION = "permission",
|
|
595
595
|
CONFIGURATION = "configuration",
|
|
596
596
|
EXECUTION = "execution",
|
|
597
|
-
SYSTEM = "system"
|
|
597
|
+
SYSTEM = "system",
|
|
598
|
+
/**
|
|
599
|
+
* Caller-initiated cancellation via AbortSignal. Distinct from system errors
|
|
600
|
+
* — represents a user/control-plane decision, not a SDK or provider failure.
|
|
601
|
+
* Consumers can branch on this category to differentiate "user cancelled"
|
|
602
|
+
* from "server error" without resorting to message-string matching.
|
|
603
|
+
*/
|
|
604
|
+
ABORT = "abort"
|
|
598
605
|
}
|
|
599
606
|
export declare enum ErrorSeverity {
|
|
600
607
|
LOW = "low",
|
|
@@ -812,6 +812,13 @@ export var ErrorCategory;
|
|
|
812
812
|
ErrorCategory["CONFIGURATION"] = "configuration";
|
|
813
813
|
ErrorCategory["EXECUTION"] = "execution";
|
|
814
814
|
ErrorCategory["SYSTEM"] = "system";
|
|
815
|
+
/**
|
|
816
|
+
* Caller-initiated cancellation via AbortSignal. Distinct from system errors
|
|
817
|
+
* — represents a user/control-plane decision, not a SDK or provider failure.
|
|
818
|
+
* Consumers can branch on this category to differentiate "user cancelled"
|
|
819
|
+
* from "server error" without resorting to message-string matching.
|
|
820
|
+
*/
|
|
821
|
+
ErrorCategory["ABORT"] = "abort";
|
|
815
822
|
})(ErrorCategory || (ErrorCategory = {}));
|
|
816
823
|
// Error severity levels
|
|
817
824
|
export var ErrorSeverity;
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic Argument Resolution Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for resolving dynamic arguments to their actual values,
|
|
5
|
+
* with support for caching, memoization, fallbacks, and conditional resolution.
|
|
6
|
+
*
|
|
7
|
+
* @module dynamic/dynamicResolver
|
|
8
|
+
*/
|
|
9
|
+
import type { DynamicArgument, DynamicResolutionContext, ResolutionOptions, ResolutionResult, DynamicConfig, ResolvedConfig } from "../types/index.js";
|
|
10
|
+
/**
|
|
11
|
+
* Resolution cache for dynamic arguments
|
|
12
|
+
*/
|
|
13
|
+
declare class ResolutionCache {
|
|
14
|
+
private cache;
|
|
15
|
+
private cleanupInterval;
|
|
16
|
+
constructor(cleanupIntervalMs?: number);
|
|
17
|
+
get<T>(key: string): T | undefined;
|
|
18
|
+
set<T>(key: string, value: T, ttl: number): void;
|
|
19
|
+
delete(key: string): boolean;
|
|
20
|
+
clear(): void;
|
|
21
|
+
size(): number;
|
|
22
|
+
private startCleanup;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
}
|
|
25
|
+
declare const globalCache: ResolutionCache;
|
|
26
|
+
/**
|
|
27
|
+
* Resolve a dynamic argument to its actual value
|
|
28
|
+
*
|
|
29
|
+
* @template T - The expected resolved type
|
|
30
|
+
* @param argument - The dynamic argument to resolve
|
|
31
|
+
* @param context - Resolution context (optional for static values)
|
|
32
|
+
* @param options - Resolution options
|
|
33
|
+
* @returns Resolution result with value and metadata
|
|
34
|
+
*
|
|
35
|
+
* @example Resolve static value
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const result = await resolveDynamicArgument("gpt-4o");
|
|
38
|
+
* console.log(result.value); // "gpt-4o"
|
|
39
|
+
* console.log(result.resolutionType); // "static"
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @example Resolve context-aware function
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const modelSelector = ({ requestContext }) =>
|
|
45
|
+
* requestContext.tenant?.plan === "enterprise" ? "claude-3-opus" : "claude-3-sonnet";
|
|
46
|
+
*
|
|
47
|
+
* const result = await resolveDynamicArgument(modelSelector, {
|
|
48
|
+
* requestContext: { requestId: "123", tenant: { id: "t1", plan: "enterprise" } }
|
|
49
|
+
* });
|
|
50
|
+
* console.log(result.value); // "claude-3-opus"
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveDynamicArgument<T>(argument: DynamicArgument<T>, context?: DynamicResolutionContext, options?: ResolutionOptions): Promise<ResolutionResult<T>>;
|
|
54
|
+
/**
|
|
55
|
+
* Resolve multiple dynamic arguments in parallel
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const [model, temperature] = await resolveDynamicArguments(
|
|
60
|
+
* [
|
|
61
|
+
* ({ requestContext }) => requestContext.user?.preferences?.preferredModel || "gpt-4o",
|
|
62
|
+
* 0.7,
|
|
63
|
+
* ],
|
|
64
|
+
* context
|
|
65
|
+
* );
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveDynamicArguments<T extends readonly unknown[]>(arguments_: {
|
|
69
|
+
[K in keyof T]: DynamicArgument<T[K]>;
|
|
70
|
+
}, context?: DynamicResolutionContext, options?: ResolutionOptions): Promise<{
|
|
71
|
+
[K in keyof T]: T[K];
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Resolve all properties of a dynamic configuration object
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const dynamicConfig = {
|
|
79
|
+
* model: ({ requestContext }) => requestContext.tenant?.settings?.defaultModel || "gpt-4o",
|
|
80
|
+
* temperature: 0.7,
|
|
81
|
+
* maxTokens: async () => (await fetchConfig()).maxTokens,
|
|
82
|
+
* };
|
|
83
|
+
*
|
|
84
|
+
* const resolved = await resolveDynamicConfig(dynamicConfig, context);
|
|
85
|
+
* // resolved.model, resolved.temperature, resolved.maxTokens are all resolved values
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare function resolveDynamicConfig<T extends Record<string, unknown>>(config: DynamicConfig<T>, context?: DynamicResolutionContext, options?: ResolutionOptions): Promise<ResolvedConfig<T>>;
|
|
89
|
+
/**
|
|
90
|
+
* Create a memoized dynamic argument that caches its result
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const expensiveModelSelector = memoizeDynamicArgument(
|
|
95
|
+
* async ({ requestContext }) => {
|
|
96
|
+
* const config = await fetchTenantConfig(requestContext.tenant?.id);
|
|
97
|
+
* return config.preferredModel;
|
|
98
|
+
* },
|
|
99
|
+
* { cacheTtl: 300000 } // Cache for 5 minutes
|
|
100
|
+
* );
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function memoizeDynamicArgument<T>(argument: DynamicArgument<T>, options?: {
|
|
104
|
+
cacheTtl?: number;
|
|
105
|
+
cacheKey?: string;
|
|
106
|
+
}): DynamicArgument<T>;
|
|
107
|
+
/**
|
|
108
|
+
* Create a dynamic argument with fallback chain
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const modelWithFallback = withFallback(
|
|
113
|
+
* ({ requestContext }) => requestContext.user?.preferences?.preferredModel,
|
|
114
|
+
* ({ requestContext }) => requestContext.tenant?.settings?.defaultModel,
|
|
115
|
+
* "gpt-4o" // Final static fallback
|
|
116
|
+
* );
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function withFallback<T>(...arguments_: DynamicArgument<T | undefined | null>[]): DynamicArgument<T>;
|
|
120
|
+
/**
|
|
121
|
+
* Create a conditional dynamic argument
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const conditionalModel = conditional(
|
|
126
|
+
* ({ requestContext }) => requestContext.tenant?.plan === "enterprise",
|
|
127
|
+
* "claude-3-opus", // If true
|
|
128
|
+
* "claude-3-sonnet" // If false
|
|
129
|
+
* );
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export declare function conditional<T>(condition: DynamicArgument<boolean>, ifTrue: DynamicArgument<T>, ifFalse: DynamicArgument<T>): DynamicArgument<T>;
|
|
133
|
+
/**
|
|
134
|
+
* Create a mapped dynamic argument that transforms the result
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* const upperCaseModel = mapDynamicArgument(
|
|
139
|
+
* ({ requestContext }) => requestContext.user?.preferences?.preferredModel,
|
|
140
|
+
* (model) => model?.toUpperCase()
|
|
141
|
+
* );
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
export declare function mapDynamicArgument<T, U>(argument: DynamicArgument<T>, transform: (value: T) => U | Promise<U>): DynamicArgument<U>;
|
|
145
|
+
/**
|
|
146
|
+
* Create a dynamic argument that combines multiple arguments
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* const combinedConfig = combineDynamicArguments(
|
|
151
|
+
* [
|
|
152
|
+
* ({ requestContext }) => requestContext.user?.preferences?.preferredModel,
|
|
153
|
+
* ({ requestContext }) => requestContext.tenant?.settings?.defaultTemperature,
|
|
154
|
+
* ],
|
|
155
|
+
* ([model, temperature]) => ({ model: model || "gpt-4o", temperature: temperature || 0.7 })
|
|
156
|
+
* );
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
export declare function combineDynamicArguments<T extends readonly unknown[], U>(arguments_: {
|
|
160
|
+
[K in keyof T]: DynamicArgument<T[K]>;
|
|
161
|
+
}, combiner: (values: T) => U | Promise<U>): DynamicArgument<U>;
|
|
162
|
+
/**
|
|
163
|
+
* Check if a value contains any dynamic arguments (is a function)
|
|
164
|
+
*/
|
|
165
|
+
export declare function hasDynamicArgument<T>(value: DynamicArgument<T>): boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Check if an object has any dynamic properties
|
|
168
|
+
*/
|
|
169
|
+
export declare function hasDynamicProperties<T extends Record<string, unknown>>(config: DynamicConfig<T>): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Clear the global resolution cache
|
|
172
|
+
*/
|
|
173
|
+
export declare function clearResolutionCache(): void;
|
|
174
|
+
/**
|
|
175
|
+
* Get resolution cache statistics
|
|
176
|
+
*/
|
|
177
|
+
export declare function getResolutionCacheStats(): {
|
|
178
|
+
size: number;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Destroy the resolver (cleanup intervals, etc.)
|
|
182
|
+
*/
|
|
183
|
+
export declare function destroyResolver(): void;
|
|
184
|
+
/**
|
|
185
|
+
* Interpolate environment variables in a string
|
|
186
|
+
*
|
|
187
|
+
* Supports syntax:
|
|
188
|
+
* - ${VAR} - Simple substitution
|
|
189
|
+
* - ${VAR:-default} - Use default if VAR is unset or empty
|
|
190
|
+
* - ${VAR:+replacement} - Use replacement if VAR is set and non-empty
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```typescript
|
|
194
|
+
* interpolateEnvVars("Model: ${DEFAULT_MODEL:-gpt-4o}");
|
|
195
|
+
* // Returns "Model: gpt-4o" if DEFAULT_MODEL is not set
|
|
196
|
+
*
|
|
197
|
+
* interpolateEnvVars("API Key: ${OPENAI_API_KEY}");
|
|
198
|
+
* // Returns "API Key: sk-xxx..." if OPENAI_API_KEY is set
|
|
199
|
+
*
|
|
200
|
+
* interpolateEnvVars("Debug: ${DEBUG:+enabled}");
|
|
201
|
+
* // Returns "Debug: enabled" if DEBUG is set, "Debug: " otherwise
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
export declare function interpolateEnvVars(input: string, customEnv?: Record<string, string | undefined>): string;
|
|
205
|
+
/**
|
|
206
|
+
* Create a dynamic argument that interpolates environment variables
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* const model = fromEnv("${PREFERRED_MODEL:-gpt-4o}");
|
|
211
|
+
* // Resolves to value of PREFERRED_MODEL or "gpt-4o" as fallback
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
export declare function fromEnv(template: string): DynamicArgument<string>;
|
|
215
|
+
/**
|
|
216
|
+
* Create a dynamic argument from a single environment variable
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* const apiKey = envVar("OPENAI_API_KEY");
|
|
221
|
+
* // Resolves to value of OPENAI_API_KEY or undefined
|
|
222
|
+
*
|
|
223
|
+
* const model = envVar("DEFAULT_MODEL", "gpt-4o");
|
|
224
|
+
* // Resolves to DEFAULT_MODEL value or "gpt-4o" as default
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
export declare function envVar<T extends string = string>(name: string, defaultValue?: T): DynamicArgument<T | undefined>;
|
|
228
|
+
/**
|
|
229
|
+
* Create a dynamic argument that selects from environment-based configurations
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* const model = envSwitch("NODE_ENV", {
|
|
234
|
+
* development: "gpt-4o-mini",
|
|
235
|
+
* production: "gpt-4o",
|
|
236
|
+
* test: "gpt-3.5-turbo",
|
|
237
|
+
* }, "gpt-4o-mini");
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
export declare function envSwitch<T>(envVarName: string, options: Record<string, T>, defaultValue: T): DynamicArgument<T>;
|
|
241
|
+
/**
|
|
242
|
+
* Create a dynamic argument that parses a JSON value from an environment variable
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* // If RATE_LIMITS='{"requestsPerMinute": 100, "tokensPerDay": 50000}'
|
|
247
|
+
* const rateLimits = envJson<RateLimits>("RATE_LIMITS", { requestsPerMinute: 10 });
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
export declare function envJson<T>(name: string, defaultValue?: T): DynamicArgument<T | undefined>;
|
|
251
|
+
/**
|
|
252
|
+
* Create a dynamic argument that reads a number from an environment variable
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```typescript
|
|
256
|
+
* const maxTokens = envNumber("MAX_TOKENS", 1000);
|
|
257
|
+
* const temperature = envNumber("TEMPERATURE", 0.7);
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
export declare function envNumber(name: string, defaultValue?: number): DynamicArgument<number | undefined>;
|
|
261
|
+
/**
|
|
262
|
+
* Create a dynamic argument that reads a boolean from an environment variable
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```typescript
|
|
266
|
+
* const enableDebug = envBoolean("DEBUG", false);
|
|
267
|
+
* const enableTools = envBoolean("ENABLE_TOOLS", true);
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
export declare function envBoolean(name: string, defaultValue?: boolean): DynamicArgument<boolean | undefined>;
|
|
271
|
+
/**
|
|
272
|
+
* Create a dynamic argument that reads a comma-separated list from an environment variable
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* // If ALLOWED_PROVIDERS='openai,anthropic,vertex'
|
|
277
|
+
* const providers = envList("ALLOWED_PROVIDERS", ["openai"]);
|
|
278
|
+
* // Returns ["openai", "anthropic", "vertex"]
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
export declare function envList(name: string, defaultValue?: string[], separator?: string): DynamicArgument<string[] | undefined>;
|
|
282
|
+
export { globalCache as resolutionCache };
|