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/dist/api-exports.js
CHANGED
|
@@ -1,189 +1,372 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Lua Skill API Exports
|
|
3
|
+
*
|
|
4
|
+
* Public API surface for LuaSkill tools.
|
|
5
|
+
* This module provides simplified interfaces to Lua platform APIs
|
|
6
|
+
* for use within skill implementations.
|
|
7
|
+
*
|
|
8
|
+
* Available APIs:
|
|
9
|
+
* - User: User data management
|
|
10
|
+
* - Data: Custom data collections (vector search, CRUD)
|
|
11
|
+
* - Products: Product catalog management
|
|
12
|
+
* - Baskets: Shopping basket operations
|
|
13
|
+
* - Orders: Order management
|
|
14
|
+
*
|
|
15
|
+
* Usage in skills:
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { User, Data, Products, Baskets, Orders } from 'lua-cli';
|
|
18
|
+
*
|
|
19
|
+
* // Get user data
|
|
20
|
+
* const user = await User.get();
|
|
21
|
+
*
|
|
22
|
+
* // Create custom data entry
|
|
23
|
+
* await Data.create('customers', { name: 'John' });
|
|
24
|
+
*
|
|
25
|
+
* // Search products
|
|
26
|
+
* const products = await Products.search('laptop');
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import { LuaSkill, env } from "./types/skill.js";
|
|
3
30
|
import { BasketStatus } from "./interfaces/baskets.js";
|
|
4
31
|
import { OrderStatus } from "./interfaces/orders.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import CustomDataApiService from "./api/custom.data.api.service.js";
|
|
14
|
-
async function getCredentials() {
|
|
15
|
-
// Load API key from keystore
|
|
16
|
-
const apiKey = await loadApiKey();
|
|
17
|
-
if (!apiKey) {
|
|
18
|
-
throw new Error('No API key found. Please run "lua auth configure" first.');
|
|
19
|
-
}
|
|
20
|
-
// Load agent ID from YAML file
|
|
21
|
-
const config = readSkillConfig();
|
|
22
|
-
if (!config?.agent?.agentId) {
|
|
23
|
-
throw new Error('No agent ID found in lua.skill.yaml. Please run "lua init" first.');
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
apiKey,
|
|
27
|
-
agentId: config.agent.agentId
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
// Lazy-loaded API instances to avoid top-level await
|
|
31
|
-
let _userInstance = null;
|
|
32
|
-
let _dataInstance = null;
|
|
33
|
-
let _productsInstance = null;
|
|
34
|
-
let _basketsInstance = null;
|
|
35
|
-
let _orderInstance = null;
|
|
36
|
-
async function getUserInstance() {
|
|
37
|
-
if (!_userInstance) {
|
|
38
|
-
const creds = await getCredentials();
|
|
39
|
-
_userInstance = new UserDataApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
|
|
40
|
-
}
|
|
41
|
-
return _userInstance;
|
|
42
|
-
}
|
|
43
|
-
async function getDataInstance() {
|
|
44
|
-
if (!_dataInstance) {
|
|
45
|
-
const creds = await getCredentials();
|
|
46
|
-
_dataInstance = new CustomDataApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
|
|
47
|
-
}
|
|
48
|
-
return _dataInstance;
|
|
49
|
-
}
|
|
50
|
-
async function getProductsInstance() {
|
|
51
|
-
if (!_productsInstance) {
|
|
52
|
-
const creds = await getCredentials();
|
|
53
|
-
_productsInstance = new ProductApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
|
|
54
|
-
}
|
|
55
|
-
return _productsInstance;
|
|
56
|
-
}
|
|
57
|
-
async function getBasketsInstance() {
|
|
58
|
-
if (!_basketsInstance) {
|
|
59
|
-
const creds = await getCredentials();
|
|
60
|
-
_basketsInstance = new BasketApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
|
|
61
|
-
}
|
|
62
|
-
return _basketsInstance;
|
|
63
|
-
}
|
|
64
|
-
async function getOrderInstance() {
|
|
65
|
-
if (!_orderInstance) {
|
|
66
|
-
const creds = await getCredentials();
|
|
67
|
-
_orderInstance = new OrderApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
|
|
68
|
-
}
|
|
69
|
-
return _orderInstance;
|
|
70
|
-
}
|
|
32
|
+
import { getUserInstance, getDataInstance, getProductsInstance, getBasketsInstance, getOrderInstance, } from "./api/lazy-instances.js";
|
|
33
|
+
// ============================================================================
|
|
34
|
+
// USER DATA API
|
|
35
|
+
// ============================================================================
|
|
36
|
+
/**
|
|
37
|
+
* User Data API
|
|
38
|
+
* Access user information and preferences
|
|
39
|
+
*/
|
|
71
40
|
export const User = {
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves current user data.
|
|
43
|
+
*
|
|
44
|
+
* @returns Promise resolving to user data
|
|
45
|
+
*/
|
|
72
46
|
async get() {
|
|
73
47
|
const instance = await getUserInstance();
|
|
74
48
|
return instance.get();
|
|
75
|
-
},
|
|
76
|
-
async update(data) {
|
|
77
|
-
const instance = await getUserInstance();
|
|
78
|
-
return instance.update(data);
|
|
79
|
-
},
|
|
80
|
-
async clear() {
|
|
81
|
-
const instance = await getUserInstance();
|
|
82
|
-
return instance.clear();
|
|
83
49
|
}
|
|
84
50
|
};
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// CUSTOM DATA API
|
|
53
|
+
// ============================================================================
|
|
54
|
+
/**
|
|
55
|
+
* Custom Data API
|
|
56
|
+
* Store and retrieve custom data with vector search capabilities
|
|
57
|
+
*/
|
|
85
58
|
export const Data = {
|
|
59
|
+
/**
|
|
60
|
+
* Creates a new entry in a custom data collection.
|
|
61
|
+
*
|
|
62
|
+
* @param collectionName - Name of the collection
|
|
63
|
+
* @param data - Data to store
|
|
64
|
+
* @param searchText - Optional text for vector search indexing
|
|
65
|
+
* @returns Promise resolving to created entry
|
|
66
|
+
*/
|
|
86
67
|
async create(collectionName, data, searchText) {
|
|
87
68
|
const instance = await getDataInstance();
|
|
88
|
-
console.log('collectionName', collectionName);
|
|
89
|
-
console.log('data', data);
|
|
90
|
-
console.log('searchText', searchText);
|
|
91
69
|
return instance.create(collectionName, data, searchText);
|
|
92
70
|
},
|
|
71
|
+
/**
|
|
72
|
+
* Retrieves entries from a collection with optional filtering and pagination.
|
|
73
|
+
*
|
|
74
|
+
* @param collectionName - Name of the collection
|
|
75
|
+
* @param filter - Optional filter criteria
|
|
76
|
+
* @param page - Page number (default: 1)
|
|
77
|
+
* @param limit - Items per page (default: 10)
|
|
78
|
+
* @returns Promise resolving to array of entries
|
|
79
|
+
*/
|
|
93
80
|
async get(collectionName, filter, page, limit) {
|
|
94
81
|
const instance = await getDataInstance();
|
|
95
82
|
return instance.get(collectionName, filter, page, limit);
|
|
96
83
|
},
|
|
84
|
+
/**
|
|
85
|
+
* Retrieves a specific entry by ID.
|
|
86
|
+
*
|
|
87
|
+
* @param collectionName - Name of the collection
|
|
88
|
+
* @param entryId - ID of the entry
|
|
89
|
+
* @returns Promise resolving to entry data
|
|
90
|
+
*/
|
|
97
91
|
async getEntry(collectionName, entryId) {
|
|
98
92
|
const instance = await getDataInstance();
|
|
99
93
|
return instance.getEntry(collectionName, entryId);
|
|
100
94
|
},
|
|
95
|
+
/**
|
|
96
|
+
* Updates an existing entry.
|
|
97
|
+
*
|
|
98
|
+
* @param collectionName - Name of the collection
|
|
99
|
+
* @param entryId - ID of the entry to update
|
|
100
|
+
* @param data - Updated data
|
|
101
|
+
* @returns Promise resolving to updated entry
|
|
102
|
+
*/
|
|
101
103
|
async update(collectionName, entryId, data) {
|
|
102
104
|
const instance = await getDataInstance();
|
|
103
105
|
return instance.update(collectionName, entryId, data);
|
|
104
106
|
},
|
|
107
|
+
/**
|
|
108
|
+
* Performs vector search on a collection.
|
|
109
|
+
*
|
|
110
|
+
* @param collectionName - Name of the collection
|
|
111
|
+
* @param searchText - Text to search for
|
|
112
|
+
* @param limit - Maximum results to return
|
|
113
|
+
* @param scoreThreshold - Minimum similarity score (0-1)
|
|
114
|
+
* @returns Promise resolving to search results
|
|
115
|
+
*/
|
|
105
116
|
async search(collectionName, searchText, limit, scoreThreshold) {
|
|
106
117
|
const instance = await getDataInstance();
|
|
107
118
|
return instance.search(collectionName, searchText, limit, scoreThreshold);
|
|
108
119
|
},
|
|
120
|
+
/**
|
|
121
|
+
* Deletes an entry from a collection.
|
|
122
|
+
*
|
|
123
|
+
* @param collectionName - Name of the collection
|
|
124
|
+
* @param entryId - ID of the entry to delete
|
|
125
|
+
* @returns Promise resolving when deletion is complete
|
|
126
|
+
*/
|
|
109
127
|
async delete(collectionName, entryId) {
|
|
110
128
|
const instance = await getDataInstance();
|
|
111
129
|
return instance.delete(collectionName, entryId);
|
|
112
130
|
}
|
|
113
131
|
};
|
|
132
|
+
// ============================================================================
|
|
133
|
+
// PRODUCTS API
|
|
134
|
+
// ============================================================================
|
|
135
|
+
/**
|
|
136
|
+
* Products API
|
|
137
|
+
* Manage product catalog
|
|
138
|
+
*/
|
|
114
139
|
export const Products = {
|
|
140
|
+
/**
|
|
141
|
+
* Retrieves products with pagination.
|
|
142
|
+
*
|
|
143
|
+
* @param limit - Items per page
|
|
144
|
+
* @param page - Page number
|
|
145
|
+
* @returns Promise resolving to product list
|
|
146
|
+
*/
|
|
115
147
|
async get(limit, page) {
|
|
116
148
|
const instance = await getProductsInstance();
|
|
117
149
|
return instance.get(limit, page);
|
|
118
150
|
},
|
|
151
|
+
/**
|
|
152
|
+
* Creates a new product.
|
|
153
|
+
*
|
|
154
|
+
* @param product - Product data
|
|
155
|
+
* @returns Promise resolving to created product
|
|
156
|
+
*/
|
|
119
157
|
async create(product) {
|
|
120
158
|
const instance = await getProductsInstance();
|
|
121
159
|
return instance.create(product);
|
|
122
160
|
},
|
|
161
|
+
/**
|
|
162
|
+
* Updates an existing product.
|
|
163
|
+
*
|
|
164
|
+
* @param data - Updated product data
|
|
165
|
+
* @param id - Product ID
|
|
166
|
+
* @returns Promise resolving to updated product
|
|
167
|
+
*/
|
|
123
168
|
async update(data, id) {
|
|
124
169
|
const instance = await getProductsInstance();
|
|
125
170
|
return instance.update(data, id);
|
|
126
171
|
},
|
|
172
|
+
/**
|
|
173
|
+
* Deletes a product.
|
|
174
|
+
*
|
|
175
|
+
* @param id - Product ID
|
|
176
|
+
* @returns Promise resolving when deletion is complete
|
|
177
|
+
*/
|
|
127
178
|
async delete(id) {
|
|
128
179
|
const instance = await getProductsInstance();
|
|
129
180
|
return instance.delete(id);
|
|
130
181
|
},
|
|
182
|
+
/**
|
|
183
|
+
* Searches products by query string.
|
|
184
|
+
*
|
|
185
|
+
* @param query - Search query
|
|
186
|
+
* @returns Promise resolving to search results
|
|
187
|
+
*/
|
|
131
188
|
async search(query) {
|
|
132
189
|
const instance = await getProductsInstance();
|
|
133
190
|
return instance.search(query);
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
* Retrieves a specific product by ID.
|
|
194
|
+
*
|
|
195
|
+
* @param id - Product ID
|
|
196
|
+
* @returns Promise resolving to product data
|
|
197
|
+
*/
|
|
198
|
+
async getById(id) {
|
|
199
|
+
const instance = await getProductsInstance();
|
|
200
|
+
return instance.getById(id);
|
|
134
201
|
}
|
|
135
202
|
};
|
|
203
|
+
// ============================================================================
|
|
204
|
+
// BASKETS API
|
|
205
|
+
// ============================================================================
|
|
206
|
+
/**
|
|
207
|
+
* Baskets API
|
|
208
|
+
* Manage shopping baskets
|
|
209
|
+
*/
|
|
136
210
|
export const Baskets = {
|
|
211
|
+
/**
|
|
212
|
+
* Creates a new basket.
|
|
213
|
+
*
|
|
214
|
+
* @param basketData - Basket initialization data
|
|
215
|
+
* @returns Promise resolving to created basket
|
|
216
|
+
*/
|
|
137
217
|
async create(basketData) {
|
|
138
218
|
const instance = await getBasketsInstance();
|
|
139
219
|
return instance.create(basketData);
|
|
140
220
|
},
|
|
221
|
+
/**
|
|
222
|
+
* Retrieves baskets, optionally filtered by status.
|
|
223
|
+
*
|
|
224
|
+
* @param status - Optional basket status filter
|
|
225
|
+
* @returns Promise resolving to basket list
|
|
226
|
+
*/
|
|
141
227
|
async get(status) {
|
|
142
228
|
const instance = await getBasketsInstance();
|
|
143
229
|
return instance.get(status);
|
|
144
230
|
},
|
|
231
|
+
/**
|
|
232
|
+
* Adds an item to a basket.
|
|
233
|
+
*
|
|
234
|
+
* @param basketId - Basket ID
|
|
235
|
+
* @param itemData - Item data to add
|
|
236
|
+
* @returns Promise resolving to updated basket
|
|
237
|
+
*/
|
|
145
238
|
async addItem(basketId, itemData) {
|
|
146
239
|
const instance = await getBasketsInstance();
|
|
147
240
|
return instance.addItem(basketId, itemData);
|
|
148
241
|
},
|
|
242
|
+
/**
|
|
243
|
+
* Removes an item from a basket.
|
|
244
|
+
*
|
|
245
|
+
* @param basketId - Basket ID
|
|
246
|
+
* @param itemId - Item ID to remove
|
|
247
|
+
* @returns Promise resolving to updated basket
|
|
248
|
+
*/
|
|
149
249
|
async removeItem(basketId, itemId) {
|
|
150
250
|
const instance = await getBasketsInstance();
|
|
151
251
|
return instance.removeItem(basketId, itemId);
|
|
152
252
|
},
|
|
253
|
+
/**
|
|
254
|
+
* Clears all items from a basket.
|
|
255
|
+
*
|
|
256
|
+
* @param basketId - Basket ID
|
|
257
|
+
* @returns Promise resolving to cleared basket
|
|
258
|
+
*/
|
|
153
259
|
async clear(basketId) {
|
|
154
260
|
const instance = await getBasketsInstance();
|
|
155
261
|
return instance.clear(basketId);
|
|
156
262
|
},
|
|
263
|
+
/**
|
|
264
|
+
* Updates basket status.
|
|
265
|
+
*
|
|
266
|
+
* @param basketId - Basket ID
|
|
267
|
+
* @param status - New basket status
|
|
268
|
+
* @returns Promise resolving to updated basket
|
|
269
|
+
*/
|
|
157
270
|
async updateStatus(basketId, status) {
|
|
158
271
|
const instance = await getBasketsInstance();
|
|
159
272
|
return instance.updateStatus(basketId, status);
|
|
160
273
|
},
|
|
274
|
+
/**
|
|
275
|
+
* Updates basket metadata.
|
|
276
|
+
*
|
|
277
|
+
* @param basketId - Basket ID
|
|
278
|
+
* @param metadata - Metadata to update
|
|
279
|
+
* @returns Promise resolving to updated basket
|
|
280
|
+
*/
|
|
161
281
|
async updateMetadata(basketId, metadata) {
|
|
162
282
|
const instance = await getBasketsInstance();
|
|
163
283
|
return instance.updateMetadata(basketId, metadata);
|
|
164
284
|
},
|
|
285
|
+
/**
|
|
286
|
+
* Converts basket to order.
|
|
287
|
+
*
|
|
288
|
+
* @param data - Order data
|
|
289
|
+
* @param basketId - Basket ID to convert
|
|
290
|
+
* @returns Promise resolving to created order
|
|
291
|
+
*/
|
|
165
292
|
async placeOrder(data, basketId) {
|
|
166
293
|
const instance = await getBasketsInstance();
|
|
167
294
|
return instance.placeOrder(data, basketId);
|
|
295
|
+
},
|
|
296
|
+
/**
|
|
297
|
+
* Retrieves a specific basket by ID.
|
|
298
|
+
*
|
|
299
|
+
* @param basketId - Basket ID
|
|
300
|
+
* @returns Promise resolving to basket data
|
|
301
|
+
*/
|
|
302
|
+
async getById(basketId) {
|
|
303
|
+
const instance = await getBasketsInstance();
|
|
304
|
+
return instance.getById(basketId);
|
|
168
305
|
}
|
|
169
306
|
};
|
|
307
|
+
// ============================================================================
|
|
308
|
+
// ORDERS API
|
|
309
|
+
// ============================================================================
|
|
310
|
+
/**
|
|
311
|
+
* Orders API
|
|
312
|
+
* Manage orders
|
|
313
|
+
*/
|
|
170
314
|
export const Orders = {
|
|
315
|
+
/**
|
|
316
|
+
* Creates a new order.
|
|
317
|
+
*
|
|
318
|
+
* @param orderData - Order data
|
|
319
|
+
* @returns Promise resolving to created order
|
|
320
|
+
*/
|
|
171
321
|
async create(orderData) {
|
|
172
322
|
const instance = await getOrderInstance();
|
|
173
323
|
return instance.create(orderData);
|
|
174
324
|
},
|
|
325
|
+
/**
|
|
326
|
+
* Updates order status.
|
|
327
|
+
*
|
|
328
|
+
* @param status - New order status
|
|
329
|
+
* @param orderId - Order ID
|
|
330
|
+
* @returns Promise resolving to updated order
|
|
331
|
+
*/
|
|
175
332
|
async updateStatus(status, orderId) {
|
|
176
333
|
const instance = await getOrderInstance();
|
|
177
334
|
return instance.updateStatus(status, orderId);
|
|
178
335
|
},
|
|
336
|
+
/**
|
|
337
|
+
* Updates order data.
|
|
338
|
+
*
|
|
339
|
+
* @param data - Data to update
|
|
340
|
+
* @param orderId - Order ID
|
|
341
|
+
* @returns Promise resolving to updated order
|
|
342
|
+
*/
|
|
179
343
|
async updateData(data, orderId) {
|
|
180
344
|
const instance = await getOrderInstance();
|
|
181
345
|
return instance.updateData(data, orderId);
|
|
182
346
|
},
|
|
347
|
+
/**
|
|
348
|
+
* Retrieves orders, optionally filtered by status.
|
|
349
|
+
*
|
|
350
|
+
* @param status - Optional order status filter
|
|
351
|
+
* @returns Promise resolving to order list
|
|
352
|
+
*/
|
|
183
353
|
async get(status) {
|
|
184
354
|
const instance = await getOrderInstance();
|
|
185
355
|
return instance.get(status);
|
|
356
|
+
},
|
|
357
|
+
/**
|
|
358
|
+
* Retrieves a specific order by ID.
|
|
359
|
+
*
|
|
360
|
+
* @param orderId - Order ID
|
|
361
|
+
* @returns Promise resolving to order data
|
|
362
|
+
*/
|
|
363
|
+
async getById(orderId) {
|
|
364
|
+
const instance = await getOrderInstance();
|
|
365
|
+
return instance.getById(orderId);
|
|
186
366
|
}
|
|
187
367
|
};
|
|
188
|
-
//
|
|
189
|
-
|
|
368
|
+
// ============================================================================
|
|
369
|
+
// EXPORTS
|
|
370
|
+
// ============================================================================
|
|
371
|
+
// Export skill classes and utilities
|
|
372
|
+
export { LuaSkill, BasketStatus, OrderStatus, env };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Definitions
|
|
3
|
+
* Centralized command structure for the CLI
|
|
4
|
+
*/
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
/**
|
|
7
|
+
* Sets up authentication-related commands.
|
|
8
|
+
*
|
|
9
|
+
* Commands:
|
|
10
|
+
* - `lua auth configure` - Set up API key
|
|
11
|
+
* - `lua auth logout` - Delete stored API key
|
|
12
|
+
* - `lua auth key` - Display current API key
|
|
13
|
+
*
|
|
14
|
+
* @param program - Commander program instance
|
|
15
|
+
*/
|
|
16
|
+
export declare function setupAuthCommands(program: Command): void;
|
|
17
|
+
/**
|
|
18
|
+
* Sets up skill management commands.
|
|
19
|
+
*
|
|
20
|
+
* Commands:
|
|
21
|
+
* - `lua init` - Initialize new project
|
|
22
|
+
* - `lua compile` - Compile skill
|
|
23
|
+
* - `lua test` - Test tools interactively
|
|
24
|
+
* - `lua push` - Push to server
|
|
25
|
+
* - `lua deploy` - Deploy to production
|
|
26
|
+
* - `lua dev` - Development mode with live reload
|
|
27
|
+
*
|
|
28
|
+
* @param program - Commander program instance
|
|
29
|
+
*/
|
|
30
|
+
export declare function setupSkillCommands(program: Command): void;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Definitions
|
|
3
|
+
* Centralized command structure for the CLI
|
|
4
|
+
*/
|
|
5
|
+
import { configureCommand, initCommand, destroyCommand, apiKeyCommand, compileCommand, testCommand, pushCommand, deployCommand, devCommand } from "../commands/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* Sets up authentication-related commands.
|
|
8
|
+
*
|
|
9
|
+
* Commands:
|
|
10
|
+
* - `lua auth configure` - Set up API key
|
|
11
|
+
* - `lua auth logout` - Delete stored API key
|
|
12
|
+
* - `lua auth key` - Display current API key
|
|
13
|
+
*
|
|
14
|
+
* @param program - Commander program instance
|
|
15
|
+
*/
|
|
16
|
+
export function setupAuthCommands(program) {
|
|
17
|
+
const authCommand = program
|
|
18
|
+
.command("auth")
|
|
19
|
+
.description("Authentication management commands");
|
|
20
|
+
authCommand
|
|
21
|
+
.command("configure")
|
|
22
|
+
.description("Set up your API key")
|
|
23
|
+
.action(configureCommand);
|
|
24
|
+
authCommand
|
|
25
|
+
.command("logout")
|
|
26
|
+
.description("Delete your stored API key")
|
|
27
|
+
.action(destroyCommand);
|
|
28
|
+
authCommand
|
|
29
|
+
.command("key")
|
|
30
|
+
.description("Display your stored API key")
|
|
31
|
+
.action(apiKeyCommand);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Sets up skill management commands.
|
|
35
|
+
*
|
|
36
|
+
* Commands:
|
|
37
|
+
* - `lua init` - Initialize new project
|
|
38
|
+
* - `lua compile` - Compile skill
|
|
39
|
+
* - `lua test` - Test tools interactively
|
|
40
|
+
* - `lua push` - Push to server
|
|
41
|
+
* - `lua deploy` - Deploy to production
|
|
42
|
+
* - `lua dev` - Development mode with live reload
|
|
43
|
+
*
|
|
44
|
+
* @param program - Commander program instance
|
|
45
|
+
*/
|
|
46
|
+
export function setupSkillCommands(program) {
|
|
47
|
+
program
|
|
48
|
+
.command("init")
|
|
49
|
+
.description("Initialize a new Lua skill project")
|
|
50
|
+
.action(initCommand);
|
|
51
|
+
program
|
|
52
|
+
.command("compile")
|
|
53
|
+
.description("Compile Lua skill to generate deployable format")
|
|
54
|
+
.action(compileCommand);
|
|
55
|
+
program
|
|
56
|
+
.command("test")
|
|
57
|
+
.description("Test Lua skill tools interactively")
|
|
58
|
+
.action(testCommand);
|
|
59
|
+
program
|
|
60
|
+
.command("push")
|
|
61
|
+
.description("Push compiled skill version to server")
|
|
62
|
+
.action(pushCommand);
|
|
63
|
+
program
|
|
64
|
+
.command("deploy")
|
|
65
|
+
.description("Deploy a version to production")
|
|
66
|
+
.action(deployCommand);
|
|
67
|
+
program
|
|
68
|
+
.command("dev")
|
|
69
|
+
.description("Push compiled skill version to sandbox for development")
|
|
70
|
+
.action(devCommand);
|
|
71
|
+
}
|
|
@@ -1 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agents Command
|
|
3
|
+
* Lists all organizations and agents accessible to the authenticated user
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Main agents command - retrieves and displays organization/agent information.
|
|
7
|
+
*
|
|
8
|
+
* This command:
|
|
9
|
+
* 1. Loads the API key from secure storage
|
|
10
|
+
* 2. Calls the agents API to retrieve organizations
|
|
11
|
+
* 3. Displays the retrieved data in JSON format
|
|
12
|
+
*
|
|
13
|
+
* Use this command to:
|
|
14
|
+
* - View all organizations you have access to
|
|
15
|
+
* - Get agent IDs for configuration
|
|
16
|
+
* - Verify API key permissions
|
|
17
|
+
*
|
|
18
|
+
* @returns Promise that resolves when agents are listed
|
|
19
|
+
* @throws Error if API key is not found or API call fails
|
|
20
|
+
*/
|
|
1
21
|
export declare function agentsCommand(): Promise<void>;
|
package/dist/commands/agents.js
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Agents Command
|
|
3
|
+
* Lists all organizations and agents accessible to the authenticated user
|
|
4
|
+
*/
|
|
2
5
|
import { loadApiKey } from "../services/auth.js";
|
|
3
6
|
import { withErrorHandling, writeSuccess } from "../utils/cli.js";
|
|
7
|
+
import AgentApi from '../api/agent.api.service.js';
|
|
8
|
+
import { BASE_URLS } from '../config/constants.js';
|
|
9
|
+
/**
|
|
10
|
+
* Main agents command - retrieves and displays organization/agent information.
|
|
11
|
+
*
|
|
12
|
+
* This command:
|
|
13
|
+
* 1. Loads the API key from secure storage
|
|
14
|
+
* 2. Calls the agents API to retrieve organizations
|
|
15
|
+
* 3. Displays the retrieved data in JSON format
|
|
16
|
+
*
|
|
17
|
+
* Use this command to:
|
|
18
|
+
* - View all organizations you have access to
|
|
19
|
+
* - Get agent IDs for configuration
|
|
20
|
+
* - Verify API key permissions
|
|
21
|
+
*
|
|
22
|
+
* @returns Promise that resolves when agents are listed
|
|
23
|
+
* @throws Error if API key is not found or API call fails
|
|
24
|
+
*/
|
|
4
25
|
export async function agentsCommand() {
|
|
5
26
|
return withErrorHandling(async () => {
|
|
6
27
|
const apiKey = await loadApiKey();
|
|
@@ -8,7 +29,8 @@ export async function agentsCommand() {
|
|
|
8
29
|
console.error("❌ No API key found. Run `lua auth configure` first.");
|
|
9
30
|
process.exit(1);
|
|
10
31
|
}
|
|
11
|
-
const
|
|
32
|
+
const agentApi = new AgentApi(BASE_URLS.API, apiKey);
|
|
33
|
+
const response = await agentApi.getOrganizations();
|
|
12
34
|
if (!response.success) {
|
|
13
35
|
console.error(`❌ Error: ${response.error?.message || 'Unknown error'}`);
|
|
14
36
|
process.exit(1);
|
|
@@ -1 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Key Display Command
|
|
3
|
+
* Securely displays the stored API key with user confirmation
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Main API key command - displays the stored API key with confirmation.
|
|
7
|
+
*
|
|
8
|
+
* This command:
|
|
9
|
+
* 1. Loads the API key from secure storage
|
|
10
|
+
* 2. Prompts for confirmation before displaying
|
|
11
|
+
* 3. Displays the API key if confirmed
|
|
12
|
+
*
|
|
13
|
+
* Security:
|
|
14
|
+
* - Requires explicit confirmation to prevent accidental exposure
|
|
15
|
+
* - Only displays if user confirms the action
|
|
16
|
+
*
|
|
17
|
+
* Use this command to:
|
|
18
|
+
* - Retrieve your API key for use elsewhere
|
|
19
|
+
* - Verify which API key is currently configured
|
|
20
|
+
* - Copy your API key to clipboard
|
|
21
|
+
*
|
|
22
|
+
* @returns Promise that resolves when command completes
|
|
23
|
+
*/
|
|
1
24
|
export declare function apiKeyCommand(): Promise<void>;
|
package/dist/commands/apiKey.js
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Key Display Command
|
|
3
|
+
* Securely displays the stored API key with user confirmation
|
|
4
|
+
*/
|
|
1
5
|
import inquirer from "inquirer";
|
|
2
6
|
import { loadApiKey } from "../services/auth.js";
|
|
3
7
|
import { withErrorHandling, writeProgress, writeSuccess } from "../utils/cli.js";
|
|
8
|
+
/**
|
|
9
|
+
* Main API key command - displays the stored API key with confirmation.
|
|
10
|
+
*
|
|
11
|
+
* This command:
|
|
12
|
+
* 1. Loads the API key from secure storage
|
|
13
|
+
* 2. Prompts for confirmation before displaying
|
|
14
|
+
* 3. Displays the API key if confirmed
|
|
15
|
+
*
|
|
16
|
+
* Security:
|
|
17
|
+
* - Requires explicit confirmation to prevent accidental exposure
|
|
18
|
+
* - Only displays if user confirms the action
|
|
19
|
+
*
|
|
20
|
+
* Use this command to:
|
|
21
|
+
* - Retrieve your API key for use elsewhere
|
|
22
|
+
* - Verify which API key is currently configured
|
|
23
|
+
* - Copy your API key to clipboard
|
|
24
|
+
*
|
|
25
|
+
* @returns Promise that resolves when command completes
|
|
26
|
+
*/
|
|
4
27
|
export async function apiKeyCommand() {
|
|
5
28
|
return withErrorHandling(async () => {
|
|
6
29
|
const apiKey = await loadApiKey();
|
|
@@ -1 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile Command
|
|
3
|
+
* Orchestrates the skill compilation process by coordinating various compilation steps
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Main compile command - orchestrates the entire skill compilation process.
|
|
7
|
+
*
|
|
8
|
+
* This command performs the following steps:
|
|
9
|
+
* 1. Cleans and prepares output directories (dist/ and .lua/)
|
|
10
|
+
* 2. Analyzes the TypeScript project to detect all tools
|
|
11
|
+
* 3. Bundles each tool individually using esbuild
|
|
12
|
+
* 4. Extracts execute code and schemas from bundled tools
|
|
13
|
+
* 5. Bundles the main index file
|
|
14
|
+
* 6. Creates deployment data in both new and legacy formats
|
|
15
|
+
*
|
|
16
|
+
* Output:
|
|
17
|
+
* - dist/deployment.json - New deployment format with tool references
|
|
18
|
+
* - dist/tools/*.js - Individual bundled tool files
|
|
19
|
+
* - dist/index.js - Main skill entry point
|
|
20
|
+
* - .lua/deploy.json - Legacy deployment format with compressed tools
|
|
21
|
+
* - .lua/*.js - Individual uncompressed tool files for debugging
|
|
22
|
+
*
|
|
23
|
+
* @returns Promise that resolves when compilation is complete
|
|
24
|
+
*/
|
|
1
25
|
export declare function compileCommand(): Promise<void>;
|