@apmantza/greedysearch-pi 1.3.0 → 1.4.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 +208 -195
- package/cdp.mjs +1 -0
- package/extractors/bing-copilot.mjs +204 -204
- package/extractors/consent.mjs +248 -248
- package/extractors/google-ai.mjs +165 -165
- package/extractors/perplexity.mjs +184 -184
- package/extractors/selectors.mjs +52 -52
- package/index.ts +623 -507
- package/launch.mjs +7 -51
- package/package.json +2 -2
- package/search.mjs +997 -609
- package/skills/greedy-search/SKILL.md +145 -145
- package/test.sh +298 -298
package/launch.mjs
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
// the "Allow remote debugging?" dialog entirely. It runs on port 9222 so it doesn't
|
|
6
6
|
// conflict with your main Chrome session (which may use port 9223).
|
|
7
7
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// The original file is restored on --kill.
|
|
8
|
+
// search.mjs passes CDP_PROFILE_DIR so cdp.mjs targets this dedicated Chrome
|
|
9
|
+
// without ever touching the user's main Chrome DevToolsActivePort file.
|
|
11
10
|
//
|
|
12
11
|
// Usage:
|
|
13
12
|
// node launch.mjs — launch (or report if already running)
|
|
@@ -15,8 +14,8 @@
|
|
|
15
14
|
// node launch.mjs --status — check if running
|
|
16
15
|
|
|
17
16
|
import { spawn } from 'child_process';
|
|
18
|
-
import { existsSync, writeFileSync, readFileSync,
|
|
19
|
-
import { tmpdir,
|
|
17
|
+
import { existsSync, writeFileSync, readFileSync, mkdirSync, unlinkSync } from 'fs';
|
|
18
|
+
import { tmpdir, platform } from 'os';
|
|
20
19
|
import { join } from 'path';
|
|
21
20
|
import http from 'http';
|
|
22
21
|
|
|
@@ -43,16 +42,6 @@ function findChrome() {
|
|
|
43
42
|
return candidates.find(existsSync) || null;
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
function systemPortPath() {
|
|
47
|
-
const os = platform();
|
|
48
|
-
if (os === 'win32') return join(homedir(), 'AppData', 'Local', 'Google', 'Chrome', 'User Data', 'DevToolsActivePort');
|
|
49
|
-
if (os === 'darwin') return join(homedir(), 'Library', 'Application Support', 'Google', 'Chrome', 'DevToolsActivePort');
|
|
50
|
-
return join(homedir(), '.config', 'google-chrome', 'DevToolsActivePort');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const SYSTEM_PORT = systemPortPath();
|
|
54
|
-
const SYSTEM_BACKUP = SYSTEM_PORT + '.bak';
|
|
55
|
-
|
|
56
45
|
const CHROME_FLAGS = [
|
|
57
46
|
`--remote-debugging-port=${PORT}`,
|
|
58
47
|
'--disable-features=DevToolsPrivacyUI', // suppresses "Allow remote debugging?" dialog
|
|
@@ -108,36 +97,6 @@ async function writePortFile(timeoutMs = 15000) {
|
|
|
108
97
|
return false;
|
|
109
98
|
}
|
|
110
99
|
|
|
111
|
-
function redirectCdpToGreedySearch() {
|
|
112
|
-
// Back up system DevToolsActivePort (user's main Chrome)
|
|
113
|
-
if (existsSync(SYSTEM_PORT) && !existsSync(SYSTEM_BACKUP)) {
|
|
114
|
-
copyFileSync(SYSTEM_PORT, SYSTEM_BACKUP);
|
|
115
|
-
}
|
|
116
|
-
// Point cdp.mjs to our dedicated Chrome's port
|
|
117
|
-
// On Windows, main Chrome may hold a lock on SYSTEM_PORT (EBUSY).
|
|
118
|
-
// Fall back to writeFileSync which uses CreateFile/WriteFile instead of CopyFile.
|
|
119
|
-
try {
|
|
120
|
-
copyFileSync(ACTIVE_PORT, SYSTEM_PORT);
|
|
121
|
-
} catch (e) {
|
|
122
|
-
if (e.code !== 'EBUSY') throw e;
|
|
123
|
-
try {
|
|
124
|
-
writeFileSync(SYSTEM_PORT, readFileSync(ACTIVE_PORT, 'utf8'), 'utf8');
|
|
125
|
-
} catch {
|
|
126
|
-
console.warn('Warning: could not redirect DevToolsActivePort (file busy) — cdp.mjs will use existing port.');
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function restoreCdpToMainChrome() {
|
|
132
|
-
if (existsSync(SYSTEM_BACKUP)) {
|
|
133
|
-
copyFileSync(SYSTEM_BACKUP, SYSTEM_PORT);
|
|
134
|
-
console.log('Restored DevToolsActivePort to main Chrome.');
|
|
135
|
-
} else if (existsSync(SYSTEM_PORT)) {
|
|
136
|
-
// No backup means main Chrome wasn't using CDP — remove our file
|
|
137
|
-
try { unlinkSync(SYSTEM_PORT); } catch {}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
100
|
// ---------------------------------------------------------------------------
|
|
142
101
|
|
|
143
102
|
async function main() {
|
|
@@ -151,7 +110,6 @@ async function main() {
|
|
|
151
110
|
} else {
|
|
152
111
|
console.log('GreedySearch Chrome is not running.');
|
|
153
112
|
}
|
|
154
|
-
restoreCdpToMainChrome();
|
|
155
113
|
return;
|
|
156
114
|
}
|
|
157
115
|
|
|
@@ -168,8 +126,7 @@ async function main() {
|
|
|
168
126
|
const ready = await writePortFile(5000);
|
|
169
127
|
if (ready) {
|
|
170
128
|
console.log(`GreedySearch Chrome already running (pid ${existing}, port ${PORT}).`);
|
|
171
|
-
|
|
172
|
-
console.log('DevToolsActivePort redirected.');
|
|
129
|
+
console.log('Dedicated GreedySearch DevToolsActivePort is ready.');
|
|
173
130
|
return;
|
|
174
131
|
}
|
|
175
132
|
// Stale PID — process alive but not Chrome on port 9223. Fall through to fresh launch.
|
|
@@ -195,16 +152,15 @@ async function main() {
|
|
|
195
152
|
proc.unref();
|
|
196
153
|
writeFileSync(PID_FILE, String(proc.pid));
|
|
197
154
|
|
|
198
|
-
// Wait for Chrome HTTP endpoint
|
|
155
|
+
// Wait for Chrome HTTP endpoint and build the dedicated DevToolsActivePort file
|
|
199
156
|
const portFileReady = await writePortFile();
|
|
200
157
|
if (!portFileReady) {
|
|
201
158
|
console.error('Chrome did not become ready within 15s.');
|
|
202
159
|
process.exit(1);
|
|
203
160
|
}
|
|
204
|
-
redirectCdpToGreedySearch();
|
|
205
161
|
|
|
206
162
|
console.log(`Ready. No more "Allow remote debugging?" dialogs.`);
|
|
207
|
-
console.log(
|
|
163
|
+
console.log('GreedySearch now uses its own isolated DevToolsActivePort file.');
|
|
208
164
|
}
|
|
209
165
|
|
|
210
166
|
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apmantza/greedysearch-pi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Pi extension: browser-automation tool that searches Perplexity, Bing Copilot, and Google AI in parallel, extracts answers and sources via CDP, with optional Gemini synthesis — grounded AI answers from real browser interactions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
],
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/apmantza/GreedySearch-pi"
|
|
11
|
+
"url": "git+https://github.com/apmantza/GreedySearch-pi.git"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"pi": {
|