lua-cli 2.2.8-alpha.2 → 2.3.0-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.
Files changed (195) hide show
  1. package/API_REFERENCE.md +1408 -0
  2. package/CLI_REFERENCE.md +818 -0
  3. package/GETTING_STARTED.md +1040 -0
  4. package/README.md +738 -424
  5. package/TEMPLATE_GUIDE.md +1398 -0
  6. package/dist/api/agent.api.service.d.ts +33 -6
  7. package/dist/api/agent.api.service.js +27 -0
  8. package/dist/api/auth.api.service.d.ts +31 -2
  9. package/dist/api/auth.api.service.js +29 -0
  10. package/dist/api/basket.api.service.d.ts +53 -11
  11. package/dist/api/basket.api.service.js +63 -14
  12. package/dist/api/chat.api.service.d.ts +15 -3
  13. package/dist/api/chat.api.service.js +12 -0
  14. package/dist/api/credentials.d.ts +24 -0
  15. package/dist/api/credentials.js +46 -0
  16. package/dist/api/custom.data.api.service.d.ts +45 -9
  17. package/dist/api/custom.data.api.service.js +43 -9
  18. package/dist/api/lazy-instances.d.ts +49 -0
  19. package/dist/api/lazy-instances.js +95 -0
  20. package/dist/api/order.api.service.d.ts +34 -4
  21. package/dist/api/order.api.service.js +41 -3
  22. package/dist/api/products.api.service.d.ts +39 -9
  23. package/dist/api/products.api.service.js +43 -5
  24. package/dist/api/skills.api.service.d.ts +49 -2
  25. package/dist/api/skills.api.service.js +47 -1
  26. package/dist/api/tool.api.service.d.ts +39 -1
  27. package/dist/api/tool.api.service.js +38 -0
  28. package/dist/api/user.data.api.service.d.ts +23 -1
  29. package/dist/api/user.data.api.service.js +22 -0
  30. package/dist/api-exports.d.ts +236 -5
  31. package/dist/api-exports.js +264 -81
  32. package/dist/cli/command-definitions.d.ts +30 -0
  33. package/dist/cli/command-definitions.js +71 -0
  34. package/dist/commands/agents.d.ts +20 -0
  35. package/dist/commands/agents.js +24 -2
  36. package/dist/commands/apiKey.d.ts +23 -0
  37. package/dist/commands/apiKey.js +23 -0
  38. package/dist/commands/compile.d.ts +24 -0
  39. package/dist/commands/compile.js +67 -759
  40. package/dist/commands/configure.d.ts +24 -0
  41. package/dist/commands/configure.js +31 -96
  42. package/dist/commands/deploy.d.ts +31 -19
  43. package/dist/commands/deploy.js +45 -74
  44. package/dist/commands/destroy.d.ts +27 -0
  45. package/dist/commands/destroy.js +27 -1
  46. package/dist/commands/dev.d.ts +25 -62
  47. package/dist/commands/dev.js +58 -878
  48. package/dist/commands/init.d.ts +27 -0
  49. package/dist/commands/init.js +98 -260
  50. package/dist/commands/push.d.ts +24 -21
  51. package/dist/commands/push.js +39 -92
  52. package/dist/commands/test.d.ts +26 -0
  53. package/dist/commands/test.js +41 -188
  54. package/dist/common/basket.instance.d.ts +54 -3
  55. package/dist/common/basket.instance.js +56 -3
  56. package/dist/common/data.entry.instance.d.ts +25 -2
  57. package/dist/common/data.entry.instance.js +24 -0
  58. package/dist/common/http.client.d.ts +51 -1
  59. package/dist/common/http.client.js +50 -0
  60. package/dist/common/order.instance.d.ts +22 -0
  61. package/dist/common/order.instance.js +31 -4
  62. package/dist/common/product.instance.d.ts +22 -1
  63. package/dist/common/product.instance.js +24 -6
  64. package/dist/common/product.pagination.instance.d.ts +22 -2
  65. package/dist/common/product.pagination.instance.js +22 -1
  66. package/dist/common/product.search.instance.d.ts +13 -3
  67. package/dist/common/product.search.instance.js +12 -1
  68. package/dist/common/user.instance.d.ts +27 -3
  69. package/dist/common/user.instance.js +28 -7
  70. package/dist/config/auth.constants.d.ts +11 -0
  71. package/dist/config/auth.constants.js +11 -0
  72. package/dist/config/compile.constants.d.ts +67 -0
  73. package/dist/config/compile.constants.js +99 -0
  74. package/dist/config/constants.d.ts +5 -0
  75. package/dist/config/constants.js +5 -0
  76. package/dist/config/dev.constants.d.ts +65 -0
  77. package/dist/config/dev.constants.js +79 -0
  78. package/dist/config/init.constants.d.ts +23 -0
  79. package/dist/config/init.constants.js +41 -0
  80. package/dist/index.d.ts +19 -3
  81. package/dist/index.js +28 -44
  82. package/dist/interfaces/admin.d.ts +56 -50
  83. package/dist/interfaces/admin.js +4 -0
  84. package/dist/interfaces/agent.d.ts +21 -0
  85. package/dist/interfaces/agent.js +4 -0
  86. package/dist/interfaces/baskets.d.ts +60 -0
  87. package/dist/interfaces/baskets.js +12 -0
  88. package/dist/interfaces/chat.d.ts +48 -4
  89. package/dist/interfaces/chat.js +4 -0
  90. package/dist/interfaces/common.d.ts +62 -0
  91. package/dist/interfaces/common.js +8 -0
  92. package/dist/interfaces/compile.d.ts +11 -0
  93. package/dist/interfaces/compile.js +4 -0
  94. package/dist/interfaces/custom.data.d.ts +49 -19
  95. package/dist/interfaces/custom.data.js +4 -0
  96. package/dist/interfaces/deploy.d.ts +29 -0
  97. package/dist/interfaces/deploy.js +4 -0
  98. package/dist/interfaces/dev.d.ts +53 -0
  99. package/dist/interfaces/dev.js +5 -0
  100. package/dist/interfaces/init.d.ts +60 -0
  101. package/dist/interfaces/init.js +4 -0
  102. package/dist/interfaces/orders.d.ts +37 -0
  103. package/dist/interfaces/orders.js +12 -0
  104. package/dist/interfaces/product.d.ts +38 -10
  105. package/dist/interfaces/product.js +4 -0
  106. package/dist/interfaces/push.d.ts +26 -0
  107. package/dist/interfaces/push.js +4 -0
  108. package/dist/interfaces/test.d.ts +36 -0
  109. package/dist/interfaces/test.js +4 -0
  110. package/dist/services/auth.d.ts +54 -99
  111. package/dist/services/auth.js +76 -12
  112. package/dist/types/api-contracts.d.ts +211 -0
  113. package/dist/types/api-contracts.js +8 -0
  114. package/dist/types/compile.types.d.ts +76 -0
  115. package/dist/types/compile.types.js +4 -0
  116. package/dist/types/index.d.ts +23 -121
  117. package/dist/types/index.js +25 -14
  118. package/dist/types/skill.d.ts +142 -0
  119. package/dist/{skill.js → types/skill.js} +66 -17
  120. package/dist/types/tool-validation.d.ts +34 -0
  121. package/dist/types/tool-validation.js +42 -0
  122. package/dist/utils/auth-flows.d.ts +26 -0
  123. package/dist/utils/auth-flows.js +141 -0
  124. package/dist/utils/bundling.d.ts +36 -0
  125. package/dist/utils/bundling.js +137 -0
  126. package/dist/utils/compile.d.ts +37 -0
  127. package/dist/utils/compile.js +242 -0
  128. package/dist/utils/deploy-api.d.ts +26 -0
  129. package/dist/utils/deploy-api.js +53 -0
  130. package/dist/utils/deploy-helpers.d.ts +46 -0
  131. package/dist/utils/deploy-helpers.js +86 -0
  132. package/dist/utils/deployment.d.ts +25 -0
  133. package/dist/utils/deployment.js +161 -0
  134. package/dist/utils/dev-api.d.ts +61 -0
  135. package/dist/utils/dev-api.js +262 -0
  136. package/dist/utils/dev-helpers.d.ts +46 -0
  137. package/dist/utils/dev-helpers.js +83 -0
  138. package/dist/utils/dev-server.d.ts +24 -0
  139. package/dist/utils/dev-server.js +555 -0
  140. package/dist/utils/dev-watcher.d.ts +31 -0
  141. package/dist/utils/dev-watcher.js +110 -0
  142. package/dist/utils/files.js +0 -5
  143. package/dist/utils/init-agent.d.ts +34 -0
  144. package/dist/utils/init-agent.js +129 -0
  145. package/dist/utils/init-helpers.d.ts +41 -0
  146. package/dist/utils/init-helpers.js +73 -0
  147. package/dist/utils/init-prompts.d.ts +47 -0
  148. package/dist/utils/init-prompts.js +168 -0
  149. package/dist/utils/push-api.d.ts +15 -0
  150. package/dist/utils/push-api.js +48 -0
  151. package/dist/utils/push-helpers.d.ts +38 -0
  152. package/dist/utils/push-helpers.js +84 -0
  153. package/dist/utils/sandbox-storage.d.ts +27 -0
  154. package/dist/utils/sandbox-storage.js +71 -0
  155. package/dist/utils/sandbox.js +78 -114
  156. package/dist/utils/skill-management.d.ts +14 -0
  157. package/dist/utils/skill-management.js +148 -0
  158. package/dist/utils/test-helpers.d.ts +40 -0
  159. package/dist/utils/test-helpers.js +92 -0
  160. package/dist/utils/test-prompts.d.ts +23 -0
  161. package/dist/utils/test-prompts.js +186 -0
  162. package/dist/utils/tool-detection.d.ts +18 -0
  163. package/dist/utils/tool-detection.js +110 -0
  164. package/dist/web/app.css +941 -17
  165. package/dist/web/app.js +174 -22
  166. package/dist/web/index.html +7 -1
  167. package/package.json +13 -4
  168. package/template/QUICKSTART.md +299 -144
  169. package/template/README.md +928 -349
  170. package/template/TOOL_EXAMPLES.md +655 -0
  171. package/template/package-lock.json +5 -5
  172. package/template/package.json +1 -1
  173. package/template/src/index.ts +147 -207
  174. package/template/src/tools/BasketTool.ts +128 -0
  175. package/template/src/tools/CustomDataTool.ts +7 -13
  176. package/template/src/tools/OrderTool.ts +54 -0
  177. package/template/src/tools/PaymentTool.ts +1 -1
  178. package/template/src/tools/ProductsTool.ts +56 -118
  179. package/template/src/tools/UserDataTool.ts +4 -26
  180. package/dist/common/config.d.ts +0 -5
  181. package/dist/common/config.js +0 -5
  182. package/dist/custom-data-api.d.ts +0 -72
  183. package/dist/custom-data-api.js +0 -174
  184. package/dist/product-api.d.ts +0 -189
  185. package/dist/product-api.js +0 -141
  186. package/dist/services/api.d.ts +0 -549
  187. package/dist/services/api.js +0 -596
  188. package/dist/skill.d.ts +0 -50
  189. package/dist/types.d.ts +0 -1
  190. package/dist/types.js +0 -2
  191. package/dist/user-data-api.d.ts +0 -39
  192. package/dist/user-data-api.js +0 -50
  193. package/template/API.md +0 -604
  194. package/template/DEVELOPER.md +0 -771
  195. package/template/lua.skill.yaml +0 -7
@@ -1,223 +1,163 @@
1
- import { LuaSkill, User, Data} from "lua-cli";
1
+ import { LuaSkill, User, Products, Orders, Data, Baskets } from "lua-cli";
2
2
  import GetWeatherTool from "./tools/GetWeatherTool";
3
- // import { GetUserDataTool, CreateUserDataTool, UpdateUserDataTool } from "./tools/UserDataTool";
3
+ import { GetUserDataTool, 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, CreateProductTool, UpdateProductTool, GetAllProductsTool, GetProductByIdTool, DeleteProductTool } from "./tools/ProductsTool";
6
+ import CreatePaymentLinkTool from "./tools/PaymentTool";
7
+ import { CreateBasketTool, GetBasketsTool, AddItemToBasketTool, RemoveItemFromBasketTool, ClearBasketTool, UpdateBasketStatusTool, UpdateBasketMetadataTool, CheckoutBasketTool, GetBasketByIdTool } from "./tools/BasketTool";
8
+ import { CreateOrderTool, UpdateOrderStatusTool, GetOrderByIdTool, GetUserOrdersTool } from "./tools/OrderTool";
9
+ import { CreateMovieTool, GetMoviesTool, GetMovieByIdTool, UpdateMovieTool, SearchMoviesTool, DeleteMovieTool } from "./tools/CustomDataTool";
8
10
 
9
11
 
10
12
  // Initialize skill with tools
11
13
  const generalSkill = new LuaSkill({
12
14
  name: "general-skill",
13
- version: "1.0.0",
15
+ version: "0.0.2",
14
16
  description: "A comprehensive Lua skill with weather, user data, post creation, and mathematical tools",
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."
17
+ 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.",
18
+ tools: [
19
+ new GetWeatherTool(),
20
+ new CreatePostTool()
21
+ ]
22
+ });
23
+
24
+ const userDataSkill = new LuaSkill({
25
+ name: "user-data-skill",
26
+ version: "0.0.1",
27
+ description: "A specific Lua skill with user data",
28
+ context: "This skill provides various utilities including user data retrieval, creation, and updating.",
29
+ tools: [
30
+ new GetUserDataTool(),
31
+ new UpdateUserDataTool()
32
+ ]
33
+ });
34
+
35
+
36
+ const productSkill = new LuaSkill({
37
+ name: "product-skill",
38
+ version: "0.0.1",
39
+ description: "A specific Lua skill with products",
40
+ context: "This skill provides various utilities including products.",
41
+ tools: [
42
+ new SearchProductsTool(),
43
+ new GetAllProductsTool(),
44
+ new CreateProductTool(),
45
+ new UpdateProductTool(),
46
+ new GetProductByIdTool(),
47
+ new DeleteProductTool()
48
+ ]
49
+ });
50
+
51
+
52
+ const basketSkill = new LuaSkill({
53
+ name: "basket-skill",
54
+ version: "0.0.1",
55
+ description: "A specific Lua skill with baskets",
56
+ context: "This skill provides various utilities including baskets.",
57
+ tools: [
58
+ new CreateBasketTool(),
59
+ new GetBasketsTool(),
60
+ new AddItemToBasketTool(),
61
+ new RemoveItemFromBasketTool(),
62
+ new ClearBasketTool(),
63
+ new UpdateBasketStatusTool(),
64
+ new UpdateBasketMetadataTool(),
65
+ new CheckoutBasketTool(),
66
+ new GetBasketByIdTool()
67
+ ]
16
68
  });
17
69
 
18
70
 
19
- generalSkill.addTools([
20
- new GetWeatherTool(),
21
- new CreatePostTool()
22
- ]);
23
-
24
-
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
- // }
71
+ const orderSkill = new LuaSkill({
72
+ name: "order-skill",
73
+ version: "0.0.1",
74
+ description: "A specific Lua skill with orders",
75
+ context: "This skill provides various utilities including orders.",
76
+ tools: [
77
+ new CreateOrderTool(),
78
+ new UpdateOrderStatusTool(),
79
+ new GetOrderByIdTool(),
80
+ new GetUserOrdersTool()
81
+ ]
82
+ });
83
+
84
+ const customDataSkill = new LuaSkill({
85
+ name: "custom-data-skill",
86
+ version: "0.0.1",
87
+ description: "A specific Lua skill with custom data",
88
+ context: "This skill provides various utilities including custom data.",
89
+ tools: [
90
+ new CreateMovieTool(),
91
+ new GetMoviesTool(),
92
+ new GetMovieByIdTool(),
93
+ new UpdateMovieTool(),
94
+ new SearchMoviesTool(),
95
+ new DeleteMovieTool()
96
+ ]
97
+ });
98
+
99
+ const paymentSkill = new LuaSkill({
100
+ name: "payment-skill",
101
+ version: "0.0.1",
102
+ description: "A specific Lua skill with payments",
103
+ context: "This skill provides various utilities including payments.",
104
+ tools: [
105
+ new CreatePaymentLinkTool()
106
+ ]
107
+ });
108
+
109
+ // Test cases
110
+ const testCases = [
111
+ { tool: "get_weather", city: "London" },
112
+ { tool: "get_user_data", userId: "user123" },
113
+ { tool: "create_post", title: "Test Post", content: "This is a test post content" },
114
+ { tool: "calculator", operation: "add", a: 5, b: 3 },
115
+ { tool: "advanced_math", operation: "factorial", numbers: [5] },
116
+ { tool: "advanced_math", operation: "is_prime", numbers: [17] },
117
+ { tool: "advanced_math", operation: "fibonacci", numbers: [10] },
118
+ { tool: "advanced_math", operation: "gcd", numbers: [48, 18] },
119
+ // This should fail - wrong property name
120
+ { tool: "get_weather", cityLong: "London", apiKey: "123" }
121
+ ];
122
+
123
+ async function runTests() {
124
+ // await seedProducts();
125
+ console.log("🧪 Running tool tests...\n");
126
+
127
+ const user = await User.get();
128
+ console.log(" Success:", user);
129
+ const products = await Products.get();
130
+ console.log(" Success:", products);
131
+ const orders = await Orders.get();
132
+ console.log(" Success:", orders);
133
+ const data = await Data.get("movies");
134
+ console.log(" Success:", data);
135
+ const baskets = await Baskets.get();
136
+ console.log("✅ Success:", baskets);
137
+
138
+ for (const [index, testCase] of testCases.entries()) {
139
+ try {
140
+ // console.log(`Test ${index + 1}: ${testCase.tool}`);
141
+ // const resultGeneral = await generalSkill.run(testCase);
142
+ // console.log("✅ Success:", resultGeneral);
143
+ // const resultUserData = await userDataSkill.run(testCase);
144
+ // console.log("✅ Success:", resultUserData);
145
+ // const resultEccomerce = await eccomerceSkill.run(testCase);
146
+ // console.log("✅ Success:", resultEccomerce);
147
+ } catch (error: any) {
148
+ console.log("❌ Error:", error.message);
149
+ }
150
+ console.log(""); // Empty line for readability
151
+ }
152
+ }
104
153
 
105
154
  async function main() {
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
-
155
+ try {
156
+ await runTests();
157
+ } catch (error) {
158
+ console.error("💥 Unexpected error:", error);
159
+ process.exit(1);
160
+ }
221
161
  }
222
162
 
223
163
  main().catch(console.error);
@@ -0,0 +1,128 @@
1
+ import { LuaTool, Baskets } from "lua-cli";
2
+ import { z } from "zod";
3
+ import { BasketStatus } from 'lua-cli';
4
+ import { v4 as uuidv4 } from 'uuid';
5
+
6
+
7
+ export class CreateBasketTool implements LuaTool {
8
+ name = "create_basket";
9
+ description = "Create a new basket";
10
+ inputSchema = z.object({
11
+ basket: z.object({
12
+ currency: z.string()
13
+ })
14
+ });
15
+
16
+ async execute(input: z.infer<typeof this.inputSchema>) {
17
+ return Baskets.create(input.basket);
18
+ }
19
+ }
20
+
21
+ export class GetBasketsTool implements LuaTool {
22
+ name = "get_baskets";
23
+ description = "Get all baskets";
24
+ inputSchema = z.object({
25
+ status: z.enum(['active', 'checked_out', 'abandoned', 'expired']).optional()
26
+ });
27
+ async execute(input: z.infer<typeof this.inputSchema>) {
28
+ return Baskets.get(input.status as BasketStatus);
29
+ }
30
+ }
31
+
32
+ export class AddItemToBasketTool implements LuaTool {
33
+ name = "add_item_to_basket";
34
+ description = "Add an item to a basket";
35
+ inputSchema = z.object({
36
+ basketId: z.string(),
37
+ item: z.object({
38
+ id: z.string(),
39
+ price: z.number(),
40
+ quantity: z.number()
41
+ })
42
+ });
43
+ async execute(input: z.infer<typeof this.inputSchema>) {
44
+ //Get user basket
45
+ const userBasket = await Baskets.getById(input.basketId);
46
+ return userBasket.addItem(input.item);
47
+ }
48
+ }
49
+
50
+ export class RemoveItemFromBasketTool implements LuaTool {
51
+ name = "remove_item_from_basket";
52
+ description = "Remove an item from a basket";
53
+ inputSchema = z.object({
54
+ basketId: z.string(),
55
+ itemId: z.string()
56
+ });
57
+ async execute(input: z.infer<typeof this.inputSchema>) {
58
+ const userBasket = await Baskets.getById(input.basketId);
59
+ return userBasket.removeItem(input.itemId);
60
+ }
61
+ }
62
+
63
+ export class ClearBasketTool implements LuaTool {
64
+ name = "clear_basket";
65
+ description = "Clear a basket";
66
+ inputSchema = z.object({
67
+ basketId: z.string()
68
+ });
69
+ async execute(input: z.infer<typeof this.inputSchema>) {
70
+ const userBasket = await Baskets.getById(input.basketId);
71
+ return userBasket.clear();
72
+ }
73
+ }
74
+
75
+ export class UpdateBasketStatusTool implements LuaTool {
76
+ name = "update_basket_status";
77
+ description = "Update the status of a basket";
78
+ inputSchema = z.object({
79
+ basketId: z.string(),
80
+ status: z.enum(['active', 'checked_out', 'abandoned', 'expired'])
81
+ });
82
+ async execute(input: z.infer<typeof this.inputSchema>) {
83
+ const userBasket = await Baskets.getById(input.basketId);
84
+ return userBasket.updateStatus(input.status as BasketStatus);
85
+ }
86
+ }
87
+
88
+ //update basket metadata
89
+ export class UpdateBasketMetadataTool implements LuaTool {
90
+ name = "update_basket_metadata";
91
+ description = "Update the metadata of a basket";
92
+ inputSchema = z.object({
93
+ basketId: z.string(),
94
+ metadata: z.object({
95
+ key: z.string(),
96
+ value: z.string()
97
+ })
98
+ });
99
+ async execute(input: z.infer<typeof this.inputSchema>) {
100
+ const userBasket = await Baskets.getById(input.basketId);
101
+ return userBasket.updateMetadata(input.metadata);
102
+ }
103
+ }
104
+
105
+ //check out basket
106
+ export class CheckoutBasketTool implements LuaTool {
107
+ name = "checkout_basket";
108
+ description = "Check out a basket";
109
+ inputSchema = z.object({
110
+ basketId: z.string()
111
+ });
112
+ async execute(input: z.infer<typeof this.inputSchema>) {
113
+ const userBasket = await Baskets.getById(input.basketId);
114
+ return userBasket.placeOrder({});
115
+ }
116
+ }
117
+
118
+ //get basket by id
119
+ export class GetBasketByIdTool implements LuaTool {
120
+ name = "get_basket_by_id";
121
+ description = "Get a basket by id";
122
+ inputSchema = z.object({
123
+ basketId: z.string()
124
+ });
125
+ async execute(input: z.infer<typeof this.inputSchema>) {
126
+ return Baskets.getById(input.basketId);
127
+ }
128
+ }
@@ -1,10 +1,7 @@
1
- import { LuaTool } from "lua-cli/skill";
1
+ import { LuaTool, Data } from "lua-cli";
2
2
  import { z } from "zod";
3
- import { customData } from 'lua-cli/custom-data-api';
4
3
 
5
4
  // Movie data schema
6
-
7
-
8
5
  export class CreateMovieTool implements LuaTool {
9
6
  name = "create_movie";
10
7
  description = "Add a new movie to the movies database";
@@ -25,10 +22,7 @@ export class CreateMovieTool implements LuaTool {
25
22
  searchText: z.string().optional().describe("Optional search text for better discoverability")
26
23
  });
27
24
  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
- });
25
+ return Data.create("movies", input.movie, input.searchText || `${input.movie.title} ${input.movie.director} ${input.movie.genre.join(' ')} ${input.movie.year}`);
32
26
  }
33
27
  }
34
28
 
@@ -47,7 +41,7 @@ export class GetMoviesTool implements LuaTool {
47
41
  limit: z.number().min(1).max(100).default(10).describe("Number of movies per page")
48
42
  });
49
43
  async execute(input: z.infer<typeof this.inputSchema>) {
50
- return customData.get("movies", input.filter, input.page, input.limit);
44
+ return Data.get("movies", input.filter, input.page, input.limit);
51
45
  }
52
46
  }
53
47
 
@@ -58,7 +52,7 @@ export class GetMovieByIdTool implements LuaTool {
58
52
  movieId: z.string().describe("The unique ID of the movie to retrieve")
59
53
  });
60
54
  async execute(input: z.infer<typeof this.inputSchema>) {
61
- return customData.getEntry("movies", input.movieId);
55
+ return Data.getEntry("movies", input.movieId);
62
56
  }
63
57
  }
64
58
 
@@ -87,7 +81,7 @@ export class UpdateMovieTool implements LuaTool {
87
81
  if (input.searchText) {
88
82
  updateData.searchText = input.searchText;
89
83
  }
90
- return customData.update("movies", input.movieId, updateData);
84
+ return Data.update("movies", input.movieId, updateData);
91
85
  }
92
86
  }
93
87
 
@@ -100,7 +94,7 @@ export class SearchMoviesTool implements LuaTool {
100
94
  scoreThreshold: z.number().min(0).max(1).default(0.3).describe("Minimum similarity score (0-1)")
101
95
  });
102
96
  async execute(input: z.infer<typeof this.inputSchema>) {
103
- return customData.search("movies", input.searchText, input.limit, input.scoreThreshold);
97
+ return Data.search("movies", input.searchText, input.limit, input.scoreThreshold);
104
98
  }
105
99
  }
106
100
 
@@ -111,6 +105,6 @@ export class DeleteMovieTool implements LuaTool {
111
105
  movieId: z.string().describe("The unique ID of the movie to delete")
112
106
  });
113
107
  async execute(input: z.infer<typeof this.inputSchema>) {
114
- return customData.delete("movies", input.movieId);
108
+ return Data.delete("movies", input.movieId);
115
109
  }
116
110
  }
@@ -0,0 +1,54 @@
1
+ import { LuaTool, Orders, } from "lua-cli";
2
+ import { z } from "zod";
3
+ import { OrderStatus } from 'lua-cli';
4
+
5
+
6
+
7
+ export class CreateOrderTool implements LuaTool {
8
+ name = "create_order";
9
+ description = "Create a new order";
10
+ inputSchema = z.object({
11
+ order: z.object({
12
+ basketId: z.string(),
13
+ data: z.object({
14
+ storeId: z.string(),
15
+ }).optional()
16
+ })
17
+ });
18
+ async execute(input: z.infer<typeof this.inputSchema>) {
19
+ return Orders.create(input.order);
20
+ }
21
+ }
22
+
23
+ export class UpdateOrderStatusTool implements LuaTool {
24
+ name = "update_order_status";
25
+ description = "Update the status of an order";
26
+ inputSchema = z.object({
27
+ orderId: z.string(),
28
+ status: z.enum(['pending', 'confirmed', 'fulfilled', 'cancelled'])
29
+ });
30
+ async execute(input: z.infer<typeof this.inputSchema>) {
31
+ const order = await Orders.getById(input.orderId);
32
+ return order.updateStatus(input.status as OrderStatus);
33
+ }
34
+ }
35
+
36
+ export class GetUserOrdersTool implements LuaTool {
37
+ name = "get_user_orders";
38
+ description = "Get all orders for a user";
39
+ inputSchema = z.object({});
40
+ async execute(input: z.infer<typeof this.inputSchema>) {
41
+ return Orders.get();
42
+ }
43
+ }
44
+
45
+ export class GetOrderByIdTool implements LuaTool {
46
+ name = "get_order_by_id";
47
+ description = "Get an order by id";
48
+ inputSchema = z.object({
49
+ orderId: z.string()
50
+ });
51
+ async execute(input: z.infer<typeof this.inputSchema>) {
52
+ return Orders.getById(input.orderId);
53
+ }
54
+ }
@@ -1,4 +1,4 @@
1
- import { LuaTool, env } from "lua-cli/skill";
1
+ import { LuaTool, env } from "lua-cli";
2
2
  import { z } from "zod";
3
3
 
4
4
  export default class CreatePaymentLinkTool implements LuaTool {