fix(cli): 自动拉起 daemon 走 boot.js(带 BrowserManager),修复 open/list/get 全 not found;daemon 增 visionl-daemon bin + start 指向 boot;docs 同步当前 CLI(无 daemon/page 子命令,Bing 易反爬请用百度等国内源)
This commit is contained in:
1 parent
36780493a5
commit
c3a7f74b1f
4 files changed
+50
-14
No files matched your search
@@ -20,7 +20,10 @@ export async function ensureDaemonRunning(port: number): Promise<VisionLClient>
|
||||
}
|
||||
}
|
||||
|
||||
const daemonEntryPath = path.resolve(__dirname, '../../daemon/dist/server.js');
|
||||
// Spawn the browser-enabled daemon entry (boot.js) so that page/content/
|
||||
// action routes are registered. Spawning server.js directly would start a
|
||||
// browser-less daemon that only serves /health.
|
||||
const daemonEntryPath = path.resolve(__dirname, '../../daemon/dist/boot.js');
|
||||
spawn('node', [daemonEntryPath], {
|
||||
env: { ...process.env, VISIONL_PORT: String(port) },
|
||||
stdio: 'ignore',
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"main": "./dist/index.js",
|
||||
"bin": {
|
||||
"visionl-daemon": "./dist/boot.js"
|
||||
},
|
||||
"scripts": {
|
||||
"typecheck": "tsc -b",
|
||||
"build": "tsc -b",
|
||||
"start": "node ./dist/index.js"
|
||||
"start": "node ./dist/boot.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@visionl/core": "*",
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { startServer } from './server.js';
|
||||
import { BrowserManager } from './browser-manager.js';
|
||||
|
||||
/**
|
||||
* boot is the browser-enabled daemon entry: it initializes a persistent
|
||||
* BrowserManager (anti-detection Chromium) and starts the HTTP+WS server with
|
||||
* it. Startup via the CLI must go through this entry so page/content/action
|
||||
* routes are actually registered (spawning server.js alone skips them).
|
||||
*/
|
||||
export async function boot(port: number, profile = 'desktop-chrome') {
|
||||
const bm = new BrowserManager(profile);
|
||||
await bm.init();
|
||||
console.log('[daemon] Browser initialized');
|
||||
const server = await startServer(port, bm);
|
||||
console.log('[daemon] Ready on port', port);
|
||||
return { bm, server };
|
||||
}
|
||||
|
||||
// Direct start when run as a script — the correct browser-enabled daemon entry.
|
||||
if (process.argv[1] && (process.argv[1].endsWith('boot.js') || process.argv[1].endsWith('boot.ts'))) {
|
||||
const port = parseInt(process.env.VISIONL_PORT || '9527', 10);
|
||||
const profile = process.env.VISIONL_PROFILE || 'desktop-chrome';
|
||||
boot(port, profile).catch((err) => {
|
||||
console.error('[daemon] Fatal:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user