Skip to main content

Hooks

Hooks are local event handlers that run inside the gateway when matching Fased events occur. They are useful for small runtime extensions such as session memory, startup files, command logging, and plugin-side tool-result transforms. Hooks are local runtime extensions. For inbound HTTP automation, read Webhooks.

Normal path

Most users only need the bundled session-memory hook.
  1. Enable session-memory during onboarding or from Agent > Memory.
  2. Use Extensions > Hooks to inspect enabled hook packs.
  3. Use Advanced > Config only when a hook has no UI yet.
  4. Restart the gateway if the UI says runtime hook state has not caught up.
Custom hooks and hook packs are executable code. Review the source before installing or enabling them.

Bundled hooks

session-memory Event: /new, /reset. Archives recent session context into the Agent workspace memory area. Normal setup path: onboarding or Agent > Memory. boot-md Event: gateway startup. Runs BOOT.md from each Agent workspace on gateway start. Normal setup path: operator startup automation. bootstrap-extra-files Event: agent bootstrap. Adds extra workspace files into Agent bootstrap context. Normal setup path: advanced workspace setup. command-logger Event: commands. Appends command events to ~/.fased/logs/commands.log. Normal setup path: debug command usage. Useful commands:

Discovery

Hooks are loaded from these sources, later sources winning name conflicts:
  1. extra hook directories from hooks.internal.load.extraDirs
  2. bundled hooks: <fased>/dist/hooks/bundled/
  3. managed hooks: ~/.fased/hooks/
  4. workspace hooks: <workspace>/hooks/
Each hook is a directory:

Hook packs

Hook packs are npm packages that expose one or more hooks through package.json -> fased.hooks. Install with:
Rules:
  • npm specs are registry-only
  • local directories and local archives are supported for operator-controlled installs
  • Git, URL, and arbitrary remote specs are rejected
  • hook entries must resolve inside the package directory
  • dependencies install with npm install --ignore-scripts
Example:
Keep hook-pack dependency trees small and treat third-party hook packs as executable code.

Hook metadata

HOOK.md combines metadata and human docs.
Supported metadata.fased fields:
  • emoji
  • events
  • export
  • homepage
  • requires
  • always
  • install
requires can check binaries, environment variables, config keys, and OS constraints before a hook is considered eligible.

Handler shape

Handlers are async functions that inspect an event, optionally append messages to the event, and may perform a small side effect.
Handlers receive:
  • type
  • action
  • sessionKey
  • agentId
  • config
  • event-specific payload
Filter events early, keep handlers fast, and avoid throwing for ordinary non-matching events.

Event families

Command Examples: command:new, command:reset, command:custom. Agent Example: agent:bootstrap. Gateway Examples: gateway:startup, gateway:shutdown. Message Examples: message:received, message:sent. Tool result Plugin-side tool-result transforms. Tool-result hooks are intentionally narrow. They can transform tool output for a participating plugin path. Tool, credential, wallet, mining, and marketplace authority stay in their owning surfaces.

Configuration

Current config shape:
For internal runtime hooks, use hooks.internal.enabled and hooks.internal.entries. Top-level hooks.enabled belongs to HTTP webhook ingress, not local runtime hooks.

Debugging

Start with:
Common causes: Hook not discovered Check directory name, HOOK.md, load source, and name collisions. Hook not eligible Check missing binary, env var, config key, or OS requirement. Hook not executing Check event name, enabled state, gateway restart, and logs. Handler errors Catch expected failures and write concise diagnostics.

See also