granclaw 0.0.1-beta.1 → 0.0.1-beta.3
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/dist/index.js +86 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -143,6 +143,91 @@ Install from https://claude.ai/download, then rerun.
|
|
|
143
143
|
process.exit(1);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Return the path to a real system Chrome/Chromium install, or null if none
|
|
148
|
+
* is found. Deliberately excludes ~/.agent-browser/browsers/ (Chrome for
|
|
149
|
+
* Testing) — GranClaw requires a real browser installed on the system.
|
|
150
|
+
*
|
|
151
|
+
* Respects AGENT_BROWSER_EXECUTABLE_PATH for users who want a custom binary.
|
|
152
|
+
*/
|
|
153
|
+
function detectSystemChrome() {
|
|
154
|
+
const override = process.env.AGENT_BROWSER_EXECUTABLE_PATH;
|
|
155
|
+
if (override)
|
|
156
|
+
return fs_1.default.existsSync(override) ? override : null;
|
|
157
|
+
const platform = os_1.default.platform();
|
|
158
|
+
if (platform === 'darwin') {
|
|
159
|
+
const candidates = [
|
|
160
|
+
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
161
|
+
'/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary',
|
|
162
|
+
'/Applications/Chromium.app/Contents/MacOS/Chromium',
|
|
163
|
+
'/Applications/Brave Browser.app/Contents/MacOS/Brave Browser',
|
|
164
|
+
path_1.default.join(os_1.default.homedir(), 'Applications/Google Chrome.app/Contents/MacOS/Google Chrome'),
|
|
165
|
+
];
|
|
166
|
+
return candidates.find((p) => fs_1.default.existsSync(p)) ?? null;
|
|
167
|
+
}
|
|
168
|
+
if (platform === 'linux') {
|
|
169
|
+
const candidates = [
|
|
170
|
+
'/usr/bin/google-chrome',
|
|
171
|
+
'/usr/bin/google-chrome-stable',
|
|
172
|
+
'/usr/bin/chromium',
|
|
173
|
+
'/usr/bin/chromium-browser',
|
|
174
|
+
'/snap/bin/chromium',
|
|
175
|
+
'/usr/bin/brave-browser',
|
|
176
|
+
'/usr/bin/microsoft-edge',
|
|
177
|
+
];
|
|
178
|
+
return candidates.find((p) => fs_1.default.existsSync(p)) ?? null;
|
|
179
|
+
}
|
|
180
|
+
if (platform === 'win32') {
|
|
181
|
+
const local = process.env.LOCALAPPDATA ?? '';
|
|
182
|
+
const pf = process.env.ProgramFiles ?? 'C:\\Program Files';
|
|
183
|
+
const pf86 = process.env['ProgramFiles(x86)'] ?? 'C:\\Program Files (x86)';
|
|
184
|
+
const candidates = [
|
|
185
|
+
path_1.default.join(local, 'Google', 'Chrome', 'Application', 'chrome.exe'),
|
|
186
|
+
path_1.default.join(pf, 'Google', 'Chrome', 'Application', 'chrome.exe'),
|
|
187
|
+
path_1.default.join(pf86, 'Google', 'Chrome', 'Application', 'chrome.exe'),
|
|
188
|
+
path_1.default.join(local, 'BraveSoftware', 'Brave-Browser', 'Application', 'brave.exe'),
|
|
189
|
+
path_1.default.join(pf, 'BraveSoftware', 'Brave-Browser', 'Application', 'brave.exe'),
|
|
190
|
+
path_1.default.join(local, 'Microsoft', 'Edge', 'Application', 'msedge.exe'),
|
|
191
|
+
path_1.default.join(pf, 'Microsoft', 'Edge', 'Application', 'msedge.exe'),
|
|
192
|
+
];
|
|
193
|
+
return candidates.find((p) => fs_1.default.existsSync(p)) ?? null;
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
function requireAgentBrowser() {
|
|
198
|
+
try {
|
|
199
|
+
(0, child_process_1.execSync)('agent-browser --version', { stdio: 'ignore' });
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
console.error(`
|
|
203
|
+
error: agent-browser not found.
|
|
204
|
+
|
|
205
|
+
GranClaw requires \`agent-browser\` for browser automation.
|
|
206
|
+
|
|
207
|
+
npm install -g agent-browser
|
|
208
|
+
`);
|
|
209
|
+
process.exit(1);
|
|
210
|
+
}
|
|
211
|
+
const chrome = detectSystemChrome();
|
|
212
|
+
if (!chrome) {
|
|
213
|
+
const platform = os_1.default.platform();
|
|
214
|
+
const installLink = 'https://google.com/chrome';
|
|
215
|
+
const linuxExtra = platform === 'linux'
|
|
216
|
+
? '\n sudo apt install google-chrome-stable # Debian/Ubuntu'
|
|
217
|
+
: '';
|
|
218
|
+
console.error(`
|
|
219
|
+
error: Chrome not found.
|
|
220
|
+
|
|
221
|
+
GranClaw requires Google Chrome (or Chromium / Brave / Edge) installed on
|
|
222
|
+
your system. Install it from:
|
|
223
|
+
|
|
224
|
+
${installLink}${linuxExtra}
|
|
225
|
+
|
|
226
|
+
To use a custom binary, set AGENT_BROWSER_EXECUTABLE_PATH before running.
|
|
227
|
+
`);
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
146
231
|
function cliPackageDir() {
|
|
147
232
|
// dist/index.js runs at <cli-pkg>/dist/, so the package root is one up.
|
|
148
233
|
return path_1.default.resolve(__dirname, '..');
|
|
@@ -152,6 +237,7 @@ function startServer(parsed) {
|
|
|
152
237
|
const templatesDir = path_1.default.join(cliPackageDir(), 'templates');
|
|
153
238
|
const staticDir = path_1.default.join(cliPackageDir(), 'dist', 'frontend');
|
|
154
239
|
requireClaudeCli();
|
|
240
|
+
requireAgentBrowser();
|
|
155
241
|
(0, home_js_1.seedHomeIfNeeded)(homeDir, templatesDir);
|
|
156
242
|
const port = parsed.port ?? (Number(process.env.PORT) || DEFAULT_PORT);
|
|
157
243
|
const env = {
|