lua-cli 3.5.0-alpha.4 → 3.5.0-alpha.6
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/api/http.client.js +5 -1
- package/dist/api/http.client.js.map +1 -1
- package/dist/commands/compile.d.ts +0 -1
- package/dist/commands/compile.js +14 -10
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/integrations.js +1 -1
- package/dist/commands/integrations.js.map +1 -1
- package/dist/commands/push.js +79 -6
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/sync.js +9 -5
- package/dist/commands/sync.js.map +1 -1
- package/dist/compiler/agent-traverser.d.ts +1 -0
- package/dist/compiler/agent-traverser.js +11 -4
- package/dist/compiler/agent-traverser.js.map +1 -1
- package/dist/compiler/bundler.d.ts +1 -1
- package/dist/compiler/bundler.js +2 -1
- package/dist/compiler/bundler.js.map +1 -1
- package/dist/compiler/compiler.js +3 -2
- package/dist/compiler/compiler.js.map +1 -1
- package/dist/compiler/index.d.ts +1 -1
- package/dist/compiler/index.js +1 -1
- package/dist/compiler/index.js.map +1 -1
- package/dist/compiler/plugins/base.d.ts +21 -1
- package/dist/compiler/plugins/base.js +37 -1
- package/dist/compiler/plugins/base.js.map +1 -1
- package/dist/compiler/plugins/job.plugin.js +17 -64
- package/dist/compiler/plugins/job.plugin.js.map +1 -1
- package/dist/compiler/plugins/mcp-server.plugin.d.ts +0 -8
- package/dist/compiler/plugins/mcp-server.plugin.js +25 -58
- package/dist/compiler/plugins/mcp-server.plugin.js.map +1 -1
- package/dist/compiler/plugins/postprocessor.plugin.js +1 -10
- package/dist/compiler/plugins/postprocessor.plugin.js.map +1 -1
- package/dist/compiler/plugins/preprocessor.plugin.js +4 -17
- package/dist/compiler/plugins/preprocessor.plugin.js.map +1 -1
- package/dist/compiler/plugins/processor-base.js +2 -9
- package/dist/compiler/plugins/processor-base.js.map +1 -1
- package/dist/compiler/plugins/skill.plugin.js +37 -32
- package/dist/compiler/plugins/skill.plugin.js.map +1 -1
- package/dist/compiler/plugins/tool.plugin.d.ts +1 -0
- package/dist/compiler/plugins/tool.plugin.js +9 -30
- package/dist/compiler/plugins/tool.plugin.js.map +1 -1
- package/dist/compiler/plugins/webhook.plugin.js +11 -23
- package/dist/compiler/plugins/webhook.plugin.js.map +1 -1
- package/dist/compiler/types.d.ts +5 -0
- package/dist/compiler/types.js +7 -0
- package/dist/compiler/types.js.map +1 -1
- package/dist/compiler/utils/ast-helpers.d.ts +69 -17
- package/dist/compiler/utils/ast-helpers.js +250 -61
- package/dist/compiler/utils/ast-helpers.js.map +1 -1
- package/dist/config/compile.constants.d.ts +26 -0
- package/dist/config/compile.constants.js +44 -0
- package/dist/config/compile.constants.js.map +1 -1
- package/dist/primitives/base.handler.d.ts +45 -6
- package/dist/primitives/base.handler.js +121 -17
- package/dist/primitives/base.handler.js.map +1 -1
- package/dist/primitives/index.d.ts +4 -5
- package/dist/primitives/index.js +7 -17
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/job.handler.d.ts +0 -5
- package/dist/primitives/job.handler.js +1 -15
- package/dist/primitives/job.handler.js.map +1 -1
- package/dist/primitives/mcp-server.handler.d.ts +1 -1
- package/dist/primitives/mcp-server.handler.js +15 -6
- package/dist/primitives/mcp-server.handler.js.map +1 -1
- package/dist/primitives/postprocessor.handler.d.ts +0 -11
- package/dist/primitives/postprocessor.handler.js +1 -24
- package/dist/primitives/postprocessor.handler.js.map +1 -1
- package/dist/primitives/preprocessor.handler.d.ts +0 -11
- package/dist/primitives/preprocessor.handler.js +1 -24
- package/dist/primitives/preprocessor.handler.js.map +1 -1
- package/dist/primitives/skill.handler.d.ts +3 -1
- package/dist/primitives/skill.handler.js +10 -29
- package/dist/primitives/skill.handler.js.map +1 -1
- package/dist/primitives/types.d.ts +18 -0
- package/dist/primitives/types.js.map +1 -1
- package/dist/primitives/webhook.handler.d.ts +0 -5
- package/dist/primitives/webhook.handler.js +1 -15
- package/dist/primitives/webhook.handler.js.map +1 -1
- package/dist/utils/cli.js +3 -3
- package/dist/utils/cli.js.map +1 -1
- package/dist/utils/command-utils.d.ts +12 -10
- package/dist/utils/command-utils.js +19 -17
- package/dist/utils/command-utils.js.map +1 -1
- package/dist/utils/files.d.ts +10 -0
- package/dist/utils/files.js +34 -0
- package/dist/utils/files.js.map +1 -1
- package/dist/utils/sandbox.js +3 -20
- package/dist/utils/sandbox.js.map +1 -1
- package/dist/web/app.css +186 -912
- package/dist/web/app.js +46 -46
- package/docs/README.md +3 -3
- package/package.json +1 -1
- package/template/package.json +1 -1
|
@@ -1,13 +1,124 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AST helper functions for extracting values from ts-morph nodes.
|
|
2
|
+
* AST helper functions for extracting and evaluating values from ts-morph nodes.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Organized into sections:
|
|
5
|
+
* 1. EVALUATION ENGINE — ts-evaluator core with lua-cli passthrough shims
|
|
6
|
+
* 2. NODE EVALUATION — resolve a raw AST Node to a typed runtime value
|
|
7
|
+
* 3. PROPERTY EXTRACTION — get typed values from ObjectLiteralExpression properties
|
|
8
|
+
* 4. NODE INSPECTION — type checks and utilities for AST nodes
|
|
9
|
+
* 5. IDENTIFIER RESOLUTION — follow variable/import reference chains to declarations
|
|
10
|
+
* 6. IMPORT RESOLUTION — locate source files for imported identifiers
|
|
6
11
|
*/
|
|
7
|
-
import { Node
|
|
12
|
+
import { Node } from 'ts-morph';
|
|
13
|
+
import ts from 'typescript';
|
|
14
|
+
import { evaluate } from 'ts-evaluator';
|
|
15
|
+
import { PRIMITIVE_SHIMS } from '../../config/compile.constants.js';
|
|
16
|
+
// =============================================================================
|
|
17
|
+
// 1. EVALUATION ENGINE
|
|
18
|
+
//
|
|
19
|
+
// Core ts-evaluator wrapper with lua-cli passthrough shims.
|
|
20
|
+
// Shims are defined in config/compile.constants.ts (single source of truth)
|
|
21
|
+
// and shared with utils/sandbox.ts.
|
|
22
|
+
// =============================================================================
|
|
23
|
+
/**
|
|
24
|
+
* Evaluate any AST expression node using ts-evaluator.
|
|
25
|
+
* Handles ALL expression types: literals, concatenation, variables,
|
|
26
|
+
* imported constants, template literals, function calls, etc.
|
|
27
|
+
*
|
|
28
|
+
* Provides lua-cli primitive shims so that expressions like
|
|
29
|
+
* `defineTool({name: 'foo'})` evaluate successfully.
|
|
30
|
+
*/
|
|
31
|
+
function evaluateNode(node) {
|
|
32
|
+
if (!node)
|
|
33
|
+
return undefined;
|
|
34
|
+
try {
|
|
35
|
+
const tsNode = node.compilerNode;
|
|
36
|
+
const typeChecker = node.getSourceFile().getProject().getTypeChecker().compilerObject;
|
|
37
|
+
const result = evaluate({
|
|
38
|
+
node: tsNode,
|
|
39
|
+
typeChecker,
|
|
40
|
+
typescript: ts,
|
|
41
|
+
environment: {
|
|
42
|
+
preset: 'NODE',
|
|
43
|
+
extra: PRIMITIVE_SHIMS,
|
|
44
|
+
},
|
|
45
|
+
policy: {
|
|
46
|
+
deterministic: false,
|
|
47
|
+
network: false,
|
|
48
|
+
console: false,
|
|
49
|
+
io: { read: true, write: false },
|
|
50
|
+
process: { exit: false, spawnChild: false },
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
if (result.success)
|
|
54
|
+
return result.value;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// ts-evaluator failed — return undefined
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
// =============================================================================
|
|
62
|
+
// 2. NODE EVALUATION
|
|
63
|
+
//
|
|
64
|
+
// Evaluate a raw AST Node to a typed runtime value.
|
|
65
|
+
// Primary path: ts-evaluator. Fallback: resolveIdentifier() + literal check.
|
|
66
|
+
// =============================================================================
|
|
67
|
+
/** Evaluate an AST node as a string. Falls back to AST resolution if ts-evaluator fails. */
|
|
68
|
+
export function evaluateNodeAsString(node) {
|
|
69
|
+
const val = evaluateNode(node);
|
|
70
|
+
if (typeof val === 'string')
|
|
71
|
+
return val;
|
|
72
|
+
// AST fallback: resolve identifier chain → check for string literal
|
|
73
|
+
if (node) {
|
|
74
|
+
const resolved = resolveIdentifier(node);
|
|
75
|
+
if (resolved && Node.isStringLiteral(resolved))
|
|
76
|
+
return resolved.getLiteralValue();
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
/** Evaluate an AST node as a number. Falls back to AST resolution if ts-evaluator fails. */
|
|
81
|
+
export function evaluateNodeAsNumber(node) {
|
|
82
|
+
const val = evaluateNode(node);
|
|
83
|
+
if (typeof val === 'number')
|
|
84
|
+
return val;
|
|
85
|
+
// AST fallback: resolve identifier chain → check for numeric literal
|
|
86
|
+
if (node) {
|
|
87
|
+
const resolved = resolveIdentifier(node);
|
|
88
|
+
if (resolved && Node.isNumericLiteral(resolved))
|
|
89
|
+
return resolved.getLiteralValue();
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
/** Evaluate an AST node as a boolean. Falls back to AST resolution if ts-evaluator fails. */
|
|
94
|
+
export function evaluateNodeAsBoolean(node) {
|
|
95
|
+
const val = evaluateNode(node);
|
|
96
|
+
if (typeof val === 'boolean')
|
|
97
|
+
return val;
|
|
98
|
+
// AST fallback: resolve identifier chain → check for boolean literal
|
|
99
|
+
if (node) {
|
|
100
|
+
const resolved = resolveIdentifier(node);
|
|
101
|
+
if (resolved && Node.isTrueLiteral(resolved))
|
|
102
|
+
return true;
|
|
103
|
+
if (resolved && Node.isFalseLiteral(resolved))
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
// =============================================================================
|
|
109
|
+
// 3. PROPERTY EXTRACTION
|
|
110
|
+
//
|
|
111
|
+
// All functions that read a named property from an ObjectLiteralExpression.
|
|
112
|
+
//
|
|
113
|
+
// Primitives: extractStringProperty, extractNumberProperty, extractBooleanProperty
|
|
114
|
+
// Complex: extractObjectProperty, extractArrayProperty, extractFunctionProperty
|
|
115
|
+
// Raw AST: extractSchemaProperty (returns Node for downstream Zod processing)
|
|
116
|
+
// Post-eval: extractNestedProperty (plain key lookup on already-extracted object)
|
|
117
|
+
// Introspection: hasProperty, getPropertyNames
|
|
118
|
+
// =============================================================================
|
|
8
119
|
/**
|
|
9
120
|
* Extract a string value from an object property.
|
|
10
|
-
*
|
|
121
|
+
* Delegates to evaluateNodeAsString for full expression evaluation + AST fallback.
|
|
11
122
|
*/
|
|
12
123
|
export function extractStringProperty(obj, propertyName) {
|
|
13
124
|
const prop = obj.getProperty(propertyName);
|
|
@@ -16,65 +127,54 @@ export function extractStringProperty(obj, propertyName) {
|
|
|
16
127
|
const value = prop.getInitializer();
|
|
17
128
|
if (!value)
|
|
18
129
|
return undefined;
|
|
19
|
-
|
|
20
|
-
if (Node.isStringLiteral(value)) {
|
|
21
|
-
return value.getLiteralValue();
|
|
22
|
-
}
|
|
23
|
-
// Template literal without expressions: `value`
|
|
24
|
-
if (Node.isNoSubstitutionTemplateLiteral(value)) {
|
|
25
|
-
return value.getLiteralValue();
|
|
26
|
-
}
|
|
27
|
-
// Template literal with expressions: `${x}` - return the full text
|
|
28
|
-
if (Node.isTemplateExpression(value)) {
|
|
29
|
-
// For complex templates, return the raw text minus backticks
|
|
30
|
-
const text = value.getText();
|
|
31
|
-
return text.slice(1, -1);
|
|
32
|
-
}
|
|
33
|
-
return undefined;
|
|
130
|
+
return evaluateNodeAsString(value);
|
|
34
131
|
}
|
|
35
132
|
/**
|
|
36
133
|
* Extract a boolean value from an object property.
|
|
134
|
+
* Delegates to evaluateNodeAsBoolean for full expression evaluation + AST fallback.
|
|
37
135
|
*/
|
|
38
136
|
export function extractBooleanProperty(obj, propertyName) {
|
|
39
137
|
const prop = obj.getProperty(propertyName);
|
|
40
138
|
if (!prop || !Node.isPropertyAssignment(prop))
|
|
41
139
|
return undefined;
|
|
42
|
-
|
|
43
|
-
if (!value)
|
|
44
|
-
return undefined;
|
|
45
|
-
const kind = value.getKind();
|
|
46
|
-
// TrueKeyword = 110, FalseKeyword = 95 in ts-morph
|
|
47
|
-
if (kind === SyntaxKind.TrueKeyword)
|
|
48
|
-
return true;
|
|
49
|
-
if (kind === SyntaxKind.FalseKeyword)
|
|
50
|
-
return false;
|
|
51
|
-
// Handle string "true" or "false"
|
|
52
|
-
if (Node.isStringLiteral(value)) {
|
|
53
|
-
const text = value.getLiteralValue();
|
|
54
|
-
if (text === 'true')
|
|
55
|
-
return true;
|
|
56
|
-
if (text === 'false')
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
return undefined;
|
|
140
|
+
return evaluateNodeAsBoolean(prop.getInitializer());
|
|
60
141
|
}
|
|
61
142
|
/**
|
|
62
143
|
* Extract a number value from an object property.
|
|
144
|
+
* Delegates to evaluateNodeAsNumber for full expression evaluation + AST fallback.
|
|
63
145
|
*/
|
|
64
146
|
export function extractNumberProperty(obj, propertyName) {
|
|
65
147
|
const prop = obj.getProperty(propertyName);
|
|
66
148
|
if (!prop || !Node.isPropertyAssignment(prop))
|
|
67
149
|
return undefined;
|
|
68
|
-
|
|
69
|
-
|
|
150
|
+
return evaluateNodeAsNumber(prop.getInitializer());
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Extract a schema node from an object property.
|
|
154
|
+
* Returns the raw AST node (not evaluated) for downstream Zod processing.
|
|
155
|
+
*/
|
|
156
|
+
export function extractSchemaProperty(obj, propertyName) {
|
|
157
|
+
const prop = obj.getProperty(propertyName);
|
|
158
|
+
if (!prop || !Node.isPropertyAssignment(prop))
|
|
70
159
|
return undefined;
|
|
71
|
-
|
|
72
|
-
return value.getLiteralValue();
|
|
73
|
-
}
|
|
74
|
-
return undefined;
|
|
160
|
+
return prop.getInitializer();
|
|
75
161
|
}
|
|
76
162
|
/**
|
|
77
|
-
* Extract
|
|
163
|
+
* Extract nested property from an already-evaluated object (not AST).
|
|
164
|
+
* Use after extractObjectProperty() to drill into nested values.
|
|
165
|
+
*
|
|
166
|
+
* Example:
|
|
167
|
+
* const schedule = extractObjectProperty(config, 'schedule');
|
|
168
|
+
* const type = extractNestedProperty(schedule, 'type');
|
|
169
|
+
*/
|
|
170
|
+
export function extractNestedProperty(obj, propertyName) {
|
|
171
|
+
if (!obj || typeof obj !== 'object')
|
|
172
|
+
return undefined;
|
|
173
|
+
return obj[propertyName];
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Extract an object property, evaluated to its runtime value.
|
|
177
|
+
* Uses ts-evaluator to resolve inline objects, variable references, imports, spreads.
|
|
78
178
|
*/
|
|
79
179
|
export function extractObjectProperty(obj, propertyName) {
|
|
80
180
|
const prop = obj.getProperty(propertyName);
|
|
@@ -83,46 +183,62 @@ export function extractObjectProperty(obj, propertyName) {
|
|
|
83
183
|
const value = prop.getInitializer();
|
|
84
184
|
if (!value)
|
|
85
185
|
return undefined;
|
|
86
|
-
|
|
87
|
-
|
|
186
|
+
const evaluated = evaluateNode(value);
|
|
187
|
+
if (evaluated && typeof evaluated === 'object' && !Array.isArray(evaluated)) {
|
|
188
|
+
return evaluated;
|
|
88
189
|
}
|
|
89
190
|
return undefined;
|
|
90
191
|
}
|
|
91
192
|
/**
|
|
92
|
-
* Extract
|
|
93
|
-
*
|
|
193
|
+
* Extract an array property, evaluated to its runtime value.
|
|
194
|
+
* Uses ts-evaluator to resolve inline arrays, variable references, imports, spreads.
|
|
94
195
|
*/
|
|
95
|
-
export function
|
|
196
|
+
export function extractArrayProperty(obj, propertyName) {
|
|
96
197
|
const prop = obj.getProperty(propertyName);
|
|
97
198
|
if (!prop || !Node.isPropertyAssignment(prop))
|
|
98
199
|
return undefined;
|
|
99
|
-
|
|
200
|
+
const value = prop.getInitializer();
|
|
201
|
+
if (!value)
|
|
202
|
+
return undefined;
|
|
203
|
+
const evaluated = evaluateNode(value);
|
|
204
|
+
return Array.isArray(evaluated) ? evaluated : undefined;
|
|
100
205
|
}
|
|
101
206
|
/**
|
|
102
|
-
*
|
|
207
|
+
* Extract a function property, evaluated to its runtime value.
|
|
208
|
+
* Detects both inline function expressions and variable references to functions.
|
|
103
209
|
*/
|
|
210
|
+
export function extractFunctionProperty(obj, propertyName) {
|
|
211
|
+
const prop = obj.getProperty(propertyName);
|
|
212
|
+
if (!prop || !Node.isPropertyAssignment(prop))
|
|
213
|
+
return undefined;
|
|
214
|
+
const value = prop.getInitializer();
|
|
215
|
+
if (!value)
|
|
216
|
+
return undefined;
|
|
217
|
+
const evaluated = evaluateNode(value);
|
|
218
|
+
return typeof evaluated === 'function' ? evaluated : undefined;
|
|
219
|
+
}
|
|
220
|
+
/** Check if a property exists on an object literal. */
|
|
104
221
|
export function hasProperty(obj, propertyName) {
|
|
105
222
|
return obj.getProperty(propertyName) !== undefined;
|
|
106
223
|
}
|
|
107
|
-
/**
|
|
108
|
-
* Extract all property names from an object literal.
|
|
109
|
-
*/
|
|
224
|
+
/** Extract all property names from an object literal. */
|
|
110
225
|
export function getPropertyNames(obj) {
|
|
111
226
|
return obj.getProperties()
|
|
112
227
|
.filter(prop => Node.isPropertyAssignment(prop))
|
|
113
228
|
.map(prop => prop.getName());
|
|
114
229
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
230
|
+
// =============================================================================
|
|
231
|
+
// 4. NODE INSPECTION
|
|
232
|
+
//
|
|
233
|
+
// Type checks and utilities for individual AST nodes.
|
|
234
|
+
// =============================================================================
|
|
235
|
+
/** Check if a node is a function (arrow or regular). */
|
|
118
236
|
export function isFunction(node) {
|
|
119
237
|
if (!node)
|
|
120
238
|
return false;
|
|
121
239
|
return Node.isArrowFunction(node) || Node.isFunctionExpression(node);
|
|
122
240
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Get the text of a function body.
|
|
125
|
-
*/
|
|
241
|
+
/** Get the text of a function body. */
|
|
126
242
|
export function getFunctionBody(node) {
|
|
127
243
|
if (!node)
|
|
128
244
|
return undefined;
|
|
@@ -136,6 +252,79 @@ export function getFunctionBody(node) {
|
|
|
136
252
|
}
|
|
137
253
|
return undefined;
|
|
138
254
|
}
|
|
255
|
+
// =============================================================================
|
|
256
|
+
// 5. IDENTIFIER RESOLUTION
|
|
257
|
+
//
|
|
258
|
+
// Follow variable reference chains (same-file and cross-file via imports)
|
|
259
|
+
// to find the underlying declaration/initializer.
|
|
260
|
+
// =============================================================================
|
|
261
|
+
/**
|
|
262
|
+
* Recursively resolve an Identifier node to its underlying initializer.
|
|
263
|
+
*
|
|
264
|
+
* Follows variable reference chains, including across files:
|
|
265
|
+
* const a = [x, y];
|
|
266
|
+
* const b = a; // resolveIdentifier(b) → ArrayLiteralExpression [x, y]
|
|
267
|
+
* const c = b; // resolveIdentifier(c) → ArrayLiteralExpression [x, y]
|
|
268
|
+
*
|
|
269
|
+
* Resolution strategy:
|
|
270
|
+
* 1. Same-file lookup via getVariableDeclaration() (fast path)
|
|
271
|
+
* 2. Cross-file lookup via getDefinitionNodes() (follows imports)
|
|
272
|
+
*
|
|
273
|
+
* Stops at non-Identifier initializers (literals, call expressions, etc.)
|
|
274
|
+
* or when the declaration can't be found.
|
|
275
|
+
* Max depth of 10 to prevent infinite loops on circular references.
|
|
276
|
+
*/
|
|
277
|
+
export function resolveIdentifier(node, maxDepth = 10) {
|
|
278
|
+
if (!Node.isIdentifier(node))
|
|
279
|
+
return node;
|
|
280
|
+
let identNode = node;
|
|
281
|
+
for (let i = 0; i < maxDepth; i++) {
|
|
282
|
+
// Fast path: same-file variable declaration
|
|
283
|
+
let varDecl = identNode.getSourceFile().getVariableDeclaration(identNode.getText());
|
|
284
|
+
// Cross-file: follow imports via TypeChecker symbol resolution
|
|
285
|
+
if (!varDecl) {
|
|
286
|
+
try {
|
|
287
|
+
const defs = identNode.getDefinitionNodes();
|
|
288
|
+
varDecl = defs.find(d => Node.isVariableDeclaration(d));
|
|
289
|
+
}
|
|
290
|
+
catch { /* symbol resolution unavailable — file not in project */ }
|
|
291
|
+
}
|
|
292
|
+
if (!varDecl)
|
|
293
|
+
return identNode; // Can't resolve further
|
|
294
|
+
const init = varDecl.getInitializer();
|
|
295
|
+
if (!init)
|
|
296
|
+
return undefined;
|
|
297
|
+
// If the initializer is another Identifier, keep following the chain
|
|
298
|
+
if (Node.isIdentifier(init)) {
|
|
299
|
+
identNode = init;
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
// Reached a non-Identifier node — this is the resolved value
|
|
303
|
+
return init;
|
|
304
|
+
}
|
|
305
|
+
return identNode;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Resolve an Identifier to an ArrayLiteralExpression (recursive).
|
|
309
|
+
* Convenience wrapper over resolveIdentifier().
|
|
310
|
+
*/
|
|
311
|
+
export function resolveIdentifierToArray(node) {
|
|
312
|
+
const resolved = resolveIdentifier(node);
|
|
313
|
+
return resolved && Node.isArrayLiteralExpression(resolved) ? resolved : undefined;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Resolve an Identifier to an ObjectLiteralExpression (recursive).
|
|
317
|
+
* Convenience wrapper over resolveIdentifier().
|
|
318
|
+
*/
|
|
319
|
+
export function resolveIdentifierToObject(node) {
|
|
320
|
+
const resolved = resolveIdentifier(node);
|
|
321
|
+
return resolved && Node.isObjectLiteralExpression(resolved) ? resolved : undefined;
|
|
322
|
+
}
|
|
323
|
+
// =============================================================================
|
|
324
|
+
// 6. IMPORT RESOLUTION
|
|
325
|
+
//
|
|
326
|
+
// Find which source file an imported identifier comes from.
|
|
327
|
+
// =============================================================================
|
|
139
328
|
/**
|
|
140
329
|
* Find the source file path for an imported identifier.
|
|
141
330
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-helpers.js","sourceRoot":"","sources":["../../../src/compiler/utils/ast-helpers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ast-helpers.js","sourceRoot":"","sources":["../../../src/compiler/utils/ast-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,IAAI,EAAoF,MA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ACrF,CAAC;AAED,gFAAgF;AAChF,uBAAuB;AACvB,EAAE;AACF,4DAA4D;AAC5D,gFAAgF;AAEhF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC9B,UAAkB,EAClB,UAAsB,EACtB,iBAAyE;IAEzE,KAAK,MAAM,UAAU,IAAI,UAAU,CAAC,qBAAqB,EAAE,EAAE,CAAC;QAC5D,MAAM,aAAa,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC;QACpD,MAAM,YAAY,GAAG,UAAU,CAAC,eAAe,EAAE,CAAC;QAElD,iEAAiE;QACjE,MAAM,OAAO,GACX,CAAC,aAAa,IAAI,aAAa,CAAC,OAAO,EAAE,KAAK,UAAU,CAAC;YACzD,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,UAAU,CAAC,CAAC;QAE7D,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,iBAAiB,CACtB,UAAU,CAAC,uBAAuB,EAAE,EACpC,UAAU,CAAC,WAAW,EAAE,CACzB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,8DAA8D;IAC9D,OAAO,UAAU,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Constants for the compile command
|
|
3
3
|
*/
|
|
4
|
+
declare class PassthroughPrimitive {
|
|
5
|
+
constructor(config: any);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Map of all lua-cli primitive shims.
|
|
9
|
+
* Single source of truth — add new primitives here.
|
|
10
|
+
*/
|
|
11
|
+
export declare const PRIMITIVE_SHIMS: {
|
|
12
|
+
LuaTool: typeof PassthroughPrimitive;
|
|
13
|
+
LuaSkill: typeof PassthroughPrimitive;
|
|
14
|
+
LuaJob: typeof PassthroughPrimitive;
|
|
15
|
+
LuaWebhook: typeof PassthroughPrimitive;
|
|
16
|
+
PreProcessor: typeof PassthroughPrimitive;
|
|
17
|
+
LuaPreprocessor: typeof PassthroughPrimitive;
|
|
18
|
+
PostProcessor: typeof PassthroughPrimitive;
|
|
19
|
+
LuaPostprocessor: typeof PassthroughPrimitive;
|
|
20
|
+
LuaMCPServer: typeof PassthroughPrimitive;
|
|
21
|
+
defineTool: (config: any) => any;
|
|
22
|
+
defineSkill: (config: any) => any;
|
|
23
|
+
defineJob: (config: any) => any;
|
|
24
|
+
defineWebhook: (config: any) => any;
|
|
25
|
+
definePreProcessor: (config: any) => any;
|
|
26
|
+
definePostProcessor: (config: any) => any;
|
|
27
|
+
defineMCPServer: (config: any) => any;
|
|
28
|
+
};
|
|
4
29
|
/**
|
|
5
30
|
* Directory names used during compilation
|
|
6
31
|
*/
|
|
@@ -46,3 +71,4 @@ export declare const YAML_FORMAT: {
|
|
|
46
71
|
readonly LINE_WIDTH: -1;
|
|
47
72
|
readonly NO_REFS: true;
|
|
48
73
|
};
|
|
74
|
+
export {};
|
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Constants for the compile command
|
|
3
3
|
*/
|
|
4
|
+
// =============================================================================
|
|
5
|
+
// PRIMITIVE SHIMS
|
|
6
|
+
//
|
|
7
|
+
// Passthrough shims for lua-cli primitives (define* functions and Lua* classes).
|
|
8
|
+
// Used in two places:
|
|
9
|
+
// - compiler/utils/ast-helpers.ts: fed to ts-evaluator so it can resolve
|
|
10
|
+
// expressions like `defineTool({name: 'foo'})` at compile time
|
|
11
|
+
// - utils/sandbox.ts: injected into the VM context so bundled code that
|
|
12
|
+
// still references these names at runtime gets a no-op passthrough
|
|
13
|
+
//
|
|
14
|
+
// The define* functions return their config as-is.
|
|
15
|
+
// The Lua* classes assign config properties to `this`.
|
|
16
|
+
// =============================================================================
|
|
17
|
+
class PassthroughPrimitive {
|
|
18
|
+
constructor(config) { Object.assign(this, config); }
|
|
19
|
+
}
|
|
20
|
+
const passthroughDefine = (config) => config;
|
|
21
|
+
/**
|
|
22
|
+
* Map of all lua-cli primitive shims.
|
|
23
|
+
* Single source of truth — add new primitives here.
|
|
24
|
+
*/
|
|
25
|
+
export const PRIMITIVE_SHIMS = {
|
|
26
|
+
// Class-based constructors
|
|
27
|
+
LuaTool: PassthroughPrimitive,
|
|
28
|
+
LuaSkill: PassthroughPrimitive,
|
|
29
|
+
LuaJob: PassthroughPrimitive,
|
|
30
|
+
LuaWebhook: PassthroughPrimitive,
|
|
31
|
+
PreProcessor: PassthroughPrimitive,
|
|
32
|
+
LuaPreprocessor: PassthroughPrimitive,
|
|
33
|
+
PostProcessor: PassthroughPrimitive,
|
|
34
|
+
LuaPostprocessor: PassthroughPrimitive,
|
|
35
|
+
LuaMCPServer: PassthroughPrimitive,
|
|
36
|
+
// Function-based define patterns
|
|
37
|
+
defineTool: passthroughDefine,
|
|
38
|
+
defineSkill: passthroughDefine,
|
|
39
|
+
defineJob: passthroughDefine,
|
|
40
|
+
defineWebhook: passthroughDefine,
|
|
41
|
+
definePreProcessor: passthroughDefine,
|
|
42
|
+
definePostProcessor: passthroughDefine,
|
|
43
|
+
defineMCPServer: passthroughDefine,
|
|
44
|
+
};
|
|
45
|
+
// =============================================================================
|
|
46
|
+
// DIRECTORIES & FILES
|
|
47
|
+
// =============================================================================
|
|
4
48
|
/**
|
|
5
49
|
* Directory names used during compilation
|
|
6
50
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.constants.js","sourceRoot":"","sources":["../../src/config/compile.constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,OAAO;CACN,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,eAAe,EAAE,iBAAiB;IAClC,WAAW,EAAE,aAAa;IAC1B,aAAa,EAAE,eAAe;IAC9B,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,cAAc;IAC5B,aAAa,EAAE,eAAe;IAC9B,cAAc,EAAE,gBAAgB;CACxB,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,EAAE;CACH,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE,CAAC;CACD,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE,CAAC;IACT,UAAU,EAAE,CAAC,CAAC;IACd,OAAO,EAAE,IAAI;CACL,CAAC"}
|
|
1
|
+
{"version":3,"file":"compile.constants.js","sourceRoot":"","sources":["../../src/config/compile.constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,gFAAgF;AAChF,kBAAkB;AAClB,EAAE;AACF,iFAAiF;AACjF,sBAAsB;AACtB,yEAAyE;AACzE,iEAAiE;AACjE,wEAAwE;AACxE,qEAAqE;AACrE,EAAE;AACF,mDAAmD;AACnD,uDAAuD;AACvD,gFAAgF;AAEhF,MAAM,oBAAoB;IAAG,YAAY,MAAW,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;CAAE;AACxF,MAAM,iBAAiB,GAAG,CAAC,MAAW,EAAE,EAAE,CAAC,MAAM,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,2BAA2B;IAC3B,OAAO,EAAE,oBAAoB;IAC7B,QAAQ,EAAE,oBAAoB;IAC9B,MAAM,EAAE,oBAAoB;IAC5B,UAAU,EAAE,oBAAoB;IAChC,YAAY,EAAE,oBAAoB;IAClC,eAAe,EAAE,oBAAoB;IACrC,aAAa,EAAE,oBAAoB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
import { YamlConfig } from '../types/yaml.types.js';
|
|
12
|
-
import type { VersionedPrimitiveHandler, PrimitiveHandler, SyncResult, YamlPrimitiveConfig } from './types.js';
|
|
12
|
+
import type { VersionedPrimitiveHandler, PrimitiveHandler, SyncResult, ServerSyncData, YamlPrimitiveConfig } from './types.js';
|
|
13
13
|
/** Default version for new primitives */
|
|
14
14
|
export declare const DEFAULT_VERSION: "1.0.0";
|
|
15
15
|
/**
|
|
@@ -29,11 +29,33 @@ export declare abstract class BaseVersionedHandler<T extends {
|
|
|
29
29
|
abstract readonly yamlConfig: YamlPrimitiveConfig;
|
|
30
30
|
protected abstract getApi(apiKey: string, agentId: string): unknown;
|
|
31
31
|
protected abstract fetchFromServer(api: unknown): Promise<any[] | null>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Strip a YAML item to only the canonical fields: name, version, [idField].
|
|
34
|
+
* Override if your YAML type has additional fields.
|
|
35
|
+
*/
|
|
36
|
+
cleanItem(item: T): T;
|
|
37
|
+
/**
|
|
38
|
+
* Whether a server entity is considered active (for orphan detection).
|
|
39
|
+
* Default: true. Override for primitives with active/status fields.
|
|
40
|
+
*/
|
|
41
|
+
isActive(_serverItem: any): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Get the active version string from a server entity.
|
|
44
|
+
* Default: finds version with isActive === true. Override for different field names.
|
|
45
|
+
*/
|
|
46
|
+
getActiveVersion(serverItem: any): string | null;
|
|
35
47
|
protected getServerItemName(item: any): string;
|
|
36
48
|
protected shouldConsiderForOrphan(_item: any): boolean;
|
|
49
|
+
/** Phase 1 of parallel sync: fetch server state (HTTP only, no YAML writes) */
|
|
50
|
+
fetchServerState(apiKey: string, agentId: string): Promise<ServerSyncData>;
|
|
51
|
+
/**
|
|
52
|
+
* Phase 2 of parallel sync: apply fetched data to YAML.
|
|
53
|
+
* Optionally creates missing primitives on server if apiKey+agentId provided.
|
|
54
|
+
*/
|
|
55
|
+
applySyncToYaml(serverData: ServerSyncData, config: YamlConfig | null, manifest?: CompilationManifest, apiCredentials?: {
|
|
56
|
+
apiKey: string;
|
|
57
|
+
agentId: string;
|
|
58
|
+
}): Promise<SyncResult>;
|
|
37
59
|
syncWithServer(apiKey: string, agentId: string, config: YamlConfig | null, manifest?: CompilationManifest): Promise<SyncResult>;
|
|
38
60
|
/**
|
|
39
61
|
* Create a primitive on the server. Subclasses must implement this.
|
|
@@ -75,13 +97,26 @@ export declare abstract class BaseVersionedHandler<T extends {
|
|
|
75
97
|
* Get the highest version string from the server for conflict avoidance.
|
|
76
98
|
*/
|
|
77
99
|
getHighestServerVersion(apiKey: string, agentId: string, entityId: string): Promise<string | null>;
|
|
100
|
+
/**
|
|
101
|
+
* Fetch all server items once, extract highest version for each entity ID.
|
|
102
|
+
* More efficient than calling getHighestServerVersion() per entity.
|
|
103
|
+
*/
|
|
104
|
+
batchGetHighestVersions(apiKey: string, agentId: string, entityIds: string[]): Promise<Map<string, string | null>>;
|
|
78
105
|
/** Get the server ID from a YAML item using the configured idField. */
|
|
79
106
|
protected getItemId(item: T): string;
|
|
80
|
-
|
|
107
|
+
protected buildMaps(serverItems: any[], yamlItems: T[]): {
|
|
108
|
+
yamlById: Map<string, T>;
|
|
109
|
+
yamlByName: Map<string, T>;
|
|
110
|
+
serverByName: Map<string, any>;
|
|
111
|
+
};
|
|
81
112
|
/**
|
|
82
113
|
* For each YAML item, match to server by name, populate missing IDs, update versions.
|
|
83
114
|
*/
|
|
84
|
-
|
|
115
|
+
protected syncFromServer(yamlItems: T[], serverByName: Map<string, any>): {
|
|
116
|
+
items: T[];
|
|
117
|
+
changed: boolean;
|
|
118
|
+
msgs: string[];
|
|
119
|
+
};
|
|
85
120
|
}
|
|
86
121
|
/**
|
|
87
122
|
* For primitives without versions (e.g., MCP servers).
|
|
@@ -99,6 +134,10 @@ export declare abstract class BaseNonVersionedHandler<T extends {
|
|
|
99
134
|
abstract cleanItem(item: T): T;
|
|
100
135
|
protected abstract isActive(item: any): boolean;
|
|
101
136
|
protected getServerItemName(item: any): string;
|
|
137
|
+
/** Phase 1 of parallel sync: fetch server state (HTTP only, no YAML writes) */
|
|
138
|
+
fetchServerState(apiKey: string, agentId: string): Promise<ServerSyncData>;
|
|
139
|
+
/** Phase 2 of parallel sync: apply fetched data to YAML (orphan detection only for non-versioned) */
|
|
140
|
+
applySyncToYaml(serverData: ServerSyncData, config: YamlConfig | null, _manifest?: CompilationManifest): Promise<SyncResult>;
|
|
102
141
|
syncWithServer(apiKey: string, agentId: string, config: YamlConfig | null, _manifest?: CompilationManifest): Promise<SyncResult>;
|
|
103
142
|
updateYaml(items: T[], config: YamlConfig | null): void;
|
|
104
143
|
getFromYaml(config: YamlConfig | null): T[];
|