Skip to content

Commit 6c111cc

Browse files
committed
docs
1 parent e6a6e7f commit 6c111cc

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

docs/configuration.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,60 @@ ECA allows to totally customize the prompt sent to LLM via the `behavior` config
352352
}
353353
}
354354
```
355+
356+
## Hooks
357+
358+
Hooks are actions that can run before or after an specific event, useful to notify after prompt finished or to block a tool call doing some check in a script.
359+
360+
Allowed hook types:
361+
362+
- `prePrompt`: Run before prompt is sent to LLM, if a hook output is provided, append to user prompt.
363+
- `postPrompt`: Run after prompt is finished, when chat come back to idle state.
364+
- `preToolCall`: Run before a tool is called, if a hook exit with status `2`, reject the tool call.
365+
- `postToolCall`: Run after a tool was called.
366+
367+
__Input__: Hooks will receive input as json with information from that event, like tool name, args or user prompt.
368+
__Output__: All hook actions allow printing output (stdout) and errors (stderr) which will be shown in chat.
369+
__Matcher__: Specify whether to apply this hook checking a regex applying to `mcp__tool-name`, applicable only for `*ToolCall` hooks.
370+
371+
Examples:
372+
373+
=== "Notify after prompt finish"
374+
375+
```javascript
376+
{
377+
"hooks": {
378+
"notify-me": {
379+
"type": "postPrompt",
380+
"actions": [
381+
{
382+
"type": "shell",
383+
"shell": "notify-send \"Hey, prompt finished!\""
384+
}
385+
]
386+
}
387+
}
388+
}
389+
```
390+
391+
=== "Block specific tool call"
392+
393+
```javascript
394+
{
395+
"hooks": {
396+
"notify-me": {
397+
"type": "preToolCall",
398+
"matcher": "my-mcp__some-tool",
399+
"actions": [
400+
{
401+
"type": "shell",
402+
"shell": "echo \"We should not run this tool bro!\" >&2 && exit 2"
403+
}
404+
]
405+
}
406+
}
407+
}
408+
```
355409

356410
## Opentelemetry integration
357411

docs/features.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ The built-in commands are:
111111

112112
It's possible to configure custom command prompts, for more details check [its configuration](./configuration.md#custom-command-prompts)
113113

114-
### Login
114+
#### Login
115115

116116
It's possible to login to some providers using `/login` command, ECA will ask and give instructions on how to authenticate in the chosen provider and save the login info globally in its cache `~/.cache/eca/db.transit.json`.
117117

@@ -120,6 +120,14 @@ Current supported providers with login:
120120
- `anthropic`: with options to login to Claude Max/Pro or create API keys.
121121
- `github-copilot`: via Github oauth.
122122

123+
### Hooks
124+
125+
Hooks are actions that can run before or after an specific event, useful to notify after prompt finished or to block a tool call doing some check in a script.
126+
127+
![](./images/features/hooks.png)
128+
129+
For more details, check [hooks configuration](./configuration.md#hooks)
130+
123131
## OpenTelemetry integration
124132

125133
ECA has support for [OpenTelemetry](https://opentelemetry.io/)(otlp), if configured, server tasks, tool calls, and more will be metrified via otlp API.

images/features/hooks.png

45.2 KB
Loading

0 commit comments

Comments
 (0)