agent-core-notify 0.8.2__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.
- agent_core_notify-0.8.2/.gitignore +245 -0
- agent_core_notify-0.8.2/CHANGELOG.md +24 -0
- agent_core_notify-0.8.2/PKG-INFO +8 -0
- agent_core_notify-0.8.2/VERSION +1 -0
- agent_core_notify-0.8.2/pyproject.toml +29 -0
- agent_core_notify-0.8.2/src/agent_core_notify/__init__.py +1 -0
- agent_core_notify-0.8.2/src/agent_core_notify/mcp_server.py +314 -0
- agent_core_notify-0.8.2/towncrier.toml +38 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# Memory compiler runtime state
|
|
2
|
+
memory-compiler/daily/
|
|
3
|
+
memory-compiler/reports/
|
|
4
|
+
memory-compiler/scripts/state.json
|
|
5
|
+
memory-compiler/scripts/last-flush.json
|
|
6
|
+
memory-compiler/scripts/flush.log
|
|
7
|
+
memory-compiler/scripts/compile.log
|
|
8
|
+
memory-compiler/scripts/session-flush-*.md
|
|
9
|
+
memory-compiler/scripts/flush-context-*.md
|
|
10
|
+
|
|
11
|
+
# Handoff writer state (placed alongside handoff files)
|
|
12
|
+
**/handoff-state.json
|
|
13
|
+
|
|
14
|
+
# Git worktrees (superpowers / parallel feature work)
|
|
15
|
+
.worktrees/
|
|
16
|
+
# Native (harness) worktrees
|
|
17
|
+
.claude/worktrees/
|
|
18
|
+
|
|
19
|
+
# Superpowers brainstorm mockups / scratch
|
|
20
|
+
.superpowers/
|
|
21
|
+
|
|
22
|
+
# Agent-core runtime state (handoffs, bus.sqlite, transcripts, etc.)
|
|
23
|
+
.agent-core/
|
|
24
|
+
|
|
25
|
+
# Local scratch / smoke-test artifacts
|
|
26
|
+
.tmp/
|
|
27
|
+
|
|
28
|
+
# Claude Code per-machine local overrides
|
|
29
|
+
.claude/settings.local.json
|
|
30
|
+
.claude/*.lock
|
|
31
|
+
|
|
32
|
+
# Byte-compiled / optimized / DLL files
|
|
33
|
+
__pycache__/
|
|
34
|
+
*.py[codz]
|
|
35
|
+
*$py.class
|
|
36
|
+
|
|
37
|
+
# C extensions
|
|
38
|
+
*.so
|
|
39
|
+
|
|
40
|
+
# Distribution / packaging
|
|
41
|
+
.Python
|
|
42
|
+
build/
|
|
43
|
+
develop-eggs/
|
|
44
|
+
dist/
|
|
45
|
+
downloads/
|
|
46
|
+
eggs/
|
|
47
|
+
.eggs/
|
|
48
|
+
lib/
|
|
49
|
+
lib64/
|
|
50
|
+
parts/
|
|
51
|
+
sdist/
|
|
52
|
+
var/
|
|
53
|
+
wheels/
|
|
54
|
+
share/python-wheels/
|
|
55
|
+
*.egg-info/
|
|
56
|
+
.installed.cfg
|
|
57
|
+
*.egg
|
|
58
|
+
MANIFEST
|
|
59
|
+
|
|
60
|
+
# PyInstaller
|
|
61
|
+
# Usually these files are written by a python script from a template
|
|
62
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
63
|
+
*.manifest
|
|
64
|
+
*.spec
|
|
65
|
+
|
|
66
|
+
# Installer logs
|
|
67
|
+
pip-log.txt
|
|
68
|
+
pip-delete-this-directory.txt
|
|
69
|
+
|
|
70
|
+
# Unit test / coverage reports
|
|
71
|
+
htmlcov/
|
|
72
|
+
.tox/
|
|
73
|
+
.nox/
|
|
74
|
+
.coverage
|
|
75
|
+
.coverage.*
|
|
76
|
+
.cache
|
|
77
|
+
nosetests.xml
|
|
78
|
+
coverage.xml
|
|
79
|
+
*.cover
|
|
80
|
+
*.py.cover
|
|
81
|
+
.hypothesis/
|
|
82
|
+
.pytest_cache/
|
|
83
|
+
cover/
|
|
84
|
+
|
|
85
|
+
# Translations
|
|
86
|
+
*.mo
|
|
87
|
+
*.pot
|
|
88
|
+
|
|
89
|
+
# Django stuff:
|
|
90
|
+
*.log
|
|
91
|
+
local_settings.py
|
|
92
|
+
db.sqlite3
|
|
93
|
+
db.sqlite3-journal
|
|
94
|
+
|
|
95
|
+
# Flask stuff:
|
|
96
|
+
instance/
|
|
97
|
+
.webassets-cache
|
|
98
|
+
|
|
99
|
+
# Scrapy stuff:
|
|
100
|
+
.scrapy
|
|
101
|
+
|
|
102
|
+
# Sphinx documentation
|
|
103
|
+
docs/_build/
|
|
104
|
+
|
|
105
|
+
# PyBuilder
|
|
106
|
+
.pybuilder/
|
|
107
|
+
target/
|
|
108
|
+
|
|
109
|
+
# Jupyter Notebook
|
|
110
|
+
.ipynb_checkpoints
|
|
111
|
+
|
|
112
|
+
# IPython
|
|
113
|
+
profile_default/
|
|
114
|
+
ipython_config.py
|
|
115
|
+
|
|
116
|
+
# pyenv
|
|
117
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
118
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
119
|
+
# .python-version
|
|
120
|
+
|
|
121
|
+
# pipenv
|
|
122
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
123
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
124
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
125
|
+
# install all needed dependencies.
|
|
126
|
+
#Pipfile.lock
|
|
127
|
+
|
|
128
|
+
# UV
|
|
129
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
130
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
131
|
+
# commonly ignored for libraries.
|
|
132
|
+
#uv.lock
|
|
133
|
+
|
|
134
|
+
# poetry
|
|
135
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
136
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
137
|
+
# commonly ignored for libraries.
|
|
138
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
139
|
+
#poetry.lock
|
|
140
|
+
#poetry.toml
|
|
141
|
+
|
|
142
|
+
# pdm
|
|
143
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
144
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
145
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
146
|
+
#pdm.lock
|
|
147
|
+
#pdm.toml
|
|
148
|
+
.pdm-python
|
|
149
|
+
.pdm-build/
|
|
150
|
+
|
|
151
|
+
# pixi
|
|
152
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
153
|
+
#pixi.lock
|
|
154
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
155
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
156
|
+
.pixi
|
|
157
|
+
|
|
158
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
159
|
+
__pypackages__/
|
|
160
|
+
|
|
161
|
+
# Celery stuff
|
|
162
|
+
celerybeat-schedule
|
|
163
|
+
celerybeat.pid
|
|
164
|
+
|
|
165
|
+
# SageMath parsed files
|
|
166
|
+
*.sage.py
|
|
167
|
+
|
|
168
|
+
# Environments
|
|
169
|
+
.env
|
|
170
|
+
.envrc
|
|
171
|
+
.venv
|
|
172
|
+
env/
|
|
173
|
+
venv/
|
|
174
|
+
ENV/
|
|
175
|
+
env.bak/
|
|
176
|
+
venv.bak/
|
|
177
|
+
|
|
178
|
+
# Spyder project settings
|
|
179
|
+
.spyderproject
|
|
180
|
+
.spyproject
|
|
181
|
+
|
|
182
|
+
# Rope project settings
|
|
183
|
+
.ropeproject
|
|
184
|
+
|
|
185
|
+
# mkdocs documentation
|
|
186
|
+
/site
|
|
187
|
+
|
|
188
|
+
# mypy
|
|
189
|
+
.mypy_cache/
|
|
190
|
+
.dmypy.json
|
|
191
|
+
dmypy.json
|
|
192
|
+
|
|
193
|
+
# Pyre type checker
|
|
194
|
+
.pyre/
|
|
195
|
+
|
|
196
|
+
# pytype static type analyzer
|
|
197
|
+
.pytype/
|
|
198
|
+
|
|
199
|
+
# Cython debug symbols
|
|
200
|
+
cython_debug/
|
|
201
|
+
|
|
202
|
+
# PyCharm
|
|
203
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
204
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
205
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
206
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
207
|
+
#.idea/
|
|
208
|
+
|
|
209
|
+
# Abstra
|
|
210
|
+
# Abstra is an AI-powered process automation framework.
|
|
211
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
212
|
+
# Learn more at https://abstra.io/docs
|
|
213
|
+
.abstra/
|
|
214
|
+
|
|
215
|
+
# Visual Studio Code
|
|
216
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
217
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
218
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
219
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
220
|
+
# .vscode/
|
|
221
|
+
|
|
222
|
+
# Ruff stuff:
|
|
223
|
+
.ruff_cache/
|
|
224
|
+
|
|
225
|
+
# PyPI configuration file
|
|
226
|
+
.pypirc
|
|
227
|
+
|
|
228
|
+
# Cursor
|
|
229
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
230
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
231
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
232
|
+
.cursorignore
|
|
233
|
+
.cursorindexingignore
|
|
234
|
+
|
|
235
|
+
# Marimo
|
|
236
|
+
marimo/_static/
|
|
237
|
+
marimo/_lsp/
|
|
238
|
+
__marimo__/
|
|
239
|
+
.gstack/
|
|
240
|
+
|
|
241
|
+
# macOS Finder metadata (occasionally sneaks in via vendored sources)
|
|
242
|
+
.DS_Store
|
|
243
|
+
|
|
244
|
+
# Operational docs that must not live in source control
|
|
245
|
+
pepper-vault-plan.txt
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.8.1](https://github.com/jeffrichley/agent_core/compare/v0.8.0...agent-core-notify-v0.8.1) (2026-07-22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* republish package family to complete rate-limited first publish ([#477](https://github.com/jeffrichley/agent_core/issues/477)) ([32977ac](https://github.com/jeffrichley/agent_core/commit/32977ac78da4a15553329bb4e1fdaa9e894834ad))
|
|
9
|
+
|
|
10
|
+
## [0.8.0](https://github.com/jeffrichley/agent_core/compare/v0.7.0...agent-core-notify-v0.8.0) (2026-07-21)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **hatchery:** ungendered templates + .mcp.json generation ([#81](https://github.com/jeffrichley/agent_core/issues/81)/[#82](https://github.com/jeffrichley/agent_core/issues/82)) ([#357](https://github.com/jeffrichley/agent_core/issues/357)) ([f48762d](https://github.com/jeffrichley/agent_core/commit/f48762df78eb12cfa9524e9b5a277741534ea8a7)), closes [#311](https://github.com/jeffrichley/agent_core/issues/311)
|
|
16
|
+
* **release:** configure release-please for 12-package synchronized version train ([#428](https://github.com/jeffrichley/agent_core/issues/428)) ([c1b4097](https://github.com/jeffrichley/agent_core/commit/c1b409765c61d09a6657b0e8b5e43a27cb235b3e))
|
|
17
|
+
|
|
18
|
+
## Changelog
|
|
19
|
+
|
|
20
|
+
All notable changes to `agent-core-notify` are documented in this file. The
|
|
21
|
+
format is generated by towncrier from fragments in `changelog.d/` at release
|
|
22
|
+
time.
|
|
23
|
+
|
|
24
|
+
<!-- towncrier release notes start -->
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.8.1
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "agent-core-notify"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
description = "Desktop notification MCP server for agent-core agents"
|
|
5
|
+
license = "MIT"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"desktop-notifier>=5.0",
|
|
9
|
+
"mcp>=1.9.0",
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
[project.scripts]
|
|
13
|
+
agent-core-notify = "agent_core_notify.mcp_server:run"
|
|
14
|
+
|
|
15
|
+
[build-system]
|
|
16
|
+
requires = ["hatchling", "uv-dynamic-versioning"]
|
|
17
|
+
build-backend = "hatchling.build"
|
|
18
|
+
|
|
19
|
+
[tool.hatch.build.targets.wheel]
|
|
20
|
+
packages = ["src/agent_core_notify"]
|
|
21
|
+
|
|
22
|
+
[tool.hatch.version]
|
|
23
|
+
source = "uv-dynamic-versioning"
|
|
24
|
+
|
|
25
|
+
[tool.uv-dynamic-versioning]
|
|
26
|
+
fallback-version = "0.0.0"
|
|
27
|
+
|
|
28
|
+
[tool.uv]
|
|
29
|
+
cache-keys = [{ file = "pyproject.toml" }, { git = { commit = true, tags = true } }]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""agent_core_notify — Desktop notification MCP server."""
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"""Desktop notification MCP server.
|
|
2
|
+
|
|
3
|
+
Provides toast notification tools that agents can call during a session.
|
|
4
|
+
Stays alive for the session lifetime, enabling interactive notifications
|
|
5
|
+
with reply fields and action buttons.
|
|
6
|
+
|
|
7
|
+
Tools:
|
|
8
|
+
send_notification: Fire-and-forget toast notification.
|
|
9
|
+
ask_user: Send notification with reply field, return immediately with ID.
|
|
10
|
+
notify_with_buttons: Send notification with action buttons, return immediately with ID.
|
|
11
|
+
get_reply: Check if the user has replied to a notification.
|
|
12
|
+
clear_notifications: Clear all active notifications.
|
|
13
|
+
|
|
14
|
+
Launch:
|
|
15
|
+
python -m agent_core_notify.mcp_server # stdio transport (for .mcp.json)
|
|
16
|
+
|
|
17
|
+
Register in .mcp.json:
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"notify": {
|
|
21
|
+
"command": "uv",
|
|
22
|
+
"args": [
|
|
23
|
+
"run",
|
|
24
|
+
"--no-sync",
|
|
25
|
+
"--directory",
|
|
26
|
+
"E:/workspaces/ai/agents/agent_core",
|
|
27
|
+
"python",
|
|
28
|
+
"-m",
|
|
29
|
+
"agent_core_notify.mcp_server"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
from __future__ import annotations
|
|
37
|
+
|
|
38
|
+
import asyncio
|
|
39
|
+
import logging
|
|
40
|
+
import sys
|
|
41
|
+
import uuid
|
|
42
|
+
from pathlib import Path
|
|
43
|
+
|
|
44
|
+
from mcp.server.fastmcp import FastMCP
|
|
45
|
+
|
|
46
|
+
from desktop_notifier import (
|
|
47
|
+
Attachment,
|
|
48
|
+
Button,
|
|
49
|
+
DesktopNotifier,
|
|
50
|
+
Icon,
|
|
51
|
+
ReplyField,
|
|
52
|
+
Sound,
|
|
53
|
+
Urgency,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
# Logging to stderr — stdout is reserved for MCP stdio transport
|
|
57
|
+
logging.basicConfig(
|
|
58
|
+
stream=sys.stderr,
|
|
59
|
+
level=logging.INFO,
|
|
60
|
+
format="%(asctime)s %(levelname)s %(message)s",
|
|
61
|
+
datefmt="%H:%M:%S",
|
|
62
|
+
)
|
|
63
|
+
logger = logging.getLogger("agent_core_notify")
|
|
64
|
+
|
|
65
|
+
mcp = FastMCP("agent-core-notify")
|
|
66
|
+
|
|
67
|
+
# Shared notifier instance
|
|
68
|
+
_notifier = DesktopNotifier(app_name="Agent Core")
|
|
69
|
+
|
|
70
|
+
# Store for pending interactive notifications (id -> reply/button result)
|
|
71
|
+
_pending: dict[str, dict] = {}
|
|
72
|
+
# Reference to the running event loop for thread-safe callback signaling
|
|
73
|
+
_loop: asyncio.AbstractEventLoop | None = None
|
|
74
|
+
|
|
75
|
+
URGENCY_MAP = {
|
|
76
|
+
"low": Urgency.Low,
|
|
77
|
+
"normal": Urgency.Normal,
|
|
78
|
+
"critical": Urgency.Critical,
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _make_sound(sound: str | None) -> Sound | None:
|
|
83
|
+
"""Create a Sound object — auto-detects file path vs system sound name."""
|
|
84
|
+
if not sound:
|
|
85
|
+
return None
|
|
86
|
+
if Path(sound).suffix in (".wav", ".mp3", ".ogg", ".flac", ".aac", ".wma"):
|
|
87
|
+
return Sound(path=Path(sound))
|
|
88
|
+
return Sound(name=sound)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _resolve_reply(notification_id: str, reply: str) -> None:
|
|
92
|
+
"""Thread-safe callback for reply fields."""
|
|
93
|
+
if notification_id in _pending:
|
|
94
|
+
_pending[notification_id]["reply"] = reply
|
|
95
|
+
_pending[notification_id]["status"] = "replied"
|
|
96
|
+
logger.info("Reply received for %s: %s", notification_id, reply)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _resolve_button(notification_id: str, button: str) -> None:
|
|
100
|
+
"""Thread-safe callback for button presses."""
|
|
101
|
+
if notification_id in _pending:
|
|
102
|
+
_pending[notification_id]["reply"] = button
|
|
103
|
+
_pending[notification_id]["status"] = "clicked"
|
|
104
|
+
logger.info("Button clicked for %s: %s", notification_id, button)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _resolve_dismissed(notification_id: str) -> None:
|
|
108
|
+
"""Thread-safe callback for dismissed notifications."""
|
|
109
|
+
if notification_id in _pending:
|
|
110
|
+
_pending[notification_id]["reply"] = ""
|
|
111
|
+
_pending[notification_id]["status"] = "dismissed"
|
|
112
|
+
logger.info("Notification dismissed: %s", notification_id)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@mcp.tool()
|
|
116
|
+
async def send_notification(
|
|
117
|
+
title: str,
|
|
118
|
+
message: str,
|
|
119
|
+
urgency: str = "normal",
|
|
120
|
+
icon: str | None = None,
|
|
121
|
+
attachment: str | None = None,
|
|
122
|
+
sound: str | None = None,
|
|
123
|
+
thread: str | None = None,
|
|
124
|
+
) -> dict[str, str]:
|
|
125
|
+
"""Send a desktop toast notification (fire-and-forget).
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
title: Notification title (e.g., agent name).
|
|
129
|
+
message: Notification body text.
|
|
130
|
+
urgency: "low", "normal", or "critical". Default: "normal".
|
|
131
|
+
icon: Path to an icon image file. Optional.
|
|
132
|
+
attachment: Path to a file to attach. Optional.
|
|
133
|
+
sound: Name of a system sound, or path to a sound file. Optional.
|
|
134
|
+
thread: Thread ID to group related notifications. Optional.
|
|
135
|
+
"""
|
|
136
|
+
urg = URGENCY_MAP.get(urgency, Urgency.Normal)
|
|
137
|
+
icon_obj = Icon(path=Path(icon)) if icon else None
|
|
138
|
+
attach_obj = Attachment(path=Path(attachment)) if attachment else None
|
|
139
|
+
sound_obj = _make_sound(sound)
|
|
140
|
+
|
|
141
|
+
await _notifier.send(
|
|
142
|
+
title=title,
|
|
143
|
+
message=message,
|
|
144
|
+
urgency=urg,
|
|
145
|
+
icon=icon_obj,
|
|
146
|
+
attachment=attach_obj,
|
|
147
|
+
sound=sound_obj,
|
|
148
|
+
thread=thread,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
logger.info("Notification sent: %s — %s", title, message)
|
|
152
|
+
return {"status": "sent", "title": title, "message": message}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@mcp.tool()
|
|
156
|
+
async def ask_user(
|
|
157
|
+
title: str,
|
|
158
|
+
message: str,
|
|
159
|
+
reply_button_title: str = "Reply",
|
|
160
|
+
urgency: str = "normal",
|
|
161
|
+
icon: str | None = None,
|
|
162
|
+
sound: str | None = None,
|
|
163
|
+
thread: str | None = None,
|
|
164
|
+
) -> dict[str, str]:
|
|
165
|
+
"""Send a notification with a reply field. Returns immediately with a notification_id.
|
|
166
|
+
|
|
167
|
+
Use get_reply(notification_id) to check if the user has replied.
|
|
168
|
+
This does NOT block — the agent can continue working while waiting.
|
|
169
|
+
|
|
170
|
+
Args:
|
|
171
|
+
title: Notification title.
|
|
172
|
+
message: The question or prompt to show.
|
|
173
|
+
reply_button_title: Label for the reply button. Default: "Reply".
|
|
174
|
+
urgency: "low", "normal", or "critical". Default: "normal".
|
|
175
|
+
icon: Path to an icon image file. Optional.
|
|
176
|
+
sound: Name of a system sound, or path to a sound file. Optional.
|
|
177
|
+
thread: Thread ID to group related notifications. Optional.
|
|
178
|
+
"""
|
|
179
|
+
notification_id = str(uuid.uuid4())[:8]
|
|
180
|
+
_pending[notification_id] = {"status": "pending", "reply": ""}
|
|
181
|
+
|
|
182
|
+
urg = URGENCY_MAP.get(urgency, Urgency.Normal)
|
|
183
|
+
icon_obj = Icon(path=Path(icon)) if icon else None
|
|
184
|
+
sound_obj = _make_sound(sound)
|
|
185
|
+
|
|
186
|
+
await _notifier.send(
|
|
187
|
+
title=title,
|
|
188
|
+
message=message,
|
|
189
|
+
urgency=urg,
|
|
190
|
+
icon=icon_obj,
|
|
191
|
+
sound=sound_obj,
|
|
192
|
+
thread=thread,
|
|
193
|
+
reply_field=ReplyField(
|
|
194
|
+
title="Type your reply",
|
|
195
|
+
button_title=reply_button_title,
|
|
196
|
+
on_replied=lambda text: _resolve_reply(notification_id, text),
|
|
197
|
+
),
|
|
198
|
+
on_dismissed=lambda: _resolve_dismissed(notification_id),
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
logger.info("Ask sent [%s]: %s — %s", notification_id, title, message)
|
|
202
|
+
return {"status": "pending", "notification_id": notification_id}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
@mcp.tool()
|
|
206
|
+
async def notify_with_buttons(
|
|
207
|
+
title: str,
|
|
208
|
+
message: str,
|
|
209
|
+
buttons: list[str],
|
|
210
|
+
urgency: str = "normal",
|
|
211
|
+
icon: str | None = None,
|
|
212
|
+
sound: str | None = None,
|
|
213
|
+
thread: str | None = None,
|
|
214
|
+
) -> dict[str, str]:
|
|
215
|
+
"""Send a notification with action buttons. Returns immediately with a notification_id.
|
|
216
|
+
|
|
217
|
+
Use get_reply(notification_id) to check which button the user clicked.
|
|
218
|
+
This does NOT block — the agent can continue working while waiting.
|
|
219
|
+
|
|
220
|
+
Args:
|
|
221
|
+
title: Notification title.
|
|
222
|
+
message: Notification body text.
|
|
223
|
+
buttons: List of button labels (e.g., ["Approve", "Deny", "Snooze"]).
|
|
224
|
+
urgency: "low", "normal", or "critical". Default: "normal".
|
|
225
|
+
icon: Path to an icon image file. Optional.
|
|
226
|
+
sound: Name of a system sound, or path to a sound file. Optional.
|
|
227
|
+
thread: Thread ID to group related notifications. Optional.
|
|
228
|
+
"""
|
|
229
|
+
notification_id = str(uuid.uuid4())[:8]
|
|
230
|
+
_pending[notification_id] = {"status": "pending", "reply": ""}
|
|
231
|
+
|
|
232
|
+
button_objs = [
|
|
233
|
+
Button(
|
|
234
|
+
title=label,
|
|
235
|
+
on_pressed=lambda lbl=label: _resolve_button(notification_id, lbl),
|
|
236
|
+
)
|
|
237
|
+
for label in buttons
|
|
238
|
+
]
|
|
239
|
+
|
|
240
|
+
urg = URGENCY_MAP.get(urgency, Urgency.Normal)
|
|
241
|
+
icon_obj = Icon(path=Path(icon)) if icon else None
|
|
242
|
+
sound_obj = _make_sound(sound)
|
|
243
|
+
|
|
244
|
+
await _notifier.send(
|
|
245
|
+
title=title,
|
|
246
|
+
message=message,
|
|
247
|
+
urgency=urg,
|
|
248
|
+
icon=icon_obj,
|
|
249
|
+
sound=sound_obj,
|
|
250
|
+
thread=thread,
|
|
251
|
+
buttons=button_objs,
|
|
252
|
+
on_dismissed=lambda: _resolve_dismissed(notification_id),
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
logger.info("Buttons sent [%s]: %s — %s [%s]", notification_id, title, message, ", ".join(buttons))
|
|
256
|
+
return {"status": "pending", "notification_id": notification_id}
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
@mcp.tool()
|
|
260
|
+
async def get_reply(notification_id: str) -> dict[str, str]:
|
|
261
|
+
"""Check if the user has replied to or interacted with a notification.
|
|
262
|
+
|
|
263
|
+
Returns the current status:
|
|
264
|
+
- {"status": "pending"} — user hasn't responded yet
|
|
265
|
+
- {"status": "replied", "reply": "user's text"} — user typed a reply
|
|
266
|
+
- {"status": "clicked", "button": "Approve"} — user clicked a button
|
|
267
|
+
- {"status": "dismissed"} — user dismissed the notification
|
|
268
|
+
- {"status": "not_found"} — unknown notification_id
|
|
269
|
+
|
|
270
|
+
Args:
|
|
271
|
+
notification_id: The ID returned by ask_user or notify_with_buttons.
|
|
272
|
+
"""
|
|
273
|
+
if notification_id not in _pending:
|
|
274
|
+
return {"status": "not_found", "notification_id": notification_id}
|
|
275
|
+
|
|
276
|
+
entry = _pending[notification_id]
|
|
277
|
+
result = {"status": entry["status"], "notification_id": notification_id}
|
|
278
|
+
|
|
279
|
+
if entry["status"] == "replied":
|
|
280
|
+
result["reply"] = entry["reply"]
|
|
281
|
+
del _pending[notification_id]
|
|
282
|
+
elif entry["status"] == "clicked":
|
|
283
|
+
result["button"] = entry["reply"]
|
|
284
|
+
del _pending[notification_id]
|
|
285
|
+
elif entry["status"] == "dismissed":
|
|
286
|
+
del _pending[notification_id]
|
|
287
|
+
|
|
288
|
+
return result
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
@mcp.tool()
|
|
292
|
+
async def clear_notifications() -> dict[str, str]:
|
|
293
|
+
"""Clear all active notifications sent by this server."""
|
|
294
|
+
await _notifier.clear_all()
|
|
295
|
+
_pending.clear()
|
|
296
|
+
logger.info("All notifications cleared")
|
|
297
|
+
return {"status": "cleared"}
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def run() -> None:
|
|
301
|
+
"""Launch the MCP server on stdio transport."""
|
|
302
|
+
try:
|
|
303
|
+
mcp.run(transport="stdio")
|
|
304
|
+
finally:
|
|
305
|
+
# desktop-notifier's WinRT backend keeps non-daemon threads alive,
|
|
306
|
+
# which blocks normal interpreter shutdown on Windows. Force-exit
|
|
307
|
+
# so the agent-core-notify entry-point .exe isn't held open after
|
|
308
|
+
# stdio closes (otherwise `uv sync` can't replace it on the next run).
|
|
309
|
+
import os
|
|
310
|
+
os._exit(0)
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
if __name__ == "__main__":
|
|
314
|
+
run()
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[tool.towncrier]
|
|
2
|
+
name = "agent-core-notify"
|
|
3
|
+
package = "agent_core_notify"
|
|
4
|
+
package_dir = "src"
|
|
5
|
+
directory = "changelog.d"
|
|
6
|
+
filename = "CHANGELOG.md"
|
|
7
|
+
title_format = "## {version} ({project_date})"
|
|
8
|
+
issue_format = "[#{issue}](https://github.com/jeffrichley/agent_core/pull/{issue})"
|
|
9
|
+
|
|
10
|
+
[[tool.towncrier.type]]
|
|
11
|
+
directory = "added"
|
|
12
|
+
name = "Added"
|
|
13
|
+
showcontent = true
|
|
14
|
+
|
|
15
|
+
[[tool.towncrier.type]]
|
|
16
|
+
directory = "changed"
|
|
17
|
+
name = "Changed"
|
|
18
|
+
showcontent = true
|
|
19
|
+
|
|
20
|
+
[[tool.towncrier.type]]
|
|
21
|
+
directory = "deprecated"
|
|
22
|
+
name = "Deprecated"
|
|
23
|
+
showcontent = true
|
|
24
|
+
|
|
25
|
+
[[tool.towncrier.type]]
|
|
26
|
+
directory = "removed"
|
|
27
|
+
name = "Removed"
|
|
28
|
+
showcontent = true
|
|
29
|
+
|
|
30
|
+
[[tool.towncrier.type]]
|
|
31
|
+
directory = "fixed"
|
|
32
|
+
name = "Fixed"
|
|
33
|
+
showcontent = true
|
|
34
|
+
|
|
35
|
+
[[tool.towncrier.type]]
|
|
36
|
+
directory = "security"
|
|
37
|
+
name = "Security"
|
|
38
|
+
showcontent = true
|