@kritchoff/agent-browser 0.9.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.
- package/LICENSE +201 -0
- package/README.md +903 -0
- package/README.sdk.md +77 -0
- package/bin/agent-browser-linux-x64 +0 -0
- package/bin/agent-browser.js +109 -0
- package/dist/actions.d.ts +17 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +1427 -0
- package/dist/actions.js.map +1 -0
- package/dist/browser.d.ts +474 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +1566 -0
- package/dist/browser.js.map +1 -0
- package/dist/cdp-client.d.ts +103 -0
- package/dist/cdp-client.d.ts.map +1 -0
- package/dist/cdp-client.js +223 -0
- package/dist/cdp-client.js.map +1 -0
- package/dist/daemon.d.ts +60 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +401 -0
- package/dist/daemon.js.map +1 -0
- package/dist/dualmode-config.d.ts +37 -0
- package/dist/dualmode-config.d.ts.map +1 -0
- package/dist/dualmode-config.js +44 -0
- package/dist/dualmode-config.js.map +1 -0
- package/dist/dualmode-fetcher.d.ts +60 -0
- package/dist/dualmode-fetcher.d.ts.map +1 -0
- package/dist/dualmode-fetcher.js +449 -0
- package/dist/dualmode-fetcher.js.map +1 -0
- package/dist/dualmode-types.d.ts +183 -0
- package/dist/dualmode-types.d.ts.map +1 -0
- package/dist/dualmode-types.js +8 -0
- package/dist/dualmode-types.js.map +1 -0
- package/dist/ios-actions.d.ts +11 -0
- package/dist/ios-actions.d.ts.map +1 -0
- package/dist/ios-actions.js +228 -0
- package/dist/ios-actions.js.map +1 -0
- package/dist/ios-manager.d.ts +266 -0
- package/dist/ios-manager.d.ts.map +1 -0
- package/dist/ios-manager.js +1073 -0
- package/dist/ios-manager.js.map +1 -0
- package/dist/protocol.d.ts +26 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +832 -0
- package/dist/protocol.js.map +1 -0
- package/dist/snapshot.d.ts +83 -0
- package/dist/snapshot.d.ts.map +1 -0
- package/dist/snapshot.js +653 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/stream-server.d.ts +117 -0
- package/dist/stream-server.d.ts.map +1 -0
- package/dist/stream-server.js +305 -0
- package/dist/stream-server.js.map +1 -0
- package/dist/types.d.ts +742 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/docker-compose.sdk.yml +45 -0
- package/package.json +85 -0
- package/scripts/benchmark.sh +80 -0
- package/scripts/build-all-platforms.sh +68 -0
- package/scripts/check-version-sync.js +39 -0
- package/scripts/copy-native.js +36 -0
- package/scripts/fast_reset.sh +108 -0
- package/scripts/postinstall.js +235 -0
- package/scripts/publish_images.sh +55 -0
- package/scripts/snapshot_manager.sh +293 -0
- package/scripts/start-android-agent.sh +49 -0
- package/scripts/sync-version.js +69 -0
- package/scripts/vaccine-run +26 -0
- package/sdk.sh +153 -0
- package/skills/agent-browser/SKILL.md +217 -0
- package/skills/agent-browser/references/authentication.md +202 -0
- package/skills/agent-browser/references/commands.md +259 -0
- package/skills/agent-browser/references/proxy-support.md +188 -0
- package/skills/agent-browser/references/session-management.md +193 -0
- package/skills/agent-browser/references/snapshot-refs.md +194 -0
- package/skills/agent-browser/references/video-recording.md +173 -0
- package/skills/agent-browser/templates/authenticated-session.sh +97 -0
- package/skills/agent-browser/templates/capture-workflow.sh +69 -0
- package/skills/agent-browser/templates/form-automation.sh +62 -0
- package/skills/skill-creator/LICENSE.txt +202 -0
- package/skills/skill-creator/SKILL.md +356 -0
- package/skills/skill-creator/references/output-patterns.md +82 -0
- package/skills/skill-creator/references/workflows.md +28 -0
- package/skills/skill-creator/scripts/init_skill.py +303 -0
- package/skills/skill-creator/scripts/package_skill.py +113 -0
- package/skills/skill-creator/scripts/quick_validate.py +95 -0
package/README.sdk.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @wootzapp/agent-browser SDK
|
|
2
|
+
|
|
3
|
+
The official SDK for controlling the WootzApp Agent Browser environment. This package provides a seamless, Docker-based Android browser for AI agents with instant startup times.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Zero-Config Setup**: Automatically pulls and runs the Docker environment.
|
|
8
|
+
- **Instant Boot**: Uses VDI Snapshots to start the browser in ~20s.
|
|
9
|
+
- **Fast Reset**: Clears browser state in ~15s for high-speed agent loops.
|
|
10
|
+
- **Headless Control**: Full programmatic access via Node.js.
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
- **Docker**: Must be installed and running.
|
|
15
|
+
- **Node.js**: v18+.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @wootzapp/agent-browser
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { WootzAgent } from '@wootzapp/agent-browser';
|
|
27
|
+
|
|
28
|
+
async function main() {
|
|
29
|
+
const agent = new WootzAgent();
|
|
30
|
+
|
|
31
|
+
console.log('Starting environment...');
|
|
32
|
+
// First run: ~90s (Cold Boot + Snapshot Creation)
|
|
33
|
+
// Subsequent runs: ~20s (Warm Boot)
|
|
34
|
+
await agent.start();
|
|
35
|
+
|
|
36
|
+
console.log('Opening Google...');
|
|
37
|
+
await agent.command('open', 'https://google.com');
|
|
38
|
+
|
|
39
|
+
// ... perform agent tasks ...
|
|
40
|
+
|
|
41
|
+
console.log('Resetting browser for next task...');
|
|
42
|
+
// Fast Reset: ~15s (Clears tabs/cookies/cache)
|
|
43
|
+
await agent.reset();
|
|
44
|
+
|
|
45
|
+
console.log('Stopping environment...');
|
|
46
|
+
await agent.stop();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
main().catch(console.error);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## How It Works
|
|
53
|
+
|
|
54
|
+
1. **First Run**: The SDK pulls the heavy Docker image (~3GB) and performs a "Cold Boot". Once the emulator is ready, it automatically saves a "Baseline Snapshot" to your local cache.
|
|
55
|
+
2. **Subsequent Runs**: The SDK detects the snapshot and performs a "Warm Boot", injecting the saved state directly into memory. This bypasses the Android boot sequence.
|
|
56
|
+
3. **Reset**: Instead of restarting the container, `agent.reset()` triggers an Android userspace reboot, which is significantly faster than a full system restart.
|
|
57
|
+
|
|
58
|
+
## API Reference
|
|
59
|
+
|
|
60
|
+
### `new WootzAgent(options?)`
|
|
61
|
+
Creates a new agent instance.
|
|
62
|
+
- `options.dist` (boolean): Whether to pull pre-built images (default: `true`).
|
|
63
|
+
|
|
64
|
+
### `agent.start()`
|
|
65
|
+
Starts the Android Emulator and Agent Service. Handles snapshot creation automatically.
|
|
66
|
+
|
|
67
|
+
### `agent.stop()`
|
|
68
|
+
Stops the Docker containers gracefully.
|
|
69
|
+
|
|
70
|
+
### `agent.reset()`
|
|
71
|
+
Performs a fast reset of the browser environment without stopping the container. Use this between agent tasks to ensure a clean state.
|
|
72
|
+
|
|
73
|
+
### `agent.command(action, ...args)`
|
|
74
|
+
Executes a raw agent command.
|
|
75
|
+
- `agent.command('open', 'url')`
|
|
76
|
+
- `agent.command('click', '@e1')`
|
|
77
|
+
- `agent.command('type', '@e2', 'hello')`
|
|
Binary file
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cross-platform CLI wrapper for agent-browser
|
|
5
|
+
*
|
|
6
|
+
* This wrapper enables npx support on Windows where shell scripts don't work.
|
|
7
|
+
* For global installs, postinstall.js patches the shims to invoke the native
|
|
8
|
+
* binary directly (zero overhead).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { spawn } from 'child_process';
|
|
12
|
+
import { existsSync, accessSync, chmodSync, constants } from 'fs';
|
|
13
|
+
import { dirname, join } from 'path';
|
|
14
|
+
import { fileURLToPath } from 'url';
|
|
15
|
+
import { platform, arch } from 'os';
|
|
16
|
+
|
|
17
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
|
|
19
|
+
// Map Node.js platform/arch to binary naming convention
|
|
20
|
+
function getBinaryName() {
|
|
21
|
+
const os = platform();
|
|
22
|
+
const cpuArch = arch();
|
|
23
|
+
|
|
24
|
+
let osKey;
|
|
25
|
+
switch (os) {
|
|
26
|
+
case 'darwin':
|
|
27
|
+
osKey = 'darwin';
|
|
28
|
+
break;
|
|
29
|
+
case 'linux':
|
|
30
|
+
osKey = 'linux';
|
|
31
|
+
break;
|
|
32
|
+
case 'win32':
|
|
33
|
+
osKey = 'win32';
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let archKey;
|
|
40
|
+
switch (cpuArch) {
|
|
41
|
+
case 'x64':
|
|
42
|
+
case 'x86_64':
|
|
43
|
+
archKey = 'x64';
|
|
44
|
+
break;
|
|
45
|
+
case 'arm64':
|
|
46
|
+
case 'aarch64':
|
|
47
|
+
archKey = 'arm64';
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const ext = os === 'win32' ? '.exe' : '';
|
|
54
|
+
return `agent-browser-${osKey}-${archKey}${ext}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function main() {
|
|
58
|
+
const binaryName = getBinaryName();
|
|
59
|
+
|
|
60
|
+
if (!binaryName) {
|
|
61
|
+
console.error(`Error: Unsupported platform: ${platform()}-${arch()}`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const binaryPath = join(__dirname, binaryName);
|
|
66
|
+
|
|
67
|
+
if (!existsSync(binaryPath)) {
|
|
68
|
+
console.error(`Error: No binary found for ${platform()}-${arch()}`);
|
|
69
|
+
console.error(`Expected: ${binaryPath}`);
|
|
70
|
+
console.error('');
|
|
71
|
+
console.error('Run "npm run build:native" to build for your platform,');
|
|
72
|
+
console.error('or reinstall the package to trigger the postinstall download.');
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Ensure binary is executable (fixes EACCES on macOS/Linux when postinstall didn't run,
|
|
77
|
+
// e.g., when using bun which blocks lifecycle scripts by default)
|
|
78
|
+
if (platform() !== 'win32') {
|
|
79
|
+
try {
|
|
80
|
+
accessSync(binaryPath, constants.X_OK);
|
|
81
|
+
} catch {
|
|
82
|
+
// Binary exists but isn't executable - fix it
|
|
83
|
+
try {
|
|
84
|
+
chmodSync(binaryPath, 0o755);
|
|
85
|
+
} catch (chmodErr) {
|
|
86
|
+
console.error(`Error: Cannot make binary executable: ${chmodErr.message}`);
|
|
87
|
+
console.error('Try running: chmod +x ' + binaryPath);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Spawn the native binary with inherited stdio
|
|
94
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
95
|
+
stdio: 'inherit',
|
|
96
|
+
windowsHide: false,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
child.on('error', (err) => {
|
|
100
|
+
console.error(`Error executing binary: ${err.message}`);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
child.on('close', (code) => {
|
|
105
|
+
process.exit(code ?? 0);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
main();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BrowserManager, ScreencastFrame } from './browser.js';
|
|
2
|
+
import type { Command, Response } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Set the callback for screencast frames
|
|
5
|
+
* This is called by the daemon to set up frame streaming
|
|
6
|
+
*/
|
|
7
|
+
export declare function setScreencastFrameCallback(callback: ((frame: ScreencastFrame) => void) | null): void;
|
|
8
|
+
/**
|
|
9
|
+
* Convert Playwright errors to AI-friendly messages
|
|
10
|
+
* @internal Exported for testing
|
|
11
|
+
*/
|
|
12
|
+
export declare function toAIFriendlyError(error: unknown, selector: string): Error;
|
|
13
|
+
/**
|
|
14
|
+
* Execute a command and return a response
|
|
15
|
+
*/
|
|
16
|
+
export declare function executeCommand(command: Command, browser: BrowserManager): Promise<Response>;
|
|
17
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,KAAK,EACV,OAAO,EACP,QAAQ,EAqHT,MAAM,YAAY,CAAC;AAMpB;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC,GAAG,IAAI,GAClD,IAAI,CAEN;AAQD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAqDzE;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,CAmQjG"}
|