cue-notify 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. cue_notify-0.1.0/.gitignore +38 -0
  2. cue_notify-0.1.0/CHANGELOG.md +99 -0
  3. cue_notify-0.1.0/LICENSE +21 -0
  4. cue_notify-0.1.0/PKG-INFO +248 -0
  5. cue_notify-0.1.0/README.md +196 -0
  6. cue_notify-0.1.0/pyproject.toml +176 -0
  7. cue_notify-0.1.0/sdks/python/README.md +48 -0
  8. cue_notify-0.1.0/sdks/python/tests/test_client.py +151 -0
  9. cue_notify-0.1.0/sdks/python/tests/test_webhooks.py +44 -0
  10. cue_notify-0.1.0/sdks/typescript/README.md +53 -0
  11. cue_notify-0.1.0/src/cue_notify/__init__.py +3 -0
  12. cue_notify-0.1.0/src/cue_notify/__main__.py +3 -0
  13. cue_notify-0.1.0/src/cue_notify/ai/__init__.py +34 -0
  14. cue_notify-0.1.0/src/cue_notify/ai/agent.py +125 -0
  15. cue_notify-0.1.0/src/cue_notify/ai/base.py +105 -0
  16. cue_notify-0.1.0/src/cue_notify/api/__init__.py +1 -0
  17. cue_notify-0.1.0/src/cue_notify/api/app.py +155 -0
  18. cue_notify-0.1.0/src/cue_notify/api/deps.py +122 -0
  19. cue_notify-0.1.0/src/cue_notify/api/pages.py +232 -0
  20. cue_notify-0.1.0/src/cue_notify/api/problems.py +68 -0
  21. cue_notify-0.1.0/src/cue_notify/api/routers/__init__.py +1 -0
  22. cue_notify-0.1.0/src/cue_notify/api/routers/agents.py +51 -0
  23. cue_notify-0.1.0/src/cue_notify/api/routers/api_keys.py +40 -0
  24. cue_notify-0.1.0/src/cue_notify/api/routers/broadcasts.py +86 -0
  25. cue_notify-0.1.0/src/cue_notify/api/routers/categories.py +52 -0
  26. cue_notify-0.1.0/src/cue_notify/api/routers/digests.py +45 -0
  27. cue_notify-0.1.0/src/cue_notify/api/routers/events.py +82 -0
  28. cue_notify-0.1.0/src/cue_notify/api/routers/health.py +25 -0
  29. cue_notify-0.1.0/src/cue_notify/api/routers/messages.py +201 -0
  30. cue_notify-0.1.0/src/cue_notify/api/routers/preferences.py +37 -0
  31. cue_notify-0.1.0/src/cue_notify/api/routers/recipients.py +126 -0
  32. cue_notify-0.1.0/src/cue_notify/api/routers/rules.py +100 -0
  33. cue_notify-0.1.0/src/cue_notify/api/routers/templates.py +113 -0
  34. cue_notify-0.1.0/src/cue_notify/api/schemas.py +542 -0
  35. cue_notify-0.1.0/src/cue_notify/asgi.py +5 -0
  36. cue_notify-0.1.0/src/cue_notify/channels/__init__.py +25 -0
  37. cue_notify-0.1.0/src/cue_notify/channels/base.py +136 -0
  38. cue_notify-0.1.0/src/cue_notify/channels/console.py +31 -0
  39. cue_notify-0.1.0/src/cue_notify/channels/fcm.py +237 -0
  40. cue_notify-0.1.0/src/cue_notify/channels/registry.py +109 -0
  41. cue_notify-0.1.0/src/cue_notify/channels/smtp.py +105 -0
  42. cue_notify-0.1.0/src/cue_notify/channels/telegram.py +78 -0
  43. cue_notify-0.1.0/src/cue_notify/channels/twilio.py +75 -0
  44. cue_notify-0.1.0/src/cue_notify/channels/webhook.py +158 -0
  45. cue_notify-0.1.0/src/cue_notify/cli.py +334 -0
  46. cue_notify-0.1.0/src/cue_notify/core/__init__.py +1 -0
  47. cue_notify-0.1.0/src/cue_notify/core/content.py +148 -0
  48. cue_notify-0.1.0/src/cue_notify/core/digest.py +71 -0
  49. cue_notify-0.1.0/src/cue_notify/core/enums.py +128 -0
  50. cue_notify-0.1.0/src/cue_notify/core/ids.py +33 -0
  51. cue_notify-0.1.0/src/cue_notify/core/limits.py +17 -0
  52. cue_notify-0.1.0/src/cue_notify/core/logic.py +469 -0
  53. cue_notify-0.1.0/src/cue_notify/core/policy.py +156 -0
  54. cue_notify-0.1.0/src/cue_notify/core/templating.py +166 -0
  55. cue_notify-0.1.0/src/cue_notify/core/time.py +16 -0
  56. cue_notify-0.1.0/src/cue_notify/db/__init__.py +1 -0
  57. cue_notify-0.1.0/src/cue_notify/db/base.py +87 -0
  58. cue_notify-0.1.0/src/cue_notify/db/dml.py +51 -0
  59. cue_notify-0.1.0/src/cue_notify/db/migrations/__init__.py +17 -0
  60. cue_notify-0.1.0/src/cue_notify/db/migrations/env.py +74 -0
  61. cue_notify-0.1.0/src/cue_notify/db/migrations/script.py.mako +25 -0
  62. cue_notify-0.1.0/src/cue_notify/db/migrations/versions/0001_initial.py +421 -0
  63. cue_notify-0.1.0/src/cue_notify/db/migrations/versions/0002_digests.py +78 -0
  64. cue_notify-0.1.0/src/cue_notify/db/migrations/versions/0003_preference_center.py +74 -0
  65. cue_notify-0.1.0/src/cue_notify/db/migrations/versions/0004_importance_and_expiry.py +48 -0
  66. cue_notify-0.1.0/src/cue_notify/db/migrations/versions/0005_agents.py +69 -0
  67. cue_notify-0.1.0/src/cue_notify/db/migrations/versions/0006_fatigue.py +30 -0
  68. cue_notify-0.1.0/src/cue_notify/db/migrations/versions/0007_event_agents.py +24 -0
  69. cue_notify-0.1.0/src/cue_notify/db/migrations/versions/0008_agent_reviewers.py +35 -0
  70. cue_notify-0.1.0/src/cue_notify/db/models.py +351 -0
  71. cue_notify-0.1.0/src/cue_notify/db/session.py +52 -0
  72. cue_notify-0.1.0/src/cue_notify/jobs.py +27 -0
  73. cue_notify-0.1.0/src/cue_notify/mcp_server.py +243 -0
  74. cue_notify-0.1.0/src/cue_notify/observability.py +115 -0
  75. cue_notify-0.1.0/src/cue_notify/py.typed +0 -0
  76. cue_notify-0.1.0/src/cue_notify/queue.py +324 -0
  77. cue_notify-0.1.0/src/cue_notify/runtime.py +77 -0
  78. cue_notify-0.1.0/src/cue_notify/services/__init__.py +1 -0
  79. cue_notify-0.1.0/src/cue_notify/services/agents.py +158 -0
  80. cue_notify-0.1.0/src/cue_notify/services/api_keys.py +78 -0
  81. cue_notify-0.1.0/src/cue_notify/services/broadcasts.py +234 -0
  82. cue_notify-0.1.0/src/cue_notify/services/catalog.py +38 -0
  83. cue_notify-0.1.0/src/cue_notify/services/composer.py +363 -0
  84. cue_notify-0.1.0/src/cue_notify/services/delivery.py +313 -0
  85. cue_notify-0.1.0/src/cue_notify/services/digests.py +214 -0
  86. cue_notify-0.1.0/src/cue_notify/services/engagement.py +48 -0
  87. cue_notify-0.1.0/src/cue_notify/services/errors.py +40 -0
  88. cue_notify-0.1.0/src/cue_notify/services/events.py +277 -0
  89. cue_notify-0.1.0/src/cue_notify/services/preferences.py +270 -0
  90. cue_notify-0.1.0/src/cue_notify/services/recipients.py +147 -0
  91. cue_notify-0.1.0/src/cue_notify/settings.py +224 -0
  92. cue_notify-0.1.0/tests/__init__.py +0 -0
  93. cue_notify-0.1.0/tests/conftest.py +160 -0
  94. cue_notify-0.1.0/tests/helpers.py +148 -0
  95. cue_notify-0.1.0/tests/integration/__init__.py +0 -0
  96. cue_notify-0.1.0/tests/integration/test_agents.py +399 -0
  97. cue_notify-0.1.0/tests/integration/test_ai_delivery.py +110 -0
  98. cue_notify-0.1.0/tests/integration/test_auth.py +61 -0
  99. cue_notify-0.1.0/tests/integration/test_broadcasts.py +150 -0
  100. cue_notify-0.1.0/tests/integration/test_catalog_api.py +94 -0
  101. cue_notify-0.1.0/tests/integration/test_cli.py +65 -0
  102. cue_notify-0.1.0/tests/integration/test_digests.py +282 -0
  103. cue_notify-0.1.0/tests/integration/test_event_flow.py +169 -0
  104. cue_notify-0.1.0/tests/integration/test_fatigue.py +88 -0
  105. cue_notify-0.1.0/tests/integration/test_hardening.py +294 -0
  106. cue_notify-0.1.0/tests/integration/test_importance.py +171 -0
  107. cue_notify-0.1.0/tests/integration/test_mcp.py +80 -0
  108. cue_notify-0.1.0/tests/integration/test_messages_api.py +181 -0
  109. cue_notify-0.1.0/tests/integration/test_migrations.py +57 -0
  110. cue_notify-0.1.0/tests/integration/test_policy.py +240 -0
  111. cue_notify-0.1.0/tests/integration/test_preferences.py +321 -0
  112. cue_notify-0.1.0/tests/unit/__init__.py +0 -0
  113. cue_notify-0.1.0/tests/unit/test_ai.py +86 -0
  114. cue_notify-0.1.0/tests/unit/test_channels.py +463 -0
  115. cue_notify-0.1.0/tests/unit/test_logic.py +122 -0
  116. cue_notify-0.1.0/tests/unit/test_policy.py +80 -0
  117. cue_notify-0.1.0/tests/unit/test_queue.py +88 -0
  118. cue_notify-0.1.0/tests/unit/test_settings.py +55 -0
  119. cue_notify-0.1.0/tests/unit/test_templating.py +93 -0
@@ -0,0 +1,38 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+ .venv/
9
+ venv/
10
+
11
+ # Tooling caches
12
+ .pytest_cache/
13
+ .ruff_cache/
14
+ .mypy_cache/
15
+ .pyright/
16
+ .coverage
17
+ .coverage.*
18
+ coverage.xml
19
+ htmlcov/
20
+
21
+ # Docs build
22
+ site/
23
+
24
+ # Local configuration and data
25
+ .env
26
+ .env.*
27
+ !.env.example
28
+ /cue.toml
29
+ *.db
30
+ *.db-journal
31
+ *.sqlite3
32
+ secrets/
33
+
34
+ # Editors / OS
35
+ .idea/
36
+ .vscode/
37
+ *.swp
38
+ .DS_Store
@@ -0,0 +1,99 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
+ [semantic versioning](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ### Added
10
+ - A throughput benchmark (`benchmarks/throughput.py`) and a performance guide.
11
+ - Agent `reviewers`: Cue reports a `cue.approval_requested` event for each reviewer when
12
+ a message waits for approval, so your own rules and templates notify them.
13
+ - Python (`cue-client`, httpx only) and TypeScript (`cue-client`, no dependencies) SDKs
14
+ with webhook signature verification, tested in CI and released by tag.
15
+
16
+ ### Fixed
17
+ - Test coverage now measures `cue_notify` (it pointed at a package name from before
18
+ the rename).
19
+ - The database pool now defaults to the worker's concurrency plus 4 connections. With
20
+ the old fixed default of 10, a busy worker opened and closed connections constantly;
21
+ end-to-end throughput roughly doubled with four workers.
22
+
23
+ ### Security
24
+ - Agent keys can no longer review messages (also not another agent's), hold the
25
+ `admin` scope, change people's preferences or rotate preference tokens.
26
+ - The hosted preference form is read with a size limit, and the unsubscribe
27
+ confirmation page only names categories that exist.
28
+ - Agent keys cannot see preference tokens (redacted from recipients and message
29
+ content), delete recipients, send inline profiles, cancel or report engagement on
30
+ other senders' messages; events they report follow the agent's categories, budget and
31
+ approval.
32
+ - A `send_at` in the past counts as now, so backdated sends cannot slip past frequency
33
+ caps or agent budgets.
34
+ - Event and message `data` is limited to 16 KB.
35
+ - The MCP server refuses ids that are not UUIDs instead of resolving them into other API
36
+ paths.
37
+ - Line breaks in e-mail subjects are collapsed, and messages that cannot be built as
38
+ e-mail fail over instead of retrying.
39
+
40
+ ## [0.1.0] — 2026-10-10
41
+
42
+ First public release of Cue, the attention layer between software, AI agents and people.
43
+
44
+ ### Added
45
+ - Event ingestion with idempotency keys and inline recipient profiles.
46
+ - Rules: JSON Logic conditions, wildcard event names, priorities, `stop_processing`,
47
+ delays, cooldowns and deterministic percentage rollouts, plus a dry-run endpoint.
48
+ - Digests: a rule can group matching events per recipient and grouping key for a
49
+ window (or until `send_after` events) and send one message rendered from all of them.
50
+ Smart digests let the AI layer summarise the group from allow-listed fields, falling
51
+ back to the template. API: `/v1/digests`.
52
+ - A `thread` content field for device-side grouping (APNs `thread-id`, FCM data, e-mail
53
+ `References`).
54
+ - Preference centre: a per-recipient preference token, a hosted preference page, a
55
+ token-authenticated JSON API for your own UI (`/v1/preferences/{token}`), RFC 8058
56
+ one-click unsubscribe with `List-Unsubscribe` headers from the SMTP connector and
57
+ `links` in webhook payloads, template `links`, token rotation, and a consent ledger
58
+ (`/v1/recipients/{id}/preferences/history`). Configure with `api.public_url`.
59
+ - Importance (`low`, `normal`, `high`, `critical`) mapped to iOS interruption levels,
60
+ Android priority, silent Telegram messages and e-mail headers; `critical` breaks
61
+ through quiet hours and caps only in categories people cannot leave.
62
+ - Expiry: `expires_at` on sends and `expires_after_seconds` on rules; stale messages are
63
+ dropped and push TTLs shortened to match.
64
+ - Template actions (buttons) for push, Telegram, e-mail and webhooks.
65
+ - Agents: automated senders with a per-person attention budget (5 a day by default), an
66
+ importance ceiling, allowed categories and an approval policy. Held messages wait in
67
+ `pending_approval` until approved or rejected (`/v1/messages/{id}/approve`,
68
+ `/reject`, MCP `review_message`), with the reviewer recorded. API keys can be bound
69
+ to an agent (`--agent`).
70
+ - Fatigue: a category can pause low and normal messages to people who ignored its
71
+ last N messages, probe again after the pause, and resume on any engagement.
72
+ - Agent-first distribution: the MCP server is part of the core package
73
+ (`uvx cue-notify mcp`), an MCP registry manifest (`server.json`), a Claude Code
74
+ plugin with an integration skill, `llms.txt` and `AGENTS.md`.
75
+ - `cuectl serve --migrate` applies migrations before starting.
76
+ - Categories carrying delivery policy: rolling frequency caps, quiet hours and
77
+ unsubscribe rules. `transactional` and `marketing` are created by default.
78
+ - Localised Jinja2 templates (sandboxed, strict) with per-channel overrides, versioning
79
+ and a preview endpoint.
80
+ - Pluggable delivery: a signed webhook connector for your own sending service,
81
+ bundled connectors for Firebase Cloud Messaging, Twilio SMS, SMTP e-mail and Telegram,
82
+ a console connector, and third-party connectors via entry points.
83
+ - Multi-address delivery, channel fallback, retry with backoff and automatic disabling
84
+ of dead addresses.
85
+ - Broadcasts with resumable batches, pause/resume/cancel and audience filters.
86
+ - Optional AI copy personalisation through Pydantic AI (any provider) with fact
87
+ guardrails, allow-listed context and a daily token budget.
88
+ - Delivery and engagement tracking, including a token-based endpoint for client apps.
89
+ - Scoped API keys, RFC 9457 problem responses, cursor pagination, Prometheus metrics.
90
+ - Hardening: SSRF-safe per-recipient webhooks, resource-bounded template sandbox and
91
+ rule evaluator, race-free cancellation, job lease heartbeats, and failure states for
92
+ events, messages and broadcasts whose jobs exhaust their retries.
93
+ - A transactional, database-backed job queue (no Redis required).
94
+ - `cuectl` CLI: `serve`, `worker`, `db`, `keys`, `jobs`, `prune`, `check`, `mcp`.
95
+ - A Model Context Protocol server so AI agents can send notifications and inspect
96
+ delivery with scoped API keys.
97
+
98
+ [Unreleased]: https://github.com/murtazox04/Cue/compare/v0.1.0...HEAD
99
+ [0.1.0]: https://github.com/murtazox04/Cue/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Murtazo Xurramov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,248 @@
1
+ Metadata-Version: 2.5
2
+ Name: cue-notify
3
+ Version: 0.1.0
4
+ Summary: The attention layer between software, AI agents and people: decides whether, what, when and where to notify.
5
+ Project-URL: Homepage, https://github.com/murtazox04/Cue
6
+ Project-URL: Documentation, https://murtazox04.github.io/Cue
7
+ Project-URL: Repository, https://github.com/murtazox04/Cue
8
+ Project-URL: Issues, https://github.com/murtazox04/Cue/issues
9
+ Project-URL: Changelog, https://github.com/murtazox04/Cue/blob/main/CHANGELOG.md
10
+ Author: Murtazo Xurramov
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: ai-agents,attention,email,event-driven,fastapi,fcm,llm,mcp,messaging,notification-engine,notifications,preference-center,push,rules-engine,sms,twilio
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Framework :: AsyncIO
16
+ Classifier: Framework :: FastAPI
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: Communications
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.12
26
+ Requires-Dist: aiosqlite>=0.21
27
+ Requires-Dist: alembic>=1.16
28
+ Requires-Dist: fastapi>=0.120
29
+ Requires-Dist: httpx>=0.28
30
+ Requires-Dist: jinja2>=3.1.6
31
+ Requires-Dist: mcp>=2.0
32
+ Requires-Dist: pydantic-settings>=2.10
33
+ Requires-Dist: pydantic>=2.11
34
+ Requires-Dist: sqlalchemy[asyncio]>=2.0.40
35
+ Requires-Dist: typer>=0.16
36
+ Requires-Dist: uvicorn[standard]>=0.34
37
+ Provides-Extra: ai
38
+ Requires-Dist: pydantic-ai-slim[anthropic,google,groq,mistral,openai]>=2.0; extra == 'ai'
39
+ Provides-Extra: all
40
+ Requires-Dist: asyncpg>=0.30; extra == 'all'
41
+ Requires-Dist: prometheus-client>=0.21; extra == 'all'
42
+ Requires-Dist: pydantic-ai-slim[anthropic,google,groq,mistral,openai]>=2.0; extra == 'all'
43
+ Requires-Dist: pyjwt[crypto]>=2.10; extra == 'all'
44
+ Provides-Extra: fcm
45
+ Requires-Dist: pyjwt[crypto]>=2.10; extra == 'fcm'
46
+ Provides-Extra: mcp
47
+ Provides-Extra: metrics
48
+ Requires-Dist: prometheus-client>=0.21; extra == 'metrics'
49
+ Provides-Extra: postgres
50
+ Requires-Dist: asyncpg>=0.30; extra == 'postgres'
51
+ Description-Content-Type: text/markdown
52
+
53
+ <div align="center">
54
+
55
+ # Cue
56
+
57
+ **The attention layer between software, AI agents and people.**
58
+
59
+ Your product and your agents report what happened;<br/>
60
+ Cue decides whether it is worth someone's attention, what to say, when, and over which
61
+ route, then hands a ready-to-send message to the delivery you plug in.
62
+
63
+ [![CI](https://github.com/murtazox04/Cue/actions/workflows/ci.yml/badge.svg)](https://github.com/murtazox04/Cue/actions/workflows/ci.yml)
64
+ [![Python](https://img.shields.io/badge/python-3.12%20|%203.13%20|%203.14-blue)](https://github.com/murtazox04/Cue/blob/main/pyproject.toml)
65
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/murtazox04/Cue/blob/main/LICENSE)
66
+
67
+ [Documentation](https://murtazox04.github.io/Cue) ·
68
+ [Getting started](https://github.com/murtazox04/Cue/blob/main/docs/getting-started.md) ·
69
+ [Architecture](https://github.com/murtazox04/Cue/blob/main/docs/architecture.md)
70
+
71
+ </div>
72
+
73
+ ---
74
+
75
+ People now hear from more software than ever: your product, background jobs, and a
76
+ growing number of AI agents acting on someone's behalf. Each sender is reasonable alone;
77
+ together they bury the person, and phones increasingly silence them. Cue is the one place
78
+ that decides. Your backend (or an agent) reports what happened — `order.shipped`,
79
+ `payment.failed`, `pr.review_requested` — and Cue decides whether a notification is
80
+ warranted, which template and language to use, when to send it in the recipient's time
81
+ zone, how important it really is, and which route to try first. It renders the message
82
+ and hands it to whatever delivery you connect: your own service, a webhook, or a
83
+ ready-made connector.
84
+
85
+ **Delivery is pluggable. The decisions are Cue's job** — and every one of them is
86
+ recorded, so "why didn't this user get the message?" becomes a query, not an
87
+ investigation.
88
+
89
+ ```bash
90
+ curl -X POST https://cue.example.com/v1/events \
91
+ -H "Authorization: Bearer $CUE_KEY" -H "Content-Type: application/json" \
92
+ -d '{"name": "order.shipped", "recipient": "customer-42",
93
+ "data": {"order_id": "1001"}, "idempotency_key": "order-1001-shipped"}'
94
+ ```
95
+
96
+ Your delivery endpoint then receives a signed, fully rendered message:
97
+
98
+ ```json
99
+ {
100
+ "id": "01a1…",
101
+ "channel": "push",
102
+ "address": "<device token>",
103
+ "locale": "en",
104
+ "importance": "normal",
105
+ "expires_at": null,
106
+ "content": {"title": "Your order is on its way", "body": "Order 1001 ships today.",
107
+ "url": "https://shop.example/orders/1001"},
108
+ "metadata": {"cue_message_id": "01a1…", "cue_tracking_token": "…"},
109
+ "links": {"preferences": "https://cue.example.com/preferences/…"}
110
+ }
111
+ ```
112
+
113
+ ## What Cue decides
114
+
115
+ - **Whether** — rules with JSON Logic conditions, priorities, wildcards, deterministic
116
+ rollouts and a dry-run endpoint; unsubscribes, frequency caps, cooldowns and
117
+ deduplication applied to every message; fatigue that backs off from people who stopped
118
+ paying attention.
119
+ - **What** — localised, sandboxed Jinja2 templates with per-route variants (a short SMS,
120
+ a rich e-mail), versioning and previews; optional AI rewording through any
121
+ [Pydantic AI](https://ai.pydantic.dev) model, with guardrails that keep numbers and
122
+ links verbatim.
123
+ - **How often** — digests that turn a burst of events into one message per window
124
+ ("Ann, Bo and 10 others commented"), optionally summarised by AI, plus thread ids so
125
+ phones and mail clients stack related messages.
126
+ - **When** — delays, quiet hours in each recipient's time zone, scheduled broadcasts,
127
+ expiry for messages that go stale, and importance levels phones understand.
128
+ - **Who decides** — the person: a hosted preference page (or a JSON API for your own),
129
+ RFC 8058 one-click unsubscribe for Gmail and Yahoo, and a consent ledger of every
130
+ change.
131
+ - **Where** — an ordered list of routes per rule (e.g. push, then SMS), every address a
132
+ person has on a route, fallback on permanent failure, retries on transient failure,
133
+ dead addresses disabled automatically.
134
+
135
+ ## Built for AI agents
136
+
137
+ - **Agents as first-class senders.** Each agent gets its own key with a per-person
138
+ attention budget, an importance ceiling and, where you want it, human approval before
139
+ anything goes out. See [agents](https://github.com/murtazox04/Cue/blob/main/docs/concepts/agents.md).
140
+ - **MCP built in.** `uvx cue-notify mcp` gives Claude, Cursor or your own agent tools to
141
+ notify people and inspect delivery, with the same policy and audit trail.
142
+ - **Claude Code plugin.** `/plugin marketplace add murtazox04/Cue`, then
143
+ `/plugin install cue@cue`, teaches Claude to integrate Cue into your app.
144
+ - **SDKs.** `pip install cue-client` and `npm install cue-client`, both with webhook
145
+ signature verification. See [SDKs](https://github.com/murtazox04/Cue/blob/main/docs/guides/sdks.md).
146
+ - **Docs for machines.** [`llms.txt`](https://murtazox04.github.io/Cue/llms.txt) and
147
+ [`AGENTS.md`](https://github.com/murtazox04/Cue/blob/main/AGENTS.md).
148
+
149
+ ## Bring your own delivery
150
+
151
+ Each route (`push`, `sms`, `email`, `ops-alerts`…) is backed by a **connector**:
152
+
153
+ | Connector | Use it when |
154
+ |---|---|
155
+ | `webhook` | You already have a sending service, or want full control. Cue POSTs signed JSON to it. |
156
+ | `fcm`, `twilio`, `smtp`, `telegram` | You want a ready-made connector for these providers. |
157
+ | `console` | Local development. |
158
+ | your own | Write a small class and register it as a plugin — see [custom connectors](https://github.com/murtazox04/Cue/blob/main/docs/guides/custom-channels.md). |
159
+
160
+ Connectors are configuration, not code changes — swap SMS vendors without touching a
161
+ rule.
162
+
163
+ ## Also
164
+
165
+ - **Engagement tracking** — delivered, opened, clicked, converted; client apps report
166
+ with a per-message token, no API key needed.
167
+ - **Broadcasts** — audience filters, resumable batches, pause/resume/cancel without
168
+ double sends.
169
+ - **AI agents** — an MCP server (`cuectl mcp`) lets Claude, Cursor or your own agents
170
+ notify people and inspect delivery within the scopes you grant.
171
+ - **Simple to run** — one Python service and PostgreSQL (or SQLite). No Redis, no
172
+ broker, no cron: the durable job queue lives in your database.
173
+ - **Observable** — per-rule event outcomes, status reasons, Prometheus metrics, JSON logs.
174
+
175
+ ## Quick start
176
+
177
+ ```bash
178
+ git clone https://github.com/murtazox04/Cue && cd Cue
179
+ docker compose up --build -d
180
+ docker compose exec api cuectl keys create admin # prints an API key
181
+ open http://localhost:8000/docs
182
+ ```
183
+
184
+ Or with Python 3.12+:
185
+
186
+ ```bash
187
+ pip install 'cue-notify[postgres]'
188
+ export CUE_WORKER__EMBEDDED=true CUE_CHANNELS__PUSH__PROVIDER=console
189
+ cuectl db upgrade && cuectl keys create admin && cuectl serve
190
+ ```
191
+
192
+ Then follow the [getting-started guide](https://github.com/murtazox04/Cue/blob/main/docs/getting-started.md).
193
+
194
+ ## How it works
195
+
196
+ ```mermaid
197
+ flowchart LR
198
+ E[POST /v1/events] --> R{Rules}
199
+ R --> P[Policy<br/>unsubscribe · caps · cooldown · quiet hours]
200
+ P --> T[Template<br/>locale · route variants]
201
+ T --> Q[(Queue)]
202
+ Q --> A[AI rewording<br/>optional]
203
+ A --> C{Your delivery<br/>webhook · connectors}
204
+ ```
205
+
206
+ | Concept | In one line |
207
+ |---|---|
208
+ | **Event** | Something that happened to a recipient. Idempotent, stored with per-rule outcomes. |
209
+ | **Rule** | When event X (and condition) → send template Y over routes [A, B]. |
210
+ | **Template** | Localised content with route-specific variants. |
211
+ | **Category** | Policy bundle: frequency caps, quiet hours, whether unsubscribing is allowed. |
212
+ | **Channel** | A named route (`push`, `sms`…) backed by a connector. |
213
+ | **Message** | One notification to one recipient, with a full status trail. |
214
+ | **Broadcast** | One template to an audience, in resumable batches. |
215
+
216
+ ## Configuration
217
+
218
+ Environment variables (`CUE_SECTION__KEY`) or a `cue.toml`:
219
+
220
+ ```toml
221
+ [database]
222
+ url = "postgresql+asyncpg://cue:secret@db/cue"
223
+
224
+ [channels.push]
225
+ provider = "webhook"
226
+ url = "https://notifications.internal.example/push"
227
+ # secret from CUE_CHANNELS__PUSH__SECRET
228
+
229
+ [channels.sms]
230
+ provider = "twilio"
231
+ account_sid = "AC…"
232
+ from_number = "+15550100" # auth token via CUE_CHANNELS__SMS__AUTH_TOKEN
233
+ ```
234
+
235
+ See the [configuration reference](https://github.com/murtazox04/Cue/blob/main/docs/reference/configuration.md) and
236
+ [`examples/cue.toml`](https://github.com/murtazox04/Cue/blob/main/examples/cue.toml).
237
+
238
+ ## Project status
239
+
240
+ Cue is in early development (0.x): the model and API are stable in shape but may still
241
+ change before 1.0. See the [roadmap](https://github.com/murtazox04/Cue/blob/main/ROADMAP.md) for what comes next. Feedback and
242
+ contributions are very welcome — see [CONTRIBUTING.md](https://github.com/murtazox04/Cue/blob/main/CONTRIBUTING.md).
243
+
244
+ ## License
245
+
246
+ [MIT](https://github.com/murtazox04/Cue/blob/main/LICENSE)
247
+
248
+ <!-- mcp-name: io.github.murtazox04/cue -->
@@ -0,0 +1,196 @@
1
+ <div align="center">
2
+
3
+ # Cue
4
+
5
+ **The attention layer between software, AI agents and people.**
6
+
7
+ Your product and your agents report what happened;<br/>
8
+ Cue decides whether it is worth someone's attention, what to say, when, and over which
9
+ route, then hands a ready-to-send message to the delivery you plug in.
10
+
11
+ [![CI](https://github.com/murtazox04/Cue/actions/workflows/ci.yml/badge.svg)](https://github.com/murtazox04/Cue/actions/workflows/ci.yml)
12
+ [![Python](https://img.shields.io/badge/python-3.12%20|%203.13%20|%203.14-blue)](https://github.com/murtazox04/Cue/blob/main/pyproject.toml)
13
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/murtazox04/Cue/blob/main/LICENSE)
14
+
15
+ [Documentation](https://murtazox04.github.io/Cue) ·
16
+ [Getting started](https://github.com/murtazox04/Cue/blob/main/docs/getting-started.md) ·
17
+ [Architecture](https://github.com/murtazox04/Cue/blob/main/docs/architecture.md)
18
+
19
+ </div>
20
+
21
+ ---
22
+
23
+ People now hear from more software than ever: your product, background jobs, and a
24
+ growing number of AI agents acting on someone's behalf. Each sender is reasonable alone;
25
+ together they bury the person, and phones increasingly silence them. Cue is the one place
26
+ that decides. Your backend (or an agent) reports what happened — `order.shipped`,
27
+ `payment.failed`, `pr.review_requested` — and Cue decides whether a notification is
28
+ warranted, which template and language to use, when to send it in the recipient's time
29
+ zone, how important it really is, and which route to try first. It renders the message
30
+ and hands it to whatever delivery you connect: your own service, a webhook, or a
31
+ ready-made connector.
32
+
33
+ **Delivery is pluggable. The decisions are Cue's job** — and every one of them is
34
+ recorded, so "why didn't this user get the message?" becomes a query, not an
35
+ investigation.
36
+
37
+ ```bash
38
+ curl -X POST https://cue.example.com/v1/events \
39
+ -H "Authorization: Bearer $CUE_KEY" -H "Content-Type: application/json" \
40
+ -d '{"name": "order.shipped", "recipient": "customer-42",
41
+ "data": {"order_id": "1001"}, "idempotency_key": "order-1001-shipped"}'
42
+ ```
43
+
44
+ Your delivery endpoint then receives a signed, fully rendered message:
45
+
46
+ ```json
47
+ {
48
+ "id": "01a1…",
49
+ "channel": "push",
50
+ "address": "<device token>",
51
+ "locale": "en",
52
+ "importance": "normal",
53
+ "expires_at": null,
54
+ "content": {"title": "Your order is on its way", "body": "Order 1001 ships today.",
55
+ "url": "https://shop.example/orders/1001"},
56
+ "metadata": {"cue_message_id": "01a1…", "cue_tracking_token": "…"},
57
+ "links": {"preferences": "https://cue.example.com/preferences/…"}
58
+ }
59
+ ```
60
+
61
+ ## What Cue decides
62
+
63
+ - **Whether** — rules with JSON Logic conditions, priorities, wildcards, deterministic
64
+ rollouts and a dry-run endpoint; unsubscribes, frequency caps, cooldowns and
65
+ deduplication applied to every message; fatigue that backs off from people who stopped
66
+ paying attention.
67
+ - **What** — localised, sandboxed Jinja2 templates with per-route variants (a short SMS,
68
+ a rich e-mail), versioning and previews; optional AI rewording through any
69
+ [Pydantic AI](https://ai.pydantic.dev) model, with guardrails that keep numbers and
70
+ links verbatim.
71
+ - **How often** — digests that turn a burst of events into one message per window
72
+ ("Ann, Bo and 10 others commented"), optionally summarised by AI, plus thread ids so
73
+ phones and mail clients stack related messages.
74
+ - **When** — delays, quiet hours in each recipient's time zone, scheduled broadcasts,
75
+ expiry for messages that go stale, and importance levels phones understand.
76
+ - **Who decides** — the person: a hosted preference page (or a JSON API for your own),
77
+ RFC 8058 one-click unsubscribe for Gmail and Yahoo, and a consent ledger of every
78
+ change.
79
+ - **Where** — an ordered list of routes per rule (e.g. push, then SMS), every address a
80
+ person has on a route, fallback on permanent failure, retries on transient failure,
81
+ dead addresses disabled automatically.
82
+
83
+ ## Built for AI agents
84
+
85
+ - **Agents as first-class senders.** Each agent gets its own key with a per-person
86
+ attention budget, an importance ceiling and, where you want it, human approval before
87
+ anything goes out. See [agents](https://github.com/murtazox04/Cue/blob/main/docs/concepts/agents.md).
88
+ - **MCP built in.** `uvx cue-notify mcp` gives Claude, Cursor or your own agent tools to
89
+ notify people and inspect delivery, with the same policy and audit trail.
90
+ - **Claude Code plugin.** `/plugin marketplace add murtazox04/Cue`, then
91
+ `/plugin install cue@cue`, teaches Claude to integrate Cue into your app.
92
+ - **SDKs.** `pip install cue-client` and `npm install cue-client`, both with webhook
93
+ signature verification. See [SDKs](https://github.com/murtazox04/Cue/blob/main/docs/guides/sdks.md).
94
+ - **Docs for machines.** [`llms.txt`](https://murtazox04.github.io/Cue/llms.txt) and
95
+ [`AGENTS.md`](https://github.com/murtazox04/Cue/blob/main/AGENTS.md).
96
+
97
+ ## Bring your own delivery
98
+
99
+ Each route (`push`, `sms`, `email`, `ops-alerts`…) is backed by a **connector**:
100
+
101
+ | Connector | Use it when |
102
+ |---|---|
103
+ | `webhook` | You already have a sending service, or want full control. Cue POSTs signed JSON to it. |
104
+ | `fcm`, `twilio`, `smtp`, `telegram` | You want a ready-made connector for these providers. |
105
+ | `console` | Local development. |
106
+ | your own | Write a small class and register it as a plugin — see [custom connectors](https://github.com/murtazox04/Cue/blob/main/docs/guides/custom-channels.md). |
107
+
108
+ Connectors are configuration, not code changes — swap SMS vendors without touching a
109
+ rule.
110
+
111
+ ## Also
112
+
113
+ - **Engagement tracking** — delivered, opened, clicked, converted; client apps report
114
+ with a per-message token, no API key needed.
115
+ - **Broadcasts** — audience filters, resumable batches, pause/resume/cancel without
116
+ double sends.
117
+ - **AI agents** — an MCP server (`cuectl mcp`) lets Claude, Cursor or your own agents
118
+ notify people and inspect delivery within the scopes you grant.
119
+ - **Simple to run** — one Python service and PostgreSQL (or SQLite). No Redis, no
120
+ broker, no cron: the durable job queue lives in your database.
121
+ - **Observable** — per-rule event outcomes, status reasons, Prometheus metrics, JSON logs.
122
+
123
+ ## Quick start
124
+
125
+ ```bash
126
+ git clone https://github.com/murtazox04/Cue && cd Cue
127
+ docker compose up --build -d
128
+ docker compose exec api cuectl keys create admin # prints an API key
129
+ open http://localhost:8000/docs
130
+ ```
131
+
132
+ Or with Python 3.12+:
133
+
134
+ ```bash
135
+ pip install 'cue-notify[postgres]'
136
+ export CUE_WORKER__EMBEDDED=true CUE_CHANNELS__PUSH__PROVIDER=console
137
+ cuectl db upgrade && cuectl keys create admin && cuectl serve
138
+ ```
139
+
140
+ Then follow the [getting-started guide](https://github.com/murtazox04/Cue/blob/main/docs/getting-started.md).
141
+
142
+ ## How it works
143
+
144
+ ```mermaid
145
+ flowchart LR
146
+ E[POST /v1/events] --> R{Rules}
147
+ R --> P[Policy<br/>unsubscribe · caps · cooldown · quiet hours]
148
+ P --> T[Template<br/>locale · route variants]
149
+ T --> Q[(Queue)]
150
+ Q --> A[AI rewording<br/>optional]
151
+ A --> C{Your delivery<br/>webhook · connectors}
152
+ ```
153
+
154
+ | Concept | In one line |
155
+ |---|---|
156
+ | **Event** | Something that happened to a recipient. Idempotent, stored with per-rule outcomes. |
157
+ | **Rule** | When event X (and condition) → send template Y over routes [A, B]. |
158
+ | **Template** | Localised content with route-specific variants. |
159
+ | **Category** | Policy bundle: frequency caps, quiet hours, whether unsubscribing is allowed. |
160
+ | **Channel** | A named route (`push`, `sms`…) backed by a connector. |
161
+ | **Message** | One notification to one recipient, with a full status trail. |
162
+ | **Broadcast** | One template to an audience, in resumable batches. |
163
+
164
+ ## Configuration
165
+
166
+ Environment variables (`CUE_SECTION__KEY`) or a `cue.toml`:
167
+
168
+ ```toml
169
+ [database]
170
+ url = "postgresql+asyncpg://cue:secret@db/cue"
171
+
172
+ [channels.push]
173
+ provider = "webhook"
174
+ url = "https://notifications.internal.example/push"
175
+ # secret from CUE_CHANNELS__PUSH__SECRET
176
+
177
+ [channels.sms]
178
+ provider = "twilio"
179
+ account_sid = "AC…"
180
+ from_number = "+15550100" # auth token via CUE_CHANNELS__SMS__AUTH_TOKEN
181
+ ```
182
+
183
+ See the [configuration reference](https://github.com/murtazox04/Cue/blob/main/docs/reference/configuration.md) and
184
+ [`examples/cue.toml`](https://github.com/murtazox04/Cue/blob/main/examples/cue.toml).
185
+
186
+ ## Project status
187
+
188
+ Cue is in early development (0.x): the model and API are stable in shape but may still
189
+ change before 1.0. See the [roadmap](https://github.com/murtazox04/Cue/blob/main/ROADMAP.md) for what comes next. Feedback and
190
+ contributions are very welcome — see [CONTRIBUTING.md](https://github.com/murtazox04/Cue/blob/main/CONTRIBUTING.md).
191
+
192
+ ## License
193
+
194
+ [MIT](https://github.com/murtazox04/Cue/blob/main/LICENSE)
195
+
196
+ <!-- mcp-name: io.github.murtazox04/cue -->