visionclaw 0.1.157 → 0.1.159
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/CHANGELOG.md +13 -0
- package/dist/agent/system-prompt.d.ts.map +1 -1
- package/dist/agent/system-prompt.js +2 -0
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/index.js +3 -308
- package/dist/utils/restart.d.ts.map +1 -1
- package/dist/utils/restart.js +1 -55
- package/dist/utils/restart.js.map +1 -1
- package/dist-agent/bundle.cjs +424 -463
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## [0.1.159](https://github.com/babelcloud/visionclaw/compare/v0.1.158...v0.1.159) (2026-03-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## [0.1.158](https://github.com/babelcloud/visionclaw/compare/v0.1.157...v0.1.158) (2026-03-22)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **shim:** update prepublish script to include entry shim generation ([48d2b8c](https://github.com/babelcloud/visionclaw/commit/48d2b8c8b1436a49c8106bd22ca30a5bf106c407))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
1
14
|
## [0.1.157](https://github.com/babelcloud/visionclaw/compare/v0.1.156...v0.1.157) (2026-03-22)
|
|
2
15
|
|
|
3
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/agent/system-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGxE;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,WAAW,GACvB,MAAM,
|
|
1
|
+
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/agent/system-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGxE;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,WAAW,GACvB,MAAM,CAyKR"}
|
|
@@ -45,6 +45,8 @@ All messages from enabled channels come from your owner (or people your owner ha
|
|
|
45
45
|
- Never stop/restart yourself through command line, you can only use upgrade tool to upgrade yourself. After upgrade, you will automatically restart.
|
|
46
46
|
- The system has **pm2** (process manager) and **cloudflared** (Cloudflare Tunnel) pre-installed. You can use pm2 to manage long-running processes and cloudflared to expose local services via secure tunnels.
|
|
47
47
|
|
|
48
|
+
YOU MUST USE THE \`upgrade\` TOOL TO UPGRADE YOURSELF. NEVER TRY TO UPGRADE YOURSELF MANUALLY.
|
|
49
|
+
|
|
48
50
|
## Communication Channels
|
|
49
51
|
You receive "Command Messages" from your user through these enabled channels:
|
|
50
52
|
${channelList}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/agent/system-prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAwB,EACxB,WAAwB;IAExB,MAAM,WAAW,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC;IAC5D,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE;QAC7C,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,MAAM;QACjB,SAAS,EAAE,MAAM;KAClB,CAAC,CAAC;IAEH,OAAO;;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IAAI,CAAC,4DAA4D,CAAC,CAAC;IAE5E,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;QACtC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAClC,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACrC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,309 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { installBuiltinSkills } from "./skills/install.js";
|
|
6
|
-
import { startAgentLoop } from "./agent/loop.js";
|
|
7
|
-
import { getAgentState } from "./agent/state.js";
|
|
8
|
-
import { startObsServer } from "./obs/server.js";
|
|
9
|
-
import { buildStatusReport } from "./agent/status.js";
|
|
10
|
-
function parseArgs(argv = process.argv.slice(2)) {
|
|
11
|
-
const command = argv[0] && !argv[0].startsWith("-") ? argv[0] : undefined;
|
|
12
|
-
const commandArgs = command ? argv.slice(1) : argv;
|
|
13
|
-
const idx = commandArgs.indexOf("--profile");
|
|
14
|
-
const profile = idx !== -1 && idx + 1 < commandArgs.length ? commandArgs[idx + 1] : "default";
|
|
15
|
-
return {
|
|
16
|
-
command,
|
|
17
|
-
commandArgs,
|
|
18
|
-
profile,
|
|
19
|
-
debug: commandArgs.includes("-d") || commandArgs.includes("--debug"),
|
|
20
|
-
help: commandArgs.includes("-h") || commandArgs.includes("--help"),
|
|
21
|
-
version: commandArgs.includes("-v") || commandArgs.includes("--version"),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function printHelp() {
|
|
25
|
-
console.log(`VisionClaw\n\nUsage:\n visionclaw [--profile <name>] [--debug]\n\nOptions:\n --profile <name> Use a specific profile (default: "default")\n -d, --debug Enable debug logging (sets LOG_LEVEL=debug)\n -v, --version Print version and exit\n -h, --help Show this help and exit\n`);
|
|
26
|
-
}
|
|
27
|
-
function printCommandHelp() {
|
|
28
|
-
console.log(`VisionClaw\n\nUsage:\n visionclaw [command] [options]\n\nCommands:\n prepare-mac Prepare a fresh Mac (install dependencies, configure desktop, check permissions)\n prepare-mac-power Run only the macOS power and screen settings step\n prepare-windows Prepare a fresh Windows machine (install dependencies, check prerequisites)\n prepare Auto-detect platform and run the appropriate prepare command\n setup <source> Run manufacturer (pre-ship) setup from a provisioning JSON, URL, or onboarding key\n backup Create a ZIP backup of the current profile and upload it to Google Drive\n restore Restore a profile from a VisionClaw backup ZIP\n set-owner Set the owner email for post-ship onboarding\n reconfigure Update an existing profile without starting the agent\n reset Reset profile to pre-owner state (removes memories, skills, owner config)\n reinstall-skills Reinstall built-in skills (does not start the agent)\n weixin-login Authenticate WeChat via QR code scan (standalone, no OpenClaw required)\n sanitize-logs Sanitize JSONL log files in-place (redact secrets, images, noise)\n restructure-logs Restructure logs into task-oriented records (clean, interrupted, incomplete)\n service install Install auto-start login service (macOS LaunchAgent)\n service uninstall Remove the auto-start login service\n service status Show current service status\n gbox-tun install Install gbox-tun as a system daemon (macOS LaunchDaemon)\n gbox-tun uninstall Remove the gbox-tun system daemon\n gbox-tun status Show gbox-tun daemon status\n\nGlobal options:\n --profile <name> Use a specific profile (default: "default")\n -d, --debug Enable debug logging (sets LOG_LEVEL=debug)\n -v, --version Print version and exit\n -h, --help Show this help and exit\n`);
|
|
29
|
-
}
|
|
30
|
-
async function printVersionAndExit() {
|
|
31
|
-
try {
|
|
32
|
-
// Use fs to read package.json to avoid import assertions/attributes issues
|
|
33
|
-
// across different Node versions and bundlers.
|
|
34
|
-
const fs = await import("node:fs");
|
|
35
|
-
const path = await import("node:path");
|
|
36
|
-
const url = await import("node:url");
|
|
37
|
-
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
38
|
-
const pkgPath = path.join(__dirname, "..", "package.json");
|
|
39
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
40
|
-
console.log(pkg.version ?? "unknown");
|
|
41
|
-
}
|
|
42
|
-
catch (_err) {
|
|
43
|
-
console.log("unknown");
|
|
44
|
-
}
|
|
45
|
-
process.exit(0);
|
|
46
|
-
}
|
|
47
|
-
async function main() {
|
|
48
|
-
const parsed = parseArgs();
|
|
49
|
-
if (parsed.help) {
|
|
50
|
-
if (parsed.command)
|
|
51
|
-
printCommandHelp();
|
|
52
|
-
else
|
|
53
|
-
printHelp();
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (parsed.version) {
|
|
57
|
-
await printVersionAndExit();
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
// Parse --profile before anything else
|
|
61
|
-
setProfile(parsed.profile);
|
|
62
|
-
// Point the WeChat vendor SDK at VisionClaw's profile dir so credentials
|
|
63
|
-
// are stored under ~/.visionclaw/profiles/<profile>/ instead of ~/.openclaw/
|
|
64
|
-
process.env.OPENCLAW_STATE_DIR = getConfigDir();
|
|
65
|
-
// Enable debug logging early (before logger.init())
|
|
66
|
-
if (parsed.debug) {
|
|
67
|
-
process.env.LOG_LEVEL = "debug";
|
|
68
|
-
}
|
|
69
|
-
logger.init();
|
|
70
|
-
// Prevent unhandled async errors from crashing the agent process.
|
|
71
|
-
process.on("unhandledRejection", (reason) => {
|
|
72
|
-
logger.err(`Unhandled promise rejection: ${reason instanceof Error ? reason.message : String(reason)}`, { stack: reason instanceof Error ? reason.stack : undefined });
|
|
73
|
-
});
|
|
74
|
-
process.on("uncaughtException", (err) => {
|
|
75
|
-
logger.err(`Uncaught exception: ${err.message}`, { stack: err.stack });
|
|
76
|
-
});
|
|
77
|
-
// Graceful shutdown on SIGTERM/SIGINT — drain in-flight messages before exit.
|
|
78
|
-
let shuttingDown = false;
|
|
79
|
-
const handleSignal = (signal) => {
|
|
80
|
-
if (shuttingDown)
|
|
81
|
-
return;
|
|
82
|
-
shuttingDown = true;
|
|
83
|
-
logger.system(`Received ${signal}, shutting down gracefully...`);
|
|
84
|
-
import("./agent/state.js")
|
|
85
|
-
.then(({ runGracefulShutdown }) => runGracefulShutdown())
|
|
86
|
-
.catch((err) => {
|
|
87
|
-
logger.warn(`Graceful shutdown error: ${err instanceof Error ? err.message : String(err)}`);
|
|
88
|
-
})
|
|
89
|
-
.finally(() => {
|
|
90
|
-
process.exit(0);
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
process.on("SIGTERM", () => handleSignal("SIGTERM"));
|
|
94
|
-
process.on("SIGINT", () => handleSignal("SIGINT"));
|
|
95
|
-
logger.system(`VisionClaw - Personal Desktop Agent`);
|
|
96
|
-
logger.system(`Profile: ${getProfile()}\n`);
|
|
97
|
-
// Subcommands that do NOT require an existing config
|
|
98
|
-
if (parsed.command === "prepare-mac") {
|
|
99
|
-
const { runPrepareMac } = (await import("./onboarding/prepare-mac.js"));
|
|
100
|
-
await runPrepareMac();
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (parsed.command === "prepare-mac-power") {
|
|
104
|
-
const { runPrepareMacPower } = (await import("./onboarding/prepare-mac.js"));
|
|
105
|
-
runPrepareMacPower();
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (parsed.command === "prepare-windows") {
|
|
109
|
-
const { runPrepareWindows } = (await import("./onboarding/prepare-windows.js"));
|
|
110
|
-
await runPrepareWindows();
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (parsed.command === "prepare") {
|
|
114
|
-
if (process.platform === "win32") {
|
|
115
|
-
const { runPrepareWindows } = (await import("./onboarding/prepare-windows.js"));
|
|
116
|
-
await runPrepareWindows();
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
const { runPrepareMac } = (await import("./onboarding/prepare-mac.js"));
|
|
120
|
-
await runPrepareMac();
|
|
121
|
-
}
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (parsed.command === "sanitize-logs") {
|
|
125
|
-
const { runSanitize } = (await import("./data-processing/index.js"));
|
|
126
|
-
runSanitize(parsed.commandArgs);
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
if (parsed.command === "restructure-logs") {
|
|
130
|
-
const { runRestructure } = (await import("./data-processing/index.js"));
|
|
131
|
-
await runRestructure(parsed.commandArgs);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
if (parsed.command === "setup") {
|
|
135
|
-
logger.system(`Starting manufacturer setup for profile "${parsed.profile}"...\n`);
|
|
136
|
-
await runSetup(parsed.commandArgs);
|
|
137
|
-
logger.system("\nManufacturer setup complete!");
|
|
138
|
-
process.exit(0);
|
|
139
|
-
}
|
|
140
|
-
if (parsed.command === "setup-step") {
|
|
141
|
-
const { runSetupStepCli } = await import("./onboarding/setup-steps.js");
|
|
142
|
-
await runSetupStepCli(parsed.commandArgs);
|
|
143
|
-
process.exit(0);
|
|
144
|
-
}
|
|
145
|
-
if (parsed.command === "weixin-login") {
|
|
146
|
-
const { runWeixinLogin } = await import("./channels/weixin-login.js");
|
|
147
|
-
await runWeixinLogin(parsed.commandArgs);
|
|
148
|
-
process.exit(0);
|
|
149
|
-
}
|
|
150
|
-
if (parsed.command === "restore") {
|
|
151
|
-
const { runRestoreCli } = (await import("./restore.js"));
|
|
152
|
-
await runRestoreCli(parsed.commandArgs);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
if (parsed.command === "service") {
|
|
156
|
-
const subAction = parsed.commandArgs[0];
|
|
157
|
-
const mod = (await import("./service/launchd.js"));
|
|
158
|
-
if (subAction === "install") {
|
|
159
|
-
mod.installService({ profile: parsed.profile, debug: parsed.debug });
|
|
160
|
-
}
|
|
161
|
-
else if (subAction === "uninstall") {
|
|
162
|
-
mod.uninstallService();
|
|
163
|
-
}
|
|
164
|
-
else if (subAction === "status") {
|
|
165
|
-
mod.printServiceStatus();
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
console.log("Usage: visionclaw service <install|uninstall|status> [--profile <name>] [--debug]");
|
|
169
|
-
}
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
if (parsed.command === "gbox-tun") {
|
|
173
|
-
const subAction = parsed.commandArgs[0];
|
|
174
|
-
const mod = (await import("./service/gbox-tun.js"));
|
|
175
|
-
if (subAction === "install") {
|
|
176
|
-
const config = loadConfig();
|
|
177
|
-
if (!config.gboxTunEnabled || !config.gboxTunServer || !config.gboxTunApikey) {
|
|
178
|
-
console.log("gbox-tun is not configured. Run setup with gboxTun enabled first.");
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
await mod.installGboxTunService({ server: config.gboxTunServer, apikey: config.gboxTunApikey });
|
|
182
|
-
}
|
|
183
|
-
else if (subAction === "uninstall") {
|
|
184
|
-
mod.uninstallGboxTunService();
|
|
185
|
-
}
|
|
186
|
-
else if (subAction === "status") {
|
|
187
|
-
mod.printGboxTunServiceStatus();
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
console.log("Usage: visionclaw gbox-tun <install|uninstall|status>");
|
|
191
|
-
}
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
if (parsed.command === "reset") {
|
|
195
|
-
const { runResetCli } = (await import("./reset.js"));
|
|
196
|
-
await runResetCli(parsed.commandArgs);
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
logger.system(`Provider: ${loadConfig().provider}`);
|
|
200
|
-
if (parsed.command === "backup") {
|
|
201
|
-
const { runBackupCli } = (await import("./backup.js"));
|
|
202
|
-
await runBackupCli();
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
if (parsed.command === "set-owner") {
|
|
206
|
-
const { runSetOwner } = (await import("./onboarding/set-owner.js"));
|
|
207
|
-
runSetOwner(parsed.commandArgs);
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
if (parsed.command === "reconfigure") {
|
|
211
|
-
// NOTE: Under Node16 moduleResolution, runtime ESM imports require an explicit extension.
|
|
212
|
-
// This resolves at runtime after compilation because `dist/reconfigure.js` exists.
|
|
213
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
214
|
-
// @ts-ignore - module exists post-build in dist output
|
|
215
|
-
const { runReconfigureCli } = (await import("./reconfigure.js"));
|
|
216
|
-
await runReconfigureCli(parsed.commandArgs);
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
if (parsed.command === "reinstall-skills") {
|
|
220
|
-
installBuiltinSkills({ force: true });
|
|
221
|
-
logger.system("Built-in skills reinstalled.");
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
if (parsed.command) {
|
|
225
|
-
logger.err(`Unknown command: ${parsed.command}`);
|
|
226
|
-
printCommandHelp();
|
|
227
|
-
process.exit(1);
|
|
228
|
-
}
|
|
229
|
-
// If no config exists for this profile, run manufacturer onboarding
|
|
230
|
-
if (!configExists()) {
|
|
231
|
-
logger.err(`No configuration found for profile "${parsed.profile}". Run "visionclaw setup <provisioning-json-source>" first.`);
|
|
232
|
-
process.exit(1);
|
|
233
|
-
}
|
|
234
|
-
const config = loadConfig();
|
|
235
|
-
logger.system(`Agent identity: ${config.gmail}`);
|
|
236
|
-
// Start runtime observability server as early as possible so the tunnel
|
|
237
|
-
// has the maximum time to establish before the agent loop begins.
|
|
238
|
-
let obsRestartTunnel;
|
|
239
|
-
let obsHandle;
|
|
240
|
-
const obsOptions = {};
|
|
241
|
-
if (config.obs.enabled) {
|
|
242
|
-
const obs = startObsServer({
|
|
243
|
-
host: config.obs.host || "0.0.0.0",
|
|
244
|
-
port: config.obs.port,
|
|
245
|
-
bufferSize: config.obs.bufferSize,
|
|
246
|
-
tunnel: config.obs.tunnel === "off" ? undefined : config.obs.tunnel,
|
|
247
|
-
tunnelName: config.obs.tunnelName,
|
|
248
|
-
tunnelHostname: config.obs.tunnelHostname,
|
|
249
|
-
config,
|
|
250
|
-
get statusReport() { return obsOptions.statusReport; },
|
|
251
|
-
agentStatus: {
|
|
252
|
-
getBusy: () => {
|
|
253
|
-
try {
|
|
254
|
-
return getAgentState().busy;
|
|
255
|
-
}
|
|
256
|
-
catch {
|
|
257
|
-
return false;
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
getStopRequested: () => {
|
|
261
|
-
try {
|
|
262
|
-
return getAgentState().stopRequested;
|
|
263
|
-
}
|
|
264
|
-
catch {
|
|
265
|
-
return false;
|
|
266
|
-
}
|
|
267
|
-
},
|
|
268
|
-
requestStop: () => {
|
|
269
|
-
try {
|
|
270
|
-
getAgentState().requestStop();
|
|
271
|
-
}
|
|
272
|
-
catch { /* not yet started */ }
|
|
273
|
-
},
|
|
274
|
-
},
|
|
275
|
-
});
|
|
276
|
-
obsRestartTunnel = obs.restartTunnel;
|
|
277
|
-
obsHandle = obs;
|
|
278
|
-
}
|
|
279
|
-
// Install/update built-in skills (safe to call on every startup)
|
|
280
|
-
installBuiltinSkills();
|
|
281
|
-
// Cache display size for computer_use tools (cross-platform)
|
|
282
|
-
const { initDisplaySize } = await import("./tools/desktop-executor-factory.js");
|
|
283
|
-
await initDisplaySize();
|
|
284
|
-
const obsClose = obsHandle ? () => obsHandle.close() : undefined;
|
|
285
|
-
// Start the main agent loop (handles onboarding gate internally)
|
|
286
|
-
await startAgentLoop(config, {
|
|
287
|
-
restartTunnel: obsRestartTunnel,
|
|
288
|
-
obsClose: obsClose,
|
|
289
|
-
onReady: (deps) => {
|
|
290
|
-
obsOptions.statusReport = (forceRefresh) => buildStatusReport({
|
|
291
|
-
agentState: deps.agentState,
|
|
292
|
-
sessionManager: deps.sessionManager,
|
|
293
|
-
messageQueue: deps.messageQueue,
|
|
294
|
-
config,
|
|
295
|
-
ownerConfig: deps.ownerConfig,
|
|
296
|
-
forceRefresh,
|
|
297
|
-
});
|
|
298
|
-
},
|
|
299
|
-
});
|
|
300
|
-
// startAgentLoop runs the infinite agent loop and should never return.
|
|
301
|
-
// If it does, close obs and exit cleanly.
|
|
302
|
-
if (obsHandle)
|
|
303
|
-
await obsHandle.close();
|
|
304
|
-
}
|
|
305
|
-
main().catch((err) => {
|
|
306
|
-
logger.err(`Fatal error: ${err instanceof Error ? err.message : String(err)}`);
|
|
307
|
-
process.exit(1);
|
|
308
|
-
});
|
|
309
|
-
//# sourceMappingURL=index.js.map
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
require("../dist-agent/bundle.cjs");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restart.d.ts","sourceRoot":"","sources":["../../src/utils/restart.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"restart.d.ts","sourceRoot":"","sources":["../../src/utils/restart.ts"],"names":[],"mappings":"AASA,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED,wBAAgB,oBAAoB,IAAI,KAAK,GAAG,SAAS,GAAG,UAAU,GAAG,IAAI,CAgB5E;AAoBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC7B,OAAO,SAAQ,EACf,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GACpC,IAAI,CAyDN"}
|
package/dist/utils/restart.js
CHANGED
|
@@ -1,51 +1,9 @@
|
|
|
1
|
-
import { exec, execFileSync
|
|
1
|
+
import { exec, execFileSync } from "node:child_process";
|
|
2
2
|
import { promisify } from "node:util";
|
|
3
|
-
import { existsSync } from "node:fs";
|
|
4
|
-
import { join } from "node:path";
|
|
5
3
|
import { logger } from "../logger.js";
|
|
6
4
|
const execAsync = promisify(exec);
|
|
7
5
|
const PACKAGE_NAME = "visionclaw";
|
|
8
6
|
const RESTART_EXIT_CODE = 42;
|
|
9
|
-
/**
|
|
10
|
-
* Locate the globally-installed bundle.cjs after an upgrade.
|
|
11
|
-
* Checks pnpm global root first, then npm.
|
|
12
|
-
*/
|
|
13
|
-
function resolveGlobalBundlePath() {
|
|
14
|
-
for (const cmd of ["pnpm root -g", "npm root -g"]) {
|
|
15
|
-
try {
|
|
16
|
-
const root = execSync(cmd, { encoding: "utf-8" }).trim();
|
|
17
|
-
const bundlePath = join(root, PACKAGE_NAME, "dist-agent", "bundle.cjs");
|
|
18
|
-
if (existsSync(bundlePath))
|
|
19
|
-
return bundlePath;
|
|
20
|
-
const distPath = join(root, PACKAGE_NAME, "dist", "index.js");
|
|
21
|
-
if (existsSync(distPath))
|
|
22
|
-
return distPath;
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
// package manager not available
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Collect the original trailing args (after `--`) that were passed to the
|
|
32
|
-
* pm2-managed script, so they can be forwarded when doing `pm2 delete` +
|
|
33
|
-
* `pm2 start`. pm2 sets `PM2_RESTART_ARGS` or we can read from process.argv.
|
|
34
|
-
*/
|
|
35
|
-
function collectPm2TrailingArgs() {
|
|
36
|
-
const argv = process.argv.slice(2);
|
|
37
|
-
const args = [];
|
|
38
|
-
for (let i = 0; i < argv.length; i++) {
|
|
39
|
-
const arg = argv[i];
|
|
40
|
-
if (arg === "--profile" && i + 1 < argv.length) {
|
|
41
|
-
args.push("--profile", argv[++i]);
|
|
42
|
-
}
|
|
43
|
-
else if (arg === "--debug" || arg === "-d") {
|
|
44
|
-
args.push("--debug");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return args;
|
|
48
|
-
}
|
|
49
7
|
export function isElectronChild() {
|
|
50
8
|
return process.env.VISIONCLAW_ELECTRON === "1";
|
|
51
9
|
}
|
|
@@ -71,18 +29,6 @@ async function restartViaProcessManager(pm) {
|
|
|
71
29
|
}
|
|
72
30
|
if (pm === "pm2") {
|
|
73
31
|
const pmId = process.env.pm_id ?? process.env.name ?? PACKAGE_NAME;
|
|
74
|
-
const newEntry = resolveGlobalBundlePath();
|
|
75
|
-
if (newEntry) {
|
|
76
|
-
logger.system(`pm2: switching entry to ${newEntry}`);
|
|
77
|
-
await execAsync(`pm2 delete ${pmId}`).catch((_e) => { });
|
|
78
|
-
const interpreter = process.execPath;
|
|
79
|
-
const trailingArgs = collectPm2TrailingArgs();
|
|
80
|
-
const trailingSuffix = trailingArgs.length > 0
|
|
81
|
-
? ` -- ${trailingArgs.join(" ")}`
|
|
82
|
-
: "";
|
|
83
|
-
const { stdout, stderr } = await execAsync(`pm2 start "${newEntry}" --name ${PACKAGE_NAME} --interpreter "${interpreter}"${trailingSuffix}`);
|
|
84
|
-
return (stdout + stderr).trim();
|
|
85
|
-
}
|
|
86
32
|
const { stdout, stderr } = await execAsync(`pm2 restart ${pmId}`);
|
|
87
33
|
return (stdout + stderr).trim();
|
|
88
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restart.js","sourceRoot":"","sources":["../../src/utils/restart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"restart.js","sourceRoot":"","sources":["../../src/utils/restart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC,MAAM,YAAY,GAAG,YAAY,CAAC;AAClC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,MAAM,UAAU,eAAe;IAC7B,OAAO,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,GAAG,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,IAAI,eAAe,EAAE,EAAE,CAAC;QACtB,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,C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