@onkernel/cli 0.9.5 → 0.10.0

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.
Files changed (3) hide show
  1. package/README.md +65 -0
  2. package/lib.js +9 -61
  3. package/package.json +19 -20
package/README.md CHANGED
@@ -241,6 +241,50 @@ Create an API key from the [Kernel dashboard](https://dashboard.onkernel.com).
241
241
 
242
242
  - `kernel browsers extensions upload <id or persistent id> <extension-path>...` - Ad-hoc upload of one or more unpacked extensions to a running browser instance.
243
243
 
244
+ ### Browser Computer Controls
245
+
246
+ - `kernel browsers computer click-mouse <id or persistent id>` - Click mouse at coordinates
247
+ - `--x <coordinate>` - X coordinate (required)
248
+ - `--y <coordinate>` - Y coordinate (required)
249
+ - `--num-clicks <n>` - Number of clicks (default: 1)
250
+ - `--button <button>` - Mouse button: left, right, middle, back, forward (default: left)
251
+ - `--click-type <type>` - Click type: down, up, click (default: click)
252
+ - `--hold-key <key>` - Modifier keys to hold (repeatable)
253
+ - `kernel browsers computer move-mouse <id or persistent id>` - Move mouse to coordinates
254
+ - `--x <coordinate>` - X coordinate (required)
255
+ - `--y <coordinate>` - Y coordinate (required)
256
+ - `--hold-key <key>` - Modifier keys to hold (repeatable)
257
+ - `kernel browsers computer screenshot <id or persistent id>` - Capture a screenshot
258
+ - `--to <path>` - Output file path for the PNG image (required)
259
+ - `--x <coordinate>` - Top-left X for region capture (optional)
260
+ - `--y <coordinate>` - Top-left Y for region capture (optional)
261
+ - `--width <pixels>` - Region width (optional)
262
+ - `--height <pixels>` - Region height (optional)
263
+ - `kernel browsers computer type <id or persistent id>` - Type text on the browser instance
264
+
265
+ - `--text <text>` - Text to type (required)
266
+ - `--delay <ms>` - Delay in milliseconds between keystrokes (optional)
267
+
268
+ - `kernel browsers computer press-key <id or persistent id>` - Press one or more keys
269
+
270
+ - `--key <key>` - Key symbols to press (repeatable)
271
+ - `--duration <ms>` - Duration to hold keys down in ms (0=tap)
272
+ - `--hold-key <key>` - Modifier keys to hold (repeatable)
273
+
274
+ - `kernel browsers computer scroll <id or persistent id>` - Scroll the mouse wheel
275
+
276
+ - `--x <coordinate>` - X coordinate (required)
277
+ - `--y <coordinate>` - Y coordinate (required)
278
+ - `--delta-x <pixels>` - Horizontal scroll amount (+right, -left)
279
+ - `--delta-y <pixels>` - Vertical scroll amount (+down, -up)
280
+ - `--hold-key <key>` - Modifier keys to hold (repeatable)
281
+
282
+ - `kernel browsers computer drag-mouse <id or persistent id>` - Drag the mouse along a path
283
+ - `--point <x,y>` - Add a point as x,y (repeatable)
284
+ - `--delay <ms>` - Delay before dragging starts in ms
285
+ - `--button <button>` - Mouse button: left, middle, right (default: left)
286
+ - `--hold-key <key>` - Modifier keys to hold (repeatable)
287
+
244
288
  ### Extension Management
245
289
 
246
290
  - `kernel extensions list` - List all uploaded extensions
@@ -330,6 +374,27 @@ kernel browsers fs upload my-browser --file "local.txt:remote.txt" --dest-dir "/
330
374
 
331
375
  # List files in a directory
332
376
  kernel browsers fs list-files my-browser --path "/tmp"
377
+
378
+ # Click the mouse at coordinates (100, 200)
379
+ kernel browsers computer click-mouse my-browser --x 100 --y 200
380
+
381
+ # Double-click the right mouse button
382
+ kernel browsers computer click-mouse my-browser --x 100 --y 200 --num-clicks 2 --button right
383
+
384
+ # Move the mouse to coordinates (500, 300)
385
+ kernel browsers computer move-mouse my-browser --x 500 --y 300
386
+
387
+ # Take a full screenshot
388
+ kernel browsers computer screenshot my-browser --to screenshot.png
389
+
390
+ # Take a screenshot of a specific region
391
+ kernel browsers computer screenshot my-browser --to region.png --x 0 --y 0 --width 800 --height 600
392
+
393
+ # Type text in the browser
394
+ kernel browsers computer type my-browser --text "Hello, World!"
395
+
396
+ # Type text with a 100ms delay between keystrokes
397
+ kernel browsers computer type my-browser --text "Slow typing..." --delay 100
333
398
  ```
334
399
 
335
400
  ### Extension management
package/lib.js CHANGED
@@ -6,18 +6,8 @@ const path = require("path");
6
6
  const JSZip = require("jszip");
7
7
  const tar = require("tar");
8
8
  const axios = require("axios");
9
- const ProxyAgent = require("proxy-agent");
10
9
  const { spawnSync } = require("child_process");
11
10
 
12
- const proxyUrl =
13
- process.env.HTTPS_PROXY ||
14
- process.env.https_proxy ||
15
- process.env.HTTP_PROXY ||
16
- process.env.http_proxy ||
17
- null;
18
-
19
- const agent = proxyUrl ? new ProxyAgent(proxyUrl) : undefined;
20
-
21
11
  const getArchive = () => {
22
12
  let target = `${process.platform}-${process.arch}`;
23
13
  const archive = archives[target];
@@ -29,61 +19,31 @@ const getArchive = () => {
29
19
 
30
20
  const binDir = path.join(__dirname, "bin");
31
21
 
32
- async function extractTar(tarPath, binaries, dir, wrappedIn) {
22
+ async function extractTar(tarPath, binaries, dir) {
33
23
  try {
34
- const filesToExtract = wrappedIn
35
- ? binaries.map((bin) =>
36
- path.join(wrappedIn, bin).replace(/\\/g, "/"),
37
- )
38
- : binaries;
39
-
40
24
  await tar.x({
41
25
  file: tarPath,
42
26
  cwd: dir,
43
- filter: (path) => filesToExtract.includes(path),
27
+ filter: (path) => binaries.includes(path),
44
28
  });
45
-
46
- // If wrapped, move files from wrapped directory to bin directory
47
- if (wrappedIn) {
48
- const wrappedDir = path.join(dir, wrappedIn);
49
- for (const binary of binaries) {
50
- const srcPath = path.join(wrappedDir, binary);
51
- const destPath = path.join(dir, binary);
52
- if (fs.existsSync(srcPath)) {
53
- fs.renameSync(srcPath, destPath);
54
- }
55
- }
56
- // Clean up empty wrapped directory
57
- try {
58
- fs.rmSync(wrappedDir, { recursive: true, force: true });
59
- } catch (err) {
60
- // Ignore cleanup errors
61
- }
62
- }
63
-
64
- console.log(`Successfully extracted ${binaries} to "${dir}"`);
29
+ console.log(`Successfully extracted binaries to "${dir}"`);
65
30
  } catch (err) {
66
31
  throw new Error(`Extraction failed: ${err.message}`);
67
32
  }
68
33
  }
69
34
 
70
- async function extractZip(zipPath, binaries, dir, wrappedIn) {
35
+ async function extractZip(zipPath, binaries, dir) {
71
36
  try {
72
37
  const zipData = fs.readFileSync(zipPath);
73
38
  const zip = await JSZip.loadAsync(zipData);
74
-
75
39
  for (const binary of binaries) {
76
- const binaryPath = wrappedIn
77
- ? path.join(wrappedIn, binary).replace(/\\/g, "/")
78
- : binary;
79
-
80
- if (!zip.files[binaryPath]) {
40
+ if (!zip.files[binary]) {
81
41
  throw new Error(
82
- `Error: ${binaryPath} does not exist in ${zipPath}`,
42
+ `Error: ${binary} does not exist in ${zipPath}`,
83
43
  );
84
44
  }
85
45
 
86
- const content = await zip.files[binaryPath].async("nodebuffer");
46
+ const content = await zip.files[binary].async("nodebuffer");
87
47
  if (!fs.existsSync(dir)) {
88
48
  fs.mkdirSync(dir, { recursive: true });
89
49
  }
@@ -134,21 +94,11 @@ const install = async () => {
134
94
  fs.chmodSync(bin, 0o755);
135
95
  return;
136
96
  case "zip":
137
- return extractZip(
138
- archivePath,
139
- archive.bins,
140
- binDir,
141
- archive.wrappedIn,
142
- );
97
+ return extractZip(archivePath, archive.bins, binDir);
143
98
  case "tar":
144
99
  case "tar.gz":
145
100
  case "tgz":
146
- return extractTar(
147
- archivePath,
148
- archive.bins,
149
- binDir,
150
- archive.wrappedIn,
151
- );
101
+ return extractTar(archivePath, archive.bins, binDir);
152
102
  case "tar.zst":
153
103
  case "tzst":
154
104
  case "tar.xz":
@@ -190,8 +140,6 @@ const download = async (url, filename) => {
190
140
  url: url,
191
141
  responseType: "stream",
192
142
  timeout: 300000, // 5min
193
- httpAgent: agent,
194
- httpsAgent: agent,
195
143
  });
196
144
 
197
145
  const writer = fs.createWriteStream(filename);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onkernel/cli",
3
- "version": "0.9.5",
3
+ "version": "0.10.0",
4
4
  "description": "Kernel CLI",
5
5
  "scripts": {
6
6
  "postinstall": "node install.js",
@@ -29,80 +29,79 @@
29
29
  "dependencies": {
30
30
  "axios": "^1.8.2",
31
31
  "jszip": "^3.10.1",
32
- "proxy-agent": "^6.5.0",
33
32
  "tar": "^7.4.3"
34
33
  },
35
34
  "archives": {
36
35
  "darwin-arm64": {
37
- "name": "kernel_0.9.5_darwin_arm64.tar.gz",
38
- "url": "https://github.com/onkernel/cli/releases/download/v0.9.5/kernel_0.9.5_darwin_arm64.tar.gz",
36
+ "name": "kernel_0.10.0_darwin_arm64.tar.gz",
37
+ "url": "https://github.com/onkernel/cli/releases/download/v0.10.0/kernel_0.10.0_darwin_arm64.tar.gz",
39
38
  "bins": [
40
39
  "kernel"
41
40
  ],
42
41
  "format": "tar.gz",
43
42
  "checksum": {
44
43
  "algorithm": "sha256",
45
- "digest": "747b2c49f67cf659aa6a25ab0101a5f3be26d3c5a26ba860f75adbbab0a7923e"
44
+ "digest": "b230200efd876777345d705e60ed44e064ee85dd28040ded956c4c4b8f3b9360"
46
45
  }
47
46
  },
48
47
  "darwin-x64": {
49
- "name": "kernel_0.9.5_darwin_amd64.tar.gz",
50
- "url": "https://github.com/onkernel/cli/releases/download/v0.9.5/kernel_0.9.5_darwin_amd64.tar.gz",
48
+ "name": "kernel_0.10.0_darwin_amd64.tar.gz",
49
+ "url": "https://github.com/onkernel/cli/releases/download/v0.10.0/kernel_0.10.0_darwin_amd64.tar.gz",
51
50
  "bins": [
52
51
  "kernel"
53
52
  ],
54
53
  "format": "tar.gz",
55
54
  "checksum": {
56
55
  "algorithm": "sha256",
57
- "digest": "6de862562281a9a6dd0a5a4c451d0eb6ab1b33a275f1afe0d05109957c091c7c"
56
+ "digest": "7d95facb8f7d61b88d9116ed91e33941855f1f316ceffcd49e1215fd48f07615"
58
57
  }
59
58
  },
60
59
  "linux-arm64": {
61
- "name": "kernel_0.9.5_linux_arm64.tar.gz",
62
- "url": "https://github.com/onkernel/cli/releases/download/v0.9.5/kernel_0.9.5_linux_arm64.tar.gz",
60
+ "name": "kernel_0.10.0_linux_arm64.tar.gz",
61
+ "url": "https://github.com/onkernel/cli/releases/download/v0.10.0/kernel_0.10.0_linux_arm64.tar.gz",
63
62
  "bins": [
64
63
  "kernel"
65
64
  ],
66
65
  "format": "tar.gz",
67
66
  "checksum": {
68
67
  "algorithm": "sha256",
69
- "digest": "1ca64517125c8aa636e3747c28a003b958d55f35bfbd156f833b9f97b9858e46"
68
+ "digest": "400c1262d5556e9930e4894e4b1865085681f37fc82e4dee6c8f13cc65e717bc"
70
69
  }
71
70
  },
72
71
  "linux-x64": {
73
- "name": "kernel_0.9.5_linux_amd64.tar.gz",
74
- "url": "https://github.com/onkernel/cli/releases/download/v0.9.5/kernel_0.9.5_linux_amd64.tar.gz",
72
+ "name": "kernel_0.10.0_linux_amd64.tar.gz",
73
+ "url": "https://github.com/onkernel/cli/releases/download/v0.10.0/kernel_0.10.0_linux_amd64.tar.gz",
75
74
  "bins": [
76
75
  "kernel"
77
76
  ],
78
77
  "format": "tar.gz",
79
78
  "checksum": {
80
79
  "algorithm": "sha256",
81
- "digest": "d9138868e4dff44313b3a34d6b3e1e62b7d8c8ca31388ecfed3bd83156c045ac"
80
+ "digest": "ceeebb892a8e71a7288afc1eb990b2af8b4405db23c205ee19515e0a3e6d6db4"
82
81
  }
83
82
  },
84
83
  "win32-arm64": {
85
- "name": "kernel_0.9.5_windows_arm64.tar.gz",
86
- "url": "https://github.com/onkernel/cli/releases/download/v0.9.5/kernel_0.9.5_windows_arm64.tar.gz",
84
+ "name": "kernel_0.10.0_windows_arm64.tar.gz",
85
+ "url": "https://github.com/onkernel/cli/releases/download/v0.10.0/kernel_0.10.0_windows_arm64.tar.gz",
87
86
  "bins": [
88
87
  "kernel.exe"
89
88
  ],
90
89
  "format": "tar.gz",
91
90
  "checksum": {
92
91
  "algorithm": "sha256",
93
- "digest": "696bc4d178f41032a10c81befaddc68db0d333071b7e8d3ba8f17093afe3dda8"
92
+ "digest": "da408a28b2faca29eefb1a409530a9c9dfb8d7ef40c286b8046822c7a72502b2"
94
93
  }
95
94
  },
96
95
  "win32-x64": {
97
- "name": "kernel_0.9.5_windows_amd64.tar.gz",
98
- "url": "https://github.com/onkernel/cli/releases/download/v0.9.5/kernel_0.9.5_windows_amd64.tar.gz",
96
+ "name": "kernel_0.10.0_windows_amd64.tar.gz",
97
+ "url": "https://github.com/onkernel/cli/releases/download/v0.10.0/kernel_0.10.0_windows_amd64.tar.gz",
99
98
  "bins": [
100
99
  "kernel.exe"
101
100
  ],
102
101
  "format": "tar.gz",
103
102
  "checksum": {
104
103
  "algorithm": "sha256",
105
- "digest": "7f8b2ef9ee318d9d6e7421c86f27053dbe68ade6583af047aee6592e9bf001c2"
104
+ "digest": "32366beec54a73500670d6efdb6257a207e9e12de9b1781751d0fce64c0c8b9d"
106
105
  }
107
106
  }
108
107
  }