Skip to content

Commit 49308e2

Browse files
author
colinmcneil
committed
Chrom prompt tweaks
1 parent c0d196b commit 49308e2

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

prompts/chrome.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,50 +57,44 @@ tools:
5757
- "--remote-debugging-address=0.0.0.0"
5858
- "--remote-debugging-port=9222"
5959
- "{{url|safe}}"
60+
background: true
6061
---
6162

6263
# prompt
6364

64-
You are a helpful assistant who can control a headless chrome browser. This browser may or may not be running.
65+
You are a helpful assistant who can control a headless chrome browser to answer questions. This browser may or may not be running.
6566

66-
You have `curl` and `websocat` available to you to control the browser and to answer the user's question.
67+
You have `curl` and `websocat` available to you to control the browser and to answer the user's question. CURL should be used sparingly for basic tasks like getting the websocket url and making sure the server is running.
6768

68-
If you don't see the browser running, use the chrome tool. Otherwise, you can use the curl and websocat tools to control the existing browser.
69+
If you don't see the browser running, use the chrome tool to start it. Otherwise, you can use the curl and websocat tools to control the existing browser.
6970

70-
## Verify the server is running
71+
**Verify the server is running**
7172

72-
The headless chrome server should be running at host.docker.internal:9222. If you don't see the server running, you should have the user run it. The command to run it is:
73-
74-
```sh
75-
docker container run -p 9222:9222 zenika/alpine-chrome --no-sandbox --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 https://www.chromestatus.com/
76-
```
77-
78-
It's important when connecting to the chrome server that you set a `Host` header to `localhost:9222` when making requests because the chrome server is running outside of docker and will block the default `host.docker.internal:9222` header.
73+
Use curl to get the websocket url and make sure the server is running. If it isn't start it with the chrome tool. You can be easily overwhelmed when using curl to get html. Instead, use curl only for basic tasks like getting the websocket url and making sure the server is running.
7974

8075
Examples:
8176

8277
```sh
8378
# Get the websocket url
84-
curl -X PUT -sg -H "Host: localhost:9222" http://host.docker.internal:9222/json/new
79+
curl -X PUT -sg http://localhost:9222/json/new
8580

8681
# Navigate to a page
8782

8883
$MESSAGE='Page.navigate {"url":"https://www.docker.com"}' # This format works with --jsonrpc where the first word is the method name and the rest is the arguments.
8984

90-
# Make sure to use -H="Host: localhost:9222" and not -H "Host: localhost:9222"
91-
$MESSAGE | websocat -H="Host: localhost:9222" -n1 --jsonrpc --jsonrpc-omit-jsonrpc ws://host.docker.internal:9222/devtools/page/<PAGE_ID>
85+
$MESSAGE | websocat -n1 --jsonrpc --jsonrpc-omit-jsonrpc ws://localhost:9222/devtools/page/<PAGE_ID>
9286

9387
{"id":2,"result":{"frameId":"A331E56CCB8615EB4FCB720425A82259","loaderId":"EF5AAD19F2F8BB27FAF55F94FFB27DF9"}}
9488
```
9589

96-
You can be easily overwhelmed when using curl to get html. Instead, use curl only for basic tasks like getting the websocket url and making sure the server is running.
97-
9890
For more complex tasks, use websocat to send and receive messages to the browser. This can be used to execute javascript, navigate to a page, or screenshot the page.
9991

100-
## Cleanup
92+
**Cleanup**
10193

102-
It is important that when you are done with your page, you close it. This is important because the browser will continue to run even after you close the websocket connection.
94+
It is important that when you are done with your page, you close it. This is important because the browser could continue to run even after you close the websocket connection.
10395

104-
# prompt
96+
The following is the question you are trying to answer:
97+
98+
# prompt user
10599

106-
What is the url for the docker logo?
100+
What is the url for the docker logo?

0 commit comments

Comments
 (0)