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
docs(artifacts): refresh stale docs; test save_artifact_as
Sanilf7535e94ab4c
diff --git a/AGENTS.md b/AGENTS.mdindex 0045848578..329f5f2d40 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -548,6 +548,7 @@ Direct rendered submodules under `vendor/`:| Submodule | Owns || --- | --- |+| `tiny-artifacts` | Versioned artifacts as a plain library (no bus contract): the record and version model, the `Artifacts` service and its rules (content fits the kind, file paths stay inside the host's `FileRoots` and pass its guard, revisions append, kept version files, publishing), the agent artifact tools, and the file-system store. OpenHuman owns the ports: the document-backed store, the card UI bridge, the protected-path guard and the cloud-storage publisher (`agent/artifacts/`). || `tinyagents` | Provider-neutral agent harness and durable typed state graph: model/tool loop, tool-call dialects and parsing, middleware, retries, caching, sessions/transcripts, and graph execution. || `tinybox` | Isolated execution environments for code the host does not trust; box lifecycle and isolation backends. || `tinybus` | TinyBus runtime and module contracts: discovery/loading, ABI and manifest admission, transport, proxies, lifecycle, and module bus behavior. |diff --git a/app/src/services/artifactDownloadService.ts b/app/src/services/artifactDownloadService.tsindex 31b080d120..078ad9fd04 100644--- a/app/src/services/artifactDownloadService.ts+++ b/app/src/services/artifactDownloadService.ts@@ -1,20 +1,17 @@/*** Artifact export service (#2779).*- * All paths first resolve the artifact's meta via the+ * Every path first resolves the artifact's meta via the* `openhuman.ai_get_artifact` core RPC (which also reports a file moved or- * deleted outside OpenHuman), then hand the artifact id + filename hint to- * the `download_artifact_to_downloads` Tauri command. The shell resolves the- * id through the core's artifact store itself — it never trusts a- * renderer-supplied path (#5505) — copies into the user's Downloads directory- * with a non-colliding name, and returns the dest path so the UI can offer- * "Reveal in Finder".+ * deleted outside OpenHuman), then hands the artifact id + filename hint to a+ * Tauri command. The shell resolves the id through the core's artifact store+ * itself — it never trusts a renderer-supplied path (#5505).*- * {@link saveArtifactViaDialog} is kept as the name its callers use, but- * the native Save-As dialog behind it was removed with the shell's `rfd`- * dependency — it now delegates to {@link downloadArtifact}, which was- * already its fallback on any host without an xdg-desktop portal. Callers- * may still branch on `'CANCELLED'`; nothing produces it any more.+ * - {@link saveArtifactViaDialog}: the OS save dialog (`save_artifact_as`);+ * the user picks the destination. A closed dialog is `'CANCELLED'`.+ * - {@link downloadArtifact}: a copy into the user's Downloads directory with+ * a non-colliding name (`download_artifact_to_downloads`), so the UI can+ * offer "Reveal in Finder".** No-ops outside Tauri (browser dev preview) — export only makes sense in* the desktop shell.diff --git a/crates/openhuman-app/permissions/README.md b/crates/openhuman-app/permissions/README.mdindex ddfc6d5ac5..c6592829fa 100644--- a/crates/openhuman-app/permissions/README.md+++ b/crates/openhuman-app/permissions/README.md@@ -35,7 +35,6 @@ RuntimeAuthority::resolve_access| [`allow-app-update.toml`](allow-app-update.toml) | `allow-app-update` | `check_app_update`, `apply_app_update`, `download_app_update`, `install_app_update`. || [`allow-workspace-files.toml`](allow-workspace-files.toml) | `allow-workspace-files` | `open_workspace_path`, `reveal_workspace_path`, `preview_workspace_text`. || [`allow-artifact-download.toml`](allow-artifact-download.toml) | `allow-artifact-download` | `download_artifact_to_downloads`, `save_artifact_as`. |-| `allow-artifact-save.toml` | `allow-artifact-save` | `save_artifact_via_dialog`. || [`allow-directory-picker.toml`](allow-directory-picker.toml) | `allow-directory-picker` | `pick_directory_via_dialog`. || [`allow-loopback-oauth.toml`](allow-loopback-oauth.toml) | `allow-loopback-oauth` | `start_loopback_oauth_listener`, `stop_loopback_oauth_listener`. Kept separate so a consumer of `allow-core-process` does not also get OAuth listener control. |@@ -61,7 +60,6 @@ Registered commands that no permission lists, so the webview cannot call them:`process_diagnostics_list_owned`, `overlay_parent_rpc_url`.Listed commands that are no longer registered, which are harmless but stale:-`save_artifact_via_dialog` (the whole `allow-artifact-save` set),`service_install_direct`, `service_start_direct`, `service_stop_direct`,`service_status_direct`, `service_uninstall_direct`,`register_companion_hotkey`, `unregister_companion_hotkey`,diff --git a/crates/openhuman-app/src/artifact_commands.rs b/crates/openhuman-app/src/artifact_commands.rsindex f25f467b3b..95a52bf8da 100644--- a/crates/openhuman-app/src/artifact_commands.rs+++ b/crates/openhuman-app/src/artifact_commands.rs@@ -1,20 +1,14 @@//! Tauri commands for exporting agent-generated artifacts (#2779).//!-//! One export path, fed by an artifact id:-//! [`download_artifact_to_downloads`] resolves the id through the core's-//! artifact store, copies the file into the user's Downloads directory with a-//! non-colliding name, and returns the dest path so the UI can offer "Reveal in-//! Finder". Cross-platform.+//! Two export paths, both fed by an artifact id://!-//! **The native Save-As dialog (#3162) was removed.** It was one call into-//! `rfd`, and `rfd` carried 13 packages — the xdg-desktop-portal client-//! (`ashpd`), `zbus`, and the `async-io`/`polling` executor stack — into a-//! binary that already reaches D-Bus through other paths. The frontend's-//! `saveArtifactViaDialog` had a Downloads fallback for hosts with no-//! portal from the day it landed, so that fallback is simply the only path-//! now; the user still gets the file plus "Reveal in Finder", one dialog-//! fewer. If a real Save-As is wanted again, prefer the destination-picking-//! surface Tauri itself already links over re-adding a second dialog stack.+//! - [`save_artifact_as`] asks the user where to save it (the OS save dialog,+//! through the `rfd` the shell links for the directory chooser) and copies+//! the file there. The preview panel's Download uses it, through the+//! frontend's `saveArtifactViaDialog`.+//! - [`download_artifact_to_downloads`] copies the file into the user's+//! Downloads directory with a non-colliding name and returns the dest path,+//! so the UI can offer "Reveal in Finder". Cross-platform.//!//! The renderer names an artifact, never a path (#5505). Artifact files now//! live in a visible, user-configurable folder rather than under the data@@ -62,19 +56,44 @@ pub async fn save_artifact_as() -> Result<Option<String>, String> {let config = openhuman_rpc::embed::config::load_host_config().await?;let roots = openhuman_rpc::embed::artifacts::FileRoots::from_config(&config);- let source = resolve_source(&config.workspace_dir, &roots, &artifact_id).await?;- let sanitized = sanitize_filename(&filename)?;+ save_to_chosen_path(+ &config.workspace_dir,+ &roots,+ &artifact_id,+ &filename,+ |name| async move {+ // macOS: NSSavePanel. Windows: IFileSaveDialog. Linux: the GTK chooser.+ rfd::AsyncFileDialog::new()+ .set_file_name(&name)+ .save_file()+ .await+ .map(|handle| handle.path().to_path_buf())+ },+ )+ .await+}- // macOS: NSSavePanel. Windows: IFileSaveDialog. Linux: the GTK chooser.- let Some(handle) = rfd::AsyncFileDialog::new()- .set_file_name(&sanitized)- .save_file()- .await- else {+/// [`save_artifact_as`] with the destination chooser passed in, so the checks+/// run without a dialog: the id must resolve to a file the artifact store+/// vouches for and the filename must be a plain name, both before `choose` is+/// asked. `choose` gets the sanitized name and returns `None` on cancel.+async fn save_to_chosen_path<F, Fut>(+ workspace_dir: &Path,+ roots: &openhuman_rpc::embed::artifacts::FileRoots,+ artifact_id: &str,+ filename: &str,+ choose: F,+) -> Result<Option<String>, String>+where+ F: FnOnce(String) -> Fut,+ Fut: std::future::Future<Output = Option<PathBuf>>,+{+ let source = resolve_source(workspace_dir, roots, artifact_id).await?;+ let sanitized = sanitize_filename(filename)?;+ let Some(dest) = choose(sanitized).await else {log::debug!("[artifact_commands] save_artifact_as cancelled by user");return Ok(None);};- let dest = handle.path().to_path_buf();let bytes = copy_to_path(&source, &dest).await?;// The chosen path carries the user's login and folder names; it is not// logged (see `directory_picker`).diff --git a/crates/openhuman-app/src/artifact_commands_tests.rs b/crates/openhuman-app/src/artifact_commands_tests.rsindex 91ef35954b..9771aacb45 100644--- a/crates/openhuman-app/src/artifact_commands_tests.rs+++ b/crates/openhuman-app/src/artifact_commands_tests.rs@@ -243,3 +243,58 @@ async fn download_rejects_invalid_inputs() {.is_err());}++#[tokio::test]+async fn save_as_refuses_before_the_dialog_opens() {+ let temp = tempfile::tempdir().unwrap();+ let files_dir = temp.path().join("Files");+ let id = ready_artifact(temp.path(), &files_dir).await;+ let roots = FileRoots::new(&files_dir);+ let never = |_: String| async { panic!("the dialog must not open") };++ for (bad_id, filename) in [+ ("", "Deck.pptx"),+ (" ", "Deck.pptx"),+ ("no-such-id", "Deck.pptx"),+ ] {+ assert!(+ save_to_chosen_path(temp.path(), &roots, bad_id, filename, never)+ .await+ .is_err(),+ "id {bad_id:?} must be refused"+ );+ }+ for bad_name in ["../escape.pptx", "a/b.pptx", ""] {+ assert!(+ save_to_chosen_path(temp.path(), &roots, &id, bad_name, never)+ .await+ .is_err(),+ "filename {bad_name:?} must be refused"+ );+ }+}++#[tokio::test]+async fn save_as_copies_to_the_chosen_path_and_reports_a_cancel() {+ let temp = tempfile::tempdir().unwrap();+ let files_dir = temp.path().join("Files");+ let id = ready_artifact(temp.path(), &files_dir).await;+ let roots = FileRoots::new(&files_dir);++ let cancelled = save_to_chosen_path(temp.path(), &roots, &id, "Deck.pptx", |_| async { None })+ .await+ .unwrap();+ assert_eq!(cancelled, None);++ let dest = temp.path().join("chosen").join("Deck.pptx");+ std::fs::create_dir_all(dest.parent().unwrap()).unwrap();+ let chosen = dest.clone();+ let saved = save_to_chosen_path(temp.path(), &roots, &id, "Deck.pptx", |name| async move {+ assert_eq!(name, "Deck.pptx");+ Some(chosen)+ })+ .await+ .unwrap();+ assert_eq!(saved.as_deref(), Some(dest.display().to_string().as_str()));+ assert_eq!(std::fs::read(&dest).unwrap(), b"deck");+}diff --git a/crates/openhuman-app/src/lib.rs b/crates/openhuman-app/src/lib.rsindex 620c716b81..17168f0449 100644--- a/crates/openhuman-app/src/lib.rs+++ b/crates/openhuman-app/src/lib.rs@@ -66,8 +66,8 @@ const _: () = assert!(const _: &str = openhuman_rpc::embed::modules::browser::MODULE_ID;mod app_update;-// Artifact export command (#2779) — cross-platform Downloads copy. The `rfd`-// Save-As dialog that used to sit in front of it was removed with the crate.+// Artifact export commands (#2779): the OS save dialog (`save_artifact_as`)+// and the cross-platform Downloads copy.mod artifact_commands;mod claude_code;mod core_process;@@ -3302,8 +3302,8 @@ pub fn run() {process_diagnostics_list_owned,// Artifact export — cross-platform. Previously macOS/Linux-gated,// but the `directories` + `tokio::fs::copy` flow compiles on Windows- // too (CodeRabbit on #4127). The Save-As dialog that used to sit in- // front of this went with the shell's `rfd` dependency.+ // too (CodeRabbit on #4127). `save_artifact_as` puts the OS save+ // dialog in front of the copy.artifact_commands::download_artifact_to_downloads,artifact_commands::save_artifact_as,// Native directory chooser for the folder memory-source (#5831).diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.mdindex 1b3bc7ee12..a04b5dbec0 100644--- a/docs/TEST-COVERAGE-MATRIX.md+++ b/docs/TEST-COVERAGE-MATRIX.md@@ -271,7 +271,7 @@ End-to-end coverage of the agent harness via the web-chat RPC surface against an| 6.1.1 | File Read Access | RU+WD | `vendor/tinyagents/vendor/tinytools/crates/tinytools-std/src/filesystem/file_read/mod.rs`, `app/test/e2e/specs/tool-filesystem-flow.spec.ts` | ✅ | Was 🟡 — WDIO drives memory_read_file + asserts via Node fs. Byte `offset` paging (continues a paged artifact read, #6284): `file_read/test.rs::file_read_offset_continues_from_the_given_byte` (tinytools-std) || 6.1.2 | File Write Access | RU+WD | `vendor/tinyagents/vendor/tinytools/crates/tinytools-std/src/filesystem/file_write/mod.rs`, `app/test/e2e/specs/tool-filesystem-flow.spec.ts` | ✅ | Was 🟡 — WDIO drives memory_write_file + asserts bytes match on disk || 6.1.3 | Path Restriction Enforcement | RU+WD | `crates/openhuman-core/src/tools/impl/filesystem/gate_tests.rs`, `app/test/e2e/specs/tool-filesystem-flow.spec.ts` | ✅ | Was 🟡 — WDIO asserts traversal + absolute-path denial envelope |-| 6.1.4 | Agent deliverables in the visible Files folder | RU+VU | `crates/openhuman-core/src/agent/artifacts/files_tests.rs`, `crates/openhuman-core/src/agent/artifacts/migrate_tests.rs`, `crates/openhuman-core/src/agent/artifacts/ops_tests.rs`, `crates/openhuman-app/src/artifact_commands_tests.rs`, `app/src/services/__tests__/artifactDownloadService.test.ts`, `crates/openhuman-core/src/config/ops_files_dir_tests.rs`, `app/src/components/settings/panels/__tests__/FilesFolderSection.test.tsx`, `app/src/components/chat/__tests__/ChatFilesPanel.test.tsx` | ✅ | Files land in `~/OpenHuman/projects/Files` with human names (`create_new`, ` (2)` on collision, shared across accounts without clobbering; per-account listing); escape guard on the recorded file; "file missing" for a file removed outside OpenHuman; crash-safe idempotent migration of legacy files; Download resolves an artifact id through the core; the folder is chosen in Settings → Agent OS access and validated (absolute, not protected, not inside the data folder); Show in folder on every ready file in the Files panel and on the settings row (#5505) |+| 6.1.4 | Agent deliverables in the visible Files folder | RU+VU | `crates/openhuman-core/src/agent/artifacts/files_tests.rs`, `crates/openhuman-core/src/agent/artifacts/migrate_tests.rs`, `crates/openhuman-core/src/agent/artifacts/ops_tests.rs`, `crates/openhuman-app/src/artifact_commands_tests.rs`, `app/src/services/__tests__/artifactDownloadService.test.ts`, `crates/openhuman-core/src/config/ops_files_dir_tests.rs`, `app/src/components/settings/panels/__tests__/FilesFolderSection.test.tsx`, `app/src/features/conversations/aui/MessageArtifactCards.test.tsx`, `app/src/features/conversations/aui/ArtifactPreviewPanel.refresh.test.tsx` | ✅ | Files land in `~/OpenHuman/projects/Files` with human names (`create_new`, ` (2)` on collision, shared across accounts without clobbering; per-account listing); escape guard on the recorded file; "file missing" for a file removed outside OpenHuman; crash-safe idempotent migration of legacy files; Download resolves an artifact id through the core; the folder is chosen in Settings → Agent OS access and validated (absolute, not protected, not inside the data folder); Show in folder on the settings row (#5505); in chat, each ready file is a card in the reply that made it and opens in the preview panel, whose Download saves it through the OS save dialog (the chat Files panel was removed in #7888) |### 6.2 Shell & Git