@actionbookdev/cli 0.2.3 → 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 +98 -148
- package/bin/actionbook-darwin-arm64 +0 -0
- package/bin/actionbook-darwin-x64 +0 -0
- package/bin/actionbook-linux-arm64 +0 -0
- package/bin/actionbook-linux-x64 +0 -0
- package/bin/actionbook-win32-arm64.exe +0 -0
- package/bin/actionbook-win32-x64.exe +0 -0
- package/bin/actionbook.js +75 -0
- package/package.json +9 -27
- package/scripts/postinstall.js +114 -0
- package/LICENSE +0 -201
- package/dist/commands/browser.d.ts +0 -3
- package/dist/commands/browser.d.ts.map +0 -1
- package/dist/commands/browser.js +0 -27
- package/dist/commands/browser.js.map +0 -1
- package/dist/commands/get.d.ts +0 -3
- package/dist/commands/get.d.ts.map +0 -1
- package/dist/commands/get.js +0 -68
- package/dist/commands/get.js.map +0 -1
- package/dist/commands/search.d.ts +0 -3
- package/dist/commands/search.d.ts.map +0 -1
- package/dist/commands/search.js +0 -61
- package/dist/commands/search.js.map +0 -1
- package/dist/commands/sources.d.ts +0 -3
- package/dist/commands/sources.d.ts.map +0 -1
- package/dist/commands/sources.js +0 -97
- package/dist/commands/sources.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -23
- package/dist/index.js.map +0 -1
- package/dist/output.d.ts +0 -15
- package/dist/output.d.ts.map +0 -1
- package/dist/output.js +0 -34
- package/dist/output.js.map +0 -1
- package/dist/utils/process.d.ts +0 -24
- package/dist/utils/process.d.ts.map +0 -1
- package/dist/utils/process.js +0 -207
- package/dist/utils/process.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @actionbookdev/cli
|
|
2
2
|
|
|
3
|
-
CLI for Actionbook -
|
|
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,24 +8,25 @@ 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
|
|
14
20
|
# Search for actions
|
|
15
21
|
actionbook search "airbnb search"
|
|
16
22
|
|
|
17
|
-
# Get action details
|
|
18
|
-
actionbook get "
|
|
23
|
+
# Get action details by area_id
|
|
24
|
+
actionbook get "airbnb.com:/:default"
|
|
19
25
|
|
|
20
|
-
#
|
|
21
|
-
actionbook
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
actionbook sources search "linkedin"
|
|
25
|
-
|
|
26
|
-
# Browser automation (requires agent-browser)
|
|
27
|
-
actionbook browser open example.com
|
|
28
|
-
actionbook browser snapshot -i
|
|
26
|
+
# Browser automation
|
|
27
|
+
actionbook browser open https://example.com
|
|
28
|
+
actionbook browser snapshot
|
|
29
|
+
actionbook browser click "button.submit"
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
## Commands
|
|
@@ -36,192 +37,141 @@ Search for action manuals by keyword.
|
|
|
36
37
|
|
|
37
38
|
```bash
|
|
38
39
|
actionbook search "google login"
|
|
39
|
-
actionbook search "airbnb" --
|
|
40
|
-
actionbook search "login" --
|
|
40
|
+
actionbook search "airbnb" --domain airbnb.com
|
|
41
|
+
actionbook search "login" --page 2 --page-size 20
|
|
41
42
|
```
|
|
42
43
|
|
|
43
44
|
**Options:**
|
|
44
|
-
- `-
|
|
45
|
-
- `-
|
|
46
|
-
- `-
|
|
47
|
-
-
|
|
48
|
-
- `-j, --json` - Output raw JSON
|
|
49
|
-
|
|
50
|
-
**Alias:** `actionbook s`
|
|
45
|
+
- `-d, --domain <domain>` - Filter by domain (e.g., "airbnb.com")
|
|
46
|
+
- `-u, --url <url>` - Filter by URL
|
|
47
|
+
- `-p, --page <number>` - Page number (default: `1`)
|
|
48
|
+
- `-s, --page-size <number>` - Results per page 1-100 (default: `10`)
|
|
51
49
|
|
|
52
|
-
### `actionbook get <
|
|
50
|
+
### `actionbook get <area_id>`
|
|
53
51
|
|
|
54
|
-
Get complete action details by
|
|
52
|
+
Get complete action details by area ID.
|
|
55
53
|
|
|
56
54
|
```bash
|
|
57
|
-
actionbook get "
|
|
58
|
-
actionbook get "
|
|
59
|
-
actionbook get "releases.rs" # domain only
|
|
55
|
+
actionbook get "airbnb.com:/:default"
|
|
56
|
+
actionbook get "github.com:/login:default"
|
|
60
57
|
```
|
|
61
58
|
|
|
62
|
-
|
|
63
|
-
- `-j, --json` - Output raw JSON
|
|
64
|
-
|
|
65
|
-
**Alias:** `actionbook g`
|
|
59
|
+
### `actionbook browser <command>`
|
|
66
60
|
|
|
67
|
-
|
|
61
|
+
Browser automation via Chrome DevTools Protocol. Uses your existing system browser (Chrome, Brave, Edge, Arc, Chromium) - no browser download required.
|
|
68
62
|
|
|
69
|
-
|
|
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
|
|
70
68
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
|
76
76
|
|
|
77
|
-
**
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
|
|
81
|
-
### `actionbook sources search <query>`
|
|
82
|
-
|
|
83
|
-
Search for sources by keyword.
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
actionbook sources search "airbnb"
|
|
87
|
-
actionbook sources search "e-commerce" --limit 20
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
**Options:**
|
|
91
|
-
- `-l, --limit <number>` - Maximum results (default: `10`)
|
|
92
|
-
- `-j, --json` - Output raw JSON
|
|
93
|
-
|
|
94
|
-
**Alias:** `actionbook sources s`
|
|
95
|
-
|
|
96
|
-
### `actionbook browser [command]`
|
|
97
|
-
|
|
98
|
-
Execute browser automation commands. This command forwards all arguments to `agent-browser` CLI.
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
# Open a website
|
|
102
|
-
actionbook browser open example.com
|
|
77
|
+
**Waiting:**
|
|
78
|
+
- `wait <selector>` - Wait for element (default 30s)
|
|
79
|
+
- `wait-nav` - Wait for navigation
|
|
103
80
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
|
109
89
|
|
|
110
|
-
|
|
111
|
-
|
|
90
|
+
**Cookies:**
|
|
91
|
+
- `cookies list` / `get` / `set` / `delete` / `clear` - Cookie management
|
|
112
92
|
|
|
113
|
-
|
|
114
|
-
|
|
93
|
+
**Session:**
|
|
94
|
+
- `status` - Show detected browsers & session info
|
|
95
|
+
- `close` / `restart` / `connect` - Session control
|
|
115
96
|
|
|
116
|
-
|
|
117
|
-
actionbook browser close
|
|
118
|
-
```
|
|
97
|
+
### `actionbook sources`
|
|
119
98
|
|
|
120
|
-
|
|
99
|
+
List and search available action sources.
|
|
121
100
|
|
|
122
101
|
```bash
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
actionbook browser install
|
|
126
|
-
|
|
127
|
-
# Linux users - include system dependencies
|
|
128
|
-
actionbook browser install --with-deps
|
|
129
|
-
# or manually: npx playwright install-deps chromium
|
|
102
|
+
actionbook sources list
|
|
103
|
+
actionbook sources search "github"
|
|
130
104
|
```
|
|
131
105
|
|
|
132
|
-
|
|
133
|
-
- `open <url>` - Navigate to URL
|
|
134
|
-
- `snapshot -i` - Get interactive elements with references
|
|
135
|
-
- `click <selector>` - Click element (or @ref)
|
|
136
|
-
- `fill <selector> <text>` - Fill input field
|
|
137
|
-
- `type <selector> <text>` - Type into element
|
|
138
|
-
- `wait <selector|ms>` - Wait for element or time
|
|
139
|
-
- `screenshot [path]` - Take screenshot
|
|
140
|
-
- `close` - Close browser
|
|
106
|
+
### `actionbook config`
|
|
141
107
|
|
|
142
|
-
|
|
108
|
+
Manage CLI configuration.
|
|
143
109
|
|
|
144
110
|
```bash
|
|
145
|
-
actionbook
|
|
146
|
-
actionbook
|
|
111
|
+
actionbook config show
|
|
112
|
+
actionbook config get api.base_url
|
|
113
|
+
actionbook config set api.api_key "your_key"
|
|
147
114
|
```
|
|
148
115
|
|
|
149
|
-
|
|
116
|
+
### `actionbook profile`
|
|
150
117
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
Set your API key via environment variable:
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
export ACTIONBOOK_API_KEY=your_api_key
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
Or pass it as an option:
|
|
118
|
+
Manage browser profiles for isolated sessions.
|
|
160
119
|
|
|
161
120
|
```bash
|
|
162
|
-
actionbook
|
|
121
|
+
actionbook profile list
|
|
122
|
+
actionbook profile create work
|
|
123
|
+
actionbook profile delete work
|
|
163
124
|
```
|
|
164
125
|
|
|
165
|
-
##
|
|
166
|
-
|
|
167
|
-
By default, the CLI outputs formatted, colorized results for human readability.
|
|
168
|
-
|
|
169
|
-
Use `--json` flag for raw JSON output, useful for piping to other tools:
|
|
126
|
+
## Global Options
|
|
170
127
|
|
|
171
128
|
```bash
|
|
172
|
-
|
|
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
|
|
173
135
|
```
|
|
174
136
|
|
|
175
|
-
##
|
|
176
|
-
|
|
177
|
-
### Typical Workflow
|
|
137
|
+
## Configuration
|
|
178
138
|
|
|
179
|
-
|
|
180
|
-
# 1. Search for actions
|
|
181
|
-
actionbook search "airbnb search"
|
|
139
|
+
Config file location: `~/.config/actionbook/config.toml`
|
|
182
140
|
|
|
183
|
-
|
|
184
|
-
|
|
141
|
+
```toml
|
|
142
|
+
[api]
|
|
143
|
+
base_url = "https://api.actionbook.dev"
|
|
144
|
+
api_key = "your_key"
|
|
185
145
|
|
|
186
|
-
|
|
146
|
+
[browser]
|
|
147
|
+
executable = "/path/to/chrome"
|
|
148
|
+
default_profile = "default"
|
|
149
|
+
headless = false
|
|
187
150
|
```
|
|
188
151
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
```bash
|
|
192
|
-
# List sources to find IDs
|
|
193
|
-
actionbook sources
|
|
194
|
-
|
|
195
|
-
# Search within specific sources
|
|
196
|
-
actionbook search "login" --source-ids 1,2
|
|
197
|
-
```
|
|
152
|
+
**Priority:** CLI args > Environment vars > Config file > Auto-discovery
|
|
198
153
|
|
|
199
|
-
|
|
154
|
+
## Environment Variables
|
|
200
155
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
actionbook get "booking.com" --json | jq '.elements'
|
|
204
|
-
```
|
|
156
|
+
- `ACTIONBOOK_API_KEY` - API key for Actionbook service
|
|
157
|
+
- `ACTIONBOOK_BINARY_PATH` - Override binary path (for development)
|
|
205
158
|
|
|
206
|
-
|
|
159
|
+
## Supported Browsers
|
|
207
160
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
actionbook browser fill @e1 "username"
|
|
216
|
-
actionbook browser fill @e2 "password"
|
|
217
|
-
actionbook browser click @e3
|
|
218
|
-
```
|
|
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 |
|
|
219
168
|
|
|
220
169
|
## Related Packages
|
|
221
170
|
|
|
222
171
|
- [`@actionbookdev/sdk`](https://www.npmjs.com/package/@actionbookdev/sdk) - JavaScript/TypeScript SDK
|
|
223
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
|
|
224
174
|
|
|
225
175
|
## License
|
|
226
176
|
|
|
227
|
-
|
|
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.
|
|
4
|
-
"description": "CLI for Actionbook -
|
|
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": "
|
|
7
|
+
"actionbook": "./bin/actionbook.js"
|
|
11
8
|
},
|
|
12
9
|
"files": [
|
|
13
|
-
"
|
|
10
|
+
"bin",
|
|
11
|
+
"scripts"
|
|
14
12
|
],
|
|
15
13
|
"publishConfig": {
|
|
16
14
|
"access": "public"
|
|
17
15
|
},
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"chalk": "^5.3.0",
|
|
21
|
-
"commander": "^12.1.0",
|
|
22
|
-
"@actionbookdev/sdk": "0.2.2"
|
|
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
|
-
|
|
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);
|