flujo-ai 3.30.0 → 3.31.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/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +153 -153
- package/.next/app-path-routes-manifest.json +20 -20
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +24 -24
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/api/approvals/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/approvals/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/backup/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/browse/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/bugs/enhance/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/cwd/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/encryption/secure/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/env/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/[id]/versions/[versionId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/[id]/versions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/compile/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/generate/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/improve/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/prompt-renderer/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/quick-chat/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/repair/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/local-models/capability/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/local-models/pull/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/local-models/suggest/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/app-sandbox/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/oauth-capability/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/prompts/get/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/prompts/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/resources/read/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/resources/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/tools/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/test-connection/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/test-connection/stream/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp-registry/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp-registry/spotlight/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/provider/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/test/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/callback/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/initiate/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/reset/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/build/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/derive-secrets/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/install/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/install/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/installed/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/resolve/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/scan-targets/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/search/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/uninstall/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/run/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/runs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/preview-schedule/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/reconcile/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/auth/resend/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/auth/reset/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/auth/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/oauth/callback/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/oauth/initiate/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/publish/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/settings/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/restore/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/runs/active/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/storage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/waves/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/webhooks/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
- package/.next/server/app/chat.html +1 -1
- package/.next/server/app/chat.rsc +1 -1
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.rsc +1 -1
- package/.next/server/app/executions/page_client-reference-manifest.js +1 -1
- package/.next/server/app/executions.html +1 -1
- package/.next/server/app/executions.rsc +1 -1
- package/.next/server/app/flows/page_client-reference-manifest.js +1 -1
- package/.next/server/app/flows.html +1 -1
- package/.next/server/app/flows.rsc +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/app/mcp/page_client-reference-manifest.js +1 -1
- package/.next/server/app/mcp-flows/route.js +1 -1
- package/.next/server/app/mcp-flows/route_client-reference-manifest.js +1 -1
- package/.next/server/app/mcp-proxy/[server]/route.js +1 -1
- package/.next/server/app/mcp-proxy/[server]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/mcp.html +1 -1
- package/.next/server/app/mcp.rsc +1 -1
- package/.next/server/app/models/page_client-reference-manifest.js +1 -1
- package/.next/server/app/packages/page_client-reference-manifest.js +1 -1
- package/.next/server/app/packages.html +1 -1
- package/.next/server/app/packages.rsc +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page.js +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings.html +1 -1
- package/.next/server/app/settings.rsc +2 -2
- package/.next/server/app/v1/chat/completions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/inject/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/resources/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/models/route_client-reference-manifest.js +1 -1
- package/.next/server/app/waves/page_client-reference-manifest.js +1 -1
- package/.next/server/app/waves.html +1 -1
- package/.next/server/app/waves.rsc +1 -1
- package/.next/server/app-paths-manifest.json +20 -20
- package/.next/server/chunks/166.js +4 -4
- package/.next/server/chunks/3570.js +42 -42
- package/.next/server/chunks/5040.js +1 -1
- package/.next/server/chunks/544.js +27 -27
- package/.next/server/chunks/5544.js +3 -3
- package/.next/server/chunks/701.js +1 -1
- package/.next/server/chunks/7506.js +1 -1
- package/.next/server/chunks/7821.js +1 -1
- package/.next/server/chunks/8387.js +1 -1
- package/.next/server/chunks/94.js +1 -1
- package/.next/server/functions-config-manifest.json +2 -2
- package/.next/server/middleware-manifest.json +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/app/settings/{page-fb336bb049bab72a.js → page-e3d9ffd69d16873a.js} +1 -1
- package/.next/trace +10 -10
- package/README.md +1 -1
- package/package.json +1 -1
- /package/.next/static/{A9jP2ydtYbqx-IayWP2Sg → eaxwKaaFHlA1_FLDIyFGi}/_buildManifest.js +0 -0
- /package/.next/static/{A9jP2ydtYbqx-IayWP2Sg → eaxwKaaFHlA1_FLDIyFGi}/_ssgManifest.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";exports.id=5544,exports.ids=[5544,7969],exports.modules={3233:(a,b,c)=>{c.d(b,{g:()=>f});var d=c(79646);let e=(0,c(50846).h)("utils/process/killProcessTree");function f(a,b=2e3){let c=a.pid;if(void 0===c)return()=>{};if("win32"===process.platform){try{(0,d.spawn)("taskkill",["/pid",String(c),"/T","/F"]).on("error",a=>e.debug(`taskkill failed for pid ${c}: ${a.message}`))}catch(a){e.debug(`taskkill spawn threw for pid ${c}: ${a instanceof Error?a.message:String(a)}`)}return()=>{}}try{process.kill(-c,"SIGTERM")}catch{}let g=setTimeout(()=>{try{process.kill(-c,"SIGKILL")}catch{}},b);return g.unref?.(),()=>clearTimeout(g)}},5591:(a,b,c)=>{c.d(b,{bz:()=>m,wp:()=>j});var d=c(33873),e=c.n(d),f=c(21820),g=c.n(f),h=c(43326),i=c(7969);let j="FLUJO_ALLOW_PROTECTED_PATHS",k=null;function l(a,...b){return e().resolve(a,...b)}function m(a){let b=e().resolve(a);if((function(){let a=[];try{a.push(e().resolve((0,h.getDataDir)()))}catch{}try{a.push(e().resolve(g().tmpdir()))}catch{}return a})().some(a=>(0,i.F)(a,b)))return{denied:!1};for(let a of function(){var a;let b="string"==typeof(a=process.env[j])&&/^(1|true|yes|on)$/i.test(a.trim()),c=(0,h.getHomeDir)(),d=`${b?"off":"on"}::${c}`;if(k&&k.key===d)return k.paths;let f=b?[]:function(a){let b=[];if("win32"===process.platform)for(let c of["AppData","Downloads","Desktop","Documents","Pictures","Music","Videos","OneDrive"])b.push(l(a,c));else if("darwin"===process.platform){for(let c of["Downloads","Desktop","Documents","Pictures","Music","Movies"])b.push(l(a,c));for(let c of["Library/Mail","Library/Messages","Library/Safari","Library/Cookies","Library/Calendars","Library/Application Support/AddressBook","Library/Application Support/com.apple.TCC","Library/PersonalizationPortrait","Library/Metadata/CoreSpotlight","Library/Suggestions"])b.push(l(a,c));for(let a of["/.Spotlight-V100","/.fseventsd","/.DocumentRevisions-V100"])b.push(e().resolve(a))}else for(let c of["Documents","Downloads","Desktop",".ssh",".gnupg",".aws",".config"])b.push(l(a,c));return Array.from(new Set(b))}(c);return k={key:d,paths:f},f}())if((0,i.F)(a,b))return{denied:!0,matchedRoot:a};return{denied:!1}}},7969:(a,b,c)=>{c.d(b,{F:()=>j,loadEffectiveRoots:()=>l});var d=c(33873),e=c.n(d),f=c(79551),g=c(50846),h=c(7658);let i=(0,g.h)("backend/services/mcp/internal/confinement");function j(a,b){let c=e().relative(a,b);return""===c||!c.startsWith("..")&&!e().isAbsolute(c)}async function k(a,b){let{resolveGlobalVars:d}=await Promise.resolve().then(c.bind(c,73456)),g=(await d(a)).trim();if(!g)return null;if(g.startsWith("file://"))try{return e().resolve((0,f.fileURLToPath)(g))}catch(a){return i.warn(`resolveRootToPath: could not parse file URI "${g}"`,a),null}return e().isAbsolute(g)?e().resolve(g):e().resolve(b,g)}async function l(a,b,d){let{getDataDir:f}=await Promise.resolve().then(c.bind(c,43326)),g=f(),l=function(a){for(let b of Array.isArray(a)?a:[a]){let a=process.env[b];if(!a||!a.trim())continue;let c=a.split(e().delimiter).map(a=>a.trim()).filter(Boolean).map(a=>e().resolve(a));if(c.length)return c}return null}(b),m=[];try{for(let b of(await (0,h.AC)(a)))m.push(e().isAbsolute(b)?e().resolve(b):e().resolve(g,b))}catch(a){i.warn("loadEffectiveRoots: could not read persisted roots",a)}try{let{getNodeRoots:b,getNodeRootsForId:e}=await Promise.resolve().then(c.bind(c,62850));for(let c of void 0!==d?(()=>{let c=e(a,d);return c.length>0?c:b(a)})():b(a)){let a=await k(c,g);a&&m.push(a)}}catch(a){i.warn("loadEffectiveRoots: could not read node roots",a)}let n=Array.from(new Set(m));if(!l)return 0===n.length?[g]:n;let o=n.filter(a=>l.some(b=>j(b,a)));return o.length?o:l}},35544:(a,b,c)=>{let d,e;c.d(b,{bashCallTool:()=>H,bashToolDefinitions:()=>B});var f=c(33873),g=c.n(f),h=c(29021),i=c.n(h),j=c(79646),k=c(3233),l=c(50846),m=c(43326),n=c(7658),o=c(7969),p=c(5591);let q=(0,l.h)("backend/services/mcp/internal/bashTools");function r(a){let b=(process.env.PATH??process.env.Path??"").split(g().delimiter).filter(Boolean),c="win32"===process.platform?(process.env.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean):[""];for(let d of b)for(let b of c){let c=g().join(d,`${a}${b}`);try{if(i().statSync(c).isFile())return c}catch{}}return null}function s(){return global.__flujo_bash_sessions||(global.__flujo_bash_sessions=new Map),global.__flujo_bash_sessions}function t(a,b=!1){return{content:[{type:"text",text:"string"==typeof a?a:JSON.stringify(a,null,2)}],...b?{isError:!0}:{}}}let u=["FLUJO_BASH_ROOTS","FLUJO_FS_ROOTS"];function v(a,b){let c=(0,m.getDataDir)(),d="string"==typeof a?a.trim():"",e=d?g().isAbsolute(d)?g().resolve(d):g().resolve(c,d):c,f=(0,p.bz)(e);if(f.denied)throw Error(`cwd "${e}" is within a protected location (${f.matchedRoot}) and is blocked by the FLUJO built-in server protected-path policy. Set ${p.wp}=1 to override (operator only).`);if(0===b.length||!b.some(a=>(0,o.F)(a,e)))throw Error(`cwd "${e}" is outside the configured bash roots.`);return e}function w(a,b,c){let d=[],e=new Set,f=a.match(/(?:[A-Za-z]:[\\/][^\s"']*|\\\\[^\s"']+|~\/[^\s"']*|(?<![\w.])\/[^\s"']+)/g)??[],h=(()=>{try{return(0,m.getHomeDir)()}catch{return""}})();for(let a of f){let f,i=a;i.startsWith("~/")&&h&&(i=g().join(h,i.slice(2)));try{f=g().isAbsolute(i)?g().resolve(i):g().resolve(b,i)}catch{continue}if(e.has(f))continue;e.add(f);let j=(0,p.bz)(f);j.denied?d.push(`Command references "${a}", which is inside a protected location (${j.matchedRoot}).`):c.length>0&&!c.some(a=>(0,o.F)(a,f))&&d.push(`Command references "${a}", which is outside the configured working roots.`)}return d}let x=new Set(["PATH","Path","HOME","USERPROFILE","TMP","TEMP","TMPDIR","LANG","LC_ALL","SystemRoot","windir","ComSpec","PATHEXT","SystemDrive","NUMBER_OF_PROCESSORS","PROCESSOR_ARCHITECTURE"]);function y(a){return"pwsh"===a||"bash"===a?a:"default"}function z(a,b,c){let{file:f,args:h,useShell:k,effectiveShell:l,fallbackFrom:m}=function(a,b){if("pwsh"===b){let b=void 0!==e?e:e=r("pwsh");return b?{file:b,args:["-NoProfile","-NonInteractive","-Command",a],useShell:!1,effectiveShell:"pwsh"}:{file:a,args:[],useShell:!0,effectiveShell:"default",fallbackFrom:"pwsh"}}if("bash"===b){let b=function(){if(void 0!==d)return d;let a=r("bash");return a||"win32"!==process.platform||(a=[process.env.ProgramFiles,process.env["ProgramFiles(x86)"],process.env.LocalAppData].filter(a=>!!a).flatMap(a=>[g().join(a,"Git","bin","bash.exe"),g().join(a,"Git","usr","bin","bash.exe"),g().join(a,"Programs","Git","bin","bash.exe"),g().join(a,"Programs","Git","usr","bin","bash.exe")]).find(a=>{try{return i().statSync(a).isFile()}catch{return!1}})??null),d=a,a}();return b?{file:b,args:["-c",a],useShell:!1,effectiveShell:"bash"}:{file:a,args:[],useShell:!0,effectiveShell:"default",fallbackFrom:"bash"}}return{file:a,args:[],useShell:!0,effectiveShell:"default"}}(a,c),n="win32"!==process.platform;try{return{child:(0,j.spawn)(f,h,{cwd:b,shell:k,env:function(){var a;if("string"==typeof(a=process.env.FLUJO_BASH_INHERIT_ENV)&&/^(1|true|yes|on)$/i.test(a.trim()))return process.env;let b={};for(let a of Object.keys(process.env))(x.has(a)||/^LC_/.test(a))&&(b[a]=process.env[a]);return b}(),detached:n}),effectiveShell:l,fallbackFrom:m}}catch(a){return{child:void 0,startError:a instanceof Error?a.message:String(a),effectiveShell:l,fallbackFrom:m}}}function A(a,b){return c=>{let d=a();if(d.length>=1e5)return;let e=!1;(d+=c).length>1e5&&(d=d.slice(0,1e5)+"\n…[output truncated]",e=!0),b(d,e)}}function B(){let a={type:"string",enum:["default","pwsh","bash"],description:'Which shell to use: "default" (the OS shell), "pwsh" (PowerShell 7+), or "bash". Falls back to the default shell if the requested one is unavailable.'},b={type:"string",description:"Working directory. Relative paths resolve against the FLUJO data directory. Defaults to the data directory. When bash roots are configured (via the MCP manager, or the FLUJO_BASH_ROOTS / FLUJO_FS_ROOTS env hard ceiling) a cwd outside them is rejected."};return[{name:"run",description:"Run a shell command to completion and return combined stdout/stderr plus the exit code. Pipes and chained commands work. Killed if it exceeds the timeout; large output is truncated. Returns { exitCode, cwd, shell, output, timedOut }.",inputSchema:{type:"object",properties:{command:{type:"string",description:'The command line to execute, e.g. "grep -r foo ." or "curl -s https://…".'},cwd:b,shell:a,timeout:{type:"number",description:"Timeout in seconds (default 60, max 600)."},normalizeNewlines:{type:"boolean",description:"If true, CRLF/CR in the captured output are normalized to LF."}},required:["command"]}},{name:"start",description:"Start a command in the BACKGROUND and return immediately with a { sessionId }. Use status/wait to observe it, write_stdin to feed it input, and kill to stop it.",inputSchema:{type:"object",properties:{command:{type:"string",description:"The command line to execute in the background."},cwd:b,shell:a},required:["command"]}},{name:"status",description:"Return the current state of a background session: { sessionId, running, exitCode, output, truncated }.",inputSchema:{type:"object",properties:{sessionId:{type:"string",description:"The id returned by start."}},required:["sessionId"]}},{name:"wait",description:"Wait until a background session finishes (or the timeout elapses). Returns { sessionId, running, exitCode, output, truncated, timedOut }.",inputSchema:{type:"object",properties:{sessionId:{type:"string",description:"The id returned by start."},timeout:{type:"number",description:"Max seconds to wait (default 60, max 600)."}},required:["sessionId"]}},{name:"write_stdin",description:'Write a string to a running background session\'s stdin. Pass "newline": false to omit the trailing newline. Returns { sessionId, written }.',inputSchema:{type:"object",properties:{sessionId:{type:"string",description:"The id returned by start."},data:{type:"string",description:"Text to write to stdin."},newline:{type:"boolean",description:"Append a trailing newline (default true)."}},required:["sessionId","data"]}},{name:"kill",description:"Kill a background session (and its whole process tree). Returns { sessionId, killed }.",inputSchema:{type:"object",properties:{sessionId:{type:"string",description:"The id returned by start."}},required:["sessionId"]}},{name:"list_sessions",description:"List all known background sessions with their state. Returns { sessions: [{ sessionId, command, running, exitCode, startedAt, endedAt }] }.",inputSchema:{type:"object",properties:{}}}]}function C(a,b){return b?a.replace(/\r\n?/g,"\n"):a}async function D(a,b){let c=String(a?.command??"").trim();if(!c)return t({error:'Provide "command": a shell command line to run.'},!0);let d=v(a.cwd,b),e=w(c,d,b),f=e.length?{warnings:e}:{},g=y(a.shell),h=!0===a.normalizeNewlines,i=Math.min(1e3*("number"==typeof a.timeout&&a.timeout>0?a.timeout:60),6e5);return await new Promise(a=>{let b,e="",j=!1,l=!1,m=!1,n=A(()=>e,(a,b)=>{e=a,j=b||j}),{child:o,startError:p,effectiveShell:q,fallbackFrom:r}=z(c,d,g),s=r?{requestedShell:r,usedShell:q}:void 0;if(p||!o)return void a(t({error:`Failed to start command (${q}): ${p??"unknown error"}`,cwd:d,shell:q,shellFallback:s},!0));let u=setTimeout(()=>{m=!0,b=(0,k.g)(o)},i),v=c=>{l||(l=!0,clearTimeout(u),b?.(),a(c))};o.stdout?.on("data",a=>n(a.toString())),o.stderr?.on("data",a=>n(a.toString())),o.on("error",a=>{n(`
|
|
1
|
+
"use strict";exports.id=5544,exports.ids=[5544,7969],exports.modules={3233:(a,b,c)=>{c.d(b,{g:()=>f});var d=c(79646);let e=(0,c(50846).h)("utils/process/killProcessTree");function f(a,b=2e3){let c=a.pid;if(void 0===c)return()=>{};if("win32"===process.platform){try{(0,d.spawn)("taskkill",["/pid",String(c),"/T","/F"]).on("error",a=>e.debug(`taskkill failed for pid ${c}: ${a.message}`))}catch(a){e.debug(`taskkill spawn threw for pid ${c}: ${a instanceof Error?a.message:String(a)}`)}return()=>{}}try{process.kill(-c,"SIGTERM")}catch{}let g=setTimeout(()=>{try{process.kill(-c,"SIGKILL")}catch{}},b);return g.unref?.(),()=>clearTimeout(g)}},5591:(a,b,c)=>{c.d(b,{bz:()=>q,cd:()=>n,wp:()=>m});var d=c(33873),e=c.n(d),f=c(21820),g=c.n(f),h=c(43326),i=c(92372),j=c(84653),k=c(7969);function l(a){return"string"==typeof a&&/^(1|true|yes|on)$/i.test(a.trim())}let m="FLUJO_ALLOW_PROTECTED_PATHS";async function n(){if(l(process.env[m]))return!1;try{let a=await (0,i.YM)(j.Z.SPEECH_SETTINGS,void 0);return a?.experimental?.protectedPathsEnabled===!0}catch{return!1}}let o=null;function p(a,...b){return e().resolve(a,...b)}function q(a){let b=e().resolve(a);if((function(){let a=[];try{a.push(e().resolve((0,h.getDataDir)()))}catch{}try{a.push(e().resolve(g().tmpdir()))}catch{}return a})().some(a=>(0,k.F)(a,b)))return{denied:!1};for(let a of function(){let a=l(process.env[m]),b=(0,h.getHomeDir)(),c=`${a?"off":"on"}::${b}`;if(o&&o.key===c)return o.paths;let d=a?[]:function(a){let b=[];if("win32"===process.platform)for(let c of["AppData","Downloads","Desktop","Documents","Pictures","Music","Videos","OneDrive"])b.push(p(a,c));else if("darwin"===process.platform){for(let c of["Downloads","Desktop","Documents","Pictures","Music","Movies"])b.push(p(a,c));for(let c of["Library/Mail","Library/Messages","Library/Safari","Library/Cookies","Library/Calendars","Library/Application Support/AddressBook","Library/Application Support/com.apple.TCC","Library/PersonalizationPortrait","Library/Metadata/CoreSpotlight","Library/Suggestions"])b.push(p(a,c));for(let a of["/.Spotlight-V100","/.fseventsd","/.DocumentRevisions-V100"])b.push(e().resolve(a))}else for(let c of["Documents","Downloads","Desktop",".ssh",".gnupg",".aws",".config"])b.push(p(a,c));return Array.from(new Set(b))}(b);return o={key:c,paths:d},d}())if((0,k.F)(a,b))return{denied:!0,matchedRoot:a};return{denied:!1}}},7969:(a,b,c)=>{c.d(b,{F:()=>j,loadEffectiveRoots:()=>l});var d=c(33873),e=c.n(d),f=c(79551),g=c(50846),h=c(7658);let i=(0,g.h)("backend/services/mcp/internal/confinement");function j(a,b){let c=e().relative(a,b);return""===c||!c.startsWith("..")&&!e().isAbsolute(c)}async function k(a,b){let{resolveGlobalVars:d}=await Promise.resolve().then(c.bind(c,73456)),g=(await d(a)).trim();if(!g)return null;if(g.startsWith("file://"))try{return e().resolve((0,f.fileURLToPath)(g))}catch(a){return i.warn(`resolveRootToPath: could not parse file URI "${g}"`,a),null}return e().isAbsolute(g)?e().resolve(g):e().resolve(b,g)}async function l(a,b,d){let{getDataDir:f}=await Promise.resolve().then(c.bind(c,43326)),g=f(),l=function(a){for(let b of Array.isArray(a)?a:[a]){let a=process.env[b];if(!a||!a.trim())continue;let c=a.split(e().delimiter).map(a=>a.trim()).filter(Boolean).map(a=>e().resolve(a));if(c.length)return c}return null}(b),m=[];try{for(let b of(await (0,h.AC)(a)))m.push(e().isAbsolute(b)?e().resolve(b):e().resolve(g,b))}catch(a){i.warn("loadEffectiveRoots: could not read persisted roots",a)}try{let{getNodeRoots:b,getNodeRootsForId:e}=await Promise.resolve().then(c.bind(c,62850));for(let c of void 0!==d?(()=>{let c=e(a,d);return c.length>0?c:b(a)})():b(a)){let a=await k(c,g);a&&m.push(a)}}catch(a){i.warn("loadEffectiveRoots: could not read node roots",a)}let n=Array.from(new Set(m));if(!l)return 0===n.length?[g]:n;let o=n.filter(a=>l.some(b=>j(b,a)));return o.length?o:l}},35544:(a,b,c)=>{let d,e;c.d(b,{bashCallTool:()=>I,bashToolDefinitions:()=>B});var f=c(33873),g=c.n(f),h=c(29021),i=c.n(h),j=c(79646),k=c(3233),l=c(50846),m=c(43326),n=c(7658),o=c(7969),p=c(5591);let q=(0,l.h)("backend/services/mcp/internal/bashTools");function r(a){let b=(process.env.PATH??process.env.Path??"").split(g().delimiter).filter(Boolean),c="win32"===process.platform?(process.env.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean):[""];for(let d of b)for(let b of c){let c=g().join(d,`${a}${b}`);try{if(i().statSync(c).isFile())return c}catch{}}return null}function s(){return global.__flujo_bash_sessions||(global.__flujo_bash_sessions=new Map),global.__flujo_bash_sessions}function t(a,b=!1){return{content:[{type:"text",text:"string"==typeof a?a:JSON.stringify(a,null,2)}],...b?{isError:!0}:{}}}let u=["FLUJO_BASH_ROOTS","FLUJO_FS_ROOTS"];async function v(a,b){let c=(0,m.getDataDir)(),d="string"==typeof a?a.trim():"",e=d?g().isAbsolute(d)?g().resolve(d):g().resolve(c,d):c;if(await (0,p.cd)()){let a=(0,p.bz)(e);if(a.denied)throw Error(`cwd "${e}" is within a protected location (${a.matchedRoot}) and is blocked by the FLUJO built-in server protected-path policy. Disable "Protect sensitive home-directory paths" in Experimental Features or set ${p.wp}=1 to override.`)}if(0===b.length||!b.some(a=>(0,o.F)(a,e)))throw Error(`cwd "${e}" is outside the configured bash roots.`);return e}async function w(a,b,c){let d=[],e=await (0,p.cd)(),f=new Set,h=a.match(/(?:[A-Za-z]:[\\/][^\s"']*|\\\\[^\s"']+|~\/[^\s"']*|(?<![\w.])\/[^\s"']+)/g)??[],i=(()=>{try{return(0,m.getHomeDir)()}catch{return""}})();for(let a of h){let h,j=a;j.startsWith("~/")&&i&&(j=g().join(i,j.slice(2)));try{h=g().isAbsolute(j)?g().resolve(j):g().resolve(b,j)}catch{continue}if(f.has(h))continue;f.add(h);let k=e?(0,p.bz)(h):{denied:!1};k.denied?d.push(`Command references "${a}", which is inside a protected location (${k.matchedRoot}).`):c.length>0&&!c.some(a=>(0,o.F)(a,h))&&d.push(`Command references "${a}", which is outside the configured working roots.`)}return d}let x=new Set(["PATH","Path","HOME","USERPROFILE","TMP","TEMP","TMPDIR","LANG","LC_ALL","SystemRoot","windir","ComSpec","PATHEXT","SystemDrive","NUMBER_OF_PROCESSORS","PROCESSOR_ARCHITECTURE"]);function y(a){return"pwsh"===a||"bash"===a?a:"default"}function z(a,b,c){let{file:f,args:h,useShell:k,effectiveShell:l,fallbackFrom:m}=function(a,b){if("pwsh"===b){let b=void 0!==e?e:e=r("pwsh");return b?{file:b,args:["-NoProfile","-NonInteractive","-Command",a],useShell:!1,effectiveShell:"pwsh"}:{file:a,args:[],useShell:!0,effectiveShell:"default",fallbackFrom:"pwsh"}}if("bash"===b){let b=function(){if(void 0!==d)return d;let a=r("bash");return a||"win32"!==process.platform||(a=[process.env.ProgramFiles,process.env["ProgramFiles(x86)"],process.env.LocalAppData].filter(a=>!!a).flatMap(a=>[g().join(a,"Git","bin","bash.exe"),g().join(a,"Git","usr","bin","bash.exe"),g().join(a,"Programs","Git","bin","bash.exe"),g().join(a,"Programs","Git","usr","bin","bash.exe")]).find(a=>{try{return i().statSync(a).isFile()}catch{return!1}})??null),d=a,a}();return b?{file:b,args:["-c",a],useShell:!1,effectiveShell:"bash"}:{file:a,args:[],useShell:!0,effectiveShell:"default",fallbackFrom:"bash"}}return{file:a,args:[],useShell:!0,effectiveShell:"default"}}(a,c),n="win32"!==process.platform;try{return{child:(0,j.spawn)(f,h,{cwd:b,shell:k,env:function(){var a;if("string"==typeof(a=process.env.FLUJO_BASH_INHERIT_ENV)&&/^(1|true|yes|on)$/i.test(a.trim()))return process.env;let b={};for(let a of Object.keys(process.env))(x.has(a)||/^LC_/.test(a))&&(b[a]=process.env[a]);return b}(),detached:n}),effectiveShell:l,fallbackFrom:m}}catch(a){return{child:void 0,startError:a instanceof Error?a.message:String(a),effectiveShell:l,fallbackFrom:m}}}function A(a,b){return c=>{let d=a();if(d.length>=1e5)return;let e=!1;(d+=c).length>1e5&&(d=d.slice(0,1e5)+"\n…[output truncated]",e=!0),b(d,e)}}function B(){let a={type:"string",enum:["default","pwsh","bash"],description:'Which shell to use: "default" (the OS shell), "pwsh" (PowerShell 7+), or "bash". Falls back to the default shell if the requested one is unavailable.'},b={type:"string",description:"Working directory. Relative paths resolve against the FLUJO data directory. Defaults to the data directory. When bash roots are configured (via the MCP manager, or the FLUJO_BASH_ROOTS / FLUJO_FS_ROOTS env hard ceiling) a cwd outside them is rejected."};return[{name:"run",description:"Run a shell command to completion and return combined stdout/stderr plus the exit code. Pipes and chained commands work. Killed if it exceeds the timeout; large output is truncated. Returns { exitCode, cwd, shell, output, timedOut }.",inputSchema:{type:"object",properties:{command:{type:"string",description:'The command line to execute, e.g. "grep -r foo ." or "curl -s https://…".'},cwd:b,shell:a,timeout:{type:"number",description:"Timeout in seconds (default 60, max 600)."},normalizeNewlines:{type:"boolean",description:"If true, CRLF/CR in the captured output are normalized to LF."}},required:["command"]}},{name:"start",description:"Start a command in the BACKGROUND and return immediately with a { sessionId }. Use status/wait to observe it, write_stdin to feed it input, and kill to stop it.",inputSchema:{type:"object",properties:{command:{type:"string",description:"The command line to execute in the background."},cwd:b,shell:a},required:["command"]}},{name:"status",description:"Return the current state of a background session: { sessionId, running, exitCode, output, truncated }.",inputSchema:{type:"object",properties:{sessionId:{type:"string",description:"The id returned by start."}},required:["sessionId"]}},{name:"wait",description:"Wait until a background session finishes (or the timeout elapses). Returns { sessionId, running, exitCode, output, truncated, timedOut }.",inputSchema:{type:"object",properties:{sessionId:{type:"string",description:"The id returned by start."},timeout:{type:"number",description:"Max seconds to wait (default 60, max 600)."}},required:["sessionId"]}},{name:"write_stdin",description:'Write a string to a running background session\'s stdin. Pass "newline": false to omit the trailing newline. Returns { sessionId, written }.',inputSchema:{type:"object",properties:{sessionId:{type:"string",description:"The id returned by start."},data:{type:"string",description:"Text to write to stdin."},newline:{type:"boolean",description:"Append a trailing newline (default true)."}},required:["sessionId","data"]}},{name:"kill",description:"Kill a background session (and its whole process tree). Returns { sessionId, killed }.",inputSchema:{type:"object",properties:{sessionId:{type:"string",description:"The id returned by start."}},required:["sessionId"]}},{name:"list_sessions",description:"List all known background sessions with their state. Returns { sessions: [{ sessionId, command, running, exitCode, startedAt, endedAt }] }.",inputSchema:{type:"object",properties:{}}}]}function C(a,b){return b?a.replace(/\r\n?/g,"\n"):a}async function D(a,b){let c=String(a?.command??"").trim();if(!c)return t({error:'Provide "command": a shell command line to run.'},!0);let d=await v(a.cwd,b),e=await w(c,d,b),f=e.length?{warnings:e}:{},g=y(a.shell),h=!0===a.normalizeNewlines,i=Math.min(1e3*("number"==typeof a.timeout&&a.timeout>0?a.timeout:60),6e5);return await new Promise(a=>{let b,e="",j=!1,l=!1,m=!1,n=A(()=>e,(a,b)=>{e=a,j=b||j}),{child:o,startError:p,effectiveShell:q,fallbackFrom:r}=z(c,d,g),s=r?{requestedShell:r,usedShell:q}:void 0;if(p||!o)return void a(t({error:`Failed to start command (${q}): ${p??"unknown error"}`,cwd:d,shell:q,shellFallback:s},!0));let u=setTimeout(()=>{m=!0,b=(0,k.g)(o)},i),v=c=>{l||(l=!0,clearTimeout(u),b?.(),a(c))};o.stdout?.on("data",a=>n(a.toString())),o.stderr?.on("data",a=>n(a.toString())),o.on("error",a=>{n(`
|
|
2
2
|
${a.message}`),v(t({error:`Command failed to start (${q}): ${a.message}`,cwd:d,shell:q,shellFallback:s,output:C(e,h)},!0))}),o.on("close",a=>{let b=C(e,h);if(m)return void v(t({timedOut:!0,cwd:d,shell:q,shellFallback:s,exitCode:a,truncated:j,output:`${b}
|
|
3
|
-
[killed after ${i/1e3}s timeout]`,...f},!0));v(t({exitCode:a,cwd:d,shell:q,shellFallback:s,truncated:j,output:b,...f},0!==a))})})}function E(a){a.reapTimer=setTimeout(()=>{s().delete(a.id)},6e5),a.reapTimer.unref?.()}
|
|
4
|
-
${a.message}`),o.running=!1,o.endedAt=Date.now(),E(o)}),h.on("close",a=>{o.running=!1,o.exitCode=a,o.endedAt=Date.now(),E(o)}),t({sessionId:n,cwd:e,shell:j,shellFallback:m,...g})}(b,a)}case"status":let d=String(b?.sessionId??""),e=s().get(d);return e?t(
|
|
3
|
+
[killed after ${i/1e3}s timeout]`,...f},!0));v(t({exitCode:a,cwd:d,shell:q,shellFallback:s,truncated:j,output:b,...f},0!==a))})})}function E(a){a.reapTimer=setTimeout(()=>{s().delete(a.id)},6e5),a.reapTimer.unref?.()}async function F(a,b){let c=String(a?.command??"").trim();if(!c)return t({error:'Provide "command": a shell command line to run.'},!0);let d=s();if(d.size>=25)for(let[a,b]of d)b.running||d.delete(a);if(d.size>=25)return t({error:"Too many active background sessions (max 25). Kill some first."},!0);!function(){if(global.__flujo_bash_cleanup_registered)return;global.__flujo_bash_cleanup_registered=!0;let a=()=>(function(){for(let a of s().values()){if(a.running)try{(0,k.g)(a.child)}catch{}a.reapTimer&&clearTimeout(a.reapTimer)}})();process.on("exit",a),process.on("SIGINT",a),process.on("SIGTERM",a)}();let e=await v(a.cwd,b),f=await w(c,e,b),g=f.length?{warnings:f}:{},{child:h,startError:i,effectiveShell:j,fallbackFrom:l}=z(c,e,y(a.shell)),m=l?{requestedShell:l,usedShell:j}:void 0;if(i||!h)return t({error:`Failed to start command (${j}): ${i??"unknown error"}`,cwd:e,shell:j,shellFallback:m},!0);let n=`bash-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,o={id:n,command:c,cwd:e,child:h,output:"",truncated:!1,running:!0,exitCode:null,startedAt:Date.now()};d.set(n,o);let p=A(()=>o.output,(a,b)=>{o.output=a,o.truncated=b||o.truncated});return h.stdout?.on("data",a=>p(a.toString())),h.stderr?.on("data",a=>p(a.toString())),h.on("error",a=>{p(`
|
|
4
|
+
${a.message}`),o.running=!1,o.endedAt=Date.now(),E(o)}),h.on("close",a=>{o.running=!1,o.exitCode=a,o.endedAt=Date.now(),E(o)}),t({sessionId:n,cwd:e,shell:j,shellFallback:m,...g})}function G(a,b={}){return{sessionId:a.id,running:a.running,exitCode:a.exitCode,output:a.output,truncated:a.truncated,...b}}async function H(a){let b=String(a?.sessionId??""),c=s().get(b);if(!c)return t({error:`No background session with id "${b}".`},!0);if(!c.running)return t(G(c,{timedOut:!1}));let d=Math.min(1e3*("number"==typeof a.timeout&&a.timeout>0?a.timeout:60),6e5),e=await new Promise(a=>{let b=Date.now(),e=()=>c.running?Date.now()-b>=d?a(!0):void setTimeout(e,100):a(!1);e()});return t(G(c,{timedOut:e}))}async function I(a,b,c){try{switch(a){case"run":{let a=await (0,o.loadEffectiveRoots)(n.PA,u,c);return await D(b,a)}case"start":{let a=await (0,o.loadEffectiveRoots)(n.PA,u,c);return await F(b,a)}case"status":let d=String(b?.sessionId??""),e=s().get(d);return e?t(G(e)):t({error:`No background session with id "${d}".`},!0);case"wait":return await H(b);case"write_stdin":let f=String(b?.sessionId??""),g=s().get(f);if(!g)return t({error:`No background session with id "${f}".`},!0);if(!g.running)return t({error:`Session "${f}" has already exited.`},!0);let h="string"==typeof b.data?b.data:"",i=!1===b.newline?h:`${h}
|
|
5
5
|
`;try{g.child.stdin?.write(i)}catch(a){return t({error:`Failed to write to stdin: ${a instanceof Error?a.message:String(a)}`},!0)}return t({sessionId:f,written:Buffer.byteLength(i,"utf8")});case"kill":let j=String(b?.sessionId??""),l=s().get(j);return l?(l.running&&(l.cancelEscalation=(0,k.g)(l.child)),t({sessionId:j,killed:!0})):t({error:`No background session with id "${j}".`},!0);case"list_sessions":return t({sessions:Array.from(s().values()).map(a=>({sessionId:a.id,command:a.command,running:a.running,exitCode:a.exitCode,startedAt:new Date(a.startedAt).toISOString(),endedAt:a.endedAt?new Date(a.endedAt).toISOString():void 0}))});default:return t({error:`Unknown tool on the built-in bash server: ${a}`},!0)}}catch(b){return q.warn("bashCallTool failed",{toolName:a,err:b}),t({error:`Tool failed: ${b instanceof Error?b.message:String(b)}`},!0)}}}};
|
|
@@ -5,6 +5,6 @@ ${b.condition}
|
|
|
5
5
|
Tool result (untrusted data):
|
|
6
6
|
\`\`\`json
|
|
7
7
|
${m}
|
|
8
|
-
\`\`\``;try{let c="llm-gate"===b.mode?await j(b.modelId,n):await k(b.flowId,n),g=function(a){let b=a.match(/\{[\s\S]*\}/);if(!b)return null;try{let a=JSON.parse(b[0]);if("boolean"!=typeof a?.fire)return null;return{fire:a.fire,reason:"string"==typeof a.reason?a.reason:""}}catch{return null}}(c);if(!g)return f.warn(`Gate returned unparseable output: ${c.slice(0,200)}`),{fire:!1,newState:{lastHash:d,...l},error:"The AI check returned an unreadable answer — did not run the flow"};if(!g.fire)return{fire:!1,newState:{lastHash:d,...l}};return{fire:!0,summary:"flow-gate"===b.mode?"Flow condition met":"AI condition met",context:{result:(0,e.Je)(a),aiReason:g.reason},newState:{lastHash:d,...l}}}catch(b){let a=b instanceof Error?b.message:String(b);return f.warn(`Gate check failed: ${a}`),{fire:!1,newState:a.startsWith("config:")?{lastHash:d}:l,error:a.replace(/^config:\s*/,"")}}}async function j(a,b){let{modelService:d}=await Promise.resolve().then(c.bind(c,12763)),{getCompletionAdapter:e}=await Promise.resolve().then(c.bind(c,
|
|
8
|
+
\`\`\``;try{let c="llm-gate"===b.mode?await j(b.modelId,n):await k(b.flowId,n),g=function(a){let b=a.match(/\{[\s\S]*\}/);if(!b)return null;try{let a=JSON.parse(b[0]);if("boolean"!=typeof a?.fire)return null;return{fire:a.fire,reason:"string"==typeof a.reason?a.reason:""}}catch{return null}}(c);if(!g)return f.warn(`Gate returned unparseable output: ${c.slice(0,200)}`),{fire:!1,newState:{lastHash:d,...l},error:"The AI check returned an unreadable answer — did not run the flow"};if(!g.fire)return{fire:!1,newState:{lastHash:d,...l}};return{fire:!0,summary:"flow-gate"===b.mode?"Flow condition met":"AI condition met",context:{result:(0,e.Je)(a),aiReason:g.reason},newState:{lastHash:d,...l}}}catch(b){let a=b instanceof Error?b.message:String(b);return f.warn(`Gate check failed: ${a}`),{fire:!1,newState:a.startsWith("config:")?{lastHash:d}:l,error:a.replace(/^config:\s*/,"")}}}async function j(a,b){let{modelService:d}=await Promise.resolve().then(c.bind(c,12763)),{getCompletionAdapter:e}=await Promise.resolve().then(c.bind(c,33456)),{normalizeMaxTokens:f}=await Promise.resolve().then(c.bind(c,5091)),g=await d.getModel(a);if(!g)throw Error(`config: The AI-check model no longer exists (${a})`);let i=await d.resolveAndDecryptApiKey(g.ApiKey);if(!i)throw Error("config: Could not resolve the AI-check model API key");let j=e(g),{completion:k}=await j.createCompletion({model:g,apiKey:i,temperature:0,maxTokens:f(g.maxTokens),messages:[{role:"system",content:h},{role:"user",content:b}]}),l=k.choices?.[0]?.message?.content;return"string"==typeof l?l:""}async function k(a,b){let{runFlow:d}=await c.e(4551).then(c.bind(c,64551)),e=await d({flowId:a,prompt:`${b}
|
|
9
9
|
|
|
10
10
|
${g}`,mode:"ephemeral",requireApproval:!1,debug:!1,userTurn:!0});if("completed"!==e.status)throw Error(e.error?.message??`The checker flow ended with status "${e.status}"`);return e.outputText??""}}};
|
|
@@ -5,6 +5,6 @@ ${b.condition}
|
|
|
5
5
|
Tool result (untrusted data):
|
|
6
6
|
\`\`\`json
|
|
7
7
|
${m}
|
|
8
|
-
\`\`\``;try{let c="llm-gate"===b.mode?await j(b.modelId,n):await k(b.flowId,n),g=function(a){let b=a.match(/\{[\s\S]*\}/);if(!b)return null;try{let a=JSON.parse(b[0]);if("boolean"!=typeof a?.fire)return null;return{fire:a.fire,reason:"string"==typeof a.reason?a.reason:""}}catch{return null}}(c);if(!g)return f.warn(`Gate returned unparseable output: ${c.slice(0,200)}`),{fire:!1,newState:{lastHash:d,...l},error:"The AI check returned an unreadable answer — did not run the flow"};if(!g.fire)return{fire:!1,newState:{lastHash:d,...l}};return{fire:!0,summary:"flow-gate"===b.mode?"Flow condition met":"AI condition met",context:{result:(0,e.Je)(a),aiReason:g.reason},newState:{lastHash:d,...l}}}catch(b){let a=b instanceof Error?b.message:String(b);return f.warn(`Gate check failed: ${a}`),{fire:!1,newState:a.startsWith("config:")?{lastHash:d}:l,error:a.replace(/^config:\s*/,"")}}}async function j(a,b){let{modelService:d}=await Promise.all([c.e(3128),c.e(4322),c.e(5067),c.e(6034),c.e(7821),c.e(5096),c.e(544),c.e(1925)]).then(c.bind(c,20433)),{getCompletionAdapter:e}=await Promise.all([c.e(3128),c.e(4322),c.e(5067),c.e(6034),c.e(7821),c.e(5096),c.e(544),c.e(1925)]).then(c.bind(c,
|
|
8
|
+
\`\`\``;try{let c="llm-gate"===b.mode?await j(b.modelId,n):await k(b.flowId,n),g=function(a){let b=a.match(/\{[\s\S]*\}/);if(!b)return null;try{let a=JSON.parse(b[0]);if("boolean"!=typeof a?.fire)return null;return{fire:a.fire,reason:"string"==typeof a.reason?a.reason:""}}catch{return null}}(c);if(!g)return f.warn(`Gate returned unparseable output: ${c.slice(0,200)}`),{fire:!1,newState:{lastHash:d,...l},error:"The AI check returned an unreadable answer — did not run the flow"};if(!g.fire)return{fire:!1,newState:{lastHash:d,...l}};return{fire:!0,summary:"flow-gate"===b.mode?"Flow condition met":"AI condition met",context:{result:(0,e.Je)(a),aiReason:g.reason},newState:{lastHash:d,...l}}}catch(b){let a=b instanceof Error?b.message:String(b);return f.warn(`Gate check failed: ${a}`),{fire:!1,newState:a.startsWith("config:")?{lastHash:d}:l,error:a.replace(/^config:\s*/,"")}}}async function j(a,b){let{modelService:d}=await Promise.all([c.e(3128),c.e(4322),c.e(5067),c.e(6034),c.e(7821),c.e(5096),c.e(544),c.e(1925)]).then(c.bind(c,20433)),{getCompletionAdapter:e}=await Promise.all([c.e(3128),c.e(4322),c.e(5067),c.e(6034),c.e(7821),c.e(5096),c.e(544),c.e(1925)]).then(c.bind(c,58858)),{normalizeMaxTokens:f}=await c.e(6496).then(c.bind(c,46496)),g=await d.getModel(a);if(!g)throw Error(`config: The AI-check model no longer exists (${a})`);let i=await d.resolveAndDecryptApiKey(g.ApiKey);if(!i)throw Error("config: Could not resolve the AI-check model API key");let j=e(g),{completion:k}=await j.createCompletion({model:g,apiKey:i,temperature:0,maxTokens:f(g.maxTokens),messages:[{role:"system",content:h},{role:"user",content:b}]}),l=k.choices?.[0]?.message?.content;return"string"==typeof l?l:""}async function k(a,b){let{runFlow:d}=await Promise.all([c.e(3128),c.e(4322),c.e(5067),c.e(6034),c.e(7821),c.e(5096),c.e(544),c.e(4671),c.e(6226),c.e(4306)]).then(c.bind(c,16226)),e=await d({flowId:a,prompt:`${b}
|
|
9
9
|
|
|
10
10
|
${g}`,mode:"ephemeral",requireApproval:!1,debug:!1,userTurn:!0});if("completed"!==e.status)throw Error(e.error?.message??`The checker flow ended with status "${e.status}"`);return e.outputText??""}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.id=7821,exports.ids=[7821],exports.modules={87821:(a,b,c)=>{c.d(b,{flowService:()=>x});var d=c(32524),e=c(92372),f=c(38844),g=c(50846),h=c(33873),i=c.n(h),j=c(29021),k=c(43326);let l=(0,g.h)("backend/services/flow/flowVersions");function m(a){return(0,e.ln)(a),`flow-versions/${a}`}async function n(a){try{let b=m(a.id),c=Date.now(),d=`${c}-${Math.random().toString(36).slice(2,6)}`,f={versionId:d,flowId:a.id,savedAt:c,flow:a};return await (0,e.Vt)(b,d,f),await o(a.id),d}catch(b){return l.warn(`Could not archive a version of flow ${a.id}`,b),null}}async function o(a){let b=m(a),c=await (0,e.pL)(b);if(!(c.length<=25))for(let d of c.sort((a,b)=>b.savedAt-a.savedAt).slice(25))try{await (0,e.bB)(b,d.versionId)}catch(b){l.warn(`Could not prune version ${d.versionId} of flow ${a}`,b)}}async function p(a){return(await (0,e.pL)(m(a))).sort((a,b)=>b.savedAt-a.savedAt).map(a=>({versionId:a.versionId,savedAt:a.savedAt,name:a.flow?.name??"unknown",nodeCount:a.flow?.nodes?.length??0,edgeCount:a.flow?.edges?.length??0}))}async function q(a,b){try{return await (0,e.EI)(m(a),b,null)}catch(c){return l.debug(`getFlowVersion: could not load ${a}/${b}`,c),null}}async function r(a){try{(0,e.ln)(a),await j.promises.rm(i().join((0,k.getDataDir)(),"db","flow-versions",a),{recursive:!0,force:!0})}catch(b){l.warn(`Could not remove version history of flow ${a}`,b)}}let s=(0,g.h)("backend/services/flow/index"),t=f.Z.FLOWS;function u(a){let{createdAt:b,updatedAt:c,...d}=a;return JSON.stringify(d)}async function v(){return global.__flujo_flowsMigration||(global.__flujo_flowsMigration=(async()=>{try{await (0,e.w5)(f.Z.FLOWS,t,a=>a.id)}catch(a){s.error("Flow storage migration failed",a),global.__flujo_flowsMigration=void 0}})()),global.__flujo_flowsMigration}class w{get flowsCache(){return global.__flujo_flowsCache??null}set flowsCache(a){global.__flujo_flowsCache=a}async loadFlows(){try{if(this.flowsCache)return s.debug("Using cached flows"),this.flowsCache;s.debug("Loading flows from storage"),await v();let a=(await (0,e.av)(t)).map(({item:a,mtimeMs:b})=>{if(null!=a.createdAt&&null!=a.updatedAt)return a;let c=Math.floor(b);return{...a,createdAt:a.createdAt??c,updatedAt:a.updatedAt??c}});return this.flowsCache=a,s.info("Loaded flows from storage",{count:a.length}),a}catch(a){return s.error("Failed to load flows",a),[]}}async getFlow(a){try{s.debug(`Getting flow by ID: ${a}`);let b=this.flowsCache?.find(b=>b.id===a)||null;if(b)return s.debug(`Flow ${a} found in cache`),b;await v();let c=null;try{c=await (0,e.EI)(t,a,null)}catch(b){s.debug(`getFlow: could not load flow ${a}`,b),c=null}if(c&&this.flowsCache){let a=this.flowsCache,b=a.findIndex(a=>a.id===c.id);b>=0?a[b]=c:a.push(c),this.flowsCache=a}return s.debug(`Flow ${a} ${c?"found":"not found"}`),c}catch(b){return s.error(`Failed to get flow ${a}`,b),null}}async invalidateExecutionCache(a){try{let{FlowExecutor:b}=await Promise.all([c.e(3128),c.e(4322),c.e(5067),c.e(6034),c.e(5096),c.e(544),c.e(3629)]).then(c.bind(c,95708));b.clearFlowCache(a),s.debug("Invalidated execution flow cache",{flowId:a??"all"})}catch(a){s.warn("Failed to invalidate execution flow cache",a)}}async saveFlow(a){try{s.debug(`Saving flow: ${a.id}`,{name:a.name}),(0,e.ln)(a.id),await v();let b=null;try{b=await (0,e.EI)(t,a.id,null)}catch(b){s.debug(`saveFlow: could not read previous definition of ${a.id} for versioning`,b)}b&&u(b)!==u(a)&&await n(b);let c=Date.now();a.createdAt=b?.createdAt??a.createdAt??c,a.updatedAt=c,await (0,e.Vt)(t,a.id,a);let d=this.flowsCache;if(d){let b=d.findIndex(b=>b.id===a.id);b>=0?d[b]=a:d.push(a),this.flowsCache=d}return await this.invalidateExecutionCache(a.id),s.info(`Flow ${a.id} saved successfully`),{success:!0}}catch(a){return s.error("Failed to save flow",a),{success:!1,error:a instanceof Error?a.message:"Failed to save flow"}}}async deleteFlow(a){try{s.debug(`Deleting flow: ${a}`),await v(),await (0,e.bB)(t,a);let b=this.flowsCache;return b&&(this.flowsCache=b.filter(b=>b.id!==a)),await this.invalidateExecutionCache(a),await r(a),s.info(`Flow ${a} deleted successfully`),{success:!0}}catch(b){return s.error(`Failed to delete flow: ${a}`,b),{success:!1,error:b instanceof Error?b.message:"Failed to delete flow"}}}async listFlowVersions(a){return p(a)}async getFlowVersion(a,b){return q(a,b)}async revertFlow(a,b){let c=await q(a,b);return c?this.saveFlow({...c.flow,id:a}):{success:!1,error:`No version "${b}" of flow ${a}`}}createNode(a,b){s.debug(`Creating new node of type: ${a}`,{position:b});let c={id:(0,d.A)(),type:a,position:b,data:{label:`${"mcp"===a?"MCP":a.charAt(0).toUpperCase()+a.slice(1)} Node`,type:a,properties:{}}};return s.debug(`Node created with ID: ${c.id}`),c}createNewFlow(a="NewFlow"){s.debug(`Creating new flow: ${a}`);let b={id:(0,d.A)(),type:"start",position:{x:250,y:150},data:{label:"Start Node",type:"start",properties:{promptTemplate:""}}},c=Date.now(),e={id:(0,d.A)(),name:a,createdAt:c,updatedAt:c,nodes:[b],edges:[]};return s.info(`New flow created with ID: ${e.id}`,{name:a}),e}createHistoryEntry(a,b){return s.debug("Creating history entry",{nodeCount:a.length,edgeCount:b.length}),{nodes:[...a],edges:[...b]}}generateSampleFlow(a="Sample Flow"){s.debug(`Generating sample flow: ${a}`);let b={id:(0,d.A)(),name:a,nodes:[{id:"1",type:"start",position:{x:250,y:50},data:{label:"Start Node",type:"start",properties:{prompt:"Enter your query here",systemMessage:"You are a helpful assistant",temperature:0}}},{id:"2",type:"process",position:{x:250,y:200},data:{label:"Process Node",type:"process",properties:{operation:"transform",enabled:!0}}},{id:"3",type:"finish",position:{x:250,y:350},data:{label:"Finish Node",type:"finish",properties:{format:"json",template:'{ "result": {{data}} }'}}},{id:"4",type:"mcp",position:{x:450,y:200},data:{label:"MCP Node",type:"mcp",properties:{channels:2,mode:"parallel"}}}],edges:[{id:"e1-2",source:"1",target:"2",type:"custom"},{id:"e2-3",source:"2",target:"3",type:"custom"}]};return s.info(`Sample flow generated with ID: ${b.id}`,{name:a}),b}async listFlows(){s.debug("listFlows: Entering method");try{let a=await this.loadFlows();return{success:!0,flows:a}}catch(a){return s.warn("listFlows: Failed to list flows:",a),{success:!1,error:a instanceof Error?a.message:"Failed to list flows"}}}}let x=new w}};
|
|
1
|
+
"use strict";exports.id=7821,exports.ids=[7821],exports.modules={87821:(a,b,c)=>{c.d(b,{flowService:()=>x});var d=c(32524),e=c(92372),f=c(38844),g=c(50846),h=c(33873),i=c.n(h),j=c(29021),k=c(43326);let l=(0,g.h)("backend/services/flow/flowVersions");function m(a){return(0,e.ln)(a),`flow-versions/${a}`}async function n(a){try{let b=m(a.id),c=Date.now(),d=`${c}-${Math.random().toString(36).slice(2,6)}`,f={versionId:d,flowId:a.id,savedAt:c,flow:a};return await (0,e.Vt)(b,d,f),await o(a.id),d}catch(b){return l.warn(`Could not archive a version of flow ${a.id}`,b),null}}async function o(a){let b=m(a),c=await (0,e.pL)(b);if(!(c.length<=25))for(let d of c.sort((a,b)=>b.savedAt-a.savedAt).slice(25))try{await (0,e.bB)(b,d.versionId)}catch(b){l.warn(`Could not prune version ${d.versionId} of flow ${a}`,b)}}async function p(a){return(await (0,e.pL)(m(a))).sort((a,b)=>b.savedAt-a.savedAt).map(a=>({versionId:a.versionId,savedAt:a.savedAt,name:a.flow?.name??"unknown",nodeCount:a.flow?.nodes?.length??0,edgeCount:a.flow?.edges?.length??0}))}async function q(a,b){try{return await (0,e.EI)(m(a),b,null)}catch(c){return l.debug(`getFlowVersion: could not load ${a}/${b}`,c),null}}async function r(a){try{(0,e.ln)(a),await j.promises.rm(i().join((0,k.getDataDir)(),"db","flow-versions",a),{recursive:!0,force:!0})}catch(b){l.warn(`Could not remove version history of flow ${a}`,b)}}let s=(0,g.h)("backend/services/flow/index"),t=f.Z.FLOWS;function u(a){let{createdAt:b,updatedAt:c,...d}=a;return JSON.stringify(d)}async function v(){return global.__flujo_flowsMigration||(global.__flujo_flowsMigration=(async()=>{try{await (0,e.w5)(f.Z.FLOWS,t,a=>a.id)}catch(a){s.error("Flow storage migration failed",a),global.__flujo_flowsMigration=void 0}})()),global.__flujo_flowsMigration}class w{get flowsCache(){return global.__flujo_flowsCache??null}set flowsCache(a){global.__flujo_flowsCache=a}async loadFlows(){try{if(this.flowsCache)return s.debug("Using cached flows"),this.flowsCache;s.debug("Loading flows from storage"),await v();let a=(await (0,e.av)(t)).map(({item:a,mtimeMs:b})=>{if(null!=a.createdAt&&null!=a.updatedAt)return a;let c=Math.floor(b);return{...a,createdAt:a.createdAt??c,updatedAt:a.updatedAt??c}});return this.flowsCache=a,s.info("Loaded flows from storage",{count:a.length}),a}catch(a){return s.error("Failed to load flows",a),[]}}async getFlow(a){try{s.debug(`Getting flow by ID: ${a}`);let b=this.flowsCache?.find(b=>b.id===a)||null;if(b)return s.debug(`Flow ${a} found in cache`),b;await v();let c=null;try{c=await (0,e.EI)(t,a,null)}catch(b){s.debug(`getFlow: could not load flow ${a}`,b),c=null}if(c&&this.flowsCache){let a=this.flowsCache,b=a.findIndex(a=>a.id===c.id);b>=0?a[b]=c:a.push(c),this.flowsCache=a}return s.debug(`Flow ${a} ${c?"found":"not found"}`),c}catch(b){return s.error(`Failed to get flow ${a}`,b),null}}async invalidateExecutionCache(a){try{let{FlowExecutor:b}=await Promise.all([c.e(3128),c.e(4322),c.e(5067),c.e(6034),c.e(5096),c.e(544),c.e(3629)]).then(c.bind(c,95708));b.clearFlowCache(a),s.debug("Invalidated execution flow cache",{flowId:a??"all"})}catch(a){s.warn("Failed to invalidate execution flow cache",a)}}async saveFlow(a){try{s.debug(`Saving flow: ${a.id}`,{name:a.name}),(0,e.ln)(a.id),await v();for(let b of a.nodes){if("process"!==b.type||!b.data?.properties)continue;let a=b.data.properties;delete a.mcpNodes,delete a.resourceNodes}let b=null;try{b=await (0,e.EI)(t,a.id,null)}catch(b){s.debug(`saveFlow: could not read previous definition of ${a.id} for versioning`,b)}b&&u(b)!==u(a)&&await n(b);let c=Date.now();a.createdAt=b?.createdAt??a.createdAt??c,a.updatedAt=c,await (0,e.Vt)(t,a.id,a);let d=this.flowsCache;if(d){let b=d.findIndex(b=>b.id===a.id);b>=0?d[b]=a:d.push(a),this.flowsCache=d}return await this.invalidateExecutionCache(a.id),s.info(`Flow ${a.id} saved successfully`),{success:!0}}catch(a){return s.error("Failed to save flow",a),{success:!1,error:a instanceof Error?a.message:"Failed to save flow"}}}async deleteFlow(a){try{s.debug(`Deleting flow: ${a}`),await v(),await (0,e.bB)(t,a);let b=this.flowsCache;return b&&(this.flowsCache=b.filter(b=>b.id!==a)),await this.invalidateExecutionCache(a),await r(a),s.info(`Flow ${a} deleted successfully`),{success:!0}}catch(b){return s.error(`Failed to delete flow: ${a}`,b),{success:!1,error:b instanceof Error?b.message:"Failed to delete flow"}}}async listFlowVersions(a){return p(a)}async getFlowVersion(a,b){return q(a,b)}async revertFlow(a,b){let c=await q(a,b);return c?this.saveFlow({...c.flow,id:a}):{success:!1,error:`No version "${b}" of flow ${a}`}}createNode(a,b){s.debug(`Creating new node of type: ${a}`,{position:b});let c={id:(0,d.A)(),type:a,position:b,data:{label:`${"mcp"===a?"MCP":a.charAt(0).toUpperCase()+a.slice(1)} Node`,type:a,properties:{}}};return s.debug(`Node created with ID: ${c.id}`),c}createNewFlow(a="NewFlow"){s.debug(`Creating new flow: ${a}`);let b={id:(0,d.A)(),type:"start",position:{x:250,y:150},data:{label:"Start Node",type:"start",properties:{promptTemplate:""}}},c=Date.now(),e={id:(0,d.A)(),name:a,createdAt:c,updatedAt:c,nodes:[b],edges:[]};return s.info(`New flow created with ID: ${e.id}`,{name:a}),e}createHistoryEntry(a,b){return s.debug("Creating history entry",{nodeCount:a.length,edgeCount:b.length}),{nodes:[...a],edges:[...b]}}generateSampleFlow(a="Sample Flow"){s.debug(`Generating sample flow: ${a}`);let b={id:(0,d.A)(),name:a,nodes:[{id:"1",type:"start",position:{x:250,y:50},data:{label:"Start Node",type:"start",properties:{prompt:"Enter your query here",systemMessage:"You are a helpful assistant",temperature:0}}},{id:"2",type:"process",position:{x:250,y:200},data:{label:"Process Node",type:"process",properties:{operation:"transform",enabled:!0}}},{id:"3",type:"finish",position:{x:250,y:350},data:{label:"Finish Node",type:"finish",properties:{format:"json",template:'{ "result": {{data}} }'}}},{id:"4",type:"mcp",position:{x:450,y:200},data:{label:"MCP Node",type:"mcp",properties:{channels:2,mode:"parallel"}}}],edges:[{id:"e1-2",source:"1",target:"2",type:"custom"},{id:"e2-3",source:"2",target:"3",type:"custom"}]};return s.info(`Sample flow generated with ID: ${b.id}`,{name:a}),b}async listFlows(){s.debug("listFlows: Entering method");try{let a=await this.loadFlows();return{success:!0,flows:a}}catch(a){return s.warn("listFlows: Failed to list flows:",a),{success:!1,error:a instanceof Error?a.message:"Failed to list flows"}}}}let x=new w}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.id=8387,exports.ids=[8387],exports.modules={5591:(a,b,c)=>{c.d(b,{bz:()=>m,wp:()=>j});var d=c(33873),e=c.n(d),f=c(21820),g=c.n(f),h=c(43326),i=c(7969);let j="FLUJO_ALLOW_PROTECTED_PATHS",k=null;function l(a,...b){return e().resolve(a,...b)}function m(a){let b=e().resolve(a);if((function(){let a=[];try{a.push(e().resolve((0,h.getDataDir)()))}catch{}try{a.push(e().resolve(g().tmpdir()))}catch{}return a})().some(a=>(0,i.F)(a,b)))return{denied:!1};for(let a of function(){var a;let b="string"==typeof(a=process.env[j])&&/^(1|true|yes|on)$/i.test(a.trim()),c=(0,h.getHomeDir)(),d=`${b?"off":"on"}::${c}`;if(k&&k.key===d)return k.paths;let f=b?[]:function(a){let b=[];if("win32"===process.platform)for(let c of["AppData","Downloads","Desktop","Documents","Pictures","Music","Videos","OneDrive"])b.push(l(a,c));else if("darwin"===process.platform){for(let c of["Downloads","Desktop","Documents","Pictures","Music","Movies"])b.push(l(a,c));for(let c of["Library/Mail","Library/Messages","Library/Safari","Library/Cookies","Library/Calendars","Library/Application Support/AddressBook","Library/Application Support/com.apple.TCC","Library/PersonalizationPortrait","Library/Metadata/CoreSpotlight","Library/Suggestions"])b.push(l(a,c));for(let a of["/.Spotlight-V100","/.fseventsd","/.DocumentRevisions-V100"])b.push(e().resolve(a))}else for(let c of["Documents","Downloads","Desktop",".ssh",".gnupg",".aws",".config"])b.push(l(a,c));return Array.from(new Set(b))}(c);return k={key:d,paths:f},f}())if((0,i.F)(a,b))return{denied:!0,matchedRoot:a};return{denied:!1}}},18387:(a,b,c)=>{c.d(b,{filesystemCallTool:()=>O,filesystemToolDefinitions:()=>t});var d=c(33873),e=c.n(d),f=c(29021),g=c(55511),h=c(4984),i=c.n(h),j=c(50846),k=c(43326),l=c(7658),m=c(7969),n=c(5591),o=c(10793);let p=(0,j.h)("backend/services/mcp/internal/filesystemTools");function q(a){return{content:[{type:"text",text:JSON.stringify(a,null,2)}],structuredContent:a}}function r(a){return{content:[{type:"text",text:JSON.stringify({error:a},null,2)}],isError:!0}}function s(a,b){let c="string"==typeof a?a.trim():"";if(!c)throw Error('Provide "path".');let d=(0,k.getDataDir)(),f=e().isAbsolute(c)?e().resolve(c):e().resolve(d,c),g=(0,n.bz)(f);if(g.denied)throw Error(`Path "${f}" is within a protected location (${g.matchedRoot}) and is blocked by the FLUJO built-in server protected-path policy. Set ${n.wp}=1 to override (operator only).`);if(0===b.length||!b.some(a=>(0,m.F)(a,f)))throw Error(`Path "${f}" is outside the configured filesystem roots.`);return f}function t(){let a={type:"string",description:"File or directory path. Relative paths resolve against the FLUJO data directory; absolute paths are used as-is."};return[{name:"read_file",description:'Read a text file and return its content. Optionally read only a line range with "from"/"to" (1-based, inclusive). For large files (> 100 KB) read WHOLE (no "from"/"to"), a "pattern" is REQUIRED: the server greps the file and returns only matching lines (with a little surrounding context) so you can follow up with targeted "from"/"to" reads. Pass pattern "*" to force-read the entire large file anyway. Returns { path, from, to, totalLines, content, truncated, contentHash, matches? }. Pass the returned contentHash back as "expectedHash" on a follow-up edit_file/write_file to guard against the file changing in between (TOCTOU).',inputSchema:{type:"object",properties:{path:a,from:{type:"number",description:"Optional 1-based first line to return (inclusive)."},to:{type:"number",description:"Optional 1-based last line to return (inclusive)."},pattern:{type:"string",description:'Case-insensitive substring to grep for. Required to read a large file whole without a "from"/"to" range; matching lines (plus context) are returned instead of the full body. Use "*" to read the whole large file anyway.'}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},from:{type:"number"},to:{type:"number"},totalLines:{type:"number"},truncated:{type:"boolean"},content:{type:"string"},contentHash:{type:"string",description:'SHA-256 (hex) of the raw file content. Pass this back as "expectedHash" to edit_file/write_file to guard against the file changing between read and write (TOCTOU).'},matches:{type:"array",items:{type:"object",properties:{line:{type:"number"},text:{type:"string"}},required:["line","text"]}}},required:["path","from","to","totalLines","truncated","content"]}},{name:"write_file",description:'Create or write a text file (parent directories are created). "mode": "overwrite" (default) replaces the whole file, or a line range when "startLine"/"endLine" (1-based inclusive) are given; "append" adds content at the end; "insert" inserts content before "startLine". Optionally pass "expectedHash" (the contentHash from a prior read_file) to reject the write if the file changed on disk since it was read (TOCTOU guard); ignored for a whole-file overwrite. Returns { path, bytesWritten, mode, ... }.',_meta:{ui:{resourceUri:"ui://devcanvas/diff"}},inputSchema:{type:"object",properties:{path:a,content:{type:"string",description:"The content to write/insert/append."},mode:{type:"string",enum:["overwrite","append","insert"],description:'Write mode (default "overwrite").'},startLine:{type:"number",description:'For "insert": line to insert before. For "overwrite": first line of the range to replace (1-based).'},endLine:{type:"number",description:'For "overwrite": last line (inclusive, 1-based) of the range to replace.'},expectedHash:{type:"string",description:"Optional SHA-256 (contentHash from read_file). For append/insert/range-overwrite modes, the write is rejected if the file no longer hashes to this value (TOCTOU guard)."}},required:["path","content"]},outputSchema:{type:"object",properties:{path:{type:"string"},bytesWritten:{type:"number"},mode:{type:"string"},startLine:{type:"number"},endLine:{type:"number"},linesReplaced:{type:"number"},linesInserted:{type:"number"}},required:["path","bytesWritten","mode"]}},{name:"edit_file",description:'Edit a text file two ways (mutually exclusive): (1) "edits": [{ oldText, newText, startLine?, endLine? }] literal find/replace — each replaces the unique occurrence of oldText. startLine/endLine are an optional disambiguation HINT (if exactly one match starts in that range it wins); a wrong/missing range still works as long as oldText is unique in the file. Include enough surrounding context to make oldText unique. Or (2) "diff": a unified diff string ("@@ -a,b +c,d @@" hunks) applied atomically — hunks are relocated to where their context actually matches, so slightly-off @@ line numbers still apply, and CRLF files are handled. Fails with no partial write only when text is missing/ambiguous or a hunk context is not found. Optionally pass "expectedHash" (the contentHash from a prior read_file) to reject the edit if the file changed on disk since it was read (TOCTOU guard). Returns { path, editsApplied|applied, diff:{added,removed} }.',_meta:{ui:{resourceUri:"ui://devcanvas/diff"}},inputSchema:{type:"object",properties:{path:a,edits:{type:"array",description:"List of literal { oldText, newText } edits applied in order (optionally scoped with startLine/endLine).",items:{type:"object",properties:{oldText:{type:"string",description:"Exact text to find."},newText:{type:"string",description:"Replacement text."},startLine:{type:"number",description:"Optional 1-based first line to scope this edit to."},endLine:{type:"number",description:"Optional 1-based last line (inclusive) to scope this edit to."}},required:["oldText","newText"]}},diff:{type:"string",description:'A unified diff to apply atomically. Mutually exclusive with "edits".'},startLine:{type:"number",description:"Optional default 1-based first line to scope all literal edits to."},endLine:{type:"number",description:"Optional default 1-based last line (inclusive) to scope all literal edits to."},expectedHash:{type:"string",description:"Optional SHA-256 (contentHash from read_file). If provided and the freshly-read file no longer hashes to it, the edit is rejected with no changes written (TOCTOU guard)."}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},mode:{type:"string"},editsApplied:{type:"number"},applied:{type:"boolean"},diff:{type:"object",properties:{added:{type:"number"},removed:{type:"number"}},required:["added","removed"]}},required:["path","diff"]}},{name:"list_dir",description:'List the entries of a directory. Returns { path, entries: [{ name, type, size }] } where type is "file" | "directory" | "other".',inputSchema:{type:"object",properties:{path:a},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},entries:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"},size:{type:"number"}},required:["name","type","size"]}}},required:["path","entries"]}},{name:"file_browser_ui",description:'Open an interactive file browser in the chat so the USER can pick a file. This returns IMMEDIATELY without a selection — the browser is shown to the user and the file they choose arrives afterwards as a follow-up user message (e.g. "Selected file: <path>"). After calling this tool you MUST stop and wait for that message; do not guess a path or continue until the user has selected.',_meta:{ui:{resourceUri:"ui://filesystem/browser"}},inputSchema:{type:"object",properties:{path:{...a,description:"Optional starting directory for the browser (defaults to the FLUJO data directory)."}},required:[]}},{name:"dir_tree",description:"Return a recursive, depth-limited directory tree as nested JSON. Returns { path, depth, tree }.",inputSchema:{type:"object",properties:{path:a,depth:{type:"number",description:"Maximum recursion depth (default 3, max 10)."}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},depth:{type:"number"},truncated:{type:"boolean"},tree:{type:"array"}},required:["path","depth","tree"]}},{name:"search",description:'Search a directory tree. Match file/dir NAMES against "namePattern" (substring, case-insensitive) and/or file CONTENT against "content" (substring, case-insensitive). Content search DOES look inside every text file, returning each matching line with its 1-based line number; likely-binary and very large files are skipped for speed. Returns { matches: [{ path, line?, text? }], truncated }.',inputSchema:{type:"object",properties:{path:a,namePattern:{type:"string",description:"Optional case-insensitive substring to match against entry names."},content:{type:"string",description:"Optional case-insensitive substring to match inside text files."}},required:["path"]},outputSchema:{type:"object",properties:{matches:{type:"array",items:{type:"object",properties:{path:{type:"string"},line:{type:"number"},text:{type:"string"}},required:["path"]}},truncated:{type:"boolean"}},required:["matches","truncated"]}},{name:"get_file_info",description:"Stat a path. Returns { path, type, size, isFile, isDirectory, createdAt, modifiedAt }.",inputSchema:{type:"object",properties:{path:a},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},type:{type:"string"},size:{type:"number"},isFile:{type:"boolean"},isDirectory:{type:"boolean"},createdAt:{type:"string"},modifiedAt:{type:"string"}},required:["path","type","size","isFile","isDirectory","createdAt","modifiedAt"]}},{name:"create_directory",description:"Create a directory (recursively). Succeeds if it already exists. Returns { path, created }.",inputSchema:{type:"object",properties:{path:a},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},created:{type:"boolean"}},required:["path","created"]}},{name:"move",description:'Move or rename a file/directory from "source" to "destination". Returns { source, destination }.',inputSchema:{type:"object",properties:{source:{type:"string",description:"Existing path to move."},destination:{type:"string",description:"Target path."}},required:["source","destination"]},outputSchema:{type:"object",properties:{source:{type:"string"},destination:{type:"string"}},required:["source","destination"]}},{name:"delete",description:'Delete a file or directory. Pass "recursive": true to remove a non-empty directory. Returns { path, deleted }.',inputSchema:{type:"object",properties:{path:a,recursive:{type:"boolean",description:"Remove directories and their contents recursively."}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},deleted:{type:"boolean"}},required:["path","deleted"]}},{name:"get_allowed_directories",description:"Returns the list of directories that this filesystem MCP server is currently allowed to access. The list is the merged result of server-level roots (configured via FLUJO MCP settings), MCP-node-level roots (set in the FlowBuilder), and the FLUJO_FS_ROOTS environment variable ceiling. When no roots are configured at all, returns the FLUJO data directory as the default (so the file browser is usable out of the box).",inputSchema:{type:"object",properties:{},required:[]},outputSchema:{type:"object",properties:{directories:{type:"array",items:{type:"string"},description:"Absolute paths of all allowed directories."}},required:["directories"]}}]}function u(a){return a.replace(/\r\n?/g,"\n").split("\n")}function v(a){return a.includes("\r\n")?"\r\n":"\n"}function w(a){return(0,g.createHash)("sha256").update(a,"utf8").digest("hex")}function x(a){return a.startsWith("\uFEFF")?{bom:"\uFEFF",body:a.slice(1)}:{bom:"",body:a}}let y="File changed after permission approval. Read it again before editing. No changes written.";function z(a){let b=Math.min(a.length,8e3);for(let c=0;c<b;c++)if(0===a[c])return!0;return!1}async function A(a,b,c){let d=b.toLowerCase(),e=[],g=!1,h=(0,f.createReadStream)(a,{encoding:"utf8"}),j=i().createInterface({input:h,crlfDelay:1/0}),k=0;try{for await(let a of j)if(k++,a.toLowerCase().includes(d)&&(e.push({line:k,text:a.slice(0,400)}),e.length>=c)){g=!0;break}}finally{j.close(),h.destroy()}return{matches:e,truncated:g}}async function B(a,b){let c=s(a.path,b),d="number"==typeof a.from||"number"==typeof a.to,e="string"==typeof a.pattern?a.pattern.trim():"",g=0;try{g=(await f.promises.stat(c)).size}catch{}if(g>1e5&&!d&&!e)return r(`File is large (${g} bytes > 100000 threshold). Reading it whole would flood the context. Provide a "pattern" to grep for (matching lines + context are returned, then read targeted ranges with "from"/"to"), or pass pattern "*" to read the whole file anyway.`);if(e&&"*"!==e&&!d){let a=await f.promises.readFile(c);if(z(a))return r(`File appears to be binary; cannot grep for a pattern: ${c}`);let b=a.toString("utf8"),d=u(b),h=d.length,i=e.toLowerCase(),j=[];for(let a=0;a<d.length&&(!d[a].toLowerCase().includes(i)||(j.push({line:a+1,text:d[a].slice(0,400)}),!(j.length>=200)));a++);let k=j.length>=200,l=new Set;for(let a of j)for(let b=a.line-2;b<=a.line+2;b++)b>=1&&b<=h&&l.add(b);let m=[...l].sort((a,b)=>a-b),n=[],p=0;for(let a of m)p&&a>p+1&&n.push("…"),n.push(`${a}: ${d[a-1]}`),p=a;let s=n.join("\n");return s.length>2e5&&(s=s.slice(0,2e5)+"\n…[truncated]"),(0,o.Wk)(c,"read",g),q({path:c,from:1,to:h,totalLines:h,truncated:k,content:j.length?s:`(no lines matched pattern ${JSON.stringify(e)})`,matches:j,contentHash:w(b)})}let h=await f.promises.readFile(c,"utf8"),i=u(h),j=i.length,k="number"==typeof a.from?Math.max(1,Math.floor(a.from)):1,l="number"==typeof a.to?Math.floor(a.to):j;l<k&&([k,l]=[l,k]),l=Math.min(l,j);let m=d?i.slice(k-1,l).join("\n"):h,n=!1;return m.length>2e5&&(m=m.slice(0,2e5)+"\n…[truncated]",n=!0),(0,o.Wk)(c,"read",g),q({path:c,from:d?k:1,to:d?l:j,totalLines:j,truncated:n,content:m,contentHash:w(h)})}async function C(a,b){let c=s(a.path,b),d="string"==typeof a.content?a.content:"",g="append"===a.mode||"insert"===a.mode?a.mode:"overwrite",h="number"==typeof a.startLine||"number"==typeof a.endLine;if(await f.promises.mkdir(e().dirname(c),{recursive:!0}),(0,o.Wk)(c,"write"),"overwrite"===g&&!h)return await f.promises.writeFile(c,d,"utf8"),q({path:c,bytesWritten:Buffer.byteLength(d,"utf8"),mode:"overwrite"});let i="";try{i=await f.promises.readFile(c,"utf8")}catch{i=""}let j="string"==typeof a.expectedHash?a.expectedHash:void 0;if(j&&w(i)!==j)return r(y);let{bom:k,body:l}=x(i);if("append"===g){let a=!l.length||l.endsWith("\n")||l.endsWith("\r\n")?"":v(l),b=k+l+a+d;return await f.promises.writeFile(c,b,"utf8"),q({path:c,bytesWritten:Buffer.byteLength(b,"utf8"),mode:"append"})}let m=v(l),n=l.length?l.split(/\r?\n/):[],p=d.split(/\r?\n/),t=n.length;if("insert"===g){let b="number"==typeof a.startLine?Math.max(1,Math.floor(a.startLine)):t+1,d=Math.min(b-1,t);n.splice(d,0,...p);let e=k+n.join(m);return await f.promises.writeFile(c,e,"utf8"),q({path:c,bytesWritten:Buffer.byteLength(e,"utf8"),mode:"insert",startLine:b,linesInserted:p.length})}let u="number"==typeof a.startLine?Math.max(1,Math.floor(a.startLine)):1,z="number"==typeof a.endLine?Math.floor(a.endLine):u;z<u&&([u,z]=[z,u]);let A=Math.max(0,(z=Math.min(z,t))-u+1);n.splice(u-1,A,...p);let B=k+n.join(m);return await f.promises.writeFile(c,B,"utf8"),q({path:c,bytesWritten:Buffer.byteLength(B,"utf8"),mode:"overwrite",startLine:u,endLine:z,linesReplaced:A})}async function D(a,b){let c=s(a.path,b),d="string"==typeof a.diff&&a.diff.trim().length>0,e=Array.isArray(a.edits)&&a.edits.length>0;if(d&&e)return r('Provide either "diff" or "edits", not both.');let g=await f.promises.readFile(c,"utf8"),h="string"==typeof a.expectedHash?a.expectedHash:void 0;if(h&&w(g)!==h)return r(y);let{bom:i,body:j}=x(g);if(d){let b,d=v(j),e=j.replace(/\r\n?/g,"\n");try{b=function(a,b){let c=a.split("\n"),d=b.split(/\r?\n/),e=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,f=[],g=null;for(let a=0;a<d.length;a++){let b=d[a];if(void 0===b)break;let c=e.exec(b);if(c){g={oldStart:parseInt(c[1],10),ops:[]},f.push(g);continue}if(b.startsWith("--- ")||b.startsWith("+++ ")){g=null;continue}if(!g)continue;let h=b.length?b[0]:" ",i=b.length?b.slice(1):"";if(" "===h||"-"===h||"+"===h)g.ops.push({tag:h,body:i});else if("\\"===h);else throw Error(`unexpected diff line: ${JSON.stringify(b)}`)}if(0===f.length)throw Error("no unified-diff hunks (@@ ... @@) found");let h=[],i=0,j=0,k=0;for(let a of f){let b=function(a,b,c,d){if(0===b.length)return Math.min(Math.max(c,d),a.length);let e=a.length-b.length,f=c=>{if(c<d||c>e)return!1;for(let d=0;d<b.length;d++)if(a[c+d]!==b[d])return!1;return!0},g=Math.max(d,c);if(f(g))return g;let h=Math.max(g-d,e-g);for(let a=1;a<=h;a++){if(f(g-a))return g-a;if(f(g+a))return g+a}throw Error(`could not locate hunk near line ${c+1}; its context/removed lines do not match the file. First expected line: ${JSON.stringify(b[0])}`)}(c,a.ops.filter(a=>" "===a.tag||"-"===a.tag).map(a=>a.body),Math.max(0,a.oldStart-1),i);if(b<i)throw Error("overlapping or out-of-order hunks");for(;i<b;)h.push(c[i]),i++;for(let b of a.ops)" "===b.tag?(h.push(c[i]),i++):"-"===b.tag?(i++,k++):(h.push(b.body),j++)}for(;i<c.length;)h.push(c[i]),i++;return{result:h.join("\n"),added:j,removed:k}}(e,a.diff)}catch(a){return r(`Diff apply failed: ${a instanceof Error?a.message:String(a)}. No changes written.`)}let g=i+("\r\n"===d?b.result.replace(/\n/g,"\r\n"):b.result);return await f.promises.writeFile(c,g,"utf8"),(0,o.Wk)(c,"write"),q({path:c,applied:!0,mode:"diff",diff:{added:b.added,removed:b.removed}})}let k=Array.isArray(a.edits)?a.edits:[];if(0===k.length)return r('Provide a non-empty "edits" array of { oldText, newText } or a "diff" string.');let l="number"==typeof a.startLine?a.startLine:void 0,m="number"==typeof a.endLine?a.endLine:void 0,n=v(j),p=j.replace(/\r\n?/g,"\n"),t=0;for(let a of k){let b="string"==typeof a.oldText?a.oldText.replace(/\r\n?/g,"\n"):"",d="string"==typeof a.newText?a.newText.replace(/\r\n?/g,"\n"):"";if(!b)return r(`Edit #${t+1} has an empty "oldText".`);let e="number"==typeof a.startLine?a.startLine:l,f="number"==typeof a.endLine?a.endLine:m,g=void 0!==e||void 0!==f,h=[];for(let a=p.indexOf(b);-1!==a;a=p.indexOf(b,a+1))h.push(a);if(0===h.length)return r(`Edit #${t+1}: "oldText" not found in ${c}. No changes written.`);let i=-1;if(g){let{lo:a,hi:b}=function(a,b,c){if(void 0===b&&void 0===c)return{lo:0,hi:a.length};let d=a.split("\n"),e=Math.max(1,Math.floor(b??1)),f=Math.min(d.length,Math.floor(c??d.length)),g=0;for(let a=0;a<e-1&&a<d.length;a++)g+=d[a].length+1;let h=g;for(let a=e-1;a<f&&a<d.length;a++)h+=d[a].length+ +(a<d.length-1);return{lo:g,hi:Math.max(g,h)}}(p,e,f),c=h.filter(c=>c>=a&&c<b);1===c.length&&(i=c[0])}if(-1===i)if(1!==h.length)return r(`Edit #${t+1}: "oldText" is ambiguous (appears ${h.length} times); add more surrounding context or a tighter startLine/endLine so exactly one occurrence is in range. No changes written.`);else i=h[0];p=p.slice(0,i)+d+p.slice(i+b.length),t+=1}let z=function(a,b){let c=u(a),d=u(b),e=new Map;for(let a of d)e.set(a,(e.get(a)??0)+1);let f=new Map;for(let a of c)f.set(a,(f.get(a)??0)+1);let g=0;for(let[a,b]of f)g+=Math.max(0,b-(e.get(a)??0));let h=0;for(let[a,b]of e)h+=Math.max(0,b-(f.get(a)??0));return{added:h,removed:g}}(j,p),A=i+("\r\n"===n?p.replace(/\n/g,"\r\n"):p);return await f.promises.writeFile(c,A,"utf8"),(0,o.Wk)(c,"write"),q({path:c,mode:"edits",editsApplied:t,diff:z})}async function E(a){try{let b=await f.promises.lstat(a);if(b.isFile())return"file";if(b.isDirectory())return"directory";return"other"}catch{return"other"}}async function F(a,b){let c=s(a.path,b),d=await f.promises.readdir(c),g=await Promise.all(d.map(async a=>{let b=e().join(c,a),d=await E(b),g=0;try{g=(await f.promises.stat(b)).size}catch{}return{name:a,type:d,size:g}}));return g.sort((a,b)=>a.type===b.type?a.name.localeCompare(b.name):"directory"===a.type?-1:1),q({path:c,entries:g})}async function G(a,b){let c=s(a.path,b),d=Math.min("number"==typeof a.depth?Math.max(1,Math.floor(a.depth)):3,10),g=0,h=!1;async function i(a,b){let c;if(b>d||h)return[];try{c=await f.promises.readdir(a)}catch{return[]}c.sort((a,b)=>a.localeCompare(b));let j=[];for(let f of c){if(++g>5e3){h=!0;break}let c=e().join(a,f),k=await E(c),l={name:f,type:k};"directory"===k&&b<d&&(l.children=await i(c,b+1)),j.push(l)}return j}let j=await i(c,1);return q({path:c,depth:d,truncated:h,tree:j})}async function H(a,b,c){let d;try{d=await f.promises.stat(a)}catch{return[]}if(!d.isFile()||d.size>5e6)return[];try{let b=await f.promises.open(a,"r");try{let a=Buffer.alloc(Math.min(8e3,d.size));if(a.length&&await b.read(a,0,a.length,0),z(a))return[]}finally{await b.close()}}catch{return[]}let{matches:e}=await A(a,b,Math.max(1,c));return e.map(b=>({path:a,line:b.line,text:b.text}))}async function I(a,b){let c=s(a.path,b),d="string"==typeof a.namePattern?a.namePattern.toLowerCase():"",g="string"==typeof a.content?a.content:"";if(!d&&!g)return r('Provide "namePattern" and/or "content" to search for.');let h=[],i=!1,j=[];async function k(a){let b;if(!i){try{b=await f.promises.readdir(a)}catch{return}for(let c of b){if(i)return;let b=e().join(a,c),f=await E(b);if(d&&c.toLowerCase().includes(d)&&(h.push({path:b}),h.length>=1e3)){i=!0;return}"directory"===f?await k(b):"file"===f&&g&&j.push(b)}}}if(await k(c),g&&!i)for(let a=0;a<j.length&&!i;a+=16){let b=j.slice(a,a+16);for(let a of(await Promise.all(b.map(a=>H(a,g,1e3))))){for(let b of a)if(h.push(b),h.length>=1e3){i=!0;break}if(i)break}}return q({matches:h,truncated:i})}async function J(a,b){let c=s(a.path,b),d=await f.promises.stat(c);return q({path:c,type:d.isFile()?"file":d.isDirectory()?"directory":"other",size:d.size,isFile:d.isFile(),isDirectory:d.isDirectory(),createdAt:d.birthtime.toISOString(),modifiedAt:d.mtime.toISOString()})}async function K(a,b){let c=s(a.path,b);return await f.promises.mkdir(c,{recursive:!0}),q({path:c,created:!0})}async function L(a,b){let c=s(a.source,b),d=s(a.destination,b);return await f.promises.mkdir(e().dirname(d),{recursive:!0}),await f.promises.rename(c,d),q({source:c,destination:d})}async function M(a,b){let c=s(a.path,b),d=!0===a.recursive;return await f.promises.rm(c,{recursive:d,force:!1}),q({path:c,deleted:!0})}async function N(a){return q({directories:a})}async function O(a,b,c){try{if("file_browser_ui"===a)return function(a,b=!1){return{content:[{type:"text",text:a}],...b?{isError:!0}:{}}}("File browser shown to the user. Waiting for them to select a file — their choice will arrive as a follow-up message. Do not proceed until then.");let d=await (0,m.loadEffectiveRoots)(l.K3,"FLUJO_FS_ROOTS",c);switch(a){case"read_file":return await B(b,d);case"write_file":return await C(b,d);case"edit_file":return await D(b,d);case"list_dir":return await F(b,d);case"dir_tree":return await G(b,d);case"search":return await I(b,d);case"get_file_info":return await J(b,d);case"create_directory":return await K(b,d);case"move":return await L(b,d);case"delete":return await M(b,d);case"get_allowed_directories":return await N(d);default:return r(`Unknown tool on the built-in filesystem server: ${a}`)}}catch(c){let b=c instanceof Error?c.message:String(c);return p.warn("filesystemCallTool failed",{toolName:a,err:c}),{isError:!0,content:[{type:"text",text:JSON.stringify({error:b})}],structuredContent:{error:b}}}}}};
|
|
1
|
+
"use strict";exports.id=8387,exports.ids=[8387],exports.modules={5591:(a,b,c)=>{c.d(b,{bz:()=>q,cd:()=>n,wp:()=>m});var d=c(33873),e=c.n(d),f=c(21820),g=c.n(f),h=c(43326),i=c(92372),j=c(84653),k=c(7969);function l(a){return"string"==typeof a&&/^(1|true|yes|on)$/i.test(a.trim())}let m="FLUJO_ALLOW_PROTECTED_PATHS";async function n(){if(l(process.env[m]))return!1;try{let a=await (0,i.YM)(j.Z.SPEECH_SETTINGS,void 0);return a?.experimental?.protectedPathsEnabled===!0}catch{return!1}}let o=null;function p(a,...b){return e().resolve(a,...b)}function q(a){let b=e().resolve(a);if((function(){let a=[];try{a.push(e().resolve((0,h.getDataDir)()))}catch{}try{a.push(e().resolve(g().tmpdir()))}catch{}return a})().some(a=>(0,k.F)(a,b)))return{denied:!1};for(let a of function(){let a=l(process.env[m]),b=(0,h.getHomeDir)(),c=`${a?"off":"on"}::${b}`;if(o&&o.key===c)return o.paths;let d=a?[]:function(a){let b=[];if("win32"===process.platform)for(let c of["AppData","Downloads","Desktop","Documents","Pictures","Music","Videos","OneDrive"])b.push(p(a,c));else if("darwin"===process.platform){for(let c of["Downloads","Desktop","Documents","Pictures","Music","Movies"])b.push(p(a,c));for(let c of["Library/Mail","Library/Messages","Library/Safari","Library/Cookies","Library/Calendars","Library/Application Support/AddressBook","Library/Application Support/com.apple.TCC","Library/PersonalizationPortrait","Library/Metadata/CoreSpotlight","Library/Suggestions"])b.push(p(a,c));for(let a of["/.Spotlight-V100","/.fseventsd","/.DocumentRevisions-V100"])b.push(e().resolve(a))}else for(let c of["Documents","Downloads","Desktop",".ssh",".gnupg",".aws",".config"])b.push(p(a,c));return Array.from(new Set(b))}(b);return o={key:c,paths:d},d}())if((0,k.F)(a,b))return{denied:!0,matchedRoot:a};return{denied:!1}}},18387:(a,b,c)=>{c.d(b,{filesystemCallTool:()=>R,filesystemToolDefinitions:()=>w});var d=c(33873),e=c.n(d),f=c(29021),g=c(55511),h=c(4984),i=c.n(h),j=c(50846),k=c(43326),l=c(7658),m=c(7969),n=c(5591),o=c(10793);let p=(0,j.h)("backend/services/mcp/internal/filesystemTools"),q={readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},r={readOnlyHint:!1,destructiveHint:!1,openWorldHint:!1},s={readOnlyHint:!1,destructiveHint:!0,openWorldHint:!1};function t(a){return{content:[{type:"text",text:JSON.stringify(a,null,2)}],structuredContent:a}}function u(a){return{content:[{type:"text",text:JSON.stringify({error:a},null,2)}],isError:!0}}async function v(a,b){let c="string"==typeof a?a.trim():"";if(!c)throw Error('Provide "path".');let d=(0,k.getDataDir)(),f=e().isAbsolute(c)?e().resolve(c):e().resolve(d,c);if(await (0,n.cd)()){let a=(0,n.bz)(f);if(a.denied)throw Error(`Path "${f}" is within a protected location (${a.matchedRoot}) and is blocked by the FLUJO built-in server protected-path policy. Disable "Protect sensitive home-directory paths" in Experimental Features or set ${n.wp}=1 to override.`)}if(0===b.length||!b.some(a=>(0,m.F)(a,f)))throw Error(`Path "${f}" is outside the configured filesystem roots.`);return f}function w(){let a={type:"string",description:"File or directory path. Relative paths resolve against the FLUJO data directory; absolute paths are used as-is."};return[{name:"read_file",annotations:q,description:'Read a text file and return its content. Optionally read only a line range with "from"/"to" (1-based, inclusive). For large files (> 100 KB) read WHOLE (no "from"/"to"), a "pattern" is REQUIRED: the server greps the file and returns only matching lines (with a little surrounding context) so you can follow up with targeted "from"/"to" reads. Pass pattern "*" to force-read the entire large file anyway. Returns { path, from, to, totalLines, content, truncated, contentHash, matches? }. Pass the returned contentHash back as "expectedHash" on a follow-up edit_file/write_file to guard against the file changing in between (TOCTOU).',inputSchema:{type:"object",properties:{path:a,from:{type:"number",description:"Optional 1-based first line to return (inclusive)."},to:{type:"number",description:"Optional 1-based last line to return (inclusive)."},pattern:{type:"string",description:'Case-insensitive substring to grep for. Required to read a large file whole without a "from"/"to" range; matching lines (plus context) are returned instead of the full body. Use "*" to read the whole large file anyway.'}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},from:{type:"number"},to:{type:"number"},totalLines:{type:"number"},truncated:{type:"boolean"},content:{type:"string"},contentHash:{type:"string",description:'SHA-256 (hex) of the raw file content. Pass this back as "expectedHash" to edit_file/write_file to guard against the file changing between read and write (TOCTOU).'},matches:{type:"array",items:{type:"object",properties:{line:{type:"number"},text:{type:"string"}},required:["line","text"]}}},required:["path","from","to","totalLines","truncated","content"]}},{name:"write_file",annotations:s,description:'Create or write a text file (parent directories are created). "mode": "overwrite" (default) replaces the whole file, or a line range when "startLine"/"endLine" (1-based inclusive) are given; "append" adds content at the end; "insert" inserts content before "startLine". Optionally pass "expectedHash" (the contentHash from a prior read_file) to reject the write if the file changed on disk since it was read (TOCTOU guard); ignored for a whole-file overwrite. Returns { path, bytesWritten, mode, ... }.',_meta:{ui:{resourceUri:"ui://devcanvas/diff"}},inputSchema:{type:"object",properties:{path:a,content:{type:"string",description:"The content to write/insert/append."},mode:{type:"string",enum:["overwrite","append","insert"],description:'Write mode (default "overwrite").'},startLine:{type:"number",description:'For "insert": line to insert before. For "overwrite": first line of the range to replace (1-based).'},endLine:{type:"number",description:'For "overwrite": last line (inclusive, 1-based) of the range to replace.'},expectedHash:{type:"string",description:"Optional SHA-256 (contentHash from read_file). For append/insert/range-overwrite modes, the write is rejected if the file no longer hashes to this value (TOCTOU guard)."}},required:["path","content"]},outputSchema:{type:"object",properties:{path:{type:"string"},bytesWritten:{type:"number"},mode:{type:"string"},startLine:{type:"number"},endLine:{type:"number"},linesReplaced:{type:"number"},linesInserted:{type:"number"}},required:["path","bytesWritten","mode"]}},{name:"edit_file",annotations:s,description:'Edit a text file two ways (mutually exclusive): (1) "edits": [{ oldText, newText, startLine?, endLine? }] literal find/replace — each replaces the unique occurrence of oldText. startLine/endLine are an optional disambiguation HINT (if exactly one match starts in that range it wins); a wrong/missing range still works as long as oldText is unique in the file. Include enough surrounding context to make oldText unique. Or (2) "diff": a unified diff string ("@@ -a,b +c,d @@" hunks) applied atomically — hunks are relocated to where their context actually matches, so slightly-off @@ line numbers still apply, and CRLF files are handled. Fails with no partial write only when text is missing/ambiguous or a hunk context is not found. Optionally pass "expectedHash" (the contentHash from a prior read_file) to reject the edit if the file changed on disk since it was read (TOCTOU guard). Returns { path, editsApplied|applied, diff:{added,removed} }.',_meta:{ui:{resourceUri:"ui://devcanvas/diff"}},inputSchema:{type:"object",properties:{path:a,edits:{type:"array",description:"List of literal { oldText, newText } edits applied in order (optionally scoped with startLine/endLine).",items:{type:"object",properties:{oldText:{type:"string",description:"Exact text to find."},newText:{type:"string",description:"Replacement text."},startLine:{type:"number",description:"Optional 1-based first line to scope this edit to."},endLine:{type:"number",description:"Optional 1-based last line (inclusive) to scope this edit to."}},required:["oldText","newText"]}},diff:{type:"string",description:'A unified diff to apply atomically. Mutually exclusive with "edits".'},startLine:{type:"number",description:"Optional default 1-based first line to scope all literal edits to."},endLine:{type:"number",description:"Optional default 1-based last line (inclusive) to scope all literal edits to."},expectedHash:{type:"string",description:"Optional SHA-256 (contentHash from read_file). If provided and the freshly-read file no longer hashes to it, the edit is rejected with no changes written (TOCTOU guard)."}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},mode:{type:"string"},editsApplied:{type:"number"},applied:{type:"boolean"},diff:{type:"object",properties:{added:{type:"number"},removed:{type:"number"}},required:["added","removed"]}},required:["path","diff"]}},{name:"list_dir",annotations:q,description:'List the entries of a directory. Returns { path, entries: [{ name, type, size }] } where type is "file" | "directory" | "other".',inputSchema:{type:"object",properties:{path:a},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},entries:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"},size:{type:"number"}},required:["name","type","size"]}}},required:["path","entries"]}},{name:"file_browser_ui",annotations:q,description:'Open an interactive file browser in the chat so the USER can pick a file. This returns IMMEDIATELY without a selection — the browser is shown to the user and the file they choose arrives afterwards as a follow-up user message (e.g. "Selected file: <path>"). After calling this tool you MUST stop and wait for that message; do not guess a path or continue until the user has selected.',_meta:{ui:{resourceUri:"ui://filesystem/browser"}},inputSchema:{type:"object",properties:{path:{...a,description:"Optional starting directory for the browser (defaults to the FLUJO data directory)."}},required:[]}},{name:"dir_tree",annotations:q,description:"Return a recursive, depth-limited directory tree as nested JSON. Returns { path, depth, tree }.",inputSchema:{type:"object",properties:{path:a,depth:{type:"number",description:"Maximum recursion depth (default 3, max 10)."}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},depth:{type:"number"},truncated:{type:"boolean"},tree:{type:"array"}},required:["path","depth","tree"]}},{name:"search",annotations:q,description:'Search a directory tree. Match file/dir NAMES against "namePattern" (substring, case-insensitive) and/or file CONTENT against "content" (substring, case-insensitive). Content search DOES look inside every text file, returning each matching line with its 1-based line number; likely-binary and very large files are skipped for speed. Returns { matches: [{ path, line?, text? }], truncated }.',inputSchema:{type:"object",properties:{path:a,namePattern:{type:"string",description:"Optional case-insensitive substring to match against entry names."},content:{type:"string",description:"Optional case-insensitive substring to match inside text files."}},required:["path"]},outputSchema:{type:"object",properties:{matches:{type:"array",items:{type:"object",properties:{path:{type:"string"},line:{type:"number"},text:{type:"string"}},required:["path"]}},truncated:{type:"boolean"}},required:["matches","truncated"]}},{name:"get_file_info",annotations:q,description:"Stat a path. Returns { path, type, size, isFile, isDirectory, createdAt, modifiedAt }.",inputSchema:{type:"object",properties:{path:a},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},type:{type:"string"},size:{type:"number"},isFile:{type:"boolean"},isDirectory:{type:"boolean"},createdAt:{type:"string"},modifiedAt:{type:"string"}},required:["path","type","size","isFile","isDirectory","createdAt","modifiedAt"]}},{name:"create_directory",annotations:r,description:"Create a directory (recursively). Succeeds if it already exists. Returns { path, created }.",inputSchema:{type:"object",properties:{path:a},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},created:{type:"boolean"}},required:["path","created"]}},{name:"move",annotations:s,description:'Move or rename a file/directory from "source" to "destination". Returns { source, destination }.',inputSchema:{type:"object",properties:{source:{type:"string",description:"Existing path to move."},destination:{type:"string",description:"Target path."}},required:["source","destination"]},outputSchema:{type:"object",properties:{source:{type:"string"},destination:{type:"string"}},required:["source","destination"]}},{name:"delete",annotations:s,description:'Delete a file or directory. Pass "recursive": true to remove a non-empty directory. Returns { path, deleted }.',inputSchema:{type:"object",properties:{path:a,recursive:{type:"boolean",description:"Remove directories and their contents recursively."}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},deleted:{type:"boolean"}},required:["path","deleted"]}},{name:"get_allowed_directories",annotations:q,description:"Returns the list of directories that this filesystem MCP server is currently allowed to access. The list is the merged result of server-level roots (configured via FLUJO MCP settings), MCP-node-level roots (set in the FlowBuilder), and the FLUJO_FS_ROOTS environment variable ceiling. When no roots are configured at all, returns the FLUJO data directory as the default (so the file browser is usable out of the box).",inputSchema:{type:"object",properties:{},required:[]},outputSchema:{type:"object",properties:{directories:{type:"array",items:{type:"string"},description:"Absolute paths of all allowed directories."}},required:["directories"]}}]}function x(a){return a.replace(/\r\n?/g,"\n").split("\n")}function y(a){return a.includes("\r\n")?"\r\n":"\n"}function z(a){return(0,g.createHash)("sha256").update(a,"utf8").digest("hex")}function A(a){return a.startsWith("\uFEFF")?{bom:"\uFEFF",body:a.slice(1)}:{bom:"",body:a}}let B="File changed after permission approval. Read it again before editing. No changes written.";function C(a){let b=Math.min(a.length,8e3);for(let c=0;c<b;c++)if(0===a[c])return!0;return!1}async function D(a,b,c){let d=b.toLowerCase(),e=[],g=!1,h=(0,f.createReadStream)(a,{encoding:"utf8"}),j=i().createInterface({input:h,crlfDelay:1/0}),k=0;try{for await(let a of j)if(k++,a.toLowerCase().includes(d)&&(e.push({line:k,text:a.slice(0,400)}),e.length>=c)){g=!0;break}}finally{j.close(),h.destroy()}return{matches:e,truncated:g}}async function E(a,b){let c=await v(a.path,b),d="number"==typeof a.from||"number"==typeof a.to,e="string"==typeof a.pattern?a.pattern.trim():"",g=0;try{g=(await f.promises.stat(c)).size}catch{}if(g>1e5&&!d&&!e)return u(`File is large (${g} bytes > 100000 threshold). Reading it whole would flood the context. Provide a "pattern" to grep for (matching lines + context are returned, then read targeted ranges with "from"/"to"), or pass pattern "*" to read the whole file anyway.`);if(e&&"*"!==e&&!d){let a=await f.promises.readFile(c);if(C(a))return u(`File appears to be binary; cannot grep for a pattern: ${c}`);let b=a.toString("utf8"),d=x(b),h=d.length,i=e.toLowerCase(),j=[];for(let a=0;a<d.length&&(!d[a].toLowerCase().includes(i)||(j.push({line:a+1,text:d[a].slice(0,400)}),!(j.length>=200)));a++);let k=j.length>=200,l=new Set;for(let a of j)for(let b=a.line-2;b<=a.line+2;b++)b>=1&&b<=h&&l.add(b);let m=[...l].sort((a,b)=>a-b),n=[],p=0;for(let a of m)p&&a>p+1&&n.push("…"),n.push(`${a}: ${d[a-1]}`),p=a;let q=n.join("\n");return q.length>2e5&&(q=q.slice(0,2e5)+"\n…[truncated]"),(0,o.Wk)(c,"read",g),t({path:c,from:1,to:h,totalLines:h,truncated:k,content:j.length?q:`(no lines matched pattern ${JSON.stringify(e)})`,matches:j,contentHash:z(b)})}let h=await f.promises.readFile(c,"utf8"),i=x(h),j=i.length,k="number"==typeof a.from?Math.max(1,Math.floor(a.from)):1,l="number"==typeof a.to?Math.floor(a.to):j;l<k&&([k,l]=[l,k]),l=Math.min(l,j);let m=d?i.slice(k-1,l).join("\n"):h,n=!1;return m.length>2e5&&(m=m.slice(0,2e5)+"\n…[truncated]",n=!0),(0,o.Wk)(c,"read",g),t({path:c,from:d?k:1,to:d?l:j,totalLines:j,truncated:n,content:m,contentHash:z(h)})}async function F(a,b){let c=await v(a.path,b),d="string"==typeof a.content?a.content:"",g="append"===a.mode||"insert"===a.mode?a.mode:"overwrite",h="number"==typeof a.startLine||"number"==typeof a.endLine;if(await f.promises.mkdir(e().dirname(c),{recursive:!0}),(0,o.Wk)(c,"write"),"overwrite"===g&&!h)return await f.promises.writeFile(c,d,"utf8"),t({path:c,bytesWritten:Buffer.byteLength(d,"utf8"),mode:"overwrite"});let i="";try{i=await f.promises.readFile(c,"utf8")}catch{i=""}let j="string"==typeof a.expectedHash?a.expectedHash:void 0;if(j&&z(i)!==j)return u(B);let{bom:k,body:l}=A(i);if("append"===g){let a=!l.length||l.endsWith("\n")||l.endsWith("\r\n")?"":y(l),b=k+l+a+d;return await f.promises.writeFile(c,b,"utf8"),t({path:c,bytesWritten:Buffer.byteLength(b,"utf8"),mode:"append"})}let m=y(l),n=l.length?l.split(/\r?\n/):[],p=d.split(/\r?\n/),q=n.length;if("insert"===g){let b="number"==typeof a.startLine?Math.max(1,Math.floor(a.startLine)):q+1,d=Math.min(b-1,q);n.splice(d,0,...p);let e=k+n.join(m);return await f.promises.writeFile(c,e,"utf8"),t({path:c,bytesWritten:Buffer.byteLength(e,"utf8"),mode:"insert",startLine:b,linesInserted:p.length})}let r="number"==typeof a.startLine?Math.max(1,Math.floor(a.startLine)):1,s="number"==typeof a.endLine?Math.floor(a.endLine):r;s<r&&([r,s]=[s,r]);let w=Math.max(0,(s=Math.min(s,q))-r+1);n.splice(r-1,w,...p);let x=k+n.join(m);return await f.promises.writeFile(c,x,"utf8"),t({path:c,bytesWritten:Buffer.byteLength(x,"utf8"),mode:"overwrite",startLine:r,endLine:s,linesReplaced:w})}async function G(a,b){let c=await v(a.path,b),d="string"==typeof a.diff&&a.diff.trim().length>0,e=Array.isArray(a.edits)&&a.edits.length>0;if(d&&e)return u('Provide either "diff" or "edits", not both.');let g=await f.promises.readFile(c,"utf8"),h="string"==typeof a.expectedHash?a.expectedHash:void 0;if(h&&z(g)!==h)return u(B);let{bom:i,body:j}=A(g);if(d){let b,d=y(j),e=j.replace(/\r\n?/g,"\n");try{b=function(a,b){let c=a.split("\n"),d=b.split(/\r?\n/),e=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,f=[],g=null;for(let a=0;a<d.length;a++){let b=d[a];if(void 0===b)break;let c=e.exec(b);if(c){g={oldStart:parseInt(c[1],10),ops:[]},f.push(g);continue}if(b.startsWith("--- ")||b.startsWith("+++ ")){g=null;continue}if(!g)continue;let h=b.length?b[0]:" ",i=b.length?b.slice(1):"";if(" "===h||"-"===h||"+"===h)g.ops.push({tag:h,body:i});else if("\\"===h);else throw Error(`unexpected diff line: ${JSON.stringify(b)}`)}if(0===f.length)throw Error("no unified-diff hunks (@@ ... @@) found");let h=[],i=0,j=0,k=0;for(let a of f){let b=function(a,b,c,d){if(0===b.length)return Math.min(Math.max(c,d),a.length);let e=a.length-b.length,f=c=>{if(c<d||c>e)return!1;for(let d=0;d<b.length;d++)if(a[c+d]!==b[d])return!1;return!0},g=Math.max(d,c);if(f(g))return g;let h=Math.max(g-d,e-g);for(let a=1;a<=h;a++){if(f(g-a))return g-a;if(f(g+a))return g+a}throw Error(`could not locate hunk near line ${c+1}; its context/removed lines do not match the file. First expected line: ${JSON.stringify(b[0])}`)}(c,a.ops.filter(a=>" "===a.tag||"-"===a.tag).map(a=>a.body),Math.max(0,a.oldStart-1),i);if(b<i)throw Error("overlapping or out-of-order hunks");for(;i<b;)h.push(c[i]),i++;for(let b of a.ops)" "===b.tag?(h.push(c[i]),i++):"-"===b.tag?(i++,k++):(h.push(b.body),j++)}for(;i<c.length;)h.push(c[i]),i++;return{result:h.join("\n"),added:j,removed:k}}(e,a.diff)}catch(a){return u(`Diff apply failed: ${a instanceof Error?a.message:String(a)}. No changes written.`)}let g=i+("\r\n"===d?b.result.replace(/\n/g,"\r\n"):b.result);return await f.promises.writeFile(c,g,"utf8"),(0,o.Wk)(c,"write"),t({path:c,applied:!0,mode:"diff",diff:{added:b.added,removed:b.removed}})}let k=Array.isArray(a.edits)?a.edits:[];if(0===k.length)return u('Provide a non-empty "edits" array of { oldText, newText } or a "diff" string.');let l="number"==typeof a.startLine?a.startLine:void 0,m="number"==typeof a.endLine?a.endLine:void 0,n=y(j),p=j.replace(/\r\n?/g,"\n"),q=0;for(let a of k){let b="string"==typeof a.oldText?a.oldText.replace(/\r\n?/g,"\n"):"",d="string"==typeof a.newText?a.newText.replace(/\r\n?/g,"\n"):"";if(!b)return u(`Edit #${q+1} has an empty "oldText".`);let e="number"==typeof a.startLine?a.startLine:l,f="number"==typeof a.endLine?a.endLine:m,g=void 0!==e||void 0!==f,h=[];for(let a=p.indexOf(b);-1!==a;a=p.indexOf(b,a+1))h.push(a);if(0===h.length)return u(`Edit #${q+1}: "oldText" not found in ${c}. No changes written.`);let i=-1;if(g){let{lo:a,hi:b}=function(a,b,c){if(void 0===b&&void 0===c)return{lo:0,hi:a.length};let d=a.split("\n"),e=Math.max(1,Math.floor(b??1)),f=Math.min(d.length,Math.floor(c??d.length)),g=0;for(let a=0;a<e-1&&a<d.length;a++)g+=d[a].length+1;let h=g;for(let a=e-1;a<f&&a<d.length;a++)h+=d[a].length+ +(a<d.length-1);return{lo:g,hi:Math.max(g,h)}}(p,e,f),c=h.filter(c=>c>=a&&c<b);1===c.length&&(i=c[0])}if(-1===i)if(1!==h.length)return u(`Edit #${q+1}: "oldText" is ambiguous (appears ${h.length} times); add more surrounding context or a tighter startLine/endLine so exactly one occurrence is in range. No changes written.`);else i=h[0];p=p.slice(0,i)+d+p.slice(i+b.length),q+=1}let r=function(a,b){let c=x(a),d=x(b),e=new Map;for(let a of d)e.set(a,(e.get(a)??0)+1);let f=new Map;for(let a of c)f.set(a,(f.get(a)??0)+1);let g=0;for(let[a,b]of f)g+=Math.max(0,b-(e.get(a)??0));let h=0;for(let[a,b]of e)h+=Math.max(0,b-(f.get(a)??0));return{added:h,removed:g}}(j,p),s=i+("\r\n"===n?p.replace(/\n/g,"\r\n"):p);return await f.promises.writeFile(c,s,"utf8"),(0,o.Wk)(c,"write"),t({path:c,mode:"edits",editsApplied:q,diff:r})}async function H(a){try{let b=await f.promises.lstat(a);if(b.isFile())return"file";if(b.isDirectory())return"directory";return"other"}catch{return"other"}}async function I(a,b){let c=await v(a.path,b),d=await f.promises.readdir(c),g=await Promise.all(d.map(async a=>{let b=e().join(c,a),d=await H(b),g=0;try{g=(await f.promises.stat(b)).size}catch{}return{name:a,type:d,size:g}}));return g.sort((a,b)=>a.type===b.type?a.name.localeCompare(b.name):"directory"===a.type?-1:1),t({path:c,entries:g})}async function J(a,b){let c=await v(a.path,b),d=Math.min("number"==typeof a.depth?Math.max(1,Math.floor(a.depth)):3,10),g=0,h=!1;async function i(a,b){let c;if(b>d||h)return[];try{c=await f.promises.readdir(a)}catch{return[]}c.sort((a,b)=>a.localeCompare(b));let j=[];for(let f of c){if(++g>5e3){h=!0;break}let c=e().join(a,f),k=await H(c),l={name:f,type:k};"directory"===k&&b<d&&(l.children=await i(c,b+1)),j.push(l)}return j}let j=await i(c,1);return t({path:c,depth:d,truncated:h,tree:j})}async function K(a,b,c){let d;try{d=await f.promises.stat(a)}catch{return[]}if(!d.isFile()||d.size>5e6)return[];try{let b=await f.promises.open(a,"r");try{let a=Buffer.alloc(Math.min(8e3,d.size));if(a.length&&await b.read(a,0,a.length,0),C(a))return[]}finally{await b.close()}}catch{return[]}let{matches:e}=await D(a,b,Math.max(1,c));return e.map(b=>({path:a,line:b.line,text:b.text}))}async function L(a,b){let c=await v(a.path,b),d="string"==typeof a.namePattern?a.namePattern.toLowerCase():"",g="string"==typeof a.content?a.content:"";if(!d&&!g)return u('Provide "namePattern" and/or "content" to search for.');let h=[],i=!1,j=[];async function k(a){let b;if(!i){try{b=await f.promises.readdir(a)}catch{return}for(let c of b){if(i)return;let b=e().join(a,c),f=await H(b);if(d&&c.toLowerCase().includes(d)&&(h.push({path:b}),h.length>=1e3)){i=!0;return}"directory"===f?await k(b):"file"===f&&g&&j.push(b)}}}if(await k(c),g&&!i)for(let a=0;a<j.length&&!i;a+=16){let b=j.slice(a,a+16);for(let a of(await Promise.all(b.map(a=>K(a,g,1e3))))){for(let b of a)if(h.push(b),h.length>=1e3){i=!0;break}if(i)break}}return t({matches:h,truncated:i})}async function M(a,b){let c=await v(a.path,b),d=await f.promises.stat(c);return t({path:c,type:d.isFile()?"file":d.isDirectory()?"directory":"other",size:d.size,isFile:d.isFile(),isDirectory:d.isDirectory(),createdAt:d.birthtime.toISOString(),modifiedAt:d.mtime.toISOString()})}async function N(a,b){let c=await v(a.path,b);return await f.promises.mkdir(c,{recursive:!0}),t({path:c,created:!0})}async function O(a,b){let c=await v(a.source,b),d=await v(a.destination,b);return await f.promises.mkdir(e().dirname(d),{recursive:!0}),await f.promises.rename(c,d),t({source:c,destination:d})}async function P(a,b){let c=await v(a.path,b),d=!0===a.recursive;return await f.promises.rm(c,{recursive:d,force:!1}),t({path:c,deleted:!0})}async function Q(a){return t({directories:a})}async function R(a,b,c){try{if("file_browser_ui"===a)return function(a,b=!1){return{content:[{type:"text",text:a}],...b?{isError:!0}:{}}}("File browser shown to the user. Waiting for them to select a file — their choice will arrive as a follow-up message. Do not proceed until then.");let d=await (0,m.loadEffectiveRoots)(l.K3,"FLUJO_FS_ROOTS",c);switch(a){case"read_file":return await E(b,d);case"write_file":return await F(b,d);case"edit_file":return await G(b,d);case"list_dir":return await I(b,d);case"dir_tree":return await J(b,d);case"search":return await L(b,d);case"get_file_info":return await M(b,d);case"create_directory":return await N(b,d);case"move":return await O(b,d);case"delete":return await P(b,d);case"get_allowed_directories":return await Q(d);default:return u(`Unknown tool on the built-in filesystem server: ${a}`)}}catch(c){let b=c instanceof Error?c.message:String(c);return p.warn("filesystemCallTool failed",{toolName:a,err:c}),{isError:!0,content:[{type:"text",text:JSON.stringify({error:b})}],structuredContent:{error:b}}}}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.id=94,exports.ids=[94],exports.modules={50094:(a,b,c)=>{c.d(b,{filesystemCallTool:()=>O,filesystemToolDefinitions:()=>t});var d=c(33873),e=c.n(d),f=c(29021),g=c(55511),h=c(4984),i=c.n(h),j=c(18230),k=c(85510),l=c(94749),m=c(48092),n=c(65858),o=c(19724);let p=(0,j.h)("backend/services/mcp/internal/filesystemTools");function q(a){return{content:[{type:"text",text:JSON.stringify(a,null,2)}],structuredContent:a}}function r(a){return{content:[{type:"text",text:JSON.stringify({error:a},null,2)}],isError:!0}}function s(a,b){let c="string"==typeof a?a.trim():"";if(!c)throw Error('Provide "path".');let d=(0,k.getDataDir)(),f=e().isAbsolute(c)?e().resolve(c):e().resolve(d,c),g=(0,n.bz)(f);if(g.denied)throw Error(`Path "${f}" is within a protected location (${g.matchedRoot}) and is blocked by the FLUJO built-in server protected-path policy. Set ${n.wp}=1 to override (operator only).`);if(0===b.length||!b.some(a=>(0,m.F)(a,f)))throw Error(`Path "${f}" is outside the configured filesystem roots.`);return f}function t(){let a={type:"string",description:"File or directory path. Relative paths resolve against the FLUJO data directory; absolute paths are used as-is."};return[{name:"read_file",description:'Read a text file and return its content. Optionally read only a line range with "from"/"to" (1-based, inclusive). For large files (> 100 KB) read WHOLE (no "from"/"to"), a "pattern" is REQUIRED: the server greps the file and returns only matching lines (with a little surrounding context) so you can follow up with targeted "from"/"to" reads. Pass pattern "*" to force-read the entire large file anyway. Returns { path, from, to, totalLines, content, truncated, contentHash, matches? }. Pass the returned contentHash back as "expectedHash" on a follow-up edit_file/write_file to guard against the file changing in between (TOCTOU).',inputSchema:{type:"object",properties:{path:a,from:{type:"number",description:"Optional 1-based first line to return (inclusive)."},to:{type:"number",description:"Optional 1-based last line to return (inclusive)."},pattern:{type:"string",description:'Case-insensitive substring to grep for. Required to read a large file whole without a "from"/"to" range; matching lines (plus context) are returned instead of the full body. Use "*" to read the whole large file anyway.'}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},from:{type:"number"},to:{type:"number"},totalLines:{type:"number"},truncated:{type:"boolean"},content:{type:"string"},contentHash:{type:"string",description:'SHA-256 (hex) of the raw file content. Pass this back as "expectedHash" to edit_file/write_file to guard against the file changing between read and write (TOCTOU).'},matches:{type:"array",items:{type:"object",properties:{line:{type:"number"},text:{type:"string"}},required:["line","text"]}}},required:["path","from","to","totalLines","truncated","content"]}},{name:"write_file",description:'Create or write a text file (parent directories are created). "mode": "overwrite" (default) replaces the whole file, or a line range when "startLine"/"endLine" (1-based inclusive) are given; "append" adds content at the end; "insert" inserts content before "startLine". Optionally pass "expectedHash" (the contentHash from a prior read_file) to reject the write if the file changed on disk since it was read (TOCTOU guard); ignored for a whole-file overwrite. Returns { path, bytesWritten, mode, ... }.',_meta:{ui:{resourceUri:"ui://devcanvas/diff"}},inputSchema:{type:"object",properties:{path:a,content:{type:"string",description:"The content to write/insert/append."},mode:{type:"string",enum:["overwrite","append","insert"],description:'Write mode (default "overwrite").'},startLine:{type:"number",description:'For "insert": line to insert before. For "overwrite": first line of the range to replace (1-based).'},endLine:{type:"number",description:'For "overwrite": last line (inclusive, 1-based) of the range to replace.'},expectedHash:{type:"string",description:"Optional SHA-256 (contentHash from read_file). For append/insert/range-overwrite modes, the write is rejected if the file no longer hashes to this value (TOCTOU guard)."}},required:["path","content"]},outputSchema:{type:"object",properties:{path:{type:"string"},bytesWritten:{type:"number"},mode:{type:"string"},startLine:{type:"number"},endLine:{type:"number"},linesReplaced:{type:"number"},linesInserted:{type:"number"}},required:["path","bytesWritten","mode"]}},{name:"edit_file",description:'Edit a text file two ways (mutually exclusive): (1) "edits": [{ oldText, newText, startLine?, endLine? }] literal find/replace — each replaces the unique occurrence of oldText. startLine/endLine are an optional disambiguation HINT (if exactly one match starts in that range it wins); a wrong/missing range still works as long as oldText is unique in the file. Include enough surrounding context to make oldText unique. Or (2) "diff": a unified diff string ("@@ -a,b +c,d @@" hunks) applied atomically — hunks are relocated to where their context actually matches, so slightly-off @@ line numbers still apply, and CRLF files are handled. Fails with no partial write only when text is missing/ambiguous or a hunk context is not found. Optionally pass "expectedHash" (the contentHash from a prior read_file) to reject the edit if the file changed on disk since it was read (TOCTOU guard). Returns { path, editsApplied|applied, diff:{added,removed} }.',_meta:{ui:{resourceUri:"ui://devcanvas/diff"}},inputSchema:{type:"object",properties:{path:a,edits:{type:"array",description:"List of literal { oldText, newText } edits applied in order (optionally scoped with startLine/endLine).",items:{type:"object",properties:{oldText:{type:"string",description:"Exact text to find."},newText:{type:"string",description:"Replacement text."},startLine:{type:"number",description:"Optional 1-based first line to scope this edit to."},endLine:{type:"number",description:"Optional 1-based last line (inclusive) to scope this edit to."}},required:["oldText","newText"]}},diff:{type:"string",description:'A unified diff to apply atomically. Mutually exclusive with "edits".'},startLine:{type:"number",description:"Optional default 1-based first line to scope all literal edits to."},endLine:{type:"number",description:"Optional default 1-based last line (inclusive) to scope all literal edits to."},expectedHash:{type:"string",description:"Optional SHA-256 (contentHash from read_file). If provided and the freshly-read file no longer hashes to it, the edit is rejected with no changes written (TOCTOU guard)."}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},mode:{type:"string"},editsApplied:{type:"number"},applied:{type:"boolean"},diff:{type:"object",properties:{added:{type:"number"},removed:{type:"number"}},required:["added","removed"]}},required:["path","diff"]}},{name:"list_dir",description:'List the entries of a directory. Returns { path, entries: [{ name, type, size }] } where type is "file" | "directory" | "other".',inputSchema:{type:"object",properties:{path:a},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},entries:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"},size:{type:"number"}},required:["name","type","size"]}}},required:["path","entries"]}},{name:"file_browser_ui",description:'Open an interactive file browser in the chat so the USER can pick a file. This returns IMMEDIATELY without a selection — the browser is shown to the user and the file they choose arrives afterwards as a follow-up user message (e.g. "Selected file: <path>"). After calling this tool you MUST stop and wait for that message; do not guess a path or continue until the user has selected.',_meta:{ui:{resourceUri:"ui://filesystem/browser"}},inputSchema:{type:"object",properties:{path:{...a,description:"Optional starting directory for the browser (defaults to the FLUJO data directory)."}},required:[]}},{name:"dir_tree",description:"Return a recursive, depth-limited directory tree as nested JSON. Returns { path, depth, tree }.",inputSchema:{type:"object",properties:{path:a,depth:{type:"number",description:"Maximum recursion depth (default 3, max 10)."}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},depth:{type:"number"},truncated:{type:"boolean"},tree:{type:"array"}},required:["path","depth","tree"]}},{name:"search",description:'Search a directory tree. Match file/dir NAMES against "namePattern" (substring, case-insensitive) and/or file CONTENT against "content" (substring, case-insensitive). Content search DOES look inside every text file, returning each matching line with its 1-based line number; likely-binary and very large files are skipped for speed. Returns { matches: [{ path, line?, text? }], truncated }.',inputSchema:{type:"object",properties:{path:a,namePattern:{type:"string",description:"Optional case-insensitive substring to match against entry names."},content:{type:"string",description:"Optional case-insensitive substring to match inside text files."}},required:["path"]},outputSchema:{type:"object",properties:{matches:{type:"array",items:{type:"object",properties:{path:{type:"string"},line:{type:"number"},text:{type:"string"}},required:["path"]}},truncated:{type:"boolean"}},required:["matches","truncated"]}},{name:"get_file_info",description:"Stat a path. Returns { path, type, size, isFile, isDirectory, createdAt, modifiedAt }.",inputSchema:{type:"object",properties:{path:a},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},type:{type:"string"},size:{type:"number"},isFile:{type:"boolean"},isDirectory:{type:"boolean"},createdAt:{type:"string"},modifiedAt:{type:"string"}},required:["path","type","size","isFile","isDirectory","createdAt","modifiedAt"]}},{name:"create_directory",description:"Create a directory (recursively). Succeeds if it already exists. Returns { path, created }.",inputSchema:{type:"object",properties:{path:a},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},created:{type:"boolean"}},required:["path","created"]}},{name:"move",description:'Move or rename a file/directory from "source" to "destination". Returns { source, destination }.',inputSchema:{type:"object",properties:{source:{type:"string",description:"Existing path to move."},destination:{type:"string",description:"Target path."}},required:["source","destination"]},outputSchema:{type:"object",properties:{source:{type:"string"},destination:{type:"string"}},required:["source","destination"]}},{name:"delete",description:'Delete a file or directory. Pass "recursive": true to remove a non-empty directory. Returns { path, deleted }.',inputSchema:{type:"object",properties:{path:a,recursive:{type:"boolean",description:"Remove directories and their contents recursively."}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},deleted:{type:"boolean"}},required:["path","deleted"]}},{name:"get_allowed_directories",description:"Returns the list of directories that this filesystem MCP server is currently allowed to access. The list is the merged result of server-level roots (configured via FLUJO MCP settings), MCP-node-level roots (set in the FlowBuilder), and the FLUJO_FS_ROOTS environment variable ceiling. When no roots are configured at all, returns the FLUJO data directory as the default (so the file browser is usable out of the box).",inputSchema:{type:"object",properties:{},required:[]},outputSchema:{type:"object",properties:{directories:{type:"array",items:{type:"string"},description:"Absolute paths of all allowed directories."}},required:["directories"]}}]}function u(a){return a.replace(/\r\n?/g,"\n").split("\n")}function v(a){return a.includes("\r\n")?"\r\n":"\n"}function w(a){return(0,g.createHash)("sha256").update(a,"utf8").digest("hex")}function x(a){return a.startsWith("\uFEFF")?{bom:"\uFEFF",body:a.slice(1)}:{bom:"",body:a}}let y="File changed after permission approval. Read it again before editing. No changes written.";function z(a){let b=Math.min(a.length,8e3);for(let c=0;c<b;c++)if(0===a[c])return!0;return!1}async function A(a,b,c){let d=b.toLowerCase(),e=[],g=!1,h=(0,f.createReadStream)(a,{encoding:"utf8"}),j=i().createInterface({input:h,crlfDelay:1/0}),k=0;try{for await(let a of j)if(k++,a.toLowerCase().includes(d)&&(e.push({line:k,text:a.slice(0,400)}),e.length>=c)){g=!0;break}}finally{j.close(),h.destroy()}return{matches:e,truncated:g}}async function B(a,b){let c=s(a.path,b),d="number"==typeof a.from||"number"==typeof a.to,e="string"==typeof a.pattern?a.pattern.trim():"",g=0;try{g=(await f.promises.stat(c)).size}catch{}if(g>1e5&&!d&&!e)return r(`File is large (${g} bytes > 100000 threshold). Reading it whole would flood the context. Provide a "pattern" to grep for (matching lines + context are returned, then read targeted ranges with "from"/"to"), or pass pattern "*" to read the whole file anyway.`);if(e&&"*"!==e&&!d){let a=await f.promises.readFile(c);if(z(a))return r(`File appears to be binary; cannot grep for a pattern: ${c}`);let b=a.toString("utf8"),d=u(b),h=d.length,i=e.toLowerCase(),j=[];for(let a=0;a<d.length&&(!d[a].toLowerCase().includes(i)||(j.push({line:a+1,text:d[a].slice(0,400)}),!(j.length>=200)));a++);let k=j.length>=200,l=new Set;for(let a of j)for(let b=a.line-2;b<=a.line+2;b++)b>=1&&b<=h&&l.add(b);let m=[...l].sort((a,b)=>a-b),n=[],p=0;for(let a of m)p&&a>p+1&&n.push("…"),n.push(`${a}: ${d[a-1]}`),p=a;let s=n.join("\n");return s.length>2e5&&(s=s.slice(0,2e5)+"\n…[truncated]"),(0,o.Wk)(c,"read",g),q({path:c,from:1,to:h,totalLines:h,truncated:k,content:j.length?s:`(no lines matched pattern ${JSON.stringify(e)})`,matches:j,contentHash:w(b)})}let h=await f.promises.readFile(c,"utf8"),i=u(h),j=i.length,k="number"==typeof a.from?Math.max(1,Math.floor(a.from)):1,l="number"==typeof a.to?Math.floor(a.to):j;l<k&&([k,l]=[l,k]),l=Math.min(l,j);let m=d?i.slice(k-1,l).join("\n"):h,n=!1;return m.length>2e5&&(m=m.slice(0,2e5)+"\n…[truncated]",n=!0),(0,o.Wk)(c,"read",g),q({path:c,from:d?k:1,to:d?l:j,totalLines:j,truncated:n,content:m,contentHash:w(h)})}async function C(a,b){let c=s(a.path,b),d="string"==typeof a.content?a.content:"",g="append"===a.mode||"insert"===a.mode?a.mode:"overwrite",h="number"==typeof a.startLine||"number"==typeof a.endLine;if(await f.promises.mkdir(e().dirname(c),{recursive:!0}),(0,o.Wk)(c,"write"),"overwrite"===g&&!h)return await f.promises.writeFile(c,d,"utf8"),q({path:c,bytesWritten:Buffer.byteLength(d,"utf8"),mode:"overwrite"});let i="";try{i=await f.promises.readFile(c,"utf8")}catch{i=""}let j="string"==typeof a.expectedHash?a.expectedHash:void 0;if(j&&w(i)!==j)return r(y);let{bom:k,body:l}=x(i);if("append"===g){let a=!l.length||l.endsWith("\n")||l.endsWith("\r\n")?"":v(l),b=k+l+a+d;return await f.promises.writeFile(c,b,"utf8"),q({path:c,bytesWritten:Buffer.byteLength(b,"utf8"),mode:"append"})}let m=v(l),n=l.length?l.split(/\r?\n/):[],p=d.split(/\r?\n/),t=n.length;if("insert"===g){let b="number"==typeof a.startLine?Math.max(1,Math.floor(a.startLine)):t+1,d=Math.min(b-1,t);n.splice(d,0,...p);let e=k+n.join(m);return await f.promises.writeFile(c,e,"utf8"),q({path:c,bytesWritten:Buffer.byteLength(e,"utf8"),mode:"insert",startLine:b,linesInserted:p.length})}let u="number"==typeof a.startLine?Math.max(1,Math.floor(a.startLine)):1,z="number"==typeof a.endLine?Math.floor(a.endLine):u;z<u&&([u,z]=[z,u]);let A=Math.max(0,(z=Math.min(z,t))-u+1);n.splice(u-1,A,...p);let B=k+n.join(m);return await f.promises.writeFile(c,B,"utf8"),q({path:c,bytesWritten:Buffer.byteLength(B,"utf8"),mode:"overwrite",startLine:u,endLine:z,linesReplaced:A})}async function D(a,b){let c=s(a.path,b),d="string"==typeof a.diff&&a.diff.trim().length>0,e=Array.isArray(a.edits)&&a.edits.length>0;if(d&&e)return r('Provide either "diff" or "edits", not both.');let g=await f.promises.readFile(c,"utf8"),h="string"==typeof a.expectedHash?a.expectedHash:void 0;if(h&&w(g)!==h)return r(y);let{bom:i,body:j}=x(g);if(d){let b,d=v(j),e=j.replace(/\r\n?/g,"\n");try{b=function(a,b){let c=a.split("\n"),d=b.split(/\r?\n/),e=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,f=[],g=null;for(let a=0;a<d.length;a++){let b=d[a];if(void 0===b)break;let c=e.exec(b);if(c){g={oldStart:parseInt(c[1],10),ops:[]},f.push(g);continue}if(b.startsWith("--- ")||b.startsWith("+++ ")){g=null;continue}if(!g)continue;let h=b.length?b[0]:" ",i=b.length?b.slice(1):"";if(" "===h||"-"===h||"+"===h)g.ops.push({tag:h,body:i});else if("\\"===h);else throw Error(`unexpected diff line: ${JSON.stringify(b)}`)}if(0===f.length)throw Error("no unified-diff hunks (@@ ... @@) found");let h=[],i=0,j=0,k=0;for(let a of f){let b=function(a,b,c,d){if(0===b.length)return Math.min(Math.max(c,d),a.length);let e=a.length-b.length,f=c=>{if(c<d||c>e)return!1;for(let d=0;d<b.length;d++)if(a[c+d]!==b[d])return!1;return!0},g=Math.max(d,c);if(f(g))return g;let h=Math.max(g-d,e-g);for(let a=1;a<=h;a++){if(f(g-a))return g-a;if(f(g+a))return g+a}throw Error(`could not locate hunk near line ${c+1}; its context/removed lines do not match the file. First expected line: ${JSON.stringify(b[0])}`)}(c,a.ops.filter(a=>" "===a.tag||"-"===a.tag).map(a=>a.body),Math.max(0,a.oldStart-1),i);if(b<i)throw Error("overlapping or out-of-order hunks");for(;i<b;)h.push(c[i]),i++;for(let b of a.ops)" "===b.tag?(h.push(c[i]),i++):"-"===b.tag?(i++,k++):(h.push(b.body),j++)}for(;i<c.length;)h.push(c[i]),i++;return{result:h.join("\n"),added:j,removed:k}}(e,a.diff)}catch(a){return r(`Diff apply failed: ${a instanceof Error?a.message:String(a)}. No changes written.`)}let g=i+("\r\n"===d?b.result.replace(/\n/g,"\r\n"):b.result);return await f.promises.writeFile(c,g,"utf8"),(0,o.Wk)(c,"write"),q({path:c,applied:!0,mode:"diff",diff:{added:b.added,removed:b.removed}})}let k=Array.isArray(a.edits)?a.edits:[];if(0===k.length)return r('Provide a non-empty "edits" array of { oldText, newText } or a "diff" string.');let l="number"==typeof a.startLine?a.startLine:void 0,m="number"==typeof a.endLine?a.endLine:void 0,n=v(j),p=j.replace(/\r\n?/g,"\n"),t=0;for(let a of k){let b="string"==typeof a.oldText?a.oldText.replace(/\r\n?/g,"\n"):"",d="string"==typeof a.newText?a.newText.replace(/\r\n?/g,"\n"):"";if(!b)return r(`Edit #${t+1} has an empty "oldText".`);let e="number"==typeof a.startLine?a.startLine:l,f="number"==typeof a.endLine?a.endLine:m,g=void 0!==e||void 0!==f,h=[];for(let a=p.indexOf(b);-1!==a;a=p.indexOf(b,a+1))h.push(a);if(0===h.length)return r(`Edit #${t+1}: "oldText" not found in ${c}. No changes written.`);let i=-1;if(g){let{lo:a,hi:b}=function(a,b,c){if(void 0===b&&void 0===c)return{lo:0,hi:a.length};let d=a.split("\n"),e=Math.max(1,Math.floor(b??1)),f=Math.min(d.length,Math.floor(c??d.length)),g=0;for(let a=0;a<e-1&&a<d.length;a++)g+=d[a].length+1;let h=g;for(let a=e-1;a<f&&a<d.length;a++)h+=d[a].length+ +(a<d.length-1);return{lo:g,hi:Math.max(g,h)}}(p,e,f),c=h.filter(c=>c>=a&&c<b);1===c.length&&(i=c[0])}if(-1===i)if(1!==h.length)return r(`Edit #${t+1}: "oldText" is ambiguous (appears ${h.length} times); add more surrounding context or a tighter startLine/endLine so exactly one occurrence is in range. No changes written.`);else i=h[0];p=p.slice(0,i)+d+p.slice(i+b.length),t+=1}let z=function(a,b){let c=u(a),d=u(b),e=new Map;for(let a of d)e.set(a,(e.get(a)??0)+1);let f=new Map;for(let a of c)f.set(a,(f.get(a)??0)+1);let g=0;for(let[a,b]of f)g+=Math.max(0,b-(e.get(a)??0));let h=0;for(let[a,b]of e)h+=Math.max(0,b-(f.get(a)??0));return{added:h,removed:g}}(j,p),A=i+("\r\n"===n?p.replace(/\n/g,"\r\n"):p);return await f.promises.writeFile(c,A,"utf8"),(0,o.Wk)(c,"write"),q({path:c,mode:"edits",editsApplied:t,diff:z})}async function E(a){try{let b=await f.promises.lstat(a);if(b.isFile())return"file";if(b.isDirectory())return"directory";return"other"}catch{return"other"}}async function F(a,b){let c=s(a.path,b),d=await f.promises.readdir(c),g=await Promise.all(d.map(async a=>{let b=e().join(c,a),d=await E(b),g=0;try{g=(await f.promises.stat(b)).size}catch{}return{name:a,type:d,size:g}}));return g.sort((a,b)=>a.type===b.type?a.name.localeCompare(b.name):"directory"===a.type?-1:1),q({path:c,entries:g})}async function G(a,b){let c=s(a.path,b),d=Math.min("number"==typeof a.depth?Math.max(1,Math.floor(a.depth)):3,10),g=0,h=!1;async function i(a,b){let c;if(b>d||h)return[];try{c=await f.promises.readdir(a)}catch{return[]}c.sort((a,b)=>a.localeCompare(b));let j=[];for(let f of c){if(++g>5e3){h=!0;break}let c=e().join(a,f),k=await E(c),l={name:f,type:k};"directory"===k&&b<d&&(l.children=await i(c,b+1)),j.push(l)}return j}let j=await i(c,1);return q({path:c,depth:d,truncated:h,tree:j})}async function H(a,b,c){let d;try{d=await f.promises.stat(a)}catch{return[]}if(!d.isFile()||d.size>5e6)return[];try{let b=await f.promises.open(a,"r");try{let a=Buffer.alloc(Math.min(8e3,d.size));if(a.length&&await b.read(a,0,a.length,0),z(a))return[]}finally{await b.close()}}catch{return[]}let{matches:e}=await A(a,b,Math.max(1,c));return e.map(b=>({path:a,line:b.line,text:b.text}))}async function I(a,b){let c=s(a.path,b),d="string"==typeof a.namePattern?a.namePattern.toLowerCase():"",g="string"==typeof a.content?a.content:"";if(!d&&!g)return r('Provide "namePattern" and/or "content" to search for.');let h=[],i=!1,j=[];async function k(a){let b;if(!i){try{b=await f.promises.readdir(a)}catch{return}for(let c of b){if(i)return;let b=e().join(a,c),f=await E(b);if(d&&c.toLowerCase().includes(d)&&(h.push({path:b}),h.length>=1e3)){i=!0;return}"directory"===f?await k(b):"file"===f&&g&&j.push(b)}}}if(await k(c),g&&!i)for(let a=0;a<j.length&&!i;a+=16){let b=j.slice(a,a+16);for(let a of(await Promise.all(b.map(a=>H(a,g,1e3))))){for(let b of a)if(h.push(b),h.length>=1e3){i=!0;break}if(i)break}}return q({matches:h,truncated:i})}async function J(a,b){let c=s(a.path,b),d=await f.promises.stat(c);return q({path:c,type:d.isFile()?"file":d.isDirectory()?"directory":"other",size:d.size,isFile:d.isFile(),isDirectory:d.isDirectory(),createdAt:d.birthtime.toISOString(),modifiedAt:d.mtime.toISOString()})}async function K(a,b){let c=s(a.path,b);return await f.promises.mkdir(c,{recursive:!0}),q({path:c,created:!0})}async function L(a,b){let c=s(a.source,b),d=s(a.destination,b);return await f.promises.mkdir(e().dirname(d),{recursive:!0}),await f.promises.rename(c,d),q({source:c,destination:d})}async function M(a,b){let c=s(a.path,b),d=!0===a.recursive;return await f.promises.rm(c,{recursive:d,force:!1}),q({path:c,deleted:!0})}async function N(a){return q({directories:a})}async function O(a,b,c){try{if("file_browser_ui"===a)return function(a,b=!1){return{content:[{type:"text",text:a}],...b?{isError:!0}:{}}}("File browser shown to the user. Waiting for them to select a file — their choice will arrive as a follow-up message. Do not proceed until then.");let d=await (0,m.loadEffectiveRoots)(l.K3,"FLUJO_FS_ROOTS",c);switch(a){case"read_file":return await B(b,d);case"write_file":return await C(b,d);case"edit_file":return await D(b,d);case"list_dir":return await F(b,d);case"dir_tree":return await G(b,d);case"search":return await I(b,d);case"get_file_info":return await J(b,d);case"create_directory":return await K(b,d);case"move":return await L(b,d);case"delete":return await M(b,d);case"get_allowed_directories":return await N(d);default:return r(`Unknown tool on the built-in filesystem server: ${a}`)}}catch(c){let b=c instanceof Error?c.message:String(c);return p.warn("filesystemCallTool failed",{toolName:a,err:c}),{isError:!0,content:[{type:"text",text:JSON.stringify({error:b})}],structuredContent:{error:b}}}}},65858:(a,b,c)=>{c.d(b,{bz:()=>m,wp:()=>j});var d=c(33873),e=c.n(d),f=c(21820),g=c.n(f),h=c(85510),i=c(48092);let j="FLUJO_ALLOW_PROTECTED_PATHS",k=null;function l(a,...b){return e().resolve(a,...b)}function m(a){let b=e().resolve(a);if((function(){let a=[];try{a.push(e().resolve((0,h.getDataDir)()))}catch{}try{a.push(e().resolve(g().tmpdir()))}catch{}return a})().some(a=>(0,i.F)(a,b)))return{denied:!1};for(let a of function(){var a;let b="string"==typeof(a=process.env[j])&&/^(1|true|yes|on)$/i.test(a.trim()),c=(0,h.getHomeDir)(),d=`${b?"off":"on"}::${c}`;if(k&&k.key===d)return k.paths;let f=b?[]:function(a){let b=[];if("win32"===process.platform)for(let c of["AppData","Downloads","Desktop","Documents","Pictures","Music","Videos","OneDrive"])b.push(l(a,c));else if("darwin"===process.platform){for(let c of["Downloads","Desktop","Documents","Pictures","Music","Movies"])b.push(l(a,c));for(let c of["Library/Mail","Library/Messages","Library/Safari","Library/Cookies","Library/Calendars","Library/Application Support/AddressBook","Library/Application Support/com.apple.TCC","Library/PersonalizationPortrait","Library/Metadata/CoreSpotlight","Library/Suggestions"])b.push(l(a,c));for(let a of["/.Spotlight-V100","/.fseventsd","/.DocumentRevisions-V100"])b.push(e().resolve(a))}else for(let c of["Documents","Downloads","Desktop",".ssh",".gnupg",".aws",".config"])b.push(l(a,c));return Array.from(new Set(b))}(c);return k={key:d,paths:f},f}())if((0,i.F)(a,b))return{denied:!0,matchedRoot:a};return{denied:!1}}}};
|
|
1
|
+
"use strict";exports.id=94,exports.ids=[94],exports.modules={50094:(a,b,c)=>{c.d(b,{filesystemCallTool:()=>R,filesystemToolDefinitions:()=>w});var d=c(33873),e=c.n(d),f=c(29021),g=c(55511),h=c(4984),i=c.n(h),j=c(18230),k=c(85510),l=c(94749),m=c(48092),n=c(65858),o=c(19724);let p=(0,j.h)("backend/services/mcp/internal/filesystemTools"),q={readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},r={readOnlyHint:!1,destructiveHint:!1,openWorldHint:!1},s={readOnlyHint:!1,destructiveHint:!0,openWorldHint:!1};function t(a){return{content:[{type:"text",text:JSON.stringify(a,null,2)}],structuredContent:a}}function u(a){return{content:[{type:"text",text:JSON.stringify({error:a},null,2)}],isError:!0}}async function v(a,b){let c="string"==typeof a?a.trim():"";if(!c)throw Error('Provide "path".');let d=(0,k.getDataDir)(),f=e().isAbsolute(c)?e().resolve(c):e().resolve(d,c);if(await (0,n.cd)()){let a=(0,n.bz)(f);if(a.denied)throw Error(`Path "${f}" is within a protected location (${a.matchedRoot}) and is blocked by the FLUJO built-in server protected-path policy. Disable "Protect sensitive home-directory paths" in Experimental Features or set ${n.wp}=1 to override.`)}if(0===b.length||!b.some(a=>(0,m.F)(a,f)))throw Error(`Path "${f}" is outside the configured filesystem roots.`);return f}function w(){let a={type:"string",description:"File or directory path. Relative paths resolve against the FLUJO data directory; absolute paths are used as-is."};return[{name:"read_file",annotations:q,description:'Read a text file and return its content. Optionally read only a line range with "from"/"to" (1-based, inclusive). For large files (> 100 KB) read WHOLE (no "from"/"to"), a "pattern" is REQUIRED: the server greps the file and returns only matching lines (with a little surrounding context) so you can follow up with targeted "from"/"to" reads. Pass pattern "*" to force-read the entire large file anyway. Returns { path, from, to, totalLines, content, truncated, contentHash, matches? }. Pass the returned contentHash back as "expectedHash" on a follow-up edit_file/write_file to guard against the file changing in between (TOCTOU).',inputSchema:{type:"object",properties:{path:a,from:{type:"number",description:"Optional 1-based first line to return (inclusive)."},to:{type:"number",description:"Optional 1-based last line to return (inclusive)."},pattern:{type:"string",description:'Case-insensitive substring to grep for. Required to read a large file whole without a "from"/"to" range; matching lines (plus context) are returned instead of the full body. Use "*" to read the whole large file anyway.'}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},from:{type:"number"},to:{type:"number"},totalLines:{type:"number"},truncated:{type:"boolean"},content:{type:"string"},contentHash:{type:"string",description:'SHA-256 (hex) of the raw file content. Pass this back as "expectedHash" to edit_file/write_file to guard against the file changing between read and write (TOCTOU).'},matches:{type:"array",items:{type:"object",properties:{line:{type:"number"},text:{type:"string"}},required:["line","text"]}}},required:["path","from","to","totalLines","truncated","content"]}},{name:"write_file",annotations:s,description:'Create or write a text file (parent directories are created). "mode": "overwrite" (default) replaces the whole file, or a line range when "startLine"/"endLine" (1-based inclusive) are given; "append" adds content at the end; "insert" inserts content before "startLine". Optionally pass "expectedHash" (the contentHash from a prior read_file) to reject the write if the file changed on disk since it was read (TOCTOU guard); ignored for a whole-file overwrite. Returns { path, bytesWritten, mode, ... }.',_meta:{ui:{resourceUri:"ui://devcanvas/diff"}},inputSchema:{type:"object",properties:{path:a,content:{type:"string",description:"The content to write/insert/append."},mode:{type:"string",enum:["overwrite","append","insert"],description:'Write mode (default "overwrite").'},startLine:{type:"number",description:'For "insert": line to insert before. For "overwrite": first line of the range to replace (1-based).'},endLine:{type:"number",description:'For "overwrite": last line (inclusive, 1-based) of the range to replace.'},expectedHash:{type:"string",description:"Optional SHA-256 (contentHash from read_file). For append/insert/range-overwrite modes, the write is rejected if the file no longer hashes to this value (TOCTOU guard)."}},required:["path","content"]},outputSchema:{type:"object",properties:{path:{type:"string"},bytesWritten:{type:"number"},mode:{type:"string"},startLine:{type:"number"},endLine:{type:"number"},linesReplaced:{type:"number"},linesInserted:{type:"number"}},required:["path","bytesWritten","mode"]}},{name:"edit_file",annotations:s,description:'Edit a text file two ways (mutually exclusive): (1) "edits": [{ oldText, newText, startLine?, endLine? }] literal find/replace — each replaces the unique occurrence of oldText. startLine/endLine are an optional disambiguation HINT (if exactly one match starts in that range it wins); a wrong/missing range still works as long as oldText is unique in the file. Include enough surrounding context to make oldText unique. Or (2) "diff": a unified diff string ("@@ -a,b +c,d @@" hunks) applied atomically — hunks are relocated to where their context actually matches, so slightly-off @@ line numbers still apply, and CRLF files are handled. Fails with no partial write only when text is missing/ambiguous or a hunk context is not found. Optionally pass "expectedHash" (the contentHash from a prior read_file) to reject the edit if the file changed on disk since it was read (TOCTOU guard). Returns { path, editsApplied|applied, diff:{added,removed} }.',_meta:{ui:{resourceUri:"ui://devcanvas/diff"}},inputSchema:{type:"object",properties:{path:a,edits:{type:"array",description:"List of literal { oldText, newText } edits applied in order (optionally scoped with startLine/endLine).",items:{type:"object",properties:{oldText:{type:"string",description:"Exact text to find."},newText:{type:"string",description:"Replacement text."},startLine:{type:"number",description:"Optional 1-based first line to scope this edit to."},endLine:{type:"number",description:"Optional 1-based last line (inclusive) to scope this edit to."}},required:["oldText","newText"]}},diff:{type:"string",description:'A unified diff to apply atomically. Mutually exclusive with "edits".'},startLine:{type:"number",description:"Optional default 1-based first line to scope all literal edits to."},endLine:{type:"number",description:"Optional default 1-based last line (inclusive) to scope all literal edits to."},expectedHash:{type:"string",description:"Optional SHA-256 (contentHash from read_file). If provided and the freshly-read file no longer hashes to it, the edit is rejected with no changes written (TOCTOU guard)."}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},mode:{type:"string"},editsApplied:{type:"number"},applied:{type:"boolean"},diff:{type:"object",properties:{added:{type:"number"},removed:{type:"number"}},required:["added","removed"]}},required:["path","diff"]}},{name:"list_dir",annotations:q,description:'List the entries of a directory. Returns { path, entries: [{ name, type, size }] } where type is "file" | "directory" | "other".',inputSchema:{type:"object",properties:{path:a},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},entries:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"},size:{type:"number"}},required:["name","type","size"]}}},required:["path","entries"]}},{name:"file_browser_ui",annotations:q,description:'Open an interactive file browser in the chat so the USER can pick a file. This returns IMMEDIATELY without a selection — the browser is shown to the user and the file they choose arrives afterwards as a follow-up user message (e.g. "Selected file: <path>"). After calling this tool you MUST stop and wait for that message; do not guess a path or continue until the user has selected.',_meta:{ui:{resourceUri:"ui://filesystem/browser"}},inputSchema:{type:"object",properties:{path:{...a,description:"Optional starting directory for the browser (defaults to the FLUJO data directory)."}},required:[]}},{name:"dir_tree",annotations:q,description:"Return a recursive, depth-limited directory tree as nested JSON. Returns { path, depth, tree }.",inputSchema:{type:"object",properties:{path:a,depth:{type:"number",description:"Maximum recursion depth (default 3, max 10)."}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},depth:{type:"number"},truncated:{type:"boolean"},tree:{type:"array"}},required:["path","depth","tree"]}},{name:"search",annotations:q,description:'Search a directory tree. Match file/dir NAMES against "namePattern" (substring, case-insensitive) and/or file CONTENT against "content" (substring, case-insensitive). Content search DOES look inside every text file, returning each matching line with its 1-based line number; likely-binary and very large files are skipped for speed. Returns { matches: [{ path, line?, text? }], truncated }.',inputSchema:{type:"object",properties:{path:a,namePattern:{type:"string",description:"Optional case-insensitive substring to match against entry names."},content:{type:"string",description:"Optional case-insensitive substring to match inside text files."}},required:["path"]},outputSchema:{type:"object",properties:{matches:{type:"array",items:{type:"object",properties:{path:{type:"string"},line:{type:"number"},text:{type:"string"}},required:["path"]}},truncated:{type:"boolean"}},required:["matches","truncated"]}},{name:"get_file_info",annotations:q,description:"Stat a path. Returns { path, type, size, isFile, isDirectory, createdAt, modifiedAt }.",inputSchema:{type:"object",properties:{path:a},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},type:{type:"string"},size:{type:"number"},isFile:{type:"boolean"},isDirectory:{type:"boolean"},createdAt:{type:"string"},modifiedAt:{type:"string"}},required:["path","type","size","isFile","isDirectory","createdAt","modifiedAt"]}},{name:"create_directory",annotations:r,description:"Create a directory (recursively). Succeeds if it already exists. Returns { path, created }.",inputSchema:{type:"object",properties:{path:a},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},created:{type:"boolean"}},required:["path","created"]}},{name:"move",annotations:s,description:'Move or rename a file/directory from "source" to "destination". Returns { source, destination }.',inputSchema:{type:"object",properties:{source:{type:"string",description:"Existing path to move."},destination:{type:"string",description:"Target path."}},required:["source","destination"]},outputSchema:{type:"object",properties:{source:{type:"string"},destination:{type:"string"}},required:["source","destination"]}},{name:"delete",annotations:s,description:'Delete a file or directory. Pass "recursive": true to remove a non-empty directory. Returns { path, deleted }.',inputSchema:{type:"object",properties:{path:a,recursive:{type:"boolean",description:"Remove directories and their contents recursively."}},required:["path"]},outputSchema:{type:"object",properties:{path:{type:"string"},deleted:{type:"boolean"}},required:["path","deleted"]}},{name:"get_allowed_directories",annotations:q,description:"Returns the list of directories that this filesystem MCP server is currently allowed to access. The list is the merged result of server-level roots (configured via FLUJO MCP settings), MCP-node-level roots (set in the FlowBuilder), and the FLUJO_FS_ROOTS environment variable ceiling. When no roots are configured at all, returns the FLUJO data directory as the default (so the file browser is usable out of the box).",inputSchema:{type:"object",properties:{},required:[]},outputSchema:{type:"object",properties:{directories:{type:"array",items:{type:"string"},description:"Absolute paths of all allowed directories."}},required:["directories"]}}]}function x(a){return a.replace(/\r\n?/g,"\n").split("\n")}function y(a){return a.includes("\r\n")?"\r\n":"\n"}function z(a){return(0,g.createHash)("sha256").update(a,"utf8").digest("hex")}function A(a){return a.startsWith("\uFEFF")?{bom:"\uFEFF",body:a.slice(1)}:{bom:"",body:a}}let B="File changed after permission approval. Read it again before editing. No changes written.";function C(a){let b=Math.min(a.length,8e3);for(let c=0;c<b;c++)if(0===a[c])return!0;return!1}async function D(a,b,c){let d=b.toLowerCase(),e=[],g=!1,h=(0,f.createReadStream)(a,{encoding:"utf8"}),j=i().createInterface({input:h,crlfDelay:1/0}),k=0;try{for await(let a of j)if(k++,a.toLowerCase().includes(d)&&(e.push({line:k,text:a.slice(0,400)}),e.length>=c)){g=!0;break}}finally{j.close(),h.destroy()}return{matches:e,truncated:g}}async function E(a,b){let c=await v(a.path,b),d="number"==typeof a.from||"number"==typeof a.to,e="string"==typeof a.pattern?a.pattern.trim():"",g=0;try{g=(await f.promises.stat(c)).size}catch{}if(g>1e5&&!d&&!e)return u(`File is large (${g} bytes > 100000 threshold). Reading it whole would flood the context. Provide a "pattern" to grep for (matching lines + context are returned, then read targeted ranges with "from"/"to"), or pass pattern "*" to read the whole file anyway.`);if(e&&"*"!==e&&!d){let a=await f.promises.readFile(c);if(C(a))return u(`File appears to be binary; cannot grep for a pattern: ${c}`);let b=a.toString("utf8"),d=x(b),h=d.length,i=e.toLowerCase(),j=[];for(let a=0;a<d.length&&(!d[a].toLowerCase().includes(i)||(j.push({line:a+1,text:d[a].slice(0,400)}),!(j.length>=200)));a++);let k=j.length>=200,l=new Set;for(let a of j)for(let b=a.line-2;b<=a.line+2;b++)b>=1&&b<=h&&l.add(b);let m=[...l].sort((a,b)=>a-b),n=[],p=0;for(let a of m)p&&a>p+1&&n.push("…"),n.push(`${a}: ${d[a-1]}`),p=a;let q=n.join("\n");return q.length>2e5&&(q=q.slice(0,2e5)+"\n…[truncated]"),(0,o.Wk)(c,"read",g),t({path:c,from:1,to:h,totalLines:h,truncated:k,content:j.length?q:`(no lines matched pattern ${JSON.stringify(e)})`,matches:j,contentHash:z(b)})}let h=await f.promises.readFile(c,"utf8"),i=x(h),j=i.length,k="number"==typeof a.from?Math.max(1,Math.floor(a.from)):1,l="number"==typeof a.to?Math.floor(a.to):j;l<k&&([k,l]=[l,k]),l=Math.min(l,j);let m=d?i.slice(k-1,l).join("\n"):h,n=!1;return m.length>2e5&&(m=m.slice(0,2e5)+"\n…[truncated]",n=!0),(0,o.Wk)(c,"read",g),t({path:c,from:d?k:1,to:d?l:j,totalLines:j,truncated:n,content:m,contentHash:z(h)})}async function F(a,b){let c=await v(a.path,b),d="string"==typeof a.content?a.content:"",g="append"===a.mode||"insert"===a.mode?a.mode:"overwrite",h="number"==typeof a.startLine||"number"==typeof a.endLine;if(await f.promises.mkdir(e().dirname(c),{recursive:!0}),(0,o.Wk)(c,"write"),"overwrite"===g&&!h)return await f.promises.writeFile(c,d,"utf8"),t({path:c,bytesWritten:Buffer.byteLength(d,"utf8"),mode:"overwrite"});let i="";try{i=await f.promises.readFile(c,"utf8")}catch{i=""}let j="string"==typeof a.expectedHash?a.expectedHash:void 0;if(j&&z(i)!==j)return u(B);let{bom:k,body:l}=A(i);if("append"===g){let a=!l.length||l.endsWith("\n")||l.endsWith("\r\n")?"":y(l),b=k+l+a+d;return await f.promises.writeFile(c,b,"utf8"),t({path:c,bytesWritten:Buffer.byteLength(b,"utf8"),mode:"append"})}let m=y(l),n=l.length?l.split(/\r?\n/):[],p=d.split(/\r?\n/),q=n.length;if("insert"===g){let b="number"==typeof a.startLine?Math.max(1,Math.floor(a.startLine)):q+1,d=Math.min(b-1,q);n.splice(d,0,...p);let e=k+n.join(m);return await f.promises.writeFile(c,e,"utf8"),t({path:c,bytesWritten:Buffer.byteLength(e,"utf8"),mode:"insert",startLine:b,linesInserted:p.length})}let r="number"==typeof a.startLine?Math.max(1,Math.floor(a.startLine)):1,s="number"==typeof a.endLine?Math.floor(a.endLine):r;s<r&&([r,s]=[s,r]);let w=Math.max(0,(s=Math.min(s,q))-r+1);n.splice(r-1,w,...p);let x=k+n.join(m);return await f.promises.writeFile(c,x,"utf8"),t({path:c,bytesWritten:Buffer.byteLength(x,"utf8"),mode:"overwrite",startLine:r,endLine:s,linesReplaced:w})}async function G(a,b){let c=await v(a.path,b),d="string"==typeof a.diff&&a.diff.trim().length>0,e=Array.isArray(a.edits)&&a.edits.length>0;if(d&&e)return u('Provide either "diff" or "edits", not both.');let g=await f.promises.readFile(c,"utf8"),h="string"==typeof a.expectedHash?a.expectedHash:void 0;if(h&&z(g)!==h)return u(B);let{bom:i,body:j}=A(g);if(d){let b,d=y(j),e=j.replace(/\r\n?/g,"\n");try{b=function(a,b){let c=a.split("\n"),d=b.split(/\r?\n/),e=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,f=[],g=null;for(let a=0;a<d.length;a++){let b=d[a];if(void 0===b)break;let c=e.exec(b);if(c){g={oldStart:parseInt(c[1],10),ops:[]},f.push(g);continue}if(b.startsWith("--- ")||b.startsWith("+++ ")){g=null;continue}if(!g)continue;let h=b.length?b[0]:" ",i=b.length?b.slice(1):"";if(" "===h||"-"===h||"+"===h)g.ops.push({tag:h,body:i});else if("\\"===h);else throw Error(`unexpected diff line: ${JSON.stringify(b)}`)}if(0===f.length)throw Error("no unified-diff hunks (@@ ... @@) found");let h=[],i=0,j=0,k=0;for(let a of f){let b=function(a,b,c,d){if(0===b.length)return Math.min(Math.max(c,d),a.length);let e=a.length-b.length,f=c=>{if(c<d||c>e)return!1;for(let d=0;d<b.length;d++)if(a[c+d]!==b[d])return!1;return!0},g=Math.max(d,c);if(f(g))return g;let h=Math.max(g-d,e-g);for(let a=1;a<=h;a++){if(f(g-a))return g-a;if(f(g+a))return g+a}throw Error(`could not locate hunk near line ${c+1}; its context/removed lines do not match the file. First expected line: ${JSON.stringify(b[0])}`)}(c,a.ops.filter(a=>" "===a.tag||"-"===a.tag).map(a=>a.body),Math.max(0,a.oldStart-1),i);if(b<i)throw Error("overlapping or out-of-order hunks");for(;i<b;)h.push(c[i]),i++;for(let b of a.ops)" "===b.tag?(h.push(c[i]),i++):"-"===b.tag?(i++,k++):(h.push(b.body),j++)}for(;i<c.length;)h.push(c[i]),i++;return{result:h.join("\n"),added:j,removed:k}}(e,a.diff)}catch(a){return u(`Diff apply failed: ${a instanceof Error?a.message:String(a)}. No changes written.`)}let g=i+("\r\n"===d?b.result.replace(/\n/g,"\r\n"):b.result);return await f.promises.writeFile(c,g,"utf8"),(0,o.Wk)(c,"write"),t({path:c,applied:!0,mode:"diff",diff:{added:b.added,removed:b.removed}})}let k=Array.isArray(a.edits)?a.edits:[];if(0===k.length)return u('Provide a non-empty "edits" array of { oldText, newText } or a "diff" string.');let l="number"==typeof a.startLine?a.startLine:void 0,m="number"==typeof a.endLine?a.endLine:void 0,n=y(j),p=j.replace(/\r\n?/g,"\n"),q=0;for(let a of k){let b="string"==typeof a.oldText?a.oldText.replace(/\r\n?/g,"\n"):"",d="string"==typeof a.newText?a.newText.replace(/\r\n?/g,"\n"):"";if(!b)return u(`Edit #${q+1} has an empty "oldText".`);let e="number"==typeof a.startLine?a.startLine:l,f="number"==typeof a.endLine?a.endLine:m,g=void 0!==e||void 0!==f,h=[];for(let a=p.indexOf(b);-1!==a;a=p.indexOf(b,a+1))h.push(a);if(0===h.length)return u(`Edit #${q+1}: "oldText" not found in ${c}. No changes written.`);let i=-1;if(g){let{lo:a,hi:b}=function(a,b,c){if(void 0===b&&void 0===c)return{lo:0,hi:a.length};let d=a.split("\n"),e=Math.max(1,Math.floor(b??1)),f=Math.min(d.length,Math.floor(c??d.length)),g=0;for(let a=0;a<e-1&&a<d.length;a++)g+=d[a].length+1;let h=g;for(let a=e-1;a<f&&a<d.length;a++)h+=d[a].length+ +(a<d.length-1);return{lo:g,hi:Math.max(g,h)}}(p,e,f),c=h.filter(c=>c>=a&&c<b);1===c.length&&(i=c[0])}if(-1===i)if(1!==h.length)return u(`Edit #${q+1}: "oldText" is ambiguous (appears ${h.length} times); add more surrounding context or a tighter startLine/endLine so exactly one occurrence is in range. No changes written.`);else i=h[0];p=p.slice(0,i)+d+p.slice(i+b.length),q+=1}let r=function(a,b){let c=x(a),d=x(b),e=new Map;for(let a of d)e.set(a,(e.get(a)??0)+1);let f=new Map;for(let a of c)f.set(a,(f.get(a)??0)+1);let g=0;for(let[a,b]of f)g+=Math.max(0,b-(e.get(a)??0));let h=0;for(let[a,b]of e)h+=Math.max(0,b-(f.get(a)??0));return{added:h,removed:g}}(j,p),s=i+("\r\n"===n?p.replace(/\n/g,"\r\n"):p);return await f.promises.writeFile(c,s,"utf8"),(0,o.Wk)(c,"write"),t({path:c,mode:"edits",editsApplied:q,diff:r})}async function H(a){try{let b=await f.promises.lstat(a);if(b.isFile())return"file";if(b.isDirectory())return"directory";return"other"}catch{return"other"}}async function I(a,b){let c=await v(a.path,b),d=await f.promises.readdir(c),g=await Promise.all(d.map(async a=>{let b=e().join(c,a),d=await H(b),g=0;try{g=(await f.promises.stat(b)).size}catch{}return{name:a,type:d,size:g}}));return g.sort((a,b)=>a.type===b.type?a.name.localeCompare(b.name):"directory"===a.type?-1:1),t({path:c,entries:g})}async function J(a,b){let c=await v(a.path,b),d=Math.min("number"==typeof a.depth?Math.max(1,Math.floor(a.depth)):3,10),g=0,h=!1;async function i(a,b){let c;if(b>d||h)return[];try{c=await f.promises.readdir(a)}catch{return[]}c.sort((a,b)=>a.localeCompare(b));let j=[];for(let f of c){if(++g>5e3){h=!0;break}let c=e().join(a,f),k=await H(c),l={name:f,type:k};"directory"===k&&b<d&&(l.children=await i(c,b+1)),j.push(l)}return j}let j=await i(c,1);return t({path:c,depth:d,truncated:h,tree:j})}async function K(a,b,c){let d;try{d=await f.promises.stat(a)}catch{return[]}if(!d.isFile()||d.size>5e6)return[];try{let b=await f.promises.open(a,"r");try{let a=Buffer.alloc(Math.min(8e3,d.size));if(a.length&&await b.read(a,0,a.length,0),C(a))return[]}finally{await b.close()}}catch{return[]}let{matches:e}=await D(a,b,Math.max(1,c));return e.map(b=>({path:a,line:b.line,text:b.text}))}async function L(a,b){let c=await v(a.path,b),d="string"==typeof a.namePattern?a.namePattern.toLowerCase():"",g="string"==typeof a.content?a.content:"";if(!d&&!g)return u('Provide "namePattern" and/or "content" to search for.');let h=[],i=!1,j=[];async function k(a){let b;if(!i){try{b=await f.promises.readdir(a)}catch{return}for(let c of b){if(i)return;let b=e().join(a,c),f=await H(b);if(d&&c.toLowerCase().includes(d)&&(h.push({path:b}),h.length>=1e3)){i=!0;return}"directory"===f?await k(b):"file"===f&&g&&j.push(b)}}}if(await k(c),g&&!i)for(let a=0;a<j.length&&!i;a+=16){let b=j.slice(a,a+16);for(let a of(await Promise.all(b.map(a=>K(a,g,1e3))))){for(let b of a)if(h.push(b),h.length>=1e3){i=!0;break}if(i)break}}return t({matches:h,truncated:i})}async function M(a,b){let c=await v(a.path,b),d=await f.promises.stat(c);return t({path:c,type:d.isFile()?"file":d.isDirectory()?"directory":"other",size:d.size,isFile:d.isFile(),isDirectory:d.isDirectory(),createdAt:d.birthtime.toISOString(),modifiedAt:d.mtime.toISOString()})}async function N(a,b){let c=await v(a.path,b);return await f.promises.mkdir(c,{recursive:!0}),t({path:c,created:!0})}async function O(a,b){let c=await v(a.source,b),d=await v(a.destination,b);return await f.promises.mkdir(e().dirname(d),{recursive:!0}),await f.promises.rename(c,d),t({source:c,destination:d})}async function P(a,b){let c=await v(a.path,b),d=!0===a.recursive;return await f.promises.rm(c,{recursive:d,force:!1}),t({path:c,deleted:!0})}async function Q(a){return t({directories:a})}async function R(a,b,c){try{if("file_browser_ui"===a)return function(a,b=!1){return{content:[{type:"text",text:a}],...b?{isError:!0}:{}}}("File browser shown to the user. Waiting for them to select a file — their choice will arrive as a follow-up message. Do not proceed until then.");let d=await (0,m.loadEffectiveRoots)(l.K3,"FLUJO_FS_ROOTS",c);switch(a){case"read_file":return await E(b,d);case"write_file":return await F(b,d);case"edit_file":return await G(b,d);case"list_dir":return await I(b,d);case"dir_tree":return await J(b,d);case"search":return await L(b,d);case"get_file_info":return await M(b,d);case"create_directory":return await N(b,d);case"move":return await O(b,d);case"delete":return await P(b,d);case"get_allowed_directories":return await Q(d);default:return u(`Unknown tool on the built-in filesystem server: ${a}`)}}catch(c){let b=c instanceof Error?c.message:String(c);return p.warn("filesystemCallTool failed",{toolName:a,err:c}),{isError:!0,content:[{type:"text",text:JSON.stringify({error:b})}],structuredContent:{error:b}}}}},65858:(a,b,c)=>{c.d(b,{bz:()=>q,cd:()=>n,wp:()=>m});var d=c(33873),e=c.n(d),f=c(21820),g=c.n(f),h=c(85510),i=c(79111),j=c(31296),k=c(48092);function l(a){return"string"==typeof a&&/^(1|true|yes|on)$/i.test(a.trim())}let m="FLUJO_ALLOW_PROTECTED_PATHS";async function n(){if(l(process.env[m]))return!1;try{let a=await (0,i.YM)(j.Z.SPEECH_SETTINGS,void 0);return a?.experimental?.protectedPathsEnabled===!0}catch{return!1}}let o=null;function p(a,...b){return e().resolve(a,...b)}function q(a){let b=e().resolve(a);if((function(){let a=[];try{a.push(e().resolve((0,h.getDataDir)()))}catch{}try{a.push(e().resolve(g().tmpdir()))}catch{}return a})().some(a=>(0,k.F)(a,b)))return{denied:!1};for(let a of function(){let a=l(process.env[m]),b=(0,h.getHomeDir)(),c=`${a?"off":"on"}::${b}`;if(o&&o.key===c)return o.paths;let d=a?[]:function(a){let b=[];if("win32"===process.platform)for(let c of["AppData","Downloads","Desktop","Documents","Pictures","Music","Videos","OneDrive"])b.push(p(a,c));else if("darwin"===process.platform){for(let c of["Downloads","Desktop","Documents","Pictures","Music","Movies"])b.push(p(a,c));for(let c of["Library/Mail","Library/Messages","Library/Safari","Library/Cookies","Library/Calendars","Library/Application Support/AddressBook","Library/Application Support/com.apple.TCC","Library/PersonalizationPortrait","Library/Metadata/CoreSpotlight","Library/Suggestions"])b.push(p(a,c));for(let a of["/.Spotlight-V100","/.fseventsd","/.DocumentRevisions-V100"])b.push(e().resolve(a))}else for(let c of["Documents","Downloads","Desktop",".ssh",".gnupg",".aws",".config"])b.push(p(a,c));return Array.from(new Set(b))}(b);return o={key:c,paths:d},d}())if((0,k.F)(a,b))return{denied:!0,matchedRoot:a};return{denied:!1}}}};
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"wasm": [],
|
|
23
23
|
"assets": [],
|
|
24
24
|
"env": {
|
|
25
|
-
"__NEXT_BUILD_ID": "
|
|
25
|
+
"__NEXT_BUILD_ID": "eaxwKaaFHlA1_FLDIyFGi",
|
|
26
26
|
"NEXT_SERVER_ACTIONS_ENCRYPTION_KEY": "WipY2wqCj7jcOnM/w7hzkm1vZp+L2RxWCfXFxhqu01A=",
|
|
27
27
|
"__NEXT_PREVIEW_MODE_ID": "09ce06347e36a1c467f28421af5e6164",
|
|
28
28
|
"__NEXT_PREVIEW_MODE_SIGNING_KEY": "ed43ccd14c50a748a4aba5cd731bc503fc7a54fb8b2a9fcabbb98c4ffb09abb8",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><!--
|
|
1
|
+
<!DOCTYPE html><!--eaxwKaaFHlA1_FLDIyFGi--><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/_next/static/css/b496025c9cd768cc.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/599369d853c61df7.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/30253fcfa8035221.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-2d8e0c13c0b865fe.js"/><script src="/_next/static/chunks/4bd1b696-182b6b13bdad92e3.js" async=""></script><script src="/_next/static/chunks/1255-13d973e0759ea6d6.js" async=""></script><script src="/_next/static/chunks/main-app-2de821d2899bb841.js" async=""></script><script src="/_next/static/chunks/app/layout-038b35b382eef11d.js" async=""></script><meta name="robots" content="noindex"/><title>FLUJO</title><meta name="description" content="A browser-based application for managing models, MCP servers, flows and chat interactions"/><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body class="__variable_246ccd __variable_c29908 antialiased"><div hidden=""><!--$--><!--/$--></div><!--$--><!--$!--><template data-dgst="BAILOUT_TO_CLIENT_SIDE_RENDERING"></template><div>Loading theme...</div><!--/$--><!--/$--><script src="/_next/static/chunks/webpack-2d8e0c13c0b865fe.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[72403,[\"7177\",\"static/chunks/app/layout-038b35b382eef11d.js\"],\"default\"]\n3:I[9766,[],\"\"]\n4:I[98924,[],\"\"]\n5:I[24431,[],\"OutletBoundary\"]\n7:I[15278,[],\"AsyncMetadataOutlet\"]\n9:I[24431,[],\"ViewportBoundary\"]\nb:I[24431,[],\"MetadataBoundary\"]\nc:\"$Sreact.suspense\"\ne:I[57150,[],\"\"]\n:HL[\"/_next/static/css/b496025c9cd768cc.css\",\"style\"]\n:HL[\"/_next/static/css/599369d853c61df7.css\",\"style\"]\n:HL[\"/_next/static/css/30253fcfa8035221.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"eaxwKaaFHlA1_FLDIyFGi\",\"p\":\"\",\"c\":[\"\",\"_not-found\"],\"i\":false,\"f\":[[[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],[\"\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/b496025c9cd768cc.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/599369d853c61df7.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}],[\"$\",\"link\",\"2\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/30253fcfa8035221.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"className\":\"__variable_246ccd __variable_c29908 antialiased\",\"children\":[\"$\",\"$L2\",null,{\"children\":[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]}]}]]}],{\"children\":[\"/_not-found\",[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[\"__PAGE__\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$L5\",null,{\"children\":[\"$L6\",[\"$\",\"$L7\",null,{\"promise\":\"$@8\"}]]}]]}],{},null,false]},null,false]},null,false],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[[\"$\",\"$L9\",null,{\"children\":\"$La\"}],null],[\"$\",\"$Lb\",null,{\"children\":[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$c\",null,{\"fallback\":null,\"children\":\"$Ld\"}]}]}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$e\",[]],\"s\":false,\"S\":true}\n"])</script><script>self.__next_f.push([1,"a:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n6:null\n"])</script><script>self.__next_f.push([1,"8:{\"metadata\":[[\"$\",\"title\",\"0\",{\"children\":\"FLUJO\"}],[\"$\",\"meta\",\"1\",{\"name\":\"description\",\"content\":\"A browser-based application for managing models, MCP servers, flows and chat interactions\"}]],\"error\":null,\"digest\":\"$undefined\"}\n"])</script><script>self.__next_f.push([1,"d:\"$8:metadata\"\n"])</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><title data-next-head="">500: Internal Server Error</title><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-2d8e0c13c0b865fe.js" defer=""></script><script src="/_next/static/chunks/framework-1548034a53843b9f.js" defer=""></script><script src="/_next/static/chunks/main-9bda5041078d2b6a.js" defer=""></script><script src="/_next/static/chunks/pages/_app-e8b861c87f6f033c.js" defer=""></script><script src="/_next/static/chunks/pages/_error-c8f84f7bd11d43d4.js" defer=""></script><script src="/_next/static/
|
|
1
|
+
<!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><title data-next-head="">500: Internal Server Error</title><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-2d8e0c13c0b865fe.js" defer=""></script><script src="/_next/static/chunks/framework-1548034a53843b9f.js" defer=""></script><script src="/_next/static/chunks/main-9bda5041078d2b6a.js" defer=""></script><script src="/_next/static/chunks/pages/_app-e8b861c87f6f033c.js" defer=""></script><script src="/_next/static/chunks/pages/_error-c8f84f7bd11d43d4.js" defer=""></script><script src="/_next/static/eaxwKaaFHlA1_FLDIyFGi/_buildManifest.js" defer=""></script><script src="/_next/static/eaxwKaaFHlA1_FLDIyFGi/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":500}},"page":"/_error","query":{},"buildId":"eaxwKaaFHlA1_FLDIyFGi","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
|