@vm0/runner 1.0.0 → 1.1.0

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 (2) hide show
  1. package/index.js +106 -0
  2. package/package.json +18 -8
package/index.js ADDED
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { program } from "commander";
5
+
6
+ // src/commands/setup.ts
7
+ import { Command } from "commander";
8
+ var setupCommand = new Command("setup").description("Configure runner (generates keys, authenticates)").action(() => {
9
+ console.log("Setup command not yet implemented");
10
+ console.log("This will:");
11
+ console.log(" - Generate RSA key pair");
12
+ console.log(" - Authenticate with VM0 server");
13
+ process.exit(0);
14
+ });
15
+
16
+ // src/commands/start.ts
17
+ import { Command as Command2 } from "commander";
18
+
19
+ // src/lib/config.ts
20
+ import { z } from "zod";
21
+ import fs from "fs";
22
+ import yaml from "yaml";
23
+ var runnerConfigSchema = z.object({
24
+ name: z.string().min(1, "Name is required"),
25
+ group: z.string().regex(
26
+ /^[a-z0-9-]+\/[a-z0-9-]+$/,
27
+ "Group must be in format 'scope/name' (lowercase, hyphens allowed)"
28
+ ),
29
+ sandbox: z.object({
30
+ max_concurrent: z.number().int().min(1).default(1),
31
+ vcpu: z.number().int().min(1).default(2),
32
+ memory_mb: z.number().int().min(128).default(2048)
33
+ }).default({}),
34
+ firecracker: z.object({
35
+ binary: z.string().min(1, "Firecracker binary path is required"),
36
+ kernel: z.string().min(1, "Kernel path is required"),
37
+ rootfs: z.string().min(1, "Rootfs path is required")
38
+ })
39
+ });
40
+ function loadConfig(configPath) {
41
+ if (!fs.existsSync(configPath)) {
42
+ throw new Error(`runner.yaml not found: ${configPath}`);
43
+ }
44
+ const content = fs.readFileSync(configPath, "utf-8");
45
+ const raw = yaml.parse(content);
46
+ const result = runnerConfigSchema.safeParse(raw);
47
+ if (!result.success) {
48
+ const errors = result.error.errors.map((e) => ` - ${e.path.join(".")}: ${e.message}`).join("\n");
49
+ throw new Error(`Invalid configuration:
50
+ ${errors}`);
51
+ }
52
+ return result.data;
53
+ }
54
+ function validateFirecrackerPaths(config) {
55
+ const checks = [
56
+ { path: config.binary, name: "Firecracker binary" },
57
+ { path: config.kernel, name: "Kernel" },
58
+ { path: config.rootfs, name: "Rootfs" }
59
+ ];
60
+ for (const check of checks) {
61
+ if (!fs.existsSync(check.path)) {
62
+ throw new Error(`${check.name} not found: ${check.path}`);
63
+ }
64
+ }
65
+ }
66
+
67
+ // src/commands/start.ts
68
+ var startCommand = new Command2("start").description("Start the runner").option("--config <path>", "Config file path", "./runner.yaml").option("--api-url <url>", "VM0 API URL").option("--dry-run", "Validate config without starting").action((options) => {
69
+ try {
70
+ const config = loadConfig(options.config);
71
+ validateFirecrackerPaths(config.firecracker);
72
+ console.log("Config valid");
73
+ if (options.dryRun) {
74
+ console.log(JSON.stringify(config, null, 2));
75
+ process.exit(0);
76
+ }
77
+ console.log("Runner start not yet implemented");
78
+ console.log(`Would connect to: ${options.apiUrl || "default API"}`);
79
+ console.log(`Runner name: ${config.name}`);
80
+ console.log(`Runner group: ${config.group}`);
81
+ process.exit(0);
82
+ } catch (error) {
83
+ if (error instanceof Error) {
84
+ console.error(`Error: ${error.message}`);
85
+ } else {
86
+ console.error("An unknown error occurred");
87
+ }
88
+ process.exit(1);
89
+ }
90
+ });
91
+
92
+ // src/commands/status.ts
93
+ import { Command as Command3 } from "commander";
94
+ var statusCommand = new Command3("status").description("Show runner status").action(() => {
95
+ console.log("Status command not yet implemented");
96
+ process.exit(0);
97
+ });
98
+
99
+ // src/index.ts
100
+ var version = true ? "1.1.0" : "0.1.0";
101
+ program.name("vm0-runner").version(version).description("Self-hosted runner for VM0 agents");
102
+ program.addCommand(setupCommand);
103
+ program.addCommand(startCommand);
104
+ program.addCommand(statusCommand);
105
+ program.parse();
106
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,12 +1,22 @@
1
1
  {
2
2
  "name": "@vm0/runner",
3
- "version": "1.0.0",
4
- "description": "",
5
- "license": "ISC",
6
- "author": "",
7
- "type": "commonjs",
8
- "main": "index.js",
9
- "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
3
+ "version": "1.1.0",
4
+ "description": "Self-hosted runner for VM0 agents",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/vm0-ai/vm0",
8
+ "directory": "turbo/apps/runner"
9
+ },
10
+ "type": "module",
11
+ "bin": {
12
+ "vm0-runner": "index.js"
13
+ },
14
+ "files": [
15
+ "."
16
+ ],
17
+ "dependencies": {
18
+ "commander": "^14.0.0",
19
+ "yaml": "^2.3.4",
20
+ "zod": "^3.25.64"
11
21
  }
12
22
  }