lua-cli 1.3.2-alpha.3 → 2.0.1
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 +25 -0
- package/README.md +2 -2
- package/dist/commands/agents.js +1 -1
- package/dist/commands/apiKey.js +2 -4
- package/dist/commands/compile.js +280 -216
- package/dist/commands/deploy.js +1 -1
- package/dist/commands/dev.js +352 -81
- package/dist/commands/init.js +43 -79
- package/dist/commands/push.js +1 -1
- package/dist/commands/test.js +49 -11
- package/dist/index.js +7 -9
- package/dist/services/api.d.ts +4 -1
- package/dist/services/api.js +7 -6
- package/dist/services/auth.d.ts +0 -4
- package/dist/services/auth.js +2 -129
- package/dist/skill.d.ts +5 -0
- package/dist/skill.js +6 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/utils/files.d.ts +1 -1
- package/dist/utils/files.js +12 -25
- package/dist/utils/sandbox.d.ts +7 -0
- package/dist/utils/sandbox.js +44 -8
- package/dist/web/app.css +4709 -796
- package/dist/web/app.js +22 -20
- package/dist/web/tools-page.css +0 -13
- package/package.json +5 -2
- package/template/env.example +17 -0
- package/template/lua.skill.yaml +14 -16
- package/template/package.json +1 -1
- package/template/src/index.ts +42 -13
- package/template/src/tools/PaymentTool.ts +2 -3
- package/dist/commands/deploy-new.d.ts +0 -0
- package/dist/commands/deploy-new.js +0 -130
- package/template/create-test.cjs +0 -39
- package/template/package-lock.json +0 -1555
package/dist/web/tools-page.css
CHANGED
|
@@ -16,19 +16,6 @@
|
|
|
16
16
|
gap: 16px;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
.loading-spinner {
|
|
20
|
-
width: 32px;
|
|
21
|
-
height: 32px;
|
|
22
|
-
border: 3px solid #3e3e42;
|
|
23
|
-
border-top: 3px solid #007acc;
|
|
24
|
-
border-radius: 50%;
|
|
25
|
-
animation: spin 1s linear infinite;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@keyframes spin {
|
|
29
|
-
0% { transform: rotate(0deg); }
|
|
30
|
-
100% { transform: rotate(360deg); }
|
|
31
|
-
}
|
|
32
19
|
|
|
33
20
|
/* Tools List View */
|
|
34
21
|
.tools-list-view {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lua-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Command-line interface for Lua AI platform - develop, test, and deploy LuaSkills with custom tools",
|
|
5
5
|
"readmeFilename": "README.md",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -60,15 +60,18 @@
|
|
|
60
60
|
"commander": "^14.0.1",
|
|
61
61
|
"esbuild": "^0.25.10",
|
|
62
62
|
"inquirer": "^12.9.6",
|
|
63
|
+
"js-yaml": "^4.1.0",
|
|
63
64
|
"keytar": "^7.9.0",
|
|
64
65
|
"node-fetch": "^3.3.2",
|
|
65
66
|
"open": "^10.1.0",
|
|
66
67
|
"react": "^18.2.0",
|
|
67
68
|
"react-dom": "^18.2.0",
|
|
69
|
+
"react-markdown": "^9.0.1",
|
|
68
70
|
"socket.io-client": "^4.7.2",
|
|
69
71
|
"ts-morph": "^27.0.0",
|
|
70
72
|
"ws": "^8.18.3",
|
|
71
|
-
"zod": "^
|
|
73
|
+
"zod": "^3.24.1",
|
|
74
|
+
"zod-to-json-schema": "^3.24.6"
|
|
72
75
|
},
|
|
73
76
|
"devDependencies": {
|
|
74
77
|
"@types/inquirer": "^9.0.9",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Example environment variables file
|
|
2
|
+
# Copy this to .env and update with your actual API keys
|
|
3
|
+
|
|
4
|
+
# OpenAI API Key (for AI tools)
|
|
5
|
+
OPENAI_API_KEY=your-openai-api-key-here
|
|
6
|
+
|
|
7
|
+
# Pinecone API Key (for vector search tools)
|
|
8
|
+
PINECONE_API_KEY=your-pinecone-api-key-here
|
|
9
|
+
|
|
10
|
+
# Stripe API Key (for payment tools)
|
|
11
|
+
STRIPE_SECRET_KEY=your-stripe-secret-key-here
|
|
12
|
+
|
|
13
|
+
# Custom application settings
|
|
14
|
+
BASE_URL=http://localhost:3000
|
|
15
|
+
API_KEY=your-api-key-here
|
|
16
|
+
|
|
17
|
+
# Note: Values in lua.skill.yaml will override values in this .env file
|
package/template/lua.skill.yaml
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
agent:
|
|
2
|
-
agentId:
|
|
3
|
-
orgId:
|
|
4
|
-
persona:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
BASE_URL: "http://localhost:3000"
|
|
17
|
-
API_KEY: "1234567890"
|
|
2
|
+
agentId: baseAgent_agent_1758705162448_cyu7ybbhx
|
|
3
|
+
orgId: ae25d3f8-5446-4135-806f-daf4ec55d010
|
|
4
|
+
persona: Your name is Stefan always remember that
|
|
5
|
+
welcomeMessage: 'Hi, I am your AI assistant. How can I help you today?'
|
|
6
|
+
skills:
|
|
7
|
+
- name: general-skill
|
|
8
|
+
version: 0.0.2
|
|
9
|
+
skillId: 24294a5a-bd95-4167-89b1-aebad352196a
|
|
10
|
+
- name: user-data-skill
|
|
11
|
+
version: 0.0.1
|
|
12
|
+
skillId: 5c167305-9f59-4e20-84e9-fd1b50856ec4
|
|
13
|
+
- name: eccomerce-skill
|
|
14
|
+
version: 0.0.1
|
|
15
|
+
skillId: dbec43db-9786-4223-9eac-8087d976d22d
|
package/template/package.json
CHANGED
package/template/src/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LuaSkill } from "lua-cli/skill";
|
|
2
|
-
|
|
3
2
|
import GetWeatherTool from "./tools/GetWeatherTool";
|
|
4
3
|
import { GetUserDataTool, CreateUserDataTool, UpdateUserDataTool } from "./tools/UserDataTool";
|
|
5
4
|
import CreatePostTool from "./tools/CreatePostTool";
|
|
@@ -7,19 +6,45 @@ import { SearchProductsTool } from "./tools/SearchProducts";
|
|
|
7
6
|
import CreatePaymentLinkTool from "./tools/PaymentTool";
|
|
8
7
|
|
|
9
8
|
// Initialize skill with tools
|
|
10
|
-
const
|
|
9
|
+
const generalSkill = new LuaSkill({
|
|
10
|
+
name: "general-skill",
|
|
11
|
+
version: "0.0.2",
|
|
11
12
|
description: "A comprehensive Lua skill with weather, user data, post creation, and mathematical tools",
|
|
12
13
|
context: "This skill provides various utilities including weather information, user data retrieval, post creation, basic calculator operations, and advanced mathematical functions. Use get_weather to fetch current weather conditions for any city, get_user_data to retrieve user information, create_post to publish new posts, calculator for basic arithmetic operations, and advanced_math for complex mathematical computations like factorials, prime checking, fibonacci sequences, and greatest common divisor calculations."
|
|
13
14
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
new
|
|
18
|
-
new
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
generalSkill.addTools([
|
|
18
|
+
new GetWeatherTool(),
|
|
19
|
+
new CreatePostTool()
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const userDataSkill = new LuaSkill({
|
|
24
|
+
name: "user-data-skill",
|
|
25
|
+
version: "0.0.1",
|
|
26
|
+
description: "A specific Lua skill with user data",
|
|
27
|
+
context: "This skill provides various utilities including user data retrieval, creation, and updating.",
|
|
28
|
+
tools: [
|
|
29
|
+
new GetUserDataTool(),
|
|
30
|
+
new CreateUserDataTool(),
|
|
31
|
+
new UpdateUserDataTool()
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
const eccomerceSkill = new LuaSkill({
|
|
37
|
+
name: "eccomerce-skill",
|
|
38
|
+
version: "0.0.1",
|
|
39
|
+
description: "A specific Lua skill with eccomerce",
|
|
40
|
+
context: "This skill provides various utilities including eccomerce."
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
eccomerceSkill.addTools([
|
|
44
|
+
new SearchProductsTool(),
|
|
45
|
+
new CreatePaymentLinkTool()
|
|
46
|
+
]);
|
|
47
|
+
|
|
23
48
|
|
|
24
49
|
// Test cases
|
|
25
50
|
const testCases = [
|
|
@@ -42,8 +67,12 @@ async function runTests() {
|
|
|
42
67
|
for (const [index, testCase] of testCases.entries()) {
|
|
43
68
|
try {
|
|
44
69
|
console.log(`Test ${index + 1}: ${testCase.tool}`);
|
|
45
|
-
const
|
|
46
|
-
console.log("✅ Success:",
|
|
70
|
+
const resultGeneral = await generalSkill.run(testCase);
|
|
71
|
+
console.log("✅ Success:", resultGeneral);
|
|
72
|
+
const resultUserData = await userDataSkill.run(testCase);
|
|
73
|
+
console.log("✅ Success:", resultUserData);
|
|
74
|
+
const resultEccomerce = await eccomerceSkill.run(testCase);
|
|
75
|
+
console.log("✅ Success:", resultEccomerce);
|
|
47
76
|
} catch (error: any) {
|
|
48
77
|
console.log("❌ Error:", error.message);
|
|
49
78
|
}
|
|
@@ -6,8 +6,7 @@ export default class CreatePaymentLinkTool implements LuaTool {
|
|
|
6
6
|
description = "Create a Stripe payment link for a one-time payment";
|
|
7
7
|
inputSchema = z.object({
|
|
8
8
|
amount: z.number().int().positive(), // in cents
|
|
9
|
-
currency: z.string().default("usd")
|
|
10
|
-
quantity: z.number().int().positive().default(1),
|
|
9
|
+
currency: z.string().default("usd")
|
|
11
10
|
});
|
|
12
11
|
outputSchema = z.object({
|
|
13
12
|
url: z.string(),
|
|
@@ -32,7 +31,7 @@ export default class CreatePaymentLinkTool implements LuaTool {
|
|
|
32
31
|
"line_items[0][price_data][currency]": input.currency,
|
|
33
32
|
"line_items[0][price_data][product_data][name]": "One-time Payment",
|
|
34
33
|
"line_items[0][price_data][unit_amount]": input.amount.toString(),
|
|
35
|
-
"line_items[0][quantity]":
|
|
34
|
+
"line_items[0][quantity]": "1",
|
|
36
35
|
success_url: "https://example.com/success",
|
|
37
36
|
cancel_url: "https://example.com/cancel",
|
|
38
37
|
}),
|
|
File without changes
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import fs from 'fs';
|
|
3
|
-
// import path from 'path';
|
|
4
|
-
// import inquirer from 'inquirer';
|
|
5
|
-
// import { loadApiKey, checkApiKey } from '../services/auth.js';
|
|
6
|
-
// import { readSkillConfig } from '../utils/files.js';
|
|
7
|
-
// export interface VersionInfo {
|
|
8
|
-
// version: string;
|
|
9
|
-
// createdDate: string;
|
|
10
|
-
// createdBy: string;
|
|
11
|
-
// isCurrent: boolean;
|
|
12
|
-
// createdByEmail: string;
|
|
13
|
-
// createdByFullName: string;
|
|
14
|
-
// }
|
|
15
|
-
// export interface VersionsResponse {
|
|
16
|
-
// versions: VersionInfo[];
|
|
17
|
-
// }
|
|
18
|
-
// export interface PublishResponse {
|
|
19
|
-
// message: string;
|
|
20
|
-
// skillId: string;
|
|
21
|
-
// activeVersionId: string;
|
|
22
|
-
// publishedAt: string;
|
|
23
|
-
// }
|
|
24
|
-
// export async function fetchVersions(apiKey: string, agentId: string, skillId: string): Promise<VersionsResponse> {
|
|
25
|
-
// try {
|
|
26
|
-
// const response = await fetch(`http://localhost:3022/developer/skills/${agentId}/${skillId}/versions`, {
|
|
27
|
-
// method: "GET",
|
|
28
|
-
// headers: {
|
|
29
|
-
// "accept": "application/json",
|
|
30
|
-
// "Authorization": `Bearer ${apiKey}`
|
|
31
|
-
// }
|
|
32
|
-
// });
|
|
33
|
-
// if (!response.ok) {
|
|
34
|
-
// throw new Error(`Failed to fetch versions: ${response.status} ${response.statusText}`);
|
|
35
|
-
// }
|
|
36
|
-
// return await response.json() as VersionsResponse;
|
|
37
|
-
// } catch (error) {
|
|
38
|
-
// console.error("❌ Error fetching versions:", error);
|
|
39
|
-
// throw error;
|
|
40
|
-
// }
|
|
41
|
-
// }
|
|
42
|
-
// export async function publishVersion(apiKey: string, agentId: string, skillId: string, version: string): Promise<PublishResponse> {
|
|
43
|
-
// try {
|
|
44
|
-
// const response = await fetch(`http://localhost:3022/developer/skills/${agentId}/${skillId}/${version}/publish`, {
|
|
45
|
-
// method: "PUT",
|
|
46
|
-
// headers: {
|
|
47
|
-
// "accept": "application/json",
|
|
48
|
-
// "Authorization": `Bearer ${apiKey}`
|
|
49
|
-
// }
|
|
50
|
-
// });
|
|
51
|
-
// if (!response.ok) {
|
|
52
|
-
// throw new Error(`Failed to publish version: ${response.status} ${response.statusText}`);
|
|
53
|
-
// }
|
|
54
|
-
// return await response.json() as PublishResponse;
|
|
55
|
-
// } catch (error) {
|
|
56
|
-
// console.error("❌ Error publishing version:", error);
|
|
57
|
-
// throw error;
|
|
58
|
-
// }
|
|
59
|
-
// }
|
|
60
|
-
// function formatVersionChoice(version: VersionInfo): string {
|
|
61
|
-
// const currentIndicator = version.isCurrent ? ' (CURRENT)' : '';
|
|
62
|
-
// const date = new Date(version.createdDate).toLocaleDateString();
|
|
63
|
-
// return `${version.version}${currentIndicator} - Created: ${date} by ${version.createdByEmail}`;
|
|
64
|
-
// }
|
|
65
|
-
// export async function deployCommand(): Promise<void> {
|
|
66
|
-
// try {
|
|
67
|
-
// // Check if we're in a skill directory
|
|
68
|
-
// const config = readSkillConfig();
|
|
69
|
-
// if (!config || !config.agent?.agentId || !config.skill?.skillId) {
|
|
70
|
-
// console.error("❌ No lua.skill.yaml found or missing agentId/skillId. Please run this command from a skill directory.");
|
|
71
|
-
// process.exit(1);
|
|
72
|
-
// }
|
|
73
|
-
// // Load API key
|
|
74
|
-
// const apiKey = await loadApiKey();
|
|
75
|
-
// if (!apiKey) {
|
|
76
|
-
// console.error("❌ No API key found. Please run 'lua configure' to set up your API key.");
|
|
77
|
-
// process.exit(1);
|
|
78
|
-
// }
|
|
79
|
-
// // Validate API key
|
|
80
|
-
// const userData = await checkApiKey(apiKey);
|
|
81
|
-
// console.log(`✅ Authenticated as ${userData.email}`);
|
|
82
|
-
// // Fetch available versions
|
|
83
|
-
// console.log("🔄 Fetching available versions...");
|
|
84
|
-
// const versionsResponse = await fetchVersions(apiKey, config.agent.agentId, config.skill.skillId);
|
|
85
|
-
// if (!versionsResponse.versions || versionsResponse.versions.length === 0) {
|
|
86
|
-
// console.log("❌ No versions found for this skill.");
|
|
87
|
-
// process.exit(1);
|
|
88
|
-
// }
|
|
89
|
-
// // Sort versions by creation date (newest first)
|
|
90
|
-
// const sortedVersions = versionsResponse.versions.sort((a, b) =>
|
|
91
|
-
// new Date(b.createdDate).getTime() - new Date(a.createdDate).getTime()
|
|
92
|
-
// );
|
|
93
|
-
// // Let user select a version
|
|
94
|
-
// const { selectedVersion } = await inquirer.prompt([
|
|
95
|
-
// {
|
|
96
|
-
// type: "list",
|
|
97
|
-
// name: "selectedVersion",
|
|
98
|
-
// message: "Select a version to deploy:",
|
|
99
|
-
// choices: sortedVersions.map(version => ({
|
|
100
|
-
// name: formatVersionChoice(version),
|
|
101
|
-
// value: version.version
|
|
102
|
-
// }))
|
|
103
|
-
// }
|
|
104
|
-
// ]);
|
|
105
|
-
// // Show warning and confirm deployment
|
|
106
|
-
// const { confirmed } = await inquirer.prompt([
|
|
107
|
-
// {
|
|
108
|
-
// type: "confirm",
|
|
109
|
-
// name: "confirmed",
|
|
110
|
-
// message: "⚠️ Warning: This version will be deployed to all users. Do you want to proceed?",
|
|
111
|
-
// default: false
|
|
112
|
-
// }
|
|
113
|
-
// ]);
|
|
114
|
-
// if (!confirmed) {
|
|
115
|
-
// console.log("❌ Deployment cancelled.");
|
|
116
|
-
// process.exit(0);
|
|
117
|
-
// }
|
|
118
|
-
// // Publish the selected version
|
|
119
|
-
// console.log(`🔄 Publishing version ${selectedVersion}...`);
|
|
120
|
-
// const publishResponse = await publishVersion(apiKey, config.agent.agentId, config.skill.skillId, selectedVersion);
|
|
121
|
-
// console.log("✅ Deployment successful!");
|
|
122
|
-
// console.log(`📦 Version: ${publishResponse.activeVersionId}`);
|
|
123
|
-
// console.log(`🆔 Skill ID: ${publishResponse.skillId}`);
|
|
124
|
-
// console.log(`📅 Published at: ${new Date(publishResponse.publishedAt).toLocaleString()}`);
|
|
125
|
-
// console.log(`💬 ${publishResponse.message}`);
|
|
126
|
-
// } catch (error: any) {
|
|
127
|
-
// console.error("❌ Error during deployment:", error.message);
|
|
128
|
-
// process.exit(1);
|
|
129
|
-
// }
|
|
130
|
-
// }
|
package/template/create-test.cjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
|
|
3
|
-
// Read the compiled search_movies.js file
|
|
4
|
-
const searchMoviesCode = fs.readFileSync('.lua/search_movies.js', 'utf8');
|
|
5
|
-
|
|
6
|
-
// Create a test function with env function
|
|
7
|
-
const testFunction = `
|
|
8
|
-
// Mock env function
|
|
9
|
-
const env = (key) => {
|
|
10
|
-
const envVars = {
|
|
11
|
-
'PINECONE_API_KEY': 'test-pinecone-key',
|
|
12
|
-
'OPENAI_API_KEY': 'test-openai-key'
|
|
13
|
-
};
|
|
14
|
-
return envVars[key];
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
${searchMoviesCode}
|
|
18
|
-
|
|
19
|
-
// Test the function
|
|
20
|
-
(async () => {
|
|
21
|
-
try {
|
|
22
|
-
console.log('Testing SearchMovies tool...');
|
|
23
|
-
const result = await module.exports({ query: 'avatar' });
|
|
24
|
-
console.log('✅ Success:', result);
|
|
25
|
-
} catch (error) {
|
|
26
|
-
console.log('❌ Error:', error.message);
|
|
27
|
-
if (error.message.includes('FormData is not defined')) {
|
|
28
|
-
console.log('❌ FormData error still exists - recursive bundling not working');
|
|
29
|
-
} else {
|
|
30
|
-
console.log('✅ FormData error resolved - recursive bundling working');
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
})();
|
|
34
|
-
`;
|
|
35
|
-
|
|
36
|
-
// Write test file
|
|
37
|
-
fs.writeFileSync('test-searchmovies.cjs', testFunction);
|
|
38
|
-
|
|
39
|
-
console.log('Test file created. Run: node test-searchmovies.cjs');
|