chrome-relay 0.3.0 → 0.3.1
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/cli.js +13 -22
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -154,7 +154,7 @@ async function callTool(name, args) {
|
|
|
154
154
|
// src/program.ts
|
|
155
155
|
function buildProgram() {
|
|
156
156
|
const program = new Command();
|
|
157
|
-
program.name("chrome-relay").description("Connect your local Chrome browser to coding agents through a local bridge.").version(CHROME_RELAY_VERSION).showHelpAfterError().addHelpText(
|
|
157
|
+
program.name("chrome-relay").description("Connect your local Chrome browser to coding agents through a local bridge.").version(CHROME_RELAY_VERSION).showHelpAfterError().option("--group <name>", "target the active tab of a named group window (works at top level too)").enablePositionalOptions().addHelpText(
|
|
158
158
|
"after",
|
|
159
159
|
`
|
|
160
160
|
|
|
@@ -202,7 +202,8 @@ Notes:
|
|
|
202
202
|
function baseArgs(opts) {
|
|
203
203
|
const args = {};
|
|
204
204
|
if (opts.tab !== void 0) args.tabId = opts.tab;
|
|
205
|
-
|
|
205
|
+
const effectiveGroup = opts.group ?? program.opts().group;
|
|
206
|
+
if (effectiveGroup) args.groupName = effectiveGroup;
|
|
206
207
|
return args;
|
|
207
208
|
}
|
|
208
209
|
program.command("tabs").description("List open Chrome windows and tabs.").action(async () => {
|
|
@@ -229,8 +230,7 @@ Use "chrome-relay switch ${url}" to activate that tab, or "chrome-relay navigate
|
|
|
229
230
|
process.exit(1);
|
|
230
231
|
}
|
|
231
232
|
const args = { url };
|
|
232
|
-
|
|
233
|
-
if (opts.group) args.groupName = opts.group;
|
|
233
|
+
Object.assign(args, baseArgs(opts));
|
|
234
234
|
if (opts.new) args.newTab = true;
|
|
235
235
|
if (opts.inactive) args.active = false;
|
|
236
236
|
await run("chrome_navigate", args);
|
|
@@ -254,8 +254,7 @@ full-tab screenshot when an agent only needs to see one component.
|
|
|
254
254
|
)
|
|
255
255
|
).action(async (opts) => {
|
|
256
256
|
const args = {};
|
|
257
|
-
|
|
258
|
-
if (opts.group) args.groupName = opts.group;
|
|
257
|
+
Object.assign(args, baseArgs(opts));
|
|
259
258
|
if (opts.full) args.fullPage = true;
|
|
260
259
|
if (opts.bbox) args.bbox = opts.bbox;
|
|
261
260
|
if (opts.selector) args.selector = opts.selector;
|
|
@@ -284,8 +283,7 @@ full-tab screenshot when an agent only needs to see one component.
|
|
|
284
283
|
program.command("read").description("Extract page structure and interactive elements.").option("-i, --interactive", "return only interactive elements")
|
|
285
284
|
).action(async (opts) => {
|
|
286
285
|
const args = {};
|
|
287
|
-
|
|
288
|
-
if (opts.group) args.groupName = opts.group;
|
|
286
|
+
Object.assign(args, baseArgs(opts));
|
|
289
287
|
if (opts.interactive) args.interactiveOnly = true;
|
|
290
288
|
await run("chrome_read_page", args);
|
|
291
289
|
});
|
|
@@ -293,16 +291,14 @@ full-tab screenshot when an agent only needs to see one component.
|
|
|
293
291
|
program.command("click <selector>").description("Click an element by CSS selector.")
|
|
294
292
|
).action(async (selector, opts) => {
|
|
295
293
|
const args = { selector };
|
|
296
|
-
|
|
297
|
-
if (opts.group) args.groupName = opts.group;
|
|
294
|
+
Object.assign(args, baseArgs(opts));
|
|
298
295
|
await run("chrome_click_element", args);
|
|
299
296
|
});
|
|
300
297
|
tabOpt(
|
|
301
298
|
program.command("fill <selector> <value>").description("Fill an input or textarea.")
|
|
302
299
|
).action(async (selector, value, opts) => {
|
|
303
300
|
const args = { selector, value };
|
|
304
|
-
|
|
305
|
-
if (opts.group) args.groupName = opts.group;
|
|
301
|
+
Object.assign(args, baseArgs(opts));
|
|
306
302
|
await run("chrome_fill_or_select", args);
|
|
307
303
|
});
|
|
308
304
|
tabOpt(
|
|
@@ -321,8 +317,7 @@ For typing text into a field, use \`chrome-relay type\` instead.
|
|
|
321
317
|
)
|
|
322
318
|
).action(async (keys, opts) => {
|
|
323
319
|
const args = { keys };
|
|
324
|
-
|
|
325
|
-
if (opts.group) args.groupName = opts.group;
|
|
320
|
+
Object.assign(args, baseArgs(opts));
|
|
326
321
|
await run("chrome_keyboard", args);
|
|
327
322
|
});
|
|
328
323
|
tabOpt(
|
|
@@ -343,8 +338,7 @@ When to pick which:
|
|
|
343
338
|
)
|
|
344
339
|
).action(async (text, opts) => {
|
|
345
340
|
const args = { text };
|
|
346
|
-
|
|
347
|
-
if (opts.group) args.groupName = opts.group;
|
|
341
|
+
Object.assign(args, baseArgs(opts));
|
|
348
342
|
if (opts.selector) args.selector = opts.selector;
|
|
349
343
|
await run("chrome_type", args);
|
|
350
344
|
});
|
|
@@ -366,8 +360,7 @@ Notes:
|
|
|
366
360
|
)
|
|
367
361
|
).action(async (code, opts) => {
|
|
368
362
|
const args = { code };
|
|
369
|
-
|
|
370
|
-
if (opts.group) args.groupName = opts.group;
|
|
363
|
+
Object.assign(args, baseArgs(opts));
|
|
371
364
|
if (typeof opts.timeoutMs === "number") args.timeoutMs = opts.timeoutMs;
|
|
372
365
|
await run("chrome_evaluate", args);
|
|
373
366
|
});
|
|
@@ -413,16 +406,14 @@ Notes:
|
|
|
413
406
|
viewport.command("preset <name>").description("Apply a named device preset (iphone-14, pixel-7, desktop-1440, etc).")
|
|
414
407
|
).action(async (name, opts) => {
|
|
415
408
|
const args = { action: "preset", name };
|
|
416
|
-
|
|
417
|
-
if (opts.group) args.groupName = opts.group;
|
|
409
|
+
Object.assign(args, baseArgs(opts));
|
|
418
410
|
await run("chrome_viewport", args);
|
|
419
411
|
});
|
|
420
412
|
tabOpt(
|
|
421
413
|
viewport.command("clear").description("Drop the viewport override and return the tab to its native size.")
|
|
422
414
|
).action(async (opts) => {
|
|
423
415
|
const args = { action: "clear" };
|
|
424
|
-
|
|
425
|
-
if (opts.group) args.groupName = opts.group;
|
|
416
|
+
Object.assign(args, baseArgs(opts));
|
|
426
417
|
await run("chrome_viewport", args);
|
|
427
418
|
});
|
|
428
419
|
viewport.command("list").description("List available presets.").action(async () => {
|