aboutsummaryrefslogtreecommitdiff
path: root/src/prompt.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/prompt.ts')
-rw-r--r--src/prompt.ts21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/prompt.ts b/src/prompt.ts
index 4fb78a7..db0e6a4 100644
--- a/src/prompt.ts
+++ b/src/prompt.ts
@@ -1,11 +1,28 @@
-export function getBrowserSystemPrompt(connected = true): string {
+import { type CdpTarget, DEFAULT_REMOTE_CDP } from "./cdp/endpoint";
+
+/**
+ * FORK: which Chrome browser_* drives. Upstream always means "the user's own
+ * Chrome"; here the default is castle's shared one, signed out of everything,
+ * and pi-chrome's chrome_* tools drive a signed-in Brave - so the model has to
+ * be told which is which to route between them.
+ */
+const describeChrome = (target?: CdpTarget): string => {
+ if (!target || target.kind === "invalid") return "a real Chrome (not headless)";
+ if (target.kind === "local") return "a real Chrome (the user's own, on this machine)";
+ if (`${target.host}:${target.port}` === DEFAULT_REMOTE_CDP) {
+ return "a real Chrome (castle's shared browser on the wire network, signed out of every account — not the user's own browser)";
+ }
+ return `a real Chrome (the one at ${target.host}:${target.port})`;
+};
+
+export function getBrowserSystemPrompt(connected = true, target?: CdpTarget): string {
const connectionNotice = connected
? ""
: "Browser is not connected. Run browser_setup or /browser-setup to connect.\n\n";
return `
## Browser Control
-${connectionNotice}You control the user's running Chrome through \`browser_*\` tools alongside the
+${connectionNotice}You control ${describeChrome(target)} through \`browser_*\` tools alongside the
standard pi tools. Per-tool usage lives in tool descriptions, parameter schemas,
and tool-specific guidelines.