Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

## 2026-11

- 11-20 自定义联动 Agent 能在配置全景上改了:「本机联动」设置里多一张表(标识 / 显示名 / 事件文件,加行、删行、整表保存,不合规的行标红),存了就生效,不用再重启肥鱼;开关仍在右键菜单「Agent 联动 → 自定义联动 Agent」
- 11-20 个人简报也改在浏览器里看:岛上的人形图标、提醒的「查看」打开配置全景的 `/report/personal_briefing`(和工作简报同一张页:分区、筛选、勾掉;「这次是怎么生成的」写明怎么连的、读了哪些文件、pull 成没成)。页上多一个「记灵感…」按钮,在肥鱼里打开原来窗口的灵感页;那扇窗不再带「简报」页
- 11-20 简报页改版:宽幅两栏,左边每个来源一块磁贴(点了滚过去)和筛选片(★★★ / ★★ / ★ / bug / 有更新,可多选),右边每个来源一张卡(实色磁贴头、条数与 ★★★ / bug / 有更新 的计数、可折叠);每条前面有勾选框,处理完勾掉(只记在这个浏览器里,重新生成后清零),可以隐藏已勾掉的;窄屏单栏。顺手修了链接文字里带方括号(日历事件「[Daily] …」)渲染不成链接的问题
- 11-20 简报页多了「这次是怎么生成的」:链路(WSL 里的 Claude Code 版本、模型、权限模式)、每个相关 MCP 服务器的状态和这次用没用到(没登录的直接给登录命令)、每次工具调用、那个账号跑的 hooks、完整命令和提示词原文;失败的那次也留。设置里新增「额外放行的工具」:连接器换了名字时自己补一行,不用等改代码
Expand Down
4 changes: 3 additions & 1 deletion docs/agent-link-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ DSH 通道只有**一个读方**:`DshMonitor`(一个 `DirGlobTailer` + 一

## 4. 自定义 Agent 通道(不改肥鱼代码)

肥鱼支持在 `config.json` 的 `agent_link` 块里声明任意数量的自定义联动 Agent:肥鱼对其事件文件做**只读监听**(统一协议),不写任何外部配置、无需授权弹窗。
肥鱼支持声明任意数量的自定义联动 Agent:肥鱼对其事件文件做**只读监听**(统一协议),不写任何外部配置、无需授权弹窗。
2026-11-20 起在[配置全景](config-panorama.md)「本机联动」磁贴的设置里改(高级 → 自定义联动 Agent,一张表:标识 / 显示名 / 事件文件),
存了就生效、不用重启;直接改 `config.json` 也仍然认,形状如下:

```jsonc
// <config.dir>/config.json
Expand Down
6 changes: 4 additions & 2 deletions docs/config-panorama.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,10 @@ sequenceDiagram
**页面这一侧的表单**是 `page/form.js` 的 `settingsForm(host, S, send, on)`:`show(描述)` 按 `GET /api/settings/<组>` 的回答画,
页面里没有任何一项设置的名字。

- 七种控件:开关(`role="switch"` 的复选框)、下拉、可自填的下拉(值不在可选值里就自动打开自填框)、数字、单行文本、长文本、
一行一个的列表(`lines`:值是字符串列表,框里一行一项;存的时候每行去掉首尾空白、空行不要,打回原样不算改过)。
- 八种控件:开关(`role="switch"` 的复选框)、下拉、可自填的下拉(值不在可选值里就自动打开自填框)、数字、单行文本、长文本、
一行一个的列表(`lines`:值是字符串列表,框里一行一项;存的时候每行去掉首尾空白、空行不要,打回原样不算改过)、
记录表(`records`:值是字典的列表,描述里的 `fields` 是列;一行一条,「加一行」「×」删行,整张表一个「保存」;草稿是一组对象,
第一次改时从当前值复制;存的时候每个字段去首尾空白、全空的行不要,和服务那边 `_as_stored` 一样,打回原样不算改过)。
下拉的可选值可以是整数(详情卡文字大小 85 / 100 / 115 / 130):`<option>` 的值只能是字串,提交时按 `choices` 换回声明的那个值,
服务那边按类型校验(字串 `"115"` 是 `not_a_choice`)。
收在「高级」里的折起来,标出有几项。每个控件都有 `<label for>` 指着它;状态行是 `role="status"`。
Expand Down
10 changes: 8 additions & 2 deletions docs/settings-and-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,17 @@
(提交的值被它改掉了就拒)。给已登记的功能加设置项时,`normalize` 对不合法值的处理就是这一项的写入校验。
功能把数字夹在一个范围里的,把那一对范围写进 `Setting.bounds`(单位写 `unit`):页面画出范围,超了明说 `out_of_range`,
而不是笼统的「不认」。可选值本身看不懂的(空串、英文档位),用 `Setting.labels` 给它配上文字。
值是字符串列表的用 `lines` 控件(一行一个)。一个配置键下的设置分给两块磁贴的,就声明成两组,各自在 `not_editable` 里说明另一半去哪改。
值是字符串列表的用 `lines` 控件(一行一个);值是「几个字段组成的字典」的列表的用 `records` 控件(`Setting.fields` 声明列:
`((字段 id, 文案键), …)`,页面画成一张小表,可加行 / 删行,整张表一个「保存」;存的时候每个字段去首尾空白、全空的行不要,
其余差别——大小写、缺字段补默认——都是功能 `normalize` 的事,被它改了就是 `rejected`,页面那一行标红)。
一个配置键下的设置分给两块磁贴的,就声明成两组,各自在 `not_editable` 里说明另一半去哪改。
已搬的组:工作简报、Slack 关注、工作笔记、个人助理、会话记忆蒸馏(个人侧、公司侧两组),`agent_link` 的四组(本机联动、WSL 联动、
会话小鱼、最近的对话;2026-11-19)。`agent_link` 分四组是按配置全景的账号带和磁贴分的,不是按旧菜单:WSL 那条在公司带、要有 WSL 才可用。
**一组在设置窗口里本来就没有控件、只在右键菜单里的**(会话小鱼那几项),搬的是菜单:开关留在菜单,选值的子菜单换成一条
「会话小鱼设置…」跳到页面。`dsh`、`custom_agents`、九个 `sound_*` 在四组里都是 `not_editable`(音效留在设置窗口「互动」,M7 搬)。
「会话小鱼设置…」跳到页面。`dsh`、九个 `sound_*` 在四组里都是 `not_editable`(音效留在设置窗口「互动」,M7 搬);
`custom_agents`(自定义联动 Agent 的 `{key, name, path}` 列表)2026-11-20 起在「本机联动」组里用 `records` 控件改,存了就
热生效(`AgentLinkManager.apply_config` → `_sync_custom_agents`:新增的建、删掉的停并移除、改了路径的重建、只改名的换名),
开不开仍在右键菜单「Agent 联动 → 自定义联动 Agent」。
- `tests/test_settings_table.py` 是守卫:功能的 `normalize` 多给出一个键,却既没在表里声明、也没写进那一组的 `not_editable`
说明为什么不给改,测试就红;表里的每个可选值存下去再读回来必须还是它;每一项在两张字表里都得有标题。
- 文字不抄第二份:从设置窗口搬过去的项直接沿用原来的文案键(`Setting.text` / `.hint`),只有新出现的才用
Expand Down
69 changes: 56 additions & 13 deletions pet/agent_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -2628,6 +2628,7 @@ class CustomAgentMonitor(BaseAgentMonitor):

def __init__(self, agent_key: str, config_dir: Path, events_path: str, parent=None) -> None:
super().__init__(agent_key, config_dir, parent)
self.events_path = str(events_path) # 配置里写的原样(热生效时和新配置比对用)
self.events_file = Path(events_path).expanduser()
self.events_dir = self.events_file.parent
self._tailer = ByteOffsetTailer(self.events_file)
Expand Down Expand Up @@ -2807,7 +2808,7 @@ def __init__(self, window: Any, config: Any, *, min_interval: float = 2.0,
# 自定义联动 Agent:配置驱动的只读监视器(key/path 已在 config 清洗时
# 保证合法唯一);显示名合并进实例级 agent_names,类级 AGENT_NAMES
# 保持仅内置(modern_settings_dialog 等按内置枚举处不受影响)。
# 注意:运行中新增/修改 custom_agents 需重启肥鱼生效。
# 运行中改了 custom_agents 由 apply_config → _sync_custom_agents 热生效(2026-11-20 起不用重启)。
self.agent_names: dict[str, str] = dict(self.AGENT_NAMES)
for item in (self.cfg.get("agent_link", {}).get("custom_agents") or []):
key = str(item.get("key") or "")
Expand All @@ -2830,18 +2831,7 @@ def __init__(self, window: Any, config: Any, *, min_interval: float = 2.0,
self._last_session_id: dict[str, str] = {}

for mon in self.monitors.values():
mon.raw_record.connect(self._remember_dialogue_record)
mon.normalized_event.connect(self._on_normalized_event)
mon.state_event.connect(self._on_agent_state_event)
mon.activity_event.connect(self._on_agent_activity_event)
mon.approval_requested.connect(self._on_approval_request)
mon.approval_resolved.connect(self._on_approval_resolved)
mon.session_done.connect(self._on_session_done)
mon.question_requested.connect(self._on_question_request)
mon.question_resolved.connect(self._on_question_resolved)
mon.cordis_requested.connect(self._on_cordis_request)
mon.cordis_resolved.connect(self._on_cordis_resolved)
mon.execution_failed.connect(self._on_execution_failed)
self._connect_monitor(mon)
self.monitors["dsh"].session_meta.connect(self._on_session_meta)
self.monitors["dsh"].model_access.connect(self._on_model_access)
self.monitors["dsh"].llm_error.connect(self._on_llm_error)
Expand Down Expand Up @@ -2909,6 +2899,7 @@ def apply_config(self) -> None:
# 在这里同步而非在探测时读配置,是为了让 agent_link 的探测保持
# "纯函数 + 模块状态"的可测形态(不必到处传 cfg)。
set_configured_pnpm_bin(self.cfg.get("pnpm_bin", ""))
self._sync_custom_agents(agent_cfg)
if not agent_cfg.get("dsh", False):
self._clear_model_access_alerts()
for key, monitor in self.monitors.items():
Expand All @@ -2929,6 +2920,58 @@ def apply_config(self) -> None:
self._uninstall_hooks(key)
self._refresh_moved_hooks(agent_cfg)

#: 每个监视器接进管理器的信号 → 槽;构造时和热加自定义通道时都走它,热删时按同一张表断开
_MONITOR_SIGNALS = (
("raw_record", "_remember_dialogue_record"), ("normalized_event", "_on_normalized_event"),
("state_event", "_on_agent_state_event"), ("activity_event", "_on_agent_activity_event"),
("approval_requested", "_on_approval_request"), ("approval_resolved", "_on_approval_resolved"),
("session_done", "_on_session_done"), ("question_requested", "_on_question_request"),
("question_resolved", "_on_question_resolved"), ("cordis_requested", "_on_cordis_request"),
("cordis_resolved", "_on_cordis_resolved"), ("execution_failed", "_on_execution_failed"),
)

def _connect_monitor(self, monitor) -> None:
for signal_name, slot_name in self._MONITOR_SIGNALS:
getattr(monitor, signal_name).connect(getattr(self, slot_name))

def _disconnect_monitor(self, monitor) -> None:
for signal_name, slot_name in self._MONITOR_SIGNALS:
try:
getattr(monitor, signal_name).disconnect(getattr(self, slot_name))
except (RuntimeError, TypeError):
pass # 没接上过(不该发生):断开没有可断的

def _sync_custom_agents(self, agent_cfg: dict) -> None:
"""配置里的 ``custom_agents`` 和已建的 ``CustomAgentMonitor`` 对齐:新增的建(下面的启停循环按开关决定起不起)、
删掉的停并移除、改了路径的停掉重建、只改显示名的就地换名。信号接线和构造时的一样。"""
wanted: dict[str, dict] = {}
for item in agent_cfg.get("custom_agents") or []:
key = str(item.get("key") or "") if isinstance(item, dict) else ""
if key and key not in self.AGENT_NAMES and key not in wanted:
wanted[key] = item
for key, monitor in list(self.monitors.items()):
if not isinstance(monitor, CustomAgentMonitor):
continue
item = wanted.get(key)
if item is not None and str(item.get("path") or "") == str(monitor.events_path):
self.agent_names[key] = str(item.get("name") or key)
continue
if monitor._running:
monitor.stop()
self._disconnect_monitor(monitor)
monitor.deleteLater()
del self.monitors[key]
self.agent_names.pop(key, None)
log.info("自定义联动 Agent [%s] 已%s", key, "移除" if item is None else "停掉,按新路径重建")
for key, item in wanted.items():
if key in self.monitors:
continue
monitor = CustomAgentMonitor(key, self.config_dir, str(item.get("path") or ""), self)
self.monitors[key] = monitor
self.agent_names[key] = str(item.get("name") or key)
self._connect_monitor(monitor)
log.info("自定义联动 Agent [%s] 已登记(%s)", key, monitor.events_file)

# ---------------------------------------------------------- 联动开着、hooks 在不在
def hooks_missing(self, agent_key: str) -> tuple[str, ...] | None:
"""这个通道缺本肥鱼 hooks 的事件。``()`` = 查过没缺(或判断不了);None = 没查过 / 通道关着。"""
Expand Down
14 changes: 11 additions & 3 deletions pet/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1518,9 +1518,17 @@ def _apply_external_config_change(self) -> None:
self._sync_todo_service()
self._sync_chime_service()
self._sync_festival_service()
# 外部配置变更也可能改了 agent_link.dsh(右键菜单开关落盘后同样收敛到
# 这里)→ 各窗 refresh_pet_settings 链里的 manager.apply_config 会按
# 同一功能门启停 DshMonitor(桥目录唯一读方)。
# 外部配置变更也可能改了 agent_link(页面上的联动开关、自定义联动 Agent、右键菜单开关落盘后同样收敛到
# 这里)。legacy 拓扑里各窗 refresh_pet_settings 链会调 manager.apply_config;overlay 拓扑没有 PetWindow
#(instance.win 是 None),那条链走不到——2026-11-20 起在这里直接应用共享的联动管理器一次
#(apply_config 幂等,legacy 拓扑里多调一次无妨)。它按同一功能门启停各监视器(含 DshMonitor,桥目录唯一读方)。
shared = getattr(self, "_shared", None)
manager = getattr(shared, "agent_link", None) if shared is not None else None
if manager is not None:
try:
manager.apply_config()
except Exception: # noqa: BLE001 - 联动应用失败不能把别的设置同步也拦下
logging.exception("外部配置变更:联动管理器应用失败")
# 联动被关掉 → 肥鱼自拉起的 dsh web 立即收口:它唯一的消费者就是这条
# 联动管线,关掉后留着只是常驻内存。顺序放在跟踪器停表之后(先停探测再
# 停服务,免得跟踪器在服务消失的那一刻又报一轮 offline);只动自拉起
Expand Down
7 changes: 7 additions & 0 deletions pet/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,11 @@
"menu.shared.drag_physics": "Drag physics",
"menu.shared.size": "Size",
"menu.shared.custom_linked_agent": "Custom linked agent",
"settings.link_win.custom_agents": "Custom linked agents",
"settings.link_win.custom_agents_hint": "One per row: a key (lowercase letters, digits, _ -; not one of the built-in claude / cursor / opencode / dsh), a display name and the events file (unified-protocol JSONL, ~ allowed, may not exist yet). The fish only tails that file: no directories created, nothing written elsewhere. Takes effect on save, no restart; each one is switched on in the right-click menu under Agent link → Custom linked agents. A row the feature rejects is not stored and is marked red.",
"settings.link_win.custom_agents.key": "Key",
"settings.link_win.custom_agents.name": "Display name",
"settings.link_win.custom_agents.path": "Events file",
"menu.shared.recent_chats_rows": "Recent chats rows",
"menu.shared.remember_recent_chats": "Remember recent chats",
"menu.shared.laurel_which_model": "Laurel for which model",
Expand Down Expand Up @@ -2187,6 +2192,8 @@
"panorama.ui.form_failed": "Not saved: something went wrong in the fish",
"panorama.ui.form_lost": "Lost the connection to the fish; nothing was saved",
"panorama.ui.form_save": "Save",
"panorama.ui.form_add_row": "Add a row",
"panorama.ui.form_delete_row": "Remove this row",
"panorama.ui.form_revert": "Undo",
"panorama.ui.form_restore_builtin": "Restore built-in",
"panorama.ui.form_using_builtin": "Using the built-in text",
Expand Down
7 changes: 7 additions & 0 deletions pet/locale/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,11 @@
"menu.shared.drag_physics": "拖动物理",
"menu.shared.size": "大小",
"menu.shared.custom_linked_agent": "自定义联动 Agent",
"settings.link_win.custom_agents": "自定义联动 Agent",
"settings.link_win.custom_agents_hint": "一行一个:标识(小写字母数字和 _ -,不能和内置的 claude / cursor / opencode / dsh 重名)、显示名、事件文件路径(统一协议的 JSONL,支持 ~,可以暂不存在)。肥鱼只读监听那个文件,不创建目录、不写任何外部位置。存了就生效,不用重启;开不开在右键菜单「Agent 联动 → 自定义联动 Agent」里。不合规的行存不进去,会标红。",
"settings.link_win.custom_agents.key": "标识",
"settings.link_win.custom_agents.name": "显示名",
"settings.link_win.custom_agents.path": "事件文件",
"menu.shared.recent_chats_rows": "最近的对话显示行数",
"menu.shared.remember_recent_chats": "记录最近的对话",
"menu.shared.laurel_which_model": "桂冠给哪个模型",
Expand Down Expand Up @@ -2179,6 +2184,8 @@
"panorama.ui.form_failed": "没存上:肥鱼那边出错了",
"panorama.ui.form_lost": "和肥鱼的连接断了,没存上",
"panorama.ui.form_save": "保存",
"panorama.ui.form_add_row": "加一行",
"panorama.ui.form_delete_row": "删掉这一行",
"panorama.ui.form_revert": "撤销",
"panorama.ui.form_restore_builtin": "恢复内置",
"panorama.ui.form_using_builtin": "正在用内置的",
Expand Down
5 changes: 5 additions & 0 deletions pet/panorama/page/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ aside{display:flex;flex-direction:column;gap:14px;position:sticky;top:60px}
.sform select{min-width:140px}.sform input[type=number]{width:90px}.sform input.fcustom{width:180px}
.sform .funit{color:var(--m-muted);font-size:12px}
.sform textarea{width:100%;box-sizing:border-box;resize:vertical;font:12px/1.5 ui-monospace,Consolas,"Cascadia Mono",monospace}
.sform table.frecords{width:100%;border-collapse:collapse;margin-bottom:6px}
.sform .frecords th{text-align:left;font-weight:500;font-size:11.5px;color:var(--m-muted);padding:0 4px 2px}
.sform .frecords td{padding:2px 4px 2px 0;vertical-align:top}.sform .frecords td:last-child{width:28px;padding-right:0}
.sform .frecords input[type=text]{width:100%;box-sizing:border-box}
.sform .frec-del{padding:2px 7px;line-height:1.2}
.sform select:focus,.sform input:focus,.sform textarea:focus{outline:2px solid var(--m-accent);outline-offset:-1px}
.sform :disabled{opacity:.55;cursor:not-allowed}
.sform input[type=checkbox][role=switch]{appearance:none;width:38px;height:20px;margin:0;border-radius:10px;background:var(--m-field);
Expand Down
Loading
Loading