@cli4ai/chrome 1.0.6 → 1.0.8
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/cli4ai.json +58 -9
- package/package.json +1 -1
- package/run.ts +7 -3
package/cli4ai.json
CHANGED
|
@@ -1,22 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chrome",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Chrome browser automation (foundation for browser tools)",
|
|
5
5
|
"author": "cliforai",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"entry": "run.ts",
|
|
8
|
-
"runtime": "
|
|
9
|
-
"keywords": [
|
|
8
|
+
"runtime": "node",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"chrome",
|
|
11
|
+
"browser",
|
|
12
|
+
"puppeteer",
|
|
13
|
+
"automation"
|
|
14
|
+
],
|
|
10
15
|
"commands": {
|
|
11
|
-
"connect": {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
"connect": {
|
|
17
|
+
"description": "Connect to Chrome",
|
|
18
|
+
"args": [
|
|
19
|
+
{
|
|
20
|
+
"name": "port",
|
|
21
|
+
"description": "Default: 9222",
|
|
22
|
+
"required": false
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"navigate": {
|
|
27
|
+
"description": "Open URL",
|
|
28
|
+
"args": [
|
|
29
|
+
{
|
|
30
|
+
"name": "url",
|
|
31
|
+
"required": true
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"eval": {
|
|
36
|
+
"description": "Run JavaScript",
|
|
37
|
+
"args": [
|
|
38
|
+
{
|
|
39
|
+
"name": "script",
|
|
40
|
+
"required": true
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"screenshot": {
|
|
45
|
+
"description": "Capture viewport",
|
|
46
|
+
"args": [
|
|
47
|
+
{
|
|
48
|
+
"name": "output",
|
|
49
|
+
"required": false
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"cookies": {
|
|
54
|
+
"description": "Get cookies",
|
|
55
|
+
"args": [
|
|
56
|
+
{
|
|
57
|
+
"name": "domain",
|
|
58
|
+
"required": false
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
16
62
|
},
|
|
17
63
|
"dependencies": {
|
|
18
64
|
"puppeteer": "^24.0.0",
|
|
19
65
|
"commander": "^14.0.0"
|
|
20
66
|
},
|
|
21
|
-
"mcp": {
|
|
67
|
+
"mcp": {
|
|
68
|
+
"enabled": true,
|
|
69
|
+
"transport": "stdio"
|
|
70
|
+
}
|
|
22
71
|
}
|
package/package.json
CHANGED
package/run.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env npx tsx
|
|
2
2
|
import puppeteer from 'puppeteer';
|
|
3
3
|
import { readFileSync, writeFileSync } from 'fs';
|
|
4
4
|
import { join, resolve } from 'path';
|
|
5
5
|
import { cli, log, output, outputError, withErrorHandling } from '@cli4ai/lib/cli.ts';
|
|
6
6
|
|
|
7
|
-
const WS_FILE = join(import.meta.
|
|
7
|
+
const WS_FILE = join(new URL('.', import.meta.url).pathname, '.ws-endpoint');
|
|
8
8
|
|
|
9
9
|
async function getPage(newTab = false) {
|
|
10
10
|
let ws: string;
|
|
@@ -50,8 +50,12 @@ program
|
|
|
50
50
|
|
|
51
51
|
program
|
|
52
52
|
.command('eval <script>')
|
|
53
|
-
.description('Run JavaScript')
|
|
53
|
+
.description('Run JavaScript (WARNING: executes arbitrary code in browser context)')
|
|
54
54
|
.action(withErrorHandling(async (script: string) => {
|
|
55
|
+
// SECURITY WARNING: This command executes arbitrary JavaScript in the browser.
|
|
56
|
+
// Only use with trusted input. Malicious scripts can access cookies, localStorage,
|
|
57
|
+
// and perform actions as the logged-in user.
|
|
58
|
+
log('⚠️ WARNING: Executing arbitrary JavaScript in browser context');
|
|
55
59
|
const { page, browser } = await getPage();
|
|
56
60
|
const result = await page.evaluate((code: string) => eval(code), script);
|
|
57
61
|
if (result !== undefined) output(result);
|