lua-cli 1.2.1 → 1.3.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/CHANGELOG.md +50 -0
- package/README.md +244 -63
- package/dist/commands/agents.js +17 -17
- package/dist/commands/apiKey.js +24 -19
- package/dist/commands/compile.d.ts +1 -0
- package/dist/commands/compile.js +1004 -0
- package/dist/commands/configure.js +93 -68
- package/dist/commands/deploy-new.d.ts +0 -0
- package/dist/commands/deploy-new.js +130 -0
- package/dist/commands/deploy.d.ts +19 -0
- package/dist/commands/deploy.js +81 -763
- package/dist/commands/destroy.js +26 -21
- package/dist/commands/dev.d.ts +63 -0
- package/dist/commands/dev.js +656 -0
- package/dist/commands/index.d.ts +4 -2
- package/dist/commands/index.js +4 -2
- package/dist/commands/init.js +297 -62
- package/dist/commands/push.d.ts +22 -0
- package/dist/commands/push.js +127 -0
- package/dist/commands/test.js +14 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +35 -19
- package/dist/services/api.d.ts +195 -0
- package/dist/services/api.js +209 -0
- package/dist/services/auth.d.ts +102 -0
- package/dist/services/auth.js +129 -40
- package/dist/skill.d.ts +22 -1
- package/dist/skill.js +21 -1
- package/dist/types/index.d.ts +16 -2
- package/dist/types/index.js +16 -1
- package/dist/user-data-api.d.ts +52 -0
- package/dist/user-data-api.js +151 -0
- package/dist/utils/cli.d.ts +34 -0
- package/dist/utils/cli.js +58 -0
- package/dist/utils/files.d.ts +4 -1
- package/dist/utils/files.js +61 -14
- package/dist/web/app.css +1050 -0
- package/dist/web/app.js +79 -0
- package/dist/web/tools-page.css +377 -0
- package/package.json +18 -5
- package/template/package-lock.json +32 -3
- package/template/package.json +3 -1
- package/template/{index.ts → src/index.ts} +13 -4
- package/template/src/tools/UserPreferencesTool.ts +73 -0
- package/template/tools/UserPreferencesTool.ts +73 -0
- package/template/tsconfig.json +1 -1
- package/template/.lua/deploy.json +0 -145
- /package/template/{services → src/services}/ApiService.ts +0 -0
- /package/template/{services → src/services}/GetWeather.ts +0 -0
- /package/template/{services → src/services}/MathService.ts +0 -0
- /package/template/{tools → src/tools}/AdvancedMathTool.ts +0 -0
- /package/template/{tools → src/tools}/CalculatorTool.ts +0 -0
- /package/template/{tools → src/tools}/CreatePostTool.ts +0 -0
- /package/template/{tools → src/tools}/GetUserDataTool.ts +0 -0
- /package/template/{tools → src/tools}/GetWeatherTool.ts +0 -0
package/dist/commands/deploy.js
CHANGED
|
@@ -1,779 +1,97 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
function
|
|
7
|
-
const compressed = gzipSync(code);
|
|
8
|
-
return compressed.toString('base64');
|
|
9
|
-
}
|
|
10
|
-
function decompressCode(compressedCode) {
|
|
11
|
-
const buffer = Buffer.from(compressedCode, 'base64');
|
|
12
|
-
return gunzipSync(buffer).toString('utf8');
|
|
13
|
-
}
|
|
14
|
-
export async function deployCommand() {
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import { loadApiKey, checkApiKey } from '../services/auth.js';
|
|
3
|
+
import { ApiService } from '../services/api.js';
|
|
4
|
+
import { readSkillConfig } from '../utils/files.js';
|
|
5
|
+
import { withErrorHandling, clearPromptLines, writeProgress, writeSuccess } from '../utils/cli.js';
|
|
6
|
+
export async function fetchVersions(apiKey, agentId, skillId) {
|
|
15
7
|
try {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
20
|
-
throw new Error("package.json not found in current directory");
|
|
21
|
-
}
|
|
22
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
23
|
-
const version = packageJson.version || "1.0.0";
|
|
24
|
-
const skillsName = packageJson.name || "lua-skill";
|
|
25
|
-
// Read index.ts file
|
|
26
|
-
const indexPath = path.join(process.cwd(), "index.ts");
|
|
27
|
-
if (!fs.existsSync(indexPath)) {
|
|
28
|
-
throw new Error("index.ts not found in current directory");
|
|
29
|
-
}
|
|
30
|
-
const indexContent = fs.readFileSync(indexPath, "utf8");
|
|
31
|
-
// Extract skill information
|
|
32
|
-
const skillInfo = await extractSkillInfo(indexContent);
|
|
33
|
-
// Create deployment data with compressed execute code
|
|
34
|
-
const deployData = {
|
|
35
|
-
version,
|
|
36
|
-
skillsName,
|
|
37
|
-
tools: skillInfo.map(tool => ({
|
|
38
|
-
...tool,
|
|
39
|
-
execute: compressCode(tool.execute)
|
|
40
|
-
}))
|
|
41
|
-
};
|
|
42
|
-
// Create .lua directory
|
|
43
|
-
const luaDir = path.join(process.cwd(), ".lua");
|
|
44
|
-
if (!fs.existsSync(luaDir)) {
|
|
45
|
-
fs.mkdirSync(luaDir, { recursive: true });
|
|
8
|
+
const response = await ApiService.Skill.getSkillVersions(apiKey, agentId, skillId);
|
|
9
|
+
if (!response.success) {
|
|
10
|
+
throw new Error(`Failed to fetch versions: ${response.error?.message || 'Unknown error'}`);
|
|
46
11
|
}
|
|
47
|
-
|
|
48
|
-
const jsonOutputPath = path.join(luaDir, "deploy.json");
|
|
49
|
-
fs.writeFileSync(jsonOutputPath, JSON.stringify(deployData, null, 2));
|
|
50
|
-
// Write individual tool files to .lua directory
|
|
51
|
-
for (const tool of skillInfo) {
|
|
52
|
-
const toolFilePath = path.join(luaDir, `${tool.name}.js`);
|
|
53
|
-
fs.writeFileSync(toolFilePath, tool.execute);
|
|
54
|
-
}
|
|
55
|
-
console.log(`📁 Compiled files written to: ${luaDir}`);
|
|
56
|
-
console.log(`📄 JSON output: ${jsonOutputPath}`);
|
|
57
|
-
console.log(`🔧 Tool files: ${skillInfo.map(t => `${t.name}.js`).join(', ')}`);
|
|
58
|
-
console.log("✅ Skill compilation completed successfully!");
|
|
12
|
+
return response.data;
|
|
59
13
|
}
|
|
60
14
|
catch (error) {
|
|
61
|
-
console.error("❌
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async function extractSkillInfo(indexContent) {
|
|
66
|
-
const tools = [];
|
|
67
|
-
// Find inline addTool calls: skill.addTool({...})
|
|
68
|
-
const inlineAddToolRegex = /skill\.addTool\(\s*\{([\s\S]*?)\}\s*\)/g;
|
|
69
|
-
let match;
|
|
70
|
-
while ((match = inlineAddToolRegex.exec(indexContent)) !== null) {
|
|
71
|
-
const toolContent = match[1];
|
|
72
|
-
// Extract tool properties
|
|
73
|
-
const nameMatch = toolContent.match(/name:\s*["']([^"']+)["']/);
|
|
74
|
-
const descriptionMatch = toolContent.match(/description:\s*["']([^"']+)["']/);
|
|
75
|
-
const inputSchemaMatch = toolContent.match(/inputSchema:\s*(\w+)/);
|
|
76
|
-
const outputSchemaMatch = toolContent.match(/outputSchema:\s*(\w+)/);
|
|
77
|
-
const executeMatch = toolContent.match(/execute:\s*async\s*\([^)]*\)\s*=>\s*\{([\s\S]*?)\}/);
|
|
78
|
-
if (nameMatch && descriptionMatch && inputSchemaMatch && outputSchemaMatch && executeMatch) {
|
|
79
|
-
const toolName = nameMatch[1];
|
|
80
|
-
const toolDescription = descriptionMatch[1];
|
|
81
|
-
const inputSchemaVar = inputSchemaMatch[1];
|
|
82
|
-
const outputSchemaVar = outputSchemaMatch[1];
|
|
83
|
-
const executeBody = executeMatch[1];
|
|
84
|
-
// Convert schemas to JSON Schema format
|
|
85
|
-
const inputSchema = convertSchemaToJSON(inputSchemaVar, indexContent);
|
|
86
|
-
const outputSchema = convertSchemaToJSON(outputSchemaVar, indexContent);
|
|
87
|
-
// Create self-contained execute function
|
|
88
|
-
const selfContainedExecute = await createSelfContainedExecute(executeBody, indexContent);
|
|
89
|
-
tools.push({
|
|
90
|
-
name: toolName,
|
|
91
|
-
description: toolDescription,
|
|
92
|
-
inputSchema,
|
|
93
|
-
outputSchema,
|
|
94
|
-
execute: selfContainedExecute
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// Find class-based addTool calls: skill.addTool(new SomeTool())
|
|
99
|
-
const classAddToolRegex = /skill\.addTool\(\s*new\s+(\w+)\(\)\s*\)/g;
|
|
100
|
-
let classMatch;
|
|
101
|
-
while ((classMatch = classAddToolRegex.exec(indexContent)) !== null) {
|
|
102
|
-
const className = classMatch[1];
|
|
103
|
-
// Find the tool class definition
|
|
104
|
-
const toolInfo = await extractToolFromClass(className, indexContent);
|
|
105
|
-
if (toolInfo) {
|
|
106
|
-
tools.push(toolInfo);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return tools;
|
|
110
|
-
}
|
|
111
|
-
function convertSchemaToJSON(schemaVar, indexContent) {
|
|
112
|
-
// Find the schema definition
|
|
113
|
-
const schemaRegex = new RegExp(`const\\s+${schemaVar}\\s*=\\s*z\\.object\\(\\{([\\s\\S]*?)\\}\\\);`, 'g');
|
|
114
|
-
const match = schemaRegex.exec(indexContent);
|
|
115
|
-
if (match) {
|
|
116
|
-
const schemaContent = match[1];
|
|
117
|
-
// Convert Zod schema to JSON Schema format
|
|
118
|
-
return {
|
|
119
|
-
type: "object",
|
|
120
|
-
properties: parseZodProperties(schemaContent),
|
|
121
|
-
required: extractRequiredFields(schemaContent)
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
// If no match found, return empty schema
|
|
125
|
-
return { type: "object", properties: {} };
|
|
126
|
-
}
|
|
127
|
-
function parseZodProperties(schemaContent) {
|
|
128
|
-
const properties = {};
|
|
129
|
-
// Simple regex to find z.string(), z.number(), etc.
|
|
130
|
-
const fieldRegex = /(\w+):\s*z\.(\w+)\(\)/g;
|
|
131
|
-
let match;
|
|
132
|
-
while ((match = fieldRegex.exec(schemaContent)) !== null) {
|
|
133
|
-
const fieldName = match[1];
|
|
134
|
-
const fieldType = match[2];
|
|
135
|
-
switch (fieldType) {
|
|
136
|
-
case 'string':
|
|
137
|
-
properties[fieldName] = { type: 'string' };
|
|
138
|
-
break;
|
|
139
|
-
case 'number':
|
|
140
|
-
properties[fieldName] = { type: 'number' };
|
|
141
|
-
break;
|
|
142
|
-
case 'boolean':
|
|
143
|
-
properties[fieldName] = { type: 'boolean' };
|
|
144
|
-
break;
|
|
145
|
-
default:
|
|
146
|
-
properties[fieldName] = { type: 'string' };
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return properties;
|
|
150
|
-
}
|
|
151
|
-
function extractRequiredFields(schemaContent) {
|
|
152
|
-
const required = [];
|
|
153
|
-
const fieldRegex = /(\w+):\s*z\.(\w+)\(\)/g;
|
|
154
|
-
let match;
|
|
155
|
-
while ((match = fieldRegex.exec(schemaContent)) !== null) {
|
|
156
|
-
required.push(match[1]);
|
|
15
|
+
console.error("❌ Error fetching versions:", error);
|
|
16
|
+
throw error;
|
|
157
17
|
}
|
|
158
|
-
return required;
|
|
159
18
|
}
|
|
160
|
-
async function
|
|
161
|
-
const dependencies = [];
|
|
162
|
-
const bundledPackages = new Set();
|
|
163
|
-
// 1. Parse external package imports and bundle their code
|
|
164
|
-
const allImportRegex = /import\s+(?:(?:\{([^}]+)\})|(\w+))\s+from\s+["']([^"']+)["']/g;
|
|
165
|
-
let importMatch;
|
|
166
|
-
while ((importMatch = allImportRegex.exec(indexContent)) !== null) {
|
|
167
|
-
const namedImports = importMatch[1]; // Named imports like { z }
|
|
168
|
-
const defaultImport = importMatch[2]; // Default import like axios
|
|
169
|
-
const packagePath = importMatch[3];
|
|
170
|
-
// Skip local imports (relative paths)
|
|
171
|
-
if (packagePath.startsWith('./') || packagePath.startsWith('../')) {
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
// Skip lua-cli imports (these are handled separately)
|
|
175
|
-
if (packagePath.startsWith('lua-cli')) {
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
// Skip zod - assume it's always available on target machine
|
|
179
|
-
if (packagePath === 'zod') {
|
|
180
|
-
// Add require statement for zod instead of bundling
|
|
181
|
-
if (namedImports) {
|
|
182
|
-
const importsList = namedImports.split(',').map(imp => imp.trim());
|
|
183
|
-
const usedImports = importsList.filter(imp => executeBody.includes(imp) || indexContent.includes(`${imp}.`));
|
|
184
|
-
if (usedImports.length > 0) {
|
|
185
|
-
const requireStatement = usedImports.length === 1
|
|
186
|
-
? `const { ${usedImports[0]} } = require('zod');`
|
|
187
|
-
: `const { ${usedImports.join(', ')} } = require('zod');`;
|
|
188
|
-
bundledPackages.add(requireStatement);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
else if (defaultImport) {
|
|
192
|
-
bundledPackages.add(`const ${defaultImport} = require('zod');`);
|
|
193
|
-
}
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
// Bundle other external packages
|
|
197
|
-
if (namedImports || defaultImport) {
|
|
198
|
-
const packageCode = await bundlePackageCode(packagePath, namedImports, defaultImport);
|
|
199
|
-
if (packageCode) {
|
|
200
|
-
bundledPackages.add(packageCode);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
// 2. Extract class definitions with proper brace matching
|
|
205
|
-
const classRegex = /class\s+(\w+)(?:\s+extends\s+\w+)?\s*\{/g;
|
|
206
|
-
let classMatch;
|
|
207
|
-
while ((classMatch = classRegex.exec(indexContent)) !== null) {
|
|
208
|
-
const className = classMatch[1];
|
|
209
|
-
const classStart = classMatch.index;
|
|
210
|
-
// Find the matching closing brace
|
|
211
|
-
let braceCount = 0;
|
|
212
|
-
let classEnd = classStart;
|
|
213
|
-
let found = false;
|
|
214
|
-
for (let i = classStart; i < indexContent.length; i++) {
|
|
215
|
-
if (indexContent[i] === '{') {
|
|
216
|
-
braceCount++;
|
|
217
|
-
}
|
|
218
|
-
else if (indexContent[i] === '}') {
|
|
219
|
-
braceCount--;
|
|
220
|
-
if (braceCount === 0) {
|
|
221
|
-
classEnd = i;
|
|
222
|
-
found = true;
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (found) {
|
|
228
|
-
const fullClass = indexContent.substring(classStart, classEnd + 1);
|
|
229
|
-
// Check if this class is used in the execute function
|
|
230
|
-
let isUsed = false;
|
|
231
|
-
// Direct usage in execute body
|
|
232
|
-
if (executeBody.includes(`new ${className}`) ||
|
|
233
|
-
executeBody.includes(`${className}.`) ||
|
|
234
|
-
executeBody.includes(`${className}(`)) {
|
|
235
|
-
isUsed = true;
|
|
236
|
-
}
|
|
237
|
-
// Check if any variable that uses this class is referenced in execute body
|
|
238
|
-
const variableRegex = new RegExp(`(?:const|let|var)\\s+(\\w+)\\s*=\\s*new\\s+${className}\\s*\\([^)]*\\);`, 'g');
|
|
239
|
-
let varMatch;
|
|
240
|
-
while ((varMatch = variableRegex.exec(indexContent)) !== null) {
|
|
241
|
-
const varName = varMatch[1];
|
|
242
|
-
if (executeBody.includes(varName)) {
|
|
243
|
-
isUsed = true;
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
if (isUsed) {
|
|
248
|
-
dependencies.push(fullClass);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
// 3. Extract function definitions
|
|
253
|
-
const functionRegex = /(?:async\s+)?function\s+(\w+)\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/g;
|
|
254
|
-
let functionMatch;
|
|
255
|
-
while ((functionMatch = functionRegex.exec(indexContent)) !== null) {
|
|
256
|
-
const functionName = functionMatch[1];
|
|
257
|
-
const functionBody = functionMatch[2];
|
|
258
|
-
if (executeBody.includes(functionName)) {
|
|
259
|
-
dependencies.push(`function ${functionName}() {\n${functionBody}\n}`);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
// 4. Extract const/let/var declarations (avoid duplicates)
|
|
263
|
-
const varRegex = /(?:const|let|var)\s+(\w+)\s*=\s*([^;]+);/g;
|
|
264
|
-
const declaredVars = new Set();
|
|
265
|
-
let varMatch;
|
|
266
|
-
while ((varMatch = varRegex.exec(indexContent)) !== null) {
|
|
267
|
-
const varName = varMatch[1];
|
|
268
|
-
const varValue = varMatch[2];
|
|
269
|
-
// Skip if it's a class instantiation (we'll handle that separately)
|
|
270
|
-
if (varValue.includes('new ') && varValue.includes('()')) {
|
|
271
|
-
continue;
|
|
272
|
-
}
|
|
273
|
-
// Skip if already declared
|
|
274
|
-
if (declaredVars.has(varName)) {
|
|
275
|
-
continue;
|
|
276
|
-
}
|
|
277
|
-
if (executeBody.includes(varName)) {
|
|
278
|
-
declaredVars.add(varName);
|
|
279
|
-
dependencies.push(`const ${varName} = ${varValue};`);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
// 5. Extract class instantiations (avoid duplicates)
|
|
283
|
-
const instantiationRegex = /(?:const|let|var)\s+(\w+)\s*=\s*new\s+(\w+)\([^)]*\);/g;
|
|
284
|
-
let instantiationMatch;
|
|
285
|
-
while ((instantiationMatch = instantiationRegex.exec(indexContent)) !== null) {
|
|
286
|
-
const instanceName = instantiationMatch[1];
|
|
287
|
-
const className = instantiationMatch[2];
|
|
288
|
-
// Skip if already declared
|
|
289
|
-
if (declaredVars.has(instanceName)) {
|
|
290
|
-
continue;
|
|
291
|
-
}
|
|
292
|
-
if (executeBody.includes(instanceName)) {
|
|
293
|
-
declaredVars.add(instanceName);
|
|
294
|
-
dependencies.push(`const ${instanceName} = new ${className}();`);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
// 6. Create the self-contained execute function
|
|
298
|
-
const allDependencies = [...Array.from(bundledPackages), ...dependencies];
|
|
299
|
-
const dependencyCode = allDependencies.join('\n');
|
|
300
|
-
// Strip TypeScript type annotations for JavaScript compatibility (only for local code)
|
|
301
|
-
const cleanDependencyCode = allDependencies.map(dep => {
|
|
302
|
-
// Only strip TypeScript from local dependencies, not bundled packages
|
|
303
|
-
if (dep.includes('require(') || dep.includes('import ')) {
|
|
304
|
-
return dep; // Skip bundled packages
|
|
305
|
-
}
|
|
306
|
-
return dep
|
|
307
|
-
.replace(/:\s*string/g, '') // Remove : string
|
|
308
|
-
.replace(/:\s*number/g, '') // Remove : number
|
|
309
|
-
.replace(/:\s*boolean/g, '') // Remove : boolean
|
|
310
|
-
.replace(/:\s*any/g, '') // Remove : any
|
|
311
|
-
.replace(/:\s*void/g, '') // Remove : void
|
|
312
|
-
.replace(/:\s*object/g, '') // Remove : object
|
|
313
|
-
.replace(/:\s*Array<[^>]+>/g, '') // Remove : Array<Type>
|
|
314
|
-
.replace(/:\s*Promise<[^>]+>/g, '') // Remove : Promise<Type>
|
|
315
|
-
.replace(/:\s*Record<[^>]+>/g, ''); // Remove : Record<Type>
|
|
316
|
-
}).join('\n');
|
|
317
|
-
const cleanExecuteBody = executeBody
|
|
318
|
-
.replace(/:\s*string/g, '') // Remove : string
|
|
319
|
-
.replace(/:\s*number/g, '') // Remove : number
|
|
320
|
-
.replace(/:\s*boolean/g, '') // Remove : boolean
|
|
321
|
-
.replace(/:\s*any/g, '') // Remove : any
|
|
322
|
-
.replace(/:\s*void/g, '') // Remove : void
|
|
323
|
-
.replace(/:\s*object/g, '') // Remove : object
|
|
324
|
-
.replace(/:\s*Array<[^>]+>/g, '') // Remove : Array<Type>
|
|
325
|
-
.replace(/:\s*Promise<[^>]+>/g, '') // Remove : Promise<Type>
|
|
326
|
-
.replace(/:\s*Record<[^>]+>/g, ''); // Remove : Record<Type>
|
|
327
|
-
const selfContainedExecute = `async (input) => {
|
|
328
|
-
${cleanDependencyCode ? ` ${cleanDependencyCode.split('\n').join('\n ')}\n` : ''} ${cleanExecuteBody.trim()}
|
|
329
|
-
}`;
|
|
330
|
-
return selfContainedExecute;
|
|
331
|
-
}
|
|
332
|
-
async function bundlePackageCode(packagePath, namedImports, defaultImport) {
|
|
19
|
+
export async function publishVersion(apiKey, agentId, skillId, version) {
|
|
333
20
|
try {
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
if (!fs.existsSync(luaDir)) {
|
|
338
|
-
fs.mkdirSync(luaDir, { recursive: true });
|
|
339
|
-
}
|
|
340
|
-
const entryFile = path.join(luaDir, `${packagePath}-entry.cjs`);
|
|
341
|
-
const outputFile = path.join(luaDir, `${packagePath}-bundle.cjs`);
|
|
342
|
-
// Create entry file based on import type
|
|
343
|
-
let entryContent = '';
|
|
344
|
-
if (defaultImport) {
|
|
345
|
-
// For default imports like `import axios from 'axios'`
|
|
346
|
-
entryContent = `import ${defaultImport} from '${packagePath}';\nmodule.exports = ${defaultImport};`;
|
|
347
|
-
}
|
|
348
|
-
else if (namedImports) {
|
|
349
|
-
// For named imports like `import { z } from 'zod'`
|
|
350
|
-
const importsList = namedImports.split(',').map(imp => imp.trim());
|
|
351
|
-
entryContent = `import { ${importsList.join(', ')} } from '${packagePath}';\nmodule.exports = { ${importsList.join(', ')} };`;
|
|
352
|
-
}
|
|
353
|
-
else {
|
|
354
|
-
// Fallback - import everything
|
|
355
|
-
entryContent = `import * as ${packagePath.replace(/[^a-zA-Z0-9]/g, '_')} from '${packagePath}';\nmodule.exports = ${packagePath.replace(/[^a-zA-Z0-9]/g, '_')};`;
|
|
356
|
-
}
|
|
357
|
-
// Write entry file
|
|
358
|
-
fs.writeFileSync(entryFile, entryContent);
|
|
359
|
-
// Bundle with esbuild
|
|
360
|
-
const result = await build({
|
|
361
|
-
entryPoints: [entryFile],
|
|
362
|
-
bundle: true,
|
|
363
|
-
format: 'cjs', // CommonJS format
|
|
364
|
-
platform: 'node',
|
|
365
|
-
target: 'node16',
|
|
366
|
-
outfile: outputFile,
|
|
367
|
-
external: [], // Bundle everything
|
|
368
|
-
minify: false, // Keep readable for debugging
|
|
369
|
-
sourcemap: false,
|
|
370
|
-
write: true,
|
|
371
|
-
resolveExtensions: ['.js', '.ts', '.json'],
|
|
372
|
-
mainFields: ['main', 'module', 'browser'],
|
|
373
|
-
conditions: ['node'],
|
|
374
|
-
nodePaths: [
|
|
375
|
-
path.join(process.cwd(), 'node_modules'),
|
|
376
|
-
path.join(process.cwd(), '..', 'node_modules'),
|
|
377
|
-
path.join(process.cwd(), '..', '..', 'node_modules')
|
|
378
|
-
],
|
|
379
|
-
absWorkingDir: process.cwd(),
|
|
380
|
-
});
|
|
381
|
-
if (result.errors.length > 0) {
|
|
382
|
-
console.warn(`Warning: esbuild errors for package ${packagePath}:`, result.errors);
|
|
383
|
-
return null;
|
|
384
|
-
}
|
|
385
|
-
// Read the bundled output
|
|
386
|
-
if (!fs.existsSync(outputFile)) {
|
|
387
|
-
console.warn(`Warning: Bundle output not found for package ${packagePath}`);
|
|
388
|
-
return null;
|
|
21
|
+
const response = await ApiService.Skill.publishSkillVersion(apiKey, agentId, skillId, version);
|
|
22
|
+
if (!response.success) {
|
|
23
|
+
throw new Error(`Failed to publish version: ${response.error?.message || 'Unknown error'}`);
|
|
389
24
|
}
|
|
390
|
-
|
|
391
|
-
// Clean up temporary files
|
|
392
|
-
try {
|
|
393
|
-
fs.unlinkSync(entryFile);
|
|
394
|
-
fs.unlinkSync(outputFile);
|
|
395
|
-
}
|
|
396
|
-
catch (cleanupError) {
|
|
397
|
-
// Ignore cleanup errors
|
|
398
|
-
}
|
|
399
|
-
// Create the final bundled code
|
|
400
|
-
let finalCode = '';
|
|
401
|
-
if (defaultImport) {
|
|
402
|
-
finalCode = `const ${defaultImport} = (function() {\n${bundledContent}\n return module.exports;\n})();\n`;
|
|
403
|
-
}
|
|
404
|
-
else if (namedImports) {
|
|
405
|
-
const importsList = namedImports.split(',').map(imp => imp.trim());
|
|
406
|
-
finalCode = `(function() {\n${bundledContent}\n})();\n`;
|
|
407
|
-
finalCode += `const { ${importsList.join(', ')} } = module.exports;\n`;
|
|
408
|
-
}
|
|
409
|
-
else {
|
|
410
|
-
finalCode = `(function() {\n${bundledContent}\n})();\n`;
|
|
411
|
-
}
|
|
412
|
-
return finalCode;
|
|
25
|
+
return response.data;
|
|
413
26
|
}
|
|
414
27
|
catch (error) {
|
|
415
|
-
console.
|
|
416
|
-
|
|
417
|
-
if (packagePath === 'axios') {
|
|
418
|
-
return createWorkingAxiosImplementation();
|
|
419
|
-
}
|
|
420
|
-
return null;
|
|
28
|
+
console.error("❌ Error publishing version:", error);
|
|
29
|
+
throw error;
|
|
421
30
|
}
|
|
422
31
|
}
|
|
423
|
-
function
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
get: async (url, config = {}) => {
|
|
428
|
-
const searchParams = new URLSearchParams(config.params || {});
|
|
429
|
-
const fullUrl = searchParams.toString() ? \`\${url}?\${searchParams}\` : url;
|
|
430
|
-
|
|
431
|
-
const response = await fetch(fullUrl, {
|
|
432
|
-
method: 'GET',
|
|
433
|
-
headers: {
|
|
434
|
-
'Content-Type': 'application/json',
|
|
435
|
-
...config.headers
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
if (!response.ok) {
|
|
440
|
-
const error = new Error(\`Request failed with status \${response.status}\`);
|
|
441
|
-
error.response = { status: response.status, statusText: response.statusText };
|
|
442
|
-
throw error;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
const data = await response.json();
|
|
446
|
-
return {
|
|
447
|
-
data,
|
|
448
|
-
status: response.status,
|
|
449
|
-
statusText: response.statusText,
|
|
450
|
-
headers: response.headers,
|
|
451
|
-
config: config
|
|
452
|
-
};
|
|
453
|
-
},
|
|
454
|
-
|
|
455
|
-
post: async (url, data, config = {}) => {
|
|
456
|
-
const response = await fetch(url, {
|
|
457
|
-
method: 'POST',
|
|
458
|
-
headers: {
|
|
459
|
-
'Content-Type': 'application/json',
|
|
460
|
-
...config.headers
|
|
461
|
-
},
|
|
462
|
-
body: JSON.stringify(data)
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
if (!response.ok) {
|
|
466
|
-
const error = new Error(\`Request failed with status \${response.status}\`);
|
|
467
|
-
error.response = { status: response.status, statusText: response.statusText };
|
|
468
|
-
throw error;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
const responseData = await response.json();
|
|
472
|
-
return {
|
|
473
|
-
data: responseData,
|
|
474
|
-
status: response.status,
|
|
475
|
-
statusText: response.statusText,
|
|
476
|
-
headers: response.headers,
|
|
477
|
-
config: config
|
|
478
|
-
};
|
|
479
|
-
},
|
|
480
|
-
|
|
481
|
-
put: async (url, data, config = {}) => {
|
|
482
|
-
const response = await fetch(url, {
|
|
483
|
-
method: 'PUT',
|
|
484
|
-
headers: {
|
|
485
|
-
'Content-Type': 'application/json',
|
|
486
|
-
...config.headers
|
|
487
|
-
},
|
|
488
|
-
body: JSON.stringify(data)
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
if (!response.ok) {
|
|
492
|
-
const error = new Error(\`Request failed with status \${response.status}\`);
|
|
493
|
-
error.response = { status: response.status, statusText: response.statusText };
|
|
494
|
-
throw error;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
const responseData = await response.json();
|
|
498
|
-
return {
|
|
499
|
-
data: responseData,
|
|
500
|
-
status: response.status,
|
|
501
|
-
statusText: response.statusText,
|
|
502
|
-
headers: response.headers,
|
|
503
|
-
config: config
|
|
504
|
-
};
|
|
505
|
-
},
|
|
506
|
-
|
|
507
|
-
delete: async (url, config = {}) => {
|
|
508
|
-
const response = await fetch(url, {
|
|
509
|
-
method: 'DELETE',
|
|
510
|
-
headers: {
|
|
511
|
-
'Content-Type': 'application/json',
|
|
512
|
-
...config.headers
|
|
513
|
-
}
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
if (!response.ok) {
|
|
517
|
-
const error = new Error(\`Request failed with status \${response.status}\`);
|
|
518
|
-
error.response = { status: response.status, statusText: response.statusText };
|
|
519
|
-
throw error;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
const responseData = await response.json();
|
|
523
|
-
return {
|
|
524
|
-
data: responseData,
|
|
525
|
-
status: response.status,
|
|
526
|
-
statusText: response.statusText,
|
|
527
|
-
headers: response.headers,
|
|
528
|
-
config: config
|
|
529
|
-
};
|
|
530
|
-
},
|
|
531
|
-
|
|
532
|
-
patch: async (url, data, config = {}) => {
|
|
533
|
-
const response = await fetch(url, {
|
|
534
|
-
method: 'PATCH',
|
|
535
|
-
headers: {
|
|
536
|
-
'Content-Type': 'application/json',
|
|
537
|
-
...config.headers
|
|
538
|
-
},
|
|
539
|
-
body: JSON.stringify(data)
|
|
540
|
-
});
|
|
541
|
-
|
|
542
|
-
if (!response.ok) {
|
|
543
|
-
const error = new Error(\`Request failed with status \${response.status}\`);
|
|
544
|
-
error.response = { status: response.status, statusText: response.statusText };
|
|
545
|
-
throw error;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
const responseData = await response.json();
|
|
549
|
-
return {
|
|
550
|
-
data: responseData,
|
|
551
|
-
status: response.status,
|
|
552
|
-
statusText: response.statusText,
|
|
553
|
-
headers: response.headers,
|
|
554
|
-
config: config
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
|
-
};
|
|
558
|
-
`;
|
|
559
|
-
}
|
|
560
|
-
async function extractToolFromClass(className, indexContent) {
|
|
561
|
-
// Find the import statement for this class
|
|
562
|
-
const importRegex = new RegExp(`import\\s+${className}\\s+from\\s+["']([^"']+)["']`, 'g');
|
|
563
|
-
const importMatch = importRegex.exec(indexContent);
|
|
564
|
-
if (!importMatch) {
|
|
565
|
-
console.warn(`Warning: Could not find import for class ${className}`);
|
|
566
|
-
return null;
|
|
567
|
-
}
|
|
568
|
-
const importPath = importMatch[1];
|
|
569
|
-
// Read the tool file
|
|
570
|
-
const toolFilePath = path.join(process.cwd(), importPath.replace('./', '') + '.ts');
|
|
571
|
-
if (!fs.existsSync(toolFilePath)) {
|
|
572
|
-
console.warn(`Warning: Tool file not found: ${toolFilePath}`);
|
|
573
|
-
return null;
|
|
574
|
-
}
|
|
575
|
-
const toolContent = fs.readFileSync(toolFilePath, 'utf8');
|
|
576
|
-
// Extract tool properties from the class
|
|
577
|
-
const nameMatch = toolContent.match(/this\.name\s*=\s*["']([^"']+)["']/);
|
|
578
|
-
const descriptionMatch = toolContent.match(/this\.description\s*=\s*["']([^"']+)["']/);
|
|
579
|
-
if (!nameMatch || !descriptionMatch) {
|
|
580
|
-
console.warn(`Warning: Could not extract name or description from ${className}`);
|
|
581
|
-
return null;
|
|
582
|
-
}
|
|
583
|
-
const toolName = nameMatch[1];
|
|
584
|
-
const toolDescription = descriptionMatch[1];
|
|
585
|
-
// Extract schemas
|
|
586
|
-
const inputSchemaMatch = toolContent.match(/const\s+(\w+)\s*=\s*z\.object\(/);
|
|
587
|
-
const outputSchemaMatch = toolContent.match(/const\s+(\w+)\s*=\s*z\.object\(/);
|
|
588
|
-
if (!inputSchemaMatch) {
|
|
589
|
-
console.warn(`Warning: Could not find input schema in ${className}`);
|
|
590
|
-
return null;
|
|
591
|
-
}
|
|
592
|
-
// Convert schemas to JSON Schema format
|
|
593
|
-
const inputSchema = convertSchemaToJSON(inputSchemaMatch[1], toolContent);
|
|
594
|
-
const outputSchema = outputSchemaMatch ? convertSchemaToJSON(outputSchemaMatch[1], toolContent) : { type: "object" };
|
|
595
|
-
// Extract execute method
|
|
596
|
-
const executeMatch = toolContent.match(/async\s+execute\s*\([^)]*\)\s*\{([\s\S]*?)\}/);
|
|
597
|
-
if (!executeMatch) {
|
|
598
|
-
console.warn(`Warning: Could not find execute method in ${className}`);
|
|
599
|
-
return null;
|
|
600
|
-
}
|
|
601
|
-
const executeBody = executeMatch[1];
|
|
602
|
-
// For class-based tools, we need to create a self-contained function that includes:
|
|
603
|
-
// 1. The service classes
|
|
604
|
-
// 2. Class instantiation
|
|
605
|
-
// 3. The execute logic
|
|
606
|
-
const selfContainedExecute = await createClassBasedExecute(executeBody, toolContent, className);
|
|
607
|
-
return {
|
|
608
|
-
name: toolName,
|
|
609
|
-
description: toolDescription,
|
|
610
|
-
inputSchema,
|
|
611
|
-
outputSchema,
|
|
612
|
-
execute: selfContainedExecute
|
|
613
|
-
};
|
|
32
|
+
function formatVersionChoice(version) {
|
|
33
|
+
const currentIndicator = version.isCurrent ? ' (CURRENT)' : '';
|
|
34
|
+
const date = new Date(version.createdDate).toLocaleDateString();
|
|
35
|
+
return `${version.version}${currentIndicator} - Created: ${date} by ${version.createdByEmail}`;
|
|
614
36
|
}
|
|
615
|
-
async function
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
}
|
|
629
|
-
//
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}
|
|
652
|
-
continue;
|
|
653
|
-
}
|
|
654
|
-
// Handle local service imports
|
|
655
|
-
if (packagePath.startsWith('./') || packagePath.startsWith('../')) {
|
|
656
|
-
// The tool files are in tools/ subdirectory, so we need to resolve from there
|
|
657
|
-
const toolDir = path.join(process.cwd(), 'tools');
|
|
658
|
-
// Resolve the service file path correctly
|
|
659
|
-
// If the import is ../services/ApiService, resolve it relative to the tools directory
|
|
660
|
-
const serviceFilePath = path.resolve(process.cwd(), 'tools', packagePath + '.ts');
|
|
661
|
-
if (fs.existsSync(serviceFilePath)) {
|
|
662
|
-
const serviceContent = fs.readFileSync(serviceFilePath, 'utf8');
|
|
663
|
-
// Process all imports in the service file
|
|
664
|
-
const serviceImportRegex = /import\s+(?:(?:\{([^}]+)\})|(\w+))\s+from\s+["']([^"']+)["']/g;
|
|
665
|
-
let serviceImportMatch;
|
|
666
|
-
while ((serviceImportMatch = serviceImportRegex.exec(serviceContent)) !== null) {
|
|
667
|
-
const namedImports = serviceImportMatch[1];
|
|
668
|
-
const defaultImport = serviceImportMatch[2];
|
|
669
|
-
const packagePath = serviceImportMatch[3];
|
|
670
|
-
// Skip lua-cli imports
|
|
671
|
-
if (packagePath.startsWith('lua-cli')) {
|
|
672
|
-
continue;
|
|
673
|
-
}
|
|
674
|
-
// Handle zod
|
|
675
|
-
if (packagePath === 'zod') {
|
|
676
|
-
if (namedImports) {
|
|
677
|
-
const importsList = namedImports.split(',').map(imp => imp.trim());
|
|
678
|
-
const usedImports = importsList.filter(imp => serviceContent.includes(`${imp}.`));
|
|
679
|
-
if (usedImports.length > 0) {
|
|
680
|
-
const requireStatement = usedImports.length === 1
|
|
681
|
-
? `const { ${usedImports[0]} } = require('zod');`
|
|
682
|
-
: `const { ${usedImports.join(', ')} } = require('zod');`;
|
|
683
|
-
bundledPackages.add(requireStatement);
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
else if (defaultImport) {
|
|
687
|
-
bundledPackages.add(`const ${defaultImport} = require('zod');`);
|
|
688
|
-
}
|
|
689
|
-
continue;
|
|
690
|
-
}
|
|
691
|
-
// Handle axios - bundle it properly
|
|
692
|
-
if (packagePath === 'axios') {
|
|
693
|
-
const packageCode = await bundlePackageCode(packagePath, namedImports, defaultImport);
|
|
694
|
-
if (packageCode) {
|
|
695
|
-
bundledPackages.add(packageCode);
|
|
696
|
-
}
|
|
697
|
-
continue;
|
|
698
|
-
}
|
|
699
|
-
// Bundle other external packages
|
|
700
|
-
if (namedImports || defaultImport) {
|
|
701
|
-
const packageCode = await bundlePackageCode(packagePath, namedImports, defaultImport);
|
|
702
|
-
if (packageCode) {
|
|
703
|
-
bundledPackages.add(packageCode);
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
// Extract the service class with proper brace matching
|
|
708
|
-
const classRegex = /class\s+(\w+)(?:\s+extends\s+\w+)?\s*\{/g;
|
|
709
|
-
let classMatch = classRegex.exec(serviceContent);
|
|
710
|
-
if (classMatch) {
|
|
711
|
-
const serviceClassName = classMatch[1];
|
|
712
|
-
const startIndex = classMatch.index + classMatch[0].length - 1; // Position of opening brace
|
|
713
|
-
// Find matching closing brace
|
|
714
|
-
let braceCount = 1;
|
|
715
|
-
let endIndex = startIndex + 1;
|
|
716
|
-
while (endIndex < serviceContent.length && braceCount > 0) {
|
|
717
|
-
if (serviceContent[endIndex] === '{')
|
|
718
|
-
braceCount++;
|
|
719
|
-
else if (serviceContent[endIndex] === '}')
|
|
720
|
-
braceCount--;
|
|
721
|
-
endIndex++;
|
|
722
|
-
}
|
|
723
|
-
if (braceCount === 0) {
|
|
724
|
-
const serviceClassBody = serviceContent.substring(startIndex + 1, endIndex - 1);
|
|
725
|
-
// Clean up the class body (remove TypeScript types)
|
|
726
|
-
const cleanClassBody = serviceClassBody
|
|
727
|
-
.replace(/:\s*string/g, '')
|
|
728
|
-
.replace(/:\s*number/g, '')
|
|
729
|
-
.replace(/:\s*boolean/g, '')
|
|
730
|
-
.replace(/:\s*any/g, '')
|
|
731
|
-
.replace(/:\s*void/g, '')
|
|
732
|
-
.replace(/:\s*Promise<[^>]+>/g, '')
|
|
733
|
-
.replace(/:\s*Record<[^>]+>/g, '');
|
|
734
|
-
// Create the service class
|
|
735
|
-
const serviceClass = `class ${serviceClassName} {\n${cleanClassBody}\n}`;
|
|
736
|
-
dependencies.push(serviceClass);
|
|
737
|
-
}
|
|
738
|
-
}
|
|
37
|
+
export async function deployCommand() {
|
|
38
|
+
return withErrorHandling(async () => {
|
|
39
|
+
// Check if we're in a skill directory
|
|
40
|
+
const config = readSkillConfig();
|
|
41
|
+
if (!config || !config.agent?.agentId || !config.skill?.skillId) {
|
|
42
|
+
console.error("❌ No lua.skill.yaml found or missing agentId/skillId. Please run this command from a skill directory.");
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
// Load API key
|
|
46
|
+
const apiKey = await loadApiKey();
|
|
47
|
+
if (!apiKey) {
|
|
48
|
+
console.error("❌ No API key found. Please run 'lua configure' to set up your API key.");
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
// Validate API key
|
|
52
|
+
const userData = await checkApiKey(apiKey);
|
|
53
|
+
writeProgress("✅ Authenticated");
|
|
54
|
+
// Fetch available versions
|
|
55
|
+
writeProgress("🔄 Fetching available versions...");
|
|
56
|
+
const versionsResponse = await fetchVersions(apiKey, config.agent.agentId, config.skill.skillId);
|
|
57
|
+
if (!versionsResponse.versions || versionsResponse.versions.length === 0) {
|
|
58
|
+
console.log("❌ No versions found for this skill.");
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
// Sort versions by creation date (newest first)
|
|
62
|
+
const sortedVersions = versionsResponse.versions.sort((a, b) => new Date(b.createdDate).getTime() - new Date(a.createdDate).getTime());
|
|
63
|
+
// Let user select a version
|
|
64
|
+
const { selectedVersion } = await inquirer.prompt([
|
|
65
|
+
{
|
|
66
|
+
type: "list",
|
|
67
|
+
name: "selectedVersion",
|
|
68
|
+
message: "Select a version to deploy:",
|
|
69
|
+
choices: sortedVersions.map(version => ({
|
|
70
|
+
name: formatVersionChoice(version),
|
|
71
|
+
value: version.version
|
|
72
|
+
}))
|
|
739
73
|
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
74
|
+
]);
|
|
75
|
+
// Clear the selection prompt lines
|
|
76
|
+
clearPromptLines(2);
|
|
77
|
+
// Show warning and confirm deployment
|
|
78
|
+
const { confirmed } = await inquirer.prompt([
|
|
79
|
+
{
|
|
80
|
+
type: "confirm",
|
|
81
|
+
name: "confirmed",
|
|
82
|
+
message: "⚠️ Warning: This version will be deployed to all users. Do you want to proceed?",
|
|
83
|
+
default: false
|
|
747
84
|
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
// 3. Create the self-contained execute function
|
|
763
|
-
const allDependencies = [...Array.from(bundledPackages), ...dependencies];
|
|
764
|
-
const dependencyCode = allDependencies.join('\n');
|
|
765
|
-
// Clean the execute body (remove TypeScript types)
|
|
766
|
-
const cleanExecuteBody = executeBody
|
|
767
|
-
.replace(/:\s*string/g, '')
|
|
768
|
-
.replace(/:\s*number/g, '')
|
|
769
|
-
.replace(/:\s*boolean/g, '')
|
|
770
|
-
.replace(/:\s*any/g, '')
|
|
771
|
-
.replace(/:\s*void/g, '')
|
|
772
|
-
.replace(/:\s*Promise<[^>]+>/g, '')
|
|
773
|
-
.replace(/:\s*Record<[^>]+>/g, '');
|
|
774
|
-
// Replace this.serviceProperty with the instantiated service
|
|
775
|
-
const finalExecuteBody = cleanExecuteBody.replace(/this\.(\w+)/g, '$1');
|
|
776
|
-
return `async (input) => {
|
|
777
|
-
${dependencyCode ? dependencyCode + '\n' : ''}${finalExecuteBody}
|
|
778
|
-
}`;
|
|
85
|
+
]);
|
|
86
|
+
// Clear the confirmation prompt lines
|
|
87
|
+
clearPromptLines(2);
|
|
88
|
+
if (!confirmed) {
|
|
89
|
+
console.log("❌ Deployment cancelled.");
|
|
90
|
+
process.exit(0);
|
|
91
|
+
}
|
|
92
|
+
// Publish the selected version
|
|
93
|
+
writeProgress("🔄 Publishing version...");
|
|
94
|
+
const publishResponse = await publishVersion(apiKey, config.agent.agentId, config.skill.skillId, selectedVersion);
|
|
95
|
+
writeSuccess(`✅ Version ${publishResponse.activeVersionId} deployed successfully`);
|
|
96
|
+
}, "deployment");
|
|
779
97
|
}
|