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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/API_REFERENCE.md +1408 -0
  2. package/CLI_REFERENCE.md +818 -0
  3. package/GETTING_STARTED.md +1040 -0
  4. package/README.md +738 -424
  5. package/TEMPLATE_GUIDE.md +1398 -0
  6. package/dist/api/agent.api.service.d.ts +33 -6
  7. package/dist/api/agent.api.service.js +27 -0
  8. package/dist/api/auth.api.service.d.ts +31 -2
  9. package/dist/api/auth.api.service.js +29 -0
  10. package/dist/api/basket.api.service.d.ts +53 -11
  11. package/dist/api/basket.api.service.js +63 -14
  12. package/dist/api/chat.api.service.d.ts +15 -3
  13. package/dist/api/chat.api.service.js +12 -0
  14. package/dist/api/credentials.d.ts +24 -0
  15. package/dist/api/credentials.js +46 -0
  16. package/dist/api/custom.data.api.service.d.ts +45 -9
  17. package/dist/api/custom.data.api.service.js +43 -9
  18. package/dist/api/lazy-instances.d.ts +49 -0
  19. package/dist/api/lazy-instances.js +95 -0
  20. package/dist/api/order.api.service.d.ts +34 -4
  21. package/dist/api/order.api.service.js +41 -3
  22. package/dist/api/products.api.service.d.ts +39 -9
  23. package/dist/api/products.api.service.js +43 -5
  24. package/dist/api/skills.api.service.d.ts +49 -2
  25. package/dist/api/skills.api.service.js +47 -1
  26. package/dist/api/tool.api.service.d.ts +39 -1
  27. package/dist/api/tool.api.service.js +38 -0
  28. package/dist/api/user.data.api.service.d.ts +23 -1
  29. package/dist/api/user.data.api.service.js +22 -0
  30. package/dist/api-exports.d.ts +236 -5
  31. package/dist/api-exports.js +264 -81
  32. package/dist/cli/command-definitions.d.ts +30 -0
  33. package/dist/cli/command-definitions.js +71 -0
  34. package/dist/commands/agents.d.ts +20 -0
  35. package/dist/commands/agents.js +24 -2
  36. package/dist/commands/apiKey.d.ts +23 -0
  37. package/dist/commands/apiKey.js +23 -0
  38. package/dist/commands/compile.d.ts +24 -0
  39. package/dist/commands/compile.js +67 -759
  40. package/dist/commands/configure.d.ts +24 -0
  41. package/dist/commands/configure.js +31 -96
  42. package/dist/commands/deploy.d.ts +31 -19
  43. package/dist/commands/deploy.js +45 -74
  44. package/dist/commands/destroy.d.ts +27 -0
  45. package/dist/commands/destroy.js +27 -1
  46. package/dist/commands/dev.d.ts +25 -62
  47. package/dist/commands/dev.js +58 -878
  48. package/dist/commands/init.d.ts +27 -0
  49. package/dist/commands/init.js +98 -260
  50. package/dist/commands/push.d.ts +24 -21
  51. package/dist/commands/push.js +39 -92
  52. package/dist/commands/test.d.ts +26 -0
  53. package/dist/commands/test.js +41 -188
  54. package/dist/common/basket.instance.d.ts +54 -3
  55. package/dist/common/basket.instance.js +56 -3
  56. package/dist/common/data.entry.instance.d.ts +25 -2
  57. package/dist/common/data.entry.instance.js +24 -0
  58. package/dist/common/http.client.d.ts +51 -1
  59. package/dist/common/http.client.js +50 -0
  60. package/dist/common/order.instance.d.ts +22 -0
  61. package/dist/common/order.instance.js +31 -4
  62. package/dist/common/product.instance.d.ts +22 -1
  63. package/dist/common/product.instance.js +24 -6
  64. package/dist/common/product.pagination.instance.d.ts +22 -2
  65. package/dist/common/product.pagination.instance.js +22 -1
  66. package/dist/common/product.search.instance.d.ts +13 -3
  67. package/dist/common/product.search.instance.js +12 -1
  68. package/dist/common/user.instance.d.ts +27 -3
  69. package/dist/common/user.instance.js +28 -7
  70. package/dist/config/auth.constants.d.ts +11 -0
  71. package/dist/config/auth.constants.js +11 -0
  72. package/dist/config/compile.constants.d.ts +67 -0
  73. package/dist/config/compile.constants.js +99 -0
  74. package/dist/config/constants.d.ts +5 -0
  75. package/dist/config/constants.js +5 -0
  76. package/dist/config/dev.constants.d.ts +65 -0
  77. package/dist/config/dev.constants.js +79 -0
  78. package/dist/config/init.constants.d.ts +23 -0
  79. package/dist/config/init.constants.js +41 -0
  80. package/dist/index.d.ts +19 -3
  81. package/dist/index.js +28 -44
  82. package/dist/interfaces/admin.d.ts +56 -50
  83. package/dist/interfaces/admin.js +4 -0
  84. package/dist/interfaces/agent.d.ts +21 -0
  85. package/dist/interfaces/agent.js +4 -0
  86. package/dist/interfaces/baskets.d.ts +60 -0
  87. package/dist/interfaces/baskets.js +12 -0
  88. package/dist/interfaces/chat.d.ts +48 -4
  89. package/dist/interfaces/chat.js +4 -0
  90. package/dist/interfaces/common.d.ts +62 -0
  91. package/dist/interfaces/common.js +8 -0
  92. package/dist/interfaces/compile.d.ts +11 -0
  93. package/dist/interfaces/compile.js +4 -0
  94. package/dist/interfaces/custom.data.d.ts +49 -19
  95. package/dist/interfaces/custom.data.js +4 -0
  96. package/dist/interfaces/deploy.d.ts +29 -0
  97. package/dist/interfaces/deploy.js +4 -0
  98. package/dist/interfaces/dev.d.ts +53 -0
  99. package/dist/interfaces/dev.js +5 -0
  100. package/dist/interfaces/init.d.ts +60 -0
  101. package/dist/interfaces/init.js +4 -0
  102. package/dist/interfaces/orders.d.ts +37 -0
  103. package/dist/interfaces/orders.js +12 -0
  104. package/dist/interfaces/product.d.ts +38 -10
  105. package/dist/interfaces/product.js +4 -0
  106. package/dist/interfaces/push.d.ts +26 -0
  107. package/dist/interfaces/push.js +4 -0
  108. package/dist/interfaces/test.d.ts +36 -0
  109. package/dist/interfaces/test.js +4 -0
  110. package/dist/services/auth.d.ts +54 -99
  111. package/dist/services/auth.js +76 -12
  112. package/dist/types/api-contracts.d.ts +211 -0
  113. package/dist/types/api-contracts.js +8 -0
  114. package/dist/types/compile.types.d.ts +76 -0
  115. package/dist/types/compile.types.js +4 -0
  116. package/dist/types/index.d.ts +23 -121
  117. package/dist/types/index.js +25 -14
  118. package/dist/types/skill.d.ts +142 -0
  119. package/dist/{skill.js → types/skill.js} +66 -17
  120. package/dist/types/tool-validation.d.ts +34 -0
  121. package/dist/types/tool-validation.js +42 -0
  122. package/dist/utils/auth-flows.d.ts +26 -0
  123. package/dist/utils/auth-flows.js +141 -0
  124. package/dist/utils/bundling.d.ts +36 -0
  125. package/dist/utils/bundling.js +137 -0
  126. package/dist/utils/compile.d.ts +37 -0
  127. package/dist/utils/compile.js +242 -0
  128. package/dist/utils/deploy-api.d.ts +26 -0
  129. package/dist/utils/deploy-api.js +53 -0
  130. package/dist/utils/deploy-helpers.d.ts +46 -0
  131. package/dist/utils/deploy-helpers.js +86 -0
  132. package/dist/utils/deployment.d.ts +25 -0
  133. package/dist/utils/deployment.js +161 -0
  134. package/dist/utils/dev-api.d.ts +61 -0
  135. package/dist/utils/dev-api.js +262 -0
  136. package/dist/utils/dev-helpers.d.ts +46 -0
  137. package/dist/utils/dev-helpers.js +83 -0
  138. package/dist/utils/dev-server.d.ts +24 -0
  139. package/dist/utils/dev-server.js +555 -0
  140. package/dist/utils/dev-watcher.d.ts +31 -0
  141. package/dist/utils/dev-watcher.js +110 -0
  142. package/dist/utils/files.js +0 -5
  143. package/dist/utils/init-agent.d.ts +34 -0
  144. package/dist/utils/init-agent.js +129 -0
  145. package/dist/utils/init-helpers.d.ts +41 -0
  146. package/dist/utils/init-helpers.js +73 -0
  147. package/dist/utils/init-prompts.d.ts +47 -0
  148. package/dist/utils/init-prompts.js +168 -0
  149. package/dist/utils/push-api.d.ts +15 -0
  150. package/dist/utils/push-api.js +48 -0
  151. package/dist/utils/push-helpers.d.ts +38 -0
  152. package/dist/utils/push-helpers.js +84 -0
  153. package/dist/utils/sandbox-storage.d.ts +27 -0
  154. package/dist/utils/sandbox-storage.js +71 -0
  155. package/dist/utils/sandbox.js +78 -114
  156. package/dist/utils/skill-management.d.ts +14 -0
  157. package/dist/utils/skill-management.js +148 -0
  158. package/dist/utils/test-helpers.d.ts +40 -0
  159. package/dist/utils/test-helpers.js +92 -0
  160. package/dist/utils/test-prompts.d.ts +23 -0
  161. package/dist/utils/test-prompts.js +186 -0
  162. package/dist/utils/tool-detection.d.ts +18 -0
  163. package/dist/utils/tool-detection.js +110 -0
  164. package/dist/web/app.css +941 -17
  165. package/dist/web/app.js +174 -22
  166. package/dist/web/index.html +7 -1
  167. package/package.json +13 -4
  168. package/template/QUICKSTART.md +299 -144
  169. package/template/README.md +928 -349
  170. package/template/TOOL_EXAMPLES.md +655 -0
  171. package/template/package-lock.json +5 -5
  172. package/template/package.json +1 -1
  173. package/template/src/index.ts +147 -207
  174. package/template/src/tools/BasketTool.ts +128 -0
  175. package/template/src/tools/CustomDataTool.ts +7 -13
  176. package/template/src/tools/OrderTool.ts +54 -0
  177. package/template/src/tools/PaymentTool.ts +1 -1
  178. package/template/src/tools/ProductsTool.ts +56 -118
  179. package/template/src/tools/UserDataTool.ts +4 -26
  180. package/dist/common/config.d.ts +0 -5
  181. package/dist/common/config.js +0 -5
  182. package/dist/custom-data-api.d.ts +0 -72
  183. package/dist/custom-data-api.js +0 -174
  184. package/dist/product-api.d.ts +0 -189
  185. package/dist/product-api.js +0 -141
  186. package/dist/services/api.d.ts +0 -549
  187. package/dist/services/api.js +0 -596
  188. package/dist/skill.d.ts +0 -50
  189. package/dist/types.d.ts +0 -1
  190. package/dist/types.js +0 -2
  191. package/dist/user-data-api.d.ts +0 -39
  192. package/dist/user-data-api.js +0 -50
  193. package/template/API.md +0 -604
  194. package/template/DEVELOPER.md +0 -771
  195. package/template/lua.skill.yaml +0 -7
@@ -1,596 +0,0 @@
1
- /**
2
- * Centralized API service for all Lua CLI API calls
3
- * This service handles all HTTP requests to various Lua endpoints
4
- */
5
- // Base URLs for different environments
6
- const BASE_URLS = {
7
- LOCAL: 'https://api.heylua.ai',
8
- API: 'https://api.heylua.ai',
9
- AUTH: 'https://auth.heylua.ai',
10
- CHAT: 'https://api.heylua.ai'
11
- };
12
- /**
13
- * Generic HTTP client with common error handling
14
- */
15
- class HttpClient {
16
- async request(url, options = {}) {
17
- try {
18
- const response = await fetch(url, {
19
- ...options,
20
- headers: {
21
- 'Content-Type': 'application/json',
22
- ...options.headers,
23
- },
24
- });
25
- const data = await response.json();
26
- if (!response.ok) {
27
- return {
28
- success: false,
29
- error: {
30
- message: data.message || data.error || `HTTP ${response.status}`,
31
- statusCode: response.status,
32
- },
33
- };
34
- }
35
- return {
36
- success: true,
37
- data,
38
- };
39
- }
40
- catch (error) {
41
- return {
42
- success: false,
43
- error: {
44
- message: error instanceof Error ? error.message : 'Network error',
45
- statusCode: 500,
46
- },
47
- };
48
- }
49
- }
50
- async get(url, headers) {
51
- return this.request(url, { method: 'GET', headers });
52
- }
53
- async post(url, data, headers) {
54
- return this.request(url, {
55
- method: 'POST',
56
- body: data ? JSON.stringify(data) : undefined,
57
- headers,
58
- });
59
- }
60
- async put(url, data, headers) {
61
- return this.request(url, {
62
- method: 'PUT',
63
- body: data ? JSON.stringify(data) : undefined,
64
- headers,
65
- });
66
- }
67
- async delete(url, headers) {
68
- return this.request(url, { method: 'DELETE', headers });
69
- }
70
- async patch(url, data, headers) {
71
- return this.request(url, {
72
- method: 'PATCH',
73
- body: data ? JSON.stringify(data) : undefined,
74
- headers,
75
- });
76
- }
77
- }
78
- const httpClient = new HttpClient();
79
- /**
80
- * Authentication API calls
81
- */
82
- export class AuthApi {
83
- static async checkApiKey(apiKey) {
84
- return httpClient.get(`${BASE_URLS.LOCAL}/admin`, {
85
- Authorization: `Bearer ${apiKey}`,
86
- });
87
- }
88
- static async sendOtp(email) {
89
- return httpClient.post(`${BASE_URLS.AUTH}/otp`, { email, type: 'email' });
90
- }
91
- static async verifyOtp(email, otp) {
92
- return httpClient.post(`${BASE_URLS.AUTH}/otp/verify`, { email, pin: otp, type: 'email' });
93
- }
94
- static async getApiKey(signInToken) {
95
- return httpClient.post(`${BASE_URLS.AUTH}/profile/apiKey`, undefined, {
96
- Authorization: `Bearer ${signInToken}`,
97
- });
98
- }
99
- }
100
- /**
101
- * Agent API calls
102
- */
103
- export class AgentApi {
104
- static async getOrganizations(apiKey) {
105
- return httpClient.get(`${BASE_URLS.LOCAL}/admin`, {
106
- Authorization: `Bearer ${apiKey}`,
107
- });
108
- }
109
- static async getAgentTypes(apiKey) {
110
- return httpClient.get(`${BASE_URLS.API}/agents/self-serve/types`, {
111
- Authorization: `Bearer ${apiKey}`,
112
- });
113
- }
114
- static async createAgent(apiKey, agentData) {
115
- return httpClient.post(`${BASE_URLS.API}/agents/self-serve/create`, agentData, {
116
- Authorization: `Bearer ${apiKey}`,
117
- });
118
- }
119
- static async getAgent(apiKey, agentId) {
120
- return httpClient.get(`${BASE_URLS.API}/admin/agents/${agentId}`, {
121
- Authorization: `Bearer ${apiKey}`,
122
- });
123
- }
124
- }
125
- /**
126
- * Skill API calls
127
- */
128
- export class SkillApi {
129
- static async createSkill(apiKey, agentId, skillData) {
130
- // console.log(`Skill data:`, skillData);
131
- return httpClient.post(`${BASE_URLS.LOCAL}/developer/skills/${agentId}`, skillData, {
132
- Authorization: `Bearer ${apiKey}`,
133
- });
134
- }
135
- static async pushSkill(apiKey, agentId, skillId, versionData) {
136
- return httpClient.post(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/version`, versionData, {
137
- Authorization: `Bearer ${apiKey}`,
138
- });
139
- }
140
- static async pushDevSkill(apiKey, agentId, skillId, versionData) {
141
- return httpClient.post(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/version/sandbox`, versionData, {
142
- Authorization: `Bearer ${apiKey}`,
143
- });
144
- }
145
- static async updateDevSkill(apiKey, agentId, skillId, sandboxVersionId, versionData) {
146
- return httpClient.put(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/version/sandbox/${sandboxVersionId}`, versionData, {
147
- Authorization: `Bearer ${apiKey}`,
148
- });
149
- }
150
- static async getSkillVersions(apiKey, agentId, skillId) {
151
- return httpClient.get(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/versions`, {
152
- Authorization: `Bearer ${apiKey}`,
153
- });
154
- }
155
- static async publishSkillVersion(apiKey, agentId, skillId, version) {
156
- return httpClient.put(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/${version}/publish`, undefined, {
157
- Authorization: `Bearer ${apiKey}`,
158
- });
159
- }
160
- }
161
- /**
162
- * Chat API calls
163
- */
164
- export class ChatApi {
165
- static async sendMessage(agentId, chatData, apiKey) {
166
- return httpClient.post(`${BASE_URLS.CHAT}/chat/generate/${agentId}?channel=dev`, chatData, {
167
- Authorization: `Bearer ${apiKey}`,
168
- });
169
- }
170
- }
171
- /**
172
- * Product API calls
173
- */
174
- export class ProductApi {
175
- /**
176
- * Get all products for an agent with pagination
177
- */
178
- static async getProducts(apiKey, agentId, page = 1, limit = 10) {
179
- const response = await httpClient.get(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products?page=${page}&limit=${limit}`, {
180
- Authorization: `Bearer ${apiKey}`,
181
- });
182
- if (response.success) {
183
- return response.data;
184
- }
185
- else {
186
- return {
187
- success: false,
188
- message: response.error?.message || 'Failed to get products'
189
- };
190
- }
191
- }
192
- /**
193
- * Create a new product
194
- */
195
- static async createProduct(apiKey, agentId, productData) {
196
- const response = await httpClient.post(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products`, productData, {
197
- Authorization: `Bearer ${apiKey}`,
198
- });
199
- if (response.success) {
200
- return response.data;
201
- }
202
- else {
203
- return {
204
- success: false,
205
- message: response.error?.message || 'Failed to create product'
206
- };
207
- }
208
- }
209
- /**
210
- * Update an existing product
211
- */
212
- static async updateProduct(apiKey, agentId, productData) {
213
- const response = await httpClient.put(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products`, productData, {
214
- Authorization: `Bearer ${apiKey}`,
215
- });
216
- if (response.success) {
217
- return response.data;
218
- }
219
- else {
220
- return {
221
- success: false,
222
- message: response.error?.message || 'Failed to update product'
223
- };
224
- }
225
- }
226
- /**
227
- * Delete a product
228
- */
229
- static async deleteProduct(apiKey, agentId, productId) {
230
- const response = await httpClient.delete(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products/${productId}`, {
231
- Authorization: `Bearer ${apiKey}`,
232
- });
233
- if (response.success) {
234
- return response.data;
235
- }
236
- else {
237
- return {
238
- success: false,
239
- message: response.error?.message || 'Failed to delete product'
240
- };
241
- }
242
- }
243
- /**
244
- * Search products by text query
245
- */
246
- static async searchProducts(apiKey, agentId, searchQuery) {
247
- const response = await httpClient.get(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products/search?searchQuery=${encodeURIComponent(searchQuery)}`, {
248
- Authorization: `Bearer ${apiKey}`,
249
- });
250
- if (response.success) {
251
- return response.data;
252
- }
253
- else {
254
- return {
255
- success: false,
256
- message: response.error?.message || 'Failed to search products'
257
- };
258
- }
259
- }
260
- /**
261
- * Create a new user basket
262
- */
263
- static async createBasket(apiKey, agentId, basketData) {
264
- const response = await httpClient.post(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/basket`, basketData, {
265
- Authorization: `Bearer ${apiKey}`,
266
- });
267
- if (response.success) {
268
- return response.data;
269
- }
270
- else {
271
- return {
272
- success: false,
273
- message: response.error?.message || 'Failed to create basket'
274
- };
275
- }
276
- }
277
- /**
278
- * Get all user baskets with optional status filter
279
- */
280
- static async getUserBaskets(apiKey, agentId, status) {
281
- const statusParam = status ? `?status=${status}` : '';
282
- const response = await httpClient.get(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/basket/user${statusParam}`, {
283
- Authorization: `Bearer ${apiKey}`,
284
- });
285
- if (response.success) {
286
- return response.data;
287
- }
288
- else {
289
- return {
290
- success: false,
291
- message: response.error?.message || 'Failed to get user baskets'
292
- };
293
- }
294
- }
295
- /**
296
- * Add item to basket
297
- */
298
- static async addItemToBasket(apiKey, agentId, basketId, itemData) {
299
- const response = await httpClient.post(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/basket/${basketId}/item`, itemData, {
300
- Authorization: `Bearer ${apiKey}`,
301
- });
302
- if (response.success) {
303
- return response.data;
304
- }
305
- else {
306
- return {
307
- success: false,
308
- message: response.error?.message || 'Failed to add item to basket'
309
- };
310
- }
311
- }
312
- /**
313
- * Remove item from basket
314
- */
315
- static async removeItemFromBasket(apiKey, agentId, basketId, itemId) {
316
- const response = await httpClient.delete(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/basket/${basketId}/item/${itemId}`, {
317
- Authorization: `Bearer ${apiKey}`,
318
- });
319
- if (response.success) {
320
- return response.data;
321
- }
322
- else {
323
- return {
324
- success: false,
325
- message: response.error?.message || 'Failed to remove item from basket'
326
- };
327
- }
328
- }
329
- /**
330
- * Clear basket (remove all items)
331
- */
332
- static async clearBasket(apiKey, agentId, basketId) {
333
- const response = await httpClient.delete(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/basket/${basketId}/clear`, {
334
- Authorization: `Bearer ${apiKey}`,
335
- });
336
- if (response.success) {
337
- return response.data;
338
- }
339
- else {
340
- return {
341
- success: false,
342
- message: response.error?.message || 'Failed to clear basket'
343
- };
344
- }
345
- }
346
- /**
347
- * Update basket status
348
- */
349
- static async updateBasketStatus(apiKey, agentId, basketId, status) {
350
- const response = await httpClient.put(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/basket/${basketId}/${status}`, undefined, {
351
- Authorization: `Bearer ${apiKey}`,
352
- });
353
- if (response.success) {
354
- return response.data;
355
- }
356
- else {
357
- return {
358
- success: false,
359
- message: response.error?.message || 'Failed to update basket status'
360
- };
361
- }
362
- }
363
- /**
364
- * Create order from basket
365
- */
366
- static async createOrder(apiKey, agentId, orderData) {
367
- const response = await httpClient.post(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/order`, orderData, {
368
- Authorization: `Bearer ${apiKey}`,
369
- });
370
- if (response.success) {
371
- return response.data;
372
- }
373
- else {
374
- return {
375
- success: false,
376
- message: response.error?.message || 'Failed to create order'
377
- };
378
- }
379
- }
380
- /**
381
- * Update order status
382
- */
383
- static async updateOrderStatus(apiKey, agentId, orderId, status) {
384
- const response = await httpClient.put(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/order/${orderId}/${status}`, undefined, {
385
- Authorization: `Bearer ${apiKey}`,
386
- });
387
- if (response.success) {
388
- return response.data;
389
- }
390
- else {
391
- return {
392
- success: false,
393
- message: response.error?.message || 'Failed to update order status'
394
- };
395
- }
396
- }
397
- /**
398
- * Get user orders with optional status filter
399
- */
400
- static async getUserOrders(apiKey, agentId, userId, status) {
401
- const statusParam = status ? `?status=${status}` : '';
402
- const response = await httpClient.get(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/order/user/${userId}${statusParam}`, {
403
- Authorization: `Bearer ${apiKey}`,
404
- });
405
- if (response.success) {
406
- return response.data;
407
- }
408
- else {
409
- return {
410
- success: false,
411
- message: response.error?.message || 'Failed to get user orders'
412
- };
413
- }
414
- }
415
- }
416
- /**
417
- * Tool API calls (for compile command)
418
- */
419
- export class ToolApi {
420
- static async getTool(url, apiKey) {
421
- return httpClient.get(url, {
422
- Authorization: `Bearer ${apiKey}`,
423
- });
424
- }
425
- static async postTool(url, data, apiKey) {
426
- return httpClient.post(url, data, {
427
- Authorization: `Bearer ${apiKey}`,
428
- });
429
- }
430
- static async putTool(url, data, apiKey) {
431
- return httpClient.put(url, data, {
432
- Authorization: `Bearer ${apiKey}`,
433
- });
434
- }
435
- static async deleteTool(url, apiKey) {
436
- return httpClient.delete(url, {
437
- Authorization: `Bearer ${apiKey}`,
438
- });
439
- }
440
- static async patchTool(url, data, apiKey) {
441
- return httpClient.patch(url, data, {
442
- Authorization: `Bearer ${apiKey}`,
443
- });
444
- }
445
- }
446
- // User Data API calls
447
- export class UserDataApi {
448
- static async getUserData(apiKey, agentId) {
449
- const response = await httpClient.get(`${BASE_URLS.LOCAL}/developer/user/data/agent/${agentId}`, {
450
- Authorization: `Bearer ${apiKey}`,
451
- });
452
- return response;
453
- }
454
- static async createUserData(apiKey, agentId, data) {
455
- const response = await httpClient.put(`${BASE_URLS.LOCAL}/developer/user/data/agent/${agentId}`, data, {
456
- Authorization: `Bearer ${apiKey}`,
457
- });
458
- return response.data.data;
459
- }
460
- static async updateUserData(apiKey, agentId, data) {
461
- const response = await httpClient.put(`${BASE_URLS.LOCAL}/developer/user/data/agent/${agentId}`, data, {
462
- Authorization: `Bearer ${apiKey}`,
463
- });
464
- return response.data.data;
465
- }
466
- static async deleteUserData(apiKey, agentId) {
467
- const response = await httpClient.delete(`${BASE_URLS.LOCAL}/developer/user/data/agent/${agentId}`, {
468
- Authorization: `Bearer ${apiKey}`,
469
- });
470
- return response;
471
- }
472
- }
473
- // Custom Data API calls
474
- export class CustomDataApi {
475
- /**
476
- * Create a new custom data entry
477
- */
478
- static async createCustomData(apiKey, agentId, collectionName, data) {
479
- const response = await httpClient.post(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/custom-data/${collectionName}`, data, {
480
- Authorization: `Bearer ${apiKey}`,
481
- });
482
- if (response.success) {
483
- return response.data;
484
- }
485
- else {
486
- return {
487
- success: false,
488
- message: response.error?.message || 'Failed to create custom data entry'
489
- };
490
- }
491
- }
492
- /**
493
- * Get custom data entries with optional filtering and pagination
494
- */
495
- static async getCustomData(apiKey, agentId, collectionName, filter, page = 1, limit = 10) {
496
- let url = `${BASE_URLS.LOCAL}/developer/agents/${agentId}/custom-data/${collectionName}?page=${page}&limit=${limit}`;
497
- if (filter) {
498
- const encodedFilter = encodeURIComponent(JSON.stringify(filter));
499
- url += `&filter=${encodedFilter}`;
500
- }
501
- const response = await httpClient.get(url, {
502
- Authorization: `Bearer ${apiKey}`,
503
- });
504
- if (response.success) {
505
- return response.data;
506
- }
507
- else {
508
- return {
509
- success: false,
510
- message: response.error?.message || 'Failed to get custom data entries'
511
- };
512
- }
513
- }
514
- /**
515
- * Get a single custom data entry by ID
516
- */
517
- static async getCustomDataEntry(apiKey, agentId, collectionName, entryId) {
518
- const response = await httpClient.get(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/custom-data/${collectionName}/${entryId}`, {
519
- Authorization: `Bearer ${apiKey}`,
520
- });
521
- if (response.success) {
522
- return response.data;
523
- }
524
- else {
525
- return {
526
- success: false,
527
- message: response.error?.message || 'Failed to get custom data entry'
528
- };
529
- }
530
- }
531
- /**
532
- * Update a custom data entry
533
- */
534
- static async updateCustomData(apiKey, agentId, collectionName, entryId, data) {
535
- const response = await httpClient.put(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/custom-data/${collectionName}/${entryId}`, data, {
536
- Authorization: `Bearer ${apiKey}`,
537
- });
538
- if (response.success) {
539
- return response.data;
540
- }
541
- else {
542
- return {
543
- success: false,
544
- message: response.error?.message || 'Failed to update custom data entry'
545
- };
546
- }
547
- }
548
- /**
549
- * Search custom data entries by text
550
- */
551
- static async searchCustomData(apiKey, agentId, collectionName, searchText, limit = 10, scoreThreshold = 0.6) {
552
- const url = `${BASE_URLS.LOCAL}/developer/agents/${agentId}/custom-data/${collectionName}/search?searchText=${encodeURIComponent(searchText)}&limit=${limit}&scoreThreshold=${scoreThreshold}`;
553
- const response = await httpClient.get(url, {
554
- Authorization: `Bearer ${apiKey}`,
555
- });
556
- if (response.success) {
557
- return response.data;
558
- }
559
- else {
560
- return {
561
- success: false,
562
- message: response.error?.message || 'Failed to search custom data entries'
563
- };
564
- }
565
- }
566
- /**
567
- * Delete a custom data entry
568
- */
569
- static async deleteCustomData(apiKey, agentId, collectionName, entryId) {
570
- const response = await httpClient.delete(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/custom-data/${collectionName}/${entryId}`, {
571
- Authorization: `Bearer ${apiKey}`,
572
- });
573
- if (response.success) {
574
- return response.data;
575
- }
576
- else {
577
- return {
578
- success: false,
579
- message: response.error?.message || 'Failed to delete custom data entry'
580
- };
581
- }
582
- }
583
- }
584
- /**
585
- * Main API service that exports all API classes
586
- */
587
- export const ApiService = {
588
- Auth: AuthApi,
589
- Agent: AgentApi,
590
- Skill: SkillApi,
591
- Chat: ChatApi,
592
- Product: ProductApi,
593
- Tool: ToolApi,
594
- UserData: UserDataApi,
595
- CustomData: CustomDataApi,
596
- };
package/dist/skill.d.ts DELETED
@@ -1,50 +0,0 @@
1
- import { ZodType } from "zod";
2
- import { LuaTool } from "./types/index.js";
3
- export { LuaTool };
4
- /**
5
- * Safe environment variable access function
6
- * Gets injected at runtime with skill-specific environment variables
7
- *
8
- * @param key - The environment variable key to retrieve
9
- * @returns The environment variable value or undefined if not found
10
- *
11
- * @example
12
- * ```typescript
13
- * const baseUrl = env('BASE_URL');
14
- * const apiKey = env('API_KEY');
15
- * ```
16
- */
17
- export declare const env: (key: string) => string | undefined;
18
- export interface LuaSkillConfig {
19
- name?: string;
20
- version?: string;
21
- description: string;
22
- context: string;
23
- tools?: LuaTool<any>[];
24
- }
25
- export declare class LuaSkill {
26
- private readonly tools;
27
- private readonly name;
28
- private readonly version;
29
- private readonly description;
30
- private readonly context;
31
- /**
32
- * Creates a new LuaSkill instance
33
- *
34
- * @param config - Configuration object containing skill metadata
35
- * @param config.description - Short description of what the skill does (1-2 sentences)
36
- * @param config.context - Detailed explanation of how the agent should use the tools
37
- *
38
- * @example
39
- * ```typescript
40
- * const skill = new LuaSkill({
41
- * description: "Weather and calculator utilities",
42
- * context: "This skill provides weather information for any city and basic mathematical operations. Use get_weather for current conditions and calculator for arithmetic operations."
43
- * });
44
- * ```
45
- */
46
- constructor(config: LuaSkillConfig);
47
- addTool<TInput extends ZodType>(tool: LuaTool<TInput>): void;
48
- addTools(tools: LuaTool<any>[]): void;
49
- run(input: Record<string, any>): Promise<any>;
50
- }
package/dist/types.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./types/index.js";
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- // Re-export types for external use
2
- export * from "./types/index.js";
@@ -1,39 +0,0 @@
1
- /**
2
- * User Data API for Lua CLI projects
3
- * Provides methods to interact with user data stored in the Lua system
4
- */
5
- export declare class UserDataAPI {
6
- userData: any;
7
- constructor();
8
- /**
9
- * Get user data for the current agent
10
- * @returns Promise<UserDataResponse>
11
- */
12
- get(): Promise<any>;
13
- /**
14
- * Create or update user data for the current agent
15
- * @param data - The user data to store
16
- * @returns Promise<UserDataResponse>
17
- */
18
- create(data: Record<string, any>): Promise<any>;
19
- /**
20
- * Update existing user data for the current agent
21
- * @param data - The user data to update
22
- * @returns Promise<UserDataResponse>
23
- */
24
- update(data: Record<string, any>): Promise<any>;
25
- /**
26
- * Clear all user data for the current agent
27
- * @returns Promise<{success: boolean}>
28
- */
29
- clear(): Promise<{
30
- success: boolean;
31
- }>;
32
- }
33
- /**
34
- * Convenience object for user data operations
35
- * Usage: user.data.get(), user.data.create(data), user.data.update(data), user.data.clear()
36
- */
37
- export declare const user: {
38
- data: UserDataAPI;
39
- };