lua-cli 2.2.8-alpha.1 → 2.3.0-alpha.1

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 (191) 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 +45 -0
  7. package/dist/api/agent.api.service.js +57 -0
  8. package/dist/api/auth.api.service.d.ts +48 -0
  9. package/dist/api/auth.api.service.js +54 -0
  10. package/dist/api/basket.api.service.d.ts +85 -0
  11. package/dist/api/basket.api.service.js +164 -0
  12. package/dist/api/chat.api.service.d.ts +21 -0
  13. package/dist/api/chat.api.service.js +24 -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 +69 -0
  17. package/dist/api/custom.data.api.service.js +125 -0
  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 +53 -0
  21. package/dist/api/order.api.service.js +95 -0
  22. package/dist/api/products.api.service.d.ts +66 -0
  23. package/dist/api/products.api.service.js +112 -0
  24. package/dist/api/skills.api.service.d.ts +77 -0
  25. package/dist/api/skills.api.service.js +88 -0
  26. package/dist/api/tool.api.service.d.ts +52 -0
  27. package/dist/api/tool.api.service.js +73 -0
  28. package/dist/api/user.data.api.service.d.ts +33 -0
  29. package/dist/api/user.data.api.service.js +59 -0
  30. package/dist/api-exports.d.ts +271 -0
  31. package/dist/api-exports.js +372 -0
  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 -873
  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 +78 -0
  55. package/dist/common/basket.instance.js +132 -0
  56. package/dist/common/data.entry.instance.d.ts +39 -0
  57. package/dist/common/data.entry.instance.js +76 -0
  58. package/dist/common/http.client.d.ts +64 -0
  59. package/dist/common/http.client.js +133 -0
  60. package/dist/common/order.instance.d.ts +40 -0
  61. package/dist/common/order.instance.js +79 -0
  62. package/dist/common/product.instance.d.ts +33 -0
  63. package/dist/common/product.instance.js +63 -0
  64. package/dist/common/product.pagination.instance.d.ts +43 -0
  65. package/dist/common/product.pagination.instance.js +74 -0
  66. package/dist/common/product.search.instance.d.ts +22 -0
  67. package/dist/common/product.search.instance.js +40 -0
  68. package/dist/common/user.instance.d.ts +41 -0
  69. package/dist/common/user.instance.js +84 -0
  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 +101 -0
  83. package/dist/interfaces/admin.js +5 -0
  84. package/dist/interfaces/agent.d.ts +107 -0
  85. package/dist/interfaces/agent.js +5 -0
  86. package/dist/interfaces/baskets.d.ts +135 -0
  87. package/dist/interfaces/baskets.js +19 -0
  88. package/dist/interfaces/chat.d.ts +61 -0
  89. package/dist/interfaces/chat.js +5 -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 +82 -0
  95. package/dist/interfaces/custom.data.js +5 -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 +91 -0
  103. package/dist/interfaces/orders.js +19 -0
  104. package/dist/interfaces/product.d.ts +65 -0
  105. package/dist/interfaces/product.js +5 -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 -85
  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 -19
  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 -118
  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 +14 -9
  165. package/package.json +11 -12
  166. package/template/QUICKSTART.md +299 -144
  167. package/template/README.md +928 -349
  168. package/template/TOOL_EXAMPLES.md +655 -0
  169. package/template/package-lock.json +3781 -0
  170. package/template/package.json +1 -1
  171. package/template/src/index.ts +81 -40
  172. package/template/src/tools/BasketTool.ts +128 -0
  173. package/template/src/tools/CustomDataTool.ts +7 -13
  174. package/template/src/tools/OrderTool.ts +54 -0
  175. package/template/src/tools/PaymentTool.ts +1 -1
  176. package/template/src/tools/ProductsTool.ts +56 -118
  177. package/template/src/tools/UserDataTool.ts +4 -27
  178. package/dist/custom-data-api.d.ts +0 -72
  179. package/dist/custom-data-api.js +0 -174
  180. package/dist/product-api.d.ts +0 -197
  181. package/dist/product-api.js +0 -152
  182. package/dist/services/api.d.ts +0 -569
  183. package/dist/services/api.js +0 -625
  184. package/dist/skill.d.ts +0 -50
  185. package/dist/types.d.ts +0 -1
  186. package/dist/types.js +0 -2
  187. package/dist/user-data-api.d.ts +0 -39
  188. package/dist/user-data-api.js +0 -50
  189. package/template/API.md +0 -604
  190. package/template/DEVELOPER.md +0 -771
  191. package/template/lua.skill.yaml +0 -16
@@ -19,7 +19,7 @@
19
19
  "axios": "^1.6.0",
20
20
  "inquirer": "^12.9.6",
21
21
  "js-yaml": "^4.1.0",
22
- "lua-cli": "2.2.8-alpha.1",
22
+ "lua-cli": "^2.3.0-alpha.1",
23
23
  "openai": "^5.23.0",
24
24
  "uuid": "^13.0.0",
25
25
  "zod": "^3.24.1"
@@ -1,9 +1,11 @@
1
- import { LuaSkill } from "lua-cli/skill";
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";
5
+ import { SearchProductsTool, CreateProductTool, UpdateProductTool, GetAllProductsTool, GetProductByIdTool, DeleteProductTool } from "./tools/ProductsTool";
6
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";
7
9
  import { CreateMovieTool, GetMoviesTool, GetMovieByIdTool, UpdateMovieTool, SearchMoviesTool, DeleteMovieTool } from "./tools/CustomDataTool";
8
10
 
9
11
 
@@ -12,16 +14,13 @@ const generalSkill = new LuaSkill({
12
14
  name: "general-skill",
13
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
+ ]
16
22
  });
17
23
 
18
-
19
- generalSkill.addTools([
20
- new GetWeatherTool(),
21
- new CreatePostTool()
22
- ]);
23
-
24
-
25
24
  const userDataSkill = new LuaSkill({
26
25
  name: "user-data-skill",
27
26
  version: "0.0.1",
@@ -29,38 +28,59 @@ const userDataSkill = new LuaSkill({
29
28
  context: "This skill provides various utilities including user data retrieval, creation, and updating.",
30
29
  tools: [
31
30
  new GetUserDataTool(),
32
- new CreateUserDataTool(),
33
31
  new UpdateUserDataTool()
34
32
  ]
35
33
  });
36
34
 
37
35
 
38
- const eccomerceSkill = new LuaSkill({
39
- name: "eccomerce-skill",
36
+ const productSkill = new LuaSkill({
37
+ name: "product-skill",
40
38
  version: "0.0.1",
41
- description: "A specific Lua skill with eccomerce",
42
- context: "This skill provides various utilities including eccomerce."
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
+ ]
43
49
  });
44
50
 
45
- eccomerceSkill.addTools([
46
- new SearchProductsTool(),
47
- new GetAllProductsTool(),
48
- new CreateProductTool(),
49
- new UpdateProductTool(),
50
- new DeleteProductTool(),
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()
61
- ]);
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
+ ]
68
+ });
62
69
 
63
70
 
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
+
64
84
  const customDataSkill = new LuaSkill({
65
85
  name: "custom-data-skill",
66
86
  version: "0.0.1",
@@ -76,6 +96,16 @@ const customDataSkill = new LuaSkill({
76
96
  ]
77
97
  });
78
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
+
79
109
  // Test cases
80
110
  const testCases = [
81
111
  { tool: "get_weather", city: "London" },
@@ -94,15 +124,26 @@ async function runTests() {
94
124
  // await seedProducts();
95
125
  console.log("🧪 Running tool tests...\n");
96
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
+
97
138
  for (const [index, testCase] of testCases.entries()) {
98
139
  try {
99
- console.log(`Test ${index + 1}: ${testCase.tool}`);
100
- const resultGeneral = await generalSkill.run(testCase);
101
- console.log("✅ Success:", resultGeneral);
102
- const resultUserData = await userDataSkill.run(testCase);
103
- console.log("✅ Success:", resultUserData);
104
- const resultEccomerce = await eccomerceSkill.run(testCase);
105
- console.log("✅ Success:", resultEccomerce);
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);
106
147
  } catch (error: any) {
107
148
  console.log("❌ Error:", error.message);
108
149
  }
@@ -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 {
@@ -1,6 +1,6 @@
1
- import { env, LuaTool } from "lua-cli/skill";
1
+ import { LuaTool, Products } from "lua-cli";
2
2
  import { z } from "zod";
3
- import { product, BasketStatus, OrderStatus, CreateOrderRequest } from 'lua-cli/product-api';
3
+ import { BasketStatus, OrderStatus } from 'lua-cli';
4
4
  import { v4 as uuidv4 } from 'uuid';
5
5
  export class SearchProductsTool implements LuaTool {
6
6
  name = "search_products";
@@ -12,7 +12,7 @@ export class SearchProductsTool implements LuaTool {
12
12
  constructor() {}
13
13
 
14
14
  async execute(input: z.infer<typeof this.inputSchema>) {
15
- return await product.data.search(input.query);
15
+ return await Products.search(input.query);
16
16
  }
17
17
  }
18
18
 
@@ -25,7 +25,7 @@ export class GetAllProductsTool implements LuaTool {
25
25
  });
26
26
 
27
27
  async execute(input: z.infer<typeof this.inputSchema>) {
28
- return product.data.get(input.page, input.limit);
28
+ return await Products.get(input.page, input.limit);
29
29
  }
30
30
  }
31
31
 
@@ -41,7 +41,7 @@ export class CreateProductTool implements LuaTool {
41
41
  });
42
42
 
43
43
  async execute(input: z.infer<typeof this.inputSchema>) {
44
- return product.data.create({...input.product, id: uuidv4()});
44
+ return Products.create({...input.product, id: uuidv4()});
45
45
  }
46
46
  }
47
47
 
@@ -58,133 +58,71 @@ export class UpdateProductTool implements LuaTool {
58
58
  });
59
59
 
60
60
  async execute(input: z.infer<typeof this.inputSchema>) {
61
- return product.data.update({...input.product, id: uuidv4()}, input.product.id);
62
- }
63
- }
64
-
65
- export class DeleteProductTool implements LuaTool {
66
- name = "delete_product";
67
- description = "Delete an existing product";
68
- inputSchema = z.object({
69
- id: z.string()
70
- });
71
-
72
- async execute(input: z.infer<typeof this.inputSchema>) {
73
- return product.data.delete(input.id);
61
+ return Products.update({...input.product, id: uuidv4()}, input.product.id);
74
62
  }
75
63
  }
76
64
 
77
- export class CreateBasketTool implements LuaTool {
78
- name = "create_basket";
79
- description = "Create a new basket";
65
+ export class GetProductByIdTool implements LuaTool {
66
+ name = "get_product_by_id";
67
+ description = "Get a product by its unique identifier";
80
68
  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()
69
+ id: z.string()
124
70
  });
125
- async execute(input: z.infer<typeof this.inputSchema>) {
126
- return product.basket.removeItem(input.basketId, input.itemId);
127
- }
128
- }
129
71
 
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
72
  async execute(input: z.infer<typeof this.inputSchema>) {
137
- return product.basket.clear(input.basketId);
73
+ return Products.getById(input.id);
138
74
  }
139
75
  }
140
-
141
- export class UpdateBasketStatusTool implements LuaTool {
142
- name = "update_basket_status";
143
- description = "Update the status of a basket";
76
+
77
+ export class DeleteProductTool implements LuaTool {
78
+ name = "delete_product";
79
+ description = "Delete an existing product";
144
80
  inputSchema = z.object({
145
- basketId: z.string(),
146
- status: z.enum(['active', 'checked_out', 'abandoned', 'expired'])
81
+ id: z.string()
147
82
  });
148
- async execute(input: z.infer<typeof this.inputSchema>) {
149
- return product.basket.updateStatus(input.basketId, input.status as BasketStatus);
150
- }
151
- }
152
83
 
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
84
  async execute(input: z.infer<typeof this.inputSchema>) {
165
- return product.order.create(input.order as CreateOrderRequest);
85
+ const product = await Products.getById(input.id);
86
+ return product.delete();
166
87
  }
167
88
  }
168
89
 
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
90
 
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
- }
91
+ // export class CreateOrderTool implements LuaTool {
92
+ // name = "create_order";
93
+ // description = "Create a new order";
94
+ // inputSchema = z.object({
95
+ // order: z.object({
96
+ // basketId: z.string(),
97
+ // data: z.object({
98
+ // storeId: z.string(),
99
+ // }).optional()
100
+ // })
101
+ // });
102
+ // async execute(input: z.infer<typeof this.inputSchema>) {
103
+ // return product.order.create(input.order as CreateOrderRequest);
104
+ // }
105
+ // }
106
+
107
+ // export class UpdateOrderStatusTool implements LuaTool {
108
+ // name = "update_order_status";
109
+ // description = "Update the status of an order";
110
+ // inputSchema = z.object({
111
+ // orderId: z.string(),
112
+ // status: z.enum(['pending', 'confirmed', 'fulfilled', 'cancelled'])
113
+ // });
114
+ // async execute(input: z.infer<typeof this.inputSchema>) {
115
+ // return product.order.updateStatus(input.orderId, input.status as OrderStatus);
116
+ // }
117
+ // }
118
+
119
+ // export class GetUserOrdersTool implements LuaTool {
120
+ // name = "get_user_orders";
121
+ // description = "Get all orders for a user";
122
+ // inputSchema = z.object({
123
+ // userId: z.string()
124
+ // });
125
+ // async execute(input: z.infer<typeof this.inputSchema>) {
126
+ // return product.order.get(input.userId);
127
+ // }
128
+ // }