Skip to content

armgit / kwant

Public Imported from GitHub
0

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.

Human steps: add the two_factor kind

Linccc389fe7fde
diff --git a/src/db/human_steps.rs b/src/db/human_steps.rs
index 49a9436d..dbcb7b5c 100644
--- a/src/db/human_steps.rs
+++ b/src/db/human_steps.rs
@@ -14,7 +14,7 @@ pub const MAX_URL_CHARS: usize = 300;
/// Most open steps per agent; an agent can't flood the person.
pub const MAX_OPEN_PER_KWANT: i64 = 5;
-pub const HUMAN_STEP_KINDS: [&str; 3] = ["sign_in", "captcha", "other"];
+pub const HUMAN_STEP_KINDS: [&str; 4] = ["sign_in", "captcha", "two_factor", "other"];
/// "open", "done", "declined" or "cancelled" (its turn was stopped).
pub const HUMAN_STEP_STATUSES: [&str; 4] = ["open", "done", "declined", "cancelled"];
@@ -94,7 +94,7 @@ pub fn clean_url(raw: &str) -> Option<String> {
pub fn clean_request(kind: &str, reason: &str, url: Option<&str>) -> Result<(String, String, Option<String>), HumanStepError> {
let kind = kind.trim();
if !HUMAN_STEP_KINDS.contains(&kind) {
- return Err(HumanStepError::Invalid("kind must be sign_in, captcha or other".into()));
+ return Err(HumanStepError::Invalid("kind must be sign_in, captcha, two_factor or other".into()));
}
let reason = reason.split_whitespace().collect::<Vec<_>>().join(" ");
if reason.is_empty() {
@@ -134,7 +134,7 @@ impl Database {
direct_kwant_id TEXT,
thread_id TEXT,
turn_id TEXT,
- kind TEXT NOT NULL CHECK (kind IN ('sign_in', 'captcha', 'other')),
+ kind TEXT NOT NULL CHECK (kind IN ('sign_in', 'captcha', 'two_factor', 'other')),
reason TEXT NOT NULL,
url TEXT,
sandbox_target TEXT,
diff --git a/src/server/human_steps.rs b/src/server/human_steps.rs
index 064c6aaa..2f9098c6 100644
--- a/src/server/human_steps.rs
+++ b/src/server/human_steps.rs
@@ -107,6 +107,7 @@ fn kind_label(kind: &str) -> &'static str {
match kind {
"sign_in" => "Sign in needed",
"captcha" => "Human check needed",
+ "two_factor" => "Sign-in code needed",
_ => "Your help is needed",
}
}
@@ -192,8 +193,8 @@ pub async fn browser_is_held(state: &AppState, target: &str) -> bool {
// Agent tool
pub const DESCRIPTION: &str = "Ask the person to do one step in the bot browser that only they can do: sign in \
- (kind sign_in), solve a CAPTCHA or human check (kind captcha), or something else that needs them (kind other, \
- e.g. approve a 2FA prompt). Never ask for passwords or codes in chat; use this instead. The browser is handed to \
+ (kind sign_in), solve a CAPTCHA or human check (kind captcha), enter a one-time code or approve a 2FA prompt \
+ (kind two_factor), or something else that needs them (kind other). Never ask for passwords or codes in chat; use this instead. The browser is handed to \
them and your turn waits (a few minutes at most) until they press Done or Decline; the tool returns which. \
After Done, look at the page again before you continue.";
@@ -205,7 +206,7 @@ pub fn tools() -> Vec<Value> {
"type": "object",
"properties": {
"reason": {"type": "string", "description": "What to do and why, in one sentence (max 300 characters)"},
- "kind": {"type": "string", "enum": ["sign_in", "captcha", "other"]},
+ "kind": {"type": "string", "enum": ["sign_in", "captcha", "two_factor", "other"]},
"url": {"type": "string", "description": "The page it happens on (optional)"},
},
"required": ["reason", "kind"],