lua-cli 1.1.4-beta.2 โ 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/README.md +183 -8
- package/dist/commands/deploy.js +69 -10
- package/dist/commands/test.js +62 -11
- package/dist/skill.d.ts +1 -2
- package/dist/skill.js +1 -2
- package/package.json +8 -3
- package/template/.lua/deploy.json +53 -3
- package/template/API.md +604 -0
- package/template/DEVELOPER.md +771 -0
- package/template/QUICKSTART.md +170 -0
- package/template/README.md +477 -0
- package/template/index.ts +40 -16
- package/template/services/GetWeather.ts +35 -3
- package/template/services/MathService.ts +61 -0
- package/template/tools/AdvancedMathTool.ts +82 -0
- package/template/tools/CalculatorTool.ts +65 -0
- package/template/tools/CreatePostTool.ts +15 -3
- package/template/tools/GetUserDataTool.ts +15 -3
- package/template/tools/GetWeatherTool.ts +18 -5
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,38 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.2.0] - 2024-09-19
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Tool Development Framework**: Complete LuaSkill and LuaTool framework for building custom tools
|
|
12
|
+
- **Dependency Bundling**: Automatic bundling of npm packages using esbuild
|
|
13
|
+
- **Interactive Testing**: Real-time tool testing with `lua test` command
|
|
14
|
+
- **Code Compression**: Gzip compression for efficient storage of bundled code
|
|
15
|
+
- **In-Memory Execution**: VM-based execution without temporary files
|
|
16
|
+
- **Comprehensive Documentation**: Complete guides, API reference, and examples
|
|
17
|
+
- **Template System**: Rich template with 5 example tools and services
|
|
18
|
+
- **TypeScript Support**: Full TypeScript integration with Zod validation
|
|
19
|
+
- **Error Handling**: Robust error handling and validation throughout
|
|
20
|
+
- **Performance Optimization**: Optimized bundling and execution
|
|
21
|
+
|
|
22
|
+
### New Commands
|
|
23
|
+
- **`lua compile`**: Bundle dependencies and compile LuaSkills
|
|
24
|
+
- **`lua test`**: Interactive testing interface for tools
|
|
25
|
+
- **`lua deploy`**: Deploy compiled skills to the Lua platform
|
|
26
|
+
|
|
27
|
+
### Technical Improvements
|
|
28
|
+
- **esbuild Integration**: Fast bundling of external dependencies
|
|
29
|
+
- **VM Context**: Secure in-memory execution environment
|
|
30
|
+
- **Schema Validation**: Zod-based input/output validation
|
|
31
|
+
- **Service Architecture**: Reusable service components
|
|
32
|
+
- **Template Examples**: Calculator, Math, Weather, API, and File operation tools
|
|
33
|
+
- **Documentation Suite**: README, Developer Guide, API Reference, and Quick Start
|
|
34
|
+
|
|
35
|
+
### Security
|
|
36
|
+
- **Sandboxed Execution**: Tools run in isolated VM contexts
|
|
37
|
+
- **Input Validation**: Comprehensive Zod schema validation
|
|
38
|
+
- **Error Isolation**: Proper error handling prevents crashes
|
|
39
|
+
|
|
8
40
|
## [1.1.0] - 2024-01-XX
|
|
9
41
|
|
|
10
42
|
### Added
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Lua CLI
|
|
2
2
|
|
|
3
|
-
A command-line interface for the Lua AI platform that helps you
|
|
3
|
+
A powerful command-line interface for the Lua AI platform that helps you develop, test, and deploy LuaSkills with custom tools.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -22,8 +22,12 @@ lua --help
|
|
|
22
22
|
- ๐ข **Organization Management**: Select and manage multiple organizations
|
|
23
23
|
- ๐ค **Agent Management**: Choose from available agents within your organizations
|
|
24
24
|
- ๐ ๏ธ **Skill Development**: Initialize new Lua skills with proper configuration
|
|
25
|
+
- ๐ง **Tool Development**: Create custom tools with TypeScript and Zod validation
|
|
26
|
+
- ๐ฆ **Dependency Bundling**: Automatic bundling of npm packages using esbuild
|
|
27
|
+
- ๐งช **Interactive Testing**: Test your tools with real-time execution
|
|
28
|
+
- ๐ **Deployment**: Compile and deploy skills to the Lua platform
|
|
25
29
|
- ๐ **API Key Management**: Securely store, view, and manage your API keys
|
|
26
|
-
-
|
|
30
|
+
- ๐ **Comprehensive Documentation**: Complete guides and examples
|
|
27
31
|
|
|
28
32
|
## Quick Start
|
|
29
33
|
|
|
@@ -39,20 +43,29 @@ lua --help
|
|
|
39
43
|
```
|
|
40
44
|
Select your organization and agent, then provide skill details.
|
|
41
45
|
|
|
42
|
-
3. **
|
|
46
|
+
3. **Develop your tools:**
|
|
43
47
|
```bash
|
|
44
|
-
|
|
48
|
+
# Create tools in the tools/ directory
|
|
49
|
+
# See template/README.md for examples
|
|
45
50
|
```
|
|
46
51
|
|
|
47
|
-
4. **
|
|
52
|
+
4. **Compile your skill:**
|
|
48
53
|
```bash
|
|
49
|
-
lua
|
|
54
|
+
lua compile
|
|
50
55
|
```
|
|
56
|
+
Bundles dependencies and creates deployable files.
|
|
51
57
|
|
|
52
|
-
5. **
|
|
58
|
+
5. **Test your tools:**
|
|
53
59
|
```bash
|
|
54
|
-
lua
|
|
60
|
+
lua test
|
|
55
61
|
```
|
|
62
|
+
Interactive testing interface for your tools.
|
|
63
|
+
|
|
64
|
+
6. **Deploy your skill:**
|
|
65
|
+
```bash
|
|
66
|
+
lua deploy
|
|
67
|
+
```
|
|
68
|
+
Deploy to the Lua platform.
|
|
56
69
|
|
|
57
70
|
## Commands
|
|
58
71
|
|
|
@@ -107,6 +120,109 @@ Delete your stored API key and credentials.
|
|
|
107
120
|
lua destroy
|
|
108
121
|
```
|
|
109
122
|
|
|
123
|
+
### `lua compile`
|
|
124
|
+
|
|
125
|
+
Compile your LuaSkill and bundle all dependencies.
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
lua compile
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
This command will:
|
|
132
|
+
- Scan your tools for imports and dependencies
|
|
133
|
+
- Bundle external packages using esbuild
|
|
134
|
+
- Compress the generated code for efficient storage
|
|
135
|
+
- Create `.lua/deploy.json` with compiled skill data
|
|
136
|
+
- Generate individual tool files in `.lua/` directory
|
|
137
|
+
|
|
138
|
+
**Options:**
|
|
139
|
+
- `--watch` - Watch for changes and recompile automatically
|
|
140
|
+
- `--minify` - Minify the bundled code
|
|
141
|
+
|
|
142
|
+
### `lua test`
|
|
143
|
+
|
|
144
|
+
Interactive testing interface for your tools.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
lua test
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Features:
|
|
151
|
+
- Tool selection menu
|
|
152
|
+
- Input validation with Zod schemas
|
|
153
|
+
- Real-time execution in isolated VM context
|
|
154
|
+
- Error reporting and debugging
|
|
155
|
+
- Mock data support
|
|
156
|
+
|
|
157
|
+
### `lua deploy`
|
|
158
|
+
|
|
159
|
+
Deploy your compiled skill to the Lua platform.
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
lua deploy
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Requirements:**
|
|
166
|
+
- Valid API key (configured with `lua configure`)
|
|
167
|
+
- Compiled skill (run `lua compile` first)
|
|
168
|
+
- Active internet connection
|
|
169
|
+
|
|
170
|
+
**Output:**
|
|
171
|
+
- Skill deployed to your selected agent
|
|
172
|
+
- Deployment confirmation and status
|
|
173
|
+
|
|
174
|
+
## Template System
|
|
175
|
+
|
|
176
|
+
The Lua CLI includes a comprehensive template system with examples and documentation:
|
|
177
|
+
|
|
178
|
+
### Template Structure
|
|
179
|
+
```
|
|
180
|
+
template/
|
|
181
|
+
โโโ README.md # Complete user guide
|
|
182
|
+
โโโ DEVELOPER.md # Technical documentation
|
|
183
|
+
โโโ API.md # API reference
|
|
184
|
+
โโโ QUICKSTART.md # Quick start guide
|
|
185
|
+
โโโ tools/ # Example tools
|
|
186
|
+
โ โโโ GetWeatherTool.ts
|
|
187
|
+
โ โโโ GetUserDataTool.ts
|
|
188
|
+
โ โโโ CreatePostTool.ts
|
|
189
|
+
โ โโโ CalculatorTool.ts
|
|
190
|
+
โ โโโ AdvancedMathTool.ts
|
|
191
|
+
โโโ services/ # Example services
|
|
192
|
+
โ โโโ ApiService.ts
|
|
193
|
+
โ โโโ GetWeather.ts
|
|
194
|
+
โ โโโ MathService.ts
|
|
195
|
+
โโโ index.ts # Main skill definition
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Getting Started with Templates
|
|
199
|
+
|
|
200
|
+
1. **Copy the template:**
|
|
201
|
+
```bash
|
|
202
|
+
cp -r template/ my-skill/
|
|
203
|
+
cd my-skill
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
2. **Install dependencies:**
|
|
207
|
+
```bash
|
|
208
|
+
npm install
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
3. **Read the documentation:**
|
|
212
|
+
```bash
|
|
213
|
+
# Start with the quick start guide
|
|
214
|
+
cat QUICKSTART.md
|
|
215
|
+
|
|
216
|
+
# Then read the full documentation
|
|
217
|
+
cat README.md
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
4. **Create your tools:**
|
|
221
|
+
```bash
|
|
222
|
+
# Modify existing tools or create new ones
|
|
223
|
+
# See tools/ directory for examples
|
|
224
|
+
```
|
|
225
|
+
|
|
110
226
|
## Configuration File
|
|
111
227
|
|
|
112
228
|
The `lua.skill.toml` file is created when you run `lua init`:
|
|
@@ -146,10 +262,57 @@ description = "Description of your skill"
|
|
|
146
262
|
- Confirmation prompts prevent accidental exposure of sensitive information
|
|
147
263
|
- No credentials are stored in plain text
|
|
148
264
|
|
|
265
|
+
## Development Workflow
|
|
266
|
+
|
|
267
|
+
### 1. Project Setup
|
|
268
|
+
```bash
|
|
269
|
+
# Initialize a new skill project
|
|
270
|
+
lua init
|
|
271
|
+
|
|
272
|
+
# Or copy the template
|
|
273
|
+
cp -r template/ my-skill/
|
|
274
|
+
cd my-skill
|
|
275
|
+
npm install
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### 2. Tool Development
|
|
279
|
+
```bash
|
|
280
|
+
# Create tools in tools/ directory
|
|
281
|
+
# Use TypeScript with Zod validation
|
|
282
|
+
# See template/tools/ for examples
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### 3. Testing
|
|
286
|
+
```bash
|
|
287
|
+
# Compile your skill
|
|
288
|
+
lua compile
|
|
289
|
+
|
|
290
|
+
# Test your tools interactively
|
|
291
|
+
lua test
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### 4. Deployment
|
|
295
|
+
```bash
|
|
296
|
+
# Deploy to Lua platform
|
|
297
|
+
lua deploy
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### 5. Iteration
|
|
301
|
+
```bash
|
|
302
|
+
# Make changes to your tools
|
|
303
|
+
# Recompile and test
|
|
304
|
+
lua compile && lua test
|
|
305
|
+
|
|
306
|
+
# Deploy updates
|
|
307
|
+
lua deploy
|
|
308
|
+
```
|
|
309
|
+
|
|
149
310
|
## Requirements
|
|
150
311
|
|
|
151
312
|
- Node.js 16.0.0 or higher
|
|
152
313
|
- Valid Lua AI platform account
|
|
314
|
+
- TypeScript knowledge (for tool development)
|
|
315
|
+
- Basic understanding of Zod schemas
|
|
153
316
|
|
|
154
317
|
## Development
|
|
155
318
|
|
|
@@ -174,6 +337,18 @@ For support and questions:
|
|
|
174
337
|
|
|
175
338
|
## Changelog
|
|
176
339
|
|
|
340
|
+
### 1.2.0
|
|
341
|
+
- **Tool Development Framework**: Complete LuaSkill and LuaTool framework
|
|
342
|
+
- **Dependency Bundling**: Automatic bundling of npm packages using esbuild
|
|
343
|
+
- **Interactive Testing**: Real-time tool testing with `lua test` command
|
|
344
|
+
- **Code Compression**: Gzip compression for efficient storage
|
|
345
|
+
- **In-Memory Execution**: VM-based execution without temporary files
|
|
346
|
+
- **Comprehensive Documentation**: Complete guides, API reference, and examples
|
|
347
|
+
- **Template System**: Rich template with 5 example tools and services
|
|
348
|
+
- **TypeScript Support**: Full TypeScript integration with Zod validation
|
|
349
|
+
- **Error Handling**: Robust error handling and validation
|
|
350
|
+
- **Performance Optimization**: Optimized bundling and execution
|
|
351
|
+
|
|
177
352
|
### 1.1.0
|
|
178
353
|
- **Major Refactoring**: Complete codebase reorganization into modular structure
|
|
179
354
|
- **Email Authentication**: Added OTP-based email authentication
|
package/dist/commands/deploy.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { gzipSync, gunzipSync } from "zlib";
|
|
4
|
+
import { Buffer } from "buffer";
|
|
5
|
+
// Compression utilities
|
|
6
|
+
function compressCode(code) {
|
|
7
|
+
const compressed = gzipSync(code);
|
|
8
|
+
return compressed.toString('base64');
|
|
9
|
+
}
|
|
10
|
+
function decompressCode(compressedCode) {
|
|
11
|
+
const buffer = Buffer.from(compressedCode, 'base64');
|
|
12
|
+
return gunzipSync(buffer).toString('utf8');
|
|
13
|
+
}
|
|
3
14
|
export async function deployCommand() {
|
|
4
15
|
try {
|
|
5
16
|
console.log("๐จ Compiling Lua skill...");
|
|
@@ -19,11 +30,14 @@ export async function deployCommand() {
|
|
|
19
30
|
const indexContent = fs.readFileSync(indexPath, "utf8");
|
|
20
31
|
// Extract skill information
|
|
21
32
|
const skillInfo = await extractSkillInfo(indexContent);
|
|
22
|
-
// Create deployment data
|
|
33
|
+
// Create deployment data with compressed execute code
|
|
23
34
|
const deployData = {
|
|
24
35
|
version,
|
|
25
36
|
skillsName,
|
|
26
|
-
tools: skillInfo
|
|
37
|
+
tools: skillInfo.map(tool => ({
|
|
38
|
+
...tool,
|
|
39
|
+
execute: compressCode(tool.execute)
|
|
40
|
+
}))
|
|
27
41
|
};
|
|
28
42
|
// Create .lua directory
|
|
29
43
|
const luaDir = path.join(process.cwd(), ".lua");
|
|
@@ -323,8 +337,8 @@ async function bundlePackageCode(packagePath, namedImports, defaultImport) {
|
|
|
323
337
|
if (!fs.existsSync(luaDir)) {
|
|
324
338
|
fs.mkdirSync(luaDir, { recursive: true });
|
|
325
339
|
}
|
|
326
|
-
const entryFile = path.join(luaDir, `${packagePath}-entry.
|
|
327
|
-
const outputFile = path.join(luaDir, `${packagePath}-bundle.
|
|
340
|
+
const entryFile = path.join(luaDir, `${packagePath}-entry.cjs`);
|
|
341
|
+
const outputFile = path.join(luaDir, `${packagePath}-bundle.cjs`);
|
|
328
342
|
// Create entry file based on import type
|
|
329
343
|
let entryContent = '';
|
|
330
344
|
if (defaultImport) {
|
|
@@ -629,21 +643,66 @@ async function createClassBasedExecute(executeBody, toolContent, className) {
|
|
|
629
643
|
}
|
|
630
644
|
continue;
|
|
631
645
|
}
|
|
632
|
-
// Handle axios
|
|
646
|
+
// Handle axios - bundle it properly
|
|
633
647
|
if (packagePath === 'axios') {
|
|
634
|
-
|
|
648
|
+
const packageCode = await bundlePackageCode(packagePath, namedImports, defaultImport);
|
|
649
|
+
if (packageCode) {
|
|
650
|
+
bundledPackages.add(packageCode);
|
|
651
|
+
}
|
|
635
652
|
continue;
|
|
636
653
|
}
|
|
637
654
|
// Handle local service imports
|
|
638
655
|
if (packagePath.startsWith('./') || packagePath.startsWith('../')) {
|
|
639
656
|
// The tool files are in tools/ subdirectory, so we need to resolve from there
|
|
640
657
|
const toolDir = path.join(process.cwd(), 'tools');
|
|
641
|
-
|
|
658
|
+
// Resolve the service file path correctly
|
|
659
|
+
// If the import is ../services/ApiService, resolve it relative to the tools directory
|
|
660
|
+
const serviceFilePath = path.resolve(process.cwd(), 'tools', packagePath + '.ts');
|
|
642
661
|
if (fs.existsSync(serviceFilePath)) {
|
|
643
662
|
const serviceContent = fs.readFileSync(serviceFilePath, 'utf8');
|
|
644
|
-
//
|
|
645
|
-
|
|
646
|
-
|
|
663
|
+
// Process all imports in the service file
|
|
664
|
+
const serviceImportRegex = /import\s+(?:(?:\{([^}]+)\})|(\w+))\s+from\s+["']([^"']+)["']/g;
|
|
665
|
+
let serviceImportMatch;
|
|
666
|
+
while ((serviceImportMatch = serviceImportRegex.exec(serviceContent)) !== null) {
|
|
667
|
+
const namedImports = serviceImportMatch[1];
|
|
668
|
+
const defaultImport = serviceImportMatch[2];
|
|
669
|
+
const packagePath = serviceImportMatch[3];
|
|
670
|
+
// Skip lua-cli imports
|
|
671
|
+
if (packagePath.startsWith('lua-cli')) {
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
// Handle zod
|
|
675
|
+
if (packagePath === 'zod') {
|
|
676
|
+
if (namedImports) {
|
|
677
|
+
const importsList = namedImports.split(',').map(imp => imp.trim());
|
|
678
|
+
const usedImports = importsList.filter(imp => serviceContent.includes(`${imp}.`));
|
|
679
|
+
if (usedImports.length > 0) {
|
|
680
|
+
const requireStatement = usedImports.length === 1
|
|
681
|
+
? `const { ${usedImports[0]} } = require('zod');`
|
|
682
|
+
: `const { ${usedImports.join(', ')} } = require('zod');`;
|
|
683
|
+
bundledPackages.add(requireStatement);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
else if (defaultImport) {
|
|
687
|
+
bundledPackages.add(`const ${defaultImport} = require('zod');`);
|
|
688
|
+
}
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
// Handle axios - bundle it properly
|
|
692
|
+
if (packagePath === 'axios') {
|
|
693
|
+
const packageCode = await bundlePackageCode(packagePath, namedImports, defaultImport);
|
|
694
|
+
if (packageCode) {
|
|
695
|
+
bundledPackages.add(packageCode);
|
|
696
|
+
}
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
699
|
+
// Bundle other external packages
|
|
700
|
+
if (namedImports || defaultImport) {
|
|
701
|
+
const packageCode = await bundlePackageCode(packagePath, namedImports, defaultImport);
|
|
702
|
+
if (packageCode) {
|
|
703
|
+
bundledPackages.add(packageCode);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
647
706
|
}
|
|
648
707
|
// Extract the service class with proper brace matching
|
|
649
708
|
const classRegex = /class\s+(\w+)(?:\s+extends\s+\w+)?\s*\{/g;
|
package/dist/commands/test.js
CHANGED
|
@@ -2,6 +2,15 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import inquirer from "inquirer";
|
|
4
4
|
import { deployCommand } from "./deploy.js";
|
|
5
|
+
import { gunzipSync } from "zlib";
|
|
6
|
+
import { Buffer } from "buffer";
|
|
7
|
+
import { createRequire } from "module";
|
|
8
|
+
import vm from "vm";
|
|
9
|
+
// Decompression utility
|
|
10
|
+
function decompressCode(compressedCode) {
|
|
11
|
+
const buffer = Buffer.from(compressedCode, 'base64');
|
|
12
|
+
return gunzipSync(buffer).toString('utf8');
|
|
13
|
+
}
|
|
5
14
|
export async function testCommand() {
|
|
6
15
|
try {
|
|
7
16
|
console.log("๐งช Testing Lua skill...");
|
|
@@ -101,12 +110,56 @@ export async function testCommand() {
|
|
|
101
110
|
}
|
|
102
111
|
console.log("\n๐ Executing tool...");
|
|
103
112
|
console.log(`Input: ${JSON.stringify(inputValues, null, 2)}`);
|
|
104
|
-
// Get the execute function string directly from the selected tool
|
|
105
|
-
const toolCode = selectedTool.execute;
|
|
113
|
+
// Get the execute function string directly from the selected tool and decompress it
|
|
114
|
+
const toolCode = decompressCode(selectedTool.execute);
|
|
106
115
|
// Execute the tool
|
|
107
116
|
try {
|
|
108
|
-
// Create a
|
|
109
|
-
const
|
|
117
|
+
// Create a CommonJS context for execution
|
|
118
|
+
const require = createRequire(process.cwd() + '/package.json');
|
|
119
|
+
// Create a sandbox context with require and other necessary globals
|
|
120
|
+
const sandbox = {
|
|
121
|
+
require,
|
|
122
|
+
console,
|
|
123
|
+
Buffer,
|
|
124
|
+
setTimeout,
|
|
125
|
+
setInterval,
|
|
126
|
+
clearTimeout,
|
|
127
|
+
clearInterval,
|
|
128
|
+
process,
|
|
129
|
+
global: globalThis,
|
|
130
|
+
__dirname: process.cwd(),
|
|
131
|
+
__filename: path.join(process.cwd(), 'index.ts'),
|
|
132
|
+
module: { exports: {} },
|
|
133
|
+
exports: {},
|
|
134
|
+
// Web APIs
|
|
135
|
+
fetch: globalThis.fetch,
|
|
136
|
+
URLSearchParams: globalThis.URLSearchParams,
|
|
137
|
+
URL: globalThis.URL,
|
|
138
|
+
Headers: globalThis.Headers,
|
|
139
|
+
Request: globalThis.Request,
|
|
140
|
+
Response: globalThis.Response,
|
|
141
|
+
// Additional Node.js globals that might be needed
|
|
142
|
+
Object,
|
|
143
|
+
Array,
|
|
144
|
+
String,
|
|
145
|
+
Number,
|
|
146
|
+
Boolean,
|
|
147
|
+
Date,
|
|
148
|
+
Math,
|
|
149
|
+
JSON,
|
|
150
|
+
Error,
|
|
151
|
+
TypeError,
|
|
152
|
+
ReferenceError,
|
|
153
|
+
SyntaxError,
|
|
154
|
+
// Node.js specific globals
|
|
155
|
+
globalThis,
|
|
156
|
+
// Additional globals that might be referenced
|
|
157
|
+
undefined: undefined,
|
|
158
|
+
null: null,
|
|
159
|
+
Infinity: Infinity,
|
|
160
|
+
NaN: NaN
|
|
161
|
+
};
|
|
162
|
+
// Create the CommonJS wrapper code
|
|
110
163
|
const commonJsWrapper = `
|
|
111
164
|
const executeFunction = ${toolCode};
|
|
112
165
|
|
|
@@ -115,14 +168,12 @@ module.exports = async (input) => {
|
|
|
115
168
|
return await executeFunction(input);
|
|
116
169
|
};
|
|
117
170
|
`;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const executeFunction =
|
|
171
|
+
// Execute the code in the sandbox
|
|
172
|
+
const context = vm.createContext(sandbox);
|
|
173
|
+
vm.runInContext(commonJsWrapper, context);
|
|
174
|
+
// Get the exported function
|
|
175
|
+
const executeFunction = context.module.exports;
|
|
123
176
|
const result = await executeFunction(inputValues);
|
|
124
|
-
// Clean up temp file
|
|
125
|
-
fs.unlinkSync(tempFile);
|
|
126
177
|
console.log("\nโ
Tool execution successful!");
|
|
127
178
|
console.log(`Output: ${JSON.stringify(result, null, 2)}`);
|
|
128
179
|
}
|
package/dist/skill.d.ts
CHANGED
|
@@ -2,9 +2,8 @@ import { ZodType } from "zod";
|
|
|
2
2
|
import { LuaTool } from "./types/index.js";
|
|
3
3
|
export { LuaTool };
|
|
4
4
|
export declare class LuaSkill {
|
|
5
|
-
private readonly apiKey;
|
|
6
5
|
private readonly tools;
|
|
7
|
-
constructor(
|
|
6
|
+
constructor();
|
|
8
7
|
addTool<TInput extends ZodType, TOutput extends ZodType>(tool: LuaTool<TInput, TOutput>): void;
|
|
9
8
|
run(input: Record<string, any>): Promise<any>;
|
|
10
9
|
}
|
package/dist/skill.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lua-cli",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Command-line interface for Lua AI platform -
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Command-line interface for Lua AI platform - develop, test, and deploy LuaSkills with custom tools",
|
|
5
5
|
"readmeFilename": "README.md",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -25,7 +25,12 @@
|
|
|
25
25
|
"automation",
|
|
26
26
|
"agents",
|
|
27
27
|
"api",
|
|
28
|
-
"typescript"
|
|
28
|
+
"typescript",
|
|
29
|
+
"tools",
|
|
30
|
+
"bundling",
|
|
31
|
+
"testing",
|
|
32
|
+
"deployment",
|
|
33
|
+
"skills"
|
|
29
34
|
],
|
|
30
35
|
"author": "Stefan Kruger <stefan@heylua.ai>",
|
|
31
36
|
"license": "MIT",
|