lua-cli 3.1.0-alpha.4 → 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 (97) hide show
  1. package/dist/api/cdn.api.service.d.ts +18 -0
  2. package/dist/api/cdn.api.service.js +43 -0
  3. package/dist/api/custom.data.api.service.d.ts +4 -3
  4. package/dist/api/custom.data.api.service.js +4 -3
  5. package/dist/api/developer.api.service.d.ts +54 -1
  6. package/dist/api/developer.api.service.js +89 -0
  7. package/dist/api/job.api.service.d.ts +10 -0
  8. package/dist/api/job.api.service.js +14 -0
  9. package/dist/api/lazy-instances.d.ts +8 -0
  10. package/dist/api/lazy-instances.js +16 -0
  11. package/dist/api/postprocessor.api.service.d.ts +3 -6
  12. package/dist/api/postprocessor.api.service.js +2 -3
  13. package/dist/api-exports.d.ts +74 -6
  14. package/dist/api-exports.js +87 -7
  15. package/dist/cli/command-definitions.js +34 -7
  16. package/dist/commands/admin.js +1 -1
  17. package/dist/commands/channels.js +1 -1
  18. package/dist/commands/compile.js +23 -4
  19. package/dist/commands/evals.d.ts +8 -0
  20. package/dist/commands/evals.js +41 -0
  21. package/dist/commands/index.d.ts +2 -0
  22. package/dist/commands/index.js +2 -0
  23. package/dist/commands/init.d.ts +10 -1
  24. package/dist/commands/init.js +13 -3
  25. package/dist/commands/mcp.d.ts +18 -0
  26. package/dist/commands/mcp.js +393 -0
  27. package/dist/commands/push.js +172 -14
  28. package/dist/common/data.entry.instance.d.ts +1 -1
  29. package/dist/common/data.entry.instance.js +4 -4
  30. package/dist/common/job.instance.d.ts +24 -0
  31. package/dist/common/job.instance.js +38 -0
  32. package/dist/config/constants.d.ts +1 -0
  33. package/dist/config/constants.js +1 -0
  34. package/dist/index.js +1 -0
  35. package/dist/interfaces/cdn.d.ts +24 -0
  36. package/dist/interfaces/cdn.js +5 -0
  37. package/dist/interfaces/compile.d.ts +1 -0
  38. package/dist/interfaces/custom.data.d.ts +3 -3
  39. package/dist/interfaces/index.d.ts +1 -0
  40. package/dist/interfaces/mcp.d.ts +64 -0
  41. package/dist/interfaces/mcp.js +5 -0
  42. package/dist/types/api-contracts.d.ts +36 -14
  43. package/dist/types/compile.types.d.ts +5 -0
  44. package/dist/types/index.d.ts +2 -2
  45. package/dist/types/index.js +3 -1
  46. package/dist/types/skill.d.ts +120 -13
  47. package/dist/types/skill.js +95 -5
  48. package/dist/utils/bundling.d.ts +4 -11
  49. package/dist/utils/bundling.js +19 -27
  50. package/dist/utils/compile.d.ts +17 -8
  51. package/dist/utils/compile.js +71 -37
  52. package/dist/utils/deployment.js +13 -6
  53. package/dist/utils/dev-api.js +1 -2
  54. package/dist/utils/dev-server.js +1 -1
  55. package/dist/utils/files.d.ts +8 -1
  56. package/dist/utils/files.js +13 -2
  57. package/dist/utils/init-helpers.d.ts +3 -1
  58. package/dist/utils/init-helpers.js +7 -2
  59. package/dist/utils/mcp-server-management.d.ts +23 -0
  60. package/dist/utils/mcp-server-management.js +212 -0
  61. package/dist/utils/sandbox.d.ts +4 -2
  62. package/dist/utils/sandbox.js +22 -3
  63. package/dist/web/app.css +1505 -14
  64. package/dist/web/app.js +79 -64
  65. package/package.json +2 -6
  66. package/template/QUICKSTART.md +57 -761
  67. package/template/README.md +80 -906
  68. package/template/examples/README.md +106 -0
  69. package/template/{src → examples}/jobs/AbandonedBasketProcessorJob.ts +67 -11
  70. package/template/{src → examples}/postprocessors/modifyResponse.ts +3 -3
  71. package/template/{src → examples}/skills/tools/GameScoreTrackerTool.ts +11 -15
  72. package/template/{src → examples}/skills/tools/OrderTool.ts +25 -0
  73. package/template/examples/skills/tools/PremiumFeatureTool.ts +98 -0
  74. package/template/{src → examples}/skills/tools/UserDataTool.ts +34 -0
  75. package/template/examples/webhooks/FileUploadWebhook.ts +86 -0
  76. package/template/package-lock.json +7895 -0
  77. package/template/package.json +1 -1
  78. package/template/src/index.ts +40 -22
  79. /package/template/{src → examples}/jobs/DailyCleanupJob.ts +0 -0
  80. /package/template/{src → examples}/jobs/DataMigrationJob.ts +0 -0
  81. /package/template/{src → examples}/jobs/HealthCheckJob.ts +0 -0
  82. /package/template/{src → examples}/preprocessors/messageMatching.ts +0 -0
  83. /package/template/{src → examples}/services/ApiService.ts +0 -0
  84. /package/template/{src → examples}/services/GetWeather.ts +0 -0
  85. /package/template/{src → examples}/skills/basket.skill.ts +0 -0
  86. /package/template/{src → examples}/skills/product.skill.ts +0 -0
  87. /package/template/{src → examples}/skills/tools/BasketTool.ts +0 -0
  88. /package/template/{src → examples}/skills/tools/CreateInlineJob.ts +0 -0
  89. /package/template/{src → examples}/skills/tools/CreatePostTool.ts +0 -0
  90. /package/template/{src → examples}/skills/tools/CustomDataTool.ts +0 -0
  91. /package/template/{src → examples}/skills/tools/GetWeatherTool.ts +0 -0
  92. /package/template/{src → examples}/skills/tools/PaymentTool.ts +0 -0
  93. /package/template/{src → examples}/skills/tools/ProductsTool.ts +0 -0
  94. /package/template/{src → examples}/skills/tools/SmartBasketTool.ts +0 -0
  95. /package/template/{src → examples}/skills/user.skill.ts +0 -0
  96. /package/template/{src → examples}/webhooks/PaymentWebhook.ts +0 -0
  97. /package/template/{src → examples}/webhooks/UserEventWebhook.ts +0 -0
@@ -122,12 +122,12 @@ export default class DataEntryInstance {
122
122
  */
123
123
  async update(data, searchText) {
124
124
  try {
125
- const response = await this.customDataAPI.update(this.collectionName, this.id, { data, searchText });
125
+ await this.customDataAPI.update(this.collectionName, this.id, data, searchText);
126
126
  this.data = { ...this.data, ...data };
127
127
  return this.data;
128
128
  }
129
129
  catch (error) {
130
- throw new Error('Failed to update user data');
130
+ throw new Error('Failed to update custom data entry');
131
131
  }
132
132
  }
133
133
  /**
@@ -141,7 +141,7 @@ export default class DataEntryInstance {
141
141
  return true;
142
142
  }
143
143
  catch (error) {
144
- throw new Error('Failed to clear user data');
144
+ throw new Error('Failed to delete custom data entry');
145
145
  }
146
146
  }
147
147
  /**
@@ -152,7 +152,7 @@ export default class DataEntryInstance {
152
152
  */
153
153
  async save(searchText) {
154
154
  try {
155
- await this.customDataAPI.update(this.collectionName, this.id, { data: this.data, searchText: searchText });
155
+ await this.customDataAPI.update(this.collectionName, this.id, this.data, searchText);
156
156
  return true;
157
157
  }
158
158
  catch (error) {
@@ -101,6 +101,30 @@ export declare class JobInstance {
101
101
  * ```
102
102
  */
103
103
  trigger(versionId?: string): Promise<JobExecution>;
104
+ /**
105
+ * Activates the job, enabling it to run on schedule.
106
+ *
107
+ * @returns Promise resolving to updated JobInstance
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * await job.activate();
112
+ * console.log('Job is now active');
113
+ * ```
114
+ */
115
+ activate(): Promise<JobInstance>;
116
+ /**
117
+ * Deactivates the job, preventing it from running on schedule.
118
+ *
119
+ * @returns Promise resolving to updated JobInstance
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * await job.deactivate();
124
+ * console.log('Job is now inactive');
125
+ * ```
126
+ */
127
+ deactivate(): Promise<JobInstance>;
104
128
  /**
105
129
  * Converts the job instance to JSON.
106
130
  */
@@ -126,6 +126,44 @@ export class JobInstance {
126
126
  }
127
127
  return result.data;
128
128
  }
129
+ /**
130
+ * Activates the job, enabling it to run on schedule.
131
+ *
132
+ * @returns Promise resolving to updated JobInstance
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * await job.activate();
137
+ * console.log('Job is now active');
138
+ * ```
139
+ */
140
+ async activate() {
141
+ const result = await this.jobApi.activateJob(this.id);
142
+ if (!result.success || !result.data) {
143
+ throw new Error(result.error?.message || 'Failed to activate job');
144
+ }
145
+ this._data = result.data;
146
+ return this;
147
+ }
148
+ /**
149
+ * Deactivates the job, preventing it from running on schedule.
150
+ *
151
+ * @returns Promise resolving to updated JobInstance
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * await job.deactivate();
156
+ * console.log('Job is now inactive');
157
+ * ```
158
+ */
159
+ async deactivate() {
160
+ const result = await this.jobApi.deactivateJob(this.id);
161
+ if (!result.success || !result.data) {
162
+ throw new Error(result.error?.message || 'Failed to deactivate job');
163
+ }
164
+ this._data = result.data;
165
+ return this;
166
+ }
129
167
  /**
130
168
  * Converts the job instance to JSON.
131
169
  */
@@ -9,4 +9,5 @@ export declare const BASE_URLS: {
9
9
  readonly AUTH: "https://auth.heylua.ai";
10
10
  readonly CHAT: "https://api.heylua.ai";
11
11
  readonly WEBHOOK: "https://webhook.heylua.ai";
12
+ readonly CDN: "https://cdn.heylua.ai";
12
13
  };
@@ -15,4 +15,5 @@ export const BASE_URLS = {
15
15
  AUTH: 'https://auth.heylua.ai',
16
16
  CHAT: 'https://api.heylua.ai',
17
17
  WEBHOOK: 'https://webhook.heylua.ai',
18
+ CDN: 'https://cdn.heylua.ai',
18
19
  };
package/dist/index.js CHANGED
@@ -61,6 +61,7 @@ Examples:
61
61
  $ lua skills production ⚙️ Manage production skills directly
62
62
  $ lua features 🎯 Manage agent features
63
63
  $ lua admin 🔧 Open admin dashboard
64
+ $ lua evals 📊 Open evaluations dashboard
64
65
  $ lua docs 📖 Open documentation
65
66
  $ lua completion 🎯 Enable shell autocomplete
66
67
  $ lua marketplace 🛍️ Interact with the Lua Marketplace
@@ -0,0 +1,24 @@
1
+ /**
2
+ * CDN Interfaces
3
+ * Types for CDN asset upload and retrieval operations
4
+ */
5
+ /**
6
+ * Internal response from the CDN upload endpoint
7
+ * @internal
8
+ */
9
+ export interface CdnUploadResponse {
10
+ fileId: string;
11
+ mediaType: string;
12
+ extension: string;
13
+ originalFilename?: string;
14
+ compression?: CompressionStats;
15
+ }
16
+ /**
17
+ * Compression statistics for an uploaded asset
18
+ * @internal
19
+ */
20
+ export interface CompressionStats {
21
+ original: number;
22
+ compressed: number;
23
+ ratio: number;
24
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * CDN Interfaces
3
+ * Types for CDN asset upload and retrieval operations
4
+ */
5
+ export {};
@@ -8,4 +8,5 @@ export interface ToolInfo {
8
8
  description?: string;
9
9
  inputSchema?: any;
10
10
  executeCode?: string;
11
+ conditionCode?: string;
11
12
  }
@@ -14,7 +14,7 @@ import { Pagination, TimestampedEntity, IdentifiedEntity } from './common.js';
14
14
  */
15
15
  export interface CustomDataEntry extends IdentifiedEntity, TimestampedEntity {
16
16
  id: string;
17
- data: any;
17
+ data: Record<string, any>;
18
18
  createdAt: number;
19
19
  updatedAt: number;
20
20
  searchText?: string;
@@ -31,7 +31,7 @@ export interface CustomDataEntry extends IdentifiedEntity, TimestampedEntity {
31
31
  * ```
32
32
  */
33
33
  export interface CreateCustomDataRequest {
34
- data: any;
34
+ data: Record<string, any>;
35
35
  searchText?: string;
36
36
  }
37
37
  /**
@@ -53,7 +53,7 @@ export interface GetCustomDataResponse {
53
53
  * Request to update a custom data entry.
54
54
  */
55
55
  export interface UpdateCustomDataRequest {
56
- data: any;
56
+ data: Record<string, any>;
57
57
  searchText?: string;
58
58
  }
59
59
  /**
@@ -9,3 +9,4 @@ export { CreateJobDTO, PushJobVersionDTO, UpdateJobVersionDTO, JobSchedule, JobS
9
9
  export { ApiResponse, Pagination } from "./common.js";
10
10
  export { SkillTool, SkillVersion, Skill, GetSkillsResponse, DeleteSkillResponse, } from "./skills.js";
11
11
  export { ImmutableUserProfile, UserAgentData } from "./user.js";
12
+ export { MCPServerResponse, MCPServerStdioResponse, MCPServerSSEResponse, CreateMCPServerRequest, UpdateMCPServerRequest, } from "./mcp.js";
@@ -0,0 +1,64 @@
1
+ /**
2
+ * MCP Server Interfaces
3
+ * API request/response types for MCP server management
4
+ */
5
+ /**
6
+ * Base MCP Server response fields
7
+ */
8
+ interface MCPServerResponseBase {
9
+ id: string;
10
+ name: string;
11
+ agentId: string;
12
+ active: boolean;
13
+ timeout?: number;
14
+ createdAt: string;
15
+ updatedAt: string;
16
+ }
17
+ /**
18
+ * MCP Server response for stdio transport
19
+ */
20
+ export interface MCPServerStdioResponse extends MCPServerResponseBase {
21
+ transport: 'stdio';
22
+ command: string;
23
+ args?: string[];
24
+ env?: Record<string, string>;
25
+ }
26
+ /**
27
+ * MCP Server response for SSE transport
28
+ */
29
+ export interface MCPServerSSEResponse extends MCPServerResponseBase {
30
+ transport: 'sse';
31
+ url: string;
32
+ headers?: Record<string, string>;
33
+ }
34
+ /**
35
+ * Union type for MCP Server API responses
36
+ */
37
+ export type MCPServerResponse = MCPServerStdioResponse | MCPServerSSEResponse;
38
+ /**
39
+ * Request payload for creating an MCP server
40
+ */
41
+ export interface CreateMCPServerRequest {
42
+ name: string;
43
+ transport: 'stdio' | 'sse';
44
+ command?: string;
45
+ args?: string[];
46
+ env?: Record<string, string>;
47
+ url?: string;
48
+ headers?: Record<string, string>;
49
+ timeout?: number;
50
+ }
51
+ /**
52
+ * Request payload for updating an MCP server
53
+ */
54
+ export interface UpdateMCPServerRequest {
55
+ name?: string;
56
+ transport?: 'stdio' | 'sse';
57
+ command?: string;
58
+ args?: string[];
59
+ env?: Record<string, string>;
60
+ url?: string;
61
+ headers?: Record<string, string>;
62
+ timeout?: number;
63
+ }
64
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * MCP Server Interfaces
3
+ * API request/response types for MCP server management
4
+ */
5
+ export {};
@@ -1,4 +1,6 @@
1
1
  import { Message } from "../interfaces/message.js";
2
+ import { GetCustomDataResponse, UpdateCustomDataResponse, DeleteCustomDataResponse } from "../interfaces/custom.data.js";
3
+ import DataEntryInstance from "../common/data.entry.instance.js";
2
4
  /**
3
5
  * API Contract Interfaces
4
6
  * TypeScript interfaces that API service classes must implement
@@ -178,50 +180,52 @@ export interface CustomDataAPI {
178
180
  /**
179
181
  * Creates a new entry in a custom data collection.
180
182
  * @param collectionName - Collection name
181
- * @param data - Data to store
182
- * @returns Promise resolving to created entry
183
+ * @param data - Data object to store
184
+ * @param searchText - Optional text for vector search indexing
185
+ * @returns Promise resolving to created entry (DataEntryInstance)
183
186
  */
184
- create(collectionName: string, data: any): Promise<any>;
187
+ create(collectionName: string, data: Record<string, any>, searchText?: string): Promise<DataEntryInstance>;
185
188
  /**
186
189
  * Gets entries from a collection with filtering and pagination.
187
190
  * @param collectionName - Collection name
188
191
  * @param filter - Optional filter criteria
189
192
  * @param page - Page number
190
193
  * @param limit - Items per page
191
- * @returns Promise resolving to entries
194
+ * @returns Promise resolving to paginated entries
192
195
  */
193
- get(collectionName: string, filter?: any, page?: number, limit?: number): Promise<any>;
196
+ get(collectionName: string, filter?: Record<string, any>, page?: number, limit?: number): Promise<GetCustomDataResponse>;
194
197
  /**
195
198
  * Gets a specific entry by ID.
196
199
  * @param collectionName - Collection name
197
200
  * @param entryId - Entry ID
198
- * @returns Promise resolving to entry data
201
+ * @returns Promise resolving to entry (DataEntryInstance)
199
202
  */
200
- getEntry(collectionName: string, entryId: string): Promise<any>;
203
+ getEntry(collectionName: string, entryId: string): Promise<DataEntryInstance>;
201
204
  /**
202
205
  * Updates an existing entry.
203
206
  * @param collectionName - Collection name
204
207
  * @param entryId - Entry ID
205
- * @param data - Updated data
206
- * @returns Promise resolving to updated entry
208
+ * @param data - Data object to update
209
+ * @param searchText - Optional text for vector search indexing
210
+ * @returns Promise resolving to update response
207
211
  */
208
- update(collectionName: string, entryId: string, data: any): Promise<any>;
212
+ update(collectionName: string, entryId: string, data: Record<string, any>, searchText?: string): Promise<UpdateCustomDataResponse>;
209
213
  /**
210
214
  * Performs vector search on a collection.
211
215
  * @param collectionName - Collection name
212
216
  * @param searchText - Text to search for
213
217
  * @param limit - Maximum results
214
218
  * @param scoreThreshold - Minimum similarity score
215
- * @returns Promise resolving to search results
219
+ * @returns Promise resolving to array of matching entries (DataEntryInstance[])
216
220
  */
217
- search(collectionName: string, searchText: string, limit?: number, scoreThreshold?: number): Promise<any>;
221
+ search(collectionName: string, searchText: string, limit?: number, scoreThreshold?: number): Promise<DataEntryInstance[]>;
218
222
  /**
219
223
  * Deletes an entry from a collection.
220
224
  * @param collectionName - Collection name
221
225
  * @param entryId - Entry ID to delete
222
- * @returns Promise resolving when deletion is complete
226
+ * @returns Promise resolving to delete response
223
227
  */
224
- delete(collectionName: string, entryId: string): Promise<any>;
228
+ delete(collectionName: string, entryId: string): Promise<DeleteCustomDataResponse>;
225
229
  }
226
230
  /**
227
231
  * WhatsApp Templates API contract.
@@ -255,3 +259,21 @@ export interface WhatsAppTemplatesAPI {
255
259
  */
256
260
  send(channelId: string, templateId: string, data: any): Promise<any>;
257
261
  }
262
+ /**
263
+ * CDN API contract.
264
+ * Defines operations for uploading and retrieving files from the CDN.
265
+ */
266
+ export interface CdnAPI {
267
+ /**
268
+ * Uploads a file to the CDN.
269
+ * @param file - The File object to upload
270
+ * @returns Promise resolving to the file ID
271
+ */
272
+ upload(file: File): Promise<string>;
273
+ /**
274
+ * Retrieves a file from the CDN by its ID.
275
+ * @param fileId - The unique identifier of the file
276
+ * @returns Promise resolving to a File object
277
+ */
278
+ get(fileId: string): Promise<File>;
279
+ }
@@ -81,6 +81,10 @@ export interface YamlConfigPostprocessor {
81
81
  version: string;
82
82
  postprocessorId: string;
83
83
  }
84
+ export interface YamlConfigMCPServer {
85
+ name: string;
86
+ mcpServerId: string;
87
+ }
84
88
  export interface YamlConfig {
85
89
  skill?: LegacyYamlConfigSkill;
86
90
  agent?: YamlConfigAgent;
@@ -89,6 +93,7 @@ export interface YamlConfig {
89
93
  jobs?: YamlConfigJob[];
90
94
  preprocessors?: YamlConfigPreprocessor[];
91
95
  postprocessors?: YamlConfigPostprocessor[];
96
+ mcpServers?: YamlConfigMCPServer[];
92
97
  }
93
98
  /**
94
99
  * Deployment data format for new deployment system
@@ -14,9 +14,9 @@
14
14
  * import { validateToolName } from './types/tool-validation.js';
15
15
  * ```
16
16
  */
17
- export { LuaSkill, LuaTool, LuaSkillConfig, LuaWebhook, LuaWebhookConfig, LuaJob, LuaJobConfig, JobSchedule, env } from './skill.js';
17
+ export { LuaSkill, LuaTool, LuaSkillConfig, LuaWebhook, LuaWebhookConfig, LuaJob, LuaJobConfig, JobSchedule, env, LuaMCPServer, LuaMCPServerConfig, MCPStdioServerConfig, MCPSSEServerConfig, MCPTransport, MCPServerBaseConfig, } from './skill.js';
18
18
  export { validateToolName, assertValidToolName } from './tool-validation.js';
19
- export { UserDataAPI, ProductAPI, BasketAPI, OrderAPI, CustomDataAPI, WhatsAppTemplatesAPI } from './api-contracts.js';
19
+ export { UserDataAPI, ProductAPI, BasketAPI, OrderAPI, CustomDataAPI, WhatsAppTemplatesAPI, CdnAPI } from './api-contracts.js';
20
20
  export { UserData, EmailAddress, Country, Admin, Organization, AgentAuth, OTPResponse, ApiKeyResponse } from '../interfaces/admin.js';
21
21
  export { Agent, AgentType, CreateAgentRequest, CreateAgentResponse, AgentDetailsResponse } from '../interfaces/agent.js';
22
22
  export { BasketStatus, BasketItem, Basket } from '../interfaces/baskets.js';
@@ -18,7 +18,9 @@
18
18
  // SKILL SYSTEM EXPORTS
19
19
  // ============================================================================
20
20
  // Core skill classes and utilities
21
- export { LuaSkill, LuaWebhook, LuaJob, env } from './skill.js';
21
+ export { LuaSkill, LuaWebhook, LuaJob, env,
22
+ // MCP Server config types (for defining servers)
23
+ LuaMCPServer, } from './skill.js';
22
24
  // Tool validation utilities
23
25
  export { validateToolName, assertValidToolName } from './tool-validation.js';
24
26
  // Basket types
@@ -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.
@@ -504,6 +524,13 @@ export declare class PreProcessor {
504
524
  getPriority(): number;
505
525
  execute(user: UserDataInstance, messages: import("../interfaces/chat.js").ChatMessage[], channel: string): Promise<PreProcessorResult>;
506
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;
533
+ }
507
534
  /**
508
535
  * PostProcessor configuration.
509
536
  */
@@ -512,18 +539,11 @@ export interface PostProcessorConfig {
512
539
  name?: string;
513
540
  /** Short description of the postprocessor */
514
541
  description: string;
515
- /**
516
- * Async flag - indicates if processor should run in background on server:
517
- * - true: Run asynchronously (non-blocking, for slow operations like API calls, translations)
518
- * - false: Run synchronously (blocking, for fast operations like text formatting)
519
- * Default: false (synchronous)
520
- */
521
- async?: boolean;
522
542
  /**
523
543
  * Function that processes the agent's response before sending to user.
524
- * MUST return string - the formatted response text.
544
+ * MUST return { modifiedResponse: string } - the formatted response text.
525
545
  */
526
- execute: (user: UserDataInstance, message: string, response: string, channel: string) => Promise<string>;
546
+ execute: (user: UserDataInstance, message: string, response: string, channel: string) => Promise<PostProcessorResponse>;
527
547
  }
528
548
  /**
529
549
  * PostProcessor class.
@@ -535,7 +555,7 @@ export interface PostProcessorConfig {
535
555
  * name: 'response-formatter',
536
556
  * description: 'Formats responses with branding',
537
557
  * execute: async (user, message, response, channel) => {
538
- * return response + '\n\n---\nPowered by Acme Corp';
558
+ * return { modifiedResponse: response + '\n\n---\nPowered by Acme Corp' };
539
559
  * }
540
560
  * });
541
561
  * ```
@@ -543,13 +563,95 @@ export interface PostProcessorConfig {
543
563
  export declare class PostProcessor {
544
564
  private readonly name;
545
565
  private readonly description;
546
- private readonly asyncMode;
547
566
  private readonly executeFunction;
548
567
  constructor(config: PostProcessorConfig);
549
568
  getName(): string;
550
569
  getDescription(): string;
551
- getAsync(): boolean;
552
- 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>;
553
655
  }
554
656
  /**
555
657
  * LuaAgent configuration interface.
@@ -574,6 +676,8 @@ export interface LuaAgentConfig {
574
676
  preProcessors?: PreProcessor[];
575
677
  /** Array of postprocessors (run after agent generates responses) */
576
678
  postProcessors?: PostProcessor[];
679
+ /** Array of MCP servers (Model Context Protocol) for external tool integrations */
680
+ mcpServers?: LuaMCPServer[];
577
681
  }
578
682
  /**
579
683
  * LuaAgent class.
@@ -611,6 +715,7 @@ export declare class LuaAgent {
611
715
  private readonly jobs;
612
716
  private readonly preProcessors;
613
717
  private readonly postProcessors;
718
+ private readonly mcpServers;
614
719
  /**
615
720
  * Creates a new LuaAgent instance.
616
721
  *
@@ -622,6 +727,7 @@ export declare class LuaAgent {
622
727
  * @param config.jobs - Optional array of jobs
623
728
  * @param config.preProcessors - Optional array of preprocessors
624
729
  * @param config.postProcessors - Optional array of postprocessors
730
+ * @param config.mcpServers - Optional array of MCP servers
625
731
  */
626
732
  constructor(config: LuaAgentConfig);
627
733
  getName(): string;
@@ -631,4 +737,5 @@ export declare class LuaAgent {
631
737
  getJobs(): LuaJob[];
632
738
  getPreProcessors(): PreProcessor[];
633
739
  getPostProcessors(): PostProcessor[];
740
+ getMCPServers(): LuaMCPServer[];
634
741
  }