fluxflow-cli 4.18.0 → 4.20.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/dist/chunks/{addMemScore-W4I665ZR.js → addMemScore-HPTGXICT.js} +1 -1
- package/dist/chunks/{ai-6LGLTTCE.js → ai-Q4NPSX2V.js} +1 -1
- package/dist/chunks/{app-UMXRKFDU.js → app-Q3BDRKBD.js} +90 -90
- package/dist/chunks/{chat-C4CKZM5D.js → chat-HHMMKXDE.js} +1 -1
- package/dist/chunks/{chunk-E3E5H3M4.js → chunk-33KD6VKN.js} +1 -1
- package/dist/chunks/{chunk-MAZITQH6.js → chunk-4XZGWK5L.js} +1 -1
- package/dist/chunks/{chunk-4CQOGQFQ.js → chunk-B7KSXQ3C.js} +289 -128
- package/dist/chunks/chunk-COUKJJ4O.js +31 -0
- package/dist/chunks/{chunk-XFL3A2CT.js → chunk-I4JQEUHE.js} +1 -1
- package/dist/chunks/chunk-NPYHHQDC.js +1 -0
- package/dist/chunks/{chunk-VCF6JVQV.js → chunk-ORXN6WUW.js} +1 -1
- package/dist/chunks/{chunk-7QASAAHS.js → chunk-Q2D63UDR.js} +1 -1
- package/dist/chunks/{chunk-UGLNJ52L.js → chunk-QGPOMXO4.js} +1 -1
- package/dist/chunks/{chunk-FDNLMLIM.js → chunk-RI37VZYB.js} +1 -1
- package/dist/chunks/{chunk-UAHJEAVX.js → chunk-RLT6EHPQ.js} +1 -1
- package/dist/chunks/chunk-RN5BZJYO.js +9 -0
- package/dist/chunks/{chunk-ZSVBC2ZI.js → chunk-UDJ2C3N3.js} +1 -1
- package/dist/chunks/{chunk-TCYHPPPS.js → chunk-UN6TUQZX.js} +1 -1
- package/dist/chunks/{chunk-BCS6MMDL.js → chunk-UVWNGUNJ.js} +180 -180
- package/dist/chunks/{chunk-HYGK7YDY.js → chunk-WFHGURXW.js} +1 -1
- package/dist/chunks/{chunk-72RYQ5W7.js → chunk-Y6DZDEJ5.js} +1 -1
- package/dist/chunks/{chunk-KFM2OZWJ.js → chunk-YUJMCXJA.js} +1 -1
- package/dist/chunks/{click-KI2HDWSU.js → click-H7HTKF3R.js} +2 -2
- package/dist/chunks/{computer_action-DTZFD3WC.js → computer_action-UTDLLMF2.js} +1 -1
- package/dist/chunks/{drag-I5U53ZJG.js → drag-U6X3O5GB.js} +1 -1
- package/dist/chunks/{emergency_rollback-JTQSRHQZ.js → emergency_rollback-HWM4FJ6J.js} +1 -1
- package/dist/chunks/{exec_command-DDBOSWMU.js → exec_command-BH3PUWVO.js} +1 -1
- package/dist/chunks/export-YTWRQ63I.js +1 -0
- package/dist/chunks/{file_map-LMYY76M4.js → file_map-XK7BFZFI.js} +1 -1
- package/dist/chunks/{generate_image-OZQE4ON3.js → generate_image-KQBOTDD4.js} +1 -1
- package/dist/chunks/{invoke-WRVCOTXT.js → invoke-ID3KSFBY.js} +2 -2
- package/dist/chunks/{invokeSync-KD765JM2.js → invokeSync-FAK53YTR.js} +2 -2
- package/dist/chunks/{key_press-26ZNSFNA.js → key_press-QRO3OFLC.js} +1 -1
- package/dist/chunks/{keyboard_typing-KFGOX3QX.js → keyboard_typing-FXP3VJ6Q.js} +1 -1
- package/dist/chunks/{memory-OYIUYX3A.js → memory-TVFFXCSD.js} +1 -1
- package/dist/chunks/{model_config-KOPB5T4R.js → model_config-UZLNHYP5.js} +1 -1
- package/dist/chunks/paths-Y7ACZJAE.js +1 -0
- package/dist/chunks/{saveSummary-ATBIFYDP.js → saveSummary-HFAPNJJH.js} +1 -1
- package/dist/chunks/{screen_grid-MAW64GKY.js → screen_grid-EIPLWNEM.js} +1 -1
- package/dist/chunks/{scroll-YN67VAJ7.js → scroll-SND6RHXA.js} +1 -1
- package/dist/chunks/search_keyword-EAMQWPPI.js +8 -0
- package/dist/chunks/{secrets-XNJW2U6Y.js → secrets-RFEEPY3S.js} +1 -1
- package/dist/chunks/sessionDaemon-GHQTAGDG.js +1 -0
- package/dist/chunks/settings-JGWWOFEC.js +1 -0
- package/dist/chunks/{todo-6ZB5YFX6.js → todo-7Q2JBEVP.js} +1 -1
- package/dist/chunks/{update_file-ACEMMAAQ.js → update_file-BXYTHDAC.js} +1 -1
- package/dist/chunks/usage-XHKS6GHC.js +1 -0
- package/dist/chunks/usageServer-5WB6ZWFG.js +1 -0
- package/dist/chunks/view_file-JRVPAETL.js +1 -0
- package/dist/chunks/{web_scrape-IKJE45Z6.js → web_scrape-LAQI7CVA.js} +1 -1
- package/dist/chunks/{web_search-7GI77X3E.js → web_search-D2GOWARI.js} +1 -1
- package/dist/chunks/{write_docx-ZTLEYYGI.js → write_docx-IUKMO7XL.js} +1 -1
- package/dist/chunks/{write_file-QDLI2RK5.js → write_file-QMTFTJ6V.js} +1 -1
- package/dist/chunks/{write_pdf-ZM6DG4DO.js → write_pdf-UM6Z2J4K.js} +1 -1
- package/dist/cli.js +21 -21
- package/dist/package.json +2 -2
- package/package.json +2 -2
- package/dist/chunks/chunk-6NCN7IZN.js +0 -1
- package/dist/chunks/chunk-KRRJNFBF.js +0 -6
- package/dist/chunks/chunk-YNU56P2H.js +0 -31
- package/dist/chunks/export-OHZ652N5.js +0 -1
- package/dist/chunks/paths-PM7MFWJK.js +0 -1
- package/dist/chunks/search_keyword-4NOEU57F.js +0 -8
- package/dist/chunks/settings-FZNBYJ3N.js +0 -1
- package/dist/chunks/usage-2UML4SGM.js +0 -1
- package/dist/chunks/usageServer-TWVV3FOE.js +0 -1
- package/dist/chunks/view_file-MGLL22AR.js +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as
|
|
3
|
-
[ERROR] Allocation value '${
|
|
4
|
-
`),process.exit(1));var
|
|
5
|
-
[MEMORY] Starting with: '${
|
|
2
|
+
import{a as v}from"./chunks/chunk-RI37VZYB.js";import{spawn as pe}from"child_process";import{fileURLToPath as ee}from"url";import me from"os";import O from"path";import F from"fs";import P from"dotenv";try{let e=O.join(v,"AGENTS.md"),d=O.join(v,"FLUXFLOW.md");F.existsSync(v)||F.mkdirSync(v,{recursive:!0}),F.existsSync(e)||F.writeFileSync(e,"","utf8"),F.existsSync(d)||F.writeFileSync(d,"","utf8")}catch{}P.config({path:"./.env",override:!0,quiet:!0});P.config({path:`${v}/.env`,override:!0,quiet:!0});P.config({path:`${v}/.env.agents`,override:!0,quiet:!0});P.config({path:`${v}/.env.fluxflow`,override:!0,quiet:!0});P.config({path:"./.env.agents",override:!0,quiet:!0});P.config({path:"./.env.fluxflow",override:!0,quiet:!0});process.env.NO_INS=!1;var de=me.totalmem(),te=de/(1024*1024),ue=.5,ge=Math.floor(te*ue),oe=process.argv.slice(2),Z=oe.indexOf("--allocation"),m=Z!==-1?parseInt(oe[Z+1],10):NaN,fe=process.env.EXPERIMENTAL_MEMORY_MANAGER==="true"||process.env.EXPERIMENTAL_MEMORY_MANAGER==="1"||process.env.EXPERIMENTAL_MEMORY_MANAGER===!0||process.env.EXPERIMENTAL_MEMORY_MANAGER===1||!1,xe=!isNaN(m)||fe||!1;!isNaN(m)&&m<64&&(console.error(`
|
|
3
|
+
[ERROR] Allocation value '${m} MB' is too low. Minimum: 64 MB, Recommended: 4096 MB.
|
|
4
|
+
`),process.exit(1));var I=Math.floor(te*.75),we=!isNaN(m)&&m>0?Math.min(m,I):Math.max(1536,Math.min(32768,ge)),he=ee(import.meta.url).endsWith(".js");if(he&&!process.execArgv.some(e=>e.includes("max-old-space-size"))&&xe)Number.isNaN(m)||(console.log(`
|
|
5
|
+
[MEMORY] Starting with: '${m>I?I:m} MB' Allocation${m>I?" (Max allowed: '"+I+" MB')":""}. Please Wait...`),await new Promise(d=>setTimeout(d,5e3))),pe(process.execPath,[`--max-old-space-size=${we}`,"--expose-gc","--max-semi-space-size=1",ee(import.meta.url),...process.argv.slice(2)],{stdio:"inherit"}).on("exit",d=>process.exit(d||0));else{let e=process.argv.slice(2),d=e.includes("--help")&&e[e.indexOf("--help")+1]==="commands",X=e.includes("--help")&&!d,V=e.includes("--version")||e.includes("-v"),z=e[0]==="--update",J=e[0]==="--export";if(e[0]==="--usage"||e.includes("--usage")||e[0]==="--budget"||e.includes("--budget")){let{openUsageDashboard:t}=await import("./chunks/usageServer-5WB6ZWFG.js"),{url:l}=await t();console.log(`
|
|
6
6
|
\u2726 FluxFlow Token Usage & Analytics Dashboard
|
|
7
|
-
\u2800\u2800\u2514\u2500 Serving at: ${
|
|
7
|
+
\u2800\u2800\u2514\u2500 Serving at: ${l}
|
|
8
8
|
\u2800\u2800\u2514\u2500 Opened in default browser. Press Ctrl+C to stop.
|
|
9
|
-
`),await new Promise(()=>{})}if(
|
|
10
|
-
Usage: fluxflow --export error`),process.exit(1)}if(
|
|
11
|
-
--mode <flux|flow>
|
|
9
|
+
`),await new Promise(()=>{})}if(V||X||d||z||J){let t=await import("fs"),l=await import("path"),{fileURLToPath:i}=await import("url"),x=l.join(l.dirname(i(import.meta.url)),"../package.json"),u=JSON.parse(t.readFileSync(x,"utf8")).version;if(J){let S=(e[1]||"").toLowerCase();if(S==="error"||S==="logs")try{let{exportErrorLogs:g}=await import("./chunks/export-YTWRQ63I.js"),n=await g();console.log(`[EXPORT LOGS] Exported ${n.entryCount} error log entries (FluxFlow: ${n.fluxflowCount}, Memory: ${n.memoryCount}, Usage: ${n.usageCount}) to "${n.exportFile}"`),process.exit(0)}catch(g){console.error(`[EXPORT ERROR] Failed to export error logs: ${g.message}`),process.exit(1)}else console.error(`[EXPORT ERROR] Invalid export target "${e[1]||""}". --export only supports 'error'.
|
|
10
|
+
Usage: fluxflow --export error`),process.exit(1)}if(V&&(console.log(`v${u}`),process.exit(0)),X&&(console.log(`FluxFlow CLI Arguments:
|
|
11
|
+
--mode <flux|flow|icu|omni> Set startup mode (Agent / Chat / Computer Use / Sentient being)
|
|
12
12
|
--model <model_name> Set startup AI model
|
|
13
13
|
--key <key@provider> Set API key and provider
|
|
14
14
|
--provider Override default provider
|
|
@@ -21,7 +21,7 @@ Usage: fluxflow --export error`),process.exit(1)}if(G&&(console.log(`v${f}`),pro
|
|
|
21
21
|
--auto-exec <on|off> Toggle permission for autonomous command execution
|
|
22
22
|
--yolo <on|off> Same as --auto-exec
|
|
23
23
|
--external-access <on|off> Toggle permission for file reads outside CWD
|
|
24
|
-
-p, --prompt <text>
|
|
24
|
+
-p, --prompt <text> [-n|--new] One-shot non-TUI answer (-n to start fresh conversation)
|
|
25
25
|
-v, --version Show installed version
|
|
26
26
|
--help Show this help menu
|
|
27
27
|
--help commands Show available /commands
|
|
@@ -32,7 +32,7 @@ Usage: fluxflow --export error`),process.exit(1)}if(G&&(console.log(`v${f}`),pro
|
|
|
32
32
|
--export error Export system error logs to fluxflow-error-<timestamp>.txt
|
|
33
33
|
--update check Check for new updates
|
|
34
34
|
--update check latest Show the latest version available on npm
|
|
35
|
-
--update [latest] Update the app to the latest version (latest is default)`),process.exit(0)),
|
|
35
|
+
--update [latest] Update the app to the latest version (latest is default)`),process.exit(0)),d&&(console.log(`FluxFlow Chat /Commands:
|
|
36
36
|
/quit Exit and shutdown Flux
|
|
37
37
|
/help Show help menu
|
|
38
38
|
/clear Clear terminal screen
|
|
@@ -64,16 +64,16 @@ Usage: fluxflow --export error`),process.exit(1)}if(G&&(console.log(`v${f}`),pro
|
|
|
64
64
|
/docs View documentation
|
|
65
65
|
/fluxflow init Create FluxFlow.md template
|
|
66
66
|
/update check Check for new version
|
|
67
|
-
/update latest Install latest release`),process.exit(0)),
|
|
68
|
-
NO markdown, just plain text
|
|
69
|
-
|
|
70
|
-
- OS: ${
|
|
71
|
-
- Model: ${O.basename(
|
|
72
|
-
- Time: ${
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
`);let{text:
|
|
67
|
+
/update latest Install latest release`),process.exit(0)),z){let S=e[1]||"latest";if(S==="check"){let g=e[2]==="latest";try{let c=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;c||(console.error("Error: Could not retrieve latest version."),process.exit(1)),console.log(g?`Latest version: v${c}`:c!==u?`A new version of FluxFlow is available: v${c} (current: v${u}). Run "fluxflow --update latest" to upgrade.`:`FluxFlow is up to date (v${u}).`)}catch(n){console.error("Error checking for updates:",n.message),process.exit(1)}process.exit(0)}else if(S==="latest"){console.log("Checking latest version and settings...");try{let a=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;a||(console.error("Error: Could not retrieve latest version."),process.exit(1)),a===u&&(console.log(`FluxFlow is already up to date (v${u}).`),process.exit(0));let c=async()=>{let o=(await import("react")).default,{useState:E}=o,{render:B,Box:w,Text:M}=await import("ink"),D=(await import("ink-select-input")).default,_=(await import("ink-text-input")).default;return new Promise(j=>{let G=[{label:"NPM",value:"npm"},{label:"PNPM",value:"pnpm"},{label:"Yarn",value:"yarn"},{label:"Bun",value:"bun"},{label:"Custom Command",value:"custom"}],q=({label:h,isSelected:p})=>o.createElement(w,{width:"100%"},o.createElement(M,{bold:p},"\u2514\u2500 ",p?"\x1B[32m\u25CF\x1B[0m":"\u25CB"," ",h)),R,A=()=>{let[h,p]=E("select"),[Y,H]=E(""),T=N=>{N.value==="custom"?p("custom"):k({manager:N.value})},W=N=>{k({manager:"custom",customCommand:N})};return h==="custom"?o.createElement(w,{flexDirection:"column",marginY:1},o.createElement(w,{marginBottom:1},o.createElement(M,{color:"magenta",bold:!0},"\u{1F527} Enter custom update command:")),o.createElement(w,{flexDirection:"row"},o.createElement(M,{color:"cyan",bold:!0}," \u276F "),o.createElement(_,{value:Y,onChange:H,onSubmit:W})),o.createElement(w,{marginTop:1},o.createElement(M,{color:"gray",dimColor:!0,italic:!0}," (Press Enter to confirm)"))):o.createElement(w,{flexDirection:"column",marginY:1},o.createElement(w,{marginBottom:1},o.createElement(M,{color:"magenta",bold:!0},"\u{1F4E6} Select a package manager for the update:")),o.createElement(D,{items:G,onSelect:T,itemComponent:q,indicatorComponent:()=>null}))},k=h=>{R&&R(),j(h)},{unmount:s}=B(o.createElement(A,null));R=s})},r,$="",b;try{let{loadSettings:o}=await import("./chunks/settings-JGWWOFEC.js");b=await o(),r=b?.systemSettings?.updateManager||b?.updateManager}catch{}if(!r){let o=await c();r=o.manager,$=o.customCommand}let f="";r==="pnpm"?f=`pnpm add -g fluxflow-cli@${a}`:r==="bun"?f=`bun add -g fluxflow-cli@${a}`:r==="yarn"?f=`yarn global add fluxflow-cli@${a}`:r==="custom"?f=$||b?.customUpdateCommand||`npm install -g fluxflow-cli@${a}`:f=`npm install -g fluxflow-cli@${a}`,console.log(`Updating FluxFlow to v${a} using ${r}...`),console.log(`Running: ${f}`);let{execSync:C}=await import("child_process");C(f,{stdio:"inherit"}),console.log(`\x1B[32m\u2705 Update successful! FluxFlow updated to v${a}.\x1B[0m`)}catch(g){console.error("\x1B[31m\u274C Update failed:\x1B[0m",g.message),process.exit(1)}process.exit(0)}else console.error("Unknown update command. Available options: --update, --update check, --update check latest, --update latest"),process.exit(1)}}let{default:se}=await import("react"),{render:re}=await import("ink"),{default:ne}=await import("./chunks/app-Q3BDRKBD.js");process.env.NODE_NO_WARNINGS="1";let ae=["cuimp","Found existing binary","Binary verified","curl.exe not found","Falling back to .bat file","DeprecationWarning"],ie=console.log,le=console.warn,ce=console.error,L=t=>{let l=t.map(String).join(" ");return ae.some(i=>l.includes(i))};console.log=(...t)=>!L(t)&&ie(...t),console.warn=(...t)=>!L(t)&&le(...t),console.error=(...t)=>!L(t)&&ce(...t);let U=e.findIndex(t=>t==="--cwd"||t==="--path");if(U!==-1&&U+1<e.length){let t=e[U+1],l=await import("path"),i=await import("fs-extra"),x=l.default.resolve(t);try{i.default.existsSync(x)&&i.default.statSync(x).isDirectory()?process.chdir(x):(console.error(`[ERROR] Directory not found: "${t}"`),process.exit(0))}catch(y){console.error(`[ERROR] Failed to change directory to "${t}": ${y.message}`),process.exit(0)}}let K=e.findIndex(t=>t==="-p"||t==="--prompt");if(K!==-1){let t=e.includes("--new")||e.includes("-n"),i=e.slice(K+1).filter(s=>s!=="-n"&&s!=="--new")[0];i||(console.error("[ERROR] -p/--prompt requires a prompt string."),process.exit(1));let{loadSettings:x}=await import("./chunks/settings-JGWWOFEC.js"),{getProviderAPIKey:y}=await import("./chunks/secrets-RFEEPY3S.js"),{getDefaultModel:u}=await import("./chunks/model_config-UZLNHYP5.js"),{generateSimpleContent:S}=await import("./chunks/ai-Q4NPSX2V.js"),{checkQuotaDetailed:g}=await import("./chunks/usage-XHKS6GHC.js"),n=await x(),a=e.filter(s=>s!=="-p"&&s!=="--prompt"&&s!==i&&s!=="-n"&&s!=="--new"),c=s=>{for(let h of s){let p=a.indexOf(h);if(p!==-1&&p+1<a.length)return a[p+1]}return null},r=c(["--provider"])||n.aiProvider||"Google",$=c(["--model"])||n.activeModel||u(r,n.apiTier)||u(r,"paid"),b=c(["--key"])||await y(r);b||(console.error(`[ERROR] No API key resolved for provider "${r}".`),process.exit(1));let f=await g("agent",{aiProvider:r});f.allowed||(console.error(`[ERROR] ${f.reason||"Budget Exhausted"} - adjust with /budget set.`),process.exit(1));let C={aiProvider:r,apiKey:b,model:$,mode:"flow",thinkingLevel:c(["--thinking"])||"Fast",systemSettings:n.systemSettings||{}},o=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",E=new Date,B=E.getFullYear(),w=E.toLocaleString("en-US",{month:"short"}).toUpperCase(),M=String(E.getDate()).padStart(2,"0"),D=E.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}),_=`${B}-${w}-${M}, ${D}`,j=`Identity: FluxFlow. Sassy, CLI Assistant
|
|
68
|
+
NO markdown, just plain text
|
|
69
|
+
Additional Context:
|
|
70
|
+
- OS: ${o}
|
|
71
|
+
- Model: ${O.basename(C.model).trim().replace(":free","").replace("-free","").replace("free/","").replaceAll("-"," ").replace(/\b\w/g,s=>s.toUpperCase().trim())}
|
|
72
|
+
- Time: ${_}
|
|
73
|
+
- Non interactive CLI mode, no agent tools
|
|
74
|
+
- \`fluxflow\` TUI needed for full capability`.trim(),{getPromptSessionHistory:G,savePromptSessionHistory:q,clearPromptSessionHistory:R}=await import("./chunks/sessionDaemon-GHQTAGDG.js"),A=[];t?await R():A=await G();let k=[];if(Array.isArray(A)&&A.length>0)for(let s of A)s.text&&k.push({role:s.role==="model"?"model":"user",parts:[{text:s.text}]});k.push({role:"user",parts:[{text:i}]});try{let s="\x1B[36m",h="\x1B[35m",p="\x1B[0m",Y=O.basename(C.model).trim().replace(":free","").replace("-free","").replace("free/","").replaceAll("-"," ").replace(/\b\w/g,W=>W.toUpperCase().trim());process.stdout.write(`Responding with ${s}${Y}${p} from ${h}${C.aiProvider}${p}:
|
|
75
|
+
`);let{text:H}=await S(C,$,k,j,C.thinkingLevel),T=(H||"").trim();process.stdout.write(T+`
|
|
76
76
|
|
|
77
|
-
`)}catch(
|
|
77
|
+
`),T&&await q(i,T)}catch(s){console.error(`[ERROR] Prompt request failed: ${s.message.trim()}
|
|
78
78
|
|
|
79
|
-
`),process.exit(1)}process.exit(0)}process.stdout.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"),process.stdout.write("\x1B[?2004h"));let
|
|
79
|
+
`),process.exit(1)}process.exit(0)}process.stdout.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"),process.stdout.write("\x1B[?2004h"));let Q=()=>{process.stdout.isTTY&&process.stdout.write("\x1B[?2004l")};if(process.on("exit",Q),["SIGINT","SIGTERM","SIGHUP"].forEach(t=>{process.once(t,()=>{Q(),process.exit(0)})}),e.includes("--playground")){let t=process.cwd();process.argv.push("--original-cwd",t);let{DATA_DIR:l}=await import("./chunks/paths-Y7ACZJAE.js"),i=await import("path"),x=await import("fs-extra"),y=i.default.join(l,"playground");try{x.default.ensureDirSync(y),process.chdir(y)}catch{}}re(se.createElement(ne,{args:process.argv.slice(2)}),{exitOnCtrlC:!1})}
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as K}from"./chunk-XFL3A2CT.js";import{a as et,b as _}from"./chunk-SIINYZWE.js";import{h as G,i as L}from"./chunk-FDNLMLIM.js";import p from"fs-extra";import st from"path";var ut=()=>Math.random().toString(36).substring(2)+Date.now().toString(36),r=null,b=null,ot=0,F=!1,S={agent:0,background:0,search:0,toolSuccess:0,toolFailure:0,toolDenied:0,duration:0,tokens:0,cachedTokens:0,candidateTokens:0,linesAdded:0,linesRemoved:0,imageCalls:[]},O=(e,i)=>{if(!e)return{};let n=Object.keys(e),c=new Date(new Date(i).getTime()-720*60*60*1e3),t={};for(let s of n)new Date(s)>=c&&(t[s]=e[s]);return t},j=async()=>{let e=new Date().toISOString().split("T")[0];try{!await p.exists(L)&&await p.exists(G)&&(await p.ensureDir(st.dirname(L)),await p.move(G,L))}catch{}let i=L+".tmp",n=null;try{if(await p.exists(i)){let t=(await p.readFile(i,"utf8")).trim(),s=null;if(t.startsWith("{")||t.startsWith("[")?s=JSON.parse(t):s=JSON.parse(_(t)),s&&s.date&&s.stats){n=s;try{await p.rename(i,L)}catch{}}else try{await p.remove(i)}catch{}}}catch{try{await p.remove(i)}catch{}}if(!n)try{if(await p.exists(L)){let t=(await p.readFile(L,"utf8")).trim();t.startsWith("{")||t.startsWith("[")?n=JSON.parse(t):n=JSON.parse(_(t))}}catch{}let c=n;if(c){let t=c.stats||{...S},s={...S,...t};Array.isArray(s.imageCalls)||(s.imageCalls=[]);let a=c.history||{},o=O(a,e);if(Object.keys(a).length!==Object.keys(o).length&&(F=!0),c.date===e)return{...c,stats:s,history:o};{let l=c.date,f=s,d={...o};return l&&(d[l]=f),{date:e,stats:{...S},history:O(d,e)}}}return{date:e,stats:{...S},history:{}}},$=async()=>{if(!(!F||!r))try{await p.ensureDir(st.dirname(L));let e=null;try{if(await p.exists(L)){let t=(await p.readFile(L,"utf8")).trim();t.startsWith("{")||t.startsWith("[")?e=JSON.parse(t):e=JSON.parse(_(t))}}catch{}if(e&&e.date===r.date&&e.stats){for(let t in r.stats)if(e.stats[t]!==void 0){if(Array.isArray(r.stats[t])){let s=Array.isArray(e.stats[t])?e.stats[t]:[],a=r.stats[t],o=new Map;for(let l of[...s,...a])l&&l.timestamp&&o.set(l.timestamp,l);r.stats[t]=Array.from(o.values())}else if(typeof r.stats[t]=="number")r.stats[t]=Math.max(r.stats[t],Number(e.stats[t])||0);else if(r.stats[t]&&typeof r.stats[t]=="object"){let s=e.stats[t]||{},a=r.stats[t];for(let o in s)if(typeof s[o]=="number")a[o]=Math.max(a[o]||0,s[o]);else if(s[o]&&typeof s[o]=="object"){a[o]||(a[o]={});for(let l in s[o])if(typeof s[o][l]=="number")a[o][l]=Math.max(a[o][l]||0,s[o][l]);else if(s[o][l]&&typeof s[o][l]=="object"){a[o][l]||(a[o][l]={});for(let f in s[o][l])a[o][l][f]=Math.max(a[o][l][f]||0,s[o][l][f])}}}}}if(e&&e.history){let t={...r.history||{}};for(let s in e.history)if(t[s])for(let a in t[s])if(a==="imageCalls"){let o=Array.isArray(e.history[s].imageCalls)?e.history[s].imageCalls:[],l=Array.isArray(t[s].imageCalls)?t[s].imageCalls:[],f=new Map;for(let d of[...o,...l])d&&d.timestamp&&f.set(d.timestamp,d);t[s].imageCalls=Array.from(f.values())}else typeof t[s][a]=="number"&&(t[s][a]=Math.max(t[s][a],Number(e.history[s][a])||0));else t[s]=e.history[s];r.history=O(t,r.date||today)}else if(r&&r.history){let t=new Date().toISOString().split("T")[0];r.history=O(r.history,t)}r.saveId=ut();let i=L+".tmp",n=et(JSON.stringify(r,null,2));await p.writeFile(i,n,"utf8");let c=await p.open(i,"r+");await p.fsync(c),await p.close(c),await p.rename(i,L),F=!1,ot=Date.now()}catch{}},J=()=>{if(F=!0,b)return;let e=Date.now(),i=Math.max(0,1500-(e-ot));b=setTimeout(async()=>{await $(),b=null},i),b.unref&&b.unref()},wt=async()=>{r=await j(),F&&J()},Tt=async()=>{b&&(clearTimeout(b),b=null),await $()},v=async()=>{let e=new Date().toISOString().split("T")[0];if(!r)r=await j();else if(r.date!==e){let i=r.date,n=r.stats,c=r.history||{};n&&(c[i]=n),r={date:e,stats:{...S},history:O(c,e)},F=!0,await $()}return r&&r.stats&&!Array.isArray(r.stats.imageCalls)&&(r.stats.imageCalls=[]),r.stats},it=async()=>{let e=new Date().toISOString().split("T")[0];r||(r=await j()),r.date!==e&&await v();let i=r.history||{},n=O(i,e);r.history=n;let c=r.stats||{...S},t={...S};t.imageCalls=[],t.models={};let s=(a,o)=>{for(let l in a)if(l==="imageCalls")a.imageCalls=[...a.imageCalls||[],...o.imageCalls||[]];else if(l==="models"){let f=o.models||{};for(let d in f){a.models[d]||(a.models[d]={});for(let m in f[d]){a.models[d][m]||(a.models[d][m]={tokens:0,cachedTokens:0,candidateTokens:0});let u=a.models[d][m],h=f[d][m];u.tokens+=h.tokens||0,u.cachedTokens+=h.cachedTokens||0,u.candidateTokens+=h.candidateTokens||0}}}else typeof a[l]=="number"&&(a[l]+=o[l]||0)};s(t,c);for(let a in n)s(t,n[a]);return t},Lt=async(e,i)=>{e==="toolSuccess"?q.toolSuccess++:e==="toolFailure"?q.toolFailure++:e==="toolDenied"&&q.toolDenied++;let n=await v();n[e]!==void 0&&n[e]++,i&&e==="agent"&&(n.providerRequests||(n.providerRequests={}),n.providerRequests[i]=(n.providerRequests[i]||0)+1),J()},q={linesAdded:0,linesRemoved:0,toolSuccess:0,toolFailure:0,toolDenied:0},Dt=async(e,i,n,c)=>{e==="linesAdded"?q.linesAdded+=i:e==="linesRemoved"&&(q.linesRemoved+=i);let t=await v();if(t[e]!==void 0&&(t[e]+=Math.floor(i)),n&&c&&(e==="tokens"||e==="cachedTokens"||e==="candidateTokens")){t.models||(t.models={}),t.models[n]||(t.models[n]={}),t.models[n][c]||(t.models[n][c]={tokens:0,cachedTokens:0,candidateTokens:0});let s=t.models[n][c];e==="tokens"&&(s.tokens+=Math.floor(i)),e==="cachedTokens"&&(s.cachedTokens+=Math.floor(i)),e==="candidateTokens"&&(s.candidateTokens+=Math.floor(i))}J()},at=async(e=1)=>{let i=new Date,n=i.toISOString().split("T")[0];r||(r=await j()),r.date!==n&&await v();let c=i.getFullYear(),t=i.getMonth();i.getDate()<e&&(t-=1,t<0&&(t=11,c-=1));let o=new Date(c,t,e).toISOString().split("T")[0],l=r.history||{},f=r.stats||{...S},d={...S};d.imageCalls=[],d.models={};let m=(u,h)=>{for(let k in u)if(k==="imageCalls")u.imageCalls=[...u.imageCalls||[],...h.imageCalls||[]];else if(k==="models"){let D=h.models||{};for(let y in D){u.models[y]||(u.models[y]={});for(let w in D[y]){u.models[y][w]||(u.models[y][w]={tokens:0,cachedTokens:0,candidateTokens:0});let C=u.models[y][w],M=D[y][w];C.tokens+=M.tokens||0,C.cachedTokens+=M.cachedTokens||0,C.candidateTokens+=M.candidateTokens||0}}}else typeof u[k]=="number"&&(u[k]+=h[k]||0)};m(d,f);for(let u in l)u>=o&&u<n&&m(d,l[u]);return d},ft=async(e,i={})=>{let n=await K().catch(()=>({})),c=i.apiTier||n.apiTier||"Free",t=i.quotas||i.systemSettings?.quotas||n.quotas||{},s=t.providerBudgets||{},a=!!s.__useProvider,o=i.aiProvider||n.aiProvider||"Google",l=a&&!!s[o],f=()=>{if(l){let d=s[o];return{agentLimit:typeof d.agentLimit=="number"&&d.agentLimit>0?d.agentLimit:99999999,tokenLimit:typeof d.tokenLimit=="number"&&d.tokenLimit>0?d.tokenLimit:99999999999999,monthlyTokenLimit:typeof d.monthlyTokenLimit=="number"&&d.monthlyTokenLimit>0?d.monthlyTokenLimit:99999999999999}}return{agentLimit:t.agentLimit||99999999,tokenLimit:t.tokenLimit||99999999999999,monthlyTokenLimit:t.monthlyTokenLimit||99999999999999}};if(e==="agent"){let{agentLimit:d,tokenLimit:m,monthlyTokenLimit:u}=f(),h=await v(),k;t.resetMode==="Custom"?k=await at(t.resetDay||1):k=await it();let D=0,y=0,w=0;if(l){D=h.providerRequests?.[o]||0;let C=h.models?.[o]||{};for(let I in C)y+=C[I]?.tokens||0;let M=k.models?.[o]||{};for(let I in M)w+=M[I]?.tokens||0}else D=h.agent||0,y=h.tokens||0,w=k.tokens||0;return c==="Free"&&h.agent+h.background>=999999?{allowed:!1,reason:"Free Tier Daily Usage Limit Exceeded"}:D>=d?{allowed:!1,reason:l?`Daily Request Limit Reached for ${o}`:"Daily Agent Request Limit Reached"}:y>=m?{allowed:!1,reason:l?`Daily Token Budget Exhausted for ${o}`:"Daily Token Budget Exhausted"}:w>=u?{allowed:!1,reason:l?`Monthly Token Budget Exhausted for ${o}`:"Monthly Token Budget Exhausted"}:{allowed:!0}}if(e==="background"){let d=await v();if(c==="Free"&&d.agent+d.background>=999999)return{allowed:!1,reason:"Free Tier Background Limit Exceeded"};let m=d.background<(t.backgroundLimit||999999);return{allowed:m,reason:m?void 0:"Background Request Limit Exceeded"}}if(e==="search"){let m=(await v()).search<(t.searchLimit||100);return{allowed:m,reason:m?void 0:"Search Quota Exceeded"}}return{allowed:!0}},Mt=async(e,i={})=>(await ft(e,i)).allowed,Y=e=>{if(!e||e.length===0)return[];let n=[...e].sort((t,s)=>t.timestamp-s.timestamp),c=[];for(let t of n){if(c.length>0){let s=c[c.length-1];if(t.timestamp>=s.start&&t.timestamp<s.end){s.calls.push(t),s.spent+=t.cost;continue}}c.push({start:t.timestamp,end:t.timestamp+36e5,calls:[t],spent:t.cost})}return c},nt=(e,i)=>{if(!e||e.length===0)return .025;let c=Y(e);if(c.length===0)return .025;let t=[];for(let m of c){let u=.025;if(t.length>0){let k=t[t.length-1],D=!1;if(t.length>=2){let y=t[t.length-2];k.ratio>=.8&&y.ratio>=.8&&(D=!0)}if(D)u=.015;else{let y=k.limit,w=k.ratio;w>=.8?u=y===.015?.015:y:w<.4?u=Math.min(.025,y+.005):w>=.4&&w<.6?u=Math.min(.025,y+.004):u=Math.min(.025,y+.002)}}let h=u>0?m.spent/u:0;t.push({limit:u,spent:m.spent,ratio:h})}let s=c[c.length-1];if(i<s.end)return t[t.length-1].limit;let a=t[t.length-1].limit,o=a,l=t[t.length-1].ratio,f=s.end,d=0;for(let m=t.length-1;m>=0&&t[m].ratio>=.8;m--)d++;for(;f<=i;){let m=.025;d>=2?m=.015:l>=.8?m=o===.015?.015:o:l<.4?m=Math.min(.025,o+.005):l>=.4&&l<.6?m=Math.min(.025,o+.004):m=Math.min(.025,o+.002),o=m,l=0,d=0,f+=36e5,a=m}return a},St=async e=>{let i=e.imageSettings||{keyType:"Default",quality:"Low-High"};if(i.keyType!=="Default")return!0;let c={Low:.001,"Low-High":.002,Medium:.008,"Medium-High":.01,High:.045,Ultra:.0488,Premium:.15}[i.quality]||.002,t=await v();t.imageCalls||(t.imageCalls=[]);let s=Date.now(),a=Y(t.imageCalls),o=0;if(a.length>0){let f=a[a.length-1];s>=f.start&&s<f.end&&(o=f.spent)}let l=nt(t.imageCalls,s);return o+c<=l},vt=async()=>{let e=await v();e.imageCalls||(e.imageCalls=[]);let i=Date.now(),n=Y(e.imageCalls),c=[],t=0,s=0;if(n.length>0){let f=n[n.length-1];i>=f.start&&i<f.end&&(c=f.calls,t=f.spent,s=Math.max(0,Math.ceil((f.end-i)/(60*1e3))))}let a=nt(e.imageCalls,i),o=Math.max(0,a-t),l=t;return{totalSpent:t,remaining:o,activeCallsCount:c.length,nextResetMin:s,reclaimCost:l,limit:a}},Ct=async e=>{let i=e.imageSettings||{keyType:"Default",quality:"Low-High"},c={Low:.001,"Low-High":.002,Medium:.008,"Medium-High":.01,High:.045,Ultra:.0488,Premium:.1}[i.quality]||.002,t=await v();t.imageCalls||(t.imageCalls=[]),t.imageCalls.push({timestamp:Date.now(),cost:c}),J()},xt=async()=>{let e=new Date().toISOString().split("T")[0];r||(r=await j()),r.date!==e&&await v();let i=r.stats||{...S},n=r.history||{},c=new Set(Object.keys(n));c.add(e);let s=Array.from(c).sort().map(T=>{let x=T===e?i:n[T]||{},g={...S,...x},B=g.tokens||0,P=g.cachedTokens||0,H=g.candidateTokens||0,N=Math.max(0,B-H),E=Math.max(0,N-P),A=g.agent||0,R=g.background||0,U=g.search||0,rt=A+R+U,Q=g.toolSuccess||0,V=g.toolFailure||0,X=g.toolDenied||0,W=Q+V+X,lt=W>0?(Q/W*100).toFixed(1):"100.0",z=g.linesAdded||0,Z=g.linesRemoved||0,tt=Array.isArray(g.imageCalls)?g.imageCalls:[],ct=tt.reduce((dt,mt)=>dt+(mt.cost||0),0);return{date:T,tokens:B,cachedTokens:P,candidateTokens:H,promptTokens:N,uncachedPromptTokens:E,agent:A,background:R,search:U,totalRequests:rt,toolSuccess:Q,toolFailure:V,toolDenied:X,totalTools:W,toolSuccessRate:parseFloat(lt),linesAdded:z,linesRemoved:Z,netLines:z-Z,duration:g.duration||0,imageCallsCount:tt.length,imageCost:ct,models:g.models||{},providerRequests:g.providerRequests||{}}}),a=await K().catch(()=>({})),o=a.quotas||{},l=a.apiTier||"Free",f=await it().catch(()=>({tokens:0,agent:0})),d=null;o.resetMode==="Custom"&&(d=await at(o.resetDay||1).catch(()=>({tokens:0})));let m=o.tokenLimit||0,u=o.monthlyTokenLimit||0,h=o.agentLimit||0,k=o.resetMode||"Daily",D=o.resetDay||1,y=o.providerBudgets||{},w=!!y.__useProvider,C=["Google","Anthropic","OpenAI","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside"];Object.keys(y).forEach(T=>{T!=="__useProvider"&&!C.includes(T)&&C.push(T)});let M=[];for(let T of C){let x=y[T];if(x&&(x.agentLimit||x.tokenLimit||x.monthlyTokenLimit)){let g=0,B=i.models?.[T]||{};for(let U in B)g+=B[U]?.tokens||0;let P=0,H=(o.resetMode==="Custom"?d?.models:f?.models)?.[T]||{};for(let U in H)P+=H[U]?.tokens||0;let N=i.providerRequests?.[T]||0,E=x.tokenLimit||0,A=x.monthlyTokenLimit||0,R=x.agentLimit||0;M.push({provider:T,dailyTokens:g,dailyTokenLimit:E,isDailyUnlimited:E>=9999999999999||E===0,monthlyTokens:P,monthlyTokenLimit:A,isMonthlyUnlimited:A>=9999999999999||A===0,dailyRequests:N,dailyAgentLimit:R,isRequestsUnlimited:R>=9999999||R===0})}}let I={apiTier:l,resetMode:k,resetDay:D,quotas:o,usingProviderBudgets:w&&M.length>0||M.length>0,providerBudgetsList:M,daily:{tokensUsed:i.tokens||0,tokenLimit:m,agentRequests:i.agent||0,agentLimit:h,isUnlimitedTokens:m>=9999999999999||m===0,isUnlimitedRequests:h>=9999999||h===0},monthly:{tokensUsed:(o.resetMode==="Custom"?d?.tokens:f?.tokens)||0,tokenLimit:u,isUnlimitedTokens:u>=9999999999999||u===0},providerBudgets:y};return{currentDate:e,todayStats:i,history:n,timeline:s,budget:I,runtimeSession:{...q}}};export{wt as a,Tt as b,v as c,it as d,Lt as e,q as f,Dt as g,at as h,ft as i,Mt as j,Y as k,nt as l,St as m,vt as n,Ct as o,xt as p};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{a as j}from"./chunk-KFM2OZWJ.js";import{c as w,d as m}from"./chunk-SIINYZWE.js";import{f as T,g as C,k as N,l as L,r as x}from"./chunk-FDNLMLIM.js";import u from"fs-extra";import F from"path";import{nanoid as S}from"nanoid";var O=Promise.resolve(),I=t=>{let n=O.then(async()=>{try{return await t()}catch(s){throw console.error("Lock Operation Failed:",s),s}});return O=n.catch(()=>{}),n},M=async()=>{await u.ensureDir(C);let t={};if(await u.pathExists(T))try{t=w(T,{})}catch{t={}}for(let n in t){let s=F.join(C,`${n}.json`);Object.defineProperty(t[n],"messages",{get:()=>{if(u.existsSync(s))try{return w(s,[])}catch{return[]}return[]},set:e=>{try{m(s,e)}catch{}},enumerable:!1,configurable:!0})}return t},J=async(t,n,s)=>I(async()=>{await u.ensureDir(C);let e=await M(),r=e[t],a=(s||[]).filter(l=>!l.isUpdateNotification&&(!l.isMeta||l.text&&l.text.includes("Request Cancelled"))),i=l=>{if(!l)return;let E=typeof l=="string"?l:l.text||l.content||"";if(!E||typeof E!="string")return;let b=E.replace(/\s*\n+\s*\[Prompted on:.*?\]/g,"").replace(/\[\/?(?:STEERING HINT|QUESTION)(?::\s*\w+)?\]/gi,"").trim();if(!b)return;let R=b.split(/\s+/),D;return R.length>7?D=R.slice(0,7).join(" ")+"...":b.length>45?D=b.substring(0,45).trimEnd()+"...":D=b,D},o,d=a.filter(l=>l.role==="user"),A=d[0],h=d[d.length-1],c=i(h),f=i(A);r&&r.prompt?Math.random()<.3&&c?o=c:o=r.prompt:o=f||c;let p=n||(r?r.name:`Session ${t.slice(-6)}`),g=F.join(C,`${t}.json`);m(g,a),e[t]={name:p,prompt:o||void 0,updatedAt:Date.now()};let y={};for(let l in e)y[l]={name:e[l].name,prompt:e[l].prompt||void 0,updatedAt:e[l].updatedAt};m(T,y)}),W=async(t,n)=>I(async()=>{let s=await M();s[t]?(s[t].name=n,s[t].updatedAt=Date.now()):s[t]={name:n,updatedAt:Date.now()};let e={};for(let r in s)e[r]={name:s[r].name,prompt:s[r].prompt||void 0,updatedAt:s[r].updatedAt};m(T,e)}),k=async t=>I(async()=>{let n=await M();delete n[t];let s={};for(let i in n)s[i]={name:n[i].name,prompt:n[i].prompt||void 0,updatedAt:n[i].updatedAt};if(m(T,s),await u.pathExists(x))try{let i=w(x,[]);if(Array.isArray(i)){let o=i.filter(d=>Object.keys(d)[0]!==String(t));m(x,o)}}catch{}let e=w(N,{});e[t]&&(delete e[t],m(N,e));let r=w(L,{});r[t]&&(delete r[t],m(L,r)),await j.deleteChatBackups(t);let a=F.join(C,`${t}.json`);if(await u.pathExists(a))try{await u.remove(a)}catch{}return n}),Y=()=>`flow-${S(6)}`,q=async t=>{if(!t||t==="Never")return;let n=parseInt(t);if(isNaN(n))return;let s=await M(),e=Date.now(),r=n*24*60*60*1e3,a=0;for(let i in s){let o=s[i];o.updatedAt&&e-o.updatedAt>r&&(await k(i),a++)}return a},H=t=>{let n=t.replace(/[\[\]]/g,"").trim(),s=new Date(n);if(!isNaN(s.getTime()))return s.getTime();let e=n.split(/,\s*|\s+/);if(e.length===0)return null;let r=e[0],a=e[1]||"",i=e[2]||"",o=r.split(/[-\/.]/).map(Number);if(o.length!==3)return null;let d="en";try{d=Intl.DateTimeFormat().resolvedOptions().locale||"en"}catch{}let A=!/^en[-_]?us$|^en$/.test(d?.toLowerCase()),h,c,f;if(o[0]>1e3)h=o[0],c=o[1],f=o[2];else if(o[2]>1e3)h=o[2],o[0]>12?(f=o[0],c=o[1]):o[1]>12?(f=o[1],c=o[0]):A?(f=o[0],c=o[1]):(c=o[0],f=o[1]);else return null;if(c<1||c>12||f<1||f>31)return null;let p=0,g=0,y=0;if(a){let E=a.split(":").map(Number);p=E[0]||0,g=E[1]||0,y=E[2]||0,i.toLowerCase()==="pm"&&p<12?p+=12:i.toLowerCase()==="am"&&p===12&&(p=0)}let l=new Date(h,c-1,f,p,g,y);return isNaN(l.getTime())?null:l.getTime()},v=async t=>{try{if(!await u.pathExists(t))return;let n=await u.readFile(t,"utf8");if(!n.trim())return;let s=n.split(`
|
|
2
|
-
`),e=[],r=null,a=/^\s*(?:DEBUG|ERROR|SEARCH|PUPPETEER)\b/i;for(let c of s)a.test(c)?(r&&e.push(r),r={header:c,body:[]}):r?r.body.push(c):e.push({header:c,body:[]});r&&e.push(r);let i=10080*60*1e3,o=Date.now(),d=[],A=/(\d{1,4}[-\/.]\d{1,4}[-\/.]\d{1,4}(?:,\s*|\s+)?(?:\d{1,2}:\d{2}:\d{2}(?:\s*[aApP][mM])?)?)/;for(let c of e){if(a.test(c.header)){let g=c.header.match(A);if(g){let y=H(g[1]);if(y&&o-y>i)continue}}let p=c.header+(c.body.length>0?`
|
|
3
|
-
`+c.body.join(`
|
|
4
|
-
`):"");d.push(p)}let h=d.join(`
|
|
5
|
-
`).trim();h?await u.writeFile(t,h+`
|
|
6
|
-
`,"utf8"):await u.writeFile(t,"","utf8")}catch{}},K=async t=>{try{if(!await u.pathExists(t))return;let n=async s=>{let e=await u.readdir(s);for(let r of e){let a=F.join(s,r);(await u.stat(a)).isDirectory()?(await n(a),(await u.readdir(a)).length===0&&await u.remove(a)):r.endsWith(".log")&&await v(a)}};await n(t)}catch{}},Q=(t,n=4)=>{if(t.length<=1)return t;let s=t[0],e=t.slice(1),r=n*2,a=e.slice(r);return[s,...a]};var X=async(t,n,s)=>I(async()=>{let e=w(x,[]);Array.isArray(e)||(e=[]);let r={total:n,context:s},a=e.findIndex(i=>Object.keys(i)[0]===String(t));a!==-1?e[a]={[String(t)]:r}:e.push({[String(t)]:r}),m(x,e)}),z=async t=>{try{if(!await u.pathExists(x))return{total:0,context:0};let n=w(x,[]);if(!Array.isArray(n))return{total:0,context:0};let s=n.find(e=>Object.keys(e)[0]===String(t));return s?{total:0,context:0,...s[String(t)]}:{total:0,context:0}}catch{return{total:0,context:0}}};export{M as a,J as b,W as c,k as d,Y as e,q as f,K as g,Q as h,X as i,z as j};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import{d as S}from"./chunk-FDNLMLIM.js";import O from"fs-extra";import T from"path";var C=a=>{if(!a)return[];let u=[],h=/\[tool:(.*?)\((.*?)\)\]/g,r=0,l;for(;(l=h.exec(a))!==null;){if(l.index>r){let t=a.slice(r,l.index);t.trim()&&u.push({type:"output",content:t})}u.push({type:"tool",toolName:l[1],args:l[2]}),r=h.lastIndex}if(r<a.length){let t=a.slice(r);t.trim()&&u.push({type:"output",content:t})}return u},b=async(a,u,h=process.cwd())=>{let r=`export-fluxflow-${a}.txt`,l=T.join(h,r),t=[],c=!1;for(let g=0;g<u.length;g++){let i=u[g];if(i&&!(i.role==="system"||i.isMeta||i.isLogo||String(i.id).startsWith("welcome"))){if(i.role==="user"){let e=i.text||"";e=e.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),t.length>0&&t.push(""),t.push("[USER]"),t.push(e),c=!1}else if(i.role==="think"){c||(t.push(""),t.push("[AGENT]"),c=!0);let e=(i.text||"").replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/gi,"").replace(/\[\[TOOL RESULTS\]\]/gi,"").replace(/\[TOOL RESULTS\]/gi,"").replace(/\[TOOL RESULT\]/gi,"").trim();e&&(t.push("[thoughts]"),t.push(e))}else if(i.role==="agent"){c||(t.push(""),t.push("[AGENT]"),c=!0);let e=C(i.text||"");for(let p of e)if(p.type==="output"){let m=p.content.replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/gi,"").replace(/\[\[TOOL RESULTS\]\]/gi,"").replace(/\[TOOL RESULTS\]/gi,"").replace(/\[TOOL RESULT\]/gi,"").trim();m&&(t.push("[output]"),t.push(m))}else p.type==="tool"&&(t.push("[tool]"),t.push(`${p.toolName} ${p.args}`))}}}let R=t.join(`
|
|
2
|
-
`);return await O.writeFile(l,R,"utf8"),{exportFile:r,exportPath:l,totalLines:t.length}},j=(a,u="FluxFlow",h=null)=>{if(!a||!a.trim())return[];let r=a.split(`
|
|
3
|
-
`),l=[],t=[],c=/^\s*(?:CRITICAL\s+ERROR|ERROR|DEBUG|SEARCH|PUPPETEER|WARN|WARNING|INFO)\b/i,R=/^\s*-{3,}\s*$/,g=!1;for(let e of r)if(c.test(e)){g=!0;break}if(!g){let e=a.trim();if(!e)return[];let p=h?new Date(h).toLocaleString():"Unknown Time",m=/\bjanitor\b/i.test(e)?"Memory":u;return[{timestamp:p,level:"ERROR",source:m,message:e}]}for(let e of r)R.test(e)?t.length>0&&(l.push(t.join(`
|
|
4
|
-
`).trim()),t=[]):c.test(e)?(t.length>0&&(l.push(t.join(`
|
|
5
|
-
`).trim()),t=[]),t.push(e)):(t.length>0||e.trim())&&t.push(e);t.length>0&&l.push(t.join(`
|
|
6
|
-
`).trim());let i=[];for(let e of l){if(!e)continue;let p=e.split(`
|
|
7
|
-
`).map(o=>o.trimEnd()),m=p[0]||"";if(!/\bERROR\b/i.test(e))continue;let d=m.match(/\[(.*?)\]/),s=d?d[1]:null,f="ERROR";/CRITICAL\s+ERROR/i.test(m)&&(f="CRITICAL ERROR");let n="";if(d){let o=m.indexOf("]:");o!==-1?n=m.substring(o+2).trim():n=m.replace(c,"").replace(/\[.*?\]/,"").replace(/^:\s*/,"").trim()}else n=m.replace(c,"").replace(/^:\s*/,"").trim();if(p.length>1){let o=p.slice(1).join(`
|
|
8
|
-
`).trim();o&&(n=n?`${n}
|
|
9
|
-
${o}`:o)}if(n){let o=/\bjanitor\b/i.test(e)?"Memory":u;i.push({timestamp:s||(h?new Date(h).toLocaleString():"Unknown Time"),level:f,source:o,message:n})}}return i},U=async(a=process.cwd())=>{let u=`fluxflow-error-${Date.now()}.txt`,h=T.join(a,u),r=async s=>{if(!await O.pathExists(s))return[];let f=await O.readdir(s),n=[];for(let o of f){let E=T.join(s,o),x=await O.stat(E);if(x.isDirectory()){let L=await r(E);n=n.concat(L)}else(o.endsWith(".log")||o.endsWith(".txt"))&&n.push({path:E,mtime:x.mtimeMs})}return n},l=await r(S),t=[];for(let s of l)try{let f=await O.readFile(s.path,"utf8");if(f.trim()){let n=s.path.replace(/\\/g,"/").toLowerCase(),o="FluxFlow";n.includes("/janitor")||n.includes("janitor")?o="Memory":!n.includes("/agent")&&!n.includes("agent")&&(o="Other");let E=j(f,o,s.mtime);t=t.concat(E)}}catch{}let c=[],R=new Set;for(let s of t){let f=`${s.source}::${s.timestamp}::${s.message.trim()}`;R.has(f)||(R.add(f),c.push(s))}let g=c.filter(s=>s.source==="FluxFlow"),i=c.filter(s=>s.source==="Memory"),e=c.filter(s=>s.source!=="FluxFlow"&&s.source!=="Memory"),p=(s,f,n)=>{let o=["================================================================================",`${s} (${f.length})`,"================================================================================"].join(`
|
|
10
|
-
`);if(f.length===0)return`${o}
|
|
11
|
-
No ${n} error entries found.`;let E=f.map((x,L)=>{let $=`[${n} #${L+1}] ${x.timestamp} (${x.level})`,F=x.message.split(`
|
|
12
|
-
`).map(y=>` ${y}`).join(`
|
|
13
|
-
`);return`${$}
|
|
14
|
-
${F}`});return`${o}
|
|
15
|
-
|
|
16
|
-
`+E.join(`
|
|
17
|
-
|
|
18
|
-
--------------------------------------------------------------------------------
|
|
19
|
-
|
|
20
|
-
`)},m=["================================================================================","FLUXFLOW ERROR LOGS EXPORT",`Exported At : ${new Date().toLocaleString()}`,`Total Errors: ${c.length} (FluxFlow: ${g.length} | Memory: ${i.length}${e.length>0?` | Other: ${e.length}`:""})`,"================================================================================",""].join(`
|
|
21
|
-
`),w=[p("SECTION 1: FLUXFLOW ERRORS",g,"FluxFlow"),p("SECTION 2: MEMORY ERRORS",i,"Memory")];e.length>0&&w.push(p("SECTION 3: OTHER SYSTEM ERRORS",e,"Other"));let d=m+w.join(`
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
`)+`
|
|
25
|
-
`;return await O.writeFile(h,d,"utf8"),{exportFile:u,exportPath:h,entryCount:c.length,fluxflowCount:g.length,memoryCount:i.length}},A=async(a,{chatId:u,messages:h})=>{let r=(a[1]||"chat").toLowerCase();return r==="chat"?{success:!0,type:"chat",message:`\u2726 Chat Exported
|
|
26
|
-
\u2800\u2800\u2514\u2500 ${(await b(u,h)).exportFile}
|
|
27
|
-
\u2800`}:r==="logs"?{success:!0,type:"logs",message:`\u2726 Error Logs Exported
|
|
28
|
-
\u2800\u2800\u2514\u2500 ${(await U()).exportFile}
|
|
29
|
-
\u2800`}:{success:!1,message:`[EXPORT USAGE] Unknown subcommand "${r}". Options:
|
|
30
|
-
\u2022 /export chat current
|
|
31
|
-
\u2022 /export logs error`}};export{C as a,b,j as c,U as d,A as e};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e}from"./chunk-YNU56P2H.js";import"./chunk-FDNLMLIM.js";export{b as exportCurrentChat,d as exportErrorLogs,e as handleExport,a as parseAgentText,c as parseLogEntries};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u}from"./chunk-FDNLMLIM.js";export{p as ACTIVE_TX_FILE,m as BACKUPS_DIR,r as CONTEXT_FILE,t as CU_CACHE_DIR,c as DATA_DIR,a as FLUXFLOW_DIR,g as HISTORY_DIR,f as HISTORY_FILE,o as LEDGER_ADVANCE_FILE,n as LEDGER_FILE,d as LOGS_DIR,j as MEMORIES_FILE,s as PARSER_DIR,q as PATHS_FILE,e as SECRET_DIR,b as SETTINGS_FILE,l as TEMP_MEM_CHAT_FILE,k as TEMP_MEM_FILE,u as THINKING_CONFIG_FILE,i as USAGE_FILE,h as USAGE_FILE_OLD};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{a as q}from"./chunk-Y5JU726N.js";import{a as Z}from"./chunk-FDNLMLIM.js";import M from"fs/promises";import R from"path";import G from"fast-glob";import{Minimatch as H}from"minimatch";import J from"fs";async function S(a,r,e=a,f=1){if(f>12)return[];let i=[],s;try{s=await M.readdir(a,{withFileTypes:!0})}catch{return[]}for(let t of s){let n=R.join(a,t.name),o=R.relative(e,n),u=o.split(R.sep).map(g=>g.toLowerCase()),z=t.name.toLowerCase();if(!r.some(g=>{let L=g.toLowerCase();return L.startsWith(".")&&z.endsWith(L)?!0:u.some(F=>F===L||F.startsWith(".pnpm"))}))if(t.isDirectory()){let g=await S(n,r,e,f+1);i=i.concat(g)}else t.isFile()&&i.push({fullPath:n,relativePath:o})}return i}function Q(a,r,e=1/0){if(a===r)return 0;if(a.length===0)return r.length;if(r.length===0)return a.length;if(Math.abs(a.length-r.length)>e)return e+1;let f=Array.from({length:r.length+1},(i,s)=>s);for(let i=1;i<=a.length;i++){let s=[i],t=i;for(let n=1;n<=r.length;n++){let o=a[i-1]===r[n-1]?0:1,u=Math.min(s[n-1]+1,f[n]+1,f[n-1]+o);s.push(u),u<t&&(t=u)}if(f=s,t>e)return e+1}return f[r.length]}function tt(a,r){if(!a||!r)return!1;let e=a.toLowerCase(),f=r.toLowerCase();if(e.includes(f))return!0;let i=e.split(/[^a-z0-9]+/).filter(t=>t.length>0),s=f.split(/[^a-z0-9]+/).filter(t=>t.length>1||f.length===1&&t.length>0);return s.length===0?!1:s.every(t=>{let n=t.length<=2?0:t.length<=5?1:2;for(let o of i)if(o.includes(t)||t.length>=3&&o.length>=3&&Math.abs(o.length-t.length)<=n&&Q(t,o,n)<=n)return!0;return!1})}async function et(a){let r=R.join(Z,"skills","fluxflow"),e=R.join(r,"references");if(!J.existsSync(e))return"No documentation found in #docs.";let f=async o=>{let u=[];try{let z=await M.readdir(o,{withFileTypes:!0});for(let P of z){let g=R.join(o,P.name);P.isDirectory()?u=u.concat(await f(g)):P.isFile()&&u.push(g)}}catch{}return u},i=await f(e);if(i.length===0)return"No documentation found in #docs.";let s=null;try{s=new RegExp(a,"i")}catch{}let t=a.toLowerCase(),n=[];for(let o of i)try{let u=await M.readFile(o,"utf8");if(s&&s.test(u)||u.toLowerCase().includes(t)){let P=R.relative(r,o).replace(/\\/g,"/");n.push(P)}}catch{}return n.length===0?`No matches found for "${a}" in #docs.`:`DOCs Search "${a}":
|
|
2
|
-
${n.map(o=>`- ${o}`).join(`
|
|
3
|
-
`)}`}var ct=async a=>{let{keyword:r,path:e,fuzzy:f,subString:i,regex:s}=q(a);if(r==null)return'ERROR: Missing "keyword" argument.';let t=String(r);if(e&&(e.trim().toLowerCase()==="#docs"||e.trim().toLowerCase()==="#doc"||e.trim().toLowerCase()==="#documentation"||e.trim().toLowerCase().includes("#skill/global/fluxflow")))return et(t);let n=l=>l===!0||l==="true"||l===1||l==="1"||l==="yes",o=s===!1||s==="false"||s===0||s==="0"||s==="no",u=s===!0||s==="true"||s===1||s==="1"||s==="yes",z=n(f)||n(i),P=null,g=null;if(o)z||(g=new RegExp(`(?<![\\w])${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w])`,"i"));else{try{P=new RegExp(t,"i")}catch(l){if(u)return`ERROR: Invalid regex pattern "${t}": ${l.message}`}g=new RegExp(`(?<![\\w])${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w])`,"i")}let L=[".git","node_modules",".gemini","dist","build",".next","out",".cache","bin","obj","vendor","venv",".idea",".gradle",".terraform","target","coverage",".vscode",".svn",".hg",".fslckout",".github",".gitlab",".circleci",".gitea",".gitee",".lerna",".changeset",".nx",".npm",".yarn",".pnpm-store",".pnpm",".expo",".nuxt",".svelte-kit",".docusaurus",".turbo",".vercel","bower_components",".netlify",".vuepress",".quasar",".output",".angular","jspm_packages",".parcel-cache",".rollup.cache",".rspack",".vitepress","__pycache__",".pytest_cache",".mypy_cache",".tox",".poetry","env","vhdl",".ipynb_checkpoints",".jupyter",".conda",".pdm-build",".bundle",".yardoc",".metadata","App_Data","ClientBin",".cargo",".rustc_info",".go","Godeps","_vendor",".rake_tasks","CMakefiles",".wakatime",".dart_tool",".fvm",".cocoapods","Pods",".pub-cache",".symlinks","DerivedData",".xcworkspace",".serverless",".aws",".gcloud",".azure",".kube",".vagrant",".docker","postgres-data","redis-data","mongo-data",".Spotlight-V100",".Trashes","$RECYCLE.BIN","System Volume Information",".DocumentRevisions-V100",".fseventsd","AppData","Application Data","Local","LocalLow","Roaming","$WinREAgent","$WINDOWS.~BT","$WINDOWS.~WS","scw","System32","SysWOW64",".AppleDouble",".AppleDB",".AppleDesktop","_CodeSignature",".cmio",".LSOverride",".localized",".TemporaryItems",".Trash",".Trash-0",".Trash-1000",".gvfs",".local",".config",".dbus",".fontconfig",".snap",".var",".lost+found","lost+found",".thumb",".thumbnails","EFI","boot","grub","logs","log",".nyc_output",".sonar",".ruff_cache",".VSCodeCounter",".exe",".dll",".so",".dylib",".png",".jpg",".jpeg",".gif",".ico",".svg",".webp",".mp3",".mp4",".avi",".zip",".tgz",".tar",".gz",".7z",".rar",".pdf",".docx",".xlsx",".pptx",".woff",".woff2",".ttf",".eot",".skills","skills"],F=150;try{let l=[],x=process.cwd(),m=null;if(e){let c=e.split(";").map(h=>h.trim()).filter(Boolean),y=c.some(h=>h.startsWith("!"));if(c.some(h=>G.isDynamicPattern(h)||/[*?{}[\]()|+]/.test(h))){m="glob";let h=e.replace(/\\/g,"/"),b=c.map($=>$.replace(/\\/g,"/")),p=L.map($=>$.startsWith(".")?`**/*${$}`:`**/${$}/**`);if(y&&!c.some($=>!$.startsWith("!"))){let $=await S(x,L,x),C=d=>d.endsWith("/")?d+"**":d,D=b.filter(d=>d.startsWith("!")).map(d=>C(d.slice(1))),I=b.filter(d=>!d.startsWith("!")).map(C);l=$.filter(d=>{let w=d.relativePath.replace(/\\/g,"/"),B=I.length===0||I.some(_=>{try{return new H(_).match(w)}catch{return!1}}),T=D.some(_=>{try{return new H(_).match(w)}catch{return!1}});return B&&!T})}else{let $=b.some(D=>/[\(\)\|]|\.\*/.test(D)),C=[];if(!$)try{C=await G(b,{cwd:x,ignore:p,dot:!0,onlyFiles:!0,absolute:!1})}catch{C=[]}if(C.length===0&&($||G.isDynamicPattern(h))){let D=h.match(/^([^\*\?\(\)\|\[\]\s]+)\//),I=D&&!/[\*\?\(\)\|\[\]]/.test(D[1])?R.resolve(x,D[1]):x,d=await S(I,L,x);try{let w=h.replace(/^\.\//,"");w=w.replace(/\.\*\/(\\.|[^\/])/g,".*$1"),!w.startsWith("^")&&!w.startsWith(".*")&&(w=`.*${w}`);let B=new RegExp(w.endsWith("$")?w:`${w}$`,"i");l=d.filter(T=>{let _=T.relativePath.replace(/\\/g,"/");return B.test(_)})}catch{l=[]}}else l=C.map(D=>({fullPath:R.resolve(x,D),relativePath:D}))}}else{let h=e.replace(/[\/\\]+$/,""),b=R.resolve(x,h);try{let p=await M.stat(b);if(p.isDirectory())m="dir",l=await S(b,L,x);else if(p.isFile())m="file",l.push({fullPath:b,relativePath:R.relative(x,b)});else return`ERROR: Path is neither a file nor a directory: ${e}`}catch{return`ERROR: Path not found: ${e}`}}}else l=await S(x,L);let U=l.map(async c=>{try{let y=await M.readFile(c.fullPath,"utf-8");if(y.includes("\0"))return[];let v=y.split(/\r?\n/),h=[];for(let p=0;p<v.length;p++)(z?v[p].toLowerCase().includes(t.toLowerCase())||tt(v[p],t):o?g&&g.test(v[p]):P&&P.test(v[p])||g&&g.test(v[p]))&&h.push({line:p+1,content:v[p].trim()});return h.length===0?null:{path:c.relativePath.replace(/\\/g,"/"),matches:h}}catch{return[]}}),X=await Promise.all(U),W=[],E=0;for(let c of X){if(!c||!c.matches)continue;if(E>=F)break;let y=F-E,v=c.matches.slice(0,y);W.push({path:c.path,matches:v}),E+=v.length}typeof global.gc=="function"&&global.gc();let k=z?"(fuzzy mode)":u?"(regex mode)":o?"(keyword mode)":"(standard mode)";if(W.length===0){let c=m==="file"?` in '${e}'`:m==="dir"||m==="glob"?` in '${e}'`:". Try to specify files",y=m==="dir"?"[DIR]":m==="glob"?"[GLOB]":"";return`${y}${y?" ":""}Found 0 matches of '${t}'${c}${k?` ${k}`:""}`}let j=k?` ${k}`:"",V=`${W.length} file${W.length===1?"":"s"}`,N=`${E} match${E===1?"":"es"}`,A;m==="file"?A=`Found ${N} of '${t}' in '${e}'${j}:`:m==="dir"||m==="glob"?A=`Found ${N} of '${t}' in '${e}' across ${V}${j}:`:A=`Found ${N} of '${t}' across ${V}${j}:`;let K=m==="dir"?"[DIR]":m==="glob"?"[GLOB]":"",O=`${K}${K?" ":""}${A}
|
|
4
|
-
|
|
5
|
-
`;for(let c of W){O+=`${c.path}
|
|
6
|
-
`;for(let y of c.matches)O+=` ${y.line}: ${y.content}
|
|
7
|
-
`;O+=`
|
|
8
|
-
`}return O.trimEnd()}catch(l){return`ERROR: ${l.message}`}};export{ct as search_keyword};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-XFL3A2CT.js";import"./chunk-UGLNJ52L.js";import"./chunk-SIINYZWE.js";import"./chunk-FDNLMLIM.js";export{a as loadSettings,b as saveSettings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-6NCN7IZN.js";import"./chunk-XFL3A2CT.js";import"./chunk-UGLNJ52L.js";import"./chunk-SIINYZWE.js";import"./chunk-FDNLMLIM.js";export{g as addToUsage,m as checkImageQuota,j as checkQuota,i as checkQuotaDetailed,b as forceFlushUsage,p as getAllUsageData,h as getCustomPeriodUsage,c as getDailyUsage,k as getImageQuotaBuckets,l as getImageQuotaLimit,n as getImageQuotaStats,d as getMonthlyUsage,e as incrementUsage,a as initUsage,o as recordImageGeneration,f as runtimeSession};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-4CQOGQFQ.js";import"./chunk-6NCN7IZN.js";import"./chunk-XFL3A2CT.js";import"./chunk-UGLNJ52L.js";import"./chunk-SIINYZWE.js";import"./chunk-FDNLMLIM.js";export{b as openUsageDashboard,a as startUsageServer};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-MAZITQH6.js";import"./chunk-Y5JU726N.js";import"./chunk-FDNLMLIM.js";export{a as view_file};
|