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.
Files changed (42) hide show
  1. package/CHANGELOG.md +8 -3
  2. package/README.md +168 -14
  3. package/dist/commands/agents.js +5 -9
  4. package/dist/commands/compile.js +252 -70
  5. package/dist/commands/deploy-new.d.ts +0 -20
  6. package/dist/commands/deploy-new.js +130 -128
  7. package/dist/commands/deploy.js +15 -43
  8. package/dist/commands/dev.d.ts +63 -0
  9. package/dist/commands/dev.js +656 -0
  10. package/dist/commands/index.d.ts +1 -0
  11. package/dist/commands/index.js +1 -0
  12. package/dist/commands/init.js +230 -42
  13. package/dist/commands/push.js +25 -36
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +7 -1
  16. package/dist/services/api.d.ts +195 -0
  17. package/dist/services/api.js +209 -0
  18. package/dist/services/auth.d.ts +82 -0
  19. package/dist/services/auth.js +101 -51
  20. package/dist/user-data-api.d.ts +52 -0
  21. package/dist/user-data-api.js +151 -0
  22. package/dist/utils/files.d.ts +4 -1
  23. package/dist/utils/files.js +62 -16
  24. package/dist/web/app.css +1050 -0
  25. package/dist/web/app.js +79 -0
  26. package/dist/web/tools-page.css +377 -0
  27. package/package.json +17 -4
  28. package/template/package-lock.json +32 -3
  29. package/template/package.json +3 -1
  30. package/template/{index.ts → src/index.ts} +9 -3
  31. package/template/src/tools/UserPreferencesTool.ts +73 -0
  32. package/template/tools/UserPreferencesTool.ts +73 -0
  33. package/template/tsconfig.json +1 -1
  34. package/template/.lua/deploy.json +0 -148
  35. /package/template/{services → src/services}/ApiService.ts +0 -0
  36. /package/template/{services → src/services}/GetWeather.ts +0 -0
  37. /package/template/{services → src/services}/MathService.ts +0 -0
  38. /package/template/{tools → src/tools}/AdvancedMathTool.ts +0 -0
  39. /package/template/{tools → src/tools}/CalculatorTool.ts +0 -0
  40. /package/template/{tools → src/tools}/CreatePostTool.ts +0 -0
  41. /package/template/{tools → src/tools}/GetUserDataTool.ts +0 -0
  42. /package/template/{tools → src/tools}/GetWeatherTool.ts +0 -0
@@ -1,128 +1,130 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import inquirer from 'inquirer';
4
- import { loadApiKey, checkApiKey } from '../services/auth.js';
5
- export async function fetchVersions(apiKey, agentId, skillId) {
6
- try {
7
- const response = await fetch(`https://api.lua.dev/developer/skills/${agentId}/${skillId}/versions`, {
8
- method: "GET",
9
- headers: {
10
- "accept": "application/json",
11
- "Authorization": `Bearer ${apiKey}`
12
- }
13
- });
14
- if (!response.ok) {
15
- throw new Error(`Failed to fetch versions: ${response.status} ${response.statusText}`);
16
- }
17
- return await response.json();
18
- }
19
- catch (error) {
20
- console.error("❌ Error fetching versions:", error);
21
- throw error;
22
- }
23
- }
24
- export async function publishVersion(apiKey, agentId, skillId, version) {
25
- try {
26
- const response = await fetch(`https://api.lua.dev/developer/skills/${agentId}/${skillId}/${version}/publish`, {
27
- method: "PUT",
28
- headers: {
29
- "accept": "application/json",
30
- "Authorization": `Bearer ${apiKey}`
31
- }
32
- });
33
- if (!response.ok) {
34
- throw new Error(`Failed to publish version: ${response.status} ${response.statusText}`);
35
- }
36
- return await response.json();
37
- }
38
- catch (error) {
39
- console.error("❌ Error publishing version:", error);
40
- throw error;
41
- }
42
- }
43
- function readTomlData() {
44
- const tomlPath = path.join(process.cwd(), 'lua.skill.toml');
45
- if (!fs.existsSync(tomlPath)) {
46
- return null;
47
- }
48
- const tomlContent = fs.readFileSync(tomlPath, 'utf8');
49
- const agentIdMatch = tomlContent.match(/agentId\s*=\s*["']([^"']+)["']/);
50
- const skillIdMatch = tomlContent.match(/skillId\s*=\s*["']([^"']+)["']/);
51
- if (!agentIdMatch || !skillIdMatch) {
52
- return null;
53
- }
54
- return {
55
- agentId: agentIdMatch[1],
56
- skillId: skillIdMatch[1]
57
- };
58
- }
59
- function formatVersionChoice(version) {
60
- const currentIndicator = version.isCurrent ? ' (CURRENT)' : '';
61
- const date = new Date(version.createdDate).toLocaleDateString();
62
- return `${version.version}${currentIndicator} - Created: ${date} by ${version.createdByEmail}`;
63
- }
64
- export async function deployCommand() {
65
- try {
66
- // Check if we're in a skill directory
67
- const tomlData = readTomlData();
68
- if (!tomlData) {
69
- console.error("❌ No lua.skill.toml found or missing agentId/skillId. Please run this command from a skill directory.");
70
- process.exit(1);
71
- }
72
- // Load API key
73
- const apiKey = await loadApiKey();
74
- if (!apiKey) {
75
- console.error("❌ No API key found. Please run 'lua configure' to set up your API key.");
76
- process.exit(1);
77
- }
78
- // Validate API key
79
- const userData = await checkApiKey(apiKey);
80
- console.log(`✅ Authenticated as ${userData.email}`);
81
- // Fetch available versions
82
- console.log("🔄 Fetching available versions...");
83
- const versionsResponse = await fetchVersions(apiKey, tomlData.agentId, tomlData.skillId);
84
- if (!versionsResponse.versions || versionsResponse.versions.length === 0) {
85
- console.log("❌ No versions found for this skill.");
86
- process.exit(1);
87
- }
88
- // Sort versions by creation date (newest first)
89
- const sortedVersions = versionsResponse.versions.sort((a, b) => new Date(b.createdDate).getTime() - new Date(a.createdDate).getTime());
90
- // Let user select a version
91
- const { selectedVersion } = await inquirer.prompt([
92
- {
93
- type: "list",
94
- name: "selectedVersion",
95
- message: "Select a version to deploy:",
96
- choices: sortedVersions.map(version => ({
97
- name: formatVersionChoice(version),
98
- value: version.version
99
- }))
100
- }
101
- ]);
102
- // Show warning and confirm deployment
103
- const { confirmed } = await inquirer.prompt([
104
- {
105
- type: "confirm",
106
- name: "confirmed",
107
- message: "⚠️ Warning: This version will be deployed to all users. Do you want to proceed?",
108
- default: false
109
- }
110
- ]);
111
- if (!confirmed) {
112
- console.log("❌ Deployment cancelled.");
113
- process.exit(0);
114
- }
115
- // Publish the selected version
116
- console.log(`🔄 Publishing version ${selectedVersion}...`);
117
- const publishResponse = await publishVersion(apiKey, tomlData.agentId, tomlData.skillId, selectedVersion);
118
- console.log("✅ Deployment successful!");
119
- console.log(`📦 Version: ${publishResponse.activeVersionId}`);
120
- console.log(`🆔 Skill ID: ${publishResponse.skillId}`);
121
- console.log(`📅 Published at: ${new Date(publishResponse.publishedAt).toLocaleString()}`);
122
- console.log(`💬 ${publishResponse.message}`);
123
- }
124
- catch (error) {
125
- console.error("❌ Error during deployment:", error.message);
126
- process.exit(1);
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
+ // }
@@ -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 fetch(`https://api.lua.dev/developer/skills/${agentId}/${skillId}/versions`, {
9
- method: "GET",
10
- headers: {
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 await response.json();
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 fetch(`https://api.lua.dev/developer/skills/${agentId}/${skillId}/${version}/publish`, {
28
- method: "PUT",
29
- headers: {
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 await response.json();
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 tomlData = readTomlData();
69
- if (!tomlData) {
70
- console.error("❌ No lua.skill.toml found or missing agentId/skillId. Please run this command from 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.");
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, tomlData.agentId, tomlData.skillId);
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, tomlData.agentId, tomlData.skillId, selectedVersion);
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>;