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
package/dist/commands/init.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import inquirer from "inquirer";
|
|
2
2
|
import { fileURLToPath } from "url";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { loadApiKey, checkApiKey, createSkill } from "../services/auth.js";
|
|
5
|
-
import { copyTemplateFiles,
|
|
4
|
+
import { loadApiKey, checkApiKey, createSkill, getAgentTypes, createAgent, getAgentDetails } from "../services/auth.js";
|
|
5
|
+
import { copyTemplateFiles, createSkillYaml } from "../utils/files.js";
|
|
6
6
|
import { withErrorHandling, clearPromptLines, writeProgress, writeSuccess } from "../utils/cli.js";
|
|
7
7
|
function getTemplateDir() {
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -16,50 +16,237 @@ export async function initCommand() {
|
|
|
16
16
|
console.error("❌ No API key found. Run `lua configure` first.");
|
|
17
17
|
process.exit(1);
|
|
18
18
|
}
|
|
19
|
-
//
|
|
20
|
-
const
|
|
21
|
-
writeProgress("✅ Authenticated");
|
|
22
|
-
// Extract organizations and create choices for selection
|
|
23
|
-
const orgs = userData.admin.orgs;
|
|
24
|
-
if (!orgs || orgs.length === 0) {
|
|
25
|
-
console.error("❌ No organizations found.");
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
const orgChoices = orgs.map((org) => ({
|
|
29
|
-
name: org.registeredName,
|
|
30
|
-
value: org
|
|
31
|
-
}));
|
|
32
|
-
// Select organization
|
|
33
|
-
const { selectedOrg } = await inquirer.prompt([
|
|
19
|
+
// Ask user if they want to create a new agent or select existing one
|
|
20
|
+
const { agentChoice } = await inquirer.prompt([
|
|
34
21
|
{
|
|
35
22
|
type: "list",
|
|
36
|
-
name: "
|
|
37
|
-
message: "
|
|
38
|
-
choices:
|
|
23
|
+
name: "agentChoice",
|
|
24
|
+
message: "What would you like to do?",
|
|
25
|
+
choices: [
|
|
26
|
+
{ name: "Select existing agent", value: "existing" },
|
|
27
|
+
{ name: "Create new agent", value: "create" }
|
|
28
|
+
]
|
|
39
29
|
}
|
|
40
30
|
]);
|
|
41
|
-
// Clear the
|
|
31
|
+
// Clear the agent choice prompt lines
|
|
42
32
|
clearPromptLines(2);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
let selectedAgent;
|
|
34
|
+
let selectedOrg;
|
|
35
|
+
let persona;
|
|
36
|
+
let welcomeMessage;
|
|
37
|
+
if (agentChoice === "existing") {
|
|
38
|
+
// Get user data from API only when selecting existing agent
|
|
39
|
+
const userData = await checkApiKey(apiKey);
|
|
40
|
+
writeProgress("✅ Authenticated");
|
|
41
|
+
// Extract organizations and create choices for selection
|
|
42
|
+
const orgs = userData.admin.orgs;
|
|
43
|
+
if (!orgs || orgs.length === 0) {
|
|
44
|
+
console.error("❌ No organizations found.");
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
const orgChoices = orgs.map((org) => ({
|
|
48
|
+
name: org.registeredName || org.name || 'Unknown Organization',
|
|
49
|
+
value: org
|
|
50
|
+
}));
|
|
51
|
+
// Select organization
|
|
52
|
+
const { selectedOrg: existingOrg } = await inquirer.prompt([
|
|
53
|
+
{
|
|
54
|
+
type: "list",
|
|
55
|
+
name: "selectedOrg",
|
|
56
|
+
message: "Select an organization:",
|
|
57
|
+
choices: orgChoices
|
|
58
|
+
}
|
|
59
|
+
]);
|
|
60
|
+
selectedOrg = existingOrg;
|
|
61
|
+
// Clear the organization selection prompt lines
|
|
62
|
+
clearPromptLines(2);
|
|
63
|
+
// Extract agents from selected organization
|
|
64
|
+
if (!selectedOrg.agents || selectedOrg.agents.length === 0) {
|
|
65
|
+
console.error("❌ No agents found in the selected organization.");
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
const agentChoices = selectedOrg.agents.map((agent) => ({
|
|
69
|
+
name: agent.name,
|
|
70
|
+
value: agent
|
|
71
|
+
}));
|
|
72
|
+
// Select agent
|
|
73
|
+
const { selectedAgent: existingAgent } = await inquirer.prompt([
|
|
74
|
+
{
|
|
75
|
+
type: "list",
|
|
76
|
+
name: "selectedAgent",
|
|
77
|
+
message: "Select an agent:",
|
|
78
|
+
choices: agentChoices
|
|
79
|
+
}
|
|
80
|
+
]);
|
|
81
|
+
selectedAgent = existingAgent;
|
|
82
|
+
// Clear the agent selection prompt lines
|
|
83
|
+
clearPromptLines(2);
|
|
47
84
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
85
|
+
else {
|
|
86
|
+
// Create new agent flow
|
|
87
|
+
writeProgress("🔄 Fetching agent types...");
|
|
88
|
+
const agentTypes = await getAgentTypes(apiKey);
|
|
89
|
+
writeProgress("✅ Agent types loaded");
|
|
90
|
+
// Select agent type
|
|
91
|
+
const agentTypeChoices = agentTypes.map((type) => ({
|
|
92
|
+
name: type.name,
|
|
93
|
+
value: type
|
|
94
|
+
}));
|
|
95
|
+
const { selectedAgentType } = await inquirer.prompt([
|
|
96
|
+
{
|
|
97
|
+
type: "list",
|
|
98
|
+
name: "selectedAgentType",
|
|
99
|
+
message: "Select an agent type:",
|
|
100
|
+
choices: agentTypeChoices
|
|
101
|
+
}
|
|
102
|
+
]);
|
|
103
|
+
// Clear the agent type selection prompt lines
|
|
104
|
+
clearPromptLines(2);
|
|
105
|
+
// Collect required metadata
|
|
106
|
+
const metadata = {};
|
|
107
|
+
if (selectedAgentType.requiredSubAgentMetadata && selectedAgentType.requiredSubAgentMetadata.length > 0) {
|
|
108
|
+
for (const field of selectedAgentType.requiredSubAgentMetadata) {
|
|
109
|
+
const { [field]: value } = await inquirer.prompt([
|
|
110
|
+
{
|
|
111
|
+
type: "input",
|
|
112
|
+
name: field,
|
|
113
|
+
message: `Enter ${field}:`,
|
|
114
|
+
validate: (input) => input.trim().length > 0 || `${field} is required`
|
|
115
|
+
}
|
|
116
|
+
]);
|
|
117
|
+
metadata[field] = value;
|
|
118
|
+
// Clear the metadata prompt lines
|
|
119
|
+
clearPromptLines(2);
|
|
120
|
+
}
|
|
59
121
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
122
|
+
// Configure features
|
|
123
|
+
const features = {};
|
|
124
|
+
const availableFeatures = Object.keys(selectedAgentType.features);
|
|
125
|
+
if (availableFeatures.length > 0) {
|
|
126
|
+
for (const feature of availableFeatures) {
|
|
127
|
+
const { [feature]: enabled } = await inquirer.prompt([
|
|
128
|
+
{
|
|
129
|
+
type: "confirm",
|
|
130
|
+
name: feature,
|
|
131
|
+
message: `Enable ${feature} feature?`,
|
|
132
|
+
default: selectedAgentType.features[feature]?.active || false
|
|
133
|
+
}
|
|
134
|
+
]);
|
|
135
|
+
features[feature] = enabled;
|
|
136
|
+
// Clear the feature prompt lines
|
|
137
|
+
clearPromptLines(2);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Collect persona information
|
|
141
|
+
const businessTypes = [
|
|
142
|
+
"Retail & Consumer Goods (e.g. clothing store, bookstore)",
|
|
143
|
+
"Food & Beverage (e.g. restaurant, bakery)",
|
|
144
|
+
"Hospitality (e.g. hotel, resort)",
|
|
145
|
+
"Personal services (e.g. hair salon, spa)",
|
|
146
|
+
"Education (e.g. language school, online courses)",
|
|
147
|
+
"Health (e.g. gym, yoga studio, clinic)"
|
|
148
|
+
];
|
|
149
|
+
const brandPersonalities = [
|
|
150
|
+
"Energetic & fun",
|
|
151
|
+
"Refined & elegant",
|
|
152
|
+
"Chatty",
|
|
153
|
+
"Casual",
|
|
154
|
+
"Funny",
|
|
155
|
+
"Friendly"
|
|
156
|
+
];
|
|
157
|
+
const { businessName } = await inquirer.prompt([
|
|
158
|
+
{
|
|
159
|
+
type: "input",
|
|
160
|
+
name: "businessName",
|
|
161
|
+
message: "Enter business name:",
|
|
162
|
+
default: "Private"
|
|
163
|
+
}
|
|
164
|
+
]);
|
|
165
|
+
clearPromptLines(2);
|
|
166
|
+
const { agentName } = await inquirer.prompt([
|
|
167
|
+
{
|
|
168
|
+
type: "input",
|
|
169
|
+
name: "agentName",
|
|
170
|
+
message: "Enter agent name:",
|
|
171
|
+
validate: (input) => input.trim().length > 0 || "Agent name is required"
|
|
172
|
+
}
|
|
173
|
+
]);
|
|
174
|
+
clearPromptLines(2);
|
|
175
|
+
const { businessType } = await inquirer.prompt([
|
|
176
|
+
{
|
|
177
|
+
type: "list",
|
|
178
|
+
name: "businessType",
|
|
179
|
+
message: "Select business type:",
|
|
180
|
+
choices: businessTypes
|
|
181
|
+
}
|
|
182
|
+
]);
|
|
183
|
+
clearPromptLines(2);
|
|
184
|
+
const { brandPersonality } = await inquirer.prompt([
|
|
185
|
+
{
|
|
186
|
+
type: "list",
|
|
187
|
+
name: "brandPersonality",
|
|
188
|
+
message: "Select brand personality:",
|
|
189
|
+
choices: brandPersonalities
|
|
190
|
+
}
|
|
191
|
+
]);
|
|
192
|
+
clearPromptLines(2);
|
|
193
|
+
const { brandTraits } = await inquirer.prompt([
|
|
194
|
+
{
|
|
195
|
+
type: "input",
|
|
196
|
+
name: "brandTraits",
|
|
197
|
+
message: "Enter brand traits (any traits the agent might have):",
|
|
198
|
+
default: ""
|
|
199
|
+
}
|
|
200
|
+
]);
|
|
201
|
+
clearPromptLines(2);
|
|
202
|
+
// For new agents, we need to handle organization selection
|
|
203
|
+
// For now, we'll create a new organization with the business name
|
|
204
|
+
// In the future, we could add organization selection here too
|
|
205
|
+
// Create agent
|
|
206
|
+
writeProgress("🔄 Creating agent...");
|
|
207
|
+
const agentData = {
|
|
208
|
+
id: `agent_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
209
|
+
type: selectedAgentType.id,
|
|
210
|
+
metadata,
|
|
211
|
+
persona: {
|
|
212
|
+
agentName,
|
|
213
|
+
businessType,
|
|
214
|
+
brandPersonality,
|
|
215
|
+
brandTraits
|
|
216
|
+
},
|
|
217
|
+
features,
|
|
218
|
+
channels: [],
|
|
219
|
+
org: {
|
|
220
|
+
registeredName: businessName
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const createAgentResult = await createAgent(apiKey, agentData);
|
|
224
|
+
if (!createAgentResult.success || !createAgentResult.data) {
|
|
225
|
+
console.error("❌ Failed to create agent:", createAgentResult.error?.message || "Unknown error");
|
|
226
|
+
process.exit(1);
|
|
227
|
+
}
|
|
228
|
+
writeProgress("✅ Agent created successfully!");
|
|
229
|
+
// Wait 30 seconds and get agent details
|
|
230
|
+
writeProgress("⏳ Waiting for agent to be ready...");
|
|
231
|
+
await new Promise(resolve => setTimeout(resolve, 30000));
|
|
232
|
+
writeProgress("🔄 Fetching agent details...");
|
|
233
|
+
const agentDetailsResult = await getAgentDetails(apiKey, createAgentResult.data.agentId);
|
|
234
|
+
if (!agentDetailsResult.success || !agentDetailsResult.data) {
|
|
235
|
+
console.error("❌ Failed to fetch agent details:", agentDetailsResult.error?.message || "Unknown error");
|
|
236
|
+
process.exit(1);
|
|
237
|
+
}
|
|
238
|
+
selectedAgent = {
|
|
239
|
+
agentId: createAgentResult.data.agentId,
|
|
240
|
+
name: createAgentResult.data.name
|
|
241
|
+
};
|
|
242
|
+
persona = agentDetailsResult.data.persona;
|
|
243
|
+
welcomeMessage = agentDetailsResult.data.welcomeMessage;
|
|
244
|
+
// For new agents, get the organization ID from the created agent response
|
|
245
|
+
selectedOrg = {
|
|
246
|
+
id: createAgentResult.data.org.id
|
|
247
|
+
};
|
|
248
|
+
writeProgress("✅ Agent details loaded");
|
|
249
|
+
}
|
|
63
250
|
// Get skill name and handle retries
|
|
64
251
|
let skillName = "";
|
|
65
252
|
let skillData = null;
|
|
@@ -104,13 +291,14 @@ export async function initCommand() {
|
|
|
104
291
|
process.exit(1);
|
|
105
292
|
}
|
|
106
293
|
}
|
|
107
|
-
// Create lua.skill.
|
|
108
|
-
|
|
109
|
-
writeProgress("✅ Created lua.skill.toml");
|
|
294
|
+
// Create lua.skill.yaml file with skill ID, actual skill name, persona and welcome message from backend
|
|
295
|
+
const actualSkillName = skillData?.name || skillName;
|
|
110
296
|
// Copy template files
|
|
111
297
|
const templateDir = getTemplateDir();
|
|
112
298
|
const currentDir = process.cwd();
|
|
113
299
|
copyTemplateFiles(templateDir, currentDir);
|
|
300
|
+
createSkillYaml(selectedAgent.agentId, selectedOrg.id, actualSkillName, skillData?.id, persona, welcomeMessage);
|
|
301
|
+
writeProgress("✅ Created lua.skill.yaml");
|
|
114
302
|
writeProgress("✅ Copied template files");
|
|
115
303
|
writeSuccess("✅ Lua skill project initialized successfully!");
|
|
116
304
|
}, "initialization");
|
package/dist/commands/push.js
CHANGED
|
@@ -3,29 +3,26 @@ import path from 'path';
|
|
|
3
3
|
import inquirer from 'inquirer';
|
|
4
4
|
import { compileCommand } from './compile.js';
|
|
5
5
|
import { checkApiKey, loadApiKey } from '../services/auth.js';
|
|
6
|
+
import { ApiService } from '../services/api.js';
|
|
7
|
+
import { readSkillConfig } from '../utils/files.js';
|
|
6
8
|
import { withErrorHandling, clearPromptLines, writeProgress, writeSuccess } from '../utils/cli.js';
|
|
7
9
|
export async function pushVersion(apiKey, agentId, skillId, versionData) {
|
|
8
10
|
try {
|
|
9
|
-
const response = await
|
|
10
|
-
|
|
11
|
-
headers: {
|
|
12
|
-
"accept": "application/json",
|
|
13
|
-
"Authorization": `Bearer ${apiKey}`,
|
|
14
|
-
"Content-Type": "application/json"
|
|
15
|
-
},
|
|
16
|
-
body: JSON.stringify(versionData)
|
|
17
|
-
});
|
|
18
|
-
const data = await response.json();
|
|
19
|
-
if (response.ok) {
|
|
11
|
+
const response = await ApiService.Skill.pushSkill(apiKey, agentId, skillId, versionData);
|
|
12
|
+
if (response.success) {
|
|
20
13
|
return {
|
|
21
14
|
success: true,
|
|
22
|
-
data: data
|
|
15
|
+
data: response.data
|
|
23
16
|
};
|
|
24
17
|
}
|
|
25
18
|
else {
|
|
26
19
|
return {
|
|
27
20
|
success: false,
|
|
28
|
-
error:
|
|
21
|
+
error: {
|
|
22
|
+
message: response.error?.message || 'Unknown error',
|
|
23
|
+
error: response.error?.message || 'Unknown error',
|
|
24
|
+
statusCode: response.error?.statusCode || 500
|
|
25
|
+
}
|
|
29
26
|
};
|
|
30
27
|
}
|
|
31
28
|
}
|
|
@@ -41,14 +38,9 @@ export async function pushVersion(apiKey, agentId, skillId, versionData) {
|
|
|
41
38
|
};
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
|
-
function
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
const tomlContent = fs.readFileSync(tomlPath, 'utf8');
|
|
50
|
-
const versionMatch = tomlContent.match(/version\s*=\s*["']([^"']+)["']/);
|
|
51
|
-
return versionMatch ? versionMatch[1] : null;
|
|
41
|
+
function readConfigVersion() {
|
|
42
|
+
const config = readSkillConfig();
|
|
43
|
+
return config?.skill?.version || null;
|
|
52
44
|
}
|
|
53
45
|
function readDeployJson() {
|
|
54
46
|
const deployPath = path.join(process.cwd(), '.lua', 'deploy.json');
|
|
@@ -61,15 +53,15 @@ function readDeployJson() {
|
|
|
61
53
|
export async function pushCommand() {
|
|
62
54
|
return withErrorHandling(async () => {
|
|
63
55
|
// Check if we're in a skill directory
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
66
|
-
console.error("❌ No lua.skill.
|
|
56
|
+
const config = readSkillConfig();
|
|
57
|
+
if (!config) {
|
|
58
|
+
console.error("❌ No lua.skill.yaml found. Please run this command from a skill directory.");
|
|
67
59
|
process.exit(1);
|
|
68
60
|
}
|
|
69
|
-
// Read version from
|
|
70
|
-
const version =
|
|
61
|
+
// Read version from config
|
|
62
|
+
const version = config.skill?.version;
|
|
71
63
|
if (!version) {
|
|
72
|
-
console.error("❌ No version found in
|
|
64
|
+
console.error("❌ No version found in skill configuration");
|
|
73
65
|
process.exit(1);
|
|
74
66
|
}
|
|
75
67
|
// Confirm with user
|
|
@@ -107,19 +99,16 @@ export async function pushCommand() {
|
|
|
107
99
|
}
|
|
108
100
|
// Verify version matches
|
|
109
101
|
if (deployData.version !== version) {
|
|
110
|
-
console.error(`❌ Version mismatch:
|
|
102
|
+
console.error(`❌ Version mismatch: config has ${version}, deploy.json has ${deployData.version}`);
|
|
111
103
|
process.exit(1);
|
|
112
104
|
}
|
|
113
|
-
// Extract agentId and skillId from
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
console.error("❌ Missing agentId or skillId in lua.skill.toml");
|
|
105
|
+
// Extract agentId and skillId from config
|
|
106
|
+
const agentId = config.agent?.agentId;
|
|
107
|
+
const skillId = config.skill?.skillId;
|
|
108
|
+
if (!agentId || !skillId) {
|
|
109
|
+
console.error("❌ Missing agentId or skillId in skill configuration");
|
|
119
110
|
process.exit(1);
|
|
120
111
|
}
|
|
121
|
-
const agentId = agentIdMatch[1];
|
|
122
|
-
const skillId = skillIdMatch[1];
|
|
123
112
|
// Push version
|
|
124
113
|
writeProgress("🔄 Pushing version to server...");
|
|
125
114
|
const result = await pushVersion(apiKey, agentId, skillId, deployData);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export {};
|
|
2
|
+
export { user, createUserDataAPI, UserDataAPI } from './user-data-api.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
|
-
import { configureCommand, initCommand, destroyCommand, apiKeyCommand, compileCommand, testCommand, pushCommand, deployCommand } from "./commands/index.js";
|
|
3
|
+
import { configureCommand, initCommand, destroyCommand, apiKeyCommand, compileCommand, testCommand, pushCommand, deployCommand, devCommand } from "./commands/index.js";
|
|
4
4
|
const program = new Command();
|
|
5
5
|
const authCommand = program
|
|
6
6
|
.command("auth")
|
|
@@ -40,4 +40,10 @@ skillCommand
|
|
|
40
40
|
.command("deploy")
|
|
41
41
|
.description("Deploy a version to production")
|
|
42
42
|
.action(deployCommand);
|
|
43
|
+
skillCommand
|
|
44
|
+
.command("dev")
|
|
45
|
+
.description("Push compiled skill version to sandbox for development")
|
|
46
|
+
.action(devCommand);
|
|
43
47
|
program.parse(process.argv);
|
|
48
|
+
// Export user data API for use in projects
|
|
49
|
+
export { user, createUserDataAPI, UserDataAPI } from './user-data-api.js';
|
|
@@ -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
|
+
};
|