lua-cli 3.0.2-alpha.3 → 3.0.2-alpha.5

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.
@@ -25,15 +25,12 @@ export default class ProductApi extends HttpClient {
25
25
  * @throws Error if the request fails or products cannot be retrieved
26
26
  */
27
27
  async get(page = 1, limit = 10) {
28
- console.log("get products", page, limit, this.agentId, this.apiKey);
29
28
  const response = await this.httpGet(`/developer/agents/${this.agentId}/products?page=${page}&limit=${limit}`, {
30
29
  Authorization: `Bearer ${this.apiKey}`,
31
30
  });
32
- console.log("get products response", response);
33
31
  if (response.success) {
34
32
  return new ProductPaginationInstance(this, response);
35
33
  }
36
- console.error(response);
37
34
  throw new Error(response.error?.message || "Failed to get products");
38
35
  }
39
36
  /**
@@ -131,11 +131,11 @@ export declare const Products: {
131
131
  /**
132
132
  * Retrieves products with pagination.
133
133
  *
134
- * @param limit - Items per page
135
134
  * @param page - Page number
135
+ * @param limit - Items per page
136
136
  * @returns Promise resolving to product list
137
137
  */
138
- get(limit?: number, page?: number): Promise<ProductPaginationInstance>;
138
+ get(page?: number, limit?: number): Promise<ProductPaginationInstance>;
139
139
  /**
140
140
  * Creates a new product.
141
141
  *
@@ -157,13 +157,13 @@ export const Products = {
157
157
  /**
158
158
  * Retrieves products with pagination.
159
159
  *
160
- * @param limit - Items per page
161
160
  * @param page - Page number
161
+ * @param limit - Items per page
162
162
  * @returns Promise resolving to product list
163
163
  */
164
- async get(limit, page) {
164
+ async get(page, limit) {
165
165
  const instance = await getProductsInstance();
166
- return instance.get(limit, page);
166
+ return instance.get(page, limit);
167
167
  },
168
168
  /**
169
169
  * Creates a new product.
package/dist/index.js CHANGED
@@ -10,16 +10,24 @@
10
10
  */
11
11
  import { Command } from "commander";
12
12
  import { setupAuthCommands, setupSkillCommands } from "./cli/command-definitions.js";
13
+ import { readFileSync } from "fs";
14
+ import { fileURLToPath } from "url";
15
+ import { dirname, join } from "path";
16
+ // Get version from package.json
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ const __dirname = dirname(__filename);
19
+ const packageJson = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8'));
20
+ const CLI_VERSION = packageJson.version;
13
21
  // Create the main CLI program
14
22
  const program = new Command();
15
23
  // Configure program metadata
16
24
  program
17
25
  .name("lua")
18
26
  .description("Lua AI - Build and deploy AI agents with superpowers")
19
- .version("2.5.8")
27
+ .version(CLI_VERSION)
20
28
  .addHelpText('before', `
21
29
  ------------------------------------------------------------------
22
- Lua AI CLI v2.5.8 - Build and deploy AI agents with superpowers
30
+ Lua AI CLI v${CLI_VERSION} - Build and deploy AI agents with superpowers
23
31
  ------------------------------------------------------------------
24
32
  `)
25
33
  .addHelpText('after', `
@@ -75,6 +75,7 @@ async function bundleAndCompressExecuteFunction(executeFunction, componentName,
75
75
  }
76
76
  const tempFile = path.join(tempDir, `${componentName}-${componentType}.ts`);
77
77
  const tempOutput = path.join(tempDir, `${componentName}-${componentType}.js`);
78
+ let moduleCode = ''; // Declare outside try block for debug mode access
78
79
  try {
79
80
  // Extract relevant imports from source file
80
81
  const relevantImports = extractRelevantImports(sourceFilePath);
@@ -85,7 +86,7 @@ async function bundleAndCompressExecuteFunction(executeFunction, componentName,
85
86
  }
86
87
  }
87
88
  // Write execute function as a module export with all relevant imports
88
- const moduleCode = `
89
+ moduleCode = `
89
90
  // ${componentType} execute function for ${componentName}
90
91
  ${relevantImports.join('\n')}
91
92
 
@@ -94,13 +95,18 @@ const executeFunc = ${executeFunction};
94
95
 
95
96
  export default executeFunc;
96
97
  `;
97
- fs.writeFileSync(tempFile, moduleCode);
98
98
  if (debugMode) {
99
- console.log(` → Created temp file: ${path.basename(tempFile)}`);
99
+ console.log(` → Using stdin bundling to preserve import resolution`);
100
100
  }
101
- // Bundle with esbuild using the source file's directory for import resolution
101
+ // Bundle with esbuild using stdin to preserve import resolution
102
+ // This ensures relative imports resolve correctly from the original source file location
102
103
  await build({
103
- entryPoints: [tempFile],
104
+ stdin: {
105
+ contents: moduleCode,
106
+ resolveDir: path.dirname(sourceFilePath), // Resolve imports from source file's directory
107
+ sourcefile: sourceFilePath, // Pretend we're the source file for better error messages
108
+ loader: 'ts',
109
+ },
104
110
  bundle: true,
105
111
  platform: 'node',
106
112
  target: 'node16',
@@ -109,7 +115,6 @@ export default executeFunc;
109
115
  outfile: tempOutput,
110
116
  external: [...EXTERNAL_PACKAGES], // Use same external packages as tools
111
117
  plugins: [sandboxGlobalsPlugin],
112
- absWorkingDir: path.dirname(sourceFilePath), // Use source file's directory for resolution
113
118
  });
114
119
  // Read bundled code and validate it exists and has content
115
120
  if (!fs.existsSync(tempOutput)) {
@@ -130,7 +135,6 @@ export default executeFunc;
130
135
  // Clean up temp files (unless in debug mode)
131
136
  if (!debugMode) {
132
137
  try {
133
- fs.unlinkSync(tempFile);
134
138
  fs.unlinkSync(tempOutput);
135
139
  }
136
140
  catch (cleanupError) {
@@ -138,9 +142,11 @@ export default executeFunc;
138
142
  }
139
143
  }
140
144
  else {
145
+ // In debug mode, write the moduleCode to tempFile for inspection
146
+ fs.writeFileSync(tempFile, moduleCode);
141
147
  console.log(` ℹ️ Preserved temp files for debugging:`);
142
- console.log(` - ${tempFile}`);
143
- console.log(` - ${tempOutput}`);
148
+ console.log(` - ${tempFile} (source with imports)`);
149
+ console.log(` - ${tempOutput} (bundled output)`);
144
150
  }
145
151
  return compressed;
146
152
  }
@@ -149,7 +155,14 @@ export default executeFunc;
149
155
  let errorMessage = `Warning: Could not bundle ${componentType} ${componentName}`;
150
156
  if (error.message && error.message.includes('Could not resolve')) {
151
157
  errorMessage += `\n Dependency resolution failed: ${error.message}`;
152
- errorMessage += `\n Hint: Ensure all imported packages are in package.json and run 'npm install'`;
158
+ // Check if it's a relative import issue
159
+ if (error.message.includes('"../') || error.message.includes('"./')) {
160
+ errorMessage += `\n Hint: Relative imports detected. Consider using TypeScript path aliases (e.g., @/services/...)`;
161
+ errorMessage += `\n Or ensure the import path is correct relative to: ${path.dirname(sourceFilePath)}`;
162
+ }
163
+ else {
164
+ errorMessage += `\n Hint: Ensure all imported packages are in package.json and run 'npm install'`;
165
+ }
153
166
  }
154
167
  else if (error.message && error.message.includes('Transform failed')) {
155
168
  errorMessage += `\n TypeScript compilation failed: ${error.message}`;
@@ -165,8 +178,6 @@ export default executeFunc;
165
178
  // Clean up on error (unless in debug mode)
166
179
  if (!debugMode) {
167
180
  try {
168
- if (fs.existsSync(tempFile))
169
- fs.unlinkSync(tempFile);
170
181
  if (fs.existsSync(tempOutput))
171
182
  fs.unlinkSync(tempOutput);
172
183
  }
@@ -175,7 +186,14 @@ export default executeFunc;
175
186
  }
176
187
  }
177
188
  else {
178
- console.log(` ℹ️ Temp files preserved for debugging (check dist/.temp/)`);
189
+ // In debug mode, write the moduleCode for inspection
190
+ try {
191
+ fs.writeFileSync(tempFile, moduleCode);
192
+ console.log(` ℹ️ Temp files preserved for debugging (check dist/.temp/)`);
193
+ }
194
+ catch (writeError) {
195
+ // Ignore write errors
196
+ }
179
197
  }
180
198
  return '';
181
199
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lua-cli",
3
- "version": "3.0.2-alpha.3",
3
+ "version": "3.0.2-alpha.5",
4
4
  "description": "Build, test, and deploy AI agents with custom tools, webhooks, and scheduled jobs. Features LuaAgent unified configuration, streaming chat, and batch deployment.",
5
5
  "readmeFilename": "README.md",
6
6
  "main": "dist/api-exports.js",
@@ -25,7 +25,7 @@ export class GetAllProductsTool implements LuaTool {
25
25
  });
26
26
 
27
27
  async execute(input: z.infer<typeof this.inputSchema>) {
28
- return await Products.get(input.limit, input.limit);
28
+ return await Products.get(input.page, input.limit);
29
29
  }
30
30
  }
31
31
 
@@ -1,5 +1,5 @@
1
1
  import { LuaSkill } from "lua-cli";
2
- import { CreateInlineJobTool, GetUserDataTool, UpdateUserDataTool, WritePoemTool } from "./tools/UserDataTool";
2
+ import { CreateInlineJobTool, GetUserDataTool, UpdateUserDataTool, WritePoemTool } from "../skills/tools/UserDataTool";
3
3
 
4
4
 
5
5
  const userSkill = new LuaSkill({