vilvona 1.0.0 → 1.0.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.
- package/openclaw.mjs +82 -627
- package/package.json +1 -1
package/openclaw.mjs
CHANGED
|
@@ -1,661 +1,116 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Vilvona AI — launcher
|
|
5
|
+
* Downloads OpenClaw runtime on first run, then starts with Vilvona defaults.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { spawn, execSync } from "node:child_process";
|
|
9
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
7
10
|
import os from "node:os";
|
|
8
11
|
import path from "node:path";
|
|
9
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
-
|
|
11
|
-
const MIN_NODE_MAJOR = 22;
|
|
12
|
-
const MIN_NODE_MINOR = 19;
|
|
13
|
-
const MIN_NODE_VERSION = `${MIN_NODE_MAJOR}.${MIN_NODE_MINOR}`;
|
|
14
|
-
|
|
15
|
-
const parseNodeVersion = (rawVersion) => {
|
|
16
|
-
const [majorRaw = "0", minorRaw = "0"] = rawVersion.split(".");
|
|
17
|
-
return {
|
|
18
|
-
major: Number(majorRaw),
|
|
19
|
-
minor: Number(minorRaw),
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const isSupportedNodeVersion = (version) =>
|
|
24
|
-
version.major > MIN_NODE_MAJOR ||
|
|
25
|
-
(version.major === MIN_NODE_MAJOR && version.minor >= MIN_NODE_MINOR);
|
|
26
12
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
// ── Node version guard ────────────────────────────────────────────────────────
|
|
14
|
+
const MIN_MAJOR = 22;
|
|
15
|
+
const MIN_MINOR = 19;
|
|
16
|
+
const [curMajor, curMinor] = process.versions.node.split(".").map(Number);
|
|
31
17
|
|
|
18
|
+
if (curMajor < MIN_MAJOR || (curMajor === MIN_MAJOR && curMinor < MIN_MINOR)) {
|
|
32
19
|
process.stderr.write(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
`
|
|
36
|
-
` nvm
|
|
37
|
-
` nvm
|
|
20
|
+
`\nVilvona AI requires Node.js ${MIN_MAJOR}.${MIN_MINOR}+\n` +
|
|
21
|
+
`Current version: v${process.versions.node}\n\n` +
|
|
22
|
+
`Fix it with nvm:\n` +
|
|
23
|
+
` nvm install ${MIN_MAJOR}\n` +
|
|
24
|
+
` nvm use ${MIN_MAJOR}\n` +
|
|
25
|
+
` nvm alias default ${MIN_MAJOR}\n\n` +
|
|
26
|
+
`Then run: npx vilvona\n\n`,
|
|
38
27
|
);
|
|
39
28
|
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
ensureSupportedNodeVersion();
|
|
29
|
+
}
|
|
43
30
|
|
|
44
|
-
|
|
31
|
+
// ── Version flag ─────────────────────────────────────────────────────────────
|
|
32
|
+
if (process.argv.includes("--version") || process.argv.includes("-v")) {
|
|
33
|
+
process.stdout.write("Vilvona AI 1.0.0 (powered by OpenClaw)\n");
|
|
45
34
|
process.exit(0);
|
|
46
35
|
}
|
|
47
36
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
// ── Runtime cache dir ─────────────────────────────────────────────────────────
|
|
38
|
+
const CACHE_DIR = path.join(os.homedir(), ".vilvona", "runtime");
|
|
39
|
+
const OPENCLAW_VERSION = "2026.6.6";
|
|
40
|
+
const ENTRY = path.join(CACHE_DIR, "node_modules", "openclaw", "dist", "entry.js");
|
|
51
41
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const normalized = value.replace(/[^A-Za-z0-9._-]+/g, "_").replace(/^_+|_+$/g, "");
|
|
57
|
-
return normalized.length > 0 ? normalized : "unknown";
|
|
58
|
-
};
|
|
59
|
-
const readPackageVersion = () => {
|
|
60
|
-
try {
|
|
61
|
-
const parsed = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf8"));
|
|
62
|
-
if (typeof parsed?.version === "string" && parsed.version.trim().length > 0) {
|
|
63
|
-
return parsed.version;
|
|
64
|
-
}
|
|
65
|
-
} catch {
|
|
66
|
-
// Fall through to an install-metadata-only cache key.
|
|
67
|
-
}
|
|
68
|
-
return "unknown";
|
|
69
|
-
};
|
|
70
|
-
const resolvePackagedCompileCacheDirectory = () => {
|
|
71
|
-
const packageJsonUrl = new URL("./package.json", import.meta.url);
|
|
72
|
-
const version = sanitizeCompileCachePathSegment(readPackageVersion());
|
|
73
|
-
let installMarker = "no-package-json";
|
|
74
|
-
try {
|
|
75
|
-
const stat = statSync(packageJsonUrl);
|
|
76
|
-
installMarker = `${Math.trunc(stat.mtimeMs)}-${stat.size}`;
|
|
77
|
-
} catch {
|
|
78
|
-
// Package archives should always have package.json, but keep startup best-effort.
|
|
79
|
-
}
|
|
80
|
-
const baseDirectory = isNodeCompileCacheRequested()
|
|
81
|
-
? process.env.NODE_COMPILE_CACHE
|
|
82
|
-
: path.join(os.tmpdir(), "node-compile-cache");
|
|
83
|
-
return path.join(
|
|
84
|
-
baseDirectory,
|
|
85
|
-
"vilvona",
|
|
86
|
-
version,
|
|
87
|
-
sanitizeCompileCachePathSegment(installMarker),
|
|
42
|
+
// ── Install openclaw runtime if not cached ────────────────────────────────────
|
|
43
|
+
if (!existsSync(ENTRY)) {
|
|
44
|
+
process.stderr.write(
|
|
45
|
+
`\nVilvona AI — first run setup\n` + `Installing OpenClaw runtime v${OPENCLAW_VERSION}...\n\n`,
|
|
88
46
|
);
|
|
89
|
-
};
|
|
90
47
|
|
|
91
|
-
|
|
92
|
-
process.platform === "win32"
|
|
93
|
-
? ["SIGTERM", "SIGINT", "SIGBREAK"]
|
|
94
|
-
: ["SIGTERM", "SIGINT", "SIGHUP", "SIGQUIT"];
|
|
95
|
-
const respawnSignalExitGraceMs = 1_000;
|
|
96
|
-
const respawnSignalForceKillGraceMs = 1_000;
|
|
97
|
-
const respawnSignalHardExitGraceMs = 1_000;
|
|
48
|
+
mkdirSync(CACHE_DIR, { recursive: true });
|
|
98
49
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// This intentionally overlaps with src/entry.compile-cache.ts; keep the
|
|
106
|
-
// respawn supervision behavior in sync until the launcher can share TS code.
|
|
107
|
-
// Give the child a moment to honor forwarded signals, then exit the wrapper so
|
|
108
|
-
// a child that ignores SIGTERM cannot keep the launcher alive indefinitely.
|
|
109
|
-
let signalExitTimer = null;
|
|
110
|
-
let signalForceKillTimer = null;
|
|
111
|
-
let signalHardExitTimer = null;
|
|
112
|
-
const detach = () => {
|
|
113
|
-
for (const [signal, listener] of listeners) {
|
|
114
|
-
process.off(signal, listener);
|
|
115
|
-
}
|
|
116
|
-
listeners.clear();
|
|
117
|
-
if (signalExitTimer) {
|
|
118
|
-
clearTimeout(signalExitTimer);
|
|
119
|
-
signalExitTimer = null;
|
|
120
|
-
}
|
|
121
|
-
if (signalForceKillTimer) {
|
|
122
|
-
clearTimeout(signalForceKillTimer);
|
|
123
|
-
signalForceKillTimer = null;
|
|
124
|
-
}
|
|
125
|
-
if (signalHardExitTimer) {
|
|
126
|
-
clearTimeout(signalHardExitTimer);
|
|
127
|
-
signalHardExitTimer = null;
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
const forceKillChild = () => {
|
|
131
|
-
try {
|
|
132
|
-
child.kill(process.platform === "win32" ? "SIGTERM" : "SIGKILL");
|
|
133
|
-
} catch {
|
|
134
|
-
// Best-effort shutdown fallback.
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
const requestChildTermination = () => {
|
|
138
|
-
try {
|
|
139
|
-
child.kill("SIGTERM");
|
|
140
|
-
} catch {
|
|
141
|
-
// Best-effort shutdown fallback.
|
|
142
|
-
}
|
|
143
|
-
signalForceKillTimer = setTimeout(() => {
|
|
144
|
-
forceKillChild();
|
|
145
|
-
signalHardExitTimer = setTimeout(() => {
|
|
146
|
-
process.exit(1);
|
|
147
|
-
}, respawnSignalHardExitGraceMs);
|
|
148
|
-
signalHardExitTimer.unref?.();
|
|
149
|
-
}, respawnSignalForceKillGraceMs);
|
|
150
|
-
signalForceKillTimer.unref?.();
|
|
151
|
-
};
|
|
152
|
-
const scheduleParentExit = () => {
|
|
153
|
-
if (signalExitTimer) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
signalExitTimer = setTimeout(() => {
|
|
157
|
-
requestChildTermination();
|
|
158
|
-
}, respawnSignalExitGraceMs);
|
|
159
|
-
signalExitTimer.unref?.();
|
|
160
|
-
};
|
|
161
|
-
for (const signal of respawnSignals) {
|
|
162
|
-
const listener = () => {
|
|
163
|
-
try {
|
|
164
|
-
child.kill(signal);
|
|
165
|
-
} catch {
|
|
166
|
-
// Best-effort signal forwarding.
|
|
167
|
-
}
|
|
168
|
-
scheduleParentExit();
|
|
169
|
-
};
|
|
170
|
-
try {
|
|
171
|
-
process.on(signal, listener);
|
|
172
|
-
listeners.set(signal, listener);
|
|
173
|
-
} catch {
|
|
174
|
-
// Unsupported signal on this platform.
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
child.once("exit", (code, signal) => {
|
|
178
|
-
detach();
|
|
179
|
-
if (signal) {
|
|
180
|
-
process.exit(1);
|
|
181
|
-
}
|
|
182
|
-
process.exit(code ?? 1);
|
|
183
|
-
});
|
|
184
|
-
child.once("error", (error) => {
|
|
185
|
-
detach();
|
|
50
|
+
try {
|
|
51
|
+
execSync(
|
|
52
|
+
`npm install --prefix "${CACHE_DIR}" openclaw@${OPENCLAW_VERSION} --save=false --loglevel=error`,
|
|
53
|
+
{ stdio: "inherit" },
|
|
54
|
+
);
|
|
55
|
+
} catch {
|
|
186
56
|
process.stderr.write(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}\n`,
|
|
57
|
+
`\nFailed to install runtime. Check your internet connection and try again.\n` +
|
|
58
|
+
`Or run: npm install -g openclaw && openclaw\n\n`,
|
|
190
59
|
);
|
|
191
60
|
process.exit(1);
|
|
192
|
-
});
|
|
193
|
-
return true;
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
const respawnWithoutCompileCacheIfNeeded = () => {
|
|
197
|
-
if (!isSourceCheckoutLauncher()) {
|
|
198
|
-
return false;
|
|
199
|
-
}
|
|
200
|
-
if (process.env.OPENCLAW_SOURCE_COMPILE_CACHE_RESPAWNED === "1") {
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
if (!module.getCompileCacheDir?.() && !isNodeCompileCacheRequested()) {
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
const env = {
|
|
207
|
-
...process.env,
|
|
208
|
-
NODE_DISABLE_COMPILE_CACHE: "1",
|
|
209
|
-
OPENCLAW_SOURCE_COMPILE_CACHE_RESPAWNED: "1",
|
|
210
|
-
};
|
|
211
|
-
delete env.NODE_COMPILE_CACHE;
|
|
212
|
-
return runRespawnedChild(
|
|
213
|
-
process.execPath,
|
|
214
|
-
[...process.execArgv, fileURLToPath(import.meta.url), ...process.argv.slice(2)],
|
|
215
|
-
env,
|
|
216
|
-
);
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
const respawnWithPackagedCompileCacheIfNeeded = () => {
|
|
220
|
-
if (isSourceCheckoutLauncher() || isNodeCompileCacheDisabled()) {
|
|
221
|
-
return false;
|
|
222
61
|
}
|
|
223
|
-
if (process.env.OPENCLAW_PACKAGED_COMPILE_CACHE_RESPAWNED === "1") {
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
const currentDirectory = module.getCompileCacheDir?.();
|
|
227
|
-
if (!currentDirectory) {
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
const desiredDirectory = resolvePackagedCompileCacheDirectory();
|
|
231
|
-
if (path.resolve(currentDirectory) === path.resolve(desiredDirectory)) {
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
const env = {
|
|
235
|
-
...process.env,
|
|
236
|
-
NODE_COMPILE_CACHE: desiredDirectory,
|
|
237
|
-
OPENCLAW_PACKAGED_COMPILE_CACHE_RESPAWNED: "1",
|
|
238
|
-
};
|
|
239
|
-
return runRespawnedChild(
|
|
240
|
-
process.execPath,
|
|
241
|
-
[...process.execArgv, fileURLToPath(import.meta.url), ...process.argv.slice(2)],
|
|
242
|
-
env,
|
|
243
|
-
);
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
const waitingForCompileCacheRespawn =
|
|
247
|
-
respawnWithoutCompileCacheIfNeeded() || respawnWithPackagedCompileCacheIfNeeded();
|
|
248
|
-
|
|
249
|
-
// https://nodejs.org/api/module.html#module-compile-cache
|
|
250
|
-
if (
|
|
251
|
-
!waitingForCompileCacheRespawn &&
|
|
252
|
-
module.enableCompileCache &&
|
|
253
|
-
!isNodeCompileCacheDisabled() &&
|
|
254
|
-
!isSourceCheckoutLauncher()
|
|
255
|
-
) {
|
|
256
|
-
try {
|
|
257
|
-
module.enableCompileCache(resolvePackagedCompileCacheDirectory());
|
|
258
|
-
} catch {
|
|
259
|
-
// Ignore errors
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
const getErrorMessage = (err) =>
|
|
264
|
-
err && typeof err === "object" && "message" in err && typeof err.message === "string"
|
|
265
|
-
? err.message
|
|
266
|
-
: "";
|
|
267
|
-
|
|
268
|
-
const isModuleNotFoundError = (err) =>
|
|
269
|
-
err && typeof err === "object" && "code" in err && err.code === "ERR_MODULE_NOT_FOUND";
|
|
270
|
-
|
|
271
|
-
const isDirectModuleNotFoundError = (err, specifier) => {
|
|
272
|
-
const message = getErrorMessage(err);
|
|
273
|
-
const bunSpecifierMiss =
|
|
274
|
-
message.includes(`Cannot find module '${specifier}'`) ||
|
|
275
|
-
message.includes(`Cannot find module "${specifier}"`);
|
|
276
|
-
const launcherPath = fileURLToPath(import.meta.url);
|
|
277
|
-
const bunLauncherImporterMiss =
|
|
278
|
-
message.includes(` from '${launcherPath}'`) || message.includes(` from "${launcherPath}"`);
|
|
279
|
-
|
|
280
|
-
const expectedUrl = new URL(specifier, import.meta.url);
|
|
281
|
-
const expectedPath = fileURLToPath(expectedUrl);
|
|
282
|
-
const nodePathMiss =
|
|
283
|
-
message.includes(`Cannot find module '${expectedPath}'`) ||
|
|
284
|
-
message.includes(`Cannot find module "${expectedPath}"`);
|
|
285
|
-
|
|
286
|
-
if (isModuleNotFoundError(err)) {
|
|
287
|
-
if (err && typeof err === "object" && "url" in err && err.url === expectedUrl.href) {
|
|
288
|
-
return true;
|
|
289
|
-
}
|
|
290
|
-
return nodePathMiss || (bunSpecifierMiss && bunLauncherImporterMiss);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
return bunSpecifierMiss && bunLauncherImporterMiss;
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
const installProcessWarningFilter = async () => {
|
|
297
|
-
// Keep bootstrap warnings consistent with the TypeScript runtime.
|
|
298
|
-
for (const specifier of ["./dist/warning-filter.js", "./dist/warning-filter.mjs"]) {
|
|
299
|
-
try {
|
|
300
|
-
const mod = await import(specifier);
|
|
301
|
-
if (typeof mod.installProcessWarningFilter === "function") {
|
|
302
|
-
mod.installProcessWarningFilter();
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
} catch (err) {
|
|
306
|
-
if (isDirectModuleNotFoundError(err, specifier)) {
|
|
307
|
-
continue;
|
|
308
|
-
}
|
|
309
|
-
throw err;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
const tryImport = async (specifier) => {
|
|
315
|
-
try {
|
|
316
|
-
await import(specifier);
|
|
317
|
-
return true;
|
|
318
|
-
} catch (err) {
|
|
319
|
-
// Only swallow direct entry misses; rethrow transitive resolution failures.
|
|
320
|
-
if (isDirectModuleNotFoundError(err, specifier)) {
|
|
321
|
-
return false;
|
|
322
|
-
}
|
|
323
|
-
throw err;
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
const exists = async (specifier) => {
|
|
328
|
-
try {
|
|
329
|
-
await access(new URL(specifier, import.meta.url));
|
|
330
|
-
return true;
|
|
331
|
-
} catch {
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
const buildMissingEntryErrorMessage = async () => {
|
|
337
|
-
const lines = ["vilvona: missing dist/entry.(m)js (build output)."];
|
|
338
|
-
if (!(await exists("./src/entry.ts"))) {
|
|
339
|
-
return lines.join("\n");
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
lines.push("This install looks like an unbuilt source tree or GitHub source archive.");
|
|
343
|
-
lines.push(
|
|
344
|
-
"Build locally with `pnpm install && pnpm build`, or install a built package instead.",
|
|
345
|
-
);
|
|
346
|
-
lines.push(
|
|
347
|
-
"For pinned GitHub installs, use `npm install -g github:vignesh2027/Vilvona-AI#<ref>` instead of a raw `/archive/<ref>.tar.gz` URL.",
|
|
348
|
-
);
|
|
349
|
-
lines.push("For releases, use `npm install -g vilvona@latest`.");
|
|
350
|
-
return lines.join("\n");
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
const isBareRootHelpInvocation = (argv) =>
|
|
354
|
-
argv.length === 3 && (argv[2] === "--help" || argv[2] === "-h");
|
|
355
|
-
|
|
356
|
-
const resolvePrecomputedCommandHelp = (argv) => {
|
|
357
|
-
if (argv.length !== 4 || (argv[3] !== "--help" && argv[3] !== "-h")) {
|
|
358
|
-
return null;
|
|
359
|
-
}
|
|
360
|
-
if (argv[2] === "browser") {
|
|
361
|
-
return { command: "browser", metadataKey: "browserHelpText" };
|
|
362
|
-
}
|
|
363
|
-
if (argv[2] === "secrets") {
|
|
364
|
-
return { command: "secrets", metadataKey: "secretsHelpText" };
|
|
365
|
-
}
|
|
366
|
-
if (argv[2] === "nodes") {
|
|
367
|
-
return { command: "nodes", metadataKey: "nodesHelpText" };
|
|
368
|
-
}
|
|
369
|
-
return null;
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
const isHelpFastPathDisabled = () =>
|
|
373
|
-
process.env.OPENCLAW_DISABLE_CLI_STARTUP_HELP_FAST_PATH === "1";
|
|
374
|
-
|
|
375
|
-
const normalizeLauncherHomeValue = (value) => {
|
|
376
|
-
const trimmed = value?.trim();
|
|
377
|
-
return trimmed && trimmed !== "undefined" && trimmed !== "null" ? trimmed : undefined;
|
|
378
|
-
};
|
|
379
62
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
os.homedir();
|
|
384
|
-
|
|
385
|
-
const resolveLauncherHomeDir = () => {
|
|
386
|
-
const explicit = normalizeLauncherHomeValue(process.env.OPENCLAW_HOME);
|
|
387
|
-
const rawHome =
|
|
388
|
-
explicit && (explicit === "~" || explicit.startsWith("~/") || explicit.startsWith("~\\"))
|
|
389
|
-
? explicit.replace(/^~(?=$|[\\/])/, resolveLauncherOsHomeDir())
|
|
390
|
-
: (explicit ?? resolveLauncherOsHomeDir());
|
|
391
|
-
return path.resolve(rawHome);
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
const resolveLauncherUserPath = (input) => {
|
|
395
|
-
if (input === "~") {
|
|
396
|
-
return resolveLauncherHomeDir();
|
|
397
|
-
}
|
|
398
|
-
if (input.startsWith("~/") || input.startsWith("~\\")) {
|
|
399
|
-
return path.join(resolveLauncherHomeDir(), input.slice(2));
|
|
400
|
-
}
|
|
401
|
-
return path.resolve(input);
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
const resolveLauncherConfigPaths = () => {
|
|
405
|
-
const explicit = process.env.OPENCLAW_CONFIG_PATH?.trim();
|
|
406
|
-
if (explicit) {
|
|
407
|
-
return [resolveLauncherUserPath(explicit)];
|
|
408
|
-
}
|
|
409
|
-
const stateOverride = process.env.OPENCLAW_STATE_DIR?.trim();
|
|
410
|
-
if (stateOverride) {
|
|
411
|
-
const stateDir = resolveLauncherUserPath(stateOverride);
|
|
412
|
-
return [path.join(stateDir, "openclaw.json"), path.join(stateDir, "clawdbot.json")];
|
|
413
|
-
}
|
|
414
|
-
const homeDir = resolveLauncherHomeDir();
|
|
415
|
-
return [
|
|
416
|
-
path.join(homeDir, ".openclaw", "openclaw.json"),
|
|
417
|
-
path.join(homeDir, ".openclaw", "clawdbot.json"),
|
|
418
|
-
path.join(homeDir, ".clawdbot", "openclaw.json"),
|
|
419
|
-
path.join(homeDir, ".clawdbot", "clawdbot.json"),
|
|
420
|
-
];
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
const shouldDeferRootHelpToRuntimeEntry = () => {
|
|
424
|
-
if (
|
|
425
|
-
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR?.trim() ||
|
|
426
|
-
process.env.OPENCLAW_DISABLE_BUNDLED_PLUGINS?.trim()
|
|
427
|
-
) {
|
|
428
|
-
return true;
|
|
429
|
-
}
|
|
430
|
-
for (const configPath of resolveLauncherConfigPaths()) {
|
|
431
|
-
try {
|
|
432
|
-
const raw = readFileSync(configPath, "utf8");
|
|
433
|
-
return /\bplugins\b|\$include\b/.test(raw);
|
|
434
|
-
} catch {
|
|
435
|
-
continue;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
return false;
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
const loadPrecomputedHelpText = (key) => {
|
|
442
|
-
try {
|
|
443
|
-
const raw = readFileSync(new URL("./dist/cli-startup-metadata.json", import.meta.url), "utf8");
|
|
444
|
-
const parsed = JSON.parse(raw);
|
|
445
|
-
const value = parsed?.[key];
|
|
446
|
-
return typeof value === "string" && value.length > 0 ? value : null;
|
|
447
|
-
} catch {
|
|
448
|
-
return null;
|
|
449
|
-
}
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
function tryOutputLauncherVersion(argv) {
|
|
453
|
-
try {
|
|
454
|
-
if (normalizeLauncherMetadataValue(process.env.OPENCLAW_CONTAINER)) {
|
|
455
|
-
return false;
|
|
456
|
-
}
|
|
457
|
-
if (!isLauncherVersionFastPathArgv(argv)) {
|
|
458
|
-
return false;
|
|
459
|
-
}
|
|
460
|
-
const version = resolveLauncherVersion();
|
|
461
|
-
const commit = resolveLauncherCommit();
|
|
462
|
-
process.stdout.write(commit ? `Vilvona AI ${version} (${commit})\n` : `Vilvona AI ${version}\n`);
|
|
463
|
-
return true;
|
|
464
|
-
} catch {
|
|
465
|
-
return false;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
function isLauncherVersionFastPathArgv(argv) {
|
|
470
|
-
return argv.length === 3 && (argv[2] === "--version" || argv[2] === "-V" || argv[2] === "-v");
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
function normalizeLauncherMetadataValue(value) {
|
|
474
|
-
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
475
|
-
return trimmed && trimmed !== "undefined" && trimmed !== "null" ? trimmed : undefined;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
function readLauncherJson(relativePath) {
|
|
479
|
-
try {
|
|
480
|
-
return JSON.parse(readFileSync(new URL(relativePath, import.meta.url), "utf8"));
|
|
481
|
-
} catch {
|
|
482
|
-
return null;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
function resolveLauncherVersion() {
|
|
487
|
-
const packageJson = readLauncherJson("./package.json");
|
|
488
|
-
const packageVersion = normalizeLauncherMetadataValue(packageJson?.version);
|
|
489
|
-
if (packageVersion) {
|
|
490
|
-
return packageVersion;
|
|
491
|
-
}
|
|
492
|
-
const buildInfo = readLauncherJson("./dist/build-info.json");
|
|
493
|
-
const buildVersion = normalizeLauncherMetadataValue(buildInfo?.version);
|
|
494
|
-
if (buildVersion) {
|
|
495
|
-
return buildVersion;
|
|
496
|
-
}
|
|
497
|
-
return normalizeLauncherMetadataValue(process.env.OPENCLAW_BUNDLED_VERSION) ?? "0.0.0";
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
function resolveLauncherCommit() {
|
|
501
|
-
const envCommit = formatLauncherCommit(process.env.GIT_COMMIT ?? process.env.GIT_SHA);
|
|
502
|
-
if (envCommit) {
|
|
503
|
-
return envCommit;
|
|
63
|
+
if (!existsSync(ENTRY)) {
|
|
64
|
+
process.stderr.write(`\nInstall succeeded but entry point not found at:\n${ENTRY}\n\n`);
|
|
65
|
+
process.exit(1);
|
|
504
66
|
}
|
|
505
|
-
return (
|
|
506
|
-
readLauncherGitCommit() ??
|
|
507
|
-
formatLauncherCommit(readLauncherJson("./dist/build-info.json")?.commit) ??
|
|
508
|
-
formatLauncherCommit(readLauncherJson("./package.json")?.gitHead) ??
|
|
509
|
-
formatLauncherCommit(readLauncherJson("./package.json")?.githead)
|
|
510
|
-
);
|
|
511
|
-
}
|
|
512
67
|
|
|
513
|
-
|
|
514
|
-
if (typeof value !== "string") {
|
|
515
|
-
return null;
|
|
516
|
-
}
|
|
517
|
-
const match = value.trim().match(/[0-9a-fA-F]{7,40}/);
|
|
518
|
-
return match ? match[0].slice(0, 7).toLowerCase() : null;
|
|
68
|
+
process.stderr.write(`\nSetup complete. Starting Vilvona AI...\n\n`);
|
|
519
69
|
}
|
|
520
70
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
return null;
|
|
544
|
-
}
|
|
545
|
-
try {
|
|
546
|
-
return formatLauncherCommit(readFileSync(refPath, "utf8"));
|
|
547
|
-
} catch {
|
|
548
|
-
return readLauncherPackedRef(refsBase, ref);
|
|
549
|
-
}
|
|
550
|
-
} catch {
|
|
551
|
-
return null;
|
|
552
|
-
}
|
|
71
|
+
// ── Vilvona AI banner ─────────────────────────────────────────────────────────
|
|
72
|
+
process.stdout.write(
|
|
73
|
+
"\n\x1b[35m" +
|
|
74
|
+
"██╗ ██╗██╗██╗ ██╗ ██╗ ██████╗ ███╗ ██╗ █████╗ █████╗ ██╗\n" +
|
|
75
|
+
"██║ ██║██║██║ ██║ ██║██╔═══██╗████╗ ██║██╔══██╗ ██╔══██╗██║\n" +
|
|
76
|
+
"██║ ██║██║██║ ██║ ██║██║ ██║██╔██╗ ██║███████║ ███████║██║\n" +
|
|
77
|
+
"╚██╗ ██╔╝██║██║ ╚██╗ ██╔╝██║ ██║██║╚██╗██║██╔══██║ ██╔══██║██║\n" +
|
|
78
|
+
" ╚████╔╝ ██║███████╗ ╚████╔╝ ╚██████╔╝██║ ╚████║██║ ██║ ██║ ██║██║\n" +
|
|
79
|
+
" ╚═══╝ ╚═╝╚══════╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝\n" +
|
|
80
|
+
"\x1b[0m" +
|
|
81
|
+
"\x1b[36m Powered by Claude Fable 5 • Tamil & Hindi • Mobile PWA\x1b[0m\n" +
|
|
82
|
+
"\x1b[90m github.com/vignesh2027/Vilvona-AI • by Vignesh S\x1b[0m\n\n"
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
// ── Set Vilvona defaults ──────────────────────────────────────────────────────
|
|
86
|
+
process.env.OPENCLAW_DEFAULT_MODEL =
|
|
87
|
+
process.env.VILVONA_DEFAULT_MODEL ??
|
|
88
|
+
process.env.OPENCLAW_DEFAULT_MODEL ??
|
|
89
|
+
"anthropic/claude-fable-5";
|
|
90
|
+
|
|
91
|
+
if (process.env.VILVONA_PRO_KEY) {
|
|
92
|
+
process.env.OPENCLAW_PRO_KEY = process.env.VILVONA_PRO_KEY;
|
|
553
93
|
}
|
|
554
94
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
const raw = readFileSync(gitPath, "utf8").trim();
|
|
561
|
-
if (!raw.startsWith("gitdir:")) {
|
|
562
|
-
return null;
|
|
563
|
-
}
|
|
564
|
-
return path.join(
|
|
565
|
-
path.resolve(path.dirname(gitPath), raw.slice("gitdir:".length).trim()),
|
|
566
|
-
"HEAD",
|
|
567
|
-
);
|
|
568
|
-
} catch {
|
|
569
|
-
return null;
|
|
570
|
-
}
|
|
571
|
-
}
|
|
95
|
+
// ── Launch ────────────────────────────────────────────────────────────────────
|
|
96
|
+
const child = spawn(process.execPath, [ENTRY, ...process.argv.slice(2)], {
|
|
97
|
+
stdio: "inherit",
|
|
98
|
+
env: process.env,
|
|
99
|
+
});
|
|
572
100
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
return commonDir ? path.resolve(gitDir, commonDir) : gitDir;
|
|
578
|
-
} catch {
|
|
579
|
-
return gitDir;
|
|
580
|
-
}
|
|
581
|
-
}
|
|
101
|
+
// Forward signals to child — Windows needs SIGTERM/SIGINT/SIGBREAK
|
|
102
|
+
const signals = process.platform === "win32"
|
|
103
|
+
? ["SIGTERM", "SIGINT", "SIGBREAK"]
|
|
104
|
+
: ["SIGTERM", "SIGINT", "SIGHUP", "SIGQUIT"];
|
|
582
105
|
|
|
583
|
-
|
|
584
|
-
try {
|
|
585
|
-
const packedRefs = readFileSync(path.join(refsBase, "packed-refs"), "utf8");
|
|
586
|
-
for (const line of packedRefs.split("\n")) {
|
|
587
|
-
if (!line || line.startsWith("#") || line.startsWith("^")) {
|
|
588
|
-
continue;
|
|
589
|
-
}
|
|
590
|
-
const [commit, packedRef] = line.trim().split(/\s+/, 2);
|
|
591
|
-
if (packedRef === ref) {
|
|
592
|
-
return formatLauncherCommit(commit);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
} catch {
|
|
596
|
-
// fall through
|
|
597
|
-
}
|
|
598
|
-
return null;
|
|
106
|
+
for (const sig of signals) {
|
|
107
|
+
try { process.on(sig, () => { try { child.kill(sig); } catch {} }); } catch {}
|
|
599
108
|
}
|
|
600
109
|
|
|
601
|
-
|
|
602
|
-
if (
|
|
603
|
-
|
|
604
|
-
}
|
|
605
|
-
if (shouldDeferRootHelpToRuntimeEntry()) {
|
|
606
|
-
return false;
|
|
607
|
-
}
|
|
608
|
-
const precomputed = loadPrecomputedHelpText("rootHelpText");
|
|
609
|
-
if (precomputed) {
|
|
610
|
-
process.stdout.write(precomputed);
|
|
611
|
-
return true;
|
|
612
|
-
}
|
|
613
|
-
for (const specifier of ["./dist/cli/program/root-help.js", "./dist/cli/program/root-help.mjs"]) {
|
|
614
|
-
try {
|
|
615
|
-
const mod = await import(specifier);
|
|
616
|
-
if (typeof mod.outputRootHelp === "function") {
|
|
617
|
-
await mod.outputRootHelp();
|
|
618
|
-
return true;
|
|
619
|
-
}
|
|
620
|
-
} catch (err) {
|
|
621
|
-
if (isDirectModuleNotFoundError(err, specifier)) {
|
|
622
|
-
continue;
|
|
623
|
-
}
|
|
624
|
-
throw err;
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
return false;
|
|
628
|
-
};
|
|
629
|
-
|
|
630
|
-
const tryOutputPrecomputedCommandHelp = () => {
|
|
631
|
-
const commandHelp = resolvePrecomputedCommandHelp(process.argv);
|
|
632
|
-
if (!commandHelp) {
|
|
633
|
-
return false;
|
|
634
|
-
}
|
|
635
|
-
if (commandHelp.command === "nodes" && shouldDeferRootHelpToRuntimeEntry()) {
|
|
636
|
-
return false;
|
|
637
|
-
}
|
|
638
|
-
const precomputed = loadPrecomputedHelpText(commandHelp.metadataKey);
|
|
639
|
-
if (!precomputed) {
|
|
640
|
-
return false;
|
|
641
|
-
}
|
|
642
|
-
process.stdout.write(precomputed);
|
|
643
|
-
return true;
|
|
644
|
-
};
|
|
645
|
-
|
|
646
|
-
if (!waitingForCompileCacheRespawn) {
|
|
647
|
-
if (!isHelpFastPathDisabled() && (await tryOutputBareRootHelp())) {
|
|
648
|
-
// OK
|
|
649
|
-
} else if (!isHelpFastPathDisabled() && tryOutputPrecomputedCommandHelp()) {
|
|
650
|
-
// OK
|
|
110
|
+
child.on("exit", (code, signal) => {
|
|
111
|
+
if (signal) {
|
|
112
|
+
try { process.kill(process.pid, signal); } catch { process.exit(1); }
|
|
651
113
|
} else {
|
|
652
|
-
|
|
653
|
-
if (await tryImport("./dist/entry.js")) {
|
|
654
|
-
// OK
|
|
655
|
-
} else if (await tryImport("./dist/entry.mjs")) {
|
|
656
|
-
// OK
|
|
657
|
-
} else {
|
|
658
|
-
throw new Error(await buildMissingEntryErrorMessage());
|
|
659
|
-
}
|
|
114
|
+
process.exit(code ?? 0);
|
|
660
115
|
}
|
|
661
|
-
}
|
|
116
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vilvona",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Vilvona AI — Your personal AI that connects everything. Claude Fable 5 powered, works on mobile, Tamil & Hindi support.",
|
|
5
5
|
"keywords": ["ai", "assistant", "claude", "fable5", "personal-ai", "whatsapp", "telegram", "slack", "tamil", "hindi", "self-hosted", "open-source", "chatbot", "automation"],
|
|
6
6
|
"homepage": "https://github.com/vignesh2027/Vilvona-AI#readme",
|