lua-cli 3.0.0-alpha.1 โ†’ 3.0.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 (61) hide show
  1. package/dist/api/job.api.service.d.ts +16 -7
  2. package/dist/api/job.api.service.js +21 -5
  3. package/dist/api/postprocessor.api.service.d.ts +61 -1
  4. package/dist/api/postprocessor.api.service.js +35 -0
  5. package/dist/api/preprocessor.api.service.d.ts +61 -1
  6. package/dist/api/preprocessor.api.service.js +35 -0
  7. package/dist/api-exports.d.ts +26 -6
  8. package/dist/api-exports.js +42 -29
  9. package/dist/cli/command-definitions.js +13 -6
  10. package/dist/commands/chat.js +32 -5
  11. package/dist/commands/compile.js +16 -2
  12. package/dist/commands/dev.js +23 -2
  13. package/dist/commands/push.d.ts +6 -2
  14. package/dist/commands/push.js +412 -6
  15. package/dist/commands/test.js +18 -2
  16. package/dist/common/job.instance.d.ts +3 -0
  17. package/dist/common/job.instance.js +8 -0
  18. package/dist/config/constants.d.ts +6 -5
  19. package/dist/config/constants.js +12 -10
  20. package/dist/interfaces/chat.d.ts +30 -1
  21. package/dist/interfaces/jobs.d.ts +21 -0
  22. package/dist/types/skill.d.ts +75 -56
  23. package/dist/types/skill.js +53 -59
  24. package/dist/utils/bundling.d.ts +13 -4
  25. package/dist/utils/bundling.js +83 -26
  26. package/dist/utils/compile.js +27 -6
  27. package/dist/utils/dev-api.d.ts +42 -2
  28. package/dist/utils/dev-api.js +177 -4
  29. package/dist/utils/dev-server.d.ts +1 -1
  30. package/dist/utils/dev-server.js +4 -4
  31. package/dist/utils/dynamic-job-bundler.d.ts +17 -0
  32. package/dist/utils/dynamic-job-bundler.js +143 -0
  33. package/dist/utils/pre-bundle-jobs.d.ts +26 -0
  34. package/dist/utils/pre-bundle-jobs.js +176 -0
  35. package/dist/utils/sandbox-storage.d.ts +48 -0
  36. package/dist/utils/sandbox-storage.js +114 -0
  37. package/dist/utils/sandbox.d.ts +2 -2
  38. package/dist/utils/sandbox.js +23 -7
  39. package/package.json +1 -1
  40. package/template/lua.skill.yaml +47 -0
  41. package/template/package-lock.json +10505 -0
  42. package/template/package.json +2 -1
  43. package/template/src/index.ts +65 -3
  44. package/template/src/tools/CreateInlineJob.ts +42 -0
  45. package/API_REFERENCE.md +0 -1408
  46. package/CHANGELOG.md +0 -236
  47. package/CLI_REFERENCE.md +0 -908
  48. package/GETTING_STARTED.md +0 -1040
  49. package/INSTANCE_TYPES.md +0 -1158
  50. package/README.md +0 -865
  51. package/TEMPLATE_GUIDE.md +0 -1398
  52. package/USER_DATA_INSTANCE.md +0 -621
  53. package/template/AGENT_CONFIGURATION.md +0 -251
  54. package/template/COMPLEX_JOB_EXAMPLES.md +0 -795
  55. package/template/DYNAMIC_JOB_CREATION.md +0 -371
  56. package/template/TOOL_EXAMPLES.md +0 -655
  57. package/template/WEBHOOKS_JOBS_QUICKSTART.md +0 -318
  58. package/template/WEBHOOK_JOB_EXAMPLES.md +0 -817
  59. package/template/src/index-agent-example.ts +0 -201
  60. package/template/src/postprocessors/ResponseFormatter.ts +0 -151
  61. package/template/src/preprocessors/MessageFilter.ts +0 -91
@@ -1,318 +0,0 @@
1
- # Webhooks & Jobs - Quick Start Guide
2
-
3
- Get started with webhooks and scheduled jobs in 5 minutes!
4
-
5
- ---
6
-
7
- ## ๐Ÿš€ What Are They?
8
-
9
- ### **Webhooks** = HTTP Endpoints
10
- Receive requests from external systems (Stripe, Zapier, your own apps)
11
-
12
- **Example:** Stripe sends payment notification โ†’ Your webhook processes it
13
-
14
- ### **Jobs** = Scheduled Tasks
15
- Run code at specific times or intervals
16
-
17
- **Example:** Every night at 2 AM โ†’ Clean up old data
18
-
19
- ---
20
-
21
- ## ๐Ÿ“ฆ Quick Start - Webhooks
22
-
23
- ### Step 1: Uncomment Example
24
-
25
- In `src/index.ts`, uncomment:
26
- ```typescript
27
- import userEventWebhook from "./webhooks/UserEventWebhook";
28
- ```
29
-
30
- ### Step 2: Compile
31
- ```bash
32
- lua compile
33
- # โœ… Found 1 webhook(s)
34
- ```
35
-
36
- ### Step 3: Test
37
- ```bash
38
- lua test webhook
39
-
40
- # Prompts:
41
- # - Query params: {"source": "test"}
42
- # - Headers: {"x-api-key": "your-secret-key"}
43
- # - Body: {"eventType": "signup", "userId": "123", "email": "test@example.com", "timestamp": "2025-01-15T10:00:00Z"}
44
-
45
- # Result: Webhook executes and stores event
46
- ```
47
-
48
- ### Step 4: Deploy
49
- ```bash
50
- lua push webhook
51
- lua webhooks production
52
- # Select: Deploy a version
53
- ```
54
-
55
- ### Step 5: Get Your URL
56
- After deployment, your webhook URL is:
57
- ```
58
- https://api.heylua.ai/webhooks/{agentId}/{webhookId}
59
- ```
60
-
61
- Configure this in Stripe, Zapier, or your external system!
62
-
63
- ---
64
-
65
- ## โฐ Quick Start - Jobs
66
-
67
- ### Step 1: Uncomment Example
68
-
69
- In `src/index.ts`, uncomment:
70
- ```typescript
71
- import dailyCleanupJob from "./jobs/DailyCleanupJob";
72
- ```
73
-
74
- ### Step 2: Compile
75
- ```bash
76
- lua compile
77
- # โœ… Found 1 job(s)
78
- ```
79
-
80
- ### Step 3: Test (runs immediately)
81
- ```bash
82
- lua test job
83
- # Select: daily-cleanup
84
- # Job executes now (ignores schedule)
85
- ```
86
-
87
- ### Step 4: Deploy
88
- ```bash
89
- lua push job
90
- lua jobs production
91
- # Select: Deploy a version
92
- # Job will now run on its schedule!
93
- ```
94
-
95
- ### Step 5: Monitor
96
- ```bash
97
- lua jobs production
98
- # Select: View deployed jobs
99
- # See: last run, next run, status
100
-
101
- # Select: View execution history
102
- # See: all past executions, results, errors
103
- ```
104
-
105
- ---
106
-
107
- ## ๐Ÿ›’ Quick Start - Smart Baskets (Advanced)
108
-
109
- This combines tools + jobs for abandoned cart recovery!
110
-
111
- ### Step 1: Enable Components
112
-
113
- In `src/index.ts`, uncomment:
114
- ```typescript
115
- import { CreateSmartBasketTool, CheckAbandonedBasketsTool } from "./tools/SmartBasketTool";
116
- import abandonedBasketProcessorJob from "./jobs/AbandonedBasketProcessorJob";
117
- ```
118
-
119
- And add to a skill:
120
- ```typescript
121
- const basketSkill = new LuaSkill({
122
- name: "basket-skill",
123
- version: "1.0.0",
124
- description: "Smart basket with abandoned cart recovery",
125
- context: "Manages baskets and sends reminders for abandoned carts",
126
- tools: [
127
- new CreateSmartBasketTool(),
128
- new CheckAbandonedBasketsTool()
129
- ]
130
- });
131
- ```
132
-
133
- ### Step 2: Compile & Deploy
134
- ```bash
135
- lua compile
136
- lua push skill
137
- lua push job
138
- lua jobs production # Activate the processor job
139
- ```
140
-
141
- ### Step 3: Use It
142
-
143
- When a user creates a basket:
144
- ```
145
- User: "Create a shopping cart"
146
- โ†“
147
- Agent uses: create_smart_basket
148
- โ†“
149
- Tool creates basket
150
- โ†“
151
- Tool schedules reminder (3 hours)
152
- โ†“
153
- Job checks every 15 minutes
154
- โ†“
155
- After 3 hours: Job checks if checked out
156
- โ†“
157
- If abandoned: Log and notify!
158
- ```
159
-
160
- ---
161
-
162
- ## ๐Ÿ“š Available Examples
163
-
164
- ### Webhooks (`src/webhooks/`)
165
-
166
- | File | Purpose | Complexity |
167
- |------|---------|------------|
168
- | **UserEventWebhook.ts** | Receive user events from external systems | โญ Easy |
169
- | **PaymentWebhook.ts** | Process payment notifications (Stripe) | โญโญ Medium |
170
-
171
- ### Jobs (`src/jobs/`)
172
-
173
- | File | Schedule Type | Purpose | Complexity |
174
- |------|--------------|---------|------------|
175
- | **DailyCleanupJob.ts** | Cron (daily) | Clean old data | โญโญ Medium |
176
- | **HealthCheckJob.ts** | Interval (5 min) | Monitor system health | โญ Easy |
177
- | **DataMigrationJob.ts** | Once (specific date) | One-time migration | โญโญโญ Advanced |
178
- | **AbandonedBasketProcessorJob.ts** | Interval (15 min) | Process cart reminders | โญโญโญ Advanced |
179
-
180
- ### Tools (`src/tools/`)
181
-
182
- | File | Purpose | Complexity |
183
- |------|---------|------------|
184
- | **SmartBasketTool.ts** | Create basket + schedule reminder | โญโญโญ Advanced |
185
-
186
- ---
187
-
188
- ## ๐Ÿ”ง Customization Guide
189
-
190
- ### Customize Webhook
191
-
192
- ```typescript
193
- // Change what events you accept
194
- bodySchema: z.object({
195
- eventType: z.enum(['signup', 'update', 'delete', 'login']), // Add 'login'
196
- // ... rest
197
- }),
198
-
199
- // Add your processing logic
200
- execute: async ({ body }) => {
201
- if (body.eventType === 'login') {
202
- // Track login events
203
- await Data.create('login-logs', body);
204
- }
205
- return { success: true };
206
- }
207
- ```
208
-
209
- ### Customize Job Schedule
210
-
211
- ```typescript
212
- // Change from daily to weekly
213
- schedule: {
214
- type: 'cron',
215
- expression: '0 2 * * 0', // Sunday at 2 AM
216
- timezone: 'America/New_York'
217
- }
218
-
219
- // Or change to hourly
220
- schedule: {
221
- type: 'interval',
222
- seconds: 3600 // Every hour
223
- }
224
- ```
225
-
226
- ### Customize Reminder Timing
227
-
228
- In SmartBasketTool.ts:
229
- ```typescript
230
- // Change from 3 hours to 1 hour
231
- const checkTime = new Date(Date.now() + 1 * 60 * 60 * 1000);
232
-
233
- // Or 24 hours
234
- const checkTime = new Date(Date.now() + 24 * 60 * 60 * 1000);
235
- ```
236
-
237
- ---
238
-
239
- ## ๐Ÿงช Testing Workflow
240
-
241
- ### Test Webhook Locally
242
- ```bash
243
- lua test webhook
244
- # Enter test data
245
- # See validation and execution
246
-
247
- # Example test data:
248
- {
249
- "eventType": "signup",
250
- "userId": "test_123",
251
- "email": "test@example.com",
252
- "name": "Test User",
253
- "timestamp": "2025-01-15T10:00:00Z"
254
- }
255
- ```
256
-
257
- ### Test Job Locally
258
- ```bash
259
- lua test job
260
- # Job runs immediately
261
- # Ignore schedule for testing
262
- # See execution result
263
- ```
264
-
265
- ### Test Smart Basket
266
- ```bash
267
- lua test skill
268
- # Select: create_smart_basket
269
- # Enter: currency: USD
270
- # See basket created + reminder scheduled
271
- ```
272
-
273
- ---
274
-
275
- ## ๐Ÿšจ Common Issues
276
-
277
- ### "Webhook not found"
278
- **Cause:** Haven't enabled webhook in index.ts
279
- **Fix:** Uncomment the import
280
-
281
- ### "Job not running"
282
- **Cause:** Job not activated in production
283
- **Fix:**
284
- ```bash
285
- lua jobs production
286
- # Select: Activate a job
287
- ```
288
-
289
- ### "Reminder not processed"
290
- **Cause:** Processor job not running
291
- **Fix:** Enable and activate `AbandonedBasketProcessorJob`
292
-
293
- ---
294
-
295
- ## ๐Ÿ’ก Next Steps
296
-
297
- ### Learn More
298
- 1. Read `WEBHOOK_JOB_EXAMPLES.md` for detailed explanations
299
- 2. Check `TOOL_EXAMPLES.md` for tool patterns
300
- 3. See main docs for API reference
301
-
302
- ### Build Your Own
303
- 1. Copy an example file
304
- 2. Rename and modify
305
- 3. Test locally
306
- 4. Deploy to production
307
-
308
- ### Get Help
309
- - ๐Ÿ“– [Webhook API Spec](../WEBHOOK_API_SPEC.md)
310
- - ๐Ÿ“– [Job API Spec](../JOB_API_SPEC.md)
311
- - ๐Ÿ“– [Full Usage Guide](../WEBHOOKS_JOBS_USAGE_GUIDE.md)
312
-
313
- ---
314
-
315
- **Ready to build powerful integrations!** ๐ŸŽ‰
316
-
317
- Try enabling one webhook and one job, compile, and test them out!
318
-