跳到主要內容

內置插件

Hermes 隨代碼庫附帶了一小組插件。它們位於 <repo>/plugins/<name>/ 目錄下,並與 ~/.hermes/plugins/ 中用戶安裝的插件一起自動加載。它們使用與第三方插件相同的插件接口——鉤子(hooks)、工具、斜槓命令——只是在代碼庫內部進行維護。

有關通用插件系統的信息,請參閱 插件 頁面;若要編寫自己的插件,請參閱 構建 Hermes 插件

發現機制的工作原理

PluginManager 按順序掃描四個來源:

  1. 內置<repo>/plugins/<name>/(本頁文檔所述)
  2. 用戶~/.hermes/plugins/<name>/
  3. 項目./.hermes/plugins/<name>/(需要設置 HERMES_ENABLE_PROJECT_PLUGINS=1
  4. Pip 入口點hermes_agent.plugins

當名稱衝突時,後發現的來源優先——例如,名為 disk-cleanup 的用戶插件將替換內置版本。

plugins/memory/plugins/context_engine/ 被刻意排除在內置掃描之外。這些目錄使用各自的發現路徑,因為內存提供者(memory providers)和上下文引擎(context engines)是通過配置中的 hermes memory setup / context.engine 配置的單選提供者。

內置插件需手動啟用

內置插件默認處於禁用狀態。發現機制可以找到它們(它們會出現在 hermes plugins list 和交互式 hermes plugins UI 中),但在你明確啟用之前,沒有任何插件會被加載:

hermes plugins enable disk-cleanup

或者通過 ~/.hermes/config.yaml 配置:

plugins:
enabled:
- disk-cleanup

這與用戶安裝插件使用的機制相同。內置插件永遠不會自動啟用——無論是全新安裝,還是現有用戶升級到較新版本的 Hermes。你始終需要顯式選擇啟用。

若要再次禁用內置插件:

hermes plugins disable disk-cleanup
# or: remove it from plugins.enabled in config.yaml

當前發佈的插件

disk-cleanup

自動跟蹤並刪除會話期間創建的臨時文件——測試腳本、臨時輸出、cron 日誌、過期的 Chrome 配置文件——無需代理記住調用工具。

工作原理:

鉤子行為
post_tool_callwrite_file / terminal / patchHERMES_HOME/tmp/hermes-* 內創建匹配 test_*tmp_**.test.* 的文件時,將其靜默跟蹤為 test / temp / cron-output
on_session_end如果在本輪對話中自動跟蹤了任何測試文件,則運行安全的 quick 清理並記錄一行摘要。否則保持靜默。

刪除規則:

類別閾值確認要求
test每次會話結束從不
temp自跟蹤起超過 7 天從不
cron-output自跟蹤起超過 14 天從不
HERMES_HOME 下的空目錄始終從不
research超過 30 天,且超出最新的 10 個文件始終(僅深度清理)
chrome-profile自跟蹤起超過 14 天始終(僅深度清理)
大於 500 MB 的文件從不自動清理始終(僅深度清理)

斜槓命令/disk-cleanup 在 CLI 和網關會話中均可用:

/disk-cleanup status                     # breakdown + top-10 largest
/disk-cleanup dry-run # preview without deleting
/disk-cleanup quick # run safe cleanup now
/disk-cleanup deep # quick + list items needing confirmation
/disk-cleanup track <path> <category> # manual tracking
/disk-cleanup forget <path> # stop tracking (does not delete)

狀態 — 所有內容均位於 $HERMES_HOME/disk-cleanup/

文件內容
tracked.json被跟蹤的路徑,包含類別、大小和時間戳
tracked.json.bak上述文件的原子寫入備份
cleanup.log追加模式的審計日誌,記錄每次跟蹤/跳過/拒絕/刪除操作

安全性 — 清理操作僅觸及 HERMES_HOME/tmp/hermes-* 下的路徑。Windows 掛載點(/mnt/c/...)會被拒絕。知名的頂層狀態目錄(logs/memories/sessions/cron/cache/skills/plugins/disk-cleanup/ 本身)即使為空也不會被刪除——因此全新安裝在第一次會話結束時不會被清空。

啟用: hermes plugins enable disk-cleanup(或在 hermes plugins 中勾選複選框)。

再次禁用: hermes plugins disable disk-cleanup

添加內置插件

內置插件的編寫方式與任何其他 Hermes 插件完全相同——參見 構建 Hermes 插件。唯一區別在於:

  • 目錄位於 <repo>/plugins/<name>/ 而非 ~/.hermes/plugins/<name>/
  • hermes plugins list 中,清單來源顯示為 bundled
  • 同名的用戶插件會覆蓋內置版本

適合打包為內置插件的條件包括:

  • 沒有可選依賴項(或其依賴項已包含在 pip install .[all] 中)
  • 其行為惠及大多數用戶,且默認啟用(opt-out)而非默認禁用(opt-in)
  • 其邏輯融入了生命週期鉤子,否則代理必須記住手動調用
  • 它補充了核心功能,而未擴大模型可見的工具表面

反面示例——應保留為用戶可安裝插件而非內置插件的情況:需要 API 密鑰的第三方集成、小眾工作流、龐大的依賴樹、任何會顯著改變代理默認行為的內容。