Skip to content

Commit be683e3

Browse files
authored
Merge pull request #3526 from dgageot/worktree-board-4db44a406235cbef
docs: add desktop notifications with hooks tip
2 parents 3f68a00 + c2cf744 commit be683e3

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

docs/guides/tips/index.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,48 @@ settings:
377377

378378
This model is used when you run `docker agent run` without a config file.
379379

380+
### Get Desktop Notifications with Hooks
381+
382+
Long-running agents shouldn't require staring at the terminal. Add [global hooks](../../configuration/hooks/index.md#global-user-level-hooks) to your user config so every agent notifies you when it needs attention or finishes:
383+
384+
```yaml
385+
# ~/.config/cagent/config.yaml
386+
settings:
387+
hooks:
388+
# Agent is waiting for your input (question, approval prompt, ...)
389+
on_user_input:
390+
- type: command
391+
command: osascript -e 'display notification "Agent needs your input" with title "docker-agent"'
392+
393+
# Agent finished responding
394+
stop:
395+
- type: command
396+
command: osascript -e 'display notification "Task finished" with title "docker-agent"'
397+
```
398+
399+
On Linux, replace `osascript` with `notify-send`:
400+
401+
```yaml
402+
command: notify-send "docker-agent" "Agent needs your input"
403+
```
404+
405+
To also get alerted on errors and warnings, hook the `notification` event and read the message from the JSON payload on stdin:
406+
407+
```yaml
408+
settings:
409+
hooks:
410+
notification:
411+
- type: command
412+
timeout: 10
413+
command: |
414+
MESSAGE=$(cat | jq -r '.notification_message // "Agent error"')
415+
osascript -e "display notification \"$MESSAGE\" with title \"docker-agent\""
416+
```
417+
418+
If a sound is enough, set `settings: { sound: true }` instead — docker-agent plays a notification sound when a task that ran longer than `sound_threshold` seconds (default 10) succeeds or fails.
419+
420+
See the [Hooks documentation](../../configuration/hooks/index.md) for the full list of events and their payloads.
421+
380422
### GitHub PR Reviewer Example
381423

382424
Use docker-agent as a GitHub Actions PR reviewer:

0 commit comments

Comments
 (0)