lua-cli 3.1.0-alpha.3 → 3.1.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.
- package/README.md +0 -4
- package/dist/api/cdn.api.service.d.ts +18 -0
- package/dist/api/cdn.api.service.js +43 -0
- package/dist/api/custom.data.api.service.d.ts +4 -3
- package/dist/api/custom.data.api.service.js +4 -3
- package/dist/api/developer.api.service.d.ts +54 -1
- package/dist/api/developer.api.service.js +89 -0
- package/dist/api/job.api.service.d.ts +33 -100
- package/dist/api/job.api.service.js +27 -11
- package/dist/api/lazy-instances.d.ts +16 -0
- package/dist/api/lazy-instances.js +32 -0
- package/dist/api/postprocessor.api.service.d.ts +3 -13
- package/dist/api/postprocessor.api.service.js +2 -4
- package/dist/api/preprocessor.api.service.d.ts +1 -8
- package/dist/api/preprocessor.api.service.js +1 -2
- package/dist/api/webhook.api.service.d.ts +1 -3
- package/dist/api/webhook.api.service.js +1 -1
- package/dist/api/whatsapp-templates.api.service.d.ts +40 -0
- package/dist/api/whatsapp-templates.api.service.js +78 -0
- package/dist/api-exports.d.ts +153 -6
- package/dist/api-exports.js +177 -21
- package/dist/cli/command-definitions.js +34 -7
- package/dist/commands/admin.js +1 -1
- package/dist/commands/channels.js +1 -1
- package/dist/commands/chat.js +2 -4
- package/dist/commands/compile.js +23 -4
- package/dist/commands/evals.d.ts +8 -0
- package/dist/commands/evals.js +41 -0
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/init.d.ts +10 -1
- package/dist/commands/init.js +23 -46
- package/dist/commands/jobs.js +5 -5
- package/dist/commands/mcp.d.ts +18 -0
- package/dist/commands/mcp.js +393 -0
- package/dist/commands/push.js +174 -23
- package/dist/common/data.entry.instance.d.ts +1 -1
- package/dist/common/data.entry.instance.js +4 -4
- package/dist/common/job.instance.d.ts +59 -7
- package/dist/common/job.instance.js +84 -19
- package/dist/config/constants.d.ts +1 -0
- package/dist/config/constants.js +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/agent.d.ts +0 -3
- package/dist/interfaces/cdn.d.ts +24 -0
- package/dist/interfaces/cdn.js +5 -0
- package/dist/interfaces/compile.d.ts +1 -0
- package/dist/interfaces/custom.data.d.ts +3 -3
- package/dist/interfaces/index.d.ts +2 -1
- package/dist/interfaces/init.d.ts +0 -1
- package/dist/interfaces/jobs.d.ts +88 -132
- package/dist/interfaces/jobs.js +1 -1
- package/dist/interfaces/mcp.d.ts +64 -0
- package/dist/interfaces/mcp.js +5 -0
- package/dist/interfaces/postprocessors.d.ts +0 -3
- package/dist/interfaces/preprocessors.d.ts +0 -3
- package/dist/interfaces/webhooks.d.ts +0 -5
- package/dist/interfaces/whatsapp-templates.d.ts +104 -0
- package/dist/interfaces/whatsapp-templates.js +5 -0
- package/dist/types/api-contracts.d.ts +68 -14
- package/dist/types/compile.types.d.ts +5 -6
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +3 -1
- package/dist/types/skill.d.ts +181 -103
- package/dist/types/skill.js +123 -91
- package/dist/utils/agent-management.d.ts +3 -5
- package/dist/utils/agent-management.js +6 -8
- package/dist/utils/bundling.d.ts +4 -11
- package/dist/utils/bundling.js +24 -33
- package/dist/utils/compile.d.ts +17 -9
- package/dist/utils/compile.js +72 -88
- package/dist/utils/deployment.js +13 -7
- package/dist/utils/dev-api.js +1 -4
- package/dist/utils/dev-server.js +1 -1
- package/dist/utils/files.d.ts +11 -4
- package/dist/utils/files.js +17 -14
- package/dist/utils/init-agent.d.ts +1 -2
- package/dist/utils/init-agent.js +4 -6
- package/dist/utils/init-helpers.d.ts +4 -4
- package/dist/utils/init-helpers.js +10 -11
- package/dist/utils/job-management.js +0 -2
- package/dist/utils/mcp-server-management.d.ts +23 -0
- package/dist/utils/mcp-server-management.js +212 -0
- package/dist/utils/postprocessor-management.js +2 -4
- package/dist/utils/preprocessor-management.js +2 -4
- package/dist/utils/sandbox.d.ts +4 -2
- package/dist/utils/sandbox.js +38 -9
- package/dist/utils/webhook-management.js +1 -3
- package/dist/web/app.css +1505 -14
- package/dist/web/app.js +79 -64
- package/package.json +2 -6
- package/template/QUICKSTART.md +57 -774
- package/template/README.md +80 -907
- package/template/examples/README.md +106 -0
- package/template/{src → examples}/jobs/AbandonedBasketProcessorJob.ts +67 -14
- package/template/{src → examples}/jobs/DailyCleanupJob.ts +0 -3
- package/template/{src → examples}/jobs/DataMigrationJob.ts +0 -3
- package/template/{src → examples}/jobs/HealthCheckJob.ts +0 -3
- package/template/{src → examples}/postprocessors/modifyResponse.ts +3 -4
- package/template/examples/preprocessors/messageMatching.ts +35 -0
- package/template/{src → examples}/skills/basket.skill.ts +0 -1
- package/template/{src → examples}/skills/product.skill.ts +0 -1
- package/template/{src → examples}/skills/tools/GameScoreTrackerTool.ts +11 -15
- package/template/{src → examples}/skills/tools/OrderTool.ts +25 -0
- package/template/examples/skills/tools/PremiumFeatureTool.ts +98 -0
- package/template/{src → examples}/skills/tools/UserDataTool.ts +34 -0
- package/template/{src → examples}/skills/user.skill.ts +0 -1
- package/template/examples/webhooks/FileUploadWebhook.ts +86 -0
- package/template/{src → examples}/webhooks/PaymentWebhook.ts +12 -9
- package/template/examples/webhooks/UserEventWebhook.ts +105 -0
- package/template/package-lock.json +7895 -0
- package/template/package.json +1 -1
- package/template/src/index.ts +40 -22
- package/template/src/preprocessors/messageMatching.ts +0 -22
- package/template/src/webhooks/UserEventWebhook.ts +0 -77
- /package/template/{src → examples}/services/ApiService.ts +0 -0
- /package/template/{src → examples}/services/GetWeather.ts +0 -0
- /package/template/{src → examples}/skills/tools/BasketTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/CreateInlineJob.ts +0 -0
- /package/template/{src → examples}/skills/tools/CreatePostTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/CustomDataTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/GetWeatherTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/PaymentTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/ProductsTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/SmartBasketTool.ts +0 -0
package/template/package.json
CHANGED
package/template/src/index.ts
CHANGED
|
@@ -1,31 +1,49 @@
|
|
|
1
1
|
import { LuaAgent } from "lua-cli";
|
|
2
|
-
import userSkill from "./skills/user.skill";
|
|
3
|
-
import productSkill from "./skills/product.skill";
|
|
4
|
-
import basketSkill from "./skills/basket.skill";
|
|
5
|
-
import userEventWebhook from "./webhooks/UserEventWebhook";
|
|
6
|
-
import healthCheckJob from "./jobs/HealthCheckJob";
|
|
7
|
-
import messageMatchingPreProcessor from "./preprocessors/messageMatching";
|
|
8
|
-
import modifyResponsePostProcessor from "./postprocessors/modifyResponse";
|
|
9
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Your Lua AI Agent
|
|
5
|
+
*
|
|
6
|
+
* This is a minimal agent ready for you to customize.
|
|
7
|
+
* Add skills, webhooks, jobs, and processors as needed.
|
|
8
|
+
*
|
|
9
|
+
* Quick start:
|
|
10
|
+
* 1. Create a tool in src/skills/tools/MyTool.ts
|
|
11
|
+
* 2. Create a skill in src/skills/my.skill.ts
|
|
12
|
+
* 3. Import and add it to the skills array below
|
|
13
|
+
* 4. Run `lua test` to test your tool
|
|
14
|
+
* 5. Run `lua chat` to chat with your agent
|
|
15
|
+
*
|
|
16
|
+
* Need examples? Run `lua init --with-examples` in a new project
|
|
17
|
+
* or see: https://docs.heylua.ai/examples
|
|
18
|
+
*/
|
|
10
19
|
const agent = new LuaAgent({
|
|
11
|
-
name: ``,
|
|
12
|
-
persona: ``,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
name: ``, // Set during lua init
|
|
21
|
+
persona: ``, // Set during lua init
|
|
22
|
+
|
|
23
|
+
// Add your skills here
|
|
24
|
+
skills: [],
|
|
25
|
+
|
|
26
|
+
// Optional: Add webhooks for external integrations
|
|
27
|
+
// webhooks: [],
|
|
28
|
+
|
|
29
|
+
// Optional: Add scheduled jobs
|
|
30
|
+
// jobs: [],
|
|
31
|
+
|
|
32
|
+
// Optional: Add message preprocessors
|
|
33
|
+
// preProcessors: [],
|
|
34
|
+
|
|
35
|
+
// Optional: Add response postprocessors
|
|
36
|
+
// postProcessors: [],
|
|
18
37
|
});
|
|
19
38
|
|
|
20
|
-
|
|
21
39
|
async function main() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
40
|
+
// Your agent is ready!
|
|
41
|
+
//
|
|
42
|
+
// Next steps:
|
|
43
|
+
// 1. Create your first skill with tools
|
|
44
|
+
// 2. Run `lua test` to test tools interactively
|
|
45
|
+
// 3. Run `lua chat` to chat with your agent
|
|
46
|
+
// 4. Run `lua push` to deploy
|
|
28
47
|
}
|
|
29
48
|
|
|
30
49
|
main().catch(console.error);
|
|
31
|
-
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ChatMessage, PreProcessor, UserDataInstance } from "lua-cli";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const messageMatchingPreProcessor = new PreProcessor({
|
|
5
|
-
name: "message-matching",
|
|
6
|
-
description: "Matches the message to the appropriate skill",
|
|
7
|
-
context: "Matches the message to the appropriate skill",
|
|
8
|
-
execute: async (user: UserDataInstance, messages: ChatMessage[], channel: string) => {
|
|
9
|
-
console.log("Message matching pre processor", user, messages, channel);
|
|
10
|
-
console.log("User data", await user.data);
|
|
11
|
-
console.log("Messages", messages);
|
|
12
|
-
console.log("Channel", channel);
|
|
13
|
-
//check if message type text contains test and return the message
|
|
14
|
-
const testMessage = messages.find((message) => message.type === "text" && message.text.includes("test"));
|
|
15
|
-
if (testMessage) {
|
|
16
|
-
return [{ type: "text", text: "Tell the user that you got their test message and nothing else" }];
|
|
17
|
-
}
|
|
18
|
-
return messages;
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export default messageMatchingPreProcessor;
|
|
@@ -1,77 +0,0 @@
|
|
|
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
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|