webhelm 1.0.31 → 1.0.32
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/README.md +1 -1
- package/package.json +1 -1
- package/runtime/chrome.mjs +2 -2
- package/runtime/cli-help.mjs +0 -12
- package/runtime/cli.mjs +0 -7
- package/runtime/config-paths.mjs +3 -6
- package/runtime/node-daemon.mjs +2 -2
- package/runtime/migrate.mjs +0 -80
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ The Platform Action implementation and its verification belong in
|
|
|
88
88
|
|
|
89
89
|
## Architecture and compatibility
|
|
90
90
|
|
|
91
|
-
The Runtime stores
|
|
91
|
+
The Runtime stores the Chrome profile under `~/.local/webhelm/chrome` and the persistent FIFO queue and IPC socket under `~/.config/webhelm/runtime/`. The runtime refuses to start against a conflicting Chrome profile rather than silently replacing an existing login. Session idle GC runs on Node before new Session allocation (5 minutes without operations or explicit heartbeat); no background sweep is started. A timed-out Session refuses subsequent exec, platform Actions and heartbeat, while already-issued browser effects retain tab ownership until settled. A stop that times out while queued cannot execute a late release, and a stop already physically releasing keeps its Session closing until the release finishes. Managed tabs are navigated back to their Extension idle URL instead of closing CDP targets; the Extension does not use `tab.lastAccessed` GC. An async Session execution has a finite deadline: if it expires, its helper capabilities are revoked and the poisoned Session is collected on the next Tab request (or immediately by an explicit stop). Session stop also has a bounded drain/release deadline and cannot leave a permanent closing flag. Client IPC requests have an independent absolute timeout and return an error if the daemon does not respond. These safeguards do not introduce periodic background GC. Only one daemon is permitted to own the queue. A CLI package update does not kill a running daemon or close another agent's tabs; upgrade daemons when idle.
|
|
92
92
|
|
|
93
93
|
NeoY and Relay can continue using `webhelm` session commands, `result.stdout` JSON receipts, and `admin_helper` returned by `status`. An `admin_helper` inside the installed Skill is a stable connector to the same Node IPC socket. `webhelm capacity` replaces the legacy Python capacity probe.
|
|
94
94
|
|
package/package.json
CHANGED
package/runtime/chrome.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import net from 'node:net';
|
|
4
4
|
import { spawn, execFileSync } from 'node:child_process';
|
|
5
5
|
|
|
6
|
-
import { CONFIG_ROOT, PROFILE_DIR, OLD_PROFILE_DIR,
|
|
6
|
+
import { CONFIG_ROOT, PROFILE_DIR, OLD_PROFILE_DIR, assertProfileConsistency } from './config-paths.mjs';
|
|
7
7
|
import { stageExtension } from './extension-manager.mjs';
|
|
8
8
|
const ROOT = CONFIG_ROOT;
|
|
9
9
|
const PROFILE = PROFILE_DIR;
|
|
@@ -122,7 +122,7 @@ export async function ensureManagedChrome(){
|
|
|
122
122
|
// Explicit CDP endpoints also support hermetic mock-browser tests.
|
|
123
123
|
const specified=process.env.WEBHELM_CDP_URL;
|
|
124
124
|
if (specified) return {mode:'override',reused:true,endpoint:specified,profile_dir:PROFILE};
|
|
125
|
-
|
|
125
|
+
assertProfileConsistency();
|
|
126
126
|
return lockOwnership(async()=>{
|
|
127
127
|
const existing=await fromState()||await discover();
|
|
128
128
|
if(existing)return {...existing, mode:'managed',reused:true,endpoint:`http://127.0.0.1:${existing.port}`};
|
package/runtime/cli-help.mjs
CHANGED
|
@@ -25,7 +25,6 @@ Commands:
|
|
|
25
25
|
webhelm platform run NAME ACTION [...] Execute an installed site Action
|
|
26
26
|
webhelm platform sync Update installed site Actions
|
|
27
27
|
webhelm platform publish --message MSG Publish reviewed site Action changes
|
|
28
|
-
webhelm migrate Migrate supported legacy local browser data
|
|
29
28
|
webhelm help [command [subcommand]] Show command help
|
|
30
29
|
Options:
|
|
31
30
|
-h, --help Show help without running the command
|
|
@@ -87,17 +86,6 @@ Output: JSON capacity information.
|
|
|
87
86
|
|
|
88
87
|
Example:
|
|
89
88
|
webhelm capacity`,
|
|
90
|
-
migrate: `webhelm migrate — migrate supported legacy local browser data
|
|
91
|
-
|
|
92
|
-
Usage:
|
|
93
|
-
webhelm migrate
|
|
94
|
-
|
|
95
|
-
Run only after stopping the legacy daemon and browser and draining Sessions.
|
|
96
|
-
Preserves the signed-in browser profile and supported local state.
|
|
97
|
-
Output: JSON with migration results.
|
|
98
|
-
|
|
99
|
-
Example:
|
|
100
|
-
webhelm migrate`,
|
|
101
89
|
session: `webhelm session — manage persistent JavaScript browser Sessions
|
|
102
90
|
|
|
103
91
|
Usage:
|
package/runtime/cli.mjs
CHANGED
|
@@ -7,7 +7,6 @@ import { randomUUID } from 'node:crypto';
|
|
|
7
7
|
import { ensureDaemon, request, SOCKET } from './node-daemon.mjs';
|
|
8
8
|
import { PLATFORMS, listPlatforms, platformProfile, actionPath, validateConfig } from './platforms.mjs';
|
|
9
9
|
import { ACTIONS_DIR, ensureActions, syncActions, publishActions } from './actions-repo.mjs';
|
|
10
|
-
import { migrateConfig, migrateChromeProfile } from './migrate.mjs';
|
|
11
10
|
import { installLoginGuard, stageRuntimeForLoginGuard } from './login-guard.mjs';
|
|
12
11
|
import { cliHelp } from './cli-help.mjs';
|
|
13
12
|
|
|
@@ -105,12 +104,6 @@ async function main(args = process.argv.slice(2)) {
|
|
|
105
104
|
return console.log(cliHelp(topics));
|
|
106
105
|
}
|
|
107
106
|
rejectWorkspaceOverride(args);
|
|
108
|
-
if (group === 'migrate') {
|
|
109
|
-
await ensureActions(); // ~/.local/webhelm is the Actions Git checkout, never create an empty replacement.
|
|
110
|
-
const legacy=await migrateConfig();
|
|
111
|
-
const chrome=await migrateChromeProfile();
|
|
112
|
-
return emit({legacy,chrome});
|
|
113
|
-
}
|
|
114
107
|
if (group === 'setup') {
|
|
115
108
|
const repo=await ensureActions();
|
|
116
109
|
const chrome=await ensureDaemon();
|
package/runtime/config-paths.mjs
CHANGED
|
@@ -3,18 +3,15 @@ import path from 'node:path';
|
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
|
|
5
5
|
export const CONFIG_ROOT = path.resolve(process.env.WEBHELM_CONFIG_ROOT || path.join(os.homedir(), '.config', 'webhelm'));
|
|
6
|
-
export const LEGACY_ROOT = path.resolve(process.env.WEBHELM_LEGACY_ROOT || (process.env.WEBHELM_CONFIG_ROOT ? path.join(CONFIG_ROOT,'legacy-browser-workspace') : path.join(os.homedir(), '.config', 'browser-workspace')));
|
|
7
6
|
export const LOCAL_ROOT = path.resolve(process.env.WEBHELM_LOCAL_ROOT || path.join(os.homedir(), '.local', 'webhelm'));
|
|
8
7
|
export const OLD_PROFILE_DIR = path.join(CONFIG_ROOT, 'chrome');
|
|
9
8
|
export const PROFILE_DIR = path.join(LOCAL_ROOT, 'chrome');
|
|
10
9
|
export const RUNTIME_DIR = path.join(CONFIG_ROOT, 'runtime');
|
|
11
10
|
|
|
12
|
-
//
|
|
13
|
-
export function
|
|
14
|
-
if (fs.existsSync(path.join(LEGACY_ROOT, 'chrome')) && !fs.existsSync(OLD_PROFILE_DIR) && !fs.existsSync(PROFILE_DIR))
|
|
15
|
-
throw Error(`Legacy Chrome profile exists at ${LEGACY_ROOT}. Stop old Chrome and WebHelm daemon, then run webhelm migrate.`);
|
|
11
|
+
// Refuse to start Chrome when the current WebHelm profile is not safely migrated.
|
|
12
|
+
export function assertProfileConsistency() {
|
|
16
13
|
if (fs.existsSync(OLD_PROFILE_DIR) && !fs.existsSync(PROFILE_DIR))
|
|
17
|
-
throw Error(`Chrome profile
|
|
14
|
+
throw Error(`WebHelm Chrome profile exists at ${OLD_PROFILE_DIR}, but ${PROFILE_DIR} is missing. Stop active Sessions, WebHelm daemon and Chrome before moving the profile to ${PROFILE_DIR}.`);
|
|
18
15
|
if (fs.existsSync(OLD_PROFILE_DIR) && fs.existsSync(PROFILE_DIR) &&
|
|
19
16
|
fs.realpathSync(OLD_PROFILE_DIR)!==fs.realpathSync(PROFILE_DIR))
|
|
20
17
|
throw Error('Two distinct WebHelm Chrome Profiles exist; refusing to use either until reconciled.');
|
package/runtime/node-daemon.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { stopMatchingSessions } from './session-control.mjs';
|
|
|
14
14
|
import { ensureManagedChrome } from './chrome.mjs';
|
|
15
15
|
import { ensureExtensionLoaded } from './extension-manager.mjs';
|
|
16
16
|
import { createManagedChromeGuard } from './managed-chrome-guard.mjs';
|
|
17
|
-
import { PROFILE_DIR, RUNTIME_DIR,
|
|
17
|
+
import { PROFILE_DIR, RUNTIME_DIR, assertProfileConsistency } from './config-paths.mjs';
|
|
18
18
|
|
|
19
19
|
const ROOT = path.dirname(fileURLToPath(import.meta.url));
|
|
20
20
|
const PACKAGE_VERSION=JSON.parse(fs.readFileSync(new URL('../package.json',import.meta.url),'utf8')).version;
|
|
@@ -808,6 +808,6 @@ async function request(payload,ensure=true){
|
|
|
808
808
|
conn.on('error',error=>finish(error));
|
|
809
809
|
});
|
|
810
810
|
}
|
|
811
|
-
export async function ensureDaemon(){try{const p=await request({op:'ping'},false);if(p.ok)return p}catch{}if(!process.env.WEBHELM_CDP_URL)
|
|
811
|
+
export async function ensureDaemon(){try{const p=await request({op:'ping'},false);if(p.ok)return p}catch{}if(!process.env.WEBHELM_CDP_URL)assertProfileConsistency();fs.mkdirSync(RUNTIME,{recursive:true,mode:0o700});if(fs.existsSync(LOCK)){let owner=0;try{owner=Number(fs.readFileSync(LOCK,'utf8').trim())}catch{};let alive=false;if(owner>0)try{process.kill(owner,0);alive=true}catch{};if(alive)throw Error(`daemon owner lock exists but socket is unreachable; refusing duplicate startup (${LOCK})`);fs.unlinkSync(LOCK)}const child=await import('node:child_process');const log=fs.openSync(path.join(RUNTIME,'session-node.log'),'a');child.spawn(process.execPath,[fileURLToPath(import.meta.url),'daemon'],{detached:true,stdio:['ignore',log,log],env:process.env}).unref();for(let i=0;i<100;i++){await delay(100);try{const p=await request({op:'ping'},false);if(p.ok)return p}catch{}}throw Error(`WebHelm Node daemon did not start; see ${path.join(RUNTIME,'session-node.log')}`)}
|
|
812
812
|
if(process.argv[2]==='daemon')main().catch(e=>{console.error(e);process.exit(1)});
|
|
813
813
|
export {request,SOCKET,RUNTIME};
|
package/runtime/migrate.mjs
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { execFileSync } from 'node:child_process';
|
|
4
|
-
import net from 'node:net';
|
|
5
|
-
import { CONFIG_ROOT, LEGACY_ROOT, OLD_PROFILE_DIR, PROFILE_DIR } from './config-paths.mjs';
|
|
6
|
-
|
|
7
|
-
function liveSocket(socketPath) {
|
|
8
|
-
return new Promise(resolve => {
|
|
9
|
-
const socket = net.createConnection(socketPath);
|
|
10
|
-
const finish = result => { socket.destroy(); resolve(result); };
|
|
11
|
-
socket.once('connect', () => finish(true));
|
|
12
|
-
socket.once('error', () => finish(false));
|
|
13
|
-
socket.setTimeout(1200, () => finish(true)); // Fail closed if probing hangs.
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function migrateConfig({ legacyRoot = LEGACY_ROOT, configRoot = CONFIG_ROOT,
|
|
18
|
-
processList = () => execFileSync('ps', ['-axo', 'command='], { encoding: 'utf8' }),
|
|
19
|
-
socketCheck = liveSocket } = {}) {
|
|
20
|
-
const legacy = path.resolve(legacyRoot);
|
|
21
|
-
const target = path.resolve(configRoot);
|
|
22
|
-
if (legacy === target) throw Error('Legacy and new config paths are identical');
|
|
23
|
-
let oldStat;
|
|
24
|
-
try { oldStat = fs.lstatSync(legacy); }
|
|
25
|
-
catch (e) { if (e.code === 'ENOENT') return { status: 'not_needed', config_root: target }; throw e; }
|
|
26
|
-
if (oldStat.isSymbolicLink()) {
|
|
27
|
-
if (fs.existsSync(target) && fs.realpathSync(legacy) === fs.realpathSync(target))
|
|
28
|
-
return { status: 'already_migrated', config_root: target, compatibility_symlink: legacy };
|
|
29
|
-
throw Error(`Legacy path is a different symlink: ${legacy}`);
|
|
30
|
-
}
|
|
31
|
-
if (!oldStat.isDirectory()) throw Error(`Legacy path is not a directory: ${legacy}`);
|
|
32
|
-
if (fs.existsSync(target)) throw Error(`Target already exists; refusing to overwrite: ${target}`);
|
|
33
|
-
const running = processList().split('\n').filter(line =>
|
|
34
|
-
line.includes(`--user-data-dir=${path.join(legacy, 'chrome')}`) ||
|
|
35
|
-
(line.includes('node-daemon.mjs daemon') && !line.includes('migrate.mjs')));
|
|
36
|
-
if (running.length) throw Error('Chrome or WebHelm daemon is still running; stop Sessions, daemon and Chrome before migration');
|
|
37
|
-
const socket = path.join(legacy, 'runtime', 'session-node.sock');
|
|
38
|
-
if (fs.existsSync(socket) && await socketCheck(socket))
|
|
39
|
-
throw Error('Legacy daemon socket is active; refusing migration');
|
|
40
|
-
fs.renameSync(legacy, target); // Same-volume atomic directory move; preserve Chrome data and FIFO WAL.
|
|
41
|
-
try { fs.symlinkSync(target, legacy, 'dir'); }
|
|
42
|
-
catch (error) {
|
|
43
|
-
fs.renameSync(target, legacy);
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
return { status: 'migrated', config_root: target, compatibility_symlink: legacy };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Move only the Chrome Profile. Durable FIFO and logs stay under ~/.config/webhelm/runtime.
|
|
50
|
-
// Chrome must be stopped because its SingletonLock and keychain-bound profile
|
|
51
|
-
// resources cannot be safely relocated while the browser is still running.
|
|
52
|
-
export async function migrateChromeProfile({oldProfile=OLD_PROFILE_DIR,newProfile=PROFILE_DIR,
|
|
53
|
-
processList=()=>execFileSync('ps',['-axo','command='],{encoding:'utf8'}),
|
|
54
|
-
socketCheck=liveSocket}={}){
|
|
55
|
-
const old=path.resolve(oldProfile),target=path.resolve(newProfile);
|
|
56
|
-
if(old===target)throw Error('Chrome source and destination paths must differ');
|
|
57
|
-
if(fs.existsSync(target)){
|
|
58
|
-
if(!fs.existsSync(old))return {status:'already_migrated',profile_dir:target};
|
|
59
|
-
if(fs.realpathSync(old)===fs.realpathSync(target))return {status:'already_migrated',profile_dir:target,compatibility_symlink:old};
|
|
60
|
-
throw Error(`Different Chrome Profiles at ${old} and ${target}; refusing to overwrite`);
|
|
61
|
-
}
|
|
62
|
-
if(!fs.existsSync(old))return {status:'not_needed',profile_dir:target};
|
|
63
|
-
if(fs.lstatSync(old).isSymbolicLink() || !fs.statSync(old).isDirectory())
|
|
64
|
-
throw Error('Old Chrome Profile is not a regular directory');
|
|
65
|
-
const running=processList().split('\n').filter(s=>s.includes(`--user-data-dir=${old}`)||s.includes(`--user-data-dir=${target}`)||s.includes('node-daemon.mjs daemon') && !s.includes('migrate.mjs'));
|
|
66
|
-
if(running.length)throw Error('Managed Chrome or daemon is running; stop and drain before migrating Profile');
|
|
67
|
-
const socket=path.join(path.dirname(old),'runtime/session-node.sock');
|
|
68
|
-
if(fs.existsSync(socket)&&await socketCheck(socket))throw Error('Session daemon still accepting requests');
|
|
69
|
-
if(!fs.existsSync(path.join(old,'Default')))throw Error('Old Chrome Profile lacks Default; refusing to migrate');
|
|
70
|
-
const parent=path.dirname(target);
|
|
71
|
-
if(fs.existsSync(path.join(parent,'.git'))){
|
|
72
|
-
const info=path.join(parent,'.git/info/exclude');
|
|
73
|
-
const current=fs.existsSync(info)?fs.readFileSync(info,'utf8'):'';
|
|
74
|
-
if(!current.split(/\r?\n/).includes('/chrome/'))fs.appendFileSync(info,'\n/chrome/\n');
|
|
75
|
-
}
|
|
76
|
-
fs.mkdirSync(parent,{recursive:true});
|
|
77
|
-
fs.renameSync(old,target);
|
|
78
|
-
try{fs.symlinkSync(target,old,'dir');}catch(error){fs.renameSync(target,old);throw error;}
|
|
79
|
-
return {status:'migrated',profile_dir:target,compatibility_symlink:old};
|
|
80
|
-
}
|