Agent Zero AI framework
workdir outside project, gitkeeps
frdelc223b468183b
diff --git a/.gitignore b/.gitignoreindex 14e964a39..70b63905f 100644--- a/.gitignore+++ b/.gitignore@@ -21,11 +21,14 @@ knowledge/custom/instruments/# Handle logs directory-logs/*+logs/**+!logs/**/# Handle tmp and usr directory-tmp/*-usr/*+tmp/**+!tmp/**/+usr/**+!usr/**/# Handle knowledge directorydiff --git a/conf/projects.default.gitignore b/conf/projects.default.gitignoreindex 9a5f01f2a..81caaed19 100644--- a/conf/projects.default.gitignore+++ b/conf/projects.default.gitignore@@ -1,13 +1,10 @@-# A0 project meta folder-.a0proj/-# Python environments & cache-venv/-**/__pycache__/+venv/**+**/__pycache__/**# Node.js dependencies-**/node_modules/-**/.npm/+**/node_modules/**+**/.npm/**# Version control metadata-**/.git/+**/.git/**diff --git a/conf/workdir.gitignore b/conf/workdir.gitignorenew file mode 100644index 000000000..81caaed19--- /dev/null+++ b/conf/workdir.gitignore@@ -0,0 +1,10 @@+# Python environments & cache+venv/**+**/__pycache__/**++# Node.js dependencies+**/node_modules/**+**/.npm/**++# Version control metadata+**/.git/**diff --git a/prompts/agent.extras.agent_info.md b/prompts/agent.extras.agent_info.mdindex 04f2656c7..d3a2507ca 100644--- a/prompts/agent.extras.agent_info.md+++ b/prompts/agent.extras.agent_info.md@@ -1,3 +1,4 @@# Agent infoAgent Number: {{number}}-Profile: {{profile}}\ No newline at end of file+Profile: {{profile}}+LLM: {{llm}}\ No newline at end of filediff --git a/prompts/agent.extras.project.file_structure.md b/prompts/agent.extras.workdir_structure.mdsimilarity index 67%rename from prompts/agent.extras.project.file_structure.mdrename to prompts/agent.extras.workdir_structure.mdindex 5167003f9..ddaa4422f 100644--- a/prompts/agent.extras.project.file_structure.md+++ b/prompts/agent.extras.workdir_structure.md@@ -1,4 +1,4 @@-# File structure of project {{project_name}}+# File structure of working directory {{folder}}- this is filtered overview not full scan- list yourself if needed- maximum depth: {{max_depth}}diff --git a/prompts/agent.system.main.tips.md b/prompts/agent.system.main.tips.mdindex 382747869..470972dc8 100644--- a/prompts/agent.system.main.tips.md+++ b/prompts/agent.system.main.tips.md@@ -7,7 +7,7 @@ never assume successmemory refers memory tools not own knowledge## Files-when not in project save files in /root+when not in project save files in {{workdir_path}}don't use spaces in file names## Skillsdiff --git a/prompts/agent.system.main.tips.py b/prompts/agent.system.main.tips.pynew file mode 100644index 000000000..495444ea6--- /dev/null+++ b/prompts/agent.system.main.tips.py@@ -0,0 +1,24 @@+from python.helpers.files import VariablesPlugin+from python.helpers import settings+from python.helpers import projects+from python.helpers import runtime+from python.helpers import files+from typing import Any++class WorkdirPath(VariablesPlugin):+ def get_variables(+ self, file: str, backup_dirs: list[str] | None = None, **kwargs+ ) -> dict[str, Any]:++ # agent = kwargs.get("_agent")+ # if agent and getattr(agent, "context", None):+ # project_name = projects.get_context_project_name(agent.context)+ # if project_name:+ # folder = projects.get_project_folder(project_name)+ # if runtime.is_development():+ # folder = files.normalize_a0_path(folder)+ # return {"workdir_path": folder}++ set = settings.get_settings()+ return {"workdir_path": set["workdir_path"]}+diff --git a/prompts/agent.system.tool.code_exe.md b/prompts/agent.system.tool.code_exe.mdindex 5a0d42668..b5bf3b24f 100644--- a/prompts/agent.system.tool.code_exe.md+++ b/prompts/agent.system.tool.code_exe.md@@ -5,7 +5,7 @@ place code in "code" arg; escape carefully and indent properlyselect "runtime" arg: "terminal" "python" "nodejs" "output"select "session" number, 0 default, others for multitaskingif code runs long, use runtime "output" to wait-use reset true on next call to kill previous process when stuck default false+use argument reset true on next call to kill previous process when stuck default falseuse "pip" "npm" "apt-get" in "terminal" to install packageto output, use print() or console.log()if tool outputs error, adjust code before retrying;diff --git a/python/api/chat_files_path_get.py b/python/api/chat_files_path_get.pyindex b2ebb789e..e6402bfc0 100644--- a/python/api/chat_files_path_get.py+++ b/python/api/chat_files_path_get.py@@ -1,5 +1,5 @@from python.helpers.api import ApiHandler, Request, Response-from python.helpers import files, memory, notification, projects, notification, runtime+from python.helpers import files, memory, notification, projects, notification, runtime, settingsimport os@@ -14,7 +14,7 @@ class GetChatFilesPath(ApiHandler):if project_name:folder = files.normalize_a0_path(projects.get_project_folder(project_name))else:- folder = "/root" # root in container+ folder = settings.get_settings()["workdir_path"]return {"ok": True,diff --git a/python/api/settings_workdir_file_structure.py b/python/api/settings_workdir_file_structure.pynew file mode 100644index 000000000..ac1e117c2--- /dev/null+++ b/python/api/settings_workdir_file_structure.py@@ -0,0 +1,32 @@+from python.helpers.api import ApiHandler, Request, Response++from python.helpers import file_tree, files+++class SettingsWorkdirFileStructure(ApiHandler):+ async def process(self, input: dict, request: Request) -> dict | Response:+ workdir_path = input.get("workdir_path", "")+ workdir_path = files.get_abs_path_development(workdir_path)+ if not workdir_path:+ raise Exception("workdir_path is required")++ tree = str(+ file_tree.file_tree(+ workdir_path,+ max_depth=int(input.get("workdir_max_depth", 0) or 0),+ max_files=int(input.get("workdir_max_files", 0) or 0),+ max_folders=int(input.get("workdir_max_folders", 0) or 0),+ max_lines=int(input.get("workdir_max_lines", 0) or 0),+ ignore=input.get("workdir_gitignore", "") or "",+ output_mode=file_tree.OUTPUT_MODE_STRING,+ )+ )++ if "\n" not in tree:+ tree += "\n # Empty"++ return {"data": tree}++ @classmethod+ def get_methods(cls) -> list[str]:+ return ["POST"]diff --git a/python/extensions/message_loop_prompts_after/_70_include_agent_info.py b/python/extensions/message_loop_prompts_after/_70_include_agent_info.pyindex 0d331bcee..f6b54cb32 100644--- a/python/extensions/message_loop_prompts_after/_70_include_agent_info.py+++ b/python/extensions/message_loop_prompts_after/_70_include_agent_info.py@@ -1,14 +1,18 @@from python.helpers.extension import Extensionfrom agent import LoopData+class IncludeAgentInfo(Extension):async def execute(self, loop_data: LoopData = LoopData(), **kwargs):-+# read promptagent_info_prompt = self.agent.read_prompt("agent.extras.agent_info.md",number=self.agent.number,profile=self.agent.config.profile or "Default",+ llm=self.agent.config.chat_model.provider+ + "/"+ + self.agent.config.chat_model.name,)# add agent info to the promptdiff --git a/python/extensions/message_loop_prompts_after/_75_include_project_extras.py b/python/extensions/message_loop_prompts_after/_75_include_project_extras.pydeleted file mode 100644index 87bef95be..000000000--- a/python/extensions/message_loop_prompts_after/_75_include_project_extras.py+++ /dev/null@@ -1,47 +0,0 @@-from python.helpers.extension import Extension-from agent import LoopData-from python.helpers import projects---class IncludeProjectExtras(Extension):- async def execute(self, loop_data: LoopData = LoopData(), **kwargs):-- # active project- project_name = projects.get_context_project_name(self.agent.context)- if not project_name:- return-- # project config- project = projects.load_basic_project_data(project_name)-- # load file structure if enabled- if project["file_structure"]["enabled"]:- file_structure = projects.get_file_structure(project_name)- gitignore = cleanup_gitignore(project["file_structure"]["gitignore"])-- # read prompt- file_structure_prompt = self.agent.read_prompt(- "agent.extras.project.file_structure.md",- max_depth=project["file_structure"]["max_depth"],- gitignore=gitignore,- project_name=project_name,- file_structure=file_structure,- )- # add file structure to the prompt- loop_data.extras_temporary["project_file_structure"] = file_structure_prompt---def cleanup_gitignore(gitignore_raw: str) -> str:- """Process gitignore: split lines, strip, remove comments, remove empty lines."""- gitignore_lines = []- for line in gitignore_raw.split('\n'):- # Strip whitespace- line = line.strip()- # Remove inline comments (everything after #)- if '#' in line:- line = line.split('#')[0].strip()- # Keep only non-empty lines- if line:- gitignore_lines.append(line)-- return '\n'.join(gitignore_lines) if gitignore_lines else "nothing ignored"diff --git a/python/extensions/message_loop_prompts_after/_75_include_workdir_extras.py b/python/extensions/message_loop_prompts_after/_75_include_workdir_extras.pynew file mode 100644index 000000000..d88ce7459--- /dev/null+++ b/python/extensions/message_loop_prompts_after/_75_include_workdir_extras.py@@ -0,0 +1,92 @@+from python.helpers.extension import Extension+from agent import LoopData+from python.helpers import projects+from python.helpers import settings+from python.helpers import runtime+from python.helpers import file_tree+from python.helpers import files++class IncludeWorkdirExtras(Extension):+ async def execute(self, loop_data: LoopData = LoopData(), **kwargs):++ project_name = projects.get_context_project_name(self.agent.context)++ enabled = False+ max_depth = 0+ max_files = 0+ max_folders = 0+ max_lines = 0+ gitignore_raw = ""+ folder = ""+ file_structure = ""++ if project_name:+ project = projects.load_basic_project_data(project_name)+ enabled = project["file_structure"]["enabled"]++ if not enabled:+ return++ max_depth = project["file_structure"]["max_depth"]+ gitignore_raw = project["file_structure"]["gitignore"]++ folder = projects.get_project_folder(project_name)+ if runtime.is_development():+ folder = files.normalize_a0_path(folder)++ file_structure = projects.get_file_structure(project_name)+ else:+ set = settings.get_settings()+ enabled = bool(set["workdir_show"])++ if not enabled:+ return++ max_depth = set["workdir_max_depth"]+ max_files = set["workdir_max_files"]+ max_folders = set["workdir_max_folders"]+ max_lines = set["workdir_max_lines"]+ gitignore_raw = set["workdir_gitignore"]++ folder = set["workdir_path"]+ scan_path = files.get_abs_path_development(folder)++ file_structure = str(+ file_tree.file_tree(+ scan_path,+ max_depth=max_depth,+ max_files=max_files,+ max_folders=max_folders,+ max_lines=max_lines,+ ignore=gitignore_raw,+ output_mode=file_tree.OUTPUT_MODE_STRING,+ )+ )++ gitignore = cleanup_gitignore(gitignore_raw)++ file_structure_prompt = self.agent.read_prompt(+ "agent.extras.workdir_structure.md",+ max_depth=max_depth,+ gitignore=gitignore,+ folder=folder,+ file_structure=file_structure,+ )++ loop_data.extras_temporary["project_file_structure"] = file_structure_prompt+++def cleanup_gitignore(gitignore_raw: str) -> str:+ """Process gitignore: split lines, strip, remove comments, remove empty lines."""+ gitignore_lines = []+ for line in gitignore_raw.split('\n'):+ # Strip whitespace+ line = line.strip()+ # Remove inline comments (everything after #)+ if '#' in line:+ line = line.split('#')[0].strip()+ # Keep only non-empty lines+ if line:+ gitignore_lines.append(line)++ return '\n'.join(gitignore_lines) if gitignore_lines else "nothing ignored"diff --git a/python/helpers/backup.py b/python/helpers/backup.pyindex 2073aa854..fbabfb0ac 100644--- a/python/helpers/backup.py+++ b/python/helpers/backup.py@@ -63,9 +63,6 @@ class BackupService:return f"""# User data# All persistent user data is now centralized in /usr for easier backup and restore{agent_root}/usr/**--# Root folder-/root/**"""def _get_agent_zero_version(self) -> str:diff --git a/python/helpers/file_tree.py b/python/helpers/file_tree.pyindex c53dbcda5..c587ed487 100644--- a/python/helpers/file_tree.py+++ b/python/helpers/file_tree.py@@ -8,7 +8,7 @@ from typing import Any, Callable, Iterable, Literal, Optional, Sequencefrom pathspec import PathSpec-from python.helpers.files import get_abs_path+from python.helpers import files as files_helperSORT_BY_NAME = "name"SORT_BY_CREATED = "created"@@ -62,10 +62,12 @@ def file_tree(:data:`OUTPUT_MODE_NESTED`.Returns:- ``OUTPUT_MODE_STRING`` → ``str``: multi-line ASCII tree.- ``OUTPUT_MODE_FLAT`` → ``list[dict]``: flattened sequence of TreeItem dictionaries.- ``OUTPUT_MODE_NESTED`` → ``list[dict]``: nested TreeItem dictionaries where folders- include ``items`` arrays.+ ``OUTPUT_MODE_STRING`` → ``str``: multi-line ASCII tree. The first line is the root banner and+ uses a dockerized absolute path for display.+ ``OUTPUT_MODE_FLAT`` → ``list[dict]``: flattened sequence of TreeItem dictionaries, with a+ synthetic root folder item prepended at index 0 (using a dockerized absolute path for display).+ ``OUTPUT_MODE_NESTED`` → ``list[dict]``: a single synthetic root folder item (using a dockerized+ absolute path for display) whose ``items`` contains the nested TreeItem dictionaries.Notes:* The utility is synchronous; avoid calling from latency-sensitive async loops.@@ -81,7 +83,8 @@ def file_tree(epoch = item[\"created\"].timestamp()"""- abs_root = get_abs_path(relative_path)+ abs_root = files_helper.get_abs_path(relative_path)+ output_root = files_helper.get_abs_path_dockerized(relative_path)if not os.path.exists(abs_root):raise FileNotFoundError(f"Path does not exist: {relative_path!r}")@@ -234,8 +237,15 @@ def file_tree(if not visible_ids or id(node) in visible_ids:yield node+ def make_root_item(items: list[dict] | None) -> dict:+ root_item = root_node.as_dict()+ root_item["name"] = output_root+ root_item["text"] = f"{output_root.rstrip(os.sep)}/"+ root_item["items"] = items+ return root_item+if output_mode == OUTPUT_MODE_STRING:- display_name = relative_path.strip() or root_name+ display_name = output_root #relative_path.strip() or root_nameroot_line = f"{display_name.rstrip(os.sep)}/"lines = [root_line]for node in iter_visible():@@ -243,9 +253,9 @@ def file_tree(return "\n".join(lines)if output_mode == OUTPUT_MODE_FLAT:- return _build_tree_items_flat(list(iter_visible()))+ return [make_root_item(None)] + _build_tree_items_flat(list(iter_visible()))- return _to_nested_structure(root_node.items or [])+ return [make_root_item(_to_nested_structure(root_node.items or []))]@dataclass(slots=True)diff --git a/python/helpers/files.py b/python/helpers/files.pyindex db565f3a1..5009e6160 100644--- a/python/helpers/files.py+++ b/python/helpers/files.py@@ -509,6 +509,19 @@ def get_abs_path(*relative_paths):"Convert relative paths to absolute paths based on the base directory."return os.path.join(get_base_dir(), *relative_paths)+def get_abs_path_dockerized(*relative_paths):+ "Ensures the abs path is dockerized (i.e. /a0/... path)"+ abs = get_abs_path(*relative_paths)+ from python.helpers import runtime+ if runtime.is_dockerized():+ return abs+ return normalize_a0_path(abs)++def get_abs_path_development(*relative_paths):+ "Ensures the abs path is relevant for dev environment"+ abs = get_abs_path(*relative_paths)+ return fix_dev_path(abs)+def deabsolute_path(path: str):"Convert absolute paths to relative paths based on the base directory."diff --git a/python/helpers/settings.py b/python/helpers/settings.pyindex f3ac7f837..91773f503 100644--- a/python/helpers/settings.py+++ b/python/helpers/settings.py@@ -50,7 +50,6 @@ def get_default_value(name: str, value: T) -> T:)return value-class Settings(TypedDict):version: str@@ -96,6 +95,14 @@ class Settings(TypedDict):agent_memory_subdir: stragent_knowledge_subdir: str+ workdir_path: str+ workdir_show: bool+ workdir_max_depth: int+ workdir_max_files: int+ workdir_max_folders: int+ workdir_max_lines: int+ workdir_gitignore: str+memory_recall_enabled: boolmemory_recall_delayed: boolmemory_recall_interval: int@@ -479,6 +486,7 @@ def _write_sensitive_settings(settings: Settings):def get_default_settings() -> Settings:+ gitignore = files.read_file(files.get_abs_path("conf/workdir.gitignore"))return Settings(version=_get_version(),chat_model_provider=get_default_value("chat_model_provider", "openrouter"),@@ -536,6 +544,13 @@ def get_default_settings() -> Settings:agent_profile=get_default_value("agent_profile", "agent0"),agent_memory_subdir=get_default_value("agent_memory_subdir", "default"),agent_knowledge_subdir=get_default_value("agent_knowledge_subdir", "custom"),+ workdir_path=get_default_value("workdir_path", files.get_abs_path_dockerized("usr/workdir")),+ workdir_show=get_default_value("workdir_show", True),+ workdir_max_depth=get_default_value("workdir_max_depth", 5),+ workdir_max_files=get_default_value("workdir_max_files", 20),+ workdir_max_folders=get_default_value("workdir_max_folders", 20),+ workdir_max_lines=get_default_value("workdir_max_lines", 250),+ workdir_gitignore=get_default_value("workdir_gitignore", gitignore),rfc_auto_docker=get_default_value("rfc_auto_docker", True),rfc_url=get_default_value("rfc_url", "localhost"),rfc_password="",diff --git a/python/tools/code_execution_tool.py b/python/tools/code_execution_tool.pyindex 828a1255b..f7435393a 100644--- a/python/tools/code_execution_tool.py+++ b/python/tools/code_execution_tool.py@@ -3,7 +3,7 @@ from dataclasses import dataclassimport shleximport timefrom python.helpers.tool import Tool, Response-from python.helpers import files, rfc_exchange, projects, runtime+from python.helpers import files, rfc_exchange, projects, runtime, settingsfrom python.helpers.print_style import PrintStylefrom python.helpers.shell_local import LocalInteractiveSessionfrom python.helpers.shell_ssh import SSHInteractiveSession@@ -135,6 +135,7 @@ class CodeExecution(Tool):# initialize local or remote interactive shell interface for session 0 if neededif session is not None and session not in shells:+ cwd = await self.ensure_cwd()if self.agent.config.code_exec_ssh_enabled:pswd = (self.agent.config.code_exec_ssh_pass@@ -147,10 +148,10 @@ class CodeExecution(Tool):self.agent.config.code_exec_ssh_port,self.agent.config.code_exec_ssh_user,pswd,- cwd=self.get_cwd(),+ cwd=cwd,)else:- shell = LocalInteractiveSession(cwd=self.get_cwd())+ shell = LocalInteractiveSession(cwd=cwd)shells[session] = ShellWrap(id=session, session=shell, running=False)await shell.connect()@@ -472,13 +473,24 @@ class CodeExecution(Tool):output = truncate_text_agent(agent=self.agent, output=output, threshold=1000000) # ~1MB, larger outputs should be dumped to file, not read from terminalreturn output- def get_cwd(self):+ async def ensure_cwd(self) -> str | None:project_name = projects.get_context_project_name(self.agent.context)- if not project_name:+ if project_name:+ path = projects.get_project_folder(project_name)+ else:+ set = settings.get_settings()+ path = set.get("workdir_path")++ if not path:return None- project_path = projects.get_project_folder(project_name)- normalized = files.normalize_a0_path(project_path)++ normalized = files.normalize_a0_path(path)+ await runtime.call_development_function(make_dir, normalized)return normalized++def make_dir(path: str):+ import os+ os.makedirs(path, exist_ok=True)\ No newline at end of filediff --git a/run_ui.py b/run_ui.pyindex 754a0ddf3..2b6433da5 100644--- a/run_ui.py+++ b/run_ui.py@@ -6,6 +6,7 @@ import socketimport structfrom functools import wrapsimport threading+import asyncioimport uvicornfrom flask import Flask, request, Response, session, redirect, url_for, render_template_string@@ -197,6 +198,7 @@ async def login_handler():session['authentication'] = login.get_credentials_hash()return redirect(url_for('serve_index'))else:+ await asyncio.sleep(1)error = 'Invalid Credentials. Please try again.'login_page_content = files.read_file("webui/login.html")diff --git a/usr/agents/.gitkeep b/usr/agents/.gitkeepnew file mode 100644index 000000000..e69de29bbdiff --git a/usr/knowledge/.gitkeep b/usr/knowledge/.gitkeepnew file mode 100644index 000000000..e69de29bbdiff --git a/usr/knowledge/main/.gitkeep b/usr/knowledge/main/.gitkeepnew file mode 100644index 000000000..e69de29bbdiff --git a/usr/knowledge/solutions/.gitkeep b/usr/knowledge/solutions/.gitkeepnew file mode 100644index 000000000..e69de29bbdiff --git a/usr/workdir/.gitkeep b/usr/workdir/.gitkeepnew file mode 100644index 000000000..e69de29bbdiff --git a/webui/components/settings/agent/agent-settings.html b/webui/components/settings/agent/agent-settings.htmlindex cc7862ab0..7513831a8 100644--- a/webui/components/settings/agent/agent-settings.html+++ b/webui/components/settings/agent/agent-settings.html@@ -51,6 +51,12 @@<span>Speech</span></a></li>+ <li>+ <a href="#section-workdir">+ <img src="/public/folder.svg" alt="Workdir" />+ <span>Workdir</span>+ </a>+ </li></ul></nav>@@ -82,6 +88,13 @@<div id="section-speech" class="section"><x-component path="settings/agent/speech.html"></x-component></div>++ <div id="section-workdir" class="section">+ <x-component path="settings/agent/workdir.html"></x-component>+ </div>+++</div></template></div>diff --git a/webui/components/settings/agent/workdir-file-structure-test.html b/webui/components/settings/agent/workdir-file-structure-test.htmlnew file mode 100644index 000000000..b07f9220c--- /dev/null+++ b/webui/components/settings/agent/workdir-file-structure-test.html@@ -0,0 +1,23 @@+<html>+ <head>+ <title>Workdir structure test</title>++ <script type="module">+ import { store as settingsStore } from "/components/settings/settings-store.js";+ </script>+ </head>++ <body>+ <div x-data>+ <template x-if="$store.settings && $store.settings.settings">+ <div>+ <h3>Workdir structure test - <span x-text="$store.settings.settings.workdir_path"></span></h3>+ <pre x-text="$store.settings.workdirFileStructureTestOutput"></pre>+ </div>+ </template>+ </div>+ </body>++ <style>+ </style>+</html>diff --git a/webui/components/settings/agent/workdir.html b/webui/components/settings/agent/workdir.htmlnew file mode 100644index 000000000..d51fa9552--- /dev/null+++ b/webui/components/settings/agent/workdir.html@@ -0,0 +1,113 @@+<html>+ <head>+ <title>Working directory</title>++ <script type="module">+ import { store } from "/components/settings/settings-store.js";+ import { store as fileBrowserStore } from "/components/modals/file-browser/file-browser-store.js";+ </script>+ </head>++ <body>+ <div x-data>+ <template x-if="$store.settings?.settings">+ <div>+ <div class="section-title">Default working directory</div>+ <div class="section-description">+ When project is not selected, agent is instructed to use this directory as it's workplace. New terminal sessions will be spawned with this CWD.+ </div>++ <div class="field">+ <div class="field-label">+ <div class="field-title">Workdir path</div>+ <div class="field-description">Full path to the working directory inside the linux container. Default is /a0/usr/workdir.</div>+ </div>+ <div class="field-control">+ <input type="text" x-model="$store.settings.settings.workdir_path" />+ </div>+ </div>++ <div class="field">+ <div class="field-label">+ <div class="field-title">Show workdir structure to the agent</div>+ <div class="field-description">+ When turned on, the workdir file structure will be injected into the context window of the agent.+ </div>+ </div>+ <div class="field-control">+ <label class="toggle">+ <input type="checkbox" x-model="$store.settings.settings.workdir_show" />+ <span class="toggler"></span>+ </label>+ </div>+ </div>++ <template x-if="$store.settings.settings.workdir_show">+ <div>+ <div class="field">+ <div class="field-label">+ <div class="field-title">Max Depth</div>+ <div class="field-description">Set the maximum depth for the file structure (0 = unlimited).</div>+ </div>+ <div class="field-control">+ <input type="number" x-model.number="$store.settings.settings.workdir_max_depth" min="0" step="1" />+ </div>+ </div>++ <div class="field">+ <div class="field-label">+ <div class="field-title">Max Lines</div>+ <div class="field-description">Maximum total lines outputted for the agent (0 = unlimited).</div>+ </div>+ <div class="field-control">+ <input type="number" x-model.number="$store.settings.settings.workdir_max_lines" min="0" step="1" />+ </div>+ </div>++ <div class="field">+ <div class="field-label">+ <div class="field-title">Max Folders</div>+ <div class="field-description">Maximum number of subfolders to display under one folder (0 = unlimited).</div>+ </div>+ <div class="field-control">+ <input type="number" x-model.number="$store.settings.settings.workdir_max_folders" min="0" step="1" />+ </div>+ </div>++ <div class="field">+ <div class="field-label">+ <div class="field-title">Max Files</div>+ <div class="field-description">Maximum number of files to display under one folder (0 = unlimited).</div>+ </div>+ <div class="field-control">+ <input type="number" x-model.number="$store.settings.settings.workdir_max_files" min="0" step="1" />+ </div>+ </div>++ <div class="field field-full">+ <div class="field-label">+ <div class="field-title">Ignored files / folders</div>+ <div class="field-description">Specify patterns in gitignore format.</div>+ </div>+ <div class="field-control">+ <textarea x-model="$store.settings.settings.workdir_gitignore" rows="5" placeholder="Enter gitignore patterns (e.g., node_modules/, .git/, *.log)"></textarea>+ </div>+ </div>++ <div class="field">+ <div class="field-label">+ <div class="field-title">Test output</div>+ <div class="field-description">Preview the current workdir structure output.</div>+ </div>+ <div class="field-control">+ <button class="btn btn-field" @click="$store.settings.testWorkdirFileStructure()">Test output</button>+ <button class="btn btn-field" style="margin-left: 0.5em;" @click="$store.fileBrowser.open($store.settings.settings.workdir_path)">Browse</button>+ </div>+ </div>+ </div>+ </template>+ </div>+ </template>+ </div>+ </body>+</html>diff --git a/webui/components/settings/settings-store.js b/webui/components/settings/settings-store.jsindex 11b5e1635..9aa439ca7 100644--- a/webui/components/settings/settings-store.js+++ b/webui/components/settings/settings-store.js@@ -27,6 +27,7 @@ const model = {error: null,settings: null,additional: null,+ workdirFileStructureTestOutput: "",// Tab state_activeTab: DEFAULT_TAB,@@ -152,6 +153,25 @@ const model = {}},+ async testWorkdirFileStructure() {+ if (!this.settings) return;+ try {+ const response = await API.callJsonApi("settings_workdir_file_structure", {+ workdir_path: this.settings.workdir_path,+ workdir_max_depth: this.settings.workdir_max_depth,+ workdir_max_files: this.settings.workdir_max_files,+ workdir_max_folders: this.settings.workdir_max_folders,+ workdir_max_lines: this.settings.workdir_max_lines,+ workdir_gitignore: this.settings.workdir_gitignore,+ });+ this.workdirFileStructureTestOutput = response?.data || "";+ window.openModal("settings/agent/workdir-file-structure-test.html");+ } catch (e) {+ console.error("Error testing workdir file structure:", e);+ toast("Error testing workdir file structure", "error");+ }+ },+// Field helpers for external components// Handle button field clicks (opens sub-modals)async handleFieldButton(field) {diff --git a/webui/public/folder.svg b/webui/public/folder.svgindex e1315e8f9..8f4b9912c 100644--- a/webui/public/folder.svg+++ b/webui/public/folder.svg@@ -1 +1,7 @@-<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 23 16.3"><path d="M21.9 5.3h-.7V3.8c0-.6-.5-1.1-1.1-1.1h-8.9L9.9.7C9.6.2 9.3 0 8.8 0H3c-.6 0-1.1.5-1.1 1.2v4.2h-.8c-.3 0-.6.1-.9.4-.1.1-.2.5-.2.8l1 8.8c.1.6.6 1 1.1 1h18.6c.6 0 1.1-.4 1.1-1l1-8.8c0-.3-.1-.7-.3-.9 0-.3-.3-.4-.6-.4M2.8 1.1c0-.1.1-.1.2-.1h5.8c.1 0 .1 0 .2.1l1.4 2.3c.1.1.2.2.4.2H20c.1 0 .2.1.2.2v1.5H2.8zM21 15.2c0 .1-.1.1-.2.1H2.2c-.1 0-.2-.1-.2-.1L1 6.5v-.1l.1-.1h20.7c.1 0 .1 0 .1.1v.1z" style="fill:#a0a0a0"/></svg>\ No newline at end of file+<?xml version="1.0" encoding="UTF-8" standalone="no"?>+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">+<svg width="100%" height="100%" viewBox="0 0 23 17" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">+ <g transform="matrix(0.993712,0,0,0.982491,0.0736794,0.107034)">+ <path d="M21.9,5.3L21.2,5.3L21.2,3.8C21.2,3.2 20.7,2.7 20.1,2.7L11.2,2.7L9.9,0.7C9.6,0.2 9.3,0 8.8,0L3,0C2.4,0 1.9,0.5 1.9,1.2L1.9,5.4L1.1,5.4C0.8,5.4 0.5,5.5 0.2,5.8C0.1,5.9 -0,6.3 -0,6.6L1,15.4C1.1,16 1.6,16.4 2.1,16.4L20.7,16.4C21.3,16.4 21.8,16 21.8,15.4L22.647,6.598C22.647,6.298 22.733,5.777 22.561,5.567C22.367,5.33 22.2,5.3 21.9,5.3M2.487,0.716C2.487,0.616 2.587,0.616 2.687,0.616L8.8,0.623C8.9,0.623 8.9,0.623 9,0.723L10.41,3.107C10.51,3.207 10.61,3.307 10.81,3.307L20.452,3.307C20.552,3.307 20.652,3.407 20.652,3.507L20.643,5.3L2.487,5.293L2.487,0.716ZM21.339,15.663C21.339,15.763 21.239,15.763 21.139,15.763L1.888,15.821C1.788,15.821 1.688,15.721 1.688,15.721L0.662,6.176L0.662,6.076L0.762,5.976L22.114,5.918C22.214,5.918 22.214,5.918 22.214,6.018L22.214,6.118L21.339,15.663Z" style="fill:rgb(160,160,160);fill-rule:nonzero;"/>+ </g>+</svg>