lua-cli 2.1.0 → 2.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/dist/commands/compile.js +42 -2
- package/dist/custom-data-api.d.ts +72 -0
- package/dist/custom-data-api.js +174 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/product-api.d.ts +141 -0
- package/dist/product-api.js +81 -1
- package/dist/services/api.d.ts +268 -0
- package/dist/services/api.js +268 -0
- package/dist/utils/sandbox.js +78 -6
- package/dist/web/app.css +58 -4
- package/dist/web/app.js +13 -13
- package/dist/web/index.html +2 -1
- package/package.json +3 -2
- package/template/lua.skill.yaml +14 -2
- package/template/package.json +1 -1
- package/template/src/index.ts +27 -2
- package/template/src/tools/CustomDataTool.ts +116 -0
- package/template/src/tools/ProductsTool.ts +117 -2
package/dist/web/index.html
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<
|
|
6
|
+
<meta name="description" content="Lua Developer Console - Build, test, and deploy AI agents">
|
|
7
|
+
<title>Lua Developer Console</title>
|
|
7
8
|
<link rel="stylesheet" href="/app.css">
|
|
8
9
|
<link rel="stylesheet" href="/tools-page.css">
|
|
9
10
|
</head>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lua-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
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",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"./types": "./dist/types.js",
|
|
10
10
|
"./skill": "./dist/skill.js",
|
|
11
11
|
"./user-data-api": "./dist/user-data-api.js",
|
|
12
|
-
"./product-api": "./dist/product-api.js"
|
|
12
|
+
"./product-api": "./dist/product-api.js",
|
|
13
|
+
"./custom-data-api": "./dist/custom-data-api.js"
|
|
13
14
|
},
|
|
14
15
|
"scripts": {
|
|
15
16
|
"clean": "rm -rf dist",
|
package/template/lua.skill.yaml
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
agent:
|
|
2
|
-
agentId:
|
|
3
|
-
orgId:
|
|
2
|
+
agentId: liteAPI_lp1a010
|
|
3
|
+
orgId: 2e7fcabb-7616-4b8d-9114-b6ac121aefe5
|
|
4
4
|
skills:
|
|
5
|
+
- name: general-skill
|
|
6
|
+
version: 0.0.2
|
|
7
|
+
skillId: 0ada138d-9155-40fd-bda4-06b51e69e78c
|
|
8
|
+
- name: user-data-skill
|
|
9
|
+
version: 0.0.1
|
|
10
|
+
skillId: b551177b-aa50-42bb-9b2f-52249db9ca67
|
|
11
|
+
- name: eccomerce-skill
|
|
12
|
+
version: 0.0.1
|
|
13
|
+
skillId: b8c9b6ad-0c3c-4bac-b182-94f19f4c062d
|
|
14
|
+
- name: custom-data-skill
|
|
15
|
+
version: 0.0.1
|
|
16
|
+
skillId: bcffdbdb-4a85-4603-9ddd-2f58e743fbd2
|
package/template/package.json
CHANGED
package/template/src/index.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { LuaSkill } from "lua-cli/skill";
|
|
|
2
2
|
import GetWeatherTool from "./tools/GetWeatherTool";
|
|
3
3
|
import { GetUserDataTool, CreateUserDataTool, UpdateUserDataTool } from "./tools/UserDataTool";
|
|
4
4
|
import CreatePostTool from "./tools/CreatePostTool";
|
|
5
|
-
import { SearchProductsTool, GetAllProductsTool, CreateProductTool, UpdateProductTool, DeleteProductTool } from "./tools/ProductsTool";
|
|
5
|
+
import { SearchProductsTool, GetAllProductsTool, CreateProductTool, UpdateProductTool, DeleteProductTool, AddItemToBasketTool, RemoveItemFromBasketTool, ClearBasketTool, CreateOrderTool, GetUserOrdersTool, UpdateOrderStatusTool, UpdateBasketStatusTool, GetBasketsTool, CreateBasketTool } from "./tools/ProductsTool";
|
|
6
6
|
import CreatePaymentLinkTool from "./tools/PaymentTool";
|
|
7
|
+
import { CreateMovieTool, GetMoviesTool, GetMovieByIdTool, UpdateMovieTool, SearchMoviesTool, DeleteMovieTool } from "./tools/CustomDataTool";
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
// Initialize skill with tools
|
|
@@ -47,10 +48,34 @@ eccomerceSkill.addTools([
|
|
|
47
48
|
new CreateProductTool(),
|
|
48
49
|
new UpdateProductTool(),
|
|
49
50
|
new DeleteProductTool(),
|
|
50
|
-
new CreatePaymentLinkTool()
|
|
51
|
+
new CreatePaymentLinkTool(),
|
|
52
|
+
new CreateBasketTool(),
|
|
53
|
+
new GetBasketsTool(),
|
|
54
|
+
new AddItemToBasketTool(),
|
|
55
|
+
new RemoveItemFromBasketTool(),
|
|
56
|
+
new ClearBasketTool(),
|
|
57
|
+
new UpdateBasketStatusTool(),
|
|
58
|
+
new CreateOrderTool(),
|
|
59
|
+
new UpdateOrderStatusTool(),
|
|
60
|
+
new GetUserOrdersTool()
|
|
51
61
|
]);
|
|
52
62
|
|
|
53
63
|
|
|
64
|
+
const customDataSkill = new LuaSkill({
|
|
65
|
+
name: "custom-data-skill",
|
|
66
|
+
version: "0.0.1",
|
|
67
|
+
description: "A specific Lua skill with custom data",
|
|
68
|
+
context: "This skill provides various utilities including custom data.",
|
|
69
|
+
tools: [
|
|
70
|
+
new CreateMovieTool(),
|
|
71
|
+
new GetMoviesTool(),
|
|
72
|
+
new GetMovieByIdTool(),
|
|
73
|
+
new UpdateMovieTool(),
|
|
74
|
+
new SearchMoviesTool(),
|
|
75
|
+
new DeleteMovieTool()
|
|
76
|
+
]
|
|
77
|
+
});
|
|
78
|
+
|
|
54
79
|
// Test cases
|
|
55
80
|
const testCases = [
|
|
56
81
|
{ tool: "get_weather", city: "London" },
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { LuaTool } from "lua-cli/skill";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { customData } from 'lua-cli/custom-data-api';
|
|
4
|
+
|
|
5
|
+
// Movie data schema
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export class CreateMovieTool implements LuaTool {
|
|
9
|
+
name = "create_movie";
|
|
10
|
+
description = "Add a new movie to the movies database";
|
|
11
|
+
inputSchema = z.object({
|
|
12
|
+
movie: z.object({
|
|
13
|
+
title: z.string(),
|
|
14
|
+
director: z.string(),
|
|
15
|
+
year: z.number(),
|
|
16
|
+
genre: z.array(z.string()),
|
|
17
|
+
rating: z.number().min(0).max(10),
|
|
18
|
+
duration: z.number(), // in minutes
|
|
19
|
+
plot: z.string(),
|
|
20
|
+
cast: z.array(z.string()),
|
|
21
|
+
budget: z.number().optional(),
|
|
22
|
+
boxOffice: z.number().optional(),
|
|
23
|
+
imdbId: z.string().optional()
|
|
24
|
+
}),
|
|
25
|
+
searchText: z.string().optional().describe("Optional search text for better discoverability")
|
|
26
|
+
});
|
|
27
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
28
|
+
return customData.create("movies", {
|
|
29
|
+
data: input.movie,
|
|
30
|
+
searchText: input.searchText || `${input.movie.title} ${input.movie.director} ${input.movie.genre.join(' ')} ${input.movie.year}`
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class GetMoviesTool implements LuaTool {
|
|
36
|
+
name = "get_movies";
|
|
37
|
+
description = "Get movies from the database with optional filtering";
|
|
38
|
+
inputSchema = z.object({
|
|
39
|
+
filter: z.object({
|
|
40
|
+
genre: z.string().optional().describe("Filter by genre (e.g., 'Action', 'Drama')"),
|
|
41
|
+
year: z.number().optional().describe("Filter by release year"),
|
|
42
|
+
director: z.string().optional().describe("Filter by director name"),
|
|
43
|
+
minRating: z.number().min(0).max(10).optional().describe("Minimum rating filter"),
|
|
44
|
+
maxRating: z.number().min(0).max(10).optional().describe("Maximum rating filter")
|
|
45
|
+
}).optional(),
|
|
46
|
+
page: z.number().min(1).default(1).describe("Page number for pagination"),
|
|
47
|
+
limit: z.number().min(1).max(100).default(10).describe("Number of movies per page")
|
|
48
|
+
});
|
|
49
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
50
|
+
return customData.get("movies", input.filter, input.page, input.limit);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export class GetMovieByIdTool implements LuaTool {
|
|
55
|
+
name = "get_movie_by_id";
|
|
56
|
+
description = "Get a specific movie by its ID";
|
|
57
|
+
inputSchema = z.object({
|
|
58
|
+
movieId: z.string().describe("The unique ID of the movie to retrieve")
|
|
59
|
+
});
|
|
60
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
61
|
+
return customData.getEntry("movies", input.movieId);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export class UpdateMovieTool implements LuaTool {
|
|
66
|
+
name = "update_movie";
|
|
67
|
+
description = "Update an existing movie in the database";
|
|
68
|
+
inputSchema = z.object({
|
|
69
|
+
movieId: z.string().describe("The unique ID of the movie to update"),
|
|
70
|
+
updates: z.object({
|
|
71
|
+
title: z.string().optional(),
|
|
72
|
+
director: z.string().optional(),
|
|
73
|
+
year: z.number().optional(),
|
|
74
|
+
genre: z.array(z.string()).optional(),
|
|
75
|
+
rating: z.number().min(0).max(10).optional(),
|
|
76
|
+
duration: z.number().optional(),
|
|
77
|
+
plot: z.string().optional(),
|
|
78
|
+
cast: z.array(z.string()).optional(),
|
|
79
|
+
budget: z.number().optional(),
|
|
80
|
+
boxOffice: z.number().optional(),
|
|
81
|
+
imdbId: z.string().optional()
|
|
82
|
+
}).describe("Movie fields to update"),
|
|
83
|
+
searchText: z.string().optional().describe("Updated search text for better discoverability")
|
|
84
|
+
});
|
|
85
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
86
|
+
const updateData: any = { data: input.updates };
|
|
87
|
+
if (input.searchText) {
|
|
88
|
+
updateData.searchText = input.searchText;
|
|
89
|
+
}
|
|
90
|
+
return customData.update("movies", input.movieId, updateData);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class SearchMoviesTool implements LuaTool {
|
|
95
|
+
name = "search_movies";
|
|
96
|
+
description = "Search movies by text (title, director, genre, plot, cast, etc.)";
|
|
97
|
+
inputSchema = z.object({
|
|
98
|
+
searchText: z.string().describe("Text to search for in movie titles, directors, genres, plot, cast, etc."),
|
|
99
|
+
limit: z.number().min(1).max(50).default(10).describe("Maximum number of results to return"),
|
|
100
|
+
scoreThreshold: z.number().min(0).max(1).default(0.3).describe("Minimum similarity score (0-1)")
|
|
101
|
+
});
|
|
102
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
103
|
+
return customData.search("movies", input.searchText, input.limit, input.scoreThreshold);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export class DeleteMovieTool implements LuaTool {
|
|
108
|
+
name = "delete_movie";
|
|
109
|
+
description = "Delete a movie from the database";
|
|
110
|
+
inputSchema = z.object({
|
|
111
|
+
movieId: z.string().describe("The unique ID of the movie to delete")
|
|
112
|
+
});
|
|
113
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
114
|
+
return customData.delete("movies", input.movieId);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { env, LuaTool } from "lua-cli/skill";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { product } from 'lua-cli/product-api';
|
|
3
|
+
import { product, BasketStatus, OrderStatus, CreateOrderRequest } from 'lua-cli/product-api';
|
|
4
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
5
|
export class SearchProductsTool implements LuaTool {
|
|
6
6
|
name = "search_products";
|
|
@@ -72,4 +72,119 @@ export class DeleteProductTool implements LuaTool {
|
|
|
72
72
|
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
73
73
|
return product.data.delete(input.id);
|
|
74
74
|
}
|
|
75
|
-
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export class CreateBasketTool implements LuaTool {
|
|
78
|
+
name = "create_basket";
|
|
79
|
+
description = "Create a new basket";
|
|
80
|
+
inputSchema = z.object({
|
|
81
|
+
basket: z.object({
|
|
82
|
+
currency: z.string()
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
87
|
+
return product.basket.create(input.basket);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class GetBasketsTool implements LuaTool {
|
|
92
|
+
name = "get_baskets";
|
|
93
|
+
description = "Get all baskets";
|
|
94
|
+
inputSchema = z.object({
|
|
95
|
+
status: z.enum(['active', 'checked_out', 'abandoned', 'expired']).optional()
|
|
96
|
+
});
|
|
97
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
98
|
+
return product.basket.get(input.status as BasketStatus);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export class AddItemToBasketTool implements LuaTool {
|
|
103
|
+
name = "add_item_to_basket";
|
|
104
|
+
description = "Add an item to a basket";
|
|
105
|
+
inputSchema = z.object({
|
|
106
|
+
basketId: z.string(),
|
|
107
|
+
item: z.object({
|
|
108
|
+
id: z.string(),
|
|
109
|
+
price: z.number(),
|
|
110
|
+
quantity: z.number()
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
114
|
+
return product.basket.addItem(input.basketId, input.item);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export class RemoveItemFromBasketTool implements LuaTool {
|
|
119
|
+
name = "remove_item_from_basket";
|
|
120
|
+
description = "Remove an item from a basket";
|
|
121
|
+
inputSchema = z.object({
|
|
122
|
+
basketId: z.string(),
|
|
123
|
+
itemId: z.string()
|
|
124
|
+
});
|
|
125
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
126
|
+
return product.basket.removeItem(input.basketId, input.itemId);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export class ClearBasketTool implements LuaTool {
|
|
131
|
+
name = "clear_basket";
|
|
132
|
+
description = "Clear a basket";
|
|
133
|
+
inputSchema = z.object({
|
|
134
|
+
basketId: z.string()
|
|
135
|
+
});
|
|
136
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
137
|
+
return product.basket.clear(input.basketId);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export class UpdateBasketStatusTool implements LuaTool {
|
|
142
|
+
name = "update_basket_status";
|
|
143
|
+
description = "Update the status of a basket";
|
|
144
|
+
inputSchema = z.object({
|
|
145
|
+
basketId: z.string(),
|
|
146
|
+
status: z.enum(['active', 'checked_out', 'abandoned', 'expired'])
|
|
147
|
+
});
|
|
148
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
149
|
+
return product.basket.updateStatus(input.basketId, input.status as BasketStatus);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export class CreateOrderTool implements LuaTool {
|
|
154
|
+
name = "create_order";
|
|
155
|
+
description = "Create a new order";
|
|
156
|
+
inputSchema = z.object({
|
|
157
|
+
order: z.object({
|
|
158
|
+
basketId: z.string(),
|
|
159
|
+
data: z.object({
|
|
160
|
+
storeId: z.string(),
|
|
161
|
+
}).optional()
|
|
162
|
+
})
|
|
163
|
+
});
|
|
164
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
165
|
+
return product.order.create(input.order as CreateOrderRequest);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export class UpdateOrderStatusTool implements LuaTool {
|
|
170
|
+
name = "update_order_status";
|
|
171
|
+
description = "Update the status of an order";
|
|
172
|
+
inputSchema = z.object({
|
|
173
|
+
orderId: z.string(),
|
|
174
|
+
status: z.enum(['pending', 'confirmed', 'fulfilled', 'cancelled'])
|
|
175
|
+
});
|
|
176
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
177
|
+
return product.order.updateStatus(input.orderId, input.status as OrderStatus);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export class GetUserOrdersTool implements LuaTool {
|
|
182
|
+
name = "get_user_orders";
|
|
183
|
+
description = "Get all orders for a user";
|
|
184
|
+
inputSchema = z.object({
|
|
185
|
+
userId: z.string()
|
|
186
|
+
});
|
|
187
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
188
|
+
return product.order.get(input.userId);
|
|
189
|
+
}
|
|
190
|
+
}
|