lua-cli 1.3.2-alpha.0 → 1.3.2-alpha.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/commands/compile.js +227 -165
- package/dist/commands/dev.js +117 -114
- package/dist/commands/test.js +122 -130
- package/dist/services/api.d.ts +4 -4
- package/dist/services/api.js +8 -4
- package/dist/skill.d.ts +16 -1
- package/dist/skill.js +49 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/user-data-api.d.ts +1 -0
- package/dist/user-data-api.js +9 -4
- package/dist/utils/files.js +33 -5
- package/dist/utils/sandbox.d.ts +96 -0
- package/dist/utils/sandbox.js +161 -0
- package/dist/web/app.css +274 -43
- package/dist/web/app.js +13 -13
- package/dist/web/tools-page.css +70 -53
- package/package.json +1 -1
- package/template/lua.skill.yaml +16 -0
- package/template/package-lock.json +9 -1
- package/template/package.json +3 -3
- package/template/src/index.ts +3 -13
- package/template/src/tools/CreatePostTool.ts +15 -23
- package/template/src/tools/GetWeatherTool.ts +22 -23
- package/template/src/tools/UserDataTool.ts +56 -0
- package/template/src/services/MathService.ts +0 -61
- package/template/src/tools/AdvancedMathTool.ts +0 -82
- package/template/src/tools/CalculatorTool.ts +0 -65
- package/template/src/tools/GetUserDataTool.ts +0 -38
- package/template/tools/UserPreferencesTool.ts +0 -73
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// Example: Simple Calculator Tool
|
|
2
|
-
import { LuaTool } from "lua-cli/skill";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
|
|
5
|
-
// Define schemas as static properties for Lua CLI detection
|
|
6
|
-
const inputSchema = z.object({
|
|
7
|
-
operation: z.enum(["add", "subtract", "multiply", "divide"]).describe("Mathematical operation"),
|
|
8
|
-
a: z.number().describe("First number"),
|
|
9
|
-
b: z.number().describe("Second number")
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
const outputSchema = z.object({
|
|
13
|
-
result: z.number(),
|
|
14
|
-
operation: z.string(),
|
|
15
|
-
expression: z.string()
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export default class CalculatorTool implements LuaTool<typeof inputSchema, typeof outputSchema> {
|
|
19
|
-
name: string;
|
|
20
|
-
description: string;
|
|
21
|
-
inputSchema: typeof inputSchema;
|
|
22
|
-
outputSchema: typeof outputSchema;
|
|
23
|
-
|
|
24
|
-
constructor() {
|
|
25
|
-
this.name = "calculator";
|
|
26
|
-
this.description = "Perform basic mathematical operations";
|
|
27
|
-
this.inputSchema = inputSchema;
|
|
28
|
-
this.outputSchema = outputSchema;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async execute(input: z.infer<typeof inputSchema>) {
|
|
32
|
-
let result: number;
|
|
33
|
-
let expression: string;
|
|
34
|
-
|
|
35
|
-
switch (input.operation) {
|
|
36
|
-
case "add":
|
|
37
|
-
result = input.a + input.b;
|
|
38
|
-
expression = `${input.a} + ${input.b}`;
|
|
39
|
-
break;
|
|
40
|
-
case "subtract":
|
|
41
|
-
result = input.a - input.b;
|
|
42
|
-
expression = `${input.a} - ${input.b}`;
|
|
43
|
-
break;
|
|
44
|
-
case "multiply":
|
|
45
|
-
result = input.a * input.b;
|
|
46
|
-
expression = `${input.a} × ${input.b}`;
|
|
47
|
-
break;
|
|
48
|
-
case "divide":
|
|
49
|
-
if (input.b === 0) {
|
|
50
|
-
throw new Error("Division by zero is not allowed");
|
|
51
|
-
}
|
|
52
|
-
result = input.a / input.b;
|
|
53
|
-
expression = `${input.a} ÷ ${input.b}`;
|
|
54
|
-
break;
|
|
55
|
-
default:
|
|
56
|
-
throw new Error(`Unknown operation: ${input.operation}`);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
result,
|
|
61
|
-
operation: input.operation,
|
|
62
|
-
expression
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { LuaTool } from "lua-cli/skill";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import ApiService from "../services/ApiService";
|
|
4
|
-
|
|
5
|
-
// Define schemas as static properties for Lua CLI detection
|
|
6
|
-
const inputSchema = z.object({
|
|
7
|
-
userId: z.string()
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
const outputSchema = z.object({
|
|
11
|
-
id: z.string(),
|
|
12
|
-
name: z.string(),
|
|
13
|
-
url: z.string().nullable(),
|
|
14
|
-
status: z.string(),
|
|
15
|
-
error: z.string().optional(),
|
|
16
|
-
timestamp: z.string()
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export default class GetUserDataTool implements LuaTool<typeof inputSchema, typeof outputSchema> {
|
|
20
|
-
name: string;
|
|
21
|
-
description: string;
|
|
22
|
-
inputSchema: typeof inputSchema;
|
|
23
|
-
outputSchema: typeof outputSchema;
|
|
24
|
-
|
|
25
|
-
apiService: ApiService;
|
|
26
|
-
|
|
27
|
-
constructor() {
|
|
28
|
-
this.name = "get_user_data";
|
|
29
|
-
this.description = "Get the user data for a given user id";
|
|
30
|
-
this.inputSchema = inputSchema;
|
|
31
|
-
this.outputSchema = outputSchema;
|
|
32
|
-
this.apiService = new ApiService();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async execute(input: z.infer<typeof inputSchema>) {
|
|
36
|
-
return this.apiService.fetchUserData(input.userId);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { LuaTool } from 'lua-cli/skill';
|
|
2
|
-
import { user } from 'lua-cli/user-data-api';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Example tool demonstrating User Data API usage
|
|
7
|
-
* This tool allows users to manage their preferences
|
|
8
|
-
*/
|
|
9
|
-
export class UserPreferencesTool extends LuaTool {
|
|
10
|
-
constructor() {
|
|
11
|
-
super('user-preferences', 'Manage user preferences and settings');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async execute(input: { action: string; key?: string; value?: string }) {
|
|
15
|
-
const { action, key, value } = input;
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
switch (action) {
|
|
19
|
-
case 'get':
|
|
20
|
-
const userData = await user.data.get();
|
|
21
|
-
return {
|
|
22
|
-
success: true,
|
|
23
|
-
preferences: userData.preferences || {},
|
|
24
|
-
message: 'Preferences retrieved successfully'
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
case 'set':
|
|
28
|
-
if (!key || !value) {
|
|
29
|
-
throw new Error('Key and value are required for set action');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const currentData = await user.data.get();
|
|
33
|
-
const updatedData = {
|
|
34
|
-
...currentData,
|
|
35
|
-
preferences: {
|
|
36
|
-
...currentData.preferences,
|
|
37
|
-
[key]: value
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
await user.data.update(updatedData);
|
|
42
|
-
return {
|
|
43
|
-
success: true,
|
|
44
|
-
message: `Set ${key} to ${value}`,
|
|
45
|
-
preferences: updatedData.preferences
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
case 'clear':
|
|
49
|
-
await user.data.clear();
|
|
50
|
-
return {
|
|
51
|
-
success: true,
|
|
52
|
-
message: 'All preferences cleared'
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
default:
|
|
56
|
-
throw new Error('Invalid action. Use: get, set, or clear');
|
|
57
|
-
}
|
|
58
|
-
} catch (error) {
|
|
59
|
-
return {
|
|
60
|
-
success: false,
|
|
61
|
-
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
getInputSchema() {
|
|
67
|
-
return z.object({
|
|
68
|
-
action: z.enum(['get', 'set', 'clear']).describe('Action to perform: get (retrieve preferences), set (update a preference), or clear (remove all preferences)'),
|
|
69
|
-
key: z.string().optional().describe('Preference key (required for set action)'),
|
|
70
|
-
value: z.string().optional().describe('Preference value (required for set action)')
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|