@agentix-e/nl2spel 1.2.0 → 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 -82
- package/dist/context/context-extractor.d.ts.map +0 -1
- package/dist/context/context-extractor.js +0 -176
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentix-e/nl2spel",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Natural Language → SpEL Expression Generation Engine — Core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -8,19 +8,22 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
11
12
|
"types": "./dist/index.d.ts"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
|
-
"files": [
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
15
19
|
"scripts": {
|
|
16
|
-
"build": "
|
|
20
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
17
21
|
"test": "vitest run",
|
|
18
22
|
"test:watch": "vitest",
|
|
19
23
|
"lint": "tsc --noEmit",
|
|
20
24
|
"typecheck": "tsc --noEmit",
|
|
21
25
|
"clean": "rm -rf dist"
|
|
22
26
|
},
|
|
23
|
-
"dependencies": {},
|
|
24
27
|
"peerDependencies": {
|
|
25
28
|
"@agentix-e/spel-ts": ">=1.1.0"
|
|
26
29
|
},
|
|
@@ -31,10 +34,18 @@
|
|
|
31
34
|
},
|
|
32
35
|
"devDependencies": {
|
|
33
36
|
"@agentix-e/spel-ts": "^1.1.0",
|
|
37
|
+
"tsup": "^8.5.1",
|
|
34
38
|
"typescript": "^5.7.3",
|
|
35
39
|
"vitest": "^3.0.0"
|
|
36
40
|
},
|
|
37
|
-
"keywords": [
|
|
41
|
+
"keywords": [
|
|
42
|
+
"spel",
|
|
43
|
+
"nlp",
|
|
44
|
+
"expression-language",
|
|
45
|
+
"spring",
|
|
46
|
+
"nl2code",
|
|
47
|
+
"agentix"
|
|
48
|
+
],
|
|
38
49
|
"license": "MIT",
|
|
39
50
|
"author": "Agentix-E",
|
|
40
51
|
"repository": {
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { ContextSchema } from '@agentix-e/spel-ts';
|
|
2
|
-
/**
|
|
3
|
-
* ContextExtractor — builds a ContextSchema from plain data structures.
|
|
4
|
-
*
|
|
5
|
-
* Decoupled from any concrete SpEL implementation, accepts only:
|
|
6
|
-
* - rootObject: any object (for extracting property types)
|
|
7
|
-
* - variables: Record<string, { type: string; value?: unknown }>
|
|
8
|
-
* - beans: string[]
|
|
9
|
-
* - types: string[]
|
|
10
|
-
*/
|
|
11
|
-
export declare class ContextExtractor {
|
|
12
|
-
/**
|
|
13
|
-
* Extract ContextSchema from plain data structures (no spel-ts dependency)
|
|
14
|
-
*/
|
|
15
|
-
extract(context: {
|
|
16
|
-
rootObject?: unknown;
|
|
17
|
-
rootName?: string;
|
|
18
|
-
variables?: Record<string, {
|
|
19
|
-
type: string;
|
|
20
|
-
value?: unknown;
|
|
21
|
-
description?: string;
|
|
22
|
-
nullable?: boolean;
|
|
23
|
-
}>;
|
|
24
|
-
beans?: Array<{
|
|
25
|
-
name: string;
|
|
26
|
-
type: string;
|
|
27
|
-
description?: string;
|
|
28
|
-
singleton?: boolean;
|
|
29
|
-
}>;
|
|
30
|
-
types?: Array<{
|
|
31
|
-
name: string;
|
|
32
|
-
className?: string;
|
|
33
|
-
description?: string;
|
|
34
|
-
}>;
|
|
35
|
-
functions?: Array<{
|
|
36
|
-
name: string;
|
|
37
|
-
returnType: string;
|
|
38
|
-
params: Array<{
|
|
39
|
-
name: string;
|
|
40
|
-
type: string;
|
|
41
|
-
}>;
|
|
42
|
-
description?: string;
|
|
43
|
-
}>;
|
|
44
|
-
}): ContextSchema;
|
|
45
|
-
/**
|
|
46
|
-
* Extract root object schema
|
|
47
|
-
*/
|
|
48
|
-
private extractRoot;
|
|
49
|
-
/**
|
|
50
|
-
* Extract object fields
|
|
51
|
-
*/
|
|
52
|
-
private extractFields;
|
|
53
|
-
/**
|
|
54
|
-
* Infer SpEL type
|
|
55
|
-
*/
|
|
56
|
-
private inferSpelType;
|
|
57
|
-
/**
|
|
58
|
-
* Generate field description
|
|
59
|
-
*/
|
|
60
|
-
private generateDescription;
|
|
61
|
-
/**
|
|
62
|
-
* Safely get example value
|
|
63
|
-
*/
|
|
64
|
-
private safeExample;
|
|
65
|
-
/**
|
|
66
|
-
* Extract variables
|
|
67
|
-
*/
|
|
68
|
-
private extractVariables;
|
|
69
|
-
/**
|
|
70
|
-
* Extract beans
|
|
71
|
-
*/
|
|
72
|
-
private extractBeans;
|
|
73
|
-
/**
|
|
74
|
-
* Extract types
|
|
75
|
-
*/
|
|
76
|
-
private extractTypes;
|
|
77
|
-
/**
|
|
78
|
-
* Extract functions
|
|
79
|
-
*/
|
|
80
|
-
private extractFunctions;
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=context-extractor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-extractor.d.ts","sourceRoot":"","sources":["../../src/context/context-extractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAOd,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;GAQG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;IACI,OAAO,CAAC,OAAO,EAAE;QACtB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAChB,MAAM,EACN;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,OAAO,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE,CAC5E,CAAC;QACF,KAAK,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,CAAC;YAAC,SAAS,CAAC,EAAE,OAAO,CAAA;SAAE,CAAC,CAAC;QACzF,KAAK,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,SAAS,CAAC,EAAE,MAAM,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAC1E,SAAS,CAAC,EAAE,KAAK,CAAC;YAChB,IAAI,EAAE,MAAM,CAAC;YACb,UAAU,EAAE,MAAM,CAAC;YACnB,MAAM,EAAE,KAAK,CAAC;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,IAAI,EAAE,MAAM,CAAA;aAAE,CAAC,CAAC;YAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;SACtB,CAAC,CAAC;KACJ,GAAG,aAAa;IAYjB;;OAEG;IACH,OAAO,CAAC,WAAW;IAkBnB;;OAEG;IACH,OAAO,CAAC,aAAa;IA0CrB;;OAEG;IACH,OAAO,CAAC,aAAa;IAWrB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAI3B;;OAEG;IACH,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAoBxB;;OAEG;IACH,OAAO,CAAC,YAAY;IAgBpB;;OAEG;IACH,OAAO,CAAC,YAAY;IAepB;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAoBzB"}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ContextExtractor — builds a ContextSchema from plain data structures.
|
|
3
|
-
*
|
|
4
|
-
* Decoupled from any concrete SpEL implementation, accepts only:
|
|
5
|
-
* - rootObject: any object (for extracting property types)
|
|
6
|
-
* - variables: Record<string, { type: string; value?: unknown }>
|
|
7
|
-
* - beans: string[]
|
|
8
|
-
* - types: string[]
|
|
9
|
-
*/
|
|
10
|
-
export class ContextExtractor {
|
|
11
|
-
/**
|
|
12
|
-
* Extract ContextSchema from plain data structures (no spel-ts dependency)
|
|
13
|
-
*/
|
|
14
|
-
extract(context) {
|
|
15
|
-
const schema = {
|
|
16
|
-
root: this.extractRoot(context),
|
|
17
|
-
variables: this.extractVariables(context),
|
|
18
|
-
beans: this.extractBeans(context),
|
|
19
|
-
types: this.extractTypes(context),
|
|
20
|
-
functions: this.extractFunctions(context),
|
|
21
|
-
};
|
|
22
|
-
return schema;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Extract root object schema
|
|
26
|
-
*/
|
|
27
|
-
extractRoot(context) {
|
|
28
|
-
const { rootObject, rootName } = context;
|
|
29
|
-
if (rootObject === null || rootObject === undefined)
|
|
30
|
-
return null;
|
|
31
|
-
const name = rootName ?? 'root';
|
|
32
|
-
const type = typeof rootObject === 'object'
|
|
33
|
-
? (rootObject?.constructor?.name ?? 'Object')
|
|
34
|
-
: typeof rootObject;
|
|
35
|
-
const fields = this.extractFields(rootObject);
|
|
36
|
-
return { name, type, fields, methods: {} };
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Extract object fields
|
|
40
|
-
*/
|
|
41
|
-
extractFields(obj, depth = 0) {
|
|
42
|
-
if (obj === null || obj === undefined || typeof obj !== 'object') {
|
|
43
|
-
return {};
|
|
44
|
-
}
|
|
45
|
-
// Prevent infinite recursion
|
|
46
|
-
if (depth > 3)
|
|
47
|
-
return {};
|
|
48
|
-
const fields = {};
|
|
49
|
-
for (const key of Object.keys(obj)) {
|
|
50
|
-
try {
|
|
51
|
-
const value = obj[key];
|
|
52
|
-
const fieldType = this.inferSpelType(value);
|
|
53
|
-
const isArray = Array.isArray(value);
|
|
54
|
-
const isObject = !isArray && typeof value === 'object' && value !== null && !(value instanceof Date);
|
|
55
|
-
const field = {
|
|
56
|
-
type: fieldType,
|
|
57
|
-
description: this.generateDescription(key, fieldType),
|
|
58
|
-
isCollection: isArray,
|
|
59
|
-
elementType: isArray && value.length > 0 ? typeof value[0] : undefined,
|
|
60
|
-
nullable: value === null,
|
|
61
|
-
example: this.safeExample(value),
|
|
62
|
-
};
|
|
63
|
-
// Recursively extract nested object fields
|
|
64
|
-
if (isObject) {
|
|
65
|
-
field.fields = this.extractFields(value, depth + 1);
|
|
66
|
-
}
|
|
67
|
-
fields[key] = field;
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
// Skip inaccessible properties
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return fields;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Infer SpEL type
|
|
77
|
-
*/
|
|
78
|
-
inferSpelType(value) {
|
|
79
|
-
if (value === null || value === undefined)
|
|
80
|
-
return 'string';
|
|
81
|
-
if (typeof value === 'string')
|
|
82
|
-
return 'string';
|
|
83
|
-
if (typeof value === 'number')
|
|
84
|
-
return 'number';
|
|
85
|
-
if (typeof value === 'boolean')
|
|
86
|
-
return 'boolean';
|
|
87
|
-
if (value instanceof Date)
|
|
88
|
-
return 'date';
|
|
89
|
-
if (Array.isArray(value))
|
|
90
|
-
return 'array';
|
|
91
|
-
if (typeof value === 'object')
|
|
92
|
-
return 'object';
|
|
93
|
-
return 'string';
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Generate field description
|
|
97
|
-
*/
|
|
98
|
-
generateDescription(key, type) {
|
|
99
|
-
return `Field '${key}' of type ${type}`;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Safely get example value
|
|
103
|
-
*/
|
|
104
|
-
safeExample(value) {
|
|
105
|
-
if (value === null)
|
|
106
|
-
return null;
|
|
107
|
-
if (typeof value === 'object')
|
|
108
|
-
return undefined;
|
|
109
|
-
return value;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Extract variables
|
|
113
|
-
*/
|
|
114
|
-
extractVariables(context) {
|
|
115
|
-
const variables = {};
|
|
116
|
-
if (!context.variables)
|
|
117
|
-
return variables;
|
|
118
|
-
for (const [name, vdef] of Object.entries(context.variables)) {
|
|
119
|
-
variables[name] = {
|
|
120
|
-
type: vdef.type,
|
|
121
|
-
description: vdef.description ?? `Variable '#${name}'`,
|
|
122
|
-
nullable: vdef.nullable ?? false,
|
|
123
|
-
value: vdef.value,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
return variables;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Extract beans
|
|
130
|
-
*/
|
|
131
|
-
extractBeans(context) {
|
|
132
|
-
const beans = {};
|
|
133
|
-
if (!context.beans)
|
|
134
|
-
return beans;
|
|
135
|
-
for (const bdef of context.beans) {
|
|
136
|
-
beans[bdef.name] = {
|
|
137
|
-
type: bdef.type,
|
|
138
|
-
description: bdef.description,
|
|
139
|
-
singleton: bdef.singleton,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
return beans;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Extract types
|
|
146
|
-
*/
|
|
147
|
-
extractTypes(context) {
|
|
148
|
-
const types = {};
|
|
149
|
-
if (!context.types)
|
|
150
|
-
return types;
|
|
151
|
-
for (const tdef of context.types) {
|
|
152
|
-
types[tdef.name] = {
|
|
153
|
-
className: tdef.className,
|
|
154
|
-
description: tdef.description,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
return types;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Extract functions
|
|
161
|
-
*/
|
|
162
|
-
extractFunctions(context) {
|
|
163
|
-
const functions = {};
|
|
164
|
-
if (!context.functions)
|
|
165
|
-
return functions;
|
|
166
|
-
for (const fdef of context.functions) {
|
|
167
|
-
functions[fdef.name] = {
|
|
168
|
-
returnType: fdef.returnType,
|
|
169
|
-
params: fdef.params,
|
|
170
|
-
description: fdef.description,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
return functions;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
//# sourceMappingURL=context-extractor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-extractor.js","sourceRoot":"","sources":["../../src/context/context-extractor.ts"],"names":[],"mappings":"AAUA;;;;;;;;GAQG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;OAEG;IACI,OAAO,CAAC,OAed;QACC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@
|
|
|
1
|
-
import type { ContextSchema } from '@agentix-e/spel-ts';
|
|
2
|
-
/**
|
|
3
|
-
* SchemaFormatter — formats ContextSchema into readable text.
|
|
4
|
-
*
|
|
5
|
-
* Two formats:
|
|
6
|
-
* 1. formatForLLM(): optimized for LLM prompts (compact, key info first)
|
|
7
|
-
* 2. formatForHuman(): human-readable format (complete, indent-friendly)
|
|
8
|
-
*/
|
|
9
|
-
export declare class SchemaFormatter {
|
|
10
|
-
/**
|
|
11
|
-
* LLM-optimized format — compact, injected into the User part of the prompt
|
|
12
|
-
*/
|
|
13
|
-
formatForLLM(schema: ContextSchema): string;
|
|
14
|
-
/**
|
|
15
|
-
* Human-readable format
|
|
16
|
-
*/
|
|
17
|
-
formatForHuman(schema: ContextSchema): string;
|
|
18
|
-
private formatFieldForLLM;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=schema-formatter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-formatter.d.ts","sourceRoot":"","sources":["../../src/context/schema-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,oBAAoB,CAAC;AAErE;;;;;;GAMG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACI,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM;IA2DlD;;OAEG;IACI,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM;IA6BpD,OAAO,CAAC,iBAAiB;CAqB1B"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SchemaFormatter — formats ContextSchema into readable text.
|
|
3
|
-
*
|
|
4
|
-
* Two formats:
|
|
5
|
-
* 1. formatForLLM(): optimized for LLM prompts (compact, key info first)
|
|
6
|
-
* 2. formatForHuman(): human-readable format (complete, indent-friendly)
|
|
7
|
-
*/
|
|
8
|
-
export class SchemaFormatter {
|
|
9
|
-
/**
|
|
10
|
-
* LLM-optimized format — compact, injected into the User part of the prompt
|
|
11
|
-
*/
|
|
12
|
-
formatForLLM(schema) {
|
|
13
|
-
const lines = ['## Context Schema'];
|
|
14
|
-
// Root Object
|
|
15
|
-
if (schema.root) {
|
|
16
|
-
lines.push('');
|
|
17
|
-
lines.push(`Root Object (accessible as #${schema.root.name}):`);
|
|
18
|
-
lines.push(` Type: ${schema.root.type}`);
|
|
19
|
-
lines.push(` Fields:`);
|
|
20
|
-
for (const [name, field] of Object.entries(schema.root.fields)) {
|
|
21
|
-
lines.push(this.formatFieldForLLM(name, field, ' '));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
// Variables
|
|
25
|
-
if (Object.keys(schema.variables).length > 0) {
|
|
26
|
-
lines.push('');
|
|
27
|
-
lines.push(`Variables:`);
|
|
28
|
-
for (const [name, varDef] of Object.entries(schema.variables)) {
|
|
29
|
-
lines.push(` #${name}: ${varDef.type}` + (varDef.description ? ` (${varDef.description})` : ''));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
// Beans
|
|
33
|
-
if (Object.keys(schema.beans).length > 0) {
|
|
34
|
-
lines.push('');
|
|
35
|
-
lines.push(`Beans:`);
|
|
36
|
-
for (const [name, beanDef] of Object.entries(schema.beans)) {
|
|
37
|
-
lines.push(` @${name}: ${beanDef.type}` + (beanDef.description ? ` (${beanDef.description})` : ''));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// Types
|
|
41
|
-
if (Object.keys(schema.types).length > 0) {
|
|
42
|
-
lines.push('');
|
|
43
|
-
lines.push(`Types (accessible via T(typeName)):`);
|
|
44
|
-
for (const [name, typeDef] of Object.entries(schema.types)) {
|
|
45
|
-
lines.push(` ${name}` + (typeDef.description ? `: ${typeDef.description}` : ''));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
// Functions
|
|
49
|
-
if (Object.keys(schema.functions).length > 0) {
|
|
50
|
-
lines.push('');
|
|
51
|
-
lines.push(`Functions:`);
|
|
52
|
-
for (const [name, funcDef] of Object.entries(schema.functions)) {
|
|
53
|
-
const params = funcDef.params.map((p) => `${p.name}: ${p.type}`).join(', ');
|
|
54
|
-
lines.push(` #${name}(${params}): ${funcDef.returnType}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
lines.push('');
|
|
58
|
-
return lines.join('\n');
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Human-readable format
|
|
62
|
-
*/
|
|
63
|
-
formatForHuman(schema) {
|
|
64
|
-
const lines = [
|
|
65
|
-
'═══════════════════════════════════════',
|
|
66
|
-
' Context Schema (Human-Readable)',
|
|
67
|
-
'═══════════════════════════════════════',
|
|
68
|
-
];
|
|
69
|
-
if (schema.root) {
|
|
70
|
-
lines.push('');
|
|
71
|
-
lines.push(`┌─ Root: #${schema.root.name}`);
|
|
72
|
-
lines.push(`│ Type: ${schema.root.type}`);
|
|
73
|
-
lines.push(`│ Fields:`);
|
|
74
|
-
const entries = Object.entries(schema.root.fields);
|
|
75
|
-
for (let i = 0; i < entries.length; i++) {
|
|
76
|
-
const [name, field] = entries[i];
|
|
77
|
-
const prefix = i < entries.length - 1 ? '├─' : '└─';
|
|
78
|
-
lines.push(`│ ${prefix} ${name} (${field.type})` +
|
|
79
|
-
(field.description ? ` — ${field.description}` : '') +
|
|
80
|
-
(field.nullable ? ' | nullable' : '') +
|
|
81
|
-
(field.isCollection ? ` | collection<${field.elementType ?? 'unknown'}>` : ''));
|
|
82
|
-
}
|
|
83
|
-
lines.push(`│ └─ (${entries.length} fields total)`);
|
|
84
|
-
}
|
|
85
|
-
return lines.join('\n');
|
|
86
|
-
}
|
|
87
|
-
formatFieldForLLM(name, field, indent) {
|
|
88
|
-
const parts = [`${indent}- ${name}: ${field.type}`];
|
|
89
|
-
if (field.description) {
|
|
90
|
-
parts.push(`(${field.description})`);
|
|
91
|
-
}
|
|
92
|
-
if (field.isCollection) {
|
|
93
|
-
parts.push(`[array of ${field.elementType ?? 'unknown'}]`);
|
|
94
|
-
}
|
|
95
|
-
if (field.nullable) {
|
|
96
|
-
parts.push(`[nullable]`);
|
|
97
|
-
}
|
|
98
|
-
if (field.example !== undefined) {
|
|
99
|
-
parts.push(`(e.g. ${JSON.stringify(field.example)})`);
|
|
100
|
-
}
|
|
101
|
-
return parts.join(' ');
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=schema-formatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-formatter.js","sourceRoot":"","sources":["../../src/context/schema-formatter.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;IAC1B;;OAEG;IACI,YAAY,CAAC,MAAqB;QACvC,MAAM,KAAK,GAAa,CAAC,mBAAmB,CAAC,CAAC;QAE9C,cAAc;QACd,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,+BAA+B,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;YAChE,KAAK,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAC1C,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACxB,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC/D,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;QAED,YAAY;QACZ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC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;QAEpD,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YACtB,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;YACvB,KAAK,CAAC,IAAI,CAAC,aAAa,KAAK,CAAC,WAAW,IAAI,SAAS,GAAG,CAAC,CAAC;QAC7D,CAAC;QAED,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3B,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { type StrategyRouterConfig } from '../strategy/strategy-router.js';
|
|
2
|
-
import type { LLMProvider } from '../provider/llm-provider.js';
|
|
3
|
-
import type { PatternDefinition } from '../pattern/pattern-definition.js';
|
|
4
|
-
import type { ContextSchema, SpelEvaluator } from '@agentix-e/spel-ts';
|
|
5
|
-
export interface GenerateOptions {
|
|
6
|
-
/** Context Schema (optional) */
|
|
7
|
-
contextSchema?: ContextSchema;
|
|
8
|
-
/** Raw context object (auto-extracted to ContextSchema) */
|
|
9
|
-
context?: {
|
|
10
|
-
rootObject?: unknown;
|
|
11
|
-
rootName?: string;
|
|
12
|
-
variables?: Record<string, {
|
|
13
|
-
type: string;
|
|
14
|
-
value?: unknown;
|
|
15
|
-
description?: string;
|
|
16
|
-
nullable?: boolean;
|
|
17
|
-
}>;
|
|
18
|
-
beans?: Array<{
|
|
19
|
-
name: string;
|
|
20
|
-
type: string;
|
|
21
|
-
description?: string;
|
|
22
|
-
}>;
|
|
23
|
-
types?: Array<{
|
|
24
|
-
name: string;
|
|
25
|
-
className?: string;
|
|
26
|
-
description?: string;
|
|
27
|
-
}>;
|
|
28
|
-
};
|
|
29
|
-
/** Force using a specific LLM Provider */
|
|
30
|
-
preferredProvider?: string;
|
|
31
|
-
/** Minimum confidence threshold (default 0.5) */
|
|
32
|
-
minConfidence?: number;
|
|
33
|
-
/** Offline only (Pattern + Template, no LLM calls) */
|
|
34
|
-
offlineOnly?: boolean;
|
|
35
|
-
/** Whether validation is enabled (default true) */
|
|
36
|
-
enableValidation?: boolean;
|
|
37
|
-
/** Whether self-correction is enabled (default true) */
|
|
38
|
-
enableSelfCorrection?: boolean;
|
|
39
|
-
/** Language (default auto-detect) */
|
|
40
|
-
language?: 'zh' | 'en';
|
|
41
|
-
/** Whether to return debug information */
|
|
42
|
-
debug?: boolean;
|
|
43
|
-
}
|
|
44
|
-
export interface GenerateResult {
|
|
45
|
-
/** Generated SpEL expression */
|
|
46
|
-
expression: string;
|
|
47
|
-
/** Strategy used */
|
|
48
|
-
strategy: string;
|
|
49
|
-
/** Confidence (0-1) */
|
|
50
|
-
confidence: number;
|
|
51
|
-
/** Generation latency (ms) */
|
|
52
|
-
latencyMs: number;
|
|
53
|
-
/** Debug info (only when debug=true) */
|
|
54
|
-
debugInfo?: DebugInfo;
|
|
55
|
-
}
|
|
56
|
-
export interface DebugInfo {
|
|
57
|
-
/** Pattern match result */
|
|
58
|
-
patternMatch?: {
|
|
59
|
-
matched: boolean;
|
|
60
|
-
patternId?: string;
|
|
61
|
-
spel?: string;
|
|
62
|
-
};
|
|
63
|
-
/** Intent classification result */
|
|
64
|
-
intent?: {
|
|
65
|
-
primary: string;
|
|
66
|
-
complexity: number;
|
|
67
|
-
};
|
|
68
|
-
/** Template generation result */
|
|
69
|
-
template?: {
|
|
70
|
-
expression?: string;
|
|
71
|
-
templateName?: string;
|
|
72
|
-
};
|
|
73
|
-
/** LLM Provider info */
|
|
74
|
-
provider?: {
|
|
75
|
-
name: string;
|
|
76
|
-
model: string;
|
|
77
|
-
};
|
|
78
|
-
/** Self-correction info */
|
|
79
|
-
corrections?: {
|
|
80
|
-
attempts: number;
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
export interface ExplainResult {
|
|
84
|
-
/** Input text */
|
|
85
|
-
input: string;
|
|
86
|
-
/** Strategy used */
|
|
87
|
-
strategy: string;
|
|
88
|
-
/** Intent information */
|
|
89
|
-
intent: {
|
|
90
|
-
primary: string;
|
|
91
|
-
complexity: number;
|
|
92
|
-
all: Array<{
|
|
93
|
-
intent: string;
|
|
94
|
-
confidence: number;
|
|
95
|
-
}>;
|
|
96
|
-
};
|
|
97
|
-
/** Whether pattern was matched */
|
|
98
|
-
patternMatched: boolean;
|
|
99
|
-
/** Matched Pattern ID */
|
|
100
|
-
patternId?: string;
|
|
101
|
-
/** Final expression */
|
|
102
|
-
expression: string;
|
|
103
|
-
/** All possible expressions (from different strategies) */
|
|
104
|
-
alternatives: string[];
|
|
105
|
-
}
|
|
106
|
-
export declare class NL2SpelEngine {
|
|
107
|
-
private readonly router;
|
|
108
|
-
private readonly providerRegistry;
|
|
109
|
-
private evaluatorInstance;
|
|
110
|
-
constructor(config?: StrategyRouterConfig);
|
|
111
|
-
/**
|
|
112
|
-
* Register an LLM Provider
|
|
113
|
-
*/
|
|
114
|
-
registerProvider(provider: LLMProvider): void;
|
|
115
|
-
/**
|
|
116
|
-
* Unregister an LLM Provider
|
|
117
|
-
*/
|
|
118
|
-
unregisterProvider(name: string): void;
|
|
119
|
-
/**
|
|
120
|
-
* Register a custom Pattern
|
|
121
|
-
*/
|
|
122
|
-
registerPattern(pattern: PatternDefinition): void;
|
|
123
|
-
/**
|
|
124
|
-
* Set SpelEvaluator for validation pipeline.
|
|
125
|
-
* Must be called before generate() if parse-level validation is required.
|
|
126
|
-
*/
|
|
127
|
-
setSpelEvaluator(evaluator: SpelEvaluator): void;
|
|
128
|
-
/**
|
|
129
|
-
* Extract ContextSchema from raw context object
|
|
130
|
-
*/
|
|
131
|
-
extractContextSchema(context: NonNullable<GenerateOptions['context']>): ContextSchema;
|
|
132
|
-
/**
|
|
133
|
-
* Core generation API
|
|
134
|
-
*/
|
|
135
|
-
generate(nl: string, options?: GenerateOptions): Promise<GenerateResult>;
|
|
136
|
-
/**
|
|
137
|
-
* Batch generation
|
|
138
|
-
*/
|
|
139
|
-
generateBatch(nls: string[], options?: GenerateOptions): Promise<GenerateResult[]>;
|
|
140
|
-
/**
|
|
141
|
-
* Debug explanation
|
|
142
|
-
*/
|
|
143
|
-
explain(nl: string, options?: GenerateOptions): Promise<ExplainResult>;
|
|
144
|
-
}
|
|
145
|
-
//# sourceMappingURL=nl2spel-engine.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nl2spel-engine.d.ts","sourceRoot":"","sources":["../../src/engine/nl2spel-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAE3F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAG1E,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEvE,MAAM,WAAW,eAAe;IAC9B,gCAAgC;IAChC,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B,2DAA2D;IAC3D,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAChB,MAAM,EACN;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,OAAO,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE,CAC5E,CAAC;QACF,KAAK,CAAC,EAA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