@thinkbrowse/cli 0.1.0 → 0.1.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/README.md +56 -3
- package/dist/bin/browse.d.ts +3 -0
- package/dist/bin/browse.d.ts.map +1 -0
- package/dist/bin/browse.js +23 -0
- package/dist/bin/browse.js.map +1 -0
- package/dist/bin/thinkbrowse.js +5 -0
- package/dist/bin/thinkbrowse.js.map +1 -1
- package/dist/scripts/browse.sh +1046 -0
- package/dist/src/adapters/cloud.d.ts.map +1 -1
- package/dist/src/adapters/cloud.js +9 -2
- package/dist/src/adapters/cloud.js.map +1 -1
- package/dist/src/commands/config.d.ts.map +1 -1
- package/dist/src/commands/config.js +6 -1
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/doctor.d.ts +15 -0
- package/dist/src/commands/doctor.d.ts.map +1 -0
- package/dist/src/commands/doctor.js +105 -0
- package/dist/src/commands/doctor.js.map +1 -0
- package/dist/src/config/store.js +2 -2
- package/dist/src/config/store.js.map +1 -1
- package/dist/src/utils.d.ts +1 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +11 -0
- package/dist/src/utils.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
# @thinkbrowse/cli
|
|
2
2
|
|
|
3
|
-
CLI for
|
|
3
|
+
CLI for ThinkBrowse browser automation.
|
|
4
|
+
|
|
5
|
+
This package now exposes two global commands:
|
|
6
|
+
- `browse`: portable dual-mode CLI (local native-host + cloud) compatible with existing `scripts/browse.sh` usage.
|
|
7
|
+
- `thinkbrowse`: cloud-focused typed CLI commands.
|
|
4
8
|
|
|
5
9
|
## Requirements
|
|
6
10
|
|
|
7
11
|
- Node.js 18+ (uses native `fetch`)
|
|
12
|
+
- For `browse` command: `bash`, `curl`, `jq`
|
|
13
|
+
|
|
14
|
+
## OS Support
|
|
15
|
+
|
|
16
|
+
- `thinkbrowse` command: macOS, Linux, Windows
|
|
17
|
+
- `browse` command: macOS, Linux, and Windows via WSL/Git Bash
|
|
8
18
|
|
|
9
19
|
## Installation
|
|
10
20
|
|
|
@@ -12,11 +22,36 @@ CLI for controlling browsers via ThinkBrowse cloud infrastructure. 21 commands c
|
|
|
12
22
|
npm install -g @thinkbrowse/cli
|
|
13
23
|
```
|
|
14
24
|
|
|
25
|
+
Install directly from this repository on your machine:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g /Users/kefentse/dev_env/mech/mech-browse/packages/cli
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
After install, use from any project:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
browse session-create
|
|
35
|
+
browse goto <sid> https://example.com
|
|
36
|
+
browse --mode cloud session-artifacts <sid>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Cloud Session Reuse (via `browse`)
|
|
40
|
+
|
|
41
|
+
Use `browse --mode cloud` when you want cloud-session parity (persisted session metadata, actions, and artifacts):
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
browse --mode cloud session-details <sid>
|
|
45
|
+
browse --mode cloud session-actions <sid> 100 0
|
|
46
|
+
browse --mode cloud session-artifacts <sid>
|
|
47
|
+
browse --mode cloud artifact-download <artifactId> ./artifact.bin
|
|
48
|
+
```
|
|
49
|
+
|
|
15
50
|
## Quick Start
|
|
16
51
|
|
|
17
52
|
```bash
|
|
18
53
|
# 1. Configure API key
|
|
19
|
-
thinkbrowse config set-key
|
|
54
|
+
thinkbrowse config set-key tb_your_api_key_here
|
|
20
55
|
|
|
21
56
|
# 2. Start a cloud browser session (waits for provisioning)
|
|
22
57
|
thinkbrowse cloud start
|
|
@@ -31,6 +66,22 @@ thinkbrowse screenshot --output page.png
|
|
|
31
66
|
thinkbrowse cloud stop
|
|
32
67
|
```
|
|
33
68
|
|
|
69
|
+
## Local Endpoint Quick Start (mech-browser-service)
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# 1. Point CLI at local server
|
|
73
|
+
thinkbrowse config set apiUrl http://localhost:3009
|
|
74
|
+
|
|
75
|
+
# 2. Use local TEST_API_KEY from mech-browser-service/.env (often ak_...)
|
|
76
|
+
thinkbrowse config set-key ak_your_local_test_key
|
|
77
|
+
|
|
78
|
+
# 3. Start/select session, then run actions
|
|
79
|
+
thinkbrowse cloud start
|
|
80
|
+
thinkbrowse navigate http://localhost:3000
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Use `thinkbrowse doctor` anytime to verify endpoint mode, health, bridge status, and active session.
|
|
84
|
+
|
|
34
85
|
## AI Agent Workflow
|
|
35
86
|
|
|
36
87
|
The `snapshot` command returns an accessibility tree — ideal for AI agents that need to understand page structure without screenshots:
|
|
@@ -56,6 +107,7 @@ thinkbrowse cloud stop
|
|
|
56
107
|
| `cloud list` | List all active sessions |
|
|
57
108
|
| `cloud status` | Show session details |
|
|
58
109
|
| `cloud use <id>` | Switch active session |
|
|
110
|
+
| `doctor` | Diagnose endpoint/auth/session setup |
|
|
59
111
|
|
|
60
112
|
#### Cloud Start Options
|
|
61
113
|
|
|
@@ -236,7 +288,8 @@ Retryable errors (502, 503) are automatically retried with exponential backoff.
|
|
|
236
288
|
| Issue | Solution |
|
|
237
289
|
|-------|----------|
|
|
238
290
|
| `API key not configured` | Run `thinkbrowse config set-key <key>` |
|
|
239
|
-
| `
|
|
291
|
+
| `Invalid API key` (local URL) | Use local `TEST_API_KEY` from `mech-browser-service/.env` |
|
|
292
|
+
| `No active session` | Run `thinkbrowse cloud start`, or `thinkbrowse cloud list` then `thinkbrowse cloud use <id>` |
|
|
240
293
|
| `Session provisioning timed out` | Check `thinkbrowse cloud status`, try again |
|
|
241
294
|
| `fetch is not defined` | Upgrade to Node.js 18+ |
|
|
242
295
|
| All requests return 404 | Update to latest CLI version |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browse.d.ts","sourceRoot":"","sources":["../../bin/browse.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { spawnSync } from 'node:child_process';
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
const packagedScript = join(__dirname, '..', 'scripts', 'browse.sh');
|
|
9
|
+
const devScript = join(__dirname, '..', '..', 'scripts', 'browse.sh');
|
|
10
|
+
const scriptPath = existsSync(packagedScript) ? packagedScript : devScript;
|
|
11
|
+
if (!existsSync(scriptPath)) {
|
|
12
|
+
console.error('ERROR: browse.sh not found in CLI package.');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
const result = spawnSync('bash', [scriptPath, ...process.argv.slice(2)], {
|
|
16
|
+
stdio: 'inherit',
|
|
17
|
+
env: process.env,
|
|
18
|
+
});
|
|
19
|
+
if (typeof result.status === 'number') {
|
|
20
|
+
process.exit(result.status);
|
|
21
|
+
}
|
|
22
|
+
process.exit(1);
|
|
23
|
+
//# sourceMappingURL=browse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browse.js","sourceRoot":"","sources":["../../bin/browse.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AACrE,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AACtE,MAAM,UAAU,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;AAE3E,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;IAC5B,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;IACvE,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,OAAO,CAAC,GAAG;CACjB,CAAC,CAAC;AAEH,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;IACtC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/bin/thinkbrowse.js
CHANGED
|
@@ -19,13 +19,18 @@ program
|
|
|
19
19
|
.option('--json', 'Output in JSON format (default for non-TTY)')
|
|
20
20
|
.option('--quiet', 'Suppress non-error output')
|
|
21
21
|
.option('--verbose', 'Verbose output with debugging info');
|
|
22
|
+
program.addHelpText('after', '\nDocs:\n' +
|
|
23
|
+
' https://thinkbrowse.io/docs\n' +
|
|
24
|
+
' https://thinkbrowse.io/llms.txt\n');
|
|
22
25
|
// Import commands
|
|
23
26
|
import { createConfigCommand } from '../src/commands/config.js';
|
|
24
27
|
import { createCloudCommand } from '../src/commands/cloud.js';
|
|
28
|
+
import { createDoctorCommand } from '../src/commands/doctor.js';
|
|
25
29
|
import { createNavigateCommand, createClickCommand, createTypeCommand, createFillCommand, createScrollCommand, createWaitCommand, createWaitForTextCommand, createHoverCommand, createSelectCommand, createPressCommand, createBackCommand, createForwardCommand, createSnapshotCommand, createScreenshotCommand, createExtractCommand, createEvaluateCommand, createDialogCommand, createConsoleCommand, createNetworkCommand, } from '../src/commands/actions.js';
|
|
26
30
|
// Add commands
|
|
27
31
|
program.addCommand(createConfigCommand());
|
|
28
32
|
program.addCommand(createCloudCommand());
|
|
33
|
+
program.addCommand(createDoctorCommand());
|
|
29
34
|
// Browser actions
|
|
30
35
|
program.addCommand(createNavigateCommand());
|
|
31
36
|
program.addCommand(createBackCommand());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinkbrowse.js","sourceRoot":"","sources":["../../bin/thinkbrowse.ts"],"names":[],"mappings":";AAEA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAErC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,gCAAgC;AAChC,4EAA4E;AAC5E,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CACnE,CAAC;AAEF,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,aAAa,CAAC;KACnB,WAAW,CAAC,8CAA8C,CAAC;KAC3D,OAAO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