lua-cli 3.1.0-alpha.3 → 3.1.0-alpha.5

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.
Files changed (125) hide show
  1. package/README.md +0 -4
  2. package/dist/api/cdn.api.service.d.ts +18 -0
  3. package/dist/api/cdn.api.service.js +43 -0
  4. package/dist/api/custom.data.api.service.d.ts +4 -3
  5. package/dist/api/custom.data.api.service.js +4 -3
  6. package/dist/api/developer.api.service.d.ts +54 -1
  7. package/dist/api/developer.api.service.js +89 -0
  8. package/dist/api/job.api.service.d.ts +33 -100
  9. package/dist/api/job.api.service.js +27 -11
  10. package/dist/api/lazy-instances.d.ts +16 -0
  11. package/dist/api/lazy-instances.js +32 -0
  12. package/dist/api/postprocessor.api.service.d.ts +3 -13
  13. package/dist/api/postprocessor.api.service.js +2 -4
  14. package/dist/api/preprocessor.api.service.d.ts +1 -8
  15. package/dist/api/preprocessor.api.service.js +1 -2
  16. package/dist/api/webhook.api.service.d.ts +1 -3
  17. package/dist/api/webhook.api.service.js +1 -1
  18. package/dist/api/whatsapp-templates.api.service.d.ts +40 -0
  19. package/dist/api/whatsapp-templates.api.service.js +78 -0
  20. package/dist/api-exports.d.ts +153 -6
  21. package/dist/api-exports.js +177 -21
  22. package/dist/cli/command-definitions.js +34 -7
  23. package/dist/commands/admin.js +1 -1
  24. package/dist/commands/channels.js +1 -1
  25. package/dist/commands/chat.js +2 -4
  26. package/dist/commands/compile.js +23 -4
  27. package/dist/commands/evals.d.ts +8 -0
  28. package/dist/commands/evals.js +41 -0
  29. package/dist/commands/index.d.ts +2 -0
  30. package/dist/commands/index.js +2 -0
  31. package/dist/commands/init.d.ts +10 -1
  32. package/dist/commands/init.js +23 -46
  33. package/dist/commands/jobs.js +5 -5
  34. package/dist/commands/mcp.d.ts +18 -0
  35. package/dist/commands/mcp.js +393 -0
  36. package/dist/commands/push.js +174 -23
  37. package/dist/common/data.entry.instance.d.ts +1 -1
  38. package/dist/common/data.entry.instance.js +4 -4
  39. package/dist/common/job.instance.d.ts +59 -7
  40. package/dist/common/job.instance.js +84 -19
  41. package/dist/config/constants.d.ts +1 -0
  42. package/dist/config/constants.js +1 -0
  43. package/dist/index.js +1 -0
  44. package/dist/interfaces/agent.d.ts +0 -3
  45. package/dist/interfaces/cdn.d.ts +24 -0
  46. package/dist/interfaces/cdn.js +5 -0
  47. package/dist/interfaces/compile.d.ts +1 -0
  48. package/dist/interfaces/custom.data.d.ts +3 -3
  49. package/dist/interfaces/index.d.ts +2 -1
  50. package/dist/interfaces/init.d.ts +0 -1
  51. package/dist/interfaces/jobs.d.ts +88 -132
  52. package/dist/interfaces/jobs.js +1 -1
  53. package/dist/interfaces/mcp.d.ts +64 -0
  54. package/dist/interfaces/mcp.js +5 -0
  55. package/dist/interfaces/postprocessors.d.ts +0 -3
  56. package/dist/interfaces/preprocessors.d.ts +0 -3
  57. package/dist/interfaces/webhooks.d.ts +0 -5
  58. package/dist/interfaces/whatsapp-templates.d.ts +104 -0
  59. package/dist/interfaces/whatsapp-templates.js +5 -0
  60. package/dist/types/api-contracts.d.ts +68 -14
  61. package/dist/types/compile.types.d.ts +5 -6
  62. package/dist/types/index.d.ts +2 -2
  63. package/dist/types/index.js +3 -1
  64. package/dist/types/skill.d.ts +181 -103
  65. package/dist/types/skill.js +123 -91
  66. package/dist/utils/agent-management.d.ts +3 -5
  67. package/dist/utils/agent-management.js +6 -8
  68. package/dist/utils/bundling.d.ts +4 -11
  69. package/dist/utils/bundling.js +24 -33
  70. package/dist/utils/compile.d.ts +17 -9
  71. package/dist/utils/compile.js +72 -88
  72. package/dist/utils/deployment.js +13 -7
  73. package/dist/utils/dev-api.js +1 -4
  74. package/dist/utils/dev-server.js +1 -1
  75. package/dist/utils/files.d.ts +11 -4
  76. package/dist/utils/files.js +17 -14
  77. package/dist/utils/init-agent.d.ts +1 -2
  78. package/dist/utils/init-agent.js +4 -6
  79. package/dist/utils/init-helpers.d.ts +4 -4
  80. package/dist/utils/init-helpers.js +10 -11
  81. package/dist/utils/job-management.js +0 -2
  82. package/dist/utils/mcp-server-management.d.ts +23 -0
  83. package/dist/utils/mcp-server-management.js +212 -0
  84. package/dist/utils/postprocessor-management.js +2 -4
  85. package/dist/utils/preprocessor-management.js +2 -4
  86. package/dist/utils/sandbox.d.ts +4 -2
  87. package/dist/utils/sandbox.js +38 -9
  88. package/dist/utils/webhook-management.js +1 -3
  89. package/dist/web/app.css +1505 -14
  90. package/dist/web/app.js +79 -64
  91. package/package.json +2 -6
  92. package/template/QUICKSTART.md +57 -774
  93. package/template/README.md +80 -907
  94. package/template/examples/README.md +106 -0
  95. package/template/{src → examples}/jobs/AbandonedBasketProcessorJob.ts +67 -14
  96. package/template/{src → examples}/jobs/DailyCleanupJob.ts +0 -3
  97. package/template/{src → examples}/jobs/DataMigrationJob.ts +0 -3
  98. package/template/{src → examples}/jobs/HealthCheckJob.ts +0 -3
  99. package/template/{src → examples}/postprocessors/modifyResponse.ts +3 -4
  100. package/template/examples/preprocessors/messageMatching.ts +35 -0
  101. package/template/{src → examples}/skills/basket.skill.ts +0 -1
  102. package/template/{src → examples}/skills/product.skill.ts +0 -1
  103. package/template/{src → examples}/skills/tools/GameScoreTrackerTool.ts +11 -15
  104. package/template/{src → examples}/skills/tools/OrderTool.ts +25 -0
  105. package/template/examples/skills/tools/PremiumFeatureTool.ts +98 -0
  106. package/template/{src → examples}/skills/tools/UserDataTool.ts +34 -0
  107. package/template/{src → examples}/skills/user.skill.ts +0 -1
  108. package/template/examples/webhooks/FileUploadWebhook.ts +86 -0
  109. package/template/{src → examples}/webhooks/PaymentWebhook.ts +12 -9
  110. package/template/examples/webhooks/UserEventWebhook.ts +105 -0
  111. package/template/package-lock.json +7895 -0
  112. package/template/package.json +1 -1
  113. package/template/src/index.ts +40 -22
  114. package/template/src/preprocessors/messageMatching.ts +0 -22
  115. package/template/src/webhooks/UserEventWebhook.ts +0 -77
  116. /package/template/{src → examples}/services/ApiService.ts +0 -0
  117. /package/template/{src → examples}/services/GetWeather.ts +0 -0
  118. /package/template/{src → examples}/skills/tools/BasketTool.ts +0 -0
  119. /package/template/{src → examples}/skills/tools/CreateInlineJob.ts +0 -0
  120. /package/template/{src → examples}/skills/tools/CreatePostTool.ts +0 -0
  121. /package/template/{src → examples}/skills/tools/CustomDataTool.ts +0 -0
  122. /package/template/{src → examples}/skills/tools/GetWeatherTool.ts +0 -0
  123. /package/template/{src → examples}/skills/tools/PaymentTool.ts +0 -0
  124. /package/template/{src → examples}/skills/tools/ProductsTool.ts +0 -0
  125. /package/template/{src → examples}/skills/tools/SmartBasketTool.ts +0 -0
@@ -47,6 +47,24 @@ export declare const env: (key: string) => string | undefined;
47
47
  * }
48
48
  * };
49
49
  * ```
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // Tool with condition - only available to premium users
54
+ * class PremiumSearchTool implements LuaTool {
55
+ * name = "premium_search";
56
+ * description = "Advanced search for premium users";
57
+ * inputSchema = z.object({ query: z.string() });
58
+ *
59
+ * // Condition runs before tool is offered to LLM
60
+ * condition = async () => {
61
+ * const user = await User.get();
62
+ * return user.data?.isPremium === true;
63
+ * };
64
+ *
65
+ * execute = async (input) => { ... };
66
+ * }
67
+ * ```
50
68
  */
51
69
  export interface LuaTool<TInput extends ZodType = ZodType> {
52
70
  /** Unique tool name (alphanumeric, hyphens, underscores only) */
@@ -57,6 +75,8 @@ export interface LuaTool<TInput extends ZodType = ZodType> {
57
75
  inputSchema: TInput;
58
76
  /** Async function that executes the tool logic */
59
77
  execute: (input: any) => Promise<any>;
78
+ /** Optional async function that determines if the tool should be available */
79
+ condition?: () => Promise<boolean>;
60
80
  }
61
81
  /**
62
82
  * Lua Skill configuration.
@@ -65,8 +85,6 @@ export interface LuaTool<TInput extends ZodType = ZodType> {
65
85
  export interface LuaSkillConfig {
66
86
  /** Skill name (optional, defaults to 'unnamed-skill') */
67
87
  name?: string;
68
- /** Skill version (optional, defaults to '1.0.0') */
69
- version?: string;
70
88
  /** Short description of the skill (1-2 sentences) */
71
89
  description: string;
72
90
  /** Detailed context for how the agent should use the tools */
@@ -87,7 +105,6 @@ export interface LuaSkillConfig {
87
105
  *
88
106
  * const skill = new LuaSkill({
89
107
  * name: 'weather-skill',
90
- * version: '1.0.0',
91
108
  * description: "Weather and calculator utilities",
92
109
  * context: "This skill provides weather information and math operations. " +
93
110
  * "Use get_weather for current conditions and calculator for arithmetic.",
@@ -101,7 +118,6 @@ export interface LuaSkillConfig {
101
118
  export declare class LuaSkill {
102
119
  private readonly tools;
103
120
  private readonly name;
104
- private readonly version;
105
121
  private readonly description;
106
122
  private readonly context;
107
123
  /**
@@ -109,7 +125,6 @@ export declare class LuaSkill {
109
125
  *
110
126
  * @param config - Configuration object containing skill metadata
111
127
  * @param config.name - Skill name (optional, defaults to 'unnamed-skill')
112
- * @param config.version - Skill version (optional, defaults to '1.0.0')
113
128
  * @param config.description - Short description of what the skill does (1-2 sentences)
114
129
  * @param config.context - Detailed explanation of how the agent should use the tools
115
130
  * @param config.tools - Optional array of tools to add immediately
@@ -164,12 +179,8 @@ export type JobSchedule = {
164
179
  export interface LuaJobConfig {
165
180
  /** Job name (optional, defaults to 'unnamed-job') */
166
181
  name?: string;
167
- /** Job version (optional, defaults to '1.0.0') */
168
- version?: string;
169
182
  /** Short description of the job (1-2 sentences) */
170
183
  description: string;
171
- /** Detailed context for what this job does */
172
- context: string;
173
184
  /** Schedule configuration - cron, once, or interval */
174
185
  schedule: JobSchedule;
175
186
  /**
@@ -205,9 +216,7 @@ export interface LuaJobConfig {
205
216
  * // Daily cleanup job at 2 AM
206
217
  * const dailyCleanup = new LuaJob({
207
218
  * name: 'daily-cleanup',
208
- * version: '1.0.0',
209
219
  * description: "Daily database cleanup job",
210
- * context: "Runs at 2 AM daily to clean up old records and optimize tables.",
211
220
  * schedule: {
212
221
  * type: 'cron',
213
222
  * expression: '0 2 * * *', // 2 AM every day
@@ -228,9 +237,7 @@ export interface LuaJobConfig {
228
237
  * // One-time job
229
238
  * const sendWelcome = new LuaJob({
230
239
  * name: 'send-welcome',
231
- * version: '1.0.0',
232
240
  * description: "Send welcome email to new users",
233
- * context: "Scheduled one-time task to send welcome emails.",
234
241
  * schedule: {
235
242
  * type: 'once',
236
243
  * executeAt: new Date('2025-12-31T10:00:00Z')
@@ -244,9 +251,7 @@ export interface LuaJobConfig {
244
251
  * // Interval-based job (every 5 minutes)
245
252
  * const healthCheck = new LuaJob({
246
253
  * name: 'health-check',
247
- * version: '1.0.0',
248
254
  * description: "System health check",
249
- * context: "Runs every 5 minutes to check system health.",
250
255
  * schedule: {
251
256
  * type: 'interval',
252
257
  * seconds: 300 // 5 minutes
@@ -259,9 +264,7 @@ export interface LuaJobConfig {
259
264
  */
260
265
  export declare class LuaJob {
261
266
  private readonly name;
262
- private readonly version;
263
267
  private readonly description;
264
- private readonly context;
265
268
  private readonly schedule;
266
269
  private readonly timeout;
267
270
  private readonly retry?;
@@ -272,9 +275,7 @@ export declare class LuaJob {
272
275
  *
273
276
  * @param config - Configuration object containing job metadata
274
277
  * @param config.name - Job name (optional, defaults to 'unnamed-job')
275
- * @param config.version - Job version (optional, defaults to '1.0.0')
276
278
  * @param config.description - Short description of what the job does (1-2 sentences)
277
- * @param config.context - Detailed explanation of the job's purpose
278
279
  * @param config.schedule - Schedule configuration (cron, once, or interval)
279
280
  * @param config.timeout - Optional timeout in seconds (default: 300)
280
281
  * @param config.retry - Optional retry configuration
@@ -286,18 +287,10 @@ export declare class LuaJob {
286
287
  * Gets the job name.
287
288
  */
288
289
  getName(): string;
289
- /**
290
- * Gets the job version.
291
- */
292
- getVersion(): string;
293
290
  /**
294
291
  * Gets the job description.
295
292
  */
296
293
  getDescription(): string;
297
- /**
298
- * Gets the job context.
299
- */
300
- getContext(): string;
301
294
  /**
302
295
  * Gets the job schedule.
303
296
  */
@@ -318,6 +311,19 @@ export declare class LuaJob {
318
311
  */
319
312
  getMetadata(): Record<string, any> | undefined;
320
313
  }
314
+ /**
315
+ * Event payload delivered to webhook execute functions.
316
+ */
317
+ export interface LuaWebhookEvent {
318
+ /** Parsed query parameters */
319
+ query?: Record<string, any>;
320
+ /** Request headers */
321
+ headers?: Record<string, any>;
322
+ /** Request body (JSON or raw data) */
323
+ body?: any;
324
+ /** ISO timestamp when the webhook was received */
325
+ timestamp: string;
326
+ }
321
327
  /**
322
328
  * Lua Webhook configuration.
323
329
  * Used to initialize a new LuaWebhook instance.
@@ -325,12 +331,8 @@ export declare class LuaJob {
325
331
  export interface LuaWebhookConfig {
326
332
  /** Webhook name (optional, defaults to 'unnamed-webhook') */
327
333
  name?: string;
328
- /** Webhook version (optional, defaults to '1.0.0') */
329
- version?: string;
330
334
  /** Short description of the webhook (1-2 sentences) */
331
335
  description: string;
332
- /** Detailed context for what this webhook does and how it should be used */
333
- context: string;
334
336
  /** Optional Zod schema for query parameter validation */
335
337
  querySchema?: ZodType;
336
338
  /** Optional Zod schema for header validation */
@@ -338,7 +340,7 @@ export interface LuaWebhookConfig {
338
340
  /** Optional Zod schema for body validation */
339
341
  bodySchema?: ZodType;
340
342
  /** Function that executes the webhook logic */
341
- execute: (query?: any, headers?: any, body?: any) => Promise<any>;
343
+ execute: (event: LuaWebhookEvent) => Promise<any>;
342
344
  }
343
345
  /**
344
346
  * Lua Webhook class.
@@ -355,10 +357,7 @@ export interface LuaWebhookConfig {
355
357
  *
356
358
  * const webhook = new LuaWebhook({
357
359
  * name: 'user-created',
358
- * version: '1.0.0',
359
360
  * description: "Webhook that handles user creation events",
360
- * context: "This webhook processes new user registration events. " +
361
- * "It validates the user data and sends welcome emails.",
362
361
  * querySchema: z.object({
363
362
  * source: z.string().optional()
364
363
  * }),
@@ -371,7 +370,8 @@ export interface LuaWebhookConfig {
371
370
  * email: z.string().email(),
372
371
  * name: z.string()
373
372
  * }),
374
- * execute: async (query, headers, body) => {
373
+ * execute: async (event) => {
374
+ * const { query, headers, body } = event;
375
375
  * // Process the webhook...
376
376
  * console.log('New user:', body.email);
377
377
  * return { success: true, userId: body.userId };
@@ -388,9 +388,7 @@ export interface LuaWebhookConfig {
388
388
  */
389
389
  export declare class LuaWebhook {
390
390
  private readonly name;
391
- private readonly version;
392
391
  private readonly description;
393
- private readonly context;
394
392
  private readonly querySchema?;
395
393
  private readonly headerSchema?;
396
394
  private readonly bodySchema?;
@@ -400,9 +398,7 @@ export declare class LuaWebhook {
400
398
  *
401
399
  * @param config - Configuration object containing webhook metadata
402
400
  * @param config.name - Webhook name (optional, defaults to 'unnamed-webhook')
403
- * @param config.version - Webhook version (optional, defaults to '1.0.0')
404
401
  * @param config.description - Short description of what the webhook does (1-2 sentences)
405
- * @param config.context - Detailed explanation of the webhook's purpose and behavior
406
402
  * @param config.querySchema - Optional Zod schema for query parameter validation
407
403
  * @param config.headerSchema - Optional Zod schema for header validation
408
404
  * @param config.bodySchema - Optional Zod schema for body validation
@@ -413,18 +409,10 @@ export declare class LuaWebhook {
413
409
  * Gets the webhook name.
414
410
  */
415
411
  getName(): string;
416
- /**
417
- * Gets the webhook version.
418
- */
419
- getVersion(): string;
420
412
  /**
421
413
  * Gets the webhook description.
422
414
  */
423
415
  getDescription(): string;
424
- /**
425
- * Gets the webhook context.
426
- */
427
- getContext(): string;
428
416
  /**
429
417
  * Executes the webhook with validated input.
430
418
  * Validates query parameters, headers, and body against their respective schemas
@@ -447,18 +435,35 @@ export declare class LuaWebhook {
447
435
  */
448
436
  execute(query?: Record<string, any>, headers?: Record<string, any>, body?: any): Promise<any>;
449
437
  }
438
+ export type PreProcessorAction = 'proceed' | 'block';
439
+ export type PreProcessorBlockResponse = {
440
+ /** Stop processing immediately */
441
+ action: 'block';
442
+ /** Message to show to the user */
443
+ response: string;
444
+ /** Optional metadata */
445
+ metadata?: Record<string, any>;
446
+ };
447
+ export type PreProcessorProceedResponse = {
448
+ /** Proceed to next preprocessor or agent */
449
+ action: 'proceed';
450
+ /** Optional modified message (if not provided, uses original/current message) */
451
+ modifiedMessage?: import("../interfaces/chat.js").ChatMessage[];
452
+ /** Optional metadata to pass along */
453
+ metadata?: Record<string, any>;
454
+ };
455
+ /**
456
+ * Result returned by the preprocessor
457
+ */
458
+ export type PreProcessorResult = PreProcessorBlockResponse | PreProcessorProceedResponse;
450
459
  /**
451
460
  * PreProcessor configuration.
452
461
  */
453
462
  export interface PreProcessorConfig {
454
463
  /** PreProcessor name (optional, defaults to 'unnamed-preprocessor') */
455
464
  name?: string;
456
- /** PreProcessor version (optional, defaults to '1.0.0') */
457
- version?: string;
458
465
  /** Short description of the preprocessor */
459
466
  description: string;
460
- /** Detailed context for what this preprocessor does */
461
- context: string;
462
467
  /**
463
468
  * Async flag - indicates if processor should run in background on server:
464
469
  * - true: Run asynchronously (non-blocking, for slow operations like API calls)
@@ -466,11 +471,15 @@ export interface PreProcessorConfig {
466
471
  * Default: false (synchronous)
467
472
  */
468
473
  async?: boolean;
474
+ /**
475
+ * Execution priority (lower runs first).
476
+ * Default: 100
477
+ */
478
+ priority?: number;
469
479
  /**
470
480
  * Function that processes messages before sending to agent.
471
- * MUST return ChatMessage[] - array of text, image, or file messages.
472
481
  */
473
- execute: (user: UserDataInstance, messages: import("../interfaces/chat.js").ChatMessage[], channel: string) => Promise<import("../interfaces/chat.js").ChatMessage[]>;
482
+ execute: (user: UserDataInstance, messages: import("../interfaces/chat.js").ChatMessage[], channel: string) => Promise<PreProcessorResult>;
474
483
  }
475
484
  /**
476
485
  * PreProcessor class.
@@ -481,41 +490,46 @@ export interface PreProcessorConfig {
481
490
  * ```typescript
482
491
  * const contentFilter = new PreProcessor({
483
492
  * name: 'content-filter',
484
- * version: '1.0.0',
485
493
  * description: 'Filters and processes message content',
486
- * context: 'Filters spam, validates images, and adds context',
494
+ * priority: 10,
487
495
  * execute: async (user, messages, channel) => {
488
- * // Process each message
489
- * return messages.map(msg => {
490
- * if (msg.type === 'text') {
491
- * // Filter spam from text
492
- * const filtered = msg.text.replace(/spam/gi, '[filtered]');
493
- * return { type: 'text', text: filtered };
494
- * }
495
- * if (msg.type === 'image') {
496
- * // Could validate image, add watermark, etc.
497
- * return msg;
498
- * }
499
- * return msg;
500
- * });
496
+ * // Check for spam
497
+ * const hasSpam = messages.some(msg =>
498
+ * msg.type === 'text' && msg.text.includes('spam')
499
+ * );
500
+ *
501
+ * if (hasSpam) {
502
+ * return {
503
+ * action: 'block',
504
+ * response: "Message blocked due to spam content"
505
+ * };
506
+ * }
507
+ *
508
+ * // Return messages to proceed
509
+ * return { action: 'proceed' };
501
510
  * }
502
511
  * });
503
512
  * ```
504
513
  */
505
514
  export declare class PreProcessor {
506
515
  private readonly name;
507
- private readonly version;
508
516
  private readonly description;
509
- private readonly context;
510
517
  private readonly asyncMode;
518
+ private readonly priority;
511
519
  private readonly executeFunction;
512
520
  constructor(config: PreProcessorConfig);
513
521
  getName(): string;
514
- getVersion(): string;
515
522
  getDescription(): string;
516
- getContext(): string;
517
523
  getAsync(): boolean;
518
- execute(user: UserDataInstance, messages: import("../interfaces/chat.js").ChatMessage[], channel: string): Promise<import("../interfaces/chat.js").ChatMessage[]>;
524
+ getPriority(): number;
525
+ execute(user: UserDataInstance, messages: import("../interfaces/chat.js").ChatMessage[], channel: string): Promise<PreProcessorResult>;
526
+ }
527
+ /**
528
+ * PostProcessor response type.
529
+ * The execute function must return an object with the modified response.
530
+ */
531
+ export interface PostProcessorResponse {
532
+ modifiedResponse: string;
519
533
  }
520
534
  /**
521
535
  * PostProcessor configuration.
@@ -523,24 +537,13 @@ export declare class PreProcessor {
523
537
  export interface PostProcessorConfig {
524
538
  /** PostProcessor name (optional, defaults to 'unnamed-postprocessor') */
525
539
  name?: string;
526
- /** PostProcessor version (optional, defaults to '1.0.0') */
527
- version?: string;
528
540
  /** Short description of the postprocessor */
529
541
  description: string;
530
- /** Detailed context for what this postprocessor does */
531
- context: string;
532
- /**
533
- * Async flag - indicates if processor should run in background on server:
534
- * - true: Run asynchronously (non-blocking, for slow operations like API calls, translations)
535
- * - false: Run synchronously (blocking, for fast operations like text formatting)
536
- * Default: false (synchronous)
537
- */
538
- async?: boolean;
539
542
  /**
540
543
  * Function that processes the agent's response before sending to user.
541
- * MUST return string - the formatted response text.
544
+ * MUST return { modifiedResponse: string } - the formatted response text.
542
545
  */
543
- execute: (user: UserDataInstance, message: string, response: string, channel: string) => Promise<string>;
546
+ execute: (user: UserDataInstance, message: string, response: string, channel: string) => Promise<PostProcessorResponse>;
544
547
  }
545
548
  /**
546
549
  * PostProcessor class.
@@ -550,29 +553,105 @@ export interface PostProcessorConfig {
550
553
  * ```typescript
551
554
  * const responseFormatter = new PostProcessor({
552
555
  * name: 'response-formatter',
553
- * version: '1.0.0',
554
556
  * description: 'Formats responses with branding',
555
- * context: 'Adds company signature to all responses',
556
557
  * execute: async (user, message, response, channel) => {
557
- * return response + '\n\n---\nPowered by Acme Corp';
558
+ * return { modifiedResponse: response + '\n\n---\nPowered by Acme Corp' };
558
559
  * }
559
560
  * });
560
561
  * ```
561
562
  */
562
563
  export declare class PostProcessor {
563
564
  private readonly name;
564
- private readonly version;
565
565
  private readonly description;
566
- private readonly context;
567
- private readonly asyncMode;
568
566
  private readonly executeFunction;
569
567
  constructor(config: PostProcessorConfig);
570
568
  getName(): string;
571
- getVersion(): string;
572
569
  getDescription(): string;
573
- getContext(): string;
574
- getAsync(): boolean;
575
- execute(user: UserDataInstance, message: string, response: string, channel: string): Promise<string>;
570
+ execute(user: UserDataInstance, message: string, response: string, channel: string): Promise<PostProcessorResponse>;
571
+ }
572
+ /**
573
+ * MCP Server transport type - determines how to connect to the server.
574
+ */
575
+ export type MCPTransport = 'stdio' | 'sse';
576
+ /**
577
+ * Base configuration for all MCP servers.
578
+ */
579
+ export interface MCPServerBaseConfig {
580
+ /** Unique identifier for this MCP server */
581
+ name: string;
582
+ /** Optional timeout in milliseconds (default: 60000) */
583
+ timeout?: number;
584
+ }
585
+ /**
586
+ * Configuration for stdio-based MCP servers (local execution via npx, node, etc.)
587
+ */
588
+ export interface MCPStdioServerConfig extends MCPServerBaseConfig {
589
+ transport: 'stdio';
590
+ /** Command to execute (e.g., 'npx', 'node') */
591
+ command: string;
592
+ /** Arguments to pass to the command */
593
+ args?: string[];
594
+ /** Environment variables for the command */
595
+ env?: Record<string, string>;
596
+ }
597
+ /**
598
+ * Configuration for SSE/HTTP-based MCP servers (remote endpoints)
599
+ */
600
+ export interface MCPSSEServerConfig extends MCPServerBaseConfig {
601
+ transport: 'sse';
602
+ /** URL of the MCP server endpoint */
603
+ url: string;
604
+ /** Optional headers to send with requests (e.g., Authorization) */
605
+ headers?: Record<string, string>;
606
+ }
607
+ /**
608
+ * Union type for all MCP server configurations.
609
+ */
610
+ export type LuaMCPServerConfig = MCPStdioServerConfig | MCPSSEServerConfig;
611
+ /**
612
+ * LuaMCPServer class.
613
+ * Defines an MCP (Model Context Protocol) server connection.
614
+ *
615
+ * MCP servers provide tools that can be used by your agent at runtime.
616
+ * You can connect to local servers (via stdio) or remote servers (via SSE/HTTP).
617
+ *
618
+ * @example
619
+ * ```typescript
620
+ * import { LuaMCPServer } from 'lua-cli';
621
+ *
622
+ * // Local MCP server via npx
623
+ * const wikipediaServer = new LuaMCPServer({
624
+ * name: 'wikipedia',
625
+ * transport: 'stdio',
626
+ * command: 'npx',
627
+ * args: ['-y', 'wikipedia-mcp'],
628
+ * description: 'Wikipedia search and retrieval'
629
+ * });
630
+ *
631
+ * // Remote MCP server via SSE
632
+ * const weatherServer = new LuaMCPServer({
633
+ * name: 'weather',
634
+ * transport: 'sse',
635
+ * url: 'https://api.example.com/mcp',
636
+ * headers: {
637
+ * 'Authorization': 'Bearer ${env.WEATHER_API_KEY}'
638
+ * },
639
+ * description: 'Weather information service'
640
+ * });
641
+ * ```
642
+ */
643
+ export declare class LuaMCPServer {
644
+ private readonly config;
645
+ constructor(config: LuaMCPServerConfig);
646
+ getName(): string;
647
+ getTransport(): MCPTransport;
648
+ getTimeout(): number | undefined;
649
+ getConfig(): LuaMCPServerConfig;
650
+ /**
651
+ * Returns the server configuration in a format suitable for serialization.
652
+ * Environment variable references (${env.VAR_NAME}) are preserved for runtime resolution.
653
+ */
654
+ toJSON(): Record<string, any>;
576
655
  }
577
656
  /**
578
657
  * LuaAgent configuration interface.
@@ -587,8 +666,6 @@ export interface LuaAgentConfig {
587
666
  name: string;
588
667
  /** Agent persona - defines the agent's behavior and personality */
589
668
  persona: string;
590
- /** Optional welcome message shown when users first interact */
591
- welcomeMessage?: string;
592
669
  /** Array of skills (each with tools) */
593
670
  skills?: LuaSkill[];
594
671
  /** Array of webhooks */
@@ -599,6 +676,8 @@ export interface LuaAgentConfig {
599
676
  preProcessors?: PreProcessor[];
600
677
  /** Array of postprocessors (run after agent generates responses) */
601
678
  postProcessors?: PostProcessor[];
679
+ /** Array of MCP servers (Model Context Protocol) for external tool integrations */
680
+ mcpServers?: LuaMCPServer[];
602
681
  }
603
682
  /**
604
683
  * LuaAgent class.
@@ -620,7 +699,6 @@ export interface LuaAgentConfig {
620
699
  * export const agent = new LuaAgent({
621
700
  * name: 'my-assistant',
622
701
  * persona: 'You are a helpful AI assistant that can manage users and products.',
623
- * welcomeMessage: 'Hello! How can I help you today?',
624
702
  * skills: [userSkill],
625
703
  * jobs: [healthCheckJob],
626
704
  * webhooks: [webhookHandler],
@@ -632,32 +710,32 @@ export interface LuaAgentConfig {
632
710
  export declare class LuaAgent {
633
711
  private readonly name;
634
712
  private readonly persona;
635
- private readonly welcomeMessage?;
636
713
  private readonly skills;
637
714
  private readonly webhooks;
638
715
  private readonly jobs;
639
716
  private readonly preProcessors;
640
717
  private readonly postProcessors;
718
+ private readonly mcpServers;
641
719
  /**
642
720
  * Creates a new LuaAgent instance.
643
721
  *
644
722
  * @param config - Agent configuration
645
723
  * @param config.name - Agent name
646
724
  * @param config.persona - Agent persona (behavior and personality)
647
- * @param config.welcomeMessage - Optional welcome message
648
725
  * @param config.skills - Optional array of skills
649
726
  * @param config.webhooks - Optional array of webhooks
650
727
  * @param config.jobs - Optional array of jobs
651
728
  * @param config.preProcessors - Optional array of preprocessors
652
729
  * @param config.postProcessors - Optional array of postprocessors
730
+ * @param config.mcpServers - Optional array of MCP servers
653
731
  */
654
732
  constructor(config: LuaAgentConfig);
655
733
  getName(): string;
656
734
  getPersona(): string;
657
- getWelcomeMessage(): string | undefined;
658
735
  getSkills(): LuaSkill[];
659
736
  getWebhooks(): LuaWebhook[];
660
737
  getJobs(): LuaJob[];
661
738
  getPreProcessors(): PreProcessor[];
662
739
  getPostProcessors(): PostProcessor[];
740
+ getMCPServers(): LuaMCPServer[];
663
741
  }