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.
- package/API_REFERENCE.md +1408 -0
- package/CLI_REFERENCE.md +818 -0
- package/GETTING_STARTED.md +1040 -0
- package/README.md +738 -424
- package/TEMPLATE_GUIDE.md +1398 -0
- package/dist/api/agent.api.service.d.ts +33 -6
- package/dist/api/agent.api.service.js +27 -0
- package/dist/api/auth.api.service.d.ts +31 -2
- package/dist/api/auth.api.service.js +29 -0
- package/dist/api/basket.api.service.d.ts +53 -11
- package/dist/api/basket.api.service.js +63 -14
- package/dist/api/chat.api.service.d.ts +15 -3
- package/dist/api/chat.api.service.js +12 -0
- package/dist/api/credentials.d.ts +24 -0
- package/dist/api/credentials.js +46 -0
- package/dist/api/custom.data.api.service.d.ts +45 -9
- package/dist/api/custom.data.api.service.js +43 -9
- package/dist/api/lazy-instances.d.ts +49 -0
- package/dist/api/lazy-instances.js +95 -0
- package/dist/api/order.api.service.d.ts +34 -4
- package/dist/api/order.api.service.js +41 -3
- package/dist/api/products.api.service.d.ts +39 -9
- package/dist/api/products.api.service.js +43 -5
- package/dist/api/skills.api.service.d.ts +49 -2
- package/dist/api/skills.api.service.js +47 -1
- package/dist/api/tool.api.service.d.ts +39 -1
- package/dist/api/tool.api.service.js +38 -0
- package/dist/api/user.data.api.service.d.ts +23 -1
- package/dist/api/user.data.api.service.js +22 -0
- package/dist/api-exports.d.ts +236 -5
- package/dist/api-exports.js +264 -81
- package/dist/cli/command-definitions.d.ts +30 -0
- package/dist/cli/command-definitions.js +71 -0
- package/dist/commands/agents.d.ts +20 -0
- package/dist/commands/agents.js +24 -2
- package/dist/commands/apiKey.d.ts +23 -0
- package/dist/commands/apiKey.js +23 -0
- package/dist/commands/compile.d.ts +24 -0
- package/dist/commands/compile.js +67 -759
- package/dist/commands/configure.d.ts +24 -0
- package/dist/commands/configure.js +31 -96
- package/dist/commands/deploy.d.ts +31 -19
- package/dist/commands/deploy.js +45 -74
- package/dist/commands/destroy.d.ts +27 -0
- package/dist/commands/destroy.js +27 -1
- package/dist/commands/dev.d.ts +25 -62
- package/dist/commands/dev.js +58 -878
- package/dist/commands/init.d.ts +27 -0
- package/dist/commands/init.js +98 -260
- package/dist/commands/push.d.ts +24 -21
- package/dist/commands/push.js +39 -92
- package/dist/commands/test.d.ts +26 -0
- package/dist/commands/test.js +41 -188
- package/dist/common/basket.instance.d.ts +54 -3
- package/dist/common/basket.instance.js +56 -3
- package/dist/common/data.entry.instance.d.ts +25 -2
- package/dist/common/data.entry.instance.js +24 -0
- package/dist/common/http.client.d.ts +51 -1
- package/dist/common/http.client.js +50 -0
- package/dist/common/order.instance.d.ts +22 -0
- package/dist/common/order.instance.js +31 -4
- package/dist/common/product.instance.d.ts +22 -1
- package/dist/common/product.instance.js +24 -6
- package/dist/common/product.pagination.instance.d.ts +22 -2
- package/dist/common/product.pagination.instance.js +22 -1
- package/dist/common/product.search.instance.d.ts +13 -3
- package/dist/common/product.search.instance.js +12 -1
- package/dist/common/user.instance.d.ts +27 -3
- package/dist/common/user.instance.js +28 -7
- package/dist/config/auth.constants.d.ts +11 -0
- package/dist/config/auth.constants.js +11 -0
- package/dist/config/compile.constants.d.ts +67 -0
- package/dist/config/compile.constants.js +99 -0
- package/dist/config/constants.d.ts +5 -0
- package/dist/config/constants.js +5 -0
- package/dist/config/dev.constants.d.ts +65 -0
- package/dist/config/dev.constants.js +79 -0
- package/dist/config/init.constants.d.ts +23 -0
- package/dist/config/init.constants.js +41 -0
- package/dist/index.d.ts +19 -3
- package/dist/index.js +28 -44
- package/dist/interfaces/admin.d.ts +56 -50
- package/dist/interfaces/admin.js +4 -0
- package/dist/interfaces/agent.d.ts +21 -0
- package/dist/interfaces/agent.js +4 -0
- package/dist/interfaces/baskets.d.ts +60 -0
- package/dist/interfaces/baskets.js +12 -0
- package/dist/interfaces/chat.d.ts +48 -4
- package/dist/interfaces/chat.js +4 -0
- package/dist/interfaces/common.d.ts +62 -0
- package/dist/interfaces/common.js +8 -0
- package/dist/interfaces/compile.d.ts +11 -0
- package/dist/interfaces/compile.js +4 -0
- package/dist/interfaces/custom.data.d.ts +49 -19
- package/dist/interfaces/custom.data.js +4 -0
- package/dist/interfaces/deploy.d.ts +29 -0
- package/dist/interfaces/deploy.js +4 -0
- package/dist/interfaces/dev.d.ts +53 -0
- package/dist/interfaces/dev.js +5 -0
- package/dist/interfaces/init.d.ts +60 -0
- package/dist/interfaces/init.js +4 -0
- package/dist/interfaces/orders.d.ts +37 -0
- package/dist/interfaces/orders.js +12 -0
- package/dist/interfaces/product.d.ts +38 -10
- package/dist/interfaces/product.js +4 -0
- package/dist/interfaces/push.d.ts +26 -0
- package/dist/interfaces/push.js +4 -0
- package/dist/interfaces/test.d.ts +36 -0
- package/dist/interfaces/test.js +4 -0
- package/dist/services/auth.d.ts +54 -99
- package/dist/services/auth.js +76 -12
- package/dist/types/api-contracts.d.ts +211 -0
- package/dist/types/api-contracts.js +8 -0
- package/dist/types/compile.types.d.ts +76 -0
- package/dist/types/compile.types.js +4 -0
- package/dist/types/index.d.ts +23 -121
- package/dist/types/index.js +25 -14
- package/dist/types/skill.d.ts +142 -0
- package/dist/{skill.js → types/skill.js} +66 -17
- package/dist/types/tool-validation.d.ts +34 -0
- package/dist/types/tool-validation.js +42 -0
- package/dist/utils/auth-flows.d.ts +26 -0
- package/dist/utils/auth-flows.js +141 -0
- package/dist/utils/bundling.d.ts +36 -0
- package/dist/utils/bundling.js +137 -0
- package/dist/utils/compile.d.ts +37 -0
- package/dist/utils/compile.js +242 -0
- package/dist/utils/deploy-api.d.ts +26 -0
- package/dist/utils/deploy-api.js +53 -0
- package/dist/utils/deploy-helpers.d.ts +46 -0
- package/dist/utils/deploy-helpers.js +86 -0
- package/dist/utils/deployment.d.ts +25 -0
- package/dist/utils/deployment.js +161 -0
- package/dist/utils/dev-api.d.ts +61 -0
- package/dist/utils/dev-api.js +262 -0
- package/dist/utils/dev-helpers.d.ts +46 -0
- package/dist/utils/dev-helpers.js +83 -0
- package/dist/utils/dev-server.d.ts +24 -0
- package/dist/utils/dev-server.js +555 -0
- package/dist/utils/dev-watcher.d.ts +31 -0
- package/dist/utils/dev-watcher.js +110 -0
- package/dist/utils/files.js +0 -5
- package/dist/utils/init-agent.d.ts +34 -0
- package/dist/utils/init-agent.js +129 -0
- package/dist/utils/init-helpers.d.ts +41 -0
- package/dist/utils/init-helpers.js +73 -0
- package/dist/utils/init-prompts.d.ts +47 -0
- package/dist/utils/init-prompts.js +168 -0
- package/dist/utils/push-api.d.ts +15 -0
- package/dist/utils/push-api.js +48 -0
- package/dist/utils/push-helpers.d.ts +38 -0
- package/dist/utils/push-helpers.js +84 -0
- package/dist/utils/sandbox-storage.d.ts +27 -0
- package/dist/utils/sandbox-storage.js +71 -0
- package/dist/utils/sandbox.js +78 -114
- package/dist/utils/skill-management.d.ts +14 -0
- package/dist/utils/skill-management.js +148 -0
- package/dist/utils/test-helpers.d.ts +40 -0
- package/dist/utils/test-helpers.js +92 -0
- package/dist/utils/test-prompts.d.ts +23 -0
- package/dist/utils/test-prompts.js +186 -0
- package/dist/utils/tool-detection.d.ts +18 -0
- package/dist/utils/tool-detection.js +110 -0
- package/dist/web/app.css +941 -17
- package/dist/web/app.js +174 -22
- package/dist/web/index.html +7 -1
- package/package.json +13 -4
- package/template/QUICKSTART.md +299 -144
- package/template/README.md +928 -349
- package/template/TOOL_EXAMPLES.md +655 -0
- package/template/package-lock.json +5 -5
- package/template/package.json +1 -1
- package/template/src/index.ts +147 -207
- package/template/src/tools/BasketTool.ts +128 -0
- package/template/src/tools/CustomDataTool.ts +7 -13
- package/template/src/tools/OrderTool.ts +54 -0
- package/template/src/tools/PaymentTool.ts +1 -1
- package/template/src/tools/ProductsTool.ts +56 -118
- package/template/src/tools/UserDataTool.ts +4 -26
- package/dist/common/config.d.ts +0 -5
- package/dist/common/config.js +0 -5
- package/dist/custom-data-api.d.ts +0 -72
- package/dist/custom-data-api.js +0 -174
- package/dist/product-api.d.ts +0 -189
- package/dist/product-api.js +0 -141
- package/dist/services/api.d.ts +0 -549
- package/dist/services/api.js +0 -596
- package/dist/skill.d.ts +0 -50
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -2
- package/dist/user-data-api.d.ts +0 -39
- package/dist/user-data-api.js +0 -50
- package/template/API.md +0 -604
- package/template/DEVELOPER.md +0 -771
- package/template/lua.skill.yaml +0 -7
package/template/src/index.ts
CHANGED
|
@@ -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
|
-
|
|
3
|
+
import { GetUserDataTool, UpdateUserDataTool } from "./tools/UserDataTool";
|
|
4
4
|
import CreatePostTool from "./tools/CreatePostTool";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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: "
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
// 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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
+
}
|