fluxflow-cli 5.0.1 → 5.2.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 +1 -1
- package/dist/chunks/{9router-LRFKCJF4.js → 9router-KRJQK6JP.js} +1 -1
- package/dist/chunks/{addMemScore-PBVNSFPN.js → addMemScore-VUSJ2Q64.js} +1 -1
- package/dist/chunks/ai-W4ZXBMB4.js +1 -0
- package/dist/chunks/{aihubmix-TETL5QYQ.js → aihubmix-KJIG7CZO.js} +1 -1
- package/dist/chunks/{apinex-FAYOPQSL.js → apinex-EP3JJPZO.js} +1 -1
- package/dist/chunks/app-THKSHPL7.js +331 -0
- package/dist/chunks/{auto_completion-UG6IEWD2.js → auto_completion-CJNBFI3A.js} +1 -1
- package/dist/chunks/{chat-ISCVWNVN.js → chat-OYRESDTX.js} +1 -1
- package/dist/chunks/{chunk-QESQR5GB.js → chunk-3BRTFYTA.js} +1 -1
- package/dist/chunks/{chunk-GBH7XI5A.js → chunk-7UF7ZHP7.js} +1 -1
- package/dist/chunks/{chunk-52STSLCN.js → chunk-BLAXTPPN.js} +1 -1
- package/dist/chunks/{chunk-V36DXF56.js → chunk-DVXSU3Z4.js} +1 -1
- package/dist/chunks/{chunk-IHDJDAG3.js → chunk-E5CFO23P.js} +1 -1
- package/dist/chunks/{chunk-ZNO55RNG.js → chunk-FOELTIXU.js} +1 -1
- package/dist/chunks/chunk-HGDSONY3.js +885 -0
- package/dist/chunks/{chunk-LQM3JK7N.js → chunk-I5LTKU2O.js} +1 -1
- package/dist/chunks/{chunk-6EYQQ7GQ.js → chunk-KOCMIEPK.js} +1 -1
- package/dist/chunks/{chunk-7SGZ66KT.js → chunk-KSP6QOQX.js} +28 -28
- package/dist/chunks/{chunk-B4UKMX5E.js → chunk-KZCVQBDK.js} +1 -1
- package/dist/chunks/chunk-L22YGL6T.js +15 -0
- package/dist/chunks/{chunk-P5HBJA23.js → chunk-NTZSL2UT.js} +1 -1
- package/dist/chunks/{chunk-EXT42EJZ.js → chunk-QVRPR3DJ.js} +1 -1
- package/dist/chunks/{chunk-J4J3F6BT.js → chunk-WEDUYGPN.js} +1 -1
- package/dist/chunks/{chunk-HFTI3R3Q.js → chunk-XPIXBWTZ.js} +1 -1
- package/dist/chunks/chunk-YFIWMGCS.js +2 -0
- package/dist/chunks/{click-AWHZCV2E.js → click-ES2QYPC4.js} +2 -2
- package/dist/chunks/{computer_action-MO2JR2XH.js → computer_action-KUJCPYPN.js} +1 -1
- package/dist/chunks/{custom_openai-K554R7Q5.js → custom_openai-ETCGLBV4.js} +1 -1
- package/dist/chunks/{deepseek-WNWZJTNE.js → deepseek-I2J4A7WQ.js} +1 -1
- package/dist/chunks/{drag-D2GVPIQB.js → drag-U3DNSM33.js} +1 -1
- package/dist/chunks/{emergency_rollback-ZHQXCIHW.js → emergency_rollback-LC4ZBOLP.js} +1 -1
- package/dist/chunks/{explabs-XHHXTERB.js → explabs-OYP64XS6.js} +1 -1
- package/dist/chunks/{export-RU6LCZUB.js → export-I5DB7ESY.js} +1 -1
- package/dist/chunks/{file_map-UA4BA5OH.js → file_map-K6JQYV35.js} +1 -1
- package/dist/chunks/find_file-5RUNVQJO.js +4 -0
- package/dist/chunks/{generate_image-45UQ6P2B.js → generate_image-OOU2MEIQ.js} +1 -1
- package/dist/chunks/{inferx-HP5AGET3.js → inferx-B6PKXWLZ.js} +1 -1
- package/dist/chunks/{infron-ULXG7VDA.js → infron-4SLX3HMD.js} +1 -1
- package/dist/chunks/{invoke-DVZUJJV3.js → invoke-DPVPIREI.js} +2 -2
- package/dist/chunks/{invokeSync-NEZGW27B.js → invokeSync-Z2OWSYC7.js} +2 -2
- package/dist/chunks/{key_press-AQNKL6UM.js → key_press-5T4RCRQQ.js} +1 -1
- package/dist/chunks/{keyboard_typing-QSBPTZJ6.js → keyboard_typing-Y2OBDZDW.js} +1 -1
- package/dist/chunks/{memory-7YOYCOXE.js → memory-AT7ARTG3.js} +1 -1
- package/dist/chunks/{mistral-ON6RQMK7.js → mistral-QQGMQJ2O.js} +1 -1
- package/dist/chunks/{model_config-QRYAVWHF.js → model_config-J4YX2PNQ.js} +1 -1
- package/dist/chunks/{nvidia-I6DPWP6U.js → nvidia-6VK5M5FB.js} +1 -1
- package/dist/chunks/{ollama-6WSZPCI5.js → ollama-YTQ5HFES.js} +1 -1
- package/dist/chunks/{openrouter-6MRG4RT6.js → openrouter-LSG67TST.js} +1 -1
- package/dist/chunks/paths-MJECGRI2.js +1 -0
- package/dist/chunks/{poolside-ODFAIK4C.js → poolside-KWCBEP3P.js} +1 -1
- package/dist/chunks/read_folder-UWFC5DNX.js +17 -0
- package/dist/chunks/{recapture_screen-PPXYK2YY.js → recapture_screen-CQ3Z5FOL.js} +1 -1
- package/dist/chunks/{saveSummary-W2JMDVZJ.js → saveSummary-ZJDPCZSR.js} +1 -1
- package/dist/chunks/{screen_grid-3RU324CV.js → screen_grid-I6BDQFDD.js} +1 -1
- package/dist/chunks/{scroll-TSU6MTGU.js → scroll-SFUGXJQR.js} +1 -1
- package/dist/chunks/search_keyword-HR6JNLS2.js +9 -0
- package/dist/chunks/{secrets-TNMLVMST.js → secrets-DQHR2CI2.js} +1 -1
- package/dist/chunks/{secrets_v2-OBRWR3UT.js → secrets_v2-7RG5NKVT.js} +1 -1
- package/dist/chunks/{sensenova-3K44URJQ.js → sensenova-MLFZTP7U.js} +1 -1
- package/dist/chunks/settings-XJ2SOAWE.js +1 -0
- package/dist/chunks/{todo-CJLWLWJB.js → todo-YFLPXYFL.js} +1 -1
- package/dist/chunks/{tokenharbor-YV2GV2LM.js → tokenharbor-Y6HSTTHA.js} +1 -1
- package/dist/chunks/update_file-BN6X5WNO.js +15 -0
- package/dist/chunks/{usage-EBE2OVES.js → usage-BCL4OUAK.js} +1 -1
- package/dist/chunks/{usageServer-RTK5N5KE.js → usageServer-FIH6WL3V.js} +1 -1
- package/dist/chunks/view_file-OYV2IEYG.js +1 -0
- package/dist/chunks/{web_scrape-J3PL2PXT.js → web_scrape-MVSCRDKO.js} +1 -1
- package/dist/chunks/{web_search-KBGH67IV.js → web_search-C3WKDOSZ.js} +1 -1
- package/dist/chunks/{write_docx-E3MTFXTQ.js → write_docx-QGW25TF7.js} +1 -1
- package/dist/chunks/write_file-Q4K4LZFU.js +34 -0
- package/dist/chunks/{write_pdf-TPGUF4VT.js → write_pdf-5HOQYVQO.js} +1 -1
- package/dist/chunks/{xkiro-B2LYGZTF.js → xkiro-D3DTPVWY.js} +1 -1
- package/dist/cli.js +6 -6
- package/dist/package.json +2 -2
- package/package.json +2 -2
- package/dist/chunks/ai-WBRHU7IH.js +0 -1
- package/dist/chunks/app-YYK3S5Y5.js +0 -325
- package/dist/chunks/chunk-24LJKH4G.js +0 -847
- package/dist/chunks/chunk-26BQ45XP.js +0 -2
- package/dist/chunks/chunk-4BLSASW6.js +0 -13
- package/dist/chunks/find_file-HYHHFHUJ.js +0 -4
- package/dist/chunks/paths-RQRI2XRY.js +0 -1
- package/dist/chunks/read_folder-EI2CNHNS.js +0 -15
- package/dist/chunks/search_keyword-DZY4MWV7.js +0 -8
- package/dist/chunks/settings-PUFSRWT3.js +0 -1
- package/dist/chunks/update_file-TGEB5UWK.js +0 -13
- package/dist/chunks/view_file-I77KYUO5.js +0 -1
- package/dist/chunks/write_file-O6OF7Z2W.js +0 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as p}from"./chunk-
|
|
1
|
+
import{a as p}from"./chunk-YFIWMGCS.js";import a from"fs";import g from"path";import{fileURLToPath as O}from"url";var y={version:0,release:20261106,fallbacks:{},providers:{}};var P=O(import.meta.url),b=g.dirname(P),v="",S=[g.join(b,"../../model_config.json"),g.join(b,"../model_config.json")];for(let e of S)try{if(a.existsSync(e)){v=e;break}}catch{}var x=g.join(p,"model_config.json"),d=null,M=()=>{if(v)try{let e=a.readFileSync(v,"utf-8"),t=JSON.parse(e);if(t&&typeof t=="object")return t}catch{}return y&&typeof y=="object"?JSON.parse(JSON.stringify(y)):{version:0,release:20260913,fallbacks:{},providers:{}}};if(a.existsSync(x))try{let e=a.readFileSync(x,"utf-8"),t=JSON.parse(e);if(t&&typeof t=="object"){let o=M();t.fallbacks={...o.fallbacks||{},...t.fallbacks||{}},t.providers||(t.providers={}),t.release||(t.release=o.release||20260913),d=t}}catch{}d||(d=M());var h=new Set,_=new Set,u=()=>{let e=new Set,t=new Set;if(d.providers)for(let o of Object.keys(d.providers)){let s=d.providers[o];if(s&&s.models){let i=["Free","Paid"];for(let l of i){let r=s.models[l];if(Array.isArray(r)){for(let n of r)if(n&&n.cmd){let c=n.cmd.trim().toLowerCase();n.multimodal===!0&&e.add(c),n.hasReasoning===!0&&t.add(c)}}}}}if(Array.isArray(d.multimodal_models))for(let o of d.multimodal_models)o&&typeof o=="string"&&e.add(o.trim().toLowerCase());h=e,_=t};u();var $=()=>d,m=()=>{try{return a.existsSync(p)||a.mkdirSync(p,{recursive:!0}),a.writeFileSync(x,JSON.stringify(d,null,2),"utf-8"),!0}catch{return!1}},U=(e,t,o=!1,s=null,i=null)=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let l=t.trim();if(!l)return{success:!1,reason:"Model ID cannot be empty"};d.providers||(d.providers={}),d.providers[e]||(d.providers[e]={default_free:"",default_paid:"",models:{Free:[],Paid:[]}});let r=d.providers[e];r.models||(r.models={Free:[],Paid:[]}),Array.isArray(r.models.Free)||(r.models.Free=[]);let n=i?String(i).trim().replace(/\/+$/,""):null,c=r.models.Free.find(f=>(typeof f=="string"?f:f?.cmd)===l);if(c)if(typeof c=="string"){let f=r.models.Free.indexOf(c),F={cmd:l,multimodal:!!o,desc:l};s&&Object.keys(s).length>0&&(F.info=s),n&&(F.baseUrl=n),r.models.Free[f]=F}else c.multimodal=!!o,s&&Object.keys(s).length>0&&(c.info={...c.info||{},...s}),n&&(c.baseUrl=n);else{let f={cmd:l,multimodal:!!o,desc:l};s&&Object.keys(s).length>0&&(f.info=s),n&&(f.baseUrl=n),r.models.Free.push(f)}return u(),m(),{success:!0}},R=(e,t,o={})=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let s=t.trim();if(!s)return{success:!1,reason:"Model ID cannot be empty"};d.providers||(d.providers={}),d.providers[e]||(d.providers[e]={default_free:"",default_paid:"",models:{Free:[],Paid:[]}});let i=d.providers[e];i.models||(i.models={Free:[],Paid:[]}),Array.isArray(i.models.Free)||(i.models.Free=[]);let l=s.toLowerCase(),r=i.models.Free.find(n=>{let c=typeof n=="string"?n:n?.cmd;return c&&c.trim().toLowerCase()===l});if(o===null)r&&typeof r=="object"&&delete r.info;else if(!r)i.models.Free.push({cmd:s,multimodal:!1,desc:s,info:o});else if(typeof r=="string"){let n=i.models.Free.indexOf(r);i.models.Free[n]={cmd:r,multimodal:!1,desc:r,info:o}}else r.info={...r.info||{},...o};return m(),{success:!0}},T=(e,t,o=!0)=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let s=t.trim();if(!s)return{success:!1,reason:"Model ID cannot be empty"};let i=d.providers?.[e];if(!i||!i.models||!Array.isArray(i.models.Free))return{success:!1,reason:`Provider ${e} has no models configured`};let l=i.models.Free.find(r=>(typeof r=="string"?r:r?.cmd)===s);if(!l)return{success:!1,reason:`Model "${s}" not found in ${e} model list`};if(typeof l=="string"){let r=i.models.Free.indexOf(l);i.models.Free[r]={cmd:s,multimodal:!!o,desc:s}}else l.multimodal=!!o;return u(),m(),{success:!0}},J=(e,t,o=!1,s=null)=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let i=t.trim();if(!i)return{success:!1,reason:"Model ID cannot be empty"};d.providers||(d.providers={}),d.providers[e]||(d.providers[e]={default_free:"",default_paid:"",models:{Free:[],Paid:[]}});let l=d.providers[e];l.models||(l.models={Free:[],Paid:[]}),Array.isArray(l.models.Free)||(l.models.Free=[]);let r=l.models.Free.find(n=>(typeof n=="string"?n:n?.cmd)===i);if(r)if(typeof r=="string"){let n=l.models.Free.indexOf(r),c={cmd:i,multimodal:!!o,desc:i};s&&Object.keys(s).length>0&&(c.info=s),l.models.Free[n]=c}else o&&(r.multimodal=!0),s&&Object.keys(s).length>0&&(r.info={...r.info||{},...s});else{let n={cmd:i,multimodal:!!o,desc:i};s&&Object.keys(s).length>0&&(n.info=s),l.models.Free.push(n)}return l.default_free=i,u(),m(),{success:!0}},W=(e,t)=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let o=t.trim();if(!o)return{success:!1,reason:"Model ID cannot be empty"};let s=d.providers?.[e];if(!s||!s.models||!Array.isArray(s.models.Free))return{success:!1,reason:`Provider ${e} has no models configured`};let i=s.models.Free.findIndex(l=>(typeof l=="string"?l:l?.cmd)===o);return i===-1?{success:!1,reason:`Model "${o}" not found in ${e} model list`}:(s.models.Free.splice(i,1),s.default_free===o&&(s.default_free=""),s.default_paid===o&&(s.default_paid=""),u(),m(),{success:!0})},E=(e,t,o)=>{if(!e||!t||!o)return{success:!1,reason:"Invalid provider or model IDs"};let s=t.trim(),i=o.trim();if(!s||!i)return{success:!1,reason:"Model IDs cannot be empty"};let l=d.providers?.[e];if(!l||!l.models||!Array.isArray(l.models.Free))return{success:!1,reason:`Provider ${e} has no models configured`};let r=l.models.Free.find(n=>(typeof n=="string"?n:n?.cmd)===s);if(!r)return{success:!1,reason:`Model "${s}" not found in ${e} model list`};if(typeof r=="string"){let n=l.models.Free.indexOf(r);l.models.Free[n]={cmd:i,multimodal:!1,desc:i}}else r.cmd=i,(r.desc===s||!r.desc)&&(r.desc=i);return u(),m(),{success:!0}},I=!1,k=e=>{I=!!e},G=k,K=e=>{if(!e)return!1;let t=e.trim().toLowerCase();return!!(I||h.has(t)||t.startsWith("gemini-")||t.startsWith("gemma-"))},V=e=>{if(!e)return!1;let t=e.trim().toLowerCase();return _.has(t)},X=(e,t,o=null)=>{let s=d.providers[e];if(!s)return[];let i=s.models[t==="Free"?"Free":"Paid"]||[];if(e==="c_openai"&&o){let l=String(o).trim().replace(/\/+$/,"");return i.filter(r=>typeof r=="object"&&r?.baseUrl?r.baseUrl.replace(/\/+$/,"")===l:!0)}return i},q=(e,t)=>{let o=d.providers[e];return o?t==="Free"?o.default_free:o.default_paid:""},z=(e,t)=>{if(!e||!t||!d.providers)return null;let o=d.providers[e];if(!o||!o.models)return null;let s=t.trim().toLowerCase(),i=["Free","Paid"];for(let l of i){let r=o.models[l];if(Array.isArray(r)){for(let n of r)if(typeof n=="object"&&n?.cmd&&n.cmd.trim().toLowerCase()===s&&n.info)return{IN:Number(n.info.IN)||0,OUT:Number(n.info.OUT)||0,CR:Number(n.info.CR)||0,CW:Number(n.info.CW)||0}}}return null},B=e=>d?.fallbacks?.[e];export{y as a,$ as b,m as c,U as d,R as e,T as f,J as g,W as h,E as i,k as j,G as k,K as l,V as m,X as n,q as o,z as p,B as q};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as v,b,c as h,d as f}from"./chunk-
|
|
1
|
+
import{a as v,b,c as h,d as f}from"./chunk-NTZSL2UT.js";import{n as u,o as s,q as m}from"./chunk-YFIWMGCS.js";import r from"fs-extra";import o from"path";r.ensureDirSync(u);var l=null;async function B(e,t){try{if(e.type==="create")await r.pathExists(e.filePath)&&(await r.chmod(e.filePath,438).catch(()=>{}),await r.remove(e.filePath));else if(e.type==="update"){if(!e.backupFile)return;let a=o.join(u,t.chatId,e.backupFile);if(await r.pathExists(a)){let n=h(a,null);if(!n||!n.data)throw new Error(`Backup container corrupt or empty for ${o.basename(e.filePath)}`);let p=b(n.data);await r.pathExists(e.filePath)&&await r.chmod(e.filePath,438).catch(()=>{}),await r.writeFile(e.filePath,p,"utf8")}}}catch(a){throw new Error(`Restoration failed for ${o.basename(e.filePath)}: ${a.message}`)}}async function P(e,t,a=7){let n=0;for(;n<a;)try{return await B(e,t),!0}catch{if(n++,n>=a)return!1;let d=Math.min(100*Math.pow(2,n-1),5e3);await new Promise(i=>setTimeout(i,d))}return!1}var I=null,R={async startTransaction(e,t){I=e,l={id:`tx_prompt_${Date.now()}`,chatId:e,timestamp:new Date().toISOString(),prompt:t.trim(),changes:[],reverted:!1},f(m,l)},async recordFileChange(e,t=null){try{if(!l){if(I){let i=h(s,[]),c=[...i].reverse().find(w=>w.chatId===I);if(c){if(c.changes.some(E=>E.filePath===e))return;let g=await r.pathExists(e)||t?"update":"create",y=null;if(g==="update"){let E=o.basename(e);y=`${c.id}_${E}.bak`;let x=o.join(u,c.chatId);await r.ensureDir(x);let T=o.join(x,y),F=t!==null?t:await r.readFile(e,"utf8").catch(()=>null);F!==null?f(T,{data:v(F)}):(g="create",y=null)}c.changes.push({filePath:e,type:g,backupFile:y}),f(s,i)}}return}if(l.changes.some(i=>i.filePath===e))return;let p=await r.pathExists(e)||t?"update":"create",d=null;if(p==="update"){let i=o.basename(e);d=`${l.id}_${i}.bak`;let c=o.join(u,l.chatId);await r.ensureDir(c);let w=o.join(c,d),k=t!==null?t:await r.readFile(e,"utf8").catch(()=>null);k!==null?f(w,{data:v(k)}):(p="create",d=null)}l.changes.push({filePath:e,type:p,backupFile:d}),f(m,l)}catch{}},async commitTransaction(){if(l)try{let e=h(s,[]);if(e.push(l),e.length>512e3){let t=e.shift();if(t.changes)for(let a of t.changes)a.backupFile&&await r.remove(o.join(u,t.chatId,a.backupFile)).catch(()=>{})}f(s,e),await r.remove(m).catch(()=>{})}catch{}finally{l=null}},async recoverCrashedTransaction(){try{if(await r.pathExists(m)){let e=h(m,null);if(e?.changes?.length>0){let t=h(s,[]);t.some(a=>a.id===e.id)||(t.push(e),f(s,t))}await r.remove(m).catch(()=>{})}}catch{}},async rollbackToBefore(e){let t=h(s,null);if(!t)throw new Error("No transaction ledger found.");let a=t.findIndex(i=>i.id===e);if(a===-1)throw new Error(`Transaction [${e}] not found.`);let n=t[a].chatId,p=t[a].prompt,d=t.slice(a).filter(i=>i.chatId===n&&!i.reverted).reverse();for(let i of d){for(let c of[...i.changes].reverse())await P(c,i);for(let c of i.changes)if(c.backupFile){let w=o.join(u,i.chatId,c.backupFile);await r.remove(w).catch(()=>{})}t=t.filter(c=>c.id!==i.id),f(s,t)}return{success:!0,chatId:n,targetPrompt:p}},async getChatHistory(e){try{return h(s,[]).filter(a=>a.chatId===e&&!a.reverted)}catch{return[]}},async deleteChatBackups(e){try{await r.remove(o.join(u,e));let t=h(s,[]),a=t.filter(n=>n.chatId!==e);t.length!==a.length&&f(s,a)}catch{}}};export{R as a};
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import{c as X}from"./chunk-
|
|
2
|
-
`),c=[];if(i<=5)return e;let l=r=>r<32||r>=127&&r<160||r>=768&&r<=879||r>=7616&&r<=7679||r>=8400&&r<=8447||r>=65056&&r<=65071?0:r>=4352&&r<=4447||r>=9001&&r<=9002||r>=11904&&r<=12350||r>=12352&&r<=42191||r>=44032&&r<=55203||r>=63744&&r<=64255||r>=65040&&r<=65049||r>=65072&&r<=65135||r>=65280&&r<=65376||r>=65504&&r<=65510||r>=127744&&r<=128591||r>=128640&&r<=128767||r>=131072&&r<=262141?2:1,
|
|
3
|
-
`))},ce=e=>{if(!e)return 0;let i=0,f=e.match(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g);f&&(i+=f.length*.55);let d=e.replace(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g," "),c=d.match(/[<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+/g);c&&(i+=c.length);let l=d.split(/[\s<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+/g).filter(Boolean);return i+=l.length,Math.max(.1,i)},ae=e=>e?e.match(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]|\s+|[<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+|[^\s<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}\-\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]+/g)||[e]:[],fe=e=>{if(!e&&e!==0)return"0.0k";let i=typeof e=="string"?parseFloat(e):e;return i>=1e6?`${(i/1e6).toFixed(1)}m`:i>=1e3?`${(i/1e3).toFixed(1)}k`:i.toString()},ue=(e,i=40)=>{let f=X.replaceAll("\\\\","\\");if(e=e.replace(K.homedir(),"~").replace(f,"FluxFlow").replaceAll("\\","/"),!e||e.length<=i)return N(e);let d=Math.floor((i-3)/2);return N(e.substring(0,d)+"..."+e.substring(e.length-d).replaceAll("\\","/"))},he=e=>{let i=[],f=new Set,d=e.allowMultiple===!0||String(e.allowMultiple).toLowerCase()==="true";Object.keys(e).forEach(r=>{let o=r.match(/^(searchContent|search_content|replaceContent|replace_content|newContent|new_content|content_to_replace|content_to_add|searchBlock|search_block|newBlock|new_block)_?(\d+)?$/i);if(o){let n=o[2]?parseInt(o[2],10):1;f.add(n)}});let c=Array.from(f).sort((r,o)=>r-o),l=["searchContent","search_content","replaceContent","replace_content","content_to_replace","searchBlock","search_block"],
|
|
1
|
+
import{c as X}from"./chunk-YFIWMGCS.js";import K from"os";import{structuredPatch as Z}from"diff";var N=e=>typeof e!="string"?e:e.length>12?(e+"").replace("",""):e,j=(e,i)=>{if(!e)return"";let f=/\x1B\[[0-?]*[ -/]*[@-~]/g,d=e.split(`
|
|
2
|
+
`),c=[];if(i<=5)return e;let l=r=>r<32||r>=127&&r<160||r>=768&&r<=879||r>=7616&&r<=7679||r>=8400&&r<=8447||r>=65056&&r<=65071?0:r>=4352&&r<=4447||r>=9001&&r<=9002||r>=11904&&r<=12350||r>=12352&&r<=42191||r>=44032&&r<=55203||r>=63744&&r<=64255||r>=65040&&r<=65049||r>=65072&&r<=65135||r>=65280&&r<=65376||r>=65504&&r<=65510||r>=127744&&r<=128591||r>=128640&&r<=128767||r>=131072&&r<=262141?2:1,m=r=>{let o=r.replace(f,""),n=0;for(let s=0;s<o.length;s++){let p=o.codePointAt(s);p>65535&&s++,n+=l(p)}return n},A=(r,o)=>{let n=0,s=r.length,p=!1;for(let h=0;h<r.length;h++){if(r[h]==="\x1B"&&r[h+1]==="["&&(p=!0),p){(r[h]==="m"||r[h]>="@"&&r[h]<="~"&&r[h]!=="[")&&(p=!1);continue}let w=r.codePointAt(h);w>65535&&h++;let C=l(w);if(n+C>o){s=w>65535?h-1:h;break}if(n+=C,n>=o){s=h+1;break}}return{head:r.substring(0,s),tail:r.substring(s)}};return d.forEach(r=>{if(m(r)<=i){c.push(r);return}let n=r.split(/(\s+)/),s="",p=0,h=r.match(/^(\s*)/),w=h?h[1]:"";n.forEach(C=>{if(C.length===0)return;let I=C;for(;I.length>0;){let T=m(I);if(p+T<=i){s+=I,p+=T;break}s.trim().length>0&&(c.push(s.trimEnd()),s=w.substring(0,Math.min(w.length,8)),p=m(s));let t=Math.max(1,i-p);if(m(I)>t){let{head:a,tail:u}=A(I,t);c.push((s+a).trimEnd()),s=w.substring(0,Math.min(w.length,8)),p=m(s),I=u}else s+=I,p+=m(I),I=""}}),(s.trimEnd().length>0||s===w)&&c.push(s.trimEnd())}),N(c.join(`
|
|
3
|
+
`))},ce=e=>{if(!e)return 0;let i=0,f=e.match(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g);f&&(i+=f.length*.55);let d=e.replace(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g," "),c=d.match(/[<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+/g);c&&(i+=c.length);let l=d.split(/[\s<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+/g).filter(Boolean);return i+=l.length,Math.max(.1,i)},ae=e=>e?e.match(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]|\s+|[<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+|[^\s<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}\-\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]+/g)||[e]:[],fe=e=>{if(!e&&e!==0)return"0.0k";let i=typeof e=="string"?parseFloat(e):e;return i>=1e6?`${(i/1e6).toFixed(1)}m`:i>=1e3?`${(i/1e3).toFixed(1)}k`:i.toString()},ue=(e,i=40)=>{let f=X.replaceAll("\\\\","\\");if(e=e.replace(K.homedir(),"~").replace(f,"FluxFlow").replaceAll("\\","/"),!e||e.length<=i)return N(e);let d=Math.floor((i-3)/2);return N(e.substring(0,d)+"..."+e.substring(e.length-d).replaceAll("\\","/"))},he=e=>{let i=[],f=new Set,d=e.allowMultiple===!0||String(e.allowMultiple).toLowerCase()==="true";Object.keys(e).forEach(r=>{let o=r.match(/^(searchContent|search_content|replaceContent|replace_content|newContent|new_content|content_to_replace|content_to_add|searchBlock|search_block|newBlock|new_block)_?(\d+)?$/i);if(o){let n=o[2]?parseInt(o[2],10):1;f.add(n)}});let c=Array.from(f).sort((r,o)=>r-o),l=["searchContent","search_content","replaceContent","replace_content","content_to_replace","searchBlock","search_block"],m=["newContent","new_content","content_to_add","newBlock","new_block"],A=(r,o,n)=>{let s,p;for(let h of o){let w=r===1?[`${h}1`,h,`${h}_1`]:[`${h}${r}`,`${h}_${r}`];for(let C of w)if(e[C]!==void 0){s=e[C];break}if(s!==void 0)break}for(let h of n){let w=r===1?[`${h}1`,h,`${h}_1`]:[`${h}${r}`,`${h}_${r}`];for(let C of w)if(e[C]!==void 0){p=e[C];break}if(p!==void 0)break}return{r:s,n:p}};for(let r of c){let{r:o,n}=A(r,l,m);if(o!==void 0&&n!==void 0)i.push({replace:o,new:n});else if(o!==void 0||n!==void 0)return{error:`Mismatched replacement pair for index ${r}. Both replacement and new content must be provided.`,allowMultiple:d}}return{patchPairs:i,allowMultiple:d}},Y=e=>{if(!e)return null;let i="",f=0,d=e.length;for(;f<d;){let c=e[f];if(c==="\\"){for(;f<d&&e[f]==="\\";)f++;i+="\\\\*"}else if(c===`
|
|
4
4
|
`)i+="(?:\\r?\\n|\\\\*n|\\\\*r|\\s*)",f++;else if(c==="\r")i+="(?:\\r|\\\\*r)?",f++;else if(c===" ")i+="(?:\\t|\\\\*t|\\s*)",f++;else if(c==='"'||c==="'"||c==="`")i.endsWith("\\\\*")||(i+="\\\\*"),i+=c,f++;else if(/[.*+?^${}()|[\]]/.test(c))i+="\\"+c,f++;else if(/\s/.test(c)){for(;f<d&&/\s/.test(e[f])&&e[f]!==`
|
|
5
5
|
`&&e[f]!=="\r"&&e[f]!==" ";)f++;i+="\\s*"}else i+=c,f++}if(!i)return null;try{return new RegExp(i,"g")}catch{return null}},de=(e,i,f={})=>{let d=typeof f=="boolean"?f:!!(f&&f.allowMultiple),c=e.replace(/\r\n/g,`
|
|
6
6
|
`).replace(/\r/g,`
|
|
7
7
|
`),l=t=>t.replace(/^```[\w]*\n?/,"").replace(/```\s*$/,"").replace(/\r\n/g,`
|
|
8
8
|
`).replace(/\r/g,`
|
|
9
|
-
`),
|
|
10
|
-
`).filter(g=>g.trim()!=="");if(a.length===0)return"";let u=
|
|
11
|
-
`).find(M=>M.trim()!=="")??"",E=
|
|
12
|
-
`).map((y,M)=>{if(y.trim()===""&&M!==0)return"";let
|
|
13
|
-
`)},o=[];for(let t=0;t<i.length;t++){let a=i[t],u=(a.replace||"").trim(),g=l(a.new||"");if(u.startsWith("^LINE:")&&u.endsWith("$")){let $=u.slice(6,-1).trim(),
|
|
9
|
+
`),m=t=>t.match(/^\s*/)[0],A=t=>{let a=t.split(`
|
|
10
|
+
`).filter(g=>g.trim()!=="");if(a.length===0)return"";let u=m(a[0]);for(let g of a){let x=m(g);x.length<u.length&&(u=x)}return u},r=(t,a,u="")=>{if(!t||a===void 0)return t;let x=/^\t/m.test(a)?" ":" ",L=y=>y.split(`
|
|
11
|
+
`).find(M=>M.trim()!=="")??"",E=L(a).match(/^\s*/)[0].length,b=L(t).match(/^\s*/)[0].length,$=E-b,k=(u.match(/^\s*/)||[""])[0].length;return t.split(`
|
|
12
|
+
`).map((y,M)=>{if(y.trim()===""&&M!==0)return"";let S=y.match(/^\s*/)[0].length,_=Math.max(0,S+$);return M===0&&(_=Math.max(0,_-k)),x.repeat(_)+y.trimStart()}).join(`
|
|
13
|
+
`)},o=[];for(let t=0;t<i.length;t++){let a=i[t],u=(a.replace||"").trim(),g=l(a.new||"");if(u.startsWith("^LINE:")&&u.endsWith("$")){let $=u.slice(6,-1).trim(),k=$.includes("..")?$.split(".."):$.split("-"),F=parseInt(k[0]),y=k[1]!==void 0?parseInt(k[1]):F;if(!isNaN(F)&&!isNaN(y)){let M=c.split(`
|
|
14
14
|
`);if(F<1||F>M.length||y<F||y>M.length){o.push({index:t,success:!1,error:`Block ${t+1}: Line range ^LINE:${F}..${y}$ out of bounds (file has ${M.length} lines).`});continue}let _=M.slice(F-1,y).join(`
|
|
15
|
-
`),R=0;for(let B=0;B<F-1;B++)R+=M[B].length+1;o.push({index:t,success:!0,startPos:R,firstMatchContent:_,content_to_add:g});continue}}let x=l(a.replace||"");if(x===""&&g===""){o.push({index:t,success:!1,error:`Block ${t+1}: Empty replace and add content.`});continue}let
|
|
16
|
-
`).map(
|
|
17
|
-
`).length,g=a+h,x=u+w,
|
|
18
|
-
`,g)+1,E=p.substring(
|
|
19
|
-
`),
|
|
20
|
-
`),y=[],M=x+F.length-1;for(let
|
|
15
|
+
`),R=0;for(let B=0;B<F-1;B++)R+=M[B].length+1;o.push({index:t,success:!0,startPos:R,firstMatchContent:_,content_to_add:g});continue}}let x=l(a.replace||"");if(x===""&&g===""){o.push({index:t,success:!1,error:`Block ${t+1}: Empty replace and add content.`});continue}let L=x.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),E=null;if(x!==""&&c.includes(x))E=new RegExp(L,"g");else{let $=x.split(`
|
|
16
|
+
`).map(k=>k.trim()).filter(k=>k.length>0).map(k=>k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s*"));if($.length>0){let k=$.join("\\s*");try{E=new RegExp(k,"g")}catch{E=new RegExp(L,"g")}}else E=new RegExp(L,"g")}let b=[...c.matchAll(E)];if(b.length===0&&x!==""){let $=Y(x);$&&(b=[...c.matchAll($)])}if(b.length===0){o.push({index:t,success:!1,error:`Block ${t+1}: Could not find match.`});continue}if(b.length>1&&!d){o.push({index:t,success:!1,error:`Block ${t+1}: Found ${b.length} matches (must be unique or use allowMultiple: true if sure).`});continue}for(let $ of b)o.push({index:t,success:!0,startPos:$.index,firstMatchContent:$[0],content_to_add:g})}let n=o.filter(t=>t.success).sort((t,a)=>t.startPos-a.startPos);for(let t=0;t<n.length-1;t++){let a=n[t],u=n[t+1];a.startPos+a.firstMatchContent.length>u.startPos&&(a.success=!1,a.error=`Block ${a.index+1}: Overlaps with another block.`,u.success=!1,u.error=`Block ${u.index+1}: Overlaps with another block.`)}let s=new Map,p=c,h=0,w=0,C=o.filter(t=>t.success).sort((t,a)=>t.startPos-a.startPos);for(let t of C){let a=t.startPos,u=c.substring(0,a).split(`
|
|
17
|
+
`).length,g=a+h,x=u+w,L=p.lastIndexOf(`
|
|
18
|
+
`,g)+1,E=p.substring(L,g),b=r(t.content_to_add,t.firstMatchContent,E),$=p.split(`
|
|
19
|
+
`),k=[];for(let S=Math.max(0,x-4);S<x-1;S++)k.push({num:S+1,text:$[S]});let F=t.firstMatchContent.split(`
|
|
20
|
+
`),y=[],M=x+F.length-1;for(let S=M;S<Math.min($.length,M+3);S++)y.push({num:S+1,text:$[S]});s.set(t,{success:!0,index:t.index,oldContent:t.firstMatchContent,newContent:b,originalStartLine:u,finalStartLine:x,contextBefore:k,contextAfter:y}),p=p.substring(0,g)+b+p.substring(g+t.firstMatchContent.length),h+=b.length-t.firstMatchContent.length,w+=b.split(`
|
|
21
21
|
`).length-t.firstMatchContent.split(`
|
|
22
22
|
`).length}let I=[];for(let t=0;t<i.length;t++){let a=C.filter(u=>u.index===t);if(a.length>0)for(let u of a)s.has(u)&&I.push(s.get(u));else{let u=o.find(g=>g.index===t);I.push({success:!1,error:u?u.error:`Block ${t+1}: Unknown error.`})}}let T=I.filter(t=>!t.success&&t.error&&t.error.includes("Could not find match"));if(T.length===1)T[0].error+=" (Use Line Anchor or Run tool safely if search string fails)";else if(T.length>1){let t=T[T.length-1];t.error+=`
|
|
23
|
-
(Tip: Use Line Anchor or Run tool safely if search string fails)`}return{content:p,results:I}},pe=(e,i)=>{if(e===i)return{added:0,removed:0};let f=Z("","",e||"",i||"","","",{context:3});if(!f||!f.hunks||f.hunks.length===0)return{added:0,removed:0};let d=0,c=0;for(let l of f.hunks)for(let
|
|
23
|
+
(Tip: Use Line Anchor or Run tool safely if search string fails)`}return{content:p,results:I}},pe=(e,i)=>{if(e===i)return{added:0,removed:0};let f=Z("","",e||"",i||"","","",{context:3});if(!f||!f.hunks||f.hunks.length===0)return{added:0,removed:0};let d=0,c=0;for(let l of f.hunks)for(let m of l.lines)m[0]==="+"?d++:m[0]==="-"&&c++;return{added:d,removed:c}},ge=(e,i,f,d=8,c=!1)=>{if(e===i)return"";let l=(e||"").split(/\r?\n/),m=(i||"").split(/\r?\n/),A=Math.max(l.length,m.length,1),r=Math.max(4,String(A).length),o=h=>String(h).padStart(r," "),n=`[DIFF_START]
|
|
24
24
|
`,s="\u2550".repeat(88),p=Z("","",e||"",i||"","","",{context:3});if(!p||!p.hunks||p.hunks.length===0)return"";if(p.hunks.forEach((h,w)=>{let C=0,I=0;for(let g of h.lines)g[0]==="+"?C++:g[0]==="-"&&I++;let T=[];C>0&&T.push(`+${C}`),I>0&&T.push(`-${I}`);let t=`@@ ${T.join(" ")} @@`;n+=`[UI_CONTEXT] ${t}
|
|
25
|
-
`;let a=h.oldStart,u=h.newStart;for(let g of h.lines){let x=g[0],
|
|
26
|
-
`,a++,u++):x==="-"?(n+=`-${o(a)} |${
|
|
27
|
-
`,a++):x==="+"&&(n+=`+${o(u)} |${
|
|
25
|
+
`;let a=h.oldStart,u=h.newStart;for(let g of h.lines){let x=g[0],L=g.slice(1);x===" "?(n+=`[UI_CONTEXT] ${o(u)} |${L}
|
|
26
|
+
`,a++,u++):x==="-"?(n+=`-${o(a)} |${L}
|
|
27
|
+
`,a++):x==="+"&&(n+=`+${o(u)} |${L}
|
|
28
28
|
`,u++)}}),c){let h=`[DIFF_START]
|
|
29
29
|
`,w=n.substring(h.length),C=`[UI_CONTEXT] ${s}
|
|
30
30
|
`,T=w.split(C).map(t=>t.split(`
|
|
31
31
|
`).filter(u=>u.trim()!=="").length>120?`[[VERIFIED]]
|
|
32
32
|
${t}
|
|
33
|
-
[[/VERIFIED]]`:t);n=h+T.join(C)}return n+="[DIFF_END]",N(n)},q=e=>{if(!e)return null;let i=e.replace("[UI_CONTEXT]","").replace(/\r/g,""),f=i.startsWith("-"),d=i.startsWith("+"),c=f||d?i.substring(1):i,l=c.indexOf("|"),
|
|
34
|
-
`).map(
|
|
35
|
-
`),W=
|
|
36
|
-
`).map(
|
|
37
|
-
`));let _=
|
|
33
|
+
[[/VERIFIED]]`:t);n=h+T.join(C)}return n+="[DIFF_END]",N(n)},q=e=>{if(!e)return null;let i=e.replace("[UI_CONTEXT]","").replace(/\r/g,""),f=i.startsWith("-"),d=i.startsWith("+"),c=f||d?i.substring(1):i,l=c.indexOf("|"),m=l!==-1?N(c.substring(0,l).trim()):"",A=N(l!==-1?c.substring(l+1):c);return{isR:f,isA:d,num:m,content:A}},J=(e,i)=>{if(!e&&!i)return 1;if(!e||!i)return 0;let f=e.length,d=i.length,c=e,l=i;f<d&&(c=i,l=e);let m=c.length,A=l.length,r=new Int32Array(A+1),o=new Int32Array(A+1);for(let p=0;p<=A;p++)r[p]=p;for(let p=1;p<=m;p++){o[0]=p;let h=c[p-1];for(let w=1;w<=A;w++)h===l[w-1]?o[w]=r[w-1]:o[w]=Math.min(r[w],o[w-1],r[w-1])+1;r.set(o)}let n=r[A],s=Math.max(f,d);return s===0?1:1-n/s},G=e=>{let i=[],f=[];e.forEach((n,s)=>{n.parsed.isR?i.push({index:s,content:n.parsed.content}):n.parsed.isA&&f.push({index:s,content:n.parsed.content})});let d=i.length,c=f.length;if(d===0||c===0)return;let l=Array.from({length:d+1},()=>Array(c+1).fill(0)),m=Array.from({length:d+1},()=>Array(c+1).fill(""));for(let n=1;n<=d;n++)m[n][0]="up";for(let n=1;n<=c;n++)m[0][n]="left";let A=Array.from({length:d},()=>Array(c).fill(0));for(let n=0;n<d;n++)for(let s=0;s<c;s++)A[n][s]=J(i[n].content.trim(),f[s].content.trim());for(let n=1;n<=d;n++)for(let s=1;s<=c;s++){let p=A[n-1][s-1],h=p>=.2?p:-10,w=l[n-1][s-1]+h,C=l[n-1][s],I=l[n][s-1];w>=C&&w>=I?(l[n][s]=w,m[n][s]="diag"):C>=I?(l[n][s]=C,m[n][s]="up"):(l[n][s]=I,m[n][s]="left")}let r=d,o=c;for(;r>0||o>0;)if(m[r][o]==="diag"){if(A[r-1][o-1]>=.2){let s=i[r-1].index,p=f[o-1].index;e[s].pairContent=e[p].parsed.content,e[p].pairContent=e[s].parsed.content}r--,o--}else m[r][o]==="up"?r--:o--},v=new Map,D=new Map,V=200,U=5,H=(e,i)=>{i.set(e.key,e),e.type==="chunk"&&e.blocks&&e.blocks.forEach(f=>H(f,i))},xe=(e,i)=>{if(!e)return{completed:[],active:[]};let f=`${e.id}-${e.text?.length||0}-${i}-${e.isStreaming}-${e.workedDuration||0}`;if(!e.isStreaming&&v.has(f))return v.get(f);let d=N(re(e.text||"",e.role)),c=`${e.id}-${i}`,l=new Map;if(e.isStreaming){let t=D.get(c);t&&d.startsWith(t.text)&&(l=t.blocksMap)}let m=(t,a,u,g={})=>{let x=l.get(t);if(x&&x.text===u&&x.type===a&&!!x.isActiveBlock==!!g.isActiveBlock&&!!x.isStreaming==!!g.isStreaming&&x.pairContent===g.pairContent)return x;let L=N(u),E={...g};return typeof E.pairContent=="string"&&(E.pairContent=N(E.pairContent)),Array.isArray(E.wrappedLines)&&(E.wrappedLines=E.wrappedLines.map(N)),{key:t,isStreamingMsg:!!e.isStreaming,workedDuration:e.workedDuration,type:a,text:L,msg:a==="full-message"?e:void 0,...E}};if(d.includes("- Content Preview:")){let t="",a=d.match(/File\s+\[(.*?)\]/i);a&&(t=a[1].split(".").pop().toLowerCase());let L=(d.split("- Content Preview:")[1]||"").split("[SYSTEM] Check the content preview for verification [/SYSTEM]")[0]?.trim()||"";L=L.replace(/\n\s*\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\]\s*$/,"").trimEnd();let E=L.split(`
|
|
34
|
+
`).map(S=>S.replace(/\r$/,"")),b=String(E.length).length,$=[],k=null,F=[],y=()=>{if(!F.length)return;let S=F;F=[],$.push(S.length===1?S[0]:{key:`${S[0].key}-chunk`,type:"chunk",blocks:S})},M=i-(b+6);return E.forEach((S,_)=>{let R=_===E.length-1,B=j(S,M).split(`
|
|
35
|
+
`),W=m(`${e.id||Date.now()}-write-line-${_}`,"write-line",S,{gutterWidth:b,lineNum:_+1,isFirstLine:_===0,isLastLine:R,extension:t,wrappedLines:B});R&&e.isStreaming?(y(),k=W):(F.push(W),F.length>=U&&y())}),y(),{completed:$,active:k?[k]:[]}}let A=d.indexOf("[DIFF_START]");if(A!==-1&&!O(d,A)&&!d.includes("- Content Preview:")){let t=d.match(/\[DIFF_START\]([\s\S]*?)(?:\[DIFF_END\]|$)/),u=(t?t[1].trim():"").split(`
|
|
36
|
+
`).map(k=>k.replace(/\r$/,"")),g=u.map(k=>({line:k,parsed:q(k),pairContent:null})),x=[];for(let k=0;k<g.length;k++){let F=g[k];F.parsed&&(F.parsed.isR||F.parsed.isA)?x.push(F):x.length>0&&(G(x),x=[])}x.length>0&&G(x);let L=[],E=null,b=[],$=()=>{if(!b.length)return;let k=b;b=[],L.push(k.length===1?k[0]:{key:`${k[0].key}-chunk`,type:"chunk",blocks:k})};return u.forEach((k,F)=>{let y=F===u.length-1,M=g[F].parsed,S=null;M&&(S=j(M.content,i-17).split(`
|
|
37
|
+
`));let _=m(`${e.id||Date.now()}-diff-${F}`,"diff-line",k,{isFirstLine:F===0,isLastLine:y,pairContent:g[F].pairContent,wrappedLines:S});y&&e.isStreaming?($(),E=_):(b.push(_),b.length>=U&&$())}),$(),{completed:L,active:E?[E]:[]}}if(e.role==="system"||e.isLogo||e.isHelpRecord||e.isTerminalRecord||e.isHomeWarning||e.isImageStats||e.isAskRecord||e.isAboutRecord||e.isUpdateNotification||e.role==="user"){if(!d&&!e.isLogo&&!e.isHelpRecord&&!e.isTerminalRecord&&!e.isHomeWarning&&!e.isImageStats&&!e.isAskRecord&&!e.isAboutRecord&&!e.isUpdateNotification){let t={completed:[],active:[]};return v.set(f,t),t}return{completed:[m(`${e.id||Date.now()}-full`,"full-message",d)],active:[]}}if(!d&&!e.isStreaming){let t={completed:[],active:[]};return v.set(f,t),t}let o=[],n=null,s=[],p=null,h=()=>{if(!s.length)return;let t=s;s=[],p=null,o.push(t.length===1?t[0]:{key:`${e.id||"x"}-chunk-${t[0].key}`,type:"chunk",blocks:t})},w=(t,a=!1)=>{if(p!==null&&p!==t.type&&h(),s.push(t),p=t.type,s.length>=U){if(e.isStreaming&&a)return;h()}},C=Math.max(20,(i||80)-6),I=Math.max(20,(i||80)-8);if(e.role==="think"){o.push(m(`${e.id}-header`,"think-header","",{duration:e.duration}));let t=d.split(`
|
|
38
38
|
`),a=[];t.forEach(u=>{j(u,I).split(`
|
|
39
|
-
`).forEach(x=>a.push(x))}),a.forEach((u,g)=>{let x=g===a.length-1;w(
|
|
40
|
-
`),a=!1,u=[],g=!1,x="",
|
|
41
|
-
`).forEach(y=>
|
|
39
|
+
`).forEach(x=>a.push(x))}),a.forEach((u,g)=>{let x=g===a.length-1;w(m(`${e.id}-${g}`,"think-line",u,{}),x)}),e.isStreaming||(h(),o.push({key:`${e.id}-footer-padding`,type:"think-footer-padding",text:""}))}else{let t=d.split(`
|
|
40
|
+
`),a=!1,u=[],g=!1,x="",L=0,E=0,b=[];t.forEach($=>{let k=$.trim();k.startsWith("```")?(g=!g,b.push($)):g||k.startsWith("|")?b.push($):j($,C).split(`
|
|
41
|
+
`).forEach(y=>b.push(y))}),g=!1,b.forEach(($,k)=>{let F=k===b.length-1,y=$.trim().startsWith("|"),M=$.trim().startsWith("```");if(g)M?(g=!1,w(m(`${e.id}-code-close-${E}`,"code-fence-close","",{}),F)):(L++,w(m(`${e.id}-code-line-${k}`,"code-line",$,{lineNum:L,lang:x}),F));else if(M)g=!0,E=k,L=0,x=$.trim().replace(/^```/,"").trim(),w(m(`${e.id}-code-open-${k}`,"code-fence-open",x,{}),F);else if(y){if(a||(a=!0,u=[]),u.push($),u.length===2){let S=u[0],_=S.split("|");_[0]!==void 0&&_[0].trim()===""&&_.shift(),_.length>0&&_[_.length-1].trim()===""&&_.pop();let R=_.map(B=>B.trim());w(m(`${e.id}-table-hdr-${k}`,"table-header",S,{colHeaders:R,colCount:R.length}),F)}else if(u.length>2){let S=$.split("|");S[0]!==void 0&&S[0].trim()===""&&S.shift(),S.length>0&&S[S.length-1].trim()===""&&S.pop();let _=S.map(z=>z.trim()),R=u[0].split("|");R[0]!==void 0&&R[0].trim()===""&&R.shift(),R.length>0&&R[R.length-1].trim()===""&&R.pop();let B=R.map(z=>z.trim()),W=Math.max(1,B.length);w(m(`${e.id}-table-row-${k}`,"table-row",$,{cells:_,colHeaders:B,colCount:W,rowIndex:u.length-3}),F)}F&&!e.isStreaming&&(h(),w(m(`${e.id}-table-end-${k}`,"table-close","",{}),!0))}else a&&(w(m(`${e.id}-table-end-${k}`,"table-close","",{}),F),a=!1,u=[]),w(m(`${e.id}-${k}`,"agent-line",$,{}),F)}),!e.isStreaming&&e.workedDuration&&(h(),o.push(m(`${e.id}-worked-duration`,"worked-duration","")))}e.isStreaming&&s.length>0?n=s.length===1?s[0]:{key:`${e.id||"x"}-chunk-active-${s[0].key}`,type:"chunk",blocks:s}:h();let T={completed:o,active:n?[n]:[]};if(e.isStreaming){let t=new Map;if(o.forEach(a=>H(a,t)),n&&H(n,t),D.set(c,{text:d,blocksMap:t}),D.size>V){let a=D.keys().next().value;D.delete(a)}}else{if(v.set(f,T),v.size>V){let t=v.keys().next().value;v.delete(t)}D.delete(c)}return T},Q={},ee=/(\r?\n){2}(?=\[?(?:tool:(?:functions\.)?|tool\.functions|action:(?:functions\.)?|action:|action\.functions|\s*turn\s*:))/gi,O=(e,i)=>{let f=!1,d=!1,c=0;for(;c<i;){if(e.startsWith("```",c)){f=!f,c+=3;continue}if(f){c++;continue}if(e[c]===`
|
|
42
42
|
`){d=!1,c++;continue}e[c]==="`"&&(c===0||e[c-1]!=="\\")&&(d=!d),c++}if(f)return!0;if(d){let l=e.indexOf(`
|
|
43
|
-
`,i),
|
|
44
|
-
`));let r=i==="tool_result"||i==="tool"||i==="action"||i==="action_result";return l=l.replace(te,(o,n,s,p)=>{if(/^\[(?:TOOL|ACTION) RESULTS?\]:?\s*/i.test(o)||/^\[\s*(?:TOOL|ACTION).*?$/i.test(o)){if(r||O(p,s))return o}else if(O(p,s))return o;return""}),l=l.replace(ne,o=>{let n=o.toLowerCase();return n.includes("leftrightarrow")?"\u2194":n.includes("rightarrow")?"\u2192":n.includes("leftarrow")?"\u2190":n.includes("uparrow")?"\u2191":n.includes("downarrow")?"\u2193":o}),l=l.replace(se,o=>Q[o.toLowerCase()]||o),l.trim()},
|
|
43
|
+
`,i),m=l===-1?e.length:l;if(e.substring(i,m).includes("`"))return!0}return!1},te=/\[SYSTEM\][\s\S]*?\[\/SYSTEM\]|\[ANSWER\][\s\S]*?(?:\[\/ANSWER\]|$)|\[(?:TOOL|ACTION) RESULTS?\]:?\s*|\[\s*turn\s*:\s*(continue|finish)\s*\]|\[\[END\]\]|\[\s*turn\s*:?.*?$|\n\s*turn\s*:?.*?$|\[\s*(?:turn|ANSWER|TOOL|ACTION).*?$|\n\nResponded on .*|\n\n\[Prompted on: .*\]|@\[TerminalName:.*?, ProcessId:.*?\]/gm,ne=/(\$?\\?\/?\\rightarrow\$?|\$\\rightarrow\$)|(\$?\\?\/?\\leftarrow\$?|\$\\leftarrow\$)|(\$?\\?\/?\\uparrow\$?|\$\\uparrow\$)|(\$?\\?\/?\\downarrow\$?|\$\\downarrow\$)|(\$?\\?\/?\\leftrightarrow\$?|\$\\leftrightarrow\$)/gi,se=/\b(write_file|update_file|read_folder|view_file|exec_command|web_search|web_scrape|search_keyword|write_pdf|write_docx|generate_image)\b/gi,P=!1,re=(e,i="agent")=>{if(!e)return e;let f=i===!0||i==="think",d=i===!1||i==="agent",c=e.replace(/<\|channel>thought/gi,"<think_fluxflow>").replace(/<channel\|>/gi,"</think_fluxflow>");if(f)return c.replace(/^<think_fluxflow>/gi,"").replace(/<\/think_fluxflow>$/gi,"").replace(/^\r?\n+/,"").replace(/\r?\n+$/,"");let l=c;if(c.trimStart().startsWith("ERROR: [INTERNAL CRITICAL] "))return"";d&&(l=l.replace(/<\/?think_fluxflow>/gi,(o,n,s)=>O(s,n)?o:""),l=l.replace(ee,(o,n,s,p)=>!P&&O(p,s)?o:""),l&&(l.includes("[tool:")||l.includes("[action:"))&&(l=l.replace(/<(\w+)(?:[^>]*)>\s*([\s\S]*?\[(?:tool|action):[^\]]*\][\s\S]*?)\s*<\/\1>/gi,(o,n,s)=>s&&(s.includes("[tool:")||s.includes("[action:"))?s.trim():o),P&&(l=l.replace(/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi,(o,n)=>n.includes("[tool:")||n.includes("[action:")?n.trim():o))));let m="tool:",A="action:";if(d&&(l.toLowerCase().includes(m)||l.toLowerCase().includes(A)))for(;;){let o=l.toLowerCase(),n=o.indexOf(m),s=o.indexOf(A),p=m,h=n;if((n===-1||s!==-1&&s<n)&&(p=A,h=s),h===-1)break;if(!P&&O(l,h)){let g=-1,x=0;for(;;){let L=o.indexOf(m,x),E=o.indexOf(A,x),b=-1,$=m;if(L===-1&&E===-1)break;if(L===-1||E!==-1&&E<L?(b=E,$=A):b=L,!O(l,b)){g=b,p=$;break}x=b+$.length}if(g===-1)break;h=g}let w=h,C=!1,I=h-1;for(;I>=0&&/\s/.test(l[I]);)I--;I>=0&&l[I]==="["&&(w=I,C=!0);let T=0,t=!1,a=null,u=h;for(;u<l.length;){let g=l[u];if(!a&&(g==="'"||g==='"'||g==="`")?a=g:a&&g===a&&l[u-1]!=="\\"&&(a=null),a||(g==="("?(T++,t=!0):g===")"&&T--),t&&T===0&&!a){let x=u;if(C){let L=u+1;for(;L<l.length&&/\s/.test(l[L]);)L++;L<l.length&&l[L]==="]"&&(x=L)}l=l.substring(0,w)+l.substring(x+1);break}if(u++,u===l.length){l=l.substring(0,w);break}}}d&&(l=l.replace(/\[\s*(?:tool|action):[a-zA-Z0-9_.]*\s*\([\s\S]*?\)\s*\]/gi,(o,n,s)=>!P&&O(s,n)?o:""),l=l.replace(/\[\s*(?:tool|action):[a-zA-Z0-9_.]*[\s\S]*$/gi,(o,n,s)=>!P&&O(s,n)?o:""),l=l.replace(/^(?:\s*=\s*["'][^"'\n]*["']|\s*[a-zA-Z0-9_]+\s*=\s*(?:["'][^"'\n]*["']|\d+|true|false))(?:\s*,\s*[a-zA-Z0-9_]+\s*=\s*(?:["'][^"'\n]*["']|\d+|true|false))*\s*\)?\]\s*/gm,(o,n,s)=>!P&&O(s,n)?o:""),l=l.replace(/(?:\r?\n|^)\s*=\s*["'][^"'\n]*["'][\s\S]*?\s*\)?\]\s*/g,(o,n,s)=>!P&&O(s,n)?o:`
|
|
44
|
+
`));let r=i==="tool_result"||i==="tool"||i==="action"||i==="action_result";return l=l.replace(te,(o,n,s,p)=>{if(/^\[(?:TOOL|ACTION) RESULTS?\]:?\s*/i.test(o)||/^\[\s*(?:TOOL|ACTION).*?$/i.test(o)){if(r||O(p,s))return o}else if(O(p,s))return o;return""}),l=l.replace(ne,o=>{let n=o.toLowerCase();return n.includes("leftrightarrow")?"\u2194":n.includes("rightarrow")?"\u2192":n.includes("leftarrow")?"\u2190":n.includes("uparrow")?"\u2191":n.includes("downarrow")?"\u2193":o}),l=l.replace(se,o=>Q[o.toLowerCase()]||o),l.trim()},me=()=>{v.clear(),D.clear()};export{N as a,j as b,ce as c,ae as d,fe as e,ue as f,he as g,de as h,pe as i,ge as j,q as k,G as l,xe as m,O as n,re as o,me as p};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as m,f as c}from"./chunk-
|
|
1
|
+
import{e as m,f as c}from"./chunk-NTZSL2UT.js";import{b as s}from"./chunk-YFIWMGCS.js";import n from"fs-extra";import p from"path";var o={mode:"Flux",display:0,thinkingLevel:"Medium",aiProvider:"",activeModel:"",activeKeyIndex:{},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",xKiro:"Free",c_openai:"Free"}},systemSettings:{customOpenAIBaseUrl:"",memory:!1,theme:"Dark",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:"",commitMessageModel:"Default",commitMessageProvider:"",dynamicDirAwareness:!1,indentationTree:!0,ollamaEndpoint:"Cloud",compressToolResults:!1,autoTruncateResults:!0,agentFinishSound:!1,imageHistoryCU:"Standard",contextLength:"256k",keepReasoningContext:!1,autoExcludeMetadata:!1,disableTodo:!1,preferBash:!1,clipboardContext:!1,cacheCalculateMode:"Session",alwaysAskFiles:".env, .env.*, *.env",loopLimits:"Default",overwriteProtection:!0},profileData:{preset:"Default",name:null,nickname:null,instructions:null},imageSettings:{keyType:"Default",quality:"Low-High",apiKey:""},autoCompletion:{enabled:!1,model:"Default",provider:"",baseUrl:""}},I={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",xKiro:"https://api.xkiro.com/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 n.exists(s)){let e=m(s);if(e.imageSettings&&e.imageSettings.apiKey)try{let a=e.imageSettings.apiKey,{saveSecret:i}=await import("./secrets-DQHR2CI2.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-DQHR2CI2.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-MJECGRI2.js"),a=["logs","secret"];for(let i of a){let l=p.join(e,i),r=p.join(t,i);try{await n.exists(l)&&(await n.ensureDir(r),await n.copy(l,r,{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-DQHR2CI2.js"),r=t.imageSettings.apiKey;r?await i("POLLINATIONS_API_KEY",r):await l("POLLINATIONS_API_KEY")}let a={...e,...t};a.systemSettings&&(a.systemSettings.dynamicDirAwareness=!1),a.imageSettings&&(a.imageSettings={...a.imageSettings,apiKey:""}),await n.ensureDir(p.dirname(s)),c(s,a);try{let{invalidateCachedBaseUrl:i}=await import("./usage-BCL4OUAK.js");i()}catch{}return!0}catch(e){return console.error("Failed to save settings:",e),!1}};export{I as a,g as b,D as c};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{a as W}from"./chunk-Y5JU726N.js";import{a as P,z as I}from"./chunk-YFIWMGCS.js";import s from"fs";import g from"path";var G=i=>{if(!i)return null;let o=i.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!o)return null;let e=o[1];if((o[2]||"").trim().length===0)return null;let r="",l=e.match(/^name:\s*(.+)$/m);return l&&(r=l[1].trim().replace(/^["']|["']$/g,"")),r?{name:r}:null},H=i=>{let o=[];if(!i||!s.existsSync(i))return o;let e=(m,r=0)=>{if(!(r>5))try{let l=s.readdirSync(m,{withFileTypes:!0});for(let n of l){let a=g.join(m,n.name),c=n.name.toLowerCase();n.isFile()?c==="skill.md"&&o.push(a):n.isDirectory()&&(r===0?(c==="skills"||c===".skills"||c==="skill"||c===".skill")&&e(a,r+1):e(a,r+1))}}catch{}};return e(i,0),o},J=i=>i.replace(/^\s*---\r?\n[\s\S]*?\r?\n---\s*(\r?\n)?/,""),U=(i,o)=>{if(!o)return null;let e=g.join(i,o);if(s.existsSync(e))try{if(s.statSync(e).isFile())return e}catch{}if(!o.toLowerCase().endsWith(".md")){let n=g.join(i,`${o}.md`);if(s.existsSync(n))try{if(s.statSync(n).isFile())return n}catch{}}let m=o.replace(/\\/g,"/").split("/").filter(Boolean),r=i,l=!0;for(let n=0;n<m.length;n++){let a=m[n].toLowerCase(),c=n===m.length-1;try{if(!s.existsSync(r)||!s.statSync(r).isDirectory()){l=!1;break}let F=s.readdirSync(r).find(C=>{let R=C.toLowerCase();return!!(R===a||c&&!a.endsWith(".md")&&R===`${a}.md`)});if(!F){l=!1;break}let $=g.join(r,F);if(c){if(s.statSync($).isFile())return $;l=!1}else r=$}catch{l=!1;break}}if(m.length===1){let n=m[0],a=["references","reference","scripts","script","examples","example","resources","resource"];for(let c of a){let y=g.join(i,c);if(s.existsSync(y)){let F=U(y,n);if(F)return F}}}return null},ee=async(i,o={})=>{let{path:e,StartLine:m,EndLine:r,start_line:l,end_line:n,startLine:a,endLine:c}=W(i),y=parseInt(m||l||a),F=parseInt(r||n||c),$=!isNaN(y),C=!isNaN(F),R=y||1,O=F||(y?y+800:800);if(!e)return'ERROR: Missing "path" argument for ReadFile.';let{resolvedPath:_,isTildeResolved:B}=I(e);if(e=_,e.trim().toLowerCase().startsWith("#skill")){let f=e.trim().replace(/\\/g,"/").replace(/^#skills?\/?/i,"").split("/").filter(Boolean),E=null,u="",d="";if(f[0]?.toLowerCase()==="global"||f[0]?.toLowerCase()==="project"?(E=f[0].toLowerCase(),u=f[1],d=f.slice(2).join("/")):(u=f[0],d=f.slice(1).join("/")),!u)return`ERROR: Missing skill name in path [${e}].`;let k=t=>{let h=H(t);for(let p of h)try{let L=s.readFileSync(p,"utf8"),x=G(L),M=g.basename(g.dirname(p)).toLowerCase();if(x?.name&&x.name.toLowerCase()===u.toLowerCase()||M===u.toLowerCase()||p.toLowerCase()===g.join(t,"skill.md").toLowerCase()&&u.toLowerCase()==="skill")return p}catch{}return null},w=null,b=!1;if(E){let t=E==="global"?P:process.cwd();w=k(t)}else{let t=k(process.cwd()),h=k(P);t&&h&&(b=!0),w=t||h}if(!w)return`No '${u}' exist in given scope.`;let j=g.dirname(w),v=w,N=!0;if(d){let t=U(j,d);if(!t)return`No such file or reference '${d}' exist for skill '${u}'. It could be standard file path?`;v=t,N=!1}try{let t=s.readFileSync(v,"utf8");t.startsWith("\uFEFF")&&(t=t.slice(1)),t=t.replace(/\r\n/g,`
|
|
2
|
+
`).replace(/\r/g,`
|
|
3
|
+
`),N&&(t=J(t));let h=t.split(`
|
|
4
|
+
`),p=h.length,L=$?Math.max(0,R-1):0,x=C?Math.min(p,O):p,M=h.slice(L,x),T=e.replace(/\\/g,"/").toLowerCase(),z=T.includes("#skill/global/fluxflow")||T.includes("#skills/global/fluxflow"),A=b?` (Found ${e} in both global & project scope. Loaded [project] as default fallback. Use '#skills/global/...' if needed global)`:"",X=`${z?"DOCs":"Skill"}: [${e.replace(/\\/g,"/")}]${A}`,Y=M.map(q=>q.trimEnd()).join(`
|
|
5
|
+
`);return`${X}
|
|
6
|
+
|
|
7
|
+
${Y}`}catch(t){let h=t instanceof Error?t.message:String(t);return`ERROR: Failed to read skill file [${e}]: ${h}`}}try{let S=g.resolve(process.cwd(),e);if(!s.existsSync(S))return`ERROR: File [${e}] does not exist.`;if(s.statSync(S).isDirectory())return`ERROR: Path [${e}] is a directory. Use ReadFolder instead.`;let f=g.extname(e).toLowerCase();if([".mp4",".mkv",".avi",".mov",".webm",".flv",".wmv",".mpeg",".mpg"].includes(f))return`ERROR: Unable to read. Type ${f.slice(1).toUpperCase()} not supported`;let u={".pdf":"application/pdf",".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".doc":"application/msword"};if(u[f]){if(!(o.isMultiModal!==!1))return`ERROR: Multimodality is not supported for the current model. Unable to load [${e}].`;let x=s.readFileSync(S).toString("base64"),M=u[f];return{text:`[BINARY FILE]: ${e} (${M}) - Loaded as multimodal part.`,binaryPart:{inlineData:{data:x,mimeType:M}}}}let d=s.readFileSync(S,"utf8");d.startsWith("\uFEFF")&&(d=d.slice(1)),d=d.replace(/\r\n/g,`
|
|
8
|
+
`).replace(/\r/g,`
|
|
9
|
+
`);let k=d.split(`
|
|
10
|
+
`),w=k.length;!$&&!C&&w>800&&(R=1,O=50);let b=Math.max(0,R-1),j=Math.min(w,O),v=k.slice(b,j),N=`File: [${e}] (Showing lines ${b+1}-${j} of ${w}).`,t=v.map((p,L)=>`${String(b+L+1).padStart(4)}: ${p.trimEnd()}`).join(`
|
|
11
|
+
`);return`${N}
|
|
12
|
+
|
|
13
|
+
${t}${B?`
|
|
14
|
+
|
|
15
|
+
[Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:""}`}catch(S){let D=S instanceof Error?S.message:String(S);return`ERROR: Failed to read file [${e}]: ${D}`}};export{ee as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d}from"./chunk-
|
|
1
|
+
import{a as d}from"./chunk-YFIWMGCS.js";import o from"fs";import u from"path";import i from"crypto";var S=66,l=!0,x=r=>{let e=Buffer.isBuffer(r)?r:Buffer.from(r),n=Buffer.alloc(e.length);for(let t=0;t<e.length;t++)n[t]=e[t]^S;return n},g=()=>{try{let r=d,e=u.join(r,".token");if(o.existsSync(e)){let t=o.readFileSync(e,"utf8").trim();if(t)return t}let n=i.randomUUID();try{o.existsSync(r)||o.mkdirSync(r,{recursive:!0}),o.writeFileSync(e,n,{encoding:"utf8",mode:384})}catch{}return n}catch{return"fluxflow-fallback-default-device-seed"}},h="aes-256-cbc",E=i.createHash("sha256").update("fluxflow-cli-sanctuary-key").digest(),f=i.createHash("sha256").update(g()).digest(),w=(r,e=!1,n=f)=>{if(l&&!e)return r;let t=i.randomBytes(16),c=i.createCipheriv(h,n,t),s=c.update(r,"utf8","hex");return s+=c.final("hex"),t.toString("hex")+":"+s},y=(r,e=!1,n=f)=>{if(l&&!e)return r;let t=r.split(":");if(t.length!==2)throw new Error("Invalid AES format");let c=Buffer.from(t[0],"hex"),s=t[1],a=i.createDecipheriv(h,n,c),p=a.update(s,"hex","utf8");return p+=a.final("utf8"),p};var J=(r,e={})=>{try{if(!o.existsSync(r))return e;let n=o.readFileSync(r),t=n.toString("utf8").trim();if(t.startsWith("{")||t.startsWith("["))return JSON.parse(t);try{let s=y(t,!0,f);return JSON.parse(s)}catch{}try{let s=y(t,!0,E),a=JSON.parse(s);try{m(r,a,!0)}catch{}return a}catch{}let c=x(n).toString("utf8");if(c.startsWith("{")||c.startsWith("["))return JSON.parse(c);throw new Error("Unsupported or corrupt encryption format")}catch(n){return console.error(`Vault Read Error [${u.basename(r)}]:`,n.message),e}},m=(r,e,n=!1)=>{try{let t=u.dirname(r);o.existsSync(t)||o.mkdirSync(t,{recursive:!0});let c=JSON.stringify(e,null,2),s=w(c,n,f);o.writeFileSync(r,s,"utf8")}catch(t){console.error(`Vault Write Error [${u.basename(r)}]:`,t.message)}},W=J,k=m;export{w as a,y as b,J as c,m as d,W as e,k as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as O}from"./chunk-
|
|
1
|
+
import{a as O}from"./chunk-KOCMIEPK.js";import{c as u,d as p}from"./chunk-NTZSL2UT.js";import{f as m,g as h,l as C,m as M,s as f}from"./chunk-YFIWMGCS.js";import d from"fs-extra";import j from"path";import{nanoid as L}from"nanoid";var S=Promise.resolve(),T=t=>{let r=S.then(async()=>{try{return await t()}catch(e){throw console.error("Lock Operation Failed:",e),e}});return S=r.catch(()=>{}),r},B=(t,r="")=>{let e=n=>(n||"").replace(/\[\/?(?:STEERING HINT|QUESTION)(?::\s*\w+)?\]/gi,"").trim();return t?.name&&!t.name.startsWith("Session")?e(t.name):t?.prompt?e(t.prompt):e(t?.name)||r},I=async()=>{await d.ensureDir(h);let t={};if(await d.pathExists(m))try{t=u(m,{})}catch{t={}}for(let r in t){let e=j.join(h,`${r}.json`);Object.defineProperty(t[r],"messages",{get:()=>{if(d.existsSync(e))try{return u(e,[])}catch{return[]}return[]},set:n=>{try{p(e,n)}catch{}},enumerable:!1,configurable:!0})}return t},G=async(t,r,e)=>T(async()=>{await d.ensureDir(h);let n=await I(),s=n[t],i=(e||[]).filter(a=>!a.isUpdateNotification&&(!a.isMeta||a.text&&a.text.includes("Request Cancelled"))),o=a=>{if(!a)return;let A=typeof a=="string"?a:a.text||a.content||"";if(!A||typeof A!="string")return;let g=A.replace(/\s*\n+\s*\[Prompted on:.*?\]/g,"").replace(/\[\/?(?:STEERING HINT|QUESTION)(?::\s*\w+)?\]/gi,"").trim();if(!g)return;let N=g.split(/\s+/),E;return N.length>7?E=N.slice(0,7).join(" ")+"...":g.length>45?E=g.substring(0,45).trimEnd()+"...":E=g,E},c,x=i.filter(a=>a.role==="user"),l=x[0],w=x[x.length-1],y=o(w),D=o(l);s&&s.prompt?c=y:c=D||y;let H=r||(s?s.name:`Session ${t.slice(-6)}`),b=j.join(h,`${t}.json`);p(b,i),n[t]={name:H,prompt:c||void 0,updatedAt:Date.now()};let k={};for(let a in n)k[a]={name:n[a].name,prompt:n[a].prompt||void 0,updatedAt:n[a].updatedAt};p(m,k)}),J=async(t,r)=>T(async()=>{let e=await I();e[t]?(e[t].name=r,e[t].updatedAt=Date.now()):e[t]={name:r,updatedAt:Date.now()};let n={};for(let s in e)n[s]={name:e[s].name,prompt:e[s].prompt||void 0,updatedAt:e[s].updatedAt};p(m,n)}),F=async t=>T(async()=>{let r=await I();delete r[t];let e={};for(let o in r)e[o]={name:r[o].name,prompt:r[o].prompt||void 0,updatedAt:r[o].updatedAt};if(p(m,e),await d.pathExists(f))try{let o=u(f,[]);if(Array.isArray(o)){let c=o.filter(x=>Object.keys(x)[0]!==String(t));p(f,c)}}catch{}let n=u(C,{});n[t]&&(delete n[t],p(C,n));let s=u(M,{});s[t]&&(delete s[t],p(M,s)),await O.deleteChatBackups(t);let i=j.join(h,`${t}.json`);if(await d.pathExists(i))try{await d.remove(i)}catch{}return r}),Q=()=>`flow-${L(6)}`,W=async t=>{if(!t||t==="Never")return;let r=parseInt(t);if(isNaN(r))return;let e=await I(),n=Date.now(),s=r*24*60*60*1e3,i=0;for(let o in e){let c=e[o];c.updatedAt&&n-c.updatedAt>s&&(await F(o),i++)}return i};var Y=async(t,r,e)=>T(async()=>{let n=u(f,[]);Array.isArray(n)||(n=[]);let s=r||0,i=e||0,o={total:s,context:i},c=n.findIndex(l=>Object.keys(l)[0]===String(t));s===0&&i===0?c!==-1&&n.splice(c,1):c!==-1?n[c]={[String(t)]:o}:n.push({[String(t)]:o});let x=n.filter(l=>{if(!l||typeof l!="object")return!1;let w=Object.keys(l)[0];if(!w)return!1;let y=l[w];return y&&((y.total||0)>0||(y.context||0)>0)});p(f,x)}),q=async t=>{try{if(!await d.pathExists(f))return{total:0,context:0};let r=u(f,[]);if(!Array.isArray(r))return{total:0,context:0};let e=r.find(n=>Object.keys(n)[0]===String(t));return e?{total:0,context:0,...e[String(t)]}:{total:0,context:0}}catch{return{total:0,context:0}}};export{B as a,I as b,G as c,J as d,F as e,Q as f,W as g,Y as h,q as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as v,d as T}from"./chunk-P5HBJA23.js";import{e as k}from"./chunk-26BQ45XP.js";import b from"fs-extra";import C from"path";var Y=C.join(k,"secrets_v2.json"),y=10,F=new Set(["9router","c_openai"]),z=new Set(["c_openai"]),U=[{canonical:"Google",secret:["GOOGLE_API_KEY","API_KEY"],aliases:["gemini"]},{canonical:"DeepSeek",secret:["DEEPSEEK_API_KEY"],aliases:["deepseek-ai","deepseekai"]},{canonical:"OpenRouter",secret:["OPENROUTER_API_KEY"],aliases:["open router","open_router"]},{canonical:"NVIDIA",secret:["NVIDIA_API_KEY"],aliases:["nvidia nim"]},{canonical:"Mistral",secret:["MISTRAL_API_KEY"],aliases:[]},{canonical:"Ollama",secret:["OLLAMA_API_KEY"],aliases:[]},{canonical:"InferX",secret:["INFERX_API_KEY"],aliases:["infer x","inferx"]},{canonical:"SenseNova",secret:["SENSENOVA_API_KEY"],aliases:["sensenova","sense nova"]},{canonical:"AIHubMix",secret:["AIHUBMIX_API_KEY"],aliases:["aihubmix","ai hub mix"]},{canonical:"Poolside",secret:["POOLSIDE_API_KEY"],aliases:[]},{canonical:"9router",secret:["9ROUTER_API_KEY"],aliases:["9router","9-router","nine router"]},{canonical:"ExpLabs",secret:["EXPLABS_API_KEY","EXPERIENTIALLABS_API_KEY"],aliases:["explabs","experientiallabs","experimentallabs","experiential labs"]},{canonical:"TokenHarbor",secret:["TOKENHARBOR_API_KEY","TOKEN_HARBOR_API_KEY"],aliases:["tokenharbor","token harbor","token_harbor","thk"]},{canonical:"Infron",secret:["INFRON_API_KEY"],aliases:["infron"]},{canonical:"APInex",secret:["APINEX_API_KEY"],aliases:["apinex","apx"]},{canonical:"xKiro",secret:["XKIRO_API_KEY"],aliases:["xkiro","kiro"]},{canonical:"c_openai",secret:["CUSTOM_OPENAI_API_KEY","C_OPENAI_API_KEY"],aliases:["custom","custom (openai)","custom openai"]}],L=new Map;for(let e of U){L.set(e.canonical.toLowerCase(),e.canonical);for(let t of e.aliases)L.set(t.toLowerCase(),e.canonical)}var f=e=>!e||typeof e!="string"?null:L.get(e.trim().toLowerCase())||null,J=()=>U.map(e=>e.canonical),h=e=>z.has(e),ie=e=>F.has(e);var ce=e=>{let t=f(e)||e;return t==="c_openai"?"custom":t},B=()=>new Array(y).fill(null),d=e=>e?typeof e=="string"?e.trim().length>0:typeof e=="object"?!!(e.key&&String(e.key).trim()):!1:!1,I=e=>e?typeof e=="string"?e:typeof e=="object"&&e.key?e.key:null:null,E=e=>{let t=B();if(Array.isArray(e))for(let s=0;s<y&&s<e.length;s++)t[s]=e[s]??null;else typeof e=="string"&&e.trim()&&(t[0]=e);return t},S=()=>{try{return v(Y,{})||{}}catch{return{}}},g=e=>{try{b.existsSync(k)||b.mkdirSync(k,{recursive:!0}),T(Y,e,!0)}catch{}},D=!1,le=async()=>{if(!D){D=!0;try{await b.pathExists(Y);let e=C.join(k,"secrets.json");if(!await b.pathExists(e))return;let t=v(e,{})||{},s=S(),n=!1;for(let o of U){let i=E(s[o.canonical]);if(i.some(d)){s[o.canonical]=i;continue}let r=null;for(let a of o.secret)if(t[a]){r=t[a];break}r&&(h(o.canonical)?i[0]={key:r,baseUrl:""}:i[0]=r,s[o.canonical]=i,n=!0)}n&&g(s)}catch{}}},A=e=>{let t=f(e)||e,s=S();return E(s[t])},q=e=>A(e).filter(d).length,ue=()=>U.filter(e=>!F.has(e.canonical)).map(e=>{let t=q(e.canonical);return{provider:e.canonical,count:t,hasKeys:t>0}}),H=async()=>{try{let{loadSettings:e}=await import("./settings-PUFSRWT3.js"),t=await e();return t&&t.activeKeyIndex||{}}catch{return{}}},Q=async e=>{try{let{loadSettings:t,saveSettings:s}=await import("./settings-PUFSRWT3.js"),n=await t();n.activeKeyIndex=e,await s(n)}catch{}},_=async e=>{let t=f(e)||e,n=(await H())[t];return Number.isInteger(n)?n:null},w=async(e,t)=>{let s=f(e)||e,n=await H();return n[s]=t,await Q(n),t},V=async()=>{try{let{loadSettings:e}=await import("./settings-PUFSRWT3.js"),t=await e();return t&&t.nullKeyProviders||{}}catch{return{}}},W=async e=>{try{let{loadSettings:t,saveSettings:s}=await import("./settings-PUFSRWT3.js"),n=await t();n.nullKeyProviders=e,await s(n)}catch{}},Z=new Set(["c_openai","Ollama"]),ee="__FLUX_NULL_KEY__",fe=e=>Z.has(f(e)||e),$=async e=>{let t=f(e)||e;return(await V())[t]===!0},P=async(e,t=!0)=>{let s=f(e)||e,n=await V();return t?n[s]=!0:delete n[s],await W(n),t===!0},x=new Map,de=(e,t,s=void 0)=>{let n=f(e)||e,o={key:t};s!==void 0&&(o.baseUrl=s),x.set(n,o)},pe=e=>{let t=f(e)||e;return x.get(t)||null},me=e=>x.has(f(e)||e),ye=()=>x.clear(),Ie=e=>x.delete(f(e)||e),O=null,xe=e=>{O=typeof e=="function"?e:null},te=e=>{try{O&&O(e)}catch{}},K=async()=>{try{let{loadSettings:e}=await import("./settings-PUFSRWT3.js"),t=await e();return t.systemSettings&&t.systemSettings.customOpenAIBaseUrl||""}catch{return""}},ge=async(e,t={})=>{let s=f(e)||e,n=t.silent===!0,o=x.get(s);if(o&&o.key)return o.key;if(await $(s))return ee;let i=A(s),r=await _(s);if(Number.isInteger(r)&&r>=0&&r<y&&d(i[r]))return I(i[r]);let a=i.findIndex(d);return a!==-1?(n||(await w(s,a),te(`No active key set for ${s}. Auto-selected slot ${a+1}.`)),I(i[a])):null},_e=async e=>{let t=f(e)||e;if(!h(t))return null;let s=x.get(t);if(s&&s.key)return s.baseUrl!==void 0?s.baseUrl:await K();if(await $(t))return await K();let n=A(t),o=await _(t);if(Number.isInteger(o)&&o>=0&&o<y){let r=n[o];if(r&&typeof r=="object"&&r.key)return r.baseUrl||""}let i=n.findIndex(d);if(i!==-1){let r=n[i];if(r&&typeof r=="object")return r.baseUrl||""}return await K()},R=async(e,t,s,n)=>{if(h(e)){let o=n!==void 0?n:s!==void 0?s:await K();return{key:t,baseUrl:o}}return t},X=e=>{let t=String(e||"").trim();if(!t)return{ok:!1,error:"URL is empty."};if(!/^https?:\/\/\S+$/i.test(t))return{ok:!1,error:"URL must start with http:// or https://"};let s=t.replace(/\/+$/,""),n=s.toLowerCase(),o=/(^|\/)v1$/.test(n),i=/(^|\/)v1\/chat\/completions$/.test(n);return!o&&!i?{ok:!1,error:"URL must end with /v1 or /v1/chat/completions"}:{ok:!0,url:s}},G=(e,t)=>{let s=String(t),n=[],o=[];return e.forEach((i,r)=>{let a=I(i);a&&(a===s?n.push(r):a.includes(s)&&o.push(r))}),n.length?n:o},he=async(e,t,s={})=>{let n=f(e)||e;if(!t||!String(t).trim())return{ok:!1,error:"Empty key."};let o=String(t).trim(),i;if(s.baseUrl!==void 0){if(!h(n))return{ok:!1,error:"--url is only supported for the custom provider."};let c=X(s.baseUrl);if(!c.ok)return{ok:!1,error:`Invalid URL: ${c.error}`};i=c.url}let r=S(),a=E(r[n]);if(a.some(c=>I(c)===o))return{ok:!1,error:`Key already exists in slot ${a.findIndex(l=>I(l)===o)+1}.`};if(Number.isInteger(s.index)){let c=s.index;if(c<0||c>=y)return{ok:!1,error:`Index must be between 1 and ${y}.`};let l=a[c]&&typeof a[c]=="object"?a[c].baseUrl:void 0;return a[c]=await R(n,o,l,i),r[n]=a,g(r),await P(n,!1),{ok:!0,index:c}}let u=a.findIndex(c=>!d(c));return u===-1?{ok:!1,error:"All slots full. Specify an index to overwrite.",full:!0}:(a[u]=await R(n,o,void 0,i),r[n]=a,g(r),await P(n,!1),{ok:!0,index:u})},we=async(e,t,s={})=>{let n=f(e)||e;if(!t||!String(t).trim())return{ok:!1,error:"Empty key."};let o=String(t).trim(),i;if(s.baseUrl!==void 0){if(!h(n))return{ok:!1,error:"Base URL is only supported for the custom provider."};let p=X(s.baseUrl);if(!p.ok)return{ok:!1,error:`Invalid URL: ${p.error}`};i=p.url}let r=S(),a=E(r[n]),u=await _(n),c=Number.isInteger(u)&&u>=0&&u<y&&d(a[u])?u:a.findIndex(d);c===-1&&(c=0);let l=a[c]&&typeof a[c]=="object"?a[c].baseUrl:void 0;return a[c]=await R(n,o,l,i),r[n]=a,g(r),await w(n,c),await P(n,!1),{ok:!0,index:c}},Ee=async(e,t,s={})=>{let n=f(e)||e,o=S(),i=E(o[n]);if(s.all||t==="--all"||t==="__all__")return o[n]=B(),g(o),await w(n,null),{ok:!0,all:!0,remaining:0,needsNewKey:!0};let r=-1;if(t==null){let l=await _(n);if(r=Number.isInteger(l)&&d(i[l])?l:i.findIndex(d),r===-1)return{ok:!1,error:"No keys to remove."}}else if(Number.isInteger(t)){if(r=t,r<0||r>=y)return{ok:!1,error:`Index must be between 1 and ${y}.`};if(!d(i[r]))return{ok:!1,error:`Slot ${r+1} is already empty.`}}else{let l=G(i,t);if(l.length===0)return{ok:!1,error:"No matching key found."};if(l.length>1)return{ok:!1,error:`Duplicate match (slots ${l.map(p=>p+1).join(", ")}). Be more specific.`};r=l[0]}let a=I(i[r]),u=await _(n)===r;i[r]=null,o[n]=i,g(o);let c=i.filter(d).length;if(u){let l=i.findIndex(d);await w(n,l===-1?null:l)}return{ok:!0,removed:a,removedIndex:r,remaining:c,needsNewKey:c===0}},Se=async(e,t)=>{let s=f(e)||e,n=A(s),o=-1;if(Number.isInteger(t)){if(o=t,o<0||o>=y)return{ok:!1,error:`Index must be between 1 and ${y}.`};if(!d(n[o]))return{ok:!1,error:`Slot ${o+1} is empty.`}}else{let r=G(n,t);if(r.length===0)return{ok:!1,error:"No matching key found."};if(r.length>1)return{ok:!1,error:`Duplicate match (slots ${r.map(a=>a+1).join(", ")}). Be more specific.`};o=r[0]}await w(s,o),await P(s,!1);let i=null;if(h(s)){let r=n[o],a=r&&typeof r=="object"&&r.baseUrl?r.baseUrl.trim():"";if(a)try{let{loadSettings:u,saveSettings:c}=await import("./settings-PUFSRWT3.js"),l=await u();if((l.systemSettings&&l.systemSettings.customOpenAIBaseUrl?l.systemSettings.customOpenAIBaseUrl.trim():"")!==a){let m={...l.systemSettings||{},customOpenAIBaseUrl:a,memory:!1};await c({...l,systemSettings:m}),i=a}}catch{}}return{ok:!0,index:o,key:I(n[o]),switchedBaseUrl:i}},ke=async(e=null)=>{let t=S(),s=e?[f(e)||e]:J(),n=0;for(let o of s){let i=E(t[o]),r=i.filter(d);if(r.length===0){t[o]=i;continue}let a=await _(o),u=Number.isInteger(a)&&d(i[a])?i[a]:null,c=B();r.forEach((p,m)=>{c[m]=p});let l=Number.isInteger(a)?a:null;if(u){let p=i.slice(0,y).map((m,N)=>({s:m,i:N})).filter(m=>d(m.s)).findIndex(m=>m.i===a);l=p===-1?null:p}t[o]=c,l!==a&&await w(o,l),n++}return g(t),{ok:!0,providers:s.length,touched:n}},j=e=>{if(!e)return"";let t=String(e),s=t.length;if(s<=3)return"...";let n=Math.floor(s/3),o=t.slice(0,n),i=t.slice(s-n);return o+"..."+i},ne=e=>{if(!e)return"";let t=String(e).replace(/\/+$/,"");return t.length<=28?t:"..."+t.replace(/^https?:\/\//i,"").slice(-24)},Ae=async(e,t={})=>{let s=t.unmask===!0,n=f(e)||e,o=A(n),i=await _(n),r=x.get(n),a=[];r&&r.key&&a.push(`Temporary: ${s?r.key:j(r.key)}`),await $(n)&&a.push("Mode: NO KEY (null) <- active");for(let u=0;u<y;u++){let c=o[u],l=I(c),p=l&&!s?j(l):l,m;if(!l)m="Empty";else if(h(n)){let M=c&&typeof c=="object"?ne(c.baseUrl):"";m=M?`${p} (Saved: ${M})`:p}else m=p;let N=u===i&&l?" \u2190 active":"";a.push(`${u+1}: ${m}${N}`)}return a};export{F as a,U as b,f as c,J as d,h as e,ie as f,ce as g,le as h,A as i,q as j,ue as k,_ as l,w as m,ee as n,fe as o,$ as p,P as q,de as r,pe as s,me as t,ye as u,Ie as v,xe as w,ge as x,_e as y,X as z,he as A,we as B,Ee as C,Se as D,ke as E,j as F,ne as G,Ae as H};
|
|
1
|
+
import{c as v,d as T}from"./chunk-NTZSL2UT.js";import{e as k}from"./chunk-YFIWMGCS.js";import b from"fs-extra";import C from"path";var Y=C.join(k,"secrets_v2.json"),y=10,F=new Set(["9router","c_openai"]),z=new Set(["c_openai"]),U=[{canonical:"Google",secret:["GOOGLE_API_KEY","API_KEY"],aliases:["gemini"]},{canonical:"DeepSeek",secret:["DEEPSEEK_API_KEY"],aliases:["deepseek-ai","deepseekai"]},{canonical:"OpenRouter",secret:["OPENROUTER_API_KEY"],aliases:["open router","open_router"]},{canonical:"NVIDIA",secret:["NVIDIA_API_KEY"],aliases:["nvidia nim"]},{canonical:"Mistral",secret:["MISTRAL_API_KEY"],aliases:[]},{canonical:"Ollama",secret:["OLLAMA_API_KEY"],aliases:[]},{canonical:"InferX",secret:["INFERX_API_KEY"],aliases:["infer x","inferx"]},{canonical:"SenseNova",secret:["SENSENOVA_API_KEY"],aliases:["sensenova","sense nova"]},{canonical:"AIHubMix",secret:["AIHUBMIX_API_KEY"],aliases:["aihubmix","ai hub mix"]},{canonical:"Poolside",secret:["POOLSIDE_API_KEY"],aliases:[]},{canonical:"9router",secret:["9ROUTER_API_KEY"],aliases:["9router","9-router","nine router"]},{canonical:"ExpLabs",secret:["EXPLABS_API_KEY","EXPERIENTIALLABS_API_KEY"],aliases:["explabs","experientiallabs","experimentallabs","experiential labs"]},{canonical:"TokenHarbor",secret:["TOKENHARBOR_API_KEY","TOKEN_HARBOR_API_KEY"],aliases:["tokenharbor","token harbor","token_harbor","thk"]},{canonical:"Infron",secret:["INFRON_API_KEY"],aliases:["infron"]},{canonical:"APInex",secret:["APINEX_API_KEY"],aliases:["apinex","apx"]},{canonical:"xKiro",secret:["XKIRO_API_KEY"],aliases:["xkiro","kiro"]},{canonical:"c_openai",secret:["CUSTOM_OPENAI_API_KEY","C_OPENAI_API_KEY"],aliases:["custom","custom (openai)","custom openai"]}],L=new Map;for(let e of U){L.set(e.canonical.toLowerCase(),e.canonical);for(let t of e.aliases)L.set(t.toLowerCase(),e.canonical)}var f=e=>!e||typeof e!="string"?null:L.get(e.trim().toLowerCase())||null,J=()=>U.map(e=>e.canonical),h=e=>z.has(e),ie=e=>F.has(e);var ce=e=>{let t=f(e)||e;return t==="c_openai"?"custom":t},B=()=>new Array(y).fill(null),d=e=>e?typeof e=="string"?e.trim().length>0:typeof e=="object"?!!(e.key&&String(e.key).trim()):!1:!1,I=e=>e?typeof e=="string"?e:typeof e=="object"&&e.key?e.key:null:null,E=e=>{let t=B();if(Array.isArray(e))for(let s=0;s<y&&s<e.length;s++)t[s]=e[s]??null;else typeof e=="string"&&e.trim()&&(t[0]=e);return t},S=()=>{try{return v(Y,{})||{}}catch{return{}}},g=e=>{try{b.existsSync(k)||b.mkdirSync(k,{recursive:!0}),T(Y,e,!0)}catch{}},D=!1,le=async()=>{if(!D){D=!0;try{await b.pathExists(Y);let e=C.join(k,"secrets.json");if(!await b.pathExists(e))return;let t=v(e,{})||{},s=S(),n=!1;for(let o of U){let i=E(s[o.canonical]);if(i.some(d)){s[o.canonical]=i;continue}let r=null;for(let a of o.secret)if(t[a]){r=t[a];break}r&&(h(o.canonical)?i[0]={key:r,baseUrl:""}:i[0]=r,s[o.canonical]=i,n=!0)}n&&g(s)}catch{}}},A=e=>{let t=f(e)||e,s=S();return E(s[t])},q=e=>A(e).filter(d).length,ue=()=>U.filter(e=>!F.has(e.canonical)).map(e=>{let t=q(e.canonical);return{provider:e.canonical,count:t,hasKeys:t>0}}),H=async()=>{try{let{loadSettings:e}=await import("./settings-XJ2SOAWE.js"),t=await e();return t&&t.activeKeyIndex||{}}catch{return{}}},Q=async e=>{try{let{loadSettings:t,saveSettings:s}=await import("./settings-XJ2SOAWE.js"),n=await t();n.activeKeyIndex=e,await s(n)}catch{}},_=async e=>{let t=f(e)||e,n=(await H())[t];return Number.isInteger(n)?n:null},w=async(e,t)=>{let s=f(e)||e,n=await H();return n[s]=t,await Q(n),t},V=async()=>{try{let{loadSettings:e}=await import("./settings-XJ2SOAWE.js"),t=await e();return t&&t.nullKeyProviders||{}}catch{return{}}},W=async e=>{try{let{loadSettings:t,saveSettings:s}=await import("./settings-XJ2SOAWE.js"),n=await t();n.nullKeyProviders=e,await s(n)}catch{}},Z=new Set(["c_openai","Ollama"]),ee="__FLUX_NULL_KEY__",fe=e=>Z.has(f(e)||e),$=async e=>{let t=f(e)||e;return(await V())[t]===!0},P=async(e,t=!0)=>{let s=f(e)||e,n=await V();return t?n[s]=!0:delete n[s],await W(n),t===!0},x=new Map,de=(e,t,s=void 0)=>{let n=f(e)||e,o={key:t};s!==void 0&&(o.baseUrl=s),x.set(n,o)},pe=e=>{let t=f(e)||e;return x.get(t)||null},me=e=>x.has(f(e)||e),ye=()=>x.clear(),Ie=e=>x.delete(f(e)||e),O=null,xe=e=>{O=typeof e=="function"?e:null},te=e=>{try{O&&O(e)}catch{}},K=async()=>{try{let{loadSettings:e}=await import("./settings-XJ2SOAWE.js"),t=await e();return t.systemSettings&&t.systemSettings.customOpenAIBaseUrl||""}catch{return""}},ge=async(e,t={})=>{let s=f(e)||e,n=t.silent===!0,o=x.get(s);if(o&&o.key)return o.key;if(await $(s))return ee;let i=A(s),r=await _(s);if(Number.isInteger(r)&&r>=0&&r<y&&d(i[r]))return I(i[r]);let a=i.findIndex(d);return a!==-1?(n||(await w(s,a),te(`No active key set for ${s}. Auto-selected slot ${a+1}.`)),I(i[a])):null},_e=async e=>{let t=f(e)||e;if(!h(t))return null;let s=x.get(t);if(s&&s.key)return s.baseUrl!==void 0?s.baseUrl:await K();if(await $(t))return await K();let n=A(t),o=await _(t);if(Number.isInteger(o)&&o>=0&&o<y){let r=n[o];if(r&&typeof r=="object"&&r.key)return r.baseUrl||""}let i=n.findIndex(d);if(i!==-1){let r=n[i];if(r&&typeof r=="object")return r.baseUrl||""}return await K()},R=async(e,t,s,n)=>{if(h(e)){let o=n!==void 0?n:s!==void 0?s:await K();return{key:t,baseUrl:o}}return t},X=e=>{let t=String(e||"").trim();if(!t)return{ok:!1,error:"URL is empty."};if(!/^https?:\/\/\S+$/i.test(t))return{ok:!1,error:"URL must start with http:// or https://"};let s=t.replace(/\/+$/,""),n=s.toLowerCase(),o=/(^|\/)v1$/.test(n),i=/(^|\/)v1\/chat\/completions$/.test(n);return!o&&!i?{ok:!1,error:"URL must end with /v1 or /v1/chat/completions"}:{ok:!0,url:s}},G=(e,t)=>{let s=String(t),n=[],o=[];return e.forEach((i,r)=>{let a=I(i);a&&(a===s?n.push(r):a.includes(s)&&o.push(r))}),n.length?n:o},he=async(e,t,s={})=>{let n=f(e)||e;if(!t||!String(t).trim())return{ok:!1,error:"Empty key."};let o=String(t).trim(),i;if(s.baseUrl!==void 0){if(!h(n))return{ok:!1,error:"--url is only supported for the custom provider."};let c=X(s.baseUrl);if(!c.ok)return{ok:!1,error:`Invalid URL: ${c.error}`};i=c.url}let r=S(),a=E(r[n]);if(a.some(c=>I(c)===o))return{ok:!1,error:`Key already exists in slot ${a.findIndex(l=>I(l)===o)+1}.`};if(Number.isInteger(s.index)){let c=s.index;if(c<0||c>=y)return{ok:!1,error:`Index must be between 1 and ${y}.`};let l=a[c]&&typeof a[c]=="object"?a[c].baseUrl:void 0;return a[c]=await R(n,o,l,i),r[n]=a,g(r),await P(n,!1),{ok:!0,index:c}}let u=a.findIndex(c=>!d(c));return u===-1?{ok:!1,error:"All slots full. Specify an index to overwrite.",full:!0}:(a[u]=await R(n,o,void 0,i),r[n]=a,g(r),await P(n,!1),{ok:!0,index:u})},we=async(e,t,s={})=>{let n=f(e)||e;if(!t||!String(t).trim())return{ok:!1,error:"Empty key."};let o=String(t).trim(),i;if(s.baseUrl!==void 0){if(!h(n))return{ok:!1,error:"Base URL is only supported for the custom provider."};let p=X(s.baseUrl);if(!p.ok)return{ok:!1,error:`Invalid URL: ${p.error}`};i=p.url}let r=S(),a=E(r[n]),u=await _(n),c=Number.isInteger(u)&&u>=0&&u<y&&d(a[u])?u:a.findIndex(d);c===-1&&(c=0);let l=a[c]&&typeof a[c]=="object"?a[c].baseUrl:void 0;return a[c]=await R(n,o,l,i),r[n]=a,g(r),await w(n,c),await P(n,!1),{ok:!0,index:c}},Ee=async(e,t,s={})=>{let n=f(e)||e,o=S(),i=E(o[n]);if(s.all||t==="--all"||t==="__all__")return o[n]=B(),g(o),await w(n,null),{ok:!0,all:!0,remaining:0,needsNewKey:!0};let r=-1;if(t==null){let l=await _(n);if(r=Number.isInteger(l)&&d(i[l])?l:i.findIndex(d),r===-1)return{ok:!1,error:"No keys to remove."}}else if(Number.isInteger(t)){if(r=t,r<0||r>=y)return{ok:!1,error:`Index must be between 1 and ${y}.`};if(!d(i[r]))return{ok:!1,error:`Slot ${r+1} is already empty.`}}else{let l=G(i,t);if(l.length===0)return{ok:!1,error:"No matching key found."};if(l.length>1)return{ok:!1,error:`Duplicate match (slots ${l.map(p=>p+1).join(", ")}). Be more specific.`};r=l[0]}let a=I(i[r]),u=await _(n)===r;i[r]=null,o[n]=i,g(o);let c=i.filter(d).length;if(u){let l=i.findIndex(d);await w(n,l===-1?null:l)}return{ok:!0,removed:a,removedIndex:r,remaining:c,needsNewKey:c===0}},Se=async(e,t)=>{let s=f(e)||e,n=A(s),o=-1;if(Number.isInteger(t)){if(o=t,o<0||o>=y)return{ok:!1,error:`Index must be between 1 and ${y}.`};if(!d(n[o]))return{ok:!1,error:`Slot ${o+1} is empty.`}}else{let r=G(n,t);if(r.length===0)return{ok:!1,error:"No matching key found."};if(r.length>1)return{ok:!1,error:`Duplicate match (slots ${r.map(a=>a+1).join(", ")}). Be more specific.`};o=r[0]}await w(s,o),await P(s,!1);let i=null;if(h(s)){let r=n[o],a=r&&typeof r=="object"&&r.baseUrl?r.baseUrl.trim():"";if(a)try{let{loadSettings:u,saveSettings:c}=await import("./settings-XJ2SOAWE.js"),l=await u();if((l.systemSettings&&l.systemSettings.customOpenAIBaseUrl?l.systemSettings.customOpenAIBaseUrl.trim():"")!==a){let m={...l.systemSettings||{},customOpenAIBaseUrl:a,memory:!1};await c({...l,systemSettings:m}),i=a}}catch{}}return{ok:!0,index:o,key:I(n[o]),switchedBaseUrl:i}},ke=async(e=null)=>{let t=S(),s=e?[f(e)||e]:J(),n=0;for(let o of s){let i=E(t[o]),r=i.filter(d);if(r.length===0){t[o]=i;continue}let a=await _(o),u=Number.isInteger(a)&&d(i[a])?i[a]:null,c=B();r.forEach((p,m)=>{c[m]=p});let l=Number.isInteger(a)?a:null;if(u){let p=i.slice(0,y).map((m,N)=>({s:m,i:N})).filter(m=>d(m.s)).findIndex(m=>m.i===a);l=p===-1?null:p}t[o]=c,l!==a&&await w(o,l),n++}return g(t),{ok:!0,providers:s.length,touched:n}},j=e=>{if(!e)return"";let t=String(e),s=t.length;if(s<=3)return"...";let n=Math.floor(s/3),o=t.slice(0,n),i=t.slice(s-n);return o+"..."+i},ne=e=>{if(!e)return"";let t=String(e).replace(/\/+$/,"");return t.length<=28?t:"..."+t.replace(/^https?:\/\//i,"").slice(-24)},Ae=async(e,t={})=>{let s=t.unmask===!0,n=f(e)||e,o=A(n),i=await _(n),r=x.get(n),a=[];r&&r.key&&a.push(`Temporary: ${s?r.key:j(r.key)}`),await $(n)&&a.push("Mode: NO KEY (null) <- active");for(let u=0;u<y;u++){let c=o[u],l=I(c),p=l&&!s?j(l):l,m;if(!l)m="Empty";else if(h(n)){let M=c&&typeof c=="object"?ne(c.baseUrl):"";m=M?`${p} (Saved: ${M})`:p}else m=p;let N=u===i&&l?" \u2190 active":"";a.push(`${u+1}: ${m}${N}`)}return a};export{F as a,U as b,f as c,J as d,h as e,ie as f,ce as g,le as h,A as i,q as j,ue as k,_ as l,w as m,ee as n,fe as o,$ as p,P as q,de as r,pe as s,me as t,ye as u,Ie as v,xe as w,ge as x,_e as y,X as z,he as A,we as B,Ee as C,Se as D,ke as E,j as F,ne as G,Ae as H};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as l,v as u}from"./chunk-
|
|
1
|
+
import{a as l,v as u}from"./chunk-YFIWMGCS.js";import f from"fs";var o=null,a=()=>{try{if(f.existsSync(u)){let e=f.readFileSync(u,"utf-8"),n=JSON.parse(e);if(n&&typeof n=="object")return o=n,o}}catch{}return o=o||{},o},y=e=>{try{return f.existsSync(l)||f.mkdirSync(l,{recursive:!0}),f.writeFileSync(u,JSON.stringify(e,null,2),"utf-8"),o=e,!0}catch{return!1}},C=(e,n,c)=>{if(!e||!n||!c)return null;let s=o||a(),t=`${e}::${n}`,r=s[t];if(r&&typeof r=="object"){let i=c.toLowerCase();if(r[i]!==void 0&&r[i]!==null)return r[i];for(let[g,k]of Object.entries(r))if(g.toLowerCase()===i)return k}return null},x=(e,n,c,s)=>{if(!e||!n||!c||!s)return{success:!1,reason:"Invalid arguments"};let t=o||a(),r=`${e}::${n}`;return(!t[r]||typeof t[r]!="object")&&(t[r]={}),t[r][c.toLowerCase()]=s,{success:y(t)}},I=(e,n,c)=>{if(!e||!n)return{success:!1,reason:"Invalid arguments"};let s=o||a(),t=`${e}::${n}`;return s[t]&&(c?(delete s[t][c.toLowerCase()],Object.keys(s[t]).length===0&&delete s[t]):delete s[t],y(s)),{success:!0}};export{C as a,x as b,I as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import g from"os";import e from"path";import p from"fs";import m from"crypto";import{minimatch as x}from"minimatch";var d=e.join(g.homedir(),".fluxflow"),_=e.join(d,"settings.json"),E=null;try{if(p.existsSync(_)){let o=p.readFileSync(_,"utf8").trim(),t;if(o.startsWith("{"))t=JSON.parse(o);else{let n=o.split(":");if(n.length===2){let s=Buffer.from(n[0],"hex"),u=n[1],c=null;try{let a=e.join(d,".token");if(p.existsSync(a)){let r=p.readFileSync(a,"utf8").trim();if(r){let f=m.createHash("sha256").update(r).digest(),l=m.createDecipheriv("aes-256-cbc",f,s);c=l.update(u,"hex","utf8")+l.final("utf8")}}}catch{}if(!c)try{let a=m.createHash("sha256").update("fluxflow-cli-sanctuary-key").digest(),r=m.createDecipheriv("aes-256-cbc",a,s);c=r.update(u,"hex","utf8")+r.final("utf8")}catch{}c&&(t=JSON.parse(c))}}if(t){let n=t.systemSettings||{};n.useExternalData&&n.externalDataPath&&(E=e.normalize(n.externalDataPath.trim()))}}}catch{}var h=E||d,D=e.join(h,"logs"),i=e.join(h,"secret"),L=e.join(i,"history.json"),T=e.join(i,"history"),R=e.join(d,"usage.json"),C=e.join(i,"usage.json"),b=e.join(i,"timed_usage"),F=e.join(i,"memories.json"),k=e.join(i,"memory-temp.json"),A=e.join(i,"temp-memory-chat.json"),w=e.join(h,"backups"),W=e.join(i,"ledger.json"),P=e.join(i,"ledgerAdvance.json"),O=e.join(i,"active_tx.json"),N=e.join(i,"path.json"),G=e.join(i,"context.json"),M=e.join(h,"parsers"),B=e.join(d,".cache","CU"),U=e.join(d,"thinking_config.json"),$=[".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"],H=(o=process.cwd())=>{try{let t=e.join(o,".gitignore");if(p.existsSync(t))return p.readFileSync(t,"utf8").split(`
|
|
2
|
+
`).map(s=>s.trim()).filter(s=>s&&!s.startsWith("#")&&!s.startsWith("!")).map(s=>s.replace(/^[\/\\]+/,"").replace(/[\/\\]+$/,"").replace(/\/\*+$/,"")).filter(Boolean)}catch{}return[]},z=(o,t)=>{if(!o||!t)return!1;let n=o.replace(/\\/g,"/"),s=e.basename(o),u=t.split(",").map(a=>a.trim()).filter(Boolean),c=null;try{let a=typeof x<"u"?x:null;a&&(c=a)}catch{}for(let a of u){let r=a.replace(/\\/g,"/");if(s.toLowerCase()===r.toLowerCase()||n.toLowerCase()===r.toLowerCase()||n.toLowerCase().endsWith("/"+r.toLowerCase()))return!0;try{if(c&&(c(n,r,{dot:!0,nocase:!0,matchBase:!0})||c(s,r,{dot:!0,nocase:!0})))return!0}catch{}if(r.includes("*")||r.includes("?")){let f="^"+r.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,".*").replace(/\*/g,"[^/]*").replace(/\?/g,".")+"$";try{let l=new RegExp(f,"i");if(l.test(s)||l.test(n))return!0}catch{}}}return!1},V=o=>{if(typeof o!="string")return{resolvedPath:o,isTildeResolved:!1};let t=o.trim();return t.startsWith("\\~")?{resolvedPath:t.slice(1),isTildeResolved:!1}:t==="~"?{resolvedPath:g.homedir(),isTildeResolved:!0}:t.startsWith("~/")||t.startsWith("~\\")?{resolvedPath:e.join(g.homedir(),t.slice(2)),isTildeResolved:!0}:{resolvedPath:t,isTildeResolved:!1}};export{d as a,_ as b,h as c,D as d,i as e,L as f,T as g,R as h,C as i,b as j,F as k,k as l,A as m,w as n,W as o,P as p,O as q,N as r,G as s,M as t,B as u,U as v,$ as w,H as x,z as y,V as z};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as W}from"./chunk-
|
|
2
|
-
`)){let i=r.split(" ");if(i.length<12||parseInt(i[0])!==5)continue;let n=i[2],c=i[3],l=i[4],w=parseInt(i[6]),x=parseInt(i[7]),R=parseInt(i[8]),M=parseInt(i[9]),f=parseFloat(i[10]),h=i.slice(11).join(" ").trim();if(!h||f<0)continue;let p={x0:w,y0:x,x1:w+R,y1:x+M},g={text:h,confidence:f,bbox:p};o.push(g);let u=`${n}_${c}_${l}`;e.has(u)||e.set(u,{words:[],bbox:{x0:1/0,y0:1/0,x1:-1/0,y1:-1/0}});let d=e.get(u);d.words.push(g),d.bbox.x0=Math.min(d.bbox.x0,p.x0),d.bbox.y0=Math.min(d.bbox.y0,p.y0),d.bbox.x1=Math.max(d.bbox.x1,p.x1),d.bbox.y1=Math.max(d.bbox.y1,p.y1)}let s=[];for(let r of e.values())r.words.length>0&&s.push({text:r.words.map(i=>i.text).join(" "),bbox:r.bbox,words:r.words});return{words:o,lines:s}}function Z(t){if(!(t.words&&t.words.length>0)){if(t.blocks&&t.blocks.length>0){t.words=[],t.lines=[];for(let o of t.blocks)for(let e of o.paragraphs||[])for(let s of e.lines||[]){s.bbox&&t.lines.push(s);for(let r of s.words||[])r.bbox&&t.words.push(r)}if(t.words.length>0)return}if(t.tsv){let o=Y(t.tsv);t.words=o.words,t.lines=o.lines}}}function L(t,o,e=0,s=0,r=1){Z(t);let i=n=>({x0:Math.round(n.x0/r)+e,y0:Math.round(n.y0/r)+s,x1:Math.round(n.x1/r)+e,y1:Math.round(n.y1/r)+s}),a=[];if(t.lines&&t.lines.length>0)for(let n of t.lines){let c=n.text?n.text.toLowerCase().trim():"";if(!c||!n.bbox||!(c===o||new RegExp(`\\b${K(o)}\\b`,"i").test(c)))continue;let w=n.words||(t.words?t.words.filter(f=>f.bbox&&f.bbox.x0>=n.bbox.x0-5&&f.bbox.x1<=n.bbox.x1+5&&f.bbox.y0>=n.bbox.y0-5&&f.bbox.y1<=n.bbox.y1+5):[]),x=o.split(/\s+/),R=x.map(f=>f.replace(/[^a-z0-9]/g,"")).join(" "),M=!1;if(w.length>0)for(let f=0;f<=w.length-x.length;f++){let h=w.slice(f,f+x.length),p=h.map(g=>(g.text||"").toLowerCase().trim().replace(/[^a-z0-9]/g,"")).join(" ");if(p===R||p.includes(R)){let g={x0:Math.min(...h.map(u=>u.bbox.x0)),y0:Math.min(...h.map(u=>u.bbox.y0)),x1:Math.max(...h.map(u=>u.bbox.x1)),y1:Math.max(...h.map(u=>u.bbox.y1))};a.push(i(g)),M=!0}}M||a.push(i(n.bbox))}if(a.length===0&&t.words&&t.words.length>0)for(let n of t.words){let c=n.text?n.text.toLowerCase().trim().replace(/[^a-z0-9]/g,""):"",l=o.replace(/[^a-z0-9]/g,"");c===l&&n.bbox&&a.push(i(n.bbox))}if(a.length===0&&t.words&&t.words.length>0){let n=V(o.length);for(let c of t.words){let l=c.text?c.text.toLowerCase().trim():"";l.length>=3&&Math.abs(l.length-o.length)<=n&&Q(l,o,n)<=n&&c.bbox&&a.push(i(c.bbox))}}return a}function N(t,o){let e=null,s=1/0;for(let r of t){let i=Math.round((r.x0+r.x1)/2),a=Math.round((r.y0+r.y1)/2),n=o.x>=r.x0&&o.x<=r.x1&&o.y>=r.y0&&o.y<=r.y1,c=Math.hypot(i-o.x,a-o.y),l=n?0:c;l<s&&(s=l,e={x:i,y:a,dist:c,containsPoint:n,bbox:r})}return e}var C=null;async function tt(){return C||(C=(async()=>{let{createWorker:t}=await import("tesseract.js"),o=await import("fs-extra"),{CU_CACHE_DIR:e}=await import("./paths-
|
|
1
|
+
import{a as W}from"./chunk-FOELTIXU.js";import{g as B,i as S}from"./chunk-7UF7ZHP7.js";import{a as P}from"./chunk-Y5JU726N.js";import X from"screenshot-desktop";import O from"sharp";import j from"fs-extra";import G from"path";import"@nut-tree-fork/nut-js";async function U(t,o,e){if(!(!process.env.SHOW_DEBUG_GRID&&!process.env.DEBUG_OCR))try{let s=G.resolve(process.cwd(),"screenshots",t);await j.ensureDir(s),await j.writeFile(G.join(s,o),e)}catch{}}function K(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Q(t,o,e=1/0){if(t===o)return 0;if(t.length===0)return o.length;if(o.length===0)return t.length;if(Math.abs(t.length-o.length)>e)return e+1;let s=Array.from({length:o.length+1},(r,i)=>i);for(let r=1;r<=t.length;r++){let i=[r],a=r;for(let n=1;n<=o.length;n++){let c=t[r-1]===o[n-1]?0:1,l=Math.min(i[n-1]+1,s[n]+1,s[n-1]+c);i.push(l),l<a&&(a=l)}if(s=i,a>e)return e+1}return s[o.length]}function V(t){return t<=4?0:t<=8?1:2}async function H(t,o=3){let e=await O(t).metadata();return O(t).resize(Math.round(e.width*o),Math.round(e.height*o),{kernel:"lanczos3"}).greyscale().normalise().toBuffer()}function Y(t){if(!t)return{words:[],lines:[]};let o=[],e=new Map;for(let r of t.split(`
|
|
2
|
+
`)){let i=r.split(" ");if(i.length<12||parseInt(i[0])!==5)continue;let n=i[2],c=i[3],l=i[4],w=parseInt(i[6]),x=parseInt(i[7]),R=parseInt(i[8]),M=parseInt(i[9]),f=parseFloat(i[10]),h=i.slice(11).join(" ").trim();if(!h||f<0)continue;let p={x0:w,y0:x,x1:w+R,y1:x+M},g={text:h,confidence:f,bbox:p};o.push(g);let u=`${n}_${c}_${l}`;e.has(u)||e.set(u,{words:[],bbox:{x0:1/0,y0:1/0,x1:-1/0,y1:-1/0}});let d=e.get(u);d.words.push(g),d.bbox.x0=Math.min(d.bbox.x0,p.x0),d.bbox.y0=Math.min(d.bbox.y0,p.y0),d.bbox.x1=Math.max(d.bbox.x1,p.x1),d.bbox.y1=Math.max(d.bbox.y1,p.y1)}let s=[];for(let r of e.values())r.words.length>0&&s.push({text:r.words.map(i=>i.text).join(" "),bbox:r.bbox,words:r.words});return{words:o,lines:s}}function Z(t){if(!(t.words&&t.words.length>0)){if(t.blocks&&t.blocks.length>0){t.words=[],t.lines=[];for(let o of t.blocks)for(let e of o.paragraphs||[])for(let s of e.lines||[]){s.bbox&&t.lines.push(s);for(let r of s.words||[])r.bbox&&t.words.push(r)}if(t.words.length>0)return}if(t.tsv){let o=Y(t.tsv);t.words=o.words,t.lines=o.lines}}}function L(t,o,e=0,s=0,r=1){Z(t);let i=n=>({x0:Math.round(n.x0/r)+e,y0:Math.round(n.y0/r)+s,x1:Math.round(n.x1/r)+e,y1:Math.round(n.y1/r)+s}),a=[];if(t.lines&&t.lines.length>0)for(let n of t.lines){let c=n.text?n.text.toLowerCase().trim():"";if(!c||!n.bbox||!(c===o||new RegExp(`\\b${K(o)}\\b`,"i").test(c)))continue;let w=n.words||(t.words?t.words.filter(f=>f.bbox&&f.bbox.x0>=n.bbox.x0-5&&f.bbox.x1<=n.bbox.x1+5&&f.bbox.y0>=n.bbox.y0-5&&f.bbox.y1<=n.bbox.y1+5):[]),x=o.split(/\s+/),R=x.map(f=>f.replace(/[^a-z0-9]/g,"")).join(" "),M=!1;if(w.length>0)for(let f=0;f<=w.length-x.length;f++){let h=w.slice(f,f+x.length),p=h.map(g=>(g.text||"").toLowerCase().trim().replace(/[^a-z0-9]/g,"")).join(" ");if(p===R||p.includes(R)){let g={x0:Math.min(...h.map(u=>u.bbox.x0)),y0:Math.min(...h.map(u=>u.bbox.y0)),x1:Math.max(...h.map(u=>u.bbox.x1)),y1:Math.max(...h.map(u=>u.bbox.y1))};a.push(i(g)),M=!0}}M||a.push(i(n.bbox))}if(a.length===0&&t.words&&t.words.length>0)for(let n of t.words){let c=n.text?n.text.toLowerCase().trim().replace(/[^a-z0-9]/g,""):"",l=o.replace(/[^a-z0-9]/g,"");c===l&&n.bbox&&a.push(i(n.bbox))}if(a.length===0&&t.words&&t.words.length>0){let n=V(o.length);for(let c of t.words){let l=c.text?c.text.toLowerCase().trim():"";l.length>=3&&Math.abs(l.length-o.length)<=n&&Q(l,o,n)<=n&&c.bbox&&a.push(i(c.bbox))}}return a}function N(t,o){let e=null,s=1/0;for(let r of t){let i=Math.round((r.x0+r.x1)/2),a=Math.round((r.y0+r.y1)/2),n=o.x>=r.x0&&o.x<=r.x1&&o.y>=r.y0&&o.y<=r.y1,c=Math.hypot(i-o.x,a-o.y),l=n?0:c;l<s&&(s=l,e={x:i,y:a,dist:c,containsPoint:n,bbox:r})}return e}var C=null;async function tt(){return C||(C=(async()=>{let{createWorker:t}=await import("tesseract.js"),o=await import("fs-extra"),{CU_CACHE_DIR:e}=await import("./paths-MJECGRI2.js");return o.ensureDirSync(e),t("eng",1,{cachePath:e,logger:()=>{}})})().catch(t=>{throw C=null,t})),C}var I=null,F=null;async function et(){let{getActiveDisplay:t}=await import("./screen_grid-I6BDQFDD.js"),o=await t();if(I&&F===o)return I;F=o,I={format:"png"};try{let e=await X.listDisplays();e&&e.length>0&&(I={format:"png",screen:(e[o]||e[0]).id})}catch{}return I}var pt=async(t,o={})=>{let e=P(t),s=e.gridId||e.grid||e.coordinate||e.target||e.id,r=(e.type||e.clickType||"single").toLowerCase(),i=(e.button||"left").toLowerCase(),a=e.intendedClickText||e.text||"",n=e.ocrCorrection!==void 0?e.ocrCorrection===!0||e.ocrCorrection==="true":e.useOCR!==void 0?e.useOCR===!0||e.useOCR==="true":!1;if(!s&&!a)return'ERROR: Missing required "gridId" parameter for Click tool.';let c=s;if(n&&a)try{let x=s?B(s):null,R=await et(),M=await X(R),f=await O(M).metadata(),h=f.width||1920,p=f.height||1080,g=x?{x:Math.round(x.x*(h/1280)),y:Math.round(x.y*(p/720))}:{x:h/2,y:p/2},u=a.toLowerCase().trim(),d=await tt(),D=null,T="",q=x?320:500;if(x){let m=Math.min(Math.round(h/2),h),y=Math.min(Math.round(p/2),p),b=Math.max(0,Math.min(h-m,g.x-Math.floor(m/2))),k=Math.max(0,Math.min(p-y,g.y-Math.floor(y/2))),_=await O(M).extract({left:b,top:k,width:m,height:y}).toBuffer(),z=2,A=await H(_,z),J=u.replace(/[^a-z0-9]/g,"_");await U("cropped",`crop_${Date.now()}_${J}.png`,A),await d.setParameters({tessedit_pageseg_mode:"11"});let{data:v}=await d.recognize(A,{},{tsv:!0,blocks:!0});if(v&&v.text){let E=L(v,u,b,k,z);if(E.length>0){let $=N(E,g);$&&($.containsPoint||$.dist<=q)&&(D=$,T="centered target crop OCR")}}}if(!D){let m=await H(M,2),y=u.replace(/[^a-z0-9]/g,"_");await U("fullscreen",`full_${Date.now()}_${y}.png`,m),await d.setParameters({tessedit_pageseg_mode:"3"});let{data:b}=await d.recognize(m,{},{tsv:!0,blocks:!0});if(b&&b.text){let k=L(b,u,0,0,2);if(k.length>0){let _=N(k,g);_&&(D=_,T="full-screen OCR")}}}if(D){let m={x:Math.round(D.x*(1280/h)),y:Math.round(D.y*(720/p))},y=await W("click",m,{button:i,clickType:r});if(typeof y=="string"&&y.startsWith("ERROR:"))return y;let b=S(m),k=`${r==="double"?"Double":"Single"} clicked ${i} button`;return s&&b&&String(s)!==String(b)?`${k}. Tried clicking grid ${s}, but OCR corrected to grid ${b} (${T} for "${a}"). If the click landed unintended, try with ocr correction off.`:`${k} on grid ${b||s} (${T} for "${a}").`}}catch{}let l=await W("click",c,{button:i,clickType:r});if(typeof l=="string"&&l.startsWith("ERROR:"))return l;let w=s||(typeof c=="object"?S(c):c);return`${r==="double"?"Double":"Single"} clicked ${i} button on grid ${w}.`};export{pt as click};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as i,b as s}from"./chunk-
|
|
1
|
+
import{a as i,b as s}from"./chunk-FOELTIXU.js";import"./chunk-7UF7ZHP7.js";import{a as c}from"./chunk-Y5JU726N.js";var d=async(a,p={})=>{let e=c(a),r=e.action||e.type||e.cmd,n=e.target||e.grid||e.gridCode||e.location||e.input;if(!r)return'ERROR: Missing required "action" argument for computer_action (e.g. move, click, drag, scroll, type, key_press, key_combination).';let t=r.toLowerCase();if(t.startsWith("mouse_")||["move","click","drag","scroll"].includes(t)){let o=t.replace("mouse_","");return await i(o,n,{button:e.button,clickType:e.clickType||e.type,from:e.from,to:e.to,direction:e.direction,amount:e.amount?parseInt(e.amount,10):void 0})}if(t.startsWith("key_")||t==="type"||t==="press"){let o=t;t==="press"&&(o="key_press");let u=e.autoPressEnter===!0||e.autoPressEnter==="true"||e.enter===!0||e.enter==="true";return await s(o,n||e.text||e.keys,{...e,autoPressEnter:u})}return`ERROR: Unrecognized action "${r}". Supported actions: move, click, drag, scroll, type, key_press, key_combination.`};export{d as computer_action};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as m}from"./chunk-PTFCY2D5.js";import{a as L}from"./chunk-
|
|
1
|
+
import{a as m}from"./chunk-PTFCY2D5.js";import{a as L}from"./chunk-XPIXBWTZ.js";import{n as U}from"./chunk-WEDUYGPN.js";import"./chunk-NTZSL2UT.js";import"./chunk-YFIWMGCS.js";var Q=async function*(_,C,v,E,A,b,$,d,W=1,B=""){let x=[];E&&x.push({role:"system",content:E});for(let t of v){let e=t.role==="user"?"user":"assistant",n=[];if(Array.isArray(t.parts)){for(let o of t.parts)if(o.text)n.push({type:"text",text:o.text});else if(o.inlineData&&$){let c=o.inlineData.mimeType,u=o.inlineData.data;c.startsWith("image/")&&n.push({type:"image_url",image_url:{url:`data:${c};base64,${u}`}})}}else{let o=t.text||"";o&&n.push({type:"text",text:o})}x.push({role:e,content:n.length===1&&n[0].type==="text"?n[0].text:n})}let P=L("c_openai",C,A),y=P!==null?P:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"xhigh"}[A],a={model:C,messages:x,stream:!0,stream_options:{include_usage:!0},temperature:W,tools:[],tool_choice:"none"};y&&y!=="none"&&(a.reasoning_effort=y,a.reasoning={effort:y});let N=(B||process.env.CUSTOM_OPENAI_URL||process.env.C_OPENAI_URL||"").trim();if(!N)throw new Error("Custom OpenAI Base URL is not configured. Please set Base URL in /settings -> Providers.");let f=N.replace(/\/+$/,"");f.endsWith("/chat/completions")||(f.endsWith("/v1")?f=`${f}/chat/completions`:f=`${f}/chat/completions`);let l={"Content-Type":"application/json",Accept:"text/event-stream, application/json","X-Title":"Flux-Flow","User-Agent":"Flux-Flow"},S=_===U,T=S?"":_&&_!=="LOCAL"?_:process.env.CUSTOM_OPENAI_API_KEY||process.env.C_OPENAI_API_KEY||"";if(!S&&T&&T.trim()!==""){let t=T.trim();l.Authorization=t.startsWith("Bearer ")?t:`Bearer ${t}`,l["api-key"]=t}let s=await m(f,{method:"POST",headers:l,body:JSON.stringify(a),signal:d});if(!s.ok&&(s.status===400||s.status===422)&&(a.reasoning||a.reasoning_effort)){if(console.info(`
|
|
2
2
|
`),a.reasoning&&a.reasoning_effort){let t={...a};delete t.reasoning_effort;let e=await m(f,{method:"POST",headers:l,body:JSON.stringify(t),signal:d}).catch(()=>null);e&&e.ok&&(s=e)}if(!s.ok&&a.reasoning_effort){let t={...a};delete t.reasoning;let e=await m(f,{method:"POST",headers:l,body:JSON.stringify(t),signal:d}).catch(()=>null);e&&e.ok&&(s=e)}if(!s.ok){let t={...a};delete t.reasoning,delete t.reasoning_effort;let e=await m(f,{method:"POST",headers:l,body:JSON.stringify(t),signal:d}).catch(()=>null);e&&e.ok&&(s=e)}}if(!s.ok){let t=await s.json().catch(()=>({})),e=t.error?.metadata?.raw||t.error?.message||(typeof t.error=="string"?t.error:"")||t.message||s.statusText||"Unknown error";throw new Error(`Custom OpenAI Error (${s.status}): ${e}`)}let F=s.body.getReader(),J=new TextDecoder,w="",i=[],p=null,k=Date.now(),g=!1,R=(t,e)=>{if(!t&&!e)return null;if(t){if(typeof t.reasoning_content=="string"&&t.reasoning_content)return t.reasoning_content;if(typeof t.reasoning=="string"&&t.reasoning)return t.reasoning;if(typeof t.thinking=="string"&&t.thinking)return t.thinking;if(typeof t.thought=="string"&&t.thought)return t.thought;if(typeof t.reasoning_text=="string"&&t.reasoning_text)return t.reasoning_text;if(Array.isArray(t.reasoning_details)&&t.reasoning_details.length>0){let n=t.reasoning_details.map(o=>typeof o=="string"?o:o?.text||o?.content||"").filter(Boolean).join("");if(n)return n}}if(e){if(typeof e.reasoning_content=="string"&&e.reasoning_content)return e.reasoning_content;if(typeof e.reasoning=="string"&&e.reasoning)return e.reasoning}return null},K=(t,e)=>{if(t){if(typeof t.content=="string"&&t.content)return t.content;if(typeof t.text=="string"&&t.text)return t.text;if(Array.isArray(t.content))return t.content.map(n=>typeof n=="string"?n:n?.text||"").join("")}return e&&typeof e.text=="string"&&e.text?e.text:""},Y=t=>{let e=t.usage||t.usageMetadata||t.choices?.[0]?.usage||null;if(!e)return null;let n=e.prompt_tokens||e.promptTokenCount||e.input_tokens||0,o=e.completion_tokens||e.candidatesTokenCount||e.output_tokens||0,c=e.total_tokens||e.totalTokenCount||n+o,u=e.prompt_tokens_details?.cached_tokens||e.prompt_tokens_details?.cache_read_input_tokens||e.cachedContentTokenCount||e.cache_read_input_tokens||0,r=e.completion_tokens_details?.reasoning_tokens||e.thoughtsTokenCount||e.reasoning_tokens||0;return{totalTokenCount:c,promptTokenCount:n,candidatesTokenCount:o,cachedContentTokenCount:u,thoughtsTokenCount:r}};for(;;){let{done:t,value:e}=await F.read();if(t){g&&(i.length>0||p)&&(yield{candidates:i.length>0?[{content:{parts:i}}]:[],usageMetadata:p});break}w+=J.decode(e,{stream:!0});let n=w.split(`
|
|
3
3
|
`);w=n.pop();for(let o of n){let c=o.trim();if(!c||!c.startsWith("data: "))continue;let u=!1;if(c==="data: [DONE]"||c==="data: [DONE]\r")u=!0;else try{let r=JSON.parse(c.substring(6));if(r.error){let H=r.error.metadata?.raw||r.error.message||(typeof r.error=="string"?r.error:JSON.stringify(r.error));throw new Error(`Custom OpenAI Stream Error: ${H}`)}let h=r.choices?.[0],O=h?.delta;h?.finish_reason&&h.finish_reason!=="null"&&(u=!0);let D=Y(r);D&&(p=D,g=!0);let I=R(O,h);I&&(i.push({text:I,thought:!0}),g=!0);let M=K(O,h);M&&(i.push({text:M}),g=!0)}catch(r){if(r.message&&r.message.startsWith("Custom OpenAI Stream Error:"))throw r}if((u||Date.now()-k>=150)&&g&&(yield{candidates:i.length>0?[{content:{parts:[...i]}}]:[],usageMetadata:p},i=[],k=Date.now(),g=!1),u)break}Date.now()-k>=150&&g&&(yield{candidates:i.length>0?[{content:{parts:[...i]}}]:[],usageMetadata:p},i=[],k=Date.now(),g=!1)}};export{Q as getCustomOpenAIStream};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as b}from"./chunk-PTFCY2D5.js";import{a as T}from"./chunk-
|
|
1
|
+
import{a as b}from"./chunk-PTFCY2D5.js";import{a as T}from"./chunk-XPIXBWTZ.js";import"./chunk-YFIWMGCS.js";var B=async function*(C,y,M,x,g,O,S,E,$=1){let m=[];x&&m.push({role:"system",content:x});for(let o of M){let k=o.role==="user"?"user":"assistant",a=[];if(Array.isArray(o.parts)){for(let e of o.parts)if(e.text)a.push({type:"text",text:e.text});else if((e.inlineData||e.inline_data)&&S){let s=e.inlineData||e.inline_data,r=s.mimeType||s.mime_type||"image/jpeg",l=s.data;r.startsWith("image/")&&a.push({type:"image_url",image_url:{url:`data:${r};base64,${l}`}})}}else{let e=o.text||"";e&&a.push({type:"text",text:e})}m.push({role:k,content:a.length===1&&a[0].type==="text"?a[0].text:a})}let f={model:y,messages:m,stream:!0,stream_options:{include_usage:!0},temperature:$,tools:[],tool_choice:"none"},D=T("DeepSeek",y,g),c=D!==null?D:g!=="Fast"?{Low:"low",Medium:"high",Standard:"high",High:"max",xHigh:"max"}[g]||"high":null;c&&c!=="disabled"&&c!=="none"&&c!=="false"&&c!==!1?(f.reasoning_effort=c,f.extra_body={thinking:{type:"enabled"}}):f.extra_body={thinking:{type:"disabled"}};let p=await b("https://api.deepseek.com/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${C}`,"Content-Type":"application/json"},body:JSON.stringify(f),signal:E});if(!p.ok){let o=await p.json().catch(()=>({}));throw new Error(`DeepSeek Error (${p.status}): ${o.error?.message||p.statusText}`)}let j=p.body.getReader(),N=new TextDecoder,_="",t=[],d=null,h=Date.now(),n=!1;for(;;){let{done:o,value:k}=await j.read();if(o){n&&(t.length>0||d)&&(yield{candidates:t.length>0?[{content:{parts:t}}]:[],usageMetadata:d});break}_+=N.decode(k,{stream:!0});let a=_.split(`
|
|
2
2
|
`);_=a.pop();for(let e of a){let s=e.trim();if(!s||!s.startsWith("data: "))continue;let r=!1;if(s==="data: [DONE]")r=!0;else try{let l=JSON.parse(s.substring(6)),u=l.choices?.[0]?.delta,i=l.usage;if(l.choices?.[0]?.finish_reason&&(r=!0),i&&(d={totalTokenCount:i.total_tokens||i.prompt_tokens+i.completion_tokens,promptTokenCount:i.prompt_tokens||0,candidatesTokenCount:i.completion_tokens||0,cachedContentTokenCount:i.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:i.completion_tokens_details?.reasoning_tokens||0},n=!0),u){let w=u.reasoning_content||null;w&&(t.push({text:w,thought:!0}),n=!0),u.content&&(t.push({text:u.content}),n=!0)}}catch{}if((r||Date.now()-h>=150)&&n&&(yield{candidates:t.length>0?[{content:{parts:[...t]}}]:[],usageMetadata:d},t=[],h=Date.now(),n=!1),r)break}Date.now()-h>=150&&n&&(yield{candidates:t.length>0?[{content:{parts:[...t]}}]:[],usageMetadata:d},t=[],h=Date.now(),n=!1)}};export{B as getDeepSeekStream};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./chunk-
|
|
1
|
+
import{a as e}from"./chunk-FOELTIXU.js";import"./chunk-7UF7ZHP7.js";import{a as d}from"./chunk-Y5JU726N.js";var m=async(a,i={})=>{let r=d(a),o=r.fromGridId||r.from||r.start,t=r.toGridId||r.to||r.end;return!o||!t?'ERROR: Drag requires both "fromGridId" and "toGridId" parameters.':await e("drag",o,{from:o,to:t})};export{m as drag};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
1
|
+
import{a as i}from"./chunk-BLAXTPPN.js";import{a as f}from"./chunk-Y5JU726N.js";import"./chunk-NTZSL2UT.js";import"./chunk-YFIWMGCS.js";var m=async(k,c={})=>{let l=f(k),s=l.method,d=l.id,a=c.chatId;if(!c.systemSettings?.advanceRollback)return"ERROR: Advance Rollback feature is currently disabled in settings under Security. Tell user to enable it if needed.";if(!a)return"ERROR: No active chat transaction found for rollback.";if(s==="getCheckpoint"){let r=await i.getCheckpoints(a);if(r.length===0)return"No checkpoints available.";let n={write_file:"WriteFile",update_file:"PatchFile",view_file:"ReadFile",read_folder:"ReadFolder",exec_command:"Run",web_search:"WebSearch",web_scrape:"WebScrape",search_keyword:"SearchKeyword",CodeSearch:"SearchKeyword",code_search:"SearchKeyword",write_pdf:"WritePDF",write_docx:"WriteDoc",generate_image:"GenerateImage",file_map:"FileMap",todo:"Todo",goal:"Goal",Goal:"Goal",await:"Await",ask:"AskUser",ask_user:"AskUser",AskUser:"AskUser",askuser:"AskUser",invoke:"Invoke",invokesync:"InvokeSync",getprogress:"GetProgress",cancel:"Cancel",emergency_rollback:"EmergencyRollback",emergencyrollback:"EmergencyRollback"},t=e=>n[e]||n[e.toLowerCase()]||e,o=`Available checkpoints for rollback:
|
|
2
2
|
|
|
3
3
|
`;for(let e of r)if(e.id==="initial")o+=`--- Initial State (id: initial) ---
|
|
4
4
|
Tools Used: User Prompted for task
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as D}from"./chunk-PTFCY2D5.js";import{a as A}from"./chunk-
|
|
1
|
+
import{a as D}from"./chunk-PTFCY2D5.js";import{a as A}from"./chunk-XPIXBWTZ.js";import"./chunk-YFIWMGCS.js";var U=async function*(L,_,b,y,x,R,P,S,C=1){let g=[];y&&g.push({role:"system",content:y});for(let o of b){let m=o.role==="user"?"user":"assistant",e=[];if(Array.isArray(o.parts)){for(let n of o.parts)if(n.text)e.push({type:"text",text:n.text});else if(n.inlineData&&P){let i=n.inlineData.mimeType,p=n.inlineData.data;i.startsWith("image/")&&e.push({type:"image_url",image_url:{url:`data:${i};base64,${p}`}})}}else{let n=o.text||"";n&&e.push({type:"text",text:n})}g.push({role:m,content:e.length===1&&e[0].type==="text"?e[0].text:e})}let k=A("ExpLabs",_,x),E=k!==null?k:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[x],w={model:_,messages:g,stream:!0,stream_options:{include_usage:!0},temperature:C,tools:[],tool_choice:"none"};E&&(w.reasoning_effort=E);let M=process.env.EXPLABS_URL||process.env.EXPERIENTIALLABS_URL||"https://api.experientiallabs.ai/v1/chat/completions",T={"Content-Type":"application/json"},v=L||process.env.EXPLABS_API_KEY||process.env.EXPERIENTIALLABS_API_KEY||"";T.Authorization=`Bearer ${v}`;let c=await D(M,{method:"POST",headers:T,body:JSON.stringify(w),signal:S});if(!c.ok){let o=await c.json().catch(()=>({}));throw new Error(`Experiential Labs Error (${c.status}): ${o.error?.message||o.message||c.statusText}`)}let B=c.body.getReader(),I=new TextDecoder,h="",t=[],l=null,f=Date.now(),a=!1;for(;;){let{done:o,value:m}=await B.read();if(o){a&&(t.length>0||l)&&(yield{candidates:t.length>0?[{content:{parts:t}}]:[],usageMetadata:l});break}h+=I.decode(m,{stream:!0});let e=h.split(`
|
|
2
2
|
`);h=e.pop();for(let n of e){let i=n.trim();if(!i||!i.startsWith("data: "))continue;let p=!1;if(i==="data: [DONE]")p=!0;else try{let d=JSON.parse(i.substring(6)),r=d.choices?.[0]?.delta,s=d.usage;if(s&&(l={totalTokenCount:s.total_tokens||(s.prompt_tokens||0)+(s.completion_tokens||0),promptTokenCount:s.prompt_tokens||0,candidatesTokenCount:s.completion_tokens||0,cachedContentTokenCount:s.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:s.completion_tokens_details?.reasoning_tokens||s.reasoning_tokens||0},a=!0),r){let u=r.reasoning_content||r.reasoning||null;!u&&Array.isArray(r.reasoning_details)&&r.reasoning_details.length>0&&(u=r.reasoning_details.map(N=>N.text||"").filter(Boolean).join("")),u&&(t.push({text:u,thought:!0}),a=!0),r.content&&(t.push({text:r.content}),a=!0)}}catch{}if((p||Date.now()-f>=150)&&a&&(yield{candidates:t.length>0?[{content:{parts:[...t]}}]:[],usageMetadata:l},t=[],f=Date.now(),a=!1),p)break}Date.now()-f>=150&&a&&(yield{candidates:t.length>0?[{content:{parts:[...t]}}]:[],usageMetadata:l},t=[],f=Date.now(),a=!1)}};export{U as getExpLabsStream};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as $}from"./chunk-
|
|
1
|
+
import{d as $}from"./chunk-YFIWMGCS.js";import R from"fs-extra";import y from"path";var N=l=>{if(!l)return[];let u=[],p=/\[(?:tool|action):(.*?)\(([\s\S]*?)\)\]/g,n=0,i;for(;(i=p.exec(l))!==null;){if(i.index>n){let t=l.slice(n,i.index);t.trim()&&u.push({type:"output",content:t})}u.push({type:"tool",toolName:i[1],args:i[2]}),n=p.lastIndex}if(n<l.length){let t=l.slice(n);t.trim()&&u.push({type:"output",content:t})}return u},b=async(l,u,p=process.cwd())=>{let n=`export-fluxflow-${l}.txt`,i=y.join(p,n),t=[],o=!1;for(let m=0;m<u.length;m++){let r=u[m];if(r&&!(r.role==="system"||r.isMeta||r.isLogo||String(r.id).startsWith("welcome"))){if(r.role==="user"){let s=r.text||"";s=s.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),t.length>0&&t.push(""),t.push("[USER]"),t.push(s),o=!1}else if(r.role==="think"){o||(t.push(""),t.push("[AGENT]"),o=!0);let s=(r.text||"").replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/gi,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULT\]/gi,"").trim();s&&(t.push("[thoughts]"),t.push(s))}else if(r.role==="agent"){o||(t.push(""),t.push("[AGENT]"),o=!0);let s=N(r.text||"");for(let c of s)if(c.type==="output"){let a=c.content.replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/gi,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULT\]/gi,"").trim();a&&(t.push("[output]"),t.push(a))}else c.type==="tool"&&(t.push("[tool]"),t.push(`${c.toolName} ${c.args}`))}}}let O=t.join(`
|
|
2
2
|
`);return await R.writeFile(i,O,"utf8"),{exportFile:n,exportPath:i,totalLines:t.length}},j=(l,u="FluxFlow",p=null)=>{if(!l||!l.trim())return[];let n=l.split(`
|
|
3
3
|
`),i=[],t=[],o=/^\s*(?:CRITICAL\s+ERROR|ERROR|DEBUG|SEARCH|PUPPETEER|WARN|WARNING|INFO)\b/i,O=/^\s*-{3,}\s*$/,m=!1;for(let s of n)if(o.test(s)){m=!0;break}if(!m){let s=l.trim();if(!s)return[];let c=p?new Date(p).toLocaleString():"Unknown Time",a=/\bjanitor\b/i.test(s)?"Memory":u;return[{timestamp:c,level:"ERROR",source:a,message:s}]}for(let s of n)O.test(s)?t.length>0&&(i.push(t.join(`
|
|
4
4
|
`).trim()),t=[]):o.test(s)?(t.length>0&&(i.push(t.join(`
|