Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
30x: goal_propose runs without a card in a goal draft turn (#904)
Oleksandr Ivanchenko76e738420337
diff --git a/src/server/continuity.rs b/src/server/continuity.rsindex 97b85a95..ebc99f3e 100644--- a/src/server/continuity.rs+++ b/src/server/continuity.rs@@ -461,7 +461,8 @@ pub fn self_server(base_url: &str, token: &str) -> McpServer {}/// Lets calls to the agents' own tools through without a card; everything else goes to `inner`.-/// With `always_ask`, only the self tools that just read go through; the rest ask too.+/// With `always_ask`, only the self tools that just read, a note and a goal draft go through; the+/// rest ask too.pub struct SelfToolsApprover {pub inner: Arc<dyn ToolApprover>,pub always_ask: bool,@@ -529,6 +530,8 @@ impl ToolApprover for SelfToolsApprover {|| READ_ONLY_SELF_TOOLS.contains(&req.tool.as_str())// P5: a note changes nothing outside kwant and the person checks every one|| req.tool == super::tool_notes::TOOL+ // A goal proposal only writes a draft; the person approves it on the board (30x)+ || req.tool == super::goals::tool::TOOL|| super::missions::auditor::take_retry(&req.kwant_id, &req.tool, &req.arguments);if req.server == SELF_SERVER_NAME && free {// Flight School: a tier below act cards kwant's own tools that change thingsdiff --git a/tests/approvals_off_test.rs b/tests/approvals_off_test.rsindex d84c9fbe..a3e8bc14 100644--- a/tests/approvals_off_test.rs+++ b/tests/approvals_off_test.rs@@ -601,3 +601,35 @@ async fn a_local_command_runs_without_a_card_when_off() {.await;assert!(waiting.is_err(), "it should wait for the person");}++/// 30x: the goal draft turn (Mission board > New goal > Draft checks) asks always, like a turn+/// kwant starts on its own. `goal_propose` only writes a draft the person approves on the board, so+/// it runs without a card there: before, it waited on a hidden "Allow once" card in the bot's DM+/// while the board said Needs you 0. A tool that changes something still asks in the same turn.+#[tokio::test]+async fn a_goal_draft_turn_proposes_without_a_card_and_still_asks_for_a_write() {+ let e = setup().await;+ let draft = || mcp_runtime::TurnApprovalOpts { always_ask: true, started_by: Some("Goal draft".into()), ..Default::default() };+ let self_name = |name: &str| format!("mcp__{}__{name}", kwnt::mcp::SELF_SERVER_NAME);+ let args = json!({"title": "Report exists", "checks": [{"kind": "file_exists", "spec": {"path": "report.md"}}]});++ let asked = ask_with(&e, &e.bot, &self_name("goal_propose"), args.clone(), draft()).await;+ assert_eq!(asked, Ok(true), "goal_propose runs without a card in a goal draft turn");+ let away = get(&e, "/api/away").await;+ assert!(away["waiting"].as_array().unwrap().iter().all(|i| i["kind"] != "approval"), "{away}");++ // The call it allowed writes the draft, which waits for the person on the board+ let (turn_id, token, _folder) = turn_with(&e, &e.bot, draft()).await;+ let (text, err) = self_tool(&e, &token, "goal_propose", args).await;+ mcp_runtime::finish_turn(&e.state, &token).await;+ e.state.turns.end_turn(&turn_id);+ assert!(!err, "{text}");+ assert_eq!(e.state.db.count_draft_goals("spc_default").await.unwrap(), 1);+ let goal_id = serde_json::from_str::<Value>(&text).unwrap()["goal_id"].as_str().unwrap().to_string();+ assert_eq!(e.state.db.get_goal(&goal_id).await.unwrap().unwrap().status, "draft");++ // A tool that changes something still asks in the same kind of turn, and says who started it+ let card = ask_with(&e, &e.bot, &self_name("memory_add"), json!({"text": "x"}), draft()).await.expect_err("a write asks");+ assert_eq!(card["always_ask"], true, "{card}");+ assert_eq!(card["started_by"], "Goal draft", "{card}");+}