The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(settings): choose the Files folder in Agent OS access
M3gA-Mind46a0f53259de
diff --git a/app/src/components/settings/panels/AgentAccessPanel.tsx b/app/src/components/settings/panels/AgentAccessPanel.tsxindex c46d012635..b158d67de6 100644--- a/app/src/components/settings/panels/AgentAccessPanel.tsx+++ b/app/src/components/settings/panels/AgentAccessPanel.tsx@@ -25,6 +25,7 @@ import {import { useSettingsNavigation } from '../hooks/useSettingsNavigation';import SettingsPanel from '../layout/SettingsPanel';import AutonomyRateLimitSection from './AutonomyPanel';+import FilesFolderSection from './FilesFolderSection';// Installs are always *available* but never silent: every `install_tool` call// is routed through the approval gate, so the user is asked to Approve/Deny@@ -336,6 +337,8 @@ const AgentAccessPanel = () => {{/* ── File system: where the agent may read and write ─────────── */}<Card title={t('settings.agentAccess.group.fileSystem')}>+ <FilesFolderSection />+<FieldhtmlFor="switch-workspace-only"label={t('settings.agentAccess.confine.label')}diff --git a/app/src/components/settings/panels/FilesFolderSection.tsx b/app/src/components/settings/panels/FilesFolderSection.tsxnew file mode 100644index 0000000000..85372ab381--- /dev/null+++ b/app/src/components/settings/panels/FilesFolderSection.tsx@@ -0,0 +1,132 @@+import { useEffect, useRef, useState } from 'react';++import { useT } from '../../../lib/i18n/I18nContext';+import {+ type AgentPaths,+ openhumanGetAgentPaths,+ openhumanUpdateAgentPaths,+} from '../../../utils/tauriCommands';+import { Button } from '../../ui';+import { SettingsStatusLine, SettingsTextField } from '../controls';++/**+ * "Files folder" row in Settings → Agent OS access (#5505): where the files+ * the agent delivers are saved. Defaults to `~/OpenHuman/projects/Files`; the+ * core validates any other choice. A change applies to new files only.+ */+const FilesFolderSection = () => {+ const { t } = useT();+ const [paths, setPaths] = useState<AgentPaths | null>(null);+ const [input, setInput] = useState('');+ const [saving, setSaving] = useState(false);+ const [error, setError] = useState<string | null>(null);+ const [savedNote, setSavedNote] = useState<string | null>(null);+ // Last write wins: a slow response must not overwrite a newer one.+ const seqRef = useRef(0);++ useEffect(() => {+ let cancelled = false;+ void (async () => {+ try {+ const resp = await openhumanGetAgentPaths();+ if (cancelled) return;+ setPaths(resp.result);+ setInput(resp.result.files_dir);+ } catch {+ if (!cancelled) setError(t('settings.agentAccess.filesFolder.loadError'));+ }+ })();+ return () => {+ cancelled = true;+ };+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, []);++ const save = async (value: string) => {+ const seq = ++seqRef.current;+ setSaving(true);+ setError(null);+ setSavedNote(null);+ try {+ const resp = await openhumanUpdateAgentPaths({ files_dir: value });+ if (seq !== seqRef.current) return;+ setPaths(resp.result);+ setInput(resp.result.files_dir);+ setSavedNote(t('settings.agentAccess.filesFolder.saved'));+ } catch (e) {+ if (seq !== seqRef.current) return;+ setError(e instanceof Error ? e.message : String(e));+ } finally {+ if (seq === seqRef.current) setSaving(false);+ }+ };++ const trimmed = input.trim();+ const unchanged = paths !== null && trimmed === paths.files_dir;++ return (+ <div data-testid="files-folder-section">+ <div className="px-4 pt-3">+ <div className="text-sm font-medium text-content">+ {t('settings.agentAccess.filesFolder.label')}+ </div>+ <p className="mt-0.5 text-xs leading-relaxed text-content-muted">+ {t('settings.agentAccess.filesFolder.desc')}+ </p>+ </div>+ <div className="flex items-center gap-2 px-4 pb-2 pt-2">+ <SettingsTextField+ mono+ className="flex-1"+ value={input}+ onChange={e => setInput(e.target.value)}+ placeholder={paths?.default_files_dir}+ aria-label={t('settings.agentAccess.filesFolder.label')}+ disabled={paths === null}+ onKeyDown={e => {+ if (e.key === 'Enter' && trimmed && !unchanged) {+ e.preventDefault();+ void save(trimmed);+ }+ }}+ inputSize="sm"+ data-testid="files-folder-input"+ />+ <Button+ type="button"+ variant="secondary"+ size="sm"+ onClick={() => void save(trimmed)}+ disabled={saving || !trimmed || unchanged}+ analyticsId="settings-files-folder-save"+ data-testid="files-folder-save">+ {t('settings.agentAccess.filesFolder.save')}+ </Button>+ {paths?.files_dir_source === 'override' && (+ <Button+ type="button"+ variant="tertiary"+ size="sm"+ onClick={() => void save('')}+ disabled={saving}+ analyticsId="settings-files-folder-reset"+ data-testid="files-folder-reset">+ {t('settings.agentAccess.filesFolder.reset')}+ </Button>+ )}+ </div>+ {(saving || savedNote || error) && (+ <div className="px-4 pb-3">+ <SettingsStatusLine+ saving={saving}+ savedNote={savedNote}+ error={error}+ savingLabel={t('settings.agentAccess.saving')}+ />+ </div>+ )}+ </div>+ );+};++export default FilesFolderSection;diff --git a/app/src/components/settings/panels/__tests__/AgentAccessPanel.defaults.test.tsx b/app/src/components/settings/panels/__tests__/AgentAccessPanel.defaults.test.tsxindex 0184cc88f4..0af0187b1f 100644--- a/app/src/components/settings/panels/__tests__/AgentAccessPanel.defaults.test.tsx+++ b/app/src/components/settings/panels/__tests__/AgentAccessPanel.defaults.test.tsx@@ -90,6 +90,20 @@ vi.mock('../../../../utils/tauriCommands', async () => {openhumanUpdateAutonomySettings: vi.fn(),openhumanGetAgentSettings: vi.fn(),openhumanUpdateAgentSettings: vi.fn(),+ // The "Files folder" row (#5505) reads the agent paths on mount.+ openhumanGetAgentPaths: vi.fn(async () => ({+ result: {+ action_dir: '/home/u/OpenHuman/projects',+ workspace_dir: '/home/u/.openhuman/users/u/workspace',+ projects_dir: '/home/u/OpenHuman/projects',+ action_dir_source: 'default',+ files_dir: '/home/u/OpenHuman/projects/Files',+ default_files_dir: '/home/u/OpenHuman/projects/Files',+ files_dir_source: 'default',+ },+ logs: [],+ })),+ openhumanUpdateAgentPaths: vi.fn(),};});diff --git a/app/src/components/settings/panels/__tests__/AgentAccessPanel.test.tsx b/app/src/components/settings/panels/__tests__/AgentAccessPanel.test.tsxindex 4dcfb8c438..3e03f04f75 100644--- a/app/src/components/settings/panels/__tests__/AgentAccessPanel.test.tsx+++ b/app/src/components/settings/panels/__tests__/AgentAccessPanel.test.tsx@@ -62,8 +62,20 @@ vi.mock('../../../../utils/tauriCommands', async () => {openhumanUpdateAutonomySettings: vi.fn(),openhumanGetAgentSettings: vi.fn(),openhumanUpdateAgentSettings: vi.fn(),- // The advanced panel no longer calls the agent-paths RPCs (action-dir- // moved to PermissionsPanel) — no mock needed, but keep the import clean.+ // The "Files folder" row (#5505) reads the agent paths on mount.+ openhumanGetAgentPaths: vi.fn(async () => ({+ result: {+ action_dir: '/home/u/OpenHuman/projects',+ workspace_dir: '/home/u/.openhuman/users/u/workspace',+ projects_dir: '/home/u/OpenHuman/projects',+ action_dir_source: 'default',+ files_dir: '/home/u/OpenHuman/projects/Files',+ default_files_dir: '/home/u/OpenHuman/projects/Files',+ files_dir_source: 'default',+ },+ logs: [],+ })),+ openhumanUpdateAgentPaths: vi.fn(),};});@@ -92,6 +104,7 @@ describe('AgentAccessPanel (advanced)', () => {expect(await screen.findByText('Confine to workspace')).toBeInTheDocument();expect(screen.getByText('Granted folders')).toBeInTheDocument();expect(screen.getByText('Always-allowed tools')).toBeInTheDocument();+ expect(screen.getByText('Files folder')).toBeInTheDocument();});it('toggling "confine to workspace" persists workspace_only', async () => {diff --git a/app/src/components/settings/panels/__tests__/FilesFolderSection.test.tsx b/app/src/components/settings/panels/__tests__/FilesFolderSection.test.tsxnew file mode 100644index 0000000000..f2fc6a5c3a--- /dev/null+++ b/app/src/components/settings/panels/__tests__/FilesFolderSection.test.tsx@@ -0,0 +1,116 @@+import { fireEvent, screen, waitFor } from '@testing-library/react';+import { beforeEach, describe, expect, it, vi } from 'vitest';++import { renderWithProviders } from '../../../../test/test-utils';+import {+ type AgentPaths,+ openhumanGetAgentPaths,+ openhumanUpdateAgentPaths,+} from '../../../../utils/tauriCommands';+import FilesFolderSection from '../FilesFolderSection';++vi.mock('../../../../utils/tauriCommands', async () => {+ const actual = await vi.importActual<typeof import('../../../../utils/tauriCommands')>(+ '../../../../utils/tauriCommands'+ );+ return { ...actual, openhumanGetAgentPaths: vi.fn(), openhumanUpdateAgentPaths: vi.fn() };+});++const DEFAULT = '/home/u/OpenHuman/projects/Files';++const paths = (overrides: Partial<AgentPaths> = {}): AgentPaths => ({+ action_dir: '/home/u/OpenHuman/projects',+ workspace_dir: '/home/u/.openhuman/users/u/workspace',+ projects_dir: '/home/u/OpenHuman/projects',+ action_dir_source: 'default',+ files_dir: DEFAULT,+ default_files_dir: DEFAULT,+ files_dir_source: 'default',+ ...overrides,+});++const mockGet = vi.mocked(openhumanGetAgentPaths);+const mockUpdate = vi.mocked(openhumanUpdateAgentPaths);++const input = () => screen.getByTestId('files-folder-input') as HTMLInputElement;++describe('FilesFolderSection', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ mockGet.mockResolvedValue({ result: paths(), logs: [] });+ });++ it('shows the folder the core reports', async () => {+ renderWithProviders(<FilesFolderSection />);+ await waitFor(() => expect(input().value).toBe(DEFAULT));+ expect(screen.getByText('Files folder')).toBeInTheDocument();+ // Nothing to save until the path changes, and no reset for the default.+ expect(screen.getByTestId('files-folder-save')).toBeDisabled();+ expect(screen.queryByTestId('files-folder-reset')).not.toBeInTheDocument();+ });++ it('saves a new folder and shows what the core stored', async () => {+ mockUpdate.mockResolvedValue({+ result: paths({ files_dir: '/data/Deliverables', files_dir_source: 'override' }),+ logs: [],+ });+ renderWithProviders(<FilesFolderSection />);+ await waitFor(() => expect(input().value).toBe(DEFAULT));++ fireEvent.change(input(), { target: { value: ' /data/Deliverables ' } });+ fireEvent.click(screen.getByTestId('files-folder-save'));++ await waitFor(() =>+ expect(mockUpdate).toHaveBeenCalledWith({ files_dir: '/data/Deliverables' })+ );+ expect(await screen.findByText('Files folder updated')).toBeInTheDocument();+ expect(input().value).toBe('/data/Deliverables');+ expect(screen.getByTestId('files-folder-reset')).toBeInTheDocument();+ });++ it('Enter saves too', async () => {+ mockUpdate.mockResolvedValue({ result: paths({ files_dir: '/data/F' }), logs: [] });+ renderWithProviders(<FilesFolderSection />);+ await waitFor(() => expect(input().value).toBe(DEFAULT));+ fireEvent.change(input(), { target: { value: '/data/F' } });+ fireEvent.keyDown(input(), { key: 'Enter' });+ await waitFor(() => expect(mockUpdate).toHaveBeenCalledWith({ files_dir: '/data/F' }));+ });++ it('"Use default" clears the override', async () => {+ mockGet.mockResolvedValue({+ result: paths({ files_dir: '/data/Mine', files_dir_source: 'override' }),+ logs: [],+ });+ mockUpdate.mockResolvedValue({ result: paths(), logs: [] });+ renderWithProviders(<FilesFolderSection />);++ fireEvent.click(await screen.findByTestId('files-folder-reset'));++ await waitFor(() => expect(mockUpdate).toHaveBeenCalledWith({ files_dir: '' }));+ await waitFor(() => expect(input().value).toBe(DEFAULT));+ expect(screen.queryByTestId('files-folder-reset')).not.toBeInTheDocument();+ });++ it("shows the core's reason when a folder is refused", async () => {+ mockUpdate.mockRejectedValue(+ new Error('files_dir must not be inside the OpenHuman data folder: /home/u/.openhuman/x')+ );+ renderWithProviders(<FilesFolderSection />);+ await waitFor(() => expect(input().value).toBe(DEFAULT));+ fireEvent.change(input(), { target: { value: '/home/u/.openhuman/x' } });+ fireEvent.click(screen.getByTestId('files-folder-save'));++ expect(+ await screen.findByText(/must not be inside the OpenHuman data folder/)+ ).toBeInTheDocument();+ expect(input().value).toBe('/home/u/.openhuman/x');+ });++ it('says so when the folder cannot be loaded', async () => {+ mockGet.mockRejectedValue(new Error('core down'));+ renderWithProviders(<FilesFolderSection />);+ expect(await screen.findByText('Could not load the files folder.')).toBeInTheDocument();+ expect(input()).toBeDisabled();+ });+});diff --git a/app/src/components/settings/panels/__tests__/PermissionsPanel.races.test.tsx b/app/src/components/settings/panels/__tests__/PermissionsPanel.races.test.tsxindex 8a50ef35df..9c64822351 100644--- a/app/src/components/settings/panels/__tests__/PermissionsPanel.races.test.tsx+++ b/app/src/components/settings/panels/__tests__/PermissionsPanel.races.test.tsx@@ -44,6 +44,9 @@ const agentPaths = (overrides: Partial<AgentPaths> = {}): AgentPaths => ({workspace_dir: '/home/test/.openhuman/users/u1/workspace',projects_dir: '/home/test/OpenHuman/projects',action_dir_source: 'default',+ files_dir: '/home/test/OpenHuman/projects/Files',+ default_files_dir: '/home/test/OpenHuman/projects/Files',+ files_dir_source: 'default',...overrides,});diff --git a/app/src/components/settings/panels/__tests__/PermissionsPanel.test.tsx b/app/src/components/settings/panels/__tests__/PermissionsPanel.test.tsxindex af250a043e..ff871b01e5 100644--- a/app/src/components/settings/panels/__tests__/PermissionsPanel.test.tsx+++ b/app/src/components/settings/panels/__tests__/PermissionsPanel.test.tsx@@ -30,6 +30,9 @@ const agentPaths = (overrides: Partial<AgentPaths> = {}): AgentPaths => ({workspace_dir: '/home/test/.openhuman/users/u1/workspace',projects_dir: '/home/test/OpenHuman/projects',action_dir_source: 'default',+ files_dir: '/home/test/OpenHuman/projects/Files',+ default_files_dir: '/home/test/OpenHuman/projects/Files',+ files_dir_source: 'default',...overrides,});diff --git a/app/src/lib/i18n/ar.ts b/app/src/lib/i18n/ar.tsindex cc1b9840b6..c035f18d42 100644--- a/app/src/lib/i18n/ar.ts+++ b/app/src/lib/i18n/ar.ts@@ -5319,6 +5319,13 @@ const messages: TranslationMap = {'settings.agentAccess.timeout.envOverride':'متغير البيئة OPENHUMAN_TOOL_TIMEOUT_SECS يتجاوز هذا الإعداد، لذا لن يكون للتغييرات هنا أي تأثير حتى يتم إلغاء ضبطه.','settings.agentAccess.grantedFolders': 'الملفات الممنوحة',+ 'settings.agentAccess.filesFolder.label': 'مجلد الملفات',+ 'settings.agentAccess.filesFolder.desc':+ 'المكان الذي تُحفظ فيه الملفات التي ينشئها الوكيل، مثل العروض التقديمية والمستندات والصور ومقاطع الفيديو. يسري التغيير على الملفات الجديدة؛ وتبقى الملفات الحالية في مكانها.',+ 'settings.agentAccess.filesFolder.save': 'حفظ',+ 'settings.agentAccess.filesFolder.reset': 'استخدام الافتراضي',+ 'settings.agentAccess.filesFolder.saved': 'تم تحديث مجلد الملفات',+ 'settings.agentAccess.filesFolder.loadError': 'تعذّر تحميل مجلد الملفات.','settings.agentAccess.alwaysAllow': 'الأدوات المتدنية دائما','settings.agentAccess.alwaysAllowDesc':'الأدوات التي وضعت علامة "الطرق تسمح" في الدردشة دون أن تسأل. أزيلي واحدة ليتم دفعها مجدداً',diff --git a/app/src/lib/i18n/bn.ts b/app/src/lib/i18n/bn.tsindex 65f73a906e..6ebe07ed72 100644--- a/app/src/lib/i18n/bn.ts+++ b/app/src/lib/i18n/bn.ts@@ -5437,6 +5437,13 @@ const messages: TranslationMap = {'settings.agentAccess.timeout.envOverride':'OPENHUMAN_TOOL_TIMEOUT_SECS এনভায়রনমেন্ট ভেরিয়েবলটি এই সেটিং ওভাররাইড করছে, তাই এটি আনসেট না করা পর্যন্ত এখানে পরিবর্তনের কোনো প্রভাব পড়বে না।','settings.agentAccess.grantedFolders': 'ফোল্ডার',+ 'settings.agentAccess.filesFolder.label': 'ফাইল ফোল্ডার',+ 'settings.agentAccess.filesFolder.desc':+ 'এজেন্ট যে ফাইলগুলো তৈরি করে, যেমন প্রেজেন্টেশন, ডকুমেন্ট, ছবি ও ভিডিও, সেগুলো এখানে সংরক্ষিত হয়। পরিবর্তন শুধু নতুন ফাইলে প্রযোজ্য; পুরোনো ফাইল যেখানে আছে সেখানেই থাকে।',+ 'settings.agentAccess.filesFolder.save': 'সংরক্ষণ করুন',+ 'settings.agentAccess.filesFolder.reset': 'ডিফল্ট ব্যবহার করুন',+ 'settings.agentAccess.filesFolder.saved': 'ফাইল ফোল্ডার আপডেট হয়েছে',+ 'settings.agentAccess.filesFolder.loadError': 'ফাইল ফোল্ডার লোড করা যায়নি।','settings.agentAccess.alwaysAllow': 'সর্বদা অপসারণযোগ্য সরঞ্জাম','settings.agentAccess.alwaysAllowDesc':'জিজ্ঞাসা না করে আলাপনের ক্ষেত্রে "সর্বদা" প্রয়োগ করা হবে। পুনরায় লেখার জন্য একটি ফোল্ডার মুছে ফেলা হবে।',diff --git a/app/src/lib/i18n/de.ts b/app/src/lib/i18n/de.tsindex 1d1dbf216b..332a9a4e99 100644--- a/app/src/lib/i18n/de.ts+++ b/app/src/lib/i18n/de.ts@@ -5575,6 +5575,13 @@ const messages: TranslationMap = {'settings.agentAccess.timeout.envOverride':'Die Umgebungsvariable OPENHUMAN_TOOL_TIMEOUT_SECS überschreibt diese Einstellung, daher haben Änderungen hier keine Wirkung, bis sie entfernt wird.','settings.agentAccess.grantedFolders': 'Erteilte Ordner',+ 'settings.agentAccess.filesFolder.label': 'Dateiordner',+ 'settings.agentAccess.filesFolder.desc':+ 'Hier speichert der Agent die Dateien, die er erstellt, etwa Präsentationen, Dokumente, Bilder und Videos. Eine Änderung gilt für neue Dateien; vorhandene Dateien bleiben, wo sie sind.',+ 'settings.agentAccess.filesFolder.save': 'Speichern',+ 'settings.agentAccess.filesFolder.reset': 'Standard verwenden',+ 'settings.agentAccess.filesFolder.saved': 'Dateiordner aktualisiert',+ 'settings.agentAccess.filesFolder.loadError': 'Der Dateiordner konnte nicht geladen werden.','settings.agentAccess.alwaysAllow': 'Immer erlaubte Werkzeuge','settings.agentAccess.alwaysAllowDesc':'Tools, die Sie im Chatlauf ohne zu fragen als "Immer zulassen" markiert haben. Entfernen Sie eine, um erneut aufgefordert zu werden.',diff --git a/app/src/lib/i18n/en.ts b/app/src/lib/i18n/en.tsindex a7d6adf14a..f5f3345316 100644--- a/app/src/lib/i18n/en.ts+++ b/app/src/lib/i18n/en.ts@@ -6234,6 +6234,13 @@ const en: TranslationMap = {'settings.agentAccess.group.fileSystem': 'File system','settings.agentAccess.group.limits': 'Limits','settings.agentAccess.grantedFolders': 'Granted folders',+ 'settings.agentAccess.filesFolder.label': 'Files folder',+ 'settings.agentAccess.filesFolder.desc':+ 'Where the files the agent makes, like decks, documents, images and videos, are saved. A change applies to new files; existing files stay where they are.',+ 'settings.agentAccess.filesFolder.save': 'Save',+ 'settings.agentAccess.filesFolder.reset': 'Use default',+ 'settings.agentAccess.filesFolder.saved': 'Files folder updated',+ 'settings.agentAccess.filesFolder.loadError': 'Could not load the files folder.','settings.agentAccess.alwaysAllow': 'Always-allowed tools','settings.agentAccess.alwaysAllowDesc':'Tools you marked "Always allow" in chat run without asking. Remove one to be prompted again.',diff --git a/app/src/lib/i18n/es.ts b/app/src/lib/i18n/es.tsindex a64c38bd7d..c9fafcaab3 100644--- a/app/src/lib/i18n/es.ts+++ b/app/src/lib/i18n/es.ts@@ -5530,6 +5530,13 @@ const messages: TranslationMap = {'settings.agentAccess.timeout.envOverride':'La variable de entorno OPENHUMAN_TOOL_TIMEOUT_SECS está anulando este ajuste, por lo que los cambios aquí no tendrán efecto hasta que se elimine.','settings.agentAccess.grantedFolders': 'Carpetas concedidas',+ 'settings.agentAccess.filesFolder.label': 'Carpeta de archivos',+ 'settings.agentAccess.filesFolder.desc':+ 'Dónde se guardan los archivos que crea el agente, como presentaciones, documentos, imágenes y vídeos. El cambio se aplica a los archivos nuevos; los existentes se quedan donde están.',+ 'settings.agentAccess.filesFolder.save': 'Guardar',+ 'settings.agentAccess.filesFolder.reset': 'Usar la predeterminada',+ 'settings.agentAccess.filesFolder.saved': 'Carpeta de archivos actualizada',+ 'settings.agentAccess.filesFolder.loadError': 'No se pudo cargar la carpeta de archivos.','settings.agentAccess.alwaysAllow': 'Herramientas siempre permitidas','settings.agentAccess.alwaysAllowDesc':'Las herramientas que marcaste como "Permitir siempre" en el chat se ejecutan sin pedir permiso. Elimina una para que se te pregunte nuevamente.',diff --git a/app/src/lib/i18n/fr.ts b/app/src/lib/i18n/fr.tsindex 7cdfcf417f..9ef463b0a1 100644--- a/app/src/lib/i18n/fr.ts+++ b/app/src/lib/i18n/fr.ts@@ -5555,6 +5555,13 @@ const messages: TranslationMap = {'settings.agentAccess.timeout.envOverride':"La variable d'environnement OPENHUMAN_TOOL_TIMEOUT_SECS remplace ce paramètre ; les modifications effectuées ici n'auront donc aucun effet tant qu'elle n'est pas supprimée.",'settings.agentAccess.grantedFolders': 'Dossiers accordés',+ 'settings.agentAccess.filesFolder.label': 'Dossier des fichiers',+ 'settings.agentAccess.filesFolder.desc':+ 'Emplacement où sont enregistrés les fichiers créés par l’agent, comme les présentations, documents, images et vidéos. Une modification s’applique aux nouveaux fichiers ; les fichiers existants restent où ils sont.',+ 'settings.agentAccess.filesFolder.save': 'Enregistrer',+ 'settings.agentAccess.filesFolder.reset': 'Utiliser le dossier par défaut',+ 'settings.agentAccess.filesFolder.saved': 'Dossier des fichiers mis à jour',+ 'settings.agentAccess.filesFolder.loadError': 'Impossible de charger le dossier des fichiers.','settings.agentAccess.alwaysAllow': 'Outils toujours autorisés','settings.agentAccess.alwaysAllowDesc':"Les outils que vous avez marqués « Toujours autoriser » dans le chat s'exécutent sans demander. Supprimez-en un pour être invité à nouveau.",diff --git a/app/src/lib/i18n/hi.ts b/app/src/lib/i18n/hi.tsindex bb7e44b254..02e437b217 100644--- a/app/src/lib/i18n/hi.ts+++ b/app/src/lib/i18n/hi.ts@@ -5440,6 +5440,13 @@ const messages: TranslationMap = {'settings.agentAccess.timeout.envOverride':'OPENHUMAN_TOOL_TIMEOUT_SECS एनवायरनमेंट वेरिएबल इस सेटिंग को ओवरराइड कर रहा है, इसलिए जब तक इसे अनसेट नहीं किया जाता, यहाँ किए गए बदलावों का कोई असर नहीं होगा।','settings.agentAccess.grantedFolders': 'स्वीकृत फ़ोल्डर',+ 'settings.agentAccess.filesFolder.label': 'फ़ाइल फ़ोल्डर',+ 'settings.agentAccess.filesFolder.desc':+ 'एजेंट जो फ़ाइलें बनाता है, जैसे प्रेज़ेंटेशन, दस्तावेज़, चित्र और वीडियो, वे यहाँ सहेजी जाती हैं। बदलाव नई फ़ाइलों पर लागू होता है; मौजूदा फ़ाइलें जहाँ हैं वहीं रहती हैं।',+ 'settings.agentAccess.filesFolder.save': 'सहेजें',+ 'settings.agentAccess.filesFolder.reset': 'डिफ़ॉल्ट उपयोग करें',+ 'settings.agentAccess.filesFolder.saved': 'फ़ाइल फ़ोल्डर अपडेट हो गया',+ 'settings.agentAccess.filesFolder.loadError': 'फ़ाइल फ़ोल्डर लोड नहीं हो सका।','settings.agentAccess.alwaysAllow': 'हमेशा की अनुमति उपकरण','settings.agentAccess.alwaysAllowDesc':'उपकरण जिन्हें आपने बिना पूछे चैट रन में "अलवे अनुमति" चिह्नित किया। एक बार फिर से शुरू करने के लिए।',diff --git a/app/src/lib/i18n/id.ts b/app/src/lib/i18n/id.tsindex 0c4f70bb2a..faee0f800e 100644--- a/app/src/lib/i18n/id.ts+++ b/app/src/lib/i18n/id.ts@@ -5471,6 +5471,13 @@ const messages: TranslationMap = {'settings.agentAccess.timeout.envOverride':'Variabel lingkungan OPENHUMAN_TOOL_TIMEOUT_SECS menggantikan pengaturan ini, sehingga perubahan di sini tidak berpengaruh hingga variabel tersebut dihapus.','settings.agentAccess.grantedFolders': 'Folder yang diberikan',+ 'settings.agentAccess.filesFolder.label': 'Folder file',+ 'settings.agentAccess.filesFolder.desc':+ 'Tempat menyimpan file yang dibuat agen, seperti presentasi, dokumen, gambar, dan video. Perubahan berlaku untuk file baru; file yang sudah ada tetap di tempatnya.',+ 'settings.agentAccess.filesFolder.save': 'Simpan',+ 'settings.agentAccess.filesFolder.reset': 'Gunakan bawaan',+ 'settings.agentAccess.filesFolder.saved': 'Folder file diperbarui',+ 'settings.agentAccess.filesFolder.loadError': 'Folder file tidak dapat dimuat.','settings.agentAccess.alwaysAllow': 'Selalu-diperbolehkan alat','settings.agentAccess.alwaysAllowDesc':'Perkakas yang Anda tandai "Always allow" dalam run percakapan tanpa bertanya. Hapus satu yang akan diminta lagi.',diff --git a/app/src/lib/i18n/it.ts b/app/src/lib/i18n/it.tsindex c4e701f134..66ce4c1e6c 100644--- a/app/src/lib/i18n/it.ts+++ b/app/src/lib/i18n/it.ts@@ -5521,6 +5521,13 @@ const messages: TranslationMap = {'settings.agentAccess.timeout.envOverride':"La variabile d'ambiente OPENHUMAN_TOOL_TIMEOUT_SECS sta sovrascrivendo questa impostazione, quindi le modifiche qui non avranno effetto finché non viene rimossa.",'settings.agentAccess.grantedFolders': 'Cartelle concesse',+ 'settings.agentAccess.filesFolder.label': 'Cartella dei file',+ 'settings.agentAccess.filesFolder.desc':+ 'Dove vengono salvati i file creati dall’agente, come presentazioni, documenti, immagini e video. La modifica vale per i nuovi file; quelli esistenti restano dove sono.',+ 'settings.agentAccess.filesFolder.save': 'Salva',+ 'settings.agentAccess.filesFolder.reset': 'Usa quella predefinita',+ 'settings.agentAccess.filesFolder.saved': 'Cartella dei file aggiornata',+ 'settings.agentAccess.filesFolder.loadError': 'Impossibile caricare la cartella dei file.','settings.agentAccess.alwaysAllow': 'Strumenti sempre consentiti','settings.agentAccess.alwaysAllowDesc':'Gli strumenti che hai contrassegnato come "Consenti sempre" in chat funzionano senza chiedere. Rimuovine uno per ricevere nuovamente la richiesta.',diff --git a/app/src/lib/i18n/ko.ts b/app/src/lib/i18n/ko.tsindex c6c1cf5065..7032211f4a 100644--- a/app/src/lib/i18n/ko.ts+++ b/app/src/lib/i18n/ko.ts@@ -5379,6 +5379,13 @@ const messages: TranslationMap = {'settings.agentAccess.timeout.envOverride':'OPENHUMAN_TOOL_TIMEOUT_SECS 환경 변수가 이 설정을 재정의하고 있으므로, 해당 변수를 해제하기 전까지 여기서의 변경 사항은 적용되지 않습니다.','settings.agentAccess.grantedFolders': '허용된 폴더',+ 'settings.agentAccess.filesFolder.label': '파일 폴더',+ 'settings.agentAccess.filesFolder.desc':+ '에이전트가 만드는 프레젠테이션, 문서, 이미지, 동영상 같은 파일이 저장되는 위치입니다. 변경 사항은 새 파일에 적용되며, 기존 파일은 그대로 유지됩니다.',+ 'settings.agentAccess.filesFolder.save': '저장',+ 'settings.agentAccess.filesFolder.reset': '기본값 사용',+ 'settings.agentAccess.filesFolder.saved': '파일 폴더가 업데이트되었습니다',+ 'settings.agentAccess.filesFolder.loadError': '파일 폴더를 불러올 수 없습니다.','settings.agentAccess.alwaysAllow': '항상 허용된 도구','settings.agentAccess.alwaysAllowDesc':'채팅에서 "항상 허용"으로 표시한 도구는 확인 없이 실행됩니다. 다시 확인을 받으려면 항목을 제거하세요.',diff --git a/app/src/lib/i18n/pl.ts b/app/src/lib/i18n/pl.tsindex 50a76f59fc..993b4adbe0 100644--- a/app/src/lib/i18n/pl.ts+++ b/app/src/lib/i18n/pl.ts@@ -5515,6 +5515,13 @@ const messages: TranslationMap = {'settings.agentAccess.timeout.envOverride':'Zmienna środowiskowa OPENHUMAN_TOOL_TIMEOUT_SECS zastępuje to ustawienie, więc zmiany tutaj nie odniosą skutku, dopóki nie zostanie ona usunięta.','settings.agentAccess.grantedFolders': 'Przyznane foldery',+ 'settings.agentAccess.filesFolder.label': 'Folder plików',+ 'settings.agentAccess.filesFolder.desc':+ 'Miejsce, w którym zapisywane są pliki tworzone przez agenta, takie jak prezentacje, dokumenty, obrazy i filmy. Zmiana dotyczy nowych plików; istniejące pliki pozostają na miejscu.',+ 'settings.agentAccess.filesFolder.save': 'Zapisz',+ 'settings.agentAccess.filesFolder.reset': 'Użyj domyślnego',+ 'settings.agentAccess.filesFolder.saved': 'Zaktualizowano folder plików',+ 'settings.agentAccess.filesFolder.loadError': 'Nie udało się wczytać folderu plików.','settings.agentAccess.alwaysAllow': 'Zawsze dozwolone narzędzia','settings.agentAccess.alwaysAllowDesc':'Narzędzia oznaczone w czacie jako „Zawsze zezwalaj” działają bez pytania. Usuń narzędzie, aby znów wymagało potwierdzenia.',diff --git a/app/src/lib/i18n/pt.ts b/app/src/lib/i18n/pt.tsindex dbdf26d5b8..9693ecd9b8 100644--- a/app/src/lib/i18n/pt.ts+++ b/app/src/lib/i18n/pt.ts@@ -5515,6 +5515,13 @@ const messages: TranslationMap = {'settings.agentAccess.timeout.envOverride':'A variável de ambiente OPENHUMAN_TOOL_TIMEOUT_SECS está substituindo esta configuração, portanto as alterações aqui não terão efeito até que ela seja removida.','settings.agentAccess.grantedFolders': 'Pastas concedidas',+ 'settings.agentAccess.filesFolder.label': 'Pasta de arquivos',+ 'settings.agentAccess.filesFolder.desc':+ 'Onde são salvos os arquivos que o agente cria, como apresentações, documentos, imagens e vídeos. A alteração vale para arquivos novos; os existentes permanecem onde estão.',+ 'settings.agentAccess.filesFolder.save': 'Salvar',+ 'settings.agentAccess.filesFolder.reset': 'Usar a padrão',+ 'settings.agentAccess.filesFolder.saved': 'Pasta de arquivos atualizada',+ 'settings.agentAccess.filesFolder.loadError': 'Não foi possível carregar a pasta de arquivos.','settings.agentAccess.alwaysAllow': 'Ferramentas sempre permitidas','settings.agentAccess.alwaysAllowDesc':'As ferramentas que você marcou como "Sempre permitir" no chat funcionam sem perguntar. Remova uma para ser solicitado novamente.',diff --git a/app/src/lib/i18n/ru.ts b/app/src/lib/i18n/ru.tsindex cfad8fe259..93f335038b 100644--- a/app/src/lib/i18n/ru.ts+++ b/app/src/lib/i18n/ru.ts@@ -5486,6 +5486,13 @@ const messages: TranslationMap = {'settings.agentAccess.timeout.envOverride':'Переменная окружения OPENHUMAN_TOOL_TIMEOUT_SECS переопределяет эту настройку, поэтому изменения здесь не вступят в силу, пока она не будет сброшена.','settings.agentAccess.grantedFolders': 'Предоставленные папки',+ 'settings.agentAccess.filesFolder.label': 'Папка файлов',+ 'settings.agentAccess.filesFolder.desc':+ 'Куда сохраняются файлы, которые создаёт агент: презентации, документы, изображения и видео. Изменение применяется к новым файлам; существующие остаются на месте.',+ 'settings.agentAccess.filesFolder.save': 'Сохранить',+ 'settings.agentAccess.filesFolder.reset': 'Использовать по умолчанию',+ 'settings.agentAccess.filesFolder.saved': 'Папка файлов обновлена',+ 'settings.agentAccess.filesFolder.loadError': 'Не удалось загрузить папку файлов.','settings.agentAccess.alwaysAllow': 'Всегда разрешенные инструменты','settings.agentAccess.alwaysAllowDesc':'Инструменты, которые вы отметили в чате как «Всегда разрешать», запускаются без запроса. Удалите один, чтобы запрос появился снова.',diff --git a/app/src/lib/i18n/zh-CN.ts b/app/src/lib/i18n/zh-CN.tsindex 0e9e075f94..6230a81d8b 100644--- a/app/src/lib/i18n/zh-CN.ts+++ b/app/src/lib/i18n/zh-CN.ts@@ -5151,6 +5151,13 @@ const messages: TranslationMap = {'settings.agentAccess.timeout.envOverride':'环境变量 OPENHUMAN_TOOL_TIMEOUT_SECS 正在覆盖此设置,因此在取消该变量之前,此处的更改不会生效。','settings.agentAccess.grantedFolders': '已授权文件夹',+ 'settings.agentAccess.filesFolder.label': '文件保存文件夹',+ 'settings.agentAccess.filesFolder.desc':+ '智能体生成的文件(如演示文稿、文档、图片和视频)保存在这里。更改仅对新文件生效;现有文件保持原位。',+ 'settings.agentAccess.filesFolder.save': '保存',+ 'settings.agentAccess.filesFolder.reset': '使用默认文件夹',+ 'settings.agentAccess.filesFolder.saved': '文件保存文件夹已更新',+ 'settings.agentAccess.filesFolder.loadError': '无法加载文件保存文件夹。','settings.agentAccess.alwaysAllow': '始终允许的工具','settings.agentAccess.alwaysAllowDesc':'你在聊天中标记为“始终允许”的工具会直接运行且不再询问。移除后会重新提示。',diff --git a/app/src/utils/tauriCommands/config.ts b/app/src/utils/tauriCommands/config.tsindex 1ca01321d8..7aec7ebbce 100644--- a/app/src/utils/tauriCommands/config.ts+++ b/app/src/utils/tauriCommands/config.ts@@ -513,12 +513,18 @@ export async function openhumanGetAutonomySettings(): Promise<CommandResponse<Au* - `action_dir_source` — where the effective `action_dir` came from:* `'env'` (pinned by OPENHUMAN_ACTION_DIR — UI must disable editing),* `'override'` (a persisted user choice), or `'default'`.+ * - `files_dir` — the visible folder agent deliverables are written to+ * (#5505); `default_files_dir` is `~/OpenHuman/projects/Files`, and+ * `files_dir_source` says whether the user chose another one.*/export interface AgentPaths {action_dir: string;workspace_dir: string;projects_dir: string;action_dir_source: 'env' | 'override' | 'default';+ files_dir: string;+ default_files_dir: string;+ files_dir_source: 'override' | 'default';}export async function openhumanGetAgentPaths(): Promise<CommandResponse<AgentPaths>> {@@ -527,9 +533,14 @@ export async function openhumanGetAgentPaths(): Promise<CommandResponse<AgentPat});}-/** Partial update for the agent's editable filesystem roots (issue #3240). */+/**+ * Partial update for the agent's editable filesystem roots (#3240, #5505).+ * An empty string reverts a field to its default; an omitted field is left+ * unchanged.+ */export interface AgentPathsUpdate {action_dir?: string;+ files_dir?: string;}export async function openhumanUpdateAgentPaths(diff --git a/crates/openhuman-core/src/agent/artifacts/ops.rs b/crates/openhuman-core/src/agent/artifacts/ops.rsindex a329a0c9ad..e7cd90ab28 100644--- a/crates/openhuman-core/src/agent/artifacts/ops.rs+++ b/crates/openhuman-core/src/agent/artifacts/ops.rs@@ -206,7 +206,7 @@ async fn regenerate_presentation());let tool = PresentationTool::with_config(config.workspace_dir.clone(),- crate::config::default_files_dir(),+ config.files_dir(),security,config.clone(),);diff --git a/crates/openhuman-core/src/config/mod.rs b/crates/openhuman-core/src/config/mod.rsindex 39e29a1820..56b7ddff9a 100644--- a/crates/openhuman-core/src/config/mod.rs+++ b/crates/openhuman-core/src/config/mod.rs@@ -31,7 +31,7 @@ pub use schema::{active_workspace_dir_cached, active_workspace_snapshot, clear_active_user, default_action_dir,default_files_dir, default_projects_dir, default_root_openhuman_dir, is_legacy_tier_model,legacy_tier_role, pre_login_user_dir, read_active_user_id, resolve_action_dir,- user_openhuman_dir, write_active_user_id, PRE_LOGIN_USER_ID, WORKLOAD_ROLES,+ resolve_files_dir, user_openhuman_dir, write_active_user_id, PRE_LOGIN_USER_ID, WORKLOAD_ROLES,};pub use workspace_handle::workspace_handle;// Crate-internal: workspace→config-dir resolver reused by the cloud embedder.diff --git a/crates/openhuman-core/src/config/ops/agent.rs b/crates/openhuman-core/src/config/ops/agent.rsindex 777a812b1b..a250cd0466 100644--- a/crates/openhuman-core/src/config/ops/agent.rs+++ b/crates/openhuman-core/src/config/ops/agent.rs@@ -59,13 +59,16 @@ pub struct AgentSettingsPatch {/// Partial update for the agent's editable filesystem roots.///-/// Only `action_dir` is editable today (issue #3240). `workspace_dir` and-/// `projects_dir` are intentionally read-only and not part of this patch.+/// `action_dir` (issue #3240) and the files folder (#5505) are editable.+/// `workspace_dir` and `projects_dir` are intentionally read-only.#[derive(Debug, Clone, Default)]pub struct AgentPathsPatch {/// New action sandbox root. `Some("")`/whitespace clears the override and/// reverts to the default; `Some(path)` sets it; `None` leaves it unchanged.pub action_dir: Option<String>,+ /// New folder for agent deliverables. Same `Some("")` / `Some(path)` /+ /// `None` semantics as `action_dir`. Affects new artifacts only.+ pub files_dir: Option<String>,}/// Patch for the global memory-sync cadence (#3302).@@ -405,7 +408,7 @@ pub async fn ensure_agent_dirs(config: &mut Config) {// Agent deliverables are written to the visible files folder (#5505).// Create it up front, and move this account's pre-#5505 artifact files out// of the hidden workspace (idempotent; a no-op once migrated).- let files_dir = crate::config::default_files_dir();+ let files_dir = config.files_dir();if let Err(e) = tokio::fs::create_dir_all(&files_dir).await {tracing::warn!(dir = %redact_home(&files_dir),@@ -468,9 +471,75 @@ fn agent_paths_payload(config: &Config) -> serde_json::Value {"workspace_dir": config.workspace_dir.display().to_string(),"projects_dir": projects_dir.display().to_string(),"action_dir_source": action_dir_source(config),+ "files_dir": config.files_dir().display().to_string(),+ "default_files_dir": crate::config::default_files_dir().display().to_string(),+ "files_dir_source": if config.files_dir_override.is_some() { "override" } else { "default" },})}+/// Validate a user-chosen files folder (#5505) and create it. Fail-closed:+/// the path must be absolute, not an existing file, not a protected location+/// (credential stores, OS directories), and not inside the OpenHuman data+/// directory — the point of the folder is that the user can see it, and the+/// data dir holds internal state.+async fn validate_files_dir(raw: &str, config: &Config) -> Result<PathBuf, String> {+ let expanded = expand_tilde(raw);+ let candidate = PathBuf::from(&expanded);+ if !candidate.is_absolute() {+ return Err(format!(+ "files_dir must be an absolute path (got '{expanded}')"+ ));+ }+ if candidate.is_file() {+ return Err(format!(+ "files_dir must be a folder, not a file: {expanded}"+ ));+ }+ if crate::security::SecurityPolicy::is_always_forbidden(&candidate) {+ return Err(format!(+ "files_dir cannot be a protected system or credential folder: {expanded}"+ ));+ }+ let mut internal = vec![config.workspace_dir.clone()];+ if let Ok(root) = crate::config::default_root_openhuman_dir() {+ internal.push(root);+ }+ if internal.iter().any(|dir| path_within(&candidate, dir)) {+ return Err(format!(+ "files_dir must not be inside the OpenHuman data folder: {expanded}"+ ));+ }+ tokio::fs::create_dir_all(&candidate)+ .await+ .map_err(|e| format!("failed to create files_dir {expanded}: {e}"))?;+ Ok(candidate)+}++/// `path` equals or sits under `dir`, comparing canonical forms so a+/// symlinked spelling (e.g. macOS `/var` → `/private/var`) cannot slip into+/// the data dir. A path that does not exist yet is canonicalized through its+/// nearest existing ancestor.+fn path_within(path: &Path, dir: &Path) -> bool {+ canonical_prefix(path).starts_with(canonical_prefix(dir))+}++fn canonical_prefix(path: &Path) -> PathBuf {+ let mut rest = Vec::new();+ let mut cursor = path;+ loop {+ if let Ok(canon) = cursor.canonicalize() {+ return rest.iter().rev().fold(canon, |acc, part| acc.join(part));+ }+ match (cursor.parent(), cursor.file_name()) {+ (Some(parent), Some(name)) => {+ rest.push(name.to_os_string());+ cursor = parent;+ }+ _ => return path.to_path_buf(),+ }+ }+}+/// Applies an edit to the agent's `action_dir` sandbox root.////// Validation (fail-closed): the path is trimmed and `~`-expanded; it must be@@ -551,6 +620,28 @@ pub async fn apply_agent_paths_settings();}+ if let Some(raw) = update.files_dir {+ let trimmed = raw.trim();+ log::debug!(+ "[config][agent_paths] apply files_dir edit (input_len={})",+ trimmed.len()+ );+ if trimmed.is_empty() {+ config.files_dir_override = None;+ notes.push("files_dir override cleared (reverted to default)".to_string());+ } else {+ let candidate = validate_files_dir(trimmed, config).await?;+ notes.push(format!("files_dir set to {}", candidate.display()));+ config.files_dir_override = Some(candidate);+ }+ config.save().await.map_err(|e| e.to_string())?;+ crate::core::bus::BUS.publish(crate::core::events::DomainEvent::AgentPathsChanged);+ log::debug!(+ "[config][agent_paths] files_dir now '{}'",+ config.files_dir().display()+ );+ }+Ok(Outcome::new(agent_paths_payload(config), notes))}diff --git a/crates/openhuman-core/src/config/ops_agent_paths_tests.rs b/crates/openhuman-core/src/config/ops_agent_paths_tests.rsindex 80b29ed619..6f47f7b427 100644--- a/crates/openhuman-core/src/config/ops_agent_paths_tests.rs+++ b/crates/openhuman-core/src/config/ops_agent_paths_tests.rs@@ -141,6 +141,7 @@ async fn apply_agent_paths_valid_abs_path_persists_override_and_recomputes() {&mut cfg,AgentPathsPatch {action_dir: Some(new_dir.to_string_lossy().to_string()),+ files_dir: None,},).await@@ -171,6 +172,7 @@ async fn apply_agent_paths_rejects_relative_path() {&mut cfg,AgentPathsPatch {action_dir: Some("relative/projects".into()),+ files_dir: None,},).await@@ -194,6 +196,7 @@ async fn apply_agent_paths_rejects_action_dir_equal_to_workspace() {&mut cfg,AgentPathsPatch {action_dir: Some(workspace.to_string_lossy().to_string()),+ files_dir: None,},).await@@ -220,6 +223,7 @@ async fn apply_agent_paths_empty_input_clears_override() {&mut cfg,AgentPathsPatch {action_dir: Some(" ".into()),+ files_dir: None,},).await@@ -249,6 +253,7 @@ async fn apply_agent_paths_auto_creates_missing_directory() {&mut cfg,AgentPathsPatch {action_dir: Some(missing.to_string_lossy().to_string()),+ files_dir: None,},).await@@ -273,6 +278,7 @@ async fn apply_agent_paths_rejects_existing_file() {&mut cfg,AgentPathsPatch {action_dir: Some(file.to_string_lossy().to_string()),+ files_dir: None,},).await@@ -302,6 +308,7 @@ async fn apply_agent_paths_env_set_reports_source_env() {&mut cfg,AgentPathsPatch {action_dir: Some(user_dir.to_string_lossy().to_string()),+ files_dir: None,},).awaitdiff --git a/crates/openhuman-core/src/config/ops_files_dir_tests.rs b/crates/openhuman-core/src/config/ops_files_dir_tests.rsnew file mode 100644index 0000000000..9290166745--- /dev/null+++ b/crates/openhuman-core/src/config/ops_files_dir_tests.rs@@ -0,0 +1,165 @@+//! The files folder setting (#5505): where agent deliverables are written.++use super::*;++fn patch(files_dir: &str) -> AgentPathsPatch {+ AgentPathsPatch {+ action_dir: None,+ files_dir: Some(files_dir.to_string()),+ }+}++#[tokio::test]+async fn setting_the_files_folder_persists_it_and_creates_it() {+ let tmp = tempdir().unwrap();+ let mut cfg = tmp_config(&tmp);+ let chosen = tmp.path().join("Deliverables");++ let outcome = apply_agent_paths_settings(&mut cfg, patch(&chosen.to_string_lossy()))+ .await+ .expect("apply files_dir");++ assert!(chosen.is_dir(), "a missing folder is created");+ assert_eq!(cfg.files_dir_override.as_deref(), Some(chosen.as_path()));+ assert_eq!(cfg.files_dir(), chosen);+ assert_eq!(+ outcome.value["files_dir"],+ serde_json::json!(chosen.display().to_string())+ );+ assert_eq!(+ outcome.value["files_dir_source"],+ serde_json::json!("override")+ );+ let saved = std::fs::read_to_string(&cfg.config_path).expect("config saved");+ assert!(saved.contains("files_dir_override"), "{saved}");+}++#[tokio::test]+async fn an_empty_value_reverts_to_the_default_folder() {+ let tmp = tempdir().unwrap();+ let mut cfg = tmp_config(&tmp);+ cfg.files_dir_override = Some(tmp.path().join("Old"));++ let outcome = apply_agent_paths_settings(&mut cfg, patch(" "))+ .await+ .expect("clear files_dir");++ assert!(cfg.files_dir_override.is_none());+ assert_eq!(cfg.files_dir(), crate::config::default_files_dir());+ assert_eq!(+ outcome.value["files_dir_source"],+ serde_json::json!("default")+ );+ assert_eq!(+ outcome.value["default_files_dir"],+ serde_json::json!(crate::config::default_files_dir().display().to_string())+ );+}++async fn rejected(cfg: &mut Config, value: &str) -> String {+ let before = cfg.files_dir_override.clone();+ let err = apply_agent_paths_settings(cfg, patch(value))+ .await+ .expect_err("files_dir must be rejected");+ assert_eq!(+ cfg.files_dir_override, before,+ "a rejected value is not stored"+ );+ err+}++#[tokio::test]+async fn a_relative_path_is_rejected() {+ let tmp = tempdir().unwrap();+ let mut cfg = tmp_config(&tmp);+ let err = rejected(&mut cfg, "relative/Files").await;+ assert!(err.contains("absolute"), "{err}");+}++#[tokio::test]+async fn a_file_is_rejected() {+ let tmp = tempdir().unwrap();+ let mut cfg = tmp_config(&tmp);+ let file = tmp.path().join("not-a-folder.txt");+ std::fs::write(&file, b"x").unwrap();+ let err = rejected(&mut cfg, &file.to_string_lossy()).await;+ assert!(err.contains("not a file"), "{err}");+}++#[tokio::test]+async fn a_folder_inside_the_openhuman_data_folder_is_rejected() {+ let tmp = tempdir().unwrap();+ let mut cfg = tmp_config(&tmp);+ let inside = cfg.workspace_dir.join("Files");+ let err = rejected(&mut cfg, &inside.to_string_lossy()).await;+ assert!(err.contains("OpenHuman data folder"), "{err}");+ assert!(!inside.exists(), "nothing is created for a rejected value");+}++#[tokio::test]+async fn a_credential_folder_is_rejected() {+ let tmp = tempdir().unwrap();+ let mut cfg = tmp_config(&tmp);+ let ssh = tmp.path().join(".ssh").join("Files");+ let err = rejected(&mut cfg, &ssh.to_string_lossy()).await;+ assert!(err.contains("protected"), "{err}");+}++#[test]+fn a_relative_override_on_disk_falls_back_to_the_default() {+ let cfg = Config {+ files_dir_override: Some(PathBuf::from("relative")),+ ..Config::default()+ };+ assert_eq!(cfg.files_dir(), crate::config::default_files_dir());+}++/// The boot migration moves legacy files into the folder the user chose, not+/// the default one.+#[tokio::test]+async fn boot_migrates_legacy_files_into_the_chosen_folder() {+ use crate::agent::artifacts::store::save_artifact_meta;+ use crate::agent::artifacts::{ArtifactKind, ArtifactMeta, ArtifactStatus};++ let _g = ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner());+ let tmp = tempdir().unwrap();+ let prev_projects_dir = std::env::var_os("OPENHUMAN_PROJECTS_DIR");+ unsafe {+ std::env::set_var("OPENHUMAN_PROJECTS_DIR", tmp.path().join("projects-home"));+ }++ let mut cfg = tmp_config(&tmp);+ cfg.action_dir = tmp.path().join("action");+ let chosen = tmp.path().join("Chosen");+ cfg.files_dir_override = Some(chosen.clone());+ let meta = ArtifactMeta {+ id: "legacy".to_string(),+ kind: ArtifactKind::Document,+ title: "Plan".to_string(),+ path: "legacy/plan.docx".to_string(),+ file: None,+ file_root: None,+ size_bytes: 4,+ status: ArtifactStatus::Ready,+ created_at: chrono::Utc::now(),+ error: None,+ thread_id: None,+ tool_call_id: None,+ };+ save_artifact_meta(&cfg.workspace_dir, &meta).await.unwrap();+ std::fs::write(+ cfg.workspace_dir.join("artifacts/legacy/plan.docx"),+ b"plan",+ )+ .unwrap();++ crate::config::ensure_agent_dirs(&mut cfg).await;++ unsafe {+ match prev_projects_dir {+ Some(v) => std::env::set_var("OPENHUMAN_PROJECTS_DIR", v),+ None => std::env::remove_var("OPENHUMAN_PROJECTS_DIR"),+ }+ }+ assert_eq!(std::fs::read(chosen.join("plan.docx")).unwrap(), b"plan");+}diff --git a/crates/openhuman-core/src/config/ops_tests.rs b/crates/openhuman-core/src/config/ops_tests.rsindex d0ac24f025..b2b1ae446f 100644--- a/crates/openhuman-core/src/config/ops_tests.rs+++ b/crates/openhuman-core/src/config/ops_tests.rs@@ -17,6 +17,8 @@ fn tmp_config(tmp: &tempfile::TempDir) -> Config {#[path = "ops_agent_paths_tests.rs"]mod agent_paths_tests;+#[path = "ops_files_dir_tests.rs"]+mod files_dir_tests;#[path = "ops_loader_and_search_tests.rs"]mod loader_and_search_tests;#[path = "ops_model_and_local_ai_tests.rs"]diff --git a/crates/openhuman-core/src/config/schema/load/dirs.rs b/crates/openhuman-core/src/config/schema/load/dirs.rsindex 7249a2e0a9..25eed92e79 100644--- a/crates/openhuman-core/src/config/schema/load/dirs.rs+++ b/crates/openhuman-core/src/config/schema/load/dirs.rs@@ -102,6 +102,21 @@ pub fn default_files_dir() -> PathBuf {default_projects_dir().join(FILES_DIRNAME)}+/// Resolve the effective files folder: the persisted override when it is a+/// non-empty absolute path, else [`default_files_dir`].+pub fn resolve_files_dir(files_dir_override: &Option<PathBuf>) -> PathBuf {+ match files_dir_override {+ Some(dir) if dir.is_absolute() => dir.clone(),+ Some(_) => {+ tracing::warn!(+ "[config] ignoring invalid files_dir_override; expected an absolute path"+ );+ default_files_dir()+ }+ None => default_files_dir(),+ }+}+/// The `OPENHUMAN_ACTION_DIR` env override, when set to a non-empty value.////// Returns `None` when the variable is unset or blank (a common shape fromdiff --git a/crates/openhuman-core/src/config/schema/load/mod.rs b/crates/openhuman-core/src/config/schema/load/mod.rsindex a2fe7fd6a4..5822bd4b5c 100644--- a/crates/openhuman-core/src/config/schema/load/mod.rs+++ b/crates/openhuman-core/src/config/schema/load/mod.rs@@ -14,7 +14,8 @@ pub use dirs::{action_dir_env_override, active_user_marker_path, active_workspace_dir,active_workspace_snapshot, clear_active_user, default_action_dir, default_files_dir,default_projects_dir, default_root_openhuman_dir, pre_login_user_dir, read_active_user_id,- resolve_action_dir, user_openhuman_dir, write_active_user_id, PRE_LOGIN_USER_ID,+ resolve_action_dir, resolve_files_dir, user_openhuman_dir, write_active_user_id,+ PRE_LOGIN_USER_ID,};// redact_url_for_log is pub(super) for the schema module; tests inside loaddiff --git a/crates/openhuman-core/src/config/schema/mod.rs b/crates/openhuman-core/src/config/schema/mod.rsindex 48b6a84aa3..80a98a9701 100644--- a/crates/openhuman-core/src/config/schema/mod.rs+++ b/crates/openhuman-core/src/config/schema/mod.rs@@ -36,8 +36,8 @@ pub use load::{action_dir_env_override, active_user_marker_path, active_workspace_dir,active_workspace_dir_cached, active_workspace_snapshot, clear_active_user, default_action_dir,default_files_dir, default_projects_dir, default_root_openhuman_dir, pre_login_user_dir,- read_active_user_id, resolve_action_dir, user_openhuman_dir, write_active_user_id,- PRE_LOGIN_USER_ID,+ read_active_user_id, resolve_action_dir, resolve_files_dir, user_openhuman_dir,+ write_active_user_id, PRE_LOGIN_USER_ID,};// Crate-internal: the invalidation half of the cached active workspace. The// marker writers in `load_user_state` call it from outside `load`; thediff --git a/crates/openhuman-core/src/config/schema/types/config.rs b/crates/openhuman-core/src/config/schema/types/config.rsindex 67e791a84f..004f8be3a4 100644--- a/crates/openhuman-core/src/config/schema/types/config.rs+++ b/crates/openhuman-core/src/config/schema/types/config.rs@@ -73,6 +73,13 @@ pub struct Config {/// overrides at runtime so existing env-driven deployments are unaffected.#[serde(default)]pub action_dir_override: Option<PathBuf>,+ /// Persisted user choice for the folder agent deliverables are written to,+ /// set via Settings → Agent OS access (`config.update_agent_paths`,+ /// #5505). `None` means the default, `~/OpenHuman/projects/Files`. Read it+ /// through [`Self::files_dir`]. Changing it affects new artifacts only;+ /// existing ones keep the folder recorded in their metadata.+ #[serde(default)]+ pub files_dir_override: Option<PathBuf>,#[serde(skip)]pub config_path: PathBuf,/// Per-load snapshot used to remove standalone CLI inference overridesdiff --git a/crates/openhuman-core/src/config/schema/types/defaults.rs b/crates/openhuman-core/src/config/schema/types/defaults.rsindex 871d37ff98..116d072871 100644--- a/crates/openhuman-core/src/config/schema/types/defaults.rs+++ b/crates/openhuman-core/src/config/schema/types/defaults.rs@@ -28,6 +28,7 @@ impl Default for Config {workspace_dir: openhuman_dir.join("workspace"),action_dir: crate::config::default_action_dir(),action_dir_override: None,+ files_dir_override: None,config_path: openhuman_dir.join("config.toml"),cli_inference_snapshot: None,recovered_from_corruption: false,diff --git a/crates/openhuman-core/src/config/schema/types/resolvers.rs b/crates/openhuman-core/src/config/schema/types/resolvers.rsindex d2c4299207..be48710185 100644--- a/crates/openhuman-core/src/config/schema/types/resolvers.rs+++ b/crates/openhuman-core/src/config/schema/types/resolvers.rs@@ -7,6 +7,13 @@ use super::output_language::output_language_directive;use crate::config::schema::Config;impl Config {+ /// The folder agent deliverables are written to (#5505): the Settings+ /// override when set, else `~/OpenHuman/projects/Files`. Every producer+ /// and the boot migration read it through here.+ pub fn files_dir(&self) -> PathBuf {+ crate::config::resolve_files_dir(&self.files_dir_override)+ }+/// Resolve the root directory where chunk `.md` files are stored.////// Resolution order:diff --git a/crates/openhuman-core/src/config/schemas/controllers/workspace.rs b/crates/openhuman-core/src/config/schemas/controllers/workspace.rsindex e5e8b69f57..f6be4a882b 100644--- a/crates/openhuman-core/src/config/schemas/controllers/workspace.rs+++ b/crates/openhuman-core/src/config/schemas/controllers/workspace.rs@@ -145,6 +145,7 @@ pub(super) fn handle_update_agent_paths(params: Map<String, Value>) -> Controlle};let patch = config_rpc::AgentPathsPatch {action_dir: update.action_dir,+ files_dir: update.files_dir,};match config_rpc::load_and_apply_agent_paths_settings(patch).await {Ok(outcome) => {diff --git a/crates/openhuman-core/src/config/schemas/helpers.rs b/crates/openhuman-core/src/config/schemas/helpers.rsindex 71b9cadff5..de9d34fab0 100644--- a/crates/openhuman-core/src/config/schemas/helpers.rs+++ b/crates/openhuman-core/src/config/schemas/helpers.rs@@ -237,6 +237,10 @@ pub(super) struct AgentPathsUpdate {/// New absolute action sandbox path. Empty string clears the override;/// omitted leaves it unchanged. Validated server-side.pub(super) action_dir: Option<String>,+ /// New absolute folder for agent deliverables (#5505). Empty string+ /// clears the override; omitted leaves it unchanged.+ #[serde(default)]+ pub(super) files_dir: Option<String>,}#[derive(Debug, Deserialize)]diff --git a/crates/openhuman-core/src/config/schemas/schema_defs/workspace.rs b/crates/openhuman-core/src/config/schemas/schema_defs/workspace.rsindex 69bcfa3dee..0ee42b5668 100644--- a/crates/openhuman-core/src/config/schemas/schema_defs/workspace.rs+++ b/crates/openhuman-core/src/config/schemas/schema_defs/workspace.rs@@ -119,23 +119,28 @@ pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {inputs: vec![],outputs: vec![json_output("paths",- "Resolved agent paths: action_dir (acting-tool CWD), workspace_dir (internal state, agent-blocked), projects_dir (default projects home), action_dir_source (env | override | default).",+ "Resolved agent paths: action_dir (acting-tool CWD), workspace_dir (internal state, agent-blocked), projects_dir (default projects home), action_dir_source (env | override | default), files_dir (where agent deliverables are written), default_files_dir, files_dir_source (override | default).",)],}),"update_agent_paths" => Some( ControllerSchema {namespace: "config",function: "update_agent_paths",description:- "Update the agent's editable filesystem roots. Currently only action_dir (the acting-tool sandbox). The path must be absolute; a missing directory is auto-created; it cannot equal the internal workspace_dir. An empty string clears the override and reverts to the default. Applies to new sessions immediately (live policy hot-swap), no restart. OPENHUMAN_ACTION_DIR still overrides at runtime when set.",+ "Update the agent's editable filesystem roots: action_dir (the acting-tool sandbox) and files_dir (the folder agent deliverables are written to; new artifacts only, and it may not sit inside the OpenHuman data folder). The path must be absolute; a missing directory is auto-created; it cannot equal the internal workspace_dir. An empty string clears the override and reverts to the default. Applies to new sessions immediately (live policy hot-swap), no restart. OPENHUMAN_ACTION_DIR still overrides at runtime when set.",inputs: vec![FieldSchema {name: "action_dir",ty: TypeSchema::Option(Box::new(TypeSchema::String)),comment: "New absolute action sandbox path. Empty string clears the override (revert to default). Omit to leave unchanged.",required: false,+ }, FieldSchema {+ name: "files_dir",+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),+ comment: "New absolute folder for agent deliverables. Empty string clears the override (revert to ~/OpenHuman/projects/Files). Omit to leave unchanged.",+ required: false,}],outputs: vec![json_output("paths",- "Updated agent paths (same shape as get_agent_paths): action_dir, workspace_dir, projects_dir, action_dir_source.",+ "Updated agent paths (same shape as get_agent_paths): action_dir, workspace_dir, projects_dir, action_dir_source, files_dir, default_files_dir, files_dir_source.",)],}),"get_onboarding_completed" => Some( ControllerSchema {diff --git a/crates/openhuman-core/src/media/generation/tools.rs b/crates/openhuman-core/src/media/generation/tools.rsindex a9e0a6a968..aeb8a779f6 100644--- a/crates/openhuman-core/src/media/generation/tools.rs+++ b/crates/openhuman-core/src/media/generation/tools.rs@@ -54,7 +54,7 @@ pub fn build_media_tools(root_config: &Config, action_dir: &Path) -> Vec<Box<dyngenerators,action_dir,&root_config.workspace_dir,- &crate::config::default_files_dir(),+ &root_config.files_dir(),WaitPolicy::new(VIDEO_POLL_INTERVAL, VIDEO_WAIT_BUDGET),)}diff --git a/crates/openhuman-core/src/tools/impl/document/mod.rs b/crates/openhuman-core/src/tools/impl/document/mod.rsindex 374fbcb178..67a7c9e9a4 100644--- a/crates/openhuman-core/src/tools/impl/document/mod.rs+++ b/crates/openhuman-core/src/tools/impl/document/mod.rs@@ -99,7 +99,7 @@ impl DocumentTool {pub fn for_config(config: &crate::config::Config, security: Arc<SecurityPolicy>) -> Self {Self::new(config.workspace_dir.clone(),- crate::config::default_files_dir(),+ config.files_dir(),security,)}diff --git a/crates/openhuman-core/src/tools/impl/presentation/mod.rs b/crates/openhuman-core/src/tools/impl/presentation/mod.rsindex 702c30ebcb..feb4b3c1eb 100644--- a/crates/openhuman-core/src/tools/impl/presentation/mod.rs+++ b/crates/openhuman-core/src/tools/impl/presentation/mod.rs@@ -100,7 +100,7 @@ impl PresentationTool {pub fn for_config(config: &crate::config::Config, security: Arc<SecurityPolicy>) -> Self {Self::new(config.workspace_dir.clone(),- crate::config::default_files_dir(),+ config.files_dir(),security,)}diff --git a/crates/openhuman-core/src/tools/ops_tests_default_registry_tests.rs b/crates/openhuman-core/src/tools/ops_tests_default_registry_tests.rsindex 9376f13805..ddbe6d7965 100644--- a/crates/openhuman-core/src/tools/ops_tests_default_registry_tests.rs+++ b/crates/openhuman-core/src/tools/ops_tests_default_registry_tests.rs@@ -743,3 +743,53 @@ fn all_tools_excludes_browser_when_disabled() {assert!(names.contains(&"pushover"));assert!(names.contains(&"proxy_config"));}++/// #5505: the producers write into the folder chosen in Settings, not a+/// hard-coded default. Generation itself needs the tinydocs module, which a+/// unit test does not have, but the artifact is reserved in the files folder+/// before generation runs, so its record names the folder either way.+#[cfg(feature = "documents")]+#[tokio::test]+async fn document_tool_writes_into_the_configured_files_folder() {+ let tmp = TempDir::new().unwrap();+ let security = Arc::new(SecurityPolicy::default());+ let browser = BrowserConfig {+ enabled: false,+ ..BrowserConfig::default()+ };+ let http = crate::config::HttpRequestConfig::default();+ let mut cfg = test_config(&tmp);+ let chosen = tmp.path().join("Chosen");+ cfg.files_dir_override = Some(chosen.clone());+ let tools = all_tools(+ Arc::new(Config::default()),+ &security,+ AuditLogger::disabled(),+ &browser,+ &http,+ tmp.path(),+ &HashMap::new(),+ &cfg,+ );+ let tool = tools+ .iter()+ .find(|t| t.name() == "generate_document")+ .expect("generate_document registered");++ let _ = tool+ .execute(serde_json::json!({+ "title": "Charter",+ "sections": [{ "heading": "Overview", "paragraphs": ["In brief."] }]+ }))+ .await;++ let (artifacts, _) =+ crate::agent::artifacts::store::list_artifacts(&cfg.workspace_dir, 0, 10, None)+ .await+ .expect("list artifacts");+ assert_eq!(artifacts.len(), 1, "{artifacts:?}");+ assert_eq!(+ artifacts[0].file_root.as_deref(),+ Some(chosen.to_string_lossy().as_ref())+ );+}