@agentix-e/nl2spel 1.2.1 → 1.2.2
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/dist/index.cjs +3040 -0
- package/dist/index.d.cts +908 -0
- package/dist/index.d.ts +908 -28
- package/dist/index.js +2999 -24
- package/package.json +16 -5
- package/dist/context/context-extractor.d.ts +0 -86
- package/dist/context/context-extractor.d.ts.map +0 -1
- package/dist/context/context-extractor.js +0 -181
- package/dist/context/context-extractor.js.map +0 -1
- package/dist/context/schema-formatter.d.ts +0 -20
- package/dist/context/schema-formatter.d.ts.map +0 -1
- package/dist/context/schema-formatter.js +0 -104
- package/dist/context/schema-formatter.js.map +0 -1
- package/dist/engine/nl2spel-engine.d.ts +0 -145
- package/dist/engine/nl2spel-engine.d.ts.map +0 -1
- package/dist/engine/nl2spel-engine.js +0 -130
- package/dist/engine/nl2spel-engine.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/pattern/builtin-patterns.d.ts +0 -12
- package/dist/pattern/builtin-patterns.d.ts.map +0 -1
- package/dist/pattern/builtin-patterns.js +0 -812
- package/dist/pattern/builtin-patterns.js.map +0 -1
- package/dist/pattern/pattern-definition.d.ts +0 -49
- package/dist/pattern/pattern-definition.d.ts.map +0 -1
- package/dist/pattern/pattern-definition.js +0 -2
- package/dist/pattern/pattern-definition.js.map +0 -1
- package/dist/pattern/pattern-matcher.d.ts +0 -55
- package/dist/pattern/pattern-matcher.d.ts.map +0 -1
- package/dist/pattern/pattern-matcher.js +0 -216
- package/dist/pattern/pattern-matcher.js.map +0 -1
- package/dist/provider/llm-provider.d.ts +0 -146
- package/dist/provider/llm-provider.d.ts.map +0 -1
- package/dist/provider/llm-provider.js +0 -2
- package/dist/provider/llm-provider.js.map +0 -1
- package/dist/provider/provider-registry.d.ts +0 -28
- package/dist/provider/provider-registry.d.ts.map +0 -1
- package/dist/provider/provider-registry.js +0 -65
- package/dist/provider/provider-registry.js.map +0 -1
- package/dist/strategy/strategy-router.d.ts +0 -79
- package/dist/strategy/strategy-router.d.ts.map +0 -1
- package/dist/strategy/strategy-router.js +0 -182
- package/dist/strategy/strategy-router.js.map +0 -1
- package/dist/template/intent-classifier.d.ts +0 -56
- package/dist/template/intent-classifier.d.ts.map +0 -1
- package/dist/template/intent-classifier.js +0 -251
- package/dist/template/intent-classifier.js.map +0 -1
- package/dist/template/nl-intent.d.ts +0 -38
- package/dist/template/nl-intent.d.ts.map +0 -1
- package/dist/template/nl-intent.js +0 -39
- package/dist/template/nl-intent.js.map +0 -1
- package/dist/template/prompts/prompt-builder.d.ts +0 -20
- package/dist/template/prompts/prompt-builder.d.ts.map +0 -1
- package/dist/template/prompts/prompt-builder.js +0 -243
- package/dist/template/prompts/prompt-builder.js.map +0 -1
- package/dist/template/template-engine.d.ts +0 -27
- package/dist/template/template-engine.d.ts.map +0 -1
- package/dist/template/template-engine.js +0 -378
- package/dist/template/template-engine.js.map +0 -1
- package/dist/utils/chinese-number-parser.d.ts +0 -30
- package/dist/utils/chinese-number-parser.d.ts.map +0 -1
- package/dist/utils/chinese-number-parser.js +0 -92
- package/dist/utils/chinese-number-parser.js.map +0 -1
- package/dist/validation/auto-fixer.d.ts +0 -13
- package/dist/validation/auto-fixer.d.ts.map +0 -1
- package/dist/validation/auto-fixer.js +0 -110
- package/dist/validation/auto-fixer.js.map +0 -1
- package/dist/validation/self-correction-loop.d.ts +0 -46
- package/dist/validation/self-correction-loop.d.ts.map +0 -1
- package/dist/validation/self-correction-loop.js +0 -132
- package/dist/validation/self-correction-loop.js.map +0 -1
- package/dist/validation/validation-pipeline.d.ts +0 -81
- package/dist/validation/validation-pipeline.d.ts.map +0 -1
- package/dist/validation/validation-pipeline.js +0 -306
- package/dist/validation/validation-pipeline.js.map +0 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,908 @@
|
|
|
1
|
+
import { ContextSchema, SpelEvaluator } from '@agentix-e/spel-ts';
|
|
2
|
+
export { BeanSchema, ContextSchema, FieldSchema, FunctionSchema, MethodSchema, ParseError, ParseResult, RootObjectSchema, SpelEvaluator, TypeSchema, VariableSchema } from '@agentix-e/spel-ts';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* LLMProvider interface — NL2Spel's pluggable LLM contract.
|
|
6
|
+
*
|
|
7
|
+
* Design principles:
|
|
8
|
+
* 1. Minimal interface: only exposes generate + generateStream + lifecycle
|
|
9
|
+
* 2. Capability declaration: capabilities let StrategyRouter make routing decisions
|
|
10
|
+
* 3. Async lifecycle: supports Providers that need init/dispose (e.g. WebLLM)
|
|
11
|
+
* 4. Stream support: optional generateStream for progressive generation
|
|
12
|
+
*/
|
|
13
|
+
interface LLMProvider {
|
|
14
|
+
/** Provider unique name, used for logging/debugging/Provider selection */
|
|
15
|
+
readonly name: string;
|
|
16
|
+
/** Provider capability declaration */
|
|
17
|
+
readonly capabilities: LLMCapabilities;
|
|
18
|
+
/**
|
|
19
|
+
* Generate a SpEL expression (core method)
|
|
20
|
+
*/
|
|
21
|
+
generate(prompt: LLMPrompt, options?: LLMGenerateOptions): Promise<LLMResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Stream generate a SpEL expression (optional implementation)
|
|
24
|
+
*/
|
|
25
|
+
generateStream?(prompt: LLMPrompt, options?: LLMGenerateOptions): AsyncIterable<LLMStreamChunk>;
|
|
26
|
+
/**
|
|
27
|
+
* Check if the Provider is currently available
|
|
28
|
+
*/
|
|
29
|
+
isAvailable(): Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* Initialize the Provider (optional)
|
|
32
|
+
*/
|
|
33
|
+
initialize?(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Release Provider resources (optional)
|
|
36
|
+
*/
|
|
37
|
+
dispose?(): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* LLMProvider capability declaration.
|
|
41
|
+
*/
|
|
42
|
+
interface LLMCapabilities {
|
|
43
|
+
/** Maximum context window (tokens) */
|
|
44
|
+
maxContextTokens: number;
|
|
45
|
+
/** Whether Grammar Constraint (GBNF, etc.) is supported */
|
|
46
|
+
supportsGrammarConstraint: boolean;
|
|
47
|
+
/** Whether streaming output is supported */
|
|
48
|
+
supportsStreaming: boolean;
|
|
49
|
+
/** Whether Structured Output (JSON mode) is supported */
|
|
50
|
+
supportsStructuredOutput: boolean;
|
|
51
|
+
/** Whether available offline */
|
|
52
|
+
offlineAvailable: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Estimated cost per request (USD)
|
|
55
|
+
*/
|
|
56
|
+
estimatedCostPerRequest?: number;
|
|
57
|
+
/** Estimated latency (ms) */
|
|
58
|
+
estimatedLatencyMs: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Standardized LLM Prompt structure.
|
|
62
|
+
*/
|
|
63
|
+
interface LLMPrompt {
|
|
64
|
+
/** System prompt */
|
|
65
|
+
system: string;
|
|
66
|
+
/** User input */
|
|
67
|
+
user: string;
|
|
68
|
+
/** Context Schema */
|
|
69
|
+
contextSchema: ContextSchema;
|
|
70
|
+
/** Few-Shot example list */
|
|
71
|
+
examples: FewShotExample[];
|
|
72
|
+
/** Grammar constraint string (GBNF format) */
|
|
73
|
+
grammar?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Few-Shot example
|
|
77
|
+
*/
|
|
78
|
+
interface FewShotExample {
|
|
79
|
+
/** Natural language input */
|
|
80
|
+
nl: string;
|
|
81
|
+
/** Expected SpEL expression */
|
|
82
|
+
spel: string;
|
|
83
|
+
/** Difficulty level */
|
|
84
|
+
difficulty: 'easy' | 'medium' | 'hard';
|
|
85
|
+
/** Category */
|
|
86
|
+
category: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* LLM generation options
|
|
90
|
+
*/
|
|
91
|
+
interface LLMGenerateOptions {
|
|
92
|
+
/** Temperature (0-2), default 0.1 */
|
|
93
|
+
temperature?: number;
|
|
94
|
+
/** Maximum output tokens */
|
|
95
|
+
maxTokens?: number;
|
|
96
|
+
/** Top-p sampling */
|
|
97
|
+
topP?: number;
|
|
98
|
+
/** Stop sequences */
|
|
99
|
+
stopSequences?: string[];
|
|
100
|
+
/** Whether to enable stream */
|
|
101
|
+
stream?: boolean;
|
|
102
|
+
/** Custom model override */
|
|
103
|
+
model?: string;
|
|
104
|
+
/** Timeout (ms), default 30000 */
|
|
105
|
+
timeout?: number;
|
|
106
|
+
/** Maximum retry count */
|
|
107
|
+
maxRetries?: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* LLM generation response
|
|
111
|
+
*/
|
|
112
|
+
interface LLMResponse {
|
|
113
|
+
/** Raw generated text */
|
|
114
|
+
text: string;
|
|
115
|
+
/** Actual model used */
|
|
116
|
+
model: string;
|
|
117
|
+
/** Token usage statistics */
|
|
118
|
+
usage: LLMUsage;
|
|
119
|
+
/** Generation latency (ms) */
|
|
120
|
+
latencyMs: number;
|
|
121
|
+
/** Finish reason */
|
|
122
|
+
finishReason: 'stop' | 'length' | 'content_filter' | 'error';
|
|
123
|
+
/** Provider name */
|
|
124
|
+
providerName: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* LLM Stream Chunk
|
|
128
|
+
*/
|
|
129
|
+
interface LLMStreamChunk {
|
|
130
|
+
/** Delta text */
|
|
131
|
+
delta: string;
|
|
132
|
+
/** Accumulated text */
|
|
133
|
+
accumulated: string;
|
|
134
|
+
/** Whether done */
|
|
135
|
+
done: boolean;
|
|
136
|
+
/** Finish reason */
|
|
137
|
+
finishReason?: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Token usage statistics
|
|
141
|
+
*/
|
|
142
|
+
interface LLMUsage {
|
|
143
|
+
promptTokens: number;
|
|
144
|
+
completionTokens: number;
|
|
145
|
+
totalTokens: number;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* ProviderRegistry — manages registered LLMProvider instances.
|
|
150
|
+
*
|
|
151
|
+
* Responsibilities:
|
|
152
|
+
* 1. Register/unregister Providers
|
|
153
|
+
* 2. Sort by priority (offline first > low latency > high accuracy)
|
|
154
|
+
* 3. Look up Providers by name (for forced selection)
|
|
155
|
+
*/
|
|
156
|
+
declare class ProviderRegistry {
|
|
157
|
+
private _providers;
|
|
158
|
+
/** Register a Provider */
|
|
159
|
+
register(provider: LLMProvider): void;
|
|
160
|
+
/** Unregister a Provider */
|
|
161
|
+
unregister(name: string): void;
|
|
162
|
+
/** Get a Provider by name */
|
|
163
|
+
get(name: string): LLMProvider | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Get available Providers sorted by priority.
|
|
166
|
+
* Sort rule: offline > low cost > low latency > high accuracy
|
|
167
|
+
*/
|
|
168
|
+
getPrioritized(): Promise<LLMProvider[]>;
|
|
169
|
+
/** List all registered Providers */
|
|
170
|
+
list(): LLMProvider[];
|
|
171
|
+
/** Number of registered Providers */
|
|
172
|
+
get count(): number;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* ContextExtractor — builds a ContextSchema from plain data structures.
|
|
177
|
+
*
|
|
178
|
+
* Decoupled from any concrete SpEL implementation, accepts only:
|
|
179
|
+
* - rootObject: any object (for extracting property types)
|
|
180
|
+
* - variables: Record<string, { type: string; value?: unknown }>
|
|
181
|
+
* - beans: string[]
|
|
182
|
+
* - types: string[]
|
|
183
|
+
*/
|
|
184
|
+
declare class ContextExtractor {
|
|
185
|
+
/**
|
|
186
|
+
* Extract ContextSchema from plain data structures (no spel-ts dependency)
|
|
187
|
+
*/
|
|
188
|
+
extract(context: {
|
|
189
|
+
rootObject?: unknown;
|
|
190
|
+
rootName?: string;
|
|
191
|
+
variables?: Record<string, {
|
|
192
|
+
type: string;
|
|
193
|
+
value?: unknown;
|
|
194
|
+
description?: string;
|
|
195
|
+
nullable?: boolean;
|
|
196
|
+
}>;
|
|
197
|
+
beans?: Array<{
|
|
198
|
+
name: string;
|
|
199
|
+
type: string;
|
|
200
|
+
description?: string;
|
|
201
|
+
singleton?: boolean;
|
|
202
|
+
}>;
|
|
203
|
+
types?: Array<{
|
|
204
|
+
name: string;
|
|
205
|
+
className?: string;
|
|
206
|
+
description?: string;
|
|
207
|
+
}>;
|
|
208
|
+
functions?: Array<{
|
|
209
|
+
name: string;
|
|
210
|
+
returnType: string;
|
|
211
|
+
params: Array<{
|
|
212
|
+
name: string;
|
|
213
|
+
type: string;
|
|
214
|
+
}>;
|
|
215
|
+
description?: string;
|
|
216
|
+
}>;
|
|
217
|
+
}): ContextSchema;
|
|
218
|
+
/**
|
|
219
|
+
* Extract root object schema
|
|
220
|
+
*/
|
|
221
|
+
private extractRoot;
|
|
222
|
+
/**
|
|
223
|
+
* Extract object fields
|
|
224
|
+
*/
|
|
225
|
+
/**
|
|
226
|
+
* Recursively extract fields from an object, following nested objects
|
|
227
|
+
* all the way to leaf values. Uses a visited set to prevent circular references.
|
|
228
|
+
*/
|
|
229
|
+
private extractFields;
|
|
230
|
+
/**
|
|
231
|
+
* Infer SpEL type
|
|
232
|
+
*/
|
|
233
|
+
private inferSpelType;
|
|
234
|
+
/**
|
|
235
|
+
* Generate field description
|
|
236
|
+
*/
|
|
237
|
+
private generateDescription;
|
|
238
|
+
/**
|
|
239
|
+
* Safely get example value
|
|
240
|
+
*/
|
|
241
|
+
private safeExample;
|
|
242
|
+
/**
|
|
243
|
+
* Extract variables
|
|
244
|
+
*/
|
|
245
|
+
private extractVariables;
|
|
246
|
+
/**
|
|
247
|
+
* Extract beans
|
|
248
|
+
*/
|
|
249
|
+
private extractBeans;
|
|
250
|
+
/**
|
|
251
|
+
* Extract types
|
|
252
|
+
*/
|
|
253
|
+
private extractTypes;
|
|
254
|
+
/**
|
|
255
|
+
* Extract functions
|
|
256
|
+
*/
|
|
257
|
+
private extractFunctions;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* SchemaFormatter — formats ContextSchema into readable text.
|
|
262
|
+
*
|
|
263
|
+
* Two formats:
|
|
264
|
+
* 1. formatForLLM(): optimized for LLM prompts (compact, key info first)
|
|
265
|
+
* 2. formatForHuman(): human-readable format (complete, indent-friendly)
|
|
266
|
+
*/
|
|
267
|
+
declare class SchemaFormatter {
|
|
268
|
+
/**
|
|
269
|
+
* LLM-optimized format — compact, injected into the User part of the prompt
|
|
270
|
+
*/
|
|
271
|
+
formatForLLM(schema: ContextSchema): string;
|
|
272
|
+
/**
|
|
273
|
+
* Human-readable format
|
|
274
|
+
*/
|
|
275
|
+
formatForHuman(schema: ContextSchema): string;
|
|
276
|
+
private formatFieldForLLM;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Pattern definition — core data structures for Layer 0.
|
|
281
|
+
*
|
|
282
|
+
* Each PatternDefinition describes a mapping from natural language pattern to SpEL expression.
|
|
283
|
+
* Supports both Chinese and English languages.
|
|
284
|
+
*/
|
|
285
|
+
interface PatternDefinition {
|
|
286
|
+
/** Unique identifier */
|
|
287
|
+
id: string;
|
|
288
|
+
/**
|
|
289
|
+
* Match regex (at least one language)
|
|
290
|
+
* Uses named capture groups (?<slotName>...) to extract slots
|
|
291
|
+
*/
|
|
292
|
+
match: RegExp;
|
|
293
|
+
/**
|
|
294
|
+
* SpEL template string
|
|
295
|
+
* Uses {slotName} placeholders to reference capture groups
|
|
296
|
+
*/
|
|
297
|
+
spelTemplate: string;
|
|
298
|
+
/**
|
|
299
|
+
* Slot definitions (capture groups mapped to SpEL types)
|
|
300
|
+
*/
|
|
301
|
+
slots: Record<string, SlotDefinition>;
|
|
302
|
+
/** Priority (0-100), higher priority matched first */
|
|
303
|
+
priority: number;
|
|
304
|
+
/** Tags (for classification and debugging) */
|
|
305
|
+
tags: string[];
|
|
306
|
+
/** Example input/output pairs */
|
|
307
|
+
examples: Array<{
|
|
308
|
+
nl: string;
|
|
309
|
+
spel: string;
|
|
310
|
+
}>;
|
|
311
|
+
/** Difficulty level */
|
|
312
|
+
difficulty: 'easy' | 'medium';
|
|
313
|
+
/** Confidence (0-1) */
|
|
314
|
+
confidence: number;
|
|
315
|
+
}
|
|
316
|
+
interface SlotDefinition {
|
|
317
|
+
/** Key appearing in spelTemplate */
|
|
318
|
+
key: string;
|
|
319
|
+
/** SpEL value type: 'number' | 'string' | 'boolean' | 'variable' | 'literal' */
|
|
320
|
+
type: 'number' | 'string' | 'boolean' | 'variable' | 'literal';
|
|
321
|
+
/** Optional: value transformer (e.g. Chinese numbers → number) */
|
|
322
|
+
transform?: SlotTransform;
|
|
323
|
+
/** Optional: default value */
|
|
324
|
+
defaultValue?: string;
|
|
325
|
+
}
|
|
326
|
+
type SlotTransform = 'toNumber' | 'toBoolean' | 'toString' | 'trim' | 'lowercase' | 'normalize';
|
|
327
|
+
|
|
328
|
+
interface PatternMatchResult {
|
|
329
|
+
/** Whether matched */
|
|
330
|
+
matched: boolean;
|
|
331
|
+
/** The matching PatternDefinition */
|
|
332
|
+
pattern?: PatternDefinition;
|
|
333
|
+
/** Generated SpEL expression (if matched) */
|
|
334
|
+
spel?: string;
|
|
335
|
+
/** Confidence (0-1) */
|
|
336
|
+
confidence: number;
|
|
337
|
+
/** Match latency (ms) */
|
|
338
|
+
latencyMs: number;
|
|
339
|
+
/** Extracted slot values */
|
|
340
|
+
slots?: Record<string, string>;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* PatternMatcher — Layer 0 pattern matching core.
|
|
344
|
+
*/
|
|
345
|
+
declare class PatternMatcher {
|
|
346
|
+
private _patterns;
|
|
347
|
+
constructor(patterns?: PatternDefinition[]);
|
|
348
|
+
get patternCount(): number;
|
|
349
|
+
register(pattern: PatternDefinition): void;
|
|
350
|
+
registerAll(patterns: PatternDefinition[]): void;
|
|
351
|
+
private sortByPriority;
|
|
352
|
+
/**
|
|
353
|
+
* Match natural language input, return the best match
|
|
354
|
+
*/
|
|
355
|
+
match(nl: string): PatternMatchResult;
|
|
356
|
+
/**
|
|
357
|
+
* Batch match
|
|
358
|
+
*/
|
|
359
|
+
matchAll(nl: string, maxResults?: number): PatternMatchResult[];
|
|
360
|
+
/**
|
|
361
|
+
* Input normalization
|
|
362
|
+
*/
|
|
363
|
+
private normalize;
|
|
364
|
+
/**
|
|
365
|
+
* Infer SpEL root object name from Chinese input
|
|
366
|
+
*/
|
|
367
|
+
private inferRoot;
|
|
368
|
+
/**
|
|
369
|
+
* Extract Chinese field names from input and map to SpEL fields
|
|
370
|
+
*/
|
|
371
|
+
private extractChineseField;
|
|
372
|
+
/**
|
|
373
|
+
* Template filling and value transformation
|
|
374
|
+
*/
|
|
375
|
+
private fillTemplate;
|
|
376
|
+
/**
|
|
377
|
+
* Infer SpEL field name from capture group
|
|
378
|
+
*/
|
|
379
|
+
private inferFieldFromCapture;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Built-in pattern library — covers ≥80% Easy scenarios, 63 PatternDefinitions.
|
|
384
|
+
*
|
|
385
|
+
* Core design:
|
|
386
|
+
* 1. All patterns use named capture groups `(?<field>…)` or `(?<value>…)` to extract parameters
|
|
387
|
+
* 2. Separate Chinese/English patterns (don't mix keywords, avoids cross-language false matches)
|
|
388
|
+
* 3. High-specificity patterns have higher priority ("not empty" > "not")
|
|
389
|
+
* 4. Sorted by priority descending
|
|
390
|
+
*/
|
|
391
|
+
declare const BUILTIN_PATTERNS: PatternDefinition[];
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* NLIntent — Natural language intent classification system.
|
|
395
|
+
*
|
|
396
|
+
* 15 intent types covering all common SpEL usage scenarios.
|
|
397
|
+
*/
|
|
398
|
+
declare enum NLIntent {
|
|
399
|
+
/** Numeric comparison: "amount > 100", "年龄大于18" */
|
|
400
|
+
COMPARISON = "COMPARISON",
|
|
401
|
+
/** Permission check: "hasRole('admin')", "用户是VIP" */
|
|
402
|
+
PERMISSION_CHECK = "PERMISSION_CHECK",
|
|
403
|
+
/** Null check: "== null", "!= null", "不为空" */
|
|
404
|
+
NULL_CHECK = "NULL_CHECK",
|
|
405
|
+
/** Logical combination: "a and b", "金额大于100且已确认" */
|
|
406
|
+
LOGICAL = "LOGICAL",
|
|
407
|
+
/** String matching: "contains('keyword')", "以ORD开头" */
|
|
408
|
+
STRING_MATCH = "STRING_MATCH",
|
|
409
|
+
/** Collection operations: "list.contains('x')", "items.isEmpty()" */
|
|
410
|
+
COLLECTION = "COLLECTION",
|
|
411
|
+
/** Range check: "between {1, 10}", "年龄在18到60之间" */
|
|
412
|
+
RANGE = "RANGE",
|
|
413
|
+
/** Selection (filter): ".?[condition]", "all matching conditions" */
|
|
414
|
+
SELECTION = "SELECTION",
|
|
415
|
+
/** Projection: ".![field]", "each item's name" */
|
|
416
|
+
PROJECTION = "PROJECTION",
|
|
417
|
+
/** Type check: "instanceof", "是否是Admin类型" */
|
|
418
|
+
TYPE_CHECK = "TYPE_CHECK",
|
|
419
|
+
/** Boolean property: "isVIP", "是否已支付" */
|
|
420
|
+
BOOLEAN = "BOOLEAN",
|
|
421
|
+
/** Date comparison: "after/before", "after a certain date" */
|
|
422
|
+
DATE = "DATE",
|
|
423
|
+
/** Elvis default: "a ?: default", "or default value" */
|
|
424
|
+
ELVIS = "ELVIS",
|
|
425
|
+
/** Assignment: "a = value", "set field to" */
|
|
426
|
+
ASSIGNMENT = "ASSIGNMENT",
|
|
427
|
+
/** Arithmetic: "amount * price", "total = unit price × quantity" */
|
|
428
|
+
ARITHMETIC = "ARITHMETIC"
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Intent classification result
|
|
433
|
+
*/
|
|
434
|
+
interface IntentResult {
|
|
435
|
+
/** Primary intent (highest confidence) */
|
|
436
|
+
primaryIntent: NLIntent;
|
|
437
|
+
/** All possible intents with confidence scores */
|
|
438
|
+
intents: Array<{
|
|
439
|
+
intent: NLIntent;
|
|
440
|
+
confidence: number;
|
|
441
|
+
}>;
|
|
442
|
+
/** Extracted entities */
|
|
443
|
+
entities: IntentEntity[];
|
|
444
|
+
/** Recognized operators */
|
|
445
|
+
operators: string[];
|
|
446
|
+
/** Recognized logical connectors */
|
|
447
|
+
logicalConnectors: string[];
|
|
448
|
+
/** Complexity score (0-100) */
|
|
449
|
+
complexity: number;
|
|
450
|
+
}
|
|
451
|
+
interface IntentEntity {
|
|
452
|
+
text: string;
|
|
453
|
+
type: 'field' | 'value' | 'operator' | 'logic' | 'quantifier';
|
|
454
|
+
position: {
|
|
455
|
+
start: number;
|
|
456
|
+
end: number;
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
declare class IntentClassifier {
|
|
460
|
+
/**
|
|
461
|
+
* Main method for classifying natural language input
|
|
462
|
+
*/
|
|
463
|
+
classify(input: string): IntentResult;
|
|
464
|
+
/**
|
|
465
|
+
* Entity extraction
|
|
466
|
+
*/
|
|
467
|
+
private extractEntities;
|
|
468
|
+
/**
|
|
469
|
+
* Operator recognition
|
|
470
|
+
*/
|
|
471
|
+
private extractOperators;
|
|
472
|
+
/**
|
|
473
|
+
* Logical connector recognition
|
|
474
|
+
*/
|
|
475
|
+
private extractLogicalConnectors;
|
|
476
|
+
/**
|
|
477
|
+
* Complexity calculation
|
|
478
|
+
*/
|
|
479
|
+
private calculateComplexity;
|
|
480
|
+
/**
|
|
481
|
+
* Input normalization
|
|
482
|
+
*/
|
|
483
|
+
private normalize;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
interface TemplateResult {
|
|
487
|
+
/** Generated SpEL expression */
|
|
488
|
+
expression: string;
|
|
489
|
+
/** Intent used */
|
|
490
|
+
intent: NLIntent;
|
|
491
|
+
/** Template name used */
|
|
492
|
+
templateName: string;
|
|
493
|
+
/** Confidence */
|
|
494
|
+
confidence: number;
|
|
495
|
+
/** Unfilled slots needing further LLM processing */
|
|
496
|
+
unfilledSlots: string[];
|
|
497
|
+
}
|
|
498
|
+
declare class TemplateEngine {
|
|
499
|
+
private contextSchema?;
|
|
500
|
+
constructor(contextSchema?: ContextSchema);
|
|
501
|
+
setContext(schema: ContextSchema): void;
|
|
502
|
+
/**
|
|
503
|
+
* Generate a SpEL expression based on intent classification results
|
|
504
|
+
*/
|
|
505
|
+
generate(input: string, intentResult: IntentResult): TemplateResult | null;
|
|
506
|
+
private selectBestTemplate;
|
|
507
|
+
private fillTemplate;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
interface PromptBuilderOptions {
|
|
511
|
+
/** Language (zh/en) */
|
|
512
|
+
language?: 'zh' | 'en';
|
|
513
|
+
/** Whether to include EBNF grammar block */
|
|
514
|
+
includeEBNF?: boolean;
|
|
515
|
+
}
|
|
516
|
+
declare class PromptBuilder {
|
|
517
|
+
private readonly formatter;
|
|
518
|
+
/**
|
|
519
|
+
* Build a complete LLM Prompt
|
|
520
|
+
*/
|
|
521
|
+
build(userInput: string, contextSchema?: ContextSchema, options?: PromptBuilderOptions): LLMPrompt;
|
|
522
|
+
/**
|
|
523
|
+
* Build Few-Shot example string
|
|
524
|
+
*/
|
|
525
|
+
private buildExamples;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
interface ValidationResult {
|
|
529
|
+
/** Whether all validation stages passed */
|
|
530
|
+
valid: boolean;
|
|
531
|
+
/** Stage results */
|
|
532
|
+
stages: {
|
|
533
|
+
parse: StageResult;
|
|
534
|
+
type: StageResult;
|
|
535
|
+
semantic: StageResult;
|
|
536
|
+
context: StageResult;
|
|
537
|
+
};
|
|
538
|
+
/** All errors */
|
|
539
|
+
errors: ValidationError[];
|
|
540
|
+
/** All warnings */
|
|
541
|
+
warnings: ValidationWarning[];
|
|
542
|
+
}
|
|
543
|
+
interface StageResult {
|
|
544
|
+
passed: boolean;
|
|
545
|
+
errors: ValidationError[];
|
|
546
|
+
warnings: ValidationWarning[];
|
|
547
|
+
}
|
|
548
|
+
interface ValidationError {
|
|
549
|
+
code: string;
|
|
550
|
+
message: string;
|
|
551
|
+
/** Error position in expression */
|
|
552
|
+
position?: number;
|
|
553
|
+
/** Stage the error belongs to */
|
|
554
|
+
stage: 'parse' | 'type' | 'semantic' | 'context';
|
|
555
|
+
/** Whether LLM regeneration is needed */
|
|
556
|
+
requiresLLM?: boolean;
|
|
557
|
+
}
|
|
558
|
+
interface ValidationWarning {
|
|
559
|
+
code: string;
|
|
560
|
+
message: string;
|
|
561
|
+
/** Warning position in expression */
|
|
562
|
+
position?: number;
|
|
563
|
+
/** Stage the warning belongs to */
|
|
564
|
+
stage: 'parse' | 'type' | 'semantic' | 'context';
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* ValidationPipeline — four-stage validation pipeline.
|
|
568
|
+
*
|
|
569
|
+
* 1. Parse: syntax validity (depends on SpelEvaluator)
|
|
570
|
+
* 2. Type: type checking (operator-operand type matching)
|
|
571
|
+
* 3. Semantic: semantic reasonableness (is the expression meaningful)
|
|
572
|
+
* 4. Context: context references (do all references exist in ContextSchema)
|
|
573
|
+
*/
|
|
574
|
+
declare class ValidationPipeline {
|
|
575
|
+
private evaluator;
|
|
576
|
+
constructor(evaluator?: SpelEvaluator | null);
|
|
577
|
+
setEvaluator(evaluator: SpelEvaluator): void;
|
|
578
|
+
/**
|
|
579
|
+
* Run the full validation pipeline
|
|
580
|
+
*/
|
|
581
|
+
validate(expression: string, contextSchema?: ContextSchema): Promise<ValidationResult>;
|
|
582
|
+
/**
|
|
583
|
+
* Stage 1: Parse Check — syntax validation
|
|
584
|
+
*/
|
|
585
|
+
private validateParse;
|
|
586
|
+
/**
|
|
587
|
+
* Stage 2: Type Check — type validation
|
|
588
|
+
*/
|
|
589
|
+
private validateTypes;
|
|
590
|
+
/**
|
|
591
|
+
* Stage 3: Semantic Check — semantic reasonableness validation
|
|
592
|
+
*/
|
|
593
|
+
private validateSemantic;
|
|
594
|
+
/**
|
|
595
|
+
* Stage 4: Context Check — context reference validation
|
|
596
|
+
*/
|
|
597
|
+
private validateContext;
|
|
598
|
+
/**
|
|
599
|
+
* Check if parentheses are balanced
|
|
600
|
+
*/
|
|
601
|
+
private hasBalancedParentheses;
|
|
602
|
+
/**
|
|
603
|
+
* Extract all identifier references from expression
|
|
604
|
+
*/
|
|
605
|
+
private extractReferences;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* AutoFixer — automatically fixes common SpEL syntax errors from LLM output.
|
|
610
|
+
*/
|
|
611
|
+
declare class AutoFixer {
|
|
612
|
+
fix(expression: string): AutoFixResult;
|
|
613
|
+
private fixAllBrackets;
|
|
614
|
+
}
|
|
615
|
+
interface AutoFixResult {
|
|
616
|
+
expression: string;
|
|
617
|
+
wasFixed: boolean;
|
|
618
|
+
changes: string[];
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
interface SelfCorrectionResult {
|
|
622
|
+
/** Final expression */
|
|
623
|
+
expression: string;
|
|
624
|
+
/** Whether validation passed */
|
|
625
|
+
valid: boolean;
|
|
626
|
+
/** Original LLM output */
|
|
627
|
+
originalOutput: string;
|
|
628
|
+
/** Number of correction attempts */
|
|
629
|
+
correctionAttempts: number;
|
|
630
|
+
/** Log of each correction round */
|
|
631
|
+
corrections: CorrectionLog[];
|
|
632
|
+
/** Total latency (ms) */
|
|
633
|
+
totalLatencyMs: number;
|
|
634
|
+
}
|
|
635
|
+
interface CorrectionLog {
|
|
636
|
+
attempt: number;
|
|
637
|
+
expression: string;
|
|
638
|
+
valid: boolean;
|
|
639
|
+
errorCount: number;
|
|
640
|
+
warningCount: number;
|
|
641
|
+
autoFixed: boolean;
|
|
642
|
+
autoFixChanges: string[];
|
|
643
|
+
}
|
|
644
|
+
interface SelfCorrectionConfig {
|
|
645
|
+
/** Maximum correction attempts (default 3) */
|
|
646
|
+
maxAttempts?: number;
|
|
647
|
+
/** Minimum confidence threshold (default 0.7) */
|
|
648
|
+
minConfidence?: number;
|
|
649
|
+
/** Whether AutoFix is enabled (default true) */
|
|
650
|
+
enableAutoFix?: boolean;
|
|
651
|
+
}
|
|
652
|
+
declare class SelfCorrectionLoop {
|
|
653
|
+
private readonly pipeline;
|
|
654
|
+
private readonly autoFixer;
|
|
655
|
+
private readonly config;
|
|
656
|
+
constructor(config?: SelfCorrectionConfig, pipeline?: ValidationPipeline, autoFixer?: AutoFixer);
|
|
657
|
+
/**
|
|
658
|
+
* Execute the self-correction loop
|
|
659
|
+
*/
|
|
660
|
+
correct(expression: string, contextSchema: ContextSchema, generateFn: (prompt: LLMPrompt) => Promise<LLMResponse>, originalPrompt: LLMPrompt): Promise<SelfCorrectionResult>;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
type StrategyType = 'pattern' | 'template' | 'llm-api' | 'llm-fallback' | 'none';
|
|
664
|
+
interface StrategyResult {
|
|
665
|
+
/** Generated SpEL expression */
|
|
666
|
+
expression: string;
|
|
667
|
+
/** Strategy used */
|
|
668
|
+
strategy: StrategyType;
|
|
669
|
+
/** Confidence (0-1) */
|
|
670
|
+
confidence: number;
|
|
671
|
+
/** Strategy-related metadata */
|
|
672
|
+
metadata: StrategyMetadata;
|
|
673
|
+
/** Generation latency (ms) */
|
|
674
|
+
latencyMs: number;
|
|
675
|
+
}
|
|
676
|
+
interface StrategyMetadata {
|
|
677
|
+
/** Matched pattern ID (pattern strategy only) */
|
|
678
|
+
patternId?: string;
|
|
679
|
+
/** Intent type (template strategy only) */
|
|
680
|
+
intent?: string;
|
|
681
|
+
/** Template name (template strategy only) */
|
|
682
|
+
templateName?: string;
|
|
683
|
+
/** LLM Provider name (llm strategy only) */
|
|
684
|
+
providerName?: string;
|
|
685
|
+
/** LLM model (llm strategy only) */
|
|
686
|
+
model?: string;
|
|
687
|
+
/** Correction count (llm strategy + self-correction only) */
|
|
688
|
+
corrections?: number;
|
|
689
|
+
/** Raw LLM output (llm strategy only) */
|
|
690
|
+
rawOutput?: string;
|
|
691
|
+
}
|
|
692
|
+
interface StrategyRouterConfig {
|
|
693
|
+
/** Pattern confidence threshold (default 0.7) */
|
|
694
|
+
patternMinConfidence?: number;
|
|
695
|
+
/** Template confidence threshold (default 0.6) */
|
|
696
|
+
templateMinConfidence?: number;
|
|
697
|
+
/** LLM confidence threshold (default 0.5) */
|
|
698
|
+
llmMinConfidence?: number;
|
|
699
|
+
/** Whether Self-Correction is enabled (default true) */
|
|
700
|
+
enableSelfCorrection?: boolean;
|
|
701
|
+
/** Maximum Self-Correction attempts (default 3) */
|
|
702
|
+
maxCorrectionAttempts?: number;
|
|
703
|
+
}
|
|
704
|
+
declare class StrategyRouter {
|
|
705
|
+
private readonly patternMatcher;
|
|
706
|
+
private readonly intentClassifier;
|
|
707
|
+
private readonly templateEngine;
|
|
708
|
+
private readonly promptBuilder;
|
|
709
|
+
private readonly validationPipeline;
|
|
710
|
+
private readonly autoFixer;
|
|
711
|
+
private readonly providerRegistry;
|
|
712
|
+
private readonly config;
|
|
713
|
+
constructor(providerRegistry: ProviderRegistry, config?: StrategyRouterConfig);
|
|
714
|
+
/**
|
|
715
|
+
* Execute the full generation strategy routing
|
|
716
|
+
*/
|
|
717
|
+
generate(nl: string, contextSchema?: ContextSchema, forceLLMProvider?: string): Promise<StrategyResult>;
|
|
718
|
+
/**
|
|
719
|
+
* Get PatternMatcher (for external testing/debugging)
|
|
720
|
+
*/
|
|
721
|
+
getPatternMatcher(): PatternMatcher;
|
|
722
|
+
/**
|
|
723
|
+
* Get TemplateEngine
|
|
724
|
+
*/
|
|
725
|
+
getTemplateEngine(): TemplateEngine;
|
|
726
|
+
/**
|
|
727
|
+
* Get PromptBuilder
|
|
728
|
+
*/
|
|
729
|
+
getPromptBuilder(): PromptBuilder;
|
|
730
|
+
/**
|
|
731
|
+
* Set SpelEvaluator for validation pipeline.
|
|
732
|
+
* Must be called before generate() if parse-level validation is needed.
|
|
733
|
+
*/
|
|
734
|
+
setEvaluator(evaluator: SpelEvaluator): void;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
interface GenerateOptions {
|
|
738
|
+
/** Context Schema (optional) */
|
|
739
|
+
contextSchema?: ContextSchema;
|
|
740
|
+
/** Raw context object (auto-extracted to ContextSchema) */
|
|
741
|
+
context?: {
|
|
742
|
+
rootObject?: unknown;
|
|
743
|
+
rootName?: string;
|
|
744
|
+
variables?: Record<string, {
|
|
745
|
+
type: string;
|
|
746
|
+
value?: unknown;
|
|
747
|
+
description?: string;
|
|
748
|
+
nullable?: boolean;
|
|
749
|
+
}>;
|
|
750
|
+
beans?: Array<{
|
|
751
|
+
name: string;
|
|
752
|
+
type: string;
|
|
753
|
+
description?: string;
|
|
754
|
+
}>;
|
|
755
|
+
types?: Array<{
|
|
756
|
+
name: string;
|
|
757
|
+
className?: string;
|
|
758
|
+
description?: string;
|
|
759
|
+
}>;
|
|
760
|
+
};
|
|
761
|
+
/** Force using a specific LLM Provider */
|
|
762
|
+
preferredProvider?: string;
|
|
763
|
+
/** Minimum confidence threshold (default 0.5) */
|
|
764
|
+
minConfidence?: number;
|
|
765
|
+
/** Offline only (Pattern + Template, no LLM calls) */
|
|
766
|
+
offlineOnly?: boolean;
|
|
767
|
+
/** Whether validation is enabled (default true) */
|
|
768
|
+
enableValidation?: boolean;
|
|
769
|
+
/** Whether self-correction is enabled (default true) */
|
|
770
|
+
enableSelfCorrection?: boolean;
|
|
771
|
+
/** Language (default auto-detect) */
|
|
772
|
+
language?: 'zh' | 'en';
|
|
773
|
+
/** Whether to return debug information */
|
|
774
|
+
debug?: boolean;
|
|
775
|
+
}
|
|
776
|
+
interface GenerateResult {
|
|
777
|
+
/** Generated SpEL expression */
|
|
778
|
+
expression: string;
|
|
779
|
+
/** Strategy used */
|
|
780
|
+
strategy: string;
|
|
781
|
+
/** Confidence (0-1) */
|
|
782
|
+
confidence: number;
|
|
783
|
+
/** Generation latency (ms) */
|
|
784
|
+
latencyMs: number;
|
|
785
|
+
/** Debug info (only when debug=true) */
|
|
786
|
+
debugInfo?: DebugInfo;
|
|
787
|
+
}
|
|
788
|
+
interface DebugInfo {
|
|
789
|
+
/** Pattern match result */
|
|
790
|
+
patternMatch?: {
|
|
791
|
+
matched: boolean;
|
|
792
|
+
patternId?: string;
|
|
793
|
+
spel?: string;
|
|
794
|
+
};
|
|
795
|
+
/** Intent classification result */
|
|
796
|
+
intent?: {
|
|
797
|
+
primary: string;
|
|
798
|
+
complexity: number;
|
|
799
|
+
};
|
|
800
|
+
/** Template generation result */
|
|
801
|
+
template?: {
|
|
802
|
+
expression?: string;
|
|
803
|
+
templateName?: string;
|
|
804
|
+
};
|
|
805
|
+
/** LLM Provider info */
|
|
806
|
+
provider?: {
|
|
807
|
+
name: string;
|
|
808
|
+
model: string;
|
|
809
|
+
};
|
|
810
|
+
/** Self-correction info */
|
|
811
|
+
corrections?: {
|
|
812
|
+
attempts: number;
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
interface ExplainResult {
|
|
816
|
+
/** Input text */
|
|
817
|
+
input: string;
|
|
818
|
+
/** Strategy used */
|
|
819
|
+
strategy: string;
|
|
820
|
+
/** Intent information */
|
|
821
|
+
intent: {
|
|
822
|
+
primary: string;
|
|
823
|
+
complexity: number;
|
|
824
|
+
all: Array<{
|
|
825
|
+
intent: string;
|
|
826
|
+
confidence: number;
|
|
827
|
+
}>;
|
|
828
|
+
};
|
|
829
|
+
/** Whether pattern was matched */
|
|
830
|
+
patternMatched: boolean;
|
|
831
|
+
/** Matched Pattern ID */
|
|
832
|
+
patternId?: string;
|
|
833
|
+
/** Final expression */
|
|
834
|
+
expression: string;
|
|
835
|
+
/** All possible expressions (from different strategies) */
|
|
836
|
+
alternatives: string[];
|
|
837
|
+
}
|
|
838
|
+
declare class NL2SpelEngine {
|
|
839
|
+
private readonly router;
|
|
840
|
+
private readonly providerRegistry;
|
|
841
|
+
private evaluatorInstance;
|
|
842
|
+
constructor(config?: StrategyRouterConfig);
|
|
843
|
+
/**
|
|
844
|
+
* Register an LLM Provider
|
|
845
|
+
*/
|
|
846
|
+
registerProvider(provider: LLMProvider): void;
|
|
847
|
+
/**
|
|
848
|
+
* Unregister an LLM Provider
|
|
849
|
+
*/
|
|
850
|
+
unregisterProvider(name: string): void;
|
|
851
|
+
/**
|
|
852
|
+
* Register a custom Pattern
|
|
853
|
+
*/
|
|
854
|
+
registerPattern(pattern: PatternDefinition): void;
|
|
855
|
+
/**
|
|
856
|
+
* Set SpelEvaluator for validation pipeline.
|
|
857
|
+
* Must be called before generate() if parse-level validation is required.
|
|
858
|
+
*/
|
|
859
|
+
setSpelEvaluator(evaluator: SpelEvaluator): void;
|
|
860
|
+
/**
|
|
861
|
+
* Extract ContextSchema from raw context object
|
|
862
|
+
*/
|
|
863
|
+
extractContextSchema(context: NonNullable<GenerateOptions['context']>): ContextSchema;
|
|
864
|
+
/**
|
|
865
|
+
* Core generation API
|
|
866
|
+
*/
|
|
867
|
+
generate(nl: string, options?: GenerateOptions): Promise<GenerateResult>;
|
|
868
|
+
/**
|
|
869
|
+
* Batch generation
|
|
870
|
+
*/
|
|
871
|
+
generateBatch(nls: string[], options?: GenerateOptions): Promise<GenerateResult[]>;
|
|
872
|
+
/**
|
|
873
|
+
* Debug explanation
|
|
874
|
+
*/
|
|
875
|
+
explain(nl: string, options?: GenerateOptions): Promise<ExplainResult>;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* Chinese number parser — converts Chinese number strings to Arabic numerals.
|
|
880
|
+
*
|
|
881
|
+
* Supports:
|
|
882
|
+
* - Basic digits: 零一二三四五六七八九十百千万亿
|
|
883
|
+
* - Leading "十": "十五" → 15
|
|
884
|
+
* - Thousands/hundred-millions grouping: "一万二千三百四十五" → 12345
|
|
885
|
+
* - Zero padding: "一千零一" → 1001
|
|
886
|
+
*/
|
|
887
|
+
declare class ChineseNumberParser {
|
|
888
|
+
private static readonly DIGITS;
|
|
889
|
+
private static readonly UNITS;
|
|
890
|
+
private static readonly CHINESE_NUM_PATTERN;
|
|
891
|
+
/**
|
|
892
|
+
* Check if a string is pure Chinese numbers
|
|
893
|
+
*/
|
|
894
|
+
static isChineseNumber(text: string): boolean;
|
|
895
|
+
/**
|
|
896
|
+
* Parse Chinese numbers → Arabic numerals
|
|
897
|
+
*
|
|
898
|
+
* @param text Chinese number string
|
|
899
|
+
* @returns Parsed number, returns NaN on failure
|
|
900
|
+
*/
|
|
901
|
+
static parse(text: string): number;
|
|
902
|
+
/**
|
|
903
|
+
* Safe parse: returns null if parsing fails
|
|
904
|
+
*/
|
|
905
|
+
static parseSafe(text: string): number | null;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
export { type AutoFixResult, AutoFixer, BUILTIN_PATTERNS, ChineseNumberParser, ContextExtractor, type CorrectionLog, type DebugInfo, type ExplainResult, type FewShotExample, type GenerateOptions, type GenerateResult, IntentClassifier, type IntentEntity, type IntentResult, type LLMCapabilities, type LLMGenerateOptions, type LLMPrompt, type LLMProvider, type LLMResponse, type LLMStreamChunk, type LLMUsage, NL2SpelEngine, NLIntent, type PatternDefinition, type PatternMatchResult, PatternMatcher, PromptBuilder, type PromptBuilderOptions, ProviderRegistry, SchemaFormatter, type SelfCorrectionConfig, SelfCorrectionLoop, type SelfCorrectionResult, type SlotDefinition, type SlotTransform, type StageResult, type StrategyMetadata, type StrategyResult, StrategyRouter, type StrategyRouterConfig, type StrategyType, TemplateEngine, type TemplateResult, type ValidationError, ValidationPipeline, type ValidationResult, type ValidationWarning };
|