—to [email protected] \
—subject “watch test” \ —body “ping”18. Watch holati va tarixini tekshiring:
- gog gmail watch status —account [email protected] gog gmail history —account [email protected] —since <historyId> 20. Nosozliklarni bartaraf etish
-
Invalid topicName: loyiha nomuvofiqligi (topic OAuth client loyihasida emas).
-
User not authorized: topic’daroles/pubsub.publisheryetishmaydi. 23. Bo‘sh xabarlar: Gmail push faqathistoryIdberadi;gog gmail historyorqali olib keling.
- Tozalash
- gog gmail watch stop —account [email protected] gcloud pubsub subscriptions delete gog-gmail-watch-push gcloud pubsub topics delete gog-gmail-watch
-
- Hooks: buyruqlar va hayotiy sikl hodisalari uchun hodisaga asoslangan avtomatlashtirish
-
- Siz /new, /reset, /stop va agent hayotiy sikli hodisalari uchun hodisaga asoslangan avtomatlashtirishni xohlaysiz
-
- Siz hook’larni yaratmoqchi, o‘rnatmoqchi yoki nosozliklarni tuzatmoqchisiz
-
- Hooks
- Hooks 31. Hooks agent buyruqlari va hodisalariga javoban harakatlarni avtomatlashtirish uchun kengaytiriladigan hodisaga asoslangan tizimni taqdim etadi.
32. Hooks kataloglardan avtomatik aniqlanadi va CLI buyruqlari orqali boshqariladi, xuddi OpenClaw’dagi skill’lar kabi.
- Yo‘naltiruvchi ma’lumot
-
- Hooks — biror narsa sodir bo‘lganda ishga tushadigan kichik skriptlar.
-
- Ikki xil turi mavjud:
- Trigger custom automations on agent lifecycle events
- Extend OpenClaw’s behavior without modifying core code
12. Boshlash
Bundled Hooks
OpenClaw ships with four bundled hooks that are automatically discovered:- 💾 session-memory: Saves session context to your agent workspace (default
~/.openclaw/workspace/memory/) when you issue/new - 📝 command-logger: Logs all command events to
~/.openclaw/logs/commands.log -
- 🚀 boot-md: Shlyuz ishga tushganda
BOOT.mdni ishga tushiradi (ichki hooklar yoqilgan bo‘lishi kerak)
- 🚀 boot-md: Shlyuz ishga tushganda
- 😈 soul-evil: Swaps injected
SOUL.mdcontent withSOUL_EVIL.mdduring a purge window or by random chance
- Hookni yoqish:
16. Onboarding
- Onboarding paytida (
openclaw onboard), sizga tavsiya etilgan hooklarni yoqish taklif etiladi. The wizard automatically discovers eligible hooks and presents them for selection.
Hook Discovery
Hooks are automatically discovered from three directories (in order of precedence):- Workspace hooks:
<workspace>/hooks/(per-agent, highest precedence) - Managed hooks:
~/.openclaw/hooks/(user-installed, shared across workspaces) - Bundled hooks:
<openclaw>/dist/hooks/bundled/(shipped with OpenClaw)
18. Hook paketlari (npm/arxivlar)
Hook packs are standard npm packages that export one or more hooks viaopenclaw.hooks in
package.json. Install them with:
package.json:
HOOK.md and handler.ts (or index.ts).
Hook packs can ship dependencies; they will be installed under ~/.openclaw/hooks/<id>.
Hook tuzilmasi
HOOK.md formati
HOOK.md fayli YAML frontmatter’dagi metama’lumotlar hamda Markdown hujjatlarini o‘z ichiga oladi:
Metama’lumot maydonlari
metadata.openclaw obyekti quyidagilarni qo‘llab-quvvatlaydi:
emoji: CLI uchun ko‘rsatiladigan emoji (masalan,"💾")events: Kuzatish uchun hodisalar ro‘yxati (masalan,["command:new", "command:reset"])export: Foydalaniladigan nomlangan eksport (standart qiymati"default")homepage: Hujjatlar URL manzilirequires: Ixtiyoriy talablarbins: Required binaries on PATH (e.g.,["git", "node"])anyBins: At least one of these binaries must be presentenv: Required environment variablesconfig: Required config paths (e.g.,["workspace.dir"])os: Required platforms (e.g.,["darwin", "linux"])
always: Bypass eligibility checks (boolean)install: Installation methods (for bundled hooks:[{"id":"bundled","kind":"bundled"}])
Handler Implementation
Thehandler.ts file exports a HookHandler function:
Event Context
Each event includes:Event Types
Command Events
Triggered when agent commands are issued:command: All command events (general listener)command:new: When/newcommand is issuedcommand:reset: When/resetcommand is issuedcommand:stop: When/stopcommand is issued
Agent Events
agent:bootstrap: Before workspace bootstrap files are injected (hooks may mutatecontext.bootstrapFiles)
Gateway Events
Triggered when the gateway starts:gateway:startup: After channels start and hooks are loaded
Tool Result Hooks (Plugin API)
These hooks are not event-stream listeners; they let plugins synchronously adjust tool results before OpenClaw persists them.tool_result_persist: transform tool results before they are written to the session transcript. Must be synchronous; return the updated tool result payload orundefinedto keep it as-is. See Agent Loop.
Future Events
Planned event types:session:start: When a new session beginssession:end: When a session endsagent:error: When an agent encounters an errormessage:sent: When a message is sentmessage:received: When a message is received
Creating Custom Hooks
1. Choose Location
- Workspace hooks (
<workspace>/hooks/): Per-agent, highest precedence - Managed hooks (
~/.openclaw/hooks/): Shared across workspaces
2. Create Directory Structure
3. Create HOOK.md
4. Create handler.ts
5. Enable and Test
Configuration
New Config Format (Recommended)
Per-Hook Configuration
Hooks can have custom configuration:Extra Directories
Load hooks from additional directories:Legacy Config Format (Still Supported)
The old config format still works for backwards compatibility:CLI Commands
List Hooks
Hook Information
Check Eligibility
Enable/Disable
Bundled hook reference
21. session-memory
Saves session context to memory when you issue/new.
Events: command:new
Requirements: workspace.dir must be configured
Output: <workspace>/memory/YYYY-MM-DD-slug.md (defaults to ~/.openclaw/workspace)
What it does:
- Uses the pre-reset session entry to locate the correct transcript
- Extracts the last 15 lines of conversation
- Uses LLM to generate a descriptive filename slug
- Saves session metadata to a dated memory file
2026-01-16-vendor-pitch.md2026-01-16-api-design.md2026-01-16-1430.md(fallback timestamp if slug generation fails)
command-logger
Logs all command events to a centralized audit file. Events:command
Requirements: None
Output: ~/.openclaw/logs/commands.log
What it does:
- Captures event details (command action, timestamp, session key, sender ID, source)
- JSONL formatida log fayliga qo‘shadi
- Fon rejimida jim ishlaydi
soul-evil
Purge oynasi davomida yoki tasodifiy ehtimol bilan kiritilganSOUL.md tarkibini SOUL_EVIL.md bilan almashtiradi.
Hodisalar: agent:bootstrap
Hujjatlar: SOUL Evil Hook
Chiqish: Hech qanday fayl yozilmaydi; almashtirishlar faqat xotirada amalga oshadi.
Yoqish:
boot-md
Gateway ishga tushganda (kanallar ishga tushgandan so‘ng)BOOT.md ni ishga tushiradi.
Buning ishlashi uchun ichki hooklar yoqilgan bo‘lishi kerak.
Hodisalar: gateway:startup
Talablar: workspace.dir sozlangan bo‘lishi kerak
Nima qiladi:
- Workspace’ingizdan
BOOT.mdni o‘qiydi - Ko‘rsatmalarni agent runner orqali bajaradi
- So‘ralgan barcha tashqi xabarlarni message tool orqali yuboradi
Eng Yaxshi Amaliyotlar
Handlerlarni Tez Saqlang
Hooklar buyruqlarni qayta ishlash jarayonida ishlaydi. Ularni yengil saqlang:Xatolarni Muloyimlik Bilan Qayta Ishlang
Xavfli amallarni har doim o‘rab oling:Hodisalarni Erta Filtrlash
Agar hodisa mos kelmasa, darhol qayting:Aniq Hodisa Kalitlaridan Foydalaning
Imkon bo‘lsa, metadata’da aniq hodisalarni ko‘rsating:Nosozliklarni Tuzatish
Hook Loglashni Yoqish
Gateway ishga tushishda hook yuklanishini loglaydi:Kashfiyotni Tekshirish
Topilgan barcha hooklarni ro‘yxatlash:2. Roʻyxatdan oʻtishni tekshiring
- Handler ichida, chaqirilgan paytini log qiling:
5. Moslikni tekshiring
- Hook nima uchun mos emasligini tekshiring:
- Chiqishda yetishmayotgan talablarni qidiring.
9. Test qilish
10. Gateway loglari
- Hook bajarilishini ko‘rish uchun gateway loglarini kuzating:
13. Hook’larni bevosita test qilish
- Handler’laringizni alohida holatda test qiling:
16. Arxitektura
17. Asosiy komponentlar
-
src/hooks/types.ts: Tip ta’riflari
-
src/hooks/workspace.ts: Kataloglarni skanerlash va yuklash
-
src/hooks/frontmatter.ts: HOOK.md metadata’ni ajratib olish
-
src/hooks/config.ts: Moslikni tekshirish
-
src/hooks/hooks-status.ts: Holatni hisobot qilish
-
src/hooks/loader.ts: Dinamik modul yuklovchi
-
src/cli/hooks-cli.ts: CLI buyruqlari
-
src/gateway/server-startup.ts: Gateway ishga tushganda hook’larni yuklaydi
-
src/auto-reply/reply/commands-core.ts: Buyruq hodisalarini ishga tushiradi
27. Aniqlash oqimi
29. Hodisa oqimi
31. Nosozliklarni bartaraf etish
32. Hook topilmadi
-
- Katalog tuzilmasini tekshiring:
-
- HOOK.md formatini tekshiring:
-
- Barcha aniqlangan hook’larni ro‘yxatlang:
39) Hook mos emas
- Talablarni tekshiring:
- Yetishmayotganlarni qidiring:
-
- Binariylar (PATH’ni tekshiring)
-
- Muhit o‘zgaruvchilari
-
- Konfiguratsiya qiymatlari
-
- OS mosligi
47. Hook bajarilmayapti
-
- Hook yoqilganligini tekshiring:
-
- Hook’lar qayta yuklanishi uchun gateway jarayonini qayta ishga tushiring.
-
Check gateway logs for errors:
Handler Errors
Check for TypeScript/import errors:Migration Guide
From Legacy Config to Discovery
Before:-
Create hook directory:
-
Create HOOK.md:
-
Update config:
-
Verify and restart your gateway process:
- Automatic discovery
- CLI management
- Eligibility checking
- Better documentation
- Consistent structure