pi-web-ui 0.88.0 → 0.89.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,405 @@
1
+ /**
2
+ * 内置定时任务调度(issue #184)。
3
+ *
4
+ * 面向普通用户的图形化调度器:任务 CRUD + cron/间隔触发 + 无头执行 +
5
+ * 执行历史 + 通知。底层 cron 解析复用 plugin-schedule.ts(parseCronSpec /
6
+ * nextCronFire),持久化走 <dataDir>/scheduler-tasks.json(全局共享,
7
+ * 与 client-state.json 同级),执行经调用方注入的 executor(index.ts 接
8
+ * AgentService.chatFromScheduler,无头伪客户端)。
9
+ *
10
+ * 定时策略:单个 10s ticker 检查到期任务(cron 下次触发 / 间隔毫秒),
11
+ * running 集合防重叠;catchUp "once" 在启动时补跑一次漏掉的触发。
12
+ */
13
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
14
+ import { join } from "node:path";
15
+ import { nextCronFire, parseCronSpec } from "./plugin-schedule.js";
16
+ export const SCHEDULER_FILE = "scheduler-tasks.json";
17
+ /** 持久间隔底线 60s(与 host.schedule 持久任务同口径,防 token 烧穿)。 */
18
+ export const SCHEDULER_MIN_INTERVAL_MS = 60_000;
19
+ export const SCHEDULER_MAX_INTERVAL_MS = 30 * 24 * 60 * 60 * 1000;
20
+ export const SCHEDULER_HISTORY_MAX = 20;
21
+ const TICK_MS = 10_000;
22
+ export const SCHEDULER_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
23
+ export function schedulerFile(dataDir) {
24
+ return join(dataDir, SCHEDULER_FILE);
25
+ }
26
+ function randomTaskId() {
27
+ const abc = "abcdefghijklmnopqrstuvwxyz0123456789";
28
+ let s = "";
29
+ for (let i = 0; i < 6; i++)
30
+ s += abc[Math.floor(Math.random() * abc.length)];
31
+ return `task-${s}`;
32
+ }
33
+ /** 归一化 + 校验用户输入;非法抛 Error(中文信息,直接面向 UI)。纯函数,可单测。 */
34
+ export function normalizeSchedulerInput(input, now = Date.now()) {
35
+ const idRaw = String(input.id ?? "").trim();
36
+ const id = idRaw || randomTaskId();
37
+ if (!SCHEDULER_ID_RE.test(id))
38
+ throw new Error("任务 id 非法(只收字母/数字/下划线/连字符,≤64 字)");
39
+ const name = String(input.name ?? "")
40
+ .trim()
41
+ .slice(0, 80);
42
+ if (!name)
43
+ throw new Error("任务名称不能为空");
44
+ const description = String(input.description ?? "")
45
+ .trim()
46
+ .slice(0, 500);
47
+ const cwd = String(input.cwd ?? "").trim();
48
+ if (!cwd)
49
+ throw new Error("执行目标项目(cwd)不能为空");
50
+ const kind = input.kind === "interval" ? "interval" : "cron";
51
+ let spec;
52
+ if (kind === "cron") {
53
+ spec = String(input.spec ?? "")
54
+ .trim()
55
+ .replace(/\s+/g, " ");
56
+ if (!parseCronSpec(spec))
57
+ throw new Error("cron 表达式非法(要 5 字段:分 时 日 月 周,如 0 9 * * *)");
58
+ }
59
+ else {
60
+ const ms = Math.floor(Number(input.spec));
61
+ if (!Number.isFinite(ms) || ms <= 0)
62
+ throw new Error("间隔毫秒数非法");
63
+ if (ms < SCHEDULER_MIN_INTERVAL_MS)
64
+ throw new Error(`间隔太短(最短 ${SCHEDULER_MIN_INTERVAL_MS / 1000}s,防 token 烧穿)`);
65
+ if (ms > SCHEDULER_MAX_INTERVAL_MS)
66
+ throw new Error("间隔太长(最长 30 天)");
67
+ spec = String(ms);
68
+ }
69
+ const prompt = String(input.prompt ?? "").trim();
70
+ if (!prompt)
71
+ throw new Error("触发指令(prompt)不能为空");
72
+ if (prompt.length > 8000)
73
+ throw new Error("触发指令超长(>8000 字),请裁剪后重试");
74
+ const model = String(input.model ?? "").trim();
75
+ if (model && !model.includes("/"))
76
+ throw new Error("模型格式非法(应为 provider/id)");
77
+ const thinkingLevel = String(input.thinkingLevel ?? "").trim();
78
+ const catchUp = input.catchUp === "once" ? "once" : "skip";
79
+ return {
80
+ id,
81
+ name,
82
+ description,
83
+ cwd,
84
+ kind,
85
+ spec,
86
+ prompt,
87
+ enabled: input.enabled !== false,
88
+ model,
89
+ thinkingLevel,
90
+ catchUp,
91
+ createdAt: now,
92
+ updatedAt: now,
93
+ };
94
+ }
95
+ /** 下次触发毫秒时间戳;非法/禁用回 null。纯函数,可单测。 */
96
+ export function computeNextFire(task, fromMs) {
97
+ try {
98
+ if (task.kind === "cron") {
99
+ const parts = parseCronSpec(task.spec);
100
+ if (!parts)
101
+ return null;
102
+ return nextCronFire(parts, fromMs);
103
+ }
104
+ const ms = Math.floor(Number(task.spec));
105
+ if (!Number.isFinite(ms) || ms <= 0)
106
+ return null;
107
+ return Math.floor(Number(fromMs)) + ms;
108
+ }
109
+ catch {
110
+ return null;
111
+ }
112
+ }
113
+ /** 间隔任务的人类可读描述(面板显示用)。纯函数。 */
114
+ export function describeIntervalMs(ms) {
115
+ const s = Math.round(ms / 1000);
116
+ if (s < 60)
117
+ return `每 ${s} 秒`;
118
+ if (s < 3600) {
119
+ const m = Math.floor(s / 60);
120
+ return s % 60 === 0 ? `每 ${m} 分钟` : `每 ${m} 分 ${s % 60} 秒`;
121
+ }
122
+ if (s < 86400) {
123
+ const h = Math.floor(s / 3600);
124
+ return s % 3600 === 0 ? `每 ${h} 小时` : `每 ${h} 小时 ${Math.floor((s % 3600) / 60)} 分`;
125
+ }
126
+ const d = Math.floor(s / 86400);
127
+ return `每 ${d} 天`;
128
+ }
129
+ function sanitizeHistory(v) {
130
+ if (!Array.isArray(v))
131
+ return [];
132
+ const out = [];
133
+ for (const r of v) {
134
+ if (!r || typeof r !== "object")
135
+ continue;
136
+ const rec = r;
137
+ if (typeof rec.at !== "number" || !Number.isFinite(rec.at))
138
+ continue;
139
+ out.push({
140
+ at: rec.at,
141
+ ok: rec.ok === true,
142
+ durationMs: typeof rec.durationMs === "number" && Number.isFinite(rec.durationMs) ? rec.durationMs : 0,
143
+ ...(typeof rec.conversationId === "string" && rec.conversationId ? { conversationId: rec.conversationId } : {}),
144
+ ...(typeof rec.error === "string" && rec.error ? { error: rec.error.slice(0, 500) } : {}),
145
+ ...(rec.manual === true ? { manual: true } : {}),
146
+ });
147
+ }
148
+ return out.sort((a, b) => b.at - a.at).slice(0, SCHEDULER_HISTORY_MAX);
149
+ }
150
+ export class SchedulerStore {
151
+ dataDir;
152
+ opts;
153
+ tasks = new Map();
154
+ nextFire = new Map();
155
+ running = new Set();
156
+ timer = null;
157
+ started = false;
158
+ constructor(dataDir, opts = {}) {
159
+ this.dataDir = dataDir;
160
+ this.opts = opts;
161
+ }
162
+ setExecutor(executor) {
163
+ this.opts.executor = executor;
164
+ }
165
+ /** 启动 ticker + catchUp 补跑(幂等)。 */
166
+ start() {
167
+ this.load();
168
+ if (this.started)
169
+ return;
170
+ this.started = true;
171
+ const now = Date.now();
172
+ for (const task of this.tasks.values()) {
173
+ if (!task.enabled)
174
+ continue;
175
+ const lastAt = task.history?.[0]?.at ?? task.updatedAt;
176
+ const next = computeNextFire(task, Math.max(lastAt, task.updatedAt));
177
+ if (next === null)
178
+ continue;
179
+ if (next <= now && task.catchUp === "once" && lastAt < now) {
180
+ // 重启发现漏跑:补一次,补完按这次重排。
181
+ this.nextFire.set(task.id, now + 5000);
182
+ void this.fire(task.id, false);
183
+ }
184
+ else if (next <= now) {
185
+ this.nextFire.set(task.id, computeNextFire(task, now) ?? now + TICK_MS);
186
+ }
187
+ else {
188
+ this.nextFire.set(task.id, next);
189
+ }
190
+ }
191
+ this.timer = setInterval(() => void this.tick(), TICK_MS);
192
+ this.timer.unref?.();
193
+ }
194
+ stop() {
195
+ if (this.timer) {
196
+ clearInterval(this.timer);
197
+ this.timer = null;
198
+ }
199
+ this.started = false;
200
+ }
201
+ /** 读盘;坏文件/形状不对当空表(读路径不回写)。 */
202
+ load() {
203
+ try {
204
+ const parsed = JSON.parse(readFileSync(schedulerFile(this.dataDir), "utf8"));
205
+ if (!parsed || typeof parsed !== "object" || !parsed.tasks || typeof parsed.tasks !== "object") {
206
+ this.tasks = new Map();
207
+ return;
208
+ }
209
+ const next = new Map();
210
+ for (const [id, raw] of Object.entries(parsed.tasks)) {
211
+ if (!raw || typeof raw !== "object")
212
+ continue;
213
+ const r = raw;
214
+ try {
215
+ const task = normalizeSchedulerInput({
216
+ id,
217
+ name: r.name,
218
+ description: r.description,
219
+ cwd: r.cwd,
220
+ kind: r.kind,
221
+ spec: r.spec,
222
+ prompt: r.prompt,
223
+ enabled: r.enabled,
224
+ model: r.model,
225
+ thinkingLevel: r.thinkingLevel,
226
+ catchUp: r.catchUp,
227
+ });
228
+ task.createdAt = typeof r.createdAt === "number" && Number.isFinite(r.createdAt) ? r.createdAt : Date.now();
229
+ task.updatedAt =
230
+ typeof r.updatedAt === "number" && Number.isFinite(r.updatedAt) ? r.updatedAt : task.createdAt;
231
+ next.set(id, { ...task, history: sanitizeHistory(r.history) });
232
+ }
233
+ catch {
234
+ // 单条坏记录跳过,不影响其他任务
235
+ }
236
+ }
237
+ this.tasks = next;
238
+ }
239
+ catch {
240
+ this.tasks = new Map();
241
+ }
242
+ }
243
+ save() {
244
+ try {
245
+ mkdirSync(this.dataDir, { recursive: true });
246
+ const file = schedulerFile(this.dataDir);
247
+ const tmp = `${file}.tmp-${process.pid}`;
248
+ const tasks = {};
249
+ for (const [id, t] of this.tasks)
250
+ tasks[id] = t;
251
+ writeFileSync(tmp, JSON.stringify({ v: 1, tasks }));
252
+ renameSync(tmp, file);
253
+ }
254
+ catch (err) {
255
+ console.error("[scheduler] persist failed:", err);
256
+ }
257
+ }
258
+ changed() {
259
+ try {
260
+ this.opts.onChange?.();
261
+ }
262
+ catch {
263
+ /* 推送失败不影响调度 */
264
+ }
265
+ }
266
+ list() {
267
+ const now = Date.now();
268
+ return [...this.tasks.values()]
269
+ .map((t) => {
270
+ const history = sanitizeHistory(t.history);
271
+ return {
272
+ id: t.id,
273
+ name: t.name,
274
+ description: t.description,
275
+ cwd: t.cwd,
276
+ kind: t.kind,
277
+ spec: t.spec,
278
+ prompt: t.prompt,
279
+ enabled: t.enabled,
280
+ model: t.model,
281
+ thinkingLevel: t.thinkingLevel,
282
+ catchUp: t.catchUp,
283
+ createdAt: t.createdAt,
284
+ updatedAt: t.updatedAt,
285
+ nextFire: !t.enabled ? null : (this.nextFire.get(t.id) ?? computeNextFire(t, Math.max(now, t.updatedAt))),
286
+ lastRun: history[0] ?? null,
287
+ history,
288
+ running: this.running.has(t.id),
289
+ };
290
+ })
291
+ .sort((a, b) => a.name.localeCompare(b.name, "zh"));
292
+ }
293
+ /** 新建或全量更新(同名 id 覆盖);返回归一化后的任务。 */
294
+ upsert(input) {
295
+ const prev = this.tasks.get(String(input.id ?? "").trim());
296
+ const task = normalizeSchedulerInput(input);
297
+ if (prev) {
298
+ task.createdAt = prev.createdAt;
299
+ task.updatedAt = Date.now();
300
+ }
301
+ const history = prev?.history ? sanitizeHistory(prev.history) : [];
302
+ this.tasks.set(task.id, { ...task, history });
303
+ // spec/cwd/开关变了 → 按现在重排下次触发
304
+ this.nextFire.set(task.id, computeNextFire(task, Date.now()) ?? Date.now() + TICK_MS);
305
+ this.save();
306
+ this.changed();
307
+ return task;
308
+ }
309
+ remove(id) {
310
+ const ok = this.tasks.delete(id);
311
+ this.nextFire.delete(id);
312
+ if (ok) {
313
+ this.save();
314
+ this.changed();
315
+ }
316
+ return ok;
317
+ }
318
+ setEnabled(id, enabled) {
319
+ const t = this.tasks.get(id);
320
+ if (!t)
321
+ return null;
322
+ t.enabled = enabled;
323
+ t.updatedAt = Date.now();
324
+ this.nextFire.set(id, computeNextFire(t, Date.now()) ?? Date.now() + TICK_MS);
325
+ this.save();
326
+ this.changed();
327
+ return t;
328
+ }
329
+ async tick() {
330
+ const now = Date.now();
331
+ for (const task of this.tasks.values()) {
332
+ if (!task.enabled || this.running.has(task.id))
333
+ continue;
334
+ let next = this.nextFire.get(task.id);
335
+ if (next === undefined) {
336
+ next = computeNextFire(task, Math.max(now, task.updatedAt)) ?? now + TICK_MS;
337
+ this.nextFire.set(task.id, next);
338
+ }
339
+ if (next <= now)
340
+ await this.fire(task.id, false);
341
+ }
342
+ }
343
+ /** 手动立即执行一次(面板 Run Now;调试用,不扰动下次触发)。 */
344
+ async runNow(id) {
345
+ const task = this.tasks.get(id);
346
+ if (!task)
347
+ return { ok: false, error: "任务不存在" };
348
+ if (this.running.has(id))
349
+ return { ok: false, error: "任务正在执行中" };
350
+ return this.fire(id, true);
351
+ }
352
+ async fire(id, manual) {
353
+ const task = this.tasks.get(id);
354
+ if (!task)
355
+ return { ok: false, error: "任务不存在" };
356
+ const executor = this.opts.executor;
357
+ if (!executor) {
358
+ const err = "调度器执行器未接入(当前引擎不支持定时任务)";
359
+ this.recordRun(id, { at: Date.now(), ok: false, durationMs: 0, error: err, ...(manual ? { manual } : {}) });
360
+ return { ok: false, error: err };
361
+ }
362
+ this.running.add(id);
363
+ this.changed();
364
+ const startedAt = Date.now();
365
+ let result;
366
+ try {
367
+ result = await executor({ ...task });
368
+ }
369
+ catch (err) {
370
+ result = { ok: false, error: err.message };
371
+ }
372
+ const durationMs = Date.now() - startedAt;
373
+ this.running.delete(id);
374
+ this.recordRun(id, {
375
+ at: Date.now(),
376
+ ok: result.ok,
377
+ durationMs,
378
+ ...(result.conversationId ? { conversationId: result.conversationId } : {}),
379
+ ...(result.error ? { error: result.error.slice(0, 500) } : {}),
380
+ ...(manual ? { manual } : {}),
381
+ });
382
+ // 按这次完成时间重排下次触发(间隔任务从完成起算,避免长任务连击)。
383
+ const cur = this.tasks.get(id);
384
+ if (cur && cur.enabled && !manual) {
385
+ this.nextFire.set(id, computeNextFire(cur, Date.now()) ?? Date.now() + TICK_MS);
386
+ this.save();
387
+ }
388
+ const label = `⏰ ${task.name}`;
389
+ if (result.ok) {
390
+ this.opts.notify?.("info", `定时任务「${task.name}」${manual ? "手动" : "定时"}触发完成(${(durationMs / 1000).toFixed(0)}s)——${label}`, `Scheduled task "${task.name}" ${manual ? "manually" : "automatically"} finished (${Math.round(durationMs / 1000)}s) — ${label}`);
391
+ }
392
+ else {
393
+ this.opts.notify?.("warning", `定时任务「${task.name}」${manual ? "手动" : "定时"}触发失败:${result.error ?? "未知错误"}`, `Scheduled task "${task.name}" ${manual ? "manual" : "automatic"} run failed: ${result.error ?? "unknown error"}`);
394
+ }
395
+ this.changed();
396
+ return result;
397
+ }
398
+ recordRun(id, run) {
399
+ const t = this.tasks.get(id);
400
+ if (!t)
401
+ return;
402
+ t.history = [run, ...sanitizeHistory(t.history)].slice(0, SCHEDULER_HISTORY_MAX);
403
+ this.save();
404
+ }
405
+ }
@@ -9,7 +9,7 @@
9
9
  import { existsSync, readdirSync } from "node:fs";
10
10
  import { basename, dirname, join } from "node:path";
11
11
  import { fileURLToPath } from "node:url";
12
- import { extensionKey, normalizeRetryMaxAttempts, normalizeSkillList, normalizeUiLayout, } from "./client-state.js";
12
+ import { extensionKey, normalizeDisabledPluginTools, normalizeRetryMaxAttempts, normalizeSkillList, normalizeUiLayout, } from "./client-state.js";
13
13
  import { findVisionModels, SYSTEM_PROMPT } from "./vision-bridge.js";
14
14
  import { DEFAULT_TEMPLATES } from "./subagent-templates.js";
15
15
  import { deriveLegacy, foldLegacyIntoDisabled, normalizeDisabledAgentTools } from "./tool-manager.js";
@@ -217,6 +217,7 @@ export class SettingsService {
217
217
  promptTemplate: this.settings.promptTemplate ?? "",
218
218
  promptOverrides: { ...this.settings.promptOverrides },
219
219
  disabledAgentTools: [...normalizeDisabledAgentTools(this.settings.disabledAgentTools)],
220
+ disabledPluginTools: [...normalizeDisabledPluginTools(this.settings.disabledPluginTools)],
220
221
  terminalToolsEnabled: legacyTools.terminalToolsEnabled,
221
222
  terminalBash: this.settings.terminalBash,
222
223
  terminalBashIdleMs: this.settings.terminalBashIdleMs,
@@ -317,6 +318,7 @@ export class SettingsService {
317
318
  partial.disabledExtensions !== undefined;
318
319
  // 统一工具开关 live 生效(ActiveSet 加减,无需 reload),见末尾 applyToolGating。
319
320
  const toolGatingChanged = partial.disabledAgentTools !== undefined ||
321
+ partial.disabledPluginTools !== undefined ||
320
322
  partial.terminalToolsEnabled !== undefined ||
321
323
  partial.editSoftEnabled !== undefined ||
322
324
  partial.questionnaireEnabled !== undefined;
@@ -358,6 +360,9 @@ export class SettingsService {
358
360
  if (partial.disabledAgentTools !== undefined) {
359
361
  this.settings.disabledAgentTools = normalizeDisabledAgentTools(partial.disabledAgentTools);
360
362
  }
363
+ if (partial.disabledPluginTools !== undefined) {
364
+ this.settings.disabledPluginTools = normalizeDisabledPluginTools(partial.disabledPluginTools);
365
+ }
361
366
  if (partial.terminalToolsEnabled !== undefined ||
362
367
  partial.editSoftEnabled !== undefined ||
363
368
  partial.questionnaireEnabled !== undefined) {
@@ -469,6 +474,7 @@ export class SettingsService {
469
474
  disabledSkills: [...this.settings.disabledSkills],
470
475
  disabledExtensions: [...this.settings.disabledExtensions],
471
476
  disabledAgentTools: [...normalizeDisabledAgentTools(this.settings.disabledAgentTools)],
477
+ disabledPluginTools: [...normalizeDisabledPluginTools(this.settings.disabledPluginTools)],
472
478
  terminalToolsEnabled: this.settings.terminalToolsEnabled,
473
479
  terminalBash: this.settings.terminalBash,
474
480
  terminalBashIdleMs: this.settings.terminalBashIdleMs,
@@ -514,6 +520,7 @@ export class SettingsService {
514
520
  disabledSkills: [...p.disabledSkills],
515
521
  disabledExtensions: [...p.disabledExtensions],
516
522
  disabledAgentTools: presetDisabled,
523
+ disabledPluginTools: normalizeDisabledPluginTools(p.disabledPluginTools ?? this.settings.disabledPluginTools),
517
524
  terminalToolsEnabled: presetLegacy.terminalToolsEnabled,
518
525
  // 终端接管偏好随预设走;旧预设缺字段时保留当前值。
519
526
  terminalBash: p.terminalBash ?? this.settings.terminalBash,
@@ -1077,7 +1077,7 @@ export class TerminalManager {
1077
1077
  * state worth protecting, so they neither retain the conversation nor
1078
1078
  * block its dismissal (they are killed together with the conversation).
1079
1079
  * Retained-output history never counts either (same as countLive).
1080
- * 存活且“用过”的终端数——对话保留/关闭拦截只看这个口径。 */
1080
+ * 存活且“用过”的终端数——对话保留只看这个口径(含 AI bash:切走不杀后台活)。 */
1081
1081
  countBlockingLive() {
1082
1082
  let n = 0;
1083
1083
  for (const entry of this.terms.values())
@@ -1085,6 +1085,19 @@ export class TerminalManager {
1085
1085
  n++;
1086
1086
  return n;
1087
1087
  }
1088
+ /** Count of LIVE *user* terminals that were actually used. AI terminals
1089
+ * (agentBash — 终端接管 bash 的一次性/持久终端) are EXCLUDED: they are
1090
+ * internal execution records owned by the agent, killed together with the
1091
+ * conversation on dismissal (removeConversation 里 killAll), so they must
1092
+ * never block it (issue #181:残留 ai-bash-98/99 把会话永久钉在列表里)。
1093
+ * 只保护用户在交互式终端里的现场:用户亲手开且用过的存活终端才阻断移出。 */
1094
+ countUserBlockingLive() {
1095
+ let n = 0;
1096
+ for (const entry of this.terms.values())
1097
+ if (!entry.exited && entry.used && !entry.agentBash)
1098
+ n++;
1099
+ return n;
1100
+ }
1088
1101
  emitList() {
1089
1102
  this.emit({ type: "terminal_list", terminals: this.list() });
1090
1103
  }
@@ -47,9 +47,12 @@ export const MARKERS_LIST_TOOL_NAME = "todo_list";
47
47
  /** 浏览器页面操作工具(定义见 agent-service.ts makeBrowserPageTool):模型经
48
48
  * page-picker 浏览器扩展读/操作用户已授权的页面。 */
49
49
  export const BROWSER_PAGE_TOOL_NAME = "browser_page";
50
+ /** 别的对话读取工具(定义见 conversation-read-tool.ts):运行中对话(含子代理)+
51
+ * 历史会话转录,只读。 */
52
+ export const CONVERSATION_READ_TOOL_NAME = "conversation_read";
50
53
  /** 旧工具名(持久化迁移用;新代码一律用 MARKERS_LIST_TOOL_NAME)。 */
51
54
  export const LEGACY_MARKERS_LIST_TOOL_NAME = "markers_list";
52
- /** 可开关的 Agent 工具总目录(共 19 个;bash 本体与 SDK 内置 edit/read
55
+ /** 可开关的 Agent 工具总目录(共 20 个;bash 本体与 SDK 内置 edit/read
53
56
  * 不进目录——关了 agent 就残了,不给关)。 */
54
57
  export const AGENT_TOOL_CATALOG = [
55
58
  ...TERMINAL_TOOL_NAMES.map((name) => ({
@@ -71,6 +74,8 @@ export const AGENT_TOOL_CATALOG = [
71
74
  // 默认关(AI 动用户浏览器,opt-in 才开)且 dshVisible=false:DSH 引擎没有页面桥
72
75
  // (page_request 由 pi 引擎的 customTool 发出),列在那里只会让用户关一个不存在的工具。
73
76
  { name: BROWSER_PAGE_TOOL_NAME, group: "other", defaultOn: false, dshVisible: false },
77
+ // 只读别的对话(含子代理实时消息与历史转录),默认开;DSH 引擎没有该 customTool。
78
+ { name: CONVERSATION_READ_TOOL_NAME, group: "other", defaultOn: true, dshVisible: false },
74
79
  ];
75
80
  const KNOWN_NAMES = new Set(AGENT_TOOL_CATALOG.map((t) => t.name));
76
81
  /** 是否为本表登记的可开关工具(未知名一律 false,不抛错)。 */