lua-cli 1.1.4-beta.0 → 1.1.4-beta.2

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.
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "lua-skill",
3
+ "version": "1.0.1-beta.0",
4
+ "description": "",
5
+ "license": "ISC",
6
+ "author": "",
7
+ "type": "module",
8
+ "main": "index.ts",
9
+ "scripts": {
10
+ "start": "tsx index.ts",
11
+ "dev": "tsx watch index.ts",
12
+ "build": "tsc",
13
+ "test": "echo \"Error: no test specified\" && exit 1"
14
+ },
15
+ "dependencies": {
16
+ "@types/inquirer": "^9.0.9",
17
+ "axios": "^1.6.0",
18
+ "inquirer": "^12.9.6",
19
+ "lua-cli": "file:..",
20
+ "zod": "^4.1.9"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^20.10.0",
24
+ "tsx": "^4.7.0",
25
+ "typescript": "^5.3.0"
26
+ }
27
+ }
@@ -0,0 +1,71 @@
1
+ import axios from "axios";
2
+
3
+ export default class ApiService {
4
+ baseUrl: string;
5
+ timeout: number;
6
+
7
+ constructor() {
8
+ this.baseUrl = "https://httpbin.org";
9
+ this.timeout = 5000;
10
+ }
11
+
12
+ async fetchUserData(userId: string) {
13
+ try {
14
+ const response = await axios.get(`${this.baseUrl}/get`, {
15
+ params: { userId },
16
+ timeout: this.timeout,
17
+ headers: {
18
+ 'Content-Type': 'application/json',
19
+ 'User-Agent': 'Lua-Skill/1.0'
20
+ }
21
+ });
22
+
23
+ return {
24
+ id: userId,
25
+ name: response.data.args.userId || 'Unknown',
26
+ url: response.data.url,
27
+ status: 'success',
28
+ timestamp: new Date().toISOString()
29
+ };
30
+ } catch (error: any) {
31
+ return {
32
+ id: userId,
33
+ name: 'Unknown',
34
+ url: null,
35
+ status: 'error',
36
+ error: error.message,
37
+ timestamp: new Date().toISOString()
38
+ };
39
+ }
40
+ }
41
+
42
+ async createPost(title: string, content: string) {
43
+ try {
44
+ const response = await axios.post(`${this.baseUrl}/post`, {
45
+ title,
46
+ content,
47
+ publishedAt: new Date().toISOString()
48
+ }, {
49
+ timeout: this.timeout,
50
+ headers: {
51
+ 'Content-Type': 'application/json'
52
+ }
53
+ });
54
+
55
+ return {
56
+ id: response.data.json.title || 'generated-id',
57
+ title: response.data.json.title,
58
+ status: 'created',
59
+ url: response.data.url
60
+ };
61
+ } catch (error: any) {
62
+ return {
63
+ id: null,
64
+ title,
65
+ status: 'error',
66
+ error: error.message,
67
+ url: null
68
+ };
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,8 @@
1
+ export default class GetWeatherMain{
2
+ constructor() {
3
+ }
4
+
5
+ async getWeather(city: string) {
6
+ return { weather: "sunny", city: city };
7
+ }
8
+ }
@@ -0,0 +1,26 @@
1
+ import { LuaTool } from "lua-cli/skill";
2
+ import { z } from "zod";
3
+ import ApiService from "../services/ApiService";
4
+
5
+ const inputSchema = z.object({ title: z.string(), content: z.string() });
6
+ const outputSchema = z.object({ id: z.string(), title: z.string(), status: z.string(), error: z.string().optional(), url: z.string().nullable() });
7
+
8
+ export default class CreatePostTool implements LuaTool<typeof inputSchema, typeof outputSchema>{
9
+ name: string;
10
+ description: string;
11
+ inputSchema: typeof inputSchema;
12
+ outputSchema: typeof outputSchema;
13
+ apiService: ApiService;
14
+
15
+ constructor() {
16
+ this.name = "create_post";
17
+ this.description = "Create a new post";
18
+ this.inputSchema = inputSchema;
19
+ this.outputSchema = outputSchema;
20
+ this.apiService = new ApiService();
21
+ }
22
+
23
+ async execute(input: z.infer<typeof inputSchema>) {
24
+ return this.apiService.createPost(input.title, input.content);
25
+ }
26
+ }
@@ -0,0 +1,26 @@
1
+ import { LuaTool } from "lua-cli/skill";
2
+ import { z } from "zod";
3
+ import ApiService from "../services/ApiService";
4
+
5
+ const inputSchema = z.object({ userId: z.string() });
6
+ const outputSchema = z.object({ id: z.string(), name: z.string(), url: z.string(), status: z.string(), error: z.string().optional(), timestamp: z.string() });
7
+
8
+ export default class GetUserDataTool implements LuaTool<typeof inputSchema, typeof outputSchema>{
9
+ name: string;
10
+ description: string;
11
+ inputSchema: typeof inputSchema;
12
+ outputSchema: typeof outputSchema;
13
+ apiService: ApiService;
14
+
15
+ constructor() {
16
+ this.name = "get_user_data";
17
+ this.description = "Get the user data for a given user id";
18
+ this.inputSchema = inputSchema;
19
+ this.outputSchema = outputSchema;
20
+ this.apiService = new ApiService();
21
+ }
22
+
23
+ async execute(input: z.infer<typeof inputSchema>) {
24
+ return this.apiService.fetchUserData(input.userId);
25
+ }
26
+ }
@@ -0,0 +1,24 @@
1
+ import { LuaTool } from "lua-cli/skill";
2
+ import { z } from "zod";
3
+ import GetWeatherMain from "../services/GetWeather";
4
+
5
+ const inputSchema = z.object({ city: z.string() });
6
+ const outputSchema = z.object({ weather: z.string() });
7
+
8
+ export default class GetWeatherTool implements LuaTool<typeof inputSchema, typeof outputSchema>{
9
+ name: string;
10
+ description: string;
11
+ inputSchema: typeof inputSchema;
12
+ outputSchema: typeof outputSchema;
13
+
14
+ constructor() {
15
+ this.name = "get_weather";
16
+ this.description = "Get the weather for a given city";
17
+ this.inputSchema = inputSchema;
18
+ this.outputSchema = outputSchema;
19
+ }
20
+
21
+ async execute(input: z.infer<typeof inputSchema>) {
22
+ return { weather: "sunny", city: input.city };
23
+ }
24
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "ESNext",
4
+ "moduleResolution": "bundler",
5
+ "target": "ES2020",
6
+ "esModuleInterop": true,
7
+ "forceConsistentCasingInFileNames": true,
8
+ "strict": true,
9
+ "skipLibCheck": true,
10
+ "baseUrl": ".",
11
+ "outDir": "./dist",
12
+ "paths": {
13
+ "@/*": ["./*"],
14
+ "@/services/*": ["./services/*"]
15
+ }
16
+ },
17
+ "exclude": ["dist", "node_modules"]
18
+ }