watchpost-agent 0.4.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.
- watchpost_agent-0.4.1/.agents/skills/verify-thread-lifecycle/SKILL.md +58 -0
- watchpost_agent-0.4.1/.github/ISSUE_TEMPLATE/bug_report.md +20 -0
- watchpost_agent-0.4.1/.github/ISSUE_TEMPLATE/feature_request.md +14 -0
- watchpost_agent-0.4.1/.github/workflows/ci.yml +38 -0
- watchpost_agent-0.4.1/.github/workflows/publish.yml +56 -0
- watchpost_agent-0.4.1/.gitignore +18 -0
- watchpost_agent-0.4.1/AGENTS.md +26 -0
- watchpost_agent-0.4.1/CHANGELOG.md +34 -0
- watchpost_agent-0.4.1/CONTRIBUTING.md +31 -0
- watchpost_agent-0.4.1/LICENSE +202 -0
- watchpost_agent-0.4.1/PKG-INFO +171 -0
- watchpost_agent-0.4.1/README.md +140 -0
- watchpost_agent-0.4.1/README.zh-CN.md +140 -0
- watchpost_agent-0.4.1/SECURITY.md +26 -0
- watchpost_agent-0.4.1/docs/ARCHITECTURE.md +73 -0
- watchpost_agent-0.4.1/docs/PLATFORM_ROADMAP.md +36 -0
- watchpost_agent-0.4.1/docs/PLUGIN_SDK.md +103 -0
- watchpost_agent-0.4.1/examples/channel_plugin_template.py +86 -0
- watchpost_agent-0.4.1/examples/notifier_plugin_template.py +62 -0
- watchpost_agent-0.4.1/examples/whatsapp_plugin_template.py +102 -0
- watchpost_agent-0.4.1/formal/WatchpostThread.cfg +6 -0
- watchpost_agent-0.4.1/formal/WatchpostThread.tla +214 -0
- watchpost_agent-0.4.1/formal/watchpost-view.mjs +100 -0
- watchpost_agent-0.4.1/pyproject.toml +57 -0
- watchpost_agent-0.4.1/src/watchpost/__init__.py +4 -0
- watchpost_agent-0.4.1/src/watchpost/adapters/__init__.py +24 -0
- watchpost_agent-0.4.1/src/watchpost/adapters/dingtalk.py +348 -0
- watchpost_agent-0.4.1/src/watchpost/adapters/discord.py +289 -0
- watchpost_agent-0.4.1/src/watchpost/adapters/external_plugin.py +98 -0
- watchpost_agent-0.4.1/src/watchpost/adapters/feishu.py +668 -0
- watchpost_agent-0.4.1/src/watchpost/adapters/local_sandbox.py +277 -0
- watchpost_agent-0.4.1/src/watchpost/adapters/simulator.py +198 -0
- watchpost_agent-0.4.1/src/watchpost/adapters/slack.py +376 -0
- watchpost_agent-0.4.1/src/watchpost/adapters/telegram.py +608 -0
- watchpost_agent-0.4.1/src/watchpost/adapters/wecom.py +360 -0
- watchpost_agent-0.4.1/src/watchpost/assets/avatar.jpg +0 -0
- watchpost_agent-0.4.1/src/watchpost/backends/__init__.py +8 -0
- watchpost_agent-0.4.1/src/watchpost/backends/antigravity.py +216 -0
- watchpost_agent-0.4.1/src/watchpost/backends/cli_agent.py +284 -0
- watchpost_agent-0.4.1/src/watchpost/backends/fallback.py +139 -0
- watchpost_agent-0.4.1/src/watchpost/backends/mock.py +165 -0
- watchpost_agent-0.4.1/src/watchpost/bubbles.py +227 -0
- watchpost_agent-0.4.1/src/watchpost/cli.py +1123 -0
- watchpost_agent-0.4.1/src/watchpost/config.py +552 -0
- watchpost_agent-0.4.1/src/watchpost/context.py +203 -0
- watchpost_agent-0.4.1/src/watchpost/daemon.py +1132 -0
- watchpost_agent-0.4.1/src/watchpost/debouncer.py +110 -0
- watchpost_agent-0.4.1/src/watchpost/engine.py +1837 -0
- watchpost_agent-0.4.1/src/watchpost/filters.py +131 -0
- watchpost_agent-0.4.1/src/watchpost/media.py +95 -0
- watchpost_agent-0.4.1/src/watchpost/models.py +188 -0
- watchpost_agent-0.4.1/src/watchpost/notifiers/__init__.py +269 -0
- watchpost_agent-0.4.1/src/watchpost/notifiers/bark.py +136 -0
- watchpost_agent-0.4.1/src/watchpost/notifiers/console.py +96 -0
- watchpost_agent-0.4.1/src/watchpost/notifiers/discord.py +181 -0
- watchpost_agent-0.4.1/src/watchpost/notifiers/external_plugin.py +122 -0
- watchpost_agent-0.4.1/src/watchpost/notifiers/imessage.py +571 -0
- watchpost_agent-0.4.1/src/watchpost/notifiers/ntfy.py +192 -0
- watchpost_agent-0.4.1/src/watchpost/notifiers/pushover.py +130 -0
- watchpost_agent-0.4.1/src/watchpost/notifiers/slack.py +212 -0
- watchpost_agent-0.4.1/src/watchpost/notifiers/telegram.py +918 -0
- watchpost_agent-0.4.1/src/watchpost/notifiers/wecom.py +120 -0
- watchpost_agent-0.4.1/src/watchpost/plugins.py +268 -0
- watchpost_agent-0.4.1/src/watchpost/ports.py +112 -0
- watchpost_agent-0.4.1/src/watchpost/prompts.py +396 -0
- watchpost_agent-0.4.1/src/watchpost/sandbox.py +345 -0
- watchpost_agent-0.4.1/src/watchpost/sandbox_ui.py +1300 -0
- watchpost_agent-0.4.1/src/watchpost/sdk.py +302 -0
- watchpost_agent-0.4.1/src/watchpost/security.py +142 -0
- watchpost_agent-0.4.1/src/watchpost/server.py +386 -0
- watchpost_agent-0.4.1/src/watchpost/setup_wizard.py +489 -0
- watchpost_agent-0.4.1/src/watchpost/skill_installer.py +53 -0
- watchpost_agent-0.4.1/src/watchpost/skills/watchpost/SKILL.md +116 -0
- watchpost_agent-0.4.1/src/watchpost/store.py +966 -0
- watchpost_agent-0.4.1/tests/test_config_cli.py +111 -0
- watchpost_agent-0.4.1/tests/test_daemon_e2e.py +286 -0
- watchpost_agent-0.4.1/tests/test_debouncer_engine.py +250 -0
- watchpost_agent-0.4.1/tests/test_feishu_adapter.py +195 -0
- watchpost_agent-0.4.1/tests/test_filters_context.py +185 -0
- watchpost_agent-0.4.1/tests/test_formal_state_regressions.py +414 -0
- watchpost_agent-0.4.1/tests/test_notifiers.py +460 -0
- watchpost_agent-0.4.1/tests/test_platforms_enterprise.py +375 -0
- watchpost_agent-0.4.1/tests/test_platforms_global.py +475 -0
- watchpost_agent-0.4.1/tests/test_prompts_bubbles.py +150 -0
- watchpost_agent-0.4.1/tests/test_sandbox.py +254 -0
- watchpost_agent-0.4.1/tests/test_sdk_plugins_setup.py +552 -0
- watchpost_agent-0.4.1/tests/test_server.py +243 -0
- watchpost_agent-0.4.1/tests/test_store.py +108 -0
- watchpost_agent-0.4.1/tests/test_v03_parity.py +1478 -0
- watchpost_agent-0.4.1/tests/test_v040_launch_readiness.py +1552 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: verify-thread-lifecycle
|
|
3
|
+
description: Formally verify Watchpost thread lifecycle, pending_go approval gates, workspace turn locking, and crash recovery invariants with TLA+ and TLC. Run during any major update or when changing src/watchpost/engine.py, src/watchpost/store.py, or src/watchpost/backends/.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Verify Watchpost Thread Lifecycle
|
|
7
|
+
|
|
8
|
+
Checks the TLA+ model in `formal/WatchpostThread.tla` against the invariants governing inbound message steering, owner `go` approval gating, per-thread and workspace read/write locking, and crash recovery.
|
|
9
|
+
|
|
10
|
+
## Coverage & Sync Record
|
|
11
|
+
|
|
12
|
+
- `sync_commit`: `131b853`
|
|
13
|
+
- **Covered files & symbols:**
|
|
14
|
+
- `src/watchpost/engine.py`: `_AsyncRWLock`, `_get_thread_lock`, `_acquire_turn`, `_process_trigger_batch`, `steer_from_owner`, `dismiss_go`, `handle_owner_action`
|
|
15
|
+
- `src/watchpost/store.py`: `create_or_update_thread`, `dismiss_thread_go`, `claim_pending_go`, `set_thread_status`, `dismiss_all_pending_go`, `recover_stale_active_threads`
|
|
16
|
+
- **Check for code drift since last sync:**
|
|
17
|
+
```sh
|
|
18
|
+
git diff 131b853..HEAD -- src/watchpost/engine.py src/watchpost/store.py
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
If covered files changed after `sync_commit`, follow the installed `maintain-formal-verification-skill` before interpreting a pass. Only move `sync_commit` forward after confirming `formal/WatchpostThread.tla` accurately describes `HEAD` and passes a mutation check.
|
|
22
|
+
|
|
23
|
+
## Verified Properties (Invariants)
|
|
24
|
+
|
|
25
|
+
1. **`NoPlaceholderSteer`:** A follow-up batch never invokes `steer_thread` with an initial `pending_<id>` placeholder ref, and a committed non-placeholder ref is never overwritten back to a placeholder.
|
|
26
|
+
2. **`NoConcurrentWriteAndRead`:** A writable `approved_go` turn never runs concurrently with a read-only owner steer or inbound follow-up turn on the same thread/workspace.
|
|
27
|
+
3. **`NoZombieAwaitingGo`:** A thread never stays in `status = awaiting_go` once `pending_go` has been cleared at any point, including immediately upon `claim_pending_go` (which atomically transitions `status` to `active`).
|
|
28
|
+
4. **`AtMostOneApprovedGo`:** Concurrent or repeated `go` taps trigger at most one writable `approved_go` execution.
|
|
29
|
+
|
|
30
|
+
## Bounds, Assumptions & Out-of-Scope
|
|
31
|
+
|
|
32
|
+
- **Bounds:** Single thread, 2 inbound channel batches (`inb1`, `inb2` covering placeholder steer check, real steer, and fresh start), `hadRealRef` tracking, 1 owner `go` attempt (`OwnerClaimGo`, `OwnerGoFailAfterClaim`, `OwnerGoStartWrite`, `goExecCount <= 2`) plus duplicate tap check (`SecondGoAttempt`), 1 owner follow-up steer (`ownerSteer`), and at most 1 daemon crash/restart (`restarted`).
|
|
33
|
+
- **Out of scope:** Quiet-hours digest queuing (`quiet_digest_queue`), external adapter cursor/debouncer timing (`BurstDebouncer`), personal direct-chat threads (`personal_direct`), and `FallbackBackend` failover internals.
|
|
34
|
+
|
|
35
|
+
## Verified Status at `131b853`
|
|
36
|
+
|
|
37
|
+
- **Model check (`WatchpostThread`):** TLC explores **75 states / 149 steps** (12 chart states, 29 arrows). All 4 invariants (`NoPlaceholderSteer`, `NoConcurrentWriteAndRead`, `NoZombieAwaitingGo`, `AtMostOneApprovedGo`) and `NoDeadlock` **hold** (`exit 0`).
|
|
38
|
+
- **Mutation proof:** Removing `ThreadLockFree` / `WorkspaceReadAllowed` from `OwnerSteerStart` fails `NoConcurrentWriteAndRead` in 5 steps (`exit 1`).
|
|
39
|
+
- **History:** Baseline violations discovered at `c54ddfb` (`NoPlaceholderSteer`, `NoConcurrentWriteAndRead`, `NoZombieAwaitingGo`) were fixed in `131b853` with regression tests in `tests/test_formal_state_regressions.py` and `tests/test_v040_launch_readiness.py`.
|
|
40
|
+
|
|
41
|
+
Treat any failure in these invariants or `NoDeadlock` as an immediate release blocker.
|
|
42
|
+
|
|
43
|
+
## How to Run
|
|
44
|
+
|
|
45
|
+
Run `formal/WatchpostThread.tla` with the installed `statechart` skill (writing output to a fresh folder under `/tmp`, never inside the repository):
|
|
46
|
+
|
|
47
|
+
- Model: `formal/WatchpostThread.tla`
|
|
48
|
+
- Config: `formal/WatchpostThread.cfg`
|
|
49
|
+
- View: `formal/watchpost-view.mjs`
|
|
50
|
+
- Output: `/tmp/watchpost-statechart-<run>` (must be a non-existent or empty directory)
|
|
51
|
+
|
|
52
|
+
*Contributor fallback (without the `statechart` skill):* run standard TLC (`java -cp tla2tools.jar tlc2.TLC -config formal/WatchpostThread.cfg formal/WatchpostThread.tla`).
|
|
53
|
+
|
|
54
|
+
## Interpreting Results & Upkeep Rules
|
|
55
|
+
|
|
56
|
+
- **Never weaken an invariant** or shrink bounds solely to make TLC pass.
|
|
57
|
+
- **Replay every violation:** If TLC reports a broken invariant, replay the exact sequence of actions against `WatchpostEngine` and `WatchpostStore` in an isolated test using temporary SQLite DBs under `/tmp`. If the sequence cannot occur in real Python execution, fix the TLA+ model (model drift) rather than product code.
|
|
58
|
+
- **Separate changes:** Keep verification updates (`formal/`, this skill) in their own clean commit separate from product bug fixes.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Report a bug, regression, or unexpected daemon behavior
|
|
4
|
+
title: "[Bug]: "
|
|
5
|
+
labels: bug
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Environment
|
|
9
|
+
- Watchpost version (`watchpost --version` or commit SHA):
|
|
10
|
+
- OS & Python version:
|
|
11
|
+
- Coding agent backend (`claude_code`, `codex`, `gemini_cli`, `antigravity`, `mock`):
|
|
12
|
+
- Channel / notifier involved:
|
|
13
|
+
|
|
14
|
+
## `watchpost doctor` output (redact any paths you don't want public)
|
|
15
|
+
```text
|
|
16
|
+
paste `watchpost doctor --json` output here
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## What happened?
|
|
20
|
+
Clear description of expected vs. actual behavior and steps to reproduce.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest a new adapter, backend capability, or operational enhancement
|
|
4
|
+
title: "[Feature]: "
|
|
5
|
+
labels: enhancement
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Problem / Use Case
|
|
9
|
+
What workflow or platform gap does this solve?
|
|
10
|
+
|
|
11
|
+
## Proposed Design
|
|
12
|
+
- CLI / config changes (if any):
|
|
13
|
+
- Compatibility & autonomy / security implications:
|
|
14
|
+
- Would this fit best inside built-in core (`Apache-2.0`) or as a `watchpost.sdk` external plugin?
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test-and-build:
|
|
11
|
+
name: ${{ matrix.os }} · Python ${{ matrix.python-version }}
|
|
12
|
+
runs-on: ${{ matrix.os }}
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
os: [ubuntu-latest, macos-latest]
|
|
17
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Check out repository
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Install uv
|
|
24
|
+
uses: astral-sh/setup-uv@v5
|
|
25
|
+
with:
|
|
26
|
+
python-version: ${{ matrix.python-version }}
|
|
27
|
+
|
|
28
|
+
- name: Sync dependencies
|
|
29
|
+
run: uv sync --all-extras
|
|
30
|
+
|
|
31
|
+
- name: Lint (syntax and undefined names)
|
|
32
|
+
run: uvx ruff check --select E9,F src tests
|
|
33
|
+
|
|
34
|
+
- name: Run test suite
|
|
35
|
+
run: uv run pytest -q
|
|
36
|
+
|
|
37
|
+
- name: Build sdist and wheel
|
|
38
|
+
run: uv build
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch: {}
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
name: Build sdist and wheel
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- name: Check out repository
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Install uv
|
|
17
|
+
uses: astral-sh/setup-uv@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.12"
|
|
20
|
+
|
|
21
|
+
- name: Sync dependencies
|
|
22
|
+
run: uv sync --all-extras
|
|
23
|
+
|
|
24
|
+
- name: Lint (syntax and undefined names)
|
|
25
|
+
run: uvx ruff check --select E9,F src tests
|
|
26
|
+
|
|
27
|
+
- name: Run test suite
|
|
28
|
+
run: uv run pytest -q
|
|
29
|
+
|
|
30
|
+
- name: Build distributions
|
|
31
|
+
run: uv build
|
|
32
|
+
|
|
33
|
+
- name: Upload dist artifacts
|
|
34
|
+
uses: actions/upload-artifact@v4
|
|
35
|
+
with:
|
|
36
|
+
name: dist
|
|
37
|
+
path: dist/
|
|
38
|
+
|
|
39
|
+
publish:
|
|
40
|
+
name: Publish to PyPI
|
|
41
|
+
needs: build
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
environment:
|
|
44
|
+
name: pypi
|
|
45
|
+
url: https://pypi.org/p/watchpost-agent
|
|
46
|
+
permissions:
|
|
47
|
+
id-token: write
|
|
48
|
+
steps:
|
|
49
|
+
- name: Download dist artifacts
|
|
50
|
+
uses: actions/download-artifact@v4
|
|
51
|
+
with:
|
|
52
|
+
name: dist
|
|
53
|
+
path: dist/
|
|
54
|
+
|
|
55
|
+
- name: Publish distributions to PyPI
|
|
56
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Watchpost Working Agreement
|
|
2
|
+
|
|
3
|
+
Read [CONTRIBUTING.md](CONTRIBUTING.md) and [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) before making substantial changes.
|
|
4
|
+
|
|
5
|
+
## Standard Verification Gate
|
|
6
|
+
|
|
7
|
+
Before committing or opening a PR, run Watchpost's linter, test suite, and package build:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
uvx ruff check --select E9,F src tests
|
|
11
|
+
uv run pytest -q
|
|
12
|
+
uv build
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Major-Update Formal State-Machine Check
|
|
16
|
+
|
|
17
|
+
Before finalizing a major update or any change touching thread states, `pending_go` approval gates, workspace turn locking, or crash recovery (`src/watchpost/engine.py`, `src/watchpost/store.py`, `src/watchpost/backends/`):
|
|
18
|
+
|
|
19
|
+
1. Run `.agents/skills/verify-thread-lifecycle/SKILL.md` (mirrored at `.claude/skills/verify-thread-lifecycle/SKILL.md`).
|
|
20
|
+
2. If covered files changed past the skill's recorded `sync_commit`, update `formal/WatchpostThread.tla` using `maintain-formal-verification-skill` before trusting a pass, and output charts/reports under `/tmp` only.
|
|
21
|
+
3. Replay any TLC counterexample against real `WatchpostEngine` + `WatchpostStore` before treating it as a code bug or model drift.
|
|
22
|
+
|
|
23
|
+
## Licensing & Privacy Boundaries
|
|
24
|
+
|
|
25
|
+
- Core stays strictly `Apache-2.0` (official APIs, local CLIs, and out-of-process JSON stdio plugins only).
|
|
26
|
+
- Keep tests/fixtures offline (`MockAgentBackend`, `SimulatorAdapter`, `httpx.MockTransport`) with zero user secrets or machine-specific paths.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to Watchpost (`watchpost-agent`) are documented in this file.
|
|
4
|
+
|
|
5
|
+
## v0.4.1 — Thread & Approval Lifecycle Hardening
|
|
6
|
+
|
|
7
|
+
- **Per-Thread & Workspace Concurrency Safety:** Serialize per-thread turns (`_get_thread_lock`) and enforce writer-preferring shared/exclusive workspace turn locking (`_AsyncRWLock`) so approved writable `"go"` turns never overlap with read-only follow-ups and inbound batches never steer placeholder `pending_<id>` refs.
|
|
8
|
+
- **Atomic Approval Claims & Crash Recovery:** Make `claim_pending_go` atomically transition `pending_go = 0` and `status = 'active'`, format owner-action payloads before claiming with post-claim error recovery in `handle_owner_action`, prevent placeholder refs from overwriting committed non-placeholder refs in `create_or_update_thread`, and recover orphaned `awaiting_go` rows in `recover_stale_active_threads` and `dismiss_all_pending_go`.
|
|
9
|
+
- **Formal Verification & Tests:** Add TLA+/TLC thread-lifecycle verification (`formal/WatchpostThread.tla` + `.agents/skills/verify-thread-lifecycle`) and regression coverage (`tests/test_formal_state_regressions.py`).
|
|
10
|
+
|
|
11
|
+
## v0.4.0 — Launch Readiness & Security Hardening
|
|
12
|
+
|
|
13
|
+
### Security & Agent Safety
|
|
14
|
+
- **Local Control API Auth & Hardening:** Automatically generate a `0o600` installation bearer token (`api.token` next to SQLite DB) required on all `/api/*` endpoints (except signed `/api/webhooks/*` and unauthenticated `/healthz`). Enforce loopback `Host` header allowlist (`403` on DNS-rebinding attempts), reject browser cross-origin `Origin` headers (`403`), and add restrictive security headers (`nosniff`, `DENY`, `default-src 'none'`).
|
|
15
|
+
- **Strict Approval Gates:** Return `409 Conflict` on `POST /api/threads/{id}/approve` when `pending_go` is `False`; reject plain `"go"` / `wp:go:<id>` / `#N go` approvals when no thread has `pending_go`; remove overly broad `"同意"` approval token so casual agreement never triggers code edits.
|
|
16
|
+
- **Per-Channel CLI Sandbox Enforcement:** Enforce `read-only` / `workspace-write` (`codex` `--sandbox` & `-c sandbox_mode`), `plan` / `acceptEdits` (`claude_code`), and `plan` / `auto_edit` (`gemini_cli`) across both initial and steering turns based on channel autonomy and verified `"go"` approval. Refuse automatic backup failover on writable `auto_fix` or `approved_go` turns to prevent duplicate edits.
|
|
17
|
+
- **Process-Tree Timeout Termination:** Launch subprocesses in their own session (`start_new_session=True` on POSIX) and terminate the entire process group via `kill_process_tree` on timeout.
|
|
18
|
+
- **Prompt Injection Fencing:** Fence untrusted external chat inputs, reply previews, and cross-channel recall inside randomized per-prompt `<untrusted_chat_data_{nonce}>` blocks and neutralize forged `[Watchpost — ...]` / `The owner explicitly APPROVED` markers.
|
|
19
|
+
- **Secret Redaction & File Permissions:** Scrub Telegram `bot<id>:<secret>`, HTTP `Bearer` tokens, and Slack `xox*-` tokens across logs (`RedactingLogFilter`), HTTP exceptions, and error messages; tighten SQLite DB/WAL/SHM (`0o600`), parent dirs (`0o700`), config (`0o600`), and optional `.env` (`0o600`).
|
|
20
|
+
|
|
21
|
+
### Packaging, Legal & Onboarding
|
|
22
|
+
- Add canonical Apache-2.0 `LICENSE`.
|
|
23
|
+
- Publish distribution metadata as `watchpost-agent` (`0.4.0`) keeping the `watchpost` CLI entry point, excluding `site/` and `uv.lock` from source distributions, and converting the bundled Telegram avatar to JPEG (`avatar.jpg`).
|
|
24
|
+
- Default setup, CLI flags (`--lang`), and engine config to English (`en`) with `slack` fallback channel recommendation, strict platform/notifier validation, sibling `.env` credential support, and read-only `watchpost doctor` checks (placeholder resolution, DB permissions, daemon lock/port conflict, per-channel workspaces, and `--live` Telegram `getWebhookInfo` conflict check).
|
|
25
|
+
- Add GitHub Actions CI matrix (`ubuntu-latest` + `macos-latest`, Python 3.11–3.13) plus `CONTRIBUTING.md`, `SECURITY.md`, and issue templates.
|
|
26
|
+
|
|
27
|
+
### Telegram UX & Daemon Reliability
|
|
28
|
+
- Nonce-verified private chat pairing in `watchpost telegram-setup` (`https://t.me/<bot>?start=<nonce>`), bearer-authenticated hot reload, and preserved `${VAR}` placeholders in `config.json`.
|
|
29
|
+
- Bot-token-scoped update cursor (`telegram_owner_update_offset:<hash>`) with deferred commit after owner action dispatch, exponential backoff on HTTP `409`/`429`/`5xx`/transport failures, and explicit handling of `/start`, unknown `/cmd` vs POSIX file paths, bare `#N` usage hints, `/list` channel + relative age + 24h index expiry, and clear guidance when `personal_workspace_dir` is unset.
|
|
30
|
+
- Isolated `webhook_port` listener (`create_webhook_app`) exposing only `/healthz` and signed webhook endpoints, `fcntl.flock` single-instance lock (`watchpost.lock`), periodic media pruning (`prune_old_media`), `asyncio.to_thread` Whisper transcription, bounded concurrency (`max_concurrent_turns` + per-workspace write locks), debouncer error surfacing, and `watchpost service {install,status,uninstall}` for `launchd` and `systemd --user`.
|
|
31
|
+
|
|
32
|
+
## v0.3.0 — Multi-Platform Adapters, Hot Reload & Bridge Showcase
|
|
33
|
+
- Native inbound & outbound support for Feishu/Lark, Slack, Discord, Telegram (shared `TelegramUpdateHub`), DingTalk, WeCom, macOS iMessage, ntfy, Bark, and Pushover.
|
|
34
|
+
- 2-bucket group context engine, Quiet Hours + Morning Briefing, cross-channel incident memory, `watchpost.sdk` external plugin protocol, interactive Web `sandbox-ui`, and zero-downtime `POST /api/reload`.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Contributing to Watchpost
|
|
2
|
+
|
|
3
|
+
Thank you for helping improve Watchpost (`watchpost-agent`).
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/Popcornnnnnnnn/watchpost.git
|
|
9
|
+
cd watchpost
|
|
10
|
+
uv sync --all-extras
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Run the test suite and linter before submitting changes:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
uvx ruff check --select E9,F src tests
|
|
17
|
+
uv run pytest -q
|
|
18
|
+
uv build
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Architecture & Licensing Rules
|
|
22
|
+
|
|
23
|
+
1. **Apache-2.0 Core:** Watchpost is licensed under the Apache License, Version 2.0 (`LICENSE`).
|
|
24
|
+
2. **External Copyleft Boundary:** Never import copyleft-licensed packages or unofficial desktop bridges directly into `src/watchpost/`. Out-of-process bridges communicate solely over the JSON stdio `watchpost.sdk` protocol (`watchpost plugins scaffold`).
|
|
25
|
+
3. **Read-Only Work Channels by Default:** Channel adapters must default to passive read/triage and never send replies to external channels unless explicitly triggered by the owner's local `"go"` flow or copy action.
|
|
26
|
+
4. **No Live User Secrets in Repo:** Tests and fixtures must run offline using `MockAgentBackend`, `SimulatorAdapter`, synthetic phone/user fixtures, or `httpx.MockTransport`.
|
|
27
|
+
|
|
28
|
+
## Pull Requests
|
|
29
|
+
|
|
30
|
+
- Keep each PR scoped cleanly with tests covering new behaviors or bug fixes.
|
|
31
|
+
- Ensure `ruff`, `pytest`, and `uv build` pass cleanly on your branch.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|