webhelm 1.0.59 → 1.0.60

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webhelm",
3
- "version": "1.0.59",
3
+ "version": "1.0.60",
4
4
  "description": "Agent browser automation in a visible managed Chrome with persistent JavaScript sessions",
5
5
  "type": "module",
6
6
  "bin": {
@@ -106,8 +106,22 @@ export function chromeMajorFromVersion(versionText){
106
106
  if(!Number.isSafeInteger(major)||major<50)throw Error(`Cannot determine managed Chrome version: ${versionText}`);
107
107
  return major;
108
108
  }
109
- function chromeMajor(chromePath){
110
- return chromeMajorFromVersion(execFileSync(chromePath,['--version'],{encoding:'utf8',timeout:5000}).trim());
109
+ export function chromeMajor(chromePath,{platform=process.platform,exec=execFileSync,realpath=fs.realpathSync}={}){
110
+ const options={encoding:'utf8',timeout:5000};
111
+ if(platform==='darwin'){
112
+ // Launching Chrome --version can initialize its Framework and crash during
113
+ // an application auto-update. Read the selected bundle instead, including
114
+ // symlinked custom executable paths. Never spawn Chrome as a fallback.
115
+ const executable=realpath(chromePath);
116
+ const contents=path.dirname(path.dirname(executable));
117
+ if(path.basename(path.dirname(executable))!=='MacOS'||path.basename(contents)!=='Contents'||!path.dirname(contents).endsWith('.app'))
118
+ throw Error('Managed Chrome executable must be inside a macOS application bundle');
119
+ const plist=path.join(contents,'Info.plist');
120
+ const version=exec('/usr/libexec/PlistBuddy',['-c','Print :CFBundleShortVersionString',plist],options).trim();
121
+ if(!/^\d+(?:\.\d+)+$/.test(version))throw Error('Cannot determine managed Chrome bundle version');
122
+ return chromeMajorFromVersion('Chrome '+version);
123
+ }
124
+ return chromeMajorFromVersion(exec(chromePath,['--version'],options).trim());
111
125
  }
112
126
  export function chromeLaunchArgs(profile,port,extensionPath,major){
113
127
  const args=[`--user-data-dir=${profile}`,`--remote-debugging-port=${port}`,'--enable-features=WebMCP'];
@@ -131,13 +145,16 @@ export async function ensureManagedChrome(){
131
145
  if(override)return {mode:'override',reused:true,endpoint:override,profile_dir:PROFILE};
132
146
  const port=await choosePort();
133
147
  const chrome=browserExecutable();
148
+ const major=chromeMajor(chrome);
134
149
  const extension=stageExtension();
135
- const log=fs.openSync(path.join(ROOT,'managed-chrome.log'),'a');
136
150
  fs.mkdirSync(PROFILE,{recursive:true});
137
- const child=spawn(chrome,chromeLaunchArgs(PROFILE,port,extension.path,chromeMajor(chrome)),
138
- {detached:true,stdio:['ignore',log,log]});
139
- child.unref();
140
- fs.closeSync(log);
151
+ const log=fs.openSync(path.join(ROOT,'managed-chrome.log'),'a');
152
+ let child;
153
+ try{
154
+ child=spawn(chrome,chromeLaunchArgs(PROFILE,port,extension.path,major),
155
+ {detached:true,stdio:['ignore',log,log]});
156
+ child.unref();
157
+ }finally{fs.closeSync(log);}
141
158
  for(let tries=0;tries<100;tries++){
142
159
  if(await endpointLive(port)){
143
160
  const state={chrome_path:chrome,pid:child.pid,port,profile_dir:PROFILE};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "WebHelm",
4
- "version": "1.0.59",
4
+ "version": "1.0.60",
5
5
  "description": "Own named Chrome tab-group workspaces and lazy reusable tab pools for browser agents.",
6
6
  "permissions": [
7
7
  "storage",