lua-cli 1.3.0-alpha.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 +8 -3
- package/README.md +168 -14
- package/dist/commands/agents.js +5 -9
- package/dist/commands/compile.js +252 -70
- package/dist/commands/deploy-new.d.ts +0 -20
- package/dist/commands/deploy-new.js +130 -128
- package/dist/commands/deploy.js +15 -43
- package/dist/commands/dev.d.ts +63 -0
- package/dist/commands/dev.js +656 -0
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.js +1 -0
- package/dist/commands/init.js +230 -42
- package/dist/commands/push.js +25 -36
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -1
- package/dist/services/api.d.ts +195 -0
- package/dist/services/api.js +209 -0
- package/dist/services/auth.d.ts +82 -0
- package/dist/services/auth.js +101 -51
- package/dist/user-data-api.d.ts +52 -0
- package/dist/user-data-api.js +151 -0
- package/dist/utils/files.d.ts +4 -1
- package/dist/utils/files.js +62 -16
- 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 +17 -4
- package/template/package-lock.json +32 -3
- package/template/package.json +3 -1
- package/template/{index.ts → src/index.ts} +9 -3
- 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 -148
- /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
|
@@ -1,128 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
export async function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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/dist/commands/deploy.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
1
|
import inquirer from 'inquirer';
|
|
4
2
|
import { loadApiKey, checkApiKey } from '../services/auth.js';
|
|
3
|
+
import { ApiService } from '../services/api.js';
|
|
4
|
+
import { readSkillConfig } from '../utils/files.js';
|
|
5
5
|
import { withErrorHandling, clearPromptLines, writeProgress, writeSuccess } from '../utils/cli.js';
|
|
6
6
|
export async function fetchVersions(apiKey, agentId, skillId) {
|
|
7
7
|
try {
|
|
8
|
-
const response = await
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"accept": "application/json",
|
|
12
|
-
"Authorization": `Bearer ${apiKey}`
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
if (!response.ok) {
|
|
16
|
-
throw new Error(`Failed to fetch versions: ${response.status} ${response.statusText}`);
|
|
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'}`);
|
|
17
11
|
}
|
|
18
|
-
return
|
|
12
|
+
return response.data;
|
|
19
13
|
}
|
|
20
14
|
catch (error) {
|
|
21
15
|
console.error("❌ Error fetching versions:", error);
|
|
@@ -24,39 +18,17 @@ export async function fetchVersions(apiKey, agentId, skillId) {
|
|
|
24
18
|
}
|
|
25
19
|
export async function publishVersion(apiKey, agentId, skillId, version) {
|
|
26
20
|
try {
|
|
27
|
-
const response = await
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"accept": "application/json",
|
|
31
|
-
"Authorization": `Bearer ${apiKey}`
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
if (!response.ok) {
|
|
35
|
-
throw new Error(`Failed to publish version: ${response.status} ${response.statusText}`);
|
|
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'}`);
|
|
36
24
|
}
|
|
37
|
-
return
|
|
25
|
+
return response.data;
|
|
38
26
|
}
|
|
39
27
|
catch (error) {
|
|
40
28
|
console.error("❌ Error publishing version:", error);
|
|
41
29
|
throw error;
|
|
42
30
|
}
|
|
43
31
|
}
|
|
44
|
-
function readTomlData() {
|
|
45
|
-
const tomlPath = path.join(process.cwd(), 'lua.skill.toml');
|
|
46
|
-
if (!fs.existsSync(tomlPath)) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
const tomlContent = fs.readFileSync(tomlPath, 'utf8');
|
|
50
|
-
const agentIdMatch = tomlContent.match(/agentId\s*=\s*["']([^"']+)["']/);
|
|
51
|
-
const skillIdMatch = tomlContent.match(/skillId\s*=\s*["']([^"']+)["']/);
|
|
52
|
-
if (!agentIdMatch || !skillIdMatch) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
agentId: agentIdMatch[1],
|
|
57
|
-
skillId: skillIdMatch[1]
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
32
|
function formatVersionChoice(version) {
|
|
61
33
|
const currentIndicator = version.isCurrent ? ' (CURRENT)' : '';
|
|
62
34
|
const date = new Date(version.createdDate).toLocaleDateString();
|
|
@@ -65,9 +37,9 @@ function formatVersionChoice(version) {
|
|
|
65
37
|
export async function deployCommand() {
|
|
66
38
|
return withErrorHandling(async () => {
|
|
67
39
|
// Check if we're in a skill directory
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
70
|
-
console.error("❌ No lua.skill.
|
|
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.");
|
|
71
43
|
process.exit(1);
|
|
72
44
|
}
|
|
73
45
|
// Load API key
|
|
@@ -81,7 +53,7 @@ export async function deployCommand() {
|
|
|
81
53
|
writeProgress("✅ Authenticated");
|
|
82
54
|
// Fetch available versions
|
|
83
55
|
writeProgress("🔄 Fetching available versions...");
|
|
84
|
-
const versionsResponse = await fetchVersions(apiKey,
|
|
56
|
+
const versionsResponse = await fetchVersions(apiKey, config.agent.agentId, config.skill.skillId);
|
|
85
57
|
if (!versionsResponse.versions || versionsResponse.versions.length === 0) {
|
|
86
58
|
console.log("❌ No versions found for this skill.");
|
|
87
59
|
process.exit(1);
|
|
@@ -119,7 +91,7 @@ export async function deployCommand() {
|
|
|
119
91
|
}
|
|
120
92
|
// Publish the selected version
|
|
121
93
|
writeProgress("🔄 Publishing version...");
|
|
122
|
-
const publishResponse = await publishVersion(apiKey,
|
|
94
|
+
const publishResponse = await publishVersion(apiKey, config.agent.agentId, config.skill.skillId, selectedVersion);
|
|
123
95
|
writeSuccess(`✅ Version ${publishResponse.activeVersionId} deployed successfully`);
|
|
124
96
|
}, "deployment");
|
|
125
97
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export interface DevVersionResponse {
|
|
2
|
+
success: boolean;
|
|
3
|
+
data?: {
|
|
4
|
+
message: string;
|
|
5
|
+
skillId: string;
|
|
6
|
+
version: string;
|
|
7
|
+
publishedAt: string;
|
|
8
|
+
};
|
|
9
|
+
error?: {
|
|
10
|
+
message: string;
|
|
11
|
+
error: string;
|
|
12
|
+
statusCode: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface UpdateDevVersionResponse {
|
|
16
|
+
success: boolean;
|
|
17
|
+
data?: {
|
|
18
|
+
message: string;
|
|
19
|
+
skillId: string;
|
|
20
|
+
version: string;
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
};
|
|
23
|
+
error?: {
|
|
24
|
+
message: string;
|
|
25
|
+
error: string;
|
|
26
|
+
statusCode: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface ChatMessage {
|
|
30
|
+
type: "text";
|
|
31
|
+
text: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ChatRequest {
|
|
34
|
+
messages: ChatMessage[];
|
|
35
|
+
navigate: boolean;
|
|
36
|
+
skillOverride: Array<{
|
|
37
|
+
skillId: string;
|
|
38
|
+
sandboxId: string;
|
|
39
|
+
}>;
|
|
40
|
+
personaOverride?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ChatResponse {
|
|
43
|
+
text: string;
|
|
44
|
+
files: any[];
|
|
45
|
+
reasoningDetails: any[];
|
|
46
|
+
toolCalls: any[];
|
|
47
|
+
toolResults: any[];
|
|
48
|
+
finishReason: string;
|
|
49
|
+
usage: {
|
|
50
|
+
promptTokens: number;
|
|
51
|
+
completionTokens: number;
|
|
52
|
+
totalTokens: number;
|
|
53
|
+
};
|
|
54
|
+
warnings: any[];
|
|
55
|
+
request: any;
|
|
56
|
+
response: any;
|
|
57
|
+
steps: any[];
|
|
58
|
+
sources: any[];
|
|
59
|
+
}
|
|
60
|
+
export declare function sendChatMessage(apiKey: string, agentId: string, skillId: string, sandboxId: string, message: string, persona?: string): Promise<string | null>;
|
|
61
|
+
export declare function updateDevVersion(apiKey: string, agentId: string, skillId: string, sandboxVersionId: string, versionData: any): Promise<UpdateDevVersionResponse>;
|
|
62
|
+
export declare function pushDevVersion(apiKey: string, agentId: string, skillId: string, versionData: any): Promise<DevVersionResponse>;
|
|
63
|
+
export declare function devCommand(): Promise<void>;
|