Files
HomeAgent/internal/plugins/all.go
JianFeeeee 6b64d69b10 refactor(timer): 从内核内置插件迁为外部插件,移除编译期注册
老大要求「把 timer 移到外部插件,移除内核的内置 timer」。本次只做内核侧
的**摘除**,插件本体在外部工程(plugins/timer → .hmap 安装)。

timer 原先由 internal/plugins/timer 的 init() 注册进编译期工厂表。
后果是改一行定时器逻辑要重编整个 homed(87MB)并重启内核——而它恰是
最该独立演进的部件:有自己的持久化状态、触发语义、并发模型,却被绑死
在主进程的发版节奏上。

搬出来后:换实现只需重装插件 + 重启单个插件进程;插件崩了自己被拉起,
不影响 agent 主循环。

1. 删除 internal/plugins/timer(plugin.go + plugin_test.go)
2. internal/plugins/all.go 去掉该 import,并写明**不要加回去**的原因
3. internal/plugins/integration_test.go 的 expectedTools 去掉 timer_set

TestIntegrationAllPluginsRegister 的语义是「编译期内置插件是否都注册了工具」,
它走的是本地装配(setupIntegration 只加载 internal/plugins 下的内置包)。
timer 搬走后不再参与这个进程的装配,留在列表里只会造出永远绿不了的假失败。

真正不该省的是验证:外部插件的工具是否真注册成功,靠装完 .hmap 后实调
timer_set / timer_list / timer_cancel 来确认(见交付报告)。

- 配置表:外部插件同用 config_<name> ⇒ config_timer,老值 max_duration /
  pending_timers 直接读回,老大已设的定时器无需迁移
- 工具名:timer_set / timer_list / timer_cancel 不变,模型侧零感知
- 注入源与通道:source/channel 仍是 "timer"
- 注入级别:内置插件可声明 L4,外部插件被夹到 L3;本插件本就要 L3,
  故行为等价

StageHost.RegisterTool 对同名工具返回 `already registered`,而插件注册是
批量失败(新实例的工具一个都注不上)。所以必须**先装新内核**(不含内置
timer)再装外部 timer 插件,反之会撞名。

(cherry picked from commit f584776f23c3bfd8fb2892155e6018a1ec57eac0)
2026-10-19 16:09:03 +08:00

43 lines
2.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package plugins
// 编译期内置插件清单。
//
// ★ 顺序无关(各插件在 init() 里自注册),但**排序保持一致**:
// 这样 diff 里能一眼看出增删,而不是被 import 重排掩盖。
//
// ## timer 已移出本清单(2026-10-19)
//
// timer 原先是这里的编译器内置插件(internal/plugins/timer + RegisterFactory),
// 后果是改一行定时器逻辑要重编整个 homed(87MB)并重启内核 ——
// 而它是**最该独立演进**的部件之一:有自己的持久化状态、自己的触发语义、
// 自己的并发模型,却被绑死在主进程的发版节奏上。
//
// 现在它作为**外部插件**(plugins/timer,.hmap 安装)运行:
// - 换实现只需重装插件 + 重启单个插件进程,不动主进程;
// - 插件崩了自己被拉起,不影响 agent 主循环;
// - 工具名 / 配置表(config_timer)/ 注入通道(timer)保持不变,
// 模型侧与已设的定时器都无需迁移。
//
// ⚠️ 不要再把 timer 加回这里:父子两份同时存在会导致同名工具注册冲突,
// 而「谁赢」取决于加载顺序 —— 那是最难排查的一类故障。
import (
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/agentcli"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/ai_image"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/cfgmgr"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/clawhubadapter"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/cli"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/cmd"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/files"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/healthcheck"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/localuse"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/mcp"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/multimodal"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/pluginmgr"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/remotedevice"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/seemedia"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/seq"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/skillmgr"
_ "github.com/JianFeeeee/HomeAgent/internal/plugins/webui"
)