lua-cli 2.5.7 → 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/agent.api.service.d.ts +45 -0
- package/dist/api/agent.api.service.js +54 -0
- package/dist/api/job.api.service.d.ts +210 -0
- package/dist/api/job.api.service.js +200 -0
- package/dist/api/lazy-instances.d.ts +24 -0
- package/dist/api/lazy-instances.js +48 -0
- package/dist/api/postprocessor.api.service.d.ts +98 -0
- package/dist/api/postprocessor.api.service.js +76 -0
- package/dist/api/preprocessor.api.service.d.ts +98 -0
- package/dist/api/preprocessor.api.service.js +76 -0
- package/dist/api/user.data.api.service.d.ts +28 -0
- package/dist/api/user.data.api.service.js +51 -0
- package/dist/api/webhook.api.service.d.ts +151 -0
- package/dist/api/webhook.api.service.js +134 -0
- package/dist/api-exports.d.ts +156 -41
- package/dist/api-exports.js +182 -21
- package/dist/cli/command-definitions.js +149 -7
- package/dist/commands/compile.js +124 -5
- package/dist/commands/completion.d.ts +11 -0
- package/dist/commands/completion.js +209 -0
- package/dist/commands/env.d.ts +3 -2
- package/dist/commands/env.js +42 -17
- package/dist/commands/features.d.ts +16 -0
- package/dist/commands/features.js +352 -0
- package/dist/commands/index.d.ts +7 -0
- package/dist/commands/index.js +7 -0
- package/dist/commands/init.js +53 -7
- package/dist/commands/jobs.d.ts +20 -0
- package/dist/commands/jobs.js +533 -0
- package/dist/commands/logs.js +2 -5
- package/dist/commands/persona.d.ts +3 -2
- package/dist/commands/persona.js +43 -18
- package/dist/commands/postprocessors.d.ts +8 -0
- package/dist/commands/postprocessors.js +431 -0
- package/dist/commands/preprocessors.d.ts +8 -0
- package/dist/commands/preprocessors.js +431 -0
- package/dist/commands/push.d.ts +9 -13
- package/dist/commands/push.js +937 -69
- package/dist/commands/skills.d.ts +16 -0
- package/dist/commands/skills.js +438 -0
- package/dist/commands/test.d.ts +9 -18
- package/dist/commands/test.js +558 -82
- package/dist/commands/webhooks.d.ts +18 -0
- package/dist/commands/webhooks.js +424 -0
- package/dist/common/data.entry.instance.d.ts +7 -0
- package/dist/common/data.entry.instance.js +15 -0
- package/dist/common/job.instance.d.ts +77 -0
- package/dist/common/job.instance.js +108 -0
- package/dist/common/order.instance.d.ts +6 -0
- package/dist/common/order.instance.js +14 -0
- package/dist/common/product.instance.d.ts +6 -0
- package/dist/common/product.instance.js +14 -0
- package/dist/common/user.instance.d.ts +15 -0
- package/dist/common/user.instance.js +38 -0
- package/dist/config/constants.d.ts +2 -2
- package/dist/config/constants.js +4 -4
- package/dist/index.js +14 -3
- package/dist/interfaces/agent.d.ts +33 -1
- package/dist/interfaces/chat.d.ts +22 -0
- package/dist/interfaces/index.d.ts +10 -0
- package/dist/interfaces/index.js +7 -0
- package/dist/interfaces/jobs.d.ts +172 -0
- package/dist/interfaces/jobs.js +5 -0
- package/dist/interfaces/message.d.ts +18 -0
- package/dist/interfaces/message.js +1 -0
- package/dist/interfaces/postprocessors.d.ts +35 -0
- package/dist/interfaces/postprocessors.js +4 -0
- package/dist/interfaces/preprocessors.d.ts +35 -0
- package/dist/interfaces/preprocessors.js +4 -0
- package/dist/interfaces/webhooks.d.ts +104 -0
- package/dist/interfaces/webhooks.js +5 -0
- package/dist/types/api-contracts.d.ts +14 -0
- package/dist/types/api-contracts.js +0 -7
- package/dist/types/compile.types.d.ts +49 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/skill.d.ts +502 -0
- package/dist/types/skill.js +477 -0
- package/dist/utils/agent-management.d.ts +25 -0
- package/dist/utils/agent-management.js +67 -0
- package/dist/utils/bundling.d.ts +31 -1
- package/dist/utils/bundling.js +653 -10
- package/dist/utils/compile.d.ts +63 -0
- package/dist/utils/compile.js +691 -36
- package/dist/utils/deployment.d.ts +2 -1
- package/dist/utils/deployment.js +16 -2
- package/dist/utils/init-agent.d.ts +3 -1
- package/dist/utils/init-agent.js +6 -4
- package/dist/utils/init-prompts.d.ts +2 -1
- package/dist/utils/init-prompts.js +14 -9
- package/dist/utils/job-management.d.ts +24 -0
- package/dist/utils/job-management.js +264 -0
- package/dist/utils/postprocessor-management.d.ts +9 -0
- package/dist/utils/postprocessor-management.js +118 -0
- package/dist/utils/preprocessor-management.d.ts +9 -0
- package/dist/utils/preprocessor-management.js +118 -0
- package/dist/utils/sandbox.d.ts +61 -1
- package/dist/utils/sandbox.js +283 -72
- package/dist/utils/tool-detection.d.ts +3 -2
- package/dist/utils/tool-detection.js +18 -4
- package/dist/utils/webhook-management.d.ts +24 -0
- package/dist/utils/webhook-management.js +256 -0
- package/dist/web/app.css +152 -736
- package/dist/web/app.js +45 -45
- package/package.json +2 -2
- package/template/AGENT_CONFIGURATION.md +251 -0
- package/template/COMPLEX_JOB_EXAMPLES.md +795 -0
- package/template/DYNAMIC_JOB_CREATION.md +371 -0
- package/template/README.md +30 -2
- package/template/WEBHOOKS_JOBS_QUICKSTART.md +318 -0
- package/template/WEBHOOK_JOB_EXAMPLES.md +817 -0
- package/template/package.json +1 -1
- package/template/src/index-agent-example.ts +201 -0
- package/template/src/index.ts +39 -0
- package/template/src/jobs/AbandonedBasketProcessorJob.ts +139 -0
- package/template/src/jobs/DailyCleanupJob.ts +100 -0
- package/template/src/jobs/DataMigrationJob.ts +133 -0
- package/template/src/jobs/HealthCheckJob.ts +87 -0
- package/template/src/postprocessors/ResponseFormatter.ts +151 -0
- package/template/src/preprocessors/MessageFilter.ts +91 -0
- package/template/src/tools/GameScoreTrackerTool.ts +356 -0
- package/template/src/tools/SmartBasketTool.ts +188 -0
- package/template/src/webhooks/PaymentWebhook.ts +113 -0
- package/template/src/webhooks/UserEventWebhook.ts +77 -0
|
@@ -20,6 +20,30 @@ export interface SkillMetadata {
|
|
|
20
20
|
context: string;
|
|
21
21
|
constructorTools: string[];
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Webhook metadata extracted from source code
|
|
25
|
+
*/
|
|
26
|
+
export interface WebhookMetadata {
|
|
27
|
+
name: string;
|
|
28
|
+
version: string;
|
|
29
|
+
description: string;
|
|
30
|
+
context: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Job metadata extracted from source code
|
|
34
|
+
*/
|
|
35
|
+
export interface JobMetadata {
|
|
36
|
+
name: string;
|
|
37
|
+
version: string;
|
|
38
|
+
description: string;
|
|
39
|
+
context: string;
|
|
40
|
+
schedule: any;
|
|
41
|
+
timeout?: number;
|
|
42
|
+
retry?: {
|
|
43
|
+
maxAttempts: number;
|
|
44
|
+
backoffSeconds?: number;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
23
47
|
/**
|
|
24
48
|
* Configuration from lua.skill.yaml
|
|
25
49
|
*/
|
|
@@ -30,15 +54,40 @@ export interface SkillConfig {
|
|
|
30
54
|
skillId?: string;
|
|
31
55
|
description?: string;
|
|
32
56
|
context?: string;
|
|
57
|
+
env?: Record<string, string>;
|
|
33
58
|
};
|
|
34
59
|
agent?: {
|
|
35
60
|
agentId?: string;
|
|
61
|
+
orgId?: string;
|
|
62
|
+
persona?: string;
|
|
63
|
+
welcomeMessage?: string;
|
|
36
64
|
};
|
|
37
65
|
skills?: Array<{
|
|
38
66
|
name: string;
|
|
39
67
|
version: string;
|
|
40
68
|
skillId: string;
|
|
41
69
|
}>;
|
|
70
|
+
webhooks?: Array<{
|
|
71
|
+
name: string;
|
|
72
|
+
version: string;
|
|
73
|
+
webhookId: string;
|
|
74
|
+
}>;
|
|
75
|
+
jobs?: Array<{
|
|
76
|
+
name: string;
|
|
77
|
+
version: string;
|
|
78
|
+
jobId: string;
|
|
79
|
+
schedule?: any;
|
|
80
|
+
}>;
|
|
81
|
+
preprocessors?: Array<{
|
|
82
|
+
name: string;
|
|
83
|
+
version: string;
|
|
84
|
+
preprocessorId: string;
|
|
85
|
+
}>;
|
|
86
|
+
postprocessors?: Array<{
|
|
87
|
+
name: string;
|
|
88
|
+
version: string;
|
|
89
|
+
postprocessorId: string;
|
|
90
|
+
}>;
|
|
42
91
|
}
|
|
43
92
|
/**
|
|
44
93
|
* Deployment data format for new deployment system
|
package/dist/types/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* import { validateToolName } from './types/tool-validation.js';
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
export { LuaSkill, LuaTool, LuaSkillConfig, env } from './skill.js';
|
|
17
|
+
export { LuaSkill, LuaTool, LuaSkillConfig, LuaWebhook, LuaWebhookConfig, LuaJob, LuaJobConfig, JobSchedule, env } from './skill.js';
|
|
18
18
|
export { validateToolName, assertValidToolName } from './tool-validation.js';
|
|
19
19
|
export { UserDataAPI, ProductAPI, BasketAPI, OrderAPI, CustomDataAPI } from './api-contracts.js';
|
|
20
20
|
export { UserData, EmailAddress, Country, Admin, Organization, AgentAuth, OTPResponse, ApiKeyResponse } from '../interfaces/admin.js';
|
package/dist/types/index.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// SKILL SYSTEM EXPORTS
|
|
19
19
|
// ============================================================================
|
|
20
20
|
// Core skill classes and utilities
|
|
21
|
-
export { LuaSkill, env } from './skill.js';
|
|
21
|
+
export { LuaSkill, LuaWebhook, LuaJob, env } from './skill.js';
|
|
22
22
|
// Tool validation utilities
|
|
23
23
|
export { validateToolName, assertValidToolName } from './tool-validation.js';
|
|
24
24
|
// Basket types
|
package/dist/types/skill.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Core types and classes for building Lua AI skills
|
|
4
4
|
*/
|
|
5
5
|
import { ZodType } from "zod";
|
|
6
|
+
import UserDataInstance from "../common/user.instance.js";
|
|
6
7
|
/**
|
|
7
8
|
* Safe environment variable access function.
|
|
8
9
|
* Gets injected at runtime with skill-specific environment variables.
|
|
@@ -140,3 +141,504 @@ export declare class LuaSkill {
|
|
|
140
141
|
*/
|
|
141
142
|
run(input: Record<string, any>): Promise<any>;
|
|
142
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Job schedule configuration
|
|
146
|
+
* Supports either cron-style recurring schedules or one-time execution
|
|
147
|
+
*/
|
|
148
|
+
export type JobSchedule = {
|
|
149
|
+
type: 'cron';
|
|
150
|
+
expression: string;
|
|
151
|
+
timezone?: string;
|
|
152
|
+
} | {
|
|
153
|
+
type: 'once';
|
|
154
|
+
executeAt: Date | string;
|
|
155
|
+
} | {
|
|
156
|
+
type: 'interval';
|
|
157
|
+
seconds: number;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Lua Job configuration.
|
|
161
|
+
* Used to initialize a new LuaJob instance.
|
|
162
|
+
*/
|
|
163
|
+
export interface LuaJobConfig {
|
|
164
|
+
/** Job name (optional, defaults to 'unnamed-job') */
|
|
165
|
+
name?: string;
|
|
166
|
+
/** Job version (optional, defaults to '1.0.0') */
|
|
167
|
+
version?: string;
|
|
168
|
+
/** Short description of the job (1-2 sentences) */
|
|
169
|
+
description: string;
|
|
170
|
+
/** Detailed context for what this job does */
|
|
171
|
+
context: string;
|
|
172
|
+
/** Schedule configuration - cron, once, or interval */
|
|
173
|
+
schedule: JobSchedule;
|
|
174
|
+
/** Function that executes the job logic - receives job instance as parameter */
|
|
175
|
+
execute: (job?: any) => Promise<any>;
|
|
176
|
+
/** Optional timeout in seconds (default: 300) */
|
|
177
|
+
timeout?: number;
|
|
178
|
+
/** Optional retry configuration */
|
|
179
|
+
retry?: {
|
|
180
|
+
maxAttempts: number;
|
|
181
|
+
backoffSeconds?: number;
|
|
182
|
+
};
|
|
183
|
+
/** Optional metadata for the job */
|
|
184
|
+
metadata?: Record<string, any>;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Lua Job class.
|
|
188
|
+
* Main class for building scheduled jobs (cron jobs, one-time tasks, intervals).
|
|
189
|
+
*
|
|
190
|
+
* A job is a scheduled task that executes at specific times or intervals.
|
|
191
|
+
* Jobs can run once, on a recurring schedule (cron), or at fixed intervals.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* import { LuaJob } from 'lua-cli';
|
|
196
|
+
*
|
|
197
|
+
* // Daily cleanup job at 2 AM
|
|
198
|
+
* const dailyCleanup = new LuaJob({
|
|
199
|
+
* name: 'daily-cleanup',
|
|
200
|
+
* version: '1.0.0',
|
|
201
|
+
* description: "Daily database cleanup job",
|
|
202
|
+
* context: "Runs at 2 AM daily to clean up old records and optimize tables.",
|
|
203
|
+
* schedule: {
|
|
204
|
+
* type: 'cron',
|
|
205
|
+
* expression: '0 2 * * *', // 2 AM every day
|
|
206
|
+
* timezone: 'America/New_York'
|
|
207
|
+
* },
|
|
208
|
+
* timeout: 600, // 10 minutes
|
|
209
|
+
* retry: {
|
|
210
|
+
* maxAttempts: 3,
|
|
211
|
+
* backoffSeconds: 60
|
|
212
|
+
* },
|
|
213
|
+
* execute: async () => {
|
|
214
|
+
* // Cleanup logic
|
|
215
|
+
* console.log('Running cleanup...');
|
|
216
|
+
* return { recordsDeleted: 150 };
|
|
217
|
+
* }
|
|
218
|
+
* });
|
|
219
|
+
*
|
|
220
|
+
* // One-time job
|
|
221
|
+
* const sendWelcome = new LuaJob({
|
|
222
|
+
* name: 'send-welcome',
|
|
223
|
+
* version: '1.0.0',
|
|
224
|
+
* description: "Send welcome email to new users",
|
|
225
|
+
* context: "Scheduled one-time task to send welcome emails.",
|
|
226
|
+
* schedule: {
|
|
227
|
+
* type: 'once',
|
|
228
|
+
* executeAt: new Date('2025-12-31T10:00:00Z')
|
|
229
|
+
* },
|
|
230
|
+
* execute: async () => {
|
|
231
|
+
* console.log('Sending welcome emails...');
|
|
232
|
+
* return { emailsSent: 100 };
|
|
233
|
+
* }
|
|
234
|
+
* });
|
|
235
|
+
*
|
|
236
|
+
* // Interval-based job (every 5 minutes)
|
|
237
|
+
* const healthCheck = new LuaJob({
|
|
238
|
+
* name: 'health-check',
|
|
239
|
+
* version: '1.0.0',
|
|
240
|
+
* description: "System health check",
|
|
241
|
+
* context: "Runs every 5 minutes to check system health.",
|
|
242
|
+
* schedule: {
|
|
243
|
+
* type: 'interval',
|
|
244
|
+
* seconds: 300 // 5 minutes
|
|
245
|
+
* },
|
|
246
|
+
* execute: async () => {
|
|
247
|
+
* return { status: 'healthy' };
|
|
248
|
+
* }
|
|
249
|
+
* });
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
export declare class LuaJob {
|
|
253
|
+
private readonly name;
|
|
254
|
+
private readonly version;
|
|
255
|
+
private readonly description;
|
|
256
|
+
private readonly context;
|
|
257
|
+
private readonly schedule;
|
|
258
|
+
private readonly timeout;
|
|
259
|
+
private readonly retry?;
|
|
260
|
+
private readonly metadata?;
|
|
261
|
+
private readonly executeFunction;
|
|
262
|
+
/**
|
|
263
|
+
* Creates a new LuaJob instance.
|
|
264
|
+
*
|
|
265
|
+
* @param config - Configuration object containing job metadata
|
|
266
|
+
* @param config.name - Job name (optional, defaults to 'unnamed-job')
|
|
267
|
+
* @param config.version - Job version (optional, defaults to '1.0.0')
|
|
268
|
+
* @param config.description - Short description of what the job does (1-2 sentences)
|
|
269
|
+
* @param config.context - Detailed explanation of the job's purpose
|
|
270
|
+
* @param config.schedule - Schedule configuration (cron, once, or interval)
|
|
271
|
+
* @param config.timeout - Optional timeout in seconds (default: 300)
|
|
272
|
+
* @param config.retry - Optional retry configuration
|
|
273
|
+
* @param config.metadata - Optional metadata for the job
|
|
274
|
+
* @param config.execute - Function that processes the job (receives job instance as parameter)
|
|
275
|
+
*/
|
|
276
|
+
constructor(config: LuaJobConfig);
|
|
277
|
+
/**
|
|
278
|
+
* Gets the job name.
|
|
279
|
+
*/
|
|
280
|
+
getName(): string;
|
|
281
|
+
/**
|
|
282
|
+
* Gets the job version.
|
|
283
|
+
*/
|
|
284
|
+
getVersion(): string;
|
|
285
|
+
/**
|
|
286
|
+
* Gets the job description.
|
|
287
|
+
*/
|
|
288
|
+
getDescription(): string;
|
|
289
|
+
/**
|
|
290
|
+
* Gets the job context.
|
|
291
|
+
*/
|
|
292
|
+
getContext(): string;
|
|
293
|
+
/**
|
|
294
|
+
* Gets the job schedule.
|
|
295
|
+
*/
|
|
296
|
+
getSchedule(): JobSchedule;
|
|
297
|
+
/**
|
|
298
|
+
* Gets the job timeout in seconds.
|
|
299
|
+
*/
|
|
300
|
+
getTimeout(): number;
|
|
301
|
+
/**
|
|
302
|
+
* Gets the retry configuration.
|
|
303
|
+
*/
|
|
304
|
+
getRetry(): {
|
|
305
|
+
maxAttempts: number;
|
|
306
|
+
backoffSeconds?: number;
|
|
307
|
+
} | undefined;
|
|
308
|
+
/**
|
|
309
|
+
* Gets the job metadata.
|
|
310
|
+
*/
|
|
311
|
+
getMetadata(): Record<string, any> | undefined;
|
|
312
|
+
/**
|
|
313
|
+
* Executes the job.
|
|
314
|
+
* This is called by the scheduler at the appropriate time.
|
|
315
|
+
*
|
|
316
|
+
* @returns Promise resolving to job execution result
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```typescript
|
|
320
|
+
* const result = await job.execute();
|
|
321
|
+
* console.log('Job completed:', result);
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
execute(): Promise<any>;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Lua Webhook configuration.
|
|
328
|
+
* Used to initialize a new LuaWebhook instance.
|
|
329
|
+
*/
|
|
330
|
+
export interface LuaWebhookConfig {
|
|
331
|
+
/** Webhook name (optional, defaults to 'unnamed-webhook') */
|
|
332
|
+
name?: string;
|
|
333
|
+
/** Webhook version (optional, defaults to '1.0.0') */
|
|
334
|
+
version?: string;
|
|
335
|
+
/** Short description of the webhook (1-2 sentences) */
|
|
336
|
+
description: string;
|
|
337
|
+
/** Detailed context for what this webhook does and how it should be used */
|
|
338
|
+
context: string;
|
|
339
|
+
/** Optional Zod schema for query parameter validation */
|
|
340
|
+
querySchema?: ZodType;
|
|
341
|
+
/** Optional Zod schema for header validation */
|
|
342
|
+
headerSchema?: ZodType;
|
|
343
|
+
/** Optional Zod schema for body validation */
|
|
344
|
+
bodySchema?: ZodType;
|
|
345
|
+
/** Function that executes the webhook logic */
|
|
346
|
+
execute: (input: {
|
|
347
|
+
query?: any;
|
|
348
|
+
headers?: any;
|
|
349
|
+
body?: any;
|
|
350
|
+
}) => Promise<any>;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Lua Webhook class.
|
|
354
|
+
* Main class for building webhooks with validated inputs.
|
|
355
|
+
*
|
|
356
|
+
* A webhook is an HTTP endpoint that can receive requests with validated
|
|
357
|
+
* query parameters, headers, and body. The execute function processes the
|
|
358
|
+
* validated input and returns a response.
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```typescript
|
|
362
|
+
* import { LuaWebhook } from 'lua-cli';
|
|
363
|
+
* import { z } from 'zod';
|
|
364
|
+
*
|
|
365
|
+
* const webhook = new LuaWebhook({
|
|
366
|
+
* name: 'user-created',
|
|
367
|
+
* version: '1.0.0',
|
|
368
|
+
* description: "Webhook that handles user creation events",
|
|
369
|
+
* context: "This webhook processes new user registration events. " +
|
|
370
|
+
* "It validates the user data and sends welcome emails.",
|
|
371
|
+
* querySchema: z.object({
|
|
372
|
+
* source: z.string().optional()
|
|
373
|
+
* }),
|
|
374
|
+
* headerSchema: z.object({
|
|
375
|
+
* 'x-api-key': z.string(),
|
|
376
|
+
* 'content-type': z.string().optional()
|
|
377
|
+
* }),
|
|
378
|
+
* bodySchema: z.object({
|
|
379
|
+
* userId: z.string(),
|
|
380
|
+
* email: z.string().email(),
|
|
381
|
+
* name: z.string()
|
|
382
|
+
* }),
|
|
383
|
+
* execute: async ({ query, headers, body }) => {
|
|
384
|
+
* // Process the webhook...
|
|
385
|
+
* console.log('New user:', body.email);
|
|
386
|
+
* return { success: true, userId: body.userId };
|
|
387
|
+
* }
|
|
388
|
+
* });
|
|
389
|
+
*
|
|
390
|
+
* // Execute the webhook with validated input
|
|
391
|
+
* const result = await webhook.execute({
|
|
392
|
+
* query: { source: 'mobile' },
|
|
393
|
+
* headers: { 'x-api-key': 'secret-key' },
|
|
394
|
+
* body: { userId: '123', email: 'user@example.com', name: 'John' }
|
|
395
|
+
* });
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
398
|
+
export declare class LuaWebhook {
|
|
399
|
+
private readonly name;
|
|
400
|
+
private readonly version;
|
|
401
|
+
private readonly description;
|
|
402
|
+
private readonly context;
|
|
403
|
+
private readonly querySchema?;
|
|
404
|
+
private readonly headerSchema?;
|
|
405
|
+
private readonly bodySchema?;
|
|
406
|
+
private readonly executeFunction;
|
|
407
|
+
/**
|
|
408
|
+
* Creates a new LuaWebhook instance.
|
|
409
|
+
*
|
|
410
|
+
* @param config - Configuration object containing webhook metadata
|
|
411
|
+
* @param config.name - Webhook name (optional, defaults to 'unnamed-webhook')
|
|
412
|
+
* @param config.version - Webhook version (optional, defaults to '1.0.0')
|
|
413
|
+
* @param config.description - Short description of what the webhook does (1-2 sentences)
|
|
414
|
+
* @param config.context - Detailed explanation of the webhook's purpose and behavior
|
|
415
|
+
* @param config.querySchema - Optional Zod schema for query parameter validation
|
|
416
|
+
* @param config.headerSchema - Optional Zod schema for header validation
|
|
417
|
+
* @param config.bodySchema - Optional Zod schema for body validation
|
|
418
|
+
* @param config.execute - Function that processes the webhook request
|
|
419
|
+
*/
|
|
420
|
+
constructor(config: LuaWebhookConfig);
|
|
421
|
+
/**
|
|
422
|
+
* Gets the webhook name.
|
|
423
|
+
*/
|
|
424
|
+
getName(): string;
|
|
425
|
+
/**
|
|
426
|
+
* Gets the webhook version.
|
|
427
|
+
*/
|
|
428
|
+
getVersion(): string;
|
|
429
|
+
/**
|
|
430
|
+
* Gets the webhook description.
|
|
431
|
+
*/
|
|
432
|
+
getDescription(): string;
|
|
433
|
+
/**
|
|
434
|
+
* Gets the webhook context.
|
|
435
|
+
*/
|
|
436
|
+
getContext(): string;
|
|
437
|
+
/**
|
|
438
|
+
* Executes the webhook with validated input.
|
|
439
|
+
* Validates query parameters, headers, and body against their respective schemas
|
|
440
|
+
* before executing the webhook function.
|
|
441
|
+
*
|
|
442
|
+
* @param input - Input object containing query, headers, and/or body
|
|
443
|
+
* @param input.query - Query parameters object
|
|
444
|
+
* @param input.headers - Headers object
|
|
445
|
+
* @param input.body - Request body
|
|
446
|
+
* @returns Promise resolving to webhook execution result
|
|
447
|
+
* @throws Error if validation fails for any input
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
* ```typescript
|
|
451
|
+
* const result = await webhook.execute({
|
|
452
|
+
* query: { limit: '10' },
|
|
453
|
+
* headers: { 'x-api-key': 'secret' },
|
|
454
|
+
* body: { data: 'value' }
|
|
455
|
+
* });
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
execute(input: {
|
|
459
|
+
query?: Record<string, any>;
|
|
460
|
+
headers?: Record<string, any>;
|
|
461
|
+
body?: any;
|
|
462
|
+
}): Promise<any>;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* PreProcessor configuration.
|
|
466
|
+
*/
|
|
467
|
+
export interface PreProcessorConfig {
|
|
468
|
+
/** PreProcessor name (optional, defaults to 'unnamed-preprocessor') */
|
|
469
|
+
name?: string;
|
|
470
|
+
/** PreProcessor version (optional, defaults to '1.0.0') */
|
|
471
|
+
version?: string;
|
|
472
|
+
/** Short description of the preprocessor */
|
|
473
|
+
description: string;
|
|
474
|
+
/** Detailed context for what this preprocessor does */
|
|
475
|
+
context: string;
|
|
476
|
+
/** Function that processes the message before sending to agent */
|
|
477
|
+
execute: (user: UserDataInstance, message: string, channel: string) => Promise<string>;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* PreProcessor class.
|
|
481
|
+
* Processes user messages before they reach the agent.
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
* ```typescript
|
|
485
|
+
* const languageDetector = new PreProcessor({
|
|
486
|
+
* name: 'language-detector',
|
|
487
|
+
* version: '1.0.0',
|
|
488
|
+
* description: 'Detects and translates messages',
|
|
489
|
+
* context: 'Detects language and translates to English if needed',
|
|
490
|
+
* execute: async (user, message, channel) => {
|
|
491
|
+
* const language = await detectLanguage(message);
|
|
492
|
+
* if (language !== 'en') {
|
|
493
|
+
* return await translate(message, 'en');
|
|
494
|
+
* }
|
|
495
|
+
* return message;
|
|
496
|
+
* }
|
|
497
|
+
* });
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
500
|
+
export declare class PreProcessor {
|
|
501
|
+
private readonly name;
|
|
502
|
+
private readonly version;
|
|
503
|
+
private readonly description;
|
|
504
|
+
private readonly context;
|
|
505
|
+
private readonly executeFunction;
|
|
506
|
+
constructor(config: PreProcessorConfig);
|
|
507
|
+
getName(): string;
|
|
508
|
+
getVersion(): string;
|
|
509
|
+
getDescription(): string;
|
|
510
|
+
getContext(): string;
|
|
511
|
+
execute(user: UserDataInstance, message: string, channel: string): Promise<string>;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* PostProcessor configuration.
|
|
515
|
+
*/
|
|
516
|
+
export interface PostProcessorConfig {
|
|
517
|
+
/** PostProcessor name (optional, defaults to 'unnamed-postprocessor') */
|
|
518
|
+
name?: string;
|
|
519
|
+
/** PostProcessor version (optional, defaults to '1.0.0') */
|
|
520
|
+
version?: string;
|
|
521
|
+
/** Short description of the postprocessor */
|
|
522
|
+
description: string;
|
|
523
|
+
/** Detailed context for what this postprocessor does */
|
|
524
|
+
context: string;
|
|
525
|
+
/** Function that processes the agent's response before sending to user */
|
|
526
|
+
execute: (user: UserDataInstance, message: string, response: string, channel: string) => Promise<string>;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* PostProcessor class.
|
|
530
|
+
* Processes agent responses before they reach the user.
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* ```typescript
|
|
534
|
+
* const responseFormatter = new PostProcessor({
|
|
535
|
+
* name: 'response-formatter',
|
|
536
|
+
* version: '1.0.0',
|
|
537
|
+
* description: 'Formats responses with branding',
|
|
538
|
+
* context: 'Adds company signature to all responses',
|
|
539
|
+
* execute: async (user, message, response, channel) => {
|
|
540
|
+
* return response + '\n\n---\nPowered by Acme Corp';
|
|
541
|
+
* }
|
|
542
|
+
* });
|
|
543
|
+
* ```
|
|
544
|
+
*/
|
|
545
|
+
export declare class PostProcessor {
|
|
546
|
+
private readonly name;
|
|
547
|
+
private readonly version;
|
|
548
|
+
private readonly description;
|
|
549
|
+
private readonly context;
|
|
550
|
+
private readonly executeFunction;
|
|
551
|
+
constructor(config: PostProcessorConfig);
|
|
552
|
+
getName(): string;
|
|
553
|
+
getVersion(): string;
|
|
554
|
+
getDescription(): string;
|
|
555
|
+
getContext(): string;
|
|
556
|
+
execute(user: UserDataInstance, message: string, response: string, channel: string): Promise<string>;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* LuaAgent configuration interface.
|
|
560
|
+
* Provides a simplified, unified way to configure an agent with all its components.
|
|
561
|
+
*
|
|
562
|
+
* This is the recommended approach for defining your agent. Instead of exporting
|
|
563
|
+
* individual skills, jobs, webhooks, etc., you export a single LuaAgent object
|
|
564
|
+
* that contains everything.
|
|
565
|
+
*/
|
|
566
|
+
export interface LuaAgentConfig {
|
|
567
|
+
/** Agent name (used for identification) */
|
|
568
|
+
name: string;
|
|
569
|
+
/** Agent persona - defines the agent's behavior and personality */
|
|
570
|
+
persona: string;
|
|
571
|
+
/** Optional welcome message shown when users first interact */
|
|
572
|
+
welcomeMessage?: string;
|
|
573
|
+
/** Array of skills (each with tools) */
|
|
574
|
+
skills?: LuaSkill[];
|
|
575
|
+
/** Array of webhooks */
|
|
576
|
+
webhooks?: LuaWebhook[];
|
|
577
|
+
/** Array of scheduled jobs */
|
|
578
|
+
jobs?: LuaJob[];
|
|
579
|
+
/** Array of preprocessors (run before messages reach the agent) */
|
|
580
|
+
preProcessors?: PreProcessor[];
|
|
581
|
+
/** Array of postprocessors (run after agent generates responses) */
|
|
582
|
+
postProcessors?: PostProcessor[];
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* LuaAgent class.
|
|
586
|
+
* Unified agent configuration that consolidates skills, webhooks, jobs, and processors.
|
|
587
|
+
*
|
|
588
|
+
* This is the simplest way to define an agent. Instead of exporting multiple separate
|
|
589
|
+
* components, you create one LuaAgent that contains everything.
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
* ```typescript
|
|
593
|
+
* import { LuaAgent, LuaSkill, LuaJob, LuaWebhook } from 'lua-cli';
|
|
594
|
+
*
|
|
595
|
+
* // Define your skills, jobs, webhooks in separate files
|
|
596
|
+
* import { userSkill } from './skills/user-skill';
|
|
597
|
+
* import { healthCheckJob } from './jobs/health-check';
|
|
598
|
+
* import { webhookHandler } from './webhooks/handler';
|
|
599
|
+
*
|
|
600
|
+
* // Create a single agent configuration
|
|
601
|
+
* export const agent = new LuaAgent({
|
|
602
|
+
* name: 'my-assistant',
|
|
603
|
+
* persona: 'You are a helpful AI assistant that can manage users and products.',
|
|
604
|
+
* welcomeMessage: 'Hello! How can I help you today?',
|
|
605
|
+
* skills: [userSkill],
|
|
606
|
+
* jobs: [healthCheckJob],
|
|
607
|
+
* webhooks: [webhookHandler],
|
|
608
|
+
* preProcessors: [],
|
|
609
|
+
* postProcessors: []
|
|
610
|
+
* });
|
|
611
|
+
* ```
|
|
612
|
+
*/
|
|
613
|
+
export declare class LuaAgent {
|
|
614
|
+
private readonly name;
|
|
615
|
+
private readonly persona;
|
|
616
|
+
private readonly welcomeMessage?;
|
|
617
|
+
private readonly skills;
|
|
618
|
+
private readonly webhooks;
|
|
619
|
+
private readonly jobs;
|
|
620
|
+
private readonly preProcessors;
|
|
621
|
+
private readonly postProcessors;
|
|
622
|
+
/**
|
|
623
|
+
* Creates a new LuaAgent instance.
|
|
624
|
+
*
|
|
625
|
+
* @param config - Agent configuration
|
|
626
|
+
* @param config.name - Agent name
|
|
627
|
+
* @param config.persona - Agent persona (behavior and personality)
|
|
628
|
+
* @param config.welcomeMessage - Optional welcome message
|
|
629
|
+
* @param config.skills - Optional array of skills
|
|
630
|
+
* @param config.webhooks - Optional array of webhooks
|
|
631
|
+
* @param config.jobs - Optional array of jobs
|
|
632
|
+
* @param config.preProcessors - Optional array of preprocessors
|
|
633
|
+
* @param config.postProcessors - Optional array of postprocessors
|
|
634
|
+
*/
|
|
635
|
+
constructor(config: LuaAgentConfig);
|
|
636
|
+
getName(): string;
|
|
637
|
+
getPersona(): string;
|
|
638
|
+
getWelcomeMessage(): string | undefined;
|
|
639
|
+
getSkills(): LuaSkill[];
|
|
640
|
+
getWebhooks(): LuaWebhook[];
|
|
641
|
+
getJobs(): LuaJob[];
|
|
642
|
+
getPreProcessors(): PreProcessor[];
|
|
643
|
+
getPostProcessors(): PostProcessor[];
|
|
644
|
+
}
|