🤖 Open-source, local-first alternative to Grok Bot, OpenAI dots and Claude Duet. Your own AI bots on any model: GPT, Claude, Gemini, Grok, DeepSeek, Kimi, GLM and 70+ more through one Modelflare key. Reach them in the app, WeChat or Feishu; they remember you, work in the background, run commands and use your computer. Pay per use.
Python ai-agentai-assistantchatbotclaudecomputer-usedeepseekdesktop-appdshelectronfeishugeminigptgrokllmlocal-firstmodelflaremulti-modelopenai-compatiblepersonal-ai-agentwechat
Tasks: one switch to pause a bot's background work
Marlab5c4c4a9e66b
diff --git a/docs/design/background-tasks-and-proactive.md b/docs/design/background-tasks-and-proactive.mdindex 227649f..aecb934 100644--- a/docs/design/background-tasks-and-proactive.md+++ b/docs/design/background-tasks-and-proactive.md@@ -391,6 +391,7 @@ Expanding a row shows the Report (summary, message, would-do), the steps, the ru| Progress | never pushed || Budgets | task $1.00, rule run $0.10, rule $3.00 per month (Q3) || Automatic pause | a rule after 3 failures in a row; background work when the bot's Modelflare budget falls below 20 % |+| Manual pause | one switch per bot (bot settings › 主动消息, the info panel's 「后台工作已暂停」 line, or asking the bot): no new task runs, scheduled rules are logged as skipped and not caught up, pushes wait; chat and running turns carry on || Observe → act hint | after 3 observed runs, shown in place, never pushed || Desktop notifications | needs-you only, window unfocused, once per item |diff --git a/dsh-runtime/plugins/amb-tasks.mjs b/dsh-runtime/plugins/amb-tasks.mjsindex 894df99..cc9d99a 100644--- a/dsh-runtime/plugins/amb-tasks.mjs+++ b/dsh-runtime/plugins/amb-tasks.mjs@@ -9,7 +9,8 @@// - registers task_report, which reports the task's state to the host (needs_you carries one question for the// user; the host asks it and hands the answer back as the session's next input),// - refuses every tool call once the host has stopped the task.-// Chat sessions get task_start / task_message / task_list and rule_create / rule_update; subagents get none of them.+// Chat sessions get task_start / task_message / task_list, rule_create / rule_update and background_pause (pause or+// resume all of the bot's background work); subagents get none of them.//// Rule sessions (`rule-<rule>-<run>`, one fresh session per run of a standing rule, 3d) are decorated from the host's// answer to /dsh/task-config (the host owns the mode): the denied tools (observe denies everything that acts), the rule@@ -30,7 +31,7 @@ export const inject = ['tools']/** Shared with amb-control: control-channel ops this plugin answers. */export const HANDLERS = Symbol.for('amb.control.handlers')-export const CHAT_TOOLS = ['task_start', 'task_message', 'task_list', 'rule_create', 'rule_update']+export const CHAT_TOOLS = ['task_start', 'task_message', 'task_list', 'rule_create', 'rule_update', 'background_pause']/** Tools a task session never gets (filtered to registered names before tools.restrict). */export const TASK_DENY = ['present', 'ask_user_question', ...CHAT_TOOLS]/** Shared with amb-permission: sessionId → DSH permission preset for rule sessions (and their subagents). */@@ -149,6 +150,15 @@ export function apply(ctx) {output: TEXT_OUT,execute: tool('rule_update'),}))+ ctx.tools.register(defineTool({+ name: 'background_pause',+ description: 'Pause or resume all of this bot\'s background work when the user asks. Paused: no task or rule runs, pushed messages wait; chat still works.',+ parameters: {+ paused: { type: 'boolean', required: true },+ },+ output: TEXT_OUT,+ execute: tool('pause'),+ }))}const known = (names) => {diff --git a/src/agent/settings.ts b/src/agent/settings.tsindex 0ca9336..faf6e2d 100644--- a/src/agent/settings.ts+++ b/src/agent/settings.ts@@ -53,6 +53,11 @@ export interface BotSettings {quietHours: QuietHours;/** 微信续期提醒:24 小时窗口快关时,还有消息要发就请用户回一句 */nudge: boolean;+ /**+ * 暂停后台工作:不开始新的任务 run(排着的等着),规则到点不跑(记为跳过、之后不补),主动消息排着等恢复;+ * 聊天照常,正在跑的那一轮照常做完(tasks/service.ts setPaused、core/delivery.ts)+ */+ paused: boolean;}export const DEFAULT_SETTINGS: BotSettings = {@@ -67,6 +72,7 @@ export const DEFAULT_SETTINGS: BotSettings = {taskSlots: 2,quietHours: { ...DEFAULT_QUIET },nudge: true,+ paused: false,};export function normalizeSettings(raw: unknown): BotSettings {@@ -109,6 +115,7 @@ export function normalizeSettings(raw: unknown): BotSettings {to: typeof qh.to === "string" && minuteOf(qh.to) !== undefined ? qh.to : DEFAULT_QUIET.to,},nudge: b(r.nudge, DEFAULT_SETTINGS.nudge),+ paused: b(r.paused, DEFAULT_SETTINGS.paused),};}diff --git a/src/core/delivery.ts b/src/core/delivery.tsindex 1c6788e..ad65eef 100644--- a/src/core/delivery.ts+++ b/src/core/delivery.ts@@ -11,6 +11,8 @@* - 微信续期提醒:24 小时窗口关闭前约 2 小时,窗口关闭后还有东西要发给这个人时,发一句「回个 ok」;* 每个窗口最多一次,免打扰时不发,用掉 10 条里的 1 条,可按机器人关掉;没有要发的就不发。* - 没送到的(微信要对方先发消息、一直失败、放弃了)是「需要你」里的一项(attentionItems),原因没了就自己消失。+ * - 暂停后台工作(机器人设置 paused):主动消息都排着(reason paused),对方发消息时也不放,不发续期提醒;+ * 恢复时(resume)马上按上面的规则重新排。聊天里的回复不受影响。** 给 3b / 3d 的接口:addReserver(占配额)、addUpcoming(续期提醒里列出要来的规则)、attentionItems / act / onChange。*/@@ -44,6 +46,8 @@ const NUDGE_TICK_MS = 15 * 60_000;export const FAILS_FOR_ATTENTION = 3;/** 放弃了的、没处理掉的,在「需要你」里留多久 */const GONE_SHOWN_MS = 7 * 86400_000;+/** 暂停时排着的主动消息隔多久再看一次(恢复时由 resume 马上放出来,这只是兜底) */+const PAUSED_RECHECK_MS = 3600_000;/** 摘要一条最长多少字(微信一条 4000 字,留余地) */const DIGEST_MAX = 3500;@@ -190,7 +194,7 @@ export class Delivery {private offOutbox: (() => void) | undefined;constructor(private o: DeliveryOptions) {- o.outbox.planner = { promote: (rows, now) => this.promote(rows, now) };+ o.outbox.planner = { promote: (rows, now) => this.promote(rows, now), waits: (r) => (r.purpose && this.paused(r.botId) ? "paused" : undefined) };}private get store(): Store {@@ -203,6 +207,21 @@ export class Delivery {return this.o.timeZone ?? systemTimeZone();}+ /** 这个机器人的后台工作暂停了(机器人设置 paused):主动消息排着,对方发消息时也不放,恢复后按平常的规则发 */+ paused(botId: string): boolean {+ return !!this.store.getBot(botId)?.settings?.paused;+ }++ /** 后台工作恢复了:因为暂停排着的主动消息马上重新排(免打扰、每天上限、合并照旧) */+ resume(botId: string): number {+ const now = this.now();+ const rows = this.store.listOutbox({ botId, status: "scheduled", limit: 500 }).filter((r) => r.reason === "paused");+ for (const r of rows) this.store.updateOutbox(r.id, { due: now }, now);+ if (rows.length) log.info("background work resumed; pushes that waited go out", { bot: botId, count: rows.length });+ this.o.outbox.wake();+ return rows.length;+ }+/** 这个机器人的免打扰时段与续期提醒开关 */settingsOf(botId: string): { quiet: QuietHours; nudge: boolean } {const s: Partial<BotSettings> | undefined = this.store.getBot(botId)?.settings;@@ -248,6 +267,8 @@ export class Delivery {/** 什么时候发:免打扰 → 每天上限 → 合并(离上一条不到 2 分钟就等,和排着的一起发) */plan(p: Peer, purpose: OutboxPurpose, anytime: boolean, now: number): { due: number; reason: string } {+ // 后台工作暂停了:排着,恢复时再按下面的规则排(resume)+ if (this.paused(p.botId)) return { due: now + PAUSED_RECHECK_MS, reason: "paused" };const { quiet } = this.settingsOf(p.botId);const tz = this.timeZone;const free = anytime || this.awake(p, now);@@ -296,6 +317,7 @@ export class Delivery {const r0 = rows[0];if (!r0.purpose || r0.purpose === "nudge") return rows.map((r) => ({ rows: [r] }));const p = peerOf(r0.botId, r0.channel, r0.peerId);+ if (this.paused(p.botId)) return { later: now + PAUSED_RECHECK_MS, reason: "paused" };const { quiet } = this.settingsOf(p.botId);const anytime = rows.every((r) => r.body.anytime);if (!anytime && !this.awake(p, now) && inQuiet(now, quiet, this.timeZone)) return { later: quietEnd(now, quiet, this.timeZone), reason: "quiet_hours" };@@ -405,7 +427,7 @@ export class Delivery {let next = now + NUDGE_TICK_MS;for (const bot of this.store.listBots()) {const st = this.settingsOf(bot.id);- if (!bot.weixinEnabled || !st.nudge) continue;+ if (!bot.weixinEnabled || !st.nudge || this.paused(bot.id)) continue;const quota = new WeixinQuota(this.store, bot.id, () => now);for (const peer of this.store.listWeixinPeers(bot.id)) {const close = peer.windowStartedAt + QUOTA_WINDOW_MS;diff --git a/src/core/outbox.ts b/src/core/outbox.tsindex 76f615a..f81b71c 100644--- a/src/core/outbox.ts+++ b/src/core/outbox.ts@@ -80,6 +80,8 @@ export interface HeldGroup {/** 排着的消息到时间了(同一会话的一批):返回 later 就再排到那时,否则返回怎么合成 */export interface OutboxPlanner {promote(rows: OutboxRow[], now: number): { later: number; reason: string } | HeldGroup[];+ /** 这条现在不能发、对方发消息时也不放(机器人的后台工作暂停了):返回原因,排着等 */+ waits?(row: OutboxRow): string | undefined;}/** 渠道的发送函数:成功返回;Later / Gone / 其他错误(临时失败,会重试)。progress 记下长文本已发出的分段数 */@@ -247,7 +249,8 @@ export class Outbox {const waiting = this.store.waitingOutbox(conv);if (!waiting.length) return 0;const now = this.now();- const live = waiting.filter((r) => r.expiresAt > now || (this.gone(r, tr("delivery.goneTooLong")), false));+ const live = waiting.filter((r) => (r.expiresAt > now || (this.gone(r, tr("delivery.goneTooLong")), false)) && !this.planner?.waits?.(r));+ if (!live.length) return 0;this.apply(combine ? combine(live) : live.map((r): HeldGroup => ({ rows: [r] })), now, "inbound");if (live.length) log.info(`releasing ${live.length} waiting message(s)`, { bot: botId, channel });this.kick();@@ -324,6 +327,14 @@ export class Outbox {if (heads.has(row.conversationId)) continue;heads.add(row.conversationId);if (this.inflight.has(row.conversationId)) continue;+ // 主动消息现在不能发(机器人的后台工作暂停了):改成排着,不挡这个会话后面的回复+ const wait = row.purpose ? this.planner?.waits?.(row) : undefined;+ if (wait) {+ this.store.updateOutbox(row.id, { status: "scheduled", due: now + MAX_SLEEP_MS, reason: wait }, now);+ this.changed(row.id);+ this.kick();+ continue;+ }if (row.expiresAt <= now) {this.gone(row, row.error ? tr("delivery.goneKeptFailing", { error: row.error }) : tr("delivery.goneTooLong"));this.kick();diff --git a/src/i18n/messages/rules.ts b/src/i18n/messages/rules.tsindex b51e2e5..f674053 100644--- a/src/i18n/messages/rules.ts+++ b/src/i18n/messages/rules.ts@@ -46,6 +46,7 @@ export const zh = {whyBusy: "一直在忙",whyOverlap: "上次还没跑完",whyRestart: "应用重启了",+ whyPaused: "后台工作已暂停",whyTimeout: "超时",whyApprovalTimeout: "批准超时",// 「需要你」@@ -75,6 +76,7 @@ export const zh = {eventNoSchedule: "这条规则由事件触发,没有时间表",remindNoObserve: "提醒没有观察模式",isOff: "规则关着",+ isPaused: "后台工作已暂停",isRunning: "正在运行",// 时间表的报错(tasks/schedule.ts normalizeSchedule)needTime: "缺少时间",@@ -126,6 +128,7 @@ export const en: Catalog<typeof zh> = {whyBusy: "no free slot",whyOverlap: "the last run was still going",whyRestart: "the app restarted",+ whyPaused: "background work was paused",whyTimeout: "timed out",whyApprovalTimeout: "approval timed out",subject: "Rule “{title}”",@@ -150,6 +153,7 @@ export const en: Catalog<typeof zh> = {eventNoSchedule: "This rule runs on events and has no schedule",remindNoObserve: "Reminders have no observe mode",isOff: "The rule is off",+ isPaused: "Background work is paused",isRunning: "Already running",needTime: "Pick a time",pastTime: "That time has passed",diff --git a/src/i18n/messages/tasks.ts b/src/i18n/messages/tasks.tsindex 832b8b8..e21b689 100644--- a/src/i18n/messages/tasks.ts+++ b/src/i18n/messages/tasks.ts@@ -31,6 +31,7 @@ export const zh = {latestSuffix: ":{text}",listHead: "后台任务:",stopHint: "发 /stop 编号 可停止。",+ pausedLine: "后台工作已暂停,跟我说一声就恢复。",noSuchIndex: "没有第 {n} 个后台任务,发 /tasks 查看。",alreadyStage: "「{title}」{stage}。",stoppedTask: "已停止后台任务「{title}」。",@@ -71,6 +72,7 @@ export const en: Catalog<typeof zh> = {latestSuffix: ": {text}",listHead: "Background tasks:",stopHint: "Send /stop <number> to stop one.",+ pausedLine: "Background work is paused; ask me to resume it.",noSuchIndex: "There's no background task {n}; send /tasks to see the list.",alreadyStage: "\"{title}\": {stage}.",stoppedTask: "Stopped the background task \"{title}\".",diff --git a/src/tasks/rules.ts b/src/tasks/rules.tsindex 12cfee0..d0d6364 100644--- a/src/tasks/rules.ts+++ b/src/tasks/rules.ts@@ -28,7 +28,7 @@ export const RULE_APPROVAL_TTL_MS = 3600_000;* 规则会话去掉的工具(只去掉注册了的;插件按 tools.restrict 的规矩过滤)。观察:能改变什么的都去掉,记忆只留 recall;* 执行:上限是可写工作区(决定 12),电脑操作和生图、生视频不给(设计第 7 节:除非规则上开了,3d 不做这个开关)。*/-const COMMON_DENY = ["present", "ask_user_question", "task_start", "task_message", "task_list", "rule_create", "rule_update", "generate_image", "generate_video", "media_models", "media_docs"];+const COMMON_DENY = ["present", "ask_user_question", "task_start", "task_message", "task_list", "rule_create", "rule_update", "background_pause", "generate_image", "generate_video", "media_models", "media_docs"];export const RULE_DENY: Readonly<Record<"observe" | "act", string[]>> = {observe: [...COMMON_DENY, "remember", "forget"],act: COMMON_DENY,@@ -107,6 +107,7 @@ export const RUN_ERROR = {busy: "busy",overlap: "overlap",restart: "restart",+ paused: "paused",timeout: "timeout",approvalTimeout: "approval_timeout",noReport: "no_report",@@ -121,6 +122,7 @@ const WHY: Record<string, MessageKey> = {busy: "rules.whyBusy",overlap: "rules.whyOverlap",restart: "rules.whyRestart",+ paused: "rules.whyPaused",timeout: "rules.whyTimeout",approval_timeout: "rules.whyApprovalTimeout",no_report: "tasks.noResult",diff --git a/src/tasks/service.ts b/src/tasks/service.tsindex 9867208..de9279d 100644--- a/src/tasks/service.ts+++ b/src/tasks/service.ts@@ -505,10 +505,47 @@ export class TaskService {return this.o.host.settings(botId).taskSlots;}- /** 有空名额就开始排队的 run(人的唤醒在前,见 slots.ts) */+ // ---------- 暂停后台工作 ----------++ /** 这个机器人的后台工作暂停了(机器人设置 › 主动消息、信息面板、聊天代理的 background_pause) */+ paused(botId: string): boolean {+ return !!this.store.getBot(botId)?.settings.paused;+ }++ /**+ * 暂停、恢复后台工作:暂停时不开始新的 run(任务的排着等,规则到点记为跳过、之后不补),主动消息排着(core/delivery.ts);+ * 聊天照常,正在跑的那一轮照常做完。恢复时排着的 run 开始、排着的主动消息按平常的规则发(免打扰、每天上限照旧)。+ */+ setPaused(botId: string, paused: boolean, by: string): boolean {+ const bot = this.store.getBot(botId);+ if (!bot) return false;+ if (bot.settings.paused === paused) return true;+ this.store.updateBot(botId, { settings: { ...bot.settings, paused } });+ log.info(paused ? "background work paused" : "background work resumed", { bot: botId, by });+ if (!paused) {+ this.o.delivery?.resume(botId);+ this.pump();+ }+ this.scheduler.wake();+ this.changed(botId);+ return true;+ }++ /** 暂停时排着的 run:任务的等恢复;规则的这次记为跳过(暂停),之后不补。返回 true = 现在不开始 */+ private heldByPause(run: RunRow): boolean {+ if (!this.paused(run.botId)) return false;+ if (run.ruleId) {+ this.store.updateRun(run.id, { state: "ended", outcome: "skipped", error: RUN_ERROR.paused, endedAt: this.now() });+ log.info("rule run skipped: background work is paused", { rule: run.ruleId, run: run.id });+ this.changed(run.ruleId);+ }+ return true;+ }++ /** 有空名额就开始排队的 run(人的唤醒在前,见 slots.ts);后台工作暂停了的机器人不开始新的 */pump(): void {if (!this.started || this.closing) return;- const queued = this.store.listRuns({ states: ["queued"] }).filter((r) => (r.taskId || (r.ruleId && !this.skipStale(r))) && !this.dropped.has(r.botId));+ const queued = this.store.listRuns({ states: ["queued"] }).filter((r) => (r.taskId || (r.ruleId && !this.skipStale(r))) && !this.dropped.has(r.botId) && !this.heldByPause(r));if (!queued.length) return;// 等批准的 run 让出名额(DSH 那次调用照样等着,批了就接着做)const blocked = new Set((this.o.approvals?.pendingAll() ?? []).filter((a) => a.taskId && a.blocking && a.kind === "approval").map((a) => a.taskId));@@ -911,6 +948,8 @@ export class TaskService {case "start": {const r = this.create({ botId, conversationId: conv.id, title: String(a.title ?? ""), brief: String(a.brief ?? ""), budgetUsd: Number(a.budget_usd) || undefined, anytime: a.anytime === true });if (!r.task) return { error: r.error };+ if (this.paused(botId))+ return { text: `Queued background task ${r.task.id} 「${r.task.title}」, but background work is paused, so it starts only when the user resumes it. Tell the user so in one sentence. Do not do the task yourself.` };return {text: `Started background task ${r.task.id} 「${r.task.title}」 in folder ${r.task.folder}. In your reply, tell the user in one sentence what now runs in the background and that they will hear back when it is done; they can keep chatting. Do not do the task yourself.`,};@@ -926,9 +965,11 @@ export class TaskService {case "list": {const list = this.list({ conversationId: conv.id, limit: 10 });const rules = this.listRules({ conversationId: conv.id });- if (!list.length && !rules.length) return { text: "This conversation has no background tasks or rules." };+ const paused = this.paused(botId) ? ["Background work is paused: no task or rule runs, pushed messages wait."] : [];+ if (!list.length && !rules.length) return { text: [...paused, "This conversation has no background tasks or rules."].join("\n") };return {text: [+ ...paused,...list.map((t) => `${t.id} 「${t.title}」 ${t.stage.label}${t.latest ? ` — ${t.latest}` : ""}`),...rules.map((r) => `rule ${r.id} 「${r.title}」 ${r.when} · ${r.state.label}${r.last ? ` — ${r.last.line}` : ""}`),].join("\n"),@@ -938,6 +979,14 @@ export class TaskService {return this.ruleCreateTool(conv, a);case "rule_update":return this.ruleUpdateTool(conv, a);+ case "pause": {+ const paused = a.paused === true;+ if (typeof a.paused !== "boolean") return { error: "paused must be true or false" };+ const was = this.paused(botId);+ this.setPaused(botId, paused, `chat:${conv.id}`);+ if (paused) return { text: `${was ? "Background work was already paused" : "Paused this bot's background work"}: no task or rule runs, pushed messages wait; chat still works. Tell the user in one short sentence.` };+ return { text: `${was ? "Resumed background work: waiting tasks start and held messages go out" : "Background work was not paused; nothing changed"}. Tell the user in one short sentence.` };+ }default:return { error: "unknown task tool" };}@@ -1148,12 +1197,14 @@ export class TaskService {listText(conversationId: string): string {const list = this.list({ conversationId, limit: 10, since: this.now() - 7 * 86400_000 });const rules = this.activeRules(conversationId);- if (!list.length && !rules.length) return tr("tasks.none");+ const conv = this.store.getConversation(conversationId);+ const paused = conv && this.paused(conv.botId) ? [tr("tasks.pausedLine")] : [];+ if (!list.length && !rules.length) return [tr("tasks.none"), ...paused].join("\n");const lines = list.map((x, i) => `${i + 1}. ${x.title} · ${x.stage.label}${x.latest ? tr("tasks.latestSuffix", { text: clip(x.latest, 40) }) : ""}`);// 规则接着编号(/stop 编号 关掉它),和任务同一种写法:标题 · 状态:时间表const ruleLines = rules.map((r, i) => `${list.length + i + 1}. ${r.title} · ${r.state.label}${tr("tasks.latestSuffix", { text: r.when })}`);const working = list.findIndex((x) => x.stage.group === "working");- return [...(list.length ? [tr("tasks.listHead"), ...lines] : []), ...(rules.length ? [tr("rules.listHead"), ...ruleLines] : []), ...(working >= 0 || rules.length ? [tr("tasks.stopHint")] : [])].join("\n");+ return [...(list.length ? [tr("tasks.listHead"), ...lines] : []), ...(rules.length ? [tr("rules.listHead"), ...ruleLines] : []), ...(working >= 0 || rules.length ? [tr("tasks.stopHint")] : []), ...paused].join("\n");}/** /tasks 里列出的规则:开着的(关了的、跑完了的一次性规则不列) */@@ -1343,6 +1394,7 @@ export class TaskService {const rule = this.store.getRule(id);if (!rule) return { error: "rule not found" };if (rule.mode === "off") return { error: tr("rules.isOff") };+ if (this.paused(rule.botId)) return { error: tr("rules.isPaused") };if (this.ruleBusy(id)) return { error: tr("rules.isRunning") };this.fireRule(rule, "manual", this.now());this.pump();@@ -1386,6 +1438,11 @@ export class TaskService {continue;}if (last > due) this.skipRun(rule, due, RUN_ERROR.appOff);+ // 后台工作暂停了:这次记为跳过,恢复后不补+ if (this.paused(rule.botId)) {+ this.skipRun(rule, last, RUN_ERROR.paused);+ continue;+ }this.fireRule(rule, "schedule", last);}this.pump();@@ -1402,6 +1459,10 @@ export class TaskService {for (const rule of this.store.listRules()) {if (rule.trigger.kind !== "event" || rule.trigger.source !== source || rule.mode === "off" || rule.pausedReason || this.dropped.has(rule.botId)) continue;if (!matchesFilter(rule.trigger.filter, event)) continue;+ if (this.paused(rule.botId)) {+ this.skipRun(rule, now, RUN_ERROR.paused);+ continue;+ }if (this.fireRule(rule, "event", now, { source, event })) out.push(rule.id);}if (out.length) {diff --git a/src/web/server.ts b/src/web/server.tsindex af8761f..735367f 100644--- a/src/web/server.ts+++ b/src/web/server.ts@@ -773,7 +773,10 @@ export async function startWebServer(app: App, opts: { port?: number; host?: strmemory: { ...cur.memory, ...(b.memory ?? {}) },steward: { ...cur.steward, ...(b.steward ?? {}) },});- const next = app.store.updateBot(id, { settings: merged })!;+ app.store.updateBot(id, { settings: merged });+ // 暂停 / 恢复后台工作:恢复时排着的 run、主动消息要放出来,经任务服务改+ if (typeof b.paused === "boolean") app.tasks.setPaused(id, b.paused, "web");+ const next = app.store.getBot(id)!;return send(res, 200, { settings: next.settings, computerUse: app.agent.computerUse(id) });}if (sub === "budget" && m === "PUT") {diff --git a/test/agent.integration.test.ts b/test/agent.integration.test.tsindex a043500..e8a72bc 100644--- a/test/agent.integration.test.ts+++ b/test/agent.integration.test.ts@@ -438,7 +438,8 @@ describe.skipIf(!runtime || !hasBwrap || process.platform !== "linux")("agent hoconst DEFAULT_PERSONA = "你是一个乐于助人的中文助手,回答简洁准确。";/*** 系统提示词加工具定义的字符数上限(DSH 自己的部分 + 我们的人设、机器人段和工具;基线 34,052 = 提示词 3,692 + 工具 30,360,其中后台任务的 task_start、task_message、task_list 约 1,460;- * 3b、3c 之后 34,289;3d 加上规则的 rule_create、rule_update 后 35,649 = 提示词 3,692 + 工具 31,957(多了 1,360);上限高约 5%)。+ * 3b、3c 之后 34,289;3d 加上规则的 rule_create、rule_update 后 35,649 = 提示词 3,692 + 工具 31,957(多了 1,360);上限高约 5%;+ * 暂停开关 background_pause 之后 35,960 = 提示词 3,692 + 工具 32,268(多了 311),还在上限之内)。* 缩短了就调低;要调高,在提交说明里写清原因。电脑操作的 MCP 工具随平台变化,不计入。*/const SURFACE_BUDGET = 37_400;diff --git a/test/delivery.unit.test.ts b/test/delivery.unit.test.tsindex 266dabe..91bae98 100644--- a/test/delivery.unit.test.ts+++ b/test/delivery.unit.test.ts@@ -412,6 +412,49 @@ describe("续期提醒(「回个 ok」)", () => {});});+describe("暂停后台工作:主动消息排着等恢复,聊天回复照常", () => {+ let r: ReturnType<typeof rig>;+ afterEach(() => r.close());++ it("暂停时推的排着(对方发消息也不放)、没发出去的改成排着,不挡后面的回复;不发续期提醒;恢复后按平常的规则发", async () => {+ r = rig("2026-11-06T10:00");+ r.store.ensureConversation("b", "weixin", "u1");+ r.store.upsertWeixinPeer({ botId: "b", userId: "u1", contextToken: "ctx", quotaRemaining: 6, windowStartedAt: at("2026-11-06T10:00") });+ r.delivery.addUpcoming(() => [{ label: "天气", at: at("2026-11-08T08:00"), kind: "rule" }]);+ // 暂停前就在等着重发的一条结果(渠道一直失败)+ r.onFail((row) => (row.id === "early" ? new Error("网络断了") : undefined));+ r.push("early", "早一点的结果", { anytime: true });+ await r.settle();+ expect(r.store.getOutbox("early")).toMatchObject({ status: "pending", attempts: 1 });+ r.onFail(undefined);+ r.settings({ paused: true });+ expect(r.push("a", "A 好了", { anytime: true })).toMatchObject({ reason: "paused" });+ expect(r.store.getOutbox("a")).toMatchObject({ status: "scheduled", reason: "paused" });+ // 那条在等重发的改成排着;后面的聊天回复照常马上发+ await r.go("2026-11-06T10:01");+ await r.outbox.send({ id: "reply", botId: "b", channel: "weixin", peerId: "u1", kind: "text", body: { text: "聊天回复" } });+ await r.settle();+ expect(r.texts()).toEqual(["聊天回复"]);+ expect(r.store.getOutbox("early")).toMatchObject({ status: "scheduled", reason: "paused" });+ // 对方发消息:不放+ expect(r.outbox.release("b", "weixin", "u1", (rows) => r.delivery.combine(rows))).toBe(0);+ await r.settle();+ expect(r.texts()).toEqual(["聊天回复"]);+ // 到了续期提醒的时间也不发;到了该再看一遍的时间还在暂停,再排+ await r.go("2026-11-07T08:00");+ r.delivery.tick();+ await r.settle();+ expect(r.texts()).toEqual(["聊天回复"]);+ expect(r.store.getOutbox("a")).toMatchObject({ status: "scheduled", reason: "paused" });+ // 恢复:排着的按平常的规则发出去(两条一起到,合成一条)+ r.settings({ paused: false });+ expect(r.delivery.resume("b")).toBe(2);+ await r.settle();+ expect(r.texts()).toEqual(["聊天回复", "2 个后台任务:\n· 早一点的结果\n· A 好了"]);+ expect(r.delivery.attentionItems()).toEqual([]);+ });+});+describe("「需要你」里的未送达", () => {let r: ReturnType<typeof rig>;afterEach(() => r.close());diff --git a/test/e2e.test.ts b/test/e2e.test.tsindex 5e06f2a..ea0da39 100644--- a/test/e2e.test.ts+++ b/test/e2e.test.ts@@ -225,6 +225,10 @@ describe("Web 界面 / API", () => {expect(c.json.bot.settings.avatar).toBe("red");expect((await api(`/bots/${id}/settings`, { method: "PUT", body: { avatar: "purple" } })).json.settings.avatar).toBe("purple");expect((await api(`/bots/${id}/settings`, { method: "PUT", body: { avatar: "pink" } })).json.settings.avatar).toBe("");+ // 暂停后台工作:经任务服务改,机器人详情里带着(信息面板据此显示那一行)+ expect((await api(`/bots/${id}/settings`, { method: "PUT", body: { paused: true } })).json.settings).toMatchObject({ paused: true, avatar: "" });+ expect((await api(`/bots/${id}`)).json.bot.settings.paused).toBe(true);+ expect((await api(`/bots/${id}/settings`, { method: "PUT", body: { paused: false } })).json.settings.paused).toBe(false);expect((await api("/bots/default")).json.bot.settings.avatar).toBe("blue");const f = await api(`/bots/${id}/feishu`, { method: "PUT", body: { appId: "cli_x", appSecret: "very-secret-value" } });expect(f.status).toBe(200);diff --git a/test/prompts.unit.test.ts b/test/prompts.unit.test.tsindex 87788c6..82f41da 100644--- a/test/prompts.unit.test.ts+++ b/test/prompts.unit.test.ts@@ -135,6 +135,7 @@ async function parts(): Promise<Record<string, string>> {"tool task_report": runtime ? JSON.stringify((await loadPlugins()).task.tools.find((t) => t.name === "task_report") ?? "") : "","tool rule_create": tool("rule_create"),"tool rule_update": tool("rule_update"),+ "tool background_pause": tool("background_pause"),"rule observe": ruleRules("observe"),"rule act": ruleRules("act"),"rule brief": ruleBrief({ title: "看 X 价格", when: "每天 08:00", instruction: "每天早上 8 点看看 X 的价格,低于 200 告诉我", mode: "observe", recent: [{ at: "11月1日 08:00", line: "没有告诉用户。X 现在 ¥259" }], memory: "" }),@@ -192,6 +193,7 @@ const RULES: [rule: string, part: string, says: string[], gone?: string[]][] = [// —— 规则(3d):检查从观察开始,只在值得说时说一句;观察只看不动;执行最多可写工作区 ——["rule_create:用户原话原样;检查从观察开始只记录;提醒到点发那句;确认一句", "tool rule_create", ["verbatim", "starts in observe mode", "only recording what it would say", "kind remind", "Confirm in one sentence", "every 30m", "weekly mon,thu"]],["rule_update:用户要求时改模式(执行才发)、原话、时间表或删掉", "tool rule_update", ["when the user asks", "mode act (results are sent)", "observe (only records)", "off", "delete"]],+ ["background_pause:用户要求时暂停或恢复全部后台工作;暂停时任务、规则不跑,主动消息等着,聊天照常", "tool background_pause", ["Pause or resume", "when the user asks", "no task or rule runs", "pushed messages wait", "chat still works", '"paused"']],["规则段(观察):优先于聊天规则;只看不动,本来要做的写进 would;值得说才说一句,只记下来;不报告就算失败", "rule observe",["优先于上面的聊天规则", "只看、只查,不改任何东西", "would", "task_report", "值得告诉用户", "不值得说就 done 不带 message", "这次只记下来", "不超过 300 字", "就算失败"], ["needs_you", ".task/journal.md"]],["规则段(执行):只做规则里写的事,外部动作前后记日志;那一句会发给用户", "rule act", ["只做规则里写的事", ".task/journal.md", "会发给用户", "不值得说就 done 不带 message"], ["would"]],@@ -221,7 +223,7 @@ describe.skipIf(!runtime)("提示词约定", () => {it("任务会话:只去掉注册了的聊天专用工具,规则段在机器人段之后(优先),有 task_report;子代理拿不到任务工具", async () => {const { task } = await loadPlugins();// 只有 present 和聊天的任务、规则工具是"注册了的":ask_user_question 在这个假环境里没有,不能交给 restrict(它会抛错)- expect(task.deny).toEqual([["present", "task_start", "task_message", "task_list", "rule_create", "rule_update"]]);+ expect(task.deny).toEqual([["present", "task_start", "task_message", "task_list", "rule_create", "rule_update", "background_pause"]]);expect(task.sections).toHaveLength(1);expect(task.sections[0]).toMatchObject({ name: TASK_SECTION, order: TASK_SECTION_ORDER, interpolate: false });expect(TASK_SECTION_ORDER).toBeGreaterThan(BOT_SECTION_ORDER);@@ -234,7 +236,7 @@ describe.skipIf(!runtime)("提示词约定", () => {expect(o.calls).toBe(1);// 只交注册了的:present、ask_user_question、聊天的任务和规则工具、生图、记忆的 remember / forget(recall 留着)expect(o.rule.deny).toHaveLength(1);- expect(new Set(o.rule.deny[0])).toEqual(new Set(["present", "ask_user_question", "task_start", "task_message", "task_list", "rule_create", "rule_update", "generate_image", "generate_video", "media_models", "media_docs", "remember", "forget"]));+ expect(new Set(o.rule.deny[0])).toEqual(new Set(["present", "ask_user_question", "task_start", "task_message", "task_list", "rule_create", "rule_update", "background_pause", "generate_image", "generate_video", "media_models", "media_docs", "remember", "forget"]));expect(o.rule.sections).toHaveLength(1);expect(o.rule.sections[0]).toMatchObject({ name: TASK_SECTION, order: TASK_SECTION_ORDER, interpolate: false });expect(o.rule.sections[0].text()).toBe(ruleRules("observe"));@@ -269,6 +271,7 @@ describe.skipIf(!runtime)("提示词约定", () => {* 我们交给模型的部分:人设 + 机器人段(典型人设、开着记忆)+ 我们的工具定义(记忆、生图、后台任务、规则)。* 3a 基线 8,514(提示词 907 + 工具 7,607,其中 task_start、task_message、task_list 1,370);3b、3c 之后 8,751(工具 7,844)。* 3d 加上 rule_create(819)、rule_update(467)和 task_list 多一句「and rules」后 10,049(工具 9,142)。上限高约 5%。+ * 暂停开关 background_pause(280)之后 10,329(工具 9,422),还在上限之内,上限不变。* 缩短了就调低;要调高,在提交说明里写清原因。*/const BUDGET = 10_550;diff --git a/test/rules.unit.test.ts b/test/rules.unit.test.tsindex 6d9a654..08ffb29 100644--- a/test/rules.unit.test.ts+++ b/test/rules.unit.test.ts@@ -563,6 +563,42 @@ describe("规则(假宿主、假时钟)", () => {]);});+ it("暂停后台工作:到点的检查、提醒、事件都记为跳过(后台工作已暂停),恢复后不补,立即运行也不行;排着的那次也跳过", async () => {+ const { rule } = await create();+ const remind = (await create("daily 09:00", { kind: "remind", message: "该喝水了" })).rule;+ const event = svc.createRule({ botId: "b", conversationId: CONV, title: "新 issue", instruction: "有新 issue 告诉我", trigger: { kind: "event", source: "repo" } }).rule!;+ expect(svc.setPaused("b", true, "web")).toBe(true);+ await go(at("2026-11-02T08:00"));+ await go(at("2026-11-02T09:00"));+ expect(svc.emitRuleEvent("repo", { action: "opened" })).toEqual([]);+ await flush();+ expect(host.prompts).toEqual([]);+ expect(store.listOutbox({ limit: 50 })).toEqual([]);+ for (const [r, t] of [[rule, at("2026-11-02T08:00")], [remind, at("2026-11-02T09:00")], [event, now]] as const) {+ expect(runsOf(r.id).map((x) => [x.outcome, x.error, x.queuedAt])).toEqual([["skipped", "paused", t]]);+ expect(svc.ruleLog(r.id)[0].line).toBe("跳过:后台工作已暂停");+ }+ expect(store.getRule(rule.id)!.nextRunAt).toBe(at("2026-11-03T08:00"));+ expect(svc.runRuleNow(rule.id)).toEqual({ error: "后台工作已暂停" });+ // 恢复:错过的不补,下一次照常+ now = at("2026-11-02T10:00");+ svc.setPaused("b", false, "web");+ await flush();+ expect(host.prompts).toEqual([]);+ expect(runsOf(rule.id)).toHaveLength(1);+ await day("2026-11-03", report("done"));+ expect(runsOf(rule.id).map((x) => x.outcome)).toEqual(["skipped", "done"]);+ // 暂停时已经排着(等名额)的那次:跳过,不等到恢复+ svc.stop();+ svc = make({ maxBackground: 0 });+ svc.start();+ await go(at("2026-11-04T08:00"));+ expect(runsOf(rule.id).at(-1)!.state).toBe("queued");+ svc.setPaused("b", true, "web");+ svc.pump();+ expect(runsOf(rule.id).at(-1)).toMatchObject({ state: "ended", outcome: "skipped", error: "paused" });+ });+it("固定提醒:直接执行,到点只发那句话(不进模型、不占名额、不受免打扰限制),一次性的跑完就结束", async () => {const r = await svc.chatTool({ botId: "b", sessionId: "chat-1", op: "rule_create", args: { title: "开会", instruction: "明天下午 3 点提醒我开会", schedule: "once 2026-11-03 15:00", kind: "remind", message: "该去开会了。" } });expect(r.text).toContain("Created reminder");diff --git a/test/tasks.integration.test.ts b/test/tasks.integration.test.tsindex 2c680fd..885b60e 100644--- a/test/tasks.integration.test.ts+++ b/test/tasks.integration.test.ts@@ -53,6 +53,8 @@ describe.skipIf(!runtime || !hasBwrap || process.platform !== "linux")("backgrouif (r) return done ? { text: `ACK-${r[1]}:好,后台开始调研,好了告诉你,你可以继续聊别的。` } : { tool: { name: "task_start", args: { title: `调研 ${r[1]}`, brief: `research ${r[1]} and write notes.md` } } };const p = /PING (\w+)/.exec(user);if (p) return { text: `PONG-${p[1]}` };+ const pause = /PAUSEBG (on|off)/.exec(user);+ if (pause) return done ? { text: `PAUSED-${pause[1]}` } : { tool: { name: "background_pause", args: { paused: pause[1] === "on" } } };const l = /LISTTOOLS/.exec(user);if (l) return { text: `CHATTOOLS<<${tools.join(",")}>>` };return { text: "好的" };@@ -194,6 +196,26 @@ describe.skipIf(!runtime || !hasBwrap || process.platform !== "linux")("backgrouexpect(host.restarts).toBe(0);}, 180_000);+ it("pause switch: the chat agent pauses background work; a new task waits (chat still answers), /tasks says so; resuming starts it and its result arrives once", async () => {+ ilink.push(OWNER, "PAUSEBG on");+ await waitFor(() => sentTo("PAUSED-on").length === 1);+ expect(app.store.getBot("default")!.settings.paused).toBe(true);+ const t = await research("PAUSEQ");+ await new Promise((r) => setTimeout(r, 1500));+ expect(stage("PAUSEQ")).toBe("working/queued");+ expect(calls.some((c) => c.task && c.users.some((u) => u.includes("RESEARCH PAUSEQ")))).toBe(false);+ ilink.push(OWNER, "/tasks");+ await waitFor(() => sentTo("后台任务:").some((s) => s.text.includes("调研 PAUSEQ · 排队中")));+ expect(sentTo("后台任务:").at(-1)!.text).toMatch(/\n后台工作已暂停,跟我说一声就恢复。$/);+ ilink.push(OWNER, "PAUSEBG off");+ await waitFor(() => sentTo("PAUSED-off").length === 1);+ await waitFor(() => sentTo("RESULT-PAUSEQ").length === 1);+ await waitFor(() => stage("PAUSEQ") === "ready");+ await app.outbox.idle();+ expect(sentTo("RESULT-PAUSEQ")).toHaveLength(1);+ expect((await api(`/tasks/${t.id}`)).runs.map((r: any) => [r.cause, r.outcome])).toEqual([["launch", "done"]]);+ }, 180_000);+it("exit demo (3b): a task asks 「中文还是英文?」 on WeChat; a bare number answers it and the task continues; needs-you lists it on desktop and is empty after", async () => {expect((await api("/attention")).items).toEqual([]);const t = await research("ASKQ");@@ -323,8 +345,9 @@ describe.skipIf(!runtime || !hasBwrap || process.platform !== "linux")("backgrouawait research("HANGS1");await waitFor(() => hanging("HANGS1"));// /tasks 列出编号;/stop 1 停掉它(插队,不进会话队列)+ const listed = sentTo("后台任务:").length;ilink.push(OWNER, "/tasks");- await waitFor(() => sentTo("后台任务:").length >= 1);+ await waitFor(() => sentTo("后台任务:").length > listed);expect(sentTo("后台任务:").at(-1)!.text).toMatch(/^后台任务:\n1\. 调研 HANGS1 · 进行中/);ilink.push(OWNER, "/stop 1");await waitFor(() => sentTo("已停止后台任务「调研 HANGS1」").length === 1);diff --git a/test/tasks.unit.test.ts b/test/tasks.unit.test.tsindex 5739830..1c91736 100644--- a/test/tasks.unit.test.ts+++ b/test/tasks.unit.test.ts@@ -710,6 +710,36 @@ describe("TaskService(假宿主)", () => {expect(svc.conversationOf(t.sessionId)).toBe(CONV);});+ it("暂停后台工作(聊天代理的 background_pause):新任务排着不开始,task_start 说清楚;正在跑的照常做完,结果排着不发;/tasks、task_list 说一句;恢复后任务开始、结果放出来", async () => {+ store.setAgentSession(CONV, "b", "session-chat");+ const tool = (op: string, args: Record<string, unknown> = {}) => svc.chatTool({ botId: "b", sessionId: "session-chat", op, args });+ const a = start("A");+ await flush();+ expect((await tool("pause", {})).error).toMatch(/paused must be true or false/);+ expect((await tool("pause", { paused: true })).text).toMatch(/^Paused this bot's background work: no task or rule runs, pushed messages wait; chat still works\./);+ expect(store.getBot("b")!.settings.paused).toBe(true);+ const r = await tool("start", { title: "B", brief: "调研 B" });+ expect(r.text).toMatch(/^Queued background task t_[0-9a-f]{12} 「B」, but background work is paused, so it starts only when the user resumes it\./);+ await flush();+ const b = store.listTasks({ conversationId: CONV }).find((t) => t.title === "B")!;+ expect(host.prompts.some((p) => p.sessionId === b.sessionId)).toBe(false);+ expect(svc.get(b.id)!.stage.key).toBe("working/queued");+ // 正在跑的 A 照常做完;结果写进会话(界面里看得到),推送排着+ await turn(a.sessionId, () => void report(a.sessionId, "done", "A 好了"));+ const row = store.getOutbox(store.listRuns({ taskId: a.id })[0].delivery)!;+ expect([row.status, row.reason]).toEqual(["scheduled", "paused"]);+ expect(store.listMessages(CONV).at(-1)!.content).toBe("A 好了");+ expect(svc.listText(CONV)).toBe("后台任务:\n1. B · 排队中\n2. A · 已完成:A 好了\n发 /stop 编号 可停止。\n后台工作已暂停,跟我说一声就恢复。");+ expect((await tool("list")).text!.split("\n")[0]).toBe("Background work is paused: no task or rule runs, pushed messages wait.");+ // 恢复:排着的任务开始,结果马上重新排(按平常的规则)+ expect((await tool("pause", { paused: false })).text).toMatch(/^Resumed background work: waiting tasks start and held messages go out\./);+ await flush();+ expect(host.prompts.some((p) => p.sessionId === b.sessionId)).toBe(true);+ expect(store.getOutbox(row.id)!.due).toBeLessThanOrEqual(Date.now());+ expect(svc.listText(CONV)).not.toMatch(/暂停/);+ expect((await tool("pause", { paused: false })).text).toMatch(/^Background work was not paused; nothing changed\./);+ });+it("飞书:结果回复在请求那条消息下(出站队列);网页:只写进会话历史,不进出站队列", async () => {const fs1 = store.ensureConversation("b", "feishu", "oc_1", "主人");store.addMessage(fs1.id, "user", "后台调研一下 GPU 价格");diff --git a/ui/components/tasks.js b/ui/components/tasks.jsindex 9b30867..dc2bef2 100644--- a/ui/components/tasks.js+++ b/ui/components/tasks.js@@ -1,7 +1,7 @@// 后台任务(3a):对话里请求那条消息下面的任务胶囊「后台任务 · 标题 · 进行中 ›」,点开是最新进展、每次运行折叠的处理过程和停止;// 信息面板里一行一个任务。状态是"点 + 文字":绿 = 进行中,黄 = 等你,红 = 失败,灰 = 已完成 / 已停止。健康时不多占地方。import { useEffect, useState } from "preact/hooks";-import { html, Icon } from "./ui.js";+import { html, Icon, Notice } from "./ui.js";import { ActivityLine } from "./activity.js";import { api } from "../lib/api.js";import { failed, toast } from "../lib/store.js";@@ -109,3 +109,18 @@ export function TaskRow({ task, onChanged, onOpen }) {${working && html`<button type="button" class="text danger" disabled=${stopping} onClick=${stop}>${stopping ? t("tasks.stopping") : t("tasks.stop")}</button>`}</div>`;}++/** 后台工作暂停时,信息面板顶部的一行(没暂停时不画):任务、规则和主动消息都停着,点「恢复」接着来 */+export function PausedLine({ onResume }) {+ const [busy, setBusy] = useState(false);+ const resume = async () => {+ setBusy(true);+ try {+ await onResume();+ } catch (e) {+ failed(e);+ }+ setBusy(false);+ };+ return html`<${Notice} action=${html`<button type="button" class="btn" disabled=${busy} aria-busy=${busy || undefined} onClick=${resume}>${t("tasks.resume")}</button>`}>${t("tasks.paused")}<//>`;+}diff --git a/ui/design/gallery.js b/ui/design/gallery.jsindex 93e1f79..66e3f8e 100644--- a/ui/design/gallery.js+++ b/ui/design/gallery.js@@ -6,6 +6,7 @@ import { BotAvatar, AvatarPicker, AppMark, BOT_CHARS, CHAR_KEYS, MAIN_CHAR } froimport { TEMPLATES } from "../screens/new-bot.js";import { NeedItem, NeedsRow } from "../screens/needs-you.js";import { RuleRow, RuleDetail } from "../components/rules.js";+import { PausedLine } from "../components/tasks.js";import { Markdown } from "../components/markdown.js";import { useStore, toast, saved, failed, confirmSheet } from "../lib/store.js";import { themeMode, setThemeMode } from "../lib/theme.js";@@ -617,6 +618,11 @@ const { mounted, leaving } = usePresence(open); /* design/motion.js:退场<div class="list">${RULES.map((r) => html`<${RuleRow} rule=${r} open=${false} onToggle=${() => {}} />`)}</div></div>`}<//>+ <${Demo} title="暂停" note="PausedLine:后台工作暂停时信息面板最上面这一行,没暂停时不画">+ ${() => html`<div class="panel-body" style="width: 340px; flex: none; padding: var(--space-2); border-radius: var(--r-pane); background: var(--grain), var(--glass-panel)">+ <${PausedLine} onResume=${async () => {}} />+ </div>`}+ <//><${Demo} title="详情与运行记录" note="RuleDetail:原话、模式、立即运行、运行记录(本会发送 / 保持安静 / 失败 / 跳过)">${() => html`<div class="panel-body" style="width: 340px; flex: none; padding: var(--space-2); border-radius: var(--r-pane); background: var(--grain), var(--glass-panel)"><div class="list"><div class="row-edit rule-edit"><${RuleDetail} rule=${RULES[0]} runs=${RULE_RUNS} /></div></div>diff --git a/ui/locales/en/botSettings.js b/ui/locales/en/botSettings.jsindex ef28f68..07f6f19 100644--- a/ui/locales/en/botSettings.js+++ b/ui/locales/en/botSettings.js@@ -109,6 +109,8 @@ export default {},proactive: {head: "Proactive messages",+ pause: "Pause background work",+ pauseSub: "Tasks, rules and pushed messages wait; chat works as usual",quiet: "Do not disturb",quietSub: "Background results wait until it ends",quietFrom: "Do not disturb from",diff --git a/ui/locales/en/tasks.js b/ui/locales/en/tasks.jsindex ea5ddf0..08a1dce 100644--- a/ui/locales/en/tasks.js+++ b/ui/locales/en/tasks.js@@ -12,4 +12,6 @@ export default {view: "View background task",chip: "Background task",minutes: { one: "{count} min", other: "{count} min" },+ paused: "Background work is paused",+ resume: "Resume",};diff --git a/ui/locales/zh-CN/botSettings.js b/ui/locales/zh-CN/botSettings.jsindex b1ce125..b5c80a9 100644--- a/ui/locales/zh-CN/botSettings.js+++ b/ui/locales/zh-CN/botSettings.js@@ -109,6 +109,8 @@ export default {},proactive: {head: "主动消息",+ pause: "暂停后台工作",+ pauseSub: "任务、规则和主动消息都先停下,聊天照常",quiet: "免打扰",quietSub: "后台结果留到结束后再发",quietFrom: "免打扰开始",diff --git a/ui/locales/zh-CN/tasks.js b/ui/locales/zh-CN/tasks.jsindex 43be68c..3271f18 100644--- a/ui/locales/zh-CN/tasks.js+++ b/ui/locales/zh-CN/tasks.js@@ -12,4 +12,6 @@ export default {view: "查看后台任务",chip: "后台任务",minutes: { other: "{count} 分钟" },+ paused: "后台工作已暂停",+ resume: "恢复",};diff --git a/ui/screens/bot-settings.js b/ui/screens/bot-settings.jsindex 55e82cc..d36feb7 100644--- a/ui/screens/bot-settings.js+++ b/ui/screens/bot-settings.js@@ -287,6 +287,9 @@ export function BotSettingsScreen({ bot, section, models, modelsError, reloadMod<div class="list-head">${t("botSettings.proactive.head")}</div><div class="list">+ <${Row} id="pause" name=${t("botSettings.proactive.pause")} sub=${t("botSettings.proactive.pauseSub")}>+ <${Switch} label=${t("botSettings.proactive.pause")} value=${s.paused} onChange=${(v) => put({ paused: v })} />+ <//><${Row} id="quiet" name=${t("botSettings.proactive.quiet")} sub=${t("botSettings.proactive.quietSub")}>${s.quietHours.enabled && html`<${MenuButton} label=${t("botSettings.proactive.quietFrom")} value=${s.quietHours.from} width=${120} options=${HOURS}onChange=${(v) => put({ quietHours: { from: v } })} />diff --git a/ui/screens/info-panel.js b/ui/screens/info-panel.jsindex baf5d0e..6cb31f9 100644--- a/ui/screens/info-panel.js+++ b/ui/screens/info-panel.js@@ -8,7 +8,7 @@ import { confirmSheet, failed, saved, toast } from "../lib/store.js";import { markDone } from "../lib/guide.js";import { fmtAgo, fmtClock, fmtDur, fmtTime } from "../lib/format.js";import { channelName as accessChannel } from "../lib/access.js";-import { TaskRow } from "../components/tasks.js";+import { PausedLine, TaskRow } from "../components/tasks.js";import { t } from "../lib/i18n.js";import { RuleRow } from "../components/rules.js";@@ -244,6 +244,7 @@ export function InfoPanel({ bot, leaving, onClose, onOpenBotSettings, onOpenChat<button type="button" class="icon-btn panel-close" title=${t("info.closeTitle")} aria-label=${t("info.closeAria")} onClick=${onClose}><${Icon} name="close" size="md" /></button></div><div class="panel-body">+ ${detail?.bot?.settings?.paused && html`<${PausedLine} onResume=${async () => (await api(`/bots/${bot.id}/settings`, { method: "PUT", body: { paused: false } }), reloadDetail())} />`}<div class="list-head">${t("info.channels")}</div><div class="list">${detail && detail.bot