diff --git a/mobile/index.html b/mobile/index.html
index cb2e60c..ceee003 100644
--- a/mobile/index.html
+++ b/mobile/index.html
@@ -1948,7 +1948,7 @@ async function editInstructions(b, d) {
// ---------- 例行任務 ----------
function routineSheet(b, r) {
if (!r) return;
- const html = `
`;
+ const html = ``;
sheet("", !isOwner() ? [] : [
{icon: "play", label: "立即執行", on: () => app("run_routine_now", {id: r.id}, b.id, "已開始執行")},
{icon: r.paused ? "play" : "pause", label: r.paused ? "繼續" : "暫停", on: async () => { if (await app("update_routine", {id: r.id, paused: !r.paused}, b.id, r.paused ? "已繼續" : "已暫停")) refreshAfter(b); }},
diff --git a/src/agent.rs b/src/agent.rs
index fde59b6..84b743e 100644
--- a/src/agent.rs
+++ b/src/agent.rs
@@ -296,6 +296,11 @@ fn learn(job: &Job, history: &[Message], cancel: &AtomicBool, send: &dyn Fn(Stre
return;
}
};
+ let issues = crate::memory::learned_issues(&out.text);
+ if !issues.is_empty() {
+ eprintln!("AnyBot:Bot 回報了 {} 個 AnyBot 自己的問題", issues.len());
+ send(StreamEvent::Issues(issues));
+ }
match (crate::memory::learned_skill(&out.text), turn.last()) {
(Some(mut k), Some(reply)) => {
k.steps = crate::memory::replay_steps(turn, &crate::memory::learned_replay(&out.text));
@@ -985,6 +990,24 @@ fn maybe_compact(job: &Job, history: &mut Vec, percent: u64, cancel: &A
Some(cut)
}
+/// Longest browser_wait after_send (a spacing of up to a quarter of an hour).
+const AFTER_SEND_MAX_SECS: f64 = 900.0;
+
+/// browser_wait after_send: wait until `want` seconds have passed since `last` (this turn's last
+/// send). What to tell the bot; None when it was stopped while waiting.
+fn wait_after_send(last: Option, want: f64, cancel: &AtomicBool) -> Option {
+ let Some(t) = last else { return Some("這一輪還沒有送出過東西,不用等。".into()) };
+ let left = want.clamp(0.0, AFTER_SEND_MAX_SECS) - t.elapsed().as_secs_f64();
+ let until = Instant::now() + Duration::from_secs_f64(left.max(0.0));
+ while Instant::now() < until {
+ if cancel.load(Ordering::Relaxed) {
+ return None;
+ }
+ std::thread::sleep(Duration::from_millis(50));
+ }
+ Some(format!("距離上次送出已經 {} 秒{}。", t.elapsed().as_secs(), if left > 0.0 { format!("(等了 {} 秒)", left.ceil() as u64) } else { ",不用再等".to_string() }))
+}
+
/// What the tools' descriptions take of every request (estimated like the rest).
fn tools_tokens(tools: &[serde_json::Value]) -> u64 {
tools.iter().map(|t| estimate_tokens(&t.to_string())).sum()
@@ -1388,6 +1411,9 @@ pub fn spawn(job: Job, bot_id: u64, tx: Sender<(u64, StreamEvent)>, cancel: Arc<
// Every step's (tool, failed, what it said) this turn: a tool that keeps failing the same
// way, whatever it is given, is stopped (see same_failures).
let runs: std::cell::RefCell> = Default::default();
+ // When this turn last sent something out (evidence::sends): what browser_wait's
+ // after_send counts from, so posts keep the person's spacing without idle waiting.
+ let last_sent: std::cell::Cell