lua-cli 3.0.0-alpha.1 → 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.
Files changed (59) 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/commands/chat.js +32 -5
  10. package/dist/commands/compile.js +16 -2
  11. package/dist/commands/dev.js +23 -2
  12. package/dist/commands/push.js +5 -3
  13. package/dist/commands/test.js +18 -2
  14. package/dist/common/job.instance.d.ts +3 -0
  15. package/dist/common/job.instance.js +8 -0
  16. package/dist/config/constants.d.ts +6 -5
  17. package/dist/config/constants.js +12 -10
  18. package/dist/interfaces/chat.d.ts +30 -1
  19. package/dist/interfaces/jobs.d.ts +21 -0
  20. package/dist/types/skill.d.ts +75 -56
  21. package/dist/types/skill.js +53 -59
  22. package/dist/utils/bundling.d.ts +13 -4
  23. package/dist/utils/bundling.js +83 -26
  24. package/dist/utils/compile.js +27 -6
  25. package/dist/utils/dev-api.d.ts +42 -2
  26. package/dist/utils/dev-api.js +177 -4
  27. package/dist/utils/dev-server.d.ts +1 -1
  28. package/dist/utils/dev-server.js +4 -4
  29. package/dist/utils/dynamic-job-bundler.d.ts +17 -0
  30. package/dist/utils/dynamic-job-bundler.js +143 -0
  31. package/dist/utils/pre-bundle-jobs.d.ts +26 -0
  32. package/dist/utils/pre-bundle-jobs.js +176 -0
  33. package/dist/utils/sandbox-storage.d.ts +48 -0
  34. package/dist/utils/sandbox-storage.js +114 -0
  35. package/dist/utils/sandbox.d.ts +2 -2
  36. package/dist/utils/sandbox.js +23 -7
  37. package/package.json +1 -1
  38. package/template/lua.skill.yaml +47 -0
  39. package/template/package-lock.json +10505 -0
  40. package/template/package.json +2 -1
  41. package/template/src/index.ts +65 -3
  42. package/template/src/tools/CreateInlineJob.ts +42 -0
  43. package/API_REFERENCE.md +0 -1408
  44. package/CHANGELOG.md +0 -236
  45. package/CLI_REFERENCE.md +0 -908
  46. package/GETTING_STARTED.md +0 -1040
  47. package/INSTANCE_TYPES.md +0 -1158
  48. package/README.md +0 -865
  49. package/TEMPLATE_GUIDE.md +0 -1398
  50. package/USER_DATA_INSTANCE.md +0 -621
  51. package/template/AGENT_CONFIGURATION.md +0 -251
  52. package/template/COMPLEX_JOB_EXAMPLES.md +0 -795
  53. package/template/DYNAMIC_JOB_CREATION.md +0 -371
  54. package/template/TOOL_EXAMPLES.md +0 -655
  55. package/template/WEBHOOKS_JOBS_QUICKSTART.md +0 -318
  56. package/template/WEBHOOK_JOB_EXAMPLES.md +0 -817
  57. package/template/src/index-agent-example.ts +0 -201
  58. package/template/src/postprocessors/ResponseFormatter.ts +0 -151
  59. package/template/src/preprocessors/MessageFilter.ts +0 -91
@@ -18,8 +18,9 @@
18
18
  "@types/js-yaml": "^4.0.9",
19
19
  "axios": "^1.6.0",
20
20
  "inquirer": "^12.9.6",
21
+ "stripe": "^17.5.0",
21
22
  "js-yaml": "^4.1.0",
22
- "lua-cli": "^2.5.8",
23
+ "lua-cli": "^3.0.0-alpha.4",
23
24
  "openai": "^5.23.0",
24
25
  "uuid": "^13.0.0",
25
26
  "zod": "^3.24.1"
@@ -1,4 +1,4 @@
1
- import { LuaSkill, User, Products, Orders, Data, Baskets } from "lua-cli";
1
+ import { LuaSkill, User, Products, Orders, Data, Baskets, LuaJob, JobInstance, LuaWebhook, Jobs } from "lua-cli";
2
2
  import GetWeatherTool from "./tools/GetWeatherTool";
3
3
  import { GetUserDataTool, UpdateUserDataTool } from "./tools/UserDataTool";
4
4
  import CreatePostTool from "./tools/CreatePostTool";
@@ -7,6 +7,8 @@ import CreatePaymentLinkTool from "./tools/PaymentTool";
7
7
  import { CreateBasketTool, GetBasketsTool, AddItemToBasketTool, RemoveItemFromBasketTool, ClearBasketTool, UpdateBasketStatusTool, UpdateBasketMetadataTool, CheckoutBasketTool, GetBasketByIdTool } from "./tools/BasketTool";
8
8
  import { CreateOrderTool, UpdateOrderStatusTool, GetOrderByIdTool, GetUserOrdersTool } from "./tools/OrderTool";
9
9
  import { CreateMovieTool, GetMoviesTool, GetMovieByIdTool, UpdateMovieTool, SearchMoviesTool, DeleteMovieTool } from "./tools/CustomDataTool";
10
+ import CreateInlineJobTool from "./tools/CreateInlineJob";
11
+ import { v4 } from 'uuid';
10
12
 
11
13
  // ============================================================================
12
14
  // WEBHOOK EXAMPLES (Uncomment to enable)
@@ -23,7 +25,7 @@ import { CreateMovieTool, GetMoviesTool, GetMovieByIdTool, UpdateMovieTool, Sear
23
25
  // Jobs are scheduled tasks that run at specific times or intervals
24
26
  // See: WEBHOOK_JOB_EXAMPLES.md for detailed explanations
25
27
 
26
- // import dailyCleanupJob from "./jobs/DailyCleanupJob";
28
+ import dailyCleanupJob from "./jobs/DailyCleanupJob";
27
29
  // import healthCheckJob from "./jobs/HealthCheckJob";
28
30
  // import dataMigrationJob from "./jobs/DataMigrationJob";
29
31
  // import abandonedBasketProcessorJob from "./jobs/AbandonedBasketProcessorJob";
@@ -56,7 +58,8 @@ const generalSkill = new LuaSkill({
56
58
  context: "This skill provides various utilities including weather information, user data retrieval, post creation, basic calculator operations, and advanced mathematical functions. Use get_weather to fetch current weather conditions for any city, get_user_data to retrieve user information, create_post to publish new posts, calculator for basic arithmetic operations, and advanced_math for complex mathematical computations like factorials, prime checking, fibonacci sequences, and greatest common divisor calculations.",
57
59
  tools: [
58
60
  new GetWeatherTool(),
59
- new CreatePostTool()
61
+ new CreatePostTool(),
62
+ new CreateInlineJobTool()
60
63
  ]
61
64
  });
62
65
 
@@ -159,6 +162,65 @@ const testCases = [
159
162
  { tool: "get_weather", cityLong: "London", apiKey: "123" }
160
163
  ];
161
164
 
165
+ const job = new LuaJob({
166
+ description: "Test job",
167
+ context: "Test job context",
168
+ name: "test-job",
169
+ schedule: {
170
+ type: "once",
171
+ executeAt: new Date(Date.now() + 1000).toISOString()
172
+ },
173
+ metadata: {
174
+ test: "test"
175
+ },
176
+ execute: async (job: JobInstance) => {
177
+ console.log("Job executed");
178
+ return { success: true, message: "Job executed successfully" };
179
+ }
180
+ });
181
+
182
+ //create webhook
183
+ const webhook = new LuaWebhook({
184
+ description: "Test webhook",
185
+ context: "Test webhook context",
186
+ name: "test-webhook",
187
+ execute: async (query: any, headers: any, body: any) => {
188
+ console.log("Webhook executed");
189
+ return { success: true, message: "Webhook executed successfully" };
190
+ }
191
+ });
192
+
193
+ const newJob = new LuaJob({
194
+ description: "Test job",
195
+ context: "Test job context",
196
+ name: "test-job",
197
+ schedule: {
198
+ type: "once",
199
+ executeAt: new Date(Date.now() + 1000).toISOString()
200
+ },
201
+ execute: async (job: JobInstance) => {
202
+ console.log("Job executed", job);
203
+ const realtimeJob = await Jobs.create({
204
+ name: `realtime-job-new-this-again`,
205
+ description: "Realtime job",
206
+ schedule: {
207
+ type: "once",
208
+ executeAt: new Date(Date.now() + 1000).toISOString()
209
+ },
210
+ execute: async (job: JobInstance) => {
211
+ // console.log("Executing realtime job", job.data);
212
+ console.log("Realtime job metadata", job.metadata);
213
+ console.log("Realtime job user", job.user);
214
+ return { success: true, message: "Realtime job executed successfully" };
215
+ }
216
+ });
217
+ return { success: true, message: "Job executed successfully" };
218
+ }
219
+ });
220
+
221
+
222
+ console.log("Job created:", job);
223
+
162
224
  async function runTests() {
163
225
  // await seedProducts();
164
226
  console.log("🧪 Running tool tests...\n");
@@ -0,0 +1,42 @@
1
+ import { LuaTool } from "lua-cli/skill";
2
+ import { z } from "zod";
3
+ import { AI, JobInstance, Jobs } from "../../../dist/api-exports";
4
+ import ApiService from "../services/ApiService";
5
+ import { v4 as uuidv4 } from 'uuid';
6
+
7
+ export default class CreateInlineJobTool implements LuaTool {
8
+ name = "create_inline_job";
9
+ description = "Create a new inline job";
10
+ inputSchema = z.object({});
11
+
12
+ async execute(input: z.infer<typeof this.inputSchema>) {
13
+ const jobId = uuidv4();
14
+ const job = await Jobs.create({
15
+ name: `inline-job-${jobId}`,
16
+ description: "Inline job",
17
+ schedule: {
18
+ type: "once",
19
+ executeAt: new Date(Date.now() + 1000)
20
+ },
21
+ metadata: {
22
+ test: "test"
23
+ },
24
+ execute: async (job: JobInstance) => {
25
+ // console.log("Executing inline job", job);
26
+ console.log("Inline job metadata", job.metadata);
27
+ console.log("Inline job user", job.user());
28
+ console.log("Inline job data", job.data);
29
+ const response = await AI.generate("You are a poet. Write a poem about the following topic:", [{ type: "text", text: "A sheep in the field" }]);
30
+ console.log("AI response", response);
31
+ const apiService = new ApiService();
32
+ const data = await apiService.fetchUserData("123");
33
+ await job.updateMetadata({ test: "test2" });
34
+ const disabled = await job.delete();
35
+ console.log("Inline job deleted", disabled);
36
+ return { success: true, data: response, user: data };
37
+ }
38
+ });
39
+
40
+ return { success: true, job: job };
41
+ }
42
+ }