lua-cli 3.1.0-alpha.2 → 3.1.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/README.md +0 -4
- package/dist/api/job.api.service.d.ts +23 -100
- package/dist/api/job.api.service.js +13 -11
- package/dist/api/lazy-instances.d.ts +8 -0
- package/dist/api/lazy-instances.js +16 -0
- package/dist/api/postprocessor.api.service.d.ts +1 -8
- package/dist/api/postprocessor.api.service.js +1 -2
- package/dist/api/preprocessor.api.service.d.ts +1 -8
- package/dist/api/preprocessor.api.service.js +1 -2
- package/dist/api/webhook.api.service.d.ts +1 -3
- package/dist/api/webhook.api.service.js +1 -1
- package/dist/api/whatsapp-templates.api.service.d.ts +40 -0
- package/dist/api/whatsapp-templates.api.service.js +78 -0
- package/dist/api-exports.d.ts +81 -2
- package/dist/api-exports.js +91 -15
- package/dist/commands/chat.js +2 -4
- package/dist/commands/init.js +11 -44
- package/dist/commands/jobs.js +5 -5
- package/dist/commands/push.js +2 -9
- package/dist/common/job.instance.d.ts +35 -7
- package/dist/common/job.instance.js +46 -19
- package/dist/config/constants.d.ts +1 -1
- package/dist/config/constants.js +1 -5
- package/dist/interfaces/agent.d.ts +0 -3
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/interfaces/init.d.ts +0 -1
- package/dist/interfaces/jobs.d.ts +88 -132
- package/dist/interfaces/jobs.js +1 -1
- package/dist/interfaces/postprocessors.d.ts +0 -3
- package/dist/interfaces/preprocessors.d.ts +0 -3
- package/dist/interfaces/webhooks.d.ts +0 -5
- package/dist/interfaces/whatsapp-templates.d.ts +104 -0
- package/dist/interfaces/whatsapp-templates.js +5 -0
- package/dist/types/api-contracts.d.ts +32 -0
- package/dist/types/compile.types.d.ts +0 -6
- package/dist/types/index.d.ts +1 -1
- package/dist/types/skill.d.ts +61 -90
- package/dist/types/skill.js +28 -86
- package/dist/utils/agent-management.d.ts +3 -5
- package/dist/utils/agent-management.js +6 -8
- package/dist/utils/bundling.js +5 -6
- package/dist/utils/compile.d.ts +0 -1
- package/dist/utils/compile.js +1 -51
- package/dist/utils/deployment.js +0 -1
- package/dist/utils/dev-api.js +0 -2
- package/dist/utils/files.d.ts +3 -3
- package/dist/utils/files.js +4 -12
- package/dist/utils/init-agent.d.ts +1 -2
- package/dist/utils/init-agent.js +4 -6
- package/dist/utils/init-helpers.d.ts +2 -4
- package/dist/utils/init-helpers.js +4 -10
- package/dist/utils/job-management.js +0 -2
- package/dist/utils/postprocessor-management.js +2 -4
- package/dist/utils/preprocessor-management.js +2 -4
- package/dist/utils/sandbox.js +17 -7
- package/dist/utils/webhook-management.js +1 -3
- package/package.json +1 -1
- package/template/QUICKSTART.md +0 -13
- package/template/README.md +6 -7
- package/template/src/jobs/AbandonedBasketProcessorJob.ts +0 -3
- package/template/src/jobs/DailyCleanupJob.ts +0 -3
- package/template/src/jobs/DataMigrationJob.ts +0 -3
- package/template/src/jobs/HealthCheckJob.ts +0 -3
- package/template/src/postprocessors/modifyResponse.ts +0 -1
- package/template/src/preprocessors/messageMatching.ts +18 -5
- package/template/src/skills/basket.skill.ts +0 -1
- package/template/src/skills/product.skill.ts +0 -1
- package/template/src/skills/user.skill.ts +0 -1
- package/template/src/webhooks/PaymentWebhook.ts +12 -9
- package/template/src/webhooks/UserEventWebhook.ts +39 -11
package/dist/types/skill.js
CHANGED
|
@@ -66,7 +66,6 @@ export const env = (key) => {
|
|
|
66
66
|
*
|
|
67
67
|
* const skill = new LuaSkill({
|
|
68
68
|
* name: 'weather-skill',
|
|
69
|
-
* version: '1.0.0',
|
|
70
69
|
* description: "Weather and calculator utilities",
|
|
71
70
|
* context: "This skill provides weather information and math operations. " +
|
|
72
71
|
* "Use get_weather for current conditions and calculator for arithmetic.",
|
|
@@ -83,7 +82,6 @@ export class LuaSkill {
|
|
|
83
82
|
*
|
|
84
83
|
* @param config - Configuration object containing skill metadata
|
|
85
84
|
* @param config.name - Skill name (optional, defaults to 'unnamed-skill')
|
|
86
|
-
* @param config.version - Skill version (optional, defaults to '1.0.0')
|
|
87
85
|
* @param config.description - Short description of what the skill does (1-2 sentences)
|
|
88
86
|
* @param config.context - Detailed explanation of how the agent should use the tools
|
|
89
87
|
* @param config.tools - Optional array of tools to add immediately
|
|
@@ -91,7 +89,6 @@ export class LuaSkill {
|
|
|
91
89
|
constructor(config) {
|
|
92
90
|
this.tools = [];
|
|
93
91
|
this.name = config.name || 'unnamed-skill';
|
|
94
|
-
this.version = config.version || '1.0.0';
|
|
95
92
|
this.description = config.description;
|
|
96
93
|
this.context = config.context;
|
|
97
94
|
// Add tools from constructor if provided
|
|
@@ -157,9 +154,7 @@ export class LuaSkill {
|
|
|
157
154
|
* // Daily cleanup job at 2 AM
|
|
158
155
|
* const dailyCleanup = new LuaJob({
|
|
159
156
|
* name: 'daily-cleanup',
|
|
160
|
-
* version: '1.0.0',
|
|
161
157
|
* description: "Daily database cleanup job",
|
|
162
|
-
* context: "Runs at 2 AM daily to clean up old records and optimize tables.",
|
|
163
158
|
* schedule: {
|
|
164
159
|
* type: 'cron',
|
|
165
160
|
* expression: '0 2 * * *', // 2 AM every day
|
|
@@ -180,9 +175,7 @@ export class LuaSkill {
|
|
|
180
175
|
* // One-time job
|
|
181
176
|
* const sendWelcome = new LuaJob({
|
|
182
177
|
* name: 'send-welcome',
|
|
183
|
-
* version: '1.0.0',
|
|
184
178
|
* description: "Send welcome email to new users",
|
|
185
|
-
* context: "Scheduled one-time task to send welcome emails.",
|
|
186
179
|
* schedule: {
|
|
187
180
|
* type: 'once',
|
|
188
181
|
* executeAt: new Date('2025-12-31T10:00:00Z')
|
|
@@ -196,9 +189,7 @@ export class LuaSkill {
|
|
|
196
189
|
* // Interval-based job (every 5 minutes)
|
|
197
190
|
* const healthCheck = new LuaJob({
|
|
198
191
|
* name: 'health-check',
|
|
199
|
-
* version: '1.0.0',
|
|
200
192
|
* description: "System health check",
|
|
201
|
-
* context: "Runs every 5 minutes to check system health.",
|
|
202
193
|
* schedule: {
|
|
203
194
|
* type: 'interval',
|
|
204
195
|
* seconds: 300 // 5 minutes
|
|
@@ -215,9 +206,7 @@ export class LuaJob {
|
|
|
215
206
|
*
|
|
216
207
|
* @param config - Configuration object containing job metadata
|
|
217
208
|
* @param config.name - Job name (optional, defaults to 'unnamed-job')
|
|
218
|
-
* @param config.version - Job version (optional, defaults to '1.0.0')
|
|
219
209
|
* @param config.description - Short description of what the job does (1-2 sentences)
|
|
220
|
-
* @param config.context - Detailed explanation of the job's purpose
|
|
221
210
|
* @param config.schedule - Schedule configuration (cron, once, or interval)
|
|
222
211
|
* @param config.timeout - Optional timeout in seconds (default: 300)
|
|
223
212
|
* @param config.retry - Optional retry configuration
|
|
@@ -226,9 +215,7 @@ export class LuaJob {
|
|
|
226
215
|
*/
|
|
227
216
|
constructor(config) {
|
|
228
217
|
this.name = config.name || 'unnamed-job';
|
|
229
|
-
this.version = config.version || '1.0.0';
|
|
230
218
|
this.description = config.description;
|
|
231
|
-
this.context = config.context;
|
|
232
219
|
this.schedule = config.schedule;
|
|
233
220
|
this.timeout = config.timeout || 300;
|
|
234
221
|
this.retry = config.retry;
|
|
@@ -241,24 +228,12 @@ export class LuaJob {
|
|
|
241
228
|
getName() {
|
|
242
229
|
return this.name;
|
|
243
230
|
}
|
|
244
|
-
/**
|
|
245
|
-
* Gets the job version.
|
|
246
|
-
*/
|
|
247
|
-
getVersion() {
|
|
248
|
-
return this.version;
|
|
249
|
-
}
|
|
250
231
|
/**
|
|
251
232
|
* Gets the job description.
|
|
252
233
|
*/
|
|
253
234
|
getDescription() {
|
|
254
235
|
return this.description;
|
|
255
236
|
}
|
|
256
|
-
/**
|
|
257
|
-
* Gets the job context.
|
|
258
|
-
*/
|
|
259
|
-
getContext() {
|
|
260
|
-
return this.context;
|
|
261
|
-
}
|
|
262
237
|
/**
|
|
263
238
|
* Gets the job schedule.
|
|
264
239
|
*/
|
|
@@ -299,10 +274,7 @@ export class LuaJob {
|
|
|
299
274
|
*
|
|
300
275
|
* const webhook = new LuaWebhook({
|
|
301
276
|
* name: 'user-created',
|
|
302
|
-
* version: '1.0.0',
|
|
303
277
|
* description: "Webhook that handles user creation events",
|
|
304
|
-
* context: "This webhook processes new user registration events. " +
|
|
305
|
-
* "It validates the user data and sends welcome emails.",
|
|
306
278
|
* querySchema: z.object({
|
|
307
279
|
* source: z.string().optional()
|
|
308
280
|
* }),
|
|
@@ -315,7 +287,8 @@ export class LuaJob {
|
|
|
315
287
|
* email: z.string().email(),
|
|
316
288
|
* name: z.string()
|
|
317
289
|
* }),
|
|
318
|
-
* execute: async (
|
|
290
|
+
* execute: async (event) => {
|
|
291
|
+
* const { query, headers, body } = event;
|
|
319
292
|
* // Process the webhook...
|
|
320
293
|
* console.log('New user:', body.email);
|
|
321
294
|
* return { success: true, userId: body.userId };
|
|
@@ -336,9 +309,7 @@ export class LuaWebhook {
|
|
|
336
309
|
*
|
|
337
310
|
* @param config - Configuration object containing webhook metadata
|
|
338
311
|
* @param config.name - Webhook name (optional, defaults to 'unnamed-webhook')
|
|
339
|
-
* @param config.version - Webhook version (optional, defaults to '1.0.0')
|
|
340
312
|
* @param config.description - Short description of what the webhook does (1-2 sentences)
|
|
341
|
-
* @param config.context - Detailed explanation of the webhook's purpose and behavior
|
|
342
313
|
* @param config.querySchema - Optional Zod schema for query parameter validation
|
|
343
314
|
* @param config.headerSchema - Optional Zod schema for header validation
|
|
344
315
|
* @param config.bodySchema - Optional Zod schema for body validation
|
|
@@ -346,9 +317,7 @@ export class LuaWebhook {
|
|
|
346
317
|
*/
|
|
347
318
|
constructor(config) {
|
|
348
319
|
this.name = config.name || 'unnamed-webhook';
|
|
349
|
-
this.version = config.version || '1.0.0';
|
|
350
320
|
this.description = config.description;
|
|
351
|
-
this.context = config.context;
|
|
352
321
|
this.querySchema = config.querySchema;
|
|
353
322
|
this.headerSchema = config.headerSchema;
|
|
354
323
|
this.bodySchema = config.bodySchema;
|
|
@@ -360,24 +329,12 @@ export class LuaWebhook {
|
|
|
360
329
|
getName() {
|
|
361
330
|
return this.name;
|
|
362
331
|
}
|
|
363
|
-
/**
|
|
364
|
-
* Gets the webhook version.
|
|
365
|
-
*/
|
|
366
|
-
getVersion() {
|
|
367
|
-
return this.version;
|
|
368
|
-
}
|
|
369
332
|
/**
|
|
370
333
|
* Gets the webhook description.
|
|
371
334
|
*/
|
|
372
335
|
getDescription() {
|
|
373
336
|
return this.description;
|
|
374
337
|
}
|
|
375
|
-
/**
|
|
376
|
-
* Gets the webhook context.
|
|
377
|
-
*/
|
|
378
|
-
getContext() {
|
|
379
|
-
return this.context;
|
|
380
|
-
}
|
|
381
338
|
/**
|
|
382
339
|
* Executes the webhook with validated input.
|
|
383
340
|
* Validates query parameters, headers, and body against their respective schemas
|
|
@@ -429,8 +386,13 @@ export class LuaWebhook {
|
|
|
429
386
|
throw new Error(`Body validation failed: ${error}`);
|
|
430
387
|
}
|
|
431
388
|
}
|
|
432
|
-
|
|
433
|
-
|
|
389
|
+
const event = {
|
|
390
|
+
query: validatedQuery || {},
|
|
391
|
+
headers: validatedHeaders || {},
|
|
392
|
+
body: validatedBody,
|
|
393
|
+
timestamp: new Date().toISOString(),
|
|
394
|
+
};
|
|
395
|
+
return this.executeFunction(event);
|
|
434
396
|
}
|
|
435
397
|
}
|
|
436
398
|
/**
|
|
@@ -442,23 +404,23 @@ export class LuaWebhook {
|
|
|
442
404
|
* ```typescript
|
|
443
405
|
* const contentFilter = new PreProcessor({
|
|
444
406
|
* name: 'content-filter',
|
|
445
|
-
* version: '1.0.0',
|
|
446
407
|
* description: 'Filters and processes message content',
|
|
447
|
-
*
|
|
408
|
+
* priority: 10,
|
|
448
409
|
* execute: async (user, messages, channel) => {
|
|
449
|
-
* //
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
410
|
+
* // Check for spam
|
|
411
|
+
* const hasSpam = messages.some(msg =>
|
|
412
|
+
* msg.type === 'text' && msg.text.includes('spam')
|
|
413
|
+
* );
|
|
414
|
+
*
|
|
415
|
+
* if (hasSpam) {
|
|
416
|
+
* return {
|
|
417
|
+
* action: 'block',
|
|
418
|
+
* response: "Message blocked due to spam content"
|
|
419
|
+
* };
|
|
420
|
+
* }
|
|
421
|
+
*
|
|
422
|
+
* // Return messages to proceed
|
|
423
|
+
* return { action: 'proceed' };
|
|
462
424
|
* }
|
|
463
425
|
* });
|
|
464
426
|
* ```
|
|
@@ -466,27 +428,23 @@ export class LuaWebhook {
|
|
|
466
428
|
export class PreProcessor {
|
|
467
429
|
constructor(config) {
|
|
468
430
|
this.name = config.name || 'unnamed-preprocessor';
|
|
469
|
-
this.version = config.version || '1.0.0';
|
|
470
431
|
this.description = config.description;
|
|
471
|
-
this.context = config.context;
|
|
472
432
|
this.asyncMode = config.async ?? false; // Default to synchronous
|
|
433
|
+
this.priority = config.priority ?? 100;
|
|
473
434
|
this.executeFunction = config.execute;
|
|
474
435
|
}
|
|
475
436
|
getName() {
|
|
476
437
|
return this.name;
|
|
477
438
|
}
|
|
478
|
-
getVersion() {
|
|
479
|
-
return this.version;
|
|
480
|
-
}
|
|
481
439
|
getDescription() {
|
|
482
440
|
return this.description;
|
|
483
441
|
}
|
|
484
|
-
getContext() {
|
|
485
|
-
return this.context;
|
|
486
|
-
}
|
|
487
442
|
getAsync() {
|
|
488
443
|
return this.asyncMode;
|
|
489
444
|
}
|
|
445
|
+
getPriority() {
|
|
446
|
+
return this.priority;
|
|
447
|
+
}
|
|
490
448
|
async execute(user, messages, channel) {
|
|
491
449
|
return this.executeFunction(user, messages, channel);
|
|
492
450
|
}
|
|
@@ -499,9 +457,7 @@ export class PreProcessor {
|
|
|
499
457
|
* ```typescript
|
|
500
458
|
* const responseFormatter = new PostProcessor({
|
|
501
459
|
* name: 'response-formatter',
|
|
502
|
-
* version: '1.0.0',
|
|
503
460
|
* description: 'Formats responses with branding',
|
|
504
|
-
* context: 'Adds company signature to all responses',
|
|
505
461
|
* execute: async (user, message, response, channel) => {
|
|
506
462
|
* return response + '\n\n---\nPowered by Acme Corp';
|
|
507
463
|
* }
|
|
@@ -511,24 +467,16 @@ export class PreProcessor {
|
|
|
511
467
|
export class PostProcessor {
|
|
512
468
|
constructor(config) {
|
|
513
469
|
this.name = config.name || 'unnamed-postprocessor';
|
|
514
|
-
this.version = config.version || '1.0.0';
|
|
515
470
|
this.description = config.description;
|
|
516
|
-
this.context = config.context;
|
|
517
471
|
this.asyncMode = config.async ?? false; // Default to synchronous
|
|
518
472
|
this.executeFunction = config.execute;
|
|
519
473
|
}
|
|
520
474
|
getName() {
|
|
521
475
|
return this.name;
|
|
522
476
|
}
|
|
523
|
-
getVersion() {
|
|
524
|
-
return this.version;
|
|
525
|
-
}
|
|
526
477
|
getDescription() {
|
|
527
478
|
return this.description;
|
|
528
479
|
}
|
|
529
|
-
getContext() {
|
|
530
|
-
return this.context;
|
|
531
|
-
}
|
|
532
480
|
getAsync() {
|
|
533
481
|
return this.asyncMode;
|
|
534
482
|
}
|
|
@@ -556,7 +504,6 @@ export class PostProcessor {
|
|
|
556
504
|
* export const agent = new LuaAgent({
|
|
557
505
|
* name: 'my-assistant',
|
|
558
506
|
* persona: 'You are a helpful AI assistant that can manage users and products.',
|
|
559
|
-
* welcomeMessage: 'Hello! How can I help you today?',
|
|
560
507
|
* skills: [userSkill],
|
|
561
508
|
* jobs: [healthCheckJob],
|
|
562
509
|
* webhooks: [webhookHandler],
|
|
@@ -572,7 +519,6 @@ export class LuaAgent {
|
|
|
572
519
|
* @param config - Agent configuration
|
|
573
520
|
* @param config.name - Agent name
|
|
574
521
|
* @param config.persona - Agent persona (behavior and personality)
|
|
575
|
-
* @param config.welcomeMessage - Optional welcome message
|
|
576
522
|
* @param config.skills - Optional array of skills
|
|
577
523
|
* @param config.webhooks - Optional array of webhooks
|
|
578
524
|
* @param config.jobs - Optional array of jobs
|
|
@@ -582,7 +528,6 @@ export class LuaAgent {
|
|
|
582
528
|
constructor(config) {
|
|
583
529
|
this.name = config.name;
|
|
584
530
|
this.persona = config.persona;
|
|
585
|
-
this.welcomeMessage = config.welcomeMessage;
|
|
586
531
|
this.skills = config.skills || [];
|
|
587
532
|
this.webhooks = config.webhooks || [];
|
|
588
533
|
this.jobs = config.jobs || [];
|
|
@@ -595,9 +540,6 @@ export class LuaAgent {
|
|
|
595
540
|
getPersona() {
|
|
596
541
|
return this.persona;
|
|
597
542
|
}
|
|
598
|
-
getWelcomeMessage() {
|
|
599
|
-
return this.welcomeMessage;
|
|
600
|
-
}
|
|
601
543
|
getSkills() {
|
|
602
544
|
return this.skills;
|
|
603
545
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent Management Utilities
|
|
3
|
-
* Handles LuaAgent persona
|
|
3
|
+
* Handles LuaAgent persona synchronization with lua.skill.yaml
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Syncs the agent's name
|
|
6
|
+
* Syncs the agent's name and persona with lua.skill.yaml.
|
|
7
7
|
* This ensures the YAML configuration reflects the agent definition in code.
|
|
8
8
|
*
|
|
9
9
|
* @param agentMetadata - Agent metadata extracted from LuaAgent
|
|
@@ -11,15 +11,13 @@
|
|
|
11
11
|
export declare function syncAgentPersonaWithYaml(agentMetadata: {
|
|
12
12
|
name: string;
|
|
13
13
|
persona: string;
|
|
14
|
-
welcomeMessage?: string;
|
|
15
14
|
}): Promise<void>;
|
|
16
15
|
/**
|
|
17
16
|
* Reads the agent persona from lua.skill.yaml.
|
|
18
17
|
* This can be used to ensure the code and YAML are in sync.
|
|
19
18
|
*
|
|
20
|
-
* @returns Agent persona
|
|
19
|
+
* @returns Agent persona from YAML, or null if not found
|
|
21
20
|
*/
|
|
22
21
|
export declare function readAgentPersonaFromYaml(): {
|
|
23
22
|
persona?: string;
|
|
24
|
-
welcomeMessage?: string;
|
|
25
23
|
} | null;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent Management Utilities
|
|
3
|
-
* Handles LuaAgent persona
|
|
3
|
+
* Handles LuaAgent persona synchronization with lua.skill.yaml
|
|
4
4
|
*/
|
|
5
5
|
import fs from "fs";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import yaml from "js-yaml";
|
|
8
8
|
import { COMPILE_FILES, YAML_FORMAT } from '../config/compile.constants.js';
|
|
9
9
|
/**
|
|
10
|
-
* Syncs the agent's name
|
|
10
|
+
* Syncs the agent's name and persona with lua.skill.yaml.
|
|
11
11
|
* This ensures the YAML configuration reflects the agent definition in code.
|
|
12
12
|
*
|
|
13
13
|
* @param agentMetadata - Agent metadata extracted from LuaAgent
|
|
@@ -20,11 +20,10 @@ export async function syncAgentPersonaWithYaml(agentMetadata) {
|
|
|
20
20
|
const yamlContent = fs.readFileSync(yamlPath, 'utf8');
|
|
21
21
|
config = yaml.load(yamlContent);
|
|
22
22
|
}
|
|
23
|
-
// Update agent section with
|
|
23
|
+
// Update agent section with persona
|
|
24
24
|
config.agent = {
|
|
25
25
|
...config.agent,
|
|
26
|
-
persona: agentMetadata.persona
|
|
27
|
-
welcomeMessage: agentMetadata.welcomeMessage
|
|
26
|
+
persona: agentMetadata.persona
|
|
28
27
|
};
|
|
29
28
|
// Store agent name as a comment or in metadata (YAML doesn't have an agentName field)
|
|
30
29
|
// The agent name is primarily for the LuaAgent in code
|
|
@@ -45,7 +44,7 @@ export async function syncAgentPersonaWithYaml(agentMetadata) {
|
|
|
45
44
|
* Reads the agent persona from lua.skill.yaml.
|
|
46
45
|
* This can be used to ensure the code and YAML are in sync.
|
|
47
46
|
*
|
|
48
|
-
* @returns Agent persona
|
|
47
|
+
* @returns Agent persona from YAML, or null if not found
|
|
49
48
|
*/
|
|
50
49
|
export function readAgentPersonaFromYaml() {
|
|
51
50
|
const yamlPath = path.join(process.cwd(), COMPILE_FILES.LUA_SKILL_YAML);
|
|
@@ -57,8 +56,7 @@ export function readAgentPersonaFromYaml() {
|
|
|
57
56
|
const config = yaml.load(yamlContent);
|
|
58
57
|
if (config.agent) {
|
|
59
58
|
return {
|
|
60
|
-
persona: config.agent.persona
|
|
61
|
-
welcomeMessage: config.agent.welcomeMessage
|
|
59
|
+
persona: config.agent.persona
|
|
62
60
|
};
|
|
63
61
|
}
|
|
64
62
|
}
|
package/dist/utils/bundling.js
CHANGED
|
@@ -248,7 +248,8 @@ export const sandboxGlobalsPlugin = {
|
|
|
248
248
|
'Baskets': 'Baskets',
|
|
249
249
|
'Orders': 'Orders',
|
|
250
250
|
'Webhooks': 'Webhooks',
|
|
251
|
-
'Jobs': 'Jobs'
|
|
251
|
+
'Jobs': 'Jobs',
|
|
252
|
+
'Templates': 'Templates'
|
|
252
253
|
};
|
|
253
254
|
// Replace usage of imported names with globals
|
|
254
255
|
for (const [importName, globalName] of Object.entries(globalMappings)) {
|
|
@@ -527,7 +528,7 @@ export async function bundleWebhook(webhook, indexFile, distDir, project, debugM
|
|
|
527
528
|
* @returns Compressed base64-encoded bundled code
|
|
528
529
|
*/
|
|
529
530
|
async function bundleAndCompressWebhookCode(executeFunction, webhookName, distDir, sourceFilePath, debugMode) {
|
|
530
|
-
return bundleAndCompressExecuteFunction(executeFunction, webhookName, 'webhook', (bundledCode) => `(async (
|
|
531
|
+
return bundleAndCompressExecuteFunction(executeFunction, webhookName, 'webhook', (bundledCode) => `(async (event) => {
|
|
531
532
|
|
|
532
533
|
// Execute the bundled webhook code
|
|
533
534
|
${bundledCode}
|
|
@@ -535,8 +536,8 @@ async function bundleAndCompressWebhookCode(executeFunction, webhookName, distDi
|
|
|
535
536
|
// Get the execute function from exports
|
|
536
537
|
const executeFunction = module.exports.default || module.exports;
|
|
537
538
|
|
|
538
|
-
// Execute with
|
|
539
|
-
return await executeFunction(
|
|
539
|
+
// Execute with the unified event object
|
|
540
|
+
return await executeFunction(event);
|
|
540
541
|
})`, distDir, sourceFilePath, debugMode);
|
|
541
542
|
}
|
|
542
543
|
/**
|
|
@@ -733,7 +734,6 @@ export async function bundlePreProcessor(preprocessor, indexFile, distDir, proje
|
|
|
733
734
|
name: preprocessor.name,
|
|
734
735
|
version: preprocessor.version,
|
|
735
736
|
description: preprocessor.description,
|
|
736
|
-
context: preprocessor.context,
|
|
737
737
|
async: preprocessor.async === true ? true : false, // Explicitly set boolean
|
|
738
738
|
executeFunction,
|
|
739
739
|
code: compressedCode
|
|
@@ -819,7 +819,6 @@ export async function bundlePostProcessor(postprocessor, indexFile, distDir, pro
|
|
|
819
819
|
name: postprocessor.name,
|
|
820
820
|
version: postprocessor.version,
|
|
821
821
|
description: postprocessor.description,
|
|
822
|
-
context: postprocessor.context,
|
|
823
822
|
async: postprocessor.async === true ? true : false, // Explicitly set boolean
|
|
824
823
|
executeFunction,
|
|
825
824
|
code: compressedCode
|
package/dist/utils/compile.d.ts
CHANGED
|
@@ -64,7 +64,6 @@ export declare function extractPostProcessorsMetadata(indexFile: any): any[];
|
|
|
64
64
|
export declare function extractLuaAgentMetadata(indexFile: any): {
|
|
65
65
|
name: string;
|
|
66
66
|
persona: string;
|
|
67
|
-
welcomeMessage?: string;
|
|
68
67
|
skills: any[];
|
|
69
68
|
webhooks: any[];
|
|
70
69
|
jobs: any[];
|
package/dist/utils/compile.js
CHANGED
|
@@ -235,7 +235,6 @@ export function extractSkillsMetadata(indexFile) {
|
|
|
235
235
|
if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
|
|
236
236
|
const configObj = args[0];
|
|
237
237
|
let skillName = '';
|
|
238
|
-
let skillVersion = '';
|
|
239
238
|
let description = '';
|
|
240
239
|
let context = '';
|
|
241
240
|
let constructorTools = [];
|
|
@@ -247,9 +246,6 @@ export function extractSkillsMetadata(indexFile) {
|
|
|
247
246
|
if (name === 'name' && value) {
|
|
248
247
|
skillName = value.getText().replace(/['"]/g, '');
|
|
249
248
|
}
|
|
250
|
-
else if (name === 'version' && value) {
|
|
251
|
-
skillVersion = value.getText().replace(/['"]/g, '');
|
|
252
|
-
}
|
|
253
249
|
else if (name === 'description' && value) {
|
|
254
250
|
description = value.getText().replace(/['"]/g, '');
|
|
255
251
|
}
|
|
@@ -271,7 +267,6 @@ export function extractSkillsMetadata(indexFile) {
|
|
|
271
267
|
if (skillName) {
|
|
272
268
|
skills.push({
|
|
273
269
|
name: skillName,
|
|
274
|
-
version: skillVersion || '1.0.0',
|
|
275
270
|
description,
|
|
276
271
|
context,
|
|
277
272
|
constructorTools
|
|
@@ -297,9 +292,7 @@ export function extractWebhooksMetadata(indexFile) {
|
|
|
297
292
|
if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
|
|
298
293
|
const configObj = args[0];
|
|
299
294
|
let webhookName = '';
|
|
300
|
-
let webhookVersion = '';
|
|
301
295
|
let description = '';
|
|
302
|
-
let context = '';
|
|
303
296
|
// Extract properties
|
|
304
297
|
configObj.getProperties().forEach((prop) => {
|
|
305
298
|
if (Node.isPropertyAssignment(prop)) {
|
|
@@ -308,23 +301,15 @@ export function extractWebhooksMetadata(indexFile) {
|
|
|
308
301
|
if (name === 'name' && value) {
|
|
309
302
|
webhookName = value.getText().replace(/['"]/g, '');
|
|
310
303
|
}
|
|
311
|
-
else if (name === 'version' && value) {
|
|
312
|
-
webhookVersion = value.getText().replace(/['"]/g, '');
|
|
313
|
-
}
|
|
314
304
|
else if (name === 'description' && value) {
|
|
315
305
|
description = value.getText().replace(/['"]/g, '');
|
|
316
306
|
}
|
|
317
|
-
else if (name === 'context' && value) {
|
|
318
|
-
context = value.getText().replace(/['"]/g, '');
|
|
319
|
-
}
|
|
320
307
|
}
|
|
321
308
|
});
|
|
322
309
|
if (webhookName) {
|
|
323
310
|
webhooks.push({
|
|
324
311
|
name: webhookName,
|
|
325
|
-
|
|
326
|
-
description,
|
|
327
|
-
context
|
|
312
|
+
description
|
|
328
313
|
});
|
|
329
314
|
}
|
|
330
315
|
}
|
|
@@ -347,9 +332,7 @@ export function extractJobsMetadata(indexFile) {
|
|
|
347
332
|
if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
|
|
348
333
|
const configObj = args[0];
|
|
349
334
|
let jobName = '';
|
|
350
|
-
let jobVersion = '';
|
|
351
335
|
let description = '';
|
|
352
|
-
let context = '';
|
|
353
336
|
let schedule = null;
|
|
354
337
|
let timeout;
|
|
355
338
|
let retry = undefined;
|
|
@@ -362,15 +345,9 @@ export function extractJobsMetadata(indexFile) {
|
|
|
362
345
|
if (name === 'name' && value) {
|
|
363
346
|
jobName = value.getText().replace(/['"]/g, '');
|
|
364
347
|
}
|
|
365
|
-
else if (name === 'version' && value) {
|
|
366
|
-
jobVersion = value.getText().replace(/['"]/g, '');
|
|
367
|
-
}
|
|
368
348
|
else if (name === 'description' && value) {
|
|
369
349
|
description = value.getText().replace(/['"]/g, '');
|
|
370
350
|
}
|
|
371
|
-
else if (name === 'context' && value) {
|
|
372
|
-
context = value.getText().replace(/['"]/g, '');
|
|
373
|
-
}
|
|
374
351
|
else if (name === 'schedule' && value) {
|
|
375
352
|
// Extract schedule configuration
|
|
376
353
|
try {
|
|
@@ -412,9 +389,7 @@ export function extractJobsMetadata(indexFile) {
|
|
|
412
389
|
if (jobName) {
|
|
413
390
|
jobs.push({
|
|
414
391
|
name: jobName,
|
|
415
|
-
version: jobVersion || '1.0.0',
|
|
416
392
|
description,
|
|
417
|
-
context,
|
|
418
393
|
schedule,
|
|
419
394
|
timeout,
|
|
420
395
|
retry,
|
|
@@ -441,9 +416,7 @@ export function extractPreProcessorsMetadata(indexFile) {
|
|
|
441
416
|
if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
|
|
442
417
|
const configObj = args[0];
|
|
443
418
|
let name = '';
|
|
444
|
-
let version = '';
|
|
445
419
|
let description = '';
|
|
446
|
-
let context = '';
|
|
447
420
|
let asyncMode = false;
|
|
448
421
|
configObj.getProperties().forEach((prop) => {
|
|
449
422
|
if (Node.isPropertyAssignment(prop)) {
|
|
@@ -452,15 +425,9 @@ export function extractPreProcessorsMetadata(indexFile) {
|
|
|
452
425
|
if (propName === 'name' && value) {
|
|
453
426
|
name = value.getText().replace(/['"]/g, '');
|
|
454
427
|
}
|
|
455
|
-
else if (propName === 'version' && value) {
|
|
456
|
-
version = value.getText().replace(/['"]/g, '');
|
|
457
|
-
}
|
|
458
428
|
else if (propName === 'description' && value) {
|
|
459
429
|
description = value.getText().replace(/['"]/g, '');
|
|
460
430
|
}
|
|
461
|
-
else if (propName === 'context' && value) {
|
|
462
|
-
context = value.getText().replace(/['"]/g, '');
|
|
463
|
-
}
|
|
464
431
|
else if (propName === 'async' && value) {
|
|
465
432
|
// Properly extract boolean value by checking node kind
|
|
466
433
|
const nodeKind = value.getKind();
|
|
@@ -471,9 +438,7 @@ export function extractPreProcessorsMetadata(indexFile) {
|
|
|
471
438
|
if (name) {
|
|
472
439
|
preprocessors.push({
|
|
473
440
|
name,
|
|
474
|
-
version: version || '1.0.0',
|
|
475
441
|
description,
|
|
476
|
-
context,
|
|
477
442
|
async: asyncMode
|
|
478
443
|
});
|
|
479
444
|
}
|
|
@@ -497,9 +462,7 @@ export function extractPostProcessorsMetadata(indexFile) {
|
|
|
497
462
|
if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
|
|
498
463
|
const configObj = args[0];
|
|
499
464
|
let name = '';
|
|
500
|
-
let version = '';
|
|
501
465
|
let description = '';
|
|
502
|
-
let context = '';
|
|
503
466
|
let asyncMode = false;
|
|
504
467
|
configObj.getProperties().forEach((prop) => {
|
|
505
468
|
if (Node.isPropertyAssignment(prop)) {
|
|
@@ -508,15 +471,9 @@ export function extractPostProcessorsMetadata(indexFile) {
|
|
|
508
471
|
if (propName === 'name' && value) {
|
|
509
472
|
name = value.getText().replace(/['"]/g, '');
|
|
510
473
|
}
|
|
511
|
-
else if (propName === 'version' && value) {
|
|
512
|
-
version = value.getText().replace(/['"]/g, '');
|
|
513
|
-
}
|
|
514
474
|
else if (propName === 'description' && value) {
|
|
515
475
|
description = value.getText().replace(/['"]/g, '');
|
|
516
476
|
}
|
|
517
|
-
else if (propName === 'context' && value) {
|
|
518
|
-
context = value.getText().replace(/['"]/g, '');
|
|
519
|
-
}
|
|
520
477
|
else if (propName === 'async' && value) {
|
|
521
478
|
// Properly extract boolean value by checking node kind
|
|
522
479
|
const nodeKind = value.getKind();
|
|
@@ -527,9 +484,7 @@ export function extractPostProcessorsMetadata(indexFile) {
|
|
|
527
484
|
if (name) {
|
|
528
485
|
postprocessors.push({
|
|
529
486
|
name,
|
|
530
|
-
version: version || '1.0.0',
|
|
531
487
|
description,
|
|
532
|
-
context,
|
|
533
488
|
async: asyncMode
|
|
534
489
|
});
|
|
535
490
|
}
|
|
@@ -558,7 +513,6 @@ export function extractLuaAgentMetadata(indexFile) {
|
|
|
558
513
|
const configObj = args[0];
|
|
559
514
|
let name = '';
|
|
560
515
|
let persona = '';
|
|
561
|
-
let welcomeMessage = '';
|
|
562
516
|
const skills = [];
|
|
563
517
|
const webhooks = [];
|
|
564
518
|
const jobs = [];
|
|
@@ -581,9 +535,6 @@ export function extractLuaAgentMetadata(indexFile) {
|
|
|
581
535
|
.replace(/\\n/g, '\n')
|
|
582
536
|
.trim();
|
|
583
537
|
}
|
|
584
|
-
else if (propName === 'welcomeMessage' && value) {
|
|
585
|
-
welcomeMessage = value.getText().replace(/['"]/g, '');
|
|
586
|
-
}
|
|
587
538
|
else if (propName === 'skills' && value && Node.isArrayLiteralExpression(value)) {
|
|
588
539
|
// Extract skill references from the array
|
|
589
540
|
value.getElements().forEach((element) => {
|
|
@@ -663,7 +614,6 @@ export function extractLuaAgentMetadata(indexFile) {
|
|
|
663
614
|
agentMetadata = {
|
|
664
615
|
name,
|
|
665
616
|
persona,
|
|
666
|
-
welcomeMessage: welcomeMessage || undefined,
|
|
667
617
|
skills,
|
|
668
618
|
webhooks,
|
|
669
619
|
jobs,
|
package/dist/utils/deployment.js
CHANGED
package/dist/utils/dev-api.js
CHANGED
|
@@ -290,7 +290,6 @@ export async function pushSinglePreProcessorToSandbox(apiKey, agentId, preproces
|
|
|
290
290
|
name: preprocessorName,
|
|
291
291
|
version: sandboxVersion,
|
|
292
292
|
description: preprocessorData.description,
|
|
293
|
-
context: preprocessorData.context,
|
|
294
293
|
code: preprocessorData.code,
|
|
295
294
|
executeFunction: preprocessorData.executeFunction,
|
|
296
295
|
async: Boolean(preprocessorData.async ?? false)
|
|
@@ -349,7 +348,6 @@ export async function pushSinglePostProcessorToSandbox(apiKey, agentId, postproc
|
|
|
349
348
|
name: postprocessorName,
|
|
350
349
|
version: sandboxVersion,
|
|
351
350
|
description: postprocessorData.description,
|
|
352
|
-
context: postprocessorData.context,
|
|
353
351
|
code: postprocessorData.code,
|
|
354
352
|
executeFunction: postprocessorData.executeFunction,
|
|
355
353
|
async: Boolean(postprocessorData.async ?? false)
|
package/dist/utils/files.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare function copyTemplateFiles(templateDir: string, targetDir: string): void;
|
|
2
|
-
export declare function createSkillYaml(agentId: string, orgId: string, skillName?: string, skillId?: string, persona?: string
|
|
2
|
+
export declare function createSkillYaml(agentId: string, orgId: string, skillName?: string, skillId?: string, persona?: string): void;
|
|
3
3
|
export declare function readSkillYaml(): any;
|
|
4
4
|
export declare function readSkillConfig(): any;
|
|
5
5
|
/**
|
|
6
6
|
* Update only the agent information in an existing YAML file
|
|
7
7
|
*/
|
|
8
|
-
export declare function updateYamlAgent(agentId: string, orgId: string, persona?: string
|
|
9
|
-
export declare function updateSkillYamlPersona(persona: string
|
|
8
|
+
export declare function updateYamlAgent(agentId: string, orgId: string, persona?: string): void;
|
|
9
|
+
export declare function updateSkillYamlPersona(persona: string): void;
|