@juspay/neurolink 9.56.1 → 9.57.0
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 +306 -306
- 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/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/files/fileReferenceRegistry.js +25 -10
- 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/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/files/fileReferenceRegistry.js +25 -10
- 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 +12 -4
- package/dist/lib/neurolink.js +79 -6
- 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/file.d.ts +10 -0
- package/dist/lib/types/fileReference.d.ts +9 -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/fileDetector.d.ts +7 -0
- package/dist/lib/utils/fileDetector.js +47 -0
- package/dist/lib/utils/messageBuilder.js +15 -1
- package/dist/lib/utils/mimeTypeHints.d.ts +40 -0
- package/dist/lib/utils/mimeTypeHints.js +122 -0
- package/dist/mcp/mcpServerBase.d.ts +1 -1
- package/dist/mcp/mcpServerBase.js +1 -1
- package/dist/neurolink.d.ts +12 -4
- package/dist/neurolink.js +79 -6
- 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/file.d.ts +10 -0
- package/dist/types/fileReference.d.ts +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/fileDetector.d.ts +7 -0
- package/dist/utils/fileDetector.js +47 -0
- package/dist/utils/messageBuilder.js +15 -1
- package/dist/utils/mimeTypeHints.d.ts +40 -0
- package/dist/utils/mimeTypeHints.js +121 -0
- package/package.json +1 -1
|
@@ -1858,7 +1858,17 @@ export class CLICommandFactory {
|
|
|
1858
1858
|
// Initialize SDK and session
|
|
1859
1859
|
const sdk = globalSession.getOrCreateNeuroLink();
|
|
1860
1860
|
const sessionVariables = globalSession.getSessionVariables();
|
|
1861
|
-
const enhancedOptions = {
|
|
1861
|
+
const enhancedOptions = {
|
|
1862
|
+
...options,
|
|
1863
|
+
...sessionVariables,
|
|
1864
|
+
// enabledToolNames must be string[] for the SDK — normalize from CSV string
|
|
1865
|
+
...(typeof sessionVariables.enabledToolNames === "string" && {
|
|
1866
|
+
enabledToolNames: sessionVariables.enabledToolNames
|
|
1867
|
+
.split(",")
|
|
1868
|
+
.map((t) => t.trim())
|
|
1869
|
+
.filter(Boolean),
|
|
1870
|
+
}),
|
|
1871
|
+
};
|
|
1862
1872
|
const sessionId = globalSession.getCurrentSessionId();
|
|
1863
1873
|
const context = sessionId
|
|
1864
1874
|
? { ...options.context, sessionId }
|
|
@@ -1879,8 +1889,7 @@ export class CLICommandFactory {
|
|
|
1879
1889
|
// Build multimodal input and output configuration
|
|
1880
1890
|
const generateInput = CLICommandFactory.buildGenerateMultimodalInput(inputText, argv);
|
|
1881
1891
|
const outputConfig = CLICommandFactory.buildGenerateOutputConfig(isVideoMode, isPPTMode, enhancedOptions);
|
|
1882
|
-
|
|
1883
|
-
const result = await sdk.generate({
|
|
1892
|
+
const runGenerate = () => sdk.generate({
|
|
1884
1893
|
input: generateInput,
|
|
1885
1894
|
csvOptions: {
|
|
1886
1895
|
maxRows: argv.csvMaxRows,
|
|
@@ -1902,6 +1911,7 @@ export class CLICommandFactory {
|
|
|
1902
1911
|
? enhancedOptions.timeout * 1000
|
|
1903
1912
|
: undefined,
|
|
1904
1913
|
disableTools: enhancedOptions.disableTools,
|
|
1914
|
+
enabledToolNames: enhancedOptions.enabledToolNames,
|
|
1905
1915
|
enableAnalytics: enhancedOptions.enableAnalytics,
|
|
1906
1916
|
enableEvaluation: enhancedOptions.enableEvaluation,
|
|
1907
1917
|
evaluationDomain: enhancedOptions.evaluationDomain,
|
|
@@ -1932,8 +1942,7 @@ export class CLICommandFactory {
|
|
|
1932
1942
|
enabled: true,
|
|
1933
1943
|
useAiResponse: true,
|
|
1934
1944
|
voice: enhancedOptions.ttsVoice,
|
|
1935
|
-
format: enhancedOptions.ttsFormat ||
|
|
1936
|
-
undefined,
|
|
1945
|
+
format: enhancedOptions.ttsFormat || undefined,
|
|
1937
1946
|
speed: enhancedOptions.ttsSpeed,
|
|
1938
1947
|
quality: enhancedOptions.ttsQuality,
|
|
1939
1948
|
output: enhancedOptions.ttsOutput,
|
|
@@ -1941,6 +1950,7 @@ export class CLICommandFactory {
|
|
|
1941
1950
|
}
|
|
1942
1951
|
: undefined,
|
|
1943
1952
|
});
|
|
1953
|
+
const result = await runGenerate();
|
|
1944
1954
|
// Handle successful result
|
|
1945
1955
|
await CLICommandFactory.handleGenerateSuccess(result, options, isVideoMode, isPPTMode, spinner);
|
|
1946
1956
|
}
|
|
@@ -2070,7 +2080,7 @@ export class CLICommandFactory {
|
|
|
2070
2080
|
const pdfFiles = CLICommandFactory.processCliPDFFiles(argv.pdf);
|
|
2071
2081
|
const videoFiles = CLICommandFactory.processCliVideoFiles(argv.video);
|
|
2072
2082
|
const files = CLICommandFactory.processCliFiles(argv.file);
|
|
2073
|
-
const
|
|
2083
|
+
const runStream = () => sdk.stream({
|
|
2074
2084
|
input: {
|
|
2075
2085
|
text: inputText,
|
|
2076
2086
|
...(imageBuffers && { images: imageBuffers }),
|
|
@@ -2098,6 +2108,7 @@ export class CLICommandFactory {
|
|
|
2098
2108
|
? enhancedOptions.timeout * 1000
|
|
2099
2109
|
: undefined,
|
|
2100
2110
|
disableTools: enhancedOptions.disableTools,
|
|
2111
|
+
enabledToolNames: enhancedOptions.enabledToolNames,
|
|
2101
2112
|
enableAnalytics: enhancedOptions.enableAnalytics,
|
|
2102
2113
|
enableEvaluation: enhancedOptions.enableEvaluation,
|
|
2103
2114
|
evaluationDomain: enhancedOptions.evaluationDomain,
|
|
@@ -2137,6 +2148,7 @@ export class CLICommandFactory {
|
|
|
2137
2148
|
}
|
|
2138
2149
|
: undefined,
|
|
2139
2150
|
});
|
|
2151
|
+
const stream = await runStream();
|
|
2140
2152
|
const streamResult = await CLICommandFactory.processStreamWithTimeout(stream, options);
|
|
2141
2153
|
await CLICommandFactory.displayStreamResults(stream, streamResult.content, options);
|
|
2142
2154
|
// Handle image output from stream (image models emit image events)
|
|
@@ -2489,7 +2501,17 @@ export class CLICommandFactory {
|
|
|
2489
2501
|
const results = [];
|
|
2490
2502
|
const sdk = globalSession.getOrCreateNeuroLink();
|
|
2491
2503
|
const sessionVariables = globalSession.getSessionVariables();
|
|
2492
|
-
const enhancedOptions = {
|
|
2504
|
+
const enhancedOptions = {
|
|
2505
|
+
...options,
|
|
2506
|
+
...sessionVariables,
|
|
2507
|
+
// enabledToolNames must be string[] for the SDK — normalize from CSV string
|
|
2508
|
+
...(typeof sessionVariables.enabledToolNames === "string" && {
|
|
2509
|
+
enabledToolNames: sessionVariables.enabledToolNames
|
|
2510
|
+
.split(",")
|
|
2511
|
+
.map((t) => t.trim())
|
|
2512
|
+
.filter(Boolean),
|
|
2513
|
+
}),
|
|
2514
|
+
};
|
|
2493
2515
|
const sessionId = globalSession.getCurrentSessionId();
|
|
2494
2516
|
for (let i = 0; i < prompts.length; i++) {
|
|
2495
2517
|
if (spinner) {
|
|
@@ -2525,7 +2547,7 @@ export class CLICommandFactory {
|
|
|
2525
2547
|
const context = sessionId
|
|
2526
2548
|
? { ...contextMetadata, sessionId }
|
|
2527
2549
|
: contextMetadata;
|
|
2528
|
-
const
|
|
2550
|
+
const runBatchGenerate = () => sdk.generate({
|
|
2529
2551
|
input: { text: inputText },
|
|
2530
2552
|
provider: enhancedOptions.provider,
|
|
2531
2553
|
model: enhancedOptions.model,
|
|
@@ -2536,6 +2558,7 @@ export class CLICommandFactory {
|
|
|
2536
2558
|
? enhancedOptions.timeout * 1000
|
|
2537
2559
|
: undefined,
|
|
2538
2560
|
disableTools: enhancedOptions.disableTools,
|
|
2561
|
+
enabledToolNames: enhancedOptions.enabledToolNames,
|
|
2539
2562
|
evaluationDomain: enhancedOptions.evaluationDomain,
|
|
2540
2563
|
toolUsageContext: enhancedOptions.toolUsageContext,
|
|
2541
2564
|
context: context,
|
|
@@ -2547,6 +2570,7 @@ export class CLICommandFactory {
|
|
|
2547
2570
|
}
|
|
2548
2571
|
: undefined,
|
|
2549
2572
|
});
|
|
2573
|
+
const result = await runBatchGenerate();
|
|
2550
2574
|
results.push({ prompt: prompts[i], response: result.content });
|
|
2551
2575
|
if (spinner) {
|
|
2552
2576
|
spinner.render();
|
|
@@ -41,6 +41,10 @@ export const textGenerationOptionsSchema = {
|
|
|
41
41
|
type: "boolean",
|
|
42
42
|
description: "Disable all tool usage for the AI.",
|
|
43
43
|
},
|
|
44
|
+
enabledToolNames: {
|
|
45
|
+
type: "string",
|
|
46
|
+
description: 'Comma-separated list of tool names to enable (e.g., "read,write,search").',
|
|
47
|
+
},
|
|
44
48
|
maxSteps: {
|
|
45
49
|
type: "number",
|
|
46
50
|
description: "Maximum number of tool execution steps.",
|
package/dist/cli/parser.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
1
2
|
import yargs from "yargs";
|
|
2
3
|
import { hideBin } from "yargs/helpers";
|
|
3
|
-
import chalk from "chalk";
|
|
4
4
|
import packageJson from "../../package.json" with { type: "json" };
|
|
5
|
-
import { CLICommandFactory } from "./factories/commandFactory.js";
|
|
6
5
|
import { globalSession } from "../lib/session/globalSessionState.js";
|
|
7
|
-
import { handleError } from "./errorHandler.js";
|
|
8
6
|
import { logger } from "../lib/utils/logger.js";
|
|
7
|
+
import { handleError } from "./errorHandler.js";
|
|
8
|
+
import { CLICommandFactory } from "./factories/commandFactory.js";
|
|
9
9
|
import { SetupCommandFactory } from "./factories/setupCommandFactory.js";
|
|
10
10
|
import { AuthCommandFactory } from "./factories/authCommandFactory.js";
|
|
11
11
|
import { ServerCommandFactory } from "./commands/server.js";
|
|
@@ -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 };
|