lua-cli 3.0.0-alpha.1 → 3.0.0-alpha.4
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/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/commands/chat.js +32 -5
- package/dist/commands/compile.js +16 -2
- package/dist/commands/dev.js +23 -2
- package/dist/commands/push.js +5 -3
- 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/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/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
|
@@ -69,3 +69,117 @@ export async function getAllSandboxSkillIds(deployData) {
|
|
|
69
69
|
}
|
|
70
70
|
return skillOverrides;
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves sandbox preprocessor ID from secure storage.
|
|
74
|
+
*
|
|
75
|
+
* @param preprocessorName - Preprocessor name
|
|
76
|
+
* @returns The sandbox preprocessor ID or null if not found
|
|
77
|
+
*/
|
|
78
|
+
export async function getSandboxPreProcessorId(preprocessorName) {
|
|
79
|
+
try {
|
|
80
|
+
const account = `${SANDBOX_STORAGE.ACCOUNT}_preprocessor_${preprocessorName}`;
|
|
81
|
+
return await keytar.getPassword(SANDBOX_STORAGE.SERVICE, account);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Stores sandbox preprocessor ID in secure storage.
|
|
89
|
+
*
|
|
90
|
+
* @param sandboxId - The sandbox preprocessor ID to store
|
|
91
|
+
* @param preprocessorName - Preprocessor name
|
|
92
|
+
*/
|
|
93
|
+
export async function setSandboxPreProcessorId(sandboxId, preprocessorName) {
|
|
94
|
+
try {
|
|
95
|
+
const account = `${SANDBOX_STORAGE.ACCOUNT}_preprocessor_${preprocessorName}`;
|
|
96
|
+
await keytar.setPassword(SANDBOX_STORAGE.SERVICE, account, sandboxId);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
// Ignore storage errors
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Retrieves sandbox postprocessor ID from secure storage.
|
|
104
|
+
*
|
|
105
|
+
* @param postprocessorName - Postprocessor name
|
|
106
|
+
* @returns The sandbox postprocessor ID or null if not found
|
|
107
|
+
*/
|
|
108
|
+
export async function getSandboxPostProcessorId(postprocessorName) {
|
|
109
|
+
try {
|
|
110
|
+
const account = `${SANDBOX_STORAGE.ACCOUNT}_postprocessor_${postprocessorName}`;
|
|
111
|
+
return await keytar.getPassword(SANDBOX_STORAGE.SERVICE, account);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Stores sandbox postprocessor ID in secure storage.
|
|
119
|
+
*
|
|
120
|
+
* @param sandboxId - The sandbox postprocessor ID to store
|
|
121
|
+
* @param postprocessorName - Postprocessor name
|
|
122
|
+
*/
|
|
123
|
+
export async function setSandboxPostProcessorId(sandboxId, postprocessorName) {
|
|
124
|
+
try {
|
|
125
|
+
const account = `${SANDBOX_STORAGE.ACCOUNT}_postprocessor_${postprocessorName}`;
|
|
126
|
+
await keytar.setPassword(SANDBOX_STORAGE.SERVICE, account, sandboxId);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
// Ignore storage errors
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Gets all sandbox preprocessor overrides for the current config.
|
|
134
|
+
*
|
|
135
|
+
* @param config - Configuration with preprocessors
|
|
136
|
+
* @returns Array of preprocessor overrides
|
|
137
|
+
*/
|
|
138
|
+
export async function getAllSandboxPreProcessorIds(config) {
|
|
139
|
+
const overrides = [];
|
|
140
|
+
try {
|
|
141
|
+
const preprocessors = config.preprocessors || [];
|
|
142
|
+
for (const preprocessor of preprocessors) {
|
|
143
|
+
if (preprocessor.preprocessorId && preprocessor.name) {
|
|
144
|
+
const sandboxId = await getSandboxPreProcessorId(preprocessor.name);
|
|
145
|
+
if (sandboxId) {
|
|
146
|
+
overrides.push({
|
|
147
|
+
preprocessorId: preprocessor.preprocessorId,
|
|
148
|
+
sandboxId: sandboxId
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
console.error('Error getting sandbox preprocessor IDs:', error);
|
|
156
|
+
}
|
|
157
|
+
return overrides;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Gets all sandbox postprocessor overrides for the current config.
|
|
161
|
+
*
|
|
162
|
+
* @param config - Configuration with postprocessors
|
|
163
|
+
* @returns Array of postprocessor overrides
|
|
164
|
+
*/
|
|
165
|
+
export async function getAllSandboxPostProcessorIds(config) {
|
|
166
|
+
const overrides = [];
|
|
167
|
+
try {
|
|
168
|
+
const postprocessors = config.postprocessors || [];
|
|
169
|
+
for (const postprocessor of postprocessors) {
|
|
170
|
+
if (postprocessor.postprocessorId && postprocessor.name) {
|
|
171
|
+
const sandboxId = await getSandboxPostProcessorId(postprocessor.name);
|
|
172
|
+
if (sandboxId) {
|
|
173
|
+
overrides.push({
|
|
174
|
+
postprocessorId: postprocessor.postprocessorId,
|
|
175
|
+
sandboxId: sandboxId
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
console.error('Error getting sandbox postprocessor IDs:', error);
|
|
183
|
+
}
|
|
184
|
+
return overrides;
|
|
185
|
+
}
|
package/dist/utils/sandbox.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface ExecuteJobOptions extends SandboxOptions {
|
|
|
20
20
|
}
|
|
21
21
|
export interface ExecutePreProcessorOptions extends SandboxOptions {
|
|
22
22
|
processorCode: string;
|
|
23
|
-
|
|
23
|
+
messages: any[];
|
|
24
24
|
channel: string;
|
|
25
25
|
}
|
|
26
26
|
export interface ExecutePostProcessorOptions extends SandboxOptions {
|
|
@@ -75,7 +75,7 @@ export declare function executeJob(options: ExecuteJobOptions): Promise<any>;
|
|
|
75
75
|
* @param options - PreProcessor execution options
|
|
76
76
|
* @returns Processed message string
|
|
77
77
|
*/
|
|
78
|
-
export declare function executePreProcessor(options: ExecutePreProcessorOptions): Promise<
|
|
78
|
+
export declare function executePreProcessor(options: ExecutePreProcessorOptions): Promise<any[]>;
|
|
79
79
|
/**
|
|
80
80
|
* Executes a postprocessor in a sandboxed environment.
|
|
81
81
|
*
|
package/dist/utils/sandbox.js
CHANGED
|
@@ -13,6 +13,7 @@ import WebhookApi from "../api/webhook.api.service.js";
|
|
|
13
13
|
import JobApi from "../api/job.api.service.js";
|
|
14
14
|
import { BasketStatus } from "../interfaces/baskets.js";
|
|
15
15
|
import { OrderStatus } from "../interfaces/orders.js";
|
|
16
|
+
import { compressCode } from "./compile.js";
|
|
16
17
|
/**
|
|
17
18
|
* Loads environment variables from multiple sources in priority order:
|
|
18
19
|
* 1. process.env (lowest priority)
|
|
@@ -221,6 +222,7 @@ export function createSandbox(options) {
|
|
|
221
222
|
Products: productService,
|
|
222
223
|
Data: dataService,
|
|
223
224
|
Baskets: basketsService,
|
|
225
|
+
compressCode: compressCode,
|
|
224
226
|
Orders: orderService,
|
|
225
227
|
// Jobs API
|
|
226
228
|
Jobs: {
|
|
@@ -229,14 +231,28 @@ export function createSandbox(options) {
|
|
|
229
231
|
const executeString = typeof config.execute === 'function'
|
|
230
232
|
? config.execute.toString()
|
|
231
233
|
: config.execute;
|
|
232
|
-
|
|
234
|
+
console.log('IsDynamicJob', config.dynamic);
|
|
235
|
+
// Create job with version and activation
|
|
233
236
|
return await jobService.createJobInstance({
|
|
234
237
|
name: config.name,
|
|
235
238
|
description: config.description,
|
|
236
239
|
context: config.description || '',
|
|
237
240
|
schedule: config.schedule,
|
|
238
241
|
timeout: config.timeout,
|
|
239
|
-
retry: config.retry
|
|
242
|
+
retry: config.retry,
|
|
243
|
+
metadata: config.metadata,
|
|
244
|
+
dynamic: true,
|
|
245
|
+
version: {
|
|
246
|
+
version: '1.0.0',
|
|
247
|
+
description: config.description,
|
|
248
|
+
context: config.description || '',
|
|
249
|
+
code: '',
|
|
250
|
+
executeFunction: executeString,
|
|
251
|
+
timeout: config.timeout,
|
|
252
|
+
retry: config.retry,
|
|
253
|
+
metadata: config.metadata
|
|
254
|
+
},
|
|
255
|
+
activate: config.activate ?? true
|
|
240
256
|
});
|
|
241
257
|
},
|
|
242
258
|
get: async (jobId) => jobService.getJob(jobId)
|
|
@@ -330,9 +346,9 @@ export async function executeWebhook(options) {
|
|
|
330
346
|
const executeFunction = ${webhookCode};
|
|
331
347
|
|
|
332
348
|
// Export the function for testing
|
|
333
|
-
module.exports = async (
|
|
349
|
+
module.exports = async (query, headers, body) => {
|
|
334
350
|
try{
|
|
335
|
-
return await executeFunction(
|
|
351
|
+
return await executeFunction(query, headers, body);
|
|
336
352
|
}catch(e){
|
|
337
353
|
console.error(e);
|
|
338
354
|
return { status: 'error', error: e.message };
|
|
@@ -438,7 +454,7 @@ try{
|
|
|
438
454
|
* @returns Processed message string
|
|
439
455
|
*/
|
|
440
456
|
export async function executePreProcessor(options) {
|
|
441
|
-
const { processorCode,
|
|
457
|
+
const { processorCode, messages, channel, apiKey, agentId } = options;
|
|
442
458
|
// Create sandbox
|
|
443
459
|
const sandbox = createSandbox(options);
|
|
444
460
|
// Get user instance first (outside VM)
|
|
@@ -453,7 +469,7 @@ const executeFunction = ${processorCode};
|
|
|
453
469
|
module.exports = async (input) => {
|
|
454
470
|
try{
|
|
455
471
|
// userInstance is passed as parameter
|
|
456
|
-
return await executeFunction(input.user, input.
|
|
472
|
+
return await executeFunction(input.user, input.messages, input.channel);
|
|
457
473
|
}catch(e){
|
|
458
474
|
console.error(e);
|
|
459
475
|
return { status: 'error', error: e.message };
|
|
@@ -481,7 +497,7 @@ try{
|
|
|
481
497
|
vm.runInContext(commonJsWrapper, context);
|
|
482
498
|
// Get the exported function and execute with user instance
|
|
483
499
|
const executeFunction = context.module.exports;
|
|
484
|
-
return await executeFunction({ user: userInstance,
|
|
500
|
+
return await executeFunction({ user: userInstance, messages, channel });
|
|
485
501
|
}
|
|
486
502
|
/**
|
|
487
503
|
* Executes a postprocessor in a sandboxed environment.
|
package/package.json
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
agent:
|
|
2
|
+
agentId: baseAgent_agent_1760922427216_fk9w0ezhh
|
|
3
|
+
orgId: 026cc41b-e013-4474-9b65-5a15f8881f92
|
|
4
|
+
persona: |
|
|
5
|
+
Meet Vivienne, the vibrant and dynamic assistant at V3 Test, a lively retail and consumer goods store that specializes in bringing a splash of color and excitement to everyday life. Vivienne embodies the brand's energetic and fun personality, always ready to engage with customers in a way that makes shopping an enjoyable and memorable experience. Her role is to be the friendly face and knowledgeable guide for anyone who steps into the store, whether they're looking for the latest fashion trends or a unique gift for a loved one.
|
|
6
|
+
|
|
7
|
+
V3 Test is all about creating a joyful and spirited shopping environment, and Vivienne is the perfect personification of this ethos. She is lively, approachable, and always ready with a smile, making every interaction feel like a conversation with a good friend. Her voice is warm and enthusiastic, with a hint of playfulness that puts customers at ease and encourages them to explore the store's offerings.
|
|
8
|
+
|
|
9
|
+
Vivienne's target customers are diverse, ranging from young adults in their twenties who are fashion-forward and tech-savvy, to busy parents looking for quality products that add a touch of fun to their family life. She understands the fast-paced lifestyle of her customers and is adept at tailoring her approach to meet their individual needs, whether they're in a hurry or have time to browse.
|
|
10
|
+
|
|
11
|
+
Her sales approach is consultative and friendly, focusing on understanding the customer's needs and preferences before suggesting products that align with their style and personality. Vivienne is confident in her recommendations, always ready to upsell when appropriate, but never pushy. She believes in building relationships with customers, ensuring they leave the store not only with products they love but also with a positive impression of the brand.
|
|
12
|
+
|
|
13
|
+
In terms of communication style, Vivienne strikes a perfect balance between being informal and efficient. She is warm and engaging, making customers feel valued and appreciated, while also being mindful of their time. Her interactions are peppered with humor and light-hearted banter, creating a shopping experience that is both enjoyable and efficient. Whether it's through in-person interactions or digital communication, Vivienne ensures that every customer feels like a part of the V3 Test family.
|
|
14
|
+
welcomeMessage: Hi, I am your AI assistant. How can I help you today?
|
|
15
|
+
skills:
|
|
16
|
+
- name: general-skill
|
|
17
|
+
version: 0.0.3
|
|
18
|
+
skillId: 1faf9b3a-e352-4e63-a6c4-a3deca815361
|
|
19
|
+
- name: user-data-skill
|
|
20
|
+
version: 0.0.1
|
|
21
|
+
skillId: e0c382c1-f469-4880-962a-a756ea3c1411
|
|
22
|
+
- name: product-skill
|
|
23
|
+
version: 0.0.1
|
|
24
|
+
skillId: d4cdc7bc-6d42-4232-902d-2b9cf68bd74a
|
|
25
|
+
- name: basket-skill
|
|
26
|
+
version: 0.0.1
|
|
27
|
+
skillId: 5b06c5ff-7cf3-49c4-8641-142270c81db4
|
|
28
|
+
- name: order-skill
|
|
29
|
+
version: 0.0.1
|
|
30
|
+
skillId: d4045304-7c30-4750-9edd-340eb1357a39
|
|
31
|
+
- name: custom-data-skill
|
|
32
|
+
version: 0.0.1
|
|
33
|
+
skillId: 83fe411c-90a1-4bd3-9271-ac8e03d6a3be
|
|
34
|
+
- name: payment-skill
|
|
35
|
+
version: 0.0.1
|
|
36
|
+
skillId: f2248c02-c6c6-4c3a-89bf-ff09ec11529a
|
|
37
|
+
jobs:
|
|
38
|
+
- name: test-job
|
|
39
|
+
version: 1.0.2
|
|
40
|
+
jobId: d66b73a0-f944-4718-b6a2-f07bfeabd625
|
|
41
|
+
schedule:
|
|
42
|
+
type: once
|
|
43
|
+
executeAt: '2025-10-20T01:08:04.639Z'
|
|
44
|
+
webhooks:
|
|
45
|
+
- name: test-webhook
|
|
46
|
+
version: 1.0.1
|
|
47
|
+
webhookId: c967fd58-1d4d-49b6-8fa6-ec36b4d23e7f
|