lua-cli 2.0.6 → 2.1.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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/product-api.d.ts +14 -0
- package/dist/product-api.js +27 -0
- package/dist/utils/sandbox.js +23 -1
- package/package.json +1 -1
- package/template/package-lock.json +4 -4
- package/template/package.json +1 -1
- package/template/src/tools/SearchProducts.ts +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class ProductAPI {
|
|
2
|
+
products: any;
|
|
3
|
+
constructor();
|
|
4
|
+
get(page?: number, limit?: number): Promise<any>;
|
|
5
|
+
create(data: Record<string, any>): Promise<any>;
|
|
6
|
+
update(data: Record<string, any>, productId: string): Promise<any>;
|
|
7
|
+
delete(productId: string): Promise<{
|
|
8
|
+
success: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
search(searchQuery: string): Promise<any>;
|
|
11
|
+
}
|
|
12
|
+
export declare const product: {
|
|
13
|
+
data: ProductAPI;
|
|
14
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class ProductAPI {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.products = {};
|
|
4
|
+
}
|
|
5
|
+
async get(page = 1, limit = 10) {
|
|
6
|
+
return { success: true, data: this.products };
|
|
7
|
+
}
|
|
8
|
+
async create(data) {
|
|
9
|
+
this.products = data;
|
|
10
|
+
return { success: true, data: this.products };
|
|
11
|
+
}
|
|
12
|
+
async update(data, productId) {
|
|
13
|
+
// Update is the same as create for this API
|
|
14
|
+
this.products = { ...this.products, ...data };
|
|
15
|
+
return { success: true, data: this.products };
|
|
16
|
+
}
|
|
17
|
+
async delete(productId) {
|
|
18
|
+
this.products = this.products.filter((product) => product.id !== productId);
|
|
19
|
+
return { success: true };
|
|
20
|
+
}
|
|
21
|
+
async search(searchQuery) {
|
|
22
|
+
return { success: true, data: this.products };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export const product = {
|
|
26
|
+
data: new ProductAPI()
|
|
27
|
+
};
|
package/dist/utils/sandbox.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createRequire } from "module";
|
|
|
2
2
|
import vm from "vm";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import fs from "fs";
|
|
5
|
-
import { UserDataApi } from "../services/api.js";
|
|
5
|
+
import { UserDataApi, ProductApi } from "../services/api.js";
|
|
6
6
|
import { readSkillConfig } from "./files.js";
|
|
7
7
|
/**
|
|
8
8
|
* Loads environment variables from multiple sources in priority order:
|
|
@@ -66,6 +66,21 @@ export function createSandbox(options) {
|
|
|
66
66
|
const linkUserData = async (data) => {
|
|
67
67
|
return await UserDataApi.createUserData(apiKey, agentId, data);
|
|
68
68
|
};
|
|
69
|
+
const createProduct = async (data) => {
|
|
70
|
+
return await ProductApi.createProduct(apiKey, agentId, data);
|
|
71
|
+
};
|
|
72
|
+
const getProducts = async (page = 1, limit = 10) => {
|
|
73
|
+
return await ProductApi.getProducts(apiKey, agentId, page, limit);
|
|
74
|
+
};
|
|
75
|
+
const updateProduct = async (data, productId) => {
|
|
76
|
+
return await ProductApi.updateProduct(apiKey, agentId, { ...data, id: productId });
|
|
77
|
+
};
|
|
78
|
+
const deleteProduct = async (productId) => {
|
|
79
|
+
return await ProductApi.deleteProduct(apiKey, agentId, productId);
|
|
80
|
+
};
|
|
81
|
+
const searchProducts = async (searchQuery) => {
|
|
82
|
+
return await ProductApi.searchProducts(apiKey, agentId, searchQuery);
|
|
83
|
+
};
|
|
69
84
|
// Create console object (use custom console if provided, otherwise default)
|
|
70
85
|
const consoleObj = customConsole || console;
|
|
71
86
|
// Create comprehensive polyfills for browser/Node.js APIs
|
|
@@ -201,6 +216,13 @@ export function createSandbox(options) {
|
|
|
201
216
|
create: linkUserData
|
|
202
217
|
}
|
|
203
218
|
},
|
|
219
|
+
product: {
|
|
220
|
+
create: createProduct,
|
|
221
|
+
get: getProducts,
|
|
222
|
+
update: updateProduct,
|
|
223
|
+
delete: deleteProduct,
|
|
224
|
+
search: searchProducts
|
|
225
|
+
},
|
|
204
226
|
// Environment variables function
|
|
205
227
|
env: (key) => envVars[key]
|
|
206
228
|
};
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"axios": "^1.6.0",
|
|
16
16
|
"inquirer": "^12.9.6",
|
|
17
17
|
"js-yaml": "^4.1.0",
|
|
18
|
-
"lua-cli": "2.0.
|
|
18
|
+
"lua-cli": "2.1.0-alpha.1",
|
|
19
19
|
"openai": "^5.23.0",
|
|
20
20
|
"zod": "^3.24.1"
|
|
21
21
|
},
|
|
@@ -2045,9 +2045,9 @@
|
|
|
2045
2045
|
}
|
|
2046
2046
|
},
|
|
2047
2047
|
"node_modules/lua-cli": {
|
|
2048
|
-
"version": "2.0.
|
|
2049
|
-
"resolved": "https://registry.npmjs.org/lua-cli/-/lua-cli-2.0.
|
|
2050
|
-
"integrity": "sha512-
|
|
2048
|
+
"version": "2.1.0-alpha.1",
|
|
2049
|
+
"resolved": "https://registry.npmjs.org/lua-cli/-/lua-cli-2.1.0-alpha.1.tgz",
|
|
2050
|
+
"integrity": "sha512-XJDR1RMOzcobw3NpfR6ZZbV1voBFNh7s9fn6rb5qbpSbxJycOc3OlDqHGMF7MUinoZJUzCRo62W7ceP+TFaKHQ==",
|
|
2051
2051
|
"license": "MIT",
|
|
2052
2052
|
"dependencies": {
|
|
2053
2053
|
"commander": "^14.0.1",
|
package/template/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { env, LuaTool } from "lua-cli/skill";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
3
|
+
import { product } from 'lua-cli/product-api';
|
|
4
4
|
import { Pinecone, Index } from '@pinecone-database/pinecone';
|
|
5
5
|
import OpenAI from "openai";
|
|
6
6
|
export class SearchProductsTool implements LuaTool {
|