@duckmind/dm-darwin-x64 0.43.2 → 0.43.4
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 +4 -3
- package/extensions/greedysearch-dm/bin/search.mjs +135 -135
- package/extensions/greedysearch-dm/src/search/engines.mjs +9 -9
- package/extensions/greedysearch-dm/src/search/paths.mjs +1 -0
- package/extensions/greedysearch-dm/src/search/research.mjs +100 -100
- package/extensions/greedysearch-dm/src/search/synthesis-runner.mjs +10 -10
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{spawn as
|
|
2
|
-
[greedysearch] Available engines: ${Object.keys(
|
|
3
|
-
`);if(
|
|
4
|
-
`)}}}catch{}return
|
|
5
|
-
`,"utf8")}catch{}}
|
|
6
|
-
[greedysearch] Available synthesizers: ${
|
|
7
|
-
[greedysearch] Falling back to default: ${
|
|
8
|
-
`)}}}catch{}return
|
|
9
|
-
`),
|
|
1
|
+
import{spawn as v}from"node:child_process";import{basename as U}from"node:path";function G(g=process.env,l=process.execPath){let E=g.GREEDY_SEARCH_NODE||g.NODE_BINARY||g.NODE;if(E?.trim())return E.trim();let s=U(l||"").toLowerCase();if(s==="node"||s==="node.exe")return l;return"node"}import{existsSync as i,mkdirSync as n,readFileSync as k,writeFileSync as B}from"node:fs";import{homedir as K}from"node:os";import{join as j}from"node:path";import{tmpdir as I}from"node:os";var T=`${I().replaceAll("\\","/")}/greedysearch-chrome-profile`,d=`${T}/DevToolsActivePort`,gg=`${I().replaceAll("\\","/")}/cdp-pages.json`,lg=`${I().replaceAll("\\","/")}/greedysearch-chrome-mode`,Eg=`${I().replaceAll("\\","/")}/greedysearch-visible-recovery.jsonl`,c=j(K(),".dm"),m=j(c,"greedyconfig"),z=["perplexity","google","chatgpt"],o="gemini";function X(){try{if(i(m)){let g=k(m,"utf8"),l=JSON.parse(g);if(Array.isArray(l.engines)&&l.engines.length>0&&l.engines.every((E)=>typeof E==="string")){let E=l.engines.filter((a)=>$[a]),s=l.engines.filter((a)=>!$[a]);if(s.length>0)process.stderr.write(`[greedysearch] Warning: ignoring unknown engine(s) in ${m}: ${s.join(", ")}
|
|
2
|
+
[greedysearch] Available engines: ${Object.keys($).join(", ")}
|
|
3
|
+
`);if(E.length>0)return E;process.stderr.write(`[greedysearch] Warning: no valid engines in ${m}, falling back to defaults: ${z.join(", ")}
|
|
4
|
+
`)}}}catch{}return z}function Q(){try{if(!i(c))n(c,{recursive:!0});if(!i(m))B(m,JSON.stringify({engines:z,synthesizer:o},null,2)+`
|
|
5
|
+
`,"utf8")}catch{}}Q();var L=["gemini","chatgpt"];function b(){try{if(i(m)){let g=k(m,"utf8"),l=JSON.parse(g);if(typeof l.synthesizer==="string"){let E=l.synthesizer.toLowerCase();if(L.includes(E))return E;process.stderr.write(`[greedysearch] Warning: unknown synthesizer "${l.synthesizer}" in ${m}
|
|
6
|
+
[greedysearch] Available synthesizers: ${L.join(", ")}
|
|
7
|
+
[greedysearch] Falling back to default: ${o}
|
|
8
|
+
`)}}}catch{}return o}var $={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"},sg=X();var ag=b(),yg=Math.max(1,Number.parseInt(process.env.GREEDY_FETCH_CONCURRENCY||"5",10)||5);process.env.CDP_PROFILE_DIR=T;import{existsSync as w}from"node:fs";import{dirname as r,join as F}from"node:path";import{fileURLToPath as P}from"node:url";function V(g){return P(new URL(".",g)).replace(/^\/([A-Z]:)/,"$1")}function q(g,l=w){let E=new Set;for(let s of g.filter(Boolean)){if(E.has(s))continue;if(E.add(s),l(s))return s}return g.filter(Boolean).at(-1)}function W(g,{moduleDir:l,entrypoint:E=process.argv[1],env:s=process.env,exists:a=w}={}){let A=E?r(E):null,C=s.GREEDY_SEARCH_EXTENSION_DIR?.trim()||null,O=[l?F(l,"..","..","extractors",g):null,l?F(l,"..","extractors",g):null,C?F(C,"extractors",g):null,A?F(A,"..","extractors",g):null];return q(O,a)}var D=V(import.meta.url);function $g(g,l,E=null,s=!1,a=null,A=null){if(a===null)a=g.includes("logically")?120000:g.includes("chatgpt")?80000:g.includes("gemini")?70000:60000;let C=[...E?["--tab",E]:[],...s?["--short"]:[],...A?["--locale",A]:[]],O=W(g,{moduleDir:D});return new Promise((Z,H)=>{let _=v(G(),[O,"--stdin",...C],{stdio:["pipe","pipe","pipe"],env:{...process.env,CDP_PROFILE_DIR:T}});_.stdin.write(l),_.stdin.end();let R="",Y="";_.stdout.on("data",(y)=>R+=y),_.stderr.on("data",(y)=>{if(Y+=y,process.env.GREEDY_SEARCH_CHILD_STDERR!=="0")process.stderr.write(y)});let J=setTimeout(()=>{_.kill();let y=(N,S=20)=>String(N??"").split(/\r?\n/).filter(Boolean).slice(-S).join(`
|
|
9
|
+
`),h=null;try{let N=JSON.parse(R.trim());if(N._envelope)h=N._envelope}catch{}let f=Error(`${g} timed out after ${a/1000}s`+(h?.lastStage?` (last stage: ${h.lastStage})`:""));f.engineScript=g,f.lastStage=h?.lastStage||null,f.partialErr=y(Y),f.partialOut=y(R),H(f)},a);_.on("close",(y)=>{if(clearTimeout(J),y===0)try{Z(JSON.parse(R.trim()))}catch{H(Error(`bad JSON from ${g}: ${R.slice(0,100)}`))}else{let h=null;try{let S=JSON.parse(R.trim());if(S._envelope)h=S._envelope}catch{}let f=Y.trim()||`extractor exit ${y}`,N=Error(f);if(h)N.envelope=h;H(N)}})})}export{$g as runExtractor,$ as ENGINES};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as H}from"node:fs";import{dirname as K,join as C}from"node:path";import{fileURLToPath as M}from"node:url";function W(k){return M(new URL(".",k)).replace(/^\/([A-Z]:)/,"$1")}function N(k,w=H){let A=new Set;for(let z of k.filter(Boolean)){if(A.has(z))continue;if(A.add(z),w(z))return z}return k.filter(Boolean).at(-1)}function X(k,{moduleDir:w,entrypoint:A=process.argv[1],env:z=process.env,exists:I=H}={}){let F=A?K(A):null,G=z.GREEDY_SEARCH_EXTENSION_DIR?.trim()||null,J=[w?C(w,"..","..","extractors",k):null,w?C(w,"..","extractors",k):null,G?C(G,"extractors",k):null,F?C(F,"..","extractors",k):null];return N(J,I)}export{X as resolveGreedySearchExtractorScript,W as moduleDirectory};
|