agent-notify-core 0.1.0

Core notification config and provider implementation for agent-notify.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
# agent-notify

A notification CLI for AI agents and automation scripts.

`agent-notify` provides the `notify` command for sending messages and generated files through configured notification channels.

```bash
notify send --channel personal --title "Task completed" --body "The report is ready."
```

## Supported Channels

* `file-log`
* `telegram`
* `discord-webhook`
* `discord-bot`
* `ntfy`
* `webhook`

The CLI can load, check, and send through the channel types above. External channel types require their configured service credentials or environment variables.


## Installation

Build from this repository:

```bash
cargo build --release
```

The binary is written to:

```text
target/release/notify
```

After the first published release, install with:

```bash
cargo install agent-notify
```

or download a prebuilt `notify` binary from the releases page.

## Quick Start

Create `notify.toml`:

```toml
default_channel = "local"

[channels.local]
type = "file-log"
path = "./notify-log"
```

Send a notification:

```bash
notify send --title "Hello" --body "Hello from agent-notify."
```

This writes a local JSONL log under `./notify-log`.

## Concepts

A `channel` is the configured destination name that users and agents select, such as `personal`, `team`, `phone`, `local`, or `automation`.

A channel has a `type`, which controls how the notification is delivered:

```text
telegram
discord-webhook
discord-bot
ntfy
webhook
file-log
```

Agents should use channel names and should not need to know service credentials or provider-specific API details.

## Configuration

`notify` looks for configuration in this order:

1. `--config <path>`
2. `./notify.toml`
3. `~/.config/agent-notify/config.toml`

Example:

```toml
default_channel = "personal"

[channels.personal]
type = "telegram"
bot_token_env = "NOTIFY_TELEGRAM_BOT_TOKEN"
chat_id_env = "NOTIFY_TELEGRAM_CHAT_ID"
parse_mode = "plain"

[channels.team]
type = "discord-webhook"
webhook_url_env = "NOTIFY_DISCORD_WEBHOOK_URL"
username = "Agent Notify"
allow_mentions = false

[channels.bot_team]
type = "discord-bot"
bot_token_env = "NOTIFY_DISCORD_BOT_TOKEN"
channel_id_env = "NOTIFY_DISCORD_CHANNEL_ID"
allow_mentions = false

[channels.phone]
type = "ntfy"
server = "https://ntfy.sh"
topic_env = "NOTIFY_NTFY_TOPIC"
token_env = "NOTIFY_NTFY_TOKEN"

[channels.automation]
type = "webhook"
url_env = "NOTIFY_WEBHOOK_URL"
auth_header_env = "NOTIFY_WEBHOOK_AUTH_HEADER"

[channels.local]
type = "file-log"
path = "./notify-log"
```

Sample files are included under:

```text
examples/notify.toml
examples/notify.env.example
```

## Secrets

Secret-like values can be configured inline or through environment variables.

Recommended:

```toml
[channels.team]
type = "discord-webhook"
webhook_url_env = "NOTIFY_DISCORD_WEBHOOK_URL"
```

```bash
export NOTIFY_DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/..."
```

Quick setup:

```toml
[channels.team]
type = "discord-webhook"
webhook_url = "https://discord.com/api/webhooks/..."
```

Environment variables are recommended for shared repositories, CI, and agent workflows.

Secrets are not accepted as CLI arguments.

Invalid:

```bash
notify send --webhook-url "https://discord.com/api/webhooks/..." --title "Hello" --body "World"
```

Also invalid:

```toml
webhook_url = "https://discord.com/api/webhooks/..."
webhook_url_env = "NOTIFY_DISCORD_WEBHOOK_URL"
```

Use either the inline field or the `_env` field, not both.

## Commands

### `notify send`

Send a notification.

```bash
notify send --channel personal --title "Task completed" --body "The report was generated successfully."
```

Use the default channel:

```bash
notify send --title "Task completed" --body "Done."
```

Attach a file:

```bash
notify send \
  --channel local \
  --title "Chart ready" \
  --body "Attached chart image." \
  --file ./chart.png
```

Read body from a file:

```bash
notify send \
  --channel local \
  --title "Error summary" \
  --body-file ./error-summary.md
```

Dry run:

```bash
notify send \
  --channel local \
  --title "Chart ready" \
  --body "Attached chart image." \
  --file ./chart.png \
  --dry-run
```

Common options:

```text
--channel <name>       Channel name. Uses default_channel if omitted.
--title <text>         Notification title.
--body <text>          Notification body.
--body-file <path>     Read body from a file.
--file <path>          Attach a file. Can be used multiple times.
--priority <level>     info | success | warning | error | critical
--format <format>      text | markdown
--tag <tag>            Add a tag. Can be used multiple times.
--dry-run              Resolve and display the notification without sending it.
--json                 Emit JSON output.
--config <path>        Use a specific config file.
```

### `notify channels`

List configured channels.

```bash
notify channels
```

Example:

```text
personal     telegram          ready
team         discord-webhook   ready
phone        ntfy              ready
local        file-log          ready
automation   webhook           ready
```

### `notify check`

Validate configuration.

```bash
notify check
```

Check one channel:

```bash
notify check --channel personal
```

### `notify test`

Send a test notification.

```bash
notify test --channel local
```

## Channel Configuration

### `file-log`

Stores notifications in a local JSONL file and copies attachments under a child directory.

```toml
[channels.local]
type = "file-log"
path = "./notify-log"
```

Use this for local testing or CI verification.

### `telegram`

```toml
[channels.personal]
type = "telegram"
bot_token_env = "NOTIFY_TELEGRAM_BOT_TOKEN"
chat_id_env = "NOTIFY_TELEGRAM_CHAT_ID"
parse_mode = "plain"
```

Inline:

```toml
[channels.personal]
type = "telegram"
bot_token = "123456:ABC..."
chat_id = "123456789"
parse_mode = "plain"
```

Supported `parse_mode` values:

```text
plain
html
markdown-v2
```

### `discord-webhook`

```toml
[channels.team]
type = "discord-webhook"
webhook_url_env = "NOTIFY_DISCORD_WEBHOOK_URL"
username = "Agent Notify"
allow_mentions = false
```

Inline:

```toml
[channels.team]
type = "discord-webhook"
webhook_url = "https://discord.com/api/webhooks/..."
```

### `discord-bot`

```toml
[channels.bot_team]
type = "discord-bot"
bot_token_env = "NOTIFY_DISCORD_BOT_TOKEN"
channel_id_env = "NOTIFY_DISCORD_CHANNEL_ID"
allow_mentions = false
```

Inline:

```toml
[channels.bot_team]
type = "discord-bot"
bot_token = "..."
channel_id = "123456789012345678"
allow_mentions = false
```

### `ntfy`

```toml
[channels.phone]
type = "ntfy"
server = "https://ntfy.sh"
topic_env = "NOTIFY_NTFY_TOPIC"
token_env = "NOTIFY_NTFY_TOKEN"
```

Inline:

```toml
[channels.phone]
type = "ntfy"
server = "https://ntfy.sh"
topic = "my-topic"
token = "..."
```

`token` is optional, depending on your ntfy server and topic configuration.

### `webhook`

```toml
[channels.automation]
type = "webhook"
url_env = "NOTIFY_WEBHOOK_URL"
auth_header_env = "NOTIFY_WEBHOOK_AUTH_HEADER"
timeout_seconds = 15
```

Inline:

```toml
[channels.automation]
type = "webhook"
url = "https://example.com/notify"
auth_header = "Bearer secret"
timeout_seconds = 15
```

The webhook channel uses the project-defined webhook protocol. The v1 payload format is defined in `SPEC.md`.

## Webhook Protocol v1

The `webhook` channel sends the agent-notify webhook protocol v1 payload.

Without attachments, the request is `application/json`. With attachments, the request is `multipart/form-data` with a `payload` JSON part and file parts named `file0`, `file1`, and so on.

The full protocol is documented in:

```text
docs/webhook-v1.md
```

## Examples

### Local test

```toml
default_channel = "local"

[channels.local]
type = "file-log"
path = "./notify-log"
```

```bash
notify send --title "Local test" --body "This notification is stored locally."
```

### Discord webhook

```toml
default_channel = "team"

[channels.team]
type = "discord-webhook"
webhook_url_env = "NOTIFY_DISCORD_WEBHOOK_URL"
```

```bash
export NOTIFY_DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/..."

notify send --title "Deployment complete" --body "The deployment finished successfully."
```

### Telegram

```toml
default_channel = "personal"

[channels.personal]
type = "telegram"
bot_token_env = "NOTIFY_TELEGRAM_BOT_TOKEN"
chat_id_env = "NOTIFY_TELEGRAM_CHAT_ID"
```

```bash
export NOTIFY_TELEGRAM_BOT_TOKEN="123456:ABC..."
export NOTIFY_TELEGRAM_CHAT_ID="123456789"

notify send --title "Job failed" --priority error --body "The nightly job failed."
```

### ntfy

```toml
default_channel = "phone"

[channels.phone]
type = "ntfy"
server = "https://ntfy.sh"
topic_env = "NOTIFY_NTFY_TOPIC"
```

```bash
export NOTIFY_NTFY_TOPIC="my-private-topic"

notify send --title "Attention needed" --priority warning --body "The agent needs attention."
```

### Webhook

```toml
default_channel = "automation"

[channels.automation]
type = "webhook"
url_env = "NOTIFY_WEBHOOK_URL"
auth_header_env = "NOTIFY_WEBHOOK_AUTH_HEADER"
```

```bash
export NOTIFY_WEBHOOK_URL="https://example.com/notify"
export NOTIFY_WEBHOOK_AUTH_HEADER="Bearer secret"

notify send --title "Report ready" --body "The report is ready." --file ./report.pdf
```

## Agent Skill

This repository includes an Agent Skill under:

```text
skills/notification/
```

Use it when installing `agent-notify` into an AI agent environment.