@duckmind/dm-darwin-arm64 0.52.6 → 0.53.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/dm +0 -0
- package/extensions/.dm-extensions.json +14 -10
- package/extensions/dm-cua/bin/browser-cua.mjs +6 -6
- package/extensions/dm-cua/index.js +5 -5
- package/extensions/dm-cua/src/browser-cua-lib.mjs +2 -2
- package/extensions/greedysearch-dm/bin/cdp-greedy.mjs +8 -1
- package/extensions/greedysearch-dm/bin/cdp-headless.mjs +1 -1
- package/extensions/greedysearch-dm/bin/cdp-visible.mjs +1 -1
- package/extensions/greedysearch-dm/bin/cdp.mjs +29 -20
- package/extensions/greedysearch-dm/bin/gschrome.mjs +1 -8
- package/extensions/greedysearch-dm/bin/kill-visible.mjs +1 -1
- package/extensions/greedysearch-dm/bin/launch-visible.mjs +1 -2
- package/extensions/greedysearch-dm/bin/launch.mjs +9 -11
- package/extensions/greedysearch-dm/bin/mcp.mjs +375 -0
- package/extensions/greedysearch-dm/bin/search.mjs +309 -157
- package/extensions/greedysearch-dm/bin/visible.mjs +1 -1
- package/extensions/greedysearch-dm/extractors/bing-copilot.mjs +205 -68
- package/extensions/greedysearch-dm/extractors/chatgpt.mjs +229 -140
- package/extensions/greedysearch-dm/extractors/common.mjs +160 -50
- package/extensions/greedysearch-dm/extractors/consensus.mjs +226 -93
- package/extensions/greedysearch-dm/extractors/consent.mjs +44 -17
- package/extensions/greedysearch-dm/extractors/gemini.mjs +277 -138
- package/extensions/greedysearch-dm/extractors/google-ai.mjs +172 -64
- package/extensions/greedysearch-dm/extractors/logically.mjs +183 -69
- package/extensions/greedysearch-dm/extractors/perplexity.mjs +331 -65
- package/extensions/greedysearch-dm/extractors/semantic-scholar.mjs +118 -41
- package/extensions/greedysearch-dm/index.js +23 -20
- package/extensions/greedysearch-dm/package.json +8 -3
- package/extensions/greedysearch-dm/skills/greedy-search/skill.md +8 -8
- package/extensions/greedysearch-dm/src/fetcher.mjs +2 -2
- package/extensions/greedysearch-dm/src/formatters/results.js +8 -6
- package/extensions/greedysearch-dm/src/github.mjs +7 -7
- package/extensions/greedysearch-dm/src/reddit.mjs +1 -1
- package/extensions/greedysearch-dm/src/search/browser-lifecycle.mjs +10 -8
- package/extensions/greedysearch-dm/src/search/challenge-detect.mjs +48 -0
- package/extensions/greedysearch-dm/src/search/chrome.mjs +130 -54
- package/extensions/greedysearch-dm/src/search/constants.mjs +6 -6
- package/extensions/greedysearch-dm/src/search/engines.mjs +9 -9
- package/extensions/greedysearch-dm/src/search/fetch-source.mjs +160 -83
- package/extensions/greedysearch-dm/src/search/minimize.mjs +1 -0
- package/extensions/greedysearch-dm/src/search/paths.mjs +1 -1
- package/extensions/greedysearch-dm/src/search/pdf.mjs +1 -1
- package/extensions/greedysearch-dm/src/search/port-pid.mjs +1 -1
- package/extensions/greedysearch-dm/src/search/progress.mjs +2 -0
- package/extensions/greedysearch-dm/src/search/recovery.mjs +1 -1
- package/extensions/greedysearch-dm/src/search/research.mjs +262 -167
- package/extensions/greedysearch-dm/src/search/scale-aware.mjs +11 -0
- package/extensions/greedysearch-dm/src/search/simple-research.mjs +827 -0
- package/extensions/greedysearch-dm/src/search/synthesis-runner.mjs +9 -9
- package/extensions/greedysearch-dm/src/search/synthesis.mjs +10 -10
- package/extensions/greedysearch-dm/src/tools/greedy-search-handler.js +23 -20
- package/extensions/greedysearch-dm/src/tools/shared.js +10 -9
- package/extensions/greedysearch-dm/src/utils/node-runtime.mjs +1 -1
- package/package.json +1 -1
- package/extensions/greedysearch-dm/src/search/cdp-endpoint.mjs +0 -3
- package/extensions/greedysearch-dm/src/search/launcher-paths.mjs +0 -3
- package/extensions/greedysearch-dm/src/search/partial-output.mjs +0 -1
- package/extensions/greedysearch-dm/src/utils/browser-executable.mjs +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{spawn as
|
|
3
|
-
`)[0]?.slice(0,8);if(!t)throw Error("No Chrome tabs found. Is Chrome running with --remote-debugging-port=9222?");let
|
|
4
|
-
`)}return
|
|
2
|
+
import{spawn as C}from"node:child_process";import{basename as T}from"node:path";import{dirname as A,join as M}from"node:path";import{fileURLToPath as $}from"node:url";function j(e=process.env,t=process.execPath){let r=e.GREEDY_SEARCH_NODE||e.NODE_BINARY||e.NODE;if(r?.trim())return r.trim();let n=T(t||"").toLowerCase();if(n==="node"||n==="node.exe")return t;return"node"}var N=A($(import.meta.url)),E=M(N,"..","bin","cdp.mjs"),I=new Set(["list","snap","eval","shot","html","nav","net","click","clickxy","type","loadall","evalraw","browse","stop","--tab"]);function R(e){if(!Array.isArray(e)||e.length===0)throw Error("cdp: args must be a non-empty array");if(e[0]==="test")return e.map((t,r)=>p(t,r));if(!I.has(e[0]))throw Error(`cdp: unknown subcommand '${e[0]}'`);return e.map((t,r)=>p(t,r))}function p(e,t){if(typeof e!=="string")throw Error(`cdp: argv[${t}] must be a string (got ${typeof e})`);if(e.includes("\x00"))throw Error(`cdp: argv[${t}] contains a null byte`);return e}function u(e,t=30000){return S(e,null,t)}function S(e,t=null,r=30000){let n=R(e);return new Promise((i,a)=>{let o=C(j(),[E,...n],{stdio:[t==null?"ignore":"pipe","pipe","pipe"]});if(t!=null)o.stdin.write(t),o.stdin.end();let l="",c="";o.stdout.on("data",(d)=>l+=d),o.stderr.on("data",(d)=>c+=d);let f=setTimeout(()=>{o.kill(),a(Error(`cdp timeout: ${e[0]}`))},r);o.on("close",(d)=>{if(clearTimeout(f),d===0)i(l.trim());else a(Error(c.trim()||`cdp exit ${d}`))})})}async function h(e){if(e)return e;let t=(await u(["list"])).split(`
|
|
3
|
+
`)[0]?.slice(0,8);if(!t)throw Error("No Chrome tabs found. Is Chrome running with --remote-debugging-port=9222?");let r=await u(["evalraw",t,"Target.createTarget",'{"url":"about:blank"}']),n;try{n=JSON.parse(r)}catch(o){throw Error(`Target.createTarget returned invalid JSON: ${o.message}`)}let{targetId:i}=n;if(!i)throw Error("Target.createTarget did not return a targetId");await u(["list"]);let a=i.slice(0,8);try{await W(a)}catch(o){process.stderr.write(`[getOrOpenTab] stealth injection failed: ${o.message}
|
|
4
|
+
`)}return a}async function W(e){await u(["evalraw",e,"Page.addScriptToEvaluateOnNewDocument",JSON.stringify({source:`
|
|
5
5
|
(function() {
|
|
6
6
|
// ── Runtime.enable / CDP detection masking ──────────────
|
|
7
7
|
try { delete window.__REBROWSER_RUNTIME_ENABLE; } catch(_) {}
|
|
@@ -12,40 +12,62 @@ import{spawn as k}from"node:child_process";import{dirname as C,join as j}from"no
|
|
|
12
12
|
try { delete window._phantom; } catch(_) {}
|
|
13
13
|
try { delete window.Buffer; } catch(_) {}
|
|
14
14
|
|
|
15
|
-
// Real Chrome without automation
|
|
16
|
-
// A literal false
|
|
17
|
-
//
|
|
18
|
-
|
|
15
|
+
// Real Chrome without automation should not expose navigator.webdriver at all.
|
|
16
|
+
// A literal false or an own-property getter returning undefined is itself a
|
|
17
|
+
// common stealth tell; remove both instance and prototype properties when the
|
|
18
|
+
// descriptor is configurable (as it is with --disable-blink-features).
|
|
19
|
+
try { delete navigator.webdriver; } catch(_) {}
|
|
20
|
+
try { delete Navigator.prototype.webdriver; } catch(_) {}
|
|
19
21
|
Object.defineProperty(navigator, 'vendor', { get: () => 'Google Inc.', configurable: true });
|
|
20
22
|
Object.defineProperty(navigator, 'platform', { get: () => 'Win32', configurable: true });
|
|
21
23
|
Object.defineProperty(navigator, 'maxTouchPoints', { get: () => 0, configurable: true });
|
|
22
24
|
Object.defineProperty(navigator, 'pdfViewerEnabled', { get: () => true, configurable: true });
|
|
25
|
+
Object.defineProperty(navigator, 'productSub', { get: () => '20030107', configurable: true });
|
|
26
|
+
Object.defineProperty(navigator, 'product', { get: () => 'Gecko', configurable: true });
|
|
27
|
+
var __greedyMimeTypes = null;
|
|
28
|
+
function __makeMimeTypes() {
|
|
29
|
+
var pdf = { type: 'application/pdf', suffixes: 'pdf', description: 'Portable Document Format', enabledPlugin: null };
|
|
30
|
+
var textPdf = { type: 'text/pdf', suffixes: 'pdf', description: 'Portable Document Format', enabledPlugin: null };
|
|
31
|
+
try { Object.setPrototypeOf(pdf, MimeType.prototype); } catch(_) {}
|
|
32
|
+
try { Object.setPrototypeOf(textPdf, MimeType.prototype); } catch(_) {}
|
|
33
|
+
var m = [pdf, textPdf];
|
|
34
|
+
try { Object.setPrototypeOf(m, MimeTypeArray.prototype); } catch(_) {}
|
|
35
|
+
m.item = function item(i) { return this[i] || null; };
|
|
36
|
+
m.namedItem = function namedItem(name) { return Array.prototype.find.call(this, function(x) { return x && x.type === name; }) || null; };
|
|
37
|
+
return m;
|
|
38
|
+
}
|
|
23
39
|
Object.defineProperty(navigator, 'plugins', {
|
|
24
40
|
get: () => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
41
|
+
__greedyMimeTypes = __greedyMimeTypes || __makeMimeTypes();
|
|
42
|
+
var plugin0 = { name: 'Chrome PDF Plugin', filename: 'internal-pdf-viewer', description: 'Portable Document Format' };
|
|
43
|
+
var plugin1 = { name: 'Chrome PDF Viewer', filename: 'mhjfbmdgcfjbbpaeojofohoefgiehjai', description: '' };
|
|
44
|
+
var plugin2 = { name: 'Native Client', filename: 'internal-nacl-plugin', description: '' };
|
|
45
|
+
try { Object.setPrototypeOf(plugin0, Plugin.prototype); } catch(_) {}
|
|
46
|
+
try { Object.setPrototypeOf(plugin1, Plugin.prototype); } catch(_) {}
|
|
47
|
+
try { Object.setPrototypeOf(plugin2, Plugin.prototype); } catch(_) {}
|
|
48
|
+
var p = [plugin0, plugin1, plugin2];
|
|
49
|
+
p.item = function item(i) { return this[i] || null; };
|
|
50
|
+
p.namedItem = function namedItem(name) { return Array.prototype.find.call(this, function(x) { return x && x.name === name; }) || null; };
|
|
51
|
+
p.refresh = function refresh() {};
|
|
52
|
+
try { Object.setPrototypeOf(p, PluginArray.prototype); } catch(_) {}
|
|
53
|
+
try {
|
|
54
|
+
__greedyMimeTypes[0].enabledPlugin = p[0];
|
|
55
|
+
__greedyMimeTypes[1].enabledPlugin = p[0];
|
|
56
|
+
} catch(_) {}
|
|
31
57
|
return p;
|
|
32
58
|
},
|
|
59
|
+
configurable: true,
|
|
33
60
|
});
|
|
34
61
|
Object.defineProperty(navigator, 'mimeTypes', {
|
|
35
62
|
get: () => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{ type: 'text/pdf', suffixes: 'pdf', description: 'Portable Document Format', enabledPlugin: null },
|
|
39
|
-
];
|
|
40
|
-
m.item = function(i) { return m[i] || null; };
|
|
41
|
-
m.namedItem = function(name) { return m.find(function(x) { return x.type === name; }) || null; };
|
|
42
|
-
return m;
|
|
63
|
+
__greedyMimeTypes = __greedyMimeTypes || __makeMimeTypes();
|
|
64
|
+
return __greedyMimeTypes;
|
|
43
65
|
},
|
|
44
66
|
configurable: true,
|
|
45
67
|
});
|
|
46
68
|
Object.defineProperty(navigator, 'languages', { get: () => ['en-US', 'en'], configurable: true });
|
|
47
69
|
try {
|
|
48
|
-
Object.defineProperty(navigator, 'connection', { get: () => ({ effectiveType: '4g', rtt: 50, downlink: 10, saveData: false }), configurable: true });
|
|
70
|
+
Object.defineProperty(navigator, 'connection', { get: () => ({ effectiveType: '4g', rtt: 50, downlink: 10, downlinkMax: Infinity, saveData: false }), configurable: true });
|
|
49
71
|
} catch(_) {}
|
|
50
72
|
if (!navigator.mediaDevices) {
|
|
51
73
|
Object.defineProperty(navigator, 'mediaDevices', {
|
|
@@ -61,6 +83,18 @@ import{spawn as k}from"node:child_process";import{dirname as C,join as j}from"no
|
|
|
61
83
|
configurable: true,
|
|
62
84
|
});
|
|
63
85
|
}
|
|
86
|
+
// ── Missing platform APIs (headless often lacks these) ─
|
|
87
|
+
try {
|
|
88
|
+
if (!navigator.share) {
|
|
89
|
+
navigator.share = function() { return Promise.reject(new Error('NotAllowedError')); };
|
|
90
|
+
}
|
|
91
|
+
} catch(_) {}
|
|
92
|
+
try {
|
|
93
|
+
if (!navigator.contentIndex) {
|
|
94
|
+
Object.defineProperty(navigator, 'contentIndex', { get: () => ({ add: function() {}, delete: function() {}, getAll: function() { return Promise.resolve([]); } }), configurable: true });
|
|
95
|
+
}
|
|
96
|
+
} catch(_) {}
|
|
97
|
+
|
|
64
98
|
if (!window.chrome) {
|
|
65
99
|
window.chrome = {
|
|
66
100
|
app: { isInstalled: false, InstallState: {}, RunningState: {} },
|
|
@@ -68,8 +102,8 @@ import{spawn as k}from"node:child_process";import{dirname as C,join as j}from"no
|
|
|
68
102
|
OnInstalledReason: {}, OnRestartRequiredReason: {}, PlatformArch: {}, PlatformNaclArch: {}, PlatformOs: {}, RequestUpdateCheckStatus: {},
|
|
69
103
|
connect: () => ({}), sendMessage: () => {}, onMessage: { addListener: () => {} }
|
|
70
104
|
},
|
|
71
|
-
loadTimes: ()
|
|
72
|
-
csi: ()
|
|
105
|
+
loadTimes: function() { return { requestTime: 0, startLoadTime: Date.now() - 5000, commitLoadTime: Date.now() - 3000, finishDocumentLoadTime: Date.now() - 2000, finishLoadTime: Date.now() - 1000, firstPaintTime: Date.now() - 800, navigationType: 'Other', wasFetchedViaSpdy: true, wasNpnNegotiated: true, npnNegotiatedProtocol: 'h2', wasAlternateProtocolAvailable: false, connectionInfo: 'http/2' }; },
|
|
106
|
+
csi: function() { var t = Date.now(); return { onloadT: t - 2000, startE: t - 5000, pageT: 'back', tran: 2 }; },
|
|
73
107
|
};
|
|
74
108
|
}
|
|
75
109
|
var __greedyNativeFns = [];
|
|
@@ -90,6 +124,19 @@ import{spawn as k}from"node:child_process";import{dirname as C,join as j}from"no
|
|
|
90
124
|
return getParam.call(this, p);
|
|
91
125
|
});
|
|
92
126
|
} catch(_) {}
|
|
127
|
+
// ── WebGL readPixels noise ──────────────────────────
|
|
128
|
+
// CreepJS and other fingerprinters draw content with WebGL and read back the
|
|
129
|
+
// rendered pixels. Adding subtle noise breaks rendering-based fingerprinting.
|
|
130
|
+
try {
|
|
131
|
+
var origReadPixels = WebGLRenderingContext.prototype.readPixels;
|
|
132
|
+
WebGLRenderingContext.prototype.readPixels = __markNative(function readPixels(x, y, width, height, format, type, pixels) {
|
|
133
|
+
var result = origReadPixels.call(this, x, y, width, height, format, type, pixels);
|
|
134
|
+
if (pixels && pixels.length > 0) {
|
|
135
|
+
pixels[0] ^= 1;
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
});
|
|
139
|
+
} catch(_) {}
|
|
93
140
|
Object.defineProperty(navigator, 'hardwareConcurrency', { get: () => 8, configurable: true });
|
|
94
141
|
Object.defineProperty(navigator, 'deviceMemory', { get: () => 8, configurable: true });
|
|
95
142
|
|
|
@@ -97,7 +144,7 @@ import{spawn as k}from"node:child_process";import{dirname as C,join as j}from"no
|
|
|
97
144
|
// Headless rendering engines produce slightly different canvas output
|
|
98
145
|
// than headed Chrome. Subtle noise breaks hash-based fingerprinting.
|
|
99
146
|
try {
|
|
100
|
-
var __canvasNoise = ((Date.now()
|
|
147
|
+
var __canvasNoise = ((Date.now() & 0xFF) | 1);
|
|
101
148
|
var origFill = CanvasRenderingContext2D.prototype.fillText;
|
|
102
149
|
CanvasRenderingContext2D.prototype.fillText = __markNative(function fillText() {
|
|
103
150
|
this.globalAlpha = 0.9995;
|
|
@@ -116,15 +163,39 @@ import{spawn as k}from"node:child_process";import{dirname as C,join as j}from"no
|
|
|
116
163
|
HTMLCanvasElement.prototype.toDataURL = __markNative(function toDataURL() {
|
|
117
164
|
var ctx = this.getContext('2d');
|
|
118
165
|
if (ctx) {
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
166
|
+
// Spread noise across canvas to break hash-based fingerprinting.
|
|
167
|
+
// Uses a deterministic pattern so it's consistent per page load
|
|
168
|
+
// but varies between sessions.
|
|
169
|
+
var w = this.width, h = this.height;
|
|
170
|
+
if (w > 0 && h > 0) {
|
|
171
|
+
var imgData = ctx.getImageData(0, 0, Math.min(w, 4), Math.min(h, 4));
|
|
172
|
+
if (imgData && imgData.data) {
|
|
173
|
+
for (var __i = 0; __i < imgData.data.length; __i += 4) {
|
|
174
|
+
imgData.data[__i] ^= (__canvasNoise + __i) & 0xFF;
|
|
175
|
+
}
|
|
176
|
+
ctx.putImageData(imgData, 0, 0);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
123
179
|
}
|
|
124
180
|
return origToDataURL.apply(this, arguments);
|
|
125
181
|
});
|
|
126
182
|
} catch(_) {}
|
|
127
183
|
|
|
184
|
+
// ── AudioContext fingerprint noise ────────────────────
|
|
185
|
+
// Headless Chrome's AudioContext produces slightly different output.
|
|
186
|
+
// Subtle noise breaks audio-based fingerprinting.
|
|
187
|
+
try {
|
|
188
|
+
var __audioSeed = ((Date.now() & 0x1F) | 1);
|
|
189
|
+
var origGetChannelData = AudioBuffer.prototype.getChannelData;
|
|
190
|
+
AudioBuffer.prototype.getChannelData = __markNative(function getChannelData(channel) {
|
|
191
|
+
var data = origGetChannelData.call(this, channel);
|
|
192
|
+
for (var __i = 0; __i < data.length; __i += 64) {
|
|
193
|
+
data[__i] *= 0.99999;
|
|
194
|
+
}
|
|
195
|
+
return data;
|
|
196
|
+
});
|
|
197
|
+
} catch(_) {}
|
|
198
|
+
|
|
128
199
|
// ── window outer dimensions ──────────────────────────
|
|
129
200
|
// outerWidth/Height = 0 in headless — a well-known bot signal.
|
|
130
201
|
// Mirror innerWidth/Height (set by --window-size flag) so the ratio is sane.
|
|
@@ -134,9 +205,15 @@ import{spawn as k}from"node:child_process";import{dirname as C,join as j}from"no
|
|
|
134
205
|
} catch(_) {}
|
|
135
206
|
|
|
136
207
|
// ── screen properties ─────────────────────────────────
|
|
208
|
+
// Headless Chrome often reports an 800x600 screen even when the viewport is
|
|
209
|
+
// 1920x1080. Keep screen metrics internally consistent with our launch flags.
|
|
137
210
|
try {
|
|
138
|
-
|
|
139
|
-
|
|
211
|
+
Object.defineProperty(screen, 'width', { get: () => 1920, configurable: true });
|
|
212
|
+
Object.defineProperty(screen, 'height', { get: () => 1080, configurable: true });
|
|
213
|
+
Object.defineProperty(screen, 'availWidth', { get: () => 1920, configurable: true });
|
|
214
|
+
Object.defineProperty(screen, 'availHeight', { get: () => 1040, configurable: true });
|
|
215
|
+
Object.defineProperty(screen, 'colorDepth', { get: () => 24, configurable: true });
|
|
216
|
+
Object.defineProperty(screen, 'pixelDepth', { get: () => 24, configurable: true });
|
|
140
217
|
} catch(_) {}
|
|
141
218
|
|
|
142
219
|
// ── navigator.userAgentData (UA Client Hints) ─────────
|
|
@@ -209,10 +286,10 @@ import{spawn as k}from"node:child_process";import{dirname as C,join as j}from"no
|
|
|
209
286
|
};
|
|
210
287
|
} catch(_) {}
|
|
211
288
|
})();
|
|
212
|
-
`})])}async function
|
|
289
|
+
`})])}async function y(e,t,r=15000,n=500){let i=String.raw`
|
|
213
290
|
new Promise((resolve) => {
|
|
214
|
-
const _deadline = Date.now() + ${
|
|
215
|
-
const _baseInterval = ${
|
|
291
|
+
const _deadline = Date.now() + ${r};
|
|
292
|
+
const _baseInterval = ${n};
|
|
216
293
|
|
|
217
294
|
function _jitter(ms) {
|
|
218
295
|
return Math.max(50, ms + (Math.random() * ms * 0.4 - ms * 0.2));
|
|
@@ -228,11 +305,11 @@ import{spawn as k}from"node:child_process";import{dirname as C,join as j}from"no
|
|
|
228
305
|
|
|
229
306
|
_poll();
|
|
230
307
|
})
|
|
231
|
-
`;return await
|
|
232
|
-
`)}function
|
|
308
|
+
`;return await u(["eval",e,i],r+5000)==="true"}async function _(e){let t=e.indexOf("--stdin");if(t===-1)return e;let r=await new Promise((i)=>{let a="";process.stdin.setEncoding("utf8"),process.stdin.on("data",(o)=>a+=o),process.stdin.on("end",()=>i(a.trim()))}),n=[...e];return n[t]=r,n}function w(e){let t=e.includes("--short"),r=e.filter((l)=>l!=="--short"),n=r.indexOf("--tab"),i=n===-1?null:r[n+1];if(n!==-1)r=r.filter((l,c)=>c!==n&&c!==n+1);let a=r.indexOf("--locale"),o=a===-1?null:r[a+1];if(a!==-1)r=r.filter((l,c)=>c!==a&&c!==a+1);return{query:r.join(" "),tabPrefix:i,short:t,locale:o}}function b(e,t){if(!e.length||e[0]==="--help")process.stderr.write(t),process.exit(1)}function v(e,t,r=300){if(!t||e.length<=r)return e;let n=e.slice(0,r),i=n.lastIndexOf(" ");return i>0?`${n.slice(0,i)}…`:`${n}…`}function x(e){process.stdout.write(`${JSON.stringify(e,null,2)}
|
|
309
|
+
`)}function g(e,t,r=null){if(!e||typeof e!=="object")return;let n=r?` (+${Date.now()-r}ms)`:"";if(e.lastStage=t,!Array.isArray(e.stages))e.stages=[];e.stages.push({stage:t,at:Date.now()});let i=e.engine||"extractor";console.error(`[${i}] stage: ${t}${n}`)}function m({engine:e,mode:t="headless",clipboardEmpty:r=null,fallbackUsed:n=null,blockedBy:i=null,verificationResult:a=null,inputReady:o=null,durationMs:l=null,lastStage:c=null,stages:f=null}={}){return{engine:e,mode:t,clipboardEmpty:r,fallbackUsed:n,blockedBy:i,verificationResult:a,inputReady:o,durationMs:l,lastStage:c,stages:f}}function P(e,t=null){if(t){let r=JSON.stringify({_envelope:t,error:e.message});process.stdout.write(`${r}
|
|
233
310
|
`)}process.stderr.write(`Error: ${e.message}
|
|
234
|
-
`),process.exit(1)}var
|
|
235
|
-
`,
|
|
311
|
+
`),process.exit(1)}var L=`Usage: node extractors/semantic-scholar.mjs "<query>" [--tab <prefix>]
|
|
312
|
+
`,F=".cl-paper-row[data-paper-id]";function D(e){let t=String(e||"").replaceAll("-"," ");return`https://www.semanticscholar.org/search?q=${encodeURIComponent(t)}&sort=relevance`}async function G(e){await u(["eval",e,String.raw`
|
|
236
313
|
(() => {
|
|
237
314
|
const selectors = [
|
|
238
315
|
'.osano-cm-dialog__close',
|
|
@@ -246,7 +323,7 @@ import{spawn as k}from"node:child_process";import{dirname as C,join as j}from"no
|
|
|
246
323
|
}
|
|
247
324
|
return null;
|
|
248
325
|
})()
|
|
249
|
-
`]).catch(()=>null)}async function
|
|
326
|
+
`]).catch(()=>null)}async function H(e,{limit:t=8}={}){let r=await u(["eval",e,String.raw`
|
|
250
327
|
((limit) => {
|
|
251
328
|
function clean(value) {
|
|
252
329
|
return String(value || '').replace(/\s+/g, ' ').trim();
|
|
@@ -303,7 +380,7 @@ import{spawn as k}from"node:child_process";import{dirname as C,join as j}from"no
|
|
|
303
380
|
};
|
|
304
381
|
}));
|
|
305
382
|
})(${t})
|
|
306
|
-
`]);try{return JSON.parse(
|
|
307
|
-
TLDR: ${t.tldr}`:"";return`${t.rank}. ${t.title}${
|
|
383
|
+
`]);try{return JSON.parse(r)}catch{return[]}}function J(e){if(!e.length)return"Semantic Scholar returned no paper results.";return e.map((t)=>{let r=[];if(t.authors?.length)r.push(t.authors.join(", "));if(t.venue)r.push(t.venue);if(t.date)r.push(t.date);if(Number.isFinite(t.citationCount))r.push(`${t.citationCount.toLocaleString()} citations`);let n=r.length?` — ${r.join(" · ")}`:"",i=t.tldr?`
|
|
384
|
+
TLDR: ${t.tldr}`:"";return`${t.rank}. ${t.title}${n}${i}`}).join(`
|
|
308
385
|
|
|
309
|
-
`)}async function
|
|
386
|
+
`)}async function q(){let e=await _(process.argv.slice(2));b(e,L);let{query:t,tabPrefix:r,short:n}=w(e),i=Date.now(),o={engine:"semantic-scholar",mode:process.env.GREEDY_SEARCH_VISIBLE==="1"?"visible":"headless",blockedBy:null,verificationResult:null,inputReady:null};try{if(!r)await u(["list"]);let l=await h(r);g(o,"nav",i),await u(["nav",l,D(t)],25000),await new Promise((s)=>setTimeout(s,800)),g(o,"consent",i),await G(l),g(o,"results-wait",i);let c=await y(l,F,15000,500);if(o.inputReady=c,!c){let s=await u(["eval",l,"document.body?.innerText || ''"]).catch(()=>"");if(/captcha|cloudflare|verify|robot|blocked/i.test(s))throw o.blockedBy="verification",o.verificationResult="needs-human",Error("Semantic Scholar verification required — please solve it in the visible browser window");throw Error("Semantic Scholar results not found")}g(o,"extract",i);let f=await H(l,{limit:n?5:8}),d=f.filter((s)=>s.title&&s.url).map((s)=>({title:s.pdfUrl?`${s.title} (PDF)`:s.title,url:s.url,semanticScholarUrl:s.semanticScholarUrl,paperId:s.paperId,citationCount:s.citationCount,venue:s.venue,year:s.date})),O=J(f),k=Date.now()-i;x({answer:v(O,n),sources:d,query:t,url:D(t),papers:f,_envelope:m({...o,durationMs:k})})}catch(l){P(l,m({...o,durationMs:Date.now()-i}))}}q();
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import{spawn as
|
|
2
|
-
|
|
3
|
-
`),X.join(`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`).trim()}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
`);if($.length>0)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
[
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
`)
|
|
18
|
-
`).
|
|
19
|
-
`);return
|
|
20
|
-
|
|
1
|
+
import{spawn as fJ}from"node:child_process";import{basename as UJ}from"node:path";function L(J=process.env,$=process.execPath){let K=J.GREEDY_SEARCH_NODE||J.NODE_BINARY||J.NODE;if(K?.trim())return K.trim();let Q=UJ($||"").toLowerCase();if(Q==="node"||Q==="node.exe")return $;return"node"}import{existsSync as yJ,mkdirSync as hJ,readFileSync as gJ,writeFileSync as pJ}from"node:fs";import{homedir as uJ}from"node:os";import{dirname as mJ,join as l}from"node:path";import{fileURLToPath as dJ}from"node:url";import{Type as k}from"@sinclair/typebox";function F(J){return{bing:"Bing Copilot",google:"Google AI",gemini:"Gemini",copilot:"Copilot",perplexity:"Perplexity"}[J]??J.charAt(0).toUpperCase()+J.slice(1)}function t(J){if(!J)return"";if(J==="official-docs")return"official docs";return J.replace(/-/g," ")}function a(J){if(!J)return"Mixed";return J.charAt(0).toUpperCase()+J.slice(1)}function r(J){return String(J.displayUrl||J.canonicalUrl||J.url||"")}function jJ(J){return String(J.title||J.domain||r(J)||"Untitled source")}function AJ(J){if(typeof J.engineCount==="number")return J.engineCount;return(Array.isArray(J.engines)?J.engines:[]).length}function wJ(J){return new Map(J.map(($)=>[String($.id||""),$]).filter(([$])=>$))}function n(J){let $=String(J.id||"?"),K=r(J),Q=jJ(J),X=String(J.domain||""),V=Array.isArray(J.engines)?J.engines:[],B=AJ(J),q=t(String(J.sourceType||"")),H=J.fetch,Z=H?.ok?`fetched ${H.status||200}`:H?.attempted?"fetch failed":"";return`- ${[`${$} - [${Q}](${K})`,X,q,V.length?`cited by ${V.map(F).join(", ")} (${B}/3)`:`${B}/3`,Z].filter(Boolean).join(" - ")}`}function s(J,$=[],K=6){if(!J.length)return[];let Q=wJ(J),X=$.map((V)=>Q.get(V)).filter((V)=>Boolean(V));if(X.length>0)return X.slice(0,K);return J.slice(0,K)}function e(J,$,K,Q=6){if($.answer)J.push("## Answer"),J.push(String($.answer)),J.push("");let X=$.agreement,V=String(X?.summary||"").trim(),B=String(X?.level||"").trim();if(V||B)J.push("## Consensus"),J.push(`- ${a(B)}${V?` - ${V}`:""}`),J.push("");let q=Array.isArray($.differences)?$.differences:[];if(q.length>0){J.push("## Where Engines Differ");for(let W of q)J.push(`- ${W}`);J.push("")}let H=Array.isArray($.caveats)?$.caveats:[];if(H.length>0){J.push("## Caveats");for(let W of H)J.push(`- ${W}`);J.push("")}let Z=Array.isArray($.claims)?$.claims:[];if(Z.length>0){J.push("## Key Claims");for(let W of Z){let b=Array.isArray(W.sourceIds)?W.sourceIds:[],U=String(W.support||"moderate");J.push(`- ${String(W.claim||"")} [${U}${b.length?`; ${b.join(", ")}`:""}]`)}J.push("")}let Y=Array.isArray($.recommendedSources)?$.recommendedSources:[],z=s(K,Y,Q);if(z.length>0){J.push("## Top Sources");for(let W of z)J.push(n(W));J.push("")}}var JJ=800;function $J(J){return J.split(`
|
|
2
|
+
`).map(($)=>$.length>JJ?$.slice(0,JJ-1)+"…":$).join(`
|
|
3
|
+
`)}function KJ(J,$){let K=[];if(J==="all")return $J(OJ($,K));return $J(GJ($,K))}function OJ(J,$){let{_synthesis:K,_sources:Q,_needsHumanVerification:X,_research:V}=J;if(X){let B=Array.isArray(X.engines)?X.engines.join(", "):"one or more engines";$.push("## Manual verification required"),$.push(String(X.message||"Visible Chrome is open. Solve the verification challenge, then rerun the same search.")),$.push(`Engines: ${B}`),$.push("")}if(K?.answer){if(V?.mode==="iterative")MJ($,V);e($,K,Q||[],6);let B=String(K.synthesizedBy||"configured synthesizer");return $.push(V?.mode==="iterative"?`*Research mode: iterative planning, source fetching, citation audit, and bundle output*
|
|
4
|
+
`:`*Synthesized by ${B} from multi-engine results and fetched sources*
|
|
5
|
+
`),$.join(`
|
|
6
|
+
`).trim()}for(let[B,q]of Object.entries(J)){if(B.startsWith("_"))continue;$.push(`
|
|
7
|
+
## ${F(B)}`),QJ(q,$,3)}return $.join(`
|
|
8
|
+
`).trim()}function MJ(J,$){let K=$.floor,Q=K?.metrics,X=$.bundle,V=$.manifest;if(J.push("## Research Run"),J.push(`- Status: ${K?.floorMet?"floor met":"partial / floor unmet"}`),V?.terminationReason)J.push(`- Stop reason: ${String(V.terminationReason)}`);if(Q)J.push(`- Evidence: ${Q.fetchedOk||0} fetched sources, ${Q.primarySources||0} primary/official, ${Q.claims||0} claims, ${Q.cited||0} citations`),J.push(`- Questions: ${Q.closedQuestions||0}/${Q.totalQuestions||0} closed${Q.openQuestions?`, ${Q.openQuestions} open`:""}`);if(X?.dir)J.push(`- Bundle: ${String(X.dir)}`);J.push("")}function GJ(J,$){let K=J._needsHumanVerification;if(K){let Q=Array.isArray(K.engines)?K.engines.join(", "):"this engine";$.push("## Manual verification required"),$.push(String(K.message||"Visible Chrome is open. Solve the verification challenge, then rerun the same search.")),$.push(`Engines: ${Q}`),$.push("")}return QJ(J,$,5),$.join(`
|
|
9
|
+
`).trim()}function QJ(J,$,K){if(J.error){$.push(`Error: ${J.error}`);return}if(J.answer)$.push(String(J.answer));let Q=J.sources;if(Array.isArray(Q)&&Q.length>0){$.push(`
|
|
10
|
+
Sources:`);for(let X of Q.slice(0,K))$.push(`- [${X.title||X.url}](${X.url})`)}}import{spawn as SJ}from"node:child_process";import{existsSync as xJ}from"node:fs";import{join as IJ}from"node:path";import{existsSync as R,mkdirSync as CJ,readFileSync as XJ,writeFileSync as NJ}from"node:fs";import{homedir as vJ}from"node:os";import{join as WJ}from"node:path";import{tmpdir as DJ}from"node:os";function PJ(J,$=9222){let K=Number.parseInt(String(J??""),10);return Number.isInteger(K)&&K>1024&&K<65535?K:$}var LJ=DJ().replaceAll("\\","/"),W0=PJ(process.env.GREEDY_SEARCH_PORT),O=(process.env.GREEDY_SEARCH_PROFILE_DIR||process.env.CDP_PROFILE_DIR||`${LJ}/greedysearch-chrome-profile`).replaceAll("\\","/"),Z0=`${O}/DevToolsActivePort`,B0=process.env.GREEDY_SEARCH_PID_FILE||`${O}/browser.pid`,q0=process.env.CDP_PAGES_CACHE||`${O}/cdp-pages.json`,z0=process.env.GREEDY_SEARCH_MODE_FILE||`${O}/browser-mode`,k0=process.env.GREEDY_SEARCH_METADATA_FILE||`${O}/browser-metadata.json`,H0=process.env.GREEDY_SEARCH_LAUNCH_LOCK_FILE||`${O}/browser-launch.lock`,Y0=process.env.GREEDY_SEARCH_ACTIVITY_FILE||`${O}/browser-last-activity`,b0=(process.env.CDP_SOCKET_DIR||`${O}/cdp-sockets`).replaceAll("\\","/"),U0=`${O}/visible-recovery.jsonl`,E=WJ(vJ(),".dm"),G=WJ(E,"greedyconfig"),f=["perplexity","google","chatgpt","gemini"],y="gemini";function FJ(){try{if(R(G)){let J=XJ(G,"utf8"),$=JSON.parse(J);if(Array.isArray($.engines)&&$.engines.length>0&&$.engines.every((K)=>typeof K==="string")){let K=$.engines.filter((X)=>T[X]),Q=$.engines.filter((X)=>!T[X]);if(Q.length>0)process.stderr.write(`[greedysearch] Warning: ignoring unknown engine(s) in ${G}: ${Q.join(", ")}
|
|
11
|
+
[greedysearch] Available engines: ${Object.keys(T).join(", ")}
|
|
12
|
+
`);if(K.length>0)return K;process.stderr.write(`[greedysearch] Warning: no valid engines in ${G}, falling back to defaults: ${f.join(", ")}
|
|
13
|
+
`)}}}catch{}return f}function RJ(){try{if(!R(E))CJ(E,{recursive:!0});if(!R(G))NJ(G,JSON.stringify({engines:f,synthesizer:y},null,2)+`
|
|
14
|
+
`,"utf8")}catch{}}RJ();var VJ=["gemini","chatgpt"];function _J(){try{if(R(G)){let J=XJ(G,"utf8"),$=JSON.parse(J);if(typeof $.synthesizer==="string"){let K=$.synthesizer.toLowerCase();if(VJ.includes(K))return K;process.stderr.write(`[greedysearch] Warning: unknown synthesizer "${$.synthesizer}" in ${G}
|
|
15
|
+
[greedysearch] Available synthesizers: ${VJ.join(", ")}
|
|
16
|
+
[greedysearch] Falling back to default: ${y}
|
|
17
|
+
`)}}}catch{}return y}var T={perplexity:"perplexity.mjs",p:"perplexity.mjs",bing:"bing-copilot.mjs",b:"bing-copilot.mjs",google:"google-ai.mjs",g:"google-ai.mjs",gemini:"gemini.mjs",gem:"gemini.mjs",chatgpt:"chatgpt.mjs",gpt:"chatgpt.mjs","semantic-scholar":"semantic-scholar.mjs",semanticscholar:"semantic-scholar.mjs",s2:"semantic-scholar.mjs",logically:"logically.mjs",log:"logically.mjs"},h=FJ();var j0=_J(),A0=Math.max(1,Number.parseInt(process.env.GREEDY_FETCH_CONCURRENCY||"5",10)||5);process.env.CDP_PROFILE_DIR=O;function g(J){return J.replace(/^"|"$/g,"")}function _(J){return xJ(IJ(J,"bin","cdp.mjs"))}function ZJ(){return{content:[{type:"text",text:"cdp.mjs missing — try reinstalling: pi install git:github.com/apmantza/greedysearch-dm"}],details:{}}}function BJ(J,$){let K=$ instanceof Error?$.message:String($);return{content:[{type:"text",text:`${J}: ${K}`}],details:{}}}function qJ(J,$,K,Q,X,V,B={}){return new Promise((q,H)=>{let{headless:Z=!0}=B,Y=[...K];if(Z!==!1&&process.env.GREEDY_SEARCH_VISIBLE!=="1")Y.push("--headless");if(Z===!1)Y.push("--always-visible");let z={...process.env};if(Z===!1)z.GREEDY_SEARCH_VISIBLE="1",z.GREEDY_SEARCH_ALWAYS_VISIBLE="1";let W=SJ(L(),[Q,J,"--inline","--stdin",...Y],{stdio:["pipe","pipe","pipe"],env:z});W.stdin.write($),W.stdin.end();let b="",U="",w=51200,A=!1,j=900000,S=parseInt(process.env.GREEDY_SEARCH_TIMEOUT_MS||"",10),D=Number.isNaN(S)?j:S,C=setTimeout(()=>{if(A)return;if(A=!0,X?.removeEventListener("abort",P),process.platform==="win32")W.kill();else W.kill("SIGTERM");H(Error(`greedy-search child timed out after ${D}ms (watchdog)`))},D);C.unref();let P=()=>{if(A)return;A=!0,clearTimeout(C),W.kill("SIGTERM"),H(Error("Aborted"))};X?.addEventListener("abort",P,{once:!0}),W.stderr.on("data",(N)=>{if(U+=N,U.length>w)U=U.slice(-w);let bJ=/^PROGRESS:(perplexity|google|chatgpt|bing|gemini|semantic-scholar|semanticscholar|s2|logically):(done|error|needs-human)$/;for(let v of N.toString().split(`
|
|
18
|
+
`)){let x=v.match(bJ);if(x&&V)V({type:"engine",engine:x[1],status:x[2]});let c=v.match(/^PROGRESS:synthesis:(done|error|skipped)$/);if(c&&V)V({type:"engine",engine:"synthesis",status:c[1]});let o=v.match(/^PROGRESS:research:(.+)$/);if(o&&V)V({type:"text",text:o[1]});let i=v.match(/^\[greedysearch\] (\[.+?\] .+)$/);if(i&&V)V({type:"text",text:i[1]});let I=v.match(/^\[(perplexity|google|chatgpt|bing|gemini|semantic-scholar|logically)\] stage: (.+) \(\+\d+ms\)$/);if(I&&V)V({type:"text",text:`${I[1]}: ${I[2]}`})}}),W.stdout.on("data",(N)=>b+=N),W.on("close",(N)=>{if(A)return;if(A=!0,clearTimeout(C),X?.removeEventListener("abort",P),N!==0)H(Error(U.trim()||`search.mjs exited with code ${N}`));else{if(V&&J!=="all")V({type:"engine",engine:J,status:"done"});try{q(JSON.parse(b.trim()))}catch{H(Error(`Invalid JSON from search.mjs: ${b.slice(0,200)}`))}}})})}function TJ(J,$){if($<=0)return"";let K=16,Q=Math.round(J/$*K);return"["+"█".repeat(Math.min(Q,K))+"░".repeat(Math.max(0,K-Q))+"]"}function EJ(J){if(J<1000)return"—";let $=Math.round(J/1000);if($<60)return`${$}s`;return`${Math.floor($/60)}m ${$%60}s`}function zJ(J,$,K,Q,X){let V=Date.now(),B=new Map,q="";function H(){let Z=[];Z.push(`**${K}...** ${X||""}`.trim());let Y=B.size;if(J.length>1&&Y>0&&!q){let W=Date.now()-V,b=Math.min(1,Y/J.length),U=b>0.01?Math.round(W/b-W):null,w=TJ(Y,J.length),A=U!=null&&U>0?EJ(U):"—";Z.push(`${w} ${Y}/${J.length} engines (ETA ${A})`)}if(q)Z.push(q);let z=[];for(let W of J){let b=B.get(W);if(b==="done")z.push(`✅ ${W} done`);else if(b==="error")z.push(`❌ ${W} failed`);else if(b==="needs-human")z.push(`\uD83D\uDD13 ${W} needs manual verification`);else z.push(`⏳ ${W}`)}if(Q&&Y>=J.length){let W=B.get("synthesis");if(W==="done")z.push("✅ synthesized");else if(W==="error")z.push("❌ synthesis failed");else if(W==="needs-human")z.push("⏭️ synthesis skipped");else z.push("\uD83D\uDD04 synthesizing")}if(z.length>0){let W=z.join(" · ");Z.push(W.length>90?W.slice(0,88)+"…":W)}$?.({content:[{type:"text",text:Z.join(`
|
|
19
|
+
`)}],details:{_progress:!0}})}return(Z)=>{if(Z.type==="text"){if(Z.text.startsWith("["))q=Z.text;H();return}let{engine:Y,status:z}=Z;B.set(Y,z),H()}}class M{text;paddingX;paddingY;constructor(J,$=0,K=0){this.text=J;this.paddingX=$;this.paddingY=K}render(J){let $=" ".repeat(this.paddingX),K="",Q=Math.max(1,J-this.paddingX*2),X=this.text.split(`
|
|
20
|
+
`).flatMap((V)=>{if(V.length<=Q)return[`${$}${V}`];let B=[];for(let q=0;q<V.length;q+=Q)B.push(`${$}${V.slice(q,q+Q)}`);return B});return[...Array.from({length:this.paddingY},()=>""),...X,...Array.from({length:this.paddingY},()=>"")]}invalidate(){}}function kJ(J,$){J.registerTool({name:"greedy_search",label:"Greedy Search",description:"WEB/RESEARCH SEARCH ONLY — searches live web via Perplexity, Google AI, ChatGPT, and Gemini, plus opt-in research through Semantic Scholar and Logically. "+"Research mode reuses the configured ~/.dm/greedyconfig engines for child searches and Gemini for planning/final synthesis. Research mode is the centerpiece: it plans follow-up actions, fetches sources, audits citations, and writes a structured research bundle on disk. Scale-aware: simple queries auto-classify and use a fast single-pass path. Use for: library docs, recent framework changes, error messages, best practices, current events. Reports streaming progress as each engine completes.",promptSnippet:"Multi-engine AI web search with streaming progress",parameters:k.Object({query:k.String({description:"The search query"}),engine:k.String({description:'Engine to use: "all" (default), "perplexity", "google", "chatgpt", "gemini", "gem". Research engines: "semantic-scholar" (alias "s2") and "logically". "all" fans out to the configured engines and fetches top sources. Customize via ~/.dm/greedyconfig. Bing Copilot is still available as "bing" for signed-in users.',default:"all"}),synthesize:k.Optional(k.Boolean({description:'Only for engine="all": synthesize the multi-engine results and fetched sources. Default: false.',default:!1})),synthesizer:k.Optional(k.String({description:'Synthesis engine for synthesize=true. Defaults to ~/.dm/greedyconfig synthesizer (currently "gemini" by default). Supported: "gemini", "chatgpt".'})),depth:k.Optional(k.String({description:'Deprecated except "research". Use depth="research" for the iterative research workflow. Research child searches use ~/.dm/greedyconfig engines; Gemini handles research planning/final synthesis. Legacy values: "fast" skips source fetching; "standard"/"deep" alias synthesize=true.'})),breadth:k.Optional(k.Number({description:'Only for depth="research": number of parallel research directions per round, 1-5 (default: 3).',default:3})),iterations:k.Optional(k.Number({description:'Only for depth="research": number of iterative research rounds, 1-3 (default: 2).',default:2})),maxSources:k.Optional(k.Number({description:'Only for depth="research": maximum fetched sources for the final report, 3-12.'})),researchOutDir:k.Optional(k.String({description:'Only for depth="research": optional directory for the structured research bundle. Defaults to .dm/greedysearch-research/<timestamp>_<query>.'})),writeResearchBundle:k.Optional(k.Boolean({description:'Only for depth="research": write the structured research bundle to disk (default true).',default:!0})),fullAnswer:k.Optional(k.Boolean({description:"When true, returns the complete answer instead of a truncated preview (default: false, answers are shortened to ~300 chars to save tokens).",default:!1})),headless:k.Optional(k.Boolean({description:"Set to false to show Chrome window (headless is the default). Set GREEDY_SEARCH_VISIBLE=1 to disable headless globally.",default:!0})),visible:k.Optional(k.Boolean({description:"Set to true to always use visible Chrome for this search. Alias for headless: false.",default:!1})),alwaysVisible:k.Optional(k.Boolean({description:"Set to true to keep GreedySearch in visible Chrome mode for this search. Alias for visible: true.",default:!1}))}),execute:async(K,Q,X,V)=>{let{query:B,fullAnswer:q}=Q,H=g(Q.engine??"all")||"all",Z=g(Q.depth??""),Y=Z==="research",z=Z==="fast",W=Z==="standard"||Z==="deep",b=H==="all"&&!z&&(Q.synthesize===!0||W),U=Y?"all":H,A=!(Q.visible===!0||Q.alwaysVisible===!0||Q.headless===!1||process.env.GREEDY_SEARCH_VISIBLE==="1"||process.env.GREEDY_SEARCH_ALWAYS_VISIBLE==="1");if(!_($))return ZJ();let j=[];if(q??U!=="all")j.push("--full");if(Y){if(j.push("--depth","research"),typeof Q.breadth==="number")j.push("--breadth",String(Q.breadth));if(typeof Q.iterations==="number")j.push("--iterations",String(Q.iterations));if(typeof Q.maxSources==="number")j.push("--max-sources",String(Q.maxSources));if(typeof Q.researchOutDir==="string")j.push("--research-out-dir",Q.researchOutDir);if(Q.writeResearchBundle===!1)j.push("--no-research-bundle")}else if(z)j.push("--fast");else if(Z==="deep")j.push("--depth","deep");else if(b)j.push("--synthesize");if(b&&typeof Q.synthesizer==="string")j.push("--synthesizer",Q.synthesizer);let D=zJ(U==="all"?h:[U],V,Y?"Researching":"Searching",b&&U==="all",B);try{let C=await qJ(U,B,j,`${$}/bin/search.mjs`,X,D,{headless:A});return{content:[{type:"text",text:KJ(U,C)||"No results returned."}],details:{raw:C}}}catch(C){return BJ("Search failed",C)}},renderCall(K,Q){let X=(K.query||"").slice(0,60),V=X.length<(K.query||"").length?`${X}...`:X,B=K.engine&&K.engine!=="all"?Q.fg("dim",` (${K.engine})`):"";return new M(`${Q.fg("toolTitle",Q.bold("greedy_search"))} "${Q.fg("accent",V)}"${B}`,0,0)},renderResult(K,{expanded:Q,isPartial:X},V){if(X){let Z=K.content.find((z)=>z.type==="text")?.text,Y=Z?Z.replace(/\*\*/g,""):"Searching...";return new M(V.fg("warning",Y),0,0)}let B=K.content.find((Z)=>Z.type==="text"),q=K.details?.raw;if(!Q){if(q?._needsHumanVerification)return new M(V.fg("warning"," → Manual verification required"),0,0);let Y=q?._synthesis,z=q?._sources;if(Y){let w=Array.isArray(z)?z.length:0,A=Y.agreement?.level,j=" → Synthesized";if(w>0)j+=` · ${w} source${w>1?"s":""}`;if(A)j+=` · ${A}`;return new M(V.fg("muted",j),0,0)}let W=Object.keys(q||{}).filter((w)=>!w.startsWith("_")),b=0;for(let w of W){let j=q?.[w]?.sources;if(Array.isArray(j))b+=j.length}if(b>0)return new M(V.fg("muted",` → ${b} source${b>1?"s":""}`),0,0);let U=B?.text;if(U)return new M(V.fg("warning",` → ${U.slice(0,80)}`),0,0);return new M(V.fg("muted"," → Done"),0,0)}if(!B||B.type!=="text")return new M("",0,0);let H=B.text.split(`
|
|
21
|
+
`).map((Z)=>V.fg("toolOutput",Z)).join(`
|
|
22
|
+
`);return new M(`
|
|
23
|
+
${H}`,0,0)}})}var m=mJ(dJ(import.meta.url));function lJ(J){J.on("session_start",async($,K)=>{if(!_(m))K.ui.notify("GreedySearch: cdp.mjs missing from package directory — try reinstalling: pi install git:github.com/apmantza/greedysearch-dm","warning")}),kJ(J,m),J.registerCommand("greedy-visible",{description:"Launch GreedySearch Chrome in visible mode for captcha/login/cookie setup.",handler:async($,K)=>{await p([],K,"Visible GreedySearch Chrome launched.")}}),J.registerCommand("greedy-status",{description:"Show GreedySearch Chrome status.",handler:async($,K)=>{await p(["--status"],K)}}),J.registerCommand("greedy-kill",{description:"Stop GreedySearch Chrome.",handler:async($,K)=>{await p(["--kill"],K,"GreedySearch Chrome stopped.")}}),J.registerCommand("set-greedy-locale",{description:"Set default locale for GreedySearch results (e.g., /set-greedy-locale de, /set-greedy-locale --clear, /set-greedy-locale --show)",handler:async($,K)=>{let Q=$.trim()||"--show";if(Q==="--show"){let q=u();if(q.locale)K.ui.notify(`Default locale: ${q.locale}`,"info");else K.ui.notify("No default locale (uses: en)","info");return}if(Q==="--clear"){let q=u();delete q.locale,HJ(q),K.ui.notify("Default locale cleared (now uses: en).","info");return}let X=Q.toLowerCase(),V=["en","de","fr","es","it","pt","nl","pl","ru","ja","ko","zh","ar","hi","tr","sv","da","no","fi","cs","hu","ro","el"];if(!V.includes(X)){K.ui.notify(`Invalid locale "${X}". Valid: ${V.join(", ")}`,"error");return}let B=u();B.locale=X,HJ(B),K.ui.notify(`Default locale set to: ${X}`,"info")}})}var YJ=l(uJ(),".config","greedysearch"),d=l(YJ,"config.json");async function p(J,$,K){let Q=l(m,"bin","visible.mjs"),{code:X,output:V}=await new Promise((B)=>{let q=fJ(L(),[Q,...J],{stdio:["ignore","pipe","pipe"],env:{...process.env,GREEDY_SEARCH_VISIBLE:"1"}}),H="";q.stdout.on("data",(Z)=>H+=Z.toString()),q.stderr.on("data",(Z)=>H+=Z.toString()),q.on("close",(Z)=>B({code:Z,output:H}))});if(X===0)$.ui.notify((K||V.trim()||"Done.").trim(),"info");else $.ui.notify(V.trim()||`GreedySearch Chrome command failed (${X})`,"error")}function u(){try{if(yJ(d))return JSON.parse(gJ(d,"utf8"))}catch{}return{}}function HJ(J){hJ(YJ,{recursive:!0}),pJ(d,JSON.stringify(J,null,2),"utf8")}export{lJ as default};
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greedysearch-dm",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "DM extension
|
|
3
|
+
"version": "2.1.6",
|
|
4
|
+
"description": "DM extension for headless multi-engine browser search, grounded source fetching, synthesis, and research",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"duckmind",
|
|
8
8
|
"dm",
|
|
9
|
+
"greedysearch",
|
|
9
10
|
"web-search",
|
|
10
|
-
"browser-automation"
|
|
11
|
+
"browser-automation",
|
|
12
|
+
"headless"
|
|
11
13
|
],
|
|
12
14
|
"author": "Apostolos Mantzaris",
|
|
13
15
|
"license": "MIT",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=20.11.0"
|
|
18
|
+
},
|
|
14
19
|
"dm": {
|
|
15
20
|
"extensions": [
|
|
16
21
|
"./index.js"
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: greedy-search
|
|
3
|
-
description:
|
|
3
|
+
description: Headless-first web and research search through DM using Perplexity, Google AI, ChatGPT, Gemini, Semantic Scholar, Logically, and signed-in Bing Copilot. Grounded all-engine search fetches sources by default; synthesis and deep research are opt-in. Engine and synthesizer settings use ~/.dm/greedyconfig. Not for local codebase search.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
`greedy_search({ query, engine
|
|
6
|
+
`greedy_search({ query, engine?: "all"|"perplexity"|"google"|"chatgpt"|"gemini"|"semantic-scholar"|"logically"|"bing", synthesize?: bool, synthesizer?: "gemini"|"chatgpt", depth?: "research", breadth?: 1-5, iterations?: 1-3, maxSources?: 3-12, researchOutDir?: string, writeResearchBundle?: bool, fullAnswer?: bool, headless?: bool, visible?: bool, alwaysVisible?: bool })`
|
|
7
7
|
|
|
8
|
-
**
|
|
8
|
+
**Browser mode:** Headless is the default. Set `headless:false`, `visible:true`, or `alwaysVisible:true` only when a visible browser is required. `GREEDY_SEARCH_VISIBLE=1` is the explicit global visible-mode override.
|
|
9
9
|
|
|
10
|
-
**
|
|
10
|
+
**Search modes:** Use one engine for a direct search. Use `engine:"all"` for configured multi-engine fan-out with fetched sources. Add `synthesize:true` for a combined answer. Use `depth:"research"` for iterative planning, source fetching, citation checks, and a structured research report.
|
|
11
11
|
|
|
12
|
-
**
|
|
12
|
+
**Configuration:** `~/.dm/greedyconfig` controls the `engine:"all"` list and default synthesizer, for example `{ "engines": ["perplexity", "google", "chatgpt", "gemini"], "synthesizer": "gemini" }`.
|
|
13
13
|
|
|
14
|
-
**Research output:** `depth:"research"` writes a
|
|
14
|
+
**Research output:** `depth:"research"` writes a structured bundle under `.dm/greedysearch-research/<timestamp>_<query>/` by default. Set `researchOutDir` to choose another directory or `writeResearchBundle:false` to disable disk output.
|
|
15
15
|
|
|
16
|
-
**
|
|
16
|
+
**Compatibility:** Legacy `depth:"fast"|"standard"|"deep"` remains accepted by the imported runtime. Prefer `synthesize:true` and `depth:"research"` in new calls.
|
|
17
17
|
|
|
18
|
-
**CDP safety:** Use `bin/cdp-greedy.mjs`
|
|
18
|
+
**CDP safety:** Use the bundled `bin/cdp-greedy.mjs` lane. Browser state is scoped through the DM-provided port, profile, PID, and mode environment variables. The launcher refuses to kill a listener unless its command line matches both the expected profile and debugging port.
|