lua-cli 3.0.0-alpha.1 → 3.0.0-alpha.11
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/chat.api.service.d.ts +8 -0
- package/dist/api/chat.api.service.js +55 -0
- package/dist/api/job.api.service.d.ts +16 -7
- package/dist/api/job.api.service.js +21 -5
- package/dist/api/postprocessor.api.service.d.ts +61 -1
- package/dist/api/postprocessor.api.service.js +35 -0
- package/dist/api/preprocessor.api.service.d.ts +61 -1
- package/dist/api/preprocessor.api.service.js +35 -0
- package/dist/api-exports.d.ts +27 -7
- package/dist/api-exports.js +48 -30
- package/dist/cli/command-definitions.js +13 -6
- package/dist/commands/chat.js +71 -39
- package/dist/commands/compile.js +16 -2
- package/dist/commands/dev.js +23 -2
- package/dist/commands/push.d.ts +3 -2
- package/dist/commands/push.js +536 -6
- package/dist/commands/test.js +18 -2
- package/dist/common/job.instance.d.ts +3 -0
- package/dist/common/job.instance.js +8 -0
- package/dist/config/constants.d.ts +6 -5
- package/dist/config/constants.js +12 -10
- package/dist/interfaces/chat.d.ts +30 -1
- package/dist/interfaces/jobs.d.ts +21 -0
- package/dist/services/auth.d.ts +8 -2
- package/dist/services/auth.js +35 -3
- package/dist/types/skill.d.ts +75 -56
- package/dist/types/skill.js +53 -59
- package/dist/utils/bundling.d.ts +13 -4
- package/dist/utils/bundling.js +83 -26
- package/dist/utils/compile.js +27 -6
- 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/pre-bundle-jobs.d.ts +26 -0
- package/dist/utils/pre-bundle-jobs.js +176 -0
- package/dist/utils/sandbox-storage.d.ts +48 -0
- package/dist/utils/sandbox-storage.js +114 -0
- package/dist/utils/sandbox.d.ts +2 -2
- package/dist/utils/sandbox.js +23 -8
- package/package.json +1 -1
- package/template/env.example +5 -0
- 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 +65 -3
- package/template/src/tools/CreateInlineJob.ts +42 -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/AGENT_CONFIGURATION.md +0 -251
- package/template/COMPLEX_JOB_EXAMPLES.md +0 -795
- package/template/DYNAMIC_JOB_CREATION.md +0 -371
- package/template/TOOL_EXAMPLES.md +0 -655
- package/template/WEBHOOKS_JOBS_QUICKSTART.md +0 -318
- package/template/WEBHOOK_JOB_EXAMPLES.md +0 -817
- package/template/src/index-agent-example.ts +0 -201
- package/template/src/postprocessors/ResponseFormatter.ts +0 -151
- package/template/src/preprocessors/MessageFilter.ts +0 -91
package/template/package.json
CHANGED
package/template/src/index.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
+
}
|