@actionbookdev/cli 0.3.0 → 0.4.0-alpha.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @actionbookdev/cli
2
2
 
3
- CLI for Actionbook - Get website action manuals for AI agents.
3
+ CLI for Actionbook - Browser automation and action manuals for AI agents. Powered by a native Rust binary for fast startup and zero runtime dependencies.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,6 +8,12 @@ CLI for Actionbook - Get website action manuals for AI agents.
8
8
  npm install -g @actionbookdev/cli
9
9
  ```
10
10
 
11
+ Or use directly with npx:
12
+
13
+ ```bash
14
+ npx @actionbookdev/cli search "airbnb search"
15
+ ```
16
+
11
17
  ## Quick Start
12
18
 
13
19
  ```bash
@@ -17,9 +23,10 @@ actionbook search "airbnb search"
17
23
  # Get action details by area_id
18
24
  actionbook get "airbnb.com:/:default"
19
25
 
20
- # Browser automation (requires agent-browser)
21
- actionbook browser open example.com
22
- actionbook browser snapshot -i
26
+ # Browser automation
27
+ actionbook browser open https://example.com
28
+ actionbook browser snapshot
29
+ actionbook browser click "button.submit"
23
30
  ```
24
31
 
25
32
  ## Commands
@@ -40,8 +47,6 @@ actionbook search "login" --page 2 --page-size 20
40
47
  - `-p, --page <number>` - Page number (default: `1`)
41
48
  - `-s, --page-size <number>` - Results per page 1-100 (default: `10`)
42
49
 
43
- **Alias:** `actionbook s`
44
-
45
50
  ### `actionbook get <area_id>`
46
51
 
47
52
  Get complete action details by area ID.
@@ -51,121 +56,122 @@ actionbook get "airbnb.com:/:default"
51
56
  actionbook get "github.com:/login:default"
52
57
  ```
53
58
 
54
- **Alias:** `actionbook g`
59
+ ### `actionbook browser <command>`
55
60
 
56
- ### `actionbook browser [command]`
61
+ Browser automation via Chrome DevTools Protocol. Uses your existing system browser (Chrome, Brave, Edge, Arc, Chromium) - no browser download required.
57
62
 
58
- Execute browser automation commands. This command forwards all arguments to `agent-browser` CLI.
63
+ **Navigation:**
64
+ - `open <url>` - Open URL in new tab
65
+ - `goto <url>` - Navigate current page
66
+ - `back` / `forward` / `reload` - History navigation
67
+ - `pages` / `switch` - Manage tabs
59
68
 
60
- ```bash
61
- # Open a website
62
- actionbook browser open example.com
69
+ **Interaction:**
70
+ - `click <selector>` - Click element
71
+ - `type <selector> <text>` - Type text (append)
72
+ - `fill <selector> <text>` - Clear and type text
73
+ - `select <selector> <value>` - Select dropdown option
74
+ - `hover <selector>` / `focus <selector>` - Hover/focus element
75
+ - `press <key>` - Press keyboard key
63
76
 
64
- # Take interactive snapshot
65
- actionbook browser snapshot -i
77
+ **Waiting:**
78
+ - `wait <selector>` - Wait for element (default 30s)
79
+ - `wait-nav` - Wait for navigation
66
80
 
67
- # Click element by reference
68
- actionbook browser click @e1
81
+ **Page Inspection:**
82
+ - `screenshot [path]` - Take screenshot
83
+ - `pdf <path>` - Export as PDF
84
+ - `html [selector]` - Get page/element HTML
85
+ - `text [selector]` - Get page/element text
86
+ - `eval <code>` - Execute JavaScript
87
+ - `snapshot` - Get accessibility snapshot
88
+ - `viewport` - Get viewport dimensions
69
89
 
70
- # Fill input field
71
- actionbook browser fill @e3 "test@example.com"
90
+ **Cookies:**
91
+ - `cookies list` / `get` / `set` / `delete` / `clear` - Cookie management
72
92
 
73
- # Check current session
74
- actionbook browser session
93
+ **Session:**
94
+ - `status` - Show detected browsers & session info
95
+ - `close` / `restart` / `connect` - Session control
75
96
 
76
- # Close browser
77
- actionbook browser close
78
- ```
97
+ ### `actionbook sources`
79
98
 
80
- **Setup:**
99
+ List and search available action sources.
81
100
 
82
101
  ```bash
83
- # npm (recommended)
84
- # Download Chromium
85
- actionbook browser install
86
-
87
- # Linux users - include system dependencies
88
- actionbook browser install --with-deps
89
- # or manually: npx playwright install-deps chromium
102
+ actionbook sources list
103
+ actionbook sources search "github"
90
104
  ```
91
105
 
92
- **Common Commands:**
93
- - `open <url>` - Navigate to URL
94
- - `snapshot -i` - Get interactive elements with references
95
- - `click <selector>` - Click element (or @ref)
96
- - `fill <selector> <text>` - Fill input field
97
- - `type <selector> <text>` - Type into element
98
- - `wait <selector|ms>` - Wait for element or time
99
- - `screenshot [path]` - Take screenshot
100
- - `close` - Close browser
106
+ ### `actionbook config`
101
107
 
102
- **For full command list:**
108
+ Manage CLI configuration.
103
109
 
104
110
  ```bash
105
- actionbook browser --help
106
- actionbook browser # Shows full agent-browser help
111
+ actionbook config show
112
+ actionbook config get api.base_url
113
+ actionbook config set api.api_key "your_key"
107
114
  ```
108
115
 
109
- **Learn more:** [agent-browser on GitHub](https://github.com/vercel-labs/agent-browser)
110
-
111
- ## Authentication
116
+ ### `actionbook profile`
112
117
 
113
- Set your API key via environment variable:
118
+ Manage browser profiles for isolated sessions.
114
119
 
115
120
  ```bash
116
- export ACTIONBOOK_API_KEY=your_api_key
121
+ actionbook profile list
122
+ actionbook profile create work
123
+ actionbook profile delete work
117
124
  ```
118
125
 
119
- Or pass it as an option:
126
+ ## Global Options
120
127
 
121
128
  ```bash
122
- actionbook --api-key your_api_key search "query"
129
+ --browser-path <path> # Custom browser executable
130
+ --cdp <port|url> # Connect to existing CDP port
131
+ --profile <name> # Use specific browser profile
132
+ --headless # Run in headless mode
133
+ --json # JSON output format
134
+ --verbose, -v # Verbose logging
123
135
  ```
124
136
 
125
- ## Output Format
137
+ ## Configuration
126
138
 
127
- The CLI outputs plain text results optimized for both human readability and AI agent consumption.
139
+ Config file location: `~/.config/actionbook/config.toml`
128
140
 
129
- ## Examples
141
+ ```toml
142
+ [api]
143
+ base_url = "https://api.actionbook.dev"
144
+ api_key = "your_key"
130
145
 
131
- ### Typical Workflow
132
-
133
- ```bash
134
- # 1. Search for actions
135
- actionbook search "airbnb search"
136
-
137
- # 2. Get details for a specific action using area_id from search results
138
- actionbook get "airbnb.com:/:default"
139
-
140
- # 3. Use the selectors in your automation script
146
+ [browser]
147
+ executable = "/path/to/chrome"
148
+ default_profile = "default"
149
+ headless = false
141
150
  ```
142
151
 
143
- ### Filter by Domain
152
+ **Priority:** CLI args > Environment vars > Config file > Auto-discovery
144
153
 
145
- ```bash
146
- # Search within a specific domain
147
- actionbook search "login" --domain github.com
148
- ```
154
+ ## Environment Variables
149
155
 
150
- ### Browser Automation Workflow
156
+ - `ACTIONBOOK_API_KEY` - API key for Actionbook service
157
+ - `ACTIONBOOK_BINARY_PATH` - Override binary path (for development)
151
158
 
152
- ```bash
153
- # 1. Get action details with verified selectors
154
- actionbook get "github.com:/login:default"
159
+ ## Supported Browsers
155
160
 
156
- # 2. Use browser command to automate
157
- actionbook browser open "https://github.com/login"
158
- actionbook browser snapshot -i
159
- actionbook browser fill @e1 "username"
160
- actionbook browser fill @e2 "password"
161
- actionbook browser click @e3
162
- ```
161
+ | Browser | macOS | Linux | Windows |
162
+ |---------|-------|-------|---------|
163
+ | Google Chrome | Yes | Yes | Yes |
164
+ | Brave | Yes | Yes | Yes |
165
+ | Microsoft Edge | Yes | Yes | Yes |
166
+ | Arc | Yes | - | - |
167
+ | Chromium | Yes | Yes | Yes |
163
168
 
164
169
  ## Related Packages
165
170
 
166
171
  - [`@actionbookdev/sdk`](https://www.npmjs.com/package/@actionbookdev/sdk) - JavaScript/TypeScript SDK
167
172
  - [`@actionbookdev/mcp`](https://www.npmjs.com/package/@actionbookdev/mcp) - MCP Server for AI agents
173
+ - [`@actionbookdev/tools-ai-sdk`](https://www.npmjs.com/package/@actionbookdev/tools-ai-sdk) - Vercel AI SDK tools
168
174
 
169
175
  ## License
170
176
 
171
- MIT
177
+ Apache-2.0
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Cross-platform CLI wrapper for actionbook
5
+ *
6
+ * Detects the current platform and spawns the corresponding native Rust binary
7
+ * from the same directory. Supports ACTIONBOOK_BINARY_PATH env var for development.
8
+ */
9
+
10
+ "use strict";
11
+
12
+ const { spawn } = require("child_process");
13
+ const { existsSync } = require("fs");
14
+ const path = require("path");
15
+
16
+ const PLATFORMS = {
17
+ "darwin-arm64": "actionbook-darwin-arm64",
18
+ "darwin-x64": "actionbook-darwin-x64",
19
+ "linux-x64": "actionbook-linux-x64",
20
+ "linux-arm64": "actionbook-linux-arm64",
21
+ "win32-x64": "actionbook-win32-x64.exe",
22
+ "win32-arm64": "actionbook-win32-arm64.exe",
23
+ };
24
+
25
+ function main() {
26
+ // Allow env var override for development
27
+ const envPath = process.env.ACTIONBOOK_BINARY_PATH;
28
+ if (envPath) {
29
+ run(envPath);
30
+ return;
31
+ }
32
+
33
+ const platformKey = `${process.platform}-${process.arch}`;
34
+ const binaryName = PLATFORMS[platformKey];
35
+
36
+ if (!binaryName) {
37
+ console.error(`Error: Unsupported platform: ${platformKey}`);
38
+ console.error(`Supported: ${Object.keys(PLATFORMS).join(", ")}`);
39
+ process.exit(1);
40
+ }
41
+
42
+ const binaryPath = path.join(__dirname, binaryName);
43
+
44
+ if (!existsSync(binaryPath)) {
45
+ console.error(`Error: No binary found for ${platformKey}`);
46
+ console.error(`Expected: ${binaryPath}`);
47
+ console.error("");
48
+ console.error("Try reinstalling:");
49
+ console.error(" npm install -g @actionbookdev/cli");
50
+ console.error("");
51
+ console.error("Or install the Rust CLI directly:");
52
+ console.error(" cargo install actionbook");
53
+ process.exit(1);
54
+ }
55
+
56
+ run(binaryPath);
57
+ }
58
+
59
+ function run(binaryPath) {
60
+ const child = spawn(binaryPath, process.argv.slice(2), {
61
+ stdio: "inherit",
62
+ windowsHide: false,
63
+ });
64
+
65
+ child.on("error", (err) => {
66
+ console.error(`Error executing binary: ${err.message}`);
67
+ process.exit(1);
68
+ });
69
+
70
+ child.on("close", (code) => {
71
+ process.exit(code ?? 0);
72
+ });
73
+ }
74
+
75
+ main();
package/package.json CHANGED
@@ -1,31 +1,20 @@
1
1
  {
2
2
  "name": "@actionbookdev/cli",
3
- "version": "0.3.0",
4
- "description": "CLI for Actionbook - Get website action manuals for AI agents",
3
+ "version": "0.4.0-alpha.1",
4
+ "description": "CLI for Actionbook - Browser automation and action manuals for AI agents",
5
5
  "private": false,
6
- "type": "module",
7
- "main": "dist/index.js",
8
- "types": "dist/index.d.ts",
9
6
  "bin": {
10
- "actionbook": "dist/index.js"
7
+ "actionbook": "./bin/actionbook.js"
11
8
  },
12
9
  "files": [
13
- "dist"
10
+ "bin",
11
+ "scripts"
14
12
  ],
15
13
  "publishConfig": {
16
14
  "access": "public"
17
15
  },
18
- "dependencies": {
19
- "agent-browser": "^0.8.3",
20
- "chalk": "^5.3.0",
21
- "commander": "^12.1.0",
22
- "@actionbookdev/sdk": "0.3.0"
23
- },
24
- "devDependencies": {
25
- "@types/node": "^20.14.0",
26
- "typescript": "^5.6.3",
27
- "vitest": "^1.6.0",
28
- "rimraf": "^5.0.5"
16
+ "scripts": {
17
+ "postinstall": "node scripts/postinstall.js"
29
18
  },
30
19
  "engines": {
31
20
  "node": ">=18"
@@ -45,12 +34,5 @@
45
34
  },
46
35
  "homepage": "https://actionbook.dev",
47
36
  "author": "Actionbook Team",
48
- "license": "Apache-2.0",
49
- "scripts": {
50
- "build": "tsc -p tsconfig.build.json",
51
- "dev": "tsc -p tsconfig.build.json --watch",
52
- "test": "vitest run",
53
- "lint": "eslint . --ext .ts",
54
- "clean": "rimraf dist"
55
- }
56
- }
37
+ "license": "Apache-2.0"
38
+ }
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Postinstall script for @actionbookdev/cli
5
+ *
6
+ * If the platform binary is missing (e.g., npm didn't include it),
7
+ * downloads it from GitHub Releases as a fallback.
8
+ */
9
+
10
+ "use strict";
11
+
12
+ const fs = require("fs");
13
+ const path = require("path");
14
+ const https = require("https");
15
+
16
+ const binDir = path.join(__dirname, "..", "bin");
17
+
18
+ const GITHUB_REPO = "actionbook/actionbook";
19
+
20
+ function getBinaryName() {
21
+ const platformKey = `${process.platform}-${process.arch}`;
22
+ const map = {
23
+ "darwin-arm64": "actionbook-darwin-arm64",
24
+ "darwin-x64": "actionbook-darwin-x64",
25
+ "linux-x64": "actionbook-linux-x64",
26
+ "linux-arm64": "actionbook-linux-arm64",
27
+ "win32-x64": "actionbook-win32-x64.exe",
28
+ "win32-arm64": "actionbook-win32-arm64.exe",
29
+ };
30
+ return map[platformKey] || null;
31
+ }
32
+
33
+ function downloadFile(url, dest) {
34
+ return new Promise((resolve, reject) => {
35
+ const request = (url) => {
36
+ https
37
+ .get(url, (response) => {
38
+ if (response.statusCode === 301 || response.statusCode === 302) {
39
+ request(response.headers.location);
40
+ return;
41
+ }
42
+ if (response.statusCode !== 200) {
43
+ reject(new Error(`HTTP ${response.statusCode}`));
44
+ return;
45
+ }
46
+ const file = fs.createWriteStream(dest);
47
+ response.pipe(file);
48
+ file.on("finish", () => {
49
+ file.close();
50
+ resolve();
51
+ });
52
+ file.on("error", (err) => {
53
+ fs.unlinkSync(dest);
54
+ reject(err);
55
+ });
56
+ })
57
+ .on("error", reject);
58
+ };
59
+ request(url);
60
+ });
61
+ }
62
+
63
+ async function main() {
64
+ const binaryName = getBinaryName();
65
+
66
+ if (!binaryName) {
67
+ console.log(
68
+ `⚠ Unsupported platform: ${process.platform}-${process.arch}. ` +
69
+ "Install the Rust CLI directly: cargo install actionbook"
70
+ );
71
+ return;
72
+ }
73
+
74
+ const binaryPath = path.join(binDir, binaryName);
75
+
76
+ // Binary already exists (shipped with npm package) — just fix permissions
77
+ if (fs.existsSync(binaryPath)) {
78
+ if (process.platform !== "win32") {
79
+ fs.chmodSync(binaryPath, 0o755);
80
+ }
81
+ return;
82
+ }
83
+
84
+ // Fallback: download from GitHub Releases
85
+ const packageJson = JSON.parse(
86
+ fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8")
87
+ );
88
+ const version = packageJson.version;
89
+ const downloadUrl = `https://github.com/${GITHUB_REPO}/releases/download/actionbook-cli-v${version}/${binaryName}`;
90
+
91
+ console.log(`Downloading actionbook binary for ${process.platform}-${process.arch}...`);
92
+
93
+ try {
94
+ if (!fs.existsSync(binDir)) {
95
+ fs.mkdirSync(binDir, { recursive: true });
96
+ }
97
+
98
+ await downloadFile(downloadUrl, binaryPath);
99
+
100
+ if (process.platform !== "win32") {
101
+ fs.chmodSync(binaryPath, 0o755);
102
+ }
103
+
104
+ console.log(`✓ Downloaded: ${binaryName}`);
105
+ } catch (err) {
106
+ console.log(`⚠ Could not download binary: ${err.message}`);
107
+ console.log("");
108
+ console.log("To install manually:");
109
+ console.log(" cargo install actionbook");
110
+ console.log(" # or set ACTIONBOOK_BINARY_PATH env var");
111
+ }
112
+ }
113
+
114
+ main().catch(console.error);