lua-cli 2.2.7 → 2.2.8-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/api/agent.api.service.d.ts +18 -0
- package/dist/api/agent.api.service.js +30 -0
- package/dist/api/auth.api.service.d.ts +19 -0
- package/dist/api/auth.api.service.js +25 -0
- package/dist/api/basket.api.service.d.ts +43 -0
- package/dist/api/basket.api.service.js +115 -0
- package/dist/api/chat.api.service.d.ts +9 -0
- package/dist/api/chat.api.service.js +12 -0
- package/dist/api/custom.data.api.service.d.ts +33 -0
- package/dist/api/custom.data.api.service.js +91 -0
- package/dist/api/order.api.service.d.ts +23 -0
- package/dist/api/order.api.service.js +57 -0
- package/dist/api/products.api.service.d.ts +36 -0
- package/dist/api/products.api.service.js +74 -0
- package/dist/api/skills.api.service.d.ts +30 -0
- package/dist/api/skills.api.service.js +42 -0
- package/dist/api/tool.api.service.d.ts +14 -0
- package/dist/api/tool.api.service.js +35 -0
- package/dist/api/user.data.api.service.d.ts +11 -0
- package/dist/api/user.data.api.service.js +37 -0
- package/dist/api-exports.d.ts +40 -0
- package/dist/api-exports.js +189 -0
- package/dist/commands/dev.js +22 -17
- package/dist/common/basket.instance.d.ts +27 -0
- package/dist/common/basket.instance.js +79 -0
- package/dist/common/config.d.ts +5 -0
- package/dist/common/config.js +5 -0
- package/dist/common/data.entry.instance.d.ts +16 -0
- package/dist/common/data.entry.instance.js +52 -0
- package/dist/common/http.client.d.ts +14 -0
- package/dist/common/http.client.js +83 -0
- package/dist/common/order.instance.d.ts +18 -0
- package/dist/common/order.instance.js +52 -0
- package/dist/common/product.instance.d.ts +12 -0
- package/dist/common/product.instance.js +45 -0
- package/dist/common/product.pagination.instance.d.ts +23 -0
- package/dist/common/product.pagination.instance.js +53 -0
- package/dist/common/product.search.instance.d.ts +12 -0
- package/dist/common/product.search.instance.js +29 -0
- package/dist/common/user.instance.d.ts +17 -0
- package/dist/common/user.instance.js +63 -0
- package/dist/interfaces/admin.d.ts +95 -0
- package/dist/interfaces/admin.js +1 -0
- package/dist/interfaces/agent.d.ts +86 -0
- package/dist/interfaces/agent.js +1 -0
- package/dist/interfaces/baskets.d.ts +75 -0
- package/dist/interfaces/baskets.js +7 -0
- package/dist/interfaces/chat.d.ts +17 -0
- package/dist/interfaces/chat.js +1 -0
- package/dist/interfaces/custom.data.d.ts +52 -0
- package/dist/interfaces/custom.data.js +1 -0
- package/dist/interfaces/orders.d.ts +54 -0
- package/dist/interfaces/orders.js +7 -0
- package/dist/interfaces/product.d.ts +37 -0
- package/dist/interfaces/product.js +1 -0
- package/dist/product-api.d.ts +2 -10
- package/dist/product-api.js +3 -14
- package/dist/services/api.d.ts +3 -23
- package/dist/services/api.js +2 -31
- package/dist/services/auth.d.ts +1 -1
- package/dist/skill.js +2 -4
- package/dist/types/index.d.ts +36 -0
- package/dist/utils/sandbox.js +3 -7
- package/package.json +8 -12
- package/template/lua.skill.yaml +3 -12
- package/template/package-lock.json +3781 -0
- package/template/package.json +1 -1
- package/template/src/index.ts +200 -99
- package/template/src/tools/UserDataTool.ts +6 -7
package/template/package.json
CHANGED
package/template/src/index.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { LuaSkill } from "lua-cli
|
|
1
|
+
import { LuaSkill, User, Data} from "lua-cli";
|
|
2
2
|
import GetWeatherTool from "./tools/GetWeatherTool";
|
|
3
|
-
import { GetUserDataTool, CreateUserDataTool, UpdateUserDataTool } from "./tools/UserDataTool";
|
|
3
|
+
// import { GetUserDataTool, CreateUserDataTool, UpdateUserDataTool } from "./tools/UserDataTool";
|
|
4
4
|
import CreatePostTool from "./tools/CreatePostTool";
|
|
5
|
-
import { SearchProductsTool, GetAllProductsTool, CreateProductTool, UpdateProductTool, DeleteProductTool, AddItemToBasketTool, RemoveItemFromBasketTool, ClearBasketTool, CreateOrderTool, GetUserOrdersTool, UpdateOrderStatusTool, UpdateBasketStatusTool, GetBasketsTool, CreateBasketTool } from "./tools/ProductsTool";
|
|
6
|
-
import CreatePaymentLinkTool from "./tools/PaymentTool";
|
|
7
|
-
import { CreateMovieTool, GetMoviesTool, GetMovieByIdTool, UpdateMovieTool, SearchMoviesTool, DeleteMovieTool } from "./tools/CustomDataTool";
|
|
5
|
+
// import { SearchProductsTool, GetAllProductsTool, CreateProductTool, UpdateProductTool, DeleteProductTool, AddItemToBasketTool, RemoveItemFromBasketTool, ClearBasketTool, CreateOrderTool, GetUserOrdersTool, UpdateOrderStatusTool, UpdateBasketStatusTool, GetBasketsTool, CreateBasketTool } from "./tools/ProductsTool";
|
|
6
|
+
// import CreatePaymentLinkTool from "./tools/PaymentTool";
|
|
7
|
+
// import { CreateMovieTool, GetMoviesTool, GetMovieByIdTool, UpdateMovieTool, SearchMoviesTool, DeleteMovieTool } from "./tools/CustomDataTool";
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
// Initialize skill with tools
|
|
11
11
|
const generalSkill = new LuaSkill({
|
|
12
12
|
name: "general-skill",
|
|
13
|
-
version: "0.0
|
|
13
|
+
version: "1.0.0",
|
|
14
14
|
description: "A comprehensive Lua skill with weather, user data, post creation, and mathematical tools",
|
|
15
15
|
context: "This skill provides various utilities including weather information, user data retrieval, post creation, basic calculator operations, and advanced mathematical functions. Use get_weather to fetch current weather conditions for any city, get_user_data to retrieve user information, create_post to publish new posts, calculator for basic arithmetic operations, and advanced_math for complex mathematical computations like factorials, prime checking, fibonacci sequences, and greatest common divisor calculations."
|
|
16
16
|
});
|
|
@@ -22,101 +22,202 @@ generalSkill.addTools([
|
|
|
22
22
|
]);
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
const userDataSkill = new LuaSkill({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const resultEccomerce = await eccomerceSkill.run(testCase);
|
|
105
|
-
console.log("✅ Success:", resultEccomerce);
|
|
106
|
-
} catch (error: any) {
|
|
107
|
-
console.log("❌ Error:", error.message);
|
|
108
|
-
}
|
|
109
|
-
console.log(""); // Empty line for readability
|
|
110
|
-
}
|
|
111
|
-
}
|
|
25
|
+
// const userDataSkill = new LuaSkill({
|
|
26
|
+
// name: "user-data-skill",
|
|
27
|
+
// description: "A specific Lua skill with user data",
|
|
28
|
+
// context: "This skill provides various utilities including user data retrieval, creation, and updating."
|
|
29
|
+
// });
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// const eccomerceSkill = new LuaSkill({
|
|
33
|
+
// name: "eccomerce-skill",
|
|
34
|
+
// description: "A specific Lua skill with eccomerce",
|
|
35
|
+
// context: "This skill provides various utilities including eccomerce."
|
|
36
|
+
// });
|
|
37
|
+
|
|
38
|
+
// eccomerceSkill.addTools([
|
|
39
|
+
// new SearchProductsTool(),
|
|
40
|
+
// new GetAllProductsTool(),
|
|
41
|
+
// new CreateProductTool(),
|
|
42
|
+
// new UpdateProductTool(),
|
|
43
|
+
// new DeleteProductTool(),
|
|
44
|
+
// new CreatePaymentLinkTool(),
|
|
45
|
+
// new CreateBasketTool(),
|
|
46
|
+
// new GetBasketsTool(),
|
|
47
|
+
// new AddItemToBasketTool(),
|
|
48
|
+
// new RemoveItemFromBasketTool(),
|
|
49
|
+
// new ClearBasketTool(),
|
|
50
|
+
// new UpdateBasketStatusTool(),
|
|
51
|
+
// new CreateOrderTool(),
|
|
52
|
+
// new UpdateOrderStatusTool(),
|
|
53
|
+
// new GetUserOrdersTool()
|
|
54
|
+
// ]);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
// const customDataSkill = new LuaSkill({
|
|
58
|
+
// name: "custom-data-skill",
|
|
59
|
+
// description: "A specific Lua skill with custom data",
|
|
60
|
+
// context: "This skill provides various utilities including custom data.",
|
|
61
|
+
// tools: [
|
|
62
|
+
// new CreateMovieTool(),
|
|
63
|
+
// new GetMoviesTool(),
|
|
64
|
+
// new GetMovieByIdTool(),
|
|
65
|
+
// new UpdateMovieTool(),
|
|
66
|
+
// new SearchMoviesTool(),
|
|
67
|
+
// new DeleteMovieTool()
|
|
68
|
+
// ]
|
|
69
|
+
// });
|
|
70
|
+
|
|
71
|
+
// // Test cases
|
|
72
|
+
// const testCases = [
|
|
73
|
+
// { tool: "get_weather", city: "London" },
|
|
74
|
+
// { tool: "get_user_data", userId: "user123" },
|
|
75
|
+
// { tool: "create_post", title: "Test Post", content: "This is a test post content" },
|
|
76
|
+
// { tool: "calculator", operation: "add", a: 5, b: 3 },
|
|
77
|
+
// { tool: "advanced_math", operation: "factorial", numbers: [5] },
|
|
78
|
+
// { tool: "advanced_math", operation: "is_prime", numbers: [17] },
|
|
79
|
+
// { tool: "advanced_math", operation: "fibonacci", numbers: [10] },
|
|
80
|
+
// { tool: "advanced_math", operation: "gcd", numbers: [48, 18] },
|
|
81
|
+
// // This should fail - wrong property name
|
|
82
|
+
// { tool: "get_weather", cityLong: "London", apiKey: "123" }
|
|
83
|
+
// ];
|
|
84
|
+
|
|
85
|
+
// async function runTests() {
|
|
86
|
+
// // await seedProducts();
|
|
87
|
+
// console.log("🧪 Running tool tests...\n");
|
|
88
|
+
|
|
89
|
+
// for (const [index, testCase] of testCases.entries()) {
|
|
90
|
+
// try {
|
|
91
|
+
// console.log(`Test ${index + 1}: ${testCase.tool}`);
|
|
92
|
+
// const resultGeneral = await generalSkill.run(testCase);
|
|
93
|
+
// console.log("✅ Success:", resultGeneral);
|
|
94
|
+
// const resultUserData = await userDataSkill.run(testCase);
|
|
95
|
+
// console.log("✅ Success:", resultUserData);
|
|
96
|
+
// const resultEccomerce = await eccomerceSkill.run(testCase);
|
|
97
|
+
// console.log("✅ Success:", resultEccomerce);
|
|
98
|
+
// } catch (error: any) {
|
|
99
|
+
// console.log("❌ Error:", error.message);
|
|
100
|
+
// }
|
|
101
|
+
// console.log(""); // Empty line for readability
|
|
102
|
+
// }
|
|
103
|
+
// }
|
|
112
104
|
|
|
113
105
|
async function main() {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
106
|
+
|
|
107
|
+
// console.log('Getting user data --------------------------------');
|
|
108
|
+
// const userData = await User.get();
|
|
109
|
+
// console.log('userData', userData.data);
|
|
110
|
+
// await userData.update({ name: 'Stefan Kruger', age: 30 });
|
|
111
|
+
// console.log('userData', userData.data);
|
|
112
|
+
// await userData.clear();
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
// console.log('Getting product data --------------------------------');
|
|
117
|
+
// const products = await Product.get(1,1);
|
|
118
|
+
// console.log('products', products.products);
|
|
119
|
+
|
|
120
|
+
// for(const product of products.products) {
|
|
121
|
+
// console.log('product', product.data);
|
|
122
|
+
// await product.update({ name: 'Product 1', price: 500 });
|
|
123
|
+
// console.log('product', product.data);
|
|
124
|
+
// await product.delete();
|
|
125
|
+
// // console.log('product', product.data);
|
|
126
|
+
// }
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
// //create a new product
|
|
130
|
+
// const newProduct = await Product.create({ id: '1', name: 'Product 1', price: 100 });
|
|
131
|
+
// console.log('newProduct', newProduct.data);
|
|
132
|
+
// console.log('pagination', products.pagination);
|
|
133
|
+
// const nextProducts = await products.nextPage();
|
|
134
|
+
// console.log('nextProducts', nextProducts.products);
|
|
135
|
+
// const prevProducts = await products.prevPage();
|
|
136
|
+
// console.log('prevProducts', prevProducts.products);
|
|
137
|
+
|
|
138
|
+
//search products
|
|
139
|
+
// const searchProducts = await Product.search('Product');
|
|
140
|
+
// console.log('searchProducts', searchProducts.products);
|
|
141
|
+
// for(const product of searchProducts.products) {
|
|
142
|
+
// console.log('product', product.data);
|
|
143
|
+
// await product.update({ name: 'Product 1', price: 500 });
|
|
144
|
+
// console.log('product', product.data);
|
|
145
|
+
|
|
146
|
+
// }
|
|
147
|
+
|
|
148
|
+
// // // // console.log('Getting basket data --------------------------------');
|
|
149
|
+
// const baskets = await Basket.get(BasketStatus.ACTIVE);
|
|
150
|
+
// // console.log('baskets', baskets);
|
|
151
|
+
|
|
152
|
+
// const thisBasket = baskets[0];
|
|
153
|
+
// console.log('thisBasket', thisBasket);
|
|
154
|
+
// const order = await thisBasket.placeOrder({
|
|
155
|
+
// shippingAddress: '123 Main St, Anytown, USA',
|
|
156
|
+
// paymentMethod: 'credit_card',
|
|
157
|
+
// customerNotes: 'Please handle with care'
|
|
158
|
+
// });
|
|
159
|
+
// console.log('order', order);
|
|
160
|
+
|
|
161
|
+
// //update order status
|
|
162
|
+
// const updatedOrder = await order.updateStatus(OrderStatus.CONFIRMED);
|
|
163
|
+
// console.log('updatedOrder', updatedOrder);
|
|
164
|
+
|
|
165
|
+
// //update order
|
|
166
|
+
// const updatedOrder2 = await order.update({
|
|
167
|
+
// checkoutDetails: 'my details',
|
|
168
|
+
// name: 'John Doe'
|
|
169
|
+
// });
|
|
170
|
+
// console.log('updatedOrder2', updatedOrder2);
|
|
171
|
+
// // await thisBasket.clear();
|
|
172
|
+
// // console.log('thisBasket', thisBasket);
|
|
173
|
+
// await thisBasket.addItem({ id: '1', price: 100, quantity: 1 });
|
|
174
|
+
// await thisBasket.addItem({ id: '2', price: 100, quantity: 1 });
|
|
175
|
+
|
|
176
|
+
// console.log('thisBasket', thisBasket);
|
|
177
|
+
// await thisBasket.removeItem('2');
|
|
178
|
+
// // console.log('thisBasket', thisBasket);
|
|
179
|
+
// // await thisBasket.clear();
|
|
180
|
+
// // console.log('thisBasket', thisBasket);
|
|
181
|
+
|
|
182
|
+
//get orders
|
|
183
|
+
// const orders = await Order.get();
|
|
184
|
+
// // console.log('orders', orders);
|
|
185
|
+
// const thisOrder = orders[0];
|
|
186
|
+
// console.log('thisOrder', thisOrder);
|
|
187
|
+
// const updatedOrder = await thisOrder.updateStatus(OrderStatus.FULFILLED);
|
|
188
|
+
// console.log('updatedOrder', updatedOrder);
|
|
189
|
+
// const updatedOrder2 = await thisOrder.update({
|
|
190
|
+
// checkoutDetails: 'my details',
|
|
191
|
+
// name: 'John Doe'
|
|
192
|
+
// });
|
|
193
|
+
// console.log('updatedOrder2', updatedOrder2);
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
//create a new data
|
|
197
|
+
// const newData = await Data.create('my-data', { name: 'Jan Kruger' }, 'jan kruger');
|
|
198
|
+
// console.log('newData', newData);
|
|
199
|
+
//search the data
|
|
200
|
+
// const searchData = await Data.search('my-data', 'Jan Kruger');
|
|
201
|
+
// for(const data of searchData) {
|
|
202
|
+
// console.log('data', data.score);
|
|
203
|
+
// //update the data
|
|
204
|
+
// await data.update({ name: 'Jan Kruger2' });
|
|
205
|
+
// console.log('data', data);
|
|
206
|
+
// //delete the data
|
|
207
|
+
// await data.delete();
|
|
208
|
+
// console.log('data', data);
|
|
209
|
+
// // await data.update({ name: 'Jan Kruger' });
|
|
210
|
+
// // console.log('data', data);
|
|
211
|
+
// // await data.delete();
|
|
212
|
+
// // console.log('data', data);
|
|
213
|
+
// }
|
|
214
|
+
// console.log('searchData', searchData);
|
|
215
|
+
|
|
216
|
+
//create a new data
|
|
217
|
+
// const newData = await Data.create('my-data', { name: 'John Doe' });
|
|
218
|
+
// console.log('newData', newData);
|
|
219
|
+
|
|
220
|
+
|
|
120
221
|
}
|
|
121
222
|
|
|
122
223
|
main().catch(console.error);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { LuaTool } from "lua-cli
|
|
1
|
+
import { Lua, LuaTool } from "lua-cli";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { user } from 'lua-cli/user-data-api';
|
|
4
3
|
|
|
5
4
|
|
|
6
5
|
export class GetUserDataTool implements LuaTool {
|
|
@@ -11,7 +10,7 @@ export class GetUserDataTool implements LuaTool {
|
|
|
11
10
|
constructor() {}
|
|
12
11
|
|
|
13
12
|
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
14
|
-
return
|
|
13
|
+
return new Lua.User().get();
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
|
|
@@ -30,11 +29,11 @@ export class CreateUserDataTool implements LuaTool {
|
|
|
30
29
|
|
|
31
30
|
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
32
31
|
console.log('createUserData tool', input);
|
|
33
|
-
const userData = await
|
|
32
|
+
const userData = await new Lua.User().get();
|
|
34
33
|
if (userData.data) {
|
|
35
|
-
return
|
|
34
|
+
return new Lua.User().update(input.data);
|
|
36
35
|
}
|
|
37
|
-
return
|
|
36
|
+
return new Lua.User().create(input.data);
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -51,6 +50,6 @@ export class UpdateUserDataTool implements LuaTool {
|
|
|
51
50
|
constructor() {}
|
|
52
51
|
|
|
53
52
|
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
54
|
-
return
|
|
53
|
+
return new Lua.User().update(input.data);
|
|
55
54
|
}
|
|
56
55
|
}
|