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.
- package/dist/api/agent.api.service.d.ts +45 -0
- package/dist/api/agent.api.service.js +54 -0
- package/dist/api/user.data.api.service.d.ts +15 -0
- package/dist/api/user.data.api.service.js +31 -0
- package/dist/cli/command-definitions.js +77 -5
- package/dist/commands/completion.d.ts +11 -0
- package/dist/commands/completion.js +209 -0
- package/dist/commands/env.d.ts +3 -2
- package/dist/commands/env.js +42 -17
- package/dist/commands/features.d.ts +16 -0
- package/dist/commands/features.js +352 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.js +3 -0
- package/dist/commands/persona.d.ts +3 -2
- package/dist/commands/persona.js +43 -18
- package/dist/commands/push.d.ts +9 -13
- package/dist/commands/push.js +271 -82
- package/dist/commands/skills.d.ts +16 -0
- package/dist/commands/skills.js +438 -0
- package/dist/common/data.entry.instance.d.ts +7 -0
- package/dist/common/data.entry.instance.js +15 -0
- package/dist/common/order.instance.d.ts +6 -0
- package/dist/common/order.instance.js +14 -0
- package/dist/common/product.instance.d.ts +6 -0
- package/dist/common/product.instance.js +14 -0
- package/dist/common/user.instance.d.ts +14 -0
- package/dist/common/user.instance.js +29 -0
- package/dist/index.js +14 -3
- package/dist/interfaces/agent.d.ts +31 -0
- package/dist/interfaces/message.d.ts +18 -0
- package/dist/interfaces/message.js +1 -0
- package/dist/types/api-contracts.d.ts +9 -0
- package/dist/types/api-contracts.js +0 -7
- package/dist/web/app.css +152 -736
- package/dist/web/app.js +45 -45
- package/package.json +2 -2
- package/template/package.json +1 -1
package/dist/commands/push.js
CHANGED
|
@@ -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
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
if
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
67
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
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>;
|