agent-browser 0.20.7 → 0.20.9
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/README.md +7 -52
- package/bin/agent-browser-darwin-arm64 +0 -0
- package/bin/agent-browser-darwin-x64 +0 -0
- package/bin/agent-browser-linux-arm64 +0 -0
- package/bin/agent-browser-linux-musl-arm64 +0 -0
- package/bin/agent-browser-linux-musl-x64 +0 -0
- package/bin/agent-browser-linux-x64 +0 -0
- package/bin/agent-browser-win32-x64.exe +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -794,15 +794,15 @@ See the [environments example](examples/environments/) for a working demo with a
|
|
|
794
794
|
|
|
795
795
|
```typescript
|
|
796
796
|
import chromium from '@sparticuz/chromium';
|
|
797
|
-
import {
|
|
797
|
+
import { execSync } from 'child_process';
|
|
798
798
|
|
|
799
799
|
export async function handler() {
|
|
800
|
-
const
|
|
801
|
-
|
|
802
|
-
executablePath
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
800
|
+
const executablePath = await chromium.executablePath();
|
|
801
|
+
const result = execSync(
|
|
802
|
+
`AGENT_BROWSER_EXECUTABLE_PATH=${executablePath} agent-browser open https://example.com && agent-browser snapshot -i --json`,
|
|
803
|
+
{ encoding: 'utf-8' }
|
|
804
|
+
);
|
|
805
|
+
return JSON.parse(result);
|
|
806
806
|
}
|
|
807
807
|
```
|
|
808
808
|
|
|
@@ -953,51 +953,6 @@ Connect to `ws://localhost:9223` to receive frames and send input:
|
|
|
953
953
|
}
|
|
954
954
|
```
|
|
955
955
|
|
|
956
|
-
### Programmatic API
|
|
957
|
-
|
|
958
|
-
For advanced use, control streaming directly via the protocol:
|
|
959
|
-
|
|
960
|
-
```typescript
|
|
961
|
-
import { BrowserManager } from 'agent-browser';
|
|
962
|
-
|
|
963
|
-
const browser = new BrowserManager();
|
|
964
|
-
await browser.launch({ headless: true });
|
|
965
|
-
await browser.navigate('https://example.com');
|
|
966
|
-
|
|
967
|
-
// Start screencast
|
|
968
|
-
await browser.startScreencast(
|
|
969
|
-
(frame) => {
|
|
970
|
-
// frame.data is base64-encoded image
|
|
971
|
-
// frame.metadata contains viewport info
|
|
972
|
-
console.log('Frame received:', frame.metadata.deviceWidth, 'x', frame.metadata.deviceHeight);
|
|
973
|
-
},
|
|
974
|
-
{
|
|
975
|
-
format: 'jpeg',
|
|
976
|
-
quality: 80,
|
|
977
|
-
maxWidth: 1280,
|
|
978
|
-
maxHeight: 720,
|
|
979
|
-
}
|
|
980
|
-
);
|
|
981
|
-
|
|
982
|
-
// Inject mouse events
|
|
983
|
-
await browser.injectMouseEvent({
|
|
984
|
-
type: 'mousePressed',
|
|
985
|
-
x: 100,
|
|
986
|
-
y: 200,
|
|
987
|
-
button: 'left',
|
|
988
|
-
});
|
|
989
|
-
|
|
990
|
-
// Inject keyboard events
|
|
991
|
-
await browser.injectKeyboardEvent({
|
|
992
|
-
type: 'keyDown',
|
|
993
|
-
key: 'Enter',
|
|
994
|
-
code: 'Enter',
|
|
995
|
-
});
|
|
996
|
-
|
|
997
|
-
// Stop when done
|
|
998
|
-
await browser.stopScreencast();
|
|
999
|
-
```
|
|
1000
|
-
|
|
1001
956
|
## Architecture
|
|
1002
957
|
|
|
1003
958
|
agent-browser uses a client-daemon architecture:
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|