pi-chrome 0.10.1 → 0.10.2
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "Pi Existing Chrome Profile Bridge",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.2",
|
|
5
5
|
"description": "Lets Pi control tabs in this existing Chrome profile via a local bridge at 127.0.0.1.",
|
|
6
6
|
"permissions": ["tabs", "scripting", "storage", "activeTab", "alarms", "webNavigation", "debugger"],
|
|
7
7
|
"host_permissions": ["<all_urls>", "http://127.0.0.1:17318/*"],
|
|
@@ -546,27 +546,83 @@ Usage rules:
|
|
|
546
546
|
return matches.length > 0 ? matches : null;
|
|
547
547
|
},
|
|
548
548
|
handler: async (args, ctx) => {
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
549
|
+
const rawArg = (args || "").trim().toLowerCase();
|
|
550
|
+
|
|
551
|
+
// Resolve current status once for both branches (interactive picker + direct args).
|
|
552
|
+
let status: { mode: string; attachedTabs: number[]; permissionGranted: boolean } | undefined;
|
|
553
|
+
try {
|
|
554
|
+
status = (await bridge.send("trusted.status", {}, 5_000)) as typeof status;
|
|
555
|
+
} catch (error) {
|
|
556
|
+
ctx.ui.notify(`Failed to read trusted mode: ${(error as Error).message}`, "warning");
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
if (!status) return;
|
|
560
|
+
|
|
561
|
+
if (!status.permissionGranted) {
|
|
562
|
+
ctx.ui.notify(
|
|
563
|
+
"chrome.debugger API unavailable — the extension is missing the 'debugger' permission. Open chrome://extensions, reload 'Pi Existing Chrome Profile Bridge', and accept the new permission prompt.",
|
|
564
|
+
"warning",
|
|
565
|
+
);
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
const attached = status.attachedTabs?.length ? ` — currently attached to tab ${status.attachedTabs.join(",")}` : "";
|
|
570
|
+
const current = status.mode;
|
|
571
|
+
|
|
572
|
+
let target = rawArg;
|
|
573
|
+
if (target === "status") {
|
|
574
|
+
ctx.ui.notify(`Trusted-input mode: ${current}${attached}`, "info");
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
if (!target) {
|
|
578
|
+
// Interactive picker. Show current mode + tradeoffs in each label.
|
|
579
|
+
const options = [
|
|
580
|
+
`on${current === "on" ? " (current)" : ""} — all chrome_* tools via CDP; yellow debugger banner appears`,
|
|
581
|
+
`off${current === "off" ? " (current)" : ""} — synthetic DOM events only (default)`,
|
|
582
|
+
`auto${current === "auto" ? " (current)" : ""} — CDP only when a tool passes trusted=true`,
|
|
583
|
+
`status — print current mode and any attached tabs\u2026`,
|
|
584
|
+
];
|
|
585
|
+
const picked = await ctx.ui.select(
|
|
586
|
+
`Trusted-input mode (current: ${current}${attached})`,
|
|
587
|
+
options,
|
|
588
|
+
);
|
|
589
|
+
if (!picked) return; // cancelled
|
|
590
|
+
if (picked.startsWith("on")) target = "on";
|
|
591
|
+
else if (picked.startsWith("off")) target = "off";
|
|
592
|
+
else if (picked.startsWith("auto")) target = "auto";
|
|
593
|
+
else if (picked.startsWith("status")) {
|
|
594
|
+
ctx.ui.notify(`Trusted-input mode: ${current}${attached}`, "info");
|
|
595
|
+
return;
|
|
558
596
|
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
if (!["on", "off", "auto"].includes(target)) {
|
|
600
|
+
ctx.ui.notify(`Unknown argument '${rawArg}'. Use: on | off | auto | status, or run /chrome-trusted with no args for a picker.`, "warning");
|
|
559
601
|
return;
|
|
560
602
|
}
|
|
561
|
-
|
|
562
|
-
|
|
603
|
+
|
|
604
|
+
if (target === current) {
|
|
605
|
+
ctx.ui.notify(`Trusted-input mode already ${current}.`, "info");
|
|
563
606
|
return;
|
|
564
607
|
}
|
|
608
|
+
|
|
609
|
+
// Extra confirmation only on first-time "on" (warn about banner).
|
|
610
|
+
if (target === "on" && current === "off") {
|
|
611
|
+
const ok = await ctx.ui.confirm(
|
|
612
|
+
"Turn on trusted-input mode?",
|
|
613
|
+
"All chrome_* tools will dispatch through chrome.debugger (CDP). Events will arrive as isTrusted=true and satisfy user-activation gates (clipboard, fullscreen, autoplay, file picker).\n\nChrome will pin a yellow 'Pi Existing Chrome Profile Bridge started debugging this browser' banner to the top of any debugged tab while attached. Clicking 'Cancel' on that banner detaches the debugger.",
|
|
614
|
+
);
|
|
615
|
+
if (!ok) {
|
|
616
|
+
ctx.ui.notify("Trusted-input mode unchanged.", "info");
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
565
621
|
try {
|
|
566
|
-
const result = (await bridge.send("trusted.mode", { mode:
|
|
622
|
+
const result = (await bridge.send("trusted.mode", { mode: target }, 5_000)) as { mode: string };
|
|
567
623
|
if (result.mode === "on") {
|
|
568
624
|
ctx.ui.notify(
|
|
569
|
-
"Trusted-input mode ON.
|
|
625
|
+
"Trusted-input mode ON. chrome_* tools now dispatch through chrome.debugger. The yellow debugger banner will appear when Chrome is next driven.",
|
|
570
626
|
"info",
|
|
571
627
|
);
|
|
572
628
|
} else if (result.mode === "off") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-chrome",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "Drive your existing logged-in Chrome from Pi — no re-login, no throwaway profile, watch the agent work in real time (or toggle quiet background mode).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|