lua-cli 2.2.8-alpha.1 → 2.3.0-alpha.1
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/API_REFERENCE.md +1408 -0
- package/CLI_REFERENCE.md +818 -0
- package/GETTING_STARTED.md +1040 -0
- package/README.md +738 -424
- package/TEMPLATE_GUIDE.md +1398 -0
- package/dist/api/agent.api.service.d.ts +45 -0
- package/dist/api/agent.api.service.js +57 -0
- package/dist/api/auth.api.service.d.ts +48 -0
- package/dist/api/auth.api.service.js +54 -0
- package/dist/api/basket.api.service.d.ts +85 -0
- package/dist/api/basket.api.service.js +164 -0
- package/dist/api/chat.api.service.d.ts +21 -0
- package/dist/api/chat.api.service.js +24 -0
- package/dist/api/credentials.d.ts +24 -0
- package/dist/api/credentials.js +46 -0
- package/dist/api/custom.data.api.service.d.ts +69 -0
- package/dist/api/custom.data.api.service.js +125 -0
- package/dist/api/lazy-instances.d.ts +49 -0
- package/dist/api/lazy-instances.js +95 -0
- package/dist/api/order.api.service.d.ts +53 -0
- package/dist/api/order.api.service.js +95 -0
- package/dist/api/products.api.service.d.ts +66 -0
- package/dist/api/products.api.service.js +112 -0
- package/dist/api/skills.api.service.d.ts +77 -0
- package/dist/api/skills.api.service.js +88 -0
- package/dist/api/tool.api.service.d.ts +52 -0
- package/dist/api/tool.api.service.js +73 -0
- package/dist/api/user.data.api.service.d.ts +33 -0
- package/dist/api/user.data.api.service.js +59 -0
- package/dist/api-exports.d.ts +271 -0
- package/dist/api-exports.js +372 -0
- package/dist/cli/command-definitions.d.ts +30 -0
- package/dist/cli/command-definitions.js +71 -0
- package/dist/commands/agents.d.ts +20 -0
- package/dist/commands/agents.js +24 -2
- package/dist/commands/apiKey.d.ts +23 -0
- package/dist/commands/apiKey.js +23 -0
- package/dist/commands/compile.d.ts +24 -0
- package/dist/commands/compile.js +67 -759
- package/dist/commands/configure.d.ts +24 -0
- package/dist/commands/configure.js +31 -96
- package/dist/commands/deploy.d.ts +31 -19
- package/dist/commands/deploy.js +45 -74
- package/dist/commands/destroy.d.ts +27 -0
- package/dist/commands/destroy.js +27 -1
- package/dist/commands/dev.d.ts +25 -62
- package/dist/commands/dev.js +58 -873
- package/dist/commands/init.d.ts +27 -0
- package/dist/commands/init.js +98 -260
- package/dist/commands/push.d.ts +24 -21
- package/dist/commands/push.js +39 -92
- package/dist/commands/test.d.ts +26 -0
- package/dist/commands/test.js +41 -188
- package/dist/common/basket.instance.d.ts +78 -0
- package/dist/common/basket.instance.js +132 -0
- package/dist/common/data.entry.instance.d.ts +39 -0
- package/dist/common/data.entry.instance.js +76 -0
- package/dist/common/http.client.d.ts +64 -0
- package/dist/common/http.client.js +133 -0
- package/dist/common/order.instance.d.ts +40 -0
- package/dist/common/order.instance.js +79 -0
- package/dist/common/product.instance.d.ts +33 -0
- package/dist/common/product.instance.js +63 -0
- package/dist/common/product.pagination.instance.d.ts +43 -0
- package/dist/common/product.pagination.instance.js +74 -0
- package/dist/common/product.search.instance.d.ts +22 -0
- package/dist/common/product.search.instance.js +40 -0
- package/dist/common/user.instance.d.ts +41 -0
- package/dist/common/user.instance.js +84 -0
- package/dist/config/auth.constants.d.ts +11 -0
- package/dist/config/auth.constants.js +11 -0
- package/dist/config/compile.constants.d.ts +67 -0
- package/dist/config/compile.constants.js +99 -0
- package/dist/config/constants.d.ts +5 -0
- package/dist/config/constants.js +5 -0
- package/dist/config/dev.constants.d.ts +65 -0
- package/dist/config/dev.constants.js +79 -0
- package/dist/config/init.constants.d.ts +23 -0
- package/dist/config/init.constants.js +41 -0
- package/dist/index.d.ts +19 -3
- package/dist/index.js +28 -44
- package/dist/interfaces/admin.d.ts +101 -0
- package/dist/interfaces/admin.js +5 -0
- package/dist/interfaces/agent.d.ts +107 -0
- package/dist/interfaces/agent.js +5 -0
- package/dist/interfaces/baskets.d.ts +135 -0
- package/dist/interfaces/baskets.js +19 -0
- package/dist/interfaces/chat.d.ts +61 -0
- package/dist/interfaces/chat.js +5 -0
- package/dist/interfaces/common.d.ts +62 -0
- package/dist/interfaces/common.js +8 -0
- package/dist/interfaces/compile.d.ts +11 -0
- package/dist/interfaces/compile.js +4 -0
- package/dist/interfaces/custom.data.d.ts +82 -0
- package/dist/interfaces/custom.data.js +5 -0
- package/dist/interfaces/deploy.d.ts +29 -0
- package/dist/interfaces/deploy.js +4 -0
- package/dist/interfaces/dev.d.ts +53 -0
- package/dist/interfaces/dev.js +5 -0
- package/dist/interfaces/init.d.ts +60 -0
- package/dist/interfaces/init.js +4 -0
- package/dist/interfaces/orders.d.ts +91 -0
- package/dist/interfaces/orders.js +19 -0
- package/dist/interfaces/product.d.ts +65 -0
- package/dist/interfaces/product.js +5 -0
- package/dist/interfaces/push.d.ts +26 -0
- package/dist/interfaces/push.js +4 -0
- package/dist/interfaces/test.d.ts +36 -0
- package/dist/interfaces/test.js +4 -0
- package/dist/services/auth.d.ts +54 -99
- package/dist/services/auth.js +76 -12
- package/dist/types/api-contracts.d.ts +211 -0
- package/dist/types/api-contracts.js +8 -0
- package/dist/types/compile.types.d.ts +76 -0
- package/dist/types/compile.types.js +4 -0
- package/dist/types/index.d.ts +23 -85
- package/dist/types/index.js +25 -14
- package/dist/types/skill.d.ts +142 -0
- package/dist/{skill.js → types/skill.js} +66 -19
- package/dist/types/tool-validation.d.ts +34 -0
- package/dist/types/tool-validation.js +42 -0
- package/dist/utils/auth-flows.d.ts +26 -0
- package/dist/utils/auth-flows.js +141 -0
- package/dist/utils/bundling.d.ts +36 -0
- package/dist/utils/bundling.js +137 -0
- package/dist/utils/compile.d.ts +37 -0
- package/dist/utils/compile.js +242 -0
- package/dist/utils/deploy-api.d.ts +26 -0
- package/dist/utils/deploy-api.js +53 -0
- package/dist/utils/deploy-helpers.d.ts +46 -0
- package/dist/utils/deploy-helpers.js +86 -0
- package/dist/utils/deployment.d.ts +25 -0
- package/dist/utils/deployment.js +161 -0
- package/dist/utils/dev-api.d.ts +61 -0
- package/dist/utils/dev-api.js +262 -0
- package/dist/utils/dev-helpers.d.ts +46 -0
- package/dist/utils/dev-helpers.js +83 -0
- package/dist/utils/dev-server.d.ts +24 -0
- package/dist/utils/dev-server.js +555 -0
- package/dist/utils/dev-watcher.d.ts +31 -0
- package/dist/utils/dev-watcher.js +110 -0
- package/dist/utils/files.js +0 -5
- package/dist/utils/init-agent.d.ts +34 -0
- package/dist/utils/init-agent.js +129 -0
- package/dist/utils/init-helpers.d.ts +41 -0
- package/dist/utils/init-helpers.js +73 -0
- package/dist/utils/init-prompts.d.ts +47 -0
- package/dist/utils/init-prompts.js +168 -0
- package/dist/utils/push-api.d.ts +15 -0
- package/dist/utils/push-api.js +48 -0
- package/dist/utils/push-helpers.d.ts +38 -0
- package/dist/utils/push-helpers.js +84 -0
- package/dist/utils/sandbox-storage.d.ts +27 -0
- package/dist/utils/sandbox-storage.js +71 -0
- package/dist/utils/sandbox.js +78 -118
- package/dist/utils/skill-management.d.ts +14 -0
- package/dist/utils/skill-management.js +148 -0
- package/dist/utils/test-helpers.d.ts +40 -0
- package/dist/utils/test-helpers.js +92 -0
- package/dist/utils/test-prompts.d.ts +23 -0
- package/dist/utils/test-prompts.js +186 -0
- package/dist/utils/tool-detection.d.ts +18 -0
- package/dist/utils/tool-detection.js +110 -0
- package/dist/web/app.css +14 -9
- package/package.json +11 -12
- package/template/QUICKSTART.md +299 -144
- package/template/README.md +928 -349
- package/template/TOOL_EXAMPLES.md +655 -0
- package/template/package-lock.json +3781 -0
- package/template/package.json +1 -1
- package/template/src/index.ts +81 -40
- package/template/src/tools/BasketTool.ts +128 -0
- package/template/src/tools/CustomDataTool.ts +7 -13
- package/template/src/tools/OrderTool.ts +54 -0
- package/template/src/tools/PaymentTool.ts +1 -1
- package/template/src/tools/ProductsTool.ts +56 -118
- package/template/src/tools/UserDataTool.ts +4 -27
- package/dist/custom-data-api.d.ts +0 -72
- package/dist/custom-data-api.js +0 -174
- package/dist/product-api.d.ts +0 -197
- package/dist/product-api.js +0 -152
- package/dist/services/api.d.ts +0 -569
- package/dist/services/api.js +0 -625
- package/dist/skill.d.ts +0 -50
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -2
- package/dist/user-data-api.d.ts +0 -39
- package/dist/user-data-api.js +0 -50
- package/template/API.md +0 -604
- package/template/DEVELOPER.md +0 -771
- package/template/lua.skill.yaml +0 -16
package/dist/commands/init.d.ts
CHANGED
|
@@ -1 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Init Command
|
|
3
|
+
* Orchestrates the initialization of a new Lua skill project
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Main init command - initializes a new Lua skill project.
|
|
7
|
+
*
|
|
8
|
+
* This command performs the following steps:
|
|
9
|
+
* 1. Authenticates the user
|
|
10
|
+
* 2. Prompts to select existing agent or create new one
|
|
11
|
+
* 3. For existing: Lets user select organization and agent
|
|
12
|
+
* 4. For new: Collects configuration and creates agent
|
|
13
|
+
* 5. Copies template files to current directory
|
|
14
|
+
* 6. Creates lua.skill.yaml configuration
|
|
15
|
+
* 7. Installs npm dependencies
|
|
16
|
+
*
|
|
17
|
+
* Features:
|
|
18
|
+
* - Interactive agent selection or creation
|
|
19
|
+
* - Organization management
|
|
20
|
+
* - Business configuration
|
|
21
|
+
* - Agent type selection (defaults to Base Agent)
|
|
22
|
+
* - Feature configuration
|
|
23
|
+
* - Automatic project scaffolding
|
|
24
|
+
* - Dependency installation
|
|
25
|
+
*
|
|
26
|
+
* @returns Promise that resolves when initialization is complete
|
|
27
|
+
*/
|
|
1
28
|
export declare function initCommand(): Promise<void>;
|
package/dist/commands/init.js
CHANGED
|
@@ -1,279 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Init Command
|
|
3
|
+
* Orchestrates the initialization of a new Lua skill project
|
|
4
|
+
*/
|
|
4
5
|
import { loadApiKey, checkApiKey } from "../services/auth.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
import { withErrorHandling, writeSuccess } from "../utils/cli.js";
|
|
7
|
+
import { promptAgentChoice, promptOrganizationSelection, promptAgentSelection, promptMetadataCollection, promptFeatureConfiguration, promptBusinessConfiguration, } from "../utils/init-prompts.js";
|
|
8
|
+
import { fetchAgentTypes, selectBaseAgentType, createNewAgent, } from "../utils/init-agent.js";
|
|
9
|
+
import { initializeProject, installDependencies, clearLinesIfNeeded, } from "../utils/init-helpers.js";
|
|
10
|
+
/**
|
|
11
|
+
* Main init command - initializes a new Lua skill project.
|
|
12
|
+
*
|
|
13
|
+
* This command performs the following steps:
|
|
14
|
+
* 1. Authenticates the user
|
|
15
|
+
* 2. Prompts to select existing agent or create new one
|
|
16
|
+
* 3. For existing: Lets user select organization and agent
|
|
17
|
+
* 4. For new: Collects configuration and creates agent
|
|
18
|
+
* 5. Copies template files to current directory
|
|
19
|
+
* 6. Creates lua.skill.yaml configuration
|
|
20
|
+
* 7. Installs npm dependencies
|
|
21
|
+
*
|
|
22
|
+
* Features:
|
|
23
|
+
* - Interactive agent selection or creation
|
|
24
|
+
* - Organization management
|
|
25
|
+
* - Business configuration
|
|
26
|
+
* - Agent type selection (defaults to Base Agent)
|
|
27
|
+
* - Feature configuration
|
|
28
|
+
* - Automatic project scaffolding
|
|
29
|
+
* - Dependency installation
|
|
30
|
+
*
|
|
31
|
+
* @returns Promise that resolves when initialization is complete
|
|
32
|
+
*/
|
|
13
33
|
export async function initCommand() {
|
|
14
34
|
return withErrorHandling(async () => {
|
|
35
|
+
// Step 1: Authenticate
|
|
15
36
|
const apiKey = await loadApiKey();
|
|
16
37
|
if (!apiKey) {
|
|
17
38
|
console.error("❌ No API key found. Run `lua auth configure` first.");
|
|
18
39
|
process.exit(1);
|
|
19
40
|
}
|
|
20
|
-
//
|
|
21
|
-
const
|
|
22
|
-
{
|
|
23
|
-
type: "list",
|
|
24
|
-
name: "agentChoice",
|
|
25
|
-
message: "What would you like to do?",
|
|
26
|
-
choices: [
|
|
27
|
-
{ name: "Select existing agent", value: "existing" },
|
|
28
|
-
{ name: "Create new agent", value: "create" }
|
|
29
|
-
]
|
|
30
|
-
}
|
|
31
|
-
]);
|
|
32
|
-
// Clear the agent choice prompt lines
|
|
33
|
-
// clearPromptLines(2);
|
|
41
|
+
// Step 2: Choose between existing or new agent
|
|
42
|
+
const agentChoice = await promptAgentChoice();
|
|
34
43
|
let selectedAgent;
|
|
35
44
|
let selectedOrg;
|
|
36
45
|
let persona;
|
|
37
46
|
let welcomeMessage;
|
|
38
47
|
if (agentChoice === "existing") {
|
|
39
|
-
//
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const orgs = userData.admin.orgs;
|
|
44
|
-
if (!orgs || orgs.length === 0) {
|
|
45
|
-
console.error("❌ No organizations found.");
|
|
46
|
-
process.exit(1);
|
|
47
|
-
}
|
|
48
|
-
const orgChoices = orgs.map((org) => ({
|
|
49
|
-
name: org.registeredName || org.name || 'Unknown Organization',
|
|
50
|
-
value: org
|
|
51
|
-
}));
|
|
52
|
-
// Select organization
|
|
53
|
-
const { selectedOrg: existingOrg } = await inquirer.prompt([
|
|
54
|
-
{
|
|
55
|
-
type: "list",
|
|
56
|
-
name: "selectedOrg",
|
|
57
|
-
message: "Select an organization:",
|
|
58
|
-
choices: orgChoices
|
|
59
|
-
}
|
|
60
|
-
]);
|
|
61
|
-
selectedOrg = existingOrg;
|
|
62
|
-
// Clear the organization selection prompt lines
|
|
63
|
-
// clearPromptLines(2);
|
|
64
|
-
// Extract agents from selected organization
|
|
65
|
-
if (!selectedOrg.agents || selectedOrg.agents.length === 0) {
|
|
66
|
-
console.error("❌ No agents found in the selected organization.");
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
const agentChoices = selectedOrg.agents.map((agent) => ({
|
|
70
|
-
name: agent.name,
|
|
71
|
-
value: agent
|
|
72
|
-
}));
|
|
73
|
-
// Select agent
|
|
74
|
-
const { selectedAgent: existingAgent } = await inquirer.prompt([
|
|
75
|
-
{
|
|
76
|
-
type: "list",
|
|
77
|
-
name: "selectedAgent",
|
|
78
|
-
message: "Select an agent:",
|
|
79
|
-
choices: agentChoices
|
|
80
|
-
}
|
|
81
|
-
]);
|
|
82
|
-
selectedAgent = existingAgent;
|
|
83
|
-
// Clear the agent selection prompt lines
|
|
84
|
-
// clearPromptLines(2);
|
|
48
|
+
// Step 3a: Select existing agent
|
|
49
|
+
const result = await selectExistingAgent(apiKey);
|
|
50
|
+
selectedAgent = result.agent;
|
|
51
|
+
selectedOrg = result.org;
|
|
85
52
|
}
|
|
86
53
|
else {
|
|
87
|
-
// Create new agent
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
let selectedAgentType = agentTypes.find((type) => type.name === 'Base Agent' ||
|
|
94
|
-
type.name === 'baseAgent' ||
|
|
95
|
-
type.name.toLowerCase().includes('base'));
|
|
96
|
-
// If still not found, use the first available type
|
|
97
|
-
if (!selectedAgentType && agentTypes.length > 0) {
|
|
98
|
-
selectedAgentType = agentTypes[0];
|
|
99
|
-
writeProgress(`⚠️ baseAgent not found, using ${selectedAgentType.name} instead`);
|
|
100
|
-
}
|
|
101
|
-
if (!selectedAgentType) {
|
|
102
|
-
throw new Error("No agent types available. Please contact support.");
|
|
103
|
-
}
|
|
104
|
-
writeProgress(`✅ Using agent type: ${selectedAgentType.name}`);
|
|
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
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// Configure features
|
|
123
|
-
const features = {};
|
|
124
|
-
const availableFeatures = Object.keys(selectedAgentType.features);
|
|
125
|
-
let linesToClear = 1;
|
|
126
|
-
if (availableFeatures.length > 0) {
|
|
127
|
-
for (const feature of availableFeatures) {
|
|
128
|
-
const { [feature]: enabled } = await inquirer.prompt([
|
|
129
|
-
{
|
|
130
|
-
type: "confirm",
|
|
131
|
-
name: feature,
|
|
132
|
-
message: `Enable ${feature} feature?`,
|
|
133
|
-
default: selectedAgentType.features[feature]?.active || false
|
|
134
|
-
}
|
|
135
|
-
]);
|
|
136
|
-
features[feature] = enabled;
|
|
137
|
-
linesToClear++;
|
|
138
|
-
// Clear the feature prompt lines
|
|
139
|
-
// clearPromptLines(2);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
// Collect persona information
|
|
143
|
-
const businessTypes = [
|
|
144
|
-
"Retail & Consumer Goods (e.g. clothing store, bookstore)",
|
|
145
|
-
"Food & Beverage (e.g. restaurant, bakery)",
|
|
146
|
-
"Hospitality (e.g. hotel, resort)",
|
|
147
|
-
"Personal services (e.g. hair salon, spa)",
|
|
148
|
-
"Education (e.g. language school, online courses)",
|
|
149
|
-
"Health (e.g. gym, yoga studio, clinic)"
|
|
150
|
-
];
|
|
151
|
-
const brandPersonalities = [
|
|
152
|
-
"Energetic & fun",
|
|
153
|
-
"Refined & elegant",
|
|
154
|
-
"Chatty",
|
|
155
|
-
"Casual",
|
|
156
|
-
"Funny",
|
|
157
|
-
"Friendly"
|
|
158
|
-
];
|
|
159
|
-
const { businessName } = await inquirer.prompt([
|
|
160
|
-
{
|
|
161
|
-
type: "input",
|
|
162
|
-
name: "businessName",
|
|
163
|
-
message: "Enter business name:",
|
|
164
|
-
default: "Private"
|
|
165
|
-
}
|
|
166
|
-
]);
|
|
167
|
-
// clearPromptLines(2);
|
|
168
|
-
linesToClear++;
|
|
169
|
-
const { agentName } = await inquirer.prompt([
|
|
170
|
-
{
|
|
171
|
-
type: "input",
|
|
172
|
-
name: "agentName",
|
|
173
|
-
message: "Enter agent name:",
|
|
174
|
-
validate: (input) => input.trim().length > 0 || "Agent name is required"
|
|
175
|
-
}
|
|
176
|
-
]);
|
|
177
|
-
// clearPromptLines(2);
|
|
178
|
-
linesToClear++;
|
|
179
|
-
const { businessType } = await inquirer.prompt([
|
|
180
|
-
{
|
|
181
|
-
type: "list",
|
|
182
|
-
name: "businessType",
|
|
183
|
-
message: "Select business type:",
|
|
184
|
-
choices: businessTypes
|
|
185
|
-
}
|
|
186
|
-
]);
|
|
187
|
-
// clearPromptLines(2);
|
|
188
|
-
linesToClear++;
|
|
189
|
-
const { brandPersonality } = await inquirer.prompt([
|
|
190
|
-
{
|
|
191
|
-
type: "list",
|
|
192
|
-
name: "brandPersonality",
|
|
193
|
-
message: "Select brand personality:",
|
|
194
|
-
choices: brandPersonalities
|
|
195
|
-
}
|
|
196
|
-
]);
|
|
197
|
-
// clearPromptLines(2);
|
|
198
|
-
linesToClear++;
|
|
199
|
-
const { brandTraits } = await inquirer.prompt([
|
|
200
|
-
{
|
|
201
|
-
type: "input",
|
|
202
|
-
name: "brandTraits",
|
|
203
|
-
message: "Enter brand traits (any traits the agent might have):",
|
|
204
|
-
default: ""
|
|
205
|
-
}
|
|
206
|
-
]);
|
|
207
|
-
// clearPromptLines(2);
|
|
208
|
-
linesToClear++;
|
|
209
|
-
// For new agents, we need to handle organization selection
|
|
210
|
-
// For now, we'll create a new organization with the business name
|
|
211
|
-
// In the future, we could add organization selection here too
|
|
212
|
-
clearPromptLines(linesToClear);
|
|
213
|
-
linesToClear = 0;
|
|
214
|
-
// Create agent
|
|
215
|
-
writeProgress("🔄 Creating agent...");
|
|
216
|
-
const agentData = {
|
|
217
|
-
id: `agent_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
218
|
-
type: selectedAgentType.id,
|
|
219
|
-
metadata,
|
|
220
|
-
persona: {
|
|
221
|
-
agentName,
|
|
222
|
-
businessType,
|
|
223
|
-
brandPersonality,
|
|
224
|
-
brandTraits
|
|
225
|
-
},
|
|
226
|
-
features,
|
|
227
|
-
channels: [],
|
|
228
|
-
org: {
|
|
229
|
-
registeredName: businessName
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
const createAgentResult = await ApiService.Agent.createAgent(apiKey, agentData);
|
|
233
|
-
if (!createAgentResult.success || !createAgentResult.data) {
|
|
234
|
-
console.error("❌ Failed to create agent:", createAgentResult.error?.message || "Unknown error");
|
|
235
|
-
process.exit(1);
|
|
236
|
-
}
|
|
237
|
-
writeProgress("✅ Agent created successfully!");
|
|
238
|
-
// Wait 30 seconds and get agent details
|
|
239
|
-
writeProgress("⏳ Waiting for agent to be ready...");
|
|
240
|
-
await new Promise(resolve => setTimeout(resolve, 30000));
|
|
241
|
-
writeProgress("🔄 Fetching agent details...");
|
|
242
|
-
const agentDetailsResult = await ApiService.Agent.getAgent(apiKey, createAgentResult.data?.agentId);
|
|
243
|
-
if (!agentDetailsResult.success || !agentDetailsResult.data) {
|
|
244
|
-
console.error("❌ Failed to fetch agent details:", agentDetailsResult.error?.message || "Unknown error");
|
|
245
|
-
process.exit(1);
|
|
246
|
-
}
|
|
247
|
-
selectedAgent = {
|
|
248
|
-
agentId: createAgentResult.data.agentId,
|
|
249
|
-
name: createAgentResult.data.name
|
|
250
|
-
};
|
|
251
|
-
persona = agentDetailsResult.data.persona;
|
|
252
|
-
welcomeMessage = agentDetailsResult.data.welcomeMessage;
|
|
253
|
-
// For new agents, get the organization ID from the created agent response
|
|
254
|
-
selectedOrg = {
|
|
255
|
-
id: createAgentResult.data.org.id
|
|
256
|
-
};
|
|
257
|
-
writeProgress("✅ Agent details loaded");
|
|
258
|
-
}
|
|
259
|
-
// Skills will be created automatically during compilation
|
|
260
|
-
// Copy template files
|
|
261
|
-
const templateDir = getTemplateDir();
|
|
262
|
-
const currentDir = process.cwd();
|
|
263
|
-
copyTemplateFiles(templateDir, currentDir);
|
|
264
|
-
createSkillYaml(selectedAgent.agentId, selectedOrg.id, undefined, undefined, persona, welcomeMessage);
|
|
265
|
-
writeProgress("✅ Created lua.skill.yaml");
|
|
266
|
-
writeProgress("✅ Copied template files");
|
|
267
|
-
// Install dependencies
|
|
268
|
-
writeProgress("📦 Installing dependencies...");
|
|
269
|
-
const { execSync } = await import('child_process');
|
|
270
|
-
try {
|
|
271
|
-
execSync('npm install --force', { stdio: 'inherit', cwd: currentDir });
|
|
272
|
-
writeProgress("✅ Dependencies installed successfully");
|
|
273
|
-
}
|
|
274
|
-
catch (error) {
|
|
275
|
-
writeProgress("⚠️ Warning: Failed to install dependencies automatically. Please run 'npm install' manually.");
|
|
54
|
+
// Step 3b: Create new agent
|
|
55
|
+
const result = await createNewAgentFlow(apiKey);
|
|
56
|
+
selectedAgent = result.agent;
|
|
57
|
+
selectedOrg = result.org;
|
|
58
|
+
persona = result.persona;
|
|
59
|
+
welcomeMessage = result.welcomeMessage;
|
|
276
60
|
}
|
|
61
|
+
// Step 4: Initialize project
|
|
62
|
+
const currentDir = initializeProject(selectedAgent.agentId, selectedOrg.id, persona, welcomeMessage);
|
|
63
|
+
// Step 5: Install dependencies
|
|
64
|
+
await installDependencies(currentDir);
|
|
277
65
|
writeSuccess("✅ Lua skill project initialized successfully!");
|
|
278
66
|
}, "initialization");
|
|
279
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Handles the flow for selecting an existing agent.
|
|
70
|
+
*
|
|
71
|
+
* @param apiKey - User's API key
|
|
72
|
+
* @returns Selected agent and organization
|
|
73
|
+
*/
|
|
74
|
+
async function selectExistingAgent(apiKey) {
|
|
75
|
+
// Get user data from API
|
|
76
|
+
const userData = await checkApiKey(apiKey);
|
|
77
|
+
// Extract organizations
|
|
78
|
+
const orgs = userData.admin.orgs;
|
|
79
|
+
if (!orgs || orgs.length === 0) {
|
|
80
|
+
throw new Error("No organizations found.");
|
|
81
|
+
}
|
|
82
|
+
// Select organization
|
|
83
|
+
const selectedOrg = await promptOrganizationSelection(orgs);
|
|
84
|
+
// Select agent from organization
|
|
85
|
+
const selectedAgent = await promptAgentSelection(selectedOrg);
|
|
86
|
+
return { agent: selectedAgent, org: selectedOrg };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Handles the flow for creating a new agent.
|
|
90
|
+
*
|
|
91
|
+
* @param apiKey - User's API key
|
|
92
|
+
* @returns Created agent, organization, and optional persona/welcome message
|
|
93
|
+
*/
|
|
94
|
+
async function createNewAgentFlow(apiKey) {
|
|
95
|
+
// Fetch and select agent type
|
|
96
|
+
const agentTypes = await fetchAgentTypes(apiKey);
|
|
97
|
+
const selectedAgentType = selectBaseAgentType(agentTypes);
|
|
98
|
+
// Collect required metadata
|
|
99
|
+
let linesToClear = 1;
|
|
100
|
+
const metadata = selectedAgentType.requiredSubAgentMetadata?.length
|
|
101
|
+
? await promptMetadataCollection(selectedAgentType.requiredSubAgentMetadata)
|
|
102
|
+
: {};
|
|
103
|
+
// Configure features
|
|
104
|
+
const availableFeatures = Object.keys(selectedAgentType.features);
|
|
105
|
+
const features = availableFeatures.length > 0
|
|
106
|
+
? await promptFeatureConfiguration(selectedAgentType)
|
|
107
|
+
: {};
|
|
108
|
+
linesToClear += availableFeatures.length;
|
|
109
|
+
// Collect business configuration
|
|
110
|
+
const businessConfig = await promptBusinessConfiguration();
|
|
111
|
+
linesToClear += 5; // businessName, agentName, businessType, brandPersonality, brandTraits
|
|
112
|
+
// Clear all prompts
|
|
113
|
+
clearLinesIfNeeded(linesToClear);
|
|
114
|
+
// Create the agent
|
|
115
|
+
const result = await createNewAgent(apiKey, selectedAgentType, businessConfig, metadata, features);
|
|
116
|
+
return result;
|
|
117
|
+
}
|
package/dist/commands/push.d.ts
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Push Command
|
|
3
|
+
* Orchestrates pushing skill versions to the server
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Main push command - pushes a skill version to the server.
|
|
7
|
+
*
|
|
8
|
+
* This command performs the following steps:
|
|
9
|
+
* 1. Validates configuration has required fields
|
|
10
|
+
* 2. Prompts for user confirmation
|
|
11
|
+
* 3. Authenticates the user
|
|
12
|
+
* 4. Compiles the skill
|
|
13
|
+
* 5. Validates deploy.json matches configuration
|
|
14
|
+
* 6. Pushes version to server
|
|
15
|
+
*
|
|
16
|
+
* Use this command to:
|
|
17
|
+
* - Upload a new version of your skill
|
|
18
|
+
* - Make your skill available for testing in dev mode
|
|
19
|
+
* - Prepare your skill for deployment
|
|
20
|
+
*
|
|
21
|
+
* Note: This does NOT deploy to production. Use `lua deploy` for that.
|
|
22
|
+
*
|
|
23
|
+
* @returns Promise that resolves when push completes
|
|
24
|
+
*/
|
|
22
25
|
export declare function pushCommand(): Promise<void>;
|
package/dist/commands/push.js
CHANGED
|
@@ -1,115 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Push Command
|
|
3
|
+
* Orchestrates pushing skill versions to the server
|
|
4
|
+
*/
|
|
4
5
|
import { compileCommand } from './compile.js';
|
|
5
6
|
import { checkApiKey, loadApiKey } from '../services/auth.js';
|
|
6
|
-
import { ApiService } from '../services/api.js';
|
|
7
7
|
import { readSkillConfig } from '../utils/files.js';
|
|
8
|
-
import { withErrorHandling,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
success: false,
|
|
33
|
-
error: {
|
|
34
|
-
message: "Network error",
|
|
35
|
-
error: "Failed to connect to server",
|
|
36
|
-
statusCode: 500
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function readConfigVersion() {
|
|
42
|
-
const config = readSkillConfig();
|
|
43
|
-
return config?.skill?.version || null;
|
|
44
|
-
}
|
|
45
|
-
function readDeployJson() {
|
|
46
|
-
const deployPath = path.join(process.cwd(), '.lua', 'deploy.json');
|
|
47
|
-
if (!fs.existsSync(deployPath)) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
const deployContent = fs.readFileSync(deployPath, 'utf8');
|
|
51
|
-
return JSON.parse(deployContent);
|
|
52
|
-
}
|
|
8
|
+
import { withErrorHandling, writeProgress, writeSuccess } from '../utils/cli.js';
|
|
9
|
+
import { readDeployJson, confirmVersionPush, validatePushConfig, validateDeployData, } from '../utils/push-helpers.js';
|
|
10
|
+
import { pushVersion } from '../utils/push-api.js';
|
|
11
|
+
/**
|
|
12
|
+
* Main push command - pushes a skill version to the server.
|
|
13
|
+
*
|
|
14
|
+
* This command performs the following steps:
|
|
15
|
+
* 1. Validates configuration has required fields
|
|
16
|
+
* 2. Prompts for user confirmation
|
|
17
|
+
* 3. Authenticates the user
|
|
18
|
+
* 4. Compiles the skill
|
|
19
|
+
* 5. Validates deploy.json matches configuration
|
|
20
|
+
* 6. Pushes version to server
|
|
21
|
+
*
|
|
22
|
+
* Use this command to:
|
|
23
|
+
* - Upload a new version of your skill
|
|
24
|
+
* - Make your skill available for testing in dev mode
|
|
25
|
+
* - Prepare your skill for deployment
|
|
26
|
+
*
|
|
27
|
+
* Note: This does NOT deploy to production. Use `lua deploy` for that.
|
|
28
|
+
*
|
|
29
|
+
* @returns Promise that resolves when push completes
|
|
30
|
+
*/
|
|
53
31
|
export async function pushCommand() {
|
|
54
32
|
return withErrorHandling(async () => {
|
|
55
|
-
//
|
|
33
|
+
// Step 1: Validate configuration
|
|
56
34
|
const config = readSkillConfig();
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// Read version from config
|
|
62
|
-
const version = config.skill?.version;
|
|
63
|
-
if (!version) {
|
|
64
|
-
console.error("❌ No version found in skill configuration");
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
// Confirm with user
|
|
68
|
-
const { confirmed } = await inquirer.prompt([
|
|
69
|
-
{
|
|
70
|
-
type: "confirm",
|
|
71
|
-
name: "confirmed",
|
|
72
|
-
message: `Are you sure you want to push version ${version}?`,
|
|
73
|
-
default: false
|
|
74
|
-
}
|
|
75
|
-
]);
|
|
76
|
-
// Clear the confirmation prompt lines
|
|
77
|
-
clearPromptLines(2);
|
|
35
|
+
validatePushConfig(config);
|
|
36
|
+
const version = config.skill.version;
|
|
37
|
+
// Step 2: Confirm with user
|
|
38
|
+
const confirmed = await confirmVersionPush(version);
|
|
78
39
|
if (!confirmed) {
|
|
79
40
|
console.log("❌ Push cancelled.");
|
|
80
41
|
process.exit(0);
|
|
81
42
|
}
|
|
82
|
-
//
|
|
43
|
+
// Step 3: Authenticate
|
|
83
44
|
const apiKey = await loadApiKey();
|
|
84
45
|
if (!apiKey) {
|
|
85
46
|
console.error("❌ No API key found. Please run 'lua auth configure' to set up your API key.");
|
|
86
47
|
process.exit(1);
|
|
87
48
|
}
|
|
88
|
-
// Validate API key
|
|
89
49
|
const userData = await checkApiKey(apiKey);
|
|
90
50
|
writeProgress("✅ Authenticated");
|
|
91
|
-
// Compile the skill
|
|
51
|
+
// Step 4: Compile the skill
|
|
92
52
|
writeProgress("🔄 Compiling skill...");
|
|
93
53
|
await compileCommand();
|
|
94
|
-
//
|
|
54
|
+
// Step 5: Validate deploy data
|
|
95
55
|
const deployData = readDeployJson();
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// Verify version matches
|
|
101
|
-
if (deployData.version !== version) {
|
|
102
|
-
console.error(`❌ Version mismatch: config has ${version}, deploy.json has ${deployData.version}`);
|
|
103
|
-
process.exit(1);
|
|
104
|
-
}
|
|
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");
|
|
110
|
-
process.exit(1);
|
|
111
|
-
}
|
|
112
|
-
// Push version
|
|
56
|
+
validateDeployData(deployData, version);
|
|
57
|
+
// Step 6: Push version to server
|
|
58
|
+
const agentId = config.agent.agentId;
|
|
59
|
+
const skillId = config.skill.skillId;
|
|
113
60
|
writeProgress("🔄 Pushing version to server...");
|
|
114
61
|
const result = await pushVersion(apiKey, agentId, skillId, deployData);
|
|
115
62
|
if (result.success && result.data) {
|
package/dist/commands/test.d.ts
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test Command
|
|
3
|
+
* Orchestrates the testing of individual tools in a local sandbox environment
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Main test command - tests a tool in a local sandbox environment.
|
|
7
|
+
*
|
|
8
|
+
* This command performs the following steps:
|
|
9
|
+
* 1. Compiles the skill to ensure latest code
|
|
10
|
+
* 2. Loads deploy.json with tool definitions
|
|
11
|
+
* 3. Extracts all available tools
|
|
12
|
+
* 4. Prompts user to select a tool
|
|
13
|
+
* 5. Collects input values based on tool's input schema
|
|
14
|
+
* 6. Executes the tool in a sandboxed environment
|
|
15
|
+
* 7. Displays the results
|
|
16
|
+
*
|
|
17
|
+
* Features:
|
|
18
|
+
* - Interactive tool selection from compiled tools
|
|
19
|
+
* - Dynamic input prompts based on tool schemas
|
|
20
|
+
* - Support for nested object inputs
|
|
21
|
+
* - Environment variable injection
|
|
22
|
+
* - Secure sandbox execution
|
|
23
|
+
* - Detailed error reporting
|
|
24
|
+
*
|
|
25
|
+
* @returns Promise that resolves when test completes
|
|
26
|
+
*/
|
|
1
27
|
export declare function testCommand(): Promise<void>;
|