lua-cli 2.5.8 → 3.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/job.api.service.d.ts +219 -0
- package/dist/api/job.api.service.js +216 -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 +158 -0
- package/dist/api/postprocessor.api.service.js +111 -0
- package/dist/api/preprocessor.api.service.d.ts +158 -0
- package/dist/api/preprocessor.api.service.js +111 -0
- package/dist/api/user.data.api.service.d.ts +13 -0
- package/dist/api/user.data.api.service.js +20 -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 +176 -41
- package/dist/api-exports.js +195 -21
- package/dist/cli/command-definitions.js +75 -5
- package/dist/commands/chat.js +32 -5
- package/dist/commands/compile.js +140 -7
- package/dist/commands/dev.js +23 -2
- package/dist/commands/index.d.ts +4 -0
- package/dist/commands/index.js +4 -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/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.js +686 -5
- package/dist/commands/test.d.ts +9 -18
- package/dist/commands/test.js +574 -82
- package/dist/commands/webhooks.d.ts +18 -0
- package/dist/commands/webhooks.js +424 -0
- package/dist/common/job.instance.d.ts +80 -0
- package/dist/common/job.instance.js +116 -0
- package/dist/common/user.instance.d.ts +1 -0
- package/dist/common/user.instance.js +9 -0
- package/dist/config/constants.d.ts +4 -3
- package/dist/config/constants.js +10 -8
- package/dist/interfaces/agent.d.ts +2 -1
- package/dist/interfaces/chat.d.ts +52 -1
- package/dist/interfaces/index.d.ts +10 -0
- package/dist/interfaces/index.js +7 -0
- package/dist/interfaces/jobs.d.ts +193 -0
- package/dist/interfaces/jobs.js +5 -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 +5 -0
- 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 +521 -0
- package/dist/types/skill.js +471 -0
- package/dist/utils/agent-management.d.ts +25 -0
- package/dist/utils/agent-management.js +67 -0
- package/dist/utils/bundling.d.ts +44 -5
- package/dist/utils/bundling.js +723 -23
- package/dist/utils/compile.d.ts +63 -0
- package/dist/utils/compile.js +712 -36
- package/dist/utils/deployment.d.ts +2 -1
- package/dist/utils/deployment.js +16 -2
- package/dist/utils/dev-api.d.ts +42 -2
- package/dist/utils/dev-api.js +177 -4
- package/dist/utils/dev-server.d.ts +1 -1
- package/dist/utils/dev-server.js +4 -4
- package/dist/utils/dynamic-job-bundler.d.ts +17 -0
- package/dist/utils/dynamic-job-bundler.js +143 -0
- package/dist/utils/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/pre-bundle-jobs.d.ts +26 -0
- package/dist/utils/pre-bundle-jobs.js +176 -0
- package/dist/utils/preprocessor-management.d.ts +9 -0
- package/dist/utils/preprocessor-management.js +118 -0
- package/dist/utils/sandbox-storage.d.ts +48 -0
- package/dist/utils/sandbox-storage.js +114 -0
- package/dist/utils/sandbox.d.ts +61 -1
- package/dist/utils/sandbox.js +299 -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/package.json +1 -1
- package/template/README.md +30 -2
- package/template/lua.skill.yaml +47 -0
- package/template/package-lock.json +10505 -0
- package/template/package.json +2 -1
- package/template/src/index.ts +103 -2
- 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/tools/CreateInlineJob.ts +42 -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
- package/API_REFERENCE.md +0 -1408
- package/CHANGELOG.md +0 -236
- package/CLI_REFERENCE.md +0 -908
- package/GETTING_STARTED.md +0 -1040
- package/INSTANCE_TYPES.md +0 -1158
- package/README.md +0 -865
- package/TEMPLATE_GUIDE.md +0 -1398
- package/USER_DATA_INSTANCE.md +0 -621
- package/template/TOOL_EXAMPLES.md +0 -655
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User Event Webhook Example
|
|
3
|
+
*
|
|
4
|
+
* This webhook receives user events from external systems (e.g., CRM, marketing tools).
|
|
5
|
+
* It validates incoming data and stores events for processing.
|
|
6
|
+
*
|
|
7
|
+
* Webhook URL: {API_URL}/webhooks/{agentId}/{webhookId}
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { LuaWebhook, Data } from "lua-cli";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
|
|
13
|
+
const userEventWebhook = new LuaWebhook({
|
|
14
|
+
name: "user-events",
|
|
15
|
+
version: "1.0.0",
|
|
16
|
+
description: "Receives user events from external systems",
|
|
17
|
+
context: "This webhook handles user registration, profile updates, and deletion events. " +
|
|
18
|
+
"It validates the incoming data, stores events in the database, and can trigger follow-up actions.",
|
|
19
|
+
|
|
20
|
+
// Validate query parameters (optional source tracking)
|
|
21
|
+
querySchema: z.object({
|
|
22
|
+
source: z.string().optional(),
|
|
23
|
+
version: z.string().optional()
|
|
24
|
+
}),
|
|
25
|
+
|
|
26
|
+
// Validate headers (require API key for security)
|
|
27
|
+
headerSchema: z.object({
|
|
28
|
+
'x-api-key': z.string(),
|
|
29
|
+
'content-type': z.string().optional()
|
|
30
|
+
}),
|
|
31
|
+
|
|
32
|
+
// Validate request body
|
|
33
|
+
bodySchema: z.object({
|
|
34
|
+
eventType: z.enum(['signup', 'update', 'delete']),
|
|
35
|
+
userId: z.string(),
|
|
36
|
+
email: z.string().email(),
|
|
37
|
+
name: z.string().optional(),
|
|
38
|
+
metadata: z.record(z.any()).optional(),
|
|
39
|
+
timestamp: z.string()
|
|
40
|
+
}),
|
|
41
|
+
|
|
42
|
+
execute: async ({ query, headers, body }) => {
|
|
43
|
+
console.log(`📥 Received ${body.eventType} event for user:`, body.email);
|
|
44
|
+
console.log(`📍 Source:`, query?.source || 'unknown');
|
|
45
|
+
|
|
46
|
+
// Security: Validate API key (in production, use env variable)
|
|
47
|
+
const expectedKey = process.env.WEBHOOK_API_KEY || 'your-secret-key';
|
|
48
|
+
if (headers['x-api-key'] !== expectedKey) {
|
|
49
|
+
throw new Error('Invalid API key');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Store the event in custom data collection
|
|
53
|
+
const eventData = {
|
|
54
|
+
...body,
|
|
55
|
+
source: query?.source,
|
|
56
|
+
receivedAt: new Date().toISOString(),
|
|
57
|
+
processed: false
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const result = await Data.create('user-events', eventData,
|
|
61
|
+
`${body.eventType} ${body.email} ${body.name || ''}`
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
console.log('✅ Event stored successfully:', result.id);
|
|
65
|
+
|
|
66
|
+
// Return success response
|
|
67
|
+
return {
|
|
68
|
+
success: true,
|
|
69
|
+
eventId: result.id,
|
|
70
|
+
userId: body.userId,
|
|
71
|
+
timestamp: new Date().toISOString()
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export default userEventWebhook;
|
|
77
|
+
|