fluxflow-cli 4.42.2 → 4.44.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.
- package/README.md +2 -1
- package/chrome-healthcheck.mjs +119 -0
- package/dist/chunks/{ai-GMCDSKAC.js → ai-3J4SUC3U.js} +1 -1
- package/dist/chunks/app-JSYMH7WB.js +332 -0
- package/dist/chunks/{auto_completion-EJXGALEE.js → auto_completion-FSSLSASK.js} +1 -1
- package/dist/chunks/{chunk-3XOMPSDB.js → chunk-2SMAZY6E.js} +1 -1
- package/dist/chunks/{chunk-CTKW7YYV.js → chunk-3HU67EUI.js} +1 -2
- package/dist/chunks/chunk-BB5UISPJ.js +1 -0
- package/dist/chunks/chunk-H3IDSRDO.js +1 -0
- package/dist/chunks/chunk-JDSDLNHL.js +1 -0
- package/dist/chunks/chunk-NN5WVXEF.js +938 -0
- package/dist/chunks/{chunk-ZYLACK6T.js → chunk-SML2NARF.js} +24 -22
- package/dist/chunks/{chunk-CTNSVXOH.js → chunk-TXMOUQPV.js} +1 -1
- package/dist/chunks/{chunk-XDCDANJJ.js → chunk-UFLKOWYM.js} +1 -1
- package/dist/chunks/chunk-VHCXFHUU.js +5 -0
- package/dist/chunks/{chunk-A73NNVCZ.js → chunk-YX4X2ZTX.js} +1 -1
- package/dist/chunks/{click-5WEIMJHK.js → click-C4LULADR.js} +2 -2
- package/dist/chunks/{computer_action-FVC3EXVR.js → computer_action-HG5P5DOG.js} +1 -1
- package/dist/chunks/{drag-YOWUC5B7.js → drag-CIAOFEBD.js} +1 -1
- package/dist/chunks/{exec_command-7AO6AUGQ.js → exec_command-GXJWBNEI.js} +1 -1
- package/dist/chunks/{generate_image-52GQGN2Q.js → generate_image-RAFSX2PO.js} +1 -1
- package/dist/chunks/getProgress-FXNG2ISE.js +26 -0
- package/dist/chunks/{invoke-RGWQLLU4.js → invoke-K5DKH37G.js} +2 -2
- package/dist/chunks/{invokeSync-4GMOXNSA.js → invokeSync-U5FLY2AB.js} +2 -2
- package/dist/chunks/{key_press-I4KBUAHP.js → key_press-3MUADXYA.js} +1 -1
- package/dist/chunks/{keyboard_typing-TSJ4CP4R.js → keyboard_typing-RDYAUO2I.js} +1 -1
- package/dist/chunks/{mistral-XDIMWAU3.js → mistral-KIAEM23F.js} +1 -1
- package/dist/chunks/{model_config-32SB7PTZ.js → model_config-Q3PYM77Y.js} +1 -1
- package/dist/chunks/{nvidia-PSGYXYNK.js → nvidia-2N7GMNVP.js} +1 -1
- package/dist/chunks/recapture_screen-CGAT4ZDO.js +1 -0
- package/dist/chunks/screen_grid-PAVYL4U2.js +1 -0
- package/dist/chunks/{scroll-OHT6HAHC.js → scroll-V3SVOZW6.js} +1 -1
- package/dist/chunks/{search_keyword-I5QJUL77.js → search_keyword-OHDFK7MO.js} +1 -1
- package/dist/chunks/{secrets-5TCTEPEV.js → secrets-FRPTIOJI.js} +1 -1
- package/dist/chunks/{settings-MGEVTCE4.js → settings-PADKHNGC.js} +1 -1
- package/dist/chunks/{update_file-JXUYSH2G.js → update_file-XM5PHLQU.js} +1 -1
- package/dist/chunks/{usage-MRIV7SXL.js → usage-PVC3CXDR.js} +1 -1
- package/dist/chunks/{usageServer-NH3CL6IF.js → usageServer-SMP52LUG.js} +1 -1
- package/dist/chunks/web_scrape-J3PL2PXT.js +18 -0
- package/dist/chunks/web_search-KBGH67IV.js +40 -0
- package/dist/chunks/{write_file-CIOAYT4P.js → write_file-NTWH4NCN.js} +1 -1
- package/dist/chunks/{write_pdf-26OQPNEP.js → write_pdf-TPGUF4VT.js} +1 -1
- package/dist/chunks/xkiro-B2LYGZTF.js +2 -0
- package/dist/cli.js +5 -5
- package/dist/model_config.json +1 -0
- package/dist/package.json +4 -2
- package/model_config.json +1 -0
- package/package.json +4 -2
- package/dist/chunks/app-OIOM2ZYA.js +0 -332
- package/dist/chunks/chunk-FXRFFNRK.js +0 -1
- package/dist/chunks/chunk-KMOTPBF5.js +0 -1
- package/dist/chunks/chunk-UIFI2JRY.js +0 -5
- package/dist/chunks/chunk-UTOIJOO3.js +0 -931
- package/dist/chunks/chunk-Y73PU7CC.js +0 -1
- package/dist/chunks/getProgress-A2TW34Q7.js +0 -26
- package/dist/chunks/recapture_screen-PPT2E3CK.js +0 -1
- package/dist/chunks/screen_grid-EXWAAOMK.js +0 -1
- package/dist/chunks/web_scrape-MW6YSZ7L.js +0 -16
- package/dist/chunks/web_search-NT3HXUO3.js +0 -36
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as m,f as c}from"./chunk-P5HBJA23.js";import{b as s}from"./chunk-26BQ45XP.js";import r from"fs-extra";import p from"path";var o={mode:"Flux",display:0,thinkingLevel:"Medium",aiProvider:"",activeModel:"",showFullThinking:!0,apiTier:"Free",quotas:{agentLimit:999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerTiers:{Google:"Free",DeepSeek:"Free",NVIDIA:"Free",OpenRouter:"Free",InferX:"Free",SenseNova:"Free",Poolside:"Free",ExpLabs:"Free",TokenHarbor:"Free",Infron:"Free",APInex:"Free",c_openai:"Free"}},systemSettings:{customOpenAIBaseUrl:"",memory:!1,theme:"Dark",compression:0,autoExec:!0,allowExternalAccess:!1,advanceRollback:!1,autoDeleteHistory:"7d",useExternalData:!1,externalDataPath:"",preserveThinking:!0,loadingPhrases:!1,progressiveRendering:!0,showTPMEstimate:!0,subAgents:!1,CustomSubAgent:!1,SubAgentModel:"Default",SubAgentProvider:"",dynamicDirAwareness:!1,indentationTree:!0,ollamaEndpoint:"Cloud",compressToolResults:!1,autoTruncateResults:!0,agentFinishSound:!1,imageHistoryCU:"Standard",contextLength:"256k",keepReasoningContext:!1,autoExcludeMetadata:!1,disableTodo:!1,clipboardContext:!1,cacheCalculateMode:"Session",alwaysAskFiles:".env, .env.*, *.env"},profileData:{preset:"Default",name:null,nickname:null,instructions:null},imageSettings:{keyType:"Default",quality:"Low-High",apiKey:""},autoCompletion:{enabled:!1,model:"Default",provider:"",baseUrl:""}},x={Mistral:"https://api.mistral.ai/v1/chat/completions",DeepSeek:"https://api.deepseek.com/chat/completions",OpenRouter:"https://openrouter.ai/api/v1/chat/completions",NVIDIA:"https://integrate.api.nvidia.com/v1",Ollama:"https://ollama.com/v1",InferX:"https://model.inferx.net/endpoints/v1/chat/completions",SenseNova:"https://token.sensenova.ai/v1/chat/completions",Poolside:"https://inference.poolside.ai/v1/chat/completions",ExpLabs:"https://api.experientiallabs.ai/v1/chat/completions",TokenHarbor:"https://tokenharbor.ai/v1/chat/completions",Infron:"https://llm.onerouter.pro/v1/chat/completions",APInex:"https://api.apinex.bond/v1/chat/completions",AIHubMix:"https://aihubmix.com/v1/chat/completions",Google:"https://generativelanguage.googleapis.com/v1beta/openai/chat/completions"},g=async()=>{let t={...o};try{if(await r.exists(s)){let e=m(s);if(e.imageSettings&&e.imageSettings.apiKey)try{let a=e.imageSettings.apiKey,{saveSecret:i}=await import("./secrets-5TCTEPEV.js");await i("POLLINATIONS_API_KEY",a),e.imageSettings.apiKey="",c(s,e)}catch{}t={...o,...e,quotas:{...o.quotas,...e.quotas,providerTiers:{...o.quotas.providerTiers,...e.quotas?.providerTiers||{}}},systemSettings:{...o.systemSettings,...e.systemSettings},profileData:{...o.profileData,...e.profileData},imageSettings:{...o.imageSettings,...e.imageSettings},autoCompletion:{...o.autoCompletion,...e.autoCompletion}}}}catch(e){console.error("Failed to load settings:",e)}try{let{getSecret:e}=await import("./secrets-5TCTEPEV.js"),a=await e("POLLINATIONS_API_KEY");a&&(t.imageSettings.apiKey=a)}catch{}if(t.showFullThinking===!1){t.showFullThinking=!0;try{c(s,t)}catch{}}return t},d=async t=>{let{FLUXFLOW_DIR:e}=await import("./paths-RQRI2XRY.js"),a=["logs","secret"];for(let i of a){let l=p.join(e,i),n=p.join(t,i);try{await r.exists(l)&&(await r.ensureDir(n),await r.copy(l,n,{overwrite:!0}))}catch(u){console.error(`Migration failed for ${i}:`,u)}}},D=async t=>{try{let e=await g();if(!e.systemSettings.useExternalData&&t.systemSettings?.useExternalData&&t.systemSettings?.externalDataPath&&await d(t.systemSettings.externalDataPath),t.imageSettings&&t.imageSettings.apiKey!==void 0){let{saveSecret:i,removeSecret:l}=await import("./secrets-5TCTEPEV.js"),n=t.imageSettings.apiKey;n?await i("POLLINATIONS_API_KEY",n):await l("POLLINATIONS_API_KEY")}let a={...e,...t};a.systemSettings&&(a.systemSettings.dynamicDirAwareness=!1),a.imageSettings&&(a.imageSettings={...a.imageSettings,apiKey:""}),await r.ensureDir(p.dirname(s)),c(s,a);try{let{invalidateCachedBaseUrl:i}=await import("./usage-MRIV7SXL.js");i()}catch{}return!0}catch(e){return console.error("Failed to save settings:",e),!1}};export{x as a,g as b,D as c};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import{a as b}from"./chunk-56EJGQU3.js";import{a as S}from"./chunk-Y5JU726N.js";var P=async(E,k={})=>{let c=S(E).id;if(!c)return'ERROR: Missing "id" argument for getProgress.';let t=b.find(s=>s.id===c);if(!t)return`ERROR: Subagent task with ID [${c}] not found.`;let n=`Subagent Task Status: ${t.status.toUpperCase()}
|
|
2
|
-
`;if(n+=`Title: ${t.title}
|
|
3
|
-
`,n+=`Task: ${t.task}
|
|
4
|
-
`,t.startedAt){let s=Math.floor((Date.now()-t.startedAt)/1e3);n+=`Elapsed Time: ${s}s
|
|
5
|
-
`}if(n+=`Turns Completed: ${t.progress.length}
|
|
6
|
-
`,t.status==="running"||t.status==="waiting"){t.currentTool&&(n+=`Current Tool: ${t.currentTool}
|
|
7
|
-
`);let r=(t.lastChunkTime?Date.now()-t.lastChunkTime:9999)<1e3&&t.wps>0?Math.round(t.wps):0;r>0&&(n+=`TPS: ${r}
|
|
8
|
-
`)}if(t.questions&&t.questions.length>0){let s=t.questions.filter(r=>!r.answered);s.length>0&&(n+=`
|
|
9
|
-
**PENDING QUESTION**
|
|
10
|
-
`,s.forEach(r=>{n+=`"${r.question}"
|
|
11
|
-
`}),n+=`Respond using tool: [tool:functions.Answer(id="${t.id}", answer="...")]
|
|
12
|
-
|
|
13
|
-
`)}return n+=`
|
|
14
|
-
Progress Log:
|
|
15
|
-
`,t.progress.forEach((s,r)=>{n+=`--- Turn ${r+1} ---
|
|
16
|
-
`;let R=s.filter(i=>!i.startsWith("[SUBAGENT SUCCESS]")).map(i=>{if(i.startsWith("[Subagent Response]")){let h="[Subagent Response]",e=i.substring(h.length),$="tool:";for(;;){let g=e.toLowerCase().indexOf($);if(g===-1)break;let d=g,T=!1,u=g-1;for(;u>=0&&/\s/.test(e[u]);)u--;u>=0&&e[u]==="["&&(d=u,T=!0);let p=0,m=!1,o=null,a=g;for(;a<e.length;){let l=e[a];if(!o&&(l==="'"||l==='"'||l==="`")?o=l:o&&l===o&&e[a-1]!=="\\"&&(o=null),o||(l==="("?(p++,m=!0):l===")"&&p--),m&&p===0&&!o){let w=a;if(T){let f=a+1;for(;f<e.length&&/\s/.test(e[f]);)f++;f<e.length&&e[f]==="]"&&(w=f)}e=e.substring(0,d)+e.substring(w+1);break}if(a++,a===e.length){e=e.substring(0,d);break}}}return h+`
|
|
17
|
-
`+e.trim()}return i.startsWith("[Executing Tool]")&&i.length>256?i.substring(0,256)+"...[truncated from logs]":i});n+=R.join(`
|
|
18
|
-
`)+`
|
|
19
|
-
|
|
20
|
-
`}),t.status==="completed"&&t.finalAnswer?n+=`Final Answer:
|
|
21
|
-
${t.finalAnswer}
|
|
22
|
-
`:t.status==="failed"&&t.error&&(n+=`Failure Error: ${t.error}
|
|
23
|
-
`),n.replace(/\r\n/g,`
|
|
24
|
-
`).replace(/\n{3,}/g,`
|
|
25
|
-
|
|
26
|
-
`).trim().replace(/\[(?:TOOL|ACTION) RESULT\]/gi,"ACTION RESULT:")};export{P as getProgress};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t=async(e,r={})=>"Screen recapture requested. The latest gridded screenshot is provided for your next decision.";export{t as recapture_screen};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h}from"./chunk-UIFI2JRY.js";export{a as GRID_CONFIG,e as captureGriddedScreenshot,h as coordinates720pToGridId,d as getActiveDisplay,g as gridToNativeCoordinates,f as parseGridCodeTo720p,c as rawModelOnly,b as useModel};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{a as E}from"./chunk-A73NNVCZ.js";import"./chunk-26BQ45XP.js";import T from"puppeteer";import M from"turndown";import{gfm as R}from"turndown-plugin-gfm";var W=async t=>{let i=t;if(typeof t=="object"&&t!==null)i=t.url||t.targetUrl||t.href||"";else if(typeof t=="string"){let r=t.match(/url\s*=\s*["'](.*)["']/);i=r?r[1]:t}let c=typeof i=="string"?i.trim():"";if(!c)return"ERROR: No target URL provided.";let s=3,f=null;for(let r=1;r<=s;r++){let a=null;try{let m=E();a=await T.launch({headless:!0,executablePath:m.executablePath||void 0,args:["--no-sandbox","--disable-setuid-sandbox","--disable-gpu","--disable-dev-shm-usage"]});let o=await a.newPage();await o.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.7778.178 Safari/537.36"),await o.setViewport({width:1920,height:1440});let d=r===1?Math.random()*1e3+500:Math.random()*2e3+1e3;await new Promise(l=>setTimeout(l,d)),await o.goto(c,{waitUntil:"networkidle2",timeout:18e4}),await new Promise(l=>setTimeout(l,1e3));let h=await o.evaluate(()=>{document.querySelectorAll("script, style, noscript, svg, canvas, iframe, ad, .ads, link, meta, img").forEach(e=>e.remove());let N=document.createNodeIterator(document.body,NodeFilter.SHOW_COMMENT),b;for(;b=N.nextNode();)b.remove();for(document.querySelectorAll("*").forEach(e=>{let n=e.attributes;for(let u=n.length-1;u>=0;u--){let p=n[u].name;p!=="href"&&p!=="src"&&e.removeAttribute(p)}});document.querySelector("div, span");)document.querySelectorAll("div, span").forEach(e=>{e.parentNode&&e.replaceWith(...e.childNodes)});document.querySelectorAll("br").forEach(e=>{e.replaceWith(document.createTextNode(`
|
|
2
|
-
|
|
3
|
-
`))});let y=()=>{let e=!1;document.querySelectorAll("*").forEach(n=>{n.childNodes.length===0&&!n.innerText.trim()&&(n.remove(),e=!0)}),e&&y()};return y(),document.body.innerHTML});if(!h)throw new Error("EMPTY_RENDER_RESULT");let S=h.replace(/<br\s*\/?>/gi,`
|
|
4
|
-
|
|
5
|
-
`).replace(/[ \t]+/g," ").replace(/>[ \t]+</g,"><").replace(/\n\s+/g,`
|
|
6
|
-
`).replace(/\n{3,}/g,`
|
|
7
|
-
|
|
8
|
-
`).trim(),w=new M({headingStyle:"atx",codeBlockStyle:"fenced"});w.use(R);let g=w.turndown(S).replace(/\.\s*\n/g,`
|
|
9
|
-
`).replace(/ +/g," ").replace(/\t/g," ").replace(/\n\s+/g,`
|
|
10
|
-
`).replace(/\n{3,}/g,`
|
|
11
|
-
|
|
12
|
-
`),v=g.substring(0,5e4);return await a.close(),`Markdown parsed from [${c}]:
|
|
13
|
-
|
|
14
|
-
${v}${g.length>5e4?`
|
|
15
|
-
|
|
16
|
-
...Truncated at 50K chars`:""}`}catch(m){if(f=m,a&&await a.close(),r<s){let o=Math.pow(2,r)*1e3;await new Promise(d=>setTimeout(d,o))}}}return`ERROR: Scrape failed after ${s+1} attempts. Last error: ${f.message}`};export{W as web_scrape};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import{a as P}from"./chunk-A73NNVCZ.js";import{a as k}from"./chunk-Y5JU726N.js";import{d as M}from"./chunk-26BQ45XP.js";import v from"puppeteer";import _ from"fs";import q from"path";var V=async F=>{let{query:f,limit:j=5,aiMode:L=!1}=k(F);if(!f)return'ERROR: Missing "query" argument for WebSearch.';let S=3,y=null;if(L){let u=`Query: ${f}
|
|
2
|
-
|
|
3
|
-
RESPONSE RULES:
|
|
4
|
-
- ANSWER CONCISELY (TL;DR style) WITH REQUIRED DETAILS UNDER 300 WORDS.
|
|
5
|
-
- DO NOT CITE, REFERENCE, OR MENTION SOURCES ANYWHERE BETWEEN THE MAIN RESPONSE.
|
|
6
|
-
- DO NOT USE MARKDOWN EXCEPT FOR THE SOURCES SECTION BELOW.
|
|
7
|
-
- END THE RESPONSE WITH EXACTLY:
|
|
8
|
-
|
|
9
|
-
Sources:
|
|
10
|
-
- <URL 1>
|
|
11
|
-
- <URL 2>
|
|
12
|
-
- <URL 3>
|
|
13
|
-
|
|
14
|
-
- LIST ONE RAW URL PER BULLET.
|
|
15
|
-
- DO NOT USE MARKDOWN LINKS.
|
|
16
|
-
- DO NOT INCLUDE ANY TEXT, NOTES, OR EXPLANATIONS AFTER THE SOURCES SECTION.`;for(let s=1;s<=S;s++){let a=null;try{let i=P();a=await v.launch({headless:!0,executablePath:i.executablePath||void 0,args:["--no-sandbox","--disable-setuid-sandbox","--disable-gpu","--disable-dev-shm-usage"]});let o=await a.newPage();await o.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.7778.178 Safari/537.36"),await o.setViewport({width:1366,height:768});let g=s===1?Math.random()*1e3+500:Math.random()*2e3+1e3;await new Promise(e=>setTimeout(e,g));let N=`https://search.brave.com/ask?q=${encodeURIComponent(u)}&source=web`;await o.goto(N,{waitUntil:"domcontentloaded",timeout:18e4});let l=null,W=45e3,E=Date.now();for(;Date.now()-E<W;){if(l=await o.evaluate(()=>{let e=Array.from(document.querySelectorAll('.message:not(.user), .answer-text, .llm-content, [data-type="answer"]')),t="";if(e.length>0&&(t=e.map(T=>T.innerText.trim()).filter(Boolean).join(`
|
|
17
|
-
|
|
18
|
-
`)),t||(t=document.body.innerText),t.includes("anomaly"))throw new Error("ANOMALY_DETECTED");let R=!!document.querySelector('.spinner, .loading, .typing, .streaming, [data-streaming="true"], [data-state="loading"], svg.animate-spin, circle[cx], div[class*="spin"]'),n=e[0]||document.body,p=n?n.innerText.trim():"",O=/^(?:[✓✔]\s*)?Finished/i.test(p)||!!(n&&n.querySelector(".status-finished, .finished")),x=!R&&(O||t.includes("Sources:")&&!R),D={};return document.querySelectorAll("a[href]").forEach(T=>{let r=T.getAttribute("href")||T.href||"";if(r.includes("uddg=")&&(r=decodeURIComponent(r.split("uddg=")[1].split("&")[0])),r.includes("url=")&&(r=decodeURIComponent(r.split("url=")[1].split("&")[0])),r&&(r.startsWith("http://")||r.startsWith("https://"))&&!r.includes("search.brave.com")){let $=T.innerText.trim();$&&(D[$]=r),T.textContent=r}}),{isFinished:x,text:t,hrefMap:D}}),l&&l.isFinished){await new Promise(e=>setTimeout(e,1e3));break}await new Promise(e=>setTimeout(e,1e3))}let c=(l?l.text:"")||"",d=l?l.hrefMap||{}:{},b="DO NOT INCLUDE ANY TEXT, NOTES, OR EXPLANATIONS AFTER THE SOURCES SECTION.";c.includes(b)&&(c=c.split(b).pop()),c=c.replace(/^.*?(Ctrl \+ Shift \+ O|Ask\nAll\nImages)/s,"").replace(/AI-generated answer\. Please verify critical facts\..*/s,"").replace(/Brave Search uses private usage metrics.*/s,"");let m=c,w="";if(c.includes("Sources:")){let e=c.split("Sources:");m=e[0],w=e.slice(1).join("Sources:")}let h=[];for(let e of m.split(`
|
|
19
|
-
`)){let t=e.trim();t&&(/^(View all|Finished|Searching|Answering|Thinking)$/i.test(t)||/^[\+\-]?\d+$/.test(t)||t.includes("search.brave.com")||t.startsWith("https://www.youtube.com/watch")||t.startsWith("https://youtube.com/watch")||h.push(e))}let U=h.join(`
|
|
20
|
-
`).replace(/^(?:[\+\-]?\d+\s*)+/i,"").replace(/\n{3,}/g,`
|
|
21
|
-
|
|
22
|
-
`).trim(),A=e=>!e||e.includes("search.brave.com")||e.includes("youtube.com")||e.includes("youtu.be"),C="";if(w){let e=w.match(/https?:\/\/[^\s\)\>]+/g)||[],t=[];for(let n of e){let p=n.replace(/[\.\,\;]+$/,""),O=Object.keys(d).find(x=>x.startsWith(p)||p.startsWith(x));O&&d[O]&&(p=d[O]),A(p)||t.push(p)}Object.values(d).forEach(n=>{!A(n)&&!t.includes(n)&&t.push(n)});let R=Array.from(new Set(t));R.length>0&&(C=`Sources:
|
|
23
|
-
`+R.map(n=>`- ${n}`).join(`
|
|
24
|
-
`))}let I=U+(C?`
|
|
25
|
-
|
|
26
|
-
`+C:"");if(!I||/^(\+\d+|Searching|Answering|Thinking|Finished)$/i.test(I))throw new Error("EMPTY_AI_RESPONSE");return await a.close(),`AI Search results for [${f}]:
|
|
27
|
-
|
|
28
|
-
${I}`}catch(i){if(y=i,_.writeFileSync(q.join(M,"web_tools","search","ai_mode","ERROR.txt"),i.message),a&&await a.close(),s<S){let o=Math.pow(2,s)*1e3;await new Promise(g=>setTimeout(g,o))}}}}for(let u=1;u<=S;u++){let s=null;try{let a=P();s=await v.launch({headless:!0,executablePath:a.executablePath||void 0,args:["--no-sandbox","--disable-setuid-sandbox","--disable-gpu","--disable-dev-shm-usage"]});let i=await s.newPage();await i.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.7778.178 Safari/537.36"),await i.setViewport({width:1366,height:768});let o=u===1?Math.random()*1e3+500:Math.random()*2e3+1e3;await new Promise(E=>setTimeout(E,o));let g=`https://html.duckduckgo.com/html/?q=${encodeURIComponent(f)}`;await i.goto(g,{waitUntil:"networkidle2",timeout:18e4});let N=await i.$$eval(".result",(E,c)=>E.slice(0,c).map((d,b)=>{let m=d.querySelector(".result__a"),w=d.querySelector(".result__snippet"),h=m?m.href:"";h.includes("uddg=")&&(h=decodeURIComponent(h.split("uddg=")[1].split("&")[0]));let U=m?m.innerText.trim():"No Title",A=w?w.innerText.trim():"No Snippet";return`${b+1}. ${U}
|
|
29
|
-
Source: ${h}
|
|
30
|
-
Snippet: ${A}`}),j);if(N.length===0){if((await i.evaluate(()=>document.body.innerText)).includes("anomaly"))throw new Error("ANOMALY_DETECTED");return await s.close(),`No results found for query: [${f}].`}let l=N.join(`
|
|
31
|
-
|
|
32
|
-
`);return await s.close(),`${L?`AI Mode temporarily failed, used Standard search.
|
|
33
|
-
|
|
34
|
-
`:""}Search results for [${f}]:
|
|
35
|
-
|
|
36
|
-
${l}`}catch(a){if(y=a,s&&await s.close(),_.writeFileSync(q.join(M,"web_tools","search","standard_mode","ERROR.txt"),a.message),u<S){let i=Math.pow(2,u)*1e3;await new Promise(o=>setTimeout(o,i))}}}return`ERROR: Search failed after ${S+1} attempts. Last error: ${y.message}`};export{V as web_search};
|