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.
Files changed (55) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +244 -63
  3. package/dist/commands/agents.js +17 -17
  4. package/dist/commands/apiKey.js +24 -19
  5. package/dist/commands/compile.d.ts +1 -0
  6. package/dist/commands/compile.js +1004 -0
  7. package/dist/commands/configure.js +93 -68
  8. package/dist/commands/deploy-new.d.ts +0 -0
  9. package/dist/commands/deploy-new.js +130 -0
  10. package/dist/commands/deploy.d.ts +19 -0
  11. package/dist/commands/deploy.js +81 -763
  12. package/dist/commands/destroy.js +26 -21
  13. package/dist/commands/dev.d.ts +63 -0
  14. package/dist/commands/dev.js +656 -0
  15. package/dist/commands/index.d.ts +4 -2
  16. package/dist/commands/index.js +4 -2
  17. package/dist/commands/init.js +297 -62
  18. package/dist/commands/push.d.ts +22 -0
  19. package/dist/commands/push.js +127 -0
  20. package/dist/commands/test.js +14 -15
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +35 -19
  23. package/dist/services/api.d.ts +195 -0
  24. package/dist/services/api.js +209 -0
  25. package/dist/services/auth.d.ts +102 -0
  26. package/dist/services/auth.js +129 -40
  27. package/dist/skill.d.ts +22 -1
  28. package/dist/skill.js +21 -1
  29. package/dist/types/index.d.ts +16 -2
  30. package/dist/types/index.js +16 -1
  31. package/dist/user-data-api.d.ts +52 -0
  32. package/dist/user-data-api.js +151 -0
  33. package/dist/utils/cli.d.ts +34 -0
  34. package/dist/utils/cli.js +58 -0
  35. package/dist/utils/files.d.ts +4 -1
  36. package/dist/utils/files.js +61 -14
  37. package/dist/web/app.css +1050 -0
  38. package/dist/web/app.js +79 -0
  39. package/dist/web/tools-page.css +377 -0
  40. package/package.json +18 -5
  41. package/template/package-lock.json +32 -3
  42. package/template/package.json +3 -1
  43. package/template/{index.ts → src/index.ts} +13 -4
  44. package/template/src/tools/UserPreferencesTool.ts +73 -0
  45. package/template/tools/UserPreferencesTool.ts +73 -0
  46. package/template/tsconfig.json +1 -1
  47. package/template/.lua/deploy.json +0 -145
  48. /package/template/{services → src/services}/ApiService.ts +0 -0
  49. /package/template/{services → src/services}/GetWeather.ts +0 -0
  50. /package/template/{services → src/services}/MathService.ts +0 -0
  51. /package/template/{tools → src/tools}/AdvancedMathTool.ts +0 -0
  52. /package/template/{tools → src/tools}/CalculatorTool.ts +0 -0
  53. /package/template/{tools → src/tools}/CreatePostTool.ts +0 -0
  54. /package/template/{tools → src/tools}/GetUserDataTool.ts +0 -0
  55. /package/template/{tools → src/tools}/GetWeatherTool.ts +0 -0
@@ -0,0 +1,195 @@
1
+ /**
2
+ * Centralized API service for all Lua CLI API calls
3
+ * This service handles all HTTP requests to various Lua endpoints
4
+ */
5
+ export interface ApiResponse<T = any> {
6
+ success: boolean;
7
+ data?: T;
8
+ error?: {
9
+ message: string;
10
+ statusCode?: number;
11
+ };
12
+ }
13
+ export interface UserData {
14
+ uid: string;
15
+ email: string;
16
+ emailVerified: boolean;
17
+ fullName: string;
18
+ mobileNumbers: any[];
19
+ emailAddresses: any[];
20
+ country: any;
21
+ admin: any;
22
+ channels: Record<string, any>;
23
+ rights: Record<string, any>;
24
+ setupPersona: Record<string, any>;
25
+ notifications: Record<string, any>;
26
+ }
27
+ export interface Organization {
28
+ id: string;
29
+ name: string;
30
+ agents: string[];
31
+ }
32
+ export interface Agent {
33
+ id: string;
34
+ name: string;
35
+ persona?: string;
36
+ welcomeMessage?: string;
37
+ featuresOverride?: Record<string, any>;
38
+ }
39
+ export interface SkillVersion {
40
+ version: string;
41
+ createdAt: string;
42
+ status: string;
43
+ }
44
+ export interface DevVersionResponse {
45
+ success: boolean;
46
+ data?: {
47
+ message: string;
48
+ skillId: string;
49
+ version: string;
50
+ };
51
+ error?: {
52
+ message: string;
53
+ statusCode: number;
54
+ };
55
+ }
56
+ export interface UpdateDevVersionResponse {
57
+ success: boolean;
58
+ data?: {
59
+ message: string;
60
+ version: string;
61
+ };
62
+ error?: {
63
+ message: string;
64
+ statusCode: number;
65
+ };
66
+ }
67
+ export interface AgentType {
68
+ id: string;
69
+ name: string;
70
+ features: Record<string, any>;
71
+ requiredSubAgentMetadata?: string[];
72
+ }
73
+ export interface CreateAgentRequest {
74
+ id: string;
75
+ type: string;
76
+ metadata: Record<string, any>;
77
+ persona: {
78
+ agentName: string;
79
+ businessType: string;
80
+ brandPersonality: string;
81
+ brandTraits: string;
82
+ };
83
+ features: Record<string, boolean>;
84
+ channels: any[];
85
+ org: {
86
+ registeredName: string;
87
+ };
88
+ }
89
+ export interface CreateAgentResponse {
90
+ agentId: string;
91
+ name: string;
92
+ baseAgentId: string;
93
+ persona: string;
94
+ createdAt: string;
95
+ welcomeMessage: string;
96
+ featuresOverride: Record<string, any>;
97
+ org: {
98
+ registeredName: string;
99
+ type: string;
100
+ agents: string[];
101
+ paymentMethods: any[];
102
+ _id: string;
103
+ id: string;
104
+ createdAt: number;
105
+ __v: number;
106
+ };
107
+ }
108
+ export interface ChatMessage {
109
+ type: 'text';
110
+ text: string;
111
+ }
112
+ export interface ChatRequest {
113
+ messages: ChatMessage[];
114
+ navigate: boolean;
115
+ skillOverride: Array<{
116
+ skillId: string;
117
+ sandboxId: string;
118
+ }>;
119
+ }
120
+ export interface ChatResponse {
121
+ success: boolean;
122
+ text?: string;
123
+ error?: string;
124
+ }
125
+ /**
126
+ * Authentication API calls
127
+ */
128
+ export declare class AuthApi {
129
+ static checkApiKey(apiKey: string): Promise<ApiResponse<UserData>>;
130
+ static sendOtp(email: string): Promise<ApiResponse<{
131
+ message: string;
132
+ }>>;
133
+ static verifyOtp(email: string, otp: string): Promise<ApiResponse<{
134
+ signInToken: string;
135
+ }>>;
136
+ static getApiKey(signInToken: string): Promise<ApiResponse<{
137
+ apiKey: string;
138
+ }>>;
139
+ }
140
+ /**
141
+ * Agent API calls
142
+ */
143
+ export declare class AgentApi {
144
+ static getOrganizations(apiKey: string): Promise<ApiResponse<Organization[]>>;
145
+ static getAgentTypes(apiKey: string): Promise<ApiResponse<AgentType[]>>;
146
+ static createAgent(apiKey: string, agentData: CreateAgentRequest): Promise<ApiResponse<CreateAgentResponse>>;
147
+ static getAgent(apiKey: string, agentId: string): Promise<ApiResponse<Agent>>;
148
+ }
149
+ /**
150
+ * Skill API calls
151
+ */
152
+ export declare class SkillApi {
153
+ static createSkill(apiKey: string, agentId: string, skillData: any): Promise<ApiResponse<{
154
+ skillId: string;
155
+ name: string;
156
+ }>>;
157
+ static pushSkill(apiKey: string, agentId: string, skillId: string, versionData: any): Promise<ApiResponse<DevVersionResponse>>;
158
+ static pushDevSkill(apiKey: string, agentId: string, skillId: string, versionData: any): Promise<ApiResponse<DevVersionResponse>>;
159
+ static updateDevSkill(apiKey: string, agentId: string, skillId: string, sandboxVersionId: string, versionData: any): Promise<ApiResponse<UpdateDevVersionResponse>>;
160
+ static getSkillVersions(apiKey: string, agentId: string, skillId: string): Promise<ApiResponse<{
161
+ versions: any[];
162
+ }>>;
163
+ static publishSkillVersion(apiKey: string, agentId: string, skillId: string, version: string): Promise<ApiResponse<{
164
+ message: string;
165
+ skillId: string;
166
+ activeVersionId: string;
167
+ publishedAt: string;
168
+ }>>;
169
+ }
170
+ /**
171
+ * Chat API calls
172
+ */
173
+ export declare class ChatApi {
174
+ static sendMessage(agentId: string, chatData: ChatRequest, apiKey: string): Promise<ApiResponse<ChatResponse>>;
175
+ }
176
+ /**
177
+ * Tool API calls (for compile command)
178
+ */
179
+ export declare class ToolApi {
180
+ static getTool(url: string, apiKey: string): Promise<ApiResponse<any>>;
181
+ static postTool(url: string, data: any, apiKey: string): Promise<ApiResponse<any>>;
182
+ static putTool(url: string, data: any, apiKey: string): Promise<ApiResponse<any>>;
183
+ static deleteTool(url: string, apiKey: string): Promise<ApiResponse<any>>;
184
+ static patchTool(url: string, data: any, apiKey: string): Promise<ApiResponse<any>>;
185
+ }
186
+ /**
187
+ * Main API service that exports all API classes
188
+ */
189
+ export declare const ApiService: {
190
+ Auth: typeof AuthApi;
191
+ Agent: typeof AgentApi;
192
+ Skill: typeof SkillApi;
193
+ Chat: typeof ChatApi;
194
+ Tool: typeof ToolApi;
195
+ };
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Centralized API service for all Lua CLI API calls
3
+ * This service handles all HTTP requests to various Lua endpoints
4
+ */
5
+ // Base URLs for different environments
6
+ const BASE_URLS = {
7
+ LOCAL: 'http://localhost:3022',
8
+ API: 'https://api.lua.dev',
9
+ AUTH: 'https://auth.lua.dev',
10
+ CHAT: 'http://localhost:3001'
11
+ };
12
+ /**
13
+ * Generic HTTP client with common error handling
14
+ */
15
+ class HttpClient {
16
+ async request(url, options = {}) {
17
+ try {
18
+ const response = await fetch(url, {
19
+ ...options,
20
+ headers: {
21
+ 'Content-Type': 'application/json',
22
+ ...options.headers,
23
+ },
24
+ });
25
+ const data = await response.json();
26
+ if (!response.ok) {
27
+ return {
28
+ success: false,
29
+ error: {
30
+ message: data.message || data.error || `HTTP ${response.status}`,
31
+ statusCode: response.status,
32
+ },
33
+ };
34
+ }
35
+ return {
36
+ success: true,
37
+ data,
38
+ };
39
+ }
40
+ catch (error) {
41
+ return {
42
+ success: false,
43
+ error: {
44
+ message: error instanceof Error ? error.message : 'Network error',
45
+ statusCode: 500,
46
+ },
47
+ };
48
+ }
49
+ }
50
+ async get(url, headers) {
51
+ return this.request(url, { method: 'GET', headers });
52
+ }
53
+ async post(url, data, headers) {
54
+ return this.request(url, {
55
+ method: 'POST',
56
+ body: data ? JSON.stringify(data) : undefined,
57
+ headers,
58
+ });
59
+ }
60
+ async put(url, data, headers) {
61
+ return this.request(url, {
62
+ method: 'PUT',
63
+ body: data ? JSON.stringify(data) : undefined,
64
+ headers,
65
+ });
66
+ }
67
+ async delete(url, headers) {
68
+ return this.request(url, { method: 'DELETE', headers });
69
+ }
70
+ async patch(url, data, headers) {
71
+ return this.request(url, {
72
+ method: 'PATCH',
73
+ body: data ? JSON.stringify(data) : undefined,
74
+ headers,
75
+ });
76
+ }
77
+ }
78
+ const httpClient = new HttpClient();
79
+ /**
80
+ * Authentication API calls
81
+ */
82
+ export class AuthApi {
83
+ static async checkApiKey(apiKey) {
84
+ return httpClient.get(`${BASE_URLS.LOCAL}/admin`, {
85
+ Authorization: `Bearer ${apiKey}`,
86
+ });
87
+ }
88
+ static async sendOtp(email) {
89
+ return httpClient.post(`${BASE_URLS.AUTH}/otp`, { email });
90
+ }
91
+ static async verifyOtp(email, otp) {
92
+ return httpClient.post(`${BASE_URLS.AUTH}/otp/verify`, { email, otp });
93
+ }
94
+ static async getApiKey(signInToken) {
95
+ return httpClient.post(`${BASE_URLS.AUTH}/profile/apiKey`, undefined, {
96
+ Authorization: `Bearer ${signInToken}`,
97
+ });
98
+ }
99
+ }
100
+ /**
101
+ * Agent API calls
102
+ */
103
+ export class AgentApi {
104
+ static async getOrganizations(apiKey) {
105
+ return httpClient.get(`${BASE_URLS.LOCAL}/admin`, {
106
+ Authorization: `Bearer ${apiKey}`,
107
+ });
108
+ }
109
+ static async getAgentTypes(apiKey) {
110
+ return httpClient.get(`${BASE_URLS.API}/agents/self-serve/types`, {
111
+ Authorization: `Bearer ${apiKey}`,
112
+ });
113
+ }
114
+ static async createAgent(apiKey, agentData) {
115
+ return httpClient.post(`${BASE_URLS.API}/agents/self-serve/create`, agentData, {
116
+ Authorization: `Bearer ${apiKey}`,
117
+ });
118
+ }
119
+ static async getAgent(apiKey, agentId) {
120
+ return httpClient.get(`${BASE_URLS.API}/admin/agents/${agentId}`, {
121
+ Authorization: `Bearer ${apiKey}`,
122
+ });
123
+ }
124
+ }
125
+ /**
126
+ * Skill API calls
127
+ */
128
+ export class SkillApi {
129
+ static async createSkill(apiKey, agentId, skillData) {
130
+ return httpClient.post(`${BASE_URLS.LOCAL}/developer/skills/${agentId}`, skillData, {
131
+ Authorization: `Bearer ${apiKey}`,
132
+ });
133
+ }
134
+ static async pushSkill(apiKey, agentId, skillId, versionData) {
135
+ return httpClient.post(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/version`, versionData, {
136
+ Authorization: `Bearer ${apiKey}`,
137
+ });
138
+ }
139
+ static async pushDevSkill(apiKey, agentId, skillId, versionData) {
140
+ return httpClient.post(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/version/sandbox`, versionData, {
141
+ Authorization: `Bearer ${apiKey}`,
142
+ });
143
+ }
144
+ static async updateDevSkill(apiKey, agentId, skillId, sandboxVersionId, versionData) {
145
+ return httpClient.put(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/version/sandbox/${sandboxVersionId}`, versionData, {
146
+ Authorization: `Bearer ${apiKey}`,
147
+ });
148
+ }
149
+ static async getSkillVersions(apiKey, agentId, skillId) {
150
+ return httpClient.get(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/versions`, {
151
+ Authorization: `Bearer ${apiKey}`,
152
+ });
153
+ }
154
+ static async publishSkillVersion(apiKey, agentId, skillId, version) {
155
+ return httpClient.put(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/${version}/publish`, undefined, {
156
+ Authorization: `Bearer ${apiKey}`,
157
+ });
158
+ }
159
+ }
160
+ /**
161
+ * Chat API calls
162
+ */
163
+ export class ChatApi {
164
+ static async sendMessage(agentId, chatData, apiKey) {
165
+ return httpClient.post(`${BASE_URLS.CHAT}/chat/generate/${agentId}?channel=dev`, chatData, {
166
+ Authorization: `Bearer ${apiKey}`,
167
+ });
168
+ }
169
+ }
170
+ /**
171
+ * Tool API calls (for compile command)
172
+ */
173
+ export class ToolApi {
174
+ static async getTool(url, apiKey) {
175
+ return httpClient.get(url, {
176
+ Authorization: `Bearer ${apiKey}`,
177
+ });
178
+ }
179
+ static async postTool(url, data, apiKey) {
180
+ return httpClient.post(url, data, {
181
+ Authorization: `Bearer ${apiKey}`,
182
+ });
183
+ }
184
+ static async putTool(url, data, apiKey) {
185
+ return httpClient.put(url, data, {
186
+ Authorization: `Bearer ${apiKey}`,
187
+ });
188
+ }
189
+ static async deleteTool(url, apiKey) {
190
+ return httpClient.delete(url, {
191
+ Authorization: `Bearer ${apiKey}`,
192
+ });
193
+ }
194
+ static async patchTool(url, data, apiKey) {
195
+ return httpClient.patch(url, data, {
196
+ Authorization: `Bearer ${apiKey}`,
197
+ });
198
+ }
199
+ }
200
+ /**
201
+ * Main API service that exports all API classes
202
+ */
203
+ export const ApiService = {
204
+ Auth: AuthApi,
205
+ Agent: AgentApi,
206
+ Skill: SkillApi,
207
+ Chat: ChatApi,
208
+ Tool: ToolApi,
209
+ };
@@ -6,3 +6,105 @@ export declare function checkApiKey(apiKey: string): Promise<UserData>;
6
6
  export declare function requestEmailOTP(email: string): Promise<boolean>;
7
7
  export declare function verifyOTPAndGetToken(email: string, pin: string): Promise<string | null>;
8
8
  export declare function generateApiKey(signInToken: string): Promise<string | null>;
9
+ export interface CreateSkillResponse {
10
+ success: boolean;
11
+ data?: {
12
+ name: string;
13
+ public: boolean;
14
+ agentId: string;
15
+ active: boolean;
16
+ _id: string;
17
+ id: string;
18
+ createdAt: string;
19
+ updatedAt: string;
20
+ __v: number;
21
+ };
22
+ error?: {
23
+ message: string;
24
+ error: string;
25
+ statusCode: number;
26
+ };
27
+ }
28
+ export declare function createSkill(apiKey: string, agentId: string, skillName: string): Promise<CreateSkillResponse>;
29
+ export interface AgentType {
30
+ id: string;
31
+ name: string;
32
+ features: Record<string, any>;
33
+ requiredSubAgentMetadata?: string[];
34
+ }
35
+ export interface CreateAgentRequest {
36
+ id: string;
37
+ type: string;
38
+ metadata: Record<string, any>;
39
+ persona: {
40
+ agentName: string;
41
+ businessType: string;
42
+ brandPersonality: string;
43
+ brandTraits: string;
44
+ };
45
+ features: Record<string, boolean>;
46
+ channels: any[];
47
+ org: {
48
+ registeredName: string;
49
+ };
50
+ }
51
+ export interface CreateAgentResponse {
52
+ success: boolean;
53
+ data?: {
54
+ agentId: string;
55
+ name: string;
56
+ baseAgentId: string;
57
+ persona: string;
58
+ createdAt: string;
59
+ welcomeMessage: string;
60
+ featuresOverride: Record<string, any>;
61
+ _id: string;
62
+ updatedAt: string;
63
+ __v: number;
64
+ org: {
65
+ registeredName: string;
66
+ type: string;
67
+ agents: string[];
68
+ paymentMethods: any[];
69
+ _id: string;
70
+ id: string;
71
+ createdAt: number;
72
+ __v: number;
73
+ };
74
+ };
75
+ error?: {
76
+ message: string;
77
+ error: string;
78
+ statusCode: number;
79
+ };
80
+ }
81
+ export interface AgentDetailsResponse {
82
+ success: boolean;
83
+ data?: {
84
+ _id: string;
85
+ agentId: string;
86
+ name: string;
87
+ baseAgentId: string;
88
+ persona: string;
89
+ createdAt: string;
90
+ welcomeMessage: string;
91
+ featuresOverride: Record<string, any>;
92
+ updatedAt: string;
93
+ __v: number;
94
+ personaConfig: {
95
+ agentName: string;
96
+ businessType: string;
97
+ brandPersonality: string;
98
+ brandTraits: string;
99
+ };
100
+ skills: any[];
101
+ };
102
+ error?: {
103
+ message: string;
104
+ error: string;
105
+ statusCode: number;
106
+ };
107
+ }
108
+ export declare function getAgentTypes(apiKey: string): Promise<AgentType[]>;
109
+ export declare function createAgent(apiKey: string, agentData: CreateAgentRequest): Promise<CreateAgentResponse>;
110
+ export declare function getAgentDetails(apiKey: string, agentId: string): Promise<AgentDetailsResponse>;