lua-cli 3.0.0-alpha.1 ā 3.0.0-alpha.10
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/chat.api.service.d.ts +8 -0
- package/dist/api/chat.api.service.js +50 -0
- package/dist/api/job.api.service.d.ts +16 -7
- package/dist/api/job.api.service.js +21 -5
- package/dist/api/postprocessor.api.service.d.ts +61 -1
- package/dist/api/postprocessor.api.service.js +35 -0
- package/dist/api/preprocessor.api.service.d.ts +61 -1
- package/dist/api/preprocessor.api.service.js +35 -0
- package/dist/api-exports.d.ts +26 -6
- package/dist/api-exports.js +42 -29
- package/dist/cli/command-definitions.js +13 -6
- package/dist/commands/chat.js +73 -36
- package/dist/commands/compile.js +16 -2
- package/dist/commands/dev.js +23 -2
- package/dist/commands/push.d.ts +3 -2
- package/dist/commands/push.js +536 -6
- package/dist/commands/test.js +18 -2
- package/dist/common/job.instance.d.ts +3 -0
- package/dist/common/job.instance.js +8 -0
- package/dist/config/constants.d.ts +6 -5
- package/dist/config/constants.js +12 -10
- package/dist/interfaces/chat.d.ts +30 -1
- package/dist/interfaces/jobs.d.ts +21 -0
- package/dist/services/auth.d.ts +8 -2
- package/dist/services/auth.js +35 -3
- package/dist/types/skill.d.ts +75 -56
- package/dist/types/skill.js +53 -59
- package/dist/utils/bundling.d.ts +13 -4
- package/dist/utils/bundling.js +83 -26
- package/dist/utils/compile.js +27 -6
- package/dist/utils/dev-api.d.ts +42 -2
- package/dist/utils/dev-api.js +177 -4
- package/dist/utils/dev-server.d.ts +1 -1
- package/dist/utils/dev-server.js +4 -4
- package/dist/utils/dynamic-job-bundler.d.ts +17 -0
- package/dist/utils/dynamic-job-bundler.js +143 -0
- package/dist/utils/pre-bundle-jobs.d.ts +26 -0
- package/dist/utils/pre-bundle-jobs.js +176 -0
- package/dist/utils/sandbox-storage.d.ts +48 -0
- package/dist/utils/sandbox-storage.js +114 -0
- package/dist/utils/sandbox.d.ts +2 -2
- package/dist/utils/sandbox.js +23 -7
- package/package.json +1 -1
- package/template/env.example +5 -0
- package/template/lua.skill.yaml +47 -0
- package/template/package-lock.json +10505 -0
- package/template/package.json +2 -1
- package/template/src/index.ts +65 -3
- package/template/src/tools/CreateInlineJob.ts +42 -0
- package/API_REFERENCE.md +0 -1408
- package/CHANGELOG.md +0 -236
- package/CLI_REFERENCE.md +0 -908
- package/GETTING_STARTED.md +0 -1040
- package/INSTANCE_TYPES.md +0 -1158
- package/README.md +0 -865
- package/TEMPLATE_GUIDE.md +0 -1398
- package/USER_DATA_INSTANCE.md +0 -621
- package/template/AGENT_CONFIGURATION.md +0 -251
- package/template/COMPLEX_JOB_EXAMPLES.md +0 -795
- package/template/DYNAMIC_JOB_CREATION.md +0 -371
- package/template/TOOL_EXAMPLES.md +0 -655
- package/template/WEBHOOKS_JOBS_QUICKSTART.md +0 -318
- package/template/WEBHOOK_JOB_EXAMPLES.md +0 -817
- package/template/src/index-agent-example.ts +0 -201
- package/template/src/postprocessors/ResponseFormatter.ts +0 -151
- package/template/src/preprocessors/MessageFilter.ts +0 -91
package/dist/commands/chat.js
CHANGED
|
@@ -8,8 +8,8 @@ import { loadApiKey, checkApiKey } from '../services/auth.js';
|
|
|
8
8
|
import { readSkillConfig } from '../utils/files.js';
|
|
9
9
|
import { withErrorHandling, writeProgress, writeSuccess } from '../utils/cli.js';
|
|
10
10
|
import { compileCommand } from './compile.js';
|
|
11
|
-
import { pushSkillsToSandbox } from '../utils/dev-api.js';
|
|
12
|
-
import { getAllSandboxSkillIds } from '../utils/sandbox-storage.js';
|
|
11
|
+
import { pushSkillsToSandbox, pushProcessorsToSandbox } from '../utils/dev-api.js';
|
|
12
|
+
import { getAllSandboxSkillIds, getAllSandboxPreProcessorIds, getAllSandboxPostProcessorIds } from '../utils/sandbox-storage.js';
|
|
13
13
|
import ChatApi from '../api/chat.api.service.js';
|
|
14
14
|
import { BASE_URLS } from '../config/constants.js';
|
|
15
15
|
import { readDeployJson, validateConfig, validateDeployData, validateAgentConfig, } from '../utils/dev-helpers.js';
|
|
@@ -66,7 +66,7 @@ export async function chatCommand() {
|
|
|
66
66
|
}, "chat");
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* Sets up the sandbox environment by compiling and pushing skills
|
|
69
|
+
* Sets up the sandbox environment by compiling and pushing skills, preprocessors, and postprocessors
|
|
70
70
|
*/
|
|
71
71
|
async function setupSandboxEnvironment(chatEnv, config) {
|
|
72
72
|
writeProgress("š Setting up sandbox environment...");
|
|
@@ -84,8 +84,31 @@ async function setupSandboxEnvironment(chatEnv, config) {
|
|
|
84
84
|
process.exit(1);
|
|
85
85
|
}
|
|
86
86
|
writeSuccess(`ā
Pushed ${Object.keys(sandboxIds).length} skills to sandbox`);
|
|
87
|
+
// Push preprocessors and postprocessors to sandbox
|
|
88
|
+
const fs = await import('fs');
|
|
89
|
+
const path = await import('path');
|
|
90
|
+
const preprocessorsPath = path.join(process.cwd(), 'dist', 'preprocessors.json');
|
|
91
|
+
const postprocessorsPath = path.join(process.cwd(), 'dist', 'postprocessors.json');
|
|
92
|
+
let bundledPreProcessors = [];
|
|
93
|
+
let bundledPostProcessors = [];
|
|
94
|
+
if (fs.existsSync(preprocessorsPath)) {
|
|
95
|
+
bundledPreProcessors = JSON.parse(fs.readFileSync(preprocessorsPath, 'utf8'));
|
|
96
|
+
}
|
|
97
|
+
if (fs.existsSync(postprocessorsPath)) {
|
|
98
|
+
bundledPostProcessors = JSON.parse(fs.readFileSync(postprocessorsPath, 'utf8'));
|
|
99
|
+
}
|
|
100
|
+
if (bundledPreProcessors.length > 0 || bundledPostProcessors.length > 0) {
|
|
101
|
+
writeProgress("š Pushing processors to sandbox...");
|
|
102
|
+
const processorCounts = await pushProcessorsToSandbox(chatEnv.apiKey, chatEnv.agentId, config, bundledPreProcessors, bundledPostProcessors, true);
|
|
103
|
+
if (processorCounts.preprocessors > 0 || processorCounts.postprocessors > 0) {
|
|
104
|
+
writeSuccess(`ā
Pushed ${processorCounts.preprocessors} preprocessor(s) and ${processorCounts.postprocessors} postprocessor(s) to sandbox`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
87
107
|
// Store deploy data for skill overrides
|
|
88
108
|
chatEnv.deployData = deployData;
|
|
109
|
+
// Get processor overrides for sandbox
|
|
110
|
+
chatEnv.preprocessorOverrides = await getAllSandboxPreProcessorIds(config);
|
|
111
|
+
chatEnv.postprocessorOverrides = await getAllSandboxPostProcessorIds(config);
|
|
89
112
|
// Check for persona in config
|
|
90
113
|
if (config.agent?.persona) {
|
|
91
114
|
chatEnv.persona = config.agent.persona;
|
|
@@ -100,8 +123,10 @@ async function startChatLoop(chatEnv) {
|
|
|
100
123
|
console.log(`Environment: ${chatEnv.type === 'sandbox' ? 'š§ Sandbox' : 'š Production'}`);
|
|
101
124
|
console.log("Press Ctrl+C to exit");
|
|
102
125
|
console.log("=".repeat(60) + "\n");
|
|
103
|
-
// Welcome message
|
|
104
|
-
|
|
126
|
+
// Welcome message from config or default
|
|
127
|
+
const config = readSkillConfig();
|
|
128
|
+
const welcomeMessage = config?.agent?.welcomeMessage || "Hi there! How can I help you today?";
|
|
129
|
+
console.log(`š Assistant: ${welcomeMessage}\n`);
|
|
105
130
|
// Create readline interface
|
|
106
131
|
const rl = readline.createInterface({
|
|
107
132
|
input: process.stdin,
|
|
@@ -124,25 +149,19 @@ async function startChatLoop(chatEnv) {
|
|
|
124
149
|
return;
|
|
125
150
|
}
|
|
126
151
|
try {
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
let
|
|
152
|
+
// Start showing the assistant response
|
|
153
|
+
process.stdout.write('š Assistant: ');
|
|
154
|
+
let fullResponse = '';
|
|
130
155
|
if (chatEnv.type === 'sandbox') {
|
|
131
|
-
// Send to sandbox with skill overrides
|
|
132
|
-
|
|
156
|
+
// Send to sandbox with skill overrides (streaming)
|
|
157
|
+
fullResponse = await sendSandboxMessageStream(chatEnv, message);
|
|
133
158
|
}
|
|
134
159
|
else {
|
|
135
|
-
// Send to production
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
// Stop typing indicator
|
|
139
|
-
stopTypingIndicator(typingInterval);
|
|
140
|
-
if (response) {
|
|
141
|
-
console.log(`š Assistant: ${response}\n`);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
console.log("š Assistant: ā Failed to get response. Please try again.\n");
|
|
160
|
+
// Send to production (streaming)
|
|
161
|
+
fullResponse = await sendProductionMessageStream(chatEnv, message);
|
|
145
162
|
}
|
|
163
|
+
// Add newline after response
|
|
164
|
+
console.log('\n');
|
|
146
165
|
}
|
|
147
166
|
catch (error) {
|
|
148
167
|
console.error(`\nā Error: ${error instanceof Error ? error.message : 'Unknown error'}\n`);
|
|
@@ -179,9 +198,9 @@ function stopTypingIndicator(interval) {
|
|
|
179
198
|
process.stdout.write('\r\x1b[K');
|
|
180
199
|
}
|
|
181
200
|
/**
|
|
182
|
-
* Sends a message to the sandbox environment with skill overrides
|
|
201
|
+
* Sends a message to the sandbox environment with skill overrides (streaming)
|
|
183
202
|
*/
|
|
184
|
-
async function
|
|
203
|
+
async function sendSandboxMessageStream(chatEnv, message) {
|
|
185
204
|
if (!chatEnv.deployData) {
|
|
186
205
|
return "ā Sandbox environment not properly initialized.";
|
|
187
206
|
}
|
|
@@ -198,24 +217,33 @@ async function sendSandboxMessage(chatEnv, message) {
|
|
|
198
217
|
}
|
|
199
218
|
],
|
|
200
219
|
navigate: true,
|
|
201
|
-
skillOverride: allSkillOverrides
|
|
220
|
+
skillOverride: allSkillOverrides,
|
|
221
|
+
preprocessorOverride: chatEnv.preprocessorOverrides || [],
|
|
222
|
+
postprocessorOverride: chatEnv.postprocessorOverrides || []
|
|
202
223
|
};
|
|
203
224
|
// Add persona override if available
|
|
204
225
|
if (chatEnv.persona) {
|
|
205
226
|
chatRequest.personaOverride = chatEnv.persona;
|
|
206
227
|
}
|
|
207
228
|
const chatApi = new ChatApi(BASE_URLS.CHAT, chatEnv.apiKey);
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
229
|
+
let fullResponse = '';
|
|
230
|
+
try {
|
|
231
|
+
await chatApi.sendMessageStream(chatEnv.agentId, chatRequest, (chunk) => {
|
|
232
|
+
// Write each chunk to stdout as it arrives
|
|
233
|
+
process.stdout.write(chunk);
|
|
234
|
+
fullResponse += chunk;
|
|
235
|
+
});
|
|
236
|
+
return fullResponse;
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
console.error(`\nā Chat API error: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
240
|
+
return '';
|
|
212
241
|
}
|
|
213
|
-
return response.data?.text || null;
|
|
214
242
|
}
|
|
215
243
|
/**
|
|
216
|
-
* Sends a message to the production environment
|
|
244
|
+
* Sends a message to the production environment (streaming)
|
|
217
245
|
*/
|
|
218
|
-
async function
|
|
246
|
+
async function sendProductionMessageStream(chatEnv, message) {
|
|
219
247
|
const chatRequest = {
|
|
220
248
|
messages: [
|
|
221
249
|
{
|
|
@@ -224,13 +252,22 @@ async function sendProductionMessage(chatEnv, message) {
|
|
|
224
252
|
}
|
|
225
253
|
],
|
|
226
254
|
navigate: true,
|
|
227
|
-
skillOverride: []
|
|
255
|
+
skillOverride: [],
|
|
256
|
+
preprocessorOverride: [],
|
|
257
|
+
postprocessorOverride: []
|
|
228
258
|
};
|
|
229
259
|
const chatApi = new ChatApi(BASE_URLS.CHAT, chatEnv.apiKey);
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
260
|
+
let fullResponse = '';
|
|
261
|
+
try {
|
|
262
|
+
await chatApi.sendMessageStream(chatEnv.agentId, chatRequest, (chunk) => {
|
|
263
|
+
// Write each chunk to stdout as it arrives
|
|
264
|
+
process.stdout.write(chunk);
|
|
265
|
+
fullResponse += chunk;
|
|
266
|
+
});
|
|
267
|
+
return fullResponse;
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
console.error(`\nā Chat API error: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
271
|
+
return '';
|
|
234
272
|
}
|
|
235
|
-
return response.data?.text || null;
|
|
236
273
|
}
|
package/dist/commands/compile.js
CHANGED
|
@@ -78,9 +78,23 @@ export async function compileCommand() {
|
|
|
78
78
|
const tools = await detectTools(indexFile, project, skillFilePaths);
|
|
79
79
|
writeProgress(`š¦ Found ${tools.length} tools to bundle...`);
|
|
80
80
|
// Step 3: Bundle each tool and extract metadata
|
|
81
|
+
const { preBundleJobsInSource, replaceJobPlaceholders } = await import('../utils/pre-bundle-jobs.js');
|
|
81
82
|
for (const tool of tools) {
|
|
82
|
-
|
|
83
|
-
await
|
|
83
|
+
// Step 3a: Pre-bundle any Jobs.create() in the tool source
|
|
84
|
+
const { modifiedSource, jobBundles } = await preBundleJobsInSource(tool.filePath, project, distDir);
|
|
85
|
+
// Step 3b: Bundle the tool (with placeholders for job execute functions)
|
|
86
|
+
await bundleTool(tool, distDir, modifiedSource);
|
|
87
|
+
// Step 3c: Replace placeholders in the bundled tool file
|
|
88
|
+
if (jobBundles.size > 0) {
|
|
89
|
+
const toolBundlePath = path.join(distDir, 'tools', `${tool.className}.js`);
|
|
90
|
+
if (fs.existsSync(toolBundlePath)) {
|
|
91
|
+
let bundledToolCode = fs.readFileSync(toolBundlePath, 'utf8');
|
|
92
|
+
bundledToolCode = replaceJobPlaceholders(bundledToolCode, jobBundles);
|
|
93
|
+
fs.writeFileSync(toolBundlePath, bundledToolCode);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Step 3d: Extract execute code
|
|
97
|
+
await extractExecuteCode(tool, project, distDir);
|
|
84
98
|
}
|
|
85
99
|
// Step 4: Bundle the main index file
|
|
86
100
|
await bundleMainIndex(indexPath, distDir);
|
package/dist/commands/dev.js
CHANGED
|
@@ -7,7 +7,7 @@ import { compileCommand } from './compile.js';
|
|
|
7
7
|
import { checkApiKey, loadApiKey } from '../services/auth.js';
|
|
8
8
|
import { readSkillConfig } from '../utils/files.js';
|
|
9
9
|
import { withErrorHandling, writeProgress, writeSuccess } from '../utils/cli.js';
|
|
10
|
-
import { pushSkillsToSandbox } from '../utils/dev-api.js';
|
|
10
|
+
import { pushSkillsToSandbox, pushProcessorsToSandbox } from '../utils/dev-api.js';
|
|
11
11
|
import { createChatServer } from '../utils/dev-server.js';
|
|
12
12
|
import { createFileWatcher } from '../utils/dev-watcher.js';
|
|
13
13
|
import { readConfigVersion, readDeployJson, extractSkillId, validateConfig, validateDeployData, validateAgentConfig, } from '../utils/dev-helpers.js';
|
|
@@ -75,6 +75,26 @@ export async function devCommand() {
|
|
|
75
75
|
process.exit(1);
|
|
76
76
|
}
|
|
77
77
|
writeSuccess(`ā
Pushed ${Object.keys(sandboxIds).length} skills to sandbox`);
|
|
78
|
+
// Step 6b: Push preprocessors and postprocessors to sandbox
|
|
79
|
+
const fs = await import('fs');
|
|
80
|
+
const path = await import('path');
|
|
81
|
+
const preprocessorsPath = path.join(process.cwd(), 'dist', 'preprocessors.json');
|
|
82
|
+
const postprocessorsPath = path.join(process.cwd(), 'dist', 'postprocessors.json');
|
|
83
|
+
let bundledPreProcessors = [];
|
|
84
|
+
let bundledPostProcessors = [];
|
|
85
|
+
if (fs.existsSync(preprocessorsPath)) {
|
|
86
|
+
bundledPreProcessors = JSON.parse(fs.readFileSync(preprocessorsPath, 'utf8'));
|
|
87
|
+
}
|
|
88
|
+
if (fs.existsSync(postprocessorsPath)) {
|
|
89
|
+
bundledPostProcessors = JSON.parse(fs.readFileSync(postprocessorsPath, 'utf8'));
|
|
90
|
+
}
|
|
91
|
+
if (bundledPreProcessors.length > 0 || bundledPostProcessors.length > 0) {
|
|
92
|
+
writeProgress("š Pushing processors to sandbox...");
|
|
93
|
+
const processorCounts = await pushProcessorsToSandbox(apiKey, agentId, updatedConfig, bundledPreProcessors, bundledPostProcessors, true);
|
|
94
|
+
if (processorCounts.preprocessors > 0 || processorCounts.postprocessors > 0) {
|
|
95
|
+
writeSuccess(`ā
Pushed ${processorCounts.preprocessors} preprocessor(s) and ${processorCounts.postprocessors} postprocessor(s) to sandbox`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
78
98
|
// Use the first skill's sandbox ID for the web interface
|
|
79
99
|
const firstSkillName = Object.keys(sandboxIds)[0];
|
|
80
100
|
const sandboxSkillId = sandboxIds[firstSkillName];
|
|
@@ -83,7 +103,8 @@ export async function devCommand() {
|
|
|
83
103
|
process.exit(1);
|
|
84
104
|
}
|
|
85
105
|
// Step 7: Start web server for chat interface
|
|
86
|
-
const { server, wss, broadcastLog } = createChatServer(apiKey, agentId, skillId, sandboxSkillId, DEV_SERVER_PORT
|
|
106
|
+
const { server, wss, broadcastLog } = createChatServer(apiKey, agentId, skillId, sandboxSkillId, DEV_SERVER_PORT, updatedConfig // Pass config for processor overrides
|
|
107
|
+
);
|
|
87
108
|
// Step 8: Open browser to chat interface
|
|
88
109
|
try {
|
|
89
110
|
await open(`http://localhost:${DEV_SERVER_PORT}`);
|
package/dist/commands/push.d.ts
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
*
|
|
18
18
|
* Note: This does NOT deploy to production. Use `lua deploy` for that.
|
|
19
19
|
*
|
|
20
|
-
* @param type - Optional type argument ('skill' or '
|
|
20
|
+
* @param type - Optional type argument ('skill', 'persona', 'webhook', 'job', 'preprocessor', 'postprocessor', or 'all')
|
|
21
|
+
* @param cmdObj - Commander command object with options
|
|
21
22
|
* @returns Promise that resolves when push completes
|
|
22
23
|
*/
|
|
23
|
-
export declare function pushCommand(type?: string): Promise<void>;
|
|
24
|
+
export declare function pushCommand(type?: string, cmdObj?: any): Promise<void>;
|