bog-agents-daemon 0.7.1__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.
- bog_agents_daemon-0.7.1/.gitignore +232 -0
- bog_agents_daemon-0.7.1/CHANGELOG.md +32 -0
- bog_agents_daemon-0.7.1/Makefile +20 -0
- bog_agents_daemon-0.7.1/PKG-INFO +201 -0
- bog_agents_daemon-0.7.1/README.md +171 -0
- bog_agents_daemon-0.7.1/bog_agents_daemon/__init__.py +3 -0
- bog_agents_daemon-0.7.1/bog_agents_daemon/api.py +579 -0
- bog_agents_daemon-0.7.1/bog_agents_daemon/install.py +256 -0
- bog_agents_daemon-0.7.1/bog_agents_daemon/main.py +150 -0
- bog_agents_daemon-0.7.1/bog_agents_daemon/models.py +196 -0
- bog_agents_daemon-0.7.1/bog_agents_daemon/runner.py +422 -0
- bog_agents_daemon-0.7.1/bog_agents_daemon/scheduler.py +322 -0
- bog_agents_daemon-0.7.1/bog_agents_daemon/store.py +322 -0
- bog_agents_daemon-0.7.1/pyproject.toml +73 -0
- bog_agents_daemon-0.7.1/tests/conftest.py +23 -0
- bog_agents_daemon-0.7.1/tests/test_api.py +261 -0
- bog_agents_daemon-0.7.1/tests/test_install.py +75 -0
- bog_agents_daemon-0.7.1/tests/test_models.py +70 -0
- bog_agents_daemon-0.7.1/tests/test_runner.py +222 -0
- bog_agents_daemon-0.7.1/tests/test_scheduler.py +251 -0
- bog_agents_daemon-0.7.1/tests/test_store.py +159 -0
- bog_agents_daemon-0.7.1/uv.lock +1607 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Node.js
|
|
192
|
+
node_modules/
|
|
193
|
+
|
|
194
|
+
# Ruff stuff:
|
|
195
|
+
.ruff_cache/
|
|
196
|
+
|
|
197
|
+
# Pytest temporary runtime directories (created by conftest.py test isolation)
|
|
198
|
+
.pytest-tmp-runtime/
|
|
199
|
+
|
|
200
|
+
# PyPI configuration file
|
|
201
|
+
.pypirc
|
|
202
|
+
|
|
203
|
+
# Cursor
|
|
204
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
205
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
206
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
207
|
+
.cursorignore
|
|
208
|
+
.cursorindexingignore
|
|
209
|
+
|
|
210
|
+
# Marimo
|
|
211
|
+
marimo/_static/
|
|
212
|
+
marimo/_lsp/
|
|
213
|
+
__marimo__/
|
|
214
|
+
|
|
215
|
+
# LangGraph
|
|
216
|
+
.langgraph_api
|
|
217
|
+
|
|
218
|
+
#claude
|
|
219
|
+
.claude
|
|
220
|
+
|
|
221
|
+
.idea
|
|
222
|
+
TEXTUAL_REFACTOR_PLAN.md
|
|
223
|
+
libs/cli/TEXTUAL_PROGRESS.md
|
|
224
|
+
|
|
225
|
+
/tmp/
|
|
226
|
+
.tmp*/
|
|
227
|
+
|
|
228
|
+
# macOS
|
|
229
|
+
.DS_Store
|
|
230
|
+
*/tmp/.DS_Store
|
|
231
|
+
|
|
232
|
+
CLAUDE.md
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.7.1](https://github.com/bogware/bog-agents/compare/bog-agents-daemon==0.7.0...bog-agents-daemon==0.7.1) (2026-04-20)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* 0.7.0 - daemon/mcp/plugins/hardening ([#40](https://github.com/bogware/bog-agents/issues/40)) ([2427dfb](https://github.com/bogware/bog-agents/commit/2427dfbda3bffc17ea34f6e38de8d2634a57f86f))
|
|
9
|
+
|
|
10
|
+
## [0.7.0] - 2026-04-18
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- Initial production release of the ambient agent daemon
|
|
15
|
+
- REST API (FastAPI) on `localhost:7391` with token-based auth
|
|
16
|
+
- Job store: persistent JSON storage with atomic writes and thread-safe locking
|
|
17
|
+
- Trigger types: cron, interval, file-change (with debounce), webhook (HMAC-SHA256 verified), git-push, manual
|
|
18
|
+
- Output targets: log, file, email (SMTP), Slack, GitHub comments, webhook, stdout
|
|
19
|
+
- Scheduler: asyncio-based with configurable concurrency semaphore (default 5 concurrent jobs)
|
|
20
|
+
- Service installer: systemd unit generator (`install_systemd`) and macOS launchd plist generator (`install_launchd`)
|
|
21
|
+
- Git hook installer: `install_git_hook` writes a post-receive hook to any repo
|
|
22
|
+
- Graceful shutdown: drains in-flight jobs (30 s timeout) on SIGTERM/SIGINT
|
|
23
|
+
- Agent timeout: configurable via `BOG_DAEMON_AGENT_TIMEOUT` env var (default 30 min)
|
|
24
|
+
- Run file pruning: keeps last N run files per job (`BOG_DAEMON_MAX_RUNS_PER_JOB`, default 100)
|
|
25
|
+
- `/ready` readiness probe endpoint (no auth — Kubernetes-compatible)
|
|
26
|
+
|
|
27
|
+
### Security
|
|
28
|
+
|
|
29
|
+
- Timing-safe auth token comparison via `hmac.compare_digest`
|
|
30
|
+
- Path traversal guard on file output targets
|
|
31
|
+
- Shell injection prevention via `shlex.quote()` in git hook generation
|
|
32
|
+
- HMAC-SHA256 webhook secret validation
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.PHONY: install test lint format help
|
|
2
|
+
|
|
3
|
+
install:
|
|
4
|
+
uv sync --group test
|
|
5
|
+
|
|
6
|
+
test:
|
|
7
|
+
uv run --group test pytest tests/ -q --timeout=30
|
|
8
|
+
|
|
9
|
+
lint:
|
|
10
|
+
uv run ruff check bog_agents_daemon/
|
|
11
|
+
uv run ruff check tests/ --ignore=ANN,S,ARG || true
|
|
12
|
+
|
|
13
|
+
format:
|
|
14
|
+
uv run ruff format bog_agents_daemon/ tests/
|
|
15
|
+
|
|
16
|
+
help:
|
|
17
|
+
@echo "install - install dependencies"
|
|
18
|
+
@echo "test - run unit tests"
|
|
19
|
+
@echo "lint - run ruff linter"
|
|
20
|
+
@echo "format - run ruff formatter"
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bog-agents-daemon
|
|
3
|
+
Version: 0.7.1
|
|
4
|
+
Summary: Ambient agent daemon for bog-agents — run agents on schedules, file-change triggers, webhooks, and git pushes
|
|
5
|
+
Project-URL: Homepage, https://github.com/bogware/bog-agents
|
|
6
|
+
Project-URL: Repository, https://github.com/bogware/bog-agents
|
|
7
|
+
Project-URL: Issues, https://github.com/bogware/bog-agents/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/bogware/bog-agents/blob/main/libs/daemon/CHANGELOG.md
|
|
9
|
+
Author-email: bogware <support@bogware.com>
|
|
10
|
+
Maintainer-email: bogware <support@bogware.com>
|
|
11
|
+
License: MIT
|
|
12
|
+
Keywords: agents,ai,bog-agents,cron,daemon,langchain,langgraph,llm,scheduler
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: No Input/Output (Daemon)
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Classifier: Topic :: System :: Distributed Computing
|
|
24
|
+
Requires-Python: <4.0,>=3.11
|
|
25
|
+
Requires-Dist: aiofiles<25.0.0,>=23.0.0
|
|
26
|
+
Requires-Dist: bog-agents<1.0.0,>=0.7.0
|
|
27
|
+
Requires-Dist: fastapi<1.0.0,>=0.115.0
|
|
28
|
+
Requires-Dist: uvicorn<1.0.0,>=0.30.0
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# bog-agents-daemon
|
|
32
|
+
|
|
33
|
+
**v0.7.0** — Ambient agent daemon for [Bog Agents](https://github.com/bogware/bog-agents). Run AI agents on schedules, file-change triggers, webhooks, and git pushes without keeping a terminal open.
|
|
34
|
+
|
|
35
|
+
[](https://pypi.org/project/bog-agents-daemon/)
|
|
36
|
+
[](https://opensource.org/licenses/MIT)
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install bog-agents-daemon
|
|
44
|
+
|
|
45
|
+
# Or with uv
|
|
46
|
+
uv tool install bog-agents-daemon
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Requires **Python 3.11+** and a running Bog Agents installation (`bog-agents>=0.7.0`).
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Quick Start
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# 1. Start the daemon (runs on localhost:7391 by default)
|
|
57
|
+
bog-agents-daemon
|
|
58
|
+
|
|
59
|
+
# 2. Or manage it via the bog-agents CLI
|
|
60
|
+
bog-agents daemon start
|
|
61
|
+
bog-agents daemon status
|
|
62
|
+
|
|
63
|
+
# 3. Create a job (cron trigger, every day at 9 AM)
|
|
64
|
+
curl -s -X POST http://localhost:7391/jobs \
|
|
65
|
+
-H "X-Daemon-Token: $(cat ~/.bog-agents/daemon/token)" \
|
|
66
|
+
-H "Content-Type: application/json" \
|
|
67
|
+
-d '{
|
|
68
|
+
"name": "daily-standup",
|
|
69
|
+
"prompt": "Summarize recent git commits and open PRs",
|
|
70
|
+
"triggers": [{"type": "cron", "cron": "0 9 * * 1-5"}],
|
|
71
|
+
"outputs": [{"target": "log"}]
|
|
72
|
+
}'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Install as a System Service
|
|
78
|
+
|
|
79
|
+
The daemon can auto-register itself as a background service that starts on login:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Linux (systemd)
|
|
83
|
+
bog-agents daemon install
|
|
84
|
+
systemctl --user enable --now bog-agents-daemon
|
|
85
|
+
|
|
86
|
+
# macOS (launchd)
|
|
87
|
+
bog-agents daemon install
|
|
88
|
+
# daemon starts automatically at login
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Trigger Types
|
|
94
|
+
|
|
95
|
+
| Trigger | Config key | Description |
|
|
96
|
+
|---------|-----------|-------------|
|
|
97
|
+
| **cron** | `cron: "0 9 * * 1-5"` | Standard 5-field cron expression |
|
|
98
|
+
| **interval** | `interval_seconds: 3600` | Every N seconds |
|
|
99
|
+
| **file_change** | `watch_dir`, `watch_patterns` | Any matched file modified |
|
|
100
|
+
| **webhook** | `webhook_path: "/hooks/deploy"` | POST to `/webhooks/<path>` |
|
|
101
|
+
| **git_push** | `git_branch_pattern: "main"` | Git post-receive hook fires |
|
|
102
|
+
| **manual** | — | `POST /jobs/{id}/run` |
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Output Targets
|
|
107
|
+
|
|
108
|
+
| Target | Description |
|
|
109
|
+
|--------|-------------|
|
|
110
|
+
| `log` | Daemon log (default) |
|
|
111
|
+
| `file` | Append/overwrite a local file |
|
|
112
|
+
| `email` | Send via SMTP |
|
|
113
|
+
| `slack` | Post to a Slack incoming webhook |
|
|
114
|
+
| `github_comment` | Comment on a GitHub issue or PR |
|
|
115
|
+
| `webhook` | POST JSON to any URL |
|
|
116
|
+
| `stdout` | Print to daemon stdout |
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## REST API
|
|
121
|
+
|
|
122
|
+
The daemon exposes a REST API on `http://127.0.0.1:7391` (localhost only). All endpoints except `/ready` require the `X-Daemon-Token` header.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
TOKEN=$(cat ~/.bog-agents/daemon/token)
|
|
126
|
+
|
|
127
|
+
# Health
|
|
128
|
+
curl -H "X-Daemon-Token: $TOKEN" http://localhost:7391/health
|
|
129
|
+
|
|
130
|
+
# Readiness probe (no auth)
|
|
131
|
+
curl http://localhost:7391/ready
|
|
132
|
+
|
|
133
|
+
# List jobs
|
|
134
|
+
curl -H "X-Daemon-Token: $TOKEN" http://localhost:7391/jobs
|
|
135
|
+
|
|
136
|
+
# Create job
|
|
137
|
+
curl -X POST -H "X-Daemon-Token: $TOKEN" -H "Content-Type: application/json" \
|
|
138
|
+
-d '{"name":"my-job","prompt":"...","triggers":[...],"outputs":[...]}' \
|
|
139
|
+
http://localhost:7391/jobs
|
|
140
|
+
|
|
141
|
+
# Trigger manually
|
|
142
|
+
curl -X POST -H "X-Daemon-Token: $TOKEN" http://localhost:7391/jobs/{id}/run
|
|
143
|
+
|
|
144
|
+
# View run history
|
|
145
|
+
curl -H "X-Daemon-Token: $TOKEN" http://localhost:7391/jobs/{id}/runs
|
|
146
|
+
|
|
147
|
+
# Enable/disable
|
|
148
|
+
curl -X POST -H "X-Daemon-Token: $TOKEN" http://localhost:7391/jobs/{id}/enable
|
|
149
|
+
curl -X POST -H "X-Daemon-Token: $TOKEN" http://localhost:7391/jobs/{id}/disable
|
|
150
|
+
|
|
151
|
+
# Delete
|
|
152
|
+
curl -X DELETE -H "X-Daemon-Token: $TOKEN" http://localhost:7391/jobs/{id}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Git Push Triggers
|
|
158
|
+
|
|
159
|
+
Install a git post-receive hook to fire jobs on push:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Via bog-agents CLI (recommended)
|
|
163
|
+
bog-agents daemon install-git-hook --repo /path/to/repo
|
|
164
|
+
|
|
165
|
+
# Or via daemon CLI
|
|
166
|
+
bog-agents-daemon install-git-hook --repo /path/to/repo
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The hook POSTs `{"ref": "refs/heads/main", "new_sha": "...", "old_sha": "..."}` to `/webhooks/git-push`. Jobs with `type: git_push` and a matching `git_branch_pattern` will fire.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Environment Variables
|
|
174
|
+
|
|
175
|
+
| Variable | Default | Description |
|
|
176
|
+
|----------|---------|-------------|
|
|
177
|
+
| `BOG_DAEMON_AGENT_TIMEOUT` | `1800` | Max seconds per agent run |
|
|
178
|
+
| `BOG_DAEMON_MAX_CONCURRENT_JOBS` | `5` | Max parallel agent executions |
|
|
179
|
+
| `BOG_DAEMON_MAX_RUNS_PER_JOB` | `100` | Run files kept per job (older pruned) |
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Security
|
|
184
|
+
|
|
185
|
+
- API binds to `127.0.0.1` (localhost only) — not reachable from the network.
|
|
186
|
+
- Auth token stored at `~/.bog-agents/daemon/token` (mode `0600`).
|
|
187
|
+
- Webhook secrets validated with HMAC-SHA256 (`hmac.compare_digest` — timing-safe).
|
|
188
|
+
- Token comparison uses `hmac.compare_digest` to prevent timing attacks.
|
|
189
|
+
- File output restricted to `$HOME` and `/tmp` (path traversal guard).
|
|
190
|
+
- Git hook scripts use `shlex.quote()` to prevent shell injection.
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Development
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
cd libs/daemon
|
|
198
|
+
uv sync --group test
|
|
199
|
+
uv run pytest tests/ -q
|
|
200
|
+
uv run ruff check bog_agents_daemon/
|
|
201
|
+
```
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# bog-agents-daemon
|
|
2
|
+
|
|
3
|
+
**v0.7.0** — Ambient agent daemon for [Bog Agents](https://github.com/bogware/bog-agents). Run AI agents on schedules, file-change triggers, webhooks, and git pushes without keeping a terminal open.
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/bog-agents-daemon/)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install bog-agents-daemon
|
|
14
|
+
|
|
15
|
+
# Or with uv
|
|
16
|
+
uv tool install bog-agents-daemon
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Requires **Python 3.11+** and a running Bog Agents installation (`bog-agents>=0.7.0`).
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# 1. Start the daemon (runs on localhost:7391 by default)
|
|
27
|
+
bog-agents-daemon
|
|
28
|
+
|
|
29
|
+
# 2. Or manage it via the bog-agents CLI
|
|
30
|
+
bog-agents daemon start
|
|
31
|
+
bog-agents daemon status
|
|
32
|
+
|
|
33
|
+
# 3. Create a job (cron trigger, every day at 9 AM)
|
|
34
|
+
curl -s -X POST http://localhost:7391/jobs \
|
|
35
|
+
-H "X-Daemon-Token: $(cat ~/.bog-agents/daemon/token)" \
|
|
36
|
+
-H "Content-Type: application/json" \
|
|
37
|
+
-d '{
|
|
38
|
+
"name": "daily-standup",
|
|
39
|
+
"prompt": "Summarize recent git commits and open PRs",
|
|
40
|
+
"triggers": [{"type": "cron", "cron": "0 9 * * 1-5"}],
|
|
41
|
+
"outputs": [{"target": "log"}]
|
|
42
|
+
}'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Install as a System Service
|
|
48
|
+
|
|
49
|
+
The daemon can auto-register itself as a background service that starts on login:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Linux (systemd)
|
|
53
|
+
bog-agents daemon install
|
|
54
|
+
systemctl --user enable --now bog-agents-daemon
|
|
55
|
+
|
|
56
|
+
# macOS (launchd)
|
|
57
|
+
bog-agents daemon install
|
|
58
|
+
# daemon starts automatically at login
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Trigger Types
|
|
64
|
+
|
|
65
|
+
| Trigger | Config key | Description |
|
|
66
|
+
|---------|-----------|-------------|
|
|
67
|
+
| **cron** | `cron: "0 9 * * 1-5"` | Standard 5-field cron expression |
|
|
68
|
+
| **interval** | `interval_seconds: 3600` | Every N seconds |
|
|
69
|
+
| **file_change** | `watch_dir`, `watch_patterns` | Any matched file modified |
|
|
70
|
+
| **webhook** | `webhook_path: "/hooks/deploy"` | POST to `/webhooks/<path>` |
|
|
71
|
+
| **git_push** | `git_branch_pattern: "main"` | Git post-receive hook fires |
|
|
72
|
+
| **manual** | — | `POST /jobs/{id}/run` |
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Output Targets
|
|
77
|
+
|
|
78
|
+
| Target | Description |
|
|
79
|
+
|--------|-------------|
|
|
80
|
+
| `log` | Daemon log (default) |
|
|
81
|
+
| `file` | Append/overwrite a local file |
|
|
82
|
+
| `email` | Send via SMTP |
|
|
83
|
+
| `slack` | Post to a Slack incoming webhook |
|
|
84
|
+
| `github_comment` | Comment on a GitHub issue or PR |
|
|
85
|
+
| `webhook` | POST JSON to any URL |
|
|
86
|
+
| `stdout` | Print to daemon stdout |
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## REST API
|
|
91
|
+
|
|
92
|
+
The daemon exposes a REST API on `http://127.0.0.1:7391` (localhost only). All endpoints except `/ready` require the `X-Daemon-Token` header.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
TOKEN=$(cat ~/.bog-agents/daemon/token)
|
|
96
|
+
|
|
97
|
+
# Health
|
|
98
|
+
curl -H "X-Daemon-Token: $TOKEN" http://localhost:7391/health
|
|
99
|
+
|
|
100
|
+
# Readiness probe (no auth)
|
|
101
|
+
curl http://localhost:7391/ready
|
|
102
|
+
|
|
103
|
+
# List jobs
|
|
104
|
+
curl -H "X-Daemon-Token: $TOKEN" http://localhost:7391/jobs
|
|
105
|
+
|
|
106
|
+
# Create job
|
|
107
|
+
curl -X POST -H "X-Daemon-Token: $TOKEN" -H "Content-Type: application/json" \
|
|
108
|
+
-d '{"name":"my-job","prompt":"...","triggers":[...],"outputs":[...]}' \
|
|
109
|
+
http://localhost:7391/jobs
|
|
110
|
+
|
|
111
|
+
# Trigger manually
|
|
112
|
+
curl -X POST -H "X-Daemon-Token: $TOKEN" http://localhost:7391/jobs/{id}/run
|
|
113
|
+
|
|
114
|
+
# View run history
|
|
115
|
+
curl -H "X-Daemon-Token: $TOKEN" http://localhost:7391/jobs/{id}/runs
|
|
116
|
+
|
|
117
|
+
# Enable/disable
|
|
118
|
+
curl -X POST -H "X-Daemon-Token: $TOKEN" http://localhost:7391/jobs/{id}/enable
|
|
119
|
+
curl -X POST -H "X-Daemon-Token: $TOKEN" http://localhost:7391/jobs/{id}/disable
|
|
120
|
+
|
|
121
|
+
# Delete
|
|
122
|
+
curl -X DELETE -H "X-Daemon-Token: $TOKEN" http://localhost:7391/jobs/{id}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Git Push Triggers
|
|
128
|
+
|
|
129
|
+
Install a git post-receive hook to fire jobs on push:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Via bog-agents CLI (recommended)
|
|
133
|
+
bog-agents daemon install-git-hook --repo /path/to/repo
|
|
134
|
+
|
|
135
|
+
# Or via daemon CLI
|
|
136
|
+
bog-agents-daemon install-git-hook --repo /path/to/repo
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The hook POSTs `{"ref": "refs/heads/main", "new_sha": "...", "old_sha": "..."}` to `/webhooks/git-push`. Jobs with `type: git_push` and a matching `git_branch_pattern` will fire.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Environment Variables
|
|
144
|
+
|
|
145
|
+
| Variable | Default | Description |
|
|
146
|
+
|----------|---------|-------------|
|
|
147
|
+
| `BOG_DAEMON_AGENT_TIMEOUT` | `1800` | Max seconds per agent run |
|
|
148
|
+
| `BOG_DAEMON_MAX_CONCURRENT_JOBS` | `5` | Max parallel agent executions |
|
|
149
|
+
| `BOG_DAEMON_MAX_RUNS_PER_JOB` | `100` | Run files kept per job (older pruned) |
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Security
|
|
154
|
+
|
|
155
|
+
- API binds to `127.0.0.1` (localhost only) — not reachable from the network.
|
|
156
|
+
- Auth token stored at `~/.bog-agents/daemon/token` (mode `0600`).
|
|
157
|
+
- Webhook secrets validated with HMAC-SHA256 (`hmac.compare_digest` — timing-safe).
|
|
158
|
+
- Token comparison uses `hmac.compare_digest` to prevent timing attacks.
|
|
159
|
+
- File output restricted to `$HOME` and `/tmp` (path traversal guard).
|
|
160
|
+
- Git hook scripts use `shlex.quote()` to prevent shell injection.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Development
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
cd libs/daemon
|
|
168
|
+
uv sync --group test
|
|
169
|
+
uv run pytest tests/ -q
|
|
170
|
+
uv run ruff check bog_agents_daemon/
|
|
171
|
+
```
|