1 / 17
⏰
الموديول 08 — الأتمتة

الأتمتة — Cron و Webhooks

خلّي الوكيل يشتغل وانت نايم — بجداول بلغة طبيعية وتنبيهات وويب هوoks
17 شريحة ثنائي اللغة تطبيق عملي
شريحة 2 — إزاي بيشتغل الـ cron مع وكيل
إزاي بيشتغل الـ cron مع وكيل
الـ cron التقليدي program scheduler صرف — الوكيل بيحتاج tick ثم session ثم delivery
cron تقليدي cron للوكيل
المُجدوَل process agent turn كامل (prompt + موديل + أدوات)
الملف المُنفَّذ shell script prompt نصي الوكيل بيفسّره
المخرجات stdout ثابت رد الوكيل بلغة طبيعية
الوجهة ملف / mail قناة مراسلة (Telegram, Discord…) أو webhook
الحتمية تام احتمالي — نفس الـ prompt ممكن يطلع مختلف
التكلفة صفر tokens لكل tick
Tick → Session → Delivery
+------------------------------------------------------------------+ | SCHEDULER (Gateway) — tick كل 60 ثانية | | 1. يحمّل jobs من ~/.hermes/cron/jobs.json | | 2. يقارن next_run_at بالوقت الحالي | | 3. claim ذري عبر .tick.lock (منع التكرار) | | 4. لكل job مستحق → جلسة AIAgent جديدة | +------------------------------------------------------------------+ | ▼ FRESH AGENT SESSION: system prompt عادي + tools محددة + optional: script pre-run → stdout في الـ prompt + hard interrupt بعد 3 دقائق لكل run | ▼ DELIVERY: الرد النهائي → deliver target + نسخة في ~/.hermes/cron/output/<job_id>/<ts>.md + ledger في executions.db +------------------------------------------------------------------+
⚠️
النقطة الحرجة
الرد النهائي للوكيل بيتسلّم تلقائياً — الوكيل مش بيبعت بنفسه.
شريحة 3 — Hermes cron والجداول بلغة طبيعية
Hermes cron والجداول بلغة طبيعية
اكتب «every monday 9am» بدل ما تحسب cron expression
ℹ️
الـ cron جزء من الـ gateway — hermes cron run بيشتغل متزامن من غير scheduler.
bash
# البوابة: cron جزء منها — لازم تكون شغالة
hermes gateway install                 # خدمة مستخدم
sudo hermes gateway install --system     # على السيرفرات: بتتشت مع البوت
hermes gateway run                       # foreground — الأفضل للـ debug

# إنشاء job — ترتيب الـ positional args: schedule الأول، prompt التاني
hermes cron create "every 2h" "Check server status"

# من الشات
/cron add "every 2h" "Check server status"
/cron add "in 30m" "Remind me to check the build"

# بأعلام كاملة
hermes cron create "every 1d at 09:00" "Audit open PRs and post a summary" \
  --name "daily-pr-audit" \
  --deliver telegram \
  --repeat 0
Schedule formats
in 30m → مرة واحدة بعد 30 دقيقة every 2h / every hour → فترات متكررة every monday 9am → أسبوعياً Mondays الساعة 9:00 weekdays at 9am / weekends at 10am / daily at 7am 0 9 * * 1-5 → cron expression (5 حقول) 2026-03-15T09:00:00 → ISO timestamp، مرة واحدة
⚠️
الـ prompt لازم يكون مكتفي بذاته
كل run في جلسة جديدة تمامًا — الـ prompt هو المهمة، الـ skill هو الإجراء.
شريحة 4 — توفير التكلفة: no-agent و wakeAgent
توفير التكلفة: no-agent و wakeAgent
افصل التنفيذ عن الاستنتاج — الـ script الرخيص يقرر
ℹ️
job كل دقيقة = 1440 استدعاء يومياً. الـ script بيفحص ويقرر.
bash
# الوضع الخالي من الوكيل: الـ script هو الـ job — صفر LLM
hermes cron create "every 5m" \
  --no-agent \
  --script memory-watchdog.sh \
  --deliver telegram \
  --name "memory-watchdog"

# بوابة wakeAgent: لو السكربت طبع {"wakeAgent": false} كآخر سطر
# الـ cron بيتخطى الـ agent run بالكامل للـ tick ده
hermes cron create "every 30m" "A new feed.json has landed. Summarize what changed." \
  --script feed-changed.sh

# وضع الرصد — نفس الفلسفة بس من غير سكربت تكتبه بنفسك
hermes cron create "every 5m" "If the output changed, report what changed" \
  --monitor-script health-check.sh \
  --deliver telegram
python
# ~/.hermes/scripts/new-rows.py
import json, sqlite3
conn = sqlite3.connect("/home/me/data/app.db")
n = conn.execute(
    "SELECT COUNT(*) FROM messages WHERE ts > strftime('%s','now','-2 hours')"
).fetchone()[0]
if n < 1:
    print(json.dumps({"wakeAgent": False}))          # صفر تكلفة
else:
    print(json.dumps({"wakeAgent": True, "context": {"new_rows": n}}))
الحالة الأداة التكلفة
شغل يحتاج استنتاج job عادي + prompt ticks × tokens
شغل محدد بالكامل بالسكربت --no-agent --script ✔ $0
استطلاع كل 1–5 دقايق script + wakeAgent ✔ $0 في الفاضي
كشف حدث فوري webhook deliver_only ✔ $0
⚠️
مخرجات الـ --monitor-script لازم تكون مستقرة — مفيش timestamps.
شريحة 5 — تسليم الـ jobs لمنصات المراسلة
تسليم الـ jobs لمنصات المراسلة
20+ وجهة — بـ --deliver، مش بمطالبة الوكيل يبعت
bash
# الوجهات الشائعة في --deliver
hermes cron create "every 1d at 7am" "Write the daily ops report as your final reply" \
  --deliver "telegram,discord" \
  --name daily-ops-report

# failure-deliver: وجهة إشعارات الفشل بس — local = اكتم الفشل
hermes cron create "every 1h" "Probe the API" \
  --deliver local \
  --failure-deliver telegram

# كل قيم التسليم Possible
origin | local | telegram | telegram:123456 | telegram:-100123:17585
discord | discord:#engineering | slack | whatsapp | signal | matrix
mattermost | email | sms | homeassistant | dingtalk | feishu | wecom
weixin | bluebubbles | qqbot | bot-chat | bot-chat:research
all | origin,all
Delivery status — execution and delivery are tracked separately
ok اشتغل واتسلّم delivery_failed اشتغل بنجاح لكن الخرج موصلش (5xx، rate limit) failed الـ run نفسه فشل blocked_config فشل preflight — مفيش نداء LLM خالص unknown attempt اتقطع — سجل تدقيق، مش بيتعاد تشغيله * فشل التسليم مش بيحسب على failure_streak — الوكيل خلّص شغله
⚠️
❌ «ابعتلي على تيليجرام» — الوكيل مش بيبعت. ✅ اكتب النتيجة في ردك النهائي.
yaml
# ~/.hermes/config.yaml
cron:
  wrap_response: false                      # سلّم الرد الخام من غير إطار
  media_send_timeout_seconds: 600           # 10 دقايق لكل مرفق
  bot_chat_delivery_timeout_seconds: 900    # bot-chat = شواهد، مش ثواني
  standalone_send_timeout_seconds: 120
  script_timeout_seconds: 1800              # 30 دقيقة
شريحة 6 — الحلقات المتكررة /loop
الحلقات المتكررة /loop
تكرار داخل جلستك الحالية — كل استيقاظ agent turn حقيقي
text
# فترة ثابتة — إنت اللي بتحدد الساعة
/loop 2m poll the build at ci.example.com/job/42 and ping me the moment it finishes
/loop 2m poll CI --times 30
/loop 5m watch the queue --until queue depth reaches zero

# إيقاع ذاتي — Hermes بيحدد الساعة (backoff أُسّي من floor لـ ceiling)
/loop keep an eye on the migration and summarize progress

# التحكم
/loop                     # الحالة: الإيقاع والتكرارات والوقت للـ tick الجاي
/loop pause / loop resume / loop stop
/proactive ...                # alias لـ /loop
/loop /goal cron
المُحفّز Timer أو self-paced حكم الـ judge بعد كل turn جدول، بره أي جلسة
مين بيشغّل جلستك الحالية جلستك الحالية جلسة جديدة لكل run
ينتهي لما شرط التوقف / سقف التكرارات / إنت الهدف يتحقق / الميزانية / إنت إنت تمسح الـ job
الأفضل لـ polling، مراقبة، إعادة تشغيل دورية هدف واحد، تكرار لحد ما يخلص غير مراقب، جداول طويلة الأمد
ℹ️
شروط التوقف: LOOP_COMPLETE · --times · --until · /loop stop · loops.max_ticks.
yaml
# ~/.hermes/config.yaml
loops:
  min_interval_seconds: 30        # حد أدنى للفترات الثابتة
  max_ticks: 100                  # ميزانية backstop (0 = بلا حد)
  self_paced_floor_seconds: 60    # بداية الإيقاع الذاتي
  self_paced_ceiling_seconds: 900 # أقصى backoff ذاتي
شريحة 7 — نبضات الجلسات (Heartbeat)
نبضات الجلسات (Heartbeat)
monitor مملوك للنظام يشغّل turn دوري — مش cron
json5
{
  commands: {
    ownerAllowFrom: ["telegram:123456789"],
  },
  agents: {
    defaults: {
      heartbeat: {
        every: "30m",
        target: "owner",   // افتراضي: DM المشغّل من ownerAllowFrom
      },
    },
    entries: {
      main: { default: true },
      ops: {
        heartbeat: { every: "1h", target: "whatsapp", to: "+155****4567" },
      },
    },
  },
}
bash
# monitor scratch = "checklist الـ heartbeat" — بيتلحق بالـ prompt لو موجود
openclaw cron list --all                      # عشان تجيب الـ jobId
openclaw cron scratch <jobId>                 # اقرأ الحالي
openclaw cron scratch <jobId> --set "..."     # استبدل بنص محدد
openclaw cron scratch <jobId> --file notes.md # من ملف (- للـ stdin)
openclaw cron scratch <jobId> --unset         # امسحه

# التحكم اليدوي
openclaw system event --text "Check for urgent follow-ups" --mode now
openclaw system heartbeat last
openclaw system heartbeat enable
openclaw system heartbeat disable
ℹ️
عقد الاستجابة: NO_REPLY / HEARTBEAT_OK ≤ 300 حرف → الرد بيتسقط.
OpenClaw Hermes
المفهوم monitor مملوك للنظام /loop = turn داخل جلستك
الافتراضي 30m (أو 1h بـ OAuth) /loop بيبدأ بإيقاعك إنت
الاعتمادية ✘ معلّق لو cron.enabled: false ✔ cron مستقل تماماً
Retry دقيقة سماح + طابور دائم retry_unreachable: 5/15/30 د
شريحة 8 — الـ Webhooks الواردة
الـ Webhooks الواردة
HTTP server بيستقبل POST، يتحقق من HMAC، ويحوّل الـ payload لـ prompt
bash
# ~/.hermes/.env — التفعيل
WEBHOOK_ENABLED=true
WEBHOOK_PORT=8644          # افتراضي
WEBHOOK_SECRET=your-global-secret

# التحقق إن السيرفر شغّال
curl http://localhost:8644/health
# {"status": "ok", "platform": "webhook"}

# نقطة عنوان الـ route
http://your-server:8644/webhooks/<route-name>

# الاشتراكات الديناميكية
hermes webhook subscribe github-issues \
  --events "issues" \
  --prompt "New issue #{issue.number}: {issue.title}\nBy: {issue.user.login}" \
  --deliver telegram --deliver-chat-id "-100123456789"
hermes webhook list
hermes webhook test github-issues --payload '{"issue": {"number": 42, "title": "Test"}}'
hermes webhook remove github-issues
yaml
# ~/.hermes/config.yaml — مثال كامل
platforms:
  webhook:
    enabled: true
    extra:
      port: 8644
      secret: "global-fallback-secret"
      routes:
        github-pr:
          events: ["pull_request"]
          secret: "github-webhook-secret"
          prompt: |
            Review this pull request:
            Repository: {repository.full_name}
            PR #{number}: {pull_request.title}
            URL: {pull_request.html_url}
          skills: ["github-code-review"]
          deliver: "github_comment"
          deliver_extra:
            repo: "{repository.full_name}"
            pr_number: "{number}"
        deploy-notify:
          events: ["push"]
          secret: "deploy-secret"
          prompt: "New push to {repository.full_name} {ref}: {head_commit.message}"
          filters:
            - field: "ref"
              equals: "refs/heads/main"
          deliver: "telegram"
⚠️
HMAC بيصادق على المرسِل مش على المحتوى. الحد الحقيقي هو سطح قدرات الوكيل: sandbox للـ runtime، وtoolset محدود، وapprovals شغالة.
المصدر آلية التحقق
GitHub X-Hub-Signature-256 — HMAC-SHA256
GitLab X-Gitlab-Token — مطابقة نصية
Generic V2 (موصى به) X-Webhook-Signature-V2 ±300 ثانية
Standard Webhooks webhook-id + webhook-signature
شريحة 9 — الهوكات الصادرة والتنبيهات
الهوكات الصادرة والتنبيهات
deliver_only يدفع إشعار عادي — صفر LLM
yaml
# Push إشعار فوري — صفر توكنز، تسليم أقل من ثانية
platforms:
  webhook:
    enabled: true
    extra:
      port: 8644
      secret: "global-secret"
      routes:
        antenna-matches:
          secret: "antenna-webhook-secret"
          deliver: "telegram"
          deliver_only: true
          prompt: "🎉 New match: {match.user_name} matched with you!"
          deliver_extra:
            chat_id: "{match.telegram_chat_id}"

# تعليق على PR — بيحتاج gh CLI متوثّق
        github-pr:
          deliver: "github_comment"
          deliver_extra:
            repo: "{repository.full_name}"
            pr_number: "{number}"
bash
# تسليم github_comment بيستخدم gh CLI — لازم يتوثّق على الـ host
gh auth login

# أنواع التسليم المتاحة في الـ webhook
log (افتراضي ومفيد للاختبار) | github_comment
telegram | discord | slack | signal | sms | whatsapp
matrix | mattermost | homeassistant | email
dingtalk | feishu | wecom | weixin
الكود المعنى
200 OK اتسلّم
200 (duplicate) تكرار خلال ساعة
202 اتدَمج أو اتجدول
401 توقيع HMAC غلط
404 اسم route مش معروف
413 / 429 تجاوز الحجم / rate limit
502 الهدف رفض
⚠️
أخطاء الإعداد اللي بتترفض
deliver_only: true يتطلب deliver هدف حقيقي.
شريحة 10 — العمارة المدفوعة بالأحداث
العمارة المدفوعة بالأحداث
poll مقابل push — والطبقات الأربع
Polling Event-driven
إيه اللي بيزوّد الاستهلاك عدد الـ ticks عدد الأحداث الفعلية
زمن الاكتشاف حتى طول الفترة ✔ فوراً
حمل LLM كل tick بس لما حدث فعلي
مثال /loop 2m poll CI webhook على pull_request_review
The four layers
+----------------------------------------------------------+ | 1. TIME ← cron / automations (الطابع الزمني) | | "كل يوم 9، اعمل X" | +----------------------------------------------------------+ | 2. EVENT ← webhooks + hooks (الحافز) | | "لما Y يحصل، اعمل Z فوراً" | +----------------------------------------------------------+ | 3. STATE ← monitors / wakeAgent gates (الفرق) | | "لو اتغيّر → قولّي، لو لأ → اصمت" | +----------------------------------------------------------+ | 4. FLOW ← context_from / Task Flow (التنسيق) | | "خط A جاب الداتا → خط B حوّلها → خط C بلّغ" | +----------------------------------------------------------+ + co 5. FLOW ← event-triggered cron (cron_job) — شعل job فوراً
bash
# OpenClaw — event-driven من stdout/stderr lines لعملية طويلة
openclaw automations add \
  --name "Build event stream" \
  --stream-command '["node","scripts/build-events.mjs"]' \
  --stream-mode match \
  --stream-match '^(failed|recovered):' \
  --stream-batch-ms 250 \
  --session isolated \
  --message "Investigate these build events."
شريحة 11 — تنسيق العمليات متعدد الخطوات
تنسيق العمليات متعدد الخطوات
سلاسل الـ jobs، الاستمرارية، والـ notepad الدائم
python
# السلسلة عبر context_from — آخر output ناجح بيتحقن فوق الـ prompt
cronjob(action="create", name="daily-digest",
        schedule="every day 7am",
        context_from=["ai-news-fetch", "github-prs-fetch"],
        prompt="Write the daily digest using the outputs above.")

# الاستمرارية — كل run بيشوف output الـ run السابق
cronjob(action="create", name="incremental-digest",
        schedule="every 1h",
        prompt="Summarize only what's new since the last digest")
bash
# الاستمرارية من الـ CLI
hermes cron create "every 1h" "Summarize only what's new since the last digest" \
  --continuity --name incremental-digest

# الـ notepad الدائم — KV ثابت عبر الـ runs للـ job
hermes cron notepad <job_id> list
hermes cron notepad <job_id> set last_page 42
hermes cron notepad <job_id> get last_page
hermes cron notepad <job_id> delete last_page

# event-triggered cron: شعل job موجود عند كل حدث webhook
hermes webhook subscribe pr-feedback \
  --events "pull_request_review" \
  --cron-job "pr-review-sweeper" \
  --prompt "PR #{number} received feedback: {review.body}"
الآلية Hermes OpenClaw
سلسلة الوظائف ✔ context_from ✘
استمرارية الـ run ✔ --continuity ✘
Event-triggered cron ✔ cron_job ✘
KV دائم للـ job ✔ cron notepad scratch (heartbeat)
Task Flow متعدد الخطوات ✘ ✔ openclaw tasks flow
Stream source ✘ ✔ --stream-command
⚠️
السلسلة بتقرا آخر output مكتمل — مش بتستنى jobs في نفس الـ tick.
شريحة 12 — معالجة الأخطاء وإعادة المحاولة
معالجة الأخطاء وإعادة المحاولة
preflight قبل أي تكلفة، سلّم 5/15/30، وحوادث بتنبهك مرة واحدة
bash
# سجل المحاولات — claimed → running → (completed | failed | unknown)
hermes cron runs <job-id> --limit 20    # alias: history

# الحوادث: ننبّه مرة واحدة على نفس الخطأ، مش كل run
hermes cron incidents
hermes cron incidents --state alerted     # detected | alerted | resolved | closed
hermes cron incidents ack <id>           # اعترف — اسكت التوقيع ده للأبد

# فحص شامل read-only — بيخرج بـ 1 لو فيه ملاحظة قائمة
hermes cron doctor
yaml
# ~/.hermes/config.yaml
cron:
  preflight: false                     # تعطيل فحص ما قبل أي تكلفة
  retry_unreachable: false              # default true — يعطّل re-runs الـ 5/15/30
  failure_repeat_alert_hours: 6         # تذكير واحد بعد 6 ساعات، بعدين صمت (0 = كل run)
  failure_nudge_threshold: 3            # default — 0 يعطّل الـ nudge
  misfire_grace_minutes: 10             # استنى قد إيه قبل catch-up محلي (0 = يعطّل)
  catch_up_missed: false                # default: true
  allow_agent_scheduling: false         # جلسات الـ cron ما تقدرش تنشئ cron
  require_restart_safe_scope: true      # fail closed بدل degradation
Incident lifecycle
detected ──► alerted ──► resolved (الـ job شغّل تمام بعد كده) └──► closed (معترف — نهائي للتوقيع ده) التكرار بيتحبس طول ما الـ incident في حالة alerted خطأ مختلف → incident جديد و ping فوراً run ناجح → بيعيد تسلّيح التوقيع فالخطأ نفسه بعد run أخضر ينبه تاني
ℹ️
Preflight قبل أي تكلفة: blocked_config + تنبيه واحد + صفر نداء LLM.
bash
# التوقف الطارئ العام — مفيش cron fire بيبدأ من أي باب
hermes pause --reason "incident response"
hermes resume
# الـ runs اللي بدأت مش بتتقتل، والتشغيل اليدوي بيفضل شغال

# الإصلاح الدائم لسلامة إعادة التشغيل تحت systemd
sudo loginctl enable-linger <gateway-user>
شريحة 13 — المراقبة والسجلات
المراقبة والسجلات
أربعة أوامر بتشوفك بالظبط
bash
# حالة المجدول: حي؟ أقرب run؟ في OVERDUE؟
hermes cron status
hermes cron list --all

# لوجات الـ gateway
journalctl -u hermes-gateway -f     # Linux service
tail -f ~/.hermes/logs/gateway.log     # الملف
openclaw logs --follow                 # OpenClaw
Where the red flags show up
hermes cron status → ⚠ Next run <time> is OVERDUE — passed 7h ago hermes cron list → Overdue: في الصف Dashboard / Desktop → Overdue since hermes cron doctor → يجمع: فشل run، فشل تسليم، dispatch متأخر، سكربت مفقود، no_agent من غير سكربت، workdir مش موجود
bash
#!/usr/bin/env bash
# ~/.hermes/scripts/cron-health.sh — جدول المراقبة الأسبوعي
echo "=== Cron health $(date -u +%FT%TZ) ==="
hermes cron status || echo "SCHEDULER PROBLEM"
echo "--- Doctor ---"
hermes cron doctor || echo "DOCTOR FOUND ISSUES"
echo "--- Open incidents ---"
hermes cron incidents --state alerted
echo "--- Recent failures ---"
hermes cron runs --limit 20
⚠️
catch-up ناجح مش بيمسح تحذير التأخّر — الـ dispatch التالي في ميعاده بيمسحه.
شريحة 14 — حالات استخدام حقيقية
حالات استخدام حقيقية
من التقارير اليومية لمراجعة PR لحظياً ورصد الاستهلاك
📊
تقرير يومي 7:00
سكربت يجمع الداتا بدون LLM، والوكيل يلخّصها على تيليجرام.
🔍
مراجعة PR تلقائية
webhook على pull_request ينشر تعليق مراجعة عبر gh.
🚨
تنبيه فشل deploy
CI يبعت POST عند الفشل، وdeliver_only: true يدفع التنبيه فوراً.
🧠
memories مدمجة
bot-chat: المجدول بيتصرف في الخرج — المستلم هو البوت نفسه.
💸
مراقبة الاستهلاك
استطلاع كل 5 دقايق بـ --monitor-script — صفر تكلفة في غير المتغير.
🩺
watchdog صامت
--no-agent — stdout فاضي يعني صمت.
💡
القاعدة التي تحسم الاختيار
شغل وانت نايم؟ → cron · محادثة جارية؟ → /loop · رصد هادي؟ → heartbeat · حدث داخلي؟ → hook · HTTP POST خارجي؟ → webhook
شريحة 15 — OpenClaw مقابل Hermes في الأتمتة
OpenClaw مقابل Hermes في الأتمتة
المصفوفات المختارة — القدرات، التسليم، والأمان
الميزة OpenClaw Hermes Agent
جدول بلغة طبيعية --at، --every ✔ every monday 9am
تحكم في التوقيت ✔ --tz, --stagger ✘
Heartbeat ✔ مملوك للنظام ✘ استخدم /loop
Task Flow ✔ openclaw tasks flow ✘
Hooks داخلية ✔ openclaw hooks ✘
Webhook HMAC Bearer token ✔ 5 طرق + replay protection
Webhook filters + coalesce ✘ ✔ تعريفية + دمج
تسليم مباشر ✘ ✔ deliver_only
Event-triggered cron ✘ ✔ cron_job
No-agent / monitor mode --command payload ✔ --no-agent + monitor
Retry ladder error-backoff ✔ 5/15/30 د
Failure incidents ✘ ✔ hermes cron incidents
Preflight validation ✘ ✔ blocked_config
Job chaining ✘ ✔ context_from
وجوه التسليم --channel ✔ 20+ هدف
قفل طارئ عام تعطيل الـ jobs ✔ hermes pause
إعادة تشغيل آمنة ✔ .tick.lock + scope
💡
متى تختار إيه
محتاج Task Flow أو hooks داخلية أو heartbeat بـ scratch → ⭐ OpenClaw. محتاج webhook pipelines موثوقة وتحكم في التكلفة → ⭐ Hermes.
شريحة 16 — المشروع العملي
المشروع العملي
نظام التقارير اليومية الآلي — cron + webhook + retry
1
2
3
4
الطبقة الهدف المخرجات
1 — collect سكربت يجمع بيانات العمليات بدون LLM collect-ops.py → JSON
2 — daily cron تقرير يومي 7:00 على تيليجرام daily-ops-report
3 — webhook تنبيه فوري عند deploy فاشل deploy-failed route
4 — reliability watchdog صامت + تقرير صحة + kill switch cron-watchdog
bash
# 1. التجهيز — البوابة شغالة + السكربت في المسار الإجباري
hermes gateway status
mkdir -p ~/ops-report/scripts
cp ~/ops-report/scripts/collect.py ~/.hermes/scripts/collect-ops.py
python3 ~/.hermes/scripts/collect-ops.py /tmp/ops.json   # اختبره محلياً

# 2. الـ job اليومي — LLM بيخلّص الداتا المباشرة
hermes cron create "every day at 7am" \
  "Here is the ops data for today as JSON. Write a concise daily ops report
   in English with sections: (1) Service health (2) Deploys (3) Errors
   (4) Open PRs. End with a one-line overall health verdict
   (GREEN/YELLOW/RED). Keep it under 200 words. Write the report as your
   final response — do not send any message yourself." \
  --script collect-ops.py \
  --deliver telegram \
  --name daily-ops-report \
  --model gpt-5-mini \
  --reasoning-effort minimal

# 3. الـ watchdog الصامت — stdout فاضي يعني مفيش مشكلة
hermes cron create "every 30m" "" \
  --no-agent \
  --script cron-health.sh \
  --deliver telegram \
  --name cron-watchdog

# 4. التحقق النهائي
hermes cron doctor          # لازم يطلع 0 findings
hermes cron run daily-ops-report
hermes webhook test deploy-failed --payload '{"deployment": {"status": {}}}'
hermes pause && hermes resume
ℹ️
الـ prompt بيقول صراحةً «اكتب التقرير في ردك النهائي — متبعتش رسالة بنفسك».
💡
الـ checklist
تقرير يومي 7:00 ✅ · تنبيه فوري عند deploy فاشل ✅ · watchdog صامت ✅ · تقرير صحة أسبوعي ✅ · صفر تكلفة لما مفيش تغييرات ✅
شريحة 17 — اختبار المعرفة
اختبار المعرفة
اختبر نفسك — 5 أسئلة سريعة

اختبار الموديول 8

Score: 0/5
Q1: job يومي خلّص شغله بنجاح، بس الـ telegram adapter رجع 500 وقت التسليم. إيه الحالة؟
failed — الـ run فشل
delivery_failed — وبيتحفظ في last_delivery_error
ok — التسليم مش مهم
unknown — الـ attempt اتقطع
Q2: عايز job يفحص كل 5 دقايق لو فيه PR جديد، ويوقظ الوكيل بس لما في حاجة جديدة فعلاً. إيه أرخص طريقة؟
--script + بوابة wakeAgent
job عادي بـ prompt كامل كل 5 دقايق
--no-agent — الوكيل مش هيتنادى
/loop 5m في الجلسة
Q3: في الـ prompt بتكتب «راجع السيرفر وابعتلي النتيجة على تيليجرام». إيه اللي هيحصل؟
الوكيل هيبعت الرسالة بنفسه
الوكيل مش بيبعت — لازم تكتب النتيجة في ردك النهائي
الـ job هيفشل بـ blocked_config
Hermes بيقرا النص ويحوّله لـ deliver
Q4: job بيفشل كل ساعة بنفس الخطأ، وعايز متplugّش في إشعارك 24 مرة. إيه اللي بيعمله Hermes؟
بيرسل تنبيه كل run
incident بتوقيع الخطأ بيتسجل — تنبيه واحد بس
بيوقّف الـ job تلقائي
مش بيعمل حاجة
Q5: route webhook عايزك تدفع إشعار فوري على تيليجرام من غير ما الوكيل يفكر خالص. إيه الإعداد؟
deliver_only: true + deliver: telegram
--no-agent — ده flag للـ cron
deliver: log + deliver_only
coalesce بنافذة صفر