Craft Anything: understand how any software works, and craft your own.
Rust
Say where a build command ran, give API-key builds their asset keys, and respect the macOS accessibility flag (#999)
BFlatfb8f304417b9
diff --git a/crates/ai/src/key_tools.rs b/crates/ai/src/key_tools.rsindex f21bad49..d296aad2 100644--- a/crates/ai/src/key_tools.rs+++ b/crates/ai/src/key_tools.rs@@ -117,14 +117,18 @@ fn assets_key_set(ctx: &mut Ctx<'_>, params: Value) -> Result<ToolOutput, ToolErif key.is_empty() || key.len() > 512 || key.chars().any(char::is_whitespace) {return Err(ToolError::invalid(format!("That doesn't look like a {} key.", to.name())).with_remediation("Copy the key from the provider's dashboard."));}- let stored_in = hub(ctx)?.set_asset_key(to.id(), key)?;+ let hub = hub(ctx)?;+ let stored_in = hub.set_asset_key(to.id(), key)?;+ crate::keys::refresh_loaded(ctx.session, &hub.keys);Ok(ToolOutput::Value(json!({"provider": to.id(), "stored": true, "stored_in": stored_in})))}fn assets_key_remove(ctx: &mut Ctx<'_>, params: Value) -> Result<ToolOutput, ToolError> {let p: ProviderParams = parse_params(params)?;let from = provider(ctx, p.provider.as_deref())?;- hub(ctx)?.remove_asset_key(from.id())?;+ let hub = hub(ctx)?;+ hub.remove_asset_key(from.id())?;+ crate::keys::refresh_loaded(ctx.session, &hub.keys);Ok(ToolOutput::Value(json!({"provider": from.id(), "stored": false})))}diff --git a/crates/ai/src/keys.rs b/crates/ai/src/keys.rsindex 638f69c6..acea8b07 100644--- a/crates/ai/src/keys.rs+++ b/crates/ai/src/keys.rs@@ -37,6 +37,16 @@ pub fn asset_keys(store: &KeyStore, providers: &AssetProviders) -> AssetKeys {)}+/// After a key changed: keys a run already loaded into `session` follow, so a removed one stops being+/// spent at once. A session with none loaded stays that way. Reads the keychain, so call it off the UI+/// thread; a tool passes the session it holds, because locking it again would wait forever.+pub fn refresh_loaded(session: &mut craft_anything_engine::Session, store: &KeyStore) {+ if session.ext.get::<AssetKeys>().is_some() {+ let providers = session.ext.get::<AssetProviders>().map(|p| p.as_ref().clone()).unwrap_or_default();+ session.ext.insert(std::sync::Arc::new(asset_keys(store, &providers)));+ }+}+/// The fal.ai key for game assets: stored, else fal's environment variable.pub fn fal_key(store: &KeyStore) -> Option<String> {asset_key(store, &craft_anything_engines::assets::fal::Fal::default())@@ -141,6 +151,12 @@ impl KeyStore {if t.remove(backend).is_some() {self.write_file(&t)?;}+ // A locked or busy keychain may have refused, and it's read first, so the key would still+ // work. Reading back, not the delete's result: with no keychain at all the delete fails too.+ if self.use_keychain && keychain::get(backend).is_some() {+ return Err(ToolError::new(ErrorCode::NoPermission, "The system keychain still has this key, so it wasn't removed.")+ .with_remediation("Unlock the keychain and try again, or delete the entry from your keychain app."));+ }Ok(())}}@@ -227,6 +243,55 @@ mod tests {assert_eq!(fal_key(&s).as_deref(), Some("f-1"));}+ /// #923: a key removed in Settings must stop being spent, in a run that already loaded it too.+ #[test]+ fn keys_loaded_by_a_run_follow_a_change_and_none_appear_otherwise() {+ let d = tempfile::tempdir().unwrap();+ let s = KeyStore::file_only(d.path().join("keys.toml"));+ let mut providers = AssetProviders::built_in();+ providers.register(std::sync::Arc::new(Other));+ s.set(&asset_key_name("other"), "o-1").unwrap();+ let mut session = craft_anything_engine::testing::session();+ session.ext.insert(std::sync::Arc::new(providers));+ refresh_loaded(&mut session, &s);+ assert!(session.ext.get::<AssetKeys>().is_none(), "no run loaded any");++ session.ext.insert(std::sync::Arc::new(AssetKeys([("other".to_string(), "old".to_string())].into())));+ refresh_loaded(&mut session, &s);+ assert_eq!(session.ext.get::<AssetKeys>().unwrap().get("other"), Some("o-1"), "a changed key");+ s.delete(&asset_key_name("other")).unwrap();+ refresh_loaded(&mut session, &s);+ assert_eq!(session.ext.get::<AssetKeys>().unwrap().get("other"), None, "a removed key");+ }++ /// Its key can't be removed: the AI stays in the list, so removing it can be tried again.+ #[test]+ fn an_ai_whose_key_cannot_be_removed_stays_to_try_again() {+ let d = tempfile::tempdir().unwrap();+ let file = d.path().join("keys.toml");+ let engine = std::sync::Arc::new(craft_anything_engine::Engine::new(craft_anything_engine::testing::session()));+ let hub = crate::AiHub::with_stores(engine, d.path().join("settings.toml"), KeyStore::file_only(file.clone()));+ let mut cfg = hub.config();+ cfg.upsert(crate::BackendEntry {+ config: crate::BackendConfig {+ name: "Mine".into(),+ kind: BackendKind::Openrouter,+ model: "m".into(),+ base_url: None,+ ssh_host: None,+ enabled: true,+ },+ options: Default::default(),+ });+ hub.engine.session().settings.ai = cfg.to_table().unwrap();+ std::fs::write(&file, "not [ toml").unwrap();+ assert!(hub.remove_backend("Mine").is_err());+ assert!(hub.config().get("Mine").is_some(), "it can still be picked to try again");+ std::fs::remove_file(&file).unwrap();+ assert!(hub.remove_backend("Mine").unwrap());+ assert!(hub.config().get("Mine").is_none());+ }+/// #262: a key file that can't be read is left as it is, with every other key in it.#[test]fn an_unreadable_key_file_is_never_replaced() {diff --git a/crates/ai/src/lib.rs b/crates/ai/src/lib.rsindex 32d0a4d7..40200fb7 100644--- a/crates/ai/src/lib.rs+++ b/crates/ai/src/lib.rs@@ -699,11 +699,16 @@ impl AiHub {/// Remove a backend and its stored key. Returns false when there was no such backend.pub fn remove_backend(&self, name: &str) -> Result<bool, ToolError> {+ if self.config_to_change()?.get(name).is_none() {+ return Ok(false);+ }+ // The key first: if it can't be removed the backend stays, so this can be tried again. The+ // settings are read after it, because the keychain can take seconds and they may change.+ self.keys.delete(name)?;let mut cfg = self.config_to_change()?;let removed = cfg.remove(name);if removed {self.save_config(&cfg)?;- self.keys.delete(name)?;}Ok(removed)}@@ -723,6 +728,12 @@ impl AiHub {self.keys.delete(&keys::asset_key_name(provider))}+ /// See [`keys::refresh_loaded`]: for callers that don't hold the session. It can wait for a+ /// running tool, so never call it from the UI thread or a tool.+ pub fn refresh_loaded_asset_keys(&self) {+ keys::refresh_loaded(&mut self.engine.session(), &self.keys);+ }+/// The provider's key is stored or in its environment variable.pub fn has_asset_key(&self, providers: &craft_anything_engines::assets::AssetProviders, provider: &str) -> bool {providers.get(provider).is_some_and(|p| keys::asset_key(&self.keys, p.as_ref()).is_some())diff --git a/crates/ai/src/rebuild/mod.rs b/crates/ai/src/rebuild/mod.rsindex 4bb10028..4066bcd5 100644--- a/crates/ai/src/rebuild/mod.rs+++ b/crates/ai/src/rebuild/mod.rs@@ -246,13 +246,14 @@ impl RebuildRun {editor: None,notes: notes.clone(),feed: feed.clone(),- assets: hub.has_asset_keys(),+ assets: false,decompiled: false,usage: Some(UsageClock { root: root.clone(), since: Instant::now() }),self_check: None,reset_progress_after_notes: false,};let r2 = running.clone();+ let key_store = hub.keys.clone();std::thread::Builder::new().name("rebuild".into()).spawn(move || {@@ -261,7 +262,10 @@ impl RebuildRun {// A clone can run for hours: keep the computer from sleeping until it ends.let awake = craft_anything_platform::keep_awake();let _here = self_check::BuildingHere::new(&ws.root);- let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| ctx.run(&mut ws, entry, api, extractor, &opts)));+ let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {+ ctx.load_asset_keys(&key_store);+ ctx.run(&mut ws, entry, api, extractor, &opts)+ }));let (ok, message, paused) = match result {Ok(Ok(m)) => (true, m, false),Ok(Err(e)) if e.code == ErrorCode::Cancelled => {@@ -496,6 +500,21 @@ impl Worker {result}+ /// An API backend's builder runs its tools in this session, not in a tool server that loads the+ /// keys itself (#923). Read on the worker because the keychain can block, and for each run so a+ /// key saved outside the app since the last one counts. The session stays held through the+ /// read, so a key removed meanwhile can't be put back by keys read before it went. What the+ /// brief says about assets comes from the same read, so the two agree.+ fn load_asset_keys(&mut self, store: &crate::KeyStore) {+ let mut session = self.engine.session();+ session.label("Load the asset keys");+ let providers = session.ext.get::<craft_anything_engines::assets::AssetProviders>().map(|p| p.as_ref().clone()).unwrap_or_default();+ let keys = crate::keys::asset_keys(store, &providers);+ // The brief offers the built-in models, so a key for another provider doesn't count.+ self.assets = craft_anything_engines::assets::AssetProviders::built_in().ids().into_iter().any(|id| keys.get(id).is_some());+ session.ext.insert(Arc::new(keys));+ }+/// Point the engine at this workspace: its investigation project and inbox.fn attach(&self, ws: &Workspace) -> Result<(), ToolError> {let dir = ws.investigation_dir();diff --git a/crates/ai/src/rebuild/runs.rs b/crates/ai/src/rebuild/runs.rsindex b38a2f0c..0bdf64d6 100644--- a/crates/ai/src/rebuild/runs.rs+++ b/crates/ai/src/rebuild/runs.rs@@ -1,7 +1,9 @@//! Several rebuilds at once. A [`RunSet`] keeps every project's run by folder: up to its limit//! work at the same time, the rest wait in order and start as others finish. The app and the//! rebuild tools both hold one; each run keeps its own project's feed, so nothing here depends on-//! which project is on screen.+//! which project is on screen. A run whose AI uses our own agent loop works alone: its tools run in+//! the app's session, which points at one project at a time, so a run starting beside it would send+//! its files and asset spending to the other project.use super::*;use std::collections::{HashMap, VecDeque};@@ -33,12 +35,28 @@ pub struct RunSet {limit: usize,/// Running and finished runs (a finished one keeps its preview and unsent notes).runs: HashMap<PathBuf, RebuildRun>,- queue: VecDeque<(Workspace, RunOptions)>,+ /// Waiting runs, and whether each last looked like it must work alone: `poll` runs every frame+ /// and looking it up can read the settings file, so it's looked up again only when a run may+ /// be about to start.+ queue: VecDeque<(Workspace, RunOptions, bool)>,+ /// The latest run to start, if it had to work alone; nothing else starts while it's working.+ alone: Option<PathBuf>,starter: Starter,/// A [`keep_queue_moving`] thread is looking after the queue.watched: bool,}+/// Whether this run's tools would run in the app's session: its Builder is an API backend, or the+/// Extractor that only works on a fresh study is (the same test as [`RebuildRun::start`]). Agent+/// apps have a tool server of their own.+fn must_work_alone(hub: &AiHub, ws: &Workspace, opts: &RunOptions) -> bool {+ let cfg = hub.config();+ let in_session = |e: &crate::BackendEntry| e.config.kind != BackendKind::AgentCli;+ let fresh = opts.message.is_none() || !ws.capture_dir().exists();+ builder_backend(&cfg, opts.backend.as_deref().or_else(|| super::project_builder(&cfg, ws))).is_ok_and(|e| in_session(&e))+ || (fresh && hub.chosen(Role::Extractor).and_then(|n| cfg.get(&n).cloned()).is_some_and(|e| in_session(&e)))+}+impl std::fmt::Debug for RunSet {fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {f.debug_struct("RunSet").field("limit", &self.limit).field("running", &self.active()).field("queued", &self.queue.len()).finish()@@ -48,7 +66,13 @@ impl std::fmt::Debug for RunSet {impl RunSet {/// At most `limit` runs work at once (at least one).pub fn new(limit: usize) -> RunSet {- RunSet { limit: limit.max(1), runs: HashMap::new(), queue: VecDeque::new(), starter: Box::new(RebuildRun::start), watched: false }+ RunSet { limit: limit.max(1), runs: HashMap::new(), queue: VecDeque::new(), alone: None, starter: Box::new(RebuildRun::start), watched: false }+ }++ /// A run may start now: there's a place, and neither it nor anyone working needs to be alone.+ fn has_room(&self, alone: bool) -> bool {+ let active = self.active();+ active < self.limit && (!alone || active == 0) && !self.alone.as_ref().is_some_and(|root| self.is_running(root))}/// Start runs another way (a fork's runner, or a test's).@@ -66,24 +90,27 @@ impl RunSet {self.limit}- /// Start a run on `ws`, or queue it when `limit` are already working. A project that is- /// working or queued is refused.+ /// Start a run on `ws`, or queue it when `limit` are already working or it has to wait to work+ /// alone. Nothing overtakes the queue, so one waiting to be alone gets its turn. A project that+ /// is working or queued is refused.pub fn start(&mut self, hub: &AiHub, ws: Workspace, opts: RunOptions) -> Result<Started, ToolError> {if self.is_running(&ws.root) || self.position(&ws.root).is_some() {return Err(ToolError::new(ErrorCode::BadInput, "This project is already building.").with_remediation("Add to it while it works, or stop it first."));}- if self.active() < self.limit {+ let alone = must_work_alone(hub, &ws, &opts);+ if self.queue.is_empty() && self.has_room(alone) {let root = ws.root.clone();let run = (self.starter)(hub, ws, opts)?;+ self.alone = alone.then(|| root.clone());self.runs.insert(root, run);return Ok(Started::Running);}// Fail now, not when its turn comes, when no coding agent is set up.let cfg = hub.config();builder_backend(&cfg, opts.backend.as_deref().or_else(|| super::project_builder(&cfg, &ws)))?;- self.queue.push_back((ws, opts));+ self.queue.push_back((ws, opts, alone));Ok(Started::Queued { position: self.queue.len() })}@@ -94,12 +121,19 @@ impl RunSet {for (root, run) in &mut self.runs {out.extend(run.poll().into_iter().map(|e| (root.clone(), e)));}- while self.active() < self.limit {- let Some((ws, opts)) = self.queue.pop_front() else { break };+ while self.queue.front().is_some_and(|(_, _, alone)| self.has_room(*alone)) {+ let Some((ws, opts, _)) = self.queue.pop_front() else { break };+ // The Builder may have been changed while it waited.+ let alone = must_work_alone(hub, &ws, &opts);+ if !self.has_room(alone) {+ self.queue.push_front((ws, opts, alone));+ break;+ }let root = ws.root.clone();let mut keep = ws.clone();match (self.starter)(hub, ws, opts) {Ok(run) => {+ self.alone = alone.then(|| root.clone());self.runs.insert(root, run);}Err(e) => {@@ -128,7 +162,7 @@ impl RunSet {/// Its place in the queue (1 starts next).pub fn position(&self, root: &Path) -> Option<usize> {- self.queue.iter().position(|(ws, _)| ws.root == root).map(|i| i + 1)+ self.queue.iter().position(|(ws, _, _)| ws.root == root).map(|i| i + 1)}/// How many are waiting.@@ -154,13 +188,13 @@ impl RunSet {/// The projects working or waiting.pub fn busy(&self) -> Vec<PathBuf> {let mut v: Vec<PathBuf> = self.runs.iter().filter(|(_, r)| r.is_running()).map(|(p, _)| p.clone()).collect();- v.extend(self.queue.iter().map(|(ws, _)| ws.root.clone()));+ v.extend(self.queue.iter().map(|(ws, _, _)| ws.root.clone()));v}/// Stop the project's run, or take it out of the queue.pub fn stop(&mut self, root: &Path) -> Stopped {- if let Some(i) = self.queue.iter().position(|(ws, _)| ws.root == root) {+ if let Some(i) = self.queue.iter().position(|(ws, _, _)| ws.root == root) {self.queue.remove(i);return Stopped::Unqueued;}@@ -263,6 +297,104 @@ mod tests {assert!(set.position(&a.root).is_none());}+ /// An agent app, which has a tool server of its own, and an API backend, which uses the session.+ fn two_backends() -> AiHub {+ let mut s = craft_anything_engine::testing::session();+ s.settings.ai = toml::from_str(+ "[[backends]]\nname = \"Agent\"\nkind = \"agent_cli\"\nmodel = \"claude-code\"\n[[backends]]\nname = \"Key\"\nkind = \"openrouter\"\nmodel = \"m\"\n",+ )+ .unwrap();+ AiHub::new(Arc::new(Engine::new(s)))+ }++ /// #923: two builds in one session wrote into one project, and spent its asset budget.+ #[test]+ fn a_run_in_the_apps_session_works_alone_and_nothing_overtakes_it() {+ let d = tempfile::tempdir().unwrap();+ let ws = |n: &str| Workspace::create(d.path(), n, "A game", TargetRef::None).unwrap();+ let (agent, key, later) = (ws("Agent"), ws("Key"), ws("Later"));+ let hub = two_backends();+ let by = |name: &str| RunOptions { backend: Some(name.into()), ..RunOptions::default() };+ let fake = StandIns::new();+ let mut set = RunSet::new(4).with_starter(fake.starter());++ assert_eq!(set.start(&hub, agent.clone(), by("Agent")).unwrap(), Started::Running);+ assert_eq!(set.start(&hub, key.clone(), by("Key")).unwrap(), Started::Queued { position: 1 }, "it waits for the session");+ assert_eq!(set.start(&hub, later.clone(), by("Agent")).unwrap(), Started::Queued { position: 2 }, "nothing overtakes it");+ assert!(set.poll(&hub).is_empty() && set.active() == 1);++ fake.finish(&agent.root);+ set.poll(&hub);+ assert!(set.is_running(&key.root) && !set.is_running(&later.root), "it has the session to itself, with places free");++ fake.finish(&key.root);+ set.poll(&hub);+ assert!(set.is_running(&later.root));+ assert_eq!(set.start(&hub, agent.clone(), by("Agent")).unwrap(), Started::Running, "agent apps still work side by side");+ set.stop_all();+ }++ /// The marker follows the run, not the project: the same folder rebuilt with an agent app+ /// doesn't keep others waiting.+ #[test]+ fn a_project_that_worked_alone_can_build_beside_others_with_an_agent_app() {+ let d = tempfile::tempdir().unwrap();+ let ws = |n: &str| Workspace::create(d.path(), n, "A game", TargetRef::None).unwrap();+ let (a, b) = (ws("A"), ws("B"));+ let hub = two_backends();+ let by = |name: &str| RunOptions { backend: Some(name.into()), ..RunOptions::default() };+ let fake = StandIns::new();+ let mut set = RunSet::new(2).with_starter(fake.starter());+ assert_eq!(set.start(&hub, a.clone(), by("Key")).unwrap(), Started::Running);+ fake.finish(&a.root);+ set.poll(&hub);+ assert_eq!(set.start(&hub, a.clone(), by("Agent")).unwrap(), Started::Running);+ assert_eq!(set.start(&hub, b.clone(), by("Agent")).unwrap(), Started::Running);+ set.stop_all();+ }++ /// Queued for an agent app, then the only AI left is an API backend: it mustn't start beside+ /// the run still working.+ #[test]+ fn a_queued_run_is_checked_again_when_its_turn_comes() {+ let d = tempfile::tempdir().unwrap();+ let ws = |n: &str| Workspace::create(d.path(), n, "A game", TargetRef::None).unwrap();+ let (a, b, c) = (ws("A"), ws("B"), ws("C"));+ let hub = two_backends();+ let by = |name: &str| RunOptions { backend: Some(name.into()), ..RunOptions::default() };+ let fake = StandIns::new();+ let mut set = RunSet::new(2).with_starter(fake.starter());+ set.start(&hub, a.clone(), by("Agent")).unwrap();+ set.start(&hub, b.clone(), by("Agent")).unwrap();+ assert_eq!(set.start(&hub, c.clone(), RunOptions::default()).unwrap(), Started::Queued { position: 1 });+ hub.engine.session().settings.ai = toml::from_str("[[backends]]\nname = \"Key\"\nkind = \"openrouter\"\nmodel = \"m\"\n").unwrap();++ fake.finish(&a.root);+ set.poll(&hub);+ assert!(!set.is_running(&c.root), "B is still working");+ fake.finish(&b.root);+ set.poll(&hub);+ assert!(set.is_running(&c.root));+ set.stop_all();+ }++ #[test]+ fn a_follow_up_with_an_api_extractor_can_build_beside_others() {+ let d = tempfile::tempdir().unwrap();+ let ws = Workspace::create(d.path(), "A", "A game", TargetRef::None).unwrap();+ let mut s = craft_anything_engine::testing::session();+ s.settings.ai = toml::from_str(+ "[roles]\nextractor = \"Key\"\n[[backends]]\nname = \"Agent\"\nkind = \"agent_cli\"\nmodel = \"claude-code\"\n[[backends]]\nname = \"Key\"\nkind = \"openrouter\"\nmodel = \"m\"\n",+ )+ .unwrap();+ let hub = AiHub::new(Arc::new(Engine::new(s)));+ let by_agent = |message: Option<&str>| RunOptions { backend: Some("Agent".into()), message: message.map(str::to_string), ..RunOptions::default() };+ assert!(must_work_alone(&hub, &ws, &by_agent(None)), "a fresh study may use the Extractor");+ assert!(must_work_alone(&hub, &ws, &by_agent(Some("make it blue"))), "with nothing studied yet, so may this");+ std::fs::create_dir_all(ws.capture_dir()).unwrap();+ assert!(!must_work_alone(&hub, &ws, &by_agent(Some("make it blue"))), "a follow-up doesn't");+ }+#[test]fn a_queued_run_that_cannot_start_says_why() {let d = tempfile::tempdir().unwrap();diff --git a/crates/ai/src/rebuild/tests.rs b/crates/ai/src/rebuild/tests.rsindex 6e392fb2..22521a81 100644--- a/crates/ai/src/rebuild/tests.rs+++ b/crates/ai/src/rebuild/tests.rs@@ -1403,6 +1403,17 @@ mod picking_up_a_build {Bench { _dir: dir, hub, projects, prompts }}+ /// #923: starting a run is what loads the keys, for builders that use this session's tools.+ #[test]+ fn a_run_loads_the_saved_asset_keys_into_its_session() {+ let b = bench();+ b.hub.set_asset_key("fal", "k-1").unwrap();+ let ws = Workspace::create(&b.projects, "x", "Build a notes app", TargetRef::None).unwrap();+ let _ = try_it(&b, &ws);+ let keys = b.hub.engine.session().ext.get::<craft_anything_engine::tools::asset_tools::AssetKeys>().unwrap_or_default();+ assert_eq!(keys.get("fal"), Some("k-1"));+ }+fn try_it(b: &Bench, ws: &Workspace) -> (bool, Vec<feed::FeedItem>) {try_with(b, ws, RunOptions::default())}@@ -2079,6 +2090,24 @@ fn just_ask_is_told_to_the_builder_shortly_and_cut_on_a_character() {assert!(super::just_asked(&longest).encode_utf16().count() < 20_000);}+/// #923: with OpenRouter as the builder, every asset call said "No fal.ai key" with one saved. The+/// project hasn't turned on generated assets, so nothing is sent or spent.+#[test]+fn a_saved_asset_key_gets_an_api_builders_tool_past_the_key_check() {+ let dir = tempfile::tempdir().unwrap();+ let ws = Workspace::create(dir.path(), "x", "Make a game", TargetRef::None).unwrap();+ let mut worker = check_worker(&ws, false);+ worker.attach(&ws).unwrap();+ let call =+ |w: &Worker| w.engine.call("assets_image_generate", json!({"prompt": "a crate", "save_as": "crate.png"}), CallOptions::new(Caller::Ui)).err().unwrap();+ assert_eq!(call(&worker).code, ErrorCode::BadSettings, "no key loaded yet");+ let store = crate::KeyStore::file_only(dir.path().join("keys.toml"));+ store.set(crate::keys::FAL_KEY, "k-1").unwrap();+ worker.load_asset_keys(&store);+ assert_eq!(call(&worker).code, ErrorCode::NoPermission);+ assert!(worker.assets, "the brief and the tools go by the same read");+}+fn check_worker(ws: &Workspace, deep: bool) -> Worker {let mut s = craft_anything_engine::testing::session();s.settings.deep_mode = deep;diff --git a/crates/engine/src/tools/apple_runtime.rs b/crates/engine/src/tools/apple_runtime.rsindex 6761eb8f..5c915f51 100644--- a/crates/engine/src/tools/apple_runtime.rs+++ b/crates/engine/src/tools/apple_runtime.rs@@ -455,16 +455,24 @@ mod macos {}}+ /// Observe a running macOS app through the native helper and return its UI evidence.+ /// Records the accessibility selection and reports a deliberately skipped tree in the+ /// summary; with accessibility disabled, the helper needs no Accessibility permission.pub fn runtime_ui_read(ctx: &mut Ctx<'_>, p: ObserveUiParams) -> Result<ToolOutput, ToolError> {let pid = p.pid.ok_or_else(|| ToolError::invalid("pid is required to read a running app's UI"))?;let request = json!({"command": "observe", "pid": pid, "window_id": p.window_id, "screenshot": p.screenshot, "accessibility": p.accessibility, "max_nodes": p.max_nodes});let result = run_helper(ctx, request, 10_000)?;let nodes = result.get("nodes").and_then(Value::as_array).map(Vec::len).unwrap_or(0);+ let summary = if p.accessibility {+ format!("Read {nodes} accessibility node(s) from pid {pid}.")+ } else {+ format!("Skipped the accessibility tree for pid {pid}, as requested.")+ };let b =EvidenceBuilder::new("runtime_ui_read", Subject { kind: "ui".into(), sha256: None, name: Some(format!("pid {pid}")) }, env(ctx, "accessibility"))- .params(json!({"pid": pid, "max_nodes": p.max_nodes, "screenshot": p.screenshot}))+ .params(json!({"pid": pid, "max_nodes": p.max_nodes, "screenshot": p.screenshot, "accessibility": p.accessibility})).result(result)- .summary(format!("Read {nodes} accessibility node(s) from pid {pid}."))+ .summary(summary).confidence(Confidence::Observed).authority(Authority::OurRun);Ok(ToolOutput::evidence(b.build()?))@@ -626,6 +634,23 @@ mod tests {}}+ /// Run the real Swift helper without reading app UI or requiring Accessibility permission.+ /// Both zero and positive node limits must return an empty, non-truncated tree and evidence+ /// that records the skipped read.+ #[cfg(target_os = "macos")]+ #[test]+ fn macos_can_skip_accessibility_without_reading_a_tree() {+ let e = Engine::new(crate::testing::session());+ for max_nodes in [0, 1] {+ let output =+ e.call("runtime_ui_read", json!({"pid": std::process::id(), "accessibility": false, "max_nodes": max_nodes}), granted()).unwrap().to_json();+ assert_eq!(output["result"]["nodes"], json!([]), "{output}");+ assert_eq!(output["result"]["truncated"], false, "{output}");+ assert_eq!(output["params"]["accessibility"], false, "{output}");+ assert!(output["summary"].as_str().unwrap().contains("Skipped the accessibility tree"), "{output}");+ }+ }+#[cfg(target_os = "macos")]#[test]fn calls_validate_before_dispatch() {diff --git a/crates/engine/src/tools/apple_runtime/native_ui_helper.swift b/crates/engine/src/tools/apple_runtime/native_ui_helper.swiftindex fd14ed08..a86a4fc5 100644--- a/crates/engine/src/tools/apple_runtime/native_ui_helper.swift+++ b/crates/engine/src/tools/apple_runtime/native_ui_helper.swift@@ -93,7 +93,10 @@ guard let req = try? JSONDecoder().decode(Request.self, from: input), let pid =exit(2)}-if !AXIsProcessTrusted() {+// Observation may explicitly omit the tree. Walkthroughs still need AX permission because+// they read and drive controls, regardless of an observe-only flag in the request.+let readAccessibility = req.command != "observe" || (req.accessibility ?? true)+if readAccessibility && !AXIsProcessTrusted() {// A typed reason so the caller can report a permission problem, not an empty tree.emit(["error": "accessibility permission not granted", "reason": "accessibility_not_granted", "nodes": []])exit(0)@@ -101,8 +104,8 @@ if !AXIsProcessTrusted() {switch req.command {case "observe":- let nodes = snapshot(pid: pid, maxNodes: req.max_nodes ?? 5000)- emit(["nodes": nodes, "truncated": nodes.count >= (req.max_nodes ?? 5000)])+ let nodes = readAccessibility ? snapshot(pid: pid, maxNodes: req.max_nodes ?? 5000) : []+ emit(["nodes": nodes, "truncated": readAccessibility && nodes.count >= (req.max_nodes ?? 5000)])case "walkthrough":let app = AXUIElementCreateApplication(pid)var steps: [[String: Any]] = []diff --git a/crates/engine/src/tools/asset_tools.rs b/crates/engine/src/tools/asset_tools.rsindex 24456ae3..ef84bbf6 100644--- a/crates/engine/src/tools/asset_tools.rs+++ b/crates/engine/src/tools/asset_tools.rs@@ -19,7 +19,8 @@ use std::path::{Path, PathBuf};use std::sync::OnceLock;/// The person's key for each asset provider (by provider id), put in the session by the tool-/// server (read from the keychain; a key never travels on a command line or into a log).+/// server or a build's run (read from the keychain; a key never travels on a command line or into a+/// log).#[derive(Default)]pub struct AssetKeys(pub std::collections::BTreeMap<String, String>);@@ -127,15 +128,16 @@ struct Job {}fn job(ctx: &Ctx<'_>) -> Result<Job, ToolError> {+ // First: outside a project no keys are loaded, so "no key" would be wrong for a saved one (#923).+ let not_project = || ToolError::new(ErrorCode::FeatureMissing, "Assets can only be generated inside a Craft Anything project.");+ let inbox = inbox(ctx).ok_or_else(not_project)?;+ let ws = workspace_of(&inbox).ok_or_else(not_project)?;let keys = ctx.session.ext.get::<AssetKeys>().unwrap_or_default();// A session can bring its own providers (a fork, a test); otherwise the built-in ones.let providers = ctx.session.ext.get::<AssetProviders>().map(|p| p.as_ref().clone()).unwrap_or_default();if !providers.ids().iter().any(|id| keys.get(id).is_some()) {return Err(no_key("fal.ai"));}- let not_project = || ToolError::new(ErrorCode::FeatureMissing, "Assets can only be generated inside a Craft Anything project.");- let inbox = inbox(ctx).ok_or_else(not_project)?;- let ws = workspace_of(&inbox).ok_or_else(not_project)?;if !ws.manifest.generate_assets {return Err(ToolError::new(ErrorCode::NoPermission, "The person hasn't turned on generated assets for this project.").with_remediation("Make these assets with simple shapes and colours instead, and tell the person they can turn on generated assets for this game in the app.",@@ -457,6 +459,16 @@ mod tests {}}+ /// #923: the CLI and a plain tool server load no keys, and "no key" sent people to add one they had.+ #[test]+ fn outside_a_project_it_says_so_and_not_that_there_is_no_key() {+ let e = crate::Engine::new(crate::testing::session());+ let err =+ e.call("assets_image_generate", json!({"prompt": "a crate", "save_as": "crate.png"}), crate::CallOptions::new(crate::Caller::Cli)).err().unwrap();+ assert_eq!(err.code, ErrorCode::FeatureMissing);+ assert!(err.message.contains("inside a Craft Anything project"), "{}", err.message);+ }+#[test]fn without_a_key_it_says_to_use_simple_shapes() {let (_d, w) = ws();diff --git a/crates/engine/src/tools/build_tools.rs b/crates/engine/src/tools/build_tools.rsindex 98a62d0a..e7e557b7 100644--- a/crates/engine/src/tools/build_tools.rs+++ b/crates/engine/src/tools/build_tools.rs@@ -329,6 +329,8 @@ fn build_command_run(ctx: &mut Ctx<'_>, params: Value) -> Result<ToolOutput, Tooapprove(ctx, "Bash", &json!({"command": p.command}))?.map_err(refused)?;let app = ws.app_dir();std::fs::create_dir_all(&app).map_err(|e| ToolError::io(app.display(), e))?;+ let inner = app.join("app");+ let had_inner = inner.is_dir();let (shell, flag) = if cfg!(windows) { ("cmd", "/C") } else { ("sh", "-c") };let cancel = ctx.cancel.clone();ctx.report(None, format!("Running {}", p.command.chars().take(120).collect::<String>()));@@ -349,13 +351,26 @@ fn build_command_run(ctx: &mut Ctx<'_>, params: Value) -> Result<ToolOutput, Too}s.get(start..).unwrap_or_default().to_string()};- Ok(ToolOutput::Value(json!({+ let mut v = json!({"command": p.command,+ "ran_in": ws.app_place(),"exit_code": out.code,"succeeded": out.success,"stdout": tail(out.stdout_text()),"stderr": tail(out.stderr_text()),- })))+ });+ // A model that reads file paths and commands from one base starts with `cd app`, or makes its+ // project with `cargo new app`, from inside app/.+ let first = p.command.split(['&', ';', '\n']).next().unwrap_or_default().trim().replace('\\', "/");+ if ["cd app", "cd app/", "cd ./app", "cd ./app/"].contains(&first.as_str()) && !inner.is_dir() {+ v["note"] = json!(format!("Commands already run in {}: leave out `cd app`.", ws.app_place()));+ } else if !had_inner && app != ws.root && ["Cargo.toml", "package.json"].iter().any(|m| inner.join(m).is_file()) {+ // Only a project: a folder named app is fine there (Next.js keeps its routes in one).+ v["note"] = json!(+ "This made a project in app/app/: commands already run in app/, so the app's project goes in app/ itself (app/Cargo.toml, app/package.json)."+ );+ }+ Ok(ToolOutput::Value(v))}#[cfg(test)]@@ -479,6 +494,30 @@ mod tests {assert!(err.message.contains("dev servers"), "{}", err.message);}+ /// R5.4: a local model ran `cd app && cargo build` from inside app/, reading file paths and+ /// commands from one base.+ #[test]+ fn a_command_says_where_it_ran() {+ let (_d, _ws, e) = building();+ let ok = call(&e, "build_command_run", json!({"command": "echo built"})).unwrap();+ assert_eq!((ok["ran_in"].as_str(), ok["succeeded"].as_bool(), ok.get("note")), (Some("app/"), Some(true), None));+ let lost = call(&e, "build_command_run", json!({"command": "cd app && echo built"})).unwrap();+ assert_eq!(lost["succeeded"], false, "{lost}");+ assert!(lost["note"].as_str().is_some_and(|n| n.contains("already run in app/")), "{lost}");+ let lines = call(&e, "build_command_run", json!({"command": "cd app\necho built"})).unwrap();+ assert!(lines["note"].as_str().is_some_and(|n| n.contains("already run in app/")), "{lines}");+ // Live, its first command was `cargo new app`, which made a project in app/app/.+ let nested = call(&e, "build_command_run", json!({"command": "mkdir app && cd app && echo [package]> Cargo.toml"})).unwrap();+ assert!(nested["note"].as_str().is_some_and(|n| n.contains("This made a project in app/app/")), "{nested}");+ // Once there, it's a folder of the app's own: going into it is left alone.+ let inner = call(&e, "build_command_run", json!({"command": "cd app && echo built"})).unwrap();+ assert_eq!((inner["succeeded"].as_bool(), inner.get("note")), (Some(true), None));+ // A folder named app with no project in it is fine (Next.js keeps its routes in one).+ let (_d, _ws, e) = building();+ let routes = call(&e, "build_command_run", json!({"command": "mkdir app"})).unwrap();+ assert_eq!(routes.get("note"), None, "{routes}");+ }+#[test]fn the_checklist_is_checked() {let (_d, _ws, e) = building();diff --git a/crates/ui-egui/src/engine_ui.rs b/crates/ui-egui/src/engine_ui.rsindex 6d3b263e..38897308 100644--- a/crates/ui-egui/src/engine_ui.rs+++ b/crates/ui-egui/src/engine_ui.rs@@ -402,6 +402,7 @@ impl CraftApp {let hub = self.hub.clone();self.jobs.spawn(tr("Save the key"), true, move |_| {hub.set_asset_key(&provider, &key).map_err(|e| e.message)?;+ hub.refresh_loaded_asset_keys();Ok(Done::AssetKeys(stored_keys(&hub)))});}@@ -410,6 +411,7 @@ impl CraftApp {let hub = self.hub.clone();self.jobs.spawn(tr("Forget the key"), true, move |_| {hub.remove_asset_key(&provider).map_err(|e| e.message)?;+ hub.refresh_loaded_asset_keys();Ok(Done::AssetKeys(stored_keys(&hub)))});}diff --git a/docs/ROADMAP.md b/docs/ROADMAP.mdindex 2e0d6c64..b6be6fa3 100644--- a/docs/ROADMAP.md+++ b/docs/ROADMAP.md@@ -316,6 +316,9 @@ been run live.tool, with only words before or between them, now runs them all (`fenced_calls`, ids`react_N` as other text calls); words after the last fence, other code, an unclosed fence ora tool that wasn't offered keep it text (#753)+- [ ] A call followed by a summary isn't run, and the model isn't told: in a second live run of+ #417's case both turns put "### Summary:" after their one `json` fence, nothing ran, and the+ build stopped after two turns with no files. Say in the next message that it wasn't run- [ ] A local builder spends its rounds on the project file and never writes the app: run 4 had acompiling `Cargo.toml` by check 3, its last, with `main.rs` still "Hello, world!". See whethermore rounds get there, or whether a small model needs the window and the `--screenshot`@@ -335,6 +338,20 @@ been run live.`TurnDone` left them out while coding agents count them. It counts them now; a live run onOllama 0.40.7 had recorded 5,323 input tokens of 75,014— claimed: SoldierPePe, branch bugfix/r5.4-usage-cached-tokens+- [ ] Told that its `cargo new app` made `app/app/`, the model kept editing `app/app/Cargo.toml`+ and running `cargo build` in `app/`, and checks 2 and 3 still found the project one folder+ down (live, GPU). See whether naming the move gets it out, or whether the run should move it+- [x] The model reads file paths from the project folder and commands from `app/` as one base:+ it ran `cargo init app` and `cd app && cargo build` after writing `app/Cargo.toml`.+ `build_command_run`'s result now says where it ran (`ran_in`), a command that makes a project+ in `app/app/` is told it goes in `app/` itself, and one that starts with `cd app` where+ there's none is told to leave it out. Live (Ollama, `qwen2.5-coder:14b`) the first command+ was still `cargo new app`, before any result could say so. On a GPU (Ollama 0.40.7) the note+ then reached the model; on the CPU a second run wrote the call with a summary after it, so+ nothing ran (the open line on a call followed by a summary)+ — claimed: SoldierPePe, branch bugfix/r5.4-build-command-folder+- [ ] `usage.json` after a local build says about 4,200 input tokens and 6.5 s of work, while+ Ollama logged about six requests of 4,000-5,000 tokens each: find what it leaves out- [x] An assistant turn with no text sends an empty string, not `content: null`, which Ollamarefused as `invalid message content type: <nil>` (#403, #536)- [x] Understand a tool call a model writes as JSON in its text (#417; implementation `dfe9a4db2dcb3e27edbd67311cbb4202584e7af6`). The fallback protocol reads@@ -387,6 +404,15 @@ Owner: open · Status: todo"400: Provider returned error" (#369): a request with tools now sets`provider.require_parameters`, and a 404 "no provider for these parameters" falls back to thetext protocol like any server that rejects tools+- [x] A saved fal.ai key reaches an API-key build's asset tools; every call said "No fal.ai key"+ (#923). Outside a project the tools now say that instead. Not checked with a real fal.ai key+ or API build+- [x] An API-key build works alone: it shares the app's session, whose `attach` points at whichever+ project started last, so another build beside it sent its files and asset spending to the+ wrong project (`build.parallel` is 2 by default). Others wait their turn in the queue+- [ ] Let API-key builds run side by side: give each an engine of its own, as a question has. This+ also closes the gap left in working alone: the app and the `rebuild_start` tool each keep a+ queue, so a build the in-app chat starts isn't kept apart from one the app started- [ ] Check #369 live with Kimi K3 and a key limited to Kimi/Moonshot models (needs the person'sOpenRouter key): that the build starts, or that the error now names the provider's reason- [ ] A live API-key build (needs a key on the test machine)@@ -399,12 +425,15 @@ Owner: open · Status: todo### R5.6 Tools report only what they sawOwner: open · Status: todo-Golden rule 3: the result is evidence. All four tickets are confirmed in the code, with no PR yet.-Each fix needs a Mac to test on.+Golden rule 3: the result is evidence. Each fix needs a Mac to test on.- [x] macOS: a denied Accessibility permission is reported as success with an empty tree (#240)— claimed: mavericzz, branch bugfix/r5.6-accessibility-denied; PR #887-- [ ] macOS: `runtime_ui_read` ignores `screenshot` (#248) and `accessibility` (#307): the Swift- helper declares both and reads neither+- [ ] macOS: `runtime_ui_read` ignores `screenshot` (#248): the Swift helper declares it but+ never captures an image+- [x] macOS: `runtime_ui_read` honours `accessibility: false` (#307): the Swift helper skips+ the tree and its permission check, returns no nodes without truncation, and the evidence+ records the flag and says the tree was skipped. Walkthroughs still require Accessibility+ — claimed: Codex, branch bugfix/r5.6-macos-ui-flags- [ ] macOS: call observation writes a literal `\n` into its lldb callback, so the Python isinvalid and it reports zero calls (#251)diff --git a/docs/STATUS.md b/docs/STATUS.mdindex a268fdbd..7781f79e 100644--- a/docs/STATUS.md+++ b/docs/STATUS.md@@ -8,6 +8,7 @@ workspace clippy, layers, fmt and the secret scan of all history were clean. Chi| Area | State | Verified by ||---|---|---|+| macOS optional UI tree | `runtime_ui_read` with `accessibility: false` skips the tree and its permission check, returns empty nodes without truncation, and records the flag and skipped read in its evidence (#307). Walkthroughs still require Accessibility. Screenshot capture remains open (#248) | Engine regression on macOS compiles and runs the real Swift helper with zero and one node limits, without reading another app's UI. No granted-permission tree read or walkthrough was run for this change || DNS question boundaries | A question is retained only when its name, type and class are complete. A missing class byte marks the DNS message incomplete; preceding complete questions remain available, and incomplete questions do not enter the query inventory | Four packet regressions cover both truncation lengths, multiple questions, complete class values and the capture summary. No live capture was used || Reject impossible IPv4 header and total lengths | IPv4 decoding rejects impossible header lengths and reports incomplete base headers or options. | Synthetic byte fixtures in `pcap_ipv4_lengths` integration regressions. Cover 10–19 captured header bytes, total lengths below IHL, missing options, complete options, truncated transport headers with readable ports, and a cut UDP payload with both ports and its captured length preserved. || Validate the version in IPv6 frames | IPv6 decoding checks the packet version before reporting IPv6 facts, including captures declaring raw IPv6; explicit raw IPv4 likewise uses IPv4 validation. | Synthetic byte fixtures in `pcap_ipv6_version` integration regressions. Cover incorrect versions behind the IPv6 EtherType, mismatched explicit raw IPv4 and IPv6 link types, matching explicit and generic raw packets, and valid IPv6 traffic-class bits. |@@ -78,7 +79,7 @@ workspace clippy, layers, fmt and the secret scan of all history were clean. Chi| Games | Engine detection for 12 engines (Unreal, Unity, Godot, Source, GameMaker, RPG Maker, Ren'Py, MonoGame, LÖVE, CryEngine, Cocos, Cube) with versions. Unreal and Godot games are rebuilt in the same engine, others in Unity; installed engines are found, Godot installs itself, others get guided installs. Picking an inner folder (Engine, Binaries, Paks…) finds the game's folder. Just look inside a game shows what it's made of (`core_target_triage` on its folder: engine and version, how its code ships, the libraries its Unity assembly names give away, its own code, scenes and size) and opens it in the chat to ask about it. The builder keeps `app/MECHANICS.md` and its structured twin `app/mechanics.json` (checked after each build), in Deep mode only, may reuse the original's readable files for private use (never decrypting; generated pictures and 3D models replace its art when the person turns them on; Clean room copies none of its files), lists them in `CREDITS.md` (checked, with the private-use line in `README.md`); a game is ready only when its `--self-test` shows the player moving, acting and the HUD drawn, and the result can be started from the project page | Unit tests; live runs on Windows || Clean room and Deep mode | Clean room (the default) runs only the tools in `engine/src/clean_room.rs`: ones that touch no target or watch from outside (the website as a visitor sees it, pictures of a window, its controls, recorded runs, a phone's screen). Every other tool, a plugin's included, is refused in the app, CLI, MCP and agents, with a way to turn on Deep mode. A Clean room build studies an app or a game only from the person's pictures and words (and a picture of its window when runtime study is on); its builder's reads and commands go through an approval rule that keeps it out of the original's folder and site (with Claude Code, and with ACP agents for what they ask about; other agents aren't held to it, see roadmap R2.2). Deep mode (`deep_mode` in Settings, `--deep` for one CLI run) uses every tool: the builder sees them all, and a website's study also reads its JavaScript and watches its start page for ten seconds (capture/how-it-works.md). Ghidra adds its decompiler in Deep mode when it's installed: it is found, or installed after asking. Study starts one analysis of the main program, saved and shared with the builder's tool server through a lock file (up to 8 h, Java gets half the machine's memory or the amount set in Settings → Engines, 4 to 31 GB, four slow passes skipped). The builder must decompile before the build is checked; addresses the built-in analysis can't place go to Ghidra, which makes a function on demand (for this run only) where its analysis has none, e.g. code reached only through tables of pointers. Without Ghidra, Deep mode uses the built-in engines | Live runs with Ghidra 12.1.4 on Windows (a shared analysis, and a decompile in seconds on a large program). Live runs with Ghidra 12.2 on Linux x86-64 (decompiles by name in position-independent programs and shared libraries, whose addresses Ghidra moves). The guided install of Ghidra and its Java is offered on Linux and macOS too, but has only been tried on Windows. Clean room and Deep mode: engine, AI, MCP, CLI and app tests; no live Clean room build run yet || Auto mode | Settings → Safety, on by default. Builder actions go ahead without asking, except a fixed set that is never done unasked (deleting outside the project, system changes, publishing…); questions get "decide yourself"; asset spending stops at the budget | Unit tests |-| Generated assets | Off until the person turns them on for a game (the switch on Make and on the project, `project_assets_allow`, `rebuild --generate-assets`, saved in craft.json; turning it on without a fal.ai key asks for one); the brief and the asset tools need both that and a key. `assets_image_generate` (Nano Banana Pro by default) and `assets_model_generate` (picture → Tripo P1 low-poly GLB with a face limit) through the person's key for each asset provider (fal.ai today); per-project budget, $5 by default (`[assets] budget_usd` in config.toml); models and prices from the `assets.toml` table (picture model selectable: Nano Banana Pro, FLUX dev or schnell; priced per picture or per megapixel); every call reports its cost | Unit tests; a live 3D generation with a real key (picture, then model) with FLUX dev; Nano Banana Pro not yet run with a real key |+| Generated assets | Off until the person turns them on for a game (the switch on Make and on the project, `project_assets_allow`, `rebuild --generate-assets`, saved in craft.json; turning it on without a fal.ai key asks for one); the brief and the asset tools need both that and a key. `assets_image_generate` (Nano Banana Pro by default) and `assets_model_generate` (picture → Tripo P1 low-poly GLB with a face limit) through the person's key for each asset provider (fal.ai today), with agent apps and API-key builds alike; per-project budget, $5 by default (`[assets] budget_usd` in config.toml); models and prices from the `assets.toml` table (picture model selectable: Nano Banana Pro, FLUX dev or schnell; priced per picture or per megapixel); every call reports its cost | Unit tests; a live 3D generation with a real key (picture, then model) with FLUX dev; Nano Banana Pro not yet run with a real key; an API-key build not yet run with one || Claude Code builder | Runs the person's own `claude` in headless mode (Opus 5.5, high effort unless configured) with our MCP server, a permission-prompt tool and `core_person_ask`; preflights for our CLI (a build stops plainly if it's missing or won't start) and sign-in | Argument and stream-parser tests; live preflight; live builder turns; see [claude-code.md](claude-code.md) || Agents over ACP | Opt-in per backend (`acp = true`): Gemini CLI, Qwen Code, opencode, goose, Hermes and Maki in their ACP mode, one agent process per chat or build with our MCP server; Maki's ACP mode takes the backend's model (`cli_model`). In chat, permission requests become consent questions; in builds they go through the same approval policy as Claude Code's (inbox, Auto mode). While a saved session loads, replayed updates are withheld from the new turn | Protocol unit tests against scripted agent messages and an approval-policy test. Run live with Maki 0.7.0 only (2026-11-02, Linux, headless CLI): a static page built to Ready in 38 s, a follow-up continued the same session with `session/load`, and with Auto mode off its command and tool requests were refused in an unattended run. Replay suppression passes scripted load-history, success/error and cancellation tests; this correction has not been rerun with a live agent. Turns report 0 tokens over ACP || GitHub Copilot | Installed `copilot` through ACP by default, with CLI-owned login (no credential import), explicit Craft Anything MCP tool allowlist, model selection and fresh read-only build questions. Target handoff retains the last 128 entries with the active target last; context discovery respects tool cancellation and shared picker warnings name the agent | Authenticated builds, model discovery and real-account session resume confirmed by the person using the app. Target-boundary, cancellation and agent-warning regressions supplement unit tests and an offline CLI 1.0.105 compatibility test covering all five access modes. See [copilot.md](copilot.md) |@@ -320,7 +321,8 @@ laptops are covered by unit tests on fake `/sys/class/drm` folders only.words. With runtime study on, the original is also started once for apicture of its window and its UI tree (Windows and macOS); it isn't driven or watched over time.- Several projects build at once (`[build] parallel`, 2 by default; Settings → Builds); more wait- their turn. Queued builds start on their own as places come free, from MCP too.+ their turn. Queued builds start on their own as places come free, from MCP too. A build with an+ API key works alone, for now: it shares the app's session, so others wait for it and it for them.- Some flows exist only in the desktop app: the project feed, game-engine and Ghidra installs,and launching results (ROADMAP R1.6).- Engine gaps from the audit: Frida session tools are partly simulated; imports outside the