lua-cli 2.1.0-alpha.4 → 2.1.0

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/README.md CHANGED
@@ -195,7 +195,7 @@ This command will:
195
195
  - Available at `http://localhost:3000` (opens automatically)
196
196
  - **Live Log Panel**:
197
197
  - Real-time log feed showing execution details
198
- - WebSocket connection to `wss://api.lua.dev/feed`
198
+ - WebSocket connection to `wss://api.heylua.ai/feed`
199
199
  - Console-style interface with color-coded log levels
200
200
  - Shows tool calls, errors, metrics, and execution metadata
201
201
  - Displays detailed information in expandable sections
@@ -498,7 +498,7 @@ For more details, see [USER_DATA_API.md](./USER_DATA_API.md).
498
498
 
499
499
  For support and questions:
500
500
  - Create an issue on [GitHub](https://github.com/lua-ai-global/lua-cli/issues)
501
- - Contact: stefan@lua.dev
501
+ - Contact: stefan@heylua.ai
502
502
 
503
503
  ## Changelog
504
504
 
@@ -227,7 +227,7 @@ async function bundleTool(tool, distDir) {
227
227
  platform: 'node',
228
228
  target: 'node16',
229
229
  outfile: outputPath,
230
- external: ['lua-cli/skill', 'lua-cli/user-data-api', 'zod'], // Exclude lua-cli modules and zod - injected into VM
230
+ external: ['lua-cli/skill', 'lua-cli/user-data-api', 'lua-cli/product-api', 'zod', 'keytar', 'esbuild', 'commander', 'inquirer', 'node-fetch', 'ws', 'socket.io-client', 'ts-morph'], // Exclude lua-cli modules, zod, and native modules
231
231
  minify: true, // Minify for smaller file sizes
232
232
  sourcemap: false,
233
233
  resolveExtensions: ['.ts', '.js', '.json'],
@@ -272,6 +272,19 @@ async function wrapToolForVM(outputPath, tool) {
272
272
  }
273
273
  }
274
274
  };
275
+
276
+ // Mock lua-cli/product-api module
277
+ const luaCliProductApi = {
278
+ product: typeof product !== 'undefined' ? product : {
279
+ data: {
280
+ get: async (page = 1, limit = 10) => ({ success: true, data: [], pagination: { currentPage: page, totalPages: 1, totalCount: 0, limit, hasNextPage: false, hasPrevPage: false, nextPage: null, prevPage: null } }),
281
+ update: async (data, productId) => ({ updated: true, isNew: false, product: data }),
282
+ create: async (data) => ({ updated: false, isNew: true, product: data }),
283
+ delete: async (productId) => ({ deleted: true }),
284
+ search: async (searchQuery) => ({ success: true, message: \`Found 0 products for "\${searchQuery}"\`, data: [] })
285
+ }
286
+ }
287
+ };
275
288
 
276
289
  // Mock zod module
277
290
  const zodModule = (() => {
@@ -313,6 +326,9 @@ async function wrapToolForVM(outputPath, tool) {
313
326
  if (id === 'lua-cli/user-data-api') {
314
327
  return luaCliUserDataApi;
315
328
  }
329
+ if (id === 'lua-cli/product-api') {
330
+ return luaCliProductApi;
331
+ }
316
332
  if (id === 'zod') {
317
333
  return zodModule;
318
334
  }
@@ -344,7 +360,7 @@ async function bundleMainIndex(indexPath, distDir) {
344
360
  platform: 'node',
345
361
  target: 'node16',
346
362
  outfile: path.join(distDir, 'index.js'),
347
- external: ['lua-cli/skill', 'lua-cli/user-data-api', 'zod'], // Exclude lua-cli modules and zod
363
+ external: ['lua-cli/skill', 'lua-cli/user-data-api', 'lua-cli/product-api', 'zod', 'keytar', 'esbuild', 'commander', 'inquirer', 'node-fetch', 'ws', 'socket.io-client', 'ts-morph'], // Exclude lua-cli modules, zod, and native modules
348
364
  minify: true, // Minify for smaller file sizes
349
365
  sourcemap: false,
350
366
  resolveExtensions: ['.ts', '.js', '.json'],
@@ -1,6 +1,41 @@
1
- import { CreateProductResponse, DeleteProductResponse, ProductsResponse, SearchProductsResponse, UpdateProductResponse } from "./services/api";
1
+ export interface Product {
2
+ id: string;
3
+ [key: string]: any;
4
+ }
5
+ export interface ProductsResponse {
6
+ success: boolean;
7
+ data: Product[];
8
+ pagination: {
9
+ currentPage: number;
10
+ totalPages: number;
11
+ totalCount: number;
12
+ limit: number;
13
+ hasNextPage: boolean;
14
+ hasPrevPage: boolean;
15
+ nextPage: number | null;
16
+ prevPage: number | null;
17
+ };
18
+ }
19
+ export interface CreateProductResponse {
20
+ updated: boolean;
21
+ isNew: boolean;
22
+ product: Product;
23
+ }
24
+ export interface UpdateProductResponse {
25
+ updated: boolean;
26
+ isNew: boolean;
27
+ product: Product;
28
+ }
29
+ export interface DeleteProductResponse {
30
+ deleted: boolean;
31
+ }
32
+ export interface SearchProductsResponse {
33
+ success: boolean;
34
+ message: string;
35
+ data: Product[];
36
+ }
2
37
  export declare class ProductAPI {
3
- products: any;
38
+ products: Product[];
4
39
  constructor();
5
40
  get(page?: number, limit?: number): Promise<ProductsResponse>;
6
41
  create(data: Record<string, any>): Promise<CreateProductResponse>;
@@ -1,25 +1,59 @@
1
1
  export class ProductAPI {
2
2
  constructor() {
3
- this.products = {};
3
+ this.products = [];
4
4
  }
5
5
  async get(page = 1, limit = 10) {
6
- return { success: true, data: this.products, pagination: { currentPage: page, totalPages: 1, totalCount: this.products.length, limit: limit, hasNextPage: false, hasPrevPage: false, nextPage: null, prevPage: null } };
6
+ return {
7
+ success: true,
8
+ data: this.products,
9
+ pagination: {
10
+ currentPage: page,
11
+ totalPages: 1,
12
+ totalCount: this.products.length,
13
+ limit: limit,
14
+ hasNextPage: false,
15
+ hasPrevPage: false,
16
+ nextPage: null,
17
+ prevPage: null
18
+ }
19
+ };
7
20
  }
8
21
  async create(data) {
9
- this.products = data;
10
- return { updated: true, isNew: true, product: this.products };
22
+ const product = data;
23
+ const existingIndex = this.products.findIndex(p => p.id === product.id);
24
+ if (existingIndex >= 0) {
25
+ this.products[existingIndex] = product;
26
+ return { updated: true, isNew: false, product };
27
+ }
28
+ else {
29
+ this.products.push(product);
30
+ return { updated: false, isNew: true, product };
31
+ }
11
32
  }
12
33
  async update(data, productId) {
13
- // Update is the same as create for this API
14
- this.products = { ...this.products, ...data };
15
- return { updated: true, isNew: false, product: this.products };
34
+ const product = data;
35
+ const existingIndex = this.products.findIndex(p => p.id === productId);
36
+ if (existingIndex >= 0) {
37
+ this.products[existingIndex] = { ...this.products[existingIndex], ...product };
38
+ return { updated: true, isNew: false, product: this.products[existingIndex] };
39
+ }
40
+ else {
41
+ this.products.push(product);
42
+ return { updated: false, isNew: true, product };
43
+ }
16
44
  }
17
45
  async delete(productId) {
46
+ const initialLength = this.products.length;
18
47
  this.products = this.products.filter((product) => product.id !== productId);
19
- return { deleted: true };
48
+ return { deleted: this.products.length < initialLength };
20
49
  }
21
50
  async search(searchQuery) {
22
- return { success: true, message: 'Products searched successfully', data: this.products };
51
+ const results = this.products.filter(product => Object.values(product).some(value => String(value).toLowerCase().includes(searchQuery.toLowerCase())));
52
+ return {
53
+ success: true,
54
+ message: `Successfully found ${results.length} products for "${searchQuery}"`,
55
+ data: results
56
+ };
23
57
  }
24
58
  }
25
59
  export const product = {
@@ -219,23 +219,38 @@ export declare class ProductApi {
219
219
  /**
220
220
  * Get all products for an agent with pagination
221
221
  */
222
- static getProducts(apiKey: string, agentId: string, page?: number, limit?: number): Promise<ApiResponse<ProductsResponse>>;
222
+ static getProducts(apiKey: string, agentId: string, page?: number, limit?: number): Promise<ProductsResponse | {
223
+ success: false;
224
+ message: string;
225
+ }>;
223
226
  /**
224
227
  * Create a new product
225
228
  */
226
- static createProduct(apiKey: string, agentId: string, productData: Product): Promise<ApiResponse<CreateProductResponse>>;
229
+ static createProduct(apiKey: string, agentId: string, productData: Product): Promise<CreateProductResponse | {
230
+ success: false;
231
+ message: string;
232
+ }>;
227
233
  /**
228
234
  * Update an existing product
229
235
  */
230
- static updateProduct(apiKey: string, agentId: string, productData: Product): Promise<ApiResponse<UpdateProductResponse>>;
236
+ static updateProduct(apiKey: string, agentId: string, productData: Product): Promise<UpdateProductResponse | {
237
+ success: false;
238
+ message: string;
239
+ }>;
231
240
  /**
232
241
  * Delete a product
233
242
  */
234
- static deleteProduct(apiKey: string, agentId: string, productId: string): Promise<ApiResponse<DeleteProductResponse>>;
243
+ static deleteProduct(apiKey: string, agentId: string, productId: string): Promise<DeleteProductResponse | {
244
+ success: false;
245
+ message: string;
246
+ }>;
235
247
  /**
236
248
  * Search products by text query
237
249
  */
238
- static searchProducts(apiKey: string, agentId: string, searchQuery: string): Promise<ApiResponse<SearchProductsResponse>>;
250
+ static searchProducts(apiKey: string, agentId: string, searchQuery: string): Promise<SearchProductsResponse | {
251
+ success: false;
252
+ message: string;
253
+ }>;
239
254
  }
240
255
  /**
241
256
  * Tool API calls (for compile command)
@@ -4,10 +4,10 @@
4
4
  */
5
5
  // Base URLs for different environments
6
6
  const BASE_URLS = {
7
- LOCAL: 'https://api.lua.dev',
8
- API: 'https://api.lua.dev',
9
- AUTH: 'https://auth.lua.dev',
10
- CHAT: 'https://api.lua.dev'
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
11
  };
12
12
  /**
13
13
  * Generic HTTP client with common error handling
@@ -176,41 +176,86 @@ export class ProductApi {
176
176
  * Get all products for an agent with pagination
177
177
  */
178
178
  static async getProducts(apiKey, agentId, page = 1, limit = 10) {
179
- return httpClient.get(`${BASE_URLS.API}/developer/agents/${agentId}/products?page=${page}&limit=${limit}`, {
179
+ const response = await httpClient.get(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products?page=${page}&limit=${limit}`, {
180
180
  Authorization: `Bearer ${apiKey}`,
181
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
+ }
182
191
  }
183
192
  /**
184
193
  * Create a new product
185
194
  */
186
195
  static async createProduct(apiKey, agentId, productData) {
187
- return httpClient.post(`${BASE_URLS.API}/developer/agents/${agentId}/products`, productData, {
196
+ const response = await httpClient.post(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products`, productData, {
188
197
  Authorization: `Bearer ${apiKey}`,
189
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
+ }
190
208
  }
191
209
  /**
192
210
  * Update an existing product
193
211
  */
194
212
  static async updateProduct(apiKey, agentId, productData) {
195
- return httpClient.put(`${BASE_URLS.API}/developer/agents/${agentId}/products`, productData, {
213
+ const response = await httpClient.put(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products`, productData, {
196
214
  Authorization: `Bearer ${apiKey}`,
197
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
+ }
198
225
  }
199
226
  /**
200
227
  * Delete a product
201
228
  */
202
229
  static async deleteProduct(apiKey, agentId, productId) {
203
- return httpClient.delete(`${BASE_URLS.API}/developer/agents/${agentId}/products/${productId}`, {
230
+ const response = await httpClient.delete(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products/${productId}`, {
204
231
  Authorization: `Bearer ${apiKey}`,
205
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
+ }
206
242
  }
207
243
  /**
208
244
  * Search products by text query
209
245
  */
210
246
  static async searchProducts(apiKey, agentId, searchQuery) {
211
- return httpClient.get(`${BASE_URLS.API}/developer/agents/${agentId}/products/search?searchQuery=${encodeURIComponent(searchQuery)}`, {
247
+ const response = await httpClient.get(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products/search?searchQuery=${encodeURIComponent(searchQuery)}`, {
212
248
  Authorization: `Bearer ${apiKey}`,
213
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
+ }
214
259
  }
215
260
  }
216
261
  /**
@@ -49,11 +49,11 @@ function updatePackageJson(srcPath, destPath) {
49
49
  }
50
50
  catch (error) {
51
51
  // If we can't read any package.json, use the fallback version
52
- console.log(`Using fallback CLI version: ${currentCliVersion}`);
52
+ // console.log(`Using fallback CLI version: ${currentCliVersion}`);
53
53
  }
54
54
  // Update the lua-cli dependency version
55
55
  if (templatePackageJson.dependencies && templatePackageJson.dependencies['lua-cli']) {
56
- templatePackageJson.dependencies['lua-cli'] = `^${currentCliVersion}`;
56
+ // templatePackageJson.dependencies['lua-cli'] = `^${currentCliVersion}`;
57
57
  }
58
58
  // Write the updated package.json
59
59
  fs.writeFileSync(destPath, JSON.stringify(templatePackageJson, null, 2) + '\n');
@@ -79,6 +79,7 @@ export function createSandbox(options) {
79
79
  return await ProductApi.deleteProduct(apiKey, agentId, productId);
80
80
  };
81
81
  const searchProducts = async (searchQuery) => {
82
+ console.log('searchProducts', searchQuery);
82
83
  return await ProductApi.searchProducts(apiKey, agentId, searchQuery);
83
84
  };
84
85
  // Create console object (use custom console if provided, otherwise default)
@@ -217,11 +218,13 @@ export function createSandbox(options) {
217
218
  }
218
219
  },
219
220
  product: {
220
- create: createProduct,
221
- get: getProducts,
222
- update: updateProduct,
223
- delete: deleteProduct,
224
- search: searchProducts
221
+ data: {
222
+ create: createProduct,
223
+ get: getProducts,
224
+ update: updateProduct,
225
+ delete: deleteProduct,
226
+ search: searchProducts
227
+ }
225
228
  },
226
229
  // Environment variables function
227
230
  env: (key) => envVars[key]