lua-cli 2.5.7 → 2.5.8

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 (37) hide show
  1. package/dist/api/agent.api.service.d.ts +45 -0
  2. package/dist/api/agent.api.service.js +54 -0
  3. package/dist/api/user.data.api.service.d.ts +15 -0
  4. package/dist/api/user.data.api.service.js +31 -0
  5. package/dist/cli/command-definitions.js +77 -5
  6. package/dist/commands/completion.d.ts +11 -0
  7. package/dist/commands/completion.js +209 -0
  8. package/dist/commands/env.d.ts +3 -2
  9. package/dist/commands/env.js +42 -17
  10. package/dist/commands/features.d.ts +16 -0
  11. package/dist/commands/features.js +352 -0
  12. package/dist/commands/index.d.ts +3 -0
  13. package/dist/commands/index.js +3 -0
  14. package/dist/commands/persona.d.ts +3 -2
  15. package/dist/commands/persona.js +43 -18
  16. package/dist/commands/push.d.ts +9 -13
  17. package/dist/commands/push.js +271 -82
  18. package/dist/commands/skills.d.ts +16 -0
  19. package/dist/commands/skills.js +438 -0
  20. package/dist/common/data.entry.instance.d.ts +7 -0
  21. package/dist/common/data.entry.instance.js +15 -0
  22. package/dist/common/order.instance.d.ts +6 -0
  23. package/dist/common/order.instance.js +14 -0
  24. package/dist/common/product.instance.d.ts +6 -0
  25. package/dist/common/product.instance.js +14 -0
  26. package/dist/common/user.instance.d.ts +14 -0
  27. package/dist/common/user.instance.js +29 -0
  28. package/dist/index.js +14 -3
  29. package/dist/interfaces/agent.d.ts +31 -0
  30. package/dist/interfaces/message.d.ts +18 -0
  31. package/dist/interfaces/message.js +1 -0
  32. package/dist/types/api-contracts.d.ts +9 -0
  33. package/dist/types/api-contracts.js +0 -7
  34. package/dist/web/app.css +152 -736
  35. package/dist/web/app.js +45 -45
  36. package/package.json +2 -2
  37. package/template/package.json +1 -1
@@ -10,10 +10,73 @@ import { safePrompt } from '../utils/prompt-handler.js';
10
10
  import { readDeployJson, validatePushConfig, validateDeployData, promptSkillSelection, promptVersionConfirmOrUpdate, getAvailableSkills, updateSkillVersionInYaml, getSkillDeployData, } from '../utils/push-helpers.js';
11
11
  import { pushVersion } from '../utils/push-api.js';
12
12
  import { fetchVersions, publishVersion, } from '../utils/deploy-api.js';
13
+ import { BASE_URLS } from '../config/constants.js';
13
14
  /**
14
- * Main push command - pushes a skill version to the server.
15
+ * Main push command - pushes a skill or persona version to the server.
15
16
  *
16
17
  * This command performs the following steps:
18
+ * 1. If type argument provided, uses it directly
19
+ * 2. Otherwise, prompts user to select 'skill' or 'persona'
20
+ * 3. Routes to appropriate push flow
21
+ *
22
+ * Use this command to:
23
+ * - Upload a new version of your skill or persona
24
+ * - Make your skill/persona available for testing in dev mode
25
+ * - Prepare your skill/persona for deployment
26
+ *
27
+ * Note: This does NOT deploy to production. Use `lua deploy` for that.
28
+ *
29
+ * @param type - Optional type argument ('skill' or 'persona')
30
+ * @returns Promise that resolves when push completes
31
+ */
32
+ export async function pushCommand(type) {
33
+ return withErrorHandling(async () => {
34
+ let selectedType;
35
+ // Step 1: Check if type was provided as argument
36
+ if (type) {
37
+ // Validate the provided type
38
+ if (type !== 'skill' && type !== 'persona') {
39
+ console.error(`āŒ Invalid type: "${type}". Must be "skill" or "persona".`);
40
+ console.log('\nUsage:');
41
+ console.log(' lua push - Interactive selection');
42
+ console.log(' lua push skill - Push a skill directly');
43
+ console.log(' lua push persona - Push a persona directly');
44
+ process.exit(1);
45
+ }
46
+ selectedType = type;
47
+ }
48
+ else {
49
+ // Step 2: Prompt for type selection
50
+ const typeAnswer = await safePrompt([
51
+ {
52
+ type: 'list',
53
+ name: 'type',
54
+ message: 'What would you like to push?',
55
+ choices: [
56
+ { name: 'šŸ› ļø Skill', value: 'skill' },
57
+ { name: 'šŸŒ™ Persona', value: 'persona' }
58
+ ]
59
+ }
60
+ ]);
61
+ if (!typeAnswer) {
62
+ console.log("Push cancelled.");
63
+ return;
64
+ }
65
+ selectedType = typeAnswer.type;
66
+ }
67
+ // Step 3: Route to appropriate function
68
+ if (selectedType === 'skill') {
69
+ await pushSkillVersion();
70
+ }
71
+ else {
72
+ await pushPersonaVersion();
73
+ }
74
+ }, "push");
75
+ }
76
+ /**
77
+ * Push skill version to the server.
78
+ *
79
+ * This function performs the following steps:
17
80
  * 1. Validates configuration has required fields
18
81
  * 2. Prompts user to select a skill (if multiple skills exist)
19
82
  * 3. Prompts to confirm or update version
@@ -23,98 +86,224 @@ import { fetchVersions, publishVersion, } from '../utils/deploy-api.js';
23
86
  * 7. Extracts the specific skill's deploy data
24
87
  * 8. Pushes version to server
25
88
  *
26
- * Use this command to:
27
- * - Upload a new version of your skill
28
- * - Make your skill available for testing in dev mode
29
- * - Prepare your skill for deployment
89
+ * @returns Promise that resolves when push completes
90
+ */
91
+ async function pushSkillVersion() {
92
+ // Step 1: Validate configuration
93
+ const config = readSkillConfig();
94
+ validatePushConfig(config);
95
+ // Step 2: Get available skills and prompt for selection
96
+ const availableSkills = getAvailableSkills(config);
97
+ if (availableSkills.length === 0) {
98
+ console.error("āŒ No skills found in configuration. Please compile your skill first using 'lua compile'.");
99
+ process.exit(1);
100
+ }
101
+ let selectedSkill;
102
+ if (availableSkills.length === 1) {
103
+ // Only one skill, use it automatically
104
+ selectedSkill = availableSkills[0];
105
+ writeInfo(`šŸ“¦ Pushing skill: ${selectedSkill.name}`);
106
+ }
107
+ else {
108
+ // Multiple skills, prompt for selection
109
+ selectedSkill = await promptSkillSelection(availableSkills);
110
+ writeInfo(`šŸ“¦ Selected skill: ${selectedSkill.name}`);
111
+ }
112
+ // Step 3: Confirm or update version
113
+ const confirmedVersion = await promptVersionConfirmOrUpdate(selectedSkill.version);
114
+ let versionUpdated = false;
115
+ if (confirmedVersion !== selectedSkill.version) {
116
+ writeInfo(`šŸ“ Updating version from ${selectedSkill.version} to ${confirmedVersion}`);
117
+ updateSkillVersionInYaml(selectedSkill.name, confirmedVersion);
118
+ selectedSkill.version = confirmedVersion;
119
+ versionUpdated = true;
120
+ }
121
+ // Step 4: Authenticate
122
+ const apiKey = await loadApiKey();
123
+ if (!apiKey) {
124
+ console.error("āŒ No API key found. Please run 'lua auth configure' to set up your API key.");
125
+ process.exit(1);
126
+ }
127
+ const userData = await checkApiKey(apiKey);
128
+ writeProgress("āœ… Authenticated");
129
+ // Step 5: Compile the skill (always compile to ensure up-to-date, or if version was updated)
130
+ writeProgress("šŸ”„ Compiling skill...");
131
+ await compileCommand();
132
+ // Step 6: Validate deploy data for the selected skill
133
+ const deployData = readDeployJson();
134
+ validateDeployData(deployData, selectedSkill);
135
+ // Step 7: Extract the specific skill's deploy data
136
+ const skillDeployData = getSkillDeployData(deployData, selectedSkill.name);
137
+ // Step 8: Push version to server
138
+ const agentId = config.agent.agentId;
139
+ const skillId = selectedSkill.skillId;
140
+ writeProgress("šŸ”„ Pushing version to server...");
141
+ const result = await pushVersion(apiKey, agentId, skillId, skillDeployData);
142
+ if (result.success && result.data) {
143
+ const pushedVersion = result.data.version;
144
+ writeSuccess(`āœ… Version ${pushedVersion} of "${selectedSkill.name}" pushed successfully`);
145
+ // Update YAML with the version returned from server (in case it's different)
146
+ if (pushedVersion !== selectedSkill.version) {
147
+ writeInfo(`šŸ“ Updating YAML with server version: ${pushedVersion}`);
148
+ updateSkillVersionInYaml(selectedSkill.name, pushedVersion);
149
+ selectedSkill.version = pushedVersion;
150
+ }
151
+ // Ask if user wants to deploy now
152
+ const deployAnswer = await safePrompt([
153
+ {
154
+ type: 'confirm',
155
+ name: 'deployNow',
156
+ message: 'Would you like to deploy this version to production now?',
157
+ default: false
158
+ }
159
+ ]);
160
+ if (deployAnswer && deployAnswer.deployNow) {
161
+ await deployVersionAfterPush(apiKey, config.agent.agentId, selectedSkill, pushedVersion);
162
+ }
163
+ }
164
+ else if (result.error) {
165
+ console.error(`āŒ ${result.error.message}`);
166
+ process.exit(1);
167
+ }
168
+ else {
169
+ console.error("āŒ Failed to push version. Please try again.");
170
+ process.exit(1);
171
+ }
172
+ }
173
+ /**
174
+ * Push persona version to the server.
30
175
  *
31
- * Note: This does NOT deploy to production. Use `lua deploy` for that.
176
+ * This function performs the following steps:
177
+ * 1. Validates configuration has required fields
178
+ * 2. Loads current persona from lua.skill.yaml
179
+ * 3. Authenticates the user
180
+ * 4. Pushes persona version to server
181
+ * 5. Optionally deploys to production
32
182
  *
33
183
  * @returns Promise that resolves when push completes
34
184
  */
35
- export async function pushCommand() {
36
- return withErrorHandling(async () => {
37
- // Step 1: Validate configuration
38
- const config = readSkillConfig();
39
- validatePushConfig(config);
40
- // Step 2: Get available skills and prompt for selection
41
- const availableSkills = getAvailableSkills(config);
42
- if (availableSkills.length === 0) {
43
- console.error("āŒ No skills found in configuration. Please compile your skill first using 'lua compile'.");
44
- process.exit(1);
45
- }
46
- let selectedSkill;
47
- if (availableSkills.length === 1) {
48
- // Only one skill, use it automatically
49
- selectedSkill = availableSkills[0];
50
- writeInfo(`šŸ“¦ Pushing skill: ${selectedSkill.name}`);
185
+ async function pushPersonaVersion() {
186
+ // Step 1: Validate configuration
187
+ const config = readSkillConfig();
188
+ if (!config || !config.agent?.agentId) {
189
+ console.error("āŒ No agent configuration found. Please run 'lua init' first.");
190
+ process.exit(1);
191
+ }
192
+ // Step 2: Load current persona
193
+ const currentPersona = config.agent?.persona || '';
194
+ if (!currentPersona || !currentPersona.trim()) {
195
+ console.error("āŒ No persona found in configuration. Please edit your persona first using 'lua persona'.");
196
+ process.exit(1);
197
+ }
198
+ writeInfo(`šŸ“¦ Pushing persona for agent: ${config.agent.agentId}`);
199
+ // Show preview of persona
200
+ const preview = currentPersona.length > 200
201
+ ? currentPersona.substring(0, 200) + '...'
202
+ : currentPersona;
203
+ console.log("\nPersona preview:");
204
+ console.log(preview);
205
+ console.log();
206
+ // Step 3: Confirm push
207
+ const confirmAnswer = await safePrompt([
208
+ {
209
+ type: 'confirm',
210
+ name: 'confirm',
211
+ message: 'Create new persona version?',
212
+ default: true
51
213
  }
52
- else {
53
- // Multiple skills, prompt for selection
54
- selectedSkill = await promptSkillSelection(availableSkills);
55
- writeInfo(`šŸ“¦ Selected skill: ${selectedSkill.name}`);
214
+ ]);
215
+ if (!confirmAnswer || !confirmAnswer.confirm) {
216
+ console.log("\nāŒ Push cancelled.\n");
217
+ return;
218
+ }
219
+ // Step 4: Authenticate
220
+ const apiKey = await loadApiKey();
221
+ if (!apiKey) {
222
+ console.error("āŒ No API key found. Please run 'lua auth configure' to set up your API key.");
223
+ process.exit(1);
224
+ }
225
+ await checkApiKey(apiKey);
226
+ writeProgress("āœ… Authenticated");
227
+ // Step 5: Push persona version to server
228
+ writeProgress("šŸ”„ Creating persona version...");
229
+ try {
230
+ const response = await fetch(`${BASE_URLS.API}/developer/agents/${config.agent.agentId}/persona/version`, {
231
+ method: 'POST',
232
+ headers: {
233
+ 'Authorization': `Bearer ${apiKey}`,
234
+ 'Content-Type': 'application/json'
235
+ },
236
+ body: JSON.stringify({ persona: currentPersona })
237
+ });
238
+ if (!response.ok) {
239
+ const errorText = await response.text();
240
+ throw new Error(`HTTP error! status: ${response.status}, ${errorText}`);
56
241
  }
57
- // Step 3: Confirm or update version
58
- const confirmedVersion = await promptVersionConfirmOrUpdate(selectedSkill.version);
59
- let versionUpdated = false;
60
- if (confirmedVersion !== selectedSkill.version) {
61
- writeInfo(`šŸ“ Updating version from ${selectedSkill.version} to ${confirmedVersion}`);
62
- updateSkillVersionInYaml(selectedSkill.name, confirmedVersion);
63
- selectedSkill.version = confirmedVersion;
64
- versionUpdated = true;
242
+ const data = await response.json();
243
+ const versionNum = data.version || data.data?.version || 'N/A';
244
+ writeSuccess(`āœ… Persona version ${versionNum} created successfully`);
245
+ // Step 6: Ask if user wants to deploy now
246
+ const deployAnswer = await safePrompt([
247
+ {
248
+ type: 'confirm',
249
+ name: 'deployNow',
250
+ message: 'Would you like to deploy this persona version to production now?',
251
+ default: false
252
+ }
253
+ ]);
254
+ if (deployAnswer && deployAnswer.deployNow) {
255
+ await deployPersonaVersionAfterPush(apiKey, config.agent.agentId, versionNum);
65
256
  }
66
- // Step 4: Authenticate
67
- const apiKey = await loadApiKey();
68
- if (!apiKey) {
69
- console.error("āŒ No API key found. Please run 'lua auth configure' to set up your API key.");
70
- process.exit(1);
257
+ else {
258
+ writeInfo("šŸ’” You can deploy this version later using: lua deploy");
71
259
  }
72
- const userData = await checkApiKey(apiKey);
73
- writeProgress("āœ… Authenticated");
74
- // Step 5: Compile the skill (always compile to ensure up-to-date, or if version was updated)
75
- writeProgress("šŸ”„ Compiling skill...");
76
- await compileCommand();
77
- // Step 6: Validate deploy data for the selected skill
78
- const deployData = readDeployJson();
79
- validateDeployData(deployData, selectedSkill);
80
- // Step 7: Extract the specific skill's deploy data
81
- const skillDeployData = getSkillDeployData(deployData, selectedSkill.name);
82
- // Step 8: Push version to server
83
- const agentId = config.agent.agentId;
84
- const skillId = selectedSkill.skillId;
85
- writeProgress("šŸ”„ Pushing version to server...");
86
- const result = await pushVersion(apiKey, agentId, skillId, skillDeployData);
87
- if (result.success && result.data) {
88
- const pushedVersion = result.data.version;
89
- writeSuccess(`āœ… Version ${pushedVersion} of "${selectedSkill.name}" pushed successfully`);
90
- // Update YAML with the version returned from server (in case it's different)
91
- if (pushedVersion !== selectedSkill.version) {
92
- writeInfo(`šŸ“ Updating YAML with server version: ${pushedVersion}`);
93
- updateSkillVersionInYaml(selectedSkill.name, pushedVersion);
94
- selectedSkill.version = pushedVersion;
95
- }
96
- // Ask if user wants to deploy now
97
- const deployAnswer = await safePrompt([
98
- {
99
- type: 'confirm',
100
- name: 'deployNow',
101
- message: 'Would you like to deploy this version to production now?',
102
- default: false
103
- }
104
- ]);
105
- if (deployAnswer && deployAnswer.deployNow) {
106
- await deployVersionAfterPush(apiKey, config.agent.agentId, selectedSkill, pushedVersion);
260
+ }
261
+ catch (error) {
262
+ console.error('āŒ Error creating persona version:', error);
263
+ process.exit(1);
264
+ }
265
+ }
266
+ /**
267
+ * Deploy a persona version immediately after pushing
268
+ */
269
+ async function deployPersonaVersionAfterPush(apiKey, agentId, versionNum) {
270
+ try {
271
+ // Show warning
272
+ console.log("\nāš ļø WARNING: You are about to deploy to PRODUCTION!");
273
+ console.log("āš ļø This will affect ALL users immediately.\n");
274
+ const confirmAnswer = await safePrompt([
275
+ {
276
+ type: 'confirm',
277
+ name: 'confirm',
278
+ message: 'Are you absolutely sure you want to deploy this persona version?',
279
+ default: false
107
280
  }
281
+ ]);
282
+ if (!confirmAnswer || !confirmAnswer.confirm) {
283
+ console.log("\nāŒ Deployment cancelled. Persona version created but not deployed.\n");
284
+ return;
108
285
  }
109
- else if (result.error) {
110
- console.error(`āŒ ${result.error.message}`);
111
- process.exit(1);
112
- }
113
- else {
114
- console.error("āŒ Failed to push version. Please try again.");
115
- process.exit(1);
286
+ writeProgress("šŸ”„ Deploying persona version...");
287
+ const deployResponse = await fetch(`${BASE_URLS.API}/developer/agents/${agentId}/persona/version/${versionNum}`, {
288
+ method: 'POST',
289
+ headers: {
290
+ 'Authorization': `Bearer ${apiKey}`,
291
+ 'Content-Type': 'application/json'
292
+ },
293
+ body: JSON.stringify({})
294
+ });
295
+ if (!deployResponse.ok) {
296
+ const errorText = await deployResponse.text();
297
+ console.error(`\nāŒ Deploy Error: ${deployResponse.status} - ${errorText}\n`);
298
+ throw new Error(`HTTP error! status: ${deployResponse.status}`);
116
299
  }
117
- }, "push");
300
+ writeSuccess(`\nāœ… Persona version ${versionNum} deployed successfully to production\n`);
301
+ writeInfo("šŸ’” The new persona is now active for all users.");
302
+ }
303
+ catch (error) {
304
+ console.error('\nāŒ Error deploying persona version:', error);
305
+ console.log('šŸ’” You can deploy later using: lua persona\n');
306
+ }
118
307
  }
119
308
  /**
120
309
  * Deploy a version immediately after pushing
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Skills Command
3
+ * Manages agent skills for sandbox and production environments
4
+ */
5
+ /**
6
+ * Main skills command - manages agent skills
7
+ *
8
+ * Features:
9
+ * - Environment selection (sandbox/staging or production)
10
+ * - Sandbox: view local skills from configuration
11
+ * - Production: view deployed skills, versions, and deploy new versions
12
+ *
13
+ * @param env - Optional environment argument ('sandbox', 'staging', or 'production')
14
+ * @returns Promise that resolves when command completes
15
+ */
16
+ export declare function skillsCommand(env?: string): Promise<void>;