跳到主要內容

僅腳本的 Cron 任務

有時你已經確切知道想要發送的消息內容。你不需要代理(agent)來進行推理——你只需要一個按定時器運行的腳本,並將其輸出(如果有)發送到 Telegram / Discord / Slack / Signal。

Hermes 將此稱為無代理模式(no-agent mode)。它是去除了大語言模型(LLM)的 cron 系統。

   ┌──────────────────┐          ┌──────────────────┐
│ scheduler tick │ every │ run script │
│ (every N minutes)│ ──────▶ │ (bash or python) │
└──────────────────┘ └──────────────────┘

│ stdout

┌──────────────────┐
│ delivery router │
│ (telegram/disc…) │
└──────────────────┘
  • **無 LLM 調用。**零 Token,零代理循環,零模型花費。
  • **腳本即任務。**腳本決定是否發出警報。產生輸出 → 發送消息。不產生輸出 → 靜默心跳。
  • Bash 或 Python。.sh / .bash 文件在 /bin/bash 下運行;任何其他擴展名的文件在當前 Python 解釋器下運行。~/.hermes/scripts/ 中的任何文件均被接受。
  • **相同的調度器。**與 LLM 任務一起存在於 cronjob 中——暫停、恢復、列出、日誌記錄和投遞目標的工作方式完全相同。

何時使用

在以下場景中使用無代理模式:

  • **內存/磁盤/GPU 看門狗。**每 5 分鐘運行一次,僅在超過閾值時發出警報。
  • **CI 鉤子。**部署完成 → 發佈 commit SHA。構建失敗 → 發送日誌的最後 100 行。
  • 定期指標。“每天早上 9 點的 Stripe 收入”,通過簡單的 API 調用 + 美化打印實現。
  • **外部事件輪詢器。**檢查 API,在狀態變更時發出警報。
  • **心跳檢測。**每 N 分鐘 ping 一次儀表板以證明主機存活。

當需要代理決定說什麼時使用常規(LLM 驅動)的 cron 任務——例如總結長文檔、從 feed 中挑選有趣的項目、起草人性化的消息。無代理路徑適用於腳本的 stdout 本身就是消息的情況。

從聊天中創建

無代理模式的真正優勢在於,代理本身可以為你設置看門狗——無需編輯器,無需 shell,無需記憶 CLI 標誌。你描述所需內容,Hermes 編寫腳本、安排調度,並告知你何時觸發。

示例對話

**你:**如果 RAM 超過 85%,每 5 分鐘在 Telegram 上提醒我

Hermes:(寫入 ~/.hermes/scripts/memory-watchdog.sh,然後使用 no_agent=true 調用 cronjob(...)

已設置。每 5 分鐘運行一次,僅在 RAM 超過 85% 時向 Telegram 發出警報。腳本:memory-watchdog.sh。任務 ID:abc123

在底層,代理進行了兩次工具調用:

# 1. Write the check script
write_file(
path="~/.hermes/scripts/memory-watchdog.sh",
content='''#!/usr/bin/env bash
ram_pct=$(free | awk '/^Mem:/ {printf "%d", $3 * 100 / $2}')
if [ "$ram_pct" -ge 85 ]; then
echo "RAM ${ram_pct}% on $(hostname)"
fi
# Empty stdout = silent tick; no message sent.
''',
)

# 2. Schedule it — no_agent=True skips the LLM on every tick
cronjob(
action="create",
schedule="every 5m",
script="memory-watchdog.sh",
no_agent=True,
deliver="telegram",
name="memory-watchdog",
)

從那一刻起,每次心跳都是免費的:調度器運行腳本,如果 stdout 非空則將其管道傳輸到 Telegram,並且絕不接觸模型。

代理為你做出的決定

當你提出類似“當 X 發生時提醒我”或“每 N 分鐘檢查 Y 並在 Z 發生時告訴我”這樣的請求時,Hermes 的 cronjob 工具描述會指示它在消息內容完全由腳本確定時使用 no_agent=True。當請求需要推理時(“總結新問題”“挑選最有趣的頭條新聞”“起草友好的提醒”),它會回退到正常的 LLM 驅動路徑。

你不必自己指定 --no-agent。只需描述行為即可。

從聊天中管理看門狗

代理可以像創建任務一樣暫停、恢復、編輯和刪除任務:

**你:**今晚停止內存看門狗

Hermes:(調用 cronjob(action='pause', job_id='abc123')

已暫停。通過說“重新開啟它”或使用 hermes cron resume abc123 來恢復。

**你:**改為每 15 分鐘一次

Hermes:(調用 cronjob(action='update', job_id='abc123', schedule='every 15m')

完整的生命週期(創建/列出/更新/暫停/恢復/立即運行/刪除)對代理可用,而你無需學習任何 CLI 命令。

從 CLI 創建

更喜歡使用 shell?CLI 路徑通過三個命令提供相同的結果:

# 1. Write your script
cat > ~/.hermes/scripts/memory-watchdog.sh <<'EOF'
#!/usr/bin/env bash
# Alert when RAM usage is over 85%. Silent otherwise.
RAM_PCT=$(free | awk '/^Mem:/ {printf "%d", $3 * 100 / $2}')
if [ "$RAM_PCT" -ge 85 ]; then
echo "⚠ RAM ${RAM_PCT}% on $(hostname)"
fi
# Empty stdout = silent run; no message sent.
EOF
chmod +x ~/.hermes/scripts/memory-watchdog.sh

# 2. Schedule it
hermes cron create "every 5m" \
--no-agent \
--script memory-watchdog.sh \
--deliver telegram \
--name "memory-watchdog"

# 3. Verify
hermes cron list
hermes cron run <job_id> # fire it once to test

這就是全部。無需提示,無需技能,無需模型。

腳本輸出如何映射到投遞

腳本行為結果
退出碼 0,stdout 非空原樣投遞 stdout
退出碼 0,stdout 為空靜默心跳 — 無投遞
退出碼 0,stdout 最後一行包含 {"wakeAgent": false}靜默心跳(與 LLM 任務共享的門控機制)
非零退出碼投遞錯誤警報(因此損壞的看門狗不會靜默失敗)
腳本超時投遞錯誤警報

“為空時靜默”的行為是經典看門狗模式的關鍵:腳本可以自由地每分鐘運行,但通道僅在確實需要注意時才看到消息。

腳本規則

腳本必須位於 ~/.hermes/scripts/ 中。這在任務創建時和運行時都會強制執行——絕對路徑、~/ 展開和路徑遍歷模式(../)會被拒絕。該目錄與 LLM 任務使用的預檢查腳本門控共享。

解釋器的選擇取決於文件擴展名:

擴展名解釋器
.sh, .bash/bin/bash
其他任何擴展名sys.executable(當前 Python)

我們故意不遵循 #!/... shebang——保持解釋器集明確且精簡,可以減少調度器信任的攻擊面。

調度語法

與其他所有 cron 任務相同:

hermes cron create "every 5m"        # interval
hermes cron create "every 2h"
hermes cron create "0 9 * * *" # standard cron: 9am daily
hermes cron create "30m" # one-shot: run once in 30 minutes

請參閱 cron 功能參考 瞭解完整語法。

投遞目標

--deliver 接受網關所知的一切內容。一些常見的形式:

--deliver telegram                       # platform home channel
--deliver telegram:-1001234567890 # specific chat
--deliver telegram:-1001234567890:17585 # specific Telegram forum topic
--deliver discord:#ops
--deliver slack:#engineering
--deliver signal:+15551234567
--deliver local # just save to ~/.hermes/cron/output/

對於機器人令牌平臺(Telegram、Discord、Slack、Signal、SMS、WhatsApp),在腳本運行時不需要運行中的網關——該工具使用 ~/.hermes/.env / ~/.hermes/config.yaml 中已有的憑據直接調用每個平臺的 REST 端點。

編輯與生命週期

hermes cron list                                    # see all jobs
hermes cron pause <job_id> # stop firing, keep definition
hermes cron resume <job_id>
hermes cron edit <job_id> --schedule "every 10m" # adjust cadence
hermes cron edit <job_id> --agent # flip to LLM mode
hermes cron edit <job_id> --no-agent --script# flip back
hermes cron remove <job_id> # delete it

所有適用於 LLM 作業的操作(暫停、恢復、手動觸發、更改投遞目標)也適用於無代理作業。

實際示例:磁盤空間警報

cat > ~/.hermes/scripts/disk-alert.sh <<'EOF'
#!/usr/bin/env bash
# Alert when / or /home is over 90% full.
THRESHOLD=90
df -h / /home 2>/dev/null | awk -v t="$THRESHOLD" '
NR > 1 && $5+0 >= t {
printf "⚠ Disk %s full on %s\n", $5, $6
}
'
EOF
chmod +x ~/.hermes/scripts/disk-alert.sh

hermes cron create "*/15 * * * *" \
--no-agent \
--script disk-alert.sh \
--deliver telegram \
--name "disk-alert"

當兩個文件系統的使用率均低於 90% 時保持靜默;當某個文件系統超出閾值時,每個超標的文件系統恰好觸發一行輸出。

與其他模式的比較

方法運行內容何時使用
cronjob --no-agent(本頁)按 Hermes 的計劃運行你的腳本不需要推理的週期性看門狗/警報/指標
cronjob(默認,LLM)帶有可選預檢查腳本的代理當消息內容需要對數據進行推理時
OS cron + 向 webhook 訂閱 發送 curl按 OS 計劃運行你的腳本當 Hermes 可能不健康時(即你正在監控的對象)

對於必須在 即使網關宕機時 也能觸發的關鍵系統健康看門狗,請使用操作系統級別的 cron 並通過普通的 curl 向 Hermes webhook 訂閱(或任何外部警報端點)發送請求——這些作為獨立的操作系統進程運行,不依賴於 Hermes 是否處於運行狀態。當被監控的對象是外部系統時,網關內調度器是正確的選擇。